@dxos/app-framework 0.14.0 → 0.16.0
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/CHANGELOG.md +73 -0
- package/dist/lib/App.mjs +1 -2
- package/dist/lib/Hooks.mjs +1 -2
- package/dist/lib/chunk-App.mjs +11 -0
- package/dist/lib/chunk-App.mjs.map +1 -0
- package/dist/lib/chunk-Cli.mjs +8 -0
- package/dist/lib/chunk-Cli.mjs.map +1 -0
- package/dist/lib/chunk-Devtools.mjs +112 -0
- package/dist/lib/chunk-Devtools.mjs.map +1 -0
- package/dist/lib/chunk-Hooks2.mjs +35 -0
- package/dist/lib/chunk-Hooks2.mjs.map +1 -0
- package/dist/lib/chunk-PluginManagerProvider.mjs +12 -0
- package/dist/lib/chunk-PluginManagerProvider.mjs.map +1 -0
- package/dist/lib/chunk-ProcessManagerPlugin.mjs +3 -3
- package/dist/lib/chunk-ProcessManagerPlugin.mjs.map +1 -1
- package/dist/lib/chunk-Role.mjs +19 -0
- package/dist/lib/chunk-Role.mjs.map +1 -0
- package/dist/lib/chunk-SharedPackages.mjs +11 -0
- package/dist/lib/chunk-SharedPackages.mjs.map +1 -0
- package/dist/lib/chunk-Surface.mjs.map +1 -1
- package/dist/lib/chunk-Surface2.mjs +37 -0
- package/dist/lib/chunk-Surface2.mjs.map +1 -0
- package/dist/lib/chunk-SurfaceManager.mjs +3 -3
- package/dist/lib/chunk-SurfaceManager.mjs.map +1 -1
- package/dist/lib/chunk-activation-event.mjs +86 -0
- package/dist/lib/chunk-activation-event.mjs.map +1 -0
- package/dist/lib/chunk-activation-events.mjs +66 -0
- package/dist/lib/chunk-activation-events.mjs.map +1 -0
- package/dist/lib/chunk-capabilities.mjs +202 -0
- package/dist/lib/chunk-capabilities.mjs.map +1 -0
- package/dist/lib/chunk-capability-manager.mjs +203 -0
- package/dist/lib/chunk-capability-manager.mjs.map +1 -0
- package/dist/lib/chunk-capability2.mjs +2 -2
- package/dist/lib/chunk-capability2.mjs.map +1 -1
- package/dist/lib/chunk-history-tracker.mjs +1 -1
- package/dist/lib/chunk-hooks.mjs +5 -5
- package/dist/lib/chunk-hooks.mjs.map +1 -1
- package/dist/lib/chunk-plugin-asset-cache.mjs +28 -0
- package/dist/lib/chunk-plugin-asset-cache.mjs.map +1 -0
- package/dist/lib/chunk-plugin-manager.mjs +68 -35
- package/dist/lib/chunk-plugin-manager.mjs.map +1 -1
- package/dist/lib/chunk-plugin-manager2.mjs +22 -0
- package/dist/lib/chunk-plugin-manager2.mjs.map +1 -0
- package/dist/lib/chunk-plugin-manifest.mjs +126 -0
- package/dist/lib/chunk-plugin-manifest.mjs.map +1 -0
- package/dist/lib/chunk-plugin.mjs +354 -0
- package/dist/lib/chunk-plugin.mjs.map +1 -0
- package/dist/lib/chunk-process-manager-capability.mjs +11 -10
- package/dist/lib/chunk-process-manager-capability.mjs.map +1 -1
- package/dist/lib/chunk-registry.mjs.map +1 -1
- package/dist/lib/chunk-undo-mapping.mjs +47 -0
- package/dist/lib/{plugin-process-manager/history/undo-mapping.mjs.map → chunk-undo-mapping.mjs.map} +1 -1
- package/dist/lib/chunk-undo-registry.mjs +22 -0
- package/dist/lib/{plugin-process-manager/history/undo-registry.mjs.map → chunk-undo-registry.mjs.map} +1 -1
- package/dist/lib/chunk-url-loader.mjs +345 -0
- package/dist/lib/chunk-url-loader.mjs.map +1 -0
- package/dist/lib/cli.mjs +3 -3
- package/dist/lib/cli.mjs.map +1 -1
- package/dist/lib/common/Role.mjs +1 -19
- package/dist/lib/common/activation-events.mjs +1 -57
- package/dist/lib/common/capabilities.mjs +1 -202
- package/dist/lib/config.mjs +1 -2
- package/dist/lib/core/activation-event.mjs +1 -86
- package/dist/lib/core/capability-manager.mjs +1 -203
- package/dist/lib/core/capability.mjs +1 -2
- package/dist/lib/core/plugin-asset-cache.mjs +1 -28
- package/dist/lib/core/plugin-manager.mjs +2 -19
- package/dist/lib/core/plugin-manifest.mjs +1 -126
- package/dist/lib/core/plugin.mjs +1 -354
- package/dist/lib/core/registry.mjs +1 -2
- package/dist/lib/core/url-loader.mjs +1 -345
- package/dist/lib/index.mjs +19 -19
- package/dist/lib/ns/App.mjs +2 -11
- package/dist/lib/ns/Cli.mjs +2 -8
- package/dist/lib/ns/Devtools.mjs +1 -112
- package/dist/lib/ns/Hooks.mjs +2 -35
- package/dist/lib/ns/PluginManagerProvider.mjs +2 -12
- package/dist/lib/ns/SharedPackages.mjs +2 -11
- package/dist/lib/ns/Surface.mjs +2 -35
- package/dist/lib/ns/Translations.mjs +1 -2
- package/dist/lib/plugin-cli.mjs +2 -4
- package/dist/lib/plugin-cli.mjs.map +1 -1
- package/dist/lib/plugin-process-manager/ProcessManagerPlugin.mjs +1 -2
- package/dist/lib/plugin-process-manager/history/history-tracker.mjs +1 -2
- package/dist/lib/plugin-process-manager/history/undo-mapping.mjs +1 -47
- package/dist/lib/plugin-process-manager/history/undo-registry.mjs +1 -22
- package/dist/lib/testing/react.mjs +1 -1
- package/dist/lib/testing/react.mjs.map +1 -1
- package/dist/lib/testing.mjs +5 -5
- package/dist/lib/testing.mjs.map +1 -1
- package/dist/lib/vite-plugin.mjs +3 -3
- package/dist/lib/vite-plugin.mjs.map +1 -1
- package/dist/types/src/common/activation-events.d.ts +8 -0
- package/dist/types/src/common/activation-events.d.ts.map +1 -1
- package/dist/types/src/core/plugin-manager/manager-state.d.ts.map +1 -1
- package/dist/types/src/core/plugin-manager/module-loader.d.ts +0 -10
- package/dist/types/src/core/plugin-manager/module-loader.d.ts.map +1 -1
- package/dist/types/src/core/plugin-manager/plugin-manager.d.ts.map +1 -1
- package/dist/types/src/plugin-process-manager/process-manager-capability.d.ts.map +1 -1
- package/dist/types/src/ui/components/Surface/SurfaceComponent.stories.d.ts.map +1 -1
- package/dist/types/src/ui/hooks/useApp.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +32 -32
- package/src/common/activation-events.ts +9 -0
- package/src/core/plugin-manager/manager-state.ts +14 -12
- package/src/core/plugin-manager/module-loader.ts +43 -7
- package/src/core/plugin-manager/plugin-manager.ts +2 -1
- package/src/plugin-process-manager/process-manager-capability.test.ts +66 -1
- package/src/plugin-process-manager/process-manager-capability.ts +22 -2
- package/src/ui/components/Surface/SurfaceComponent.stories.tsx +9 -7
- package/src/ui/hooks/useApp.tsx +2 -1
- package/src/vite-plugin/boot-loader/loader-app/boot-loader.css +19 -1
- package/dist/lib/common/Role.mjs.map +0 -1
- package/dist/lib/common/activation-events.mjs.map +0 -1
- package/dist/lib/common/capabilities.mjs.map +0 -1
- package/dist/lib/core/activation-event.mjs.map +0 -1
- package/dist/lib/core/capability-manager.mjs.map +0 -1
- package/dist/lib/core/plugin-asset-cache.mjs.map +0 -1
- package/dist/lib/core/plugin-manager.mjs.map +0 -1
- package/dist/lib/core/plugin-manifest.mjs.map +0 -1
- package/dist/lib/core/plugin.mjs.map +0 -1
- package/dist/lib/core/url-loader.mjs.map +0 -1
- package/dist/lib/ns/App.mjs.map +0 -1
- package/dist/lib/ns/Cli.mjs.map +0 -1
- package/dist/lib/ns/Devtools.mjs.map +0 -1
- package/dist/lib/ns/Hooks.mjs.map +0 -1
- package/dist/lib/ns/PluginManagerProvider.mjs.map +0 -1
- package/dist/lib/ns/SharedPackages.mjs.map +0 -1
- package/dist/lib/ns/Surface.mjs.map +0 -1
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
|
|
2
|
+
import { S as makeSingleton, b as make, g as getOption, p as get } from "./chunk-capability.mjs";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Option from "effect/Option";
|
|
5
|
+
//#region src/common/capabilities.ts
|
|
6
|
+
var capabilities_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
AtomRegistry: () => AtomRegistry,
|
|
8
|
+
Command: () => Command,
|
|
9
|
+
HistoryTracker: () => HistoryTracker,
|
|
10
|
+
Layer: () => Layer,
|
|
11
|
+
LayerSpec: () => LayerSpec,
|
|
12
|
+
ManagedRuntime: () => ManagedRuntime,
|
|
13
|
+
OperationHandler: () => OperationHandler,
|
|
14
|
+
OperationHandlers: () => OperationHandlers,
|
|
15
|
+
OperationInvoker: () => OperationInvoker,
|
|
16
|
+
PluginManager: () => PluginManager,
|
|
17
|
+
ProcessManager: () => ProcessManager,
|
|
18
|
+
ProcessManagerRuntime: () => ProcessManagerRuntime,
|
|
19
|
+
ReactContext: () => ReactContext,
|
|
20
|
+
ReactRoot: () => ReactRoot,
|
|
21
|
+
ReactSurface: () => ReactSurface,
|
|
22
|
+
RemoteTraceMonitor: () => RemoteTraceMonitor,
|
|
23
|
+
ServiceResolver: () => ServiceResolver,
|
|
24
|
+
TraceSink: () => TraceSink,
|
|
25
|
+
UndoMapping: () => UndoMapping,
|
|
26
|
+
UndoRegistry: () => UndoRegistry,
|
|
27
|
+
getAtomValue: () => getAtomValue,
|
|
28
|
+
getAtomValueOption: () => getAtomValueOption,
|
|
29
|
+
subscribeAtom: () => subscribeAtom,
|
|
30
|
+
updateAtomValue: () => updateAtomValue
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* @category Capability
|
|
34
|
+
*/
|
|
35
|
+
var PluginManager = makeSingleton()("org.dxos.app-framework.capability.pluginManager");
|
|
36
|
+
/**
|
|
37
|
+
* @category Capability
|
|
38
|
+
*/
|
|
39
|
+
var AtomRegistry = makeSingleton()("org.dxos.app-framework.capability.atomRegistry");
|
|
40
|
+
/**
|
|
41
|
+
* @category Capability
|
|
42
|
+
*/
|
|
43
|
+
var ReactContext = make()("org.dxos.app-framework.capability.reactContext");
|
|
44
|
+
/**
|
|
45
|
+
* @category Capability
|
|
46
|
+
*/
|
|
47
|
+
var ReactRoot = make()("org.dxos.app-framework.capability.reactRoot");
|
|
48
|
+
/**
|
|
49
|
+
* @category Capability
|
|
50
|
+
*/
|
|
51
|
+
var ReactSurface = make()("org.dxos.app-framework.capability.reactSurface");
|
|
52
|
+
/**
|
|
53
|
+
* @category Capability
|
|
54
|
+
*/
|
|
55
|
+
var Command = make()("org.dxos.app-framework.capability.command");
|
|
56
|
+
/**
|
|
57
|
+
* @category Capability
|
|
58
|
+
*/
|
|
59
|
+
var Layer = make()("org.dxos.app-framework.capability.layer");
|
|
60
|
+
/**
|
|
61
|
+
* Layer specification contributed by plugins.
|
|
62
|
+
*
|
|
63
|
+
* Plugins contribute {@link LayerSpec.LayerSpec} entries that are collected by the
|
|
64
|
+
* process-manager module and composed into a {@link LayerStack} which backs the
|
|
65
|
+
* {@link ProcessManagerRuntime}'s service resolver.
|
|
66
|
+
*
|
|
67
|
+
* @category Capability
|
|
68
|
+
*/
|
|
69
|
+
var LayerSpec = make()("org.dxos.app-framework.capability.layerSpec");
|
|
70
|
+
/**
|
|
71
|
+
* Trace sink contribution.
|
|
72
|
+
*
|
|
73
|
+
* Plugins contribute {@link TraceSinkFactory} functions; the process-manager
|
|
74
|
+
* capability invokes each factory with the runtime's
|
|
75
|
+
* {@link ServiceResolver$.ServiceResolver}, collects the resulting
|
|
76
|
+
* {@link Trace$.Sink}s, merges them via {@link Trace$.mergeSinks}, and
|
|
77
|
+
* installs the merged sink as {@link Trace$.TraceSink} in the runtime layer
|
|
78
|
+
* so every process writes to every contributed sink.
|
|
79
|
+
*
|
|
80
|
+
* @category Capability
|
|
81
|
+
*/
|
|
82
|
+
var TraceSink = make()("org.dxos.app-framework.capability.traceSink");
|
|
83
|
+
/**
|
|
84
|
+
* Source of ephemeral trace messages broadcast by remote runtimes over the space swarm (DX-1125).
|
|
85
|
+
* Contributed by a client-aware plugin; the process-manager capability wires the first contribution
|
|
86
|
+
* (or a no-op) into the aggregate {@link ProcessManager} so its `subscribeToTraceMessages` surfaces
|
|
87
|
+
* remote progress alongside local.
|
|
88
|
+
*
|
|
89
|
+
* @category Capability
|
|
90
|
+
*/
|
|
91
|
+
var RemoteTraceMonitor = make()("org.dxos.app-framework.capability.remoteTraceMonitor");
|
|
92
|
+
/**
|
|
93
|
+
* Service resolver backing the shared {@link ProcessManagerRuntime}.
|
|
94
|
+
*
|
|
95
|
+
* Contributed by the process-manager capability module. Consumers can combine
|
|
96
|
+
* it with {@link ServiceResolver$.provide} to build space-scoped layers without
|
|
97
|
+
* having to go through the process-manager runtime:
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* const resolver = yield* Capability.get(Capabilities.ServiceResolver);
|
|
102
|
+
* yield* effect.pipe(
|
|
103
|
+
* Effect.provide(
|
|
104
|
+
* ServiceResolver.provide({ space }, Database.Service).pipe(
|
|
105
|
+
* Layer.provide(Layer.succeed(ServiceResolver.ServiceResolver, resolver)),
|
|
106
|
+
* ),
|
|
107
|
+
* ),
|
|
108
|
+
* );
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* @category Capability
|
|
112
|
+
*/
|
|
113
|
+
var ServiceResolver = makeSingleton()("org.dxos.app-framework.capability.serviceResolver");
|
|
114
|
+
/**
|
|
115
|
+
* Process manager backing the shared {@link ProcessManagerRuntime}. Exposes the
|
|
116
|
+
* live process tree (including inactive/terminated entries) via
|
|
117
|
+
* {@link Process.Manager#processTreeAtom}.
|
|
118
|
+
*
|
|
119
|
+
* @category Capability
|
|
120
|
+
*/
|
|
121
|
+
var ProcessManager = makeSingleton()("org.dxos.app-framework.capability.processManager");
|
|
122
|
+
/**
|
|
123
|
+
* @category Capability
|
|
124
|
+
*/
|
|
125
|
+
var ProcessManagerRuntime = makeSingleton()("org.dxos.app-framework.capability.processManagerRuntime");
|
|
126
|
+
/**
|
|
127
|
+
* @category Capability
|
|
128
|
+
*/
|
|
129
|
+
var ManagedRuntime = makeSingleton()("org.dxos.app-framework.capability.managedRuntime");
|
|
130
|
+
var OperationHandler = make()("org.dxos.app-framework.capability.operationHandler");
|
|
131
|
+
/**
|
|
132
|
+
* Merged, contribution-ordered view over all {@link OperationHandler} contributions — the same
|
|
133
|
+
* set the operation invoker resolves against. Provided by ProcessManagerPlugin.
|
|
134
|
+
* @category Capability
|
|
135
|
+
*/
|
|
136
|
+
var OperationHandlers = makeSingleton()("org.dxos.app-framework.capability.operationHandlers");
|
|
137
|
+
/**
|
|
138
|
+
* Undo mapping registration - contributed by plugins.
|
|
139
|
+
* @category Capability
|
|
140
|
+
*/
|
|
141
|
+
var UndoMapping = make()("org.dxos.app-framework.capability.undoMapping");
|
|
142
|
+
/**
|
|
143
|
+
* Operation invoker - provided by the process-manager capability.
|
|
144
|
+
* @category Capability
|
|
145
|
+
*/
|
|
146
|
+
var OperationInvoker = makeSingleton()("org.dxos.app-framework.capability.operationInvoker");
|
|
147
|
+
/**
|
|
148
|
+
* Undo registry - provided by ProcessManagerPlugin.
|
|
149
|
+
* @category Capability
|
|
150
|
+
*/
|
|
151
|
+
var UndoRegistry = makeSingleton()("org.dxos.app-framework.capability.undoRegistry");
|
|
152
|
+
/**
|
|
153
|
+
* History tracker - provided by ProcessManagerPlugin.
|
|
154
|
+
* @category Capability
|
|
155
|
+
*/
|
|
156
|
+
var HistoryTracker = makeSingleton()("org.dxos.app-framework.capability.historyTracker");
|
|
157
|
+
/**
|
|
158
|
+
* Get the current value of an atom capability.
|
|
159
|
+
* @example const settings = yield* Capabilities.getAtomValue(CommentCapabilities.Settings);
|
|
160
|
+
*/
|
|
161
|
+
var getAtomValue = (atomCapability) => Effect.gen(function* () {
|
|
162
|
+
const registry = yield* get(AtomRegistry);
|
|
163
|
+
const atom = yield* get(atomCapability);
|
|
164
|
+
return registry.get(atom);
|
|
165
|
+
});
|
|
166
|
+
/**
|
|
167
|
+
* Get the current value of an atom capability, or `Option.none()` when either the registry or the
|
|
168
|
+
* atom itself is uncontributed.
|
|
169
|
+
*
|
|
170
|
+
* For operations that run on both the app and a headless host (the edge operation-service, `dx mcp
|
|
171
|
+
* serve`): those hosts have a capability manager but activate no UI plugins, so {@link getAtomValue}
|
|
172
|
+
* fails on capabilities like `Layout` that only the app contributes.
|
|
173
|
+
*
|
|
174
|
+
* @example const layout = yield* Capabilities.getAtomValueOption(AppCapabilities.Layout);
|
|
175
|
+
*/
|
|
176
|
+
var getAtomValueOption = (atomCapability) => Effect.gen(function* () {
|
|
177
|
+
const registry = yield* getOption(AtomRegistry);
|
|
178
|
+
const atom = yield* getOption(atomCapability);
|
|
179
|
+
return Option.map(Option.all([registry, atom]), ([registry, atom]) => registry.get(atom));
|
|
180
|
+
});
|
|
181
|
+
/**
|
|
182
|
+
* Update an atom capability value (requires writable atom).
|
|
183
|
+
* @example yield* Capabilities.updateAtomValue(CommentCapabilities.Settings, (s) => ({ ...s, foo: true }));
|
|
184
|
+
*/
|
|
185
|
+
var updateAtomValue = (atomCapability, fn) => Effect.gen(function* () {
|
|
186
|
+
const registry = yield* get(AtomRegistry);
|
|
187
|
+
const atom = yield* get(atomCapability);
|
|
188
|
+
registry.set(atom, fn(registry.get(atom)));
|
|
189
|
+
});
|
|
190
|
+
/**
|
|
191
|
+
* Subscribe to an atom capability.
|
|
192
|
+
* @example const unsubscribe = yield* Capabilities.subscribeAtom(CommentCapabilities.Settings, (value) => ...);
|
|
193
|
+
*/
|
|
194
|
+
var subscribeAtom = (atomCapability, callback) => Effect.gen(function* () {
|
|
195
|
+
const registry = yield* get(AtomRegistry);
|
|
196
|
+
const atom = yield* get(atomCapability);
|
|
197
|
+
return registry.subscribe(atom, () => callback(registry.get(atom)));
|
|
198
|
+
});
|
|
199
|
+
//#endregion
|
|
200
|
+
export { getAtomValueOption as C, getAtomValue as S, updateAtomValue as T, ServiceResolver as _, LayerSpec as a, UndoRegistry as b, OperationHandlers as c, ProcessManager as d, ProcessManagerRuntime as f, RemoteTraceMonitor as g, ReactSurface as h, Layer as i, OperationInvoker as l, ReactRoot as m, Command as n, ManagedRuntime as o, ReactContext as p, HistoryTracker as r, OperationHandler as s, AtomRegistry as t, PluginManager as u, TraceSink as v, subscribeAtom as w, capabilities_exports as x, UndoMapping as y };
|
|
201
|
+
|
|
202
|
+
//# sourceMappingURL=chunk-capabilities.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-capabilities.mjs","names":["Capability$.makeSingleton","Capability$.make","Capability$.get","Capability$.getOption"],"sources":["../../src/common/capabilities.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Command$ from 'effect/cli/Command';\nimport * as Effect from 'effect/Effect';\nimport type * as Exit$ from 'effect/Exit';\nimport type * as Fiber$ from 'effect/Fiber';\nimport type * as Layer$ from 'effect/Layer';\nimport type * as ManagedRuntime$ from 'effect/ManagedRuntime';\nimport * as Option from 'effect/Option';\nimport type * as Atom from 'effect/reactivity/Atom';\nimport type * as Registry from 'effect/reactivity/AtomRegistry';\nimport type { FC, PropsWithChildren } from 'react';\n\nimport type {\n ProcessManager as ProcessManager$,\n RemoteTraceMonitor as RemoteTraceMonitor$,\n} from '@dxos/compute-runtime';\nimport * as ComputeLayerSpec from '@dxos/compute/LayerSpec';\nimport * as Operation from '@dxos/compute/Operation';\nimport * as OperationHandlerSet from '@dxos/compute/OperationHandlerSet';\nimport * as Process from '@dxos/compute/Process';\nimport * as ComputeServiceResolver from '@dxos/compute/ServiceResolver';\nimport * as Trace from '@dxos/compute/Trace';\nimport { OperationInvoker as OperationInvoker$ } from '@dxos/operation';\n\nimport { Capability as Capability$, Plugin as Plugin$, type PluginManager as PluginManager$ } from '../core/index.ts';\nimport type {\n HistoryTracker as HistoryTracker$,\n UndoMapping as UndoMapping$,\n UndoRegistry as UndoRegistry$,\n} from '../plugin-process-manager/index.ts';\nimport type { Surface } from '../ui/index.ts';\n\n/**\n * @category Capability\n */\nexport const PluginManager = Capability$.makeSingleton<PluginManager$.PluginManager>()(\n 'org.dxos.app-framework.capability.pluginManager',\n);\n\n/**\n * @category Capability\n */\nexport const AtomRegistry = Capability$.makeSingleton<Registry.AtomRegistry>()(\n 'org.dxos.app-framework.capability.atomRegistry',\n);\n\nexport type ReactContext = Readonly<{\n id: string;\n dependsOn?: string[];\n context: FC<PropsWithChildren>;\n}>;\n\n/**\n * @category Capability\n */\nexport const ReactContext = Capability$.make<ReactContext>()('org.dxos.app-framework.capability.reactContext');\n\nexport type ReactRoot = Readonly<{ id: string; root: FC<PropsWithChildren> }>;\n\n/**\n * @category Capability\n */\nexport const ReactRoot = Capability$.make<ReactRoot>()('org.dxos.app-framework.capability.reactRoot');\n\n/**\n * Surface definitions that can be either React components or Web Components.\n */\nexport type ReactSurface = Surface.Definition | readonly Surface.Definition[];\n\n/**\n * @category Capability\n */\nexport const ReactSurface = Capability$.make<ReactSurface>()('org.dxos.app-framework.capability.reactSurface');\n\n// The requirement channel stays open: a command's services are supplied partly by the contributing\n// plugin and partly by the host — `CommandConfig` carries the host's global flags and is provided as\n// an ambient layer by the host binary — so no single side can discharge them all. `CommandServices`\n// in @dxos/cli-util names what a host owes; hosts should type their layer with it.\nexport type AnyCommand = Command$.Command<any, any, any, any, any>;\n\n/**\n * @category Capability\n */\nexport const Command = Capability$.make<AnyCommand>()('org.dxos.app-framework.capability.command');\n\n/**\n * @category Capability\n */\n// The input channel is closed: a contributed layer is merged into whatever a host is assembling, so\n// it has to carry its own requirements rather than expect the host to satisfy them.\nexport const Layer = Capability$.make<Layer$.Layer<any, any, never>>()('org.dxos.app-framework.capability.layer');\n\n/**\n * Layer specification contributed by plugins.\n *\n * Plugins contribute {@link LayerSpec.LayerSpec} entries that are collected by the\n * process-manager module and composed into a {@link LayerStack} which backs the\n * {@link ProcessManagerRuntime}'s service resolver.\n *\n * @category Capability\n */\nexport const LayerSpec = Capability$.make<ComputeLayerSpec.LayerSpec>()('org.dxos.app-framework.capability.layerSpec');\n\n/**\n * Context passed to {@link TraceSinkFactory} implementations when the\n * process-manager capability materialises contributed sinks.\n */\nexport interface TraceSinkFactoryContext {\n /**\n * Service resolver backing the shared {@link ProcessManagerRuntime}. Use it\n * to resolve per-space (or per-process) services like `FeedTraceSink` when\n * building a routing sink.\n */\n readonly resolver: ComputeServiceResolver.ServiceResolver;\n}\n\n/**\n * Factory that builds a {@link Trace$.Sink} when the process-manager\n * capability is ready. Plugins that only need a static sink can ignore the\n * context (e.g. `() => myConsoleSink`); plugins that need per-space routing\n * can use {@link TraceSinkFactoryContext.resolver} to look up services.\n */\nexport type TraceSinkFactory = (ctx: TraceSinkFactoryContext) => Trace.Sink;\n\n/**\n * Trace sink contribution.\n *\n * Plugins contribute {@link TraceSinkFactory} functions; the process-manager\n * capability invokes each factory with the runtime's\n * {@link ServiceResolver$.ServiceResolver}, collects the resulting\n * {@link Trace$.Sink}s, merges them via {@link Trace$.mergeSinks}, and\n * installs the merged sink as {@link Trace$.TraceSink} in the runtime layer\n * so every process writes to every contributed sink.\n *\n * @category Capability\n */\nexport const TraceSink = Capability$.make<TraceSinkFactory>()('org.dxos.app-framework.capability.traceSink');\n\n/**\n * Source of ephemeral trace messages broadcast by remote runtimes over the space swarm (DX-1125).\n * Contributed by a client-aware plugin; the process-manager capability wires the first contribution\n * (or a no-op) into the aggregate {@link ProcessManager} so its `subscribeToTraceMessages` surfaces\n * remote progress alongside local.\n *\n * @category Capability\n */\nexport const RemoteTraceMonitor = Capability$.make<RemoteTraceMonitor$.Monitor>()(\n 'org.dxos.app-framework.capability.remoteTraceMonitor',\n);\n\n/**\n * Service resolver backing the shared {@link ProcessManagerRuntime}.\n *\n * Contributed by the process-manager capability module. Consumers can combine\n * it with {@link ServiceResolver$.provide} to build space-scoped layers without\n * having to go through the process-manager runtime:\n *\n * @example\n * ```ts\n * const resolver = yield* Capability.get(Capabilities.ServiceResolver);\n * yield* effect.pipe(\n * Effect.provide(\n * ServiceResolver.provide({ space }, Database.Service).pipe(\n * Layer.provide(Layer.succeed(ServiceResolver.ServiceResolver, resolver)),\n * ),\n * ),\n * );\n * ```\n *\n * @category Capability\n */\nexport const ServiceResolver = Capability$.makeSingleton<ComputeServiceResolver.ServiceResolver>()(\n 'org.dxos.app-framework.capability.serviceResolver',\n);\n\n/**\n * Process manager backing the shared {@link ProcessManagerRuntime}. Exposes the\n * live process tree (including inactive/terminated entries) via\n * {@link Process.Manager#processTreeAtom}.\n *\n * @category Capability\n */\nexport const ProcessManager = Capability$.makeSingleton<Process.Manager>()(\n 'org.dxos.app-framework.capability.processManager',\n);\n\n/**\n * Services that are always available when running effects through a {@link ProcessManagerRuntime}.\n */\nexport type ProcessManagerRuntimeServices =\n | Capability$.Service\n | Plugin$.Service\n | ProcessManager$.ProcessManagerService\n | Operation.Service\n | ComputeServiceResolver.ServiceResolver;\n\n/**\n * Runtime that runs effects requiring a fixed set of capability-manager and\n * process-manager services.\n *\n * The shape mirrors {@link ManagedRuntime$.ManagedRuntime} but deliberately does\n * not expose `dispose` – lifecycle is driven by the host plugin manager.\n */\nexport interface ProcessManagerRuntime {\n runPromise<A, E>(\n effect: Effect.Effect<A, E, ProcessManagerRuntimeServices>,\n options?: { readonly signal?: AbortSignal },\n ): Promise<A>;\n runPromiseExit<A, E>(\n effect: Effect.Effect<A, E, ProcessManagerRuntimeServices>,\n options?: { readonly signal?: AbortSignal },\n ): Promise<Exit$.Exit<A, E>>;\n runFork<A, E>(\n effect: Effect.Effect<A, E, ProcessManagerRuntimeServices>,\n options?: Effect.RunOptions,\n ): Fiber$.Fiber<A, E>;\n runSync<A, E>(effect: Effect.Effect<A, E, ProcessManagerRuntimeServices>): A;\n}\n\n/**\n * @category Capability\n */\nexport const ProcessManagerRuntime = Capability$.makeSingleton<ProcessManagerRuntime>()(\n 'org.dxos.app-framework.capability.processManagerRuntime',\n);\n\nexport type ManagedRuntime = ManagedRuntime$.ManagedRuntime<any, any>;\n\n/**\n * @category Capability\n */\nexport const ManagedRuntime = Capability$.makeSingleton<ManagedRuntime>()(\n 'org.dxos.app-framework.capability.managedRuntime',\n);\n\n//\n// Operation System Capabilities\n//\n\nexport const OperationHandler = Capability$.make<OperationHandlerSet.OperationHandlerSet>()(\n 'org.dxos.app-framework.capability.operationHandler',\n);\n\n/**\n * Merged, contribution-ordered view over all {@link OperationHandler} contributions — the same\n * set the operation invoker resolves against. Provided by ProcessManagerPlugin.\n * @category Capability\n */\nexport const OperationHandlers = Capability$.makeSingleton<OperationHandlerSet.OperationHandlerSet>()(\n 'org.dxos.app-framework.capability.operationHandlers',\n);\n\nexport type UndoMapping = UndoMapping$.UndoMapping;\n\n/**\n * Undo mapping registration - contributed by plugins.\n * @category Capability\n */\nexport const UndoMapping = Capability$.make<UndoMapping[]>()('org.dxos.app-framework.capability.undoMapping');\n\n/**\n * Operation invoker backed by the process manager. Spawns a process per\n * operation invocation; see `ProcessOperationInvoker` in `@dxos/compute-runtime`.\n */\nexport type OperationInvoker = OperationInvoker$.OperationInvoker;\n\n/**\n * Operation invoker - provided by the process-manager capability.\n * @category Capability\n */\nexport const OperationInvoker = Capability$.makeSingleton<OperationInvoker>()(\n 'org.dxos.app-framework.capability.operationInvoker',\n);\n\nexport type UndoRegistry = UndoRegistry$.UndoRegistry;\n\n/**\n * Undo registry - provided by ProcessManagerPlugin.\n * @category Capability\n */\nexport const UndoRegistry = Capability$.makeSingleton<UndoRegistry>()('org.dxos.app-framework.capability.undoRegistry');\n\nexport type HistoryTracker = HistoryTracker$.HistoryTracker;\n\n/**\n * History tracker - provided by ProcessManagerPlugin.\n * @category Capability\n */\nexport const HistoryTracker = Capability$.makeSingleton<HistoryTracker>()(\n 'org.dxos.app-framework.capability.historyTracker',\n);\n\n//\n// Atom Capability Helpers\n//\n\n/**\n * Get the current value of an atom capability.\n * @example const settings = yield* Capabilities.getAtomValue(CommentCapabilities.Settings);\n */\nexport const getAtomValue = <T>(\n atomCapability: Capability$.InterfaceDef<Atom.Atom<T>>,\n): Effect.Effect<T, Error, Capability$.Service> =>\n Effect.gen(function* () {\n const registry = yield* Capability$.get(AtomRegistry);\n const atom = yield* Capability$.get(atomCapability);\n return registry.get(atom);\n });\n\n/**\n * Get the current value of an atom capability, or `Option.none()` when either the registry or the\n * atom itself is uncontributed.\n *\n * For operations that run on both the app and a headless host (the edge operation-service, `dx mcp\n * serve`): those hosts have a capability manager but activate no UI plugins, so {@link getAtomValue}\n * fails on capabilities like `Layout` that only the app contributes.\n *\n * @example const layout = yield* Capabilities.getAtomValueOption(AppCapabilities.Layout);\n */\nexport const getAtomValueOption = <T>(\n atomCapability: Capability$.InterfaceDef<Atom.Atom<T>>,\n): Effect.Effect<Option.Option<T>, never, Capability$.Service> =>\n Effect.gen(function* () {\n const registry = yield* Capability$.getOption(AtomRegistry);\n const atom = yield* Capability$.getOption(atomCapability);\n return Option.map(Option.all([registry, atom]), ([registry, atom]) => registry.get(atom));\n });\n\n/**\n * Update an atom capability value (requires writable atom).\n * @example yield* Capabilities.updateAtomValue(CommentCapabilities.Settings, (s) => ({ ...s, foo: true }));\n */\nexport const updateAtomValue = <T>(\n atomCapability: Capability$.InterfaceDef<Atom.Writable<T>>,\n fn: (current: T) => T,\n): Effect.Effect<void, Error, Capability$.Service> =>\n Effect.gen(function* () {\n const registry = yield* Capability$.get(AtomRegistry);\n const atom = yield* Capability$.get(atomCapability);\n registry.set(atom, fn(registry.get(atom)));\n });\n\n/**\n * Subscribe to an atom capability.\n * @example const unsubscribe = yield* Capabilities.subscribeAtom(CommentCapabilities.Settings, (value) => ...);\n */\nexport const subscribeAtom = <T>(\n atomCapability: Capability$.InterfaceDef<Atom.Atom<T>>,\n callback: (value: T) => void,\n): Effect.Effect<() => void, Error, Capability$.Service> =>\n Effect.gen(function* () {\n const registry = yield* Capability$.get(AtomRegistry);\n const atom = yield* Capability$.get(atomCapability);\n return registry.subscribe(atom, () => callback(registry.get(atom)));\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,IAAa,gBAAgBA,cAAwD,CAAC,CACpF,iDACF;;;;AAKA,IAAa,eAAeA,cAAiD,CAAC,CAC5E,gDACF;;;;AAWA,IAAa,eAAeC,KAA+B,CAAC,CAAC,gDAAgD;;;;AAO7G,IAAa,YAAYA,KAA4B,CAAC,CAAC,6CAA6C;;;;AAUpG,IAAa,eAAeA,KAA+B,CAAC,CAAC,gDAAg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CAAC;AAC1F,CAAC;;;;;AAMH,IAAa,mBACX,gBACA,OAEA,OAAO,IAAI,aAAa;CACtB,MAAM,WAAW,OAAOD,IAAgB,YAAY;CACpD,MAAM,OAAO,OAAOA,IAAgB,cAAc;CAClD,SAAS,IAAI,MAAM,GAAG,SAAS,IAAI,IAAI,CAAC,CAAC;AAC3C,CAAC;;;;;AAMH,IAAa,iBACX,gBACA,aAEA,OAAO,IAAI,aAAa;CACtB,MAAM,WAAW,OAAOA,IAAgB,YAAY;CACpD,MAAM,OAAO,OAAOA,IAAgB,cAAc;CAClD,OAAO,SAAS,UAAU,YAAY,SAAS,SAAS,IAAI,IAAI,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
|
|
2
|
+
import { T as CapabilityNotFoundError, n as ContributionTypeId } from "./chunk-capability.mjs";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as EffectEx from "@dxos/effect/EffectEx";
|
|
5
|
+
import { log } from "@dxos/log";
|
|
6
|
+
import * as Deferred from "effect/Deferred";
|
|
7
|
+
import * as Atom from "effect/reactivity/Atom";
|
|
8
|
+
//#region src/core/capability-manager.ts
|
|
9
|
+
var capability_manager_exports = /* @__PURE__ */ __exportAll({
|
|
10
|
+
expandContributions: () => expandContributions,
|
|
11
|
+
isContribution: () => isContribution,
|
|
12
|
+
make: () => make,
|
|
13
|
+
normalizeActivateResult: () => normalizeActivateResult
|
|
14
|
+
});
|
|
15
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/capability-manager.ts";
|
|
16
|
+
/**
|
|
17
|
+
* Type guard to check if a value is a {@link Capability.Contribution}.
|
|
18
|
+
*/
|
|
19
|
+
var isContribution = (value) => {
|
|
20
|
+
return typeof value === "object" && value !== null && ContributionTypeId in value;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Normalizes a module activate result into a flat list of items (legacy capabilities and
|
|
24
|
+
* typed contributions).
|
|
25
|
+
*/
|
|
26
|
+
var normalizeActivateResult = (result) => {
|
|
27
|
+
if (result == null) return [];
|
|
28
|
+
return Array.isArray(result) ? [...result] : [result];
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Expands typed contributions into per-value capability entries; legacy capability entries
|
|
32
|
+
* pass through.
|
|
33
|
+
*/
|
|
34
|
+
var expandContributions = (items) => items.flatMap((item) => isContribution(item) ? item.values.map((value) => ({
|
|
35
|
+
interface: item.capability,
|
|
36
|
+
implementation: value
|
|
37
|
+
})) : [item]);
|
|
38
|
+
/**
|
|
39
|
+
* Internal implementation of CapabilityManager.
|
|
40
|
+
*/
|
|
41
|
+
var CapabilityManagerImpl = class {
|
|
42
|
+
_registry;
|
|
43
|
+
_registeredIdentifiers = /* @__PURE__ */ new Set();
|
|
44
|
+
_contributionsViews = /* @__PURE__ */ new Map();
|
|
45
|
+
/** In-flight {@link waitForPromise} results, keyed by interface identifier. */
|
|
46
|
+
_waitPromises = /* @__PURE__ */ new Map();
|
|
47
|
+
_capabilityEntries = Atom.family(() => {
|
|
48
|
+
return Atom.make([]).pipe(Atom.keepAlive);
|
|
49
|
+
});
|
|
50
|
+
_capabilities = Atom.family((id) => {
|
|
51
|
+
return Atom.make((get) => {
|
|
52
|
+
return get(this._capabilityEntries(id)).map((c) => c.implementation);
|
|
53
|
+
}).pipe(Atom.keepAlive);
|
|
54
|
+
});
|
|
55
|
+
_capabilitiesByModule = Atom.family((id) => {
|
|
56
|
+
return Atom.make((get) => {
|
|
57
|
+
const entries = get(this._capabilityEntries(id));
|
|
58
|
+
const result = {};
|
|
59
|
+
for (const entry of entries) (result[entry.moduleId] ??= []).push(entry.implementation);
|
|
60
|
+
return result;
|
|
61
|
+
}).pipe(Atom.keepAlive);
|
|
62
|
+
});
|
|
63
|
+
_capability = Atom.family((id) => {
|
|
64
|
+
return Atom.make((get) => {
|
|
65
|
+
const current = get(this._capabilities(id));
|
|
66
|
+
if (current.length === 0) throw new CapabilityNotFoundError({
|
|
67
|
+
identifier: id,
|
|
68
|
+
registered: this.listRegisteredIdentifiers()
|
|
69
|
+
});
|
|
70
|
+
return current[0];
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
constructor({ registry }) {
|
|
74
|
+
this._registry = registry;
|
|
75
|
+
}
|
|
76
|
+
contribute({ module: moduleId, interface: interfaceDef, implementation }) {
|
|
77
|
+
const current = this._registry.get(this._capabilityEntries(interfaceDef.identifier));
|
|
78
|
+
if (current.some((c) => c.moduleId === moduleId && c.implementation === implementation)) {
|
|
79
|
+
log("capability already contributed, skipping", {
|
|
80
|
+
id: interfaceDef.identifier,
|
|
81
|
+
moduleId
|
|
82
|
+
}, {
|
|
83
|
+
"~LogMeta": "~LogMeta",
|
|
84
|
+
F: __dxlog_file,
|
|
85
|
+
L: 195,
|
|
86
|
+
S: this
|
|
87
|
+
});
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const entry = {
|
|
91
|
+
moduleId,
|
|
92
|
+
implementation
|
|
93
|
+
};
|
|
94
|
+
this._registry.set(this._capabilityEntries(interfaceDef.identifier), [...current, entry]);
|
|
95
|
+
this._registeredIdentifiers.add(interfaceDef.identifier);
|
|
96
|
+
log("capability contributed", {
|
|
97
|
+
id: interfaceDef.identifier,
|
|
98
|
+
moduleId,
|
|
99
|
+
count: current.length
|
|
100
|
+
}, {
|
|
101
|
+
"~LogMeta": "~LogMeta",
|
|
102
|
+
F: __dxlog_file,
|
|
103
|
+
L: 202,
|
|
104
|
+
S: this
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
remove(interfaceDef, implementation) {
|
|
108
|
+
const current = this._registry.get(this._capabilityEntries(interfaceDef.identifier));
|
|
109
|
+
if (current.length === 0) return;
|
|
110
|
+
const next = current.filter((c) => c.implementation !== implementation);
|
|
111
|
+
if (next.length !== current.length) {
|
|
112
|
+
this._registry.set(this._capabilityEntries(interfaceDef.identifier), next);
|
|
113
|
+
if (next.length === 0) this._registeredIdentifiers.delete(interfaceDef.identifier);
|
|
114
|
+
log("capability removed", {
|
|
115
|
+
id: interfaceDef.identifier,
|
|
116
|
+
count: current.length
|
|
117
|
+
}, {
|
|
118
|
+
"~LogMeta": "~LogMeta",
|
|
119
|
+
F: __dxlog_file,
|
|
120
|
+
L: 221,
|
|
121
|
+
S: this
|
|
122
|
+
});
|
|
123
|
+
} else log.warn("capability not removed", { id: interfaceDef.identifier }, {
|
|
124
|
+
"~LogMeta": "~LogMeta",
|
|
125
|
+
F: __dxlog_file,
|
|
126
|
+
L: 223,
|
|
127
|
+
S: this
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
atom(interfaceDef) {
|
|
131
|
+
return this._capabilities(interfaceDef.identifier);
|
|
132
|
+
}
|
|
133
|
+
getAll(interfaceDef) {
|
|
134
|
+
return this._registry.get(this.atom(interfaceDef));
|
|
135
|
+
}
|
|
136
|
+
get(interfaceDef) {
|
|
137
|
+
const capabilities = this.getAll(interfaceDef);
|
|
138
|
+
if (capabilities.length === 0) {
|
|
139
|
+
log("capability not available", {
|
|
140
|
+
requested: interfaceDef.identifier,
|
|
141
|
+
registered: this.listRegisteredIdentifiers()
|
|
142
|
+
}, {
|
|
143
|
+
"~LogMeta": "~LogMeta",
|
|
144
|
+
F: __dxlog_file,
|
|
145
|
+
L: 239,
|
|
146
|
+
S: this
|
|
147
|
+
});
|
|
148
|
+
throw new CapabilityNotFoundError({
|
|
149
|
+
identifier: interfaceDef.identifier,
|
|
150
|
+
registered: this.listRegisteredIdentifiers()
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
return capabilities[0];
|
|
154
|
+
}
|
|
155
|
+
listRegisteredIdentifiers() {
|
|
156
|
+
return [...this._registeredIdentifiers].sort();
|
|
157
|
+
}
|
|
158
|
+
waitFor(interfaceDef) {
|
|
159
|
+
return Effect.gen({ self: this }, function* () {
|
|
160
|
+
const [capability] = this.getAll(interfaceDef);
|
|
161
|
+
if (capability) return capability;
|
|
162
|
+
const deferred = yield* Deferred.make();
|
|
163
|
+
const cancel = this._registry.subscribe(this.atom(interfaceDef), (capabilities) => {
|
|
164
|
+
if (capabilities.length > 0) Effect.runSync(Deferred.succeed(deferred, capabilities[0]));
|
|
165
|
+
});
|
|
166
|
+
const result = yield* Deferred.await(deferred);
|
|
167
|
+
cancel();
|
|
168
|
+
return result;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
waitForPromise(interfaceDef) {
|
|
172
|
+
const existing = this._waitPromises.get(interfaceDef.identifier);
|
|
173
|
+
if (existing) return existing;
|
|
174
|
+
const promise = EffectEx.runPromise(this.waitFor(interfaceDef)).finally(() => {
|
|
175
|
+
this._waitPromises.delete(interfaceDef.identifier);
|
|
176
|
+
});
|
|
177
|
+
this._waitPromises.set(interfaceDef.identifier, promise);
|
|
178
|
+
return promise;
|
|
179
|
+
}
|
|
180
|
+
atomByModule(interfaceDef) {
|
|
181
|
+
return this._capabilitiesByModule(interfaceDef.identifier);
|
|
182
|
+
}
|
|
183
|
+
contributions(interfaceDef) {
|
|
184
|
+
const existing = this._contributionsViews.get(interfaceDef.identifier);
|
|
185
|
+
if (existing) return existing;
|
|
186
|
+
const atom = this._capabilities(interfaceDef.identifier);
|
|
187
|
+
const view = {
|
|
188
|
+
atom,
|
|
189
|
+
get: () => this._registry.get(atom),
|
|
190
|
+
subscribe: (cb) => this._registry.subscribe(atom, cb)
|
|
191
|
+
};
|
|
192
|
+
this._contributionsViews.set(interfaceDef.identifier, view);
|
|
193
|
+
return view;
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Creates a new Capability Manager instance.
|
|
198
|
+
*/
|
|
199
|
+
var make = (options) => new CapabilityManagerImpl(options);
|
|
200
|
+
//#endregion
|
|
201
|
+
export { normalizeActivateResult as a, make as i, expandContributions as n, isContribution as r, capability_manager_exports as t };
|
|
202
|
+
|
|
203
|
+
//# sourceMappingURL=chunk-capability-manager.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-capability-manager.mjs","names":[],"sources":["../../src/core/capability-manager.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Deferred from 'effect/Deferred';\nimport * as Effect from 'effect/Effect';\nimport * as Atom from 'effect/reactivity/Atom';\nimport type * as Registry from 'effect/reactivity/AtomRegistry';\n\nimport * as EffectEx from '@dxos/effect/EffectEx';\nimport { log } from '@dxos/log';\n\nimport type * as Capability from './capability.ts';\nimport { ContributionTypeId } from './capability.ts';\nimport { CapabilityNotFoundError } from './errors.ts';\n\ntype CapabilityEntry<T> = {\n moduleId: string;\n implementation: T;\n};\n\n//\n// Contribution ingestion — manager-side machinery for a module's activate result. Lives here\n// rather than in `capability` so the authoring namespace exposes only the plugin-author API.\n//\n\n/**\n * Type guard to check if a value is a {@link Capability.Contribution}.\n */\nexport const isContribution = (value: unknown): value is Capability.AnyContribution => {\n return typeof value === 'object' && value !== null && ContributionTypeId in value;\n};\n\n/**\n * Normalizes a module activate result into a flat list of items (legacy capabilities and\n * typed contributions).\n */\nexport const normalizeActivateResult = (\n result: Capability.ModuleReturn | Capability.AnyContribution | readonly Capability.AnyContribution[],\n): Array<Capability.Any | Capability.AnyContribution> => {\n if (result == null) {\n return [];\n }\n // Cast: Array.isArray does not narrow the ReadonlyArray members of ModuleReturn.\n return (Array.isArray(result) ? [...result] : [result]) as Array<Capability.Any | Capability.AnyContribution>;\n};\n\n/**\n * Expands typed contributions into per-value capability entries; legacy capability entries\n * pass through.\n */\nexport const expandContributions = (\n items: ReadonlyArray<Capability.Any | Capability.AnyContribution>,\n): Capability.Any[] =>\n items.flatMap((item) =>\n isContribution(item)\n ? item.values.map((value): Capability.Any => ({\n interface: item.capability,\n implementation: value,\n }))\n : [item],\n );\n\n/**\n * Options for creating a capability manager.\n * @internal\n */\nexport type CapabilityManagerOptions = {\n registry: Registry.AtomRegistry;\n};\n\n/**\n * Interface for the Capability Manager.\n * Provides methods for contributing, removing, and accessing capabilities.\n */\nexport interface CapabilityManager {\n contribute<T>(args: { module: string; interface: Capability.InterfaceDef<T>; implementation: T }): void;\n\n remove<T>(interfaceDef: Capability.InterfaceDef<T>, implementation: T): void;\n\n /**\n * Get the Atom reference to the available capabilities for a given interface.\n * Primarily useful for deriving other Atom values based on the capabilities or\n * for subscribing to changes in the capabilities.\n * @returns An atom reference to the available capabilities.\n */\n atom<T>(interfaceDef: Capability.InterfaceDef<T>): Atom.Atom<T[]>;\n\n /**\n * Get capabilities from the capability manager.\n * @returns An array of capabilities.\n */\n getAll<T>(interfaceDef: Capability.InterfaceDef<T>): T[];\n\n /**\n * Requests a single capability from the capability manager.\n * @returns The capability.\n * @throws If no capability is found.\n */\n get<T>(interfaceDef: Capability.InterfaceDef<T>): T;\n\n /**\n * Waits for a capability to be available.\n * @returns The capability.\n */\n waitFor<T>(interfaceDef: Capability.InterfaceDef<T>): Effect.Effect<T>;\n\n /**\n * Promise form of {@link waitFor}, memoized per interface so repeated calls return the SAME\n * reference — React dedupes suspended renders by thrown-promise identity, so a fresh promise per\n * render would re-suspend forever.\n * @returns A promise settling once at least one capability is contributed.\n */\n waitForPromise<T>(interfaceDef: Capability.InterfaceDef<T>): Promise<T>;\n\n /**\n * Get capabilities grouped by the module that contributed them.\n * @returns An atom containing a record from module ID to capability implementations.\n */\n atomByModule<T>(interfaceDef: Capability.InterfaceDef<T>): Atom.Atom<Record<string, T[]>>;\n\n /**\n * Live view over all contributions for a capability interface.\n * Stable per interface: repeated calls return the same object.\n */\n contributions<T>(interfaceDef: Capability.InterfaceDef<T>): Capability.Contributions<T>;\n\n /**\n * Lists capability interface identifiers that currently have at least one contribution.\n */\n listRegisteredIdentifiers(): string[];\n}\n\n/**\n * Internal implementation of CapabilityManager.\n */\nclass CapabilityManagerImpl implements CapabilityManager {\n private readonly _registry: Registry.AtomRegistry;\n\n private readonly _registeredIdentifiers = new Set<string>();\n\n private readonly _contributionsViews = new Map<string, Capability.Contributions<unknown>>();\n\n /** In-flight {@link waitForPromise} results, keyed by interface identifier. */\n private readonly _waitPromises = new Map<string, Promise<unknown>>();\n\n private readonly _capabilityEntries = Atom.family<string, Atom.Writable<CapabilityEntry<unknown>[]>>(() => {\n return Atom.make<CapabilityEntry<unknown>[]>([]).pipe(Atom.keepAlive);\n });\n\n readonly _capabilities = Atom.family<string, Atom.Atom<unknown[]>>((id: string) => {\n return Atom.make((get) => {\n const current = get(this._capabilityEntries(id));\n return current.map((c) => c.implementation);\n }).pipe(Atom.keepAlive);\n });\n\n readonly _capabilitiesByModule = Atom.family<string, Atom.Atom<Record<string, unknown[]>>>((id: string) => {\n return Atom.make((get) => {\n const entries = get(this._capabilityEntries(id));\n const result: Record<string, unknown[]> = {};\n for (const entry of entries) {\n (result[entry.moduleId] ??= []).push(entry.implementation);\n }\n return result;\n }).pipe(Atom.keepAlive);\n });\n\n readonly _capability = Atom.family<string, Atom.Atom<unknown>>((id: string) => {\n return Atom.make((get) => {\n const current = get(this._capabilities(id));\n if (current.length === 0) {\n throw new CapabilityNotFoundError({ identifier: id, registered: this.listRegisteredIdentifiers() });\n }\n return current[0];\n });\n });\n\n constructor({ registry }: CapabilityManagerOptions) {\n this._registry = registry;\n }\n\n contribute<T>({\n module: moduleId,\n interface: interfaceDef,\n implementation,\n }: {\n module: string;\n interface: Capability.InterfaceDef<T>;\n implementation: T;\n }): void {\n const current = this._registry.get(this._capabilityEntries(interfaceDef.identifier));\n const isDuplicate = current.some((c) => c.moduleId === moduleId && c.implementation === implementation);\n if (isDuplicate) {\n log('capability already contributed, skipping', { id: interfaceDef.identifier, moduleId });\n return;\n }\n\n const entry: CapabilityEntry<T> = { moduleId, implementation };\n this._registry.set(this._capabilityEntries(interfaceDef.identifier), [...current, entry]);\n this._registeredIdentifiers.add(interfaceDef.identifier);\n log('capability contributed', {\n id: interfaceDef.identifier,\n moduleId,\n count: current.length,\n });\n }\n\n remove<T>(interfaceDef: Capability.InterfaceDef<T>, implementation: T): void {\n const current = this._registry.get(this._capabilityEntries(interfaceDef.identifier));\n if (current.length === 0) {\n return;\n }\n\n const next = current.filter((c) => c.implementation !== implementation);\n if (next.length !== current.length) {\n this._registry.set(this._capabilityEntries(interfaceDef.identifier), next);\n if (next.length === 0) {\n this._registeredIdentifiers.delete(interfaceDef.identifier);\n }\n log('capability removed', { id: interfaceDef.identifier, count: current.length });\n } else {\n log.warn('capability not removed', { id: interfaceDef.identifier });\n }\n }\n\n atom<T>(interfaceDef: Capability.InterfaceDef<T>): Atom.Atom<T[]> {\n // NOTE: This the type-checking for capabilities is done at the time of contribution.\n return this._capabilities(interfaceDef.identifier) as Atom.Atom<T[]>;\n }\n\n getAll<T>(interfaceDef: Capability.InterfaceDef<T>): T[] {\n return this._registry.get(this.atom(interfaceDef));\n }\n\n get<T>(interfaceDef: Capability.InterfaceDef<T>): T {\n const capabilities = this.getAll(interfaceDef);\n if (capabilities.length === 0) {\n log('capability not available', {\n requested: interfaceDef.identifier,\n registered: this.listRegisteredIdentifiers(),\n });\n throw new CapabilityNotFoundError({\n identifier: interfaceDef.identifier,\n registered: this.listRegisteredIdentifiers(),\n });\n }\n return capabilities[0];\n }\n\n listRegisteredIdentifiers(): string[] {\n return [...this._registeredIdentifiers].sort();\n }\n\n waitFor<T>(interfaceDef: Capability.InterfaceDef<T>): Effect.Effect<T> {\n return Effect.gen({ self: this }, function* () {\n const [capability] = this.getAll(interfaceDef);\n if (capability) {\n return capability;\n }\n\n const deferred = yield* Deferred.make<T>();\n const cancel = this._registry.subscribe(this.atom(interfaceDef), (capabilities) => {\n if (capabilities.length > 0) {\n Effect.runSync(Deferred.succeed(deferred, capabilities[0]));\n }\n });\n const result = yield* Deferred.await(deferred);\n cancel();\n return result;\n });\n }\n\n waitForPromise<T>(interfaceDef: Capability.InterfaceDef<T>): Promise<T> {\n const existing = this._waitPromises.get(interfaceDef.identifier);\n if (existing) {\n return existing as Promise<T>;\n }\n const promise = EffectEx.runPromise(this.waitFor(interfaceDef)).finally(() => {\n // Drop it once settled so a capability that is removed and re-contributed can be waited on\n // again; until then every suspended reader shares this one reference.\n this._waitPromises.delete(interfaceDef.identifier);\n });\n this._waitPromises.set(interfaceDef.identifier, promise);\n return promise;\n }\n\n atomByModule<T>(interfaceDef: Capability.InterfaceDef<T>): Atom.Atom<Record<string, T[]>> {\n return this._capabilitiesByModule(interfaceDef.identifier) as Atom.Atom<Record<string, T[]>>;\n }\n\n contributions<T>(interfaceDef: Capability.InterfaceDef<T>): Capability.Contributions<T> {\n const existing = this._contributionsViews.get(interfaceDef.identifier);\n if (existing) {\n // NOTE: The type-checking for capabilities is done at the time of contribution.\n return existing as Capability.Contributions<T>;\n }\n\n const atom = this._capabilities(interfaceDef.identifier);\n const view: Capability.Contributions<unknown> = {\n atom,\n get: () => this._registry.get(atom),\n subscribe: (cb) => this._registry.subscribe(atom, cb),\n };\n this._contributionsViews.set(interfaceDef.identifier, view);\n return view as Capability.Contributions<T>;\n }\n}\n\n/**\n * Creates a new Capability Manager instance.\n */\nexport const make = (options: CapabilityManagerOptions): CapabilityManager => new CapabilityManagerImpl(options);\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,IAAa,kBAAkB,UAAwD;CACrF,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,sBAAsB;AAC9E;;;;;AAMA,IAAa,2BACX,WACuD;CACvD,IAAI,UAAU,MACZ,OAAO,CAAC;CAGV,OAAQ,MAAM,QAAQ,MAAM,IAAI,CAAC,GAAG,MAAM,IAAI,CAAC,MAAM;AACvD;;;;;AAMA,IAAa,uBACX,UAEA,MAAM,SAAS,SACb,eAAe,IAAI,IACf,KAAK,OAAO,KAAK,WAA2B;CAC1C,WAAW,KAAK;CAChB,gBAAgB;AAClB,EAAE,IACF,CAAC,IAAI,CACX;;;;AA2EF,IAAM,wBAAN,MAAyD;CACvD;CAEA,yCAA0C,IAAI,IAAY;CAE1D,sCAAuC,IAAI,IAA+C;;CAG1F,gCAAiC,IAAI,IAA8B;CAE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AU,MAAM,EAAE;EACtD;EACA,KAAK,oBAAoB,IAAI,aAAa,YAAY,IAAI;EAC1D,OAAO;CACT;AACF;;;;AAKA,IAAa,QAAQ,YAAyD,IAAI,sBAAsB,OAAO"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { u as contribute, x as makeModule } from "./chunk-capability.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { make } from "./
|
|
2
|
+
import { b as UndoRegistry, l as OperationInvoker, r as HistoryTracker, y as UndoMapping } from "./chunk-capabilities.mjs";
|
|
3
|
+
import { t as make } from "./chunk-undo-registry.mjs";
|
|
4
4
|
import { n as make$1 } from "./chunk-history-tracker.mjs";
|
|
5
5
|
import * as Effect from "effect/Effect";
|
|
6
6
|
//#region src/plugin-process-manager/history/capability.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk-capability2.mjs","names":[],"sources":["../../src/plugin-process-manager/history/capability.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { OperationInvoker } from '@dxos/operation';\n\nimport { Capabilities } from '../../common/index.ts';\nimport { Capability } from '../../core/index.ts';\nimport * as HistoryTracker from './history-tracker.ts';\nimport * as UndoRegistry from './undo-registry.ts';\n\n//\n// Capability Module - contributes both UndoRegistry and HistoryTracker.\n//\n\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n // Create UndoRegistry over the live mapping contributions (synchronous access in callbacks).\n const undoMappings = yield* Capabilities.UndoMapping;\n const undoRegistry = UndoRegistry.make(() => undoMappings.get().flat());\n\n // Create HistoryTracker (depends on UndoRegistry and OperationInvoker).\n const invoker = yield* Capabilities.OperationInvoker;\n // Cast to internal type - the factory always returns OperationInvokerInternal.\n const historyTracker = HistoryTracker.make(invoker as OperationInvoker.OperationInvokerInternal, undoRegistry);\n\n return [\n Capability.contribute(Capabilities.UndoRegistry, undoRegistry),\n Capability.contribute(Capabilities.HistoryTracker, historyTracker),\n ];\n }),\n);\n"],"mappings":";;;;;;AAiBA,IAAA,
|
|
1
|
+
{"version":3,"file":"chunk-capability2.mjs","names":["Capability.makeModule","Capabilities.UndoMapping","UndoRegistry.make","Capabilities.OperationInvoker","HistoryTracker.make","Capability.contribute","Capabilities.UndoRegistry","Capabilities.HistoryTracker"],"sources":["../../src/plugin-process-manager/history/capability.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { OperationInvoker } from '@dxos/operation';\n\nimport { Capabilities } from '../../common/index.ts';\nimport { Capability } from '../../core/index.ts';\nimport * as HistoryTracker from './history-tracker.ts';\nimport * as UndoRegistry from './undo-registry.ts';\n\n//\n// Capability Module - contributes both UndoRegistry and HistoryTracker.\n//\n\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n // Create UndoRegistry over the live mapping contributions (synchronous access in callbacks).\n const undoMappings = yield* Capabilities.UndoMapping;\n const undoRegistry = UndoRegistry.make(() => undoMappings.get().flat());\n\n // Create HistoryTracker (depends on UndoRegistry and OperationInvoker).\n const invoker = yield* Capabilities.OperationInvoker;\n // Cast to internal type - the factory always returns OperationInvokerInternal.\n const historyTracker = HistoryTracker.make(invoker as OperationInvoker.OperationInvokerInternal, undoRegistry);\n\n return [\n Capability.contribute(Capabilities.UndoRegistry, undoRegistry),\n Capability.contribute(Capabilities.HistoryTracker, historyTracker),\n ];\n }),\n);\n"],"mappings":";;;;;;AAiBA,IAAA,qBAAeA,WACb,OAAO,WAAW,aAAa;CAE7B,MAAM,eAAe,OAAOC;CAC5B,MAAM,eAAeC,WAAwB,aAAa,IAAI,CAAC,CAAC,KAAK,CAAC;CAGtE,MAAM,UAAU,OAAOC;CAEvB,MAAM,iBAAiBC,OAAoB,SAAsD,YAAY;CAE7G,OAAO,CACLC,WAAsBC,cAA2B,YAAY,GAC7DD,WAAsBE,gBAA6B,cAAc,CACnE;AACF,CAAC,CACH"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
|
|
2
|
-
import { resolveMessage } from "./
|
|
2
|
+
import { n as resolveMessage } from "./chunk-undo-mapping.mjs";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
4
|
import * as EffectEx from "@dxos/effect/EffectEx";
|
|
5
5
|
import { log } from "@dxos/log";
|
package/dist/lib/chunk-hooks.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { d as SurfaceManagerProvider, t as SurfaceManager } from "./chunk-SurfaceManager.mjs";
|
|
2
2
|
import { r as make } from "./chunk-plugin-manager.mjs";
|
|
3
3
|
import { t as PluginManagerContext } from "./chunk-context.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { Startup } from "./
|
|
4
|
+
import { c as OperationHandlers, f as ProcessManagerRuntime, l as OperationInvoker, m as ReactRoot, p as ReactContext, t as AtomRegistry, u as PluginManager } from "./chunk-capabilities.mjs";
|
|
5
|
+
import { a as Startup } from "./chunk-activation-events.mjs";
|
|
6
6
|
import { PluginManagerProvider, useOptionalPluginManager, usePluginManager } from "./PluginManagerProvider.mjs";
|
|
7
7
|
import { t as Context } from "./chunk-Surface.mjs";
|
|
8
|
-
import { setup } from "./
|
|
8
|
+
import { n as setup } from "./chunk-Devtools.mjs";
|
|
9
9
|
import { t as topologicalSort } from "./chunk-helpers.mjs";
|
|
10
10
|
import { Suspense, use, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
11
11
|
import { useAtomValue } from "@effect/atom-react/Hooks";
|
|
@@ -376,7 +376,7 @@ var useApp = ({ pluginManager, pluginLoader: pluginLoaderProp, onPluginRemove, p
|
|
|
376
376
|
setError(withContext(error$, diagnostics));
|
|
377
377
|
reportFailure(diagnostics);
|
|
378
378
|
}
|
|
379
|
-
})), Effect.forever));
|
|
379
|
+
})), Effect.forever({ disableYield: true })));
|
|
380
380
|
yield* Effect.all([...setupEvents.map((event) => manager.activate(event)), manager.activate(Startup)]);
|
|
381
381
|
return yield* Fiber.join(listener);
|
|
382
382
|
}).pipe(Effect.scoped, Effect.runFork);
|
|
@@ -384,7 +384,7 @@ var useApp = ({ pluginManager, pluginLoader: pluginLoaderProp, onPluginRemove, p
|
|
|
384
384
|
log("useApp: effect cleanup", void 0, {
|
|
385
385
|
"~LogMeta": "~LogMeta",
|
|
386
386
|
F: __dxlog_file,
|
|
387
|
-
L:
|
|
387
|
+
L: 454,
|
|
388
388
|
S: void 0
|
|
389
389
|
});
|
|
390
390
|
watchdog.dispose();
|