@zhama/a2ui-core 0.6.0 → 0.6.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.
@@ -1,3 +1,3 @@
1
- 'use strict';var l=0;function i(t="comp"){return `${t}_${Date.now()}_${l++}`}function I(){l=0;}function y(){return l}function p(t,e={}){let{id:n=i("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 S(t,e={}){let{id:n=i("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 b(t,e={}){let{id:n=i("icon"),weight:o}=e;return {id:n,component:"Icon",name:t,...o!==void 0&&{weight:o}}}function T(t,e={}){let{id:n=i("video"),weight:o}=e;return {id:n,component:"Video",url:t,...o!==void 0&&{weight:o}}}function v(t,e={}){let{id:n=i("audio"),weight:o,description:r}=e;return {id:n,component:"AudioPlayer",url:t,...o!==void 0&&{weight:o},...r&&{description:r}}}function D(t,e={}){let{id:n=i("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 P(t,e={}){let{id:n=i("column"),weight:o,alignment:r,distribution:a,classes:s}=e;return {id:n,component:"Column",children:t,...o!==void 0&&{weight:o},...r&&{alignment:r},...a&&{distribution:a},...s&&s.length>0&&{classes:s}}}function V(t,e={}){let{id:n=i("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 A(t,e={}){let{id:n=i("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 w(t,e={}){let{id:n=i("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 U(t={}){let{id:e=i("divider"),weight:n,axis:o}=t;return {id:e,component:"Divider",...n!==void 0&&{weight:n},...o&&{axis:o}}}function E(t,e,n={}){let{id:o=i("modal"),weight:r}=n;return {id:o,component:"Modal",entryPointChild:t,contentChild:e,...r!==void 0&&{weight:r}}}function m(t,e,n={}){let{id:o=i("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 j(t,e,n={}){let{id:o=i("checkbox"),weight:r}=n;return {id:o,component:"CheckBox",label:t,value:e,...r!==void 0&&{weight:r}}}function k(t,e,n={}){let{id:o=i("textfield"),weight:r,usageHint:a,validationRegexp:s}=n;return {id:o,component:"TextField",label:t,...e!==void 0&&{text:e},...r!==void 0&&{weight:r},...a&&{usageHint:a},...s&&{validationRegexp:s}}}function _(t,e={}){let{id:n=i("datetime"),weight:o,enableDate:r,enableTime:a,outputFormat:s,label:u}=e;return {id:n,component:"DateTimeInput",value:t,...o!==void 0&&{weight:o},...r!==void 0&&{enableDate:r},...a!==void 0&&{enableTime:a},...s&&{outputFormat:s},...u&&{label:u}}}function H(t,e,n,o={}){let{id:r=i("choice"),weight:a,label:s}=o;return {id:r,component:"ChoicePicker",options:t,value:e,usageHint:n,...a!==void 0&&{weight:a},...s&&{label:s}}}function B(t,e={}){let{id:n=i("slider"),weight:o,label:r,min:a,max:s}=e;return {id:n,component:"Slider",value:t,...o!==void 0&&{weight:o},...r&&{label:r},...a!==void 0&&{min:a},...s!==void 0&&{max:s}}}function N(t,e,n={}){let o=n.textId??i("btn_text"),r=p(t,{id:o}),a=m(o,e,n);return [r,a]}function R(t,e={}){return p(t,{...e,usageHint:"h1"})}function L(t,e={}){return p(t,{...e,usageHint:"h2"})}function F(t,e={}){return p(t,{...e,usageHint:"h3"})}function $(t,e={}){return p(t,{...e,usageHint:"h4"})}function G(t,e={}){return p(t,{...e,usageHint:"h5"})}function z(t,e={}){return p(t,{...e,usageHint:"caption"})}function J(t,e={}){return p(t,{...e,usageHint:"body"})}var d="https://a2ui.dev/specification/0.9/standard_catalog_definition.json";function f(t,e=d){return {createSurface:{surfaceId:t,catalogId:e}}}function C(t,e){return {updateComponents:{surfaceId:t,components:e}}}function x(t,e,n,o="replace"){return {updateDataModel:{surfaceId:t,...n&&{path:n},op:o,...o!=="remove"&&{value:e}}}}function W(t){return {deleteSurface:{surfaceId:t}}}function X(t){let{surfaceId:e,catalogId:n=d,components:o,dataModel:r}=t,a=[f(e,n),C(e,o)];return r&&a.push(x(e,r)),a}function Y(t){return t.map(e=>JSON.stringify(e)).join(`
2
- `)}function K(t){return t.split(`
3
- `).filter(e=>e.trim()).map(e=>JSON.parse(e))}var O={};function q(t,e=""){let n=[];for(let[o,r]of Object.entries(t)){let a=e?`${e}/${o}`:`/${o}`;n.push(c(a,r));}return n}function c(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)=>c(String(o),n))};if(typeof e=="object"){let n=[];for(let[o,r]of Object.entries(e))n.push(c(o,r));return {key:t,valueMap:n}}return {key:t,valueString:String(e)}}function h(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 Q(t,e="",n=O){let o=[];for(let r of t){let a=r.path.startsWith("/")?r.path:`${e}/${r.path}`,s=h(a,n);if(r.value!==null&&typeof r.value=="object"&&!Array.isArray(r.value)){let u=g(r.value,s);o.push(...u);}else o.push(c(s,r.value));}return o}function g(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 s=g(r,a);n.push(...s);}else n.push(c(a,r));}return n}function M(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]=M(n.valueMap));}return e}exports.DEFAULT_PATH_MAPPINGS=O;exports.audioPlayer=v;exports.body=J;exports.button=m;exports.caption=z;exports.card=A;exports.checkbox=j;exports.choicePicker=H;exports.column=P;exports.createSurface=f;exports.createV09Messages=X;exports.dateTimeInput=_;exports.deleteSurface=W;exports.divider=U;exports.flattenObjectToValueMap=g;exports.generateId=i;exports.getIdCounter=y;exports.h1=R;exports.h2=L;exports.h3=F;exports.h4=$;exports.h5=G;exports.icon=b;exports.image=S;exports.jsonlToMessages=K;exports.list=V;exports.messagesToJsonl=Y;exports.modal=E;exports.normalizePath=h;exports.objectToValueMap=q;exports.resetIdCounter=I;exports.row=D;exports.slider=B;exports.tabs=w;exports.text=p;exports.textButton=N;exports.textField=k;exports.updateComponents=C;exports.updateDataModel=x;exports.updatesToValueMap=Q;exports.valueMapToObject=M;exports.valueToValueMap=c;exports.video=T;
1
+ 'use strict';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}exports.DEFAULT_PATH_MAPPINGS=b;exports.audioPlayer=U;exports.barChart=J;exports.body=te;exports.button=I;exports.caption=ee;exports.card=_;exports.chart=d;exports.checkbox=R;exports.choicePicker=$;exports.column=j;exports.createSurface=M;exports.createV09Messages=oe;exports.dateTimeInput=F;exports.deleteSurface=ne;exports.divider=B;exports.flattenObjectToValueMap=m;exports.generateId=s;exports.getIdCounter=P;exports.h1=Y;exports.h2=K;exports.h3=q;exports.h4=Q;exports.h5=Z;exports.icon=A;exports.image=V;exports.jsonlToMessages=ae;exports.lineChart=z;exports.list=k;exports.messagesToJsonl=re;exports.modal=N;exports.normalizePath=T;exports.objectToValueMap=ie;exports.pieChart=W;exports.resetIdCounter=D;exports.row=E;exports.slider=G;exports.tabs=H;exports.text=p;exports.textButton=X;exports.textField=L;exports.updateComponents=y;exports.updateDataModel=S;exports.updatesToValueMap=se;exports.valueMapToObject=v;exports.valueToValueMap=u;exports.video=w;
@@ -1,5 +1,5 @@
1
1
  import { S as StringOrPath, B as BooleanOrPath, a as StringArrayOrPath, N as NumberOrPath } from '../primitives-DLbBDhLq.cjs';
2
- import { TextComponent, ImageComponent, RowComponent, ListComponent, DividerComponent, TextFieldComponent, ComponentInstance, ChildrenProperty, Action, ChoicePickerComponent, CreateSurfaceMessage, UpdateComponentsMessage, UpdateDataModelMessage, DeleteSurfaceMessage, DataObject, ServerToClientMessageV09, DataValue } from '../types/index.cjs';
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.cjs';
3
3
 
4
4
  /**
5
5
  * ID Generator
@@ -151,6 +151,21 @@ interface SliderOptions extends ComponentOptions {
151
151
  min?: number;
152
152
  max?: number;
153
153
  }
154
+ /**
155
+ * Chart 组件选项
156
+ */
157
+ interface ChartOptions extends ComponentOptions {
158
+ title?: StringOrPath;
159
+ xAxis?: ChartAxisConfig;
160
+ yAxis?: ChartAxisConfig;
161
+ legend?: boolean;
162
+ tooltip?: boolean;
163
+ height?: number;
164
+ width?: number | string;
165
+ echartsOption?: Record<string, unknown> | {
166
+ path: string;
167
+ };
168
+ }
154
169
  /**
155
170
  * 创建 Text 组件
156
171
  *
@@ -299,6 +314,49 @@ declare function choicePicker(optionsList: Array<{
299
314
  * @param options - 选项
300
315
  */
301
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
+ */
339
+ declare function chart(chartType: ChartType, series: ChartSeries[] | {
340
+ path: string;
341
+ }, options?: ChartOptions): ComponentInstance;
342
+ /**
343
+ * 创建折线图组件(便捷函数)
344
+ */
345
+ declare function lineChart(series: ChartSeries[] | {
346
+ path: string;
347
+ }, options?: ChartOptions): ComponentInstance;
348
+ /**
349
+ * 创建柱状图组件(便捷函数)
350
+ */
351
+ declare function barChart(series: ChartSeries[] | {
352
+ path: string;
353
+ }, options?: ChartOptions): ComponentInstance;
354
+ /**
355
+ * 创建饼图组件(便捷函数)
356
+ */
357
+ declare function pieChart(series: ChartSeries[] | {
358
+ path: string;
359
+ }, options?: ChartOptions): ComponentInstance;
302
360
  /**
303
361
  * 创建带文本的按钮(返回按钮和文本组件)
304
362
  *
@@ -534,4 +592,4 @@ declare function flattenObjectToValueMap(obj: DataObject, basePath: string): Val
534
592
  */
535
593
  declare function valueMapToObject(valueMaps: ValueMap[]): DataObject;
536
594
 
537
- export { type AudioPlayerOptions, type ButtonOptions, type CardOptions, 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, body, button, caption, card, checkbox, choicePicker, column, createSurface, createV09Messages, dateTimeInput, deleteSurface, divider, flattenObjectToValueMap, generateId, getIdCounter, h1, h2, h3, h4, h5, icon, image, jsonlToMessages, list, messagesToJsonl, modal, normalizePath, objectToValueMap, resetIdCounter, row, slider, tabs, text, textButton, textField, updateComponents, updateDataModel, updatesToValueMap, valueMapToObject, valueToValueMap, video };
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 };
@@ -1,5 +1,5 @@
1
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, ComponentInstance, ChildrenProperty, Action, ChoicePickerComponent, CreateSurfaceMessage, UpdateComponentsMessage, UpdateDataModelMessage, DeleteSurfaceMessage, DataObject, ServerToClientMessageV09, DataValue } from '../types/index.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';
3
3
 
4
4
  /**
5
5
  * ID Generator
@@ -151,6 +151,21 @@ interface SliderOptions extends ComponentOptions {
151
151
  min?: number;
152
152
  max?: number;
153
153
  }
154
+ /**
155
+ * Chart 组件选项
156
+ */
157
+ interface ChartOptions extends ComponentOptions {
158
+ title?: StringOrPath;
159
+ xAxis?: ChartAxisConfig;
160
+ yAxis?: ChartAxisConfig;
161
+ legend?: boolean;
162
+ tooltip?: boolean;
163
+ height?: number;
164
+ width?: number | string;
165
+ echartsOption?: Record<string, unknown> | {
166
+ path: string;
167
+ };
168
+ }
154
169
  /**
155
170
  * 创建 Text 组件
156
171
  *
@@ -299,6 +314,49 @@ declare function choicePicker(optionsList: Array<{
299
314
  * @param options - 选项
300
315
  */
301
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
+ */
339
+ declare function chart(chartType: ChartType, series: ChartSeries[] | {
340
+ path: string;
341
+ }, options?: ChartOptions): ComponentInstance;
342
+ /**
343
+ * 创建折线图组件(便捷函数)
344
+ */
345
+ declare function lineChart(series: ChartSeries[] | {
346
+ path: string;
347
+ }, options?: ChartOptions): ComponentInstance;
348
+ /**
349
+ * 创建柱状图组件(便捷函数)
350
+ */
351
+ declare function barChart(series: ChartSeries[] | {
352
+ path: string;
353
+ }, options?: ChartOptions): ComponentInstance;
354
+ /**
355
+ * 创建饼图组件(便捷函数)
356
+ */
357
+ declare function pieChart(series: ChartSeries[] | {
358
+ path: string;
359
+ }, options?: ChartOptions): ComponentInstance;
302
360
  /**
303
361
  * 创建带文本的按钮(返回按钮和文本组件)
304
362
  *
@@ -534,4 +592,4 @@ declare function flattenObjectToValueMap(obj: DataObject, basePath: string): Val
534
592
  */
535
593
  declare function valueMapToObject(valueMaps: ValueMap[]): DataObject;
536
594
 
537
- export { type AudioPlayerOptions, type ButtonOptions, type CardOptions, 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, body, button, caption, card, checkbox, choicePicker, column, createSurface, createV09Messages, dateTimeInput, deleteSurface, divider, flattenObjectToValueMap, generateId, getIdCounter, h1, h2, h3, h4, h5, icon, image, jsonlToMessages, list, messagesToJsonl, modal, normalizePath, objectToValueMap, resetIdCounter, row, slider, tabs, text, textButton, textField, updateComponents, updateDataModel, updatesToValueMap, valueMapToObject, valueToValueMap, video };
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 };
@@ -1,3 +1,3 @@
1
- var l=0;function i(t="comp"){return `${t}_${Date.now()}_${l++}`}function I(){l=0;}function y(){return l}function p(t,e={}){let{id:n=i("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 S(t,e={}){let{id:n=i("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 b(t,e={}){let{id:n=i("icon"),weight:o}=e;return {id:n,component:"Icon",name:t,...o!==void 0&&{weight:o}}}function T(t,e={}){let{id:n=i("video"),weight:o}=e;return {id:n,component:"Video",url:t,...o!==void 0&&{weight:o}}}function v(t,e={}){let{id:n=i("audio"),weight:o,description:r}=e;return {id:n,component:"AudioPlayer",url:t,...o!==void 0&&{weight:o},...r&&{description:r}}}function D(t,e={}){let{id:n=i("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 P(t,e={}){let{id:n=i("column"),weight:o,alignment:r,distribution:a,classes:s}=e;return {id:n,component:"Column",children:t,...o!==void 0&&{weight:o},...r&&{alignment:r},...a&&{distribution:a},...s&&s.length>0&&{classes:s}}}function V(t,e={}){let{id:n=i("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 A(t,e={}){let{id:n=i("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 w(t,e={}){let{id:n=i("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 U(t={}){let{id:e=i("divider"),weight:n,axis:o}=t;return {id:e,component:"Divider",...n!==void 0&&{weight:n},...o&&{axis:o}}}function E(t,e,n={}){let{id:o=i("modal"),weight:r}=n;return {id:o,component:"Modal",entryPointChild:t,contentChild:e,...r!==void 0&&{weight:r}}}function m(t,e,n={}){let{id:o=i("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 j(t,e,n={}){let{id:o=i("checkbox"),weight:r}=n;return {id:o,component:"CheckBox",label:t,value:e,...r!==void 0&&{weight:r}}}function k(t,e,n={}){let{id:o=i("textfield"),weight:r,usageHint:a,validationRegexp:s}=n;return {id:o,component:"TextField",label:t,...e!==void 0&&{text:e},...r!==void 0&&{weight:r},...a&&{usageHint:a},...s&&{validationRegexp:s}}}function _(t,e={}){let{id:n=i("datetime"),weight:o,enableDate:r,enableTime:a,outputFormat:s,label:u}=e;return {id:n,component:"DateTimeInput",value:t,...o!==void 0&&{weight:o},...r!==void 0&&{enableDate:r},...a!==void 0&&{enableTime:a},...s&&{outputFormat:s},...u&&{label:u}}}function H(t,e,n,o={}){let{id:r=i("choice"),weight:a,label:s}=o;return {id:r,component:"ChoicePicker",options:t,value:e,usageHint:n,...a!==void 0&&{weight:a},...s&&{label:s}}}function B(t,e={}){let{id:n=i("slider"),weight:o,label:r,min:a,max:s}=e;return {id:n,component:"Slider",value:t,...o!==void 0&&{weight:o},...r&&{label:r},...a!==void 0&&{min:a},...s!==void 0&&{max:s}}}function N(t,e,n={}){let o=n.textId??i("btn_text"),r=p(t,{id:o}),a=m(o,e,n);return [r,a]}function R(t,e={}){return p(t,{...e,usageHint:"h1"})}function L(t,e={}){return p(t,{...e,usageHint:"h2"})}function F(t,e={}){return p(t,{...e,usageHint:"h3"})}function $(t,e={}){return p(t,{...e,usageHint:"h4"})}function G(t,e={}){return p(t,{...e,usageHint:"h5"})}function z(t,e={}){return p(t,{...e,usageHint:"caption"})}function J(t,e={}){return p(t,{...e,usageHint:"body"})}var d="https://a2ui.dev/specification/0.9/standard_catalog_definition.json";function f(t,e=d){return {createSurface:{surfaceId:t,catalogId:e}}}function C(t,e){return {updateComponents:{surfaceId:t,components:e}}}function x(t,e,n,o="replace"){return {updateDataModel:{surfaceId:t,...n&&{path:n},op:o,...o!=="remove"&&{value:e}}}}function W(t){return {deleteSurface:{surfaceId:t}}}function X(t){let{surfaceId:e,catalogId:n=d,components:o,dataModel:r}=t,a=[f(e,n),C(e,o)];return r&&a.push(x(e,r)),a}function Y(t){return t.map(e=>JSON.stringify(e)).join(`
2
- `)}function K(t){return t.split(`
3
- `).filter(e=>e.trim()).map(e=>JSON.parse(e))}var O={};function q(t,e=""){let n=[];for(let[o,r]of Object.entries(t)){let a=e?`${e}/${o}`:`/${o}`;n.push(c(a,r));}return n}function c(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)=>c(String(o),n))};if(typeof e=="object"){let n=[];for(let[o,r]of Object.entries(e))n.push(c(o,r));return {key:t,valueMap:n}}return {key:t,valueString:String(e)}}function h(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 Q(t,e="",n=O){let o=[];for(let r of t){let a=r.path.startsWith("/")?r.path:`${e}/${r.path}`,s=h(a,n);if(r.value!==null&&typeof r.value=="object"&&!Array.isArray(r.value)){let u=g(r.value,s);o.push(...u);}else o.push(c(s,r.value));}return o}function g(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 s=g(r,a);n.push(...s);}else n.push(c(a,r));}return n}function M(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]=M(n.valueMap));}return e}export{O as DEFAULT_PATH_MAPPINGS,v as audioPlayer,J as body,m as button,z as caption,A as card,j as checkbox,H as choicePicker,P as column,f as createSurface,X as createV09Messages,_ as dateTimeInput,W as deleteSurface,U as divider,g as flattenObjectToValueMap,i as generateId,y as getIdCounter,R as h1,L as h2,F as h3,$ as h4,G as h5,b as icon,S as image,K as jsonlToMessages,V as list,Y as messagesToJsonl,E as modal,h as normalizePath,q as objectToValueMap,I as resetIdCounter,D as row,B as slider,w as tabs,p as text,N as textButton,k as textField,C as updateComponents,x as updateDataModel,Q as updatesToValueMap,M as valueMapToObject,c as valueToValueMap,T as video};
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};
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';function A(e){return "createSurface"in e||"updateComponents"in e||"updateDataModel"in e}var g="https://a2ui.dev/specification/0.9/standard_catalog_definition.json";var E="https://a2ui.dev/specification/0.9",N="application/json+a2ui";var O=0;function s(e="comp"){return `${e}_${Date.now()}_${O++}`}function R(){O=0;}function _(){return O}function c(e,t={}){let{id:o=s("text"),weight:a,usageHint:n,classes:r}=t;return {id:o,component:"Text",text:e,...a!==void 0&&{weight:a},...n&&{usageHint:n},...r&&r.length>0&&{classes:r}}}function U(e,t={}){let{id:o=s("image"),weight:a,fit:n,usageHint:r}=t;return {id:o,component:"Image",url:e,...a!==void 0&&{weight:a},...n&&{fit:n},...r&&{usageHint:r}}}function w(e,t={}){let{id:o=s("icon"),weight:a}=t;return {id:o,component:"Icon",name:e,...a!==void 0&&{weight:a}}}function k(e,t={}){let{id:o=s("video"),weight:a}=t;return {id:o,component:"Video",url:e,...a!==void 0&&{weight:a}}}function j(e,t={}){let{id:o=s("audio"),weight:a,description:n}=t;return {id:o,component:"AudioPlayer",url:e,...a!==void 0&&{weight:a},...n&&{description:n}}}function F(e,t={}){let{id:o=s("row"),weight:a,alignment:n,distribution:r}=t;return {id:o,component:"Row",children:e,...a!==void 0&&{weight:a},...n&&{alignment:n},...r&&{distribution:r}}}function B(e,t={}){let{id:o=s("column"),weight:a,alignment:n,distribution:r,classes:i}=t;return {id:o,component:"Column",children:e,...a!==void 0&&{weight:a},...n&&{alignment:n},...r&&{distribution:r},...i&&i.length>0&&{classes:i}}}function L(e,t={}){let{id:o=s("list"),weight:a,direction:n,alignment:r}=t;return {id:o,component:"List",children:e,...a!==void 0&&{weight:a},...n&&{direction:n},...r&&{alignment:r}}}function H(e,t={}){let{id:o=s("card"),weight:a,classes:n}=t;return {id:o,component:"Card",child:e,...a!==void 0&&{weight:a},...n&&n.length>0&&{classes:n}}}function $(e,t={}){let{id:o=s("tabs"),weight:a}=t;return {id:o,component:"Tabs",tabItems:e.map(n=>({title:n.title,child:n.childId})),...a!==void 0&&{weight:a}}}function G(e={}){let{id:t=s("divider"),weight:o,axis:a}=e;return {id:t,component:"Divider",...o!==void 0&&{weight:o},...a&&{axis:a}}}function W(e,t,o={}){let{id:a=s("modal"),weight:n}=o;return {id:a,component:"Modal",entryPointChild:e,contentChild:t,...n!==void 0&&{weight:n}}}function M(e,t,o={}){let{id:a=s("button"),weight:n,primary:r}=o;return {id:a,component:"Button",child:e,action:t,...n!==void 0&&{weight:n},...r!==void 0&&{primary:r}}}function q(e,t,o={}){let{id:a=s("checkbox"),weight:n}=o;return {id:a,component:"CheckBox",label:e,value:t,...n!==void 0&&{weight:n}}}function Y(e,t,o={}){let{id:a=s("textfield"),weight:n,usageHint:r,validationRegexp:i}=o;return {id:a,component:"TextField",label:e,...t!==void 0&&{text:t},...n!==void 0&&{weight:n},...r&&{usageHint:r},...i&&{validationRegexp:i}}}function z(e,t={}){let{id:o=s("datetime"),weight:a,enableDate:n,enableTime:r,outputFormat:i,label:p}=t;return {id:o,component:"DateTimeInput",value:e,...a!==void 0&&{weight:a},...n!==void 0&&{enableDate:n},...r!==void 0&&{enableTime:r},...i&&{outputFormat:i},...p&&{label:p}}}function J(e,t,o,a={}){let{id:n=s("choice"),weight:r,label:i}=a;return {id:n,component:"ChoicePicker",options:e,value:t,usageHint:o,...r!==void 0&&{weight:r},...i&&{label:i}}}function X(e,t={}){let{id:o=s("slider"),weight:a,label:n,min:r,max:i}=t;return {id:o,component:"Slider",value:e,...a!==void 0&&{weight:a},...n&&{label:n},...r!==void 0&&{min:r},...i!==void 0&&{max:i}}}function K(e,t,o={}){let a=o.textId??s("btn_text"),n=c(e,{id:a}),r=M(a,t,o);return [n,r]}function Q(e,t={}){return c(e,{...t,usageHint:"h1"})}function Z(e,t={}){return c(e,{...t,usageHint:"h2"})}function ee(e,t={}){return c(e,{...t,usageHint:"h3"})}function te(e,t={}){return c(e,{...t,usageHint:"h4"})}function ne(e,t={}){return c(e,{...t,usageHint:"h5"})}function oe(e,t={}){return c(e,{...t,usageHint:"caption"})}function ae(e,t={}){return c(e,{...t,usageHint:"body"})}function m(e,t=g){return {createSurface:{surfaceId:e,catalogId:t}}}function f(e,t){return {updateComponents:{surfaceId:e,components:t}}}function C(e,t,o,a="replace"){return {updateDataModel:{surfaceId:e,...o&&{path:o},op:a,...a!=="remove"&&{value:t}}}}function h(e){return {deleteSurface:{surfaceId:e}}}function re(e){let{surfaceId:t,catalogId:o=g,components:a,dataModel:n}=e,r=[m(t,o),f(t,a)];return n&&r.push(C(t,n)),r}function ie(e){return e.map(t=>JSON.stringify(t)).join(`
2
- `)}function se(e){return e.split(`
3
- `).filter(t=>t.trim()).map(t=>JSON.parse(t))}var y={};function pe(e,t=""){let o=[];for(let[a,n]of Object.entries(e)){let r=t?`${t}/${a}`:`/${a}`;o.push(d(r,n));}return o}function d(e,t){if(t==null)return {key:e,valueString:""};if(typeof t=="string")return {key:e,valueString:t};if(typeof t=="number")return {key:e,valueNumber:t};if(typeof t=="boolean")return {key:e,valueBoolean:t};if(Array.isArray(t))return {key:e,valueMap:t.map((o,a)=>d(String(a),o))};if(typeof t=="object"){let o=[];for(let[a,n]of Object.entries(t))o.push(d(a,n));return {key:e,valueMap:o}}return {key:e,valueString:String(t)}}function T(e,t={}){let o=e.replace(/\./g,"/");o.startsWith("/")||(o=`/${o}`);for(let[a,n]of Object.entries(t)){let r=new RegExp(`^/${a}(/|$)`);r.test(o)&&(o=o.replace(r,`/${n}$1`));}return o}function ce(e,t="",o=y){let a=[];for(let n of e){let r=n.path.startsWith("/")?n.path:`${t}/${n.path}`,i=T(r,o);if(n.value!==null&&typeof n.value=="object"&&!Array.isArray(n.value)){let p=S(n.value,i);a.push(...p);}else a.push(d(i,n.value));}return a}function S(e,t){let o=[];for(let[a,n]of Object.entries(e)){let r=`${t}/${a}`;if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let i=S(n,r);o.push(...i);}else o.push(d(r,n));}return o}function D(e){let t={};for(let o of e){let a=o.key.startsWith("/")?o.key.slice(1):o.key;o.valueString!==void 0?t[a]=o.valueString:o.valueNumber!==void 0?t[a]=o.valueNumber:o.valueBoolean!==void 0?t[a]=o.valueBoolean:o.valueMap!==void 0&&(t[a]=D(o.valueMap));}return t}var Se=["Text","Image","Icon","Video","AudioPlayer","Row","Column","List","Card","Tabs","Divider","Modal","Button","CheckBox","TextField","DateTimeInput","ChoicePicker","Slider"];function V(e,t={}){let o=[],a=[];if("createSurface"in e){let{createSurface:n}=e;n.surfaceId||o.push({code:"MISSING_SURFACE_ID",message:"createSurface.surfaceId is required",path:"createSurface.surfaceId"}),n.catalogId||o.push({code:"MISSING_CATALOG_ID",message:"createSurface.catalogId is required",path:"createSurface.catalogId"});}else if("updateComponents"in e){let{updateComponents:n}=e;n.surfaceId||o.push({code:"MISSING_SURFACE_ID",message:"updateComponents.surfaceId is required",path:"updateComponents.surfaceId"}),!n.components||!Array.isArray(n.components)?o.push({code:"INVALID_COMPONENTS",message:"updateComponents.components must be an array",path:"updateComponents.components"}):Oe(n.components,o,a,t);}else if("updateDataModel"in e){let{updateDataModel:n}=e;n.surfaceId||o.push({code:"MISSING_SURFACE_ID",message:"updateDataModel.surfaceId is required",path:"updateDataModel.surfaceId"}),n.op&&!["add","replace","remove"].includes(n.op)&&o.push({code:"INVALID_OP",message:"updateDataModel.op must be one of: add, replace, remove",path:"updateDataModel.op"}),n.op==="remove"&&n.value!==void 0&&a.push({code:"UNNECESSARY_VALUE",message:"updateDataModel.value should not be provided for remove operation",path:"updateDataModel.value"}),n.op!=="remove"&&n.value===void 0&&n.op==="add"&&o.push({code:"MISSING_VALUE",message:"updateDataModel.value is required for add operation",path:"updateDataModel.value"});}else if("deleteSurface"in e){let{deleteSurface:n}=e;n.surfaceId||o.push({code:"MISSING_SURFACE_ID",message:"deleteSurface.surfaceId is required",path:"deleteSurface.surfaceId"});}else o.push({code:"INVALID_MESSAGE_TYPE",message:"Message must contain one of: createSurface, updateComponents, updateDataModel, deleteSurface"});return {valid:o.length===0,errors:o,warnings:a}}function b(e,t={}){return V(e,t)}function ue(e,t={}){let o=[],a=[];for(let n=0;n<e.length;n++){let r=e[n];if(!r)continue;let i=b(r,t);for(let p of i.errors)o.push({...p,path:`messages[${n}].${p.path??""}`});for(let p of i.warnings)a.push({...p,path:`messages[${n}].${p.path??""}`});}return {valid:o.length===0,errors:o,warnings:a}}function Oe(e,t,o,a){let n=new Set,r=false;for(let i=0;i<e.length;i++){let p=e[i];if(!p)continue;let I=`updateComponents.components[${i}]`;p.id?(n.has(p.id)&&t.push({code:"DUPLICATE_COMPONENT_ID",message:`Duplicate component id: ${p.id}`,path:`${I}.id`}),n.add(p.id),p.id==="root"&&(r=true)):t.push({code:"MISSING_COMPONENT_ID",message:"Component id is required",path:`${I}.id`}),p.component?a.strict&&!Se.includes(p.component)&&a.allowedComponents&&!a.allowedComponents.includes(p.component)&&o.push({code:"UNKNOWN_COMPONENT_TYPE",message:`Unknown component type: ${p.component}`,path:`${I}.component`}):t.push({code:"MISSING_COMPONENT_TYPE",message:"Component type is required",path:`${I}.component`});}!r&&a.strict&&o.push({code:"MISSING_ROOT_COMPONENT",message:'No component with id "root" found',path:"updateComponents.components"});}function v(e){return typeof e=="object"&&e!==null&&"path"in e}function Me(e){if(!v(e))return e}function ye(e){if(v(e))return e.path}function Te(e){return {path:e}}function de(e,t){let o={...e};for(let a of Object.keys(t)){let n=t[a],r=o[a];n!==void 0&&typeof n=="object"&&n!==null&&!Array.isArray(n)&&typeof r=="object"&&r!==null&&!Array.isArray(r)?o[a]=de(r,n):n!==void 0&&(o[a]=n);}return o}function De(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return (e==="x"?t:t&3|8).toString(16)})}var u={CHAT:"@chat",RECOMMENDATION:"@recommendation",INPUT_FORM:"@input-form",ORCHESTRATION:"@orchestration",STATUS:"@status",RESULT:"@result",CONFIRM:"@confirm",NOTIFICATION:"@notification"},P=0;function x(e="surface"){return P++,`${e}-${Date.now()}-${P}`}function le(){P=0;}function l(e,t,o){let a=o??x();return t.find(i=>i.id===e)||console.warn(`[A2UI] Root component "${e}" not found in components list`),{messages:[m(a),f(a,t)],surfaceId:a}}function me(e,t,o,a){let n=a??x();return {messages:[m(n),f(n,t),C(n,o)],surfaceId:n}}function fe(e){return h(e)}function ge(e,t){return l(e,t,u.CHAT)}function Ce(e,t){return l(e,t,u.RECOMMENDATION)}function xe(e,t){return l(e,t,u.INPUT_FORM)}function Ie(e,t){return l(e,t,u.ORCHESTRATION)}function he(e,t){return l(e,t,u.STATUS)}exports.A2UI_EXTENSION_URI=E;exports.A2UI_MIME_TYPE=N;exports.DEFAULT_PATH_MAPPINGS=y;exports.STANDARD_CATALOG_ID=g;exports.SURFACE_IDS=u;exports.audioPlayer=j;exports.body=ae;exports.button=M;exports.caption=oe;exports.card=H;exports.checkbox=q;exports.choicePicker=J;exports.column=B;exports.createA2UISurface=l;exports.createA2UISurfaceWithData=me;exports.createChatSurface=ge;exports.createDeleteSurfaceMessage=fe;exports.createInputFormSurface=xe;exports.createOrchestrationSurface=Ie;exports.createRecommendationSurface=Ce;exports.createStatusSurface=he;exports.createSurface=m;exports.createV09Messages=re;exports.dateTimeInput=z;exports.deepMerge=de;exports.deleteSurface=h;exports.divider=G;exports.flattenObjectToValueMap=S;exports.generateId=s;exports.generateSurfaceId=x;exports.getIdCounter=_;exports.getLiteralValue=Me;exports.getPathValue=ye;exports.h1=Q;exports.h2=Z;exports.h3=ee;exports.h4=te;exports.h5=ne;exports.icon=w;exports.image=U;exports.isPathBinding=v;exports.isV09Message=A;exports.jsonlToMessages=se;exports.list=L;exports.messagesToJsonl=ie;exports.modal=W;exports.normalizePath=T;exports.objectToValueMap=pe;exports.path=Te;exports.resetIdCounter=R;exports.resetSurfaceIdCounter=le;exports.row=F;exports.slider=X;exports.tabs=$;exports.text=c;exports.textButton=K;exports.textField=Y;exports.updateComponents=f;exports.updateDataModel=C;exports.updatesToValueMap=ce;exports.uuid=De;exports.validateMessage=b;exports.validateMessages=ue;exports.validateV09Message=V;exports.valueMapToObject=D;exports.valueToValueMap=d;exports.video=k;
1
+ 'use strict';function U(e){return "createSurface"in e||"updateComponents"in e||"updateDataModel"in e}var C="https://a2ui.dev/specification/0.9/standard_catalog_definition.json";var w="https://a2ui.dev/specification/0.9",k="application/json+a2ui";var M=0;function p(e="comp"){return `${e}_${Date.now()}_${M++}`}function j(){M=0;}function F(){return M}function c(e,t={}){let{id:o=p("text"),weight:a,usageHint:n,classes:r}=t;return {id:o,component:"Text",text:e,...a!==void 0&&{weight:a},...n&&{usageHint:n},...r&&r.length>0&&{classes:r}}}function B(e,t={}){let{id:o=p("image"),weight:a,fit:n,usageHint:r}=t;return {id:o,component:"Image",url:e,...a!==void 0&&{weight:a},...n&&{fit:n},...r&&{usageHint:r}}}function L(e,t={}){let{id:o=p("icon"),weight:a}=t;return {id:o,component:"Icon",name:e,...a!==void 0&&{weight:a}}}function H(e,t={}){let{id:o=p("video"),weight:a}=t;return {id:o,component:"Video",url:e,...a!==void 0&&{weight:a}}}function $(e,t={}){let{id:o=p("audio"),weight:a,description:n}=t;return {id:o,component:"AudioPlayer",url:e,...a!==void 0&&{weight:a},...n&&{description:n}}}function G(e,t={}){let{id:o=p("row"),weight:a,alignment:n,distribution:r}=t;return {id:o,component:"Row",children:e,...a!==void 0&&{weight:a},...n&&{alignment:n},...r&&{distribution:r}}}function W(e,t={}){let{id:o=p("column"),weight:a,alignment:n,distribution:r,classes:i}=t;return {id:o,component:"Column",children:e,...a!==void 0&&{weight:a},...n&&{alignment:n},...r&&{distribution:r},...i&&i.length>0&&{classes:i}}}function q(e,t={}){let{id:o=p("list"),weight:a,direction:n,alignment:r}=t;return {id:o,component:"List",children:e,...a!==void 0&&{weight:a},...n&&{direction:n},...r&&{alignment:r}}}function Y(e,t={}){let{id:o=p("card"),weight:a,classes:n}=t;return {id:o,component:"Card",child:e,...a!==void 0&&{weight:a},...n&&n.length>0&&{classes:n}}}function z(e,t={}){let{id:o=p("tabs"),weight:a}=t;return {id:o,component:"Tabs",tabItems:e.map(n=>({title:n.title,child:n.childId})),...a!==void 0&&{weight:a}}}function J(e={}){let{id:t=p("divider"),weight:o,axis:a}=e;return {id:t,component:"Divider",...o!==void 0&&{weight:o},...a&&{axis:a}}}function X(e,t,o={}){let{id:a=p("modal"),weight:n}=o;return {id:a,component:"Modal",entryPointChild:e,contentChild:t,...n!==void 0&&{weight:n}}}function y(e,t,o={}){let{id:a=p("button"),weight:n,primary:r}=o;return {id:a,component:"Button",child:e,action:t,...n!==void 0&&{weight:n},...r!==void 0&&{primary:r}}}function K(e,t,o={}){let{id:a=p("checkbox"),weight:n}=o;return {id:a,component:"CheckBox",label:e,value:t,...n!==void 0&&{weight:n}}}function Q(e,t,o={}){let{id:a=p("textfield"),weight:n,usageHint:r,validationRegexp:i}=o;return {id:a,component:"TextField",label:e,...t!==void 0&&{text:t},...n!==void 0&&{weight:n},...r&&{usageHint:r},...i&&{validationRegexp:i}}}function Z(e,t={}){let{id:o=p("datetime"),weight:a,enableDate:n,enableTime:r,outputFormat:i,label:s}=t;return {id:o,component:"DateTimeInput",value:e,...a!==void 0&&{weight:a},...n!==void 0&&{enableDate:n},...r!==void 0&&{enableTime:r},...i&&{outputFormat:i},...s&&{label:s}}}function ee(e,t,o,a={}){let{id:n=p("choice"),weight:r,label:i}=a;return {id:n,component:"ChoicePicker",options:e,value:t,usageHint:o,...r!==void 0&&{weight:r},...i&&{label:i}}}function te(e,t={}){let{id:o=p("slider"),weight:a,label:n,min:r,max:i}=t;return {id:o,component:"Slider",value:e,...a!==void 0&&{weight:a},...n&&{label:n},...r!==void 0&&{min:r},...i!==void 0&&{max:i}}}function h(e,t,o={}){let{id:a=p("chart"),weight:n,title:r,xAxis:i,yAxis:s,legend:d,tooltip:E,height:N,width:R,echartsOption:_}=o;return {id:a,component:"Chart",chartType:e,series:t,...n!==void 0&&{weight:n},...r&&{title:r},...i&&{xAxis:i},...s&&{yAxis:s},...d!==void 0&&{legend:d},...E!==void 0&&{tooltip:E},...N!==void 0&&{height:N},...R!==void 0&&{width:R},..._&&{echartsOption:_}}}function ne(e,t={}){return h("line",e,t)}function oe(e,t={}){return h("bar",e,t)}function ae(e,t={}){return h("pie",e,t)}function re(e,t,o={}){let a=o.textId??p("btn_text"),n=c(e,{id:a}),r=y(a,t,o);return [n,r]}function ie(e,t={}){return c(e,{...t,usageHint:"h1"})}function se(e,t={}){return c(e,{...t,usageHint:"h2"})}function pe(e,t={}){return c(e,{...t,usageHint:"h3"})}function ce(e,t={}){return c(e,{...t,usageHint:"h4"})}function ue(e,t={}){return c(e,{...t,usageHint:"h5"})}function de(e,t={}){return c(e,{...t,usageHint:"caption"})}function le(e,t={}){return c(e,{...t,usageHint:"body"})}function f(e,t=C){return {createSurface:{surfaceId:e,catalogId:t}}}function g(e,t){return {updateComponents:{surfaceId:e,components:t}}}function x(e,t,o,a="replace"){return {updateDataModel:{surfaceId:e,...o&&{path:o},op:a,...a!=="remove"&&{value:t}}}}function I(e){return {deleteSurface:{surfaceId:e}}}function me(e){let{surfaceId:t,catalogId:o=C,components:a,dataModel:n}=e,r=[f(t,o),g(t,a)];return n&&r.push(x(t,n)),r}function fe(e){return e.map(t=>JSON.stringify(t)).join(`
2
+ `)}function ge(e){return e.split(`
3
+ `).filter(t=>t.trim()).map(t=>JSON.parse(t))}var T={};function Ce(e,t=""){let o=[];for(let[a,n]of Object.entries(e)){let r=t?`${t}/${a}`:`/${a}`;o.push(l(r,n));}return o}function l(e,t){if(t==null)return {key:e,valueString:""};if(typeof t=="string")return {key:e,valueString:t};if(typeof t=="number")return {key:e,valueNumber:t};if(typeof t=="boolean")return {key:e,valueBoolean:t};if(Array.isArray(t))return {key:e,valueMap:t.map((o,a)=>l(String(a),o))};if(typeof t=="object"){let o=[];for(let[a,n]of Object.entries(t))o.push(l(a,n));return {key:e,valueMap:o}}return {key:e,valueString:String(t)}}function D(e,t={}){let o=e.replace(/\./g,"/");o.startsWith("/")||(o=`/${o}`);for(let[a,n]of Object.entries(t)){let r=new RegExp(`^/${a}(/|$)`);r.test(o)&&(o=o.replace(r,`/${n}$1`));}return o}function he(e,t="",o=T){let a=[];for(let n of e){let r=n.path.startsWith("/")?n.path:`${t}/${n.path}`,i=D(r,o);if(n.value!==null&&typeof n.value=="object"&&!Array.isArray(n.value)){let s=O(n.value,i);a.push(...s);}else a.push(l(i,n.value));}return a}function O(e,t){let o=[];for(let[a,n]of Object.entries(e)){let r=`${t}/${a}`;if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let i=O(n,r);o.push(...i);}else o.push(l(r,n));}return o}function b(e){let t={};for(let o of e){let a=o.key.startsWith("/")?o.key.slice(1):o.key;o.valueString!==void 0?t[a]=o.valueString:o.valueNumber!==void 0?t[a]=o.valueNumber:o.valueBoolean!==void 0?t[a]=o.valueBoolean:o.valueMap!==void 0&&(t[a]=b(o.valueMap));}return t}var ve=["Text","Image","Icon","Video","AudioPlayer","Row","Column","List","Card","Tabs","Divider","Modal","Button","CheckBox","TextField","DateTimeInput","ChoicePicker","Slider"];function V(e,t={}){let o=[],a=[];if("createSurface"in e){let{createSurface:n}=e;n.surfaceId||o.push({code:"MISSING_SURFACE_ID",message:"createSurface.surfaceId is required",path:"createSurface.surfaceId"}),n.catalogId||o.push({code:"MISSING_CATALOG_ID",message:"createSurface.catalogId is required",path:"createSurface.catalogId"});}else if("updateComponents"in e){let{updateComponents:n}=e;n.surfaceId||o.push({code:"MISSING_SURFACE_ID",message:"updateComponents.surfaceId is required",path:"updateComponents.surfaceId"}),!n.components||!Array.isArray(n.components)?o.push({code:"INVALID_COMPONENTS",message:"updateComponents.components must be an array",path:"updateComponents.components"}):Ae(n.components,o,a,t);}else if("updateDataModel"in e){let{updateDataModel:n}=e;n.surfaceId||o.push({code:"MISSING_SURFACE_ID",message:"updateDataModel.surfaceId is required",path:"updateDataModel.surfaceId"}),n.op&&!["add","replace","remove"].includes(n.op)&&o.push({code:"INVALID_OP",message:"updateDataModel.op must be one of: add, replace, remove",path:"updateDataModel.op"}),n.op==="remove"&&n.value!==void 0&&a.push({code:"UNNECESSARY_VALUE",message:"updateDataModel.value should not be provided for remove operation",path:"updateDataModel.value"}),n.op!=="remove"&&n.value===void 0&&n.op==="add"&&o.push({code:"MISSING_VALUE",message:"updateDataModel.value is required for add operation",path:"updateDataModel.value"});}else if("deleteSurface"in e){let{deleteSurface:n}=e;n.surfaceId||o.push({code:"MISSING_SURFACE_ID",message:"deleteSurface.surfaceId is required",path:"deleteSurface.surfaceId"});}else o.push({code:"INVALID_MESSAGE_TYPE",message:"Message must contain one of: createSurface, updateComponents, updateDataModel, deleteSurface"});return {valid:o.length===0,errors:o,warnings:a}}function v(e,t={}){return V(e,t)}function xe(e,t={}){let o=[],a=[];for(let n=0;n<e.length;n++){let r=e[n];if(!r)continue;let i=v(r,t);for(let s of i.errors)o.push({...s,path:`messages[${n}].${s.path??""}`});for(let s of i.warnings)a.push({...s,path:`messages[${n}].${s.path??""}`});}return {valid:o.length===0,errors:o,warnings:a}}function Ae(e,t,o,a){let n=new Set,r=false;for(let i=0;i<e.length;i++){let s=e[i];if(!s)continue;let d=`updateComponents.components[${i}]`;s.id?(n.has(s.id)&&t.push({code:"DUPLICATE_COMPONENT_ID",message:`Duplicate component id: ${s.id}`,path:`${d}.id`}),n.add(s.id),s.id==="root"&&(r=true)):t.push({code:"MISSING_COMPONENT_ID",message:"Component id is required",path:`${d}.id`}),s.component?a.strict&&!ve.includes(s.component)&&a.allowedComponents&&!a.allowedComponents.includes(s.component)&&o.push({code:"UNKNOWN_COMPONENT_TYPE",message:`Unknown component type: ${s.component}`,path:`${d}.component`}):t.push({code:"MISSING_COMPONENT_TYPE",message:"Component type is required",path:`${d}.component`});}!r&&a.strict&&o.push({code:"MISSING_ROOT_COMPONENT",message:'No component with id "root" found',path:"updateComponents.components"});}function A(e){return typeof e=="object"&&e!==null&&"path"in e}function Pe(e){if(!A(e))return e}function Ee(e){if(A(e))return e.path}function Ne(e){return {path:e}}function Se(e,t){let o={...e};for(let a of Object.keys(t)){let n=t[a],r=o[a];n!==void 0&&typeof n=="object"&&n!==null&&!Array.isArray(n)&&typeof r=="object"&&r!==null&&!Array.isArray(r)?o[a]=Se(r,n):n!==void 0&&(o[a]=n);}return o}function Re(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return (e==="x"?t:t&3|8).toString(16)})}var u={CHAT:"@chat",RECOMMENDATION:"@recommendation",INPUT_FORM:"@input-form",ORCHESTRATION:"@orchestration",STATUS:"@status",RESULT:"@result",CONFIRM:"@confirm",NOTIFICATION:"@notification"},P=0;function S(e="surface"){return P++,`${e}-${Date.now()}-${P}`}function Ie(){P=0;}function m(e,t,o){let a=o??S();return t.find(i=>i.id===e)||console.warn(`[A2UI] Root component "${e}" not found in components list`),{messages:[f(a),g(a,t)],surfaceId:a}}function Oe(e,t,o,a){let n=a??S();return {messages:[f(n),g(n,t),x(n,o)],surfaceId:n}}function Me(e){return I(e)}function ye(e,t){return m(e,t,u.CHAT)}function Te(e,t){return m(e,t,u.RECOMMENDATION)}function De(e,t){return m(e,t,u.INPUT_FORM)}function be(e,t){return m(e,t,u.ORCHESTRATION)}function Ve(e,t){return m(e,t,u.STATUS)}exports.A2UI_EXTENSION_URI=w;exports.A2UI_MIME_TYPE=k;exports.DEFAULT_PATH_MAPPINGS=T;exports.STANDARD_CATALOG_ID=C;exports.SURFACE_IDS=u;exports.audioPlayer=$;exports.barChart=oe;exports.body=le;exports.button=y;exports.caption=de;exports.card=Y;exports.chart=h;exports.checkbox=K;exports.choicePicker=ee;exports.column=W;exports.createA2UISurface=m;exports.createA2UISurfaceWithData=Oe;exports.createChatSurface=ye;exports.createDeleteSurfaceMessage=Me;exports.createInputFormSurface=De;exports.createOrchestrationSurface=be;exports.createRecommendationSurface=Te;exports.createStatusSurface=Ve;exports.createSurface=f;exports.createV09Messages=me;exports.dateTimeInput=Z;exports.deepMerge=Se;exports.deleteSurface=I;exports.divider=J;exports.flattenObjectToValueMap=O;exports.generateId=p;exports.generateSurfaceId=S;exports.getIdCounter=F;exports.getLiteralValue=Pe;exports.getPathValue=Ee;exports.h1=ie;exports.h2=se;exports.h3=pe;exports.h4=ce;exports.h5=ue;exports.icon=L;exports.image=B;exports.isPathBinding=A;exports.isV09Message=U;exports.jsonlToMessages=ge;exports.lineChart=ne;exports.list=q;exports.messagesToJsonl=fe;exports.modal=X;exports.normalizePath=D;exports.objectToValueMap=Ce;exports.path=Ne;exports.pieChart=ae;exports.resetIdCounter=j;exports.resetSurfaceIdCounter=Ie;exports.row=G;exports.slider=te;exports.tabs=z;exports.text=c;exports.textButton=re;exports.textField=Q;exports.updateComponents=g;exports.updateDataModel=x;exports.updatesToValueMap=he;exports.uuid=Re;exports.validateMessage=v;exports.validateMessages=xe;exports.validateV09Message=V;exports.valueMapToObject=b;exports.valueToValueMap=l;exports.video=H;
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { B as BooleanOrPath, C as ContextValue, N as NumberOrPath, a as StringArrayOrPath, S as StringOrPath } from './primitives-DLbBDhLq.cjs';
2
- export { A2UI_EXTENSION_URI, A2UI_MIME_TYPE, Action, AnyComponent, AudioPlayerComponent, ButtonComponent, CardComponent, CheckBoxComponent, ChildrenProperty, ChoicePickerComponent, ClientErrorMessage, ClientToServerMessage, ColumnComponent, ComponentCommon, ComponentInstance, ComponentType, CreateSurfaceMessage, DataArray, DataChangeEvent, DataObject, DataValue, DateTimeInputComponent, DeleteSurfaceMessage, DividerComponent, GenericError, IconComponent, ImageComponent, ListComponent, ModalComponent, RowComponent, STANDARD_CATALOG_ID, ServerToClientMessageV09 as ServerToClientMessage, ServerToClientMessageV09, SliderComponent, StandardIconName, TabsComponent, TextComponent, TextFieldComponent, Theme, UpdateComponentsMessage, UpdateDataModelMessage, UserActionEvent, ValidationFailedError, VideoComponent, isV09Message } from './types/index.cjs';
3
- export { AudioPlayerOptions, ButtonOptions, CardOptions, CheckBoxOptions, ChoicePickerOptions, ComponentOptions, DEFAULT_PATH_MAPPINGS, DateTimeInputOptions, DividerOptions, IconOptions, ImageOptions, LayoutOptions, ListOptions, ModalOptions, PathMappings, SliderOptions, TabItem, TabsOptions, TextFieldOptions, TextOptions, UpdateDataItem, VideoOptions, audioPlayer, body, button, caption, card, checkbox, choicePicker, column, createSurface, createV09Messages, dateTimeInput, deleteSurface, divider, flattenObjectToValueMap, generateId, getIdCounter, h1, h2, h3, h4, h5, icon, image, jsonlToMessages, list, messagesToJsonl, modal, normalizePath, objectToValueMap, resetIdCounter, row, slider, tabs, text, textButton, textField, updateComponents, updateDataModel, updatesToValueMap, valueMapToObject, valueToValueMap, video } from './builders/index.cjs';
2
+ export { A2UI_EXTENSION_URI, A2UI_MIME_TYPE, Action, AnyComponent, AudioPlayerComponent, ButtonComponent, CardComponent, ChartAxisConfig, ChartComponent, ChartSeries, ChartType, CheckBoxComponent, ChildrenProperty, ChoicePickerComponent, ClientErrorMessage, ClientToServerMessage, ColumnComponent, ComponentCommon, ComponentInstance, ComponentType, CreateSurfaceMessage, DataArray, DataChangeEvent, DataObject, DataValue, DateTimeInputComponent, DeleteSurfaceMessage, DividerComponent, GenericError, IconComponent, ImageComponent, ListComponent, ModalComponent, RowComponent, STANDARD_CATALOG_ID, ServerToClientMessageV09 as ServerToClientMessage, ServerToClientMessageV09, SliderComponent, StandardIconName, TabsComponent, TextComponent, TextFieldComponent, Theme, UpdateComponentsMessage, UpdateDataModelMessage, UserActionEvent, ValidationFailedError, VideoComponent, isV09Message } from './types/index.cjs';
3
+ export { AudioPlayerOptions, ButtonOptions, CardOptions, ChartOptions, CheckBoxOptions, ChoicePickerOptions, ComponentOptions, DEFAULT_PATH_MAPPINGS, DateTimeInputOptions, DividerOptions, IconOptions, ImageOptions, LayoutOptions, ListOptions, ModalOptions, PathMappings, SliderOptions, TabItem, TabsOptions, TextFieldOptions, TextOptions, UpdateDataItem, 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 } from './builders/index.cjs';
4
4
  export { ValidationError, ValidationOptions, ValidationResult, ValidationWarning, validateMessage, validateMessages, validateV09Message } from './validators/index.cjs';
5
5
  export { deepMerge, getLiteralValue, getPathValue, isPathBinding, path, uuid } from './utils/index.cjs';
6
6
  export { SURFACE_IDS, SurfaceConfig, SurfaceIdType, SurfaceResult, createA2UISurface, createA2UISurfaceWithData, createChatSurface, createDeleteSurfaceMessage, createInputFormSurface, createOrchestrationSurface, createRecommendationSurface, createStatusSurface, generateSurfaceId, resetSurfaceIdCounter } from './surface/index.cjs';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { B as BooleanOrPath, C as ContextValue, N as NumberOrPath, a as StringArrayOrPath, S as StringOrPath } from './primitives-DLbBDhLq.js';
2
- export { A2UI_EXTENSION_URI, A2UI_MIME_TYPE, Action, AnyComponent, AudioPlayerComponent, ButtonComponent, CardComponent, CheckBoxComponent, ChildrenProperty, ChoicePickerComponent, ClientErrorMessage, ClientToServerMessage, ColumnComponent, ComponentCommon, ComponentInstance, ComponentType, CreateSurfaceMessage, DataArray, DataChangeEvent, DataObject, DataValue, DateTimeInputComponent, DeleteSurfaceMessage, DividerComponent, GenericError, IconComponent, ImageComponent, ListComponent, ModalComponent, RowComponent, STANDARD_CATALOG_ID, ServerToClientMessageV09 as ServerToClientMessage, ServerToClientMessageV09, SliderComponent, StandardIconName, TabsComponent, TextComponent, TextFieldComponent, Theme, UpdateComponentsMessage, UpdateDataModelMessage, UserActionEvent, ValidationFailedError, VideoComponent, isV09Message } from './types/index.js';
3
- export { AudioPlayerOptions, ButtonOptions, CardOptions, CheckBoxOptions, ChoicePickerOptions, ComponentOptions, DEFAULT_PATH_MAPPINGS, DateTimeInputOptions, DividerOptions, IconOptions, ImageOptions, LayoutOptions, ListOptions, ModalOptions, PathMappings, SliderOptions, TabItem, TabsOptions, TextFieldOptions, TextOptions, UpdateDataItem, VideoOptions, audioPlayer, body, button, caption, card, checkbox, choicePicker, column, createSurface, createV09Messages, dateTimeInput, deleteSurface, divider, flattenObjectToValueMap, generateId, getIdCounter, h1, h2, h3, h4, h5, icon, image, jsonlToMessages, list, messagesToJsonl, modal, normalizePath, objectToValueMap, resetIdCounter, row, slider, tabs, text, textButton, textField, updateComponents, updateDataModel, updatesToValueMap, valueMapToObject, valueToValueMap, video } from './builders/index.js';
2
+ export { A2UI_EXTENSION_URI, A2UI_MIME_TYPE, Action, AnyComponent, AudioPlayerComponent, ButtonComponent, CardComponent, ChartAxisConfig, ChartComponent, ChartSeries, ChartType, CheckBoxComponent, ChildrenProperty, ChoicePickerComponent, ClientErrorMessage, ClientToServerMessage, ColumnComponent, ComponentCommon, ComponentInstance, ComponentType, CreateSurfaceMessage, DataArray, DataChangeEvent, DataObject, DataValue, DateTimeInputComponent, DeleteSurfaceMessage, DividerComponent, GenericError, IconComponent, ImageComponent, ListComponent, ModalComponent, RowComponent, STANDARD_CATALOG_ID, ServerToClientMessageV09 as ServerToClientMessage, ServerToClientMessageV09, SliderComponent, StandardIconName, TabsComponent, TextComponent, TextFieldComponent, Theme, UpdateComponentsMessage, UpdateDataModelMessage, UserActionEvent, ValidationFailedError, VideoComponent, isV09Message } from './types/index.js';
3
+ export { AudioPlayerOptions, ButtonOptions, CardOptions, ChartOptions, CheckBoxOptions, ChoicePickerOptions, ComponentOptions, DEFAULT_PATH_MAPPINGS, DateTimeInputOptions, DividerOptions, IconOptions, ImageOptions, LayoutOptions, ListOptions, ModalOptions, PathMappings, SliderOptions, TabItem, TabsOptions, TextFieldOptions, TextOptions, UpdateDataItem, 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 } from './builders/index.js';
4
4
  export { ValidationError, ValidationOptions, ValidationResult, ValidationWarning, validateMessage, validateMessages, validateV09Message } from './validators/index.js';
5
5
  export { deepMerge, getLiteralValue, getPathValue, isPathBinding, path, uuid } from './utils/index.js';
6
6
  export { SURFACE_IDS, SurfaceConfig, SurfaceIdType, SurfaceResult, createA2UISurface, createA2UISurfaceWithData, createChatSurface, createDeleteSurfaceMessage, createInputFormSurface, createOrchestrationSurface, createRecommendationSurface, createStatusSurface, generateSurfaceId, resetSurfaceIdCounter } from './surface/index.js';
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- function A(e){return "createSurface"in e||"updateComponents"in e||"updateDataModel"in e}var g="https://a2ui.dev/specification/0.9/standard_catalog_definition.json";var E="https://a2ui.dev/specification/0.9",N="application/json+a2ui";var O=0;function s(e="comp"){return `${e}_${Date.now()}_${O++}`}function R(){O=0;}function _(){return O}function c(e,t={}){let{id:o=s("text"),weight:a,usageHint:n,classes:r}=t;return {id:o,component:"Text",text:e,...a!==void 0&&{weight:a},...n&&{usageHint:n},...r&&r.length>0&&{classes:r}}}function U(e,t={}){let{id:o=s("image"),weight:a,fit:n,usageHint:r}=t;return {id:o,component:"Image",url:e,...a!==void 0&&{weight:a},...n&&{fit:n},...r&&{usageHint:r}}}function w(e,t={}){let{id:o=s("icon"),weight:a}=t;return {id:o,component:"Icon",name:e,...a!==void 0&&{weight:a}}}function k(e,t={}){let{id:o=s("video"),weight:a}=t;return {id:o,component:"Video",url:e,...a!==void 0&&{weight:a}}}function j(e,t={}){let{id:o=s("audio"),weight:a,description:n}=t;return {id:o,component:"AudioPlayer",url:e,...a!==void 0&&{weight:a},...n&&{description:n}}}function F(e,t={}){let{id:o=s("row"),weight:a,alignment:n,distribution:r}=t;return {id:o,component:"Row",children:e,...a!==void 0&&{weight:a},...n&&{alignment:n},...r&&{distribution:r}}}function B(e,t={}){let{id:o=s("column"),weight:a,alignment:n,distribution:r,classes:i}=t;return {id:o,component:"Column",children:e,...a!==void 0&&{weight:a},...n&&{alignment:n},...r&&{distribution:r},...i&&i.length>0&&{classes:i}}}function L(e,t={}){let{id:o=s("list"),weight:a,direction:n,alignment:r}=t;return {id:o,component:"List",children:e,...a!==void 0&&{weight:a},...n&&{direction:n},...r&&{alignment:r}}}function H(e,t={}){let{id:o=s("card"),weight:a,classes:n}=t;return {id:o,component:"Card",child:e,...a!==void 0&&{weight:a},...n&&n.length>0&&{classes:n}}}function $(e,t={}){let{id:o=s("tabs"),weight:a}=t;return {id:o,component:"Tabs",tabItems:e.map(n=>({title:n.title,child:n.childId})),...a!==void 0&&{weight:a}}}function G(e={}){let{id:t=s("divider"),weight:o,axis:a}=e;return {id:t,component:"Divider",...o!==void 0&&{weight:o},...a&&{axis:a}}}function W(e,t,o={}){let{id:a=s("modal"),weight:n}=o;return {id:a,component:"Modal",entryPointChild:e,contentChild:t,...n!==void 0&&{weight:n}}}function M(e,t,o={}){let{id:a=s("button"),weight:n,primary:r}=o;return {id:a,component:"Button",child:e,action:t,...n!==void 0&&{weight:n},...r!==void 0&&{primary:r}}}function q(e,t,o={}){let{id:a=s("checkbox"),weight:n}=o;return {id:a,component:"CheckBox",label:e,value:t,...n!==void 0&&{weight:n}}}function Y(e,t,o={}){let{id:a=s("textfield"),weight:n,usageHint:r,validationRegexp:i}=o;return {id:a,component:"TextField",label:e,...t!==void 0&&{text:t},...n!==void 0&&{weight:n},...r&&{usageHint:r},...i&&{validationRegexp:i}}}function z(e,t={}){let{id:o=s("datetime"),weight:a,enableDate:n,enableTime:r,outputFormat:i,label:p}=t;return {id:o,component:"DateTimeInput",value:e,...a!==void 0&&{weight:a},...n!==void 0&&{enableDate:n},...r!==void 0&&{enableTime:r},...i&&{outputFormat:i},...p&&{label:p}}}function J(e,t,o,a={}){let{id:n=s("choice"),weight:r,label:i}=a;return {id:n,component:"ChoicePicker",options:e,value:t,usageHint:o,...r!==void 0&&{weight:r},...i&&{label:i}}}function X(e,t={}){let{id:o=s("slider"),weight:a,label:n,min:r,max:i}=t;return {id:o,component:"Slider",value:e,...a!==void 0&&{weight:a},...n&&{label:n},...r!==void 0&&{min:r},...i!==void 0&&{max:i}}}function K(e,t,o={}){let a=o.textId??s("btn_text"),n=c(e,{id:a}),r=M(a,t,o);return [n,r]}function Q(e,t={}){return c(e,{...t,usageHint:"h1"})}function Z(e,t={}){return c(e,{...t,usageHint:"h2"})}function ee(e,t={}){return c(e,{...t,usageHint:"h3"})}function te(e,t={}){return c(e,{...t,usageHint:"h4"})}function ne(e,t={}){return c(e,{...t,usageHint:"h5"})}function oe(e,t={}){return c(e,{...t,usageHint:"caption"})}function ae(e,t={}){return c(e,{...t,usageHint:"body"})}function m(e,t=g){return {createSurface:{surfaceId:e,catalogId:t}}}function f(e,t){return {updateComponents:{surfaceId:e,components:t}}}function C(e,t,o,a="replace"){return {updateDataModel:{surfaceId:e,...o&&{path:o},op:a,...a!=="remove"&&{value:t}}}}function h(e){return {deleteSurface:{surfaceId:e}}}function re(e){let{surfaceId:t,catalogId:o=g,components:a,dataModel:n}=e,r=[m(t,o),f(t,a)];return n&&r.push(C(t,n)),r}function ie(e){return e.map(t=>JSON.stringify(t)).join(`
2
- `)}function se(e){return e.split(`
3
- `).filter(t=>t.trim()).map(t=>JSON.parse(t))}var y={};function pe(e,t=""){let o=[];for(let[a,n]of Object.entries(e)){let r=t?`${t}/${a}`:`/${a}`;o.push(d(r,n));}return o}function d(e,t){if(t==null)return {key:e,valueString:""};if(typeof t=="string")return {key:e,valueString:t};if(typeof t=="number")return {key:e,valueNumber:t};if(typeof t=="boolean")return {key:e,valueBoolean:t};if(Array.isArray(t))return {key:e,valueMap:t.map((o,a)=>d(String(a),o))};if(typeof t=="object"){let o=[];for(let[a,n]of Object.entries(t))o.push(d(a,n));return {key:e,valueMap:o}}return {key:e,valueString:String(t)}}function T(e,t={}){let o=e.replace(/\./g,"/");o.startsWith("/")||(o=`/${o}`);for(let[a,n]of Object.entries(t)){let r=new RegExp(`^/${a}(/|$)`);r.test(o)&&(o=o.replace(r,`/${n}$1`));}return o}function ce(e,t="",o=y){let a=[];for(let n of e){let r=n.path.startsWith("/")?n.path:`${t}/${n.path}`,i=T(r,o);if(n.value!==null&&typeof n.value=="object"&&!Array.isArray(n.value)){let p=S(n.value,i);a.push(...p);}else a.push(d(i,n.value));}return a}function S(e,t){let o=[];for(let[a,n]of Object.entries(e)){let r=`${t}/${a}`;if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let i=S(n,r);o.push(...i);}else o.push(d(r,n));}return o}function D(e){let t={};for(let o of e){let a=o.key.startsWith("/")?o.key.slice(1):o.key;o.valueString!==void 0?t[a]=o.valueString:o.valueNumber!==void 0?t[a]=o.valueNumber:o.valueBoolean!==void 0?t[a]=o.valueBoolean:o.valueMap!==void 0&&(t[a]=D(o.valueMap));}return t}var Se=["Text","Image","Icon","Video","AudioPlayer","Row","Column","List","Card","Tabs","Divider","Modal","Button","CheckBox","TextField","DateTimeInput","ChoicePicker","Slider"];function V(e,t={}){let o=[],a=[];if("createSurface"in e){let{createSurface:n}=e;n.surfaceId||o.push({code:"MISSING_SURFACE_ID",message:"createSurface.surfaceId is required",path:"createSurface.surfaceId"}),n.catalogId||o.push({code:"MISSING_CATALOG_ID",message:"createSurface.catalogId is required",path:"createSurface.catalogId"});}else if("updateComponents"in e){let{updateComponents:n}=e;n.surfaceId||o.push({code:"MISSING_SURFACE_ID",message:"updateComponents.surfaceId is required",path:"updateComponents.surfaceId"}),!n.components||!Array.isArray(n.components)?o.push({code:"INVALID_COMPONENTS",message:"updateComponents.components must be an array",path:"updateComponents.components"}):Oe(n.components,o,a,t);}else if("updateDataModel"in e){let{updateDataModel:n}=e;n.surfaceId||o.push({code:"MISSING_SURFACE_ID",message:"updateDataModel.surfaceId is required",path:"updateDataModel.surfaceId"}),n.op&&!["add","replace","remove"].includes(n.op)&&o.push({code:"INVALID_OP",message:"updateDataModel.op must be one of: add, replace, remove",path:"updateDataModel.op"}),n.op==="remove"&&n.value!==void 0&&a.push({code:"UNNECESSARY_VALUE",message:"updateDataModel.value should not be provided for remove operation",path:"updateDataModel.value"}),n.op!=="remove"&&n.value===void 0&&n.op==="add"&&o.push({code:"MISSING_VALUE",message:"updateDataModel.value is required for add operation",path:"updateDataModel.value"});}else if("deleteSurface"in e){let{deleteSurface:n}=e;n.surfaceId||o.push({code:"MISSING_SURFACE_ID",message:"deleteSurface.surfaceId is required",path:"deleteSurface.surfaceId"});}else o.push({code:"INVALID_MESSAGE_TYPE",message:"Message must contain one of: createSurface, updateComponents, updateDataModel, deleteSurface"});return {valid:o.length===0,errors:o,warnings:a}}function b(e,t={}){return V(e,t)}function ue(e,t={}){let o=[],a=[];for(let n=0;n<e.length;n++){let r=e[n];if(!r)continue;let i=b(r,t);for(let p of i.errors)o.push({...p,path:`messages[${n}].${p.path??""}`});for(let p of i.warnings)a.push({...p,path:`messages[${n}].${p.path??""}`});}return {valid:o.length===0,errors:o,warnings:a}}function Oe(e,t,o,a){let n=new Set,r=false;for(let i=0;i<e.length;i++){let p=e[i];if(!p)continue;let I=`updateComponents.components[${i}]`;p.id?(n.has(p.id)&&t.push({code:"DUPLICATE_COMPONENT_ID",message:`Duplicate component id: ${p.id}`,path:`${I}.id`}),n.add(p.id),p.id==="root"&&(r=true)):t.push({code:"MISSING_COMPONENT_ID",message:"Component id is required",path:`${I}.id`}),p.component?a.strict&&!Se.includes(p.component)&&a.allowedComponents&&!a.allowedComponents.includes(p.component)&&o.push({code:"UNKNOWN_COMPONENT_TYPE",message:`Unknown component type: ${p.component}`,path:`${I}.component`}):t.push({code:"MISSING_COMPONENT_TYPE",message:"Component type is required",path:`${I}.component`});}!r&&a.strict&&o.push({code:"MISSING_ROOT_COMPONENT",message:'No component with id "root" found',path:"updateComponents.components"});}function v(e){return typeof e=="object"&&e!==null&&"path"in e}function Me(e){if(!v(e))return e}function ye(e){if(v(e))return e.path}function Te(e){return {path:e}}function de(e,t){let o={...e};for(let a of Object.keys(t)){let n=t[a],r=o[a];n!==void 0&&typeof n=="object"&&n!==null&&!Array.isArray(n)&&typeof r=="object"&&r!==null&&!Array.isArray(r)?o[a]=de(r,n):n!==void 0&&(o[a]=n);}return o}function De(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return (e==="x"?t:t&3|8).toString(16)})}var u={CHAT:"@chat",RECOMMENDATION:"@recommendation",INPUT_FORM:"@input-form",ORCHESTRATION:"@orchestration",STATUS:"@status",RESULT:"@result",CONFIRM:"@confirm",NOTIFICATION:"@notification"},P=0;function x(e="surface"){return P++,`${e}-${Date.now()}-${P}`}function le(){P=0;}function l(e,t,o){let a=o??x();return t.find(i=>i.id===e)||console.warn(`[A2UI] Root component "${e}" not found in components list`),{messages:[m(a),f(a,t)],surfaceId:a}}function me(e,t,o,a){let n=a??x();return {messages:[m(n),f(n,t),C(n,o)],surfaceId:n}}function fe(e){return h(e)}function ge(e,t){return l(e,t,u.CHAT)}function Ce(e,t){return l(e,t,u.RECOMMENDATION)}function xe(e,t){return l(e,t,u.INPUT_FORM)}function Ie(e,t){return l(e,t,u.ORCHESTRATION)}function he(e,t){return l(e,t,u.STATUS)}export{E as A2UI_EXTENSION_URI,N as A2UI_MIME_TYPE,y as DEFAULT_PATH_MAPPINGS,g as STANDARD_CATALOG_ID,u as SURFACE_IDS,j as audioPlayer,ae as body,M as button,oe as caption,H as card,q as checkbox,J as choicePicker,B as column,l as createA2UISurface,me as createA2UISurfaceWithData,ge as createChatSurface,fe as createDeleteSurfaceMessage,xe as createInputFormSurface,Ie as createOrchestrationSurface,Ce as createRecommendationSurface,he as createStatusSurface,m as createSurface,re as createV09Messages,z as dateTimeInput,de as deepMerge,h as deleteSurface,G as divider,S as flattenObjectToValueMap,s as generateId,x as generateSurfaceId,_ as getIdCounter,Me as getLiteralValue,ye as getPathValue,Q as h1,Z as h2,ee as h3,te as h4,ne as h5,w as icon,U as image,v as isPathBinding,A as isV09Message,se as jsonlToMessages,L as list,ie as messagesToJsonl,W as modal,T as normalizePath,pe as objectToValueMap,Te as path,R as resetIdCounter,le as resetSurfaceIdCounter,F as row,X as slider,$ as tabs,c as text,K as textButton,Y as textField,f as updateComponents,C as updateDataModel,ce as updatesToValueMap,De as uuid,b as validateMessage,ue as validateMessages,V as validateV09Message,D as valueMapToObject,d as valueToValueMap,k as video};
1
+ function U(e){return "createSurface"in e||"updateComponents"in e||"updateDataModel"in e}var C="https://a2ui.dev/specification/0.9/standard_catalog_definition.json";var w="https://a2ui.dev/specification/0.9",k="application/json+a2ui";var M=0;function p(e="comp"){return `${e}_${Date.now()}_${M++}`}function j(){M=0;}function F(){return M}function c(e,t={}){let{id:o=p("text"),weight:a,usageHint:n,classes:r}=t;return {id:o,component:"Text",text:e,...a!==void 0&&{weight:a},...n&&{usageHint:n},...r&&r.length>0&&{classes:r}}}function B(e,t={}){let{id:o=p("image"),weight:a,fit:n,usageHint:r}=t;return {id:o,component:"Image",url:e,...a!==void 0&&{weight:a},...n&&{fit:n},...r&&{usageHint:r}}}function L(e,t={}){let{id:o=p("icon"),weight:a}=t;return {id:o,component:"Icon",name:e,...a!==void 0&&{weight:a}}}function H(e,t={}){let{id:o=p("video"),weight:a}=t;return {id:o,component:"Video",url:e,...a!==void 0&&{weight:a}}}function $(e,t={}){let{id:o=p("audio"),weight:a,description:n}=t;return {id:o,component:"AudioPlayer",url:e,...a!==void 0&&{weight:a},...n&&{description:n}}}function G(e,t={}){let{id:o=p("row"),weight:a,alignment:n,distribution:r}=t;return {id:o,component:"Row",children:e,...a!==void 0&&{weight:a},...n&&{alignment:n},...r&&{distribution:r}}}function W(e,t={}){let{id:o=p("column"),weight:a,alignment:n,distribution:r,classes:i}=t;return {id:o,component:"Column",children:e,...a!==void 0&&{weight:a},...n&&{alignment:n},...r&&{distribution:r},...i&&i.length>0&&{classes:i}}}function q(e,t={}){let{id:o=p("list"),weight:a,direction:n,alignment:r}=t;return {id:o,component:"List",children:e,...a!==void 0&&{weight:a},...n&&{direction:n},...r&&{alignment:r}}}function Y(e,t={}){let{id:o=p("card"),weight:a,classes:n}=t;return {id:o,component:"Card",child:e,...a!==void 0&&{weight:a},...n&&n.length>0&&{classes:n}}}function z(e,t={}){let{id:o=p("tabs"),weight:a}=t;return {id:o,component:"Tabs",tabItems:e.map(n=>({title:n.title,child:n.childId})),...a!==void 0&&{weight:a}}}function J(e={}){let{id:t=p("divider"),weight:o,axis:a}=e;return {id:t,component:"Divider",...o!==void 0&&{weight:o},...a&&{axis:a}}}function X(e,t,o={}){let{id:a=p("modal"),weight:n}=o;return {id:a,component:"Modal",entryPointChild:e,contentChild:t,...n!==void 0&&{weight:n}}}function y(e,t,o={}){let{id:a=p("button"),weight:n,primary:r}=o;return {id:a,component:"Button",child:e,action:t,...n!==void 0&&{weight:n},...r!==void 0&&{primary:r}}}function K(e,t,o={}){let{id:a=p("checkbox"),weight:n}=o;return {id:a,component:"CheckBox",label:e,value:t,...n!==void 0&&{weight:n}}}function Q(e,t,o={}){let{id:a=p("textfield"),weight:n,usageHint:r,validationRegexp:i}=o;return {id:a,component:"TextField",label:e,...t!==void 0&&{text:t},...n!==void 0&&{weight:n},...r&&{usageHint:r},...i&&{validationRegexp:i}}}function Z(e,t={}){let{id:o=p("datetime"),weight:a,enableDate:n,enableTime:r,outputFormat:i,label:s}=t;return {id:o,component:"DateTimeInput",value:e,...a!==void 0&&{weight:a},...n!==void 0&&{enableDate:n},...r!==void 0&&{enableTime:r},...i&&{outputFormat:i},...s&&{label:s}}}function ee(e,t,o,a={}){let{id:n=p("choice"),weight:r,label:i}=a;return {id:n,component:"ChoicePicker",options:e,value:t,usageHint:o,...r!==void 0&&{weight:r},...i&&{label:i}}}function te(e,t={}){let{id:o=p("slider"),weight:a,label:n,min:r,max:i}=t;return {id:o,component:"Slider",value:e,...a!==void 0&&{weight:a},...n&&{label:n},...r!==void 0&&{min:r},...i!==void 0&&{max:i}}}function h(e,t,o={}){let{id:a=p("chart"),weight:n,title:r,xAxis:i,yAxis:s,legend:d,tooltip:E,height:N,width:R,echartsOption:_}=o;return {id:a,component:"Chart",chartType:e,series:t,...n!==void 0&&{weight:n},...r&&{title:r},...i&&{xAxis:i},...s&&{yAxis:s},...d!==void 0&&{legend:d},...E!==void 0&&{tooltip:E},...N!==void 0&&{height:N},...R!==void 0&&{width:R},..._&&{echartsOption:_}}}function ne(e,t={}){return h("line",e,t)}function oe(e,t={}){return h("bar",e,t)}function ae(e,t={}){return h("pie",e,t)}function re(e,t,o={}){let a=o.textId??p("btn_text"),n=c(e,{id:a}),r=y(a,t,o);return [n,r]}function ie(e,t={}){return c(e,{...t,usageHint:"h1"})}function se(e,t={}){return c(e,{...t,usageHint:"h2"})}function pe(e,t={}){return c(e,{...t,usageHint:"h3"})}function ce(e,t={}){return c(e,{...t,usageHint:"h4"})}function ue(e,t={}){return c(e,{...t,usageHint:"h5"})}function de(e,t={}){return c(e,{...t,usageHint:"caption"})}function le(e,t={}){return c(e,{...t,usageHint:"body"})}function f(e,t=C){return {createSurface:{surfaceId:e,catalogId:t}}}function g(e,t){return {updateComponents:{surfaceId:e,components:t}}}function x(e,t,o,a="replace"){return {updateDataModel:{surfaceId:e,...o&&{path:o},op:a,...a!=="remove"&&{value:t}}}}function I(e){return {deleteSurface:{surfaceId:e}}}function me(e){let{surfaceId:t,catalogId:o=C,components:a,dataModel:n}=e,r=[f(t,o),g(t,a)];return n&&r.push(x(t,n)),r}function fe(e){return e.map(t=>JSON.stringify(t)).join(`
2
+ `)}function ge(e){return e.split(`
3
+ `).filter(t=>t.trim()).map(t=>JSON.parse(t))}var T={};function Ce(e,t=""){let o=[];for(let[a,n]of Object.entries(e)){let r=t?`${t}/${a}`:`/${a}`;o.push(l(r,n));}return o}function l(e,t){if(t==null)return {key:e,valueString:""};if(typeof t=="string")return {key:e,valueString:t};if(typeof t=="number")return {key:e,valueNumber:t};if(typeof t=="boolean")return {key:e,valueBoolean:t};if(Array.isArray(t))return {key:e,valueMap:t.map((o,a)=>l(String(a),o))};if(typeof t=="object"){let o=[];for(let[a,n]of Object.entries(t))o.push(l(a,n));return {key:e,valueMap:o}}return {key:e,valueString:String(t)}}function D(e,t={}){let o=e.replace(/\./g,"/");o.startsWith("/")||(o=`/${o}`);for(let[a,n]of Object.entries(t)){let r=new RegExp(`^/${a}(/|$)`);r.test(o)&&(o=o.replace(r,`/${n}$1`));}return o}function he(e,t="",o=T){let a=[];for(let n of e){let r=n.path.startsWith("/")?n.path:`${t}/${n.path}`,i=D(r,o);if(n.value!==null&&typeof n.value=="object"&&!Array.isArray(n.value)){let s=O(n.value,i);a.push(...s);}else a.push(l(i,n.value));}return a}function O(e,t){let o=[];for(let[a,n]of Object.entries(e)){let r=`${t}/${a}`;if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let i=O(n,r);o.push(...i);}else o.push(l(r,n));}return o}function b(e){let t={};for(let o of e){let a=o.key.startsWith("/")?o.key.slice(1):o.key;o.valueString!==void 0?t[a]=o.valueString:o.valueNumber!==void 0?t[a]=o.valueNumber:o.valueBoolean!==void 0?t[a]=o.valueBoolean:o.valueMap!==void 0&&(t[a]=b(o.valueMap));}return t}var ve=["Text","Image","Icon","Video","AudioPlayer","Row","Column","List","Card","Tabs","Divider","Modal","Button","CheckBox","TextField","DateTimeInput","ChoicePicker","Slider"];function V(e,t={}){let o=[],a=[];if("createSurface"in e){let{createSurface:n}=e;n.surfaceId||o.push({code:"MISSING_SURFACE_ID",message:"createSurface.surfaceId is required",path:"createSurface.surfaceId"}),n.catalogId||o.push({code:"MISSING_CATALOG_ID",message:"createSurface.catalogId is required",path:"createSurface.catalogId"});}else if("updateComponents"in e){let{updateComponents:n}=e;n.surfaceId||o.push({code:"MISSING_SURFACE_ID",message:"updateComponents.surfaceId is required",path:"updateComponents.surfaceId"}),!n.components||!Array.isArray(n.components)?o.push({code:"INVALID_COMPONENTS",message:"updateComponents.components must be an array",path:"updateComponents.components"}):Ae(n.components,o,a,t);}else if("updateDataModel"in e){let{updateDataModel:n}=e;n.surfaceId||o.push({code:"MISSING_SURFACE_ID",message:"updateDataModel.surfaceId is required",path:"updateDataModel.surfaceId"}),n.op&&!["add","replace","remove"].includes(n.op)&&o.push({code:"INVALID_OP",message:"updateDataModel.op must be one of: add, replace, remove",path:"updateDataModel.op"}),n.op==="remove"&&n.value!==void 0&&a.push({code:"UNNECESSARY_VALUE",message:"updateDataModel.value should not be provided for remove operation",path:"updateDataModel.value"}),n.op!=="remove"&&n.value===void 0&&n.op==="add"&&o.push({code:"MISSING_VALUE",message:"updateDataModel.value is required for add operation",path:"updateDataModel.value"});}else if("deleteSurface"in e){let{deleteSurface:n}=e;n.surfaceId||o.push({code:"MISSING_SURFACE_ID",message:"deleteSurface.surfaceId is required",path:"deleteSurface.surfaceId"});}else o.push({code:"INVALID_MESSAGE_TYPE",message:"Message must contain one of: createSurface, updateComponents, updateDataModel, deleteSurface"});return {valid:o.length===0,errors:o,warnings:a}}function v(e,t={}){return V(e,t)}function xe(e,t={}){let o=[],a=[];for(let n=0;n<e.length;n++){let r=e[n];if(!r)continue;let i=v(r,t);for(let s of i.errors)o.push({...s,path:`messages[${n}].${s.path??""}`});for(let s of i.warnings)a.push({...s,path:`messages[${n}].${s.path??""}`});}return {valid:o.length===0,errors:o,warnings:a}}function Ae(e,t,o,a){let n=new Set,r=false;for(let i=0;i<e.length;i++){let s=e[i];if(!s)continue;let d=`updateComponents.components[${i}]`;s.id?(n.has(s.id)&&t.push({code:"DUPLICATE_COMPONENT_ID",message:`Duplicate component id: ${s.id}`,path:`${d}.id`}),n.add(s.id),s.id==="root"&&(r=true)):t.push({code:"MISSING_COMPONENT_ID",message:"Component id is required",path:`${d}.id`}),s.component?a.strict&&!ve.includes(s.component)&&a.allowedComponents&&!a.allowedComponents.includes(s.component)&&o.push({code:"UNKNOWN_COMPONENT_TYPE",message:`Unknown component type: ${s.component}`,path:`${d}.component`}):t.push({code:"MISSING_COMPONENT_TYPE",message:"Component type is required",path:`${d}.component`});}!r&&a.strict&&o.push({code:"MISSING_ROOT_COMPONENT",message:'No component with id "root" found',path:"updateComponents.components"});}function A(e){return typeof e=="object"&&e!==null&&"path"in e}function Pe(e){if(!A(e))return e}function Ee(e){if(A(e))return e.path}function Ne(e){return {path:e}}function Se(e,t){let o={...e};for(let a of Object.keys(t)){let n=t[a],r=o[a];n!==void 0&&typeof n=="object"&&n!==null&&!Array.isArray(n)&&typeof r=="object"&&r!==null&&!Array.isArray(r)?o[a]=Se(r,n):n!==void 0&&(o[a]=n);}return o}function Re(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return (e==="x"?t:t&3|8).toString(16)})}var u={CHAT:"@chat",RECOMMENDATION:"@recommendation",INPUT_FORM:"@input-form",ORCHESTRATION:"@orchestration",STATUS:"@status",RESULT:"@result",CONFIRM:"@confirm",NOTIFICATION:"@notification"},P=0;function S(e="surface"){return P++,`${e}-${Date.now()}-${P}`}function Ie(){P=0;}function m(e,t,o){let a=o??S();return t.find(i=>i.id===e)||console.warn(`[A2UI] Root component "${e}" not found in components list`),{messages:[f(a),g(a,t)],surfaceId:a}}function Oe(e,t,o,a){let n=a??S();return {messages:[f(n),g(n,t),x(n,o)],surfaceId:n}}function Me(e){return I(e)}function ye(e,t){return m(e,t,u.CHAT)}function Te(e,t){return m(e,t,u.RECOMMENDATION)}function De(e,t){return m(e,t,u.INPUT_FORM)}function be(e,t){return m(e,t,u.ORCHESTRATION)}function Ve(e,t){return m(e,t,u.STATUS)}export{w as A2UI_EXTENSION_URI,k as A2UI_MIME_TYPE,T as DEFAULT_PATH_MAPPINGS,C as STANDARD_CATALOG_ID,u as SURFACE_IDS,$ as audioPlayer,oe as barChart,le as body,y as button,de as caption,Y as card,h as chart,K as checkbox,ee as choicePicker,W as column,m as createA2UISurface,Oe as createA2UISurfaceWithData,ye as createChatSurface,Me as createDeleteSurfaceMessage,De as createInputFormSurface,be as createOrchestrationSurface,Te as createRecommendationSurface,Ve as createStatusSurface,f as createSurface,me as createV09Messages,Z as dateTimeInput,Se as deepMerge,I as deleteSurface,J as divider,O as flattenObjectToValueMap,p as generateId,S as generateSurfaceId,F as getIdCounter,Pe as getLiteralValue,Ee as getPathValue,ie as h1,se as h2,pe as h3,ce as h4,ue as h5,L as icon,B as image,A as isPathBinding,U as isV09Message,ge as jsonlToMessages,ne as lineChart,q as list,fe as messagesToJsonl,X as modal,D as normalizePath,Ce as objectToValueMap,Ne as path,ae as pieChart,j as resetIdCounter,Ie as resetSurfaceIdCounter,G as row,te as slider,z as tabs,c as text,re as textButton,Q as textField,g as updateComponents,x as updateDataModel,he as updatesToValueMap,Re as uuid,v as validateMessage,xe as validateMessages,V as validateV09Message,b as valueMapToObject,l as valueToValueMap,H as video};
@@ -1,2 +1,2 @@
1
- 'use strict';var n={CHAT:"@chat",RECOMMENDATION:"@recommendation",INPUT_FORM:"@input-form",ORCHESTRATION:"@orchestration",STATUS:"@status",RESULT:"@result",CONFIRM:"@confirm",NOTIFICATION:"@notification"},c=0;function i(e="surface"){return c++,`${e}-${Date.now()}-${c}`}function C(){c=0;}var p="https://a2ui.dev/specification/0.9/standard_catalog_definition.json";function u(e,t=p){return {createSurface:{surfaceId:e,catalogId:t}}}function g(e,t){return {updateComponents:{surfaceId:e,components:t}}}function f(e,t,a,r="replace"){return {updateDataModel:{surfaceId:e,...a,op:r,...r!=="remove"&&{value:t}}}}function d(e){return {deleteSurface:{surfaceId:e}}}function o(e,t,a){let r=a??i();return t.find(l=>l.id===e)||console.warn(`[A2UI] Root component "${e}" not found in components list`),{messages:[u(r),g(r,t)],surfaceId:r}}function S(e,t,a,r){let s=r??i();return {messages:[u(s),g(s,t),f(s,a)],surfaceId:s}}function M(e){return d(e)}function I(e,t){return o(e,t,n.CHAT)}function T(e,t){return o(e,t,n.RECOMMENDATION)}function x(e,t){return o(e,t,n.INPUT_FORM)}function D(e,t){return o(e,t,n.ORCHESTRATION)}function A(e,t){return o(e,t,n.STATUS)}
2
- exports.SURFACE_IDS=n;exports.createA2UISurface=o;exports.createA2UISurfaceWithData=S;exports.createChatSurface=I;exports.createDeleteSurfaceMessage=M;exports.createInputFormSurface=x;exports.createOrchestrationSurface=D;exports.createRecommendationSurface=T;exports.createStatusSurface=A;exports.generateSurfaceId=i;exports.resetSurfaceIdCounter=C;
1
+ 'use strict';var n={CHAT:"@chat",RECOMMENDATION:"@recommendation",INPUT_FORM:"@input-form",ORCHESTRATION:"@orchestration",STATUS:"@status",RESULT:"@result",CONFIRM:"@confirm",NOTIFICATION:"@notification"},c=0;function i(e="surface"){return c++,`${e}-${Date.now()}-${c}`}function l(){c=0;}var p="https://a2ui.dev/specification/0.9/standard_catalog_definition.json";function u(e,t=p){return {createSurface:{surfaceId:e,catalogId:t}}}function g(e,t){return {updateComponents:{surfaceId:e,components:t}}}function f(e,t,a,r="replace"){return {updateDataModel:{surfaceId:e,...a,op:r,...r!=="remove"&&{value:t}}}}function d(e){return {deleteSurface:{surfaceId:e}}}function o(e,t,a){let r=a??i();return t.find(C=>C.id===e)||console.warn(`[A2UI] Root component "${e}" not found in components list`),{messages:[u(r),g(r,t)],surfaceId:r}}function S(e,t,a,r){let s=r??i();return {messages:[u(s),g(s,t),f(s,a)],surfaceId:s}}function M(e){return d(e)}function I(e,t){return o(e,t,n.CHAT)}function T(e,t){return o(e,t,n.RECOMMENDATION)}function x(e,t){return o(e,t,n.INPUT_FORM)}function D(e,t){return o(e,t,n.ORCHESTRATION)}function A(e,t){return o(e,t,n.STATUS)}
2
+ exports.SURFACE_IDS=n;exports.createA2UISurface=o;exports.createA2UISurfaceWithData=S;exports.createChatSurface=I;exports.createDeleteSurfaceMessage=M;exports.createInputFormSurface=x;exports.createOrchestrationSurface=D;exports.createRecommendationSurface=T;exports.createStatusSurface=A;exports.generateSurfaceId=i;exports.resetSurfaceIdCounter=l;
@@ -1,2 +1,2 @@
1
- var n={CHAT:"@chat",RECOMMENDATION:"@recommendation",INPUT_FORM:"@input-form",ORCHESTRATION:"@orchestration",STATUS:"@status",RESULT:"@result",CONFIRM:"@confirm",NOTIFICATION:"@notification"},c=0;function i(e="surface"){return c++,`${e}-${Date.now()}-${c}`}function C(){c=0;}var p="https://a2ui.dev/specification/0.9/standard_catalog_definition.json";function u(e,t=p){return {createSurface:{surfaceId:e,catalogId:t}}}function g(e,t){return {updateComponents:{surfaceId:e,components:t}}}function f(e,t,a,r="replace"){return {updateDataModel:{surfaceId:e,...a,op:r,...r!=="remove"&&{value:t}}}}function d(e){return {deleteSurface:{surfaceId:e}}}function o(e,t,a){let r=a??i();return t.find(l=>l.id===e)||console.warn(`[A2UI] Root component "${e}" not found in components list`),{messages:[u(r),g(r,t)],surfaceId:r}}function S(e,t,a,r){let s=r??i();return {messages:[u(s),g(s,t),f(s,a)],surfaceId:s}}function M(e){return d(e)}function I(e,t){return o(e,t,n.CHAT)}function T(e,t){return o(e,t,n.RECOMMENDATION)}function x(e,t){return o(e,t,n.INPUT_FORM)}function D(e,t){return o(e,t,n.ORCHESTRATION)}function A(e,t){return o(e,t,n.STATUS)}
2
- export{n as SURFACE_IDS,o as createA2UISurface,S as createA2UISurfaceWithData,I as createChatSurface,M as createDeleteSurfaceMessage,x as createInputFormSurface,D as createOrchestrationSurface,T as createRecommendationSurface,A as createStatusSurface,i as generateSurfaceId,C as resetSurfaceIdCounter};
1
+ var n={CHAT:"@chat",RECOMMENDATION:"@recommendation",INPUT_FORM:"@input-form",ORCHESTRATION:"@orchestration",STATUS:"@status",RESULT:"@result",CONFIRM:"@confirm",NOTIFICATION:"@notification"},c=0;function i(e="surface"){return c++,`${e}-${Date.now()}-${c}`}function l(){c=0;}var p="https://a2ui.dev/specification/0.9/standard_catalog_definition.json";function u(e,t=p){return {createSurface:{surfaceId:e,catalogId:t}}}function g(e,t){return {updateComponents:{surfaceId:e,components:t}}}function f(e,t,a,r="replace"){return {updateDataModel:{surfaceId:e,...a,op:r,...r!=="remove"&&{value:t}}}}function d(e){return {deleteSurface:{surfaceId:e}}}function o(e,t,a){let r=a??i();return t.find(C=>C.id===e)||console.warn(`[A2UI] Root component "${e}" not found in components list`),{messages:[u(r),g(r,t)],surfaceId:r}}function S(e,t,a,r){let s=r??i();return {messages:[u(s),g(s,t),f(s,a)],surfaceId:s}}function M(e){return d(e)}function I(e,t){return o(e,t,n.CHAT)}function T(e,t){return o(e,t,n.RECOMMENDATION)}function x(e,t){return o(e,t,n.INPUT_FORM)}function D(e,t){return o(e,t,n.ORCHESTRATION)}function A(e,t){return o(e,t,n.STATUS)}
2
+ export{n as SURFACE_IDS,o as createA2UISurface,S as createA2UISurfaceWithData,I as createChatSurface,M as createDeleteSurfaceMessage,x as createInputFormSurface,D as createOrchestrationSurface,T as createRecommendationSurface,A as createStatusSurface,i as generateSurfaceId,l as resetSurfaceIdCounter};
@@ -347,10 +347,105 @@ interface SliderComponent {
347
347
  */
348
348
  value: NumberOrPath;
349
349
  }
350
+ /**
351
+ * Chart 图表类型
352
+ */
353
+ type ChartType = 'line' | 'bar' | 'pie' | 'scatter' | 'area' | 'radar' | 'gauge';
354
+ /**
355
+ * Chart 数据系列
356
+ */
357
+ interface ChartSeries {
358
+ /**
359
+ * 系列名称
360
+ */
361
+ name?: string;
362
+ /**
363
+ * 系列类型(可覆盖 chartType)
364
+ */
365
+ type?: ChartType;
366
+ /**
367
+ * 数据点数组
368
+ */
369
+ data: number[] | Array<{
370
+ name?: string;
371
+ value: number;
372
+ }> | {
373
+ path: string;
374
+ };
375
+ }
376
+ /**
377
+ * Chart 坐标轴配置
378
+ */
379
+ interface ChartAxisConfig {
380
+ /**
381
+ * 坐标轴类型
382
+ */
383
+ type?: 'category' | 'value' | 'time' | 'log';
384
+ /**
385
+ * 坐标轴数据(category 类型时使用)
386
+ */
387
+ data?: string[] | {
388
+ path: string;
389
+ };
390
+ /**
391
+ * 坐标轴名称
392
+ */
393
+ name?: string;
394
+ }
395
+ /**
396
+ * Chart 组件 - 图表可视化
397
+ */
398
+ interface ChartComponent {
399
+ component: 'Chart';
400
+ /**
401
+ * 图表类型
402
+ */
403
+ chartType: ChartType;
404
+ /**
405
+ * 图表标题
406
+ */
407
+ title?: StringOrPath;
408
+ /**
409
+ * 数据系列
410
+ */
411
+ series: ChartSeries[] | {
412
+ path: string;
413
+ };
414
+ /**
415
+ * X 轴配置
416
+ */
417
+ xAxis?: ChartAxisConfig;
418
+ /**
419
+ * Y 轴配置
420
+ */
421
+ yAxis?: ChartAxisConfig;
422
+ /**
423
+ * 是否显示图例
424
+ */
425
+ legend?: boolean;
426
+ /**
427
+ * 是否显示 tooltip
428
+ */
429
+ tooltip?: boolean;
430
+ /**
431
+ * 图表高度(像素)
432
+ */
433
+ height?: number;
434
+ /**
435
+ * 图表宽度(像素或百分比字符串)
436
+ */
437
+ width?: number | string;
438
+ /**
439
+ * ECharts 原生 option 扩展(高级用法)
440
+ */
441
+ echartsOption?: Record<string, unknown> | {
442
+ path: string;
443
+ };
444
+ }
350
445
  /**
351
446
  * 任意标准组件类型
352
447
  */
353
- type AnyComponent = TextComponent | ImageComponent | IconComponent | VideoComponent | AudioPlayerComponent | RowComponent | ColumnComponent | ListComponent | CardComponent | TabsComponent | DividerComponent | ModalComponent | ButtonComponent | CheckBoxComponent | TextFieldComponent | DateTimeInputComponent | ChoicePickerComponent | SliderComponent;
448
+ type AnyComponent = TextComponent | ImageComponent | IconComponent | VideoComponent | AudioPlayerComponent | RowComponent | ColumnComponent | ListComponent | CardComponent | TabsComponent | DividerComponent | ModalComponent | ButtonComponent | CheckBoxComponent | TextFieldComponent | DateTimeInputComponent | ChoicePickerComponent | SliderComponent | ChartComponent;
354
449
  /**
355
450
  * 组件类型名称
356
451
  */
@@ -665,4 +760,4 @@ declare const A2UI_EXTENSION_URI = "https://a2ui.dev/specification/0.9";
665
760
  */
666
761
  declare const A2UI_MIME_TYPE = "application/json+a2ui";
667
762
 
668
- export { A2UI_EXTENSION_URI, A2UI_MIME_TYPE, type Action, type AnyComponent, type AudioPlayerComponent, BooleanOrPath, type ButtonComponent, type CardComponent, type CheckBoxComponent, type ChildrenProperty, type ChoicePickerComponent, type ClientErrorMessage, type ClientToServerMessage, type ColumnComponent, type ComponentCommon, type ComponentInstance, type ComponentType, type CreateSurfaceMessage, type DataArray, type DataChangeEvent, type DataObject, type DataValue, type DateTimeInputComponent, type DeleteSurfaceMessage, type DividerComponent, type GenericError, type IconComponent, type ImageComponent, type ListComponent, type ModalComponent, NumberOrPath, type RowComponent, STANDARD_CATALOG_ID, type ServerToClientMessageV09, type SliderComponent, type StandardIconName, StringArrayOrPath, StringOrPath, type TabsComponent, type TextComponent, type TextFieldComponent, type Theme, type UpdateComponentsMessage, type UpdateDataModelMessage, type UserActionEvent, type ValidationFailedError, type VideoComponent, isV09Message };
763
+ export { A2UI_EXTENSION_URI, A2UI_MIME_TYPE, type Action, type AnyComponent, type AudioPlayerComponent, BooleanOrPath, type ButtonComponent, type CardComponent, type ChartAxisConfig, type ChartComponent, type ChartSeries, type ChartType, type CheckBoxComponent, type ChildrenProperty, type ChoicePickerComponent, type ClientErrorMessage, type ClientToServerMessage, type ColumnComponent, type ComponentCommon, type ComponentInstance, type ComponentType, type CreateSurfaceMessage, type DataArray, type DataChangeEvent, type DataObject, type DataValue, type DateTimeInputComponent, type DeleteSurfaceMessage, type DividerComponent, type GenericError, type IconComponent, type ImageComponent, type ListComponent, type ModalComponent, NumberOrPath, type RowComponent, STANDARD_CATALOG_ID, type ServerToClientMessageV09, type SliderComponent, type StandardIconName, StringArrayOrPath, StringOrPath, type TabsComponent, type TextComponent, type TextFieldComponent, type Theme, type UpdateComponentsMessage, type UpdateDataModelMessage, type UserActionEvent, type ValidationFailedError, type VideoComponent, isV09Message };
@@ -347,10 +347,105 @@ interface SliderComponent {
347
347
  */
348
348
  value: NumberOrPath;
349
349
  }
350
+ /**
351
+ * Chart 图表类型
352
+ */
353
+ type ChartType = 'line' | 'bar' | 'pie' | 'scatter' | 'area' | 'radar' | 'gauge';
354
+ /**
355
+ * Chart 数据系列
356
+ */
357
+ interface ChartSeries {
358
+ /**
359
+ * 系列名称
360
+ */
361
+ name?: string;
362
+ /**
363
+ * 系列类型(可覆盖 chartType)
364
+ */
365
+ type?: ChartType;
366
+ /**
367
+ * 数据点数组
368
+ */
369
+ data: number[] | Array<{
370
+ name?: string;
371
+ value: number;
372
+ }> | {
373
+ path: string;
374
+ };
375
+ }
376
+ /**
377
+ * Chart 坐标轴配置
378
+ */
379
+ interface ChartAxisConfig {
380
+ /**
381
+ * 坐标轴类型
382
+ */
383
+ type?: 'category' | 'value' | 'time' | 'log';
384
+ /**
385
+ * 坐标轴数据(category 类型时使用)
386
+ */
387
+ data?: string[] | {
388
+ path: string;
389
+ };
390
+ /**
391
+ * 坐标轴名称
392
+ */
393
+ name?: string;
394
+ }
395
+ /**
396
+ * Chart 组件 - 图表可视化
397
+ */
398
+ interface ChartComponent {
399
+ component: 'Chart';
400
+ /**
401
+ * 图表类型
402
+ */
403
+ chartType: ChartType;
404
+ /**
405
+ * 图表标题
406
+ */
407
+ title?: StringOrPath;
408
+ /**
409
+ * 数据系列
410
+ */
411
+ series: ChartSeries[] | {
412
+ path: string;
413
+ };
414
+ /**
415
+ * X 轴配置
416
+ */
417
+ xAxis?: ChartAxisConfig;
418
+ /**
419
+ * Y 轴配置
420
+ */
421
+ yAxis?: ChartAxisConfig;
422
+ /**
423
+ * 是否显示图例
424
+ */
425
+ legend?: boolean;
426
+ /**
427
+ * 是否显示 tooltip
428
+ */
429
+ tooltip?: boolean;
430
+ /**
431
+ * 图表高度(像素)
432
+ */
433
+ height?: number;
434
+ /**
435
+ * 图表宽度(像素或百分比字符串)
436
+ */
437
+ width?: number | string;
438
+ /**
439
+ * ECharts 原生 option 扩展(高级用法)
440
+ */
441
+ echartsOption?: Record<string, unknown> | {
442
+ path: string;
443
+ };
444
+ }
350
445
  /**
351
446
  * 任意标准组件类型
352
447
  */
353
- type AnyComponent = TextComponent | ImageComponent | IconComponent | VideoComponent | AudioPlayerComponent | RowComponent | ColumnComponent | ListComponent | CardComponent | TabsComponent | DividerComponent | ModalComponent | ButtonComponent | CheckBoxComponent | TextFieldComponent | DateTimeInputComponent | ChoicePickerComponent | SliderComponent;
448
+ type AnyComponent = TextComponent | ImageComponent | IconComponent | VideoComponent | AudioPlayerComponent | RowComponent | ColumnComponent | ListComponent | CardComponent | TabsComponent | DividerComponent | ModalComponent | ButtonComponent | CheckBoxComponent | TextFieldComponent | DateTimeInputComponent | ChoicePickerComponent | SliderComponent | ChartComponent;
354
449
  /**
355
450
  * 组件类型名称
356
451
  */
@@ -665,4 +760,4 @@ declare const A2UI_EXTENSION_URI = "https://a2ui.dev/specification/0.9";
665
760
  */
666
761
  declare const A2UI_MIME_TYPE = "application/json+a2ui";
667
762
 
668
- export { A2UI_EXTENSION_URI, A2UI_MIME_TYPE, type Action, type AnyComponent, type AudioPlayerComponent, BooleanOrPath, type ButtonComponent, type CardComponent, type CheckBoxComponent, type ChildrenProperty, type ChoicePickerComponent, type ClientErrorMessage, type ClientToServerMessage, type ColumnComponent, type ComponentCommon, type ComponentInstance, type ComponentType, type CreateSurfaceMessage, type DataArray, type DataChangeEvent, type DataObject, type DataValue, type DateTimeInputComponent, type DeleteSurfaceMessage, type DividerComponent, type GenericError, type IconComponent, type ImageComponent, type ListComponent, type ModalComponent, NumberOrPath, type RowComponent, STANDARD_CATALOG_ID, type ServerToClientMessageV09, type SliderComponent, type StandardIconName, StringArrayOrPath, StringOrPath, type TabsComponent, type TextComponent, type TextFieldComponent, type Theme, type UpdateComponentsMessage, type UpdateDataModelMessage, type UserActionEvent, type ValidationFailedError, type VideoComponent, isV09Message };
763
+ export { A2UI_EXTENSION_URI, A2UI_MIME_TYPE, type Action, type AnyComponent, type AudioPlayerComponent, BooleanOrPath, type ButtonComponent, type CardComponent, type ChartAxisConfig, type ChartComponent, type ChartSeries, type ChartType, type CheckBoxComponent, type ChildrenProperty, type ChoicePickerComponent, type ClientErrorMessage, type ClientToServerMessage, type ColumnComponent, type ComponentCommon, type ComponentInstance, type ComponentType, type CreateSurfaceMessage, type DataArray, type DataChangeEvent, type DataObject, type DataValue, type DateTimeInputComponent, type DeleteSurfaceMessage, type DividerComponent, type GenericError, type IconComponent, type ImageComponent, type ListComponent, type ModalComponent, NumberOrPath, type RowComponent, STANDARD_CATALOG_ID, type ServerToClientMessageV09, type SliderComponent, type StandardIconName, StringArrayOrPath, StringOrPath, type TabsComponent, type TextComponent, type TextFieldComponent, type Theme, type UpdateComponentsMessage, type UpdateDataModelMessage, type UserActionEvent, type ValidationFailedError, type VideoComponent, isV09Message };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhama/a2ui-core",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "A2UI Protocol Core Library - Framework-agnostic TypeScript types and builders for A2UI protocol",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",