@deviltea/widget-core 0.0.3 → 0.0.5
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 +54 -4
- package/dist/{dep-DAoSoLhi.d.mts → dep-Cvv2QPKi.d.mts} +9 -2
- package/dist/index.d.mts +13 -2
- package/dist/index.mjs +39 -31
- package/dist/inspection/index.d.mts +1 -1
- package/dist/integration/index.d.mts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,6 +75,14 @@ See
|
|
|
75
75
|
[Plugin registration errors](https://deviltea.github.io/widget/packages/widget-core#plugin-registration-errors)
|
|
76
76
|
in the full guide.
|
|
77
77
|
|
|
78
|
+
A plugin with a config capability always runs `config.validate`. An omitted
|
|
79
|
+
raw `config` is validated as `null`, so required-ness comes from the raw config
|
|
80
|
+
type: declare `raw: Config | null` (and accept `null` in the validator) when
|
|
81
|
+
config may be omitted, or `raw: Config` to require it. A rejected config yields
|
|
82
|
+
`invalid-widget-config` and resolves through `resolve(null)`. See
|
|
83
|
+
[Config](https://deviltea.github.io/widget/packages/widget-core#config) in the
|
|
84
|
+
full guide.
|
|
85
|
+
|
|
78
86
|
Plugin, config, and slot descriptions are required intrinsic metadata. The
|
|
79
87
|
immutable `system.catalog` is a passive projection of registered widget types,
|
|
80
88
|
descriptions, and capability descriptions; it does not contain Blueprint or
|
|
@@ -273,10 +281,38 @@ subscribers. `failure.code` is one of:
|
|
|
273
281
|
before any operation is evaluated.
|
|
274
282
|
- An operation failure `{ code, operationIndex, message }`, where `code` is
|
|
275
283
|
`invalid-path`, `path-not-found`, `path-not-traversable`,
|
|
276
|
-
`invalid-array-index`, `invalid-move-target`, `test-failed`,
|
|
277
|
-
`source-access-failed`, and `operationIndex`
|
|
278
|
-
position in the patch. A failed patch leaves the
|
|
279
|
-
unchanged.
|
|
284
|
+
`invalid-array-index`, `invalid-move-target`, `test-failed`,
|
|
285
|
+
`json-incompatible-value`, or `source-access-failed`, and `operationIndex`
|
|
286
|
+
is the failing operation's position in the patch. A failed patch leaves the
|
|
287
|
+
committed source and revision unchanged.
|
|
288
|
+
|
|
289
|
+
| `code` | Meaning |
|
|
290
|
+
| --- | --- |
|
|
291
|
+
| `invalid-path` | malformed path or operation shape |
|
|
292
|
+
| `path-not-found` | the path does not identify an existing location |
|
|
293
|
+
| `path-not-traversable` | the path passes through a non-traversable value |
|
|
294
|
+
| `invalid-array-index` | an Array parent was addressed by anything other than an in-bounds canonical index (see below) |
|
|
295
|
+
| `invalid-move-target` | a `move` into its own descendant |
|
|
296
|
+
| `test-failed` | a `test` operand did not match the addressed value |
|
|
297
|
+
| `json-incompatible-value` | an `add`/`replace`/`test` `value` is outside Core's JSON domain (missing or `undefined`, functions, `bigint`, symbols, `NaN`/`±Infinity`, cycles, non-plain prototypes, sparse or extra-property Arrays, accessors, symbol keys, or reflection that throws); checked after path parsing and before the operation is evaluated |
|
|
298
|
+
| `source-access-failed` | unsafe access to the *source* material only |
|
|
299
|
+
|
|
300
|
+
Three edge semantics apply to every operation:
|
|
301
|
+
|
|
302
|
+
- **Arrays have only index members.** After path normalization, any segment on
|
|
303
|
+
an Array parent that is not a canonical index (`'length'`, `'foo'`, `'01'`, or a
|
|
304
|
+
structured `'-'`) fails `invalid-array-index`, at every position (traversal,
|
|
305
|
+
target, and `from`) and in both path forms. Append remains JSON-Pointer-only
|
|
306
|
+
(`/items/-`); a structured `'-'` never appends and is an ordinary key on
|
|
307
|
+
objects. Non-index properties already present on a recovery Array are repaired
|
|
308
|
+
by replacing that Array or an ancestor.
|
|
309
|
+
- **Numbers compare by SameValueZero.** `test` and no-op detection treat `0` and
|
|
310
|
+
`-0` as equal, so replacing `0` with `-0` (or the reverse) returns
|
|
311
|
+
`{ ok: true, changed: false }` and the source keeps its original value.
|
|
312
|
+
Explicit `add`/`replace` operands are copied with `-0` written as `+0` at
|
|
313
|
+
every depth; `copy`/`move` relocate existing material unchanged.
|
|
314
|
+
- **Operands must be JSON values.** A non-JSON operand fails with
|
|
315
|
+
`json-incompatible-value`, not `source-access-failed`.
|
|
280
316
|
|
|
281
317
|
`document.subscribe(listener)` registers `listener` and returns an idempotent
|
|
282
318
|
unsubscribe function. The listener is not called on subscription; it receives
|
|
@@ -330,6 +366,11 @@ later occurrence is de-identified with its available subtree preserved.
|
|
|
330
366
|
- Every `RuntimeMethod` invocation batches its dependency/state writes; the
|
|
331
367
|
batch flushes once the method returns, so partial writes from nested method
|
|
332
368
|
calls are not observed mid-flight by outside subscribers.
|
|
369
|
+
- A failed dependency call adds a consumer-local `dependency-target-failed` /
|
|
370
|
+
`dependency-value-rejected` diagnostic to the calling Property or Method's
|
|
371
|
+
active diagnostic collector. Computing a fallback value after the failure
|
|
372
|
+
does not make the operation succeed: the result is still `ok: false`. See
|
|
373
|
+
[Dependency failures fail the consumer](https://deviltea.github.io/widget/packages/widget-core#dependency-failures-fail-the-consumer).
|
|
333
374
|
- Every state write, property evaluation, and method invocation keeps the
|
|
334
375
|
**latest completed** diagnostic snapshot only (`getDiagnostics()` /
|
|
335
376
|
`subscribeDiagnostics()`), never a history.
|
|
@@ -367,6 +408,15 @@ import { inspectBlueprint, inspectRuntime } from '@deviltea/widget-core/inspecti
|
|
|
367
408
|
in the full guide for the exact contract, including the Event inspection
|
|
368
409
|
delivery guarantees.
|
|
369
410
|
|
|
411
|
+
### Host requirements
|
|
412
|
+
|
|
413
|
+
The current implementation needs an ES2022 engine and a global
|
|
414
|
+
`queueMicrotask` whose jobs the host actually runs: a throwing `subscribe` /
|
|
415
|
+
`subscribeDiagnostics` listener is isolated and rethrown in a microtask.
|
|
416
|
+
Embedded engines such as QuickJS (`rquickjs`) must drain their pending jobs,
|
|
417
|
+
or those listener errors never surface. See
|
|
418
|
+
[Host requirements](https://deviltea.github.io/widget/packages/widget-core#host-requirements).
|
|
419
|
+
|
|
370
420
|
The full guide at
|
|
371
421
|
[docs/site/packages/widget-core.md](https://deviltea.github.io/widget/packages/widget-core)
|
|
372
422
|
covers the dependency grammar, the compile pipeline, and every Runtime
|
|
@@ -35,7 +35,12 @@ type WidgetMemberKey = string;
|
|
|
35
35
|
*/
|
|
36
36
|
interface WidgetInterfaces {
|
|
37
37
|
config?: {
|
|
38
|
-
|
|
38
|
+
/**
|
|
39
|
+
* The authored config values the plugin accepts. `config.validate` always runs, and an omitted
|
|
40
|
+
* config is validated as `null`, so include `null` (e.g. `raw: MyConfig | null`) when config may be
|
|
41
|
+
* omitted; leave it out to make config required.
|
|
42
|
+
*/
|
|
43
|
+
raw: Record<any, any> | null;
|
|
39
44
|
resolved: Record<any, any>;
|
|
40
45
|
};
|
|
41
46
|
slots?: string;
|
|
@@ -661,8 +666,10 @@ interface ValidBlueprintView<Plugins extends AnyWidgetPluginTuple = AnyWidgetPlu
|
|
|
661
666
|
type WidgetSourceFor<Plugin extends AnyWidgetPlugin, Plugins extends AnyWidgetPluginTuple> = {
|
|
662
667
|
readonly id: WidgetId;
|
|
663
668
|
readonly type: WidgetPluginTypeOf<Plugin>;
|
|
664
|
-
} & (HasWidgetCapability<WidgetInterfacesOf<Plugin>, 'config'> extends true ? {
|
|
669
|
+
} & (HasWidgetCapability<WidgetInterfacesOf<Plugin>, 'config'> extends true ? [null] extends [WidgetRawConfigOf<WidgetInterfacesOf<Plugin>>] ? {
|
|
665
670
|
readonly config?: WidgetRawConfigOf<WidgetInterfacesOf<Plugin>>;
|
|
671
|
+
} : {
|
|
672
|
+
readonly config: WidgetRawConfigOf<WidgetInterfacesOf<Plugin>>;
|
|
666
673
|
} : unknown) & (HasWidgetCapability<WidgetInterfacesOf<Plugin>, 'slots'> extends true ? {
|
|
667
674
|
readonly slots?: { readonly [Name in WidgetSlotNameOf<WidgetInterfacesOf<Plugin>>]?: readonly WidgetSource<Plugins>[]; };
|
|
668
675
|
} : unknown);
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as RuntimeDependencyValueRejectedDiagnostic, $n as createWidgetValueContract, $t as WidgetCatalogEntry, A as BlueprintNodeDiagnostic, An as WidgetPluginInterfacesPhase, Ar as JsonPrimitive, At as RuntimeEventSurface, B as Diagnostic, Bn as WidgetPropertyComputeContext, Bt as SelfBlueprintWidgetNodeView, C as BlueprintDependencyDiagnosticLocation, Cn as WidgetPlugin, Cr as WidgetResolvedConfigOf, Ct as CreateWidgetSystemRuntimeOptions, D as BlueprintDiagnostic, Dn as WidgetPluginDescriptionPhase, Dr as WidgetStateValueOf, Dt as ResolvedBlueprintWidgetNodeView, E as BlueprintDependencyTarget, En as WidgetPluginConfigPhase, Er as WidgetStateOf, Et as ResolvedBlueprintWidgetNodeFor, F as BlueprintSourceDiagnostic, Fn as WidgetPluginStatePhase, Ft as RuntimeState, G as JsonCompatibilityDiagnostic, Gn as WidgetSlotDefinitions, Gt as WidgetLocationView, H as DiagnosticCollector, Hn as WidgetRegisterDepsContext, Ht as ValidBlueprintView, I as BlueprintSourceDiagnosticLocation, In as WidgetPluginTypeOf, It as RuntimeStateSurface, J as RelativeSlotStructureDiagnosticInput, Jn as WidgetStateMemberDefinition, Jt as WidgetSystemBlueprint, K as JsonCompatibilityReason, Kn as WidgetSlotValidateStructureContext, Kt as WidgetSource, L as BlueprintStructureDiagnostic, Ln as WidgetPluginValidateStructure, Lt as RuntimeWidget, M as BlueprintPropertyDiagnosticLocation, Mn as WidgetPluginPhaseOrderViolation, Mt as RuntimeMethodSurface, N as BlueprintSlotChildDiagnosticLocation, Nn as WidgetPluginPropertiesPhase, Nt as RuntimeProperty, O as BlueprintDiagnosticLocation, On as WidgetPluginDonePhase, Or as JsonArray, Ot as ResolvedBlueprintWidgetNodeViewFor, P as BlueprintSlotDiagnosticLocation, Pn as WidgetPluginSlotsPhase, Pt as RuntimePropertySurface, Q as RuntimeDependencyTargetFailedDiagnostic, Qn as createWidgetPlugin, Qt as WidgetCatalog, R as BlueprintStructureDiagnosticLocation, Rn as WidgetPluginValidateStructureContext, Rt as RuntimeWidgetFor, S as BlueprintDependencyDiagnostic, Sn as WidgetMethodsSection, Sr as WidgetRawConfigOf, St as BlueprintWidgetNodeView, T as BlueprintDependencyReference, Tn as WidgetPluginConfigMetadata, Tr as WidgetStateKeyOf, Tt as ResolvedBlueprintWidgetNode, U as DiagnosticPath, Un as WidgetResolvedConfigContext, Ut as ValidWidgetSystemBlueprint, V as DiagnosticBase, Vn as WidgetPropertyDefinition, Vt as UnresolvedBlueprintWidgetNode, W as EMPTY_DIAGNOSTICS, Wn as WidgetSlotDefinition, Wt as WidgetLocation, X as RelativeSystemStructureDiagnosticInput, Xn as WidgetStateValidateContext, Xt as WidgetSystemRuntime, Y as RelativeStructureDiagnosticLocation, Yn as WidgetStateSection, Yt as WidgetSystemBlueprintStatus, Z as RelativeValueDiagnosticInput, Zn as WidgetValueContract, Zt as CreateWidgetSystemOptions, _ as ToExecutedDeps, _n as WidgetInterfacesOf, _r as WidgetMethodReturnOf, _t as BlueprintNodeConfigFields, a as MaybeOptional, an as WidgetSystemValidateStructureContext, ar as WidgetEventArgsOf, at as RuntimeMethodDependencyDiagnostic, b as BlueprintConfigDiagnostic, bn as WidgetMethodExecuteContext, br as WidgetPropertyKeyOf, bt as BlueprintWidgetNode, c as PropertyGetDepExpression, cn as AnyWidgetPluginTuple, cr as WidgetId, ct as RuntimePropertyDependencyDiagnostic, d as SelfMethodDependencyOperations, dn as WidgetConfigJsonSchema, dr as WidgetMemberKey, dt as RuntimeStateDiagnostic, en as WidgetPluginOf, er as ExecutionFailure, et as RuntimeDiagnostic, f as SelfPropertyDependencyOperations, fn as WidgetConfigValidateContext, fr as WidgetMemberKeysOf, ft as RuntimeWidgetDiagnostic, g as ToExecutedDep, gn as WidgetEventsSection, gr as WidgetMethodOf, gt as BlueprintCompileView, h as StateSetDepExpression, hn as WidgetEventEmitterContext, hr as WidgetMethodKeyOf, ht as WidgetSystemRuntimeDisposedError, i as EmptyRegisteredDeps, in as WidgetSystemValidateStructure, ir as WidgetCapabilityOf, it as RuntimeMethodArgsDiagnostic, j as BlueprintNodeDiagnosticLocation, jn as WidgetPluginMethodsPhase, jr as JsonValue, jt as RuntimeMethod, k as BlueprintMethodDiagnosticLocation, kn as WidgetPluginEventsPhase, kr as JsonObject, kt as RuntimeEvent, l as RegisteredDeps, ln as WIDGET_CONFIG_JSON_SCHEMA_DIALECT, lr as WidgetInterfaces, lt as RuntimePropertyDiagnostic, m as StateGetDepExpression, mn as WidgetEventEmitter, mr as WidgetMethodArgsOf, mt as WidgetSystemRuntimeDiagnostic, n as DependencyBuilder, nn as WidgetSystemConfigurationError, nr as HasWidgetCapability, nt as RuntimeLevelDiagnostic, o as MethodInvokeDepExpression, on as createWidgetSystem, or as WidgetEventKeyOf, ot as RuntimeMethodDiagnostic, p as SelfStateDependencyOperations, pn as WidgetEventDefinition, pr as WidgetMemberValueOf, pt as SourceAccessDiagnostic, q as RelativePluginStructureDiagnosticInput, qn as WidgetStateDefaultContext, qt as WidgetSourceFor, r as DependencyConsumer, rn as WidgetSystemConfigurationErrorCode, rr as NonEmptyReadonlyArray, rt as RuntimeLevelDiagnosticLocation, s as OptionalizableDependencyTarget, sn as AnyWidgetPlugin, sr as WidgetEventsOf, st as RuntimeMethodResultDiagnostic, t as AnyDepExpression, tn as WidgetSystem, tr as ExecutionResult, tt as RuntimeDiagnosticLocation, u as SelfDependencyTarget, un as WidgetConfigDefinition, ur as WidgetInterfacesViolationOf, ut as RuntimePropertyResultDiagnostic, v as UnknownTargetDependencyOperations, vn as WidgetInterfacesViolation, vr as WidgetMethodsOf, vt as BlueprintSemanticSlots, w as BlueprintDependencyOperation, wn as WidgetPluginCapabilities, wr as WidgetSlotNameOf, wt as InvalidWidgetSystemBlueprint, x as BlueprintDefinitionDiagnostic, xn as WidgetMethodValidateArgsContext, xr as WidgetPropertyValueOf, xt as BlueprintWidgetNodeBase, y as UnknownTargetStateDependencyOperations, yn as WidgetMethodDefinition, yr as WidgetPropertiesOf, yt as BlueprintSemanticSlotsView, z as BlueprintWidgetDiagnosticLocation, zn as WidgetPropertiesSection, zt as SelfBlueprintWidgetNode } from "./dep-
|
|
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-Cvv2QPKi.mjs";
|
|
2
2
|
//#region src/source-patch.d.ts
|
|
3
3
|
type SourcePath = readonly (string | number)[] | string;
|
|
4
4
|
type SourcePatchOperation = {
|
|
@@ -25,8 +25,19 @@ type SourcePatchOperation = {
|
|
|
25
25
|
readonly path: SourcePath;
|
|
26
26
|
readonly value: JsonValue;
|
|
27
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* An RFC 6902-style patch over JSON-domain authored source. Arrays are addressed only by canonical
|
|
30
|
+
* index (append is the JSON Pointer `/items/-` only). `test` and no-op detection compare numbers by
|
|
31
|
+
* SameValueZero (`0` equals `-0`), and explicit `add`/`replace` operands write `-0` as `+0`.
|
|
32
|
+
*/
|
|
28
33
|
type SourcePatch = readonly SourcePatchOperation[];
|
|
29
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Operation failure codes. `invalid-array-index` covers any non-canonical-index segment on an Array
|
|
36
|
+
* parent (`'length'`, `'foo'`, `'01'`, structured `'-'`) in both path forms. `json-incompatible-value`
|
|
37
|
+
* is an `add`/`replace`/`test` operand outside Core's JSON domain; `source-access-failed` concerns
|
|
38
|
+
* unsafe access to source material only.
|
|
39
|
+
*/
|
|
40
|
+
type SourcePatchOperationFailureCode = 'invalid-path' | 'path-not-found' | 'path-not-traversable' | 'invalid-array-index' | 'invalid-move-target' | 'test-failed' | 'json-incompatible-value' | 'source-access-failed';
|
|
30
41
|
interface SourcePatchOperationFailure {
|
|
31
42
|
readonly code: SourcePatchOperationFailureCode;
|
|
32
43
|
readonly operationIndex: number;
|
package/dist/index.mjs
CHANGED
|
@@ -168,9 +168,19 @@ function inspectJsonValue(value) {
|
|
|
168
168
|
function isJsonValue(value) {
|
|
169
169
|
return inspectJsonValue(value).compatible;
|
|
170
170
|
}
|
|
171
|
-
/**
|
|
171
|
+
/**
|
|
172
|
+
* SameValueZero: `+0` equals `-0` and `NaN` equals `NaN`. Used only for SourcePatch comparisons
|
|
173
|
+
* (`test` and no-op detection); Runtime State has its own equality rule and does not use this.
|
|
174
|
+
*/
|
|
175
|
+
function sameValueZero(left, right) {
|
|
176
|
+
return left === right || typeof left === "number" && typeof right === "number" && Number.isNaN(left) && Number.isNaN(right);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* JSON-domain equality used by the RFC6902 `test` operation; primitives compare by SameValueZero,
|
|
180
|
+
* so `-0` equals `0`. (SourcePatch no-op detection uses `structurallyEqual` in `source-patch.ts`.)
|
|
181
|
+
*/
|
|
172
182
|
function jsonEqual(left, right, seen = /* @__PURE__ */ new Set()) {
|
|
173
|
-
if (
|
|
183
|
+
if (sameValueZero(left, right)) return true;
|
|
174
184
|
if (typeof left !== "object" || left === null || typeof right !== "object" || right === null) return false;
|
|
175
185
|
if (!isJsonValue(left) || !isJsonValue(right)) return false;
|
|
176
186
|
if (seen.has(left) || seen.has(right)) return false;
|
|
@@ -204,6 +214,7 @@ const PATCH_ERROR_MESSAGES = {
|
|
|
204
214
|
"invalid-array-index": "The SourcePath contains an invalid Array index.",
|
|
205
215
|
"invalid-move-target": "The move destination is invalid relative to its source.",
|
|
206
216
|
"test-failed": "The test operation did not match the addressed value.",
|
|
217
|
+
"json-incompatible-value": "The SourcePatch operand is outside the JSON value domain.",
|
|
207
218
|
"source-access-failed": "The source could not be inspected safely."
|
|
208
219
|
};
|
|
209
220
|
function failure(code, message = PATCH_ERROR_MESSAGES[code]) {
|
|
@@ -288,12 +299,14 @@ function inspectStructuralContainer(value) {
|
|
|
288
299
|
function isCanonicalArrayIndex(key) {
|
|
289
300
|
return /^(?:0|[1-9]\d*)$/.test(key) && Number(key) < 4294967295;
|
|
290
301
|
}
|
|
291
|
-
|
|
302
|
+
/**
|
|
303
|
+
* Arrays have only index members: after path normalization, any segment that is not a canonical
|
|
304
|
+
* index fails `invalid-array-index` in both path forms. `null` means the JSON Pointer append
|
|
305
|
+
* position and is only returned when the caller allows it (callers pass `allowAppend` only for a
|
|
306
|
+
* final JSON Pointer `-` on an add-like operation).
|
|
307
|
+
*/
|
|
308
|
+
function getArrayIndex(segment, allowAppend = false) {
|
|
292
309
|
const key = String(segment);
|
|
293
|
-
if (!path.pointer && typeof segment === "string" && !isCanonicalArrayIndex(key)) return {
|
|
294
|
-
ok: true,
|
|
295
|
-
value: null
|
|
296
|
-
};
|
|
297
310
|
if (key === "-" && allowAppend) return {
|
|
298
311
|
ok: true,
|
|
299
312
|
value: null
|
|
@@ -345,7 +358,7 @@ function readAt(source, path) {
|
|
|
345
358
|
if (!container.ok) return container;
|
|
346
359
|
if (container.value === "opaque") return failure("path-not-traversable");
|
|
347
360
|
if (container.value === "array") {
|
|
348
|
-
const indexResult = getArrayIndex(
|
|
361
|
+
const indexResult = getArrayIndex(segment);
|
|
349
362
|
if (!indexResult.ok) return indexResult;
|
|
350
363
|
const length = readArrayLength(current);
|
|
351
364
|
if (!length.ok) return length;
|
|
@@ -419,17 +432,12 @@ function rebuildObject(container, segment, action, value, pointer = true, allowA
|
|
|
419
432
|
const key = String(segment);
|
|
420
433
|
const append = isArray && pointer && segment === "-" && allowArrayAppend;
|
|
421
434
|
const effectiveKey = append ? String(arrayLength.value) : key;
|
|
422
|
-
const arrayIndexResult = isArray ? getArrayIndex({
|
|
423
|
-
segments: [],
|
|
424
|
-
append: false,
|
|
425
|
-
pointer
|
|
426
|
-
}, segment, allowArrayAppend) : {
|
|
435
|
+
const arrayIndexResult = isArray ? getArrayIndex(segment, append) : {
|
|
427
436
|
ok: true,
|
|
428
437
|
value: null
|
|
429
438
|
};
|
|
430
439
|
if (!arrayIndexResult.ok) return arrayIndexResult;
|
|
431
440
|
const arrayIndex = append ? arrayLength.value : arrayIndexResult.value;
|
|
432
|
-
if (isArray && pointer && segment === "-" && !allowArrayAppend) return failure("invalid-array-index");
|
|
433
441
|
if (isArray && arrayIndex !== null) {
|
|
434
442
|
if (action === "add" && arrayIndex > arrayLength.value) return failure("invalid-array-index");
|
|
435
443
|
if (action !== "add" && arrayIndex >= arrayLength.value) return failure("invalid-array-index");
|
|
@@ -475,7 +483,7 @@ function modifyAt(source, path, modify) {
|
|
|
475
483
|
const key = String(segment);
|
|
476
484
|
if (index === path.segments.length - 1) return modify(container, segment);
|
|
477
485
|
if (containerKind.value === "array") {
|
|
478
|
-
const indexResult = getArrayIndex(
|
|
486
|
+
const indexResult = getArrayIndex(segment);
|
|
479
487
|
if (!indexResult.ok) return indexResult;
|
|
480
488
|
const length = readArrayLength(container);
|
|
481
489
|
if (!length.ok) return length;
|
|
@@ -495,10 +503,15 @@ function modifyRoot(source, value) {
|
|
|
495
503
|
value
|
|
496
504
|
};
|
|
497
505
|
}
|
|
498
|
-
|
|
506
|
+
/**
|
|
507
|
+
* Structurally copies `value`. With `canonicalizeNegativeZero` (explicit `add`/`replace` operands),
|
|
508
|
+
* every `-0` at any depth is written as `+0`; `copy`/`move` relocate existing material unchanged.
|
|
509
|
+
*/
|
|
510
|
+
function copyValue(value, canonicalizeNegativeZero = false) {
|
|
511
|
+
const canonical = (primitive) => canonicalizeNegativeZero && Object.is(primitive, -0) ? 0 : primitive;
|
|
499
512
|
if (value === null || typeof value !== "object") return {
|
|
500
513
|
ok: true,
|
|
501
|
-
value
|
|
514
|
+
value: canonical(value)
|
|
502
515
|
};
|
|
503
516
|
const containerKind = inspectStructuralContainer(value);
|
|
504
517
|
if (!containerKind.ok) return containerKind;
|
|
@@ -526,7 +539,7 @@ function copyValue(value) {
|
|
|
526
539
|
const child = descriptor.value;
|
|
527
540
|
let copied = {
|
|
528
541
|
ok: true,
|
|
529
|
-
value: child
|
|
542
|
+
value: canonical(child)
|
|
530
543
|
};
|
|
531
544
|
if (child !== null && typeof child === "object") {
|
|
532
545
|
const childKind = inspectStructuralContainer(child);
|
|
@@ -547,7 +560,7 @@ function copyValue(value) {
|
|
|
547
560
|
function structurallyEqual(left, right) {
|
|
548
561
|
const matched = /* @__PURE__ */ new WeakMap();
|
|
549
562
|
function equal(currentLeft, currentRight) {
|
|
550
|
-
if (
|
|
563
|
+
if (sameValueZero(currentLeft, currentRight)) return true;
|
|
551
564
|
if (typeof currentLeft !== "object" || currentLeft === null || typeof currentRight !== "object" || currentRight === null) return false;
|
|
552
565
|
const leftKind = inspectStructuralContainer(currentLeft);
|
|
553
566
|
const rightKind = inspectStructuralContainer(currentRight);
|
|
@@ -628,11 +641,11 @@ function applySourcePatch(source, patch) {
|
|
|
628
641
|
if (!isJsonValue(value)) return {
|
|
629
642
|
ok: false,
|
|
630
643
|
failure: operationError(operationIndex, {
|
|
631
|
-
code: "
|
|
632
|
-
message: "
|
|
644
|
+
code: "json-incompatible-value",
|
|
645
|
+
message: PATCH_ERROR_MESSAGES["json-incompatible-value"]
|
|
633
646
|
})
|
|
634
647
|
};
|
|
635
|
-
const copied = copyValue(value);
|
|
648
|
+
const copied = copyValue(value, true);
|
|
636
649
|
if (!copied.ok) return {
|
|
637
650
|
ok: false,
|
|
638
651
|
failure: operationError(operationIndex, copied.error)
|
|
@@ -656,8 +669,8 @@ function applySourcePatch(source, patch) {
|
|
|
656
669
|
if (!isJsonValue(value)) return {
|
|
657
670
|
ok: false,
|
|
658
671
|
failure: operationError(operationIndex, {
|
|
659
|
-
code: "
|
|
660
|
-
message: "
|
|
672
|
+
code: "json-incompatible-value",
|
|
673
|
+
message: PATCH_ERROR_MESSAGES["json-incompatible-value"]
|
|
661
674
|
})
|
|
662
675
|
};
|
|
663
676
|
const actual = readAt(working, path);
|
|
@@ -2971,19 +2984,14 @@ function buildNode(ctx, rawValue, parentNodeId, parentPublicNode, placement) {
|
|
|
2971
2984
|
const definition = readWidgetPluginDefinition(plugin);
|
|
2972
2985
|
const configProperty = readOwnDataProperty(raw, "config");
|
|
2973
2986
|
if (definition.config !== null) {
|
|
2974
|
-
if (!configProperty.
|
|
2975
|
-
const resolved = definition.config.resolve(null);
|
|
2976
|
-
assertSyncValue(resolved, "config.resolve");
|
|
2977
|
-
working.rawConfig = null;
|
|
2978
|
-
working.config = resolved;
|
|
2979
|
-
} else if (!configProperty.accessible) {
|
|
2987
|
+
if (configProperty.found && !configProperty.accessible) {
|
|
2980
2988
|
localDiagnostics.push(configDiagnostic(publicNode, "Widget config could not be inspected safely."));
|
|
2981
2989
|
const resolved = definition.config.resolve(null);
|
|
2982
2990
|
assertSyncValue(resolved, "config.resolve");
|
|
2983
2991
|
working.rawConfig = null;
|
|
2984
2992
|
working.config = resolved;
|
|
2985
2993
|
} else {
|
|
2986
|
-
const rawConfigValue = configProperty.value;
|
|
2994
|
+
const rawConfigValue = configProperty.found ? configProperty.value : null;
|
|
2987
2995
|
const { collector, items } = createCollector();
|
|
2988
2996
|
let ok = false;
|
|
2989
2997
|
try {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Jt as WidgetSystemBlueprint, T as BlueprintDependencyReference, Tn as WidgetPluginConfigMetadata, Tt as ResolvedBlueprintWidgetNode, Vt as UnresolvedBlueprintWidgetNode, Xt as WidgetSystemRuntime, bt as BlueprintWidgetNode, cn as AnyWidgetPluginTuple, dr as WidgetMemberKey, lt as RuntimePropertyDiagnostic, sn as AnyWidgetPlugin, tr as ExecutionResult } from "../dep-
|
|
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-Cvv2QPKi.mjs";
|
|
2
2
|
//#region src/inspection/types.d.ts
|
|
3
3
|
declare const inspectionNodeIdBrand: unique symbol;
|
|
4
4
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Lt as RuntimeWidget, Xt as WidgetSystemRuntime, cn as AnyWidgetPluginTuple, dr as WidgetMemberKey } from "../dep-
|
|
1
|
+
import { Lt as RuntimeWidget, Xt as WidgetSystemRuntime, cn as AnyWidgetPluginTuple, dr as WidgetMemberKey } from "../dep-Cvv2QPKi.mjs";
|
|
2
2
|
//#region src/integration/index.d.ts
|
|
3
3
|
type WidgetIntegrationErrorCode = 'runtime-widget-mismatch' | 'foreign-runtime';
|
|
4
4
|
declare class WidgetIntegrationError extends Error {
|
package/package.json
CHANGED