@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.
Files changed (129) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/dist/lib/App.mjs +1 -2
  3. package/dist/lib/Hooks.mjs +1 -2
  4. package/dist/lib/chunk-App.mjs +11 -0
  5. package/dist/lib/chunk-App.mjs.map +1 -0
  6. package/dist/lib/chunk-Cli.mjs +8 -0
  7. package/dist/lib/chunk-Cli.mjs.map +1 -0
  8. package/dist/lib/chunk-Devtools.mjs +112 -0
  9. package/dist/lib/chunk-Devtools.mjs.map +1 -0
  10. package/dist/lib/chunk-Hooks2.mjs +35 -0
  11. package/dist/lib/chunk-Hooks2.mjs.map +1 -0
  12. package/dist/lib/chunk-PluginManagerProvider.mjs +12 -0
  13. package/dist/lib/chunk-PluginManagerProvider.mjs.map +1 -0
  14. package/dist/lib/chunk-ProcessManagerPlugin.mjs +3 -3
  15. package/dist/lib/chunk-ProcessManagerPlugin.mjs.map +1 -1
  16. package/dist/lib/chunk-Role.mjs +19 -0
  17. package/dist/lib/chunk-Role.mjs.map +1 -0
  18. package/dist/lib/chunk-SharedPackages.mjs +11 -0
  19. package/dist/lib/chunk-SharedPackages.mjs.map +1 -0
  20. package/dist/lib/chunk-Surface.mjs.map +1 -1
  21. package/dist/lib/chunk-Surface2.mjs +37 -0
  22. package/dist/lib/chunk-Surface2.mjs.map +1 -0
  23. package/dist/lib/chunk-SurfaceManager.mjs +3 -3
  24. package/dist/lib/chunk-SurfaceManager.mjs.map +1 -1
  25. package/dist/lib/chunk-activation-event.mjs +86 -0
  26. package/dist/lib/chunk-activation-event.mjs.map +1 -0
  27. package/dist/lib/chunk-activation-events.mjs +66 -0
  28. package/dist/lib/chunk-activation-events.mjs.map +1 -0
  29. package/dist/lib/chunk-capabilities.mjs +202 -0
  30. package/dist/lib/chunk-capabilities.mjs.map +1 -0
  31. package/dist/lib/chunk-capability-manager.mjs +203 -0
  32. package/dist/lib/chunk-capability-manager.mjs.map +1 -0
  33. package/dist/lib/chunk-capability2.mjs +2 -2
  34. package/dist/lib/chunk-capability2.mjs.map +1 -1
  35. package/dist/lib/chunk-history-tracker.mjs +1 -1
  36. package/dist/lib/chunk-hooks.mjs +5 -5
  37. package/dist/lib/chunk-hooks.mjs.map +1 -1
  38. package/dist/lib/chunk-plugin-asset-cache.mjs +28 -0
  39. package/dist/lib/chunk-plugin-asset-cache.mjs.map +1 -0
  40. package/dist/lib/chunk-plugin-manager.mjs +68 -35
  41. package/dist/lib/chunk-plugin-manager.mjs.map +1 -1
  42. package/dist/lib/chunk-plugin-manager2.mjs +22 -0
  43. package/dist/lib/chunk-plugin-manager2.mjs.map +1 -0
  44. package/dist/lib/chunk-plugin-manifest.mjs +126 -0
  45. package/dist/lib/chunk-plugin-manifest.mjs.map +1 -0
  46. package/dist/lib/chunk-plugin.mjs +354 -0
  47. package/dist/lib/chunk-plugin.mjs.map +1 -0
  48. package/dist/lib/chunk-process-manager-capability.mjs +11 -10
  49. package/dist/lib/chunk-process-manager-capability.mjs.map +1 -1
  50. package/dist/lib/chunk-registry.mjs.map +1 -1
  51. package/dist/lib/chunk-undo-mapping.mjs +47 -0
  52. package/dist/lib/{plugin-process-manager/history/undo-mapping.mjs.map → chunk-undo-mapping.mjs.map} +1 -1
  53. package/dist/lib/chunk-undo-registry.mjs +22 -0
  54. package/dist/lib/{plugin-process-manager/history/undo-registry.mjs.map → chunk-undo-registry.mjs.map} +1 -1
  55. package/dist/lib/chunk-url-loader.mjs +345 -0
  56. package/dist/lib/chunk-url-loader.mjs.map +1 -0
  57. package/dist/lib/cli.mjs +3 -3
  58. package/dist/lib/cli.mjs.map +1 -1
  59. package/dist/lib/common/Role.mjs +1 -19
  60. package/dist/lib/common/activation-events.mjs +1 -57
  61. package/dist/lib/common/capabilities.mjs +1 -202
  62. package/dist/lib/config.mjs +1 -2
  63. package/dist/lib/core/activation-event.mjs +1 -86
  64. package/dist/lib/core/capability-manager.mjs +1 -203
  65. package/dist/lib/core/capability.mjs +1 -2
  66. package/dist/lib/core/plugin-asset-cache.mjs +1 -28
  67. package/dist/lib/core/plugin-manager.mjs +2 -19
  68. package/dist/lib/core/plugin-manifest.mjs +1 -126
  69. package/dist/lib/core/plugin.mjs +1 -354
  70. package/dist/lib/core/registry.mjs +1 -2
  71. package/dist/lib/core/url-loader.mjs +1 -345
  72. package/dist/lib/index.mjs +19 -19
  73. package/dist/lib/ns/App.mjs +2 -11
  74. package/dist/lib/ns/Cli.mjs +2 -8
  75. package/dist/lib/ns/Devtools.mjs +1 -112
  76. package/dist/lib/ns/Hooks.mjs +2 -35
  77. package/dist/lib/ns/PluginManagerProvider.mjs +2 -12
  78. package/dist/lib/ns/SharedPackages.mjs +2 -11
  79. package/dist/lib/ns/Surface.mjs +2 -35
  80. package/dist/lib/ns/Translations.mjs +1 -2
  81. package/dist/lib/plugin-cli.mjs +2 -4
  82. package/dist/lib/plugin-cli.mjs.map +1 -1
  83. package/dist/lib/plugin-process-manager/ProcessManagerPlugin.mjs +1 -2
  84. package/dist/lib/plugin-process-manager/history/history-tracker.mjs +1 -2
  85. package/dist/lib/plugin-process-manager/history/undo-mapping.mjs +1 -47
  86. package/dist/lib/plugin-process-manager/history/undo-registry.mjs +1 -22
  87. package/dist/lib/testing/react.mjs +1 -1
  88. package/dist/lib/testing/react.mjs.map +1 -1
  89. package/dist/lib/testing.mjs +5 -5
  90. package/dist/lib/testing.mjs.map +1 -1
  91. package/dist/lib/vite-plugin.mjs +3 -3
  92. package/dist/lib/vite-plugin.mjs.map +1 -1
  93. package/dist/types/src/common/activation-events.d.ts +8 -0
  94. package/dist/types/src/common/activation-events.d.ts.map +1 -1
  95. package/dist/types/src/core/plugin-manager/manager-state.d.ts.map +1 -1
  96. package/dist/types/src/core/plugin-manager/module-loader.d.ts +0 -10
  97. package/dist/types/src/core/plugin-manager/module-loader.d.ts.map +1 -1
  98. package/dist/types/src/core/plugin-manager/plugin-manager.d.ts.map +1 -1
  99. package/dist/types/src/plugin-process-manager/process-manager-capability.d.ts.map +1 -1
  100. package/dist/types/src/ui/components/Surface/SurfaceComponent.stories.d.ts.map +1 -1
  101. package/dist/types/src/ui/hooks/useApp.d.ts.map +1 -1
  102. package/dist/types/tsconfig.tsbuildinfo +1 -1
  103. package/package.json +32 -32
  104. package/src/common/activation-events.ts +9 -0
  105. package/src/core/plugin-manager/manager-state.ts +14 -12
  106. package/src/core/plugin-manager/module-loader.ts +43 -7
  107. package/src/core/plugin-manager/plugin-manager.ts +2 -1
  108. package/src/plugin-process-manager/process-manager-capability.test.ts +66 -1
  109. package/src/plugin-process-manager/process-manager-capability.ts +22 -2
  110. package/src/ui/components/Surface/SurfaceComponent.stories.tsx +9 -7
  111. package/src/ui/hooks/useApp.tsx +2 -1
  112. package/src/vite-plugin/boot-loader/loader-app/boot-loader.css +19 -1
  113. package/dist/lib/common/Role.mjs.map +0 -1
  114. package/dist/lib/common/activation-events.mjs.map +0 -1
  115. package/dist/lib/common/capabilities.mjs.map +0 -1
  116. package/dist/lib/core/activation-event.mjs.map +0 -1
  117. package/dist/lib/core/capability-manager.mjs.map +0 -1
  118. package/dist/lib/core/plugin-asset-cache.mjs.map +0 -1
  119. package/dist/lib/core/plugin-manager.mjs.map +0 -1
  120. package/dist/lib/core/plugin-manifest.mjs.map +0 -1
  121. package/dist/lib/core/plugin.mjs.map +0 -1
  122. package/dist/lib/core/url-loader.mjs.map +0 -1
  123. package/dist/lib/ns/App.mjs.map +0 -1
  124. package/dist/lib/ns/Cli.mjs.map +0 -1
  125. package/dist/lib/ns/Devtools.mjs.map +0 -1
  126. package/dist/lib/ns/Hooks.mjs.map +0 -1
  127. package/dist/lib/ns/PluginManagerProvider.mjs.map +0 -1
  128. package/dist/lib/ns/SharedPackages.mjs.map +0 -1
  129. package/dist/lib/ns/Surface.mjs.map +0 -1
