@deviltea/widget-core 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
- import { a as isCompiledDependency, i as compiledDependencyBrand, n as runtimeInternals, o as readCompiledBlueprint, r as blueprintInternals } from "./internals-DXFEmv8H.mjs";
2
- import { computed, effect, endBatch, setActiveSub, signal, startBatch } from "alien-signals";
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";
3
+ import { computed, endBatch, signal, startBatch } from "alien-signals";
3
4
  //#region src/diagnostic.ts
4
5
  const EMPTY_DIAGNOSTICS = Object.freeze([]);
5
6
  var WidgetSystemRuntimeDisposedError = class extends Error {
@@ -10,144 +11,6 @@ var WidgetSystemRuntimeDisposedError = class extends Error {
10
11
  }
11
12
  };
12
13
  //#endregion
13
- //#region src/runtime/adapter.ts
14
- /**
15
- * Invokes `listener(value)` with no active alien subscriber (restoring the previous one afterward) and
16
- * isolates a synchronous throw so it cannot escape into the current alien-signals flush. Baseline
17
- * reporting for an isolated exception is a queued microtask rethrow.
18
- */
19
- function invokeListenerIsolated(listener, value) {
20
- const previous = setActiveSub(void 0);
21
- try {
22
- listener(value);
23
- } catch (error) {
24
- queueMicrotask(() => {
25
- throw error;
26
- });
27
- } finally {
28
- setActiveSub(previous);
29
- }
30
- }
31
- /**
32
- * Nesting depth of the calls that can drive an `alien-signals` evaluation/flush and therefore have to be
33
- * back out of the reactive graph before a deferred propagation is safe to release: `RuntimeState`'s
34
- * `attemptSet`, `RuntimeMethod`'s `invoke` and the tracked read of a Property's result computed. Purely
35
- * local bookkeeping for {@link writeDeferringFlush}, not a semantic boundary of its own.
36
- */
37
- let operationDepth = 0;
38
- /** Number of `startBatch()` calls {@link writeDeferringFlush} has opened and not yet closed. */
39
- let deferredFlushDepth = 0;
40
- /**
41
- * Closes every batch level {@link writeDeferringFlush} left open, letting alien-signals flush the
42
- * notifications it already queued.
43
- *
44
- * The loop condition is re-tested after every `endBatch()`: that flush can run an effect whose Property
45
- * recompute commits its own diagnostic snapshot, which opens a fresh level this same drain must then close.
46
- * A recompute that throws inside one of those flushes must not leave alien-signals permanently batched
47
- * (every later flush in the Runtime's life would be silently suspended), so the remaining levels are
48
- * closed before the throw is rethrown.
49
- */
50
- function releaseDeferredFlushes() {
51
- while (deferredFlushDepth > 0) {
52
- --deferredFlushDepth;
53
- try {
54
- endBatch();
55
- } catch (error) {
56
- releaseDeferredFlushes();
57
- throw error;
58
- }
59
- }
60
- }
61
- /**
62
- * Tracks one nesting level of the calls that can drive an evaluation, and releases every flush
63
- * {@link writeDeferringFlush} deferred inside it once the outermost level is leaving.
64
- *
65
- * The release runs while the depth is still `1`, so a listener that the release's own flush invokes and
66
- * that re-enters the Runtime cannot re-enter the drain loop. The decrement is unconditional: a Property
67
- * recompute that throws inside the release's flush (`createTrackedSubscription` isolates the external
68
- * listener, never the tracked read) must not leave the depth pinned above `0`, or every later call would
69
- * look nested and no release would ever run again.
70
- */
71
- function runRuntimeOperation(fn) {
72
- ++operationDepth;
73
- try {
74
- return fn();
75
- } finally {
76
- try {
77
- if (operationDepth === 1) releaseDeferredFlushes();
78
- } finally {
79
- --operationDepth;
80
- }
81
- }
82
- }
83
- /**
84
- * Performs a signal write whose propagation must not be flushed while a computed may still be
85
- * mid-evaluation, by holding an alien batch open until the outermost {@link runRuntimeOperation} frame on
86
- * the stack is leaving — i.e. until nothing that could still be evaluating remains.
87
- *
88
- * Why this is required in pinned alien-signals@3.2.1 (`esm/index.mjs` / `esm/system.mjs`):
89
- *
90
- * - `signalOper` ends a changed write with `propagate(subs, ...)` followed by `if (!batchDepth) flush()`.
91
- * A write performed from inside a computed's own evaluator therefore starts a *nested* flush that runs
92
- * the effects the outer propagation had already queued — while the computed that queued them is still
93
- * mid-`updateComputed`.
94
- * - `updateComputed` sets `c.flags = 1 | 4` (`Mutable | RecursedCheck`) and only assigns
95
- * `c.value = c.getter(...)` after the getter returns, so during that window the computed carries
96
- * neither `Dirty` (16) nor `Pending` (32) and still holds its previous value.
97
- * - `checkDirty` has no `RecursedCheck` branch: a queued effect whose dependency chain passes through
98
- * that computed hits none of its `(1 | 16)` / `(1 | 32)` cases, concludes `dirty === false`, and then
99
- * clears its own intermediate's `Pending` flag (`sub.flags &= ~32`). The intermediate is now marked
100
- * clean while still holding a stale cached value, so the later `shallowPropagate` — which only
101
- * upgrades subscribers that are still `Pending` — skips it for good: the effect never runs again and
102
- * even an untracked `.get()` returns the stale cache.
103
- *
104
- * Keeping `batchDepth > 0` for the write removes the nested flush entirely: `propagate` still marks and
105
- * queues every watcher through alien-signals' own bookkeeping, and the queue is drained later — by the
106
- * flush that is already running (it re-reads the shared queue length) or by
107
- * {@link runRuntimeOperation}'s release. Nothing here re-implements propagation, ordering or dedupe.
108
- *
109
- * The write itself is unconditional and immediate, so a snapshot is committed exactly where it was
110
- * before: `pendingValue` is written synchronously and every later read commits it (`signalOper`'s read
111
- * path runs `updateSignal` when the signal is `Dirty`), which keeps "the snapshot is committed by the
112
- * time the operation's `ExecutionResult` is observable" true. Only the *notification* moves — never past
113
- * the end of the operation that produced it.
114
- *
115
- * One consequence of using an alien batch as the deferral mechanism, rather than a normative rule about
116
- * Runtime operations: while a level is open, alien-signals coalesces as it does inside any batch, so two
117
- * writes to the *same* signal before the release notify its subscribers once, with the final value. This
118
- * is not a new Runtime semantic — it is the ordinary behavior of the batching alien-signals already owns,
119
- * already observable inside `RuntimeMethod.invoke`'s batch. Every actual completed recompute still
120
- * notifies each of its own subscribers exactly once; alien-signals, not this module, decides which
121
- * recomputes happen.
122
- */
123
- function writeDeferringFlush(write) {
124
- if (operationDepth === 0) {
125
- write();
126
- return;
127
- }
128
- startBatch();
129
- ++deferredFlushDepth;
130
- write();
131
- }
132
- /**
133
- * Creates a Runtime-owned public subscription: an alien `effect()` that tracks `read()`, skips the
134
- * bootstrap run, and invokes `listener` through {@link invokeListenerIsolated} on every actual
135
- * subsequent run. Returns an idempotent unsubscribe function registered with the Runtime's disposal
136
- * bookkeeping.
137
- */
138
- function createTrackedSubscription(context, read, listener) {
139
- let isBootstrap = true;
140
- const rawDispose = effect(() => {
141
- const value = read();
142
- if (isBootstrap) {
143
- isBootstrap = false;
144
- return;
145
- }
146
- invokeListenerIsolated(listener, value);
147
- });
148
- return context.registerSubscription(rawDispose);
149
- }
150
- //#endregion
151
14
  //#region src/json.ts
