@deviltea/widget-core 0.0.6 → 0.1.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/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
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-DKbvAjPb.mjs";
1
+ import { $ as RuntimeDiagnostic, $n as WidgetStateValidateContext, $t as WidgetCatalog, A as BlueprintNodeDiagnostic, An as WidgetPluginDonePhase, Ar as WidgetStateValueOf, At as ResolvedBlueprintWidgetNodeViewFor, B as DiagnosticBase, Bn as WidgetPluginValidateStructure, Bt as RuntimeWidgetFor, C as BlueprintDependencyDiagnosticLocation, Cn as WidgetMethodValidateArgsContext, Cr as WidgetPropertyKeyOf, Ct as BlueprintWidgetNodeBase, D as BlueprintDiagnostic, Dn as WidgetPluginConfigMetadata, Dr as WidgetSlotNameOf, Dt as ResolvedBlueprintWidgetNode, E as BlueprintDependencyTarget, En as WidgetPluginCapabilities, Er as WidgetResolvedConfigOf, Et as InvalidWidgetSystemBlueprint, F as BlueprintSourceDiagnostic, Fn as WidgetPluginPropertiesPhase, Fr as MAX_JSON_DEPTH, Ft as RuntimeProperty, G as JsonCompatibilityReason, Gn as WidgetRegisterDepsContext, Gt as WidgetLocation, H as DiagnosticPath, Hn as WidgetPropertiesSection, Ht as SelfBlueprintWidgetNodeView, I as BlueprintSourceDiagnosticLocation, In as WidgetPluginSlotsPhase, Ir as isJsonValue, It as RuntimePropertySurface, J as RelativeStructureDiagnosticLocation, Jn as WidgetSlotDefinitions, Jt as WidgetSourceFor, K as RelativePluginStructureDiagnosticInput, Kn as WidgetResolvedConfigContext, Kt as WidgetLocationView, L as BlueprintStructureDiagnostic, Ln as WidgetPluginStatePhase, Lt as RuntimeState, M as BlueprintPropertyDiagnosticLocation, Mn as WidgetPluginInterfacesPhase, Mr as JsonObject, Mt as RuntimeEventSurface, N as BlueprintSlotChildDiagnosticLocation, Nn as WidgetPluginMethodsPhase, Nr as JsonPrimitive, Nt as RuntimeMethod, O as BlueprintDiagnosticLocation, On as WidgetPluginConfigPhase, Or as WidgetStateKeyOf, Ot as ResolvedBlueprintWidgetNodeFor, P as BlueprintSlotDiagnosticLocation, Pn as WidgetPluginPhaseOrderViolation, Pr as JsonValue, Pt as RuntimeMethodSurface, Q as RuntimeDependencyValueRejectedDiagnostic, Qn as WidgetStateSection, Qt as CreateWidgetSystemOptions, R as BlueprintStructureDiagnosticLocation, Rn as WidgetPluginStructurePhase, Rt as RuntimeStateSurface, S as BlueprintDependencyDiagnostic, Sn as WidgetMethodExecuteContext, Sr as WidgetPropertiesOf, St as BlueprintWidgetNode, T as BlueprintDependencyReference, Tn as WidgetPlugin, Tr as WidgetRawConfigOf, Tt as CreateWidgetSystemRuntimeOptions, U as EMPTY_DIAGNOSTICS, Un as WidgetPropertyComputeContext, Ut as UnresolvedBlueprintWidgetNode, V as DiagnosticCollector, Vn as WidgetPluginValidateStructureContext, Vt as SelfBlueprintWidgetNode, W as JsonCompatibilityDiagnostic, Wn as WidgetPropertyDefinition, Wt as ValidWidgetSystemBlueprint, X as RelativeValueDiagnosticInput, Xn as WidgetStateDefaultContext, Xt as WidgetSystemBlueprintStatus, Y as RelativeSystemStructureDiagnosticInput, Yn as WidgetSlotValidateStructureContext, Yt as WidgetSystemBlueprint, Z as RuntimeDependencyTargetFailedDiagnostic, Zn as WidgetStateMemberDefinition, Zt as WidgetSystemRuntime, _ as ToExecutedDeps, _n as WidgetEventsSection, _r as WidgetMethodArgsOf, _t as BlueprintNodeConfigFields, a as MaybeOptional, an as WidgetSystemValidateStructure, ar as HasWidgetCapability, at as RuntimeMethodDiagnostic, b as BlueprintConfigDiagnostic, bn as WidgetMethodDefinition, br as WidgetMethodReturnOf, bt as BlueprintSemanticSlotsView, c as PropertyGetDepExpression, cn as AnyWidgetPlugin, cr as WidgetEventArgsOf, ct as RuntimePropertyDependencyDiagnostic, d as SelfMethodDependencyOperations, dn as WidgetConfigDefinition, dr as WidgetId, dt as RuntimeStateDiagnostic, en as WidgetCatalogEntry, er as WidgetValueContract, et as RuntimeDiagnosticLocation, f as SelfPropertyDependencyOperations, fn as WidgetConfigJsonSchema, fr as WidgetInterfaces, ft as RuntimeWidgetDiagnostic, g as ToExecutedDep, gn as WidgetEventEmitterContext, gr as WidgetMemberValueOf, gt as BlueprintCompileView, h as StateSetDepExpression, hn as WidgetEventEmitter, hr as WidgetMemberKeysOf, ht as WidgetSystemRuntimeReentrancyError, i as EmptyRegisteredDeps, in as WidgetSystemConfigurationErrorCode, ir as ExecutionResult, it as RuntimeMethodDependencyDiagnostic, j as BlueprintNodeDiagnosticLocation, jn as WidgetPluginEventsPhase, jr as JsonArray, jt as RuntimeEvent, k as BlueprintMethodDiagnosticLocation, kn as WidgetPluginDescriptionPhase, kr as WidgetStateOf, kt as ResolvedBlueprintWidgetNodeView, l as RegisteredDeps, ln as AnyWidgetPluginTuple, lr as WidgetEventKeyOf, lt as RuntimePropertyDiagnostic, m as StateGetDepExpression, mn as WidgetEventDefinition, mr as WidgetMemberKey, mt as WidgetSystemRuntimeDisposedError, n as DependencyBuilder, nn as WidgetSystem, nr as createWidgetValueContract, nt as RuntimeLevelDiagnosticLocation, o as MethodInvokeDepExpression, on as WidgetSystemValidateStructureContext, or as NonEmptyReadonlyArray, ot as RuntimeMethodResultDiagnostic, p as SelfStateDependencyOperations, pn as WidgetConfigValidateContext, pr as WidgetInterfacesViolationOf, pt as SourceAccessDiagnostic, q as RelativeSlotStructureDiagnosticInput, qn as WidgetSlotDefinition, qt as WidgetSource, r as DependencyConsumer, rn as WidgetSystemConfigurationError, rr as ExecutionFailure, rt as RuntimeMethodArgsDiagnostic, s as OptionalizableDependencyTarget, sn as createWidgetSystem, sr as WidgetCapabilityOf, st as RuntimePrimitiveDiagnosticLocation, t as AnyDepExpression, tn as WidgetPluginOf, tr as createWidgetPlugin, tt as RuntimeLevelDiagnostic, u as SelfDependencyTarget, un as WIDGET_CONFIG_JSON_SCHEMA_DIALECT, ur as WidgetEventsOf, ut as RuntimePropertyResultDiagnostic, v as UnknownTargetDependencyOperations, vn as WidgetInterfacesOf, vr as WidgetMethodKeyOf, vt as BlueprintRuntimeView, w as BlueprintDependencyOperation, wn as WidgetMethodsSection, wr as WidgetPropertyValueOf, wt as BlueprintWidgetNodeView, x as BlueprintDefinitionDiagnostic, xn as WidgetMethodEventEmitter, xr as WidgetMethodsOf, xt as BlueprintSourcePath, y as UnknownTargetStateDependencyOperations, yn as WidgetInterfacesViolation, yr as WidgetMethodOf, yt as BlueprintSemanticSlots, z as BlueprintWidgetDiagnosticLocation, zn as WidgetPluginTypeOf, zt as RuntimeWidget } from "./dep-BXcdMm-M.mjs";
2
2
  //#region src/source-patch.d.ts
