@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
|
@@ -0,0 +1,907 @@
|
|
|
1
|
+
import {
|
|
2
|
+
eventKey,
|
|
3
|
+
getEvents,
|
|
4
|
+
isAllOf
|
|
5
|
+
} from "./chunk-66IXTIVK.mjs";
|
|
6
|
+
import {
|
|
7
|
+
Service as Service2,
|
|
8
|
+
isLazy,
|
|
9
|
+
resolveLazy
|
|
10
|
+
} from "./chunk-Z55LVAGN.mjs";
|
|
11
|
+
import {
|
|
12
|
+
Service
|
|
13
|
+
} from "./chunk-3JWJXGLK.mjs";
|
|
14
|
+
import {
|
|
15
|
+
__export
|
|
16
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
17
|
+
|
|
18
|
+
// src/core/plugin-manager.ts
|
|
19
|
+
var plugin_manager_exports = {};
|
|
20
|
+
__export(plugin_manager_exports, {
|
|
21
|
+
ManagerTypeId: () => ManagerTypeId,
|
|
22
|
+
PluginInitializationError: () => PluginInitializationError,
|
|
23
|
+
isManager: () => isManager,
|
|
24
|
+
make: () => make5
|
|
25
|
+
});
|
|
26
|
+
import { Atom as Atom2, Registry } from "@effect-atom/atom-react";
|
|
27
|
+
import * as Array from "effect/Array";
|
|
28
|
+
import * as Cause from "effect/Cause";
|
|
29
|
+
import * as Deferred2 from "effect/Deferred";
|
|
30
|
+
import * as Duration from "effect/Duration";
|
|
31
|
+
import * as Effect2 from "effect/Effect";
|
|
32
|
+
import * as Fiber from "effect/Fiber";
|
|
33
|
+
import * as Function from "effect/Function";
|
|
34
|
+
import * as HashSet from "effect/HashSet";
|
|
35
|
+
import * as PubSub from "effect/PubSub";
|
|
36
|
+
import * as Ref from "effect/Ref";
|
|
37
|
+
import { runAndForwardErrors } from "@dxos/effect";
|
|
38
|
+
import { Performance } from "@dxos/effect";
|
|
39
|
+
import { BaseError } from "@dxos/errors";
|
|
40
|
+
import { log as log2 } from "@dxos/log";
|
|
41
|
+
|
|
42
|
+
// src/core/capability-manager.ts
|
|
43
|
+
var capability_manager_exports = {};
|
|
44
|
+
__export(capability_manager_exports, {
|
|
45
|
+
make: () => make2
|
|
46
|
+
});
|
|
47
|
+
import { Atom } from "@effect-atom/atom-react";
|
|
48
|
+
import * as Deferred from "effect/Deferred";
|
|
49
|
+
import * as Effect from "effect/Effect";
|
|
50
|
+
import { invariant } from "@dxos/invariant";
|
|
51
|
+
import { log } from "@dxos/log";
|
|
52
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/capability-manager.ts";
|
|
53
|
+
var CapabilityManagerImpl = class {
|
|
54
|
+
_registry;
|
|
55
|
+
_capabilityEntries = Atom.family(() => {
|
|
56
|
+
return Atom.make([]).pipe(Atom.keepAlive);
|
|
57
|
+
});
|
|
58
|
+
_capabilities = Atom.family((id) => {
|
|
59
|
+
return Atom.make((get2) => {
|
|
60
|
+
const current = get2(this._capabilityEntries(id));
|
|
61
|
+
return current.map((c) => c.implementation);
|
|
62
|
+
}).pipe(Atom.keepAlive);
|
|
63
|
+
});
|
|
64
|
+
_capabilitiesByModule = Atom.family((id) => {
|
|
65
|
+
return Atom.make((get2) => {
|
|
66
|
+
const entries = get2(this._capabilityEntries(id));
|
|
67
|
+
const result = {};
|
|
68
|
+
for (const entry of entries) {
|
|
69
|
+
(result[entry.moduleId] ??= []).push(entry.implementation);
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
}).pipe(Atom.keepAlive);
|
|
73
|
+
});
|
|
74
|
+
_capability = Atom.family((id) => {
|
|
75
|
+
return Atom.make((get2) => {
|
|
76
|
+
const current = get2(this._capabilities(id));
|
|
77
|
+
invariant(current.length > 0, `No capability found for ${id}`, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 35, S: this, A: ["current.length > 0", "`No capability found for ${id}`"] });
|
|
78
|
+
return current[0];
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
constructor({ registry }) {
|
|
82
|
+
this._registry = registry;
|
|
83
|
+
}
|
|
84
|
+
contribute({ module: moduleId, interface: interfaceDef, implementation }) {
|
|
85
|
+
const current = this._registry.get(this._capabilityEntries(interfaceDef.identifier));
|
|
86
|
+
const isDuplicate = current.some((c) => c.moduleId === moduleId && c.implementation === implementation);
|
|
87
|
+
if (isDuplicate) {
|
|
88
|
+
log("capability already contributed, skipping", {
|
|
89
|
+
id: interfaceDef.identifier,
|
|
90
|
+
moduleId
|
|
91
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 46, S: this });
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const entry = {
|
|
95
|
+
moduleId,
|
|
96
|
+
implementation
|
|
97
|
+
};
|
|
98
|
+
this._registry.set(this._capabilityEntries(interfaceDef.identifier), [
|
|
99
|
+
...current,
|
|
100
|
+
entry
|
|
101
|
+
]);
|
|
102
|
+
log("capability contributed", {
|
|
103
|
+
id: interfaceDef.identifier,
|
|
104
|
+
moduleId,
|
|
105
|
+
count: current.length
|
|
106
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 60, S: this });
|
|
107
|
+
}
|
|
108
|
+
remove(interfaceDef, implementation) {
|
|
109
|
+
const current = this._registry.get(this._capabilityEntries(interfaceDef.identifier));
|
|
110
|
+
if (current.length === 0) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const next = current.filter((c) => c.implementation !== implementation);
|
|
114
|
+
if (next.length !== current.length) {
|
|
115
|
+
this._registry.set(this._capabilityEntries(interfaceDef.identifier), next);
|
|
116
|
+
log("capability removed", {
|
|
117
|
+
id: interfaceDef.identifier,
|
|
118
|
+
count: current.length
|
|
119
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 74, S: this });
|
|
120
|
+
} else {
|
|
121
|
+
log.warn("capability not removed", {
|
|
122
|
+
id: interfaceDef.identifier
|
|
123
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 79, S: this });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
atom(interfaceDef) {
|
|
127
|
+
return this._capabilities(interfaceDef.identifier);
|
|
128
|
+
}
|
|
129
|
+
getAll(interfaceDef) {
|
|
130
|
+
return this._registry.get(this.atom(interfaceDef));
|
|
131
|
+
}
|
|
132
|
+
get(interfaceDef) {
|
|
133
|
+
const capabilities = this.getAll(interfaceDef);
|
|
134
|
+
invariant(capabilities.length > 0, `No capability found for ${interfaceDef.identifier}`, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 93, S: this, A: ["capabilities.length > 0", "`No capability found for ${interfaceDef.identifier}`"] });
|
|
135
|
+
return capabilities[0];
|
|
136
|
+
}
|
|
137
|
+
waitFor(interfaceDef) {
|
|
138
|
+
return Effect.gen(this, function* () {
|
|
139
|
+
const [capability] = this.getAll(interfaceDef);
|
|
140
|
+
if (capability) {
|
|
141
|
+
return capability;
|
|
142
|
+
}
|
|
143
|
+
const deferred = yield* Deferred.make();
|
|
144
|
+
const cancel = this._registry.subscribe(this.atom(interfaceDef), (capabilities) => {
|
|
145
|
+
if (capabilities.length > 0) {
|
|
146
|
+
Effect.runSync(Deferred.succeed(deferred, capabilities[0]));
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
const result = yield* Deferred.await(deferred);
|
|
150
|
+
cancel();
|
|
151
|
+
return result;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
atomByModule(interfaceDef) {
|
|
155
|
+
return this._capabilitiesByModule(interfaceDef.identifier);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
var make2 = (options) => new CapabilityManagerImpl(options);
|
|
159
|
+
|
|
160
|
+
// src/core/plugin-manager.ts
|
|
161
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/plugin-manager.ts";
|
|
162
|
+
var PluginInitializationError = class extends BaseError.extend("PluginInitializationError", "Plugin manager initialization failed") {
|
|
163
|
+
};
|
|
164
|
+
var ManagerTypeId = /* @__PURE__ */ Symbol.for("@dxos/app-framework/Manager");
|
|
165
|
+
var isManager = (value) => {
|
|
166
|
+
return typeof value === "object" && value !== null && ManagerTypeId in value;
|
|
167
|
+
};
|
|
168
|
+
var ManagerImpl = class {
|
|
169
|
+
[ManagerTypeId] = ManagerTypeId;
|
|
170
|
+
activation = Effect2.runSync(PubSub.unbounded());
|
|
171
|
+
capabilities;
|
|
172
|
+
registry;
|
|
173
|
+
_pluginsAtom;
|
|
174
|
+
_coreAtom;
|
|
175
|
+
_enabledAtom;
|
|
176
|
+
_modulesAtom;
|
|
177
|
+
_activeAtom;
|
|
178
|
+
_eventsFiredAtom;
|
|
179
|
+
_pendingResetAtom;
|
|
180
|
+
_pluginLoader;
|
|
181
|
+
_onRemove;
|
|
182
|
+
_capabilities = /* @__PURE__ */ new Map();
|
|
183
|
+
_moduleMemoMap = /* @__PURE__ */ new Map();
|
|
184
|
+
_moduleSemaphores = /* @__PURE__ */ new Map();
|
|
185
|
+
// Coalesces concurrent `_resolveLazyPlugin` calls per plugin id. Without
|
|
186
|
+
// this, two callers entering `enable(id)` before the swap completes would
|
|
187
|
+
// each invoke `mod.default(options)` and produce distinct module objects,
|
|
188
|
+
// defeating `_addModule`'s reference-equality dedupe and racing the
|
|
189
|
+
// `_pluginsAtom` swap.
|
|
190
|
+
_resolvingPlugins = /* @__PURE__ */ new Map();
|
|
191
|
+
_activatingEvents = Effect2.runSync(Ref.make([]));
|
|
192
|
+
_activatingModules = Effect2.runSync(Ref.make([]));
|
|
193
|
+
_inFlightFibers = Effect2.runSync(Ref.make([]));
|
|
194
|
+
_shutdownSemaphore = Effect2.runSync(Effect2.makeSemaphore(1));
|
|
195
|
+
_shuttingDown = Effect2.runSync(Ref.make(false));
|
|
196
|
+
// Tracks the constructor-launched core/enabled `enable()` calls so that
|
|
197
|
+
// `activate` can wait for module registration before dispatching events.
|
|
198
|
+
// Lazy plugins make `enable` asynchronous (a dynamic `import()` happens
|
|
199
|
+
// inside it), so without this synchronization an `activate` triggered
|
|
200
|
+
// immediately after `make` could fire on an empty module set. Failures
|
|
201
|
+
// are wrapped in `PluginInitializationError` so awaiters get a tagged
|
|
202
|
+
// error rather than the wide `Error` produced by the underlying chain.
|
|
203
|
+
_initialization = Effect2.runSync(Deferred2.make());
|
|
204
|
+
constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta }) => meta.id), enabled = [], registry, onRemove }) {
|
|
205
|
+
this.registry = registry ?? Registry.make();
|
|
206
|
+
this.capabilities = make2({
|
|
207
|
+
registry: this.registry
|
|
208
|
+
});
|
|
209
|
+
this._pluginLoader = pluginLoader;
|
|
210
|
+
this._onRemove = onRemove;
|
|
211
|
+
this._pluginsAtom = Atom2.make(plugins).pipe(Atom2.keepAlive);
|
|
212
|
+
this._coreAtom = Atom2.make(core).pipe(Atom2.keepAlive);
|
|
213
|
+
this._enabledAtom = Atom2.make(enabled).pipe(Atom2.keepAlive);
|
|
214
|
+
this._modulesAtom = Atom2.make([]).pipe(Atom2.keepAlive);
|
|
215
|
+
this._activeAtom = Atom2.make([]).pipe(Atom2.keepAlive);
|
|
216
|
+
this._eventsFiredAtom = Atom2.make([]).pipe(Atom2.keepAlive);
|
|
217
|
+
this._pendingResetAtom = Atom2.make([]).pipe(Atom2.keepAlive);
|
|
218
|
+
plugins.forEach((plugin) => this._addPlugin(plugin));
|
|
219
|
+
const initialIds = [
|
|
220
|
+
.../* @__PURE__ */ new Set([
|
|
221
|
+
...core,
|
|
222
|
+
...enabled
|
|
223
|
+
])
|
|
224
|
+
];
|
|
225
|
+
void Effect2.all(initialIds.map((id) => this.enable(id))).pipe(Effect2.mapError((cause) => new PluginInitializationError({
|
|
226
|
+
cause
|
|
227
|
+
})), Effect2.tap(() => Deferred2.succeed(this._initialization, void 0)), Effect2.tapErrorCause((cause) => Deferred2.failCause(this._initialization, cause))).pipe(runAndForwardErrors);
|
|
228
|
+
}
|
|
229
|
+
get plugins() {
|
|
230
|
+
return this._pluginsAtom;
|
|
231
|
+
}
|
|
232
|
+
get core() {
|
|
233
|
+
return this._coreAtom;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Ids of plugins that are currently enabled.
|
|
237
|
+
*/
|
|
238
|
+
get enabled() {
|
|
239
|
+
return this._enabledAtom;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Modules of plugins which are currently enabled.
|
|
243
|
+
*/
|
|
244
|
+
get modules() {
|
|
245
|
+
return this._modulesAtom;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Ids of modules which are currently active.
|
|
249
|
+
*/
|
|
250
|
+
get active() {
|
|
251
|
+
return this._activeAtom;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Ids of events which have been fired.
|
|
255
|
+
*/
|
|
256
|
+
get eventsFired() {
|
|
257
|
+
return this._eventsFiredAtom;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Ids of modules which are pending reset.
|
|
261
|
+
*/
|
|
262
|
+
get pendingReset() {
|
|
263
|
+
return this._pendingResetAtom;
|
|
264
|
+
}
|
|
265
|
+
getPlugins() {
|
|
266
|
+
return this._get(this._pluginsAtom);
|
|
267
|
+
}
|
|
268
|
+
getCore() {
|
|
269
|
+
return this._get(this._coreAtom);
|
|
270
|
+
}
|
|
271
|
+
getEnabled() {
|
|
272
|
+
return this._get(this._enabledAtom);
|
|
273
|
+
}
|
|
274
|
+
getModules() {
|
|
275
|
+
return this._get(this._modulesAtom);
|
|
276
|
+
}
|
|
277
|
+
getActive() {
|
|
278
|
+
return this._get(this._activeAtom);
|
|
279
|
+
}
|
|
280
|
+
getEventsFired() {
|
|
281
|
+
return this._get(this._eventsFiredAtom);
|
|
282
|
+
}
|
|
283
|
+
getPendingReset() {
|
|
284
|
+
return this._get(this._pendingResetAtom);
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Adds a plugin to the manager via the plugin loader.
|
|
288
|
+
* The plugin is registered but not enabled; call `enable` separately to activate it.
|
|
289
|
+
* @param id The id of the plugin.
|
|
290
|
+
*/
|
|
291
|
+
add(id) {
|
|
292
|
+
return Effect2.gen(this, function* () {
|
|
293
|
+
log2("add plugin", {
|
|
294
|
+
id
|
|
295
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 165, S: this });
|
|
296
|
+
const plugin = yield* this._pluginLoader(id);
|
|
297
|
+
this._addPlugin(plugin);
|
|
298
|
+
return plugin;
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Enables a plugin.
|
|
303
|
+
* @param id The id of the plugin.
|
|
304
|
+
*/
|
|
305
|
+
enable(id) {
|
|
306
|
+
return Effect2.gen(this, function* () {
|
|
307
|
+
log2("enable plugin", {
|
|
308
|
+
id
|
|
309
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 178, S: this });
|
|
310
|
+
const stub = this._getPlugin(id);
|
|
311
|
+
if (!stub) {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
const plugin = yield* this._resolveLazyPlugin(stub);
|
|
315
|
+
this._update(this._enabledAtom, (enabled) => enabled.includes(id) ? enabled : [
|
|
316
|
+
...enabled,
|
|
317
|
+
id
|
|
318
|
+
]);
|
|
319
|
+
plugin.modules.forEach((module) => {
|
|
320
|
+
this._addModule(module);
|
|
321
|
+
this._setPendingResetByModule(module);
|
|
322
|
+
});
|
|
323
|
+
log2("pending reset", {
|
|
324
|
+
events: [
|
|
325
|
+
...this.getPendingReset()
|
|
326
|
+
]
|
|
327
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 194, S: this });
|
|
328
|
+
yield* Effect2.all(this.getPendingReset().map((event) => this.activate(event)), {
|
|
329
|
+
concurrency: "unbounded"
|
|
330
|
+
});
|
|
331
|
+
return true;
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Resolves a lazy plugin stub (returned by {@link Plugin.lazy}) to its
|
|
336
|
+
* loaded form and swaps it into `_pluginsAtom`. Returns the input unchanged
|
|
337
|
+
* when the plugin is already resolved, so callers can `yield*` this
|
|
338
|
+
* unconditionally. The lazy stub carries `meta` synchronously but its
|
|
339
|
+
* `modules` list is empty until the loader resolves; the swap ensures
|
|
340
|
+
* subsequent enable/disable operations see the resolved plugin.
|
|
341
|
+
*
|
|
342
|
+
* Concurrent calls for the same id are coalesced via `_resolvingPlugins`:
|
|
343
|
+
* the first caller starts the resolution, every subsequent caller awaits
|
|
344
|
+
* the same `Deferred`. On failure we publish a `lazy:<id>` error message
|
|
345
|
+
* and skip the atom swap so the failure is observable to the activation
|
|
346
|
+
* subscriber and a retry can be attempted.
|
|
347
|
+
*/
|
|
348
|
+
_resolveLazyPlugin(plugin) {
|
|
349
|
+
return Effect2.gen(this, function* () {
|
|
350
|
+
if (!isLazy(plugin)) {
|
|
351
|
+
return plugin;
|
|
352
|
+
}
|
|
353
|
+
const id = plugin.meta.id;
|
|
354
|
+
const existing = this._resolvingPlugins.get(id);
|
|
355
|
+
if (existing) {
|
|
356
|
+
return yield* Deferred2.await(existing);
|
|
357
|
+
}
|
|
358
|
+
const deferred = yield* Deferred2.make();
|
|
359
|
+
this._resolvingPlugins.set(id, deferred);
|
|
360
|
+
return yield* Effect2.gen(this, function* () {
|
|
361
|
+
log2("resolving lazy plugin", {
|
|
362
|
+
id
|
|
363
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 231, S: this });
|
|
364
|
+
yield* PubSub.publish(this.activation, {
|
|
365
|
+
event: "",
|
|
366
|
+
state: "activating",
|
|
367
|
+
module: `lazy:${id}`
|
|
368
|
+
});
|
|
369
|
+
const resolvedPlugin = yield* resolveLazy(plugin);
|
|
370
|
+
this._update(this._pluginsAtom, (plugins) => plugins.map((p) => p.meta.id === id ? resolvedPlugin : p));
|
|
371
|
+
yield* PubSub.publish(this.activation, {
|
|
372
|
+
event: "",
|
|
373
|
+
state: "activated",
|
|
374
|
+
module: `lazy:${id}`
|
|
375
|
+
});
|
|
376
|
+
return resolvedPlugin;
|
|
377
|
+
}).pipe(Effect2.tapError((error) => PubSub.publish(this.activation, {
|
|
378
|
+
event: "",
|
|
379
|
+
state: "error",
|
|
380
|
+
module: `lazy:${id}`,
|
|
381
|
+
error
|
|
382
|
+
})), Effect2.tap((value) => Deferred2.succeed(deferred, value)), Effect2.tapErrorCause((cause) => Deferred2.failCause(deferred, cause)), Effect2.ensuring(Effect2.sync(() => this._resolvingPlugins.delete(id))));
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Removes a plugin from the manager.
|
|
387
|
+
* @param id The id of the plugin.
|
|
388
|
+
*/
|
|
389
|
+
remove(id) {
|
|
390
|
+
return Effect2.gen(this, function* () {
|
|
391
|
+
log2("remove plugin", {
|
|
392
|
+
id
|
|
393
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 260, S: this });
|
|
394
|
+
const disabled = yield* this.disable(id);
|
|
395
|
+
if (!disabled) {
|
|
396
|
+
return false;
|
|
397
|
+
}
|
|
398
|
+
this._removePlugin(id);
|
|
399
|
+
if (this._onRemove) {
|
|
400
|
+
this._runForkedFiber(this._onRemove(id).pipe(Effect2.tapError((error) => Effect2.sync(() => log2.warn("plugin remove hook failed", {
|
|
401
|
+
id,
|
|
402
|
+
error
|
|
403
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 269, S: this }))), Effect2.ignore));
|
|
404
|
+
}
|
|
405
|
+
return true;
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Disables a plugin.
|
|
410
|
+
* @param id The id of the plugin.
|
|
411
|
+
*/
|
|
412
|
+
disable(id) {
|
|
413
|
+
return Effect2.gen(this, function* () {
|
|
414
|
+
log2("disable plugin", {
|
|
415
|
+
id
|
|
416
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 282, S: this });
|
|
417
|
+
if (this._get(this._coreAtom).includes(id)) {
|
|
418
|
+
return false;
|
|
419
|
+
}
|
|
420
|
+
const plugin = this._getPlugin(id);
|
|
421
|
+
if (!plugin) {
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
const enabledIndex = this._get(this._enabledAtom).findIndex((enabled) => enabled === id);
|
|
425
|
+
if (enabledIndex !== -1) {
|
|
426
|
+
this._update(this._enabledAtom, (enabled) => enabled.filter((item) => item !== id));
|
|
427
|
+
yield* this.deactivate(id);
|
|
428
|
+
plugin.modules.forEach((module) => {
|
|
429
|
+
this._removeModule(module.id);
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
return true;
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Activates plugins based on the activation event.
|
|
437
|
+
* @param event The activation event.
|
|
438
|
+
* @returns Whether the activation was successful.
|
|
439
|
+
*/
|
|
440
|
+
activate(event, params) {
|
|
441
|
+
const key = typeof event === "string" ? event : eventKey(event);
|
|
442
|
+
return Effect2.gen(this, function* () {
|
|
443
|
+
if (yield* this._isShuttingDown()) {
|
|
444
|
+
log2("skipping activation during shutdown", {
|
|
445
|
+
key,
|
|
446
|
+
...params
|
|
447
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 311, S: this });
|
|
448
|
+
return false;
|
|
449
|
+
}
|
|
450
|
+
yield* Deferred2.await(this._initialization);
|
|
451
|
+
return yield* Effect2.withFiberRuntime((fiber) => this._activateEvent(key, params, fiber).pipe(together(Effect2.sleep(Duration.seconds(15)).pipe(Effect2.andThen(Effect2.sync(() => log2.warn("event activation is taking a long time", {
|
|
452
|
+
event: key
|
|
453
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 322, S: this }))))), Performance.addTrackEntry({
|
|
454
|
+
name: typeof event === "string" ? event : eventKey(event),
|
|
455
|
+
devtools: {
|
|
456
|
+
dataType: "track-entry",
|
|
457
|
+
track: "Event Activation",
|
|
458
|
+
trackGroup: "Composer",
|
|
459
|
+
color: "primary"
|
|
460
|
+
}
|
|
461
|
+
})));
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Deactivates all of the modules for a plugin.
|
|
466
|
+
* @param id The id of the plugin.
|
|
467
|
+
* @returns Whether the deactivation was successful.
|
|
468
|
+
*/
|
|
469
|
+
deactivate(id) {
|
|
470
|
+
return Effect2.gen(this, function* () {
|
|
471
|
+
const plugin = this._getPlugin(id);
|
|
472
|
+
if (!plugin) {
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
const modules = plugin.modules;
|
|
476
|
+
const results = yield* Effect2.all(modules.map((module) => this._deactivateModule(module)), {
|
|
477
|
+
concurrency: "unbounded"
|
|
478
|
+
});
|
|
479
|
+
return results.every((result) => result);
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Re-activates the modules that were activated by the event.
|
|
484
|
+
* @param event The activation event.
|
|
485
|
+
* @returns Whether the reset was successful.
|
|
486
|
+
*/
|
|
487
|
+
reset(event) {
|
|
488
|
+
return Effect2.gen(this, function* () {
|
|
489
|
+
const key = typeof event === "string" ? event : eventKey(event);
|
|
490
|
+
log2("reset", {
|
|
491
|
+
key
|
|
492
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 359, S: this });
|
|
493
|
+
const modules = this._getActiveModulesByEvent(key);
|
|
494
|
+
const results = yield* Effect2.all(modules.map((module) => this._deactivateModule(module)), {
|
|
495
|
+
concurrency: "unbounded"
|
|
496
|
+
});
|
|
497
|
+
if (results.every((result) => result)) {
|
|
498
|
+
return yield* this.activate(key);
|
|
499
|
+
} else {
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
shutdown() {
|
|
505
|
+
return this._shutdownSemaphore.withPermits(1)(Effect2.gen(this, function* () {
|
|
506
|
+
yield* Ref.set(this._shuttingDown, true);
|
|
507
|
+
log2("shutdown", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 376, S: this });
|
|
508
|
+
yield* this._interruptInFlightActivations();
|
|
509
|
+
const activeIds = [
|
|
510
|
+
...this._get(this._activeAtom)
|
|
511
|
+
].reverse();
|
|
512
|
+
const allModules = this._get(this._modulesAtom);
|
|
513
|
+
const modulesToDeactivate = activeIds.map((id) => allModules.find((module) => module.id === id)).filter((module) => module != null);
|
|
514
|
+
for (const module of modulesToDeactivate) {
|
|
515
|
+
yield* this._deactivateModule(module);
|
|
516
|
+
}
|
|
517
|
+
this._set(this._eventsFiredAtom, []);
|
|
518
|
+
this._set(this._pendingResetAtom, []);
|
|
519
|
+
this._moduleMemoMap.clear();
|
|
520
|
+
yield* Ref.set(this._activatingEvents, []);
|
|
521
|
+
yield* Ref.set(this._activatingModules, []);
|
|
522
|
+
log2("shutdown complete", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 391, S: this });
|
|
523
|
+
return true;
|
|
524
|
+
}).pipe(Effect2.ensuring(Ref.set(this._shuttingDown, false))));
|
|
525
|
+
}
|
|
526
|
+
//
|
|
527
|
+
// State helpers
|
|
528
|
+
//
|
|
529
|
+
_get(atom) {
|
|
530
|
+
return this.registry.get(atom);
|
|
531
|
+
}
|
|
532
|
+
_set(atom, value) {
|
|
533
|
+
this.registry.set(atom, value);
|
|
534
|
+
}
|
|
535
|
+
_update(atom, updater) {
|
|
536
|
+
this._set(atom, updater(this._get(atom)));
|
|
537
|
+
}
|
|
538
|
+
_isShuttingDown() {
|
|
539
|
+
return Ref.get(this._shuttingDown);
|
|
540
|
+
}
|
|
541
|
+
_getPlugin(id) {
|
|
542
|
+
return this._get(this._pluginsAtom).find((plugin) => plugin.meta.id === id);
|
|
543
|
+
}
|
|
544
|
+
_getActiveModules() {
|
|
545
|
+
const active = this._get(this._activeAtom);
|
|
546
|
+
return this._get(this._modulesAtom).filter((module) => active.includes(module.id));
|
|
547
|
+
}
|
|
548
|
+
_getInactiveModules() {
|
|
549
|
+
const active = this._get(this._activeAtom);
|
|
550
|
+
return this._get(this._modulesAtom).filter((module) => !active.includes(module.id));
|
|
551
|
+
}
|
|
552
|
+
_getActiveModulesByEvent(key) {
|
|
553
|
+
return this._getActiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
|
|
554
|
+
}
|
|
555
|
+
_getInactiveModulesByEvent(key) {
|
|
556
|
+
return this._getInactiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
|
|
557
|
+
}
|
|
558
|
+
_setPendingResetByModule(module) {
|
|
559
|
+
const activationEvents = getEvents(module.activatesOn).map(eventKey).filter((key) => this._get(this._eventsFiredAtom).includes(key));
|
|
560
|
+
const pendingReset = Array.fromIterable(new Set(activationEvents)).filter((event) => {
|
|
561
|
+
const pending = this._get(this._pendingResetAtom);
|
|
562
|
+
return !pending.includes(event);
|
|
563
|
+
});
|
|
564
|
+
if (pendingReset.length > 0) {
|
|
565
|
+
log2("pending reset", {
|
|
566
|
+
events: pendingReset
|
|
567
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 434, S: this });
|
|
568
|
+
this._update(this._pendingResetAtom, (current) => [
|
|
569
|
+
...current,
|
|
570
|
+
...pendingReset
|
|
571
|
+
]);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
_clearPendingReset(key) {
|
|
575
|
+
const pendingIndex = this._get(this._pendingResetAtom).findIndex((event) => event === key);
|
|
576
|
+
if (pendingIndex !== -1) {
|
|
577
|
+
this._update(this._pendingResetAtom, (pending) => pending.filter((event) => event !== key));
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
//
|
|
581
|
+
// Fiber helpers
|
|
582
|
+
//
|
|
583
|
+
_interruptInFlightActivations() {
|
|
584
|
+
return Effect2.gen(this, function* () {
|
|
585
|
+
const inFlightFibers = yield* Ref.get(this._inFlightFibers);
|
|
586
|
+
yield* Effect2.forEach(inFlightFibers, (fiber) => Fiber.interrupt(fiber), {
|
|
587
|
+
concurrency: "unbounded"
|
|
588
|
+
});
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
_trackFiber(ref, fiber) {
|
|
592
|
+
return Ref.update(ref, (fibers) => [
|
|
593
|
+
...fibers,
|
|
594
|
+
fiber
|
|
595
|
+
]);
|
|
596
|
+
}
|
|
597
|
+
_untrackFiber(ref, fiber) {
|
|
598
|
+
return Ref.update(ref, (fibers) => fibers.filter((trackedFiber) => trackedFiber !== fiber));
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Spawns an effect on the default runtime and registers the resulting fiber in
|
|
602
|
+
* `_inFlightFibers` so {@link shutdown} can interrupt it. Used from sync entry
|
|
603
|
+
* points like {@link remove} where there is no enclosing Effect to fork from;
|
|
604
|
+
* inside an Effect chain prefer the existing track/await/untrack pattern.
|
|
605
|
+
*/
|
|
606
|
+
_runForkedFiber(effect) {
|
|
607
|
+
const fiber = Effect2.runFork(effect);
|
|
608
|
+
Effect2.runSync(this._trackFiber(this._inFlightFibers, fiber));
|
|
609
|
+
Effect2.runFork(Fiber.await(fiber).pipe(Effect2.andThen(() => this._untrackFiber(this._inFlightFibers, fiber))));
|
|
610
|
+
}
|
|
611
|
+
//
|
|
612
|
+
// Registration helpers
|
|
613
|
+
//
|
|
614
|
+
_addPlugin(plugin) {
|
|
615
|
+
log2("add plugin", {
|
|
616
|
+
id: plugin.meta.id
|
|
617
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 483, S: this });
|
|
618
|
+
this._update(this._pluginsAtom, (plugins) => plugins.includes(plugin) ? plugins : [
|
|
619
|
+
...plugins,
|
|
620
|
+
plugin
|
|
621
|
+
]);
|
|
622
|
+
}
|
|
623
|
+
_removePlugin(id) {
|
|
624
|
+
log2("remove plugin", {
|
|
625
|
+
id
|
|
626
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 493, S: this });
|
|
627
|
+
this._update(this._pluginsAtom, (plugins) => plugins.filter((plugin) => plugin.meta.id !== id));
|
|
628
|
+
}
|
|
629
|
+
_addModule(module) {
|
|
630
|
+
log2("add module", {
|
|
631
|
+
id: module.id
|
|
632
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 499, S: this });
|
|
633
|
+
this._update(this._modulesAtom, (modules) => modules.includes(module) ? modules : [
|
|
634
|
+
...modules,
|
|
635
|
+
module
|
|
636
|
+
]);
|
|
637
|
+
}
|
|
638
|
+
_removeModule(id) {
|
|
639
|
+
log2("remove module", {
|
|
640
|
+
id
|
|
641
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 509, S: this });
|
|
642
|
+
this._update(this._modulesAtom, (modules) => modules.filter((module) => module.id !== id));
|
|
643
|
+
}
|
|
644
|
+
//
|
|
645
|
+
// Activation helpers
|
|
646
|
+
//
|
|
647
|
+
_activateEvent(key, params, fiber) {
|
|
648
|
+
return Effect2.gen(this, function* () {
|
|
649
|
+
yield* this._trackFiber(this._inFlightFibers, fiber);
|
|
650
|
+
log2("activating", {
|
|
651
|
+
key,
|
|
652
|
+
...params
|
|
653
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 520, S: this });
|
|
654
|
+
yield* Ref.update(this._activatingEvents, (activating) => Array.append(activating, key));
|
|
655
|
+
this._clearPendingReset(key);
|
|
656
|
+
const activatingEvents = yield* this._activatingEvents;
|
|
657
|
+
const activatingModules = yield* this._activatingModules;
|
|
658
|
+
const modules = this._getModulesForActivation(key, activatingEvents, activatingModules);
|
|
659
|
+
if (modules.length === 0) {
|
|
660
|
+
log2("no modules to activate", {
|
|
661
|
+
key
|
|
662
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 530, S: this });
|
|
663
|
+
if (!this._get(this._eventsFiredAtom).includes(key)) {
|
|
664
|
+
this._update(this._eventsFiredAtom, (events) => [
|
|
665
|
+
...events,
|
|
666
|
+
key
|
|
667
|
+
]);
|
|
668
|
+
}
|
|
669
|
+
return false;
|
|
670
|
+
}
|
|
671
|
+
return yield* this._activateModulesForEvent(key, modules, activatingEvents);
|
|
672
|
+
}).pipe(Effect2.ensuring(Effect2.all([
|
|
673
|
+
this._untrackFiber(this._inFlightFibers, fiber),
|
|
674
|
+
Ref.update(this._activatingEvents, (activating) => Array.filter(activating, (event) => event !== key))
|
|
675
|
+
])));
|
|
676
|
+
}
|
|
677
|
+
_activateModulesForEvent(key, modules, activatingEvents) {
|
|
678
|
+
const activatingModuleIds = modules.map((module) => module.id);
|
|
679
|
+
return Effect2.gen(this, function* () {
|
|
680
|
+
yield* Ref.update(this._activatingModules, (activating) => Array.appendAll(activating, activatingModuleIds));
|
|
681
|
+
log2("activating modules", {
|
|
682
|
+
key,
|
|
683
|
+
modules: activatingModuleIds
|
|
684
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 551, S: this });
|
|
685
|
+
performance.mark(`event:${key}:start`);
|
|
686
|
+
yield* PubSub.publish(this.activation, {
|
|
687
|
+
event: key,
|
|
688
|
+
state: "activating"
|
|
689
|
+
});
|
|
690
|
+
yield* this._activateRelatedEvents(key, this._getBeforeEvents(modules, activatingEvents), "before");
|
|
691
|
+
const capabilities = yield* this._loadCapabilitiesForModules(key, modules);
|
|
692
|
+
yield* this._contributeCapabilitiesForModules(modules, capabilities);
|
|
693
|
+
yield* this._activateRelatedEvents(key, this._getAfterEvents(modules, activatingEvents), "after");
|
|
694
|
+
if (!this._get(this._eventsFiredAtom).includes(key)) {
|
|
695
|
+
this._update(this._eventsFiredAtom, (events) => [
|
|
696
|
+
...events,
|
|
697
|
+
key
|
|
698
|
+
]);
|
|
699
|
+
}
|
|
700
|
+
performance.mark(`event:${key}:end`);
|
|
701
|
+
performance.measure(`event:${key}`, `event:${key}:start`, `event:${key}:end`);
|
|
702
|
+
yield* PubSub.publish(this.activation, {
|
|
703
|
+
event: key,
|
|
704
|
+
state: "activated"
|
|
705
|
+
});
|
|
706
|
+
log2("activated", {
|
|
707
|
+
key
|
|
708
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 576, S: this });
|
|
709
|
+
return true;
|
|
710
|
+
}).pipe(Effect2.ensuring(Ref.update(this._activatingModules, (activating) => Array.filter(activating, (module) => !activatingModuleIds.includes(module)))));
|
|
711
|
+
}
|
|
712
|
+
_getModulesForActivation(key, activatingEvents, activatingModules) {
|
|
713
|
+
return this._getInactiveModulesByEvent(key).filter((module) => {
|
|
714
|
+
const allOf = isAllOf(module.activatesOn);
|
|
715
|
+
if (!allOf) {
|
|
716
|
+
return true;
|
|
717
|
+
}
|
|
718
|
+
const events = getEvents(module.activatesOn).filter((event) => eventKey(event) !== key);
|
|
719
|
+
return events.every((event) => this._get(this._eventsFiredAtom).includes(eventKey(event)) || activatingEvents.includes(eventKey(event))) && !activatingModules.includes(module.id);
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
_getBeforeEvents(modules, activatingEvents) {
|
|
723
|
+
return Function.pipe(modules, Array.flatMap((module) => module.firesBeforeActivation ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event) => !activatingEvents.includes(eventKey(event))));
|
|
724
|
+
}
|
|
725
|
+
_getAfterEvents(modules, activatingEvents) {
|
|
726
|
+
return Function.pipe(modules, Array.flatMap((module) => module.firesAfterActivation ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event) => !activatingEvents.includes(eventKey(event))));
|
|
727
|
+
}
|
|
728
|
+
_activateRelatedEvents(key, events, phase) {
|
|
729
|
+
const logLabel = phase === "before" ? "firesBeforeActivation" : "firesAfterActivation";
|
|
730
|
+
const eventKey2 = phase === "before" ? "beforeEvents" : "afterEvents";
|
|
731
|
+
return Function.pipe(events, Array.map((event) => this.activate(event, phase === "before" ? {
|
|
732
|
+
before: key
|
|
733
|
+
} : {
|
|
734
|
+
after: key
|
|
735
|
+
})), Effect2.allWith({
|
|
736
|
+
concurrency: "unbounded"
|
|
737
|
+
}), together(Effect2.sleep(Duration.seconds(10)).pipe(Effect2.andThen(Effect2.sync(() => log2.warn(`${logLabel} is taking a long time`, {
|
|
738
|
+
event: key,
|
|
739
|
+
[eventKey2]: events.map(eventKey)
|
|
740
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 609, S: this }))))), Effect2.asVoid);
|
|
741
|
+
}
|
|
742
|
+
//
|
|
743
|
+
// Module lifecycle helpers
|
|
744
|
+
//
|
|
745
|
+
_loadCapabilitiesForModules(key, modules) {
|
|
746
|
+
return Function.pipe(modules, Array.map((mod) => this._loadModule(mod, key)), Effect2.allWith({
|
|
747
|
+
concurrency: "unbounded"
|
|
748
|
+
}), Effect2.catchAll((error) => {
|
|
749
|
+
return Effect2.gen(this, function* () {
|
|
750
|
+
yield* PubSub.publish(this.activation, {
|
|
751
|
+
event: key,
|
|
752
|
+
state: "error",
|
|
753
|
+
error
|
|
754
|
+
});
|
|
755
|
+
return yield* Effect2.fail(error);
|
|
756
|
+
});
|
|
757
|
+
}));
|
|
758
|
+
}
|
|
759
|
+
_contributeCapabilitiesForModules(modules, capabilities) {
|
|
760
|
+
return Function.pipe(
|
|
761
|
+
modules,
|
|
762
|
+
Array.zip(capabilities),
|
|
763
|
+
Array.map(([module, capabilitySet]) => this._contributeCapabilities(module, capabilitySet)),
|
|
764
|
+
Effect2.all,
|
|
765
|
+
Effect2.asVoid
|
|
766
|
+
);
|
|
767
|
+
}
|
|
768
|
+
_getModuleSemaphore(moduleId) {
|
|
769
|
+
let semaphore = this._moduleSemaphores.get(moduleId);
|
|
770
|
+
if (!semaphore) {
|
|
771
|
+
semaphore = Effect2.runSync(Effect2.makeSemaphore(1));
|
|
772
|
+
this._moduleSemaphores.set(moduleId, semaphore);
|
|
773
|
+
}
|
|
774
|
+
return semaphore;
|
|
775
|
+
}
|
|
776
|
+
// `parentEvent` is the activation event that first triggered this module
|
|
777
|
+
// load — included in `activating`/`activated` PubSub messages so subscribers
|
|
778
|
+
// (e.g. the boot loader's status listener) can associate a module with its
|
|
779
|
+
// triggering event in the trace. The same module may be referenced by
|
|
780
|
+
// multiple events, but module loads are memoized via `_moduleMemoMap`, so
|
|
781
|
+
// only the first event to need it will appear here; later events await the
|
|
782
|
+
// cached deferred without re-publishing.
|
|
783
|
+
_loadModule = (module, parentEvent) => Effect2.gen(this, function* () {
|
|
784
|
+
const semaphore = this._getModuleSemaphore(module.id);
|
|
785
|
+
const deferredToAwait = yield* Effect2.gen(this, function* () {
|
|
786
|
+
const existing = this._moduleMemoMap.get(module.id);
|
|
787
|
+
if (existing) {
|
|
788
|
+
return existing;
|
|
789
|
+
}
|
|
790
|
+
const deferred = yield* Deferred2.make();
|
|
791
|
+
this._moduleMemoMap.set(module.id, deferred);
|
|
792
|
+
const loadEffect = Effect2.gen(this, function* () {
|
|
793
|
+
log2("loading module", {
|
|
794
|
+
module: module.id,
|
|
795
|
+
parentEvent
|
|
796
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 667, S: this });
|
|
797
|
+
performance.mark(`module:${module.id}:start`);
|
|
798
|
+
yield* PubSub.publish(this.activation, {
|
|
799
|
+
event: parentEvent,
|
|
800
|
+
state: "activating",
|
|
801
|
+
module: module.id
|
|
802
|
+
});
|
|
803
|
+
const [duration, capabilities] = yield* module.activate().pipe(Effect2.provideService(Service, this.capabilities), Effect2.provideService(Service2, this), Effect2.timed);
|
|
804
|
+
const normalized = capabilities == null ? [] : Array.isArray(capabilities) ? capabilities : [
|
|
805
|
+
capabilities
|
|
806
|
+
];
|
|
807
|
+
const elapsed = Duration.toMillis(duration);
|
|
808
|
+
performance.mark(`module:${module.id}:end`);
|
|
809
|
+
performance.measure(`module:${module.id}`, `module:${module.id}:start`, `module:${module.id}:end`);
|
|
810
|
+
yield* PubSub.publish(this.activation, {
|
|
811
|
+
event: parentEvent,
|
|
812
|
+
state: "activated",
|
|
813
|
+
module: module.id
|
|
814
|
+
});
|
|
815
|
+
log2("loaded module", {
|
|
816
|
+
module: module.id,
|
|
817
|
+
parentEvent,
|
|
818
|
+
elapsed,
|
|
819
|
+
failed: false
|
|
820
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 689, S: this });
|
|
821
|
+
return normalized;
|
|
822
|
+
}).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`, {
|
|
823
|
+
module: module.id
|
|
824
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 696, S: this }))))), Performance.addTrackEntry({
|
|
825
|
+
name: module.id,
|
|
826
|
+
devtools: {
|
|
827
|
+
dataType: "track-entry",
|
|
828
|
+
track: "Module Activation",
|
|
829
|
+
trackGroup: "Composer",
|
|
830
|
+
color: "primary"
|
|
831
|
+
}
|
|
832
|
+
}));
|
|
833
|
+
const fiber = yield* Effect2.forkDaemon(loadEffect.pipe(Effect2.tap((result) => Deferred2.succeed(deferred, result)), Effect2.catchAllCause((cause) => {
|
|
834
|
+
const error = Cause.squash(cause);
|
|
835
|
+
log2.error("module failed to activate", {
|
|
836
|
+
module: module.id,
|
|
837
|
+
error: error instanceof Error ? error.message : String(error),
|
|
838
|
+
stack: error instanceof Error ? error.stack : void 0,
|
|
839
|
+
isDefect: !Cause.isFailure(cause)
|
|
840
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 710, S: this });
|
|
841
|
+
return Deferred2.fail(deferred, error instanceof Error ? error : new Error(String(error)));
|
|
842
|
+
})));
|
|
843
|
+
yield* this._trackFiber(this._inFlightFibers, fiber);
|
|
844
|
+
yield* Effect2.forkDaemon(Fiber.await(fiber).pipe(Effect2.andThen(() => this._untrackFiber(this._inFlightFibers, fiber))));
|
|
845
|
+
return deferred;
|
|
846
|
+
}).pipe(semaphore.withPermits(1));
|
|
847
|
+
return yield* Deferred2.await(deferredToAwait);
|
|
848
|
+
});
|
|
849
|
+
_contributeCapabilities(module, capabilities) {
|
|
850
|
+
return Effect2.gen(this, function* () {
|
|
851
|
+
capabilities.forEach((capability) => {
|
|
852
|
+
this.capabilities.contribute({
|
|
853
|
+
module: module.id,
|
|
854
|
+
...capability
|
|
855
|
+
});
|
|
856
|
+
});
|
|
857
|
+
this._update(this._activeAtom, (active) => [
|
|
858
|
+
...active,
|
|
859
|
+
module.id
|
|
860
|
+
]);
|
|
861
|
+
this._capabilities.set(module.id, capabilities);
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
_deactivateModule(module) {
|
|
865
|
+
return Effect2.gen(this, function* () {
|
|
866
|
+
const id = module.id;
|
|
867
|
+
log2("deactivating", {
|
|
868
|
+
id
|
|
869
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 743, S: this });
|
|
870
|
+
this._moduleMemoMap.delete(id);
|
|
871
|
+
const capabilities = this._capabilities.get(id);
|
|
872
|
+
if (capabilities) {
|
|
873
|
+
for (const capability of capabilities) {
|
|
874
|
+
this.capabilities.remove(capability.interface, capability.implementation);
|
|
875
|
+
const program = capability.deactivate?.() ?? Effect2.succeed(void 0);
|
|
876
|
+
yield* program;
|
|
877
|
+
}
|
|
878
|
+
this._capabilities.delete(id);
|
|
879
|
+
}
|
|
880
|
+
const activeIndex = this._get(this._activeAtom).findIndex((event) => event === id);
|
|
881
|
+
if (activeIndex !== -1) {
|
|
882
|
+
this._update(this._activeAtom, (active) => active.filter((event) => event !== id));
|
|
883
|
+
}
|
|
884
|
+
log2("deactivated", {
|
|
885
|
+
id
|
|
886
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 760, S: this });
|
|
887
|
+
return true;
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
};
|
|
891
|
+
var make5 = (options) => new ManagerImpl(options);
|
|
892
|
+
var together = (togetherEffect) => (effect) => Effect2.gen(function* () {
|
|
893
|
+
const togetherFiber = yield* Effect2.fork(togetherEffect);
|
|
894
|
+
const result = yield* effect;
|
|
895
|
+
yield* Fiber.interrupt(togetherFiber);
|
|
896
|
+
return result;
|
|
897
|
+
});
|
|
898
|
+
|
|
899
|
+
export {
|
|
900
|
+
capability_manager_exports,
|
|
901
|
+
PluginInitializationError,
|
|
902
|
+
ManagerTypeId,
|
|
903
|
+
isManager,
|
|
904
|
+
make5 as make,
|
|
905
|
+
plugin_manager_exports
|
|
906
|
+
};
|
|
907
|
+
//# sourceMappingURL=chunk-3ZS2A3DN.mjs.map
|