@dxos/app-framework 0.8.4-main.a4bbb77 → 0.8.4-main.abd8ff62ef
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-Q5XRXRD2.mjs +38 -0
- package/dist/lib/browser/capability-Q5XRXRD2.mjs.map +7 -0
- package/dist/lib/browser/capability-V7LR4LQN.mjs +35 -0
- package/dist/lib/browser/capability-V7LR4LQN.mjs.map +7 -0
- package/dist/lib/browser/chunk-23D4SJUE.mjs +42 -0
- package/dist/lib/browser/chunk-23D4SJUE.mjs.map +7 -0
- package/dist/lib/browser/chunk-3JWJXGLK.mjs +79 -0
- package/dist/lib/browser/chunk-3JWJXGLK.mjs.map +7 -0
- package/dist/lib/browser/chunk-3ZS2A3DN.mjs +907 -0
- package/dist/lib/browser/chunk-3ZS2A3DN.mjs.map +7 -0
- package/dist/lib/browser/chunk-45CHLTBV.mjs +34 -0
- package/dist/lib/browser/chunk-45CHLTBV.mjs.map +7 -0
- package/dist/lib/browser/chunk-5LAIGWLU.mjs +467 -0
- package/dist/lib/browser/chunk-5LAIGWLU.mjs.map +7 -0
- package/dist/lib/browser/chunk-66IXTIVK.mjs +48 -0
- package/dist/lib/browser/chunk-66IXTIVK.mjs.map +7 -0
- package/dist/lib/browser/chunk-FJ4765WW.mjs +8 -0
- package/dist/lib/browser/chunk-FJ4765WW.mjs.map +7 -0
- package/dist/lib/browser/chunk-G7SDBRKH.mjs +1 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-JXCBZSBJ.mjs +372 -0
- package/dist/lib/browser/chunk-JXCBZSBJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-MX5DKEJH.mjs +584 -0
- package/dist/lib/browser/chunk-MX5DKEJH.mjs.map +7 -0
- package/dist/lib/browser/chunk-WBHCSOBW.mjs +80 -0
- package/dist/lib/browser/chunk-WBHCSOBW.mjs.map +7 -0
- package/dist/lib/browser/chunk-Z55LVAGN.mjs +213 -0
- package/dist/lib/browser/chunk-Z55LVAGN.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZGJAZSNE.mjs +142 -0
- package/dist/lib/browser/chunk-ZGJAZSNE.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +74 -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 +17 -0
- package/dist/lib/browser/core/plugin-manager.mjs.map +7 -0
- package/dist/lib/browser/core/plugin.mjs +37 -0
- package/dist/lib/browser/core/plugin.mjs.map +7 -0
- package/dist/lib/browser/core/url-loader.mjs +20 -0
- package/dist/lib/browser/core/url-loader.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +95 -148
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/invoker-capability-LNX4CGIV.mjs +44 -0
- package/dist/lib/browser/invoker-capability-LNX4CGIV.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +227 -41
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/browser/testing/react.mjs +78 -0
- package/dist/lib/browser/testing/react.mjs.map +7 -0
- package/dist/lib/browser/ui/index.mjs +48 -0
- package/dist/lib/browser/ui/index.mjs.map +7 -0
- package/dist/lib/node-esm/capability-EW5GJCI6.mjs +39 -0
- package/dist/lib/node-esm/capability-EW5GJCI6.mjs.map +7 -0
- package/dist/lib/node-esm/capability-YKBMMD53.mjs +36 -0
- package/dist/lib/node-esm/capability-YKBMMD53.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-37Z53PXZ.mjs +10 -0
- package/dist/lib/node-esm/chunk-37Z53PXZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-6XW6LET6.mjs +35 -0
- package/dist/lib/node-esm/chunk-6XW6LET6.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-D347W3KO.mjs +143 -0
- package/dist/lib/node-esm/chunk-D347W3KO.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-D5PO2WXX.mjs +373 -0
- package/dist/lib/node-esm/chunk-D5PO2WXX.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-HTBJU5FX.mjs +214 -0
- package/dist/lib/node-esm/chunk-HTBJU5FX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-KM2F6GH6.mjs +468 -0
- package/dist/lib/node-esm/chunk-KM2F6GH6.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-OZ7DZA5Z.mjs +2 -0
- package/dist/lib/node-esm/chunk-OZ7DZA5Z.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-Q7XBFII4.mjs +908 -0
- package/dist/lib/node-esm/chunk-Q7XBFII4.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SBS2YMPT.mjs +43 -0
- package/dist/lib/node-esm/chunk-SBS2YMPT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SDJ4B2LU.mjs +80 -0
- package/dist/lib/node-esm/chunk-SDJ4B2LU.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WFSRZKBP.mjs +81 -0
- package/dist/lib/node-esm/chunk-WFSRZKBP.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WKTLE7MG.mjs +585 -0
- package/dist/lib/node-esm/chunk-WKTLE7MG.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-XOCUANHO.mjs +49 -0
- package/dist/lib/node-esm/chunk-XOCUANHO.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +75 -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 +18 -0
- package/dist/lib/node-esm/core/plugin-manager.mjs.map +7 -0
- package/dist/lib/node-esm/core/plugin.mjs +38 -0
- package/dist/lib/node-esm/core/plugin.mjs.map +7 -0
- package/dist/lib/node-esm/core/url-loader.mjs +21 -0
- package/dist/lib/node-esm/core/url-loader.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +95 -148
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/invoker-capability-O4T5PHLA.mjs +45 -0
- package/dist/lib/node-esm/invoker-capability-O4T5PHLA.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +227 -41
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/testing/react.mjs +79 -0
- package/dist/lib/node-esm/testing/react.mjs.map +7 -0
- package/dist/lib/node-esm/ui/index.mjs +49 -0
- package/dist/lib/node-esm/ui/index.mjs.map +7 -0
- package/dist/plugin/node-esm/index.mjs +832 -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 +110 -197
- 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 +8 -8
- 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} +11 -11
- 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 +8 -4
- package/dist/types/src/core/index.d.ts.map +1 -1
- package/dist/types/src/core/plugin-asset-cache.d.ts +71 -0
- package/dist/types/src/core/plugin-asset-cache.d.ts.map +1 -0
- package/dist/types/src/core/plugin-manager.d.ts +122 -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-manifest.d.ts +76 -0
- package/dist/types/src/core/plugin-manifest.d.ts.map +1 -0
- package/dist/types/src/core/plugin-manifest.test.d.ts +2 -0
- package/dist/types/src/core/plugin-manifest.test.d.ts.map +1 -0
- package/dist/types/src/core/plugin.d.ts +207 -39
- package/dist/types/src/core/plugin.d.ts.map +1 -1
- package/dist/types/src/core/url-loader.d.ts +112 -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/helpers.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -4
- 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 +59 -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/harness.d.ts +67 -0
- package/dist/types/src/testing/harness.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/react.d.ts +27 -0
- package/dist/types/src/testing/react.d.ts.map +1 -0
- package/dist/types/src/testing/react.test.d.ts +2 -0
- package/dist/types/src/testing/react.test.d.ts.map +1 -0
- 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 +7 -6
- 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/ui/components/Placeholder/Placeholder.d.ts +64 -0
- package/dist/types/src/ui/components/Placeholder/Placeholder.d.ts.map +1 -0
- package/dist/types/src/ui/components/Placeholder/Placeholder.stories.d.ts +19 -0
- package/dist/types/src/ui/components/Placeholder/Placeholder.stories.d.ts.map +1 -0
- package/dist/types/src/ui/components/Placeholder/index.d.ts +2 -0
- package/dist/types/src/ui/components/Placeholder/index.d.ts.map +1 -0
- package/dist/types/src/{playground/playground.stories.d.ts → ui/components/PluginManager/PluginManagerContext.stories.d.ts} +5 -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 +24 -0
- package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts.map +1 -0
- package/dist/types/src/{components/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 +36 -0
- package/dist/types/src/ui/components/Surface/index.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/types.d.ts +197 -0
- package/dist/types/src/ui/components/Surface/types.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/types.test.d.ts +2 -0
- package/dist/types/src/ui/components/Surface/types.test.d.ts.map +1 -0
- package/dist/types/src/ui/components/index.d.ts +5 -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/ui/hooks/useApp.d.ts +88 -0
- 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/{components → 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/boot-loader/BootLoader.stories.d.ts +34 -0
- package/dist/types/src/vite-plugin/boot-loader/BootLoader.stories.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/boot-loader/index.d.ts +52 -0
- package/dist/types/src/vite-plugin/boot-loader/index.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/composer/index.d.ts +34 -0
- package/dist/types/src/vite-plugin/composer/index.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/import-map/index.d.ts +28 -0
- package/dist/types/src/vite-plugin/import-map/index.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/index.d.ts +5 -0
- package/dist/types/src/vite-plugin/index.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/manifest.d.ts +37 -0
- package/dist/types/src/vite-plugin/manifest.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/manifest.test.d.ts +2 -0
- package/dist/types/src/vite-plugin/manifest.test.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/packages.d.ts +13 -0
- package/dist/types/src/vite-plugin/packages.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/moon.yml +25 -6
- package/package.json +112 -55
- package/src/cli/cli.ts +107 -0
- package/src/{components → cli}/index.ts +1 -1
- package/src/common/activation-events.ts +44 -0
- package/src/common/capabilities.ts +169 -210
- package/src/common/index.ts +4 -8
- package/src/common/operations.ts +35 -0
- package/src/common/translations.ts +18 -10
- 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 +8 -4
- package/src/core/plugin-asset-cache.ts +60 -0
- package/src/core/plugin-manager.test.ts +1354 -0
- package/src/core/plugin-manager.ts +1025 -0
- package/src/core/plugin-manifest.test.ts +48 -0
- package/src/core/plugin-manifest.ts +102 -0
- package/src/core/plugin.ts +365 -45
- package/src/core/url-loader.test.ts +178 -0
- package/src/core/url-loader.ts +337 -0
- package/src/index.ts +3 -4
- 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 +374 -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 +55 -0
- package/src/plugin-operation/meta.ts +11 -0
- package/src/plugin-operation/testing.ts +155 -0
- package/src/plugin-runtime/RuntimePlugin.ts +19 -0
- package/src/plugin-runtime/capability.ts +53 -0
- package/src/{playground/layout → plugin-runtime}/index.ts +1 -1
- package/src/plugin-runtime/meta.ts +11 -0
- package/src/testing/harness.ts +229 -0
- package/src/testing/index.ts +2 -0
- package/src/testing/react.test.tsx +48 -0
- package/src/testing/react.tsx +113 -0
- package/src/testing/service.ts +52 -0
- package/src/testing/withPluginManager.stories.tsx +8 -9
- package/src/testing/withPluginManager.tsx +68 -40
- package/src/ui/components/App/App.stories.tsx +92 -0
- package/src/ui/components/App/App.tsx +81 -0
- package/src/{playground/debug → ui/components/App}/index.ts +1 -1
- package/src/ui/components/Placeholder/Placeholder.stories.tsx +77 -0
- package/src/ui/components/Placeholder/Placeholder.tsx +155 -0
- package/src/{playground/logger → ui/components/Placeholder}/index.ts +1 -1
- package/src/ui/components/PluginManager/PluginManagerContext.stories.tsx +185 -0
- package/src/{react → ui/components/PluginManager}/PluginManagerProvider.ts +3 -3
- package/src/ui/components/PluginManager/index.ts +5 -0
- package/src/ui/components/Surface/SurfaceComponent.stories.tsx +144 -0
- package/src/ui/components/Surface/SurfaceComponent.tsx +303 -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 +54 -0
- package/src/ui/components/Surface/types.test.ts +126 -0
- package/src/ui/components/Surface/types.ts +269 -0
- package/src/ui/components/index.ts +8 -0
- package/src/ui/hooks/index.ts +9 -0
- package/src/ui/hooks/useApp.test.tsx +159 -0
- package/src/ui/hooks/useApp.tsx +413 -0
- package/src/ui/hooks/useCapabilities.ts +67 -0
- package/src/{components → ui/hooks}/useLoading.tsx +16 -10
- 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/boot-loader/BootLoader.stories.tsx +263 -0
- package/src/vite-plugin/boot-loader/boot-loader.css +294 -0
- package/src/vite-plugin/boot-loader/boot-loader.js +274 -0
- package/src/vite-plugin/boot-loader/index.ts +112 -0
- package/src/vite-plugin/composer/index.ts +277 -0
- package/src/vite-plugin/import-map/index.ts +524 -0
- package/src/vite-plugin/index.ts +10 -0
- package/src/vite-plugin/manifest.test.ts +24 -0
- package/src/vite-plugin/manifest.ts +50 -0
- package/src/vite-plugin/packages.ts +188 -0
- package/tsconfig.json +18 -15
- 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/727453fb3a62f7f1d952a41e051ca8a6f88cadc45cee43c6a4d1aa45f9b75665.wasmer-v7 +0 -0
- package/.swc/plugins/linux_x86_64_19.0.0/fce1bdb8e20a094e4af08bad09cc81497ed0e2e7c51223b07d371063cca18429.wasmer-v7 +0 -0
- package/dist/lib/browser/app-graph-builder-XH4OYQLC.mjs +0 -137
- package/dist/lib/browser/app-graph-builder-XH4OYQLC.mjs.map +0 -7
- package/dist/lib/browser/chunk-6V54SRFL.mjs +0 -1638
- package/dist/lib/browser/chunk-6V54SRFL.mjs.map +0 -7
- package/dist/lib/browser/chunk-RGKMLI6U.mjs +0 -35
- package/dist/lib/browser/chunk-RGKMLI6U.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZZVFNUHZ.mjs +0 -467
- package/dist/lib/browser/chunk-ZZVFNUHZ.mjs.map +0 -7
- package/dist/lib/browser/intent-dispatcher-VFMJVO2M.mjs +0 -11
- package/dist/lib/browser/intent-resolver-ICAPD4JL.mjs +0 -39
- package/dist/lib/browser/intent-resolver-ICAPD4JL.mjs.map +0 -7
- package/dist/lib/browser/store-7ZGMHOGB.mjs +0 -30
- package/dist/lib/browser/store-7ZGMHOGB.mjs.map +0 -7
- package/dist/lib/browser/worker.mjs +0 -77
- package/dist/lib/node-esm/app-graph-builder-C7H22SOL.mjs +0 -138
- package/dist/lib/node-esm/app-graph-builder-C7H22SOL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AXSZKZFD.mjs +0 -468
- package/dist/lib/node-esm/chunk-AXSZKZFD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LKPMRTRR.mjs +0 -37
- package/dist/lib/node-esm/chunk-LKPMRTRR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SOVTUUAY.mjs +0 -1640
- package/dist/lib/node-esm/chunk-SOVTUUAY.mjs.map +0 -7
- package/dist/lib/node-esm/intent-dispatcher-SAPOKSLZ.mjs +0 -12
- package/dist/lib/node-esm/intent-resolver-CRNJ6BMD.mjs +0 -40
- package/dist/lib/node-esm/intent-resolver-CRNJ6BMD.mjs.map +0 -7
- package/dist/lib/node-esm/store-H4F4RMYD.mjs +0 -31
- package/dist/lib/node-esm/store-H4F4RMYD.mjs.map +0 -7
- package/dist/lib/node-esm/worker.mjs +0 -78
- 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 -59
- package/dist/types/src/common/surface.d.ts.map +0 -1
- package/dist/types/src/components/App.d.ts +0 -10
- package/dist/types/src/components/App.d.ts.map +0 -1
- package/dist/types/src/components/App.stories.d.ts.map +0 -1
- package/dist/types/src/components/DefaultFallback.d.ts +0 -8
- package/dist/types/src/components/DefaultFallback.d.ts.map +0 -1
- package/dist/types/src/components/index.d.ts +0 -2
- package/dist/types/src/components/index.d.ts.map +0 -1
- package/dist/types/src/components/useApp.d.ts +0 -44
- package/dist/types/src/components/useApp.d.ts.map +0 -1
- package/dist/types/src/components/useLoading.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.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/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 +0 -17
- 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 -7
- package/dist/types/src/react/index.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/worker.d.ts +0 -4
- package/dist/types/src/worker.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 -83
- package/src/components/App.stories.tsx +0 -33
- package/src/components/App.tsx +0 -59
- package/src/components/DefaultFallback.tsx +0 -26
- package/src/components/useApp.tsx +0 -164
- package/src/core/capabilities.test.ts +0 -136
- package/src/core/capabilities.ts +0 -259
- package/src/core/manager.test.ts +0 -516
- package/src/core/manager.ts +0 -597
- package/src/playground/debug/Debug.tsx +0 -39
- package/src/playground/debug/plugin.ts +0 -16
- package/src/playground/generator/Main.tsx +0 -71
- 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 -279
- package/src/plugin-intent/intent-dispatcher.ts +0 -334
- 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 -159
- 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/ErrorBoundary.tsx +0 -54
- package/src/react/IntentContext.tsx +0 -35
- package/src/react/Surface.stories.tsx +0 -101
- package/src/react/Surface.tsx +0 -86
- package/src/react/common.ts +0 -13
- package/src/react/index.ts +0 -10
- package/src/react/useCapabilities.ts +0 -31
- package/src/react/useIntentResolver.ts +0 -22
- package/src/worker.ts +0 -11
- /package/dist/lib/browser/{intent-dispatcher-VFMJVO2M.mjs.map → chunk-G7SDBRKH.mjs.map} +0 -0
- /package/dist/lib/browser/{worker.mjs.map → chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{node-esm/intent-dispatcher-SAPOKSLZ.mjs.map → browser/common/activation-events.mjs.map} +0 -0
- /package/dist/lib/{node-esm/worker.mjs.map → browser/common/capabilities.mjs.map} +0 -0
|
@@ -1,1638 +0,0 @@
|
|
|
1
|
-
// src/plugin-intent/intent-dispatcher.ts
|
|
2
|
-
import { Effect as Effect3, Option, Ref as Ref2, pipe as pipe2 } from "effect";
|
|
3
|
-
import { live as live2 } from "@dxos/live-object";
|
|
4
|
-
import { log as log3 } from "@dxos/log";
|
|
5
|
-
import { byPosition } from "@dxos/util";
|
|
6
|
-
|
|
7
|
-
// src/core/capabilities.ts
|
|
8
|
-
import { Rx } from "@effect-rx/rx-react";
|
|
9
|
-
import { Effect } from "effect";
|
|
10
|
-
import { Trigger } from "@dxos/async";
|
|
11
|
-
import { invariant } from "@dxos/invariant";
|
|
12
|
-
import { log } from "@dxos/log";
|
|
13
|
-
function _define_property(obj, key, value) {
|
|
14
|
-
if (key in obj) {
|
|
15
|
-
Object.defineProperty(obj, key, {
|
|
16
|
-
value,
|
|
17
|
-
enumerable: true,
|
|
18
|
-
configurable: true,
|
|
19
|
-
writable: true
|
|
20
|
-
});
|
|
21
|
-
} else {
|
|
22
|
-
obj[key] = value;
|
|
23
|
-
}
|
|
24
|
-
return obj;
|
|
25
|
-
}
|
|
26
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/capabilities.ts";
|
|
27
|
-
var InterfaceDefTypeId = Symbol.for("InterfaceDefTypeId");
|
|
28
|
-
var defineCapability = (identifier) => {
|
|
29
|
-
return {
|
|
30
|
-
identifier
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
var CapabilityImpl = class {
|
|
34
|
-
constructor(moduleId, implementation) {
|
|
35
|
-
_define_property(this, "moduleId", void 0);
|
|
36
|
-
_define_property(this, "implementation", void 0);
|
|
37
|
-
this.moduleId = moduleId;
|
|
38
|
-
this.implementation = implementation;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
var contributes = (interfaceDef, implementation, deactivate) => {
|
|
42
|
-
return {
|
|
43
|
-
interface: interfaceDef,
|
|
44
|
-
implementation,
|
|
45
|
-
deactivate
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
var lazy = (c) => async (props) => {
|
|
49
|
-
const { default: getCapability } = await c();
|
|
50
|
-
return async () => getCapability(props);
|
|
51
|
-
};
|
|
52
|
-
var PluginContext = class {
|
|
53
|
-
/**
|
|
54
|
-
* @internal
|
|
55
|
-
*/
|
|
56
|
-
contributeCapability({ module: moduleId, interface: interfaceDef, implementation }) {
|
|
57
|
-
const current = this._registry.get(this._capabilityImpls(interfaceDef.identifier));
|
|
58
|
-
const capability = new CapabilityImpl(moduleId, implementation);
|
|
59
|
-
if (current.includes(capability)) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
this._registry.set(this._capabilityImpls(interfaceDef.identifier), [
|
|
63
|
-
...current,
|
|
64
|
-
capability
|
|
65
|
-
]);
|
|
66
|
-
log("capability contributed", {
|
|
67
|
-
id: interfaceDef.identifier,
|
|
68
|
-
moduleId,
|
|
69
|
-
count: current.length
|
|
70
|
-
}, {
|
|
71
|
-
F: __dxlog_file,
|
|
72
|
-
L: 166,
|
|
73
|
-
S: this,
|
|
74
|
-
C: (f, a) => f(...a)
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* @internal
|
|
79
|
-
*/
|
|
80
|
-
removeCapability(interfaceDef, implementation) {
|
|
81
|
-
const current = this._registry.get(this._capabilityImpls(interfaceDef.identifier));
|
|
82
|
-
if (current.length === 0) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
const next = current.filter((c) => c.implementation !== implementation);
|
|
86
|
-
if (next.length !== current.length) {
|
|
87
|
-
this._registry.set(this._capabilityImpls(interfaceDef.identifier), next);
|
|
88
|
-
log("capability removed", {
|
|
89
|
-
id: interfaceDef.identifier,
|
|
90
|
-
count: current.length
|
|
91
|
-
}, {
|
|
92
|
-
F: __dxlog_file,
|
|
93
|
-
L: 185,
|
|
94
|
-
S: this,
|
|
95
|
-
C: (f, a) => f(...a)
|
|
96
|
-
});
|
|
97
|
-
} else {
|
|
98
|
-
log.warn("capability not removed", {
|
|
99
|
-
id: interfaceDef.identifier
|
|
100
|
-
}, {
|
|
101
|
-
F: __dxlog_file,
|
|
102
|
-
L: 187,
|
|
103
|
-
S: this,
|
|
104
|
-
C: (f, a) => f(...a)
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Get the Rx reference to the available capabilities for a given interface.
|
|
110
|
-
* Primarily useful for deriving other Rx values based on the capabilities or
|
|
111
|
-
* for subscribing to changes in the capabilities.
|
|
112
|
-
* @returns An Rx reference to the available capabilities.
|
|
113
|
-
*/
|
|
114
|
-
capabilities(interfaceDef) {
|
|
115
|
-
return this._capabilities(interfaceDef.identifier);
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Get the Rx reference to the available capabilities for a given interface.
|
|
119
|
-
* Primarily useful for deriving other Rx values based on the capability or
|
|
120
|
-
* for subscribing to changes in the capability.
|
|
121
|
-
* @returns An Rx reference to the available capability.
|
|
122
|
-
* @throws If no capability is found.
|
|
123
|
-
*/
|
|
124
|
-
capability(interfaceDef) {
|
|
125
|
-
return this._capability(interfaceDef.identifier);
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Get capabilities from the plugin context.
|
|
129
|
-
* @returns An array of capabilities.
|
|
130
|
-
*/
|
|
131
|
-
getCapabilities(interfaceDef) {
|
|
132
|
-
return this._registry.get(this.capabilities(interfaceDef));
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Requests a single capability from the plugin context.
|
|
136
|
-
* @returns The capability.
|
|
137
|
-
* @throws If no capability is found.
|
|
138
|
-
*/
|
|
139
|
-
getCapability(interfaceDef) {
|
|
140
|
-
return this._registry.get(this.capability(interfaceDef));
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Waits for a capability to be available.
|
|
144
|
-
* @returns The capability.
|
|
145
|
-
*/
|
|
146
|
-
async waitForCapability(interfaceDef) {
|
|
147
|
-
const [capability] = this.getCapabilities(interfaceDef);
|
|
148
|
-
if (capability) {
|
|
149
|
-
return capability;
|
|
150
|
-
}
|
|
151
|
-
const trigger = new Trigger();
|
|
152
|
-
const cancel = this._registry.subscribe(this.capabilities(interfaceDef), (capabilities) => {
|
|
153
|
-
if (capabilities.length > 0) {
|
|
154
|
-
trigger.wake(capabilities[0]);
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
const result = await trigger.wait();
|
|
158
|
-
cancel();
|
|
159
|
-
return result;
|
|
160
|
-
}
|
|
161
|
-
async activatePromise(event) {
|
|
162
|
-
return this.activate(event).pipe(Effect.runPromise);
|
|
163
|
-
}
|
|
164
|
-
async resetPromise(event) {
|
|
165
|
-
return this.reset(event).pipe(Effect.runPromise);
|
|
166
|
-
}
|
|
167
|
-
constructor({ registry, activate, reset }) {
|
|
168
|
-
_define_property(this, "_registry", void 0);
|
|
169
|
-
_define_property(this, "_capabilityImpls", Rx.family(() => {
|
|
170
|
-
return Rx.make([]).pipe(Rx.keepAlive);
|
|
171
|
-
}));
|
|
172
|
-
_define_property(this, "_capabilities", Rx.family((id) => {
|
|
173
|
-
return Rx.make((get) => {
|
|
174
|
-
const current = get(this._capabilityImpls(id));
|
|
175
|
-
return current.map((c) => c.implementation);
|
|
176
|
-
});
|
|
177
|
-
}));
|
|
178
|
-
_define_property(this, "_capability", Rx.family((id) => {
|
|
179
|
-
return Rx.make((get) => {
|
|
180
|
-
const current = get(this._capabilities(id));
|
|
181
|
-
invariant(current.length > 0, `No capability found for ${id}`, {
|
|
182
|
-
F: __dxlog_file,
|
|
183
|
-
L: 122,
|
|
184
|
-
S: this,
|
|
185
|
-
A: [
|
|
186
|
-
"current.length > 0",
|
|
187
|
-
"`No capability found for ${id}`"
|
|
188
|
-
]
|
|
189
|
-
});
|
|
190
|
-
return current[0];
|
|
191
|
-
});
|
|
192
|
-
}));
|
|
193
|
-
_define_property(this, "activate", void 0);
|
|
194
|
-
_define_property(this, "reset", void 0);
|
|
195
|
-
this._registry = registry;
|
|
196
|
-
this.activate = activate;
|
|
197
|
-
this.reset = reset;
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
// src/core/events.ts
|
|
202
|
-
var defineEvent = (id, specifier) => {
|
|
203
|
-
return {
|
|
204
|
-
id,
|
|
205
|
-
specifier
|
|
206
|
-
};
|
|
207
|
-
};
|
|
208
|
-
var eventKey = (event) => event.specifier ? `${event.id}:${event.specifier}` : event.id;
|
|
209
|
-
var oneOf = (...events) => ({
|
|
210
|
-
type: "one-of",
|
|
211
|
-
events
|
|
212
|
-
});
|
|
213
|
-
var allOf = (...events) => ({
|
|
214
|
-
type: "all-of",
|
|
215
|
-
events
|
|
216
|
-
});
|
|
217
|
-
var isOneOf = (events) => "type" in events && events.type === "one-of";
|
|
218
|
-
var isAllOf = (events) => "type" in events && events.type === "all-of";
|
|
219
|
-
var getEvents = (events) => "type" in events ? events.events : [
|
|
220
|
-
events
|
|
221
|
-
];
|
|
222
|
-
|
|
223
|
-
// src/core/manager.ts
|
|
224
|
-
import { Registry } from "@effect-rx/rx-react";
|
|
225
|
-
import { untracked } from "@preact/signals-core";
|
|
226
|
-
import { Array, Duration, Effect as Effect2, Fiber, HashSet, Match, Ref, pipe } from "effect";
|
|
227
|
-
import { Event } from "@dxos/async";
|
|
228
|
-
import { live } from "@dxos/live-object";
|
|
229
|
-
import { log as log2 } from "@dxos/log";
|
|
230
|
-
function _define_property2(obj, key, value) {
|
|
231
|
-
if (key in obj) {
|
|
232
|
-
Object.defineProperty(obj, key, {
|
|
233
|
-
value,
|
|
234
|
-
enumerable: true,
|
|
235
|
-
configurable: true,
|
|
236
|
-
writable: true
|
|
237
|
-
});
|
|
238
|
-
} else {
|
|
239
|
-
obj[key] = value;
|
|
240
|
-
}
|
|
241
|
-
return obj;
|
|
242
|
-
}
|
|
243
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/manager.ts";
|
|
244
|
-
var isPromise = (value) => {
|
|
245
|
-
return value !== null && typeof value === "object" && "then" in value;
|
|
246
|
-
};
|
|
247
|
-
var PluginManager = class {
|
|
248
|
-
/**
|
|
249
|
-
* Plugins that are currently registered.
|
|
250
|
-
*
|
|
251
|
-
* @reactive
|
|
252
|
-
*/
|
|
253
|
-
get plugins() {
|
|
254
|
-
return this._state.plugins;
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Ids of plugins that are core and cannot be removed.
|
|
258
|
-
*
|
|
259
|
-
* @reactive
|
|
260
|
-
*/
|
|
261
|
-
get core() {
|
|
262
|
-
return this._state.core;
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Ids of plugins that are currently enabled.
|
|
266
|
-
*
|
|
267
|
-
* @reactive
|
|
268
|
-
*/
|
|
269
|
-
get enabled() {
|
|
270
|
-
return this._state.enabled;
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Modules of plugins which are currently enabled.
|
|
274
|
-
*
|
|
275
|
-
* @reactive
|
|
276
|
-
*/
|
|
277
|
-
get modules() {
|
|
278
|
-
return this._state.modules;
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Ids of modules which are currently active.
|
|
282
|
-
*
|
|
283
|
-
* @reactive
|
|
284
|
-
*/
|
|
285
|
-
get active() {
|
|
286
|
-
return this._state.active;
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Ids of events which have been fired.
|
|
290
|
-
*
|
|
291
|
-
* @reactive
|
|
292
|
-
*/
|
|
293
|
-
get eventsFired() {
|
|
294
|
-
return this._state.eventsFired;
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Ids of modules which are pending reset.
|
|
298
|
-
*
|
|
299
|
-
* @reactive
|
|
300
|
-
*/
|
|
301
|
-
get pendingReset() {
|
|
302
|
-
return this._state.pendingReset;
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Adds a plugin to the manager via the plugin loader.
|
|
306
|
-
* @param id The id of the plugin.
|
|
307
|
-
*/
|
|
308
|
-
async add(id) {
|
|
309
|
-
return untracked(async () => {
|
|
310
|
-
log2("add plugin", {
|
|
311
|
-
id
|
|
312
|
-
}, {
|
|
313
|
-
F: __dxlog_file2,
|
|
314
|
-
L: 157,
|
|
315
|
-
S: this,
|
|
316
|
-
C: (f, a) => f(...a)
|
|
317
|
-
});
|
|
318
|
-
const plugin = await this._pluginLoader(id);
|
|
319
|
-
this._addPlugin(plugin);
|
|
320
|
-
return this.enable(id);
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Enables a plugin.
|
|
325
|
-
* @param id The id of the plugin.
|
|
326
|
-
*/
|
|
327
|
-
enable(id) {
|
|
328
|
-
return untracked(async () => {
|
|
329
|
-
log2("enable plugin", {
|
|
330
|
-
id
|
|
331
|
-
}, {
|
|
332
|
-
F: __dxlog_file2,
|
|
333
|
-
L: 170,
|
|
334
|
-
S: this,
|
|
335
|
-
C: (f, a) => f(...a)
|
|
336
|
-
});
|
|
337
|
-
const plugin = this._getPlugin(id);
|
|
338
|
-
if (!plugin) {
|
|
339
|
-
return false;
|
|
340
|
-
}
|
|
341
|
-
if (!this._state.enabled.includes(id)) {
|
|
342
|
-
this._state.enabled.push(id);
|
|
343
|
-
}
|
|
344
|
-
plugin.modules.forEach((module) => {
|
|
345
|
-
this._addModule(module);
|
|
346
|
-
this._setPendingResetByModule(module);
|
|
347
|
-
});
|
|
348
|
-
log2("pending reset", {
|
|
349
|
-
events: [
|
|
350
|
-
...this.pendingReset
|
|
351
|
-
]
|
|
352
|
-
}, {
|
|
353
|
-
F: __dxlog_file2,
|
|
354
|
-
L: 185,
|
|
355
|
-
S: this,
|
|
356
|
-
C: (f, a) => f(...a)
|
|
357
|
-
});
|
|
358
|
-
await Effect2.runPromise(Effect2.all(this.pendingReset.map((event) => this._activate(event)), {
|
|
359
|
-
concurrency: "unbounded"
|
|
360
|
-
}));
|
|
361
|
-
return true;
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* Removes a plugin from the manager.
|
|
366
|
-
* @param id The id of the plugin.
|
|
367
|
-
*/
|
|
368
|
-
remove(id) {
|
|
369
|
-
return untracked(() => {
|
|
370
|
-
log2("remove plugin", {
|
|
371
|
-
id
|
|
372
|
-
}, {
|
|
373
|
-
F: __dxlog_file2,
|
|
374
|
-
L: 203,
|
|
375
|
-
S: this,
|
|
376
|
-
C: (f, a) => f(...a)
|
|
377
|
-
});
|
|
378
|
-
const result = this.disable(id);
|
|
379
|
-
if (!result) {
|
|
380
|
-
return false;
|
|
381
|
-
}
|
|
382
|
-
this._removePlugin(id);
|
|
383
|
-
return true;
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Disables a plugin.
|
|
388
|
-
* @param id The id of the plugin.
|
|
389
|
-
*/
|
|
390
|
-
disable(id) {
|
|
391
|
-
return untracked(async () => {
|
|
392
|
-
log2("disable plugin", {
|
|
393
|
-
id
|
|
394
|
-
}, {
|
|
395
|
-
F: __dxlog_file2,
|
|
396
|
-
L: 220,
|
|
397
|
-
S: this,
|
|
398
|
-
C: (f, a) => f(...a)
|
|
399
|
-
});
|
|
400
|
-
if (this._state.core.includes(id)) {
|
|
401
|
-
return false;
|
|
402
|
-
}
|
|
403
|
-
const plugin = this._getPlugin(id);
|
|
404
|
-
if (!plugin) {
|
|
405
|
-
return false;
|
|
406
|
-
}
|
|
407
|
-
const enabledIndex = this._state.enabled.findIndex((enabled) => enabled === id);
|
|
408
|
-
if (enabledIndex !== -1) {
|
|
409
|
-
this._state.enabled.splice(enabledIndex, 1);
|
|
410
|
-
await Effect2.runPromise(this._deactivate(id));
|
|
411
|
-
plugin.modules.forEach((module) => {
|
|
412
|
-
this._removeModule(module.id);
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
return true;
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
/**
|
|
419
|
-
* Activates plugins based on the activation event.
|
|
420
|
-
* @param event The activation event.
|
|
421
|
-
* @returns Whether the activation was successful.
|
|
422
|
-
*/
|
|
423
|
-
activate(event) {
|
|
424
|
-
return untracked(() => Effect2.runPromise(this._activate(event)));
|
|
425
|
-
}
|
|
426
|
-
/**
|
|
427
|
-
* Deactivates all of the modules for a plugin.
|
|
428
|
-
* @param id The id of the plugin.
|
|
429
|
-
* @returns Whether the deactivation was successful.
|
|
430
|
-
*/
|
|
431
|
-
deactivate(id) {
|
|
432
|
-
return untracked(() => Effect2.runPromise(this._deactivate(id)));
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* Re-activates the modules that were activated by the event.
|
|
436
|
-
* @param event The activation event.
|
|
437
|
-
* @returns Whether the reset was successful.
|
|
438
|
-
*/
|
|
439
|
-
reset(event) {
|
|
440
|
-
return untracked(() => Effect2.runPromise(this._reset(event)));
|
|
441
|
-
}
|
|
442
|
-
_addPlugin(plugin) {
|
|
443
|
-
untracked(() => {
|
|
444
|
-
log2("add plugin", {
|
|
445
|
-
id: plugin.meta.id
|
|
446
|
-
}, {
|
|
447
|
-
F: __dxlog_file2,
|
|
448
|
-
L: 273,
|
|
449
|
-
S: this,
|
|
450
|
-
C: (f, a) => f(...a)
|
|
451
|
-
});
|
|
452
|
-
if (!this._state.plugins.includes(plugin)) {
|
|
453
|
-
this._state.plugins.push(plugin);
|
|
454
|
-
}
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
_removePlugin(id) {
|
|
458
|
-
untracked(() => {
|
|
459
|
-
log2("remove plugin", {
|
|
460
|
-
id
|
|
461
|
-
}, {
|
|
462
|
-
F: __dxlog_file2,
|
|
463
|
-
L: 283,
|
|
464
|
-
S: this,
|
|
465
|
-
C: (f, a) => f(...a)
|
|
466
|
-
});
|
|
467
|
-
const pluginIndex = this._state.plugins.findIndex((plugin) => plugin.meta.id === id);
|
|
468
|
-
if (pluginIndex !== -1) {
|
|
469
|
-
this._state.plugins.splice(pluginIndex, 1);
|
|
470
|
-
}
|
|
471
|
-
});
|
|
472
|
-
}
|
|
473
|
-
_addModule(module) {
|
|
474
|
-
untracked(() => {
|
|
475
|
-
log2("add module", {
|
|
476
|
-
id: module.id
|
|
477
|
-
}, {
|
|
478
|
-
F: __dxlog_file2,
|
|
479
|
-
L: 293,
|
|
480
|
-
S: this,
|
|
481
|
-
C: (f, a) => f(...a)
|
|
482
|
-
});
|
|
483
|
-
if (!this._state.modules.includes(module)) {
|
|
484
|
-
this._state.modules.push(module);
|
|
485
|
-
}
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
_removeModule(id) {
|
|
489
|
-
untracked(() => {
|
|
490
|
-
log2("remove module", {
|
|
491
|
-
id
|
|
492
|
-
}, {
|
|
493
|
-
F: __dxlog_file2,
|
|
494
|
-
L: 303,
|
|
495
|
-
S: this,
|
|
496
|
-
C: (f, a) => f(...a)
|
|
497
|
-
});
|
|
498
|
-
const moduleIndex = this._state.modules.findIndex((module) => module.id === id);
|
|
499
|
-
if (moduleIndex !== -1) {
|
|
500
|
-
this._state.modules.splice(moduleIndex, 1);
|
|
501
|
-
}
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
_getPlugin(id) {
|
|
505
|
-
return this._state.plugins.find((plugin) => plugin.meta.id === id);
|
|
506
|
-
}
|
|
507
|
-
_getActiveModules() {
|
|
508
|
-
return this._state.modules.filter((module) => this._state.active.includes(module.id));
|
|
509
|
-
}
|
|
510
|
-
_getInactiveModules() {
|
|
511
|
-
return this._state.modules.filter((module) => !this._state.active.includes(module.id));
|
|
512
|
-
}
|
|
513
|
-
_getActiveModulesByEvent(key) {
|
|
514
|
-
return this._getActiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
|
|
515
|
-
}
|
|
516
|
-
_getInactiveModulesByEvent(key) {
|
|
517
|
-
return this._getInactiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
|
|
518
|
-
}
|
|
519
|
-
_setPendingResetByModule(module) {
|
|
520
|
-
return untracked(() => {
|
|
521
|
-
const activationEvents = getEvents(module.activatesOn).map(eventKey).filter((key) => this._state.eventsFired.includes(key));
|
|
522
|
-
const pendingReset = Array.fromIterable(new Set(activationEvents)).filter((event) => !this._state.pendingReset.includes(event));
|
|
523
|
-
if (pendingReset.length > 0) {
|
|
524
|
-
log2("pending reset", {
|
|
525
|
-
events: pendingReset
|
|
526
|
-
}, {
|
|
527
|
-
F: __dxlog_file2,
|
|
528
|
-
L: 341,
|
|
529
|
-
S: this,
|
|
530
|
-
C: (f, a) => f(...a)
|
|
531
|
-
});
|
|
532
|
-
this._state.pendingReset.push(...pendingReset);
|
|
533
|
-
}
|
|
534
|
-
});
|
|
535
|
-
}
|
|
536
|
-
/**
|
|
537
|
-
* @internal
|
|
538
|
-
*/
|
|
539
|
-
// TODO(wittjosiah): Improve error typing.
|
|
540
|
-
_activate(event, params) {
|
|
541
|
-
return Effect2.gen(this, function* () {
|
|
542
|
-
const key = typeof event === "string" ? event : eventKey(event);
|
|
543
|
-
log2("activating", {
|
|
544
|
-
key,
|
|
545
|
-
...params
|
|
546
|
-
}, {
|
|
547
|
-
F: __dxlog_file2,
|
|
548
|
-
L: 357,
|
|
549
|
-
S: this,
|
|
550
|
-
C: (f, a) => f(...a)
|
|
551
|
-
});
|
|
552
|
-
yield* Ref.update(this._activatingEvents, (activating) => Array.append(activating, key));
|
|
553
|
-
const pendingIndex = this._state.pendingReset.findIndex((event2) => event2 === key);
|
|
554
|
-
if (pendingIndex !== -1) {
|
|
555
|
-
this._state.pendingReset.splice(pendingIndex, 1);
|
|
556
|
-
}
|
|
557
|
-
const activatingEvents = yield* this._activatingEvents;
|
|
558
|
-
const activatingModules = yield* this._activatingModules;
|
|
559
|
-
const modules = this._getInactiveModulesByEvent(key).filter((module) => {
|
|
560
|
-
const allOf2 = isAllOf(module.activatesOn);
|
|
561
|
-
if (!allOf2) {
|
|
562
|
-
return true;
|
|
563
|
-
}
|
|
564
|
-
const events = module.activatesOn.events.filter((event2) => eventKey(event2) !== key);
|
|
565
|
-
return events.every((event2) => this._state.eventsFired.includes(eventKey(event2)) || activatingEvents.includes(eventKey(event2))) && !activatingModules.includes(module.id);
|
|
566
|
-
});
|
|
567
|
-
yield* Ref.update(this._activatingModules, (activating) => Array.appendAll(activating, modules.map((module) => module.id)));
|
|
568
|
-
if (modules.length === 0) {
|
|
569
|
-
log2("no modules to activate", {
|
|
570
|
-
key
|
|
571
|
-
}, {
|
|
572
|
-
F: __dxlog_file2,
|
|
573
|
-
L: 388,
|
|
574
|
-
S: this,
|
|
575
|
-
C: (f, a) => f(...a)
|
|
576
|
-
});
|
|
577
|
-
if (!this._state.eventsFired.includes(key)) {
|
|
578
|
-
this._state.eventsFired.push(key);
|
|
579
|
-
}
|
|
580
|
-
return false;
|
|
581
|
-
}
|
|
582
|
-
log2("activating modules", {
|
|
583
|
-
key,
|
|
584
|
-
modules: modules.map((module) => module.id)
|
|
585
|
-
}, {
|
|
586
|
-
F: __dxlog_file2,
|
|
587
|
-
L: 395,
|
|
588
|
-
S: this,
|
|
589
|
-
C: (f, a) => f(...a)
|
|
590
|
-
});
|
|
591
|
-
this.activation.emit({
|
|
592
|
-
event: key,
|
|
593
|
-
state: "activating"
|
|
594
|
-
});
|
|
595
|
-
yield* pipe(modules, Array.flatMap((module) => module.activatesBefore ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
|
|
596
|
-
before: key
|
|
597
|
-
})), Effect2.allWith({
|
|
598
|
-
concurrency: "unbounded"
|
|
599
|
-
}));
|
|
600
|
-
const getCapabilities = yield* pipe(modules, Array.map((mod) => this._loadModule(mod)), Effect2.allWith({
|
|
601
|
-
concurrency: "unbounded"
|
|
602
|
-
}), Effect2.catchAll((error) => {
|
|
603
|
-
this.activation.emit({
|
|
604
|
-
event: key,
|
|
605
|
-
state: "error",
|
|
606
|
-
error
|
|
607
|
-
});
|
|
608
|
-
return Effect2.fail(error);
|
|
609
|
-
}));
|
|
610
|
-
yield* pipe(
|
|
611
|
-
modules,
|
|
612
|
-
Array.zip(getCapabilities),
|
|
613
|
-
Array.map(([module, capabilities]) => this._contributeCapabilities(module, capabilities)),
|
|
614
|
-
// TODO(wittjosiah): This currently can't be run in parallel.
|
|
615
|
-
// Running this with concurrency causes races with `allOf` activation events.
|
|
616
|
-
Effect2.all
|
|
617
|
-
);
|
|
618
|
-
yield* pipe(modules, Array.flatMap((module) => module.activatesAfter ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
|
|
619
|
-
after: key
|
|
620
|
-
})), Effect2.allWith({
|
|
621
|
-
concurrency: "unbounded"
|
|
622
|
-
}));
|
|
623
|
-
yield* Ref.update(this._activatingEvents, (activating) => Array.filter(activating, (event2) => event2 !== key));
|
|
624
|
-
yield* Ref.update(this._activatingModules, (activating) => Array.filter(activating, (module) => !modules.map((module2) => module2.id).includes(module)));
|
|
625
|
-
if (!this._state.eventsFired.includes(key)) {
|
|
626
|
-
this._state.eventsFired.push(key);
|
|
627
|
-
}
|
|
628
|
-
this.activation.emit({
|
|
629
|
-
event: key,
|
|
630
|
-
state: "activated"
|
|
631
|
-
});
|
|
632
|
-
log2("activated", {
|
|
633
|
-
key
|
|
634
|
-
}, {
|
|
635
|
-
F: __dxlog_file2,
|
|
636
|
-
L: 451,
|
|
637
|
-
S: this,
|
|
638
|
-
C: (f, a) => f(...a)
|
|
639
|
-
});
|
|
640
|
-
return true;
|
|
641
|
-
});
|
|
642
|
-
}
|
|
643
|
-
_contributeCapabilities(module, capabilities) {
|
|
644
|
-
return Effect2.gen(this, function* () {
|
|
645
|
-
capabilities.forEach((capability) => {
|
|
646
|
-
this.context.contributeCapability({
|
|
647
|
-
module: module.id,
|
|
648
|
-
...capability
|
|
649
|
-
});
|
|
650
|
-
});
|
|
651
|
-
this._state.active.push(module.id);
|
|
652
|
-
this._capabilities.set(module.id, capabilities);
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
_deactivate(id) {
|
|
656
|
-
return Effect2.gen(this, function* () {
|
|
657
|
-
const plugin = this._getPlugin(id);
|
|
658
|
-
if (!plugin) {
|
|
659
|
-
return false;
|
|
660
|
-
}
|
|
661
|
-
const modules = plugin.modules;
|
|
662
|
-
const results = yield* Effect2.all(modules.map((module) => this._deactivateModule(module)), {
|
|
663
|
-
concurrency: "unbounded"
|
|
664
|
-
});
|
|
665
|
-
return results.every((result) => result);
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
_deactivateModule(module) {
|
|
669
|
-
return Effect2.gen(this, function* () {
|
|
670
|
-
const id = module.id;
|
|
671
|
-
log2("deactivating", {
|
|
672
|
-
id
|
|
673
|
-
}, {
|
|
674
|
-
F: __dxlog_file2,
|
|
675
|
-
L: 533,
|
|
676
|
-
S: this,
|
|
677
|
-
C: (f, a) => f(...a)
|
|
678
|
-
});
|
|
679
|
-
this._moduleMemoMap.delete(id);
|
|
680
|
-
const capabilities = this._capabilities.get(id);
|
|
681
|
-
if (capabilities) {
|
|
682
|
-
for (const capability of capabilities) {
|
|
683
|
-
this.context.removeCapability(capability.interface, capability.implementation);
|
|
684
|
-
const program = capability.deactivate?.();
|
|
685
|
-
yield* Match.value(program).pipe(Match.when(Effect2.isEffect, (effect) => effect), Match.when(isPromise, (promise) => Effect2.tryPromise({
|
|
686
|
-
try: () => promise,
|
|
687
|
-
catch: (error) => error
|
|
688
|
-
})), Match.orElse((program2) => Effect2.succeed(program2)));
|
|
689
|
-
}
|
|
690
|
-
this._capabilities.delete(id);
|
|
691
|
-
}
|
|
692
|
-
const activeIndex = this._state.active.findIndex((event) => event === id);
|
|
693
|
-
if (activeIndex !== -1) {
|
|
694
|
-
this._state.active.splice(activeIndex, 1);
|
|
695
|
-
}
|
|
696
|
-
log2("deactivated", {
|
|
697
|
-
id
|
|
698
|
-
}, {
|
|
699
|
-
F: __dxlog_file2,
|
|
700
|
-
L: 560,
|
|
701
|
-
S: this,
|
|
702
|
-
C: (f, a) => f(...a)
|
|
703
|
-
});
|
|
704
|
-
return true;
|
|
705
|
-
});
|
|
706
|
-
}
|
|
707
|
-
_reset(event) {
|
|
708
|
-
return Effect2.gen(this, function* () {
|
|
709
|
-
const key = typeof event === "string" ? event : eventKey(event);
|
|
710
|
-
log2("reset", {
|
|
711
|
-
key
|
|
712
|
-
}, {
|
|
713
|
-
F: __dxlog_file2,
|
|
714
|
-
L: 568,
|
|
715
|
-
S: this,
|
|
716
|
-
C: (f, a) => f(...a)
|
|
717
|
-
});
|
|
718
|
-
const modules = this._getActiveModulesByEvent(key);
|
|
719
|
-
const results = yield* Effect2.all(modules.map((module) => this._deactivateModule(module)), {
|
|
720
|
-
concurrency: "unbounded"
|
|
721
|
-
});
|
|
722
|
-
if (results.every((result) => result)) {
|
|
723
|
-
return yield* this._activate(key);
|
|
724
|
-
} else {
|
|
725
|
-
return false;
|
|
726
|
-
}
|
|
727
|
-
});
|
|
728
|
-
}
|
|
729
|
-
constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta: meta2 }) => meta2.id), enabled = [], registry }) {
|
|
730
|
-
_define_property2(this, "activation", new Event());
|
|
731
|
-
_define_property2(this, "context", void 0);
|
|
732
|
-
_define_property2(this, "registry", void 0);
|
|
733
|
-
_define_property2(this, "_state", void 0);
|
|
734
|
-
_define_property2(this, "_pluginLoader", void 0);
|
|
735
|
-
_define_property2(this, "_capabilities", /* @__PURE__ */ new Map());
|
|
736
|
-
_define_property2(this, "_moduleMemoMap", /* @__PURE__ */ new Map());
|
|
737
|
-
_define_property2(this, "_activatingEvents", Effect2.runSync(Ref.make([])));
|
|
738
|
-
_define_property2(this, "_activatingModules", Effect2.runSync(Ref.make([])));
|
|
739
|
-
_define_property2(this, "_loadModule", (mod) => Effect2.tryPromise({
|
|
740
|
-
try: async () => {
|
|
741
|
-
const entry = this._moduleMemoMap.get(mod.id);
|
|
742
|
-
if (entry) {
|
|
743
|
-
return entry;
|
|
744
|
-
}
|
|
745
|
-
const promise = (async () => {
|
|
746
|
-
const start = performance.now();
|
|
747
|
-
let failed = false;
|
|
748
|
-
try {
|
|
749
|
-
log2("loading module", {
|
|
750
|
-
module: mod.id
|
|
751
|
-
}, {
|
|
752
|
-
F: __dxlog_file2,
|
|
753
|
-
L: 470,
|
|
754
|
-
S: this,
|
|
755
|
-
C: (f, a) => f(...a)
|
|
756
|
-
});
|
|
757
|
-
let activationResult = await mod.activate(this.context);
|
|
758
|
-
if (typeof activationResult === "function") {
|
|
759
|
-
activationResult = await activationResult();
|
|
760
|
-
}
|
|
761
|
-
return Array.isArray(activationResult) ? activationResult : [
|
|
762
|
-
activationResult
|
|
763
|
-
];
|
|
764
|
-
} catch (error) {
|
|
765
|
-
failed = true;
|
|
766
|
-
throw error;
|
|
767
|
-
} finally {
|
|
768
|
-
performance.measure("activate-module", {
|
|
769
|
-
start,
|
|
770
|
-
end: performance.now(),
|
|
771
|
-
detail: {
|
|
772
|
-
module: mod.id
|
|
773
|
-
}
|
|
774
|
-
});
|
|
775
|
-
log2("loaded module", {
|
|
776
|
-
module: mod.id,
|
|
777
|
-
elapsed: performance.now() - start,
|
|
778
|
-
failed
|
|
779
|
-
}, {
|
|
780
|
-
F: __dxlog_file2,
|
|
781
|
-
L: 488,
|
|
782
|
-
S: this,
|
|
783
|
-
C: (f, a) => f(...a)
|
|
784
|
-
});
|
|
785
|
-
}
|
|
786
|
-
})();
|
|
787
|
-
this._moduleMemoMap.set(mod.id, promise);
|
|
788
|
-
return promise;
|
|
789
|
-
},
|
|
790
|
-
catch: (error) => error
|
|
791
|
-
}).pipe(Effect2.withSpan("PluginManager._loadModule"), together(Effect2.sleep(Duration.seconds(10)).pipe(Effect2.andThen(Effect2.sync(() => log2.warn(`module is taking a long time to activate`, {
|
|
792
|
-
module: mod.id
|
|
793
|
-
}, {
|
|
794
|
-
F: __dxlog_file2,
|
|
795
|
-
L: 499,
|
|
796
|
-
S: this,
|
|
797
|
-
C: (f, a) => f(...a)
|
|
798
|
-
})))))));
|
|
799
|
-
this.registry = registry ?? Registry.make();
|
|
800
|
-
this.context = new PluginContext({
|
|
801
|
-
registry: this.registry,
|
|
802
|
-
activate: (event) => this._activate(event),
|
|
803
|
-
reset: (id) => this._reset(id)
|
|
804
|
-
});
|
|
805
|
-
this._pluginLoader = pluginLoader;
|
|
806
|
-
this._state = live({
|
|
807
|
-
plugins,
|
|
808
|
-
core,
|
|
809
|
-
enabled,
|
|
810
|
-
modules: [],
|
|
811
|
-
active: [],
|
|
812
|
-
eventsFired: [],
|
|
813
|
-
pendingReset: []
|
|
814
|
-
});
|
|
815
|
-
plugins.forEach((plugin) => this._addPlugin(plugin));
|
|
816
|
-
core.forEach((id) => this.enable(id));
|
|
817
|
-
enabled.forEach((id) => this.enable(id));
|
|
818
|
-
}
|
|
819
|
-
};
|
|
820
|
-
var together = (togetherEffect) => (effect) => Effect2.gen(function* () {
|
|
821
|
-
const togetherFiber = yield* Effect2.fork(togetherEffect);
|
|
822
|
-
const result = yield* effect;
|
|
823
|
-
yield* Fiber.interrupt(togetherFiber);
|
|
824
|
-
return result;
|
|
825
|
-
});
|
|
826
|
-
|
|
827
|
-
// src/core/plugin.ts
|
|
828
|
-
function _define_property3(obj, key, value) {
|
|
829
|
-
if (key in obj) {
|
|
830
|
-
Object.defineProperty(obj, key, {
|
|
831
|
-
value,
|
|
832
|
-
enumerable: true,
|
|
833
|
-
configurable: true,
|
|
834
|
-
writable: true
|
|
835
|
-
});
|
|
836
|
-
} else {
|
|
837
|
-
obj[key] = value;
|
|
838
|
-
}
|
|
839
|
-
return obj;
|
|
840
|
-
}
|
|
841
|
-
var PluginModule = class {
|
|
842
|
-
constructor(options) {
|
|
843
|
-
_define_property3(this, "id", void 0);
|
|
844
|
-
_define_property3(this, "activatesOn", void 0);
|
|
845
|
-
_define_property3(this, "activatesBefore", void 0);
|
|
846
|
-
_define_property3(this, "activatesAfter", void 0);
|
|
847
|
-
_define_property3(this, "activate", void 0);
|
|
848
|
-
this.id = options.id;
|
|
849
|
-
this.activatesOn = options.activatesOn;
|
|
850
|
-
this.activatesBefore = options.activatesBefore;
|
|
851
|
-
this.activatesAfter = options.activatesAfter;
|
|
852
|
-
this.activate = options.activate;
|
|
853
|
-
}
|
|
854
|
-
};
|
|
855
|
-
var defineModule = (options) => new PluginModule(options);
|
|
856
|
-
var Plugin = class {
|
|
857
|
-
constructor(meta2, modules) {
|
|
858
|
-
_define_property3(this, "meta", void 0);
|
|
859
|
-
_define_property3(this, "modules", void 0);
|
|
860
|
-
this.meta = meta2;
|
|
861
|
-
this.modules = modules;
|
|
862
|
-
}
|
|
863
|
-
};
|
|
864
|
-
var definePlugin = (meta2, provider) => {
|
|
865
|
-
const factory = (args) => {
|
|
866
|
-
return new Plugin(meta2, provider(args));
|
|
867
|
-
};
|
|
868
|
-
return Object.assign(factory, {
|
|
869
|
-
meta: meta2
|
|
870
|
-
});
|
|
871
|
-
};
|
|
872
|
-
|
|
873
|
-
// src/common/capabilities.ts
|
|
874
|
-
(function(Capabilities2) {
|
|
875
|
-
Capabilities2.Null = defineCapability("dxos.org/app-framework/capability/null");
|
|
876
|
-
Capabilities2.PluginManager = defineCapability("dxos.org/app-framework/capability/plugin-manager");
|
|
877
|
-
Capabilities2.RxRegistry = defineCapability("dxos.org/app-framework/capability/rx-registry");
|
|
878
|
-
Capabilities2.ReactContext = defineCapability("dxos.org/app-framework/capability/react-context");
|
|
879
|
-
Capabilities2.ReactRoot = defineCapability("dxos.org/app-framework/capability/react-root");
|
|
880
|
-
Capabilities2.ReactSurface = defineCapability("dxos.org/app-framework/common/react-surface");
|
|
881
|
-
Capabilities2.IntentResolver = defineCapability("dxos.org/app-framework/capability/intent-resolver");
|
|
882
|
-
Capabilities2.IntentDispatcher = defineCapability("dxos.org/app-framework/capability/intent-dispatcher");
|
|
883
|
-
Capabilities2.Layout = defineCapability("dxos.org/app-framework/capability/layout");
|
|
884
|
-
Capabilities2.Translations = defineCapability("dxos.org/app-framework/capability/translations");
|
|
885
|
-
Capabilities2.AppGraph = defineCapability("dxos.org/app-framework/capability/app-graph");
|
|
886
|
-
Capabilities2.AppGraphBuilder = defineCapability("dxos.org/app-framework/capability/app-graph-builder");
|
|
887
|
-
Capabilities2.AppGraphSerializer = defineCapability("dxos.org/app-framework/capability/app-graph-serializer");
|
|
888
|
-
Capabilities2.SettingsStore = defineCapability("dxos.org/app-framework/capability/settings-store");
|
|
889
|
-
Capabilities2.Settings = defineCapability("dxos.org/app-framework/capability/settings");
|
|
890
|
-
Capabilities2.Metadata = defineCapability("dxos.org/app-framework/capability/metadata");
|
|
891
|
-
Capabilities2.Toolkit = defineCapability("dxos.org/app-framework/capability/ai-toolkit");
|
|
892
|
-
Capabilities2.ToolkitHandler = defineCapability("dxos.org/app-framework/capability/ai-toolkit-handler");
|
|
893
|
-
Capabilities2.BlueprintDefinition = defineCapability("dxos.org/app-framework/capability/blueprint-definition");
|
|
894
|
-
Capabilities2.AiServiceLayer = defineCapability("dxos.org/app-framework/capability/ai-service-factory");
|
|
895
|
-
Capabilities2.AiModelResolver = defineCapability("dxos.org/app-framework/capability/ai-model-resolver");
|
|
896
|
-
Capabilities2.Functions = defineCapability("dxos.org/app-framework/capability/functions");
|
|
897
|
-
Capabilities2.FileUploader = defineCapability("dxos.org/app-framework/capability/file-uploader");
|
|
898
|
-
Capabilities2.AnchorSort = defineCapability("dxos.org/app-framework/capability/anchor-sort");
|
|
899
|
-
})(Capabilities || (Capabilities = {}));
|
|
900
|
-
var Capabilities;
|
|
901
|
-
|
|
902
|
-
// src/common/collaboration.ts
|
|
903
|
-
import { Schema } from "effect";
|
|
904
|
-
import { DataType } from "@dxos/schema";
|
|
905
|
-
(function(CollaborationActions2) {
|
|
906
|
-
class AcceptProposal extends Schema.TaggedClass()("collaboration/accept-proposal", {
|
|
907
|
-
input: Schema.Struct({
|
|
908
|
-
subject: Schema.Any,
|
|
909
|
-
anchor: Schema.String,
|
|
910
|
-
proposal: DataType.MessageBlock.Proposal
|
|
911
|
-
}),
|
|
912
|
-
output: Schema.Void
|
|
913
|
-
}) {
|
|
914
|
-
}
|
|
915
|
-
CollaborationActions2.AcceptProposal = AcceptProposal;
|
|
916
|
-
})(CollaborationActions || (CollaborationActions = {}));
|
|
917
|
-
var CollaborationActions;
|
|
918
|
-
|
|
919
|
-
// src/common/events.ts
|
|
920
|
-
(function(Events2) {
|
|
921
|
-
Events2.Startup = defineEvent("dxos.org/app-framework/event/startup");
|
|
922
|
-
Events2.SetupReactSurface = defineEvent("dxos.org/app-framework/event/setup-react-surface");
|
|
923
|
-
Events2.SetupMetadata = defineEvent("dxos.org/app-framework/event/setup-metadata");
|
|
924
|
-
Events2.SetupIntentResolver = defineEvent("dxos.org/app-framework/event/setup-intent-resolver");
|
|
925
|
-
Events2.SetupSettings = defineEvent("dxos.org/app-framework/event/setup-settings");
|
|
926
|
-
Events2.SetupAppGraph = defineEvent("dxos.org/app-framework/event/setup-graph");
|
|
927
|
-
Events2.SetupTranslations = defineEvent("dxos.org/app-framework/event/setup-translations");
|
|
928
|
-
Events2.SetupArtifactDefinition = defineEvent("dxos.org/app-framework/event/setup-artifact-definition");
|
|
929
|
-
Events2.DispatcherReady = defineEvent("dxos.org/app-framework/event/dispatcher-ready");
|
|
930
|
-
Events2.SettingsReady = defineEvent("dxos.org/app-framework/event/settings-ready");
|
|
931
|
-
Events2.AppGraphReady = defineEvent("dxos.org/app-framework/event/graph-ready");
|
|
932
|
-
Events2.createStateEvent = (specifier) => defineEvent("dxos.org/app-framework/event/state", specifier);
|
|
933
|
-
Events2.LayoutReady = Events2.createStateEvent(Capabilities.Layout.identifier);
|
|
934
|
-
})(Events || (Events = {}));
|
|
935
|
-
var Events;
|
|
936
|
-
|
|
937
|
-
// src/common/file.ts
|
|
938
|
-
import { Schema as Schema2 } from "effect";
|
|
939
|
-
var defaultFileTypes = {
|
|
940
|
-
images: [
|
|
941
|
-
"png",
|
|
942
|
-
"jpg",
|
|
943
|
-
"jpeg",
|
|
944
|
-
"gif"
|
|
945
|
-
],
|
|
946
|
-
media: [
|
|
947
|
-
"mp3",
|
|
948
|
-
"mp4",
|
|
949
|
-
"mov",
|
|
950
|
-
"avi"
|
|
951
|
-
],
|
|
952
|
-
text: [
|
|
953
|
-
"pdf",
|
|
954
|
-
"txt",
|
|
955
|
-
"md"
|
|
956
|
-
]
|
|
957
|
-
};
|
|
958
|
-
var FileInfoSchema = Schema2.Struct({
|
|
959
|
-
name: Schema2.String,
|
|
960
|
-
type: Schema2.String,
|
|
961
|
-
url: Schema2.optional(Schema2.String),
|
|
962
|
-
cid: Schema2.optional(Schema2.String)
|
|
963
|
-
});
|
|
964
|
-
|
|
965
|
-
// src/common/layout.ts
|
|
966
|
-
import { Schema as Schema5 } from "effect";
|
|
967
|
-
|
|
968
|
-
// src/plugin-intent/actions.ts
|
|
969
|
-
import { Schema as Schema4 } from "effect";
|
|
970
|
-
|
|
971
|
-
// src/plugin-intent/intent.ts
|
|
972
|
-
import { Schema as Schema3 } from "effect";
|
|
973
|
-
var createIntent = (schema, data = {}, params = {}) => {
|
|
974
|
-
const _ = Schema3.validateSync(schema.fields.input)(data);
|
|
975
|
-
const intent = {
|
|
976
|
-
...params,
|
|
977
|
-
_schema: schema,
|
|
978
|
-
id: schema._tag,
|
|
979
|
-
data
|
|
980
|
-
};
|
|
981
|
-
return {
|
|
982
|
-
first: intent,
|
|
983
|
-
last: intent,
|
|
984
|
-
all: [
|
|
985
|
-
intent
|
|
986
|
-
]
|
|
987
|
-
};
|
|
988
|
-
};
|
|
989
|
-
var chain = (schema, data = {}, params = {}) => (intent) => {
|
|
990
|
-
const intents = "all" in intent ? intent.all : [
|
|
991
|
-
intent
|
|
992
|
-
];
|
|
993
|
-
const first = intents[0];
|
|
994
|
-
const last = {
|
|
995
|
-
...params,
|
|
996
|
-
_schema: schema,
|
|
997
|
-
id: schema._tag,
|
|
998
|
-
data
|
|
999
|
-
};
|
|
1000
|
-
return {
|
|
1001
|
-
first,
|
|
1002
|
-
last,
|
|
1003
|
-
all: [
|
|
1004
|
-
...intents,
|
|
1005
|
-
last
|
|
1006
|
-
]
|
|
1007
|
-
};
|
|
1008
|
-
};
|
|
1009
|
-
var Label = Schema3.Union(Schema3.String, Schema3.mutable(Schema3.Tuple(Schema3.String, Schema3.mutable(Schema3.Struct({
|
|
1010
|
-
ns: Schema3.String,
|
|
1011
|
-
count: Schema3.optional(Schema3.Number),
|
|
1012
|
-
defaultValue: Schema3.optional(Schema3.String)
|
|
1013
|
-
})))));
|
|
1014
|
-
|
|
1015
|
-
// src/plugin-intent/meta.ts
|
|
1016
|
-
var meta = {
|
|
1017
|
-
id: "dxos.org/plugin/intent",
|
|
1018
|
-
name: "Intent"
|
|
1019
|
-
};
|
|
1020
|
-
|
|
1021
|
-
// src/plugin-intent/actions.ts
|
|
1022
|
-
(function(IntentAction2) {
|
|
1023
|
-
class Track extends Schema4.TaggedClass()(`${meta.id}/action/track`, {
|
|
1024
|
-
input: Schema4.Struct({
|
|
1025
|
-
intents: Schema4.Array(Schema4.String),
|
|
1026
|
-
error: Schema4.optional(Schema4.String)
|
|
1027
|
-
}),
|
|
1028
|
-
output: Schema4.Void
|
|
1029
|
-
}) {
|
|
1030
|
-
}
|
|
1031
|
-
IntentAction2.Track = Track;
|
|
1032
|
-
class ShowUndo extends Schema4.TaggedClass()(`${meta.id}/action/show-undo`, {
|
|
1033
|
-
input: Schema4.Struct({
|
|
1034
|
-
message: Label
|
|
1035
|
-
}),
|
|
1036
|
-
output: Schema4.Void
|
|
1037
|
-
}) {
|
|
1038
|
-
}
|
|
1039
|
-
IntentAction2.ShowUndo = ShowUndo;
|
|
1040
|
-
})(IntentAction || (IntentAction = {}));
|
|
1041
|
-
var IntentAction;
|
|
1042
|
-
|
|
1043
|
-
// src/plugin-intent/errors.ts
|
|
1044
|
-
function _define_property4(obj, key, value) {
|
|
1045
|
-
if (key in obj) {
|
|
1046
|
-
Object.defineProperty(obj, key, {
|
|
1047
|
-
value,
|
|
1048
|
-
enumerable: true,
|
|
1049
|
-
configurable: true,
|
|
1050
|
-
writable: true
|
|
1051
|
-
});
|
|
1052
|
-
} else {
|
|
1053
|
-
obj[key] = value;
|
|
1054
|
-
}
|
|
1055
|
-
return obj;
|
|
1056
|
-
}
|
|
1057
|
-
var BaseError = class extends Error {
|
|
1058
|
-
constructor(code, message, context) {
|
|
1059
|
-
super(message ?? code, {
|
|
1060
|
-
cause: context
|
|
1061
|
-
}), _define_property4(this, "code", void 0), _define_property4(this, "context", void 0), this.code = code, this.context = context;
|
|
1062
|
-
this.name = code;
|
|
1063
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
1064
|
-
}
|
|
1065
|
-
};
|
|
1066
|
-
var NoResolversError = class extends BaseError {
|
|
1067
|
-
constructor(action) {
|
|
1068
|
-
super("NO_RESOLVERS", "No resolvers were found for the action", {
|
|
1069
|
-
action
|
|
1070
|
-
});
|
|
1071
|
-
}
|
|
1072
|
-
};
|
|
1073
|
-
var CycleDetectedError = class extends BaseError {
|
|
1074
|
-
constructor(context) {
|
|
1075
|
-
super("CYCLE_DETECTED", "Intent execution limit exceeded. This is likely due to an infinite loop within intent resolvers.", context);
|
|
1076
|
-
}
|
|
1077
|
-
};
|
|
1078
|
-
|
|
1079
|
-
// src/plugin-intent/IntentPlugin.ts
|
|
1080
|
-
var IntentPlugin = definePlugin(meta, () => [
|
|
1081
|
-
defineModule({
|
|
1082
|
-
id: `${meta.id}/module/dispatcher`,
|
|
1083
|
-
// TODO(wittjosiah): This will mean that startup needs to be reset when intents are added or removed.
|
|
1084
|
-
// This is fine for now because it's how it worked prior to capabilities api anyways.
|
|
1085
|
-
// In the future, the intent dispatcher should be able to be reset without resetting the entire app.
|
|
1086
|
-
activatesOn: Events.Startup,
|
|
1087
|
-
activatesAfter: [
|
|
1088
|
-
Events.DispatcherReady
|
|
1089
|
-
],
|
|
1090
|
-
activate: lazy(() => import("./intent-dispatcher-VFMJVO2M.mjs"))
|
|
1091
|
-
})
|
|
1092
|
-
]);
|
|
1093
|
-
|
|
1094
|
-
// src/common/layout.ts
|
|
1095
|
-
var LAYOUT_PLUGIN = "dxos.org/plugin/layout";
|
|
1096
|
-
(function(LayoutAction2) {
|
|
1097
|
-
LayoutAction2.UPDATE_LAYOUT = `${LAYOUT_PLUGIN}/action/update-layout`;
|
|
1098
|
-
class UpdateLayout extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1099
|
-
input: Schema5.Struct({
|
|
1100
|
-
part: Schema5.String.annotations({
|
|
1101
|
-
description: "The part of the layout to mutate."
|
|
1102
|
-
}),
|
|
1103
|
-
subject: Schema5.optional(Schema5.Any.annotations({
|
|
1104
|
-
description: "The subject of the layout update."
|
|
1105
|
-
})),
|
|
1106
|
-
options: Schema5.optional(Schema5.Record({
|
|
1107
|
-
key: Schema5.String,
|
|
1108
|
-
value: Schema5.Any
|
|
1109
|
-
}).annotations({
|
|
1110
|
-
description: "Additional options for the layout action."
|
|
1111
|
-
}))
|
|
1112
|
-
}),
|
|
1113
|
-
output: Schema5.Void
|
|
1114
|
-
}) {
|
|
1115
|
-
}
|
|
1116
|
-
LayoutAction2.UpdateLayout = UpdateLayout;
|
|
1117
|
-
class SetLayoutMode extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1118
|
-
input: Schema5.Struct({
|
|
1119
|
-
part: Schema5.Literal("mode").annotations({
|
|
1120
|
-
description: "Setting the layout mode."
|
|
1121
|
-
}),
|
|
1122
|
-
subject: Schema5.optional(Schema5.String.annotations({
|
|
1123
|
-
description: "Item which is the subject of the new layout mode."
|
|
1124
|
-
})),
|
|
1125
|
-
options: Schema5.Union(Schema5.Struct({
|
|
1126
|
-
mode: Schema5.String.annotations({
|
|
1127
|
-
description: "The new layout mode."
|
|
1128
|
-
})
|
|
1129
|
-
}), Schema5.Struct({
|
|
1130
|
-
revert: Schema5.Boolean.annotations({
|
|
1131
|
-
description: "Revert to the previous layout mode."
|
|
1132
|
-
})
|
|
1133
|
-
}))
|
|
1134
|
-
}),
|
|
1135
|
-
output: Schema5.Void
|
|
1136
|
-
}) {
|
|
1137
|
-
}
|
|
1138
|
-
LayoutAction2.SetLayoutMode = SetLayoutMode;
|
|
1139
|
-
class UpdateSidebar extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1140
|
-
input: Schema5.Struct({
|
|
1141
|
-
part: Schema5.Literal("sidebar").annotations({
|
|
1142
|
-
description: "Updating the sidebar."
|
|
1143
|
-
}),
|
|
1144
|
-
subject: Schema5.optional(Schema5.String.annotations({
|
|
1145
|
-
description: "URI of the component to display in the sidebar."
|
|
1146
|
-
})),
|
|
1147
|
-
options: Schema5.optional(Schema5.Struct({
|
|
1148
|
-
state: Schema5.Literal("closed", "collapsed", "expanded").annotations({
|
|
1149
|
-
description: "Whether the sidebar is closed, collapsed, or expanded."
|
|
1150
|
-
})
|
|
1151
|
-
}))
|
|
1152
|
-
}),
|
|
1153
|
-
output: Schema5.Void
|
|
1154
|
-
}) {
|
|
1155
|
-
}
|
|
1156
|
-
LayoutAction2.UpdateSidebar = UpdateSidebar;
|
|
1157
|
-
class UpdateComplementary extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1158
|
-
input: Schema5.Struct({
|
|
1159
|
-
part: Schema5.Literal("complementary").annotations({
|
|
1160
|
-
description: "Updating the complementary sidebar."
|
|
1161
|
-
}),
|
|
1162
|
-
subject: Schema5.optional(Schema5.String.annotations({
|
|
1163
|
-
description: "URI of the component to display in the complementary area."
|
|
1164
|
-
})),
|
|
1165
|
-
options: Schema5.optional(Schema5.Struct({
|
|
1166
|
-
state: Schema5.Literal("closed", "collapsed", "expanded").annotations({
|
|
1167
|
-
description: "Whether the complementary sidebar is closed, collapsed, or expanded."
|
|
1168
|
-
})
|
|
1169
|
-
}))
|
|
1170
|
-
}),
|
|
1171
|
-
output: Schema5.Void
|
|
1172
|
-
}) {
|
|
1173
|
-
}
|
|
1174
|
-
LayoutAction2.UpdateComplementary = UpdateComplementary;
|
|
1175
|
-
class UpdateDialog extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1176
|
-
input: Schema5.Struct({
|
|
1177
|
-
part: Schema5.Literal("dialog").annotations({
|
|
1178
|
-
description: "Updating the dialog."
|
|
1179
|
-
}),
|
|
1180
|
-
subject: Schema5.optional(Schema5.String.annotations({
|
|
1181
|
-
description: "URI of the component to display in the dialog."
|
|
1182
|
-
})),
|
|
1183
|
-
options: Schema5.Struct({
|
|
1184
|
-
state: Schema5.optional(Schema5.Boolean.annotations({
|
|
1185
|
-
description: "Whether the dialog is open or closed."
|
|
1186
|
-
})),
|
|
1187
|
-
type: Schema5.optional(Schema5.Literal("default", "alert").annotations({
|
|
1188
|
-
description: "The type of dialog."
|
|
1189
|
-
})),
|
|
1190
|
-
blockAlign: Schema5.optional(Schema5.Literal("start", "center", "end").annotations({
|
|
1191
|
-
description: "The alignment of the dialog."
|
|
1192
|
-
})),
|
|
1193
|
-
overlayClasses: Schema5.optional(Schema5.String.annotations({
|
|
1194
|
-
description: "Additional classes for the dialog overlay."
|
|
1195
|
-
})),
|
|
1196
|
-
overlayStyle: Schema5.optional(Schema5.Record({
|
|
1197
|
-
key: Schema5.String,
|
|
1198
|
-
value: Schema5.Any
|
|
1199
|
-
}).annotations({
|
|
1200
|
-
description: "Additional styles for the dialog overlay."
|
|
1201
|
-
})),
|
|
1202
|
-
props: Schema5.optional(Schema5.Record({
|
|
1203
|
-
key: Schema5.String,
|
|
1204
|
-
value: Schema5.Any
|
|
1205
|
-
}).annotations({
|
|
1206
|
-
description: "Additional props for the dialog."
|
|
1207
|
-
}))
|
|
1208
|
-
})
|
|
1209
|
-
}),
|
|
1210
|
-
output: Schema5.Void
|
|
1211
|
-
}) {
|
|
1212
|
-
}
|
|
1213
|
-
LayoutAction2.UpdateDialog = UpdateDialog;
|
|
1214
|
-
class UpdatePopover extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1215
|
-
input: Schema5.Struct({
|
|
1216
|
-
part: Schema5.Literal("popover").annotations({
|
|
1217
|
-
description: "Updating the popover."
|
|
1218
|
-
}),
|
|
1219
|
-
subject: Schema5.optional(Schema5.Any.annotations({
|
|
1220
|
-
description: "URI of the component to display in the popover or data to pass to the popover."
|
|
1221
|
-
})),
|
|
1222
|
-
options: Schema5.Struct({
|
|
1223
|
-
side: Schema5.optional(Schema5.Literal("top", "right", "bottom", "left").annotations({
|
|
1224
|
-
description: "The side of the anchor."
|
|
1225
|
-
})),
|
|
1226
|
-
state: Schema5.optional(Schema5.Boolean.annotations({
|
|
1227
|
-
description: "Whether the popover is open or closed."
|
|
1228
|
-
})),
|
|
1229
|
-
props: Schema5.optional(Schema5.Record({
|
|
1230
|
-
key: Schema5.String,
|
|
1231
|
-
value: Schema5.Any
|
|
1232
|
-
}).annotations({
|
|
1233
|
-
description: "Additional props for the popover."
|
|
1234
|
-
}))
|
|
1235
|
-
}).pipe(Schema5.extend(Schema5.Union(Schema5.Struct({
|
|
1236
|
-
variant: Schema5.Literal("virtual"),
|
|
1237
|
-
anchor: Schema5.Any.annotations({
|
|
1238
|
-
description: "The DOM element to anchor the popover to."
|
|
1239
|
-
})
|
|
1240
|
-
}), Schema5.Struct({
|
|
1241
|
-
variant: Schema5.optional(Schema5.Literal("react")),
|
|
1242
|
-
anchorId: Schema5.String.annotations({
|
|
1243
|
-
description: "An id that can be used to determine whether to render the anchor subcomponent."
|
|
1244
|
-
})
|
|
1245
|
-
}))))
|
|
1246
|
-
}),
|
|
1247
|
-
output: Schema5.Void
|
|
1248
|
-
}) {
|
|
1249
|
-
}
|
|
1250
|
-
LayoutAction2.UpdatePopover = UpdatePopover;
|
|
1251
|
-
LayoutAction2.Toast = Schema5.Struct({
|
|
1252
|
-
id: Schema5.String.annotations({
|
|
1253
|
-
description: "The id of the toast."
|
|
1254
|
-
}),
|
|
1255
|
-
title: Schema5.optional(Label.annotations({
|
|
1256
|
-
description: "The title of the toast."
|
|
1257
|
-
})),
|
|
1258
|
-
description: Schema5.optional(Label.annotations({
|
|
1259
|
-
description: "The description of the toast."
|
|
1260
|
-
})),
|
|
1261
|
-
icon: Schema5.optional(Schema5.String.annotations({
|
|
1262
|
-
description: "The icon of the toast."
|
|
1263
|
-
})),
|
|
1264
|
-
duration: Schema5.optional(Schema5.Number.annotations({
|
|
1265
|
-
description: "The duration of the toast."
|
|
1266
|
-
})),
|
|
1267
|
-
closeLabel: Schema5.optional(Label.annotations({
|
|
1268
|
-
description: "The label of the close button."
|
|
1269
|
-
})),
|
|
1270
|
-
actionLabel: Schema5.optional(Label.annotations({
|
|
1271
|
-
description: "The label of the action button."
|
|
1272
|
-
})),
|
|
1273
|
-
actionAlt: Schema5.optional(Label.annotations({
|
|
1274
|
-
description: "The alt text of the action button."
|
|
1275
|
-
})),
|
|
1276
|
-
onAction: Schema5.optional(Schema5.Any.annotations({
|
|
1277
|
-
description: "The action to perform when the action button is clicked."
|
|
1278
|
-
}))
|
|
1279
|
-
});
|
|
1280
|
-
class AddToast extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1281
|
-
input: Schema5.Struct({
|
|
1282
|
-
part: Schema5.Literal("toast").annotations({
|
|
1283
|
-
description: "Adding a toast."
|
|
1284
|
-
}),
|
|
1285
|
-
subject: LayoutAction2.Toast.annotations({
|
|
1286
|
-
description: "The toast to add."
|
|
1287
|
-
})
|
|
1288
|
-
}),
|
|
1289
|
-
output: Schema5.Void
|
|
1290
|
-
}) {
|
|
1291
|
-
}
|
|
1292
|
-
LayoutAction2.AddToast = AddToast;
|
|
1293
|
-
class SwitchWorkspace extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1294
|
-
input: Schema5.Struct({
|
|
1295
|
-
part: Schema5.Literal("workspace").annotations({
|
|
1296
|
-
description: "Switching the workspace."
|
|
1297
|
-
}),
|
|
1298
|
-
subject: Schema5.String.annotations({
|
|
1299
|
-
description: "The id of the workspace to switch to."
|
|
1300
|
-
})
|
|
1301
|
-
}),
|
|
1302
|
-
output: Schema5.Void
|
|
1303
|
-
}) {
|
|
1304
|
-
}
|
|
1305
|
-
LayoutAction2.SwitchWorkspace = SwitchWorkspace;
|
|
1306
|
-
class RevertWorkspace extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1307
|
-
input: Schema5.Struct({
|
|
1308
|
-
part: Schema5.Literal("workspace").annotations({
|
|
1309
|
-
description: "Switching the workspace."
|
|
1310
|
-
}),
|
|
1311
|
-
options: Schema5.Struct({
|
|
1312
|
-
revert: Schema5.Literal(true).annotations({
|
|
1313
|
-
description: "Revert to the previous workspace."
|
|
1314
|
-
})
|
|
1315
|
-
})
|
|
1316
|
-
}),
|
|
1317
|
-
output: Schema5.Void
|
|
1318
|
-
}) {
|
|
1319
|
-
}
|
|
1320
|
-
LayoutAction2.RevertWorkspace = RevertWorkspace;
|
|
1321
|
-
class Open extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1322
|
-
input: Schema5.Struct({
|
|
1323
|
-
part: Schema5.Literal("main").annotations({
|
|
1324
|
-
description: "Opening an item in the main content area."
|
|
1325
|
-
}),
|
|
1326
|
-
subject: Schema5.Array(Schema5.String.annotations({
|
|
1327
|
-
description: "Ids of the items to open."
|
|
1328
|
-
})),
|
|
1329
|
-
options: Schema5.optional(Schema5.Struct({
|
|
1330
|
-
state: Schema5.optional(Schema5.Literal(true).annotations({
|
|
1331
|
-
description: "The items are being added."
|
|
1332
|
-
})),
|
|
1333
|
-
variant: Schema5.optional(Schema5.String.annotations({
|
|
1334
|
-
description: "The variant of the item to open."
|
|
1335
|
-
})),
|
|
1336
|
-
key: Schema5.optional(Schema5.String.annotations({
|
|
1337
|
-
description: "If provided, will replace item with a matching key (id prefix)."
|
|
1338
|
-
})),
|
|
1339
|
-
workspace: Schema5.optional(Schema5.String.annotations({
|
|
1340
|
-
description: "The workspace to open the items in."
|
|
1341
|
-
})),
|
|
1342
|
-
scrollIntoView: Schema5.optional(Schema5.Boolean.annotations({
|
|
1343
|
-
description: "Scroll the items into view."
|
|
1344
|
-
})),
|
|
1345
|
-
pivotId: Schema5.optional(Schema5.String.annotations({
|
|
1346
|
-
description: "The id of the item to place new items next to."
|
|
1347
|
-
})),
|
|
1348
|
-
positioning: Schema5.optional(Schema5.Union(Schema5.Literal("start").annotations({
|
|
1349
|
-
description: "The items are being added before the pivot item."
|
|
1350
|
-
}), Schema5.Literal("end").annotations({
|
|
1351
|
-
description: "The items are being added after the pivot item."
|
|
1352
|
-
})))
|
|
1353
|
-
}))
|
|
1354
|
-
}),
|
|
1355
|
-
output: Schema5.Void
|
|
1356
|
-
}) {
|
|
1357
|
-
}
|
|
1358
|
-
LayoutAction2.Open = Open;
|
|
1359
|
-
class Set2 extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1360
|
-
input: Schema5.Struct({
|
|
1361
|
-
part: Schema5.Literal("main").annotations({
|
|
1362
|
-
description: "Setting items in the main content area."
|
|
1363
|
-
}),
|
|
1364
|
-
subject: Schema5.Array(Schema5.String.annotations({
|
|
1365
|
-
description: "Ids of the items to set."
|
|
1366
|
-
})),
|
|
1367
|
-
options: Schema5.Struct({
|
|
1368
|
-
override: Schema5.Literal(true).annotations({
|
|
1369
|
-
description: "Override the current items in the main content area."
|
|
1370
|
-
})
|
|
1371
|
-
})
|
|
1372
|
-
}),
|
|
1373
|
-
output: Schema5.Void
|
|
1374
|
-
}) {
|
|
1375
|
-
}
|
|
1376
|
-
LayoutAction2.Set = Set2;
|
|
1377
|
-
class Close extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1378
|
-
input: Schema5.Struct({
|
|
1379
|
-
part: Schema5.Literal("main").annotations({
|
|
1380
|
-
description: "Closing items in the main content area."
|
|
1381
|
-
}),
|
|
1382
|
-
subject: Schema5.Array(Schema5.String.annotations({
|
|
1383
|
-
description: "Ids of the items to close."
|
|
1384
|
-
})),
|
|
1385
|
-
options: Schema5.Struct({
|
|
1386
|
-
state: Schema5.Literal(false).annotations({
|
|
1387
|
-
description: "The items are being removed."
|
|
1388
|
-
})
|
|
1389
|
-
})
|
|
1390
|
-
}),
|
|
1391
|
-
output: Schema5.Void
|
|
1392
|
-
}) {
|
|
1393
|
-
}
|
|
1394
|
-
LayoutAction2.Close = Close;
|
|
1395
|
-
class ScrollIntoView extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1396
|
-
input: Schema5.Struct({
|
|
1397
|
-
part: Schema5.Literal("current").annotations({
|
|
1398
|
-
description: "Setting the current item"
|
|
1399
|
-
}),
|
|
1400
|
-
subject: Schema5.optional(Schema5.String.annotations({
|
|
1401
|
-
description: "The id of the item to set as current."
|
|
1402
|
-
})),
|
|
1403
|
-
options: Schema5.optional(Schema5.Record({
|
|
1404
|
-
key: Schema5.String,
|
|
1405
|
-
value: Schema5.Any
|
|
1406
|
-
}).annotations({
|
|
1407
|
-
description: "Additional options for the scroll into view."
|
|
1408
|
-
}))
|
|
1409
|
-
}),
|
|
1410
|
-
output: Schema5.Void
|
|
1411
|
-
}) {
|
|
1412
|
-
}
|
|
1413
|
-
LayoutAction2.ScrollIntoView = ScrollIntoView;
|
|
1414
|
-
class Expose extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1415
|
-
input: Schema5.Struct({
|
|
1416
|
-
part: Schema5.Literal("navigation").annotations({
|
|
1417
|
-
description: "Exposing an item in the navigation area."
|
|
1418
|
-
}),
|
|
1419
|
-
subject: Schema5.String.annotations({
|
|
1420
|
-
description: "The id of the item to expose."
|
|
1421
|
-
})
|
|
1422
|
-
}),
|
|
1423
|
-
output: Schema5.Void
|
|
1424
|
-
}) {
|
|
1425
|
-
}
|
|
1426
|
-
LayoutAction2.Expose = Expose;
|
|
1427
|
-
})(LayoutAction || (LayoutAction = {}));
|
|
1428
|
-
var LayoutAction;
|
|
1429
|
-
|
|
1430
|
-
// src/common/surface.ts
|
|
1431
|
-
var createSurface = (definition) => definition;
|
|
1432
|
-
|
|
1433
|
-
// src/common/translations.ts
|
|
1434
|
-
import { Schema as Schema6 } from "effect";
|
|
1435
|
-
var ResourceKey = Schema6.Union(Schema6.String, Schema6.Record({
|
|
1436
|
-
key: Schema6.String,
|
|
1437
|
-
value: Schema6.Any
|
|
1438
|
-
}));
|
|
1439
|
-
var ResourceLanguage = Schema6.Record({
|
|
1440
|
-
key: Schema6.String,
|
|
1441
|
-
value: ResourceKey
|
|
1442
|
-
});
|
|
1443
|
-
var Resource = Schema6.Record({
|
|
1444
|
-
key: Schema6.String,
|
|
1445
|
-
value: ResourceLanguage
|
|
1446
|
-
});
|
|
1447
|
-
|
|
1448
|
-
// src/plugin-intent/intent-dispatcher.ts
|
|
1449
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/sdk/app-framework/src/plugin-intent/intent-dispatcher.ts";
|
|
1450
|
-
var EXECUTION_LIMIT = 100;
|
|
1451
|
-
var HISTORY_LIMIT = 100;
|
|
1452
|
-
var createResolver = (resolver) => resolver;
|
|
1453
|
-
var isUndoable = (historyEntry) => historyEntry.length > 0 && historyEntry.every(({ undoable }) => !!undoable);
|
|
1454
|
-
var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, historyLimit = HISTORY_LIMIT } = {}) => {
|
|
1455
|
-
const historyRef = Effect3.runSync(Ref2.make([]));
|
|
1456
|
-
const handleIntent = (intent) => Effect3.gen(function* () {
|
|
1457
|
-
const candidates = getResolvers().filter((resolver) => resolver.intent._tag === intent.id).filter((resolver) => !resolver.filter || resolver.filter(intent.data)).toSorted(byPosition);
|
|
1458
|
-
if (candidates.length === 0) {
|
|
1459
|
-
return yield* Effect3.fail(new NoResolversError(intent.id));
|
|
1460
|
-
}
|
|
1461
|
-
const effect = candidates[0].resolve(intent.data, intent.undo ?? false);
|
|
1462
|
-
const result = Effect3.isEffect(effect) ? yield* effect : yield* Effect3.promise(async () => effect);
|
|
1463
|
-
return {
|
|
1464
|
-
_intent: intent,
|
|
1465
|
-
...result
|
|
1466
|
-
};
|
|
1467
|
-
});
|
|
1468
|
-
const dispatch = (intentChain, depth = 0) => {
|
|
1469
|
-
return Effect3.gen(function* () {
|
|
1470
|
-
if (depth > executionLimit) {
|
|
1471
|
-
return yield* Effect3.fail(new CycleDetectedError());
|
|
1472
|
-
}
|
|
1473
|
-
const resultsRef = yield* Ref2.make([]);
|
|
1474
|
-
for (const intent of intentChain.all) {
|
|
1475
|
-
const { data: prev } = (yield* resultsRef.get)[0] ?? {};
|
|
1476
|
-
const result2 = yield* handleIntent({
|
|
1477
|
-
...intent,
|
|
1478
|
-
data: {
|
|
1479
|
-
...intent.data,
|
|
1480
|
-
...prev
|
|
1481
|
-
}
|
|
1482
|
-
});
|
|
1483
|
-
yield* Ref2.update(resultsRef, (results2) => [
|
|
1484
|
-
result2,
|
|
1485
|
-
...results2
|
|
1486
|
-
]);
|
|
1487
|
-
if (result2.intents) {
|
|
1488
|
-
for (const intent2 of result2.intents) {
|
|
1489
|
-
yield* dispatch(intent2, depth + 1);
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
if (result2.error) {
|
|
1493
|
-
return yield* Effect3.fail(result2.error);
|
|
1494
|
-
}
|
|
1495
|
-
}
|
|
1496
|
-
const results = yield* resultsRef.get;
|
|
1497
|
-
const result = results[0];
|
|
1498
|
-
yield* Ref2.update(historyRef, (history) => {
|
|
1499
|
-
const next = [
|
|
1500
|
-
...history,
|
|
1501
|
-
results
|
|
1502
|
-
];
|
|
1503
|
-
if (next.length > historyLimit) {
|
|
1504
|
-
next.splice(0, next.length - historyLimit);
|
|
1505
|
-
}
|
|
1506
|
-
return next;
|
|
1507
|
-
});
|
|
1508
|
-
if (result.undoable && isUndoable(results)) {
|
|
1509
|
-
yield* pipe2(dispatch(createIntent(IntentAction.ShowUndo, {
|
|
1510
|
-
message: result.undoable.message
|
|
1511
|
-
})), Effect3.catchSome((err) => err instanceof NoResolversError ? Option.some(Effect3.succeed(void 0)) : Option.none()));
|
|
1512
|
-
}
|
|
1513
|
-
return result.data;
|
|
1514
|
-
});
|
|
1515
|
-
};
|
|
1516
|
-
const dispatchPromise = (intentChain) => {
|
|
1517
|
-
return Effect3.runPromise(dispatch(intentChain)).then((data) => ({
|
|
1518
|
-
data
|
|
1519
|
-
})).catch((error) => {
|
|
1520
|
-
log3.catch(error, void 0, {
|
|
1521
|
-
F: __dxlog_file3,
|
|
1522
|
-
L: 271,
|
|
1523
|
-
S: void 0,
|
|
1524
|
-
C: (f, a) => f(...a)
|
|
1525
|
-
});
|
|
1526
|
-
return {
|
|
1527
|
-
error
|
|
1528
|
-
};
|
|
1529
|
-
});
|
|
1530
|
-
};
|
|
1531
|
-
const undo = () => {
|
|
1532
|
-
return Effect3.gen(function* () {
|
|
1533
|
-
const history = yield* historyRef.get;
|
|
1534
|
-
const last = history.findLastIndex(isUndoable);
|
|
1535
|
-
const result = last !== -1 ? history[last] : void 0;
|
|
1536
|
-
if (result) {
|
|
1537
|
-
const all = result.map(({ _intent, undoable }) => {
|
|
1538
|
-
const data = _intent.data;
|
|
1539
|
-
const undoData = undoable?.data ?? {};
|
|
1540
|
-
return {
|
|
1541
|
-
..._intent,
|
|
1542
|
-
data: {
|
|
1543
|
-
...data,
|
|
1544
|
-
...undoData
|
|
1545
|
-
},
|
|
1546
|
-
undo: true
|
|
1547
|
-
};
|
|
1548
|
-
});
|
|
1549
|
-
const intent = {
|
|
1550
|
-
first: all[0],
|
|
1551
|
-
last: all.at(-1),
|
|
1552
|
-
all
|
|
1553
|
-
};
|
|
1554
|
-
yield* Ref2.update(historyRef, (h) => h.filter((_, index) => index !== last));
|
|
1555
|
-
return yield* dispatch(intent);
|
|
1556
|
-
}
|
|
1557
|
-
});
|
|
1558
|
-
};
|
|
1559
|
-
const undoPromise = () => {
|
|
1560
|
-
return Effect3.runPromise(undo()).then((data) => ({
|
|
1561
|
-
data
|
|
1562
|
-
})).catch((error) => ({
|
|
1563
|
-
error
|
|
1564
|
-
}));
|
|
1565
|
-
};
|
|
1566
|
-
return {
|
|
1567
|
-
dispatch,
|
|
1568
|
-
dispatchPromise,
|
|
1569
|
-
undo,
|
|
1570
|
-
undoPromise
|
|
1571
|
-
};
|
|
1572
|
-
};
|
|
1573
|
-
var defaultEffect = () => Effect3.fail(new Error("Intent runtime not ready"));
|
|
1574
|
-
var defaultPromise = () => Effect3.runPromise(defaultEffect());
|
|
1575
|
-
var intent_dispatcher_default = ((context) => {
|
|
1576
|
-
const state = live2({
|
|
1577
|
-
dispatch: defaultEffect,
|
|
1578
|
-
dispatchPromise: defaultPromise,
|
|
1579
|
-
undo: defaultEffect,
|
|
1580
|
-
undoPromise: defaultPromise
|
|
1581
|
-
});
|
|
1582
|
-
const { dispatch, dispatchPromise, undo, undoPromise } = createDispatcher(() => context.getCapabilities(Capabilities.IntentResolver).flat());
|
|
1583
|
-
const manager = context.getCapability(Capabilities.PluginManager);
|
|
1584
|
-
state.dispatch = (intentChain, depth) => {
|
|
1585
|
-
return Effect3.gen(function* () {
|
|
1586
|
-
yield* manager._activate(Events.SetupIntentResolver);
|
|
1587
|
-
return yield* dispatch(intentChain, depth);
|
|
1588
|
-
});
|
|
1589
|
-
};
|
|
1590
|
-
state.dispatchPromise = async (intentChain) => {
|
|
1591
|
-
await manager.activate(Events.SetupIntentResolver);
|
|
1592
|
-
return await dispatchPromise(intentChain);
|
|
1593
|
-
};
|
|
1594
|
-
state.undo = undo;
|
|
1595
|
-
state.undoPromise = undoPromise;
|
|
1596
|
-
return contributes(Capabilities.IntentDispatcher, state);
|
|
1597
|
-
});
|
|
1598
|
-
|
|
1599
|
-
export {
|
|
1600
|
-
defineCapability,
|
|
1601
|
-
contributes,
|
|
1602
|
-
lazy,
|
|
1603
|
-
PluginContext,
|
|
1604
|
-
defineEvent,
|
|
1605
|
-
eventKey,
|
|
1606
|
-
oneOf,
|
|
1607
|
-
allOf,
|
|
1608
|
-
isOneOf,
|
|
1609
|
-
isAllOf,
|
|
1610
|
-
getEvents,
|
|
1611
|
-
PluginManager,
|
|
1612
|
-
PluginModule,
|
|
1613
|
-
defineModule,
|
|
1614
|
-
Plugin,
|
|
1615
|
-
definePlugin,
|
|
1616
|
-
Capabilities,
|
|
1617
|
-
CollaborationActions,
|
|
1618
|
-
Events,
|
|
1619
|
-
defaultFileTypes,
|
|
1620
|
-
FileInfoSchema,
|
|
1621
|
-
createIntent,
|
|
1622
|
-
chain,
|
|
1623
|
-
Label,
|
|
1624
|
-
IntentAction,
|
|
1625
|
-
BaseError,
|
|
1626
|
-
NoResolversError,
|
|
1627
|
-
CycleDetectedError,
|
|
1628
|
-
createResolver,
|
|
1629
|
-
createDispatcher,
|
|
1630
|
-
intent_dispatcher_default,
|
|
1631
|
-
IntentPlugin,
|
|
1632
|
-
LayoutAction,
|
|
1633
|
-
createSurface,
|
|
1634
|
-
ResourceKey,
|
|
1635
|
-
ResourceLanguage,
|
|
1636
|
-
Resource
|
|
1637
|
-
};
|
|
1638
|
-
//# sourceMappingURL=chunk-6V54SRFL.mjs.map
|