@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.
- package/LICENSE +21 -0
- package/README.md +327 -0
- package/dist/dep-DKQpJwdW.d.mts +1110 -0
- package/dist/index.d.mts +149 -0
- package/dist/index.mjs +3891 -0
- package/dist/inspection/index.d.mts +190 -0
- package/dist/inspection/index.mjs +296 -0
- package/dist/internals-DXFEmv8H.mjs +27 -0
- package/package.json +62 -0
|
@@ -0,0 +1,1110 @@
|
|
|
1
|
+
//#region src/json.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The authored value domain. Runtime/config-resolved values intentionally use `unknown` instead;
|
|
4
|
+
* this type is only for values that can occur in persisted Widget source and SourcePatch operands.
|
|
5
|
+
*/
|
|
6
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
7
|
+
type JsonArray = readonly JsonValue[];
|
|
8
|
+
interface JsonObject {
|
|
9
|
+
readonly [key: string]: JsonValue;
|
|
10
|
+
}
|
|
11
|
+
type JsonValue = JsonPrimitive | JsonArray | JsonObject;
|
|
12
|
+
/**
|
|
13
|
+
* Type-level diagnostic for a RawConfig that is not statically within JsonValue. Optional properties
|
|
14
|
+
* are allowed to be omitted, but an explicitly required `undefined` remains outside the domain.
|
|
15
|
+
*/
|
|
16
|
+
type IsAny$1<T> = 0 extends 1 & T ? true : false;
|
|
17
|
+
type OptionalKeys<T extends object> = { [Key in keyof T]-?: Record<never, never> extends Pick<T, Key> ? Key : never; }[keyof T];
|
|
18
|
+
type JsonDomainViolation<Value> = IsAny$1<Value> extends true ? 'authored JSON values cannot contain any' : [Value] extends [never] ? never : [Value] extends [JsonValue] ? never : Value extends string | number | boolean | null ? never : Value extends ((...args: any[]) => any) ? 'authored values must be JSON-compatible' : Value extends readonly (infer Element)[] ? JsonDomainViolation<Element> : Value extends object ? Exclude<keyof Value, string> extends never ? { [Key in keyof Value]-?: Key extends OptionalKeys<Value> ? JsonDomainViolation<Exclude<Value[Key], undefined>> : JsonDomainViolation<Value[Key]>; }[keyof Value] : 'authored JSON objects may only have string keys' : 'authored values must be JSON-compatible';
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/types.d.ts
|
|
21
|
+
/**
|
|
22
|
+
* Persisted/domain widget identity. Compiler-internal node identity is private and never public.
|
|
23
|
+
*/
|
|
24
|
+
type WidgetId = string;
|
|
25
|
+
/**
|
|
26
|
+
* Semantic member key domain for state / properties / methods / slots.
|
|
27
|
+
*
|
|
28
|
+
* Locked to `string`: numeric keys, symbol keys and broad string index signatures are unsupported.
|
|
29
|
+
*/
|
|
30
|
+
type WidgetMemberKey = string;
|
|
31
|
+
/**
|
|
32
|
+
* Plugin capability declaration. Every section is optional and every present section is a capability
|
|
33
|
+
* that must be implemented completely by the plugin builder.
|
|
34
|
+
*/
|
|
35
|
+
interface WidgetInterfaces {
|
|
36
|
+
config?: {
|
|
37
|
+
raw: Record<any, any>;
|
|
38
|
+
resolved: Record<any, any>;
|
|
39
|
+
};
|
|
40
|
+
slots?: string;
|
|
41
|
+
state?: Record<any, any>;
|
|
42
|
+
properties?: Record<any, any>;
|
|
43
|
+
methods?: Record<any, (...args: any[]) => any>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A readonly array that is non-empty when present. Used by every optional `related` collection.
|
|
47
|
+
*/
|
|
48
|
+
type NonEmptyReadonlyArray<T> = readonly [T, ...T[]];
|
|
49
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
50
|
+
/**
|
|
51
|
+
* Reads one declared capability. Returns `never` when the capability is absent.
|
|
52
|
+
*
|
|
53
|
+
* A capability counts as declared only when the interfaces type declares the key as a required
|
|
54
|
+
* property; an optional (`undefined`-inclusive) declaration is treated as absent so that
|
|
55
|
+
* `interface X extends WidgetInterfaces` does not silently claim every capability.
|
|
56
|
+
*/
|
|
57
|
+
type WidgetCapabilityOf<Interfaces extends WidgetInterfaces, Key extends keyof WidgetInterfaces> = Interfaces extends Record<Key, infer Capability> ? Capability : never;
|
|
58
|
+
/**
|
|
59
|
+
* `true` when the capability is declared, `false` otherwise.
|
|
60
|
+
*
|
|
61
|
+
* The authoritative presence predicate (diagnostic #10 amendment "declaration-presence semantics and public
|
|
62
|
+
* `WidgetPlugin.capabilities`"): presence is required-key *declaration*, independent of the capability's
|
|
63
|
+
* own payload type. It must never be implemented by testing whether `WidgetCapabilityOf<...>` is
|
|
64
|
+
* `never` — a legitimately-present capability can itself have payload `never` (the canonical
|
|
65
|
+
* explicit-empty spelling for `slots`, e.g. `slots: never`), which would otherwise be indistinguishable
|
|
66
|
+
* from a capability that was never declared at all. `Interfaces extends Record<Key, unknown>` checks
|
|
67
|
+
* required-property presence directly: an optional inherited declaration (`config?: X` left unnarrowed)
|
|
68
|
+
* is not assignable to a shape requiring `Key`, so it correctly stays `false`.
|
|
69
|
+
*/
|
|
70
|
+
type HasWidgetCapability<Interfaces extends WidgetInterfaces, Key extends keyof WidgetInterfaces> = Interfaces extends Record<Key, unknown> ? true : false;
|
|
71
|
+
/**
|
|
72
|
+
* Indexes a declared member record without requiring the key to be statically provable.
|
|
73
|
+
*/
|
|
74
|
+
type WidgetMemberValueOf<Members, Key extends WidgetMemberKey> = Key extends keyof Members ? Members[Key] : never;
|
|
75
|
+
type WidgetRawConfigOf<Interfaces extends WidgetInterfaces> = WidgetCapabilityOf<Interfaces, 'config'> extends {
|
|
76
|
+
raw: infer Raw;
|
|
77
|
+
} ? Raw : never;
|
|
78
|
+
type WidgetResolvedConfigOf<Interfaces extends WidgetInterfaces> = WidgetCapabilityOf<Interfaces, 'config'> extends {
|
|
79
|
+
resolved: infer Resolved;
|
|
80
|
+
} ? Resolved : never;
|
|
81
|
+
type WidgetSlotNameOf<Interfaces extends WidgetInterfaces> = Extract<WidgetCapabilityOf<Interfaces, 'slots'>, WidgetMemberKey>;
|
|
82
|
+
type WidgetStateOf<Interfaces extends WidgetInterfaces> = WidgetCapabilityOf<Interfaces, 'state'>;
|
|
83
|
+
type WidgetPropertiesOf<Interfaces extends WidgetInterfaces> = WidgetCapabilityOf<Interfaces, 'properties'>;
|
|
84
|
+
type WidgetMethodsOf<Interfaces extends WidgetInterfaces> = WidgetCapabilityOf<Interfaces, 'methods'> extends (infer Methods extends Record<WidgetMemberKey, (...args: any[]) => any>) ? Methods : never;
|
|
85
|
+
/**
|
|
86
|
+
* Declared member keys of one section, or `never` when the capability is absent.
|
|
87
|
+
*/
|
|
88
|
+
type WidgetMemberKeysOf<Members> = [Members] extends [never] ? never : Extract<keyof Members, WidgetMemberKey>;
|
|
89
|
+
type WidgetStateKeyOf<Interfaces extends WidgetInterfaces> = WidgetMemberKeysOf<WidgetStateOf<Interfaces>>;
|
|
90
|
+
type WidgetPropertyKeyOf<Interfaces extends WidgetInterfaces> = WidgetMemberKeysOf<WidgetPropertiesOf<Interfaces>>;
|
|
91
|
+
type WidgetMethodKeyOf<Interfaces extends WidgetInterfaces> = WidgetMemberKeysOf<WidgetMethodsOf<Interfaces>>;
|
|
92
|
+
type WidgetStateValueOf<Interfaces extends WidgetInterfaces, Key extends WidgetMemberKey> = WidgetMemberValueOf<WidgetStateOf<Interfaces>, Key>;
|
|
93
|
+
type WidgetPropertyValueOf<Interfaces extends WidgetInterfaces, Name extends WidgetMemberKey> = WidgetMemberValueOf<WidgetPropertiesOf<Interfaces>, Name>;
|
|
94
|
+
type WidgetMethodOf<Interfaces extends WidgetInterfaces, Name extends WidgetMemberKey> = Extract<WidgetMemberValueOf<WidgetMethodsOf<Interfaces>, Name>, (...args: any[]) => any>;
|
|
95
|
+
type WidgetMethodArgsOf<Interfaces extends WidgetInterfaces, Name extends WidgetMemberKey> = Parameters<WidgetMethodOf<Interfaces, Name>>;
|
|
96
|
+
type WidgetMethodReturnOf<Interfaces extends WidgetInterfaces, Name extends WidgetMemberKey> = ReturnType<WidgetMethodOf<Interfaces, Name>>;
|
|
97
|
+
type ContainsPromiseLike<Value> = IsAny<Value> extends true ? false : [Extract<Value, PromiseLike<unknown>>] extends [never] ? false : true;
|
|
98
|
+
type MemberKeyDomainViolation<Section extends string, Members> = [Members] extends [never] ? never : [keyof Members] extends [never] ? never : [keyof Members] extends [WidgetMemberKey] ? WidgetMemberKey extends keyof Members ? `'${Section}' must not be declared with a broad string index signature` : never : `'${Section}' member keys must be finite string literals`;
|
|
99
|
+
type SyncValueDomainViolation<Section extends string, Members> = [Members] extends [never] ? never : true extends { [Key in keyof Members]-?: ContainsPromiseLike<Members[Key]>; }[keyof Members] ? `'${Section}' values must not be PromiseLike; the core semantic boundary is synchronous` : never;
|
|
100
|
+
type SyncMethodReturnViolation<Interfaces extends WidgetInterfaces> = WidgetMethodsOf<Interfaces> extends (infer Methods) ? [Methods] extends [never] ? never : true extends { [Key in keyof Methods]-?: ContainsPromiseLike<ReturnType<Extract<Methods[Key], (...args: any[]) => any>>>; }[keyof Methods] ? `'methods' return types must not be PromiseLike; the core semantic boundary is synchronous` : never : never;
|
|
101
|
+
type SlotDomainViolation<Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'slots'> extends false ? never : WidgetMemberKey extends WidgetCapabilityOf<Interfaces, 'slots'> ? `'slots' must be a finite union of string literals` : never;
|
|
102
|
+
type RawConfigDomainViolation<Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'config'> extends true ? JsonDomainViolation<WidgetRawConfigOf<Interfaces>> : never;
|
|
103
|
+
/**
|
|
104
|
+
* Every reason the supplied `WidgetInterfaces` cannot back a plugin builder, or `never` when valid.
|
|
105
|
+
*
|
|
106
|
+
* Rejection happens at the `.interfaces()` boundary so that a section can never start with an
|
|
107
|
+
* unfinishable `Remaining` such as `string`.
|
|
108
|
+
*/
|
|
109
|
+
type WidgetInterfacesViolationOf<Interfaces extends WidgetInterfaces> = MemberKeyDomainViolation<'state', WidgetStateOf<Interfaces>> | MemberKeyDomainViolation<'properties', WidgetPropertiesOf<Interfaces>> | MemberKeyDomainViolation<'methods', WidgetMethodsOf<Interfaces>> | SlotDomainViolation<Interfaces> | RawConfigDomainViolation<Interfaces> | SyncValueDomainViolation<'state', WidgetStateOf<Interfaces>> | SyncValueDomainViolation<'properties', WidgetPropertiesOf<Interfaces>> | SyncMethodReturnViolation<Interfaces>;
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/execution-result.d.ts
|
|
112
|
+
interface ExecutionFailure<Diagnostic> {
|
|
113
|
+
readonly diagnostics: NonEmptyReadonlyArray<Diagnostic>;
|
|
114
|
+
}
|
|
115
|
+
/** Domain-specific execution outcome. There is intentionally no public generic `Result` alias. */
|
|
116
|
+
type ExecutionResult<T, Diagnostic> = {
|
|
117
|
+
readonly ok: true;
|
|
118
|
+
readonly value: T;
|
|
119
|
+
} | {
|
|
120
|
+
readonly ok: false;
|
|
121
|
+
readonly failure: ExecutionFailure<Diagnostic>;
|
|
122
|
+
};
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/plugin.d.ts
|
|
125
|
+
/**
|
|
126
|
+
* Framework-private brand carrying the plugin's phantom interfaces and its erased definition record.
|
|
127
|
+
*/
|
|
128
|
+
declare const widgetPluginBrand: unique symbol;
|
|
129
|
+
/**
|
|
130
|
+
* Framework-private section typestate markers.
|
|
131
|
+
*
|
|
132
|
+
* They exist so that an empty mapped object (`{}`) cannot accidentally satisfy a completed section
|
|
133
|
+
* type. They are never user-facing operations.
|
|
134
|
+
*/
|
|
135
|
+
declare const widgetSectionKind: unique symbol;
|
|
136
|
+
declare const widgetSectionRemaining: unique symbol;
|
|
137
|
+
interface ErasedWidgetConfigDefinition {
|
|
138
|
+
readonly description: string;
|
|
139
|
+
readonly validate: (input: unknown, ctx: any) => boolean;
|
|
140
|
+
readonly resolve: (rawConfig: any) => unknown;
|
|
141
|
+
}
|
|
142
|
+
interface ErasedWidgetSlotDefinition {
|
|
143
|
+
readonly description: string;
|
|
144
|
+
readonly validateStructure?: (ctx: any) => void;
|
|
145
|
+
}
|
|
146
|
+
interface ErasedWidgetStateMemberDefinition {
|
|
147
|
+
readonly validate: (input: unknown, ctx: any) => boolean;
|
|
148
|
+
readonly default?: (ctx: any) => unknown;
|
|
149
|
+
}
|
|
150
|
+
interface ErasedWidgetPropertyDefinition {
|
|
151
|
+
readonly registerDeps?: (ctx: any) => RegisteredDeps;
|
|
152
|
+
readonly compute: (ctx: any) => unknown;
|
|
153
|
+
}
|
|
154
|
+
interface ErasedWidgetMethodDefinition {
|
|
155
|
+
readonly registerDeps?: (ctx: any) => RegisteredDeps;
|
|
156
|
+
readonly validateArgs: (args: readonly unknown[], ctx: any) => boolean;
|
|
157
|
+
readonly execute: (ctx: any) => unknown;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Erased plugin definition record.
|
|
161
|
+
*
|
|
162
|
+
* `null` means the capability was not declared. Member registries are `Map`s so that declaration
|
|
163
|
+
* order is preserved and special JavaScript names (`constructor`, `__proto__`, ...) stay safe.
|
|
164
|
+
*/
|
|
165
|
+
interface WidgetPluginDefinition {
|
|
166
|
+
readonly type: string;
|
|
167
|
+
readonly description: string;
|
|
168
|
+
readonly config: ErasedWidgetConfigDefinition | null;
|
|
169
|
+
readonly slots: ReadonlyMap<WidgetMemberKey, ErasedWidgetSlotDefinition> | null;
|
|
170
|
+
readonly validateStructure: ((ctx: any) => void) | null;
|
|
171
|
+
readonly state: ReadonlyMap<WidgetMemberKey, ErasedWidgetStateMemberDefinition> | null;
|
|
172
|
+
readonly properties: ReadonlyMap<WidgetMemberKey, ErasedWidgetPropertyDefinition> | null;
|
|
173
|
+
readonly methods: ReadonlyMap<WidgetMemberKey, ErasedWidgetMethodDefinition> | null;
|
|
174
|
+
}
|
|
175
|
+
interface WidgetPluginBrand<Interfaces extends WidgetInterfaces> {
|
|
176
|
+
readonly interfaces?: Interfaces;
|
|
177
|
+
readonly definition: WidgetPluginDefinition;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Renderer-agnostic runtime-readable capability-presence facts (diagnostic #10 amendment
|
|
181
|
+
* "declaration-presence semantics and public `WidgetPlugin.capabilities`"). Presence booleans only — no
|
|
182
|
+
* member inventories, callbacks, Blueprint state, Runtime state, diagnostics, or renderer concerns. Not
|
|
183
|
+
* an inspection/DevTools API: consumers that already hold the exact plugin object (e.g. a renderer
|
|
184
|
+
* adapter's `useWidget(plugin)`) read this instead of inferring presence from Blueprint object shape or
|
|
185
|
+
* importing `@deviltea/widget-core/inspection`. The shape intentionally matches
|
|
186
|
+
* `BlueprintInspectionCapabilities`, but no object-identity relationship between the two is part of the
|
|
187
|
+
* contract.
|
|
188
|
+
*/
|
|
189
|
+
interface WidgetPluginCapabilities {
|
|
190
|
+
readonly config: boolean;
|
|
191
|
+
readonly slots: boolean;
|
|
192
|
+
readonly state: boolean;
|
|
193
|
+
readonly properties: boolean;
|
|
194
|
+
readonly methods: boolean;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* A completed plugin. Plugin-specific integration options are captured by the plugin factory's
|
|
198
|
+
* closure; there is no `pluginConfig` / `globalConfig`.
|
|
199
|
+
*/
|
|
200
|
+
interface WidgetPlugin<Type extends string = string, Interfaces extends WidgetInterfaces = WidgetInterfaces> {
|
|
201
|
+
readonly type: Type;
|
|
202
|
+
readonly description: string;
|
|
203
|
+
/** Compiler/plugin-builder-authoritative declaration-presence facts. Immutable, stable for the plugin's lifetime. */
|
|
204
|
+
readonly capabilities: WidgetPluginCapabilities;
|
|
205
|
+
readonly descriptions: {
|
|
206
|
+
readonly config: string | null;
|
|
207
|
+
readonly slots: ReadonlyMap<WidgetMemberKey, string> | null;
|
|
208
|
+
};
|
|
209
|
+
readonly [widgetPluginBrand]: WidgetPluginBrand<Interfaces>;
|
|
210
|
+
}
|
|
211
|
+
type AnyWidgetPlugin = WidgetPlugin<string, WidgetInterfaces>;
|
|
212
|
+
type AnyWidgetPluginTuple = readonly AnyWidgetPlugin[];
|
|
213
|
+
type WidgetPluginTypeOf<Plugin extends AnyWidgetPlugin> = Plugin extends WidgetPlugin<infer Type, any> ? Type : never;
|
|
214
|
+
type WidgetInterfacesOf<Plugin extends AnyWidgetPlugin> = Plugin extends WidgetPlugin<any, infer Interfaces> ? Interfaces : never;
|
|
215
|
+
/**
|
|
216
|
+
* Conditional resolved-config context fragment. Resolves to `unknown` (an intersection identity)
|
|
217
|
+
* when the plugin has no config capability.
|
|
218
|
+
*/
|
|
219
|
+
type WidgetResolvedConfigContext<Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'config'> extends true ? {
|
|
220
|
+
readonly config: WidgetResolvedConfigOf<Interfaces>;
|
|
221
|
+
} : unknown;
|
|
222
|
+
type WidgetConfigValidateContext = DiagnosticCollector<RelativeValueDiagnosticInput>;
|
|
223
|
+
type WidgetStateValidateContext<Interfaces extends WidgetInterfaces> = DiagnosticCollector<RelativeValueDiagnosticInput> & WidgetResolvedConfigContext<Interfaces>;
|
|
224
|
+
type WidgetStateDefaultContext<Interfaces extends WidgetInterfaces> = WidgetResolvedConfigContext<Interfaces>;
|
|
225
|
+
type WidgetMethodValidateArgsContext<Interfaces extends WidgetInterfaces> = DiagnosticCollector<RelativeValueDiagnosticInput> & WidgetResolvedConfigContext<Interfaces>;
|
|
226
|
+
type WidgetSlotValidateStructureContext<Interfaces extends WidgetInterfaces, SlotName extends WidgetMemberKey> = {
|
|
227
|
+
readonly widget: SelfBlueprintWidgetNodeView<Interfaces>;
|
|
228
|
+
readonly slot: SlotName;
|
|
229
|
+
readonly children: readonly BlueprintWidgetNodeView[];
|
|
230
|
+
readonly blueprint: BlueprintCompileView;
|
|
231
|
+
} & DiagnosticCollector<RelativeSlotStructureDiagnosticInput> & WidgetResolvedConfigContext<Interfaces>;
|
|
232
|
+
type WidgetPluginValidateStructureContext<Interfaces extends WidgetInterfaces> = {
|
|
233
|
+
readonly widget: SelfBlueprintWidgetNodeView<Interfaces>;
|
|
234
|
+
readonly blueprint: BlueprintCompileView;
|
|
235
|
+
} & DiagnosticCollector<RelativePluginStructureDiagnosticInput<WidgetSlotNameOf<Interfaces>>> & WidgetResolvedConfigContext<Interfaces>;
|
|
236
|
+
/**
|
|
237
|
+
* `registerDeps` runs once per Blueprint snapshot. It sees the compile semantic view and resolved
|
|
238
|
+
* config, and has no runtime values and no diagnostic collector.
|
|
239
|
+
*/
|
|
240
|
+
type WidgetRegisterDepsContext<Interfaces extends WidgetInterfaces, Consumer extends DependencyConsumer> = {
|
|
241
|
+
readonly widget: SelfBlueprintWidgetNodeView<Interfaces>;
|
|
242
|
+
readonly blueprint: BlueprintCompileView;
|
|
243
|
+
readonly dep: DependencyBuilder<Interfaces, Consumer>;
|
|
244
|
+
} & WidgetResolvedConfigContext<Interfaces>;
|
|
245
|
+
type WidgetPropertyComputeContext<Interfaces extends WidgetInterfaces, Deps extends RegisteredDeps> = {
|
|
246
|
+
readonly widget: SelfBlueprintWidgetNode<Interfaces>;
|
|
247
|
+
readonly blueprint: ValidBlueprintView;
|
|
248
|
+
readonly deps: ToExecutedDeps<Deps, 'property'>;
|
|
249
|
+
} & DiagnosticCollector<RelativeValueDiagnosticInput> & WidgetResolvedConfigContext<Interfaces>;
|
|
250
|
+
type WidgetMethodExecuteContext<Interfaces extends WidgetInterfaces, Name extends WidgetMemberKey, Deps extends RegisteredDeps> = {
|
|
251
|
+
readonly args: WidgetMethodArgsOf<Interfaces, Name>;
|
|
252
|
+
readonly widget: SelfBlueprintWidgetNode<Interfaces>;
|
|
253
|
+
readonly blueprint: ValidBlueprintView;
|
|
254
|
+
readonly deps: ToExecutedDeps<Deps, 'method'>;
|
|
255
|
+
} & DiagnosticCollector<RelativeValueDiagnosticInput> & WidgetResolvedConfigContext<Interfaces>;
|
|
256
|
+
interface WidgetConfigDefinition<Interfaces extends WidgetInterfaces> {
|
|
257
|
+
readonly description: string;
|
|
258
|
+
readonly validate: (input: unknown, ctx: WidgetConfigValidateContext) => input is WidgetRawConfigOf<Interfaces>;
|
|
259
|
+
readonly resolve: (rawConfig: WidgetRawConfigOf<Interfaces> | null) => WidgetResolvedConfigOf<Interfaces>;
|
|
260
|
+
}
|
|
261
|
+
interface WidgetSlotDefinition<Interfaces extends WidgetInterfaces, SlotName extends WidgetMemberKey> {
|
|
262
|
+
readonly description: string;
|
|
263
|
+
readonly validateStructure?: (ctx: WidgetSlotValidateStructureContext<Interfaces, SlotName>) => void;
|
|
264
|
+
}
|
|
265
|
+
type WidgetSlotDefinitions<Interfaces extends WidgetInterfaces> = { readonly [Name in WidgetSlotNameOf<Interfaces>]: WidgetSlotDefinition<Interfaces, Name>; };
|
|
266
|
+
/**
|
|
267
|
+
* Rejects a slots object that carries a slot the interfaces never declared, including when the
|
|
268
|
+
* object is supplied through a variable instead of a fresh object literal.
|
|
269
|
+
*/
|
|
270
|
+
type ExactWidgetSlotDefinitions<Interfaces extends WidgetInterfaces, Definitions> = WidgetSlotDefinitions<Interfaces> & { readonly [Name in keyof Definitions as Name extends WidgetSlotNameOf<Interfaces> ? never : Name]: never; };
|
|
271
|
+
type WidgetPluginValidateStructure<Interfaces extends WidgetInterfaces> = (ctx: WidgetPluginValidateStructureContext<Interfaces>) => void;
|
|
272
|
+
interface WidgetStateMemberDefinition<Interfaces extends WidgetInterfaces, Key extends WidgetMemberKey> {
|
|
273
|
+
readonly validate: (input: unknown, ctx: WidgetStateValidateContext<Interfaces>) => input is WidgetStateValueOf<Interfaces, Key>;
|
|
274
|
+
readonly default?: (ctx: WidgetStateDefaultContext<Interfaces>) => WidgetStateValueOf<Interfaces, Key>;
|
|
275
|
+
}
|
|
276
|
+
interface WidgetPropertyDefinition<Interfaces extends WidgetInterfaces, Name extends WidgetMemberKey, Deps extends RegisteredDeps> {
|
|
277
|
+
readonly registerDeps?: (ctx: WidgetRegisterDepsContext<Interfaces, 'property'>) => Deps;
|
|
278
|
+
readonly compute: (ctx: WidgetPropertyComputeContext<Interfaces, Deps>) => WidgetPropertyValueOf<Interfaces, Name>;
|
|
279
|
+
}
|
|
280
|
+
interface WidgetMethodDefinition<Interfaces extends WidgetInterfaces, Name extends WidgetMemberKey, Deps extends RegisteredDeps> {
|
|
281
|
+
readonly registerDeps?: (ctx: WidgetRegisterDepsContext<Interfaces, 'method'>) => Deps;
|
|
282
|
+
readonly validateArgs: (args: readonly unknown[], ctx: WidgetMethodValidateArgsContext<Interfaces>) => args is WidgetMethodArgsOf<Interfaces, Name>;
|
|
283
|
+
readonly execute: (ctx: WidgetMethodExecuteContext<Interfaces, Name, Deps>) => WidgetMethodReturnOf<Interfaces, Name>;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Phantom section typestate. `Remaining` is part of the marker type, so a section is complete only
|
|
287
|
+
* when `Remaining` has been reduced to `never`.
|
|
288
|
+
*/
|
|
289
|
+
interface WidgetSectionMarker<Kind extends string, Remaining extends WidgetMemberKey> {
|
|
290
|
+
readonly [widgetSectionKind]: Kind;
|
|
291
|
+
readonly [widgetSectionRemaining]: Remaining;
|
|
292
|
+
}
|
|
293
|
+
type WidgetStateSection<Interfaces extends WidgetInterfaces, Remaining extends WidgetStateKeyOf<Interfaces>> = WidgetSectionMarker<'state', Remaining> & { [Key in Remaining]: (definition: WidgetStateMemberDefinition<Interfaces, Key>) => WidgetStateSection<Interfaces, Exclude<Remaining, Key>>; };
|
|
294
|
+
type WidgetPropertiesSection<Interfaces extends WidgetInterfaces, Remaining extends WidgetPropertyKeyOf<Interfaces>> = WidgetSectionMarker<'properties', Remaining> & { [Name in Remaining]: <const Deps extends RegisteredDeps = EmptyRegisteredDeps>(definition: WidgetPropertyDefinition<Interfaces, Name, Deps>) => WidgetPropertiesSection<Interfaces, Exclude<Remaining, Name>>; };
|
|
295
|
+
type WidgetMethodsSection<Interfaces extends WidgetInterfaces, Remaining extends WidgetMethodKeyOf<Interfaces>> = WidgetSectionMarker<'methods', Remaining> & { [Name in Remaining]: <const Deps extends RegisteredDeps = EmptyRegisteredDeps>(definition: WidgetMethodDefinition<Interfaces, Name, Deps>) => WidgetMethodsSection<Interfaces, Exclude<Remaining, Name>>; };
|
|
296
|
+
/**
|
|
297
|
+
* Returned instead of the next builder phase when the supplied `WidgetInterfaces` is outside the
|
|
298
|
+
* supported declaration domain. It exposes no builder operation, so the chain cannot continue.
|
|
299
|
+
*/
|
|
300
|
+
interface WidgetInterfacesViolation<Reason extends string> {
|
|
301
|
+
readonly 'widget-core: unsupported WidgetInterfaces': Reason;
|
|
302
|
+
}
|
|
303
|
+
interface WidgetPluginDonePhase<Type extends string, Interfaces extends WidgetInterfaces> {
|
|
304
|
+
done: () => WidgetPlugin<Type, Interfaces>;
|
|
305
|
+
}
|
|
306
|
+
type WidgetPluginMethodsPhase<Type extends string, Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'methods'> extends true ? {
|
|
307
|
+
methods: (build: (section: WidgetMethodsSection<Interfaces, WidgetMethodKeyOf<Interfaces>>) => WidgetMethodsSection<Interfaces, never>) => WidgetPluginDonePhase<Type, Interfaces>;
|
|
308
|
+
} : WidgetPluginDonePhase<Type, Interfaces>;
|
|
309
|
+
type WidgetPluginPropertiesPhase<Type extends string, Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'properties'> extends true ? {
|
|
310
|
+
properties: (build: (section: WidgetPropertiesSection<Interfaces, WidgetPropertyKeyOf<Interfaces>>) => WidgetPropertiesSection<Interfaces, never>) => WidgetPluginMethodsPhase<Type, Interfaces>;
|
|
311
|
+
} : WidgetPluginMethodsPhase<Type, Interfaces>;
|
|
312
|
+
type WidgetPluginStatePhase<Type extends string, Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'state'> extends true ? {
|
|
313
|
+
state: (build: (section: WidgetStateSection<Interfaces, WidgetStateKeyOf<Interfaces>>) => WidgetStateSection<Interfaces, never>) => WidgetPluginPropertiesPhase<Type, Interfaces>;
|
|
314
|
+
} : WidgetPluginPropertiesPhase<Type, Interfaces>;
|
|
315
|
+
/**
|
|
316
|
+
* `slots: never` is the canonical explicit-empty slots declaration (diagnostic #10 amendment
|
|
317
|
+
* "declaration-presence semantics and public `WidgetPlugin.capabilities`"): the phase still exists —
|
|
318
|
+
* gated on `HasWidgetCapability`, never on whether `WidgetCapabilityOf<Interfaces, 'slots'>` happens to
|
|
319
|
+
* be `never` — and completes as `.slots({})`, since `ExactWidgetSlotDefinitions` for zero slot names is
|
|
320
|
+
* exactly `{}`.
|
|
321
|
+
*/
|
|
322
|
+
type WidgetPluginSlotsPhase<Type extends string, Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'slots'> extends true ? {
|
|
323
|
+
slots: <const Definitions extends ExactWidgetSlotDefinitions<Interfaces, Definitions>>(definitions: Definitions, validateStructure?: WidgetPluginValidateStructure<Interfaces>) => WidgetPluginStatePhase<Type, Interfaces>;
|
|
324
|
+
} : WidgetPluginStatePhase<Type, Interfaces>;
|
|
325
|
+
type WidgetPluginConfigPhase<Type extends string, Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'config'> extends true ? {
|
|
326
|
+
config: (definition: WidgetConfigDefinition<Interfaces>) => WidgetPluginSlotsPhase<Type, Interfaces>;
|
|
327
|
+
} : WidgetPluginSlotsPhase<Type, Interfaces>;
|
|
328
|
+
interface WidgetPluginInterfacesPhase<Type extends string> {
|
|
329
|
+
interfaces: <Interfaces extends WidgetInterfaces>() => [WidgetInterfacesViolationOf<Interfaces>] extends [never] ? WidgetPluginConfigPhase<Type, Interfaces> : WidgetInterfacesViolation<WidgetInterfacesViolationOf<Interfaces>>;
|
|
330
|
+
}
|
|
331
|
+
interface WidgetPluginDescriptionPhase<Type extends string> {
|
|
332
|
+
description: (description: string) => WidgetPluginInterfacesPhase<Type>;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Starts the plugin builder for one plugin `type`.
|
|
336
|
+
*
|
|
337
|
+
* Phase order is `interfaces -> config? -> slots? -> state? -> properties? -> methods? -> done()`;
|
|
338
|
+
* a phase exists only when its capability is declared.
|
|
339
|
+
*/
|
|
340
|
+
declare function createWidgetPlugin<const Type extends string>(type: Type): WidgetPluginDescriptionPhase<Type>;
|
|
341
|
+
//#endregion
|
|
342
|
+
//#region src/system.d.ts
|
|
343
|
+
interface WidgetCatalogEntry {
|
|
344
|
+
readonly type: string;
|
|
345
|
+
readonly description: string;
|
|
346
|
+
readonly descriptions: {
|
|
347
|
+
readonly config: string | null;
|
|
348
|
+
readonly slots: ReadonlyMap<string, string> | null;
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
interface WidgetCatalog {
|
|
352
|
+
readonly widgets: readonly WidgetCatalogEntry[];
|
|
353
|
+
}
|
|
354
|
+
type WidgetSystemValidateStructureContext<Plugins extends AnyWidgetPluginTuple> = {
|
|
355
|
+
readonly blueprint: BlueprintCompileView<Plugins>;
|
|
356
|
+
} & DiagnosticCollector<RelativeSystemStructureDiagnosticInput<Plugins>>;
|
|
357
|
+
type WidgetSystemValidateStructure<Plugins extends AnyWidgetPluginTuple> = (ctx: WidgetSystemValidateStructureContext<Plugins>) => void;
|
|
358
|
+
interface CreateWidgetSystemOptions<Plugins extends AnyWidgetPluginTuple> {
|
|
359
|
+
readonly plugins: Plugins;
|
|
360
|
+
readonly validateStructure?: WidgetSystemValidateStructure<Plugins>;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Selects one registered plugin by its `type` discriminator.
|
|
364
|
+
*/
|
|
365
|
+
type WidgetPluginOf<Plugins extends AnyWidgetPluginTuple, Type extends string> = Extract<Plugins[number], {
|
|
366
|
+
readonly type: Type;
|
|
367
|
+
}>;
|
|
368
|
+
interface WidgetSystem<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> {
|
|
369
|
+
/**
|
|
370
|
+
* The registered plugin tuple. It defines this instance's TypeScript universe; there is no
|
|
371
|
+
* global/module augmentation.
|
|
372
|
+
*/
|
|
373
|
+
readonly plugins: Plugins;
|
|
374
|
+
readonly validateStructure: WidgetSystemValidateStructure<Plugins> | null;
|
|
375
|
+
readonly catalog: WidgetCatalog;
|
|
376
|
+
getPlugin: <Type extends WidgetPluginTypeOf<Plugins[number]>>(type: Type) => WidgetPluginOf<Plugins, Type>;
|
|
377
|
+
/**
|
|
378
|
+
* The compilation boundary. The input is `unknown` because JSON-parsed/untrusted document data is
|
|
379
|
+
* the real boundary; malformed input still produces an inspectable Blueprint.
|
|
380
|
+
*/
|
|
381
|
+
createBlueprint: (definition: unknown) => WidgetSystemBlueprint<Plugins>;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Creates an instance-scoped, immutable widget system. Duplicate `plugin.type` is rejected.
|
|
385
|
+
*/
|
|
386
|
+
declare function createWidgetSystem<const Plugins extends AnyWidgetPluginTuple>(options: CreateWidgetSystemOptions<Plugins>): WidgetSystem<Plugins>;
|
|
387
|
+
//#endregion
|
|
388
|
+
//#region src/internal/contract.d.ts
|
|
389
|
+
type WidgetSystemBlueprintStatus = 'valid' | 'invalid';
|
|
390
|
+
interface BlueprintWidgetNodeBase<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple, Source = unknown> {
|
|
391
|
+
/**
|
|
392
|
+
* The exact source fragment for this recovered node. Never mutated, cloned or frozen by the core.
|
|
393
|
+
*/
|
|
394
|
+
readonly source: Source;
|
|
395
|
+
readonly diagnostics: readonly BlueprintNodeDiagnostic<Plugins>[];
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* A node whose widget semantic identity could not be established (missing/invalid `id`,
|
|
399
|
+
* missing/invalid `type`, or unknown plugin type).
|
|
400
|
+
*/
|
|
401
|
+
interface UnresolvedBlueprintWidgetNode<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple, Source = unknown> extends BlueprintWidgetNodeBase<Plugins, Source> {
|
|
402
|
+
readonly resolved: false;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Complete declared semantic slot map. Only declared slots appear, every declared slot exists, and an
|
|
406
|
+
* empty slot is an empty array. A plugin without slot capability has `{}`.
|
|
407
|
+
*/
|
|
408
|
+
type BlueprintSemanticSlots<Interfaces extends WidgetInterfaces, Plugins extends AnyWidgetPluginTuple, Source = unknown> = { readonly [Name in WidgetSlotNameOf<Interfaces>]: readonly BlueprintWidgetNode<Plugins, Source>[]; };
|
|
409
|
+
type BlueprintNodeConfigFields<Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'config'> extends true ? {
|
|
410
|
+
/**
|
|
411
|
+
* Typed raw config, or `null` when the raw config was omitted or invalid. The exact source
|
|
412
|
+
* fragment always stays available through `source`.
|
|
413
|
+
*/
|
|
414
|
+
readonly rawConfig: WidgetRawConfigOf<Interfaces> | null;
|
|
415
|
+
readonly config: WidgetResolvedConfigOf<Interfaces>;
|
|
416
|
+
} : unknown;
|
|
417
|
+
/**
|
|
418
|
+
* A node with established widget semantic identity. Later config/slot/structure/dependency errors keep
|
|
419
|
+
* the node resolved while the Blueprint becomes invalid.
|
|
420
|
+
*/
|
|
421
|
+
type ResolvedBlueprintWidgetNodeFor<Plugin extends AnyWidgetPlugin, Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple, Source = unknown> = BlueprintWidgetNodeBase<Plugins, Source> & {
|
|
422
|
+
readonly resolved: true;
|
|
423
|
+
readonly id: WidgetId;
|
|
424
|
+
readonly type: WidgetPluginTypeOf<Plugin>;
|
|
425
|
+
readonly plugin: Plugin;
|
|
426
|
+
readonly slots: BlueprintSemanticSlots<WidgetInterfacesOf<Plugin>, Plugins, Source>;
|
|
427
|
+
} & BlueprintNodeConfigFields<WidgetInterfacesOf<Plugin>>;
|
|
428
|
+
type ResolvedBlueprintWidgetNode<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple, Source = unknown> = Plugins[number] extends (infer Plugin) ? Plugin extends AnyWidgetPlugin ? ResolvedBlueprintWidgetNodeFor<Plugin, Plugins, Source> : never : never;
|
|
429
|
+
type BlueprintWidgetNode<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple, Source = unknown> = UnresolvedBlueprintWidgetNode<Plugins, Source> | ResolvedBlueprintWidgetNode<Plugins, Source>;
|
|
430
|
+
/**
|
|
431
|
+
* The semantic node type a plugin author sees for its own widget.
|
|
432
|
+
*/
|
|
433
|
+
type SelfBlueprintWidgetNode<Interfaces extends WidgetInterfaces> = ResolvedBlueprintWidgetNodeFor<WidgetPlugin<string, Interfaces>, AnyWidgetPluginTuple, JsonValue>;
|
|
434
|
+
/**
|
|
435
|
+
* Compile-time view of {@link BlueprintSemanticSlots}: same complete declared-slot map, but every
|
|
436
|
+
* child is a {@link BlueprintWidgetNodeView} instead of a full node — the view is recursive all the
|
|
437
|
+
* way down, not just at the top level.
|
|
438
|
+
*/
|
|
439
|
+
type BlueprintSemanticSlotsView<Interfaces extends WidgetInterfaces, Plugins extends AnyWidgetPluginTuple, Source = unknown> = { readonly [Name in WidgetSlotNameOf<Interfaces>]: readonly BlueprintWidgetNodeView<Plugins, Source>[]; };
|
|
440
|
+
/**
|
|
441
|
+
* Compile-time view of {@link ResolvedBlueprintWidgetNodeFor}: no `diagnostics`, and `.slots`'
|
|
442
|
+
* children are themselves views (recursive), not full nodes.
|
|
443
|
+
*/
|
|
444
|
+
type ResolvedBlueprintWidgetNodeViewFor<Plugin extends AnyWidgetPlugin, Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple, Source = unknown> = Omit<ResolvedBlueprintWidgetNodeFor<Plugin, Plugins, Source>, 'diagnostics' | 'slots'> & {
|
|
445
|
+
readonly slots: BlueprintSemanticSlotsView<WidgetInterfacesOf<Plugin>, Plugins, Source>;
|
|
446
|
+
};
|
|
447
|
+
/**
|
|
448
|
+
* The resolved-only compile-time node view, distributed over the registered plugin tuple, for
|
|
449
|
+
* compile-time locations that are only reachable from a resolved node (slot / slot-child).
|
|
450
|
+
*/
|
|
451
|
+
type ResolvedBlueprintWidgetNodeView<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple, Source = unknown> = Plugins[number] extends (infer Plugin) ? Plugin extends AnyWidgetPlugin ? ResolvedBlueprintWidgetNodeViewFor<Plugin, Plugins, Source> : never : never;
|
|
452
|
+
/**
|
|
453
|
+
* Compile-time view of {@link BlueprintWidgetNode}: same navigation shape, but with `diagnostics`
|
|
454
|
+
* removed recursively — including through `.slots`' children — not just at the top level.
|
|
455
|
+
*
|
|
456
|
+
* Used only for the types compile-time callbacks (`validateStructure`, `registerDeps`) and
|
|
457
|
+
* {@link BlueprintCompileView} see. Backed by a genuinely restricted, frozen runtime facade object —
|
|
458
|
+
* not the same node object the finalized Blueprint later exposes — so a facade never physically has
|
|
459
|
+
* `diagnostics` and no callback can reassign a navigation method to corrupt the view later callbacks in
|
|
460
|
+
* the same compile pass observe. Facade identity is snapshot-local to one compile pass; the finalized
|
|
461
|
+
* Blueprint's nodes (which do carry `diagnostics`) are separate full-node objects built once
|
|
462
|
+
* compilation completes, because no final diagnostic snapshot exists yet while compilation is in progress.
|
|
463
|
+
*/
|
|
464
|
+
type BlueprintWidgetNodeView<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple, Source = unknown> = Omit<UnresolvedBlueprintWidgetNode<Plugins, Source>, 'diagnostics'> | ResolvedBlueprintWidgetNodeView<Plugins, Source>;
|
|
465
|
+
/**
|
|
466
|
+
* Compile-time view of {@link SelfBlueprintWidgetNode}, for the same reason as
|
|
467
|
+
* {@link BlueprintWidgetNodeView}.
|
|
468
|
+
*/
|
|
469
|
+
type SelfBlueprintWidgetNodeView<Interfaces extends WidgetInterfaces> = ResolvedBlueprintWidgetNodeViewFor<WidgetPlugin<string, Interfaces>>;
|
|
470
|
+
/**
|
|
471
|
+
* Topology/navigation placement of a recovered node.
|
|
472
|
+
*
|
|
473
|
+
* `slot` is a confirmed semantic slot edge; `raw-slot` is a recovered source edge that was not
|
|
474
|
+
* confirmed semantically.
|
|
475
|
+
*/
|
|
476
|
+
type WidgetLocation<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple, Source = unknown> = {
|
|
477
|
+
readonly type: 'root';
|
|
478
|
+
} | {
|
|
479
|
+
readonly type: 'slot';
|
|
480
|
+
readonly parent: ResolvedBlueprintWidgetNode<Plugins, Source>;
|
|
481
|
+
readonly slot: WidgetMemberKey;
|
|
482
|
+
readonly index: number;
|
|
483
|
+
} | {
|
|
484
|
+
readonly type: 'raw-slot';
|
|
485
|
+
readonly parent: BlueprintWidgetNode<Plugins, Source>;
|
|
486
|
+
readonly slot: string;
|
|
487
|
+
readonly index: number;
|
|
488
|
+
};
|
|
489
|
+
/**
|
|
490
|
+
* Compile-time view of {@link WidgetLocation}: same topology shape, but `parent` is a
|
|
491
|
+
* {@link BlueprintWidgetNodeView} / {@link ResolvedBlueprintWidgetNodeView} rather than a full node —
|
|
492
|
+
* a `validateStructure`/`registerDeps` author reaching a location through `BlueprintCompileView`
|
|
493
|
+
* cannot get from there to `diagnostics` either.
|
|
494
|
+
*/
|
|
495
|
+
type WidgetLocationView<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple, Source = unknown> = {
|
|
496
|
+
readonly type: 'root';
|
|
497
|
+
} | {
|
|
498
|
+
readonly type: 'slot';
|
|
499
|
+
readonly parent: ResolvedBlueprintWidgetNodeView<Plugins, Source>;
|
|
500
|
+
readonly slot: WidgetMemberKey;
|
|
501
|
+
readonly index: number;
|
|
502
|
+
} | {
|
|
503
|
+
readonly type: 'raw-slot';
|
|
504
|
+
readonly parent: BlueprintWidgetNodeView<Plugins, Source>;
|
|
505
|
+
readonly slot: string;
|
|
506
|
+
readonly index: number;
|
|
507
|
+
};
|
|
508
|
+
/**
|
|
509
|
+
* Read-only semantic view handed to compile-time callbacks (`validateStructure`, `registerDeps`).
|
|
510
|
+
*
|
|
511
|
+
* It intentionally exposes no `diagnostics`, no final status, and no runtime machinery, because
|
|
512
|
+
* compilation is still in progress. Every field is `readonly` — the concrete runtime object the
|
|
513
|
+
* compiler hands out is additionally frozen, so plugin code cannot reassign a navigation method to
|
|
514
|
+
* corrupt the view later callbacks in the same compile pass see.
|
|
515
|
+
*/
|
|
516
|
+
interface BlueprintCompileView<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> {
|
|
517
|
+
readonly root: BlueprintWidgetNodeView<Plugins>;
|
|
518
|
+
readonly getWidget: (id: WidgetId) => BlueprintWidgetNodeView<Plugins> | null;
|
|
519
|
+
readonly getParent: (node: BlueprintWidgetNodeView<Plugins>) => BlueprintWidgetNodeView<Plugins> | null;
|
|
520
|
+
readonly getLocation: (node: BlueprintWidgetNodeView<Plugins>) => WidgetLocationView<Plugins> | null;
|
|
521
|
+
readonly getChildren: (node: BlueprintWidgetNodeView<Plugins>) => readonly BlueprintWidgetNodeView<Plugins>[];
|
|
522
|
+
readonly getChildrenAt: (node: BlueprintWidgetNodeView<Plugins>, slot: WidgetMemberKey) => readonly BlueprintWidgetNodeView<Plugins>[];
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Read-only valid-Blueprint view handed to runtime semantic callbacks (`compute`, `execute`).
|
|
526
|
+
*/
|
|
527
|
+
interface ValidBlueprintView<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> {
|
|
528
|
+
readonly root: ResolvedBlueprintWidgetNode<Plugins, JsonValue>;
|
|
529
|
+
getWidget: (id: WidgetId) => ResolvedBlueprintWidgetNode<Plugins, JsonValue> | null;
|
|
530
|
+
getParent: (node: ResolvedBlueprintWidgetNode<Plugins>) => ResolvedBlueprintWidgetNode<Plugins, JsonValue> | null;
|
|
531
|
+
getLocation: (node: ResolvedBlueprintWidgetNode<Plugins>) => WidgetLocation<Plugins, JsonValue> | null;
|
|
532
|
+
getChildren: (node: ResolvedBlueprintWidgetNode<Plugins>) => readonly ResolvedBlueprintWidgetNode<Plugins, JsonValue>[];
|
|
533
|
+
getChildrenAt: (node: ResolvedBlueprintWidgetNode<Plugins>, slot: WidgetMemberKey) => readonly ResolvedBlueprintWidgetNode<Plugins, JsonValue>[];
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Typed raw representation of one widget. Not the compiler input type: `createBlueprint` takes
|
|
537
|
+
* `unknown` because JSON-parsed/untrusted input is the real boundary.
|
|
538
|
+
*/
|
|
539
|
+
type WidgetSourceFor<Plugin extends AnyWidgetPlugin, Plugins extends AnyWidgetPluginTuple> = {
|
|
540
|
+
readonly id: WidgetId;
|
|
541
|
+
readonly type: WidgetPluginTypeOf<Plugin>;
|
|
542
|
+
} & (HasWidgetCapability<WidgetInterfacesOf<Plugin>, 'config'> extends true ? {
|
|
543
|
+
readonly config?: WidgetRawConfigOf<WidgetInterfacesOf<Plugin>>;
|
|
544
|
+
} : unknown) & (HasWidgetCapability<WidgetInterfacesOf<Plugin>, 'slots'> extends true ? {
|
|
545
|
+
readonly slots?: { readonly [Name in WidgetSlotNameOf<WidgetInterfacesOf<Plugin>>]?: readonly WidgetSource<Plugins>[]; };
|
|
546
|
+
} : unknown);
|
|
547
|
+
type WidgetSource<Plugins extends AnyWidgetPluginTuple> = Plugins[number] extends (infer Plugin) ? Plugin extends AnyWidgetPlugin ? WidgetSourceFor<Plugin, Plugins> : never : never;
|
|
548
|
+
interface WidgetSystemBlueprintBase<Plugins extends AnyWidgetPluginTuple, Source = unknown> {
|
|
549
|
+
readonly system: WidgetSystem<Plugins>;
|
|
550
|
+
/**
|
|
551
|
+
* The exact entire unknown input this Blueprint was compiled from.
|
|
552
|
+
*/
|
|
553
|
+
readonly source: Source;
|
|
554
|
+
readonly sourceJsonCompatible: boolean;
|
|
555
|
+
/**
|
|
556
|
+
* Observably equivalent to `blueprint.system.createBlueprint(next)`.
|
|
557
|
+
*/
|
|
558
|
+
recompile: (definition: unknown) => WidgetSystemBlueprint<Plugins>;
|
|
559
|
+
}
|
|
560
|
+
interface ValidWidgetSystemBlueprint<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> extends WidgetSystemBlueprintBase<Plugins, JsonValue> {
|
|
561
|
+
readonly status: 'valid';
|
|
562
|
+
readonly sourceJsonCompatible: true;
|
|
563
|
+
readonly root: ResolvedBlueprintWidgetNode<Plugins, JsonValue>;
|
|
564
|
+
getWidget: (id: WidgetId) => ResolvedBlueprintWidgetNode<Plugins, JsonValue> | null;
|
|
565
|
+
getParent: (node: BlueprintWidgetNode<Plugins>) => ResolvedBlueprintWidgetNode<Plugins, JsonValue> | null;
|
|
566
|
+
getLocation: (node: BlueprintWidgetNode<Plugins>) => WidgetLocation<Plugins, JsonValue> | null;
|
|
567
|
+
getChildren: (node: BlueprintWidgetNode<Plugins>) => readonly ResolvedBlueprintWidgetNode<Plugins, JsonValue>[];
|
|
568
|
+
getChildrenAt: (node: BlueprintWidgetNode<Plugins>, slot: WidgetMemberKey) => readonly ResolvedBlueprintWidgetNode<Plugins, JsonValue>[];
|
|
569
|
+
readonly diagnostics: readonly never[];
|
|
570
|
+
createRuntime: (options?: CreateWidgetSystemRuntimeOptions) => WidgetSystemRuntime<Plugins>;
|
|
571
|
+
}
|
|
572
|
+
interface InvalidWidgetSystemBlueprint<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple, Source = unknown, Compatible extends boolean = boolean> extends WidgetSystemBlueprintBase<Plugins, Source> {
|
|
573
|
+
readonly status: 'invalid';
|
|
574
|
+
readonly sourceJsonCompatible: Compatible;
|
|
575
|
+
readonly root: BlueprintWidgetNode<Plugins, Source>;
|
|
576
|
+
getWidget: (id: WidgetId) => BlueprintWidgetNode<Plugins, Source> | null;
|
|
577
|
+
getParent: (node: BlueprintWidgetNode<Plugins>) => BlueprintWidgetNode<Plugins, Source> | null;
|
|
578
|
+
getLocation: (node: BlueprintWidgetNode<Plugins>) => WidgetLocation<Plugins, Source> | null;
|
|
579
|
+
getChildren: (node: BlueprintWidgetNode<Plugins>) => readonly BlueprintWidgetNode<Plugins, Source>[];
|
|
580
|
+
getChildrenAt: (node: BlueprintWidgetNode<Plugins>, slot: WidgetMemberKey) => readonly BlueprintWidgetNode<Plugins, Source>[];
|
|
581
|
+
readonly diagnostics: readonly BlueprintDiagnostic<Plugins>[];
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Immutable compiled semantic snapshot of one unknown/raw widget tree.
|
|
585
|
+
*
|
|
586
|
+
* A valid Blueprint narrows every node query to resolved nodes, narrows collected diagnostics to empty and
|
|
587
|
+
* is the only variant exposing `createRuntime`.
|
|
588
|
+
*/
|
|
589
|
+
type WidgetSystemBlueprint<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> = ValidWidgetSystemBlueprint<Plugins> | InvalidWidgetSystemBlueprint<Plugins, JsonValue, true> | InvalidWidgetSystemBlueprint<Plugins, unknown, false>;
|
|
590
|
+
interface CreateWidgetSystemRuntimeOptions {
|
|
591
|
+
/**
|
|
592
|
+
* Initialization-only, best-effort candidate map. Own-property presence decides whether an
|
|
593
|
+
* override exists, so an explicit `undefined` is still an explicit candidate.
|
|
594
|
+
*/
|
|
595
|
+
readonly overrideStateDefaults?: Readonly<Record<WidgetId, Readonly<Record<WidgetMemberKey, unknown>>>>;
|
|
596
|
+
}
|
|
597
|
+
interface RuntimeState<T> {
|
|
598
|
+
get: () => T | null;
|
|
599
|
+
set: (value: T) => ExecutionResult<T, RuntimeStateDiagnostic>;
|
|
600
|
+
subscribe: (listener: (value: T | null) => void) => () => void;
|
|
601
|
+
getDiagnostics: () => readonly RuntimeStateDiagnostic[];
|
|
602
|
+
subscribeDiagnostics: (listener: (diagnostics: readonly RuntimeStateDiagnostic[]) => void) => () => void;
|
|
603
|
+
}
|
|
604
|
+
interface RuntimeProperty<T> {
|
|
605
|
+
get: () => ExecutionResult<T | null, RuntimePropertyDiagnostic>;
|
|
606
|
+
subscribe: (listener: (result: ExecutionResult<T | null, RuntimePropertyDiagnostic>) => void) => () => void;
|
|
607
|
+
getDiagnostics: () => readonly RuntimePropertyDiagnostic[];
|
|
608
|
+
subscribeDiagnostics: (listener: (diagnostics: readonly RuntimePropertyDiagnostic[]) => void) => () => void;
|
|
609
|
+
}
|
|
610
|
+
interface RuntimeMethod<Fn extends (...args: any[]) => any> {
|
|
611
|
+
(...args: Parameters<Fn>): ExecutionResult<ReturnType<Fn> | null, RuntimeMethodDiagnostic>;
|
|
612
|
+
getDiagnostics: () => readonly RuntimeMethodDiagnostic[];
|
|
613
|
+
subscribeDiagnostics: (listener: (diagnostics: readonly RuntimeMethodDiagnostic[]) => void) => () => void;
|
|
614
|
+
}
|
|
615
|
+
type RuntimeStateSurface<Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'state'> extends true ? {
|
|
616
|
+
readonly state: { readonly [Key in WidgetStateKeyOf<Interfaces>]: RuntimeState<WidgetStateValueOf<Interfaces, Key>>; };
|
|
617
|
+
} : unknown;
|
|
618
|
+
type RuntimePropertySurface<Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'properties'> extends true ? {
|
|
619
|
+
readonly properties: { readonly [Name in WidgetPropertyKeyOf<Interfaces>]: RuntimeProperty<WidgetPropertyValueOf<Interfaces, Name>>; };
|
|
620
|
+
} : unknown;
|
|
621
|
+
/**
|
|
622
|
+
* Gated on capability presence (`HasWidgetCapability`), not on the declared member-key union: an
|
|
623
|
+
* explicitly-declared-empty `methods: Record<never, never>` capability is present (and therefore
|
|
624
|
+
* exposes an empty `methods` surface), matching Runtime assembly's `definition.methods !== null` check.
|
|
625
|
+
* Gating on `WidgetMethodKeyOf` instead would collapse "declared empty" into "absent" because both have
|
|
626
|
+
* an empty key union; gating on `[WidgetMethodsOf<Interfaces>] extends [never]` would additionally
|
|
627
|
+
* misclassify any capability whose *payload* itself is `never` (diagnostic #10 amendment "declaration-presence
|
|
628
|
+
* semantics and public `WidgetPlugin.capabilities`").
|
|
629
|
+
*/
|
|
630
|
+
type RuntimeMethodSurface<Interfaces extends WidgetInterfaces> = HasWidgetCapability<Interfaces, 'methods'> extends true ? {
|
|
631
|
+
readonly methods: { readonly [Name in WidgetMethodKeyOf<Interfaces>]: RuntimeMethod<WidgetMethodOf<Interfaces, Name>>; };
|
|
632
|
+
} : unknown;
|
|
633
|
+
type RuntimeWidgetFor<Plugin extends AnyWidgetPlugin, Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> = {
|
|
634
|
+
readonly id: WidgetId;
|
|
635
|
+
readonly type: WidgetPluginTypeOf<Plugin>;
|
|
636
|
+
readonly blueprint: ResolvedBlueprintWidgetNodeFor<Plugin, Plugins>;
|
|
637
|
+
/**
|
|
638
|
+
* This widget's own aggregate diagnostic snapshot: state members -> property members -> method
|
|
639
|
+
* members, declaration order within each capability, each primitive's own local diagnostic order.
|
|
640
|
+
* Present regardless of declared capabilities (a widget with none aggregates to `[]`). Never
|
|
641
|
+
* includes Runtime-level diagnostics.
|
|
642
|
+
*/
|
|
643
|
+
getDiagnostics: () => readonly RuntimeWidgetDiagnostic[];
|
|
644
|
+
subscribeDiagnostics: (listener: (diagnostics: readonly RuntimeWidgetDiagnostic[]) => void) => () => void;
|
|
645
|
+
} & RuntimeStateSurface<WidgetInterfacesOf<Plugin>> & RuntimePropertySurface<WidgetInterfacesOf<Plugin>> & RuntimeMethodSurface<WidgetInterfacesOf<Plugin>>;
|
|
646
|
+
type RuntimeWidget<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> = Plugins[number] extends (infer Plugin) ? Plugin extends AnyWidgetPlugin ? RuntimeWidgetFor<Plugin, Plugins> : never : never;
|
|
647
|
+
/**
|
|
648
|
+
* Executable instance of a valid Blueprint.
|
|
649
|
+
*
|
|
650
|
+
* After `dispose()`, `isDisposed` and `blueprint` stay readable while every live query/operation and
|
|
651
|
+
* every new subscription throws `WidgetSystemRuntimeDisposedError`.
|
|
652
|
+
*/
|
|
653
|
+
interface WidgetSystemRuntime<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> {
|
|
654
|
+
readonly blueprint: ValidWidgetSystemBlueprint<Plugins>;
|
|
655
|
+
readonly isDisposed: boolean;
|
|
656
|
+
getWidget: (id: WidgetId) => RuntimeWidget<Plugins> | null;
|
|
657
|
+
/**
|
|
658
|
+
* Runtime-level diagnostics plus the current state/property/method diagnostic snapshots, in deterministic
|
|
659
|
+
* order. Never history, and never activates property evaluation.
|
|
660
|
+
*/
|
|
661
|
+
getDiagnostics: () => readonly WidgetSystemRuntimeDiagnostic[];
|
|
662
|
+
subscribeDiagnostics: (listener: (diagnostics: readonly WidgetSystemRuntimeDiagnostic[]) => void) => () => void;
|
|
663
|
+
dispose: () => void;
|
|
664
|
+
}
|
|
665
|
+
//#endregion
|
|
666
|
+
//#region src/diagnostic.d.ts
|
|
667
|
+
type DiagnosticPath = readonly PropertyKey[];
|
|
668
|
+
interface DiagnosticBase<Code extends string = string, Location = unknown> {
|
|
669
|
+
readonly code: Code;
|
|
670
|
+
readonly location: Location;
|
|
671
|
+
readonly message: string;
|
|
672
|
+
}
|
|
673
|
+
/** General structural diagnostic shape for code which does not need a narrower union. */
|
|
674
|
+
type Diagnostic<Code extends string = string, Location = unknown> = DiagnosticBase<Code, Location>;
|
|
675
|
+
declare const EMPTY_DIAGNOSTICS: readonly never[];
|
|
676
|
+
declare class WidgetSystemRuntimeDisposedError extends Error {
|
|
677
|
+
readonly name = "WidgetSystemRuntimeDisposedError";
|
|
678
|
+
readonly code: "runtime-disposed";
|
|
679
|
+
constructor(message?: string);
|
|
680
|
+
}
|
|
681
|
+
interface RelativeValueDiagnosticInput {
|
|
682
|
+
readonly message: string;
|
|
683
|
+
readonly path?: DiagnosticPath;
|
|
684
|
+
readonly reason?: string;
|
|
685
|
+
}
|
|
686
|
+
interface RelativeSlotStructureDiagnosticInput {
|
|
687
|
+
readonly message: string;
|
|
688
|
+
readonly index?: number;
|
|
689
|
+
readonly reason?: string;
|
|
690
|
+
}
|
|
691
|
+
type RelativePluginStructureDiagnosticInput<SlotName extends WidgetMemberKey = WidgetMemberKey> = {
|
|
692
|
+
readonly message: string;
|
|
693
|
+
readonly reason?: string;
|
|
694
|
+
} | {
|
|
695
|
+
readonly message: string;
|
|
696
|
+
readonly slot: SlotName;
|
|
697
|
+
readonly reason?: string;
|
|
698
|
+
} | {
|
|
699
|
+
readonly message: string;
|
|
700
|
+
readonly slot: SlotName;
|
|
701
|
+
readonly index: number;
|
|
702
|
+
readonly reason?: string;
|
|
703
|
+
};
|
|
704
|
+
type RelativeStructureDiagnosticLocation<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> = {
|
|
705
|
+
readonly type: 'widget';
|
|
706
|
+
readonly node: BlueprintWidgetNodeView<Plugins>;
|
|
707
|
+
} | {
|
|
708
|
+
readonly type: 'slot';
|
|
709
|
+
readonly node: ResolvedBlueprintWidgetNodeView<Plugins>;
|
|
710
|
+
readonly slot: WidgetMemberKey;
|
|
711
|
+
} | {
|
|
712
|
+
readonly type: 'slot-child';
|
|
713
|
+
readonly node: ResolvedBlueprintWidgetNodeView<Plugins>;
|
|
714
|
+
readonly slot: WidgetMemberKey;
|
|
715
|
+
readonly index: number;
|
|
716
|
+
};
|
|
717
|
+
interface RelativeSystemStructureDiagnosticInput<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> {
|
|
718
|
+
readonly message: string;
|
|
719
|
+
readonly location: RelativeStructureDiagnosticLocation<Plugins>;
|
|
720
|
+
readonly related?: NonEmptyReadonlyArray<RelativeStructureDiagnosticLocation<Plugins>>;
|
|
721
|
+
readonly reason?: string;
|
|
722
|
+
}
|
|
723
|
+
interface DiagnosticCollector<Input> {
|
|
724
|
+
addDiagnostic: (diagnostic: Input) => void;
|
|
725
|
+
hasAnyDiagnostic: () => boolean;
|
|
726
|
+
}
|
|
727
|
+
interface BlueprintSourceDiagnosticLocation {
|
|
728
|
+
readonly type: 'source';
|
|
729
|
+
}
|
|
730
|
+
interface BlueprintWidgetDiagnosticLocation<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> {
|
|
731
|
+
readonly type: 'widget';
|
|
732
|
+
readonly node: BlueprintWidgetNode<Plugins>;
|
|
733
|
+
}
|
|
734
|
+
interface BlueprintSlotDiagnosticLocation<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> {
|
|
735
|
+
readonly type: 'slot';
|
|
736
|
+
readonly node: ResolvedBlueprintWidgetNode<Plugins>;
|
|
737
|
+
readonly slot: WidgetMemberKey;
|
|
738
|
+
}
|
|
739
|
+
interface BlueprintSlotChildDiagnosticLocation<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> {
|
|
740
|
+
readonly type: 'slot-child';
|
|
741
|
+
readonly node: ResolvedBlueprintWidgetNode<Plugins>;
|
|
742
|
+
readonly slot: WidgetMemberKey;
|
|
743
|
+
readonly index: number;
|
|
744
|
+
}
|
|
745
|
+
interface BlueprintPropertyDiagnosticLocation<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> {
|
|
746
|
+
readonly type: 'property';
|
|
747
|
+
readonly node: ResolvedBlueprintWidgetNode<Plugins>;
|
|
748
|
+
readonly name: WidgetMemberKey;
|
|
749
|
+
}
|
|
750
|
+
interface BlueprintMethodDiagnosticLocation<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> {
|
|
751
|
+
readonly type: 'method';
|
|
752
|
+
readonly node: ResolvedBlueprintWidgetNode<Plugins>;
|
|
753
|
+
readonly name: WidgetMemberKey;
|
|
754
|
+
}
|
|
755
|
+
type BlueprintNodeDiagnosticLocation<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> = BlueprintWidgetDiagnosticLocation<Plugins> | BlueprintSlotDiagnosticLocation<Plugins> | BlueprintSlotChildDiagnosticLocation<Plugins> | BlueprintPropertyDiagnosticLocation<Plugins> | BlueprintMethodDiagnosticLocation<Plugins>;
|
|
756
|
+
type BlueprintDiagnosticLocation<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> = BlueprintSourceDiagnosticLocation | BlueprintNodeDiagnosticLocation<Plugins>;
|
|
757
|
+
type BlueprintStructureDiagnosticLocation<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> = BlueprintWidgetDiagnosticLocation<Plugins> | BlueprintSlotDiagnosticLocation<Plugins> | BlueprintSlotChildDiagnosticLocation<Plugins>;
|
|
758
|
+
type BlueprintDependencyDiagnosticLocation<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> = BlueprintWidgetDiagnosticLocation<Plugins> | BlueprintPropertyDiagnosticLocation<Plugins> | BlueprintMethodDiagnosticLocation<Plugins>;
|
|
759
|
+
interface BlueprintDependencyReference {
|
|
760
|
+
readonly target: {
|
|
761
|
+
readonly type: 'self';
|
|
762
|
+
} | {
|
|
763
|
+
readonly type: 'root';
|
|
764
|
+
} | {
|
|
765
|
+
readonly type: 'parent';
|
|
766
|
+
readonly optional: boolean;
|
|
767
|
+
} | {
|
|
768
|
+
readonly type: 'widget';
|
|
769
|
+
readonly widgetId: WidgetId;
|
|
770
|
+
readonly optional: boolean;
|
|
771
|
+
};
|
|
772
|
+
readonly operation: {
|
|
773
|
+
readonly type: 'state-get';
|
|
774
|
+
readonly key: WidgetMemberKey;
|
|
775
|
+
} | {
|
|
776
|
+
readonly type: 'state-set';
|
|
777
|
+
readonly key: WidgetMemberKey;
|
|
778
|
+
} | {
|
|
779
|
+
readonly type: 'property-get';
|
|
780
|
+
readonly name: WidgetMemberKey;
|
|
781
|
+
} | {
|
|
782
|
+
readonly type: 'method-invoke';
|
|
783
|
+
readonly name: WidgetMemberKey;
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
type BlueprintDependencyTarget = BlueprintDependencyReference['target'];
|
|
787
|
+
type BlueprintDependencyOperation = BlueprintDependencyReference['operation'];
|
|
788
|
+
type BlueprintDiagnosticRelated<Plugins extends AnyWidgetPluginTuple> = NonEmptyReadonlyArray<BlueprintNodeDiagnosticLocation<Plugins>>;
|
|
789
|
+
type BlueprintDefinitionDiagnostic<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> = DiagnosticBase<'invalid-widget-definition', BlueprintWidgetDiagnosticLocation<Plugins>> | (DiagnosticBase<'invalid-widget-id', BlueprintWidgetDiagnosticLocation<Plugins>> & {
|
|
790
|
+
readonly path: DiagnosticPath;
|
|
791
|
+
readonly related?: BlueprintDiagnosticRelated<Plugins>;
|
|
792
|
+
}) | (DiagnosticBase<'invalid-widget-type', BlueprintWidgetDiagnosticLocation<Plugins>> & {
|
|
793
|
+
readonly path: DiagnosticPath;
|
|
794
|
+
}) | (DiagnosticBase<'unknown-widget-type', BlueprintWidgetDiagnosticLocation<Plugins>> & {
|
|
795
|
+
readonly path: DiagnosticPath;
|
|
796
|
+
}) | (DiagnosticBase<'unexpected-widget-config', BlueprintWidgetDiagnosticLocation<Plugins>> & {
|
|
797
|
+
readonly path: DiagnosticPath;
|
|
798
|
+
}) | (DiagnosticBase<'invalid-widget-slots', BlueprintWidgetDiagnosticLocation<Plugins>> & {
|
|
799
|
+
readonly path: DiagnosticPath;
|
|
800
|
+
}) | (DiagnosticBase<'unexpected-widget-slots', BlueprintWidgetDiagnosticLocation<Plugins>> & {
|
|
801
|
+
readonly path: DiagnosticPath;
|
|
802
|
+
}) | (DiagnosticBase<'undeclared-widget-slot', BlueprintWidgetDiagnosticLocation<Plugins>> & {
|
|
803
|
+
readonly path: DiagnosticPath;
|
|
804
|
+
}) | (DiagnosticBase<'invalid-widget-slot', BlueprintWidgetDiagnosticLocation<Plugins>> & {
|
|
805
|
+
readonly path: DiagnosticPath;
|
|
806
|
+
});
|
|
807
|
+
type BlueprintConfigDiagnostic<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> = DiagnosticBase<'invalid-widget-config', BlueprintWidgetDiagnosticLocation<Plugins>> & {
|
|
808
|
+
readonly path?: DiagnosticPath;
|
|
809
|
+
readonly reason?: string;
|
|
810
|
+
};
|
|
811
|
+
type BlueprintStructureDiagnostic<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> = DiagnosticBase<'invalid-widget-structure', BlueprintStructureDiagnosticLocation<Plugins>> & {
|
|
812
|
+
readonly related?: NonEmptyReadonlyArray<BlueprintStructureDiagnosticLocation<Plugins>>;
|
|
813
|
+
readonly reason?: string;
|
|
814
|
+
};
|
|
815
|
+
type BlueprintDependencyDiagnostic<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> = (DiagnosticBase<'missing-dependency-target' | 'unresolved-dependency-target' | 'missing-dependency-capability' | 'missing-dependency-member', BlueprintDependencyDiagnosticLocation<Plugins>> & {
|
|
816
|
+
readonly dependency: BlueprintDependencyReference;
|
|
817
|
+
readonly related?: NonEmptyReadonlyArray<BlueprintDependencyDiagnosticLocation<Plugins>>;
|
|
818
|
+
}) | (DiagnosticBase<'ambiguous-dependency-target', BlueprintDependencyDiagnosticLocation<Plugins>> & {
|
|
819
|
+
readonly dependency: BlueprintDependencyReference;
|
|
820
|
+
readonly related: NonEmptyReadonlyArray<BlueprintDependencyDiagnosticLocation<Plugins>>;
|
|
821
|
+
}) | (DiagnosticBase<'property-dependency-has-write-effects', BlueprintDependencyDiagnosticLocation<Plugins>> & {
|
|
822
|
+
readonly dependency: BlueprintDependencyReference;
|
|
823
|
+
readonly related: NonEmptyReadonlyArray<BlueprintDependencyDiagnosticLocation<Plugins>>;
|
|
824
|
+
}) | (DiagnosticBase<'property-evaluation-cycle', BlueprintDependencyDiagnosticLocation<Plugins>> & {
|
|
825
|
+
readonly related?: NonEmptyReadonlyArray<BlueprintDependencyDiagnosticLocation<Plugins>>;
|
|
826
|
+
});
|
|
827
|
+
type JsonCompatibilityReason = 'undefined' | 'non-finite-number' | 'bigint' | 'symbol' | 'function' | 'unsupported-object-prototype' | 'symbol-key' | 'accessor-property' | 'sparse-array' | 'array-extra-property' | 'cyclic-reference';
|
|
828
|
+
type JsonCompatibilityDiagnostic = DiagnosticBase<'json-incompatible-value', BlueprintSourceDiagnosticLocation> & {
|
|
829
|
+
readonly path: DiagnosticPath;
|
|
830
|
+
readonly reason: JsonCompatibilityReason;
|
|
831
|
+
};
|
|
832
|
+
type SourceAccessDiagnostic = DiagnosticBase<'source-access-failed', BlueprintSourceDiagnosticLocation> & {
|
|
833
|
+
readonly path: DiagnosticPath;
|
|
834
|
+
};
|
|
835
|
+
type BlueprintSourceDiagnostic = JsonCompatibilityDiagnostic | SourceAccessDiagnostic;
|
|
836
|
+
type BlueprintNodeDiagnostic<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> = BlueprintDefinitionDiagnostic<Plugins> | BlueprintConfigDiagnostic<Plugins> | BlueprintStructureDiagnostic<Plugins> | BlueprintDependencyDiagnostic<Plugins>;
|
|
837
|
+
type BlueprintDiagnostic<Plugins extends AnyWidgetPluginTuple = AnyWidgetPluginTuple> = BlueprintSourceDiagnostic | BlueprintNodeDiagnostic<Plugins>;
|
|
838
|
+
type RuntimePrimitiveDiagnosticLocation = {
|
|
839
|
+
readonly type: 'state';
|
|
840
|
+
readonly widgetId: WidgetId;
|
|
841
|
+
readonly key: WidgetMemberKey;
|
|
842
|
+
} | {
|
|
843
|
+
readonly type: 'property';
|
|
844
|
+
readonly widgetId: WidgetId;
|
|
845
|
+
readonly name: WidgetMemberKey;
|
|
846
|
+
} | {
|
|
847
|
+
readonly type: 'method';
|
|
848
|
+
readonly widgetId: WidgetId;
|
|
849
|
+
readonly name: WidgetMemberKey;
|
|
850
|
+
};
|
|
851
|
+
interface RuntimeLevelDiagnosticLocation {
|
|
852
|
+
readonly type: 'runtime';
|
|
853
|
+
}
|
|
854
|
+
type RuntimeDiagnosticLocation = RuntimePrimitiveDiagnosticLocation;
|
|
855
|
+
type RuntimeStateDiagnostic = DiagnosticBase<'invalid-state-value', Extract<RuntimePrimitiveDiagnosticLocation, {
|
|
856
|
+
type: 'state';
|
|
857
|
+
}>> & {
|
|
858
|
+
readonly candidate: unknown;
|
|
859
|
+
readonly path?: DiagnosticPath;
|
|
860
|
+
readonly reason?: string;
|
|
861
|
+
};
|
|
862
|
+
type RuntimePropertyResultDiagnostic = DiagnosticBase<'invalid-property-result', Extract<RuntimePrimitiveDiagnosticLocation, {
|
|
863
|
+
type: 'property';
|
|
864
|
+
}>> & {
|
|
865
|
+
readonly result: unknown;
|
|
866
|
+
readonly path?: DiagnosticPath;
|
|
867
|
+
readonly reason?: string;
|
|
868
|
+
};
|
|
869
|
+
type RuntimeMethodArgsDiagnostic = DiagnosticBase<'invalid-method-arguments', Extract<RuntimePrimitiveDiagnosticLocation, {
|
|
870
|
+
type: 'method';
|
|
871
|
+
}>> & {
|
|
872
|
+
readonly args: readonly unknown[];
|
|
873
|
+
readonly path?: DiagnosticPath;
|
|
874
|
+
readonly reason?: string;
|
|
875
|
+
};
|
|
876
|
+
type RuntimeMethodResultDiagnostic = DiagnosticBase<'invalid-method-result', Extract<RuntimePrimitiveDiagnosticLocation, {
|
|
877
|
+
type: 'method';
|
|
878
|
+
}>> & {
|
|
879
|
+
readonly result: unknown;
|
|
880
|
+
readonly path?: DiagnosticPath;
|
|
881
|
+
readonly reason?: string;
|
|
882
|
+
};
|
|
883
|
+
type RuntimeDependencyTargetFailedDiagnostic = DiagnosticBase<'dependency-target-failed', RuntimePrimitiveDiagnosticLocation> & {
|
|
884
|
+
readonly dependency: BlueprintDependencyReference;
|
|
885
|
+
readonly related: NonEmptyReadonlyArray<RuntimePrimitiveDiagnosticLocation>;
|
|
886
|
+
readonly cause: RuntimeDiagnostic;
|
|
887
|
+
};
|
|
888
|
+
type RuntimeDependencyValueRejectedDiagnostic = DiagnosticBase<'dependency-value-rejected', RuntimePrimitiveDiagnosticLocation> & {
|
|
889
|
+
readonly dependency: BlueprintDependencyReference;
|
|
890
|
+
readonly related: NonEmptyReadonlyArray<RuntimePrimitiveDiagnosticLocation>;
|
|
891
|
+
readonly received: unknown;
|
|
892
|
+
};
|
|
893
|
+
type RuntimePropertyDependencyDiagnostic = (RuntimeDependencyTargetFailedDiagnostic | RuntimeDependencyValueRejectedDiagnostic) & {
|
|
894
|
+
readonly location: Extract<RuntimePrimitiveDiagnosticLocation, {
|
|
895
|
+
type: 'property';
|
|
896
|
+
}>;
|
|
897
|
+
};
|
|
898
|
+
type RuntimeMethodDependencyDiagnostic = (RuntimeDependencyTargetFailedDiagnostic | RuntimeDependencyValueRejectedDiagnostic) & {
|
|
899
|
+
readonly location: Extract<RuntimePrimitiveDiagnosticLocation, {
|
|
900
|
+
type: 'method';
|
|
901
|
+
}>;
|
|
902
|
+
};
|
|
903
|
+
type RuntimePropertyDiagnostic = RuntimePropertyResultDiagnostic | RuntimePropertyDependencyDiagnostic;
|
|
904
|
+
type RuntimeMethodDiagnostic = RuntimeMethodArgsDiagnostic | RuntimeMethodResultDiagnostic | RuntimeMethodDependencyDiagnostic;
|
|
905
|
+
type RuntimeDiagnostic = RuntimeStateDiagnostic | RuntimePropertyDiagnostic | RuntimeMethodDiagnostic;
|
|
906
|
+
type RuntimeLevelDiagnostic = (DiagnosticBase<'invalid-state-overrides', RuntimeLevelDiagnosticLocation> & {
|
|
907
|
+
readonly path?: DiagnosticPath;
|
|
908
|
+
readonly reason?: string;
|
|
909
|
+
}) | (DiagnosticBase<'unknown-state-override-widget', RuntimeLevelDiagnosticLocation> & {
|
|
910
|
+
readonly path: DiagnosticPath;
|
|
911
|
+
readonly reason?: string;
|
|
912
|
+
}) | (DiagnosticBase<'unsupported-state-override-target', RuntimeLevelDiagnosticLocation> & {
|
|
913
|
+
readonly path: DiagnosticPath;
|
|
914
|
+
readonly reason?: string;
|
|
915
|
+
}) | (DiagnosticBase<'invalid-state-override-fragment', RuntimeLevelDiagnosticLocation> & {
|
|
916
|
+
readonly path: DiagnosticPath;
|
|
917
|
+
readonly reason?: string;
|
|
918
|
+
}) | (DiagnosticBase<'unknown-state-override-member', RuntimeLevelDiagnosticLocation> & {
|
|
919
|
+
readonly path: DiagnosticPath;
|
|
920
|
+
readonly reason?: string;
|
|
921
|
+
});
|
|
922
|
+
type RuntimeWidgetDiagnostic = RuntimeStateDiagnostic | RuntimePropertyDiagnostic | RuntimeMethodDiagnostic;
|
|
923
|
+
type WidgetSystemRuntimeDiagnostic = RuntimeLevelDiagnostic | RuntimeWidgetDiagnostic;
|
|
924
|
+
//#endregion
|
|
925
|
+
//#region src/dep.d.ts
|
|
926
|
+
/**
|
|
927
|
+
* Framework-private brand of a dependency expression leaf.
|
|
928
|
+
*
|
|
929
|
+
* Plugin code must never construct an expression manually or read its internals; leaves are opaque
|
|
930
|
+
* and are only produced by the fluent `dep` builder.
|
|
931
|
+
*/
|
|
932
|
+
declare const depExpressionBrand: unique symbol;
|
|
933
|
+
type DependencyConsumer = 'property' | 'method';
|
|
934
|
+
/**
|
|
935
|
+
* Conservative optional-target nullability: only a provable literal `false` removes the
|
|
936
|
+
* absent-target `null`.
|
|
937
|
+
*/
|
|
938
|
+
type MaybeOptional<Value, Optional extends boolean> = [Optional] extends [false] ? Value : Value | null;
|
|
939
|
+
type DepExpressionMeta = {
|
|
940
|
+
readonly kind: 'state-get';
|
|
941
|
+
readonly value: unknown;
|
|
942
|
+
readonly optional: boolean;
|
|
943
|
+
} | {
|
|
944
|
+
readonly kind: 'state-set';
|
|
945
|
+
readonly input: unknown;
|
|
946
|
+
readonly optional: boolean;
|
|
947
|
+
} | {
|
|
948
|
+
readonly kind: 'property-get';
|
|
949
|
+
readonly value: unknown;
|
|
950
|
+
readonly optional: boolean;
|
|
951
|
+
} | {
|
|
952
|
+
readonly kind: 'method-invoke';
|
|
953
|
+
readonly args: readonly unknown[];
|
|
954
|
+
readonly value: unknown;
|
|
955
|
+
readonly optional: boolean;
|
|
956
|
+
};
|
|
957
|
+
/**
|
|
958
|
+
* Any branded dependency expression leaf.
|
|
959
|
+
*/
|
|
960
|
+
interface AnyDepExpression {
|
|
961
|
+
readonly [depExpressionBrand]: DepExpressionMeta;
|
|
962
|
+
}
|
|
963
|
+
interface StateGetDepExpression<Value, Optional extends boolean> {
|
|
964
|
+
readonly [depExpressionBrand]: {
|
|
965
|
+
readonly kind: 'state-get';
|
|
966
|
+
readonly value: Value;
|
|
967
|
+
readonly optional: Optional;
|
|
968
|
+
};
|
|
969
|
+
/**
|
|
970
|
+
* Pure refinement of the read value. Repeatable, narrowing only, never part of the stable
|
|
971
|
+
* public dependency reference, and skipped entirely when an optional target is absent.
|
|
972
|
+
*/
|
|
973
|
+
validate: <Refined extends Value>(validate: (input: Value) => input is Refined) => StateGetDepExpression<Refined, Optional>;
|
|
974
|
+
}
|
|
975
|
+
interface StateSetDepExpression<Input, Optional extends boolean> {
|
|
976
|
+
readonly [depExpressionBrand]: {
|
|
977
|
+
readonly kind: 'state-set';
|
|
978
|
+
readonly input: Input;
|
|
979
|
+
readonly optional: Optional;
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
interface PropertyGetDepExpression<Value, Optional extends boolean> {
|
|
983
|
+
readonly [depExpressionBrand]: {
|
|
984
|
+
readonly kind: 'property-get';
|
|
985
|
+
readonly value: Value;
|
|
986
|
+
readonly optional: Optional;
|
|
987
|
+
};
|
|
988
|
+
validate: <Refined extends Value>(validate: (input: Value) => input is Refined) => PropertyGetDepExpression<Refined, Optional>;
|
|
989
|
+
}
|
|
990
|
+
interface MethodInvokeDepExpression<Args extends readonly unknown[], Value, Optional extends boolean> {
|
|
991
|
+
readonly [depExpressionBrand]: {
|
|
992
|
+
readonly kind: 'method-invoke';
|
|
993
|
+
readonly args: Args;
|
|
994
|
+
readonly value: Value;
|
|
995
|
+
readonly optional: Optional;
|
|
996
|
+
};
|
|
997
|
+
validate: <Refined extends Value>(validate: (input: Value) => input is Refined) => MethodInvokeDepExpression<Args, Refined, Optional>;
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* Arbitrary recursive readonly container whose leaves are branded dependency expressions.
|
|
1001
|
+
*
|
|
1002
|
+
* Container shape is free organization only; `registerDeps` is not a static data transport.
|
|
1003
|
+
*/
|
|
1004
|
+
type RegisteredDeps = AnyDepExpression | {
|
|
1005
|
+
readonly [key: string]: RegisteredDeps;
|
|
1006
|
+
} | readonly RegisteredDeps[];
|
|
1007
|
+
/**
|
|
1008
|
+
* Default for a member declared without `registerDeps`.
|
|
1009
|
+
*/
|
|
1010
|
+
type EmptyRegisteredDeps = Record<never, never>;
|
|
1011
|
+
type DependencyDiagnosticOf<Consumer extends DependencyConsumer> = Consumer extends 'property' ? RuntimePropertyDependencyDiagnostic : RuntimeMethodDependencyDiagnostic;
|
|
1012
|
+
/**
|
|
1013
|
+
* Runtime materialization of one branded dependency leaf.
|
|
1014
|
+
*
|
|
1015
|
+
* Reads/invocations are callables returning `ExecutionResult`; state setters are write callables
|
|
1016
|
+
* whose absent-target no-op still succeeds with the original candidate.
|
|
1017
|
+
*/
|
|
1018
|
+
type ToExecutedDep<Expression, Consumer extends DependencyConsumer> = Expression extends {
|
|
1019
|
+
readonly [depExpressionBrand]: infer Meta;
|
|
1020
|
+
} ? Meta extends {
|
|
1021
|
+
readonly kind: 'state-get';
|
|
1022
|
+
readonly value: infer Value;
|
|
1023
|
+
readonly optional: infer Optional extends boolean;
|
|
1024
|
+
} ? () => ExecutionResult<MaybeOptional<Value, Optional>, DependencyDiagnosticOf<Consumer>> : Meta extends {
|
|
1025
|
+
readonly kind: 'state-set';
|
|
1026
|
+
readonly input: infer Input;
|
|
1027
|
+
readonly optional: boolean;
|
|
1028
|
+
} ? (candidate: Input) => ExecutionResult<Input, DependencyDiagnosticOf<Consumer>> : Meta extends {
|
|
1029
|
+
readonly kind: 'property-get';
|
|
1030
|
+
readonly value: infer Value;
|
|
1031
|
+
readonly optional: infer Optional extends boolean;
|
|
1032
|
+
} ? () => ExecutionResult<MaybeOptional<Value, Optional>, DependencyDiagnosticOf<Consumer>> : Meta extends {
|
|
1033
|
+
readonly kind: 'method-invoke';
|
|
1034
|
+
readonly args: infer Args extends readonly unknown[];
|
|
1035
|
+
readonly value: infer Value;
|
|
1036
|
+
readonly optional: infer Optional extends boolean;
|
|
1037
|
+
} ? (...args: Args) => ExecutionResult<MaybeOptional<Value, Optional>, DependencyDiagnosticOf<Consumer>> : never : never;
|
|
1038
|
+
/**
|
|
1039
|
+
* Recursively maps a registered dependency container to its executed form.
|
|
1040
|
+
*
|
|
1041
|
+
* The branded leaf test happens before container recursion, exact object/array/tuple shape is
|
|
1042
|
+
* preserved, and the result is recursively readonly.
|
|
1043
|
+
*/
|
|
1044
|
+
type ToExecutedDeps<Deps, Consumer extends DependencyConsumer> = Deps extends AnyDepExpression ? ToExecutedDep<Deps, Consumer> : Deps extends readonly unknown[] ? { readonly [Key in keyof Deps]: ToExecutedDeps<Deps[Key], Consumer>; } : Deps extends object ? { readonly [Key in keyof Deps]: ToExecutedDeps<Deps[Key], Consumer>; } : never;
|
|
1045
|
+
/**
|
|
1046
|
+
* Capability grammar of an unknown plugin target (`root` / `parent` / `widget(id)`).
|
|
1047
|
+
*
|
|
1048
|
+
* Capability and member existence are Blueprint dependency-resolution concerns, so the whole
|
|
1049
|
+
* grammar is exposed and read values start at `unknown` until `.validate()` refines them.
|
|
1050
|
+
*/
|
|
1051
|
+
interface UnknownTargetDependencyOperations<Consumer extends DependencyConsumer, Optional extends boolean> {
|
|
1052
|
+
readonly state: UnknownTargetStateDependencyOperations<Consumer, Optional>;
|
|
1053
|
+
readonly properties: {
|
|
1054
|
+
get: (name: WidgetMemberKey) => PropertyGetDepExpression<unknown, Optional>;
|
|
1055
|
+
};
|
|
1056
|
+
readonly methods: {
|
|
1057
|
+
invoke: (name: WidgetMemberKey) => MethodInvokeDepExpression<readonly unknown[], unknown, Optional>;
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
1060
|
+
type UnknownTargetStateDependencyOperations<Consumer extends DependencyConsumer, Optional extends boolean> = {
|
|
1061
|
+
get: (key: WidgetMemberKey) => StateGetDepExpression<unknown, Optional>;
|
|
1062
|
+
} & (Consumer extends 'method' ? {
|
|
1063
|
+
set: (key: WidgetMemberKey) => StateSetDepExpression<unknown, Optional>;
|
|
1064
|
+
} : unknown);
|
|
1065
|
+
/**
|
|
1066
|
+
* `parent` / `widget(id)` target stage. `optional()` is exposed only here and disappears as soon as a
|
|
1067
|
+
* capability is selected; it modifies target existence only.
|
|
1068
|
+
*/
|
|
1069
|
+
type OptionalizableDependencyTarget<Consumer extends DependencyConsumer> = UnknownTargetDependencyOperations<Consumer, false> & {
|
|
1070
|
+
optional: () => UnknownTargetDependencyOperations<Consumer, true>;
|
|
1071
|
+
};
|
|
1072
|
+
type SelfStateDependencyOperations<Interfaces extends WidgetInterfaces, Consumer extends DependencyConsumer> = {
|
|
1073
|
+
get: <Key extends WidgetStateKeyOf<Interfaces>>(key: Key) => StateGetDepExpression<WidgetStateValueOf<Interfaces, Key> | null, false>;
|
|
1074
|
+
} & (Consumer extends 'method' ? {
|
|
1075
|
+
set: <Key extends WidgetStateKeyOf<Interfaces>>(key: Key) => StateSetDepExpression<WidgetStateValueOf<Interfaces, Key>, false>;
|
|
1076
|
+
} : unknown);
|
|
1077
|
+
interface SelfPropertyDependencyOperations<Interfaces extends WidgetInterfaces> {
|
|
1078
|
+
get: <Name extends WidgetPropertyKeyOf<Interfaces>>(name: Name) => PropertyGetDepExpression<WidgetPropertyValueOf<Interfaces, Name> | null, false>;
|
|
1079
|
+
}
|
|
1080
|
+
interface SelfMethodDependencyOperations<Interfaces extends WidgetInterfaces> {
|
|
1081
|
+
invoke: <Name extends WidgetMethodKeyOf<Interfaces>>(name: Name) => MethodInvokeDepExpression<WidgetMethodArgsOf<Interfaces, Name>, WidgetMethodReturnOf<Interfaces, Name> | null, false>;
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1084
|
+
* `self` target stage: guaranteed target, strongly typed, and capability-aware.
|
|
1085
|
+
*
|
|
1086
|
+
* Gated on `HasWidgetCapability` (declaration presence), never on whether the capability's own payload
|
|
1087
|
+
* type happens to be `never` — a declared-but-explicitly-empty capability (e.g. `state: Record<never,
|
|
1088
|
+
* never>`) still exposes its `dep.self.state` surface, just with an uncallable-with-any-real-key `get`.
|
|
1089
|
+
*/
|
|
1090
|
+
type SelfDependencyTarget<Interfaces extends WidgetInterfaces, Consumer extends DependencyConsumer> = (HasWidgetCapability<Interfaces, 'state'> extends true ? {
|
|
1091
|
+
readonly state: SelfStateDependencyOperations<Interfaces, Consumer>;
|
|
1092
|
+
} : unknown) & (HasWidgetCapability<Interfaces, 'properties'> extends true ? {
|
|
1093
|
+
readonly properties: SelfPropertyDependencyOperations<Interfaces>;
|
|
1094
|
+
} : unknown) & (HasWidgetCapability<Interfaces, 'methods'> extends true ? {
|
|
1095
|
+
readonly methods: SelfMethodDependencyOperations<Interfaces>;
|
|
1096
|
+
} : unknown);
|
|
1097
|
+
/**
|
|
1098
|
+
* The `dep` grammar supplied to `registerDeps`.
|
|
1099
|
+
*
|
|
1100
|
+
* `dep.root` and `dep.widget(id)` stay unknown-typed even when they happen to designate the current
|
|
1101
|
+
* widget; precise typing is exclusive to `dep.self`.
|
|
1102
|
+
*/
|
|
1103
|
+
interface DependencyBuilder<Interfaces extends WidgetInterfaces, Consumer extends DependencyConsumer> {
|
|
1104
|
+
readonly self: SelfDependencyTarget<Interfaces, Consumer>;
|
|
1105
|
+
readonly root: UnknownTargetDependencyOperations<Consumer, false>;
|
|
1106
|
+
readonly parent: OptionalizableDependencyTarget<Consumer>;
|
|
1107
|
+
widget: (widgetId: WidgetId) => OptionalizableDependencyTarget<Consumer>;
|
|
1108
|
+
}
|
|
1109
|
+
//#endregion
|
|
1110
|
+
export { RuntimeDependencyValueRejectedDiagnostic as $, WidgetMethodReturnOf as $n, WidgetSystem as $t, BlueprintNodeDiagnostic as A, WidgetResolvedConfigContext as An, RuntimeMethodSurface as At, Diagnostic as B, ExecutionResult as Bn, ValidBlueprintView as Bt, BlueprintDependencyDiagnosticLocation as C, WidgetPluginTypeOf as Cn, CreateWidgetSystemRuntimeOptions as Ct, BlueprintDiagnostic as D, WidgetPropertyComputeContext as Dn, ResolvedBlueprintWidgetNodeView as Dt, BlueprintDependencyTarget as E, WidgetPropertiesSection as En, ResolvedBlueprintWidgetNodeFor as Et, BlueprintSourceDiagnostic as F, WidgetStateMemberDefinition as Fn, RuntimeWidget as Ft, JsonCompatibilityDiagnostic as G, WidgetInterfaces as Gn, WidgetSourceFor as Gt, DiagnosticCollector as H, NonEmptyReadonlyArray as Hn, WidgetLocation as Ht, BlueprintSourceDiagnosticLocation as I, WidgetStateSection as In, RuntimeWidgetFor as It, RelativeSlotStructureDiagnosticInput as J, WidgetMemberKeysOf as Jn, WidgetSystemRuntime as Jt, JsonCompatibilityReason as K, WidgetInterfacesViolationOf as Kn, WidgetSystemBlueprint as Kt, BlueprintStructureDiagnostic as L, WidgetStateValidateContext as Ln, SelfBlueprintWidgetNode as Lt, BlueprintPropertyDiagnosticLocation as M, WidgetSlotDefinitions as Mn, RuntimePropertySurface as Mt, BlueprintSlotChildDiagnosticLocation as N, WidgetSlotValidateStructureContext as Nn, RuntimeState as Nt, BlueprintDiagnosticLocation as O, WidgetPropertyDefinition as On, ResolvedBlueprintWidgetNodeViewFor as Ot, BlueprintSlotDiagnosticLocation as P, WidgetStateDefaultContext as Pn, RuntimeStateSurface as Pt, RuntimeDependencyTargetFailedDiagnostic as Q, WidgetMethodOf as Qn, WidgetPluginOf as Qt, BlueprintStructureDiagnosticLocation as R, createWidgetPlugin as Rn, SelfBlueprintWidgetNodeView as Rt, BlueprintDependencyDiagnostic as S, WidgetPluginStatePhase as Sn, BlueprintWidgetNodeView as St, BlueprintDependencyReference as T, WidgetPluginValidateStructureContext as Tn, ResolvedBlueprintWidgetNode as Tt, DiagnosticPath as U, WidgetCapabilityOf as Un, WidgetLocationView as Ut, DiagnosticBase as V, HasWidgetCapability as Vn, ValidWidgetSystemBlueprint as Vt, EMPTY_DIAGNOSTICS as W, WidgetId as Wn, WidgetSource as Wt, RelativeSystemStructureDiagnosticInput as X, WidgetMethodArgsOf as Xn, WidgetCatalog as Xt, RelativeStructureDiagnosticLocation as Y, WidgetMemberValueOf as Yn, CreateWidgetSystemOptions as Yt, RelativeValueDiagnosticInput as Z, WidgetMethodKeyOf as Zn, WidgetCatalogEntry as Zt, ToExecutedDeps as _, WidgetPluginDonePhase as _n, BlueprintNodeConfigFields as _t, MaybeOptional as a, WidgetConfigDefinition as an, WidgetResolvedConfigOf as ar, RuntimeMethodDependencyDiagnostic as at, BlueprintConfigDiagnostic as b, WidgetPluginPropertiesPhase as bn, BlueprintWidgetNode as bt, PropertyGetDepExpression as c, WidgetInterfacesViolation as cn, WidgetStateOf as cr, RuntimePropertyDependencyDiagnostic as ct, SelfMethodDependencyOperations as d, WidgetMethodValidateArgsContext as dn, JsonObject as dr, RuntimeStateDiagnostic as dt, WidgetSystemValidateStructure as en, WidgetMethodsOf as er, RuntimeDiagnostic as et, SelfPropertyDependencyOperations as f, WidgetMethodsSection as fn, JsonPrimitive as fr, RuntimeWidgetDiagnostic as ft, ToExecutedDep as g, WidgetPluginDescriptionPhase as gn, BlueprintCompileView as gt, StateSetDepExpression as h, WidgetPluginConfigPhase as hn, WidgetSystemRuntimeDisposedError as ht, EmptyRegisteredDeps as i, AnyWidgetPluginTuple as in, WidgetRawConfigOf as ir, RuntimeMethodArgsDiagnostic as it, BlueprintNodeDiagnosticLocation as j, WidgetSlotDefinition as jn, RuntimeProperty as jt, BlueprintMethodDiagnosticLocation as k, WidgetRegisterDepsContext as kn, RuntimeMethod as kt, RegisteredDeps as l, WidgetMethodDefinition as ln, WidgetStateValueOf as lr, RuntimePropertyDiagnostic as lt, StateGetDepExpression as m, WidgetPluginCapabilities as mn, WidgetSystemRuntimeDiagnostic as mt, DependencyBuilder as n, createWidgetSystem as nn, WidgetPropertyKeyOf as nr, RuntimeLevelDiagnostic as nt, MethodInvokeDepExpression as o, WidgetConfigValidateContext as on, WidgetSlotNameOf as or, RuntimeMethodDiagnostic as ot, SelfStateDependencyOperations as p, WidgetPlugin as pn, JsonValue as pr, SourceAccessDiagnostic as pt, RelativePluginStructureDiagnosticInput as q, WidgetMemberKey as qn, WidgetSystemBlueprintStatus as qt, DependencyConsumer as r, AnyWidgetPlugin as rn, WidgetPropertyValueOf as rr, RuntimeLevelDiagnosticLocation as rt, OptionalizableDependencyTarget as s, WidgetInterfacesOf as sn, WidgetStateKeyOf as sr, RuntimeMethodResultDiagnostic as st, AnyDepExpression as t, WidgetSystemValidateStructureContext as tn, WidgetPropertiesOf as tr, RuntimeDiagnosticLocation as tt, SelfDependencyTarget as u, WidgetMethodExecuteContext as un, JsonArray as ur, RuntimePropertyResultDiagnostic as ut, UnknownTargetDependencyOperations as v, WidgetPluginInterfacesPhase as vn, BlueprintSemanticSlots as vt, BlueprintDependencyOperation as w, WidgetPluginValidateStructure as wn, InvalidWidgetSystemBlueprint as wt, BlueprintDefinitionDiagnostic as x, WidgetPluginSlotsPhase as xn, BlueprintWidgetNodeBase as xt, UnknownTargetStateDependencyOperations as y, WidgetPluginMethodsPhase as yn, BlueprintSemanticSlotsView as yt, BlueprintWidgetDiagnosticLocation as z, ExecutionFailure as zn, UnresolvedBlueprintWidgetNode as zt };
|