conformtools 0.6.17 → 0.6.19
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/README.md +3 -2
- package/dist/account-KSE6H6DJ.js +3 -0
- package/dist/{agent-hook-setup-HBT2LTVR.js → agent-hook-setup-SHZOVJYL.js} +1 -1
- package/dist/{analysis-engine-BZUEBW55.js → analysis-engine-KUGSWNQB.js} +1 -1
- package/dist/{bridge-DRC6BQFR.js → bridge-REYIYXUU.js} +1 -1
- package/dist/browser/timeline_core_bg.wasm +0 -0
- package/dist/{chunk-MTAXVOHK.js → chunk-2DEUYEQD.js} +1 -1
- package/dist/{chunk-STGGRRYM.js → chunk-2GRXBIJB.js} +1 -1
- package/dist/{chunk-GRJLKGBG.js → chunk-3DYCTUSQ.js} +1 -1
- package/dist/{chunk-M5CEBOLK.js → chunk-3J2FARFO.js} +1 -1
- package/dist/chunk-4KMSOMLG.js +524 -0
- package/dist/chunk-4PV2UTKG.js +10 -0
- package/dist/{chunk-RITYQNOO.js → chunk-567IWIX6.js} +1 -1
- package/dist/{chunk-73RFYAVG.js → chunk-ATEWMIY5.js} +1 -1
- package/dist/{chunk-TWHNQFKI.js → chunk-BD54PRSN.js} +1 -1
- package/dist/{chunk-NN444GPH.js → chunk-BZQAUU3D.js} +1 -1
- package/dist/chunk-COALWMI7.js +4 -0
- package/dist/{chunk-JT3HI632.js → chunk-CUZVK2JJ.js} +1 -1
- package/dist/{chunk-MVQ5RGZB.js → chunk-EWW5KWAO.js} +1 -1
- package/dist/{chunk-CRMGV32N.js → chunk-GTN62ZQV.js} +1 -1
- package/dist/{chunk-S5AOIOTT.js → chunk-HKHEL4MZ.js} +1 -1
- package/dist/chunk-HZG55H3B.js +3 -0
- package/dist/{chunk-QNF4NMIW.js → chunk-L2RTMZCN.js} +1 -1
- package/dist/{chunk-UBWUED67.js → chunk-LUKA7UUJ.js} +1 -1
- package/dist/chunk-MJKISVPS.js +7 -0
- package/dist/{chunk-IG2X534U.js → chunk-ND2YUUUH.js} +1 -1
- package/dist/{chunk-2VH2Z6RD.js → chunk-NHVH373D.js} +1 -1
- package/dist/chunk-NQD6H7SY.js +7 -0
- package/dist/chunk-PY6HS3EP.js +10 -0
- package/dist/{chunk-YGAAGTLE.js → chunk-TD3ZHREE.js} +1 -1
- package/dist/chunk-UWEM5YEM.js +161 -0
- package/dist/{chunk-R2WEXCVQ.js → chunk-WM7ESQLY.js} +1 -1
- package/dist/{chunk-2SDAOYP5.js → chunk-WNDA7QSY.js} +1 -1
- package/dist/{chunk-S2WAFMRV.js → chunk-XQON6ASI.js} +1 -1
- package/dist/chunk-Y7PFSVRX.js +3 -0
- package/dist/{claude-setup-W27DLJIO.js → claude-setup-ZOEQ5NXE.js} +1 -1
- package/dist/cli.js +2 -2
- package/dist/{cr3-wasm-VUEEZYKQ.js → cr3-wasm-DIWL7CPH.js} +1 -1
- package/dist/demo-engine-ZX24TAXA.js +3 -0
- package/dist/{dng-wasm-5RQBGYAK.js → dng-wasm-PE463PG2.js} +1 -1
- package/dist/{dpx-wasm-OQVTNGOB.js → dpx-wasm-DKE3LJ6Z.js} +1 -1
- package/dist/engine-K6QYU5KJ.js +5 -0
- package/dist/{exr-wasm-72YZFOME.js → exr-wasm-HAFH3YA5.js} +1 -1
- package/dist/framing-B6LP7MS2.js +3 -0
- package/dist/gfx-worker.js +1 -1
- package/dist/{h264-QCYEI6RF.js → h264-YX5KP63E.js} +1 -1
- package/dist/{h264-mxf-2BYKXDGT.js → h264-mxf-VAHIJCA7.js} +1 -1
- package/dist/hook.js +3 -2
- package/dist/host-relink-VYEOE3NE.js +10 -0
- package/dist/hosted-NLYSTYYN.js +3 -0
- package/dist/hosts-47EW33NY.js +3 -0
- package/dist/http.js +4 -3
- package/dist/{inspect-R4RWCK3X.js → inspect-QRHOFMC2.js} +18 -18
- package/dist/{isobmff-RH4JKUUB.js → isobmff-RHP3N5K2.js} +1 -1
- package/dist/{mc-video-MMKWEKFZ.js → mc-video-CHBOYPI5.js} +1 -1
- package/dist/mcp.js +8 -8
- package/dist/media-TPGEESEU.js +3 -0
- package/dist/{media_core_bg-FDL7GJZP.js → media_core_bg-ZMRCKALR.js} +1 -1
- package/dist/{mxf-7HFFEBNW.js → mxf-R2ONKSYU.js} +1 -1
- package/dist/{ops-EM345H7F.js → ops-MKDFWWPG.js} +1 -1
- package/dist/{probe-YDOFGCGD.js → probe-CHT266NN.js} +1 -1
- package/dist/{r3d-DDOTSYZH.js → r3d-EKISZSKU.js} +1 -1
- package/dist/{r3d-G34YLXXA.js → r3d-F4OWLQE2.js} +1 -1
- package/dist/resolve-bridge.py +173 -27
- package/dist/{sequence-patch-2S7IPE52.js → sequence-patch-6FSMBG7O.js} +1 -1
- package/dist/{still-AGBF3OOY.js → still-IDLCMQRD.js} +1 -1
- package/dist/{still-wasm-6YLI6NQQ.js → still-wasm-54HEDTRX.js} +1 -1
- package/dist/{store-LWUDJD76.js → store-CFQHKBGL.js} +1 -1
- package/dist/{tiff-wasm-6APT7FYP.js → tiff-wasm-O7XUGXIO.js} +1 -1
- package/dist/timeline-MZ6A3PQX.js +3 -0
- package/dist/timeline_core-6BRZG4LP.js +3 -0
- package/dist/{wav-CV43ZAJI.js → wav-OLA3QYFJ.js} +1 -1
- package/package.json +5 -5
- package/dist/account-VXAKXGY6.js +0 -3
- package/dist/chunk-CZ6OZKR6.js +0 -516
- package/dist/chunk-GTPTZRO6.js +0 -3
- package/dist/chunk-JTRM2JCE.js +0 -7
- package/dist/chunk-LVGGCRDW.js +0 -3
- package/dist/chunk-P4PCSGEH.js +0 -10
- package/dist/chunk-ROGMKTND.js +0 -4
- package/dist/chunk-T7S2UBNN.js +0 -7
- package/dist/chunk-VCBLWNQR.js +0 -160
- package/dist/chunk-WKNX742H.js +0 -10
- package/dist/demo-engine-5TCNOTTH.js +0 -3
- package/dist/engine-4X6TDWWA.js +0 -5
- package/dist/framing-HGW5RCUA.js +0 -3
- package/dist/host-relink-37DCSN47.js +0 -10
- package/dist/hosted-M2OZSONX.js +0 -3
- package/dist/hosts-IAJTORJD.js +0 -3
- package/dist/media-6MB7EKA7.js +0 -3
- package/dist/timeline-EZ6WUHCB.js +0 -3
- package/dist/timeline_core-ZKQQHUA2.js +0 -3
- /package/dist/{arriraw-GZ63YMLZ.js → arriraw-PS6V532Y.js} +0 -0
- /package/dist/{chunk-D6YDLKSA.js → chunk-LMRPCWHV.js} +0 -0
- /package/dist/{media_core_bg-XRBVKQZH.js → media_core_bg-57CDWER6.js} +0 -0
- /package/dist/{prores-RIG37OIH.js → prores-CFX64NME.js} +0 -0
- /package/dist/{timeline_core_bg-JW42YM3G.js → timeline_core_bg-5COJCLPG.js} +0 -0
- /package/dist/{udf_bg-B37GKRIH.js → udf_bg-HOHEKAVF.js} +0 -0
|
@@ -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,b}from"./chunk-
|
|
3
|
+
import{a,b}from"./chunk-LUKA7UUJ.js";import"./chunk-L2RTMZCN.js";import"./chunk-PSANHDZM.js";export{b as decodeDpxWasm,a as inspectDpxWasm};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
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-ZX24TAXA.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(`
|
|
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-ZX24TAXA.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-ZX24TAXA.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-ZX24TAXA.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};
|
|
@@ -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,b}from"./chunk-
|
|
3
|
+
import{a,b}from"./chunk-ATEWMIY5.js";import"./chunk-L2RTMZCN.js";import"./chunk-PSANHDZM.js";export{b as decodeExrWasm,a as inspectExrWasm};
|
|
@@ -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{jc as a,kc as b,lc as c,mc as d,nc as e,oc as f,pc as g,qc as h,rc as i,sc as j,tc as k,uc as l,vc as m,wc as n,xc as o}from"./chunk-UWEM5YEM.js";import"./chunk-IN6XVTUS.js";import"./chunk-4PV2UTKG.js";import"./chunk-3PVQ5QP4.js";import"./chunk-VFXMP7IF.js";import"./chunk-BD54PRSN.js";import"./chunk-LUKA7UUJ.js";import"./chunk-ATEWMIY5.js";import"./chunk-2GRXBIJB.js";import"./chunk-EWW5KWAO.js";import"./chunk-567IWIX6.js";import"./chunk-OSUIS4JU.js";import"./chunk-JV7TZDKJ.js";import"./chunk-BBCQMZQN.js";import"./chunk-2DEUYEQD.js";import"./chunk-TD3ZHREE.js";import"./chunk-ND2YUUUH.js";import"./chunk-NQD6H7SY.js";import"./chunk-3J2FARFO.js";import"./chunk-Y7PFSVRX.js";import"./chunk-C2ESM27Z.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import"./chunk-L2RTMZCN.js";import"./chunk-GTN62ZQV.js";import"./chunk-MJKISVPS.js";import"./chunk-BZQAUU3D.js";import"./chunk-COALWMI7.js";import"./chunk-HZG55H3B.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};
|
package/dist/gfx-worker.js
CHANGED
|
@@ -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-
|
|
3
|
+
import{a as h,b as d,j as w,l as _}from"./chunk-NHVH373D.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import{Ha as u,U as l,W as g}from"./chunk-L2RTMZCN.js";import"./chunk-COALWMI7.js";import{x as y}from"./chunk-HZG55H3B.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)})}});
|
|
@@ -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 O}from"./chunk-TK55FA56.js";import"./chunk-PSANHDZM.js";function v(e,n,t,f){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]),c=8;if(o===1){let l=s.getUint32(r+8),g=s.getUint32(r+12);o=l*2**32+g,c=16}else o===0&&(o=t-r);if(o<c||r+o>t)break;f(a,r+c,r+o),r+=o}}var E=new Set(["moov","trak","mdia","minf","stbl"]);function D(e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=null,f=(r,o)=>{let a={},c=!1,l=(g,w)=>{v(e,g,w,(y,i,p)=>{if(E.has(y)){l(i,p);return}if(!(!c&&y!=="hdlr"&&y!=="stsd"))switch(y){case"hdlr":{String.fromCharCode(e[i+8],e[i+9],e[i+10],e[i+11])==="vide"&&(c=!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),c&&a.chunkOffsets&&a.sampleSizes&&a.sampleToChunk&&(t=a)};if(((r,o)=>{v(e,r,o,(a,c,l)=>{a==="moov"&&v(e,c,l,(g,w,y)=>{g==="trak"&&f(w,y)})})})(0,e.length),!t)throw new Error("could not find a video sample table");return t}function V(e){let n=[],t=0;for(let f=0;f<e.chunkOffsets.length;f++){let s=1;for(let o=0;o<e.sampleToChunk.length;o++)f+1>=e.sampleToChunk[o].firstChunk&&(s=e.sampleToChunk[o].samplesPerChunk);let r=e.chunkOffsets[f];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,f){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)===f)return[r+a,r+o];if(o<a)break;r+=o}return null}function H(e,n,t,f){let s=[n,t];for(let r of f){if(!s)return null;s=S(e,s[0],s[1],r)}return s}function M(e,n,t){let f=S(e,n[0],n[1],"stts");if(!f)return new Int32Array(0);let s=t.getUint32(f[0]+4),r=[],o=0,a=f[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 c=r.length,l=S(e,n[0],n[1],"ctts"),g=new Float64Array(c);for(let i=0;i<c;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<c;m++){let d=t.getUint32(p),h=t.getInt32(p+4);for(let k=0;k<d&&u<c;k++)g[u++]+=h;p+=8}}let w=Array.from({length:c},(i,p)=>p).sort((i,p)=>g[i]-g[p]||i-p),y=new Int32Array(c);for(let i=0;i<c;i++)y[w[i]]=i;return y}function I(e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=S(e,0,e.length,"moov"),[f,s]=t??[0,e.length],r=f;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 c=H(e,r+a,r+o,["mdia","minf","stbl"]);if(c){let l=S(e,c[0],c[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=M(e,c,n),k=h.length,C=S(e,c[0],c[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 x=8,R=1500,F=new WeakMap;async function L(e){let n=F.get(e);return n||(n=q(e),F.set(e,n)),n}async function q(e){if(typeof VideoDecoder>"u")throw new Error("h264: WebCodecs (VideoDecoder) not available in this context");let n=e.parts[0],t=await O({fileSize:n.fileSize,read:n.read}),f=V(D(t)),s=I(t);if(!s)throw new Error("h264: no H.264/HEVC config in container");let r=s.decodeToPres.length||f.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]:f.length;a.push([g,w])}let c={offs:f,cfg:s,gops:a,presToDecode:o,count:r,dec:null,wanted:-1,got:null,gotResolve:null,fedThrough:-1,queue:Promise.resolve()};return c.dec=new VideoDecoder({output:l=>{Number(l.timestamp)===c.wanted&&!c.got?(c.got=l,c.gotResolve?.()):l.close()},error:()=>{c.fedThrough=-1}}),c.dec.configure({codec:s.codec,description:s.description,optimizeForLatency:!0,hardwareAcceleration:"prefer-hardware"}),c}function B(e,n){let t=0,f=e.length-1,s=0;for(;t<=f;){let r=t+f>>1;e[r][0]<=n?(s=r,t=r+1):f=r-1}return s}async function $(e){let n=e.codedWidth,t=e.codedHeight;try{let f=n*t*4,s=new Uint8Array(f);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 N(e,n){let t=await L(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 f,s=new Promise(o=>{f=o}),r=t.queue;t.queue=t.queue.then(()=>s),await r;try{let o=e.parts[0],a=t.presToDecode[n],c=B(t.gops,a),[l,g]=t.gops[c];for(let w=0;w<2;w++){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+x);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,R));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 $(d)}finally{d.close()}}throw new Error(`h264: frame ${n} did not decode`)}finally{f()}}async function A(){return(await import("./isobmff-
|
|
3
|
+
import{a as O}from"./chunk-TK55FA56.js";import"./chunk-PSANHDZM.js";function v(e,n,t,f){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]),c=8;if(o===1){let l=s.getUint32(r+8),g=s.getUint32(r+12);o=l*2**32+g,c=16}else o===0&&(o=t-r);if(o<c||r+o>t)break;f(a,r+c,r+o),r+=o}}var E=new Set(["moov","trak","mdia","minf","stbl"]);function D(e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=null,f=(r,o)=>{let a={},c=!1,l=(g,w)=>{v(e,g,w,(y,i,p)=>{if(E.has(y)){l(i,p);return}if(!(!c&&y!=="hdlr"&&y!=="stsd"))switch(y){case"hdlr":{String.fromCharCode(e[i+8],e[i+9],e[i+10],e[i+11])==="vide"&&(c=!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),c&&a.chunkOffsets&&a.sampleSizes&&a.sampleToChunk&&(t=a)};if(((r,o)=>{v(e,r,o,(a,c,l)=>{a==="moov"&&v(e,c,l,(g,w,y)=>{g==="trak"&&f(w,y)})})})(0,e.length),!t)throw new Error("could not find a video sample table");return t}function V(e){let n=[],t=0;for(let f=0;f<e.chunkOffsets.length;f++){let s=1;for(let o=0;o<e.sampleToChunk.length;o++)f+1>=e.sampleToChunk[o].firstChunk&&(s=e.sampleToChunk[o].samplesPerChunk);let r=e.chunkOffsets[f];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,f){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)===f)return[r+a,r+o];if(o<a)break;r+=o}return null}function H(e,n,t,f){let s=[n,t];for(let r of f){if(!s)return null;s=S(e,s[0],s[1],r)}return s}function M(e,n,t){let f=S(e,n[0],n[1],"stts");if(!f)return new Int32Array(0);let s=t.getUint32(f[0]+4),r=[],o=0,a=f[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 c=r.length,l=S(e,n[0],n[1],"ctts"),g=new Float64Array(c);for(let i=0;i<c;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<c;m++){let d=t.getUint32(p),h=t.getInt32(p+4);for(let k=0;k<d&&u<c;k++)g[u++]+=h;p+=8}}let w=Array.from({length:c},(i,p)=>p).sort((i,p)=>g[i]-g[p]||i-p),y=new Int32Array(c);for(let i=0;i<c;i++)y[w[i]]=i;return y}function I(e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=S(e,0,e.length,"moov"),[f,s]=t??[0,e.length],r=f;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 c=H(e,r+a,r+o,["mdia","minf","stbl"]);if(c){let l=S(e,c[0],c[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=M(e,c,n),k=h.length,C=S(e,c[0],c[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 x=8,R=1500,F=new WeakMap;async function L(e){let n=F.get(e);return n||(n=q(e),F.set(e,n)),n}async function q(e){if(typeof VideoDecoder>"u")throw new Error("h264: WebCodecs (VideoDecoder) not available in this context");let n=e.parts[0],t=await O({fileSize:n.fileSize,read:n.read}),f=V(D(t)),s=I(t);if(!s)throw new Error("h264: no H.264/HEVC config in container");let r=s.decodeToPres.length||f.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]:f.length;a.push([g,w])}let c={offs:f,cfg:s,gops:a,presToDecode:o,count:r,dec:null,wanted:-1,got:null,gotResolve:null,fedThrough:-1,queue:Promise.resolve()};return c.dec=new VideoDecoder({output:l=>{Number(l.timestamp)===c.wanted&&!c.got?(c.got=l,c.gotResolve?.()):l.close()},error:()=>{c.fedThrough=-1}}),c.dec.configure({codec:s.codec,description:s.description,optimizeForLatency:!0,hardwareAcceleration:"prefer-hardware"}),c}function B(e,n){let t=0,f=e.length-1,s=0;for(;t<=f;){let r=t+f>>1;e[r][0]<=n?(s=r,t=r+1):f=r-1}return s}async function $(e){let n=e.codedWidth,t=e.codedHeight;try{let f=n*t*4,s=new Uint8Array(f);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 N(e,n){let t=await L(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 f,s=new Promise(o=>{f=o}),r=t.queue;t.queue=t.queue.then(()=>s),await r;try{let o=e.parts[0],a=t.presToDecode[n],c=B(t.gops,a),[l,g]=t.gops[c];for(let w=0;w<2;w++){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+x);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,R));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 $(d)}finally{d.close()}}throw new Error(`h264: frame ${n} did not decode`)}finally{f()}}async function A(){return(await import("./isobmff-RHP3N5K2.js")).isobmffFormat}var J={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 N(e,n)}};export{J 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{Ha as v,na as g,pa as b}from"./chunk-
|
|
3
|
+
import{Ha as v,na as g,pa as b}from"./chunk-L2RTMZCN.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-R2ONKSYU.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};
|
package/dist/hook.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{appendFileSync as
|
|
3
|
-
`),"queued"):"nothing"}catch{return"nothing"}}if(import.meta.main??/hook\.(js|ts)$/.test(process.argv[1]??"")){let
|
|
2
|
+
import{appendFileSync as on,mkdirSync as rn,readFileSync as g}from"node:fs";import{join as l}from"node:path";import{homedir as sn}from"node:os";import{randomUUID as ln}from"node:crypto";var E=new Set(["ffmpeg","ffprobe","ffplay","sox","soxi","mediainfo","exiftool","mkvmerge","mkvextract","mp4box","bmxtranswrap","raw2rgb","redline","art-cmd","oiiotool","iconvert","idiff","asdcp-wrap","asdcp-unwrap","asdcp-info","opendcp","dcp_inspect","handbrakecli","gst-launch-1.0","mencoder","mplayer","sips","afconvert","avconvert","qtfaststart","mediaconch","bwfmetaedit","x264","x265","aomenc","svtav1encapp","otiotool","otioconvert","otioview","cineform","ale2csv"]),S=["mov","mp4","m4v","mxf","mkv","avi","webm","mts","m2ts","mpg","mpeg","r3d","braw","ari","arx","crm","dng","dpx","exr","wav","aif","aiff","bwf","flac","mp3","aac","m4a","caf"],A=["aaf","avb","edl","drt","otio","fcpxml","fcpxmld","prproj","ptx","ale","xml","csv"],m=new Set(["xml","csv","png","jpg","jpeg","tif","tiff"]),v=new Set([...S,...A,...m]),T=new Set(["sudo","env","time","nice","nohup","command","exec","xargs","caffeinate","stdbuf","timeout","doas"]),d=t=>(t.replace(/^["']+|["']+$/g,"").split(/[\\/]/).pop()??t).toLowerCase();function O(t){let n=[];for(let o of t.split(/\|\||&&|;|\||\n|\$\(|`/)){let e=o.trim().split(/\s+/).filter(Boolean),r=0;for(;r<e.length&&(/^[A-Za-z_][A-Za-z0-9_]*=/.test(e[r])||T.has(d(e[r]))||e[r].startsWith("-")||/^\d+$/.test(e[r]));)r++;let s=e[r];if(!s)continue;let i=d(s);/^[a-z0-9_.+-]{1,32}$/.test(i)&&!n.includes(i)&&n.push(i)}return n}function C(t){let n=new Set;for(let o of t.matchAll(/\.([A-Za-z0-9]{2,7})(?=["'\s)\]|;,>]|$)/g)){let e=o[1].toLowerCase();v.has(e)&&n.add(e)}return[...n].sort()}function N(t){if(!t||typeof t!="object")return null;let n=t;if(n.hook_event_name==="afterShellExecution"&&typeof n.command=="string")return{command:n.command,client:"cursor"};let o=n.tool_input;if(n.tool_name==="Bash"&&o&&typeof o=="object"&&typeof o.command=="string"){let e=typeof n.transcript_path=="string"?n.transcript_path:"";return{command:o.command,client:/[\\/]\.codex[\\/]/.test(e)?"codex":/[\\/]\.claude[\\/]/.test(e)?"claude-code":null}}return null}function h(t){let n=N(t);if(!n)return null;let o=O(n.command),e=C(n.command),r=o.filter(i=>E.has(i)),s=e.filter(i=>!m.has(i));return!r.length&&!s.length?null:{verb:`shell:${r[0]??o[0]??"sh"}`,fields:e.slice(0,16),counts:{programs:o.length,media_programs:r.length,extensions:e.length},client:n.client}}var D=t=>t&&typeof t=="object"&&!Array.isArray(t)?t:{};function _(t){return D(t).hook_event_name==="UserPromptSubmit"?"conform.tools: if this message asks for media, timeline or conform work (a follow-up too), call conformtools begin before anything else, asked = this message word for word with only each show, client, person, clip, reel, scene, file and path swapped for a {placeholder}.":null}var I=new Set("const let var await async for of in if else return new true false null undefined function try catch finally throw break continue while do typeof instanceof switch case default void delete yield this".split(" ")),M=new Set("ct length map filter push forEach find findIndex some every join split includes slice sort reverse concat flat flatMap reduce indexOf Object keys values entries assign Array from isArray JSON stringify parse Math round min max abs floor ceil console log Promise all allSettled Set Map has add get set size String Number Boolean trim startsWith endsWith replace toLowerCase toUpperCase toFixed padStart then error ok".split(" "));var P=/\{(?:path\.[a-z0-9]{1,8}|path|str|n)\}|[A-Za-z_$][A-Za-z0-9_$]*|\s+|[^A-Za-z0-9_$\s{}'"`]|[{}]/g,L=/^(?:v\d+|[a-z][a-z0-9_]{0,40})$/;function b(t){if(typeof t!="string"||!t||t.length>8e3)return!1;let n=0;for(let o of t.matchAll(P)){n+=o[0].length;let e=o[0];if(/^[A-Za-z_$]/.test(e)&&!(I.has(e)||M.has(e)||L.test(e)))return!1}return n===t.length}var gn=256*1024;var p=String.raw`[^\s"'${"`"}<>|,;()[\]{}\\/]+(?: [^\s"'${"`"}<>|,;()[\]{}\\/:]+(?=$|[\s"'${"`"}<>|,;()[\]{}\\/]))*`,y=String.raw`[^\s"'${"`"}<>|,;()[\]{}\\/]+`,$=new RegExp(String.raw`(?<![A-Za-z0-9_.~:\\/-])(?:file://)?(?:~|[A-Za-z]:)?(?:[\\/]${p}){2,}[\\/]?|\\\\${p}(?:\\${p})+`+String.raw`|(?<![A-Za-z0-9_.~:\\/-])${y}(?:[\\/]${y}){2,}`,"g");function z(t){let n=t.replace(/[\\/]+$/,""),o=Math.max(n.lastIndexOf("/"),n.lastIndexOf("\\"));return o>=0?n.slice(o+1):n}var j=(t,n)=>t.length>n?`${t.slice(0,n)}\u2026`:t;var F=/^[A-Za-z0-9_.:-]{1,64}$/;function u(t){return typeof t=="string"&&F.test(t)?t:null}var a=(t,n)=>typeof t=="string"&&n.includes(t)?t:null,H=600,U=["solved","partly","failed"],Z=new Set("AAF EDL XML DCP KDM IMF VFX QC OCF MOV MP4 MXF LUT CDL ACES HDR SDR VFR CFR ISO AVB DRT DRP FCP FCPXML OTIO RGB YUV ARRI RED BRAW DNX DNXHD DNXHR HEVC AVC PRORES EXR DPX TIFF TIF PNG JPG JPEG WAV AIFF OMF LTFS UHD NLE API CLI MCP PDF CSV JSON SRT SCC STL TTML PAL NTSC SMPTE LTC VITC CST IDT ODT RRT ALE ASC TC GPU CPU SSD NAS USB HDD MAM DIT VND RAW CC SFX ADR MNE ME LFE HFR DCI DCDM AUDIO NOTE TODO ALL ANY EVERY EACH ONLY NOT NEW OLD AND THE FOR WITH NEVER ALWAYS MUST".split(" ")),q=/\b(?:https?|ftp|s3|gs|file):\/\/\S+/gi,X=/\b[\w.+-]+@[\w-]+(?:\.[\w-]+)+\b/g,V=/\b(?:\d{1,3}\.){3}\d{1,3}(?::\d{1,5})?\b|\[[0-9a-f:.]{2,45}\](?::\d{1,5})?|(?<![\w:])(?:[0-9a-f]{1,4}:){7}[0-9a-f]{1,4}(?![\w:])|(?<![\w:])(?:[0-9a-f]{1,4}:)*[0-9a-f]{0,4}::(?:[0-9a-f]{1,4}(?::[0-9a-f]{1,4})*)?(?![\w:])/gi,G=/\b\d{1,2}[:;]\d{2}[:;]\d{2}[:;.]\d{2,3}\b/g,K=/"[^"]{1,200}"|“[^”]{1,200}”|‘[^’]{1,200}’|(?<![A-Za-z])'[^']{1,200}'(?![A-Za-z])/g,Y=/(?<![{\w])[\w][\w.+-]+\.[A-Za-z][A-Za-z0-9]{1,4}\b/g,J=/(?<![{\w])(?=[\w-]*[A-Za-z])(?=[\w-]*\d)(?:[\w]+[_-][\w-]+|[A-Za-z]+\d+[A-Za-z]+\d+\w*)(?![\w}])/g,B=/(?<![{\w])[A-Z][A-Z0-9&]{2,}(?:\s+[A-Z][A-Z0-9&]{2,})*(?![\w}])/g;function f(t,n=H){if(typeof t!="string")return null;let o=t.replace(/\s+/g," ").trim();return o?(o=o.replace(q,"{url}").replace(X,"{email}").replace(V,"{ip}").replace($,e=>{let r=z(e),s=r.indexOf(" ");return`{path}${s>=0?r.slice(s):""}`}).replace(K,"{text}").replace(G,"{tc}").replace(Y,e=>e.toLowerCase()==="conform.tools"?e:"{file}").replace(J,e=>/^\d+-[a-z]+$/.test(e)?e:"{id}").replace(B,e=>e.split(/\s+/).every(r=>Z.has(r))?e:"{title}").replace(/\{([^{}]*)\}/g,(e,r)=>/^[a-z_]{1,24}$/.test(r)?`{${r}}`:"{text}"),j(o,n)):null}var W=["outcome","invalid_args","dropped"],Q=300,w=/^[A-Za-z0-9 ._()-]{1,80}$/,R=(t,n)=>typeof t=="number"&&Number.isInteger(t)&&t>0&&t<=n?t:null,nn=/^[a-z_]{1,32}$/,k=/^[A-Za-z0-9_.]{1,64}(=[a-z0-9_.-]{1,40})?$/,c=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function tn(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let n={};for(let[o,e]of Object.entries(t).slice(0,16))nn.test(o)&&typeof e=="number"&&Number.isFinite(e)&&e>=0&&(n[o]=Math.round(e));return Object.keys(n).length?n:null}var en=new Set(["host_setup","host_current"]);function x(t){if(!t||typeof t!="object")return null;let n=t,o=a(n.kind,W),e=u(n.verb);if(!o||!e||o==="outcome"&&n.ok===!0&&en.has(e))return null;let r=Array.isArray(n.fields)?n.fields.filter(s=>typeof s=="string"&&k.test(s)).slice(0,32):null;return{kind:o,verb:e,ok:o==="outcome"&&typeof n.ok=="boolean"?n.ok:null,code:u(n.code),duration_ms:typeof n.duration_ms=="number"&&Number.isFinite(n.duration_ms)&&n.duration_ms>=0?Math.round(n.duration_ms):null,version:u(n.version),engine:a(n.engine,["local","hosted"]),counts:o!=="invalid_args"?tn(n.counts):null,fields:r?.length?r:null,run_id:typeof n.run_id=="string"&&c.test(n.run_id)?n.run_id:null,seq:typeof n.seq=="number"&&Number.isInteger(n.seq)&&n.seq>0&&n.seq<1e6?n.seq:null,run_at:typeof n.run_at=="string"&&!Number.isNaN(Date.parse(n.run_at))?new Date(n.run_at).toISOString():null,event_id:typeof n.event_id=="string"&&c.test(n.event_id)?n.event_id:null,req:typeof n.req=="number"&&Number.isInteger(n.req)&&n.req>0&&n.req<1e6?n.req:null,asked:o==="outcome"?f(n.asked):null,previous:o==="outcome"?a(n.previous,U):null,previous_why:o==="outcome"?f(n.previous_why,200):null,client:typeof n.client=="string"?u(n.client.toLowerCase().replace(/[^a-z0-9_.:-]+/g,"-").slice(0,64)):null,hits:Array.isArray(n.hits)?n.hits.filter(s=>typeof s=="string"&&k.test(s)).slice(0,8):null,error:o==="outcome"&&n.ok===!1?f(n.error,Q):null,platform:typeof n.platform=="string"&&w.test(n.platform)?n.platform:null,runtime:typeof n.runtime=="string"&&w.test(n.runtime)?n.runtime:null,memory_gb:R(n.memory_gb,4096),cpus:R(n.cpus,1024),install:typeof n.install=="string"&&c.test(n.install)?n.install:null,script:o==="outcome"&&b(n.script)?n.script:null,session_id:typeof n.session_id=="string"&&c.test(n.session_id)?n.session_id:null,author:a(n.author,["claude","user"])}}var un=12*36e5;function an(t,n=process.env.CONFORM_MCP_HOME??l(sn(),".conform-mcp")){try{if(process.env.CONFORM_TELEMETRY==="off"||process.env.CONFORM_TELEMETRY==="0")return"off";let o={};try{o=JSON.parse(g(l(n,"config.json"),"utf8"))}catch{}if(o.telemetry===!1)return"off";let e=h(JSON.parse(t));if(!e)return"not media";let r={};try{r=JSON.parse(g(l(n,"telemetry","run.json"),"utf8"))}catch{}let s=typeof r.at=="string"&&Date.now()-Date.parse(r.at)<un,i=x({kind:"outcome",verb:e.verb,ok:!0,counts:e.counts,fields:e.fields,client:e.client??(s?r.client:null),run_id:s?r.run_id:null,req:s?r.req:null,event_id:ln(),run_at:new Date().toISOString(),install:o.install});return i?(rn(l(n,"telemetry"),{recursive:!0}),on(l(n,"telemetry","queue.jsonl"),JSON.stringify(i)+`
|
|
3
|
+
`),"queued"):"nothing"}catch{return"nothing"}}if(import.meta.main??/hook\.(js|ts)$/.test(process.argv[1]??"")){let t="";try{t=g(0,"utf8")}catch{}if(t.trim()){let n=null;try{n=_(JSON.parse(t))}catch{}n?process.stdout.write(n+`
|
|
4
|
+
`):an(t)}process.exit(0)}export{an as main};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
|
|
3
|
+
import{a as T}from"./chunk-XQON6ASI.js";import{c as D}from"./chunk-CUZVK2JJ.js";import{$b as N,R as M,Vb as P,dc as q}from"./chunk-UWEM5YEM.js";import"./chunk-IN6XVTUS.js";import{l as A}from"./chunk-4PV2UTKG.js";import"./chunk-3PVQ5QP4.js";import"./chunk-VFXMP7IF.js";import"./chunk-WNDA7QSY.js";import"./chunk-BD54PRSN.js";import"./chunk-LUKA7UUJ.js";import"./chunk-ATEWMIY5.js";import"./chunk-2GRXBIJB.js";import"./chunk-EWW5KWAO.js";import"./chunk-567IWIX6.js";import"./chunk-OSUIS4JU.js";import"./chunk-JV7TZDKJ.js";import"./chunk-BBCQMZQN.js";import"./chunk-2DEUYEQD.js";import"./chunk-TD3ZHREE.js";import"./chunk-ND2YUUUH.js";import"./chunk-NQD6H7SY.js";import"./chunk-3J2FARFO.js";import"./chunk-Y7PFSVRX.js";import"./chunk-C2ESM27Z.js";import"./chunk-N34DQ6MH.js";import{b as F}from"./chunk-NU3X7P4N.js";import"./chunk-L2RTMZCN.js";import"./chunk-GTN62ZQV.js";import"./chunk-MJKISVPS.js";import"./chunk-BZQAUU3D.js";import"./chunk-COALWMI7.js";import{$ as U,M as x,N as E,aa as R,ca as k,p as O,t as S}from"./chunk-HZG55H3B.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-CFQHKBGL.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
|
+
`).slice(-6).join(`
|
|
5
|
+
`)].filter(Boolean).join(`
|
|
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(`
|
|
7
|
+
`),data:{media:t,results:b.results,undo_relink:b.undo,...v?{refit:v.data}:{},from:r}}}if(i.mode==="cut_in"){let u=await s.items({timeline:i.timeline,kind:"video"}),d=Math.max(0,...u.items.map(h=>h.track)),g=i.track??d+1,_=await s.cutIn(i.timeline,n.map(h=>({path:h.path,track:g,start:h.start,src_in:h.src_in,duration:h.duration,copy_from:{track:h.track,start:h.start}}))),b=_.results.filter(h=>h.ok).length;return{text:[...c,`cut in ${b}/${n.length} on V${g} (video only, the originals untouched underneath; Edit > Undo ${_.undo_steps}\xD7 in Premiere takes the cuts${_.undo_steps>1?" and the carried sizing":""} back; each return clip keeps its in/out marks)`,...n.map((h,$)=>` V${h.track} @${h.start} ${h.name} \u2192 ${h.path.split("/").pop()} src ${h.src_in}${_.results[$]?.ok?"":` REFUSED: ${_.results[$]?.detail??""}`}`)].join(`
|
|
8
|
+
`),data:{media:t,cuts:n,results:_.results,track:g,from:r}}}let f=e.session.timelines.find(u=>u.kind==="primary")??e.session.timelines[0];f&&(f.name=i.name??`${f.name}_CONFORMED`);let a=await q(e.session,"premiere-prproj",k(await x("conform-ppro-"),"/"),""),p=await s.open({path:a.path});return{text:[...c,`new sequence "${p.timeline}" in ${p.project} (the open sequence is untouched)`,...m,...p.notes,...a.issues.slice(0,10).map(u=>` note: ${u.message}`)].join(`
|
|
9
|
+
`),data:{media:t,path:a.path,sequence:p.timeline,issues:a.issues,from:r}}}function L(s,i,o){let r=new Map,l=(e,t)=>(e.media_references??[]).find(n=>n.id===t);for(let e of o){let t=l(s,e.ref_id),n=l(i,e.ref_id),c=t?.source_resolution_w,m=t?.source_resolution_h,f=n?.source_resolution_w,a=n?.source_resolution_h;!c||!m||!f||!a||c===f||Math.abs(c/m-f/a)>.01||r.set(e.old,c/f)}return r}async function Y(s,i){let o=[];for(let r of(await s.current()).timelines){let l=await s.model(r).catch(()=>null);for(let e of l?.items??[])i.has(e.file_path)&&o.push({sequence:r,track:e.track,start:e.start-l.start_frame,file:e.file_path,zx:e.sizing.ZoomX??1,zy:e.sizing.ZoomY??e.sizing.ZoomX??1,keyframed:!!e.sizing_keyframed})}return o}async function B(s,i,o){let r=[],l={},e=new Map;for(let t of i)(e.get(t.sequence)??e.set(t.sequence,[]).get(t.sequence)).push(t);for(let[t,n]of e){let c=n.filter(a=>a.keyframed),m=n.filter(a=>!a.keyframed).map(a=>{let p=o.get(a.file);return{op:"properties",item:{kind:"video",track:a.track,start:a.start},set:{ZoomX:+(a.zx*p).toFixed(6),ZoomY:+(a.zy*p).toFixed(6)}}}),f=m.length?await s.apply({timeline:t,ops:m}):null;l[t]={rescaled:f?.applied??0,keyframed:c.length,undo:f?.undo??[]},r.push(` "${t}": ${f?.applied??0}/${m.length} use(s) rescaled to keep their framing on the new raster (one Edit > Undo)${c.length?`; ${c.length} with keyframed scale left as they are \u2014 check them`:""}`)}return{lines:["framing kept through the raster change (Premiere's Scale is a percent of the media's pixels):",...r],data:l}}async function G(s){let i=new Set;for(let e of s.timelines)for(let t of e.tracks)for(let n of t.items)n.is_adjustment&&(i.add(n.id),n.is_adjustment=!1);let o=s.timelines.flatMap(e=>e.tracks.flatMap(t=>t.items)).filter(e=>e.kind==="nested").length,r=await M(s);if(!r)throw new Error("un-nesting needs the conform.tools engine on this machine");for(let e of r.session.timelines)for(let t of e.tracks)for(let n of t.items)i.has(n.id)&&(n.is_adjustment=!0);let l=s.timelines[0]?.id;return Object.assign(s,r.session),s.timelines=s.timelines.filter(e=>e.id===l),{summary:`un-nested ${o} nest${o===1?"":"s"}`,issues:r.issues}}async function ae(s,i){let{session:o,from:r,lossy:l}=await H(s,i.timeline),e=await J(o,i.ops,i.name),t=await q(e.session,"premiere-prproj",k(await x("conform-ppro-"),"/"),""),n=await s.open({path:t.path}),c=[...e.issues,...t.issues.map(m=>m.message)];return{text:[`read from ${r}`,...l?[`\u26A0 ${l}`]:[],...e.lines,`new sequence "${n.timeline}" in ${n.project} (the open sequence is untouched)`,...c.slice(0,12).map(m=>` note: ${m}`),...c.length>12?[` \u2026and ${c.length-12} more notes`]:[]].join(`
|
|
10
|
+
`),data:{sequence:n.timeline,path:t.path,notes:c,from:r}}}async function J(s,i,o){let r=[],l=[],e=()=>s.timelines[0];for(let n of i){if(n.kind==="unnest"){let a=await G(s);r.push(a.summary),l.push(...a.issues);continue}let c=new Set(s.timelines.map(a=>a.id)),m=N(s,n.kind,{timeline_id:e()?.id,...n.args??{}});r.push(m.summary);let f=s.timelines.find(a=>!c.has(a.id)&&a.kind!=="compound");f&&(s.timelines=z(s,f).timelines)}let t=e();if(!t)throw new Error("nothing to write: the operations left no timeline");return t.name=o??(i.length===1?`${t.name}_${i[0].kind.toUpperCase()}`:`${t.name}_EDIT`),{session:z(s,t),lines:r,issues:l}}export{C as bindAtRecordedPaths,X as changes,J as editSession,ae as hostEdit,oe as hostRelink,H as premiereSession,Z as probeRefs,L as rasterRatios,I as withLiveMarkers,z as withNests,re as withOfflineReference,W as withPremiereTimecodes};
|
|
@@ -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,b,c,d}from"./chunk-3J2FARFO.js";import"./chunk-Y7PFSVRX.js";import"./chunk-C2ESM27Z.js";import"./chunk-MJKISVPS.js";import"./chunk-BZQAUU3D.js";import"./chunk-COALWMI7.js";import"./chunk-HZG55H3B.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-PY6HS3EP.js";import"./chunk-CUZVK2JJ.js";import"./chunk-UWEM5YEM.js";import"./chunk-IN6XVTUS.js";import"./chunk-4PV2UTKG.js";import"./chunk-3PVQ5QP4.js";import"./chunk-VFXMP7IF.js";import"./chunk-WNDA7QSY.js";import"./chunk-BD54PRSN.js";import"./chunk-LUKA7UUJ.js";import"./chunk-ATEWMIY5.js";import"./chunk-2GRXBIJB.js";import"./chunk-EWW5KWAO.js";import"./chunk-567IWIX6.js";import"./chunk-OSUIS4JU.js";import"./chunk-JV7TZDKJ.js";import"./chunk-BBCQMZQN.js";import"./chunk-2DEUYEQD.js";import"./chunk-TD3ZHREE.js";import"./chunk-ND2YUUUH.js";import"./chunk-NQD6H7SY.js";import"./chunk-3J2FARFO.js";import"./chunk-Y7PFSVRX.js";import"./chunk-C2ESM27Z.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import"./chunk-L2RTMZCN.js";import"./chunk-GTN62ZQV.js";import"./chunk-MJKISVPS.js";import"./chunk-BZQAUU3D.js";import"./chunk-COALWMI7.js";import"./chunk-HZG55H3B.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,5 +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-
|
|
4
|
-
|
|
5
|
-
`)},c.
|
|
3
|
+
import{a as jt}from"./chunk-WM7ESQLY.js";import{a as Tt,b as vt,c as Rt,d as Et,e as Pt,f as Ct,g as $t,h as At,k as O,l as Nt,o as $,p as Mt}from"./chunk-4KMSOMLG.js";import"./chunk-3DYCTUSQ.js";import"./chunk-XQON6ASI.js";import"./chunk-PY6HS3EP.js";import"./chunk-CUZVK2JJ.js";import"./chunk-HKHEL4MZ.js";import"./chunk-YU3SUSK3.js";import"./chunk-QTFFVLVJ.js";import"./chunk-5YULBQJX.js";import{Eb as wt,Fb as _t,G as it,H as ct,J as ht,P as W,Uc as yt,Xc as bt,Yc as D,Zc as T,ed as xt,gd as St,id as Ot,yc as kt}from"./chunk-UWEM5YEM.js";import"./chunk-IN6XVTUS.js";import"./chunk-4PV2UTKG.js";import"./chunk-3PVQ5QP4.js";import"./chunk-VFXMP7IF.js";import"./chunk-WNDA7QSY.js";import{a as at}from"./chunk-BD54PRSN.js";import"./chunk-LUKA7UUJ.js";import"./chunk-ATEWMIY5.js";import"./chunk-2GRXBIJB.js";import"./chunk-EWW5KWAO.js";import"./chunk-567IWIX6.js";import"./chunk-OSUIS4JU.js";import"./chunk-JV7TZDKJ.js";import"./chunk-BBCQMZQN.js";import"./chunk-2DEUYEQD.js";import"./chunk-TD3ZHREE.js";import"./chunk-ND2YUUUH.js";import"./chunk-NQD6H7SY.js";import"./chunk-3J2FARFO.js";import"./chunk-Y7PFSVRX.js";import"./chunk-C2ESM27Z.js";import"./chunk-LMRPCWHV.js";import"./chunk-NHVH373D.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import"./chunk-L2RTMZCN.js";import{C,E as gt,t as V,u as ut,v as dt,x as pt,y as mt,z as ft}from"./chunk-GTN62ZQV.js";import{l as lt,p as G}from"./chunk-MJKISVPS.js";import"./chunk-BZQAUU3D.js";import{a as H}from"./chunk-COALWMI7.js";import{$ as U,A as et,B as j,D as nt,H as L,M as J,N as ot,O as st,V as rt,aa as I,b as v,ca as S,n as P,t as B,u as Q,x as q,y as tt,z as F}from"./chunk-HZG55H3B.js";import"./chunk-PSANHDZM.js";import N from"node:process";var Lt=new Map;function Ut(t,i,s,b){let a=`${t}:${s}:${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${s}_${b}.cube`);if(!await Q(d)){let{adapter:_}=await import("./hosts-47EW33NY.js");if((await _("resolve").clipLut({timeline:i,track:s,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 s=(i??"").split(";")[0].trim().toLowerCase();return s==="application/json"||s==="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,s,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-KSE6H6DJ.js"),r=await fetch(`${e().supabaseUrl}/functions/v1/v1-billing/v1/billing/app-policy`,{signal:AbortSignal.timeout(3e3)}).catch(()=>null);return s(r?.ok?await r.json():{offline:!0})}if(o==="account"&&t.method==="GET"){let e=await O("account_status",{}),r=await G().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 s({...e.structuredContent,...e.structuredContent?.account??{},...r,text:e.content[0]?.text})}{let e=await G().then(()=>null,r=>r);if(e)return s({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)}:{}}),s({ok:!0})}if(o==="problem"&&t.method==="POST"){let e=await t.json().catch(()=>({}));return await D("app_window",{isError:!0,content:[],structuredContent:{code:"window_error",message:`${String(e.what??"").slice(0,200)}${e.detail?`
|
|
4
|
+
${String(e.detail).slice(0,100)}`:""}`}},0),s({ok:!0})}if(o==="convert"&&t.method==="POST"){let e=new URL(t.url).searchParams,r=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 s({ok:!1,error:"a folder and at least one format are needed"},400);let u=await J("conform-te-"),f=S(u,r);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 s({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(()=>{}),s({ok:R>0,savedCount:R,...m.length?{error:m.join(`
|
|
5
|
+
`)}:{}})}if(o==="fs"&&t.method==="POST"){let{op:e,path:r,offset:c=0,length:p=0}=await _();if(e==="statPath"){let l=await B(r).catch(()=>null);return s({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(r))(u.isFile||u.isDirectory)&&l.push({name:u.name,kind:u.isDirectory?"directory":"file"});return s({ok:!0,result:l})}if(e==="readFile"){let l=p>0?p:Math.max(0,(await B(r)).size-Math.max(0,c)),u=512<<20;if(l>u)return s({ok:!1,code:"too_large",message:`${r} is ${Math.round(l/(1<<20))} MB: read it in parts (offset, length \u2264 ${u>>20} MB)`},413);let f=await st(r);try{return a(await f.readAt(Math.max(0,c),l),"application/octet-stream")}finally{await f.close()}}return s({ok:!1,code:"bad_request",message:`no fs op ${e}`},400)}if(o==="canonicalize"&&t.method==="POST"){let e=new URL(t.url).searchParams,r=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 s({ok:!1,error:u.content[0]?.text??"could not read the timeline"},422);let h=(await C(f)).session,y=h.timelines;if(r.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 r){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 s({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,r=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:r,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,r,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 s({ok:!1,code:"no_frame",message:f.message},404)}let p=await O("timeline_frame",{session_id:n,record:r,width:c,...e.get("timeline")?{timeline:e.get("timeline")}:{}},{poll:!0}),l=p.structuredContent?.out_path;if(p.isError||!l)return s({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?s(e):s({ok:!1,code:"not_found"},404)}if(o==="sessions"&&!n)return s(await gt());if(o!=="projects")return s({ok:!1,code:"not_found"},404);if(!n){if(t.method==="POST"){let e=await _(),r=await O("project",{action:"create",name:e.name,client_name:e.client_name,handles:e.handles});return r.isError?s({...r.structuredContent,text:r.content[0]?.text},422):(await Dt(),s(r.structuredContent))}return s(await Dt())}if(!d){let[e,r,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===V?null:St().catch(()=>null)]);await pt(n===V?null:{id:n,name:e.name??n});let{text:f="",...h}=r??{};return s({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??"")),s({ok:!0});if(d==="context"&&t.method==="PUT"){let e=await _();try{let{text:r,...c}=await dt(n,String(e.text??""),e.base===void 0?void 0:e.base);return s({ok:!0,context:r,context_meta:c})}catch(r){if(r instanceof H&&r.code==="context_conflict"){let c=r.data?.current;return s({ok:!1,code:r.code,message:r.message,context:c.context,context_meta:{updated_at:c.context_updated_at,updated_by:c.context_updated_by_name??null}},409)}throw r}}return s({ok:!1,code:"not_found"},404)}catch(e){let r=e instanceof H?e:null;return s({ok:!1,code:r?.code??"internal",message:e.message},r?.code==="not_found"?404:r?.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,s=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()=>{s(),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 s=t.headers.get("origin")??"";return Gt.includes(s)&&i.set("access-control-allow-origin",s),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,s=200)=>new Response(JSON.stringify(i),{status:s,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),s=(t.headers.get("host")??"").toLowerCase();if(!Ht.has(s))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:W()});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:W()})));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"),r=e?null:Pt(n.name,_.data,()=>void T("finish_missing"));r&&D(n.name,r,0,Object.keys(_.data));let c=r??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-REYIYXUU.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)}});
|