conformtools 0.6.19 → 0.6.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/{account-KSE6H6DJ.js → account-VD3EE5UT.js} +1 -1
  2. package/dist/{agent-hook-setup-SHZOVJYL.js → agent-hook-setup-D2QNHA3V.js} +1 -1
  3. package/dist/{analysis-engine-KUGSWNQB.js → analysis-engine-VNGF3DE4.js} +1 -1
  4. package/dist/{bridge-REYIYXUU.js → bridge-MLBUD6XW.js} +1 -1
  5. package/dist/browser/timeline_core_bg.wasm +0 -0
  6. package/dist/{chunk-ND2YUUUH.js → chunk-2S2ZPQQD.js} +1 -1
  7. package/dist/{chunk-HKHEL4MZ.js → chunk-2WNNDPVR.js} +1 -1
  8. package/dist/chunk-2XQ42O7E.js +7 -0
  9. package/dist/{chunk-GTN62ZQV.js → chunk-3WJSWOCS.js} +1 -1
  10. package/dist/{chunk-WM7ESQLY.js → chunk-4UT55WZA.js} +1 -1
  11. package/dist/{chunk-TD3ZHREE.js → chunk-4V3KLFCJ.js} +1 -1
  12. package/dist/chunk-6IL7M3VP.js +162 -0
  13. package/dist/chunk-A7AYMSY7.js +9 -0
  14. package/dist/chunk-GBNPOZ32.js +10 -0
  15. package/dist/{chunk-BD54PRSN.js → chunk-GHP6HDLM.js} +1 -1
  16. package/dist/{chunk-3DYCTUSQ.js → chunk-HCT34NDA.js} +1 -1
  17. package/dist/{chunk-NHVH373D.js → chunk-HROU7LLU.js} +1 -1
  18. package/dist/{chunk-3J2FARFO.js → chunk-IPQLKAF2.js} +1 -1
  19. package/dist/chunk-JVJUJKUP.js +5 -0
  20. package/dist/chunk-M545OKDZ.js +6 -0
  21. package/dist/chunk-MU5AGXSH.js +3 -0
  22. package/dist/chunk-OSPDH2RK.js +6 -0
  23. package/dist/{chunk-WNDA7QSY.js → chunk-V2FVIZT7.js} +1 -1
  24. package/dist/{chunk-4KMSOMLG.js → chunk-WYI4LL4P.js} +207 -196
  25. package/dist/chunk-ZAL7Y5VZ.js +7 -0
  26. package/dist/{claude-setup-ZOEQ5NXE.js → claude-setup-AI4WXN2V.js} +1 -1
  27. package/dist/cli.js +2 -2
  28. package/dist/{demo-engine-ZX24TAXA.js → demo-engine-MOHHYVGV.js} +1 -1
  29. package/dist/{engine-K6QYU5KJ.js → engine-WMOJ3HRU.js} +2 -2
  30. package/dist/{framing-B6LP7MS2.js → framing-U46POZQG.js} +1 -1
  31. package/dist/gfx-worker.js +1 -1
  32. package/dist/{h264-YX5KP63E.js → h264-4ETGWMKR.js} +1 -1
  33. package/dist/{h264-mxf-VAHIJCA7.js → h264-mxf-EFHHQL7X.js} +1 -1
  34. package/dist/hook.js +3 -3
  35. package/dist/host-relink-MVHI3YQI.js +10 -0
  36. package/dist/hosted-6BLHLZXM.js +3 -0
  37. package/dist/hosts-7UO4QETB.js +3 -0
  38. package/dist/http.js +2 -2
  39. package/dist/{inspect-QRHOFMC2.js → inspect-5TMUYGAL.js} +16 -16
  40. package/dist/{isobmff-RHP3N5K2.js → isobmff-55TPOVCK.js} +1 -1
  41. package/dist/{mc-video-CHBOYPI5.js → mc-video-GKWEWCEQ.js} +1 -1
  42. package/dist/mcp.js +1 -1
  43. package/dist/{media-TPGEESEU.js → media-HCKSVARE.js} +1 -1
  44. package/dist/{mxf-R2ONKSYU.js → mxf-AJTCMKTX.js} +1 -1
  45. package/dist/{ops-MKDFWWPG.js → ops-UGZODMYE.js} +1 -1
  46. package/dist/{probe-CHT266NN.js → probe-YOYK7HR5.js} +1 -1
  47. package/dist/{r3d-F4OWLQE2.js → r3d-XHSJUARW.js} +1 -1
  48. package/dist/{sequence-patch-6FSMBG7O.js → sequence-patch-5MFTY52Q.js} +1 -1
  49. package/dist/{store-CFQHKBGL.js → store-6XN5Q6UG.js} +1 -1
  50. package/dist/{timeline-MZ6A3PQX.js → timeline-TFF3L7JP.js} +1 -1
  51. package/package.json +5 -5
  52. package/dist/chunk-4PV2UTKG.js +0 -10
  53. package/dist/chunk-BZQAUU3D.js +0 -6
  54. package/dist/chunk-CUZVK2JJ.js +0 -6
  55. package/dist/chunk-HZG55H3B.js +0 -3
  56. package/dist/chunk-MJKISVPS.js +0 -7
  57. package/dist/chunk-NQD6H7SY.js +0 -7
  58. package/dist/chunk-PY6HS3EP.js +0 -10
  59. package/dist/chunk-UWEM5YEM.js +0 -161
  60. package/dist/chunk-XQON6ASI.js +0 -5
  61. package/dist/host-relink-VYEOE3NE.js +0 -10
  62. package/dist/hosted-NLYSTYYN.js +0 -3
  63. package/dist/hosts-47EW33NY.js +0 -3
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{c as u,d as y,g as w,h}from"./chunk-Y7PFSVRX.js";import{d as f,i as p}from"./chunk-MJKISVPS.js";import{a}from"./chunk-COALWMI7.js";import{b as g}from"./chunk-HZG55H3B.js";u(!0);var b={aaf:"aaf",avb:"avb",prproj:"prproj",drt:"resolve-drt",otio:"otio",capcut:"capcut",flame:"flame-archive",fcpxml:"resolve-fcpxml",xmeml:"fcp-xml",blscene:"baselight-blscene"},R=Object.keys(b),v=new Set([502,503,504,529,546]),d=(e,o)=>`${f().supabaseUrl}/functions/v1/${e}${o}`;async function m(){let e=await p();if(!e&&g("CONFORM_ANONYMOUS_READ")==="1")return f().anonKey;if(!e)throw new a("not_signed_in","reading and writing timelines runs on conform.tools \u2014 sign in first (account_login)");return e}async function S(e,o){let t;for(let n=0;n<3;n++){try{let i=await fetch(e,o);if(!v.has(i.status)||n===2)return i;t=new Error(`status ${i.status}`)}catch(i){if(t=i,n===2)break}await new Promise(i=>setTimeout(i,1500*(n+1)))}throw new a("offline",`conform.tools is unreachable (${t instanceof Error?t.message:String(t)}) \u2014 reading and writing timelines need the network`)}async function _(e,o){let n=(await e.json().catch(()=>({})))?.error?.message??`${o} failed (${e.status})`;throw e.status===401?new a("not_signed_in",`${n} \u2014 sign in again (account_login)`):e.status===402||e.status===403?new a("not_entitled",n):new a(e.status>=500?"engine":"refused",n)}async function P(e,o){let t=b[e];if(!t)throw new a("unsupported",`'${e}' timelines are not read by conform.tools yet`);let{fmt:n,extract:i}=await y(o,t),c=JSON.stringify({format:n,source_filename:o.name,persist:!1})+`
3
+ import{c as u,d as y,g as w,h}from"./chunk-Y7PFSVRX.js";import{d as f,i as p}from"./chunk-2XQ42O7E.js";import{a}from"./chunk-COALWMI7.js";import{b as g}from"./chunk-MU5AGXSH.js";u(!0);var b={aaf:"aaf",avb:"avb",prproj:"prproj",drt:"resolve-drt",otio:"otio",capcut:"capcut",flame:"flame-archive",fcpxml:"resolve-fcpxml",xmeml:"fcp-xml",blscene:"baselight-blscene"},R=Object.keys(b),v=new Set([502,503,504,529,546]),d=(e,o)=>`${f().supabaseUrl}/functions/v1/${e}${o}`;async function m(){let e=await p();if(!e&&g("CONFORM_ANONYMOUS_READ")==="1")return f().anonKey;if(!e)throw new a("not_signed_in","reading and writing timelines runs on conform.tools \u2014 sign in first (account_login)");return e}async function S(e,o){let t;for(let n=0;n<3;n++){try{let i=await fetch(e,o);if(!v.has(i.status)||n===2)return i;t=new Error(`status ${i.status}`)}catch(i){if(t=i,n===2)break}await new Promise(i=>setTimeout(i,1500*(n+1)))}throw new a("offline",`conform.tools is unreachable (${t instanceof Error?t.message:String(t)}) \u2014 reading and writing timelines need the network`)}async function _(e,o){let n=(await e.json().catch(()=>({})))?.error?.message??`${o} failed (${e.status})`;throw e.status===401?new a("not_signed_in",`${n} \u2014 sign in again (account_login)`):e.status===402||e.status===403?new a("not_entitled",n):new a(e.status>=500?"engine":"refused",n)}async function P(e,o){let t=b[e];if(!t)throw new a("unsupported",`'${e}' timelines are not read by conform.tools yet`);let{fmt:n,extract:i}=await y(o,t),c=JSON.stringify({format:n,source_filename:o.name,persist:!1})+`
4
4
  `+(typeof i=="string"?i:JSON.stringify(i)),s=await S(d("v1-timeline-canonicalize","/v1/timeline-canonicalize"),{method:"POST",headers:{"content-type":"application/x-ct-canonicalize-v1",authorization:`Bearer ${await m()}`,apikey:f().anonKey},body:c});s.ok||await _(s,"read");let l=await s.json();return JSON.stringify(l.session)}async function N(e,o){let t=await S(d("v1-write","/v1/write"),{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${await m()}`,apikey:f().anonKey,"x-engine-accept-delivery":"cdn"},body:JSON.stringify({target_format:e,session:o})});t.ok||await _(t,"write");let n=h(t.headers.get(w))??[];if(t.headers.get("x-engine-delivery")==="cdn"){let r=await t.json(),c=await fetch(r.download_url);if(!c.ok)throw new a("engine",`download failed (${c.status})`);let s=new Uint8Array(await c.arrayBuffer());if(s.byteLength!==r.size)throw new a("engine",`download incomplete: ${s.byteLength} of ${r.size} bytes`);return{body:s,contentType:r.content_type,filenameSuggestion:r.filename,issues:n,serverSession:r.session_id??void 0}}let i=t.headers.get("content-disposition")?.match(/filename="([^"]+)"/)?.[1];return{body:new Uint8Array(await t.arrayBuffer()),contentType:t.headers.get("content-type")??"application/octet-stream",filenameSuggestion:i??`timeline.${e}`,issues:n,serverSession:t.headers.get("x-session-id")??void 0}}async function j(e,o,t){try{let n={"content-type":"application/json",authorization:`Bearer ${await m()}`,apikey:f().anonKey},i=k=>d("v1-sessions",`/v1/sessions/${encodeURIComponent(e)}/original${k}`),r=await fetch(i(""),{method:"POST",headers:n,body:JSON.stringify({filename:o,content_type:"application/octet-stream"})});if(!r.ok)return!1;let{key:c,upload:s}=await r.json();return(await fetch(s.url,{method:s.method??"PUT",headers:s.headers??{"content-type":"application/octet-stream"},body:t})).ok?(await fetch(i("/complete"),{method:"POST",headers:n,body:JSON.stringify({key:c})})).ok:!1}catch{return!1}}export{R as a,P as b,N as c,j as d};
