From 25f02a6c97733b79ff1aed5e8c4c1726c16144fe Mon Sep 17 00:00:00 2001 From: Thomas Zemp Date: Wed, 20 Dec 2023 11:47:59 +0100 Subject: [PATCH 1/2] feat: plugin experimental export --- runtime/package.json | 10 ++++++++-- runtime/src/experimental.ts | 4 ++++ runtime/src/index.ts | 2 -- 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 runtime/src/experimental.ts diff --git a/runtime/package.json b/runtime/package.json index 8b03d18f8..b1c4f9ab1 100644 --- a/runtime/package.json +++ b/runtime/package.json @@ -6,8 +6,14 @@ "module": "./build/es/index.js", "types": "./build/types/index.d.ts", "exports": { - "import": "./build/es/index.js", - "require": "./build/cjs/index.js" + ".": { + "import": "./build/es/index.js", + "require": "./build/cjs/index.js" + }, + "./experimental": { + "import": "./build/es/experimental.js", + "require": "./build/cjs/experimental.js" + } }, "repository": { "type": "git", diff --git a/runtime/src/experimental.ts b/runtime/src/experimental.ts new file mode 100644 index 000000000..d6c425c49 --- /dev/null +++ b/runtime/src/experimental.ts @@ -0,0 +1,4 @@ +/** + * this is experimental and the API is unstable + */ +export { Plugin } from '@dhis2/app-service-plugin' diff --git a/runtime/src/index.ts b/runtime/src/index.ts index 3c4ab7cd4..5bf44ba37 100644 --- a/runtime/src/index.ts +++ b/runtime/src/index.ts @@ -23,6 +23,4 @@ export { clearSensitiveCaches, } from '@dhis2/app-service-offline' -export { Plugin } from '@dhis2/app-service-plugin' - export { Provider } from './Provider' From be215b2c292e451662b72043f20921d42bf36d33 Mon Sep 17 00:00:00 2001 From: Thomas Zemp Date: Wed, 20 Dec 2023 13:12:36 +0100 Subject: [PATCH 2/2] fix: plugin experimental docs --- docs/components/Plugin.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/components/Plugin.md b/docs/components/Plugin.md index c7df09be4..e8ea7f528 100644 --- a/docs/components/Plugin.md +++ b/docs/components/Plugin.md @@ -1,13 +1,15 @@ # Plugin Component +_NOTE:_ This component is experimental and is available for import from `@dhis2/app-runtime/experimental`. The api for this component is not guaranteed to be stable. + A wrapper that creates an iframe for a specified plugin and establishes a two-way communication channel with said plugin, allowing you to pass props (including callbacks between an app and a plugin). Note that the plugin must be built using the app-platform with entryPoints.plugin specified in the d2.config.js file. ## Basic Usage (Defining a plugin within an app) -Within an app you can specify a plugin (either by providing its short name `pluginShortName`, or by specifying a URL directly (`pluginSource`). If you have provided `pluginSource`, this will take precedence (Note: lookup logic is TBD? Should we allow a URL only in development mode, for example?). +Within an app you can specify a plugin (either by providing its short name `pluginShortName`, or by specifying a URL directly (`pluginSource`). If you have provided `pluginSource`, this will take precedence. ```jsx -import { Plugin } from '@dhis2/app-runtime' +import { Plugin } from '@dhis2/app-runtime/experimental' // within the app const MyApp = () => (