@dxos/app-framework 0.8.4-main.c85a9c8dae → 0.8.4-main.d05539e30a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/browser/{capability-7RLVE42K.mjs → capability-K5XIVCQU.mjs} +12 -11
- package/dist/lib/browser/capability-K5XIVCQU.mjs.map +7 -0
- package/dist/lib/browser/chunk-5AHASNDW.mjs +95 -0
- package/dist/lib/browser/chunk-5AHASNDW.mjs.map +7 -0
- package/dist/lib/browser/chunk-5GY3YOEL.mjs +28 -0
- package/dist/lib/browser/chunk-5GY3YOEL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-PKQT6C53.mjs → chunk-66IXTIVK.mjs} +3 -2
- package/dist/lib/browser/chunk-66IXTIVK.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ZRWBPIZG.mjs → chunk-BRK6GYNB.mjs} +14 -42
- package/dist/lib/browser/chunk-BRK6GYNB.mjs.map +7 -0
- package/dist/lib/browser/chunk-FJ4765WW.mjs +8 -0
- package/dist/lib/browser/{chunk-FHQTHCX7.mjs.map → chunk-FJ4765WW.mjs.map} +3 -3
- package/dist/lib/browser/chunk-FO3IYSLV.mjs +68 -0
- package/dist/lib/browser/chunk-FO3IYSLV.mjs.map +7 -0
- package/dist/lib/browser/{chunk-YNFPIQGB.mjs → chunk-IW44C7UL.mjs} +9 -2
- package/dist/lib/browser/chunk-IW44C7UL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-5RJNZV7K.mjs → chunk-KFDF7KR3.mjs} +11 -13
- package/dist/lib/browser/{chunk-5RJNZV7K.mjs.map → chunk-KFDF7KR3.mjs.map} +3 -3
- package/dist/lib/browser/chunk-KLHQNYJ2.mjs +422 -0
- package/dist/lib/browser/chunk-KLHQNYJ2.mjs.map +7 -0
- package/dist/lib/browser/chunk-QLML5QFJ.mjs +581 -0
- package/dist/lib/browser/chunk-QLML5QFJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FNKT2QQ2.mjs → chunk-SLX73WRZ.mjs} +90 -17
- package/dist/lib/browser/chunk-SLX73WRZ.mjs.map +7 -0
- package/dist/lib/browser/chunk-UVTGHZQF.mjs +513 -0
- package/dist/lib/browser/chunk-UVTGHZQF.mjs.map +7 -0
- package/dist/lib/browser/chunk-VJ5PFAWC.mjs +1446 -0
- package/dist/lib/browser/chunk-VJ5PFAWC.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +17 -32
- package/dist/lib/browser/cli/index.mjs.map +3 -3
- package/dist/lib/browser/common/activation-events.mjs +11 -14
- package/dist/lib/browser/common/capabilities.mjs +19 -8
- package/dist/lib/browser/core/activation-event.mjs +1 -1
- package/dist/lib/browser/core/capability.mjs +5 -1
- package/dist/lib/browser/core/plugin-manager.mjs +8 -4
- package/dist/lib/browser/core/plugin.mjs +16 -4
- package/dist/lib/browser/core/url-loader.mjs +24 -0
- package/dist/lib/browser/index.mjs +47 -49
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/process-manager-capability-JIWLN7SU.mjs +89 -0
- package/dist/lib/browser/process-manager-capability-JIWLN7SU.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +199 -56
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/browser/testing/react.mjs +78 -0
- package/dist/lib/browser/testing/react.mjs.map +7 -0
- package/dist/lib/browser/ui/index.mjs +24 -15
- package/dist/lib/node-esm/{capability-EVZK4REM.mjs → capability-RLKFFLTB.mjs} +12 -11
- package/dist/lib/node-esm/capability-RLKFFLTB.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-UEWJDI2L.mjs → chunk-37Z53PXZ.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-UEWJDI2L.mjs.map → chunk-37Z53PXZ.mjs.map} +3 -3
- package/dist/lib/node-esm/chunk-42UNAKYO.mjs +423 -0
- package/dist/lib/node-esm/chunk-42UNAKYO.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-CJCQS2YL.mjs → chunk-6S45OMUP.mjs} +90 -17
- package/dist/lib/node-esm/chunk-6S45OMUP.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-2A4PRBIX.mjs → chunk-BYHYYJZH.mjs} +14 -42
- package/dist/lib/node-esm/chunk-BYHYYJZH.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-SB5ODNPX.mjs → chunk-CTKEZHKF.mjs} +9 -2
- package/dist/lib/node-esm/chunk-CTKEZHKF.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-JNT72ZCN.mjs +514 -0
- package/dist/lib/node-esm/chunk-JNT72ZCN.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-KFZEB6BV.mjs +29 -0
- package/dist/lib/node-esm/chunk-KFZEB6BV.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-LJNUFNDO.mjs +582 -0
- package/dist/lib/node-esm/chunk-LJNUFNDO.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-VUIUFIGT.mjs → chunk-OUEMWPIW.mjs} +11 -13
- package/dist/lib/node-esm/{chunk-VUIUFIGT.mjs.map → chunk-OUEMWPIW.mjs.map} +3 -3
- package/dist/lib/node-esm/chunk-PW2VYGOS.mjs +96 -0
- package/dist/lib/node-esm/chunk-PW2VYGOS.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SFYCO3PT.mjs +1447 -0
- package/dist/lib/node-esm/chunk-SFYCO3PT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WK7OIQKI.mjs +70 -0
- package/dist/lib/node-esm/chunk-WK7OIQKI.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-7OWSHPYK.mjs → chunk-XOCUANHO.mjs} +3 -2
- package/dist/lib/node-esm/chunk-XOCUANHO.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +17 -32
- package/dist/lib/node-esm/cli/index.mjs.map +3 -3
- package/dist/lib/node-esm/common/activation-events.mjs +11 -14
- package/dist/lib/node-esm/common/capabilities.mjs +19 -8
- package/dist/lib/node-esm/core/activation-event.mjs +1 -1
- package/dist/lib/node-esm/core/capability.mjs +5 -1
- package/dist/lib/node-esm/core/plugin-manager.mjs +8 -4
- package/dist/lib/node-esm/core/plugin.mjs +16 -4
- package/dist/lib/node-esm/core/url-loader.mjs +25 -0
- package/dist/lib/node-esm/index.mjs +47 -49
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/process-manager-capability-PHKLO2BL.mjs +90 -0
- package/dist/lib/node-esm/process-manager-capability-PHKLO2BL.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +199 -56
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/testing/react.mjs +79 -0
- package/dist/lib/node-esm/testing/react.mjs.map +7 -0
- package/dist/lib/node-esm/ui/index.mjs +24 -15
- package/dist/plugin/node-esm/index.mjs +893 -0
- package/dist/plugin/node-esm/index.mjs.map +7 -0
- package/dist/plugin/node-esm/meta.json +1 -0
- package/dist/types/src/cli/cli.d.ts +1 -3
- package/dist/types/src/cli/cli.d.ts.map +1 -1
- package/dist/types/src/common/activation-events.d.ts +10 -13
- package/dist/types/src/common/activation-events.d.ts.map +1 -1
- package/dist/types/src/common/annotations.d.ts +1 -0
- package/dist/types/src/common/annotations.d.ts.map +1 -0
- package/dist/types/src/common/capabilities.d.ts +113 -12
- package/dist/types/src/common/capabilities.d.ts.map +1 -1
- package/dist/types/src/common/operations.d.ts +8 -22
- package/dist/types/src/common/operations.d.ts.map +1 -1
- package/dist/types/src/core/activation-event.d.ts +5 -5
- package/dist/types/src/core/activation-event.d.ts.map +1 -1
- package/dist/types/src/core/capability-manager.d.ts +5 -0
- package/dist/types/src/core/capability-manager.d.ts.map +1 -1
- package/dist/types/src/core/capability.d.ts +13 -2
- package/dist/types/src/core/capability.d.ts.map +1 -1
- package/dist/types/src/core/edge-registry-plugin-provider.d.ts +30 -0
- package/dist/types/src/core/edge-registry-plugin-provider.d.ts.map +1 -0
- package/dist/types/src/core/index.d.ts +6 -0
- package/dist/types/src/core/index.d.ts.map +1 -1
- package/dist/types/src/core/plugin-asset-cache.d.ts +71 -0
- package/dist/types/src/core/plugin-asset-cache.d.ts.map +1 -0
- package/dist/types/src/core/plugin-manager.d.ts +238 -7
- package/dist/types/src/core/plugin-manager.d.ts.map +1 -1
- package/dist/types/src/core/plugin-manifest.d.ts +101 -0
- package/dist/types/src/core/plugin-manifest.d.ts.map +1 -0
- package/dist/types/src/core/plugin-manifest.test.d.ts +2 -0
- package/dist/types/src/core/plugin-manifest.test.d.ts.map +1 -0
- package/dist/types/src/core/plugin.d.ts +182 -7
- package/dist/types/src/core/plugin.d.ts.map +1 -1
- package/dist/types/src/core/registry.d.ts +107 -0
- package/dist/types/src/core/registry.d.ts.map +1 -0
- package/dist/types/src/core/url-loader.d.ts +127 -0
- package/dist/types/src/core/url-loader.d.ts.map +1 -0
- package/dist/types/src/core/url-loader.test.d.ts +2 -0
- package/dist/types/src/core/url-loader.test.d.ts.map +1 -0
- package/dist/types/src/helpers.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/plugin-process-manager/ProcessManagerPlugin.d.ts +3 -0
- package/dist/types/src/plugin-process-manager/ProcessManagerPlugin.d.ts.map +1 -0
- package/dist/types/src/plugin-process-manager/history/capability.d.ts.map +1 -0
- package/dist/types/src/plugin-process-manager/history/errors.d.ts +32 -0
- package/dist/types/src/plugin-process-manager/history/errors.d.ts.map +1 -0
- package/dist/types/src/{plugin-operation → plugin-process-manager}/history/history-tracker.d.ts +1 -1
- package/dist/types/src/plugin-process-manager/history/history-tracker.d.ts.map +1 -0
- package/dist/types/src/plugin-process-manager/history/history-tracker.test.d.ts.map +1 -0
- package/dist/types/src/plugin-process-manager/history/index.d.ts.map +1 -0
- package/dist/types/src/{plugin-operation → plugin-process-manager}/history/types.d.ts +1 -1
- package/dist/types/src/plugin-process-manager/history/types.d.ts.map +1 -0
- package/dist/types/src/{plugin-operation → plugin-process-manager}/history/undo-mapping.d.ts +1 -1
- package/dist/types/src/plugin-process-manager/history/undo-mapping.d.ts.map +1 -0
- package/dist/types/src/{plugin-operation → plugin-process-manager}/history/undo-registry.d.ts +1 -1
- package/dist/types/src/plugin-process-manager/history/undo-registry.d.ts.map +1 -0
- package/dist/types/src/plugin-process-manager/history/undo-registry.test.d.ts.map +1 -0
- package/dist/types/src/plugin-process-manager/index.d.ts +3 -0
- package/dist/types/src/plugin-process-manager/index.d.ts.map +1 -0
- package/dist/types/src/plugin-process-manager/meta.d.ts.map +1 -0
- package/dist/types/src/plugin-process-manager/process-manager-capability.d.ts +8 -0
- package/dist/types/src/plugin-process-manager/process-manager-capability.d.ts.map +1 -0
- package/dist/types/src/plugin-process-manager/testing.d.ts +59 -0
- package/dist/types/src/plugin-process-manager/testing.d.ts.map +1 -0
- package/dist/types/src/testing/harness.d.ts +79 -0
- package/dist/types/src/testing/harness.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/react.d.ts +27 -0
- package/dist/types/src/testing/react.d.ts.map +1 -0
- package/dist/types/src/testing/react.test.d.ts +2 -0
- package/dist/types/src/testing/react.test.d.ts.map +1 -0
- package/dist/types/src/testing/service.d.ts.map +1 -1
- package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
- package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -1
- package/dist/types/src/ui/components/App/App.d.ts +3 -2
- package/dist/types/src/ui/components/App/App.d.ts.map +1 -1
- package/dist/types/src/ui/components/App/App.stories.d.ts +2 -2
- package/dist/types/src/ui/components/App/App.stories.d.ts.map +1 -1
- package/dist/types/src/ui/components/Placeholder/Placeholder.d.ts +64 -0
- package/dist/types/src/ui/components/Placeholder/Placeholder.d.ts.map +1 -0
- package/dist/types/src/ui/components/Placeholder/Placeholder.stories.d.ts +19 -0
- package/dist/types/src/ui/components/Placeholder/Placeholder.stories.d.ts.map +1 -0
- package/dist/types/src/ui/components/Placeholder/index.d.ts +2 -0
- package/dist/types/src/ui/components/Placeholder/index.d.ts.map +1 -0
- package/dist/types/src/ui/components/PluginManager/PluginManagerContext.stories.d.ts.map +1 -1
- package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts +16 -4
- package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts.map +1 -1
- package/dist/types/src/ui/components/Surface/SurfaceComponent.stories.d.ts.map +1 -1
- package/dist/types/src/ui/components/Surface/SurfaceInfo.d.ts.map +1 -1
- package/dist/types/src/ui/components/Surface/SurfaceProfilerContext.d.ts +48 -0
- package/dist/types/src/ui/components/Surface/SurfaceProfilerContext.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/index.d.ts +22 -6
- package/dist/types/src/ui/components/Surface/index.d.ts.map +1 -1
- package/dist/types/src/ui/components/Surface/types.d.ts +110 -9
- package/dist/types/src/ui/components/Surface/types.d.ts.map +1 -1
- package/dist/types/src/ui/components/Surface/types.test.d.ts +2 -0
- package/dist/types/src/ui/components/Surface/types.test.d.ts.map +1 -0
- package/dist/types/src/ui/components/index.d.ts +1 -0
- package/dist/types/src/ui/components/index.d.ts.map +1 -1
- package/dist/types/src/ui/hooks/index.d.ts +1 -1
- package/dist/types/src/ui/hooks/index.d.ts.map +1 -1
- package/dist/types/src/ui/hooks/useApp.d.ts +47 -11
- package/dist/types/src/ui/hooks/useApp.d.ts.map +1 -1
- package/dist/types/src/ui/hooks/useApp.test.d.ts +2 -0
- package/dist/types/src/ui/hooks/useApp.test.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/useCapabilities.d.ts.map +1 -1
- package/dist/types/src/ui/hooks/useLoading.d.ts.map +1 -1
- package/dist/types/src/ui/hooks/useProcessManagerRuntime.d.ts +24 -0
- package/dist/types/src/ui/hooks/useProcessManagerRuntime.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/useSettingsState.d.ts.map +1 -1
- package/dist/types/src/vite-plugin/boot-loader/BootLoader.stories.d.ts +34 -0
- package/dist/types/src/vite-plugin/boot-loader/BootLoader.stories.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/boot-loader/index.d.ts +2 -0
- package/dist/types/src/vite-plugin/boot-loader/index.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/boot-loader/loader.d.ts +51 -0
- package/dist/types/src/vite-plugin/boot-loader/loader.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/composer/index.d.ts +34 -0
- package/dist/types/src/vite-plugin/composer/index.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/import-map/index.d.ts +28 -0
- package/dist/types/src/vite-plugin/import-map/index.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/index.d.ts +5 -0
- package/dist/types/src/vite-plugin/index.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/manifest.d.ts +41 -0
- package/dist/types/src/vite-plugin/manifest.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/manifest.test.d.ts +2 -0
- package/dist/types/src/vite-plugin/manifest.test.d.ts.map +1 -0
- package/dist/types/src/vite-plugin/packages.d.ts +13 -0
- package/dist/types/src/vite-plugin/packages.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/moon.yml +15 -0
- package/package.json +53 -54
- package/src/cli/cli.ts +4 -9
- package/src/common/activation-events.ts +12 -17
- package/src/common/annotations.ts +3 -0
- package/src/common/capabilities.ts +160 -29
- package/src/common/operations.ts +7 -10
- package/src/context.ts +1 -1
- package/src/core/activation-event.ts +5 -2
- package/src/core/capability-manager.test.ts +1 -1
- package/src/core/capability-manager.ts +22 -1
- package/src/core/capability.ts +20 -2
- package/src/core/edge-registry-plugin-provider.ts +92 -0
- package/src/core/index.ts +6 -0
- package/src/core/plugin-asset-cache.ts +60 -0
- package/src/core/plugin-manager.test.ts +1085 -31
- package/src/core/plugin-manager.ts +1170 -198
- package/src/core/plugin-manifest.test.ts +75 -0
- package/src/core/plugin-manifest.ts +134 -0
- package/src/core/plugin.ts +194 -12
- package/src/core/registry.ts +163 -0
- package/src/core/url-loader.test.ts +221 -0
- package/src/core/url-loader.ts +388 -0
- package/src/index.ts +1 -2
- package/src/plugin-process-manager/ProcessManagerPlugin.ts +24 -0
- package/src/{plugin-operation → plugin-process-manager}/history/capability.ts +1 -2
- package/src/plugin-process-manager/history/errors.ts +7 -0
- package/src/{plugin-operation → plugin-process-manager}/history/history-tracker.test.ts +37 -43
- package/src/{plugin-operation → plugin-process-manager}/history/history-tracker.ts +1 -2
- package/src/{plugin-operation → plugin-process-manager}/history/types.ts +1 -1
- package/src/{plugin-operation → plugin-process-manager}/history/undo-mapping.ts +1 -1
- package/src/{plugin-operation → plugin-process-manager}/history/undo-registry.test.ts +3 -4
- package/src/{plugin-operation → plugin-process-manager}/history/undo-registry.ts +1 -1
- package/src/{plugin-operation → plugin-process-manager}/index.ts +1 -1
- package/src/plugin-process-manager/meta.ts +14 -0
- package/src/plugin-process-manager/process-manager-capability.ts +178 -0
- package/src/{plugin-operation → plugin-process-manager}/testing.ts +26 -45
- package/src/testing/harness.ts +247 -0
- package/src/testing/index.ts +1 -0
- package/src/testing/react.test.tsx +48 -0
- package/src/testing/react.tsx +113 -0
- package/src/testing/service.ts +4 -4
- package/src/testing/withPluginManager.stories.tsx +1 -2
- package/src/testing/withPluginManager.tsx +45 -20
- package/src/ui/components/App/App.stories.tsx +7 -13
- package/src/ui/components/App/App.tsx +29 -5
- package/src/ui/components/Placeholder/Placeholder.stories.tsx +77 -0
- package/src/ui/components/Placeholder/Placeholder.tsx +155 -0
- package/src/{plugin-runtime → ui/components/Placeholder}/index.ts +1 -1
- package/src/ui/components/PluginManager/PluginManagerContext.stories.tsx +8 -7
- package/src/ui/components/Surface/SurfaceComponent.stories.tsx +16 -15
- package/src/ui/components/Surface/SurfaceComponent.tsx +111 -55
- package/src/ui/components/Surface/SurfaceInfo.tsx +0 -1
- package/src/ui/components/Surface/SurfaceProfilerContext.tsx +207 -0
- package/src/ui/components/Surface/index.ts +35 -1
- package/src/ui/components/Surface/types.test.ts +126 -0
- package/src/ui/components/Surface/types.ts +164 -12
- package/src/ui/components/index.ts +1 -0
- package/src/ui/hooks/index.ts +1 -1
- package/src/ui/hooks/useApp.test.tsx +159 -0
- package/src/ui/hooks/useApp.tsx +229 -24
- package/src/ui/hooks/useLoading.tsx +14 -6
- package/src/ui/hooks/useProcessManagerRuntime.ts +68 -0
- package/src/vite-plugin/boot-loader/BootLoader.stories.tsx +270 -0
- package/src/vite-plugin/boot-loader/boot-loader.css +320 -0
- package/src/vite-plugin/boot-loader/boot-loader.js +325 -0
- package/src/vite-plugin/boot-loader/index.ts +5 -0
- package/src/vite-plugin/boot-loader/loader.ts +123 -0
- package/src/vite-plugin/composer/index.ts +306 -0
- package/src/vite-plugin/import-map/index.ts +527 -0
- package/src/vite-plugin/index.ts +10 -0
- package/src/vite-plugin/manifest.test.ts +46 -0
- package/src/vite-plugin/manifest.ts +57 -0
- package/src/vite-plugin/packages.ts +187 -0
- package/tsconfig.json +25 -1
- package/tsconfig.node.json +1 -1
- package/vitest.config.ts +1 -1
- package/.swc/plugins/linux_x86_64_19.0.0/727453fb3a62f7f1d952a41e051ca8a6f88cadc45cee43c6a4d1aa45f9b75665.wasmer-v7 +0 -0
- package/dist/lib/browser/capability-2GL5JAGJ.mjs +0 -37
- package/dist/lib/browser/capability-2GL5JAGJ.mjs.map +0 -7
- package/dist/lib/browser/capability-7RLVE42K.mjs.map +0 -7
- package/dist/lib/browser/chunk-4CTRO67U.mjs +0 -703
- package/dist/lib/browser/chunk-4CTRO67U.mjs.map +0 -7
- package/dist/lib/browser/chunk-FHQTHCX7.mjs +0 -8
- package/dist/lib/browser/chunk-FNKT2QQ2.mjs.map +0 -7
- package/dist/lib/browser/chunk-HE27PNNQ.mjs +0 -824
- package/dist/lib/browser/chunk-HE27PNNQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-NPUEVX42.mjs +0 -34
- package/dist/lib/browser/chunk-NPUEVX42.mjs.map +0 -7
- package/dist/lib/browser/chunk-PKQT6C53.mjs.map +0 -7
- package/dist/lib/browser/chunk-REORGDJT.mjs +0 -80
- package/dist/lib/browser/chunk-REORGDJT.mjs.map +0 -7
- package/dist/lib/browser/chunk-YAFEA4GV.mjs +0 -1
- package/dist/lib/browser/chunk-YNFPIQGB.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZRWBPIZG.mjs.map +0 -7
- package/dist/lib/browser/invoker-capability-BNLVNYHU.mjs +0 -36
- package/dist/lib/browser/invoker-capability-BNLVNYHU.mjs.map +0 -7
- package/dist/lib/node-esm/capability-CHIMU6LX.mjs +0 -38
- package/dist/lib/node-esm/capability-CHIMU6LX.mjs.map +0 -7
- package/dist/lib/node-esm/capability-EVZK4REM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2A4PRBIX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7CPNAEGV.mjs +0 -704
- package/dist/lib/node-esm/chunk-7CPNAEGV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7OWSHPYK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CJCQS2YL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DTCHT2X2.mjs +0 -825
- package/dist/lib/node-esm/chunk-DTCHT2X2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JAZVHID3.mjs +0 -35
- package/dist/lib/node-esm/chunk-JAZVHID3.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SB5ODNPX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UFW652GS.mjs +0 -81
- package/dist/lib/node-esm/chunk-UFW652GS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Z4TJPSMP.mjs +0 -2
- package/dist/lib/node-esm/invoker-capability-VF6SP44V.mjs +0 -37
- package/dist/lib/node-esm/invoker-capability-VF6SP44V.mjs.map +0 -7
- package/dist/types/src/plugin-operation/OperationPlugin.d.ts +0 -3
- package/dist/types/src/plugin-operation/OperationPlugin.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/history/capability.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/history/errors.d.ts +0 -5
- package/dist/types/src/plugin-operation/history/errors.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/history/history-tracker.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/history/history-tracker.test.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/history/index.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/history/types.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/history/undo-mapping.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/history/undo-registry.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/history/undo-registry.test.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/index.d.ts +0 -3
- package/dist/types/src/plugin-operation/index.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/invoker-capability.d.ts +0 -6
- package/dist/types/src/plugin-operation/invoker-capability.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/meta.d.ts.map +0 -1
- package/dist/types/src/plugin-operation/testing.d.ts +0 -109
- package/dist/types/src/plugin-operation/testing.d.ts.map +0 -1
- package/dist/types/src/plugin-runtime/RuntimePlugin.d.ts +0 -3
- package/dist/types/src/plugin-runtime/RuntimePlugin.d.ts.map +0 -1
- package/dist/types/src/plugin-runtime/capability.d.ts +0 -6
- package/dist/types/src/plugin-runtime/capability.d.ts.map +0 -1
- package/dist/types/src/plugin-runtime/index.d.ts +0 -2
- package/dist/types/src/plugin-runtime/index.d.ts.map +0 -1
- package/dist/types/src/plugin-runtime/meta.d.ts +0 -3
- package/dist/types/src/plugin-runtime/meta.d.ts.map +0 -1
- package/dist/types/src/ui/hooks/useOperationResolver.d.ts +0 -19
- package/dist/types/src/ui/hooks/useOperationResolver.d.ts.map +0 -1
- package/src/plugin-operation/OperationPlugin.ts +0 -25
- package/src/plugin-operation/history/errors.ts +0 -11
- package/src/plugin-operation/invoker-capability.ts +0 -40
- package/src/plugin-operation/meta.ts +0 -11
- package/src/plugin-runtime/RuntimePlugin.ts +0 -20
- package/src/plugin-runtime/capability.ts +0 -53
- package/src/plugin-runtime/meta.ts +0 -11
- package/src/ui/hooks/useOperationResolver.ts +0 -40
- /package/dist/lib/browser/{chunk-YAFEA4GV.mjs.map → core/url-loader.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-Z4TJPSMP.mjs.map → core/url-loader.mjs.map} +0 -0
- /package/dist/types/src/{plugin-operation → plugin-process-manager}/history/capability.d.ts +0 -0
- /package/dist/types/src/{plugin-operation → plugin-process-manager}/history/history-tracker.test.d.ts +0 -0
- /package/dist/types/src/{plugin-operation → plugin-process-manager}/history/index.d.ts +0 -0
- /package/dist/types/src/{plugin-operation → plugin-process-manager}/history/undo-registry.test.d.ts +0 -0
- /package/dist/types/src/{plugin-operation → plugin-process-manager}/meta.d.ts +0 -0
- /package/src/{plugin-operation → plugin-process-manager}/history/index.ts +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/core/url-loader.ts", "../../../src/core/plugin-asset-cache.ts", "../../../src/core/plugin-manifest.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\n\nimport { BaseError } from '@dxos/errors';\nimport { log } from '@dxos/log';\n\nimport * as Plugin from './plugin';\nimport * as PluginAssetCache from './plugin-asset-cache';\nimport * as PluginManifest from './plugin-manifest';\n\nconst DEFAULT_KEY = 'org.dxos.composer.remote-plugins';\n\n/**\n * Tagged error for any failure during remote plugin loading. Construction sites\n * set `context.locator` and `context.reason` (one of `'invalid-locator' |\n * 'manifest-error' | 'cache-error' | 'import-failed' | 'meta-missing' |\n * 'meta-mismatch' | 'duplicate-id'`) so handlers can route on the failure mode.\n */\nexport class RemotePluginLoadError extends BaseError.extend('RemotePluginLoadError', 'Failed to load remote plugin') {}\n\n/**\n * Abstraction over key-value storage (defaults to localStorage).\n */\nexport type Storage = {\n get(key: string): string | null;\n set(key: string, value: string): void;\n};\n\n/**\n * Options for configuring the URL loader.\n */\nexport type Options = {\n storage?: Storage;\n key?: string;\n /**\n * Per-platform offline asset cache. Defaults to a no-op cache (no offline support).\n */\n cache?: PluginAssetCache.Cache;\n};\n\n/**\n * Options for the preload entry point. Adds an optional progress hook so hosts\n * can drive a boot-loader counter (`Loading plugins (3/12)…`) as remote plugin\n * manifests resolve. Resolution order is *not* deterministic — each entry races\n * its own network fetch — so callers should treat `loaded` as a count, not an\n * index. Failures are still swallowed; `loaded` advances on both success and\n * recoverable failure so the counter always reaches `total`.\n */\nexport type PreloadOptions = Options & {\n onPluginLoaded?: (loaded: number, total: number) => void;\n};\n\n/**\n * Persisted record of a remote plugin that has been loaded previously.\n *\n * `url` is the URL of the plugin manifest (`plugin.json`), not the entry module.\n */\nexport type RemotePluginEntry = {\n id: string;\n url: string;\n /** Installed version string, e.g. `v1.0.0`. Populated after install from a community catalog entry. */\n version?: string;\n};\n\nconst defaultStorage = (): Storage => ({\n get: (key) => localStorage.getItem(key),\n set: (key, value) => localStorage.setItem(key, value),\n});\n\nconst getPersistedRemotePlugins = (storage: Storage, key: string): RemotePluginEntry[] => {\n try {\n const parsed: unknown = JSON.parse(storage.get(key) ?? '[]');\n if (!Array.isArray(parsed)) {\n return [];\n }\n return parsed.filter(\n (entry): entry is RemotePluginEntry =>\n typeof entry === 'object' && entry !== null && typeof entry.id === 'string' && typeof entry.url === 'string',\n );\n } catch {\n return [];\n }\n};\n\nconst persistRemotePlugin = (storage: Storage, key: string, entry: RemotePluginEntry): void => {\n try {\n const entries = getPersistedRemotePlugins(storage, key).filter((existing) => existing.id !== entry.id);\n entries.push(entry);\n storage.set(key, JSON.stringify(entries));\n } catch (error) {\n log.warn('failed to persist remote plugin entry', { entry, error });\n }\n};\n\nconst removePersistedRemotePlugin = (storage: Storage, key: string, pluginId: string): void => {\n try {\n const entries = getPersistedRemotePlugins(storage, key).filter((existing) => existing.id !== pluginId);\n storage.set(key, JSON.stringify(entries));\n } catch (error) {\n log.warn('failed to remove remote plugin entry', { pluginId, error });\n }\n};\n\nconst isUrl = (locator: string): boolean => {\n try {\n const url = new URL(locator);\n return url.protocol === 'http:' || url.protocol === 'https:';\n } catch {\n return false;\n }\n};\n\n/**\n * Returns true when the URL's hostname is the local host (localhost, 127.0.0.1, or ::1).\n */\nexport const isLocalUrl = (locator: string): boolean => {\n try {\n const hostname = new URL(locator).hostname.toLowerCase();\n // WHATWG URL returns '::1' without brackets in Node; some browsers return '[::1]'.\n return hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '::1' || hostname === '[::1]';\n } catch {\n return false;\n }\n};\n\n/**\n * Returns the list of remote plugin entries previously persisted by {@link make}.\n * Useful for UI code that needs to know which loaded plugins were installed from a URL\n * (e.g. to surface a tag on remote or localhost-hosted plugins).\n */\nexport const getRemoteEntries = (options: Options = {}): readonly RemotePluginEntry[] => {\n const storage = options.storage ?? defaultStorage();\n const key = options.key ?? DEFAULT_KEY;\n return getPersistedRemotePlugins(storage, key);\n};\n\n/**\n * Updates the persisted installed version for an already-stored remote plugin entry.\n * Does nothing if the plugin has not been persisted yet.\n */\nexport const setInstalledVersion = (id: string, version: string, options: Options = {}): void => {\n const storage = options.storage ?? defaultStorage();\n const key = options.key ?? DEFAULT_KEY;\n const entries = getPersistedRemotePlugins(storage, key);\n const index = entries.findIndex((entry) => entry.id === id);\n if (index === -1) {\n return;\n }\n entries[index] = { ...entries[index], version };\n try {\n storage.set(key, JSON.stringify(entries));\n } catch (error) {\n log.warn('failed to update installed version for remote plugin', { id, version, error });\n }\n};\n\n/**\n * Returns the installed version string for the given plugin id, or `undefined` if\n * the plugin was installed without version tracking (legacy install) or is not found.\n */\nexport const getInstalledVersion = (id: string, options: Options = {}): string | undefined => {\n const storage = options.storage ?? defaultStorage();\n const key = options.key ?? DEFAULT_KEY;\n return getPersistedRemotePlugins(storage, key).find((entry) => entry.id === id)?.version;\n};\n\nconst normalizePluginExport = (mod: Record<string, unknown>): Plugin.Plugin => {\n const exported = mod.default;\n if (Plugin.isPlugin(exported)) {\n return exported;\n }\n if (typeof exported === 'function') {\n const result = (exported as () => unknown)();\n if (Plugin.isPlugin(result)) {\n return result;\n }\n }\n throw new Error('Remote module default export is not a Plugin or a zero-arg plugin factory.');\n};\n\n/**\n * Loads stylesheets declared in the manifest by appending `<link rel=\"stylesheet\">` elements to the host document.\n * Each link is tagged with `data-dxos-plugin-id` so `uninstall` can clean them up.\n */\nconst loadStylesheets = (\n manifest: PluginManifest.ResolvedManifest,\n cache: PluginAssetCache.Cache,\n): Effect.Effect<void, PluginAssetCache.PluginAssetCacheError> =>\n Effect.gen(function* () {\n if (typeof document === 'undefined') {\n return;\n }\n const cssUrls = manifest.assetUrls.filter((url) => url.endsWith('.css'));\n for (const url of cssUrls) {\n const resolved = yield* cache.resolve(manifest.id, url);\n if (document.querySelector(`link[data-dxos-plugin-id=\"${manifest.id}\"][href=\"${resolved}\"]`)) {\n continue;\n }\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = resolved;\n link.dataset.dxosPluginId = manifest.id;\n document.head.appendChild(link);\n }\n });\n\nconst loadFromManifest = (\n manifestUrl: string,\n cache: PluginAssetCache.Cache,\n): Effect.Effect<{ plugin: Plugin.Plugin; manifest: PluginManifest.ResolvedManifest }, RemotePluginLoadError> =>\n Effect.gen(function* () {\n log.info('loading remote plugin', { manifestUrl });\n const manifest = yield* PluginManifest.fetchManifest(manifestUrl).pipe(\n Effect.mapError(\n (cause) => new RemotePluginLoadError({ context: { locator: manifestUrl, reason: 'manifest-error' }, cause }),\n ),\n );\n const wrapCacheError = Effect.mapError(\n (cause: PluginAssetCache.PluginAssetCacheError) =>\n new RemotePluginLoadError({ context: { locator: manifestUrl, reason: 'cache-error' }, cause }),\n );\n // Dev-mode manifests (served by `vite dev` via composerPlugin) skip the offline\n // cache: chunks resolve on demand through the dev server, the asset list isn't\n // enumerable up-front, and CSS arrives via runtime <style> injection rather than\n // static <link> tags.\n if (!manifest.dev) {\n // Cache the manifest URL alongside its declared assets. Without it, `preload` on a\n // subsequent reload would fetch the manifest from the network — and fail when the\n // plugin's host is offline, dropping the plugin from the runtime.\n const cachedUrls =\n manifest.assetUrls.indexOf(manifestUrl) === -1 ? [manifestUrl, ...manifest.assetUrls] : manifest.assetUrls;\n yield* cache.cache(manifest.id, cachedUrls).pipe(wrapCacheError);\n }\n const entryUrl = manifest.dev\n ? manifest.entryUrl\n : yield* cache.resolve(manifest.id, manifest.entryUrl).pipe(wrapCacheError);\n const mod = yield* Effect.tryPromise({\n try: () => import(/* @vite-ignore */ entryUrl),\n catch: (cause) =>\n new RemotePluginLoadError({ context: { locator: manifestUrl, reason: 'import-failed' }, cause }),\n });\n const plugin = normalizePluginExport(mod);\n if (!plugin.meta.id || !plugin.meta.name) {\n return yield* Effect.fail(\n new RemotePluginLoadError({ context: { locator: manifestUrl, reason: 'meta-missing' } }),\n );\n }\n if (plugin.meta.id !== manifest.id) {\n return yield* Effect.fail(\n new RemotePluginLoadError({\n context: {\n locator: manifestUrl,\n reason: 'meta-mismatch',\n metaId: plugin.meta.id,\n manifestId: manifest.id,\n },\n }),\n );\n }\n // Append stylesheets only after the entry imports cleanly and meta validation\n // passes. If we did this earlier and the import or meta checks failed, the\n // `<link>` tags would leak into the host DOM with no plugin to own their\n // teardown — `uninstall` only runs for plugins the manager actually accepted.\n // In dev mode, Vite injects styles at runtime via the module graph, so static\n // <link> tags would duplicate (or 404, since CSS chunks aren't pre-built).\n if (!manifest.dev) {\n yield* loadStylesheets(manifest, cache).pipe(wrapCacheError);\n }\n return { plugin, manifest };\n });\n\n/**\n * Preloads previously persisted remote plugins from storage. Per-entry failures\n * are logged and swallowed — the returned effect always succeeds with whichever\n * plugins loaded cleanly, so a single bad entry can't block the host's startup.\n */\nexport const preload = (options: PreloadOptions = {}): Effect.Effect<Plugin.Plugin[], never> =>\n Effect.gen(function* () {\n const storage = options.storage ?? defaultStorage();\n const key = options.key ?? DEFAULT_KEY;\n const cache = options.cache ?? PluginAssetCache.noop();\n const onPluginLoaded = options.onPluginLoaded;\n\n const entries = getPersistedRemotePlugins(storage, key);\n if (entries.length === 0) {\n return [];\n }\n log.info('preloading remote plugins', { count: entries.length });\n const total = entries.length;\n let loaded = 0;\n const results = yield* Effect.all(\n entries.map((entry) =>\n loadFromManifest(entry.url, cache).pipe(\n Effect.tapError((error) => Effect.sync(() => log.warn('failed to preload remote plugin', { entry, error }))),\n Effect.option,\n // Tick the progress hook on both success and recoverable failure so\n // the counter monotonically reaches `total`. The host-supplied\n // callback is best-effort: any synchronous throw flows through\n // `Effect.try` and gets logged + ignored so a buggy hook can't\n // derail the preload.\n Effect.tap(() =>\n Effect.sync(() => {\n loaded += 1;\n }).pipe(\n Effect.andThen(Effect.try(() => onPluginLoaded?.(loaded, total))),\n Effect.tapError((error) => Effect.sync(() => log.warn('onPluginLoaded threw', { loaded, total, error }))),\n Effect.ignore,\n ),\n ),\n ),\n ),\n { concurrency: 'unbounded' },\n );\n return results.flatMap((result) =>\n Option.match(result, {\n onNone: () => [],\n onSome: ({ plugin }) => [plugin],\n }),\n );\n });\n\n/**\n * Creates a plugin loader that resolves built-in plugins by ID or loads remote plugins from URLs.\n *\n * Remote URLs must point at a plugin manifest (`plugin.json`). The loader fetches the manifest,\n * eagerly persists every declared asset via the configured `PluginAssetCache`, then dynamic-imports\n * the entry module.\n */\nexport const make = (builtinPlugins: Plugin.Plugin[], options: Options = {}) => {\n const storage = options.storage ?? defaultStorage();\n const key = options.key ?? DEFAULT_KEY;\n const cache = options.cache ?? PluginAssetCache.noop();\n\n return (locator: string): Effect.Effect<{ plugin: Plugin.Plugin; dev?: boolean }, RemotePluginLoadError> =>\n Effect.gen(function* () {\n const builtin = builtinPlugins.find((plugin) => plugin.meta.id === locator);\n if (builtin) {\n return { plugin: builtin };\n }\n if (!isUrl(locator)) {\n return yield* Effect.fail(new RemotePluginLoadError({ context: { locator, reason: 'invalid-locator' } }));\n }\n const { plugin, manifest } = yield* loadFromManifest(locator, cache);\n // Production manifests can't collide with a builtin id — that would make\n // the registered plugin permanently inaccessible. Dev manifests are\n // allowed to collide because the manager shadow primitive handles the\n // overlap (dev plugin takes the id slot for the session, original is\n // restored on uninstall or page reload).\n if (!manifest.dev) {\n const duplicate = builtinPlugins.find((existing) => existing.meta.id === plugin.meta.id);\n if (duplicate) {\n return yield* Effect.fail(\n new RemotePluginLoadError({ context: { locator, reason: 'duplicate-id', id: plugin.meta.id } }),\n );\n }\n persistRemotePlugin(storage, key, { id: plugin.meta.id, url: locator });\n }\n return { plugin, dev: manifest.dev };\n });\n};\n\n/**\n * Removes a previously installed remote plugin: drops the persisted entry, evicts cached\n * assets, and removes any stylesheet `<link>` tags that {@link loadFromManifest} appended.\n *\n * Cache eviction failures are logged and swallowed — the persisted entry has already been\n * dropped so the user-visible state is consistent regardless of whether the platform\n * cache cooperated.\n */\nexport const uninstall = (pluginId: string, options: Options = {}): Effect.Effect<void, never> =>\n Effect.gen(function* () {\n const storage = options.storage ?? defaultStorage();\n const key = options.key ?? DEFAULT_KEY;\n const cache = options.cache ?? PluginAssetCache.noop();\n\n removePersistedRemotePlugin(storage, key, pluginId);\n if (typeof document !== 'undefined') {\n document.querySelectorAll(`link[data-dxos-plugin-id=\"${pluginId}\"]`).forEach((node) => node.remove());\n }\n yield* cache.evict(pluginId).pipe(\n Effect.tapError((error) => Effect.sync(() => log.warn('failed to evict plugin assets', { pluginId, error }))),\n Effect.ignore,\n );\n });\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { BaseError } from '@dxos/errors';\n\n/**\n * Tagged error for cache operations. Construction sites supply `context.operation`\n * (one of `'cache' | 'evict' | 'resolve' | 'list'`) and `context.pluginId` so\n * downstream handlers can route on the failed call without scanning the message.\n */\nexport class PluginAssetCacheError extends BaseError.extend(\n 'PluginAssetCacheError',\n 'Plugin asset cache operation failed',\n) {}\n\n/**\n * Per-platform offline cache for third-party plugin assets.\n *\n * Implementations live alongside their platform glue (composer-app's\n * `asset-cache/{tauri,service-worker}.ts`); the no-op default is for tests\n * and unsupported environments.\n */\nexport interface Cache {\n /**\n * Persist all listed URLs under the namespace of `pluginId`. Idempotent.\n * The order of `urls` is significant — the first entry is treated as the entry module.\n */\n cache(pluginId: string, urls: readonly string[]): Effect.Effect<void, PluginAssetCacheError>;\n\n /**\n * Drop all assets for a plugin (uninstall).\n */\n evict(pluginId: string): Effect.Effect<void, PluginAssetCacheError>;\n\n /**\n * Resolves a plugin asset URL to a platform-specific cached URL when one is available.\n * Returns the original URL when no cached copy exists or the platform serves cached\n * responses transparently (e.g. service worker fetch interception on web).\n */\n resolve(pluginId: string, url: string): Effect.Effect<string, PluginAssetCacheError>;\n\n /**\n * List currently cached plugin ids (diagnostic).\n */\n list(): Effect.Effect<readonly string[], PluginAssetCacheError>;\n}\n\n/**\n * No-op implementation. Used when no platform cache is registered (tests, unsupported environments).\n * Plugins still load — they just have no offline guarantee.\n */\nexport const noop = (): Cache => ({\n cache: () => Effect.void,\n evict: () => Effect.void,\n resolve: (_pluginId, url) => Effect.succeed(url),\n list: () => Effect.succeed([] as readonly string[]),\n});\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as FetchHttpClient from '@effect/platform/FetchHttpClient';\nimport * as HttpClient from '@effect/platform/HttpClient';\nimport * as HttpClientRequest from '@effect/platform/HttpClientRequest';\nimport * as HttpClientResponse from '@effect/platform/HttpClientResponse';\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { BaseError } from '@dxos/errors';\nimport { PLUGIN_ENTRY_FILENAME } from '@dxos/protocols';\n\n/**\n * Default port the Vite plugin (`composerPlugin`) binds the dev server to.\n *\n * Shared single source of truth — `composerPlugin` reads it as the default\n * port, and the host's \"Load Dev Plugin\" affordance pre-fills the manifest URL\n * with `http://localhost:${PLUGIN_DEV_SERVER_PORT}/manifest.json`. Lives in\n * app-framework rather than `@dxos/protocols` because the constant is a\n * client-side convention (host loader + Vite plugin) rather than a wire-level\n * protocol.\n */\nexport const PLUGIN_DEV_SERVER_PORT = 3967;\n\n/**\n * Tagged error for manifest fetch / parse failures. Construction sites set\n * `context.manifestUrl` and `context.reason` (one of `'fetch-failed' |\n * 'http-error' | 'parse-failed' | 'invalid'`) so handlers can route on the\n * specific failure mode.\n */\nexport class PluginManifestError extends BaseError.extend('PluginManifestError', 'Plugin manifest is invalid') {}\n\n/**\n * Schema for a third-party plugin manifest.\n *\n * Production manifests are published as a sibling of the plugin's entry module\n * ({@link PLUGIN_ENTRY_FILENAME}) and advertise every file the plugin needs at\n * runtime so the host can eagerly cache them for offline use.\n *\n * Dev manifests (served by `vite dev` via {@link composerPlugin}) set `devEntry`\n * to point at the unbundled source entry. The host's loader treats the presence\n * of `devEntry` as the dev-mode signal: it imports the entry directly from the\n * dev server, skips eager asset caching, and skips static stylesheet injection\n * (Vite handles CSS via runtime `<style>` injection during HMR). `assets` is not\n * required to enumerate every file in dev mode — chunks and styles flow through\n * the dev server on demand.\n */\nexport const Manifest = Schema.Struct({\n id: Schema.String,\n name: Schema.String,\n version: Schema.String,\n assets: Schema.Array(Schema.String),\n devEntry: Schema.String.pipe(Schema.optional),\n});\n\nexport type Manifest = Schema.Schema.Type<typeof Manifest>;\n\n/**\n * Resolved manifest with all asset paths converted to absolute URLs.\n *\n * `dev` reflects whether the source manifest declared a `devEntry`. Loaders branch\n * on this to skip offline caching and stylesheet injection — both are no-ops (or\n * actively wrong) when the plugin is being served by a Vite dev server.\n */\nexport type ResolvedManifest = {\n id: string;\n name: string;\n version: string;\n entryUrl: string;\n assetUrls: readonly string[];\n dev: boolean;\n};\n\n/**\n * Resolves a parsed manifest's relative asset paths against the manifest's URL.\n * In dev mode the entry comes from `devEntry`; otherwise it's the canonical\n * {@link PLUGIN_ENTRY_FILENAME} sitting next to the manifest.\n */\nconst resolve = (manifestUrl: string, manifest: Manifest): ResolvedManifest => {\n const dev = manifest.devEntry !== undefined;\n return {\n id: manifest.id,\n name: manifest.name,\n version: manifest.version,\n entryUrl: new URL(dev ? manifest.devEntry! : PLUGIN_ENTRY_FILENAME, manifestUrl).toString(),\n assetUrls: manifest.assets.map((asset) => new URL(asset, manifestUrl).toString()),\n dev,\n };\n};\n\n/**\n * Synchronous decode + validate + resolve for an in-memory manifest payload. Used\n * by tests and tooling that have the manifest body already loaded; the runtime\n * path goes through {@link fetchManifest}.\n */\nexport const parse = (manifestUrl: string, payload: unknown): ResolvedManifest => {\n const manifest = Schema.decodeUnknownSync(Manifest)(payload);\n if (manifest.devEntry === undefined && !manifest.assets.includes(PLUGIN_ENTRY_FILENAME)) {\n throw new Error(`Manifest at ${manifestUrl} does not list ${PLUGIN_ENTRY_FILENAME} in assets.`);\n }\n return resolve(manifestUrl, manifest);\n};\n\n/**\n * Fetches and parses a manifest from the given URL via Effect's HTTP client and\n * Schema-driven JSON decoding. All failure modes surface as a single tagged\n * {@link PluginManifestError}; callers route on `error.context.reason`.\n */\nexport const fetchManifest = (manifestUrl: string): Effect.Effect<ResolvedManifest, PluginManifestError> =>\n Effect.gen(function* () {\n const response = yield* HttpClientRequest.get(manifestUrl).pipe(\n HttpClient.execute,\n Effect.mapError((cause) => new PluginManifestError({ context: { manifestUrl, reason: 'fetch-failed' }, cause })),\n );\n if (response.status >= 400) {\n return yield* Effect.fail(\n new PluginManifestError({ context: { manifestUrl, reason: 'http-error', status: response.status } }),\n );\n }\n const manifest = yield* HttpClientResponse.schemaBodyJson(Manifest)(response).pipe(\n Effect.mapError((cause) => new PluginManifestError({ context: { manifestUrl, reason: 'parse-failed' }, cause })),\n );\n if (manifest.devEntry === undefined && !manifest.assets.includes(PLUGIN_ENTRY_FILENAME)) {\n return yield* Effect.fail(\n new PluginManifestError({\n context: { manifestUrl, reason: 'invalid' },\n cause: `assets does not include ${PLUGIN_ENTRY_FILENAME}`,\n }),\n );\n }\n return resolve(manifestUrl, manifest);\n }).pipe(Effect.scoped, Effect.provide(FetchHttpClient.layer));\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAAA;;;;;;;;;;;AAIA,YAAYA,aAAY;AACxB,YAAYC,YAAY;AAExB,SAASC,aAAAA,kBAAiB;AAC1B,SAASC,WAAW;;;ACRpB;;;;;AAIA,YAAYC,YAAY;AAExB,SAASC,iBAAiB;AAOnB,IAAMC,wBAAN,cAAoCD,UAAUE,OACnD,yBACA,qCAAA,EAAA;AACC;AAsCI,IAAMC,OAAO,OAAc;EAChCC,OAAO,MAAaC;EACpBC,OAAO,MAAaD;EACpBE,SAAS,CAACC,WAAWC,QAAeC,eAAQD,GAAAA;EAC5CE,MAAM,MAAaD,eAAQ,CAAA,CAAE;AAC/B;;;AC3DA;;;;;;;;AAIA,YAAYE,qBAAqB;AACjC,YAAYC,gBAAgB;AAC5B,YAAYC,uBAAuB;AACnC,YAAYC,wBAAwB;AACpC,YAAYC,aAAY;AACxB,YAAYC,YAAY;AAExB,SAASC,aAAAA,kBAAiB;AAC1B,SAASC,6BAA6B;AAY/B,IAAMC,yBAAyB;AAQ/B,IAAMC,sBAAN,cAAkCH,WAAUI,OAAO,uBAAuB,4BAAA,EAAA;AAA+B;AAiBzG,IAAMC,WAAkBC,cAAO;EACpCC,IAAWC;EACXC,MAAaD;EACbE,SAAgBF;EAChBG,QAAeC,aAAaJ,aAAM;EAClCK,UAAiBL,cAAOM,KAAYC,eAAQ;AAC9C,CAAA;AAyBA,IAAMC,UAAU,CAACC,aAAqBC,aAAAA;AACpC,QAAMC,MAAMD,SAASL,aAAaO;AAClC,SAAO;IACLb,IAAIW,SAASX;IACbE,MAAMS,SAAST;IACfC,SAASQ,SAASR;IAClBW,UAAU,IAAIC,IAAIH,MAAMD,SAASL,WAAYZ,uBAAuBgB,WAAAA,EAAaM,SAAQ;IACzFC,WAAWN,SAASP,OAAOc,IAAI,CAACC,UAAU,IA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AASwB;YAAwBnB;YAAmB,QAAA;YAAE,IAAA,OAAA,KAAA;UAEjG;QACA8C,CAAAA,CAAAA;;0BAA6DnD,SAAAA,KAAAA;QAAQ,IAAA,OAAA,KAAA;QACvE,KAAA;MACA,CAAA;;WAAiBoD;MAAkB;MACrC,KAAA,SAAA;IACF;EAEF,CAAA;;AAWI,IAAM/D,YAAcA,CAAAA,UAAOP,UAAAA,CAAAA,MAAAA,YAAAA,aAAAA;AAC3B,QAAM8C,UAAQ3B,QAAQ2B,WAASQ,eAAiBC;AAEhDgB,QAAAA,MAAAA,QAAAA,OAAAA;AACA,QAAI,QAAOtC,QAAAA,SAA0B,KAAA;8BAC1BuC,SAAkB,KAAA,QAAA;AAC7B,MAAA,OAAA,aAAA,aAAA;AACA,aAAaC,iBAAgBb,6BACAE,QAAOY,IAAK,EAAA,QAAUC,CAAAA,SAAK,KAAA,OAAA,CAAA;;eAA6ChE,MAAAA,QAAAA,EAAAA,KAAAA,iBAAAA,CAAAA,UAAAA,aAAAA,MAAAA,IAAAA,KAAAA,iCAAAA;IAAM;IAG1G;;;",
|
|
6
|
+
"names": ["Effect", "Option", "BaseError", "log", "Effect", "BaseError", "PluginAssetCacheError", "extend", "noop", "cache", "void", "evict", "resolve", "_pluginId", "url", "succeed", "list", "FetchHttpClient", "HttpClient", "HttpClientRequest", "HttpClientResponse", "Effect", "Schema", "BaseError", "PLUGIN_ENTRY_FILENAME", "PLUGIN_DEV_SERVER_PORT", "PluginManifestError", "extend", "Manifest", "Struct", "id", "String", "name", "version", "assets", "Array", "devEntry", "pipe", "optional", "resolve", "manifestUrl", "manifest", "dev", "undefined", "entryUrl", "URL", "toString", "assetUrls", "map", "asset", "parse", "payload", "decodeUnknownSync", "includes", "Error", "fetchManifest", "gen", "response", "get", "execute", "mapError", "cause", "context", "reason", "status", "fail", "schemaBodyJson", "scoped", "provide", "layer", "DEFAULT_KEY", "defaultStorage", "BaseError", "value", "localStorage", "getPersistedRemotePlugins", "storage", "key", "get", "parsed", "entries", "error", "log", "entry", "pluginId", "url", "URL", "hostname", "locator", "options", "index", "findIndex", "version", "id", "find", "normalizePluginExport", "mod", "exported", "Plugin", "result", "resolved", "resolve", "manifest", "document", "querySelector", "link", "href", "dataset", "head", "loadFromManifest", "manifestUrl", "context", "reason", "cause", "wrapCacheError", "assetUrls", "cache", "entryUrl", "try", "catch", "RemotePluginLoadError", "plugin", "metaId", "manifestId", "PluginAssetCache", "noop", "onPluginLoaded", "info", "total", "results", "pipe", "andThen", "Effect", "loaded", "flatMap", "onSome", "gen", "builtin", "duplicate", "persistRemotePlugin", "dev", "removePersistedRemotePlugin", "querySelectorAll", "evict", "sync", "warn"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
import {
|
|
2
|
+
capabilities_exports
|
|
3
|
+
} from "./chunk-5AHASNDW.mjs";
|
|
4
|
+
|
|
5
|
+
// src/helpers.ts
|
|
6
|
+
var topologicalSort = (nodes) => {
|
|
7
|
+
const getDependencies = (nodeId, seen = /* @__PURE__ */ new Set(), path = /* @__PURE__ */ new Set()) => {
|
|
8
|
+
if (path.has(nodeId)) {
|
|
9
|
+
throw new Error(`Circular dependency detected involving ${nodeId}`);
|
|
10
|
+
}
|
|
11
|
+
if (seen.has(nodeId)) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
const node = nodes.find((n) => n.id === nodeId);
|
|
15
|
+
if (!node) {
|
|
16
|
+
throw new Error(`Node ${nodeId} not found but is listed as a dependency`);
|
|
17
|
+
}
|
|
18
|
+
const newPath = /* @__PURE__ */ new Set([
|
|
19
|
+
...path,
|
|
20
|
+
nodeId
|
|
21
|
+
]);
|
|
22
|
+
const newSeen = /* @__PURE__ */ new Set([
|
|
23
|
+
...seen,
|
|
24
|
+
nodeId
|
|
25
|
+
]);
|
|
26
|
+
const dependsOn = node.dependsOn ?? [];
|
|
27
|
+
return [
|
|
28
|
+
...dependsOn.flatMap((depId) => getDependencies(depId, newSeen, newPath)),
|
|
29
|
+
nodeId
|
|
30
|
+
];
|
|
31
|
+
};
|
|
32
|
+
const allDependencies = nodes.map((node) => node.id).flatMap((id) => getDependencies(id)).filter((id, index, self) => self.indexOf(id) === index);
|
|
33
|
+
return allDependencies.map((id) => nodes.find((node) => node.id === id)).filter((node) => node !== void 0);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// src/ui/hooks/useSurface.ts
|
|
37
|
+
import { useContext as useContext3 } from "react";
|
|
38
|
+
import { raise as raise2 } from "@dxos/debug";
|
|
39
|
+
|
|
40
|
+
// src/ui/components/PluginManager/PluginManagerProvider.ts
|
|
41
|
+
import { createContext, useContext } from "react";
|
|
42
|
+
import { raise } from "@dxos/debug";
|
|
43
|
+
var PluginManagerContext = createContext(void 0);
|
|
44
|
+
var usePluginManager = () => useContext(PluginManagerContext) ?? raise(new Error("Missing PluginManagerContext"));
|
|
45
|
+
var PluginManagerProvider = PluginManagerContext.Provider;
|
|
46
|
+
|
|
47
|
+
// src/ui/components/Surface/context.ts
|
|
48
|
+
import { createContext as createContext2 } from "react";
|
|
49
|
+
var SurfaceContext = createContext2(void 0);
|
|
50
|
+
|
|
51
|
+
// src/ui/components/Surface/SurfaceComponent.tsx
|
|
52
|
+
import { useAtomValue } from "@effect-atom/atom-react";
|
|
53
|
+
import React3, { Fragment, Profiler, Suspense, forwardRef as forwardRef2, memo, useEffect, useMemo as useMemo2, useRef as useRef2 } from "react";
|
|
54
|
+
import { log } from "@dxos/log";
|
|
55
|
+
import { ErrorBoundary } from "@dxos/react-error-boundary";
|
|
56
|
+
import { useDefaultValue } from "@dxos/react-hooks";
|
|
57
|
+
import { byPosition } from "@dxos/util";
|
|
58
|
+
|
|
59
|
+
// src/ui/components/Surface/SurfaceInfo.tsx
|
|
60
|
+
import React, { cloneElement, forwardRef, useCallback, useLayoutEffect, useState } from "react";
|
|
61
|
+
import { createPortal } from "react-dom";
|
|
62
|
+
import { addEventListener, combine } from "@dxos/async";
|
|
63
|
+
import { useMergeRefs } from "@dxos/react-hooks";
|
|
64
|
+
var SurfaceInfo = /* @__PURE__ */ forwardRef(({ children }, forwardedRef) => {
|
|
65
|
+
const [rect, setRect] = useState(null);
|
|
66
|
+
const [expand, setExpand] = useState(false);
|
|
67
|
+
const info = useSurface();
|
|
68
|
+
const [root, setRoot] = useState(null);
|
|
69
|
+
const measureRef = useCallback((node) => setRoot(node), []);
|
|
70
|
+
const mergedRef = useMergeRefs([
|
|
71
|
+
measureRef,
|
|
72
|
+
forwardedRef
|
|
73
|
+
]);
|
|
74
|
+
const childWithRef = /* @__PURE__ */ cloneElement(children, {
|
|
75
|
+
ref: mergedRef
|
|
76
|
+
});
|
|
77
|
+
useLayoutEffect(() => {
|
|
78
|
+
if (!root) {
|
|
79
|
+
setRect(null);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const measure = () => {
|
|
83
|
+
setRect(root.getBoundingClientRect());
|
|
84
|
+
};
|
|
85
|
+
const observer = new ResizeObserver(measure);
|
|
86
|
+
observer.observe(root);
|
|
87
|
+
measure();
|
|
88
|
+
return combine(addEventListener(window, "scroll", measure, true), addEventListener(window, "resize", measure), () => {
|
|
89
|
+
observer.disconnect();
|
|
90
|
+
});
|
|
91
|
+
}, [
|
|
92
|
+
root
|
|
93
|
+
]);
|
|
94
|
+
const padding = 0;
|
|
95
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, childWithRef, rect && /* @__PURE__ */ createPortal(
|
|
96
|
+
/* @__PURE__ */ React.createElement("div", {
|
|
97
|
+
className: "z-[100] fixed flex flex-col-reverse scrollbar-none overflow-auto pointer-events-none",
|
|
98
|
+
style: {
|
|
99
|
+
top: rect.top + padding,
|
|
100
|
+
left: rect.left + padding,
|
|
101
|
+
width: rect.width - padding * 2,
|
|
102
|
+
height: rect.height - padding * 2
|
|
103
|
+
}
|
|
104
|
+
}, expand ? /* @__PURE__ */ React.createElement("div", {
|
|
105
|
+
className: "absolute inset-0 bg-deck-surface border border-green-500 cursor-pointer pointer-events-auto overflow-auto",
|
|
106
|
+
onPointerDown: (ev) => ev.stopPropagation(),
|
|
107
|
+
onClick: (ev) => {
|
|
108
|
+
ev.stopPropagation();
|
|
109
|
+
setExpand(false);
|
|
110
|
+
}
|
|
111
|
+
}, /* @__PURE__ */ React.createElement("pre", {
|
|
112
|
+
className: "p-2 text-xs text-description font-mono"
|
|
113
|
+
}, JSON.stringify({
|
|
114
|
+
info
|
|
115
|
+
}, null, 2))) : /* @__PURE__ */ React.createElement("span", {
|
|
116
|
+
className: "absolute right-1 bottom-0 flex items-center p-1 text-green-500 opacity-80 hover:opacity-100 text-xl cursor-pointer pointer-events-auto",
|
|
117
|
+
title: info.id,
|
|
118
|
+
onPointerDown: (ev) => ev.stopPropagation(),
|
|
119
|
+
onClick: (ev) => {
|
|
120
|
+
ev.stopPropagation();
|
|
121
|
+
setExpand(true);
|
|
122
|
+
}
|
|
123
|
+
}, "\u24D8")),
|
|
124
|
+
// TODO(burdon): Create well-known element to gather all debug portals.
|
|
125
|
+
document.body
|
|
126
|
+
));
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// src/ui/components/Surface/SurfaceProfilerContext.tsx
|
|
130
|
+
import React2, { createContext as createContext3, useContext as useContext2, useMemo, useRef, useSyncExternalStore } from "react";
|
|
131
|
+
var MAX_ENTRIES = 500;
|
|
132
|
+
var SurfaceProfilerStore = class {
|
|
133
|
+
_entries = [];
|
|
134
|
+
_listeners = /* @__PURE__ */ new Set();
|
|
135
|
+
_snapshot = [];
|
|
136
|
+
_pendingNotify = false;
|
|
137
|
+
/** Records an entry and schedules a deferred notification to avoid re-render loops. */
|
|
138
|
+
record(entry) {
|
|
139
|
+
this._entries.push(entry);
|
|
140
|
+
if (this._entries.length > MAX_ENTRIES) {
|
|
141
|
+
this._entries = this._entries.slice(-MAX_ENTRIES);
|
|
142
|
+
}
|
|
143
|
+
this._snapshot = [
|
|
144
|
+
...this._entries
|
|
145
|
+
];
|
|
146
|
+
this._scheduleNotify();
|
|
147
|
+
}
|
|
148
|
+
clear() {
|
|
149
|
+
this._entries = [];
|
|
150
|
+
this._snapshot = [];
|
|
151
|
+
this._notifySync();
|
|
152
|
+
}
|
|
153
|
+
subscribe = (listener) => {
|
|
154
|
+
this._listeners.add(listener);
|
|
155
|
+
return () => {
|
|
156
|
+
this._listeners.delete(listener);
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
getSnapshot = () => {
|
|
160
|
+
return this._snapshot;
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Defers notification to the next animation frame to break the
|
|
164
|
+
* Profiler onRender → record → notify → re-render → onRender loop.
|
|
165
|
+
*/
|
|
166
|
+
_scheduleNotify() {
|
|
167
|
+
if (!this._pendingNotify) {
|
|
168
|
+
this._pendingNotify = true;
|
|
169
|
+
requestAnimationFrame(() => {
|
|
170
|
+
this._pendingNotify = false;
|
|
171
|
+
this._notifySync();
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
_notifySync() {
|
|
176
|
+
for (const listener of this._listeners) {
|
|
177
|
+
listener();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
var SurfaceProfilerContext = /* @__PURE__ */ createContext3(void 0);
|
|
182
|
+
var SurfaceProfilerProvider = ({ children }) => {
|
|
183
|
+
const storeRef = useRef(null);
|
|
184
|
+
if (!storeRef.current) {
|
|
185
|
+
storeRef.current = new SurfaceProfilerStore();
|
|
186
|
+
}
|
|
187
|
+
return /* @__PURE__ */ React2.createElement(SurfaceProfilerContext.Provider, {
|
|
188
|
+
value: {
|
|
189
|
+
store: storeRef.current
|
|
190
|
+
}
|
|
191
|
+
}, children);
|
|
192
|
+
};
|
|
193
|
+
var useSurfaceProfilerCallback = () => {
|
|
194
|
+
const store = useContext2(SurfaceProfilerContext)?.store;
|
|
195
|
+
return useMemo(() => {
|
|
196
|
+
if (!store) {
|
|
197
|
+
return void 0;
|
|
198
|
+
}
|
|
199
|
+
return (id, phase, actualDuration, baseDuration, startTime, commitTime) => {
|
|
200
|
+
store.record({
|
|
201
|
+
id,
|
|
202
|
+
phase,
|
|
203
|
+
actualDuration,
|
|
204
|
+
baseDuration,
|
|
205
|
+
startTime,
|
|
206
|
+
commitTime,
|
|
207
|
+
timestamp: Date.now()
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
}, [
|
|
211
|
+
store
|
|
212
|
+
]);
|
|
213
|
+
};
|
|
214
|
+
var useSurfaceProfilerEntries = () => {
|
|
215
|
+
const context = useContext2(SurfaceProfilerContext);
|
|
216
|
+
return useSyncExternalStore(context?.store.subscribe ?? noop, context?.store.getSnapshot ?? emptySnapshot);
|
|
217
|
+
};
|
|
218
|
+
var useSurfaceProfilerStats = () => {
|
|
219
|
+
const entries = useSurfaceProfilerEntries();
|
|
220
|
+
const statsMap = /* @__PURE__ */ new Map();
|
|
221
|
+
for (const entry of entries) {
|
|
222
|
+
let stats = statsMap.get(entry.id);
|
|
223
|
+
if (!stats) {
|
|
224
|
+
stats = {
|
|
225
|
+
id: entry.id,
|
|
226
|
+
mountCount: 0,
|
|
227
|
+
updateCount: 0,
|
|
228
|
+
totalRenders: 0,
|
|
229
|
+
avgActualDuration: 0,
|
|
230
|
+
maxActualDuration: 0,
|
|
231
|
+
avgBaseDuration: 0,
|
|
232
|
+
lastActualDuration: 0,
|
|
233
|
+
lastCommitTime: 0
|
|
234
|
+
};
|
|
235
|
+
statsMap.set(entry.id, stats);
|
|
236
|
+
}
|
|
237
|
+
if (entry.phase === "mount") {
|
|
238
|
+
stats.mountCount++;
|
|
239
|
+
} else {
|
|
240
|
+
stats.updateCount++;
|
|
241
|
+
}
|
|
242
|
+
stats.totalRenders++;
|
|
243
|
+
stats.avgActualDuration = (stats.avgActualDuration * (stats.totalRenders - 1) + entry.actualDuration) / stats.totalRenders;
|
|
244
|
+
stats.avgBaseDuration = (stats.avgBaseDuration * (stats.totalRenders - 1) + entry.baseDuration) / stats.totalRenders;
|
|
245
|
+
stats.maxActualDuration = Math.max(stats.maxActualDuration, entry.actualDuration);
|
|
246
|
+
stats.lastActualDuration = entry.actualDuration;
|
|
247
|
+
stats.lastCommitTime = entry.commitTime;
|
|
248
|
+
}
|
|
249
|
+
return [
|
|
250
|
+
...statsMap.values()
|
|
251
|
+
].sort((a, b) => b.maxActualDuration - a.maxActualDuration);
|
|
252
|
+
};
|
|
253
|
+
var useSurfaceProfilerClear = () => {
|
|
254
|
+
const store = useContext2(SurfaceProfilerContext)?.store;
|
|
255
|
+
return useMemo(() => store ? () => store.clear() : void 0, [
|
|
256
|
+
store
|
|
257
|
+
]);
|
|
258
|
+
};
|
|
259
|
+
var noop = () => () => {
|
|
260
|
+
};
|
|
261
|
+
var EMPTY_SNAPSHOT = [];
|
|
262
|
+
var emptySnapshot = () => EMPTY_SNAPSHOT;
|
|
263
|
+
|
|
264
|
+
// src/ui/components/Surface/SurfaceComponent.tsx
|
|
265
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/ui/components/Surface/SurfaceComponent.tsx";
|
|
266
|
+
var DEBUG = import.meta.env.VITE_DEBUG;
|
|
267
|
+
var DEFAULT_PLACEHOLDER = /* @__PURE__ */ React3.createElement(Fragment, null);
|
|
268
|
+
var WebComponentWrapper = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ id, role, data, limit, definition, ...rest }, forwardedRef) => {
|
|
269
|
+
const containerRef = useRef2(null);
|
|
270
|
+
const elementRef = useRef2(null);
|
|
271
|
+
const propsRef = useRef2({
|
|
272
|
+
id,
|
|
273
|
+
role,
|
|
274
|
+
data,
|
|
275
|
+
limit,
|
|
276
|
+
...rest
|
|
277
|
+
});
|
|
278
|
+
propsRef.current = {
|
|
279
|
+
id,
|
|
280
|
+
role,
|
|
281
|
+
data,
|
|
282
|
+
limit,
|
|
283
|
+
...rest
|
|
284
|
+
};
|
|
285
|
+
useEffect(() => {
|
|
286
|
+
if (!containerRef.current || elementRef.current) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const element = document.createElement(definition.tagName);
|
|
290
|
+
elementRef.current = element;
|
|
291
|
+
Object.assign(element, propsRef.current);
|
|
292
|
+
containerRef.current.appendChild(element);
|
|
293
|
+
if (typeof forwardedRef === "function") {
|
|
294
|
+
forwardedRef(element);
|
|
295
|
+
} else if (forwardedRef) {
|
|
296
|
+
forwardedRef.current = element;
|
|
297
|
+
}
|
|
298
|
+
return () => {
|
|
299
|
+
if (elementRef.current && containerRef.current?.contains(elementRef.current)) {
|
|
300
|
+
containerRef.current.removeChild(elementRef.current);
|
|
301
|
+
}
|
|
302
|
+
if (typeof forwardedRef === "function") {
|
|
303
|
+
forwardedRef(null);
|
|
304
|
+
} else if (forwardedRef) {
|
|
305
|
+
forwardedRef.current = null;
|
|
306
|
+
}
|
|
307
|
+
elementRef.current = null;
|
|
308
|
+
};
|
|
309
|
+
}, [
|
|
310
|
+
definition.tagName,
|
|
311
|
+
forwardedRef
|
|
312
|
+
]);
|
|
313
|
+
useEffect(() => {
|
|
314
|
+
const element = elementRef.current;
|
|
315
|
+
if (!element) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
Object.assign(element, propsRef.current);
|
|
319
|
+
});
|
|
320
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
321
|
+
ref: containerRef
|
|
322
|
+
});
|
|
323
|
+
}));
|
|
324
|
+
WebComponentWrapper.displayName = "WebComponentWrapper";
|
|
325
|
+
var SurfaceContextProvider = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ id, role, data, limit, fallback = ErrorFallback, definition, ...rest }, forwardedRef) => {
|
|
326
|
+
const contextValue = useMemo2(() => ({
|
|
327
|
+
id,
|
|
328
|
+
role,
|
|
329
|
+
data
|
|
330
|
+
}), [
|
|
331
|
+
id,
|
|
332
|
+
role,
|
|
333
|
+
data
|
|
334
|
+
]);
|
|
335
|
+
const onProfilerRender = useSurfaceProfilerCallback();
|
|
336
|
+
const profilerId = `surface/${id}/${role}`;
|
|
337
|
+
if (definition.kind === "web-component") {
|
|
338
|
+
return /* @__PURE__ */ React3.createElement(ErrorBoundary, {
|
|
339
|
+
name: "surface",
|
|
340
|
+
resetKeys: [
|
|
341
|
+
data
|
|
342
|
+
],
|
|
343
|
+
FallbackComponent: fallback
|
|
344
|
+
}, /* @__PURE__ */ React3.createElement(SurfaceContext.Provider, {
|
|
345
|
+
value: contextValue
|
|
346
|
+
}, /* @__PURE__ */ React3.createElement(WebComponentWrapper, {
|
|
347
|
+
id,
|
|
348
|
+
role,
|
|
349
|
+
data,
|
|
350
|
+
limit,
|
|
351
|
+
definition,
|
|
352
|
+
ref: forwardedRef,
|
|
353
|
+
...rest
|
|
354
|
+
})));
|
|
355
|
+
}
|
|
356
|
+
const Component = definition.component;
|
|
357
|
+
const debug = DEBUG || "__DX_DEBUG__" in window;
|
|
358
|
+
if (debug) {
|
|
359
|
+
return /* @__PURE__ */ React3.createElement(ErrorBoundary, {
|
|
360
|
+
name: "surface",
|
|
361
|
+
resetKeys: [
|
|
362
|
+
data
|
|
363
|
+
],
|
|
364
|
+
FallbackComponent: fallback
|
|
365
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
366
|
+
className: "contents",
|
|
367
|
+
"data-id": id,
|
|
368
|
+
"data-role": role
|
|
369
|
+
}, /* @__PURE__ */ React3.createElement(SurfaceContext.Provider, {
|
|
370
|
+
value: contextValue
|
|
371
|
+
}, /* @__PURE__ */ React3.createElement(SurfaceInfo, {
|
|
372
|
+
ref: forwardedRef
|
|
373
|
+
}, onProfilerRender && !profilerId.includes("org.dxos.plugin.debug") ? /* @__PURE__ */ React3.createElement(Profiler, {
|
|
374
|
+
id: profilerId,
|
|
375
|
+
onRender: onProfilerRender
|
|
376
|
+
}, /* @__PURE__ */ React3.createElement(Component, {
|
|
377
|
+
id,
|
|
378
|
+
role,
|
|
379
|
+
data,
|
|
380
|
+
limit,
|
|
381
|
+
...rest
|
|
382
|
+
})) : /* @__PURE__ */ React3.createElement(Component, {
|
|
383
|
+
id,
|
|
384
|
+
role,
|
|
385
|
+
data,
|
|
386
|
+
limit,
|
|
387
|
+
...rest
|
|
388
|
+
})))));
|
|
389
|
+
}
|
|
390
|
+
return /* @__PURE__ */ React3.createElement(ErrorBoundary, {
|
|
391
|
+
name: "surface",
|
|
392
|
+
resetKeys: [
|
|
393
|
+
data
|
|
394
|
+
],
|
|
395
|
+
FallbackComponent: fallback
|
|
396
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
397
|
+
className: "contents",
|
|
398
|
+
"data-id": id,
|
|
399
|
+
"data-role": role
|
|
400
|
+
}, /* @__PURE__ */ React3.createElement(SurfaceContext.Provider, {
|
|
401
|
+
value: contextValue
|
|
402
|
+
}, /* @__PURE__ */ React3.createElement(Component, {
|
|
403
|
+
id,
|
|
404
|
+
role,
|
|
405
|
+
data,
|
|
406
|
+
limit,
|
|
407
|
+
...rest,
|
|
408
|
+
ref: forwardedRef
|
|
409
|
+
}))));
|
|
410
|
+
}));
|
|
411
|
+
SurfaceContextProvider.displayName = "SurfaceContextProvider";
|
|
412
|
+
var SurfaceComponent = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ id: _id, role, type, data: dataProp, limit, placeholder = DEFAULT_PLACEHOLDER, ...rest }, forwardedRef) => {
|
|
413
|
+
const data = useDefaultValue(dataProp, () => ({}));
|
|
414
|
+
const surfaces = useSurfaces();
|
|
415
|
+
const effectiveRole = role ?? type?.role;
|
|
416
|
+
if (effectiveRole == null) {
|
|
417
|
+
if (DEBUG) {
|
|
418
|
+
log.warn("Surface has neither `role` nor `type` prop", {
|
|
419
|
+
id: _id
|
|
420
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 194, S: void 0 });
|
|
421
|
+
}
|
|
422
|
+
return null;
|
|
423
|
+
}
|
|
424
|
+
const definitions = findCandidates(surfaces, {
|
|
425
|
+
role: effectiveRole,
|
|
426
|
+
data
|
|
427
|
+
});
|
|
428
|
+
const candidates = limit ? definitions.slice(0, limit) : definitions;
|
|
429
|
+
if (DEBUG && candidates.length === 0) {
|
|
430
|
+
log.warn("no candidates for surface", {
|
|
431
|
+
role: effectiveRole,
|
|
432
|
+
data
|
|
433
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 207, S: void 0 });
|
|
434
|
+
return null;
|
|
435
|
+
}
|
|
436
|
+
return /* @__PURE__ */ React3.createElement(Suspense, {
|
|
437
|
+
fallback: placeholder
|
|
438
|
+
}, candidates.map((definition) => /* @__PURE__ */ React3.createElement(SurfaceContextProvider, {
|
|
439
|
+
key: definition.id,
|
|
440
|
+
id: definition.id,
|
|
441
|
+
role: effectiveRole,
|
|
442
|
+
data,
|
|
443
|
+
limit,
|
|
444
|
+
definition,
|
|
445
|
+
ref: forwardedRef,
|
|
446
|
+
...rest
|
|
447
|
+
})));
|
|
448
|
+
}));
|
|
449
|
+
SurfaceComponent.displayName = "Surface";
|
|
450
|
+
var ErrorFallback = ({ error }) => {
|
|
451
|
+
const { message } = error instanceof Error ? error : {
|
|
452
|
+
message: String(error)
|
|
453
|
+
};
|
|
454
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
455
|
+
role: "alert",
|
|
456
|
+
"data-testid": "error-boundary-fallback"
|
|
457
|
+
}, /* @__PURE__ */ React3.createElement("h1", {
|
|
458
|
+
className: "flex gap-2 text-sm mt-2 text-info-text"
|
|
459
|
+
}, message));
|
|
460
|
+
};
|
|
461
|
+
var findCandidates = (surfaces, { role, data }) => {
|
|
462
|
+
return Object.values(surfaces).filter((definition) => Array.isArray(definition.role) ? definition.role.includes(role) : definition.role === role).filter(({ filter }) => filter ? filter(data ?? {}, role) : true).toSorted(byPosition);
|
|
463
|
+
};
|
|
464
|
+
var useSurfaces = () => {
|
|
465
|
+
const manager = usePluginManager();
|
|
466
|
+
const surfacesByModule = useAtomValue(manager.capabilities.atomByModule(capabilities_exports.ReactSurface));
|
|
467
|
+
return useMemo2(() => {
|
|
468
|
+
const result = [];
|
|
469
|
+
for (const [moduleId, surfaces] of Object.entries(surfacesByModule)) {
|
|
470
|
+
for (const def of surfaces.flat()) {
|
|
471
|
+
result.push({
|
|
472
|
+
...def,
|
|
473
|
+
id: `${moduleId}.${def.id}`
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
return result;
|
|
478
|
+
}, [
|
|
479
|
+
surfacesByModule
|
|
480
|
+
]);
|
|
481
|
+
};
|
|
482
|
+
function isSurfaceAvailable(capabilityManager, { role, type, data }) {
|
|
483
|
+
const effectiveRole = role ?? type?.role;
|
|
484
|
+
if (effectiveRole == null) {
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
487
|
+
const surfaces = capabilityManager.getAll(capabilities_exports.ReactSurface);
|
|
488
|
+
const candidates = findCandidates(surfaces.flat(), {
|
|
489
|
+
role: effectiveRole,
|
|
490
|
+
data
|
|
491
|
+
});
|
|
492
|
+
return candidates.length > 0;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// src/ui/components/Surface/types.ts
|
|
496
|
+
var isSurfaceFilter = (value) => typeof value === "object" && value !== null && Array.isArray(value.bindings);
|
|
497
|
+
var makeType = (role) => ({
|
|
498
|
+
role
|
|
499
|
+
});
|
|
500
|
+
var expandBindings = (filter) => {
|
|
501
|
+
const bindings = filter.bindings;
|
|
502
|
+
const roles = Array.from(new Set(bindings.map((binding) => binding.role)));
|
|
503
|
+
const guard = (data, role) => {
|
|
504
|
+
if (role != null) {
|
|
505
|
+
return bindings.some((entry) => entry.role === role && entry.guard(data));
|
|
506
|
+
}
|
|
507
|
+
return bindings.some((entry) => entry.guard(data));
|
|
508
|
+
};
|
|
509
|
+
return {
|
|
510
|
+
role: roles.length === 1 ? roles[0] : roles,
|
|
511
|
+
guard
|
|
512
|
+
};
|
|
513
|
+
};
|
|
514
|
+
function create(definition) {
|
|
515
|
+
if (isSurfaceFilter(definition.filter)) {
|
|
516
|
+
const { id, filter, component, position } = definition;
|
|
517
|
+
const { role, guard } = expandBindings(filter);
|
|
518
|
+
return {
|
|
519
|
+
kind: "react",
|
|
520
|
+
id,
|
|
521
|
+
role,
|
|
522
|
+
position,
|
|
523
|
+
component,
|
|
524
|
+
filter: guard
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
return {
|
|
528
|
+
...definition,
|
|
529
|
+
kind: "react"
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
function createWeb(definition) {
|
|
533
|
+
if (isSurfaceFilter(definition.filter)) {
|
|
534
|
+
const { id, filter, tagName, position } = definition;
|
|
535
|
+
const { role, guard } = expandBindings(filter);
|
|
536
|
+
return {
|
|
537
|
+
kind: "web-component",
|
|
538
|
+
id,
|
|
539
|
+
role,
|
|
540
|
+
position,
|
|
541
|
+
tagName,
|
|
542
|
+
filter: guard
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
return {
|
|
546
|
+
...definition,
|
|
547
|
+
kind: "web-component"
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
// src/ui/components/Surface/index.ts
|
|
552
|
+
(function(Surface2) {
|
|
553
|
+
Surface2.create = create;
|
|
554
|
+
Surface2.createWeb = createWeb;
|
|
555
|
+
Surface2.Context = SurfaceContext;
|
|
556
|
+
Surface2.Surface = SurfaceComponent;
|
|
557
|
+
Surface2.isAvailable = isSurfaceAvailable;
|
|
558
|
+
Surface2.makeType = makeType;
|
|
559
|
+
Surface2.isFilter = isSurfaceFilter;
|
|
560
|
+
Surface2.ProfilerProvider = SurfaceProfilerProvider;
|
|
561
|
+
Surface2.useProfilerCallback = useSurfaceProfilerCallback;
|
|
562
|
+
Surface2.useProfilerEntries = useSurfaceProfilerEntries;
|
|
563
|
+
Surface2.useProfilerStats = useSurfaceProfilerStats;
|
|
564
|
+
Surface2.useProfilerClear = useSurfaceProfilerClear;
|
|
565
|
+
})(Surface || (Surface = {}));
|
|
566
|
+
var Surface;
|
|
567
|
+
|
|
568
|
+
// src/ui/hooks/useSurface.ts
|
|
569
|
+
var useSurface = () => {
|
|
570
|
+
return useContext3(Surface.Context) ?? raise2(new Error("Missing SurfaceContext"));
|
|
571
|
+
};
|
|
572
|
+
|
|
573
|
+
export {
|
|
574
|
+
topologicalSort,
|
|
575
|
+
useSurface,
|
|
576
|
+
usePluginManager,
|
|
577
|
+
PluginManagerProvider,
|
|
578
|
+
SurfaceComponent,
|
|
579
|
+
Surface
|
|
580
|
+
};
|
|
581
|
+
//# sourceMappingURL=chunk-QLML5QFJ.mjs.map
|