@deviltea/widget-core 0.0.1 → 0.0.3

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.
@@ -0,0 +1,192 @@
1
+ import { effect, endBatch, setActiveSub, startBatch } from "alien-signals";
2
+ //#region src/runtime/adapter.ts
3
+ /**
4
+ * Invokes `listener(value)` with no active alien subscriber (restoring the previous one afterward) and
5
+ * isolates a synchronous throw so it cannot escape into the current alien-signals flush. Baseline
6
+ * reporting for an isolated exception is a queued microtask rethrow.
7
+ */
8
+ function invokeListenerIsolated(listener, value) {
9
+ const previous = setActiveSub(void 0);
10
+ try {
11
+ listener(value);
12
+ } catch (error) {
13
+ queueMicrotask(() => {
14
+ throw error;
15
+ });
16
+ } finally {
17
+ setActiveSub(previous);
18
+ }
19
+ }
20
+ /**
21
+ * Calls a synchronous semantic event listener without leaking its reads into an enclosing
22
+ * Property/effect. Unlike reactive value listeners, event listener exceptions propagate immediately.
23
+ */
24
+ function invokeListenerUntracked(listener, args) {
25
+ const previous = setActiveSub(void 0);
26
+ try {
27
+ listener(...args);
28
+ } finally {
29
+ setActiveSub(previous);
30
+ }
31
+ }
32
+ /**
33
+ * Nesting depth of the calls that can drive an `alien-signals` evaluation/flush and therefore have to be
34
+ * back out of the reactive graph before a deferred propagation is safe to release: `RuntimeState`'s
35
+ * `attemptSet`, `RuntimeMethod`'s `invoke` and the tracked read of a Property's result computed. Purely
36
+ * local bookkeeping for {@link writeDeferringFlush}, not a semantic boundary of its own.
37
+ */
38
+ let operationDepth = 0;
39
+ /** Number of `startBatch()` calls {@link writeDeferringFlush} has opened and not yet closed. */
40
+ let deferredFlushDepth = 0;
41
+ /**
42
+ * Closes every batch level {@link writeDeferringFlush} left open, letting alien-signals flush the
43
+ * notifications it already queued.
44
+ *
45
+ * The loop condition is re-tested after every `endBatch()`: that flush can run an effect whose Property
46
+ * recompute commits its own diagnostic snapshot, which opens a fresh level this same drain must then close.
47
+ * A recompute that throws inside one of those flushes must not leave alien-signals permanently batched
48
+ * (every later flush in the Runtime's life would be silently suspended), so the remaining levels are
49
+ * closed before the throw is rethrown.
50
+ */
51
+ function releaseDeferredFlushes() {
52
+ while (deferredFlushDepth > 0) {
53
+ --deferredFlushDepth;
54
+ try {
55
+ endBatch();
56
+ } catch (error) {
57
+ releaseDeferredFlushes();
58
+ throw error;
59
+ }
60
+ }
61
+ }
62
+ /**
63
+ * Tracks one nesting level of the calls that can drive an evaluation, and releases every flush
64
+ * {@link writeDeferringFlush} deferred inside it once the outermost level is leaving.
65
+ *
66
+ * The release runs while the depth is still `1`, so a listener that the release's own flush invokes and
67
+ * that re-enters the Runtime cannot re-enter the drain loop. The decrement is unconditional: a Property
68
+ * recompute that throws inside the release's flush (`createTrackedSubscription` isolates the external
69
+ * listener, never the tracked read) must not leave the depth pinned above `0`, or every later call would
70
+ * look nested and no release would ever run again.
71
+ */
72
+ function runRuntimeOperation(fn) {
73
+ ++operationDepth;
74
+ try {
75
+ return fn();
76
+ } finally {
77
+ try {
78
+ if (operationDepth === 1) releaseDeferredFlushes();
79
+ } finally {
80
+ --operationDepth;
81
+ }
82
+ }
83
+ }
84
+ /**
85
+ * Performs a signal write whose propagation must not be flushed while a computed may still be
86
+ * mid-evaluation, by holding an alien batch open until the outermost {@link runRuntimeOperation} frame on
87
+ * the stack is leaving — i.e. until nothing that could still be evaluating remains.
88
+ *
89
+ * Why this is required in pinned alien-signals@3.2.1 (`esm/index.mjs` / `esm/system.mjs`):
90
+ *
91
+ * - `signalOper` ends a changed write with `propagate(subs, ...)` followed by `if (!batchDepth) flush()`.
92
+ * A write performed from inside a computed's own evaluator therefore starts a *nested* flush that runs
93
+ * the effects the outer propagation had already queued — while the computed that queued them is still
94
+ * mid-`updateComputed`.
95
+ * - `updateComputed` sets `c.flags = 1 | 4` (`Mutable | RecursedCheck`) and only assigns
96
+ * `c.value = c.getter(...)` after the getter returns, so during that window the computed carries
97
+ * neither `Dirty` (16) nor `Pending` (32) and still holds its previous value.
98
+ * - `checkDirty` has no `RecursedCheck` branch: a queued effect whose dependency chain passes through
99
+ * that computed hits none of its `(1 | 16)` / `(1 | 32)` cases, concludes `dirty === false`, and then
100
+ * clears its own intermediate's `Pending` flag (`sub.flags &= ~32`). The intermediate is now marked
101
+ * clean while still holding a stale cached value, so the later `shallowPropagate` — which only
102
+ * upgrades subscribers that are still `Pending` — skips it for good: the effect never runs again and
103
+ * even an untracked `.get()` returns the stale cache.
104
+ *
105
+ * Keeping `batchDepth > 0` for the write removes the nested flush entirely: `propagate` still marks and
106
+ * queues every watcher through alien-signals' own bookkeeping, and the queue is drained later — by the
107
+ * flush that is already running (it re-reads the shared queue length) or by
108
+ * {@link runRuntimeOperation}'s release. Nothing here re-implements propagation, ordering or dedupe.
109
+ *
110
+ * The write itself is unconditional and immediate, so a snapshot is committed exactly where it was
111
+ * before: `pendingValue` is written synchronously and every later read commits it (`signalOper`'s read
112
+ * path runs `updateSignal` when the signal is `Dirty`), which keeps "the snapshot is committed by the
113
+ * time the operation's `ExecutionResult` is observable" true. Only the *notification* moves — never past
114
+ * the end of the operation that produced it.
115
+ *
116
+ * One consequence of using an alien batch as the deferral mechanism, rather than a normative rule about
117
+ * Runtime operations: while a level is open, alien-signals coalesces as it does inside any batch, so two
118
+ * writes to the *same* signal before the release notify its subscribers once, with the final value. This
119
+ * is not a new Runtime semantic — it is the ordinary behavior of the batching alien-signals already owns,
120
+ * already observable inside `RuntimeMethod.invoke`'s batch. Every actual completed recompute still
121
+ * notifies each of its own subscribers exactly once; alien-signals, not this module, decides which
122
+ * recomputes happen.
123
+ */
124
+ function writeDeferringFlush(write) {
125
+ if (operationDepth === 0) {
126
+ write();
127
+ return;
128
+ }
129
+ startBatch();
130
+ ++deferredFlushDepth;
131
+ write();
132
+ }
133
+ /**
134
+ * Creates a Runtime-owned public subscription: an alien `effect()` that tracks `read()`, skips the
135
+ * bootstrap run, and invokes `listener` through {@link invokeListenerIsolated} on every actual
136
+ * subsequent run. Returns an idempotent unsubscribe function registered with the Runtime's disposal
137
+ * bookkeeping.
138
+ */
139
+ function createTrackedSubscription(context, read, listener) {
140
+ let isBootstrap = true;
141
+ const rawDispose = effect(() => {
142
+ const value = read();
143
+ if (isBootstrap) {
144
+ isBootstrap = false;
145
+ return;
146
+ }
147
+ invokeListenerIsolated(listener, value);
148
+ });
149
+ return context.registerSubscription(rawDispose);
150
+ }
151
+ //#endregion
152
+ //#region src/runtime/event.ts
153
+ function createEventPrimitive(context) {
154
+ const listeners = /* @__PURE__ */ new Set();
155
+ let inspectionListeners = null;
156
+ function publishInspectionOccurrence(args) {
157
+ if (inspectionListeners === null) return;
158
+ const snapshot = inspectionListeners.slice();
159
+ for (const { listener } of snapshot) invokeListenerIsolated(listener, args);
160
+ }
161
+ return {
162
+ public: Object.freeze({ subscribe(listener) {
163
+ context.assertActive();
164
+ const entry = { listener };
165
+ listeners.add(entry);
166
+ return context.registerSubscription(() => listeners.delete(entry));
167
+ } }),
168
+ emit(...args) {
169
+ context.assertActive();
170
+ const listenersSnapshot = [...listeners];
171
+ publishInspectionOccurrence(Object.freeze([...args]));
172
+ for (const { listener } of listenersSnapshot) invokeListenerUntracked(listener, args);
173
+ },
174
+ inspection: { subscribe(listener) {
175
+ const entry = { listener };
176
+ if (inspectionListeners === null) inspectionListeners = [];
177
+ inspectionListeners.push(entry);
178
+ return () => {
179
+ if (inspectionListeners === null) return;
180
+ const index = inspectionListeners.indexOf(entry);
181
+ if (index !== -1) inspectionListeners.splice(index, 1);
182
+ };
183
+ } }
184
+ };
185
+ }
186
+ function buildEventEmitter(events) {
187
+ const emitter = Object.create(null);
188
+ for (const [name, primitive] of events) emitter[name] = (...args) => primitive.emit(...args);
189
+ return Object.freeze(emitter);
190
+ }
191
+ //#endregion
192
+ export { runRuntimeOperation as a, invokeListenerIsolated as i, createEventPrimitive as n, writeDeferringFlush as o, createTrackedSubscription as r, buildEventEmitter as t };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as RuntimeDependencyValueRejectedDiagnostic, $n as WidgetMethodReturnOf, $t as WidgetSystem, A as BlueprintNodeDiagnostic, An as WidgetResolvedConfigContext, At as RuntimeMethodSurface, B as Diagnostic, Bn as ExecutionResult, Bt as ValidBlueprintView, C as BlueprintDependencyDiagnosticLocation, Cn as WidgetPluginTypeOf, Ct as CreateWidgetSystemRuntimeOptions, D as BlueprintDiagnostic, Dn as WidgetPropertyComputeContext, Dt as ResolvedBlueprintWidgetNodeView, E as BlueprintDependencyTarget, En as WidgetPropertiesSection, Et as ResolvedBlueprintWidgetNodeFor, F as BlueprintSourceDiagnostic, Fn as WidgetStateMemberDefinition, Ft as RuntimeWidget, G as JsonCompatibilityDiagnostic, Gn as WidgetInterfaces, Gt as WidgetSourceFor, H as DiagnosticCollector, Hn as NonEmptyReadonlyArray, Ht as WidgetLocation, I as BlueprintSourceDiagnosticLocation, In as WidgetStateSection, It as RuntimeWidgetFor, J as RelativeSlotStructureDiagnosticInput, Jn as WidgetMemberKeysOf, Jt as WidgetSystemRuntime, K as JsonCompatibilityReason, Kn as WidgetInterfacesViolationOf, Kt as WidgetSystemBlueprint, L as BlueprintStructureDiagnostic, Ln as WidgetStateValidateContext, Lt as SelfBlueprintWidgetNode, M as BlueprintPropertyDiagnosticLocation, Mn as WidgetSlotDefinitions, Mt as RuntimePropertySurface, N as BlueprintSlotChildDiagnosticLocation, Nn as WidgetSlotValidateStructureContext, Nt as RuntimeState, O as BlueprintDiagnosticLocation, On as WidgetPropertyDefinition, Ot as ResolvedBlueprintWidgetNodeViewFor, P as BlueprintSlotDiagnosticLocation, Pn as WidgetStateDefaultContext, Pt as RuntimeStateSurface, Q as RuntimeDependencyTargetFailedDiagnostic, Qn as WidgetMethodOf, Qt as WidgetPluginOf, R as BlueprintStructureDiagnosticLocation, Rn as createWidgetPlugin, Rt as SelfBlueprintWidgetNodeView, S as BlueprintDependencyDiagnostic, Sn as WidgetPluginStatePhase, St as BlueprintWidgetNodeView, T as BlueprintDependencyReference, Tn as WidgetPluginValidateStructureContext, Tt as ResolvedBlueprintWidgetNode, U as DiagnosticPath, Un as WidgetCapabilityOf, Ut as WidgetLocationView, V as DiagnosticBase, Vn as HasWidgetCapability, Vt as ValidWidgetSystemBlueprint, W as EMPTY_DIAGNOSTICS, Wn as WidgetId, Wt as WidgetSource, X as RelativeSystemStructureDiagnosticInput, Xn as WidgetMethodArgsOf, Xt as WidgetCatalog, Y as RelativeStructureDiagnosticLocation, Yn as WidgetMemberValueOf, Yt as CreateWidgetSystemOptions, Z as RelativeValueDiagnosticInput, Zn as WidgetMethodKeyOf, Zt as WidgetCatalogEntry, _ as ToExecutedDeps, _n as WidgetPluginDonePhase, _t as BlueprintNodeConfigFields, a as MaybeOptional, an as WidgetConfigDefinition, ar as WidgetResolvedConfigOf, at as RuntimeMethodDependencyDiagnostic, b as BlueprintConfigDiagnostic, bn as WidgetPluginPropertiesPhase, bt as BlueprintWidgetNode, c as PropertyGetDepExpression, cn as WidgetInterfacesViolation, cr as WidgetStateOf, ct as RuntimePropertyDependencyDiagnostic, d as SelfMethodDependencyOperations, dn as WidgetMethodValidateArgsContext, dr as JsonObject, dt as RuntimeStateDiagnostic, en as WidgetSystemValidateStructure, er as WidgetMethodsOf, et as RuntimeDiagnostic, f as SelfPropertyDependencyOperations, fn as WidgetMethodsSection, fr as JsonPrimitive, ft as RuntimeWidgetDiagnostic, g as ToExecutedDep, gn as WidgetPluginDescriptionPhase, gt as BlueprintCompileView, h as StateSetDepExpression, hn as WidgetPluginConfigPhase, ht as WidgetSystemRuntimeDisposedError, i as EmptyRegisteredDeps, in as AnyWidgetPluginTuple, ir as WidgetRawConfigOf, it as RuntimeMethodArgsDiagnostic, j as BlueprintNodeDiagnosticLocation, jn as WidgetSlotDefinition, jt as RuntimeProperty, k as BlueprintMethodDiagnosticLocation, kn as WidgetRegisterDepsContext, kt as RuntimeMethod, l as RegisteredDeps, ln as WidgetMethodDefinition, lr as WidgetStateValueOf, lt as RuntimePropertyDiagnostic, m as StateGetDepExpression, mn as WidgetPluginCapabilities, mt as WidgetSystemRuntimeDiagnostic, n as DependencyBuilder, nn as createWidgetSystem, nr as WidgetPropertyKeyOf, nt as RuntimeLevelDiagnostic, o as MethodInvokeDepExpression, on as WidgetConfigValidateContext, or as WidgetSlotNameOf, ot as RuntimeMethodDiagnostic, p as SelfStateDependencyOperations, pn as WidgetPlugin, pr as JsonValue, pt as SourceAccessDiagnostic, q as RelativePluginStructureDiagnosticInput, qn as WidgetMemberKey, qt as WidgetSystemBlueprintStatus, r as DependencyConsumer, rn as AnyWidgetPlugin, rr as WidgetPropertyValueOf, rt as RuntimeLevelDiagnosticLocation, s as OptionalizableDependencyTarget, sn as WidgetInterfacesOf, sr as WidgetStateKeyOf, st as RuntimeMethodResultDiagnostic, t as AnyDepExpression, tn as WidgetSystemValidateStructureContext, tr as WidgetPropertiesOf, tt as RuntimeDiagnosticLocation, u as SelfDependencyTarget, un as WidgetMethodExecuteContext, ur as JsonArray, ut as RuntimePropertyResultDiagnostic, v as UnknownTargetDependencyOperations, vn as WidgetPluginInterfacesPhase, vt as BlueprintSemanticSlots, w as BlueprintDependencyOperation, wn as WidgetPluginValidateStructure, wt as InvalidWidgetSystemBlueprint, x as BlueprintDefinitionDiagnostic, xn as WidgetPluginSlotsPhase, xt as BlueprintWidgetNodeBase, y as UnknownTargetStateDependencyOperations, yn as WidgetPluginMethodsPhase, yt as BlueprintSemanticSlotsView, z as BlueprintWidgetDiagnosticLocation, zn as ExecutionFailure, zt as UnresolvedBlueprintWidgetNode } from "./dep-DKQpJwdW.mjs";
1
+ import { $ as RuntimeDependencyValueRejectedDiagnostic, $n as createWidgetValueContract, $t as WidgetCatalogEntry, A as BlueprintNodeDiagnostic, An as WidgetPluginInterfacesPhase, Ar as JsonPrimitive, At as RuntimeEventSurface, B as Diagnostic, Bn as WidgetPropertyComputeContext, Bt as SelfBlueprintWidgetNodeView, C as BlueprintDependencyDiagnosticLocation, Cn as WidgetPlugin, Cr as WidgetResolvedConfigOf, Ct as CreateWidgetSystemRuntimeOptions, D as BlueprintDiagnostic, Dn as WidgetPluginDescriptionPhase, Dr as WidgetStateValueOf, Dt as ResolvedBlueprintWidgetNodeView, E as BlueprintDependencyTarget, En as WidgetPluginConfigPhase, Er as WidgetStateOf, Et as ResolvedBlueprintWidgetNodeFor, F as BlueprintSourceDiagnostic, Fn as WidgetPluginStatePhase, Ft as RuntimeState, G as JsonCompatibilityDiagnostic, Gn as WidgetSlotDefinitions, Gt as WidgetLocationView, H as DiagnosticCollector, Hn as WidgetRegisterDepsContext, Ht as ValidBlueprintView, I as BlueprintSourceDiagnosticLocation, In as WidgetPluginTypeOf, It as RuntimeStateSurface, J as RelativeSlotStructureDiagnosticInput, Jn as WidgetStateMemberDefinition, Jt as WidgetSystemBlueprint, K as JsonCompatibilityReason, Kn as WidgetSlotValidateStructureContext, Kt as WidgetSource, L as BlueprintStructureDiagnostic, Ln as WidgetPluginValidateStructure, Lt as RuntimeWidget, M as BlueprintPropertyDiagnosticLocation, Mn as WidgetPluginPhaseOrderViolation, Mt as RuntimeMethodSurface, N as BlueprintSlotChildDiagnosticLocation, Nn as WidgetPluginPropertiesPhase, Nt as RuntimeProperty, O as BlueprintDiagnosticLocation, On as WidgetPluginDonePhase, Or as JsonArray, Ot as ResolvedBlueprintWidgetNodeViewFor, P as BlueprintSlotDiagnosticLocation, Pn as WidgetPluginSlotsPhase, Pt as RuntimePropertySurface, Q as RuntimeDependencyTargetFailedDiagnostic, Qn as createWidgetPlugin, Qt as WidgetCatalog, R as BlueprintStructureDiagnosticLocation, Rn as WidgetPluginValidateStructureContext, Rt as RuntimeWidgetFor, S as BlueprintDependencyDiagnostic, Sn as WidgetMethodsSection, Sr as WidgetRawConfigOf, St as BlueprintWidgetNodeView, T as BlueprintDependencyReference, Tn as WidgetPluginConfigMetadata, Tr as WidgetStateKeyOf, Tt as ResolvedBlueprintWidgetNode, U as DiagnosticPath, Un as WidgetResolvedConfigContext, Ut as ValidWidgetSystemBlueprint, V as DiagnosticBase, Vn as WidgetPropertyDefinition, Vt as UnresolvedBlueprintWidgetNode, W as EMPTY_DIAGNOSTICS, Wn as WidgetSlotDefinition, Wt as WidgetLocation, X as RelativeSystemStructureDiagnosticInput, Xn as WidgetStateValidateContext, Xt as WidgetSystemRuntime, Y as RelativeStructureDiagnosticLocation, Yn as WidgetStateSection, Yt as WidgetSystemBlueprintStatus, Z as RelativeValueDiagnosticInput, Zn as WidgetValueContract, Zt as CreateWidgetSystemOptions, _ as ToExecutedDeps, _n as WidgetInterfacesOf, _r as WidgetMethodReturnOf, _t as BlueprintNodeConfigFields, a as MaybeOptional, an as WidgetSystemValidateStructureContext, ar as WidgetEventArgsOf, at as RuntimeMethodDependencyDiagnostic, b as BlueprintConfigDiagnostic, bn as WidgetMethodExecuteContext, br as WidgetPropertyKeyOf, bt as BlueprintWidgetNode, c as PropertyGetDepExpression, cn as AnyWidgetPluginTuple, cr as WidgetId, ct as RuntimePropertyDependencyDiagnostic, d as SelfMethodDependencyOperations, dn as WidgetConfigJsonSchema, dr as WidgetMemberKey, dt as RuntimeStateDiagnostic, en as WidgetPluginOf, er as ExecutionFailure, et as RuntimeDiagnostic, f as SelfPropertyDependencyOperations, fn as WidgetConfigValidateContext, fr as WidgetMemberKeysOf, ft as RuntimeWidgetDiagnostic, g as ToExecutedDep, gn as WidgetEventsSection, gr as WidgetMethodOf, gt as BlueprintCompileView, h as StateSetDepExpression, hn as WidgetEventEmitterContext, hr as WidgetMethodKeyOf, ht as WidgetSystemRuntimeDisposedError, i as EmptyRegisteredDeps, in as WidgetSystemValidateStructure, ir as WidgetCapabilityOf, it as RuntimeMethodArgsDiagnostic, j as BlueprintNodeDiagnosticLocation, jn as WidgetPluginMethodsPhase, jr as JsonValue, jt as RuntimeMethod, k as BlueprintMethodDiagnosticLocation, kn as WidgetPluginEventsPhase, kr as JsonObject, kt as RuntimeEvent, l as RegisteredDeps, ln as WIDGET_CONFIG_JSON_SCHEMA_DIALECT, lr as WidgetInterfaces, lt as RuntimePropertyDiagnostic, m as StateGetDepExpression, mn as WidgetEventEmitter, mr as WidgetMethodArgsOf, mt as WidgetSystemRuntimeDiagnostic, n as DependencyBuilder, nn as WidgetSystemConfigurationError, nr as HasWidgetCapability, nt as RuntimeLevelDiagnostic, o as MethodInvokeDepExpression, on as createWidgetSystem, or as WidgetEventKeyOf, ot as RuntimeMethodDiagnostic, p as SelfStateDependencyOperations, pn as WidgetEventDefinition, pr as WidgetMemberValueOf, pt as SourceAccessDiagnostic, q as RelativePluginStructureDiagnosticInput, qn as WidgetStateDefaultContext, qt as WidgetSourceFor, r as DependencyConsumer, rn as WidgetSystemConfigurationErrorCode, rr as NonEmptyReadonlyArray, rt as RuntimeLevelDiagnosticLocation, s as OptionalizableDependencyTarget, sn as AnyWidgetPlugin, sr as WidgetEventsOf, st as RuntimeMethodResultDiagnostic, t as AnyDepExpression, tn as WidgetSystem, tr as ExecutionResult, tt as RuntimeDiagnosticLocation, u as SelfDependencyTarget, un as WidgetConfigDefinition, ur as WidgetInterfacesViolationOf, ut as RuntimePropertyResultDiagnostic, v as UnknownTargetDependencyOperations, vn as WidgetInterfacesViolation, vr as WidgetMethodsOf, vt as BlueprintSemanticSlots, w as BlueprintDependencyOperation, wn as WidgetPluginCapabilities, wr as WidgetSlotNameOf, wt as InvalidWidgetSystemBlueprint, x as BlueprintDefinitionDiagnostic, xn as WidgetMethodValidateArgsContext, xr as WidgetPropertyValueOf, xt as BlueprintWidgetNodeBase, y as UnknownTargetStateDependencyOperations, yn as WidgetMethodDefinition, yr as WidgetPropertiesOf, yt as BlueprintSemanticSlotsView, z as BlueprintWidgetDiagnosticLocation, zn as WidgetPropertiesSection, zt as SelfBlueprintWidgetNode } from "./dep-DAoSoLhi.mjs";
2
2
  //#region src/source-patch.d.ts
