@opencx/widget-react-headless 5.7.2 → 5.7.3

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/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Gt=t=>{throw TypeError(t)};var Qt=(t,e,s)=>e.has(t)||Gt("Cannot "+s);var Z=(t,e,s)=>(Qt(t,e,"read from private field"),s?s.call(t):e.get(t)),de=(t,e,s)=>e.has(t)?Gt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),K=(t,e,s,r)=>(Qt(t,e,"write to private field"),r?r.call(t,s):e.set(t,s),s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react"),F=require("@opencx/widget-core"),Y=require("zod/v4"),Mr=require("zod/v4/core");require("react/jsx-runtime");const D=require("zod"),Is="5.7.2";function J(t){return p.useSyncExternalStore(t.subscribe,t.get,t.get)}function Rr({turnSources:t,liveItems:e,isStreaming:s,lastMessageIsFromUser:r}){var o;if(s||r)return null;const n=e.length>0?e:(o=t.at(-1))==null?void 0:o.items;return n?_r(n):null}function _r(t){for(let e=t.length-1;e>=0;e--){const s=t[e];if((s==null?void 0:s.kind)==="questions")return s.request}return null}const ws="vercel.ai.error",Pr=Symbol.for(ws);var G=class As extends Error{constructor({name:e,message:s,cause:r}){super(s),this[Pr]=!0,this.name=e,this.cause=r}static isInstance(e){return As.hasMarker(e,ws)}static hasMarker(e,s){const r=Symbol.for(s);return e!=null&&typeof e=="object"&&r in e&&typeof e[r]=="boolean"&&e[r]===!0}};const xs="AI_APICallError",Ts=`vercel.ai.error.${xs}`,Or=Symbol.for(Ts);var Ms=class extends G{constructor({message:t,url:e,requestBodyValues:s,statusCode:r,responseHeaders:n,responseBody:o,cause:l,isRetryable:u=r!=null&&(r===408||r===409||r===429||r>=500),data:v}){super({name:xs,message:t,cause:l}),this[Or]=!0,this.url=e,this.requestBodyValues=s,this.statusCode=r,this.responseHeaders=n,this.responseBody=o,this.isRetryable=u,this.data=v}static isInstance(t){return G.hasMarker(t,Ts)}};const Rs="AI_EmptyResponseBodyError",_s=`vercel.ai.error.${Rs}`,Nr=Symbol.for(_s);var ct=class extends G{constructor({message:t="Empty response body"}={}){super({name:Rs,message:t}),this[Nr]=!0}static isInstance(t){return G.hasMarker(t,_s)}};function Ps(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.toString():JSON.stringify(t)}const Os="AI_InvalidArgumentError",Ns=`vercel.ai.error.${Os}`,kr=Symbol.for(Ns);var Dr=class extends G{constructor({message:e,cause:s,argument:r}){super({name:Os,message:e,cause:s}),this[kr]=!0,this.argument=r}static isInstance(e){return G.hasMarker(e,Ns)}};const ks="AI_JSONParseError",Ds=`vercel.ai.error.${ks}`,Lr=Symbol.for(Ds);var Xt=class extends G{constructor({text:t,cause:e}){super({name:ks,message:`JSON parsing failed: Text: ${t}.
1
+ "use strict";var Gt=t=>{throw TypeError(t)};var Qt=(t,e,s)=>e.has(t)||Gt("Cannot "+s);var Z=(t,e,s)=>(Qt(t,e,"read from private field"),s?s.call(t):e.get(t)),de=(t,e,s)=>e.has(t)?Gt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),K=(t,e,s,r)=>(Qt(t,e,"write to private field"),r?r.call(t,s):e.set(t,s),s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react"),F=require("@opencx/widget-core"),Y=require("zod/v4"),Mr=require("zod/v4/core");require("react/jsx-runtime");const D=require("zod"),Is="5.7.3";function J(t){return p.useSyncExternalStore(t.subscribe,t.get,t.get)}function Rr({turnSources:t,liveItems:e,isStreaming:s,lastMessageIsFromUser:r}){var o;if(s||r)return null;const n=e.length>0?e:(o=t.at(-1))==null?void 0:o.items;return n?_r(n):null}function _r(t){for(let e=t.length-1;e>=0;e--){const s=t[e];if((s==null?void 0:s.kind)==="questions")return s.request}return null}const ws="vercel.ai.error",Pr=Symbol.for(ws);var G=class As extends Error{constructor({name:e,message:s,cause:r}){super(s),this[Pr]=!0,this.name=e,this.cause=r}static isInstance(e){return As.hasMarker(e,ws)}static hasMarker(e,s){const r=Symbol.for(s);return e!=null&&typeof e=="object"&&r in e&&typeof e[r]=="boolean"&&e[r]===!0}};const xs="AI_APICallError",Ts=`vercel.ai.error.${xs}`,Or=Symbol.for(Ts);var Ms=class extends G{constructor({message:t,url:e,requestBodyValues:s,statusCode:r,responseHeaders:n,responseBody:o,cause:l,isRetryable:u=r!=null&&(r===408||r===409||r===429||r>=500),data:v}){super({name:xs,message:t,cause:l}),this[Or]=!0,this.url=e,this.requestBodyValues=s,this.statusCode=r,this.responseHeaders=n,this.responseBody=o,this.isRetryable=u,this.data=v}static isInstance(t){return G.hasMarker(t,Ts)}};const Rs="AI_EmptyResponseBodyError",_s=`vercel.ai.error.${Rs}`,Nr=Symbol.for(_s);var ct=class extends G{constructor({message:t="Empty response body"}={}){super({name:Rs,message:t}),this[Nr]=!0}static isInstance(t){return G.hasMarker(t,_s)}};function Ps(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.toString():JSON.stringify(t)}const Os="AI_InvalidArgumentError",Ns=`vercel.ai.error.${Os}`,kr=Symbol.for(Ns);var Dr=class extends G{constructor({message:e,cause:s,argument:r}){super({name:Os,message:e,cause:s}),this[kr]=!0,this.argument=r}static isInstance(e){return G.hasMarker(e,Ns)}};const ks="AI_JSONParseError",Ds=`vercel.ai.error.${ks}`,Lr=Symbol.for(Ds);var Xt=class extends G{constructor({text:t,cause:e}){super({name:ks,message:`JSON parsing failed: Text: ${t}.
2
2
  Error message: ${Ps(e)}`,cause:e}),this[Lr]=!0,this.text=t}static isInstance(t){return G.hasMarker(t,Ds)}};const Ls="AI_TypeValidationError",js=`vercel.ai.error.${Ls}`,jr=Symbol.for(js);var ut=class Pt extends G{constructor({value:e,cause:s,context:r}){let n="Type validation failed";if(r!=null&&r.field&&(n+=` for ${r.field}`),r!=null&&r.entityName||r!=null&&r.entityId){n+=" (";const o=[];r.entityName&&o.push(r.entityName),r.entityId&&o.push(`id: "${r.entityId}"`),n+=o.join(", "),n+=")"}super({name:Ls,message:`${n}: Value: ${JSON.stringify(e)}.
3
3
  Error message: ${Ps(s)}`,cause:s}),this[jr]=!0,this.value=e,this.context=r}static isInstance(e){return G.hasMarker(e,js)}static wrap({value:e,cause:s,context:r}){var n,o,l;return Pt.isInstance(s)&&s.value===e&&((n=s.context)==null?void 0:n.field)===(r==null?void 0:r.field)&&((o=s.context)==null?void 0:o.entityName)===(r==null?void 0:r.entityName)&&((l=s.context)==null?void 0:l.entityId)===(r==null?void 0:r.entityId)?s:new Pt({value:e,cause:s,context:r})}};const $s="AI_UnsupportedFunctionalityError",Fs=`vercel.ai.error.${$s}`,$r=Symbol.for(Fs);var Fr=class extends G{constructor({functionality:t,message:e=`'${t}' functionality not supported.`}){super({name:$s,message:e}),this[$r]=!0,this.functionality=t}static isInstance(t){return G.hasMarker(t,Fs)}};class At extends Error{constructor(e,s){super(e),this.name="ParseError",this.type=s.type,this.field=s.field,this.value=s.value,this.line=s.line}}const es=10,Ur=13,Me=32;function xt(t){}function zr(t){if(typeof t=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");const{onEvent:e=xt,onError:s=xt,onRetry:r=xt,onComment:n,maxBufferSize:o}=t,l=[];let u=0,v=!0,h,i="",d=0,f,S=!1;function P(c){if(S)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(v&&(v=!1,c.charCodeAt(0)===239&&c.charCodeAt(1)===187&&c.charCodeAt(2)===191&&(c=c.slice(3))),l.length===0){const y=O(c);y!==""&&(l.push(y),u=y.length),R();return}if(c.indexOf(`
4
4
  `)===-1&&c.indexOf("\r")===-1){l.push(c),u+=c.length,R();return}l.push(c);const g=l.join("");l.length=0,u=0;const m=O(g);m!==""&&(l.push(m),u=m.length),R()}function R(){o!==void 0&&(u+i.length<=o||(S=!0,l.length=0,u=0,h=void 0,i="",d=0,f=void 0,s(new At(`Buffered data exceeded max buffer size of ${o} characters`,{type:"max-buffer-size-exceeded"}))))}function O(c){let g=0;if(c.indexOf("\r")===-1){let m=c.indexOf(`