@maxhealth.tech/prefab 0.3.18 → 0.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/a2ui/browser.js +1 -2
- package/dist/a2ui/browser.js.map +1 -1
- package/dist/a2ui/expr.d.ts +7 -54
- package/dist/a2ui/expr.d.ts.map +1 -1
- package/dist/a2ui/expr.js +13 -90
- package/dist/a2ui/expr.js.map +1 -1
- package/dist/a2ui/icons.d.ts +3 -25
- package/dist/a2ui/icons.d.ts.map +1 -1
- package/dist/a2ui/icons.js +4 -33
- package/dist/a2ui/icons.js.map +1 -1
- package/dist/a2ui/types.d.ts +7 -54
- package/dist/a2ui/types.d.ts.map +1 -1
- package/dist/a2ui/types.js +2 -21
- package/dist/a2ui/types.js.map +1 -1
- package/dist/a2ui.min.js +1 -1
- package/dist/actions/subscribe.d.ts +3 -18
- package/dist/actions/subscribe.d.ts.map +1 -1
- package/dist/actions/subscribe.js +2 -17
- package/dist/actions/subscribe.js.map +1 -1
- package/dist/components/pdf/index.d.ts +3 -9
- package/dist/components/pdf/index.d.ts.map +1 -1
- package/dist/components/pdf/index.js +2 -8
- package/dist/components/pdf/index.js.map +1 -1
- package/dist/core/escape.d.ts +1 -19
- package/dist/core/escape.d.ts.map +1 -1
- package/dist/core/escape.js +1 -19
- package/dist/core/escape.js.map +1 -1
- package/dist/core/humanize.d.ts +2 -17
- package/dist/core/humanize.d.ts.map +1 -1
- package/dist/core/humanize.js +8 -20
- package/dist/core/humanize.js.map +1 -1
- package/dist/core/logger.d.ts +1 -9
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +1 -9
- package/dist/core/logger.js.map +1 -1
- package/dist/core/stringify.d.ts +2 -19
- package/dist/core/stringify.d.ts.map +1 -1
- package/dist/core/stringify.js +3 -21
- package/dist/core/stringify.js.map +1 -1
- package/dist/core/validate.d.ts.map +1 -1
- package/dist/core/validate.js +23 -26
- package/dist/core/validate.js.map +1 -1
- package/dist/core/version.d.ts +3 -22
- package/dist/core/version.d.ts.map +1 -1
- package/dist/core/version.js +3 -22
- package/dist/core/version.js.map +1 -1
- package/dist/mcp/a2ui.d.ts +6 -36
- package/dist/mcp/a2ui.d.ts.map +1 -1
- package/dist/mcp/a2ui.js +6 -36
- package/dist/mcp/a2ui.js.map +1 -1
- package/dist/mcp/input-required.d.ts.map +1 -1
- package/dist/mcp/input-required.js +2 -8
- package/dist/mcp/input-required.js.map +1 -1
- package/dist/mcp/resource.d.ts +12 -88
- package/dist/mcp/resource.d.ts.map +1 -1
- package/dist/mcp/resource.js +18 -85
- package/dist/mcp/resource.js.map +1 -1
- package/dist/mcp/result.d.ts +2 -27
- package/dist/mcp/result.d.ts.map +1 -1
- package/dist/mcp/result.js +2 -27
- package/dist/mcp/result.js.map +1 -1
- package/dist/mcp/theme-bridge.d.ts +5 -36
- package/dist/mcp/theme-bridge.d.ts.map +1 -1
- package/dist/mcp/theme-bridge.js +6 -43
- package/dist/mcp/theme-bridge.js.map +1 -1
- package/dist/mcp/types.d.ts +11 -106
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/mcp/types.js +2 -22
- package/dist/mcp/types.js.map +1 -1
- package/dist/renderer/actions.d.ts +2 -2
- package/dist/renderer/actions.d.ts.map +1 -1
- package/dist/renderer/actions.js +6 -2
- package/dist/renderer/actions.js.map +1 -1
- package/dist/renderer/app.d.ts.map +1 -1
- package/dist/renderer/app.js +3 -2
- package/dist/renderer/app.js.map +1 -1
- package/dist/renderer/auto.js +9 -4
- package/dist/renderer/auto.js.map +1 -1
- package/dist/renderer/bridge.d.ts +3 -7
- package/dist/renderer/bridge.d.ts.map +1 -1
- package/dist/renderer/bridge.js +38 -64
- package/dist/renderer/bridge.js.map +1 -1
- package/dist/renderer/components/alert.d.ts.map +1 -1
- package/dist/renderer/components/alert.js +4 -2
- package/dist/renderer/components/alert.js.map +1 -1
- package/dist/renderer/components/charts/props.d.ts.map +1 -1
- package/dist/renderer/components/charts/props.js +3 -2
- package/dist/renderer/components/charts/props.js.map +1 -1
- package/dist/renderer/components/choice.d.ts.map +1 -1
- package/dist/renderer/components/choice.js +5 -4
- package/dist/renderer/components/choice.js.map +1 -1
- package/dist/renderer/components/control.d.ts.map +1 -1
- package/dist/renderer/components/control.js +16 -9
- package/dist/renderer/components/control.js.map +1 -1
- package/dist/renderer/components/data.d.ts.map +1 -1
- package/dist/renderer/components/data.js +17 -15
- package/dist/renderer/components/data.js.map +1 -1
- package/dist/renderer/components/form.d.ts.map +1 -1
- package/dist/renderer/components/form.js +18 -17
- package/dist/renderer/components/form.js.map +1 -1
- package/dist/renderer/components/interactive.d.ts.map +1 -1
- package/dist/renderer/components/interactive.js +3 -2
- package/dist/renderer/components/interactive.js.map +1 -1
- package/dist/renderer/components/media.d.ts.map +1 -1
- package/dist/renderer/components/media.js +13 -10
- package/dist/renderer/components/media.js.map +1 -1
- package/dist/renderer/components/pdf.d.ts +1 -10
- package/dist/renderer/components/pdf.d.ts.map +1 -1
- package/dist/renderer/components/pdf.js +19 -14
- package/dist/renderer/components/pdf.js.map +1 -1
- package/dist/renderer/components/table.js +2 -2
- package/dist/renderer/components/table.js.map +1 -1
- package/dist/renderer/components/typography.d.ts.map +1 -1
- package/dist/renderer/components/typography.js +4 -2
- package/dist/renderer/components/typography.js.map +1 -1
- package/dist/renderer/engine.d.ts.map +1 -1
- package/dist/renderer/engine.js +5 -6
- package/dist/renderer/engine.js.map +1 -1
- package/dist/renderer/host-context.d.ts +8 -0
- package/dist/renderer/host-context.d.ts.map +1 -0
- package/dist/renderer/host-context.js +62 -0
- package/dist/renderer/host-context.js.map +1 -0
- package/dist/renderer/index.d.ts.map +1 -1
- package/dist/renderer/index.js +20 -20
- package/dist/renderer/index.js.map +1 -1
- package/dist/renderer/rx.d.ts.map +1 -1
- package/dist/renderer/rx.js +17 -24
- package/dist/renderer/rx.js.map +1 -1
- package/dist/renderer/state.d.ts.map +1 -1
- package/dist/renderer/state.js +10 -4
- package/dist/renderer/state.js.map +1 -1
- package/dist/renderer.auto.min.js +10 -10
- package/dist/renderer.min.js +10 -10
- package/dist/rx/pipes.d.ts +3 -19
- package/dist/rx/pipes.d.ts.map +1 -1
- package/dist/rx/pipes.js +3 -19
- package/dist/rx/pipes.js.map +1 -1
- package/dist/rx/signal.d.ts +3 -13
- package/dist/rx/signal.d.ts.map +1 -1
- package/dist/rx/signal.js +2 -9
- package/dist/rx/signal.js.map +1 -1
- package/package.json +1 -1
package/dist/a2ui.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var{defineProperty:v,getOwnPropertyNames:se,getOwnPropertyDescriptor:ae}=Object,ue=Object.prototype.hasOwnProperty;function le(e){return this[e]}var de=(e)=>{var n=(R??=new WeakMap).get(e),t;if(n)return n;if(n=v({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var i of se(e))if(!ue.call(n,i))v(n,i,{get:le.bind(e,i),enumerable:!(t=ae(e,i))||t.enumerable})}return R.set(e,n),n},R;var ce=(e)=>e;function pe(e,n){this[e]=ce.bind(null,n)}var fe=(e,n)=>{for(var t in n)v(e,t,{get:n[t],enumerable:!0,configurable:!0,set:pe.bind(n,t)})};var He={};fe(He,{default:()=>qe,emit:()=>te,envelope:()=>ie});var E={silent:0,error:1,warn:2,info:3,debug:4},me="warn";function x(e){let n=e?`[prefab:${e}]`:"[prefab]",t=(i,r,o)=>{if(E[i]>E[me])return;console[i](`${n} ${r}`,...o)};return{error:(i,...r)=>t("error",i,r),warn:(i,...r)=>t("warn",i,r),info:(i,...r)=>t("info",i,r),debug:(i,...r)=>t("debug",i,r)}}var Ge=x();var ge=/^(.+?)\s*\|\s*([A-Za-z_][\w]*)\s*(?::\s*(.+))?$/;function N(e){let n=ge.exec(e);if(n==null)return;let t=n[1].trim();if(t.includes("|"))return;let i=n.at(3)?.trim();if(i===void 0)return{base:t,name:n[2]};let r=/^'([^']*)'$|^"([^"]*)"$/.exec(i);if(r!=null){let s=r.at(1)??r.at(2);return{base:t,name:n[2],arg:s??""}}let o=Number(i);if(!Number.isNaN(o))return{base:t,name:n[2],arg:o};return}function S(e,n){return(t)=>({call:{call:"formatDate",args:{value:t,format:e}},note:`the "${n}" pipe renders in the reader's locale; A2UI needs an explicit pattern, so "${e}" was used`})}var he={currency:(e,n)=>({call:{call:"formatCurrency",args:{value:e,currency:typeof n==="string"?n:"USD"}}}),number:(e,n)=>({call:{call:"formatNumber",args:{value:e,...typeof n==="number"&&{decimals:n}}}}),round:(e,n)=>({call:{call:"formatNumber",args:{value:e,decimals:typeof n==="number"?n:0}}}),pluralize:(e,n)=>{if(typeof n!=="string")return;return{call:{call:"pluralize",args:{value:e,one:n,other:`${n}s`}}}},date:S("y-MM-dd","date"),time:S("HH:mm","time"),datetime:S("y-MM-dd HH:mm","datetime")};function B(e,n){return he[e.name]?.(n,e.arg)}var ye=/^\s*\{\{\s*(.+?)\s*\}\}\s*$/s,Ae=/\{\{\s*(.+?)\s*\}\}/g,be=/^\$?[A-Za-z_][\w$]*(?:\.(?:[A-Za-z_$][\w$]*|\d+))*$/,U="$index";function c(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Ce(e){return"/"+e.map(c).join("/")}function ve(e){return e.startsWith("state.")?e.slice(6):e}function w(e,n){if(!be.test(e))return;let t=ve(e).split("."),i=t[0],r=Object.hasOwn(n,i)?n[i]:void 0;if(r===void 0){if(i.startsWith("$"))return;return Ce(t)}let o=t.slice(1);if(r==="")return o.length===0?void 0:o.map(c).join("/");return o.length===0?r:`${r}/${o.map(c).join("/")}`}function L(e){return e.replace(/\$\{/g,"\\${")}function xe(e,n){let t,i="",r=0;for(let o of e.matchAll(Ae)){let s=o[1].trim(),a=w(s,n);if(a==null){t=s;break}i+=L(e.slice(r,o.index)),i+=`\${${a}}`,r=o.index+o[0].length}if(t!=null)return;return i+=L(e.slice(r)),{call:"formatString",args:{value:i}}}function Se(e,n){let t=N(e);if(t==null)return;let i=w(t.base,n),r=i!=null?{path:i}:/^-?\d+(\.\d+)?$/.test(t.base)?Number(t.base):void 0;if(r===void 0)return;let o=B(t,r);if(o==null)return;return{kind:"format",value:o.call,...o.note!=null&&{note:o.note}}}function f(e,n={}){let t=ye.exec(e);if(t!=null&&!t[1].includes("{{")&&!t[1].includes("}}")){let o=t[1].trim();if(o===U&&U in n)return{kind:"index",value:{call:"@index"}};let s=w(o,n);if(s!=null)return{kind:"binding",value:{path:s}};let a=Se(o,n);if(a!=null)return a;return{kind:"unbindable",expression:o}}if(!e.includes("{{"))return{kind:"literal",value:e};let r=xe(e,n);if(r!=null)return{kind:"format",value:r};return{kind:"unbindable",expression:e}}function h(e,n={}){if(e==null)return;let t=f(e,n);switch(t.kind){case"literal":return t.value;case"binding":return t.value;case"format":return t.value;case"index":return t.value;default:return}}var we=["accountCircle","add","arrowBack","arrowForward","attachFile","calendarToday","call","camera","check","close","delete","download","edit","event","error","fastForward","favorite","favoriteOff","folder","help","home","info","locationOn","lock","lockOpen","mail","menu","moreVert","moreHoriz","notificationsOff","notifications","pause","payment","person","phone","photo","play","print","refresh","rewind","search","send","settings","share","shoppingCart","skipNext","skipPrevious","star","starHalf","starOff","stop","upload","visibility","visibilityOff","volumeDown","volumeMute","volumeOff","volumeUp","warning"],ke=new Map(we.map((e)=>[F(e),e])),Te={alertcircle:"error",alerttriangle:"warning",alertoctagon:"error",xcircle:"error",circlex:"error",circlealert:"error",checkcircle:"check",circlecheck:"check",checkcircle2:"check",infocircle:"info",circleinfo:"info",helpcircle:"help",circlehelp:"help",bell:"notifications",belloff:"notificationsOff",arrowleft:"arrowBack",arrowright:"arrowForward",chevronleft:"arrowBack",chevronright:"arrowForward",x:"close",plus:"add",trash:"delete",trash2:"delete",ellipsisvertical:"moreVert",ellipsis:"moreHoriz",morehorizontal:"moreHoriz",morevertical:"moreVert",pencil:"edit",pen:"edit",squarepen:"edit",user:"person",usercircle:"accountCircle",circleuser:"accountCircle",eye:"visibility",eyeoff:"visibilityOff",mappin:"locationOn",map:"locationOn",image:"photo",images:"photo",file:"folder",files:"folder",calendar:"calendarToday",calendardays:"calendarToday",clock:"event",creditcard:"payment",cart:"shoppingCart",shoppingbag:"shoppingCart",phonecall:"call",mailopen:"mail",inbox:"mail",cog:"settings",gear:"settings",sliders:"settings",rotatecw:"refresh",rotateccw:"refresh",refreshcw:"refresh",heart:"favorite",heartoff:"favoriteOff",volume:"volumeUp",volume1:"volumeDown",volume2:"volumeUp",volumex:"volumeOff",skipforward:"skipNext",skipback:"skipPrevious",paperclip:"attachFile",link:"share",share2:"share",magnifyingglass:"search",searchicon:"search"};function F(e){return e.replace(/[\s._-]/g,"").toLowerCase()}function _(e){let n=F(e);return ke.get(n)??Te[n]}function k(e,...n){for(let t of n){let i=e[t];if(typeof i==="string"||typeof i==="number"||typeof i==="boolean")return String(i)}return}function Oe(e){return e!=null&&typeof e==="object"&&!Array.isArray(e)}var T={ForEach:(e,n)=>{let t=k(e,"expression");if(t==null){n.note("unsupported","ForEach","no expression to iterate");return}let i=n.bind(t);if(i.kind!=="binding"){n.note("expression","ForEach",`"${t}" is not a plain path, so there is no list to bind`);return}let r=n.inScope({$item:"",$index:""},()=>n.single(e.children));if(r==null){n.note("unsupported","ForEach","the loop body had nothing to render");return}return{component:"Column",children:{path:i.value.path,componentId:r}}},Define:()=>{return},Use:(e,n)=>{let t=k(e,"def","name");if(t==null){n.note("unsupported","Use","no definition name");return}let i=n.definition(t);if(i==null){n.note("unsupported","Use",`no definition named "${t}" was declared`);return}let r=e.overrides,o={};if(r!=null&&typeof r==="object"&&!Array.isArray(r)){let g=n.bindData(`use_${t}`,r);for(let d of Object.keys(r))o[d]=`${g}/${c(d)}`}let s={...Oe(e.slots)?e.slots:{},...Array.isArray(e.children)&&e.children.length>0?{default:e.children}:{}},a=n.expand(t,()=>n.inScope(o,()=>n.withSlots(s,()=>n.single(i))));if(a==null){n.note("unsupported","Use",`definition "${t}" rendered nothing`);return}return{component:"Column",children:[a]}},Slot:(e,n)=>{let t=k(e,"name")??"default",i=n.slotContent(t)??(Array.isArray(e.children)?e.children:void 0),r=i!=null?n.single(i):void 0;if(r==null){n.note("unsupported","Slot",`slot "${t}" had neither content nor a fallback`);return}return{component:"Column",children:[r]}}};for(let e of["If","Elif","Else","Condition","Match","Case"])T[e]=(n,t)=>{t.note("unsupported",n.type,"A2UI has no declarative conditional; the agent re-sends updateComponents when the shape changes");return};var J=["TableHead","TableBody","TableFooter","TableRow","TableCell","TableHeader","ExpandableRow"];function De(e){if(!Array.isArray(e.columns))return[];let n=[];for(let t of e.columns){if(t==null||typeof t!=="object")continue;let i=t,r=typeof i.accessor==="string"?i.accessor:typeof i.key==="string"?i.key:void 0;if(r==null)continue;n.push({key:r,header:typeof i.header==="string"?i.header:r})}return n}function Ie(e,n){let t=e.rows;if(typeof t==="string"){let i=f(t);if(i.kind==="binding")return i.value.path;n.note("expression","DataTable",`rows expression "${t}" is not a plain path; the table has no data source`);return}if(Array.isArray(t))return n.bindData("rows",t);n.note("unsupported","DataTable","no rows to render");return}function j(e,n){let t=De(e);if(t.length===0){n.note("unsupported","DataTable","no usable column definitions");return}let i=Ie(e,n);if(i==null)return;let r=n.push({component:"Row",children:t.map((a)=>n.push({component:"Text",text:a.header,variant:"caption"})),align:"center"}),o=n.push({component:"Row",children:t.map((a)=>n.push({component:"Text",text:{path:a.key.split(".").join("/")}})),align:"center"}),s=n.push({component:"Column",children:{path:i,componentId:o}});if(e.search===!0||e.paginated===!0)n.note("degraded","DataTable","search and pagination dropped; A2UI Basic has no table controls");return{component:"Column",children:[r,s]}}function Me(e){let n=[],t=(i)=>{if(i.type==="TableRow"||i.type==="ExpandableRow"){n.push(i);return}if(Array.isArray(i.children))for(let r of i.children)t(r)};if(Array.isArray(e.children))for(let i of e.children)t(i);return n}function Pe(e,n){let t=e.type==="TableHeader";if(Array.isArray(e.children)&&e.children.length>0)return n.single(e.children);let i=e.content??e.text??e.label;if(typeof i!=="string"&&typeof i!=="number"&&typeof i!=="boolean")return;let r=String(i),o=h(r);if(o==null){n.note("expression",e.type,`cell expression "${r}" has no A2UI equivalent`);return}return n.push({component:"Text",text:o,...t&&{variant:"caption"}})}function V(e,n){let t=Me(e),i=[];for(let r of t){let s=(Array.isArray(r.children)?r.children:[]).map((a)=>Pe(a,n)).filter((a)=>a!=null);if(s.length===0)continue;i.push(n.push({component:"Row",children:s,align:"center"}))}if(i.length===0){n.note("unsupported","Table","no rows with renderable cells");return}return n.note("degraded","Table","rendered as a Column of Rows; column widths do not align"),{component:"Column",children:i}}function u(e,...n){for(let t of n){let i=e[t];if(typeof i==="string"||typeof i==="number"||typeof i==="boolean")return String(i)}return}function l(e,n,t){let i=u(e,...t?.keys??["content","text","label","title"]);if(i==null){n.note("unsupported",e.type,"no text content to render");return}let r=n.bind(i);if(r.kind==="unbindable")n.note("expression",e.type,`"${r.expression}" is richer than a JSON Pointer; the text was left as written`);let o=t?.prefix??"",s=t?.suffix??"";if(r.kind==="format"&&r.note!=null)n.note("degraded",e.type,r.note);if(r.kind==="binding"||r.kind==="format"||r.kind==="index"){if(o!==""||s!=="")n.note("degraded",e.type,"Markdown emphasis dropped: the text is a data binding");return{component:"Text",text:r.value,...t?.variant!=null&&{variant:t.variant}}}let a=r.kind==="literal"?r.value:i;return{component:"Text",text:`${o}${a}${s}`,...t?.variant!=null&&{variant:t.variant}}}var Re={start:"start",end:"end",center:"center",between:"spaceBetween",around:"spaceAround",evenly:"spaceEvenly",spaceBetween:"spaceBetween",spaceAround:"spaceAround",spaceEvenly:"spaceEvenly"},Ee={start:"start",end:"end",center:"center",stretch:"stretch",baseline:"baseline"};function y(e){return(n,t)=>{let i=t.children(n.children);if(i.length===0){t.note("unsupported",n.type,`${e} requires at least one child and none survived`);return}let r=typeof n.justify==="string"?Re[n.justify]:void 0,o=typeof n.align==="string"?Ee[n.align]:void 0;return{component:e,children:i,...r!=null&&{justify:r},...o!=null&&{align:o}}}}var Ne=["Div","Container","Stack","Grid","GridItem","Page","Pages","Dashboard","DashboardItem","MasterDetail","Detail","Form","Fieldset","CardContent","CardHeader","CardFooter","Accordion","Carousel","SelectGroup","ComboboxGroup","Section","Article","Aside","Header","Footer","Nav","Span"],Be=["ButtonGroup","Toolbar","Inline"],$e={H1:"# ",H2:"## ",H3:"### ",H4:"#### ",H5:"##### ",H6:"###### "},q={Heading:(e,n)=>{let t=typeof e.level==="number"?Math.min(6,Math.max(1,e.level)):1;return l(e,n,{prefix:`${"#".repeat(t)} `})},Text:(e,n)=>l(e,n),P:(e,n)=>l(e,n),Lead:(e,n)=>l(e,n),Large:(e,n)=>l(e,n),Small:(e,n)=>l(e,n,{variant:"caption"}),Muted:(e,n)=>l(e,n,{variant:"caption"}),Label:(e,n)=>l(e,n,{variant:"caption"}),TableCaption:(e,n)=>l(e,n,{variant:"caption"}),BlockQuote:(e,n)=>l(e,n,{prefix:"> "}),Code:(e,n)=>l(e,n,{prefix:"`",suffix:"`"}),Kbd:(e,n)=>l(e,n,{prefix:"`",suffix:"`"}),Markdown:(e,n)=>l(e,n),Badge:(e,n)=>l(e,n,{keys:["label","content"],variant:"caption"}),CardTitle:(e,n)=>l(e,n,{prefix:"**",suffix:"**"}),CardDescription:(e,n)=>l(e,n,{variant:"caption"}),Tooltip:(e,n)=>l(e,n,{variant:"caption"}),AlertTitle:(e,n)=>l(e,n,{prefix:"**",suffix:"**"}),AlertDescription:(e,n)=>l(e,n)};for(let[e,n]of Object.entries($e))q[e]=(t,i)=>l(t,i,{prefix:n});function O(e){return(n,t)=>{let i=t.dyn(u(n,"src","url"));if(i==null){t.note("unsupported",n.type,"no resolvable source URL");return}let r=e==="Video"?void 0:t.dyn(u(n,"alt","description")),o=e==="Video"?t.dyn(u(n,"poster","posterUrl")):void 0;return{component:e,url:i,...r!=null&&{description:r},...o!=null&&{posterUrl:o}}}}var Ue={text:"shortText",email:"shortText",url:"shortText",tel:"shortText",search:"shortText",password:"obscured",number:"number"};function m(e,n){let t=typeof e.name==="string"?e.name:void 0;if(t==null)return;let i=n.bind(`{{ ${t} }}`);return i.kind==="binding"?i.value:void 0}function P(e,n){let t=m(e,n);if(t==null)return;let i=[];if(e.required===!0)i.push({condition:{call:"required",args:{value:t}}});if(e.inputType==="email")i.push({condition:{call:"email",args:{value:t}}});return i.length>0?i:void 0}function Le(e,n){let t=Array.isArray(e.children)?e.children:[],i=[];for(let r of t){let o=u(r,"value");if(o==null){n.note("degraded",e.type,`dropped a ${r.type} child that carries no option value`);continue}i.push({label:u(r,"label")??o,value:o})}return i}function D(e,n,t){if(u(e,"label","name")==null)n.note("degraded",e.type,"no label available for the DateTimeInput");return{component:"DateTimeInput",value:m(e,n)??"",...t}}function I(e){return(n,t)=>{let i=t.dyn(u(n,"label","name"));if(i==null){t.note("unsupported",n.type,"ChoicePicker requires a label and none could be derived");return}let r=Le(n,t);if(r.length===0){t.note("unsupported",n.type,"no options to choose from");return}let o=m(n,t),s=P(n,t);return{component:"ChoicePicker",label:i,variant:e,options:r,...o!=null&&{value:o},...s!=null&&{checks:s}}}}function H(e,n,t){let i=n.dyn(u(e,"label","name"));if(i==null){n.note("unsupported",e.type,"TextField requires a label and none could be derived");return}let r=m(e,n),o=n.dyn(u(e,"placeholder")),s=P(e,n);return{component:"TextField",label:i,variant:t,...r!=null&&{value:r},...o!=null&&{placeholder:o},...s!=null&&{checks:s}}}var M={Input:(e,n)=>{let t=typeof e.inputType==="string"?e.inputType:"text",i=Ue[t];if(i==null)n.note("degraded",e.type,`inputType "${t}" has no A2UI variant; used shortText`);return H(e,n,i??"shortText")},Textarea:(e,n)=>H(e,n,"longText"),Checkbox:(e,n)=>{let t=n.dyn(u(e,"label","name"));if(t==null){n.note("unsupported",e.type,"CheckBox requires a label and none could be derived");return}let i=P(e,n);return{component:"CheckBox",label:t,value:m(e,n)??!1,...i!=null&&{checks:i}}},Slider:(e,n)=>{let t=typeof e.max==="number"?e.max:void 0;if(t==null){n.note("unsupported",e.type,"Slider requires a max and prefab left it open");return}let i=n.dyn(u(e,"label","name")),r=typeof e.min==="number"?e.min:void 0,o=typeof e.step==="number"?e.step:void 0,s=o!=null&&o>0?Math.max(1,Math.round((t-(r??0))/o)):void 0;return{component:"Slider",max:t,value:m(e,n)??r??0,...i!=null&&{label:i},...r!=null&&{min:r},...s!=null&&{steps:s}}},Button:(e,n)=>{let t=u(e,"label","content")??"Button",i=n.action(e.onClick,"Button")??(e.submit===!0?{event:{name:"submit"}}:void 0);if(i==null){n.note("unsupported",e.type,"Button requires an action and none could be derived");return}let r=n.push({component:"Text",text:n.dyn(t)??t}),o=e.variant==="link"||e.variant==="ghost"?"borderless":e.variant==="default"?"primary":"default";return{component:"Button",child:r,action:i,variant:o}},Link:(e,n)=>{let t=u(e,"href","url");if(t==null){n.note("unsupported",e.type,"no href to open");return}let i=u(e,"content","label")??t;return{component:"Button",child:n.push({component:"Text",text:n.dyn(i)??i}),variant:"borderless",action:{functionCall:{call:"openUrl",args:{url:t}}}}},DatePicker:(e,n)=>D(e,n,{enableDate:!0}),TimePicker:(e,n)=>D(e,n,{enableTime:!0}),DateTimePicker:(e,n)=>D(e,n,{enableDate:!0,enableTime:!0}),Select:(e,n)=>I(e.multiple===!0?"multipleSelection":"mutuallyExclusive")(e,n),RadioGroup:I("mutuallyExclusive"),Combobox:I("mutuallyExclusive")};M.Switch=M.Checkbox;var Fe={Card:(e,n)=>{let t=n.single(e.children);if(t==null){n.note("unsupported","Card","Card requires a child and it had none");return}return{component:"Card",child:t}},Alert:(e,n)=>{let t=n.single(e.children);if(t==null){n.note("unsupported","Alert","no alert body to render");return}let i=typeof e.variant==="string"?e.variant:"default";return n.note("degraded","Alert",`variant "${i}" rendered as a plain Card`),{component:"Card",child:t}},Separator:()=>({component:"Divider"}),Divider:()=>({component:"Divider"}),Icon:(e,n)=>{let t=u(e,"name","icon");if(t==null){n.note("unsupported","Icon","no icon name");return}let i=_(t);if(i==null){n.note("unsupported","Icon",`"${t}" has no equivalent in the A2UI icon set`);return}if(i!==t)n.note("degraded","Icon",`"${t}" mapped to the A2UI icon "${i}"`);return{component:"Icon",name:i}},Metric:(e,n)=>{let t=[],i=u(e,"label","title");if(i!=null)t.push(n.push({component:"Text",text:n.dyn(i)??i,variant:"caption"}));let r=u(e,"value");if(r!=null)t.push(n.push({component:"Text",text:n.dyn(r)??r}));if(t.length===0){n.note("unsupported","Metric","neither a label nor a value to render");return}return n.note("degraded","Metric","rendered as a Column of Text; trend and delta styling dropped"),{component:"Column",children:t}},Tabs:(e,n)=>{let t=Array.isArray(e.children)?e.children:[],i=[];for(let r of t){let o=n.single(r.children);if(o==null)continue;i.push({title:u(r,"title")??"Tab",child:o})}if(i.length===0){n.note("unsupported","Tabs","no tab had renderable content");return}return{component:"Tabs",tabs:i}},Dialog:(e,n)=>{let t=n.single(e.children);if(t==null){n.note("unsupported","Dialog","no dialog body to render");return}let i=e.trigger,r=i!=null?u(i,"label","content")??u(e,"title")??"Open":u(e,"title")??"Open";return{component:"Modal",trigger:(i!=null?n.child(i):void 0)??n.push({component:"Text",text:n.dyn(r)??r}),content:t}},AccordionItem:(e,n)=>{let t=[],i=u(e,"title");if(i!=null)t.push(n.push({component:"Text",text:i,variant:"caption"}));if(t.push(...n.children(e.children)),t.length===0){n.note("unsupported","AccordionItem","nothing to render");return}return n.note("degraded","AccordionItem","rendered expanded; A2UI Basic has no disclosure component"),{component:"Column",children:t}}},A={Column:y("Column"),Row:y("Row"),...q,...M,...Fe,...T,Image:O("Image"),Video:O("Video"),Audio:O("AudioPlayer"),Table:V,DataTable:j};for(let e of Ne)A[e]??=y("Column");for(let e of Be)A[e]??=y("Row");var _e=new Set(["Tab","SelectOption","ComboboxOption","Radio","Option",...J]),Je={LineChart:"charts",BarChart:"charts",AreaChart:"charts",PieChart:"charts",ScatterChart:"charts",RadarChart:"charts",RadialChart:"charts",Histogram:"charts",Sparkline:"charts",Svg:"inline vector graphics",Mermaid:"diagrams",Embed:"embedded frames",DropZone:"file uploads",Ring:"progress rings",Loader:"loading indicators",Progress:"progress bars"};function z(e){return A[e]}function G(e){return _e.has(e)}function W(){return Object.keys(A).sort()}function K(e,n){let t=Je[e.type];if(t!=null){n.note("unsupported",e.type,`${t} are outside the A2UI Basic catalog`);return}if(Array.isArray(e.children)&&e.children.length>0){let i=n.children(e.children);if(i.length>0)return n.note("degraded",e.type,"no Basic-catalog equivalent; flattened to a Column"),{component:"Column",children:i}}if(u(e,"content","text","label","title")!=null)return n.note("degraded",e.type,"no Basic-catalog equivalent; rendered as Text"),l(e,n);n.note("unsupported",e.type,"no Basic-catalog equivalent and nothing to render");return}var p="v1.0",b="https://a2ui.org/specification/v1_0/catalogs/basic/catalog.json",Y="application/a2ui+json",X="a2ui://",C="root";var je=x("a2ui");function Ve(e){let n=e.children;if(e.type==="Div"&&typeof e.cssClass==="string"&&e.cssClass.startsWith("pf-app-root")&&Array.isArray(n)&&n.length===1)return n[0];return e}function Z(e,n){if(e.type==="Define"){let t=typeof e.name==="string"?e.name:void 0;if(t!=null&&Array.isArray(e.children))n.set(t,e.children)}if(Array.isArray(e.children))for(let t of e.children)Z(t,n)}class Q{warn;components=new Map;dataModel=new Map;used=new Set([C]);diagnostics=[];definitions=new Map;counter=0;scope={};slots={};expanding=new Set;constructor(e){this.warn=e}bind(e){return f(e,this.scope)}dyn(e){return h(e,this.scope)}inScope(e,n){let t=this.scope;this.scope={...t,...e};try{return n()}finally{this.scope=t}}withSlots(e,n){let t=this.slots;this.slots={...t,...e};try{return n()}finally{this.slots=t}}slotContent(e){return this.slots[e]}definition(e){if(this.expanding.has(e)){this.note("unsupported","Use",`definition "${e}" uses itself; A2UI has no recursive template`);return}return this.definitions.get(e)}expand(e,n){this.expanding.add(e);try{return n()}finally{this.expanding.delete(e)}}note(e,n,t){if(this.diagnostics.push({kind:e,subject:n,detail:t}),this.warn)je.warn(`${e}: ${n} — ${t}`)}allocate(e){let n=typeof e?.id==="string"&&e.id.length>0?e.id:void 0;if(n!=null&&!this.used.has(n))return this.used.add(n),n;let t;do this.counter+=1,t=`c${this.counter}`;while(this.used.has(t));return this.used.add(t),t}push(e){let n=this.allocate();return this.components.set(n,{id:n,...e}),n}bindData(e,n){let t=e,i=0;while(this.dataModel.has(t))i+=1,t=`${e}${i}`;return this.dataModel.set(t,n),`/${c(t)}`}child(e){return this.emit(e,!1)}children(e){if(!Array.isArray(e))return[];let n=[];for(let t of e){if(t==null||typeof t!=="object")continue;let i=this.emit(t,!1);if(i!=null)n.push(i)}return n}single(e){let n=this.children(e);if(n.length===0)return;if(n.length===1)return n[0];return this.push({component:"Column",children:n})}action(e,n){if(e==null)return;if(Array.isArray(e)){if(e.length===0)return;if(e.length>1)this.note("action",n,`${e.length} actions were bound; A2UI carries one, so the rest were dropped`);return this.action(e[0],n)}if(typeof e!=="object")return;let t=e,i=typeof t.action==="string"?t.action:void 0;if(i==null)return;switch(i){case"toolCall":case"callTool":{let r=typeof t.tool==="string"?t.tool:void 0;if(r==null)return;let o=this.eventContext(t.arguments,n);return{event:{name:r,...o!=null&&{context:o}}}}case"sendMessage":return{event:{name:"sendMessage",context:{message:typeof t.message==="string"?t.message:""}}};case"openLink":{let r=typeof t.url==="string"?t.url:typeof t.href==="string"?t.href:void 0;if(r==null)return;return{functionCall:{call:"openUrl",args:{url:r}}}}default:{this.note("action",n,`"${i}" has no renderer-side equivalent; emitted as an agent event`);let{action:r,...o}=t,s=this.eventContext(o,n);return{event:{name:i,...s!=null&&{context:s}}}}}}eventContext(e,n){if(e==null||typeof e!=="object"||Array.isArray(e))return;let t={};for(let[i,r]of Object.entries(e)){if(typeof r==="number"||typeof r==="boolean"||r===null){t[i]=r;continue}if(typeof r!=="string"){this.note("action",n,`argument "${i}" is not a scalar and was dropped from the event context`);continue}let o=f(r);if(o.kind==="unbindable"){this.note("action",n,`argument "${i}" uses "${o.expression}", which A2UI cannot bind; it was dropped`);continue}t[i]=o.kind==="binding"?o.value:o.value}return Object.keys(t).length>0?t:void 0}rollback(e,n){let t=[...this.components.keys()];for(let r=e;r<t.length;r++)if(this.components.delete(t[r]),t[r]!==C)this.used.delete(t[r]);let i=[...this.dataModel.keys()];for(let r=n;r<i.length;r++)this.dataModel.delete(i[r])}emit(e,n){if(typeof e.type!=="string")return;if(G(e.type)){this.note("unsupported",e.type,"only meaningful inside its parent; emitted standalone it has no meaning");return}let t=this.components.size,i=this.dataModel.size,r=n?C:this.allocate(e);this.components.set(r,void 0);let s=(z(e.type)??K)(e,this);if(s==null){this.rollback(t,i);return}return this.components.set(r,{id:r,...s}),r}finish(e,n){let t=n.surfaceId??"prefab";for(let[d,oe]of Object.entries(e.defs??{}))this.definitions.set(d,[oe]);if(Z(e.view,this.definitions),this.emit(Ve(e.view),!0)==null)this.note("unsupported","view","nothing in the view could be expressed in A2UI; the surface is empty");let r=[];for(let d of this.components.values())if(d!=null)r.push(d);let o={...Object.fromEntries(this.dataModel),...e.state??{}},s=Object.keys(o).length>0,a=[],g=n.catalogId??b;if(n.stream===!0){if(a.push({version:p,createSurface:{surfaceId:t,catalogId:g,...n.sendDataModel===!0&&{sendDataModel:!0}}}),r.length>0)a.push({version:p,updateComponents:{surfaceId:t,components:r}});if(s)a.push({version:p,updateDataModel:{surfaceId:t,value:o}})}else a.push({version:p,createSurface:{surfaceId:t,catalogId:g,...n.sendDataModel===!0&&{sendDataModel:!0},...r.length>0&&{components:r},...s&&{dataModel:o}}});return{messages:a,diagnostics:this.diagnostics}}}function ee(e,n){let t=n??{};return new Q(t.warn===!0).finish(e,t)}var ne="0.3.18";function te(e,n){if(e==null||typeof e!=="object"||!("view"in e))throw TypeError('PrefabA2UI.emit: expected a $prefab payload with a "view"');return ee(e,n)}function ie(e){return{messages:e}}var re={emit:te,envelope:ie,mappedTypes:W,VERSION:ne,A2UI_VERSION:p,A2UI_BASIC_CATALOG:b,A2UI_MIME:Y,A2UI_SCHEME:X},qe=re;if(typeof window<"u")window.PrefabA2UI=re;})();
|
|
1
|
+
(()=>{var{defineProperty:v,getOwnPropertyNames:se,getOwnPropertyDescriptor:ae}=Object,ue=Object.prototype.hasOwnProperty;function le(e){return this[e]}var de=(e)=>{var n=(R??=new WeakMap).get(e),t;if(n)return n;if(n=v({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var i of se(e))if(!ue.call(n,i))v(n,i,{get:le.bind(e,i),enumerable:!(t=ae(e,i))||t.enumerable})}return R.set(e,n),n},R;var ce=(e)=>e;function pe(e,n){this[e]=ce.bind(null,n)}var fe=(e,n)=>{for(var t in n)v(e,t,{get:n[t],enumerable:!0,configurable:!0,set:pe.bind(n,t)})};var He={};fe(He,{default:()=>qe,emit:()=>te,envelope:()=>ie});var E={silent:0,error:1,warn:2,info:3,debug:4},me="warn";function x(e){let n=e?`[prefab:${e}]`:"[prefab]",t=(i,r,o)=>{if(E[i]>E[me])return;console[i](`${n} ${r}`,...o)};return{error:(i,...r)=>t("error",i,r),warn:(i,...r)=>t("warn",i,r),info:(i,...r)=>t("info",i,r),debug:(i,...r)=>t("debug",i,r)}}var Ge=x();var ge=/^(.+?)\s*\|\s*([A-Za-z_][\w]*)\s*(?::\s*(.+))?$/;function N(e){let n=ge.exec(e);if(n==null)return;let t=n[1].trim();if(t.includes("|"))return;let i=n.at(3)?.trim();if(i===void 0)return{base:t,name:n[2]};let r=/^'([^']*)'$|^"([^"]*)"$/.exec(i);if(r!=null){let s=r.at(1)??r.at(2);return{base:t,name:n[2],arg:s??""}}let o=Number(i);if(!Number.isNaN(o))return{base:t,name:n[2],arg:o};return}function S(e,n){return(t)=>({call:{call:"formatDate",args:{value:t,format:e}},note:`the "${n}" pipe renders in the reader's locale; A2UI needs an explicit pattern, so "${e}" was used`})}var he={currency:(e,n)=>({call:{call:"formatCurrency",args:{value:e,currency:typeof n==="string"?n:"USD"}}}),number:(e,n)=>({call:{call:"formatNumber",args:{value:e,...typeof n==="number"&&{decimals:n}}}}),round:(e,n)=>({call:{call:"formatNumber",args:{value:e,decimals:typeof n==="number"?n:0}}}),pluralize:(e,n)=>{if(typeof n!=="string")return;return{call:{call:"pluralize",args:{value:e,one:n,other:`${n}s`}}}},date:S("y-MM-dd","date"),time:S("HH:mm","time"),datetime:S("y-MM-dd HH:mm","datetime")};function B(e,n){return he[e.name]?.(n,e.arg)}var ye=/^\s*\{\{\s*(.+?)\s*\}\}\s*$/s,Ae=/\{\{\s*(.+?)\s*\}\}/g,be=/^\$?[A-Za-z_][\w$]*(?:\.(?:[A-Za-z_$][\w$]*|\d+))*$/,U="$index";function c(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Ce(e){return"/"+e.map(c).join("/")}function ve(e){return e.startsWith("state.")?e.slice(6):e}function w(e,n){if(!be.test(e))return;let t=ve(e).split("."),i=t[0],r=Object.hasOwn(n,i)?n[i]:void 0;if(r===void 0){if(i.startsWith("$"))return;return Ce(t)}let o=t.slice(1);if(r==="")return o.length===0?void 0:o.map(c).join("/");return o.length===0?r:`${r}/${o.map(c).join("/")}`}function L(e){return e.replace(/\$\{/g,"\\${")}function xe(e,n){let t,i="",r=0;for(let o of e.matchAll(Ae)){let s=o[1].trim(),a=w(s,n);if(a==null){t=s;break}i+=L(e.slice(r,o.index)),i+=`\${${a}}`,r=o.index+o[0].length}if(t!=null)return;return i+=L(e.slice(r)),{call:"formatString",args:{value:i}}}function Se(e,n){let t=N(e);if(t==null)return;let i=w(t.base,n),r=i!=null?{path:i}:/^-?\d+(\.\d+)?$/.test(t.base)?Number(t.base):void 0;if(r===void 0)return;let o=B(t,r);if(o==null)return;return{kind:"format",value:o.call,...o.note!=null&&{note:o.note}}}function f(e,n={}){let t=ye.exec(e);if(t!=null&&!t[1].includes("{{")&&!t[1].includes("}}")){let o=t[1].trim();if(o===U&&U in n)return{kind:"index",value:{call:"@index"}};let s=w(o,n);if(s!=null)return{kind:"binding",value:{path:s}};let a=Se(o,n);if(a!=null)return a;return{kind:"unbindable",expression:o}}if(!e.includes("{{"))return{kind:"literal",value:e};let r=xe(e,n);if(r!=null)return{kind:"format",value:r};return{kind:"unbindable",expression:e}}function h(e,n={}){if(e==null)return;let t=f(e,n);switch(t.kind){case"literal":return t.value;case"binding":return t.value;case"format":return t.value;case"index":return t.value;default:return}}var we=["accountCircle","add","arrowBack","arrowForward","attachFile","calendarToday","call","camera","check","close","delete","download","edit","event","error","fastForward","favorite","favoriteOff","folder","help","home","info","locationOn","lock","lockOpen","mail","menu","moreVert","moreHoriz","notificationsOff","notifications","pause","payment","person","phone","photo","play","print","refresh","rewind","search","send","settings","share","shoppingCart","skipNext","skipPrevious","star","starHalf","starOff","stop","upload","visibility","visibilityOff","volumeDown","volumeMute","volumeOff","volumeUp","warning"],ke=new Map(we.map((e)=>[F(e),e])),Te={alertcircle:"error",alerttriangle:"warning",alertoctagon:"error",xcircle:"error",circlex:"error",circlealert:"error",checkcircle:"check",circlecheck:"check",checkcircle2:"check",infocircle:"info",circleinfo:"info",helpcircle:"help",circlehelp:"help",bell:"notifications",belloff:"notificationsOff",arrowleft:"arrowBack",arrowright:"arrowForward",chevronleft:"arrowBack",chevronright:"arrowForward",x:"close",plus:"add",trash:"delete",trash2:"delete",ellipsisvertical:"moreVert",ellipsis:"moreHoriz",morehorizontal:"moreHoriz",morevertical:"moreVert",pencil:"edit",pen:"edit",squarepen:"edit",user:"person",usercircle:"accountCircle",circleuser:"accountCircle",eye:"visibility",eyeoff:"visibilityOff",mappin:"locationOn",map:"locationOn",image:"photo",images:"photo",file:"folder",files:"folder",calendar:"calendarToday",calendardays:"calendarToday",clock:"event",creditcard:"payment",cart:"shoppingCart",shoppingbag:"shoppingCart",phonecall:"call",mailopen:"mail",inbox:"mail",cog:"settings",gear:"settings",sliders:"settings",rotatecw:"refresh",rotateccw:"refresh",refreshcw:"refresh",heart:"favorite",heartoff:"favoriteOff",volume:"volumeUp",volume1:"volumeDown",volume2:"volumeUp",volumex:"volumeOff",skipforward:"skipNext",skipback:"skipPrevious",paperclip:"attachFile",link:"share",share2:"share",magnifyingglass:"search",searchicon:"search"};function F(e){return e.replace(/[\s._-]/g,"").toLowerCase()}function _(e){let n=F(e);return ke.get(n)??Te[n]}function k(e,...n){for(let t of n){let i=e[t];if(typeof i==="string"||typeof i==="number"||typeof i==="boolean")return String(i)}return}function Oe(e){return e!=null&&typeof e==="object"&&!Array.isArray(e)}var T={ForEach:(e,n)=>{let t=k(e,"expression");if(t==null){n.note("unsupported","ForEach","no expression to iterate");return}let i=n.bind(t);if(i.kind!=="binding"){n.note("expression","ForEach",`"${t}" is not a plain path, so there is no list to bind`);return}let r=n.inScope({$item:"",$index:""},()=>n.single(e.children));if(r==null){n.note("unsupported","ForEach","the loop body had nothing to render");return}return{component:"Column",children:{path:i.value.path,componentId:r}}},Define:()=>{return},Use:(e,n)=>{let t=k(e,"def","name");if(t==null){n.note("unsupported","Use","no definition name");return}let i=n.definition(t);if(i==null){n.note("unsupported","Use",`no definition named "${t}" was declared`);return}let r=e.overrides,o={};if(r!=null&&typeof r==="object"&&!Array.isArray(r)){let g=n.bindData(`use_${t}`,r);for(let d of Object.keys(r))o[d]=`${g}/${c(d)}`}let s={...Oe(e.slots)?e.slots:{},...Array.isArray(e.children)&&e.children.length>0?{default:e.children}:{}},a=n.expand(t,()=>n.inScope(o,()=>n.withSlots(s,()=>n.single(i))));if(a==null){n.note("unsupported","Use",`definition "${t}" rendered nothing`);return}return{component:"Column",children:[a]}},Slot:(e,n)=>{let t=k(e,"name")??"default",i=n.slotContent(t)??(Array.isArray(e.children)?e.children:void 0),r=i!=null?n.single(i):void 0;if(r==null){n.note("unsupported","Slot",`slot "${t}" had neither content nor a fallback`);return}return{component:"Column",children:[r]}}};for(let e of["If","Elif","Else","Condition","Match","Case"])T[e]=(n,t)=>{t.note("unsupported",n.type,"A2UI has no declarative conditional; the agent re-sends updateComponents when the shape changes");return};var J=["TableHead","TableBody","TableFooter","TableRow","TableCell","TableHeader","ExpandableRow"];function De(e){if(!Array.isArray(e.columns))return[];let n=[];for(let t of e.columns){if(t==null||typeof t!=="object")continue;let i=t,r=typeof i.accessor==="string"?i.accessor:typeof i.key==="string"?i.key:void 0;if(r==null)continue;n.push({key:r,header:typeof i.header==="string"?i.header:r})}return n}function Me(e,n){let t=e.rows;if(typeof t==="string"){let i=f(t);if(i.kind==="binding")return i.value.path;n.note("expression","DataTable",`rows expression "${t}" is not a plain path; the table has no data source`);return}if(Array.isArray(t))return n.bindData("rows",t);n.note("unsupported","DataTable","no rows to render");return}function j(e,n){let t=De(e);if(t.length===0){n.note("unsupported","DataTable","no usable column definitions");return}let i=Me(e,n);if(i==null)return;let r=n.push({component:"Row",children:t.map((a)=>n.push({component:"Text",text:a.header,variant:"caption"})),align:"center"}),o=n.push({component:"Row",children:t.map((a)=>n.push({component:"Text",text:{path:a.key.split(".").join("/")}})),align:"center"}),s=n.push({component:"Column",children:{path:i,componentId:o}});if(e.search===!0||e.paginated===!0)n.note("degraded","DataTable","search and pagination dropped; A2UI Basic has no table controls");return{component:"Column",children:[r,s]}}function Ie(e){let n=[],t=(i)=>{if(i.type==="TableRow"||i.type==="ExpandableRow"){n.push(i);return}if(Array.isArray(i.children))for(let r of i.children)t(r)};if(Array.isArray(e.children))for(let i of e.children)t(i);return n}function Pe(e,n){let t=e.type==="TableHeader";if(Array.isArray(e.children)&&e.children.length>0)return n.single(e.children);let i=e.content??e.text??e.label;if(typeof i!=="string"&&typeof i!=="number"&&typeof i!=="boolean")return;let r=String(i),o=h(r);if(o==null){n.note("expression",e.type,`cell expression "${r}" has no A2UI equivalent`);return}return n.push({component:"Text",text:o,...t&&{variant:"caption"}})}function V(e,n){let t=Ie(e),i=[];for(let r of t){let s=(Array.isArray(r.children)?r.children:[]).map((a)=>Pe(a,n)).filter((a)=>a!=null);if(s.length===0)continue;i.push(n.push({component:"Row",children:s,align:"center"}))}if(i.length===0){n.note("unsupported","Table","no rows with renderable cells");return}return n.note("degraded","Table","rendered as a Column of Rows; column widths do not align"),{component:"Column",children:i}}function u(e,...n){for(let t of n){let i=e[t];if(typeof i==="string"||typeof i==="number"||typeof i==="boolean")return String(i)}return}function l(e,n,t){let i=u(e,...t?.keys??["content","text","label","title"]);if(i==null){n.note("unsupported",e.type,"no text content to render");return}let r=n.bind(i);if(r.kind==="unbindable")n.note("expression",e.type,`"${r.expression}" is richer than a JSON Pointer; the text was left as written`);let o=t?.prefix??"",s=t?.suffix??"";if(r.kind==="format"&&r.note!=null)n.note("degraded",e.type,r.note);if(r.kind==="binding"||r.kind==="format"||r.kind==="index"){if(o!==""||s!=="")n.note("degraded",e.type,"Markdown emphasis dropped: the text is a data binding");return{component:"Text",text:r.value,...t?.variant!=null&&{variant:t.variant}}}let a=r.kind==="literal"?r.value:i;return{component:"Text",text:`${o}${a}${s}`,...t?.variant!=null&&{variant:t.variant}}}var Re={start:"start",end:"end",center:"center",between:"spaceBetween",around:"spaceAround",evenly:"spaceEvenly",spaceBetween:"spaceBetween",spaceAround:"spaceAround",spaceEvenly:"spaceEvenly"},Ee={start:"start",end:"end",center:"center",stretch:"stretch",baseline:"baseline"};function y(e){return(n,t)=>{let i=t.children(n.children);if(i.length===0){t.note("unsupported",n.type,`${e} requires at least one child and none survived`);return}let r=typeof n.justify==="string"?Re[n.justify]:void 0,o=typeof n.align==="string"?Ee[n.align]:void 0;return{component:e,children:i,...r!=null&&{justify:r},...o!=null&&{align:o}}}}var Ne=["Div","Container","Stack","Grid","GridItem","Page","Pages","Dashboard","DashboardItem","MasterDetail","Detail","Form","Fieldset","CardContent","CardHeader","CardFooter","Accordion","Carousel","SelectGroup","ComboboxGroup","Section","Article","Aside","Header","Footer","Nav","Span"],Be=["ButtonGroup","Toolbar","Inline"],$e={H1:"# ",H2:"## ",H3:"### ",H4:"#### ",H5:"##### ",H6:"###### "},q={Heading:(e,n)=>{let t=typeof e.level==="number"?Math.min(6,Math.max(1,e.level)):1;return l(e,n,{prefix:`${"#".repeat(t)} `})},Text:(e,n)=>l(e,n),P:(e,n)=>l(e,n),Lead:(e,n)=>l(e,n),Large:(e,n)=>l(e,n),Small:(e,n)=>l(e,n,{variant:"caption"}),Muted:(e,n)=>l(e,n,{variant:"caption"}),Label:(e,n)=>l(e,n,{variant:"caption"}),TableCaption:(e,n)=>l(e,n,{variant:"caption"}),BlockQuote:(e,n)=>l(e,n,{prefix:"> "}),Code:(e,n)=>l(e,n,{prefix:"`",suffix:"`"}),Kbd:(e,n)=>l(e,n,{prefix:"`",suffix:"`"}),Markdown:(e,n)=>l(e,n),Badge:(e,n)=>l(e,n,{keys:["label","content"],variant:"caption"}),CardTitle:(e,n)=>l(e,n,{prefix:"**",suffix:"**"}),CardDescription:(e,n)=>l(e,n,{variant:"caption"}),Tooltip:(e,n)=>l(e,n,{variant:"caption"}),AlertTitle:(e,n)=>l(e,n,{prefix:"**",suffix:"**"}),AlertDescription:(e,n)=>l(e,n)};for(let[e,n]of Object.entries($e))q[e]=(t,i)=>l(t,i,{prefix:n});function O(e){return(n,t)=>{let i=t.dyn(u(n,"src","url"));if(i==null){t.note("unsupported",n.type,"no resolvable source URL");return}let r=e==="Video"?void 0:t.dyn(u(n,"alt","description")),o=e==="Video"?t.dyn(u(n,"poster","posterUrl")):void 0;return{component:e,url:i,...r!=null&&{description:r},...o!=null&&{posterUrl:o}}}}var Ue={text:"shortText",email:"shortText",url:"shortText",tel:"shortText",search:"shortText",password:"obscured",number:"number"};function m(e,n){let t=typeof e.name==="string"?e.name:void 0;if(t==null)return;let i=n.bind(`{{ ${t} }}`);return i.kind==="binding"?i.value:void 0}function P(e,n){let t=m(e,n);if(t==null)return;let i=[];if(e.required===!0)i.push({condition:{call:"required",args:{value:t}}});if(e.inputType==="email")i.push({condition:{call:"email",args:{value:t}}});return i.length>0?i:void 0}function Le(e,n){let t=Array.isArray(e.children)?e.children:[],i=[];for(let r of t){let o=u(r,"value");if(o==null){n.note("degraded",e.type,`dropped a ${r.type} child that carries no option value`);continue}i.push({label:u(r,"label")??o,value:o})}return i}function D(e,n,t){if(u(e,"label","name")==null)n.note("degraded",e.type,"no label available for the DateTimeInput");return{component:"DateTimeInput",value:m(e,n)??"",...t}}function M(e){return(n,t)=>{let i=t.dyn(u(n,"label","name"));if(i==null){t.note("unsupported",n.type,"ChoicePicker requires a label and none could be derived");return}let r=Le(n,t);if(r.length===0){t.note("unsupported",n.type,"no options to choose from");return}let o=m(n,t),s=P(n,t);return{component:"ChoicePicker",label:i,variant:e,options:r,...o!=null&&{value:o},...s!=null&&{checks:s}}}}function H(e,n,t){let i=n.dyn(u(e,"label","name"));if(i==null){n.note("unsupported",e.type,"TextField requires a label and none could be derived");return}let r=m(e,n),o=n.dyn(u(e,"placeholder")),s=P(e,n);return{component:"TextField",label:i,variant:t,...r!=null&&{value:r},...o!=null&&{placeholder:o},...s!=null&&{checks:s}}}var I={Input:(e,n)=>{let t=typeof e.inputType==="string"?e.inputType:"text",i=Ue[t];if(i==null)n.note("degraded",e.type,`inputType "${t}" has no A2UI variant; used shortText`);return H(e,n,i??"shortText")},Textarea:(e,n)=>H(e,n,"longText"),Checkbox:(e,n)=>{let t=n.dyn(u(e,"label","name"));if(t==null){n.note("unsupported",e.type,"CheckBox requires a label and none could be derived");return}let i=P(e,n);return{component:"CheckBox",label:t,value:m(e,n)??!1,...i!=null&&{checks:i}}},Slider:(e,n)=>{let t=typeof e.max==="number"?e.max:void 0;if(t==null){n.note("unsupported",e.type,"Slider requires a max and prefab left it open");return}let i=n.dyn(u(e,"label","name")),r=typeof e.min==="number"?e.min:void 0,o=typeof e.step==="number"?e.step:void 0,s=o!=null&&o>0?Math.max(1,Math.round((t-(r??0))/o)):void 0;return{component:"Slider",max:t,value:m(e,n)??r??0,...i!=null&&{label:i},...r!=null&&{min:r},...s!=null&&{steps:s}}},Button:(e,n)=>{let t=u(e,"label","content")??"Button",i=n.action(e.onClick,"Button")??(e.submit===!0?{event:{name:"submit"}}:void 0);if(i==null){n.note("unsupported",e.type,"Button requires an action and none could be derived");return}let r=n.push({component:"Text",text:n.dyn(t)??t}),o=e.variant==="link"||e.variant==="ghost"?"borderless":e.variant==="default"?"primary":"default";return{component:"Button",child:r,action:i,variant:o}},Link:(e,n)=>{let t=u(e,"href","url");if(t==null){n.note("unsupported",e.type,"no href to open");return}let i=u(e,"content","label")??t;return{component:"Button",child:n.push({component:"Text",text:n.dyn(i)??i}),variant:"borderless",action:{functionCall:{call:"openUrl",args:{url:t}}}}},DatePicker:(e,n)=>D(e,n,{enableDate:!0}),TimePicker:(e,n)=>D(e,n,{enableTime:!0}),DateTimePicker:(e,n)=>D(e,n,{enableDate:!0,enableTime:!0}),Select:(e,n)=>M(e.multiple===!0?"multipleSelection":"mutuallyExclusive")(e,n),RadioGroup:M("mutuallyExclusive"),Combobox:M("mutuallyExclusive")};I.Switch=I.Checkbox;var Fe={Card:(e,n)=>{let t=n.single(e.children);if(t==null){n.note("unsupported","Card","Card requires a child and it had none");return}return{component:"Card",child:t}},Alert:(e,n)=>{let t=n.single(e.children);if(t==null){n.note("unsupported","Alert","no alert body to render");return}let i=typeof e.variant==="string"?e.variant:"default";return n.note("degraded","Alert",`variant "${i}" rendered as a plain Card`),{component:"Card",child:t}},Separator:()=>({component:"Divider"}),Divider:()=>({component:"Divider"}),Icon:(e,n)=>{let t=u(e,"name","icon");if(t==null){n.note("unsupported","Icon","no icon name");return}let i=_(t);if(i==null){n.note("unsupported","Icon",`"${t}" has no equivalent in the A2UI icon set`);return}if(i!==t)n.note("degraded","Icon",`"${t}" mapped to the A2UI icon "${i}"`);return{component:"Icon",name:i}},Metric:(e,n)=>{let t=[],i=u(e,"label","title");if(i!=null)t.push(n.push({component:"Text",text:n.dyn(i)??i,variant:"caption"}));let r=u(e,"value");if(r!=null)t.push(n.push({component:"Text",text:n.dyn(r)??r}));if(t.length===0){n.note("unsupported","Metric","neither a label nor a value to render");return}return n.note("degraded","Metric","rendered as a Column of Text; trend and delta styling dropped"),{component:"Column",children:t}},Tabs:(e,n)=>{let t=Array.isArray(e.children)?e.children:[],i=[];for(let r of t){let o=n.single(r.children);if(o==null)continue;i.push({title:u(r,"title")??"Tab",child:o})}if(i.length===0){n.note("unsupported","Tabs","no tab had renderable content");return}return{component:"Tabs",tabs:i}},Dialog:(e,n)=>{let t=n.single(e.children);if(t==null){n.note("unsupported","Dialog","no dialog body to render");return}let i=e.trigger,r=i!=null?u(i,"label","content")??u(e,"title")??"Open":u(e,"title")??"Open";return{component:"Modal",trigger:(i!=null?n.child(i):void 0)??n.push({component:"Text",text:n.dyn(r)??r}),content:t}},AccordionItem:(e,n)=>{let t=[],i=u(e,"title");if(i!=null)t.push(n.push({component:"Text",text:i,variant:"caption"}));if(t.push(...n.children(e.children)),t.length===0){n.note("unsupported","AccordionItem","nothing to render");return}return n.note("degraded","AccordionItem","rendered expanded; A2UI Basic has no disclosure component"),{component:"Column",children:t}}},A={Column:y("Column"),Row:y("Row"),...q,...I,...Fe,...T,Image:O("Image"),Video:O("Video"),Audio:O("AudioPlayer"),Table:V,DataTable:j};for(let e of Ne)A[e]??=y("Column");for(let e of Be)A[e]??=y("Row");var _e=new Set(["Tab","SelectOption","ComboboxOption","Radio","Option",...J]),Je={LineChart:"charts",BarChart:"charts",AreaChart:"charts",PieChart:"charts",ScatterChart:"charts",RadarChart:"charts",RadialChart:"charts",Histogram:"charts",Sparkline:"charts",Svg:"inline vector graphics",Mermaid:"diagrams",Embed:"embedded frames",DropZone:"file uploads",Ring:"progress rings",Loader:"loading indicators",Progress:"progress bars"};function z(e){return A[e]}function G(e){return _e.has(e)}function W(){return Object.keys(A).sort()}function K(e,n){let t=Je[e.type];if(t!=null){n.note("unsupported",e.type,`${t} are outside the A2UI Basic catalog`);return}if(Array.isArray(e.children)&&e.children.length>0){let i=n.children(e.children);if(i.length>0)return n.note("degraded",e.type,"no Basic-catalog equivalent; flattened to a Column"),{component:"Column",children:i}}if(u(e,"content","text","label","title")!=null)return n.note("degraded",e.type,"no Basic-catalog equivalent; rendered as Text"),l(e,n);n.note("unsupported",e.type,"no Basic-catalog equivalent and nothing to render");return}var p="v1.0",b="https://a2ui.org/specification/v1_0/catalogs/basic/catalog.json",Y="application/a2ui+json",X="a2ui://",C="root";var je=x("a2ui");function Ve(e){let n=e.children;if(e.type==="Div"&&typeof e.cssClass==="string"&&e.cssClass.startsWith("pf-app-root")&&Array.isArray(n)&&n.length===1)return n[0];return e}function Z(e,n){if(e.type==="Define"){let t=typeof e.name==="string"?e.name:void 0;if(t!=null&&Array.isArray(e.children))n.set(t,e.children)}if(Array.isArray(e.children))for(let t of e.children)Z(t,n)}class Q{warn;components=new Map;dataModel=new Map;used=new Set([C]);diagnostics=[];definitions=new Map;counter=0;scope={};slots={};expanding=new Set;constructor(e){this.warn=e}bind(e){return f(e,this.scope)}dyn(e){return h(e,this.scope)}inScope(e,n){let t=this.scope;this.scope={...t,...e};try{return n()}finally{this.scope=t}}withSlots(e,n){let t=this.slots;this.slots={...t,...e};try{return n()}finally{this.slots=t}}slotContent(e){return this.slots[e]}definition(e){if(this.expanding.has(e)){this.note("unsupported","Use",`definition "${e}" uses itself; A2UI has no recursive template`);return}return this.definitions.get(e)}expand(e,n){this.expanding.add(e);try{return n()}finally{this.expanding.delete(e)}}note(e,n,t){if(this.diagnostics.push({kind:e,subject:n,detail:t}),this.warn)je.warn(`${e}: ${n} — ${t}`)}allocate(e){let n=typeof e?.id==="string"&&e.id.length>0?e.id:void 0;if(n!=null&&!this.used.has(n))return this.used.add(n),n;let t;do this.counter+=1,t=`c${this.counter}`;while(this.used.has(t));return this.used.add(t),t}push(e){let n=this.allocate();return this.components.set(n,{id:n,...e}),n}bindData(e,n){let t=e,i=0;while(this.dataModel.has(t))i+=1,t=`${e}${i}`;return this.dataModel.set(t,n),`/${c(t)}`}child(e){return this.emit(e,!1)}children(e){if(!Array.isArray(e))return[];let n=[];for(let t of e){if(t==null||typeof t!=="object")continue;let i=this.emit(t,!1);if(i!=null)n.push(i)}return n}single(e){let n=this.children(e);if(n.length===0)return;if(n.length===1)return n[0];return this.push({component:"Column",children:n})}action(e,n){if(e==null)return;if(Array.isArray(e)){if(e.length===0)return;if(e.length>1)this.note("action",n,`${e.length} actions were bound; A2UI carries one, so the rest were dropped`);return this.action(e[0],n)}if(typeof e!=="object")return;let t=e,i=typeof t.action==="string"?t.action:void 0;if(i==null)return;switch(i){case"toolCall":case"callTool":{let r=typeof t.tool==="string"?t.tool:void 0;if(r==null)return;let o=this.eventContext(t.arguments,n);return{event:{name:r,...o!=null&&{context:o}}}}case"sendMessage":return{event:{name:"sendMessage",context:{message:typeof t.message==="string"?t.message:""}}};case"openLink":{let r=typeof t.url==="string"?t.url:typeof t.href==="string"?t.href:void 0;if(r==null)return;return{functionCall:{call:"openUrl",args:{url:r}}}}default:{this.note("action",n,`"${i}" has no renderer-side equivalent; emitted as an agent event`);let{action:r,...o}=t,s=this.eventContext(o,n);return{event:{name:i,...s!=null&&{context:s}}}}}}eventContext(e,n){if(e==null||typeof e!=="object"||Array.isArray(e))return;let t={};for(let[i,r]of Object.entries(e)){if(typeof r==="number"||typeof r==="boolean"||r===null){t[i]=r;continue}if(typeof r!=="string"){this.note("action",n,`argument "${i}" is not a scalar and was dropped from the event context`);continue}let o=f(r);if(o.kind==="unbindable"){this.note("action",n,`argument "${i}" uses "${o.expression}", which A2UI cannot bind; it was dropped`);continue}t[i]=o.kind==="binding"?o.value:o.value}return Object.keys(t).length>0?t:void 0}rollback(e,n){let t=[...this.components.keys()];for(let r=e;r<t.length;r++)if(this.components.delete(t[r]),t[r]!==C)this.used.delete(t[r]);let i=[...this.dataModel.keys()];for(let r=n;r<i.length;r++)this.dataModel.delete(i[r])}emit(e,n){if(typeof e.type!=="string")return;if(G(e.type)){this.note("unsupported",e.type,"only meaningful inside its parent; emitted standalone it has no meaning");return}let t=this.components.size,i=this.dataModel.size,r=n?C:this.allocate(e);this.components.set(r,void 0);let s=(z(e.type)??K)(e,this);if(s==null){this.rollback(t,i);return}return this.components.set(r,{id:r,...s}),r}finish(e,n){let t=n.surfaceId??"prefab";for(let[d,oe]of Object.entries(e.defs??{}))this.definitions.set(d,[oe]);if(Z(e.view,this.definitions),this.emit(Ve(e.view),!0)==null)this.note("unsupported","view","nothing in the view could be expressed in A2UI; the surface is empty");let r=[];for(let d of this.components.values())if(d!=null)r.push(d);let o={...Object.fromEntries(this.dataModel),...e.state??{}},s=Object.keys(o).length>0,a=[],g=n.catalogId??b;if(n.stream===!0){if(a.push({version:p,createSurface:{surfaceId:t,catalogId:g,...n.sendDataModel===!0&&{sendDataModel:!0}}}),r.length>0)a.push({version:p,updateComponents:{surfaceId:t,components:r}});if(s)a.push({version:p,updateDataModel:{surfaceId:t,value:o}})}else a.push({version:p,createSurface:{surfaceId:t,catalogId:g,...n.sendDataModel===!0&&{sendDataModel:!0},...r.length>0&&{components:r},...s&&{dataModel:o}}});return{messages:a,diagnostics:this.diagnostics}}}function ee(e,n){let t=n??{};return new Q(t.warn===!0).finish(e,t)}var ne="0.3.20";function te(e,n){if(e==null||typeof e!=="object"||!("view"in e))throw TypeError('PrefabA2UI.emit: expected a $prefab payload with a "view"');return ee(e,n)}function ie(e){return{messages:e}}var re={emit:te,envelope:ie,mappedTypes:W,VERSION:ne,A2UI_VERSION:p,A2UI_BASIC_CATALOG:b,A2UI_MIME:Y,A2UI_SCHEME:X},qe=re;if(typeof window<"u")Object.assign(window,{PrefabA2UI:re});})();
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Subscribe action — declarative real-time resource subscriptions with polling fallback.
|
|
3
|
-
*
|
|
4
|
-
* Enables server→client push via MCP resource subscriptions when the host supports it.
|
|
5
|
-
* Automatically falls back to SetInterval + CallTool polling otherwise.
|
|
6
|
-
*/
|
|
7
1
|
import type { Action, ActionJSON } from './types.js';
|
|
8
2
|
export interface SubscribeOpts {
|
|
9
3
|
/** Reactive store key where incoming data is written. */
|
|
@@ -18,15 +12,11 @@ export interface SubscribeOpts {
|
|
|
18
12
|
fallbackArgs?: Record<string, unknown>;
|
|
19
13
|
/** Action(s) executed whenever new data arrives (push or poll). */
|
|
20
14
|
onData?: Action | Action[];
|
|
21
|
-
/** Action(s) executed
|
|
15
|
+
/** Action(s) executed when the host refuses the subscription or a poll fails. */
|
|
22
16
|
onError?: Action | Action[];
|
|
23
17
|
}
|
|
24
18
|
/**
|
|
25
|
-
* Subscribe to a resource URI
|
|
26
|
-
*
|
|
27
|
-
* When the host supports MCP resource subscriptions (`capabilities.subscriptions`),
|
|
28
|
-
* the renderer uses push notifications via the bridge. Otherwise it falls back to
|
|
29
|
-
* periodic polling using `SetInterval` + `CallTool`.
|
|
19
|
+
* Subscribe to a resource URI: push when the host supports resource subscriptions, otherwise poll `fallbackTool`.
|
|
30
20
|
*
|
|
31
21
|
* @example
|
|
32
22
|
* ```ts
|
|
@@ -45,12 +35,7 @@ export declare class Subscribe implements Action {
|
|
|
45
35
|
constructor(uri: string, opts: SubscribeOpts);
|
|
46
36
|
toJSON(): ActionJSON;
|
|
47
37
|
}
|
|
48
|
-
/**
|
|
49
|
-
* Unsubscribe from a previously subscribed resource URI.
|
|
50
|
-
*
|
|
51
|
-
* Typically used in cleanup or when navigating away from a view.
|
|
52
|
-
* The renderer also automatically unsubscribes on destroy.
|
|
53
|
-
*/
|
|
38
|
+
/** Unsubscribe from a resource URI; the renderer also unsubscribes everything on destroy. */
|
|
54
39
|
export declare class Unsubscribe implements Action {
|
|
55
40
|
readonly uri: string;
|
|
56
41
|
constructor(uri: string);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../../src/actions/subscribe.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../../src/actions/subscribe.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAIpD,MAAM,WAAW,aAAa;IAC5B,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAA;IAChB,uIAAuI;IACvI,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,8FAA8F;IAC9F,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,kDAAkD;IAClD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,kDAAkD;IAClD,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACtC,mEAAmE;IACnE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC1B,iFAAiF;IACjF,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAC5B;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,SAAU,YAAW,MAAM;IAEpC,QAAQ,CAAC,GAAG,EAAE,MAAM;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBADZ,GAAG,EAAE,MAAM,EACH,IAAI,EAAE,aAAa;IAGtC,MAAM,IAAI,UAAU;CAcrB;AAED,6FAA6F;AAC7F,qBAAa,WAAY,YAAW,MAAM;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM;gBAAX,GAAG,EAAE,MAAM;IAEhC,MAAM,IAAI,UAAU;CAGrB"}
|
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Subscribe action — declarative real-time resource subscriptions with polling fallback.
|
|
3
|
-
*
|
|
4
|
-
* Enables server→client push via MCP resource subscriptions when the host supports it.
|
|
5
|
-
* Automatically falls back to SetInterval + CallTool polling otherwise.
|
|
6
|
-
*/
|
|
7
1
|
import { serializeCallbacks } from './types.js';
|
|
8
2
|
import { serializeValue } from '../core/component.js';
|
|
9
3
|
/**
|
|
10
|
-
* Subscribe to a resource URI
|
|
11
|
-
*
|
|
12
|
-
* When the host supports MCP resource subscriptions (`capabilities.subscriptions`),
|
|
13
|
-
* the renderer uses push notifications via the bridge. Otherwise it falls back to
|
|
14
|
-
* periodic polling using `SetInterval` + `CallTool`.
|
|
4
|
+
* Subscribe to a resource URI: push when the host supports resource subscriptions, otherwise poll `fallbackTool`.
|
|
15
5
|
*
|
|
16
6
|
* @example
|
|
17
7
|
* ```ts
|
|
@@ -52,12 +42,7 @@ export class Subscribe {
|
|
|
52
42
|
return json;
|
|
53
43
|
}
|
|
54
44
|
}
|
|
55
|
-
/**
|
|
56
|
-
* Unsubscribe from a previously subscribed resource URI.
|
|
57
|
-
*
|
|
58
|
-
* Typically used in cleanup or when navigating away from a view.
|
|
59
|
-
* The renderer also automatically unsubscribes on destroy.
|
|
60
|
-
*/
|
|
45
|
+
/** Unsubscribe from a resource URI; the renderer also unsubscribes everything on destroy. */
|
|
61
46
|
export class Unsubscribe {
|
|
62
47
|
uri;
|
|
63
48
|
constructor(uri) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribe.js","sourceRoot":"","sources":["../../src/actions/subscribe.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"subscribe.js","sourceRoot":"","sources":["../../src/actions/subscribe.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAmBrD;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,SAAS;IAET;IACQ;IAFnB,YACW,GAAW,EACH,IAAmB;QAD3B,QAAG,GAAH,GAAG,CAAQ;QACH,SAAI,GAAJ,IAAI,CAAe;IACnC,CAAC;IAEJ,MAAM;QACJ,MAAM,IAAI,GAAe;YACvB,MAAM,EAAE,WAAW;YACnB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ;SAC7B,CAAA;QACD,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,KAAK;YAAE,IAAI,CAAC,IAAI,GAAG,KAAK,CAAA;QAC/C,IAAI,IAAI,CAAC,IAAI,CAAC,gBAAgB,IAAI,IAAI;YAAE,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAA;QAC1F,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAA;QACtE,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,IAAI,CAAC,YAAY,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QACtF,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,IAAI,CAAC,MAAM,GAAG,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACxE,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,IAAI,CAAC,OAAO,GAAG,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC3E,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAED,6FAA6F;AAC7F,MAAM,OAAO,WAAW;IACD;IAArB,YAAqB,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;IAEpC,MAAM;QACJ,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAA;IACjD,CAAC;CACF"}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* PdfViewer
|
|
3
|
-
*
|
|
4
|
-
* Uses Mozilla PDF.js loaded on-demand from CDN. Renders pages to `<canvas>`
|
|
5
|
-
* with an optional text layer for copy/paste and search.
|
|
6
|
-
*
|
|
7
|
-
* CSP requirements:
|
|
8
|
-
* - `resourceDomains`: include the PDF.js CDN (jsdelivr by default)
|
|
9
|
-
* - `connectDomains`: include the origin serving your PDF files
|
|
2
|
+
* PdfViewer: PDF.js (from jsDelivr, so list it in `resourceDomains`) draws pages to a `<canvas>`.
|
|
3
|
+
* A `src` URL's origin belongs in `connectDomains`.
|
|
10
4
|
*/
|
|
11
5
|
import { Component } from '../../core/component.js';
|
|
12
6
|
import type { ComponentProps } from '../../core/component.js';
|
|
@@ -20,7 +14,7 @@ export interface PdfViewerProps extends ComponentProps {
|
|
|
20
14
|
page?: number;
|
|
21
15
|
/** Zoom mode or scale factor. @default 'fit-width' */
|
|
22
16
|
zoom?: PdfZoom;
|
|
23
|
-
/** Show
|
|
17
|
+
/** Show the page navigation toolbar. @default true */
|
|
24
18
|
toolbar?: boolean;
|
|
25
19
|
/** Container height in pixels. @default 600 */
|
|
26
20
|
height?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/pdf/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/pdf/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAE7D,MAAM,MAAM,OAAO,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,CAAA;AAEvD,MAAM,WAAW,cAAe,SAAQ,cAAc;IACpD,iEAAiE;IACjE,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,wDAAwD;IACxD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,sDAAsD;IACtD,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,sDAAsD;IACtD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,KAAK,CAAC,GAAG,SAAS,CAmB5G"}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* PdfViewer
|
|
3
|
-
*
|
|
4
|
-
* Uses Mozilla PDF.js loaded on-demand from CDN. Renders pages to `<canvas>`
|
|
5
|
-
* with an optional text layer for copy/paste and search.
|
|
6
|
-
*
|
|
7
|
-
* CSP requirements:
|
|
8
|
-
* - `resourceDomains`: include the PDF.js CDN (jsdelivr by default)
|
|
9
|
-
* - `connectDomains`: include the origin serving your PDF files
|
|
2
|
+
* PdfViewer: PDF.js (from jsDelivr, so list it in `resourceDomains`) draws pages to a `<canvas>`.
|
|
3
|
+
* A `src` URL's origin belongs in `connectDomains`.
|
|
10
4
|
*/
|
|
11
5
|
import { Component } from '../../core/component.js';
|
|
12
6
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/pdf/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/pdf/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAoBnD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,SAAS,CAAC,UAAmC,EAAE,IAAkC;IAC/F,MAAM,GAAG,GAAG,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAA;IACxE,MAAM,IAAI,GAAG,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAA;IACzE,MAAM,SAAS,GAAG,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAA;IACpE,MAAM,IAAI,GAAG,SAAS,EAAE,IAAI,IAAI,CAAC,CAAA;IACjC,MAAM,IAAI,GAAG,SAAS,EAAE,IAAI,IAAI,WAAW,CAAA;IAC3C,MAAM,OAAO,GAAG,SAAS,EAAE,OAAO,IAAI,IAAI,CAAA;IAC1C,MAAM,MAAM,GAAG,SAAS,EAAE,MAAM,IAAI,GAAG,CAAA;IAEvC,MAAM,CAAC,GAAG,IAAI,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;IAC/C,CAAC,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC,CAAC;QAClB,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,CAAC;QACnB,GAAG,CAAC,IAAI,IAAI,EAAE,IAAI,EAAE,CAAC;QACrB,IAAI;QACJ,IAAI;QACJ,OAAO;QACP,MAAM;KACP,CAAC,CAAA;IACF,OAAO,CAAC,CAAA;AACV,CAAC"}
|
package/dist/core/escape.d.ts
CHANGED
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTML escaping for server-built markup.
|
|
3
|
-
*
|
|
4
|
-
* One function, safe in every context prefab emits: element text, and attribute
|
|
5
|
-
* values whether they are double- or single-quoted. Callers do not have to know
|
|
6
|
-
* which context they are in, which is the point — the three previous copies of
|
|
7
|
-
* this logic each escaped a different subset and each happened to be correct only
|
|
8
|
-
* for its own call site.
|
|
9
|
-
*
|
|
10
|
-
* `'` is escaped as `'` rather than `'`: the numeric reference is
|
|
11
|
-
* understood by HTML4 parsers too, and costs nothing here.
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Escape `& < > " '` for safe interpolation into HTML.
|
|
15
|
-
*
|
|
16
|
-
* Escaping is not sanitizing. This makes a value inert as *markup*; it does not
|
|
17
|
-
* make a URL safe to put in `href`/`src`. Scheme filtering is a separate concern
|
|
18
|
-
* (see `MD_UNSAFE_SCHEMES` in the markdown renderer).
|
|
19
|
-
*/
|
|
1
|
+
/** Escape `& < > " '` for element text and quoted attributes. It does not make a URL safe for `href`/`src`. */
|
|
20
2
|
export declare function escapeHtml(s: string): string;
|
|
21
3
|
//# sourceMappingURL=escape.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escape.d.ts","sourceRoot":"","sources":["../../src/core/escape.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"escape.d.ts","sourceRoot":"","sources":["../../src/core/escape.ts"],"names":[],"mappings":"AAQA,+GAA+G;AAC/G,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE5C"}
|
package/dist/core/escape.js
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTML escaping for server-built markup.
|
|
3
|
-
*
|
|
4
|
-
* One function, safe in every context prefab emits: element text, and attribute
|
|
5
|
-
* values whether they are double- or single-quoted. Callers do not have to know
|
|
6
|
-
* which context they are in, which is the point — the three previous copies of
|
|
7
|
-
* this logic each escaped a different subset and each happened to be correct only
|
|
8
|
-
* for its own call site.
|
|
9
|
-
*
|
|
10
|
-
* `'` is escaped as `'` rather than `'`: the numeric reference is
|
|
11
|
-
* understood by HTML4 parsers too, and costs nothing here.
|
|
12
|
-
*/
|
|
13
1
|
const HTML_ESCAPES = {
|
|
14
2
|
'&': '&',
|
|
15
3
|
'<': '<',
|
|
@@ -17,13 +5,7 @@ const HTML_ESCAPES = {
|
|
|
17
5
|
'"': '"',
|
|
18
6
|
"'": ''',
|
|
19
7
|
};
|
|
20
|
-
/**
|
|
21
|
-
* Escape `& < > " '` for safe interpolation into HTML.
|
|
22
|
-
*
|
|
23
|
-
* Escaping is not sanitizing. This makes a value inert as *markup*; it does not
|
|
24
|
-
* make a URL safe to put in `href`/`src`. Scheme filtering is a separate concern
|
|
25
|
-
* (see `MD_UNSAFE_SCHEMES` in the markdown renderer).
|
|
26
|
-
*/
|
|
8
|
+
/** Escape `& < > " '` for element text and quoted attributes. It does not make a URL safe for `href`/`src`. */
|
|
27
9
|
export function escapeHtml(s) {
|
|
28
10
|
return s.replace(/[&<>"']/g, c => HTML_ESCAPES[c] ?? c);
|
|
29
11
|
}
|
package/dist/core/escape.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escape.js","sourceRoot":"","sources":["../../src/core/escape.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"escape.js","sourceRoot":"","sources":["../../src/core/escape.ts"],"names":[],"mappings":"AAAA,MAAM,YAAY,GAAqC;IACrD,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,OAAO;CACb,CAAA;AAED,+GAA+G;AAC/G,MAAM,UAAU,UAAU,CAAC,CAAS;IAClC,OAAO,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;AACzD,CAAC"}
|
package/dist/core/humanize.d.ts
CHANGED
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Key humanization — turn a data key into a label a person reads.
|
|
3
|
-
*
|
|
4
|
-
* Four copies of this had accumulated (`autoDetail`/`autoTable`, `autoForm`,
|
|
5
|
-
* `autoComparison`, and now the schema converter), three of them byte-identical.
|
|
6
|
-
* They are one function with one optional extra rule, so they live here.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* `firstName` / `first_name` / `first-name` → `First name`.
|
|
10
|
-
*
|
|
11
|
-
* Only the first word is capitalized: these are labels in a sentence-case UI,
|
|
12
|
-
* not headings.
|
|
13
|
-
*/
|
|
1
|
+
/** `firstName` / `first_name` / `first-name` → `First name`: sentence case, acronyms (`userID` → `User ID`) kept whole. */
|
|
14
2
|
export declare function humanizeKey(key: string): string;
|
|
15
|
-
/**
|
|
16
|
-
* {@link humanizeKey} plus the `id` → `ID` rule, for table headers and detail
|
|
17
|
-
* rows where `User Id` reads as a typo.
|
|
18
|
-
*/
|
|
3
|
+
/** {@link humanizeKey} plus `id` → `ID`, for table headers and detail rows. */
|
|
19
4
|
export declare function humanizeColumnKey(key: string): string;
|
|
20
5
|
//# sourceMappingURL=humanize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"humanize.d.ts","sourceRoot":"","sources":["../../src/core/humanize.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"humanize.d.ts","sourceRoot":"","sources":["../../src/core/humanize.ts"],"names":[],"mappings":"AAAA,2HAA2H;AAC3H,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAS/C;AAED,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAErD"}
|
package/dist/core/humanize.js
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Key humanization — turn a data key into a label a person reads.
|
|
3
|
-
*
|
|
4
|
-
* Four copies of this had accumulated (`autoDetail`/`autoTable`, `autoForm`,
|
|
5
|
-
* `autoComparison`, and now the schema converter), three of them byte-identical.
|
|
6
|
-
* They are one function with one optional extra rule, so they live here.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* `firstName` / `first_name` / `first-name` → `First name`.
|
|
10
|
-
*
|
|
11
|
-
* Only the first word is capitalized: these are labels in a sentence-case UI,
|
|
12
|
-
* not headings.
|
|
13
|
-
*/
|
|
1
|
+
/** `firstName` / `first_name` / `first-name` → `First name`: sentence case, acronyms (`userID` → `User ID`) kept whole. */
|
|
14
2
|
export function humanizeKey(key) {
|
|
15
3
|
return key
|
|
16
|
-
.replace(/([A-Z])/g, ' $
|
|
17
|
-
.replace(/[
|
|
18
|
-
.
|
|
4
|
+
.replace(/([a-z\d])([A-Z])/g, '$1 $2')
|
|
5
|
+
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')
|
|
6
|
+
.split(/[\s_-]+/)
|
|
7
|
+
.filter(word => word !== '')
|
|
8
|
+
.map(word => (/^[A-Z\d]{2,}$/.test(word) ? word : word.toLowerCase()))
|
|
9
|
+
.join(' ')
|
|
19
10
|
.replace(/^\w/, c => c.toUpperCase());
|
|
20
11
|
}
|
|
21
|
-
/**
|
|
22
|
-
* {@link humanizeKey} plus the `id` → `ID` rule, for table headers and detail
|
|
23
|
-
* rows where `User Id` reads as a typo.
|
|
24
|
-
*/
|
|
12
|
+
/** {@link humanizeKey} plus `id` → `ID`, for table headers and detail rows. */
|
|
25
13
|
export function humanizeColumnKey(key) {
|
|
26
14
|
return humanizeKey(key).replace(/\bid\b/gi, 'ID');
|
|
27
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"humanize.js","sourceRoot":"","sources":["../../src/core/humanize.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"humanize.js","sourceRoot":"","sources":["../../src/core/humanize.ts"],"names":[],"mappings":"AAAA,2HAA2H;AAC3H,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,OAAO,GAAG;SACP,OAAO,CAAC,mBAAmB,EAAE,OAAO,CAAC;SACrC,OAAO,CAAC,uBAAuB,EAAE,OAAO,CAAC;SACzC,KAAK,CAAC,SAAS,CAAC;SAChB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC;SAC3B,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;SACrE,IAAI,CAAC,GAAG,CAAC;SACT,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA;AACzC,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AACnD,CAAC"}
|
package/dist/core/logger.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Zero-dependency by design (prefab's renderer bundle ships no runtime deps),
|
|
5
|
-
* but API-compatible with the org-wide `@maxhealth.tech/utils` `createLogger`
|
|
6
|
-
* so call sites read the same everywhere and could later swap to the shared
|
|
7
|
-
* package without churn.
|
|
8
|
-
*
|
|
9
|
-
* Adds a runtime level (the utils logger gates on NODE_ENV, which is unreliable
|
|
10
|
-
* in a browser bundle) so an embedding host can raise or mute prefab's output:
|
|
2
|
+
* The one sink for prefab's console output, with a runtime level a host can raise or mute:
|
|
11
3
|
*
|
|
12
4
|
* ```ts
|
|
13
5
|
* import { setLogLevel } from '@maxhealth.tech/prefab'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAQrE,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAEjD;AAED,wBAAgB,WAAW,IAAI,QAAQ,CAEtC;AAID,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAChD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAC/C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAC/C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;CACjD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAanD;AAED,8CAA8C;AAC9C,eAAO,MAAM,GAAG,EAAE,MAAuB,CAAA"}
|
package/dist/core/logger.js
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Zero-dependency by design (prefab's renderer bundle ships no runtime deps),
|
|
5
|
-
* but API-compatible with the org-wide `@maxhealth.tech/utils` `createLogger`
|
|
6
|
-
* so call sites read the same everywhere and could later swap to the shared
|
|
7
|
-
* package without churn.
|
|
8
|
-
*
|
|
9
|
-
* Adds a runtime level (the utils logger gates on NODE_ENV, which is unreliable
|
|
10
|
-
* in a browser bundle) so an embedding host can raise or mute prefab's output:
|
|
2
|
+
* The one sink for prefab's console output, with a runtime level a host can raise or mute:
|
|
11
3
|
*
|
|
12
4
|
* ```ts
|
|
13
5
|
* import { setLogLevel } from '@maxhealth.tech/prefab'
|
package/dist/core/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,iFAAiF;AACjF,MAAM,IAAI,GAA6B,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAA;AAE1F,yFAAyF;AACzF,IAAI,YAAY,GAAa,MAAM,CAAA;AAEnC,MAAM,UAAU,WAAW,CAAC,KAAe;IACzC,YAAY,GAAG,KAAK,CAAA;AACtB,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,YAAY,CAAA;AACrB,CAAC;AAWD;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,WAAW,KAAK,GAAG,CAAC,CAAC,CAAC,UAAU,CAAA;IACvD,MAAM,IAAI,GAAG,CAAC,MAAc,EAAE,OAAe,EAAE,IAAe,EAAQ,EAAE;QACtE,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC;YAAE,OAAM;QAC7C,oFAAoF;QACpF,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,IAAI,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAA;IAClD,CAAC,CAAA;IACD,OAAO;QACL,KAAK,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC;QACzD,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;QACvD,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;QACvD,KAAK,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC;KAC1D,CAAA;AACH,CAAC;AAED,8CAA8C;AAC9C,MAAM,CAAC,MAAM,GAAG,GAAW,YAAY,EAAE,CAAA"}
|
package/dist/core/stringify.d.ts
CHANGED
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Component props, state entries and row cells are all typed `unknown` because
|
|
5
|
-
* they arrive from JSON. Passing those straight to `String()` renders every
|
|
6
|
-
* object as `[object Object]`, which blanks out table cells and chart labels
|
|
7
|
-
* and — worse — makes every distinct object collide when the result is used as
|
|
8
|
-
* a lookup key. Route those coercions through {@link stringifyValue} instead.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Coerce an arbitrary value to a string for display or identity comparison.
|
|
12
|
-
*
|
|
13
|
-
* - `null` / `undefined` → `''`
|
|
14
|
-
* - strings pass through verbatim, other primitives use `String()`
|
|
15
|
-
* - `Date` → ISO string (invalid dates → `''`)
|
|
16
|
-
* - arrays → members stringified and joined with `', '`
|
|
17
|
-
* - any other object → compact JSON (honouring `toJSON()`), never `[object Object]`
|
|
18
|
-
*
|
|
19
|
-
* The result is stable for a given value, so it is also safe to use as a map
|
|
20
|
-
* key or for equality checks between two loosely-typed values.
|
|
2
|
+
* A value as display text, never `[object Object]`: nullish → `''`, Date → ISO, arrays joined with `', '`,
|
|
3
|
+
* other objects as compact JSON. Loose by design, so `1` and `'1'` give the same string.
|
|
21
4
|
*/
|
|
22
5
|
export declare function stringifyValue(value: unknown): string;
|
|
23
6
|
//# sourceMappingURL=stringify.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringify.d.ts","sourceRoot":"","sources":["../../src/core/stringify.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"stringify.d.ts","sourceRoot":"","sources":["../../src/core/stringify.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAgBrD"}
|
package/dist/core/stringify.js
CHANGED
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Component props, state entries and row cells are all typed `unknown` because
|
|
5
|
-
* they arrive from JSON. Passing those straight to `String()` renders every
|
|
6
|
-
* object as `[object Object]`, which blanks out table cells and chart labels
|
|
7
|
-
* and — worse — makes every distinct object collide when the result is used as
|
|
8
|
-
* a lookup key. Route those coercions through {@link stringifyValue} instead.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Coerce an arbitrary value to a string for display or identity comparison.
|
|
12
|
-
*
|
|
13
|
-
* - `null` / `undefined` → `''`
|
|
14
|
-
* - strings pass through verbatim, other primitives use `String()`
|
|
15
|
-
* - `Date` → ISO string (invalid dates → `''`)
|
|
16
|
-
* - arrays → members stringified and joined with `', '`
|
|
17
|
-
* - any other object → compact JSON (honouring `toJSON()`), never `[object Object]`
|
|
18
|
-
*
|
|
19
|
-
* The result is stable for a given value, so it is also safe to use as a map
|
|
20
|
-
* key or for equality checks between two loosely-typed values.
|
|
2
|
+
* A value as display text, never `[object Object]`: nullish → `''`, Date → ISO, arrays joined with `', '`,
|
|
3
|
+
* other objects as compact JSON. Loose by design, so `1` and `'1'` give the same string.
|
|
21
4
|
*/
|
|
22
5
|
export function stringifyValue(value) {
|
|
23
6
|
if (value == null)
|
|
@@ -35,8 +18,7 @@ export function stringifyValue(value) {
|
|
|
35
18
|
if (Array.isArray(value))
|
|
36
19
|
return value.map(stringifyValue).join(', ');
|
|
37
20
|
try {
|
|
38
|
-
//
|
|
39
|
-
// undefined makes JSON.stringify return undefined too — hence the guard.
|
|
21
|
+
// JSON.stringify returns undefined when toJSON() does, despite its declared type.
|
|
40
22
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
41
23
|
return JSON.stringify(value) ?? '';
|
|
42
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringify.js","sourceRoot":"","sources":["../../src/core/stringify.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"stringify.js","sourceRoot":"","sources":["../../src/core/stringify.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,EAAE,CAAA;IAC5B,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC3C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;IAC9G,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,WAAW,IAAI,EAAE,CAAA;IAC7D,IAAI,OAAO,KAAK,KAAK,UAAU;QAAE,OAAO,KAAK,CAAC,IAAI,CAAA;IAClD,IAAI,KAAK,YAAY,IAAI;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAA;IAC1F,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrE,IAAI,CAAC;QACH,kFAAkF;QAClF,uEAAuE;QACvE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,mEAAmE;QACnE,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/core/validate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/core/validate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAMjD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,eAAe,EAAE,CAAA;CAC1B;AAWD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,OAAO,EACb,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC9B,gBAAgB,CA8ElB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,gBAAgB,CAEzE"}
|