@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,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/core/plugin-manager.ts", "../../../src/core/capability-manager.ts", "../../../src/core/registry.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Atom, Registry } from '@effect-atom/atom-react';\nimport * as Array from 'effect/Array';\nimport * as Cause from 'effect/Cause';\nimport * as Deferred from 'effect/Deferred';\nimport * as Duration from 'effect/Duration';\nimport * as Effect from 'effect/Effect';\nimport * as Fiber from 'effect/Fiber';\nimport * as Function from 'effect/Function';\nimport * as HashSet from 'effect/HashSet';\nimport * as PubSub from 'effect/PubSub';\nimport * as Ref from 'effect/Ref';\n\nimport { runAndForwardErrors } from '@dxos/effect';\nimport { Performance } from '@dxos/effect';\nimport { BaseError } from '@dxos/errors';\nimport { log } from '@dxos/log';\n\nimport * as ActivationEvent from './activation-event';\nimport * as Capability from './capability';\nimport * as CapabilityManager from './capability-manager';\nimport * as Plugin from './plugin';\n// Imported with a `PluginRegistry` alias because the unrelated `@effect-atom/atom-react`\n// `Registry` is already imported above; from outside this file the namespace is\n// re-exported as `Registry` via `./index.ts`.\nimport * as PluginRegistry from './registry';\n\n/**\n * Tagged error for failures during the constructor-launched core/enabled\n * `enable()` chain. Surfaces via {@link PluginManager.activate}'s wait on\n * `_initialization` so a caller blocked on initialization gets a typed\n * failure (with the original error preserved as `cause`) instead of an\n * untyped `Error`.\n */\nexport class PluginInitializationError extends BaseError.extend(\n 'PluginInitializationError',\n 'Plugin manager initialization failed',\n) {}\n\n/**\n * Tagged error raised when a plugin exceeds its configured load or activation\n * timeout. The plugin manager records the failure on the `failed` atom and\n * auto-disables the plugin so that one stuck remote does not stall app boot.\n * `context.id` is the plugin id, `context.phase` is `'load'` or `'activation'`.\n */\nexport class PluginTimeoutError extends BaseError.extend('PluginTimeoutError', 'Plugin operation timed out') {}\n\n/** Phase of the plugin lifecycle in which the failure was observed. */\nexport type PluginFailurePhase = 'load' | 'activation';\n\n/** Why the plugin entered a failed state. */\nexport type PluginFailureReason = 'timeout' | 'error';\n\n/**\n * Record of a plugin that failed to load or activate. Surfaced via the\n * {@link PluginManager.failed} atom so registry / UI consumers can flag\n * unhealthy plugins (e.g. a remote host that has gone offline) rather than\n * leaving the app in a half-broken state.\n */\nexport type PluginFailure = {\n readonly id: string;\n readonly phase: PluginFailurePhase;\n readonly reason: PluginFailureReason;\n readonly error: Error;\n /** `Date.now()` when the failure was recorded. */\n readonly timestamp: number;\n};\n\n/** Default deadline for resolving a lazy plugin's dynamic import. */\nconst DEFAULT_LOAD_TIMEOUT = Duration.seconds(30);\n\n/** Default deadline for a single module's `activate()` body. */\nconst DEFAULT_ACTIVATION_TIMEOUT = Duration.seconds(30);\n\n/**\n * Identifier denoting a Manager.\n */\nexport const ManagerTypeId: unique symbol = Symbol.for('@dxos/app-framework/Manager');\nexport type ManagerTypeId = typeof ManagerTypeId;\n\n/**\n * Loader result that carries optional metadata about how the plugin was sourced.\n *\n * `dev: true` marks a plugin as session-only and triggers shadow-on-id-collision\n * inside the manager: if a plugin with the same id is already registered (a\n * builtin, or a previously-installed plugin from the registry), the dev plugin\n * temporarily takes over that id slot. The original is restored when the dev\n * plugin is removed (or on page reload, since dev plugins aren't persisted).\n */\nexport type LoadedPlugin = {\n plugin: Plugin.Plugin;\n /** True when the plugin came from a dev source. See type doc for semantics. */\n dev?: boolean;\n};\n\nexport type ManagerOptions = {\n pluginLoader: (id: string) => Effect.Effect<LoadedPlugin, Error>;\n plugins?: Plugin.Plugin[];\n core?: string[];\n enabled?: string[];\n registry?: Registry.Registry;\n /**\n * Backend for the plugin registry catalog. When omitted the manager exposes a\n * no-op `pluginRegistry` (empty list, no versions endpoint). Implementations\n * live in app-framework alongside the interface (e.g.\n * `EdgeRegistryPluginProvider`); the host app instantiates one and passes it in.\n */\n pluginRegistryProvider?: PluginRegistry.PluginProvider;\n /**\n * Hook called when a plugin is removed via {@link PluginManager.remove}. Used by the\n * host app to clean up persisted state (e.g. evict offline-cached plugin assets).\n * Failures are logged and swallowed; removal still succeeds even if the hook fails.\n */\n onRemove?: (id: string) => Effect.Effect<void, unknown>;\n /**\n * Maximum time allowed for a lazy plugin's dynamic `import()` to resolve.\n * Plugins that exceed this are flagged on the {@link PluginManager.failed}\n * atom and auto-disabled so a stuck remote host can't stall app boot.\n * Defaults to 30 seconds; pass `Duration.infinity` to disable.\n */\n loadTimeout?: Duration.DurationInput;\n /**\n * Maximum time allowed for a single module's `activate()` Effect to settle.\n * Modules that exceed this fail with {@link PluginTimeoutError}; the owning\n * plugin is recorded on `failed` and auto-disabled. Defaults to 30 seconds;\n * pass `Duration.infinity` to disable.\n */\n activationTimeout?: Duration.DurationInput;\n};\n\nexport type ActivationMessage = {\n event: string;\n state: 'activating' | 'activated' | 'error';\n /** Module ID when the message pertains to a specific module activation. */\n module?: string;\n error?: Error;\n};\n\n/**\n * Interface for the Plugin Manager.\n */\nexport interface PluginManager {\n readonly [ManagerTypeId]: ManagerTypeId;\n readonly activation: PubSub.PubSub<ActivationMessage>;\n readonly capabilities: CapabilityManager.CapabilityManager;\n readonly registry: Registry.Registry;\n /**\n * Cached registry catalog state plus pass-throughs for `listVersions` /\n * `getPlugin`. Always present — the host supplies a `pluginRegistryProvider`\n * via {@link ManagerOptions} for real backends, or it falls back to a no-op\n * implementation that yields an empty catalog.\n */\n readonly pluginRegistry: PluginRegistry.Manager;\n\n readonly plugins: Atom.Atom<readonly Plugin.Plugin[]>;\n readonly core: Atom.Atom<readonly string[]>;\n readonly enabled: Atom.Atom<readonly string[]>;\n readonly modules: Atom.Atom<readonly Plugin.PluginModule[]>;\n readonly active: Atom.Atom<readonly string[]>;\n readonly eventsFired: Atom.Atom<readonly string[]>;\n readonly pendingReset: Atom.Atom<readonly string[]>;\n /**\n * Plugins that failed to load or activate. Subscribers (e.g. the registry\n * UI) can use this to flag unhealthy entries; a plugin id appears here at\n * most once with its most recent failure.\n */\n readonly failed: Atom.Atom<readonly PluginFailure[]>;\n /**\n * Ids of currently-registered plugins that came from a dev source (loaded\n * via {@link LoadedPlugin} with `dev: true`). Subscribers can use this to\n * badge dev-overridden plugins or to derive the id of the active dev plugin\n * for an \"uninstall dev plugin\" affordance.\n */\n readonly devPluginIds: Atom.Atom<readonly string[]>;\n\n getPlugins(): readonly Plugin.Plugin[];\n getCore(): readonly string[];\n getEnabled(): readonly string[];\n getModules(): readonly Plugin.PluginModule[];\n getActive(): readonly string[];\n getEventsFired(): readonly string[];\n getPendingReset(): readonly string[];\n getFailed(): readonly PluginFailure[];\n getDevPluginIds(): readonly string[];\n\n /**\n * Clears the failure record for a plugin so it can be retried. Returns\n * whether a failure record existed and was removed.\n */\n clearFailure(id: string): boolean;\n\n /**\n * Loads a plugin via the plugin loader and registers it without enabling it.\n * Returns the loaded plugin so callers can enable it by its canonical id\n * (which may differ from the locator used to load it, e.g. URL loaders).\n */\n add(id: string): Effect.Effect<Plugin.Plugin, Error>;\n enable(id: string): Effect.Effect<boolean, Error>;\n remove(id: string): Effect.Effect<boolean, Error>;\n disable(id: string): Effect.Effect<boolean, Error>;\n // TODO(wittjosiah): Improve error typing.\n activate(\n event: ActivationEvent.ActivationEvent | string,\n params?: { before?: string; after?: string },\n ): Effect.Effect<boolean, Error>;\n deactivate(id: string): Effect.Effect<boolean, Error>;\n reset(event: ActivationEvent.ActivationEvent | string): Effect.Effect<boolean, Error>;\n\n /**\n * Shuts down the manager by deactivating all active modules in reverse activation order,\n * clearing all capabilities, and resetting lifecycle bookkeeping.\n * Plugins, core, enabled, and modules remain intact so the manager can be reused.\n */\n shutdown(): Effect.Effect<boolean, Error>;\n}\n\n/**\n * Type guard to check if a value is a PluginManager.\n */\nexport const isManager = (value: unknown): value is PluginManager => {\n return typeof value === 'object' && value !== null && ManagerTypeId in value;\n};\n\n/**\n * Internal implementation of PluginManager.\n */\nclass ManagerImpl implements PluginManager {\n readonly [ManagerTypeId]: ManagerTypeId = ManagerTypeId;\n readonly activation = Effect.runSync(PubSub.unbounded<ActivationMessage>());\n readonly capabilities: CapabilityManager.CapabilityManager;\n readonly registry: Registry.Registry;\n readonly pluginRegistry: PluginRegistry.Manager;\n\n private readonly _pluginsAtom: Atom.Writable<Plugin.Plugin[]>;\n private readonly _coreAtom: Atom.Writable<string[]>;\n private readonly _enabledAtom: Atom.Writable<string[]>;\n private readonly _modulesAtom: Atom.Writable<Plugin.PluginModule[]>;\n private readonly _activeAtom: Atom.Writable<string[]>;\n private readonly _eventsFiredAtom: Atom.Writable<string[]>;\n private readonly _pendingResetAtom: Atom.Writable<string[]>;\n private readonly _failedAtom: Atom.Writable<PluginFailure[]>;\n private readonly _pluginLoader: ManagerOptions['pluginLoader'];\n private readonly _onRemove: ManagerOptions['onRemove'];\n private readonly _loadTimeout: Duration.DurationInput;\n private readonly _activationTimeout: Duration.DurationInput;\n private readonly _capabilities = new Map<string, Capability.Any[]>();\n private readonly _moduleMemoMap = new Map<Plugin.PluginModule['id'], Deferred.Deferred<Capability.Any[], Error>>();\n private readonly _moduleSemaphores = new Map<Plugin.PluginModule['id'], Effect.Semaphore>();\n // Coalesces concurrent `_resolveLazyPlugin` calls per plugin id. Without\n // this, two callers entering `enable(id)` before the swap completes would\n // each invoke `mod.default(options)` and produce distinct module objects,\n // defeating `_addModule`'s reference-equality dedupe and racing the\n // `_pluginsAtom` swap.\n private readonly _resolvingPlugins = new Map<string, Deferred.Deferred<Plugin.Plugin, Plugin.LazyPluginError>>();\n // Tracks dev-source plugins (loaded via a Vite dev server) keyed by id.\n // When `shadow` is present, the entry has displaced an existing plugin —\n // `remove` reinstates it and re-enables iff `wasEnabled`. Entries without a\n // shadow are dev plugins with no underlying registry/builtin to restore.\n // The atom mirrors the map's keys for UI subscribers (they don't need the\n // shadow internals); the two stay in sync via {@link _markDev}/{@link _unmarkDev}.\n private readonly _devPlugins = new Map<string, { shadow?: { plugin: Plugin.Plugin; wasEnabled: boolean } }>();\n private readonly _devPluginIdsAtom: Atom.Writable<string[]>;\n private readonly _activatingEvents = Effect.runSync(Ref.make<string[]>([]));\n private readonly _activatingModules = Effect.runSync(Ref.make<string[]>([]));\n private readonly _inFlightFibers = Effect.runSync(Ref.make<Array<Fiber.Fiber<unknown, unknown>>>([]));\n private readonly _shutdownSemaphore = Effect.runSync(Effect.makeSemaphore(1));\n private readonly _shuttingDown = Effect.runSync(Ref.make(false));\n // Tracks the constructor-launched core/enabled `enable()` calls so that\n // `activate` can wait for module registration before dispatching events.\n // Lazy plugins make `enable` asynchronous (a dynamic `import()` happens\n // inside it), so without this synchronization an `activate` triggered\n // immediately after `make` could fire on an empty module set. Failures\n // are wrapped in `PluginInitializationError` so awaiters get a tagged\n // error rather than the wide `Error` produced by the underlying chain.\n private readonly _initialization = Effect.runSync(Deferred.make<void, PluginInitializationError>());\n\n constructor({\n pluginLoader,\n plugins = [],\n core = plugins.map(({ meta }) => meta.id),\n enabled = [],\n registry,\n pluginRegistryProvider,\n onRemove,\n loadTimeout = DEFAULT_LOAD_TIMEOUT,\n activationTimeout = DEFAULT_ACTIVATION_TIMEOUT,\n }: ManagerOptions) {\n this.registry = registry ?? Registry.make();\n this.capabilities = CapabilityManager.make({\n registry: this.registry,\n });\n this.pluginRegistry = new PluginRegistry.Manager(pluginRegistryProvider, this.registry);\n\n this._pluginLoader = pluginLoader;\n this._onRemove = onRemove;\n this._loadTimeout = loadTimeout;\n this._activationTimeout = activationTimeout;\n this._pluginsAtom = Atom.make(plugins).pipe(Atom.keepAlive);\n this._coreAtom = Atom.make(core).pipe(Atom.keepAlive);\n this._enabledAtom = Atom.make(enabled).pipe(Atom.keepAlive);\n this._modulesAtom = Atom.make<Plugin.PluginModule[]>([]).pipe(Atom.keepAlive);\n this._activeAtom = Atom.make<string[]>([]).pipe(Atom.keepAlive);\n this._eventsFiredAtom = Atom.make<string[]>([]).pipe(Atom.keepAlive);\n this._pendingResetAtom = Atom.make<string[]>([]).pipe(Atom.keepAlive);\n this._failedAtom = Atom.make<PluginFailure[]>([]).pipe(Atom.keepAlive);\n this._devPluginIdsAtom = Atom.make<string[]>([]).pipe(Atom.keepAlive);\n plugins.forEach((plugin) => this._addPlugin(plugin));\n // Dedupe before mapping to `enable` — `core` and `enabled` may overlap (an\n // app-supplied plugin can be in both), and concurrent `enable(id)` calls\n // for the same id are not idempotent (each would re-run the lazy resolve\n // and double-register modules). `new Set([...])` preserves first-seen\n // order which matches the natural core-before-enabled precedence.\n const initialIds = [...new Set([...core, ...enabled])];\n void Effect.all(initialIds.map((id) => this.enable(id)))\n .pipe(\n Effect.mapError((cause) => new PluginInitializationError({ cause })),\n Effect.tap(() => Deferred.succeed(this._initialization, undefined)),\n Effect.tapErrorCause((cause) => Deferred.failCause(this._initialization, cause)),\n )\n .pipe(runAndForwardErrors);\n }\n\n get plugins(): Atom.Atom<readonly Plugin.Plugin[]> {\n return this._pluginsAtom;\n }\n\n get core(): Atom.Atom<readonly string[]> {\n return this._coreAtom;\n }\n\n /**\n * Ids of plugins that are currently enabled.\n */\n get enabled(): Atom.Atom<readonly string[]> {\n return this._enabledAtom;\n }\n\n /**\n * Modules of plugins which are currently enabled.\n */\n get modules(): Atom.Atom<readonly Plugin.PluginModule[]> {\n return this._modulesAtom;\n }\n\n /**\n * Ids of modules which are currently active.\n */\n get active(): Atom.Atom<readonly string[]> {\n return this._activeAtom;\n }\n\n /**\n * Ids of events which have been fired.\n */\n get eventsFired(): Atom.Atom<readonly string[]> {\n return this._eventsFiredAtom;\n }\n\n /**\n * Ids of modules which are pending reset.\n */\n get pendingReset(): Atom.Atom<readonly string[]> {\n return this._pendingResetAtom;\n }\n\n /**\n * Plugins that failed to load or activate.\n */\n get failed(): Atom.Atom<readonly PluginFailure[]> {\n return this._failedAtom;\n }\n\n /**\n * Ids of currently-registered plugins that came from a dev source.\n */\n get devPluginIds(): Atom.Atom<readonly string[]> {\n return this._devPluginIdsAtom;\n }\n\n getPlugins(): readonly Plugin.Plugin[] {\n return this._get(this._pluginsAtom);\n }\n\n getCore(): readonly string[] {\n return this._get(this._coreAtom);\n }\n\n getEnabled(): readonly string[] {\n return this._get(this._enabledAtom);\n }\n\n getModules(): readonly Plugin.PluginModule[] {\n return this._get(this._modulesAtom);\n }\n\n getActive(): readonly string[] {\n return this._get(this._activeAtom);\n }\n\n getEventsFired(): readonly string[] {\n return this._get(this._eventsFiredAtom);\n }\n\n getPendingReset(): readonly string[] {\n return this._get(this._pendingResetAtom);\n }\n\n getFailed(): readonly PluginFailure[] {\n return this._get(this._failedAtom);\n }\n\n getDevPluginIds(): readonly string[] {\n return this._get(this._devPluginIdsAtom);\n }\n\n /**\n * Marks `id` as dev-sourced. If the plugin displaced an existing one, pass\n * the shadow snapshot so `remove` can restore it. Repeat calls (e.g. a dev\n * plugin reload) preserve the original shadow target — restoration always\n * unwinds back to the real underlying plugin, never an intermediate dev build.\n */\n private _markDev(id: string, shadow?: { plugin: Plugin.Plugin; wasEnabled: boolean }): void {\n if (this._devPlugins.has(id)) {\n return;\n }\n this._devPlugins.set(id, { shadow });\n this._update(this._devPluginIdsAtom, (ids) => (ids.includes(id) ? ids : [...ids, id]));\n }\n\n /** Drops the dev-plugin entry and returns its shadow data (if any) for restoration. */\n private _unmarkDev(id: string): { plugin: Plugin.Plugin; wasEnabled: boolean } | undefined {\n const entry = this._devPlugins.get(id);\n this._devPlugins.delete(id);\n this._update(this._devPluginIdsAtom, (ids) => ids.filter((existing) => existing !== id));\n return entry?.shadow;\n }\n\n clearFailure(id: string): boolean {\n const current = this._get(this._failedAtom);\n if (!current.some((failure) => failure.id === id)) {\n return false;\n }\n this._set(\n this._failedAtom,\n current.filter((failure) => failure.id !== id),\n );\n return true;\n }\n\n /**\n * Adds a plugin to the manager via the plugin loader.\n * The plugin is registered but not enabled; call `enable` separately to activate it.\n * @param id The id of the plugin.\n */\n add(id: string): Effect.Effect<Plugin.Plugin, Error> {\n return Effect.gen(this, function* () {\n log('add plugin', { id });\n const { plugin, dev = false } = yield* this._pluginLoader(id);\n const pluginId = plugin.meta.id;\n const existing = this._getPlugin(pluginId);\n\n if (dev && existing && existing !== plugin) {\n // Shadow path: a plugin with this id is already registered (a builtin,\n // a registry install, or a previous dev load). Disable it, stash it,\n // and swap the dev plugin into the same id slot. The dialog will call\n // `enable(pluginId)` next, which activates the dev plugin's modules.\n // `_markDev` is a no-op when the id is already tracked, so a dev-plugin\n // reload (after editing source) keeps the *original* shadow target —\n // removal restores the real underlying plugin, not an intermediate build.\n const wasEnabled = this._get(this._enabledAtom).includes(pluginId);\n if (wasEnabled) {\n yield* this.disable(pluginId);\n }\n this._markDev(pluginId, { plugin: existing, wasEnabled });\n this._update(this._pluginsAtom, (plugins) => plugins.map((p) => (p.meta.id === pluginId ? plugin : p)));\n } else {\n this._addPlugin(plugin);\n if (dev) {\n this._markDev(pluginId);\n }\n }\n\n return plugin;\n });\n }\n\n /**\n * Enables a plugin.\n * @param id The id of the plugin.\n */\n enable(id: string): Effect.Effect<boolean, Error> {\n return Effect.gen(this, function* () {\n log('enable plugin', { id });\n const stub = this._getPlugin(id);\n if (!stub) {\n return false;\n }\n\n // Clear any prior failure record so a retry starts from a clean slate.\n // The failure stays on the atom only if this attempt also fails.\n this.clearFailure(id);\n\n const plugin = yield* this._resolveLazyPlugin(stub);\n\n this._update(this._enabledAtom, (enabled) => (enabled.includes(id) ? enabled : [...enabled, id]));\n\n plugin.modules.forEach((module) => {\n this._addModule(module);\n this._setPendingResetByModule(module);\n });\n\n log('pending reset', { events: [...this.getPendingReset()] });\n yield* Effect.all(\n this.getPendingReset().map((event) => this.activate(event)),\n { concurrency: 'unbounded' },\n );\n\n return true;\n });\n }\n\n /**\n * Resolves a lazy plugin stub (returned by {@link Plugin.lazy}) to its\n * loaded form and swaps it into `_pluginsAtom`. Returns the input unchanged\n * when the plugin is already resolved, so callers can `yield*` this\n * unconditionally. The lazy stub carries `meta` synchronously but its\n * `modules` list is empty until the loader resolves; the swap ensures\n * subsequent enable/disable operations see the resolved plugin.\n *\n * Concurrent calls for the same id are coalesced via `_resolvingPlugins`:\n * the first caller starts the resolution, every subsequent caller awaits\n * the same `Deferred`. On failure we publish a `lazy:<id>` error message\n * and skip the atom swap so the failure is observable to the activation\n * subscriber and a retry can be attempted.\n */\n private _resolveLazyPlugin(plugin: Plugin.Plugin): Effect.Effect<Plugin.Plugin, Plugin.LazyPluginError> {\n return Effect.gen(this, function* () {\n if (!Plugin.isLazy(plugin)) {\n return plugin;\n }\n const id = plugin.meta.id;\n\n const existing = this._resolvingPlugins.get(id);\n if (existing) {\n return yield* Deferred.await(existing);\n }\n const deferred = yield* Deferred.make<Plugin.Plugin, Plugin.LazyPluginError>();\n this._resolvingPlugins.set(id, deferred);\n\n return yield* Effect.gen(this, function* () {\n log('resolving lazy plugin', { id });\n yield* PubSub.publish(this.activation, { event: '', state: 'activating', module: `lazy:${id}` });\n const resolvedPlugin = yield* Plugin.resolveLazy(plugin).pipe(\n // Cap how long a remote import can hang. Without this the host can\n // sit on a pending dynamic `import()` indefinitely if the plugin's\n // server is unreachable, which stalls every caller awaiting\n // `enable(id)` and (transitively) the manager's initialization.\n Effect.timeoutFail({\n duration: this._loadTimeout,\n onTimeout: () =>\n new Plugin.LazyPluginError({\n context: { id, reason: 'load-failed' },\n cause: new PluginTimeoutError({ context: { id, phase: 'load' as PluginFailurePhase } }),\n }),\n }),\n );\n this._update(this._pluginsAtom, (plugins) => plugins.map((p) => (p.meta.id === id ? resolvedPlugin : p)));\n yield* PubSub.publish(this.activation, { event: '', state: 'activated', module: `lazy:${id}` });\n return resolvedPlugin;\n }).pipe(\n Effect.tapError((error) =>\n Effect.gen(this, function* () {\n yield* PubSub.publish(this.activation, { event: '', state: 'error', module: `lazy:${id}`, error });\n this._recordFailure(id, 'load', error);\n this._scheduleAutoDisable(id);\n }),\n ),\n Effect.tap((value) => Deferred.succeed(deferred, value)),\n Effect.tapErrorCause((cause) => Deferred.failCause(deferred, cause)),\n Effect.ensuring(Effect.sync(() => this._resolvingPlugins.delete(id))),\n );\n });\n }\n\n /**\n * Removes a plugin from the manager.\n * @param id The id of the plugin.\n */\n remove(id: string): Effect.Effect<boolean, Error> {\n return Effect.gen(this, function* () {\n log('remove plugin', { id });\n const wasDev = this._devPlugins.has(id);\n const disabled = yield* this.disable(id);\n if (!disabled) {\n return false;\n }\n\n this._removePlugin(id);\n if (this._onRemove) {\n this._runForkedFiber(\n this._onRemove(id).pipe(\n Effect.tapError((error) => Effect.sync(() => log.warn('plugin remove hook failed', { id, error }))),\n Effect.ignore,\n ),\n );\n }\n\n // If a dev plugin was shadowing an existing plugin, reinstate the\n // original now that the dev plugin is gone. Re-enable only if the\n // original was enabled at shadow time — preserving the user's intent\n // for plugins they had explicitly disabled before iterating on a dev\n // build.\n if (wasDev) {\n const shadow = this._unmarkDev(id);\n if (shadow) {\n this._addPlugin(shadow.plugin);\n if (shadow.wasEnabled) {\n yield* this.enable(id);\n }\n }\n }\n return true;\n });\n }\n\n /**\n * Disables a plugin.\n * @param id The id of the plugin.\n */\n disable(id: string): Effect.Effect<boolean, Error> {\n return Effect.gen(this, function* () {\n log('disable plugin', { id });\n if (this._get(this._coreAtom).includes(id)) {\n return false;\n }\n\n const plugin = this._getPlugin(id);\n if (!plugin) {\n return false;\n }\n\n const enabledIndex = this._get(this._enabledAtom).findIndex((enabled) => enabled === id);\n if (enabledIndex !== -1) {\n this._update(this._enabledAtom, (enabled) => enabled.filter((item) => item !== id));\n yield* this.deactivate(id);\n\n plugin.modules.forEach((module) => {\n this._removeModule(module.id);\n });\n }\n\n return true;\n });\n }\n\n /**\n * Activates plugins based on the activation event.\n * @param event The activation event.\n * @returns Whether the activation was successful.\n */\n activate(\n event: ActivationEvent.ActivationEvent | string,\n params?: { before?: string; after?: string },\n ): Effect.Effect<boolean, Error> {\n const key = typeof event === 'string' ? event : ActivationEvent.eventKey(event);\n return Effect.gen(this, function* () {\n if (yield* this._isShuttingDown()) {\n log('skipping activation during shutdown', { key, ...params });\n return false;\n }\n\n // Wait for the constructor's core/enabled `enable()` chain — including\n // any async dynamic imports for lazy plugins — to finish registering\n // modules. Without this, dispatching to an empty module set is the\n // observable symptom of the race.\n yield* Deferred.await(this._initialization);\n\n return yield* Effect.withFiberRuntime<boolean, Error>((fiber) =>\n this._activateEvent(key, params, fiber).pipe(\n together(\n Effect.sleep(Duration.seconds(15)).pipe(\n Effect.andThen(Effect.sync(() => log.warn('event activation is taking a long time', { event: key }))),\n ),\n ),\n Performance.addTrackEntry({\n name: typeof event === 'string' ? event : ActivationEvent.eventKey(event),\n devtools: {\n dataType: 'track-entry',\n track: 'Event Activation',\n trackGroup: 'Composer',\n color: 'primary',\n },\n }),\n ),\n );\n });\n }\n\n /**\n * Deactivates all of the modules for a plugin.\n * @param id The id of the plugin.\n * @returns Whether the deactivation was successful.\n */\n deactivate(id: string): Effect.Effect<boolean, Error> {\n return Effect.gen(this, function* () {\n const plugin = this._getPlugin(id);\n if (!plugin) {\n return false;\n }\n\n const modules = plugin.modules;\n const results = yield* Effect.all(\n modules.map((module) => this._deactivateModule(module)),\n { concurrency: 'unbounded' },\n );\n return results.every((result) => result);\n });\n }\n\n /**\n * Re-activates the modules that were activated by the event.\n * @param event The activation event.\n * @returns Whether the reset was successful.\n */\n reset(event: ActivationEvent.ActivationEvent | string): Effect.Effect<boolean, Error> {\n return Effect.gen(this, function* () {\n const key = typeof event === 'string' ? event : ActivationEvent.eventKey(event);\n log('reset', { key });\n const modules = this._getActiveModulesByEvent(key);\n const results = yield* Effect.all(\n modules.map((module) => this._deactivateModule(module)),\n { concurrency: 'unbounded' },\n );\n\n if (results.every((result) => result)) {\n return yield* this.activate(key);\n } else {\n return false;\n }\n });\n }\n\n shutdown(): Effect.Effect<boolean, Error> {\n return this._shutdownSemaphore.withPermits(1)(\n Effect.gen(this, function* () {\n yield* Ref.set(this._shuttingDown, true);\n log('shutdown');\n\n yield* this._interruptInFlightActivations();\n\n const activeIds = [...this._get(this._activeAtom)].reverse();\n const allModules = this._get(this._modulesAtom);\n const modulesToDeactivate = activeIds\n .map((id) => allModules.find((module) => module.id === id))\n .filter((module): module is Plugin.PluginModule => module != null);\n\n for (const module of modulesToDeactivate) {\n yield* this._deactivateModule(module);\n }\n\n this._set(this._eventsFiredAtom, []);\n this._set(this._pendingResetAtom, []);\n this._moduleMemoMap.clear();\n yield* Ref.set(this._activatingEvents, []);\n yield* Ref.set(this._activatingModules, []);\n\n log('shutdown complete');\n return true;\n }).pipe(Effect.ensuring(Ref.set(this._shuttingDown, false))),\n );\n }\n\n //\n // State helpers\n //\n\n private _get<T>(atom: Atom.Atom<T>): T {\n return this.registry.get(atom);\n }\n\n private _set<T>(atom: Atom.Writable<T>, value: T): void {\n this.registry.set(atom, value);\n }\n\n private _update<T>(atom: Atom.Writable<T>, updater: (current: T) => T): void {\n this._set(atom, updater(this._get(atom)));\n }\n\n private _isShuttingDown(): Effect.Effect<boolean> {\n return Ref.get(this._shuttingDown);\n }\n\n private _getPlugin(id: string): Plugin.Plugin | undefined {\n return this._get(this._pluginsAtom).find((plugin) => plugin.meta.id === id);\n }\n\n private _getPluginIdForModule(moduleId: string): string | undefined {\n return this._get(this._pluginsAtom).find((plugin) => plugin.modules.some((module) => module.id === moduleId))?.meta\n .id;\n }\n\n /**\n * Records a failure for a plugin. Latest failure wins so the registry UI\n * always sees the most recent reason. Walks the `cause` chain when checking\n * for timeouts: lazy-load timeouts arrive wrapped in `LazyPluginError` (the\n * timeout is the cause), but the operator-visible reason should still be\n * `'timeout'`.\n */\n private _recordFailure(id: string, phase: PluginFailurePhase, error: Error): void {\n const reason: PluginFailureReason = isTimeoutCause(error) ? 'timeout' : 'error';\n const failure: PluginFailure = { id, phase, reason, error, timestamp: Date.now() };\n log.warn('plugin failed', { id, phase, reason, error: error.message });\n this._update(this._failedAtom, (current) => [...current.filter((entry) => entry.id !== id), failure]);\n }\n\n /**\n * Fire-and-forget disable of a failed plugin. Forked because a failure can\n * happen mid-activation chain — yielding a `disable` inline would deadlock\n * on the shared semaphores. Core plugins are skipped (the host opted into\n * them being non-removable; the failure record is enough signal).\n */\n private _scheduleAutoDisable(id: string): void {\n if (this._get(this._coreAtom).includes(id)) {\n return;\n }\n if (!this._get(this._enabledAtom).includes(id)) {\n return;\n }\n this._runForkedFiber(\n this.disable(id).pipe(\n Effect.tapError((error) => Effect.sync(() => log.warn('auto-disable failed', { id, error }))),\n Effect.ignore,\n ),\n );\n }\n\n private _getActiveModules(): Plugin.PluginModule[] {\n const active = this._get(this._activeAtom);\n return this._get(this._modulesAtom).filter((module) => active.includes(module.id));\n }\n\n private _getInactiveModules(): Plugin.PluginModule[] {\n const active = this._get(this._activeAtom);\n return this._get(this._modulesAtom).filter((module) => !active.includes(module.id));\n }\n\n private _getActiveModulesByEvent(key: string): Plugin.PluginModule[] {\n return this._getActiveModules().filter((module) =>\n ActivationEvent.getEvents(module.activatesOn).map(ActivationEvent.eventKey).includes(key),\n );\n }\n\n private _getInactiveModulesByEvent(key: string): Plugin.PluginModule[] {\n return this._getInactiveModules().filter((module) =>\n ActivationEvent.getEvents(module.activatesOn).map(ActivationEvent.eventKey).includes(key),\n );\n }\n\n private _setPendingResetByModule(module: Plugin.PluginModule): void {\n const activationEvents = ActivationEvent.getEvents(module.activatesOn)\n .map(ActivationEvent.eventKey)\n .filter((key) => this._get(this._eventsFiredAtom).includes(key));\n\n const pendingReset = Array.fromIterable(new Set(activationEvents)).filter((event) => {\n const pending = this._get(this._pendingResetAtom);\n return !pending.includes(event);\n });\n if (pendingReset.length > 0) {\n log('pending reset', { events: pendingReset });\n this._update(this._pendingResetAtom, (current) => [...current, ...pendingReset]);\n }\n }\n\n private _clearPendingReset(key: string): void {\n const pendingIndex = this._get(this._pendingResetAtom).findIndex((event) => event === key);\n if (pendingIndex !== -1) {\n this._update(this._pendingResetAtom, (pending) => pending.filter((event) => event !== key));\n }\n }\n\n //\n // Fiber helpers\n //\n\n private _interruptInFlightActivations(): Effect.Effect<void> {\n return Effect.gen(this, function* () {\n const inFlightFibers = yield* Ref.get(this._inFlightFibers);\n yield* Effect.forEach(inFlightFibers, (fiber) => Fiber.interrupt(fiber), {\n concurrency: 'unbounded',\n });\n });\n }\n\n private _trackFiber(\n ref: Ref.Ref<Array<Fiber.Fiber<unknown, unknown>>>,\n fiber: Fiber.Fiber<unknown, unknown>,\n ): Effect.Effect<void> {\n return Ref.update(ref, (fibers) => [...fibers, fiber]);\n }\n\n private _untrackFiber(\n ref: Ref.Ref<Array<Fiber.Fiber<unknown, unknown>>>,\n fiber: Fiber.Fiber<unknown, unknown>,\n ): Effect.Effect<void> {\n return Ref.update(ref, (fibers) => fibers.filter((trackedFiber) => trackedFiber !== fiber));\n }\n\n /**\n * Spawns an effect on the default runtime and registers the resulting fiber in\n * `_inFlightFibers` so {@link shutdown} can interrupt it. Used from sync entry\n * points like {@link remove} where there is no enclosing Effect to fork from;\n * inside an Effect chain prefer the existing track/await/untrack pattern.\n */\n private _runForkedFiber<E>(effect: Effect.Effect<void, E>): void {\n const fiber = Effect.runFork(effect);\n Effect.runSync(this._trackFiber(this._inFlightFibers, fiber));\n Effect.runFork(Fiber.await(fiber).pipe(Effect.andThen(() => this._untrackFiber(this._inFlightFibers, fiber))));\n }\n\n //\n // Registration helpers\n //\n\n private _addPlugin(plugin: Plugin.Plugin): void {\n log('add plugin', { id: plugin.meta.id });\n // TODO(wittjosiah): Find a way to add a warning for duplicate plugins that doesn't cause log spam.\n this._update(this._pluginsAtom, (plugins) => (plugins.includes(plugin) ? plugins : [...plugins, plugin]));\n }\n\n private _removePlugin(id: string): void {\n log('remove plugin', { id });\n this._update(this._pluginsAtom, (plugins) => plugins.filter((plugin) => plugin.meta.id !== id));\n }\n\n private _addModule(module: Plugin.PluginModule): void {\n log('add module', { id: module.id });\n // TODO(wittjosiah): Find a way to add a warning for duplicate modules that doesn't cause log spam.\n this._update(this._modulesAtom, (modules) => (modules.includes(module) ? modules : [...modules, module]));\n }\n\n private _removeModule(id: string): void {\n log('remove module', { id });\n this._update(this._modulesAtom, (modules) => modules.filter((module) => module.id !== id));\n }\n\n //\n // Activation helpers\n //\n\n private _activateEvent(\n key: string,\n params: { before?: string; after?: string } | undefined,\n fiber: Fiber.Fiber<unknown, unknown>,\n ): Effect.Effect<boolean, Error> {\n return Effect.gen(this, function* () {\n yield* this._trackFiber(this._inFlightFibers, fiber);\n log('activating', { key, ...params });\n yield* Ref.update(this._activatingEvents, (activating) => Array.append(activating, key));\n this._clearPendingReset(key);\n\n const activatingEvents = yield* this._activatingEvents;\n const activatingModules = yield* this._activatingModules;\n const modules = this._getModulesForActivation(key, activatingEvents, activatingModules);\n if (modules.length === 0) {\n log('no modules to activate', { key });\n if (!this._get(this._eventsFiredAtom).includes(key)) {\n this._update(this._eventsFiredAtom, (events) => [...events, key]);\n }\n return false;\n }\n\n return yield* this._activateModulesForEvent(key, modules, activatingEvents);\n }).pipe(\n Effect.ensuring(\n Effect.all([\n this._untrackFiber(this._inFlightFibers, fiber),\n Ref.update(this._activatingEvents, (activating) => Array.filter(activating, (event) => event !== key)),\n ]),\n ),\n );\n }\n\n private _activateModulesForEvent(\n key: string,\n modules: Plugin.PluginModule[],\n activatingEvents: string[],\n ): Effect.Effect<boolean, Error> {\n const activatingModuleIds = modules.map((module) => module.id);\n return Effect.gen(this, function* () {\n yield* Ref.update(this._activatingModules, (activating) => Array.appendAll(activating, activatingModuleIds));\n\n log('activating modules', { key, modules: activatingModuleIds });\n performance.mark(`event:${key}:start`);\n yield* PubSub.publish(this.activation, { event: key, state: 'activating' });\n\n yield* this._activateRelatedEvents(key, this._getBeforeEvents(modules, activatingEvents), 'before');\n\n const capabilities = yield* this._loadCapabilitiesForModules(key, modules);\n yield* this._contributeCapabilitiesForModules(modules, capabilities);\n\n yield* this._activateRelatedEvents(key, this._getAfterEvents(modules, activatingEvents), 'after');\n\n if (!this._get(this._eventsFiredAtom).includes(key)) {\n this._update(this._eventsFiredAtom, (events) => [...events, key]);\n }\n\n performance.mark(`event:${key}:end`);\n performance.measure(`event:${key}`, `event:${key}:start`, `event:${key}:end`);\n yield* PubSub.publish(this.activation, { event: key, state: 'activated' });\n log('activated', { key });\n\n return true;\n }).pipe(\n Effect.ensuring(\n Ref.update(this._activatingModules, (activating) =>\n Array.filter(activating, (module) => !activatingModuleIds.includes(module)),\n ),\n ),\n );\n }\n\n private _getModulesForActivation(\n key: string,\n activatingEvents: string[],\n activatingModules: string[],\n ): Plugin.PluginModule[] {\n return this._getInactiveModulesByEvent(key).filter((module) => {\n const allOf = ActivationEvent.isAllOf(module.activatesOn);\n if (!allOf) {\n return true;\n }\n\n // Check to see if all of the events in the `allOf` have been fired.\n // An event can be considered \"fired\" if it is in the `eventsFired` list or if it is currently being activated.\n const events = ActivationEvent.getEvents(module.activatesOn).filter(\n (event) => ActivationEvent.eventKey(event) !== key,\n );\n return (\n events.every(\n (event) =>\n this._get(this._eventsFiredAtom).includes(ActivationEvent.eventKey(event)) ||\n activatingEvents.includes(ActivationEvent.eventKey(event)),\n ) && !activatingModules.includes(module.id)\n );\n });\n }\n\n private _getBeforeEvents(\n modules: Plugin.PluginModule[],\n activatingEvents: string[],\n ): ActivationEvent.ActivationEvent[] {\n return Function.pipe(\n modules,\n Array.flatMap((module) => module.firesBeforeActivation ?? []),\n HashSet.fromIterable,\n HashSet.toValues,\n Array.filter((event) => !activatingEvents.includes(ActivationEvent.eventKey(event))),\n );\n }\n\n private _getAfterEvents(\n modules: Plugin.PluginModule[],\n activatingEvents: string[],\n ): ActivationEvent.ActivationEvent[] {\n return Function.pipe(\n modules,\n Array.flatMap((module) => module.firesAfterActivation ?? []),\n HashSet.fromIterable,\n HashSet.toValues,\n Array.filter((event) => !activatingEvents.includes(ActivationEvent.eventKey(event))),\n );\n }\n\n private _activateRelatedEvents(\n key: string,\n events: ActivationEvent.ActivationEvent[],\n phase: 'before' | 'after',\n ): Effect.Effect<void, Error> {\n const logLabel = phase === 'before' ? 'firesBeforeActivation' : 'firesAfterActivation';\n const eventKey = phase === 'before' ? 'beforeEvents' : 'afterEvents';\n return Function.pipe(\n events,\n Array.map((event) => this.activate(event, phase === 'before' ? { before: key } : { after: key })),\n Effect.allWith({ concurrency: 'unbounded' }),\n together(\n Effect.sleep(Duration.seconds(10)).pipe(\n Effect.andThen(\n Effect.sync(() =>\n log.warn(`${logLabel} is taking a long time`, {\n event: key,\n [eventKey]: events.map(ActivationEvent.eventKey),\n }),\n ),\n ),\n ),\n ),\n Effect.asVoid,\n );\n }\n\n //\n // Module lifecycle helpers\n //\n\n private _loadCapabilitiesForModules(\n key: string,\n modules: Plugin.PluginModule[],\n ): Effect.Effect<Capability.Any[][], Error> {\n return Function.pipe(\n modules,\n Array.map((mod) => this._loadModule(mod, key)),\n Effect.allWith({ concurrency: 'unbounded' }),\n Effect.catchAll((error) => {\n return Effect.gen(this, function* () {\n yield* PubSub.publish(this.activation, { event: key, state: 'error', error });\n return yield* Effect.fail(error);\n });\n }),\n );\n }\n\n private _contributeCapabilitiesForModules(\n modules: Plugin.PluginModule[],\n capabilities: Capability.Any[][],\n ): Effect.Effect<void, Error> {\n return Function.pipe(\n modules,\n Array.zip(capabilities),\n Array.map(([module, capabilitySet]) => this._contributeCapabilities(module, capabilitySet)),\n // TODO(wittjosiah): This currently can't be run in parallel, and inserting\n // any yield between contributions (`Effect.yieldNow()`, `Effect.sleep(0)`)\n // races the `allOf` activation-event resolver — observed as a System\n // Error dialog on warm reloads. Contributions must stay strictly\n // synchronous within an event; React paint slots have to be found at\n // event boundaries higher up the call chain.\n Effect.all,\n Effect.asVoid,\n );\n }\n\n private _getModuleSemaphore(moduleId: Plugin.PluginModule['id']): Effect.Semaphore {\n let semaphore = this._moduleSemaphores.get(moduleId);\n if (!semaphore) {\n semaphore = Effect.runSync(Effect.makeSemaphore(1));\n this._moduleSemaphores.set(moduleId, semaphore);\n }\n return semaphore;\n }\n\n // `parentEvent` is the activation event that first triggered this module\n // load — included in `activating`/`activated` PubSub messages so subscribers\n // (e.g. the boot loader's status listener) can associate a module with its\n // triggering event in the trace. The same module may be referenced by\n // multiple events, but module loads are memoized via `_moduleMemoMap`, so\n // only the first event to need it will appear here; later events await the\n // cached deferred without re-publishing.\n private _loadModule = (module: Plugin.PluginModule, parentEvent: string): Effect.Effect<Capability.Any[], Error> =>\n Effect.gen(this, function* () {\n const semaphore = this._getModuleSemaphore(module.id);\n\n // Atomically check-and-set under per-module semaphore to prevent race conditions.\n const deferredToAwait = yield* Effect.gen(this, function* () {\n const existing = this._moduleMemoMap.get(module.id);\n if (existing) {\n return existing;\n }\n\n // First caller - create deferred, store it, and start loading in background.\n const deferred = yield* Deferred.make<Capability.Any[], Error>();\n this._moduleMemoMap.set(module.id, deferred);\n\n const loadEffect = Effect.gen(this, function* () {\n log('loading module', { module: module.id, parentEvent });\n performance.mark(`module:${module.id}:start`);\n yield* PubSub.publish(this.activation, { event: parentEvent, state: 'activating', module: module.id });\n const pluginId = this._getPluginIdForModule(module.id);\n const [duration, capabilities] = yield* module.activate().pipe(\n Effect.provideService(Capability.Service, this.capabilities),\n Effect.provideService(Plugin.Service, this),\n // Cap activation so a single misbehaving module can't hold the\n // event chain open. On timeout the failure is recorded against\n // the plugin and surfaced as `PluginTimeoutError`.\n Effect.timeoutFail({\n duration: this._activationTimeout,\n onTimeout: () =>\n new PluginTimeoutError({\n context: { id: pluginId ?? module.id, module: module.id, phase: 'activation' as PluginFailurePhase },\n }),\n }),\n Effect.timed,\n );\n const normalized = capabilities == null ? [] : Array.isArray(capabilities) ? capabilities : [capabilities];\n const elapsed = Duration.toMillis(duration);\n performance.mark(`module:${module.id}:end`);\n performance.measure(`module:${module.id}`, `module:${module.id}:start`, `module:${module.id}:end`);\n yield* PubSub.publish(this.activation, { event: parentEvent, state: 'activated', module: module.id });\n log('loaded module', {\n module: module.id,\n parentEvent,\n elapsed,\n failed: false,\n });\n return normalized as Capability.Any[];\n }).pipe(\n Effect.withSpan('PluginManager._loadModule'),\n together(\n Effect.sleep(Duration.seconds(10)).pipe(\n Effect.andThen(\n Effect.sync(() => log.warn(`module is taking a long time to activate`, { module: module.id })),\n ),\n ),\n ),\n Performance.addTrackEntry({\n name: module.id,\n devtools: {\n dataType: 'track-entry',\n track: 'Module Activation',\n trackGroup: 'Composer',\n color: 'primary',\n },\n }),\n );\n\n // Fork the load to run in background, completing the deferred when done.\n const fiber = yield* Effect.forkDaemon(\n loadEffect.pipe(\n Effect.tap((result) => Deferred.succeed(deferred, result)),\n Effect.catchAllCause((cause) => {\n const error = Cause.squash(cause);\n log.error('module failed to activate', {\n module: module.id,\n error: error instanceof Error ? error.message : String(error),\n stack: error instanceof Error ? error.stack : undefined,\n isDefect: !Cause.isFailure(cause),\n });\n const normalizedError = error instanceof Error ? error : new Error(String(error));\n const pluginId = this._getPluginIdForModule(module.id);\n if (pluginId !== undefined) {\n this._recordFailure(pluginId, 'activation', normalizedError);\n this._scheduleAutoDisable(pluginId);\n }\n return Deferred.fail(deferred, normalizedError);\n }),\n ),\n );\n yield* this._trackFiber(this._inFlightFibers, fiber);\n yield* Effect.forkDaemon(\n Fiber.await(fiber).pipe(Effect.andThen(() => this._untrackFiber(this._inFlightFibers, fiber))),\n );\n\n return deferred;\n }).pipe(semaphore.withPermits(1));\n\n // Wait for result outside the semaphore so multiple waiters can proceed concurrently.\n return yield* Deferred.await(deferredToAwait);\n });\n\n private _contributeCapabilities(\n module: Plugin.PluginModule,\n capabilities: Capability.Any[],\n ): Effect.Effect<void, Error> {\n return Effect.gen(this, function* () {\n capabilities.forEach((capability) => {\n this.capabilities.contribute({ module: module.id, ...capability });\n });\n this._update(this._activeAtom, (active) => [...active, module.id]);\n this._capabilities.set(module.id, capabilities);\n });\n }\n\n private _deactivateModule(module: Plugin.PluginModule): Effect.Effect<boolean, Error> {\n return Effect.gen(this, function* () {\n const id = module.id;\n log('deactivating', { id });\n this._moduleMemoMap.delete(id);\n\n const capabilities = this._capabilities.get(id);\n if (capabilities) {\n for (const capability of capabilities) {\n this.capabilities.remove(capability.interface, capability.implementation);\n const program = capability.deactivate?.() ?? Effect.succeed(undefined);\n yield* program;\n }\n this._capabilities.delete(id);\n }\n\n const activeIndex = this._get(this._activeAtom).findIndex((event) => event === id);\n if (activeIndex !== -1) {\n this._update(this._activeAtom, (active) => active.filter((event) => event !== id));\n }\n\n log('deactivated', { id });\n return true;\n });\n }\n}\n\n/**\n * Creates a new Plugin Manager instance.\n */\nexport const make = (options: ManagerOptions): PluginManager => new ManagerImpl(options);\n\n/**\n * True when `error` (or anything along its `cause` chain) is a\n * {@link PluginTimeoutError}. Lazy-load timeouts wrap the timeout inside\n * `LazyPluginError`, so a shallow check on the outer error misses them.\n * Bounded depth so a circular chain can't loop forever.\n */\nconst isTimeoutCause = (error: unknown, depth = 0): boolean => {\n if (depth > 5 || !(error instanceof Error)) {\n return false;\n }\n if (PluginTimeoutError.is(error)) {\n return true;\n }\n return isTimeoutCause((error as Error & { cause?: unknown }).cause, depth + 1);\n};\n\n/**\n * Runs an effect concurrently with another effect.\n * If the first effect completes, the second effect is interrupted.\n */\n// TODO(dmaretskyi): Effect.race > Effect.asVoid\nconst together =\n <R1>(togetherEffect: Effect.Effect<void, never, R1>) =>\n <A, E, R2>(effect: Effect.Effect<A, E, R2>): Effect.Effect<A, E, R1 | R2> =>\n Effect.gen(function* () {\n const togetherFiber = yield* Effect.fork(togetherEffect);\n const result = yield* effect;\n yield* Fiber.interrupt(togetherFiber);\n return result;\n });\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Atom, type Registry } from '@effect-atom/atom-react';\nimport * as Deferred from 'effect/Deferred';\nimport * as Effect from 'effect/Effect';\n\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\n\nimport type * as Capability from './capability';\n\ntype CapabilityEntry<T> = {\n moduleId: string;\n implementation: T;\n};\n\n/**\n * Options for creating a capability manager.\n * @internal\n */\nexport type CapabilityManagerOptions = {\n registry: Registry.Registry;\n};\n\n/**\n * Interface for the Capability Manager.\n * Provides methods for contributing, removing, and accessing capabilities.\n */\nexport interface CapabilityManager {\n contribute<T>(args: { module: string; interface: Capability.InterfaceDef<T>; implementation: T }): void;\n\n remove<T>(interfaceDef: Capability.InterfaceDef<T>, implementation: T): void;\n\n /**\n * Get the Atom reference to the available capabilities for a given interface.\n * Primarily useful for deriving other Atom values based on the capabilities or\n * for subscribing to changes in the capabilities.\n * @returns An atom reference to the available capabilities.\n */\n atom<T>(interfaceDef: Capability.InterfaceDef<T>): Atom.Atom<T[]>;\n\n /**\n * Get capabilities from the capability manager.\n * @returns An array of capabilities.\n */\n getAll<T>(interfaceDef: Capability.InterfaceDef<T>): T[];\n\n /**\n * Requests a single capability from the capability manager.\n * @returns The capability.\n * @throws If no capability is found.\n */\n get<T>(interfaceDef: Capability.InterfaceDef<T>): T;\n\n /**\n * Waits for a capability to be available.\n * @returns The capability.\n */\n waitFor<T>(interfaceDef: Capability.InterfaceDef<T>): Effect.Effect<T, Error>;\n\n /**\n * Get capabilities grouped by the module that contributed them.\n * @returns An atom containing a record from module ID to capability implementations.\n */\n atomByModule<T>(interfaceDef: Capability.InterfaceDef<T>): Atom.Atom<Record<string, T[]>>;\n}\n\n/**\n * Internal implementation of CapabilityManager.\n */\nclass CapabilityManagerImpl implements CapabilityManager {\n private readonly _registry: Registry.Registry;\n\n private readonly _capabilityEntries = Atom.family<string, Atom.Writable<CapabilityEntry<unknown>[]>>(() => {\n return Atom.make<CapabilityEntry<unknown>[]>([]).pipe(Atom.keepAlive);\n });\n\n readonly _capabilities = Atom.family<string, Atom.Atom<unknown[]>>((id: string) => {\n return Atom.make((get) => {\n const current = get(this._capabilityEntries(id));\n return current.map((c) => c.implementation);\n }).pipe(Atom.keepAlive);\n });\n\n readonly _capabilitiesByModule = Atom.family<string, Atom.Atom<Record<string, unknown[]>>>((id: string) => {\n return Atom.make((get) => {\n const entries = get(this._capabilityEntries(id));\n const result: Record<string, unknown[]> = {};\n for (const entry of entries) {\n (result[entry.moduleId] ??= []).push(entry.implementation);\n }\n return result;\n }).pipe(Atom.keepAlive);\n });\n\n readonly _capability = Atom.family<string, Atom.Atom<unknown>>((id: string) => {\n return Atom.make((get) => {\n const current = get(this._capabilities(id));\n invariant(current.length > 0, `No capability found for ${id}`);\n return current[0];\n });\n });\n\n constructor({ registry }: CapabilityManagerOptions) {\n this._registry = registry;\n }\n\n contribute<T>({\n module: moduleId,\n interface: interfaceDef,\n implementation,\n }: {\n module: string;\n interface: Capability.InterfaceDef<T>;\n implementation: T;\n }): void {\n const current = this._registry.get(this._capabilityEntries(interfaceDef.identifier));\n const isDuplicate = current.some((c) => c.moduleId === moduleId && c.implementation === implementation);\n if (isDuplicate) {\n log('capability already contributed, skipping', { id: interfaceDef.identifier, moduleId });\n return;\n }\n\n const entry: CapabilityEntry<T> = { moduleId, implementation };\n this._registry.set(this._capabilityEntries(interfaceDef.identifier), [...current, entry]);\n log('capability contributed', {\n id: interfaceDef.identifier,\n moduleId,\n count: current.length,\n });\n }\n\n remove<T>(interfaceDef: Capability.InterfaceDef<T>, implementation: T): void {\n const current = this._registry.get(this._capabilityEntries(interfaceDef.identifier));\n if (current.length === 0) {\n return;\n }\n\n const next = current.filter((c) => c.implementation !== implementation);\n if (next.length !== current.length) {\n this._registry.set(this._capabilityEntries(interfaceDef.identifier), next);\n log('capability removed', { id: interfaceDef.identifier, count: current.length });\n } else {\n log.warn('capability not removed', { id: interfaceDef.identifier });\n }\n }\n\n atom<T>(interfaceDef: Capability.InterfaceDef<T>): Atom.Atom<T[]> {\n // NOTE: This the type-checking for capabilities is done at the time of contribution.\n return this._capabilities(interfaceDef.identifier) as Atom.Atom<T[]>;\n }\n\n getAll<T>(interfaceDef: Capability.InterfaceDef<T>): T[] {\n return this._registry.get(this.atom(interfaceDef));\n }\n\n get<T>(interfaceDef: Capability.InterfaceDef<T>): T {\n const capabilities = this.getAll(interfaceDef);\n invariant(capabilities.length > 0, `No capability found for ${interfaceDef.identifier}`);\n return capabilities[0];\n }\n\n waitFor<T>(interfaceDef: Capability.InterfaceDef<T>): Effect.Effect<T, Error> {\n return Effect.gen(this, function* () {\n const [capability] = this.getAll(interfaceDef);\n if (capability) {\n return capability;\n }\n\n const deferred = yield* Deferred.make<T, Error>();\n const cancel = this._registry.subscribe(this.atom(interfaceDef), (capabilities) => {\n if (capabilities.length > 0) {\n Effect.runSync(Deferred.succeed(deferred, capabilities[0]));\n }\n });\n const result = yield* Deferred.await(deferred);\n cancel();\n return result;\n });\n }\n\n atomByModule<T>(interfaceDef: Capability.InterfaceDef<T>): Atom.Atom<Record<string, T[]>> {\n return this._capabilitiesByModule(interfaceDef.identifier) as Atom.Atom<Record<string, T[]>>;\n }\n}\n\n/**\n * Creates a new Capability Manager instance.\n */\nexport const make = (options: CapabilityManagerOptions): CapabilityManager => new CapabilityManagerImpl(options);\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { Atom, type Registry as AtomRegistry } from '@effect-atom/atom-react';\nimport * as Effect from 'effect/Effect';\n\nimport { runAndForwardErrors } from '@dxos/effect';\nimport { log } from '@dxos/log';\n\n/**\n * A registry plugin entry as seen by the plugin manager layer.\n * Populated from the registry catalog; represents the latest available version of a plugin.\n *\n * Independently defined from @dxos/protocols PluginEntry — similar shape but not the same type.\n * Implementations of {@link PluginProvider} (e.g. {@link EdgeRegistryPluginProvider})\n * are responsible for mapping their wire-format entries to this shape.\n */\nexport type Plugin = {\n id: string;\n name: string;\n description?: string;\n homePage?: string;\n source?: string;\n screenshots?: string[];\n tags?: string[];\n icon?: string;\n iconHue?: string;\n /** URL to dynamic-import the latest version of this plugin module. */\n moduleUrl: string;\n /** GitHub repository slug, e.g. `owner/name`. Used to fetch version history. */\n repo: string;\n /**\n * Latest known version string, e.g. `v1.2.0`.\n * Corresponds to releaseTag in the wire-format PluginEntry; named `version` here\n * because the plugin manager layer speaks versions, not release tags.\n */\n version: string;\n};\n\n/**\n * A single installable version of a registry plugin.\n */\nexport type PluginVersion = {\n /** Version string, e.g. `v1.2.0`. */\n tag: string;\n /** URL to dynamic-import this specific version of the plugin module. */\n moduleUrl: string;\n /** Unix ms of when this version was published (optional; omitted when unknown). */\n releasedAt?: number;\n};\n\n/**\n * Abstraction over the plugin registry catalog backend.\n * Implementations may call Edge, a local cache, or a stub.\n *\n * The interface itself is transport-agnostic; concrete implementations live\n * alongside it in this package (see {@link EdgeRegistryPluginProvider}) so we\n * avoid `app-framework ↔ edge-client` cycles, but they only need to satisfy\n * this shape — callers can substitute their own.\n */\nexport interface PluginProvider {\n /**\n * Returns all healthy registry plugins (latest version of each).\n */\n listPlugins(): Effect.Effect<readonly Plugin[], Error>;\n\n /**\n * Returns all known versions of a plugin identified by its GitHub repo slug.\n * Until the backend implements a versions endpoint, implementations MUST\n * return at least one entry representing the current/latest release.\n */\n listVersions(repo: string): Effect.Effect<readonly PluginVersion[], Error>;\n\n /**\n * Returns a single plugin entry for the given repo.\n * If `version` is omitted, returns the latest.\n * Fails if the specified version is not found.\n */\n getPlugin(repo: string, version?: string): Effect.Effect<Plugin, Error>;\n}\n\n/**\n * Atomic snapshot of the registry catalog as observed by the host.\n * Exposed via {@link Manager.plugins} so consumers can subscribe reactively\n * (loading state, list contents, last error).\n */\nexport type PluginsState = {\n entries: readonly Plugin[];\n loading: boolean;\n error: Error | null;\n};\n\n/**\n * Default no-op provider used when no `PluginProvider` is supplied at construction\n * time (e.g. tests, stories, environments without an Edge connection).\n *\n * `listPlugins` returns an empty list (so `Manager.plugins` settles to a stable\n * empty state). `listVersions` and `getPlugin` fail with an explicit error so\n * callers know they need to configure a real provider.\n */\nconst NULL_PROVIDER: PluginProvider = {\n listPlugins: () => Effect.succeed([] as readonly Plugin[]),\n listVersions: () => Effect.fail(new Error('No plugin registry provider configured')),\n getPlugin: () => Effect.fail(new Error('No plugin registry provider configured')),\n};\n\n/**\n * Owns the cached registry catalog state and forwards `listVersions` / `getPlugin`\n * calls to the underlying {@link PluginProvider}. Lives on the `PluginManager`\n * (as `manager.pluginRegistry`) so consumers can reach it through the manager\n * without a separate capability lookup.\n *\n * On construction the manager kicks off a background fetch via `provider.listPlugins()`\n * and writes the result into the {@link plugins} atom. Subscribers see `loading: true`\n * during the fetch and `loading: false` once it settles.\n */\nexport class Manager {\n readonly plugins: Atom.Writable<PluginsState>;\n readonly #provider: PluginProvider;\n\n constructor(provider: PluginProvider | undefined, atomRegistry: AtomRegistry.Registry) {\n this.#provider = provider ?? NULL_PROVIDER;\n const initialLoading = provider !== undefined;\n this.plugins = Atom.make<PluginsState>({ entries: [], loading: initialLoading, error: null }).pipe(Atom.keepAlive);\n\n if (provider !== undefined) {\n // Fire-and-forget initial load. Errors are surfaced via the atom's `error` field.\n void runAndForwardErrors(\n provider.listPlugins().pipe(\n Effect.match({\n onSuccess: (entries) => atomRegistry.set(this.plugins, { entries, loading: false, error: null }),\n onFailure: (error) => {\n log.catch(error);\n atomRegistry.set(this.plugins, { entries: [], loading: false, error });\n },\n }),\n ),\n );\n }\n }\n\n /** Forwards to the underlying provider. */\n listPlugins(): Effect.Effect<readonly Plugin[], Error> {\n return this.#provider.listPlugins();\n }\n\n /** Forwards to the underlying provider. */\n listVersions(repo: string): Effect.Effect<readonly PluginVersion[], Error> {\n return this.#provider.listVersions(repo);\n }\n\n /** Forwards to the underlying provider. */\n getPlugin(repo: string, version?: string): Effect.Effect<Plugin, Error> {\n return this.#provider.getPlugin(repo, version);\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;;cAAAA;;AAIA,SAASC,QAAAA,OAAMC,gBAAgB;AAC/B,YAAYC,WAAW;AACvB,YAAYC,WAAW;AACvB,YAAYC,eAAc;AAC1B,YAAYC,cAAc;AAC1B,YAAYC,aAAY;AACxB,YAAYC,WAAW;AACvB,YAAYC,cAAc;AAC1B,YAAYC,aAAa;AACzB,YAAYC,YAAY;AACxB,YAAYC,SAAS;AAErB,SAASC,uBAA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F,CAAA;EAEA;;;IAaI,iBAAO,CAAA,OAAA,QAAA,MAAA;AACT,MAAA,QAAA,KAAA,EAAA,iBAAA,QAAA;AACIuF,WAAAA;;AAEJ,MAAA,mBAAA,GAAA,KAAA,GAAA;AACA,WAAOmH;EACT;AAEA,SAAA,eAAA,MAAA,OAAA,QAAA,CAAA;;eAUM,CAAMC,mBAAgBC,CAAAA,WAAAA,YAAAA,aAAAA;AACtB,QAAA,gBAAsB,OAACC,aAAAA,cAAAA;AACvB,QAAA,SAAOF,OAAAA;AACT,SAAA,gBAAA,aAAA;;;",
|
|
6
|
+
"names": ["make", "Atom", "Registry", "Array", "Cause", "Deferred", "Duration", "Effect", "Fiber", "Function", "HashSet", "PubSub", "Ref", "runAndForwardErrors", "Performance", "BaseError", "log", "make", "Atom", "Deferred", "Effect", "invariant", "log", "_capabilityEntries", "family", "_capabilities", "id", "current", "c", "pipe", "keepAlive", "_capabilitiesByModule", "get", "result", "entry", "entries", "_capability", "length", "contribute", "moduleId", "isDuplicate", "implementation", "interfaceDef", "count", "remove", "_registry", "set", "identifier", "atom", "getAll", "capabilities", "waitFor", "capability", "deferred", "runSync", "cancel", "atomByModule", "Atom", "Effect", "runAndForwardErrors", "log", "__dxlog_file", "listVersions", "getPlugin", "fail", "Error", "initialLoading", "provider", "plugins", "entries", "loading", "error", "pipe", "keepAlive", "onFailure", "atomRegistry", "__dxlog_file", "DEFAULT_LOAD_TIMEOUT", "seconds", "activation", "Effect", "capabilities", "registry", "pluginRegistry", "_pluginsAtom", "_coreAtom", "_enabledAtom", "_modulesAtom", "_activeAtom", "_eventsFiredAtom", "_pendingResetAtom", "_failedAtom", "_pluginLoader", "_onRemove", "_loadTimeout", "_activationTimeout", "_capabilities", "_moduleMemoMap", "_moduleSemaphores", "Map", "_activatingEvents", "_activatingModules", "_inFlightFibers", "runSync", "make", "_shutdownSemaphore", "makeSemaphore", "_shuttingDown", "CapabilityManager", "onRemove", "loadTimeout", "Atom", "enabled", "pipe", "keepAlive", "_devPluginIdsAtom", "plugins", "plugin", "_addPlugin", "core", "tap", "Deferred", "succeed", "_initialization", "undefined", "tapErrorCause", "failCause", "runAndForwardErrors", "getPlugins", "getCore", "getEnabled", "getModules", "getActive", "getEventsFired", "getPendingReset", "getFailed", "getDevPluginIds", "id", "_update", "shadow", "clearFailure", "current", "some", "log", "pluginId", "meta", "existing", "_getPlugin", "dev", "disable", "_markDev", "wasEnabled", "modules", "_setPendingResetByModule", "concurrency", "isLazy", "deferred", "module", "resolvedPlugin", "onTimeout", "context", "reason", "cause", "PluginTimeoutError", "phase", "event", "error", "value", "disabled", "_removePlugin", "_runForkedFiber", "enable", "enabledIndex", "filter", "item", "deactivate", "forEach", "_removeModule", "gen", "_isShuttingDown", "key", "Performance", "addTrackEntry", "name", "devtools", "dataType", "track", "trackGroup", "color", "every", "results", "map", "shutdown", "_interruptInFlightActivations", "activeIds", "_get", "reverse", "allModules", "modulesToDeactivate", "_deactivateModule", "Ref", "set", "_set", "atom", "updater", "_getPluginIdForModule", "moduleId", "failure", "timestamp", "warn", "entry", "_getActiveModules", "_getInactiveModules", "_getActiveModulesByEvent", "_getInactiveModulesByEvent", "Array", "fromIterable", "includes", "pendingReset", "length", "_clearPendingReset", "pendingIndex", "pending", "inFlightFibers", "_trackFiber", "fibers", "fiber", "_untrackFiber", "await", "_addModule", "activatingEvents", "activatingModules", "_getModulesForActivation", "events", "_activateModulesForEvent", "activating", "activatingModuleIds", "performance", "mark", "publish", "_contributeCapabilitiesForModules", "_activateRelatedEvents", "PubSub", "ensuring", "update", "ActivationEvent", "allOf", "_getBeforeEvents", "_getAfterEvents", "after", "together", "sleep", "eventKey", "catchAll", "_getModuleSemaphore", "semaphore", "deferredToAwait", "loadEffect", "parentEvent", "Service", "timed", "normalized", "elapsed", "failed", "withSpan", "stack", "isDefect", "isFailure", "normalizedError", "_recordFailure", "_scheduleAutoDisable", "withPermits", "_contributeCapabilities", "capability", "get", "program", "activeIndex", "active", "isTimeoutCause", "result", "effect", "togetherFiber"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import {
|
|
2
|
+
capability_exports
|
|
3
|
+
} from "./chunk-3JWJXGLK.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__export
|
|
6
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
7
|
+
|
|
8
|
+
// src/common/capabilities.ts
|
|
9
|
+
var capabilities_exports = {};
|
|
10
|
+
__export(capabilities_exports, {
|
|
11
|
+
AtomRegistry: () => AtomRegistry,
|
|
12
|
+
Command: () => Command,
|
|
13
|
+
HistoryTracker: () => HistoryTracker,
|
|
14
|
+
Layer: () => Layer,
|
|
15
|
+
ManagedRuntime: () => ManagedRuntime,
|
|
16
|
+
Null: () => Null,
|
|
17
|
+
OperationHandler: () => OperationHandler,
|
|
18
|
+
OperationInvoker: () => OperationInvoker,
|
|
19
|
+
PluginManager: () => PluginManager,
|
|
20
|
+
ReactContext: () => ReactContext,
|
|
21
|
+
ReactRoot: () => ReactRoot,
|
|
22
|
+
ReactSurface: () => ReactSurface,
|
|
23
|
+
UndoMapping: () => UndoMapping,
|
|
24
|
+
UndoRegistry: () => UndoRegistry,
|
|
25
|
+
getAtomValue: () => getAtomValue,
|
|
26
|
+
subscribeAtom: () => subscribeAtom,
|
|
27
|
+
updateAtomValue: () => updateAtomValue
|
|
28
|
+
});
|
|
29
|
+
import * as Effect from "effect/Effect";
|
|
30
|
+
var Null = capability_exports.make("org.dxos.app-framework.capability.null");
|
|
31
|
+
var PluginManager = capability_exports.make("org.dxos.app-framework.capability.plugin-manager");
|
|
32
|
+
var AtomRegistry = capability_exports.make("org.dxos.app-framework.capability.atom-registry");
|
|
33
|
+
var ReactContext = capability_exports.make("org.dxos.app-framework.capability.react-context");
|
|
34
|
+
var ReactRoot = capability_exports.make("org.dxos.app-framework.capability.react-root");
|
|
35
|
+
var ReactSurface = capability_exports.make("org.dxos.app-framework.common.react-surface");
|
|
36
|
+
var Command = capability_exports.make("org.dxos.app-framework.capability.command");
|
|
37
|
+
var Layer = capability_exports.make("org.dxos.app-framework.capability.layer");
|
|
38
|
+
var ManagedRuntime = capability_exports.make("org.dxos.app-framework.capability.managed-runtime");
|
|
39
|
+
var OperationHandler = capability_exports.make("org.dxos.app-framework.capability.operation-handler");
|
|
40
|
+
var UndoMapping = capability_exports.make("org.dxos.app-framework.capability.undo-mapping");
|
|
41
|
+
var OperationInvoker = capability_exports.make("org.dxos.app-framework.capability.operation-invoker");
|
|
42
|
+
var UndoRegistry = capability_exports.make("org.dxos.app-framework.capability.undo-registry");
|
|
43
|
+
var HistoryTracker = capability_exports.make("org.dxos.app-framework.capability.history-tracker");
|
|
44
|
+
var getAtomValue = (atomCapability) => Effect.gen(function* () {
|
|
45
|
+
const registry = yield* capability_exports.get(AtomRegistry);
|
|
46
|
+
const atom = yield* capability_exports.get(atomCapability);
|
|
47
|
+
return registry.get(atom);
|
|
48
|
+
});
|
|
49
|
+
var updateAtomValue = (atomCapability, fn) => Effect.gen(function* () {
|
|
50
|
+
const registry = yield* capability_exports.get(AtomRegistry);
|
|
51
|
+
const atom = yield* capability_exports.get(atomCapability);
|
|
52
|
+
registry.set(atom, fn(registry.get(atom)));
|
|
53
|
+
});
|
|
54
|
+
var subscribeAtom = (atomCapability, callback) => Effect.gen(function* () {
|
|
55
|
+
const registry = yield* capability_exports.get(AtomRegistry);
|
|
56
|
+
const atom = yield* capability_exports.get(atomCapability);
|
|
57
|
+
return registry.subscribe(atom, () => callback(registry.get(atom)));
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export {
|
|
61
|
+
Null,
|
|
62
|
+
PluginManager,
|
|
63
|
+
AtomRegistry,
|
|
64
|
+
ReactContext,
|
|
65
|
+
ReactRoot,
|
|
66
|
+
ReactSurface,
|
|
67
|
+
Command,
|
|
68
|
+
Layer,
|
|
69
|
+
ManagedRuntime,
|
|
70
|
+
OperationHandler,
|
|
71
|
+
UndoMapping,
|
|
72
|
+
OperationInvoker,
|
|
73
|
+
UndoRegistry,
|
|
74
|
+
HistoryTracker,
|
|
75
|
+
getAtomValue,
|
|
76
|
+
updateAtomValue,
|
|
77
|
+
subscribeAtom,
|
|
78
|
+
capabilities_exports
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=chunk-WBHCSOBW.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/common/capabilities.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Atom, type Registry } from '@effect-atom/atom-react';\nimport type * as Command$ from '@effect/cli/Command';\nimport * as Effect from 'effect/Effect';\nimport type * as Layer$ from 'effect/Layer';\nimport type * as ManagedRuntime$ from 'effect/ManagedRuntime';\nimport type { FC, PropsWithChildren } from 'react';\n\nimport type { OperationHandlerSet } from '@dxos/compute';\nimport { OperationInvoker as OperationInvoker$ } from '@dxos/operation';\n\nimport { Capability as Capability$, type PluginManager as PluginManager$ } from '../core';\nimport type {\n HistoryTracker as HistoryTracker$,\n UndoMapping as UndoMapping$,\n UndoRegistry as UndoRegistry$,\n} from '../plugin-operation';\nimport type { Surface } from '../ui';\n\n/**\n * Null capability.\n * @category Capability\n */\nexport const Null = Capability$.make<null>('org.dxos.app-framework.capability.null');\n\n/**\n * @category Capability\n */\nexport const PluginManager = Capability$.make<PluginManager$.PluginManager>(\n 'org.dxos.app-framework.capability.plugin-manager',\n);\n\n/**\n * @category Capability\n */\nexport const AtomRegistry = Capability$.make<Registry.Registry>('org.dxos.app-framework.capability.atom-registry');\n\nexport type ReactContext = Readonly<{\n id: string;\n dependsOn?: string[];\n context: FC<PropsWithChildren>;\n}>;\n\n/**\n * @category Capability\n */\nexport const ReactContext = Capability$.make<ReactContext>('org.dxos.app-framework.capability.react-context');\n\nexport type ReactRoot = Readonly<{ id: string; root: FC<PropsWithChildren> }>;\n\n/**\n * @category Capability\n */\nexport const ReactRoot = Capability$.make<ReactRoot>('org.dxos.app-framework.capability.react-root');\n\n/**\n * Surface definitions that can be either React components or Web Components.\n */\nexport type ReactSurface = Surface.Definition | readonly Surface.Definition[];\n\n/**\n * @category Capability\n */\nexport const ReactSurface = Capability$.make<ReactSurface>('org.dxos.app-framework.common.react-surface');\n\nexport type AnyCommand = Command$.Command<any, any, any, any>;\n\n/**\n * @category Capability\n */\nexport const Command = Capability$.make<AnyCommand>('org.dxos.app-framework.capability.command');\n\n/**\n * @category Capability\n */\nexport const Layer = Capability$.make<Layer$.Layer<any, any, any>>('org.dxos.app-framework.capability.layer');\n\nexport type ManagedRuntime = ManagedRuntime$.ManagedRuntime<any, any>;\n\n/**\n * @category Capability\n */\nexport const ManagedRuntime = Capability$.make<ManagedRuntime>('org.dxos.app-framework.capability.managed-runtime');\n\n//\n// Operation System Capabilities\n//\n\nexport const OperationHandler = Capability$.make<OperationHandlerSet.OperationHandlerSet>(\n 'org.dxos.app-framework.capability.operation-handler',\n);\n\nexport type UndoMapping = UndoMapping$.UndoMapping;\n\n/**\n * Undo mapping registration - contributed by plugins.\n * @category Capability\n */\nexport const UndoMapping = Capability$.make<UndoMapping[]>('org.dxos.app-framework.capability.undo-mapping');\n\nexport type OperationInvoker = OperationInvoker$.OperationInvoker;\n\n/**\n * Operation invoker - provided by OperationPlugin.\n * @category Capability\n */\nexport const OperationInvoker = Capability$.make<OperationInvoker>(\n 'org.dxos.app-framework.capability.operation-invoker',\n);\n\nexport type UndoRegistry = UndoRegistry$.UndoRegistry;\n\n/**\n * Undo registry - provided by OperationPlugin.\n * @category Capability\n */\nexport const UndoRegistry = Capability$.make<UndoRegistry>('org.dxos.app-framework.capability.undo-registry');\n\nexport type HistoryTracker = HistoryTracker$.HistoryTracker;\n\n/**\n * History tracker - provided by OperationPlugin.\n * @category Capability\n */\nexport const HistoryTracker = Capability$.make<HistoryTracker>('org.dxos.app-framework.capability.history-tracker');\n\n//\n// Atom Capability Helpers\n//\n\n/**\n * Get the current value of an atom capability.\n * @example const settings = yield* Capabilities.getAtomValue(ThreadCapabilities.Settings);\n */\nexport const getAtomValue = <T>(\n atomCapability: Capability$.InterfaceDef<Atom.Atom<T>>,\n): Effect.Effect<T, Error, Capability$.Service> =>\n Effect.gen(function* () {\n const registry = yield* Capability$.get(AtomRegistry);\n const atom = yield* Capability$.get(atomCapability);\n return registry.get(atom);\n });\n\n/**\n * Update an atom capability value (requires writable atom).\n * @example yield* Capabilities.updateAtomValue(ThreadCapabilities.Settings, (s) => ({ ...s, foo: true }));\n */\nexport const updateAtomValue = <T>(\n atomCapability: Capability$.InterfaceDef<Atom.Writable<T>>,\n fn: (current: T) => T,\n): Effect.Effect<void, Error, Capability$.Service> =>\n Effect.gen(function* () {\n const registry = yield* Capability$.get(AtomRegistry);\n const atom = yield* Capability$.get(atomCapability);\n registry.set(atom, fn(registry.get(atom)));\n });\n\n/**\n * Subscribe to an atom capability.\n * @example const unsubscribe = yield* Capabilities.subscribeAtom(ThreadCapabilities.Settings, (value) => ...);\n */\nexport const subscribeAtom = <T>(\n atomCapability: Capability$.InterfaceDef<Atom.Atom<T>>,\n callback: (value: T) => void,\n): Effect.Effect<() => void, Error, Capability$.Service> =>\n Effect.gen(function* () {\n const registry = yield* Capability$.get(AtomRegistry);\n const atom = yield* Capability$.get(atomCapability);\n return registry.subscribe(atom, () => callback(registry.get(atom)));\n });\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;AAMA,YAAYA,YAAY;AAoBjB,IAAMC,OAAOC,mBAAYC,KAAW,wCAAA;AAKpC,IAAMC,gBAAgBF,mBAAYC,KACvC,kDAAA;AAMK,IAAME,eAAeH,mBAAYC,KAAwB,iDAAA;AAWzD,IAAMG,eAAeJ,mBAAYC,KAAmB,iDAAA;AAOpD,IAAMI,YAAYL,mBAAYC,KAAgB,8CAAA;AAU9C,IAAMK,eAAeN,mBAAYC,KAAmB,6CAAA;AAOpD,IAAMM,UAAUP,mBAAYC,KAAiB,2CAAA;AAK7C,IAAMO,QAAQR,mBAAYC,KAAkC,yCAAA;AAO5D,IAAMQ,iBAAiBT,mBAAYC,KAAqB,mDAAA;AAMxD,IAAMS,mBAAmBV,mBAAYC,KAC1C,qDAAA;AASK,IAAMU,cAAcX,mBAAYC,KAAoB,gDAAA;AAQpD,IAAMW,mBAAmBZ,mBAAYC,KAC1C,qDAAA;AASK,IAAMY,eAAeb,mBAAYC,KAAmB,iDAAA;AAQpD,IAAMa,iBAAiBd,mBAAYC,KAAqB,mDAAA;AAUxD,IAAMc,eAAe,CAC1BC,mBAEOC,WAAI,aAAA;AACT,QAAMC,WAAW,OAAOlB,mBAAYmB,IAAIhB,YAAAA;AACxC,QAAMiB,OAAO,OAAOpB,mBAAYmB,IAAIH,cAAAA;AACpC,SAAOE,SAASC,IAAIC,IAAAA;AACtB,CAAA;AAMK,IAAMC,kBAAkB,CAC7BL,gBACAM,OAEOL,WAAI,aAAA;AACT,QAAMC,WAAW,OAAOlB,mBAAYmB,IAAIhB,YAAAA;AACxC,QAAMiB,OAAO,OAAOpB,mBAAYmB,IAAIH,cAAAA;AACpCE,WAASK,IAAIH,MAAME,GAAGJ,SAASC,IAAIC,IAAAA,CAAAA,CAAAA;AACrC,CAAA;AAMK,IAAMI,gBAAgB,CAC3BR,gBACAS,aAEOR,WAAI,aAAA;AACT,QAAMC,WAAW,OAAOlB,mBAAYmB,IAAIhB,YAAAA;AACxC,QAAMiB,OAAO,OAAOpB,mBAAYmB,IAAIH,cAAAA;AACpC,SAAOE,SAASQ,UAAUN,MAAM,MAAMK,SAASP,SAASC,IAAIC,IAAAA,CAAAA,CAAAA;AAC9D,CAAA;",
|
|
6
|
+
"names": ["Effect", "Null", "Capability$", "make", "PluginManager", "AtomRegistry", "ReactContext", "ReactRoot", "ReactSurface", "Command", "Layer", "ManagedRuntime", "OperationHandler", "UndoMapping", "OperationInvoker", "UndoRegistry", "HistoryTracker", "getAtomValue", "atomCapability", "gen", "registry", "get", "atom", "updateAtomValue", "fn", "set", "subscribeAtom", "callback", "subscribe"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getModuleTag
|
|
3
|
+
} from "./chunk-3JWJXGLK.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__export
|
|
6
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
7
|
+
|
|
8
|
+
// src/core/plugin.ts
|
|
9
|
+
var plugin_exports = {};
|
|
10
|
+
__export(plugin_exports, {
|
|
11
|
+
LazyPluginError: () => LazyPluginError,
|
|
12
|
+
PluginModuleTypeId: () => PluginModuleTypeId,
|
|
13
|
+
PluginTypeId: () => PluginTypeId,
|
|
14
|
+
Service: () => Service,
|
|
15
|
+
activate: () => activate,
|
|
16
|
+
addModule: () => addModule,
|
|
17
|
+
define: () => define,
|
|
18
|
+
isLazy: () => isLazy,
|
|
19
|
+
isPlugin: () => isPlugin,
|
|
20
|
+
isPluginModule: () => isPluginModule,
|
|
21
|
+
lazy: () => lazy,
|
|
22
|
+
make: () => make,
|
|
23
|
+
reset: () => reset,
|
|
24
|
+
resolveLazy: () => resolveLazy,
|
|
25
|
+
shutdown: () => shutdown
|
|
26
|
+
});
|
|
27
|
+
import * as Context from "effect/Context";
|
|
28
|
+
import * as Effect from "effect/Effect";
|
|
29
|
+
import * as Option from "effect/Option";
|
|
30
|
+
import * as Pipeable from "effect/Pipeable";
|
|
31
|
+
import { BaseError } from "@dxos/errors";
|
|
32
|
+
import { invariant } from "@dxos/invariant";
|
|
33
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/plugin.ts";
|
|
34
|
+
var Service = class extends Context.Tag("@dxos/app-framework/PluginManager")() {
|
|
35
|
+
};
|
|
36
|
+
var activate = (event) => Effect.flatMap(Service, (manager) => manager.activate(event));
|
|
37
|
+
var reset = (event) => Effect.flatMap(Service, (manager) => manager.reset(event));
|
|
38
|
+
var shutdown = () => Effect.flatMap(Service, (manager) => manager.shutdown());
|
|
39
|
+
var computeModuleId = (pluginId, moduleName) => {
|
|
40
|
+
return `${pluginId}.module.${moduleName}`;
|
|
41
|
+
};
|
|
42
|
+
var PluginModuleTypeId = /* @__PURE__ */ Symbol.for("@dxos/app-framework/PluginModule");
|
|
43
|
+
var isPluginModule = (value) => {
|
|
44
|
+
return typeof value === "object" && value !== null && PluginModuleTypeId in value;
|
|
45
|
+
};
|
|
46
|
+
var PluginModuleImpl = class {
|
|
47
|
+
[PluginModuleTypeId] = PluginModuleTypeId;
|
|
48
|
+
id;
|
|
49
|
+
activatesOn;
|
|
50
|
+
firesBeforeActivation;
|
|
51
|
+
firesAfterActivation;
|
|
52
|
+
activate;
|
|
53
|
+
constructor(options) {
|
|
54
|
+
this.id = options.id;
|
|
55
|
+
this.activatesOn = options.activatesOn;
|
|
56
|
+
this.firesBeforeActivation = options.firesBeforeActivation;
|
|
57
|
+
this.firesAfterActivation = options.firesAfterActivation;
|
|
58
|
+
this.activate = options.activate;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var PluginTypeId = /* @__PURE__ */ Symbol.for("@dxos/app-framework/Plugin");
|
|
62
|
+
var isPlugin = (value) => {
|
|
63
|
+
return typeof value === "object" && value !== null && PluginTypeId in value;
|
|
64
|
+
};
|
|
65
|
+
var PluginImpl = class {
|
|
66
|
+
_meta;
|
|
67
|
+
_modules;
|
|
68
|
+
[PluginTypeId] = PluginTypeId;
|
|
69
|
+
constructor(_meta, _modules) {
|
|
70
|
+
this._meta = _meta;
|
|
71
|
+
this._modules = _modules;
|
|
72
|
+
}
|
|
73
|
+
get meta() {
|
|
74
|
+
return this._meta;
|
|
75
|
+
}
|
|
76
|
+
get modules() {
|
|
77
|
+
return this._modules;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
var PluginBuilderImpl = class {
|
|
81
|
+
meta;
|
|
82
|
+
_modules = [];
|
|
83
|
+
constructor(meta) {
|
|
84
|
+
this.meta = meta;
|
|
85
|
+
}
|
|
86
|
+
get modules() {
|
|
87
|
+
return this._modules;
|
|
88
|
+
}
|
|
89
|
+
addModule(moduleOptions) {
|
|
90
|
+
this._modules.push(moduleOptions);
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
pipe() {
|
|
94
|
+
return Pipeable.pipeArguments(this, arguments);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
var define = (meta) => new PluginBuilderImpl(meta);
|
|
98
|
+
function addModule(moduleOptionsOrBuilder, moduleOptions) {
|
|
99
|
+
if (moduleOptions !== void 0) {
|
|
100
|
+
return moduleOptionsOrBuilder.addModule(moduleOptions);
|
|
101
|
+
}
|
|
102
|
+
const moduleOpts = moduleOptionsOrBuilder;
|
|
103
|
+
return (builder) => builder.addModule(moduleOpts);
|
|
104
|
+
}
|
|
105
|
+
var resolveModule = (meta, module, options) => {
|
|
106
|
+
const moduleOptions = typeof module === "function" ? module(options) : module;
|
|
107
|
+
const id = Option.fromNullable(moduleOptions.id).pipe(Option.match({
|
|
108
|
+
onNone: () => {
|
|
109
|
+
const exportName = getModuleTag(moduleOptions.activate);
|
|
110
|
+
invariant(exportName, `Plugin module missing name. Plugin: ${meta.id}`, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 131, S: void 0, A: ["exportName", "`Plugin module missing name. Plugin: ${meta.id}`"] });
|
|
111
|
+
return computeModuleId(meta.id, exportName);
|
|
112
|
+
},
|
|
113
|
+
onSome: (id2) => computeModuleId(meta.id, id2)
|
|
114
|
+
}));
|
|
115
|
+
return new PluginModuleImpl({
|
|
116
|
+
...moduleOptions,
|
|
117
|
+
id
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
function make(builder) {
|
|
121
|
+
const meta = builder.meta;
|
|
122
|
+
const factory = (options) => {
|
|
123
|
+
const modules = builder.modules.map((module) => resolveModule(meta, module, options));
|
|
124
|
+
return new PluginImpl(meta, modules);
|
|
125
|
+
};
|
|
126
|
+
return Object.assign(factory, {
|
|
127
|
+
meta
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
var LazyTag = /* @__PURE__ */ Symbol.for("@dxos/app-framework/Plugin/Lazy");
|
|
131
|
+
var lazy = (meta, loader) => {
|
|
132
|
+
const factory = (options) => {
|
|
133
|
+
const stub = new PluginImpl(meta, []);
|
|
134
|
+
Object.defineProperty(stub, LazyTag, {
|
|
135
|
+
value: {
|
|
136
|
+
loader,
|
|
137
|
+
options
|
|
138
|
+
},
|
|
139
|
+
enumerable: false
|
|
140
|
+
});
|
|
141
|
+
return stub;
|
|
142
|
+
};
|
|
143
|
+
return Object.assign(factory, {
|
|
144
|
+
meta
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
var isLazy = (plugin) => LazyTag in plugin;
|
|
148
|
+
var LazyPluginError = class extends BaseError.extend("LazyPluginError", "Failed to resolve lazy plugin") {
|
|
149
|
+
};
|
|
150
|
+
var resolveLazy = (plugin) => Effect.gen(function* () {
|
|
151
|
+
if (!isLazy(plugin)) {
|
|
152
|
+
return plugin;
|
|
153
|
+
}
|
|
154
|
+
const id = plugin.meta.id;
|
|
155
|
+
const { loader, options } = plugin[LazyTag];
|
|
156
|
+
const mod = yield* Effect.tryPromise({
|
|
157
|
+
try: loader,
|
|
158
|
+
catch: (error) => new LazyPluginError({
|
|
159
|
+
context: {
|
|
160
|
+
id,
|
|
161
|
+
reason: "load-failed"
|
|
162
|
+
},
|
|
163
|
+
cause: error
|
|
164
|
+
})
|
|
165
|
+
});
|
|
166
|
+
if (!mod || typeof mod.default !== "function") {
|
|
167
|
+
return yield* Effect.fail(new LazyPluginError({
|
|
168
|
+
context: {
|
|
169
|
+
id,
|
|
170
|
+
reason: "missing-default"
|
|
171
|
+
}
|
|
172
|
+
}));
|
|
173
|
+
}
|
|
174
|
+
const result = mod.default(options);
|
|
175
|
+
if (!isPlugin(result)) {
|
|
176
|
+
return yield* Effect.fail(new LazyPluginError({
|
|
177
|
+
context: {
|
|
178
|
+
id,
|
|
179
|
+
reason: "invalid-plugin"
|
|
180
|
+
}
|
|
181
|
+
}));
|
|
182
|
+
}
|
|
183
|
+
if (result.meta.id !== id) {
|
|
184
|
+
return yield* Effect.fail(new LazyPluginError({
|
|
185
|
+
context: {
|
|
186
|
+
id,
|
|
187
|
+
reason: "meta-mismatch",
|
|
188
|
+
returnedId: result.meta.id
|
|
189
|
+
}
|
|
190
|
+
}));
|
|
191
|
+
}
|
|
192
|
+
return result;
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
export {
|
|
196
|
+
Service,
|
|
197
|
+
activate,
|
|
198
|
+
reset,
|
|
199
|
+
shutdown,
|
|
200
|
+
PluginModuleTypeId,
|
|
201
|
+
isPluginModule,
|
|
202
|
+
PluginTypeId,
|
|
203
|
+
isPlugin,
|
|
204
|
+
define,
|
|
205
|
+
addModule,
|
|
206
|
+
make,
|
|
207
|
+
lazy,
|
|
208
|
+
isLazy,
|
|
209
|
+
LazyPluginError,
|
|
210
|
+
resolveLazy,
|
|
211
|
+
plugin_exports
|
|
212
|
+
};
|
|
213
|
+
//# sourceMappingURL=chunk-Z55LVAGN.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/core/plugin.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\nimport * as Pipeable from 'effect/Pipeable';\n\nimport { BaseError } from '@dxos/errors';\nimport { invariant } from '@dxos/invariant';\n\nimport type * as ActivationEvent from './activation-event';\nimport * as Capability from './capability';\nimport type * as PluginManager from './plugin-manager';\n\n//\n// Plugin Service Layer\n//\n\n/**\n * Effect Context.Tag for accessing PluginManager via the Effect layer system.\n * This allows lifecycle operations to access the plugin manager without having it passed as an argument.\n */\nexport class Service extends Context.Tag('@dxos/app-framework/PluginManager')<Service, PluginManager.PluginManager>() {}\n\n//\n// Lifecycle Functions\n//\n\n/**\n * Activates plugins based on the activation event.\n * Accesses the PluginManager via the Effect layer system.\n * @param event The activation event.\n * @returns Whether the activation was successful.\n */\nexport const activate = (event: ActivationEvent.ActivationEvent): Effect.Effect<boolean, Error, Service> =>\n Effect.flatMap(Service, (manager) => manager.activate(event));\n\n/**\n * Re-activates the modules that were activated by the event.\n * Accesses the PluginManager via the Effect layer system.\n * @param event The activation event.\n * @returns Whether the reset was successful.\n */\nexport const reset = (event: ActivationEvent.ActivationEvent): Effect.Effect<boolean, Error, Service> =>\n Effect.flatMap(Service, (manager) => manager.reset(event));\n\n/**\n * Shuts down the plugin manager, deactivating all active modules and clearing lifecycle state.\n * Accesses the PluginManager via the Effect layer system.\n */\nexport const shutdown = (): Effect.Effect<boolean, Error, Service> =>\n Effect.flatMap(Service, (manager) => manager.shutdown());\n\n/**\n * Computes a module ID from plugin ID and export name.\n */\nconst computeModuleId = (pluginId: string, moduleName: string): string => {\n return `${pluginId}.module.${moduleName}`;\n};\n\n/**\n * Identifier denoting a PluginModule.\n */\nexport const PluginModuleTypeId: unique symbol = Symbol.for('@dxos/app-framework/PluginModule');\nexport type PluginModuleTypeId = typeof PluginModuleTypeId;\n\n/**\n * Type guard to check if a value is a PluginModule.\n */\nexport const isPluginModule = (value: unknown): value is PluginModule => {\n return typeof value === 'object' && value !== null && PluginModuleTypeId in value;\n};\n\n/**\n * A unit of containment of modular functionality that can be provided to an application.\n * Activation of a module is async allowing for code to split and loaded lazily.\n */\nexport interface PluginModule {\n readonly [PluginModuleTypeId]: PluginModuleTypeId;\n /**\n * Unique id of the module.\n */\n id: string;\n\n /**\n * Events for which the module will be activated.\n */\n activatesOn: ActivationEvent.Events;\n\n /**\n * Events that this module fires *before* its own activation runs.\n *\n * When this module is asked to activate (via {@link activatesOn}), the\n * plugin manager first activates every event listed here, ensuring any\n * other modules that contribute to those events have completed before\n * this module's {@link activate} body executes. These events are fired\n * by the framework on this module's behalf — the module does not need\n * to wait for some other code to fire them.\n *\n * The module is marked as needing reset if a module activated by one\n * of these events is later removed.\n *\n * Read as: \"this module fires these events before [its] activation\".\n */\n firesBeforeActivation?: ActivationEvent.ActivationEvent[];\n\n /**\n * Events that this module fires *after* its own activation completes.\n *\n * Once this module's {@link activate} body has finished executing, the\n * plugin manager activates every event listed here, causing any modules\n * listening on those events to run. These events are fired by the\n * framework on this module's behalf as part of this module's lifecycle.\n *\n * Read as: \"this module fires these events after [its] activation\".\n */\n firesAfterActivation?: ActivationEvent.ActivationEvent[];\n\n /**\n * Called when the module is activated.\n * CapabilityManager is accessed via the Effect layer system (Capability.Service).\n * PluginManager is accessed via Plugin.Service.\n * @param props Optional props passed to the module.\n * @returns The capabilities of the module.\n */\n activate: (props?: any) => Effect.Effect<Capability.ModuleReturn, Error, Capability.Service | Service | never>;\n}\n\nexport type PluginModuleOptions = Omit<PluginModule, 'id' | typeof PluginModuleTypeId> & { id?: string };\n\nclass PluginModuleImpl implements PluginModule {\n readonly [PluginModuleTypeId]: PluginModuleTypeId = PluginModuleTypeId;\n readonly id: PluginModule['id'];\n readonly activatesOn: PluginModule['activatesOn'];\n readonly firesBeforeActivation?: PluginModule['firesBeforeActivation'];\n readonly firesAfterActivation?: PluginModule['firesAfterActivation'];\n readonly activate: PluginModule['activate'];\n\n constructor(options: Omit<PluginModule, typeof PluginModuleTypeId>) {\n this.id = options.id;\n this.activatesOn = options.activatesOn;\n this.firesBeforeActivation = options.firesBeforeActivation;\n this.firesAfterActivation = options.firesAfterActivation;\n this.activate = options.activate;\n }\n}\n\nexport type Meta = {\n /**\n * Globally unique ID.\n *\n * Expected to be in the form of a valid URL.\n *\n * @example org.dxos.plugin.example\n */\n id: string;\n\n /**\n * Human-readable name.\n */\n name: string;\n\n /**\n * Short description of plugin functionality.\n */\n description?: string;\n\n /**\n * Name of the author or organization that created the plugin.\n */\n author?: string;\n\n /**\n * URL of home page.\n */\n homePage?: string;\n\n /**\n * URL of source code.\n */\n source?: string;\n\n /**\n * URL of screenshot.\n */\n screenshots?: string[];\n\n /**\n * Tags to help categorize the plugin.\n */\n tags?: string[];\n\n /**\n * A grep-able symbol string which can be resolved to an icon asset by @ch-ui/icons, via @ch-ui/vite-plugin-icons.\n */\n icon?: string;\n\n /**\n * Icon hue (ChromaticPalette).\n */\n iconHue?: string;\n};\n\n/**\n * Identifier denoting a Plugin.\n */\nexport const PluginTypeId: unique symbol = Symbol.for('@dxos/app-framework/Plugin');\nexport type PluginTypeId = typeof PluginTypeId;\n\n/**\n * Type guard to check if a value is a Plugin.\n */\nexport const isPlugin = (value: unknown): value is Plugin => {\n return typeof value === 'object' && value !== null && PluginTypeId in value;\n};\n\n/**\n * A collection of modules that are be enabled/disabled as a unit.\n * Plugins provide things such as components, state, actions, etc. to the application.\n */\n// TODO(burdon): Convert to ECHO schema.\nexport interface Plugin {\n readonly [PluginTypeId]: PluginTypeId;\n readonly meta: Readonly<Meta>;\n readonly modules: ReadonlyArray<PluginModule>;\n}\n\n/**\n * Internal implementation of Plugin.\n * @internal\n */\nclass PluginImpl implements Plugin {\n readonly [PluginTypeId]: PluginTypeId = PluginTypeId;\n\n constructor(\n private readonly _meta: Meta,\n private readonly _modules: PluginModule[],\n ) {}\n\n get meta(): Readonly<Meta> {\n return this._meta;\n }\n\n get modules(): ReadonlyArray<PluginModule> {\n return this._modules;\n }\n}\n\n/**\n * Builder interface for creating plugins incrementally.\n */\nexport interface PluginBuilder<T = void> extends Pipeable.Pipeable {\n readonly meta: Meta;\n readonly modules: ReadonlyArray<PluginModuleOptions | ((options: T) => PluginModuleOptions)>;\n addModule(moduleOptions: PluginModuleOptions | ((options: T) => PluginModuleOptions)): PluginBuilder<T>;\n}\n\n/**\n * Builder implementation for creating plugins incrementally.\n */\nclass PluginBuilderImpl<T = void> implements PluginBuilder<T> {\n readonly meta: Meta;\n private readonly _modules: Array<PluginModuleOptions | ((options: T) => PluginModuleOptions)> = [];\n\n constructor(meta: Meta) {\n this.meta = meta;\n }\n\n get modules(): ReadonlyArray<PluginModuleOptions | ((options: T) => PluginModuleOptions)> {\n return this._modules;\n }\n\n addModule(moduleOptions: PluginModuleOptions | ((options: T) => PluginModuleOptions)): PluginBuilder<T> {\n this._modules.push(moduleOptions);\n return this;\n }\n\n pipe() {\n // eslint-disable-next-line prefer-rest-params\n return Pipeable.pipeArguments(this, arguments);\n }\n}\n\n/**\n * Creates a new PluginBuilder to start building a plugin.\n */\nexport const define = <T = void>(meta: Meta): PluginBuilder<T> => new PluginBuilderImpl<T>(meta);\n\n/**\n * Adds a module to a plugin builder.\n * Supports both pipeline and direct call styles.\n * Modules can be either PluginModuleOptions or functions that receive options.\n */\nexport function addModule<T>(\n moduleOptions: PluginModuleOptions | ((options: T) => PluginModuleOptions),\n): (builder: PluginBuilder<T>) => PluginBuilder<T>;\nexport function addModule<T>(\n builder: PluginBuilder<T>,\n moduleOptions: PluginModuleOptions | ((options: T) => PluginModuleOptions),\n): PluginBuilder<T>;\nexport function addModule<T>(\n moduleOptionsOrBuilder: PluginModuleOptions | ((options: T) => PluginModuleOptions) | PluginBuilder<T>,\n moduleOptions?: PluginModuleOptions | ((options: T) => PluginModuleOptions),\n): ((builder: PluginBuilder<T>) => PluginBuilder<T>) | PluginBuilder<T> {\n // If second arg is provided, it's the direct call style: addModule(builder, moduleOptions)\n if (moduleOptions !== undefined) {\n return (moduleOptionsOrBuilder as PluginBuilder<T>).addModule(moduleOptions);\n }\n // Otherwise it's pipeline style: addModule(moduleOptions) returns a function\n const moduleOpts = moduleOptionsOrBuilder as PluginModuleOptions | ((options: T) => PluginModuleOptions);\n return (builder: PluginBuilder<T>) => builder.addModule(moduleOpts);\n}\n\nexport type PluginFactory<T = void> = ((options: T) => Plugin) & { meta: Meta };\n\n/**\n * Resolves a module from either PluginModuleOptions or a function that returns PluginModuleOptions.\n */\nconst resolveModule = (\n meta: Meta,\n module: PluginModuleOptions | ((options: any) => PluginModuleOptions),\n options?: any,\n): PluginModuleImpl => {\n const moduleOptions = typeof module === 'function' ? module(options) : module;\n const id = Option.fromNullable(moduleOptions.id).pipe(\n Option.match({\n onNone: () => {\n const exportName = Capability.getModuleTag(moduleOptions.activate);\n invariant(exportName, `Plugin module missing name. Plugin: ${meta.id}`);\n return computeModuleId(meta.id, exportName);\n },\n onSome: (id) => computeModuleId(meta.id, id),\n }),\n );\n return new PluginModuleImpl({ ...moduleOptions, id });\n};\n\n/**\n * Creates a Plugin from a builder.\n * Supports both pipeline and direct call styles.\n * Always returns a factory function (options: T) => Plugin.\n * When T is void, the function takes no arguments: () => Plugin.\n */\nexport function make<T>(builder: PluginBuilder<T>): PluginFactory<T>;\nexport function make<T>(builder: PluginBuilder<T>): PluginFactory<T> {\n const meta = builder.meta;\n\n const factory = (options: T) => {\n const modules = builder.modules.map((module) => resolveModule(meta, module, options));\n return new PluginImpl(meta, modules);\n };\n\n return Object.assign(factory, { meta });\n}\n\n//\n// Lazy plugin loading\n//\n\n/**\n * Symbol used to tag lazy plugin stubs with their loader closure.\n * Hidden from enumeration so plugin manager iteration / serialization paths\n * don't trip over it.\n */\nconst LazyTag: unique symbol = Symbol.for('@dxos/app-framework/Plugin/Lazy');\n\n/**\n * Async loader for a lazy plugin's real implementation.\n * The default export of the loaded module must be a `PluginFactory<T>` —\n * i.e. the same shape `Plugin.make` produces.\n */\nexport type LazyLoader<T = void> = () => Promise<{ default: PluginFactory<T> }>;\n\n/** Internal: payload carried on a lazy stub. */\ntype LazyPayload = { loader: LazyLoader<any>; options: unknown };\n\n/**\n * Defines a lazy plugin whose body is loaded on first enable.\n *\n * The returned factory produces a stub `Plugin` that exposes `meta`\n * synchronously (so callers can read `Plugin.meta.id` for free) but defers\n * loading the real plugin's modules until the manager calls\n * `Plugin.resolveLazy`. This lets the plugin's main entry point ship as a\n * tiny meta-only chunk — the heavy capabilities, schema, React surfaces,\n * etc. live behind the dynamic `import()` and become a separate Rollup\n * chunk that is only fetched when the plugin is enabled.\n *\n * @example\n * ```ts\n * // plugin-markdown/src/index.ts\n * import { Plugin } from '@dxos/app-framework';\n * import { meta } from './meta';\n *\n * export const MarkdownPlugin = Plugin.lazy(meta, () => import('./MarkdownPlugin'));\n *\n * // plugin-markdown/src/MarkdownPlugin.tsx\n * export const MarkdownPlugin = Plugin.define(meta).pipe(...heavy modules..., Plugin.make);\n * export default MarkdownPlugin;\n * ```\n */\nexport const lazy = <T = void>(meta: Meta, loader: LazyLoader<T>): PluginFactory<T> => {\n const factory = (options: T): Plugin => {\n const stub = new PluginImpl(meta, []);\n Object.defineProperty(stub, LazyTag, {\n value: { loader, options } satisfies LazyPayload,\n enumerable: false,\n });\n return stub;\n };\n return Object.assign(factory, { meta });\n};\n\n/**\n * Type guard for lazy plugin stubs produced by {@link lazy}.\n */\nexport const isLazy = (plugin: Plugin): boolean => LazyTag in plugin;\n\n/**\n * Tagged error for failures during lazy plugin resolution. `context.id` is\n * the lazy plugin's `meta.id`; `context.reason` discriminates the failure\n * mode (`'load-failed' | 'missing-default' | 'invalid-plugin' |\n * 'meta-mismatch'`) so callers can route on it.\n */\nexport class LazyPluginError extends BaseError.extend('LazyPluginError', 'Failed to resolve lazy plugin') {}\n\n/**\n * Resolves a lazy plugin stub to its real plugin.\n * Returns the plugin unchanged if it is not lazy. Failures surface as\n * {@link LazyPluginError} with `context.reason` indicating the failure mode\n * and (for loader failures) `cause` set to the original error.\n */\nexport const resolveLazy = (plugin: Plugin): Effect.Effect<Plugin, LazyPluginError> =>\n Effect.gen(function* () {\n if (!isLazy(plugin)) {\n return plugin;\n }\n const id = plugin.meta.id;\n const { loader, options } = (plugin as unknown as { [LazyTag]: LazyPayload })[LazyTag];\n const mod = yield* Effect.tryPromise({\n try: loader,\n catch: (error) => new LazyPluginError({ context: { id, reason: 'load-failed' }, cause: error }),\n });\n if (!mod || typeof mod.default !== 'function') {\n return yield* Effect.fail(new LazyPluginError({ context: { id, reason: 'missing-default' } }));\n }\n const result = mod.default(options);\n if (!isPlugin(result)) {\n return yield* Effect.fail(new LazyPluginError({ context: { id, reason: 'invalid-plugin' } }));\n }\n if (result.meta.id !== id) {\n return yield* Effect.fail(\n new LazyPluginError({ context: { id, reason: 'meta-mismatch', returnedId: result.meta.id } }),\n );\n }\n return result;\n });\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAAA;;;;;;;;;;;;;;;;;;AAIA,YAAYA,aAAa;AACzB,YAAYC,YAAY;AACxB,YAAYC,YAAY;AACxB,YAAYC,cAAc;AAE1B,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAM1B,IAAE,eAAA;AAUA,IAAA,UAAA,cAAA,YAAA,mCAAA,EAAA,EAAA;AACF;;;;AAiCA,IAAA,kBAAA,CAAA,UAAA,eAAA;AAEA,SAAA,GAAA,QAAA,WAAA,UAAA;;;AAWE,IAAA,iBAAA,CAAA,UAAA;AA2DF,SAAMC,OAAAA,UAAAA,YAAAA,UAAAA,QAAAA,sBAAAA;;IAEKC,yBAAuB;EACvBC,CAAAA,kBAAyC,IAAA;EACzCC;EACAC;EACAC;EAET;;cAEOH,SAAW;AAChB,SAAKC,KAAAA,QAAAA;AACL,SAAKC,cAAAA,QAAoB;AACzB,SAAKC,wBAAmBA,QAAQ;AAClC,SAAA,uBAAA,QAAA;AACF,SAAA,WAAA,QAAA;EA0DA;;;AAWE,IAAA,WAAA,CAAA,UAAA;AAaF,SAAA,OAAA,UAAA,YAAA,UAAA,QAAA,gBAAA;;;EAKW;EAET;eACmBC,IAAAA;cACAC,OAAAA,UAAAA;AAChB,SAAA,QAAA;AAECC,SAAAA,WAAuB;;EAE3B,IAAA,OAAA;AAEIC,WAAAA,KAAuC;;EAE3C,IAAA,UAAA;AACF,WAAA,KAAA;EAWA;;AAKmBF,IAAAA,oBAAAA,MAAkF;EAEnG;aACOC,CAAAA;EACP,YAAA,MAAA;AAEIC,SAAAA,OAAsF;;EAE1F,IAAA,UAAA;AAEAC,WAAUC,KAAAA;;YAER,eAAW;AACb,SAAA,SAAA,KAAA,aAAA;AAEAC,WAAO;;SAEL;AAEJ,WAAA,uBAAA,MAAA,SAAA;EAEA;;AAqBE,IAAA,SAAA,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,OAAA,mBAAA,+BAAA,EAAA;;IASM,cAAOO,CAAAA,WAAAA,WAAAA,aAAAA;AACT,MAAA,CAAA,OAAA,MAAA,GAAA;AACA,WAAWA;EACX;AACA,QAAMC,KAAAA,OAAM,KAAOC;QACjBC,EAAAA,QAAKL,QAAAA,IAAAA,OAAAA,OAAAA;QACLM,MAAQC,OAAcC,kBAAAA;;sBAA6BtC,IAAAA,gBAAAA;eAAIuC;QAAsB;QAAGC,QAAOH;MAAM;MAC/F,OAAA;IACKJ,CAAAA;;cAC6CQ,OAAS,IAAA,YAAA,YAAA;kBAAEzC,YAAAA,IAAAA,gBAAAA;eAAIuC;QAA0B;QAAE,QAAA;MAC7F;IACA,CAAA,CAAMG;EACN;QACE,SAAO,IAAOR,QAAOS,OAASL;gBAAkBG,MAAS,GAAA;kBAAEzC,YAAAA,IAAAA,gBAAAA;eAAIuC;QAAyB;QAAE,QAAA;MAC5F;IACIG,CAAAA,CAAAA;;aAEsBD,KAAAA,OAAS,IAAA;kBAAEzC,YAAAA,IAAAA,gBAAAA;eAAIuC;QAAyBK;QAA2B,QAAA;QAAE,YAAA,OAAA,KAAA;MAE/F;IACA,CAAA,CAAA;EACC;;;",
|
|
6
|
+
"names": ["Context", "Effect", "Option", "Pipeable", "BaseError", "invariant", "PluginModuleImpl", "id", "activatesOn", "firesBeforeActivation", "firesAfterActivation", "activate", "_meta", "_modules", "meta", "modules", "addModule", "moduleOptions", "pipe", "undefined", "fromNullable", "onNone", "exportName", "Capability", "getModuleTag", "invariant", "onSome", "computeModuleId", "factory", "options", "builder", "PluginImpl", "Object", "assign", "stub", "defineProperty", "value", "loader", "enumerable", "plugin", "mod", "Effect", "try", "catch", "error", "LazyPluginError", "reason", "cause", "context", "result", "fail", "returnedId"]
|
|
7
|
+
}
|