@dxos/app-framework 0.8.4-main.d05539e30a → 0.8.4-main.d9fc60f731
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-K5XIVCQU.mjs → capability-JCUNWZ66.mjs} +7 -7
- package/dist/lib/browser/{chunk-5AHASNDW.mjs → chunk-2ZIYRDAF.mjs} +1 -1
- package/dist/lib/browser/{chunk-5AHASNDW.mjs.map → chunk-2ZIYRDAF.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-QLML5QFJ.mjs → chunk-7MBI66M7.mjs} +12 -6
- package/dist/lib/browser/chunk-7MBI66M7.mjs.map +7 -0
- package/dist/lib/browser/{chunk-VJ5PFAWC.mjs → chunk-BMLCIFZW.mjs} +37 -16
- package/dist/lib/browser/chunk-BMLCIFZW.mjs.map +7 -0
- package/dist/lib/browser/{chunk-SLX73WRZ.mjs → chunk-DC3WRPBV.mjs} +14 -5
- package/dist/lib/browser/chunk-DC3WRPBV.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BRK6GYNB.mjs → chunk-E5DTDNDY.mjs} +20 -19
- package/dist/lib/browser/chunk-E5DTDNDY.mjs.map +7 -0
- package/dist/lib/browser/{chunk-KLHQNYJ2.mjs → chunk-KZUDO43J.mjs} +2 -2
- package/dist/lib/browser/chunk-Q2GLJTVV.mjs +12 -0
- package/dist/lib/browser/chunk-Q2GLJTVV.mjs.map +7 -0
- package/dist/lib/browser/{chunk-UVTGHZQF.mjs → chunk-VBG5F5UF.mjs} +51 -88
- package/dist/lib/browser/chunk-VBG5F5UF.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +5 -5
- package/dist/lib/browser/common/activation-events.mjs +3 -3
- package/dist/lib/browser/common/capabilities.mjs +4 -4
- package/dist/lib/browser/core/plugin-manager.mjs +2 -2
- package/dist/lib/browser/core/plugin.mjs +3 -1
- package/dist/lib/browser/core/url-loader.mjs +2 -2
- package/dist/lib/browser/index.mjs +13 -14
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{process-manager-capability-JIWLN7SU.mjs → process-manager-capability-4FUA4TRP.mjs} +6 -6
- package/dist/lib/browser/testing/index.mjs +11 -10
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/testing/react.mjs +6 -6
- package/dist/lib/browser/ui/index.mjs +7 -9
- package/dist/lib/node-esm/{capability-RLKFFLTB.mjs → capability-7TCQK7ZP.mjs} +7 -7
- package/dist/lib/node-esm/{chunk-SFYCO3PT.mjs → chunk-4BX2AE47.mjs} +37 -16
- package/dist/lib/node-esm/chunk-4BX2AE47.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-FPW45EZH.mjs +14 -0
- package/dist/lib/node-esm/chunk-FPW45EZH.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-LJNUFNDO.mjs → chunk-GEWHMHM7.mjs} +12 -6
- package/dist/lib/node-esm/chunk-GEWHMHM7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-BYHYYJZH.mjs → chunk-KSH4OVMY.mjs} +20 -19
- package/dist/lib/node-esm/chunk-KSH4OVMY.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-PW2VYGOS.mjs → chunk-QBUGLR4H.mjs} +1 -1
- package/dist/lib/node-esm/{chunk-PW2VYGOS.mjs.map → chunk-QBUGLR4H.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-42UNAKYO.mjs → chunk-XGBUKRCK.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-6S45OMUP.mjs → chunk-XIGPWXCQ.mjs} +14 -5
- package/dist/lib/node-esm/chunk-XIGPWXCQ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-JNT72ZCN.mjs → chunk-Y7JKXNDU.mjs} +51 -88
- package/dist/lib/node-esm/chunk-Y7JKXNDU.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +5 -5
- package/dist/lib/node-esm/common/activation-events.mjs +3 -3
- package/dist/lib/node-esm/common/capabilities.mjs +4 -4
- package/dist/lib/node-esm/core/plugin-manager.mjs +2 -2
- package/dist/lib/node-esm/core/plugin.mjs +3 -1
- package/dist/lib/node-esm/core/url-loader.mjs +2 -2
- package/dist/lib/node-esm/index.mjs +13 -14
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{process-manager-capability-PHKLO2BL.mjs → process-manager-capability-F23D62RN.mjs} +6 -6
- package/dist/lib/node-esm/testing/index.mjs +11 -10
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/testing/react.mjs +6 -6
- package/dist/lib/node-esm/ui/index.mjs +7 -9
- package/dist/plugin/node-esm/index.mjs +155 -77
- package/dist/plugin/node-esm/index.mjs.map +4 -4
- package/dist/plugin/node-esm/meta.json +1 -1
- package/dist/types/src/common/capabilities.d.ts +1 -1
- package/dist/types/src/common/index.d.ts +0 -1
- package/dist/types/src/common/index.d.ts.map +1 -1
- package/dist/types/src/common/translations.d.ts +1 -1
- package/dist/types/src/core/capability-manager.d.ts +4 -0
- package/dist/types/src/core/capability-manager.d.ts.map +1 -1
- package/dist/types/src/core/plugin-manager.d.ts.map +1 -1
- package/dist/types/src/core/plugin.d.ts +33 -6
- package/dist/types/src/core/plugin.d.ts.map +1 -1
- package/dist/types/src/plugin-process-manager/history/history-tracker.d.ts +15 -1
- package/dist/types/src/plugin-process-manager/history/history-tracker.d.ts.map +1 -1
- package/dist/types/src/plugin-process-manager/history/undo-mapping.d.ts +1 -1
- package/dist/types/src/plugin-process-manager/history/undo-mapping.d.ts.map +1 -1
- package/dist/types/src/plugin-process-manager/meta.d.ts +1 -1
- package/dist/types/src/plugin-process-manager/meta.d.ts.map +1 -1
- package/dist/types/src/plugin-process-manager/testing.d.ts.map +1 -1
- package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
- package/dist/types/src/ui/components/App/App.d.ts +34 -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.map +1 -1
- package/dist/types/src/ui/components/PluginManager/PluginManagerContext.stories.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 +0 -1
- package/dist/types/src/ui/components/index.d.ts.map +1 -1
- package/dist/types/src/ui/hooks/useApp.d.ts +1 -7
- 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/useProcessManagerRuntime.d.ts +6 -0
- package/dist/types/src/ui/hooks/useProcessManagerRuntime.d.ts.map +1 -1
- package/dist/types/src/vite-plugin/boot-loader/loader.d.ts +26 -23
- package/dist/types/src/vite-plugin/boot-loader/loader.d.ts.map +1 -1
- package/dist/types/src/vite-plugin/manifest.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +40 -35
- package/src/common/capabilities.ts +1 -1
- package/src/common/index.ts +0 -1
- package/src/common/translations.ts +1 -1
- package/src/core/capability-manager.test.ts +3 -0
- package/src/core/capability-manager.ts +22 -1
- package/src/core/plugin-manager.test.ts +51 -21
- package/src/core/plugin-manager.ts +10 -5
- package/src/core/plugin.ts +44 -8
- package/src/core/url-loader.test.ts +2 -1
- package/src/plugin-process-manager/history/history-tracker.test.ts +39 -60
- package/src/plugin-process-manager/history/history-tracker.ts +32 -16
- package/src/plugin-process-manager/history/undo-mapping.ts +1 -1
- package/src/plugin-process-manager/history/undo-registry.test.ts +3 -1
- package/src/plugin-process-manager/meta.ts +6 -4
- package/src/plugin-process-manager/testing.ts +6 -5
- package/src/testing/react.test.tsx +3 -1
- package/src/testing/withPluginManager.tsx +4 -3
- package/src/ui/components/App/App.stories.tsx +9 -11
- package/src/ui/components/App/App.tsx +80 -17
- package/src/ui/components/PluginManager/PluginManagerContext.stories.tsx +9 -14
- package/src/ui/components/Surface/SurfaceComponent.stories.tsx +1 -1
- package/src/ui/components/Surface/SurfaceComponent.tsx +1 -1
- package/src/ui/components/Surface/types.test.ts +2 -2
- package/src/ui/components/Surface/types.ts +21 -0
- package/src/ui/components/index.ts +0 -1
- package/src/ui/hooks/useApp.test.tsx +3 -1
- package/src/ui/hooks/useApp.tsx +4 -18
- package/src/ui/hooks/useCapabilities.ts +1 -0
- package/src/ui/hooks/useProcessManagerRuntime.ts +12 -2
- package/src/vite-plugin/boot-loader/BootLoader.solid-stories.tsx +198 -0
- package/src/vite-plugin/boot-loader/loader-app/Loader.tsx +166 -0
- package/src/vite-plugin/boot-loader/loader-app/boot-loader.css +311 -0
- package/src/vite-plugin/boot-loader/loader-app/bridge.ts +25 -0
- package/src/vite-plugin/boot-loader/loader-app/entry.tsx +21 -0
- package/src/vite-plugin/boot-loader/loader-app/mount.tsx +70 -0
- package/src/vite-plugin/boot-loader/loader-app/store.test.ts +137 -0
- package/src/vite-plugin/boot-loader/loader-app/store.ts +149 -0
- package/src/vite-plugin/boot-loader/loader-app/tsconfig.json +11 -0
- package/src/vite-plugin/boot-loader/loader-app/types.ts +78 -0
- package/src/vite-plugin/boot-loader/loader.ts +133 -63
- package/src/vite-plugin/manifest.test.ts +19 -10
- package/src/vite-plugin/manifest.ts +9 -3
- package/tsconfig.json +6 -7
- package/dist/lib/browser/chunk-BRK6GYNB.mjs.map +0 -7
- package/dist/lib/browser/chunk-KFDF7KR3.mjs +0 -42
- package/dist/lib/browser/chunk-KFDF7KR3.mjs.map +0 -7
- package/dist/lib/browser/chunk-QLML5QFJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-SLX73WRZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-UVTGHZQF.mjs.map +0 -7
- package/dist/lib/browser/chunk-VJ5PFAWC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6S45OMUP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BYHYYJZH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JNT72ZCN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LJNUFNDO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OUEMWPIW.mjs +0 -43
- package/dist/lib/node-esm/chunk-OUEMWPIW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SFYCO3PT.mjs.map +0 -7
- package/dist/types/src/common/operations.d.ts +0 -19
- package/dist/types/src/common/operations.d.ts.map +0 -1
- package/dist/types/src/ui/components/Placeholder/Placeholder.d.ts +0 -64
- package/dist/types/src/ui/components/Placeholder/Placeholder.d.ts.map +0 -1
- package/dist/types/src/ui/components/Placeholder/Placeholder.stories.d.ts +0 -19
- package/dist/types/src/ui/components/Placeholder/Placeholder.stories.d.ts.map +0 -1
- package/dist/types/src/ui/components/Placeholder/index.d.ts +0 -2
- package/dist/types/src/ui/components/Placeholder/index.d.ts.map +0 -1
- package/dist/types/src/vite-plugin/boot-loader/BootLoader.stories.d.ts +0 -34
- package/dist/types/src/vite-plugin/boot-loader/BootLoader.stories.d.ts.map +0 -1
- package/src/common/operations.ts +0 -35
- package/src/ui/components/Placeholder/Placeholder.stories.tsx +0 -77
- package/src/ui/components/Placeholder/Placeholder.tsx +0 -155
- package/src/ui/components/Placeholder/index.ts +0 -5
- package/src/vite-plugin/boot-loader/BootLoader.stories.tsx +0 -270
- package/src/vite-plugin/boot-loader/boot-loader.css +0 -320
- package/src/vite-plugin/boot-loader/boot-loader.js +0 -325
- /package/dist/lib/browser/{capability-K5XIVCQU.mjs.map → capability-JCUNWZ66.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-KLHQNYJ2.mjs.map → chunk-KZUDO43J.mjs.map} +0 -0
- /package/dist/lib/browser/{process-manager-capability-JIWLN7SU.mjs.map → process-manager-capability-4FUA4TRP.mjs.map} +0 -0
- /package/dist/lib/node-esm/{capability-RLKFFLTB.mjs.map → capability-7TCQK7ZP.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-42UNAKYO.mjs.map → chunk-XGBUKRCK.mjs.map} +0 -0
- /package/dist/lib/node-esm/{process-manager-capability-PHKLO2BL.mjs.map → process-manager-capability-F23D62RN.mjs.map} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/app-framework",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.d9fc60f731",
|
|
4
4
|
"description": "A framework for building applications from composible plugins.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -92,54 +92,59 @@
|
|
|
92
92
|
},
|
|
93
93
|
"types": "dist/types/src/index.d.ts",
|
|
94
94
|
"dependencies": {
|
|
95
|
-
"@
|
|
96
|
-
"@
|
|
97
|
-
"@effect/
|
|
95
|
+
"@babel/core": "^7.18.13",
|
|
96
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
97
|
+
"@effect-atom/atom": "^0.5.3",
|
|
98
|
+
"@effect/cli": "0.75.1",
|
|
99
|
+
"@effect/platform": "0.96.1",
|
|
100
|
+
"babel-preset-solid": "^1.9.9",
|
|
98
101
|
"cjs-module-lexer": "^2.2.0",
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"@dxos/compute
|
|
102
|
-
"@dxos/context": "0.8.4-main.
|
|
103
|
-
"@dxos/
|
|
104
|
-
"@dxos/edge-client": "0.8.4-main.
|
|
105
|
-
"@dxos/
|
|
106
|
-
"@dxos/effect": "0.8.4-main.
|
|
107
|
-
"@dxos/
|
|
108
|
-
"@dxos/
|
|
109
|
-
"@dxos/
|
|
110
|
-
"@dxos/
|
|
111
|
-
"@dxos/
|
|
112
|
-
"@dxos/react-error-boundary": "0.8.4-main.
|
|
113
|
-
"@dxos/
|
|
114
|
-
"@dxos/
|
|
115
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
116
|
-
"@dxos/
|
|
117
|
-
"@dxos/web-context": "0.8.4-main.
|
|
118
|
-
"@dxos/
|
|
119
|
-
"@dxos/web-context-react": "0.8.4-main.
|
|
102
|
+
"esbuild": "0.28.0",
|
|
103
|
+
"solid-js": "^1.9.11",
|
|
104
|
+
"@dxos/compute": "0.8.4-main.d9fc60f731",
|
|
105
|
+
"@dxos/context": "0.8.4-main.d9fc60f731",
|
|
106
|
+
"@dxos/compute-runtime": "0.8.4-main.d9fc60f731",
|
|
107
|
+
"@dxos/edge-client": "0.8.4-main.d9fc60f731",
|
|
108
|
+
"@dxos/debug": "0.8.4-main.d9fc60f731",
|
|
109
|
+
"@dxos/effect": "0.8.4-main.d9fc60f731",
|
|
110
|
+
"@dxos/invariant": "0.8.4-main.d9fc60f731",
|
|
111
|
+
"@dxos/errors": "0.8.4-main.d9fc60f731",
|
|
112
|
+
"@dxos/keys": "0.8.4-main.d9fc60f731",
|
|
113
|
+
"@dxos/log": "0.8.4-main.d9fc60f731",
|
|
114
|
+
"@dxos/operation": "0.8.4-main.d9fc60f731",
|
|
115
|
+
"@dxos/react-error-boundary": "0.8.4-main.d9fc60f731",
|
|
116
|
+
"@dxos/react-hooks": "0.8.4-main.d9fc60f731",
|
|
117
|
+
"@dxos/protocols": "0.8.4-main.d9fc60f731",
|
|
118
|
+
"@dxos/react-ui": "0.8.4-main.d9fc60f731",
|
|
119
|
+
"@dxos/ui-theme": "0.8.4-main.d9fc60f731",
|
|
120
|
+
"@dxos/web-context": "0.8.4-main.d9fc60f731",
|
|
121
|
+
"@dxos/util": "0.8.4-main.d9fc60f731",
|
|
122
|
+
"@dxos/web-context-react": "0.8.4-main.d9fc60f731",
|
|
123
|
+
"@dxos/async": "0.8.4-main.d9fc60f731"
|
|
120
124
|
},
|
|
121
125
|
"devDependencies": {
|
|
122
126
|
"@effect-atom/atom-react": "^0.5.0",
|
|
123
|
-
"@effect/platform": "0.
|
|
127
|
+
"@effect/platform": "0.96.1",
|
|
124
128
|
"@effect/vitest": "0.29.0",
|
|
125
129
|
"@testing-library/react": "^16.3.0",
|
|
126
130
|
"@types/react": "~19.2.7",
|
|
127
|
-
"effect": "3.
|
|
131
|
+
"effect": "3.21.2",
|
|
128
132
|
"react": "~19.2.3",
|
|
129
133
|
"react-dom": "~19.2.3",
|
|
130
134
|
"typedoc": "0.28.1",
|
|
131
|
-
"vite": "^8.0.
|
|
132
|
-
"
|
|
133
|
-
"@dxos/echo-db": "0.8.4-main.
|
|
134
|
-
"@dxos/
|
|
135
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
136
|
-
"@dxos/
|
|
135
|
+
"vite": "^8.0.14",
|
|
136
|
+
"vite-plugin-solid": "^2.11.12",
|
|
137
|
+
"@dxos/echo-db": "0.8.4-main.d9fc60f731",
|
|
138
|
+
"@dxos/brand": "0.8.4-main.d9fc60f731",
|
|
139
|
+
"@dxos/storybook-utils": "0.8.4-main.d9fc60f731",
|
|
140
|
+
"@dxos/random": "0.8.4-main.d9fc60f731",
|
|
141
|
+
"@dxos/test-utils": "0.8.4-main.d9fc60f731"
|
|
137
142
|
},
|
|
138
143
|
"peerDependencies": {
|
|
139
144
|
"@effect-atom/atom-react": "^0.5.0",
|
|
140
|
-
"@effect/platform": "0.
|
|
145
|
+
"@effect/platform": "0.96.1",
|
|
141
146
|
"@testing-library/react": "^16.3.0",
|
|
142
|
-
"effect": "3.
|
|
147
|
+
"effect": "3.21.2",
|
|
143
148
|
"react": "~19.2.3",
|
|
144
149
|
"react-dom": "~19.2.3"
|
|
145
150
|
},
|
|
@@ -147,7 +147,7 @@ export const TraceSink = Capability$.make<TraceSinkFactory>('org.dxos.app-framew
|
|
|
147
147
|
* const resolver = yield* Capability.get(Capabilities.ServiceResolver);
|
|
148
148
|
* yield* effect.pipe(
|
|
149
149
|
* Effect.provide(
|
|
150
|
-
* ServiceResolver.provide({ space }, Database.Service,
|
|
150
|
+
* ServiceResolver.provide({ space }, Database.Service, Feed.FeedService).pipe(
|
|
151
151
|
* Layer.provide(Layer.succeed(ServiceResolver.ServiceResolver, resolver)),
|
|
152
152
|
* ),
|
|
153
153
|
* ),
|
package/src/common/index.ts
CHANGED
|
@@ -14,7 +14,7 @@ export const Label = Schema.Union(
|
|
|
14
14
|
Schema.String,
|
|
15
15
|
Schema.mutable(
|
|
16
16
|
Schema.Struct({
|
|
17
|
-
ns: Schema.String,
|
|
17
|
+
ns: Schema.Union(Schema.String, Schema.Array(Schema.String)),
|
|
18
18
|
count: Schema.optional(Schema.Number),
|
|
19
19
|
defaultValue: Schema.optional(Schema.String),
|
|
20
20
|
}),
|
|
@@ -22,6 +22,7 @@ describe('CapabilityManager', () => {
|
|
|
22
22
|
const capabilityManager = CapabilityManager.make({ registry });
|
|
23
23
|
const interfaceDef = Capability.make<{ example: string }>('@dxos/app-framework/test/example');
|
|
24
24
|
expect(() => capabilityManager.get(interfaceDef)).toThrow('No capability found');
|
|
25
|
+
expect(capabilityManager.listRegisteredIdentifiers()).toEqual([]);
|
|
25
26
|
});
|
|
26
27
|
|
|
27
28
|
it.effect('Capability.get should fail when no capability exists', () =>
|
|
@@ -46,6 +47,7 @@ describe('CapabilityManager', () => {
|
|
|
46
47
|
const implementation = { example: 'identifier' };
|
|
47
48
|
capabilityManager.contribute({ interface: interfaceDef, implementation, module: 'test' });
|
|
48
49
|
expect(capabilityManager.getAll(interfaceDef)).toEqual([implementation]);
|
|
50
|
+
expect(capabilityManager.listRegisteredIdentifiers()).toEqual([interfaceDef.identifier]);
|
|
49
51
|
});
|
|
50
52
|
|
|
51
53
|
it('should be able to remove capabilities', () => {
|
|
@@ -57,6 +59,7 @@ describe('CapabilityManager', () => {
|
|
|
57
59
|
expect(capabilityManager.getAll(interfaceDef)).toEqual([implementation]);
|
|
58
60
|
capabilityManager.remove(interfaceDef, implementation);
|
|
59
61
|
expect(capabilityManager.getAll(interfaceDef)).toEqual([]);
|
|
62
|
+
expect(capabilityManager.listRegisteredIdentifiers()).toEqual([]);
|
|
60
63
|
});
|
|
61
64
|
|
|
62
65
|
it('should be able to contribute and request multiple implementations', () => {
|
|
@@ -65,6 +65,11 @@ export interface CapabilityManager {
|
|
|
65
65
|
* @returns An atom containing a record from module ID to capability implementations.
|
|
66
66
|
*/
|
|
67
67
|
atomByModule<T>(interfaceDef: Capability.InterfaceDef<T>): Atom.Atom<Record<string, T[]>>;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Lists capability interface identifiers that currently have at least one contribution.
|
|
71
|
+
*/
|
|
72
|
+
listRegisteredIdentifiers(): string[];
|
|
68
73
|
}
|
|
69
74
|
|
|
70
75
|
/**
|
|
@@ -73,6 +78,8 @@ export interface CapabilityManager {
|
|
|
73
78
|
class CapabilityManagerImpl implements CapabilityManager {
|
|
74
79
|
private readonly _registry: Registry.Registry;
|
|
75
80
|
|
|
81
|
+
private readonly _registeredIdentifiers = new Set<string>();
|
|
82
|
+
|
|
76
83
|
private readonly _capabilityEntries = Atom.family<string, Atom.Writable<CapabilityEntry<unknown>[]>>(() => {
|
|
77
84
|
return Atom.make<CapabilityEntry<unknown>[]>([]).pipe(Atom.keepAlive);
|
|
78
85
|
});
|
|
@@ -125,6 +132,7 @@ class CapabilityManagerImpl implements CapabilityManager {
|
|
|
125
132
|
|
|
126
133
|
const entry: CapabilityEntry<T> = { moduleId, implementation };
|
|
127
134
|
this._registry.set(this._capabilityEntries(interfaceDef.identifier), [...current, entry]);
|
|
135
|
+
this._registeredIdentifiers.add(interfaceDef.identifier);
|
|
128
136
|
log('capability contributed', {
|
|
129
137
|
id: interfaceDef.identifier,
|
|
130
138
|
moduleId,
|
|
@@ -141,6 +149,9 @@ class CapabilityManagerImpl implements CapabilityManager {
|
|
|
141
149
|
const next = current.filter((c) => c.implementation !== implementation);
|
|
142
150
|
if (next.length !== current.length) {
|
|
143
151
|
this._registry.set(this._capabilityEntries(interfaceDef.identifier), next);
|
|
152
|
+
if (next.length === 0) {
|
|
153
|
+
this._registeredIdentifiers.delete(interfaceDef.identifier);
|
|
154
|
+
}
|
|
144
155
|
log('capability removed', { id: interfaceDef.identifier, count: current.length });
|
|
145
156
|
} else {
|
|
146
157
|
log.warn('capability not removed', { id: interfaceDef.identifier });
|
|
@@ -158,10 +169,20 @@ class CapabilityManagerImpl implements CapabilityManager {
|
|
|
158
169
|
|
|
159
170
|
get<T>(interfaceDef: Capability.InterfaceDef<T>): T {
|
|
160
171
|
const capabilities = this.getAll(interfaceDef);
|
|
161
|
-
|
|
172
|
+
if (capabilities.length === 0) {
|
|
173
|
+
log('capability not available', {
|
|
174
|
+
requested: interfaceDef.identifier,
|
|
175
|
+
registered: this.listRegisteredIdentifiers(),
|
|
176
|
+
});
|
|
177
|
+
invariant(capabilities.length > 0, `No capability found for ${interfaceDef.identifier}`);
|
|
178
|
+
}
|
|
162
179
|
return capabilities[0];
|
|
163
180
|
}
|
|
164
181
|
|
|
182
|
+
listRegisteredIdentifiers(): string[] {
|
|
183
|
+
return [...this._registeredIdentifiers].sort();
|
|
184
|
+
}
|
|
185
|
+
|
|
165
186
|
waitFor<T>(interfaceDef: Capability.InterfaceDef<T>): Effect.Effect<T, Error> {
|
|
166
187
|
return Effect.gen(this, function* () {
|
|
167
188
|
const [capability] = this.getAll(interfaceDef);
|
|
@@ -15,6 +15,7 @@ import * as Queue from 'effect/Queue';
|
|
|
15
15
|
import * as TestClock from 'effect/TestClock';
|
|
16
16
|
|
|
17
17
|
import { invariant } from '@dxos/invariant';
|
|
18
|
+
import { DXN } from '@dxos/keys';
|
|
18
19
|
import { type LogConfig, type LogEntry, LogLevel, log } from '@dxos/log';
|
|
19
20
|
|
|
20
21
|
import { ActivationEvents } from '../common';
|
|
@@ -31,7 +32,7 @@ const Total = Capability.make<{ total: number }>('org.dxos.test.total');
|
|
|
31
32
|
const CountEvent = ActivationEvent.make('org.dxos.test.count');
|
|
32
33
|
const FailEvent = ActivationEvent.make('org.dxos.test.fail');
|
|
33
34
|
|
|
34
|
-
const testMeta = {
|
|
35
|
+
const testMeta = Plugin.makeMeta({ key: DXN.make('org.dxos.plugin.test'), name: 'Test' });
|
|
35
36
|
|
|
36
37
|
// TODO(wittjosiah): Factor out?
|
|
37
38
|
const atomCounter = (registry: Registry.Registry, atom: Atom.Atom<any>) => {
|
|
@@ -549,7 +550,7 @@ describe('PluginManager', () => {
|
|
|
549
550
|
|
|
550
551
|
it.effect('should be able to fire custom activation events', () =>
|
|
551
552
|
Effect.gen(function* () {
|
|
552
|
-
const Plugin1 = Plugin.define({
|
|
553
|
+
const Plugin1 = Plugin.define(Plugin.makeMeta({ key: DXN.make('org.dxos.test.plugin1'), name: 'Plugin 1' })).pipe(
|
|
553
554
|
Plugin.addModule({
|
|
554
555
|
activatesOn: CountEvent,
|
|
555
556
|
id: 'Plugin1',
|
|
@@ -557,7 +558,7 @@ describe('PluginManager', () => {
|
|
|
557
558
|
}),
|
|
558
559
|
Plugin.make,
|
|
559
560
|
);
|
|
560
|
-
const Plugin2 = Plugin.define({
|
|
561
|
+
const Plugin2 = Plugin.define(Plugin.makeMeta({ key: DXN.make('org.dxos.test.plugin2'), name: 'Plugin 2' })).pipe(
|
|
561
562
|
Plugin.addModule({
|
|
562
563
|
activatesOn: CountEvent,
|
|
563
564
|
id: 'Plugin2',
|
|
@@ -565,7 +566,7 @@ describe('PluginManager', () => {
|
|
|
565
566
|
}),
|
|
566
567
|
Plugin.make,
|
|
567
568
|
);
|
|
568
|
-
const Plugin3 = Plugin.define({
|
|
569
|
+
const Plugin3 = Plugin.define(Plugin.makeMeta({ key: DXN.make('org.dxos.test.plugin3'), name: 'Plugin 3' })).pipe(
|
|
569
570
|
Plugin.addModule({
|
|
570
571
|
activatesOn: CountEvent,
|
|
571
572
|
id: 'Plugin3',
|
|
@@ -681,7 +682,7 @@ describe('PluginManager', () => {
|
|
|
681
682
|
state.total = numbers.reduce((acc: number, n: { number: number }) => acc + n.number, 0);
|
|
682
683
|
};
|
|
683
684
|
|
|
684
|
-
const Count = Plugin.define({
|
|
685
|
+
const Count = Plugin.define(Plugin.makeMeta({ key: DXN.make('org.dxos.test.count'), name: 'Count' })).pipe(
|
|
685
686
|
Plugin.addModule({
|
|
686
687
|
id: 'Count',
|
|
687
688
|
activatesOn: ActivationEvents.Startup,
|
|
@@ -763,7 +764,7 @@ describe('PluginManager', () => {
|
|
|
763
764
|
|
|
764
765
|
it.effect('should be reactive', () =>
|
|
765
766
|
Effect.gen(function* () {
|
|
766
|
-
const Plugin1 = Plugin.define({
|
|
767
|
+
const Plugin1 = Plugin.define(Plugin.makeMeta({ key: DXN.make('org.dxos.test.plugin1'), name: 'Plugin 1' })).pipe(
|
|
767
768
|
Plugin.addModule({
|
|
768
769
|
activatesOn: CountEvent,
|
|
769
770
|
id: 'Plugin1',
|
|
@@ -771,7 +772,7 @@ describe('PluginManager', () => {
|
|
|
771
772
|
}),
|
|
772
773
|
Plugin.make,
|
|
773
774
|
);
|
|
774
|
-
const Plugin2 = Plugin.define({
|
|
775
|
+
const Plugin2 = Plugin.define(Plugin.makeMeta({ key: DXN.make('org.dxos.test.plugin2'), name: 'Plugin 2' })).pipe(
|
|
775
776
|
Plugin.addModule({
|
|
776
777
|
activatesOn: CountEvent,
|
|
777
778
|
id: 'Plugin2',
|
|
@@ -779,7 +780,7 @@ describe('PluginManager', () => {
|
|
|
779
780
|
}),
|
|
780
781
|
Plugin.make,
|
|
781
782
|
);
|
|
782
|
-
const Plugin3 = Plugin.define({
|
|
783
|
+
const Plugin3 = Plugin.define(Plugin.makeMeta({ key: DXN.make('org.dxos.test.plugin3'), name: 'Plugin 3' })).pipe(
|
|
783
784
|
Plugin.addModule({
|
|
784
785
|
activatesOn: CountEvent,
|
|
785
786
|
id: 'Plugin3',
|
|
@@ -893,7 +894,9 @@ describe('PluginManager', () => {
|
|
|
893
894
|
});
|
|
894
895
|
|
|
895
896
|
const SlowEvent = ActivationEvent.make('org.dxos.test.slow');
|
|
896
|
-
const SlowPlugin = Plugin.define(
|
|
897
|
+
const SlowPlugin = Plugin.define(
|
|
898
|
+
Plugin.makeMeta({ key: DXN.make('org.dxos.test.slowPlugin'), name: 'Slow Plugin' }),
|
|
899
|
+
).pipe(
|
|
897
900
|
Plugin.addModule({
|
|
898
901
|
id: 'SlowModule',
|
|
899
902
|
activatesOn: SlowEvent,
|
|
@@ -940,7 +943,12 @@ describe('PluginManager', () => {
|
|
|
940
943
|
const EventB = ActivationEvent.make('org.dxos.test.event-b');
|
|
941
944
|
|
|
942
945
|
let activateCallCount = 0;
|
|
943
|
-
const ConcurrentPlugin = Plugin.define(
|
|
946
|
+
const ConcurrentPlugin = Plugin.define(
|
|
947
|
+
Plugin.makeMeta({
|
|
948
|
+
key: DXN.make('org.dxos.test.concurrentPlugin'),
|
|
949
|
+
name: 'Concurrent Plugin',
|
|
950
|
+
}),
|
|
951
|
+
).pipe(
|
|
944
952
|
Plugin.addModule({
|
|
945
953
|
id: 'ConcurrentModule',
|
|
946
954
|
// Module activates on either event - this allows two different events to race.
|
|
@@ -987,7 +995,7 @@ describe('PluginManager', () => {
|
|
|
987
995
|
|
|
988
996
|
it.effect('should deactivate all active modules on shutdown', () =>
|
|
989
997
|
Effect.gen(function* () {
|
|
990
|
-
const Plugin1 = Plugin.define({
|
|
998
|
+
const Plugin1 = Plugin.define(Plugin.makeMeta({ key: DXN.make('org.dxos.test.plugin1'), name: 'Plugin 1' })).pipe(
|
|
991
999
|
Plugin.addModule({
|
|
992
1000
|
activatesOn: ActivationEvents.Startup,
|
|
993
1001
|
id: 'Plugin1',
|
|
@@ -995,7 +1003,7 @@ describe('PluginManager', () => {
|
|
|
995
1003
|
}),
|
|
996
1004
|
Plugin.make,
|
|
997
1005
|
);
|
|
998
|
-
const Plugin2 = Plugin.define({
|
|
1006
|
+
const Plugin2 = Plugin.define(Plugin.makeMeta({ key: DXN.make('org.dxos.test.plugin2'), name: 'Plugin 2' })).pipe(
|
|
999
1007
|
Plugin.addModule({
|
|
1000
1008
|
activatesOn: ActivationEvents.Startup,
|
|
1001
1009
|
id: 'Plugin2',
|
|
@@ -1060,7 +1068,7 @@ describe('PluginManager', () => {
|
|
|
1060
1068
|
it.effect('should deactivate modules in reverse activation order during shutdown', () =>
|
|
1061
1069
|
Effect.gen(function* () {
|
|
1062
1070
|
const deactivationOrder: string[] = [];
|
|
1063
|
-
const Plugin1 = Plugin.define({
|
|
1071
|
+
const Plugin1 = Plugin.define(Plugin.makeMeta({ key: DXN.make('org.dxos.test.plugin1'), name: 'Plugin 1' })).pipe(
|
|
1064
1072
|
Plugin.addModule({
|
|
1065
1073
|
activatesOn: ActivationEvents.Startup,
|
|
1066
1074
|
id: 'First',
|
|
@@ -1075,7 +1083,7 @@ describe('PluginManager', () => {
|
|
|
1075
1083
|
}),
|
|
1076
1084
|
Plugin.make,
|
|
1077
1085
|
);
|
|
1078
|
-
const Plugin2 = Plugin.define({
|
|
1086
|
+
const Plugin2 = Plugin.define(Plugin.makeMeta({ key: DXN.make('org.dxos.test.plugin2'), name: 'Plugin 2' })).pipe(
|
|
1079
1087
|
Plugin.addModule({
|
|
1080
1088
|
activatesOn: ActivationEvents.Startup,
|
|
1081
1089
|
id: 'Second',
|
|
@@ -1241,7 +1249,7 @@ describe('PluginManager', () => {
|
|
|
1241
1249
|
);
|
|
1242
1250
|
|
|
1243
1251
|
describe('Plugin.lazy', () => {
|
|
1244
|
-
const lazyMeta = {
|
|
1252
|
+
const lazyMeta = Plugin.makeMeta({ key: DXN.make('org.dxos.plugin.lazy'), name: 'Lazy' });
|
|
1245
1253
|
|
|
1246
1254
|
it('exposes meta synchronously without invoking the loader', () => {
|
|
1247
1255
|
let loaderCalls = 0;
|
|
@@ -1485,7 +1493,12 @@ describe('PluginManager', () => {
|
|
|
1485
1493
|
it.effect('records and auto-disables a plugin whose module exceeds the activation timeout', () =>
|
|
1486
1494
|
Effect.gen(function* () {
|
|
1487
1495
|
const SlowEvent = ActivationEvent.make('org.dxos.test.activation-timeout');
|
|
1488
|
-
const SlowPlugin = Plugin.define(
|
|
1496
|
+
const SlowPlugin = Plugin.define(
|
|
1497
|
+
Plugin.makeMeta({
|
|
1498
|
+
key: DXN.make('org.dxos.test.slowActivation'),
|
|
1499
|
+
name: 'Slow Activation',
|
|
1500
|
+
}),
|
|
1501
|
+
).pipe(
|
|
1489
1502
|
Plugin.addModule({
|
|
1490
1503
|
id: 'Slow',
|
|
1491
1504
|
activatesOn: SlowEvent,
|
|
@@ -1529,7 +1542,7 @@ describe('PluginManager', () => {
|
|
|
1529
1542
|
|
|
1530
1543
|
it.effect('records and auto-disables a lazy plugin whose loader exceeds the load timeout', () =>
|
|
1531
1544
|
Effect.gen(function* () {
|
|
1532
|
-
const lazyMeta = {
|
|
1545
|
+
const lazyMeta = Plugin.makeMeta({ key: DXN.make('org.dxos.test.slowLoad'), name: 'Slow Load' });
|
|
1533
1546
|
// The dynamic import never resolves; the manager's load timeout should
|
|
1534
1547
|
// surface this as a `LazyPluginError` whose `cause` is `PluginTimeoutError`.
|
|
1535
1548
|
const LazyTest = Plugin.lazy(lazyMeta, () => new Promise<{ default: Plugin.PluginFactory }>(() => {}));
|
|
@@ -1573,7 +1586,9 @@ describe('PluginManager', () => {
|
|
|
1573
1586
|
it.effect('records non-timeout activation errors as reason: error', () =>
|
|
1574
1587
|
Effect.gen(function* () {
|
|
1575
1588
|
const FailingEvent = ActivationEvent.make('org.dxos.test.activation-error');
|
|
1576
|
-
const FailingPlugin = Plugin.define(
|
|
1589
|
+
const FailingPlugin = Plugin.define(
|
|
1590
|
+
Plugin.makeMeta({ key: DXN.make('org.dxos.test.failing'), name: 'Failing' }),
|
|
1591
|
+
).pipe(
|
|
1577
1592
|
Plugin.addModule({
|
|
1578
1593
|
id: 'Boom',
|
|
1579
1594
|
activatesOn: FailingEvent,
|
|
@@ -1603,7 +1618,9 @@ describe('PluginManager', () => {
|
|
|
1603
1618
|
it.effect('does not auto-disable a core plugin even though the failure is recorded', () =>
|
|
1604
1619
|
Effect.gen(function* () {
|
|
1605
1620
|
const FailingEvent = ActivationEvent.make('org.dxos.test.core-fail');
|
|
1606
|
-
const CorePlugin = Plugin.define(
|
|
1621
|
+
const CorePlugin = Plugin.define(
|
|
1622
|
+
Plugin.makeMeta({ key: DXN.make('org.dxos.test.core'), name: 'Core', tags: ['system'] }),
|
|
1623
|
+
).pipe(
|
|
1607
1624
|
Plugin.addModule({
|
|
1608
1625
|
id: 'Boom',
|
|
1609
1626
|
activatesOn: FailingEvent,
|
|
@@ -1632,7 +1649,9 @@ describe('PluginManager', () => {
|
|
|
1632
1649
|
Effect.gen(function* () {
|
|
1633
1650
|
let shouldFail = true;
|
|
1634
1651
|
const Event = ActivationEvent.make('org.dxos.test.flaky');
|
|
1635
|
-
const FlakyPlugin = Plugin.define(
|
|
1652
|
+
const FlakyPlugin = Plugin.define(
|
|
1653
|
+
Plugin.makeMeta({ key: DXN.make('org.dxos.test.flaky'), name: 'Flaky' }),
|
|
1654
|
+
).pipe(
|
|
1636
1655
|
Plugin.addModule({
|
|
1637
1656
|
id: 'Maybe',
|
|
1638
1657
|
activatesOn: Event,
|
|
@@ -1674,8 +1693,19 @@ describe('PluginManager', () => {
|
|
|
1674
1693
|
describe('plugin dependencies (dependsOn)', () => {
|
|
1675
1694
|
// Build a small plugin with a `dependsOn` chain. The helper keeps each test
|
|
1676
1695
|
// focused on the dependency semantics rather than module wiring.
|
|
1696
|
+
// These dependency-graph tests use short opaque ids (`'a'`, `'coreClient'`,
|
|
1697
|
+
// `'org.dxos.missing'`) as graph keys rather than real DXNs. `id`/`dependsOn` are
|
|
1698
|
+
// bare strings; only `key` (an unused DXN here) is cast at this test-only boundary.
|
|
1677
1699
|
const makePlugin = (id: string, dependsOn?: string[], tags?: string[]) =>
|
|
1678
|
-
Plugin.make(
|
|
1700
|
+
Plugin.make(
|
|
1701
|
+
Plugin.define({
|
|
1702
|
+
id,
|
|
1703
|
+
key: id as unknown as DXN.DXN,
|
|
1704
|
+
name: id,
|
|
1705
|
+
dependsOn,
|
|
1706
|
+
tags,
|
|
1707
|
+
}),
|
|
1708
|
+
)();
|
|
1679
1709
|
|
|
1680
1710
|
it.effect('enable resolves the transitive closure in dependency-first order', () =>
|
|
1681
1711
|
Effect.gen(function* () {
|
|
@@ -342,7 +342,7 @@ class ManagerImpl implements PluginManager {
|
|
|
342
342
|
// Core plugins are derived from `meta.tags.includes('system')`; the set is
|
|
343
343
|
// a snapshot of the initial `plugins` array (later `add()` calls do not
|
|
344
344
|
// promote plugins to core).
|
|
345
|
-
const core = plugins.filter(({ meta }) => meta.tags?.includes('system')).map(({ meta }) => meta.id);
|
|
345
|
+
const core: string[] = plugins.filter(({ meta }) => meta.tags?.includes('system')).map(({ meta }) => meta.id);
|
|
346
346
|
this.registry = registry ?? Registry.make();
|
|
347
347
|
this.capabilities = CapabilityManager.make({
|
|
348
348
|
registry: this.registry,
|
|
@@ -1121,7 +1121,7 @@ class ManagerImpl implements PluginManager {
|
|
|
1121
1121
|
*/
|
|
1122
1122
|
private _collectDependents(id: string, opts: { transitive: boolean; enabledOnly: boolean }): string[] {
|
|
1123
1123
|
const direct = this._get(this._pluginsAtom)
|
|
1124
|
-
.filter((plugin) => plugin.meta.dependsOn?.
|
|
1124
|
+
.filter((plugin) => plugin.meta.dependsOn?.some((dep) => dep === id))
|
|
1125
1125
|
.map((plugin) => plugin.meta.id);
|
|
1126
1126
|
|
|
1127
1127
|
if (!opts.transitive) {
|
|
@@ -1138,7 +1138,7 @@ class ManagerImpl implements PluginManager {
|
|
|
1138
1138
|
}
|
|
1139
1139
|
visited.add(currentId);
|
|
1140
1140
|
const parents = this._get(this._pluginsAtom)
|
|
1141
|
-
.filter((plugin) => plugin.meta.dependsOn?.
|
|
1141
|
+
.filter((plugin) => plugin.meta.dependsOn?.some((dep) => dep === currentId))
|
|
1142
1142
|
.map((plugin) => plugin.meta.id);
|
|
1143
1143
|
for (const parentId of parents) {
|
|
1144
1144
|
visit(parentId);
|
|
@@ -1344,7 +1344,7 @@ class ManagerImpl implements PluginManager {
|
|
|
1344
1344
|
return Effect.gen(this, function* () {
|
|
1345
1345
|
yield* Ref.update(this._activatingModules, (activating) => Array.appendAll(activating, activatingModuleIds));
|
|
1346
1346
|
|
|
1347
|
-
log('
|
|
1347
|
+
log.info('activation wave', { event: key, modules: activatingModuleIds });
|
|
1348
1348
|
performance.mark(`event:${key}:start`);
|
|
1349
1349
|
yield* PubSub.publish(this.activation, { event: key, state: 'activating' });
|
|
1350
1350
|
|
|
@@ -1582,9 +1582,14 @@ class ManagerImpl implements PluginManager {
|
|
|
1582
1582
|
Effect.tap((result) => Deferred.succeed(deferred, result)),
|
|
1583
1583
|
Effect.catchAllCause((cause) => {
|
|
1584
1584
|
const error = Cause.squash(cause);
|
|
1585
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1586
|
+
const missingCapability = errorMessage.match(/No capability found for ([^\s\[]+)/)?.[1];
|
|
1585
1587
|
log.error('module failed to activate', {
|
|
1586
1588
|
module: module.id,
|
|
1587
|
-
|
|
1589
|
+
parentEvent,
|
|
1590
|
+
missingCapability,
|
|
1591
|
+
registeredCapabilities: this.capabilities.listRegisteredIdentifiers(),
|
|
1592
|
+
error: errorMessage,
|
|
1588
1593
|
stack: error instanceof Error ? error.stack : undefined,
|
|
1589
1594
|
isDefect: !Cause.isFailure(cause),
|
|
1590
1595
|
});
|
package/src/core/plugin.ts
CHANGED
|
@@ -9,6 +9,7 @@ import * as Pipeable from 'effect/Pipeable';
|
|
|
9
9
|
|
|
10
10
|
import { BaseError } from '@dxos/errors';
|
|
11
11
|
import { invariant } from '@dxos/invariant';
|
|
12
|
+
import { DXN } from '@dxos/keys';
|
|
12
13
|
|
|
13
14
|
import type * as ActivationEvent from './activation-event';
|
|
14
15
|
import * as Capability from './capability';
|
|
@@ -149,14 +150,22 @@ class PluginModuleImpl implements PluginModule {
|
|
|
149
150
|
|
|
150
151
|
export type Meta = {
|
|
151
152
|
/**
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* @example org.dxos.plugin.example
|
|
153
|
+
* Bare NSID (the name portion of {@link key}, e.g. `org.dxos.plugin.example`).
|
|
154
|
+
* Stable across versions; used for module-id namespacing, i18n namespaces,
|
|
155
|
+
* enable/disable, and registry lookups. Derived from `key` by {@link makeMeta} —
|
|
156
|
+
* do not set directly.
|
|
157
157
|
*/
|
|
158
158
|
id: string;
|
|
159
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Canonical identity DXN, including version when published
|
|
162
|
+
* (e.g. `dxn:org.dxos.plugin.example:0.8.3`). The validated source of truth
|
|
163
|
+
* from which {@link id} and {@link version} are derived.
|
|
164
|
+
*
|
|
165
|
+
* @example DXN.make('org.dxos.plugin.example', '0.8.3')
|
|
166
|
+
*/
|
|
167
|
+
key: DXN.DXN;
|
|
168
|
+
|
|
160
169
|
/**
|
|
161
170
|
* Human-readable name.
|
|
162
171
|
*/
|
|
@@ -164,7 +173,8 @@ export type Meta = {
|
|
|
164
173
|
|
|
165
174
|
/**
|
|
166
175
|
* Semver version string of the plugin, typically the publishing package's
|
|
167
|
-
* `package.json` version.
|
|
176
|
+
* `package.json` version. Derived from the version segment of {@link key} by
|
|
177
|
+
* {@link makeMeta} — do not set directly.
|
|
168
178
|
*/
|
|
169
179
|
version?: string;
|
|
170
180
|
|
|
@@ -234,6 +244,30 @@ export type Meta = {
|
|
|
234
244
|
dependsOn?: string[];
|
|
235
245
|
};
|
|
236
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Options for {@link makeMeta}: a {@link Meta} minus the fields derived from `key`.
|
|
249
|
+
* Identity and version are specified solely through the `key` DXN — `id` and
|
|
250
|
+
* `version` cannot be passed directly.
|
|
251
|
+
*/
|
|
252
|
+
export type MakeMetaOptions = Omit<Meta, 'id' | 'version'>;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Constructs a plugin {@link Meta} from a single canonical DXN. The `key` DXN is
|
|
256
|
+
* the one source of truth; `id` (bare NSID) and `version` (semver) are derived
|
|
257
|
+
* from it so each datum has exactly one home and cannot drift out of sync.
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* export const meta = Plugin.makeMeta({
|
|
261
|
+
* key: DXN.make('org.dxos.plugin.example', '0.8.3'),
|
|
262
|
+
* name: 'Example',
|
|
263
|
+
* });
|
|
264
|
+
*/
|
|
265
|
+
export const makeMeta = (options: MakeMetaOptions): Meta => ({
|
|
266
|
+
...options,
|
|
267
|
+
id: DXN.getName(options.key),
|
|
268
|
+
version: DXN.getVersion(options.key),
|
|
269
|
+
});
|
|
270
|
+
|
|
237
271
|
/**
|
|
238
272
|
* Identifier denoting a Plugin.
|
|
239
273
|
*/
|
|
@@ -355,14 +389,15 @@ const resolveModule = (
|
|
|
355
389
|
options?: any,
|
|
356
390
|
): PluginModuleImpl => {
|
|
357
391
|
const moduleOptions = typeof module === 'function' ? module(options) : module;
|
|
392
|
+
const pluginName = meta.id;
|
|
358
393
|
const id = Option.fromNullable(moduleOptions.id).pipe(
|
|
359
394
|
Option.match({
|
|
360
395
|
onNone: () => {
|
|
361
396
|
const exportName = Capability.getModuleTag(moduleOptions.activate);
|
|
362
397
|
invariant(exportName, `Plugin module missing name. Plugin: ${meta.id}`);
|
|
363
|
-
return computeModuleId(
|
|
398
|
+
return computeModuleId(pluginName, exportName);
|
|
364
399
|
},
|
|
365
|
-
onSome: (id) => computeModuleId(
|
|
400
|
+
onSome: (id) => computeModuleId(pluginName, id),
|
|
366
401
|
}),
|
|
367
402
|
);
|
|
368
403
|
return new PluginModuleImpl({ ...moduleOptions, id });
|
|
@@ -377,6 +412,7 @@ const resolveModule = (
|
|
|
377
412
|
export function make<T>(builder: PluginBuilder<T>): PluginFactory<T>;
|
|
378
413
|
export function make<T>(builder: PluginBuilder<T>): PluginFactory<T> {
|
|
379
414
|
const meta = builder.meta;
|
|
415
|
+
// `dependsOn` entries and `id` are both bare NSIDs, so compare directly.
|
|
380
416
|
invariant(!meta.dependsOn?.includes(meta.id), `Plugin ${meta.id} declares itself as a dependency.`);
|
|
381
417
|
|
|
382
418
|
const factory = (options: T) => {
|
|
@@ -6,12 +6,13 @@ import { assert, describe, it } from '@effect/vitest';
|
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
|
|
8
8
|
import { runAndForwardErrors } from '@dxos/effect';
|
|
9
|
+
import { DXN } from '@dxos/keys';
|
|
9
10
|
|
|
10
11
|
import * as Plugin from './plugin';
|
|
11
12
|
import * as PluginAssetCache from './plugin-asset-cache';
|
|
12
13
|
import * as UrlLoader from './url-loader';
|
|
13
14
|
|
|
14
|
-
const testMeta = {
|
|
15
|
+
const testMeta = Plugin.makeMeta({ key: DXN.make('org.dxos.plugin.test'), name: 'Test' });
|
|
15
16
|
|
|
16
17
|
const memoryStorage = (initial: string | null = null): UrlLoader.Storage => {
|
|
17
18
|
let value = initial;
|