@@ -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{Gb as L,Hb as A,Ib as E,Jb as P,Kb as T,Lb as M,Mb as N,Nb as D,Ob as z,Pb as B,Qb as I,tb as S}from"./chunk-6IL7M3VP.js";import{a as b}from"./chunk-COALWMI7.js";import{aa as p,u as R}from"./chunk-MU5AGXSH.js";async function W(r,t){let c=t.media_root?[t.media_root]:await z();if(!c.length)throw new b("invalid_args","no media_root given and no remembered locations \u2014 pass the folder to link from");for(let e of c)try{if(!(await R(e)).isDirectory)throw 0}catch{throw new b("invalid_args",`media_root is not a folder on this machine: ${e}`)}let i=A(r,{ref_ids:t.ref_ids,lane:t.lane,reset:t.reset});if(!i.length)return{session:r,changed:!1,note:"",text:"nothing in scope: every reference in scope is already linked (use reset=true to re-point) or the ids/lane matched nothing"};if(t.reset)for(let e of i)e.binding_state="unbound",delete e.coverage_reason;let m=[],k=!1,u=[];for(let e of c)if(t.gather==="path")for(let n of i){let l=n.local_path??n.target_url??"",o=l?await P(e,l):null;o?m.push(o):u.push(`${n.id} ${p(l)}: not at its recorded path under ${e}`)}else{let n=await E(e,i,t.cap,{byName:t.criteria?.file_name!==!1,exts:t.criteria?.extensions});m.push(...n.paths),k||=n.capped}let{refs:$,failed:_}=await T([...new Set(m)]);t.remember&&t.media_root&&await B(t.media_root);let y=new Set(i.map(e=>e.id)),f=S(r,$,y);if(f.splits.length){r=f.session;let e=new Set([...y,...f.splits.flatMap(n=>n.into)]);i=(r.media_references??[]).filter(n=>e.has(n.id));for(let n of f.splits){let l=o=>p(i.find(G=>G.id===o)?.target_url??o);u.push(`split ${n.ref_id} across ${n.into.length} section file(s): ${n.into.map(l).join(", ")}`)}}let d=L(t.criteria),a=M(r,i,$,d,t.tolerances),O=t.criteria?.picture?await N(r,a):[],s=e=>a.rows.filter(n=>n.status===e).length,U=c.map(e=>e.split(/[\\/]/).filter(Boolean).pop()??e).join(", "),v=[`${t.dry_run?"would link":"found"} ${s("matched")} of ${i.length} clip${i.length===1?"":"s"} in ${U}${s("ambiguous")?`, ${s("ambiguous")} with more than one match`:""}${i.length-s("matched")-s("ambiguous")?`, ${i.length-s("matched")-s("ambiguous")} not found there`:""}${t.dry_run?" (dry run: nothing changed)":""}`,`scope: ${i.length} reference(s)${t.lane!=="both"?` (${t.lane} lane)`:""}${t.ref_ids?` (zone of ${t.ref_ids.length})`:""}; gather=${t.gather} under ${c.join(", ")}: ${$.length} candidate clip(s)${k?` (CAPPED at ${t.cap} \u2014 narrow the folder)`:""}`,`criteria: ${[...Object.entries(d).filter(([,e])=>e===!0).map(([e])=>e),...t.criteria?.picture?["picture"]:[]].join(", ")}${d.fileName?` (${d.fileNameMode})`:""}${d.fileExtensions?`; ext ${d.fileExtensions}`:""}; timecode containment + fps always on`,..._.length?[`could not probe ${_.length}: ${_.slice(0,5).join("; ")}`]:[],...u.slice(0,20),...O.slice(0,40)];if(t.dry_run)return{session:r,changed:!1,note:"",text:[...v,I(r,a,{compare:t.compare}),"(dry run \u2014 nothing changed; pass accept=[{ref_id,candidate_id}] to commit chosen rows, or run again without dry_run to apply every matched row)"].join(`
4
+ `)};let h,g=[];if(t.accept?.length){h=[];for(let e of t.accept){let n=a.rows.find(o=>o.ref_id===e.ref_id);n&&(n.candidate?.id===e.candidate_id||n.alternatives.some(o=>o.id===e.candidate_id))?h.push(e):g.push(`${e.ref_id} \u2192 ${e.candidate_id}: not a proposed match or alternative for that reference`)}}else h=a.rows.filter(e=>e.status==="matched"&&e.candidate).map(e=>({ref_id:e.ref_id,candidate_id:e.candidate.id}));let w=D(r,a,h),x=w.session.media_references??[],j=x.filter(e=>i.some(n=>n.id===e.id)&&e.binding_state==="linked").length,q=w.applied,C=x.filter(e=>i.some(n=>n.id===e.id)&&e.binding_state!=="linked").map(e=>` - ${e.id} ${p(e.target_url??"")}: ${e.coverage_reason??(a.rows.find(n=>n.ref_id===e.id)?.status==="ambiguous"?"ambiguous \u2014 pick one with accept":"no file matched")}`),F=[...v,`Linked ${j} of ${i.length}${g.length?`; ${g.length} pick(s) vetoed`:""}`,...q.map(e=>`- ${e.ref_id}: ${p(e.before.path??"?")} \u2192 ${e.after.path}${e.warning?` \u26A0 ${e.warning}`:""}`),...g.map(e=>` \u2717 ${e}`),...C.length?["unresolved:",...C]:[]].join(`
5
+ `);return{session:w.session,changed:!0,note:`relink ${t.gather} ${c[0]} (${j}/${i.length})`,text:F}}export{W as a};
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{a as E}from"./chunk-COALWMI7.js";import{U as x,b as y,g,h as f,l as w,m as h,t as p,w as b}from"./chunk-MU5AGXSH.js";async function k(){let e=f()==="win32"?"conformtools-analyze.exe":"conformtools-analyze",r=[y("CONFORM_ANALYZE"),w(e),p(new URL(`./${e}`,import.meta.url)),p(new URL(`../../rust/target/release/${e}`,import.meta.url))].filter(Boolean);for(let n of r)if(await b(n))return n;return null}var R=e=>e.code==="not_entitled"?new E("not_entitled",String(e.why)):void 0;async function A(e){let r=await P(),n=await r.ask({op:"job",reference:e.reference,clips:e.clips,lite:e.lite??!0,display:!!e.display});if(!n.ok)throw r.close(),R(n)??new Error(`analysis engine: ${n.why}`);return r}async function N(e,r,n){let i=await P(),t=()=>i.close();n?.addEventListener("abort",t);let s;try{s=await i.ask(e,r)}finally{n?.removeEventListener("abort",t),i.close()}if(n?.aborted)throw new Error("cancelled");if(!s.ok)throw R(s)??new Error(s.why??`the analysis engine could not run ${e.op}`);return s}async function P(){let e=await k();if(!e)throw new Error(h("the analysis engine (conformtools-analyze)"));let r="",n=null,i=[],t=x(e,["serve"],o=>{r+=new TextDecoder().decode(o);let a;for(;(a=r.indexOf(`
4
+ `))>=0;){let c=r.slice(0,a);r=r.slice(a+1);let l=JSON.parse(c);if(l.progress){n?.progress?.(l.progress[0],l.progress[1],l.phase??"");continue}let d=n;n=null,d?.done(l)}},o=>{console.error(o.trimEnd()),i=[...i,...o.split(`
5
+ `).filter(a=>a.trim())].slice(-3)}),s=null;t.exited.then(o=>{s={ok:!1,why:`the analysis engine exited${o==null?"":` (code ${o})`}${i.length?`: ${i.join(" | ").slice(0,400)}`:""}`},n?.done(s)});let m=Promise.resolve();return{ask:(o,a)=>{let c=m.then(async()=>{t.hold(!0);try{if(s)return s;let l=new Promise(v=>{n={done:v,progress:a}}),u=await t.write(new TextEncoder().encode(JSON.stringify(o)+`
6
+ `)).then(()=>!0,()=>!1)?await l:await Promise.race([l,t.exited.then(()=>s??{ok:!1,why:"the analysis engine exited"})]);return u.miss&&(console.error(`[mirror] MISS \u2014 ${u.miss} is not in the mirror. Replay never reads the source drive; record this case again with the drive mounted (CONFORM_MIRROR_MODE=record).`),g(75)),u}finally{t.hold(!1)}});return m=c.catch(()=>{}),c},close:()=>t.close()}}export{k as a,A as b,N as c,P as d};
@@ -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{readFile as S,writeFile as H,appendFile as q,stat as W,readdir as G,mkdir as _,open as U,copyFile as Y,mkdtemp as K,rm as P,chmod as V,rename as B,cp as X,statfs as Z,realpath as Q}from"node:fs/promises";import{execFile as ee,spawn as j}from"node:child_process";import{createHash as te}from"node:crypto";import{createReadStream as re,chmodSync as ne,cpSync as oe,existsSync as E,statSync as M}from"node:fs";import{homedir as se,hostname as ie,tmpdir as ae,platform as ce,release as le,arch as ue,totalmem as de,availableParallelism as me}from"node:os";import{fileURLToPath as O}from"node:url";import fe from"node:http";import pe from"node:http2";import f from"node:process";import{setTimeout as ge}from"node:timers";import{Buffer as $}from"node:buffer";import{basename as ye,dirname as we,join as h,resolve as C,sep as v}from"node:path";import{createRequire as be}from"node:module";import{basename as Tt,dirname as Dt,extname as Et,join as Mt,relative as Ct,resolve as Nt}from"node:path";{let e=globalThis.fetch,t=typeof globalThis.Deno<"u";e&&!t&&(globalThis.fetch=(async(r,o)=>{let n=typeof r=="string"?r:r instanceof URL?r.href:r.url;if(n.startsWith("file:")){let s=await S(O(n)),i=n.endsWith(".wasm")?"application/wasm":"application/octet-stream";return new Response(s,{status:200,headers:{"content-type":i}})}return e(r,o)}))}var w=e=>f.env[e];function Ie(e,t){ge(e,t).unref()}var He=()=>Number(w("CONFORM_MEMORY_GB")??0)*2**30||de(),We=()=>me(),_e=()=>f.argv.slice(2),Be=e=>f.exit(e),he=()=>f.platform,je=()=>ie(),ze=()=>w("CONFORM_PYTHON")??(he()==="win32"?"python":"python3"),Le=()=>f.arch,z=()=>`${f.platform}-${f.arch}`;function Je(e){try{return h(we(be(import.meta.url).resolve(`${xe(z())}/package.json`)),e)}catch{return null}}var xe=e=>`conformtools-${e==="win32-x64"?"windows-x64":e}`,qe=e=>`${e} is not in this package for ${z()} (conform.tools builds it for darwin-arm64, darwin-x64, linux-x64 and win32-x64)`;function Ge(){let e=f.versions.deno,t=w("CONFORM_APP_VERSION"),r=e?`deno ${e}`:`node ${f.version}`;return{platform:`${ce()} ${le()} ${ue()}`,runtime:t&&/^[0-9A-Za-z.-]{1,32}$/.test(t)?`${r} app ${t}`:r}}var ve=()=>w("CONFORM_MCP_HOME")??h(A(),".conform-mcp"),A=()=>w("HOME")??se();function Ye(e){let t=e.trim();if(t.length>=2&&(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1,-1)),/^file:\/\//i.test(t))try{t=O(t)}catch{}return t==="~"?t=A():(t.startsWith("~/")||t.startsWith("~\\"))&&(t=h(A(),t.slice(2))),t&&C(t)+(/[\\/]$/.test(t)&&!/[\\/]$/.test(C(t))?v:"")}async function Ke(e,t){let r=await import("node:sqlite").catch(()=>null);if(r?.DatabaseSync){let n=new r.DatabaseSync(e,{readOnly:!0});try{let s=n.prepare(t);return s.setReadBigInts(!0),s.all().map(i=>Object.fromEntries(Object.entries(i).map(([c,l])=>[c,typeof l=="bigint"?Number(l):l])))}finally{n.close()}}let o=await F("sqlite3",["-readonly","-json",e,t]);if(!o.success)throw new Error(`sqlite3 ${ye(e)}: ${o.stderr.trim()||o.stdout.trim()}`);return o.stdout.trim()?JSON.parse(o.stdout):[]}var Ve=(e,t)=>e?`${e.replace(/[\\/]+$/,"")}${e.includes("\\")&&!e.includes("/")?"\\":"/"}${t}`:t;function Xe(e){let t=O(e),r=t.indexOf(`${v}deno-compile-`);if(r<0||!E(t))return t;let o=t.slice(r+1).split(v).slice(1).join(v),n=h(ve(),"bin",o);try{let s=M(t),i=E(n)?M(n):null;return(!i||s.isFile()&&(i.size!==s.size||i.mtimeMs<s.mtimeMs))&&(oe(t,n,{recursive:!0,force:!0}),s.isFile()&&ne(n,493)),n}catch{return t}}var N=null;var x=e=>N?.owns(e)?N:null;async function I(e){let t=await W(e);return{isFile:t.isFile(),isDirectory:t.isDirectory(),size:t.size,mtimeMs:t.mtimeMs}}function R(e){return x(e)?.stat(e,()=>I(e))??I(e)}async function Ze(e){try{return await R(e),!0}catch{return!1}}async function Qe(e){try{return(await R(e)).isFile}catch{return!1}}async function et(e){try{return(await R(e)).isDirectory}catch{return!1}}async function tt(e){x(e)?.guard(e,"read whole file");let t=await S(e);return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}var rt=e=>S(e,"utf8"),nt=(e,t)=>H(e,t),ot=(e,t,r)=>r?.append?q(e,t):H(e,t);async function st(e){await _(e,{recursive:!0})}async function it(e,t={}){let r=Date.now()+(t.timeoutMs??5e3),o=t.staleMs??15e3;for(;;)try{await _(e);break}catch(n){if(n.code!=="EEXIST")throw n;try{if(Date.now()-(await R(e)).mtimeMs>o){await P(e,{recursive:!0,force:!0});continue}}catch{}if(Date.now()>r)break;await new Promise(s=>setTimeout(s,25))}return()=>P(e,{recursive:!0,force:!0}).catch(()=>{})}var at=e=>P(e,{force:!0}),ct=(e,t)=>V(e,t).catch(()=>{}),lt=(e,t)=>Y(e,t),ut=(e,t)=>B(e,t),dt=e=>P(e,{recursive:!0,force:!0}),mt=(e,t)=>X(e,t,{recursive:!0,verbatimSymlinks:!0});async function ft(e){try{let t=await Z(e);return Number(t.bavail)*Number(t.bsize)}catch{return null}}async function pt(e){try{return await Q(e)}catch{return null}}var gt=()=>f.ppid,yt=(e="conform-")=>K(h(ae(),e));async function*wt(e){let t=async()=>(await G(e,{withFileTypes:!0})).map(r=>({name:r.name,isFile:r.isFile(),isDirectory:r.isDirectory()}));yield*await(x(e)?.readDir(e,t)??t())}async function bt(e){x(e)?.guard(e,"read bytes");let t=await U(e,"r"),r=(await t.stat()).size;return{path:e,size:r,async readAt(o,n){let s=new Uint8Array(n),i=0;for(;i<n;){let{bytesRead:c}=await t.read(s,i,n-i,o+i);if(!c)break;i+=c}return i===n?s:s.subarray(0,i)},close:()=>t.close()}}async function ht(e){let t=await U(e,"w");return{async writeAt(r,o){let n=0;for(;n<o.length;){let{bytesWritten:s}=await t.write(o,n,o.length-n,r+n);n+=s}},truncate:r=>t.truncate(r),close:()=>t.close()}}var L=(e,t)=>{for(let r of t)x(r)?.guard(r,`${e.split(/[\\/]/).pop()} ${t[0]}`)};function F(e,t,r={}){return L(e,t),new Promise(o=>{ee(e,t,{maxBuffer:1<<30,env:r.env?{...f.env,...r.env}:void 0,timeout:r.timeoutMs},(n,s,i)=>{let c=n?.code??0;o({success:!n,code:c,stdout:String(s),stderr:String(i)})})})}var Pe="[Console]::OutputEncoding=[Text.Encoding]::UTF8;$t=@{};Get-Process|?{$_.MainWindowTitle}|%{$t[$_.Id]=$_.MainWindowTitle};ConvertTo-Json -Compress -InputObject @(Get-CimInstance Win32_Process|%{[pscustomobject]@{pid=[int]$_.ProcessId;exe=$_.ExecutablePath;cmd=$_.CommandLine;title=$t[[int]$_.ProcessId]}})";async function xt(){let e=await F("powershell.exe",["-NoProfile","-NonInteractive","-Command",Pe],{timeoutMs:3e4});return $e(e.stdout)}function $e(e){let t;try{t=JSON.parse(e.replace(/^/,"").trim()||"[]")}catch{return[]}return(Array.isArray(t)?t:[t]).flatMap(r=>{let o=r??{},n=Number(o.pid);return!Number.isInteger(n)||n<=0?[]:[{pid:n,args:String(o.cmd||o.exe||""),title:typeof o.title=="string"?o.title:""}]})}function vt(e,t,r,o={}){return L(e,t),new Promise((n,s)=>{let i=j(e,t,{env:o.env?{...f.env,...o.env}:void 0,stdio:["ignore","pipe","pipe"]}),c="";i.stdout.on("data",l=>r(l)),i.stderr.on("data",l=>{c+=new TextDecoder().decode(l)}),i.on("error",s),i.on("close",l=>n({code:l,stderr:c})),o.signal?.addEventListener("abort",()=>i.kill(),{once:!0})})}function Pt(e,t,r,o,n={}){let s=j(e,t,{stdio:["pipe","pipe","pipe"],env:n.env?{...f.env,...n.env}:void 0});s.stdin.on("error",()=>{}),s.stdout.on("data",a=>r(a)),s.stderr.on("data",a=>o?.(new TextDecoder().decode(a)));let i=new Promise(a=>{s.on("close",u=>a(u)),s.on("error",()=>a(null))}),c=[s,s.stdout,s.stderr,s.stdin],l=a=>{for(let u of c)(a?u.ref:u.unref)?.call(u)};return l(!1),{write:a=>new Promise((u,p)=>{s.stdin.write(a,m=>m?p(m):u())}),hold:l,close:()=>{try{s.stdin.end(),s.kill()}catch{}},exited:i}}async function $t(e){if(w("CONFORM_NO_BROWSER"))return!1;let[t,r]=f.platform==="darwin"?["open",[e]]:f.platform==="win32"?["cmd",["/c","start","",e.replace(/&/g,"^&")]]:["xdg-open",[e]];return(await F(t,r)).success}function Rt(e,t){let r=fe.createServer(async(o,n)=>{try{let s=[];if(o.method!=="GET"&&o.method!=="HEAD")for await(let p of o)s.push(p);let i=s.length>0,c=new Headers;for(let[p,m]of Object.entries(o.headers))m!=null&&c.set(p,Array.isArray(m)?m.join(", "):m);let l=`http://${o.headers.host??`${e.hostname}:${e.port}`}${o.url??"/"}`,a=new AbortController;n.on("close",()=>{n.writableEnded||a.abort()});let u=await t(new Request(l,{method:o.method,headers:c,body:i?$.concat(s):void 0,signal:a.signal}));if(n.statusCode=u.status,u.headers.forEach((p,m)=>n.setHeader(m,p)),u.body&&u.headers.get("content-type")?.startsWith("text/event-stream")){n.flushHeaders();let p=u.body.getReader();for(a.signal.addEventListener("abort",()=>void p.cancel(),{once:!0});;){let{value:m,done:g}=await p.read();if(g)break;n.write(m)}n.end();return}n.end($.from(await u.arrayBuffer()))}catch(s){n.statusCode=500,n.end(JSON.stringify({ok:!1,code:"internal",message:s instanceof Error?s.message:String(s)}))}});return r.listen(e.port,e.hostname,()=>{let o=r.address();e.onListen?.(typeof o=="object"&&o?o.port:e.port)}),{close:()=>r.close()}}var y=class extends Error{constructor(r,o,n){super(o);this.code=r;this.grpcStatus=n}};function kt(e,t,r,o,n){return new Promise((s,i)=>{let c=pe.connect(`http://${e}:${t}`),l=!1,a=(d,J)=>{l||(l=!0,clearTimeout(p),c.destroy(),d?i(d):s(J))},u=!1;c.on("connect",()=>{u=!0});let p=setTimeout(()=>a(u?new y("deadline",`no answer from ${e}:${t} in ${n} ms`):new y("unavailable",`${e}:${t}: no connection in ${n} ms`)),n);c.on("error",d=>a(new y("unavailable",`${e}:${t}: ${d.message}`)));let m=$.alloc(5+o.length);m.writeUInt32BE(o.length,1),m.set(o,5);let g=c.request({":method":"POST",":path":r,"content-type":"application/grpc",te:"trailers"}),T=[],b,k="",D=d=>{d["grpc-status"]!=null&&(b=String(d["grpc-status"]),k=decodeURIComponent(String(d["grpc-message"]??"")))};g.on("response",D),g.on("trailers",D),g.on("data",d=>T.push(d)),g.on("error",d=>a(new y("unavailable",`${e}:${t}: ${d.message}`))),g.on("end",()=>{if(b!=="0")return a(new y("grpc",`grpc-status ${b??"missing"}${k?`: ${k}`:""}`,b==null?void 0:Number(b)));let d=$.concat(T);if(d.length<5||d[0]!==0)return a(new y("grpc","reply is not one uncompressed gRPC message"));a(null,new Uint8Array(d.subarray(5,5+d.readUInt32BE(1))))}),g.end(m)})}async function At(e){let t=te("sha256");for await(let r of re(e))t.update(r);return t.digest("hex")}async function St(e,t,r){let o=`${t}.part`;for(let n=0;;n++){let s=0;try{s=(await W(o)).size}catch{}try{let i=await fetch(e,{headers:s?{Range:`bytes=${s}-`}:{}});if(i.status===416)break;if(!i.ok||!i.body)throw new Error(`${e} answered ${i.status}`);s&&i.status!==206&&(s=0);let c=s+Number(i.headers.get("content-length")??0),l=await U(o,s?"a":"w");try{let a=s;for await(let u of i.body)await l.write(u),a+=u.length,r?.(a,c)}finally{await l.close()}break}catch(i){if(n>=4)throw i;await new Promise(c=>setTimeout(c,2e3*(n+1)))}}await B(o,t)}function Ut(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}export{O as a,w as b,Ie as c,He as d,We as e,_e as f,Be as g,he as h,je as i,ze as j,Le as k,Je as l,qe as m,Ge as n,ve as o,A as p,Ye as q,Ke as r,Ve as s,Xe as t,R as u,Ze as v,Qe as w,et as x,tt as y,rt as z,nt as A,ot as B,st as C,it as D,at as E,ct as F,lt as G,ut as H,dt as I,mt as J,ft as K,pt as L,gt as M,yt as N,wt as O,bt as P,ht as Q,F as R,xt as S,vt as T,Pt as U,$t as V,Rt as W,y as X,kt as Y,At as Z,St as _,Ut as $,Tt as aa,Dt as ba,Et as ca,Mt as da,Ct as ea,Nt as fa};
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{Rb as F,Sb as N,Vb as D}from"./chunk-6IL7M3VP.js";import{i as j}from"./chunk-V2FVIZT7.js";import{B as E,C as M,G as C,I as R,J as T,N as q,O as L,R as w,aa as b,ca as k,da as _,fa as I,h as y,o as O,t as S,u as A,v as x,w as P,z as H}from"./chunk-MU5AGXSH.js";var W=16e3,h=class extends Error{constructor(t,s){super(s);this.code=t}},$=class p{constructor(e,t=j,s=W){this.spec=e;this.bridge=t;this.waitMs=s;this.renders=new Map;this.host=e.host,e.items&&(this.items=n=>this.modelItems(n??{}))}async peer(){let e=await(await this.bridge()).waitFor(this.host,this.waitMs);if(!e)throw new h("not_connected",`${this.host}: the conform.tools plugin in ${this.spec.label} is not connected. ${this.spec.setup}`);return e}async needs(e){let t=await this.peer();if(!t.capabilities.includes(e))throw new h("panel_old",`${this.host}: the conform.tools plugin open in ${this.spec.label} ${t.version||""} has no ${e} (an older plugin); update it (${this.spec.setup})`);return t}async ask(e,t={},s){return await this.peer(),await(await this.bridge()).request(this.host,e,t,s)}static{this.announced=(e,t)=>e.optional_verbs.includes(t)}async support(){let e;try{e=await(await this.bridge()).waitFor(this.host,Math.min(3e3,this.waitMs))}catch(n){let o={ok:!1,reason:n instanceof Error?n.message:String(n)};return{export:o,open:o,render:o,markers:o}}if(!e){let n={ok:!1,reason:`the conform.tools plugin in ${this.spec.label} is not connected`,setup:this.spec.setup};return{export:n,open:n,render:n,markers:n}}let t=(n,o)=>n?{ok:!0}:{ok:!1,reason:`this plugin version has no ${o}`},s=e.capabilities;return{export:t(s.includes("timeline_read")||s.includes("timeline_write"),"timeline_read"),open:t(p.announced(e,"timeline_write.import_file"),"timeline_write.import_file"),render:t(s.includes("render"),"render"),markers:t(s.includes("markers"),"markers")}}async current(){let e=await this.ask("session.current_project");if(!e)return{project:"",timelines:[],timeline:""};let t=await this.ask("session.timeline_count",{project:e}),s=[];for(let o=1;o<=t;o++){let l=await this.ask("session.timeline_by_index",{project:e,index:o});l&&s.push(await this.ask("session.name",{handle:l}))}let n=await this.ask("session.current_timeline",{project:e});return{project:await this.ask("session.name",{handle:e}),timelines:s,timeline:n?await this.ask("session.name",{handle:n}):""}}async project(e={}){let t=await this.current();return{project:t.project,timeline:e.timeline??t.timeline,timelines:t.timelines,tracks:[],jobs:[],found:{},pool:{path:"",clips:0,folders:[]}}}async sequence(e){let t=await this.ask("session.current_project");if(!t)throw new h("no_project",`${this.host}: no project is open`);if(!e){let o=await this.ask("session.current_timeline",{project:t});if(!o)throw new h("no_timeline",`${this.host}: no timeline is active`);return{project:t,seq:o,name:await this.ask("session.name",{handle:o})}}let s=await this.ask("session.timeline_count",{project:t}),n=[];for(let o=1;o<=s;o++){let l=await this.ask("session.timeline_by_index",{project:t,index:o});if(!l)continue;let d=await this.ask("session.name",{handle:l});if(d===e)return{project:t,seq:l,name:d};n.push(d)}throw new h("not_found",`${this.host}: no timeline named "${e}" (have: ${n.join(", ")})`)}async model(e){let{project:t,seq:s}=await this.sequence(e);return await this.ask("timeline_read.model",{timeline:s,project:t},12e4)}async export(e){if(!e.out_path)throw new h("usage",`${this.host}: export needs out_path`);let t=await this.peer(),{project:s,seq:n,name:o}=await this.sequence(e.timeline),l=await this.ask("session.name",{handle:s}),d=r=>p.announced(t,r),m=e.out_path,c,a=[];if(d("timeline_write.export_otio")||d("timeline_write.export_xml")){let r=d("timeline_write.export_otio"),i=await this.ask(r?"timeline_write.export_otio":"timeline_write.export_xml",{project:s,timeline:n,path:e.out_path},12e4);if(c=i.format??(r?"otio":"xmeml"),i.ok===!1)throw new h("export_failed",`${this.host}: ${this.spec.label} did not write ${e.out_path}${i.errors?.length?` (${i.errors.join("; ")})`:""}`);i.path&&i.path!==e.out_path&&(m=await this.adopt(i.path,e.out_path)),a=i.warnings??[]}else if(d("timeline_read.export_file")){let r=await this.ask("timeline_read.export_file",{timeline:n,fmt:"otio",path:e.out_path},12e4);if(!r)throw new h("export_failed",`${this.host}: ${this.spec.label} exported no OTIO`);c="otio",r!==e.out_path&&(m=await this.adopt(r,e.out_path))}else{await this.needs("timeline_read");let r=await this.ask("timeline_read.model",{timeline:n,project:s},12e4),i=J(r);await E(e.out_path,JSON.stringify(i.otio)),c="otio",a=i.notes}if(!F.includes(c))throw new h("export_failed",`${this.host}: ${this.spec.label} exported ${c}, which the engine does not read (${m})`);if(!await P(m)||(await A(m)).size===0)throw new h("export_failed",`${this.host}: ${this.spec.label} did not write ${m}`);return{path:m,format:c,project:l,timeline:o,...a.length?{notes:a}:{}}}async adopt(e,t){let s=k(e)&&k(e)!==k(t)?t.slice(0,t.length-k(t).length)+k(e):t;if(await C(e,s),!N(s))throw new h("export_failed",`${this.host}: ${this.spec.label} exported ${b(e)}, which the engine does not read`);return s}async open(e){if(e.into==="scratch")throw new h("unsupported",`${this.host}: opening into a scratch project is not supported; the import lands in the open project`);let t=await this.peer();if(!p.announced(t,"timeline_write.import_file"))throw new h("unsupported",`${this.host}: this conform.tools plugin cannot import timelines (${this.spec.setup})`);let s=await this.ask("session.current_project");if(!s)throw new h("no_project",`${this.host}: no project is open`);let n=await this.ask("timeline_write.import_file",{project:s,path:e.path,sequences:null},3e5);if(!n.ok)throw new h("import_failed",`${this.host}: ${this.spec.label} did not import ${e.path}${n.issues?.length?` (${n.issues.join("; ")})`:""}`);let o=[...n.issues??[]];return n.imported.length>1&&o.push(`imported ${n.imported.length} timelines: ${n.imported.map(l=>l.name).join(", ")}`),e.name&&o.push(`${this.spec.label} names imported timelines after the file's own; name was not applied`),e.media_dirs?.length&&o.push(`${this.spec.label} links media from the paths in the file; media_dirs was not used (relink with timeline_relink before writing)`),{project:await this.ask("session.name",{handle:s}),timeline:n.imported[0]?.name??b(e.path),notes:o,restored:!e.stay,...n.bin?{folder:n.bin}:{}}}async modelItems(e){let t=await this.model(e.timeline),s=[...e.kind==="audio"?[]:t.items.map(n=>({kind:"video",track:n.track,start:n.start-t.start_frame,end:n.end-t.start_frame,id:n.handle?.$h??n.clip_id??"",name:n.name??"",color:n.color??"",flags:n.flags??[],enabled:n.enabled??!0,file:n.file_path})),...e.kind==="video"?[]:(t.audio_items??[]).map(n=>({kind:"audio",track:n.track,start:n.start-t.start_frame,end:n.end-t.start_frame,id:"",name:n.name??"",file:n.file_path??""}))].filter(n=>e.track===void 0||n.track===e.track);return{project:(await this.current()).project,timeline:t.timeline,start_frame:t.start_frame,fps:t.fps,items:s,color_groups:[],layers:1}}async apply(e){let t=e.ops.length>0&&e.ops.every(a=>a.op==="timeline_rename"&&(a.timeline||a.guid)),{project:s,seq:n,name:o}=await this.sequence(t?void 0:e.timeline),l=[],d=[],m=a=>a.op.startsWith("marker_")&&!a.item;for(let a=0;a<e.ops.length;){let r=a;for(;r<e.ops.length&&m(e.ops[r])===m(e.ops[a]);)r++;let i=e.ops.slice(a,r),u=m(i[0])?await this.markerOps(n,i):await this.clipOps(n,i,e.timeline);l.push(...u.results),d.unshift(...u.undo),a=r}let c=l.filter(a=>a.ok).length;return{project:await this.ask("session.name",{handle:s}),timeline:o,results:l,undo:d,applied:c,failed:l.length-c}}async clipOps(e,t,s){let n=await this.peer();if(n.capabilities.includes("edit"))return await this.ask("edit.apply",{timeline:e,ops:t},6e4+t.length*500);let o=(a,r)=>({op:a.op,ok:!1,detail:r});if(!n.capabilities.includes("item_meta"))return{results:t.map(a=>o(a,`${this.host}: clip edits are not reachable over this plugin`)),undo:[]};let l=await this.model(s),d=a=>a?"id"in a?{$h:a.id}:(a.kind??"video")!=="video"?null:l.items.find(r=>r.track===a.track&&r.start-l.start_frame===a.start)?.handle??null:null,m=[],c=[];for(let a of t){let r=d(a.item);try{if(!r)m.push(o(a,`no video item at ${JSON.stringify(a.item??null)}`));else if(a.op==="clip_color"){let i=await this.ask("item_meta.color",{handle:r}),u=a.color?await this.ask("item_meta.set_color",{handle:r,color:a.color}):await this.ask("item_meta.clear_color",{handle:r});m.push({op:a.op,ok:u}),u&&c.unshift({op:"clip_color",item:a.item,color:i})}else if(a.op==="enabled"&&p.announced(n,"item_meta.set_enabled")){let i=l.items.find(f=>f.handle?.$h===r.$h)?.enabled??!0,u=await this.ask("item_meta.set_enabled",{item:r,enabled:!!a.on});m.push({op:a.op,ok:u}),u&&c.unshift({op:"enabled",item:a.item,on:i})}else m.push(o(a,`${this.host}: '${a.op}' is not reachable over this plugin`))}catch(i){m.push(o(a,i instanceof Error?i.message:String(i)))}}return{results:m,undo:c}}async markerOps(e,t){let s=await this.peer(),n=r=>p.announced(s,r),o=new Map((await this.ask("markers.list",{target:e})).map(r=>[r.frame,r])),l=[],d=[],m=async r=>{let i=await this.ask("markers.add",{target:e,frame:r.frame,color:r.color??"",name:r.name??"",note:r.note??"",duration:r.duration??1,custom_data:r.custom_data??""});return i&&o.set(r.frame,{color:"",name:"",note:"",duration:1,...r}),i},c=async r=>{let i=await this.ask("markers.delete_at",{target:e,frame:r});return i&&o.delete(r),i},a=r=>({op:"marker_add",frame:r.frame,color:r.color,name:r.name,note:r.note,duration:r.duration,...r.custom_data?{data:r.custom_data}:{}});for(let r of t){let i=Number(r.frame);try{if(r.op==="marker_add"){let u=o.get(i);u&&await c(i);let f=await m({frame:i,color:r.color,name:r.name,note:r.note,duration:Number(r.duration??1),custom_data:r.data});l.push({op:r.op,ok:f}),f&&d.unshift(...u?[a(u)]:[],{op:"marker_delete",frame:i})}else if(r.op==="marker_update"){let u=o.get(i);if(!u){l.push({op:r.op,ok:!1,detail:`no marker at frame ${i}`});continue}let f=r.to_frame!==void 0?Number(r.to_frame):i,v={...u,frame:f,...r.color!==void 0?{color:String(r.color)}:{},...r.name!==void 0?{name:String(r.name)}:{},...r.note!==void 0?{note:String(r.note)}:{}},g=!0;n("markers.set_color")&&n("markers.set_text")&&n("markers.move")?(r.color!==void 0&&(g=await this.ask("markers.set_color",{target:e,frame:i,color:r.color})&&g),(r.name!==void 0||r.note!==void 0)&&(g=await this.ask("markers.set_text",{target:e,frame:i,name:r.name,note:r.note})&&g),f!==i&&(g=await this.ask("markers.move",{target:e,frame:i,to_frame:f})&&g),o.delete(i),o.set(f,v)):g=await c(i)&&await m(v),l.push({op:r.op,ok:g}),d.unshift({op:"marker_update",frame:f,color:u.color,name:u.name,note:u.note,...f!==i?{to_frame:i}:{}})}else if(r.op==="marker_delete"){let u=o.get(i),f=!!u&&await c(i);l.push({op:r.op,ok:f,...u?{}:{detail:`no marker at frame ${i}`}}),f&&u&&d.unshift(a(u))}else l.push({op:r.op,ok:!1,detail:`${this.host}: '${r.op}' is not reachable over this plugin`})}catch(u){l.push({op:r.op,ok:!1,detail:u instanceof Error?u.message:String(u)})}}return{results:l,undo:d}}async renderStart(e){if(await this.needs("render"),e.disable_tracks?.length||e.audio_tracks?.length)throw new h("unsupported",`${this.host}: disable_tracks / audio_tracks are DaVinci Resolve's; pick a preset that renders what you need`);if(!e.preset)throw new h("usage",`${this.host}: preset is required: one of ${this.spec.label}'s export presets by name`);let{seq:t,name:s}=await this.sequence(e.timeline),n=e.name??s,o={purpose:"deliver",format:"preset",preset:e.preset,target_dir:e.target_dir,name:n,...e.range?{range:[e.range.in,e.range.out]}:{}},l=await this.ask("render.submit",{timeline:t,job:o});if(!l?.id)throw new h("render_refused",`${this.host}: ${l?.error??`${this.spec.label} refused the render`}`);if(!await this.ask("render.start",{job_ids:[l.id]}))throw new h("render_refused",`${this.host}: ${this.spec.label} did not start job ${l.id}`);return this.renders.set(l.id,{dir:e.target_dir,name:n}),{job_id:l.id,state:"queued",percent:0}}async renderStatus(e){let t=await this.ask("render.status",{job_id:e});if(!t)return{job_id:e,state:"failed",percent:0,error:`${this.host}: no render job ${e}`};let s={done:"complete",rendering:"rendering",queued:"queued",failed:"failed",cancelled:"cancelled"}[t.state]??"rendering",n={job_id:e,state:s,percent:Math.round(t.progress??(s==="complete"?100:0)),...t.error?{error:t.error}:{}};if(s==="complete"||s==="failed"||s==="cancelled"){let o=this.renders.get(e);s==="complete"&&o&&(n.outputs=await V(o.dir,o.name)),await this.ask("render.remove",{job_id:e}).catch(()=>!1),this.renders.delete(e)}return n}async renderCancel(e){return await this.ask("render.cancel",{job_id:e})?{job_id:e,state:"cancelled",percent:0}:{...await this.renderStatus(e),error:`${this.spec.label}'s running export cannot be cancelled from here; stop it in ${this.spec.label}`}}};async function V(p,e){let t=[];try{for await(let s of L(p))s.isFile&&s.name.startsWith(`${e}.`)&&t.push(_(p,s.name))}catch{}return t.sort()}function J(p){let e=(c,a)=>({OTIO_SCHEMA:"RationalTime.1",value:c,rate:a}),t=(c,a,r,i=r)=>({OTIO_SCHEMA:"TimeRange.1",start_time:e(c,r),duration:e(a,i)}),s=p.fps,n=p.tracks?.length?p.tracks:[...new Set(p.items.map(c=>c.track))].sort((c,a)=>c-a).map(c=>({index:c,enabled:!0,name:"",items:p.items.filter(a=>a.track===c)})),o=c=>(c.reversed?-1:1)*(c.speed||1)/(c.fps_factor||1),l=new Map;for(let c of p.items)if(c.file_path&&c.start_tc!=null&&c.src_abs_in!=null){let a=c.src_abs_in-c.start_tc+Math.ceil((c.end-c.start)*Math.abs(o(c))*(c.fps_factor||1));l.set(c.file_path,Math.max(l.get(c.file_path)??0,a))}let d=n.map(c=>{let a=p.start_frame,r=[];for(let i of[...c.items].sort((u,f)=>u.start-f.start)){if(i.start<a)continue;i.start>a&&r.push({OTIO_SCHEMA:"Gap.1",name:"",source_range:t(0,i.start-a,s)});let u=i.src_fps||s,f=i.start_tc!=null&&l.has(i.file_path)?i.start_tc:null,v=f!=null?i.src_abs_in:i.src_in??i.src_abs_in??0,g=o(i);r.push({OTIO_SCHEMA:"Clip.2",name:i.name??b(i.file_path||""),enabled:i.enabled!==!1,source_range:t(v,i.end-i.start,u,s),media_references:{DEFAULT_MEDIA:{OTIO_SCHEMA:"ExternalReference.1",name:b(i.file_path||""),target_url:i.file_path?`file://${i.file_path}`:"",...f!=null?{available_range:t(f,l.get(i.file_path),u)}:{},metadata:{}}},active_media_reference_key:"DEFAULT_MEDIA",effects:Math.abs(g-1)>1e-6?[{OTIO_SCHEMA:"LinearTimeWarp.1",name:"",effect_name:"LinearTimeWarp",time_scalar:g}]:[],markers:[],metadata:i.reel?{cmx_3600:{reel:i.reel}}:{}}),a=i.end}return{OTIO_SCHEMA:"Track.1",name:c.name||`V${c.index}`,kind:"Video",enabled:c.enabled!==!1,children:r,effects:[],markers:[],metadata:{}}}),m=[];return p.audio_items?.length&&m.push(`${p.audio_items.length} audio clip(s) not carried: the host's plugin reports no audio source times`),p.transitions?.length&&m.push(`${p.transitions.length} transition(s) not carried (cuts in their place)`),{otio:{OTIO_SCHEMA:"Timeline.1",name:p.timeline,global_start_time:e(p.start_frame,s),metadata:{},tracks:{OTIO_SCHEMA:"Stack.1",name:"tracks",children:d,effects:[],markers:[],metadata:{}}},notes:m}}var X=16e3,G="Install the conform.tools panel (host_setup host=premiere action=install_panel), then in Premiere open Window > UXP Plugins > conform.tools. It connects by itself from then on.";var U=class extends ${constructor(t=j,s=X){super({host:"premiere",label:"Premiere Pro",setup:G},t,s);this.items=async(t={})=>{await this.needs("edit");let{seq:s}=await this.sequence(t.timeline),n=await this.ask("edit.items",{timeline:s,kind:t.kind,track:t.track},12e4),o=n.project_path?await K(n.project_path,n.timeline).catch(d=>({error:d instanceof Error?d.message:String(d)})):{error:"the project has never been saved"},l=0;if(!("error"in o))for(let d of n.items){let m=o.get(`${d.kind}:${d.track}:${d.start}:${Number(d.end)-Number(d.start)}`);m?Object.assign(d,m,{saved:!0}):(d.saved=!1,l++)}return{...n,color_groups:[],layers:1,..."error"in o?{saved_note:`saved project not read: ${o.error}`}:{unsaved_items:l}}};this.premiereRenders=new Map}async current(){let t=await this.ask("session.describe");return{project:t.project,timelines:t.timelines,timeline:t.current}}async liveMarkers(t){if(!$.announced(await this.peer(),"edit.markers"))return null;let{seq:s}=await this.sequence(t);return await this.ask("edit.markers",{timeline:s},12e4)}async model(t){return await super.model(t)}async projectClips(){return await this.needs("edit"),await this.ask("edit.project_clips",{},12e4)}async relinkClips(t){return await this.needs("edit"),await this.ask("edit.relink_clips",{items:t},6e4+t.length*2e3)}async cutIn(t,s){await this.needs("edit");let{seq:n}=await this.sequence(t);return await this.ask("edit.cut_in",{timeline:n,cuts:s},12e4+s.length*3e3)}async renderStart(t){if(t.range)throw new h("unsupported","premiere: a frame range is not supported yet; set in/out on the sequence in Premiere");if(!t.preset||!/\.epr$/i.test(t.preset))throw new h("usage","premiere: preset must be the path of a Media Encoder preset (.epr)");let{seq:s,name:n}=await this.sequence(t.timeline);await M(t.target_dir);let o=_(t.target_dir,`${t.name??n}.mov`),l=await this.ask("render.export_sequence",{timeline:s,output_path:o,preset_path:t.preset,queue:!1},6e4);if(!l.ok)throw new h("render_refused","premiere: Premiere refused the export");let d=l.job||`ppro-${Date.now()}`;return this.premiereRenders.set(d,o),{job_id:d,state:"rendering",percent:0}}async renderStatus(t){let s=await this.ask("render.progress"),n=s[t]??s.last,o=this.premiereRenders.get(t);return n?.event==="error"||n?.event==="onEncodeError"?{job_id:t,state:"failed",percent:0,error:String(n.data??"encode error")}:n?.event==="complete"||n?.event==="onEncodeComplete"||o&&await x(o)&&!n?{job_id:t,state:"complete",percent:100,...o?{outputs:[o]}:{}}:{job_id:t,state:"rendering",percent:typeof n?.data=="number"?Math.round(Number(n.data)*100):0}}async renderCancel(t){return{job_id:t,state:"cancelled",percent:0,error:"Premiere's export cannot be cancelled from here; cancel it in Premiere / Media Encoder"}}};async function K(p,e){let{session:t}=await D(p,"prproj"),s=t.timelines.find(o=>o.name===e),n=new Map;if(!s)throw new Error(`the saved project has no sequence "${e}" (saved before it was made?)`);for(let o of s.tracks)if(!(o.kind!=="Video"&&o.kind!=="Audio"))for(let l of o.items){if(l.kind==="gap"||l.kind==="transition")continue;let d=l;n.set(`${o.kind==="Video"?"video":"audio"}:${o.track_index}:${l.timeline_range.start.value}:${l.timeline_range.duration.value}`,{saved_id:l.id,...d.speed_factor!=null&&d.speed_factor!==1?{retime:d.speed_factor}:{},...d.speed_ramped?{ramped:!0}:{},...d.speed_reverse?{reversed:!0}:{},...l.kind==="nested"?{nested:!0}:{},...d.is_multicam?{multicam:!0}:{},...d.effects?.some(m=>/stabiliz/i.test(m.kind??""))?{stabilized:!0}:{},...d.effects?.length?{saved_effects:d.effects.map(m=>m.name??m.kind??"")}:{}})}return n}function z(p=y()){return p==="darwin"?"/Library/Application Support/Adobe/Adobe Desktop Common/RemoteComponents/UPI/UnifiedPluginInstallerAgent/UnifiedPluginInstallerAgent.app/Contents/MacOS/UnifiedPluginInstallerAgent":p==="win32"?"C:\\Program Files\\Common Files\\Adobe\\Adobe Desktop Common\\RemoteComponents\\UPI\\UnifiedPluginInstallerAgent\\UnifiedPluginInstallerAgent.exe":null}async function B(){for(let p of["./uxp-plugin/","./premiere-uxp/"]){let e=S(new URL(p,import.meta.url));if(await P(_(e,"manifest.json")))return e}throw new Error("premiere: the conform.tools panel is missing from this install")}async function Q(){return JSON.parse(await H(_(await B(),"manifest.json"))).version}async function oe(p=y()){let e=z(p);if(!e||!await x(e))return{installed:!1,listing:"Creative Cloud's plugin installer is not on this machine"};let t=await w(e,p==="win32"?["/list","all"]:["--list","all"],{timeoutMs:6e4}),s=t.stdout.split(`
4
+ `).find(n=>/CONFORM\.TOOLS|conformtools/i.test(n));return{installed:!!s&&/enabled|installed/i.test(s),version:s?.match(/(\d+\.\d+\.\d+)\s*$/)?.[1],listing:t.stdout.trim()}}async function ae(p=y()){let e=z(p);if(!e||!await x(e))throw new Error("premiere: Creative Cloud's plugin installer (UnifiedPluginInstallerAgent) is not on this machine; install Creative Cloud");let t=await B(),s=await Q(),n=await q("conform-ccx-");for(let a of["manifest.json","index.html","index.js","lib","icons"])await T(_(t,a),_(n,a));let o=_(O(),"premiere");await M(o);let l=I(_(o,`conformtools-premiere-${s}.ccx`));await R(l);let d=p==="darwin"?await w("sh",["-c",`cd '${n.replace(/'/g,"'\\''")}' && zip -r -q -X '${l.replace(/'/g,"'\\''")}' manifest.json index.html index.js lib icons`]):await w("powershell",["-NoProfile","-Command",`Compress-Archive -Path '${n}\\*' -DestinationPath '${l.replace(/\.ccx$/,".zip")}' -Force; Move-Item -Force '${l.replace(/\.ccx$/,".zip")}' '${l}'`]);if(await R(n),!d.success)throw new Error(`premiere: could not package the panel: ${d.stderr.trim()}`);await w(e,p==="win32"?["/remove","conform.tools"]:["--remove","conform.tools"],{timeoutMs:12e4});let m=await w(e,p==="win32"?["/install",l]:["--install",l],{timeoutMs:18e4}),c=`${m.stdout}
5
+ ${m.stderr}`.trim();if(!m.success||!/Installation Successful/i.test(c))throw new Error(`premiere: Adobe's installer refused the panel: ${c.split(`
6
+ `).pop()}`);return{version:s,ccx:l,output:c}}export{$ as a,U as b,K as c,Q as d,oe as e,ae as f};
@@ -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 L}from"./chunk-BD54PRSN.js";import{A as O,B as R,D as W,E as I,ca as P,n as _,s as H,y as N}from"./chunk-HZG55H3B.js";import X from"node:http";import{connect as Y}from"node:net";import{createHash as M,randomBytes as U}from"node:crypto";import{Buffer as d}from"node:buffer";var j="258EAFA5-E914-47DA-95CA-C5AB0DC85B11";function A(a,e,c=!1){let n=e.length,r=c?128:0,s=n<126?d.from([128|a,r|n]):n<65536?d.from([128|a,r|126,n>>8,n&255]):(()=>{let o=d.alloc(10);return o[0]=128|a,o[1]=r|127,o.writeBigUInt64BE(BigInt(n),2),o})();if(!c)return d.concat([s,d.from(e)]);let t=U(4),i=d.from(e);for(let o=0;o<i.length;o++)i[o]^=t[o&3];return d.concat([s,t,i])}function D(a,e,c,n=!1){let r=d.alloc(0),s=[],t=0,i=!1,o=[],p=[],u=()=>{i||(i=!0,p.forEach(l=>l()))},f=(l=1e3,m="")=>{if(i)return;let h=d.from(m),g=d.alloc(2+h.length);g.writeUInt16BE(l,0),h.copy(g,2);try{a.write(A(8,g,n))}catch{}a.end(),u()};return a.on("data",l=>{for(r=d.concat([r,l]);r.length>=2;){let m=(r[0]&128)!==0,h=r[0]&15,g=(r[1]&128)!==0,v=r[1]&127,w=2;if(v===126){if(r.length<4)return;v=r.readUInt16BE(2),w=4}else if(v===127){if(r.length<10)return;let b=r.readBigUInt64BE(2);if(b>BigInt(c))return f(1009,"too big");v=Number(b),w=10}if(g===n)return f(1002,n?"server frames must not be masked":"client frames must be masked");if(v>c||t+v>c)return f(1009,"message too big");let E=g?4:0;if(r.length<w+E+v)return;let S=d.from(r.subarray(w+E,w+E+v));if(g){let b=r.subarray(w,w+4);for(let x=0;x<S.length;x++)S[x]^=b[x&3]}if(r=r.subarray(w+E+v),h===8)return f(1e3);if(h===9){a.write(A(10,S,n));continue}if(h!==10){if(h===1||h===0){if(s.push(S),t+=S.length,m){let b=d.concat(s).toString("utf8");s=[],t=0,o.forEach(x=>x(b))}continue}return f(1003,"text frames only")}}}),a.on("close",u),a.on("error",u),{origin:e,send:l=>{i||a.write(A(1,d.from(l,"utf8"),n))},close:f,onMessage:l=>{o.push(l)},onClose:l=>{p.push(l)}}}function J(a,e){let c=new Set,n=X.createServer((r,s)=>{let t=n.address();a.onHttp?.(r,s,typeof t=="object"&&t?t.port:a.port)||(s.writeHead(426,{"content-type":"text/plain"}),s.end("websocket only"))});return n.on("upgrade",(r,s)=>{let t=r.headers["sec-websocket-key"];if(r.url?.split("?")[0]!==a.path||typeof t!="string"||String(r.headers.upgrade).toLowerCase()!=="websocket"){s.end(`HTTP/1.1 400 Bad Request\r
3
+ import{a as L}from"./chunk-GHP6HDLM.js";import{B as O,C as R,E as W,F as I,da as P,o as _,t as H,z as N}from"./chunk-MU5AGXSH.js";import X from"node:http";import{connect as Y}from"node:net";import{createHash as M,randomBytes as U}from"node:crypto";import{Buffer as d}from"node:buffer";var j="258EAFA5-E914-47DA-95CA-C5AB0DC85B11";function A(a,e,c=!1){let n=e.length,r=c?128:0,s=n<126?d.from([128|a,r|n]):n<65536?d.from([128|a,r|126,n>>8,n&255]):(()=>{let o=d.alloc(10);return o[0]=128|a,o[1]=r|127,o.writeBigUInt64BE(BigInt(n),2),o})();if(!c)return d.concat([s,d.from(e)]);let t=U(4),i=d.from(e);for(let o=0;o<i.length;o++)i[o]^=t[o&3];return d.concat([s,t,i])}function D(a,e,c,n=!1){let r=d.alloc(0),s=[],t=0,i=!1,o=[],p=[],u=()=>{i||(i=!0,p.forEach(l=>l()))},f=(l=1e3,m="")=>{if(i)return;let h=d.from(m),g=d.alloc(2+h.length);g.writeUInt16BE(l,0),h.copy(g,2);try{a.write(A(8,g,n))}catch{}a.end(),u()};return a.on("data",l=>{for(r=d.concat([r,l]);r.length>=2;){let m=(r[0]&128)!==0,h=r[0]&15,g=(r[1]&128)!==0,v=r[1]&127,w=2;if(v===126){if(r.length<4)return;v=r.readUInt16BE(2),w=4}else if(v===127){if(r.length<10)return;let b=r.readBigUInt64BE(2);if(b>BigInt(c))return f(1009,"too big");v=Number(b),w=10}if(g===n)return f(1002,n?"server frames must not be masked":"client frames must be masked");if(v>c||t+v>c)return f(1009,"message too big");let E=g?4:0;if(r.length<w+E+v)return;let S=d.from(r.subarray(w+E,w+E+v));if(g){let b=r.subarray(w,w+4);for(let x=0;x<S.length;x++)S[x]^=b[x&3]}if(r=r.subarray(w+E+v),h===8)return f(1e3);if(h===9){a.write(A(10,S,n));continue}if(h!==10){if(h===1||h===0){if(s.push(S),t+=S.length,m){let b=d.concat(s).toString("utf8");s=[],t=0,o.forEach(x=>x(b))}continue}return f(1003,"text frames only")}}}),a.on("close",u),a.on("error",u),{origin:e,send:l=>{i||a.write(A(1,d.from(l,"utf8"),n))},close:f,onMessage:l=>{o.push(l)},onClose:l=>{p.push(l)}}}function J(a,e){let c=new Set,n=X.createServer((r,s)=>{let t=n.address();a.onHttp?.(r,s,typeof t=="object"&&t?t.port:a.port)||(s.writeHead(426,{"content-type":"text/plain"}),s.end("websocket only"))});return n.on("upgrade",(r,s)=>{let t=r.headers["sec-websocket-key"];if(r.url?.split("?")[0]!==a.path||typeof t!="string"||String(r.headers.upgrade).toLowerCase()!=="websocket"){s.end(`HTTP/1.1 400 Bad Request\r
4
4
  \r
5
5
  `);return}let i=M("sha1").update(t+j).digest("base64");s.write(`HTTP/1.1 101 Switching Protocols\r
6
6
  Upgrade: websocket\r