@deviltea/widget-core 0.0.4 → 0.0.6

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/README.md CHANGED
@@ -75,6 +75,14 @@ See
75
75
  [Plugin registration errors](https://deviltea.github.io/widget/packages/widget-core#plugin-registration-errors)
76
76
  in the full guide.
77
77
 
78
+ A plugin with a config capability always runs `config.validate`. An omitted
79
+ raw `config` is validated as `null`, so required-ness comes from the raw config
80
+ type: declare `raw: Config | null` (and accept `null` in the validator) when
81
+ config may be omitted, or `raw: Config` to require it. A rejected config yields
82
+ `invalid-widget-config` and resolves through `resolve(null)`. See
83
+ [Config](https://deviltea.github.io/widget/packages/widget-core#config) in the
84
+ full guide.
85
+
78
86
  Plugin, config, and slot descriptions are required intrinsic metadata. The
79
87
  immutable `system.catalog` is a passive projection of registered widget types,
80
88
  descriptions, and capability descriptions; it does not contain Blueprint or
@@ -189,7 +197,9 @@ runtime.dispose()
189
197
  ### Blueprint diagnostics
190
198
 
191
199
  `createBlueprint` accepts `unknown`; malformed input never throws — it always
192
- produces an inspectable Blueprint. Every diagnostic has top-level `code`,
200
+ produces an inspectable Blueprint. `createBlueprintFromJson(text)` is the
201
+ equivalent of `createBlueprint(JSON.parse(text))` that skips the JSON-domain
202
+ inspection, because Core parsed the value itself. Every diagnostic has top-level `code`,
193
203
  `location`, and `message` fields. Variant-specific facts are direct fields;
194
204
  structured `path` and `related` fields are not hidden behind a `source` object.
195
205
  Codes are stable lowercase kebab-case values such as
@@ -358,6 +368,17 @@ later occurrence is de-identified with its available subtree preserved.
358
368
  - Every `RuntimeMethod` invocation batches its dependency/state writes; the
359
369
  batch flushes once the method returns, so partial writes from nested method
360
370
  calls are not observed mid-flight by outside subscribers.
371
+ - A failed dependency call adds a consumer-local `dependency-target-failed` /
372
+ `dependency-value-rejected` diagnostic to the calling Property or Method's
373
+ active diagnostic collector. Computing a fallback value after the failure
374
+ does not make the operation succeed: the result is still `ok: false`. See
375
+ [Dependency failures fail the consumer](https://deviltea.github.io/widget/packages/widget-core#dependency-failures-fail-the-consumer).
376
+ - `runtime.resetState()` restores every State member to its initialization
377
+ outcome (value and diagnostic snapshot) in one batch without re-running
378
+ `validate`, so one Runtime can evaluate many independent inputs. See
379
+ [Reusing a Runtime](https://deviltea.github.io/widget/packages/widget-core#reusing-a-runtime-resetstate).
380
+ - A callback's `addDiagnostic` / `hasAnyDiagnostic` throw a `TypeError` when
381
+ called after that callback returned.
361
382
  - Every state write, property evaluation, and method invocation keeps the
362
383
  **latest completed** diagnostic snapshot only (`getDiagnostics()` /
363
384
  `subscribeDiagnostics()`), never a history.
@@ -395,6 +416,15 @@ import { inspectBlueprint, inspectRuntime } from '@deviltea/widget-core/inspecti
395
416
  in the full guide for the exact contract, including the Event inspection
396
417
  delivery guarantees.
397
418
 
419
+ ### Host requirements
420
+
421
+ The current implementation needs an ES2022 engine and a global
422
+ `queueMicrotask` whose jobs the host actually runs: a throwing `subscribe` /
423
+ `subscribeDiagnostics` listener is isolated and rethrown in a microtask.
424
+ Embedded engines such as QuickJS (`rquickjs`) must drain their pending jobs,
425
+ or those listener errors never surface. See
426
+ [Host requirements](https://deviltea.github.io/widget/packages/widget-core#host-requirements).
427
+
398
428
  The full guide at
399
429
  [docs/site/packages/widget-core.md](https://deviltea.github.io/widget/packages/widget-core)
400
430
  covers the dependency grammar, the compile pipeline, and every Runtime
@@ -35,7 +35,12 @@ type WidgetMemberKey = string;
35
35
  */
36
36
  interface WidgetInterfaces {
37
37
  config?: {
38
- raw: Record<any, any>;
38
+ /**
39
+ * The authored config values the plugin accepts. `config.validate` always runs, and an omitted
40
+ * config is validated as `null`, so include `null` (e.g. `raw: MyConfig | null`) when config may be
41
+ * omitted; leave it out to make config required.
42
+ */
43
+ raw: Record<any, any> | null;
39
44
  resolved: Record<any, any>;
40
45
  };
41
46
  slots?: string;
@@ -482,6 +487,14 @@ interface WidgetSystem<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTup
482
487
  * editing your own object.
483
488
  */
484
489
  createBlueprint: (definition: unknown) => WidgetSystemBlueprint<Plugins>;
490
+ /**
491
+ * Parses `text` with `JSON.parse` and compiles the result. Observably equivalent to
492
+ * `createBlueprint(JSON.parse(text))`, but cheaper: a value produced by `JSON.parse` (without a
493
+ * reviver) is in the authored JSON domain by construction, so Core skips the whole-source JSON-domain
494
+ * inspection and `sourceJsonCompatible` is `true`. Invalid JSON text throws the `SyntaxError` from
495
+ * `JSON.parse`, unchanged. The parsed source is referenced by nothing but the Blueprint.
496
+ */
497
+ createBlueprintFromJson: (text: string) => WidgetSystemBlueprint<Plugins>;
485
498
  }
486
499
  type WidgetSystemConfigurationErrorCode = 'foreign-plugin' | 'duplicate-plugin-type';
487
500
  /**
@@ -661,8 +674,10 @@ interface ValidBlueprintView<Plugins extends AnyWidgetPluginTuple = AnyWidgetPlu
661
674
  type WidgetSourceFor<Plugin extends AnyWidgetPlugin, Plugins extends AnyWidgetPluginTuple> = {
662
675
  readonly id: WidgetId;
663
676
  readonly type: WidgetPluginTypeOf<Plugin>;
664
- } & (HasWidgetCapability<WidgetInterfacesOf<Plugin>, 'config'> extends true ? {
677
+ } & (HasWidgetCapability<WidgetInterfacesOf<Plugin>, 'config'> extends true ? [null] extends [WidgetRawConfigOf<WidgetInterfacesOf<Plugin>>] ? {
665
678
  readonly config?: WidgetRawConfigOf<WidgetInterfacesOf<Plugin>>;
679
+ } : {
680
+ readonly config: WidgetRawConfigOf<WidgetInterfacesOf<Plugin>>;
666
681
  } : unknown) & (HasWidgetCapability<WidgetInterfacesOf<Plugin>, 'slots'> extends true ? {
667
682
  readonly slots?: { readonly [Name in WidgetSlotNameOf<WidgetInterfacesOf<Plugin>>]?: readonly WidgetSource<Plugins>[]; };
668
683
  } : unknown);
@@ -784,6 +799,14 @@ interface WidgetSystemRuntime<Plugins extends AnyWidgetPluginTuple = AnyWidgetPl
784
799
  readonly blueprint: ValidWidgetSystemBlueprint<Plugins>;
785
800
  readonly isDisposed: boolean;
786
801
  getWidget: (id: WidgetId) => RuntimeWidget<Plugins> | null;
802
+ /**
803
+ * Restores every State member of every widget to its initialization outcome (override > default >
804
+ * `null`, as validated when this Runtime was created): the same value and the same diagnostic snapshot,
805
+ * without running `validate` again. All writes form one batch, so dependents recompute and subscribers
806
+ * are notified once. Property and Method diagnostic snapshots are not reset; Properties re-evaluate
807
+ * through ordinary invalidation.
808
+ */
809
+ resetState: () => void;
787
810
  /**
788
811
  * Runtime-level diagnostics plus the current state/property/method diagnostic snapshots, in deterministic
789
812
  * order. Never history, and never activates property evaluation.
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-DAoSoLhi.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-DKbvAjPb.mjs";
2
2
  //#region src/source-patch.d.ts
3
3
  type SourcePath = readonly (string | number)[] | string;
4
4
  type SourcePatchOperation = {
package/dist/index.mjs CHANGED
@@ -30,6 +30,9 @@ function accessDiagnostic(path) {
30
30
  message: "Authored source could not be safely inspected."
31
31
  };
32
32
  }
33
+ /**
34
+ * `path` is one shared stack, pushed before and popped after each child visit; diagnostics copy it.
35
+ */
33
36
  function inspectJsonValueAt(value, path, active, diagnostics) {
34
37
  if (value === null || typeof value === "string" || typeof value === "boolean") return;
35
38
  if (typeof value === "number") {
@@ -122,7 +125,9 @@ function inspectJsonValueAt(value, path, active, diagnostics) {
122
125
  diagnostics.push(jsonDiagnostic([...path, index], "accessor-property"));
123
126
  continue;
124
127
  }
125
- inspectJsonValueAt(descriptor.value, [...path, index], active, diagnostics);
128
+ path.push(index);
129
+ inspectJsonValueAt(descriptor.value, path, active, diagnostics);
130
+ path.pop();
126
131
  }
127
132
  return;
128
133
  }
@@ -146,7 +151,9 @@ function inspectJsonValueAt(value, path, active, diagnostics) {
146
151
  diagnostics.push(jsonDiagnostic([...path, key], "accessor-property"));
147
152
  continue;
148
153
  }
149
- inspectJsonValueAt(descriptor.value, [...path, key], active, diagnostics);
154
+ path.push(key);
155
+ inspectJsonValueAt(descriptor.value, path, active, diagnostics);
156
+ path.pop();
150
157
  }
151
158
  } finally {
152
159
  active.delete(value);
@@ -1508,6 +1515,14 @@ function createRuntimeContext() {
1508
1515
  function assertSyncValue(value, description) {
1509
1516
  if ((typeof value === "object" && value !== null || typeof value === "function") && "then" in value && typeof value.then === "function") throw new TypeError(`${description} returned a thenable. The widget-core semantic boundary is synchronous only.`);
1510
1517
  }
1518
+ /**
1519
+ * Callback-context lifetime guard: a callback's `addDiagnostic` / `hasAnyDiagnostic` belong to the
1520
+ * synchronous call that received them. Calling one after that callback returned or threw is an
1521
+ * implementation-contract violation (the operation's diagnostics are already final), so it throws.
1522
+ */
1523
+ function throwClosedCollector(method) {
1524
+ throw new TypeError(`${method} was called after its callback returned. Diagnostics must be reported synchronously while the callback runs.`);
1525
+ }
1511
1526
  //#endregion
1512
1527
  //#region src/runtime/deps.ts
1513
1528
  function consumerDependencyDiagnostic(params, dependency, message, received, related, cause) {
@@ -1636,24 +1651,32 @@ function materializeResolvedLeaf(leaf, params) {
1636
1651
  const related = locationOf(operation, resolveTargetWidgetId(params.nodes, leaf.targetNodeId));
1637
1652
  const leafId = nextLeafId++;
1638
1653
  switch (operation.type) {
1639
- case "state-get": return () => {
1640
- const target = resolveEntry(params, leaf.targetNodeId).state.get(operation.key);
1641
- if (target === void 0) throw new Error(`widget-core: internal error — resolved state-get target "${operation.key}" is missing.`);
1642
- const refined = applyRefinements(target.internal.get(), leaf.refinements);
1643
- if (!refined.ok) {
1644
- const diagnostic = consumerDependencyDiagnostic(params, reference, "The dependency value failed validation.", { value: refined.received }, related);
1645
- const diagnostics = freezeDiagnosticSnapshot([deepFreezeDiagnostic(diagnostic)]);
1646
- reportDependencyDiagnostic(params, diagnostic, dependencyDedupeDescriptor(leafId, refined.received));
1654
+ case "state-get": {
1655
+ let target;
1656
+ return () => {
1657
+ target ??= resolveEntry(params, leaf.targetNodeId).state.get(operation.key);
1658
+ if (target === void 0) throw new Error(`widget-core: internal error — resolved state-get target "${operation.key}" is missing.`);
1659
+ const raw = target.internal.get();
1660
+ if (leaf.refinements.length === 0) return {
1661
+ ok: true,
1662
+ value: raw
1663
+ };
1664
+ const refined = applyRefinements(raw, leaf.refinements);
1665
+ if (!refined.ok) {
1666
+ const diagnostic = consumerDependencyDiagnostic(params, reference, "The dependency value failed validation.", { value: refined.received }, related);
1667
+ const diagnostics = freezeDiagnosticSnapshot([deepFreezeDiagnostic(diagnostic)]);
1668
+ reportDependencyDiagnostic(params, diagnostic, dependencyDedupeDescriptor(leafId, refined.received));
1669
+ return {
1670
+ ok: false,
1671
+ failure: { diagnostics }
1672
+ };
1673
+ }
1647
1674
  return {
1648
- ok: false,
1649
- failure: { diagnostics }
1675
+ ok: true,
1676
+ value: refined.value
1650
1677
  };
1651
- }
1652
- return {
1653
- ok: true,
1654
- value: refined.value
1655
1678
  };
1656
- };
1679
+ }
1657
1680
  case "state-set": return (candidate) => {
1658
1681
  const target = resolveEntry(params, leaf.targetNodeId).state.get(operation.key);
1659
1682
  if (target === void 0) throw new Error(`widget-core: internal error — resolved state-set target "${operation.key}" is missing.`);
@@ -1667,29 +1690,36 @@ function materializeResolvedLeaf(leaf, params) {
1667
1690
  failure: { diagnostics: wrapTargetFailure(params, reference, result.failure.diagnostics, related, leafId) }
1668
1691
  };
1669
1692
  };
1670
- case "property-get": return () => {
1671
- const target = resolveEntry(params, leaf.targetNodeId).properties.get(operation.name);
1672
- if (target === void 0) throw new Error(`widget-core: internal error — resolved property-get target "${operation.name}" is missing.`);
1673
- const targetResult = target.internal.getResult();
1674
- if (!targetResult.ok) return {
1675
- ok: false,
1676
- failure: { diagnostics: wrapTargetFailure(params, reference, targetResult.failure.diagnostics, related, leafId) }
1677
- };
1678
- const refined = applyRefinements(targetResult.value, leaf.refinements);
1679
- if (!refined.ok) {
1680
- const diagnostic = consumerDependencyDiagnostic(params, reference, "The dependency value failed validation.", { value: refined.received }, related);
1681
- const diagnostics = freezeDiagnosticSnapshot([deepFreezeDiagnostic(diagnostic)]);
1682
- reportDependencyDiagnostic(params, diagnostic, dependencyDedupeDescriptor(leafId, refined.received));
1683
- return {
1693
+ case "property-get": {
1694
+ let target;
1695
+ return () => {
1696
+ target ??= resolveEntry(params, leaf.targetNodeId).properties.get(operation.name);
1697
+ if (target === void 0) throw new Error(`widget-core: internal error — resolved property-get target "${operation.name}" is missing.`);
1698
+ const targetResult = target.internal.getResult();
1699
+ if (!targetResult.ok) return {
1684
1700
  ok: false,
1685
- failure: { diagnostics }
1701
+ failure: { diagnostics: wrapTargetFailure(params, reference, targetResult.failure.diagnostics, related, leafId) }
1702
+ };
1703
+ if (leaf.refinements.length === 0) return {
1704
+ ok: true,
1705
+ value: targetResult.value
1706
+ };
1707
+ const refined = applyRefinements(targetResult.value, leaf.refinements);
1708
+ if (!refined.ok) {
1709
+ const diagnostic = consumerDependencyDiagnostic(params, reference, "The dependency value failed validation.", { value: refined.received }, related);
1710
+ const diagnostics = freezeDiagnosticSnapshot([deepFreezeDiagnostic(diagnostic)]);
1711
+ reportDependencyDiagnostic(params, diagnostic, dependencyDedupeDescriptor(leafId, refined.received));
1712
+ return {
1713
+ ok: false,
1714
+ failure: { diagnostics }
1715
+ };
1716
+ }
1717
+ return {
1718
+ ok: true,
1719
+ value: refined.value
1686
1720
  };
1687
- }
1688
- return {
1689
- ok: true,
1690
- value: refined.value
1691
1721
  };
1692
- };
1722
+ }
1693
1723
  case "method-invoke": return (...args) => {
1694
1724
  const target = resolveEntry(params, leaf.targetNodeId).methods.get(operation.name);
1695
1725
  if (target === void 0) throw new Error(`widget-core: internal error — resolved method-invoke target "${operation.name}" is missing.`);
@@ -1744,17 +1774,20 @@ function materializeDependencyTree(tree, params) {
1744
1774
  //#endregion
1745
1775
  //#region src/runtime/collector.ts
1746
1776
  function createOperationCollector() {
1747
- const entries = [];
1748
- const seenAnchorsByScope = /* @__PURE__ */ new Map();
1777
+ let entries = null;
1778
+ let seenAnchorsByScope = null;
1779
+ let closed = false;
1749
1780
  return {
1750
1781
  addDiagnostic(input) {
1751
- entries.push({
1782
+ if (closed) throwClosedCollector("addDiagnostic");
1783
+ (entries ??= []).push({
1752
1784
  kind: "relative",
1753
1785
  input
1754
1786
  });
1755
1787
  },
1756
1788
  addFinalizedDiagnostic(diagnostic, dedupe) {
1757
1789
  if (dedupe !== void 0) {
1790
+ seenAnchorsByScope ??= /* @__PURE__ */ new Map();
1758
1791
  let seenAnchors = seenAnchorsByScope.get(dedupe.scope);
1759
1792
  if (seenAnchors === void 0) {
1760
1793
  seenAnchors = /* @__PURE__ */ new Set();
@@ -1763,16 +1796,21 @@ function createOperationCollector() {
1763
1796
  if (seenAnchors.has(dedupe.anchor)) return;
1764
1797
  seenAnchors.add(dedupe.anchor);
1765
1798
  }
1766
- entries.push({
1799
+ (entries ??= []).push({
1767
1800
  kind: "final",
1768
1801
  diagnostic
1769
1802
  });
1770
1803
  },
1771
1804
  hasAnyDiagnostic() {
1772
- return entries.length > 0;
1805
+ if (closed) throwClosedCollector("hasAnyDiagnostic");
1806
+ return entries !== null;
1773
1807
  },
1774
1808
  finalize(toFinalDiagnostic) {
1809
+ if (entries === null) return EMPTY_DIAGNOSTICS;
1775
1810
  return freezeDiagnosticSnapshot(entries.map((entry) => entry.kind === "relative" ? toFinalDiagnostic(entry.input) : entry.diagnostic));
1811
+ },
1812
+ close() {
1813
+ closed = true;
1776
1814
  }
1777
1815
  };
1778
1816
  }
@@ -1780,6 +1818,12 @@ function createOperationCollector() {
1780
1818
  //#region src/runtime/method.ts
1781
1819
  function createMethodPrimitive(context, params) {
1782
1820
  const diagnosticsSignal = signal(EMPTY_DIAGNOSTICS);
1821
+ let committedDiagnostics = EMPTY_DIAGNOSTICS;
1822
+ function commitDiagnostics(next) {
1823
+ if (next === committedDiagnostics) return;
1824
+ committedDiagnostics = next;
1825
+ writeDeferringFlush(() => diagnosticsSignal(next));
1826
+ }
1783
1827
  function invoke(...args) {
1784
1828
  context.assertActive();
1785
1829
  return runRuntimeOperation(() => invokeWithinOperation(...args));
@@ -1793,12 +1837,19 @@ function createMethodPrimitive(context, params) {
1793
1837
  addDiagnostic: argsCollector.addDiagnostic,
1794
1838
  hasAnyDiagnostic: argsCollector.hasAnyDiagnostic
1795
1839
  };
1796
- const validArgs = params.definition.validateArgs(args, argsCtx);
1797
- assertSyncValue(validArgs, `Method "${params.name}"'s validateArgs`);
1798
- if (!validArgs || argsCollector.hasAnyDiagnostic()) {
1840
+ let validArgs;
1841
+ let hasArgsDiagnostic;
1842
+ try {
1843
+ validArgs = params.definition.validateArgs(args, argsCtx);
1844
+ assertSyncValue(validArgs, `Method "${params.name}"'s validateArgs`);
1845
+ hasArgsDiagnostic = argsCollector.hasAnyDiagnostic();
1846
+ } finally {
1847
+ argsCollector.close();
1848
+ }
1849
+ if (!validArgs || hasArgsDiagnostic) {
1799
1850
  const finalized = argsCollector.finalize((input) => buildMethodArgsDiagnostic(params.widgetId, params.name, args, input));
1800
1851
  const diagnostics = finalized.length > 0 ? finalized : freezeDiagnosticSnapshot([buildDefaultMethodArgsDiagnostic(params.widgetId, params.name, args)]);
1801
- writeDeferringFlush(() => diagnosticsSignal(diagnostics));
1852
+ commitDiagnostics(diagnostics);
1802
1853
  return Object.freeze({
1803
1854
  ok: false,
1804
1855
  failure: { diagnostics }
@@ -1816,10 +1867,15 @@ function createMethodPrimitive(context, params) {
1816
1867
  addDiagnostic: execCollector.addDiagnostic,
1817
1868
  hasAnyDiagnostic: execCollector.hasAnyDiagnostic
1818
1869
  };
1819
- const value = context.withActiveCollector(sink, () => params.definition.execute(executeCtx));
1870
+ let value;
1871
+ try {
1872
+ value = context.withActiveCollector(sink, () => params.definition.execute(executeCtx));
1873
+ } finally {
1874
+ execCollector.close();
1875
+ }
1820
1876
  assertSyncValue(value, `Method "${params.name}"'s execute`);
1821
1877
  const diagnostics = execCollector.finalize((input) => buildMethodResultDiagnostic(params.widgetId, params.name, value, input));
1822
- writeDeferringFlush(() => diagnosticsSignal(toDiagnosticSnapshot(diagnostics)));
1878
+ commitDiagnostics(toDiagnosticSnapshot(diagnostics));
1823
1879
  const result = diagnostics.length > 0 ? {
1824
1880
  ok: false,
1825
1881
  failure: { diagnostics }
@@ -1904,17 +1960,22 @@ function resolveStateOverrides(compiled, overrideStateDefaults) {
1904
1960
  const NEVER_EVALUATED_SNAPSHOT = Object.freeze({ status: "never-evaluated" });
1905
1961
  function createPropertyPrimitive(context, params) {
1906
1962
  const diagnosticsSignal = signal(EMPTY_DIAGNOSTICS);
1963
+ let committedDiagnostics = EMPTY_DIAGNOSTICS;
1907
1964
  let inspectionSnapshot = NEVER_EVALUATED_SNAPSHOT;
1908
1965
  let inspectionListeners = null;
1909
1966
  let lastPublishedResult = null;
1910
- function publishInspectionCompletion(result) {
1911
- inspectionSnapshot = Object.freeze({
1967
+ function readInspectionSnapshot() {
1968
+ return inspectionSnapshot ??= Object.freeze({
1912
1969
  status: "completed",
1913
- result
1970
+ result: lastPublishedResult
1914
1971
  });
1915
- if (inspectionListeners === null) return;
1972
+ }
1973
+ function publishInspectionCompletion() {
1974
+ inspectionSnapshot = null;
1975
+ if (inspectionListeners === null || inspectionListeners.length === 0) return;
1976
+ const snapshot = readInspectionSnapshot();
1916
1977
  const listenersSnapshot = inspectionListeners.slice();
1917
- for (const entry of listenersSnapshot) invokeListenerIsolated(entry.listener, inspectionSnapshot);
1978
+ for (const entry of listenersSnapshot) invokeListenerIsolated(entry.listener, snapshot);
1918
1979
  }
1919
1980
  const resultComputed = computed(() => {
1920
1981
  const collector = createOperationCollector();
@@ -1927,10 +1988,19 @@ function createPropertyPrimitive(context, params) {
1927
1988
  addDiagnostic: collector.addDiagnostic,
1928
1989
  hasAnyDiagnostic: collector.hasAnyDiagnostic
1929
1990
  };
1930
- const value = context.withActiveCollector(sink, () => params.definition.compute(ctx));
1991
+ let value;
1992
+ try {
1993
+ value = context.withActiveCollector(sink, () => params.definition.compute(ctx));
1994
+ } finally {
1995
+ collector.close();
1996
+ }
1931
1997
  assertSyncValue(value, `Property "${params.name}"'s compute`);
1932
1998
  const diagnostics = collector.finalize((input) => buildPropertyResultDiagnostic(params.widgetId, params.name, value, input));
1933
- writeDeferringFlush(() => diagnosticsSignal(toDiagnosticSnapshot(diagnostics)));
1999
+ const snapshot = toDiagnosticSnapshot(diagnostics);
2000
+ if (snapshot !== committedDiagnostics) {
2001
+ committedDiagnostics = snapshot;
2002
+ writeDeferringFlush(() => diagnosticsSignal(snapshot));
2003
+ }
1934
2004
  const result = diagnostics.length > 0 ? {
1935
2005
  ok: false,
1936
2006
  failure: { diagnostics }
@@ -1961,7 +2031,7 @@ function createPropertyPrimitive(context, params) {
1961
2031
  const result = runRuntimeOperation(resultComputed);
1962
2032
  if (result !== lastPublishedResult) {
1963
2033
  lastPublishedResult = result;
1964
- publishInspectionCompletion(result);
2034
+ publishInspectionCompletion();
1965
2035
  }
1966
2036
  return result;
1967
2037
  }
@@ -1969,7 +2039,7 @@ function createPropertyPrimitive(context, params) {
1969
2039
  getResult: getResultWithInspectionPublish,
1970
2040
  getDiagnostics: () => diagnosticsSignal(),
1971
2041
  inspection: {
1972
- getSnapshot: () => inspectionSnapshot,
2042
+ getSnapshot: readInspectionSnapshot,
1973
2043
  subscribe: (listener) => {
1974
2044
  const entry = { listener };
1975
2045
  if (inspectionListeners === null) inspectionListeners = [];
@@ -2024,6 +2094,12 @@ function createStatePrimitive(context, params) {
2024
2094
  * out of the graph, so the propagations they deferred are released here: still inside the very `set()`
2025
2095
  * call that caused them, before its `ExecutionResult` reaches the caller.
2026
2096
  */
2097
+ let committedDiagnostics = EMPTY_DIAGNOSTICS;
2098
+ function commitDiagnostics(next) {
2099
+ if (next === committedDiagnostics) return;
2100
+ committedDiagnostics = next;
2101
+ writeDeferringFlush(() => diagnosticsSignal(next));
2102
+ }
2027
2103
  function attemptSet(candidate) {
2028
2104
  return runRuntimeOperation(() => attemptSetWithinOperation(candidate));
2029
2105
  }
@@ -2034,12 +2110,19 @@ function createStatePrimitive(context, params) {
2034
2110
  addDiagnostic: collector.addDiagnostic,
2035
2111
  hasAnyDiagnostic: collector.hasAnyDiagnostic
2036
2112
  };
2037
- const isValid = params.definition.validate(candidate, ctx);
2038
- assertSyncValue(isValid, `State "${params.key}"'s validate`);
2039
- if (!isValid || collector.hasAnyDiagnostic()) {
2113
+ let isValid;
2114
+ let hasDiagnostic;
2115
+ try {
2116
+ isValid = params.definition.validate(candidate, ctx);
2117
+ assertSyncValue(isValid, `State "${params.key}"'s validate`);
2118
+ hasDiagnostic = collector.hasAnyDiagnostic();
2119
+ } finally {
2120
+ collector.close();
2121
+ }
2122
+ if (!isValid || hasDiagnostic) {
2040
2123
  const finalized = collector.finalize((input) => buildStateValidationDiagnostic(params.widgetId, params.key, candidate, input));
2041
2124
  const diagnostics = finalized.length > 0 ? finalized : freezeDiagnosticSnapshot([buildDefaultStateValidationDiagnostic(params.widgetId, params.key, candidate)]);
2042
- writeDeferringFlush(() => diagnosticsSignal(diagnostics));
2125
+ commitDiagnostics(diagnostics);
2043
2126
  return {
2044
2127
  ok: false,
2045
2128
  failure: { diagnostics }
@@ -2048,14 +2131,26 @@ function createStatePrimitive(context, params) {
2048
2131
  assertSyncValue(candidate, `State "${params.key}"'s value`);
2049
2132
  const previous = valueSignal();
2050
2133
  valueSignal(candidate);
2051
- writeDeferringFlush(() => diagnosticsSignal(EMPTY_DIAGNOSTICS));
2134
+ commitDiagnostics(EMPTY_DIAGNOSTICS);
2052
2135
  if (candidate !== previous) publishInspectionSnapshot(candidate);
2053
2136
  return {
2054
2137
  ok: true,
2055
2138
  value: candidate
2056
2139
  };
2057
2140
  }
2141
+ let initialValue = null;
2142
+ let initialDiagnostics = EMPTY_DIAGNOSTICS;
2058
2143
  const internal = {
2144
+ captureInitial() {
2145
+ initialValue = valueSignal();
2146
+ initialDiagnostics = committedDiagnostics;
2147
+ },
2148
+ restoreInitial() {
2149
+ const previous = valueSignal();
2150
+ valueSignal(initialValue);
2151
+ commitDiagnostics(initialDiagnostics);
2152
+ if (initialValue !== previous) publishInspectionSnapshot(initialValue);
2153
+ },
2059
2154
  get: () => valueSignal(),
2060
2155
  getDiagnostics: () => diagnosticsSignal(),
2061
2156
  attemptSet,
@@ -2141,8 +2236,8 @@ function createWidgetSystemRuntime(blueprint, options) {
2141
2236
  const blueprintView = buildBlueprintView(blueprint);
2142
2237
  const registry = /* @__PURE__ */ new Map();
2143
2238
  function buildConfigFragmentFor(node) {
2144
- if (readWidgetPluginDefinition(node.plugin).config === null) return () => ({});
2145
- return () => ({ config: node.config });
2239
+ const fragment = readWidgetPluginDefinition(node.plugin).config === null ? Object.freeze({}) : Object.freeze({ config: node.config });
2240
+ return () => fragment;
2146
2241
  }
2147
2242
  for (let nodeId = 0; nodeId < compiled.nodes.length; nodeId++) {
2148
2243
  const node = compiled.nodes[nodeId];
@@ -2184,11 +2279,12 @@ function createWidgetSystemRuntime(blueprint, options) {
2184
2279
  candidate = overrides.get(key);
2185
2280
  hasCandidate = true;
2186
2281
  } else if (member.definition.default) {
2187
- candidate = member.definition.default(buildConfigFragment());
2282
+ candidate = member.definition.default({ ...buildConfigFragment() });
2188
2283
  assertSyncValue(candidate, `State "${key}"'s default`);
2189
2284
  hasCandidate = true;
2190
2285
  }
2191
2286
  if (hasCandidate) primitive.internal.attemptSet(candidate);
2287
+ primitive.internal.captureInitial();
2192
2288
  }
2193
2289
  }
2194
2290
  for (let nodeId = 0; nodeId < compiled.nodes.length; nodeId++) {
@@ -2258,12 +2354,24 @@ function createWidgetSystemRuntime(blueprint, options) {
2258
2354
  if (nodeId === void 0) return null;
2259
2355
  return runtimeWidgetsByNodeId.get(nodeId) ?? null;
2260
2356
  }
2357
+ function resetState() {
2358
+ context.assertActive();
2359
+ runRuntimeOperation(() => {
2360
+ startBatch();
2361
+ try {
2362
+ for (const entry of registry.values()) for (const primitive of entry.state.values()) primitive.internal.restoreInitial();
2363
+ } finally {
2364
+ endBatch();
2365
+ }
2366
+ });
2367
+ }
2261
2368
  const runtime = {
2262
2369
  blueprint,
2263
2370
  get isDisposed() {
2264
2371
  return context.isDisposed();
2265
2372
  },
2266
2373
  getWidget,
2374
+ resetState,
2267
2375
  getDiagnostics: aggregate.getDiagnostics,
2268
2376
  subscribeDiagnostics: aggregate.subscribeDiagnostics,
2269
2377
  dispose: () => context.dispose()
@@ -2360,13 +2468,27 @@ function createDependencyBuilder() {
2360
2468
  }
2361
2469
  //#endregion
2362
2470
  //#region src/blueprint/diagnostics.ts
2471
+ /**
2472
+ * A compile-time callback's collector. `close()` ends its plugin-facing lifetime once the callback has
2473
+ * returned or thrown; a later `addDiagnostic` / `hasAnyDiagnostic` call then throws.
2474
+ */
2363
2475
  function createCollector() {
2364
2476
  const items = [];
2477
+ let closed = false;
2365
2478
  return {
2366
2479
  items,
2367
2480
  collector: {
2368
- addDiagnostic: (diagnostic) => items.push(diagnostic),
2369
- hasAnyDiagnostic: () => items.length > 0
2481
+ addDiagnostic: (diagnostic) => {
2482
+ if (closed) throwClosedCollector("addDiagnostic");
2483
+ items.push(diagnostic);
2484
+ },
2485
+ hasAnyDiagnostic: () => {
2486
+ if (closed) throwClosedCollector("hasAnyDiagnostic");
2487
+ return items.length > 0;
2488
+ }
2489
+ },
2490
+ close: () => {
2491
+ closed = true;
2370
2492
  }
2371
2493
  };
2372
2494
  }
@@ -2408,23 +2530,9 @@ function methodLocation(node, name) {
2408
2530
  name
2409
2531
  };
2410
2532
  }
2411
- function definitionCode(message, path) {
2412
- if (path === void 0) return "invalid-widget-definition";
2413
- const first = path[0];
2414
- if (first === "id") return "invalid-widget-id";
2415
- if (first === "type") return message.startsWith("Unknown plugin type") ? "unknown-widget-type" : "invalid-widget-type";
2416
- if (first === "config") return message.includes("no config capability") ? "unexpected-widget-config" : "invalid-widget-definition";
2417
- if (first === "slots") {
2418
- if (message.includes("not declared")) return "undeclared-widget-slot";
2419
- if (message.includes("must be an array")) return "invalid-widget-slot";
2420
- if (message.includes("no slots capability")) return "unexpected-widget-slots";
2421
- return "invalid-widget-slots";
2422
- }
2423
- return "invalid-widget-definition";
2424
- }
2425
- function definitionDiagnostic(node, message, path, related) {
2533
+ function definitionDiagnostic(node, code, message, path, related) {
2426
2534
  return {
2427
- code: definitionCode(message, path),
2535
+ code,
2428
2536
  location: widgetLocation(node),
2429
2537
  message,
2430
2538
  ...path === void 0 ? {} : { path },
@@ -2449,20 +2557,10 @@ function structureDiagnostic(node, message, slot, index, related, reason) {
2449
2557
  ...reason === void 0 ? {} : { reason }
2450
2558
  };
2451
2559
  }
2452
- function dependencyCode(message) {
2453
- if (message.includes("ambiguous")) return "ambiguous-dependency-target";
2454
- if (message.includes("could not be resolved")) return "unresolved-dependency-target";
2455
- if (message.includes("does not exist")) return "missing-dependency-target";
2456
- if (message.includes("no state capability") || message.includes("no properties capability") || message.includes("no methods capability")) return "missing-dependency-capability";
2457
- if (message.includes("no state member") || message.includes("no property") || message.includes("no method")) return "missing-dependency-member";
2458
- if (message.includes("invokes writeful")) return "property-dependency-has-write-effects";
2459
- return "property-evaluation-cycle";
2460
- }
2461
- function dependencyDiagnostic(node, member, message, dependency, related) {
2462
- const location = member.type === "property" ? propertyLocation(node, member.name) : methodLocation(node, member.name);
2560
+ function dependencyDiagnostic(node, member, code, message, dependency, related) {
2463
2561
  return {
2464
- code: dependencyCode(message),
2465
- location,
2562
+ code,
2563
+ location: member.type === "property" ? propertyLocation(node, member.name) : methodLocation(node, member.name),
2466
2564
  message,
2467
2565
  ...dependency === void 0 ? {} : { dependency },
2468
2566
  ...toNonEmpty(related ?? []) === void 0 ? {} : { related: toNonEmpty(related ?? []) }
@@ -2555,39 +2653,39 @@ function resolveLeaf(nodes, nodeIdsByWidgetId, rootNodeId, ownerNodeId, member,
2555
2653
  }
2556
2654
  if (candidateIds.length === 0) {
2557
2655
  if ((target.type === "parent" || target.type === "widget") && target.optional) return absent();
2558
- finalDiagnostics.push(dependencyDiagnostic(ownerPublicNode, member, describeMissingTarget(target), reference));
2656
+ finalDiagnostics.push(dependencyDiagnostic(ownerPublicNode, member, "missing-dependency-target", describeMissingTarget(target), reference));
2559
2657
  return invalid();
2560
2658
  }
2561
2659
  if (candidateIds.length > 1) {
2562
2660
  const related = candidateIds.map((id) => widgetLocation(nodes[id].publicNode));
2563
- finalDiagnostics.push(dependencyDiagnostic(ownerPublicNode, member, "Dependency target is ambiguous: multiple widgets share that id.", reference, related));
2661
+ finalDiagnostics.push(dependencyDiagnostic(ownerPublicNode, member, "ambiguous-dependency-target", "Dependency target is ambiguous: multiple widgets share that id.", reference, related));
2564
2662
  return invalid();
2565
2663
  }
2566
2664
  const targetNodeId = candidateIds[0];
2567
2665
  const targetWorking = nodes[targetNodeId];
2568
2666
  if (!targetWorking.resolved) {
2569
- finalDiagnostics.push(dependencyDiagnostic(ownerPublicNode, member, "Dependency target could not be resolved to a widget.", reference, [widgetLocation(targetWorking.publicNode)]));
2667
+ finalDiagnostics.push(dependencyDiagnostic(ownerPublicNode, member, "unresolved-dependency-target", "Dependency target could not be resolved to a widget.", reference, [widgetLocation(targetWorking.publicNode)]));
2570
2668
  return invalid(targetNodeId);
2571
2669
  }
2572
2670
  const targetDefinition = readWidgetPluginDefinition(targetWorking.plugin);
2573
2671
  const targetPublicNode = targetWorking.publicNode;
2574
2672
  if (operation.type === "state-get" || operation.type === "state-set") {
2575
2673
  if (targetDefinition.state === null) {
2576
- finalDiagnostics.push(dependencyDiagnostic(ownerPublicNode, member, "Dependency target has no state capability.", reference, [widgetLocation(targetPublicNode)]));
2674
+ finalDiagnostics.push(dependencyDiagnostic(ownerPublicNode, member, "missing-dependency-capability", "Dependency target has no state capability.", reference, [widgetLocation(targetPublicNode)]));
2577
2675
  return invalid(targetNodeId);
2578
2676
  }
2579
2677
  if (!targetDefinition.state.has(operation.key)) {
2580
- finalDiagnostics.push(dependencyDiagnostic(ownerPublicNode, member, `Dependency target has no state member "${operation.key}".`, reference, [widgetLocation(targetPublicNode)]));
2678
+ finalDiagnostics.push(dependencyDiagnostic(ownerPublicNode, member, "missing-dependency-member", `Dependency target has no state member "${operation.key}".`, reference, [widgetLocation(targetPublicNode)]));
2581
2679
  return invalid(targetNodeId);
2582
2680
  }
2583
2681
  if (operation.type === "state-set" && member.type === "method") directWriteSeeds.add(`${ownerNodeId}:${member.name}`);
2584
2682
  } else if (operation.type === "property-get") {
2585
2683
  if (targetDefinition.properties === null) {
2586
- finalDiagnostics.push(dependencyDiagnostic(ownerPublicNode, member, "Dependency target has no properties capability.", reference, [widgetLocation(targetPublicNode)]));
2684
+ finalDiagnostics.push(dependencyDiagnostic(ownerPublicNode, member, "missing-dependency-capability", "Dependency target has no properties capability.", reference, [widgetLocation(targetPublicNode)]));
2587
2685
  return invalid(targetNodeId);
2588
2686
  }
2589
2687
  if (!targetDefinition.properties.has(operation.name)) {
2590
- finalDiagnostics.push(dependencyDiagnostic(ownerPublicNode, member, `Dependency target has no property "${operation.name}".`, reference, [widgetLocation(targetPublicNode)]));
2688
+ finalDiagnostics.push(dependencyDiagnostic(ownerPublicNode, member, "missing-dependency-member", `Dependency target has no property "${operation.name}".`, reference, [widgetLocation(targetPublicNode)]));
2591
2689
  return invalid(targetNodeId);
2592
2690
  }
2593
2691
  const key = edgeKey(member.type, ownerNodeId, member.name, "property", targetNodeId, operation.name);
@@ -2602,11 +2700,11 @@ function resolveLeaf(nodes, nodeIdsByWidgetId, rootNodeId, ownerNodeId, member,
2602
2700
  });
2603
2701
  } else {
2604
2702
  if (targetDefinition.methods === null) {
2605
- finalDiagnostics.push(dependencyDiagnostic(ownerPublicNode, member, "Dependency target has no methods capability.", reference, [widgetLocation(targetPublicNode)]));
2703
+ finalDiagnostics.push(dependencyDiagnostic(ownerPublicNode, member, "missing-dependency-capability", "Dependency target has no methods capability.", reference, [widgetLocation(targetPublicNode)]));
2606
2704
  return invalid(targetNodeId);
2607
2705
  }
2608
2706
  if (!targetDefinition.methods.has(operation.name)) {
2609
- finalDiagnostics.push(dependencyDiagnostic(ownerPublicNode, member, `Dependency target has no method "${operation.name}".`, reference, [widgetLocation(targetPublicNode)]));
2707
+ finalDiagnostics.push(dependencyDiagnostic(ownerPublicNode, member, "missing-dependency-member", `Dependency target has no method "${operation.name}".`, reference, [widgetLocation(targetPublicNode)]));
2610
2708
  return invalid(targetNodeId);
2611
2709
  }
2612
2710
  const key = edgeKey(member.type, ownerNodeId, member.name, "method", targetNodeId, operation.name);
@@ -2744,7 +2842,7 @@ function emitPurityDiagnostics(nodes, edges, writefulMethods, finalDiagnostics)
2744
2842
  finalDiagnostics.push(dependencyDiagnostic(ownerNode, {
2745
2843
  type: "property",
2746
2844
  name: edge.fromName
2747
- }, `Property "${edge.fromName}" invokes writeful method "${edge.toName}".`, edge.reference, [methodLocation(targetNode, edge.toName)]));
2845
+ }, "property-dependency-has-write-effects", `Property "${edge.fromName}" invokes writeful method "${edge.toName}".`, edge.reference, [methodLocation(targetNode, edge.toName)]));
2748
2846
  }
2749
2847
  }
2750
2848
  /**
@@ -2808,7 +2906,7 @@ function emitCycleDiagnostics(nodes, memberOrder, memberOrderKeys, adjacency, fi
2808
2906
  finalDiagnostics.push(dependencyDiagnostic(ownerNode, {
2809
2907
  type: "property",
2810
2908
  name: property.name
2811
- }, `Property "${property.name}" participates in an evaluation cycle.`, void 0, related));
2909
+ }, "property-evaluation-cycle", `Property "${property.name}" participates in an evaluation cycle.`, void 0, related));
2812
2910
  }
2813
2911
  }
2814
2912
  return invalidCycles;
@@ -2948,13 +3046,13 @@ function buildNode(ctx, rawValue, parentNodeId, parentPublicNode, placement) {
2948
3046
  const localDiagnostics = [];
2949
3047
  const raw = isRecoverableObject(rawValue) ? rawValue : null;
2950
3048
  if (raw === null) {
2951
- localDiagnostics.push(definitionDiagnostic(publicNode, "Widget definition must be a plain object."));
3049
+ localDiagnostics.push(definitionDiagnostic(publicNode, "invalid-widget-definition", "Widget definition must be a plain object."));
2952
3050
  finalizeShell(shell, working);
2953
3051
  flushDiagnostics(ctx, localDiagnostics);
2954
3052
  return nodeId;
2955
3053
  }
2956
3054
  if (ctx.activeSourceObjects.has(raw)) {
2957
- localDiagnostics.push(definitionDiagnostic(publicNode, "Widget definition contains a cyclic source reference."));
3055
+ localDiagnostics.push(definitionDiagnostic(publicNode, "invalid-widget-definition", "Widget definition contains a cyclic source reference."));
2958
3056
  finalizeShell(shell, working);
2959
3057
  flushDiagnostics(ctx, localDiagnostics);
2960
3058
  return nodeId;
@@ -2963,15 +3061,15 @@ function buildNode(ctx, rawValue, parentNodeId, parentPublicNode, placement) {
2963
3061
  const idProperty = readOwnDataProperty(raw, "id");
2964
3062
  const rawId = idProperty.accessible ? idProperty.value : void 0;
2965
3063
  const hasValidId = idProperty.found && idProperty.accessible && typeof rawId === "string";
2966
- if (!hasValidId) localDiagnostics.push(definitionDiagnostic(publicNode, "Widget \"id\" is missing or is not a string.", ["id"]));
3064
+ if (!hasValidId) localDiagnostics.push(definitionDiagnostic(publicNode, "invalid-widget-id", "Widget \"id\" is missing or is not a string.", ["id"]));
2967
3065
  const typeProperty = readOwnDataProperty(raw, "type");
2968
3066
  const rawType = typeProperty.accessible ? typeProperty.value : void 0;
2969
3067
  const hasValidTypeShape = typeProperty.found && typeProperty.accessible && typeof rawType === "string";
2970
3068
  let plugin = null;
2971
- if (!hasValidTypeShape) localDiagnostics.push(definitionDiagnostic(publicNode, "Widget \"type\" is missing or is not a string.", ["type"]));
3069
+ if (!hasValidTypeShape) localDiagnostics.push(definitionDiagnostic(publicNode, "invalid-widget-type", "Widget \"type\" is missing or is not a string.", ["type"]));
2972
3070
  else {
2973
3071
  plugin = ctx.pluginsByType.get(rawType) ?? null;
2974
- if (plugin === null) localDiagnostics.push(definitionDiagnostic(publicNode, `Unknown plugin type "${rawType}".`, ["type"]));
3072
+ if (plugin === null) localDiagnostics.push(definitionDiagnostic(publicNode, "unknown-widget-type", `Unknown plugin type "${rawType}".`, ["type"]));
2975
3073
  }
2976
3074
  const resolved = hasValidId && hasValidTypeShape && plugin !== null;
2977
3075
  working.resolved = resolved;
@@ -2984,20 +3082,15 @@ function buildNode(ctx, rawValue, parentNodeId, parentPublicNode, placement) {
2984
3082
  const definition = readWidgetPluginDefinition(plugin);
2985
3083
  const configProperty = readOwnDataProperty(raw, "config");
2986
3084
  if (definition.config !== null) {
2987
- if (!configProperty.found) {
2988
- const resolved = definition.config.resolve(null);
2989
- assertSyncValue(resolved, "config.resolve");
2990
- working.rawConfig = null;
2991
- working.config = resolved;
2992
- } else if (!configProperty.accessible) {
3085
+ if (configProperty.found && !configProperty.accessible) {
2993
3086
  localDiagnostics.push(configDiagnostic(publicNode, "Widget config could not be inspected safely."));
2994
3087
  const resolved = definition.config.resolve(null);
2995
3088
  assertSyncValue(resolved, "config.resolve");
2996
3089
  working.rawConfig = null;
2997
3090
  working.config = resolved;
2998
3091
  } else {
2999
- const rawConfigValue = configProperty.value;
3000
- const { collector, items } = createCollector();
3092
+ const rawConfigValue = configProperty.found ? configProperty.value : null;
3093
+ const { collector, items, close } = createCollector();
3001
3094
  let ok = false;
3002
3095
  try {
3003
3096
  const rawValidateResult = definition.config.validate(rawConfigValue, collector);
@@ -3007,6 +3100,8 @@ function buildNode(ctx, rawValue, parentNodeId, parentPublicNode, placement) {
3007
3100
  finalizeShell(shell, working);
3008
3101
  flushDiagnostics(ctx, localDiagnostics);
3009
3102
  throw error;
3103
+ } finally {
3104
+ close();
3010
3105
  }
3011
3106
  if (ok && items.length === 0) {
3012
3107
  const resolved = definition.config.resolve(rawConfigValue);
@@ -3022,7 +3117,7 @@ function buildNode(ctx, rawValue, parentNodeId, parentPublicNode, placement) {
3022
3117
  working.config = resolved;
3023
3118
  }
3024
3119
  }
3025
- } else if (configProperty.found) localDiagnostics.push(definitionDiagnostic(publicNode, "Widget declares \"config\" but its plugin has no config capability.", ["config"]));
3120
+ } else if (configProperty.found) localDiagnostics.push(definitionDiagnostic(publicNode, "unexpected-widget-config", "Widget declares \"config\" but its plugin has no config capability.", ["config"]));
3026
3121
  }
3027
3122
  if (resolved && plugin !== null) {
3028
3123
  const definition = readWidgetPluginDefinition(plugin);
@@ -3067,30 +3162,30 @@ function recoverSlots(ctx, working, raw, plugin, localDiagnostics) {
3067
3162
  return;
3068
3163
  }
3069
3164
  if (!slotsProperty.accessible) {
3070
- localDiagnostics.push(definitionDiagnostic(publicNode, "Widget \"slots\" could not be inspected safely.", ["slots"]));
3165
+ localDiagnostics.push(definitionDiagnostic(publicNode, "invalid-widget-slots", "Widget \"slots\" could not be inspected safely.", ["slots"]));
3071
3166
  fillMissingDeclaredSlots();
3072
3167
  return;
3073
3168
  }
3074
3169
  const rawSlotsValue = slotsProperty.value;
3075
3170
  if (!isRecoverableObject(rawSlotsValue)) {
3076
- localDiagnostics.push(definitionDiagnostic(publicNode, "Widget \"slots\" must be a plain object.", ["slots"]));
3171
+ localDiagnostics.push(definitionDiagnostic(publicNode, "invalid-widget-slots", "Widget \"slots\" must be a plain object.", ["slots"]));
3077
3172
  fillMissingDeclaredSlots();
3078
3173
  return;
3079
3174
  }
3080
- if (plugin !== null && declaredSlots === null) localDiagnostics.push(definitionDiagnostic(publicNode, "Widget declares \"slots\" but its plugin has no slots capability.", ["slots"]));
3175
+ if (plugin !== null && declaredSlots === null) localDiagnostics.push(definitionDiagnostic(publicNode, "unexpected-widget-slots", "Widget declares \"slots\" but its plugin has no slots capability.", ["slots"]));
3081
3176
  const slotNames = readOwnEnumerableStringKeys(rawSlotsValue);
3082
3177
  if (slotNames === null) {
3083
- localDiagnostics.push(definitionDiagnostic(publicNode, "Widget \"slots\" could not be inspected safely.", ["slots"]));
3178
+ localDiagnostics.push(definitionDiagnostic(publicNode, "invalid-widget-slots", "Widget \"slots\" could not be inspected safely.", ["slots"]));
3084
3179
  fillMissingDeclaredSlots();
3085
3180
  return;
3086
3181
  }
3087
3182
  for (const slotName of slotNames) {
3088
3183
  const slotProperty = readOwnDataProperty(rawSlotsValue, slotName);
3089
3184
  const isDeclared = declaredSlots !== null && declaredSlots.has(slotName);
3090
- if (declaredSlots !== null && !isDeclared) localDiagnostics.push(definitionDiagnostic(publicNode, `Widget slot "${slotName}" is not declared by its plugin.`, ["slots", slotName]));
3185
+ if (declaredSlots !== null && !isDeclared) localDiagnostics.push(definitionDiagnostic(publicNode, "undeclared-widget-slot", `Widget slot "${slotName}" is not declared by its plugin.`, ["slots", slotName]));
3091
3186
  const slotArray = readArrayInfo(slotProperty.value);
3092
3187
  if (!slotProperty.found || !slotProperty.accessible || !slotArray.isArray || !slotArray.accessible) {
3093
- localDiagnostics.push(definitionDiagnostic(publicNode, `Widget slot "${slotName}" must be an array.`, ["slots", slotName]));
3188
+ localDiagnostics.push(definitionDiagnostic(publicNode, "invalid-widget-slot", `Widget slot "${slotName}" must be an array.`, ["slots", slotName]));
3094
3189
  continue;
3095
3190
  }
3096
3191
  const childNodeIds = [];
@@ -3147,7 +3242,7 @@ function emitDuplicateIdDiagnostics(ctx, index) {
3147
3242
  for (const nodeId of ids) {
3148
3243
  const node = ctx.nodes[nodeId];
3149
3244
  const related = ids.filter((otherId) => otherId !== nodeId).map((otherId) => widgetLocation(ctx.nodes[otherId].publicNode));
3150
- ctx.finalDiagnostics.push(definitionDiagnostic(node.publicNode, `Duplicate widget id "${node.id}".`, ["id"], related));
3245
+ ctx.finalDiagnostics.push(definitionDiagnostic(node.publicNode, "invalid-widget-id", `Duplicate widget id "${node.id}".`, ["id"], related));
3151
3246
  }
3152
3247
  }
3153
3248
  }
@@ -3290,45 +3385,57 @@ function runStructureValidation(system, nodes, semanticOrder, compileFacade, fin
3290
3385
  if (definition.slots !== null) for (const [slotName, slotDefinition] of definition.slots) {
3291
3386
  if (slotDefinition.validateStructure === void 0) continue;
3292
3387
  const children = (node.semanticSlots.get(slotName) ?? []).map((id) => compileFacade.facadeForNodeId(id));
3293
- const { collector, items } = createCollector();
3294
- assertSyncValue(slotDefinition.validateStructure({
3295
- widget: widgetFacade,
3296
- slot: slotName,
3297
- children,
3298
- blueprint: compileFacade.view,
3299
- ...configFragment(node),
3300
- ...collector
3301
- }), `Slot "${slotName}"'s validateStructure`);
3302
- for (const item of items) finalDiagnostics.push(structureDiagnostic(publicNode, item.message, slotName, item.index));
3388
+ const { collector, items, close } = createCollector();
3389
+ try {
3390
+ assertSyncValue(slotDefinition.validateStructure({
3391
+ widget: widgetFacade,
3392
+ slot: slotName,
3393
+ children,
3394
+ blueprint: compileFacade.view,
3395
+ ...configFragment(node),
3396
+ ...collector
3397
+ }), `Slot "${slotName}"'s validateStructure`);
3398
+ } finally {
3399
+ close();
3400
+ }
3401
+ for (const item of items) finalDiagnostics.push(structureDiagnostic(publicNode, item.message, slotName, item.index, void 0, item.reason));
3303
3402
  }
3304
3403
  if (definition.validateStructure !== null) {
3305
- const { collector, items } = createCollector();
3306
- assertSyncValue(definition.validateStructure({
3307
- widget: widgetFacade,
3308
- blueprint: compileFacade.view,
3309
- ...configFragment(node),
3310
- ...collector
3311
- }), `Plugin "${node.type}"'s validateStructure`);
3404
+ const { collector, items, close } = createCollector();
3405
+ try {
3406
+ assertSyncValue(definition.validateStructure({
3407
+ widget: widgetFacade,
3408
+ blueprint: compileFacade.view,
3409
+ ...configFragment(node),
3410
+ ...collector
3411
+ }), `Plugin "${node.type}"'s validateStructure`);
3412
+ } finally {
3413
+ close();
3414
+ }
3312
3415
  for (const item of items) {
3313
3416
  const slot = "slot" in item ? item.slot : void 0;
3314
3417
  const index = "index" in item ? item.index : void 0;
3315
- finalDiagnostics.push(structureDiagnostic(publicNode, item.message, slot, index));
3418
+ finalDiagnostics.push(structureDiagnostic(publicNode, item.message, slot, index, void 0, item.reason));
3316
3419
  }
3317
3420
  }
3318
3421
  }
3319
3422
  if (system.validateStructure !== null) {
3320
- const { collector, items } = createCollector();
3321
- assertSyncValue(system.validateStructure({
3322
- blueprint: compileFacade.view,
3323
- ...collector
3324
- }), "System-level validateStructure");
3423
+ const { collector, items, close } = createCollector();
3424
+ try {
3425
+ assertSyncValue(system.validateStructure({
3426
+ blueprint: compileFacade.view,
3427
+ ...collector
3428
+ }), "System-level validateStructure");
3429
+ } finally {
3430
+ close();
3431
+ }
3325
3432
  const semanticOrderIndex = /* @__PURE__ */ new Map();
3326
3433
  semanticOrder.forEach((nodeId, index) => semanticOrderIndex.set(nodeId, index));
3327
3434
  for (const item of items) {
3328
3435
  const { location, related } = item;
3329
3436
  const nodeId = compileFacade.resolveNodeId(location.node);
3330
3437
  const realNode = nodeId !== void 0 ? nodes[nodeId].publicNode : location.node;
3331
- finalDiagnostics.push(structureDiagnostic(realNode, item.message, location.type === "widget" ? void 0 : location.slot, location.type === "slot-child" ? location.index : void 0, normalizeRelated(nodes, semanticOrderIndex, compileFacade.resolveNodeId, related)));
3438
+ finalDiagnostics.push(structureDiagnostic(realNode, item.message, location.type === "widget" ? void 0 : location.slot, location.type === "slot-child" ? location.index : void 0, normalizeRelated(nodes, semanticOrderIndex, compileFacade.resolveNodeId, related), item.reason));
3332
3439
  }
3333
3440
  }
3334
3441
  }
@@ -3522,9 +3629,17 @@ function buildCompiledNodes(nodes, diagnosticsByNode) {
3522
3629
  };
3523
3630
  });
3524
3631
  }
3525
- function compileBlueprint(system, definition) {
3632
+ const JSON_PROVEN_BY_CONSTRUCTION = Object.freeze({
3633
+ compatible: true,
3634
+ diagnostics: Object.freeze([])
3635
+ });
3636
+ /**
3637
+ * `sourceJsonProven` is set only for a value Core itself produced with `JSON.parse` (no reviver): such a
3638
+ * value cannot hold anything `inspectJsonValue` rejects, so the inspection would prove nothing new.
3639
+ */
3640
+ function compileBlueprint(system, definition, sourceJsonProven = false) {
3526
3641
  const { nodes, rootNodeId, nodeIdByPublicNode, nodeIdsByWidgetId, finalDiagnostics, diagnosticsByNode } = recoverBlueprint(system, definition);
3527
- const jsonInspection = inspectJsonValue(definition);
3642
+ const jsonInspection = sourceJsonProven ? JSON_PROVEN_BY_CONSTRUCTION : inspectJsonValue(definition);
3528
3643
  const sourceJsonCompatible = jsonInspection.compatible;
3529
3644
  finalDiagnostics.push(...jsonInspection.diagnostics);
3530
3645
  const semanticOrder = computeSemanticOrder(nodes, rootNodeId);
@@ -3685,6 +3800,9 @@ function createWidgetSystem(options) {
3685
3800
  },
3686
3801
  createBlueprint(definition) {
3687
3802
  return compileBlueprint(system, definition);
3803
+ },
3804
+ createBlueprintFromJson(text) {
3805
+ return compileBlueprint(system, JSON.parse(text), true);
3688
3806
  }
3689
3807
  };
3690
3808
  return Object.freeze(system);
@@ -1,4 +1,4 @@
1
- import { Jt as WidgetSystemBlueprint, T as BlueprintDependencyReference, Tn as WidgetPluginConfigMetadata, Tt as ResolvedBlueprintWidgetNode, Vt as UnresolvedBlueprintWidgetNode, Xt as WidgetSystemRuntime, bt as BlueprintWidgetNode, cn as AnyWidgetPluginTuple, dr as WidgetMemberKey, lt as RuntimePropertyDiagnostic, sn as AnyWidgetPlugin, tr as ExecutionResult } from "../dep-DAoSoLhi.mjs";
1
+ import { Jt as WidgetSystemBlueprint, T as BlueprintDependencyReference, Tn as WidgetPluginConfigMetadata, Tt as ResolvedBlueprintWidgetNode, Vt as UnresolvedBlueprintWidgetNode, Xt as WidgetSystemRuntime, bt as BlueprintWidgetNode, cn as AnyWidgetPluginTuple, dr as WidgetMemberKey, lt as RuntimePropertyDiagnostic, sn as AnyWidgetPlugin, tr as ExecutionResult } from "../dep-DKbvAjPb.mjs";
2
2
  //#region src/inspection/types.d.ts
3
3
  declare const inspectionNodeIdBrand: unique symbol;
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { Lt as RuntimeWidget, Xt as WidgetSystemRuntime, cn as AnyWidgetPluginTuple, dr as WidgetMemberKey } from "../dep-DAoSoLhi.mjs";
1
+ import { Lt as RuntimeWidget, Xt as WidgetSystemRuntime, cn as AnyWidgetPluginTuple, dr as WidgetMemberKey } from "../dep-DKbvAjPb.mjs";
2
2
  //#region src/integration/index.d.ts
3
3
  type WidgetIntegrationErrorCode = 'runtime-widget-mismatch' | 'foreign-runtime';
4
4
  declare class WidgetIntegrationError extends Error {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.0.4",
7
+ "version": "0.0.6",
8
8
  "author": "DevilTea <ch19980814@gmail.com>",
9
9
  "license": "MIT",
10
10
  "homepage": "https://github.com/DevilTea/widget/tree/main/packages/core#readme",