@dxos/app-framework 0.7.5-main.9d26e3a → 0.7.5-main.e9bb01b
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-F7VZ6LRN.mjs +137 -0
- package/dist/lib/browser/app-graph-builder-F7VZ6LRN.mjs.map +7 -0
- package/dist/lib/browser/chunk-ATRNTMSS.mjs +1399 -0
- package/dist/lib/browser/chunk-ATRNTMSS.mjs.map +7 -0
- package/dist/lib/browser/chunk-LDJ3T4V3.mjs +32 -0
- package/dist/lib/browser/chunk-LDJ3T4V3.mjs.map +7 -0
- package/dist/lib/browser/chunk-WS6SU6HI.mjs +285 -0
- package/dist/lib/browser/chunk-WS6SU6HI.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-E6J7E5Y5.mjs +11 -0
- package/dist/lib/browser/intent-resolver-XLE4L3LS.mjs +38 -0
- package/dist/lib/browser/intent-resolver-XLE4L3LS.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/store-QU2IKFAI.mjs +19 -0
- package/dist/lib/browser/store-QU2IKFAI.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +74 -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-JGBADFF7.cjs +146 -0
- package/dist/lib/node/app-graph-builder-JGBADFF7.cjs.map +7 -0
- package/dist/lib/node/{chunk-FCMHRU3M.cjs → chunk-QLVQ6PND.cjs} +23 -35
- package/dist/lib/node/chunk-QLVQ6PND.cjs.map +7 -0
- package/dist/lib/node/chunk-WKC6YMEQ.cjs +1433 -0
- package/dist/lib/node/chunk-WKC6YMEQ.cjs.map +7 -0
- package/dist/lib/node/chunk-WRWRZKZU.cjs +308 -0
- package/dist/lib/node/chunk-WRWRZKZU.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-CFBKDZQR.cjs} +10 -14
- package/dist/lib/node/intent-dispatcher-CFBKDZQR.cjs.map +7 -0
- package/dist/lib/node/intent-resolver-3TKCXP4S.cjs +45 -0
- package/dist/lib/node/intent-resolver-3TKCXP4S.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/store-4QMUUU2A.cjs +34 -0
- package/dist/lib/node/store-4QMUUU2A.cjs.map +7 -0
- package/dist/lib/node/testing/index.cjs +98 -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-2QEX57NX.mjs +138 -0
- package/dist/lib/node-esm/app-graph-builder-2QEX57NX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-44J2VZBB.mjs +1401 -0
- package/dist/lib/node-esm/chunk-44J2VZBB.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CNJYZNSL.mjs +34 -0
- package/dist/lib/node-esm/chunk-CNJYZNSL.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HTLXL32I.mjs +286 -0
- package/dist/lib/node-esm/chunk-HTLXL32I.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-LDQGDZ62.mjs +12 -0
- package/dist/lib/node-esm/intent-resolver-7VJWN67U.mjs +39 -0
- package/dist/lib/node-esm/intent-resolver-7VJWN67U.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/store-VWDAYUQY.mjs +20 -0
- package/dist/lib/node-esm/store-VWDAYUQY.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +75 -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 +293 -0
- package/dist/types/src/common/capabilities.d.ts.map +1 -0
- package/dist/types/src/common/events.d.ts +48 -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 +248 -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 +6 -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 +6 -0
- package/dist/types/src/playground/generator/Main.d.ts.map +1 -0
- package/dist/types/src/playground/generator/Toolbar.d.ts +6 -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 +6 -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 +10 -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/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 +16 -0
- package/dist/types/src/react/Surface.stories.d.ts.map +1 -0
- package/dist/types/src/react/common.d.ts +12 -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 +10 -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 +37 -18
- package/project.json +4 -3
- package/src/App.tsx +139 -34
- package/src/common/capabilities.ts +91 -0
- package/src/common/events.ts +72 -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 +225 -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 +114 -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 +28 -0
- package/src/plugin-settings/store.ts +20 -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 +39 -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 +75 -0
- package/src/worker.ts +11 -0
- package/tsconfig.json +16 -4
- 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/dist/lib/browser/{plugin-intent-T7Y3MJ5C.mjs.map → intent-dispatcher-E6J7E5Y5.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-LDQGDZ62.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/dist/types/src/{plugins/plugin-surface → react}/ErrorBoundary.d.ts +0 -0
- /package/src/{plugins/plugin-surface → react}/ErrorBoundary.tsx +0 -0
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { untracked } from '@preact/signals-core';
|
|
6
|
+
import { Array as A, Effect, Either, Match, pipe } from 'effect';
|
|
7
|
+
|
|
8
|
+
import { Event } from '@dxos/async';
|
|
9
|
+
import { create, type ReactiveObject } from '@dxos/live-object';
|
|
10
|
+
import { log } from '@dxos/log';
|
|
11
|
+
import { type MaybePromise } from '@dxos/util';
|
|
12
|
+
|
|
13
|
+
import { type AnyCapability, PluginsContext } from './capabilities';
|
|
14
|
+
import { type ActivationEvent, eventKey, getEvents, isAllOf } from './events';
|
|
15
|
+
import { type PluginModule, type Plugin } from './plugin';
|
|
16
|
+
|
|
17
|
+
// TODO(wittjosiah): Factor out?
|
|
18
|
+
const isPromise = (value: unknown): value is Promise<unknown> => {
|
|
19
|
+
return value !== null && typeof value === 'object' && 'then' in value;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type PluginManagerOptions = {
|
|
23
|
+
pluginLoader: (id: string) => MaybePromise<Plugin>;
|
|
24
|
+
plugins?: Plugin[];
|
|
25
|
+
core?: string[];
|
|
26
|
+
enabled?: string[];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type PluginManagerState = {
|
|
30
|
+
// Plugins
|
|
31
|
+
plugins: Plugin[];
|
|
32
|
+
core: string[];
|
|
33
|
+
enabled: string[];
|
|
34
|
+
|
|
35
|
+
// Modules
|
|
36
|
+
modules: PluginModule[];
|
|
37
|
+
active: string[];
|
|
38
|
+
|
|
39
|
+
// Events
|
|
40
|
+
eventsFired: string[];
|
|
41
|
+
pendingReset: string[];
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export class PluginManager {
|
|
45
|
+
readonly activation = new Event<{ event: string; state: 'activating' | 'activated' | 'error'; error?: any }>();
|
|
46
|
+
|
|
47
|
+
readonly context = new PluginsContext({
|
|
48
|
+
activate: (event) => this.activate(event),
|
|
49
|
+
reset: (id) => this.reset(id),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
private readonly _state: ReactiveObject<PluginManagerState>;
|
|
53
|
+
private readonly _pluginLoader: PluginManagerOptions['pluginLoader'];
|
|
54
|
+
private readonly _capabilities = new Map<string, AnyCapability[]>();
|
|
55
|
+
|
|
56
|
+
constructor({
|
|
57
|
+
pluginLoader,
|
|
58
|
+
plugins = [],
|
|
59
|
+
core = plugins.map(({ meta }) => meta.id),
|
|
60
|
+
enabled = [],
|
|
61
|
+
}: PluginManagerOptions) {
|
|
62
|
+
this._pluginLoader = pluginLoader;
|
|
63
|
+
this._state = create({
|
|
64
|
+
plugins,
|
|
65
|
+
core,
|
|
66
|
+
enabled,
|
|
67
|
+
modules: [],
|
|
68
|
+
active: [],
|
|
69
|
+
pendingReset: [],
|
|
70
|
+
eventsFired: [],
|
|
71
|
+
});
|
|
72
|
+
plugins.forEach((plugin) => this._addPlugin(plugin));
|
|
73
|
+
core.forEach((id) => this.enable(id));
|
|
74
|
+
enabled.forEach((id) => this.enable(id));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Plugins that are currently registered.
|
|
79
|
+
*
|
|
80
|
+
* @reactive
|
|
81
|
+
*/
|
|
82
|
+
get plugins(): ReactiveObject<readonly Plugin[]> {
|
|
83
|
+
return this._state.plugins;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Ids of plugins that are core and cannot be removed.
|
|
88
|
+
*
|
|
89
|
+
* @reactive
|
|
90
|
+
*/
|
|
91
|
+
get core(): ReactiveObject<readonly string[]> {
|
|
92
|
+
return this._state.core;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Ids of plugins that are currently enabled.
|
|
97
|
+
*
|
|
98
|
+
* @reactive
|
|
99
|
+
*/
|
|
100
|
+
get enabled(): ReactiveObject<readonly string[]> {
|
|
101
|
+
return this._state.enabled;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Modules of plugins which are currently enabled.
|
|
106
|
+
*
|
|
107
|
+
* @reactive
|
|
108
|
+
*/
|
|
109
|
+
get modules(): ReactiveObject<readonly PluginModule[]> {
|
|
110
|
+
return this._state.modules;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Ids of modules which are currently active.
|
|
115
|
+
*
|
|
116
|
+
* @reactive
|
|
117
|
+
*/
|
|
118
|
+
get active(): ReactiveObject<readonly string[]> {
|
|
119
|
+
return this._state.active;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Ids of events which have been fired.
|
|
124
|
+
*
|
|
125
|
+
* @reactive
|
|
126
|
+
*/
|
|
127
|
+
get eventsFired(): ReactiveObject<readonly string[]> {
|
|
128
|
+
return this._state.eventsFired;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Ids of modules which are pending reset.
|
|
133
|
+
*
|
|
134
|
+
* @reactive
|
|
135
|
+
*/
|
|
136
|
+
get pendingReset(): ReactiveObject<readonly string[]> {
|
|
137
|
+
return this._state.pendingReset;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Adds a plugin to the manager via the plugin loader.
|
|
142
|
+
* @param id The id of the plugin.
|
|
143
|
+
*/
|
|
144
|
+
async add(id: string): Promise<boolean> {
|
|
145
|
+
return untracked(async () => {
|
|
146
|
+
log('add plugin', { id });
|
|
147
|
+
const plugin = await this._pluginLoader(id);
|
|
148
|
+
this._addPlugin(plugin);
|
|
149
|
+
return this.enable(id);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Enables a plugin.
|
|
155
|
+
* @param id The id of the plugin.
|
|
156
|
+
*/
|
|
157
|
+
enable(id: string): Promise<boolean> {
|
|
158
|
+
return untracked(async () => {
|
|
159
|
+
log('enable plugin', { id });
|
|
160
|
+
const plugin = this._getPlugin(id);
|
|
161
|
+
if (!plugin) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (!this._state.enabled.includes(id)) {
|
|
166
|
+
this._state.enabled.push(id);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
plugin.modules.forEach((module) => {
|
|
170
|
+
this._addModule(module);
|
|
171
|
+
this._setPendingResetByModule(module);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
log('pending reset', { events: [...this.pendingReset] });
|
|
175
|
+
await Effect.runPromise(
|
|
176
|
+
Effect.all(
|
|
177
|
+
this.pendingReset.map((event) => this._activate(event)),
|
|
178
|
+
{ concurrency: 'unbounded' },
|
|
179
|
+
),
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
return true;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Removes a plugin from the manager.
|
|
188
|
+
* @param id The id of the plugin.
|
|
189
|
+
*/
|
|
190
|
+
remove(id: string): boolean {
|
|
191
|
+
return untracked(() => {
|
|
192
|
+
log('remove plugin', { id });
|
|
193
|
+
const result = this.disable(id);
|
|
194
|
+
if (!result) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
this._removePlugin(id);
|
|
199
|
+
return true;
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Disables a plugin.
|
|
205
|
+
* @param id The id of the plugin.
|
|
206
|
+
*/
|
|
207
|
+
disable(id: string): Promise<boolean> {
|
|
208
|
+
return untracked(async () => {
|
|
209
|
+
log('disable plugin', { id });
|
|
210
|
+
if (this._state.core.includes(id)) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const plugin = this._getPlugin(id);
|
|
215
|
+
if (!plugin) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const enabledIndex = this._state.enabled.findIndex((enabled) => enabled === id);
|
|
220
|
+
if (enabledIndex !== -1) {
|
|
221
|
+
this._state.enabled.splice(enabledIndex, 1);
|
|
222
|
+
await Effect.runPromise(this._deactivate(id));
|
|
223
|
+
|
|
224
|
+
plugin.modules.forEach((module) => {
|
|
225
|
+
this._removeModule(module.id);
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return true;
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Activates plugins based on the activation event.
|
|
235
|
+
* @param event The activation event.
|
|
236
|
+
* @returns Whether the activation was successful.
|
|
237
|
+
*/
|
|
238
|
+
activate(event: ActivationEvent | string): Promise<boolean> {
|
|
239
|
+
return untracked(() => Effect.runPromise(this._activate(event)));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Deactivates all of the modules for a plugin.
|
|
244
|
+
* @param id The id of the plugin.
|
|
245
|
+
* @returns Whether the deactivation was successful.
|
|
246
|
+
*/
|
|
247
|
+
deactivate(id: string): Promise<boolean> {
|
|
248
|
+
return untracked(() => Effect.runPromise(this._deactivate(id)));
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Re-activates the modules that were activated by the event.
|
|
253
|
+
* @param event The activation event.
|
|
254
|
+
* @returns Whether the reset was successful.
|
|
255
|
+
*/
|
|
256
|
+
reset(event: ActivationEvent | string): Promise<boolean> {
|
|
257
|
+
return untracked(() => Effect.runPromise(this._reset(event)));
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
private _addPlugin(plugin: Plugin) {
|
|
261
|
+
untracked(() => {
|
|
262
|
+
log('add plugin', { id: plugin.meta.id });
|
|
263
|
+
if (!this._state.plugins.includes(plugin)) {
|
|
264
|
+
this._state.plugins.push(plugin);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
private _removePlugin(id: string) {
|
|
270
|
+
untracked(() => {
|
|
271
|
+
log('remove plugin', { id });
|
|
272
|
+
const pluginIndex = this._state.plugins.findIndex((plugin) => plugin.meta.id === id);
|
|
273
|
+
if (pluginIndex !== -1) {
|
|
274
|
+
this._state.plugins.splice(pluginIndex, 1);
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
private _addModule(module: PluginModule) {
|
|
280
|
+
untracked(() => {
|
|
281
|
+
log('add module', { id: module.id });
|
|
282
|
+
if (!this._state.modules.includes(module)) {
|
|
283
|
+
this._state.modules.push(module);
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
private _removeModule(id: string) {
|
|
289
|
+
untracked(() => {
|
|
290
|
+
log('remove module', { id });
|
|
291
|
+
const moduleIndex = this._state.modules.findIndex((module) => module.id === id);
|
|
292
|
+
if (moduleIndex !== -1) {
|
|
293
|
+
this._state.modules.splice(moduleIndex, 1);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
private _getPlugin(id: string) {
|
|
299
|
+
return this._state.plugins.find((plugin) => plugin.meta.id === id);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
private _getActiveModules() {
|
|
303
|
+
return this._state.modules.filter((module) => this._state.active.includes(module.id));
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
private _getInactiveModules() {
|
|
307
|
+
return this._state.modules.filter((module) => !this._state.active.includes(module.id));
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
private _getActiveModulesByEvent(key: string) {
|
|
311
|
+
return this._getActiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
private _getInactiveModulesByEvent(key: string) {
|
|
315
|
+
return this._getInactiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
private _setPendingResetByModule(module: PluginModule) {
|
|
319
|
+
return untracked(() => {
|
|
320
|
+
const activationEvents = getEvents(module.activatesOn)
|
|
321
|
+
.map(eventKey)
|
|
322
|
+
.filter((key) => this._state.eventsFired.includes(key));
|
|
323
|
+
|
|
324
|
+
const pendingReset = Array.from(new Set(activationEvents)).filter(
|
|
325
|
+
(event) => !this._state.pendingReset.includes(event),
|
|
326
|
+
);
|
|
327
|
+
if (pendingReset.length > 0) {
|
|
328
|
+
log('pending reset', { events: pendingReset });
|
|
329
|
+
this._state.pendingReset.push(...pendingReset);
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* @internal
|
|
336
|
+
*/
|
|
337
|
+
// TODO(wittjosiah): Improve error typing.
|
|
338
|
+
_activate(event: ActivationEvent | string): Effect.Effect<boolean, Error> {
|
|
339
|
+
return Effect.gen(this, function* () {
|
|
340
|
+
const key = typeof event === 'string' ? event : eventKey(event);
|
|
341
|
+
log('activating', { key });
|
|
342
|
+
const pendingIndex = this._state.pendingReset.findIndex((event) => event === key);
|
|
343
|
+
if (pendingIndex !== -1) {
|
|
344
|
+
this._state.pendingReset.splice(pendingIndex, 1);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const modules = this._getInactiveModulesByEvent(key).filter((module) => {
|
|
348
|
+
const allOf = isAllOf(module.activatesOn);
|
|
349
|
+
if (!allOf) {
|
|
350
|
+
return true;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
const events = module.activatesOn.events.filter((event) => eventKey(event) !== key);
|
|
354
|
+
return events.every((event) => this._state.eventsFired.includes(eventKey(event)));
|
|
355
|
+
});
|
|
356
|
+
if (modules.length === 0) {
|
|
357
|
+
log('no modules to activate', { key });
|
|
358
|
+
if (!this._state.eventsFired.includes(key)) {
|
|
359
|
+
this._state.eventsFired.push(key);
|
|
360
|
+
}
|
|
361
|
+
return false;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
log('activating modules', { key, modules: modules.map((module) => module.id) });
|
|
365
|
+
this.activation.emit({ event: key, state: 'activating' });
|
|
366
|
+
|
|
367
|
+
// Concurrently triggers loading of lazy capabilities.
|
|
368
|
+
const getCapabilities = yield* Effect.all(
|
|
369
|
+
modules.map(({ activate }) =>
|
|
370
|
+
Effect.tryPromise({
|
|
371
|
+
try: async () => activate(this.context),
|
|
372
|
+
catch: (error) => error as Error,
|
|
373
|
+
}),
|
|
374
|
+
),
|
|
375
|
+
{ concurrency: 'unbounded' },
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
const result = yield* pipe(
|
|
379
|
+
modules,
|
|
380
|
+
A.zip(getCapabilities),
|
|
381
|
+
A.map(([module, getCapabilities]) => this._activateModule(module, getCapabilities)),
|
|
382
|
+
// TODO(wittjosiah): This currently can't be run in parallel.
|
|
383
|
+
// Running this with concurrency causes races with `allOf` activation events.
|
|
384
|
+
Effect.all,
|
|
385
|
+
Effect.either,
|
|
386
|
+
);
|
|
387
|
+
|
|
388
|
+
if (Either.isLeft(result)) {
|
|
389
|
+
this.activation.emit({ event: key, state: 'error', error: result.left });
|
|
390
|
+
yield* Effect.fail(result.left);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
if (!this._state.eventsFired.includes(key)) {
|
|
394
|
+
this._state.eventsFired.push(key);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
this.activation.emit({ event: key, state: 'activated' });
|
|
398
|
+
log('activated', { key });
|
|
399
|
+
|
|
400
|
+
return true;
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
private _activateModule(
|
|
405
|
+
module: PluginModule,
|
|
406
|
+
getCapabilities: AnyCapability | AnyCapability[] | (() => Promise<AnyCapability | AnyCapability[]>),
|
|
407
|
+
): Effect.Effect<void, Error> {
|
|
408
|
+
return Effect.gen(this, function* () {
|
|
409
|
+
yield* Effect.all(module.activatesBefore?.map((event) => this._activate(event)) ?? [], {
|
|
410
|
+
concurrency: 'unbounded',
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
log('activating module...', { module: module.id });
|
|
414
|
+
// TODO(wittjosiah): This is not handling errors thrown if this is synchronous.
|
|
415
|
+
const maybeCapabilities = typeof getCapabilities === 'function' ? getCapabilities() : getCapabilities;
|
|
416
|
+
const resolvedCapabilities = yield* Match.value(maybeCapabilities).pipe(
|
|
417
|
+
// TODO(wittjosiah): Activate with an effect?
|
|
418
|
+
// Match.when(Effect.isEffect, (effect) => effect),
|
|
419
|
+
Match.when(isPromise, (promise) =>
|
|
420
|
+
Effect.tryPromise({
|
|
421
|
+
try: () => promise,
|
|
422
|
+
catch: (error) => error as Error,
|
|
423
|
+
}),
|
|
424
|
+
),
|
|
425
|
+
Match.orElse((program) => Effect.succeed(program)),
|
|
426
|
+
);
|
|
427
|
+
const capabilities = Match.value(resolvedCapabilities).pipe(
|
|
428
|
+
Match.when(Array.isArray, (array) => array),
|
|
429
|
+
Match.orElse((value) => [value]),
|
|
430
|
+
);
|
|
431
|
+
capabilities.forEach((capability) => {
|
|
432
|
+
this.context.contributeCapability({ module: module.id, ...capability });
|
|
433
|
+
});
|
|
434
|
+
this._state.active.push(module.id);
|
|
435
|
+
this._capabilities.set(module.id, capabilities);
|
|
436
|
+
log('activated module', { module: module.id });
|
|
437
|
+
|
|
438
|
+
yield* Effect.all(module.activatesAfter?.map((event) => this._activate(event)) ?? [], {
|
|
439
|
+
concurrency: 'unbounded',
|
|
440
|
+
});
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
private _deactivate(id: string): Effect.Effect<boolean, Error> {
|
|
445
|
+
return Effect.gen(this, function* () {
|
|
446
|
+
const plugin = this._getPlugin(id);
|
|
447
|
+
if (!plugin) {
|
|
448
|
+
return false;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
const modules = plugin.modules;
|
|
452
|
+
const results = yield* Effect.all(
|
|
453
|
+
modules.map((module) => this._deactivateModule(module)),
|
|
454
|
+
{ concurrency: 'unbounded' },
|
|
455
|
+
);
|
|
456
|
+
return results.every((result) => result);
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
private _deactivateModule(module: PluginModule): Effect.Effect<boolean, Error> {
|
|
461
|
+
return Effect.gen(this, function* () {
|
|
462
|
+
const id = module.id;
|
|
463
|
+
log('deactivating', { id });
|
|
464
|
+
|
|
465
|
+
const capabilities = this._capabilities.get(id);
|
|
466
|
+
if (capabilities) {
|
|
467
|
+
for (const capability of capabilities) {
|
|
468
|
+
this.context.removeCapability(capability.interface, capability.implementation);
|
|
469
|
+
const program = capability.deactivate?.();
|
|
470
|
+
yield* Match.value(program).pipe(
|
|
471
|
+
Match.when(Effect.isEffect, (effect) => effect),
|
|
472
|
+
Match.when(isPromise, (promise) =>
|
|
473
|
+
Effect.tryPromise({
|
|
474
|
+
try: () => promise,
|
|
475
|
+
catch: (error) => error as Error,
|
|
476
|
+
}),
|
|
477
|
+
),
|
|
478
|
+
Match.orElse((program) => Effect.succeed(program)),
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
this._capabilities.delete(id);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
const activeIndex = this._state.active.findIndex((event) => event === id);
|
|
485
|
+
if (activeIndex !== -1) {
|
|
486
|
+
this._state.active.splice(activeIndex, 1);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
log('deactivated', { id });
|
|
490
|
+
return true;
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
private _reset(event: ActivationEvent | string): Effect.Effect<boolean, Error> {
|
|
495
|
+
return Effect.gen(this, function* () {
|
|
496
|
+
const key = typeof event === 'string' ? event : eventKey(event);
|
|
497
|
+
log('reset', { key });
|
|
498
|
+
const modules = this._getActiveModulesByEvent(key);
|
|
499
|
+
const results = yield* Effect.all(
|
|
500
|
+
modules.map((module) => this._deactivateModule(module)),
|
|
501
|
+
{ concurrency: 'unbounded' },
|
|
502
|
+
);
|
|
503
|
+
|
|
504
|
+
if (results.every((result) => result)) {
|
|
505
|
+
return yield* this._activate(key);
|
|
506
|
+
} else {
|
|
507
|
+
return false;
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type MaybePromise } from '@dxos/util';
|
|
6
|
+
|
|
7
|
+
import { type AnyCapability, type PluginsContext } from './capabilities';
|
|
8
|
+
import { type ActivationEvent, type ActivationEvents } from './events';
|
|
9
|
+
|
|
10
|
+
interface PluginModuleInterface {
|
|
11
|
+
/**
|
|
12
|
+
* Unique id of the module.
|
|
13
|
+
*/
|
|
14
|
+
id: string;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Events for which the module will be activated.
|
|
18
|
+
*/
|
|
19
|
+
activatesOn: ActivationEvents;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Events which the plugin depends on being activated.
|
|
23
|
+
* Plugin is marked as needing reset a plugin activated by a dependent event is removed.
|
|
24
|
+
* Events are automatically activated before activation of the plugin.
|
|
25
|
+
*/
|
|
26
|
+
activatesBefore?: ActivationEvent[];
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Events which this plugin triggers upon activation.
|
|
30
|
+
*/
|
|
31
|
+
activatesAfter?: ActivationEvent[];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Called when the module is activated.
|
|
35
|
+
* @param context The plugin context.
|
|
36
|
+
* @returns The capabilities of the module.
|
|
37
|
+
*/
|
|
38
|
+
activate: (
|
|
39
|
+
context: PluginsContext,
|
|
40
|
+
) => MaybePromise<AnyCapability | AnyCapability[]> | Promise<() => Promise<AnyCapability | AnyCapability[]>>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A unit of containment of modular functionality that can be provided to an application.
|
|
45
|
+
* Plugins provide things like components, state, actions, etc. to the application.
|
|
46
|
+
*/
|
|
47
|
+
// NOTE: This is implemented as a class to prevent it from being proxied by PluginManager state.
|
|
48
|
+
export class PluginModule implements PluginModuleInterface {
|
|
49
|
+
readonly id: PluginModuleInterface['id'];
|
|
50
|
+
readonly activatesOn: PluginModuleInterface['activatesOn'];
|
|
51
|
+
readonly activatesBefore?: PluginModuleInterface['activatesBefore'];
|
|
52
|
+
readonly activatesAfter?: PluginModuleInterface['activatesAfter'];
|
|
53
|
+
readonly activate: PluginModuleInterface['activate'];
|
|
54
|
+
|
|
55
|
+
constructor(options: PluginModuleInterface) {
|
|
56
|
+
this.id = options.id;
|
|
57
|
+
this.activatesOn = options.activatesOn;
|
|
58
|
+
this.activatesBefore = options.activatesBefore;
|
|
59
|
+
this.activatesAfter = options.activatesAfter;
|
|
60
|
+
this.activate = options.activate;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Helper to define a module.
|
|
66
|
+
*/
|
|
67
|
+
export const defineModule = (options: PluginModuleInterface) => new PluginModule(options);
|
|
68
|
+
|
|
69
|
+
export type PluginMeta = {
|
|
70
|
+
/**
|
|
71
|
+
* Globally unique ID.
|
|
72
|
+
*
|
|
73
|
+
* Expected to be in the form of a valid URL.
|
|
74
|
+
*
|
|
75
|
+
* @example dxos.org/plugin/example
|
|
76
|
+
*/
|
|
77
|
+
id: string;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Human-readable name.
|
|
81
|
+
*/
|
|
82
|
+
name?: string;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Short description of plugin functionality.
|
|
86
|
+
*/
|
|
87
|
+
description?: string;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* URL of home page.
|
|
91
|
+
*/
|
|
92
|
+
homePage?: string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* URL of source code.
|
|
96
|
+
*/
|
|
97
|
+
source?: string;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* URL of screenshot.
|
|
101
|
+
*/
|
|
102
|
+
screenshots?: string[];
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Tags to help categorize the plugin.
|
|
106
|
+
*/
|
|
107
|
+
tags?: string[];
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* A grep-able symbol string which can be resolved to an icon asset by @ch-ui/icons, via @ch-ui/vite-plugin-icons.
|
|
111
|
+
*/
|
|
112
|
+
icon?: string;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* A collection of modules that are be enabled/disabled as a unit.
|
|
117
|
+
*/
|
|
118
|
+
// NOTE: This is implemented as a class to prevent it from being proxied by PluginManager state.
|
|
119
|
+
export class Plugin {
|
|
120
|
+
constructor(
|
|
121
|
+
readonly meta: PluginMeta,
|
|
122
|
+
readonly modules: PluginModule[],
|
|
123
|
+
) {}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Helper to define a plugin.
|
|
128
|
+
*/
|
|
129
|
+
export const definePlugin = (meta: PluginMeta, modules: PluginModule[]) => {
|
|
130
|
+
return new Plugin(meta, modules);
|
|
131
|
+
};
|