152
15
  function jsonDiagnostic(path, reason) {
153
16
  return {
@@ -956,149 +819,6 @@ function createWidgetDocument(options) {
956
819
  });
957
820
  }
958
821
  //#endregion
959
- //#region src/readonly-map.ts
960
- /** Creates a map-shaped, runtime immutable projection without exposing mutating Map methods. */
961
- function createReadonlyMap(entries) {
962
- const map = new Map(entries);
963
- const result = {
964
- get size() {
965
- return map.size;
966
- },
967
- get(key) {
968
- return map.get(key);
969
- },
970
- has(key) {
971
- return map.has(key);
972
- },
973
- keys() {
974
- return map.keys();
975
- },
976
- values() {
977
- return map.values();
978
- },
979
- entries() {
980
- return map.entries();
981
- },
982
- forEach(callbackfn, thisArg) {
983
- map.forEach((value, key) => callbackfn.call(thisArg, value, key, result));
984
- },
985
- [Symbol.iterator]() {
986
- return map[Symbol.iterator]();
987
- }
988
- };
989
- return Object.freeze(result);
990
- }
991
- //#endregion
992
- //#region src/plugin.ts
993
- /**
994
- * Framework-private brand carrying the plugin's phantom interfaces and its erased definition record.
995
- */
996
- const widgetPluginBrand = Symbol("@deviltea/widget-core:widget-plugin");
997
- /**
998
- * Reads the erased definition record of a plugin.
999
- */
1000
- function readWidgetPluginDefinition(plugin) {
1001
- return plugin[widgetPluginBrand].definition;
1002
- }
1003
- /**
1004
- * Builds the section keyed-chain object.
1005
- *
1006
- * Declared member keys exist only at the type level, so every string member access resolves to a
1007
- * consuming function; the returned chain object is the same object by identity.
1008
- */
1009
- function createSection(sink) {
1010
- const section = new Proxy({}, { get(_target, key) {
1011
- if (typeof key !== "string") return void 0;
1012
- return (definition) => {
1013
- sink.set(key, definition);
1014
- return section;
1015
- };
1016
- } });
1017
- return section;
1018
- }
1019
- /**
1020
- * Starts the plugin builder for one plugin `type`.
1021
- *
1022
- * Phase order is `interfaces -> config? -> slots? -> state? -> properties? -> methods? -> done()`;
1023
- * a phase exists only when its capability is declared.
1024
- */
1025
- function createWidgetPlugin(type) {
1026
- const draft = {
1027
- description: "",
1028
- config: null,
1029
- slots: null,
1030
- validateStructure: null,
1031
- state: null,
1032
- properties: null,
1033
- methods: null
1034
- };
1035
- const builder = {
1036
- description(description) {
1037
- draft.description = description;
1038
- return builder;
1039
- },
1040
- interfaces: () => builder,
1041
- config(definition) {
1042
- draft.config = definition;
1043
- return builder;
1044
- },
1045
- slots(definitions, validateStructure) {
1046
- draft.slots = new Map(Object.entries(definitions));
1047
- draft.validateStructure = validateStructure ?? null;
1048
- return builder;
1049
- },
1050
- state(build) {
1051
- const members = /* @__PURE__ */ new Map();
1052
- draft.state = members;
1053
- build(createSection(members));
1054
- return builder;
1055
- },
1056
- properties(build) {
1057
- const members = /* @__PURE__ */ new Map();
1058
- draft.properties = members;
1059
- build(createSection(members));
1060
- return builder;
1061
- },
1062
- methods(build) {
1063
- const members = /* @__PURE__ */ new Map();
1064
- draft.methods = members;
1065
- build(createSection(members));
1066
- return builder;
1067
- },
1068
- done() {
1069
- const definition = Object.freeze({
1070
- type,
1071
- description: draft.description,
1072
- config: draft.config,
1073
- slots: draft.slots,
1074
- validateStructure: draft.validateStructure,
1075
- state: draft.state,
1076
- properties: draft.properties,
1077
- methods: draft.methods
1078
- });
1079
- const capabilities = Object.freeze({
1080
- config: definition.config !== null,
1081
- slots: definition.slots !== null,
1082
- state: definition.state !== null,
1083
- properties: definition.properties !== null,
1084
- methods: definition.methods !== null
1085
- });
1086
- const descriptions = Object.freeze({
1087
- config: definition.config?.description ?? null,
1088
- slots: definition.slots === null ? null : createReadonlyMap([...definition.slots].map(([key, slot]) => [key, slot.description]))
1089
- });
1090
- return Object.freeze({
1091
- type,
1092
- description: draft.description,
1093
- capabilities,
1094
- descriptions,
1095
- [widgetPluginBrand]: Object.freeze({ definition })
1096
- });
1097
- }
1098
- };
1099
- return builder;
1100
- }
1101
- //#endregion
1102
822
  //#region src/separated-source.ts