@@ -1,202 +1 @@
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 { AtomRegistry, Command, HistoryTracker, Layer, LayerSpec, ManagedRuntime, OperationHandler, OperationHandlers, OperationInvoker, PluginManager, ProcessManager, ProcessManagerRuntime, ReactContext, ReactRoot, ReactSurface, RemoteTraceMonitor, ServiceResolver, TraceSink, UndoMapping, UndoRegistry, getAtomValue, getAtomValueOption, subscribeAtom, capabilities_exports as t, updateAtomValue };
201
-
202
- //# sourceMappingURL=capabilities.mjs.map
1
+ export { t as AtomRegistry, n as Command, r as HistoryTracker, i as Layer, a as LayerSpec, o as ManagedRuntime, s as OperationHandler, c as OperationHandlers, l as OperationInvoker, u as PluginManager, d as ProcessManager, f as ProcessManagerRuntime, p as ReactContext, m as ReactRoot, h as ReactSurface, g as RemoteTraceMonitor, _ as ServiceResolver, v as TraceSink, y as UndoMapping, b as UndoRegistry, S as getAtomValue, C as getAtomValueOption, w as subscribeAtom, T as updateAtomValue } from "../chunk-capabilities.mjs";
@@ -1,2 +1 @@
1
- import { Config2 } from "@dxos/protocols";
2
- export { Config2 };
1
+ export { Config2 } from "@dxos/protocols";
@@ -1,86 +1 @@
1
- import { t as __exportAll } from "../chunk-rolldown-runtime.mjs";
2
- import { compositeKey } from "@dxos/util";
3
- import { DXN } from "@dxos/keys";
4
- //#region src/core/activation-event.ts
5
- var activation_event_exports = /* @__PURE__ */ __exportAll({
6
- Idle: () => Idle,
7
- Startup: () => Startup,
8
- allOf: () => allOf,
9
- eventKey: () => eventKey,
10
- getEvents: () => getEvents,
11
- isAllOf: () => isAllOf,
12
- isOneOf: () => isOneOf,
13
- make: () => make,
14
- oneOf: () => oneOf,
15
- pluginStart: () => pluginStart
16
- });
17
- /**
18
- * Helper to define an activation event from an NSID.
19
- * Static NSID strings are validated at compile time via {@link DXN.Name}.
20
- */
21
- var make = (nsid, specifier) => ({
22
- id: DXN.make(nsid),
23
- specifier
24
- });
25
- /**
26
- * Helper to create an activation event key.
27
- */
28
- var eventKey = (event) => event.specifier ? compositeKey(event.id, event.specifier) : event.id;
29
- /**
30
- * Helper to create an activation event that triggers when any of the given events are activated.
31
- */
32
- var oneOf = (...events) => ({
33
- type: "one-of",
34
- events
35
- });
36
- /**
37
- * Helper to create an activation event that triggers when all of the given events are activated.
38
- */
39
- var allOf = (...events) => ({
40
- type: "all-of",
41
- events
42
- });
43
- /**
44
- * Helper to check if an activation event is a one-of event.
45
- */
46
- var isOneOf = (events) => "type" in events && events.type === "one-of";
47
- /**
48
- * Helper to check if an activation event is an all-of event.
49
- */
50
- var isAllOf = (events) => "type" in events && events.type === "all-of";
51
- /**
52
- * Helper to get the events from an activation event.
53
- */
54
- var getEvents = (events) => "type" in events ? events.events : [events];
55
- /**
56
- * Fired when the app is started.
57
- * Defined in core (rather than the `common` well-known events, which re-export it) because
58
- * the plugin manager's `start()` delegates `activate(Startup)` and publishes the
59
- * startup-complete message on this key.
60
- * @deprecated As an `activatesOn` target — declare `provides`/`requires` instead; the
61
- * dependency pass replaces startup-event wiring. External callers keep using
62
- * `PluginManager.activate(Startup)` (it delegates to `start()`).
63
- */
64
- var Startup = make("org.dxos.app-framework.event.startup");
65
- /**
66
- * Fired once by the host at main-thread idle after the app is interactive; see the `common`
67
- * well-known events for the authoring-facing documentation.
68
- *
69
- * Defined here rather than only in `common` because omitting `activatesOn` normalizes to this
70
- * event, and `Plugin.normalizeActivation` lives in core — which cannot import `common` without
71
- * closing the `common -> core` cycle.
72
- */
73
- var Idle = make("org.dxos.app-framework.event.idle");
74
- /**
75
- * A plugin's feature-start event, by convention `<pluginKey>.event.start`. A plugin's
76
- * off-critical-path modules declare `activatesOn` on its own start event (conventionally
77
- * exported as `<Name>Events.Start` from the plugin's types); cross-plugin contributions (a
78
- * skill, a markdown extension) declare the CONSUMING plugin's start event. Deriving the id
79
- * from the key alone lets fire sites (enable, idle, demand signals) activate a feature
80
- * without importing its package.
81
- */
82
- var pluginStart = (pluginKey) => make(`${pluginKey}.event.start`);
83
- //#endregion
84
- export { Idle, Startup, allOf, eventKey, getEvents, isAllOf, isOneOf, make, oneOf, pluginStart, activation_event_exports as t };
85
-
86
- //# sourceMappingURL=activation-event.mjs.map
1
+ export { t as Idle, n as Startup, i as allOf, a as eventKey, o as getEvents, s as isAllOf, c as isOneOf, l as make, u as oneOf, d as pluginStart } from "../chunk-activation-event.mjs";
@@ -1,203 +1 @@
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 { expandContributions, isContribution, make, normalizeActivateResult, capability_manager_exports as t };
202
-
203
- //# sourceMappingURL=capability-manager.mjs.map
1
+ export { n as expandContributions, r as isContribution, i as make, a as normalizeActivateResult } from "../chunk-capability-manager.mjs";
@@ -1,2 +1 @@
1
- import { C as moduleMaker, S as makeSingleton, T as CapabilityNotFoundError, _ as inlineModule, a as Service, b as make, c as atomByModule, d as contributeAll, f as contributions, g as getOption, h as getModuleTag, i as ModuleTag, m as getAll, n as ContributionTypeId, o as asLayer, p as get, r as CurrentModuleId, s as atom, t as ActivatingModuleIds, u as contribute, v as layerWith, w as waitFor, x as makeModule, y as lazyModule } from "../chunk-capability.mjs";
2
- export { ActivatingModuleIds, ContributionTypeId, CurrentModuleId, ModuleTag, CapabilityNotFoundError as NotFoundError, Service, asLayer, atom, atomByModule, contribute, contributeAll, contributions, get, getAll, getModuleTag, getOption, inlineModule, layerWith, lazyModule, make, makeModule, makeSingleton, moduleMaker, waitFor };
1
+ export { t as ActivatingModuleIds, n as ContributionTypeId, r as CurrentModuleId, i as ModuleTag, T as NotFoundError, a as Service, o as asLayer, s as atom, c as atomByModule, u as contribute, d as contributeAll, f as contributions, p as get, m as getAll, h as getModuleTag, g as getOption, _ as inlineModule, v as layerWith, y as lazyModule, b as make, x as makeModule, S as makeSingleton, C as moduleMaker, w as waitFor } from "../chunk-capability.mjs";
@@ -1,28 +1 @@
1
- import { t as __exportAll } from "../chunk-rolldown-runtime.mjs";
2
- import * as Effect from "effect/Effect";
3
- import { BaseError } from "@dxos/errors";
4
- //#region src/core/plugin-asset-cache.ts
5
- var plugin_asset_cache_exports = /* @__PURE__ */ __exportAll({
6
- PluginAssetCacheError: () => PluginAssetCacheError,
7
- noop: () => noop
8
- });
9
- /**
10
- * Tagged error for cache operations. Construction sites supply `context.operation`
11
- * (one of `'cache' | 'evict' | 'resolve' | 'list'`) and `context.pluginId` so
12
- * downstream handlers can route on the failed call without scanning the message.
13
- */
14
- var PluginAssetCacheError = class extends BaseError.extend("PluginAssetCacheError", "Plugin asset cache operation failed") {};
15
- /**
16
- * No-op implementation. Used when no platform cache is registered (tests, unsupported environments).
17
- * Plugins still load — they just have no offline guarantee.
18
- */
19
- var noop = () => ({
20
- cache: () => Effect.void,
21
- evict: () => Effect.void,
22
- resolve: (_pluginId, url) => Effect.succeed(url),
23
- list: () => Effect.succeed([])
24
- });
25
- //#endregion
26
- export { PluginAssetCacheError, noop, plugin_asset_cache_exports as t };
27
-
28
- //# sourceMappingURL=plugin-asset-cache.mjs.map
1
+ export { t as PluginAssetCacheError, n as noop } from "../chunk-plugin-asset-cache.mjs";
@@ -1,22 +1,5 @@
1
- import { t as __exportAll } from "../chunk-rolldown-runtime.mjs";
2
1
  import { A as ProvidesMismatchError, D as DuplicateProviderError, E as DependencyCycleError, O as MissingProviderError, k as ModuleActivationError } from "../chunk-capability.mjs";
