@zhama/a2ui-core 0.6.1 → 0.9.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.
@@ -1,5 +1,5 @@
1
- import { S as StringOrPath, B as BooleanOrPath, a as StringArrayOrPath, N as NumberOrPath } from '../primitives-DLbBDhLq.js';
2
- import { TextComponent, ImageComponent, RowComponent, ListComponent, DividerComponent, TextFieldComponent, ChartAxisConfig, ComponentInstance, ChildrenProperty, Action, ChoicePickerComponent, ChartType, ChartSeries, CreateSurfaceMessage, UpdateComponentsMessage, UpdateDataModelMessage, DeleteSurfaceMessage, DataObject, ServerToClientMessageV09, DataValue } from '../types/index.js';
1
+ import { A as AccessibilityAttributes, C as CheckRule, b as DynamicString, f as DynamicValue, d as DynamicBoolean, e as DynamicStringList, c as DynamicNumber } from '../primitives-DRaAeo-1.js';
2
+ import { TextVariant, ImageComponent, ImageVariant, AlignItems, JustifyContent, ListComponent, DividerComponent, ButtonVariant, TextFieldVariant, ChoicePickerVariant, ChartAxisConfig, Action, ComponentInstance, ChildList, ChoiceOption, ChartType, ChartSeries, Theme, CreateSurfaceMessage, UpdateComponentsMessage, UpdateDataModelMessage, DeleteSurfaceMessage, DataObject, ServerToClientMessage, DataValue } from '../types/index.js';
3
3
 
4
4
  /**
5
5
  * ID Generator
@@ -30,132 +30,70 @@ declare function getIdCounter(): number;
30
30
  /**
31
31
  * Component Builder
32
32
  *
33
- * 提供 A2UI 组件定义的构建工具函数
34
- * 用于创建符合 A2UI v0.9 协议的组件结构
33
+ * A2UI v0.9 组件构建器
35
34
  */
36
35
 
37
- /**
38
- * 组件构建选项基类
39
- */
40
36
  interface ComponentOptions {
41
- /** 组件 ID(可选,自动生成) */
42
37
  id?: string;
43
- /** 在 Row/Column 中的权重 */
44
38
  weight?: number;
45
- /** 额外的 CSS 类名(A2UI 工具类或自定义类) */
46
- classes?: string[];
39
+ accessibility?: AccessibilityAttributes;
40
+ }
41
+ interface CheckableOptions {
42
+ checks?: CheckRule[];
47
43
  }
48
- /**
49
- * Text 组件选项
50
- */
51
44
  interface TextOptions extends ComponentOptions {
52
- usageHint?: TextComponent['usageHint'];
45
+ variant?: TextVariant;
53
46
  }
54
- /**
55
- * Image 组件选项
56
- */
57
47
  interface ImageOptions extends ComponentOptions {
58
48
  fit?: ImageComponent['fit'];
59
- usageHint?: ImageComponent['usageHint'];
49
+ variant?: ImageVariant;
60
50
  }
61
- /**
62
- * Icon 组件选项
63
- */
64
51
  type IconOptions = ComponentOptions;
65
- /**
66
- * Video 组件选项
67
- */
68
52
  type VideoOptions = ComponentOptions;
69
- /**
70
- * AudioPlayer 组件选项
71
- */
72
53
  interface AudioPlayerOptions extends ComponentOptions {
73
- description?: StringOrPath;
54
+ description?: DynamicString;
74
55
  }
75
- /**
76
- * 布局组件选项
77
- */
78
56
  interface LayoutOptions extends ComponentOptions {
79
- alignment?: RowComponent['alignment'];
80
- distribution?: RowComponent['distribution'];
57
+ align?: AlignItems;
58
+ justify?: JustifyContent;
81
59
  }
82
- /**
83
- * List 组件选项
84
- */
85
60
  interface ListOptions extends ComponentOptions {
86
61
  direction?: ListComponent['direction'];
87
- alignment?: ListComponent['alignment'];
62
+ align?: AlignItems;
88
63
  }
89
- /**
90
- * Card 组件选项
91
- */
92
64
  type CardOptions = ComponentOptions;