1103
823
  function readDataProperty(value, key) {
1104
824
  try {
@@ -1390,45 +1110,47 @@ function normalizeSeparatedWidgetSource(input) {
1390
1110
  area: "structure",
1391
1111
  path: diagnosticPath(path, "slots")
1392
1112
  }, "structure slots could not be inspected safely.", { reason: "invalid-slots" });
1393
- else if (slotsProperty.found && slotsProperty.accessible) if (!isPlainObject(slotsProperty.value)) {
1394
- output.slots = copyRecoveryValue(slotsProperty.value);
1395
- addDiagnostic("invalid-separated-structure", {
1396
- area: "structure",
1397
- path: diagnosticPath(path, "slots")
1398
- }, "structure slots must be an object.", { reason: "invalid-slots" });
1399
- } else {
1400
- const outputSlots = Object.create(null);
1401
- const slots = ownStringKeys(slotsProperty.value);
1402
- if (slots === null) addDiagnostic("invalid-separated-structure", {
1403
- area: "structure",
1404
- path: diagnosticPath(path, "slots")
1405
- }, "structure slots could not be inspected safely.", { reason: "invalid-slots" });
1406
- else {
1407
- for (const slot of slots) {
1408
- const slotProperty = readDataProperty(slotsProperty.value, slot);
1409
- const slotPath = diagnosticPath(diagnosticPath(path, "slots"), slot);
1410
- const slotArray = readArrayInfo$1(slotProperty.value);
1411
- if (!slotProperty.found || !slotProperty.accessible || !slotArray.isArray || !slotArray.accessible) {
1412
- if (slotProperty.found && slotProperty.accessible) outputSlots[slot] = copyRecoveryValue(slotProperty.value);
1413
- addDiagnostic("invalid-separated-structure", {
1414
- area: "structure",
1415
- path: slotPath
1416
- }, "structure slot must be an Array.", { reason: "invalid-slot-children" });
1417
- continue;
1418
- }
1419
- const children = [];
1420
- const childArray = slotProperty.value;
1421
- for (let index = 0; index < slotArray.length; index++) {
1422
- const childProperty = readDataProperty(childArray, String(index));
1423
- children.push(childProperty.found && childProperty.accessible ? normalizeNode(childProperty.value, [...slotPath, index]) : void 0);
1424
- if (!childProperty.found || !childProperty.accessible) addDiagnostic("invalid-separated-structure", {
1425
- area: "structure",
1426
- path: [...slotPath, index]
1427
- }, "structure child could not be inspected safely.", { reason: "invalid-slot-children" });
1113
+ else if (slotsProperty.found && slotsProperty.accessible) {
1114
+ if (!isPlainObject(slotsProperty.value)) {
1115
+ output.slots = copyRecoveryValue(slotsProperty.value);
1116
+ addDiagnostic("invalid-separated-structure", {
1117
+ area: "structure",
1118
+ path: diagnosticPath(path, "slots")
1119
+ }, "structure slots must be an object.", { reason: "invalid-slots" });
1120
+ } else {
1121
+ const outputSlots = Object.create(null);
1122
+ const slots = ownStringKeys(slotsProperty.value);
1123
+ if (slots === null) addDiagnostic("invalid-separated-structure", {
1124
+ area: "structure",
1125
+ path: diagnosticPath(path, "slots")
1126
+ }, "structure slots could not be inspected safely.", { reason: "invalid-slots" });
1127
+ else {
1128
+ for (const slot of slots) {
1129
+ const slotProperty = readDataProperty(slotsProperty.value, slot);
1130
+ const slotPath = diagnosticPath(diagnosticPath(path, "slots"), slot);
1131
+ const slotArray = readArrayInfo$1(slotProperty.value);
1132
+ if (!slotProperty.found || !slotProperty.accessible || !slotArray.isArray || !slotArray.accessible) {
1133
+ if (slotProperty.found && slotProperty.accessible) outputSlots[slot] = copyRecoveryValue(slotProperty.value);
1134
+ addDiagnostic("invalid-separated-structure", {
1135
+ area: "structure",
1136
+ path: slotPath
1137
+ }, "structure slot must be an Array.", { reason: "invalid-slot-children" });
1138
+ continue;
1139
+ }
1140
+ const children = [];
1141
+ const childArray = slotProperty.value;
1142
+ for (let index = 0; index < slotArray.length; index++) {
1143
+ const childProperty = readDataProperty(childArray, String(index));
1144
+ children.push(childProperty.found && childProperty.accessible ? normalizeNode(childProperty.value, [...slotPath, index]) : void 0);
1145
+ if (!childProperty.found || !childProperty.accessible) addDiagnostic("invalid-separated-structure", {
1146
+ area: "structure",
1147
+ path: [...slotPath, index]
1148
+ }, "structure child could not be inspected safely.", { reason: "invalid-slot-children" });
1149
+ }
1150
+ outputSlots[slot] = children;
1428
1151
  }
1429
- outputSlots[slot] = children;
1152
+ output.slots = outputSlots;
1430
1153
  }
1431
- output.slots = outputSlots;
1432
1154
  }
1433
1155
  }
1434
1156
  return output;
@@ -2066,6 +1788,7 @@ function createMethodPrimitive(context, params) {
2066
1788
  widget: params.selfNode,
2067
1789
  blueprint: params.blueprintView,
2068
1790
  deps: params.deps,
1791
+ ...params.emitFragment,
2069
1792
  ...params.buildConfigFragment(),
2070
1793
  addDiagnostic: execCollector.addDiagnostic,
2071
1794
  hasAnyDiagnostic: execCollector.hasAnyDiagnostic
@@ -2380,6 +2103,11 @@ function buildRuntimeWidget(context, node, entry) {
2380
2103
  for (const [name, primitive] of entry.methods) methodsSurface[name] = primitive.public;
2381
2104
  widget.methods = Object.freeze(methodsSurface);
2382
2105
  }
2106
+ if (definition.events !== null) {
2107
+ const eventsSurface = Object.create(null);
2108
+ for (const [name, primitive] of entry.events) eventsSurface[name] = primitive.public;
2109
+ widget.events = Object.freeze(eventsSurface);
2110
+ }
2383
2111
  return Object.freeze(widget);
2384
2112
  }
2385
2113
  //#endregion
@@ -2399,9 +2127,12 @@ function createWidgetSystemRuntime(blueprint, options) {
2399
2127
  const entry = {
2400
2128
  state: /* @__PURE__ */ new Map(),
2401
2129
  properties: /* @__PURE__ */ new Map(),
2402
- methods: /* @__PURE__ */ new Map()
2130
+ methods: /* @__PURE__ */ new Map(),
2131
+ events: /* @__PURE__ */ new Map()
2403
2132
  };
2404
2133
  registry.set(nodeId, entry);
2134
+ const definition = readWidgetPluginDefinition(node.plugin);
2135
+ if (definition.events !== null) for (const name of definition.events.keys()) entry.events.set(name, createEventPrimitive(context));
2405
2136
  const buildConfigFragment = buildConfigFragmentFor(node);
2406
2137
  for (const [key, member] of node.state) {
2407
2138
  const primitive = createStatePrimitive(context, {
@@ -2443,6 +2174,7 @@ function createWidgetSystemRuntime(blueprint, options) {
2443
2174
  const entry = registry.get(nodeId);
2444
2175
  if (entry === void 0) continue;
2445
2176
  const buildConfigFragment = buildConfigFragmentFor(node);
2177
+ const emitFragment = readWidgetPluginDefinition(node.plugin).events === null ? Object.freeze({}) : Object.freeze({ emit: buildEventEmitter(entry.events) });
2446
2178
  for (const [name, member] of node.properties) {
2447
2179
  const deps = materializeDependencyTree(member.deps, {
2448
2180
  consumer: "property",
@@ -2479,7 +2211,8 @@ function createWidgetSystemRuntime(blueprint, options) {
2479
2211
  buildConfigFragment,
2480
2212
  selfNode: node.publicNode,
2481
2213
  blueprintView,
2482
- deps
2214
+ deps,
2215
+ emitFragment
2483
2216
  });
2484
2217
  entry.methods.set(name, primitive);
2485
2218
  }
@@ -3222,45 +2955,46 @@ function buildNode(ctx, rawValue, parentNodeId, parentPublicNode, placement) {
3222
2955
  if (resolved && plugin !== null) {
3223
2956
  const definition = readWidgetPluginDefinition(plugin);
3224
2957
  const configProperty = readOwnDataProperty(raw, "config");
3225
- if (definition.config !== null) if (!configProperty.found) {
3226
- const resolved = definition.config.resolve(null);
3227
- assertSyncValue(resolved, "config.resolve");
3228
- working.rawConfig = null;
3229
- working.config = resolved;
3230
- } else if (!configProperty.accessible) {
3231
- localDiagnostics.push(configDiagnostic(publicNode, "Widget config could not be inspected safely."));
3232
- const resolved = definition.config.resolve(null);
3233
- assertSyncValue(resolved, "config.resolve");
3234
- working.rawConfig = null;
3235
- working.config = resolved;
3236
- } else {
3237
- const rawConfigValue = configProperty.value;
3238
- const { collector, items } = createCollector();
3239
- let ok = false;
3240
- try {
3241
- const rawValidateResult = definition.config.validate(rawConfigValue, collector);
3242
- assertSyncValue(rawValidateResult, "config.validate");
3243
- ok = rawValidateResult;
3244
- } catch (error) {
3245
- finalizeShell(shell, working);
3246
- flushDiagnostics(ctx, localDiagnostics);
3247
- throw error;
3248
- }
3249
- if (ok && items.length === 0) {
3250
- const resolved = definition.config.resolve(rawConfigValue);
2958
+ if (definition.config !== null) {
2959
+ if (!configProperty.found) {
2960
+ const resolved = definition.config.resolve(null);
3251
2961
  assertSyncValue(resolved, "config.resolve");
3252
- working.rawConfig = rawConfigValue;
2962
+ working.rawConfig = null;
3253
2963
  working.config = resolved;
3254
- } else {
3255
- if (items.length === 0) items.push({ message: "Invalid config." });
3256
- for (const item of items) localDiagnostics.push(configDiagnostic(publicNode, item.message, item.path, item.reason));
2964
+ } else if (!configProperty.accessible) {
2965
+ localDiagnostics.push(configDiagnostic(publicNode, "Widget config could not be inspected safely."));
3257
2966
  const resolved = definition.config.resolve(null);
3258
2967
  assertSyncValue(resolved, "config.resolve");
3259
2968
  working.rawConfig = null;
3260
2969
  working.config = resolved;
2970
+ } else {
2971
+ const rawConfigValue = configProperty.value;
2972
+ const { collector, items } = createCollector();
2973
+ let ok = false;
2974
+ try {
2975
+ const rawValidateResult = definition.config.validate(rawConfigValue, collector);
2976
+ assertSyncValue(rawValidateResult, "config.validate");
2977
+ ok = rawValidateResult;
2978
+ } catch (error) {
2979
+ finalizeShell(shell, working);
2980
+ flushDiagnostics(ctx, localDiagnostics);
2981
+ throw error;
2982
+ }
2983
+ if (ok && items.length === 0) {
2984
+ const resolved = definition.config.resolve(rawConfigValue);
2985
+ assertSyncValue(resolved, "config.resolve");
2986
+ working.rawConfig = rawConfigValue;
2987
+ working.config = resolved;
2988
+ } else {
2989
+ if (items.length === 0) items.push({ message: "Invalid config." });
2990
+ for (const item of items) localDiagnostics.push(configDiagnostic(publicNode, item.message, item.path, item.reason));
2991
+ const resolved = definition.config.resolve(null);
2992
+ assertSyncValue(resolved, "config.resolve");
2993
+ working.rawConfig = null;
2994
+ working.config = resolved;
2995
+ }
3261
2996
  }
3262
- }
3263
- else if (configProperty.found) localDiagnostics.push(definitionDiagnostic(publicNode, "Widget declares \"config\" but its plugin has no config capability.", ["config"]));
2997
+ } else if (configProperty.found) localDiagnostics.push(definitionDiagnostic(publicNode, "Widget declares \"config\" but its plugin has no config capability.", ["config"]));
3264
2998
  }
3265
2999
  if (resolved && plugin !== null) {
3266
3000
  const definition = readWidgetPluginDefinition(plugin);
@@ -3869,6 +3603,7 @@ function createWidgetSystem(options) {
3869
3603
  const catalog = Object.freeze({ widgets: Object.freeze(plugins.map((plugin) => Object.freeze({
3870
3604
  type: plugin.type,
3871
3605
  description: plugin.description,
3606
+ config: plugin.config,
3872
3607
  descriptions: Object.freeze({
3873
3608
  config: plugin.descriptions.config,
3874
3609
  slots: plugin.descriptions.slots === null ? null : createReadonlyMap(plugin.descriptions.slots)
@@ -3888,4 +3623,4 @@ function createWidgetSystem(options) {
3888
3623
  return Object.freeze(system);
3889
3624
  }
3890
3625
  //#endregion
3891
- export { EMPTY_DIAGNOSTICS, WidgetSystemRuntimeDisposedError, createWidgetDocument, createWidgetPlugin, createWidgetSystem, normalizeSeparatedWidgetSource, separateWidgetSource };
3626
+ export { EMPTY_DIAGNOSTICS, WIDGET_CONFIG_JSON_SCHEMA_DIALECT, WidgetSystemRuntimeDisposedError, createWidgetDocument, createWidgetPlugin, createWidgetSystem, createWidgetValueContract, normalizeSeparatedWidgetSource, separateWidgetSource };
@@ -1,4 +1,4 @@
1
- import { Bn as ExecutionResult, Jt as WidgetSystemRuntime, Kt as WidgetSystemBlueprint, T as BlueprintDependencyReference, Tt as ResolvedBlueprintWidgetNode, bt as BlueprintWidgetNode, in as AnyWidgetPluginTuple, lt as RuntimePropertyDiagnostic, qn as WidgetMemberKey, zt as UnresolvedBlueprintWidgetNode } from "../dep-DKQpJwdW.mjs";
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";
2
2
  //#region src/inspection/types.d.ts
3
3
  declare const inspectionNodeIdBrand: unique symbol;
4
4
  /**
@@ -11,12 +11,36 @@ declare const inspectionNodeIdBrand: unique symbol;
11
11
  type InspectionNodeId = number & {
12
12
  readonly [inspectionNodeIdBrand]: true;
13
13
  };
14
+ interface PluginInspectionStateMember {
15
+ readonly type: 'state';
16
+ readonly name: WidgetMemberKey;
17
+ readonly authorWritable: boolean;
18
+ }
19
+ interface PluginInspectionPropertyMember {
20
+ readonly type: 'property';
21
+ readonly name: WidgetMemberKey;
22
+ readonly valueContractId: string | null;
23
+ }
24
+ interface PluginInspectionEventMember {
25
+ readonly type: 'event';
26
+ readonly name: WidgetMemberKey;
27
+ readonly description: string;
28
+ }
29
+ interface PluginInspection {
30
+ /** Null means the State capability was not declared; an empty map means explicitly declared empty. */
31
+ readonly state: ReadonlyMap<WidgetMemberKey, PluginInspectionStateMember> | null;
32
+ /** Null means the Properties capability was not declared; an empty map means explicitly declared empty. */
33
+ readonly properties: ReadonlyMap<WidgetMemberKey, PluginInspectionPropertyMember> | null;
34
+ /** Null means the Events capability was not declared; an empty map means explicitly declared empty. */
35
+ readonly events: ReadonlyMap<WidgetMemberKey, PluginInspectionEventMember> | null;
36
+ }
14
37
  interface BlueprintInspectionCapabilities {
15
38
  readonly config: boolean;
16
39
  readonly slots: boolean;
17
40
  readonly state: boolean;
18
41
  readonly properties: boolean;
19
42
  readonly methods: boolean;
43
+ readonly events: boolean;
20
44
  }
21
45
  interface BlueprintInspectionSourceSlot {
22
46
  readonly name: string;
@@ -70,12 +94,19 @@ type BlueprintInspectionDependency = ResolvedBlueprintInspectionDependency | Abs
70
94
  interface BlueprintInspectionStateMember {
71
95
  readonly type: 'state';
72
96
  readonly name: WidgetMemberKey;
97
+ readonly authorWritable: boolean;
73
98
  }
74
99
  interface BlueprintInspectionPropertyMember {
75
100
  readonly type: 'property';
76
101
  readonly name: WidgetMemberKey;
102
+ readonly valueContractId: string | null;
77
103
  readonly dependencies: readonly BlueprintInspectionDependency[];
78
104
  }
105
+ interface BlueprintInspectionEventMember {
106
+ readonly type: 'event';
107
+ readonly name: WidgetMemberKey;
108
+ readonly description: string;
109
+ }
79
110
  interface BlueprintInspectionMethodMember {
80
111
  readonly type: 'method';
81
112
  readonly name: WidgetMemberKey;
@@ -102,10 +133,13 @@ interface ResolvedBlueprintInspectionNode<Plugins extends AnyWidgetPluginTuple =
102
133
  readonly node: ResolvedBlueprintWidgetNode<Plugins>;
103
134
  /** Authoritative capability presence (absent vs explicitly declared empty). */
104
135
  readonly capabilities: BlueprintInspectionCapabilities;
136
+ /** Passive config authoring metadata. Null means no config capability. */
137
+ readonly config: WidgetPluginConfigMetadata | null;
105
138
  readonly semanticSlots: readonly BlueprintInspectionSemanticSlot[];
106
139
  readonly state: readonly BlueprintInspectionStateMember[];
107
140
  readonly properties: readonly BlueprintInspectionPropertyMember[];
108
141
  readonly methods: readonly BlueprintInspectionMethodMember[];
142
+ readonly events: readonly BlueprintInspectionEventMember[];
109
143
  }
110
144
  type BlueprintInspectionNode<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> = UnresolvedBlueprintInspectionNode<Plugins> | ResolvedBlueprintInspectionNode<Plugins>;
111
145
  interface BlueprintInspectionEvaluationMemberRef {
@@ -149,6 +183,9 @@ type RuntimePropertyInspectionSnapshot<T> = {
149
183
  readonly result: ExecutionResult<T | null, RuntimePropertyDiagnostic>;
150
184
  };
151
185
  interface RuntimePropertyInspection<T> extends InspectionObservable<RuntimePropertyInspectionSnapshot<T>> {}
186
+ interface RuntimeEventInspection {
187
+ subscribe: (listener: (args: readonly unknown[]) => void) => () => void;
188
+ }
152
189
  interface RuntimeWidgetInspection<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> {
153
190
  readonly nodeId: InspectionNodeId;
154
191
  readonly blueprintNode: ResolvedBlueprintInspectionNode<Plugins>;
@@ -156,6 +193,8 @@ interface RuntimeWidgetInspection<Plugins extends AnyWidgetPluginTuple = AnyWidg
156
193
  getState: (key: WidgetMemberKey) => RuntimeStateInspection<unknown> | null;
157
194
  /** `null` when the property member/capability does not exist. Dynamic `unknown` typing. */
158
195
  getProperty: (name: WidgetMemberKey) => RuntimePropertyInspection<unknown> | null;
196
+ /** `null` when the event member/capability does not exist. Readonly occurrence observation only. */
197
+ getEvent: (name: WidgetMemberKey) => RuntimeEventInspection | null;
159
198
  }
160
199
  interface RuntimeInspection<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> {
161
200
  /** Identity-stable with `inspectBlueprint(runtime.blueprint)`. */
@@ -178,6 +217,12 @@ interface RuntimeInspection<Plugins extends AnyWidgetPluginTuple = AnyWidgetPlug
178
217
  */
179
218
  declare function inspectBlueprint<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple>(blueprint: WidgetSystemBlueprint<Plugins>): BlueprintInspection<Plugins>;
180
219
  //#endregion
220
+ //#region src/inspection/plugin.d.ts
221
+ /**
222
+ * Returns an identity-stable, readonly/passive projection for the exact completed Plugin object.
223
+ */
224
+ declare function inspectPlugin(plugin: AnyWidgetPlugin): PluginInspection;
225
+ //#endregion
181
226
  //#region src/inspection/runtime.d.ts
182
227
  /**
183
228
  * Returns the readonly Runtime inspection facade for `runtime`, cached (weak, no global strong
@@ -187,4 +232,4 @@ declare function inspectBlueprint<Plugins extends AnyWidgetPluginTuple = AnyWidg
187
232
  */
188
233
  declare function inspectRuntime<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple>(runtime: WidgetSystemRuntime<Plugins>): RuntimeInspection<Plugins>;
189
234
  //#endregion
190
- export { type AbsentBlueprintInspectionDependency, type BlueprintInspection, type BlueprintInspectionCapabilities, type BlueprintInspectionDependency, type BlueprintInspectionDependencyBase, type BlueprintInspectionEvaluationMemberRef, 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 ResolvedBlueprintInspectionDependency, type ResolvedBlueprintInspectionNode, type RuntimeInspection, type RuntimePropertyInspection, type RuntimePropertyInspectionSnapshot, type RuntimeStateInspection, type RuntimeStateInspectionSnapshot, type RuntimeWidgetInspection, type UnresolvedBlueprintInspectionNode, inspectBlueprint, inspectRuntime };
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 };