@dxos/app-framework 0.8.4-main.dedc0f3 → 0.8.4-main.dfabb4ec29
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 +9 -0
- package/.storybook/preview.mts +8 -0
- package/dist/lib/browser/capability-5RRH3WIB.mjs +35 -0
- package/dist/lib/browser/capability-5RRH3WIB.mjs.map +7 -0
- package/dist/lib/browser/capability-LUKGKUQH.mjs +38 -0
- package/dist/lib/browser/capability-LUKGKUQH.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-45CHLTBV.mjs +34 -0
- package/dist/lib/browser/chunk-45CHLTBV.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-7VZJR2OA.mjs +581 -0
- package/dist/lib/browser/chunk-7VZJR2OA.mjs.map +7 -0
- package/dist/lib/browser/chunk-CZ4BIAHH.mjs +422 -0
- package/dist/lib/browser/chunk-CZ4BIAHH.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-FO3IYSLV.mjs +68 -0
- package/dist/lib/browser/chunk-FO3IYSLV.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-JD3Z5NEF.mjs +469 -0
- package/dist/lib/browser/chunk-JD3Z5NEF.mjs.map +7 -0
- package/dist/lib/browser/chunk-NBXPP7JR.mjs +1174 -0
- package/dist/lib/browser/chunk-NBXPP7JR.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 +76 -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/capability.mjs +30 -0
- package/dist/lib/browser/core/capability.mjs.map +7 -0
- package/dist/lib/browser/core/plugin-manager.mjs +19 -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 +24 -0
- package/dist/lib/browser/core/url-loader.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +108 -162
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/invoker-capability-K4GHUFXF.mjs +44 -0
- package/dist/lib/browser/invoker-capability-K4GHUFXF.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +235 -48
- 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-FCGZVIEG.mjs +39 -0
- package/dist/lib/node-esm/capability-FCGZVIEG.mjs.map +7 -0
- package/dist/lib/node-esm/capability-JOIQ2MQE.mjs +36 -0
- package/dist/lib/node-esm/capability-JOIQ2MQE.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-DRZKO5UZ.mjs +470 -0
- package/dist/lib/node-esm/chunk-DRZKO5UZ.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-M3HKPRPO.mjs +423 -0
- package/dist/lib/node-esm/chunk-M3HKPRPO.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-MUVUQC3G.mjs +1175 -0
- package/dist/lib/node-esm/chunk-MUVUQC3G.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-V24UWT36.mjs +582 -0
- package/dist/lib/node-esm/chunk-V24UWT36.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-WK7OIQKI.mjs +70 -0
- package/dist/lib/node-esm/chunk-WK7OIQKI.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 +77 -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 +20 -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 +25 -0
- package/dist/lib/node-esm/core/url-loader.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +108 -162
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/invoker-capability-XEPW5LMJ.mjs +45 -0
- package/dist/lib/node-esm/invoker-capability-XEPW5LMJ.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +235 -48
- 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 +893 -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/annotations.d.ts +1 -0
- package/dist/types/src/common/annotations.d.ts.map +1 -0
- package/dist/types/src/common/capabilities.d.ts +110 -190
- 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/edge-registry-plugin-provider.d.ts +30 -0
- package/dist/types/src/core/edge-registry-plugin-provider.d.ts.map +1 -0
- package/dist/types/src/core/index.d.ts +11 -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 +239 -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 +101 -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 +208 -37
- package/dist/types/src/core/plugin.d.ts.map +1 -1
- package/dist/types/src/core/registry.d.ts +101 -0
- package/dist/types/src/core/registry.d.ts.map +1 -0
- package/dist/types/src/core/url-loader.d.ts +127 -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 +8 -9
- 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 -4
- 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 -2
- 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 +89 -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 +2 -0
- package/dist/types/src/vite-plugin/boot-loader/index.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/boot-loader/loader.d.ts +51 -0
- package/dist/types/src/vite-plugin/boot-loader/loader.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 +41 -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 +26 -3
- package/package.json +114 -54
- package/src/cli/cli.ts +107 -0
- package/src/{playground/logger → cli}/index.ts +1 -1
- package/src/common/activation-events.ts +44 -0
- package/src/{components/index.ts → common/annotations.ts} +0 -2
- package/src/common/capabilities.ts +169 -195
- 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/edge-registry-plugin-provider.ts +92 -0
- package/src/core/index.ts +11 -4
- package/src/core/plugin-asset-cache.ts +60 -0
- package/src/core/plugin-manager.test.ts +1671 -0
- package/src/core/plugin-manager.ts +1335 -0
- package/src/core/plugin-manifest.test.ts +75 -0
- package/src/core/plugin-manifest.ts +134 -0
- package/src/core/plugin.ts +369 -43
- package/src/core/registry.ts +157 -0
- package/src/core/url-loader.test.ts +221 -0
- package/src/core/url-loader.ts +388 -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 +12 -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/plugin-runtime/index.ts +5 -0
- package/src/plugin-runtime/meta.ts +12 -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 +9 -10
- package/src/testing/withPluginManager.tsx +74 -50
- package/src/ui/components/App/App.stories.tsx +88 -0
- package/src/ui/components/App/App.tsx +81 -0
- package/src/{playground/layout → 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/debug → 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 +106 -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 +424 -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 +270 -0
- package/src/vite-plugin/boot-loader/boot-loader.css +320 -0
- package/src/vite-plugin/boot-loader/boot-loader.js +325 -0
- package/src/vite-plugin/boot-loader/index.ts +5 -0
- package/src/vite-plugin/boot-loader/loader.ts +123 -0
- package/src/vite-plugin/composer/index.ts +306 -0
- package/src/vite-plugin/import-map/index.ts +527 -0
- package/src/vite-plugin/index.ts +10 -0
- package/src/vite-plugin/manifest.test.ts +46 -0
- package/src/vite-plugin/manifest.ts +57 -0
- package/src/vite-plugin/packages.ts +187 -0
- package/tsconfig.json +24 -15
- package/tsconfig.node.json +2 -4
- package/typedoc.json +2 -4
- package/vitest.config.ts +8 -6
- 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-AFFC6VB2.mjs +0 -137
- package/dist/lib/browser/app-graph-builder-AFFC6VB2.mjs.map +0 -7
- package/dist/lib/browser/chunk-ORWHM7CO.mjs +0 -32
- package/dist/lib/browser/chunk-ORWHM7CO.mjs.map +0 -7
- package/dist/lib/browser/chunk-OZY7HV2A.mjs +0 -1643
- package/dist/lib/browser/chunk-OZY7HV2A.mjs.map +0 -7
- package/dist/lib/browser/chunk-T6M7JB7M.mjs +0 -471
- package/dist/lib/browser/chunk-T6M7JB7M.mjs.map +0 -7
- package/dist/lib/browser/intent-dispatcher-QG7UPGQX.mjs +0 -11
- package/dist/lib/browser/intent-resolver-4S4PSTM5.mjs +0 -39
- package/dist/lib/browser/intent-resolver-4S4PSTM5.mjs.map +0 -7
- package/dist/lib/browser/store-6E33KLGK.mjs +0 -30
- package/dist/lib/browser/store-6E33KLGK.mjs.map +0 -7
- package/dist/lib/browser/worker.mjs +0 -85
- package/dist/lib/node-esm/app-graph-builder-S4OAULX5.mjs +0 -138
- package/dist/lib/node-esm/app-graph-builder-S4OAULX5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-F63ZRXMK.mjs +0 -1645
- package/dist/lib/node-esm/chunk-F63ZRXMK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HJFU7QOR.mjs +0 -472
- package/dist/lib/node-esm/chunk-HJFU7QOR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UMZQERLE.mjs +0 -34
- package/dist/lib/node-esm/chunk-UMZQERLE.mjs.map +0 -7
- package/dist/lib/node-esm/intent-dispatcher-NXBGPJOX.mjs +0 -12
- package/dist/lib/node-esm/intent-resolver-2ZKXI5ET.mjs +0 -40
- package/dist/lib/node-esm/intent-resolver-2ZKXI5ET.mjs.map +0 -7
- package/dist/lib/node-esm/store-QQUTQHHT.mjs +0 -31
- package/dist/lib/node-esm/store-QQUTQHHT.mjs.map +0 -7
- package/dist/lib/node-esm/worker.mjs +0 -86
- 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 -281
- package/dist/types/src/common/layout.d.ts.map +0 -1
- package/dist/types/src/common/surface.d.ts +0 -65
- 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 -38
- 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-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 -27
- 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/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 -10
- 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 -18
- 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 -278
- package/src/common/surface.ts +0 -86
- package/src/components/App.stories.tsx +0 -35
- package/src/components/App.tsx +0 -59
- package/src/components/DefaultFallback.tsx +0 -26
- package/src/components/useApp.tsx +0 -166
- 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 -17
- 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 -23
- package/src/playground/layout/Layout.tsx +0 -33
- package/src/playground/layout/plugin.ts +0 -17
- package/src/playground/logger/Toolbar.tsx +0 -30
- package/src/playground/logger/plugin.ts +0 -37
- package/src/playground/logger/schema.ts +0 -12
- package/src/playground/playground.stories.tsx +0 -47
- package/src/plugin-intent/IntentPlugin.ts +0 -21
- package/src/plugin-intent/actions.ts +0 -33
- package/src/plugin-intent/errors.ts +0 -39
- 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 -335
- package/src/plugin-intent/intent.ts +0 -154
- package/src/plugin-settings/SettingsPlugin.ts +0 -36
- package/src/plugin-settings/actions.ts +0 -29
- package/src/plugin-settings/app-graph-builder.ts +0 -158
- package/src/plugin-settings/index.ts +0 -6
- package/src/plugin-settings/intent-resolver.ts +0 -35
- 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 -104
- package/src/react/Surface.tsx +0 -78
- 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/{node-esm/worker.mjs.map → browser/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{node-esm/intent-dispatcher-NXBGPJOX.mjs.map → browser/common/activation-events.mjs.map} +0 -0
- /package/dist/lib/browser/{worker.mjs.map → common/capabilities.mjs.map} +0 -0
- /package/dist/lib/browser/{intent-dispatcher-QG7UPGQX.mjs.map → core/activation-event.mjs.map} +0 -0
|
@@ -0,0 +1,1174 @@
|
|
|
1
|
+
import {
|
|
2
|
+
eventKey,
|
|
3
|
+
getEvents,
|
|
4
|
+
isAllOf
|
|
5
|
+
} from "./chunk-66IXTIVK.mjs";
|
|
6
|
+
import {
|
|
7
|
+
LazyPluginError,
|
|
8
|
+
Service as Service2,
|
|
9
|
+
isLazy,
|
|
10
|
+
resolveLazy
|
|
11
|
+
} from "./chunk-Z55LVAGN.mjs";
|
|
12
|
+
import {
|
|
13
|
+
Service
|
|
14
|
+
} from "./chunk-3JWJXGLK.mjs";
|
|
15
|
+
import {
|
|
16
|
+
__export
|
|
17
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
18
|
+
|
|
19
|
+
// src/core/plugin-manager.ts
|
|
20
|
+
var plugin_manager_exports = {};
|
|
21
|
+
__export(plugin_manager_exports, {
|
|
22
|
+
ManagerTypeId: () => ManagerTypeId,
|
|
23
|
+
PluginInitializationError: () => PluginInitializationError,
|
|
24
|
+
PluginTimeoutError: () => PluginTimeoutError,
|
|
25
|
+
isManager: () => isManager,
|
|
26
|
+
make: () => make5
|
|
27
|
+
});
|
|
28
|
+
import { Atom as Atom3, Registry } from "@effect-atom/atom-react";
|
|
29
|
+
import * as Array from "effect/Array";
|
|
30
|
+
import * as Cause from "effect/Cause";
|
|
31
|
+
import * as Deferred2 from "effect/Deferred";
|
|
32
|
+
import * as Duration from "effect/Duration";
|
|
33
|
+
import * as Effect3 from "effect/Effect";
|
|
34
|
+
import * as Fiber from "effect/Fiber";
|
|
35
|
+
import * as Function from "effect/Function";
|
|
36
|
+
import * as HashSet from "effect/HashSet";
|
|
37
|
+
import * as PubSub from "effect/PubSub";
|
|
38
|
+
import * as Ref from "effect/Ref";
|
|
39
|
+
import { runAndForwardErrors as runAndForwardErrors2 } from "@dxos/effect";
|
|
40
|
+
import { Performance } from "@dxos/effect";
|
|
41
|
+
import { BaseError } from "@dxos/errors";
|
|
42
|
+
import { log as log3 } from "@dxos/log";
|
|
43
|
+
|
|
44
|
+
// src/core/capability-manager.ts
|
|
45
|
+
var capability_manager_exports = {};
|
|
46
|
+
__export(capability_manager_exports, {
|
|
47
|
+
make: () => make2
|
|
48
|
+
});
|
|
49
|
+
import { Atom } from "@effect-atom/atom-react";
|
|
50
|
+
import * as Deferred from "effect/Deferred";
|
|
51
|
+
import * as Effect from "effect/Effect";
|
|
52
|
+
import { invariant } from "@dxos/invariant";
|
|
53
|
+
import { log } from "@dxos/log";
|
|
54
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/capability-manager.ts";
|
|
55
|
+
var CapabilityManagerImpl = class {
|
|
56
|
+
_registry;
|
|
57
|
+
_capabilityEntries = Atom.family(() => {
|
|
58
|
+
return Atom.make([]).pipe(Atom.keepAlive);
|
|
59
|
+
});
|
|
60
|
+
_capabilities = Atom.family((id) => {
|
|
61
|
+
return Atom.make((get2) => {
|
|
62
|
+
const current = get2(this._capabilityEntries(id));
|
|
63
|
+
return current.map((c) => c.implementation);
|
|
64
|
+
}).pipe(Atom.keepAlive);
|
|
65
|
+
});
|
|
66
|
+
_capabilitiesByModule = Atom.family((id) => {
|
|
67
|
+
return Atom.make((get2) => {
|
|
68
|
+
const entries = get2(this._capabilityEntries(id));
|
|
69
|
+
const result = {};
|
|
70
|
+
for (const entry of entries) {
|
|
71
|
+
(result[entry.moduleId] ??= []).push(entry.implementation);
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}).pipe(Atom.keepAlive);
|
|
75
|
+
});
|
|
76
|
+
_capability = Atom.family((id) => {
|
|
77
|
+
return Atom.make((get2) => {
|
|
78
|
+
const current = get2(this._capabilities(id));
|
|
79
|
+
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}`"] });
|
|
80
|
+
return current[0];
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
constructor({ registry }) {
|
|
84
|
+
this._registry = registry;
|
|
85
|
+
}
|
|
86
|
+
contribute({ module: moduleId, interface: interfaceDef, implementation }) {
|
|
87
|
+
const current = this._registry.get(this._capabilityEntries(interfaceDef.identifier));
|
|
88
|
+
const isDuplicate = current.some((c) => c.moduleId === moduleId && c.implementation === implementation);
|
|
89
|
+
if (isDuplicate) {
|
|
90
|
+
log("capability already contributed, skipping", {
|
|
91
|
+
id: interfaceDef.identifier,
|
|
92
|
+
moduleId
|
|
93
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 46, S: this });
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const entry = {
|
|
97
|
+
moduleId,
|
|
98
|
+
implementation
|
|
99
|
+
};
|
|
100
|
+
this._registry.set(this._capabilityEntries(interfaceDef.identifier), [
|
|
101
|
+
...current,
|
|
102
|
+
entry
|
|
103
|
+
]);
|
|
104
|
+
log("capability contributed", {
|
|
105
|
+
id: interfaceDef.identifier,
|
|
106
|
+
moduleId,
|
|
107
|
+
count: current.length
|
|
108
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 60, S: this });
|
|
109
|
+
}
|
|
110
|
+
remove(interfaceDef, implementation) {
|
|
111
|
+
const current = this._registry.get(this._capabilityEntries(interfaceDef.identifier));
|
|
112
|
+
if (current.length === 0) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const next = current.filter((c) => c.implementation !== implementation);
|
|
116
|
+
if (next.length !== current.length) {
|
|
117
|
+
this._registry.set(this._capabilityEntries(interfaceDef.identifier), next);
|
|
118
|
+
log("capability removed", {
|
|
119
|
+
id: interfaceDef.identifier,
|
|
120
|
+
count: current.length
|
|
121
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 74, S: this });
|
|
122
|
+
} else {
|
|
123
|
+
log.warn("capability not removed", {
|
|
124
|
+
id: interfaceDef.identifier
|
|
125
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 79, S: this });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
atom(interfaceDef) {
|
|
129
|
+
return this._capabilities(interfaceDef.identifier);
|
|
130
|
+
}
|
|
131
|
+
getAll(interfaceDef) {
|
|
132
|
+
return this._registry.get(this.atom(interfaceDef));
|
|
133
|
+
}
|
|
134
|
+
get(interfaceDef) {
|
|
135
|
+
const capabilities = this.getAll(interfaceDef);
|
|
136
|
+
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}`"] });
|
|
137
|
+
return capabilities[0];
|
|
138
|
+
}
|
|
139
|
+
waitFor(interfaceDef) {
|
|
140
|
+
return Effect.gen(this, function* () {
|
|
141
|
+
const [capability] = this.getAll(interfaceDef);
|
|
142
|
+
if (capability) {
|
|
143
|
+
return capability;
|
|
144
|
+
}
|
|
145
|
+
const deferred = yield* Deferred.make();
|
|
146
|
+
const cancel = this._registry.subscribe(this.atom(interfaceDef), (capabilities) => {
|
|
147
|
+
if (capabilities.length > 0) {
|
|
148
|
+
Effect.runSync(Deferred.succeed(deferred, capabilities[0]));
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
const result = yield* Deferred.await(deferred);
|
|
152
|
+
cancel();
|
|
153
|
+
return result;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
atomByModule(interfaceDef) {
|
|
157
|
+
return this._capabilitiesByModule(interfaceDef.identifier);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
var make2 = (options) => new CapabilityManagerImpl(options);
|
|
161
|
+
|
|
162
|
+
// src/core/registry.ts
|
|
163
|
+
var registry_exports = {};
|
|
164
|
+
__export(registry_exports, {
|
|
165
|
+
Manager: () => Manager
|
|
166
|
+
});
|
|
167
|
+
import { Atom as Atom2 } from "@effect-atom/atom-react";
|
|
168
|
+
import * as Effect2 from "effect/Effect";
|
|
169
|
+
import { runAndForwardErrors } from "@dxos/effect";
|
|
170
|
+
import { log as log2 } from "@dxos/log";
|
|
171
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/registry.ts";
|
|
172
|
+
var NULL_PROVIDER = {
|
|
173
|
+
listPlugins: () => Effect2.succeed([]),
|
|
174
|
+
listVersions: () => Effect2.fail(new Error("No plugin registry provider configured")),
|
|
175
|
+
getPlugin: () => Effect2.fail(new Error("No plugin registry provider configured"))
|
|
176
|
+
};
|
|
177
|
+
var Manager = class {
|
|
178
|
+
plugins;
|
|
179
|
+
#provider;
|
|
180
|
+
constructor(provider, atomRegistry) {
|
|
181
|
+
this.#provider = provider ?? NULL_PROVIDER;
|
|
182
|
+
const initialLoading = provider !== void 0;
|
|
183
|
+
this.plugins = Atom2.make({
|
|
184
|
+
entries: [],
|
|
185
|
+
loading: initialLoading,
|
|
186
|
+
error: null
|
|
187
|
+
}).pipe(Atom2.keepAlive);
|
|
188
|
+
if (provider !== void 0) {
|
|
189
|
+
void runAndForwardErrors(provider.listPlugins().pipe(Effect2.match({
|
|
190
|
+
onSuccess: (entries) => atomRegistry.set(this.plugins, {
|
|
191
|
+
entries,
|
|
192
|
+
loading: false,
|
|
193
|
+
error: null
|
|
194
|
+
}),
|
|
195
|
+
onFailure: (error) => {
|
|
196
|
+
log2.catch(error, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 49, S: this });
|
|
197
|
+
atomRegistry.set(this.plugins, {
|
|
198
|
+
entries: [],
|
|
199
|
+
loading: false,
|
|
200
|
+
error
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
})));
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/** Forwards to the underlying provider. */
|
|
207
|
+
listPlugins() {
|
|
208
|
+
return this.#provider.listPlugins();
|
|
209
|
+
}
|
|
210
|
+
/** Forwards to the underlying provider. */
|
|
211
|
+
listVersions(repo) {
|
|
212
|
+
return this.#provider.listVersions(repo);
|
|
213
|
+
}
|
|
214
|
+
/** Forwards to the underlying provider. */
|
|
215
|
+
getPlugin(repo, version) {
|
|
216
|
+
return this.#provider.getPlugin(repo, version);
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
// src/core/plugin-manager.ts
|
|
221
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/plugin-manager.ts";
|
|
222
|
+
var PluginInitializationError = class extends BaseError.extend("PluginInitializationError", "Plugin manager initialization failed") {
|
|
223
|
+
};
|
|
224
|
+
var PluginTimeoutError = class extends BaseError.extend("PluginTimeoutError", "Plugin operation timed out") {
|
|
225
|
+
};
|
|
226
|
+
var DEFAULT_LOAD_TIMEOUT = Duration.seconds(30);
|
|
227
|
+
var DEFAULT_ACTIVATION_TIMEOUT = Duration.seconds(30);
|
|
228
|
+
var ManagerTypeId = /* @__PURE__ */ Symbol.for("@dxos/app-framework/Manager");
|
|
229
|
+
var isManager = (value) => {
|
|
230
|
+
return typeof value === "object" && value !== null && ManagerTypeId in value;
|
|
231
|
+
};
|
|
232
|
+
var ManagerImpl = class {
|
|
233
|
+
[ManagerTypeId] = ManagerTypeId;
|
|
234
|
+
activation = Effect3.runSync(PubSub.unbounded());
|
|
235
|
+
capabilities;
|
|
236
|
+
registry;
|
|
237
|
+
pluginRegistry;
|
|
238
|
+
_pluginsAtom;
|
|
239
|
+
_coreAtom;
|
|
240
|
+
_enabledAtom;
|
|
241
|
+
_modulesAtom;
|
|
242
|
+
_activeAtom;
|
|
243
|
+
_eventsFiredAtom;
|
|
244
|
+
_pendingResetAtom;
|
|
245
|
+
_failedAtom;
|
|
246
|
+
_pluginLoader;
|
|
247
|
+
_onRemove;
|
|
248
|
+
_loadTimeout;
|
|
249
|
+
_activationTimeout;
|
|
250
|
+
_capabilities = /* @__PURE__ */ new Map();
|
|
251
|
+
_moduleMemoMap = /* @__PURE__ */ new Map();
|
|
252
|
+
_moduleSemaphores = /* @__PURE__ */ new Map();
|
|
253
|
+
// Coalesces concurrent `_resolveLazyPlugin` calls per plugin id. Without
|
|
254
|
+
// this, two callers entering `enable(id)` before the swap completes would
|
|
255
|
+
// each invoke `mod.default(options)` and produce distinct module objects,
|
|
256
|
+
// defeating `_addModule`'s reference-equality dedupe and racing the
|
|
257
|
+
// `_pluginsAtom` swap.
|
|
258
|
+
_resolvingPlugins = /* @__PURE__ */ new Map();
|
|
259
|
+
// Tracks dev-source plugins (loaded via a Vite dev server) keyed by id.
|
|
260
|
+
// When `shadow` is present, the entry has displaced an existing plugin —
|
|
261
|
+
// `remove` reinstates it and re-enables iff `wasEnabled`. Entries without a
|
|
262
|
+
// shadow are dev plugins with no underlying registry/builtin to restore.
|
|
263
|
+
// The atom mirrors the map's keys for UI subscribers (they don't need the
|
|
264
|
+
// shadow internals); the two stay in sync via {@link _markDev}/{@link _unmarkDev}.
|
|
265
|
+
_devPlugins = /* @__PURE__ */ new Map();
|
|
266
|
+
_devPluginIdsAtom;
|
|
267
|
+
_activatingEvents = Effect3.runSync(Ref.make([]));
|
|
268
|
+
_activatingModules = Effect3.runSync(Ref.make([]));
|
|
269
|
+
_inFlightFibers = Effect3.runSync(Ref.make([]));
|
|
270
|
+
_shutdownSemaphore = Effect3.runSync(Effect3.makeSemaphore(1));
|
|
271
|
+
_shuttingDown = Effect3.runSync(Ref.make(false));
|
|
272
|
+
// Tracks the constructor-launched core/enabled `enable()` calls so that
|
|
273
|
+
// `activate` can wait for module registration before dispatching events.
|
|
274
|
+
// Lazy plugins make `enable` asynchronous (a dynamic `import()` happens
|
|
275
|
+
// inside it), so without this synchronization an `activate` triggered
|
|
276
|
+
// immediately after `make` could fire on an empty module set. Failures
|
|
277
|
+
// are wrapped in `PluginInitializationError` so awaiters get a tagged
|
|
278
|
+
// error rather than the wide `Error` produced by the underlying chain.
|
|
279
|
+
_initialization = Effect3.runSync(Deferred2.make());
|
|
280
|
+
constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta }) => meta.id), enabled = [], registry, pluginRegistryProvider, onRemove, loadTimeout = DEFAULT_LOAD_TIMEOUT, activationTimeout = DEFAULT_ACTIVATION_TIMEOUT }) {
|
|
281
|
+
this.registry = registry ?? Registry.make();
|
|
282
|
+
this.capabilities = make2({
|
|
283
|
+
registry: this.registry
|
|
284
|
+
});
|
|
285
|
+
this.pluginRegistry = new Manager(pluginRegistryProvider, this.registry);
|
|
286
|
+
this._pluginLoader = pluginLoader;
|
|
287
|
+
this._onRemove = onRemove;
|
|
288
|
+
this._loadTimeout = loadTimeout;
|
|
289
|
+
this._activationTimeout = activationTimeout;
|
|
290
|
+
this._pluginsAtom = Atom3.make(plugins).pipe(Atom3.keepAlive);
|
|
291
|
+
this._coreAtom = Atom3.make(core).pipe(Atom3.keepAlive);
|
|
292
|
+
this._enabledAtom = Atom3.make(enabled).pipe(Atom3.keepAlive);
|
|
293
|
+
this._modulesAtom = Atom3.make([]).pipe(Atom3.keepAlive);
|
|
294
|
+
this._activeAtom = Atom3.make([]).pipe(Atom3.keepAlive);
|
|
295
|
+
this._eventsFiredAtom = Atom3.make([]).pipe(Atom3.keepAlive);
|
|
296
|
+
this._pendingResetAtom = Atom3.make([]).pipe(Atom3.keepAlive);
|
|
297
|
+
this._failedAtom = Atom3.make([]).pipe(Atom3.keepAlive);
|
|
298
|
+
this._devPluginIdsAtom = Atom3.make([]).pipe(Atom3.keepAlive);
|
|
299
|
+
plugins.forEach((plugin) => this._addPlugin(plugin));
|
|
300
|
+
const initialIds = [
|
|
301
|
+
.../* @__PURE__ */ new Set([
|
|
302
|
+
...core,
|
|
303
|
+
...enabled
|
|
304
|
+
])
|
|
305
|
+
];
|
|
306
|
+
void Effect3.all(initialIds.map((id) => this.enable(id))).pipe(Effect3.mapError((cause) => new PluginInitializationError({
|
|
307
|
+
cause
|
|
308
|
+
})), Effect3.tap(() => Deferred2.succeed(this._initialization, void 0)), Effect3.tapErrorCause((cause) => Deferred2.failCause(this._initialization, cause))).pipe(runAndForwardErrors2);
|
|
309
|
+
}
|
|
310
|
+
get plugins() {
|
|
311
|
+
return this._pluginsAtom;
|
|
312
|
+
}
|
|
313
|
+
get core() {
|
|
314
|
+
return this._coreAtom;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Ids of plugins that are currently enabled.
|
|
318
|
+
*/
|
|
319
|
+
get enabled() {
|
|
320
|
+
return this._enabledAtom;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Modules of plugins which are currently enabled.
|
|
324
|
+
*/
|
|
325
|
+
get modules() {
|
|
326
|
+
return this._modulesAtom;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Ids of modules which are currently active.
|
|
330
|
+
*/
|
|
331
|
+
get active() {
|
|
332
|
+
return this._activeAtom;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Ids of events which have been fired.
|
|
336
|
+
*/
|
|
337
|
+
get eventsFired() {
|
|
338
|
+
return this._eventsFiredAtom;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Ids of modules which are pending reset.
|
|
342
|
+
*/
|
|
343
|
+
get pendingReset() {
|
|
344
|
+
return this._pendingResetAtom;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Plugins that failed to load or activate.
|
|
348
|
+
*/
|
|
349
|
+
get failed() {
|
|
350
|
+
return this._failedAtom;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Ids of currently-registered plugins that came from a dev source.
|
|
354
|
+
*/
|
|
355
|
+
get devPluginIds() {
|
|
356
|
+
return this._devPluginIdsAtom;
|
|
357
|
+
}
|
|
358
|
+
getPlugins() {
|
|
359
|
+
return this._get(this._pluginsAtom);
|
|
360
|
+
}
|
|
361
|
+
getCore() {
|
|
362
|
+
return this._get(this._coreAtom);
|
|
363
|
+
}
|
|
364
|
+
getEnabled() {
|
|
365
|
+
return this._get(this._enabledAtom);
|
|
366
|
+
}
|
|
367
|
+
getModules() {
|
|
368
|
+
return this._get(this._modulesAtom);
|
|
369
|
+
}
|
|
370
|
+
getActive() {
|
|
371
|
+
return this._get(this._activeAtom);
|
|
372
|
+
}
|
|
373
|
+
getEventsFired() {
|
|
374
|
+
return this._get(this._eventsFiredAtom);
|
|
375
|
+
}
|
|
376
|
+
getPendingReset() {
|
|
377
|
+
return this._get(this._pendingResetAtom);
|
|
378
|
+
}
|
|
379
|
+
getFailed() {
|
|
380
|
+
return this._get(this._failedAtom);
|
|
381
|
+
}
|
|
382
|
+
getDevPluginIds() {
|
|
383
|
+
return this._get(this._devPluginIdsAtom);
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Marks `id` as dev-sourced. If the plugin displaced an existing one, pass
|
|
387
|
+
* the shadow snapshot so `remove` can restore it. Repeat calls (e.g. a dev
|
|
388
|
+
* plugin reload) preserve the original shadow target — restoration always
|
|
389
|
+
* unwinds back to the real underlying plugin, never an intermediate dev build.
|
|
390
|
+
*/
|
|
391
|
+
_markDev(id, shadow) {
|
|
392
|
+
if (this._devPlugins.has(id)) {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
this._devPlugins.set(id, {
|
|
396
|
+
shadow
|
|
397
|
+
});
|
|
398
|
+
this._update(this._devPluginIdsAtom, (ids) => ids.includes(id) ? ids : [
|
|
399
|
+
...ids,
|
|
400
|
+
id
|
|
401
|
+
]);
|
|
402
|
+
}
|
|
403
|
+
/** Drops the dev-plugin entry and returns its shadow data (if any) for restoration. */
|
|
404
|
+
_unmarkDev(id) {
|
|
405
|
+
const entry = this._devPlugins.get(id);
|
|
406
|
+
this._devPlugins.delete(id);
|
|
407
|
+
this._update(this._devPluginIdsAtom, (ids) => ids.filter((existing) => existing !== id));
|
|
408
|
+
return entry?.shadow;
|
|
409
|
+
}
|
|
410
|
+
clearFailure(id) {
|
|
411
|
+
const current = this._get(this._failedAtom);
|
|
412
|
+
if (!current.some((failure) => failure.id === id)) {
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
this._set(this._failedAtom, current.filter((failure) => failure.id !== id));
|
|
416
|
+
return true;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Adds a plugin to the manager via the plugin loader.
|
|
420
|
+
* The plugin is registered but not enabled; call `enable` separately to activate it.
|
|
421
|
+
* @param id The id of the plugin.
|
|
422
|
+
*/
|
|
423
|
+
add(id) {
|
|
424
|
+
return Effect3.gen(this, function* () {
|
|
425
|
+
log3("add plugin", {
|
|
426
|
+
id
|
|
427
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 242, S: this });
|
|
428
|
+
const { plugin, dev = false } = yield* this._pluginLoader(id);
|
|
429
|
+
const pluginId = plugin.meta.id;
|
|
430
|
+
const existing = this._getPlugin(pluginId);
|
|
431
|
+
if (dev && existing && existing !== plugin) {
|
|
432
|
+
const wasEnabled = this._get(this._enabledAtom).includes(pluginId);
|
|
433
|
+
if (wasEnabled) {
|
|
434
|
+
yield* this.disable(pluginId);
|
|
435
|
+
}
|
|
436
|
+
this._markDev(pluginId, {
|
|
437
|
+
plugin: existing,
|
|
438
|
+
wasEnabled
|
|
439
|
+
});
|
|
440
|
+
this._update(this._pluginsAtom, (plugins) => plugins.map((p) => p.meta.id === pluginId ? plugin : p));
|
|
441
|
+
} else {
|
|
442
|
+
this._addPlugin(plugin);
|
|
443
|
+
if (dev) {
|
|
444
|
+
this._markDev(pluginId);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return plugin;
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Enables a plugin.
|
|
452
|
+
* @param id The id of the plugin.
|
|
453
|
+
*/
|
|
454
|
+
enable(id) {
|
|
455
|
+
return Effect3.gen(this, function* () {
|
|
456
|
+
log3("enable plugin", {
|
|
457
|
+
id
|
|
458
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 279, S: this });
|
|
459
|
+
const stub = this._getPlugin(id);
|
|
460
|
+
if (!stub) {
|
|
461
|
+
return false;
|
|
462
|
+
}
|
|
463
|
+
this.clearFailure(id);
|
|
464
|
+
const plugin = yield* this._resolveLazyPlugin(stub);
|
|
465
|
+
this._update(this._enabledAtom, (enabled) => enabled.includes(id) ? enabled : [
|
|
466
|
+
...enabled,
|
|
467
|
+
id
|
|
468
|
+
]);
|
|
469
|
+
plugin.modules.forEach((module) => {
|
|
470
|
+
this._addModule(module);
|
|
471
|
+
this._setPendingResetByModule(module);
|
|
472
|
+
});
|
|
473
|
+
log3("pending reset", {
|
|
474
|
+
events: [
|
|
475
|
+
...this.getPendingReset()
|
|
476
|
+
]
|
|
477
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 298, S: this });
|
|
478
|
+
yield* Effect3.all(this.getPendingReset().map((event) => this.activate(event)), {
|
|
479
|
+
concurrency: "unbounded"
|
|
480
|
+
});
|
|
481
|
+
return true;
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Resolves a lazy plugin stub (returned by {@link Plugin.lazy}) to its
|
|
486
|
+
* loaded form and swaps it into `_pluginsAtom`. Returns the input unchanged
|
|
487
|
+
* when the plugin is already resolved, so callers can `yield*` this
|
|
488
|
+
* unconditionally. The lazy stub carries `meta` synchronously but its
|
|
489
|
+
* `modules` list is empty until the loader resolves; the swap ensures
|
|
490
|
+
* subsequent enable/disable operations see the resolved plugin.
|
|
491
|
+
*
|
|
492
|
+
* Concurrent calls for the same id are coalesced via `_resolvingPlugins`:
|
|
493
|
+
* the first caller starts the resolution, every subsequent caller awaits
|
|
494
|
+
* the same `Deferred`. On failure we publish a `lazy:<id>` error message
|
|
495
|
+
* and skip the atom swap so the failure is observable to the activation
|
|
496
|
+
* subscriber and a retry can be attempted.
|
|
497
|
+
*/
|
|
498
|
+
_resolveLazyPlugin(plugin) {
|
|
499
|
+
return Effect3.gen(this, function* () {
|
|
500
|
+
if (!isLazy(plugin)) {
|
|
501
|
+
return plugin;
|
|
502
|
+
}
|
|
503
|
+
const id = plugin.meta.id;
|
|
504
|
+
const existing = this._resolvingPlugins.get(id);
|
|
505
|
+
if (existing) {
|
|
506
|
+
return yield* Deferred2.await(existing);
|
|
507
|
+
}
|
|
508
|
+
const deferred = yield* Deferred2.make();
|
|
509
|
+
this._resolvingPlugins.set(id, deferred);
|
|
510
|
+
return yield* Effect3.gen(this, function* () {
|
|
511
|
+
log3("resolving lazy plugin", {
|
|
512
|
+
id
|
|
513
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 335, S: this });
|
|
514
|
+
yield* PubSub.publish(this.activation, {
|
|
515
|
+
event: "",
|
|
516
|
+
state: "activating",
|
|
517
|
+
module: `lazy:${id}`
|
|
518
|
+
});
|
|
519
|
+
const resolvedPlugin = yield* resolveLazy(plugin).pipe(
|
|
520
|
+
// Cap how long a remote import can hang. Without this the host can
|
|
521
|
+
// sit on a pending dynamic `import()` indefinitely if the plugin's
|
|
522
|
+
// server is unreachable, which stalls every caller awaiting
|
|
523
|
+
// `enable(id)` and (transitively) the manager's initialization.
|
|
524
|
+
Effect3.timeoutFail({
|
|
525
|
+
duration: this._loadTimeout,
|
|
526
|
+
onTimeout: () => new LazyPluginError({
|
|
527
|
+
context: {
|
|
528
|
+
id,
|
|
529
|
+
reason: "load-failed"
|
|
530
|
+
},
|
|
531
|
+
cause: new PluginTimeoutError({
|
|
532
|
+
context: {
|
|
533
|
+
id,
|
|
534
|
+
phase: "load"
|
|
535
|
+
}
|
|
536
|
+
})
|
|
537
|
+
})
|
|
538
|
+
})
|
|
539
|
+
);
|
|
540
|
+
this._update(this._pluginsAtom, (plugins) => plugins.map((p) => p.meta.id === id ? resolvedPlugin : p));
|
|
541
|
+
yield* PubSub.publish(this.activation, {
|
|
542
|
+
event: "",
|
|
543
|
+
state: "activated",
|
|
544
|
+
module: `lazy:${id}`
|
|
545
|
+
});
|
|
546
|
+
return resolvedPlugin;
|
|
547
|
+
}).pipe(Effect3.tapError((error) => Effect3.gen(this, function* () {
|
|
548
|
+
yield* PubSub.publish(this.activation, {
|
|
549
|
+
event: "",
|
|
550
|
+
state: "error",
|
|
551
|
+
module: `lazy:${id}`,
|
|
552
|
+
error
|
|
553
|
+
});
|
|
554
|
+
this._recordFailure(id, "load", error);
|
|
555
|
+
this._scheduleAutoDisable(id);
|
|
556
|
+
})), Effect3.tap((value) => Deferred2.succeed(deferred, value)), Effect3.tapErrorCause((cause) => Deferred2.failCause(deferred, cause)), Effect3.ensuring(Effect3.sync(() => this._resolvingPlugins.delete(id))));
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Removes a plugin from the manager.
|
|
561
|
+
* @param id The id of the plugin.
|
|
562
|
+
*/
|
|
563
|
+
remove(id) {
|
|
564
|
+
return Effect3.gen(this, function* () {
|
|
565
|
+
log3("remove plugin", {
|
|
566
|
+
id
|
|
567
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 386, S: this });
|
|
568
|
+
const wasDev = this._devPlugins.has(id);
|
|
569
|
+
const disabled = yield* this.disable(id);
|
|
570
|
+
if (!disabled) {
|
|
571
|
+
return false;
|
|
572
|
+
}
|
|
573
|
+
this._removePlugin(id);
|
|
574
|
+
if (this._onRemove) {
|
|
575
|
+
this._runForkedFiber(this._onRemove(id).pipe(Effect3.tapError((error) => Effect3.sync(() => log3.warn("plugin remove hook failed", {
|
|
576
|
+
id,
|
|
577
|
+
error
|
|
578
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 396, S: this }))), Effect3.ignore));
|
|
579
|
+
}
|
|
580
|
+
if (wasDev) {
|
|
581
|
+
const shadow = this._unmarkDev(id);
|
|
582
|
+
if (shadow) {
|
|
583
|
+
this._addPlugin(shadow.plugin);
|
|
584
|
+
if (shadow.wasEnabled) {
|
|
585
|
+
yield* this.enable(id);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
return true;
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Disables a plugin.
|
|
594
|
+
* @param id The id of the plugin.
|
|
595
|
+
*/
|
|
596
|
+
disable(id) {
|
|
597
|
+
return Effect3.gen(this, function* () {
|
|
598
|
+
log3("disable plugin", {
|
|
599
|
+
id
|
|
600
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 423, S: this });
|
|
601
|
+
if (this._get(this._coreAtom).includes(id)) {
|
|
602
|
+
return false;
|
|
603
|
+
}
|
|
604
|
+
const plugin = this._getPlugin(id);
|
|
605
|
+
if (!plugin) {
|
|
606
|
+
return false;
|
|
607
|
+
}
|
|
608
|
+
const enabledIndex = this._get(this._enabledAtom).findIndex((enabled) => enabled === id);
|
|
609
|
+
if (enabledIndex !== -1) {
|
|
610
|
+
this._update(this._enabledAtom, (enabled) => enabled.filter((item) => item !== id));
|
|
611
|
+
yield* this.deactivate(id);
|
|
612
|
+
plugin.modules.forEach((module) => {
|
|
613
|
+
this._removeModule(module.id);
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
return true;
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Activates plugins based on the activation event.
|
|
621
|
+
* @param event The activation event.
|
|
622
|
+
* @returns Whether the activation was successful.
|
|
623
|
+
*/
|
|
624
|
+
activate(event, params) {
|
|
625
|
+
const key = typeof event === "string" ? event : eventKey(event);
|
|
626
|
+
return Effect3.gen(this, function* () {
|
|
627
|
+
if (yield* this._isShuttingDown()) {
|
|
628
|
+
log3("skipping activation during shutdown", {
|
|
629
|
+
key,
|
|
630
|
+
...params
|
|
631
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 452, S: this });
|
|
632
|
+
return false;
|
|
633
|
+
}
|
|
634
|
+
yield* Deferred2.await(this._initialization);
|
|
635
|
+
return yield* Effect3.withFiberRuntime((fiber) => this._activateEvent(key, params, fiber).pipe(together(Effect3.sleep(Duration.seconds(15)).pipe(Effect3.andThen(Effect3.sync(() => log3.warn("event activation is taking a long time", {
|
|
636
|
+
event: key
|
|
637
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 463, S: this }))))), Performance.addTrackEntry({
|
|
638
|
+
name: typeof event === "string" ? event : eventKey(event),
|
|
639
|
+
devtools: {
|
|
640
|
+
dataType: "track-entry",
|
|
641
|
+
track: "Event Activation",
|
|
642
|
+
trackGroup: "Composer",
|
|
643
|
+
color: "primary"
|
|
644
|
+
}
|
|
645
|
+
})));
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* Deactivates all of the modules for a plugin.
|
|
650
|
+
* @param id The id of the plugin.
|
|
651
|
+
* @returns Whether the deactivation was successful.
|
|
652
|
+
*/
|
|
653
|
+
deactivate(id) {
|
|
654
|
+
return Effect3.gen(this, function* () {
|
|
655
|
+
const plugin = this._getPlugin(id);
|
|
656
|
+
if (!plugin) {
|
|
657
|
+
return false;
|
|
658
|
+
}
|
|
659
|
+
const modules = plugin.modules;
|
|
660
|
+
const results = yield* Effect3.all(modules.map((module) => this._deactivateModule(module)), {
|
|
661
|
+
concurrency: "unbounded"
|
|
662
|
+
});
|
|
663
|
+
return results.every((result) => result);
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Re-activates the modules that were activated by the event.
|
|
668
|
+
* @param event The activation event.
|
|
669
|
+
* @returns Whether the reset was successful.
|
|
670
|
+
*/
|
|
671
|
+
reset(event) {
|
|
672
|
+
return Effect3.gen(this, function* () {
|
|
673
|
+
const key = typeof event === "string" ? event : eventKey(event);
|
|
674
|
+
log3("reset", {
|
|
675
|
+
key
|
|
676
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 500, S: this });
|
|
677
|
+
const modules = this._getActiveModulesByEvent(key);
|
|
678
|
+
const results = yield* Effect3.all(modules.map((module) => this._deactivateModule(module)), {
|
|
679
|
+
concurrency: "unbounded"
|
|
680
|
+
});
|
|
681
|
+
if (results.every((result) => result)) {
|
|
682
|
+
return yield* this.activate(key);
|
|
683
|
+
} else {
|
|
684
|
+
return false;
|
|
685
|
+
}
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
shutdown() {
|
|
689
|
+
return this._shutdownSemaphore.withPermits(1)(Effect3.gen(this, function* () {
|
|
690
|
+
yield* Ref.set(this._shuttingDown, true);
|
|
691
|
+
log3("shutdown", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 517, S: this });
|
|
692
|
+
yield* this._interruptInFlightActivations();
|
|
693
|
+
const activeIds = [
|
|
694
|
+
...this._get(this._activeAtom)
|
|
695
|
+
].reverse();
|
|
696
|
+
const allModules = this._get(this._modulesAtom);
|
|
697
|
+
const modulesToDeactivate = activeIds.map((id) => allModules.find((module) => module.id === id)).filter((module) => module != null);
|
|
698
|
+
for (const module of modulesToDeactivate) {
|
|
699
|
+
yield* this._deactivateModule(module);
|
|
700
|
+
}
|
|
701
|
+
this._set(this._eventsFiredAtom, []);
|
|
702
|
+
this._set(this._pendingResetAtom, []);
|
|
703
|
+
this._moduleMemoMap.clear();
|
|
704
|
+
yield* Ref.set(this._activatingEvents, []);
|
|
705
|
+
yield* Ref.set(this._activatingModules, []);
|
|
706
|
+
log3("shutdown complete", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 532, S: this });
|
|
707
|
+
return true;
|
|
708
|
+
}).pipe(Effect3.ensuring(Ref.set(this._shuttingDown, false))));
|
|
709
|
+
}
|
|
710
|
+
//
|
|
711
|
+
// State helpers
|
|
712
|
+
//
|
|
713
|
+
_get(atom) {
|
|
714
|
+
return this.registry.get(atom);
|
|
715
|
+
}
|
|
716
|
+
_set(atom, value) {
|
|
717
|
+
this.registry.set(atom, value);
|
|
718
|
+
}
|
|
719
|
+
_update(atom, updater) {
|
|
720
|
+
this._set(atom, updater(this._get(atom)));
|
|
721
|
+
}
|
|
722
|
+
_isShuttingDown() {
|
|
723
|
+
return Ref.get(this._shuttingDown);
|
|
724
|
+
}
|
|
725
|
+
_getPlugin(id) {
|
|
726
|
+
return this._get(this._pluginsAtom).find((plugin) => plugin.meta.id === id);
|
|
727
|
+
}
|
|
728
|
+
_getPluginIdForModule(moduleId) {
|
|
729
|
+
return this._get(this._pluginsAtom).find((plugin) => plugin.modules.some((module) => module.id === moduleId))?.meta.id;
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Records a failure for a plugin. Latest failure wins so the registry UI
|
|
733
|
+
* always sees the most recent reason. Walks the `cause` chain when checking
|
|
734
|
+
* for timeouts: lazy-load timeouts arrive wrapped in `LazyPluginError` (the
|
|
735
|
+
* timeout is the cause), but the operator-visible reason should still be
|
|
736
|
+
* `'timeout'`.
|
|
737
|
+
*/
|
|
738
|
+
_recordFailure(id, phase, error) {
|
|
739
|
+
const reason = isTimeoutCause(error) ? "timeout" : "error";
|
|
740
|
+
const failure = {
|
|
741
|
+
id,
|
|
742
|
+
phase,
|
|
743
|
+
reason,
|
|
744
|
+
error,
|
|
745
|
+
timestamp: Date.now()
|
|
746
|
+
};
|
|
747
|
+
log3.warn("plugin failed", {
|
|
748
|
+
id,
|
|
749
|
+
phase,
|
|
750
|
+
reason,
|
|
751
|
+
error: error.message
|
|
752
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 572, S: this });
|
|
753
|
+
this._update(this._failedAtom, (current) => [
|
|
754
|
+
...current.filter((entry) => entry.id !== id),
|
|
755
|
+
failure
|
|
756
|
+
]);
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Fire-and-forget disable of a failed plugin. Forked because a failure can
|
|
760
|
+
* happen mid-activation chain — yielding a `disable` inline would deadlock
|
|
761
|
+
* on the shared semaphores. Core plugins are skipped (the host opted into
|
|
762
|
+
* them being non-removable; the failure record is enough signal).
|
|
763
|
+
*/
|
|
764
|
+
_scheduleAutoDisable(id) {
|
|
765
|
+
if (this._get(this._coreAtom).includes(id)) {
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
if (!this._get(this._enabledAtom).includes(id)) {
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
this._runForkedFiber(this.disable(id).pipe(Effect3.tapError((error) => Effect3.sync(() => log3.warn("auto-disable failed", {
|
|
772
|
+
id,
|
|
773
|
+
error
|
|
774
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 595, S: this }))), Effect3.ignore));
|
|
775
|
+
}
|
|
776
|
+
_getActiveModules() {
|
|
777
|
+
const active = this._get(this._activeAtom);
|
|
778
|
+
return this._get(this._modulesAtom).filter((module) => active.includes(module.id));
|
|
779
|
+
}
|
|
780
|
+
_getInactiveModules() {
|
|
781
|
+
const active = this._get(this._activeAtom);
|
|
782
|
+
return this._get(this._modulesAtom).filter((module) => !active.includes(module.id));
|
|
783
|
+
}
|
|
784
|
+
_getActiveModulesByEvent(key) {
|
|
785
|
+
return this._getActiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
|
|
786
|
+
}
|
|
787
|
+
_getInactiveModulesByEvent(key) {
|
|
788
|
+
return this._getInactiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
|
|
789
|
+
}
|
|
790
|
+
_setPendingResetByModule(module) {
|
|
791
|
+
const activationEvents = getEvents(module.activatesOn).map(eventKey).filter((key) => this._get(this._eventsFiredAtom).includes(key));
|
|
792
|
+
const pendingReset = Array.fromIterable(new Set(activationEvents)).filter((event) => {
|
|
793
|
+
const pending = this._get(this._pendingResetAtom);
|
|
794
|
+
return !pending.includes(event);
|
|
795
|
+
});
|
|
796
|
+
if (pendingReset.length > 0) {
|
|
797
|
+
log3("pending reset", {
|
|
798
|
+
events: pendingReset
|
|
799
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 621, S: this });
|
|
800
|
+
this._update(this._pendingResetAtom, (current) => [
|
|
801
|
+
...current,
|
|
802
|
+
...pendingReset
|
|
803
|
+
]);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
_clearPendingReset(key) {
|
|
807
|
+
const pendingIndex = this._get(this._pendingResetAtom).findIndex((event) => event === key);
|
|
808
|
+
if (pendingIndex !== -1) {
|
|
809
|
+
this._update(this._pendingResetAtom, (pending) => pending.filter((event) => event !== key));
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
//
|
|
813
|
+
// Fiber helpers
|
|
814
|
+
//
|
|
815
|
+
_interruptInFlightActivations() {
|
|
816
|
+
return Effect3.gen(this, function* () {
|
|
817
|
+
const inFlightFibers = yield* Ref.get(this._inFlightFibers);
|
|
818
|
+
yield* Effect3.forEach(inFlightFibers, (fiber) => Fiber.interrupt(fiber), {
|
|
819
|
+
concurrency: "unbounded"
|
|
820
|
+
});
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
_trackFiber(ref, fiber) {
|
|
824
|
+
return Ref.update(ref, (fibers) => [
|
|
825
|
+
...fibers,
|
|
826
|
+
fiber
|
|
827
|
+
]);
|
|
828
|
+
}
|
|
829
|
+
_untrackFiber(ref, fiber) {
|
|
830
|
+
return Ref.update(ref, (fibers) => fibers.filter((trackedFiber) => trackedFiber !== fiber));
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Spawns an effect on the default runtime and registers the resulting fiber in
|
|
834
|
+
* `_inFlightFibers` so {@link shutdown} can interrupt it. Used from sync entry
|
|
835
|
+
* points like {@link remove} where there is no enclosing Effect to fork from;
|
|
836
|
+
* inside an Effect chain prefer the existing track/await/untrack pattern.
|
|
837
|
+
*/
|
|
838
|
+
_runForkedFiber(effect) {
|
|
839
|
+
const fiber = Effect3.runFork(effect);
|
|
840
|
+
Effect3.runSync(this._trackFiber(this._inFlightFibers, fiber));
|
|
841
|
+
Effect3.runFork(Fiber.await(fiber).pipe(Effect3.andThen(() => this._untrackFiber(this._inFlightFibers, fiber))));
|
|
842
|
+
}
|
|
843
|
+
//
|
|
844
|
+
// Registration helpers
|
|
845
|
+
//
|
|
846
|
+
_addPlugin(plugin) {
|
|
847
|
+
log3("add plugin", {
|
|
848
|
+
id: plugin.meta.id
|
|
849
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 670, S: this });
|
|
850
|
+
this._update(this._pluginsAtom, (plugins) => plugins.includes(plugin) ? plugins : [
|
|
851
|
+
...plugins,
|
|
852
|
+
plugin
|
|
853
|
+
]);
|
|
854
|
+
}
|
|
855
|
+
_removePlugin(id) {
|
|
856
|
+
log3("remove plugin", {
|
|
857
|
+
id
|
|
858
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 680, S: this });
|
|
859
|
+
this._update(this._pluginsAtom, (plugins) => plugins.filter((plugin) => plugin.meta.id !== id));
|
|
860
|
+
}
|
|
861
|
+
_addModule(module) {
|
|
862
|
+
log3("add module", {
|
|
863
|
+
id: module.id
|
|
864
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 686, S: this });
|
|
865
|
+
this._update(this._modulesAtom, (modules) => modules.includes(module) ? modules : [
|
|
866
|
+
...modules,
|
|
867
|
+
module
|
|
868
|
+
]);
|
|
869
|
+
}
|
|
870
|
+
_removeModule(id) {
|
|
871
|
+
log3("remove module", {
|
|
872
|
+
id
|
|
873
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 696, S: this });
|
|
874
|
+
this._update(this._modulesAtom, (modules) => modules.filter((module) => module.id !== id));
|
|
875
|
+
}
|
|
876
|
+
//
|
|
877
|
+
// Activation helpers
|
|
878
|
+
//
|
|
879
|
+
_activateEvent(key, params, fiber) {
|
|
880
|
+
return Effect3.gen(this, function* () {
|
|
881
|
+
yield* this._trackFiber(this._inFlightFibers, fiber);
|
|
882
|
+
log3("activating", {
|
|
883
|
+
key,
|
|
884
|
+
...params
|
|
885
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 707, S: this });
|
|
886
|
+
yield* Ref.update(this._activatingEvents, (activating) => Array.append(activating, key));
|
|
887
|
+
this._clearPendingReset(key);
|
|
888
|
+
const activatingEvents = yield* this._activatingEvents;
|
|
889
|
+
const activatingModules = yield* this._activatingModules;
|
|
890
|
+
const modules = this._getModulesForActivation(key, activatingEvents, activatingModules);
|
|
891
|
+
if (modules.length === 0) {
|
|
892
|
+
log3("no modules to activate", {
|
|
893
|
+
key
|
|
894
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 717, S: this });
|
|
895
|
+
if (!this._get(this._eventsFiredAtom).includes(key)) {
|
|
896
|
+
this._update(this._eventsFiredAtom, (events) => [
|
|
897
|
+
...events,
|
|
898
|
+
key
|
|
899
|
+
]);
|
|
900
|
+
}
|
|
901
|
+
return false;
|
|
902
|
+
}
|
|
903
|
+
return yield* this._activateModulesForEvent(key, modules, activatingEvents);
|
|
904
|
+
}).pipe(Effect3.ensuring(Effect3.all([
|
|
905
|
+
this._untrackFiber(this._inFlightFibers, fiber),
|
|
906
|
+
Ref.update(this._activatingEvents, (activating) => Array.filter(activating, (event) => event !== key))
|
|
907
|
+
])));
|
|
908
|
+
}
|
|
909
|
+
_activateModulesForEvent(key, modules, activatingEvents) {
|
|
910
|
+
const activatingModuleIds = modules.map((module) => module.id);
|
|
911
|
+
return Effect3.gen(this, function* () {
|
|
912
|
+
yield* Ref.update(this._activatingModules, (activating) => Array.appendAll(activating, activatingModuleIds));
|
|
913
|
+
log3("activating modules", {
|
|
914
|
+
key,
|
|
915
|
+
modules: activatingModuleIds
|
|
916
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 738, S: this });
|
|
917
|
+
performance.mark(`event:${key}:start`);
|
|
918
|
+
yield* PubSub.publish(this.activation, {
|
|
919
|
+
event: key,
|
|
920
|
+
state: "activating"
|
|
921
|
+
});
|
|
922
|
+
yield* this._activateRelatedEvents(key, this._getBeforeEvents(modules, activatingEvents), "before");
|
|
923
|
+
const capabilities = yield* this._loadCapabilitiesForModules(key, modules);
|
|
924
|
+
yield* this._contributeCapabilitiesForModules(modules, capabilities);
|
|
925
|
+
yield* this._activateRelatedEvents(key, this._getAfterEvents(modules, activatingEvents), "after");
|
|
926
|
+
if (!this._get(this._eventsFiredAtom).includes(key)) {
|
|
927
|
+
this._update(this._eventsFiredAtom, (events) => [
|
|
928
|
+
...events,
|
|
929
|
+
key
|
|
930
|
+
]);
|
|
931
|
+
}
|
|
932
|
+
performance.mark(`event:${key}:end`);
|
|
933
|
+
performance.measure(`event:${key}`, `event:${key}:start`, `event:${key}:end`);
|
|
934
|
+
yield* PubSub.publish(this.activation, {
|
|
935
|
+
event: key,
|
|
936
|
+
state: "activated"
|
|
937
|
+
});
|
|
938
|
+
log3("activated", {
|
|
939
|
+
key
|
|
940
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 763, S: this });
|
|
941
|
+
return true;
|
|
942
|
+
}).pipe(Effect3.ensuring(Ref.update(this._activatingModules, (activating) => Array.filter(activating, (module) => !activatingModuleIds.includes(module)))));
|
|
943
|
+
}
|
|
944
|
+
_getModulesForActivation(key, activatingEvents, activatingModules) {
|
|
945
|
+
return this._getInactiveModulesByEvent(key).filter((module) => {
|
|
946
|
+
const allOf = isAllOf(module.activatesOn);
|
|
947
|
+
if (!allOf) {
|
|
948
|
+
return true;
|
|
949
|
+
}
|
|
950
|
+
const events = getEvents(module.activatesOn).filter((event) => eventKey(event) !== key);
|
|
951
|
+
return events.every((event) => this._get(this._eventsFiredAtom).includes(eventKey(event)) || activatingEvents.includes(eventKey(event))) && !activatingModules.includes(module.id);
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
_getBeforeEvents(modules, activatingEvents) {
|
|
955
|
+
return Function.pipe(modules, Array.flatMap((module) => module.firesBeforeActivation ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event) => !activatingEvents.includes(eventKey(event))));
|
|
956
|
+
}
|
|
957
|
+
_getAfterEvents(modules, activatingEvents) {
|
|
958
|
+
return Function.pipe(modules, Array.flatMap((module) => module.firesAfterActivation ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event) => !activatingEvents.includes(eventKey(event))));
|
|
959
|
+
}
|
|
960
|
+
_activateRelatedEvents(key, events, phase) {
|
|
961
|
+
const logLabel = phase === "before" ? "firesBeforeActivation" : "firesAfterActivation";
|
|
962
|
+
const eventKey2 = phase === "before" ? "beforeEvents" : "afterEvents";
|
|
963
|
+
return Function.pipe(events, Array.map((event) => this.activate(event, phase === "before" ? {
|
|
964
|
+
before: key
|
|
965
|
+
} : {
|
|
966
|
+
after: key
|
|
967
|
+
})), Effect3.allWith({
|
|
968
|
+
concurrency: "unbounded"
|
|
969
|
+
}), together(Effect3.sleep(Duration.seconds(10)).pipe(Effect3.andThen(Effect3.sync(() => log3.warn(`${logLabel} is taking a long time`, {
|
|
970
|
+
event: key,
|
|
971
|
+
[eventKey2]: events.map(eventKey)
|
|
972
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 796, S: this }))))), Effect3.asVoid);
|
|
973
|
+
}
|
|
974
|
+
//
|
|
975
|
+
// Module lifecycle helpers
|
|
976
|
+
//
|
|
977
|
+
_loadCapabilitiesForModules(key, modules) {
|
|
978
|
+
return Function.pipe(modules, Array.map((mod) => this._loadModule(mod, key)), Effect3.allWith({
|
|
979
|
+
concurrency: "unbounded"
|
|
980
|
+
}), Effect3.catchAll((error) => {
|
|
981
|
+
return Effect3.gen(this, function* () {
|
|
982
|
+
yield* PubSub.publish(this.activation, {
|
|
983
|
+
event: key,
|
|
984
|
+
state: "error",
|
|
985
|
+
error
|
|
986
|
+
});
|
|
987
|
+
return yield* Effect3.fail(error);
|
|
988
|
+
});
|
|
989
|
+
}));
|
|
990
|
+
}
|
|
991
|
+
_contributeCapabilitiesForModules(modules, capabilities) {
|
|
992
|
+
return Function.pipe(
|
|
993
|
+
modules,
|
|
994
|
+
Array.zip(capabilities),
|
|
995
|
+
Array.map(([module, capabilitySet]) => this._contributeCapabilities(module, capabilitySet)),
|
|
996
|
+
Effect3.all,
|
|
997
|
+
Effect3.asVoid
|
|
998
|
+
);
|
|
999
|
+
}
|
|
1000
|
+
_getModuleSemaphore(moduleId) {
|
|
1001
|
+
let semaphore = this._moduleSemaphores.get(moduleId);
|
|
1002
|
+
if (!semaphore) {
|
|
1003
|
+
semaphore = Effect3.runSync(Effect3.makeSemaphore(1));
|
|
1004
|
+
this._moduleSemaphores.set(moduleId, semaphore);
|
|
1005
|
+
}
|
|
1006
|
+
return semaphore;
|
|
1007
|
+
}
|
|
1008
|
+
// `parentEvent` is the activation event that first triggered this module
|
|
1009
|
+
// load — included in `activating`/`activated` PubSub messages so subscribers
|
|
1010
|
+
// (e.g. the boot loader's status listener) can associate a module with its
|
|
1011
|
+
// triggering event in the trace. The same module may be referenced by
|
|
1012
|
+
// multiple events, but module loads are memoized via `_moduleMemoMap`, so
|
|
1013
|
+
// only the first event to need it will appear here; later events await the
|
|
1014
|
+
// cached deferred without re-publishing.
|
|
1015
|
+
_loadModule = (module, parentEvent) => Effect3.gen(this, function* () {
|
|
1016
|
+
const semaphore = this._getModuleSemaphore(module.id);
|
|
1017
|
+
const deferredToAwait = yield* Effect3.gen(this, function* () {
|
|
1018
|
+
const existing = this._moduleMemoMap.get(module.id);
|
|
1019
|
+
if (existing) {
|
|
1020
|
+
return existing;
|
|
1021
|
+
}
|
|
1022
|
+
const deferred = yield* Deferred2.make();
|
|
1023
|
+
this._moduleMemoMap.set(module.id, deferred);
|
|
1024
|
+
const loadEffect = Effect3.gen(this, function* () {
|
|
1025
|
+
log3("loading module", {
|
|
1026
|
+
module: module.id,
|
|
1027
|
+
parentEvent
|
|
1028
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 854, S: this });
|
|
1029
|
+
performance.mark(`module:${module.id}:start`);
|
|
1030
|
+
yield* PubSub.publish(this.activation, {
|
|
1031
|
+
event: parentEvent,
|
|
1032
|
+
state: "activating",
|
|
1033
|
+
module: module.id
|
|
1034
|
+
});
|
|
1035
|
+
const pluginId = this._getPluginIdForModule(module.id);
|
|
1036
|
+
const [duration, capabilities] = yield* module.activate().pipe(
|
|
1037
|
+
Effect3.provideService(Service, this.capabilities),
|
|
1038
|
+
Effect3.provideService(Service2, this),
|
|
1039
|
+
// Cap activation so a single misbehaving module can't hold the
|
|
1040
|
+
// event chain open. On timeout the failure is recorded against
|
|
1041
|
+
// the plugin and surfaced as `PluginTimeoutError`.
|
|
1042
|
+
Effect3.timeoutFail({
|
|
1043
|
+
duration: this._activationTimeout,
|
|
1044
|
+
onTimeout: () => new PluginTimeoutError({
|
|
1045
|
+
context: {
|
|
1046
|
+
id: pluginId ?? module.id,
|
|
1047
|
+
module: module.id,
|
|
1048
|
+
phase: "activation"
|
|
1049
|
+
}
|
|
1050
|
+
})
|
|
1051
|
+
}),
|
|
1052
|
+
Effect3.timed
|
|
1053
|
+
);
|
|
1054
|
+
const normalized = capabilities == null ? [] : Array.isArray(capabilities) ? capabilities : [
|
|
1055
|
+
capabilities
|
|
1056
|
+
];
|
|
1057
|
+
const elapsed = Duration.toMillis(duration);
|
|
1058
|
+
performance.mark(`module:${module.id}:end`);
|
|
1059
|
+
performance.measure(`module:${module.id}`, `module:${module.id}:start`, `module:${module.id}:end`);
|
|
1060
|
+
yield* PubSub.publish(this.activation, {
|
|
1061
|
+
event: parentEvent,
|
|
1062
|
+
state: "activated",
|
|
1063
|
+
module: module.id
|
|
1064
|
+
});
|
|
1065
|
+
log3("loaded module", {
|
|
1066
|
+
module: module.id,
|
|
1067
|
+
parentEvent,
|
|
1068
|
+
elapsed,
|
|
1069
|
+
failed: false
|
|
1070
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 889, S: this });
|
|
1071
|
+
return normalized;
|
|
1072
|
+
}).pipe(Effect3.withSpan("PluginManager._loadModule"), together(Effect3.sleep(Duration.seconds(10)).pipe(Effect3.andThen(Effect3.sync(() => log3.warn(`module is taking a long time to activate`, {
|
|
1073
|
+
module: module.id
|
|
1074
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 896, S: this }))))), Performance.addTrackEntry({
|
|
1075
|
+
name: module.id,
|
|
1076
|
+
devtools: {
|
|
1077
|
+
dataType: "track-entry",
|
|
1078
|
+
track: "Module Activation",
|
|
1079
|
+
trackGroup: "Composer",
|
|
1080
|
+
color: "primary"
|
|
1081
|
+
}
|
|
1082
|
+
}));
|
|
1083
|
+
const fiber = yield* Effect3.forkDaemon(loadEffect.pipe(Effect3.tap((result) => Deferred2.succeed(deferred, result)), Effect3.catchAllCause((cause) => {
|
|
1084
|
+
const error = Cause.squash(cause);
|
|
1085
|
+
log3.error("module failed to activate", {
|
|
1086
|
+
module: module.id,
|
|
1087
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1088
|
+
stack: error instanceof Error ? error.stack : void 0,
|
|
1089
|
+
isDefect: !Cause.isFailure(cause)
|
|
1090
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 910, S: this });
|
|
1091
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
1092
|
+
const pluginId = this._getPluginIdForModule(module.id);
|
|
1093
|
+
if (pluginId !== void 0) {
|
|
1094
|
+
this._recordFailure(pluginId, "activation", normalizedError);
|
|
1095
|
+
this._scheduleAutoDisable(pluginId);
|
|
1096
|
+
}
|
|
1097
|
+
return Deferred2.fail(deferred, normalizedError);
|
|
1098
|
+
})));
|
|
1099
|
+
yield* this._trackFiber(this._inFlightFibers, fiber);
|
|
1100
|
+
yield* Effect3.forkDaemon(Fiber.await(fiber).pipe(Effect3.andThen(() => this._untrackFiber(this._inFlightFibers, fiber))));
|
|
1101
|
+
return deferred;
|
|
1102
|
+
}).pipe(semaphore.withPermits(1));
|
|
1103
|
+
return yield* Deferred2.await(deferredToAwait);
|
|
1104
|
+
});
|
|
1105
|
+
_contributeCapabilities(module, capabilities) {
|
|
1106
|
+
return Effect3.gen(this, function* () {
|
|
1107
|
+
capabilities.forEach((capability) => {
|
|
1108
|
+
this.capabilities.contribute({
|
|
1109
|
+
module: module.id,
|
|
1110
|
+
...capability
|
|
1111
|
+
});
|
|
1112
|
+
});
|
|
1113
|
+
this._update(this._activeAtom, (active) => [
|
|
1114
|
+
...active,
|
|
1115
|
+
module.id
|
|
1116
|
+
]);
|
|
1117
|
+
this._capabilities.set(module.id, capabilities);
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
_deactivateModule(module) {
|
|
1121
|
+
return Effect3.gen(this, function* () {
|
|
1122
|
+
const id = module.id;
|
|
1123
|
+
log3("deactivating", {
|
|
1124
|
+
id
|
|
1125
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 949, S: this });
|
|
1126
|
+
this._moduleMemoMap.delete(id);
|
|
1127
|
+
const capabilities = this._capabilities.get(id);
|
|
1128
|
+
if (capabilities) {
|
|
1129
|
+
for (const capability of capabilities) {
|
|
1130
|
+
this.capabilities.remove(capability.interface, capability.implementation);
|
|
1131
|
+
const program = capability.deactivate?.() ?? Effect3.succeed(void 0);
|
|
1132
|
+
yield* program;
|
|
1133
|
+
}
|
|
1134
|
+
this._capabilities.delete(id);
|
|
1135
|
+
}
|
|
1136
|
+
const activeIndex = this._get(this._activeAtom).findIndex((event) => event === id);
|
|
1137
|
+
if (activeIndex !== -1) {
|
|
1138
|
+
this._update(this._activeAtom, (active) => active.filter((event) => event !== id));
|
|
1139
|
+
}
|
|
1140
|
+
log3("deactivated", {
|
|
1141
|
+
id
|
|
1142
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 966, S: this });
|
|
1143
|
+
return true;
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
};
|
|
1147
|
+
var make5 = (options) => new ManagerImpl(options);
|
|
1148
|
+
var isTimeoutCause = (error, depth = 0) => {
|
|
1149
|
+
if (depth > 5 || !(error instanceof Error)) {
|
|
1150
|
+
return false;
|
|
1151
|
+
}
|
|
1152
|
+
if (PluginTimeoutError.is(error)) {
|
|
1153
|
+
return true;
|
|
1154
|
+
}
|
|
1155
|
+
return isTimeoutCause(error.cause, depth + 1);
|
|
1156
|
+
};
|
|
1157
|
+
var together = (togetherEffect) => (effect) => Effect3.gen(function* () {
|
|
1158
|
+
const togetherFiber = yield* Effect3.fork(togetherEffect);
|
|
1159
|
+
const result = yield* effect;
|
|
1160
|
+
yield* Fiber.interrupt(togetherFiber);
|
|
1161
|
+
return result;
|
|
1162
|
+
});
|
|
1163
|
+
|
|
1164
|
+
export {
|
|
1165
|
+
capability_manager_exports,
|
|
1166
|
+
registry_exports,
|
|
1167
|
+
PluginInitializationError,
|
|
1168
|
+
PluginTimeoutError,
|
|
1169
|
+
ManagerTypeId,
|
|
1170
|
+
isManager,
|
|
1171
|
+
make5 as make,
|
|
1172
|
+
plugin_manager_exports
|
|
1173
|
+
};
|
|
1174
|
+
//# sourceMappingURL=chunk-NBXPP7JR.mjs.map
|