@deviltea/widget-core 0.0.1

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.
@@ -0,0 +1,149 @@
1
+ import { $ as RuntimeDependencyValueRejectedDiagnostic, $n as WidgetMethodReturnOf, $t as WidgetSystem, A as BlueprintNodeDiagnostic, An as WidgetResolvedConfigContext, At as RuntimeMethodSurface, B as Diagnostic, Bn as ExecutionResult, Bt as ValidBlueprintView, C as BlueprintDependencyDiagnosticLocation, Cn as WidgetPluginTypeOf, Ct as CreateWidgetSystemRuntimeOptions, D as BlueprintDiagnostic, Dn as WidgetPropertyComputeContext, Dt as ResolvedBlueprintWidgetNodeView, E as BlueprintDependencyTarget, En as WidgetPropertiesSection, Et as ResolvedBlueprintWidgetNodeFor, F as BlueprintSourceDiagnostic, Fn as WidgetStateMemberDefinition, Ft as RuntimeWidget, G as JsonCompatibilityDiagnostic, Gn as WidgetInterfaces, Gt as WidgetSourceFor, H as DiagnosticCollector, Hn as NonEmptyReadonlyArray, Ht as WidgetLocation, I as BlueprintSourceDiagnosticLocation, In as WidgetStateSection, It as RuntimeWidgetFor, J as RelativeSlotStructureDiagnosticInput, Jn as WidgetMemberKeysOf, Jt as WidgetSystemRuntime, K as JsonCompatibilityReason, Kn as WidgetInterfacesViolationOf, Kt as WidgetSystemBlueprint, L as BlueprintStructureDiagnostic, Ln as WidgetStateValidateContext, Lt as SelfBlueprintWidgetNode, M as BlueprintPropertyDiagnosticLocation, Mn as WidgetSlotDefinitions, Mt as RuntimePropertySurface, N as BlueprintSlotChildDiagnosticLocation, Nn as WidgetSlotValidateStructureContext, Nt as RuntimeState, O as BlueprintDiagnosticLocation, On as WidgetPropertyDefinition, Ot as ResolvedBlueprintWidgetNodeViewFor, P as BlueprintSlotDiagnosticLocation, Pn as WidgetStateDefaultContext, Pt as RuntimeStateSurface, Q as RuntimeDependencyTargetFailedDiagnostic, Qn as WidgetMethodOf, Qt as WidgetPluginOf, R as BlueprintStructureDiagnosticLocation, Rn as createWidgetPlugin, Rt as SelfBlueprintWidgetNodeView, S as BlueprintDependencyDiagnostic, Sn as WidgetPluginStatePhase, St as BlueprintWidgetNodeView, T as BlueprintDependencyReference, Tn as WidgetPluginValidateStructureContext, Tt as ResolvedBlueprintWidgetNode, U as DiagnosticPath, Un as WidgetCapabilityOf, Ut as WidgetLocationView, V as DiagnosticBase, Vn as HasWidgetCapability, Vt as ValidWidgetSystemBlueprint, W as EMPTY_DIAGNOSTICS, Wn as WidgetId, Wt as WidgetSource, X as RelativeSystemStructureDiagnosticInput, Xn as WidgetMethodArgsOf, Xt as WidgetCatalog, Y as RelativeStructureDiagnosticLocation, Yn as WidgetMemberValueOf, Yt as CreateWidgetSystemOptions, Z as RelativeValueDiagnosticInput, Zn as WidgetMethodKeyOf, Zt as WidgetCatalogEntry, _ as ToExecutedDeps, _n as WidgetPluginDonePhase, _t as BlueprintNodeConfigFields, a as MaybeOptional, an as WidgetConfigDefinition, ar as WidgetResolvedConfigOf, at as RuntimeMethodDependencyDiagnostic, b as BlueprintConfigDiagnostic, bn as WidgetPluginPropertiesPhase, bt as BlueprintWidgetNode, c as PropertyGetDepExpression, cn as WidgetInterfacesViolation, cr as WidgetStateOf, ct as RuntimePropertyDependencyDiagnostic, d as SelfMethodDependencyOperations, dn as WidgetMethodValidateArgsContext, dr as JsonObject, dt as RuntimeStateDiagnostic, en as WidgetSystemValidateStructure, er as WidgetMethodsOf, et as RuntimeDiagnostic, f as SelfPropertyDependencyOperations, fn as WidgetMethodsSection, fr as JsonPrimitive, ft as RuntimeWidgetDiagnostic, g as ToExecutedDep, gn as WidgetPluginDescriptionPhase, gt as BlueprintCompileView, h as StateSetDepExpression, hn as WidgetPluginConfigPhase, ht as WidgetSystemRuntimeDisposedError, i as EmptyRegisteredDeps, in as AnyWidgetPluginTuple, ir as WidgetRawConfigOf, it as RuntimeMethodArgsDiagnostic, j as BlueprintNodeDiagnosticLocation, jn as WidgetSlotDefinition, jt as RuntimeProperty, k as BlueprintMethodDiagnosticLocation, kn as WidgetRegisterDepsContext, kt as RuntimeMethod, l as RegisteredDeps, ln as WidgetMethodDefinition, lr as WidgetStateValueOf, lt as RuntimePropertyDiagnostic, m as StateGetDepExpression, mn as WidgetPluginCapabilities, mt as WidgetSystemRuntimeDiagnostic, n as DependencyBuilder, nn as createWidgetSystem, nr as WidgetPropertyKeyOf, nt as RuntimeLevelDiagnostic, o as MethodInvokeDepExpression, on as WidgetConfigValidateContext, or as WidgetSlotNameOf, ot as RuntimeMethodDiagnostic, p as SelfStateDependencyOperations, pn as WidgetPlugin, pr as JsonValue, pt as SourceAccessDiagnostic, q as RelativePluginStructureDiagnosticInput, qn as WidgetMemberKey, qt as WidgetSystemBlueprintStatus, r as DependencyConsumer, rn as AnyWidgetPlugin, rr as WidgetPropertyValueOf, rt as RuntimeLevelDiagnosticLocation, s as OptionalizableDependencyTarget, sn as WidgetInterfacesOf, sr as WidgetStateKeyOf, st as RuntimeMethodResultDiagnostic, t as AnyDepExpression, tn as WidgetSystemValidateStructureContext, tr as WidgetPropertiesOf, tt as RuntimeDiagnosticLocation, u as SelfDependencyTarget, un as WidgetMethodExecuteContext, ur as JsonArray, ut as RuntimePropertyResultDiagnostic, v as UnknownTargetDependencyOperations, vn as WidgetPluginInterfacesPhase, vt as BlueprintSemanticSlots, w as BlueprintDependencyOperation, wn as WidgetPluginValidateStructure, wt as InvalidWidgetSystemBlueprint, x as BlueprintDefinitionDiagnostic, xn as WidgetPluginSlotsPhase, xt as BlueprintWidgetNodeBase, y as UnknownTargetStateDependencyOperations, yn as WidgetPluginMethodsPhase, yt as BlueprintSemanticSlotsView, z as BlueprintWidgetDiagnosticLocation, zn as ExecutionFailure, zt as UnresolvedBlueprintWidgetNode } from "./dep-DKQpJwdW.mjs";
2
+ //#region src/source-patch.d.ts
3
+ type SourcePath = readonly (string | number)[] | string;
4
+ type SourcePatchOperation = {
5
+ readonly op: 'add';
6
+ readonly path: SourcePath;
7
+ readonly value: JsonValue;
8
+ } | {
9
+ readonly op: 'remove';
10
+ readonly path: SourcePath;
11
+ } | {
12
+ readonly op: 'replace';
13
+ readonly path: SourcePath;
14
+ readonly value: JsonValue;
15
+ } | {
16
+ readonly op: 'move';
17
+ readonly from: SourcePath;
18
+ readonly path: SourcePath;
19
+ } | {
20
+ readonly op: 'copy';
21
+ readonly from: SourcePath;
22
+ readonly path: SourcePath;
23
+ } | {
24
+ readonly op: 'test';
25
+ readonly path: SourcePath;
26
+ readonly value: JsonValue;
27
+ };
28
+ type SourcePatch = readonly SourcePatchOperation[];
29
+ type SourcePatchOperationFailureCode = 'invalid-path' | 'path-not-found' | 'path-not-traversable' | 'invalid-array-index' | 'invalid-move-target' | 'test-failed' | 'source-access-failed';
30
+ interface SourcePatchOperationFailure {
31
+ readonly code: SourcePatchOperationFailureCode;
32
+ readonly operationIndex: number;
33
+ readonly message: string;
34
+ }
35
+ //#endregion
36
+ //#region src/document.d.ts
37
+ interface WidgetDocumentSnapshot<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> {
38
+ readonly revision: number;
39
+ readonly blueprint: WidgetSystemBlueprint<Plugins>;
40
+ }
41
+ interface ApplyPatchOptions {
42
+ readonly expectedRevision: number;
43
+ }
44
+ interface ReentrantApplyFailure {
45
+ readonly code: 'reentrant-apply';
46
+ readonly message: string;
47
+ }
48
+ interface DocumentRevisionConflictFailure {
49
+ readonly code: 'document-revision-conflict';
50
+ readonly expectedRevision: number;
51
+ readonly actualRevision: number;
52
+ readonly message: string;
53
+ }
54
+ type ApplyPatchFailure = SourcePatchOperationFailure | ReentrantApplyFailure | DocumentRevisionConflictFailure;
55
+ type Result<Success extends object, Failure> = ({
56
+ readonly ok: true;
57
+ } & Success) | {
58
+ readonly ok: false;
59
+ readonly failure: Failure;
60
+ };
61
+ type ApplyPatchResult = Result<{
62
+ readonly changed: boolean;
63
+ }, ApplyPatchFailure>;
64
+ interface WidgetDocument<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> {
65
+ getSnapshot: () => WidgetDocumentSnapshot<Plugins>;
66
+ applyPatch: (patch: SourcePatch, options?: ApplyPatchOptions) => ApplyPatchResult;
67
+ subscribe: (listener: (snapshot: WidgetDocumentSnapshot<Plugins>) => void) => () => void;
68
+ }
69
+ interface CreateWidgetDocumentOptions<Plugins extends AnyWidgetPluginTuple> {
70
+ readonly system: WidgetSystem<Plugins>;
71
+ readonly source: unknown;
72
+ }
73
+ declare function createWidgetDocument<const Plugins extends AnyWidgetPluginTuple>(options: CreateWidgetDocumentOptions<Plugins>): WidgetDocument<Plugins>;
74
+ //#endregion
75
+ //#region src/separated-source.d.ts
76
+ /** The tree half of a {@link SeparatedWidgetSource}. */
77
+ interface SeparatedWidgetStructure {
78
+ readonly id: WidgetId;
79
+ readonly slots?: Readonly<Record<string, readonly SeparatedWidgetStructure[]>>;
80
+ }
81
+ /** One entry in the flat Widget data list. */
82
+ interface SeparatedWidgetData {
83
+ readonly id: WidgetId;
84
+ readonly type: string;
85
+ readonly config?: JsonValue;
86
+ }
87
+ /**
88
+ * Explicit alternative source representation: a nested structural tree plus a flat data list.
89
+ * The list is intentionally not a map so duplicate IDs remain observable and diagnosable.
90
+ */
91
+ interface SeparatedWidgetSource {
92
+ readonly structure: SeparatedWidgetStructure;
93
+ readonly widgets: readonly SeparatedWidgetData[];
94
+ }
95
+ /** A representation-aware source location, independent from Blueprint semantic locations. */
96
+ type SeparatedSourceLocation = {
97
+ readonly area: 'widgets';
98
+ readonly index: number;
99
+ readonly path?: readonly PropertyKey[];
100
+ } | {
101
+ readonly area: 'structure';
102
+ readonly path: readonly PropertyKey[];
103
+ };
104
+ /** Stable codes for separated-source normalization facts. */
105
+ type SeparatedWidgetSourceDiagnosticCode = 'invalid-separated-source' | 'invalid-separated-structure' | 'invalid-separated-widget' | 'duplicate-widget-id' | 'missing-widget-data' | 'unused-widget-data' | 'duplicate-structure-id';
106
+ /**
107
+ * Representation diagnostics are deliberately separate from Blueprint semantic diagnostics. The
108
+ * source location always identifies the separated input area and never relies on WidgetId
109
+ * uniqueness.
110
+ */
111
+ type SeparatedWidgetSourceDiagnostic = (DiagnosticBase<'invalid-separated-source', SeparatedSourceLocation> & {
112
+ readonly reason: 'missing-structure' | 'invalid-widgets';
113
+ }) | (DiagnosticBase<'invalid-separated-structure', SeparatedSourceLocation> & {
114
+ readonly reason: 'invalid-node' | 'invalid-slots' | 'invalid-slot-children';
115
+ }) | (DiagnosticBase<'invalid-separated-widget', SeparatedSourceLocation> & {
116
+ readonly reason: 'invalid-entry' | 'invalid-id' | 'invalid-type';
117
+ }) | (DiagnosticBase<'duplicate-widget-id', SeparatedSourceLocation> & {
118
+ readonly widgetId: WidgetId;
119
+ }) | (DiagnosticBase<'missing-widget-data', SeparatedSourceLocation> & {
120
+ readonly widgetId: WidgetId;
121
+ }) | (DiagnosticBase<'unused-widget-data', SeparatedSourceLocation> & {
122
+ readonly widgetId: WidgetId;
123
+ }) | (DiagnosticBase<'duplicate-structure-id', SeparatedSourceLocation> & {
124
+ readonly widgetId: WidgetId;
125
+ });
126
+ /** Result of explicit separated-source normalization. */
127
+ interface SeparatedWidgetSourceNormalization {
128
+ /**
129
+ * Best-effort nested source. It is `unknown` because malformed separated input intentionally
130
+ * remains recoverable rather than being asserted to satisfy `WidgetSource`.
131
+ */
132
+ readonly source: unknown;
133
+ readonly diagnostics: readonly SeparatedWidgetSourceDiagnostic[];
134
+ }
135
+ /**
136
+ * Projects canonical nested authored source into the explicit separated representation.
137
+ * Projection preserves nested slot order and emits flat data in deterministic depth-first order.
138
+ */
139
+ declare function separateWidgetSource<const Plugins extends AnyWidgetPluginTuple>(source: WidgetSource<Plugins>): SeparatedWidgetSource;
140
+ /**
141
+ * Normalizes an explicitly supplied separated representation into a best-effort nested source.
142
+ *
143
+ * Normalization is deterministic and non-destructive: the first flat entry for an ID wins;
144
+ * missing data creates a partial node; unused data is never guessed into the tree; and repeated
145
+ * structural occurrences retain their available data/subtree while omitting the repeated ID.
146
+ */
147
+ declare function normalizeSeparatedWidgetSource(input: unknown): SeparatedWidgetSourceNormalization;
148
+ //#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 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, type WidgetCapabilityOf, type WidgetCatalog, type WidgetCatalogEntry, type WidgetConfigDefinition, type WidgetConfigValidateContext, type WidgetDocument, type WidgetDocumentSnapshot, 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 WidgetPluginConfigPhase, type WidgetPluginDescriptionPhase, type WidgetPluginDonePhase, 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, createWidgetDocument, createWidgetPlugin, createWidgetSystem, normalizeSeparatedWidgetSource, separateWidgetSource };