3
2
  import { a as PluginTimeoutError, i as PluginInitializationError, n as isManager, r as make, t as ManagerTypeId } from "../chunk-plugin-manager.mjs";
4
3
  import { t as PluginManagerContext } from "../chunk-context.mjs";
5
- //#region src/core/plugin-manager/index.ts
6
- var plugin_manager_exports = /* @__PURE__ */ __exportAll({
7
- Context: () => PluginManagerContext,
8
- DependencyCycleError: () => DependencyCycleError,
9
- DuplicateProviderError: () => DuplicateProviderError,
10
- ManagerTypeId: () => ManagerTypeId,
11
- MissingProviderError: () => MissingProviderError,
12
- ModuleActivationError: () => ModuleActivationError,
13
- PluginInitializationError: () => PluginInitializationError,
14
- PluginTimeoutError: () => PluginTimeoutError,
15
- ProvidesMismatchError: () => ProvidesMismatchError,
16
- isManager: () => isManager,
17
- make: () => make
18
- });
19
- //#endregion
20
- export { PluginManagerContext as Context, DependencyCycleError, DuplicateProviderError, ManagerTypeId, MissingProviderError, ModuleActivationError, PluginInitializationError, PluginTimeoutError, ProvidesMismatchError, isManager, make, plugin_manager_exports as t };
21
-
22
- //# sourceMappingURL=plugin-manager.mjs.map
4
+ import "../chunk-plugin-manager2.mjs";
5
+ export { PluginManagerContext as Context, DependencyCycleError, DuplicateProviderError, ManagerTypeId, MissingProviderError, ModuleActivationError, PluginInitializationError, PluginTimeoutError, ProvidesMismatchError, isManager, make };