Skip to content

Commit

Permalink
feat: experimental plugin release
Browse files Browse the repository at this point in the history
  • Loading branch information
tomzemp authored Dec 20, 2023
2 parents d61be79 + be215b2 commit f5cca86
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
6 changes: 4 additions & 2 deletions docs/components/Plugin.md
Original file line number Diff line number Diff line change
@@ -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 = () => (
Expand Down
10 changes: 8 additions & 2 deletions runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions runtime/src/experimental.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* this is experimental and the API is unstable
*/
export { Plugin } from '@dhis2/app-service-plugin'
2 changes: 0 additions & 2 deletions runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,4 @@ export {
clearSensitiveCaches,
} from '@dhis2/app-service-offline'

export { Plugin } from '@dhis2/app-service-plugin'

export { Provider } from './Provider'

0 comments on commit f5cca86

Please sign in to comment.