@dxos/app-framework 0.8.4-main.a4bbb77 → 0.8.4-main.abd8ff62ef
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.storybook/main.mts +2 -4
- package/.storybook/preview.mts +2 -2
- package/dist/lib/browser/capability-Q5XRXRD2.mjs +38 -0
- package/dist/lib/browser/capability-Q5XRXRD2.mjs.map +7 -0
- package/dist/lib/browser/capability-V7LR4LQN.mjs +35 -0
- package/dist/lib/browser/capability-V7LR4LQN.mjs.map +7 -0
- package/dist/lib/browser/chunk-23D4SJUE.mjs +42 -0
- package/dist/lib/browser/chunk-23D4SJUE.mjs.map +7 -0
- package/dist/lib/browser/chunk-3JWJXGLK.mjs +79 -0
- package/dist/lib/browser/chunk-3JWJXGLK.mjs.map +7 -0
- package/dist/lib/browser/chunk-3ZS2A3DN.mjs +907 -0
- package/dist/lib/browser/chunk-3ZS2A3DN.mjs.map +7 -0
- package/dist/lib/browser/chunk-45CHLTBV.mjs +34 -0
- package/dist/lib/browser/chunk-45CHLTBV.mjs.map +7 -0
- package/dist/lib/browser/chunk-5LAIGWLU.mjs +467 -0
- package/dist/lib/browser/chunk-5LAIGWLU.mjs.map +7 -0
- package/dist/lib/browser/chunk-66IXTIVK.mjs +48 -0
- package/dist/lib/browser/chunk-66IXTIVK.mjs.map +7 -0
- package/dist/lib/browser/chunk-FJ4765WW.mjs +8 -0
- package/dist/lib/browser/chunk-FJ4765WW.mjs.map +7 -0
- package/dist/lib/browser/chunk-G7SDBRKH.mjs +1 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-JXCBZSBJ.mjs +372 -0
- package/dist/lib/browser/chunk-JXCBZSBJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-MX5DKEJH.mjs +584 -0
- package/dist/lib/browser/chunk-MX5DKEJH.mjs.map +7 -0
- package/dist/lib/browser/chunk-WBHCSOBW.mjs +80 -0
- package/dist/lib/browser/chunk-WBHCSOBW.mjs.map +7 -0
- package/dist/lib/browser/chunk-Z55LVAGN.mjs +213 -0
- package/dist/lib/browser/chunk-Z55LVAGN.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZGJAZSNE.mjs +142 -0
- package/dist/lib/browser/chunk-ZGJAZSNE.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +74 -0
- package/dist/lib/browser/cli/index.mjs.map +7 -0
- package/dist/lib/browser/common/activation-events.mjs +24 -0
- package/dist/lib/browser/common/capabilities.mjs +46 -0
- package/dist/lib/browser/core/activation-event.mjs +20 -0
- package/dist/lib/browser/core/activation-event.mjs.map +7 -0
- package/dist/lib/browser/core/capability.mjs +30 -0
- package/dist/lib/browser/core/capability.mjs.map +7 -0
- package/dist/lib/browser/core/plugin-manager.mjs +17 -0
- package/dist/lib/browser/core/plugin-manager.mjs.map +7 -0
- package/dist/lib/browser/core/plugin.mjs +37 -0
- package/dist/lib/browser/core/plugin.mjs.map +7 -0
- package/dist/lib/browser/core/url-loader.mjs +20 -0
- package/dist/lib/browser/core/url-loader.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +95 -148
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/invoker-capability-LNX4CGIV.mjs +44 -0
- package/dist/lib/browser/invoker-capability-LNX4CGIV.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +227 -41
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/browser/testing/react.mjs +78 -0
- package/dist/lib/browser/testing/react.mjs.map +7 -0
- package/dist/lib/browser/ui/index.mjs +48 -0
- package/dist/lib/browser/ui/index.mjs.map +7 -0
- package/dist/lib/node-esm/capability-EW5GJCI6.mjs +39 -0
- package/dist/lib/node-esm/capability-EW5GJCI6.mjs.map +7 -0
- package/dist/lib/node-esm/capability-YKBMMD53.mjs +36 -0
- package/dist/lib/node-esm/capability-YKBMMD53.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-37Z53PXZ.mjs +10 -0
- package/dist/lib/node-esm/chunk-37Z53PXZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-6XW6LET6.mjs +35 -0
- package/dist/lib/node-esm/chunk-6XW6LET6.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-D347W3KO.mjs +143 -0
- package/dist/lib/node-esm/chunk-D347W3KO.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-D5PO2WXX.mjs +373 -0
- package/dist/lib/node-esm/chunk-D5PO2WXX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HTBJU5FX.mjs +214 -0
- package/dist/lib/node-esm/chunk-HTBJU5FX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-KM2F6GH6.mjs +468 -0
- package/dist/lib/node-esm/chunk-KM2F6GH6.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-OZ7DZA5Z.mjs +2 -0
- package/dist/lib/node-esm/chunk-OZ7DZA5Z.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-Q7XBFII4.mjs +908 -0
- package/dist/lib/node-esm/chunk-Q7XBFII4.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SBS2YMPT.mjs +43 -0
- package/dist/lib/node-esm/chunk-SBS2YMPT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SDJ4B2LU.mjs +80 -0
- package/dist/lib/node-esm/chunk-SDJ4B2LU.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WFSRZKBP.mjs +81 -0
- package/dist/lib/node-esm/chunk-WFSRZKBP.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WKTLE7MG.mjs +585 -0
- package/dist/lib/node-esm/chunk-WKTLE7MG.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-XOCUANHO.mjs +49 -0
- package/dist/lib/node-esm/chunk-XOCUANHO.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +75 -0
- package/dist/lib/node-esm/cli/index.mjs.map +7 -0
- package/dist/lib/node-esm/common/activation-events.mjs +25 -0
- package/dist/lib/node-esm/common/activation-events.mjs.map +7 -0
- package/dist/lib/node-esm/common/capabilities.mjs +47 -0
- package/dist/lib/node-esm/common/capabilities.mjs.map +7 -0
- package/dist/lib/node-esm/core/activation-event.mjs +21 -0
- package/dist/lib/node-esm/core/activation-event.mjs.map +7 -0
- package/dist/lib/node-esm/core/capability.mjs +31 -0
- package/dist/lib/node-esm/core/capability.mjs.map +7 -0
- package/dist/lib/node-esm/core/plugin-manager.mjs +18 -0
- package/dist/lib/node-esm/core/plugin-manager.mjs.map +7 -0
- package/dist/lib/node-esm/core/plugin.mjs +38 -0
- package/dist/lib/node-esm/core/plugin.mjs.map +7 -0
- package/dist/lib/node-esm/core/url-loader.mjs +21 -0
- package/dist/lib/node-esm/core/url-loader.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +95 -148
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/invoker-capability-O4T5PHLA.mjs +45 -0
- package/dist/lib/node-esm/invoker-capability-O4T5PHLA.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +227 -41
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/testing/react.mjs +79 -0
- package/dist/lib/node-esm/testing/react.mjs.map +7 -0
- package/dist/lib/node-esm/ui/index.mjs +49 -0
- package/dist/lib/node-esm/ui/index.mjs.map +7 -0
- package/dist/plugin/node-esm/index.mjs +832 -0
- package/dist/plugin/node-esm/index.mjs.map +7 -0
- package/dist/plugin/node-esm/meta.json +1 -0
- package/dist/types/src/cli/cli.d.ts +39 -0
- package/dist/types/src/cli/cli.d.ts.map +1 -0
- package/dist/types/src/cli/index.d.ts +2 -0
- package/dist/types/src/cli/index.d.ts.map +1 -0
- package/dist/types/src/common/activation-events.d.ts +27 -0
- package/dist/types/src/common/activation-events.d.ts.map +1 -0
- package/dist/types/src/common/capabilities.d.ts +110 -197
- package/dist/types/src/common/capabilities.d.ts.map +1 -1
- package/dist/types/src/common/index.d.ts +4 -8
- package/dist/types/src/common/index.d.ts.map +1 -1
- package/dist/types/src/common/operations.d.ts +19 -0
- package/dist/types/src/common/operations.d.ts.map +1 -0
- package/dist/types/src/common/translations.d.ts +8 -8
- package/dist/types/src/common/translations.d.ts.map +1 -1
- package/dist/types/src/context.d.ts +5 -0
- package/dist/types/src/context.d.ts.map +1 -0
- package/dist/types/src/core/{events.d.ts → activation-event.d.ts} +11 -11
- package/dist/types/src/core/activation-event.d.ts.map +1 -0
- package/dist/types/src/core/capability-manager.d.ts +48 -0
- package/dist/types/src/core/capability-manager.d.ts.map +1 -0
- package/dist/types/src/core/capability-manager.test.d.ts +2 -0
- package/dist/types/src/core/capability-manager.test.d.ts.map +1 -0
- package/dist/types/src/core/capability.d.ts +156 -0
- package/dist/types/src/core/capability.d.ts.map +1 -0
- package/dist/types/src/core/index.d.ts +8 -4
- package/dist/types/src/core/index.d.ts.map +1 -1
- package/dist/types/src/core/plugin-asset-cache.d.ts +71 -0
- package/dist/types/src/core/plugin-asset-cache.d.ts.map +1 -0
- package/dist/types/src/core/plugin-manager.d.ts +122 -0
- package/dist/types/src/core/plugin-manager.d.ts.map +1 -0
- package/dist/types/src/core/plugin-manager.test.d.ts +2 -0
- package/dist/types/src/core/plugin-manager.test.d.ts.map +1 -0
- package/dist/types/src/core/plugin-manifest.d.ts +76 -0
- package/dist/types/src/core/plugin-manifest.d.ts.map +1 -0
- package/dist/types/src/core/plugin-manifest.test.d.ts +2 -0
- package/dist/types/src/core/plugin-manifest.test.d.ts.map +1 -0
- package/dist/types/src/core/plugin.d.ts +207 -39
- package/dist/types/src/core/plugin.d.ts.map +1 -1
- package/dist/types/src/core/url-loader.d.ts +112 -0
- package/dist/types/src/core/url-loader.d.ts.map +1 -0
- package/dist/types/src/core/url-loader.test.d.ts +2 -0
- package/dist/types/src/core/url-loader.test.d.ts.map +1 -0
- package/dist/types/src/helpers.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -4
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/OperationPlugin.d.ts +3 -0
- package/dist/types/src/plugin-operation/OperationPlugin.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/capability.d.ts +7 -0
- package/dist/types/src/plugin-operation/history/capability.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/errors.d.ts +32 -0
- package/dist/types/src/plugin-operation/history/errors.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/history-tracker.d.ts +18 -0
- package/dist/types/src/plugin-operation/history/history-tracker.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/history-tracker.test.d.ts +2 -0
- package/dist/types/src/plugin-operation/history/history-tracker.test.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/index.d.ts +6 -0
- package/dist/types/src/plugin-operation/history/index.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/types.d.ts +13 -0
- package/dist/types/src/plugin-operation/history/types.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/undo-mapping.d.ts +101 -0
- package/dist/types/src/plugin-operation/history/undo-mapping.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/undo-registry.d.ts +23 -0
- package/dist/types/src/plugin-operation/history/undo-registry.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/undo-registry.test.d.ts +2 -0
- package/dist/types/src/plugin-operation/history/undo-registry.test.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/index.d.ts +3 -0
- package/dist/types/src/plugin-operation/index.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/invoker-capability.d.ts +6 -0
- package/dist/types/src/plugin-operation/invoker-capability.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/meta.d.ts +3 -0
- package/dist/types/src/plugin-operation/meta.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/testing.d.ts +59 -0
- package/dist/types/src/plugin-operation/testing.d.ts.map +1 -0
- package/dist/types/src/plugin-runtime/RuntimePlugin.d.ts +3 -0
- package/dist/types/src/plugin-runtime/RuntimePlugin.d.ts.map +1 -0
- package/dist/types/src/plugin-runtime/capability.d.ts +6 -0
- package/dist/types/src/plugin-runtime/capability.d.ts.map +1 -0
- package/dist/types/src/plugin-runtime/index.d.ts +2 -0
- package/dist/types/src/plugin-runtime/index.d.ts.map +1 -0
- package/dist/types/src/plugin-runtime/meta.d.ts +3 -0
- package/dist/types/src/plugin-runtime/meta.d.ts.map +1 -0
- package/dist/types/src/testing/harness.d.ts +67 -0
- package/dist/types/src/testing/harness.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/react.d.ts +27 -0
- package/dist/types/src/testing/react.d.ts.map +1 -0
- package/dist/types/src/testing/react.test.d.ts +2 -0
- package/dist/types/src/testing/react.test.d.ts.map +1 -0
- package/dist/types/src/testing/service.d.ts +8 -0
- package/dist/types/src/testing/service.d.ts.map +1 -0
- package/dist/types/src/testing/withPluginManager.d.ts +7 -6
- package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
- package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -1
- package/dist/types/src/ui/components/App/App.d.ts +9 -0
- package/dist/types/src/ui/components/App/App.d.ts.map +1 -0
- package/dist/types/src/ui/components/App/App.stories.d.ts +19 -0
- package/dist/types/src/ui/components/App/App.stories.d.ts.map +1 -0
- package/dist/types/src/ui/components/App/index.d.ts +2 -0
- package/dist/types/src/ui/components/App/index.d.ts.map +1 -0
- package/dist/types/src/ui/components/Placeholder/Placeholder.d.ts +64 -0
- package/dist/types/src/ui/components/Placeholder/Placeholder.d.ts.map +1 -0
- package/dist/types/src/ui/components/Placeholder/Placeholder.stories.d.ts +19 -0
- package/dist/types/src/ui/components/Placeholder/Placeholder.stories.d.ts.map +1 -0
- package/dist/types/src/ui/components/Placeholder/index.d.ts +2 -0
- package/dist/types/src/ui/components/Placeholder/index.d.ts.map +1 -0
- package/dist/types/src/{playground/playground.stories.d.ts → ui/components/PluginManager/PluginManagerContext.stories.d.ts} +5 -3
- package/dist/types/src/ui/components/PluginManager/PluginManagerContext.stories.d.ts.map +1 -0
- package/dist/types/src/ui/components/PluginManager/PluginManagerProvider.d.ts +10 -0
- package/dist/types/src/ui/components/PluginManager/PluginManagerProvider.d.ts.map +1 -0
- package/dist/types/src/ui/components/PluginManager/index.d.ts +2 -0
- package/dist/types/src/ui/components/PluginManager/index.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts +24 -0
- package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts.map +1 -0
- package/dist/types/src/{components/App.stories.d.ts → ui/components/Surface/SurfaceComponent.stories.d.ts} +1 -1
- package/dist/types/src/ui/components/Surface/SurfaceComponent.stories.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/SurfaceInfo.d.ts +11 -0
- package/dist/types/src/ui/components/Surface/SurfaceInfo.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/SurfaceProfilerContext.d.ts +48 -0
- package/dist/types/src/ui/components/Surface/SurfaceProfilerContext.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/context.d.ts +5 -0
- package/dist/types/src/ui/components/Surface/context.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/index.d.ts +36 -0
- package/dist/types/src/ui/components/Surface/index.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/types.d.ts +197 -0
- package/dist/types/src/ui/components/Surface/types.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/types.test.d.ts +2 -0
- package/dist/types/src/ui/components/Surface/types.test.d.ts.map +1 -0
- package/dist/types/src/ui/components/index.d.ts +5 -0
- package/dist/types/src/ui/components/index.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/index.d.ts +6 -0
- package/dist/types/src/ui/hooks/index.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/useApp.d.ts +88 -0
- package/dist/types/src/ui/hooks/useApp.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/useApp.test.d.ts +2 -0
- package/dist/types/src/ui/hooks/useApp.test.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/useCapabilities.d.ts +31 -0
- package/dist/types/src/ui/hooks/useCapabilities.d.ts.map +1 -0
- package/dist/types/src/{components → ui/hooks}/useLoading.d.ts +1 -2
- package/dist/types/src/ui/hooks/useLoading.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/useSettingsState.d.ts +10 -0
- package/dist/types/src/ui/hooks/useSettingsState.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/useSurface.d.ts +3 -0
- package/dist/types/src/ui/hooks/useSurface.d.ts.map +1 -0
- package/dist/types/src/ui/index.d.ts +3 -0
- package/dist/types/src/ui/index.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/boot-loader/BootLoader.stories.d.ts +34 -0
- package/dist/types/src/vite-plugin/boot-loader/BootLoader.stories.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/boot-loader/index.d.ts +52 -0
- package/dist/types/src/vite-plugin/boot-loader/index.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/composer/index.d.ts +34 -0
- package/dist/types/src/vite-plugin/composer/index.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/import-map/index.d.ts +28 -0
- package/dist/types/src/vite-plugin/import-map/index.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/index.d.ts +5 -0
- package/dist/types/src/vite-plugin/index.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/manifest.d.ts +37 -0
- package/dist/types/src/vite-plugin/manifest.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/manifest.test.d.ts +2 -0
- package/dist/types/src/vite-plugin/manifest.test.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/packages.d.ts +13 -0
- package/dist/types/src/vite-plugin/packages.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/moon.yml +25 -6
- package/package.json +112 -55
- package/src/cli/cli.ts +107 -0
- package/src/{components → cli}/index.ts +1 -1
- package/src/common/activation-events.ts +44 -0
- package/src/common/capabilities.ts +169 -210
- package/src/common/index.ts +4 -8
- package/src/common/operations.ts +35 -0
- package/src/common/translations.ts +18 -10
- package/src/context.ts +9 -0
- package/src/core/{events.ts → activation-event.ts} +10 -7
- package/src/core/capability-manager.test.ts +151 -0
- package/src/core/capability-manager.ts +192 -0
- package/src/core/capability.ts +247 -0
- package/src/core/index.ts +8 -4
- package/src/core/plugin-asset-cache.ts +60 -0
- package/src/core/plugin-manager.test.ts +1354 -0
- package/src/core/plugin-manager.ts +1025 -0
- package/src/core/plugin-manifest.test.ts +48 -0
- package/src/core/plugin-manifest.ts +102 -0
- package/src/core/plugin.ts +365 -45
- package/src/core/url-loader.test.ts +178 -0
- package/src/core/url-loader.ts +337 -0
- package/src/index.ts +3 -4
- package/src/plugin-operation/OperationPlugin.ts +24 -0
- package/src/plugin-operation/history/capability.ts +36 -0
- package/src/plugin-operation/history/errors.ts +7 -0
- package/src/plugin-operation/history/history-tracker.test.ts +374 -0
- package/src/plugin-operation/history/history-tracker.ts +128 -0
- package/src/plugin-operation/history/index.ts +9 -0
- package/src/plugin-operation/history/types.ts +17 -0
- package/src/plugin-operation/history/undo-mapping.ts +135 -0
- package/src/plugin-operation/history/undo-registry.test.ts +72 -0
- package/src/plugin-operation/history/undo-registry.ts +54 -0
- package/src/plugin-operation/index.ts +6 -0
- package/src/plugin-operation/invoker-capability.ts +55 -0
- package/src/plugin-operation/meta.ts +11 -0
- package/src/plugin-operation/testing.ts +155 -0
- package/src/plugin-runtime/RuntimePlugin.ts +19 -0
- package/src/plugin-runtime/capability.ts +53 -0
- package/src/{playground/layout → plugin-runtime}/index.ts +1 -1
- package/src/plugin-runtime/meta.ts +11 -0
- package/src/testing/harness.ts +229 -0
- package/src/testing/index.ts +2 -0
- package/src/testing/react.test.tsx +48 -0
- package/src/testing/react.tsx +113 -0
- package/src/testing/service.ts +52 -0
- package/src/testing/withPluginManager.stories.tsx +8 -9
- package/src/testing/withPluginManager.tsx +68 -40
- package/src/ui/components/App/App.stories.tsx +92 -0
- package/src/ui/components/App/App.tsx +81 -0
- package/src/{playground/debug → ui/components/App}/index.ts +1 -1
- package/src/ui/components/Placeholder/Placeholder.stories.tsx +77 -0
- package/src/ui/components/Placeholder/Placeholder.tsx +155 -0
- package/src/{playground/logger → ui/components/Placeholder}/index.ts +1 -1
- package/src/ui/components/PluginManager/PluginManagerContext.stories.tsx +185 -0
- package/src/{react → ui/components/PluginManager}/PluginManagerProvider.ts +3 -3
- package/src/ui/components/PluginManager/index.ts +5 -0
- package/src/ui/components/Surface/SurfaceComponent.stories.tsx +144 -0
- package/src/ui/components/Surface/SurfaceComponent.tsx +303 -0
- package/src/ui/components/Surface/SurfaceInfo.tsx +107 -0
- package/src/ui/components/Surface/SurfaceProfilerContext.tsx +207 -0
- package/src/ui/components/Surface/context.ts +12 -0
- package/src/ui/components/Surface/index.ts +54 -0
- package/src/ui/components/Surface/types.test.ts +126 -0
- package/src/ui/components/Surface/types.ts +269 -0
- package/src/ui/components/index.ts +8 -0
- package/src/ui/hooks/index.ts +9 -0
- package/src/ui/hooks/useApp.test.tsx +159 -0
- package/src/ui/hooks/useApp.tsx +413 -0
- package/src/ui/hooks/useCapabilities.ts +67 -0
- package/src/{components → ui/hooks}/useLoading.tsx +16 -10
- package/src/ui/hooks/useSettingsState.ts +26 -0
- package/src/ui/hooks/useSurface.ts +13 -0
- package/src/ui/index.ts +6 -0
- package/src/vite-plugin/boot-loader/BootLoader.stories.tsx +263 -0
- package/src/vite-plugin/boot-loader/boot-loader.css +294 -0
- package/src/vite-plugin/boot-loader/boot-loader.js +274 -0
- package/src/vite-plugin/boot-loader/index.ts +112 -0
- package/src/vite-plugin/composer/index.ts +277 -0
- package/src/vite-plugin/import-map/index.ts +524 -0
- package/src/vite-plugin/index.ts +10 -0
- package/src/vite-plugin/manifest.test.ts +24 -0
- package/src/vite-plugin/manifest.ts +50 -0
- package/src/vite-plugin/packages.ts +188 -0
- package/tsconfig.json +18 -15
- package/tsconfig.node.json +2 -4
- package/typedoc.json +2 -4
- package/vitest.config.ts +1 -1
- package/.swc/plugins/linux_x86_64_19.0.0/727453fb3a62f7f1d952a41e051ca8a6f88cadc45cee43c6a4d1aa45f9b75665.wasmer-v7 +0 -0
- package/.swc/plugins/linux_x86_64_19.0.0/fce1bdb8e20a094e4af08bad09cc81497ed0e2e7c51223b07d371063cca18429.wasmer-v7 +0 -0
- package/dist/lib/browser/app-graph-builder-XH4OYQLC.mjs +0 -137
- package/dist/lib/browser/app-graph-builder-XH4OYQLC.mjs.map +0 -7
- package/dist/lib/browser/chunk-6V54SRFL.mjs +0 -1638
- package/dist/lib/browser/chunk-6V54SRFL.mjs.map +0 -7
- package/dist/lib/browser/chunk-RGKMLI6U.mjs +0 -35
- package/dist/lib/browser/chunk-RGKMLI6U.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZZVFNUHZ.mjs +0 -467
- package/dist/lib/browser/chunk-ZZVFNUHZ.mjs.map +0 -7
- package/dist/lib/browser/intent-dispatcher-VFMJVO2M.mjs +0 -11
- package/dist/lib/browser/intent-resolver-ICAPD4JL.mjs +0 -39
- package/dist/lib/browser/intent-resolver-ICAPD4JL.mjs.map +0 -7
- package/dist/lib/browser/store-7ZGMHOGB.mjs +0 -30
- package/dist/lib/browser/store-7ZGMHOGB.mjs.map +0 -7
- package/dist/lib/browser/worker.mjs +0 -77
- package/dist/lib/node-esm/app-graph-builder-C7H22SOL.mjs +0 -138
- package/dist/lib/node-esm/app-graph-builder-C7H22SOL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AXSZKZFD.mjs +0 -468
- package/dist/lib/node-esm/chunk-AXSZKZFD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LKPMRTRR.mjs +0 -37
- package/dist/lib/node-esm/chunk-LKPMRTRR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SOVTUUAY.mjs +0 -1640
- package/dist/lib/node-esm/chunk-SOVTUUAY.mjs.map +0 -7
- package/dist/lib/node-esm/intent-dispatcher-SAPOKSLZ.mjs +0 -12
- package/dist/lib/node-esm/intent-resolver-CRNJ6BMD.mjs +0 -40
- package/dist/lib/node-esm/intent-resolver-CRNJ6BMD.mjs.map +0 -7
- package/dist/lib/node-esm/store-H4F4RMYD.mjs +0 -31
- package/dist/lib/node-esm/store-H4F4RMYD.mjs.map +0 -7
- package/dist/lib/node-esm/worker.mjs +0 -78
- package/dist/types/src/common/collaboration.d.ts +0 -20
- package/dist/types/src/common/collaboration.d.ts.map +0 -1
- package/dist/types/src/common/events.d.ts +0 -52
- package/dist/types/src/common/events.d.ts.map +0 -1
- package/dist/types/src/common/file.d.ts +0 -14
- package/dist/types/src/common/file.d.ts.map +0 -1
- package/dist/types/src/common/graph.d.ts +0 -21
- package/dist/types/src/common/graph.d.ts.map +0 -1
- package/dist/types/src/common/layout.d.ts +0 -279
- package/dist/types/src/common/layout.d.ts.map +0 -1
- package/dist/types/src/common/surface.d.ts +0 -59
- package/dist/types/src/common/surface.d.ts.map +0 -1
- package/dist/types/src/components/App.d.ts +0 -10
- package/dist/types/src/components/App.d.ts.map +0 -1
- package/dist/types/src/components/App.stories.d.ts.map +0 -1
- package/dist/types/src/components/DefaultFallback.d.ts +0 -8
- package/dist/types/src/components/DefaultFallback.d.ts.map +0 -1
- package/dist/types/src/components/index.d.ts +0 -2
- package/dist/types/src/components/index.d.ts.map +0 -1
- package/dist/types/src/components/useApp.d.ts +0 -44
- package/dist/types/src/components/useApp.d.ts.map +0 -1
- package/dist/types/src/components/useLoading.d.ts.map +0 -1
- package/dist/types/src/core/capabilities.d.ts +0 -117
- package/dist/types/src/core/capabilities.d.ts.map +0 -1
- package/dist/types/src/core/capabilities.test.d.ts +0 -2
- package/dist/types/src/core/capabilities.test.d.ts.map +0 -1
- package/dist/types/src/core/events.d.ts.map +0 -1
- package/dist/types/src/core/manager.d.ts +0 -126
- package/dist/types/src/core/manager.d.ts.map +0 -1
- package/dist/types/src/core/manager.test.d.ts +0 -2
- package/dist/types/src/core/manager.test.d.ts.map +0 -1
- package/dist/types/src/playground/debug/Debug.d.ts +0 -6
- package/dist/types/src/playground/debug/Debug.d.ts.map +0 -1
- package/dist/types/src/playground/debug/index.d.ts +0 -2
- package/dist/types/src/playground/debug/index.d.ts.map +0 -1
- package/dist/types/src/playground/debug/plugin.d.ts +0 -2
- package/dist/types/src/playground/debug/plugin.d.ts.map +0 -1
- package/dist/types/src/playground/generator/Main.d.ts +0 -6
- package/dist/types/src/playground/generator/Main.d.ts.map +0 -1
- package/dist/types/src/playground/generator/Toolbar.d.ts +0 -6
- package/dist/types/src/playground/generator/Toolbar.d.ts.map +0 -1
- package/dist/types/src/playground/generator/generator.d.ts +0 -7
- package/dist/types/src/playground/generator/generator.d.ts.map +0 -1
- package/dist/types/src/playground/generator/index.d.ts +0 -3
- package/dist/types/src/playground/generator/index.d.ts.map +0 -1
- package/dist/types/src/playground/generator/plugin.d.ts +0 -2
- package/dist/types/src/playground/generator/plugin.d.ts.map +0 -1
- package/dist/types/src/playground/layout/Layout.d.ts +0 -8
- package/dist/types/src/playground/layout/Layout.d.ts.map +0 -1
- package/dist/types/src/playground/layout/index.d.ts +0 -2
- package/dist/types/src/playground/layout/index.d.ts.map +0 -1
- package/dist/types/src/playground/layout/plugin.d.ts +0 -2
- package/dist/types/src/playground/layout/plugin.d.ts.map +0 -1
- package/dist/types/src/playground/logger/Toolbar.d.ts +0 -6
- package/dist/types/src/playground/logger/Toolbar.d.ts.map +0 -1
- package/dist/types/src/playground/logger/index.d.ts +0 -2
- package/dist/types/src/playground/logger/index.d.ts.map +0 -1
- package/dist/types/src/playground/logger/plugin.d.ts +0 -2
- package/dist/types/src/playground/logger/plugin.d.ts.map +0 -1
- package/dist/types/src/playground/logger/schema.d.ts +0 -13
- package/dist/types/src/playground/logger/schema.d.ts.map +0 -1
- package/dist/types/src/playground/playground.stories.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts +0 -2
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/actions.d.ts +0 -36
- package/dist/types/src/plugin-intent/actions.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/errors.d.ts +0 -16
- package/dist/types/src/plugin-intent/errors.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/index.d.ts +0 -6
- package/dist/types/src/plugin-intent/index.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +0 -139
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts +0 -2
- package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/intent.d.ts +0 -63
- package/dist/types/src/plugin-intent/intent.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/meta.d.ts +0 -3
- package/dist/types/src/plugin-intent/meta.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +0 -2
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/actions.d.ts +0 -25
- package/dist/types/src/plugin-settings/actions.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts +0 -4
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/index.d.ts +0 -3
- package/dist/types/src/plugin-settings/index.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/intent-resolver.d.ts +0 -4
- package/dist/types/src/plugin-settings/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/meta.d.ts +0 -3
- package/dist/types/src/plugin-settings/meta.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/store.d.ts +0 -5
- package/dist/types/src/plugin-settings/store.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/translations.d.ts +0 -11
- package/dist/types/src/plugin-settings/translations.d.ts.map +0 -1
- package/dist/types/src/react/ErrorBoundary.d.ts +0 -30
- package/dist/types/src/react/ErrorBoundary.d.ts.map +0 -1
- package/dist/types/src/react/IntentContext.d.ts +0 -8
- package/dist/types/src/react/IntentContext.d.ts.map +0 -1
- package/dist/types/src/react/PluginManagerProvider.d.ts +0 -10
- package/dist/types/src/react/PluginManagerProvider.d.ts.map +0 -1
- package/dist/types/src/react/Surface.d.ts +0 -12
- package/dist/types/src/react/Surface.d.ts.map +0 -1
- package/dist/types/src/react/Surface.stories.d.ts +0 -17
- package/dist/types/src/react/Surface.stories.d.ts.map +0 -1
- package/dist/types/src/react/common.d.ts +0 -13
- package/dist/types/src/react/common.d.ts.map +0 -1
- package/dist/types/src/react/index.d.ts +0 -7
- package/dist/types/src/react/index.d.ts.map +0 -1
- package/dist/types/src/react/useCapabilities.d.ts +0 -13
- package/dist/types/src/react/useCapabilities.d.ts.map +0 -1
- package/dist/types/src/react/useIntentResolver.d.ts +0 -3
- package/dist/types/src/react/useIntentResolver.d.ts.map +0 -1
- package/dist/types/src/worker.d.ts +0 -4
- package/dist/types/src/worker.d.ts.map +0 -1
- package/src/common/collaboration.ts +0 -18
- package/src/common/events.ts +0 -79
- package/src/common/file.ts +0 -22
- package/src/common/graph.ts +0 -30
- package/src/common/layout.ts +0 -277
- package/src/common/surface.ts +0 -83
- package/src/components/App.stories.tsx +0 -33
- package/src/components/App.tsx +0 -59
- package/src/components/DefaultFallback.tsx +0 -26
- package/src/components/useApp.tsx +0 -164
- package/src/core/capabilities.test.ts +0 -136
- package/src/core/capabilities.ts +0 -259
- package/src/core/manager.test.ts +0 -516
- package/src/core/manager.ts +0 -597
- package/src/playground/debug/Debug.tsx +0 -39
- package/src/playground/debug/plugin.ts +0 -16
- package/src/playground/generator/Main.tsx +0 -71
- package/src/playground/generator/Toolbar.tsx +0 -47
- package/src/playground/generator/generator.ts +0 -48
- package/src/playground/generator/index.ts +0 -6
- package/src/playground/generator/plugin.ts +0 -22
- package/src/playground/layout/Layout.tsx +0 -33
- package/src/playground/layout/plugin.ts +0 -18
- package/src/playground/logger/Toolbar.tsx +0 -30
- package/src/playground/logger/plugin.ts +0 -41
- package/src/playground/logger/schema.ts +0 -12
- package/src/playground/playground.stories.tsx +0 -46
- package/src/plugin-intent/IntentPlugin.ts +0 -20
- package/src/plugin-intent/actions.ts +0 -31
- package/src/plugin-intent/errors.ts +0 -40
- package/src/plugin-intent/index.ts +0 -9
- package/src/plugin-intent/intent-dispatcher.test.ts +0 -279
- package/src/plugin-intent/intent-dispatcher.ts +0 -334
- package/src/plugin-intent/intent.ts +0 -154
- package/src/plugin-intent/meta.ts +0 -10
- package/src/plugin-settings/SettingsPlugin.ts +0 -34
- package/src/plugin-settings/actions.ts +0 -25
- package/src/plugin-settings/app-graph-builder.ts +0 -159
- package/src/plugin-settings/index.ts +0 -6
- package/src/plugin-settings/intent-resolver.ts +0 -35
- package/src/plugin-settings/meta.ts +0 -10
- package/src/plugin-settings/store.ts +0 -33
- package/src/plugin-settings/translations.ts +0 -19
- package/src/react/ErrorBoundary.tsx +0 -54
- package/src/react/IntentContext.tsx +0 -35
- package/src/react/Surface.stories.tsx +0 -101
- package/src/react/Surface.tsx +0 -86
- package/src/react/common.ts +0 -13
- package/src/react/index.ts +0 -10
- package/src/react/useCapabilities.ts +0 -31
- package/src/react/useIntentResolver.ts +0 -22
- package/src/worker.ts +0 -11
- /package/dist/lib/browser/{intent-dispatcher-VFMJVO2M.mjs.map → chunk-G7SDBRKH.mjs.map} +0 -0
- /package/dist/lib/browser/{worker.mjs.map → chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{node-esm/intent-dispatcher-SAPOKSLZ.mjs.map → browser/common/activation-events.mjs.map} +0 -0
- /package/dist/lib/{node-esm/worker.mjs.map → browser/common/capabilities.mjs.map} +0 -0
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { init as initCjsLexer, parse as parseCjs } from 'cjs-module-lexer';
|
|
6
|
+
import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
|
7
|
+
import { createRequire as nodeCreateRequire } from 'node:module';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { type Plugin } from 'vite';
|
|
10
|
+
|
|
11
|
+
import { DEFAULT_PACKAGES } from '../packages';
|
|
12
|
+
|
|
13
|
+
const require = nodeCreateRequire(import.meta.url);
|
|
14
|
+
|
|
15
|
+
//
|
|
16
|
+
// Import map helpers.
|
|
17
|
+
// These utilities support `importMapPlugin` by resolving package entrypoints,
|
|
18
|
+
// detecting module formats (ESM vs CJS), and extracting named exports from CJS bundles.
|
|
19
|
+
//
|
|
20
|
+
|
|
21
|
+
/** Strips vite query strings (e.g. `?v=123`) from resolved module IDs. */
|
|
22
|
+
const trimQueryString = (id: string) => id.replace(/\?.*$/, '');
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Determines whether a resolved file is an ESM module by checking file extension
|
|
26
|
+
* first (.mjs/.cjs), then walking up to the nearest package.json for `"type": "module"`.
|
|
27
|
+
*/
|
|
28
|
+
const resolvedIdIsEsmModule = (resolvedId: string): boolean => {
|
|
29
|
+
const file = trimQueryString(resolvedId);
|
|
30
|
+
if (file.endsWith('.mjs') || file.endsWith('.mts')) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
if (file.endsWith('.cjs') || file.endsWith('.cts')) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let directory = path.dirname(file);
|
|
38
|
+
while (directory !== path.dirname(directory)) {
|
|
39
|
+
const packageJsonPath = path.join(directory, 'package.json');
|
|
40
|
+
if (existsSync(packageJsonPath)) {
|
|
41
|
+
try {
|
|
42
|
+
const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf8')) as { type?: string };
|
|
43
|
+
return pkg.type === 'module';
|
|
44
|
+
} catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
directory = path.dirname(directory);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return false;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Walks up from a resolved file path to find the package.json whose `"name"` matches
|
|
56
|
+
* the given package name. Returns the path to that package.json, or undefined.
|
|
57
|
+
*/
|
|
58
|
+
const findPackageJsonPath = (resolvedId: string, packageName: string): string | undefined => {
|
|
59
|
+
let directory = path.dirname(trimQueryString(resolvedId));
|
|
60
|
+
|
|
61
|
+
while (directory !== path.dirname(directory)) {
|
|
62
|
+
const packageJsonPath = path.join(directory, 'package.json');
|
|
63
|
+
if (existsSync(packageJsonPath)) {
|
|
64
|
+
try {
|
|
65
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8')) as { name?: string };
|
|
66
|
+
if (packageJson.name === packageName) {
|
|
67
|
+
return packageJsonPath;
|
|
68
|
+
}
|
|
69
|
+
} catch {}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
directory = path.dirname(directory);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return undefined;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/** Resolves a package name to its package.json path using Node's require.resolve. */
|
|
79
|
+
const resolvePackageJsonPath = (packageName: string): string | undefined => {
|
|
80
|
+
try {
|
|
81
|
+
return findPackageJsonPath(require.resolve(packageName), packageName);
|
|
82
|
+
} catch {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Resolves a package name to its package.json via vite's own resolver, which handles
|
|
89
|
+
* workspace-linked packages whose `exports` field omits `./package.json` (so
|
|
90
|
+
* `require.resolve` can't find it). Falls back to `require.resolve`.
|
|
91
|
+
*/
|
|
92
|
+
const resolvePackageJsonPathViaContext = async (
|
|
93
|
+
ctx: { resolve: (id: string) => Promise<{ id: string } | null> },
|
|
94
|
+
packageName: string,
|
|
95
|
+
): Promise<string | undefined> => {
|
|
96
|
+
try {
|
|
97
|
+
const resolved = await ctx.resolve(packageName);
|
|
98
|
+
if (resolved) {
|
|
99
|
+
const viaResolved = findPackageJsonPath(resolved.id, packageName);
|
|
100
|
+
if (viaResolved) {
|
|
101
|
+
return viaResolved;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
} catch {
|
|
105
|
+
// fall through
|
|
106
|
+
}
|
|
107
|
+
return resolvePackageJsonPath(packageName);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Subpath exports that should be excluded from the import map.
|
|
112
|
+
* These are node-only entrypoints (vite plugins, native addons) that shouldn't be pre-bundled for the browser.
|
|
113
|
+
*
|
|
114
|
+
* TODO(wittjosiah): Replace these hand-maintained lists (plus {@link GLOBALLY_EXCLUDED_SUBPATHS}
|
|
115
|
+
* and {@link BUILD_TOOL_SUBPATH}) with a structural check — e.g. honour an `agent`/`node`-only
|
|
116
|
+
* export condition in package.json, or probe each subpath's resolved file for `node:*` imports
|
|
117
|
+
* at build time — so every new server-only entrypoint doesn't require a code change here.
|
|
118
|
+
*/
|
|
119
|
+
const importMapExcludedSubpaths: Readonly<Record<string, ReadonlySet<string>>> = {
|
|
120
|
+
'@dxos/app-framework': new Set(['vite-plugin']),
|
|
121
|
+
// `@dxos/lit-grid/testing` re-exports a playwright page-object manager and pulls
|
|
122
|
+
// `@playwright/test` (and transitive playwright-core) into the browser bundle.
|
|
123
|
+
'@dxos/lit-grid': new Set(['testing']),
|
|
124
|
+
'@dxos/react-ui-mosaic': new Set(['playwright']),
|
|
125
|
+
'@dxos/react-ui-stack': new Set(['playwright']),
|
|
126
|
+
'@dxos/react-ui-table': new Set(['playwright']),
|
|
127
|
+
'@dxos/ui-theme': new Set(['plugin']),
|
|
128
|
+
// `solid-js/web/storage` is a server-only helper that pulls
|
|
129
|
+
// `node:async_hooks` (AsyncLocalStorage) and has no browser shim. Client
|
|
130
|
+
// code imports `solid-js`, `solid-js/store`, and `solid-js/web` only.
|
|
131
|
+
'solid-js': new Set(['web/storage']),
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Subpaths common to many packages that should always be excluded.
|
|
136
|
+
* `./playwright` subdirectories house e2e test harnesses that pull in
|
|
137
|
+
* `@playwright/test` (a node-only package that breaks the browser bundle).
|
|
138
|
+
* `./testing` subpaths similarly expose node-only test helpers (e.g.
|
|
139
|
+
* `@dxos/edge-client/testing` pulls `@dxos/node-std/http` which has no
|
|
140
|
+
* browser analogue) and aren't part of the plugin-facing surface.
|
|
141
|
+
*/
|
|
142
|
+
const GLOBALLY_EXCLUDED_SUBPATHS = new Set(['playwright', 'testing']);
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Regex for subpaths that are always node-only build tooling — vite, esbuild, and
|
|
146
|
+
* rollup plugins. These use `node:*` imports and will blow up the browser bundle if
|
|
147
|
+
* they end up in the import map.
|
|
148
|
+
*/
|
|
149
|
+
const BUILD_TOOL_SUBPATH = /^(vite-plugin|esbuild-plugin|rollup-plugin|plugin)$/;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Asset subpaths (CSS, PCSS, images, etc.) that the host already loads via its own
|
|
153
|
+
* bundle — for example `@dxos/react-ui-form` pulls in `@dxos/lit-ui/dx-tag-picker.pcss`
|
|
154
|
+
* on startup, so the stylesheet is already attached to the DOM by the time a remote
|
|
155
|
+
* plugin runs. Community plugins should still be able to _import_ those specifiers
|
|
156
|
+
* (rolldown leaves the `import "…"` statements in the output when the package is
|
|
157
|
+
* externalized), so the import map maps them to a no-op empty ES module. The
|
|
158
|
+
* resulting browser fetch is a cheap no-op; the styles are never re-downloaded
|
|
159
|
+
* and never re-injected.
|
|
160
|
+
*/
|
|
161
|
+
const ASSET_SUBPATH = /\.(css|pcss|scss|sass|less|json|node|wasm|html|svg|png|jpe?g|gif|webp|ico)$/;
|
|
162
|
+
const isAssetSubpath = (specifier: string) => ASSET_SUBPATH.test(specifier);
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Walks `baseDir` and returns every file that matches the pattern `${baseDir}/<rest>${extension}`.
|
|
166
|
+
* Used to expand wildcard exports like `./proto/*` → `./dist/src/proto/gen/*.js` into their
|
|
167
|
+
* full set of bare specifiers.
|
|
168
|
+
*/
|
|
169
|
+
const walkDirectoryForExtension = (baseDir: string, extension: string): string[] => {
|
|
170
|
+
if (!existsSync(baseDir)) {
|
|
171
|
+
return [];
|
|
172
|
+
}
|
|
173
|
+
const results: string[] = [];
|
|
174
|
+
const walk = (dir: string) => {
|
|
175
|
+
let entries: string[];
|
|
176
|
+
try {
|
|
177
|
+
entries = readdirSync(dir);
|
|
178
|
+
} catch {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
for (const entry of entries) {
|
|
182
|
+
const full = path.join(dir, entry);
|
|
183
|
+
let stat;
|
|
184
|
+
try {
|
|
185
|
+
stat = statSync(full);
|
|
186
|
+
} catch {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
if (stat.isDirectory()) {
|
|
190
|
+
walk(full);
|
|
191
|
+
} else if (entry.endsWith(extension)) {
|
|
192
|
+
results.push(path.relative(baseDir, full).slice(0, -extension.length));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
walk(baseDir);
|
|
197
|
+
return results;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
/** Resolves an `exports` value to a single target path for pattern expansion. */
|
|
201
|
+
const pickPatternTarget = (value: unknown): string | undefined => {
|
|
202
|
+
if (typeof value === 'string') {
|
|
203
|
+
return value;
|
|
204
|
+
}
|
|
205
|
+
if (value && typeof value === 'object') {
|
|
206
|
+
const obj = value as Record<string, unknown>;
|
|
207
|
+
const preferred = obj.browser ?? obj.import ?? obj.default ?? obj.module;
|
|
208
|
+
return typeof preferred === 'string' ? preferred : undefined;
|
|
209
|
+
}
|
|
210
|
+
return undefined;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Expands a wildcard export like `./proto/*` into concrete subpath specifiers by walking
|
|
215
|
+
* the target directory. Returns `<packageName>/<subpath>` strings.
|
|
216
|
+
*/
|
|
217
|
+
const expandWildcardExport = (
|
|
218
|
+
packageName: string,
|
|
219
|
+
packageJsonDir: string,
|
|
220
|
+
exportKey: string,
|
|
221
|
+
exportValue: unknown,
|
|
222
|
+
): string[] => {
|
|
223
|
+
const target = pickPatternTarget(exportValue);
|
|
224
|
+
if (!target || !target.includes('*')) {
|
|
225
|
+
return [];
|
|
226
|
+
}
|
|
227
|
+
// Split on `*` — at most one supported (node's exports pattern semantics).
|
|
228
|
+
const keyStarIndex = exportKey.indexOf('*');
|
|
229
|
+
const targetStarIndex = target.indexOf('*');
|
|
230
|
+
if (keyStarIndex === -1 || targetStarIndex === -1) {
|
|
231
|
+
return [];
|
|
232
|
+
}
|
|
233
|
+
const keyPrefix = exportKey.slice(2, keyStarIndex); // drop leading './'
|
|
234
|
+
const targetPrefix = target.slice(2, targetStarIndex); // drop leading './'
|
|
235
|
+
const targetSuffix = target.slice(targetStarIndex + 1);
|
|
236
|
+
const baseDir = path.resolve(packageJsonDir, targetPrefix);
|
|
237
|
+
const files = walkDirectoryForExtension(baseDir, targetSuffix || '.js');
|
|
238
|
+
return files.map((relativeNoExt) => `${packageName}/${keyPrefix}${relativeNoExt}`);
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Reads a package's `exports` field and returns all subpath entrypoints as bare specifiers
|
|
243
|
+
* (e.g. `@dxos/client`, `@dxos/client/echo`, `@dxos/lit-ui/dx-tag-picker.pcss`,
|
|
244
|
+
* `@dxos/protocols/proto/dxos/echo/metadata`). Wildcard patterns are expanded by walking
|
|
245
|
+
* the corresponding output directory. Falls back to just the package name if exports is
|
|
246
|
+
* absent or simple.
|
|
247
|
+
*/
|
|
248
|
+
const getPackageEntrypoints = (packageName: string, packageJsonPath: string): string[] => {
|
|
249
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8')) as {
|
|
250
|
+
exports?: Record<string, unknown> | string | string[];
|
|
251
|
+
};
|
|
252
|
+
const exportsField = packageJson.exports;
|
|
253
|
+
|
|
254
|
+
if (!exportsField || typeof exportsField === 'string' || Array.isArray(exportsField)) {
|
|
255
|
+
return [packageName];
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const exportKeys = Object.keys(exportsField);
|
|
259
|
+
if (!exportKeys.some((key) => key.startsWith('.'))) {
|
|
260
|
+
return [packageName];
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const excluded = importMapExcludedSubpaths[packageName];
|
|
264
|
+
const packageJsonDir = path.dirname(packageJsonPath);
|
|
265
|
+
const modules = exportKeys.flatMap((key) => {
|
|
266
|
+
if (key === '.') {
|
|
267
|
+
return [packageName];
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (!key.startsWith('./') || key === './package.json') {
|
|
271
|
+
return [];
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Skip `.d.ts` subpath exports — these are meant to be imported as raw text
|
|
275
|
+
// (e.g. `@dxos/echo-query/api.d.ts?raw` for in-editor type hints), not as
|
|
276
|
+
// ES modules. Enumerating them here would have vite try to bundle the
|
|
277
|
+
// declaration file's imports (protobufjs, effect, etc.), which breaks.
|
|
278
|
+
if (key.endsWith('.d.ts')) {
|
|
279
|
+
return [];
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (key.includes('*')) {
|
|
283
|
+
// Expand wildcard patterns like `./proto/*` into concrete specifiers.
|
|
284
|
+
return expandWildcardExport(packageName, packageJsonDir, key, (exportsField as Record<string, unknown>)[key]);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const subpath = key.slice(2);
|
|
288
|
+
if (excluded?.has(subpath) || GLOBALLY_EXCLUDED_SUBPATHS.has(subpath) || BUILD_TOOL_SUBPATH.test(subpath)) {
|
|
289
|
+
return [];
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return [`${packageName}/${subpath}`];
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
return modules.length > 0 ? modules : [packageName];
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Statically analyzes a CJS file to extract named exports using cjs-module-lexer.
|
|
300
|
+
* Follows re-exports (e.g. react's index.js re-exports from cjs/react.development.js)
|
|
301
|
+
* and deduplicates. Filters out `default` and `__esModule` pseudo-exports.
|
|
302
|
+
*/
|
|
303
|
+
const getCjsNamedExports = (filePath: string, seen = new Set<string>()): string[] => {
|
|
304
|
+
const normalized = trimQueryString(filePath);
|
|
305
|
+
if (seen.has(normalized)) {
|
|
306
|
+
return [];
|
|
307
|
+
}
|
|
308
|
+
seen.add(normalized);
|
|
309
|
+
|
|
310
|
+
try {
|
|
311
|
+
const source = readFileSync(normalized, 'utf8');
|
|
312
|
+
const { exports: directExports, reexports } = parseCjs(source);
|
|
313
|
+
|
|
314
|
+
const reexportedNames = reexports.flatMap((reexport) => {
|
|
315
|
+
const resolved = path.resolve(path.dirname(normalized), reexport);
|
|
316
|
+
const candidates = [resolved, `${resolved}.js`, `${resolved}.cjs`];
|
|
317
|
+
const found = candidates.find((candidate) => existsSync(candidate));
|
|
318
|
+
return found ? getCjsNamedExports(found, seen) : [];
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
return [...new Set([...directExports, ...reexportedNames])].filter(
|
|
322
|
+
(name) => name !== 'default' && name !== '__esModule',
|
|
323
|
+
);
|
|
324
|
+
} catch {
|
|
325
|
+
return [];
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Vite plugin for the **host app** (Composer). Generates a browser import map so that
|
|
331
|
+
* shared packages are loaded once and reused by both the host and any remote plugins.
|
|
332
|
+
*
|
|
333
|
+
* In production, emits a dedicated chunk per specifier via virtual wrapper modules,
|
|
334
|
+
* then injects a `<script type="importmap">` tag into the HTML with the chunk URLs.
|
|
335
|
+
*
|
|
336
|
+
* Virtual wrappers are needed because directly emitting chunks for CJS packages loses
|
|
337
|
+
* their named exports due to Rollup's interop. The wrapper re-exports them explicitly.
|
|
338
|
+
*
|
|
339
|
+
* TODO: Restore dev-mode support. The previous dev path mapped each bare specifier to
|
|
340
|
+
* its absolute `/@fs/` file path during `buildStart`, which forced `this.resolve()` for
|
|
341
|
+
* hundreds of subpath entrypoints and raced with Vite's optimize-deps static scan —
|
|
342
|
+
* producing non-deterministic chunk content (~34 chunks drifting per warm-start) and
|
|
343
|
+
* triggering Vite 8.0.10's `runOptimizer` / `commitProcessing` crashes (`fileHash` /
|
|
344
|
+
* `browserHash` undefined on partial-discovery batches). Plugin is currently gated to
|
|
345
|
+
* `apply: 'build'` to avoid both. A working dev-mode implementation would need to
|
|
346
|
+
* resolve specifiers without participating in the optimize-deps phase — candidates:
|
|
347
|
+
* - defer resolution to `transformIndexHtml` (after the optimizer settles)
|
|
348
|
+
* - read resolved paths from `environment.depsOptimizer.metadata` rather than calling
|
|
349
|
+
* `this.resolve()` ourselves
|
|
350
|
+
* - resolve via `require.resolve` directly, bypassing the Vite plugin pipeline entirely
|
|
351
|
+
*/
|
|
352
|
+
export const importMapPlugin = (options?: { packages?: string[] }): Plugin[] => {
|
|
353
|
+
const packages = options?.packages ?? DEFAULT_PACKAGES;
|
|
354
|
+
const WRAPPER_PREFIX = '\0import-map:';
|
|
355
|
+
const chunkRefIds: Record<string, string> = {};
|
|
356
|
+
const resolvedIds: Record<string, string> = {};
|
|
357
|
+
let imports: Record<string, string> = {};
|
|
358
|
+
let modules: string[] = [];
|
|
359
|
+
let importMapIsDev = false;
|
|
360
|
+
let base = '/';
|
|
361
|
+
|
|
362
|
+
return [
|
|
363
|
+
// Phase 1: Resolve all package entrypoints and emit chunks.
|
|
364
|
+
//
|
|
365
|
+
// Build-only. The dev-mode path (recording absolute `/@fs/` paths in
|
|
366
|
+
// `imports[]`) is non-functional today and was actively harmful: calling
|
|
367
|
+
// `this.resolve()` for every shared package's subpath entrypoints during
|
|
368
|
+
// `buildStart` races with Vite's optimize-deps static scan, producing
|
|
369
|
+
// non-deterministic chunk content (~34 drifting chunks per warm-start) and
|
|
370
|
+
// triggering Vite 8.0.10's `runOptimizer` / `commitProcessing` crashes
|
|
371
|
+
// (`fileHash` / `browserHash` undefined on partial-discovery batches) when
|
|
372
|
+
// the resolved set doesn't match the optimizer's metadata. The importmap
|
|
373
|
+
// is only meaningful for production builds where remote plugins consume
|
|
374
|
+
// the emitted wrapper chunks.
|
|
375
|
+
{
|
|
376
|
+
name: 'import-map:get-chunk-ref-ids',
|
|
377
|
+
apply: 'build',
|
|
378
|
+
configResolved(config) {
|
|
379
|
+
base = config.base ?? '/';
|
|
380
|
+
},
|
|
381
|
+
async buildStart() {
|
|
382
|
+
importMapIsDev = this.environment.mode === 'dev';
|
|
383
|
+
await initCjsLexer();
|
|
384
|
+
|
|
385
|
+
// Expand each package name into its full set of subpath entrypoints
|
|
386
|
+
// (e.g. '@dxos/client' -> ['@dxos/client', '@dxos/client/echo', ...]).
|
|
387
|
+
modules = [
|
|
388
|
+
...new Set(
|
|
389
|
+
(
|
|
390
|
+
await Promise.all(
|
|
391
|
+
packages.map(async (packageName) => {
|
|
392
|
+
const packageJsonPath = await resolvePackageJsonPathViaContext(this, packageName);
|
|
393
|
+
if (!packageJsonPath) {
|
|
394
|
+
this.warn(`Unable to locate package.json for import map package: ${packageName}`);
|
|
395
|
+
return [packageName];
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
return getPackageEntrypoints(packageName, packageJsonPath);
|
|
399
|
+
}),
|
|
400
|
+
)
|
|
401
|
+
).flat(),
|
|
402
|
+
),
|
|
403
|
+
];
|
|
404
|
+
|
|
405
|
+
for (const specifier of modules) {
|
|
406
|
+
if (isAssetSubpath(specifier)) {
|
|
407
|
+
// Host already loaded the real asset; remote plugins need the specifier to
|
|
408
|
+
// resolve to *something* that behaves as an ES module. A data URL is the
|
|
409
|
+
// cheapest option — no chunk to emit (rolldown tree-shakes an empty wrapper
|
|
410
|
+
// even with `preserveSignature: 'strict'`, so the referenced file wouldn't
|
|
411
|
+
// exist at runtime), no extra network request, and the same path in dev and prod.
|
|
412
|
+
imports[specifier] = 'data:text/javascript;charset=utf-8,export%20%7B%7D%3B';
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
const resolved = await this.resolve(specifier);
|
|
417
|
+
if (!resolved) {
|
|
418
|
+
this.warn(`Import map: unable to resolve "${specifier}"; omitting from import map.`);
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
if (importMapIsDev) {
|
|
423
|
+
// Dev: map bare specifier to the resolved file path, prefixed with vite's
|
|
424
|
+
// `/@fs/` escape hatch so absolute node_modules paths (including
|
|
425
|
+
// `.vite/deps/*` pre-bundled chunks) round-trip through the dev server
|
|
426
|
+
// instead of being resolved against the document origin as a 404.
|
|
427
|
+
const filePath = trimQueryString(resolved.id);
|
|
428
|
+
imports[specifier] = filePath.startsWith('/') ? `/@fs${filePath}` : filePath;
|
|
429
|
+
} else {
|
|
430
|
+
// Prod: emit a virtual wrapper chunk that re-exports from the real module.
|
|
431
|
+
resolvedIds[specifier] = resolved.id;
|
|
432
|
+
chunkRefIds[specifier] = this.emitFile({
|
|
433
|
+
type: 'chunk',
|
|
434
|
+
id: `${WRAPPER_PREFIX}${specifier}`,
|
|
435
|
+
preserveSignature: 'strict',
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
},
|
|
440
|
+
|
|
441
|
+
// Intercept virtual wrapper IDs so Rollup doesn't try to resolve them as files.
|
|
442
|
+
resolveId(id) {
|
|
443
|
+
if (id.startsWith(WRAPPER_PREFIX)) {
|
|
444
|
+
return id;
|
|
445
|
+
}
|
|
446
|
+
},
|
|
447
|
+
|
|
448
|
+
// Generate the source for each virtual wrapper module.
|
|
449
|
+
// For CJS packages, explicitly re-export named exports (discovered via static analysis)
|
|
450
|
+
// because Rollup's `export *` interop doesn't preserve them for CJS.
|
|
451
|
+
//
|
|
452
|
+
// Each wrapper also emits a local `__keepalive` export. Without this, Rolldown
|
|
453
|
+
// (Vite 8) tree-shakes wrappers whose `export *` re-exports happen to coincide
|
|
454
|
+
// with another already-emitted chunk's exports — typical for umbrella packages
|
|
455
|
+
// (e.g. `@dxos/compute` re-exports from `@dxos/operation`, so the operation
|
|
456
|
+
// wrapper looks "redundant" to Rolldown and gets merged away). A local const
|
|
457
|
+
// export has no upstream source for Rolldown to dedupe against, so the chunk
|
|
458
|
+
// is always preserved and the import-map entry resolves at runtime.
|
|
459
|
+
load(id) {
|
|
460
|
+
if (!id.startsWith(WRAPPER_PREFIX)) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
const specifier = id.slice(WRAPPER_PREFIX.length);
|
|
464
|
+
const keepalive = `export const __dxosImportMapKeepalive = ${JSON.stringify(specifier)};`;
|
|
465
|
+
const resolvedId = resolvedIds[specifier];
|
|
466
|
+
if (!resolvedId) {
|
|
467
|
+
return `export * from ${JSON.stringify(specifier)};\n${keepalive}\n`;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
const filePath = trimQueryString(resolvedId);
|
|
471
|
+
const isCjs = filePath.endsWith('.cjs') || (!filePath.endsWith('.mjs') && !resolvedIdIsEsmModule(filePath));
|
|
472
|
+
|
|
473
|
+
if (isCjs) {
|
|
474
|
+
const named = getCjsNamedExports(filePath);
|
|
475
|
+
if (named.length > 0) {
|
|
476
|
+
return `export { default, ${named.join(', ')} } from ${JSON.stringify(specifier)};\n${keepalive}\n`;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return `export * from ${JSON.stringify(specifier)};\n${keepalive}\n`;
|
|
480
|
+
},
|
|
481
|
+
|
|
482
|
+
// After bundling, map each specifier to the URL of its emitted chunk. Preserves
|
|
483
|
+
// asset-subpath entries already written to `imports` during `buildStart` (those
|
|
484
|
+
// use an inline data URL rather than an emitted chunk).
|
|
485
|
+
generateBundle() {
|
|
486
|
+
if (importMapIsDev) {
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
imports = {
|
|
491
|
+
...imports,
|
|
492
|
+
...Object.fromEntries(
|
|
493
|
+
modules
|
|
494
|
+
.filter((specifier) => chunkRefIds[specifier] !== undefined)
|
|
495
|
+
.map((specifier) => [specifier, `${base}${this.getFileName(chunkRefIds[specifier])}`]),
|
|
496
|
+
),
|
|
497
|
+
};
|
|
498
|
+
},
|
|
499
|
+
},
|
|
500
|
+
|
|
501
|
+
// Phase 2: Inject the import map into the HTML as a <script type="importmap"> tag.
|
|
502
|
+
{
|
|
503
|
+
name: 'import-map:transform-index-html',
|
|
504
|
+
apply: 'build',
|
|
505
|
+
enforce: 'post',
|
|
506
|
+
transformIndexHtml(html: string) {
|
|
507
|
+
const tags = [
|
|
508
|
+
{
|
|
509
|
+
tag: 'script',
|
|
510
|
+
attrs: {
|
|
511
|
+
type: 'importmap',
|
|
512
|
+
},
|
|
513
|
+
children: JSON.stringify({ imports }, null, 2),
|
|
514
|
+
},
|
|
515
|
+
];
|
|
516
|
+
|
|
517
|
+
return {
|
|
518
|
+
html,
|
|
519
|
+
tags,
|
|
520
|
+
};
|
|
521
|
+
},
|
|
522
|
+
},
|
|
523
|
+
];
|
|
524
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
export * from './boot-loader';
|
|
6
|
+
export * from './composer';
|
|
7
|
+
export * from './import-map';
|
|
8
|
+
// `manifest` and `packages` are shared data used by composer / import-map; they
|
|
9
|
+
// stay at the top level because they're not vite plugins themselves.
|
|
10
|
+
export * from './packages';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { serializeManifest } from './manifest';
|
|
8
|
+
|
|
9
|
+
describe('serializeManifest', () => {
|
|
10
|
+
test('serializes plugin meta plus assets', ({ expect }) => {
|
|
11
|
+
const json = serializeManifest(
|
|
12
|
+
{ id: 'org.example.plugin', name: 'Example', description: 'Demo', tags: ['new'], version: '1.2.3' },
|
|
13
|
+
{ assets: ['index.mjs', 'style.css', 'chunks/lib-abc.js'] },
|
|
14
|
+
);
|
|
15
|
+
expect(JSON.parse(json)).toEqual({
|
|
16
|
+
id: 'org.example.plugin',
|
|
17
|
+
name: 'Example',
|
|
18
|
+
description: 'Demo',
|
|
19
|
+
tags: ['new'],
|
|
20
|
+
version: '1.2.3',
|
|
21
|
+
assets: ['index.mjs', 'style.css', 'chunks/lib-abc.js'],
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { PLUGIN_ENTRY_FILENAME } from '@dxos/protocols';
|
|
6
|
+
|
|
7
|
+
import { type Plugin } from '../core';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Name of the asset written alongside the built module bundle.
|
|
11
|
+
* The DXOS community registry resolves each published plugin by fetching this file
|
|
12
|
+
* from the repo's latest GitHub Release, so authors should not rename it.
|
|
13
|
+
*/
|
|
14
|
+
export const MANIFEST_ASSET_NAME = 'manifest.json';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Canonical entry filename (re-exported from `@dxos/protocols`) so vite-plugin
|
|
18
|
+
* consumers don't have to reach into the protocols package directly.
|
|
19
|
+
*/
|
|
20
|
+
export const ENTRY_FILENAME = PLUGIN_ENTRY_FILENAME;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Plugin metadata required to emit a manifest at build time.
|
|
24
|
+
*
|
|
25
|
+
* Extends `Plugin.Meta` with a build-time `version` field that is not
|
|
26
|
+
* relevant to the runtime plugin definition itself.
|
|
27
|
+
*/
|
|
28
|
+
export type BuildMeta = Plugin.Meta & { version: string };
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Serializes a plugin's public metadata + bundle layout into the format consumed
|
|
32
|
+
* by the host loader (see `UrlLoader.make` and `PluginManifest.parse`).
|
|
33
|
+
*
|
|
34
|
+
* The host fetches this manifest, resolves every entry in `assets` against the
|
|
35
|
+
* manifest URL, and persists them via the platform `PluginAssetCache` so the
|
|
36
|
+
* plugin works offline. The entry module is always {@link ENTRY_FILENAME}; it
|
|
37
|
+
* must appear in `assets`.
|
|
38
|
+
*
|
|
39
|
+
* Exported from a vite-free module so tests and tooling can validate manifests
|
|
40
|
+
* without paying the cost of loading vite + esbuild.
|
|
41
|
+
*/
|
|
42
|
+
export const serializeManifest = (meta: BuildMeta, { assets }: { assets: readonly string[] }): string =>
|
|
43
|
+
JSON.stringify(
|
|
44
|
+
{
|
|
45
|
+
...meta,
|
|
46
|
+
assets,
|
|
47
|
+
},
|
|
48
|
+
null,
|
|
49
|
+
2,
|
|
50
|
+
);
|