3
3
  type SourcePath = readonly (string | number)[] | string;
4
4
  type SourcePatchOperation = {
@@ -70,6 +70,15 @@ interface CreateWidgetDocumentOptions<Plugins extends AnyWidgetPluginTuple> {
70
70
  readonly system: WidgetSystem<Plugins>;
71
71
  readonly source: unknown;
72
72
  }
73
+ /**
74
+ * Creates a revisioned source + Blueprint coordinator.
75
+ *
76
+ * Ownership: `options.source` is retained by reference as revision 0's `blueprint.source`, and Core
77
+ * never mutates it. Handing it over transfers ownership, so it must not be mutated afterwards. Patches
78
+ * are copy-on-write: each new revision shares untouched subtrees with the previous one, so any revision
79
+ * can share structure with this original input, and mutating the input corrupts later revisions too.
80
+ * A host that keeps its own editable model should pass a copy (for example `structuredClone`).
81
+ */
73
82
  declare function createWidgetDocument<const Plugins extends AnyWidgetPluginTuple>(options: CreateWidgetDocumentOptions<Plugins>): WidgetDocument<Plugins>;
74
83
  //#endregion
75
84
  //#region src/separated-source.d.ts
@@ -146,4 +155,4 @@ declare function separateWidgetSource<const Plugins extends AnyWidgetPluginTuple
146
155
  */
147
156
  declare function normalizeSeparatedWidgetSource(input: unknown): SeparatedWidgetSourceNormalization;
148
157
  //#endregion
149
- export { type AnyDepExpression, type AnyWidgetPlugin, type AnyWidgetPluginTuple, type ApplyPatchFailure, type ApplyPatchOptions, type ApplyPatchResult, type BlueprintCompileView, type BlueprintConfigDiagnostic, type BlueprintDefinitionDiagnostic, type BlueprintDependencyDiagnostic, type BlueprintDependencyDiagnosticLocation, type BlueprintDependencyOperation, type BlueprintDependencyReference, type BlueprintDependencyTarget, type BlueprintDiagnostic, type BlueprintDiagnosticLocation, type BlueprintMethodDiagnosticLocation, type BlueprintNodeConfigFields, type BlueprintNodeDiagnostic, type BlueprintNodeDiagnosticLocation, type BlueprintPropertyDiagnosticLocation, type BlueprintSemanticSlots, type BlueprintSemanticSlotsView, type BlueprintSlotChildDiagnosticLocation, type BlueprintSlotDiagnosticLocation, type BlueprintSourceDiagnostic, type BlueprintSourceDiagnosticLocation, type BlueprintStructureDiagnostic, type BlueprintStructureDiagnosticLocation, type BlueprintWidgetDiagnosticLocation, type BlueprintWidgetNode, type BlueprintWidgetNodeBase, type BlueprintWidgetNodeView, type CreateWidgetDocumentOptions, type CreateWidgetSystemOptions, type CreateWidgetSystemRuntimeOptions, type DependencyBuilder, type DependencyConsumer, type Diagnostic, type DiagnosticBase, type DiagnosticCollector, type DiagnosticPath, type DocumentRevisionConflictFailure, EMPTY_DIAGNOSTICS, type EmptyRegisteredDeps, type ExecutionFailure, type ExecutionResult, type HasWidgetCapability, type InvalidWidgetSystemBlueprint, type JsonArray, type JsonCompatibilityDiagnostic, type JsonCompatibilityReason, type JsonObject, type JsonPrimitive, type JsonValue, type MaybeOptional, type MethodInvokeDepExpression, type NonEmptyReadonlyArray, type OptionalizableDependencyTarget, type PropertyGetDepExpression, type ReentrantApplyFailure, type RegisteredDeps, type RelativePluginStructureDiagnosticInput, type RelativeSlotStructureDiagnosticInput, type RelativeStructureDiagnosticLocation, type RelativeSystemStructureDiagnosticInput, type RelativeValueDiagnosticInput, type ResolvedBlueprintWidgetNode, type ResolvedBlueprintWidgetNodeFor, type ResolvedBlueprintWidgetNodeView, type ResolvedBlueprintWidgetNodeViewFor, type RuntimeDependencyTargetFailedDiagnostic, type RuntimeDependencyValueRejectedDiagnostic, type RuntimeDiagnostic, type RuntimeDiagnosticLocation, type RuntimeLevelDiagnostic, type RuntimeLevelDiagnosticLocation, type RuntimeMethod, type RuntimeMethodArgsDiagnostic, type RuntimeMethodDependencyDiagnostic, type RuntimeMethodDiagnostic, type RuntimeMethodResultDiagnostic, type RuntimeMethodSurface, type RuntimeProperty, type RuntimePropertyDependencyDiagnostic, type RuntimePropertyDiagnostic, type RuntimePropertyResultDiagnostic, type RuntimePropertySurface, type RuntimeState, type RuntimeStateDiagnostic, type RuntimeStateSurface, type RuntimeWidget, type RuntimeWidgetDiagnostic, type RuntimeWidgetFor, type SelfBlueprintWidgetNode, type SelfBlueprintWidgetNodeView, type SelfDependencyTarget, type SelfMethodDependencyOperations, type SelfPropertyDependencyOperations, type SelfStateDependencyOperations, type SeparatedSourceLocation, type SeparatedWidgetData, type SeparatedWidgetSource, type SeparatedWidgetSourceDiagnostic, type SeparatedWidgetSourceDiagnosticCode, type SeparatedWidgetSourceNormalization, type SeparatedWidgetStructure, type SourceAccessDiagnostic, type SourcePatch, type SourcePatchOperation, type SourcePatchOperationFailure, type SourcePatchOperationFailureCode, type SourcePath, type StateGetDepExpression, type StateSetDepExpression, type ToExecutedDep, type ToExecutedDeps, type UnknownTargetDependencyOperations, type UnknownTargetStateDependencyOperations, type UnresolvedBlueprintWidgetNode, type ValidBlueprintView, type ValidWidgetSystemBlueprint, type WidgetCapabilityOf, type WidgetCatalog, type WidgetCatalogEntry, type WidgetConfigDefinition, type WidgetConfigValidateContext, type WidgetDocument, type WidgetDocumentSnapshot, type WidgetId, type WidgetInterfaces, type WidgetInterfacesOf, type WidgetInterfacesViolation, type WidgetInterfacesViolationOf, type WidgetLocation, type WidgetLocationView, type WidgetMemberKey, type WidgetMemberKeysOf, type WidgetMemberValueOf, type WidgetMethodArgsOf, type WidgetMethodDefinition, type WidgetMethodExecuteContext, type WidgetMethodKeyOf, type WidgetMethodOf, type WidgetMethodReturnOf, type WidgetMethodValidateArgsContext, type WidgetMethodsOf, type WidgetMethodsSection, type WidgetPlugin, type WidgetPluginCapabilities, type WidgetPluginConfigPhase, type WidgetPluginDescriptionPhase, type WidgetPluginDonePhase, type WidgetPluginInterfacesPhase, type WidgetPluginMethodsPhase, type WidgetPluginOf, type WidgetPluginPropertiesPhase, type WidgetPluginSlotsPhase, type WidgetPluginStatePhase, type WidgetPluginTypeOf, type WidgetPluginValidateStructure, type WidgetPluginValidateStructureContext, type WidgetPropertiesOf, type WidgetPropertiesSection, type WidgetPropertyComputeContext, type WidgetPropertyDefinition, type WidgetPropertyKeyOf, type WidgetPropertyValueOf, type WidgetRawConfigOf, type WidgetRegisterDepsContext, type WidgetResolvedConfigContext, type WidgetResolvedConfigOf, type WidgetSlotDefinition, type WidgetSlotDefinitions, type WidgetSlotNameOf, type WidgetSlotValidateStructureContext, type WidgetSource, type WidgetSourceFor, type WidgetStateDefaultContext, type WidgetStateKeyOf, type WidgetStateMemberDefinition, type WidgetStateOf, type WidgetStateSection, type WidgetStateValidateContext, type WidgetStateValueOf, type WidgetSystem, type WidgetSystemBlueprint, type WidgetSystemBlueprintStatus, type WidgetSystemRuntime, type WidgetSystemRuntimeDiagnostic, WidgetSystemRuntimeDisposedError, type WidgetSystemValidateStructure, type WidgetSystemValidateStructureContext, createWidgetDocument, createWidgetPlugin, createWidgetSystem, normalizeSeparatedWidgetSource, separateWidgetSource };
158
+ export { type AnyDepExpression, type AnyWidgetPlugin, type AnyWidgetPluginTuple, type ApplyPatchFailure, type ApplyPatchOptions, type ApplyPatchResult, type BlueprintCompileView, type BlueprintConfigDiagnostic, type BlueprintDefinitionDiagnostic, type BlueprintDependencyDiagnostic, type BlueprintDependencyDiagnosticLocation, type BlueprintDependencyOperation, type BlueprintDependencyReference, type BlueprintDependencyTarget, type BlueprintDiagnostic, type BlueprintDiagnosticLocation, type BlueprintMethodDiagnosticLocation, type BlueprintNodeConfigFields, type BlueprintNodeDiagnostic, type BlueprintNodeDiagnosticLocation, type BlueprintPropertyDiagnosticLocation, type BlueprintSemanticSlots, type BlueprintSemanticSlotsView, type BlueprintSlotChildDiagnosticLocation, type BlueprintSlotDiagnosticLocation, type BlueprintSourceDiagnostic, type BlueprintSourceDiagnosticLocation, type BlueprintStructureDiagnostic, type BlueprintStructureDiagnosticLocation, type BlueprintWidgetDiagnosticLocation, type BlueprintWidgetNode, type BlueprintWidgetNodeBase, type BlueprintWidgetNodeView, type CreateWidgetDocumentOptions, type CreateWidgetSystemOptions, type CreateWidgetSystemRuntimeOptions, type DependencyBuilder, type DependencyConsumer, type Diagnostic, type DiagnosticBase, type DiagnosticCollector, type DiagnosticPath, type DocumentRevisionConflictFailure, EMPTY_DIAGNOSTICS, type EmptyRegisteredDeps, type ExecutionFailure, type ExecutionResult, type HasWidgetCapability, type InvalidWidgetSystemBlueprint, type JsonArray, type JsonCompatibilityDiagnostic, type JsonCompatibilityReason, type JsonObject, type JsonPrimitive, type JsonValue, type MaybeOptional, type MethodInvokeDepExpression, type NonEmptyReadonlyArray, type OptionalizableDependencyTarget, type PropertyGetDepExpression, type ReentrantApplyFailure, type RegisteredDeps, type RelativePluginStructureDiagnosticInput, type RelativeSlotStructureDiagnosticInput, type RelativeStructureDiagnosticLocation, type RelativeSystemStructureDiagnosticInput, type RelativeValueDiagnosticInput, type ResolvedBlueprintWidgetNode, type ResolvedBlueprintWidgetNodeFor, type ResolvedBlueprintWidgetNodeView, type ResolvedBlueprintWidgetNodeViewFor, type RuntimeDependencyTargetFailedDiagnostic, type RuntimeDependencyValueRejectedDiagnostic, type RuntimeDiagnostic, type RuntimeDiagnosticLocation, type RuntimeEvent, type RuntimeEventSurface, type RuntimeLevelDiagnostic, type RuntimeLevelDiagnosticLocation, type RuntimeMethod, type RuntimeMethodArgsDiagnostic, type RuntimeMethodDependencyDiagnostic, type RuntimeMethodDiagnostic, type RuntimeMethodResultDiagnostic, type RuntimeMethodSurface, type RuntimeProperty, type RuntimePropertyDependencyDiagnostic, type RuntimePropertyDiagnostic, type RuntimePropertyResultDiagnostic, type RuntimePropertySurface, type RuntimeState, type RuntimeStateDiagnostic, type RuntimeStateSurface, type RuntimeWidget, type RuntimeWidgetDiagnostic, type RuntimeWidgetFor, type SelfBlueprintWidgetNode, type SelfBlueprintWidgetNodeView, type SelfDependencyTarget, type SelfMethodDependencyOperations, type SelfPropertyDependencyOperations, type SelfStateDependencyOperations, type SeparatedSourceLocation, type SeparatedWidgetData, type SeparatedWidgetSource, type SeparatedWidgetSourceDiagnostic, type SeparatedWidgetSourceDiagnosticCode, type SeparatedWidgetSourceNormalization, type SeparatedWidgetStructure, type SourceAccessDiagnostic, type SourcePatch, type SourcePatchOperation, type SourcePatchOperationFailure, type SourcePatchOperationFailureCode, type SourcePath, type StateGetDepExpression, type StateSetDepExpression, type ToExecutedDep, type ToExecutedDeps, type UnknownTargetDependencyOperations, type UnknownTargetStateDependencyOperations, type UnresolvedBlueprintWidgetNode, type ValidBlueprintView, type ValidWidgetSystemBlueprint, WIDGET_CONFIG_JSON_SCHEMA_DIALECT, type WidgetCapabilityOf, type WidgetCatalog, type WidgetCatalogEntry, type WidgetConfigDefinition, type WidgetConfigJsonSchema, type WidgetConfigValidateContext, type WidgetDocument, type WidgetDocumentSnapshot, type WidgetEventArgsOf, type WidgetEventDefinition, type WidgetEventEmitter, type WidgetEventEmitterContext, type WidgetEventKeyOf, type WidgetEventsOf, type WidgetEventsSection, type WidgetId, type WidgetInterfaces, type WidgetInterfacesOf, type WidgetInterfacesViolation, type WidgetInterfacesViolationOf, type WidgetLocation, type WidgetLocationView, type WidgetMemberKey, type WidgetMemberKeysOf, type WidgetMemberValueOf, type WidgetMethodArgsOf, type WidgetMethodDefinition, type WidgetMethodExecuteContext, type WidgetMethodKeyOf, type WidgetMethodOf, type WidgetMethodReturnOf, type WidgetMethodValidateArgsContext, type WidgetMethodsOf, type WidgetMethodsSection, type WidgetPlugin, type WidgetPluginCapabilities, type WidgetPluginConfigMetadata, type WidgetPluginConfigPhase, type WidgetPluginDescriptionPhase, type WidgetPluginDonePhase, type WidgetPluginEventsPhase, type WidgetPluginInterfacesPhase, type WidgetPluginMethodsPhase, type WidgetPluginOf, type WidgetPluginPhaseOrderViolation, type WidgetPluginPropertiesPhase, type WidgetPluginSlotsPhase, type WidgetPluginStatePhase, type WidgetPluginTypeOf, type WidgetPluginValidateStructure, type WidgetPluginValidateStructureContext, type WidgetPropertiesOf, type WidgetPropertiesSection, type WidgetPropertyComputeContext, type WidgetPropertyDefinition, type WidgetPropertyKeyOf, type WidgetPropertyValueOf, type WidgetRawConfigOf, type WidgetRegisterDepsContext, type WidgetResolvedConfigContext, type WidgetResolvedConfigOf, type WidgetSlotDefinition, type WidgetSlotDefinitions, type WidgetSlotNameOf, type WidgetSlotValidateStructureContext, type WidgetSource, type WidgetSourceFor, type WidgetStateDefaultContext, type WidgetStateKeyOf, type WidgetStateMemberDefinition, type WidgetStateOf, type WidgetStateSection, type WidgetStateValidateContext, type WidgetStateValueOf, type WidgetSystem, type WidgetSystemBlueprint, type WidgetSystemBlueprintStatus, WidgetSystemConfigurationError, type WidgetSystemConfigurationErrorCode, type WidgetSystemRuntime, type WidgetSystemRuntimeDiagnostic, WidgetSystemRuntimeDisposedError, type WidgetSystemValidateStructure, type WidgetSystemValidateStructureContext, type WidgetValueContract, createWidgetDocument, createWidgetPlugin, createWidgetSystem, createWidgetValueContract, normalizeSeparatedWidgetSource, separateWidgetSource };