@dxos/app-framework 0.7.5-main.499c70c → 0.7.5-main.5ae2ba8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/app-graph-builder-S4MYSHQA.mjs +137 -0
- package/dist/lib/browser/app-graph-builder-S4MYSHQA.mjs.map +7 -0
- package/dist/lib/browser/chunk-BCMEJONP.mjs +1432 -0
- package/dist/lib/browser/chunk-BCMEJONP.mjs.map +7 -0
- package/dist/lib/browser/chunk-QS4J6O47.mjs +285 -0
- package/dist/lib/browser/chunk-QS4J6O47.mjs.map +7 -0
- package/dist/lib/browser/chunk-SRZH2PQ2.mjs +32 -0
- package/dist/lib/browser/chunk-SRZH2PQ2.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +119 -642
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-dispatcher-GFBH7T2J.mjs +11 -0
- package/dist/lib/browser/intent-resolver-KAFM7CQH.mjs +39 -0
- package/dist/lib/browser/intent-resolver-KAFM7CQH.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/store-L3VRR7II.mjs +29 -0
- package/dist/lib/browser/store-L3VRR7II.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +77 -0
- package/dist/lib/browser/testing/index.mjs.map +7 -0
- package/dist/lib/browser/worker.mjs +77 -0
- package/dist/lib/node/app-graph-builder-VMHWFCTP.cjs +146 -0
- package/dist/lib/node/app-graph-builder-VMHWFCTP.cjs.map +7 -0
- package/dist/lib/node/chunk-7Y6KJ3OK.cjs +1466 -0
- package/dist/lib/node/chunk-7Y6KJ3OK.cjs.map +7 -0
- package/dist/lib/node/chunk-B65NJEIJ.cjs +308 -0
- package/dist/lib/node/chunk-B65NJEIJ.cjs.map +7 -0
- package/dist/lib/node/{chunk-FCMHRU3M.cjs → chunk-VCIHQZSN.cjs} +23 -35
- package/dist/lib/node/chunk-VCIHQZSN.cjs.map +7 -0
- package/dist/lib/node/index.cjs +125 -665
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/{plugin-settings-W6UHMH5M.cjs → intent-dispatcher-PRCC4KZT.cjs} +10 -14
- package/dist/lib/node/intent-dispatcher-PRCC4KZT.cjs.map +7 -0
- package/dist/lib/node/intent-resolver-OZDKCHPW.cjs +46 -0
- package/dist/lib/node/intent-resolver-OZDKCHPW.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/store-BVUKNVKL.cjs +44 -0
- package/dist/lib/node/store-BVUKNVKL.cjs.map +7 -0
- package/dist/lib/node/testing/index.cjs +101 -0
- package/dist/lib/node/testing/index.cjs.map +7 -0
- package/dist/lib/node/worker.cjs +99 -0
- package/dist/lib/node/worker.cjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-XHI5IIXQ.mjs +138 -0
- package/dist/lib/node-esm/app-graph-builder-XHI5IIXQ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CBT75GCX.mjs +34 -0
- package/dist/lib/node-esm/chunk-CBT75GCX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-JDAHZRYQ.mjs +286 -0
- package/dist/lib/node-esm/chunk-JDAHZRYQ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-TVIR2PHY.mjs +1434 -0
- package/dist/lib/node-esm/chunk-TVIR2PHY.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +119 -642
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-dispatcher-LGACN32C.mjs +12 -0
- package/dist/lib/node-esm/intent-resolver-RBNG76ZX.mjs +40 -0
- package/dist/lib/node-esm/intent-resolver-RBNG76ZX.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/store-PHTOEREN.mjs +30 -0
- package/dist/lib/node-esm/store-PHTOEREN.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +78 -0
- package/dist/lib/node-esm/testing/index.mjs.map +7 -0
- package/dist/lib/node-esm/worker.mjs +78 -0
- package/dist/types/src/App.d.ts +22 -13
- package/dist/types/src/App.d.ts.map +1 -1
- package/dist/types/src/common/capabilities.d.ts +304 -0
- package/dist/types/src/common/capabilities.d.ts.map +1 -0
- package/dist/types/src/common/events.d.ts +52 -0
- package/dist/types/src/common/events.d.ts.map +1 -0
- package/dist/types/src/common/file.d.ts +14 -0
- package/dist/types/src/common/file.d.ts.map +1 -0
- package/dist/types/src/common/graph.d.ts +21 -0
- package/dist/types/src/common/graph.d.ts.map +1 -0
- package/dist/types/src/common/index.d.ts +8 -0
- package/dist/types/src/common/index.d.ts.map +1 -0
- package/dist/types/src/common/layout.d.ts +262 -0
- package/dist/types/src/common/layout.d.ts.map +1 -0
- package/dist/types/src/{plugins/plugin-surface/SurfaceContext.d.ts → common/surface.d.ts} +12 -29
- package/dist/types/src/common/surface.d.ts.map +1 -0
- package/dist/types/src/common/translations.d.ts +11 -0
- package/dist/types/src/common/translations.d.ts.map +1 -0
- package/dist/types/src/core/capabilities.d.ts +94 -0
- package/dist/types/src/core/capabilities.d.ts.map +1 -0
- package/dist/types/src/core/capabilities.test.d.ts +2 -0
- package/dist/types/src/core/capabilities.test.d.ts.map +1 -0
- package/dist/types/src/core/events.d.ts +58 -0
- package/dist/types/src/core/events.d.ts.map +1 -0
- package/dist/types/src/core/index.d.ts +5 -0
- package/dist/types/src/core/index.d.ts.map +1 -0
- package/dist/types/src/core/manager.d.ts +119 -0
- package/dist/types/src/core/manager.d.ts.map +1 -0
- package/dist/types/src/core/manager.test.d.ts +2 -0
- package/dist/types/src/core/manager.test.d.ts.map +1 -0
- package/dist/types/src/core/plugin.d.ts +97 -0
- package/dist/types/src/core/plugin.d.ts.map +1 -0
- package/dist/types/src/helpers.d.ts +10 -0
- package/dist/types/src/helpers.d.ts.map +1 -0
- package/dist/types/src/helpers.test.d.ts +2 -0
- package/dist/types/src/helpers.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +5 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/playground/debug/Debug.d.ts +5 -0
- package/dist/types/src/playground/debug/Debug.d.ts.map +1 -0
- package/dist/types/src/playground/debug/index.d.ts +2 -0
- package/dist/types/src/playground/debug/index.d.ts.map +1 -0
- package/dist/types/src/playground/debug/plugin.d.ts +2 -0
- package/dist/types/src/playground/debug/plugin.d.ts.map +1 -0
- package/dist/types/src/playground/generator/Main.d.ts +5 -0
- package/dist/types/src/playground/generator/Main.d.ts.map +1 -0
- package/dist/types/src/playground/generator/Toolbar.d.ts +5 -0
- package/dist/types/src/playground/generator/Toolbar.d.ts.map +1 -0
- package/dist/types/src/playground/generator/generator.d.ts +7 -0
- package/dist/types/src/playground/generator/generator.d.ts.map +1 -0
- package/dist/types/src/playground/generator/index.d.ts +3 -0
- package/dist/types/src/playground/generator/index.d.ts.map +1 -0
- package/dist/types/src/playground/generator/plugin.d.ts +2 -0
- package/dist/types/src/playground/generator/plugin.d.ts.map +1 -0
- package/dist/types/src/playground/layout/Layout.d.ts +8 -0
- package/dist/types/src/playground/layout/Layout.d.ts.map +1 -0
- package/dist/types/src/playground/layout/index.d.ts +2 -0
- package/dist/types/src/playground/layout/index.d.ts.map +1 -0
- package/dist/types/src/playground/layout/plugin.d.ts +2 -0
- package/dist/types/src/playground/layout/plugin.d.ts.map +1 -0
- package/dist/types/src/playground/logger/Toolbar.d.ts +5 -0
- package/dist/types/src/playground/logger/Toolbar.d.ts.map +1 -0
- package/dist/types/src/playground/logger/index.d.ts +2 -0
- package/dist/types/src/playground/logger/index.d.ts.map +1 -0
- package/dist/types/src/playground/logger/plugin.d.ts +2 -0
- package/dist/types/src/playground/logger/plugin.d.ts.map +1 -0
- package/dist/types/src/playground/logger/schema.d.ts +13 -0
- package/dist/types/src/playground/logger/schema.d.ts.map +1 -0
- package/dist/types/src/playground/playground.stories.d.ts +9 -0
- package/dist/types/src/playground/playground.stories.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts +2 -0
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/actions.d.ts +23 -0
- package/dist/types/src/plugin-intent/actions.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/errors.d.ts +16 -0
- package/dist/types/src/plugin-intent/errors.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/index.d.ts +5 -0
- package/dist/types/src/plugin-intent/index.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +113 -0
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts.map +1 -0
- package/dist/types/src/{plugins/plugin-intent → plugin-intent}/intent.d.ts +8 -28
- package/dist/types/src/plugin-intent/intent.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +2 -0
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/actions.d.ts +27 -0
- package/dist/types/src/plugin-settings/actions.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts +197 -0
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/index.d.ts +3 -0
- package/dist/types/src/plugin-settings/index.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/intent-resolver.d.ts +4 -0
- package/dist/types/src/plugin-settings/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/store.d.ts +5 -0
- package/dist/types/src/plugin-settings/store.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/translations.d.ts +11 -0
- package/dist/types/src/plugin-settings/translations.d.ts.map +1 -0
- package/dist/types/src/{plugins/plugin-surface → react}/ErrorBoundary.d.ts +1 -1
- package/dist/types/src/react/ErrorBoundary.d.ts.map +1 -0
- package/dist/types/src/{plugins/plugin-intent → react}/IntentContext.d.ts +2 -2
- package/dist/types/src/react/IntentContext.d.ts.map +1 -0
- package/dist/types/src/react/PluginManagerProvider.d.ts +10 -0
- package/dist/types/src/react/PluginManagerProvider.d.ts.map +1 -0
- package/dist/types/src/react/Surface.d.ts +12 -0
- package/dist/types/src/react/Surface.d.ts.map +1 -0
- package/dist/types/src/react/Surface.stories.d.ts +15 -0
- package/dist/types/src/react/Surface.stories.d.ts.map +1 -0
- package/dist/types/src/react/common.d.ts +13 -0
- package/dist/types/src/react/common.d.ts.map +1 -0
- package/dist/types/src/react/index.d.ts +7 -0
- package/dist/types/src/react/index.d.ts.map +1 -0
- package/dist/types/src/react/useCapabilities.d.ts +13 -0
- package/dist/types/src/react/useCapabilities.d.ts.map +1 -0
- package/dist/types/src/react/useIntentResolver.d.ts +3 -0
- package/dist/types/src/react/useIntentResolver.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/withPluginManager.d.ts +12 -0
- package/dist/types/src/testing/withPluginManager.d.ts.map +1 -0
- package/dist/types/src/testing/withPluginManager.stories.d.ts +5 -0
- package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -0
- package/dist/types/src/worker.d.ts +4 -0
- package/dist/types/src/worker.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +40 -19
- package/project.json +5 -3
- package/src/App.tsx +140 -34
- package/src/common/capabilities.ts +101 -0
- package/src/common/events.ts +77 -0
- package/src/common/file.ts +22 -0
- package/src/common/graph.ts +30 -0
- package/src/{plugins/common → common}/index.ts +3 -2
- package/src/common/layout.ts +238 -0
- package/src/{plugins/plugin-surface/SurfaceContext.ts → common/surface.ts} +6 -37
- package/src/common/translations.ts +17 -0
- package/src/core/capabilities.test.ts +116 -0
- package/src/core/capabilities.ts +222 -0
- package/src/core/events.ts +58 -0
- package/src/core/index.ts +8 -0
- package/src/core/manager.test.ts +516 -0
- package/src/core/manager.ts +511 -0
- package/src/core/plugin.ts +131 -0
- package/src/helpers.test.ts +97 -0
- package/src/helpers.ts +45 -0
- package/src/index.ts +6 -3
- package/src/playground/debug/Debug.tsx +39 -0
- package/src/playground/debug/index.ts +5 -0
- package/src/playground/debug/plugin.ts +17 -0
- package/src/playground/generator/Main.tsx +71 -0
- package/src/playground/generator/Toolbar.tsx +46 -0
- package/src/playground/generator/generator.ts +48 -0
- package/src/playground/generator/index.ts +6 -0
- package/src/playground/generator/plugin.ts +23 -0
- package/src/playground/layout/Layout.tsx +33 -0
- package/src/playground/layout/index.ts +5 -0
- package/src/playground/layout/plugin.ts +17 -0
- package/src/playground/logger/Toolbar.tsx +29 -0
- package/src/playground/logger/index.ts +5 -0
- package/src/playground/logger/plugin.ts +36 -0
- package/src/playground/logger/schema.ts +12 -0
- package/src/playground/playground.stories.tsx +34 -0
- package/src/plugin-intent/IntentPlugin.tsx +20 -0
- package/src/plugin-intent/actions.ts +22 -0
- package/src/plugin-intent/errors.ts +39 -0
- package/src/plugin-intent/index.ts +8 -0
- package/src/{plugins/plugin-intent → plugin-intent}/intent-dispatcher.test.ts +83 -63
- package/src/{plugins/plugin-intent → plugin-intent}/intent-dispatcher.ts +118 -95
- package/src/{plugins/plugin-intent → plugin-intent}/intent.ts +10 -26
- package/src/plugin-settings/SettingsPlugin.ts +35 -0
- package/src/plugin-settings/actions.ts +27 -0
- package/src/plugin-settings/app-graph-builder.ts +122 -0
- package/src/plugin-settings/index.ts +6 -0
- package/src/plugin-settings/intent-resolver.ts +34 -0
- package/src/plugin-settings/store.ts +30 -0
- package/src/plugin-settings/translations.ts +17 -0
- package/src/{plugins/plugin-intent → react}/IntentContext.tsx +13 -5
- package/src/react/PluginManagerProvider.ts +22 -0
- package/src/react/Surface.stories.tsx +96 -0
- package/src/react/Surface.tsx +75 -0
- package/src/react/common.ts +12 -0
- package/src/react/index.ts +10 -0
- package/src/react/useCapabilities.ts +40 -0
- package/src/react/useIntentResolver.ts +22 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/withPluginManager.stories.tsx +47 -0
- package/src/testing/withPluginManager.tsx +91 -0
- package/src/worker.ts +11 -0
- package/tsconfig.json +19 -13
- package/dist/lib/browser/chunk-3E7RY3CE.mjs +0 -72
- package/dist/lib/browser/chunk-3E7RY3CE.mjs.map +0 -7
- package/dist/lib/browser/chunk-QG25ZU2N.mjs +0 -320
- package/dist/lib/browser/chunk-QG25ZU2N.mjs.map +0 -7
- package/dist/lib/browser/chunk-SPDTXTOV.mjs +0 -163
- package/dist/lib/browser/chunk-SPDTXTOV.mjs.map +0 -7
- package/dist/lib/browser/chunk-WBOXEHBE.mjs +0 -51
- package/dist/lib/browser/chunk-WBOXEHBE.mjs.map +0 -7
- package/dist/lib/browser/plugin-intent-T7Y3MJ5C.mjs +0 -32
- package/dist/lib/browser/plugin-settings-5U2L2NRU.mjs +0 -15
- package/dist/lib/browser/plugin-surface-OKPF3EQI.mjs +0 -24
- package/dist/lib/node/chunk-BW3RNEVI.cjs +0 -185
- package/dist/lib/node/chunk-BW3RNEVI.cjs.map +0 -7
- package/dist/lib/node/chunk-FCMHRU3M.cjs.map +0 -7
- package/dist/lib/node/chunk-QBM42OQ6.cjs +0 -97
- package/dist/lib/node/chunk-QBM42OQ6.cjs.map +0 -7
- package/dist/lib/node/chunk-VWHAALIN.cjs +0 -344
- package/dist/lib/node/chunk-VWHAALIN.cjs.map +0 -7
- package/dist/lib/node/plugin-intent-F3TQZIUR.cjs +0 -53
- package/dist/lib/node/plugin-intent-F3TQZIUR.cjs.map +0 -7
- package/dist/lib/node/plugin-settings-W6UHMH5M.cjs.map +0 -7
- package/dist/lib/node/plugin-surface-CCSIONYW.cjs +0 -45
- package/dist/lib/node/plugin-surface-CCSIONYW.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-3T5UIJY3.mjs +0 -53
- package/dist/lib/node-esm/chunk-3T5UIJY3.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4GX7V5ZE.mjs +0 -164
- package/dist/lib/node-esm/chunk-4GX7V5ZE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CFOUYXQ6.mjs +0 -321
- package/dist/lib/node-esm/chunk-CFOUYXQ6.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs +0 -74
- package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs.map +0 -7
- package/dist/lib/node-esm/plugin-intent-W2HQC6LC.mjs +0 -33
- package/dist/lib/node-esm/plugin-settings-H5RHNFVC.mjs +0 -16
- package/dist/lib/node-esm/plugin-settings-H5RHNFVC.mjs.map +0 -7
- package/dist/lib/node-esm/plugin-surface-V3YET3UL.mjs +0 -25
- package/dist/lib/node-esm/plugin-surface-V3YET3UL.mjs.map +0 -7
- package/dist/types/src/plugins/common/file.d.ts +0 -22
- package/dist/types/src/plugins/common/file.d.ts.map +0 -1
- package/dist/types/src/plugins/common/graph.d.ts +0 -51
- package/dist/types/src/plugins/common/graph.d.ts.map +0 -1
- package/dist/types/src/plugins/common/index.d.ts +0 -7
- package/dist/types/src/plugins/common/index.d.ts.map +0 -1
- package/dist/types/src/plugins/common/layout.d.ts +0 -176
- package/dist/types/src/plugins/common/layout.d.ts.map +0 -1
- package/dist/types/src/plugins/common/metadata.d.ts +0 -16
- package/dist/types/src/plugins/common/metadata.d.ts.map +0 -1
- package/dist/types/src/plugins/common/navigation.d.ts +0 -243
- package/dist/types/src/plugins/common/navigation.d.ts.map +0 -1
- package/dist/types/src/plugins/common/translations.d.ts +0 -22
- package/dist/types/src/plugins/common/translations.d.ts.map +0 -1
- package/dist/types/src/plugins/helpers.d.ts +0 -41
- package/dist/types/src/plugins/helpers.d.ts.map +0 -1
- package/dist/types/src/plugins/index.d.ts +0 -7
- package/dist/types/src/plugins/index.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts +0 -16
- package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts +0 -14
- package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-host/PluginContext.d.ts +0 -47
- package/dist/types/src/plugins/plugin-host/PluginContext.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-host/index.d.ts +0 -6
- package/dist/types/src/plugins/plugin-host/index.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-host/plugin.d.ts +0 -104
- package/dist/types/src/plugins/plugin-host/plugin.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-host/plugin.test.d.ts +0 -35
- package/dist/types/src/plugins/plugin-host/plugin.test.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/IntentContext.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts +0 -8
- package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/index.d.ts +0 -7
- package/dist/types/src/plugins/plugin-intent/index.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/intent-dispatcher.d.ts +0 -107
- package/dist/types/src/plugins/plugin-intent/intent-dispatcher.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/intent-dispatcher.test.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/intent.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/meta.d.ts +0 -6
- package/dist/types/src/plugins/plugin-intent/meta.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/provides.d.ts +0 -16
- package/dist/types/src/plugins/plugin-intent/provides.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts +0 -4
- package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-settings/index.d.ts +0 -4
- package/dist/types/src/plugins/plugin-settings/index.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-settings/meta.d.ts +0 -5
- package/dist/types/src/plugins/plugin-settings/meta.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-settings/provides.d.ts +0 -26
- package/dist/types/src/plugins/plugin-settings/provides.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/ErrorBoundary.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/Surface.d.ts +0 -7
- package/dist/types/src/plugins/plugin-surface/Surface.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/SurfaceContext.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts +0 -7
- package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/helpers.d.ts +0 -21
- package/dist/types/src/plugins/plugin-surface/helpers.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/index.d.ts +0 -8
- package/dist/types/src/plugins/plugin-surface/index.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/meta.d.ts +0 -5
- package/dist/types/src/plugins/plugin-surface/meta.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/provides.d.ts +0 -17
- package/dist/types/src/plugins/plugin-surface/provides.d.ts.map +0 -1
- package/src/plugins/common/file.ts +0 -36
- package/src/plugins/common/graph.ts +0 -70
- package/src/plugins/common/layout.ts +0 -173
- package/src/plugins/common/metadata.ts +0 -29
- package/src/plugins/common/navigation.ts +0 -214
- package/src/plugins/common/translations.ts +0 -36
- package/src/plugins/helpers.ts +0 -92
- package/src/plugins/index.ts +0 -11
- package/src/plugins/plugin-host/HostPlugin.tsx +0 -88
- package/src/plugins/plugin-host/PluginContainer.tsx +0 -120
- package/src/plugins/plugin-host/PluginContext.tsx +0 -79
- package/src/plugins/plugin-host/index.ts +0 -12
- package/src/plugins/plugin-host/plugin.test.ts +0 -158
- package/src/plugins/plugin-host/plugin.ts +0 -133
- package/src/plugins/plugin-intent/IntentPlugin.tsx +0 -75
- package/src/plugins/plugin-intent/index.ts +0 -13
- package/src/plugins/plugin-intent/meta.ts +0 -11
- package/src/plugins/plugin-intent/provides.ts +0 -26
- package/src/plugins/plugin-settings/SettingsPlugin.tsx +0 -22
- package/src/plugins/plugin-settings/index.ts +0 -9
- package/src/plugins/plugin-settings/meta.ts +0 -9
- package/src/plugins/plugin-settings/provides.ts +0 -34
- package/src/plugins/plugin-surface/Surface.tsx +0 -62
- package/src/plugins/plugin-surface/SurfacePlugin.tsx +0 -45
- package/src/plugins/plugin-surface/helpers.ts +0 -22
- package/src/plugins/plugin-surface/index.ts +0 -14
- package/src/plugins/plugin-surface/meta.ts +0 -9
- package/src/plugins/plugin-surface/provides.ts +0 -27
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
- /package/dist/lib/browser/{plugin-intent-T7Y3MJ5C.mjs.map → intent-dispatcher-GFBH7T2J.mjs.map} +0 -0
- /package/dist/lib/browser/{plugin-settings-5U2L2NRU.mjs.map → worker.mjs.map} +0 -0
- /package/dist/lib/{browser/plugin-surface-OKPF3EQI.mjs.map → node-esm/intent-dispatcher-LGACN32C.mjs.map} +0 -0
- /package/dist/lib/node-esm/{plugin-intent-W2HQC6LC.mjs.map → worker.mjs.map} +0 -0
- /package/dist/types/src/{plugins/plugin-intent → plugin-intent}/intent-dispatcher.test.d.ts +0 -0
- /package/src/{plugins/plugin-surface → react}/ErrorBoundary.tsx +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { pipe } from 'effect';
|
|
6
|
+
|
|
7
|
+
import { SETTINGS_ID, SETTINGS_KEY, SettingsAction } from './actions';
|
|
8
|
+
import { Capabilities, LayoutAction } from '../common';
|
|
9
|
+
import { contributes } from '../core';
|
|
10
|
+
import { createResolver, createIntent, chain } from '../plugin-intent';
|
|
11
|
+
|
|
12
|
+
export default () =>
|
|
13
|
+
contributes(
|
|
14
|
+
Capabilities.IntentResolver,
|
|
15
|
+
createResolver({
|
|
16
|
+
intent: SettingsAction.Open,
|
|
17
|
+
resolve: ({ plugin }) => {
|
|
18
|
+
const openSettings = createIntent(LayoutAction.SwitchWorkspace, { part: 'workspace', subject: SETTINGS_ID });
|
|
19
|
+
return {
|
|
20
|
+
intents: [
|
|
21
|
+
plugin
|
|
22
|
+
? pipe(
|
|
23
|
+
openSettings,
|
|
24
|
+
chain(LayoutAction.Open, {
|
|
25
|
+
part: 'main',
|
|
26
|
+
subject: [`${SETTINGS_KEY}:${plugin.replaceAll('/', ':')}`],
|
|
27
|
+
}),
|
|
28
|
+
)
|
|
29
|
+
: openSettings,
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
34
|
+
);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { effect } from '@preact/signals-core';
|
|
6
|
+
|
|
7
|
+
import { RootSettingsStore } from '@dxos/local-storage';
|
|
8
|
+
|
|
9
|
+
import { Capabilities } from '../common';
|
|
10
|
+
import { contributes, type PluginsContext } from '../core';
|
|
11
|
+
|
|
12
|
+
export default (context: PluginsContext) => {
|
|
13
|
+
const settingsStore = new RootSettingsStore();
|
|
14
|
+
|
|
15
|
+
let previous: Capabilities.Settings[] = [];
|
|
16
|
+
const unsubscribe = effect(() => {
|
|
17
|
+
const allSettings = context.requestCapabilities(Capabilities.Settings);
|
|
18
|
+
const added = allSettings.filter((setting) => !previous.includes(setting));
|
|
19
|
+
const removed = previous.filter((setting) => !allSettings.includes(setting));
|
|
20
|
+
previous = allSettings;
|
|
21
|
+
added.forEach((setting) => {
|
|
22
|
+
settingsStore.createStore(setting as any);
|
|
23
|
+
});
|
|
24
|
+
removed.forEach((setting) => {
|
|
25
|
+
settingsStore.removeStore(setting.prefix);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return contributes(Capabilities.SettingsStore, settingsStore, () => unsubscribe());
|
|
30
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { SETTINGS_PLUGIN } from './actions';
|
|
6
|
+
|
|
7
|
+
export default [
|
|
8
|
+
{
|
|
9
|
+
'en-US': {
|
|
10
|
+
[SETTINGS_PLUGIN]: {
|
|
11
|
+
'open settings label': 'Open settings',
|
|
12
|
+
'app settings label': 'Settings',
|
|
13
|
+
'custom plugins label': 'Plugins',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
];
|
|
@@ -7,7 +7,9 @@ import { type Context, createContext, useContext, type Provider, useEffect } fro
|
|
|
7
7
|
import { raise } from '@dxos/debug';
|
|
8
8
|
import { pick } from '@dxos/util';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { usePluginManager } from './PluginManagerProvider';
|
|
11
|
+
import { Capabilities } from '../common';
|
|
12
|
+
import { type AnyIntentResolver, type IntentContext } from '../plugin-intent';
|
|
11
13
|
|
|
12
14
|
const IntentContext: Context<IntentContext | undefined> = createContext<IntentContext | undefined>(undefined);
|
|
13
15
|
|
|
@@ -16,11 +18,17 @@ export const useIntentDispatcher = (): Pick<IntentContext, 'dispatch' | 'dispatc
|
|
|
16
18
|
return pick(context, ['dispatch', 'dispatchPromise']);
|
|
17
19
|
};
|
|
18
20
|
|
|
19
|
-
export const useIntentResolver = (
|
|
20
|
-
const
|
|
21
|
+
export const useIntentResolver = (module: string, resolver: AnyIntentResolver) => {
|
|
22
|
+
const manager = usePluginManager();
|
|
21
23
|
useEffect(() => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
manager.context.contributeCapability({
|
|
25
|
+
module,
|
|
26
|
+
interface: Capabilities.IntentResolver,
|
|
27
|
+
implementation: resolver,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return () => manager.context.removeCapability(Capabilities.IntentResolver, resolver);
|
|
31
|
+
}, [module, resolver]);
|
|
24
32
|
};
|
|
25
33
|
|
|
26
34
|
export const IntentProvider: Provider<IntentContext | undefined> = IntentContext.Provider;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { createContext, useContext } from 'react';
|
|
6
|
+
|
|
7
|
+
import { raise } from '@dxos/debug';
|
|
8
|
+
|
|
9
|
+
import { type PluginManager } from '../core';
|
|
10
|
+
|
|
11
|
+
const PluginManagerContext = createContext<PluginManager | undefined>(undefined);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Get the plugin manager.
|
|
15
|
+
*/
|
|
16
|
+
export const usePluginManager = (): PluginManager =>
|
|
17
|
+
useContext(PluginManagerContext) ?? raise(new Error('Missing PluginManagerContext'));
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Context provider for a plugin manager.
|
|
21
|
+
*/
|
|
22
|
+
export const PluginManagerProvider = PluginManagerContext.Provider;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import React, { useCallback, useState } from 'react';
|
|
8
|
+
|
|
9
|
+
import { faker } from '@dxos/random';
|
|
10
|
+
import { Button, List, ListItem } from '@dxos/react-ui';
|
|
11
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
12
|
+
|
|
13
|
+
import { PluginManagerProvider, usePluginManager } from './PluginManagerProvider';
|
|
14
|
+
import { Surface, useSurfaces } from './Surface';
|
|
15
|
+
import { Capabilities, createSurface } from '../common';
|
|
16
|
+
import { type PluginManager } from '../core';
|
|
17
|
+
import { setupPluginManager } from '../testing';
|
|
18
|
+
|
|
19
|
+
const randomColor = (): string => {
|
|
20
|
+
const hue = faker.number.int({ min: 0, max: 360 });
|
|
21
|
+
const saturation = faker.number.int({ min: 50, max: 90 });
|
|
22
|
+
const lightness = faker.number.int({ min: 40, max: 70 });
|
|
23
|
+
return `hsl(${hue}, ${saturation}%, ${lightness}%)`;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const Story = () => {
|
|
27
|
+
const manager = usePluginManager();
|
|
28
|
+
const surfaces = useSurfaces();
|
|
29
|
+
const [picked, setPicked] = useState('test');
|
|
30
|
+
|
|
31
|
+
const handleAdd = useCallback(() => {
|
|
32
|
+
const id = `test-${faker.number.int({ min: 0, max: 1_000_000 })}`;
|
|
33
|
+
const backgroundColor = randomColor();
|
|
34
|
+
|
|
35
|
+
manager.context.contributeCapability({
|
|
36
|
+
module: 'test',
|
|
37
|
+
interface: Capabilities.ReactSurface,
|
|
38
|
+
implementation: createSurface({
|
|
39
|
+
id,
|
|
40
|
+
role: id,
|
|
41
|
+
component: () => (
|
|
42
|
+
<div className='flex-1' style={{ backgroundColor }}>
|
|
43
|
+
{id}
|
|
44
|
+
</div>
|
|
45
|
+
),
|
|
46
|
+
}),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
setPicked(id);
|
|
50
|
+
}, [manager]);
|
|
51
|
+
|
|
52
|
+
const handlePick = useCallback(() => {
|
|
53
|
+
setPicked(faker.helpers.arrayElement(surfaces).id);
|
|
54
|
+
}, [surfaces]);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<div className='flex flex-col gap-2'>
|
|
58
|
+
<div className='flex gap-2'>
|
|
59
|
+
<Button onClick={handleAdd}>Add</Button>
|
|
60
|
+
<Button onClick={handlePick}>Pick</Button>
|
|
61
|
+
</div>
|
|
62
|
+
<div className='flex gap-2'>
|
|
63
|
+
<div className='flex-1'>
|
|
64
|
+
<List itemSizes='one'>
|
|
65
|
+
{surfaces.map((surface) => (
|
|
66
|
+
<ListItem.Root key={surface.id} id={surface.id}>
|
|
67
|
+
<ListItem.Heading classNames='grow pbs-2'>{surface.id}</ListItem.Heading>
|
|
68
|
+
</ListItem.Root>
|
|
69
|
+
))}
|
|
70
|
+
</List>
|
|
71
|
+
</div>
|
|
72
|
+
<div className='flex-1'>
|
|
73
|
+
<Surface role={picked} limit={1} />
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export default {
|
|
81
|
+
title: 'sdk/app-framework/Surface',
|
|
82
|
+
render: ({ manager }: { manager: PluginManager }) => {
|
|
83
|
+
return (
|
|
84
|
+
<PluginManagerProvider value={manager}>
|
|
85
|
+
<Story />
|
|
86
|
+
</PluginManagerProvider>
|
|
87
|
+
);
|
|
88
|
+
},
|
|
89
|
+
// NOTE: Intentionally not using withPluginManager to try to reduce surface area of the story.
|
|
90
|
+
decorators: [withTheme, withLayout({ tooltips: true })],
|
|
91
|
+
args: {
|
|
92
|
+
manager: setupPluginManager(),
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const Default = {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { memo, forwardRef, Suspense, useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { useDefaultValue } from '@dxos/react-hooks';
|
|
8
|
+
import { byPosition } from '@dxos/util';
|
|
9
|
+
|
|
10
|
+
import { ErrorBoundary } from './ErrorBoundary';
|
|
11
|
+
import { useCapabilities } from './useCapabilities';
|
|
12
|
+
import { Capabilities, type SurfaceDefinition, type SurfaceProps } from '../common';
|
|
13
|
+
import { type PluginsContext } from '../core';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export const useSurfaces = () => {
|
|
19
|
+
const surfaces = useCapabilities(Capabilities.ReactSurface);
|
|
20
|
+
return useMemo(() => surfaces.flat(), [surfaces]);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const findCandidates = (surfaces: SurfaceDefinition[], { role, data }: Pick<SurfaceProps, 'role' | 'data'>) => {
|
|
24
|
+
return Object.values(surfaces)
|
|
25
|
+
.filter((definition) =>
|
|
26
|
+
Array.isArray(definition.role) ? definition.role.includes(role) : definition.role === role,
|
|
27
|
+
)
|
|
28
|
+
.filter(({ filter }) => (filter ? filter(data ?? {}) : true))
|
|
29
|
+
.toSorted(byPosition);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @returns `true` if there is a contributed surface which matches the specified role & data, `false` otherwise.
|
|
34
|
+
*/
|
|
35
|
+
export const isSurfaceAvailable = (context: PluginsContext, { role, data }: Pick<SurfaceProps, 'role' | 'data'>) => {
|
|
36
|
+
const surfaces = context.requestCapabilities(Capabilities.ReactSurface);
|
|
37
|
+
const candidates = findCandidates(surfaces.flat(), { role, data });
|
|
38
|
+
return candidates.length > 0;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A surface is a named region of the screen that can be populated by plugins.
|
|
43
|
+
*/
|
|
44
|
+
export const Surface = memo(
|
|
45
|
+
forwardRef<HTMLElement, SurfaceProps>(
|
|
46
|
+
({ id: _id, role, data: _data, limit, fallback, placeholder, ...rest }, forwardedRef) => {
|
|
47
|
+
// TODO(wittjosiah): This will make all surfaces depend on a single signal.
|
|
48
|
+
// This isn't ideal because it means that any change to the data will cause all surfaces to re-render.
|
|
49
|
+
// This effectively means that plugin modules which contribute surfaces need to all be activated at startup.
|
|
50
|
+
// This should be fine for now because it's how it worked prior to capabilities api anyways.
|
|
51
|
+
// In the future, it would be nice to be able to bucket the surface contributions by role.
|
|
52
|
+
const surfaces = useSurfaces();
|
|
53
|
+
const data = useDefaultValue(_data, () => ({}));
|
|
54
|
+
|
|
55
|
+
// NOTE: Memoizing the candidates makes the surface not re-render based on reactivity within data.
|
|
56
|
+
const definitions = findCandidates(surfaces, { role, data });
|
|
57
|
+
const candidates = limit ? definitions.slice(0, limit) : definitions;
|
|
58
|
+
const nodes = candidates.map(({ component: Component, id }) => (
|
|
59
|
+
<Component ref={forwardedRef} key={id} id={id} role={role} data={data} limit={limit} {...rest} />
|
|
60
|
+
));
|
|
61
|
+
|
|
62
|
+
const suspense = placeholder ? <Suspense fallback={placeholder}>{nodes}</Suspense> : nodes;
|
|
63
|
+
|
|
64
|
+
return fallback ? (
|
|
65
|
+
<ErrorBoundary data={data} fallback={fallback}>
|
|
66
|
+
{suspense}
|
|
67
|
+
</ErrorBoundary>
|
|
68
|
+
) : (
|
|
69
|
+
suspense
|
|
70
|
+
);
|
|
71
|
+
},
|
|
72
|
+
),
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
Surface.displayName = 'Surface';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useCapability } from './useCapabilities';
|
|
6
|
+
import { Capabilities } from '../common';
|
|
7
|
+
|
|
8
|
+
export const useIntentDispatcher = () => useCapability(Capabilities.IntentDispatcher);
|
|
9
|
+
|
|
10
|
+
export const useAppGraph = () => useCapability(Capabilities.AppGraph);
|
|
11
|
+
|
|
12
|
+
export const useLayout = () => useCapability(Capabilities.Layout);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { computed } from '@preact/signals-core';
|
|
6
|
+
import { useMemo } from 'react';
|
|
7
|
+
|
|
8
|
+
import { usePluginManager } from './PluginManagerProvider';
|
|
9
|
+
import { type InterfaceDef } from '../core';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Hook to request capabilities from the plugin context.
|
|
13
|
+
* @returns An array of capabilities.
|
|
14
|
+
*/
|
|
15
|
+
export const useCapabilities = <T, U extends T = T>(
|
|
16
|
+
interfaceDef: InterfaceDef<T>,
|
|
17
|
+
filter?: (capability: T, moduleId: string) => capability is U,
|
|
18
|
+
) => {
|
|
19
|
+
const manager = usePluginManager();
|
|
20
|
+
const signal = useMemo(
|
|
21
|
+
() => computed(() => manager.context.requestCapabilities(interfaceDef, filter)),
|
|
22
|
+
[interfaceDef],
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return signal.value;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Hook to request a capability from the plugin context.
|
|
30
|
+
* @returns The capability.
|
|
31
|
+
* @throws If no capability is found.
|
|
32
|
+
*/
|
|
33
|
+
export const useCapability = <T, U extends T = T>(
|
|
34
|
+
interfaceDef: InterfaceDef<T>,
|
|
35
|
+
filter?: (capability: T, moduleId: string) => capability is U,
|
|
36
|
+
) => {
|
|
37
|
+
const manager = usePluginManager();
|
|
38
|
+
const signal = useMemo(() => computed(() => manager.context.requestCapability(interfaceDef, filter)), [interfaceDef]);
|
|
39
|
+
return signal.value;
|
|
40
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useEffect } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Capabilities } from '../common';
|
|
8
|
+
import { type AnyIntentResolver } from '../plugin-intent';
|
|
9
|
+
import { usePluginManager } from '../react';
|
|
10
|
+
|
|
11
|
+
export const useIntentResolver = (module: string, resolver: AnyIntentResolver) => {
|
|
12
|
+
const manager = usePluginManager();
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
manager.context.contributeCapability({
|
|
15
|
+
module,
|
|
16
|
+
interface: Capabilities.IntentResolver,
|
|
17
|
+
implementation: resolver,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
return () => manager.context.removeCapability(Capabilities.IntentResolver, resolver);
|
|
21
|
+
}, [module, resolver]);
|
|
22
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
|
|
4
|
+
//
|
|
5
|
+
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { withTheme, type Meta } from '@dxos/storybook-utils';
|
|
9
|
+
|
|
10
|
+
import { withPluginManager } from './withPluginManager';
|
|
11
|
+
import { Capabilities, createSurface } from '../common';
|
|
12
|
+
import { contributes } from '../core';
|
|
13
|
+
import { Surface } from '../react';
|
|
14
|
+
|
|
15
|
+
const Render = () => {
|
|
16
|
+
console.log('Render');
|
|
17
|
+
return (
|
|
18
|
+
<div>
|
|
19
|
+
<div>Hello</div>
|
|
20
|
+
<Surface role='main' />
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const meta: Meta = {
|
|
26
|
+
title: 'sdk/app-framework/withPluginManager',
|
|
27
|
+
render: Render,
|
|
28
|
+
decorators: [
|
|
29
|
+
withTheme,
|
|
30
|
+
withPluginManager({
|
|
31
|
+
capabilities: [
|
|
32
|
+
contributes(
|
|
33
|
+
Capabilities.ReactSurface,
|
|
34
|
+
createSurface({
|
|
35
|
+
id: 'test',
|
|
36
|
+
role: 'main',
|
|
37
|
+
component: ({ role }) => <span>{JSON.stringify({ role })}</span>,
|
|
38
|
+
}),
|
|
39
|
+
),
|
|
40
|
+
],
|
|
41
|
+
}),
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default meta;
|
|
46
|
+
|
|
47
|
+
export const Default = {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Decorator } from '@storybook/react';
|
|
6
|
+
import React, { useEffect } from 'react';
|
|
7
|
+
|
|
8
|
+
import { raise } from '@dxos/debug';
|
|
9
|
+
|
|
10
|
+
import { createApp, type CreateAppOptions } from '../App';
|
|
11
|
+
import { Capabilities, Events } from '../common';
|
|
12
|
+
import {
|
|
13
|
+
type ActivationEvent,
|
|
14
|
+
type AnyCapability,
|
|
15
|
+
contributes,
|
|
16
|
+
defineModule,
|
|
17
|
+
definePlugin,
|
|
18
|
+
PluginManager,
|
|
19
|
+
} from '../core';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export const setupPluginManager = ({
|
|
25
|
+
capabilities,
|
|
26
|
+
plugins = [],
|
|
27
|
+
core = plugins.map(({ meta }) => meta.id),
|
|
28
|
+
...options
|
|
29
|
+
}: CreateAppOptions & { capabilities?: AnyCapability[] } = {}) => {
|
|
30
|
+
const pluginManager = new PluginManager({
|
|
31
|
+
pluginLoader: () => raise(new Error('Not implemented')),
|
|
32
|
+
plugins: [StoryPlugin(), ...plugins],
|
|
33
|
+
core: [STORY_PLUGIN, ...core],
|
|
34
|
+
...options,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (capabilities) {
|
|
38
|
+
capabilities.forEach((capability) => {
|
|
39
|
+
pluginManager.context.contributeCapability({
|
|
40
|
+
interface: capability.interface,
|
|
41
|
+
implementation: capability.implementation,
|
|
42
|
+
module: 'story',
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return pluginManager;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type WithPluginManagerOptions = CreateAppOptions & {
|
|
51
|
+
capabilities?: AnyCapability[];
|
|
52
|
+
fireEvents?: (ActivationEvent | string)[];
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Wraps a story with a plugin manager.
|
|
57
|
+
*/
|
|
58
|
+
export const withPluginManager = (options: WithPluginManagerOptions = {}): Decorator => {
|
|
59
|
+
const pluginManager = setupPluginManager(options);
|
|
60
|
+
const App = createApp({ pluginManager });
|
|
61
|
+
|
|
62
|
+
options.fireEvents?.forEach((event) => {
|
|
63
|
+
void pluginManager.activate(event);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return (Story, context) => {
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
const capability = contributes(Capabilities.ReactRoot, {
|
|
69
|
+
id: context.id,
|
|
70
|
+
root: () => <Story />,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
pluginManager.context.contributeCapability({
|
|
74
|
+
...capability,
|
|
75
|
+
module: 'dxos.org/app-framework/withPluginManager',
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
return () => pluginManager.context.removeCapability(capability.interface, capability.implementation);
|
|
79
|
+
}, []);
|
|
80
|
+
|
|
81
|
+
return <App />;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// No-op plugin to ensure there exists at least one plugin for the startup event.
|
|
86
|
+
// This is necessary because `createApp` expects the startup event to complete before the app is ready.
|
|
87
|
+
const STORY_PLUGIN = 'dxos.org/app-framework/story';
|
|
88
|
+
const StoryPlugin = () =>
|
|
89
|
+
definePlugin({ id: STORY_PLUGIN }, [
|
|
90
|
+
defineModule({ id: STORY_PLUGIN, activatesOn: Events.Startup, activate: () => [] }),
|
|
91
|
+
]);
|
package/src/worker.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
// Entrypoint for using plugins in workers runtimes (e.g. Cloudflare Workers, etc.)
|
|
6
|
+
// Excludes all frontend code & dependencies (e.g. localStorage, React, etc.)
|
|
7
|
+
|
|
8
|
+
export * from './core';
|
|
9
|
+
// NOTE: Common includes browser capabilities but they are types only.
|
|
10
|
+
export * from './common';
|
|
11
|
+
export * from './plugin-intent';
|
package/tsconfig.json
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "../../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"esModuleInterop": true,
|
|
5
|
-
"jsx": "react",
|
|
6
|
-
"lib": [
|
|
7
|
-
"DOM",
|
|
8
|
-
"ESNext"
|
|
9
|
-
],
|
|
10
|
-
"module": "ESNext",
|
|
11
|
-
"outDir": "dist"
|
|
12
|
-
},
|
|
3
|
+
"compilerOptions": {},
|
|
13
4
|
"exclude": [
|
|
14
5
|
"/node_modules/"
|
|
15
6
|
],
|
|
@@ -20,9 +11,6 @@
|
|
|
20
11
|
{
|
|
21
12
|
"path": "../../common/async"
|
|
22
13
|
},
|
|
23
|
-
{
|
|
24
|
-
"path": "../../common/context"
|
|
25
|
-
},
|
|
26
14
|
{
|
|
27
15
|
"path": "../../common/debug"
|
|
28
16
|
},
|
|
@@ -35,18 +23,36 @@
|
|
|
35
23
|
{
|
|
36
24
|
"path": "../../common/log"
|
|
37
25
|
},
|
|
26
|
+
{
|
|
27
|
+
"path": "../../common/random"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"path": "../../common/storybook-utils"
|
|
31
|
+
},
|
|
38
32
|
{
|
|
39
33
|
"path": "../../common/util"
|
|
40
34
|
},
|
|
41
35
|
{
|
|
42
36
|
"path": "../../core/echo/echo-schema"
|
|
43
37
|
},
|
|
38
|
+
{
|
|
39
|
+
"path": "../../core/echo/echo-signals"
|
|
40
|
+
},
|
|
44
41
|
{
|
|
45
42
|
"path": "../../core/echo/live-object"
|
|
46
43
|
},
|
|
44
|
+
{
|
|
45
|
+
"path": "../../experimental/artifact"
|
|
46
|
+
},
|
|
47
47
|
{
|
|
48
48
|
"path": "../../ui/primitives/react-hooks"
|
|
49
49
|
},
|
|
50
|
+
{
|
|
51
|
+
"path": "../../ui/react-ui"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"path": "../../ui/react-ui-syntax-highlighter"
|
|
55
|
+
},
|
|
50
56
|
{
|
|
51
57
|
"path": "../app-graph"
|
|
52
58
|
},
|