@zhama/a2ui-core 0.1.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/README.md +161 -0
- package/dist/builders/index.cjs +496 -0
- package/dist/builders/index.cjs.map +1 -0
- package/dist/builders/index.d.cts +538 -0
- package/dist/builders/index.d.ts +538 -0
- package/dist/builders/index.js +445 -0
- package/dist/builders/index.js.map +1 -0
- package/dist/index.cjs +869 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +43 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +802 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.cjs +22 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +711 -0
- package/dist/types/index.d.ts +711 -0
- package/dist/types/index.js +15 -0
- package/dist/types/index.js.map +1 -0
- package/dist/validators/index.cjs +313 -0
- package/dist/validators/index.cjs.map +1 -0
- package/dist/validators/index.d.cts +68 -0
- package/dist/validators/index.d.ts +68 -0
- package/dist/validators/index.js +308 -0
- package/dist/validators/index.js.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1,711 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2UI Primitive Types
|
|
3
|
+
*
|
|
4
|
+
* 基础值类型定义,支持字面值和数据绑定路径
|
|
5
|
+
* These types represent values that can be either literal values or data bindings
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* 字符串值 - 可以是字面值或数据路径绑定
|
|
9
|
+
* @example
|
|
10
|
+
* // Literal value
|
|
11
|
+
* { literalString: "Hello World" }
|
|
12
|
+
* // or simply a string (v0.9 format)
|
|
13
|
+
* "Hello World"
|
|
14
|
+
*
|
|
15
|
+
* // Data binding
|
|
16
|
+
* { path: "/user/name" }
|
|
17
|
+
*/
|
|
18
|
+
type StringOrPath = string | {
|
|
19
|
+
path: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 数值 - 可以是字面值或数据路径绑定
|
|
23
|
+
*/
|
|
24
|
+
type NumberOrPath = number | {
|
|
25
|
+
path: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* 布尔值 - 可以是字面值或数据路径绑定
|
|
29
|
+
*/
|
|
30
|
+
type BooleanOrPath = boolean | {
|
|
31
|
+
path: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* 字符串数组 - 可以是字面值或数据路径绑定
|
|
35
|
+
*/
|
|
36
|
+
type StringArrayOrPath = string[] | {
|
|
37
|
+
path: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* v0.8 格式的字符串值(带有 literalString/path 区分)
|
|
41
|
+
*/
|
|
42
|
+
interface StringValue {
|
|
43
|
+
path?: string;
|
|
44
|
+
literalString?: string;
|
|
45
|
+
/** @deprecated 使用 literalString */
|
|
46
|
+
literal?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* v0.8 格式的数值(带有 literalNumber/path 区分)
|
|
50
|
+
*/
|
|
51
|
+
interface NumberValue {
|
|
52
|
+
path?: string;
|
|
53
|
+
literalNumber?: number;
|
|
54
|
+
/** @deprecated 使用 literalNumber */
|
|
55
|
+
literal?: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* v0.8 格式的布尔值(带有 literalBoolean/path 区分)
|
|
59
|
+
*/
|
|
60
|
+
interface BooleanValue {
|
|
61
|
+
path?: string;
|
|
62
|
+
literalBoolean?: boolean;
|
|
63
|
+
/** @deprecated 使用 literalBoolean */
|
|
64
|
+
literal?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* v0.8 格式的字符串数组值
|
|
68
|
+
*/
|
|
69
|
+
interface StringArrayValue {
|
|
70
|
+
path?: string;
|
|
71
|
+
literalArray?: string[];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Context value - 用于 Action context 中的值
|
|
75
|
+
*/
|
|
76
|
+
type ContextValue = string | number | boolean | {
|
|
77
|
+
path: string;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* A2UI Component Types
|
|
82
|
+
*
|
|
83
|
+
* 标准组件目录中的组件类型定义
|
|
84
|
+
* Based on A2UI v0.9 specification
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 用户操作定义
|
|
89
|
+
* Dispatched when interactive components (like Button) are activated
|
|
90
|
+
*/
|
|
91
|
+
interface Action {
|
|
92
|
+
/**
|
|
93
|
+
* 操作名称,用于标识操作类型
|
|
94
|
+
* @example "submit_form", "navigate", "select_item"
|
|
95
|
+
*/
|
|
96
|
+
name: string;
|
|
97
|
+
/**
|
|
98
|
+
* 操作上下文,键值对形式
|
|
99
|
+
* Values can be literals or data bindings
|
|
100
|
+
*/
|
|
101
|
+
context?: Record<string, StringOrPath | NumberOrPath | BooleanOrPath>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* v0.8 格式的 Action 上下文项
|
|
105
|
+
*/
|
|
106
|
+
interface ActionContextItem {
|
|
107
|
+
key: string;
|
|
108
|
+
value: {
|
|
109
|
+
path?: string;
|
|
110
|
+
literalString?: string;
|
|
111
|
+
literalNumber?: number;
|
|
112
|
+
literalBoolean?: boolean;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* v0.8 格式的 Action
|
|
117
|
+
*/
|
|
118
|
+
interface ActionV08 {
|
|
119
|
+
name: string;
|
|
120
|
+
context?: ActionContextItem[];
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* 组件公共属性
|
|
124
|
+
*/
|
|
125
|
+
interface ComponentCommon {
|
|
126
|
+
/**
|
|
127
|
+
* 组件唯一标识符
|
|
128
|
+
*/
|
|
129
|
+
id: string;
|
|
130
|
+
/**
|
|
131
|
+
* 在 Row 或 Column 中的相对权重(类似 CSS flex-grow)
|
|
132
|
+
*/
|
|
133
|
+
weight?: number;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Text 组件 - 显示文本内容
|
|
137
|
+
*/
|
|
138
|
+
interface TextComponent {
|
|
139
|
+
component: 'Text';
|
|
140
|
+
/**
|
|
141
|
+
* 文本内容,支持简单 Markdown
|
|
142
|
+
*/
|
|
143
|
+
text: StringOrPath;
|
|
144
|
+
/**
|
|
145
|
+
* 文本样式提示
|
|
146
|
+
*/
|
|
147
|
+
usageHint?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'caption' | 'body';
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Image 组件 - 显示图片
|
|
151
|
+
*/
|
|
152
|
+
interface ImageComponent {
|
|
153
|
+
component: 'Image';
|
|
154
|
+
/**
|
|
155
|
+
* 图片 URL
|
|
156
|
+
*/
|
|
157
|
+
url: StringOrPath;
|
|
158
|
+
/**
|
|
159
|
+
* 图片适应方式
|
|
160
|
+
*/
|
|
161
|
+
fit?: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down';
|
|
162
|
+
/**
|
|
163
|
+
* 图片尺寸/样式提示
|
|
164
|
+
*/
|
|
165
|
+
usageHint?: 'icon' | 'avatar' | 'smallFeature' | 'mediumFeature' | 'largeFeature' | 'header';
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Icon 组件 - 显示图标
|
|
169
|
+
*/
|
|
170
|
+
interface IconComponent {
|
|
171
|
+
component: 'Icon';
|
|
172
|
+
/**
|
|
173
|
+
* 图标名称,支持标准图标集
|
|
174
|
+
*/
|
|
175
|
+
name: StringOrPath;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* 标准图标名称
|
|
179
|
+
*/
|
|
180
|
+
type StandardIconName = 'accountCircle' | 'add' | 'arrowBack' | 'arrowForward' | 'attachFile' | 'calendarToday' | 'call' | 'camera' | 'check' | 'close' | 'delete' | 'download' | 'edit' | 'event' | 'error' | 'fastForward' | 'favorite' | 'favoriteOff' | 'folder' | 'help' | 'home' | 'info' | 'locationOn' | 'lock' | 'lockOpen' | 'mail' | 'menu' | 'moreVert' | 'moreHoriz' | 'notificationsOff' | 'notifications' | 'pause' | 'payment' | 'person' | 'phone' | 'photo' | 'play' | 'print' | 'refresh' | 'rewind' | 'search' | 'send' | 'settings' | 'share' | 'shoppingCart' | 'skipNext' | 'skipPrevious' | 'star' | 'starHalf' | 'starOff' | 'stop' | 'upload' | 'visibility' | 'visibilityOff' | 'volumeDown' | 'volumeMute' | 'volumeOff' | 'volumeUp' | 'warning';
|
|
181
|
+
/**
|
|
182
|
+
* Video 组件 - 显示视频
|
|
183
|
+
*/
|
|
184
|
+
interface VideoComponent {
|
|
185
|
+
component: 'Video';
|
|
186
|
+
/**
|
|
187
|
+
* 视频 URL
|
|
188
|
+
*/
|
|
189
|
+
url: StringOrPath;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* AudioPlayer 组件 - 音频播放器
|
|
193
|
+
*/
|
|
194
|
+
interface AudioPlayerComponent {
|
|
195
|
+
component: 'AudioPlayer';
|
|
196
|
+
/**
|
|
197
|
+
* 音频 URL
|
|
198
|
+
*/
|
|
199
|
+
url: StringOrPath;
|
|
200
|
+
/**
|
|
201
|
+
* 音频描述/标题
|
|
202
|
+
*/
|
|
203
|
+
description?: StringOrPath;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* 子组件引用 - 静态列表或动态模板
|
|
207
|
+
*/
|
|
208
|
+
type ChildrenProperty = string[] | {
|
|
209
|
+
componentId: string;
|
|
210
|
+
path: string;
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Row 组件 - 水平布局
|
|
214
|
+
*/
|
|
215
|
+
interface RowComponent {
|
|
216
|
+
component: 'Row';
|
|
217
|
+
/**
|
|
218
|
+
* 子组件 ID 列表或动态模板
|
|
219
|
+
*/
|
|
220
|
+
children: ChildrenProperty;
|
|
221
|
+
/**
|
|
222
|
+
* 主轴方向上的分布方式
|
|
223
|
+
*/
|
|
224
|
+
distribution?: 'start' | 'center' | 'end' | 'spaceBetween' | 'spaceAround' | 'spaceEvenly' | 'stretch';
|
|
225
|
+
/**
|
|
226
|
+
* 交叉轴方向上的对齐方式
|
|
227
|
+
*/
|
|
228
|
+
alignment?: 'start' | 'center' | 'end' | 'stretch';
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Column 组件 - 垂直布局
|
|
232
|
+
*/
|
|
233
|
+
interface ColumnComponent {
|
|
234
|
+
component: 'Column';
|
|
235
|
+
/**
|
|
236
|
+
* 子组件 ID 列表或动态模板
|
|
237
|
+
*/
|
|
238
|
+
children: ChildrenProperty;
|
|
239
|
+
/**
|
|
240
|
+
* 主轴方向上的分布方式
|
|
241
|
+
*/
|
|
242
|
+
distribution?: 'start' | 'center' | 'end' | 'spaceBetween' | 'spaceAround' | 'spaceEvenly' | 'stretch';
|
|
243
|
+
/**
|
|
244
|
+
* 交叉轴方向上的对齐方式
|
|
245
|
+
*/
|
|
246
|
+
alignment?: 'start' | 'center' | 'end' | 'stretch';
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* List 组件 - 列表布局
|
|
250
|
+
*/
|
|
251
|
+
interface ListComponent {
|
|
252
|
+
component: 'List';
|
|
253
|
+
/**
|
|
254
|
+
* 子组件 ID 列表或动态模板
|
|
255
|
+
*/
|
|
256
|
+
children: ChildrenProperty;
|
|
257
|
+
/**
|
|
258
|
+
* 列表方向
|
|
259
|
+
*/
|
|
260
|
+
direction?: 'vertical' | 'horizontal';
|
|
261
|
+
/**
|
|
262
|
+
* 对齐方式
|
|
263
|
+
*/
|
|
264
|
+
alignment?: 'start' | 'center' | 'end' | 'stretch';
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Card 组件 - 卡片容器
|
|
268
|
+
*/
|
|
269
|
+
interface CardComponent {
|
|
270
|
+
component: 'Card';
|
|
271
|
+
/**
|
|
272
|
+
* 单个子组件 ID
|
|
273
|
+
*/
|
|
274
|
+
child: string;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Tabs 组件 - 标签页
|
|
278
|
+
*/
|
|
279
|
+
interface TabsComponent {
|
|
280
|
+
component: 'Tabs';
|
|
281
|
+
/**
|
|
282
|
+
* 标签项列表
|
|
283
|
+
*/
|
|
284
|
+
tabItems: Array<{
|
|
285
|
+
title: StringOrPath;
|
|
286
|
+
child: string;
|
|
287
|
+
}>;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Divider 组件 - 分割线
|
|
291
|
+
*/
|
|
292
|
+
interface DividerComponent {
|
|
293
|
+
component: 'Divider';
|
|
294
|
+
/**
|
|
295
|
+
* 方向
|
|
296
|
+
*/
|
|
297
|
+
axis?: 'horizontal' | 'vertical';
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Modal 组件 - 模态框
|
|
301
|
+
*/
|
|
302
|
+
interface ModalComponent {
|
|
303
|
+
component: 'Modal';
|
|
304
|
+
/**
|
|
305
|
+
* 触发模态框的组件 ID
|
|
306
|
+
*/
|
|
307
|
+
entryPointChild: string;
|
|
308
|
+
/**
|
|
309
|
+
* 模态框内容组件 ID
|
|
310
|
+
*/
|
|
311
|
+
contentChild: string;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Button 组件 - 按钮
|
|
315
|
+
*/
|
|
316
|
+
interface ButtonComponent {
|
|
317
|
+
component: 'Button';
|
|
318
|
+
/**
|
|
319
|
+
* 按钮内容组件 ID(通常是 Text)
|
|
320
|
+
*/
|
|
321
|
+
child: string;
|
|
322
|
+
/**
|
|
323
|
+
* 是否为主按钮样式
|
|
324
|
+
*/
|
|
325
|
+
primary?: boolean;
|
|
326
|
+
/**
|
|
327
|
+
* 点击时触发的操作
|
|
328
|
+
*/
|
|
329
|
+
action: Action;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* CheckBox 组件 - 复选框
|
|
333
|
+
*/
|
|
334
|
+
interface CheckBoxComponent {
|
|
335
|
+
component: 'CheckBox';
|
|
336
|
+
/**
|
|
337
|
+
* 标签文本
|
|
338
|
+
*/
|
|
339
|
+
label: StringOrPath;
|
|
340
|
+
/**
|
|
341
|
+
* 选中状态
|
|
342
|
+
*/
|
|
343
|
+
value: BooleanOrPath;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* TextField 组件 - 文本输入框
|
|
347
|
+
*/
|
|
348
|
+
interface TextFieldComponent {
|
|
349
|
+
component: 'TextField';
|
|
350
|
+
/**
|
|
351
|
+
* 输入框标签
|
|
352
|
+
*/
|
|
353
|
+
label: StringOrPath;
|
|
354
|
+
/**
|
|
355
|
+
* 输入框值
|
|
356
|
+
*/
|
|
357
|
+
text?: StringOrPath;
|
|
358
|
+
/**
|
|
359
|
+
* 输入类型提示
|
|
360
|
+
*/
|
|
361
|
+
usageHint?: 'longText' | 'number' | 'shortText' | 'obscured';
|
|
362
|
+
/**
|
|
363
|
+
* 验证正则表达式
|
|
364
|
+
*/
|
|
365
|
+
validationRegexp?: string;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* DateTimeInput 组件 - 日期时间选择器
|
|
369
|
+
*/
|
|
370
|
+
interface DateTimeInputComponent {
|
|
371
|
+
component: 'DateTimeInput';
|
|
372
|
+
/**
|
|
373
|
+
* 当前值(ISO 8601 格式)
|
|
374
|
+
*/
|
|
375
|
+
value: StringOrPath;
|
|
376
|
+
/**
|
|
377
|
+
* 是否允许选择日期
|
|
378
|
+
*/
|
|
379
|
+
enableDate?: boolean;
|
|
380
|
+
/**
|
|
381
|
+
* 是否允许选择时间
|
|
382
|
+
*/
|
|
383
|
+
enableTime?: boolean;
|
|
384
|
+
/**
|
|
385
|
+
* 输出格式
|
|
386
|
+
*/
|
|
387
|
+
outputFormat?: string;
|
|
388
|
+
/**
|
|
389
|
+
* 标签
|
|
390
|
+
*/
|
|
391
|
+
label?: StringOrPath;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* ChoicePicker 组件 - 选择器
|
|
395
|
+
*/
|
|
396
|
+
interface ChoicePickerComponent {
|
|
397
|
+
component: 'ChoicePicker';
|
|
398
|
+
/**
|
|
399
|
+
* 标签
|
|
400
|
+
*/
|
|
401
|
+
label?: StringOrPath;
|
|
402
|
+
/**
|
|
403
|
+
* 使用提示
|
|
404
|
+
*/
|
|
405
|
+
usageHint: 'multipleSelection' | 'mutuallyExclusive';
|
|
406
|
+
/**
|
|
407
|
+
* 选项列表
|
|
408
|
+
*/
|
|
409
|
+
options: Array<{
|
|
410
|
+
label: StringOrPath;
|
|
411
|
+
value: string;
|
|
412
|
+
}>;
|
|
413
|
+
/**
|
|
414
|
+
* 当前选中的值
|
|
415
|
+
*/
|
|
416
|
+
value: StringArrayOrPath;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Slider 组件 - 滑块
|
|
420
|
+
*/
|
|
421
|
+
interface SliderComponent {
|
|
422
|
+
component: 'Slider';
|
|
423
|
+
/**
|
|
424
|
+
* 标签
|
|
425
|
+
*/
|
|
426
|
+
label?: StringOrPath;
|
|
427
|
+
/**
|
|
428
|
+
* 最小值
|
|
429
|
+
*/
|
|
430
|
+
min?: number;
|
|
431
|
+
/**
|
|
432
|
+
* 最大值
|
|
433
|
+
*/
|
|
434
|
+
max?: number;
|
|
435
|
+
/**
|
|
436
|
+
* 当前值
|
|
437
|
+
*/
|
|
438
|
+
value: NumberOrPath;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* 任意标准组件类型
|
|
442
|
+
*/
|
|
443
|
+
type AnyComponent = TextComponent | ImageComponent | IconComponent | VideoComponent | AudioPlayerComponent | RowComponent | ColumnComponent | ListComponent | CardComponent | TabsComponent | DividerComponent | ModalComponent | ButtonComponent | CheckBoxComponent | TextFieldComponent | DateTimeInputComponent | ChoicePickerComponent | SliderComponent;
|
|
444
|
+
/**
|
|
445
|
+
* 组件类型名称
|
|
446
|
+
*/
|
|
447
|
+
type ComponentType = AnyComponent['component'];
|
|
448
|
+
/**
|
|
449
|
+
* 组件实例 - 带有 ID 和可选权重的组件
|
|
450
|
+
*/
|
|
451
|
+
interface ComponentInstance extends ComponentCommon {
|
|
452
|
+
component: string;
|
|
453
|
+
[key: string]: unknown;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* A2UI Message Types
|
|
458
|
+
*
|
|
459
|
+
* 服务器到客户端的消息类型定义
|
|
460
|
+
* Based on A2UI v0.9 specification
|
|
461
|
+
*/
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* A2UI 主题配置
|
|
465
|
+
*/
|
|
466
|
+
interface Theme {
|
|
467
|
+
/**
|
|
468
|
+
* 主要字体
|
|
469
|
+
*/
|
|
470
|
+
font?: string;
|
|
471
|
+
/**
|
|
472
|
+
* 主题色(十六进制格式,如 '#00BFFF')
|
|
473
|
+
*/
|
|
474
|
+
primaryColor?: string;
|
|
475
|
+
/**
|
|
476
|
+
* 其他自定义样式
|
|
477
|
+
*/
|
|
478
|
+
[key: string]: string | undefined;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* CreateSurface 消息 - 创建新的 UI Surface
|
|
482
|
+
*/
|
|
483
|
+
interface CreateSurfaceMessage {
|
|
484
|
+
createSurface: {
|
|
485
|
+
/**
|
|
486
|
+
* Surface 唯一标识符
|
|
487
|
+
*/
|
|
488
|
+
surfaceId: string;
|
|
489
|
+
/**
|
|
490
|
+
* 组件目录 ID
|
|
491
|
+
* @example "https://a2ui.dev/specification/0.9/standard_catalog_definition.json"
|
|
492
|
+
*/
|
|
493
|
+
catalogId: string;
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* UpdateComponents 消息 - 更新 Surface 中的组件
|
|
498
|
+
*/
|
|
499
|
+
interface UpdateComponentsMessage {
|
|
500
|
+
updateComponents: {
|
|
501
|
+
/**
|
|
502
|
+
* Surface 唯一标识符
|
|
503
|
+
*/
|
|
504
|
+
surfaceId: string;
|
|
505
|
+
/**
|
|
506
|
+
* 组件列表(扁平化,通过 ID 引用建立关系)
|
|
507
|
+
*/
|
|
508
|
+
components: ComponentInstance[];
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* UpdateDataModel 消息 - 更新数据模型
|
|
513
|
+
*/
|
|
514
|
+
interface UpdateDataModelMessage {
|
|
515
|
+
updateDataModel: {
|
|
516
|
+
/**
|
|
517
|
+
* Surface 唯一标识符
|
|
518
|
+
*/
|
|
519
|
+
surfaceId: string;
|
|
520
|
+
/**
|
|
521
|
+
* 数据路径(可选,默认为根路径)
|
|
522
|
+
* @example "/user/name"
|
|
523
|
+
*/
|
|
524
|
+
path?: string;
|
|
525
|
+
/**
|
|
526
|
+
* 操作类型
|
|
527
|
+
*/
|
|
528
|
+
op?: 'add' | 'replace' | 'remove';
|
|
529
|
+
/**
|
|
530
|
+
* 数据值(add/replace 操作需要)
|
|
531
|
+
*/
|
|
532
|
+
value?: unknown;
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* DeleteSurface 消息 - 删除 Surface
|
|
537
|
+
*/
|
|
538
|
+
interface DeleteSurfaceMessage {
|
|
539
|
+
deleteSurface: {
|
|
540
|
+
/**
|
|
541
|
+
* 要删除的 Surface ID
|
|
542
|
+
*/
|
|
543
|
+
surfaceId: string;
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* v0.9 服务器到客户端消息
|
|
548
|
+
*/
|
|
549
|
+
type ServerToClientMessageV09 = CreateSurfaceMessage | UpdateComponentsMessage | UpdateDataModelMessage | DeleteSurfaceMessage;
|
|
550
|
+
/**
|
|
551
|
+
* BeginRendering 消息 (v0.8) - 开始渲染
|
|
552
|
+
*/
|
|
553
|
+
interface BeginRenderingMessage {
|
|
554
|
+
beginRendering: {
|
|
555
|
+
/**
|
|
556
|
+
* Surface ID
|
|
557
|
+
*/
|
|
558
|
+
surfaceId: string;
|
|
559
|
+
/**
|
|
560
|
+
* 根组件 ID
|
|
561
|
+
*/
|
|
562
|
+
root: string;
|
|
563
|
+
/**
|
|
564
|
+
* 样式配置
|
|
565
|
+
*/
|
|
566
|
+
styles?: Theme;
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* SurfaceUpdate 消息 (v0.8) - 更新组件
|
|
571
|
+
*/
|
|
572
|
+
interface SurfaceUpdateMessage {
|
|
573
|
+
surfaceUpdate: {
|
|
574
|
+
surfaceId: string;
|
|
575
|
+
components: ComponentInstanceV08[];
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* v0.8 组件实例格式
|
|
580
|
+
*/
|
|
581
|
+
interface ComponentInstanceV08 {
|
|
582
|
+
id: string;
|
|
583
|
+
weight?: number;
|
|
584
|
+
component: Record<string, unknown>;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* DataModelUpdate 消息 (v0.8) - 更新数据模型
|
|
588
|
+
*/
|
|
589
|
+
interface DataModelUpdateMessage {
|
|
590
|
+
dataModelUpdate: {
|
|
591
|
+
surfaceId: string;
|
|
592
|
+
path?: string;
|
|
593
|
+
contents: ValueMap[];
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* DeleteSurface 消息 (v0.8)
|
|
598
|
+
*/
|
|
599
|
+
interface DeleteSurfaceMessageV08 {
|
|
600
|
+
deleteSurface: {
|
|
601
|
+
surfaceId: string;
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* v0.8 ValueMap 格式
|
|
606
|
+
*/
|
|
607
|
+
interface ValueMap {
|
|
608
|
+
key: string;
|
|
609
|
+
valueString?: string;
|
|
610
|
+
valueNumber?: number;
|
|
611
|
+
valueBoolean?: boolean;
|
|
612
|
+
valueMap?: ValueMap[];
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* v0.8 服务器到客户端消息
|
|
616
|
+
*/
|
|
617
|
+
type ServerToClientMessageV08 = BeginRenderingMessage | SurfaceUpdateMessage | DataModelUpdateMessage | DeleteSurfaceMessageV08;
|
|
618
|
+
/**
|
|
619
|
+
* 服务器到客户端消息(支持 v0.8 和 v0.9)
|
|
620
|
+
*/
|
|
621
|
+
type ServerToClientMessage = ServerToClientMessageV08 | ServerToClientMessageV09;
|
|
622
|
+
/**
|
|
623
|
+
* 判断是否为 v0.9 消息
|
|
624
|
+
*/
|
|
625
|
+
declare function isV09Message(message: ServerToClientMessage): message is ServerToClientMessageV09;
|
|
626
|
+
/**
|
|
627
|
+
* 判断是否为 v0.8 消息
|
|
628
|
+
*/
|
|
629
|
+
declare function isV08Message(message: ServerToClientMessage): message is ServerToClientMessageV08;
|
|
630
|
+
/**
|
|
631
|
+
* 用户操作事件
|
|
632
|
+
*/
|
|
633
|
+
interface UserActionEvent {
|
|
634
|
+
/**
|
|
635
|
+
* 操作名称
|
|
636
|
+
*/
|
|
637
|
+
actionName: string;
|
|
638
|
+
/**
|
|
639
|
+
* 触发组件的 ID
|
|
640
|
+
*/
|
|
641
|
+
sourceComponentId: string;
|
|
642
|
+
/**
|
|
643
|
+
* 时间戳(ISO 8601 格式)
|
|
644
|
+
*/
|
|
645
|
+
timestamp: string;
|
|
646
|
+
/**
|
|
647
|
+
* 操作上下文(解析后的值)
|
|
648
|
+
*/
|
|
649
|
+
context?: Record<string, unknown>;
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* 数据变更事件
|
|
653
|
+
*/
|
|
654
|
+
interface DataChangeEvent {
|
|
655
|
+
/**
|
|
656
|
+
* Surface ID
|
|
657
|
+
*/
|
|
658
|
+
surfaceId: string;
|
|
659
|
+
/**
|
|
660
|
+
* 数据路径
|
|
661
|
+
*/
|
|
662
|
+
path: string;
|
|
663
|
+
/**
|
|
664
|
+
* 新值
|
|
665
|
+
*/
|
|
666
|
+
value: unknown;
|
|
667
|
+
/**
|
|
668
|
+
* 触发组件的 ID
|
|
669
|
+
*/
|
|
670
|
+
sourceComponentId: string;
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* 客户端到服务器消息
|
|
674
|
+
*/
|
|
675
|
+
type ClientToServerMessage = {
|
|
676
|
+
userAction: UserActionEvent;
|
|
677
|
+
} | {
|
|
678
|
+
dataChange: DataChangeEvent;
|
|
679
|
+
};
|
|
680
|
+
/**
|
|
681
|
+
* 数据模型值类型
|
|
682
|
+
*/
|
|
683
|
+
type DataValue = string | number | boolean | null | DataObject | DataArray;
|
|
684
|
+
/**
|
|
685
|
+
* 数据对象
|
|
686
|
+
*/
|
|
687
|
+
interface DataObject {
|
|
688
|
+
[key: string]: DataValue;
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* 数据数组
|
|
692
|
+
*/
|
|
693
|
+
type DataArray = DataValue[];
|
|
694
|
+
/**
|
|
695
|
+
* A2UI 标准 Catalog ID
|
|
696
|
+
*/
|
|
697
|
+
declare const STANDARD_CATALOG_ID = "https://a2ui.dev/specification/0.9/standard_catalog_definition.json";
|
|
698
|
+
/**
|
|
699
|
+
* A2UI 扩展 URI (v0.8)
|
|
700
|
+
*/
|
|
701
|
+
declare const A2UI_EXTENSION_URI_V08 = "https://a2ui.org/a2a-extension/a2ui/v0.8";
|
|
702
|
+
/**
|
|
703
|
+
* A2UI 扩展 URI (v0.9)
|
|
704
|
+
*/
|
|
705
|
+
declare const A2UI_EXTENSION_URI = "https://a2ui.dev/specification/0.9";
|
|
706
|
+
/**
|
|
707
|
+
* A2UI MIME 类型
|
|
708
|
+
*/
|
|
709
|
+
declare const A2UI_MIME_TYPE = "application/json+a2ui";
|
|
710
|
+
|
|
711
|
+
export { A2UI_EXTENSION_URI, A2UI_EXTENSION_URI_V08, A2UI_MIME_TYPE, type Action, type ActionContextItem, type ActionV08, type AnyComponent, type AudioPlayerComponent, type BeginRenderingMessage, type BooleanOrPath, type BooleanValue, type ButtonComponent, type CardComponent, type CheckBoxComponent, type ChildrenProperty, type ChoicePickerComponent, type ClientToServerMessage, type ColumnComponent, type ComponentCommon, type ComponentInstance, type ComponentInstanceV08, type ComponentType, type ContextValue, type CreateSurfaceMessage, type DataArray, type DataChangeEvent, type DataModelUpdateMessage, type DataObject, type DataValue, type DateTimeInputComponent, type DeleteSurfaceMessage, type DeleteSurfaceMessageV08, type DividerComponent, type IconComponent, type ImageComponent, type ListComponent, type ModalComponent, type NumberOrPath, type NumberValue, type RowComponent, STANDARD_CATALOG_ID, type ServerToClientMessage, type ServerToClientMessageV08, type ServerToClientMessageV09, type SliderComponent, type StandardIconName, type StringArrayOrPath, type StringArrayValue, type StringOrPath, type StringValue, type SurfaceUpdateMessage, type TabsComponent, type TextComponent, type TextFieldComponent, type Theme, type UpdateComponentsMessage, type UpdateDataModelMessage, type UserActionEvent, type ValueMap, type VideoComponent, isV08Message, isV09Message };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/types/messages.ts
|
|
2
|
+
function isV09Message(message) {
|
|
3
|
+
return "createSurface" in message || "updateComponents" in message || "updateDataModel" in message;
|
|
4
|
+
}
|
|
5
|
+
function isV08Message(message) {
|
|
6
|
+
return "beginRendering" in message || "surfaceUpdate" in message || "dataModelUpdate" in message;
|
|
7
|
+
}
|
|
8
|
+
var STANDARD_CATALOG_ID = "https://a2ui.dev/specification/0.9/standard_catalog_definition.json";
|
|
9
|
+
var A2UI_EXTENSION_URI_V08 = "https://a2ui.org/a2a-extension/a2ui/v0.8";
|
|
10
|
+
var A2UI_EXTENSION_URI = "https://a2ui.dev/specification/0.9";
|
|
11
|
+
var A2UI_MIME_TYPE = "application/json+a2ui";
|
|
12
|
+
|
|
13
|
+
export { A2UI_EXTENSION_URI, A2UI_EXTENSION_URI_V08, A2UI_MIME_TYPE, STANDARD_CATALOG_ID, isV08Message, isV09Message };
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
15
|
+
//# sourceMappingURL=index.js.map
|