@dxos/app-framework 0.8.4-main.c85a9c8dae → 0.8.4-main.cb12b3f963
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/dist/lib/browser/{capability-7RLVE42K.mjs → capability-5RRH3WIB.mjs} +11 -10
- package/dist/lib/browser/capability-5RRH3WIB.mjs.map +7 -0
- package/dist/lib/browser/{capability-2GL5JAGJ.mjs → capability-LUKGKUQH.mjs} +10 -9
- package/dist/lib/browser/{chunk-5RJNZV7K.mjs → chunk-23D4SJUE.mjs} +11 -13
- package/dist/lib/browser/{chunk-5RJNZV7K.mjs.map → chunk-23D4SJUE.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-YNFPIQGB.mjs → chunk-3JWJXGLK.mjs} +5 -2
- 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-PKQT6C53.mjs → chunk-66IXTIVK.mjs} +3 -2
- package/dist/lib/browser/chunk-66IXTIVK.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-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-MX5DKEJH.mjs +584 -0
- package/dist/lib/browser/chunk-MX5DKEJH.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-PC4NOADA.mjs +471 -0
- package/dist/lib/browser/chunk-PC4NOADA.mjs.map +7 -0
- package/dist/lib/browser/{chunk-REORGDJT.mjs → chunk-WBHCSOBW.mjs} +18 -18
- package/dist/lib/browser/chunk-WBHCSOBW.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FNKT2QQ2.mjs → chunk-Z55LVAGN.mjs} +85 -17
- package/dist/lib/browser/chunk-Z55LVAGN.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ZRWBPIZG.mjs → chunk-ZGJAZSNE.mjs} +9 -37
- package/dist/lib/browser/chunk-ZGJAZSNE.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +16 -29
- package/dist/lib/browser/cli/index.mjs.map +3 -3
- package/dist/lib/browser/common/activation-events.mjs +9 -8
- package/dist/lib/browser/common/capabilities.mjs +9 -8
- package/dist/lib/browser/core/activation-event.mjs +1 -1
- package/dist/lib/browser/core/capability.mjs +3 -1
- package/dist/lib/browser/core/plugin-manager.mjs +8 -4
- package/dist/lib/browser/core/plugin.mjs +14 -4
- package/dist/lib/browser/core/url-loader.mjs +24 -0
- package/dist/lib/browser/index.mjs +37 -22
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{invoker-capability-BNLVNYHU.mjs → invoker-capability-K4GHUFXF.mjs} +22 -14
- 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 +184 -49
- 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 +18 -15
- package/dist/lib/node-esm/{capability-CHIMU6LX.mjs → capability-FCGZVIEG.mjs} +10 -9
- package/dist/lib/{browser/capability-2GL5JAGJ.mjs.map → node-esm/capability-FCGZVIEG.mjs.map} +1 -1
- package/dist/lib/node-esm/{capability-EVZK4REM.mjs → capability-JOIQ2MQE.mjs} +11 -10
- package/dist/lib/node-esm/capability-JOIQ2MQE.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-42J2ZUQQ.mjs +472 -0
- package/dist/lib/node-esm/chunk-42J2ZUQQ.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-2A4PRBIX.mjs → chunk-D347W3KO.mjs} +9 -37
- package/dist/lib/node-esm/chunk-D347W3KO.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-CJCQS2YL.mjs → chunk-HTBJU5FX.mjs} +85 -17
- 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-VUIUFIGT.mjs → chunk-SBS2YMPT.mjs} +11 -13
- package/dist/lib/node-esm/{chunk-VUIUFIGT.mjs.map → chunk-SBS2YMPT.mjs.map} +3 -3
- package/dist/lib/node-esm/{chunk-SB5ODNPX.mjs → chunk-SDJ4B2LU.mjs} +5 -2
- package/dist/lib/node-esm/chunk-SDJ4B2LU.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-UFW652GS.mjs → chunk-WFSRZKBP.mjs} +18 -18
- 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-WKTLE7MG.mjs +585 -0
- package/dist/lib/node-esm/chunk-WKTLE7MG.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 +16 -29
- package/dist/lib/node-esm/cli/index.mjs.map +3 -3
- package/dist/lib/node-esm/common/activation-events.mjs +9 -8
- package/dist/lib/node-esm/common/capabilities.mjs +9 -8
- package/dist/lib/node-esm/core/activation-event.mjs +1 -1
- package/dist/lib/node-esm/core/capability.mjs +3 -1
- package/dist/lib/node-esm/core/plugin-manager.mjs +8 -4
- package/dist/lib/node-esm/core/plugin.mjs +14 -4
- package/dist/lib/node-esm/core/url-loader.mjs +25 -0
- package/dist/lib/node-esm/index.mjs +37 -22
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{invoker-capability-VF6SP44V.mjs → invoker-capability-XEPW5LMJ.mjs} +22 -14
- 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 +184 -49
- 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 +18 -15
- package/dist/plugin/node-esm/index.mjs +875 -0
- package/dist/plugin/node-esm/index.mjs.map +7 -0
- package/dist/plugin/node-esm/meta.json +1 -0
- package/dist/types/src/common/activation-events.d.ts +1 -1
- 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 +4 -8
- 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 +8 -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 +177 -4
- 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 +113 -7
- 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/plugin-operation/OperationPlugin.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/history/capability.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/history/errors.d.ts +30 -3
- package/dist/types/src/plugin-operation/history/errors.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/history/history-tracker.d.ts +1 -1
- package/dist/types/src/plugin-operation/history/history-tracker.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/history/types.d.ts +1 -1
- package/dist/types/src/plugin-operation/history/types.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/history/undo-mapping.d.ts +1 -1
- package/dist/types/src/plugin-operation/history/undo-mapping.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/history/undo-registry.d.ts +1 -1
- package/dist/types/src/plugin-operation/history/undo-registry.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/invoker-capability.d.ts +1 -1
- package/dist/types/src/plugin-operation/invoker-capability.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/testing.d.ts +27 -77
- package/dist/types/src/plugin-operation/testing.d.ts.map +1 -1
- package/dist/types/src/plugin-runtime/RuntimePlugin.d.ts.map +1 -1
- package/dist/types/src/plugin-runtime/capability.d.ts +1 -1
- package/dist/types/src/plugin-runtime/capability.d.ts.map +1 -1
- 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 +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/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 +0 -1
- package/dist/types/src/ui/hooks/index.d.ts.map +1 -1
- package/dist/types/src/ui/hooks/useApp.d.ts +43 -4
- 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/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 +52 -0
- package/dist/types/src/vite-plugin/boot-loader/index.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/composer/index.d.ts +34 -0
- package/dist/types/src/vite-plugin/composer/index.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/import-map/index.d.ts +28 -0
- package/dist/types/src/vite-plugin/import-map/index.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/index.d.ts +5 -0
- package/dist/types/src/vite-plugin/index.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/manifest.d.ts +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 +48 -53
- package/src/cli/cli.ts +3 -3
- package/src/common/activation-events.ts +6 -6
- package/src/common/annotations.ts +3 -0
- package/src/common/capabilities.ts +18 -23
- 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 +13 -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 +855 -29
- package/src/core/plugin-manager.ts +808 -188
- package/src/core/plugin-manifest.test.ts +75 -0
- package/src/core/plugin-manifest.ts +134 -0
- package/src/core/plugin.ts +144 -12
- 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/plugin-operation/OperationPlugin.ts +2 -3
- package/src/plugin-operation/history/capability.ts +1 -2
- package/src/plugin-operation/history/errors.ts +2 -6
- package/src/plugin-operation/history/history-tracker.test.ts +37 -43
- package/src/plugin-operation/history/history-tracker.ts +1 -2
- package/src/plugin-operation/history/types.ts +1 -1
- package/src/plugin-operation/history/undo-mapping.ts +1 -1
- package/src/plugin-operation/history/undo-registry.test.ts +3 -4
- package/src/plugin-operation/history/undo-registry.ts +1 -1
- package/src/plugin-operation/invoker-capability.ts +19 -4
- package/src/plugin-operation/meta.ts +1 -1
- package/src/plugin-operation/testing.ts +26 -45
- package/src/plugin-runtime/RuntimePlugin.ts +2 -3
- package/src/plugin-runtime/meta.ts +1 -1
- package/src/testing/harness.ts +229 -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 +3 -3
- package/src/testing/withPluginManager.stories.tsx +1 -2
- package/src/testing/withPluginManager.tsx +40 -18
- package/src/ui/components/App/App.stories.tsx +5 -5
- 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/ui/components/Placeholder/index.ts +5 -0
- package/src/ui/components/PluginManager/PluginManagerContext.stories.tsx +8 -6
- package/src/ui/components/Surface/SurfaceComponent.stories.tsx +16 -15
- package/src/ui/components/Surface/SurfaceComponent.tsx +109 -53
- 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 +0 -1
- package/src/ui/hooks/useApp.test.tsx +159 -0
- package/src/ui/hooks/useApp.tsx +226 -15
- package/src/ui/hooks/useLoading.tsx +14 -6
- package/src/vite-plugin/boot-loader/BootLoader.stories.tsx +263 -0
- package/src/vite-plugin/boot-loader/boot-loader.css +294 -0
- package/src/vite-plugin/boot-loader/boot-loader.js +274 -0
- package/src/vite-plugin/boot-loader/index.ts +112 -0
- package/src/vite-plugin/composer/index.ts +306 -0
- package/src/vite-plugin/import-map/index.ts +524 -0
- package/src/vite-plugin/index.ts +10 -0
- package/src/vite-plugin/manifest.test.ts +46 -0
- package/src/vite-plugin/manifest.ts +57 -0
- package/src/vite-plugin/packages.ts +188 -0
- package/tsconfig.json +19 -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-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.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.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.map +0 -7
- package/dist/lib/node-esm/chunk-Z4TJPSMP.mjs +0 -2
- package/dist/lib/node-esm/invoker-capability-VF6SP44V.mjs.map +0 -7
- 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/ui/hooks/useOperationResolver.ts +0 -40
- /package/dist/lib/{node-esm/capability-CHIMU6LX.mjs.map → browser/capability-LUKGKUQH.mjs.map} +0 -0
- /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
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import * as PluginManifest from './plugin-manifest';
|
|
8
|
+
|
|
9
|
+
describe('PluginManifest', () => {
|
|
10
|
+
describe('parse', () => {
|
|
11
|
+
test('resolves entry and assets relative to manifest URL', ({ expect }) => {
|
|
12
|
+
const resolved = PluginManifest.parse('https://example.com/plugins/foo/manifest.json', {
|
|
13
|
+
id: 'com.example.foo',
|
|
14
|
+
name: 'Foo',
|
|
15
|
+
version: '1.0.0',
|
|
16
|
+
assets: ['index.mjs', 'style.css', 'chunks/lib-abc.js'],
|
|
17
|
+
});
|
|
18
|
+
expect(resolved.id).toBe('com.example.foo');
|
|
19
|
+
expect(resolved.dev).toBe(false);
|
|
20
|
+
expect(resolved.entryUrl).toBe('https://example.com/plugins/foo/index.mjs');
|
|
21
|
+
expect(resolved.assetUrls).toEqual([
|
|
22
|
+
'https://example.com/plugins/foo/index.mjs',
|
|
23
|
+
'https://example.com/plugins/foo/style.css',
|
|
24
|
+
'https://example.com/plugins/foo/chunks/lib-abc.js',
|
|
25
|
+
]);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('throws if the canonical entry filename is not listed in assets', ({ expect }) => {
|
|
29
|
+
expect(() =>
|
|
30
|
+
PluginManifest.parse('https://example.com/manifest.json', {
|
|
31
|
+
id: 'a',
|
|
32
|
+
name: 'A',
|
|
33
|
+
version: '0.0.1',
|
|
34
|
+
assets: ['style.css'],
|
|
35
|
+
}),
|
|
36
|
+
).toThrow();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('throws on missing required fields', ({ expect }) => {
|
|
40
|
+
expect(() =>
|
|
41
|
+
PluginManifest.parse('https://example.com/manifest.json', {
|
|
42
|
+
name: 'A',
|
|
43
|
+
version: '0.0.1',
|
|
44
|
+
assets: ['index.mjs'],
|
|
45
|
+
}),
|
|
46
|
+
).toThrow();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('devEntry flips dev mode and resolves the entry against the manifest URL', ({ expect }) => {
|
|
50
|
+
const resolved = PluginManifest.parse('http://localhost:3967/manifest.json', {
|
|
51
|
+
id: 'com.example.foo',
|
|
52
|
+
name: 'Foo',
|
|
53
|
+
version: '0.0.0-dev',
|
|
54
|
+
assets: [],
|
|
55
|
+
devEntry: 'src/plugin.tsx',
|
|
56
|
+
});
|
|
57
|
+
expect(resolved.dev).toBe(true);
|
|
58
|
+
expect(resolved.entryUrl).toBe('http://localhost:3967/src/plugin.tsx');
|
|
59
|
+
expect(resolved.assetUrls).toEqual([]);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('devEntry waives the canonical-entry-in-assets requirement', ({ expect }) => {
|
|
63
|
+
// No `index.mjs` in assets — would throw without devEntry.
|
|
64
|
+
expect(() =>
|
|
65
|
+
PluginManifest.parse('http://localhost:3967/manifest.json', {
|
|
66
|
+
id: 'a',
|
|
67
|
+
name: 'A',
|
|
68
|
+
version: '0.0.0-dev',
|
|
69
|
+
assets: [],
|
|
70
|
+
devEntry: 'src/plugin.tsx',
|
|
71
|
+
}),
|
|
72
|
+
).not.toThrow();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as FetchHttpClient from '@effect/platform/FetchHttpClient';
|
|
6
|
+
import * as HttpClient from '@effect/platform/HttpClient';
|
|
7
|
+
import * as HttpClientRequest from '@effect/platform/HttpClientRequest';
|
|
8
|
+
import * as HttpClientResponse from '@effect/platform/HttpClientResponse';
|
|
9
|
+
import * as Effect from 'effect/Effect';
|
|
10
|
+
import * as Schema from 'effect/Schema';
|
|
11
|
+
|
|
12
|
+
import { BaseError } from '@dxos/errors';
|
|
13
|
+
import { PLUGIN_ENTRY_FILENAME } from '@dxos/protocols';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Default port the Vite plugin (`composerPlugin`) binds the dev server to.
|
|
17
|
+
*
|
|
18
|
+
* Shared single source of truth — `composerPlugin` reads it as the default
|
|
19
|
+
* port, and the host's "Load Dev Plugin" affordance pre-fills the manifest URL
|
|
20
|
+
* with `http://localhost:${PLUGIN_DEV_SERVER_PORT}/manifest.json`. Lives in
|
|
21
|
+
* app-framework rather than `@dxos/protocols` because the constant is a
|
|
22
|
+
* client-side convention (host loader + Vite plugin) rather than a wire-level
|
|
23
|
+
* protocol.
|
|
24
|
+
*/
|
|
25
|
+
export const PLUGIN_DEV_SERVER_PORT = 3967;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Tagged error for manifest fetch / parse failures. Construction sites set
|
|
29
|
+
* `context.manifestUrl` and `context.reason` (one of `'fetch-failed' |
|
|
30
|
+
* 'http-error' | 'parse-failed' | 'invalid'`) so handlers can route on the
|
|
31
|
+
* specific failure mode.
|
|
32
|
+
*/
|
|
33
|
+
export class PluginManifestError extends BaseError.extend('PluginManifestError', 'Plugin manifest is invalid') {}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Schema for a third-party plugin manifest.
|
|
37
|
+
*
|
|
38
|
+
* Production manifests are published as a sibling of the plugin's entry module
|
|
39
|
+
* ({@link PLUGIN_ENTRY_FILENAME}) and advertise every file the plugin needs at
|
|
40
|
+
* runtime so the host can eagerly cache them for offline use.
|
|
41
|
+
*
|
|
42
|
+
* Dev manifests (served by `vite dev` via {@link composerPlugin}) set `devEntry`
|
|
43
|
+
* to point at the unbundled source entry. The host's loader treats the presence
|
|
44
|
+
* of `devEntry` as the dev-mode signal: it imports the entry directly from the
|
|
45
|
+
* dev server, skips eager asset caching, and skips static stylesheet injection
|
|
46
|
+
* (Vite handles CSS via runtime `<style>` injection during HMR). `assets` is not
|
|
47
|
+
* required to enumerate every file in dev mode — chunks and styles flow through
|
|
48
|
+
* the dev server on demand.
|
|
49
|
+
*/
|
|
50
|
+
export const Manifest = Schema.Struct({
|
|
51
|
+
id: Schema.String,
|
|
52
|
+
name: Schema.String,
|
|
53
|
+
version: Schema.String,
|
|
54
|
+
assets: Schema.Array(Schema.String),
|
|
55
|
+
devEntry: Schema.String.pipe(Schema.optional),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export type Manifest = Schema.Schema.Type<typeof Manifest>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Resolved manifest with all asset paths converted to absolute URLs.
|
|
62
|
+
*
|
|
63
|
+
* `dev` reflects whether the source manifest declared a `devEntry`. Loaders branch
|
|
64
|
+
* on this to skip offline caching and stylesheet injection — both are no-ops (or
|
|
65
|
+
* actively wrong) when the plugin is being served by a Vite dev server.
|
|
66
|
+
*/
|
|
67
|
+
export type ResolvedManifest = {
|
|
68
|
+
id: string;
|
|
69
|
+
name: string;
|
|
70
|
+
version: string;
|
|
71
|
+
entryUrl: string;
|
|
72
|
+
assetUrls: readonly string[];
|
|
73
|
+
dev: boolean;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Resolves a parsed manifest's relative asset paths against the manifest's URL.
|
|
78
|
+
* In dev mode the entry comes from `devEntry`; otherwise it's the canonical
|
|
79
|
+
* {@link PLUGIN_ENTRY_FILENAME} sitting next to the manifest.
|
|
80
|
+
*/
|
|
81
|
+
const resolve = (manifestUrl: string, manifest: Manifest): ResolvedManifest => {
|
|
82
|
+
const dev = manifest.devEntry !== undefined;
|
|
83
|
+
return {
|
|
84
|
+
id: manifest.id,
|
|
85
|
+
name: manifest.name,
|
|
86
|
+
version: manifest.version,
|
|
87
|
+
entryUrl: new URL(dev ? manifest.devEntry! : PLUGIN_ENTRY_FILENAME, manifestUrl).toString(),
|
|
88
|
+
assetUrls: manifest.assets.map((asset) => new URL(asset, manifestUrl).toString()),
|
|
89
|
+
dev,
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Synchronous decode + validate + resolve for an in-memory manifest payload. Used
|
|
95
|
+
* by tests and tooling that have the manifest body already loaded; the runtime
|
|
96
|
+
* path goes through {@link fetchManifest}.
|
|
97
|
+
*/
|
|
98
|
+
export const parse = (manifestUrl: string, payload: unknown): ResolvedManifest => {
|
|
99
|
+
const manifest = Schema.decodeUnknownSync(Manifest)(payload);
|
|
100
|
+
if (manifest.devEntry === undefined && !manifest.assets.includes(PLUGIN_ENTRY_FILENAME)) {
|
|
101
|
+
throw new Error(`Manifest at ${manifestUrl} does not list ${PLUGIN_ENTRY_FILENAME} in assets.`);
|
|
102
|
+
}
|
|
103
|
+
return resolve(manifestUrl, manifest);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Fetches and parses a manifest from the given URL via Effect's HTTP client and
|
|
108
|
+
* Schema-driven JSON decoding. All failure modes surface as a single tagged
|
|
109
|
+
* {@link PluginManifestError}; callers route on `error.context.reason`.
|
|
110
|
+
*/
|
|
111
|
+
export const fetchManifest = (manifestUrl: string): Effect.Effect<ResolvedManifest, PluginManifestError> =>
|
|
112
|
+
Effect.gen(function* () {
|
|
113
|
+
const response = yield* HttpClientRequest.get(manifestUrl).pipe(
|
|
114
|
+
HttpClient.execute,
|
|
115
|
+
Effect.mapError((cause) => new PluginManifestError({ context: { manifestUrl, reason: 'fetch-failed' }, cause })),
|
|
116
|
+
);
|
|
117
|
+
if (response.status >= 400) {
|
|
118
|
+
return yield* Effect.fail(
|
|
119
|
+
new PluginManifestError({ context: { manifestUrl, reason: 'http-error', status: response.status } }),
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
const manifest = yield* HttpClientResponse.schemaBodyJson(Manifest)(response).pipe(
|
|
123
|
+
Effect.mapError((cause) => new PluginManifestError({ context: { manifestUrl, reason: 'parse-failed' }, cause })),
|
|
124
|
+
);
|
|
125
|
+
if (manifest.devEntry === undefined && !manifest.assets.includes(PLUGIN_ENTRY_FILENAME)) {
|
|
126
|
+
return yield* Effect.fail(
|
|
127
|
+
new PluginManifestError({
|
|
128
|
+
context: { manifestUrl, reason: 'invalid' },
|
|
129
|
+
cause: `assets does not include ${PLUGIN_ENTRY_FILENAME}`,
|
|
130
|
+
}),
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
return resolve(manifestUrl, manifest);
|
|
134
|
+
}).pipe(Effect.scoped, Effect.provide(FetchHttpClient.layer));
|
package/src/core/plugin.ts
CHANGED
|
@@ -7,6 +7,7 @@ import * as Effect from 'effect/Effect';
|
|
|
7
7
|
import * as Option from 'effect/Option';
|
|
8
8
|
import * as Pipeable from 'effect/Pipeable';
|
|
9
9
|
|
|
10
|
+
import { BaseError } from '@dxos/errors';
|
|
10
11
|
import { invariant } from '@dxos/invariant';
|
|
11
12
|
|
|
12
13
|
import type * as ActivationEvent from './activation-event';
|
|
@@ -45,11 +46,18 @@ export const activate = (event: ActivationEvent.ActivationEvent): Effect.Effect<
|
|
|
45
46
|
export const reset = (event: ActivationEvent.ActivationEvent): Effect.Effect<boolean, Error, Service> =>
|
|
46
47
|
Effect.flatMap(Service, (manager) => manager.reset(event));
|
|
47
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Shuts down the plugin manager, deactivating all active modules and clearing lifecycle state.
|
|
51
|
+
* Accesses the PluginManager via the Effect layer system.
|
|
52
|
+
*/
|
|
53
|
+
export const shutdown = (): Effect.Effect<boolean, Error, Service> =>
|
|
54
|
+
Effect.flatMap(Service, (manager) => manager.shutdown());
|
|
55
|
+
|
|
48
56
|
/**
|
|
49
57
|
* Computes a module ID from plugin ID and export name.
|
|
50
58
|
*/
|
|
51
59
|
const computeModuleId = (pluginId: string, moduleName: string): string => {
|
|
52
|
-
return `${pluginId}
|
|
60
|
+
return `${pluginId}.module.${moduleName}`;
|
|
53
61
|
};
|
|
54
62
|
|
|
55
63
|
/**
|
|
@@ -82,16 +90,33 @@ export interface PluginModule {
|
|
|
82
90
|
activatesOn: ActivationEvent.Events;
|
|
83
91
|
|
|
84
92
|
/**
|
|
85
|
-
* Events
|
|
86
|
-
*
|
|
87
|
-
*
|
|
93
|
+
* Events that this module fires *before* its own activation runs.
|
|
94
|
+
*
|
|
95
|
+
* When this module is asked to activate (via {@link activatesOn}), the
|
|
96
|
+
* plugin manager first activates every event listed here, ensuring any
|
|
97
|
+
* other modules that contribute to those events have completed before
|
|
98
|
+
* this module's {@link activate} body executes. These events are fired
|
|
99
|
+
* by the framework on this module's behalf — the module does not need
|
|
100
|
+
* to wait for some other code to fire them.
|
|
101
|
+
*
|
|
102
|
+
* The module is marked as needing reset if a module activated by one
|
|
103
|
+
* of these events is later removed.
|
|
104
|
+
*
|
|
105
|
+
* Read as: "this module fires these events before [its] activation".
|
|
88
106
|
*/
|
|
89
|
-
|
|
107
|
+
firesBeforeActivation?: ActivationEvent.ActivationEvent[];
|
|
90
108
|
|
|
91
109
|
/**
|
|
92
|
-
* Events
|
|
110
|
+
* Events that this module fires *after* its own activation completes.
|
|
111
|
+
*
|
|
112
|
+
* Once this module's {@link activate} body has finished executing, the
|
|
113
|
+
* plugin manager activates every event listed here, causing any modules
|
|
114
|
+
* listening on those events to run. These events are fired by the
|
|
115
|
+
* framework on this module's behalf as part of this module's lifecycle.
|
|
116
|
+
*
|
|
117
|
+
* Read as: "this module fires these events after [its] activation".
|
|
93
118
|
*/
|
|
94
|
-
|
|
119
|
+
firesAfterActivation?: ActivationEvent.ActivationEvent[];
|
|
95
120
|
|
|
96
121
|
/**
|
|
97
122
|
* Called when the module is activated.
|
|
@@ -109,15 +134,15 @@ class PluginModuleImpl implements PluginModule {
|
|
|
109
134
|
readonly [PluginModuleTypeId]: PluginModuleTypeId = PluginModuleTypeId;
|
|
110
135
|
readonly id: PluginModule['id'];
|
|
111
136
|
readonly activatesOn: PluginModule['activatesOn'];
|
|
112
|
-
readonly
|
|
113
|
-
readonly
|
|
137
|
+
readonly firesBeforeActivation?: PluginModule['firesBeforeActivation'];
|
|
138
|
+
readonly firesAfterActivation?: PluginModule['firesAfterActivation'];
|
|
114
139
|
readonly activate: PluginModule['activate'];
|
|
115
140
|
|
|
116
141
|
constructor(options: Omit<PluginModule, typeof PluginModuleTypeId>) {
|
|
117
142
|
this.id = options.id;
|
|
118
143
|
this.activatesOn = options.activatesOn;
|
|
119
|
-
this.
|
|
120
|
-
this.
|
|
144
|
+
this.firesBeforeActivation = options.firesBeforeActivation;
|
|
145
|
+
this.firesAfterActivation = options.firesAfterActivation;
|
|
121
146
|
this.activate = options.activate;
|
|
122
147
|
}
|
|
123
148
|
}
|
|
@@ -128,7 +153,7 @@ export type Meta = {
|
|
|
128
153
|
*
|
|
129
154
|
* Expected to be in the form of a valid URL.
|
|
130
155
|
*
|
|
131
|
-
* @example dxos.
|
|
156
|
+
* @example org.dxos.plugin.example
|
|
132
157
|
*/
|
|
133
158
|
id: string;
|
|
134
159
|
|
|
@@ -142,6 +167,11 @@ export type Meta = {
|
|
|
142
167
|
*/
|
|
143
168
|
description?: string;
|
|
144
169
|
|
|
170
|
+
/**
|
|
171
|
+
* Name of the author or organization that created the plugin.
|
|
172
|
+
*/
|
|
173
|
+
author?: string;
|
|
174
|
+
|
|
145
175
|
/**
|
|
146
176
|
* URL of home page.
|
|
147
177
|
*/
|
|
@@ -324,3 +354,105 @@ export function make<T>(builder: PluginBuilder<T>): PluginFactory<T> {
|
|
|
324
354
|
|
|
325
355
|
return Object.assign(factory, { meta });
|
|
326
356
|
}
|
|
357
|
+
|
|
358
|
+
//
|
|
359
|
+
// Lazy plugin loading
|
|
360
|
+
//
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Symbol used to tag lazy plugin stubs with their loader closure.
|
|
364
|
+
* Hidden from enumeration so plugin manager iteration / serialization paths
|
|
365
|
+
* don't trip over it.
|
|
366
|
+
*/
|
|
367
|
+
const LazyTag: unique symbol = Symbol.for('@dxos/app-framework/Plugin/Lazy');
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Async loader for a lazy plugin's real implementation.
|
|
371
|
+
* The default export of the loaded module must be a `PluginFactory<T>` —
|
|
372
|
+
* i.e. the same shape `Plugin.make` produces.
|
|
373
|
+
*/
|
|
374
|
+
export type LazyLoader<T = void> = () => Promise<{ default: PluginFactory<T> }>;
|
|
375
|
+
|
|
376
|
+
/** Internal: payload carried on a lazy stub. */
|
|
377
|
+
type LazyPayload = { loader: LazyLoader<any>; options: unknown };
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Defines a lazy plugin whose body is loaded on first enable.
|
|
381
|
+
*
|
|
382
|
+
* The returned factory produces a stub `Plugin` that exposes `meta`
|
|
383
|
+
* synchronously (so callers can read `Plugin.meta.id` for free) but defers
|
|
384
|
+
* loading the real plugin's modules until the manager calls
|
|
385
|
+
* `Plugin.resolveLazy`. This lets the plugin's main entry point ship as a
|
|
386
|
+
* tiny meta-only chunk — the heavy capabilities, schema, React surfaces,
|
|
387
|
+
* etc. live behind the dynamic `import()` and become a separate Rollup
|
|
388
|
+
* chunk that is only fetched when the plugin is enabled.
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* ```ts
|
|
392
|
+
* // plugin-markdown/src/index.ts
|
|
393
|
+
* import { Plugin } from '@dxos/app-framework';
|
|
394
|
+
* import { meta } from './meta';
|
|
395
|
+
*
|
|
396
|
+
* export const MarkdownPlugin = Plugin.lazy(meta, () => import('./MarkdownPlugin'));
|
|
397
|
+
*
|
|
398
|
+
* // plugin-markdown/src/MarkdownPlugin.tsx
|
|
399
|
+
* export const MarkdownPlugin = Plugin.define(meta).pipe(...heavy modules..., Plugin.make);
|
|
400
|
+
* export default MarkdownPlugin;
|
|
401
|
+
* ```
|
|
402
|
+
*/
|
|
403
|
+
export const lazy = <T = void>(meta: Meta, loader: LazyLoader<T>): PluginFactory<T> => {
|
|
404
|
+
const factory = (options: T): Plugin => {
|
|
405
|
+
const stub = new PluginImpl(meta, []);
|
|
406
|
+
Object.defineProperty(stub, LazyTag, {
|
|
407
|
+
value: { loader, options } satisfies LazyPayload,
|
|
408
|
+
enumerable: false,
|
|
409
|
+
});
|
|
410
|
+
return stub;
|
|
411
|
+
};
|
|
412
|
+
return Object.assign(factory, { meta });
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Type guard for lazy plugin stubs produced by {@link lazy}.
|
|
417
|
+
*/
|
|
418
|
+
export const isLazy = (plugin: Plugin): boolean => LazyTag in plugin;
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Tagged error for failures during lazy plugin resolution. `context.id` is
|
|
422
|
+
* the lazy plugin's `meta.id`; `context.reason` discriminates the failure
|
|
423
|
+
* mode (`'load-failed' | 'missing-default' | 'invalid-plugin' |
|
|
424
|
+
* 'meta-mismatch'`) so callers can route on it.
|
|
425
|
+
*/
|
|
426
|
+
export class LazyPluginError extends BaseError.extend('LazyPluginError', 'Failed to resolve lazy plugin') {}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Resolves a lazy plugin stub to its real plugin.
|
|
430
|
+
* Returns the plugin unchanged if it is not lazy. Failures surface as
|
|
431
|
+
* {@link LazyPluginError} with `context.reason` indicating the failure mode
|
|
432
|
+
* and (for loader failures) `cause` set to the original error.
|
|
433
|
+
*/
|
|
434
|
+
export const resolveLazy = (plugin: Plugin): Effect.Effect<Plugin, LazyPluginError> =>
|
|
435
|
+
Effect.gen(function* () {
|
|
436
|
+
if (!isLazy(plugin)) {
|
|
437
|
+
return plugin;
|
|
438
|
+
}
|
|
439
|
+
const id = plugin.meta.id;
|
|
440
|
+
const { loader, options } = (plugin as unknown as { [LazyTag]: LazyPayload })[LazyTag];
|
|
441
|
+
const mod = yield* Effect.tryPromise({
|
|
442
|
+
try: loader,
|
|
443
|
+
catch: (error) => new LazyPluginError({ context: { id, reason: 'load-failed' }, cause: error }),
|
|
444
|
+
});
|
|
445
|
+
if (!mod || typeof mod.default !== 'function') {
|
|
446
|
+
return yield* Effect.fail(new LazyPluginError({ context: { id, reason: 'missing-default' } }));
|
|
447
|
+
}
|
|
448
|
+
const result = mod.default(options);
|
|
449
|
+
if (!isPlugin(result)) {
|
|
450
|
+
return yield* Effect.fail(new LazyPluginError({ context: { id, reason: 'invalid-plugin' } }));
|
|
451
|
+
}
|
|
452
|
+
if (result.meta.id !== id) {
|
|
453
|
+
return yield* Effect.fail(
|
|
454
|
+
new LazyPluginError({ context: { id, reason: 'meta-mismatch', returnedId: result.meta.id } }),
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
return result;
|
|
458
|
+
});
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Atom, type Registry as AtomRegistry } from '@effect-atom/atom-react';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
|
|
8
|
+
import { runAndForwardErrors } from '@dxos/effect';
|
|
9
|
+
import { log } from '@dxos/log';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A registry plugin entry as seen by the plugin manager layer.
|
|
13
|
+
* Populated from the registry catalog; represents the latest available version of a plugin.
|
|
14
|
+
*
|
|
15
|
+
* Independently defined from @dxos/protocols PluginEntry — similar shape but not the same type.
|
|
16
|
+
* Implementations of {@link PluginProvider} (e.g. {@link EdgeRegistryPluginProvider})
|
|
17
|
+
* are responsible for mapping their wire-format entries to this shape.
|
|
18
|
+
*/
|
|
19
|
+
export type Plugin = {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
homePage?: string;
|
|
24
|
+
source?: string;
|
|
25
|
+
screenshots?: string[];
|
|
26
|
+
tags?: string[];
|
|
27
|
+
icon?: string;
|
|
28
|
+
iconHue?: string;
|
|
29
|
+
/** URL to dynamic-import the latest version of this plugin module. */
|
|
30
|
+
moduleUrl: string;
|
|
31
|
+
/** GitHub repository slug, e.g. `owner/name`. Used to fetch version history. */
|
|
32
|
+
repo: string;
|
|
33
|
+
/**
|
|
34
|
+
* Latest known version string, e.g. `v1.2.0`.
|
|
35
|
+
* Corresponds to releaseTag in the wire-format PluginEntry; named `version` here
|
|
36
|
+
* because the plugin manager layer speaks versions, not release tags.
|
|
37
|
+
*/
|
|
38
|
+
version: string;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A single installable version of a registry plugin.
|
|
43
|
+
*/
|
|
44
|
+
export type PluginVersion = {
|
|
45
|
+
/** Version string, e.g. `v1.2.0`. */
|
|
46
|
+
tag: string;
|
|
47
|
+
/** URL to dynamic-import this specific version of the plugin module. */
|
|
48
|
+
moduleUrl: string;
|
|
49
|
+
/** Unix ms of when this version was published (optional; omitted when unknown). */
|
|
50
|
+
releasedAt?: number;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Abstraction over the plugin registry catalog backend.
|
|
55
|
+
* Implementations may call Edge, a local cache, or a stub.
|
|
56
|
+
*
|
|
57
|
+
* The interface itself is transport-agnostic; concrete implementations live
|
|
58
|
+
* alongside it in this package (see {@link EdgeRegistryPluginProvider}) so we
|
|
59
|
+
* avoid `app-framework ↔ edge-client` cycles, but they only need to satisfy
|
|
60
|
+
* this shape — callers can substitute their own.
|
|
61
|
+
*/
|
|
62
|
+
export interface PluginProvider {
|
|
63
|
+
/**
|
|
64
|
+
* Returns all healthy registry plugins (latest version of each).
|
|
65
|
+
*/
|
|
66
|
+
listPlugins(): Effect.Effect<readonly Plugin[], Error>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Returns all known versions of a plugin identified by its GitHub repo slug.
|
|
70
|
+
* Until the backend implements a versions endpoint, implementations MUST
|
|
71
|
+
* return at least one entry representing the current/latest release.
|
|
72
|
+
*/
|
|
73
|
+
listVersions(repo: string): Effect.Effect<readonly PluginVersion[], Error>;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Returns a single plugin entry for the given repo.
|
|
77
|
+
* If `version` is omitted, returns the latest.
|
|
78
|
+
* Fails if the specified version is not found.
|
|
79
|
+
*/
|
|
80
|
+
getPlugin(repo: string, version?: string): Effect.Effect<Plugin, Error>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Atomic snapshot of the registry catalog as observed by the host.
|
|
85
|
+
* Exposed via {@link Manager.plugins} so consumers can subscribe reactively
|
|
86
|
+
* (loading state, list contents, last error).
|
|
87
|
+
*/
|
|
88
|
+
export type PluginsState = {
|
|
89
|
+
entries: readonly Plugin[];
|
|
90
|
+
loading: boolean;
|
|
91
|
+
error: Error | null;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Default no-op provider used when no `PluginProvider` is supplied at construction
|
|
96
|
+
* time (e.g. tests, stories, environments without an Edge connection).
|
|
97
|
+
*
|
|
98
|
+
* `listPlugins` returns an empty list (so `Manager.plugins` settles to a stable
|
|
99
|
+
* empty state). `listVersions` and `getPlugin` fail with an explicit error so
|
|
100
|
+
* callers know they need to configure a real provider.
|
|
101
|
+
*/
|
|
102
|
+
const NULL_PROVIDER: PluginProvider = {
|
|
103
|
+
listPlugins: () => Effect.succeed([] as readonly Plugin[]),
|
|
104
|
+
listVersions: () => Effect.fail(new Error('No plugin registry provider configured')),
|
|
105
|
+
getPlugin: () => Effect.fail(new Error('No plugin registry provider configured')),
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Owns the cached registry catalog state and forwards `listVersions` / `getPlugin`
|
|
110
|
+
* calls to the underlying {@link PluginProvider}. Lives on the `PluginManager`
|
|
111
|
+
* (as `manager.pluginRegistry`) so consumers can reach it through the manager
|
|
112
|
+
* without a separate capability lookup.
|
|
113
|
+
*
|
|
114
|
+
* On construction the manager kicks off a background fetch via `provider.listPlugins()`
|
|
115
|
+
* and writes the result into the {@link plugins} atom. Subscribers see `loading: true`
|
|
116
|
+
* during the fetch and `loading: false` once it settles.
|
|
117
|
+
*/
|
|
118
|
+
export class Manager {
|
|
119
|
+
readonly plugins: Atom.Writable<PluginsState>;
|
|
120
|
+
readonly #provider: PluginProvider;
|
|
121
|
+
|
|
122
|
+
constructor(provider: PluginProvider | undefined, atomRegistry: AtomRegistry.Registry) {
|
|
123
|
+
this.#provider = provider ?? NULL_PROVIDER;
|
|
124
|
+
const initialLoading = provider !== undefined;
|
|
125
|
+
this.plugins = Atom.make<PluginsState>({ entries: [], loading: initialLoading, error: null }).pipe(Atom.keepAlive);
|
|
126
|
+
|
|
127
|
+
if (provider !== undefined) {
|
|
128
|
+
// Fire-and-forget initial load. Errors are surfaced via the atom's `error` field.
|
|
129
|
+
void runAndForwardErrors(
|
|
130
|
+
provider.listPlugins().pipe(
|
|
131
|
+
Effect.match({
|
|
132
|
+
onSuccess: (entries) => atomRegistry.set(this.plugins, { entries, loading: false, error: null }),
|
|
133
|
+
onFailure: (error) => {
|
|
134
|
+
log.catch(error);
|
|
135
|
+
atomRegistry.set(this.plugins, { entries: [], loading: false, error });
|
|
136
|
+
},
|
|
137
|
+
}),
|
|
138
|
+
),
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Forwards to the underlying provider. */
|
|
144
|
+
listPlugins(): Effect.Effect<readonly Plugin[], Error> {
|
|
145
|
+
return this.#provider.listPlugins();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Forwards to the underlying provider. */
|
|
149
|
+
listVersions(repo: string): Effect.Effect<readonly PluginVersion[], Error> {
|
|
150
|
+
return this.#provider.listVersions(repo);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Forwards to the underlying provider. */
|
|
154
|
+
getPlugin(repo: string, version?: string): Effect.Effect<Plugin, Error> {
|
|
155
|
+
return this.#provider.getPlugin(repo, version);
|
|
156
|
+
}
|
|
157
|
+
}
|