@veil-runtime/ui 0.1.0 → 0.4.0
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/CHANGELOG.md +43 -0
- package/README.md +18 -10
- package/dist/build-manifest.json +26 -12
- package/dist/composition.d.ts +43 -0
- package/dist/composition.js +227 -0
- package/dist/dom.d.ts +31 -0
- package/dist/dom.js +569 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/input-schema.d.ts +4 -2
- package/dist/interface-transaction.d.ts +9 -0
- package/dist/interface-transaction.js +14 -0
- package/dist/interface.d.ts +261 -0
- package/dist/interface.js +524 -0
- package/dist/presentation-composition.d.ts +1 -1
- package/dist/presentation-composition.js +3 -1
- package/docs/API.md +4 -2
- package/docs/COMPOSITION.md +67 -0
- package/docs/DECISIONS.md +1 -1
- package/docs/RELEASE-0.3.0-rc.1.md +25 -0
- package/docs/RELEASE-0.3.0-rc.2.md +9 -0
- package/docs/RELEASE-0.4.0.md +9 -0
- package/docs/THIRD_PARTY.md +1 -1
- package/docs/UNIVERSAL-INTERFACE.md +105 -0
- package/docs/v0.4.0.md +47 -0
- package/examples/composed/app.mjs +44 -0
- package/examples/composed/build.mjs +7 -0
- package/examples/composed/index.html +34 -0
- package/examples/universal/agent.mjs +52 -0
- package/examples/universal/application.mjs +16 -0
- package/examples/universal/build.mjs +6 -0
- package/examples/universal/human.mjs +16 -0
- package/examples/universal/index.html +4 -0
- package/examples/universal/main.mjs +11 -0
- package/examples/universal/validated.mjs +21 -0
- package/package.json +24 -3
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
export type InterfaceValue = string | number | boolean | null;
|
|
2
|
+
export interface InterfaceBinding {
|
|
3
|
+
source: "data" | "state";
|
|
4
|
+
path: string;
|
|
5
|
+
}
|
|
6
|
+
export interface InterfaceCondition {
|
|
7
|
+
binding: InterfaceBinding;
|
|
8
|
+
equals: InterfaceValue;
|
|
9
|
+
}
|
|
10
|
+
export type InterfaceConditionExpression = InterfaceCondition | {
|
|
11
|
+
binding: InterfaceBinding;
|
|
12
|
+
operator: "ne" | "lt" | "lte" | "gt" | "gte";
|
|
13
|
+
value: InterfaceValue;
|
|
14
|
+
} | {
|
|
15
|
+
all: InterfaceConditionExpression[];
|
|
16
|
+
} | {
|
|
17
|
+
any: InterfaceConditionExpression[];
|
|
18
|
+
} | {
|
|
19
|
+
not: InterfaceConditionExpression;
|
|
20
|
+
};
|
|
21
|
+
export interface InterfaceValidation {
|
|
22
|
+
required?: boolean;
|
|
23
|
+
minLength?: number;
|
|
24
|
+
maxLength?: number;
|
|
25
|
+
min?: number;
|
|
26
|
+
max?: number;
|
|
27
|
+
}
|
|
28
|
+
export interface InterfaceOption {
|
|
29
|
+
value: string;
|
|
30
|
+
label: string;
|
|
31
|
+
}
|
|
32
|
+
export interface InterfaceColumn {
|
|
33
|
+
key: string;
|
|
34
|
+
label: string;
|
|
35
|
+
}
|
|
36
|
+
export interface InterfaceNode {
|
|
37
|
+
key: string;
|
|
38
|
+
component: string;
|
|
39
|
+
children?: InterfaceNode[];
|
|
40
|
+
text?: string | InterfaceBinding;
|
|
41
|
+
binding?: InterfaceBinding;
|
|
42
|
+
visible?: InterfaceConditionExpression;
|
|
43
|
+
disabled?: InterfaceConditionExpression;
|
|
44
|
+
validation?: InterfaceValidation;
|
|
45
|
+
options?: InterfaceOption[];
|
|
46
|
+
validate?: boolean;
|
|
47
|
+
action?: string;
|
|
48
|
+
label?: string;
|
|
49
|
+
inputType?: "text" | "number" | "checkbox";
|
|
50
|
+
columns?: InterfaceColumn[];
|
|
51
|
+
ariaLabel?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface InterfaceDefinition {
|
|
54
|
+
id: string;
|
|
55
|
+
screen: InterfaceNode;
|
|
56
|
+
actions?: string[];
|
|
57
|
+
data?: Record<string, unknown>;
|
|
58
|
+
state?: Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
/** Use `satisfies BuiltinInterfaceDefinition` for compile-time checks on JSON-only built-in screens. */
|
|
61
|
+
type BuiltinBase = Pick<InterfaceNode, "key" | "visible" | "ariaLabel">;
|
|
62
|
+
export type BuiltinInterfaceNode = (BuiltinBase & {
|
|
63
|
+
component: "Stack" | "Row";
|
|
64
|
+
children?: BuiltinInterfaceNode[];
|
|
65
|
+
}) | (BuiltinBase & {
|
|
66
|
+
component: "Text" | "Status";
|
|
67
|
+
text?: string | InterfaceBinding;
|
|
68
|
+
}) | (BuiltinBase & {
|
|
69
|
+
component: "Heading";
|
|
70
|
+
text: string | InterfaceBinding;
|
|
71
|
+
}) | (BuiltinBase & {
|
|
72
|
+
component: "Input";
|
|
73
|
+
label: string;
|
|
74
|
+
binding: InterfaceBinding & {
|
|
75
|
+
source: "state";
|
|
76
|
+
};
|
|
77
|
+
inputType?: "text" | "number" | "checkbox";
|
|
78
|
+
validation?: InterfaceValidation;
|
|
79
|
+
}) | (BuiltinBase & {
|
|
80
|
+
component: "Textarea";
|
|
81
|
+
label: string;
|
|
82
|
+
binding: InterfaceBinding & {
|
|
83
|
+
source: "state";
|
|
84
|
+
};
|
|
85
|
+
validation?: InterfaceValidation;
|
|
86
|
+
}) | (BuiltinBase & {
|
|
87
|
+
component: "Select";
|
|
88
|
+
label: string;
|
|
89
|
+
binding: InterfaceBinding & {
|
|
90
|
+
source: "state";
|
|
91
|
+
};
|
|
92
|
+
options: InterfaceOption[];
|
|
93
|
+
validation?: InterfaceValidation;
|
|
94
|
+
}) | (BuiltinBase & {
|
|
95
|
+
component: "Button";
|
|
96
|
+
text: string | InterfaceBinding;
|
|
97
|
+
action: string;
|
|
98
|
+
disabled?: InterfaceConditionExpression;
|
|
99
|
+
validate?: boolean;
|
|
100
|
+
}) | (BuiltinBase & {
|
|
101
|
+
component: "Table";
|
|
102
|
+
binding: InterfaceBinding;
|
|
103
|
+
columns: InterfaceColumn[];
|
|
104
|
+
}) | (BuiltinBase & {
|
|
105
|
+
component: "List";
|
|
106
|
+
binding: InterfaceBinding;
|
|
107
|
+
});
|
|
108
|
+
export type BuiltinInterfaceDefinition = Omit<InterfaceDefinition, "screen"> & {
|
|
109
|
+
screen: BuiltinInterfaceNode;
|
|
110
|
+
};
|
|
111
|
+
export interface InterfaceEvent {
|
|
112
|
+
action: string;
|
|
113
|
+
source: string;
|
|
114
|
+
state: Record<string, unknown>;
|
|
115
|
+
revision: number;
|
|
116
|
+
}
|
|
117
|
+
export interface InterfaceSnapshot {
|
|
118
|
+
definition: InterfaceDefinition;
|
|
119
|
+
data: Record<string, unknown>;
|
|
120
|
+
state: Record<string, unknown>;
|
|
121
|
+
revision: number;
|
|
122
|
+
}
|
|
123
|
+
export interface InterfaceController {
|
|
124
|
+
snapshot(): InterfaceSnapshot;
|
|
125
|
+
updateData(data: Record<string, unknown>, expectedRevision?: number): boolean;
|
|
126
|
+
updateDefinition(definition: InterfaceDefinition, expectedRevision?: number): boolean;
|
|
127
|
+
setState(path: string, value: InterfaceValue): void;
|
|
128
|
+
dispatch(action: string, source: string): void;
|
|
129
|
+
subscribe(listener: (snapshot: InterfaceSnapshot) => void): () => void;
|
|
130
|
+
dispose(): void;
|
|
131
|
+
}
|
|
132
|
+
/** JSON-safe description of the built-in vocabulary. Host extensions are trusted code and are never advertised here. */
|
|
133
|
+
export declare function getInterfaceCapabilities(): {
|
|
134
|
+
version: number;
|
|
135
|
+
components: {
|
|
136
|
+
readonly Stack: {
|
|
137
|
+
readonly properties: readonly ["key", "component", "visible", "ariaLabel", "children"];
|
|
138
|
+
readonly required: readonly [];
|
|
139
|
+
readonly children: true;
|
|
140
|
+
readonly event: null;
|
|
141
|
+
};
|
|
142
|
+
readonly Row: {
|
|
143
|
+
readonly properties: readonly ["key", "component", "visible", "ariaLabel", "children"];
|
|
144
|
+
readonly required: readonly [];
|
|
145
|
+
readonly children: true;
|
|
146
|
+
readonly event: null;
|
|
147
|
+
};
|
|
148
|
+
readonly Text: {
|
|
149
|
+
readonly properties: readonly ["key", "component", "visible", "ariaLabel", "text"];
|
|
150
|
+
readonly required: readonly [];
|
|
151
|
+
readonly children: false;
|
|
152
|
+
readonly event: null;
|
|
153
|
+
};
|
|
154
|
+
readonly Heading: {
|
|
155
|
+
readonly properties: readonly ["key", "component", "visible", "ariaLabel", "text"];
|
|
156
|
+
readonly required: readonly ["text"];
|
|
157
|
+
readonly children: false;
|
|
158
|
+
readonly event: null;
|
|
159
|
+
};
|
|
160
|
+
readonly Status: {
|
|
161
|
+
readonly properties: readonly ["key", "component", "visible", "ariaLabel", "text"];
|
|
162
|
+
readonly required: readonly [];
|
|
163
|
+
readonly children: false;
|
|
164
|
+
readonly event: null;
|
|
165
|
+
};
|
|
166
|
+
readonly Input: {
|
|
167
|
+
readonly properties: readonly ["key", "component", "visible", "ariaLabel", "label", "binding", "inputType", "validation"];
|
|
168
|
+
readonly required: readonly ["label", "binding"];
|
|
169
|
+
readonly children: false;
|
|
170
|
+
readonly event: "state change";
|
|
171
|
+
};
|
|
172
|
+
readonly Textarea: {
|
|
173
|
+
readonly properties: readonly ["key", "component", "visible", "ariaLabel", "label", "binding", "validation"];
|
|
174
|
+
readonly required: readonly ["label", "binding"];
|
|
175
|
+
readonly children: false;
|
|
176
|
+
readonly event: "state change";
|
|
177
|
+
};
|
|
178
|
+
readonly Select: {
|
|
179
|
+
readonly properties: readonly ["key", "component", "visible", "ariaLabel", "label", "binding", "validation", "options"];
|
|
180
|
+
readonly required: readonly ["label", "binding", "options"];
|
|
181
|
+
readonly children: false;
|
|
182
|
+
readonly event: "state change";
|
|
183
|
+
};
|
|
184
|
+
readonly Button: {
|
|
185
|
+
readonly properties: readonly ["key", "component", "visible", "ariaLabel", "text", "action", "disabled", "validate"];
|
|
186
|
+
readonly required: readonly ["text", "action"];
|
|
187
|
+
readonly children: false;
|
|
188
|
+
readonly event: "action";
|
|
189
|
+
};
|
|
190
|
+
readonly Table: {
|
|
191
|
+
readonly properties: readonly ["key", "component", "visible", "ariaLabel", "binding", "columns"];
|
|
192
|
+
readonly required: readonly ["binding", "columns"];
|
|
193
|
+
readonly children: false;
|
|
194
|
+
readonly event: null;
|
|
195
|
+
};
|
|
196
|
+
readonly List: {
|
|
197
|
+
readonly properties: readonly ["key", "component", "visible", "ariaLabel", "binding"];
|
|
198
|
+
readonly required: readonly ["binding"];
|
|
199
|
+
readonly children: false;
|
|
200
|
+
readonly event: null;
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
bindings: {
|
|
204
|
+
sources: string[];
|
|
205
|
+
path: string;
|
|
206
|
+
missing: string;
|
|
207
|
+
visibility: string;
|
|
208
|
+
};
|
|
209
|
+
propertyTypes: {
|
|
210
|
+
key: string;
|
|
211
|
+
component: string;
|
|
212
|
+
children: string;
|
|
213
|
+
text: string;
|
|
214
|
+
binding: string;
|
|
215
|
+
visible: string;
|
|
216
|
+
disabled: string;
|
|
217
|
+
validation: string;
|
|
218
|
+
validate: string;
|
|
219
|
+
options: string;
|
|
220
|
+
action: string;
|
|
221
|
+
label: string;
|
|
222
|
+
inputType: string[];
|
|
223
|
+
columns: string;
|
|
224
|
+
ariaLabel: string;
|
|
225
|
+
};
|
|
226
|
+
events: {
|
|
227
|
+
action: {
|
|
228
|
+
fields: string[];
|
|
229
|
+
declaration: string;
|
|
230
|
+
};
|
|
231
|
+
state: {
|
|
232
|
+
type: string;
|
|
233
|
+
source: string;
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
limits: {
|
|
237
|
+
treeDepth: number;
|
|
238
|
+
nodes: number;
|
|
239
|
+
textLength: number;
|
|
240
|
+
tableRows: number;
|
|
241
|
+
tableColumns: number;
|
|
242
|
+
listItems: number;
|
|
243
|
+
transportBytes: number;
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
export declare function defineInterface<const T extends InterfaceDefinition>(definition: T): T;
|
|
247
|
+
/** Validate untrusted structured data before creating a controller or mounting it. */
|
|
248
|
+
export declare function validateInterfaceDefinition(value: unknown, components?: readonly string[]): asserts value is InterfaceDefinition;
|
|
249
|
+
export declare function createInterfaceController(definition: InterfaceDefinition, options?: {
|
|
250
|
+
components?: readonly string[];
|
|
251
|
+
allowedActions?: readonly string[];
|
|
252
|
+
onEvent?: (event: InterfaceEvent) => void | Promise<void>;
|
|
253
|
+
onError?: (error: unknown) => void;
|
|
254
|
+
}): InterfaceController;
|
|
255
|
+
export declare function resolveInterfaceBinding(snapshot: InterfaceSnapshot, bindingValue: InterfaceBinding): unknown;
|
|
256
|
+
/** Evaluate a validated condition without coercion or side effects. Missing numeric values never match. */
|
|
257
|
+
export declare function evaluateInterfaceCondition(condition: InterfaceConditionExpression, snapshot: Pick<InterfaceSnapshot, "data" | "state">): boolean;
|
|
258
|
+
export declare function isInterfaceField(node: Pick<InterfaceNode, "component">): boolean;
|
|
259
|
+
/** Errors are recomputed from accepted state; hidden fields are excluded, including hidden ancestors. */
|
|
260
|
+
export declare function getInterfaceValidation(snapshot: Pick<InterfaceSnapshot, "definition" | "data" | "state">): Record<string, string>;
|
|
261
|
+
export {};
|