@dxos/app-framework 0.8.4-main.422d1c7879 → 0.8.4-main.4f23b4e393
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{capability-DOMNPRJP.mjs → capability-5RRH3WIB.mjs} +11 -11
- package/dist/lib/browser/capability-5RRH3WIB.mjs.map +7 -0
- package/dist/lib/browser/{capability-KSNT34SN.mjs → capability-LUKGKUQH.mjs} +10 -10
- package/dist/lib/browser/{chunk-T3Y4AEKX.mjs → chunk-23D4SJUE.mjs} +3 -3
- package/dist/lib/browser/{chunk-T3Y4AEKX.mjs.map → chunk-23D4SJUE.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-2CKCJ6PN.mjs → chunk-3JWJXGLK.mjs} +1 -1
- package/dist/lib/browser/{chunk-2CKCJ6PN.mjs.map → chunk-3JWJXGLK.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-I34GF4NG.mjs → chunk-45CHLTBV.mjs} +2 -2
- package/dist/lib/browser/{chunk-QSXYHXCE.mjs → chunk-66IXTIVK.mjs} +1 -1
- package/dist/lib/browser/{chunk-QSXYHXCE.mjs.map → chunk-66IXTIVK.mjs.map} +2 -2
- package/dist/lib/browser/{chunk-QRTB4Q3U.mjs → chunk-7VZJR2OA.mjs} +4 -17
- package/dist/lib/browser/chunk-7VZJR2OA.mjs.map +7 -0
- package/dist/lib/browser/chunk-CZ4BIAHH.mjs +422 -0
- package/dist/lib/browser/chunk-CZ4BIAHH.mjs.map +7 -0
- package/dist/lib/browser/{chunk-TGX63LTL.mjs → chunk-FJ4765WW.mjs} +1 -1
- package/dist/lib/browser/{chunk-TGX63LTL.mjs.map → chunk-FJ4765WW.mjs.map} +2 -2
- package/dist/lib/browser/chunk-FO3IYSLV.mjs +68 -0
- package/dist/lib/browser/chunk-FO3IYSLV.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BMIAYUWT.mjs → chunk-JD3Z5NEF.mjs} +147 -75
- package/dist/lib/browser/chunk-JD3Z5NEF.mjs.map +7 -0
- package/dist/lib/browser/chunk-NBXPP7JR.mjs +1174 -0
- package/dist/lib/browser/chunk-NBXPP7JR.mjs.map +7 -0
- package/dist/lib/browser/{chunk-JKWMHZP6.mjs → chunk-WBHCSOBW.mjs} +2 -2
- package/dist/lib/browser/chunk-WBHCSOBW.mjs.map +7 -0
- package/dist/lib/browser/{chunk-GDWTW4ZW.mjs → chunk-Z55LVAGN.mjs} +76 -11
- package/dist/lib/browser/chunk-Z55LVAGN.mjs.map +7 -0
- package/dist/lib/browser/{chunk-F7FW2RK2.mjs → chunk-ZGJAZSNE.mjs} +7 -32
- package/dist/lib/browser/chunk-ZGJAZSNE.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +14 -28
- package/dist/lib/browser/cli/index.mjs.map +3 -3
- package/dist/lib/browser/common/activation-events.mjs +7 -7
- package/dist/lib/browser/common/capabilities.mjs +7 -7
- package/dist/lib/browser/core/activation-event.mjs +1 -1
- package/dist/lib/browser/core/capability.mjs +1 -1
- package/dist/lib/browser/core/plugin-manager.mjs +8 -4
- package/dist/lib/browser/core/plugin.mjs +10 -2
- package/dist/lib/browser/core/url-loader.mjs +13 -5
- package/dist/lib/browser/index.mjs +34 -17
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{invoker-capability-VCMPQOIA.mjs → invoker-capability-K4GHUFXF.mjs} +12 -11
- package/dist/lib/browser/invoker-capability-K4GHUFXF.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +20 -32
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/testing/react.mjs +11 -11
- package/dist/lib/browser/ui/index.mjs +14 -12
- package/dist/lib/node-esm/{capability-EOQTORML.mjs → capability-FCGZVIEG.mjs} +10 -10
- package/dist/lib/node-esm/{capability-KJTQIWDK.mjs → capability-JOIQ2MQE.mjs} +11 -11
- package/dist/lib/node-esm/capability-JOIQ2MQE.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-FKE4Z3D6.mjs → chunk-37Z53PXZ.mjs} +1 -1
- package/dist/lib/node-esm/{chunk-FKE4Z3D6.mjs.map → chunk-37Z53PXZ.mjs.map} +2 -2
- package/dist/lib/node-esm/{chunk-WZCSOX5Q.mjs → chunk-6XW6LET6.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-URWHJQT2.mjs → chunk-D347W3KO.mjs} +7 -32
- package/dist/lib/node-esm/chunk-D347W3KO.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-WZ6DHQER.mjs → chunk-DRZKO5UZ.mjs} +147 -75
- package/dist/lib/node-esm/chunk-DRZKO5UZ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-HI3YBICQ.mjs → chunk-HTBJU5FX.mjs} +76 -11
- package/dist/lib/node-esm/chunk-HTBJU5FX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-M3HKPRPO.mjs +423 -0
- package/dist/lib/node-esm/chunk-M3HKPRPO.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-MUVUQC3G.mjs +1175 -0
- package/dist/lib/node-esm/chunk-MUVUQC3G.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-VKHGNEDB.mjs → chunk-SBS2YMPT.mjs} +3 -3
- package/dist/lib/node-esm/{chunk-VKHGNEDB.mjs.map → chunk-SBS2YMPT.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-42KBWDE4.mjs → chunk-SDJ4B2LU.mjs} +1 -1
- package/dist/lib/node-esm/{chunk-42KBWDE4.mjs.map → chunk-SDJ4B2LU.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-JPWVIQ5I.mjs → chunk-V24UWT36.mjs} +4 -17
- package/dist/lib/node-esm/chunk-V24UWT36.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-G3RTFSNG.mjs → chunk-WFSRZKBP.mjs} +2 -2
- package/dist/lib/node-esm/chunk-WFSRZKBP.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WK7OIQKI.mjs +70 -0
- package/dist/lib/node-esm/chunk-WK7OIQKI.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ZZ7CKK6W.mjs → chunk-XOCUANHO.mjs} +1 -1
- package/dist/lib/node-esm/{chunk-ZZ7CKK6W.mjs.map → chunk-XOCUANHO.mjs.map} +2 -2
- package/dist/lib/node-esm/cli/index.mjs +14 -28
- package/dist/lib/node-esm/cli/index.mjs.map +3 -3
- package/dist/lib/node-esm/common/activation-events.mjs +7 -7
- package/dist/lib/node-esm/common/capabilities.mjs +7 -7
- package/dist/lib/node-esm/core/activation-event.mjs +1 -1
- package/dist/lib/node-esm/core/capability.mjs +1 -1
- package/dist/lib/node-esm/core/plugin-manager.mjs +8 -4
- package/dist/lib/node-esm/core/plugin.mjs +10 -2
- package/dist/lib/node-esm/core/url-loader.mjs +13 -5
- package/dist/lib/node-esm/index.mjs +34 -17
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{invoker-capability-EGA3XW6J.mjs → invoker-capability-XEPW5LMJ.mjs} +12 -11
- package/dist/lib/node-esm/invoker-capability-XEPW5LMJ.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +20 -32
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/testing/react.mjs +11 -11
- package/dist/lib/node-esm/ui/index.mjs +14 -12
- package/dist/plugin/node-esm/index.mjs +136 -37
- package/dist/plugin/node-esm/index.mjs.map +4 -4
- package/dist/plugin/node-esm/meta.json +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 +2 -1
- package/dist/types/src/common/capabilities.d.ts.map +1 -1
- package/dist/types/src/common/operations.d.ts +1 -1
- package/dist/types/src/common/operations.d.ts.map +1 -1
- package/dist/types/src/core/activation-event.d.ts +4 -4
- package/dist/types/src/core/activation-event.d.ts.map +1 -1
- package/dist/types/src/core/capability-manager.d.ts.map +1 -1
- package/dist/types/src/core/capability.d.ts +2 -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 +5 -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 +163 -2
- 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 +80 -0
- package/dist/types/src/core/plugin.d.ts.map +1 -1
- package/dist/types/src/core/registry.d.ts +101 -0
- package/dist/types/src/core/registry.d.ts.map +1 -0
- package/dist/types/src/core/url-loader.d.ts +88 -3
- package/dist/types/src/core/url-loader.d.ts.map +1 -1
- package/dist/types/src/helpers.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/history/capability.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/history/errors.d.ts +6 -6
- package/dist/types/src/plugin-operation/history/errors.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/history/history-tracker.d.ts +1 -1
- package/dist/types/src/plugin-operation/history/history-tracker.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/history/types.d.ts +1 -1
- package/dist/types/src/plugin-operation/history/types.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/history/undo-mapping.d.ts +1 -1
- package/dist/types/src/plugin-operation/history/undo-mapping.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/history/undo-registry.d.ts +1 -1
- package/dist/types/src/plugin-operation/history/undo-registry.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/invoker-capability.d.ts +1 -1
- package/dist/types/src/plugin-operation/invoker-capability.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/meta.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/testing.d.ts +2 -1
- package/dist/types/src/plugin-operation/testing.d.ts.map +1 -1
- package/dist/types/src/plugin-runtime/capability.d.ts +1 -1
- package/dist/types/src/plugin-runtime/capability.d.ts.map +1 -1
- package/dist/types/src/plugin-runtime/meta.d.ts.map +1 -1
- package/dist/types/src/testing/harness.d.ts +1 -1
- package/dist/types/src/testing/harness.d.ts.map +1 -1
- package/dist/types/src/testing/react.d.ts.map +1 -1
- 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.map +1 -1
- 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.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.map +1 -1
- package/dist/types/src/ui/components/Surface/index.d.ts +1 -1
- package/dist/types/src/ui/components/Surface/index.d.ts.map +1 -1
- package/dist/types/src/ui/components/Surface/types.d.ts.map +1 -1
- 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/useApp.d.ts +30 -3
- package/dist/types/src/ui/hooks/useApp.d.ts.map +1 -1
- package/dist/types/src/ui/hooks/useCapabilities.d.ts.map +1 -1
- package/dist/types/src/ui/hooks/useLoading.d.ts.map +1 -1
- package/dist/types/src/ui/hooks/useSettingsState.d.ts.map +1 -1
- package/dist/types/src/vite-plugin/boot-loader/BootLoader.stories.d.ts +20 -36
- package/dist/types/src/vite-plugin/boot-loader/BootLoader.stories.d.ts.map +1 -1
- package/dist/types/src/vite-plugin/boot-loader/index.d.ts +1 -50
- package/dist/types/src/vite-plugin/boot-loader/index.d.ts.map +1 -1
- 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 +12 -12
- package/dist/types/src/vite-plugin/composer/index.d.ts.map +1 -1
- package/dist/types/src/vite-plugin/import-map/index.d.ts +13 -1
- package/dist/types/src/vite-plugin/import-map/index.d.ts.map +1 -1
- package/dist/types/src/vite-plugin/manifest.d.ts +30 -5
- package/dist/types/src/vite-plugin/manifest.d.ts.map +1 -1
- package/dist/types/src/vite-plugin/packages.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +27 -23
- package/src/cli/cli.ts +1 -1
- package/src/common/annotations.ts +3 -0
- package/src/common/capabilities.ts +2 -1
- package/src/common/operations.ts +1 -1
- package/src/core/capability.ts +1 -1
- package/src/core/edge-registry-plugin-provider.ts +92 -0
- package/src/core/index.ts +5 -0
- package/src/core/plugin-asset-cache.ts +60 -0
- package/src/core/plugin-manager.test.ts +533 -4
- package/src/core/plugin-manager.ts +470 -28
- package/src/core/plugin-manifest.test.ts +75 -0
- package/src/core/plugin-manifest.ts +134 -0
- package/src/core/plugin.ts +103 -0
- package/src/core/registry.ts +157 -0
- package/src/core/url-loader.test.ts +115 -6
- package/src/core/url-loader.ts +253 -43
- package/src/plugin-operation/history/capability.ts +1 -1
- package/src/plugin-operation/history/history-tracker.test.ts +2 -1
- package/src/plugin-operation/history/history-tracker.ts +1 -1
- package/src/plugin-operation/history/types.ts +1 -1
- package/src/plugin-operation/history/undo-mapping.ts +1 -1
- package/src/plugin-operation/history/undo-registry.ts +1 -1
- package/src/plugin-operation/invoker-capability.ts +2 -1
- package/src/plugin-operation/meta.ts +1 -0
- package/src/plugin-operation/testing.ts +2 -1
- package/src/plugin-runtime/meta.ts +1 -0
- package/src/testing/harness.ts +2 -2
- package/src/testing/service.ts +1 -1
- package/src/testing/withPluginManager.stories.tsx +1 -1
- package/src/ui/components/App/App.stories.tsx +2 -6
- package/src/ui/components/App/App.tsx +12 -1
- package/src/ui/components/Placeholder/Placeholder.stories.tsx +77 -0
- package/src/ui/components/Placeholder/Placeholder.tsx +155 -0
- package/src/ui/components/Placeholder/index.ts +5 -0
- package/src/ui/components/PluginManager/PluginManagerContext.stories.tsx +4 -2
- package/src/ui/components/Surface/SurfaceComponent.stories.tsx +1 -1
- package/src/ui/components/Surface/SurfaceComponent.tsx +2 -2
- package/src/ui/components/Surface/SurfaceInfo.tsx +0 -1
- package/src/ui/components/index.ts +1 -0
- package/src/ui/hooks/useApp.test.tsx +1 -1
- package/src/ui/hooks/useApp.tsx +161 -26
- package/src/ui/hooks/useLoading.tsx +14 -6
- package/src/vite-plugin/boot-loader/BootLoader.stories.tsx +208 -100
- package/src/vite-plugin/boot-loader/boot-loader.css +248 -45
- package/src/vite-plugin/boot-loader/boot-loader.js +309 -39
- package/src/vite-plugin/boot-loader/index.ts +1 -95
- package/src/vite-plugin/boot-loader/loader.ts +123 -0
- package/src/vite-plugin/composer/index.ts +61 -39
- package/src/vite-plugin/import-map/index.ts +42 -5
- package/src/vite-plugin/index.ts +2 -2
- package/src/vite-plugin/manifest.test.ts +27 -4
- package/src/vite-plugin/manifest.ts +42 -5
- package/src/vite-plugin/packages.ts +8 -2
- package/tsconfig.json +16 -1
- package/.swc/plugins/linux_x86_64_19.0.0/727453fb3a62f7f1d952a41e051ca8a6f88cadc45cee43c6a4d1aa45f9b75665.wasmer-v7 +0 -0
- package/dist/lib/browser/capability-DOMNPRJP.mjs.map +0 -7
- package/dist/lib/browser/chunk-7B6AJK4D.mjs +0 -964
- package/dist/lib/browser/chunk-7B6AJK4D.mjs.map +0 -7
- package/dist/lib/browser/chunk-BMIAYUWT.mjs.map +0 -7
- package/dist/lib/browser/chunk-F7FW2RK2.mjs.map +0 -7
- package/dist/lib/browser/chunk-GDWTW4ZW.mjs.map +0 -7
- package/dist/lib/browser/chunk-JKWMHZP6.mjs.map +0 -7
- package/dist/lib/browser/chunk-QRTB4Q3U.mjs.map +0 -7
- package/dist/lib/browser/chunk-RFSO3JRG.mjs +0 -1
- package/dist/lib/browser/chunk-RFSO3JRG.mjs.map +0 -7
- package/dist/lib/browser/chunk-Y543KCO7.mjs +0 -174
- package/dist/lib/browser/chunk-Y543KCO7.mjs.map +0 -7
- package/dist/lib/browser/invoker-capability-VCMPQOIA.mjs.map +0 -7
- package/dist/lib/node-esm/capability-KJTQIWDK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7PJ5OKRB.mjs +0 -965
- package/dist/lib/node-esm/chunk-7PJ5OKRB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DXVXOGJ7.mjs +0 -175
- package/dist/lib/node-esm/chunk-DXVXOGJ7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EL3R25OQ.mjs +0 -2
- package/dist/lib/node-esm/chunk-EL3R25OQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-G3RTFSNG.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HI3YBICQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JPWVIQ5I.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-URWHJQT2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WZ6DHQER.mjs.map +0 -7
- package/dist/lib/node-esm/invoker-capability-EGA3XW6J.mjs.map +0 -7
- /package/dist/lib/browser/{capability-KSNT34SN.mjs.map → capability-LUKGKUQH.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-I34GF4NG.mjs.map → chunk-45CHLTBV.mjs.map} +0 -0
- /package/dist/lib/node-esm/{capability-EOQTORML.mjs.map → capability-FCGZVIEG.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-WZCSOX5Q.mjs.map → chunk-6XW6LET6.mjs.map} +0 -0
package/src/core/url-loader.ts
CHANGED
|
@@ -3,13 +3,25 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Option from 'effect/Option';
|
|
6
7
|
|
|
8
|
+
import { BaseError } from '@dxos/errors';
|
|
7
9
|
import { log } from '@dxos/log';
|
|
8
10
|
|
|
9
11
|
import * as Plugin from './plugin';
|
|
12
|
+
import * as PluginAssetCache from './plugin-asset-cache';
|
|
13
|
+
import * as PluginManifest from './plugin-manifest';
|
|
10
14
|
|
|
11
15
|
const DEFAULT_KEY = 'org.dxos.composer.remote-plugins';
|
|
12
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Tagged error for any failure during remote plugin loading. Construction sites
|
|
19
|
+
* set `context.locator` and `context.reason` (one of `'invalid-locator' |
|
|
20
|
+
* 'manifest-error' | 'cache-error' | 'import-failed' | 'meta-missing' |
|
|
21
|
+
* 'meta-mismatch' | 'duplicate-id'`) so handlers can route on the failure mode.
|
|
22
|
+
*/
|
|
23
|
+
export class RemotePluginLoadError extends BaseError.extend('RemotePluginLoadError', 'Failed to load remote plugin') {}
|
|
24
|
+
|
|
13
25
|
/**
|
|
14
26
|
* Abstraction over key-value storage (defaults to localStorage).
|
|
15
27
|
*/
|
|
@@ -24,14 +36,34 @@ export type Storage = {
|
|
|
24
36
|
export type Options = {
|
|
25
37
|
storage?: Storage;
|
|
26
38
|
key?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Per-platform offline asset cache. Defaults to a no-op cache (no offline support).
|
|
41
|
+
*/
|
|
42
|
+
cache?: PluginAssetCache.Cache;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Options for the preload entry point. Adds an optional progress hook so hosts
|
|
47
|
+
* can drive a boot-loader counter (`Loading plugins (3/12)…`) as remote plugin
|
|
48
|
+
* manifests resolve. Resolution order is *not* deterministic — each entry races
|
|
49
|
+
* its own network fetch — so callers should treat `loaded` as a count, not an
|
|
50
|
+
* index. Failures are still swallowed; `loaded` advances on both success and
|
|
51
|
+
* recoverable failure so the counter always reaches `total`.
|
|
52
|
+
*/
|
|
53
|
+
export type PreloadOptions = Options & {
|
|
54
|
+
onPluginLoaded?: (loaded: number, total: number) => void;
|
|
27
55
|
};
|
|
28
56
|
|
|
29
57
|
/**
|
|
30
58
|
* Persisted record of a remote plugin that has been loaded previously.
|
|
59
|
+
*
|
|
60
|
+
* `url` is the URL of the plugin manifest (`plugin.json`), not the entry module.
|
|
31
61
|
*/
|
|
32
62
|
export type RemotePluginEntry = {
|
|
33
63
|
id: string;
|
|
34
64
|
url: string;
|
|
65
|
+
/** Installed version string, e.g. `v1.0.0`. Populated after install from a community catalog entry. */
|
|
66
|
+
version?: string;
|
|
35
67
|
};
|
|
36
68
|
|
|
37
69
|
const defaultStorage = (): Storage => ({
|
|
@@ -64,6 +96,15 @@ const persistRemotePlugin = (storage: Storage, key: string, entry: RemotePluginE
|
|
|
64
96
|
}
|
|
65
97
|
};
|
|
66
98
|
|
|
99
|
+
const removePersistedRemotePlugin = (storage: Storage, key: string, pluginId: string): void => {
|
|
100
|
+
try {
|
|
101
|
+
const entries = getPersistedRemotePlugins(storage, key).filter((existing) => existing.id !== pluginId);
|
|
102
|
+
storage.set(key, JSON.stringify(entries));
|
|
103
|
+
} catch (error) {
|
|
104
|
+
log.warn('failed to remove remote plugin entry', { pluginId, error });
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
67
108
|
const isUrl = (locator: string): boolean => {
|
|
68
109
|
try {
|
|
69
110
|
const url = new URL(locator);
|
|
@@ -97,6 +138,36 @@ export const getRemoteEntries = (options: Options = {}): readonly RemotePluginEn
|
|
|
97
138
|
return getPersistedRemotePlugins(storage, key);
|
|
98
139
|
};
|
|
99
140
|
|
|
141
|
+
/**
|
|
142
|
+
* Updates the persisted installed version for an already-stored remote plugin entry.
|
|
143
|
+
* Does nothing if the plugin has not been persisted yet.
|
|
144
|
+
*/
|
|
145
|
+
export const setInstalledVersion = (id: string, version: string, options: Options = {}): void => {
|
|
146
|
+
const storage = options.storage ?? defaultStorage();
|
|
147
|
+
const key = options.key ?? DEFAULT_KEY;
|
|
148
|
+
const entries = getPersistedRemotePlugins(storage, key);
|
|
149
|
+
const index = entries.findIndex((entry) => entry.id === id);
|
|
150
|
+
if (index === -1) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
entries[index] = { ...entries[index], version };
|
|
154
|
+
try {
|
|
155
|
+
storage.set(key, JSON.stringify(entries));
|
|
156
|
+
} catch (error) {
|
|
157
|
+
log.warn('failed to update installed version for remote plugin', { id, version, error });
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Returns the installed version string for the given plugin id, or `undefined` if
|
|
163
|
+
* the plugin was installed without version tracking (legacy install) or is not found.
|
|
164
|
+
*/
|
|
165
|
+
export const getInstalledVersion = (id: string, options: Options = {}): string | undefined => {
|
|
166
|
+
const storage = options.storage ?? defaultStorage();
|
|
167
|
+
const key = options.key ?? DEFAULT_KEY;
|
|
168
|
+
return getPersistedRemotePlugins(storage, key).find((entry) => entry.id === id)?.version;
|
|
169
|
+
};
|
|
170
|
+
|
|
100
171
|
const normalizePluginExport = (mod: Record<string, unknown>): Plugin.Plugin => {
|
|
101
172
|
const exported = mod.default;
|
|
102
173
|
if (Plugin.isPlugin(exported)) {
|
|
@@ -111,68 +182,207 @@ const normalizePluginExport = (mod: Record<string, unknown>): Plugin.Plugin => {
|
|
|
111
182
|
throw new Error('Remote module default export is not a Plugin or a zero-arg plugin factory.');
|
|
112
183
|
};
|
|
113
184
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
185
|
+
/**
|
|
186
|
+
* Loads stylesheets declared in the manifest by appending `<link rel="stylesheet">` elements to the host document.
|
|
187
|
+
* Each link is tagged with `data-dxos-plugin-id` so `uninstall` can clean them up.
|
|
188
|
+
*/
|
|
189
|
+
const loadStylesheets = (
|
|
190
|
+
manifest: PluginManifest.ResolvedManifest,
|
|
191
|
+
cache: PluginAssetCache.Cache,
|
|
192
|
+
): Effect.Effect<void, PluginAssetCache.PluginAssetCacheError> =>
|
|
193
|
+
Effect.gen(function* () {
|
|
194
|
+
if (typeof document === 'undefined') {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const cssUrls = manifest.assetUrls.filter((url) => url.endsWith('.css'));
|
|
198
|
+
for (const url of cssUrls) {
|
|
199
|
+
const resolved = yield* cache.resolve(manifest.id, url);
|
|
200
|
+
if (document.querySelector(`link[data-dxos-plugin-id="${manifest.id}"][href="${resolved}"]`)) {
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
const link = document.createElement('link');
|
|
204
|
+
link.rel = 'stylesheet';
|
|
205
|
+
link.href = resolved;
|
|
206
|
+
link.dataset.dxosPluginId = manifest.id;
|
|
207
|
+
document.head.appendChild(link);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
const loadFromManifest = (
|
|
212
|
+
manifestUrl: string,
|
|
213
|
+
cache: PluginAssetCache.Cache,
|
|
214
|
+
): Effect.Effect<{ plugin: Plugin.Plugin; manifest: PluginManifest.ResolvedManifest }, RemotePluginLoadError> =>
|
|
215
|
+
Effect.gen(function* () {
|
|
216
|
+
log.info('loading remote plugin', { manifestUrl });
|
|
217
|
+
const manifest = yield* PluginManifest.fetchManifest(manifestUrl).pipe(
|
|
218
|
+
Effect.mapError(
|
|
219
|
+
(cause) => new RemotePluginLoadError({ context: { locator: manifestUrl, reason: 'manifest-error' }, cause }),
|
|
220
|
+
),
|
|
221
|
+
);
|
|
222
|
+
const wrapCacheError = Effect.mapError(
|
|
223
|
+
(cause: PluginAssetCache.PluginAssetCacheError) =>
|
|
224
|
+
new RemotePluginLoadError({ context: { locator: manifestUrl, reason: 'cache-error' }, cause }),
|
|
225
|
+
);
|
|
226
|
+
// Dev-mode manifests (served by `vite dev` via composerPlugin) skip the offline
|
|
227
|
+
// cache: chunks resolve on demand through the dev server, the asset list isn't
|
|
228
|
+
// enumerable up-front, and CSS arrives via runtime <style> injection rather than
|
|
229
|
+
// static <link> tags.
|
|
230
|
+
if (!manifest.dev) {
|
|
231
|
+
// Cache the manifest URL alongside its declared assets. Without it, `preload` on a
|
|
232
|
+
// subsequent reload would fetch the manifest from the network — and fail when the
|
|
233
|
+
// plugin's host is offline, dropping the plugin from the runtime.
|
|
234
|
+
const cachedUrls =
|
|
235
|
+
manifest.assetUrls.indexOf(manifestUrl) === -1 ? [manifestUrl, ...manifest.assetUrls] : manifest.assetUrls;
|
|
236
|
+
yield* cache.cache(manifest.id, cachedUrls).pipe(wrapCacheError);
|
|
237
|
+
}
|
|
238
|
+
const entryUrl = manifest.dev
|
|
239
|
+
? manifest.entryUrl
|
|
240
|
+
: yield* cache.resolve(manifest.id, manifest.entryUrl).pipe(wrapCacheError);
|
|
241
|
+
const mod = yield* Effect.tryPromise({
|
|
242
|
+
try: () => import(/* @vite-ignore */ entryUrl),
|
|
243
|
+
catch: (cause) =>
|
|
244
|
+
new RemotePluginLoadError({ context: { locator: manifestUrl, reason: 'import-failed' }, cause }),
|
|
245
|
+
});
|
|
246
|
+
const plugin = normalizePluginExport(mod);
|
|
247
|
+
if (!plugin.meta.id || !plugin.meta.name) {
|
|
248
|
+
return yield* Effect.fail(
|
|
249
|
+
new RemotePluginLoadError({ context: { locator: manifestUrl, reason: 'meta-missing' } }),
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
if (plugin.meta.id !== manifest.id) {
|
|
253
|
+
return yield* Effect.fail(
|
|
254
|
+
new RemotePluginLoadError({
|
|
255
|
+
context: {
|
|
256
|
+
locator: manifestUrl,
|
|
257
|
+
reason: 'meta-mismatch',
|
|
258
|
+
metaId: plugin.meta.id,
|
|
259
|
+
manifestId: manifest.id,
|
|
260
|
+
},
|
|
261
|
+
}),
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
// Append stylesheets only after the entry imports cleanly and meta validation
|
|
265
|
+
// passes. If we did this earlier and the import or meta checks failed, the
|
|
266
|
+
// `<link>` tags would leak into the host DOM with no plugin to own their
|
|
267
|
+
// teardown — `uninstall` only runs for plugins the manager actually accepted.
|
|
268
|
+
// In dev mode, Vite injects styles at runtime via the module graph, so static
|
|
269
|
+
// <link> tags would duplicate (or 404, since CSS chunks aren't pre-built).
|
|
270
|
+
if (!manifest.dev) {
|
|
271
|
+
yield* loadStylesheets(manifest, cache).pipe(wrapCacheError);
|
|
272
|
+
}
|
|
273
|
+
return { plugin, manifest };
|
|
274
|
+
});
|
|
123
275
|
|
|
124
276
|
/**
|
|
125
|
-
* Preloads previously persisted remote plugins from storage.
|
|
277
|
+
* Preloads previously persisted remote plugins from storage. Per-entry failures
|
|
278
|
+
* are logged and swallowed — the returned effect always succeeds with whichever
|
|
279
|
+
* plugins loaded cleanly, so a single bad entry can't block the host's startup.
|
|
126
280
|
*/
|
|
127
|
-
export const preload =
|
|
128
|
-
|
|
129
|
-
|
|
281
|
+
export const preload = (options: PreloadOptions = {}): Effect.Effect<Plugin.Plugin[], never> =>
|
|
282
|
+
Effect.gen(function* () {
|
|
283
|
+
const storage = options.storage ?? defaultStorage();
|
|
284
|
+
const key = options.key ?? DEFAULT_KEY;
|
|
285
|
+
const cache = options.cache ?? PluginAssetCache.noop();
|
|
286
|
+
const onPluginLoaded = options.onPluginLoaded;
|
|
130
287
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
log.info('preloading remote plugins', { count: entries.length });
|
|
136
|
-
const results = await Promise.allSettled(entries.map((entry) => loadRemotePlugin(entry.url)));
|
|
137
|
-
const plugins: Plugin.Plugin[] = [];
|
|
138
|
-
for (let index = 0; index < results.length; index++) {
|
|
139
|
-
const result = results[index];
|
|
140
|
-
if (result.status === 'fulfilled') {
|
|
141
|
-
plugins.push(result.value);
|
|
142
|
-
} else {
|
|
143
|
-
log.warn('failed to preload remote plugin', { entry: entries[index], error: result.reason });
|
|
288
|
+
const entries = getPersistedRemotePlugins(storage, key);
|
|
289
|
+
if (entries.length === 0) {
|
|
290
|
+
return [];
|
|
144
291
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
292
|
+
log.info('preloading remote plugins', { count: entries.length });
|
|
293
|
+
const total = entries.length;
|
|
294
|
+
let loaded = 0;
|
|
295
|
+
const results = yield* Effect.all(
|
|
296
|
+
entries.map((entry) =>
|
|
297
|
+
loadFromManifest(entry.url, cache).pipe(
|
|
298
|
+
Effect.tapError((error) => Effect.sync(() => log.warn('failed to preload remote plugin', { entry, error }))),
|
|
299
|
+
Effect.option,
|
|
300
|
+
// Tick the progress hook on both success and recoverable failure so
|
|
301
|
+
// the counter monotonically reaches `total`. The host-supplied
|
|
302
|
+
// callback is best-effort: any synchronous throw flows through
|
|
303
|
+
// `Effect.try` and gets logged + ignored so a buggy hook can't
|
|
304
|
+
// derail the preload.
|
|
305
|
+
Effect.tap(() =>
|
|
306
|
+
Effect.sync(() => {
|
|
307
|
+
loaded += 1;
|
|
308
|
+
}).pipe(
|
|
309
|
+
Effect.andThen(Effect.try(() => onPluginLoaded?.(loaded, total))),
|
|
310
|
+
Effect.tapError((error) => Effect.sync(() => log.warn('onPluginLoaded threw', { loaded, total, error }))),
|
|
311
|
+
Effect.ignore,
|
|
312
|
+
),
|
|
313
|
+
),
|
|
314
|
+
),
|
|
315
|
+
),
|
|
316
|
+
{ concurrency: 'unbounded' },
|
|
317
|
+
);
|
|
318
|
+
return results.flatMap((result) =>
|
|
319
|
+
Option.match(result, {
|
|
320
|
+
onNone: () => [],
|
|
321
|
+
onSome: ({ plugin }) => [plugin],
|
|
322
|
+
}),
|
|
323
|
+
);
|
|
324
|
+
});
|
|
148
325
|
|
|
149
326
|
/**
|
|
150
327
|
* Creates a plugin loader that resolves built-in plugins by ID or loads remote plugins from URLs.
|
|
328
|
+
*
|
|
329
|
+
* Remote URLs must point at a plugin manifest (`plugin.json`). The loader fetches the manifest,
|
|
330
|
+
* eagerly persists every declared asset via the configured `PluginAssetCache`, then dynamic-imports
|
|
331
|
+
* the entry module.
|
|
151
332
|
*/
|
|
152
333
|
export const make = (builtinPlugins: Plugin.Plugin[], options: Options = {}) => {
|
|
153
334
|
const storage = options.storage ?? defaultStorage();
|
|
154
335
|
const key = options.key ?? DEFAULT_KEY;
|
|
336
|
+
const cache = options.cache ?? PluginAssetCache.noop();
|
|
155
337
|
|
|
156
|
-
return (locator: string): Effect.Effect<Plugin.Plugin,
|
|
338
|
+
return (locator: string): Effect.Effect<{ plugin: Plugin.Plugin; dev?: boolean }, RemotePluginLoadError> =>
|
|
157
339
|
Effect.gen(function* () {
|
|
158
340
|
const builtin = builtinPlugins.find((plugin) => plugin.meta.id === locator);
|
|
159
341
|
if (builtin) {
|
|
160
|
-
return builtin;
|
|
342
|
+
return { plugin: builtin };
|
|
161
343
|
}
|
|
162
344
|
if (!isUrl(locator)) {
|
|
163
|
-
return yield* Effect.fail(new
|
|
345
|
+
return yield* Effect.fail(new RemotePluginLoadError({ context: { locator, reason: 'invalid-locator' } }));
|
|
164
346
|
}
|
|
165
|
-
const plugin = yield*
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
)
|
|
347
|
+
const { plugin, manifest } = yield* loadFromManifest(locator, cache);
|
|
348
|
+
// Production manifests can't collide with a builtin id — that would make
|
|
349
|
+
// the registered plugin permanently inaccessible. Dev manifests are
|
|
350
|
+
// allowed to collide because the manager shadow primitive handles the
|
|
351
|
+
// overlap (dev plugin takes the id slot for the session, original is
|
|
352
|
+
// restored on uninstall or page reload).
|
|
353
|
+
if (!manifest.dev) {
|
|
354
|
+
const duplicate = builtinPlugins.find((existing) => existing.meta.id === plugin.meta.id);
|
|
355
|
+
if (duplicate) {
|
|
356
|
+
return yield* Effect.fail(
|
|
357
|
+
new RemotePluginLoadError({ context: { locator, reason: 'duplicate-id', id: plugin.meta.id } }),
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
persistRemotePlugin(storage, key, { id: plugin.meta.id, url: locator });
|
|
174
361
|
}
|
|
175
|
-
|
|
176
|
-
return plugin;
|
|
362
|
+
return { plugin, dev: manifest.dev };
|
|
177
363
|
});
|
|
178
364
|
};
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Removes a previously installed remote plugin: drops the persisted entry, evicts cached
|
|
368
|
+
* assets, and removes any stylesheet `<link>` tags that {@link loadFromManifest} appended.
|
|
369
|
+
*
|
|
370
|
+
* Cache eviction failures are logged and swallowed — the persisted entry has already been
|
|
371
|
+
* dropped so the user-visible state is consistent regardless of whether the platform
|
|
372
|
+
* cache cooperated.
|
|
373
|
+
*/
|
|
374
|
+
export const uninstall = (pluginId: string, options: Options = {}): Effect.Effect<void, never> =>
|
|
375
|
+
Effect.gen(function* () {
|
|
376
|
+
const storage = options.storage ?? defaultStorage();
|
|
377
|
+
const key = options.key ?? DEFAULT_KEY;
|
|
378
|
+
const cache = options.cache ?? PluginAssetCache.noop();
|
|
379
|
+
|
|
380
|
+
removePersistedRemotePlugin(storage, key, pluginId);
|
|
381
|
+
if (typeof document !== 'undefined') {
|
|
382
|
+
document.querySelectorAll(`link[data-dxos-plugin-id="${pluginId}"]`).forEach((node) => node.remove());
|
|
383
|
+
}
|
|
384
|
+
yield* cache.evict(pluginId).pipe(
|
|
385
|
+
Effect.tapError((error) => Effect.sync(() => log.warn('failed to evict plugin assets', { pluginId, error }))),
|
|
386
|
+
Effect.ignore,
|
|
387
|
+
);
|
|
388
|
+
});
|
|
@@ -10,7 +10,8 @@ import * as ManagedRuntime from 'effect/ManagedRuntime';
|
|
|
10
10
|
import * as TestClock from 'effect/TestClock';
|
|
11
11
|
import { describe, expect } from 'vitest';
|
|
12
12
|
|
|
13
|
-
import { Operation
|
|
13
|
+
import { Operation } from '@dxos/compute';
|
|
14
|
+
import { OperationInvoker } from '@dxos/operation';
|
|
14
15
|
|
|
15
16
|
const testRuntime = ManagedRuntime.make(Layer.empty) as unknown as ManagedRuntime.ManagedRuntime<any, any>;
|
|
16
17
|
|
|
@@ -7,7 +7,7 @@ import * as Stream from 'effect/Stream';
|
|
|
7
7
|
|
|
8
8
|
import { runAndForwardErrors } from '@dxos/effect';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
|
-
import {
|
|
10
|
+
import { OperationInvoker } from '@dxos/operation';
|
|
11
11
|
|
|
12
12
|
import { UndoOperation } from '../../common';
|
|
13
13
|
import { EmptyHistoryError } from './errors';
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
|
-
import { OperationHandlerSet
|
|
7
|
+
import { OperationHandlerSet } from '@dxos/compute';
|
|
8
|
+
import { OperationInvoker } from '@dxos/operation';
|
|
8
9
|
|
|
9
10
|
import { ActivationEvents, Capabilities } from '../common';
|
|
10
11
|
import { Capability, Plugin } from '../core';
|
|
@@ -9,7 +9,8 @@ import * as Ref from 'effect/Ref';
|
|
|
9
9
|
import * as Schema from 'effect/Schema';
|
|
10
10
|
import * as Stream from 'effect/Stream';
|
|
11
11
|
|
|
12
|
-
import { Operation
|
|
12
|
+
import { Operation } from '@dxos/compute';
|
|
13
|
+
import { OperationInvoker } from '@dxos/operation';
|
|
13
14
|
|
|
14
15
|
//
|
|
15
16
|
// Test Operations
|
package/src/testing/harness.ts
CHANGED
|
@@ -8,9 +8,9 @@ import * as Effect from 'effect/Effect';
|
|
|
8
8
|
import * as PubSub from 'effect/PubSub';
|
|
9
9
|
import * as Queue from 'effect/Queue';
|
|
10
10
|
|
|
11
|
+
import { type Operation } from '@dxos/compute';
|
|
11
12
|
import { runAndForwardErrors } from '@dxos/effect';
|
|
12
13
|
import { invariant } from '@dxos/invariant';
|
|
13
|
-
import { type Operation } from '@dxos/operation';
|
|
14
14
|
|
|
15
15
|
import { ActivationEvents, Capabilities } from '../common';
|
|
16
16
|
import { ActivationEvent, type Capability, type CapabilityManager, type Plugin, PluginManager } from '../core';
|
|
@@ -97,7 +97,7 @@ export const createTestApp = async (opts: TestAppOptions): Promise<TestHarness>
|
|
|
97
97
|
Effect.sync(() => {
|
|
98
98
|
const plugin = plugins.find((plugin) => plugin.meta.id === id);
|
|
99
99
|
invariant(plugin, `Plugin not found: ${id}`);
|
|
100
|
-
return plugin;
|
|
100
|
+
return { plugin };
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
const manager = PluginManager.make({ pluginLoader, plugins, core, enabled });
|
package/src/testing/service.ts
CHANGED
|
@@ -24,7 +24,7 @@ export const fromPlugins = (plugins: Plugin.Plugin[]) =>
|
|
|
24
24
|
Effect.sync(() => {
|
|
25
25
|
const plugin = plugins.find((plugin) => plugin.meta.id === id);
|
|
26
26
|
invariant(plugin, `Plugin not found: ${id}`);
|
|
27
|
-
return plugin;
|
|
27
|
+
return { plugin };
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
const manager = PluginManager.make({
|
|
@@ -55,11 +55,7 @@ const DefaultStory = ({ plugins }: DefaultStoryProps) => {
|
|
|
55
55
|
plugins,
|
|
56
56
|
core,
|
|
57
57
|
placeholder: () => {
|
|
58
|
-
return
|
|
59
|
-
<div role='none' className='text-description'>
|
|
60
|
-
Loading...
|
|
61
|
-
</div>
|
|
62
|
-
);
|
|
58
|
+
return <div className='text-description'>Loading...</div>;
|
|
63
59
|
},
|
|
64
60
|
});
|
|
65
61
|
|
|
@@ -67,7 +63,7 @@ const DefaultStory = ({ plugins }: DefaultStoryProps) => {
|
|
|
67
63
|
};
|
|
68
64
|
|
|
69
65
|
const meta = {
|
|
70
|
-
title: 'sdk/app-framework/App',
|
|
66
|
+
title: 'sdk/app-framework/components/App',
|
|
71
67
|
render: DefaultStory,
|
|
72
68
|
decorators: [withTheme()],
|
|
73
69
|
parameters: {
|
|
@@ -25,10 +25,21 @@ export const App = ({ placeholder: Placeholder, ready, error, debounce, progress
|
|
|
25
25
|
// Emit a once-per-app `app-framework:first-interactive` mark the first time
|
|
26
26
|
// the placeholder is dismissed and the real app shell renders. Closes the
|
|
27
27
|
// gap between `Startup` activated and the first interactive paint.
|
|
28
|
+
//
|
|
29
|
+
// Also dismisses the native-DOM boot loader from
|
|
30
|
+
// `@dxos/app-framework/vite-plugin` here — the framework owns the
|
|
31
|
+
// handoff-complete signal, so dismissing in `App` covers both hosts that
|
|
32
|
+
// wire in a `Placeholder` (which may have its own dismiss path) and hosts
|
|
33
|
+
// that don't (the loader would otherwise sit forever as a `z-index: 10`
|
|
34
|
+
// overlay covering the rendered shell).
|
|
28
35
|
useEffect(() => {
|
|
29
|
-
if (placeholderDismissed
|
|
36
|
+
if (!placeholderDismissed) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (performance.getEntriesByName(FIRST_INTERACTIVE_MARK).length === 0) {
|
|
30
40
|
performance.mark(FIRST_INTERACTIVE_MARK);
|
|
31
41
|
}
|
|
42
|
+
(window as { __bootLoader?: { dismiss?: () => void } }).__bootLoader?.dismiss?.();
|
|
32
43
|
}, [placeholderDismissed]);
|
|
33
44
|
|
|
34
45
|
if (error) {
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React, { useEffect, useState } from 'react';
|
|
7
|
+
import { expect, within } from 'storybook/test';
|
|
8
|
+
|
|
9
|
+
import { Composer } from '@dxos/brand';
|
|
10
|
+
import { Input, Panel, Toolbar } from '@dxos/react-ui';
|
|
11
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
12
|
+
|
|
13
|
+
import { Placeholder } from './Placeholder';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The story renders the brand-agnostic `Placeholder` from `@dxos/app-framework/ui`
|
|
17
|
+
* with the Composer brand icon as its `logo`, so the storybook mirrors what
|
|
18
|
+
* composer-app actually mounts in production. The render function form lets
|
|
19
|
+
* the SVG accept the placeholder's animation `className` directly.
|
|
20
|
+
*/
|
|
21
|
+
const meta = {
|
|
22
|
+
title: 'sdk/app-framework/components/Placeholder',
|
|
23
|
+
component: Placeholder,
|
|
24
|
+
render: () => {
|
|
25
|
+
const [stage, setStage] = useState(0);
|
|
26
|
+
const [auto, setAuto] = useState(false);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (!auto) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const interval = setInterval(() => {
|
|
33
|
+
setStage((prev) => {
|
|
34
|
+
return prev >= 2 ? 0 : prev + 1;
|
|
35
|
+
});
|
|
36
|
+
}, 3_000);
|
|
37
|
+
|
|
38
|
+
return () => clearInterval(interval);
|
|
39
|
+
}, [auto]);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Panel.Root>
|
|
43
|
+
<Panel.Toolbar asChild>
|
|
44
|
+
<Toolbar.Root classNames='gap-2'>
|
|
45
|
+
<Input.Root>
|
|
46
|
+
<Input.Checkbox checked={auto} onCheckedChange={(checked) => setAuto(checked === true)} />
|
|
47
|
+
<Input.Label>Auto</Input.Label>
|
|
48
|
+
</Input.Root>
|
|
49
|
+
<Toolbar.Button onClick={() => setStage((prev) => (prev < 2 ? prev + 1 : 0))}>Next</Toolbar.Button>
|
|
50
|
+
<Toolbar.Text>{stage}</Toolbar.Text>
|
|
51
|
+
</Toolbar.Root>
|
|
52
|
+
</Panel.Toolbar>
|
|
53
|
+
<Panel.Content>
|
|
54
|
+
<Placeholder stage={stage} logo={(logoProps) => <Composer {...logoProps} />} />
|
|
55
|
+
</Panel.Content>
|
|
56
|
+
</Panel.Root>
|
|
57
|
+
);
|
|
58
|
+
},
|
|
59
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' })],
|
|
60
|
+
tags: ['test'],
|
|
61
|
+
} satisfies Meta<typeof Placeholder>;
|
|
62
|
+
|
|
63
|
+
export default meta;
|
|
64
|
+
|
|
65
|
+
type Story = StoryObj<typeof meta>;
|
|
66
|
+
|
|
67
|
+
export const Default: Story = {
|
|
68
|
+
args: {
|
|
69
|
+
stage: 0,
|
|
70
|
+
},
|
|
71
|
+
play: async ({ canvasElement }) => {
|
|
72
|
+
const canvas = within(canvasElement);
|
|
73
|
+
// Smoke test: the toolbar's `Next` button is rendered alongside the
|
|
74
|
+
// placeholder, so the story mounted without throwing.
|
|
75
|
+
await expect(canvas.getByRole('button', { name: 'Next' })).toBeInTheDocument();
|
|
76
|
+
},
|
|
77
|
+
};
|