@dxos/app-framework 0.8.4-main.72ec0f3 → 0.8.4-main.74a063c4e0
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-BBBBAPDI.mjs +38 -0
- package/dist/lib/browser/capability-BBBBAPDI.mjs.map +7 -0
- package/dist/lib/browser/capability-OP63CD5N.mjs +35 -0
- package/dist/lib/browser/capability-OP63CD5N.mjs.map +7 -0
- package/dist/lib/browser/chunk-2CKCJ6PN.mjs +79 -0
- package/dist/lib/browser/chunk-2CKCJ6PN.mjs.map +7 -0
- package/dist/lib/browser/chunk-F7FW2RK2.mjs +167 -0
- package/dist/lib/browser/chunk-F7FW2RK2.mjs.map +7 -0
- package/dist/lib/browser/chunk-FU4GAFUQ.mjs +148 -0
- package/dist/lib/browser/chunk-FU4GAFUQ.mjs.map +7 -0
- package/dist/lib/browser/chunk-GX4TUNM6.mjs +963 -0
- package/dist/lib/browser/chunk-GX4TUNM6.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-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-JKWMHZP6.mjs +80 -0
- package/dist/lib/browser/chunk-JKWMHZP6.mjs.map +7 -0
- package/dist/lib/browser/chunk-LVJW5EFU.mjs +157 -0
- package/dist/lib/browser/chunk-LVJW5EFU.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-RFSO3JRG.mjs +1 -0
- package/dist/lib/browser/chunk-T3Y4AEKX.mjs +42 -0
- package/dist/lib/browser/chunk-T3Y4AEKX.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-WPE6AL7I.mjs +905 -0
- package/dist/lib/browser/chunk-WPE6AL7I.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +90 -0
- package/dist/lib/browser/cli/index.mjs.map +7 -0
- package/dist/lib/browser/common/activation-events.mjs +24 -0
- package/dist/lib/browser/common/capabilities.mjs +46 -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 +30 -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/core/url-loader.mjs +12 -0
- package/dist/lib/browser/core/url-loader.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +92 -121
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/invoker-capability-H5PPENOC.mjs +43 -0
- package/dist/lib/browser/invoker-capability-H5PPENOC.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +108 -40
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/browser/ui/index.mjs +44 -0
- package/dist/lib/browser/ui/index.mjs.map +7 -0
- package/dist/lib/node-esm/capability-AWBEMRYR.mjs +39 -0
- package/dist/lib/node-esm/capability-AWBEMRYR.mjs.map +7 -0
- package/dist/lib/node-esm/capability-WFEG6CIZ.mjs +36 -0
- package/dist/lib/node-esm/capability-WFEG6CIZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-42KBWDE4.mjs +80 -0
- package/dist/lib/node-esm/chunk-42KBWDE4.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-4A3ZCMI3.mjs +158 -0
- package/dist/lib/node-esm/chunk-4A3ZCMI3.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-BCEOLX47.mjs +964 -0
- package/dist/lib/node-esm/chunk-BCEOLX47.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-EL3R25OQ.mjs +2 -0
- package/dist/lib/node-esm/chunk-EL3R25OQ.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-G3RTFSNG.mjs +81 -0
- package/dist/lib/node-esm/chunk-G3RTFSNG.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-LQKOTNJW.mjs +906 -0
- package/dist/lib/node-esm/chunk-LQKOTNJW.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ULUEXB7Q.mjs +149 -0
- package/dist/lib/node-esm/chunk-ULUEXB7Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-URWHJQT2.mjs +168 -0
- package/dist/lib/node-esm/chunk-URWHJQT2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VKHGNEDB.mjs +43 -0
- package/dist/lib/node-esm/chunk-VKHGNEDB.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-ZZ7CKK6W.mjs +49 -0
- package/dist/lib/node-esm/chunk-ZZ7CKK6W.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +91 -0
- package/dist/lib/node-esm/cli/index.mjs.map +7 -0
- package/dist/lib/node-esm/common/activation-events.mjs +25 -0
- package/dist/lib/node-esm/common/activation-events.mjs.map +7 -0
- package/dist/lib/node-esm/common/capabilities.mjs +47 -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 +31 -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/core/url-loader.mjs +13 -0
- package/dist/lib/node-esm/core/url-loader.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +92 -121
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/invoker-capability-S3ZA527J.mjs +44 -0
- package/dist/lib/node-esm/invoker-capability-S3ZA527J.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +108 -40
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/ui/index.mjs +45 -0
- package/dist/lib/node-esm/ui/index.mjs.map +7 -0
- package/dist/plugin/node-esm/index.mjs +384 -0
- package/dist/plugin/node-esm/index.mjs.map +7 -0
- package/dist/plugin/node-esm/meta.json +1 -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 +48 -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 +156 -0
- package/dist/types/src/core/capability.d.ts.map +1 -0
- package/dist/types/src/core/index.d.ts +6 -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/core/url-loader.d.ts +25 -0
- package/dist/types/src/core/url-loader.d.ts.map +1 -0
- package/dist/types/src/core/url-loader.test.d.ts +2 -0
- package/dist/types/src/core/url-loader.test.d.ts.map +1 -0
- 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/testing/withPluginManager.stories.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/src/vite-plugin/composer-plugin.d.ts +18 -0
- package/dist/types/src/vite-plugin/composer-plugin.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/import-map-plugin.d.ts +16 -0
- package/dist/types/src/vite-plugin/import-map-plugin.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/index.d.ts +3 -0
- package/dist/types/src/vite-plugin/index.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/packages.d.ts +7 -0
- package/dist/types/src/vite-plugin/packages.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/moon.yml +24 -6
- package/package.json +130 -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 +35 -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 +192 -0
- package/src/core/capability.ts +247 -0
- package/src/core/index.ts +6 -4
- package/src/core/plugin-manager.test.ts +1113 -0
- package/src/core/plugin-manager.ts +883 -0
- package/src/core/plugin.ts +230 -40
- package/src/core/url-loader.test.ts +79 -0
- package/src/core/url-loader.ts +148 -0
- package/src/index.ts +3 -2
- package/src/plugin-operation/OperationPlugin.ts +24 -0
- package/src/plugin-operation/history/capability.ts +36 -0
- package/src/plugin-operation/history/errors.ts +7 -0
- package/src/plugin-operation/history/history-tracker.test.ts +373 -0
- package/src/plugin-operation/history/history-tracker.ts +128 -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 +72 -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 +19 -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 -8
- 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} +55 -36
- package/src/ui/components/Surface/SurfaceComponent.tsx +266 -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 +289 -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/src/vite-plugin/composer-plugin.ts +128 -0
- package/src/vite-plugin/import-map-plugin.ts +314 -0
- package/src/vite-plugin/index.ts +6 -0
- package/src/vite-plugin/packages.ts +29 -0
- package/tsconfig.json +12 -27
- package/tsconfig.node.json +2 -4
- 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-RFSO3JRG.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
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { Compute, HalveCompute } from '../testing';
|
|
8
|
+
import * as UndoMapping from './undo-mapping';
|
|
9
|
+
import * as UndoRegistry from './undo-registry';
|
|
10
|
+
|
|
11
|
+
describe('UndoRegistry', () => {
|
|
12
|
+
test('looks up undo mapping by operation key', ({ expect }) => {
|
|
13
|
+
const undoMapping = UndoMapping.make({
|
|
14
|
+
operation: Compute,
|
|
15
|
+
inverse: HalveCompute,
|
|
16
|
+
deriveContext: (_input, output) => ({ value: output.value }),
|
|
17
|
+
});
|
|
18
|
+
const registry = UndoRegistry.make(() => [undoMapping]);
|
|
19
|
+
|
|
20
|
+
const result = registry.lookup(Compute);
|
|
21
|
+
expect(result).not.toBe(undefined);
|
|
22
|
+
expect(result?.inverse.meta.key).toBe('test.halve-compute');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('returns undefined for unmapped operations', ({ expect }) => {
|
|
26
|
+
const registry = UndoRegistry.make(() => []);
|
|
27
|
+
|
|
28
|
+
const result = registry.lookup(Compute);
|
|
29
|
+
expect(result).toBe(undefined);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('deriveContext extracts correct undo input', ({ expect }) => {
|
|
33
|
+
const undoMapping = UndoMapping.make({
|
|
34
|
+
operation: Compute,
|
|
35
|
+
inverse: HalveCompute,
|
|
36
|
+
// Note: This tests that input and output types are inferred correctly.
|
|
37
|
+
deriveContext: (input, output) => ({ value: output.value + input.value }),
|
|
38
|
+
});
|
|
39
|
+
const registry = UndoRegistry.make(() => [undoMapping]);
|
|
40
|
+
|
|
41
|
+
const result = registry.lookup(Compute);
|
|
42
|
+
const context = result?.deriveContext({ value: 5 }, { value: 10 });
|
|
43
|
+
expect(context).toEqual({ value: 15 });
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('resolveMessage', () => {
|
|
48
|
+
test('returns undefined for undefined message', ({ expect }) => {
|
|
49
|
+
const result = UndoMapping.resolveMessage(undefined, { value: 1 }, { value: 2 });
|
|
50
|
+
expect(result).toBe(undefined);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('returns static label as-is', ({ expect }) => {
|
|
54
|
+
const staticMessage: [string, { ns: string }] = ['test.message', { ns: 'test' }];
|
|
55
|
+
const result = UndoMapping.resolveMessage(staticMessage, { value: 1 }, { value: 2 });
|
|
56
|
+
expect(result).toEqual(staticMessage);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('calls function message with input and output', ({ expect }) => {
|
|
60
|
+
const messageFunc = (input: { value: number }, output: { value: number }): [string, { ns: string }] => [
|
|
61
|
+
`input-${input.value}-output-${output.value}`,
|
|
62
|
+
{ ns: 'test' },
|
|
63
|
+
];
|
|
64
|
+
const result = UndoMapping.resolveMessage(messageFunc, { value: 5 }, { value: 10 });
|
|
65
|
+
expect(result).toEqual(['input-5-output-10', { ns: 'test' }]);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('returns string label as-is', ({ expect }) => {
|
|
69
|
+
const result = UndoMapping.resolveMessage('simple string', { value: 1 }, { value: 2 });
|
|
70
|
+
expect(result).toBe('simple string');
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import type { Operation } from '@dxos/operation';
|
|
6
|
+
|
|
7
|
+
import type * as UndoMapping from './undo-mapping';
|
|
8
|
+
|
|
9
|
+
//
|
|
10
|
+
// Public Interface
|
|
11
|
+
//
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Lookup result from UndoRegistry.
|
|
15
|
+
*/
|
|
16
|
+
export type UndoMappingResult = {
|
|
17
|
+
inverse: Operation.Definition<any, any>;
|
|
18
|
+
/** Returns undefined to indicate the operation is not undoable. */
|
|
19
|
+
deriveContext: (input: any, output: any) => any | undefined;
|
|
20
|
+
/** Message provider - may be a static Label or a function. */
|
|
21
|
+
message?: UndoMapping.MessageProvider<Operation.Definition<any, any>>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* UndoRegistry interface - looks up inverse operations.
|
|
26
|
+
*/
|
|
27
|
+
export interface UndoRegistry {
|
|
28
|
+
lookup: (operation: Operation.Definition<any, any>) => UndoMappingResult | undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//
|
|
32
|
+
// Factory
|
|
33
|
+
//
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Creates an UndoRegistry that looks up inverse operations.
|
|
37
|
+
*/
|
|
38
|
+
export const make = (getMappings: () => UndoMapping.UndoMapping[]): UndoRegistry => {
|
|
39
|
+
const lookup = (operation: Operation.Definition<any, any>): UndoMappingResult | undefined => {
|
|
40
|
+
const mappings = getMappings();
|
|
41
|
+
const mapping = mappings.find((m) => m.operation.meta.key === operation.meta.key);
|
|
42
|
+
if (!mapping) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
inverse: mapping.inverse,
|
|
48
|
+
deriveContext: mapping.deriveContext,
|
|
49
|
+
message: mapping.message,
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return { lookup };
|
|
54
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { OperationHandlerSet, OperationInvoker } from '@dxos/operation';
|
|
8
|
+
|
|
9
|
+
import { ActivationEvents, Capabilities } from '../common';
|
|
10
|
+
import { Capability, Plugin } from '../core';
|
|
11
|
+
|
|
12
|
+
//
|
|
13
|
+
// Capability Module
|
|
14
|
+
//
|
|
15
|
+
|
|
16
|
+
export default Capability.makeModule(
|
|
17
|
+
Effect.fnUntraced(function* () {
|
|
18
|
+
// Get the services for synchronous access in callbacks.
|
|
19
|
+
const capabilityManager = yield* Capability.Service;
|
|
20
|
+
const pluginManager = yield* Plugin.Service;
|
|
21
|
+
|
|
22
|
+
// Get the ManagedRuntime capability (should be available since we activate after ManagedRuntimeReady).
|
|
23
|
+
const managedRuntime = yield* Capability.get(Capabilities.ManagedRuntime);
|
|
24
|
+
|
|
25
|
+
// Cache the merged handler promise to prevent concurrent module loading.
|
|
26
|
+
// Multiple Effects can invoke getHandlers simultaneously; without caching each
|
|
27
|
+
// creates a new merge() which triggers parallel dynamic imports that race in
|
|
28
|
+
// WebKit's module evaluator, causing TDZ errors on export default bindings.
|
|
29
|
+
let cachedSets: readonly OperationHandlerSet.OperationHandlerSet[] | undefined;
|
|
30
|
+
let cachedHandlers: ReturnType<OperationHandlerSet.OperationHandlerSet['getHandlers']> | undefined;
|
|
31
|
+
|
|
32
|
+
const invoker = OperationInvoker.make(
|
|
33
|
+
() =>
|
|
34
|
+
Effect.gen(function* () {
|
|
35
|
+
yield* Plugin.activate(ActivationEvents.SetupOperationHandler);
|
|
36
|
+
const sets = yield* Capability.getAll(Capabilities.OperationHandler);
|
|
37
|
+
|
|
38
|
+
if (sets !== cachedSets) {
|
|
39
|
+
cachedSets = sets;
|
|
40
|
+
cachedHandlers = OperationHandlerSet.merge(...sets).getHandlers();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return yield* Effect.promise(() => cachedHandlers!);
|
|
44
|
+
}).pipe(
|
|
45
|
+
Effect.provideService(Capability.Service, capabilityManager),
|
|
46
|
+
Effect.provideService(Plugin.Service, pluginManager),
|
|
47
|
+
Effect.orDie,
|
|
48
|
+
),
|
|
49
|
+
managedRuntime,
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
return Capability.contributes(Capabilities.OperationInvoker, invoker);
|
|
53
|
+
}),
|
|
54
|
+
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Plugin } from '../core';
|
|
6
|
+
|
|
7
|
+
export const meta: Plugin.Meta = {
|
|
8
|
+
id: 'org.dxos.plugin.operation',
|
|
9
|
+
name: 'Operation Plugin',
|
|
10
|
+
description: 'Provides operation invocation, undo registry, and history tracking.',
|
|
11
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Deferred from 'effect/Deferred';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import * as Fiber from 'effect/Fiber';
|
|
8
|
+
import * as Ref from 'effect/Ref';
|
|
9
|
+
import * as Schema from 'effect/Schema';
|
|
10
|
+
import * as Stream from 'effect/Stream';
|
|
11
|
+
|
|
12
|
+
import { Operation, type OperationInvoker } from '@dxos/operation';
|
|
13
|
+
|
|
14
|
+
//
|
|
15
|
+
// Test Operations
|
|
16
|
+
//
|
|
17
|
+
|
|
18
|
+
export const Compute = Operation.make({
|
|
19
|
+
input: Schema.Struct({ value: Schema.Number }),
|
|
20
|
+
output: Schema.Struct({ value: Schema.Number }),
|
|
21
|
+
meta: { key: 'test.compute' },
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const HalveCompute = Operation.make({
|
|
25
|
+
input: Schema.Struct({ value: Schema.Number }),
|
|
26
|
+
output: Schema.Struct({ value: Schema.Number }),
|
|
27
|
+
meta: { key: 'test.halve-compute' },
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const ToString = Operation.make({
|
|
31
|
+
input: Schema.Struct({ value: Schema.Number }),
|
|
32
|
+
output: Schema.Struct({ string: Schema.String }),
|
|
33
|
+
meta: { key: 'test.to-string' },
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const Add = Operation.make({
|
|
37
|
+
input: Schema.Tuple(Schema.Number, Schema.Number),
|
|
38
|
+
output: Schema.Number,
|
|
39
|
+
meta: { key: 'test.add' },
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export const SideEffect = Operation.make({
|
|
43
|
+
input: Schema.Void,
|
|
44
|
+
output: Schema.Void,
|
|
45
|
+
meta: { key: 'test.side-effect' },
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
//
|
|
49
|
+
// Test Handlers
|
|
50
|
+
//
|
|
51
|
+
|
|
52
|
+
export const computeHandler = Operation.withHandler(Compute, (data) =>
|
|
53
|
+
Effect.gen(function* () {
|
|
54
|
+
yield* Effect.sleep(data.value * 10);
|
|
55
|
+
return { value: data.value * 2 };
|
|
56
|
+
}),
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
export const halveComputeHandler = Operation.withHandler(HalveCompute, (data) =>
|
|
60
|
+
Effect.succeed({ value: data.value / 2 }),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
export const toStringHandler = Operation.withHandler(ToString, (data) =>
|
|
64
|
+
Effect.succeed({ string: data.value.toString() }),
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
export const addHandler = Operation.withHandler(Add, (data) => Effect.succeed(data[0] + data[1]));
|
|
68
|
+
|
|
69
|
+
export const sideEffectHandler = Operation.withHandler(SideEffect, () => Effect.succeed(undefined));
|
|
70
|
+
|
|
71
|
+
//
|
|
72
|
+
// Test Utilities
|
|
73
|
+
//
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Event collector for testing - provides deterministic event collection using Effect primitives.
|
|
77
|
+
*/
|
|
78
|
+
export interface EventCollector {
|
|
79
|
+
/** All collected events. */
|
|
80
|
+
readonly events: OperationInvoker.InvocationEvent[];
|
|
81
|
+
/** Wait until N events have been collected. */
|
|
82
|
+
waitForEvents: (count: number) => Effect.Effect<void>;
|
|
83
|
+
/** Clean up the subscription fiber. */
|
|
84
|
+
dispose: Effect.Effect<void>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Creates an event collector that subscribes to invoker events.
|
|
89
|
+
* Uses Effect primitives for synchronization.
|
|
90
|
+
*/
|
|
91
|
+
export const createEventCollector = (invoker: OperationInvoker.OperationInvoker): Effect.Effect<EventCollector> =>
|
|
92
|
+
Effect.gen(function* () {
|
|
93
|
+
const events: OperationInvoker.InvocationEvent[] = [];
|
|
94
|
+
|
|
95
|
+
// Ref to track current waiter (waiting for N events).
|
|
96
|
+
const waiterRef = yield* Ref.make<{ count: number; deferred: Deferred.Deferred<void> } | null>(null);
|
|
97
|
+
|
|
98
|
+
// Deferred to signal when subscription is ready.
|
|
99
|
+
const subscriptionReady = yield* Deferred.make<void>();
|
|
100
|
+
|
|
101
|
+
const checkWaiter = Effect.gen(function* () {
|
|
102
|
+
const waiter = yield* Ref.get(waiterRef);
|
|
103
|
+
if (waiter && events.length >= waiter.count) {
|
|
104
|
+
yield* Deferred.succeed(waiter.deferred, undefined);
|
|
105
|
+
yield* Ref.set(waiterRef, null);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Fork a fiber to consume the invocation stream.
|
|
110
|
+
const fiber = yield* Effect.fork(
|
|
111
|
+
Effect.gen(function* () {
|
|
112
|
+
// Signal that subscription is about to start.
|
|
113
|
+
yield* Deferred.succeed(subscriptionReady, undefined);
|
|
114
|
+
yield* Stream.fromPubSub(invoker.invocations).pipe(
|
|
115
|
+
Stream.runForEach((event) =>
|
|
116
|
+
Effect.gen(function* () {
|
|
117
|
+
events.push(event);
|
|
118
|
+
yield* checkWaiter;
|
|
119
|
+
}),
|
|
120
|
+
),
|
|
121
|
+
);
|
|
122
|
+
}),
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
// Wait for the subscription to be established.
|
|
126
|
+
yield* Deferred.await(subscriptionReady);
|
|
127
|
+
// Additional yield to ensure PubSub subscription is fully registered.
|
|
128
|
+
yield* Effect.yieldNow();
|
|
129
|
+
|
|
130
|
+
const waitForEvents = (count: number): Effect.Effect<void> =>
|
|
131
|
+
Effect.gen(function* () {
|
|
132
|
+
if (events.length >= count) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const deferred = yield* Deferred.make<void>();
|
|
136
|
+
yield* Ref.set(waiterRef, { count, deferred });
|
|
137
|
+
yield* Deferred.await(deferred);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const dispose = Fiber.interrupt(fiber);
|
|
141
|
+
|
|
142
|
+
return { events, waitForEvents, dispose };
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Waits until a condition is true, yielding to the JS event loop between checks.
|
|
147
|
+
* Uses setImmediate to allow other async work to complete.
|
|
148
|
+
*/
|
|
149
|
+
export const waitUntil = (condition: () => boolean): Effect.Effect<void> =>
|
|
150
|
+
Effect.gen(function* () {
|
|
151
|
+
while (!condition()) {
|
|
152
|
+
yield* Effect.promise(() => new Promise((r) => setImmediate(r)));
|
|
153
|
+
}
|
|
154
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { ActivationEvents } from '../common';
|
|
6
|
+
import { Capability, Plugin } from '../core';
|
|
7
|
+
import { meta } from './meta';
|
|
8
|
+
|
|
9
|
+
const ManagedRuntimeCapability = Capability.lazy('ManagedRuntime', () => import('./capability'));
|
|
10
|
+
|
|
11
|
+
export const RuntimePlugin = Plugin.define(meta).pipe(
|
|
12
|
+
Plugin.addModule({
|
|
13
|
+
activatesOn: ActivationEvents.Startup,
|
|
14
|
+
activatesBefore: [ActivationEvents.SetupLayer],
|
|
15
|
+
activatesAfter: [ActivationEvents.ManagedRuntimeReady],
|
|
16
|
+
activate: ManagedRuntimeCapability,
|
|
17
|
+
}),
|
|
18
|
+
Plugin.make,
|
|
19
|
+
);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Layer from 'effect/Layer';
|
|
7
|
+
import * as ManagedRuntime from 'effect/ManagedRuntime';
|
|
8
|
+
|
|
9
|
+
import { ActivationEvents, Capabilities } from '../common';
|
|
10
|
+
import { Capability, Plugin } from '../core';
|
|
11
|
+
|
|
12
|
+
//
|
|
13
|
+
// Capability Module
|
|
14
|
+
//
|
|
15
|
+
|
|
16
|
+
export default Capability.makeModule(
|
|
17
|
+
Effect.fnUntraced(function* () {
|
|
18
|
+
// Get the CapabilityManager to create a layer for it.
|
|
19
|
+
const capabilityManager = yield* Capability.Service;
|
|
20
|
+
|
|
21
|
+
// Get the PluginManager to create a layer for it.
|
|
22
|
+
const pluginManager = yield* Plugin.Service;
|
|
23
|
+
|
|
24
|
+
// Trigger setup event so plugins can contribute their layers.
|
|
25
|
+
yield* Plugin.activate(ActivationEvents.SetupLayer);
|
|
26
|
+
|
|
27
|
+
// Gather all contributed layers.
|
|
28
|
+
const layers = yield* Capability.getAll(Capabilities.Layer);
|
|
29
|
+
|
|
30
|
+
// Create layers that provide Capability.Service and Plugin.Service.
|
|
31
|
+
const capabilityServiceLayer = Layer.succeed(Capability.Service, capabilityManager);
|
|
32
|
+
const pluginServiceLayer = Layer.succeed(Plugin.Service, pluginManager);
|
|
33
|
+
|
|
34
|
+
// Merge all layers including service layers.
|
|
35
|
+
// Layer.mergeAll requires a tuple type, so we use a cast for dynamic arrays.
|
|
36
|
+
const composedLayer =
|
|
37
|
+
layers.length > 0
|
|
38
|
+
? (Layer.mergeAll as (...args: Layer.Layer<any, any, any>[]) => Layer.Layer<any, any, never>)(
|
|
39
|
+
capabilityServiceLayer,
|
|
40
|
+
pluginServiceLayer,
|
|
41
|
+
...layers,
|
|
42
|
+
)
|
|
43
|
+
: (Layer.mergeAll as (...args: Layer.Layer<any, any, any>[]) => Layer.Layer<any, any, never>)(
|
|
44
|
+
capabilityServiceLayer,
|
|
45
|
+
pluginServiceLayer,
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
// Create the managed runtime from the composed layer.
|
|
49
|
+
const runtime = ManagedRuntime.make(composedLayer) as Capabilities.ManagedRuntime;
|
|
50
|
+
|
|
51
|
+
return Capability.contributes(Capabilities.ManagedRuntime, runtime);
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Plugin } from '../core';
|
|
6
|
+
|
|
7
|
+
export const meta: Plugin.Meta = {
|
|
8
|
+
id: 'org.dxos.plugin.runtime',
|
|
9
|
+
name: 'Runtime Plugin',
|
|
10
|
+
description: 'Provides a managed Effect runtime by composing contributed layers.',
|
|
11
|
+
};
|
package/src/testing/index.ts
CHANGED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Layer from 'effect/Layer';
|
|
7
|
+
|
|
8
|
+
import { invariant } from '@dxos/invariant';
|
|
9
|
+
|
|
10
|
+
import { ActivationEvents, Capabilities } from '../common';
|
|
11
|
+
import { Plugin, PluginManager } from '../core';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Creates a Plugin.Service layer from a list of plugins.
|
|
15
|
+
* This is primarily used for testing.
|
|
16
|
+
*/
|
|
17
|
+
export const fromPlugins = (plugins: Plugin.Plugin[]) =>
|
|
18
|
+
Layer.effect(
|
|
19
|
+
Plugin.Service,
|
|
20
|
+
Effect.gen(function* () {
|
|
21
|
+
// TODO(wittjosiah): Try to dedupe logic between here, createCliApp and useApp.
|
|
22
|
+
|
|
23
|
+
const pluginLoader = (id: string) =>
|
|
24
|
+
Effect.sync(() => {
|
|
25
|
+
const plugin = plugins.find((plugin) => plugin.meta.id === id);
|
|
26
|
+
invariant(plugin, `Plugin not found: ${id}`);
|
|
27
|
+
return plugin;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const manager = PluginManager.make({
|
|
31
|
+
pluginLoader,
|
|
32
|
+
plugins,
|
|
33
|
+
core: plugins.map((plugin) => plugin.meta.id),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
manager.capabilities.contribute({
|
|
37
|
+
interface: Capabilities.PluginManager,
|
|
38
|
+
implementation: manager,
|
|
39
|
+
module: 'org.dxos.app-framework.plugin-manager',
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
manager.capabilities.contribute({
|
|
43
|
+
interface: Capabilities.AtomRegistry,
|
|
44
|
+
implementation: manager.registry,
|
|
45
|
+
module: 'org.dxos.app-framework.atom-registry',
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
yield* manager.activate(ActivationEvents.Startup);
|
|
49
|
+
|
|
50
|
+
return manager;
|
|
51
|
+
}),
|
|
52
|
+
);
|
|
@@ -7,10 +7,9 @@ import React from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { withTheme } from '@dxos/react-ui/testing';
|
|
9
9
|
|
|
10
|
-
import { Capabilities
|
|
11
|
-
import {
|
|
12
|
-
import { Surface } from '../
|
|
13
|
-
|
|
10
|
+
import { Capabilities } from '../common';
|
|
11
|
+
import { Capability } from '../core';
|
|
12
|
+
import { Surface } from '../ui';
|
|
14
13
|
import { withPluginManager } from './withPluginManager';
|
|
15
14
|
|
|
16
15
|
const DefaultStory = () => {
|
|
@@ -18,7 +17,7 @@ const DefaultStory = () => {
|
|
|
18
17
|
return (
|
|
19
18
|
<div>
|
|
20
19
|
<div>Hello</div>
|
|
21
|
-
<Surface role='main' />
|
|
20
|
+
<Surface.Surface role='main' />
|
|
22
21
|
</div>
|
|
23
22
|
);
|
|
24
23
|
};
|
|
@@ -27,12 +26,12 @@ const meta = {
|
|
|
27
26
|
title: 'sdk/app-framework/withPluginManager',
|
|
28
27
|
render: DefaultStory,
|
|
29
28
|
decorators: [
|
|
30
|
-
withTheme,
|
|
29
|
+
withTheme(),
|
|
31
30
|
withPluginManager({
|
|
32
31
|
capabilities: [
|
|
33
|
-
contributes(
|
|
32
|
+
Capability.contributes(
|
|
34
33
|
Capabilities.ReactSurface,
|
|
35
|
-
|
|
34
|
+
Surface.create({
|
|
36
35
|
id: 'test',
|
|
37
36
|
role: 'main',
|
|
38
37
|
component: ({ role }) => <span>{JSON.stringify({ role })}</span>,
|