3
3
  type SourcePath = readonly (string | number)[] | string;
4
4
  type SourcePatchOperation = {
@@ -33,15 +33,26 @@ type SourcePatchOperation = {
33
33
  type SourcePatch = readonly SourcePatchOperation[];
34
34
  /**
35
35
  * Operation failure codes. `invalid-array-index` covers any non-canonical-index segment on an Array
36
- * parent (`'length'`, `'foo'`, `'01'`, structured `'-'`) in both path forms. `json-incompatible-value`
37
- * is an `add`/`replace`/`test` operand outside Core's JSON domain; `source-access-failed` concerns
38
- * unsafe access to source material only.
36
+ * parent (`'length'`, `'foo'`, `'01'`, structured `'-'`) in both path forms. `invalid-operation` is a
37
+ * patch that is not an Array, or an operation that is not an object or has an unknown `op`.
38
+ * `json-incompatible-value` is an `add`/`replace`/`test` operand outside Core's JSON domain (including one
39
+ * nested deeper than `MAX_JSON_DEPTH`); `max-depth-exceeded` is a path with more than `MAX_JSON_DEPTH + 2`
40
+ * segments (the longest path of a node a Blueprint materializes) or a `copy`/`move` source value nested
41
+ * deeper than `MAX_JSON_DEPTH`; `source-access-failed` concerns unsafe
42
+ * access to source material only.
39
43
  */
40
- type SourcePatchOperationFailureCode = 'invalid-path' | 'path-not-found' | 'path-not-traversable' | 'invalid-array-index' | 'invalid-move-target' | 'test-failed' | 'json-incompatible-value' | 'source-access-failed';
44
+ type SourcePatchOperationFailureCode = 'invalid-path' | 'invalid-operation' | 'path-not-found' | 'path-not-traversable' | 'invalid-array-index' | 'invalid-move-target' | 'max-depth-exceeded' | 'test-failed' | 'json-incompatible-value' | 'source-access-failed';
41
45
  interface SourcePatchOperationFailure {
42
46
  readonly code: SourcePatchOperationFailureCode;
43
47
  readonly operationIndex: number;
44
48
  readonly message: string;
49
+ /**
50
+ * Only for `json-incompatible-value`: where in the operand (`value`) the first offending part is, relative
51
+ * to the operand root (`[]` for the operand itself), like a Blueprint diagnostic of the same code.
52
+ */
53
+ readonly path?: DiagnosticPath;
54
+ /** Only for `json-incompatible-value`: why that part is outside the JSON domain, when known. */
55
+ readonly reason?: JsonCompatibilityReason;
45
56
  }
46
57
  //#endregion
47
58
  //#region src/document.d.ts
@@ -49,6 +60,16 @@ interface WidgetDocumentSnapshot<Plugins extends AnyWidgetPluginTuple = AnyWidge
49
60
  readonly revision: number;
50
61
  readonly blueprint: WidgetSystemBlueprint<Plugins>;
51
62
  }
63
+ /**
64
+ * What a committed `applyPatch` changed, passed to every listener beside the new snapshot: the snapshot it
65
+ * replaced and the exact patch that produced the new one (the same array that was applied, not a copy).
66
+ * Only an actual change commits; a no-op patch notifies nobody.
67
+ */
68
+ interface WidgetDocumentCommit<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> {
69
+ readonly previous: WidgetDocumentSnapshot<Plugins>;
70
+ readonly patch: SourcePatch;
71
+ }
72
+ type WidgetDocumentListener<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> = (snapshot: WidgetDocumentSnapshot<Plugins>, commit: WidgetDocumentCommit<Plugins>) => void;
52
73
  interface ApplyPatchOptions {
53
74
  readonly expectedRevision: number;
54
75
  }
@@ -75,7 +96,7 @@ type ApplyPatchResult = Result<{
75
96
  interface WidgetDocument<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> {
76
97
  getSnapshot: () => WidgetDocumentSnapshot<Plugins>;
77
98
  applyPatch: (patch: SourcePatch, options?: ApplyPatchOptions) => ApplyPatchResult;
78
- subscribe: (listener: (snapshot: WidgetDocumentSnapshot<Plugins>) => void) => () => void;
99
+ subscribe: (listener: WidgetDocumentListener<Plugins>) => () => void;
79
100
  }
80
101
  interface CreateWidgetDocumentOptions<Plugins extends AnyWidgetPluginTuple> {
81
102
  readonly system: WidgetSystem<Plugins>;
@@ -92,6 +113,41 @@ interface CreateWidgetDocumentOptions<Plugins extends AnyWidgetPluginTuple> {
92
113
  */
93
114
  declare function createWidgetDocument<const Plugins extends AnyWidgetPluginTuple>(options: CreateWidgetDocumentOptions<Plugins>): WidgetDocument<Plugins>;
94
115
  //#endregion
116
+ //#region src/runtime/adapter.d.ts
117
+ /**
118
+ * Receives an exception Core isolated from the operation that raised it (see {@link setIsolatedErrorHandler}).
119
+ * It receives only the exception: nothing says which Runtime, member or call isolated it.
120
+ */
121
+ type IsolatedErrorHandler = (error: unknown) => void;
122
+ /**
123
+ * Sets the function that receives the exceptions Core isolates: those thrown by a State, Property,
124
+ * diagnostics, Event, disposal, inspection or `WidgetDocument` listener, by a Property `compute` while a
125
+ * subscription re-evaluates it, and the `RangeError` that reports a bounded runaway loop. `null` or
126
+ * `undefined` restores the default report, a rethrow in a queued microtask. Returns the handler that was set
127
+ * before (`null` for the default), so a caller that sets one temporarily can put it back.
128
+ *
129
+ * Every report goes through one hand-over pass (see {@link deliverQueued}): an exception isolated while a
130
+ * Runtime operation is in progress is handed over once the outermost operation has finished its work, still
131
+ * before it returns to its caller (also when it throws); one isolated with no operation in progress starts the
132
+ * pass at once. Within a pass, reports and Property inspection deliveries are handed over one at a time, in the
133
+ * order Core produced them, and the handler is never re-entered: what its own calls isolate is handed over
134
+ * after it returns, behind what was already waiting. The handler therefore never runs while Core is evaluating,
135
+ * checking or flushing (unless the host holds its own alien-signals batch, which is unsupported), and it may
136
+ * read and write any Runtime. A `compute` exception that several subscriptions re-read is handed over once
137
+ * per pass.
138
+ *
139
+ * A handler that throws breaks nothing: its exception is rethrown in a queued microtask, and the remaining
140
+ * reports are still handed over. A report still queued when the handler is replaced goes to the new handler;
141
+ * one still queued when the handler is removed is rethrown in a microtask. A handler whose handling keeps
142
+ * causing new isolated exceptions is stopped by {@link MAX_HANDLER_CAUSED_DEPTH} and
143
+ * {@link MAX_HANDLER_CAUSED_REPORTS}, and what its handling causes after the inspection delivery bound stopped a
144
+ * pass is rethrown in a microtask too. These rethrows are the only microtasks Core queues while a handler is
145
+ * set; in a host without `queueMicrotask` such a report is dropped, and nothing else is affected. One handler serves the
146
+ * whole loaded Core module, every System, Runtime and `WidgetDocument` alike: it belongs to the host, and a
147
+ * plugin or renderer library must not set it.
148
+ */
149
+ declare function setIsolatedErrorHandler(handler: IsolatedErrorHandler | null | undefined): IsolatedErrorHandler | null;
150
+ //#endregion
95
151
  //#region src/separated-source.d.ts
96
152
  /** The tree half of a {@link SeparatedWidgetSource}. */
97
153
  interface SeparatedWidgetStructure {
@@ -103,6 +159,8 @@ interface SeparatedWidgetData {
103
159
  readonly id: WidgetId;
104
160
  readonly type: string;
105
161
  readonly config?: JsonValue;
162
+ /** The authored `meta` extension value, carried through losslessly and never interpreted. */
163
+ readonly meta?: JsonValue;
106
164
  }
107
165
  /**
108
166
  * Explicit alternative source representation: a nested structural tree plus a flat data list.
@@ -112,11 +170,18 @@ interface SeparatedWidgetSource {
112
170
  readonly structure: SeparatedWidgetStructure;
113
171
  readonly widgets: readonly SeparatedWidgetData[];
114
172
  }
115
- /** A representation-aware source location, independent from Blueprint semantic locations. */
173
+ /**
174
+ * A representation-aware source location, independent from Blueprint semantic locations. `widgets` and
175
+ * `structure` locate a fact in a separated input (`index` is absent when the fact concerns the whole `widgets`
176
+ * value); `source` locates a fact in the nested source given to {@link separateWidgetSource} by its path there.
177
+ */
116
178
  type SeparatedSourceLocation = {
117
179
  readonly area: 'widgets';
118
- readonly index: number;
180
+ readonly index?: number;
119
181
  readonly path?: readonly PropertyKey[];
182
+ } | {
183
+ readonly area: 'source';
184
+ readonly path: readonly PropertyKey[];
120
185
  } | {
121
186
  readonly area: 'structure';
122
187
  readonly path: readonly PropertyKey[];
@@ -131,9 +196,9 @@ type SeparatedWidgetSourceDiagnosticCode = 'invalid-separated-source' | 'invalid
131
196
  type SeparatedWidgetSourceDiagnostic = (DiagnosticBase<'invalid-separated-source', SeparatedSourceLocation> & {
132
197
  readonly reason: 'missing-structure' | 'invalid-widgets';
133
198
  }) | (DiagnosticBase<'invalid-separated-structure', SeparatedSourceLocation> & {
134
- readonly reason: 'invalid-node' | 'invalid-slots' | 'invalid-slot-children';
199
+ readonly reason: 'invalid-node' | 'invalid-slots' | 'invalid-slot-children' | 'max-depth-exceeded';
135
200
  }) | (DiagnosticBase<'invalid-separated-widget', SeparatedSourceLocation> & {
136
- readonly reason: 'invalid-entry' | 'invalid-id' | 'invalid-type';
201
+ readonly reason: 'invalid-entry' | 'invalid-id' | 'invalid-type' | 'invalid-config' | 'invalid-meta' | 'unexpected-field';
137
202
  }) | (DiagnosticBase<'duplicate-widget-id', SeparatedSourceLocation> & {
138
203
  readonly widgetId: WidgetId;
139
204
  }) | (DiagnosticBase<'missing-widget-data', SeparatedSourceLocation> & {
@@ -143,6 +208,15 @@ type SeparatedWidgetSourceDiagnostic = (DiagnosticBase<'invalid-separated-source
143
208
  }) | (DiagnosticBase<'duplicate-structure-id', SeparatedSourceLocation> & {
144
209
  readonly widgetId: WidgetId;
145
210
  });
211
+ /**
212
+ * Result of {@link separateWidgetSource}. `separated` is best-effort: it is non-null whenever `diagnostics` is
213
+ * empty, and null only when the root itself cannot be projected. When `diagnostics` is empty,
214
+ * `normalizeSeparatedWidgetSource(separated).source` is structurally equal to the projected source.
215
+ */
216
+ interface SeparatedWidgetSourceProjection {
217
+ readonly separated: SeparatedWidgetSource | null;
218
+ readonly diagnostics: readonly SeparatedWidgetSourceDiagnostic[];
219
+ }
146
220
  /** Result of explicit separated-source normalization. */
147
221
  interface SeparatedWidgetSourceNormalization {
148
222
  /**
@@ -154,9 +228,16 @@ interface SeparatedWidgetSourceNormalization {
154
228
  }
155
229
  /**
156
230
  * Projects canonical nested authored source into the explicit separated representation.
231
+ *
232
+ * The input is `unknown`: projection never throws on malformed input. Everything it cannot project
233
+ * faithfully (a malformed shape, a duplicate id, a non-JSON `config`/`meta`, a cyclic or too deep tree, an
234
+ * unrecognized field) is reported as a diagnostic located by its path in the input (`area: 'source'`), and
235
+ * the unprojectable part is left out of the best-effort result. When `diagnostics` is empty,
236
+ * `normalizeSeparatedWidgetSource(separated).source` is structurally equal to `source`.
237
+ *
157
238
  * Projection preserves nested slot order and emits flat data in deterministic depth-first order.
158
239
  */
159
- declare function separateWidgetSource<const Plugins extends AnyWidgetPluginTuple>(source: WidgetSource<Plugins>): SeparatedWidgetSource;
240
+ declare function separateWidgetSource(source: unknown): SeparatedWidgetSourceProjection;
160
241
  /**
161
242
  * Normalizes an explicitly supplied separated representation into a best-effort nested source.
162
243
  *
@@ -166,4 +247,4 @@ declare function separateWidgetSource<const Plugins extends AnyWidgetPluginTuple
166
247
  */
167
248
  declare function normalizeSeparatedWidgetSource(input: unknown): SeparatedWidgetSourceNormalization;
168
249
  //#endregion
169
- 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 };
250
+ 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 BlueprintRuntimeView, type BlueprintSemanticSlots, type BlueprintSemanticSlotsView, type BlueprintSlotChildDiagnosticLocation, type BlueprintSlotDiagnosticLocation, type BlueprintSourceDiagnostic, type BlueprintSourceDiagnosticLocation, type BlueprintSourcePath, type BlueprintStructureDiagnostic, type BlueprintStructureDiagnosticLocation, type BlueprintWidgetDiagnosticLocation, type BlueprintWidgetNode, type BlueprintWidgetNodeBase, type BlueprintWidgetNodeView, type CreateWidgetDocumentOptions, type CreateWidgetSystemOptions, type CreateWidgetSystemRuntimeOptions, type DependencyBuilder, type DependencyConsumer, type DiagnosticBase, type DiagnosticCollector, type DiagnosticPath, type DocumentRevisionConflictFailure, EMPTY_DIAGNOSTICS, type EmptyRegisteredDeps, type ExecutionFailure, type ExecutionResult, type HasWidgetCapability, type InvalidWidgetSystemBlueprint, type IsolatedErrorHandler, type JsonArray, type JsonCompatibilityDiagnostic, type JsonCompatibilityReason, type JsonObject, type JsonPrimitive, type JsonValue, MAX_JSON_DEPTH, 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 RuntimePrimitiveDiagnosticLocation, 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 SeparatedWidgetSourceProjection, 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 ValidWidgetSystemBlueprint, WIDGET_CONFIG_JSON_SCHEMA_DIALECT, type WidgetCapabilityOf, type WidgetCatalog, type WidgetCatalogEntry, type WidgetConfigDefinition, type WidgetConfigJsonSchema, type WidgetConfigValidateContext, type WidgetDocument, type WidgetDocumentCommit, type WidgetDocumentListener, 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 WidgetMethodEventEmitter, 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 WidgetPluginStructurePhase, 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, WidgetSystemRuntimeDisposedError, WidgetSystemRuntimeReentrancyError, type WidgetSystemValidateStructure, type WidgetSystemValidateStructureContext, type WidgetValueContract, createWidgetDocument, createWidgetPlugin, createWidgetSystem, createWidgetValueContract, isJsonValue, normalizeSeparatedWidgetSource, separateWidgetSource, setIsolatedErrorHandler };