conformtools 0.6.13 → 0.6.15
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 +6 -1
- package/dist/account-W7Z2MYZU.js +3 -0
- package/dist/{agent-hook-setup-RTQT5JEN.js → agent-hook-setup-JCIZG3Q3.js} +1 -1
- package/dist/{analysis-engine-UWIK7AYB.js → analysis-engine-DCHJHZ7W.js} +1 -1
- package/dist/{bridge-PWYOJ7E7.js → bridge-RH3JRSBN.js} +1 -1
- package/dist/browser/timeline_core_bg.wasm +0 -0
- package/dist/{chunk-LZRCXSUJ.js → chunk-4RA57LTJ.js} +1 -1
- package/dist/chunk-63WQRYTJ.js +159 -0
- package/dist/chunk-6KEFHHS6.js +10 -0
- package/dist/{chunk-4VFDGL4E.js → chunk-7NGS2BN7.js} +1 -1
- package/dist/{chunk-BYMCZJBQ.js → chunk-B2KCENY6.js} +1 -1
- package/dist/chunk-DLF5AKXT.js +10 -0
- package/dist/chunk-FLLB6UZJ.js +7 -0
- package/dist/chunk-G7CVRPVA.js +5 -0
- package/dist/chunk-HTRW5GX4.js +510 -0
- package/dist/chunk-IBIAW6IW.js +6 -0
- package/dist/{chunk-G3HBKJ5L.js → chunk-IDJIOKXA.js} +1 -1
- package/dist/chunk-OWWXUNJF.js +7 -0
- package/dist/{chunk-NZLL44HU.js → chunk-QH5DTYSE.js} +1 -1
- package/dist/{chunk-PHAMF4JF.js → chunk-ROGMKTND.js} +2 -2
- package/dist/{chunk-H4BU5WA6.js → chunk-TBU2XWFD.js} +1 -1
- package/dist/{chunk-6WLSIH2N.js → chunk-UAURERD3.js} +1 -1
- package/dist/{chunk-7W5AFZYX.js → chunk-UKXSKFL3.js} +1 -1
- package/dist/{chunk-L3HRAIDR.js → chunk-VERTA23P.js} +1 -1
- package/dist/{chunk-EP4L2BWV.js → chunk-VETHR2O7.js} +1 -1
- package/dist/chunk-X527E5VI.js +3 -0
- package/dist/{chunk-4BTTR6U3.js → chunk-XVZ7KJRI.js} +5 -5
- package/dist/{claude-setup-NGZ5NDYH.js → claude-setup-CM7G2YSG.js} +8 -8
- package/dist/cli.js +2 -2
- package/dist/demo-engine-WXNT4Y7S.js +3 -0
- package/dist/engine-HXZCA42S.js +5 -0
- package/dist/framing-HVUDKTZG.js +3 -0
- package/dist/gfx-worker.js +1 -1
- package/dist/{h264-JI62TU4W.js → h264-MAUVJTR4.js} +1 -1
- package/dist/{h264-mxf-J2QPZO4U.js → h264-mxf-2O4SAUTA.js} +1 -1
- package/dist/hook.js +1 -1
- package/dist/{host-relink-76CFY32O.js → host-relink-RI3JEY4M.js} +1 -1
- package/dist/hosted-2XACQY7J.js +3 -0
- package/dist/hosts-QW64CIJU.js +3 -0
- package/dist/http.js +3 -3
- package/dist/{inspect-U656APGR.js → inspect-NUS3XAJH.js} +2 -2
- package/dist/isobmff-MTMGQKLK.js +3 -0
- package/dist/{mc-video-LSTKUKNL.js → mc-video-HRZC7HGH.js} +1 -1
- package/dist/mcp.js +1 -1
- package/dist/{media-XBNKYKB7.js → media-WC4ZVKIL.js} +1 -1
- package/dist/{mxf-ZL57VJ3C.js → mxf-J5QHA3VY.js} +1 -1
- package/dist/{ops-ZQEQXW2N.js → ops-XIUVNJE2.js} +1 -1
- package/dist/probe-GIAKRPFV.js +3 -0
- package/dist/{r3d-R4TLYJVE.js → r3d-2PCOFR2Z.js} +1 -1
- package/dist/resolve-bridge.py +116 -146
- package/dist/{sequence-patch-C2QRIT5V.js → sequence-patch-DFGEAJGB.js} +1 -1
- package/dist/{store-JNWELX35.js → store-WZHNO43A.js} +1 -1
- package/dist/timeline-NOTHRTAT.js +3 -0
- package/package.json +5 -5
- package/dist/account-F54SG45Q.js +0 -3
- package/dist/chunk-B54TEGMG.js +0 -5
- package/dist/chunk-BTS3DFPD.js +0 -7
- package/dist/chunk-ERUN634Q.js +0 -6
- package/dist/chunk-I2Y2P5NH.js +0 -7
- package/dist/chunk-J43UCJ6G.js +0 -4
- package/dist/chunk-LKQTE6T5.js +0 -158
- package/dist/chunk-LRGA6QJQ.js +0 -514
- package/dist/chunk-OD445COC.js +0 -7
- package/dist/chunk-XI6XF7FQ.js +0 -3
- package/dist/chunk-Y455Y6V4.js +0 -10
- package/dist/engine-6ACEWA4S.js +0 -5
- package/dist/framing-P5RGN5V3.js +0 -3
- package/dist/hosted-L26AGRIY.js +0 -3
- package/dist/hosts-TBHEPV6A.js +0 -3
- package/dist/isobmff-UISATYUR.js +0 -3
- package/dist/nuke/panel/python/Startup/conformtools_nuke_startup.py +0 -44
- package/dist/nuke/panel/python/conformtools_nuke/__init__.py +0 -10
- package/dist/nuke/panel/python/conformtools_nuke/panel.py +0 -217
- package/dist/nuke/panel/python/conformtools_nuke/verbs.py +0 -837
- package/dist/probe-ZDX6XNRF.js +0 -3
- package/dist/resolve-presets/conform.tools.xml +0 -127
- package/dist/timeline-JONFBIA3.js +0 -3
|
@@ -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 P(){let e=window.__CONFORM_ENGINE__;if(e?.base)return e;let t=new URLSearchParams(window.location.search),n=c=>{try{return sessionStorage.getItem(`conform.engine.${c}`)}catch{return null}},s=(c,g)=>{try{sessionStorage.setItem(`conform.engine.${c}`,g)}catch{}},i=t.get("engine"),o=t.get("token");return i?s("url",i):i=n("url"),o?s("token",o):o=n("token"),{base:i?/^\d+$/.test(i)?`http://127.0.0.1:${i}`:i.replace(/\/$/,""):"http://127.0.0.1:7791",token:o??""}}var d=typeof window>"u"?{base:"http://127.0.0.1:7791",token:""}:P(),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-WXNT4Y7S.js").then(e=>e.answer):null,j=f!==null,v=class extends Error{constructor(n,s){super(s);this.code=n}};async function r(e,t,n,s=[],i={},o=0){if(f)return(await f)(e,t,n);let a;try{a=await fetch(`${d.base}${t}`,{method:e,headers:{...w(),...i},body:n===void 0?void 0:JSON.stringify(n),...o?{signal:AbortSignal.timeout(o)}:{}})}catch{throw new v("engine_down",`the conform.tools engine is not running at ${d.base}`)}let c=await a.json().catch(()=>({}));if(!a.ok&&!("text"in c)&&!s.includes(a.status))throw new v(c.code??String(a.status),c.message??`HTTP ${a.status}`);return c}async function S(e,t,n,s,i=0){if(f)return new Promise(()=>{});let o;try{o=await fetch(`${d.base}${e}`,{...t,headers:w(),signal:s})}catch{s?.aborted||n({type:"error",code:"engine_down",message:`the conform.tools engine is not running at ${d.base}`});return}if(!o.ok||!o.body){let b=await o.json().catch(()=>({}));n({type:"error",code:b.code??String(o.status),message:b.message??`HTTP ${o.status}`});return}let a=o.body.getReader(),c=new TextDecoder,g="";for(;;){let b,m=i?new Promise(u=>{b=setTimeout(()=>u(null),i)}):null,h=await(m?Promise.race([a.read(),m]):a.read());if(clearTimeout(b),!h){a.cancel().catch(()=>{});break}let{value:y,done:R}=h;if(R)break;g+=c.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 x(){if(T)return;let e=T=new AbortController;(async()=>{for(;!e.signal.aborted;)await S("/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 O={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,s,i,o,a)=>{let c=new URLSearchParams({f:String(t),w:String(n),...i?{timeline:i}:{},...o?{track:String(o)}:{},...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?${c}`,{headers:w(!1),signal:s}).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),R=m.getUint32(8,!0)===1,p=new Uint8ClampedArray(b.buffer,12,h*y*4);for(let u=0;u<p.length;u+=4){if(R){let _=p[u];p[u]=p[u+2],p[u+2]=_}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:i,ext:o})=>({target:i,ext:o}))),sequences:JSON.stringify(e.sequences)});if(f)return{ok:!1,error:(await import("./demo-engine-WXNT4Y7S.js")).DEMO_TEXT};let s=await fetch(`${d.base}/app/convert?${n}`,{method:"POST",headers:{...w(!1),"content-type":"application/octet-stream"},body:e.bytes});return await s.json().catch(()=>({ok:!1,error:`the engine said ${s.status}`}))},canonicalize:async(e,t=[],n=[])=>{let s=new URLSearchParams({name:e.name,sequences:JSON.stringify(t),previous:JSON.stringify(n)});if(f)throw new Error((await import("./demo-engine-WXNT4Y7S.js")).DEMO_TEXT);let i=await fetch(`${d.base}/app/canonicalize?${s}`,{method:"POST",headers:{...w(!1),"content-type":"application/octet-stream"},body:await e.arrayBuffer()}),o=await i.json().catch(()=>({ok:!1,error:`the engine said ${i.status}`}));if(!o.ok)throw new Error(o.error??o.message??`the engine said ${i.status}`);return o},policy:()=>r("GET","/app/policy"),session:e=>r("GET",`/app/sessions/${e}`),onEvent:e=>(k.add(e),x(),()=>{k.delete(e),k.size||(T?.abort(),T=null)}),saveRunCsv:(e,t,n,s)=>r("POST","/verbs/tool_run",{action:"csv",project_id:e,path:t,id:n,table:s}),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-WXNT4Y7S.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 i=await n.arrayBuffer();return{result:{byteLength:i.byteLength},bytes:i}}let s=await n.json().catch(()=>({ok:!1}));if(!s.ok)throw Object.assign(new Error(s.message??`the engine said ${n.status}`),{name:"NotFoundError"});return{result:s.result}}var l=()=>typeof window<"u"?window.__TAURI__:void 0,E={available:()=>!!l()?.core?.invoke,licenseStatus:()=>l().core.invoke("license_status"),fingerprint:()=>l().core.invoke("machine_fingerprint"),version:()=>l().app.getVersion(),installUpdate:()=>l().core.invoke("install_update"),float:(e,t,n,s)=>l().core.invoke("open_float",{path:e,title:t,width:n,height:s}),importLicense:async()=>{let e=await l().dialog.open({multiple:!1,filters:[{name:"conform.tools licence",extensions:["lic","json"]}]});return typeof e=="string"?l().core.invoke("import_license",{path:e}):null},pickFolder:async()=>{let e=await l().dialog.open({directory:!0,multiple:!1});return typeof e=="string"?e:null},pickFiles:async()=>{let e=await l().dialog.open({directory:!1,multiple:!0});return Array.isArray(e)?e:typeof e=="string"?[e]:[]},pickFile:async()=>{let e=await l().dialog.open({directory:!1,multiple:!1});return typeof e=="string"?e:null},saveFile:async e=>{try{let t=e.split(".").pop()??"json",n=await l().dialog.save({defaultPath:e,filters:[{name:t==="csv"?"Table":"Recipe",extensions:[t]}]});return typeof n=="string"?n:null}catch{let t=await l().dialog.open({directory:!0,multiple:!1});return typeof t=="string"?`${t.replace(/[\\/]$/,"")}/${e}`:null}}};export{v as EngineError,O as engine,$ as engineFs,j as isDemo,E as shell};
|
|
@@ -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}from"./chunk-63WQRYTJ.js";import"./chunk-IN6XVTUS.js";import"./chunk-DLF5AKXT.js";import"./chunk-PFZVET7S.js";import"./chunk-6V4OEOOX.js";import"./chunk-TBU2XWFD.js";import"./chunk-ISKNIQVO.js";import"./chunk-JKOB3U54.js";import"./chunk-EEDLRRKU.js";import"./chunk-WJ5EWXP2.js";import"./chunk-YUO3UWPH.js";import"./chunk-DKGGJM6Z.js";import"./chunk-JV7TZDKJ.js";import"./chunk-RGMTLNMF.js";import"./chunk-XDI6CPPV.js";import"./chunk-UKXSKFL3.js";import"./chunk-4RA57LTJ.js";import"./chunk-FLLB6UZJ.js";import"./chunk-UAURERD3.js";import"./chunk-LVGGCRDW.js";import"./chunk-C2ESM27Z.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import"./chunk-DPA26AOI.js";import"./chunk-VERTA23P.js";import"./chunk-OWWXUNJF.js";import"./chunk-VETHR2O7.js";import"./chunk-ROGMKTND.js";import"./chunk-X527E5VI.js";import"./chunk-PSANHDZM.js";export{j as ASPECTS,a as INPUT_SCALING,f as SIZING_TARGETS,i as alignText,h as alignTimeline,k as aspectOf,l as blankingForAspect,m as blankingQc,n as blankingText,c as inputFitRatio,g 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-XVZ7KJRI.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import{Ia as u,U as l,W as g}from"./chunk-DPA26AOI.js";import"./chunk-ROGMKTND.js";import{x as y}from"./chunk-X527E5VI.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,y)=>{v(e,g,y,(w,i,p)=>{if(E.has(w)){l(i,p);return}if(!(!c&&w!=="hdlr"&&w!=="stsd"))switch(w){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),d=n.getUint32(i+8),m=[];if(u===0)for(let h=0;h<d;h++)m.push(n.getUint32(i+12+h*4));else for(let h=0;h<d;h++)m.push(u);a.sampleSizes=m;break}case"stco":{let u=n.getUint32(i+4),d=[];for(let m=0;m<u;m++)d.push(n.getUint32(i+8+m*4));a.chunkOffsets=d;break}case"co64":{let u=n.getUint32(i+4),d=[];for(let m=0;m<u;m++){let h=n.getUint32(i+8+m*8),k=n.getUint32(i+12+m*8);d.push(h*2**32+k)}a.chunkOffsets=d;break}case"stsc":{let u=n.getUint32(i+4),d=[];for(let m=0;m<u;m++)d.push({firstChunk:n.getUint32(i+8+m*12),samplesPerChunk:n.getUint32(i+8+m*12+4),descIdx:n.getUint32(i+8+m*12+8)});a.sampleToChunk=d;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,y,w)=>{g==="trak"&&f(y,w)})})})(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 d=0;d<p;d++)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 d=0;d<i&&u<c;d++){let m=t.getUint32(p),h=t.getInt32(p+4);for(let k=0;k<m&&u<c;k++)g[u++]+=h;p+=8}}let y=Array.from({length:c},(i,p)=>p).sort((i,p)=>g[i]-g[p]||i-p),w=new Int32Array(c);for(let i=0;i<c;i++)w[y[i]]=i;return w}function F(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,y=P(e,g+4);if(y==="avc1"||y==="avc3"||y==="hvc1"||y==="hev1"){let w=n.getUint32(g),i=g+8+78,p=y.startsWith("hv")||y.startsWith("he"),u=S(e,i,g+w,p?"hvcC":"avcC");if(!u)return null;let d=e.subarray(u[0],u[1]),m=p?"hvc1.1.6.L93.B0":`avc1.${z(d[1])}${z(d[2])}${z(d[3])}`,h=M(e,c,n),k=h.length,U=S(e,c[0],c[1],"stss"),b=[];if(U){let T=n.getUint32(U[0]+4);for(let C=0;C<T;C++)b.push(n.getUint32(U[0]+8+C*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,C)=>T-C),{codec:m,description:d,keyframes:b,decodeToPres:h}}}}}if(o<a)break;r+=o}return null}var x=8,R=1500,I=new WeakMap;async function $(e){let n=I.get(e);return n||(n=L(e),I.set(e,n)),n}async function L(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=F(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],y=l+1<s.keyframes.length?s.keyframes[l+1]:f.length;a.push([g,y])}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 q(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 B(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 $(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=q(t.gops,a),[l,g]=t.gops[c];for(let y=0;y<2;y++){let w=y===0&&t.fedThrough>l&&t.fedThrough<=g&&a>=t.fedThrough,i=w?t.fedThrough:l;if(!w&&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 U=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:U.subarray(T.offset-h,T.offset-h+T.size)}))}t.fedThrough=p}let d=new Promise(h=>setTimeout(h,R));if(await Promise.race([u,d]),!t.got){try{await t.dec.flush()}catch{}t.fedThrough=-1}let m=t.got;if(t.wanted=-1,t.gotResolve=null,t.got=null,!!m)try{return await B(m)}finally{m.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,y)=>{v(e,g,y,(w,i,p)=>{if(E.has(w)){l(i,p);return}if(!(!c&&w!=="hdlr"&&w!=="stsd"))switch(w){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),d=n.getUint32(i+8),m=[];if(u===0)for(let h=0;h<d;h++)m.push(n.getUint32(i+12+h*4));else for(let h=0;h<d;h++)m.push(u);a.sampleSizes=m;break}case"stco":{let u=n.getUint32(i+4),d=[];for(let m=0;m<u;m++)d.push(n.getUint32(i+8+m*4));a.chunkOffsets=d;break}case"co64":{let u=n.getUint32(i+4),d=[];for(let m=0;m<u;m++){let h=n.getUint32(i+8+m*8),k=n.getUint32(i+12+m*8);d.push(h*2**32+k)}a.chunkOffsets=d;break}case"stsc":{let u=n.getUint32(i+4),d=[];for(let m=0;m<u;m++)d.push({firstChunk:n.getUint32(i+8+m*12),samplesPerChunk:n.getUint32(i+8+m*12+4),descIdx:n.getUint32(i+8+m*12+8)});a.sampleToChunk=d;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,y,w)=>{g==="trak"&&f(y,w)})})})(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 d=0;d<p;d++)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 d=0;d<i&&u<c;d++){let m=t.getUint32(p),h=t.getInt32(p+4);for(let k=0;k<m&&u<c;k++)g[u++]+=h;p+=8}}let y=Array.from({length:c},(i,p)=>p).sort((i,p)=>g[i]-g[p]||i-p),w=new Int32Array(c);for(let i=0;i<c;i++)w[y[i]]=i;return w}function F(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,y=P(e,g+4);if(y==="avc1"||y==="avc3"||y==="hvc1"||y==="hev1"){let w=n.getUint32(g),i=g+8+78,p=y.startsWith("hv")||y.startsWith("he"),u=S(e,i,g+w,p?"hvcC":"avcC");if(!u)return null;let d=e.subarray(u[0],u[1]),m=p?"hvc1.1.6.L93.B0":`avc1.${z(d[1])}${z(d[2])}${z(d[3])}`,h=M(e,c,n),k=h.length,U=S(e,c[0],c[1],"stss"),b=[];if(U){let T=n.getUint32(U[0]+4);for(let C=0;C<T;C++)b.push(n.getUint32(U[0]+8+C*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,C)=>T-C),{codec:m,description:d,keyframes:b,decodeToPres:h}}}}}if(o<a)break;r+=o}return null}var x=8,R=1500,I=new WeakMap;async function $(e){let n=I.get(e);return n||(n=L(e),I.set(e,n)),n}async function L(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=F(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],y=l+1<s.keyframes.length?s.keyframes[l+1]:f.length;a.push([g,y])}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 q(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 B(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 $(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=q(t.gops,a),[l,g]=t.gops[c];for(let y=0;y<2;y++){let w=y===0&&t.fedThrough>l&&t.fedThrough<=g&&a>=t.fedThrough,i=w?t.fedThrough:l;if(!w&&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 U=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:U.subarray(T.offset-h,T.offset-h+T.size)}))}t.fedThrough=p}let d=new Promise(h=>setTimeout(h,R));if(await Promise.race([u,d]),!t.got){try{await t.dec.flush()}catch{}t.fedThrough=-1}let m=t.got;if(t.wanted=-1,t.gotResolve=null,t.got=null,!!m)try{return await B(m)}finally{m.close()}}throw new Error(`h264: frame ${n} did not decode`)}finally{f()}}async function A(){return(await import("./isobmff-MTMGQKLK.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{Ia as v,na as g,pa as b}from"./chunk-DPA26AOI.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-
|
|
3
|
+
import{Ia as v,na as g,pa as b}from"./chunk-DPA26AOI.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-J5QHA3VY.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,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{appendFileSync as Y,mkdirSync as
|
|
2
|
+
import{appendFileSync as Y,mkdirSync as K,readFileSync as d}from"node:fs";import{join as l}from"node:path";import{homedir as B}from"node:os";import{randomUUID as J}from"node:crypto";var w=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"]),x=["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"],E=["aaf","avb","edl","drt","otio","fcpxml","fcpxmld","prproj","ptx","ale","xml","csv"],m=new Set(["xml","csv","png","jpg","jpeg","tif","tiff"]),A=new Set([...x,...E,...m]),S=new Set(["sudo","env","time","nice","nohup","command","exec","xargs","caffeinate","stdbuf","timeout","doas"]),g=e=>(e.replace(/^["']+|["']+$/g,"").split(/[\\/]/).pop()??e).toLowerCase();function T(e){let n=[];for(let o of e.split(/\|\||&&|;|\||\n|\$\(|`/)){let t=o.trim().split(/\s+/).filter(Boolean),r=0;for(;r<t.length&&(/^[A-Za-z_][A-Za-z0-9_]*=/.test(t[r])||S.has(g(t[r]))||t[r].startsWith("-")||/^\d+$/.test(t[r]));)r++;let s=t[r];if(!s)continue;let i=g(s);/^[a-z0-9_.+-]{1,32}$/.test(i)&&!n.includes(i)&&n.push(i)}return n}function v(e){let n=new Set;for(let o of e.matchAll(/\.([A-Za-z0-9]{2,7})(?=["'\s)\]|;,>]|$)/g)){let t=o[1].toLowerCase();A.has(t)&&n.add(t)}return[...n].sort()}function O(e){if(!e||typeof e!="object")return null;let n=e;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 t=typeof n.transcript_path=="string"?n.transcript_path:"";return{command:o.command,client:/[\\/]\.codex[\\/]/.test(t)?"codex":/[\\/]\.claude[\\/]/.test(t)?"claude-code":null}}return null}function b(e){let n=O(e);if(!n)return null;let o=T(n.command),t=v(n.command),r=o.filter(i=>w.has(i)),s=t.filter(i=>!m.has(i));return!r.length&&!s.length?null:{verb:`shell:${r[0]??o[0]??"sh"}`,fields:t.slice(0,16),counts:{programs:o.length,media_programs:r.length,extensions:t.length},client:n.client}}var c=String.raw`[^\s"'${"`"}<>|,;()[\]{}\\/]+(?: [^\s"'${"`"}<>|,;()[\]{}\\/:]+(?=$|[\s"'${"`"}<>|,;()[\]{}\\/]))*`,_=String.raw`[^\s"'${"`"}<>|,;()[\]{}\\/]+`,C=new RegExp(String.raw`(?<![A-Za-z0-9_.~:\\/-])(?:file://)?(?:~|[A-Za-z]:)?(?:[\\/]${c}){2,}[\\/]?|\\\\${c}(?:\\${c})+`+String.raw`|(?<![A-Za-z0-9_.~:\\/-])${_}(?:[\\/]${_}){2,}`,"g");function D(e){let n=e.replace(/[\\/]+$/,""),o=Math.max(n.lastIndexOf("/"),n.lastIndexOf("\\"));return o>=0?n.slice(o+1):n}var N=(e,n)=>e.length>n?`${e.slice(0,n)}\u2026`:e;var M=/^[A-Za-z0-9_.:-]{1,64}$/;function u(e){return typeof e=="string"&&M.test(e)?e:null}var a=(e,n)=>typeof e=="string"&&n.includes(e)?e:null,I=300,P=["solved","partly","failed"],L=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(" ")),F=/\b(?:https?|ftp|s3|gs|file):\/\/\S+/gi,$=/\b[\w.+-]+@[\w-]+(?:\.[\w-]+)+\b/g,j=/\b\d{1,2}[:;]\d{2}[:;]\d{2}[:;.]\d{2,3}\b/g,H=/"[^"]{1,200}"|“[^”]{1,200}”|‘[^’]{1,200}’|(?<![A-Za-z])'[^']{1,200}'(?![A-Za-z])/g,U=/(?<![{\w])[\w][\w.+-]+\.[A-Za-z][A-Za-z0-9]{1,4}\b/g,z=/(?<![{\w])(?=[\w-]*[A-Za-z])(?=[\w-]*\d)(?:[\w]+[_-][\w-]+|[A-Za-z]+\d+[A-Za-z]+\d+\w*)(?![\w}])/g,q=/(?<![{\w])[A-Z][A-Z0-9&]{2,}(?:\s+[A-Z][A-Z0-9&]{2,})*(?![\w}])/g;function p(e,n=I){if(typeof e!="string")return null;let o=e.replace(/\s+/g," ").trim();return o?(o=o.replace(F,"{url}").replace($,"{email}").replace(C,t=>{let r=D(t),s=r.indexOf(" ");return`{path}${s>=0?r.slice(s):""}`}).replace(H,"{text}").replace(j,"{tc}").replace(U,t=>t.toLowerCase()==="conform.tools"?t:"{file}").replace(z,t=>/^\d+-[a-z]+$/.test(t)?t:"{id}").replace(q,t=>t.split(/\s+/).every(r=>L.has(r))?t:"{title}").replace(/\{([^{}]*)\}/g,(t,r)=>/^[a-z_]{1,24}$/.test(r)?`{${r}}`:"{text}"),N(o,n)):null}var X=["outcome","invalid_args","dropped"],Z=300,y=/^[A-Za-z0-9 ._()-]{1,80}$/,h=(e,n)=>typeof e=="number"&&Number.isInteger(e)&&e>0&&e<=n?e:null,V=/^[a-z_]{1,32}$/,k=/^[A-Za-z0-9_.]{1,64}$/,f=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function G(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let n={};for(let[o,t]of Object.entries(e).slice(0,16))V.test(o)&&typeof t=="number"&&Number.isFinite(t)&&t>=0&&(n[o]=Math.round(t));return Object.keys(n).length?n:null}function R(e){if(!e||typeof e!="object")return null;let n=e,o=a(n.kind,X),t=u(n.verb);if(!o||!t)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:t,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"?G(n.counts):null,fields:r?.length?r:null,run_id:typeof n.run_id=="string"&&f.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"&&f.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"?p(n.asked):null,previous:o==="outcome"?a(n.previous,P):null,previous_why:o==="outcome"?p(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?p(n.error,Z):null,platform:typeof n.platform=="string"&&y.test(n.platform)?n.platform:null,runtime:typeof n.runtime=="string"&&y.test(n.runtime)?n.runtime:null,memory_gb:h(n.memory_gb,4096),cpus:h(n.cpus,1024),install:typeof n.install=="string"&&f.test(n.install)?n.install:null}}var W=12*36e5;function Q(e,n=process.env.CONFORM_MCP_HOME??l(B(),".conform-mcp")){try{if(process.env.CONFORM_TELEMETRY==="off"||process.env.CONFORM_TELEMETRY==="0")return"off";let o={};try{o=JSON.parse(d(l(n,"config.json"),"utf8"))}catch{}if(o.telemetry===!1)return"off";let t=b(JSON.parse(e));if(!t)return"not media";let r={};try{r=JSON.parse(d(l(n,"telemetry","run.json"),"utf8"))}catch{}let s=typeof r.at=="string"&&Date.now()-Date.parse(r.at)<W,i=R({kind:"outcome",verb:t.verb,ok:!0,counts:t.counts,fields:t.fields,client:t.client??(s?r.client:null),run_id:s?r.run_id:null,req:s?r.req:null,event_id:J(),run_at:new Date().toISOString(),install:o.install});return i?(K(l(n,"telemetry"),{recursive:!0}),Y(l(n,"telemetry","queue.jsonl"),JSON.stringify(i)+`
|
|
3
3
|
`),"queued"):"nothing"}catch{return"nothing"}}if(import.meta.main??/hook\.(js|ts)$/.test(process.argv[1]??"")){let e="";try{e=d(0,"utf8")}catch{}e.trim()&&Q(e),process.exit(0)}export{Q as main};
|
|
@@ -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-
|
|
3
|
+
import{a as T}from"./chunk-G7CVRPVA.js";import{c as D}from"./chunk-IBIAW6IW.js";import{$b as N,R as M,Ub as P,dc as q}from"./chunk-63WQRYTJ.js";import"./chunk-IN6XVTUS.js";import{k as A}from"./chunk-DLF5AKXT.js";import"./chunk-PFZVET7S.js";import"./chunk-6V4OEOOX.js";import"./chunk-7NGS2BN7.js";import"./chunk-TBU2XWFD.js";import"./chunk-ISKNIQVO.js";import"./chunk-JKOB3U54.js";import"./chunk-EEDLRRKU.js";import"./chunk-WJ5EWXP2.js";import"./chunk-YUO3UWPH.js";import"./chunk-DKGGJM6Z.js";import"./chunk-JV7TZDKJ.js";import"./chunk-RGMTLNMF.js";import"./chunk-XDI6CPPV.js";import"./chunk-UKXSKFL3.js";import"./chunk-4RA57LTJ.js";import"./chunk-FLLB6UZJ.js";import"./chunk-UAURERD3.js";import"./chunk-LVGGCRDW.js";import"./chunk-C2ESM27Z.js";import"./chunk-N34DQ6MH.js";import{b as F}from"./chunk-NU3X7P4N.js";import"./chunk-DPA26AOI.js";import"./chunk-VERTA23P.js";import"./chunk-OWWXUNJF.js";import"./chunk-VETHR2O7.js";import"./chunk-ROGMKTND.js";import{$ as R,L as x,M as E,_ as U,ba as k,p as O,t as S}from"./chunk-X527E5VI.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-WZHNO43A.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(`
|
|
@@ -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-UAURERD3.js";import"./chunk-LVGGCRDW.js";import"./chunk-C2ESM27Z.js";import"./chunk-OWWXUNJF.js";import"./chunk-VETHR2O7.js";import"./chunk-ROGMKTND.js";import"./chunk-X527E5VI.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-6KEFHHS6.js";import"./chunk-IBIAW6IW.js";import"./chunk-63WQRYTJ.js";import"./chunk-IN6XVTUS.js";import"./chunk-DLF5AKXT.js";import"./chunk-PFZVET7S.js";import"./chunk-6V4OEOOX.js";import"./chunk-7NGS2BN7.js";import"./chunk-TBU2XWFD.js";import"./chunk-ISKNIQVO.js";import"./chunk-JKOB3U54.js";import"./chunk-EEDLRRKU.js";import"./chunk-WJ5EWXP2.js";import"./chunk-YUO3UWPH.js";import"./chunk-DKGGJM6Z.js";import"./chunk-JV7TZDKJ.js";import"./chunk-RGMTLNMF.js";import"./chunk-XDI6CPPV.js";import"./chunk-UKXSKFL3.js";import"./chunk-4RA57LTJ.js";import"./chunk-FLLB6UZJ.js";import"./chunk-UAURERD3.js";import"./chunk-LVGGCRDW.js";import"./chunk-C2ESM27Z.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import"./chunk-DPA26AOI.js";import"./chunk-VERTA23P.js";import"./chunk-OWWXUNJF.js";import"./chunk-VETHR2O7.js";import"./chunk-ROGMKTND.js";import"./chunk-X527E5VI.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,5 @@
|
|
|
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
|
|
4
|
-
`)}:{}})}if(
|
|
5
|
-
`)},e.isError?422:200)}if(a[0]==="debug"&&a.length===3&&t.method==="POST"&&
|
|
3
|
+
import{a as At}from"./chunk-B2KCENY6.js";import{a as St,b as Tt,c as Ot,d as Rt,e as vt,f as Et,g as Pt,j as T,k as Ct,n as $,o as $t}from"./chunk-HTRW5GX4.js";import"./chunk-IDJIOKXA.js";import"./chunk-G7CVRPVA.js";import"./chunk-6KEFHHS6.js";import"./chunk-IBIAW6IW.js";import"./chunk-QH5DTYSE.js";import"./chunk-YU3SUSK3.js";import"./chunk-QTFFVLVJ.js";import"./chunk-5YULBQJX.js";import{Db as ht,Eb as wt,G as at,H as it,J as gt,P as V,Tc as kt,Xc as R,bd as yt,dd as xt,fd as bt,xc as _t}from"./chunk-63WQRYTJ.js";import"./chunk-IN6XVTUS.js";import"./chunk-DLF5AKXT.js";import"./chunk-PFZVET7S.js";import"./chunk-6V4OEOOX.js";import"./chunk-7NGS2BN7.js";import{a as rt}from"./chunk-TBU2XWFD.js";import"./chunk-ISKNIQVO.js";import"./chunk-JKOB3U54.js";import"./chunk-EEDLRRKU.js";import"./chunk-WJ5EWXP2.js";import"./chunk-YUO3UWPH.js";import"./chunk-DKGGJM6Z.js";import"./chunk-JV7TZDKJ.js";import"./chunk-RGMTLNMF.js";import"./chunk-XDI6CPPV.js";import"./chunk-UKXSKFL3.js";import"./chunk-4RA57LTJ.js";import"./chunk-FLLB6UZJ.js";import"./chunk-UAURERD3.js";import"./chunk-LVGGCRDW.js";import"./chunk-C2ESM27Z.js";import"./chunk-D6YDLKSA.js";import"./chunk-XVZ7KJRI.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import"./chunk-DPA26AOI.js";import{C,E as mt,t as G,u as lt,v as ut,x as dt,y as pt,z as ft}from"./chunk-VERTA23P.js";import{h as ct,l as H}from"./chunk-OWWXUNJF.js";import"./chunk-VETHR2O7.js";import{a as I}from"./chunk-ROGMKTND.js";import{$ as J,A as tt,B as j,D as et,H as L,L as F,M as nt,N as ot,U as st,_ as U,b as O,ba as S,n as P,t as z,u as Z,x as Q,y as q,z as B}from"./chunk-X527E5VI.js";import"./chunk-PSANHDZM.js";import N from"node:process";var Nt=new Map;function Mt(t,i,s,x){let a=`${t}:${s}:${x}`,o=Nt.get(a);return o||(o=(async()=>{let n=S(P(),"cache","grade-luts",t);await j(n);let d=S(n,`V${s}_${x}.cube`);if(!await Z(d)){let{adapter:k}=await import("./hosts-QW64CIJU.js");if((await k("resolve").clipLut({timeline:i,track:s,start:x,out_path:d})).ok===!1)return null}return d})().catch(()=>null),Nt.set(a,o)),o}var It=new Set(["/app/convert","/app/canonicalize"]);function Lt(t,i){let s=(i??"").split(";")[0].trim().toLowerCase();return s==="application/json"||s==="application/octet-stream"&&It.has(t)}function Ht(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 W={id:"local",name:"Local",client_name:null,handles:24,local:!0};async function Ut(){try{return JSON.parse(await q(S(P(),"projects","projects.json")))}catch{return[]}}async function jt(){let t=await T("project",{action:"list"});if(!t.isError){let i=t.structuredContent?.projects??[];return await j(S(P(),"projects")),await tt(S(P(),"projects","projects.json"),JSON.stringify(i)),{projects:[W,...i],offline:!1}}return{projects:[W,...await Ut()],offline:!0,code:String(t.structuredContent?.code??"offline"),reason:String(t.structuredContent?.message??t.content[0]?.text??"")}}async function Gt(t){return t==="local"?W:(await Ut()).find(i=>i.id===t)??{id:t,name:t}}async function Dt(t,i,s,x,a=(o,n)=>new Response(o,{headers:{"content-type":n}})){if(i[0]!=="app")return null;let[,o,n,d]=i,k=async()=>t.headers.get("content-type")?.includes("json")?await t.json():{};try{if(o==="policy"&&t.method==="GET"){let{config:e}=await import("./account-W7Z2MYZU.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 T("account_status",{}),r=await H().then(c=>({app:!0,studio_tools:c.source==="licence"||ct(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 H().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 x(Rt());if(o==="front"&&t.method==="POST"){let e=await t.json();return Tt({project:String(e.project??""),view:String(e.view??""),...e.tool?{tool:String(e.tool)}:{}}),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")||"",g=JSON.parse(e.get("targets")||"[]"),l=JSON.parse(e.get("sequences")||"[]");if(!c||!g.length)return s({ok:!1,error:"a folder and at least one format are needed"},400);let u=await F("conform-te-"),f=S(u,r);await B(f,new Uint8Array(await t.arrayBuffer()));let h=await T("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(b=>b.kind!=="compound"),_=l.length?w.filter(b=>l.includes(b.name??"")):w,p=[],v=0;for(let b of _)for(let E of g){let M=S(c,`${Ht(b.name??"timeline")}.${E.ext}`),Y=await T("timeline_write",{session_id:y,target:E.target,out_path:M,..._.length>1||w.length>1?{timeline_id:b.id}:{}});Y.isError?p.push(`${b.name} \u2192 ${E.target}: ${Y.content[0]?.text}`):v++}return await L(u).catch(()=>{}),s({ok:v>0,savedCount:v,...p.length?{error:p.join(`
|
|
4
|
+
`)}:{}})}if(o==="fs"&&t.method==="POST"){let{op:e,path:r,offset:c=0,length:g=0}=await k();if(e==="statPath"){let l=await z(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 nt(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=g>0?g:Math.max(0,(await z(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 ot(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")||"[]"),g=await F("conform-te-");try{let l=S(g,U(e.get("name")||"timeline"));await B(l,new Uint8Array(await t.arrayBuffer()));let u=await T("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 p of c)w.set(p,(w.get(p)??0)+1);let _=new Set;for(let p of r){let v=h.timelines.filter(M=>M.kind!=="compound"&&(M.name??"")===p),b=w.get(p)??0;w.set(p,b+1);let E=v[Math.min(b,v.length-1)];E&&_.add(E)}y=h.timelines.filter(p=>p.kind==="compound"||_.has(p))}return s({ok:!0,session_id:f,session:{...h,timelines:y}})}finally{await L(g).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 _=(()=>{try{return ht(f,{record:r,timeline:e.get("timeline")??void 0,track:h})}catch{return null}})();_&&(y=await Mt(n,e.get("host_timeline")??void 0,_.video_track,_.record_start)??void 0)}let w=await wt(f,r,c,e.get("timeline")??void 0,h,y);if(w){let _=new Uint8Array(12+w.px.length),p=new DataView(_.buffer);return p.setUint32(0,w.w,!0),p.setUint32(4,w.h,!0),p.setUint32(8,w.order==="bgra"?1:0,!0),_.set(w.px,12),a(_,"application/x-conform-pixels")}}catch(f){return s({ok:!1,code:"no_frame",message:f.message},404)}let g=await T("timeline_frame",{session_id:n,record:r,width:c,...e.get("timeline")?{timeline:e.get("timeline")}:{}},{poll:!0}),l=g.structuredContent?.out_path;if(g.isError||!l)return s({ok:!1,code:String(g.structuredContent?.code??"no_frame"),message:g.content[0]?.text??"no picture here"},404);let u=await Q(l);return await(U(J(l)).startsWith("conform-frame-")?L(J(l)):et(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 mt());if(o!=="projects")return s({ok:!1,code:"not_found"},404);if(!n){if(t.method==="POST"){let e=await k(),r=await T("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 jt(),s(r.structuredContent))}return s(await jt())}if(!d){let[e,r,c,g,l,u]=await Promise.all([Gt(n),lt(n).catch(()=>null),ft(n),gt(n),yt(n).then(y=>y.facts).catch(()=>[]),n===G?null:xt().catch(()=>null)]);await dt(n===G?null:{id:n,name:e.name??n});let{text:f="",...h}=r??{};return s({project:e,context:f,context_meta:h,sessions:c,activity:g.slice(-100).reverse(),known:bt(l),facility:u?.text??""})}if(d==="sessions"&&t.method==="PUT")return await pt(n,String((await k()).session_id??"")),s({ok:!0});if(d==="context"&&t.method==="PUT"){let e=await k();try{let{text:r,...c}=await ut(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 I&&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 I?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 zt=t=>t==="1"?"app":"http",K=(t,i)=>t&&i.has(t)?t:"custom",A=new Map,Vt=500;function Bt(t){let i=null,s=St(a=>{switch(a.type){case"open":R(`app:open:${K(a.tool,t)}`);break;case"home":R("app:home");break;case"workspace":{let o=a.workspace;R("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):[];R("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>=Vt&&A.delete(A.keys().next().value),A.set(o.id,o.status),R(`app:run_${o.status}:${K(o.tool,t)}`,{fields:[o.by==="app"?"app":"assistant"],ok:o.status!=="failed"});break}}}),x=Ot(a=>{let o=/^[a-z]+$/.test(a.view)?a.view:"other",n=`${a.project}|${o}|${a.tool??""}`;n!==i&&(i=n,R(o==="tool"?`app:view:tool:${K(a.tool,t)}`:`app:view:${o}`))});return()=>{s(),x()}}var Wt=Number(O("CONFORM_HTTP_PORT")??7791);O("CONFORM_EXIT_WITH_PARENT")==="1"&&(N.stdin.on("end",()=>N.exit(0)),N.stdin.on("close",()=>N.exit(0)),N.stdin.resume());kt(zt(O("CONFORM_EXIT_WITH_PARENT")));Bt(new Set([..._t.map(t=>t.id),...$.map(t=>t.name),"context","source"]));var X=O("CONFORM_HTTP_TOKEN")??"",Jt=(O("CONFORM_HTTP_ORIGINS")??"https://conform.tools,https://app.conform.tools,http://localhost:5173,http://localhost:3000").split(","),D=(t,i=new Headers)=>{let s=t.headers.get("origin")??"";return Jt.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},Ft=new Set,m=(t,i,s=200)=>new Response(JSON.stringify(i),{status:s,headers:D(t,new Headers({"content-type":"application/json"}))});st({hostname:"127.0.0.1",port:Wt,onListen:t=>{Ft=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)`),At(t,X)}},async t=>{let i=new URL(t.url),s=(t.headers.get("host")??"").toLowerCase();if(!Ft.has(s))return new Response("forbidden host",{status:403});let x=t.headers.get("origin");if(x&&!Jt.includes(x))return new Response("forbidden origin",{status:403});if(t.method==="OPTIONS")return new Response(null,{status:204,headers:D(t)});if((t.method==="POST"||t.method==="PUT")&&t.headers.get("content-length")!=="0"&&!Lt(i.pathname,t.headers.get("content-type")))return m(t,{ok:!1,code:"unsupported_media_type",message:"send the body as application/json"},415);if(X&&t.headers.get("authorization")!==`Bearer ${X}`&&i.pathname!=="/health")return m(t,{ok:!1,code:"unauthorized"},401);let a=i.pathname.split("/").filter(Boolean);try{if(i.pathname==="/health")return m(t,{ok:!0,verbs:$.length,version:rt,engine:V()});if(a[0]==="verbs"&&a.length===1&&t.method==="GET")return m(t,$.map(n=>({name:n.name,title:n.title,description:n.description,long:!!n.long,input_schema:it(at.object(n.inputSchema)),protected_stages:n.protectedStages??[],engine:V()})));if(a[0]==="verbs"&&a.length===2&&t.method==="POST"){let n=$t(a[1]);if(!n)return m(t,{ok:!1,code:"not_found",message:`unknown verb ${a[1]}`},404);let d=t.headers.get("content-type")?.includes("json")?await t.json():{},k=Ct(n.name,d);if(!k.ok)return m(t,{...k.result.structuredContent,text:k.result.content[0].text},400);let e=await T(n.name,k.data,{client:t.headers.get("x-conform-client")??"http",poll:t.headers.get("x-conform-poll")==="1"});return m(t,{...e.structuredContent??{ok:!e.isError},text:e.content.map(r=>r.text).join(`
|
|
5
|
+
`)},e.isError?422:200)}if(a[0]==="debug"&&a.length===3&&t.method==="POST"&&O("CONFORM_DEBUG_BRIDGE")==="1"){let{hostBridge:n}=await import("./bridge-RH3JRSBN.js"),d=await n();return await d.waitFor(a[1],5e3)?m(t,{ok:!0,result:await d.request(a[1],a[2],t.headers.get("content-type")?.includes("json")?await t.json():{},12e4)}):m(t,{ok:!1,code:"not_connected"},409)}let o=await Dt(t,a,(n,d)=>m(t,n,d),n=>new Response(n,{headers:D(t,new Headers({"content-type":"text/event-stream","cache-control":"no-cache"}))}),(n,d)=>new Response(n,{headers:D(t,new Headers({"content-type":d,"cache-control":"no-store"}))}));if(o)return o;if(a[0]==="jobs"&&a.length===1)return m(t,await Pt());if(a[0]==="jobs"&&a.length===2){if(t.method==="DELETE")return m(t,{ok:Et(a[1])});let n=await vt(a[1]);return n?m(t,n):m(t,{ok:!1,code:"not_found"},404)}return m(t,{ok:!1,code:"not_found"},404)}catch(o){return m(t,{ok:!1,code:"internal",message:o instanceof Error?o.message:String(o)},500)}});
|