yaml-flow 8.4.15 → 8.4.17
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/browser/asset-integrity.json +3 -3
- package/browser/board-livecards-client.js +1 -1
- package/browser/board-livecards-localstorage.js +6 -6
- package/cli/browser-api/board-live-cards-browser-adapter.d.ts +2 -2
- package/cli/browser-api/board-live-cards-browser-adapter.js +3 -3
- package/cli/browser-api/card-store-browser-api.js +1 -1
- package/cli/bundled/artifacts-store-cli.mjs +4 -4
- package/cli/bundled/batch-runner-cli.mjs +1 -1
- package/cli/bundled/board-live-cards-cli.mjs +20 -20
- package/cli/bundled/card-store-cli.mjs +78 -78
- package/cli/{execution-interface-DCFBy4L8.d.ts → execution-interface-BCIhu1gO.d.ts} +7 -0
- package/cli/{types-BbQ75HLf.d.ts → types-juH2nFpz.d.ts} +21 -1
- package/examples/board/demo-shell-with-server.html +2 -2
- package/examples/board/doc.html +2 -2
- package/examples/board-local/demo-shell-localstorage.html +3 -3
- package/lib/{artifacts-store-lib-WdoKNAF0.d.cts → artifacts-store-lib-CVgtQrNZ.d.cts} +1 -1
- package/lib/{artifacts-store-lib-CXgRA5J7.d.ts → artifacts-store-lib-D-k-E8Vy.d.ts} +1 -1
- package/lib/artifacts-store-public.d.cts +3 -3
- package/lib/artifacts-store-public.d.ts +3 -3
- package/lib/board-live-cards-node.cjs +14 -14
- package/lib/board-live-cards-node.d.cts +10 -10
- package/lib/board-live-cards-node.d.ts +10 -10
- package/lib/board-live-cards-node.js +14 -14
- package/lib/{board-live-cards-public-wbWRD1nO.d.cts → board-live-cards-public-B4RcYPC_.d.cts} +21 -1
- package/lib/{board-live-cards-public-C81ZEkF-.d.ts → board-live-cards-public-ydXuA4zh.d.ts} +21 -1
- package/lib/board-live-cards-public.cjs +2 -2
- package/lib/board-live-cards-public.d.cts +2 -2
- package/lib/board-live-cards-public.d.ts +2 -2
- package/lib/board-live-cards-public.js +2 -2
- package/lib/board-live-cards-server-runtime.cjs +3 -3
- package/lib/board-live-cards-server-runtime.d.cts +5 -5
- package/lib/board-live-cards-server-runtime.d.ts +5 -5
- package/lib/board-live-cards-server-runtime.js +3 -3
- package/lib/board-livegraph-runtime/index.cjs +1 -1
- package/lib/board-livegraph-runtime/index.d.cts +1 -1
- package/lib/board-livegraph-runtime/index.d.ts +1 -1
- package/lib/board-livegraph-runtime/index.js +1 -1
- package/lib/card-store-public.cjs +1 -1
- package/lib/card-store-public.d.cts +13 -2
- package/lib/card-store-public.d.ts +13 -2
- package/lib/card-store-public.js +1 -1
- package/lib/{chat-storage-lib-OX0Q_Ttf.d.cts → chat-storage-lib-B1wU27y3.d.cts} +1 -1
- package/lib/{chat-storage-lib-DGaKrjVe.d.ts → chat-storage-lib-DsF4kPon.d.ts} +1 -1
- package/lib/chat-store-public.d.cts +3 -3
- package/lib/chat-store-public.d.ts +3 -3
- package/lib/continuous-event-graph/index.cjs +2 -2
- package/lib/continuous-event-graph/index.d.cts +2 -2
- package/lib/continuous-event-graph/index.d.ts +2 -2
- package/lib/continuous-event-graph/index.js +2 -2
- package/lib/execution-refs.cjs +2 -2
- package/lib/execution-refs.js +2 -2
- package/lib/index.cjs +12 -12
- package/lib/index.d.cts +2 -2
- package/lib/index.d.ts +2 -2
- package/lib/index.js +12 -12
- package/lib/{live-cards-bridge-b25aAVvE.d.cts → live-cards-bridge-Bwi-lbBT.d.cts} +2 -0
- package/lib/{live-cards-bridge-DC_ZU0eS.d.ts → live-cards-bridge-YL6AWawT.d.ts} +2 -0
- package/lib/server-runtime/index.cjs +3 -3
- package/lib/server-runtime/index.d.cts +6 -6
- package/lib/server-runtime/index.d.ts +6 -6
- package/lib/server-runtime/index.js +3 -3
- package/lib/step-machine-public/index.cjs +3 -3
- package/lib/step-machine-public/index.d.cts +1 -1
- package/lib/step-machine-public/index.d.ts +1 -1
- package/lib/step-machine-public/index.js +3 -3
- package/lib/{storage-interface-B-7pDHwD.d.cts → storage-interface-B2WD9D5n.d.cts} +7 -0
- package/lib/{storage-interface-B-7pDHwD.d.ts → storage-interface-B2WD9D5n.d.ts} +7 -0
- package/lib/stores/index.d.cts +1 -1
- package/lib/stores/index.d.ts +1 -1
- package/lib/stores/kv.d.cts +1 -1
- package/lib/stores/kv.d.ts +1 -1
- package/lib/{types-DsKGXgeT.d.ts → types-1L1D33mr.d.ts} +4 -4
- package/lib/{types-U3Iu6jDR.d.cts → types-D501gMQt.d.cts} +4 -4
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"generatedAt": "2026-05-
|
|
2
|
+
"generatedAt": "2026-05-25T18:48:29.821Z",
|
|
3
3
|
"algorithm": "sha256",
|
|
4
4
|
"files": {
|
|
5
5
|
"browser/board-livecards-localstorage.js": {
|
|
6
|
-
"sha256": "sha256-
|
|
7
|
-
"bytes":
|
|
6
|
+
"sha256": "sha256-dSW3cXY7kodc92AjKo+VPDvysAwKETeuwZPlTPDgkOI=",
|
|
7
|
+
"bytes": 105448
|
|
8
8
|
},
|
|
9
9
|
"browser/live-cards.schema.json": {
|
|
10
10
|
"sha256": "sha256-F5nfqDzZ5L3p0lLTMxGt4YtMa2sVzdNPh8sbQ8OiXHE=",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var BoardLiveCardsClient=(function(exports){'use strict';function W(t){return t==="running"||t==="in-progress"?"loading":t==="failed"?"error":"fresh"}function pt(t,e){let r=e&&typeof e=="object"&&!Array.isArray(e)?e:{};return {schema_version:r.schema_version||"v1",card_id:typeof r.card_id=="string"?r.card_id:t,card_data:r.card_data&&typeof r.card_data=="object"&&!Array.isArray(r.card_data)?structuredClone(r.card_data):{},computed_values:r.computed_values&&typeof r.computed_values=="object"&&!Array.isArray(r.computed_values)?structuredClone(r.computed_values):{}}}function x(t,e){if(!t||typeof t!="object")throw new Error("payload must be an object");if(!e)throw new Error("cardId is required");let h=(Array.isArray(t.cardDefinitions)?t.cardDefinitions:[]).find(C=>C.id===e);if(!h)throw new Error(`cardDefinitions has no entry with id ${e}`);let n=t.statusSnapshot&&typeof t.statusSnapshot=="object"?t.statusSnapshot:{},o=t.cardRuntimeById&&typeof t.cardRuntimeById=="object"?t.cardRuntimeById:{},y=t.dataObjectsByToken&&typeof t.dataObjectsByToken=="object"?t.dataObjectsByToken:{},u=(Array.isArray(n.cards)?n.cards:[]).find(C=>C.name===e),f=structuredClone(h),i=pt(e,o[e]),a={...f.card_data&&typeof f.card_data=="object"&&!Array.isArray(f.card_data)?f.card_data:{},...i.card_data||{},status:W(u?.status),lastRun:u?.runtime?.last_transition_at??null};u?.error?.message&&(a.error=u.error.message);let p=u?{task_status:u.status??null,card_status:W(u.status),runtime:structuredClone(u.runtime??{}),error:u.error?structuredClone(u.error):null,blocked_by:Array.isArray(u.blocked_by)?structuredClone(u.blocked_by):[],requires_missing:Array.isArray(u.requires_missing)?structuredClone(u.requires_missing):[]}:{task_status:null,card_status:a.status??"fresh",runtime:{last_transition_at:a.lastRun??null},error:a.error?{message:a.error}:null,blocked_by:[],requires_missing:[]},k=Array.isArray(f.requires)?f.requires:[],c={};for(let[C,E]of Object.entries(y))c[C]=structuredClone(E);for(let C of k)Object.prototype.hasOwnProperty.call(c,C)||(c[C]=null);let d=(t.cardChatsByCardId&&typeof t.cardChatsByCardId=="object"?t.cardChatsByCardId:{})[e],S=d?{messages:Array.isArray(d.messages)?d.messages:[],receiving:!!d.receiving,processing:!!d.processing}:null;return {id:e,card:f,card_data:a,requires:c,computed_values:i.computed_values,runtime_state:p,card_chats:S}}function U(t){if(!t||typeof t!="object")throw new Error("payload must be an object");return (Array.isArray(t.cardDefinitions)?t.cardDefinitions:[]).map(r=>x(t,r.id))}function G(t){return JSON.parse(JSON.stringify(t))}function B(t,e){if(t===e)return t;try{if(JSON.stringify(t)===JSON.stringify(e))return t}catch{}return e}function _(t,e){if(t===e)return true;try{return JSON.stringify(t)===JSON.stringify(e)}catch{return false}}function gt(t){return t==="running"||t==="in-progress"?"loading":t==="failed"?"error":"fresh"}function q(t,e,r){let h=t,o=(h&&Array.isArray(h.cardDefinitions)?h.cardDefinitions:[]).map(u=>u.id),y=e&&e.modelsById||{},m={};for(let u of o){let f=r(t,u),i=y[u];if(!i){m[u]=f;continue}let g=f.card_chats!=null?B(i.card_chats,f.card_chats??null):i.card_chats??null,a={id:f.id,card:B(i.card,f.card),card_data:B(i.card_data,f.card_data),requires:B(i.requires,f.requires),computed_values:B(i.computed_values,f.computed_values),runtime_state:B(i.runtime_state,f.runtime_state),card_chats:g};m[u]=a.card===i.card&&a.card_data===i.card_data&&a.requires===i.requires&&a.computed_values===i.computed_values&&a.runtime_state===i.runtime_state&&a.card_chats===i.card_chats?i:a;}return {payload:t,cardIds:o,modelsById:m}}function H(t,e={}){if(!t)return t;let r=typeof e.includeCard=="function"?e.includeCard:(()=>true),h=typeof e.mapCard=="function"?e.mapCard:(u=>u),n=false,o=[],y={};for(let u of t.cardIds){let f=t.modelsById[u];if(!f){n=true;continue}if(!r(f,t)){n=true;continue}let i=h(f,t);if(!i||i.id!==u)throw new Error(`deriveBoardState: mapped card must preserve id "${u}"`);i!==f&&(n=true),o.push(u),y[u]=i;}let m=typeof e.mapPayload=="function"?e.mapPayload(t.payload,{sourceState:t,cardIds:o,modelsById:y}):t.payload;return m!==t.payload&&(n=true),!n&&o.length===t.cardIds.length?t:{payload:m,cardIds:o,modelsById:y}}function J(t,e,r,h){if(!t||!Array.isArray(e)||e.length===0)return t;let n=t.modelsById,o=t.cardIds,y=false,m=false,u={};for(let i of o){let g=n[i],a=g&&g.requires;if(a&&typeof a=="object")for(let p of Object.keys(a))(u[p]=u[p]||[]).push(i);}function f(){y||(n={...n},y=true);}for(let i of e)if(!(!i||!i.kind)){if(i.kind==="computed_values"){let g=i.cardId,a=n[g];if(!a)continue;let p=i.values||{};if(_(a.computed_values,p))continue;f(),n[g]={...a,computed_values:p},m=true;}else if(i.kind==="data_object"){let g=i.key,a=i.payload,p=u[g]||[];for(let k of p){let c=n[k];if(!c)continue;let w=c.requires||{};_(w[g],a)||(f(),n[k]={...c,requires:{...w,[g]:a}},m=true);}}else if(i.kind==="card_refreshed"){let g=i.cardId,a=null,p=n[g],k=i.card;if(p&&k&&typeof k=="object"&&!Array.isArray(k)){let c=k,w=c.card_data&&typeof c.card_data=="object"&&!Array.isArray(c.card_data)?c.card_data:p.card_data,d=c.requires&&typeof c.requires=="object"&&!Array.isArray(c.requires)?c.requires:p.requires,S=c.computed_values&&typeof c.computed_values=="object"&&!Array.isArray(c.computed_values)?c.computed_values:p.computed_values,C=c.runtime_state&&typeof c.runtime_state=="object"&&!Array.isArray(c.runtime_state)?c.runtime_state:p.runtime_state;a={...p,card:k,card_data:w,requires:d,computed_values:S,runtime_state:C};}if(!a)try{let c=h();c&&(a=r(c,g));}catch{}if(!a||p&&_(p.card,a.card)&&_(p.card_data,a.card_data)&&_(p.requires,a.requires)&&_(p.computed_values,a.computed_values)&&_(p.runtime_state,a.runtime_state))continue;f(),n[g]=a,o.includes(g)||(o=[...o,g]),m=true;}else if(i.kind==="card_chats"){let g=i.cardId,a=n[g];if(!a)continue;let p=Array.isArray(i.messages)?i.messages:a.card_chats?.messages??[],k=typeof i.receiving=="boolean"?i.receiving:a.card_chats?.receiving??false,c=typeof i.processing=="boolean"?i.processing:a.card_chats?.processing??false,w={messages:p,receiving:k,processing:c};if(_(a.card_chats,w))continue;f(),n[g]={...a,card_chats:w},m=true;}else if(i.kind==="chat_messages"){let g=i.cardId,a=n[g];if(!a)continue;let p=Array.isArray(i.messages)?i.messages:[],k=a.card_chats||{receiving:false,processing:false},c={messages:p,receiving:k.receiving,processing:!!k.processing};if(_(a.card_chats,c))continue;f(),n[g]={...a,card_chats:c},m=true;}else if(i.kind==="status"){let g=i.status?.cards??[];for(let a of g){let p=a?.name;if(!p||!n[p])continue;let k=n[p],c=gt(a.status),w={...k.card_data||{},status:c,lastRun:a.runtime?.last_transition_at??null,...a.error?.message?{error:a.error.message}:{}};a.error?.message||delete w.error;let d={task_status:a.status??null,card_status:c,runtime:a.runtime?G(a.runtime):{},error:a.error?G(a.error):null,blocked_by:Array.isArray(a.blocked_by)?G(a.blocked_by):[],requires_missing:Array.isArray(a.requires_missing)?G(a.requires_missing):[]};_(k.card_data,w)&&_(k.runtime_state,d)||(f(),n[p]={...k,card_data:w,runtime_state:d},m=true);}}}return m?{payload:t.payload,cardIds:o,modelsById:n}:t}function Ie(t,e="/api/boards"){let r=e.replace(/\/$/,""),h=encodeURIComponent(t||"default"),n=`${r}/${h}`;return {initBoard:`${n}/init-board`,stream:`${n}/sse`,patchCard:o=>`${n}/cards/${encodeURIComponent(o)}`,retriggerCard:o=>`${n}/cards/${encodeURIComponent(o)}/retrigger`,cardAction:o=>`${n}/cards/${encodeURIComponent(o)}/actions`,cardFile:o=>`${n}/cards/${encodeURIComponent(o)}/files`,cardChats:o=>`${n}/cards/${encodeURIComponent(o)}/chats`,chatSubscribeSse:o=>`${n}/cards/${encodeURIComponent(o)}/chats/subscribe-sse`,chatUnsubscribeSse:o=>`${n}/cards/${encodeURIComponent(o)}/chats/unsubscribe-sse`}}function Be(t="/api/board"){let e=t.replace(/\/$/,"");return {initBoard:`${e}/init-board`,stream:`${e}/sse`,patchCard:r=>`${e}/cards/${encodeURIComponent(r)}`,retriggerCard:r=>`${e}/cards/${encodeURIComponent(r)}/retrigger`,cardAction:r=>`${e}/cards/${encodeURIComponent(r)}/actions`,cardFile:r=>`${e}/cards/${encodeURIComponent(r)}/files`,cardChats:r=>`${e}/cards/${encodeURIComponent(r)}/chats`,chatSubscribeSse:r=>`${e}/cards/${encodeURIComponent(r)}/chats/subscribe-sse`,chatUnsubscribeSse:r=>`${e}/cards/${encodeURIComponent(r)}/chats/unsubscribe-sse`}}function ht(t){let e=t.getServerOrigin();if(!e||!t.boardId)return null;let r=t.boardPaths(t.boardId);return `${e}${r.initBoard.replace(/\/init-board$/,"")}`}async function Z(t){if(!t.file)return null;let e=t.boardPaths(t.boardId),r=t.inChat?`${e.cardFile(t.cardId)}?inChat=true`:e.cardFile(t.cardId),h=typeof t.file.name=="string"?t.file.name:"upload.bin",n=t.file.type||"application/octet-stream",o=await t.fetchServer(r,{method:"POST",headers:{"content-type":n,"x-file-name":encodeURIComponent(h)},body:t.file});if(!o.ok){let m=await o.text();throw new Error(`Upload failed for ${t.cardId} (${o.status})${m?": "+m:""}`)}return (await o.json())?.file??null}async function mt(t){let{actionType:e}=t;if(e!=="chat-send"&&e!=="file-upload")return t.payload||{};let r={...t.payload||{}},h=Array.isArray(r.files)?r.files:[];if(!h.length)return r.files=[],r;let n=[];for(let o of h){let y=await Z({...t,file:o,inChat:e==="chat-send"});y&&n.push(y);}return r.files=e==="chat-send"?[]:n,r}async function yt(t){let e=t.boardPaths(t.boardId),r=await t.fetchServer(e.patchCard(t.cardId),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(t.patch||{})});if(!r.ok)throw new Error(`PATCH failed for ${t.cardId} (${r.status})`)}async function kt(t){let e=t.boardPaths(t.boardId),r=await t.fetchServer(e.retriggerCard(t.cardId),{method:"POST"});if(!r.ok)throw new Error(`retrigger failed for ${t.cardId} (${r.status})`)}async function St(t){let e=t.boardPaths(t.boardId),r=await mt(t),h=await t.fetchServer(e.cardAction(t.cardId),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({actionType:t.actionType,payload:r})});if(!h.ok)throw new Error(`${t.actionType==="refresh"?"Refresh":"Action"} failed for ${t.cardId} (${h.status})`);return {payload:r}}function Oe(t,e=null){return q(t,e,x)}function Pe(t,e,r){return J(t,e,x,r)}function De(t,e){let r=new Set(e.map(String)),h=t.cardIds.filter(o=>r.has(o)),n={};for(let o of h)n[o]=t.modelsById[o];return {payload:t.payload,cardIds:h,modelsById:n}}function je(t,e){let r=e instanceof Set?e:new Set(e.map(String)),h=t.cardIds.filter(o=>!r.has(o)),n={};for(let o of h)n[o]=t.modelsById[o];return {payload:t.payload,cardIds:h,modelsById:n}}function vt(t){let e=t?.core,r=t?.engine??e?.engine;r&&typeof r.onServerSseEvent=="function"?r.onServerSseEvent():r&&typeof r.refreshOpenChatModal=="function"&&r.refreshOpenChatModal();}function bt(){let t=globalThis.LiveCard;if(!t)throw new Error("LiveCard global not loaded \u2014 include live-cards.js before this script");return t}function Ct(t){if(!t||typeof t!="object")throw new Error("options are required");let{fetchServer:e,boardPaths:r,getServerOrigin:h}=t;if(typeof e!="function")throw new Error("options.fetchServer is required");if(typeof r!="function")throw new Error("options.boardPaths is required");if(typeof h!="function")throw new Error("options.getServerOrigin is required");let n={current:null},o=new Set,y=null,m=null,u=null,f={},i={},g=globalThis.crypto&&typeof globalThis.crypto.randomUUID=="function"?globalThis.crypto.randomUUID():`lc-${Date.now()}-${Math.random().toString(36).slice(2)}`;function a(){for(let s of o)s(n.current);}function p(){return n.current?n.current.payload:null}function k(s){return n.current=s,a(),n.current}function c(){let s=m;if(!s)throw new Error("Board runtime session is not bound to a board yet");let l=u??r(s);return u=l,{boardId:s,paths:l}}function w(s){let l=q(s,n.current,x);return k(l),l}function d(s,l){let b=q(s,l??n.current,x);return k(b),b}function S(s){return k(s)}function C(s){if(!n.current)return n.current;let l=J(n.current,s,x,p);return k(l),l}async function E(s,l,b){let{boardId:R}=c();return Z({fetchServer:e,boardPaths:r,boardId:R,cardId:s,file:l,inChat:b?.inChat})}async function M(s,l,b){let{boardId:R}=c();return l==="chat-send"&&await A(s),St({fetchServer:e,boardPaths:r,boardId:R,cardId:s,actionType:l,payload:b})}function v(s,l){return i[s]=l,l.finally(()=>{i[s]===l&&delete i[s];})}async function A(s){let l=i[s];if(l){await l;return}f[s]||await K(s);}async function $(s,l){let{boardId:b}=c();await yt({fetchServer:e,boardPaths:r,boardId:b,cardId:s,patch:l});}async function tt(s){let{boardId:l}=c();await kt({fetchServer:e,boardPaths:r,boardId:l,cardId:s});}async function K(s){let{paths:l}=c(),b=i[s];if(b){await b;return}if(f[s])return;f[s]=true;let R=(async()=>{await e(l.chatSubscribeSse(s),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({clientId:g})});})().catch(()=>{delete f[s];});await v(s,R);}async function et(s){let{paths:l}=c(),b=i[s];if(b)try{await b;}catch{}delete f[s];try{await e(l.chatUnsubscribeSse(s),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({clientId:g})});}catch{}}function rt(s){Object.keys(f).forEach(l=>{e(s.chatSubscribeSse(l),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({clientId:g})}).catch(()=>{});});}function V(s){let l=s;l?.kind==="notification-batch"&&Array.isArray(l.notifications)?C(l.notifications):l?.cardDefinitions&&w(l);}function nt(s){return m=String(s.boardId||"default"),u=r(m),s.state!==void 0?S(s.state??null):s.payload?d(s.payload,n.current):n.current}function st(s){return V(s),n.current}function F(){y&&(y.close(),y=null);}async function at(s={}){let l=String(s.boardId||m||"default");m=l;let b=r(l);if(u=b,s.initialState!==void 0?S(s.initialState??null):s.initialPayload!==void 0&&d(s.initialPayload,n.current),s.skipInitBoard!==true){let O=typeof s.taskExecutorPath=="string"?s.taskExecutorPath.trim():"",P=O?`${b.initBoard}?taskExecutorPath=${encodeURIComponent(O)}`:b.initBoard,T=await e(P);if(!T.ok)throw new Error(`Server init-board failed (${T.status}).`)}let R=h();if(!R)throw new Error("Server origin not resolved before SSE start");F();let I=!n.current,dt=`${R}${b.stream}${b.stream.includes("?")?"&":"?"}clientId=${encodeURIComponent(g)}`,X=await new Promise((O,P)=>{let T=new EventSource(dt);y=T;let D=false,j=I?setTimeout(()=>{D||P(new Error("SSE initial payload timeout (15s)"));},15e3):null;T.onopen=()=>{rt(b),I||O(n.current?.payload??null);},T.onmessage=ct=>{try{let L=JSON.parse(ct.data||"{}");V(L),!D&&I&&(L?.cardDefinitions||U(L))&&(D=!0,j&&clearTimeout(j),O(L));}catch{if(!I)return}},T.onerror=()=>{I&&!D&&(j&&clearTimeout(j),P(new Error("SSE connection failed during bootstrap")));};});if(I){if(!U(X))throw new Error("SSE payload missing published runtime artifacts");w(X);}return n.current}function ot(s){return o.add(s),s(n.current),()=>{o.delete(s);}}function it(){F(),Object.keys(f).forEach(s=>delete f[s]),u=null,m=null,o.clear(),n.current=null;}return {bootstrap:at,attachProvidedState:nt,applyServerUpdate:st,seedStateFromPayload:d,seedState:S,applyNotificationBatch:C,replacePayload:w,subscribe:ot,closeSse:F,isConnected:()=>y!=null,getState:()=>n.current,getPayload:p,getBoardId:()=>m,getClientId:()=>g,getSseClientId:()=>g,patchCardState:$,retriggerCard:tt,dispatchCardAction:M,uploadCardFile:E,subscribeCardChats:K,unsubscribeCardChats:et,dispose:it}}function Q(t){if(!t||typeof t!="object")throw new Error("options are required");if(!t.session)throw new Error("options.session is required");let{session:e,...r}=t,h=t.session&&"canvas"in t&&typeof t.canvas=="object"?t.canvas:{height:"72vh",overflow:"auto"},n=e.getState()?H(e.getState(),r):null,o=null,y=String(t.initialMode||"board"),m=new Set;function u(){for(let d of m)d(n);}function f(d){n=d?H(d,r):null,u(),o&&n&&(o.setState(()=>n),vt(o));}let i=e.subscribe(d=>{f(d);});function g(d){if(!n)throw new Error("Derived board runtime has no state to mount");let S=d?.rootElement;if(!S)throw new Error("mountBoard requires params.rootElement");y=String(d?.mode||y||"board");let C=r.boardPaths&&r.getServerOrigin&&e.getBoardId()?ht({boardPaths:r.boardPaths,getServerOrigin:r.getServerOrigin,boardId:e.getBoardId()}):null,E=bt(),M=E.init({resolve:v=>n?.modelsById[v],chartLib:globalThis.Chart??null,markdown:globalThis.marked?v=>globalThis.marked.parse(v):null,sanitize:globalThis.DOMPurify?v=>globalThis.DOMPurify.sanitize(v):null,onPatchState:(v,A)=>e.patchCardState(v,A),onRefresh:v=>e.retriggerCard(v),onAction:(v,A,$)=>e.dispatchCardAction(v,A,$).then(()=>{}),startReceivingChats:v=>{e.subscribeCardChats(v);},stopReceivingChats:v=>{e.unsubscribeCardChats(v);},fileUrlBase:C||void 0});return S.innerHTML="",o=E.Board(M,S,{initialState:n,getNodeIds:v=>v.cardIds,selectNode:(v,A)=>v.modelsById[A],mode:y,canvas:h}),o}function a(d){return m.add(d),d(n),()=>{m.delete(d);}}function p(d){y=String(d||"board");let S=o&&o.core;S&&typeof S.setMode=="function"&&S.setMode(y);}function k(){if(!o)return;y="canvas";let d=o.core;d&&typeof d.setMode=="function"&&d.setMode("canvas"),d&&typeof d.autoLayout=="function"&&d.autoLayout();}function c(d){let S=o&&o.core;S&&typeof S.setDevMode=="function"&&S.setDevMode(!!d);}function w(){i(),m.clear(),o=null;}return {mountBoard:g,subscribe:a,getState:()=>n,getFullState:()=>e.getState(),getBoardId:()=>e.getBoardId(),getClientId:()=>e.getClientId(),getSseClientId:()=>e.getSseClientId(),patchCardState:(d,S)=>e.patchCardState(d,S),retriggerCard:d=>e.retriggerCard(d),dispatchCardAction:(d,S,C)=>e.dispatchCardAction(d,S,C),uploadCardFile:(d,S,C)=>e.uploadCardFile(d,S,C),subscribeCardChats:d=>e.subscribeCardChats(d),unsubscribeCardChats:d=>e.unsubscribeCardChats(d),setMode:p,autoLayout:k,setDevMode:c,getCurrentMode:()=>y,dispose:w}}function Le(t){let e=Ct(t),r=Q({session:e,boardPaths:t.boardPaths,getServerOrigin:t.getServerOrigin});async function h(n){let o=String(n?.boardId||"default");return await e.bootstrap({boardId:o,taskExecutorPath:n?.taskExecutorPath}),r.mountBoard({rootElement:n.rootElement,mode:n.mode})}return {bootstrapBoard:h,dispose:()=>{r.dispose(),e.dispose();},setMode:n=>r.setMode(n),autoLayout:()=>r.autoLayout(),setDevMode:n=>r.setDevMode(n),getCurrentMode:()=>r.getCurrentMode(),getState:()=>e.getState(),getRuntimeSession:()=>e,createDerivedRuntime:(n={})=>Q({session:e,...n})}}exports.applyBoardNotifications=Pe;exports.applyNotification=J;exports.buildBoardState=q;exports.buildFileUrlBase=ht;exports.createBoardRuntimeClient=Le;exports.createBoardRuntimeSession=Ct;exports.createDerivedBoardRuntime=Q;exports.defaultBoardPaths=Ie;exports.deriveBoardState=H;exports.dispatchCardAction=St;exports.patchCardState=yt;exports.pickBoardState=De;exports.prepareActionPayload=mt;exports.retriggerCard=kt;exports.selectAllLiveCardModels=U;exports.selectLiveCardModel=x;exports.serverPayloadToBoardState=Oe;exports.singleBoardPaths=Be;exports.subtractBoardState=je;exports.uploadCardFile=Z;return exports;})({});//# sourceMappingURL=board-livecards-client.js.map
|
|
1
|
+
var BoardLiveCardsClient=(function(exports){'use strict';function W(t){return t==="running"||t==="in-progress"?"loading":t==="failed"?"error":"fresh"}function pt(t,e){let r=e&&typeof e=="object"&&!Array.isArray(e)?e:{};return {schema_version:r.schema_version||"v1",card_id:typeof r.card_id=="string"?r.card_id:t,card_data:r.card_data&&typeof r.card_data=="object"&&!Array.isArray(r.card_data)?structuredClone(r.card_data):{},computed_values:r.computed_values&&typeof r.computed_values=="object"&&!Array.isArray(r.computed_values)?structuredClone(r.computed_values):{}}}function E(t,e){if(!t||typeof t!="object")throw new Error("payload must be an object");if(!e)throw new Error("cardId is required");let h=(Array.isArray(t.cardDefinitions)?t.cardDefinitions:[]).find(C=>C.id===e);if(!h)throw new Error(`cardDefinitions has no entry with id ${e}`);let n=t.statusSnapshot&&typeof t.statusSnapshot=="object"?t.statusSnapshot:{},o=t.cardRuntimeById&&typeof t.cardRuntimeById=="object"?t.cardRuntimeById:{},y=t.dataObjectsByToken&&typeof t.dataObjectsByToken=="object"?t.dataObjectsByToken:{},u=(Array.isArray(n.cards)?n.cards:[]).find(C=>C.name===e),l=structuredClone(h),i=pt(e,o[e]),s={...l.card_data&&typeof l.card_data=="object"&&!Array.isArray(l.card_data)?l.card_data:{},...i.card_data||{},status:W(u?.status),lastRun:u?.runtime?.last_transition_at??null};u?.error?.message&&(s.error=u.error.message);let g=u?{task_status:u.status??null,card_status:W(u.status),runtime:structuredClone(u.runtime??{}),error:u.error?structuredClone(u.error):null,blocked_by:Array.isArray(u.blocked_by)?structuredClone(u.blocked_by):[],requires_missing:Array.isArray(u.requires_missing)?structuredClone(u.requires_missing):[]}:{task_status:null,card_status:s.status??"fresh",runtime:{last_transition_at:s.lastRun??null},error:s.error?{message:s.error}:null,blocked_by:[],requires_missing:[]},k=Array.isArray(l.requires)?l.requires:[],c={};for(let[C,x]of Object.entries(y))c[C]=structuredClone(x);for(let C of k)Object.prototype.hasOwnProperty.call(c,C)||(c[C]=null);let d=(t.cardChatsByCardId&&typeof t.cardChatsByCardId=="object"?t.cardChatsByCardId:{})[e],S=d?{messages:Array.isArray(d.messages)?d.messages:[],receiving:!!d.receiving,processing:!!d.processing}:null;return {id:e,card:l,card_data:s,requires:c,computed_values:i.computed_values,runtime_state:g,card_chats:S}}function U(t){if(!t||typeof t!="object")throw new Error("payload must be an object");return (Array.isArray(t.cardDefinitions)?t.cardDefinitions:[]).map(r=>E(t,r.id))}function G(t){return JSON.parse(JSON.stringify(t))}function B(t,e){if(t===e)return t;try{if(JSON.stringify(t)===JSON.stringify(e))return t}catch{}return e}function _(t,e){if(t===e)return true;try{return JSON.stringify(t)===JSON.stringify(e)}catch{return false}}function gt(t){return t==="running"||t==="in-progress"?"loading":t==="failed"?"error":"fresh"}function q(t,e,r){let h=t,o=(h&&Array.isArray(h.cardDefinitions)?h.cardDefinitions:[]).map(u=>u.id),y=e&&e.modelsById||{},m={};for(let u of o){let l=r(t,u),i=y[u];if(!i){m[u]=l;continue}let p=l.card_chats!=null?B(i.card_chats,l.card_chats??null):i.card_chats??null,s={id:l.id,card:B(i.card,l.card),card_data:B(i.card_data,l.card_data),requires:B(i.requires,l.requires),computed_values:B(i.computed_values,l.computed_values),runtime_state:B(i.runtime_state,l.runtime_state),card_chats:p};m[u]=s.card===i.card&&s.card_data===i.card_data&&s.requires===i.requires&&s.computed_values===i.computed_values&&s.runtime_state===i.runtime_state&&s.card_chats===i.card_chats?i:s;}return {payload:t,cardIds:o,modelsById:m}}function H(t,e={}){if(!t)return t;let r=typeof e.includeCard=="function"?e.includeCard:(()=>true),h=typeof e.mapCard=="function"?e.mapCard:(u=>u),n=false,o=[],y={};for(let u of t.cardIds){let l=t.modelsById[u];if(!l){n=true;continue}if(!r(l,t)){n=true;continue}let i=h(l,t);if(!i||i.id!==u)throw new Error(`deriveBoardState: mapped card must preserve id "${u}"`);i!==l&&(n=true),o.push(u),y[u]=i;}let m=typeof e.mapPayload=="function"?e.mapPayload(t.payload,{sourceState:t,cardIds:o,modelsById:y}):t.payload;return m!==t.payload&&(n=true),!n&&o.length===t.cardIds.length?t:{payload:m,cardIds:o,modelsById:y}}function J(t,e,r,h){if(!t||!Array.isArray(e)||e.length===0)return t;let n=t.modelsById,o=t.cardIds,y=false,m=false,u={};for(let i of o){let p=n[i],s=p&&p.requires;if(s&&typeof s=="object")for(let g of Object.keys(s))(u[g]=u[g]||[]).push(i);}function l(){y||(n={...n},y=true);}for(let i of e)if(!(!i||!i.kind)){if(i.kind==="computed_values"){let p=i.cardId,s=n[p];if(!s)continue;let g=i.values||{};if(_(s.computed_values,g))continue;l(),n[p]={...s,computed_values:g},m=true;}else if(i.kind==="data_object"){let p=i.key,s=i.payload,g=u[p]||[];for(let k of g){let c=n[k];if(!c)continue;let w=c.requires||{};_(w[p],s)||(l(),n[k]={...c,requires:{...w,[p]:s}},m=true);}}else if(i.kind==="card_refreshed"){let p=i.cardId,s=null,g=n[p],k=i.card;if(g&&k&&typeof k=="object"&&!Array.isArray(k)){let c=k,w=c.card_data&&typeof c.card_data=="object"&&!Array.isArray(c.card_data)?c.card_data:g.card_data,d=c.requires&&typeof c.requires=="object"&&!Array.isArray(c.requires)?c.requires:g.requires,S=c.computed_values&&typeof c.computed_values=="object"&&!Array.isArray(c.computed_values)?c.computed_values:g.computed_values,C=c.runtime_state&&typeof c.runtime_state=="object"&&!Array.isArray(c.runtime_state)?c.runtime_state:g.runtime_state;s={...g,card:k,card_data:w,requires:d,computed_values:S,runtime_state:C};}if(!s)try{let c=h();c&&(s=r(c,p));}catch{}if(!s||g&&_(g.card,s.card)&&_(g.card_data,s.card_data)&&_(g.requires,s.requires)&&_(g.computed_values,s.computed_values)&&_(g.runtime_state,s.runtime_state))continue;l(),n[p]=s,o.includes(p)||(o=[...o,p]),m=true;}else if(i.kind==="card_removed"){let p=i.cardId;if(!n[p])continue;l(),delete n[p],o=o.filter(s=>s!==p),m=true;}else if(i.kind==="card_chats"){let p=i.cardId,s=n[p];if(!s)continue;let g=Array.isArray(i.messages)?i.messages:s.card_chats?.messages??[],k=typeof i.receiving=="boolean"?i.receiving:s.card_chats?.receiving??false,c=typeof i.processing=="boolean"?i.processing:s.card_chats?.processing??false,w={messages:g,receiving:k,processing:c};if(_(s.card_chats,w))continue;l(),n[p]={...s,card_chats:w},m=true;}else if(i.kind==="chat_messages"){let p=i.cardId,s=n[p];if(!s)continue;let g=Array.isArray(i.messages)?i.messages:[],k=s.card_chats||{receiving:false,processing:false},c={messages:g,receiving:k.receiving,processing:!!k.processing};if(_(s.card_chats,c))continue;l(),n[p]={...s,card_chats:c},m=true;}else if(i.kind==="status"){let p=i.status?.cards??[];for(let s of p){let g=s?.name;if(!g||!n[g])continue;let k=n[g],c=gt(s.status),w={...k.card_data||{},status:c,lastRun:s.runtime?.last_transition_at??null,...s.error?.message?{error:s.error.message}:{}};s.error?.message||delete w.error;let d={task_status:s.status??null,card_status:c,runtime:s.runtime?G(s.runtime):{},error:s.error?G(s.error):null,blocked_by:Array.isArray(s.blocked_by)?G(s.blocked_by):[],requires_missing:Array.isArray(s.requires_missing)?G(s.requires_missing):[]};_(k.card_data,w)&&_(k.runtime_state,d)||(l(),n[g]={...k,card_data:w,runtime_state:d},m=true);}}}return m?{payload:t.payload,cardIds:o,modelsById:n}:t}function Ie(t,e="/api/boards"){let r=e.replace(/\/$/,""),h=encodeURIComponent(t||"default"),n=`${r}/${h}`;return {initBoard:`${n}/init-board`,stream:`${n}/sse`,patchCard:o=>`${n}/cards/${encodeURIComponent(o)}`,retriggerCard:o=>`${n}/cards/${encodeURIComponent(o)}/retrigger`,cardAction:o=>`${n}/cards/${encodeURIComponent(o)}/actions`,cardFile:o=>`${n}/cards/${encodeURIComponent(o)}/files`,cardChats:o=>`${n}/cards/${encodeURIComponent(o)}/chats`,chatSubscribeSse:o=>`${n}/cards/${encodeURIComponent(o)}/chats/subscribe-sse`,chatUnsubscribeSse:o=>`${n}/cards/${encodeURIComponent(o)}/chats/unsubscribe-sse`}}function Be(t="/api/board"){let e=t.replace(/\/$/,"");return {initBoard:`${e}/init-board`,stream:`${e}/sse`,patchCard:r=>`${e}/cards/${encodeURIComponent(r)}`,retriggerCard:r=>`${e}/cards/${encodeURIComponent(r)}/retrigger`,cardAction:r=>`${e}/cards/${encodeURIComponent(r)}/actions`,cardFile:r=>`${e}/cards/${encodeURIComponent(r)}/files`,cardChats:r=>`${e}/cards/${encodeURIComponent(r)}/chats`,chatSubscribeSse:r=>`${e}/cards/${encodeURIComponent(r)}/chats/subscribe-sse`,chatUnsubscribeSse:r=>`${e}/cards/${encodeURIComponent(r)}/chats/unsubscribe-sse`}}function ht(t){let e=t.getServerOrigin();if(!e||!t.boardId)return null;let r=t.boardPaths(t.boardId);return `${e}${r.initBoard.replace(/\/init-board$/,"")}`}async function Z(t){if(!t.file)return null;let e=t.boardPaths(t.boardId),r=t.inChat?`${e.cardFile(t.cardId)}?inChat=true`:e.cardFile(t.cardId),h=typeof t.file.name=="string"?t.file.name:"upload.bin",n=t.file.type||"application/octet-stream",o=await t.fetchServer(r,{method:"POST",headers:{"content-type":n,"x-file-name":encodeURIComponent(h)},body:t.file});if(!o.ok){let m=await o.text();throw new Error(`Upload failed for ${t.cardId} (${o.status})${m?": "+m:""}`)}return (await o.json())?.file??null}async function mt(t){let{actionType:e}=t;if(e!=="chat-send"&&e!=="file-upload")return t.payload||{};let r={...t.payload||{}},h=Array.isArray(r.files)?r.files:[];if(!h.length)return r.files=[],r;let n=[];for(let o of h){let y=await Z({...t,file:o,inChat:e==="chat-send"});y&&n.push(y);}return r.files=e==="chat-send"?[]:n,r}async function yt(t){let e=t.boardPaths(t.boardId),r=await t.fetchServer(e.patchCard(t.cardId),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(t.patch||{})});if(!r.ok)throw new Error(`PATCH failed for ${t.cardId} (${r.status})`)}async function kt(t){let e=t.boardPaths(t.boardId),r=await t.fetchServer(e.retriggerCard(t.cardId),{method:"POST"});if(!r.ok)throw new Error(`retrigger failed for ${t.cardId} (${r.status})`)}async function St(t){let e=t.boardPaths(t.boardId),r=await mt(t),h=await t.fetchServer(e.cardAction(t.cardId),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({actionType:t.actionType,payload:r})});if(!h.ok)throw new Error(`${t.actionType==="refresh"?"Refresh":"Action"} failed for ${t.cardId} (${h.status})`);return {payload:r}}function Oe(t,e=null){return q(t,e,E)}function Pe(t,e,r){return J(t,e,E,r)}function De(t,e){let r=new Set(e.map(String)),h=t.cardIds.filter(o=>r.has(o)),n={};for(let o of h)n[o]=t.modelsById[o];return {payload:t.payload,cardIds:h,modelsById:n}}function je(t,e){let r=e instanceof Set?e:new Set(e.map(String)),h=t.cardIds.filter(o=>!r.has(o)),n={};for(let o of h)n[o]=t.modelsById[o];return {payload:t.payload,cardIds:h,modelsById:n}}function vt(t){let e=t?.core,r=t?.engine??e?.engine;r&&typeof r.onServerSseEvent=="function"?r.onServerSseEvent():r&&typeof r.refreshOpenChatModal=="function"&&r.refreshOpenChatModal();}function bt(){let t=globalThis.LiveCard;if(!t)throw new Error("LiveCard global not loaded \u2014 include live-cards.js before this script");return t}function Ct(t){if(!t||typeof t!="object")throw new Error("options are required");let{fetchServer:e,boardPaths:r,getServerOrigin:h}=t;if(typeof e!="function")throw new Error("options.fetchServer is required");if(typeof r!="function")throw new Error("options.boardPaths is required");if(typeof h!="function")throw new Error("options.getServerOrigin is required");let n={current:null},o=new Set,y=null,m=null,u=null,l={},i={},p=globalThis.crypto&&typeof globalThis.crypto.randomUUID=="function"?globalThis.crypto.randomUUID():`lc-${Date.now()}-${Math.random().toString(36).slice(2)}`;function s(){for(let a of o)a(n.current);}function g(){return n.current?n.current.payload:null}function k(a){return n.current=a,s(),n.current}function c(){let a=m;if(!a)throw new Error("Board runtime session is not bound to a board yet");let f=u??r(a);return u=f,{boardId:a,paths:f}}function w(a){let f=q(a,n.current,E);return k(f),f}function d(a,f){let b=q(a,f??n.current,E);return k(b),b}function S(a){return k(a)}function C(a){if(!n.current)return n.current;let f=J(n.current,a,E,g);return k(f),f}async function x(a,f,b){let{boardId:R}=c();return Z({fetchServer:e,boardPaths:r,boardId:R,cardId:a,file:f,inChat:b?.inChat})}async function M(a,f,b){let{boardId:R}=c();return f==="chat-send"&&await A(a),St({fetchServer:e,boardPaths:r,boardId:R,cardId:a,actionType:f,payload:b})}function v(a,f){return i[a]=f,f.finally(()=>{i[a]===f&&delete i[a];})}async function A(a){let f=i[a];if(f){await f;return}l[a]||await K(a);}async function $(a,f){let{boardId:b}=c();await yt({fetchServer:e,boardPaths:r,boardId:b,cardId:a,patch:f});}async function tt(a){let{boardId:f}=c();await kt({fetchServer:e,boardPaths:r,boardId:f,cardId:a});}async function K(a){let{paths:f}=c(),b=i[a];if(b){await b;return}if(l[a])return;l[a]=true;let R=(async()=>{await e(f.chatSubscribeSse(a),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({clientId:p})});})().catch(()=>{delete l[a];});await v(a,R);}async function et(a){let{paths:f}=c(),b=i[a];if(b)try{await b;}catch{}delete l[a];try{await e(f.chatUnsubscribeSse(a),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({clientId:p})});}catch{}}function rt(a){Object.keys(l).forEach(f=>{e(a.chatSubscribeSse(f),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({clientId:p})}).catch(()=>{});});}function V(a){let f=a;f?.kind==="notification-batch"&&Array.isArray(f.notifications)?C(f.notifications):f?.cardDefinitions&&w(f);}function nt(a){return m=String(a.boardId||"default"),u=r(m),a.state!==void 0?S(a.state??null):a.payload?d(a.payload,n.current):n.current}function st(a){return V(a),n.current}function F(){y&&(y.close(),y=null);}async function at(a={}){let f=String(a.boardId||m||"default");m=f;let b=r(f);if(u=b,a.initialState!==void 0?S(a.initialState??null):a.initialPayload!==void 0&&d(a.initialPayload,n.current),a.skipInitBoard!==true){let O=typeof a.taskExecutorPath=="string"?a.taskExecutorPath.trim():"",P=O?`${b.initBoard}?taskExecutorPath=${encodeURIComponent(O)}`:b.initBoard,T=await e(P);if(!T.ok)throw new Error(`Server init-board failed (${T.status}).`)}let R=h();if(!R)throw new Error("Server origin not resolved before SSE start");F();let I=!n.current,dt=`${R}${b.stream}${b.stream.includes("?")?"&":"?"}clientId=${encodeURIComponent(p)}`,X=await new Promise((O,P)=>{let T=new EventSource(dt);y=T;let D=false,j=I?setTimeout(()=>{D||P(new Error("SSE initial payload timeout (15s)"));},15e3):null;T.onopen=()=>{rt(b),I||O(n.current?.payload??null);},T.onmessage=ct=>{try{let N=JSON.parse(ct.data||"{}");V(N),!D&&I&&(N?.cardDefinitions||U(N))&&(D=!0,j&&clearTimeout(j),O(N));}catch{if(!I)return}},T.onerror=()=>{I&&!D&&(j&&clearTimeout(j),P(new Error("SSE connection failed during bootstrap")));};});if(I){if(!U(X))throw new Error("SSE payload missing published runtime artifacts");w(X);}return n.current}function ot(a){return o.add(a),a(n.current),()=>{o.delete(a);}}function it(){F(),Object.keys(l).forEach(a=>delete l[a]),u=null,m=null,o.clear(),n.current=null;}return {bootstrap:at,attachProvidedState:nt,applyServerUpdate:st,seedStateFromPayload:d,seedState:S,applyNotificationBatch:C,replacePayload:w,subscribe:ot,closeSse:F,isConnected:()=>y!=null,getState:()=>n.current,getPayload:g,getBoardId:()=>m,getClientId:()=>p,getSseClientId:()=>p,patchCardState:$,retriggerCard:tt,dispatchCardAction:M,uploadCardFile:x,subscribeCardChats:K,unsubscribeCardChats:et,dispose:it}}function Q(t){if(!t||typeof t!="object")throw new Error("options are required");if(!t.session)throw new Error("options.session is required");let{session:e,...r}=t,h=t.session&&"canvas"in t&&typeof t.canvas=="object"?t.canvas:{height:"72vh",overflow:"auto"},n=e.getState()?H(e.getState(),r):null,o=null,y=String(t.initialMode||"board"),m=new Set;function u(){for(let d of m)d(n);}function l(d){n=d?H(d,r):null,u(),o&&n&&(o.setState(()=>n),vt(o));}let i=e.subscribe(d=>{l(d);});function p(d){if(!n)throw new Error("Derived board runtime has no state to mount");let S=d?.rootElement;if(!S)throw new Error("mountBoard requires params.rootElement");y=String(d?.mode||y||"board");let C=r.boardPaths&&r.getServerOrigin&&e.getBoardId()?ht({boardPaths:r.boardPaths,getServerOrigin:r.getServerOrigin,boardId:e.getBoardId()}):null,x=bt(),M=x.init({resolve:v=>n?.modelsById[v],chartLib:globalThis.Chart??null,markdown:globalThis.marked?v=>globalThis.marked.parse(v):null,sanitize:globalThis.DOMPurify?v=>globalThis.DOMPurify.sanitize(v):null,onPatchState:(v,A)=>e.patchCardState(v,A),onRefresh:v=>e.retriggerCard(v),onAction:(v,A,$)=>e.dispatchCardAction(v,A,$).then(()=>{}),startReceivingChats:v=>{e.subscribeCardChats(v);},stopReceivingChats:v=>{e.unsubscribeCardChats(v);},fileUrlBase:C||void 0});return S.innerHTML="",o=x.Board(M,S,{initialState:n,getNodeIds:v=>v.cardIds,selectNode:(v,A)=>v.modelsById[A],mode:y,canvas:h}),o}function s(d){return m.add(d),d(n),()=>{m.delete(d);}}function g(d){y=String(d||"board");let S=o&&o.core;S&&typeof S.setMode=="function"&&S.setMode(y);}function k(){if(!o)return;y="canvas";let d=o.core;d&&typeof d.setMode=="function"&&d.setMode("canvas"),d&&typeof d.autoLayout=="function"&&d.autoLayout();}function c(d){let S=o&&o.core;S&&typeof S.setDevMode=="function"&&S.setDevMode(!!d);}function w(){i(),m.clear(),o=null;}return {mountBoard:p,subscribe:s,getState:()=>n,getFullState:()=>e.getState(),getBoardId:()=>e.getBoardId(),getClientId:()=>e.getClientId(),getSseClientId:()=>e.getSseClientId(),patchCardState:(d,S)=>e.patchCardState(d,S),retriggerCard:d=>e.retriggerCard(d),dispatchCardAction:(d,S,C)=>e.dispatchCardAction(d,S,C),uploadCardFile:(d,S,C)=>e.uploadCardFile(d,S,C),subscribeCardChats:d=>e.subscribeCardChats(d),unsubscribeCardChats:d=>e.unsubscribeCardChats(d),setMode:g,autoLayout:k,setDevMode:c,getCurrentMode:()=>y,dispose:w}}function Ne(t){let e=Ct(t),r=Q({session:e,boardPaths:t.boardPaths,getServerOrigin:t.getServerOrigin});async function h(n){let o=String(n?.boardId||"default");return await e.bootstrap({boardId:o,taskExecutorPath:n?.taskExecutorPath}),r.mountBoard({rootElement:n.rootElement,mode:n.mode})}return {bootstrapBoard:h,dispose:()=>{r.dispose(),e.dispose();},setMode:n=>r.setMode(n),autoLayout:()=>r.autoLayout(),setDevMode:n=>r.setDevMode(n),getCurrentMode:()=>r.getCurrentMode(),getState:()=>e.getState(),getRuntimeSession:()=>e,createDerivedRuntime:(n={})=>Q({session:e,...n})}}exports.applyBoardNotifications=Pe;exports.applyNotification=J;exports.buildBoardState=q;exports.buildFileUrlBase=ht;exports.createBoardRuntimeClient=Ne;exports.createBoardRuntimeSession=Ct;exports.createDerivedBoardRuntime=Q;exports.defaultBoardPaths=Ie;exports.deriveBoardState=H;exports.dispatchCardAction=St;exports.patchCardState=yt;exports.pickBoardState=De;exports.prepareActionPayload=mt;exports.retriggerCard=kt;exports.selectAllLiveCardModels=U;exports.selectLiveCardModel=E;exports.serverPayloadToBoardState=Oe;exports.singleBoardPaths=Be;exports.subtractBoardState=je;exports.uploadCardFile=Z;return exports;})({});//# sourceMappingURL=board-livecards-client.js.map
|
|
2
2
|
//# sourceMappingURL=board-livecards-client.js.map
|