@deviltea/widget-core 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -7
- package/dist/contract-CRpMqCY2.mjs +23 -0
- package/dist/{dep-CzOpc4xk.d.mts → dep-DAoSoLhi.d.mts} +82 -18
- package/dist/index.d.mts +11 -2
- package/dist/index.mjs +61 -7
- package/dist/inspection/index.d.mts +34 -2
- package/dist/inspection/index.mjs +21 -2
- package/dist/integration/index.d.mts +2 -2
- package/dist/integration/index.mjs +9 -9
- package/dist/{internals-B67fyYoz.mjs → internals-L391flXY.mjs} +21 -17
- package/package.json +1 -1
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](
|
|
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,46 @@ 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`, or
|
|
277
|
+
`source-access-failed`, and `operationIndex` is the failing operation's
|
|
278
|
+
position in the patch. A failed patch leaves the committed source and revision
|
|
279
|
+
unchanged.
|
|
280
|
+
|
|
281
|
+
`document.subscribe(listener)` registers `listener` and returns an idempotent
|
|
282
|
+
unsubscribe function. The listener is not called on subscription; it receives
|
|
283
|
+
the new snapshot after each committed (`changed: true`) patch, in subscription
|
|
284
|
+
order, over the subscriber list as it stood when notification began. An
|
|
285
|
+
exception thrown by a listener does not fail `applyPatch()` or stop the
|
|
286
|
+
remaining listeners, and it is reported outside `applyPatch()`; the reporting
|
|
287
|
+
mechanism is not part of the contract.
|
|
288
|
+
|
|
237
289
|
### SeparatedWidgetSource tooling
|
|
238
290
|
|
|
239
291
|
`WidgetSource` is the only canonical nested authored representation. The explicit
|
|
@@ -261,6 +313,12 @@ later occurrence is de-identified with its available subtree preserved.
|
|
|
261
313
|
|
|
262
314
|
### Runtime semantics
|
|
263
315
|
|
|
316
|
+
- Declared `events` are public notifications: subscribe through
|
|
317
|
+
`widget.events[name].subscribe(listener)`. Delivery is synchronous and
|
|
318
|
+
depth-first for nested emits; a throwing public listener propagates to the
|
|
319
|
+
emit caller and stops the remaining public listeners. Emit authority belongs
|
|
320
|
+
to Method `execute` (`emit`) and, for renderers, `@deviltea/widget-core/integration`.
|
|
321
|
+
See [Events](https://deviltea.github.io/widget/packages/widget-core#events).
|
|
264
322
|
- `widget.state[key].get()` returns `T | null` directly — it is not an
|
|
265
323
|
`ExecutionResult`.
|
|
266
324
|
- `widget.properties[name].get()` / `.subscribe(listener)` and
|
|
@@ -292,19 +350,22 @@ later occurrence is de-identified with its available subtree preserved.
|
|
|
292
350
|
`WidgetSystemRuntimeDisposedError`; unsubscribe functions obtained before
|
|
293
351
|
disposal remain safe idempotent no-ops.
|
|
294
352
|
|
|
295
|
-
### Inspection
|
|
353
|
+
### Inspection
|
|
296
354
|
|
|
297
|
-
A dedicated, strictly readonly subpath
|
|
298
|
-
|
|
299
|
-
|
|
355
|
+
A dedicated, strictly readonly subpath is a supported observation surface for
|
|
356
|
+
any host (DevTools, prototype players, test harnesses). It exposes
|
|
357
|
+
compiler/runtime facts, including passive Event occurrence observation through
|
|
358
|
+
`getEvent(name).subscribe(...)`, and never mutates state, invokes methods, or
|
|
359
|
+
forces Property evaluation:
|
|
300
360
|
|
|
301
361
|
```typescript
|
|
302
362
|
import { inspectBlueprint, inspectRuntime } from '@deviltea/widget-core/inspection'
|
|
303
363
|
```
|
|
304
364
|
|
|
305
365
|
`@deviltea/widget-core`'s root entrypoint does not export this surface. See
|
|
306
|
-
[Inspection](https://deviltea.github.io/widget/packages/widget-core#inspection
|
|
307
|
-
in the full guide for the exact contract
|
|
366
|
+
[Inspection](https://deviltea.github.io/widget/packages/widget-core#inspection)
|
|
367
|
+
in the full guide for the exact contract, including the Event inspection
|
|
368
|
+
delivery guarantees.
|
|
308
369
|
|
|
309
370
|
The full guide at
|
|
310
371
|
[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
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
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 $,
|
|
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
|
|
1
|
+
import { $ as RuntimeDependencyValueRejectedDiagnostic, $n as createWidgetValueContract, $t as WidgetCatalogEntry, A as BlueprintNodeDiagnostic, An as WidgetPluginInterfacesPhase, Ar as JsonPrimitive, At as RuntimeEventSurface, B as Diagnostic, Bn as WidgetPropertyComputeContext, Bt as SelfBlueprintWidgetNodeView, C as BlueprintDependencyDiagnosticLocation, Cn as WidgetPlugin, Cr as WidgetResolvedConfigOf, Ct as CreateWidgetSystemRuntimeOptions, D as BlueprintDiagnostic, Dn as WidgetPluginDescriptionPhase, Dr as WidgetStateValueOf, Dt as ResolvedBlueprintWidgetNodeView, E as BlueprintDependencyTarget, En as WidgetPluginConfigPhase, Er as WidgetStateOf, Et as ResolvedBlueprintWidgetNodeFor, F as BlueprintSourceDiagnostic, Fn as WidgetPluginStatePhase, Ft as RuntimeState, G as JsonCompatibilityDiagnostic, Gn as WidgetSlotDefinitions, Gt as WidgetLocationView, H as DiagnosticCollector, Hn as WidgetRegisterDepsContext, Ht as ValidBlueprintView, I as BlueprintSourceDiagnosticLocation, In as WidgetPluginTypeOf, It as RuntimeStateSurface, J as RelativeSlotStructureDiagnosticInput, Jn as WidgetStateMemberDefinition, Jt as WidgetSystemBlueprint, K as JsonCompatibilityReason, Kn as WidgetSlotValidateStructureContext, Kt as WidgetSource, L as BlueprintStructureDiagnostic, Ln as WidgetPluginValidateStructure, Lt as RuntimeWidget, M as BlueprintPropertyDiagnosticLocation, Mn as WidgetPluginPhaseOrderViolation, Mt as RuntimeMethodSurface, N as BlueprintSlotChildDiagnosticLocation, Nn as WidgetPluginPropertiesPhase, Nt as RuntimeProperty, O as BlueprintDiagnosticLocation, On as WidgetPluginDonePhase, Or as JsonArray, Ot as ResolvedBlueprintWidgetNodeViewFor, P as BlueprintSlotDiagnosticLocation, Pn as WidgetPluginSlotsPhase, Pt as RuntimePropertySurface, Q as RuntimeDependencyTargetFailedDiagnostic, Qn as createWidgetPlugin, Qt as WidgetCatalog, R as BlueprintStructureDiagnosticLocation, Rn as WidgetPluginValidateStructureContext, Rt as RuntimeWidgetFor, S as BlueprintDependencyDiagnostic, Sn as WidgetMethodsSection, Sr as WidgetRawConfigOf, St as BlueprintWidgetNodeView, T as BlueprintDependencyReference, Tn as WidgetPluginConfigMetadata, Tr as WidgetStateKeyOf, Tt as ResolvedBlueprintWidgetNode, U as DiagnosticPath, Un as WidgetResolvedConfigContext, Ut as ValidWidgetSystemBlueprint, V as DiagnosticBase, Vn as WidgetPropertyDefinition, Vt as UnresolvedBlueprintWidgetNode, W as EMPTY_DIAGNOSTICS, Wn as WidgetSlotDefinition, Wt as WidgetLocation, X as RelativeSystemStructureDiagnosticInput, Xn as WidgetStateValidateContext, Xt as WidgetSystemRuntime, Y as RelativeStructureDiagnosticLocation, Yn as WidgetStateSection, Yt as WidgetSystemBlueprintStatus, Z as RelativeValueDiagnosticInput, Zn as WidgetValueContract, Zt as CreateWidgetSystemOptions, _ as ToExecutedDeps, _n as WidgetInterfacesOf, _r as WidgetMethodReturnOf, _t as BlueprintNodeConfigFields, a as MaybeOptional, an as WidgetSystemValidateStructureContext, ar as WidgetEventArgsOf, at as RuntimeMethodDependencyDiagnostic, b as BlueprintConfigDiagnostic, bn as WidgetMethodExecuteContext, br as WidgetPropertyKeyOf, bt as BlueprintWidgetNode, c as PropertyGetDepExpression, cn as AnyWidgetPluginTuple, cr as WidgetId, ct as RuntimePropertyDependencyDiagnostic, d as SelfMethodDependencyOperations, dn as WidgetConfigJsonSchema, dr as WidgetMemberKey, dt as RuntimeStateDiagnostic, en as WidgetPluginOf, er as ExecutionFailure, et as RuntimeDiagnostic, f as SelfPropertyDependencyOperations, fn as WidgetConfigValidateContext, fr as WidgetMemberKeysOf, ft as RuntimeWidgetDiagnostic, g as ToExecutedDep, gn as WidgetEventsSection, gr as WidgetMethodOf, gt as BlueprintCompileView, h as StateSetDepExpression, hn as WidgetEventEmitterContext, hr as WidgetMethodKeyOf, ht as WidgetSystemRuntimeDisposedError, i as EmptyRegisteredDeps, in as WidgetSystemValidateStructure, ir as WidgetCapabilityOf, it as RuntimeMethodArgsDiagnostic, j as BlueprintNodeDiagnosticLocation, jn as WidgetPluginMethodsPhase, jr as JsonValue, jt as RuntimeMethod, k as BlueprintMethodDiagnosticLocation, kn as WidgetPluginEventsPhase, kr as JsonObject, kt as RuntimeEvent, l as RegisteredDeps, ln as WIDGET_CONFIG_JSON_SCHEMA_DIALECT, lr as WidgetInterfaces, lt as RuntimePropertyDiagnostic, m as StateGetDepExpression, mn as WidgetEventEmitter, mr as WidgetMethodArgsOf, mt as WidgetSystemRuntimeDiagnostic, n as DependencyBuilder, nn as WidgetSystemConfigurationError, nr as HasWidgetCapability, nt as RuntimeLevelDiagnostic, o as MethodInvokeDepExpression, on as createWidgetSystem, or as WidgetEventKeyOf, ot as RuntimeMethodDiagnostic, p as SelfStateDependencyOperations, pn as WidgetEventDefinition, pr as WidgetMemberValueOf, pt as SourceAccessDiagnostic, q as RelativePluginStructureDiagnosticInput, qn as WidgetStateDefaultContext, qt as WidgetSourceFor, r as DependencyConsumer, rn as WidgetSystemConfigurationErrorCode, rr as NonEmptyReadonlyArray, rt as RuntimeLevelDiagnosticLocation, s as OptionalizableDependencyTarget, sn as AnyWidgetPlugin, sr as WidgetEventsOf, st as RuntimeMethodResultDiagnostic, t as AnyDepExpression, tn as WidgetSystem, tr as ExecutionResult, tt as RuntimeDiagnosticLocation, u as SelfDependencyTarget, un as WidgetConfigDefinition, ur as WidgetInterfacesViolationOf, ut as RuntimePropertyResultDiagnostic, v as UnknownTargetDependencyOperations, vn as WidgetInterfacesViolation, vr as WidgetMethodsOf, vt as BlueprintSemanticSlots, w as BlueprintDependencyOperation, wn as WidgetPluginCapabilities, wr as WidgetSlotNameOf, wt as InvalidWidgetSystemBlueprint, x as BlueprintDefinitionDiagnostic, xn as WidgetMethodValidateArgsContext, xr as WidgetPropertyValueOf, xt as BlueprintWidgetNodeBase, y as UnknownTargetStateDependencyOperations, yn as WidgetMethodDefinition, yr as WidgetPropertiesOf, yt as BlueprintSemanticSlotsView, z as BlueprintWidgetDiagnosticLocation, zn as WidgetPropertiesSection, zt as SelfBlueprintWidgetNode } from "./dep-DAoSoLhi.mjs";
|
|
2
2
|
//#region src/source-patch.d.ts
|
|
3
3
|
type SourcePath = readonly (string | number)[] | string;
|
|
4
4
|
type SourcePatchOperation = {
|
|
@@ -70,6 +70,15 @@ interface CreateWidgetDocumentOptions<Plugins extends AnyWidgetPluginTuple> {
|
|
|
70
70
|
readonly system: WidgetSystem<Plugins>;
|
|
71
71
|
readonly source: unknown;
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Creates a revisioned source + Blueprint coordinator.
|
|
75
|
+
*
|
|
76
|
+
* Ownership: `options.source` is retained by reference as revision 0's `blueprint.source`, and Core
|
|
77
|
+
* never mutates it. Handing it over transfers ownership, so it must not be mutated afterwards. Patches
|
|
78
|
+
* are copy-on-write: each new revision shares untouched subtrees with the previous one, so any revision
|
|
79
|
+
* can share structure with this original input, and mutating the input corrupts later revisions too.
|
|
80
|
+
* A host that keeps its own editable model should pass a copy (for example `structuredClone`).
|
|
81
|
+
*/
|
|
73
82
|
declare function createWidgetDocument<const Plugins extends AnyWidgetPluginTuple>(options: CreateWidgetDocumentOptions<Plugins>): WidgetDocument<Plugins>;
|
|
74
83
|
//#endregion
|
|
75
84
|
//#region src/separated-source.d.ts
|
|
@@ -146,4 +155,4 @@ declare function separateWidgetSource<const Plugins extends AnyWidgetPluginTuple
|
|
|
146
155
|
*/
|
|
147
156
|
declare function normalizeSeparatedWidgetSource(input: unknown): SeparatedWidgetSourceNormalization;
|
|
148
157
|
//#endregion
|
|
149
|
-
export { type AnyDepExpression, type AnyWidgetPlugin, type AnyWidgetPluginTuple, type ApplyPatchFailure, type ApplyPatchOptions, type ApplyPatchResult, type BlueprintCompileView, type BlueprintConfigDiagnostic, type BlueprintDefinitionDiagnostic, type BlueprintDependencyDiagnostic, type BlueprintDependencyDiagnosticLocation, type BlueprintDependencyOperation, type BlueprintDependencyReference, type BlueprintDependencyTarget, type BlueprintDiagnostic, type BlueprintDiagnosticLocation, type BlueprintMethodDiagnosticLocation, type BlueprintNodeConfigFields, type BlueprintNodeDiagnostic, type BlueprintNodeDiagnosticLocation, type BlueprintPropertyDiagnosticLocation, type BlueprintSemanticSlots, type BlueprintSemanticSlotsView, type BlueprintSlotChildDiagnosticLocation, type BlueprintSlotDiagnosticLocation, type BlueprintSourceDiagnostic, type BlueprintSourceDiagnosticLocation, type BlueprintStructureDiagnostic, type BlueprintStructureDiagnosticLocation, type BlueprintWidgetDiagnosticLocation, type BlueprintWidgetNode, type BlueprintWidgetNodeBase, type BlueprintWidgetNodeView, type CreateWidgetDocumentOptions, type CreateWidgetSystemOptions, type CreateWidgetSystemRuntimeOptions, type DependencyBuilder, type DependencyConsumer, type Diagnostic, type DiagnosticBase, type DiagnosticCollector, type DiagnosticPath, type DocumentRevisionConflictFailure, EMPTY_DIAGNOSTICS, type EmptyRegisteredDeps, type ExecutionFailure, type ExecutionResult, type HasWidgetCapability, type InvalidWidgetSystemBlueprint, type JsonArray, type JsonCompatibilityDiagnostic, type JsonCompatibilityReason, type JsonObject, type JsonPrimitive, type JsonValue, type MaybeOptional, type MethodInvokeDepExpression, type NonEmptyReadonlyArray, type OptionalizableDependencyTarget, type PropertyGetDepExpression, type ReentrantApplyFailure, type RegisteredDeps, type RelativePluginStructureDiagnosticInput, type RelativeSlotStructureDiagnosticInput, type RelativeStructureDiagnosticLocation, type RelativeSystemStructureDiagnosticInput, type RelativeValueDiagnosticInput, type ResolvedBlueprintWidgetNode, type ResolvedBlueprintWidgetNodeFor, type ResolvedBlueprintWidgetNodeView, type ResolvedBlueprintWidgetNodeViewFor, type RuntimeDependencyTargetFailedDiagnostic, type RuntimeDependencyValueRejectedDiagnostic, type RuntimeDiagnostic, type RuntimeDiagnosticLocation, type 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 };
|
|
158
|
+
export { type AnyDepExpression, type AnyWidgetPlugin, type AnyWidgetPluginTuple, type ApplyPatchFailure, type ApplyPatchOptions, type ApplyPatchResult, type BlueprintCompileView, type BlueprintConfigDiagnostic, type BlueprintDefinitionDiagnostic, type BlueprintDependencyDiagnostic, type BlueprintDependencyDiagnosticLocation, type BlueprintDependencyOperation, type BlueprintDependencyReference, type BlueprintDependencyTarget, type BlueprintDiagnostic, type BlueprintDiagnosticLocation, type BlueprintMethodDiagnosticLocation, type BlueprintNodeConfigFields, type BlueprintNodeDiagnostic, type BlueprintNodeDiagnosticLocation, type BlueprintPropertyDiagnosticLocation, type BlueprintSemanticSlots, type BlueprintSemanticSlotsView, type BlueprintSlotChildDiagnosticLocation, type BlueprintSlotDiagnosticLocation, type BlueprintSourceDiagnostic, type BlueprintSourceDiagnosticLocation, type BlueprintStructureDiagnostic, type BlueprintStructureDiagnosticLocation, type BlueprintWidgetDiagnosticLocation, type BlueprintWidgetNode, type BlueprintWidgetNodeBase, type BlueprintWidgetNodeView, type CreateWidgetDocumentOptions, type CreateWidgetSystemOptions, type CreateWidgetSystemRuntimeOptions, type DependencyBuilder, type DependencyConsumer, type Diagnostic, type DiagnosticBase, type DiagnosticCollector, type DiagnosticPath, type DocumentRevisionConflictFailure, EMPTY_DIAGNOSTICS, type EmptyRegisteredDeps, type ExecutionFailure, type ExecutionResult, type HasWidgetCapability, type InvalidWidgetSystemBlueprint, type JsonArray, type JsonCompatibilityDiagnostic, type JsonCompatibilityReason, type JsonObject, type JsonPrimitive, type JsonValue, type MaybeOptional, type MethodInvokeDepExpression, type NonEmptyReadonlyArray, type OptionalizableDependencyTarget, type PropertyGetDepExpression, type ReentrantApplyFailure, type RegisteredDeps, type RelativePluginStructureDiagnosticInput, type RelativeSlotStructureDiagnosticInput, type RelativeStructureDiagnosticLocation, type RelativeSystemStructureDiagnosticInput, type RelativeValueDiagnosticInput, type ResolvedBlueprintWidgetNode, type ResolvedBlueprintWidgetNodeFor, type ResolvedBlueprintWidgetNodeView, type ResolvedBlueprintWidgetNodeViewFor, type RuntimeDependencyTargetFailedDiagnostic, type RuntimeDependencyValueRejectedDiagnostic, type RuntimeDiagnostic, type RuntimeDiagnosticLocation, type RuntimeEvent, type RuntimeEventSurface, type RuntimeLevelDiagnostic, type RuntimeLevelDiagnosticLocation, type RuntimeMethod, type RuntimeMethodArgsDiagnostic, type RuntimeMethodDependencyDiagnostic, type RuntimeMethodDiagnostic, type RuntimeMethodResultDiagnostic, type RuntimeMethodSurface, type RuntimeProperty, type RuntimePropertyDependencyDiagnostic, type RuntimePropertyDiagnostic, type RuntimePropertyResultDiagnostic, type RuntimePropertySurface, type RuntimeState, type RuntimeStateDiagnostic, type RuntimeStateSurface, type RuntimeWidget, type RuntimeWidgetDiagnostic, type RuntimeWidgetFor, type SelfBlueprintWidgetNode, type SelfBlueprintWidgetNodeView, type SelfDependencyTarget, type SelfMethodDependencyOperations, type SelfPropertyDependencyOperations, type SelfStateDependencyOperations, type SeparatedSourceLocation, type SeparatedWidgetData, type SeparatedWidgetSource, type SeparatedWidgetSourceDiagnostic, type SeparatedWidgetSourceDiagnosticCode, type SeparatedWidgetSourceNormalization, type SeparatedWidgetStructure, type SourceAccessDiagnostic, type SourcePatch, type SourcePatchOperation, type SourcePatchOperationFailure, type SourcePatchOperationFailureCode, type SourcePath, type StateGetDepExpression, type StateSetDepExpression, type ToExecutedDep, type ToExecutedDeps, type UnknownTargetDependencyOperations, type UnknownTargetStateDependencyOperations, type UnresolvedBlueprintWidgetNode, type ValidBlueprintView, type ValidWidgetSystemBlueprint, WIDGET_CONFIG_JSON_SCHEMA_DIALECT, type WidgetCapabilityOf, type WidgetCatalog, type WidgetCatalogEntry, type WidgetConfigDefinition, type WidgetConfigJsonSchema, type WidgetConfigValidateContext, type WidgetDocument, type WidgetDocumentSnapshot, type WidgetEventArgsOf, type WidgetEventDefinition, type WidgetEventEmitter, type WidgetEventEmitterContext, type WidgetEventKeyOf, type WidgetEventsOf, type WidgetEventsSection, type WidgetId, type WidgetInterfaces, type WidgetInterfacesOf, type WidgetInterfacesViolation, type WidgetInterfacesViolationOf, type WidgetLocation, type WidgetLocationView, type WidgetMemberKey, type WidgetMemberKeysOf, type WidgetMemberValueOf, type WidgetMethodArgsOf, type WidgetMethodDefinition, type WidgetMethodExecuteContext, type WidgetMethodKeyOf, type WidgetMethodOf, type WidgetMethodReturnOf, type WidgetMethodValidateArgsContext, type WidgetMethodsOf, type WidgetMethodsSection, type WidgetPlugin, type WidgetPluginCapabilities, type WidgetPluginConfigMetadata, type WidgetPluginConfigPhase, type WidgetPluginDescriptionPhase, type WidgetPluginDonePhase, type WidgetPluginEventsPhase, type WidgetPluginInterfacesPhase, type WidgetPluginMethodsPhase, type WidgetPluginOf, type WidgetPluginPhaseOrderViolation, type WidgetPluginPropertiesPhase, type WidgetPluginSlotsPhase, type WidgetPluginStatePhase, type WidgetPluginTypeOf, type WidgetPluginValidateStructure, type WidgetPluginValidateStructureContext, type WidgetPropertiesOf, type WidgetPropertiesSection, type WidgetPropertyComputeContext, type WidgetPropertyDefinition, type WidgetPropertyKeyOf, type WidgetPropertyValueOf, type WidgetRawConfigOf, type WidgetRegisterDepsContext, type WidgetResolvedConfigContext, type WidgetResolvedConfigOf, type WidgetSlotDefinition, type WidgetSlotDefinitions, type WidgetSlotNameOf, type WidgetSlotValidateStructureContext, type WidgetSource, type WidgetSourceFor, type WidgetStateDefaultContext, type WidgetStateKeyOf, type WidgetStateMemberDefinition, type WidgetStateOf, type WidgetStateSection, type WidgetStateValidateContext, type WidgetStateValueOf, type WidgetSystem, type WidgetSystemBlueprint, type WidgetSystemBlueprintStatus, WidgetSystemConfigurationError, type WidgetSystemConfigurationErrorCode, type WidgetSystemRuntime, type WidgetSystemRuntimeDiagnostic, WidgetSystemRuntimeDisposedError, type WidgetSystemValidateStructure, type WidgetSystemValidateStructureContext, type WidgetValueContract, createWidgetDocument, createWidgetPlugin, createWidgetSystem, createWidgetValueContract, normalizeSeparatedWidgetSource, separateWidgetSource };
|
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
|
|
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,7 +168,7 @@ function inspectJsonValue(value) {
|
|
|
167
168
|
function isJsonValue(value) {
|
|
168
169
|
return inspectJsonValue(value).compatible;
|
|
169
170
|
}
|
|
170
|
-
/** JSON-domain equality used by RFC6902 `test`
|
|
171
|
+
/** JSON-domain equality used by the RFC6902 `test` operation. (SourcePatch no-op detection uses `structurallyEqual` in `source-patch.ts`.) */
|
|
171
172
|
function jsonEqual(left, right, seen = /* @__PURE__ */ new Set()) {
|
|
172
173
|
if (Object.is(left, right)) return true;
|
|
173
174
|
if (typeof left !== "object" || left === null || typeof right !== "object" || right === null) return false;
|
|
@@ -745,6 +746,15 @@ function applySourcePatch(source, patch) {
|
|
|
745
746
|
}
|
|
746
747
|
//#endregion
|
|
747
748
|
//#region src/document.ts
|
|
749
|
+
/**
|
|
750
|
+
* Creates a revisioned source + Blueprint coordinator.
|
|
751
|
+
*
|
|
752
|
+
* Ownership: `options.source` is retained by reference as revision 0's `blueprint.source`, and Core
|
|
753
|
+
* never mutates it. Handing it over transfers ownership, so it must not be mutated afterwards. Patches
|
|
754
|
+
* are copy-on-write: each new revision shares untouched subtrees with the previous one, so any revision
|
|
755
|
+
* can share structure with this original input, and mutating the input corrupts later revisions too.
|
|
756
|
+
* A host that keeps its own editable model should pass a copy (for example `structuredClone`).
|
|
757
|
+
*/
|
|
748
758
|
function createWidgetDocument(options) {
|
|
749
759
|
let blueprint = options.system.createBlueprint(options.source);
|
|
750
760
|
let snapshot = Object.freeze({
|
|
@@ -2218,10 +2228,13 @@ function createWidgetSystemRuntime(blueprint, options) {
|
|
|
2218
2228
|
}
|
|
2219
2229
|
}
|
|
2220
2230
|
const runtimeWidgetsByNodeId = /* @__PURE__ */ new Map();
|
|
2231
|
+
const nodeIdByRuntimeWidget = /* @__PURE__ */ new Map();
|
|
2221
2232
|
for (const [nodeId, entry] of registry) {
|
|
2222
2233
|
const node = compiled.nodes[nodeId];
|
|
2223
2234
|
if (node === void 0 || !node.resolved) continue;
|
|
2224
|
-
|
|
2235
|
+
const runtimeWidget = buildRuntimeWidget(context, node, entry);
|
|
2236
|
+
runtimeWidgetsByNodeId.set(nodeId, runtimeWidget);
|
|
2237
|
+
nodeIdByRuntimeWidget.set(runtimeWidget, nodeId);
|
|
2225
2238
|
}
|
|
2226
2239
|
const aggregate = createRuntimeAggregate(context, compiled, registry, overrideResolution.runtimeLevelDiagnostics);
|
|
2227
2240
|
function getWidget(id) {
|
|
@@ -2244,7 +2257,9 @@ function createWidgetSystemRuntime(blueprint, options) {
|
|
|
2244
2257
|
};
|
|
2245
2258
|
runtime[runtimeInternals] = {
|
|
2246
2259
|
context,
|
|
2247
|
-
registry
|
|
2260
|
+
registry,
|
|
2261
|
+
compiled,
|
|
2262
|
+
nodeIdByRuntimeWidget
|
|
2248
2263
|
};
|
|
2249
2264
|
return runtime;
|
|
2250
2265
|
}
|
|
@@ -3591,13 +3606,52 @@ function attachInternalsAndFreeze(blueprint, compiled) {
|
|
|
3591
3606
|
//#endregion
|
|
3592
3607
|
//#region src/system.ts
|
|
3593
3608
|
/**
|
|
3609
|
+
* Thrown by `createWidgetSystem` for an invalid plugin registration. Discriminate by class and `code`;
|
|
3610
|
+
* `message` is not protocol.
|
|
3611
|
+
*
|
|
3612
|
+
* - `foreign-plugin`: the entry at `pluginIndex` was not completed by this loaded module instance
|
|
3613
|
+
* (another module instance or a structural look-alike). `pluginType` is its `type` when a string,
|
|
3614
|
+
* else `null`. `firstPluginIndex` is `null`.
|
|
3615
|
+
* - `duplicate-plugin-type`: the entry at `pluginIndex` repeats `pluginType`, first registered at
|
|
3616
|
+
* `firstPluginIndex`.
|
|
3617
|
+
*/
|
|
3618
|
+
var WidgetSystemConfigurationError = class extends Error {
|
|
3619
|
+
code;
|
|
3620
|
+
pluginIndex;
|
|
3621
|
+
pluginType;
|
|
3622
|
+
firstPluginIndex;
|
|
3623
|
+
name = "WidgetSystemConfigurationError";
|
|
3624
|
+
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}).`) {
|
|
3625
|
+
super(message);
|
|
3626
|
+
this.code = code;
|
|
3627
|
+
this.pluginIndex = pluginIndex;
|
|
3628
|
+
this.pluginType = pluginType;
|
|
3629
|
+
this.firstPluginIndex = firstPluginIndex;
|
|
3630
|
+
}
|
|
3631
|
+
};
|
|
3632
|
+
/**
|
|
3633
|
+
* Best-effort read of a foreign entry's `type`; a throwing accessor must not leak as an uncoded failure.
|
|
3634
|
+
*/
|
|
3635
|
+
function readForeignPluginType(entry) {
|
|
3636
|
+
try {
|
|
3637
|
+
const type = entry?.type;
|
|
3638
|
+
return typeof type === "string" ? type : null;
|
|
3639
|
+
} catch {
|
|
3640
|
+
return null;
|
|
3641
|
+
}
|
|
3642
|
+
}
|
|
3643
|
+
/**
|
|
3594
3644
|
* Creates an instance-scoped, immutable widget system. Duplicate `plugin.type` is rejected.
|
|
3595
3645
|
*/
|
|
3596
3646
|
function createWidgetSystem(options) {
|
|
3597
3647
|
const plugins = Object.freeze([...options.plugins]);
|
|
3598
3648
|
const pluginsByType = /* @__PURE__ */ new Map();
|
|
3599
|
-
|
|
3600
|
-
|
|
3649
|
+
const firstIndexByType = /* @__PURE__ */ new Map();
|
|
3650
|
+
for (const [index, plugin] of plugins.entries()) {
|
|
3651
|
+
if (!isCoreWidgetPlugin(plugin)) throw new WidgetSystemConfigurationError("foreign-plugin", index, readForeignPluginType(plugin));
|
|
3652
|
+
const firstIndex = firstIndexByType.get(plugin.type);
|
|
3653
|
+
if (firstIndex !== void 0) throw new WidgetSystemConfigurationError("duplicate-plugin-type", index, plugin.type, firstIndex);
|
|
3654
|
+
firstIndexByType.set(plugin.type, index);
|
|
3601
3655
|
pluginsByType.set(plugin.type, plugin);
|
|
3602
3656
|
}
|
|
3603
3657
|
const catalog = Object.freeze({ widgets: Object.freeze(plugins.map((plugin) => Object.freeze({
|
|
@@ -3623,4 +3677,4 @@ function createWidgetSystem(options) {
|
|
|
3623
3677
|
return Object.freeze(system);
|
|
3624
3678
|
}
|
|
3625
3679
|
//#endregion
|
|
3626
|
-
export { EMPTY_DIAGNOSTICS, WIDGET_CONFIG_JSON_SCHEMA_DIALECT, WidgetSystemRuntimeDisposedError, createWidgetDocument, createWidgetPlugin, createWidgetSystem, createWidgetValueContract, normalizeSeparatedWidgetSource, separateWidgetSource };
|
|
3680
|
+
export { EMPTY_DIAGNOSTICS, WIDGET_CONFIG_JSON_SCHEMA_DIALECT, WidgetSystemConfigurationError, WidgetSystemRuntimeDisposedError, createWidgetDocument, createWidgetPlugin, createWidgetSystem, createWidgetValueContract, normalizeSeparatedWidgetSource, separateWidgetSource };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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 {
|
|
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,
|
|
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 {
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const nodeId =
|
|
17
|
-
if (nodeId === void 0) throw new
|
|
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 =
|
|
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/
|
|
170
|
-
const
|
|
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
|
-
*
|
|
184
|
+
* Provenance probe: true only for Runtimes produced by this loaded module instance.
|
|
177
185
|
*/
|
|
178
|
-
function
|
|
179
|
-
|
|
180
|
-
|
|
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 {
|
|
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