@deviltea/widget-core 0.0.2 → 0.0.4

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
@@ -1,7 +1,7 @@
1
1
  # @deviltea/widget-core
2
2
 
3
3
  Cross-cutting Diagnostic/Result/Failure/Error conventions are maintained in
4
- [Widget API conventions](../../../docs/architecture/widget-api-conventions.md).
4
+ [Widget API conventions](https://github.com/DevilTea/widget/blob/main/docs/architecture/widget-api-conventions.md).
5
5
 
6
6
  > ESM-only package.
7
7
 
@@ -63,6 +63,18 @@ empty — a completed plugin exposes these facts at runtime as
63
63
  [Reading capability presence at runtime](https://deviltea.github.io/widget/packages/widget-core#reading-capability-presence-at-runtime-plugin-capabilities)
64
64
  in the full guide.
65
65
 
66
+ `createWidgetSystem` rejects invalid plugin registration with the coded
67
+ `WidgetSystemConfigurationError`: `foreign-plugin` (entry not created by this
68
+ loaded module instance; fields `pluginIndex`, `pluginType`, with
69
+ `firstPluginIndex` always `null`) and `duplicate-plugin-type` (fields
70
+ `pluginIndex`, `pluginType`, `firstPluginIndex`).
71
+ Inspection entries throw `WidgetInspectionError` (`@deviltea/widget-core/inspection`)
72
+ and `getWidgetEventEmitter` throws `WidgetIntegrationError`
73
+ (`@deviltea/widget-core/integration`, code `foreign-runtime`) for foreign inputs.
74
+ See
75
+ [Plugin registration errors](https://deviltea.github.io/widget/packages/widget-core#plugin-registration-errors)
76
+ in the full guide.
77
+
66
78
  Plugin, config, and slot descriptions are required intrinsic metadata. The
67
79
  immutable `system.catalog` is a passive projection of registered widget types,
68
80
  descriptions, and capability descriptions; it does not contain Blueprint or
@@ -234,6 +246,74 @@ if (result.ok && result.changed)
234
246
  console.log(document.getSnapshot().revision) // 1
235
247
  ```
236
248
 
249
+ Authored source is handed to Core **by reference**: `createBlueprint`,
250
+ `recompile` and `createWidgetDocument` keep `source` as given, so
251
+ `blueprint.source` is the exact input and Core never clones or freezes it.
252
+ Passing source transfers ownership; do not mutate it afterwards (behavior is
253
+ unspecified), and pass a copy such as `structuredClone` if you keep editing
254
+ your own object. "Immutable" Blueprint describes Core's API, not a defensive
255
+ copy. `applyPatch` never mutates the accepted source, but copy-on-write
256
+ revisions share untouched subtrees with the previous revision and so with the
257
+ original input. See the
258
+ [Core model](https://deviltea.github.io/widget/packages/widget-core#core-model)
259
+ ownership rules.
260
+
261
+ `applyPatch(patch, options?)` returns `{ ok: true, changed }` or
262
+ `{ ok: false, failure }`. A patch that leaves the source structurally equal
263
+ returns `{ ok: true, changed: false }`: the revision does not advance and
264
+ subscribers are not notified. A changing patch compiles the next Blueprint once
265
+ after all operations succeed, commits it at `revision + 1`, then notifies
266
+ subscribers. `failure.code` is one of:
267
+
268
+ - `reentrant-apply`: `applyPatch()` was called while the Document was applying
269
+ or notifying (for example from a subscriber). It is checked first.
270
+ - `document-revision-conflict`: `options.expectedRevision` was supplied and
271
+ differs from the current revision. The failure carries `expectedRevision` and
272
+ `actualRevision`. Omitting `options` skips this check, and the check runs
273
+ before any operation is evaluated.
274
+ - An operation failure `{ code, operationIndex, message }`, where `code` is
275
+ `invalid-path`, `path-not-found`, `path-not-traversable`,
276
+ `invalid-array-index`, `invalid-move-target`, `test-failed`,
277
+ `json-incompatible-value`, or `source-access-failed`, and `operationIndex`
278
+ is the failing operation's position in the patch. A failed patch leaves the
279
+ committed source and revision unchanged.
280
+
281
+ | `code` | Meaning |
282
+ | --- | --- |
283
+ | `invalid-path` | malformed path or operation shape |
284
+ | `path-not-found` | the path does not identify an existing location |
285
+ | `path-not-traversable` | the path passes through a non-traversable value |
286
+ | `invalid-array-index` | an Array parent was addressed by anything other than an in-bounds canonical index (see below) |
287
+ | `invalid-move-target` | a `move` into its own descendant |
288
+ | `test-failed` | a `test` operand did not match the addressed value |
289
+ | `json-incompatible-value` | an `add`/`replace`/`test` `value` is outside Core's JSON domain (missing or `undefined`, functions, `bigint`, symbols, `NaN`/`±Infinity`, cycles, non-plain prototypes, sparse or extra-property Arrays, accessors, symbol keys, or reflection that throws); checked after path parsing and before the operation is evaluated |
290
+ | `source-access-failed` | unsafe access to the *source* material only |
291
+
292
+ Three edge semantics apply to every operation:
293
+
294
+ - **Arrays have only index members.** After path normalization, any segment on
295
+ an Array parent that is not a canonical index (`'length'`, `'foo'`, `'01'`, or a
296
+ structured `'-'`) fails `invalid-array-index`, at every position (traversal,
297
+ target, and `from`) and in both path forms. Append remains JSON-Pointer-only
298
+ (`/items/-`); a structured `'-'` never appends and is an ordinary key on
299
+ objects. Non-index properties already present on a recovery Array are repaired
300
+ by replacing that Array or an ancestor.
301
+ - **Numbers compare by SameValueZero.** `test` and no-op detection treat `0` and
302
+ `-0` as equal, so replacing `0` with `-0` (or the reverse) returns
303
+ `{ ok: true, changed: false }` and the source keeps its original value.
304
+ Explicit `add`/`replace` operands are copied with `-0` written as `+0` at
305
+ every depth; `copy`/`move` relocate existing material unchanged.
306
+ - **Operands must be JSON values.** A non-JSON operand fails with
307
+ `json-incompatible-value`, not `source-access-failed`.
308
+
309
+ `document.subscribe(listener)` registers `listener` and returns an idempotent
310
+ unsubscribe function. The listener is not called on subscription; it receives
311
+ the new snapshot after each committed (`changed: true`) patch, in subscription
312
+ order, over the subscriber list as it stood when notification began. An
313
+ exception thrown by a listener does not fail `applyPatch()` or stop the
314
+ remaining listeners, and it is reported outside `applyPatch()`; the reporting
315
+ mechanism is not part of the contract.
316
+
237
317
  ### SeparatedWidgetSource tooling
238
318
 
239
319
  `WidgetSource` is the only canonical nested authored representation. The explicit
@@ -261,6 +341,12 @@ later occurrence is de-identified with its available subtree preserved.
261
341
 
262
342
  ### Runtime semantics
263
343
 
344
+ - Declared `events` are public notifications: subscribe through
345
+ `widget.events[name].subscribe(listener)`. Delivery is synchronous and
346
+ depth-first for nested emits; a throwing public listener propagates to the
347
+ emit caller and stops the remaining public listeners. Emit authority belongs
348
+ to Method `execute` (`emit`) and, for renderers, `@deviltea/widget-core/integration`.
349
+ See [Events](https://deviltea.github.io/widget/packages/widget-core#events).
264
350
  - `widget.state[key].get()` returns `T | null` directly — it is not an
265
351
  `ExecutionResult`.
266
352
  - `widget.properties[name].get()` / `.subscribe(listener)` and
@@ -292,19 +378,22 @@ later occurrence is de-identified with its available subtree preserved.
292
378
  `WidgetSystemRuntimeDisposedError`; unsubscribe functions obtained before
293
379
  disposal remain safe idempotent no-ops.
294
380
 
295
- ### Inspection (DevTools)
381
+ ### Inspection
296
382
 
297
- A dedicated, strictly readonly subpath exposes compiler/runtime facts for
298
- building inspectors — it never mutates state, invokes methods, or forces
299
- Property evaluation:
383
+ A dedicated, strictly readonly subpath is a supported observation surface for
384
+ any host (DevTools, prototype players, test harnesses). It exposes
385
+ compiler/runtime facts, including passive Event occurrence observation through
386
+ `getEvent(name).subscribe(...)`, and never mutates state, invokes methods, or
387
+ forces Property evaluation:
300
388
 
301
389
  ```typescript
302
390
  import { inspectBlueprint, inspectRuntime } from '@deviltea/widget-core/inspection'
303
391
  ```
304
392
 
305
393
  `@deviltea/widget-core`'s root entrypoint does not export this surface. See
306
- [Inspection](https://deviltea.github.io/widget/packages/widget-core#inspection-devtools)
307
- in the full guide for the exact contract.
394
+ [Inspection](https://deviltea.github.io/widget/packages/widget-core#inspection)
395
+ in the full guide for the exact contract, including the Event inspection
396
+ delivery guarantees.
308
397
 
309
398
  The full guide at
310
399
  [docs/site/packages/widget-core.md](https://deviltea.github.io/widget/packages/widget-core)
@@ -0,0 +1,23 @@
1
+ //#region src/internal/contract.ts
2
+ const compiledDependencyBrand = Symbol("@deviltea/widget-core:compiled-dependency");
3
+ function isCompiledDependency(value) {
4
+ return typeof value === "object" && value !== null && compiledDependencyBrand in value;
5
+ }
6
+ const blueprintInternals = Symbol("@deviltea/widget-core:blueprint-internals");
7
+ /**
8
+ * Provenance probe: true only for Blueprints produced by this loaded module instance.
9
+ */
10
+ function isCoreBlueprint(value) {
11
+ if (typeof value !== "object" || value === null) return false;
12
+ return value[blueprintInternals] !== void 0;
13
+ }
14
+ /**
15
+ * Reads the compiled snapshot carried by a Blueprint.
16
+ */
17
+ function readCompiledBlueprint(blueprint) {
18
+ const compiled = blueprint[blueprintInternals];
19
+ if (compiled === void 0) throw new Error("The blueprint was not produced by this widget core build.");
20
+ return compiled;
21
+ }
22
+ //#endregion
23
+ export { readCompiledBlueprint as a, isCoreBlueprint as i, compiledDependencyBrand as n, isCompiledDependency as r, blueprintInternals as t };
@@ -359,18 +359,51 @@ interface WidgetInterfacesViolation<Reason extends string> {
359
359
  interface WidgetPluginDonePhase<Type extends string, Interfaces extends WidgetInterfaces> {
360
360
  done: () => WidgetPlugin<Type, Interfaces>;
361
361
  }
362
- type WidgetPluginEventsPhase<Type extends string, Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'events'> extends true ? {
363
- events: (build: (section: WidgetEventsSection<Interfaces, WidgetEventKeyOf<Interfaces>>) => WidgetEventsSection<Interfaces, never>) => WidgetPluginDonePhase<Type, Interfaces>;
364
- } : WidgetPluginDonePhase<Type, Interfaces>;
365
- type WidgetPluginMethodsPhase<Type extends string, Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'methods'> extends true ? {
362
+ /**
363
+ * Outer capability phases in their fixed call order. Part of the type-level order diagnostics only;
364
+ * the runtime builder is order-agnostic.
365
+ */
366
+ type WidgetPluginPhaseOrder = readonly ['config', 'slots', 'state', 'properties', 'methods', 'events'];
367
+ type WidgetPluginPhaseName = WidgetPluginPhaseOrder[number];
368
+ /** The phases whose capability was declared in `Interfaces`. */
369
+ type WidgetPluginDeclaredPhaseName<Interfaces extends WidgetInterfaces> = { [Phase in WidgetPluginPhaseName]: HasWidgetCapability<Interfaces, Phase> extends true ? Phase : never; }[WidgetPluginPhaseName];
370
+ type WidgetPluginPhaseIsBefore<A extends WidgetPluginPhaseName, B extends WidgetPluginPhaseName, Order extends readonly WidgetPluginPhaseName[] = WidgetPluginPhaseOrder> = Order extends readonly [infer Head, ...infer Tail extends readonly WidgetPluginPhaseName[]] ? Head extends A ? true : Head extends B ? false : WidgetPluginPhaseIsBefore<A, B, Tail> : false;
371
+ /**
372
+ * Type-only order marker: the message of the compile error raised when a declared phase is called at
373
+ * the wrong position. The marker name and reason text are diagnostics, not protocol.
374
+ */
375
+ interface WidgetPluginPhaseOrderViolation<Reason extends string> {
376
+ readonly 'widget-core: builder phase order violation': Reason;
377
+ }
378
+ /**
379
+ * Argument list of a misplaced marker: the real phase's arguments, with the first one intersected with
380
+ * the order violation. The call therefore fails at its first argument with the violation (and its
381
+ * reason) in the message, while the function constituent keeps callbacks contextually typed, so no
382
+ * implicit-`any` follow-on errors appear. Section builders may return anything.
383
+ */
384
+ type WidgetPluginMisplacedArguments<Interfaces extends WidgetInterfaces, Phase extends WidgetPluginPhaseName, Violation> = Phase extends 'config' ? [definition: Violation & WidgetConfigDefinition<Interfaces>] : Phase extends 'slots' ? [definitions: Violation & WidgetSlotDefinitions<Interfaces>, validateStructure?: WidgetPluginValidateStructure<Interfaces>] : Phase extends 'state' ? [build: Violation & ((section: WidgetStateSection<Interfaces, WidgetStateKeyOf<Interfaces>>) => unknown)] : Phase extends 'properties' ? [build: Violation & ((section: WidgetPropertiesSection<Interfaces, WidgetPropertyKeyOf<Interfaces>>) => unknown)] : Phase extends 'methods' ? [build: Violation & ((section: WidgetMethodsSection<Interfaces, WidgetMethodKeyOf<Interfaces>>) => unknown)] : [build: Violation & ((section: WidgetEventsSection<Interfaces, WidgetEventKeyOf<Interfaces>>) => unknown)];
385
+ type WidgetPluginPhaseOrderReason<Phase extends WidgetPluginPhaseName, Stage extends WidgetPluginPhaseName | 'done'> = Stage extends WidgetPluginPhaseName ? WidgetPluginPhaseIsBefore<Phase, Stage> extends true ? `'.${Phase}()' was already called or must be called earlier; the next phase is '.${Stage}()'. Order: description -> interfaces -> config? -> slots? -> state? -> properties? -> methods? -> events? -> done()` : `'.${Phase}()' is called too early; call '.${Stage}()' first. Order: description -> interfaces -> config? -> slots? -> state? -> properties? -> methods? -> events? -> done()` : `'.${Phase}()' cannot be called here; the declared phases are already complete, so only '.done()' remains. Order: description -> interfaces -> config? -> slots? -> state? -> properties? -> methods? -> events? -> done()`;
386
+ /**
387
+ * Adds type-only order markers for every declared phase that is not callable at `Stage`. A marker
388
+ * takes the real phase's arguments with the first one intersected with
389
+ * `WidgetPluginPhaseOrderViolation`, so no real value satisfies it and the call fails with an
390
+ * order-specific diagnostic (the function constituent keeps a callback passed to it contextually typed,
391
+ * so no implicit-`any` follow-on errors appear). It returns the same phase, so a misplaced call never
392
+ * advances the chain.
393
+ */
394
+ type WidgetPluginOrderedPhase<Phase, Interfaces extends WidgetInterfaces, Stage extends WidgetPluginPhaseName | 'done'> = [Exclude<WidgetPluginDeclaredPhaseName<Interfaces>, Stage>] extends [never] ? Phase : Phase & { [Misplaced in Exclude<WidgetPluginDeclaredPhaseName<Interfaces>, Stage>]: (...args: WidgetPluginMisplacedArguments<Interfaces, Misplaced, WidgetPluginPhaseOrderViolation<WidgetPluginPhaseOrderReason<Misplaced, Stage>>>) => WidgetPluginOrderedPhase<Phase, Interfaces, Stage>; };
395
+ type WidgetPluginEventsPhase<Type extends string, Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'events'> extends true ? WidgetPluginOrderedPhase<{
396
+ events: (build: (section: WidgetEventsSection<Interfaces, WidgetEventKeyOf<Interfaces>>) => WidgetEventsSection<Interfaces, never>) => WidgetPluginOrderedPhase<WidgetPluginDonePhase<Type, Interfaces>, Interfaces, 'done'>;
397
+ }, Interfaces, 'events'> : WidgetPluginOrderedPhase<WidgetPluginDonePhase<Type, Interfaces>, Interfaces, 'done'>;
398
+ type WidgetPluginMethodsPhase<Type extends string, Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'methods'> extends true ? WidgetPluginOrderedPhase<{
366
399
  methods: (build: (section: WidgetMethodsSection<Interfaces, WidgetMethodKeyOf<Interfaces>>) => WidgetMethodsSection<Interfaces, never>) => WidgetPluginEventsPhase<Type, Interfaces>;
367
- } : WidgetPluginEventsPhase<Type, Interfaces>;
368
- type WidgetPluginPropertiesPhase<Type extends string, Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'properties'> extends true ? {
400
+ }, Interfaces, 'methods'> : WidgetPluginEventsPhase<Type, Interfaces>;
401
+ type WidgetPluginPropertiesPhase<Type extends string, Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'properties'> extends true ? WidgetPluginOrderedPhase<{
369
402
  properties: (build: (section: WidgetPropertiesSection<Interfaces, WidgetPropertyKeyOf<Interfaces>>) => WidgetPropertiesSection<Interfaces, never>) => WidgetPluginMethodsPhase<Type, Interfaces>;
370
- } : WidgetPluginMethodsPhase<Type, Interfaces>;
371
- type WidgetPluginStatePhase<Type extends string, Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'state'> extends true ? {
403
+ }, Interfaces, 'properties'> : WidgetPluginMethodsPhase<Type, Interfaces>;
404
+ type WidgetPluginStatePhase<Type extends string, Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'state'> extends true ? WidgetPluginOrderedPhase<{
372
405
  state: (build: (section: WidgetStateSection<Interfaces, WidgetStateKeyOf<Interfaces>>) => WidgetStateSection<Interfaces, never>) => WidgetPluginPropertiesPhase<Type, Interfaces>;
373
- } : WidgetPluginPropertiesPhase<Type, Interfaces>;
406
+ }, Interfaces, 'state'> : WidgetPluginPropertiesPhase<Type, Interfaces>;
374
407
  /**
375
408
  * `slots: never` is the canonical explicit-empty slots declaration (diagnostic #10 amendment
376
409
  * "declaration-presence semantics and public `WidgetPlugin.capabilities`"): the phase still exists —
@@ -378,12 +411,12 @@ type WidgetPluginStatePhase<Type extends string, Interfaces extends WidgetInterf
378
411
  * be `never` — and completes as `.slots({})`, since `ExactWidgetSlotDefinitions` for zero slot names is
379
412
  * exactly `{}`.
380
413
  */
381
- type WidgetPluginSlotsPhase<Type extends string, Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'slots'> extends true ? {
414
+ type WidgetPluginSlotsPhase<Type extends string, Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'slots'> extends true ? WidgetPluginOrderedPhase<{
382
415
  slots: <const Definitions extends ExactWidgetSlotDefinitions<Interfaces, Definitions>>(definitions: Definitions, validateStructure?: WidgetPluginValidateStructure<Interfaces>) => WidgetPluginStatePhase<Type, Interfaces>;
383
- } : WidgetPluginStatePhase<Type, Interfaces>;
384
- type WidgetPluginConfigPhase<Type extends string, Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'config'> extends true ? {
416
+ }, Interfaces, 'slots'> : WidgetPluginStatePhase<Type, Interfaces>;
417
+ type WidgetPluginConfigPhase<Type extends string, Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'config'> extends true ? WidgetPluginOrderedPhase<{
385
418
  config: (definition: WidgetConfigDefinition<Interfaces>) => WidgetPluginSlotsPhase<Type, Interfaces>;
386
- } : WidgetPluginSlotsPhase<Type, Interfaces>;
419
+ }, Interfaces, 'config'> : WidgetPluginSlotsPhase<Type, Interfaces>;
387
420
  interface WidgetPluginInterfacesPhase<Type extends string> {
388
421
  interfaces: <Interfaces extends WidgetInterfaces>() => [WidgetInterfacesViolationOf<Interfaces>] extends [never] ? WidgetPluginConfigPhase<Type, Interfaces> : WidgetInterfacesViolation<WidgetInterfacesViolationOf<Interfaces>>;
389
422
  }
@@ -393,8 +426,10 @@ interface WidgetPluginDescriptionPhase<Type extends string> {
393
426
  /**
394
427
  * Starts the plugin builder for one plugin `type`.
395
428
  *
396
- * Phase order is `interfaces -> config? -> slots? -> state? -> properties? -> methods? -> events? -> done()`;
397
- * a phase exists only when its capability is declared.
429
+ * Phase order is `description -> interfaces -> config? -> slots? -> state? -> properties? -> methods? -> events? -> done()`;
430
+ * a phase exists only when its capability is declared. Calling a declared phase out of order (or
431
+ * repeating it) fails type-checking with an order-specific diagnostic; the runtime builder itself is
432
+ * order-agnostic.
398
433
  */
399
434
  declare function createWidgetPlugin<const Type extends string>(type: Type): WidgetPluginDescriptionPhase<Type>;
400
435
  //#endregion
@@ -438,9 +473,35 @@ interface WidgetSystem<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTup
438
473
  /**
439
474
  * The compilation boundary. The input is `unknown` because JSON-parsed/untrusted document data is
440
475
  * the real boundary; malformed input still produces an inspectable Blueprint.
476
+ *
477
+ * Ownership: `definition` is retained **by reference**. `blueprint.source` is that exact value and
478
+ * each recovered node's `source` is a reference into the same graph; Core never clones, freezes or
479
+ * Proxy-wraps it. Passing it here transfers semantic ownership: neither the caller nor any reader of
480
+ * `blueprint.source` may mutate it (or anything inside it) afterwards, and behavior after such a
481
+ * mutation is unspecified. Pass a copy (for example `structuredClone` for JSON-domain data) to keep
482
+ * editing your own object.
441
483
  */
442
484
  createBlueprint: (definition: unknown) => WidgetSystemBlueprint<Plugins>;
443
485
  }
486
+ type WidgetSystemConfigurationErrorCode = 'foreign-plugin' | 'duplicate-plugin-type';
487
+ /**
488
+ * Thrown by `createWidgetSystem` for an invalid plugin registration. Discriminate by class and `code`;
489
+ * `message` is not protocol.
490
+ *
491
+ * - `foreign-plugin`: the entry at `pluginIndex` was not completed by this loaded module instance
492
+ * (another module instance or a structural look-alike). `pluginType` is its `type` when a string,
493
+ * else `null`. `firstPluginIndex` is `null`.
494
+ * - `duplicate-plugin-type`: the entry at `pluginIndex` repeats `pluginType`, first registered at
495
+ * `firstPluginIndex`.
496
+ */
497
+ declare class WidgetSystemConfigurationError extends Error {
498
+ readonly code: WidgetSystemConfigurationErrorCode;
499
+ readonly pluginIndex: number;
500
+ readonly pluginType: string | null;
501
+ readonly firstPluginIndex: number | null;
502
+ readonly name = "WidgetSystemConfigurationError";
503
+ constructor(code: WidgetSystemConfigurationErrorCode, pluginIndex: number, pluginType: string | null, firstPluginIndex?: number | null, message?: string);
504
+ }
444
505
  /**
445
506
  * Creates an instance-scoped, immutable widget system. Duplicate `plugin.type` is rejected.
446
507
  */
@@ -609,12 +670,15 @@ type WidgetSource<Plugins extends AnyWidgetPluginTuple> = Plugins[number] extend
609
670
  interface WidgetSystemBlueprintBase<Plugins extends AnyWidgetPluginTuple, Source = unknown> {
610
671
  readonly system: WidgetSystem<Plugins>;
611
672
  /**
612
- * The exact entire unknown input this Blueprint was compiled from.
673
+ * The exact entire unknown input this Blueprint was compiled from: the same reference that was
674
+ * passed in, never cloned or frozen by Core. Callers and readers must not mutate it; ownership of
675
+ * the graph transferred to Core when it was handed over (behavior after mutation is unspecified).
613
676
  */
614
677
  readonly source: Source;
615
678
  readonly sourceJsonCompatible: boolean;
616
679
  /**
617
- * Observably equivalent to `blueprint.system.createBlueprint(next)`.
680
+ * Observably equivalent to `blueprint.system.createBlueprint(next)`. `definition` is retained by
681
+ * reference and ownership transfers exactly as for `createBlueprint`.
618
682
  */
619
683
  recompile: (definition: unknown) => WidgetSystemBlueprint<Plugins>;
620
684
  }
@@ -1173,4 +1237,4 @@ interface DependencyBuilder<Interfaces extends WidgetInterfaces, Consumer extend
1173
1237
  widget: (widgetId: WidgetId) => OptionalizableDependencyTarget<Consumer>;
1174
1238
  }
1175
1239
  //#endregion
1176
- export { RuntimeDependencyValueRejectedDiagnostic as $, HasWidgetCapability as $n, WidgetCatalogEntry as $t, BlueprintNodeDiagnostic as A, WidgetPluginPropertiesPhase as An, RuntimeEventSurface as At, Diagnostic as B, WidgetResolvedConfigContext as Bn, SelfBlueprintWidgetNodeView as Bt, BlueprintDependencyDiagnosticLocation as C, WidgetPluginConfigMetadata as Cn, WidgetStateOf as Cr, CreateWidgetSystemRuntimeOptions as Ct, BlueprintDiagnostic as D, WidgetPluginEventsPhase as Dn, JsonPrimitive as Dr, ResolvedBlueprintWidgetNodeView as Dt, BlueprintDependencyTarget as E, WidgetPluginDonePhase as En, JsonObject as Er, ResolvedBlueprintWidgetNodeFor as Et, BlueprintSourceDiagnostic as F, WidgetPluginValidateStructureContext as Fn, RuntimeState as Ft, JsonCompatibilityDiagnostic as G, WidgetStateMemberDefinition as Gn, WidgetLocationView as Gt, DiagnosticCollector as H, WidgetSlotDefinitions as Hn, ValidBlueprintView as Ht, BlueprintSourceDiagnosticLocation as I, WidgetPropertiesSection as In, RuntimeStateSurface as It, RelativeSlotStructureDiagnosticInput as J, WidgetValueContract as Jn, WidgetSystemBlueprint as Jt, JsonCompatibilityReason as K, WidgetStateSection as Kn, WidgetSource as Kt, BlueprintStructureDiagnostic as L, WidgetPropertyComputeContext as Ln, RuntimeWidget as Lt, BlueprintPropertyDiagnosticLocation as M, WidgetPluginStatePhase as Mn, RuntimeMethodSurface as Mt, BlueprintSlotChildDiagnosticLocation as N, WidgetPluginTypeOf as Nn, RuntimeProperty as Nt, BlueprintDiagnosticLocation as O, WidgetPluginInterfacesPhase as On, JsonValue as Or, ResolvedBlueprintWidgetNodeViewFor as Ot, BlueprintSlotDiagnosticLocation as P, WidgetPluginValidateStructure as Pn, RuntimePropertySurface as Pt, RuntimeDependencyTargetFailedDiagnostic as Q, ExecutionResult as Qn, WidgetCatalog as Qt, BlueprintStructureDiagnosticLocation as R, WidgetPropertyDefinition as Rn, RuntimeWidgetFor as Rt, BlueprintDependencyDiagnostic as S, WidgetPluginCapabilities as Sn, WidgetStateKeyOf as Sr, BlueprintWidgetNodeView as St, BlueprintDependencyReference as T, WidgetPluginDescriptionPhase as Tn, JsonArray as Tr, ResolvedBlueprintWidgetNode as Tt, DiagnosticPath as U, WidgetSlotValidateStructureContext as Un, ValidWidgetSystemBlueprint as Ut, DiagnosticBase as V, WidgetSlotDefinition as Vn, UnresolvedBlueprintWidgetNode as Vt, EMPTY_DIAGNOSTICS as W, WidgetStateDefaultContext as Wn, WidgetLocation as Wt, RelativeSystemStructureDiagnosticInput as X, createWidgetValueContract as Xn, WidgetSystemRuntime as Xt, RelativeStructureDiagnosticLocation as Y, createWidgetPlugin as Yn, WidgetSystemBlueprintStatus as Yt, RelativeValueDiagnosticInput as Z, ExecutionFailure as Zn, CreateWidgetSystemOptions as Zt, ToExecutedDeps as _, WidgetMethodDefinition as _n, WidgetPropertyKeyOf as _r, BlueprintNodeConfigFields as _t, MaybeOptional as a, AnyWidgetPlugin as an, WidgetId as ar, RuntimeMethodDependencyDiagnostic as at, BlueprintConfigDiagnostic as b, WidgetMethodsSection as bn, WidgetResolvedConfigOf as br, BlueprintWidgetNode as bt, PropertyGetDepExpression as c, WidgetConfigDefinition as cn, WidgetMemberKey as cr, RuntimePropertyDependencyDiagnostic as ct, SelfMethodDependencyOperations as d, WidgetEventDefinition as dn, WidgetMethodArgsOf as dr, RuntimeStateDiagnostic as dt, WidgetPluginOf as en, NonEmptyReadonlyArray as er, RuntimeDiagnostic as et, SelfPropertyDependencyOperations as f, WidgetEventEmitter as fn, WidgetMethodKeyOf as fr, RuntimeWidgetDiagnostic as ft, ToExecutedDep as g, WidgetInterfacesViolation as gn, WidgetPropertiesOf as gr, BlueprintCompileView as gt, StateSetDepExpression as h, WidgetInterfacesOf as hn, WidgetMethodsOf as hr, WidgetSystemRuntimeDisposedError as ht, EmptyRegisteredDeps as i, createWidgetSystem as in, WidgetEventsOf as ir, RuntimeMethodArgsDiagnostic as it, BlueprintNodeDiagnosticLocation as j, WidgetPluginSlotsPhase as jn, RuntimeMethod as jt, BlueprintMethodDiagnosticLocation as k, WidgetPluginMethodsPhase as kn, RuntimeEvent as kt, RegisteredDeps as l, WidgetConfigJsonSchema as ln, WidgetMemberKeysOf as lr, RuntimePropertyDiagnostic as lt, StateGetDepExpression as m, WidgetEventsSection as mn, WidgetMethodReturnOf as mr, WidgetSystemRuntimeDiagnostic as mt, DependencyBuilder as n, WidgetSystemValidateStructure as nn, WidgetEventArgsOf as nr, RuntimeLevelDiagnostic as nt, MethodInvokeDepExpression as o, AnyWidgetPluginTuple as on, WidgetInterfaces as or, RuntimeMethodDiagnostic as ot, SelfStateDependencyOperations as p, WidgetEventEmitterContext as pn, WidgetMethodOf as pr, SourceAccessDiagnostic as pt, RelativePluginStructureDiagnosticInput as q, WidgetStateValidateContext as qn, WidgetSourceFor as qt, DependencyConsumer as r, WidgetSystemValidateStructureContext as rn, WidgetEventKeyOf as rr, RuntimeLevelDiagnosticLocation as rt, OptionalizableDependencyTarget as s, WIDGET_CONFIG_JSON_SCHEMA_DIALECT as sn, WidgetInterfacesViolationOf as sr, RuntimeMethodResultDiagnostic as st, AnyDepExpression as t, WidgetSystem as tn, WidgetCapabilityOf as tr, RuntimeDiagnosticLocation as tt, SelfDependencyTarget as u, WidgetConfigValidateContext as un, WidgetMemberValueOf as ur, RuntimePropertyResultDiagnostic as ut, UnknownTargetDependencyOperations as v, WidgetMethodExecuteContext as vn, WidgetPropertyValueOf as vr, BlueprintSemanticSlots as vt, BlueprintDependencyOperation as w, WidgetPluginConfigPhase as wn, WidgetStateValueOf as wr, InvalidWidgetSystemBlueprint as wt, BlueprintDefinitionDiagnostic as x, WidgetPlugin as xn, WidgetSlotNameOf as xr, BlueprintWidgetNodeBase as xt, UnknownTargetStateDependencyOperations as y, WidgetMethodValidateArgsContext as yn, WidgetRawConfigOf as yr, BlueprintSemanticSlotsView as yt, BlueprintWidgetDiagnosticLocation as z, WidgetRegisterDepsContext as zn, SelfBlueprintWidgetNode as zt };
1240
+ export { RuntimeDependencyValueRejectedDiagnostic as $, createWidgetValueContract as $n, WidgetCatalogEntry as $t, BlueprintNodeDiagnostic as A, WidgetPluginInterfacesPhase as An, JsonPrimitive as Ar, RuntimeEventSurface as At, Diagnostic as B, WidgetPropertyComputeContext as Bn, SelfBlueprintWidgetNodeView as Bt, BlueprintDependencyDiagnosticLocation as C, WidgetPlugin as Cn, WidgetResolvedConfigOf as Cr, CreateWidgetSystemRuntimeOptions as Ct, BlueprintDiagnostic as D, WidgetPluginDescriptionPhase as Dn, WidgetStateValueOf as Dr, ResolvedBlueprintWidgetNodeView as Dt, BlueprintDependencyTarget as E, WidgetPluginConfigPhase as En, WidgetStateOf as Er, ResolvedBlueprintWidgetNodeFor as Et, BlueprintSourceDiagnostic as F, WidgetPluginStatePhase as Fn, RuntimeState as Ft, JsonCompatibilityDiagnostic as G, WidgetSlotDefinitions as Gn, WidgetLocationView as Gt, DiagnosticCollector as H, WidgetRegisterDepsContext as Hn, ValidBlueprintView as Ht, BlueprintSourceDiagnosticLocation as I, WidgetPluginTypeOf as In, RuntimeStateSurface as It, RelativeSlotStructureDiagnosticInput as J, WidgetStateMemberDefinition as Jn, WidgetSystemBlueprint as Jt, JsonCompatibilityReason as K, WidgetSlotValidateStructureContext as Kn, WidgetSource as Kt, BlueprintStructureDiagnostic as L, WidgetPluginValidateStructure as Ln, RuntimeWidget as Lt, BlueprintPropertyDiagnosticLocation as M, WidgetPluginPhaseOrderViolation as Mn, RuntimeMethodSurface as Mt, BlueprintSlotChildDiagnosticLocation as N, WidgetPluginPropertiesPhase as Nn, RuntimeProperty as Nt, BlueprintDiagnosticLocation as O, WidgetPluginDonePhase as On, JsonArray as Or, ResolvedBlueprintWidgetNodeViewFor as Ot, BlueprintSlotDiagnosticLocation as P, WidgetPluginSlotsPhase as Pn, RuntimePropertySurface as Pt, RuntimeDependencyTargetFailedDiagnostic as Q, createWidgetPlugin as Qn, WidgetCatalog as Qt, BlueprintStructureDiagnosticLocation as R, WidgetPluginValidateStructureContext as Rn, RuntimeWidgetFor as Rt, BlueprintDependencyDiagnostic as S, WidgetMethodsSection as Sn, WidgetRawConfigOf as Sr, BlueprintWidgetNodeView as St, BlueprintDependencyReference as T, WidgetPluginConfigMetadata as Tn, WidgetStateKeyOf as Tr, ResolvedBlueprintWidgetNode as Tt, DiagnosticPath as U, WidgetResolvedConfigContext as Un, ValidWidgetSystemBlueprint as Ut, DiagnosticBase as V, WidgetPropertyDefinition as Vn, UnresolvedBlueprintWidgetNode as Vt, EMPTY_DIAGNOSTICS as W, WidgetSlotDefinition as Wn, WidgetLocation as Wt, RelativeSystemStructureDiagnosticInput as X, WidgetStateValidateContext as Xn, WidgetSystemRuntime as Xt, RelativeStructureDiagnosticLocation as Y, WidgetStateSection as Yn, WidgetSystemBlueprintStatus as Yt, RelativeValueDiagnosticInput as Z, WidgetValueContract as Zn, CreateWidgetSystemOptions as Zt, ToExecutedDeps as _, WidgetInterfacesOf as _n, WidgetMethodReturnOf as _r, BlueprintNodeConfigFields as _t, MaybeOptional as a, WidgetSystemValidateStructureContext as an, WidgetEventArgsOf as ar, RuntimeMethodDependencyDiagnostic as at, BlueprintConfigDiagnostic as b, WidgetMethodExecuteContext as bn, WidgetPropertyKeyOf as br, BlueprintWidgetNode as bt, PropertyGetDepExpression as c, AnyWidgetPluginTuple as cn, WidgetId as cr, RuntimePropertyDependencyDiagnostic as ct, SelfMethodDependencyOperations as d, WidgetConfigJsonSchema as dn, WidgetMemberKey as dr, RuntimeStateDiagnostic as dt, WidgetPluginOf as en, ExecutionFailure as er, RuntimeDiagnostic as et, SelfPropertyDependencyOperations as f, WidgetConfigValidateContext as fn, WidgetMemberKeysOf as fr, RuntimeWidgetDiagnostic as ft, ToExecutedDep as g, WidgetEventsSection as gn, WidgetMethodOf as gr, BlueprintCompileView as gt, StateSetDepExpression as h, WidgetEventEmitterContext as hn, WidgetMethodKeyOf as hr, WidgetSystemRuntimeDisposedError as ht, EmptyRegisteredDeps as i, WidgetSystemValidateStructure as in, WidgetCapabilityOf as ir, RuntimeMethodArgsDiagnostic as it, BlueprintNodeDiagnosticLocation as j, WidgetPluginMethodsPhase as jn, JsonValue as jr, RuntimeMethod as jt, BlueprintMethodDiagnosticLocation as k, WidgetPluginEventsPhase as kn, JsonObject as kr, RuntimeEvent as kt, RegisteredDeps as l, WIDGET_CONFIG_JSON_SCHEMA_DIALECT as ln, WidgetInterfaces as lr, RuntimePropertyDiagnostic as lt, StateGetDepExpression as m, WidgetEventEmitter as mn, WidgetMethodArgsOf as mr, WidgetSystemRuntimeDiagnostic as mt, DependencyBuilder as n, WidgetSystemConfigurationError as nn, HasWidgetCapability as nr, RuntimeLevelDiagnostic as nt, MethodInvokeDepExpression as o, createWidgetSystem as on, WidgetEventKeyOf as or, RuntimeMethodDiagnostic as ot, SelfStateDependencyOperations as p, WidgetEventDefinition as pn, WidgetMemberValueOf as pr, SourceAccessDiagnostic as pt, RelativePluginStructureDiagnosticInput as q, WidgetStateDefaultContext as qn, WidgetSourceFor as qt, DependencyConsumer as r, WidgetSystemConfigurationErrorCode as rn, NonEmptyReadonlyArray as rr, RuntimeLevelDiagnosticLocation as rt, OptionalizableDependencyTarget as s, AnyWidgetPlugin as sn, WidgetEventsOf as sr, RuntimeMethodResultDiagnostic as st, AnyDepExpression as t, WidgetSystem as tn, ExecutionResult as tr, RuntimeDiagnosticLocation as tt, SelfDependencyTarget as u, WidgetConfigDefinition as un, WidgetInterfacesViolationOf as ur, RuntimePropertyResultDiagnostic as ut, UnknownTargetDependencyOperations as v, WidgetInterfacesViolation as vn, WidgetMethodsOf as vr, BlueprintSemanticSlots as vt, BlueprintDependencyOperation as w, WidgetPluginCapabilities as wn, WidgetSlotNameOf as wr, InvalidWidgetSystemBlueprint as wt, BlueprintDefinitionDiagnostic as x, WidgetMethodValidateArgsContext as xn, WidgetPropertyValueOf as xr, BlueprintWidgetNodeBase as xt, UnknownTargetStateDependencyOperations as y, WidgetMethodDefinition as yn, WidgetPropertiesOf as yr, BlueprintSemanticSlotsView as yt, BlueprintWidgetDiagnosticLocation as z, WidgetPropertiesSection as zn, SelfBlueprintWidgetNode as zt };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as RuntimeDependencyValueRejectedDiagnostic, $n as HasWidgetCapability, $t as WidgetCatalogEntry, A as BlueprintNodeDiagnostic, An as WidgetPluginPropertiesPhase, At as RuntimeEventSurface, B as Diagnostic, Bn as WidgetResolvedConfigContext, Bt as SelfBlueprintWidgetNodeView, C as BlueprintDependencyDiagnosticLocation, Cn as WidgetPluginConfigMetadata, Cr as WidgetStateOf, Ct as CreateWidgetSystemRuntimeOptions, D as BlueprintDiagnostic, Dn as WidgetPluginEventsPhase, Dr as JsonPrimitive, Dt as ResolvedBlueprintWidgetNodeView, E as BlueprintDependencyTarget, En as WidgetPluginDonePhase, Er as JsonObject, Et as ResolvedBlueprintWidgetNodeFor, F as BlueprintSourceDiagnostic, Fn as WidgetPluginValidateStructureContext, Ft as RuntimeState, G as JsonCompatibilityDiagnostic, Gn as WidgetStateMemberDefinition, Gt as WidgetLocationView, H as DiagnosticCollector, Hn as WidgetSlotDefinitions, Ht as ValidBlueprintView, I as BlueprintSourceDiagnosticLocation, In as WidgetPropertiesSection, It as RuntimeStateSurface, J as RelativeSlotStructureDiagnosticInput, Jn as WidgetValueContract, Jt as WidgetSystemBlueprint, K as JsonCompatibilityReason, Kn as WidgetStateSection, Kt as WidgetSource, L as BlueprintStructureDiagnostic, Ln as WidgetPropertyComputeContext, Lt as RuntimeWidget, M as BlueprintPropertyDiagnosticLocation, Mn as WidgetPluginStatePhase, Mt as RuntimeMethodSurface, N as BlueprintSlotChildDiagnosticLocation, Nn as WidgetPluginTypeOf, Nt as RuntimeProperty, O as BlueprintDiagnosticLocation, On as WidgetPluginInterfacesPhase, Or as JsonValue, Ot as ResolvedBlueprintWidgetNodeViewFor, P as BlueprintSlotDiagnosticLocation, Pn as WidgetPluginValidateStructure, Pt as RuntimePropertySurface, Q as RuntimeDependencyTargetFailedDiagnostic, Qn as ExecutionResult, Qt as WidgetCatalog, R as BlueprintStructureDiagnosticLocation, Rn as WidgetPropertyDefinition, Rt as RuntimeWidgetFor, S as BlueprintDependencyDiagnostic, Sn as WidgetPluginCapabilities, Sr as WidgetStateKeyOf, St as BlueprintWidgetNodeView, T as BlueprintDependencyReference, Tn as WidgetPluginDescriptionPhase, Tr as JsonArray, Tt as ResolvedBlueprintWidgetNode, U as DiagnosticPath, Un as WidgetSlotValidateStructureContext, Ut as ValidWidgetSystemBlueprint, V as DiagnosticBase, Vn as WidgetSlotDefinition, Vt as UnresolvedBlueprintWidgetNode, W as EMPTY_DIAGNOSTICS, Wn as WidgetStateDefaultContext, Wt as WidgetLocation, X as RelativeSystemStructureDiagnosticInput, Xn as createWidgetValueContract, Xt as WidgetSystemRuntime, Y as RelativeStructureDiagnosticLocation, Yn as createWidgetPlugin, Yt as WidgetSystemBlueprintStatus, Z as RelativeValueDiagnosticInput, Zn as ExecutionFailure, Zt as CreateWidgetSystemOptions, _ as ToExecutedDeps, _n as WidgetMethodDefinition, _r as WidgetPropertyKeyOf, _t as BlueprintNodeConfigFields, a as MaybeOptional, an as AnyWidgetPlugin, ar as WidgetId, at as RuntimeMethodDependencyDiagnostic, b as BlueprintConfigDiagnostic, bn as WidgetMethodsSection, br as WidgetResolvedConfigOf, bt as BlueprintWidgetNode, c as PropertyGetDepExpression, cn as WidgetConfigDefinition, cr as WidgetMemberKey, ct as RuntimePropertyDependencyDiagnostic, d as SelfMethodDependencyOperations, dn as WidgetEventDefinition, dr as WidgetMethodArgsOf, dt as RuntimeStateDiagnostic, en as WidgetPluginOf, er as NonEmptyReadonlyArray, et as RuntimeDiagnostic, f as SelfPropertyDependencyOperations, fn as WidgetEventEmitter, fr as WidgetMethodKeyOf, ft as RuntimeWidgetDiagnostic, g as ToExecutedDep, gn as WidgetInterfacesViolation, gr as WidgetPropertiesOf, gt as BlueprintCompileView, h as StateSetDepExpression, hn as WidgetInterfacesOf, hr as WidgetMethodsOf, ht as WidgetSystemRuntimeDisposedError, i as EmptyRegisteredDeps, in as createWidgetSystem, ir as WidgetEventsOf, it as RuntimeMethodArgsDiagnostic, j as BlueprintNodeDiagnosticLocation, jn as WidgetPluginSlotsPhase, jt as RuntimeMethod, k as BlueprintMethodDiagnosticLocation, kn as WidgetPluginMethodsPhase, kt as RuntimeEvent, l as RegisteredDeps, ln as WidgetConfigJsonSchema, lr as WidgetMemberKeysOf, lt as RuntimePropertyDiagnostic, m as StateGetDepExpression, mn as WidgetEventsSection, mr as WidgetMethodReturnOf, mt as WidgetSystemRuntimeDiagnostic, n as DependencyBuilder, nn as WidgetSystemValidateStructure, nr as WidgetEventArgsOf, nt as RuntimeLevelDiagnostic, o as MethodInvokeDepExpression, on as AnyWidgetPluginTuple, or as WidgetInterfaces, ot as RuntimeMethodDiagnostic, p as SelfStateDependencyOperations, pn as WidgetEventEmitterContext, pr as WidgetMethodOf, pt as SourceAccessDiagnostic, q as RelativePluginStructureDiagnosticInput, qn as WidgetStateValidateContext, qt as WidgetSourceFor, r as DependencyConsumer, rn as WidgetSystemValidateStructureContext, rr as WidgetEventKeyOf, rt as RuntimeLevelDiagnosticLocation, s as OptionalizableDependencyTarget, sn as WIDGET_CONFIG_JSON_SCHEMA_DIALECT, sr as WidgetInterfacesViolationOf, st as RuntimeMethodResultDiagnostic, t as AnyDepExpression, tn as WidgetSystem, tr as WidgetCapabilityOf, tt as RuntimeDiagnosticLocation, u as SelfDependencyTarget, un as WidgetConfigValidateContext, ur as WidgetMemberValueOf, ut as RuntimePropertyResultDiagnostic, v as UnknownTargetDependencyOperations, vn as WidgetMethodExecuteContext, vr as WidgetPropertyValueOf, vt as BlueprintSemanticSlots, w as BlueprintDependencyOperation, wn as WidgetPluginConfigPhase, wr as WidgetStateValueOf, wt as InvalidWidgetSystemBlueprint, x as BlueprintDefinitionDiagnostic, xn as WidgetPlugin, xr as WidgetSlotNameOf, xt as BlueprintWidgetNodeBase, y as UnknownTargetStateDependencyOperations, yn as WidgetMethodValidateArgsContext, yr as WidgetRawConfigOf, yt as BlueprintSemanticSlotsView, z as BlueprintWidgetDiagnosticLocation, zn as WidgetRegisterDepsContext, zt as SelfBlueprintWidgetNode } from "./dep-CzOpc4xk.mjs";
1
+ import { $ as RuntimeDependencyValueRejectedDiagnostic, $n as createWidgetValueContract, $t as WidgetCatalogEntry, A as BlueprintNodeDiagnostic, An as WidgetPluginInterfacesPhase, Ar as JsonPrimitive, At as RuntimeEventSurface, B as Diagnostic, Bn as WidgetPropertyComputeContext, Bt as SelfBlueprintWidgetNodeView, C as BlueprintDependencyDiagnosticLocation, Cn as WidgetPlugin, Cr as WidgetResolvedConfigOf, Ct as CreateWidgetSystemRuntimeOptions, D as BlueprintDiagnostic, Dn as WidgetPluginDescriptionPhase, Dr as WidgetStateValueOf, Dt as ResolvedBlueprintWidgetNodeView, E as BlueprintDependencyTarget, En as WidgetPluginConfigPhase, Er as WidgetStateOf, Et as ResolvedBlueprintWidgetNodeFor, F as BlueprintSourceDiagnostic, Fn as WidgetPluginStatePhase, Ft as RuntimeState, G as JsonCompatibilityDiagnostic, Gn as WidgetSlotDefinitions, Gt as WidgetLocationView, H as DiagnosticCollector, Hn as WidgetRegisterDepsContext, Ht as ValidBlueprintView, I as BlueprintSourceDiagnosticLocation, In as WidgetPluginTypeOf, It as RuntimeStateSurface, J as RelativeSlotStructureDiagnosticInput, Jn as WidgetStateMemberDefinition, Jt as WidgetSystemBlueprint, K as JsonCompatibilityReason, Kn as WidgetSlotValidateStructureContext, Kt as WidgetSource, L as BlueprintStructureDiagnostic, Ln as WidgetPluginValidateStructure, Lt as RuntimeWidget, M as BlueprintPropertyDiagnosticLocation, Mn as WidgetPluginPhaseOrderViolation, Mt as RuntimeMethodSurface, N as BlueprintSlotChildDiagnosticLocation, Nn as WidgetPluginPropertiesPhase, Nt as RuntimeProperty, O as BlueprintDiagnosticLocation, On as WidgetPluginDonePhase, Or as JsonArray, Ot as ResolvedBlueprintWidgetNodeViewFor, P as BlueprintSlotDiagnosticLocation, Pn as WidgetPluginSlotsPhase, Pt as RuntimePropertySurface, Q as RuntimeDependencyTargetFailedDiagnostic, Qn as createWidgetPlugin, Qt as WidgetCatalog, R as BlueprintStructureDiagnosticLocation, Rn as WidgetPluginValidateStructureContext, Rt as RuntimeWidgetFor, S as BlueprintDependencyDiagnostic, Sn as WidgetMethodsSection, Sr as WidgetRawConfigOf, St as BlueprintWidgetNodeView, T as BlueprintDependencyReference, Tn as WidgetPluginConfigMetadata, Tr as WidgetStateKeyOf, Tt as ResolvedBlueprintWidgetNode, U as DiagnosticPath, Un as WidgetResolvedConfigContext, Ut as ValidWidgetSystemBlueprint, V as DiagnosticBase, Vn as WidgetPropertyDefinition, Vt as UnresolvedBlueprintWidgetNode, W as EMPTY_DIAGNOSTICS, Wn as WidgetSlotDefinition, Wt as WidgetLocation, X as RelativeSystemStructureDiagnosticInput, Xn as WidgetStateValidateContext, Xt as WidgetSystemRuntime, Y as RelativeStructureDiagnosticLocation, Yn as WidgetStateSection, Yt as WidgetSystemBlueprintStatus, Z as RelativeValueDiagnosticInput, Zn as WidgetValueContract, Zt as CreateWidgetSystemOptions, _ as ToExecutedDeps, _n as WidgetInterfacesOf, _r as WidgetMethodReturnOf, _t as BlueprintNodeConfigFields, a as MaybeOptional, an as WidgetSystemValidateStructureContext, ar as WidgetEventArgsOf, at as RuntimeMethodDependencyDiagnostic, b as BlueprintConfigDiagnostic, bn as WidgetMethodExecuteContext, br as WidgetPropertyKeyOf, bt as BlueprintWidgetNode, c as PropertyGetDepExpression, cn as AnyWidgetPluginTuple, cr as WidgetId, ct as RuntimePropertyDependencyDiagnostic, d as SelfMethodDependencyOperations, dn as WidgetConfigJsonSchema, dr as WidgetMemberKey, dt as RuntimeStateDiagnostic, en as WidgetPluginOf, er as ExecutionFailure, et as RuntimeDiagnostic, f as SelfPropertyDependencyOperations, fn as WidgetConfigValidateContext, fr as WidgetMemberKeysOf, ft as RuntimeWidgetDiagnostic, g as ToExecutedDep, gn as WidgetEventsSection, gr as WidgetMethodOf, gt as BlueprintCompileView, h as StateSetDepExpression, hn as WidgetEventEmitterContext, hr as WidgetMethodKeyOf, ht as WidgetSystemRuntimeDisposedError, i as EmptyRegisteredDeps, in as WidgetSystemValidateStructure, ir as WidgetCapabilityOf, it as RuntimeMethodArgsDiagnostic, j as BlueprintNodeDiagnosticLocation, jn as WidgetPluginMethodsPhase, jr as JsonValue, jt as RuntimeMethod, k as BlueprintMethodDiagnosticLocation, kn as WidgetPluginEventsPhase, kr as JsonObject, kt as RuntimeEvent, l as RegisteredDeps, ln as WIDGET_CONFIG_JSON_SCHEMA_DIALECT, lr as WidgetInterfaces, lt as RuntimePropertyDiagnostic, m as StateGetDepExpression, mn as WidgetEventEmitter, mr as WidgetMethodArgsOf, mt as WidgetSystemRuntimeDiagnostic, n as DependencyBuilder, nn as WidgetSystemConfigurationError, nr as HasWidgetCapability, nt as RuntimeLevelDiagnostic, o as MethodInvokeDepExpression, on as createWidgetSystem, or as WidgetEventKeyOf, ot as RuntimeMethodDiagnostic, p as SelfStateDependencyOperations, pn as WidgetEventDefinition, pr as WidgetMemberValueOf, pt as SourceAccessDiagnostic, q as RelativePluginStructureDiagnosticInput, qn as WidgetStateDefaultContext, qt as WidgetSourceFor, r as DependencyConsumer, rn as WidgetSystemConfigurationErrorCode, rr as NonEmptyReadonlyArray, rt as RuntimeLevelDiagnosticLocation, s as OptionalizableDependencyTarget, sn as AnyWidgetPlugin, sr as WidgetEventsOf, st as RuntimeMethodResultDiagnostic, t as AnyDepExpression, tn as WidgetSystem, tr as ExecutionResult, tt as RuntimeDiagnosticLocation, u as SelfDependencyTarget, un as WidgetConfigDefinition, ur as WidgetInterfacesViolationOf, ut as RuntimePropertyResultDiagnostic, v as UnknownTargetDependencyOperations, vn as WidgetInterfacesViolation, vr as WidgetMethodsOf, vt as BlueprintSemanticSlots, w as BlueprintDependencyOperation, wn as WidgetPluginCapabilities, wr as WidgetSlotNameOf, wt as InvalidWidgetSystemBlueprint, x as BlueprintDefinitionDiagnostic, xn as WidgetMethodValidateArgsContext, xr as WidgetPropertyValueOf, xt as BlueprintWidgetNodeBase, y as UnknownTargetStateDependencyOperations, yn as WidgetMethodDefinition, yr as WidgetPropertiesOf, yt as BlueprintSemanticSlotsView, z as BlueprintWidgetDiagnosticLocation, zn as WidgetPropertiesSection, zt as SelfBlueprintWidgetNode } from "./dep-DAoSoLhi.mjs";
2
2
  //#region src/source-patch.d.ts
3
3
  type SourcePath = readonly (string | number)[] | string;
4
4
  type SourcePatchOperation = {
@@ -25,8 +25,19 @@ type SourcePatchOperation = {
25
25
  readonly path: SourcePath;
26
26
  readonly value: JsonValue;
27
27
  };
28
+ /**
29
+ * An RFC 6902-style patch over JSON-domain authored source. Arrays are addressed only by canonical
30
+ * index (append is the JSON Pointer `/items/-` only). `test` and no-op detection compare numbers by
31
+ * SameValueZero (`0` equals `-0`), and explicit `add`/`replace` operands write `-0` as `+0`.
32
+ */
28
33
  type SourcePatch = readonly SourcePatchOperation[];
29
- type SourcePatchOperationFailureCode = 'invalid-path' | 'path-not-found' | 'path-not-traversable' | 'invalid-array-index' | 'invalid-move-target' | 'test-failed' | 'source-access-failed';
34
+ /**
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.
39
+ */
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';
30
41
  interface SourcePatchOperationFailure {
31
42
  readonly code: SourcePatchOperationFailureCode;
32
43
  readonly operationIndex: number;
@@ -70,6 +81,15 @@ interface CreateWidgetDocumentOptions<Plugins extends AnyWidgetPluginTuple> {
70
81
  readonly system: WidgetSystem<Plugins>;
71
82
  readonly source: unknown;
72
83
  }
84
+ /**
85
+ * Creates a revisioned source + Blueprint coordinator.
86
+ *
87
+ * Ownership: `options.source` is retained by reference as revision 0's `blueprint.source`, and Core
88
+ * never mutates it. Handing it over transfers ownership, so it must not be mutated afterwards. Patches
89
+ * are copy-on-write: each new revision shares untouched subtrees with the previous one, so any revision
90
+ * can share structure with this original input, and mutating the input corrupts later revisions too.
91
+ * A host that keeps its own editable model should pass a copy (for example `structuredClone`).
92
+ */
73
93
  declare function createWidgetDocument<const Plugins extends AnyWidgetPluginTuple>(options: CreateWidgetDocumentOptions<Plugins>): WidgetDocument<Plugins>;
74
94
  //#endregion
75
95
  //#region src/separated-source.d.ts
@@ -146,4 +166,4 @@ declare function separateWidgetSource<const Plugins extends AnyWidgetPluginTuple
146
166
  */
147
167
  declare function normalizeSeparatedWidgetSource(input: unknown): SeparatedWidgetSourceNormalization;
148
168
  //#endregion
149
- export { type AnyDepExpression, type AnyWidgetPlugin, type AnyWidgetPluginTuple, type ApplyPatchFailure, type ApplyPatchOptions, type ApplyPatchResult, type BlueprintCompileView, type BlueprintConfigDiagnostic, type BlueprintDefinitionDiagnostic, type BlueprintDependencyDiagnostic, type BlueprintDependencyDiagnosticLocation, type BlueprintDependencyOperation, type BlueprintDependencyReference, type BlueprintDependencyTarget, type BlueprintDiagnostic, type BlueprintDiagnosticLocation, type BlueprintMethodDiagnosticLocation, type BlueprintNodeConfigFields, type BlueprintNodeDiagnostic, type BlueprintNodeDiagnosticLocation, type BlueprintPropertyDiagnosticLocation, type BlueprintSemanticSlots, type BlueprintSemanticSlotsView, type BlueprintSlotChildDiagnosticLocation, type BlueprintSlotDiagnosticLocation, type BlueprintSourceDiagnostic, type BlueprintSourceDiagnosticLocation, type BlueprintStructureDiagnostic, type BlueprintStructureDiagnosticLocation, type BlueprintWidgetDiagnosticLocation, type BlueprintWidgetNode, type BlueprintWidgetNodeBase, type BlueprintWidgetNodeView, type CreateWidgetDocumentOptions, type CreateWidgetSystemOptions, type CreateWidgetSystemRuntimeOptions, type DependencyBuilder, type DependencyConsumer, type Diagnostic, type DiagnosticBase, type DiagnosticCollector, type DiagnosticPath, type DocumentRevisionConflictFailure, EMPTY_DIAGNOSTICS, type EmptyRegisteredDeps, type ExecutionFailure, type ExecutionResult, type HasWidgetCapability, type InvalidWidgetSystemBlueprint, type JsonArray, type JsonCompatibilityDiagnostic, type JsonCompatibilityReason, type JsonObject, type JsonPrimitive, type JsonValue, type MaybeOptional, type MethodInvokeDepExpression, type NonEmptyReadonlyArray, type OptionalizableDependencyTarget, type PropertyGetDepExpression, type ReentrantApplyFailure, type RegisteredDeps, type RelativePluginStructureDiagnosticInput, type RelativeSlotStructureDiagnosticInput, type RelativeStructureDiagnosticLocation, type RelativeSystemStructureDiagnosticInput, type RelativeValueDiagnosticInput, type ResolvedBlueprintWidgetNode, type ResolvedBlueprintWidgetNodeFor, type ResolvedBlueprintWidgetNodeView, type ResolvedBlueprintWidgetNodeViewFor, type RuntimeDependencyTargetFailedDiagnostic, type RuntimeDependencyValueRejectedDiagnostic, type RuntimeDiagnostic, type RuntimeDiagnosticLocation, type 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 WidgetPluginPropertiesPhase, type WidgetPluginSlotsPhase, type WidgetPluginStatePhase, type WidgetPluginTypeOf, type WidgetPluginValidateStructure, type WidgetPluginValidateStructureContext, type WidgetPropertiesOf, type WidgetPropertiesSection, type WidgetPropertyComputeContext, type WidgetPropertyDefinition, type WidgetPropertyKeyOf, type WidgetPropertyValueOf, type WidgetRawConfigOf, type WidgetRegisterDepsContext, type WidgetResolvedConfigContext, type WidgetResolvedConfigOf, type WidgetSlotDefinition, type WidgetSlotDefinitions, type WidgetSlotNameOf, type WidgetSlotValidateStructureContext, type WidgetSource, type WidgetSourceFor, type WidgetStateDefaultContext, type WidgetStateKeyOf, type WidgetStateMemberDefinition, type WidgetStateOf, type WidgetStateSection, type WidgetStateValidateContext, type WidgetStateValueOf, type WidgetSystem, type WidgetSystemBlueprint, type WidgetSystemBlueprintStatus, type WidgetSystemRuntime, type WidgetSystemRuntimeDiagnostic, WidgetSystemRuntimeDisposedError, type WidgetSystemValidateStructure, type WidgetSystemValidateStructureContext, type WidgetValueContract, createWidgetDocument, createWidgetPlugin, createWidgetSystem, createWidgetValueContract, normalizeSeparatedWidgetSource, separateWidgetSource };
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 };
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { a as runRuntimeOperation, i as invokeListenerIsolated, n as createEventPrimitive, o as writeDeferringFlush, r as createTrackedSubscription, t as buildEventEmitter } from "./event-BMif_vRJ.mjs";
2
- import { a as isCompiledDependency, c as createWidgetPlugin, d as createReadonlyMap, i as compiledDependencyBrand, l as createWidgetValueContract, n as runtimeInternals, o as readCompiledBlueprint, r as blueprintInternals, s as WIDGET_CONFIG_JSON_SCHEMA_DIALECT, u as readWidgetPluginDefinition } from "./internals-B67fyYoz.mjs";
2
+ import { a as createWidgetPlugin, c as readWidgetPluginDefinition, i as WIDGET_CONFIG_JSON_SCHEMA_DIALECT, l as createReadonlyMap, o as createWidgetValueContract, r as runtimeInternals, s as isCoreWidgetPlugin } from "./internals-L391flXY.mjs";
3
+ import { a as readCompiledBlueprint, n as compiledDependencyBrand, r as isCompiledDependency, t as blueprintInternals } from "./contract-CRpMqCY2.mjs";
3
4
  import { computed, endBatch, signal, startBatch } from "alien-signals";
4
5
  //#region src/diagnostic.ts
5
6
  const EMPTY_DIAGNOSTICS = Object.freeze([]);
@@ -167,9 +168,19 @@ function inspectJsonValue(value) {
167
168
  function isJsonValue(value) {
168
169
  return inspectJsonValue(value).compatible;
169
170
  }
170
- /** JSON-domain equality used by RFC6902 `test` and by SourcePatch no-op detection. */
171
+ /**
172
+ * SameValueZero: `+0` equals `-0` and `NaN` equals `NaN`. Used only for SourcePatch comparisons
173
+ * (`test` and no-op detection); Runtime State has its own equality rule and does not use this.
174
+ */
175
+ function sameValueZero(left, right) {
176
+ return left === right || typeof left === "number" && typeof right === "number" && Number.isNaN(left) && Number.isNaN(right);
177
+ }
178
+ /**
179
+ * JSON-domain equality used by the RFC6902 `test` operation; primitives compare by SameValueZero,
180
+ * so `-0` equals `0`. (SourcePatch no-op detection uses `structurallyEqual` in `source-patch.ts`.)
181
+ */
171
182
  function jsonEqual(left, right, seen = /* @__PURE__ */ new Set()) {
172
- if (Object.is(left, right)) return true;
183
+ if (sameValueZero(left, right)) return true;
173
184
  if (typeof left !== "object" || left === null || typeof right !== "object" || right === null) return false;
174
185
  if (!isJsonValue(left) || !isJsonValue(right)) return false;
175
186
  if (seen.has(left) || seen.has(right)) return false;
@@ -203,6 +214,7 @@ const PATCH_ERROR_MESSAGES = {
203
214
  "invalid-array-index": "The SourcePath contains an invalid Array index.",
204
215
  "invalid-move-target": "The move destination is invalid relative to its source.",
205
216
  "test-failed": "The test operation did not match the addressed value.",
217
+ "json-incompatible-value": "The SourcePatch operand is outside the JSON value domain.",
206
218
  "source-access-failed": "The source could not be inspected safely."
207
219
  };
208
220
  function failure(code, message = PATCH_ERROR_MESSAGES[code]) {
@@ -287,12 +299,14 @@ function inspectStructuralContainer(value) {
287
299
  function isCanonicalArrayIndex(key) {
288
300
  return /^(?:0|[1-9]\d*)$/.test(key) && Number(key) < 4294967295;
289
301
  }
290
- function getArrayIndex(path, segment, allowAppend = false) {
302
+ /**
303
+ * Arrays have only index members: after path normalization, any segment that is not a canonical
304
+ * index fails `invalid-array-index` in both path forms. `null` means the JSON Pointer append
305
+ * position and is only returned when the caller allows it (callers pass `allowAppend` only for a
306
+ * final JSON Pointer `-` on an add-like operation).
307
+ */
308
+ function getArrayIndex(segment, allowAppend = false) {
291
309
  const key = String(segment);
292
- if (!path.pointer && typeof segment === "string" && !isCanonicalArrayIndex(key)) return {
293
- ok: true,
294
- value: null
295
- };
296
310
  if (key === "-" && allowAppend) return {
297
311
  ok: true,
298
312
  value: null
@@ -344,7 +358,7 @@ function readAt(source, path) {
344
358
  if (!container.ok) return container;
345
359
  if (container.value === "opaque") return failure("path-not-traversable");
346
360
  if (container.value === "array") {
347
- const indexResult = getArrayIndex(path, segment);
361
+ const indexResult = getArrayIndex(segment);
348
362
  if (!indexResult.ok) return indexResult;
349
363
  const length = readArrayLength(current);
350
364
  if (!length.ok) return length;
@@ -418,17 +432,12 @@ function rebuildObject(container, segment, action, value, pointer = true, allowA
418
432
  const key = String(segment);
419
433
  const append = isArray && pointer && segment === "-" && allowArrayAppend;
420
434
  const effectiveKey = append ? String(arrayLength.value) : key;
421
- const arrayIndexResult = isArray ? getArrayIndex({
422
- segments: [],
423
- append: false,
424
- pointer
425
- }, segment, allowArrayAppend) : {
435
+ const arrayIndexResult = isArray ? getArrayIndex(segment, append) : {
426
436
  ok: true,
427
437
  value: null
428
438
  };
429
439
  if (!arrayIndexResult.ok) return arrayIndexResult;
430
440
  const arrayIndex = append ? arrayLength.value : arrayIndexResult.value;
431
- if (isArray && pointer && segment === "-" && !allowArrayAppend) return failure("invalid-array-index");
432
441
  if (isArray && arrayIndex !== null) {
433
442
  if (action === "add" && arrayIndex > arrayLength.value) return failure("invalid-array-index");
434
443
  if (action !== "add" && arrayIndex >= arrayLength.value) return failure("invalid-array-index");
@@ -474,7 +483,7 @@ function modifyAt(source, path, modify) {
474
483
  const key = String(segment);
475
484
  if (index === path.segments.length - 1) return modify(container, segment);
476
485
  if (containerKind.value === "array") {
477
- const indexResult = getArrayIndex(path, segment);
486
+ const indexResult = getArrayIndex(segment);
478
487
  if (!indexResult.ok) return indexResult;
479
488
  const length = readArrayLength(container);
480
489
  if (!length.ok) return length;
@@ -494,10 +503,15 @@ function modifyRoot(source, value) {
494
503
  value
495
504
  };
496
505
  }
497
- function copyValue(value) {
506
+ /**
507
+ * Structurally copies `value`. With `canonicalizeNegativeZero` (explicit `add`/`replace` operands),
508
+ * every `-0` at any depth is written as `+0`; `copy`/`move` relocate existing material unchanged.
509
+ */
510
+ function copyValue(value, canonicalizeNegativeZero = false) {
511
+ const canonical = (primitive) => canonicalizeNegativeZero && Object.is(primitive, -0) ? 0 : primitive;
498
512
  if (value === null || typeof value !== "object") return {
499
513
  ok: true,
500
- value
514
+ value: canonical(value)
501
515
  };
502
516
  const containerKind = inspectStructuralContainer(value);
503
517
  if (!containerKind.ok) return containerKind;
@@ -525,7 +539,7 @@ function copyValue(value) {
525
539
  const child = descriptor.value;
526
540
  let copied = {
527
541
  ok: true,
528
- value: child
542
+ value: canonical(child)
529
543
  };
530
544
  if (child !== null && typeof child === "object") {
531
545
  const childKind = inspectStructuralContainer(child);
@@ -546,7 +560,7 @@ function copyValue(value) {
546
560
  function structurallyEqual(left, right) {
547
561
  const matched = /* @__PURE__ */ new WeakMap();
548
562
  function equal(currentLeft, currentRight) {
549
- if (Object.is(currentLeft, currentRight)) return true;
563
+ if (sameValueZero(currentLeft, currentRight)) return true;
550
564
  if (typeof currentLeft !== "object" || currentLeft === null || typeof currentRight !== "object" || currentRight === null) return false;
551
565
  const leftKind = inspectStructuralContainer(currentLeft);
552
566
  const rightKind = inspectStructuralContainer(currentRight);
@@ -627,11 +641,11 @@ function applySourcePatch(source, patch) {
627
641
  if (!isJsonValue(value)) return {
628
642
  ok: false,
629
643
  failure: operationError(operationIndex, {
630
- code: "source-access-failed",
631
- message: "SourcePatch operands must be JsonValue."
644
+ code: "json-incompatible-value",
645
+ message: PATCH_ERROR_MESSAGES["json-incompatible-value"]
632
646
  })
633
647
  };
634
- const copied = copyValue(value);
648
+ const copied = copyValue(value, true);
635
649
  if (!copied.ok) return {
636
650
  ok: false,
637
651
  failure: operationError(operationIndex, copied.error)
@@ -655,8 +669,8 @@ function applySourcePatch(source, patch) {
655
669
  if (!isJsonValue(value)) return {
656
670
  ok: false,
657
671
  failure: operationError(operationIndex, {
658
- code: "source-access-failed",
659
- message: "SourcePatch operands must be JsonValue."
672
+ code: "json-incompatible-value",
673
+ message: PATCH_ERROR_MESSAGES["json-incompatible-value"]
660
674
  })
661
675
  };
662
676
  const actual = readAt(working, path);
@@ -745,6 +759,15 @@ function applySourcePatch(source, patch) {
745
759
  }
746
760
  //#endregion
747
761
  //#region src/document.ts
762
+ /**
763
+ * Creates a revisioned source + Blueprint coordinator.
764
+ *
765
+ * Ownership: `options.source` is retained by reference as revision 0's `blueprint.source`, and Core
766
+ * never mutates it. Handing it over transfers ownership, so it must not be mutated afterwards. Patches
767
+ * are copy-on-write: each new revision shares untouched subtrees with the previous one, so any revision
768
+ * can share structure with this original input, and mutating the input corrupts later revisions too.
769
+ * A host that keeps its own editable model should pass a copy (for example `structuredClone`).
770
+ */
748
771
  function createWidgetDocument(options) {
749
772
  let blueprint = options.system.createBlueprint(options.source);
750
773
  let snapshot = Object.freeze({
@@ -2218,10 +2241,13 @@ function createWidgetSystemRuntime(blueprint, options) {
2218
2241
  }
2219
2242
  }
2220
2243
  const runtimeWidgetsByNodeId = /* @__PURE__ */ new Map();
2244
+ const nodeIdByRuntimeWidget = /* @__PURE__ */ new Map();
2221
2245
  for (const [nodeId, entry] of registry) {
2222
2246
  const node = compiled.nodes[nodeId];
2223
2247
  if (node === void 0 || !node.resolved) continue;
2224
- runtimeWidgetsByNodeId.set(nodeId, buildRuntimeWidget(context, node, entry));
2248
+ const runtimeWidget = buildRuntimeWidget(context, node, entry);
2249
+ runtimeWidgetsByNodeId.set(nodeId, runtimeWidget);
2250
+ nodeIdByRuntimeWidget.set(runtimeWidget, nodeId);
2225
2251
  }
2226
2252
  const aggregate = createRuntimeAggregate(context, compiled, registry, overrideResolution.runtimeLevelDiagnostics);
2227
2253
  function getWidget(id) {
@@ -2244,7 +2270,9 @@ function createWidgetSystemRuntime(blueprint, options) {
2244
2270
  };
2245
2271
  runtime[runtimeInternals] = {
2246
2272
  context,
2247
- registry
2273
+ registry,
2274
+ compiled,
2275
+ nodeIdByRuntimeWidget
2248
2276
  };
2249
2277
  return runtime;
2250
2278
  }
@@ -3591,13 +3619,52 @@ function attachInternalsAndFreeze(blueprint, compiled) {
3591
3619
  //#endregion
3592
3620
  //#region src/system.ts
3593
3621
  /**
3622
+ * Thrown by `createWidgetSystem` for an invalid plugin registration. Discriminate by class and `code`;
3623
+ * `message` is not protocol.
3624
+ *
3625
+ * - `foreign-plugin`: the entry at `pluginIndex` was not completed by this loaded module instance
3626
+ * (another module instance or a structural look-alike). `pluginType` is its `type` when a string,
3627
+ * else `null`. `firstPluginIndex` is `null`.
3628
+ * - `duplicate-plugin-type`: the entry at `pluginIndex` repeats `pluginType`, first registered at
3629
+ * `firstPluginIndex`.
3630
+ */
3631
+ var WidgetSystemConfigurationError = class extends Error {
3632
+ code;
3633
+ pluginIndex;
3634
+ pluginType;
3635
+ firstPluginIndex;
3636
+ name = "WidgetSystemConfigurationError";
3637
+ constructor(code, pluginIndex, pluginType, firstPluginIndex = null, message = code === "foreign-plugin" ? `The widget plugin at index ${pluginIndex} was not created by this widget core instance.` : `Duplicate widget plugin type "${pluginType}" at index ${pluginIndex} (first registered at index ${firstPluginIndex}).`) {
3638
+ super(message);
3639
+ this.code = code;
3640
+ this.pluginIndex = pluginIndex;
3641
+ this.pluginType = pluginType;
3642
+ this.firstPluginIndex = firstPluginIndex;
3643
+ }
3644
+ };
3645
+ /**
3646
+ * Best-effort read of a foreign entry's `type`; a throwing accessor must not leak as an uncoded failure.
3647
+ */
3648
+ function readForeignPluginType(entry) {
3649
+ try {
3650
+ const type = entry?.type;
3651
+ return typeof type === "string" ? type : null;
3652
+ } catch {
3653
+ return null;
3654
+ }
3655
+ }
3656
+ /**
3594
3657
  * Creates an instance-scoped, immutable widget system. Duplicate `plugin.type` is rejected.
3595
3658
  */
3596
3659
  function createWidgetSystem(options) {
3597
3660
  const plugins = Object.freeze([...options.plugins]);
3598
3661
  const pluginsByType = /* @__PURE__ */ new Map();
3599
- for (const plugin of plugins) {
3600
- if (pluginsByType.has(plugin.type)) throw new Error(`Duplicate widget plugin type: "${plugin.type}".`);
3662
+ const firstIndexByType = /* @__PURE__ */ new Map();
3663
+ for (const [index, plugin] of plugins.entries()) {
3664
+ if (!isCoreWidgetPlugin(plugin)) throw new WidgetSystemConfigurationError("foreign-plugin", index, readForeignPluginType(plugin));
3665
+ const firstIndex = firstIndexByType.get(plugin.type);
3666
+ if (firstIndex !== void 0) throw new WidgetSystemConfigurationError("duplicate-plugin-type", index, plugin.type, firstIndex);
3667
+ firstIndexByType.set(plugin.type, index);
3601
3668
  pluginsByType.set(plugin.type, plugin);
3602
3669
  }
3603
3670
  const catalog = Object.freeze({ widgets: Object.freeze(plugins.map((plugin) => Object.freeze({
@@ -3623,4 +3690,4 @@ function createWidgetSystem(options) {
3623
3690
  return Object.freeze(system);
3624
3691
  }
3625
3692
  //#endregion
3626
- export { EMPTY_DIAGNOSTICS, WIDGET_CONFIG_JSON_SCHEMA_DIALECT, WidgetSystemRuntimeDisposedError, createWidgetDocument, createWidgetPlugin, createWidgetSystem, createWidgetValueContract, normalizeSeparatedWidgetSource, separateWidgetSource };
3693
+ export { EMPTY_DIAGNOSTICS, WIDGET_CONFIG_JSON_SCHEMA_DIALECT, WidgetSystemConfigurationError, WidgetSystemRuntimeDisposedError, createWidgetDocument, createWidgetPlugin, createWidgetSystem, createWidgetValueContract, normalizeSeparatedWidgetSource, separateWidgetSource };
@@ -1,4 +1,4 @@
1
- import { Cn as WidgetPluginConfigMetadata, Jt as WidgetSystemBlueprint, Qn as ExecutionResult, T as BlueprintDependencyReference, Tt as ResolvedBlueprintWidgetNode, Vt as UnresolvedBlueprintWidgetNode, Xt as WidgetSystemRuntime, an as AnyWidgetPlugin, bt as BlueprintWidgetNode, cr as WidgetMemberKey, lt as RuntimePropertyDiagnostic, on as AnyWidgetPluginTuple } from "../dep-CzOpc4xk.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-DAoSoLhi.mjs";
2
2
  //#region src/inspection/types.d.ts
3
3
  declare const inspectionNodeIdBrand: unique symbol;
4
4
  /**
@@ -183,6 +183,22 @@ type RuntimePropertyInspectionSnapshot<T> = {
183
183
  readonly result: ExecutionResult<T | null, RuntimePropertyDiagnostic>;
184
184
  };
185
185
  interface RuntimePropertyInspection<T> extends InspectionObservable<RuntimePropertyInspectionSnapshot<T>> {}
186
+ /**
187
+ * Passive, readonly observation of one Event member's occurrences. It grants no emit authority and never
188
+ * changes emission, public listener membership or order, or any exception the emitter sees.
189
+ *
190
+ * For one emit, every inspection listener runs **before** any public listener; the public audience is
191
+ * fixed before inspection listeners run, so an inspection callback cannot join the current public
192
+ * delivery. The inspection audience is snapshotted per occurrence. A throwing listener is isolated (it
193
+ * reaches neither the emitter, peer inspection listeners nor public listeners) and is reported outside
194
+ * the emit call; the reporting mechanism is not normative. Each occurrence passes one shallow-frozen
195
+ * args array shared by that occurrence's listeners; elements are the emitted references and are not
196
+ * cloned or deep-frozen. Only future occurrences are delivered (no replay or history). After
197
+ * `runtime.dispose()`, a new `subscribe()` throws `WidgetSystemRuntimeDisposedError`, earlier
198
+ * subscriptions receive nothing further, and unsubscribe stays idempotent. What a listener does by
199
+ * synchronously writing State or invoking Methods is not guaranteed beyond ordinary Runtime rules;
200
+ * defer such work, for example to a microtask.
201
+ */
186
202
  interface RuntimeEventInspection {
187
203
  subscribe: (listener: (args: readonly unknown[]) => void) => () => void;
188
204
  }
@@ -217,6 +233,22 @@ interface RuntimeInspection<Plugins extends AnyWidgetPluginTuple = AnyWidgetPlug
217
233
  */
218
234
  declare function inspectBlueprint<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple>(blueprint: WidgetSystemBlueprint<Plugins>): BlueprintInspection<Plugins>;
219
235
  //#endregion
236
+ //#region src/inspection/errors.d.ts
237
+ /**
238
+ * Coded exception for foreign inputs to the inspection entries.
239
+ */
240
+ type WidgetInspectionErrorCode = 'foreign-plugin' | 'foreign-blueprint' | 'foreign-runtime';
241
+ /**
242
+ * Thrown by `inspectPlugin` / `inspectBlueprint` / `inspectRuntime` when the argument was not produced
243
+ * by this loaded `@deviltea/widget-core` module instance (another module instance or a structural
244
+ * look-alike). Discriminate by class and `code`; `message` is not protocol.
245
+ */
246
+ declare class WidgetInspectionError extends Error {
247
+ readonly code: WidgetInspectionErrorCode;
248
+ readonly name = "WidgetInspectionError";
249
+ constructor(code: WidgetInspectionErrorCode, message?: string);
250
+ }
251
+ //#endregion
220
252
  //#region src/inspection/plugin.d.ts
221
253
  /**
222
254
  * Returns an identity-stable, readonly/passive projection for the exact completed Plugin object.
@@ -232,4 +264,4 @@ declare function inspectPlugin(plugin: AnyWidgetPlugin): PluginInspection;
232
264
  */
233
265
  declare function inspectRuntime<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple>(runtime: WidgetSystemRuntime<Plugins>): RuntimeInspection<Plugins>;
234
266
  //#endregion
235
- export { type AbsentBlueprintInspectionDependency, type BlueprintInspection, type BlueprintInspectionCapabilities, type BlueprintInspectionDependency, type BlueprintInspectionDependencyBase, type BlueprintInspectionEvaluationMemberRef, type BlueprintInspectionEventMember, type BlueprintInspectionInvalidCycle, type BlueprintInspectionMemberRef, type BlueprintInspectionMethodMember, type BlueprintInspectionNode, type BlueprintInspectionNodeBase, type BlueprintInspectionPropertyMember, type BlueprintInspectionSemanticSlot, type BlueprintInspectionSourceSlot, type BlueprintInspectionStateMember, type InspectionNodeId, type InspectionObservable, type InvalidBlueprintInspectionDependency, type PluginInspection, type PluginInspectionEventMember, type PluginInspectionPropertyMember, type PluginInspectionStateMember, type ResolvedBlueprintInspectionDependency, type ResolvedBlueprintInspectionNode, type RuntimeEventInspection, type RuntimeInspection, type RuntimePropertyInspection, type RuntimePropertyInspectionSnapshot, type RuntimeStateInspection, type RuntimeStateInspectionSnapshot, type RuntimeWidgetInspection, type UnresolvedBlueprintInspectionNode, inspectBlueprint, inspectPlugin, inspectRuntime };
267
+ export { type AbsentBlueprintInspectionDependency, type BlueprintInspection, type BlueprintInspectionCapabilities, type BlueprintInspectionDependency, type BlueprintInspectionDependencyBase, type BlueprintInspectionEvaluationMemberRef, type BlueprintInspectionEventMember, type BlueprintInspectionInvalidCycle, type BlueprintInspectionMemberRef, type BlueprintInspectionMethodMember, type BlueprintInspectionNode, type BlueprintInspectionNodeBase, type BlueprintInspectionPropertyMember, type BlueprintInspectionSemanticSlot, type BlueprintInspectionSourceSlot, type BlueprintInspectionStateMember, type InspectionNodeId, type InspectionObservable, type InvalidBlueprintInspectionDependency, type PluginInspection, type PluginInspectionEventMember, type PluginInspectionPropertyMember, type PluginInspectionStateMember, type ResolvedBlueprintInspectionDependency, type ResolvedBlueprintInspectionNode, type RuntimeEventInspection, type RuntimeInspection, type RuntimePropertyInspection, type RuntimePropertyInspectionSnapshot, type RuntimeStateInspection, type RuntimeStateInspectionSnapshot, type RuntimeWidgetInspection, type UnresolvedBlueprintInspectionNode, WidgetInspectionError, type WidgetInspectionErrorCode, inspectBlueprint, inspectPlugin, inspectRuntime };
@@ -1,4 +1,20 @@
1
- import { a as isCompiledDependency, d as createReadonlyMap, o as readCompiledBlueprint, t as readRuntimeInternals, u as readWidgetPluginDefinition } from "../internals-B67fyYoz.mjs";
1
+ import { c as readWidgetPluginDefinition, l as createReadonlyMap, n as readRuntimeInternals, s as isCoreWidgetPlugin, t as isCoreRuntime } from "../internals-L391flXY.mjs";
2
+ import { a as readCompiledBlueprint, i as isCoreBlueprint, r as isCompiledDependency } from "../contract-CRpMqCY2.mjs";
3
+ //#region src/inspection/errors.ts
4
+ /**
5
+ * Thrown by `inspectPlugin` / `inspectBlueprint` / `inspectRuntime` when the argument was not produced
6
+ * by this loaded `@deviltea/widget-core` module instance (another module instance or a structural
7
+ * look-alike). Discriminate by class and `code`; `message` is not protocol.
8
+ */
9
+ var WidgetInspectionError = class extends Error {
10
+ code;
11
+ name = "WidgetInspectionError";
12
+ constructor(code, message = `The ${code.slice(8)} was not produced by this widget core instance.`) {
13
+ super(message);
14
+ this.code = code;
15
+ }
16
+ };
17
+ //#endregion
2
18
  //#region src/inspection/blueprint.ts
3
19
  /**
4
20
  * Projects a compiler-owned `BlueprintDependencyReference` into an independent, deep-frozen structural
@@ -215,6 +231,7 @@ const blueprintInspectionCache = /* @__PURE__ */ new WeakMap();
215
231
  * cached (weak, no global strong retention) so `inspectBlueprint(blueprint) === inspectBlueprint(blueprint)`.
216
232
  */
217
233
  function inspectBlueprint(blueprint) {
234
+ if (!isCoreBlueprint(blueprint)) throw new WidgetInspectionError("foreign-blueprint");
218
235
  const cached = blueprintInspectionCache.get(blueprint);
219
236
  if (cached !== void 0) return cached;
220
237
  const built = buildBlueprintInspection(blueprint);
@@ -261,6 +278,7 @@ function buildEventMembers(plugin) {
261
278
  * Returns an identity-stable, readonly/passive projection for the exact completed Plugin object.
262
279
  */
263
280
  function inspectPlugin(plugin) {
281
+ if (!isCoreWidgetPlugin(plugin)) throw new WidgetInspectionError("foreign-plugin");
264
282
  const existing = inspectionCache.get(plugin);
265
283
  if (existing !== void 0) return existing;
266
284
  const inspection = Object.freeze({
@@ -369,6 +387,7 @@ const runtimeInspectionCache = /* @__PURE__ */ new WeakMap();
369
387
  * (post-mortem inspection).
370
388
  */
371
389
  function inspectRuntime(runtime) {
390
+ if (!isCoreRuntime(runtime)) throw new WidgetInspectionError("foreign-runtime");
372
391
  const cached = runtimeInspectionCache.get(runtime);
373
392
  if (cached !== void 0) return cached;
374
393
  const built = buildRuntimeInspection(runtime);
@@ -376,4 +395,4 @@ function inspectRuntime(runtime) {
376
395
  return built;
377
396
  }
378
397
  //#endregion
379
- export { inspectBlueprint, inspectPlugin, inspectRuntime };
398
+ export { WidgetInspectionError, inspectBlueprint, inspectPlugin, inspectRuntime };
@@ -1,6 +1,6 @@
1
- import { Lt as RuntimeWidget, Xt as WidgetSystemRuntime, cr as WidgetMemberKey, on as AnyWidgetPluginTuple } from "../dep-CzOpc4xk.mjs";
1
+ import { Lt as RuntimeWidget, Xt as WidgetSystemRuntime, cn as AnyWidgetPluginTuple, dr as WidgetMemberKey } from "../dep-DAoSoLhi.mjs";
2
2
  //#region src/integration/index.d.ts
3
- type WidgetIntegrationErrorCode = 'runtime-widget-mismatch';
3
+ type WidgetIntegrationErrorCode = 'runtime-widget-mismatch' | 'foreign-runtime';
4
4
  declare class WidgetIntegrationError extends Error {
5
5
  readonly code: WidgetIntegrationErrorCode;
6
6
  readonly name = "WidgetIntegrationError";
@@ -1,24 +1,24 @@
1
1
  import { t as buildEventEmitter } from "../event-BMif_vRJ.mjs";
2
- import { o as readCompiledBlueprint, t as readRuntimeInternals, u as readWidgetPluginDefinition } from "../internals-B67fyYoz.mjs";
2
+ import { c as readWidgetPluginDefinition, n as readRuntimeInternals, t as isCoreRuntime } from "../internals-L391flXY.mjs";
3
3
  //#region src/integration/index.ts
4
4
  var WidgetIntegrationError = class extends Error {
5
5
  code;
6
6
  name = "WidgetIntegrationError";
7
- constructor(code, message = "The RuntimeWidget does not belong to the supplied WidgetSystemRuntime instance.") {
7
+ constructor(code, message = code === "foreign-runtime" ? "The supplied WidgetSystemRuntime was not produced by this widget core instance." : "The RuntimeWidget does not belong to the supplied WidgetSystemRuntime instance.") {
8
8
  super(message);
9
9
  this.code = code;
10
10
  }
11
11
  };
12
12
  function getWidgetEventEmitter(runtime, widget) {
13
- const erasedWidget = widget;
14
- if (runtime.getWidget(erasedWidget.id) !== widget) throw new WidgetIntegrationError("runtime-widget-mismatch");
15
- const compiled = readCompiledBlueprint(runtime.blueprint);
16
- const nodeId = compiled.nodeIdByPublicNode.get(erasedWidget.blueprint);
17
- if (nodeId === void 0) throw new Error("The RuntimeWidget is not backed by the supplied Runtime Blueprint.");
18
- const node = compiled.nodes[nodeId];
13
+ if (!isCoreRuntime(runtime)) throw new WidgetIntegrationError("foreign-runtime");
14
+ const internals = readRuntimeInternals(runtime);
15
+ internals.context.assertActive();
16
+ const nodeId = typeof widget === "object" && widget !== null ? internals.nodeIdByRuntimeWidget.get(widget) : void 0;
17
+ if (nodeId === void 0) throw new WidgetIntegrationError("runtime-widget-mismatch");
18
+ const node = internals.compiled.nodes[nodeId];
19
19
  if (node === void 0 || !node.resolved) throw new Error("The RuntimeWidget is not backed by a resolved Runtime node.");
20
20
  if (readWidgetPluginDefinition(node.plugin).events === null) return null;
21
- const entry = readRuntimeInternals(runtime).registry.get(nodeId);
21
+ const entry = internals.registry.get(nodeId);
22
22
  if (entry === void 0) throw new Error("The RuntimeWidget event implementation was not found in the supplied Runtime.");
23
23
  return buildEventEmitter(entry.events);
24
24
  }
@@ -45,6 +45,16 @@ function createWidgetValueContract(id) {
45
45
  }
46
46
  const WIDGET_CONFIG_JSON_SCHEMA_DIALECT = "https://json-schema.org/draft/2020-12/schema";
47
47
  /**
48
+ * Provenance probe: true only for plugins completed by this loaded module instance. A plugin from
49
+ * another module instance (its brand is a different Symbol) or a structural look-alike is foreign.
50
+ * Capability separation, not a security sandbox.
51
+ */
52
+ function isCoreWidgetPlugin(value) {
53
+ if (typeof value !== "object" || value === null) return false;
54
+ const brand = value[widgetPluginBrand];
55
+ return typeof brand === "object" && brand !== null && typeof brand.definition === "object" && brand.definition !== null;
56
+ }
57
+ /**
48
58
  * Reads the erased definition record of a plugin.
49
59
  */
50
60
  function readWidgetPluginDefinition(plugin) {
@@ -69,8 +79,10 @@ function createSection(sink) {
69
79
  /**
70
80
  * Starts the plugin builder for one plugin `type`.
71
81
  *
72
- * Phase order is `interfaces -> config? -> slots? -> state? -> properties? -> methods? -> events? -> done()`;
73
- * a phase exists only when its capability is declared.
82
+ * Phase order is `description -> interfaces -> config? -> slots? -> state? -> properties? -> methods? -> events? -> done()`;
83
+ * a phase exists only when its capability is declared. Calling a declared phase out of order (or
84
+ * repeating it) fails type-checking with an order-specific diagnostic; the runtime builder itself is
85
+ * order-agnostic.
74
86
  */
75
87
  function createWidgetPlugin(type) {
76
88
  const draft = {
@@ -166,23 +178,15 @@ function createWidgetPlugin(type) {
166
178
  return builder;
167
179
  }
168
180
  //#endregion
169
- //#region src/internal/contract.ts
170
- const compiledDependencyBrand = Symbol("@deviltea/widget-core:compiled-dependency");
171
- function isCompiledDependency(value) {
172
- return typeof value === "object" && value !== null && compiledDependencyBrand in value;
173
- }
174
- const blueprintInternals = Symbol("@deviltea/widget-core:blueprint-internals");
181
+ //#region src/runtime/internals.ts
182
+ const runtimeInternals = Symbol("@deviltea/widget-core:runtime-internals");
175
183
  /**
176
- * Reads the compiled snapshot carried by a Blueprint.
184
+ * Provenance probe: true only for Runtimes produced by this loaded module instance.
177
185
  */
178
- function readCompiledBlueprint(blueprint) {
179
- const compiled = blueprint[blueprintInternals];
180
- if (compiled === void 0) throw new Error("The blueprint was not produced by this widget core build.");
181
- return compiled;
186
+ function isCoreRuntime(value) {
187
+ if (typeof value !== "object" || value === null) return false;
188
+ return value[runtimeInternals] !== void 0;
182
189
  }
183
- //#endregion
184
- //#region src/runtime/internals.ts
185
- const runtimeInternals = Symbol("@deviltea/widget-core:runtime-internals");
186
190
  /**
187
191
  * Reads the internals carried by a Runtime produced by `createWidgetSystemRuntime`.
188
192
  */
@@ -192,4 +196,4 @@ function readRuntimeInternals(runtime) {
192
196
  return internals;
193
197
  }
194
198
  //#endregion
195
- export { isCompiledDependency as a, createWidgetPlugin as c, createReadonlyMap as d, compiledDependencyBrand as i, createWidgetValueContract as l, runtimeInternals as n, readCompiledBlueprint as o, blueprintInternals as r, WIDGET_CONFIG_JSON_SCHEMA_DIALECT as s, readRuntimeInternals as t, readWidgetPluginDefinition as u };
199
+ export { createWidgetPlugin as a, readWidgetPluginDefinition as c, WIDGET_CONFIG_JSON_SCHEMA_DIALECT as i, createReadonlyMap as l, readRuntimeInternals as n, createWidgetValueContract as o, runtimeInternals as r, isCoreWidgetPlugin as s, isCoreRuntime as t };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.0.2",
7
+ "version": "0.0.4",
8
8
  "author": "DevilTea <ch19980814@gmail.com>",
9
9
  "license": "MIT",
10
10
  "homepage": "https://github.com/DevilTea/widget/tree/main/packages/core#readme",