conformtools 0.6.27 → 0.6.29

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.
Files changed (57) hide show
  1. package/dist/{account-RSL4PTDB.js → account-F4ODJBD2.js} +1 -1
  2. package/dist/{agent-hook-setup-IACTYSVL.js → agent-hook-setup-KBCGZNEE.js} +1 -1
  3. package/dist/{analysis-engine-BBOSGAB2.js → analysis-engine-LGB4OXG7.js} +1 -1
  4. package/dist/{bridge-42OMO43V.js → bridge-GLW34YZF.js} +1 -1
  5. package/dist/browser/timeline_core_bg.wasm +0 -0
  6. package/dist/{chunk-2DMNGWC2.js → chunk-7DH6DFYL.js} +1 -1
  7. package/dist/{chunk-XLRQNFJU.js → chunk-BZE7IP6U.js} +91 -91
  8. package/dist/{chunk-TGLH2JDW.js → chunk-FHCRWOI7.js} +1 -1
  9. package/dist/{chunk-NRURUPLU.js → chunk-GDPYFRSV.js} +1 -1
  10. package/dist/chunk-H3FD5KA2.js +7 -0
  11. package/dist/{chunk-BIX5ETBY.js → chunk-HHOFGYZ7.js} +1 -1
  12. package/dist/{chunk-YMRK5D3X.js → chunk-HZBGG7HI.js} +1 -1
  13. package/dist/{chunk-AR5BTVBM.js → chunk-KD7UGCLT.js} +1 -1
  14. package/dist/{chunk-2X2SFPWD.js → chunk-NTPDZOPF.js} +1 -1
  15. package/dist/chunk-QDL3XYOE.js +545 -0
  16. package/dist/chunk-QQBDHVUU.js +3 -0
  17. package/dist/chunk-RKJML7MH.js +10 -0
  18. package/dist/{chunk-T4B4Y5WQ.js → chunk-RVKNGIE3.js} +2 -2
  19. package/dist/{chunk-3KS3547B.js → chunk-SSFG7FNI.js} +1 -1
  20. package/dist/{chunk-UXEL636C.js → chunk-UXVABU6B.js} +1 -1
  21. package/dist/{chunk-6BL5HE4S.js → chunk-WJS6NM7T.js} +1 -1
  22. package/dist/{chunk-RL5XRG6O.js → chunk-WWE2FXAQ.js} +1 -1
  23. package/dist/{chunk-HNEKQMQG.js → chunk-YJREJ2MH.js} +1 -1
  24. package/dist/{chunk-JZCADV5C.js → chunk-ZE7BP4AE.js} +1 -1
  25. package/dist/{claude-setup-6RMV3QZM.js → claude-setup-FYWGYBTH.js} +1 -1
  26. package/dist/cli.js +2 -2
  27. package/dist/demo-engine-5HWLXPDJ.js +3 -0
  28. package/dist/{engine-I2NXY2OK.js → engine-LFB243Q6.js} +2 -2
  29. package/dist/{framing-PHFTZ4GL.js → framing-KHUFARKE.js} +1 -1
  30. package/dist/gfx-worker.js +1 -1
  31. package/dist/h264-QGSP23K2.js +3 -0
  32. package/dist/{h264-mxf-PKSTGNGH.js → h264-mxf-I4YANT5F.js} +1 -1
  33. package/dist/{host-relink-FHOEDE76.js → host-relink-L7I75SUH.js} +1 -1
  34. package/dist/{hosted-26GUD7IU.js → hosted-5Y5VX6X6.js} +1 -1
  35. package/dist/hosts-QMGBN2E6.js +3 -0
  36. package/dist/http.js +2 -2
  37. package/dist/{inspect-RT36GEVU.js → inspect-GP6B6UPD.js} +2 -2
  38. package/dist/{isobmff-65LRNCQH.js → isobmff-LAXAYC7P.js} +1 -1
  39. package/dist/{mc-video-2PCAX65A.js → mc-video-KQ7TP4DG.js} +1 -1
  40. package/dist/mcp.js +7 -7
  41. package/dist/{media-OXHZ3PGZ.js → media-SUPBJX64.js} +1 -1
  42. package/dist/{mxf-WFJNAX7D.js → mxf-2TQO552L.js} +1 -1
  43. package/dist/{ops-SH3IUU2Z.js → ops-CVKPID5Z.js} +1 -1
  44. package/dist/{probe-VB6JH6ZJ.js → probe-HUPB4H4G.js} +1 -1
  45. package/dist/{r3d-X2O5LUAB.js → r3d-EPSGIBPT.js} +1 -1
  46. package/dist/resolve-bridge.py +4 -1
  47. package/dist/{sequence-patch-OHYBBKKZ.js → sequence-patch-GXM3QSJC.js} +1 -1
  48. package/dist/{store-F2CTSR6E.js → store-K4W2LVRN.js} +1 -1
  49. package/dist/{timeline-AK6DUMWB.js → timeline-HTG23FEH.js} +1 -1
  50. package/package.json +5 -5
  51. package/dist/chunk-E4KQR4M3.js +0 -10
  52. package/dist/chunk-IDADYIY6.js +0 -7
  53. package/dist/chunk-M6SVZJAX.js +0 -537
  54. package/dist/chunk-ZPIY5DOU.js +0 -3
  55. package/dist/demo-engine-ITZ7VG6Q.js +0 -3
  56. package/dist/h264-TVMYQ7EB.js +0 -3
  57. package/dist/hosts-DXH4SQPZ.js +0 -3
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import"./chunk-PSANHDZM.js";function R(){let e=window.__CONFORM_ENGINE__;if(e?.base)return e;let t=new URLSearchParams(window.location.search),n=l=>{try{return sessionStorage.getItem(`conform.engine.${l}`)}catch{return null}},i=(l,g)=>{try{sessionStorage.setItem(`conform.engine.${l}`,g)}catch{}},o=t.get("engine"),s=t.get("token");return o?i("url",o):o=n("url"),s?i("token",s):s=n("token"),{base:o?/^\d+$/.test(o)?`http://127.0.0.1:${o}`:o.replace(/\/$/,""):"http://127.0.0.1:7791",token:s??""}}var d=typeof window>"u"?{base:"http://127.0.0.1:7791",token:""}:R(),w=(e=!0)=>({...e?{"content-type":"application/json"}:{},"x-conform-client":"app",...d.token?{authorization:`Bearer ${d.token}`}:{}}),f=typeof window<"u"&&new URLSearchParams(window.location.search).has("demo")?import("./demo-engine-ITZ7VG6Q.js").then(e=>e.answer):null,O=f!==null,v=class extends Error{constructor(n,i){super(i);this.code=n}};async function r(e,t,n,i=[],o={},s=0){if(f)return(await f)(e,t,n);let a;try{a=await fetch(`${d.base}${t}`,{method:e,headers:{...w(),...o},body:n===void 0?void 0:JSON.stringify(n),...s?{signal:AbortSignal.timeout(s)}:{}})}catch{throw new v("engine_down",`the conform.tools engine is not running at ${d.base}`)}let l=await a.json().catch(()=>({}));if((l?.code==="not_signed_in"||l?.structuredContent?.code==="not_signed_in")&&window.dispatchEvent(new Event(S)),!a.ok&&!("text"in l)&&!i.includes(a.status))throw new v(l.code??String(a.status),l.message??`HTTP ${a.status}`);return l}var S="conformtools:signed-out";async function x(e,t,n,i,o=0){if(f)return new Promise(()=>{});let s;try{s=await fetch(`${d.base}${e}`,{...t,headers:w(),signal:i})}catch{i?.aborted||n({type:"error",code:"engine_down",message:`the conform.tools engine is not running at ${d.base}`});return}if(!s.ok||!s.body){let b=await s.json().catch(()=>({}));n({type:"error",code:b.code??String(s.status),message:b.message??`HTTP ${s.status}`});return}let a=s.body.getReader(),l=new TextDecoder,g="";for(;;){let b,m=o?new Promise(u=>{b=setTimeout(()=>u(null),o)}):null,h=await(m?Promise.race([a.read(),m]):a.read());if(clearTimeout(b),!h){a.cancel().catch(()=>{});break}let{value:y,done:_}=h;if(_)break;g+=l.decode(y,{stream:!0});let p;for(;(p=g.indexOf(`
3
+ import"./chunk-PSANHDZM.js";function R(){let e=window.__CONFORM_ENGINE__;if(e?.base)return e;let t=new URLSearchParams(window.location.search),n=l=>{try{return sessionStorage.getItem(`conform.engine.${l}`)}catch{return null}},i=(l,u)=>{try{sessionStorage.setItem(`conform.engine.${l}`,u)}catch{}},o=t.get("engine"),s=t.get("token");return o?i("url",o):o=n("url"),s?i("token",s):s=n("token"),{base:o?/^\d+$/.test(o)?`http://127.0.0.1:${o}`:o.replace(/\/$/,""):"http://127.0.0.1:7791",token:s??""}}var d=typeof window>"u"?{base:"http://127.0.0.1:7791",token:""}:R(),w=(e=!0)=>({...e?{"content-type":"application/json"}:{},"x-conform-client":"app",...d.token?{authorization:`Bearer ${d.token}`}:{}}),b=typeof window<"u"&&new URLSearchParams(window.location.search).has("demo")?import("./demo-engine-5HWLXPDJ.js").then(e=>e.answer):null,O=b!==null,v=class extends Error{constructor(n,i){super(i);this.code=n}};async function r(e,t,n,i=[],o={},s=0){if(b)return(await b)(e,t,n);let a;try{a=await fetch(`${d.base}${t}`,{method:e,headers:{...w(),...o},body:n===void 0?void 0:JSON.stringify(n),...s?{signal:AbortSignal.timeout(s)}:{}})}catch{throw new v("engine_down",`the conform.tools engine is not running at ${d.base}`)}let l=await a.json().catch(()=>({}));if((l?.code==="not_signed_in"||l?.structuredContent?.code==="not_signed_in")&&window.dispatchEvent(new Event(S)),!a.ok&&!("text"in l)&&!i.includes(a.status))throw new v(l.code??String(a.status),l.message??`HTTP ${a.status}`);return l}var S="conformtools:signed-out";async function x(e,t,n,i,o=0){if(b)return new Promise(()=>{});let s;try{s=await fetch(`${d.base}${e}`,{...t,headers:w(),signal:i})}catch{i?.aborted||n({type:"error",code:"engine_down",message:`the conform.tools engine is not running at ${d.base}`});return}if(!s.ok||!s.body){let f=await s.json().catch(()=>({}));n({type:"error",code:f.code??String(s.status),message:f.message??`HTTP ${s.status}`});return}let a=s.body.getReader(),l=new TextDecoder,u="";for(;;){let f,m=o?new Promise(g=>{f=setTimeout(()=>g(null),o)}):null,h=await(m?Promise.race([a.read(),m]):a.read());if(clearTimeout(f),!h){a.cancel().catch(()=>{});break}let{value:y,done:_}=h;if(_)break;u+=l.decode(y,{stream:!0});let p;for(;(p=u.indexOf(`
4
4
 
5
- `))>=0;){let u=g.slice(0,p);g=g.slice(p+2),u.startsWith("data: ")&&n(JSON.parse(u.slice(6)))}}}var k=new Set,T=null;function j(){if(T)return;let e=T=new AbortController;(async()=>{for(;!e.signal.aborted;)await x("/app/events",{method:"GET"},t=>{for(let n of k)n(t)},e.signal,45e3).catch(()=>{}),e.signal.aborted||await new Promise(t=>setTimeout(t,2e3))})()}var E={base:d.base,health:()=>r("GET","/health"),verb:(e,t={})=>r("POST",`/verbs/${e}`,t),poll:(e,t={})=>r("POST",`/verbs/${e}`,t,[],{"x-conform-poll":"1"},2e4),job:e=>r("GET",`/jobs/${e}`),cancelJob:e=>r("DELETE",`/jobs/${e}`),front:e=>r("POST","/app/front",e),account:()=>r("GET","/app/account"),projects:()=>r("GET","/app/projects"),createProject:e=>r("POST","/app/projects",e),project:e=>r("GET",`/app/projects/${e}`),attachSession:(e,t)=>r("PUT",`/app/projects/${e}/sessions`,{session_id:t}),saveContext:(e,t,n)=>r("PUT",`/app/projects/${e}/context`,{text:t,base:n},[409]),frame:async(e,t,n,i,o,s,a)=>{let l=new URLSearchParams({f:String(t),w:String(n),...o?{timeline:o}:{},...s?{track:String(s)}:{},...a?{grade:"resolve",...a.host_timeline?{host_timeline:a.host_timeline}:{}}:{}});if(f)return null;let g=await fetch(`${d.base}/app/sessions/${e}/frame?${l}`,{headers:w(!1),signal:i}).catch(()=>null);if(!g?.ok)return null;if(g.headers.get("content-type")!=="application/x-conform-pixels")return createImageBitmap(await g.blob()).catch(()=>null);let b=new Uint8Array(await g.arrayBuffer()),m=new DataView(b.buffer),h=m.getUint32(0,!0),y=m.getUint32(4,!0),_=m.getUint32(8,!0)===1,p=new Uint8ClampedArray(b.buffer,12,h*y*4);for(let u=0;u<p.length;u+=4){if(_){let P=p[u];p[u]=p[u+2],p[u+2]=P}p[u+3]=255}return createImageBitmap(new ImageData(p,h,y)).catch(()=>null)},tools:()=>r("POST","/verbs/tool",{action:"list"}).then(e=>e.tools??[]),blocks:()=>r("POST","/verbs/tool",{action:"blocks"}).then(e=>e.blocks??[]),saveTool:e=>r("POST","/verbs/tool",{action:"save",spec:e},[422]),deleteTool:e=>r("POST","/verbs/tool",{action:"delete",id:e},[422]),toolLayout:()=>r("POST","/verbs/tool",{action:"layout"}).then(e=>e.layout),arrangeTools:e=>r("POST","/verbs/tool",{action:"arrange",layout:e}).then(t=>t.layout),hideTool:(e,t)=>r("POST","/verbs/tool",{action:t?"hide":"show_tool",id:e}).then(n=>n.layout),workspace:e=>r("POST","/verbs/tool",{action:"workspace",project_id:e}).then(t=>t.workspace),saveWorkspace:(e,t)=>r("POST","/verbs/tool",{action:"workspace_save",project_id:e,workspace:t},[422]),exportTools:(e,t)=>r("POST","/verbs/tool",{action:"export",ids:e,path:t},[422]),importTools:e=>r("POST","/verbs/tool",{action:"import",path:e},[422]),hostSetup:(e,t="status")=>r("POST","/verbs/host_setup",{host:e,action:t},[422]),convert:async(e,t)=>{let n=new URLSearchParams({name:e.fileName,out:t,targets:JSON.stringify(e.targets.map(({target:o,ext:s})=>({target:o,ext:s}))),sequences:JSON.stringify(e.sequences)});if(f)return{ok:!1,error:(await import("./demo-engine-ITZ7VG6Q.js")).DEMO_TEXT};let i=await fetch(`${d.base}/app/convert?${n}`,{method:"POST",headers:{...w(!1),"content-type":"application/octet-stream"},body:e.bytes});return await i.json().catch(()=>({ok:!1,error:`the engine said ${i.status}`}))},canonicalize:async(e,t=[],n=[])=>{let i=new URLSearchParams({name:e.name,sequences:JSON.stringify(t),previous:JSON.stringify(n)});if(f)throw new Error((await import("./demo-engine-ITZ7VG6Q.js")).DEMO_TEXT);let o=await fetch(`${d.base}/app/canonicalize?${i}`,{method:"POST",headers:{...w(!1),"content-type":"application/octet-stream"},body:await e.arrayBuffer()}),s=await o.json().catch(()=>({ok:!1,error:`the engine said ${o.status}`}));if(!s.ok)throw new Error(s.error??s.message??`the engine said ${o.status}`);return s},policy:()=>r("GET","/app/policy"),session:e=>r("GET",`/app/sessions/${e}`),onEvent:e=>(k.add(e),j(),()=>{k.delete(e),k.size||(T?.abort(),T=null)}),problem:(e,t)=>r("POST","/app/problem",{what:e,...t?{detail:t}:{}}),saveRunCsv:(e,t,n,i,o)=>r("POST","/verbs/tool_run",{action:"csv",project_id:e,path:t,id:n,table:i,...o?{session_id:o}:{}}),runs:(e,t)=>r("POST","/verbs/tool_run",{action:"list",project_id:e,...t?{id:t}:{}}).then(n=>n.runs??[])};async function $(e,t){if(f)throw Object.assign(new Error((await import("./demo-engine-ITZ7VG6Q.js")).DEMO_TEXT),{name:"NotFoundError"});let n=await fetch(`${d.base}/app/fs`,{method:"POST",headers:w(),body:JSON.stringify({op:e,...t})});if(e==="readFile"){if(!n.ok)throw Object.assign(new Error(`could not read ${String(t.path)}`),{name:"NotReadableError"});let o=await n.arrayBuffer();return{result:{byteLength:o.byteLength},bytes:o}}let i=await n.json().catch(()=>({ok:!1}));if(!i.ok)throw Object.assign(new Error(i.message??`the engine said ${n.status}`),{name:"NotFoundError"});return{result:i.result}}var c=()=>typeof window<"u"?window.__TAURI__:void 0,V={available:()=>!!c()?.core?.invoke,licenseStatus:()=>c().core.invoke("license_status"),fingerprint:()=>c().core.invoke("machine_fingerprint"),version:()=>c().app.getVersion(),installUpdate:()=>c().core.invoke("install_update"),float:(e,t,n,i)=>c().core.invoke("open_float",{path:e,title:t,width:n,height:i}),importLicense:async()=>{let e=await c().dialog.open({multiple:!1,filters:[{name:"conform.tools licence",extensions:["lic","json"]}]});return typeof e=="string"?c().core.invoke("import_license",{path:e}):null},pickFolder:async()=>{let e=await c().dialog.open({directory:!0,multiple:!1});return typeof e=="string"?e:null},pickFiles:async()=>{let e=await c().dialog.open({directory:!1,multiple:!0});return Array.isArray(e)?e:typeof e=="string"?[e]:[]},pickFile:async()=>{let e=await c().dialog.open({directory:!1,multiple:!1});return typeof e=="string"?e:null},saveFile:async e=>{try{let t=e.split(".").pop()??"json",n=await c().dialog.save({defaultPath:e,filters:[{name:t==="csv"?"Table":t==="html"?"Page":"Recipe",extensions:[t]}]});return typeof n=="string"?n:null}catch{let t=await c().dialog.open({directory:!0,multiple:!1});return typeof t=="string"?`${t.replace(/[\\/]$/,"")}/${e}`:null}}};export{v as EngineError,S as SIGNED_OUT,E as engine,$ as engineFs,O as isDemo,V as shell};
5
+ `))>=0;){let g=u.slice(0,p);u=u.slice(p+2),g.startsWith("data: ")&&n(JSON.parse(g.slice(6)))}}}var k=new Set,T=null;function j(){if(T)return;let e=T=new AbortController;(async()=>{for(;!e.signal.aborted;)await x("/app/events",{method:"GET"},t=>{for(let n of k)n(t)},e.signal,45e3).catch(()=>{}),e.signal.aborted||await new Promise(t=>setTimeout(t,2e3))})()}var E={base:d.base,health:()=>r("GET","/health"),verb:(e,t={})=>r("POST",`/verbs/${e}`,t),poll:(e,t={})=>r("POST",`/verbs/${e}`,t,[],{"x-conform-poll":"1"},2e4),job:e=>r("GET",`/jobs/${e}`),cancelJob:e=>r("DELETE",`/jobs/${e}`),front:e=>r("POST","/app/front",e),account:()=>r("GET","/app/account"),projects:()=>r("GET","/app/projects"),createProject:e=>r("POST","/app/projects",e),project:e=>r("GET",`/app/projects/${e}`),attachSession:(e,t)=>r("PUT",`/app/projects/${e}/sessions`,{session_id:t}),saveContext:(e,t,n)=>r("PUT",`/app/projects/${e}/context`,{text:t,base:n},[409]),frame:async(e,t,n,i,o,s,a)=>{let l=new URLSearchParams({f:String(t),w:String(n),...o?{timeline:o}:{},...s?{track:String(s)}:{},...a?{grade:"resolve",...a.host_timeline?{host_timeline:a.host_timeline}:{}}:{}});if(b)return null;let u=await fetch(`${d.base}/app/sessions/${e}/frame?${l}`,{headers:w(!1),signal:i}).catch(()=>null);if(!u?.ok)return null;if(u.headers.get("content-type")!=="application/x-conform-pixels")return createImageBitmap(await u.blob()).catch(()=>null);let f=new Uint8Array(await u.arrayBuffer()),m=new DataView(f.buffer),h=m.getUint32(0,!0),y=m.getUint32(4,!0),_=m.getUint32(8,!0)===1,p=new Uint8ClampedArray(f.buffer,12,h*y*4);for(let g=0;g<p.length;g+=4){if(_){let P=p[g];p[g]=p[g+2],p[g+2]=P}p[g+3]=255}return createImageBitmap(new ImageData(p,h,y)).catch(()=>null)},tools:()=>r("POST","/verbs/tool",{action:"list"}).then(e=>e.tools??[]),blocks:()=>r("POST","/verbs/tool",{action:"blocks"}).then(e=>e.blocks??[]),saveTool:e=>r("POST","/verbs/tool",{action:"save",spec:e},[422]),deleteTool:e=>r("POST","/verbs/tool",{action:"delete",id:e},[422]),toolLayout:()=>r("POST","/verbs/tool",{action:"layout"}).then(e=>e.layout),arrangeTools:e=>r("POST","/verbs/tool",{action:"arrange",layout:e}).then(t=>t.layout),hideTool:(e,t)=>r("POST","/verbs/tool",{action:t?"hide":"show_tool",id:e}).then(n=>n.layout),workspace:e=>r("POST","/verbs/tool",{action:"workspace",project_id:e}).then(t=>t.workspace),saveWorkspace:(e,t)=>r("POST","/verbs/tool",{action:"workspace_save",project_id:e,workspace:t},[422]),exportTools:(e,t)=>r("POST","/verbs/tool",{action:"export",ids:e,path:t},[422]),importTools:e=>r("POST","/verbs/tool",{action:"import",path:e},[422]),hostSetup:(e,t="status")=>r("POST","/verbs/host_setup",{host:e,action:t},[422]),convert:async(e,t)=>{let n=new URLSearchParams({name:e.fileName,out:t,targets:JSON.stringify(e.targets.map(({target:o,ext:s})=>({target:o,ext:s}))),sequences:JSON.stringify(e.sequences)});if(b)return{ok:!1,error:(await import("./demo-engine-5HWLXPDJ.js")).DEMO_TEXT};let i=await fetch(`${d.base}/app/convert?${n}`,{method:"POST",headers:{...w(!1),"content-type":"application/octet-stream"},body:e.bytes});return await i.json().catch(()=>({ok:!1,error:`the engine said ${i.status}`}))},canonicalize:async(e,t=[],n=[])=>{let i=new URLSearchParams({name:e.name,sequences:JSON.stringify(t),previous:JSON.stringify(n)});if(b)throw new Error((await import("./demo-engine-5HWLXPDJ.js")).DEMO_TEXT);let o=await fetch(`${d.base}/app/canonicalize?${i}`,{method:"POST",headers:{...w(!1),"content-type":"application/octet-stream"},body:await e.arrayBuffer()}),s=await o.json().catch(()=>({ok:!1,error:`the engine said ${o.status}`}));if(!s.ok)throw new Error(s.error??s.message??`the engine said ${o.status}`);return s},policy:()=>r("GET","/app/policy"),session:e=>r("GET",`/app/sessions/${e}`),onEvent:e=>(k.add(e),j(),()=>{k.delete(e),k.size||(T?.abort(),T=null)}),problem:(e,t)=>r("POST","/app/problem",{what:e,...t?{detail:t}:{}}),saveRunCsv:(e,t,n,i,o)=>r("POST","/verbs/tool_run",{action:"csv",project_id:e,path:t,id:n,table:i,...o?{session_id:o}:{}}),runs:(e,t)=>r("POST","/verbs/tool_run",{action:"list",project_id:e,...t?{id:t}:{}}).then(n=>n.runs??[])};async function $(e,t){if(b)throw Object.assign(new Error((await import("./demo-engine-5HWLXPDJ.js")).DEMO_TEXT),{name:"NotFoundError"});let n=await fetch(`${d.base}/app/fs`,{method:"POST",headers:w(),body:JSON.stringify({op:e,...t})});if(e==="readFile"){if(!n.ok)throw Object.assign(new Error(`could not read ${String(t.path)}`),{name:"NotReadableError"});let o=await n.arrayBuffer();return{result:{byteLength:o.byteLength},bytes:o}}let i=await n.json().catch(()=>({ok:!1}));if(!i.ok)throw Object.assign(new Error(i.message??`the engine said ${n.status}`),{name:"NotFoundError"});return{result:i.result}}var c=()=>typeof window<"u"?window.__TAURI__:void 0;function V(e){try{let t=new URL(e);return t.protocol==="conformtools:"&&(t.hostname||t.pathname.replace(/^\/+/,""))==="p2p"&&t.searchParams.get("from")||null}catch{return null}}var A={available:()=>!!c()?.core?.invoke,takeOpenUrl:()=>c().core.invoke("take_open_url"),licenseStatus:()=>c().core.invoke("license_status"),fingerprint:()=>c().core.invoke("machine_fingerprint"),version:()=>c().app.getVersion(),installUpdate:()=>c().core.invoke("install_update"),float:(e,t,n,i)=>c().core.invoke("open_float",{path:e,title:t,width:n,height:i}),importLicense:async()=>{let e=await c().dialog.open({multiple:!1,filters:[{name:"conform.tools licence",extensions:["lic","json"]}]});return typeof e=="string"?c().core.invoke("import_license",{path:e}):null},pickFolder:async()=>{let e=await c().dialog.open({directory:!0,multiple:!1});return typeof e=="string"?e:null},pickFiles:async()=>{let e=await c().dialog.open({directory:!1,multiple:!0});return Array.isArray(e)?e:typeof e=="string"?[e]:[]},pickFile:async()=>{let e=await c().dialog.open({directory:!1,multiple:!1});return typeof e=="string"?e:null},saveFile:async e=>{try{let t=e.split(".").pop()??"json",n=await c().dialog.save({defaultPath:e,filters:[{name:t==="csv"?"Table":t==="html"?"Page":"Recipe",extensions:[t]}]});return typeof n=="string"?n:null}catch{let t=await c().dialog.open({directory:!0,multiple:!1});return typeof t=="string"?`${t.replace(/[\\/]$/,"")}/${e}`:null}}};export{v as EngineError,S as SIGNED_OUT,E as engine,$ as engineFs,O as isDemo,V as openUrlFrom,A as shell};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{ec as a,fc as b,gc as c,hc as d,ic as e,jc as f,kc as g,lc as h,mc as i,nc as j,oc as k,pc as l,qc as m,rc as n,sc as o}from"./chunk-XLRQNFJU.js";import"./chunk-IN6XVTUS.js";import"./chunk-E4KQR4M3.js";import"./chunk-3PVQ5QP4.js";import"./chunk-VFXMP7IF.js";import"./chunk-6BL5HE4S.js";import"./chunk-TNCXZIOX.js";import"./chunk-5JIFRR7U.js";import"./chunk-WRDA44QF.js";import"./chunk-PGJMKUUP.js";import"./chunk-6QB4DV22.js";import"./chunk-OSUIS4JU.js";import"./chunk-JV7TZDKJ.js";import"./chunk-BBCQMZQN.js";import"./chunk-ASFUV3PB.js";import"./chunk-NRURUPLU.js";import"./chunk-TGLH2JDW.js";import"./chunk-RL5XRG6O.js";import"./chunk-IDADYIY6.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import"./chunk-7Z65WW4I.js";import"./chunk-AR5BTVBM.js";import"./chunk-VZ3XYHK4.js";import"./chunk-HNEKQMQG.js";import"./chunk-E75BCWXY.js";import"./chunk-ZPIY5DOU.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";export{k as ASPECTS,a as INPUT_SCALING,g as SIZING_TARGETS,j as alignText,i as alignTimeline,l as aspectOf,m as blankingForAspect,n as blankingQc,o as blankingText,f as cropUnderRef,c as inputFitRatio,h as offlineLane,d as resolveProps,b as scalingOf,e as underRef};
3
+ import{ec as a,fc as b,gc as c,hc as d,ic as e,jc as f,kc as g,lc as h,mc as i,nc as j,oc as k,pc as l,qc as m,rc as n,sc as o}from"./chunk-BZE7IP6U.js";import"./chunk-IN6XVTUS.js";import"./chunk-RKJML7MH.js";import"./chunk-3PVQ5QP4.js";import"./chunk-VFXMP7IF.js";import"./chunk-WJS6NM7T.js";import"./chunk-TNCXZIOX.js";import"./chunk-5JIFRR7U.js";import"./chunk-WRDA44QF.js";import"./chunk-PGJMKUUP.js";import"./chunk-6QB4DV22.js";import"./chunk-OSUIS4JU.js";import"./chunk-JV7TZDKJ.js";import"./chunk-BBCQMZQN.js";import"./chunk-ASFUV3PB.js";import"./chunk-GDPYFRSV.js";import"./chunk-FHCRWOI7.js";import"./chunk-WWE2FXAQ.js";import"./chunk-H3FD5KA2.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import"./chunk-7Z65WW4I.js";import"./chunk-KD7UGCLT.js";import"./chunk-VZ3XYHK4.js";import"./chunk-YJREJ2MH.js";import"./chunk-E75BCWXY.js";import"./chunk-QQBDHVUU.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";export{k as ASPECTS,a as INPUT_SCALING,g as SIZING_TARGETS,j as alignText,i as alignTimeline,l as aspectOf,m as blankingForAspect,n as blankingQc,o as blankingText,f as cropUnderRef,c as inputFitRatio,h as offlineLane,d as resolveProps,b as scalingOf,e as underRef};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a as h,b as d,j as w,l as _}from"./chunk-BIX5ETBY.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import{Ja as u,U as l,W as g}from"./chunk-7Z65WW4I.js";import"./chunk-E75BCWXY.js";import{y}from"./chunk-ZPIY5DOU.js";import"./chunk-PSANHDZM.js";import{parentPort as p,workerData as C}from"node:worker_threads";import{createCanvas as M,loadImage as A}from"@napi-rs/canvas";var S=(async()=>{await w(C),await u()})(),o=new Map,c=new Map;p.on("message",async t=>{try{await S;let s={};for(let[e,a]of Object.entries(t.images))c.has(a)||c.set(a,await A(await y(a))),s[e]=c.get(a);let m=`${t.fmt.w}x${t.fmt.h}`;o.has(m)||o.set(m,M(t.fmt.w,t.fmt.h));let i=o.get(m).getContext("2d"),v=h(i),r=[],f=null;for(let e=t.from;e<t.to;e++){d(i,t.scene,e/t.fps,t.fmt,v,s);let a=i.getImageData(0,0,t.fmt.w,t.fmt.h).data,n=new Uint8Array(a.buffer,a.byteOffset,a.byteLength);if(f&&_(f,n)){r.push(null);continue}r.push(t.alpha?l(n,t.fmt.w,t.fmt.h,4):g(n,t.fmt.w,t.fmt.h,4)),f=n.slice()}p.postMessage({id:t.id,samples:r},r.filter(e=>!!e).map(e=>e.buffer))}catch(s){p.postMessage({id:t.id,error:s.message??String(s)})}});
3
+ import{a as h,b as d,j as w,l as _}from"./chunk-HHOFGYZ7.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import{Ja as u,U as l,W as g}from"./chunk-7Z65WW4I.js";import"./chunk-E75BCWXY.js";import{y}from"./chunk-QQBDHVUU.js";import"./chunk-PSANHDZM.js";import{parentPort as p,workerData as C}from"node:worker_threads";import{createCanvas as M,loadImage as A}from"@napi-rs/canvas";var S=(async()=>{await w(C),await u()})(),o=new Map,c=new Map;p.on("message",async t=>{try{await S;let s={};for(let[e,a]of Object.entries(t.images))c.has(a)||c.set(a,await A(await y(a))),s[e]=c.get(a);let m=`${t.fmt.w}x${t.fmt.h}`;o.has(m)||o.set(m,M(t.fmt.w,t.fmt.h));let i=o.get(m).getContext("2d"),v=h(i),r=[],f=null;for(let e=t.from;e<t.to;e++){d(i,t.scene,e/t.fps,t.fmt,v,s);let a=i.getImageData(0,0,t.fmt.w,t.fmt.h).data,n=new Uint8Array(a.buffer,a.byteOffset,a.byteLength);if(f&&_(f,n)){r.push(null);continue}r.push(t.alpha?l(n,t.fmt.w,t.fmt.h,4):g(n,t.fmt.w,t.fmt.h,4)),f=n.slice()}p.postMessage({id:t.id,samples:r},r.filter(e=>!!e).map(e=>e.buffer))}catch(s){p.postMessage({id:t.id,error:s.message??String(s)})}});
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{a as D}from"./chunk-TK55FA56.js";import"./chunk-PSANHDZM.js";function v(e,n,t,c){let s=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n;for(;r+8<=t;){let o=s.getUint32(r),a=String.fromCharCode(e[r+4],e[r+5],e[r+6],e[r+7]),f=8;if(o===1){let l=s.getUint32(r+8),g=s.getUint32(r+12);o=l*2**32+g,f=16}else o===0&&(o=t-r);if(o<f||r+o>t)break;c(a,r+f,r+o),r+=o}}var E=new Set(["moov","trak","mdia","minf","stbl"]);function V(e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=null,c=(r,o)=>{let a={},f=!1,l=(g,w)=>{v(e,g,w,(y,i,p)=>{if(E.has(y)){l(i,p);return}if(!(!f&&y!=="hdlr"&&y!=="stsd"))switch(y){case"hdlr":{String.fromCharCode(e[i+8],e[i+9],e[i+10],e[i+11])==="vide"&&(f=!0);break}case"stsd":{let u=i+8;a.codec=String.fromCharCode(e[u+4],e[u+5],e[u+6],e[u+7]),a.width=n.getUint16(u+32),a.height=n.getUint16(u+34);break}case"stsz":{let u=n.getUint32(i+4),m=n.getUint32(i+8),d=[];if(u===0)for(let h=0;h<m;h++)d.push(n.getUint32(i+12+h*4));else for(let h=0;h<m;h++)d.push(u);a.sampleSizes=d;break}case"stco":{let u=n.getUint32(i+4),m=[];for(let d=0;d<u;d++)m.push(n.getUint32(i+8+d*4));a.chunkOffsets=m;break}case"co64":{let u=n.getUint32(i+4),m=[];for(let d=0;d<u;d++){let h=n.getUint32(i+8+d*8),k=n.getUint32(i+12+d*8);m.push(h*2**32+k)}a.chunkOffsets=m;break}case"stsc":{let u=n.getUint32(i+4),m=[];for(let d=0;d<u;d++)m.push({firstChunk:n.getUint32(i+8+d*12),samplesPerChunk:n.getUint32(i+8+d*12+4),descIdx:n.getUint32(i+8+d*12+8)});a.sampleToChunk=m;break}}})};l(r,o),f&&a.chunkOffsets&&a.sampleSizes&&a.sampleToChunk&&(t=a)};if(((r,o)=>{v(e,r,o,(a,f,l)=>{a==="moov"&&v(e,f,l,(g,w,y)=>{g==="trak"&&c(w,y)})})})(0,e.length),!t)throw new Error("could not find a video sample table");return t}function I(e){let n=[],t=0;for(let c=0;c<e.chunkOffsets.length;c++){let s=1;for(let o=0;o<e.sampleToChunk.length;o++)c+1>=e.sampleToChunk[o].firstChunk&&(s=e.sampleToChunk[o].samplesPerChunk);let r=e.chunkOffsets[c];for(let o=0;o<s&&t<e.sampleSizes.length;o++){let a=e.sampleSizes[t];n.push({offset:r,size:a}),r+=a,t++}}return n}var P=(e,n)=>String.fromCharCode(e[n],e[n+1],e[n+2],e[n+3]),z=e=>e.toString(16).padStart(2,"0");function S(e,n,t,c){let s=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n;for(;r+8<=t;){let o=s.getUint32(r),a=8;if(o===1?(o=Number(s.getBigUint64(r+8)),a=16):o===0&&(o=t-r),P(e,r+4)===c)return[r+a,r+o];if(o<a)break;r+=o}return null}function M(e,n,t,c){let s=[n,t];for(let r of c){if(!s)return null;s=S(e,s[0],s[1],r)}return s}function x(e,n,t){let c=S(e,n[0],n[1],"stts");if(!c)return new Int32Array(0);let s=t.getUint32(c[0]+4),r=[],o=0,a=c[0]+8;for(let i=0;i<s;i++){let p=t.getUint32(a),u=t.getInt32(a+4);for(let m=0;m<p;m++)r.push(o),o+=u;a+=8}let f=r.length,l=S(e,n[0],n[1],"ctts"),g=new Float64Array(f);for(let i=0;i<f;i++)g[i]=r[i];if(l){let i=t.getUint32(l[0]+4),p=l[0]+8,u=0;for(let m=0;m<i&&u<f;m++){let d=t.getUint32(p),h=t.getInt32(p+4);for(let k=0;k<d&&u<f;k++)g[u++]+=h;p+=8}}let w=Array.from({length:f},(i,p)=>p).sort((i,p)=>g[i]-g[p]||i-p),y=new Int32Array(f);for(let i=0;i<f;i++)y[w[i]]=i;return y}function F(e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=S(e,0,e.length,"moov"),[c,s]=t??[0,e.length],r=c;for(;r+8<=s;){let o=n.getUint32(r),a=8;if(o===1?(o=Number(n.getBigUint64(r+8)),a=16):o===0&&(o=s-r),P(e,r+4)==="trak"){let f=M(e,r+a,r+o,["mdia","minf","stbl"]);if(f){let l=S(e,f[0],f[1],"stsd");if(l){let g=l[0]+8,w=P(e,g+4);if(w==="avc1"||w==="avc3"||w==="hvc1"||w==="hev1"){let y=n.getUint32(g),i=g+8+78,p=w.startsWith("hv")||w.startsWith("he"),u=S(e,i,g+y,p?"hvcC":"avcC");if(!u)return null;let m=e.subarray(u[0],u[1]),d=p?"hvc1.1.6.L93.B0":`avc1.${z(m[1])}${z(m[2])}${z(m[3])}`,h=x(e,f,n),k=h.length,C=S(e,f[0],f[1],"stss"),b=[];if(C){let T=n.getUint32(C[0]+4);for(let U=0;U<T;U++)b.push(n.getUint32(C[0]+8+U*4)-1)}else for(let T=0;T<k;T++)b.push(T);return(b.length===0||b[0]!==0)&&b.unshift(0),b.sort((T,U)=>T-U),{codec:d,description:m,keyframes:b,decodeToPres:h}}}}}if(o<a)break;r+=o}return null}var R=8,L=1500,H=new WeakMap;async function q(e){let n=H.get(e);return n||(n=B(e),H.set(e,n)),n}async function B(e){if(typeof VideoDecoder>"u")throw new Error("h264: WebCodecs (VideoDecoder) not available in this context");let n=e.parts[0],t=await D({fileSize:n.fileSize,read:n.read}),c=I(V(t)),s=F(t);if(!s)throw new Error("h264: no H.264/HEVC config in container");let r=s.decodeToPres.length||c.length,o=new Int32Array(r);for(let l=0;l<s.decodeToPres.length;l++)o[s.decodeToPres[l]]=l;let a=[];for(let l=0;l<s.keyframes.length;l++){let g=s.keyframes[l],w=l+1<s.keyframes.length?s.keyframes[l+1]:c.length;a.push([g,w])}let f={offs:c,cfg:s,gops:a,presToDecode:o,count:r,dec:null,wanted:-1,got:null,gotResolve:null,fedThrough:-1,queue:Promise.resolve()};return O(f),f}function O(e){let n=e.cfg;e.dec=new VideoDecoder({output:t=>{Number(t.timestamp)===e.wanted&&!e.got?(e.got=t,e.gotResolve?.()):t.close()},error:()=>{e.fedThrough=-1}}),e.dec.configure({codec:n.codec,description:n.description,optimizeForLatency:!0,hardwareAcceleration:"prefer-hardware"})}function $(e,n){let t=0,c=e.length-1,s=0;for(;t<=c;){let r=t+c>>1;e[r][0]<=n?(s=r,t=r+1):c=r-1}return s}async function N(e){let n=e.codedWidth,t=e.codedHeight;try{let c=n*t*4,s=new Uint8Array(c);return await e.copyTo(s,{format:"RGBA",colorSpace:"srgb"}),{width:n,height:t,rgba:s}}catch{let s=new OffscreenCanvas(n,t).getContext("2d",{willReadFrequently:!0});if(!s)throw new Error("h264: no 2d context for frame readback");s.drawImage(e,0,0);let r=s.getImageData(0,0,n,t);return{width:n,height:t,rgba:new Uint8Array(r.data.buffer)}}}async function W(e,n){let t=await q(e);if(t.count===0)throw new Error("h264: empty clip");if(n<0||n>=t.count)throw new Error(`COVERAGE_MISS: frame ${n} outside 0..${t.count-1}`);let c,s=new Promise(o=>{c=o}),r=t.queue;t.queue=t.queue.then(()=>s),await r;try{t.dec.state==="closed"&&(O(t),t.fedThrough=-1);let o=e.parts[0],a=t.presToDecode[n],f=$(t.gops,a),[l,g]=t.gops[f];for(let w=0;w<2;w++){t.dec.state==="closed"&&(O(t),t.fedThrough=-1);let y=w===0&&t.fedThrough>l&&t.fedThrough<=g&&a>=t.fedThrough,i=y?t.fedThrough:l;if(!y&&t.fedThrough!==-1){try{await t.dec.flush()}catch{}t.fedThrough=-1}let p=Math.min(g,a+1+R);t.wanted=n,t.got=null;let u=new Promise(h=>{t.gotResolve=h});if(p>i){let h=1/0,k=0;for(let b=i;b<p;b++)h=Math.min(h,t.offs[b].offset),k=Math.max(k,t.offs[b].offset+t.offs[b].size);let C=await o.read(h,k-h);for(let b=i;b<p;b++){let T=t.offs[b];t.dec.decode(new EncodedVideoChunk({type:b===l?"key":"delta",timestamp:t.cfg.decodeToPres[b],data:C.subarray(T.offset-h,T.offset-h+T.size)}))}t.fedThrough=p}let m=new Promise(h=>setTimeout(h,L));if(await Promise.race([u,m]),!t.got){try{await t.dec.flush()}catch{}t.fedThrough=-1}let d=t.got;if(t.wanted=-1,t.gotResolve=null,t.got=null,!!d)try{return await N(d)}finally{d.close()}}throw new Error(`h264: frame ${n} did not decode`)}finally{c()}}async function A(){return(await import("./isobmff-LAXAYC7P.js")).isobmffFormat}var Q={async inspect(e){return(await A()).inspect(e)},async extract(e){return(await A()).extract(e)},async sparsify(e,n){return(await A()).sparsify(e,n)},async trim(e,n){return(await A()).trim(e,n)},async decode(e,n){return W(e,n)}};export{Q as h264Format};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{Ja as v,oa as g,qa as b}from"./chunk-7Z65WW4I.js";import"./chunk-PSANHDZM.js";var G=8,P=1500,M=new WeakMap,S=o=>(t,e)=>o.read(t,e);function F(o){let t=new DataView(o.buffer,o.byteOffset,o.byteLength),e=t.getUint32(0,!0),n=[];for(let a=0;a<e;a++)n.push(t.getUint32(4+a*4,!0));let i=[],r=4+e*4;for(let a of n)i.push(o.subarray(r,r+a)),r+=a;return i}function V(o){for(let t=0;t+5<o.length;t++){let e=o[t]===0&&o[t+1]===0&&o[t+2]===0&&o[t+3]===1,n=o[t]===0&&o[t+1]===0&&o[t+2]===1;if(e||n){let i=t+(e?4:3);if((o[i]&31)===7){let r=a=>a.toString(16).padStart(2,"0");return`avc1.${r(o[i+1])}${r(o[i+2])}${r(o[i+3])}`}t=i-1}}return"avc1.640028"}async function A(o){if(typeof VideoDecoder>"u")throw new Error("h264-mxf: WebCodecs (VideoDecoder) not available in this context");await v();let t=o.parts[0],e=S(t),n=JSON.parse(await b(e,t.fileSize));if(!n.raps.length)throw new Error("h264-mxf: no random-access points in MXF index");let i=V(F(await g(e,t.fileSize,0,0))[0]),r={map:n,codec:i,dec:null,wanted:-1,emitted:0,got:null,gotResolve:null,fedGop:-1,fedThrough:-1,queue:Promise.resolve()};return r.dec=new VideoDecoder({output:a=>{r.emitted++===r.wanted&&!r.got?(r.got=a,r.gotResolve?.()):a.close()},error:()=>{r.fedGop=-1,r.fedThrough=-1}}),r.dec.configure({codec:i,codedWidth:n.coded_width||1920,codedHeight:n.coded_height||1088,optimizeForLatency:!0}),r}async function E(o){let t=M.get(o);return t||(t=A(o),M.set(o,t)),t}function D(o,t){let e=o.raps,n=0,i=e.length-1,r=0;for(;n<=i;){let a=n+i>>1;e[a]<=t?(r=a,n=a+1):i=a-1}return{start:e[r],end:r+1<e.length?e[r+1]:o.total_frames}}async function R(o){let t=o.visibleRect,e=t?t.width:o.codedWidth,n=t?t.height:o.codedHeight;try{let i=new Uint8Array(e*n*4);return await o.copyTo(i,{format:"RGBA",colorSpace:"srgb",rect:t??void 0}),{width:e,height:n,rgba:i}}catch{let r=new OffscreenCanvas(e,n).getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("h264-mxf: no 2d context for frame readback");r.drawImage(o,t?t.x:0,t?t.y:0,e,n,0,0,e,n);let a=r.getImageData(0,0,e,n);return{width:e,height:n,rgba:new Uint8Array(a.data.buffer)}}}async function U(o,t){let e=await E(o);if(e.map.total_frames===0)throw new Error("h264-mxf: empty clip");if(t<0||t>=e.map.total_frames)throw new Error(`COVERAGE_MISS: frame ${t} outside 0..${e.map.total_frames-1}`);let n,i=new Promise(a=>{n=a}),r=e.queue;e.queue=e.queue.then(()=>i),await r;try{let a=o.parts[0],w=S(a),{start:c,end:_}=D(e.map,t);for(let u=0;u<2;u++){let f=u===0&&e.fedGop===c&&e.fedThrough>c&&t>=e.fedThrough;if(!f&&e.fedGop!==-1){try{await e.dec.flush()}catch{}e.fedGop=-1,e.fedThrough=-1}let l=f?e.fedThrough:c,h=Math.min(_,t+1+G);f||(e.emitted=0),e.wanted=t-c,e.got=null;let T=new Promise(s=>{e.gotResolve=s});if(h>l){let s=F(await g(w,a.fileSize,l,h-1));for(let d=0;d<s.length;d++){let y=l+d;e.dec.decode(new EncodedVideoChunk({type:y===c?"key":"delta",timestamp:y*1e3,data:s[d]}))}e.fedGop=c,e.fedThrough=h}let x=new Promise(s=>setTimeout(s,P));if(await Promise.race([T,x]),!e.got){try{await e.dec.flush()}catch{}e.fedGop=-1,e.fedThrough=-1}let p=e.got;if(e.wanted=-1,e.gotResolve=null,e.got=null,!!p)try{return await R(p)}finally{p.close()}}throw new Error(`h264-mxf: frame ${t} did not decode`)}finally{n()}}async function m(){return(await import("./mxf-WFJNAX7D.js")).mxfFormat}var O={async inspect(o){return(await m()).inspect(o)},async extract(o){return(await m()).extract(o)},async sparsify(o,t){return(await m()).sparsify(o,t)},async trim(o,t){return(await m()).trim(o,t)},async decode(o,t){return U(o,t)}};export{O as h264MxfFormat};
3
+ import{Ja as v,oa as g,qa as b}from"./chunk-7Z65WW4I.js";import"./chunk-PSANHDZM.js";var G=8,P=1500,M=new WeakMap,S=o=>(t,e)=>o.read(t,e);function F(o){let t=new DataView(o.buffer,o.byteOffset,o.byteLength),e=t.getUint32(0,!0),n=[];for(let a=0;a<e;a++)n.push(t.getUint32(4+a*4,!0));let i=[],r=4+e*4;for(let a of n)i.push(o.subarray(r,r+a)),r+=a;return i}function V(o){for(let t=0;t+5<o.length;t++){let e=o[t]===0&&o[t+1]===0&&o[t+2]===0&&o[t+3]===1,n=o[t]===0&&o[t+1]===0&&o[t+2]===1;if(e||n){let i=t+(e?4:3);if((o[i]&31)===7){let r=a=>a.toString(16).padStart(2,"0");return`avc1.${r(o[i+1])}${r(o[i+2])}${r(o[i+3])}`}t=i-1}}return"avc1.640028"}async function A(o){if(typeof VideoDecoder>"u")throw new Error("h264-mxf: WebCodecs (VideoDecoder) not available in this context");await v();let t=o.parts[0],e=S(t),n=JSON.parse(await b(e,t.fileSize));if(!n.raps.length)throw new Error("h264-mxf: no random-access points in MXF index");let i=V(F(await g(e,t.fileSize,0,0))[0]),r={map:n,codec:i,dec:null,wanted:-1,emitted:0,got:null,gotResolve:null,fedGop:-1,fedThrough:-1,queue:Promise.resolve()};return r.dec=new VideoDecoder({output:a=>{r.emitted++===r.wanted&&!r.got?(r.got=a,r.gotResolve?.()):a.close()},error:()=>{r.fedGop=-1,r.fedThrough=-1}}),r.dec.configure({codec:i,codedWidth:n.coded_width||1920,codedHeight:n.coded_height||1088,optimizeForLatency:!0}),r}async function E(o){let t=M.get(o);return t||(t=A(o),M.set(o,t)),t}function D(o,t){let e=o.raps,n=0,i=e.length-1,r=0;for(;n<=i;){let a=n+i>>1;e[a]<=t?(r=a,n=a+1):i=a-1}return{start:e[r],end:r+1<e.length?e[r+1]:o.total_frames}}async function R(o){let t=o.visibleRect,e=t?t.width:o.codedWidth,n=t?t.height:o.codedHeight;try{let i=new Uint8Array(e*n*4);return await o.copyTo(i,{format:"RGBA",colorSpace:"srgb",rect:t??void 0}),{width:e,height:n,rgba:i}}catch{let r=new OffscreenCanvas(e,n).getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("h264-mxf: no 2d context for frame readback");r.drawImage(o,t?t.x:0,t?t.y:0,e,n,0,0,e,n);let a=r.getImageData(0,0,e,n);return{width:e,height:n,rgba:new Uint8Array(a.data.buffer)}}}async function U(o,t){let e=await E(o);if(e.map.total_frames===0)throw new Error("h264-mxf: empty clip");if(t<0||t>=e.map.total_frames)throw new Error(`COVERAGE_MISS: frame ${t} outside 0..${e.map.total_frames-1}`);let n,i=new Promise(a=>{n=a}),r=e.queue;e.queue=e.queue.then(()=>i),await r;try{let a=o.parts[0],w=S(a),{start:c,end:_}=D(e.map,t);for(let u=0;u<2;u++){let f=u===0&&e.fedGop===c&&e.fedThrough>c&&t>=e.fedThrough;if(!f&&e.fedGop!==-1){try{await e.dec.flush()}catch{}e.fedGop=-1,e.fedThrough=-1}let l=f?e.fedThrough:c,h=Math.min(_,t+1+G);f||(e.emitted=0),e.wanted=t-c,e.got=null;let T=new Promise(s=>{e.gotResolve=s});if(h>l){let s=F(await g(w,a.fileSize,l,h-1));for(let d=0;d<s.length;d++){let y=l+d;e.dec.decode(new EncodedVideoChunk({type:y===c?"key":"delta",timestamp:y*1e3,data:s[d]}))}e.fedGop=c,e.fedThrough=h}let x=new Promise(s=>setTimeout(s,P));if(await Promise.race([T,x]),!e.got){try{await e.dec.flush()}catch{}e.fedGop=-1,e.fedThrough=-1}let p=e.got;if(e.wanted=-1,e.gotResolve=null,e.got=null,!!p)try{return await R(p)}finally{p.close()}}throw new Error(`h264-mxf: frame ${t} did not decode`)}finally{n()}}async function m(){return(await import("./mxf-2TQO552L.js")).mxfFormat}var O={async inspect(o){return(await m()).inspect(o)},async extract(o){return(await m()).extract(o)},async sparsify(o,t){return(await m()).sparsify(o,t)},async trim(o,t){return(await m()).trim(o,t)},async decode(o,t){return U(o,t)}};export{O as h264MxfFormat};
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a as T}from"./chunk-2X2SFPWD.js";import{c as D}from"./chunk-2DMNGWC2.js";import{Qb as P,Wb as N,_b as q}from"./chunk-XLRQNFJU.js";import"./chunk-IN6XVTUS.js";import{l as A}from"./chunk-E4KQR4M3.js";import"./chunk-3PVQ5QP4.js";import"./chunk-VFXMP7IF.js";import"./chunk-YMRK5D3X.js";import"./chunk-6BL5HE4S.js";import"./chunk-TNCXZIOX.js";import"./chunk-5JIFRR7U.js";import"./chunk-WRDA44QF.js";import"./chunk-PGJMKUUP.js";import"./chunk-6QB4DV22.js";import"./chunk-OSUIS4JU.js";import"./chunk-JV7TZDKJ.js";import"./chunk-BBCQMZQN.js";import"./chunk-ASFUV3PB.js";import"./chunk-NRURUPLU.js";import"./chunk-TGLH2JDW.js";import"./chunk-RL5XRG6O.js";import"./chunk-IDADYIY6.js";import"./chunk-N34DQ6MH.js";import{b as F}from"./chunk-NU3X7P4N.js";import"./chunk-7Z65WW4I.js";import{n as M}from"./chunk-AR5BTVBM.js";import"./chunk-VZ3XYHK4.js";import"./chunk-HNEKQMQG.js";import"./chunk-E75BCWXY.js";import{N as x,O as E,aa as U,ba as R,da as k,q as O,u as S}from"./chunk-ZPIY5DOU.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";var y=s=>{let i=s?.target_url??s?.local_path??"";return i.startsWith("file://")?O(i):i};async function H(s,i){let o=await V(s,i);return await I(s,o.session,i),o}async function I(s,i,o){let r=await s.liveMarkers(o).catch(()=>null);if(!r)return;let l=i.timelines,e=l.find(m=>m.kind!=="compound")??l[0];if(!e)return;let t=(m,f,a,p)=>({id:`live-${p??"tl"}-${m}`,time:{value:m},duration:{value:Math.max(1,f)},color:a.color,name:a.name,note:a.note,...p?{item_id:p}:{}}),n=r.timeline.map(m=>t(m.frame,m.duration,m)),c=e.tracks.filter(m=>m.kind==="Video");for(let m of r.clips){let f=c[m.track-1]?.items.find(a=>a.timeline_range?.start?.value===m.start);if(f)for(let a of m.markers)n.push(t(a.frame,a.duration,a,f.id))}e.markers=n}async function V(s,i){let o=await s.items({timeline:i,kind:"video"}),r=o.items.map(f=>`${f.kind}:${f.track}:${f.start}:${f.end-f.start}`),l=async f=>{let a=await D(f,o.timeline).catch(()=>null);if(!a||!r.every(d=>a.has(d)))return null;let{session:p}=await P(f,"prproj"),u=p.timelines.find(d=>d.name===o.timeline);return u?z(p,u):null};if(o.project_path){let f=await l(o.project_path);if(f)return await C(f),{session:f,from:"the saved project (matches the live sequence)",path:o.project_path};let a=k(R(o.project_path),"Adobe Premiere Pro Auto-Save"),p=U(o.project_path).replace(/\.prproj$/i,""),u=[];try{for await(let d of E(a))d.isFile&&d.name.startsWith(`${p}--`)&&d.name.endsWith(".prproj")&&u.push({path:k(a,d.name),mtime:(await S(k(a,d.name))).mtime?.getTime()??0})}catch{}for(let d of u.sort((g,_)=>_.mtime-g.mtime).slice(0,3)){let g=await l(d.path);if(g&&await C(g),g)return{session:g,from:`Premiere's auto-save of ${new Date(d.mtime).toLocaleTimeString()} (matches the live sequence; the project itself is not saved)`,path:d.path}}}let e=k(await x("conform-ppro-"),"live.otio"),t=await s.export({timeline:i,out_path:e}),{session:n}=await P(t.path,t.format);if(await W(s,n),await Z(n),typeof o.drop_frame=="boolean")for(let f of n.timelines)f.is_drop_frame=o.drop_frame;await C(n);for(let f of n.timelines)for(let a of f.tracks)for(let p of a.items){let u=p;u.scale=null,u.position_x=null,u.position_y=null,u.rotation=null}let c=await s.model(i).then(f=>f.items.filter(a=>Object.keys(a.sizing??{}).length).map(a=>`${a.name??a.file_path.split("/").pop()} (V${a.track} @${a.start-f.start_frame})`)).catch(()=>[]),m=`Premiere's OTIO export carries the cut, not the clips' Motion / Opacity / effects / retimes${c.length?` \u2014 ${c.length} clip(s) here have Motion that will not carry: ${c.slice(0,6).join(", ")}${c.length>6?"\u2026":""}`:""}; save the project (or wait for its auto-save) and run it again for every one of them`;return{session:n,from:"Premiere's OTIO export of the live sequence (no saved or auto-saved copy matches it yet)",path:t.path,lossy:m}}async function C(s){let i=new Set;for(let r of s.media_references??[]){if(r.binding_state==="linked")continue;let l=y(r);l&&await S(l).then(e=>e.isFile,()=>!1)&&i.add(R(l))}let o=s;for(let r of i){let l=await T(o,{media_root:r,gather:"path",criteria:{file_name:!0,file_name_mode:"tight"},lane:"both",reset:!1,dry_run:!1,compare:!1,cap:2e3,remember:!1}).catch(()=>null);l?.changed&&(o=l.session)}return o!==s&&Object.assign(s,o),(s.media_references??[]).filter(r=>r.binding_state==="linked").length}async function Z(s){let i=0;for(let o of s.media_references??[]){if(o.source_resolution_w)continue;let r=y(o),l=r?await A(r).catch(()=>null):null;if(!l)continue;let e=l;for(let t of["source_resolution_w","source_resolution_h","source_pixel_aspect","codec","container","streams"])e[t]!=null&&o[t]==null&&(o[t]=e[t]);o.source_fps??=e.source_fps??null,o.source_timecode??=e.source_timecode??null,!o.available_range&&e.available_range&&(o.available_range=e.available_range),i++}return i}async function re(s,i){let o=i.timelines.filter(t=>t.offline_reference?.clip_id);if(!o.length)return 0;let r=t=>[...t?.clip_list??[],...(t?.folders??[]).flatMap(r)],l=new Map(r((await s.project({clips:!0})).pool).map(t=>[t.id,t])),e=0;for(let t of o){let n=l.get(t.offline_reference.clip_id);if(n?.file){let c=i.media_references.find(m=>y(m)===n.file);c||(c={id:`offline-ref-${t.id??e}`,kind:"external",name:n.name,target_url:`file://${n.file}`,local_path:n.file},i.media_references.push(c)),t.offline_reference.media_reference_id=c.id,e++}else if(n&&n.name!==t.name&&(n.type==="Timeline"||/compound/i.test(n.type??""))){let{createSession:c}=await import("./store-F2CTSR6E.js"),m=k(await x("conform-offline-ref-"),`${n.name.replace(/[^\w.-]+/g,"_")}.drt`),f=await s.export(n.type==="Timeline"?{timeline:n.name,out_path:m}:{clip_id:n.id,out_path:m}),{session:a}=await P(f.path,"drt");a=(await M(a))?.session??a,t.offline_reference.session_id=(await c(a,f.path,"drt")).id,e++}else t.offline_reference=null}return e}async function W(s,i){let o=(await s.projectClips()).clips,r=new Map(o.filter(e=>e.start_frame!=null&&e.fps).map(e=>[e.file,e])),l=0;for(let e of i.media_references??[]){if(e.source_timecode)continue;let t=r.get(y(e));if(t){e.source_timecode=F(t.start_frame,t.fps),e.source_fps??=t.fps,l++;continue}let n=y(e),c=n?await A(n).catch(()=>null):null;c?.source_timecode&&(e.source_timecode=c.source_timecode,e.source_fps??=c.source_fps??null,l++)}return l}function z(s,i){let o=new Map(s.timelines.map(l=>[l.id,l])),r=[i];for(let l=0;l<r.length;l++)for(let e of r[l].tracks)for(let t of e.items){let n=t.nested_timeline_id,c=n?o.get(n):void 0;c&&!r.includes(c)&&r.push(c)}return{...s,timelines:r}}function X(s,i){let o=new Map((s.media_references??[]).map(n=>[n.id,y(n)])),r=[];for(let n of i.media_references??[]){let c=o.get(n.id),m=y(n);c!==void 0&&m&&m!==c&&r.push({ref_id:n.id,old:c,new:m})}let l=new Map(r.map(n=>[n.ref_id,n])),e=[],t=i.timelines.find(n=>n.kind==="primary")??i.timelines[0];for(let n of t?.tracks??[])if(n.kind==="Video")for(let c of n.items){let m=c.media_reference_id?l.get(c.media_reference_id):void 0;!m||c.kind!=="clip"||!c.source_range||e.push({track:n.track_index,start:c.timeline_range.start.value,duration:c.timeline_range.duration.value,src_in:c.source_range.start.value,path:m.new,name:c.name??""})}return{media:r,cuts:e}}async function oe(s,i){let{session:o,from:r,lossy:l}=await H(s,i.timeline),e=await T(structuredClone(o),{media_root:i.media_root,gather:"walk",reset:!0,lane:"video",dry_run:!1,cap:2e3,criteria:i.criteria??(i.mode==="cut_in"?{file_name:!1,reel_name:!0}:{file_name:!0,file_name_mode:"loose"}),tolerances:i.tolerances}),{media:t,cuts:n}=X(o,e.session),c=[`read from ${r}`,...l&&i.mode==="new_version"?[`\u26A0 ${l}`]:[],`matched ${t.length} medi${t.length===1?"um":"a"} under ${i.media_root} (${n.length} clip use${n.length===1?"":"s"} in the sequence)`],m=t.map(u=>` ${u.old.split("/").pop()} \u2192 ${u.new}`);if(i.dry_run||!t.length)return{text:[...c,...m,i.dry_run?"(dry run \u2014 nothing changed in Premiere)":"",e.text.split(`
3
+ import{a as T}from"./chunk-NTPDZOPF.js";import{c as D}from"./chunk-7DH6DFYL.js";import{Qb as P,Wb as N,_b as q}from"./chunk-BZE7IP6U.js";import"./chunk-IN6XVTUS.js";import{l as A}from"./chunk-RKJML7MH.js";import"./chunk-3PVQ5QP4.js";import"./chunk-VFXMP7IF.js";import"./chunk-HZBGG7HI.js";import"./chunk-WJS6NM7T.js";import"./chunk-TNCXZIOX.js";import"./chunk-5JIFRR7U.js";import"./chunk-WRDA44QF.js";import"./chunk-PGJMKUUP.js";import"./chunk-6QB4DV22.js";import"./chunk-OSUIS4JU.js";import"./chunk-JV7TZDKJ.js";import"./chunk-BBCQMZQN.js";import"./chunk-ASFUV3PB.js";import"./chunk-GDPYFRSV.js";import"./chunk-FHCRWOI7.js";import"./chunk-WWE2FXAQ.js";import"./chunk-H3FD5KA2.js";import"./chunk-N34DQ6MH.js";import{b as F}from"./chunk-NU3X7P4N.js";import"./chunk-7Z65WW4I.js";import{n as M}from"./chunk-KD7UGCLT.js";import"./chunk-VZ3XYHK4.js";import"./chunk-YJREJ2MH.js";import"./chunk-E75BCWXY.js";import{O as x,P as E,ba as U,ca as R,ea as k,q as O,u as S}from"./chunk-QQBDHVUU.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";var y=s=>{let i=s?.target_url??s?.local_path??"";return i.startsWith("file://")?O(i):i};async function H(s,i){let o=await V(s,i);return await I(s,o.session,i),o}async function I(s,i,o){let r=await s.liveMarkers(o).catch(()=>null);if(!r)return;let l=i.timelines,e=l.find(m=>m.kind!=="compound")??l[0];if(!e)return;let t=(m,f,a,p)=>({id:`live-${p??"tl"}-${m}`,time:{value:m},duration:{value:Math.max(1,f)},color:a.color,name:a.name,note:a.note,...p?{item_id:p}:{}}),n=r.timeline.map(m=>t(m.frame,m.duration,m)),c=e.tracks.filter(m=>m.kind==="Video");for(let m of r.clips){let f=c[m.track-1]?.items.find(a=>a.timeline_range?.start?.value===m.start);if(f)for(let a of m.markers)n.push(t(a.frame,a.duration,a,f.id))}e.markers=n}async function V(s,i){let o=await s.items({timeline:i,kind:"video"}),r=o.items.map(f=>`${f.kind}:${f.track}:${f.start}:${f.end-f.start}`),l=async f=>{let a=await D(f,o.timeline).catch(()=>null);if(!a||!r.every(d=>a.has(d)))return null;let{session:p}=await P(f,"prproj"),u=p.timelines.find(d=>d.name===o.timeline);return u?z(p,u):null};if(o.project_path){let f=await l(o.project_path);if(f)return await C(f),{session:f,from:"the saved project (matches the live sequence)",path:o.project_path};let a=k(R(o.project_path),"Adobe Premiere Pro Auto-Save"),p=U(o.project_path).replace(/\.prproj$/i,""),u=[];try{for await(let d of E(a))d.isFile&&d.name.startsWith(`${p}--`)&&d.name.endsWith(".prproj")&&u.push({path:k(a,d.name),mtime:(await S(k(a,d.name))).mtime?.getTime()??0})}catch{}for(let d of u.sort((g,_)=>_.mtime-g.mtime).slice(0,3)){let g=await l(d.path);if(g&&await C(g),g)return{session:g,from:`Premiere's auto-save of ${new Date(d.mtime).toLocaleTimeString()} (matches the live sequence; the project itself is not saved)`,path:d.path}}}let e=k(await x("conform-ppro-"),"live.otio"),t=await s.export({timeline:i,out_path:e}),{session:n}=await P(t.path,t.format);if(await W(s,n),await Z(n),typeof o.drop_frame=="boolean")for(let f of n.timelines)f.is_drop_frame=o.drop_frame;await C(n);for(let f of n.timelines)for(let a of f.tracks)for(let p of a.items){let u=p;u.scale=null,u.position_x=null,u.position_y=null,u.rotation=null}let c=await s.model(i).then(f=>f.items.filter(a=>Object.keys(a.sizing??{}).length).map(a=>`${a.name??a.file_path.split("/").pop()} (V${a.track} @${a.start-f.start_frame})`)).catch(()=>[]),m=`Premiere's OTIO export carries the cut, not the clips' Motion / Opacity / effects / retimes${c.length?` \u2014 ${c.length} clip(s) here have Motion that will not carry: ${c.slice(0,6).join(", ")}${c.length>6?"\u2026":""}`:""}; save the project (or wait for its auto-save) and run it again for every one of them`;return{session:n,from:"Premiere's OTIO export of the live sequence (no saved or auto-saved copy matches it yet)",path:t.path,lossy:m}}async function C(s){let i=new Set;for(let r of s.media_references??[]){if(r.binding_state==="linked")continue;let l=y(r);l&&await S(l).then(e=>e.isFile,()=>!1)&&i.add(R(l))}let o=s;for(let r of i){let l=await T(o,{media_root:r,gather:"path",criteria:{file_name:!0,file_name_mode:"tight"},lane:"both",reset:!1,dry_run:!1,compare:!1,cap:2e3,remember:!1}).catch(()=>null);l?.changed&&(o=l.session)}return o!==s&&Object.assign(s,o),(s.media_references??[]).filter(r=>r.binding_state==="linked").length}async function Z(s){let i=0;for(let o of s.media_references??[]){if(o.source_resolution_w)continue;let r=y(o),l=r?await A(r).catch(()=>null):null;if(!l)continue;let e=l;for(let t of["source_resolution_w","source_resolution_h","source_pixel_aspect","codec","container","streams"])e[t]!=null&&o[t]==null&&(o[t]=e[t]);o.source_fps??=e.source_fps??null,o.source_timecode??=e.source_timecode??null,!o.available_range&&e.available_range&&(o.available_range=e.available_range),i++}return i}async function re(s,i){let o=i.timelines.filter(t=>t.offline_reference?.clip_id);if(!o.length)return 0;let r=t=>[...t?.clip_list??[],...(t?.folders??[]).flatMap(r)],l=new Map(r((await s.project({clips:!0})).pool).map(t=>[t.id,t])),e=0;for(let t of o){let n=l.get(t.offline_reference.clip_id);if(n?.file){let c=i.media_references.find(m=>y(m)===n.file);c||(c={id:`offline-ref-${t.id??e}`,kind:"external",name:n.name,target_url:`file://${n.file}`,local_path:n.file},i.media_references.push(c)),t.offline_reference.media_reference_id=c.id,e++}else if(n&&n.name!==t.name&&(n.type==="Timeline"||/compound/i.test(n.type??""))){let{createSession:c}=await import("./store-K4W2LVRN.js"),m=k(await x("conform-offline-ref-"),`${n.name.replace(/[^\w.-]+/g,"_")}.drt`),f=await s.export(n.type==="Timeline"?{timeline:n.name,out_path:m}:{clip_id:n.id,out_path:m}),{session:a}=await P(f.path,"drt");a=(await M(a))?.session??a,t.offline_reference.session_id=(await c(a,f.path,"drt")).id,e++}else t.offline_reference=null}return e}async function W(s,i){let o=(await s.projectClips()).clips,r=new Map(o.filter(e=>e.start_frame!=null&&e.fps).map(e=>[e.file,e])),l=0;for(let e of i.media_references??[]){if(e.source_timecode)continue;let t=r.get(y(e));if(t){e.source_timecode=F(t.start_frame,t.fps),e.source_fps??=t.fps,l++;continue}let n=y(e),c=n?await A(n).catch(()=>null):null;c?.source_timecode&&(e.source_timecode=c.source_timecode,e.source_fps??=c.source_fps??null,l++)}return l}function z(s,i){let o=new Map(s.timelines.map(l=>[l.id,l])),r=[i];for(let l=0;l<r.length;l++)for(let e of r[l].tracks)for(let t of e.items){let n=t.nested_timeline_id,c=n?o.get(n):void 0;c&&!r.includes(c)&&r.push(c)}return{...s,timelines:r}}function X(s,i){let o=new Map((s.media_references??[]).map(n=>[n.id,y(n)])),r=[];for(let n of i.media_references??[]){let c=o.get(n.id),m=y(n);c!==void 0&&m&&m!==c&&r.push({ref_id:n.id,old:c,new:m})}let l=new Map(r.map(n=>[n.ref_id,n])),e=[],t=i.timelines.find(n=>n.kind==="primary")??i.timelines[0];for(let n of t?.tracks??[])if(n.kind==="Video")for(let c of n.items){let m=c.media_reference_id?l.get(c.media_reference_id):void 0;!m||c.kind!=="clip"||!c.source_range||e.push({track:n.track_index,start:c.timeline_range.start.value,duration:c.timeline_range.duration.value,src_in:c.source_range.start.value,path:m.new,name:c.name??""})}return{media:r,cuts:e}}async function oe(s,i){let{session:o,from:r,lossy:l}=await H(s,i.timeline),e=await T(structuredClone(o),{media_root:i.media_root,gather:"walk",reset:!0,lane:"video",dry_run:!1,cap:2e3,criteria:i.criteria??(i.mode==="cut_in"?{file_name:!1,reel_name:!0}:{file_name:!0,file_name_mode:"loose"}),tolerances:i.tolerances}),{media:t,cuts:n}=X(o,e.session),c=[`read from ${r}`,...l&&i.mode==="new_version"?[`\u26A0 ${l}`]:[],`matched ${t.length} medi${t.length===1?"um":"a"} under ${i.media_root} (${n.length} clip use${n.length===1?"":"s"} in the sequence)`],m=t.map(u=>` ${u.old.split("/").pop()} \u2192 ${u.new}`);if(i.dry_run||!t.length)return{text:[...c,...m,i.dry_run?"(dry run \u2014 nothing changed in Premiere)":"",e.text.split(`
4
4
  `).slice(-6).join(`
5
5
  `)].filter(Boolean).join(`
6
6
  `),data:{media:t,cuts:n,from:r}};if(i.mode==="replace"||i.mode==="hires"||i.mode==="proxy"){let d=(await s.projectClips()).clips.flatMap(w=>t.filter(j=>j.old===w.file).map(j=>({clip:w.id,path:j.new,mode:i.mode}))),g=i.mode==="replace"?L(o,e.session,t):new Map,_=g.size?await Y(s,new Set(g.keys())):[],b=await s.relinkClips(d),h=b.results.filter(w=>w.ok).length,$=[...c,`${i.mode==="hires"?"attached full-res behind":i.mode==="proxy"?"attached as proxies to":"repointed"} ${h}/${d.length} project clip(s)${i.mode==="proxy"?" (Toggle Proxies in Premiere switches)":""}`,...m,...b.results.filter(w=>!w.ok).map(w=>` refused: ${w.detail??"Premiere refused"}`)],v=_.length?await B(s,_,g):null;return v&&$.push(...v.lines),{text:$.join(`
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{d as a,e as b,f as c,g as d}from"./chunk-AR5BTVBM.js";import"./chunk-VZ3XYHK4.js";import"./chunk-HNEKQMQG.js";import"./chunk-E75BCWXY.js";import"./chunk-ZPIY5DOU.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";export{a as HOSTED_READ_KEYS,b as readHosted,d as shareOriginal,c as writeHosted};
3
+ import{d as a,e as b,f as c,g as d}from"./chunk-KD7UGCLT.js";import"./chunk-VZ3XYHK4.js";import"./chunk-YJREJ2MH.js";import"./chunk-E75BCWXY.js";import"./chunk-QQBDHVUU.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";export{a as HOSTED_READ_KEYS,b as readHosted,d as shareOriginal,c as writeHosted};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{g as a,h as b,i as c,j as d}from"./chunk-RVKNGIE3.js";import"./chunk-7DH6DFYL.js";import"./chunk-BZE7IP6U.js";import"./chunk-IN6XVTUS.js";import"./chunk-RKJML7MH.js";import"./chunk-3PVQ5QP4.js";import"./chunk-VFXMP7IF.js";import"./chunk-HZBGG7HI.js";import"./chunk-WJS6NM7T.js";import"./chunk-TNCXZIOX.js";import"./chunk-5JIFRR7U.js";import"./chunk-WRDA44QF.js";import"./chunk-PGJMKUUP.js";import"./chunk-6QB4DV22.js";import"./chunk-OSUIS4JU.js";import"./chunk-JV7TZDKJ.js";import"./chunk-BBCQMZQN.js";import"./chunk-ASFUV3PB.js";import"./chunk-GDPYFRSV.js";import"./chunk-FHCRWOI7.js";import"./chunk-WWE2FXAQ.js";import"./chunk-H3FD5KA2.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import"./chunk-7Z65WW4I.js";import"./chunk-KD7UGCLT.js";import"./chunk-VZ3XYHK4.js";import"./chunk-YJREJ2MH.js";import"./chunk-E75BCWXY.js";import"./chunk-QQBDHVUU.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";export{a as AVID_SETUP,b as FLAME_SETUP,d as adapter,c as setAdapter};
package/dist/http.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a as jt}from"./chunk-JZCADV5C.js";import{a as Tt,b as vt,c as Rt,d as Et,f as Pt,g as Ct,h as $t,i as At,l as O,m as Nt,p as $,q as Mt}from"./chunk-M6SVZJAX.js";import"./chunk-UXEL636C.js";import"./chunk-2X2SFPWD.js";import"./chunk-T4B4Y5WQ.js";import"./chunk-2DMNGWC2.js";import"./chunk-3KS3547B.js";import"./chunk-YU3SUSK3.js";import"./chunk-QTFFVLVJ.js";import"./chunk-5YULBQJX.js";import{Ab as _t,G as it,H as ct,J as ht,Qc as yt,Uc as bt,Vc as D,Wc as T,bd as xt,dd as St,fd as Ot,tc as kt,zb as wt}from"./chunk-XLRQNFJU.js";import"./chunk-IN6XVTUS.js";import"./chunk-E4KQR4M3.js";import"./chunk-3PVQ5QP4.js";import"./chunk-VFXMP7IF.js";import"./chunk-YMRK5D3X.js";import{a as at}from"./chunk-6BL5HE4S.js";import"./chunk-TNCXZIOX.js";import"./chunk-5JIFRR7U.js";import"./chunk-WRDA44QF.js";import"./chunk-PGJMKUUP.js";import"./chunk-6QB4DV22.js";import"./chunk-OSUIS4JU.js";import"./chunk-JV7TZDKJ.js";import"./chunk-BBCQMZQN.js";import"./chunk-ASFUV3PB.js";import"./chunk-NRURUPLU.js";import"./chunk-TGLH2JDW.js";import{C,E as gt,t as W,u as ut,v as dt,x as pt,y as mt,z as ft}from"./chunk-RL5XRG6O.js";import"./chunk-IDADYIY6.js";import"./chunk-LMRPCWHV.js";import"./chunk-BIX5ETBY.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import"./chunk-7Z65WW4I.js";import{C as V,k as G,y as lt}from"./chunk-AR5BTVBM.js";import"./chunk-VZ3XYHK4.js";import"./chunk-HNEKQMQG.js";import{a as H}from"./chunk-E75BCWXY.js";import{A as F,B as et,C as j,E as nt,I as L,N as J,O as ot,P as st,W as rt,aa as U,b as v,ba as I,da as S,o as P,u as B,v as Q,y as q,z as tt}from"./chunk-ZPIY5DOU.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";import N from"node:process";var Lt=new Map;function Ut(t,i,r,b){let a=`${t}:${r}:${b}`,o=Lt.get(a);return o||(o=(async()=>{let n=S(P(),"cache","grade-luts",t);await j(n);let d=S(n,`V${r}_${b}.cube`);if(!await Q(d)){let{adapter:_}=await import("./hosts-DXH4SQPZ.js");if((await _("resolve").clipLut({timeline:i,track:r,start:b,out_path:d})).ok===!1)return null}return d})().catch(()=>null),Lt.set(a,o)),o}var Vt=new Set(["/app/convert","/app/canonicalize"]);function zt(t,i){let r=(i??"").split(";")[0].trim().toLowerCase();return r==="application/json"||r==="application/octet-stream"&&Vt.has(t)}function Wt(t){let i=t.replace(/[\\/:*?"<>|\x00-\x1f]+/g,"_").replace(/[. ]+$/,"")||"timeline";return/^(con|prn|aux|nul|com\d|lpt\d)(\..*)?$/i.test(i)?`_${i}`:i}var K={id:"local",name:"Local",client_name:null,handles:24,local:!0};async function Bt(){try{return JSON.parse(await tt(S(P(),"projects","projects.json")))}catch{return[]}}async function Dt(){let t=await O("project",{action:"list"});if(!t.isError){let i=t.structuredContent?.projects??[];return await j(S(P(),"projects")),await et(S(P(),"projects","projects.json"),JSON.stringify(i)),{projects:[K,...i],offline:!1}}return{projects:[K,...await Bt()],offline:!0,code:String(t.structuredContent?.code??"offline"),reason:String(t.structuredContent?.message??t.content[0]?.text??"")}}async function Kt(t){return t==="local"?K:(await Bt()).find(i=>i.id===t)??{id:t,name:t}}async function Ft(t,i,r,b,a=(o,n)=>new Response(o,{headers:{"content-type":n}})){if(i[0]!=="app")return null;let[,o,n,d]=i,_=async()=>t.headers.get("content-type")?.includes("json")?await t.json():{};try{if(o==="policy"&&t.method==="GET"){let{config:e}=await import("./account-RSL4PTDB.js"),s=await fetch(`${e().supabaseUrl}/functions/v1/v1-billing/v1/billing/app-policy`,{signal:AbortSignal.timeout(3e3)}).catch(()=>null);return r(s?.ok?await s.json():{offline:!0})}if(o==="account"&&t.method==="GET"){let e=await O("account_status",{}),s=await V().then(c=>({app:!0,studio_tools:c.source==="licence"||lt(c)?.studio_tools!==!1}),c=>({app:!1,app_reason:c.message,code:c.code,...c.data?.in_use_by?{in_use_by:c.data.in_use_by}:{}}));return r({...e.structuredContent,...e.structuredContent?.account??{},...s,text:e.content[0]?.text})}{let e=await V().then(()=>null,s=>s);if(e)return r({ok:!1,code:e.code,message:e.message,needs:"app"},e.code==="not_signed_in"?401:402)}if(o==="events"&&t.method==="GET")return b(Et());if(o==="front"&&t.method==="POST"){let e=await t.json();return vt({project:String(e.project??""),view:String(e.view??""),...e.tool?{tool:String(e.tool)}:{}}),r({ok:!0})}if(o==="problem"&&t.method==="POST"){let e=await t.json().catch(()=>({})),s=/\bnot signed in\b/i.test(String(e.what??""))?"not_signed_in":"window_error";return await D("app_window",{isError:!0,content:[],structuredContent:{code:s,message:`${String(e.what??"").slice(0,200)}${e.detail?`
3
+ import{a as jt}from"./chunk-ZE7BP4AE.js";import{a as Tt,b as vt,c as Rt,d as Et,f as Pt,g as Ct,h as $t,i as At,l as O,m as Nt,p as $,q as Mt}from"./chunk-QDL3XYOE.js";import"./chunk-UXVABU6B.js";import"./chunk-NTPDZOPF.js";import"./chunk-RVKNGIE3.js";import"./chunk-7DH6DFYL.js";import"./chunk-SSFG7FNI.js";import"./chunk-YU3SUSK3.js";import"./chunk-QTFFVLVJ.js";import"./chunk-5YULBQJX.js";import{Ab as _t,G as it,H as ct,J as ht,Qc as yt,Uc as bt,Vc as D,Wc as T,bd as xt,dd as St,fd as Ot,tc as kt,zb as wt}from"./chunk-BZE7IP6U.js";import"./chunk-IN6XVTUS.js";import"./chunk-RKJML7MH.js";import"./chunk-3PVQ5QP4.js";import"./chunk-VFXMP7IF.js";import"./chunk-HZBGG7HI.js";import{a as at}from"./chunk-WJS6NM7T.js";import"./chunk-TNCXZIOX.js";import"./chunk-5JIFRR7U.js";import"./chunk-WRDA44QF.js";import"./chunk-PGJMKUUP.js";import"./chunk-6QB4DV22.js";import"./chunk-OSUIS4JU.js";import"./chunk-JV7TZDKJ.js";import"./chunk-BBCQMZQN.js";import"./chunk-ASFUV3PB.js";import"./chunk-GDPYFRSV.js";import"./chunk-FHCRWOI7.js";import{C,E as gt,t as W,u as ut,v as dt,x as pt,y as mt,z as ft}from"./chunk-WWE2FXAQ.js";import"./chunk-H3FD5KA2.js";import"./chunk-LMRPCWHV.js";import"./chunk-HHOFGYZ7.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import"./chunk-7Z65WW4I.js";import{C as V,k as G,y as lt}from"./chunk-KD7UGCLT.js";import"./chunk-VZ3XYHK4.js";import"./chunk-YJREJ2MH.js";import{a as H}from"./chunk-E75BCWXY.js";import{A as F,C as et,D as j,F as nt,J as L,O as J,P as ot,Q as st,X as rt,b as v,ba as U,ca as I,ea as S,o as P,u as B,v as Q,y as q,z as tt}from"./chunk-QQBDHVUU.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";import N from"node:process";var Lt=new Map;function Ut(t,i,r,b){let a=`${t}:${r}:${b}`,o=Lt.get(a);return o||(o=(async()=>{let n=S(P(),"cache","grade-luts",t);await j(n);let d=S(n,`V${r}_${b}.cube`);if(!await Q(d)){let{adapter:_}=await import("./hosts-QMGBN2E6.js");if((await _("resolve").clipLut({timeline:i,track:r,start:b,out_path:d})).ok===!1)return null}return d})().catch(()=>null),Lt.set(a,o)),o}var Vt=new Set(["/app/convert","/app/canonicalize"]);function zt(t,i){let r=(i??"").split(";")[0].trim().toLowerCase();return r==="application/json"||r==="application/octet-stream"&&Vt.has(t)}function Wt(t){let i=t.replace(/[\\/:*?"<>|\x00-\x1f]+/g,"_").replace(/[. ]+$/,"")||"timeline";return/^(con|prn|aux|nul|com\d|lpt\d)(\..*)?$/i.test(i)?`_${i}`:i}var K={id:"local",name:"Local",client_name:null,handles:24,local:!0};async function Bt(){try{return JSON.parse(await tt(S(P(),"projects","projects.json")))}catch{return[]}}async function Dt(){let t=await O("project",{action:"list"});if(!t.isError){let i=t.structuredContent?.projects??[];return await j(S(P(),"projects")),await et(S(P(),"projects","projects.json"),JSON.stringify(i)),{projects:[K,...i],offline:!1}}return{projects:[K,...await Bt()],offline:!0,code:String(t.structuredContent?.code??"offline"),reason:String(t.structuredContent?.message??t.content[0]?.text??"")}}async function Kt(t){return t==="local"?K:(await Bt()).find(i=>i.id===t)??{id:t,name:t}}async function Ft(t,i,r,b,a=(o,n)=>new Response(o,{headers:{"content-type":n}})){if(i[0]!=="app")return null;let[,o,n,d]=i,_=async()=>t.headers.get("content-type")?.includes("json")?await t.json():{};try{if(o==="policy"&&t.method==="GET"){let{config:e}=await import("./account-F4ODJBD2.js"),s=await fetch(`${e().supabaseUrl}/functions/v1/v1-billing/v1/billing/app-policy`,{signal:AbortSignal.timeout(3e3)}).catch(()=>null);return r(s?.ok?await s.json():{offline:!0})}if(o==="account"&&t.method==="GET"){let e=await O("account_status",{}),s=await V().then(c=>({app:!0,studio_tools:c.source==="licence"||lt(c)?.studio_tools!==!1}),c=>({app:!1,app_reason:c.message,code:c.code,...c.data?.in_use_by?{in_use_by:c.data.in_use_by}:{}}));return r({...e.structuredContent,...e.structuredContent?.account??{},...s,text:e.content[0]?.text})}{let e=await V().then(()=>null,s=>s);if(e)return r({ok:!1,code:e.code,message:e.message,needs:"app"},e.code==="not_signed_in"?401:402)}if(o==="events"&&t.method==="GET")return b(Et());if(o==="front"&&t.method==="POST"){let e=await t.json();return vt({project:String(e.project??""),view:String(e.view??""),...e.tool?{tool:String(e.tool)}:{}}),r({ok:!0})}if(o==="problem"&&t.method==="POST"){let e=await t.json().catch(()=>({})),s=/\bnot signed in\b/i.test(String(e.what??""))?"not_signed_in":"window_error";return await D("app_window",{isError:!0,content:[],structuredContent:{code:s,message:`${String(e.what??"").slice(0,200)}${e.detail?`
4
4
  ${String(e.detail).slice(0,100)}`:""}`}},0),r({ok:!0})}if(o==="convert"&&t.method==="POST"){let e=new URL(t.url).searchParams,s=U(e.get("name")||"timeline"),c=e.get("out")||"",p=JSON.parse(e.get("targets")||"[]"),l=JSON.parse(e.get("sequences")||"[]");if(!c||!p.length)return r({ok:!1,error:"a folder and at least one format are needed"},400);let u=await J("conform-te-"),f=S(u,s);await F(f,new Uint8Array(await t.arrayBuffer()));let h=await O("timeline_read",{path:f}),y=h.structuredContent?.session_id??h.content[0]?.text.match(/session_id: (\w+)/)?.[1];if(h.isError||!y)return r({ok:!1,error:h.content[0]?.text??"could not read the timeline"});let w=(await C(y)).session.timelines.filter(x=>x.kind!=="compound"),k=l.length?w.filter(x=>l.includes(x.name??"")):w,m=[],R=0;for(let x of k)for(let E of p){let M=S(c,`${Wt(x.name??"timeline")}.${E.ext}`),Z=await O("timeline_write",{session_id:y,target:E.target,out_path:M,...k.length>1||w.length>1?{timeline_id:x.id}:{}});Z.isError?m.push(`${x.name} \u2192 ${E.target}: ${Z.content[0]?.text}`):R++}return await L(u).catch(()=>{}),r({ok:R>0,savedCount:R,...m.length?{error:m.join(`
5
5
  `)}:{}})}if(o==="fs"&&t.method==="POST"){let{op:e,path:s,offset:c=0,length:p=0}=await _();if(e==="statPath"){let l=await B(s).catch(()=>null);return r({ok:!0,result:l?{kind:l.isDirectory?"directory":"file",size:l.size,lastModified:Math.round(l.mtimeMs)}:null})}if(e==="readDir"){let l=[];for await(let u of ot(s))(u.isFile||u.isDirectory)&&l.push({name:u.name,kind:u.isDirectory?"directory":"file"});return r({ok:!0,result:l})}if(e==="readFile"){let l=p>0?p:Math.max(0,(await B(s)).size-Math.max(0,c)),u=512<<20;if(l>u)return r({ok:!1,code:"too_large",message:`${s} is ${Math.round(l/(1<<20))} MB: read it in parts (offset, length \u2264 ${u>>20} MB)`},413);let f=await st(s);try{return a(await f.readAt(Math.max(0,c),l),"application/octet-stream")}finally{await f.close()}}return r({ok:!1,code:"bad_request",message:`no fs op ${e}`},400)}if(o==="canonicalize"&&t.method==="POST"){let e=new URL(t.url).searchParams,s=JSON.parse(e.get("sequences")||"[]"),c=JSON.parse(e.get("previous")||"[]"),p=await J("conform-te-");try{let l=S(p,U(e.get("name")||"timeline"));await F(l,new Uint8Array(await t.arrayBuffer()));let u=await O("timeline_read",{path:l}),f=u.structuredContent?.session_id??u.content[0]?.text.match(/session_id: (\w+)/)?.[1];if(u.isError||!f)return r({ok:!1,error:u.content[0]?.text??"could not read the timeline"},422);let h=(await C(f)).session,y=h.timelines;if(s.length){let w=new Map;for(let m of c)w.set(m,(w.get(m)??0)+1);let k=new Set;for(let m of s){let R=h.timelines.filter(M=>M.kind!=="compound"&&(M.name??"")===m),x=w.get(m)??0;w.set(m,x+1);let E=R[Math.min(x,R.length-1)];E&&k.add(E)}y=h.timelines.filter(m=>m.kind==="compound"||k.has(m))}return r({ok:!0,session_id:f,session:{...h,timelines:y}})}finally{await L(p).catch(()=>{})}}if(o==="sessions"&&n&&d==="frame"){let e=new URL(t.url).searchParams,s=Math.max(0,Math.round(Number(e.get("f")??0))),c=Math.min(3840,Math.max(64,Number(e.get("w")??1280)|0));try{let f=(await C(n)).session,h=e.get("track")==="offline"?"offline":Number(e.get("track"))||void 0,y;if(e.get("grade")==="resolve"&&h!=="offline"){let k=(()=>{try{return wt(f,{record:s,timeline:e.get("timeline")??void 0,track:h})}catch{return null}})();k&&(y=await Ut(n,e.get("host_timeline")??void 0,k.video_track,k.record_start)??void 0)}let w=await _t(f,s,c,e.get("timeline")??void 0,h,y);if(w){let k=new Uint8Array(12+w.px.length),m=new DataView(k.buffer);return m.setUint32(0,w.w,!0),m.setUint32(4,w.h,!0),m.setUint32(8,w.order==="bgra"?1:0,!0),k.set(w.px,12),a(k,"application/x-conform-pixels")}}catch(f){return r({ok:!1,code:"no_frame",message:f.message},404)}let p=await O("timeline_frame",{session_id:n,record:s,width:c,...e.get("timeline")?{timeline:e.get("timeline")}:{}},{poll:!0}),l=p.structuredContent?.out_path;if(p.isError||!l)return r({ok:!1,code:String(p.structuredContent?.code??"no_frame"),message:p.content[0]?.text??"no picture here"},404);let u=await q(l);return await(U(I(l)).startsWith("conform-frame-")?L(I(l)):nt(l)).catch(()=>{}),a(u,"image/png")}if(o==="sessions"&&n&&t.method==="GET"){let e=await C(n).catch(()=>null);return e?r(e):r({ok:!1,code:"not_found"},404)}if(o==="sessions"&&!n)return r(await gt());if(o!=="projects")return r({ok:!1,code:"not_found"},404);if(!n){if(t.method==="POST"){let e=await _(),s=await O("project",{action:"create",name:e.name,client_name:e.client_name,handles:e.handles});return s.isError?r({...s.structuredContent,text:s.content[0]?.text},422):(await Dt(),r(s.structuredContent))}return r(await Dt())}if(!d){let[e,s,c,p,l,u]=await Promise.all([Kt(n),ut(n).catch(()=>null),ft(n),ht(n),xt(n).then(y=>y.facts).catch(()=>[]),n===W?null:St().catch(()=>null)]);await pt(n===W?null:{id:n,name:e.name??n});let{text:f="",...h}=s??{};return r({project:e,context:f,context_meta:h,sessions:c,activity:p.slice(-100).reverse(),known:Ot(l),facility:u?.text??""})}if(d==="sessions"&&t.method==="PUT")return await mt(n,String((await _()).session_id??"")),r({ok:!0});if(d==="context"&&t.method==="PUT"){let e=await _();try{let{text:s,...c}=await dt(n,String(e.text??""),e.base===void 0?void 0:e.base);return r({ok:!0,context:s,context_meta:c})}catch(s){if(s instanceof H&&s.code==="context_conflict"){let c=s.data?.current;return r({ok:!1,code:s.code,message:s.message,context:c.context,context_meta:{updated_at:c.context_updated_at,updated_by:c.context_updated_by_name??null}},409)}throw s}}return r({ok:!1,code:"not_found"},404)}catch(e){let s=e instanceof H?e:null;return r({ok:!1,code:s?.code??"internal",message:e.message},s?.code==="not_found"?404:s?.code==="invalid_args"?400:500)}}var Jt=t=>t==="1"?"app":"http",X=(t,i)=>t&&i.has(t)?t:"custom",A=new Map,Xt=500;function It(t){let i=null,r=Tt(a=>{switch(a.type){case"open":T(`app:open:${X(a.tool,t)}`);break;case"home":T("app:home");break;case"workspace":{let o=a.workspace;T("app:workspace",{counts:{open:Array.isArray(o?.open)?o.open.length:0}});break}case"settings":{let o=a.settings&&typeof a.settings=="object"?Object.keys(a.settings).filter(n=>/^[A-Za-z0-9_.]{1,64}$/.test(n)).slice(0,16):[];T("app:settings",{fields:o});break}case"run":{let o=a.run;if(!o?.id||!o.status||!/^[a-z]+$/.test(o.status)||A.get(o.id)===o.status)break;A.size>=Xt&&A.delete(A.keys().next().value),A.set(o.id,o.status),T(`app:run_${o.status}:${X(o.tool,t)}`,{fields:[o.by==="app"?"app":"assistant"],ok:o.status!=="failed"});break}}}),b=Rt(a=>{let o=/^[a-z]+$/.test(a.view)?a.view:"other",n=`${a.project}|${o}|${a.tool??""}`;n!==i&&(i=n,T(o==="tool"?`app:view:tool:${X(a.tool,t)}`:`app:view:${o}`))});return()=>{r(),b()}}bt();var Yt=Number(v("CONFORM_HTTP_PORT")??7791);v("CONFORM_EXIT_WITH_PARENT")==="1"&&(N.stdin.on("end",()=>N.exit(0)),N.stdin.on("close",()=>N.exit(0)),N.stdin.resume());yt(Jt(v("CONFORM_EXIT_WITH_PARENT")));It(new Set([...kt.map(t=>t.id),...$.map(t=>t.name),"context","source"]));var Y=v("CONFORM_HTTP_TOKEN")??"",Gt=(v("CONFORM_HTTP_ORIGINS")??"https://conform.tools,https://app.conform.tools,http://localhost:5173,http://localhost:3000").split(","),z=(t,i=new Headers)=>{let r=t.headers.get("origin")??"";return Gt.includes(r)&&i.set("access-control-allow-origin",r),i.set("access-control-allow-headers","authorization, content-type, x-conform-client, x-conform-poll"),i.set("access-control-allow-methods","GET, POST, PUT, DELETE, OPTIONS"),i.set("access-control-allow-private-network","true"),i.set("vary","origin"),i},Ht=new Set,g=(t,i,r=200)=>new Response(JSON.stringify(i),{status:r,headers:z(t,new Headers({"content-type":"application/json"}))});rt({hostname:"127.0.0.1",port:Yt,onListen:t=>{Ht=new Set([`127.0.0.1:${t}`,`localhost:${t}`,`[::1]:${t}`]),console.error(`conformtools HTTP API on http://127.0.0.1:${t} (${$.length} verbs)`),jt(t,Y)}},async t=>{let i=new URL(t.url),r=(t.headers.get("host")??"").toLowerCase();if(!Ht.has(r))return new Response("forbidden host",{status:403});let b=t.headers.get("origin");if(b&&!Gt.includes(b))return new Response("forbidden origin",{status:403});if(t.method==="OPTIONS")return new Response(null,{status:204,headers:z(t)});if((t.method==="POST"||t.method==="PUT")&&t.headers.get("content-length")!=="0"&&!zt(i.pathname,t.headers.get("content-type")))return g(t,{ok:!1,code:"unsupported_media_type",message:"send the body as application/json"},415);if(Y&&t.headers.get("authorization")!==`Bearer ${Y}`&&i.pathname!=="/health")return g(t,{ok:!1,code:"unauthorized"},401);let a=i.pathname.split("/").filter(Boolean);try{if(i.pathname==="/health")return g(t,{ok:!0,verbs:$.length,version:at,engine:G()});if(a[0]==="verbs"&&a.length===1&&t.method==="GET")return g(t,$.map(n=>({name:n.name,title:n.title,description:n.description,long:!!n.long,input_schema:ct(it.object(n.inputSchema)),protected_stages:n.protectedStages??[],engine:G()})));if(a[0]==="verbs"&&a.length===2&&t.method==="POST"){let n=Mt(a[1]);if(!n)return g(t,{ok:!1,code:"not_found",message:`unknown verb ${a[1]}`},404);let d=t.headers.get("content-type")?.includes("json")?await t.json():{},_=Nt(n.name,d);if(!_.ok)return g(t,{..._.result.structuredContent,text:_.result.content[0].text},400);let e=t.headers.get("x-conform-client"),s=e?null:Pt(n.name,_.data,()=>void T("finish_missing"));s&&D(n.name,s,0,Object.keys(_.data));let c=s??await O(n.name,_.data,{client:e??"http",poll:t.headers.get("x-conform-poll")==="1"});return g(t,{...c.structuredContent??{ok:!c.isError},text:c.content.map(p=>p.text).join(`
6
- `)},c.isError?422:200)}if(a[0]==="debug"&&a.length===3&&t.method==="POST"&&v("CONFORM_DEBUG_BRIDGE")==="1"){let{hostBridge:n}=await import("./bridge-42OMO43V.js"),d=await n();return await d.waitFor(a[1],5e3)?g(t,{ok:!0,result:await d.request(a[1],a[2],t.headers.get("content-type")?.includes("json")?await t.json():{},12e4)}):g(t,{ok:!1,code:"not_connected"},409)}let o=await Ft(t,a,(n,d)=>g(t,n,d),n=>new Response(n,{headers:z(t,new Headers({"content-type":"text/event-stream","cache-control":"no-cache"}))}),(n,d)=>new Response(n,{headers:z(t,new Headers({"content-type":d,"cache-control":"no-store"}))}));if(o)return o;if(a[0]==="jobs"&&a.length===1)return g(t,await At());if(a[0]==="jobs"&&a.length===2){if(t.method==="DELETE")return g(t,{ok:$t(a[1])});let n=await Ct(a[1]);return n?g(t,n):g(t,{ok:!1,code:"not_found"},404)}return g(t,{ok:!1,code:"not_found"},404)}catch(o){return g(t,{ok:!1,code:"internal",message:o instanceof Error?o.message:String(o)},500)}});
6
+ `)},c.isError?422:200)}if(a[0]==="debug"&&a.length===3&&t.method==="POST"&&v("CONFORM_DEBUG_BRIDGE")==="1"){let{hostBridge:n}=await import("./bridge-GLW34YZF.js"),d=await n();return await d.waitFor(a[1],5e3)?g(t,{ok:!0,result:await d.request(a[1],a[2],t.headers.get("content-type")?.includes("json")?await t.json():{},12e4)}):g(t,{ok:!1,code:"not_connected"},409)}let o=await Ft(t,a,(n,d)=>g(t,n,d),n=>new Response(n,{headers:z(t,new Headers({"content-type":"text/event-stream","cache-control":"no-cache"}))}),(n,d)=>new Response(n,{headers:z(t,new Headers({"content-type":d,"cache-control":"no-store"}))}));if(o)return o;if(a[0]==="jobs"&&a.length===1)return g(t,await At());if(a[0]==="jobs"&&a.length===2){if(t.method==="DELETE")return g(t,{ok:$t(a[1])});let n=await Ct(a[1]);return n?g(t,n):g(t,{ok:!1,code:"not_found"},404)}return g(t,{ok:!1,code:"not_found"},404)}catch(o){return g(t,{ok:!1,code:"internal",message:o instanceof Error?o.message:String(o)},500)}});