@dxos/app-framework 0.8.4-main.72ec0f3 → 0.8.4-main.7996785055
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/.storybook/main.mts +2 -4
- package/.storybook/preview.mts +2 -2
- package/dist/lib/browser/capability-6JE7FJLC.mjs +37 -0
- package/dist/lib/browser/capability-6JE7FJLC.mjs.map +7 -0
- package/dist/lib/browser/capability-UUQTJFHY.mjs +34 -0
- package/dist/lib/browser/capability-UUQTJFHY.mjs.map +7 -0
- package/dist/lib/browser/chunk-6EJDI5ZO.mjs +950 -0
- package/dist/lib/browser/chunk-6EJDI5ZO.mjs.map +7 -0
- package/dist/lib/browser/chunk-BSVDAIXI.mjs +167 -0
- package/dist/lib/browser/chunk-BSVDAIXI.mjs.map +7 -0
- package/dist/lib/browser/chunk-I34GF4NG.mjs +34 -0
- package/dist/lib/browser/chunk-I34GF4NG.mjs.map +7 -0
- package/dist/lib/browser/chunk-I62FGR6U.mjs +148 -0
- package/dist/lib/browser/chunk-I62FGR6U.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-K253W2N7.mjs +80 -0
- package/dist/lib/browser/chunk-K253W2N7.mjs.map +7 -0
- package/dist/lib/browser/chunk-KS4Q72QV.mjs +42 -0
- package/dist/lib/browser/chunk-KS4Q72QV.mjs.map +7 -0
- package/dist/lib/browser/chunk-NI7GOTDQ.mjs +892 -0
- package/dist/lib/browser/chunk-NI7GOTDQ.mjs.map +7 -0
- package/dist/lib/browser/chunk-QSXYHXCE.mjs +48 -0
- package/dist/lib/browser/chunk-QSXYHXCE.mjs.map +7 -0
- package/dist/lib/browser/chunk-TGX63LTL.mjs +8 -0
- package/dist/lib/browser/chunk-TGX63LTL.mjs.map +7 -0
- package/dist/lib/browser/chunk-WL752JEV.mjs +76 -0
- package/dist/lib/browser/chunk-WL752JEV.mjs.map +7 -0
- package/dist/lib/browser/chunk-YAFEA4GV.mjs +1 -0
- package/dist/lib/browser/cli/index.mjs +89 -0
- package/dist/lib/browser/cli/index.mjs.map +7 -0
- package/dist/lib/browser/common/activation-events.mjs +23 -0
- package/dist/lib/browser/common/capabilities.mjs +45 -0
- package/dist/lib/browser/core/activation-event.mjs +20 -0
- package/dist/lib/browser/core/activation-event.mjs.map +7 -0
- package/dist/lib/browser/core/capability.mjs +28 -0
- package/dist/lib/browser/core/capability.mjs.map +7 -0
- package/dist/lib/browser/core/plugin-manager.mjs +15 -0
- package/dist/lib/browser/core/plugin-manager.mjs.map +7 -0
- package/dist/lib/browser/core/plugin.mjs +29 -0
- package/dist/lib/browser/core/plugin.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +88 -121
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/invoker-capability-OO52QFT6.mjs +42 -0
- package/dist/lib/browser/invoker-capability-OO52QFT6.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +107 -40
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/browser/ui/index.mjs +43 -0
- package/dist/lib/browser/ui/index.mjs.map +7 -0
- package/dist/lib/node-esm/capability-DALQCNHW.mjs +35 -0
- package/dist/lib/node-esm/capability-DALQCNHW.mjs.map +7 -0
- package/dist/lib/node-esm/capability-DOPPY4B5.mjs +38 -0
- package/dist/lib/node-esm/capability-DOPPY4B5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-DQGLY76M.mjs +168 -0
- package/dist/lib/node-esm/chunk-DQGLY76M.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-FKE4Z3D6.mjs +10 -0
- package/dist/lib/node-esm/chunk-FKE4Z3D6.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UZHLZYKI.mjs +893 -0
- package/dist/lib/node-esm/chunk-UZHLZYKI.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VUQOWBYT.mjs +81 -0
- package/dist/lib/node-esm/chunk-VUQOWBYT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WZCSOX5Q.mjs +35 -0
- package/dist/lib/node-esm/chunk-WZCSOX5Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-X7PFMIHT.mjs +77 -0
- package/dist/lib/node-esm/chunk-X7PFMIHT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-XTCKAJXE.mjs +149 -0
- package/dist/lib/node-esm/chunk-XTCKAJXE.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-YEPUMKW5.mjs +43 -0
- package/dist/lib/node-esm/chunk-YEPUMKW5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-YOWIQDUW.mjs +951 -0
- package/dist/lib/node-esm/chunk-YOWIQDUW.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-Z4TJPSMP.mjs +2 -0
- package/dist/lib/node-esm/chunk-Z4TJPSMP.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ZZ7CKK6W.mjs +49 -0
- package/dist/lib/node-esm/chunk-ZZ7CKK6W.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +90 -0
- package/dist/lib/node-esm/cli/index.mjs.map +7 -0
- package/dist/lib/node-esm/common/activation-events.mjs +24 -0
- package/dist/lib/node-esm/common/activation-events.mjs.map +7 -0
- package/dist/lib/node-esm/common/capabilities.mjs +46 -0
- package/dist/lib/node-esm/common/capabilities.mjs.map +7 -0
- package/dist/lib/node-esm/core/activation-event.mjs +21 -0
- package/dist/lib/node-esm/core/activation-event.mjs.map +7 -0
- package/dist/lib/node-esm/core/capability.mjs +29 -0
- package/dist/lib/node-esm/core/capability.mjs.map +7 -0
- package/dist/lib/node-esm/core/plugin-manager.mjs +16 -0
- package/dist/lib/node-esm/core/plugin-manager.mjs.map +7 -0
- package/dist/lib/node-esm/core/plugin.mjs +30 -0
- package/dist/lib/node-esm/core/plugin.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +88 -121
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/invoker-capability-N42CZPNN.mjs +43 -0
- package/dist/lib/node-esm/invoker-capability-N42CZPNN.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +107 -40
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/ui/index.mjs +44 -0
- package/dist/lib/node-esm/ui/index.mjs.map +7 -0
- package/dist/types/src/cli/cli.d.ts +39 -0
- package/dist/types/src/cli/cli.d.ts.map +1 -0
- package/dist/types/src/cli/index.d.ts +2 -0
- package/dist/types/src/cli/index.d.ts.map +1 -0
- package/dist/types/src/common/activation-events.d.ts +27 -0
- package/dist/types/src/common/activation-events.d.ts.map +1 -0
- package/dist/types/src/common/capabilities.d.ts +109 -194
- package/dist/types/src/common/capabilities.d.ts.map +1 -1
- package/dist/types/src/common/index.d.ts +4 -8
- package/dist/types/src/common/index.d.ts.map +1 -1
- package/dist/types/src/common/operations.d.ts +19 -0
- package/dist/types/src/common/operations.d.ts.map +1 -0
- package/dist/types/src/common/translations.d.ts +7 -7
- package/dist/types/src/common/translations.d.ts.map +1 -1
- package/dist/types/src/context.d.ts +5 -0
- package/dist/types/src/context.d.ts.map +1 -0
- package/dist/types/src/core/{events.d.ts → activation-event.d.ts} +7 -7
- package/dist/types/src/core/activation-event.d.ts.map +1 -0
- package/dist/types/src/core/capability-manager.d.ts +43 -0
- package/dist/types/src/core/capability-manager.d.ts.map +1 -0
- package/dist/types/src/core/capability-manager.test.d.ts +2 -0
- package/dist/types/src/core/capability-manager.test.d.ts.map +1 -0
- package/dist/types/src/core/capability.d.ts +150 -0
- package/dist/types/src/core/capability.d.ts.map +1 -0
- package/dist/types/src/core/index.d.ts +5 -4
- package/dist/types/src/core/index.d.ts.map +1 -1
- package/dist/types/src/core/plugin-manager.d.ts +73 -0
- package/dist/types/src/core/plugin-manager.d.ts.map +1 -0
- package/dist/types/src/core/plugin-manager.test.d.ts +2 -0
- package/dist/types/src/core/plugin-manager.test.d.ts.map +1 -0
- package/dist/types/src/core/plugin.d.ts +98 -35
- package/dist/types/src/core/plugin.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/OperationPlugin.d.ts +3 -0
- package/dist/types/src/plugin-operation/OperationPlugin.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/capability.d.ts +7 -0
- package/dist/types/src/plugin-operation/history/capability.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/errors.d.ts +32 -0
- package/dist/types/src/plugin-operation/history/errors.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/history-tracker.d.ts +18 -0
- package/dist/types/src/plugin-operation/history/history-tracker.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/history-tracker.test.d.ts +2 -0
- package/dist/types/src/plugin-operation/history/history-tracker.test.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/index.d.ts +6 -0
- package/dist/types/src/plugin-operation/history/index.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/types.d.ts +13 -0
- package/dist/types/src/plugin-operation/history/types.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/undo-mapping.d.ts +101 -0
- package/dist/types/src/plugin-operation/history/undo-mapping.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/undo-registry.d.ts +23 -0
- package/dist/types/src/plugin-operation/history/undo-registry.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/undo-registry.test.d.ts +2 -0
- package/dist/types/src/plugin-operation/history/undo-registry.test.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/index.d.ts +3 -0
- package/dist/types/src/plugin-operation/index.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/invoker-capability.d.ts +6 -0
- package/dist/types/src/plugin-operation/invoker-capability.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/meta.d.ts +3 -0
- package/dist/types/src/plugin-operation/meta.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/testing.d.ts +58 -0
- package/dist/types/src/plugin-operation/testing.d.ts.map +1 -0
- package/dist/types/src/plugin-runtime/RuntimePlugin.d.ts +3 -0
- package/dist/types/src/plugin-runtime/RuntimePlugin.d.ts.map +1 -0
- package/dist/types/src/plugin-runtime/capability.d.ts +6 -0
- package/dist/types/src/plugin-runtime/capability.d.ts.map +1 -0
- package/dist/types/src/plugin-runtime/index.d.ts +2 -0
- package/dist/types/src/plugin-runtime/index.d.ts.map +1 -0
- package/dist/types/src/plugin-runtime/meta.d.ts +3 -0
- package/dist/types/src/plugin-runtime/meta.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/service.d.ts +8 -0
- package/dist/types/src/testing/service.d.ts.map +1 -0
- package/dist/types/src/testing/withPluginManager.d.ts +4 -4
- package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
- package/dist/types/src/ui/components/App/App.d.ts +9 -0
- package/dist/types/src/ui/components/App/App.d.ts.map +1 -0
- package/dist/types/src/ui/components/App/App.stories.d.ts +19 -0
- package/dist/types/src/ui/components/App/App.stories.d.ts.map +1 -0
- package/dist/types/src/ui/components/App/index.d.ts +2 -0
- package/dist/types/src/ui/components/App/index.d.ts.map +1 -0
- package/dist/types/src/{react/Surface.stories.d.ts → ui/components/PluginManager/PluginManagerContext.stories.d.ts} +2 -3
- package/dist/types/src/ui/components/PluginManager/PluginManagerContext.stories.d.ts.map +1 -0
- package/dist/types/src/ui/components/PluginManager/PluginManagerProvider.d.ts +10 -0
- package/dist/types/src/ui/components/PluginManager/PluginManagerProvider.d.ts.map +1 -0
- package/dist/types/src/ui/components/PluginManager/index.d.ts +2 -0
- package/dist/types/src/ui/components/PluginManager/index.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts +12 -0
- package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts.map +1 -0
- package/dist/types/src/{react/App.stories.d.ts → ui/components/Surface/SurfaceComponent.stories.d.ts} +1 -1
- package/dist/types/src/ui/components/Surface/SurfaceComponent.stories.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/SurfaceInfo.d.ts +11 -0
- package/dist/types/src/ui/components/Surface/SurfaceInfo.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/SurfaceProfilerContext.d.ts +48 -0
- package/dist/types/src/ui/components/Surface/SurfaceProfilerContext.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/context.d.ts +5 -0
- package/dist/types/src/ui/components/Surface/context.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/index.d.ts +26 -0
- package/dist/types/src/ui/components/Surface/index.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/types.d.ts +96 -0
- package/dist/types/src/ui/components/Surface/types.d.ts.map +1 -0
- package/dist/types/src/ui/components/index.d.ts +4 -0
- package/dist/types/src/ui/components/index.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/index.d.ts +6 -0
- package/dist/types/src/ui/hooks/index.d.ts.map +1 -0
- package/dist/types/src/{react → ui/hooks}/useApp.d.ts +30 -12
- package/dist/types/src/ui/hooks/useApp.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/useApp.test.d.ts +2 -0
- package/dist/types/src/ui/hooks/useApp.test.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/useCapabilities.d.ts +31 -0
- package/dist/types/src/ui/hooks/useCapabilities.d.ts.map +1 -0
- package/dist/types/src/{react → ui/hooks}/useLoading.d.ts +1 -2
- package/dist/types/src/ui/hooks/useLoading.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/useSettingsState.d.ts +10 -0
- package/dist/types/src/ui/hooks/useSettingsState.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/useSurface.d.ts +3 -0
- package/dist/types/src/ui/hooks/useSurface.d.ts.map +1 -0
- package/dist/types/src/ui/index.d.ts +3 -0
- package/dist/types/src/ui/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/moon.yml +10 -6
- package/package.json +112 -50
- package/src/cli/cli.ts +107 -0
- package/src/{playground/debug → cli}/index.ts +1 -1
- package/src/common/activation-events.ts +44 -0
- package/src/common/capabilities.ts +168 -210
- package/src/common/index.ts +4 -8
- package/src/common/operations.ts +36 -0
- package/src/common/translations.ts +17 -9
- package/src/context.ts +9 -0
- package/src/core/{events.ts → activation-event.ts} +10 -7
- package/src/core/capability-manager.test.ts +151 -0
- package/src/core/capability-manager.ts +171 -0
- package/src/core/capability.ts +237 -0
- package/src/core/index.ts +5 -4
- package/src/core/plugin-manager.test.ts +1093 -0
- package/src/core/plugin-manager.ts +883 -0
- package/src/core/plugin.ts +230 -40
- package/src/index.ts +3 -2
- package/src/plugin-operation/OperationPlugin.ts +25 -0
- package/src/plugin-operation/history/capability.ts +37 -0
- package/src/plugin-operation/history/errors.ts +7 -0
- package/src/plugin-operation/history/history-tracker.test.ts +374 -0
- package/src/plugin-operation/history/history-tracker.ts +129 -0
- package/src/plugin-operation/history/index.ts +9 -0
- package/src/plugin-operation/history/types.ts +17 -0
- package/src/plugin-operation/history/undo-mapping.ts +135 -0
- package/src/plugin-operation/history/undo-registry.test.ts +73 -0
- package/src/plugin-operation/history/undo-registry.ts +54 -0
- package/src/plugin-operation/index.ts +6 -0
- package/src/plugin-operation/invoker-capability.ts +54 -0
- package/src/plugin-operation/meta.ts +11 -0
- package/src/plugin-operation/testing.ts +154 -0
- package/src/plugin-runtime/RuntimePlugin.ts +20 -0
- package/src/plugin-runtime/capability.ts +53 -0
- package/src/{playground/logger → plugin-runtime}/index.ts +1 -1
- package/src/plugin-runtime/meta.ts +11 -0
- package/src/testing/index.ts +1 -0
- package/src/testing/service.ts +52 -0
- package/src/testing/withPluginManager.stories.tsx +7 -7
- package/src/testing/withPluginManager.tsx +63 -38
- package/src/ui/components/App/App.stories.tsx +92 -0
- package/src/{react → ui/components/App}/App.tsx +11 -12
- package/src/{playground/layout → ui/components/App}/index.ts +1 -1
- package/src/ui/components/PluginManager/PluginManagerContext.stories.tsx +183 -0
- package/src/{react → ui/components/PluginManager}/PluginManagerProvider.ts +3 -3
- package/src/ui/components/PluginManager/index.ts +5 -0
- package/src/{react/Surface.stories.tsx → ui/components/Surface/SurfaceComponent.stories.tsx} +51 -31
- package/src/ui/components/Surface/SurfaceComponent.tsx +257 -0
- package/src/ui/components/Surface/SurfaceInfo.tsx +107 -0
- package/src/ui/components/Surface/SurfaceProfilerContext.tsx +207 -0
- package/src/ui/components/Surface/context.ts +12 -0
- package/src/ui/components/Surface/index.ts +35 -0
- package/src/ui/components/Surface/types.ts +117 -0
- package/src/ui/components/index.ts +7 -0
- package/src/ui/hooks/index.ts +9 -0
- package/src/ui/hooks/useApp.test.tsx +159 -0
- package/src/ui/hooks/useApp.tsx +290 -0
- package/src/ui/hooks/useCapabilities.ts +67 -0
- package/src/{react → ui/hooks}/useLoading.tsx +4 -6
- package/src/ui/hooks/useSettingsState.ts +26 -0
- package/src/ui/hooks/useSurface.ts +13 -0
- package/src/ui/index.ts +6 -0
- package/tsconfig.json +12 -27
- package/tsconfig.node.json +1 -3
- package/typedoc.json +2 -4
- package/vitest.config.ts +1 -1
- package/.swc/plugins/linux_x86_64_19.0.0/fce1bdb8e20a094e4af08bad09cc81497ed0e2e7c51223b07d371063cca18429.wasmer-v7 +0 -0
- package/dist/lib/browser/app-graph-builder-OIEZZC45.mjs +0 -138
- package/dist/lib/browser/app-graph-builder-OIEZZC45.mjs.map +0 -7
- package/dist/lib/browser/chunk-SCPE4ZO2.mjs +0 -35
- package/dist/lib/browser/chunk-SCPE4ZO2.mjs.map +0 -7
- package/dist/lib/browser/chunk-VFUKEZIN.mjs +0 -483
- package/dist/lib/browser/chunk-VFUKEZIN.mjs.map +0 -7
- package/dist/lib/browser/chunk-WPW5VVAX.mjs +0 -1651
- package/dist/lib/browser/chunk-WPW5VVAX.mjs.map +0 -7
- package/dist/lib/browser/intent-dispatcher-LZ4AE66E.mjs +0 -11
- package/dist/lib/browser/intent-resolver-QVCKRX6G.mjs +0 -39
- package/dist/lib/browser/intent-resolver-QVCKRX6G.mjs.map +0 -7
- package/dist/lib/browser/react/index.mjs +0 -34
- package/dist/lib/browser/store-CNPHOYTJ.mjs +0 -30
- package/dist/lib/browser/store-CNPHOYTJ.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-EBU4NVWD.mjs +0 -139
- package/dist/lib/node-esm/app-graph-builder-EBU4NVWD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IJOHO66N.mjs +0 -484
- package/dist/lib/node-esm/chunk-IJOHO66N.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XJZGUJ3H.mjs +0 -1653
- package/dist/lib/node-esm/chunk-XJZGUJ3H.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZX63QUGE.mjs +0 -37
- package/dist/lib/node-esm/chunk-ZX63QUGE.mjs.map +0 -7
- package/dist/lib/node-esm/intent-dispatcher-MGOJ3CHD.mjs +0 -12
- package/dist/lib/node-esm/intent-resolver-URF3HN3G.mjs +0 -40
- package/dist/lib/node-esm/intent-resolver-URF3HN3G.mjs.map +0 -7
- package/dist/lib/node-esm/react/index.mjs +0 -35
- package/dist/lib/node-esm/store-RK5B4XEL.mjs +0 -31
- package/dist/lib/node-esm/store-RK5B4XEL.mjs.map +0 -7
- package/dist/types/src/common/collaboration.d.ts +0 -20
- package/dist/types/src/common/collaboration.d.ts.map +0 -1
- package/dist/types/src/common/events.d.ts +0 -52
- package/dist/types/src/common/events.d.ts.map +0 -1
- package/dist/types/src/common/file.d.ts +0 -14
- package/dist/types/src/common/file.d.ts.map +0 -1
- package/dist/types/src/common/graph.d.ts +0 -21
- package/dist/types/src/common/graph.d.ts.map +0 -1
- package/dist/types/src/common/layout.d.ts +0 -279
- package/dist/types/src/common/layout.d.ts.map +0 -1
- package/dist/types/src/common/surface.d.ts +0 -68
- package/dist/types/src/common/surface.d.ts.map +0 -1
- package/dist/types/src/core/capabilities.d.ts +0 -117
- package/dist/types/src/core/capabilities.d.ts.map +0 -1
- package/dist/types/src/core/capabilities.test.d.ts +0 -2
- package/dist/types/src/core/capabilities.test.d.ts.map +0 -1
- package/dist/types/src/core/events.d.ts.map +0 -1
- package/dist/types/src/core/manager.d.ts +0 -126
- package/dist/types/src/core/manager.d.ts.map +0 -1
- package/dist/types/src/core/manager.test.d.ts +0 -2
- package/dist/types/src/core/manager.test.d.ts.map +0 -1
- package/dist/types/src/playground/debug/Debug.d.ts +0 -6
- package/dist/types/src/playground/debug/Debug.d.ts.map +0 -1
- package/dist/types/src/playground/debug/index.d.ts +0 -2
- package/dist/types/src/playground/debug/index.d.ts.map +0 -1
- package/dist/types/src/playground/debug/plugin.d.ts +0 -2
- package/dist/types/src/playground/debug/plugin.d.ts.map +0 -1
- package/dist/types/src/playground/generator/Main.d.ts +0 -6
- package/dist/types/src/playground/generator/Main.d.ts.map +0 -1
- package/dist/types/src/playground/generator/Toolbar.d.ts +0 -6
- package/dist/types/src/playground/generator/Toolbar.d.ts.map +0 -1
- package/dist/types/src/playground/generator/generator.d.ts +0 -7
- package/dist/types/src/playground/generator/generator.d.ts.map +0 -1
- package/dist/types/src/playground/generator/index.d.ts +0 -3
- package/dist/types/src/playground/generator/index.d.ts.map +0 -1
- package/dist/types/src/playground/generator/plugin.d.ts +0 -2
- package/dist/types/src/playground/generator/plugin.d.ts.map +0 -1
- package/dist/types/src/playground/layout/Layout.d.ts +0 -8
- package/dist/types/src/playground/layout/Layout.d.ts.map +0 -1
- package/dist/types/src/playground/layout/index.d.ts +0 -2
- package/dist/types/src/playground/layout/index.d.ts.map +0 -1
- package/dist/types/src/playground/layout/plugin.d.ts +0 -2
- package/dist/types/src/playground/layout/plugin.d.ts.map +0 -1
- package/dist/types/src/playground/logger/Toolbar.d.ts +0 -6
- package/dist/types/src/playground/logger/Toolbar.d.ts.map +0 -1
- package/dist/types/src/playground/logger/index.d.ts +0 -2
- package/dist/types/src/playground/logger/index.d.ts.map +0 -1
- package/dist/types/src/playground/logger/plugin.d.ts +0 -2
- package/dist/types/src/playground/logger/plugin.d.ts.map +0 -1
- package/dist/types/src/playground/logger/schema.d.ts +0 -13
- package/dist/types/src/playground/logger/schema.d.ts.map +0 -1
- package/dist/types/src/playground/playground.stories.d.ts +0 -11
- package/dist/types/src/playground/playground.stories.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts +0 -2
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/actions.d.ts +0 -36
- package/dist/types/src/plugin-intent/actions.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/errors.d.ts +0 -16
- package/dist/types/src/plugin-intent/errors.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/index.d.ts +0 -6
- package/dist/types/src/plugin-intent/index.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +0 -139
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts +0 -2
- package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/intent.d.ts +0 -63
- package/dist/types/src/plugin-intent/intent.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/meta.d.ts +0 -3
- package/dist/types/src/plugin-intent/meta.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +0 -2
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/actions.d.ts +0 -25
- package/dist/types/src/plugin-settings/actions.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts +0 -4
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/index.d.ts +0 -3
- package/dist/types/src/plugin-settings/index.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/intent-resolver.d.ts +0 -4
- package/dist/types/src/plugin-settings/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/meta.d.ts +0 -3
- package/dist/types/src/plugin-settings/meta.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/store.d.ts +0 -5
- package/dist/types/src/plugin-settings/store.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/translations.d.ts +0 -11
- package/dist/types/src/plugin-settings/translations.d.ts.map +0 -1
- package/dist/types/src/react/App.d.ts +0 -10
- package/dist/types/src/react/App.d.ts.map +0 -1
- package/dist/types/src/react/App.stories.d.ts.map +0 -1
- package/dist/types/src/react/DefaultFallback.d.ts +0 -8
- package/dist/types/src/react/DefaultFallback.d.ts.map +0 -1
- package/dist/types/src/react/ErrorBoundary.d.ts +0 -30
- package/dist/types/src/react/ErrorBoundary.d.ts.map +0 -1
- package/dist/types/src/react/IntentContext.d.ts +0 -8
- package/dist/types/src/react/IntentContext.d.ts.map +0 -1
- package/dist/types/src/react/PluginManagerProvider.d.ts +0 -10
- package/dist/types/src/react/PluginManagerProvider.d.ts.map +0 -1
- package/dist/types/src/react/Surface.d.ts +0 -12
- package/dist/types/src/react/Surface.d.ts.map +0 -1
- package/dist/types/src/react/Surface.stories.d.ts.map +0 -1
- package/dist/types/src/react/common.d.ts +0 -13
- package/dist/types/src/react/common.d.ts.map +0 -1
- package/dist/types/src/react/index.d.ts +0 -9
- package/dist/types/src/react/index.d.ts.map +0 -1
- package/dist/types/src/react/types.d.ts +0 -14
- package/dist/types/src/react/types.d.ts.map +0 -1
- package/dist/types/src/react/useApp.d.ts.map +0 -1
- package/dist/types/src/react/useCapabilities.d.ts +0 -13
- package/dist/types/src/react/useCapabilities.d.ts.map +0 -1
- package/dist/types/src/react/useIntentResolver.d.ts +0 -3
- package/dist/types/src/react/useIntentResolver.d.ts.map +0 -1
- package/dist/types/src/react/useLoading.d.ts.map +0 -1
- package/src/common/collaboration.ts +0 -18
- package/src/common/events.ts +0 -79
- package/src/common/file.ts +0 -22
- package/src/common/graph.ts +0 -30
- package/src/common/layout.ts +0 -277
- package/src/common/surface.ts +0 -88
- package/src/core/capabilities.test.ts +0 -136
- package/src/core/capabilities.ts +0 -263
- package/src/core/manager.test.ts +0 -516
- package/src/core/manager.ts +0 -604
- package/src/playground/debug/Debug.tsx +0 -39
- package/src/playground/debug/plugin.ts +0 -16
- package/src/playground/generator/Main.tsx +0 -70
- package/src/playground/generator/Toolbar.tsx +0 -47
- package/src/playground/generator/generator.ts +0 -48
- package/src/playground/generator/index.ts +0 -6
- package/src/playground/generator/plugin.ts +0 -22
- package/src/playground/layout/Layout.tsx +0 -33
- package/src/playground/layout/plugin.ts +0 -18
- package/src/playground/logger/Toolbar.tsx +0 -30
- package/src/playground/logger/plugin.ts +0 -41
- package/src/playground/logger/schema.ts +0 -12
- package/src/playground/playground.stories.tsx +0 -46
- package/src/plugin-intent/IntentPlugin.ts +0 -20
- package/src/plugin-intent/actions.ts +0 -31
- package/src/plugin-intent/errors.ts +0 -40
- package/src/plugin-intent/index.ts +0 -9
- package/src/plugin-intent/intent-dispatcher.test.ts +0 -286
- package/src/plugin-intent/intent-dispatcher.ts +0 -342
- package/src/plugin-intent/intent.ts +0 -154
- package/src/plugin-intent/meta.ts +0 -10
- package/src/plugin-settings/SettingsPlugin.ts +0 -34
- package/src/plugin-settings/actions.ts +0 -25
- package/src/plugin-settings/app-graph-builder.ts +0 -160
- package/src/plugin-settings/index.ts +0 -6
- package/src/plugin-settings/intent-resolver.ts +0 -35
- package/src/plugin-settings/meta.ts +0 -10
- package/src/plugin-settings/store.ts +0 -33
- package/src/plugin-settings/translations.ts +0 -19
- package/src/react/App.stories.tsx +0 -33
- package/src/react/DefaultFallback.tsx +0 -26
- package/src/react/ErrorBoundary.tsx +0 -56
- package/src/react/IntentContext.tsx +0 -35
- package/src/react/Surface.tsx +0 -109
- package/src/react/common.ts +0 -13
- package/src/react/index.ts +0 -14
- package/src/react/types.ts +0 -37
- package/src/react/useApp.tsx +0 -165
- package/src/react/useCapabilities.ts +0 -31
- package/src/react/useIntentResolver.ts +0 -22
- /package/dist/lib/browser/{intent-dispatcher-LZ4AE66E.mjs.map → chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/browser/{react/index.mjs.map → chunk-YAFEA4GV.mjs.map} +0 -0
- /package/dist/lib/{node-esm/intent-dispatcher-MGOJ3CHD.mjs.map → browser/common/activation-events.mjs.map} +0 -0
- /package/dist/lib/{node-esm/react/index.mjs.map → browser/common/capabilities.mjs.map} +0 -0
package/src/core/plugin.ts
CHANGED
|
@@ -2,12 +2,82 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Context from 'effect/Context';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import * as Option from 'effect/Option';
|
|
8
|
+
import * as Pipeable from 'effect/Pipeable';
|
|
6
9
|
|
|
7
|
-
import {
|
|
8
|
-
import { type ActivationEvent, type ActivationEvents } from './events';
|
|
10
|
+
import { invariant } from '@dxos/invariant';
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
import type * as ActivationEvent from './activation-event';
|
|
13
|
+
import * as Capability from './capability';
|
|
14
|
+
import type * as PluginManager from './plugin-manager';
|
|
15
|
+
|
|
16
|
+
//
|
|
17
|
+
// Plugin Service Layer
|
|
18
|
+
//
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Effect Context.Tag for accessing PluginManager via the Effect layer system.
|
|
22
|
+
* This allows lifecycle operations to access the plugin manager without having it passed as an argument.
|
|
23
|
+
*/
|
|
24
|
+
export class Service extends Context.Tag('@dxos/app-framework/PluginManager')<Service, PluginManager.PluginManager>() {}
|
|
25
|
+
|
|
26
|
+
//
|
|
27
|
+
// Lifecycle Functions
|
|
28
|
+
//
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Activates plugins based on the activation event.
|
|
32
|
+
* Accesses the PluginManager via the Effect layer system.
|
|
33
|
+
* @param event The activation event.
|
|
34
|
+
* @returns Whether the activation was successful.
|
|
35
|
+
*/
|
|
36
|
+
export const activate = (event: ActivationEvent.ActivationEvent): Effect.Effect<boolean, Error, Service> =>
|
|
37
|
+
Effect.flatMap(Service, (manager) => manager.activate(event));
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Re-activates the modules that were activated by the event.
|
|
41
|
+
* Accesses the PluginManager via the Effect layer system.
|
|
42
|
+
* @param event The activation event.
|
|
43
|
+
* @returns Whether the reset was successful.
|
|
44
|
+
*/
|
|
45
|
+
export const reset = (event: ActivationEvent.ActivationEvent): Effect.Effect<boolean, Error, Service> =>
|
|
46
|
+
Effect.flatMap(Service, (manager) => manager.reset(event));
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Shuts down the plugin manager, deactivating all active modules and clearing lifecycle state.
|
|
50
|
+
* Accesses the PluginManager via the Effect layer system.
|
|
51
|
+
*/
|
|
52
|
+
export const shutdown = (): Effect.Effect<boolean, Error, Service> =>
|
|
53
|
+
Effect.flatMap(Service, (manager) => manager.shutdown());
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Computes a module ID from plugin ID and export name.
|
|
57
|
+
*/
|
|
58
|
+
const computeModuleId = (pluginId: string, moduleName: string): string => {
|
|
59
|
+
return `${pluginId}.module.${moduleName}`;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Identifier denoting a PluginModule.
|
|
64
|
+
*/
|
|
65
|
+
export const PluginModuleTypeId: unique symbol = Symbol.for('@dxos/app-framework/PluginModule');
|
|
66
|
+
export type PluginModuleTypeId = typeof PluginModuleTypeId;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Type guard to check if a value is a PluginModule.
|
|
70
|
+
*/
|
|
71
|
+
export const isPluginModule = (value: unknown): value is PluginModule => {
|
|
72
|
+
return typeof value === 'object' && value !== null && PluginModuleTypeId in value;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A unit of containment of modular functionality that can be provided to an application.
|
|
77
|
+
* Activation of a module is async allowing for code to split and loaded lazily.
|
|
78
|
+
*/
|
|
79
|
+
export interface PluginModule {
|
|
80
|
+
readonly [PluginModuleTypeId]: PluginModuleTypeId;
|
|
11
81
|
/**
|
|
12
82
|
* Unique id of the module.
|
|
13
83
|
*/
|
|
@@ -16,43 +86,41 @@ interface PluginModuleInterface {
|
|
|
16
86
|
/**
|
|
17
87
|
* Events for which the module will be activated.
|
|
18
88
|
*/
|
|
19
|
-
activatesOn:
|
|
89
|
+
activatesOn: ActivationEvent.Events;
|
|
20
90
|
|
|
21
91
|
/**
|
|
22
92
|
* Events which the plugin depends on being activated.
|
|
23
93
|
* Plugin is marked as needing reset a plugin activated by a dependent event is removed.
|
|
24
94
|
* Events are automatically activated before activation of the plugin.
|
|
25
95
|
*/
|
|
26
|
-
activatesBefore?: ActivationEvent[];
|
|
96
|
+
activatesBefore?: ActivationEvent.ActivationEvent[];
|
|
27
97
|
|
|
28
98
|
/**
|
|
29
99
|
* Events which this plugin triggers upon activation.
|
|
30
100
|
*/
|
|
31
|
-
activatesAfter?: ActivationEvent[];
|
|
101
|
+
activatesAfter?: ActivationEvent.ActivationEvent[];
|
|
32
102
|
|
|
33
103
|
/**
|
|
34
104
|
* Called when the module is activated.
|
|
35
|
-
*
|
|
105
|
+
* CapabilityManager is accessed via the Effect layer system (Capability.Service).
|
|
106
|
+
* PluginManager is accessed via Plugin.Service.
|
|
107
|
+
* @param props Optional props passed to the module.
|
|
36
108
|
* @returns The capabilities of the module.
|
|
37
109
|
*/
|
|
38
|
-
activate: (
|
|
39
|
-
context: PluginContext,
|
|
40
|
-
) => MaybePromise<AnyCapability | AnyCapability[]> | Promise<() => Promise<AnyCapability | AnyCapability[]>>;
|
|
110
|
+
activate: (props?: any) => Effect.Effect<Capability.ModuleReturn, Error, Capability.Service | Service | never>;
|
|
41
111
|
}
|
|
42
112
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
readonly
|
|
50
|
-
readonly
|
|
51
|
-
readonly
|
|
52
|
-
readonly activatesAfter?: PluginModuleInterface['activatesAfter'];
|
|
53
|
-
readonly activate: PluginModuleInterface['activate'];
|
|
113
|
+
export type PluginModuleOptions = Omit<PluginModule, 'id' | typeof PluginModuleTypeId> & { id?: string };
|
|
114
|
+
|
|
115
|
+
class PluginModuleImpl implements PluginModule {
|
|
116
|
+
readonly [PluginModuleTypeId]: PluginModuleTypeId = PluginModuleTypeId;
|
|
117
|
+
readonly id: PluginModule['id'];
|
|
118
|
+
readonly activatesOn: PluginModule['activatesOn'];
|
|
119
|
+
readonly activatesBefore?: PluginModule['activatesBefore'];
|
|
120
|
+
readonly activatesAfter?: PluginModule['activatesAfter'];
|
|
121
|
+
readonly activate: PluginModule['activate'];
|
|
54
122
|
|
|
55
|
-
constructor(options:
|
|
123
|
+
constructor(options: Omit<PluginModule, typeof PluginModuleTypeId>) {
|
|
56
124
|
this.id = options.id;
|
|
57
125
|
this.activatesOn = options.activatesOn;
|
|
58
126
|
this.activatesBefore = options.activatesBefore;
|
|
@@ -61,18 +129,13 @@ export class PluginModule implements PluginModuleInterface {
|
|
|
61
129
|
}
|
|
62
130
|
}
|
|
63
131
|
|
|
64
|
-
|
|
65
|
-
* Helper to define a module.
|
|
66
|
-
*/
|
|
67
|
-
export const defineModule = (options: PluginModuleInterface) => new PluginModule(options);
|
|
68
|
-
|
|
69
|
-
export type PluginMeta = {
|
|
132
|
+
export type Meta = {
|
|
70
133
|
/**
|
|
71
134
|
* Globally unique ID.
|
|
72
135
|
*
|
|
73
136
|
* Expected to be in the form of a valid URL.
|
|
74
137
|
*
|
|
75
|
-
* @example dxos.
|
|
138
|
+
* @example org.dxos.plugin.example
|
|
76
139
|
*/
|
|
77
140
|
id: string;
|
|
78
141
|
|
|
@@ -117,27 +180,154 @@ export type PluginMeta = {
|
|
|
117
180
|
iconHue?: string;
|
|
118
181
|
};
|
|
119
182
|
|
|
183
|
+
/**
|
|
184
|
+
* Identifier denoting a Plugin.
|
|
185
|
+
*/
|
|
186
|
+
export const PluginTypeId: unique symbol = Symbol.for('@dxos/app-framework/Plugin');
|
|
187
|
+
export type PluginTypeId = typeof PluginTypeId;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Type guard to check if a value is a Plugin.
|
|
191
|
+
*/
|
|
192
|
+
export const isPlugin = (value: unknown): value is Plugin => {
|
|
193
|
+
return typeof value === 'object' && value !== null && PluginTypeId in value;
|
|
194
|
+
};
|
|
195
|
+
|
|
120
196
|
/**
|
|
121
197
|
* A collection of modules that are be enabled/disabled as a unit.
|
|
122
198
|
* Plugins provide things such as components, state, actions, etc. to the application.
|
|
123
199
|
*/
|
|
124
|
-
//
|
|
125
|
-
export
|
|
200
|
+
// TODO(burdon): Convert to ECHO schema.
|
|
201
|
+
export interface Plugin {
|
|
202
|
+
readonly [PluginTypeId]: PluginTypeId;
|
|
203
|
+
readonly meta: Readonly<Meta>;
|
|
204
|
+
readonly modules: ReadonlyArray<PluginModule>;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Internal implementation of Plugin.
|
|
209
|
+
* @internal
|
|
210
|
+
*/
|
|
211
|
+
class PluginImpl implements Plugin {
|
|
212
|
+
readonly [PluginTypeId]: PluginTypeId = PluginTypeId;
|
|
213
|
+
|
|
126
214
|
constructor(
|
|
127
|
-
readonly
|
|
128
|
-
readonly
|
|
215
|
+
private readonly _meta: Meta,
|
|
216
|
+
private readonly _modules: PluginModule[],
|
|
129
217
|
) {}
|
|
218
|
+
|
|
219
|
+
get meta(): Readonly<Meta> {
|
|
220
|
+
return this._meta;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
get modules(): ReadonlyArray<PluginModule> {
|
|
224
|
+
return this._modules;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Builder interface for creating plugins incrementally.
|
|
230
|
+
*/
|
|
231
|
+
export interface PluginBuilder<T = void> extends Pipeable.Pipeable {
|
|
232
|
+
readonly meta: Meta;
|
|
233
|
+
readonly modules: ReadonlyArray<PluginModuleOptions | ((options: T) => PluginModuleOptions)>;
|
|
234
|
+
addModule(moduleOptions: PluginModuleOptions | ((options: T) => PluginModuleOptions)): PluginBuilder<T>;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Builder implementation for creating plugins incrementally.
|
|
239
|
+
*/
|
|
240
|
+
class PluginBuilderImpl<T = void> implements PluginBuilder<T> {
|
|
241
|
+
readonly meta: Meta;
|
|
242
|
+
private readonly _modules: Array<PluginModuleOptions | ((options: T) => PluginModuleOptions)> = [];
|
|
243
|
+
|
|
244
|
+
constructor(meta: Meta) {
|
|
245
|
+
this.meta = meta;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
get modules(): ReadonlyArray<PluginModuleOptions | ((options: T) => PluginModuleOptions)> {
|
|
249
|
+
return this._modules;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
addModule(moduleOptions: PluginModuleOptions | ((options: T) => PluginModuleOptions)): PluginBuilder<T> {
|
|
253
|
+
this._modules.push(moduleOptions);
|
|
254
|
+
return this;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
pipe() {
|
|
258
|
+
// eslint-disable-next-line prefer-rest-params
|
|
259
|
+
return Pipeable.pipeArguments(this, arguments);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Creates a new PluginBuilder to start building a plugin.
|
|
265
|
+
*/
|
|
266
|
+
export const define = <T = void>(meta: Meta): PluginBuilder<T> => new PluginBuilderImpl<T>(meta);
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Adds a module to a plugin builder.
|
|
270
|
+
* Supports both pipeline and direct call styles.
|
|
271
|
+
* Modules can be either PluginModuleOptions or functions that receive options.
|
|
272
|
+
*/
|
|
273
|
+
export function addModule<T>(
|
|
274
|
+
moduleOptions: PluginModuleOptions | ((options: T) => PluginModuleOptions),
|
|
275
|
+
): (builder: PluginBuilder<T>) => PluginBuilder<T>;
|
|
276
|
+
export function addModule<T>(
|
|
277
|
+
builder: PluginBuilder<T>,
|
|
278
|
+
moduleOptions: PluginModuleOptions | ((options: T) => PluginModuleOptions),
|
|
279
|
+
): PluginBuilder<T>;
|
|
280
|
+
export function addModule<T>(
|
|
281
|
+
moduleOptionsOrBuilder: PluginModuleOptions | ((options: T) => PluginModuleOptions) | PluginBuilder<T>,
|
|
282
|
+
moduleOptions?: PluginModuleOptions | ((options: T) => PluginModuleOptions),
|
|
283
|
+
): ((builder: PluginBuilder<T>) => PluginBuilder<T>) | PluginBuilder<T> {
|
|
284
|
+
// If second arg is provided, it's the direct call style: addModule(builder, moduleOptions)
|
|
285
|
+
if (moduleOptions !== undefined) {
|
|
286
|
+
return (moduleOptionsOrBuilder as PluginBuilder<T>).addModule(moduleOptions);
|
|
287
|
+
}
|
|
288
|
+
// Otherwise it's pipeline style: addModule(moduleOptions) returns a function
|
|
289
|
+
const moduleOpts = moduleOptionsOrBuilder as PluginModuleOptions | ((options: T) => PluginModuleOptions);
|
|
290
|
+
return (builder: PluginBuilder<T>) => builder.addModule(moduleOpts);
|
|
130
291
|
}
|
|
131
292
|
|
|
132
|
-
export type PluginFactory<T = void> = ((
|
|
293
|
+
export type PluginFactory<T = void> = ((options: T) => Plugin) & { meta: Meta };
|
|
133
294
|
|
|
134
295
|
/**
|
|
135
|
-
*
|
|
296
|
+
* Resolves a module from either PluginModuleOptions or a function that returns PluginModuleOptions.
|
|
136
297
|
*/
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
298
|
+
const resolveModule = (
|
|
299
|
+
meta: Meta,
|
|
300
|
+
module: PluginModuleOptions | ((options: any) => PluginModuleOptions),
|
|
301
|
+
options?: any,
|
|
302
|
+
): PluginModuleImpl => {
|
|
303
|
+
const moduleOptions = typeof module === 'function' ? module(options) : module;
|
|
304
|
+
const id = Option.fromNullable(moduleOptions.id).pipe(
|
|
305
|
+
Option.match({
|
|
306
|
+
onNone: () => {
|
|
307
|
+
const exportName = Capability.getModuleTag(moduleOptions.activate);
|
|
308
|
+
invariant(exportName, `Plugin module missing name. Plugin: ${meta.id}`);
|
|
309
|
+
return computeModuleId(meta.id, exportName);
|
|
310
|
+
},
|
|
311
|
+
onSome: (id) => computeModuleId(meta.id, id),
|
|
312
|
+
}),
|
|
313
|
+
);
|
|
314
|
+
return new PluginModuleImpl({ ...moduleOptions, id });
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Creates a Plugin from a builder.
|
|
319
|
+
* Supports both pipeline and direct call styles.
|
|
320
|
+
* Always returns a factory function (options: T) => Plugin.
|
|
321
|
+
* When T is void, the function takes no arguments: () => Plugin.
|
|
322
|
+
*/
|
|
323
|
+
export function make<T>(builder: PluginBuilder<T>): PluginFactory<T>;
|
|
324
|
+
export function make<T>(builder: PluginBuilder<T>): PluginFactory<T> {
|
|
325
|
+
const meta = builder.meta;
|
|
326
|
+
|
|
327
|
+
const factory = (options: T) => {
|
|
328
|
+
const modules = builder.modules.map((module) => resolveModule(meta, module, options));
|
|
329
|
+
return new PluginImpl(meta, modules);
|
|
140
330
|
};
|
|
141
331
|
|
|
142
332
|
return Object.assign(factory, { meta });
|
|
143
|
-
}
|
|
333
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { ActivationEvents } from '../common';
|
|
6
|
+
import { Capability, Plugin } from '../core';
|
|
7
|
+
|
|
8
|
+
import { meta } from './meta';
|
|
9
|
+
|
|
10
|
+
const OperationInvoker = Capability.lazy('OperationInvoker', () => import('./invoker-capability'));
|
|
11
|
+
const HistoryCapabilities = Capability.lazy('HistoryCapabilities', () => import('./history/capability'));
|
|
12
|
+
|
|
13
|
+
export const OperationPlugin = Plugin.define(meta).pipe(
|
|
14
|
+
Plugin.addModule({
|
|
15
|
+
activatesOn: ActivationEvents.ManagedRuntimeReady,
|
|
16
|
+
activatesBefore: [ActivationEvents.SetupOperationHandler],
|
|
17
|
+
activatesAfter: [ActivationEvents.OperationInvokerReady],
|
|
18
|
+
activate: OperationInvoker,
|
|
19
|
+
}),
|
|
20
|
+
Plugin.addModule({
|
|
21
|
+
activatesOn: ActivationEvents.OperationInvokerReady,
|
|
22
|
+
activate: HistoryCapabilities,
|
|
23
|
+
}),
|
|
24
|
+
Plugin.make,
|
|
25
|
+
);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { type OperationInvoker } from '@dxos/operation';
|
|
8
|
+
|
|
9
|
+
import { Capabilities } from '../../common';
|
|
10
|
+
import { Capability } from '../../core';
|
|
11
|
+
|
|
12
|
+
import * as HistoryTracker from './history-tracker';
|
|
13
|
+
import * as UndoRegistry from './undo-registry';
|
|
14
|
+
|
|
15
|
+
//
|
|
16
|
+
// Capability Module - contributes both UndoRegistry and HistoryTracker.
|
|
17
|
+
//
|
|
18
|
+
|
|
19
|
+
export default Capability.makeModule(
|
|
20
|
+
Effect.fnUntraced(function* () {
|
|
21
|
+
// Get the context for synchronous access in callbacks.
|
|
22
|
+
const capabilities = yield* Capability.Service;
|
|
23
|
+
|
|
24
|
+
// Create UndoRegistry.
|
|
25
|
+
const undoRegistry = UndoRegistry.make(() => capabilities.getAll(Capabilities.UndoMapping).flat());
|
|
26
|
+
|
|
27
|
+
// Create HistoryTracker (depends on UndoRegistry and OperationInvoker).
|
|
28
|
+
const invoker = yield* Capability.get(Capabilities.OperationInvoker);
|
|
29
|
+
// Cast to internal type - the factory always returns OperationInvokerInternal.
|
|
30
|
+
const historyTracker = HistoryTracker.make(invoker as OperationInvoker.OperationInvokerInternal, undoRegistry);
|
|
31
|
+
|
|
32
|
+
return [
|
|
33
|
+
Capability.contributes(Capabilities.UndoRegistry, undoRegistry),
|
|
34
|
+
Capability.contributes(Capabilities.HistoryTracker, historyTracker),
|
|
35
|
+
];
|
|
36
|
+
}),
|
|
37
|
+
);
|