@dxos/app-framework 0.8.4-main.c85a9c8dae → 0.8.4-main.d05539e30a
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/browser/{capability-7RLVE42K.mjs → capability-K5XIVCQU.mjs} +12 -11
- package/dist/lib/browser/capability-K5XIVCQU.mjs.map +7 -0
- package/dist/lib/browser/chunk-5AHASNDW.mjs +95 -0
- package/dist/lib/browser/chunk-5AHASNDW.mjs.map +7 -0
- package/dist/lib/browser/chunk-5GY3YOEL.mjs +28 -0
- package/dist/lib/browser/chunk-5GY3YOEL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-PKQT6C53.mjs → chunk-66IXTIVK.mjs} +3 -2
- package/dist/lib/browser/chunk-66IXTIVK.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ZRWBPIZG.mjs → chunk-BRK6GYNB.mjs} +14 -42
- package/dist/lib/browser/chunk-BRK6GYNB.mjs.map +7 -0
- package/dist/lib/browser/chunk-FJ4765WW.mjs +8 -0
- package/dist/lib/browser/{chunk-FHQTHCX7.mjs.map → chunk-FJ4765WW.mjs.map} +3 -3
- package/dist/lib/browser/chunk-FO3IYSLV.mjs +68 -0
- package/dist/lib/browser/chunk-FO3IYSLV.mjs.map +7 -0
- package/dist/lib/browser/{chunk-YNFPIQGB.mjs → chunk-IW44C7UL.mjs} +9 -2
- package/dist/lib/browser/chunk-IW44C7UL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-5RJNZV7K.mjs → chunk-KFDF7KR3.mjs} +11 -13
- package/dist/lib/browser/{chunk-5RJNZV7K.mjs.map → chunk-KFDF7KR3.mjs.map} +3 -3
- package/dist/lib/browser/chunk-KLHQNYJ2.mjs +422 -0
- package/dist/lib/browser/chunk-KLHQNYJ2.mjs.map +7 -0
- package/dist/lib/browser/chunk-QLML5QFJ.mjs +581 -0
- package/dist/lib/browser/chunk-QLML5QFJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FNKT2QQ2.mjs → chunk-SLX73WRZ.mjs} +90 -17
- package/dist/lib/browser/chunk-SLX73WRZ.mjs.map +7 -0
- package/dist/lib/browser/chunk-UVTGHZQF.mjs +513 -0
- package/dist/lib/browser/chunk-UVTGHZQF.mjs.map +7 -0
- package/dist/lib/browser/chunk-VJ5PFAWC.mjs +1446 -0
- package/dist/lib/browser/chunk-VJ5PFAWC.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +17 -32
- package/dist/lib/browser/cli/index.mjs.map +3 -3
- package/dist/lib/browser/common/activation-events.mjs +11 -14
- package/dist/lib/browser/common/capabilities.mjs +19 -8
- package/dist/lib/browser/core/activation-event.mjs +1 -1
- package/dist/lib/browser/core/capability.mjs +5 -1
- package/dist/lib/browser/core/plugin-manager.mjs +8 -4
- package/dist/lib/browser/core/plugin.mjs +16 -4
- package/dist/lib/browser/core/url-loader.mjs +24 -0
- package/dist/lib/browser/index.mjs +47 -49
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/process-manager-capability-JIWLN7SU.mjs +89 -0
- package/dist/lib/browser/process-manager-capability-JIWLN7SU.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +199 -56
- 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 +24 -15
- package/dist/lib/node-esm/{capability-EVZK4REM.mjs → capability-RLKFFLTB.mjs} +12 -11
- package/dist/lib/node-esm/capability-RLKFFLTB.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-UEWJDI2L.mjs → chunk-37Z53PXZ.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-UEWJDI2L.mjs.map → chunk-37Z53PXZ.mjs.map} +3 -3
- package/dist/lib/node-esm/chunk-42UNAKYO.mjs +423 -0
- package/dist/lib/node-esm/chunk-42UNAKYO.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-CJCQS2YL.mjs → chunk-6S45OMUP.mjs} +90 -17
- package/dist/lib/node-esm/chunk-6S45OMUP.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-2A4PRBIX.mjs → chunk-BYHYYJZH.mjs} +14 -42
- package/dist/lib/node-esm/chunk-BYHYYJZH.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-SB5ODNPX.mjs → chunk-CTKEZHKF.mjs} +9 -2
- package/dist/lib/node-esm/chunk-CTKEZHKF.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-JNT72ZCN.mjs +514 -0
- package/dist/lib/node-esm/chunk-JNT72ZCN.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-KFZEB6BV.mjs +29 -0
- package/dist/lib/node-esm/chunk-KFZEB6BV.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-LJNUFNDO.mjs +582 -0
- package/dist/lib/node-esm/chunk-LJNUFNDO.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-VUIUFIGT.mjs → chunk-OUEMWPIW.mjs} +11 -13
- package/dist/lib/node-esm/{chunk-VUIUFIGT.mjs.map → chunk-OUEMWPIW.mjs.map} +3 -3
- package/dist/lib/node-esm/chunk-PW2VYGOS.mjs +96 -0
- package/dist/lib/node-esm/chunk-PW2VYGOS.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SFYCO3PT.mjs +1447 -0
- package/dist/lib/node-esm/chunk-SFYCO3PT.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-7OWSHPYK.mjs → chunk-XOCUANHO.mjs} +3 -2
- package/dist/lib/node-esm/chunk-XOCUANHO.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +17 -32
- package/dist/lib/node-esm/cli/index.mjs.map +3 -3
- package/dist/lib/node-esm/common/activation-events.mjs +11 -14
- package/dist/lib/node-esm/common/capabilities.mjs +19 -8
- package/dist/lib/node-esm/core/activation-event.mjs +1 -1
- package/dist/lib/node-esm/core/capability.mjs +5 -1
- package/dist/lib/node-esm/core/plugin-manager.mjs +8 -4
- package/dist/lib/node-esm/core/plugin.mjs +16 -4
- package/dist/lib/node-esm/core/url-loader.mjs +25 -0
- package/dist/lib/node-esm/index.mjs +47 -49
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/process-manager-capability-PHKLO2BL.mjs +90 -0
- package/dist/lib/node-esm/process-manager-capability-PHKLO2BL.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +199 -56
- 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 +24 -15
- 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 +1 -3
- package/dist/types/src/cli/cli.d.ts.map +1 -1
- package/dist/types/src/common/activation-events.d.ts +10 -13
- package/dist/types/src/common/activation-events.d.ts.map +1 -1
- 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 +113 -12
- package/dist/types/src/common/capabilities.d.ts.map +1 -1
- package/dist/types/src/common/operations.d.ts +8 -22
- package/dist/types/src/common/operations.d.ts.map +1 -1
- package/dist/types/src/core/activation-event.d.ts +5 -5
- package/dist/types/src/core/activation-event.d.ts.map +1 -1
- package/dist/types/src/core/capability-manager.d.ts +5 -0
- package/dist/types/src/core/capability-manager.d.ts.map +1 -1
- package/dist/types/src/core/capability.d.ts +13 -2
- package/dist/types/src/core/capability.d.ts.map +1 -1
- 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 +6 -0
- 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 +238 -7
- package/dist/types/src/core/plugin-manager.d.ts.map +1 -1
- 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 +182 -7
- package/dist/types/src/core/plugin.d.ts.map +1 -1
- package/dist/types/src/core/registry.d.ts +107 -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 +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/plugin-process-manager/ProcessManagerPlugin.d.ts +3 -0
- package/dist/types/src/plugin-process-manager/ProcessManagerPlugin.d.ts.map +1 -0
- package/dist/types/src/plugin-process-manager/history/capability.d.ts.map +1 -0
- package/dist/types/src/plugin-process-manager/history/errors.d.ts +32 -0
- package/dist/types/src/plugin-process-manager/history/errors.d.ts.map +1 -0
- package/dist/types/src/{plugin-operation → plugin-process-manager}/history/history-tracker.d.ts +1 -1
- package/dist/types/src/plugin-process-manager/history/history-tracker.d.ts.map +1 -0
- package/dist/types/src/plugin-process-manager/history/history-tracker.test.d.ts.map +1 -0
- package/dist/types/src/plugin-process-manager/history/index.d.ts.map +1 -0
- package/dist/types/src/{plugin-operation → plugin-process-manager}/history/types.d.ts +1 -1
- package/dist/types/src/plugin-process-manager/history/types.d.ts.map +1 -0
- package/dist/types/src/{plugin-operation → plugin-process-manager}/history/undo-mapping.d.ts +1 -1
- package/dist/types/src/plugin-process-manager/history/undo-mapping.d.ts.map +1 -0
- package/dist/types/src/{plugin-operation → plugin-process-manager}/history/undo-registry.d.ts +1 -1
- package/dist/types/src/plugin-process-manager/history/undo-registry.d.ts.map +1 -0
- package/dist/types/src/plugin-process-manager/history/undo-registry.test.d.ts.map +1 -0
- package/dist/types/src/plugin-process-manager/index.d.ts +3 -0
- package/dist/types/src/plugin-process-manager/index.d.ts.map +1 -0
- package/dist/types/src/plugin-process-manager/meta.d.ts.map +1 -0
- package/dist/types/src/plugin-process-manager/process-manager-capability.d.ts +8 -0
- package/dist/types/src/plugin-process-manager/process-manager-capability.d.ts.map +1 -0
- package/dist/types/src/plugin-process-manager/testing.d.ts +59 -0
- package/dist/types/src/plugin-process-manager/testing.d.ts.map +1 -0
- package/dist/types/src/testing/harness.d.ts +79 -0
- package/dist/types/src/testing/harness.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/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.map +1 -1
- 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 +3 -2
- package/dist/types/src/ui/components/App/App.d.ts.map +1 -1
- package/dist/types/src/ui/components/App/App.stories.d.ts +2 -2
- package/dist/types/src/ui/components/App/App.stories.d.ts.map +1 -1
- 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/ui/components/PluginManager/PluginManagerContext.stories.d.ts.map +1 -1
- package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts +16 -4
- package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts.map +1 -1
- package/dist/types/src/ui/components/Surface/SurfaceComponent.stories.d.ts.map +1 -1
- package/dist/types/src/ui/components/Surface/SurfaceInfo.d.ts.map +1 -1
- 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/index.d.ts +22 -6
- package/dist/types/src/ui/components/Surface/index.d.ts.map +1 -1
- package/dist/types/src/ui/components/Surface/types.d.ts +110 -9
- package/dist/types/src/ui/components/Surface/types.d.ts.map +1 -1
- 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 +1 -0
- package/dist/types/src/ui/components/index.d.ts.map +1 -1
- package/dist/types/src/ui/hooks/index.d.ts +1 -1
- package/dist/types/src/ui/hooks/index.d.ts.map +1 -1
- package/dist/types/src/ui/hooks/useApp.d.ts +47 -11
- package/dist/types/src/ui/hooks/useApp.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/types/src/ui/hooks/useLoading.d.ts.map +1 -1
- package/dist/types/src/ui/hooks/useProcessManagerRuntime.d.ts +24 -0
- package/dist/types/src/ui/hooks/useProcessManagerRuntime.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/useSettingsState.d.ts.map +1 -1
- 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 +15 -0
- package/package.json +53 -54
- package/src/cli/cli.ts +4 -9
- package/src/common/activation-events.ts +12 -17
- package/src/common/annotations.ts +3 -0
- package/src/common/capabilities.ts +160 -29
- package/src/common/operations.ts +7 -10
- package/src/context.ts +1 -1
- package/src/core/activation-event.ts +5 -2
- package/src/core/capability-manager.test.ts +1 -1
- package/src/core/capability-manager.ts +22 -1
- package/src/core/capability.ts +20 -2
- package/src/core/edge-registry-plugin-provider.ts +92 -0
- package/src/core/index.ts +6 -0
- package/src/core/plugin-asset-cache.ts +60 -0
- package/src/core/plugin-manager.test.ts +1085 -31
- package/src/core/plugin-manager.ts +1170 -198
- package/src/core/plugin-manifest.test.ts +75 -0
- package/src/core/plugin-manifest.ts +134 -0
- package/src/core/plugin.ts +194 -12
- package/src/core/registry.ts +163 -0
- package/src/core/url-loader.test.ts +221 -0
- package/src/core/url-loader.ts +388 -0
- package/src/index.ts +1 -2
- package/src/plugin-process-manager/ProcessManagerPlugin.ts +24 -0
- package/src/{plugin-operation → plugin-process-manager}/history/capability.ts +1 -2
- package/src/plugin-process-manager/history/errors.ts +7 -0
- package/src/{plugin-operation → plugin-process-manager}/history/history-tracker.test.ts +37 -43
- package/src/{plugin-operation → plugin-process-manager}/history/history-tracker.ts +1 -2
- package/src/{plugin-operation → plugin-process-manager}/history/types.ts +1 -1
- package/src/{plugin-operation → plugin-process-manager}/history/undo-mapping.ts +1 -1
- package/src/{plugin-operation → plugin-process-manager}/history/undo-registry.test.ts +3 -4
- package/src/{plugin-operation → plugin-process-manager}/history/undo-registry.ts +1 -1
- package/src/{plugin-operation → plugin-process-manager}/index.ts +1 -1
- package/src/plugin-process-manager/meta.ts +14 -0
- package/src/plugin-process-manager/process-manager-capability.ts +178 -0
- package/src/{plugin-operation → plugin-process-manager}/testing.ts +26 -45
- package/src/testing/harness.ts +247 -0
- package/src/testing/index.ts +1 -0
- package/src/testing/react.test.tsx +48 -0
- package/src/testing/react.tsx +113 -0
- package/src/testing/service.ts +4 -4
- package/src/testing/withPluginManager.stories.tsx +1 -2
- package/src/testing/withPluginManager.tsx +45 -20
- package/src/ui/components/App/App.stories.tsx +7 -13
- package/src/ui/components/App/App.tsx +29 -5
- package/src/ui/components/Placeholder/Placeholder.stories.tsx +77 -0
- package/src/ui/components/Placeholder/Placeholder.tsx +155 -0
- package/src/{plugin-runtime → ui/components/Placeholder}/index.ts +1 -1
- package/src/ui/components/PluginManager/PluginManagerContext.stories.tsx +8 -7
- package/src/ui/components/Surface/SurfaceComponent.stories.tsx +16 -15
- package/src/ui/components/Surface/SurfaceComponent.tsx +111 -55
- package/src/ui/components/Surface/SurfaceInfo.tsx +0 -1
- package/src/ui/components/Surface/SurfaceProfilerContext.tsx +207 -0
- package/src/ui/components/Surface/index.ts +35 -1
- package/src/ui/components/Surface/types.test.ts +126 -0
- package/src/ui/components/Surface/types.ts +164 -12
- package/src/ui/components/index.ts +1 -0
- package/src/ui/hooks/index.ts +1 -1
- package/src/ui/hooks/useApp.test.tsx +159 -0
- package/src/ui/hooks/useApp.tsx +229 -24
- package/src/ui/hooks/useLoading.tsx +14 -6
- package/src/ui/hooks/useProcessManagerRuntime.ts +68 -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 +25 -1
- package/tsconfig.node.json +1 -1
- package/vitest.config.ts +1 -1
- package/.swc/plugins/linux_x86_64_19.0.0/727453fb3a62f7f1d952a41e051ca8a6f88cadc45cee43c6a4d1aa45f9b75665.wasmer-v7 +0 -0
- package/dist/lib/browser/capability-2GL5JAGJ.mjs +0 -37
- package/dist/lib/browser/capability-2GL5JAGJ.mjs.map +0 -7
- package/dist/lib/browser/capability-7RLVE42K.mjs.map +0 -7
- package/dist/lib/browser/chunk-4CTRO67U.mjs +0 -703
- package/dist/lib/browser/chunk-4CTRO67U.mjs.map +0 -7
- package/dist/lib/browser/chunk-FHQTHCX7.mjs +0 -8
- package/dist/lib/browser/chunk-FNKT2QQ2.mjs.map +0 -7
- package/dist/lib/browser/chunk-HE27PNNQ.mjs +0 -824
- package/dist/lib/browser/chunk-HE27PNNQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-NPUEVX42.mjs +0 -34
- package/dist/lib/browser/chunk-NPUEVX42.mjs.map +0 -7
- package/dist/lib/browser/chunk-PKQT6C53.mjs.map +0 -7
- package/dist/lib/browser/chunk-REORGDJT.mjs +0 -80
- package/dist/lib/browser/chunk-REORGDJT.mjs.map +0 -7
- package/dist/lib/browser/chunk-YAFEA4GV.mjs +0 -1
- package/dist/lib/browser/chunk-YNFPIQGB.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZRWBPIZG.mjs.map +0 -7
- package/dist/lib/browser/invoker-capability-BNLVNYHU.mjs +0 -36
- package/dist/lib/browser/invoker-capability-BNLVNYHU.mjs.map +0 -7
- package/dist/lib/node-esm/capability-CHIMU6LX.mjs +0 -38
- package/dist/lib/node-esm/capability-CHIMU6LX.mjs.map +0 -7
- package/dist/lib/node-esm/capability-EVZK4REM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2A4PRBIX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7CPNAEGV.mjs +0 -704
- package/dist/lib/node-esm/chunk-7CPNAEGV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7OWSHPYK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CJCQS2YL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DTCHT2X2.mjs +0 -825
- package/dist/lib/node-esm/chunk-DTCHT2X2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JAZVHID3.mjs +0 -35
- package/dist/lib/node-esm/chunk-JAZVHID3.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SB5ODNPX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UFW652GS.mjs +0 -81
- package/dist/lib/node-esm/chunk-UFW652GS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Z4TJPSMP.mjs +0 -2
- package/dist/lib/node-esm/invoker-capability-VF6SP44V.mjs +0 -37
- package/dist/lib/node-esm/invoker-capability-VF6SP44V.mjs.map +0 -7
- package/dist/types/src/plugin-operation/OperationPlugin.d.ts +0 -3
- package/dist/types/src/plugin-operation/OperationPlugin.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/history/capability.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/history/errors.d.ts +0 -5
- package/dist/types/src/plugin-operation/history/errors.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/history/history-tracker.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/history/history-tracker.test.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/history/index.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/history/types.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/history/undo-mapping.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/history/undo-registry.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/history/undo-registry.test.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/index.d.ts +0 -3
- package/dist/types/src/plugin-operation/index.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/invoker-capability.d.ts +0 -6
- package/dist/types/src/plugin-operation/invoker-capability.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/meta.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/testing.d.ts +0 -109
- package/dist/types/src/plugin-operation/testing.d.ts.map +0 -1
- package/dist/types/src/plugin-runtime/RuntimePlugin.d.ts +0 -3
- package/dist/types/src/plugin-runtime/RuntimePlugin.d.ts.map +0 -1
- package/dist/types/src/plugin-runtime/capability.d.ts +0 -6
- package/dist/types/src/plugin-runtime/capability.d.ts.map +0 -1
- package/dist/types/src/plugin-runtime/index.d.ts +0 -2
- package/dist/types/src/plugin-runtime/index.d.ts.map +0 -1
- package/dist/types/src/plugin-runtime/meta.d.ts +0 -3
- package/dist/types/src/plugin-runtime/meta.d.ts.map +0 -1
- package/dist/types/src/ui/hooks/useOperationResolver.d.ts +0 -19
- package/dist/types/src/ui/hooks/useOperationResolver.d.ts.map +0 -1
- package/src/plugin-operation/OperationPlugin.ts +0 -25
- package/src/plugin-operation/history/errors.ts +0 -11
- package/src/plugin-operation/invoker-capability.ts +0 -40
- package/src/plugin-operation/meta.ts +0 -11
- package/src/plugin-runtime/RuntimePlugin.ts +0 -20
- package/src/plugin-runtime/capability.ts +0 -53
- package/src/plugin-runtime/meta.ts +0 -11
- package/src/ui/hooks/useOperationResolver.ts +0 -40
- /package/dist/lib/browser/{chunk-YAFEA4GV.mjs.map → core/url-loader.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-Z4TJPSMP.mjs.map → core/url-loader.mjs.map} +0 -0
- /package/dist/types/src/{plugin-operation → plugin-process-manager}/history/capability.d.ts +0 -0
- /package/dist/types/src/{plugin-operation → plugin-process-manager}/history/history-tracker.test.d.ts +0 -0
- /package/dist/types/src/{plugin-operation → plugin-process-manager}/history/index.d.ts +0 -0
- /package/dist/types/src/{plugin-operation → plugin-process-manager}/history/undo-registry.test.d.ts +0 -0
- /package/dist/types/src/{plugin-operation → plugin-process-manager}/meta.d.ts +0 -0
- /package/src/{plugin-operation → plugin-process-manager}/history/index.ts +0 -0
|
@@ -0,0 +1,1446 @@
|
|
|
1
|
+
import {
|
|
2
|
+
eventKey,
|
|
3
|
+
getEvents,
|
|
4
|
+
isAllOf
|
|
5
|
+
} from "./chunk-66IXTIVK.mjs";
|
|
6
|
+
import {
|
|
7
|
+
LazyPluginError,
|
|
8
|
+
PluginDependencyError,
|
|
9
|
+
Service as Service2,
|
|
10
|
+
isLazy,
|
|
11
|
+
resolveLazy
|
|
12
|
+
} from "./chunk-SLX73WRZ.mjs";
|
|
13
|
+
import {
|
|
14
|
+
Service
|
|
15
|
+
} from "./chunk-IW44C7UL.mjs";
|
|
16
|
+
import {
|
|
17
|
+
__export
|
|
18
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
19
|
+
|
|
20
|
+
// src/core/plugin-manager.ts
|
|
21
|
+
var plugin_manager_exports = {};
|
|
22
|
+
__export(plugin_manager_exports, {
|
|
23
|
+
ManagerTypeId: () => ManagerTypeId,
|
|
24
|
+
PluginInitializationError: () => PluginInitializationError,
|
|
25
|
+
PluginTimeoutError: () => PluginTimeoutError,
|
|
26
|
+
isManager: () => isManager,
|
|
27
|
+
make: () => make5
|
|
28
|
+
});
|
|
29
|
+
import { Atom as Atom3, Registry } from "@effect-atom/atom-react";
|
|
30
|
+
import * as Array from "effect/Array";
|
|
31
|
+
import * as Cause from "effect/Cause";
|
|
32
|
+
import * as Deferred2 from "effect/Deferred";
|
|
33
|
+
import * as Duration from "effect/Duration";
|
|
34
|
+
import * as Effect3 from "effect/Effect";
|
|
35
|
+
import * as Fiber from "effect/Fiber";
|
|
36
|
+
import * as Function from "effect/Function";
|
|
37
|
+
import * as HashSet from "effect/HashSet";
|
|
38
|
+
import * as PubSub from "effect/PubSub";
|
|
39
|
+
import * as Ref from "effect/Ref";
|
|
40
|
+
import { runAndForwardErrors as runAndForwardErrors2 } from "@dxos/effect";
|
|
41
|
+
import { Performance } from "@dxos/effect";
|
|
42
|
+
import { BaseError } from "@dxos/errors";
|
|
43
|
+
import { log as log3 } from "@dxos/log";
|
|
44
|
+
|
|
45
|
+
// src/core/capability-manager.ts
|
|
46
|
+
var capability_manager_exports = {};
|
|
47
|
+
__export(capability_manager_exports, {
|
|
48
|
+
make: () => make2
|
|
49
|
+
});
|
|
50
|
+
import { Atom } from "@effect-atom/atom-react";
|
|
51
|
+
import * as Deferred from "effect/Deferred";
|
|
52
|
+
import * as Effect from "effect/Effect";
|
|
53
|
+
import { invariant } from "@dxos/invariant";
|
|
54
|
+
import { log } from "@dxos/log";
|
|
55
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/capability-manager.ts";
|
|
56
|
+
var CapabilityManagerImpl = class {
|
|
57
|
+
_registry;
|
|
58
|
+
_capabilityEntries = Atom.family(() => {
|
|
59
|
+
return Atom.make([]).pipe(Atom.keepAlive);
|
|
60
|
+
});
|
|
61
|
+
_capabilities = Atom.family((id) => {
|
|
62
|
+
return Atom.make((get2) => {
|
|
63
|
+
const current = get2(this._capabilityEntries(id));
|
|
64
|
+
return current.map((c) => c.implementation);
|
|
65
|
+
}).pipe(Atom.keepAlive);
|
|
66
|
+
});
|
|
67
|
+
_capabilitiesByModule = Atom.family((id) => {
|
|
68
|
+
return Atom.make((get2) => {
|
|
69
|
+
const entries = get2(this._capabilityEntries(id));
|
|
70
|
+
const result = {};
|
|
71
|
+
for (const entry of entries) {
|
|
72
|
+
(result[entry.moduleId] ??= []).push(entry.implementation);
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}).pipe(Atom.keepAlive);
|
|
76
|
+
});
|
|
77
|
+
_capability = Atom.family((id) => {
|
|
78
|
+
return Atom.make((get2) => {
|
|
79
|
+
const current = get2(this._capabilities(id));
|
|
80
|
+
invariant(current.length > 0, `No capability found for ${id}`, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 35, S: this, A: ["current.length > 0", "`No capability found for ${id}`"] });
|
|
81
|
+
return current[0];
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
constructor({ registry }) {
|
|
85
|
+
this._registry = registry;
|
|
86
|
+
}
|
|
87
|
+
contribute({ module: moduleId, interface: interfaceDef, implementation }) {
|
|
88
|
+
const current = this._registry.get(this._capabilityEntries(interfaceDef.identifier));
|
|
89
|
+
const isDuplicate = current.some((c) => c.moduleId === moduleId && c.implementation === implementation);
|
|
90
|
+
if (isDuplicate) {
|
|
91
|
+
log("capability already contributed, skipping", {
|
|
92
|
+
id: interfaceDef.identifier,
|
|
93
|
+
moduleId
|
|
94
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 46, S: this });
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const entry = {
|
|
98
|
+
moduleId,
|
|
99
|
+
implementation
|
|
100
|
+
};
|
|
101
|
+
this._registry.set(this._capabilityEntries(interfaceDef.identifier), [
|
|
102
|
+
...current,
|
|
103
|
+
entry
|
|
104
|
+
]);
|
|
105
|
+
log("capability contributed", {
|
|
106
|
+
id: interfaceDef.identifier,
|
|
107
|
+
moduleId,
|
|
108
|
+
count: current.length
|
|
109
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 60, S: this });
|
|
110
|
+
}
|
|
111
|
+
remove(interfaceDef, implementation) {
|
|
112
|
+
const current = this._registry.get(this._capabilityEntries(interfaceDef.identifier));
|
|
113
|
+
if (current.length === 0) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const next = current.filter((c) => c.implementation !== implementation);
|
|
117
|
+
if (next.length !== current.length) {
|
|
118
|
+
this._registry.set(this._capabilityEntries(interfaceDef.identifier), next);
|
|
119
|
+
log("capability removed", {
|
|
120
|
+
id: interfaceDef.identifier,
|
|
121
|
+
count: current.length
|
|
122
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 74, S: this });
|
|
123
|
+
} else {
|
|
124
|
+
log.warn("capability not removed", {
|
|
125
|
+
id: interfaceDef.identifier
|
|
126
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 79, S: this });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
atom(interfaceDef) {
|
|
130
|
+
return this._capabilities(interfaceDef.identifier);
|
|
131
|
+
}
|
|
132
|
+
getAll(interfaceDef) {
|
|
133
|
+
return this._registry.get(this.atom(interfaceDef));
|
|
134
|
+
}
|
|
135
|
+
get(interfaceDef) {
|
|
136
|
+
const capabilities = this.getAll(interfaceDef);
|
|
137
|
+
invariant(capabilities.length > 0, `No capability found for ${interfaceDef.identifier}`, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 93, S: this, A: ["capabilities.length > 0", "`No capability found for ${interfaceDef.identifier}`"] });
|
|
138
|
+
return capabilities[0];
|
|
139
|
+
}
|
|
140
|
+
waitFor(interfaceDef) {
|
|
141
|
+
return Effect.gen(this, function* () {
|
|
142
|
+
const [capability] = this.getAll(interfaceDef);
|
|
143
|
+
if (capability) {
|
|
144
|
+
return capability;
|
|
145
|
+
}
|
|
146
|
+
const deferred = yield* Deferred.make();
|
|
147
|
+
const cancel = this._registry.subscribe(this.atom(interfaceDef), (capabilities) => {
|
|
148
|
+
if (capabilities.length > 0) {
|
|
149
|
+
Effect.runSync(Deferred.succeed(deferred, capabilities[0]));
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
const result = yield* Deferred.await(deferred);
|
|
153
|
+
cancel();
|
|
154
|
+
return result;
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
atomByModule(interfaceDef) {
|
|
158
|
+
return this._capabilitiesByModule(interfaceDef.identifier);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
var make2 = (options) => new CapabilityManagerImpl(options);
|
|
162
|
+
|
|
163
|
+
// src/core/registry.ts
|
|
164
|
+
var registry_exports = {};
|
|
165
|
+
__export(registry_exports, {
|
|
166
|
+
Manager: () => Manager
|
|
167
|
+
});
|
|
168
|
+
import { Atom as Atom2 } from "@effect-atom/atom-react";
|
|
169
|
+
import * as Effect2 from "effect/Effect";
|
|
170
|
+
import { runAndForwardErrors } from "@dxos/effect";
|
|
171
|
+
import { log as log2 } from "@dxos/log";
|
|
172
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/registry.ts";
|
|
173
|
+
var NULL_PROVIDER = {
|
|
174
|
+
listPlugins: () => Effect2.succeed([]),
|
|
175
|
+
listVersions: () => Effect2.fail(new Error("No plugin registry provider configured")),
|
|
176
|
+
getPlugin: () => Effect2.fail(new Error("No plugin registry provider configured"))
|
|
177
|
+
};
|
|
178
|
+
var Manager = class {
|
|
179
|
+
plugins;
|
|
180
|
+
#provider;
|
|
181
|
+
constructor(provider, atomRegistry) {
|
|
182
|
+
this.#provider = provider ?? NULL_PROVIDER;
|
|
183
|
+
const initialLoading = provider !== void 0;
|
|
184
|
+
this.plugins = Atom2.make({
|
|
185
|
+
entries: [],
|
|
186
|
+
loading: initialLoading,
|
|
187
|
+
error: null
|
|
188
|
+
}).pipe(Atom2.keepAlive);
|
|
189
|
+
if (provider !== void 0) {
|
|
190
|
+
void runAndForwardErrors(provider.listPlugins().pipe(Effect2.match({
|
|
191
|
+
onSuccess: (entries) => atomRegistry.set(this.plugins, {
|
|
192
|
+
entries,
|
|
193
|
+
loading: false,
|
|
194
|
+
error: null
|
|
195
|
+
}),
|
|
196
|
+
onFailure: (error) => {
|
|
197
|
+
log2.catch(error, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 49, S: this });
|
|
198
|
+
atomRegistry.set(this.plugins, {
|
|
199
|
+
entries: [],
|
|
200
|
+
loading: false,
|
|
201
|
+
error
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
})));
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/** Forwards to the underlying provider. */
|
|
208
|
+
listPlugins() {
|
|
209
|
+
return this.#provider.listPlugins();
|
|
210
|
+
}
|
|
211
|
+
/** Forwards to the underlying provider. */
|
|
212
|
+
listVersions(repo) {
|
|
213
|
+
return this.#provider.listVersions(repo);
|
|
214
|
+
}
|
|
215
|
+
/** Forwards to the underlying provider. */
|
|
216
|
+
getPlugin(repo, version) {
|
|
217
|
+
return this.#provider.getPlugin(repo, version);
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
// src/core/plugin-manager.ts
|
|
222
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/plugin-manager.ts";
|
|
223
|
+
var PluginInitializationError = class extends BaseError.extend("PluginInitializationError", "Plugin manager initialization failed") {
|
|
224
|
+
};
|
|
225
|
+
var PluginTimeoutError = class extends BaseError.extend("PluginTimeoutError", "Plugin operation timed out") {
|
|
226
|
+
};
|
|
227
|
+
var DEFAULT_LOAD_TIMEOUT = Duration.seconds(30);
|
|
228
|
+
var DEFAULT_ACTIVATION_TIMEOUT = Duration.seconds(30);
|
|
229
|
+
var ManagerTypeId = /* @__PURE__ */ Symbol.for("@dxos/app-framework/Manager");
|
|
230
|
+
var isManager = (value) => {
|
|
231
|
+
return typeof value === "object" && value !== null && ManagerTypeId in value;
|
|
232
|
+
};
|
|
233
|
+
var ManagerImpl = class {
|
|
234
|
+
[ManagerTypeId] = ManagerTypeId;
|
|
235
|
+
activation = Effect3.runSync(PubSub.unbounded());
|
|
236
|
+
capabilities;
|
|
237
|
+
registry;
|
|
238
|
+
pluginRegistry;
|
|
239
|
+
_pluginsAtom;
|
|
240
|
+
_coreAtom;
|
|
241
|
+
_enabledAtom;
|
|
242
|
+
_modulesAtom;
|
|
243
|
+
_activeAtom;
|
|
244
|
+
_eventsFiredAtom;
|
|
245
|
+
_pendingResetAtom;
|
|
246
|
+
_failedAtom;
|
|
247
|
+
_pluginLoader;
|
|
248
|
+
_onRemove;
|
|
249
|
+
_loadTimeout;
|
|
250
|
+
_activationTimeout;
|
|
251
|
+
_capabilities = /* @__PURE__ */ new Map();
|
|
252
|
+
_moduleMemoMap = /* @__PURE__ */ new Map();
|
|
253
|
+
_moduleSemaphores = /* @__PURE__ */ new Map();
|
|
254
|
+
// Coalesces concurrent `_resolveLazyPlugin` calls per plugin id. Without
|
|
255
|
+
// this, two callers entering `enable(id)` before the swap completes would
|
|
256
|
+
// each invoke `mod.default(options)` and produce distinct module objects,
|
|
257
|
+
// defeating `_addModule`'s reference-equality dedupe and racing the
|
|
258
|
+
// `_pluginsAtom` swap.
|
|
259
|
+
_resolvingPlugins = /* @__PURE__ */ new Map();
|
|
260
|
+
// Tracks dev-source plugins (loaded via a Vite dev server) keyed by id.
|
|
261
|
+
// When `shadow` is present, the entry has displaced an existing plugin —
|
|
262
|
+
// `remove` reinstates it and re-enables iff `wasEnabled`. Entries without a
|
|
263
|
+
// shadow are dev plugins with no underlying registry/builtin to restore.
|
|
264
|
+
// The atom mirrors the map's keys for UI subscribers (they don't need the
|
|
265
|
+
// shadow internals); the two stay in sync via {@link _markDev}/{@link _unmarkDev}.
|
|
266
|
+
_devPlugins = /* @__PURE__ */ new Map();
|
|
267
|
+
_devPluginIdsAtom;
|
|
268
|
+
_activatingEvents = Effect3.runSync(Ref.make([]));
|
|
269
|
+
_activatingModules = Effect3.runSync(Ref.make([]));
|
|
270
|
+
_inFlightFibers = Effect3.runSync(Ref.make([]));
|
|
271
|
+
_shutdownSemaphore = Effect3.runSync(Effect3.makeSemaphore(1));
|
|
272
|
+
_shuttingDown = Effect3.runSync(Ref.make(false));
|
|
273
|
+
// Tracks the constructor-launched core/enabled `enable()` calls so that
|
|
274
|
+
// `activate` can wait for module registration before dispatching events.
|
|
275
|
+
// Lazy plugins make `enable` asynchronous (a dynamic `import()` happens
|
|
276
|
+
// inside it), so without this synchronization an `activate` triggered
|
|
277
|
+
// immediately after `make` could fire on an empty module set. Failures
|
|
278
|
+
// are wrapped in `PluginInitializationError` so awaiters get a tagged
|
|
279
|
+
// error rather than the wide `Error` produced by the underlying chain.
|
|
280
|
+
_initialization = Effect3.runSync(Deferred2.make());
|
|
281
|
+
constructor({ pluginLoader, plugins = [], enabled = [], registry, pluginRegistryProvider, onRemove, loadTimeout = DEFAULT_LOAD_TIMEOUT, activationTimeout = DEFAULT_ACTIVATION_TIMEOUT }) {
|
|
282
|
+
const core = plugins.filter(({ meta }) => meta.tags?.includes("system")).map(({ meta }) => meta.id);
|
|
283
|
+
this.registry = registry ?? Registry.make();
|
|
284
|
+
this.capabilities = make2({
|
|
285
|
+
registry: this.registry
|
|
286
|
+
});
|
|
287
|
+
this.pluginRegistry = new Manager(pluginRegistryProvider, this.registry);
|
|
288
|
+
this._pluginLoader = pluginLoader;
|
|
289
|
+
this._onRemove = onRemove;
|
|
290
|
+
this._loadTimeout = loadTimeout;
|
|
291
|
+
this._activationTimeout = activationTimeout;
|
|
292
|
+
this._pluginsAtom = Atom3.make(plugins).pipe(Atom3.keepAlive);
|
|
293
|
+
this._coreAtom = Atom3.make(core).pipe(Atom3.keepAlive);
|
|
294
|
+
this._enabledAtom = Atom3.make(enabled).pipe(Atom3.keepAlive);
|
|
295
|
+
this._modulesAtom = Atom3.make([]).pipe(Atom3.keepAlive);
|
|
296
|
+
this._activeAtom = Atom3.make([]).pipe(Atom3.keepAlive);
|
|
297
|
+
this._eventsFiredAtom = Atom3.make([]).pipe(Atom3.keepAlive);
|
|
298
|
+
this._pendingResetAtom = Atom3.make([]).pipe(Atom3.keepAlive);
|
|
299
|
+
this._failedAtom = Atom3.make([]).pipe(Atom3.keepAlive);
|
|
300
|
+
this._devPluginIdsAtom = Atom3.make([]).pipe(Atom3.keepAlive);
|
|
301
|
+
plugins.forEach((plugin) => this._addPlugin(plugin));
|
|
302
|
+
const initialIds = [
|
|
303
|
+
.../* @__PURE__ */ new Set([
|
|
304
|
+
...core,
|
|
305
|
+
...enabled
|
|
306
|
+
])
|
|
307
|
+
];
|
|
308
|
+
void Effect3.all(initialIds.map((id) => this.enable(id))).pipe(Effect3.mapError((cause) => new PluginInitializationError({
|
|
309
|
+
cause
|
|
310
|
+
})), Effect3.tap(() => Deferred2.succeed(this._initialization, void 0)), Effect3.tapErrorCause((cause) => Deferred2.failCause(this._initialization, cause))).pipe(runAndForwardErrors2);
|
|
311
|
+
}
|
|
312
|
+
get plugins() {
|
|
313
|
+
return this._pluginsAtom;
|
|
314
|
+
}
|
|
315
|
+
get core() {
|
|
316
|
+
return this._coreAtom;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Ids of plugins that are currently enabled.
|
|
320
|
+
*/
|
|
321
|
+
get enabled() {
|
|
322
|
+
return this._enabledAtom;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Modules of plugins which are currently enabled.
|
|
326
|
+
*/
|
|
327
|
+
get modules() {
|
|
328
|
+
return this._modulesAtom;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Ids of modules which are currently active.
|
|
332
|
+
*/
|
|
333
|
+
get active() {
|
|
334
|
+
return this._activeAtom;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Ids of events which have been fired.
|
|
338
|
+
*/
|
|
339
|
+
get eventsFired() {
|
|
340
|
+
return this._eventsFiredAtom;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Ids of modules which are pending reset.
|
|
344
|
+
*/
|
|
345
|
+
get pendingReset() {
|
|
346
|
+
return this._pendingResetAtom;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Plugins that failed to load or activate.
|
|
350
|
+
*/
|
|
351
|
+
get failed() {
|
|
352
|
+
return this._failedAtom;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Ids of currently-registered plugins that came from a dev source.
|
|
356
|
+
*/
|
|
357
|
+
get devPluginIds() {
|
|
358
|
+
return this._devPluginIdsAtom;
|
|
359
|
+
}
|
|
360
|
+
getPlugins() {
|
|
361
|
+
return this._get(this._pluginsAtom);
|
|
362
|
+
}
|
|
363
|
+
getCore() {
|
|
364
|
+
return this._get(this._coreAtom);
|
|
365
|
+
}
|
|
366
|
+
getEnabled() {
|
|
367
|
+
return this._get(this._enabledAtom);
|
|
368
|
+
}
|
|
369
|
+
getModules() {
|
|
370
|
+
return this._get(this._modulesAtom);
|
|
371
|
+
}
|
|
372
|
+
getActive() {
|
|
373
|
+
return this._get(this._activeAtom);
|
|
374
|
+
}
|
|
375
|
+
getEventsFired() {
|
|
376
|
+
return this._get(this._eventsFiredAtom);
|
|
377
|
+
}
|
|
378
|
+
getPendingReset() {
|
|
379
|
+
return this._get(this._pendingResetAtom);
|
|
380
|
+
}
|
|
381
|
+
getFailed() {
|
|
382
|
+
return this._get(this._failedAtom);
|
|
383
|
+
}
|
|
384
|
+
getDevPluginIds() {
|
|
385
|
+
return this._get(this._devPluginIdsAtom);
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Marks `id` as dev-sourced. If the plugin displaced an existing one, pass
|
|
389
|
+
* the shadow snapshot so `remove` can restore it. Repeat calls (e.g. a dev
|
|
390
|
+
* plugin reload) preserve the original shadow target — restoration always
|
|
391
|
+
* unwinds back to the real underlying plugin, never an intermediate dev build.
|
|
392
|
+
*/
|
|
393
|
+
_markDev(id, shadow) {
|
|
394
|
+
if (this._devPlugins.has(id)) {
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
this._devPlugins.set(id, {
|
|
398
|
+
shadow
|
|
399
|
+
});
|
|
400
|
+
this._update(this._devPluginIdsAtom, (ids) => ids.includes(id) ? ids : [
|
|
401
|
+
...ids,
|
|
402
|
+
id
|
|
403
|
+
]);
|
|
404
|
+
}
|
|
405
|
+
/** Drops the dev-plugin entry and returns its shadow data (if any) for restoration. */
|
|
406
|
+
_unmarkDev(id) {
|
|
407
|
+
const entry = this._devPlugins.get(id);
|
|
408
|
+
this._devPlugins.delete(id);
|
|
409
|
+
this._update(this._devPluginIdsAtom, (ids) => ids.filter((existing) => existing !== id));
|
|
410
|
+
return entry?.shadow;
|
|
411
|
+
}
|
|
412
|
+
getDependencies(id, opts) {
|
|
413
|
+
const transitive = opts?.transitive !== false;
|
|
414
|
+
if (!transitive) {
|
|
415
|
+
return this._directDependencies(id);
|
|
416
|
+
}
|
|
417
|
+
const walk = this._computeDependencyClosure(id);
|
|
418
|
+
return walk.order.filter((depId) => depId !== id);
|
|
419
|
+
}
|
|
420
|
+
getDependents(id, opts) {
|
|
421
|
+
return this._collectDependents(id, {
|
|
422
|
+
transitive: opts?.transitive !== false,
|
|
423
|
+
enabledOnly: opts?.enabledOnly === true
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
clearFailure(id) {
|
|
427
|
+
const current = this._get(this._failedAtom);
|
|
428
|
+
if (!current.some((failure) => failure.id === id)) {
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
this._set(this._failedAtom, current.filter((failure) => failure.id !== id));
|
|
432
|
+
return true;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Adds a plugin to the manager via the plugin loader.
|
|
436
|
+
* The plugin is registered but not enabled; call `enable` separately to activate it.
|
|
437
|
+
* @param id The id of the plugin.
|
|
438
|
+
*/
|
|
439
|
+
add(id) {
|
|
440
|
+
return Effect3.gen(this, function* () {
|
|
441
|
+
log3("add plugin", {
|
|
442
|
+
id
|
|
443
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 262, S: this });
|
|
444
|
+
const { plugin, dev = false } = yield* this._pluginLoader(id);
|
|
445
|
+
const pluginId = plugin.meta.id;
|
|
446
|
+
const existing = this._getPlugin(pluginId);
|
|
447
|
+
if (dev && existing && existing !== plugin) {
|
|
448
|
+
const wasEnabled = this._get(this._enabledAtom).includes(pluginId);
|
|
449
|
+
if (wasEnabled) {
|
|
450
|
+
yield* this.disable(pluginId);
|
|
451
|
+
}
|
|
452
|
+
this._markDev(pluginId, {
|
|
453
|
+
plugin: existing,
|
|
454
|
+
wasEnabled
|
|
455
|
+
});
|
|
456
|
+
this._update(this._pluginsAtom, (plugins) => plugins.map((p) => p.meta.id === pluginId ? plugin : p));
|
|
457
|
+
} else {
|
|
458
|
+
this._addPlugin(plugin);
|
|
459
|
+
if (dev) {
|
|
460
|
+
this._markDev(pluginId);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return plugin;
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Enables a plugin.
|
|
468
|
+
* @param id The id of the plugin.
|
|
469
|
+
* @param opts See {@link PluginManager.enable}.
|
|
470
|
+
*/
|
|
471
|
+
enable(id, opts) {
|
|
472
|
+
const resolveDependencies = opts?.resolveDependencies !== false;
|
|
473
|
+
return Effect3.gen(this, function* () {
|
|
474
|
+
log3("enable plugin", {
|
|
475
|
+
id,
|
|
476
|
+
resolveDependencies
|
|
477
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 301, S: this });
|
|
478
|
+
if (!resolveDependencies) {
|
|
479
|
+
return yield* this._enableOne(id);
|
|
480
|
+
}
|
|
481
|
+
if (!this._getPlugin(id) && !this._getCatalogEntry(id)) {
|
|
482
|
+
return yield* this._enableOne(id);
|
|
483
|
+
}
|
|
484
|
+
const walk = this._computeDependencyClosure(id);
|
|
485
|
+
if (walk.cycle) {
|
|
486
|
+
this._recordFailure(id, "load", new PluginDependencyError({
|
|
487
|
+
context: {
|
|
488
|
+
id,
|
|
489
|
+
reason: "cycle",
|
|
490
|
+
path: walk.cycle
|
|
491
|
+
}
|
|
492
|
+
}));
|
|
493
|
+
return false;
|
|
494
|
+
}
|
|
495
|
+
if (walk.missing.length > 0) {
|
|
496
|
+
this._recordFailure(id, "load", new PluginDependencyError({
|
|
497
|
+
context: {
|
|
498
|
+
id,
|
|
499
|
+
reason: "missing",
|
|
500
|
+
missing: walk.missing
|
|
501
|
+
}
|
|
502
|
+
}));
|
|
503
|
+
return false;
|
|
504
|
+
}
|
|
505
|
+
let queue = walk.toInstall.slice();
|
|
506
|
+
const installed = /* @__PURE__ */ new Set();
|
|
507
|
+
while (queue.length > 0) {
|
|
508
|
+
const next = queue.shift();
|
|
509
|
+
if (installed.has(next) || this._getPlugin(next)) {
|
|
510
|
+
continue;
|
|
511
|
+
}
|
|
512
|
+
const installResult = yield* this.add(next).pipe(Effect3.either);
|
|
513
|
+
if (installResult._tag === "Left") {
|
|
514
|
+
this._recordFailure(id, "load", new PluginDependencyError({
|
|
515
|
+
context: {
|
|
516
|
+
id,
|
|
517
|
+
reason: "install-failed",
|
|
518
|
+
dependency: next
|
|
519
|
+
},
|
|
520
|
+
cause: installResult.left
|
|
521
|
+
}));
|
|
522
|
+
return false;
|
|
523
|
+
}
|
|
524
|
+
installed.add(next);
|
|
525
|
+
const rewalk = this._computeDependencyClosure(id);
|
|
526
|
+
if (rewalk.cycle) {
|
|
527
|
+
this._recordFailure(id, "load", new PluginDependencyError({
|
|
528
|
+
context: {
|
|
529
|
+
id,
|
|
530
|
+
reason: "cycle",
|
|
531
|
+
path: rewalk.cycle
|
|
532
|
+
}
|
|
533
|
+
}));
|
|
534
|
+
return false;
|
|
535
|
+
}
|
|
536
|
+
if (rewalk.missing.length > 0) {
|
|
537
|
+
this._recordFailure(id, "load", new PluginDependencyError({
|
|
538
|
+
context: {
|
|
539
|
+
id,
|
|
540
|
+
reason: "missing",
|
|
541
|
+
missing: rewalk.missing
|
|
542
|
+
}
|
|
543
|
+
}));
|
|
544
|
+
return false;
|
|
545
|
+
}
|
|
546
|
+
queue = rewalk.toInstall.filter((depId) => !installed.has(depId));
|
|
547
|
+
}
|
|
548
|
+
const order = this._computeDependencyClosure(id).order;
|
|
549
|
+
let succeeded = false;
|
|
550
|
+
for (const depId of order) {
|
|
551
|
+
const ok = yield* this._enableOne(depId);
|
|
552
|
+
if (depId === id) {
|
|
553
|
+
succeeded = ok;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
return succeeded;
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Enables a single plugin without consulting its declared dependencies.
|
|
561
|
+
* Used by {@link enable} as the leaf step after closure resolution, and
|
|
562
|
+
* directly when callers pass `{ resolveDependencies: false }`.
|
|
563
|
+
*
|
|
564
|
+
* The underlying operations (`_addModule`, `_setPendingResetByModule`,
|
|
565
|
+
* `activate`) are all idempotent, so this method is safe to call multiple
|
|
566
|
+
* times for the same id. The constructor's bootstrap path relies on this:
|
|
567
|
+
* the persisted `enabled` ids are written into `_enabledAtom` up front, so
|
|
568
|
+
* the very first `enable(id)` for those plugins sees `alreadyEnabled`-style
|
|
569
|
+
* state but still needs to perform the module registration and activation.
|
|
570
|
+
*/
|
|
571
|
+
_enableOne(id) {
|
|
572
|
+
return Effect3.gen(this, function* () {
|
|
573
|
+
const stub = this._getPlugin(id);
|
|
574
|
+
if (!stub) {
|
|
575
|
+
return false;
|
|
576
|
+
}
|
|
577
|
+
this.clearFailure(id);
|
|
578
|
+
const plugin = yield* this._resolveLazyPlugin(stub);
|
|
579
|
+
this._update(this._enabledAtom, (enabled) => enabled.includes(id) ? enabled : [
|
|
580
|
+
...enabled,
|
|
581
|
+
id
|
|
582
|
+
]);
|
|
583
|
+
plugin.modules.forEach((module) => {
|
|
584
|
+
this._addModule(module);
|
|
585
|
+
this._setPendingResetByModule(module);
|
|
586
|
+
});
|
|
587
|
+
log3("pending reset", {
|
|
588
|
+
events: [
|
|
589
|
+
...this.getPendingReset()
|
|
590
|
+
]
|
|
591
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 428, S: this });
|
|
592
|
+
yield* Effect3.all(this.getPendingReset().map((event) => this.activate(event)), {
|
|
593
|
+
concurrency: "unbounded"
|
|
594
|
+
});
|
|
595
|
+
return true;
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Resolves a lazy plugin stub (returned by {@link Plugin.lazy}) to its
|
|
600
|
+
* loaded form and swaps it into `_pluginsAtom`. Returns the input unchanged
|
|
601
|
+
* when the plugin is already resolved, so callers can `yield*` this
|
|
602
|
+
* unconditionally. The lazy stub carries `meta` synchronously but its
|
|
603
|
+
* `modules` list is empty until the loader resolves; the swap ensures
|
|
604
|
+
* subsequent enable/disable operations see the resolved plugin.
|
|
605
|
+
*
|
|
606
|
+
* Concurrent calls for the same id are coalesced via `_resolvingPlugins`:
|
|
607
|
+
* the first caller starts the resolution, every subsequent caller awaits
|
|
608
|
+
* the same `Deferred`. On failure we publish a `lazy:<id>` error message
|
|
609
|
+
* and skip the atom swap so the failure is observable to the activation
|
|
610
|
+
* subscriber and a retry can be attempted.
|
|
611
|
+
*/
|
|
612
|
+
_resolveLazyPlugin(plugin) {
|
|
613
|
+
return Effect3.gen(this, function* () {
|
|
614
|
+
if (!isLazy(plugin)) {
|
|
615
|
+
return plugin;
|
|
616
|
+
}
|
|
617
|
+
const id = plugin.meta.id;
|
|
618
|
+
const existing = this._resolvingPlugins.get(id);
|
|
619
|
+
if (existing) {
|
|
620
|
+
return yield* Deferred2.await(existing);
|
|
621
|
+
}
|
|
622
|
+
const deferred = yield* Deferred2.make();
|
|
623
|
+
this._resolvingPlugins.set(id, deferred);
|
|
624
|
+
return yield* Effect3.gen(this, function* () {
|
|
625
|
+
log3("resolving lazy plugin", {
|
|
626
|
+
id
|
|
627
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 465, S: this });
|
|
628
|
+
yield* PubSub.publish(this.activation, {
|
|
629
|
+
event: "",
|
|
630
|
+
state: "activating",
|
|
631
|
+
module: `lazy:${id}`
|
|
632
|
+
});
|
|
633
|
+
const resolvedPlugin = yield* resolveLazy(plugin).pipe(
|
|
634
|
+
// Cap how long a remote import can hang. Without this the host can
|
|
635
|
+
// sit on a pending dynamic `import()` indefinitely if the plugin's
|
|
636
|
+
// server is unreachable, which stalls every caller awaiting
|
|
637
|
+
// `enable(id)` and (transitively) the manager's initialization.
|
|
638
|
+
Effect3.timeoutFail({
|
|
639
|
+
duration: this._loadTimeout,
|
|
640
|
+
onTimeout: () => new LazyPluginError({
|
|
641
|
+
context: {
|
|
642
|
+
id,
|
|
643
|
+
reason: "load-failed"
|
|
644
|
+
},
|
|
645
|
+
cause: new PluginTimeoutError({
|
|
646
|
+
context: {
|
|
647
|
+
id,
|
|
648
|
+
phase: "load"
|
|
649
|
+
}
|
|
650
|
+
})
|
|
651
|
+
})
|
|
652
|
+
})
|
|
653
|
+
);
|
|
654
|
+
this._update(this._pluginsAtom, (plugins) => plugins.map((p) => p.meta.id === id ? resolvedPlugin : p));
|
|
655
|
+
yield* PubSub.publish(this.activation, {
|
|
656
|
+
event: "",
|
|
657
|
+
state: "activated",
|
|
658
|
+
module: `lazy:${id}`
|
|
659
|
+
});
|
|
660
|
+
return resolvedPlugin;
|
|
661
|
+
}).pipe(Effect3.tapError((error) => Effect3.gen(this, function* () {
|
|
662
|
+
yield* PubSub.publish(this.activation, {
|
|
663
|
+
event: "",
|
|
664
|
+
state: "error",
|
|
665
|
+
module: `lazy:${id}`,
|
|
666
|
+
error
|
|
667
|
+
});
|
|
668
|
+
this._recordFailure(id, "load", error);
|
|
669
|
+
this._scheduleAutoDisable(id);
|
|
670
|
+
})), Effect3.tap((value) => Deferred2.succeed(deferred, value)), Effect3.tapErrorCause((cause) => Deferred2.failCause(deferred, cause)), Effect3.ensuring(Effect3.sync(() => this._resolvingPlugins.delete(id))));
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Removes a plugin from the manager.
|
|
675
|
+
* @param id The id of the plugin.
|
|
676
|
+
* @param opts See {@link PluginManager.remove}.
|
|
677
|
+
*/
|
|
678
|
+
remove(id, opts) {
|
|
679
|
+
return Effect3.gen(this, function* () {
|
|
680
|
+
log3("remove plugin", {
|
|
681
|
+
id
|
|
682
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 517, S: this });
|
|
683
|
+
const wasDev = this._devPlugins.has(id);
|
|
684
|
+
const disabled = yield* this.disable(id, opts);
|
|
685
|
+
if (!disabled) {
|
|
686
|
+
return false;
|
|
687
|
+
}
|
|
688
|
+
this._removePlugin(id);
|
|
689
|
+
if (this._onRemove) {
|
|
690
|
+
this._runForkedFiber(this._onRemove(id).pipe(Effect3.tapError((error) => Effect3.sync(() => log3.warn("plugin remove hook failed", {
|
|
691
|
+
id,
|
|
692
|
+
error
|
|
693
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 527, S: this }))), Effect3.ignore));
|
|
694
|
+
}
|
|
695
|
+
if (wasDev) {
|
|
696
|
+
const shadow = this._unmarkDev(id);
|
|
697
|
+
if (shadow) {
|
|
698
|
+
this._addPlugin(shadow.plugin);
|
|
699
|
+
if (shadow.wasEnabled) {
|
|
700
|
+
yield* this.enable(id);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
return true;
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Disables a plugin.
|
|
709
|
+
* @param id The id of the plugin.
|
|
710
|
+
* @param opts See {@link PluginManager.disable}.
|
|
711
|
+
*/
|
|
712
|
+
disable(id, { cascade = true } = {}) {
|
|
713
|
+
return Effect3.gen(this, function* () {
|
|
714
|
+
log3("disable plugin", {
|
|
715
|
+
id,
|
|
716
|
+
cascade
|
|
717
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 555, S: this });
|
|
718
|
+
if (this._get(this._coreAtom).includes(id)) {
|
|
719
|
+
return false;
|
|
720
|
+
}
|
|
721
|
+
const plugin = this._getPlugin(id);
|
|
722
|
+
if (!plugin) {
|
|
723
|
+
return false;
|
|
724
|
+
}
|
|
725
|
+
if (cascade) {
|
|
726
|
+
const enabledDependents = this._collectDependents(id, {
|
|
727
|
+
transitive: true,
|
|
728
|
+
enabledOnly: true
|
|
729
|
+
});
|
|
730
|
+
if (enabledDependents.length > 0) {
|
|
731
|
+
const coreDependent = enabledDependents.find((dependentId) => this._get(this._coreAtom).includes(dependentId));
|
|
732
|
+
if (coreDependent) {
|
|
733
|
+
return yield* Effect3.fail(new PluginDependencyError({
|
|
734
|
+
context: {
|
|
735
|
+
id,
|
|
736
|
+
reason: "core-dependent",
|
|
737
|
+
coreDependent
|
|
738
|
+
}
|
|
739
|
+
}));
|
|
740
|
+
}
|
|
741
|
+
for (const dependentId of enabledDependents) {
|
|
742
|
+
yield* this._disableOne(dependentId);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
yield* this._disableOne(id);
|
|
747
|
+
return true;
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Disables a single plugin without consulting its dependents. Used by
|
|
752
|
+
* {@link disable} after the dependents pass has run (or been skipped via
|
|
753
|
+
* `cascade: false`).
|
|
754
|
+
*/
|
|
755
|
+
_disableOne(id) {
|
|
756
|
+
return Effect3.gen(this, function* () {
|
|
757
|
+
if (this._get(this._coreAtom).includes(id)) {
|
|
758
|
+
return false;
|
|
759
|
+
}
|
|
760
|
+
const plugin = this._getPlugin(id);
|
|
761
|
+
if (!plugin) {
|
|
762
|
+
return false;
|
|
763
|
+
}
|
|
764
|
+
const enabledIndex = this._get(this._enabledAtom).findIndex((enabled) => enabled === id);
|
|
765
|
+
if (enabledIndex !== -1) {
|
|
766
|
+
this._update(this._enabledAtom, (enabled) => enabled.filter((item) => item !== id));
|
|
767
|
+
yield* this.deactivate(id);
|
|
768
|
+
plugin.modules.forEach((module) => {
|
|
769
|
+
this._removeModule(module.id);
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
return true;
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* Activates plugins based on the activation event.
|
|
777
|
+
* @param event The activation event.
|
|
778
|
+
* @returns Whether the activation was successful.
|
|
779
|
+
*/
|
|
780
|
+
activate(event, params) {
|
|
781
|
+
const key = typeof event === "string" ? event : eventKey(event);
|
|
782
|
+
return Effect3.gen(this, function* () {
|
|
783
|
+
if (yield* this._isShuttingDown()) {
|
|
784
|
+
log3("skipping activation during shutdown", {
|
|
785
|
+
key,
|
|
786
|
+
...params
|
|
787
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 626, S: this });
|
|
788
|
+
return false;
|
|
789
|
+
}
|
|
790
|
+
yield* Deferred2.await(this._initialization);
|
|
791
|
+
return yield* Effect3.withFiberRuntime((fiber) => this._activateEvent(key, params, fiber).pipe(together(Effect3.sleep(Duration.seconds(15)).pipe(Effect3.andThen(Effect3.sync(() => log3.warn("event activation is taking a long time", {
|
|
792
|
+
event: key
|
|
793
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 637, S: this }))))), Performance.addTrackEntry({
|
|
794
|
+
name: typeof event === "string" ? event : eventKey(event),
|
|
795
|
+
devtools: {
|
|
796
|
+
dataType: "track-entry",
|
|
797
|
+
track: "Event Activation",
|
|
798
|
+
trackGroup: "Composer",
|
|
799
|
+
color: "primary"
|
|
800
|
+
}
|
|
801
|
+
})));
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* Deactivates all of the modules for a plugin.
|
|
806
|
+
* @param id The id of the plugin.
|
|
807
|
+
* @returns Whether the deactivation was successful.
|
|
808
|
+
*/
|
|
809
|
+
deactivate(id) {
|
|
810
|
+
return Effect3.gen(this, function* () {
|
|
811
|
+
const plugin = this._getPlugin(id);
|
|
812
|
+
if (!plugin) {
|
|
813
|
+
return false;
|
|
814
|
+
}
|
|
815
|
+
const modules = plugin.modules;
|
|
816
|
+
const results = yield* Effect3.all(modules.map((module) => this._deactivateModule(module)), {
|
|
817
|
+
concurrency: "unbounded"
|
|
818
|
+
});
|
|
819
|
+
return results.every((result) => result);
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Re-activates the modules that were activated by the event.
|
|
824
|
+
* @param event The activation event.
|
|
825
|
+
* @returns Whether the reset was successful.
|
|
826
|
+
*/
|
|
827
|
+
reset(event) {
|
|
828
|
+
return Effect3.gen(this, function* () {
|
|
829
|
+
const key = typeof event === "string" ? event : eventKey(event);
|
|
830
|
+
log3("reset", {
|
|
831
|
+
key
|
|
832
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 674, S: this });
|
|
833
|
+
const modules = this._getActiveModulesByEvent(key);
|
|
834
|
+
const results = yield* Effect3.all(modules.map((module) => this._deactivateModule(module)), {
|
|
835
|
+
concurrency: "unbounded"
|
|
836
|
+
});
|
|
837
|
+
if (results.every((result) => result)) {
|
|
838
|
+
return yield* this.activate(key);
|
|
839
|
+
} else {
|
|
840
|
+
return false;
|
|
841
|
+
}
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
shutdown() {
|
|
845
|
+
return this._shutdownSemaphore.withPermits(1)(Effect3.gen(this, function* () {
|
|
846
|
+
yield* Ref.set(this._shuttingDown, true);
|
|
847
|
+
log3("shutdown", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 691, S: this });
|
|
848
|
+
yield* this._interruptInFlightActivations();
|
|
849
|
+
const activeIds = [
|
|
850
|
+
...this._get(this._activeAtom)
|
|
851
|
+
].reverse();
|
|
852
|
+
const allModules = this._get(this._modulesAtom);
|
|
853
|
+
const modulesToDeactivate = activeIds.map((id) => allModules.find((module) => module.id === id)).filter((module) => module != null);
|
|
854
|
+
for (const module of modulesToDeactivate) {
|
|
855
|
+
yield* this._deactivateModule(module);
|
|
856
|
+
}
|
|
857
|
+
this._set(this._eventsFiredAtom, []);
|
|
858
|
+
this._set(this._pendingResetAtom, []);
|
|
859
|
+
this._moduleMemoMap.clear();
|
|
860
|
+
yield* Ref.set(this._activatingEvents, []);
|
|
861
|
+
yield* Ref.set(this._activatingModules, []);
|
|
862
|
+
log3("shutdown complete", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 706, S: this });
|
|
863
|
+
return true;
|
|
864
|
+
}).pipe(Effect3.ensuring(Ref.set(this._shuttingDown, false))));
|
|
865
|
+
}
|
|
866
|
+
//
|
|
867
|
+
// State helpers
|
|
868
|
+
//
|
|
869
|
+
_get(atom) {
|
|
870
|
+
return this.registry.get(atom);
|
|
871
|
+
}
|
|
872
|
+
_set(atom, value) {
|
|
873
|
+
this.registry.set(atom, value);
|
|
874
|
+
}
|
|
875
|
+
_update(atom, updater) {
|
|
876
|
+
this._set(atom, updater(this._get(atom)));
|
|
877
|
+
}
|
|
878
|
+
_isShuttingDown() {
|
|
879
|
+
return Ref.get(this._shuttingDown);
|
|
880
|
+
}
|
|
881
|
+
_getPlugin(id) {
|
|
882
|
+
return this._get(this._pluginsAtom).find((plugin) => plugin.meta.id === id);
|
|
883
|
+
}
|
|
884
|
+
_getPluginIdForModule(moduleId) {
|
|
885
|
+
return this._get(this._pluginsAtom).find((plugin) => plugin.modules.some((module) => module.id === moduleId))?.meta.id;
|
|
886
|
+
}
|
|
887
|
+
/** Looks up an id in the cached registry catalog, returning the entry or `undefined`. */
|
|
888
|
+
_getCatalogEntry(id) {
|
|
889
|
+
return this._get(this.pluginRegistry.plugins).entries.find((entry) => entry.id === id);
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Returns the direct `dependsOn` declarations for an id, drawing from the
|
|
893
|
+
* registered plugin's meta when available and falling back to the registry
|
|
894
|
+
* catalog entry. Unknown ids return an empty list (callers detect "missing"
|
|
895
|
+
* separately).
|
|
896
|
+
*/
|
|
897
|
+
_directDependencies(id) {
|
|
898
|
+
const plugin = this._getPlugin(id);
|
|
899
|
+
if (plugin) {
|
|
900
|
+
return [
|
|
901
|
+
...plugin.meta.dependsOn ?? []
|
|
902
|
+
];
|
|
903
|
+
}
|
|
904
|
+
const catalog = this._getCatalogEntry(id);
|
|
905
|
+
return catalog?.dependsOn ? [
|
|
906
|
+
...catalog.dependsOn
|
|
907
|
+
] : [];
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* Computes the transitive dependency closure for an id.
|
|
911
|
+
*
|
|
912
|
+
* Walks {@link _directDependencies} (registered plugins ∪ catalog entries).
|
|
913
|
+
* Returns:
|
|
914
|
+
* - `order`: closure including the root in dependency-first topological order.
|
|
915
|
+
* - `missing`: ids in the closure that are neither registered nor in the catalog.
|
|
916
|
+
* - `toInstall`: ids in the closure that are in the catalog but not yet registered.
|
|
917
|
+
* - `cycle`: when a cycle is detected, the cycle path; otherwise `undefined`.
|
|
918
|
+
*/
|
|
919
|
+
_computeDependencyClosure(id) {
|
|
920
|
+
const order = [];
|
|
921
|
+
const visited = /* @__PURE__ */ new Set();
|
|
922
|
+
const onStack = /* @__PURE__ */ new Set();
|
|
923
|
+
const stackPath = [];
|
|
924
|
+
const missing = [];
|
|
925
|
+
const toInstall = [];
|
|
926
|
+
let cycle;
|
|
927
|
+
const knownIds = /* @__PURE__ */ new Set([
|
|
928
|
+
...this._get(this._pluginsAtom).map((plugin) => plugin.meta.id),
|
|
929
|
+
...this._get(this.pluginRegistry.plugins).entries.map((entry) => entry.id)
|
|
930
|
+
]);
|
|
931
|
+
const visit = (currentId) => {
|
|
932
|
+
if (cycle) {
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
if (visited.has(currentId)) {
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
if (onStack.has(currentId)) {
|
|
939
|
+
const cycleStart = stackPath.indexOf(currentId);
|
|
940
|
+
cycle = [
|
|
941
|
+
...stackPath.slice(cycleStart),
|
|
942
|
+
currentId
|
|
943
|
+
];
|
|
944
|
+
return;
|
|
945
|
+
}
|
|
946
|
+
onStack.add(currentId);
|
|
947
|
+
stackPath.push(currentId);
|
|
948
|
+
if (!knownIds.has(currentId)) {
|
|
949
|
+
missing.push(currentId);
|
|
950
|
+
} else if (!this._getPlugin(currentId)) {
|
|
951
|
+
toInstall.push(currentId);
|
|
952
|
+
}
|
|
953
|
+
for (const depId of this._directDependencies(currentId)) {
|
|
954
|
+
visit(depId);
|
|
955
|
+
if (cycle) {
|
|
956
|
+
break;
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
onStack.delete(currentId);
|
|
960
|
+
stackPath.pop();
|
|
961
|
+
if (!cycle) {
|
|
962
|
+
visited.add(currentId);
|
|
963
|
+
order.push(currentId);
|
|
964
|
+
}
|
|
965
|
+
};
|
|
966
|
+
visit(id);
|
|
967
|
+
return {
|
|
968
|
+
order,
|
|
969
|
+
missing,
|
|
970
|
+
toInstall,
|
|
971
|
+
cycle
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* Walks the reverse `dependsOn` edges across registered plugins. With
|
|
976
|
+
* `enabledOnly`, filters the result to currently-enabled ids. Returns
|
|
977
|
+
* dependents in dependents-before-deps order so callers (cascade-disable)
|
|
978
|
+
* can iterate and tear down leaves first.
|
|
979
|
+
*/
|
|
980
|
+
_collectDependents(id, opts) {
|
|
981
|
+
const direct = this._get(this._pluginsAtom).filter((plugin) => plugin.meta.dependsOn?.includes(id)).map((plugin) => plugin.meta.id);
|
|
982
|
+
if (!opts.transitive) {
|
|
983
|
+
return opts.enabledOnly ? direct.filter((dependentId) => this._get(this._enabledAtom).includes(dependentId)) : direct;
|
|
984
|
+
}
|
|
985
|
+
const result = [];
|
|
986
|
+
const visited = /* @__PURE__ */ new Set();
|
|
987
|
+
const visit = (currentId) => {
|
|
988
|
+
if (visited.has(currentId)) {
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
visited.add(currentId);
|
|
992
|
+
const parents = this._get(this._pluginsAtom).filter((plugin) => plugin.meta.dependsOn?.includes(currentId)).map((plugin) => plugin.meta.id);
|
|
993
|
+
for (const parentId of parents) {
|
|
994
|
+
visit(parentId);
|
|
995
|
+
if (parentId !== id && !result.includes(parentId)) {
|
|
996
|
+
result.push(parentId);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
};
|
|
1000
|
+
visit(id);
|
|
1001
|
+
return opts.enabledOnly ? result.filter((dependentId) => this._get(this._enabledAtom).includes(dependentId)) : result;
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Records a failure for a plugin. Latest failure wins so the registry UI
|
|
1005
|
+
* always sees the most recent reason. Walks the `cause` chain when checking
|
|
1006
|
+
* for timeouts: lazy-load timeouts arrive wrapped in `LazyPluginError` (the
|
|
1007
|
+
* timeout is the cause), but the operator-visible reason should still be
|
|
1008
|
+
* `'timeout'`.
|
|
1009
|
+
*/
|
|
1010
|
+
_recordFailure(id, phase, error) {
|
|
1011
|
+
const reason = isTimeoutCause(error) ? "timeout" : "error";
|
|
1012
|
+
const failure = {
|
|
1013
|
+
id,
|
|
1014
|
+
phase,
|
|
1015
|
+
reason,
|
|
1016
|
+
error,
|
|
1017
|
+
timestamp: Date.now()
|
|
1018
|
+
};
|
|
1019
|
+
log3.warn("plugin failed", {
|
|
1020
|
+
id,
|
|
1021
|
+
phase,
|
|
1022
|
+
reason,
|
|
1023
|
+
error: error.message
|
|
1024
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 858, S: this });
|
|
1025
|
+
this._update(this._failedAtom, (current) => [
|
|
1026
|
+
...current.filter((entry) => entry.id !== id),
|
|
1027
|
+
failure
|
|
1028
|
+
]);
|
|
1029
|
+
}
|
|
1030
|
+
/**
|
|
1031
|
+
* Fire-and-forget disable of a failed plugin. Forked because a failure can
|
|
1032
|
+
* happen mid-activation chain — yielding a `disable` inline would deadlock
|
|
1033
|
+
* on the shared semaphores. Core plugins are skipped (the host opted into
|
|
1034
|
+
* them being non-removable; the failure record is enough signal).
|
|
1035
|
+
*/
|
|
1036
|
+
_scheduleAutoDisable(id) {
|
|
1037
|
+
if (this._get(this._coreAtom).includes(id)) {
|
|
1038
|
+
return;
|
|
1039
|
+
}
|
|
1040
|
+
if (!this._get(this._enabledAtom).includes(id)) {
|
|
1041
|
+
return;
|
|
1042
|
+
}
|
|
1043
|
+
this._runForkedFiber(this.disable(id).pipe(Effect3.tapError((error) => Effect3.sync(() => log3.warn("auto-disable failed", {
|
|
1044
|
+
id,
|
|
1045
|
+
error
|
|
1046
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 881, S: this }))), Effect3.ignore));
|
|
1047
|
+
}
|
|
1048
|
+
_getActiveModules() {
|
|
1049
|
+
const active = this._get(this._activeAtom);
|
|
1050
|
+
return this._get(this._modulesAtom).filter((module) => active.includes(module.id));
|
|
1051
|
+
}
|
|
1052
|
+
_getInactiveModules() {
|
|
1053
|
+
const active = this._get(this._activeAtom);
|
|
1054
|
+
return this._get(this._modulesAtom).filter((module) => !active.includes(module.id));
|
|
1055
|
+
}
|
|
1056
|
+
_getActiveModulesByEvent(key) {
|
|
1057
|
+
return this._getActiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
|
|
1058
|
+
}
|
|
1059
|
+
_getInactiveModulesByEvent(key) {
|
|
1060
|
+
return this._getInactiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
|
|
1061
|
+
}
|
|
1062
|
+
_setPendingResetByModule(module) {
|
|
1063
|
+
const activationEvents = getEvents(module.activatesOn).map(eventKey).filter((key) => this._get(this._eventsFiredAtom).includes(key));
|
|
1064
|
+
const pendingReset = Array.fromIterable(new Set(activationEvents)).filter((event) => {
|
|
1065
|
+
const pending = this._get(this._pendingResetAtom);
|
|
1066
|
+
return !pending.includes(event);
|
|
1067
|
+
});
|
|
1068
|
+
if (pendingReset.length > 0) {
|
|
1069
|
+
log3("pending reset", {
|
|
1070
|
+
events: pendingReset
|
|
1071
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 907, S: this });
|
|
1072
|
+
this._update(this._pendingResetAtom, (current) => [
|
|
1073
|
+
...current,
|
|
1074
|
+
...pendingReset
|
|
1075
|
+
]);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
_clearPendingReset(key) {
|
|
1079
|
+
const pendingIndex = this._get(this._pendingResetAtom).findIndex((event) => event === key);
|
|
1080
|
+
if (pendingIndex !== -1) {
|
|
1081
|
+
this._update(this._pendingResetAtom, (pending) => pending.filter((event) => event !== key));
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
//
|
|
1085
|
+
// Fiber helpers
|
|
1086
|
+
//
|
|
1087
|
+
_interruptInFlightActivations() {
|
|
1088
|
+
return Effect3.gen(this, function* () {
|
|
1089
|
+
const inFlightFibers = yield* Ref.get(this._inFlightFibers);
|
|
1090
|
+
yield* Effect3.forEach(inFlightFibers, (fiber) => Fiber.interrupt(fiber), {
|
|
1091
|
+
concurrency: "unbounded"
|
|
1092
|
+
});
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
_trackFiber(ref, fiber) {
|
|
1096
|
+
return Ref.update(ref, (fibers) => [
|
|
1097
|
+
...fibers,
|
|
1098
|
+
fiber
|
|
1099
|
+
]);
|
|
1100
|
+
}
|
|
1101
|
+
_untrackFiber(ref, fiber) {
|
|
1102
|
+
return Ref.update(ref, (fibers) => fibers.filter((trackedFiber) => trackedFiber !== fiber));
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Spawns an effect on the default runtime and registers the resulting fiber in
|
|
1106
|
+
* `_inFlightFibers` so {@link shutdown} can interrupt it. Used from sync entry
|
|
1107
|
+
* points like {@link remove} where there is no enclosing Effect to fork from;
|
|
1108
|
+
* inside an Effect chain prefer the existing track/await/untrack pattern.
|
|
1109
|
+
*/
|
|
1110
|
+
_runForkedFiber(effect) {
|
|
1111
|
+
const fiber = Effect3.runFork(effect);
|
|
1112
|
+
Effect3.runSync(this._trackFiber(this._inFlightFibers, fiber));
|
|
1113
|
+
Effect3.runFork(Fiber.await(fiber).pipe(Effect3.andThen(() => this._untrackFiber(this._inFlightFibers, fiber))));
|
|
1114
|
+
}
|
|
1115
|
+
//
|
|
1116
|
+
// Registration helpers
|
|
1117
|
+
//
|
|
1118
|
+
_addPlugin(plugin) {
|
|
1119
|
+
log3("add plugin", {
|
|
1120
|
+
id: plugin.meta.id
|
|
1121
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 956, S: this });
|
|
1122
|
+
this._update(this._pluginsAtom, (plugins) => plugins.includes(plugin) ? plugins : [
|
|
1123
|
+
...plugins,
|
|
1124
|
+
plugin
|
|
1125
|
+
]);
|
|
1126
|
+
}
|
|
1127
|
+
_removePlugin(id) {
|
|
1128
|
+
log3("remove plugin", {
|
|
1129
|
+
id
|
|
1130
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 966, S: this });
|
|
1131
|
+
this._update(this._pluginsAtom, (plugins) => plugins.filter((plugin) => plugin.meta.id !== id));
|
|
1132
|
+
}
|
|
1133
|
+
_addModule(module) {
|
|
1134
|
+
log3("add module", {
|
|
1135
|
+
id: module.id
|
|
1136
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 972, S: this });
|
|
1137
|
+
this._update(this._modulesAtom, (modules) => modules.includes(module) ? modules : [
|
|
1138
|
+
...modules,
|
|
1139
|
+
module
|
|
1140
|
+
]);
|
|
1141
|
+
}
|
|
1142
|
+
_removeModule(id) {
|
|
1143
|
+
log3("remove module", {
|
|
1144
|
+
id
|
|
1145
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 982, S: this });
|
|
1146
|
+
this._update(this._modulesAtom, (modules) => modules.filter((module) => module.id !== id));
|
|
1147
|
+
}
|
|
1148
|
+
//
|
|
1149
|
+
// Activation helpers
|
|
1150
|
+
//
|
|
1151
|
+
_activateEvent(key, params, fiber) {
|
|
1152
|
+
return Effect3.gen(this, function* () {
|
|
1153
|
+
yield* this._trackFiber(this._inFlightFibers, fiber);
|
|
1154
|
+
log3("activating", {
|
|
1155
|
+
key,
|
|
1156
|
+
...params
|
|
1157
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 993, S: this });
|
|
1158
|
+
yield* Ref.update(this._activatingEvents, (activating) => Array.append(activating, key));
|
|
1159
|
+
this._clearPendingReset(key);
|
|
1160
|
+
const activatingEvents = yield* this._activatingEvents;
|
|
1161
|
+
const activatingModules = yield* this._activatingModules;
|
|
1162
|
+
const modules = this._getModulesForActivation(key, activatingEvents, activatingModules);
|
|
1163
|
+
if (modules.length === 0) {
|
|
1164
|
+
log3("no modules to activate", {
|
|
1165
|
+
key
|
|
1166
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 1003, S: this });
|
|
1167
|
+
if (!this._get(this._eventsFiredAtom).includes(key)) {
|
|
1168
|
+
this._update(this._eventsFiredAtom, (events) => [
|
|
1169
|
+
...events,
|
|
1170
|
+
key
|
|
1171
|
+
]);
|
|
1172
|
+
}
|
|
1173
|
+
return false;
|
|
1174
|
+
}
|
|
1175
|
+
return yield* this._activateModulesForEvent(key, modules, activatingEvents);
|
|
1176
|
+
}).pipe(Effect3.ensuring(Effect3.all([
|
|
1177
|
+
this._untrackFiber(this._inFlightFibers, fiber),
|
|
1178
|
+
Ref.update(this._activatingEvents, (activating) => Array.filter(activating, (event) => event !== key))
|
|
1179
|
+
])));
|
|
1180
|
+
}
|
|
1181
|
+
_activateModulesForEvent(key, modules, activatingEvents) {
|
|
1182
|
+
const activatingModuleIds = modules.map((module) => module.id);
|
|
1183
|
+
return Effect3.gen(this, function* () {
|
|
1184
|
+
yield* Ref.update(this._activatingModules, (activating) => Array.appendAll(activating, activatingModuleIds));
|
|
1185
|
+
log3("activating modules", {
|
|
1186
|
+
key,
|
|
1187
|
+
modules: activatingModuleIds
|
|
1188
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 1024, S: this });
|
|
1189
|
+
performance.mark(`event:${key}:start`);
|
|
1190
|
+
yield* PubSub.publish(this.activation, {
|
|
1191
|
+
event: key,
|
|
1192
|
+
state: "activating"
|
|
1193
|
+
});
|
|
1194
|
+
yield* this._activateRelatedEvents(key, this._getBeforeEvents(modules, activatingEvents), "before");
|
|
1195
|
+
const capabilities = yield* this._loadCapabilitiesForModules(key, modules);
|
|
1196
|
+
yield* this._contributeCapabilitiesForModules(modules, capabilities);
|
|
1197
|
+
yield* this._activateRelatedEvents(key, this._getAfterEvents(modules, activatingEvents), "after");
|
|
1198
|
+
if (!this._get(this._eventsFiredAtom).includes(key)) {
|
|
1199
|
+
this._update(this._eventsFiredAtom, (events) => [
|
|
1200
|
+
...events,
|
|
1201
|
+
key
|
|
1202
|
+
]);
|
|
1203
|
+
}
|
|
1204
|
+
performance.mark(`event:${key}:end`);
|
|
1205
|
+
performance.measure(`event:${key}`, `event:${key}:start`, `event:${key}:end`);
|
|
1206
|
+
yield* PubSub.publish(this.activation, {
|
|
1207
|
+
event: key,
|
|
1208
|
+
state: "activated"
|
|
1209
|
+
});
|
|
1210
|
+
log3("activated", {
|
|
1211
|
+
key
|
|
1212
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 1049, S: this });
|
|
1213
|
+
return true;
|
|
1214
|
+
}).pipe(Effect3.ensuring(Ref.update(this._activatingModules, (activating) => Array.filter(activating, (module) => !activatingModuleIds.includes(module)))));
|
|
1215
|
+
}
|
|
1216
|
+
_getModulesForActivation(key, activatingEvents, activatingModules) {
|
|
1217
|
+
return this._getInactiveModulesByEvent(key).filter((module) => {
|
|
1218
|
+
const allOf = isAllOf(module.activatesOn);
|
|
1219
|
+
if (!allOf) {
|
|
1220
|
+
return true;
|
|
1221
|
+
}
|
|
1222
|
+
const events = getEvents(module.activatesOn).filter((event) => eventKey(event) !== key);
|
|
1223
|
+
return events.every((event) => this._get(this._eventsFiredAtom).includes(eventKey(event)) || activatingEvents.includes(eventKey(event))) && !activatingModules.includes(module.id);
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1226
|
+
_getBeforeEvents(modules, activatingEvents) {
|
|
1227
|
+
return Function.pipe(modules, Array.flatMap((module) => module.firesBeforeActivation ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event) => !activatingEvents.includes(eventKey(event))));
|
|
1228
|
+
}
|
|
1229
|
+
_getAfterEvents(modules, activatingEvents) {
|
|
1230
|
+
return Function.pipe(modules, Array.flatMap((module) => module.firesAfterActivation ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event) => !activatingEvents.includes(eventKey(event))));
|
|
1231
|
+
}
|
|
1232
|
+
_activateRelatedEvents(key, events, phase) {
|
|
1233
|
+
const logLabel = phase === "before" ? "firesBeforeActivation" : "firesAfterActivation";
|
|
1234
|
+
const eventKey2 = phase === "before" ? "beforeEvents" : "afterEvents";
|
|
1235
|
+
return Function.pipe(events, Array.map((event) => this.activate(event, phase === "before" ? {
|
|
1236
|
+
before: key
|
|
1237
|
+
} : {
|
|
1238
|
+
after: key
|
|
1239
|
+
})), Effect3.allWith({
|
|
1240
|
+
concurrency: "unbounded"
|
|
1241
|
+
}), together(Effect3.sleep(Duration.seconds(10)).pipe(Effect3.andThen(Effect3.sync(() => log3.warn(`${logLabel} is taking a long time`, {
|
|
1242
|
+
event: key,
|
|
1243
|
+
[eventKey2]: events.map(eventKey)
|
|
1244
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 1082, S: this }))))), Effect3.asVoid);
|
|
1245
|
+
}
|
|
1246
|
+
//
|
|
1247
|
+
// Module lifecycle helpers
|
|
1248
|
+
//
|
|
1249
|
+
_loadCapabilitiesForModules(key, modules) {
|
|
1250
|
+
return Function.pipe(modules, Array.map((mod) => this._loadModule(mod, key)), Effect3.allWith({
|
|
1251
|
+
concurrency: "unbounded"
|
|
1252
|
+
}), Effect3.catchAll((error) => {
|
|
1253
|
+
return Effect3.gen(this, function* () {
|
|
1254
|
+
yield* PubSub.publish(this.activation, {
|
|
1255
|
+
event: key,
|
|
1256
|
+
state: "error",
|
|
1257
|
+
error
|
|
1258
|
+
});
|
|
1259
|
+
return yield* Effect3.fail(error);
|
|
1260
|
+
});
|
|
1261
|
+
}));
|
|
1262
|
+
}
|
|
1263
|
+
_contributeCapabilitiesForModules(modules, capabilities) {
|
|
1264
|
+
return Function.pipe(
|
|
1265
|
+
modules,
|
|
1266
|
+
Array.zip(capabilities),
|
|
1267
|
+
Array.map(([module, capabilitySet]) => this._contributeCapabilities(module, capabilitySet)),
|
|
1268
|
+
Effect3.all,
|
|
1269
|
+
Effect3.asVoid
|
|
1270
|
+
);
|
|
1271
|
+
}
|
|
1272
|
+
_getModuleSemaphore(moduleId) {
|
|
1273
|
+
let semaphore = this._moduleSemaphores.get(moduleId);
|
|
1274
|
+
if (!semaphore) {
|
|
1275
|
+
semaphore = Effect3.runSync(Effect3.makeSemaphore(1));
|
|
1276
|
+
this._moduleSemaphores.set(moduleId, semaphore);
|
|
1277
|
+
}
|
|
1278
|
+
return semaphore;
|
|
1279
|
+
}
|
|
1280
|
+
// `parentEvent` is the activation event that first triggered this module
|
|
1281
|
+
// load — included in `activating`/`activated` PubSub messages so subscribers
|
|
1282
|
+
// (e.g. the boot loader's status listener) can associate a module with its
|
|
1283
|
+
// triggering event in the trace. The same module may be referenced by
|
|
1284
|
+
// multiple events, but module loads are memoized via `_moduleMemoMap`, so
|
|
1285
|
+
// only the first event to need it will appear here; later events await the
|
|
1286
|
+
// cached deferred without re-publishing.
|
|
1287
|
+
_loadModule = (module, parentEvent) => Effect3.gen(this, function* () {
|
|
1288
|
+
const semaphore = this._getModuleSemaphore(module.id);
|
|
1289
|
+
const deferredToAwait = yield* Effect3.gen(this, function* () {
|
|
1290
|
+
const existing = this._moduleMemoMap.get(module.id);
|
|
1291
|
+
if (existing) {
|
|
1292
|
+
return existing;
|
|
1293
|
+
}
|
|
1294
|
+
const deferred = yield* Deferred2.make();
|
|
1295
|
+
this._moduleMemoMap.set(module.id, deferred);
|
|
1296
|
+
const loadEffect = Effect3.gen(this, function* () {
|
|
1297
|
+
log3("loading module", {
|
|
1298
|
+
module: module.id,
|
|
1299
|
+
parentEvent
|
|
1300
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 1140, S: this });
|
|
1301
|
+
performance.mark(`module:${module.id}:start`);
|
|
1302
|
+
yield* PubSub.publish(this.activation, {
|
|
1303
|
+
event: parentEvent,
|
|
1304
|
+
state: "activating",
|
|
1305
|
+
module: module.id
|
|
1306
|
+
});
|
|
1307
|
+
const pluginId = this._getPluginIdForModule(module.id);
|
|
1308
|
+
const [duration, capabilities] = yield* module.activate().pipe(
|
|
1309
|
+
Effect3.provideService(Service, this.capabilities),
|
|
1310
|
+
Effect3.provideService(Service2, this),
|
|
1311
|
+
// Cap activation so a single misbehaving module can't hold the
|
|
1312
|
+
// event chain open. On timeout the failure is recorded against
|
|
1313
|
+
// the plugin and surfaced as `PluginTimeoutError`.
|
|
1314
|
+
Effect3.timeoutFail({
|
|
1315
|
+
duration: this._activationTimeout,
|
|
1316
|
+
onTimeout: () => new PluginTimeoutError({
|
|
1317
|
+
context: {
|
|
1318
|
+
id: pluginId ?? module.id,
|
|
1319
|
+
module: module.id,
|
|
1320
|
+
phase: "activation"
|
|
1321
|
+
}
|
|
1322
|
+
})
|
|
1323
|
+
}),
|
|
1324
|
+
Effect3.timed
|
|
1325
|
+
);
|
|
1326
|
+
const normalized = capabilities == null ? [] : Array.isArray(capabilities) ? capabilities : [
|
|
1327
|
+
capabilities
|
|
1328
|
+
];
|
|
1329
|
+
const elapsed = Duration.toMillis(duration);
|
|
1330
|
+
performance.mark(`module:${module.id}:end`);
|
|
1331
|
+
performance.measure(`module:${module.id}`, `module:${module.id}:start`, `module:${module.id}:end`);
|
|
1332
|
+
yield* PubSub.publish(this.activation, {
|
|
1333
|
+
event: parentEvent,
|
|
1334
|
+
state: "activated",
|
|
1335
|
+
module: module.id
|
|
1336
|
+
});
|
|
1337
|
+
log3("loaded module", {
|
|
1338
|
+
module: module.id,
|
|
1339
|
+
parentEvent,
|
|
1340
|
+
elapsed,
|
|
1341
|
+
failed: false
|
|
1342
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 1175, S: this });
|
|
1343
|
+
return normalized;
|
|
1344
|
+
}).pipe(Effect3.withSpan("PluginManager._loadModule"), together(Effect3.sleep(Duration.seconds(10)).pipe(Effect3.andThen(Effect3.sync(() => log3.warn(`module is taking a long time to activate`, {
|
|
1345
|
+
module: module.id
|
|
1346
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 1182, S: this }))))), Performance.addTrackEntry({
|
|
1347
|
+
name: module.id,
|
|
1348
|
+
devtools: {
|
|
1349
|
+
dataType: "track-entry",
|
|
1350
|
+
track: "Module Activation",
|
|
1351
|
+
trackGroup: "Composer",
|
|
1352
|
+
color: "primary"
|
|
1353
|
+
}
|
|
1354
|
+
}));
|
|
1355
|
+
const fiber = yield* Effect3.forkDaemon(loadEffect.pipe(Effect3.tap((result) => Deferred2.succeed(deferred, result)), Effect3.catchAllCause((cause) => {
|
|
1356
|
+
const error = Cause.squash(cause);
|
|
1357
|
+
log3.error("module failed to activate", {
|
|
1358
|
+
module: module.id,
|
|
1359
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1360
|
+
stack: error instanceof Error ? error.stack : void 0,
|
|
1361
|
+
isDefect: !Cause.isFailure(cause)
|
|
1362
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 1196, S: this });
|
|
1363
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
1364
|
+
const pluginId = this._getPluginIdForModule(module.id);
|
|
1365
|
+
if (pluginId !== void 0) {
|
|
1366
|
+
this._recordFailure(pluginId, "activation", normalizedError);
|
|
1367
|
+
this._scheduleAutoDisable(pluginId);
|
|
1368
|
+
}
|
|
1369
|
+
return Deferred2.fail(deferred, normalizedError);
|
|
1370
|
+
})));
|
|
1371
|
+
yield* this._trackFiber(this._inFlightFibers, fiber);
|
|
1372
|
+
yield* Effect3.forkDaemon(Fiber.await(fiber).pipe(Effect3.andThen(() => this._untrackFiber(this._inFlightFibers, fiber))));
|
|
1373
|
+
return deferred;
|
|
1374
|
+
}).pipe(semaphore.withPermits(1));
|
|
1375
|
+
return yield* Deferred2.await(deferredToAwait);
|
|
1376
|
+
});
|
|
1377
|
+
_contributeCapabilities(module, capabilities) {
|
|
1378
|
+
return Effect3.gen(this, function* () {
|
|
1379
|
+
capabilities.forEach((capability) => {
|
|
1380
|
+
this.capabilities.contribute({
|
|
1381
|
+
module: module.id,
|
|
1382
|
+
...capability
|
|
1383
|
+
});
|
|
1384
|
+
});
|
|
1385
|
+
this._update(this._activeAtom, (active) => [
|
|
1386
|
+
...active,
|
|
1387
|
+
module.id
|
|
1388
|
+
]);
|
|
1389
|
+
this._capabilities.set(module.id, capabilities);
|
|
1390
|
+
});
|
|
1391
|
+
}
|
|
1392
|
+
_deactivateModule(module) {
|
|
1393
|
+
return Effect3.gen(this, function* () {
|
|
1394
|
+
const id = module.id;
|
|
1395
|
+
log3("deactivating", {
|
|
1396
|
+
id
|
|
1397
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 1235, S: this });
|
|
1398
|
+
this._moduleMemoMap.delete(id);
|
|
1399
|
+
const capabilities = this._capabilities.get(id);
|
|
1400
|
+
if (capabilities) {
|
|
1401
|
+
for (const capability of capabilities) {
|
|
1402
|
+
this.capabilities.remove(capability.interface, capability.implementation);
|
|
1403
|
+
const program = capability.deactivate?.() ?? Effect3.succeed(void 0);
|
|
1404
|
+
yield* program;
|
|
1405
|
+
}
|
|
1406
|
+
this._capabilities.delete(id);
|
|
1407
|
+
}
|
|
1408
|
+
const activeIndex = this._get(this._activeAtom).findIndex((event) => event === id);
|
|
1409
|
+
if (activeIndex !== -1) {
|
|
1410
|
+
this._update(this._activeAtom, (active) => active.filter((event) => event !== id));
|
|
1411
|
+
}
|
|
1412
|
+
log3("deactivated", {
|
|
1413
|
+
id
|
|
1414
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 1252, S: this });
|
|
1415
|
+
return true;
|
|
1416
|
+
});
|
|
1417
|
+
}
|
|
1418
|
+
};
|
|
1419
|
+
var make5 = (options) => new ManagerImpl(options);
|
|
1420
|
+
var isTimeoutCause = (error, depth = 0) => {
|
|
1421
|
+
if (depth > 5 || !(error instanceof Error)) {
|
|
1422
|
+
return false;
|
|
1423
|
+
}
|
|
1424
|
+
if (PluginTimeoutError.is(error)) {
|
|
1425
|
+
return true;
|
|
1426
|
+
}
|
|
1427
|
+
return isTimeoutCause(error.cause, depth + 1);
|
|
1428
|
+
};
|
|
1429
|
+
var together = (togetherEffect) => (effect) => Effect3.gen(function* () {
|
|
1430
|
+
const togetherFiber = yield* Effect3.fork(togetherEffect);
|
|
1431
|
+
const result = yield* effect;
|
|
1432
|
+
yield* Fiber.interrupt(togetherFiber);
|
|
1433
|
+
return result;
|
|
1434
|
+
});
|
|
1435
|
+
|
|
1436
|
+
export {
|
|
1437
|
+
capability_manager_exports,
|
|
1438
|
+
registry_exports,
|
|
1439
|
+
PluginInitializationError,
|
|
1440
|
+
PluginTimeoutError,
|
|
1441
|
+
ManagerTypeId,
|
|
1442
|
+
isManager,
|
|
1443
|
+
make5 as make,
|
|
1444
|
+
plugin_manager_exports
|
|
1445
|
+
};
|
|
1446
|
+
//# sourceMappingURL=chunk-VJ5PFAWC.mjs.map
|