@dxos/app-framework 0.7.4 → 0.7.5-labs.071a3e2
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-MOLT4EHG.mjs +137 -0
- package/dist/lib/browser/app-graph-builder-MOLT4EHG.mjs.map +7 -0
- package/dist/lib/browser/chunk-G3HBVVT5.mjs +1403 -0
- package/dist/lib/browser/chunk-G3HBVVT5.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-TGOF2WQZ.mjs +285 -0
- package/dist/lib/browser/chunk-TGOF2WQZ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +135 -543
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-dispatcher-LJKNIGAM.mjs +11 -0
- package/dist/lib/browser/intent-resolver-Z724VAMC.mjs +38 -0
- package/dist/lib/browser/intent-resolver-Z724VAMC.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/store-NWCY7LAP.mjs +19 -0
- package/dist/lib/browser/store-NWCY7LAP.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-G7SRXDFD.cjs +146 -0
- package/dist/lib/node/app-graph-builder-G7SRXDFD.cjs.map +7 -0
- package/dist/lib/node/chunk-55KIQ6YK.cjs +1437 -0
- package/dist/lib/node/chunk-55KIQ6YK.cjs.map +7 -0
- package/dist/lib/node/chunk-5GABBW2Q.cjs +308 -0
- package/dist/lib/node/chunk-5GABBW2Q.cjs.map +7 -0
- package/dist/lib/node/chunk-QLVQ6PND.cjs +58 -0
- package/dist/lib/node/chunk-QLVQ6PND.cjs.map +7 -0
- package/dist/lib/node/index.cjs +136 -558
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/{plugin-settings-OZ6IKAE5.cjs → intent-dispatcher-CGUK3BCJ.cjs} +10 -10
- package/dist/lib/node/intent-dispatcher-CGUK3BCJ.cjs.map +7 -0
- package/dist/lib/node/intent-resolver-7GNKPRWT.cjs +45 -0
- package/dist/lib/node/intent-resolver-7GNKPRWT.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/store-WMJSEQPC.cjs +34 -0
- package/dist/lib/node/store-WMJSEQPC.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-MKLYH3NE.mjs +138 -0
- package/dist/lib/node-esm/app-graph-builder-MKLYH3NE.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-47FG42II.mjs +286 -0
- package/dist/lib/node-esm/chunk-47FG42II.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-ZTB4TA6Q.mjs +1405 -0
- package/dist/lib/node-esm/chunk-ZTB4TA6Q.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +135 -543
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-dispatcher-RZAWA4XD.mjs +12 -0
- package/dist/lib/node-esm/intent-resolver-UIU37CKJ.mjs +39 -0
- package/dist/lib/node-esm/intent-resolver-UIU37CKJ.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/store-YUWINFBN.mjs +20 -0
- package/dist/lib/node-esm/store-YUWINFBN.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 +296 -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/common/surface.d.ts +68 -0
- 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 +2 -0
- package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/intent.d.ts +68 -0
- 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/react/IntentContext.d.ts +8 -0
- 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 -0
- package/package.json +39 -17
- package/project.json +4 -3
- package/src/App.tsx +139 -34
- package/src/common/capabilities.ts +97 -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/common/surface.ts +81 -0
- 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/plugin-intent/intent-dispatcher.test.ts +299 -0
- package/src/plugin-intent/intent-dispatcher.ts +304 -0
- package/src/plugin-intent/intent.ts +146 -0
- 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/react/IntentContext.tsx +34 -0
- 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 +75 -0
- package/src/worker.ts +11 -0
- package/tsconfig.json +54 -2
- package/dist/lib/browser/chunk-3E7RY3CE.mjs +0 -72
- package/dist/lib/browser/chunk-3E7RY3CE.mjs.map +0 -7
- package/dist/lib/browser/chunk-653Y45CL.mjs +0 -41
- package/dist/lib/browser/chunk-653Y45CL.mjs.map +0 -7
- package/dist/lib/browser/chunk-FRXJ25VI.mjs +0 -214
- package/dist/lib/browser/chunk-FRXJ25VI.mjs.map +0 -7
- package/dist/lib/browser/chunk-YXM35XRE.mjs +0 -213
- package/dist/lib/browser/chunk-YXM35XRE.mjs.map +0 -7
- package/dist/lib/browser/plugin-intent-LU4KL2RO.mjs +0 -22
- package/dist/lib/browser/plugin-settings-OM3G2QFY.mjs +0 -11
- package/dist/lib/browser/plugin-surface-LECZMKSQ.mjs +0 -24
- package/dist/lib/node/chunk-JZ2JVKRY.cjs +0 -58
- package/dist/lib/node/chunk-JZ2JVKRY.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-QSVP5HOW.cjs +0 -238
- package/dist/lib/node/chunk-QSVP5HOW.cjs.map +0 -7
- package/dist/lib/node/chunk-SOVLKUWI.cjs +0 -236
- package/dist/lib/node/chunk-SOVLKUWI.cjs.map +0 -7
- package/dist/lib/node/plugin-intent-FVFR2LKB.cjs +0 -43
- package/dist/lib/node/plugin-intent-FVFR2LKB.cjs.map +0 -7
- package/dist/lib/node/plugin-settings-OZ6IKAE5.cjs.map +0 -7
- package/dist/lib/node/plugin-surface-YWDRXQTD.cjs +0 -45
- package/dist/lib/node/plugin-surface-YWDRXQTD.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-2R4GVK7O.mjs +0 -215
- package/dist/lib/node-esm/chunk-2R4GVK7O.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/chunk-YFMFQBB4.mjs +0 -214
- package/dist/lib/node-esm/chunk-YFMFQBB4.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YNU7FTGJ.mjs +0 -43
- package/dist/lib/node-esm/chunk-YNU7FTGJ.mjs.map +0 -7
- package/dist/lib/node-esm/plugin-intent-V7ER24Y6.mjs +0 -23
- package/dist/lib/node-esm/plugin-settings-37UVWF2V.mjs +0 -12
- package/dist/lib/node-esm/plugin-settings-37UVWF2V.mjs.map +0 -7
- package/dist/lib/node-esm/plugin-surface-TEU42XQN.mjs +0 -25
- package/dist/lib/node-esm/plugin-surface-TEU42XQN.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 -202
- 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 -196
- 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 -21
- 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 -4
- package/dist/types/src/plugins/plugin-host/index.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-host/plugin.d.ts +0 -98
- 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 +0 -21
- 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/helpers.d.ts +0 -6
- package/dist/types/src/plugins/plugin-intent/helpers.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/index.d.ts +0 -6
- package/dist/types/src/plugins/plugin-intent/index.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/intent.d.ts +0 -81
- package/dist/types/src/plugins/plugin-intent/intent.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/meta.d.ts +0 -5
- package/dist/types/src/plugins/plugin-intent/meta.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/provides.d.ts +0 -20
- 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 -13
- 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 -62
- package/dist/types/src/plugins/plugin-surface/Surface.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/SurfaceRootContext.d.ts +0 -39
- package/dist/types/src/plugins/plugin-surface/SurfaceRootContext.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 -16
- 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 -155
- package/src/plugins/common/metadata.ts +0 -29
- package/src/plugins/common/navigation.ts +0 -185
- 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 -96
- 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 -8
- package/src/plugins/plugin-host/plugin.test.ts +0 -158
- package/src/plugins/plugin-host/plugin.ts +0 -126
- package/src/plugins/plugin-intent/IntentContext.tsx +0 -49
- package/src/plugins/plugin-intent/IntentPlugin.tsx +0 -151
- package/src/plugins/plugin-intent/helpers.ts +0 -11
- package/src/plugins/plugin-intent/index.ts +0 -12
- package/src/plugins/plugin-intent/intent.ts +0 -101
- package/src/plugins/plugin-intent/meta.ts +0 -9
- package/src/plugins/plugin-intent/provides.ts +0 -38
- 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 -29
- package/src/plugins/plugin-surface/Surface.tsx +0 -195
- package/src/plugins/plugin-surface/SurfacePlugin.tsx +0 -33
- package/src/plugins/plugin-surface/SurfaceRootContext.tsx +0 -60
- 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 -26
- /package/dist/lib/browser/{plugin-intent-LU4KL2RO.mjs.map → intent-dispatcher-LJKNIGAM.mjs.map} +0 -0
- /package/dist/lib/browser/{plugin-settings-OM3G2QFY.mjs.map → worker.mjs.map} +0 -0
- /package/dist/lib/{browser/plugin-surface-LECZMKSQ.mjs.map → node-esm/intent-dispatcher-RZAWA4XD.mjs.map} +0 -0
- /package/dist/lib/node-esm/{plugin-intent-V7ER24Y6.mjs.map → worker.mjs.map} +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,516 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { effect } from '@preact/signals-core';
|
|
6
|
+
import { afterEach } from 'node:test';
|
|
7
|
+
import { describe, expect, it } from 'vitest';
|
|
8
|
+
|
|
9
|
+
import { Trigger } from '@dxos/async';
|
|
10
|
+
import { raise } from '@dxos/debug';
|
|
11
|
+
import { updateCounter } from '@dxos/echo-schema/testing';
|
|
12
|
+
import { registerSignalsRuntime } from '@dxos/echo-signals';
|
|
13
|
+
import { invariant } from '@dxos/invariant';
|
|
14
|
+
import { create } from '@dxos/live-object';
|
|
15
|
+
|
|
16
|
+
import { contributes, defineCapability, type PluginsContext } from './capabilities';
|
|
17
|
+
import { allOf, defineEvent, oneOf } from './events';
|
|
18
|
+
import { PluginManager } from './manager';
|
|
19
|
+
import { definePlugin, defineModule, type Plugin } from './plugin';
|
|
20
|
+
import { Events } from '../common';
|
|
21
|
+
|
|
22
|
+
registerSignalsRuntime();
|
|
23
|
+
|
|
24
|
+
const String = defineCapability<{ string: string }>('dxos.org/test/string');
|
|
25
|
+
const Number = defineCapability<{ number: number }>('dxos.org/test/number');
|
|
26
|
+
const Total = defineCapability<{ total: number }>('dxos.org/test/total');
|
|
27
|
+
|
|
28
|
+
const CountEvent = defineEvent('dxos.org/test/count');
|
|
29
|
+
const FailEvent = defineEvent('dxos.org/test/fail');
|
|
30
|
+
|
|
31
|
+
const testMeta = { id: 'dxos.org/plugin/test' };
|
|
32
|
+
|
|
33
|
+
describe('PluginManager', () => {
|
|
34
|
+
let plugins: Plugin[] = [];
|
|
35
|
+
const pluginLoader = (id: string) => {
|
|
36
|
+
const plugin = plugins.find((plugin) => plugin.meta.id === id);
|
|
37
|
+
invariant(plugin, `Plugin not found: ${id}`);
|
|
38
|
+
return plugin;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
afterEach(() => {
|
|
42
|
+
plugins = [];
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should be able to add and remove plugins', async () => {
|
|
46
|
+
const Test = definePlugin(testMeta, []);
|
|
47
|
+
plugins = [Test];
|
|
48
|
+
|
|
49
|
+
const manager = new PluginManager({ pluginLoader });
|
|
50
|
+
await manager.add(testMeta.id);
|
|
51
|
+
expect(manager.plugins).toEqual([Test]);
|
|
52
|
+
await manager.remove(testMeta.id);
|
|
53
|
+
expect(manager.plugins).toEqual([]);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('should be able to enable and disable plugins', async () => {
|
|
57
|
+
const Hello = defineModule({
|
|
58
|
+
id: 'dxos.org/test/hello',
|
|
59
|
+
activatesOn: Events.Startup,
|
|
60
|
+
activate: () => contributes(String, { string: 'hello' }),
|
|
61
|
+
});
|
|
62
|
+
const Test = definePlugin(testMeta, [Hello]);
|
|
63
|
+
|
|
64
|
+
const manager = new PluginManager({ plugins: [Test], core: [], pluginLoader });
|
|
65
|
+
await manager.enable(testMeta.id);
|
|
66
|
+
expect(manager.enabled).toEqual([Test.meta.id]);
|
|
67
|
+
expect(manager.modules).toEqual([Hello]);
|
|
68
|
+
await manager.disable(testMeta.id);
|
|
69
|
+
expect(manager.enabled).toEqual([]);
|
|
70
|
+
expect(manager.modules).toEqual([]);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should be able to activate plugins', async () => {
|
|
74
|
+
const Hello = defineModule({
|
|
75
|
+
id: 'dxos.org/test/hello',
|
|
76
|
+
activatesOn: Events.Startup,
|
|
77
|
+
activate: () => contributes(String, { string: 'hello' }),
|
|
78
|
+
});
|
|
79
|
+
const Test = definePlugin(testMeta, [Hello]);
|
|
80
|
+
|
|
81
|
+
const manager = new PluginManager({ plugins: [Test], enabled: [Test.meta.id], pluginLoader });
|
|
82
|
+
expect(manager.plugins).toEqual([Test]);
|
|
83
|
+
expect(manager.enabled).toEqual([Test.meta.id]);
|
|
84
|
+
expect(manager.modules).toEqual([Hello]);
|
|
85
|
+
expect(manager.active).toEqual([]);
|
|
86
|
+
expect(manager.eventsFired).toEqual([]);
|
|
87
|
+
await manager.activate(Events.Startup);
|
|
88
|
+
expect(manager.active).toEqual([Hello.id]);
|
|
89
|
+
expect(manager.eventsFired).toEqual([Events.Startup.id]);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('should propagate errors thrown by module activate callbacks', async () => {
|
|
93
|
+
const Fail = defineModule({
|
|
94
|
+
id: 'dxos.org/test/fail',
|
|
95
|
+
activatesOn: FailEvent,
|
|
96
|
+
activate: async () => raise(new Error('test')),
|
|
97
|
+
});
|
|
98
|
+
plugins = [definePlugin(testMeta, [Fail])];
|
|
99
|
+
|
|
100
|
+
const manager = new PluginManager({ pluginLoader });
|
|
101
|
+
await manager.add(testMeta.id);
|
|
102
|
+
await expect(() => manager.activate(FailEvent)).rejects.toThrow('test');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('should fire activation events', async () => {
|
|
106
|
+
const Hello = defineModule({
|
|
107
|
+
id: 'dxos.org/test/hello',
|
|
108
|
+
activatesOn: Events.Startup,
|
|
109
|
+
activate: () => contributes(String, { string: 'hello' }),
|
|
110
|
+
});
|
|
111
|
+
const Fail = defineModule({
|
|
112
|
+
id: 'dxos.org/test/fail',
|
|
113
|
+
activatesOn: FailEvent,
|
|
114
|
+
// TODO(wittjosiah): Test and catch more failure modes.
|
|
115
|
+
activate: async () => async () => raise(new Error('test')),
|
|
116
|
+
});
|
|
117
|
+
plugins = [definePlugin(testMeta, [Hello, Fail])];
|
|
118
|
+
|
|
119
|
+
const manager = new PluginManager({ pluginLoader });
|
|
120
|
+
const activating = new Trigger<boolean>();
|
|
121
|
+
const activated = new Trigger<boolean>();
|
|
122
|
+
const error = new Trigger<boolean>();
|
|
123
|
+
|
|
124
|
+
manager.activation.on(({ state }) => {
|
|
125
|
+
state === 'activating' && activating.wake(true);
|
|
126
|
+
state === 'activated' && activated.wake(true);
|
|
127
|
+
state === 'error' && error.wake(true);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
await manager.add(testMeta.id);
|
|
131
|
+
await manager.activate(Events.Startup);
|
|
132
|
+
expect(await activating.wait()).toEqual(true);
|
|
133
|
+
expect(await activated.wait()).toEqual(true);
|
|
134
|
+
|
|
135
|
+
activating.reset();
|
|
136
|
+
|
|
137
|
+
await manager.activate(FailEvent).catch(() => {});
|
|
138
|
+
expect(await activating.wait()).toEqual(true);
|
|
139
|
+
expect(await error.wait()).toEqual(true);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('should be able to reset an activation event', async () => {
|
|
143
|
+
let count = 0;
|
|
144
|
+
const Hello = defineModule({
|
|
145
|
+
id: 'dxos.org/test/hello',
|
|
146
|
+
activatesOn: Events.Startup,
|
|
147
|
+
activate: () => {
|
|
148
|
+
count++;
|
|
149
|
+
return contributes(String, { string: 'hello' });
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
plugins = [definePlugin(testMeta, [Hello])];
|
|
153
|
+
|
|
154
|
+
const manager = new PluginManager({ pluginLoader });
|
|
155
|
+
|
|
156
|
+
{
|
|
157
|
+
await manager.add(testMeta.id);
|
|
158
|
+
const result = await manager.activate(Events.Startup);
|
|
159
|
+
expect(result).toEqual(true);
|
|
160
|
+
expect(manager.active).toEqual([Hello.id]);
|
|
161
|
+
expect(count).toEqual(1);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
{
|
|
165
|
+
const result = await manager.activate(Events.Startup);
|
|
166
|
+
expect(result).toEqual(false);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
{
|
|
170
|
+
const result = await manager.reset(Events.Startup);
|
|
171
|
+
expect(result).toEqual(true);
|
|
172
|
+
expect(count).toEqual(2);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it('should not fire an unknown event', async () => {
|
|
177
|
+
const manager = new PluginManager({ pluginLoader });
|
|
178
|
+
const UnknownEvent = defineEvent('unknown');
|
|
179
|
+
expect(await manager.activate(UnknownEvent)).toEqual(false);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('should be able to fire custom activation events', async () => {
|
|
183
|
+
const One = definePlugin({ id: 'dxos.org/test/one' }, [
|
|
184
|
+
defineModule({
|
|
185
|
+
id: 'dxos.org/test/one',
|
|
186
|
+
activatesOn: CountEvent,
|
|
187
|
+
activate: () => [contributes(Number, { number: 1 })],
|
|
188
|
+
}),
|
|
189
|
+
]);
|
|
190
|
+
const Two = definePlugin({ id: 'dxos.org/test/two' }, [
|
|
191
|
+
defineModule({
|
|
192
|
+
id: 'dxos.org/test/two',
|
|
193
|
+
activatesOn: CountEvent,
|
|
194
|
+
activate: () => [contributes(Number, { number: 2 })],
|
|
195
|
+
}),
|
|
196
|
+
]);
|
|
197
|
+
const Three = definePlugin({ id: 'dxos.org/test/three' }, [
|
|
198
|
+
defineModule({
|
|
199
|
+
id: 'dxos.org/test/three',
|
|
200
|
+
activatesOn: CountEvent,
|
|
201
|
+
activate: () => [contributes(Number, { number: 3 })],
|
|
202
|
+
}),
|
|
203
|
+
]);
|
|
204
|
+
plugins = [One, Two, Three];
|
|
205
|
+
|
|
206
|
+
const manager = new PluginManager({ pluginLoader });
|
|
207
|
+
expect(manager.active).toEqual([]);
|
|
208
|
+
expect(manager.context.requestCapabilities(Number)).toHaveLength(0);
|
|
209
|
+
|
|
210
|
+
await manager.add(One.meta.id);
|
|
211
|
+
await manager.activate(CountEvent);
|
|
212
|
+
expect(manager.active).toEqual([One.meta.id]);
|
|
213
|
+
expect(manager.context.requestCapabilities(Number)).toHaveLength(1);
|
|
214
|
+
|
|
215
|
+
await manager.add(Two.meta.id);
|
|
216
|
+
await manager.activate(CountEvent);
|
|
217
|
+
expect(manager.active).toEqual([One.meta.id, Two.meta.id]);
|
|
218
|
+
expect(manager.context.requestCapabilities(Number)).toHaveLength(2);
|
|
219
|
+
|
|
220
|
+
await manager.add(Three.meta.id);
|
|
221
|
+
await manager.activate(CountEvent);
|
|
222
|
+
expect(manager.active).toEqual([One.meta.id, Two.meta.id, Three.meta.id]);
|
|
223
|
+
expect(manager.context.requestCapabilities(Number)).toHaveLength(3);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it('should only activate modules after all activatation events have been fired', async () => {
|
|
227
|
+
const Hello = defineModule({
|
|
228
|
+
id: 'dxos.org/test/hello',
|
|
229
|
+
activatesOn: allOf(Events.Startup, CountEvent),
|
|
230
|
+
activate: () => {
|
|
231
|
+
return contributes(String, { string: 'hello' });
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
plugins = [definePlugin(testMeta, [Hello])];
|
|
235
|
+
|
|
236
|
+
const manager = new PluginManager({ pluginLoader });
|
|
237
|
+
expect(manager.active).toEqual([]);
|
|
238
|
+
expect(manager.context.requestCapabilities(String)).toHaveLength(0);
|
|
239
|
+
|
|
240
|
+
await manager.add(testMeta.id);
|
|
241
|
+
await manager.activate(Events.Startup);
|
|
242
|
+
expect(manager.active).toEqual([]);
|
|
243
|
+
expect(manager.context.requestCapabilities(String)).toHaveLength(0);
|
|
244
|
+
|
|
245
|
+
await manager.activate(CountEvent);
|
|
246
|
+
expect(manager.active).toEqual([Hello.id]);
|
|
247
|
+
expect(manager.context.requestCapabilities(String)).toHaveLength(1);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it('should only activate modules once when multiple activatation events have been fired', async () => {
|
|
251
|
+
let count = 0;
|
|
252
|
+
const Hello = defineModule({
|
|
253
|
+
id: 'dxos.org/test/hello',
|
|
254
|
+
activatesOn: oneOf(Events.Startup, CountEvent),
|
|
255
|
+
activate: () => {
|
|
256
|
+
count++;
|
|
257
|
+
return contributes(String, { string: 'hello' });
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
plugins = [definePlugin(testMeta, [Hello])];
|
|
261
|
+
|
|
262
|
+
const manager = new PluginManager({ pluginLoader });
|
|
263
|
+
expect(manager.active).toEqual([]);
|
|
264
|
+
expect(manager.context.requestCapabilities(String)).toHaveLength(0);
|
|
265
|
+
expect(count).toEqual(0);
|
|
266
|
+
|
|
267
|
+
await manager.add(testMeta.id);
|
|
268
|
+
await manager.activate(CountEvent);
|
|
269
|
+
expect(manager.active).toEqual([Hello.id]);
|
|
270
|
+
expect(manager.context.requestCapabilities(String)).toHaveLength(1);
|
|
271
|
+
expect(count).toEqual(1);
|
|
272
|
+
|
|
273
|
+
await manager.activate(Events.Startup);
|
|
274
|
+
expect(manager.active).toEqual([Hello.id]);
|
|
275
|
+
expect(manager.context.requestCapabilities(String)).toHaveLength(1);
|
|
276
|
+
expect(count).toEqual(1);
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it('should be able to disable and re-enable an active plugin', async () => {
|
|
280
|
+
const state = { total: 0 };
|
|
281
|
+
const computeTotal = (context: PluginsContext) => {
|
|
282
|
+
const numbers = context.requestCapabilities(Number);
|
|
283
|
+
state.total = numbers.reduce((acc, n) => acc + n.number, 0);
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
const Count = definePlugin({ id: 'dxos.org/test/count' }, [
|
|
287
|
+
defineModule({
|
|
288
|
+
id: 'dxos.org/test/count',
|
|
289
|
+
activatesOn: Events.Startup,
|
|
290
|
+
activatesBefore: [CountEvent],
|
|
291
|
+
activate: async (context) => async () => {
|
|
292
|
+
computeTotal(context);
|
|
293
|
+
return contributes(Total, state);
|
|
294
|
+
},
|
|
295
|
+
}),
|
|
296
|
+
]);
|
|
297
|
+
|
|
298
|
+
const Test = definePlugin(testMeta, [
|
|
299
|
+
defineModule({
|
|
300
|
+
id: 'dxos.org/test/one',
|
|
301
|
+
activatesOn: CountEvent,
|
|
302
|
+
activate: () => contributes(Number, { number: 1 }),
|
|
303
|
+
}),
|
|
304
|
+
defineModule({
|
|
305
|
+
id: 'dxos.org/test/two',
|
|
306
|
+
activatesOn: CountEvent,
|
|
307
|
+
activate: () => contributes(Number, { number: 2 }),
|
|
308
|
+
}),
|
|
309
|
+
defineModule({
|
|
310
|
+
id: 'dxos.org/test/three',
|
|
311
|
+
activatesOn: CountEvent,
|
|
312
|
+
activate: () => contributes(Number, { number: 3 }),
|
|
313
|
+
}),
|
|
314
|
+
]);
|
|
315
|
+
plugins = [Count, Test];
|
|
316
|
+
|
|
317
|
+
const manager = new PluginManager({ pluginLoader });
|
|
318
|
+
{
|
|
319
|
+
await manager.add(Test.meta.id);
|
|
320
|
+
await manager.add(Count.meta.id);
|
|
321
|
+
await manager.activate(Events.Startup);
|
|
322
|
+
expect(manager.active).toEqual([...Test.modules.map((m) => m.id), Count.meta.id]);
|
|
323
|
+
expect(manager.pendingReset).toEqual([]);
|
|
324
|
+
|
|
325
|
+
const totals = manager.context.requestCapabilities(Total);
|
|
326
|
+
expect(totals).toHaveLength(1);
|
|
327
|
+
expect(totals[0].total).toEqual(6);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
{
|
|
331
|
+
await manager.disable(Test.meta.id);
|
|
332
|
+
expect(manager.active).toEqual([Count.meta.id]);
|
|
333
|
+
expect(manager.pendingReset).toEqual([]);
|
|
334
|
+
|
|
335
|
+
const totals = manager.context.requestCapabilities(Total);
|
|
336
|
+
expect(totals).toHaveLength(1);
|
|
337
|
+
// Total doesn't change because it is not reactive.
|
|
338
|
+
expect(totals[0].total).toEqual(6);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
{
|
|
342
|
+
await manager.enable(Test.meta.id);
|
|
343
|
+
expect(manager.active).toEqual([Count.meta.id, ...Test.modules.map((m) => m.id)]);
|
|
344
|
+
expect(manager.pendingReset).toEqual([]);
|
|
345
|
+
|
|
346
|
+
const totals = manager.context.requestCapabilities(Total);
|
|
347
|
+
expect(totals).toHaveLength(1);
|
|
348
|
+
expect(totals[0].total).toEqual(6);
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
it('should be able to handle live object contributions', async () => {
|
|
353
|
+
const id = 'dxos.org/test/counter';
|
|
354
|
+
const stateEvent = Events.createStateEvent(id);
|
|
355
|
+
|
|
356
|
+
const Test = definePlugin(testMeta, [
|
|
357
|
+
defineModule({
|
|
358
|
+
id,
|
|
359
|
+
activatesOn: Events.Startup,
|
|
360
|
+
activatesAfter: [stateEvent],
|
|
361
|
+
activate: () => contributes(Number, create({ number: 1 })),
|
|
362
|
+
}),
|
|
363
|
+
defineModule({
|
|
364
|
+
id: 'dxos.org/test/doubler',
|
|
365
|
+
activatesOn: stateEvent,
|
|
366
|
+
activate: (context) => {
|
|
367
|
+
const counter = context.requestCapability(Number);
|
|
368
|
+
const state = create({ total: counter.number * 2 });
|
|
369
|
+
const unsubscribe = effect(() => {
|
|
370
|
+
state.total = counter.number * 2;
|
|
371
|
+
});
|
|
372
|
+
return contributes(Total, state, () => unsubscribe());
|
|
373
|
+
},
|
|
374
|
+
}),
|
|
375
|
+
]);
|
|
376
|
+
plugins = [Test];
|
|
377
|
+
|
|
378
|
+
const manager = new PluginManager({ pluginLoader });
|
|
379
|
+
await manager.add(Test.meta.id);
|
|
380
|
+
await manager.activate(Events.Startup);
|
|
381
|
+
expect(manager.active).toEqual(Test.modules.map((m) => m.id));
|
|
382
|
+
|
|
383
|
+
const counter = manager.context.requestCapability(Number);
|
|
384
|
+
const doubler = manager.context.requestCapability(Total);
|
|
385
|
+
expect(counter.number).toEqual(1);
|
|
386
|
+
expect(doubler.total).toEqual(2);
|
|
387
|
+
|
|
388
|
+
counter.number = 2;
|
|
389
|
+
expect(doubler.total).toEqual(4);
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
it('should be reactive', async () => {
|
|
393
|
+
const One = definePlugin({ id: 'dxos.org/test/one' }, [
|
|
394
|
+
defineModule({
|
|
395
|
+
id: 'dxos.org/test/one',
|
|
396
|
+
activatesOn: CountEvent,
|
|
397
|
+
activate: () => [contributes(Number, { number: 1 })],
|
|
398
|
+
}),
|
|
399
|
+
]);
|
|
400
|
+
const Two = definePlugin({ id: 'dxos.org/test/two' }, [
|
|
401
|
+
defineModule({
|
|
402
|
+
id: 'dxos.org/test/two',
|
|
403
|
+
activatesOn: CountEvent,
|
|
404
|
+
activate: () => [contributes(Number, { number: 2 })],
|
|
405
|
+
}),
|
|
406
|
+
]);
|
|
407
|
+
const Three = definePlugin({ id: 'dxos.org/test/three' }, [
|
|
408
|
+
defineModule({
|
|
409
|
+
id: 'dxos.org/test/three',
|
|
410
|
+
activatesOn: CountEvent,
|
|
411
|
+
activate: () => [contributes(Number, { number: 3 })],
|
|
412
|
+
}),
|
|
413
|
+
]);
|
|
414
|
+
plugins = [One, Two, Three];
|
|
415
|
+
|
|
416
|
+
const manager = new PluginManager({ pluginLoader });
|
|
417
|
+
using pluginUpdates = updateCounter(() => {
|
|
418
|
+
const _ = manager.plugins.length;
|
|
419
|
+
});
|
|
420
|
+
using enabledUpdates = updateCounter(() => {
|
|
421
|
+
const _ = manager.enabled.length;
|
|
422
|
+
});
|
|
423
|
+
using modulesUpdates = updateCounter(() => {
|
|
424
|
+
const _ = manager.modules.length;
|
|
425
|
+
});
|
|
426
|
+
using activeUpdates = updateCounter(() => {
|
|
427
|
+
const _ = manager.active.length;
|
|
428
|
+
});
|
|
429
|
+
using eventsFiredUpdates = updateCounter(() => {
|
|
430
|
+
const _ = manager.eventsFired.length;
|
|
431
|
+
});
|
|
432
|
+
using pendingResetUpdates = updateCounter(() => {
|
|
433
|
+
const _ = manager.pendingReset.length;
|
|
434
|
+
});
|
|
435
|
+
expect(pluginUpdates.count).toEqual(0);
|
|
436
|
+
expect(enabledUpdates.count).toEqual(0);
|
|
437
|
+
expect(modulesUpdates.count).toEqual(0);
|
|
438
|
+
expect(activeUpdates.count).toEqual(0);
|
|
439
|
+
expect(eventsFiredUpdates.count).toEqual(0);
|
|
440
|
+
expect(pendingResetUpdates.count).toEqual(0);
|
|
441
|
+
|
|
442
|
+
await manager.add(One.meta.id);
|
|
443
|
+
expect(pluginUpdates.count).toEqual(1);
|
|
444
|
+
expect(enabledUpdates.count).toEqual(1);
|
|
445
|
+
expect(modulesUpdates.count).toEqual(1);
|
|
446
|
+
expect(activeUpdates.count).toEqual(0);
|
|
447
|
+
expect(eventsFiredUpdates.count).toEqual(0);
|
|
448
|
+
expect(pendingResetUpdates.count).toEqual(0);
|
|
449
|
+
|
|
450
|
+
await manager.activate(CountEvent);
|
|
451
|
+
expect(pluginUpdates.count).toEqual(1);
|
|
452
|
+
expect(enabledUpdates.count).toEqual(1);
|
|
453
|
+
expect(modulesUpdates.count).toEqual(1);
|
|
454
|
+
expect(activeUpdates.count).toEqual(1);
|
|
455
|
+
expect(eventsFiredUpdates.count).toEqual(1);
|
|
456
|
+
expect(pendingResetUpdates.count).toEqual(0);
|
|
457
|
+
|
|
458
|
+
await manager.add(Two.meta.id);
|
|
459
|
+
expect(pluginUpdates.count).toEqual(2);
|
|
460
|
+
expect(enabledUpdates.count).toEqual(2);
|
|
461
|
+
expect(modulesUpdates.count).toEqual(2);
|
|
462
|
+
expect(activeUpdates.count).toEqual(2);
|
|
463
|
+
expect(eventsFiredUpdates.count).toEqual(1);
|
|
464
|
+
expect(pendingResetUpdates.count).toEqual(2);
|
|
465
|
+
|
|
466
|
+
await manager.activate(CountEvent);
|
|
467
|
+
expect(pluginUpdates.count).toEqual(2);
|
|
468
|
+
expect(enabledUpdates.count).toEqual(2);
|
|
469
|
+
expect(modulesUpdates.count).toEqual(2);
|
|
470
|
+
expect(activeUpdates.count).toEqual(2);
|
|
471
|
+
expect(eventsFiredUpdates.count).toEqual(1);
|
|
472
|
+
expect(pendingResetUpdates.count).toEqual(2);
|
|
473
|
+
|
|
474
|
+
await manager.add(Three.meta.id);
|
|
475
|
+
expect(pluginUpdates.count).toEqual(3);
|
|
476
|
+
expect(enabledUpdates.count).toEqual(3);
|
|
477
|
+
expect(modulesUpdates.count).toEqual(3);
|
|
478
|
+
expect(activeUpdates.count).toEqual(3);
|
|
479
|
+
expect(eventsFiredUpdates.count).toEqual(1);
|
|
480
|
+
expect(pendingResetUpdates.count).toEqual(4);
|
|
481
|
+
|
|
482
|
+
await manager.reset(CountEvent);
|
|
483
|
+
expect(pluginUpdates.count).toEqual(3);
|
|
484
|
+
expect(enabledUpdates.count).toEqual(3);
|
|
485
|
+
expect(modulesUpdates.count).toEqual(3);
|
|
486
|
+
// Starts at 3, plus deactivates 3, plus activates 3.
|
|
487
|
+
expect(activeUpdates.count).toEqual(9);
|
|
488
|
+
expect(eventsFiredUpdates.count).toEqual(1);
|
|
489
|
+
expect(pendingResetUpdates.count).toEqual(4);
|
|
490
|
+
|
|
491
|
+
await manager.disable(One.meta.id);
|
|
492
|
+
expect(pluginUpdates.count).toEqual(3);
|
|
493
|
+
expect(enabledUpdates.count).toEqual(4);
|
|
494
|
+
expect(modulesUpdates.count).toEqual(4);
|
|
495
|
+
expect(activeUpdates.count).toEqual(10);
|
|
496
|
+
expect(eventsFiredUpdates.count).toEqual(1);
|
|
497
|
+
expect(pendingResetUpdates.count).toEqual(4);
|
|
498
|
+
|
|
499
|
+
await manager.remove(One.meta.id);
|
|
500
|
+
expect(pluginUpdates.count).toEqual(4);
|
|
501
|
+
expect(enabledUpdates.count).toEqual(4);
|
|
502
|
+
expect(modulesUpdates.count).toEqual(4);
|
|
503
|
+
expect(activeUpdates.count).toEqual(10);
|
|
504
|
+
expect(eventsFiredUpdates.count).toEqual(1);
|
|
505
|
+
expect(pendingResetUpdates.count).toEqual(4);
|
|
506
|
+
|
|
507
|
+
await manager.reset(CountEvent);
|
|
508
|
+
expect(pluginUpdates.count).toEqual(4);
|
|
509
|
+
expect(enabledUpdates.count).toEqual(4);
|
|
510
|
+
expect(modulesUpdates.count).toEqual(4);
|
|
511
|
+
// Starts at 10, plus deactivates 2, plus activates 2.
|
|
512
|
+
expect(activeUpdates.count).toEqual(14);
|
|
513
|
+
expect(eventsFiredUpdates.count).toEqual(1);
|
|
514
|
+
expect(pendingResetUpdates.count).toEqual(4);
|
|
515
|
+
});
|
|
516
|
+
});
|