93
- /**
94
- * Tabs 组件选项
95
- */
96
- type TabsOptions = ComponentOptions;
97
- /**
98
- * Tab 项目
99
- */
100
- interface TabItem {
101
- title: string;
65
+ interface TabInput {
66
+ title: DynamicString;
102
67
  childId: string;
103
68
  }
104
- /**
105
- * Divider 组件选项
106
- */
69
+ type TabsOptions = ComponentOptions;
107
70
  interface DividerOptions extends ComponentOptions {
108
71
  axis?: DividerComponent['axis'];
109
72
  }
110
- /**
111
- * Modal 组件选项
112
- */
113
73
  type ModalOptions = ComponentOptions;
114
- /**
115
- * Button 组件选项
116
- */
117
- interface ButtonOptions extends ComponentOptions {
118
- primary?: boolean;
74
+ interface ButtonOptions extends ComponentOptions, CheckableOptions {
75
+ variant?: ButtonVariant;
119
76
  }
120
- /**
121
- * CheckBox 组件选项
122
- */
123
- type CheckBoxOptions = ComponentOptions;
124
- /**
125
- * TextField 组件选项
126
- */
127
- interface TextFieldOptions extends ComponentOptions {
128
- usageHint?: TextFieldComponent['usageHint'];
129
- validationRegexp?: string;
77
+ type CheckBoxOptions = ComponentOptions & CheckableOptions;
78
+ interface TextFieldOptions extends ComponentOptions, CheckableOptions {
79
+ variant?: TextFieldVariant;
130
80
  }
131
- /**
132
- * DateTimeInput 组件选项
133
- */
134
- interface DateTimeInputOptions extends ComponentOptions {
81
+ interface DateTimeInputOptions extends ComponentOptions, CheckableOptions {
135
82
  enableDate?: boolean;
136
83
  enableTime?: boolean;
137
- outputFormat?: string;
138
- label?: StringOrPath;
84
+ min?: DynamicString;
85
+ max?: DynamicString;
86
+ label?: DynamicString;
139
87
  }
140
- /**
141
- * ChoicePicker 组件选项
142
- */
143
- interface ChoicePickerOptions extends ComponentOptions {
144
- label?: StringOrPath;
88
+ interface ChoicePickerOptions extends ComponentOptions, CheckableOptions {
89
+ label?: DynamicString;
90
+ variant?: ChoicePickerVariant;
145
91
  }
146
- /**
147
- * Slider 组件选项
148
- */
149
- interface SliderOptions extends ComponentOptions {
150
- label?: StringOrPath;
151
- min?: number;
152
- max?: number;
92
+ interface SliderOptions extends ComponentOptions, CheckableOptions {
93
+ label?: DynamicString;
153
94
  }
154
- /**
155
- * Chart 组件选项
156
- */
157
95
  interface ChartOptions extends ComponentOptions {
158
- title?: StringOrPath;
96
+ title?: DynamicString;
159
97
  xAxis?: ChartAxisConfig;
160
98
  yAxis?: ChartAxisConfig;
161
99
  legend?: boolean;
@@ -167,351 +105,83 @@ interface ChartOptions extends ComponentOptions {
167
105
  };
168
106
  }
169
107
  /**
170
- * 创建 Text 组件
171
- *
172
- * @param text - 文本内容或数据路径
173
- * @param options - 组件选项
174
- *
175
- * @example
176
- * // 静态文本
177
- * text('Hello World', { usageHint: 'h1' });
178
- *
179
- * // 数据绑定
180
- * text({ path: '/user/name' });
181
- */
182
- declare function text(content: StringOrPath, options?: TextOptions): ComponentInstance;
183
- /**
184
- * 创建 Image 组件
185
- *
186
- * @param url - 图片 URL 或数据路径
187
- * @param options - 组件选项
188
- */
189
- declare function image(url: StringOrPath, options?: ImageOptions): ComponentInstance;
190
- /**
191
- * 创建 Icon 组件
192
- *
193
- * @param name - 图标名称或数据路径
194
- * @param options - 组件选项
195
- */
196
- declare function icon(name: StringOrPath, options?: IconOptions): ComponentInstance;
197
- /**
198
- * 创建 Video 组件
199
- *
200
- * @param url - 视频 URL 或数据路径
201
- * @param options - 组件选项
202
- */
203
- declare function video(url: StringOrPath, options?: VideoOptions): ComponentInstance;
204
- /**
205
- * 创建 AudioPlayer 组件
206
- *
207
- * @param url - 音频 URL 或数据路径
208
- * @param options - 组件选项
209
- */
210
- declare function audioPlayer(url: StringOrPath, options?: AudioPlayerOptions): ComponentInstance;
211
- /**
212
- * 创建 Row 组件(水平布局)
213
- *
214
- * @param children - 子组件 ID 列表或动态模板
215
- * @param options - 布局选项
216
- *
217
- * @example
218
- * // 静态子组件
219
- * row(['text1', 'text2', 'button1']);
220
- *
221
- * // 动态模板
222
- * row({ componentId: 'itemTemplate', path: '/items' });
223
- */
224
- declare function row(children: ChildrenProperty, options?: LayoutOptions): ComponentInstance;
225
- /**
226
- * 创建 Column 组件(垂直布局)
227
- *
228
- * @param children - 子组件 ID 列表或动态模板
229
- * @param options - 布局选项
230
- */
231
- declare function column(children: ChildrenProperty, options?: LayoutOptions): ComponentInstance;
232
- /**
233
- * 创建 List 组件
234
- *
235
- * @param children - 子组件 ID 列表或动态模板
236
- * @param options - 列表选项
237
- */
238
- declare function list(children: ChildrenProperty, options?: ListOptions): ComponentInstance;
239
- /**
240
- * 创建 Card 组件
241
- *
242
- * @param childId - 子组件 ID
243
- * @param options - 卡片选项
108
+ * 创建服务器端事件 Action
244
109
  */
110
+ declare function eventAction(name: string, context?: Record<string, DynamicValue>): Action;
111
+ declare function text(content: DynamicString, options?: TextOptions): ComponentInstance;
112
+ declare function image(url: DynamicString, options?: ImageOptions): ComponentInstance;
113
+ declare function icon(name: DynamicString, options?: IconOptions): ComponentInstance;
114
+ declare function video(url: DynamicString, options?: VideoOptions): ComponentInstance;
115
+ declare function audioPlayer(url: DynamicString, options?: AudioPlayerOptions): ComponentInstance;
116
+ declare function row(children: ChildList, options?: LayoutOptions): ComponentInstance;
117
+ declare function column(children: ChildList, options?: LayoutOptions): ComponentInstance;
118
+ declare function list(children: ChildList, options?: ListOptions): ComponentInstance;
245
119
  declare function card(childId: string, options?: CardOptions): ComponentInstance;
246
- /**
247
- * 创建 Tabs 组件
248
- *
249
- * @param items - 标签项列表
250
- * @param options - Tabs 选项
251
- */
252
- declare function tabs(items: TabItem[], options?: TabsOptions): ComponentInstance;
253
- /**
254
- * 创建 Divider 组件
255
- *
256
- * @param options - 分割线选项
257
- */
120
+ declare function tabs(items: TabInput[], options?: TabsOptions): ComponentInstance;
258
121
  declare function divider(options?: DividerOptions): ComponentInstance;
259
- /**
260
- * 创建 Modal 组件
261
- *
262
- * @param entryPointChildId - 触发模态框的组件 ID
263
- * @param contentChildId - 模态框内容组件 ID
264
- * @param options - Modal 选项
265
- */
266
- declare function modal(entryPointChildId: string, contentChildId: string, options?: ModalOptions): ComponentInstance;
267
- /**
268
- * 创建 Button 组件
269
- *
270
- * @param childId - 按钮内容组件 ID(通常是 Text)
271
- * @param action - 点击时触发的操作
272
- * @param options - 按钮选项
273
- */
122
+ declare function modal(triggerId: string, contentId: string, options?: ModalOptions): ComponentInstance;
274
123
  declare function button(childId: string, action: Action, options?: ButtonOptions): ComponentInstance;
275
- /**
276
- * 创建 CheckBox 组件
277
- *
278
- * @param label - 标签
279
- * @param value - 值(布尔值或数据路径)
280
- * @param options - 选项
281
- */
282
- declare function checkbox(label: StringOrPath, value: BooleanOrPath, options?: CheckBoxOptions): ComponentInstance;
283
- /**
284
- * 创建 TextField 组件
285
- *
286
- * @param label - 标签
287
- * @param textValue - 值(可选)
288
- * @param options - 选项
289
- */
290
- declare function textField(label: StringOrPath, textValue?: StringOrPath, options?: TextFieldOptions): ComponentInstance;
291
- /**
292
- * 创建 DateTimeInput 组件
293
- *
294
- * @param value - 值(ISO 8601 格式字符串或数据路径)
295
- * @param options - 选项
296
- */
297
- declare function dateTimeInput(value: StringOrPath, options?: DateTimeInputOptions): ComponentInstance;
298
- /**
299
- * 创建 ChoicePicker 组件
300
- *
301
- * @param optionsList - 选项列表
302
- * @param value - 当前选中值
303
- * @param usageHint - 使用提示
304
- * @param options - 组件选项
305
- */
306
- declare function choicePicker(optionsList: Array<{
307
- label: StringOrPath;
308
- value: string;
309
- }>, value: StringArrayOrPath, usageHint: ChoicePickerComponent['usageHint'], options?: ChoicePickerOptions): ComponentInstance;
310
- /**
311
- * 创建 Slider 组件
312
- *
313
- * @param value - 当前值
314
- * @param options - 选项
315
- */
316
- declare function slider(value: NumberOrPath, options?: SliderOptions): ComponentInstance;
317
- /**
318
- * 创建 Chart 组件
319
- *
320
- * @param chartType - 图表类型
321
- * @param series - 数据系列
322
- * @param options - 组件选项
323
- *
324
- * @example
325
- * // 简单折线图
326
- * chart('line', [
327
- * { name: '销售额', data: [120, 200, 150, 80, 70, 110, 130] }
328
- * ], {
329
- * title: '月度销售趋势',
330
- * xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }
331
- * });
332
- *
333
- * // 数据绑定
334
- * chart('bar', { path: '/chart/series' }, {
335
- * title: { path: '/chart/title' },
336
- * xAxis: { type: 'category', data: { path: '/chart/categories' } }
337
- * });
338
- */
124
+ declare function checkbox(label: DynamicString, value: DynamicBoolean, options?: CheckBoxOptions): ComponentInstance;
125
+ declare function textField(label: DynamicString, value?: DynamicString, options?: TextFieldOptions): ComponentInstance;
126
+ declare function dateTimeInput(value: DynamicString, options?: DateTimeInputOptions): ComponentInstance;
127
+ declare function choicePicker(optionsList: ChoiceOption[], value: DynamicStringList, options?: ChoicePickerOptions): ComponentInstance;
128
+ declare function slider(value: DynamicNumber, min: number, max: number, options?: SliderOptions): ComponentInstance;
339
129
  declare function chart(chartType: ChartType, series: ChartSeries[] | {
340
130
  path: string;
341
131
  }, options?: ChartOptions): ComponentInstance;
342
- /**
343
- * 创建折线图组件(便捷函数)
344
- */
345
132
  declare function lineChart(series: ChartSeries[] | {
346
133
  path: string;
347
134
  }, options?: ChartOptions): ComponentInstance;
348
- /**
349
- * 创建柱状图组件(便捷函数)
350
- */
351
135
  declare function barChart(series: ChartSeries[] | {
352
136
  path: string;
353
137
  }, options?: ChartOptions): ComponentInstance;
354
- /**
355
- * 创建饼图组件(便捷函数)
356
- */
357
138
  declare function pieChart(series: ChartSeries[] | {
358
139
  path: string;
359
140
  }, options?: ChartOptions): ComponentInstance;
360
- /**
361
- * 创建带文本的按钮(返回按钮和文本组件)
362
- *
363
- * @param buttonText - 按钮文本
364
- * @param action - 点击操作
365
- * @param options - 按钮选项
366
- * @returns 包含按钮和文本组件的数组
367
- */
368
141
  declare function textButton(buttonText: string, action: Action, options?: ButtonOptions & {
369
142
  textId?: string;
370
143
  }): [ComponentInstance, ComponentInstance];
371
- /**
372
- * 创建标题组件
373
- */
374
- declare function h1(content: StringOrPath, options?: Omit<TextOptions, 'usageHint'>): ComponentInstance;
375
- declare function h2(content: StringOrPath, options?: Omit<TextOptions, 'usageHint'>): ComponentInstance;
376
- declare function h3(content: StringOrPath, options?: Omit<TextOptions, 'usageHint'>): ComponentInstance;
377
- declare function h4(content: StringOrPath, options?: Omit<TextOptions, 'usageHint'>): ComponentInstance;
378
- declare function h5(content: StringOrPath, options?: Omit<TextOptions, 'usageHint'>): ComponentInstance;
379
- declare function caption(content: StringOrPath, options?: Omit<TextOptions, 'usageHint'>): ComponentInstance;
380
- declare function body(content: StringOrPath, options?: Omit<TextOptions, 'usageHint'>): ComponentInstance;
144
+ declare function h1(content: DynamicString, options?: Omit<TextOptions, 'variant'>): ComponentInstance;
145
+ declare function h2(content: DynamicString, options?: Omit<TextOptions, 'variant'>): ComponentInstance;
146
+ declare function h3(content: DynamicString, options?: Omit<TextOptions, 'variant'>): ComponentInstance;
147
+ declare function h4(content: DynamicString, options?: Omit<TextOptions, 'variant'>): ComponentInstance;
148
+ declare function h5(content: DynamicString, options?: Omit<TextOptions, 'variant'>): ComponentInstance;
149
+ declare function caption(content: DynamicString, options?: Omit<TextOptions, 'variant'>): ComponentInstance;
150
+ declare function body(content: DynamicString, options?: Omit<TextOptions, 'variant'>): ComponentInstance;
381
151
 
382
152
  /**
383
153
  * Message Builder
384
154
  *
385
- * 提供 A2UI v0.9 协议消息的构建工具函数
386
- *
387
- * v0.9 消息类型:
388
- * - createSurface: 创建新的 UI Surface
389
- * - updateComponents: 更新组件
390
- * - updateDataModel: 更新数据模型 (JSON Patch 风格)
391
- * - deleteSurface: 删除 Surface
392
- *
393
- * 参考: https://a2ui.org/
155
+ * A2UI v0.9 消息构建器
394
156
  */
395
157
 
396
- /**
397
- * 创建 CreateSurface 消息
398
- *
399
- * @param surfaceId - Surface ID
400
- * @param catalogId - Catalog ID(默认为标准目录)
401
- *
402
- * @example
403
- * ```typescript
404
- * const msg = createSurface('my-surface');
405
- * // { createSurface: { surfaceId: 'my-surface', catalogId: '...' } }
406
- * ```
407
- */
408
- declare function createSurface(surfaceId: string, catalogId?: string): CreateSurfaceMessage;
409
- /**
410
- * 创建 UpdateComponents 消息
411
- *
412
- * @param surfaceId - Surface ID
413
- * @param components - 组件列表
414
- *
415
- * @example
416
- * ```typescript
417
- * const title = text('Hello', { id: 'title' });
418
- * const msg = updateComponents('my-surface', [title]);
419
- * ```
420
- */
158
+ interface CreateSurfaceOptions {
159
+ catalogId?: string;
160
+ theme?: Theme;
161
+ sendDataModel?: boolean;
162
+ }
163
+ declare function createSurface(surfaceId: string, options?: CreateSurfaceOptions): CreateSurfaceMessage;
421
164
  declare function updateComponents(surfaceId: string, components: ComponentInstance[]): UpdateComponentsMessage;
422
- /**
423
- * 创建 UpdateDataModel 消息
424
- *
425
- * @param surfaceId - Surface ID
426
- * @param value - 数据值
427
- * @param path - 数据路径(可选,默认为根路径)
428
- * @param op - 操作类型(默认为 replace)
429
- *
430
- * @example
431
- * ```typescript
432
- * // 替换整个数据模型
433
- * updateDataModel('my-surface', { user: { name: 'John' } });
434
- *
435
- * // 更新特定路径
436
- * updateDataModel('my-surface', 'Jane', '/user/name', 'replace');
437
- *
438
- * // 添加数据
439
- * updateDataModel('my-surface', 'new-item', '/items/-', 'add');
440
- * ```
441
- */
442
- declare function updateDataModel(surfaceId: string, value: unknown, path?: string, op?: 'add' | 'replace' | 'remove'): UpdateDataModelMessage;
443
- /**
444
- * 创建 DeleteSurface 消息
445
- *
446
- * @param surfaceId - 要删除的 Surface ID
447
- */
165
+ declare function updateDataModel(surfaceId: string, value?: unknown, path?: string): UpdateDataModelMessage;
448
166
  declare function deleteSurface(surfaceId: string): DeleteSurfaceMessage;
449
- /**
450
- * 创建完整的 v0.9 消息序列
451
- *
452
- * @param options - 选项
453
- * @returns 消息数组(可直接作为 JSONL 流发送)
454
- *
455
- * @example
456
- * ```typescript
457
- * const title = h1('Welcome', { id: 'title' });
458
- * const root = column(['title'], { id: 'root' });
459
- *
460
- * const messages = createV09Messages({
461
- * surfaceId: '@chat',
462
- * components: [title, root],
463
- * dataModel: { user: { name: 'John' } }
464
- * });
465
- *
466
- * // 发送为 JSONL 流
467
- * const jsonl = messagesToJsonl(messages);
468
- * ```
469
- */
470
- declare function createV09Messages(options: {
167
+ declare function createMessages(options: {
471
168
  surfaceId: string;
472
169
  catalogId?: string;
170
+ theme?: Theme;
171
+ sendDataModel?: boolean;
473
172
  components: ComponentInstance[];
474
173
  dataModel?: DataObject;
475
- }): ServerToClientMessageV09[];
476
- /**
477
- * 将消息数组转换为 JSONL 格式字符串
478
- *
479
- * @param messages - 消息数组
480
- * @returns JSONL 格式字符串
481
- *
482
- * @example
483
- * ```typescript
484
- * const jsonl = messagesToJsonl(messages);
485
- * // 每行一个 JSON 对象
486
- * ```
487
- */
488
- declare function messagesToJsonl(messages: ServerToClientMessageV09[]): string;
489
- /**
490
- * 从 JSONL 格式字符串解析消息数组
491
- *
492
- * @param jsonl - JSONL 格式字符串
493
- * @returns 消息数组
494
- */
495
- declare function jsonlToMessages(jsonl: string): ServerToClientMessageV09[];
174
+ }): ServerToClientMessage[];
175
+ declare function messagesToJsonl(messages: ServerToClientMessage[]): string;
176
+ declare function jsonlToMessages(jsonl: string): ServerToClientMessage[];
496
177
 
497
178
  /**
498
179
  * Data Model Builder
499
180
  *
500
- * 提供 DataModel 相关的构建工具函数
501
- * 包括 v0.9 JSON 对象格式和 v0.8 ValueMap 格式转换
181
+ * A2UI v0.9 数据模型工具函数
182
+ * v0.9 直接使用 JSON 值,不需要 ValueMap 包装格式
502
183
  */
503
184
 
504
- /**
505
- * ValueMap 格式 - 用于 v0.8 兼容和内部数据转换
506
- * @internal
507
- */
508
- interface ValueMap {
509
- key: string;
510
- valueString?: string;
511
- valueNumber?: number;
512
- valueBoolean?: boolean;
513
- valueMap?: ValueMap[];
514
- }
515
185
  /**
516
186
  * 路径映射表类型
517
187
  */
@@ -520,27 +190,6 @@ type PathMappings = Record<string, string>;
520
190
  * 默认路径映射
521
191
  */
522
192
  declare const DEFAULT_PATH_MAPPINGS: PathMappings;
523
- /**
524
- * 将 JavaScript 对象转换为 A2UI ValueMap 格式
525
- *
526
- * @param obj - JavaScript 对象
527
- * @param prefix - 路径前缀(用于嵌套对象的 key 生成)
528
- *
529
- * @example
530
- * objectToValueMap({ name: 'John', age: 30 });
531
- * // Returns: [
532
- * // { key: '/name', valueString: 'John' },
533
- * // { key: '/age', valueNumber: 30 }
534
- * // ]
535
- */
536
- declare function objectToValueMap(obj: DataObject, prefix?: string): ValueMap[];
537
- /**
538
- * 将单个值转换为 A2UI ValueMap 格式
539
- *
540
- * @param key - 数据路径/键
541
- * @param value - JavaScript 值
542
- */
543
- declare function valueToValueMap(key: string, value: DataValue): ValueMap;
544
193
  /**
545
194
  * 规范化路径格式
546
195
  * - 将 . 分隔符转换为 /
@@ -569,27 +218,5 @@ interface UpdateDataItem {
569
218
  /** 操作类型(可选,用于增量更新) */
570
219
  operation?: 'set' | 'increment' | 'decrement' | 'append' | 'remove';
571
220
  }
572
- /**
573
- * 将更新数据项数组转换为 ValueMap
574
- *
575
- * @param updates - 更新数据项
576
- * @param basePath - 基础路径
577
- * @param pathMappings - 可选路径映射表
578
- */
579
- declare function updatesToValueMap(updates: UpdateDataItem[], basePath?: string, pathMappings?: PathMappings): ValueMap[];
580
- /**
581
- * 将嵌套对象扁平化为 ValueMap 条目
582
- *
583
- * @param obj - 要扁平化的对象
584
- * @param basePath - 基础路径
585
- */
586
- declare function flattenObjectToValueMap(obj: DataObject, basePath: string): ValueMap[];
587
- /**
588
- * 从 ValueMap 数组中提取普通 JavaScript 对象
589
- *
590
- * @param valueMaps - ValueMap 数组
591
- * @returns JavaScript 对象
592
- */
593
- declare function valueMapToObject(valueMaps: ValueMap[]): DataObject;
594
221
 
595
- export { type AudioPlayerOptions, type ButtonOptions, type CardOptions, type ChartOptions, type CheckBoxOptions, type ChoicePickerOptions, type ComponentOptions, DEFAULT_PATH_MAPPINGS, type DateTimeInputOptions, type DividerOptions, type IconOptions, type ImageOptions, type LayoutOptions, type ListOptions, type ModalOptions, type PathMappings, type SliderOptions, type TabItem, type TabsOptions, type TextFieldOptions, type TextOptions, type UpdateDataItem, type VideoOptions, audioPlayer, barChart, body, button, caption, card, chart, checkbox, choicePicker, column, createSurface, createV09Messages, dateTimeInput, deleteSurface, divider, flattenObjectToValueMap, generateId, getIdCounter, h1, h2, h3, h4, h5, icon, image, jsonlToMessages, lineChart, list, messagesToJsonl, modal, normalizePath, objectToValueMap, pieChart, resetIdCounter, row, slider, tabs, text, textButton, textField, updateComponents, updateDataModel, updatesToValueMap, valueMapToObject, valueToValueMap, video };
222
+ export { type AudioPlayerOptions, type ButtonOptions, type CardOptions, type ChartOptions, type CheckBoxOptions, type CheckableOptions, type ChoicePickerOptions, type ComponentOptions, type CreateSurfaceOptions, DEFAULT_PATH_MAPPINGS, type DateTimeInputOptions, type DividerOptions, type IconOptions, type ImageOptions, type LayoutOptions, type ListOptions, type ModalOptions, type PathMappings, type SliderOptions, type TabInput, type TabsOptions, type TextFieldOptions, type TextOptions, type UpdateDataItem, type VideoOptions, audioPlayer, barChart, body, button, caption, card, chart, checkbox, choicePicker, column, createMessages, createSurface, dateTimeInput, deleteSurface, divider, eventAction, generateId, getIdCounter, h1, h2, h3, h4, h5, icon, image, jsonlToMessages, lineChart, list, messagesToJsonl, modal, normalizePath, pieChart, resetIdCounter, row, slider, tabs, text, textButton, textField, updateComponents, updateDataModel, video };
@@ -1,3 +1,3 @@
1
- var l=0;function s(t="comp"){return `${t}_${Date.now()}_${l++}`}function D(){l=0;}function P(){return l}function p(t,e={}){let{id:n=s("text"),weight:o,usageHint:r,classes:a}=e;return {id:n,component:"Text",text:t,...o!==void 0&&{weight:o},...r&&{usageHint:r},...a&&a.length>0&&{classes:a}}}function V(t,e={}){let{id:n=s("image"),weight:o,fit:r,usageHint:a}=e;return {id:n,component:"Image",url:t,...o!==void 0&&{weight:o},...r&&{fit:r},...a&&{usageHint:a}}}function A(t,e={}){let{id:n=s("icon"),weight:o}=e;return {id:n,component:"Icon",name:t,...o!==void 0&&{weight:o}}}function w(t,e={}){let{id:n=s("video"),weight:o}=e;return {id:n,component:"Video",url:t,...o!==void 0&&{weight:o}}}function U(t,e={}){let{id:n=s("audio"),weight:o,description:r}=e;return {id:n,component:"AudioPlayer",url:t,...o!==void 0&&{weight:o},...r&&{description:r}}}function E(t,e={}){let{id:n=s("row"),weight:o,alignment:r,distribution:a}=e;return {id:n,component:"Row",children:t,...o!==void 0&&{weight:o},...r&&{alignment:r},...a&&{distribution:a}}}function j(t,e={}){let{id:n=s("column"),weight:o,alignment:r,distribution:a,classes:i}=e;return {id:n,component:"Column",children:t,...o!==void 0&&{weight:o},...r&&{alignment:r},...a&&{distribution:a},...i&&i.length>0&&{classes:i}}}function k(t,e={}){let{id:n=s("list"),weight:o,direction:r,alignment:a}=e;return {id:n,component:"List",children:t,...o!==void 0&&{weight:o},...r&&{direction:r},...a&&{alignment:a}}}function _(t,e={}){let{id:n=s("card"),weight:o,classes:r}=e;return {id:n,component:"Card",child:t,...o!==void 0&&{weight:o},...r&&r.length>0&&{classes:r}}}function H(t,e={}){let{id:n=s("tabs"),weight:o}=e;return {id:n,component:"Tabs",tabItems:t.map(r=>({title:r.title,child:r.childId})),...o!==void 0&&{weight:o}}}function B(t={}){let{id:e=s("divider"),weight:n,axis:o}=t;return {id:e,component:"Divider",...n!==void 0&&{weight:n},...o&&{axis:o}}}function N(t,e,n={}){let{id:o=s("modal"),weight:r}=n;return {id:o,component:"Modal",entryPointChild:t,contentChild:e,...r!==void 0&&{weight:r}}}function I(t,e,n={}){let{id:o=s("button"),weight:r,primary:a}=n;return {id:o,component:"Button",child:t,action:e,...r!==void 0&&{weight:r},...a!==void 0&&{primary:a}}}function R(t,e,n={}){let{id:o=s("checkbox"),weight:r}=n;return {id:o,component:"CheckBox",label:t,value:e,...r!==void 0&&{weight:r}}}function L(t,e,n={}){let{id:o=s("textfield"),weight:r,usageHint:a,validationRegexp:i}=n;return {id:o,component:"TextField",label:t,...e!==void 0&&{text:e},...r!==void 0&&{weight:r},...a&&{usageHint:a},...i&&{validationRegexp:i}}}function F(t,e={}){let{id:n=s("datetime"),weight:o,enableDate:r,enableTime:a,outputFormat:i,label:c}=e;return {id:n,component:"DateTimeInput",value:t,...o!==void 0&&{weight:o},...r!==void 0&&{enableDate:r},...a!==void 0&&{enableTime:a},...i&&{outputFormat:i},...c&&{label:c}}}function $(t,e,n,o={}){let{id:r=s("choice"),weight:a,label:i}=o;return {id:r,component:"ChoicePicker",options:t,value:e,usageHint:n,...a!==void 0&&{weight:a},...i&&{label:i}}}function G(t,e={}){let{id:n=s("slider"),weight:o,label:r,min:a,max:i}=e;return {id:n,component:"Slider",value:t,...o!==void 0&&{weight:o},...r&&{label:r},...a!==void 0&&{min:a},...i!==void 0&&{max:i}}}function d(t,e,n={}){let{id:o=s("chart"),weight:r,title:a,xAxis:i,yAxis:c,legend:f,tooltip:C,height:h,width:x,echartsOption:O}=n;return {id:o,component:"Chart",chartType:t,series:e,...r!==void 0&&{weight:r},...a&&{title:a},...i&&{xAxis:i},...c&&{yAxis:c},...f!==void 0&&{legend:f},...C!==void 0&&{tooltip:C},...h!==void 0&&{height:h},...x!==void 0&&{width:x},...O&&{echartsOption:O}}}function z(t,e={}){return d("line",t,e)}function J(t,e={}){return d("bar",t,e)}function W(t,e={}){return d("pie",t,e)}function X(t,e,n={}){let o=n.textId??s("btn_text"),r=p(t,{id:o}),a=I(o,e,n);return [r,a]}function Y(t,e={}){return p(t,{...e,usageHint:"h1"})}function K(t,e={}){return p(t,{...e,usageHint:"h2"})}function q(t,e={}){return p(t,{...e,usageHint:"h3"})}function Q(t,e={}){return p(t,{...e,usageHint:"h4"})}function Z(t,e={}){return p(t,{...e,usageHint:"h5"})}function ee(t,e={}){return p(t,{...e,usageHint:"caption"})}function te(t,e={}){return p(t,{...e,usageHint:"body"})}var g="https://a2ui.dev/specification/0.9/standard_catalog_definition.json";function M(t,e=g){return {createSurface:{surfaceId:t,catalogId:e}}}function y(t,e){return {updateComponents:{surfaceId:t,components:e}}}function S(t,e,n,o="replace"){return {updateDataModel:{surfaceId:t,...n&&{path:n},op:o,...o!=="remove"&&{value:e}}}}function ne(t){return {deleteSurface:{surfaceId:t}}}function oe(t){let{surfaceId:e,catalogId:n=g,components:o,dataModel:r}=t,a=[M(e,n),y(e,o)];return r&&a.push(S(e,r)),a}function re(t){return t.map(e=>JSON.stringify(e)).join(`
2
- `)}function ae(t){return t.split(`
3
- `).filter(e=>e.trim()).map(e=>JSON.parse(e))}var b={};function ie(t,e=""){let n=[];for(let[o,r]of Object.entries(t)){let a=e?`${e}/${o}`:`/${o}`;n.push(u(a,r));}return n}function u(t,e){if(e==null)return {key:t,valueString:""};if(typeof e=="string")return {key:t,valueString:e};if(typeof e=="number")return {key:t,valueNumber:e};if(typeof e=="boolean")return {key:t,valueBoolean:e};if(Array.isArray(e))return {key:t,valueMap:e.map((n,o)=>u(String(o),n))};if(typeof e=="object"){let n=[];for(let[o,r]of Object.entries(e))n.push(u(o,r));return {key:t,valueMap:n}}return {key:t,valueString:String(e)}}function T(t,e={}){let n=t.replace(/\./g,"/");n.startsWith("/")||(n=`/${n}`);for(let[o,r]of Object.entries(e)){let a=new RegExp(`^/${o}(/|$)`);a.test(n)&&(n=n.replace(a,`/${r}$1`));}return n}function se(t,e="",n=b){let o=[];for(let r of t){let a=r.path.startsWith("/")?r.path:`${e}/${r.path}`,i=T(a,n);if(r.value!==null&&typeof r.value=="object"&&!Array.isArray(r.value)){let c=m(r.value,i);o.push(...c);}else o.push(u(i,r.value));}return o}function m(t,e){let n=[];for(let[o,r]of Object.entries(t)){let a=`${e}/${o}`;if(r!==null&&typeof r=="object"&&!Array.isArray(r)){let i=m(r,a);n.push(...i);}else n.push(u(a,r));}return n}function v(t){let e={};for(let n of t){let o=n.key.startsWith("/")?n.key.slice(1):n.key;n.valueString!==void 0?e[o]=n.valueString:n.valueNumber!==void 0?e[o]=n.valueNumber:n.valueBoolean!==void 0?e[o]=n.valueBoolean:n.valueMap!==void 0&&(e[o]=v(n.valueMap));}return e}export{b as DEFAULT_PATH_MAPPINGS,U as audioPlayer,J as barChart,te as body,I as button,ee as caption,_ as card,d as chart,R as checkbox,$ as choicePicker,j as column,M as createSurface,oe as createV09Messages,F as dateTimeInput,ne as deleteSurface,B as divider,m as flattenObjectToValueMap,s as generateId,P as getIdCounter,Y as h1,K as h2,q as h3,Q as h4,Z as h5,A as icon,V as image,ae as jsonlToMessages,z as lineChart,k as list,re as messagesToJsonl,N as modal,T as normalizePath,ie as objectToValueMap,W as pieChart,D as resetIdCounter,E as row,G as slider,H as tabs,p as text,X as textButton,L as textField,y as updateComponents,S as updateDataModel,se as updatesToValueMap,v as valueMapToObject,u as valueToValueMap,w as video};
1
+ var g=0;function p(t="comp"){return `${t}_${Date.now()}_${g++}`}function b(){g=0;}function S(){return g}function M(t,e){let o={name:t};return e&&(o.context=e),{event:o}}function d(t,e={}){let{id:o=p("text"),weight:i,variant:n,accessibility:a}=e;return {id:o,component:"Text",text:t,...i!==void 0&&{weight:i},...n&&{variant:n},...a&&{accessibility:a}}}function T(t,e={}){let{id:o=p("image"),weight:i,fit:n,variant:a,accessibility:r}=e;return {id:o,component:"Image",url:t,...i!==void 0&&{weight:i},...n&&{fit:n},...a&&{variant:a},...r&&{accessibility:r}}}function v(t,e={}){let{id:o=p("icon"),weight:i,accessibility:n}=e;return {id:o,component:"Icon",name:t,...i!==void 0&&{weight:i},...n&&{accessibility:n}}}function A(t,e={}){let{id:o=p("video"),weight:i,accessibility:n}=e;return {id:o,component:"Video",url:t,...i!==void 0&&{weight:i},...n&&{accessibility:n}}}function k(t,e={}){let{id:o=p("audio"),weight:i,description:n,accessibility:a}=e;return {id:o,component:"AudioPlayer",url:t,...i!==void 0&&{weight:i},...n&&{description:n},...a&&{accessibility:a}}}function w(t,e={}){let{id:o=p("row"),weight:i,align:n,justify:a,accessibility:r}=e;return {id:o,component:"Row",children:t,...i!==void 0&&{weight:i},...n&&{align:n},...a&&{justify:a},...r&&{accessibility:r}}}function V(t,e={}){let{id:o=p("column"),weight:i,align:n,justify:a,accessibility:r}=e;return {id:o,component:"Column",children:t,...i!==void 0&&{weight:i},...n&&{align:n},...a&&{justify:a},...r&&{accessibility:r}}}function P(t,e={}){let{id:o=p("list"),weight:i,direction:n,align:a,accessibility:r}=e;return {id:o,component:"List",children:t,...i!==void 0&&{weight:i},...n&&{direction:n},...a&&{align:a},...r&&{accessibility:r}}}function L(t,e={}){let{id:o=p("card"),weight:i,accessibility:n}=e;return {id:o,component:"Card",child:t,...i!==void 0&&{weight:i},...n&&{accessibility:n}}}function R(t,e={}){let{id:o=p("tabs"),weight:i,accessibility:n}=e;return {id:o,component:"Tabs",tabs:t.map(a=>({title:a.title,child:a.childId})),...i!==void 0&&{weight:i},...n&&{accessibility:n}}}function F(t={}){let{id:e=p("divider"),weight:o,axis:i,accessibility:n}=t;return {id:e,component:"Divider",...o!==void 0&&{weight:o},...i&&{axis:i},...n&&{accessibility:n}}}function U(t,e,o={}){let{id:i=p("modal"),weight:n,accessibility:a}=o;return {id:i,component:"Modal",trigger:t,content:e,...n!==void 0&&{weight:n},...a&&{accessibility:a}}}function y(t,e,o={}){let{id:i=p("button"),weight:n,variant:a,checks:r,accessibility:s}=o;return {id:i,component:"Button",child:t,action:e,...n!==void 0&&{weight:n},...a&&{variant:a},...r&&r.length>0&&{checks:r},...s&&{accessibility:s}}}function B(t,e,o={}){let{id:i=p("checkbox"),weight:n,checks:a,accessibility:r}=o;return {id:i,component:"CheckBox",label:t,value:e,...n!==void 0&&{weight:n},...a&&a.length>0&&{checks:a},...r&&{accessibility:r}}}function E(t,e,o={}){let{id:i=p("textfield"),weight:n,variant:a,checks:r,accessibility:s}=o;return {id:i,component:"TextField",label:t,...e!==void 0&&{value:e},...n!==void 0&&{weight:n},...a&&{variant:a},...r&&r.length>0&&{checks:r},...s&&{accessibility:s}}}function _(t,e={}){let{id:o=p("datetime"),weight:i,enableDate:n,enableTime:a,min:r,max:s,label:c,checks:m,accessibility:u}=e;return {id:o,component:"DateTimeInput",value:t,...i!==void 0&&{weight:i},...n!==void 0&&{enableDate:n},...a!==void 0&&{enableTime:a},...r&&{min:r},...s&&{max:s},...c&&{label:c},...m&&m.length>0&&{checks:m},...u&&{accessibility:u}}}function j(t,e,o={}){let{id:i=p("choice"),weight:n,label:a,variant:r,checks:s,accessibility:c}=o;return {id:i,component:"ChoicePicker",options:t,value:e,...n!==void 0&&{weight:n},...a&&{label:a},...r&&{variant:r},...s&&s.length>0&&{checks:s},...c&&{accessibility:c}}}function N(t,e,o,i={}){let{id:n=p("slider"),weight:a,label:r,checks:s,accessibility:c}=i;return {id:n,component:"Slider",value:t,min:e,max:o,...a!==void 0&&{weight:a},...r&&{label:r},...s&&s.length>0&&{checks:s},...c&&{accessibility:c}}}function l(t,e,o={}){let{id:i=p("chart"),weight:n,title:a,xAxis:r,yAxis:s,legend:c,tooltip:m,height:u,width:f,echartsOption:x,accessibility:h}=o;return {id:i,component:"Chart",chartType:t,series:e,...n!==void 0&&{weight:n},...a&&{title:a},...r&&{xAxis:r},...s&&{yAxis:s},...c!==void 0&&{legend:c},...m!==void 0&&{tooltip:m},...u!==void 0&&{height:u},...f!==void 0&&{width:f},...x&&{echartsOption:x},...h&&{accessibility:h}}}function G(t,e={}){return l("line",t,e)}function $(t,e={}){return l("bar",t,e)}function J(t,e={}){return l("pie",t,e)}function z(t,e,o={}){let i=o.textId??p("btn_text"),n=d(t,{id:i}),a=y(i,e,o);return [n,a]}function H(t,e={}){return d(t,{...e,variant:"h1"})}function W(t,e={}){return d(t,{...e,variant:"h2"})}function q(t,e={}){return d(t,{...e,variant:"h3"})}function K(t,e={}){return d(t,{...e,variant:"h4"})}function Q(t,e={}){return d(t,{...e,variant:"h5"})}function X(t,e={}){return d(t,{...e,variant:"caption"})}function Y(t,e={}){return d(t,{...e,variant:"body"})}var C="https://a2ui.dev/specification/v0_9/standard_catalog.json";function O(t,e={}){let{catalogId:o=C,theme:i,sendDataModel:n}=e;return {createSurface:{surfaceId:t,catalogId:o,...i&&{theme:i},...n!==void 0&&{sendDataModel:n}}}}function D(t,e){return {updateComponents:{surfaceId:t,components:e}}}function I(t,e,o){return {updateDataModel:{surfaceId:t,...o&&{path:o},...e!==void 0&&{value:e}}}}function Z(t){return {deleteSurface:{surfaceId:t}}}function ee(t){let{surfaceId:e,catalogId:o,theme:i,sendDataModel:n,components:a,dataModel:r}=t,s=[O(e,{catalogId:o,theme:i,sendDataModel:n}),D(e,a)];return r&&s.push(I(e,r)),s}function te(t){return t.map(e=>JSON.stringify(e)).join(`
2
+ `)}function ne(t){return t.split(`
3
+ `).filter(e=>e.trim()).map(e=>JSON.parse(e))}var oe={};function ie(t,e={}){let o=t.replace(/\./g,"/");o.startsWith("/")||(o=`/${o}`);for(let[i,n]of Object.entries(e)){let a=new RegExp(`^/${i}(/|$)`);a.test(o)&&(o=o.replace(a,`/${n}$1`));}return o}export{oe as DEFAULT_PATH_MAPPINGS,k as audioPlayer,$ as barChart,Y as body,y as button,X as caption,L as card,l as chart,B as checkbox,j as choicePicker,V as column,ee as createMessages,O as createSurface,_ as dateTimeInput,Z as deleteSurface,F as divider,M as eventAction,p as generateId,S as getIdCounter,H as h1,W as h2,q as h3,K as h4,Q as h5,v as icon,T as image,ne as jsonlToMessages,G as lineChart,P as list,te as messagesToJsonl,U as modal,ie as normalizePath,J as pieChart,b as resetIdCounter,w as row,N as slider,R as tabs,d as text,z as textButton,E as textField,D as updateComponents,I as updateDataModel,A as video};