conformtools 0.6.6 → 0.6.8

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 (72) hide show
  1. package/README.md +15 -10
  2. package/dist/{account-HDXVTS5T.js → account-NJSA4N67.js} +1 -1
  3. package/dist/{bridge-D5KPIUSY.js → bridge-UIDAF74E.js} +1 -1
  4. package/dist/browser/timeline_core_bg.wasm +0 -0
  5. package/dist/chunk-2BPR6LK6.js +3 -0
  6. package/dist/{chunk-VS3MKKJ5.js → chunk-3D3Z4TBR.js} +1 -1
  7. package/dist/{chunk-P7OVDUA5.js → chunk-6V4OEOOX.js} +1 -1
  8. package/dist/{chunk-SZD4C5MB.js → chunk-7SENYEIV.js} +1 -1
  9. package/dist/{chunk-6ML26TIK.js → chunk-A7FNR3T5.js} +1 -1
  10. package/dist/chunk-AMRJXYL4.js +3 -0
  11. package/dist/{chunk-RFIPLBQ4.js → chunk-BW4LRTHG.js} +1 -1
  12. package/dist/{chunk-5SUGU2YR.js → chunk-D4WPRRBT.js} +1 -1
  13. package/dist/{chunk-EJGVNQ3E.js → chunk-F74QMWXE.js} +1 -1
  14. package/dist/{chunk-AS7IXHYM.js → chunk-GK4YYKJ6.js} +1 -1
  15. package/dist/{chunk-LFJLRLEP.js → chunk-GM6QKY7W.js} +1 -1
  16. package/dist/chunk-H6WZ43NS.js +39 -0
  17. package/dist/{chunk-OVUCL3YY.js → chunk-IPFPZBSC.js} +1 -1
  18. package/dist/{chunk-HGDO3OED.js → chunk-J2JXLEAI.js} +1 -1
  19. package/dist/{chunk-5RSNFPED.js → chunk-JZY2BHQB.js} +7 -6
  20. package/dist/{chunk-5JBUCVRI.js → chunk-LGUO7PL5.js} +1 -1
  21. package/dist/{chunk-UKKRZ574.js → chunk-MS3AWOSG.js} +2 -2
  22. package/dist/{chunk-3OCQA33E.js → chunk-PHAMF4JF.js} +2 -1
  23. package/dist/chunk-RGMTLNMF.js +3 -0
  24. package/dist/chunk-RJ6JA2LZ.js +3 -0
  25. package/dist/{chunk-X53BNWNV.js → chunk-SGLQY53R.js} +1 -1
  26. package/dist/{chunk-OJWIBQK4.js → chunk-SYX6W5TS.js} +167 -165
  27. package/dist/{chunk-3XD6NC4G.js → chunk-VIBEEWPC.js} +1 -1
  28. package/dist/{chunk-NQHQKEP5.js → chunk-WN53ARHJ.js} +1 -1
  29. package/dist/cli.js +3 -3
  30. package/dist/conformtools-analyze +0 -0
  31. package/dist/conformtools-decode +0 -0
  32. package/dist/{cr3-wasm-L2LFY3LM.js → cr3-wasm-HLJWEV2S.js} +1 -1
  33. package/dist/{dng-wasm-U6NC3MDK.js → dng-wasm-CQDLPM5V.js} +1 -1
  34. package/dist/{dpx-wasm-RMKEUKED.js → dpx-wasm-TLGMM7BO.js} +1 -1
  35. package/dist/{exr-wasm-LBAOMOZD.js → exr-wasm-2NPKPTVB.js} +1 -1
  36. package/dist/framing-7LAOPOED.js +3 -0
  37. package/dist/gfx-worker.js +1 -1
  38. package/dist/{h264-3ESGVT6G.js → h264-JJMZSUWW.js} +1 -1
  39. package/dist/{h264-mxf-NPFS7NGH.js → h264-mxf-DCUOGLDU.js} +1 -1
  40. package/dist/{host-relink-D6CB2VOQ.js → host-relink-UOS3P5SL.js} +1 -1
  41. package/dist/hosts-66KSLCFJ.js +3 -0
  42. package/dist/http.js +2 -2
  43. package/dist/{inspect-7ASUPU73.js → inspect-FJKYPEXL.js} +15 -15
  44. package/dist/{isobmff-SIOE67WL.js → isobmff-VJOWP4MH.js} +1 -1
  45. package/dist/mc-video-5MGGOQN4.js +3 -0
  46. package/dist/mcp.js +1 -1
  47. package/dist/{media-7AUNRKHF.js → media-NZYVREUF.js} +1 -1
  48. package/dist/media_core-YZ3PABEG.js +9 -0
  49. package/dist/{mxf-74TTDICM.js → mxf-FJSRFLJC.js} +1 -1
  50. package/dist/{ops-FSOOBXMV.js → ops-X7NAREC4.js} +1 -1
  51. package/dist/premiere-uxp/lib/probe.js +212 -1
  52. package/dist/{r3d-ZDJ3WURS.js → r3d-CXUNG6VS.js} +1 -1
  53. package/dist/{r3d-YTLOMC7C.js → r3d-T5O6IIZZ.js} +1 -1
  54. package/dist/{source-BDJAUQVR.js → source-QGWWLMME.js} +1 -1
  55. package/dist/still-P4JJNTEO.js +3 -0
  56. package/dist/still-wasm-DN5LPASS.js +3 -0
  57. package/dist/{store-ZHXLQCGN.js → store-EXUE5XX5.js} +1 -1
  58. package/dist/{tiff-wasm-D2FJ3L56.js → tiff-wasm-BPRDR6EB.js} +1 -1
  59. package/dist/{timeline-6DYFDVEH.js → timeline-GVVL2CBI.js} +1 -1
  60. package/dist/wasm/media_core_bg.wasm +0 -0
  61. package/dist/wasm-threads/media_core_bg.wasm +0 -0
  62. package/dist/{wav-OWMUGQMM.js → wav-64SC6P7U.js} +1 -1
  63. package/package.json +1 -1
  64. package/dist/chunk-7MC7M2Y5.js +0 -3
  65. package/dist/chunk-BL6L5ZBP.js +0 -39
  66. package/dist/chunk-C5IX63YF.js +0 -3
  67. package/dist/chunk-UCMNH6Q6.js +0 -3
  68. package/dist/chunk-XNR7M4VX.js +0 -3
  69. package/dist/framing-SRCJKAYO.js +0 -3
  70. package/dist/hosts-W4AD2MYH.js +0 -3
  71. package/dist/media_core-Q2PIEV7D.js +0 -9
  72. package/dist/still-ZG2RUQAL.js +0 -3
@@ -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 M}from"./chunk-PFZVET7S.js";import{b as fe,c as pe,f as he}from"./chunk-P7OVDUA5.js";import{f as K,h as me}from"./chunk-7MC7M2Y5.js";import{a as de}from"./chunk-VS3MKKJ5.js";import{i as D}from"./chunk-XNR7M4VX.js";import{b as C,d as J,f as R}from"./chunk-NU3X7P4N.js";import{Ga as ue,da as oe,ea as ie,ia as se,na as ae,va as ce,wa as le}from"./chunk-C5IX63YF.js";import{a as ne}from"./chunk-3OCQA33E.js";import{C as W,I as v,J as A,K as re,N as te,V as b,W as y,X as L,Y as _,b as E,c as Z,d as Q,g as q,p as I,q as B,s as ee,t as O,w as H,y as j}from"./chunk-PLRB2YXJ.js";var V=!1;var F=8,Me=0,Fe=3,z=2;async function Pe(e){let t=new Uint8Array(await e.slice(0,16).arrayBuffer()),o=s=>String.fromCharCode(t[s],t[s+1],t[s+2],t[s+3]);if(t[0]===6&&t[1]===14&&t[2]===43&&t[3]===52)return"mxf";if(o(4)==="RED1"||o(4)==="RED2")return"r3d";let r=t[0]<<24|t[1]<<16|t[2]<<8|t[3],i=o(4);return/^[A-Za-z0-9 ]{4}$/.test(i)&&(r>=8||r===1)&&r<=e.size?"isobmff":null}function Ee(e){let t=e.toLowerCase();return t.endsWith(".braw")?"braw":t.endsWith(".crm")?"crm":"mov"}function Oe(e){return async(t,o)=>new Uint8Array(await e.slice(t,Math.min(t+o,e.size)).arrayBuffer())}function be(e){let t=e.timecode;return!t||!t.fps_denominator?null:t.fps_numerator/t.fps_denominator}async function nr(e){return await ue(),ge?ge.clip(e,V?"rec709":"",()=>we(e)):we(e)}var ge=null;async function we(e){let t=await Pe(e),o=[];if(t==="r3d"){let r=e,i=r.parts&&r.bases?r.parts:[{name:e.name,size:e.size}],n=r.bases??[0],s=async(u,m,d)=>{let f=n[u]+m;return new Uint8Array(await e.slice(f,Math.min(f+d,n[u]+i[u].size)).arrayBuffer())},a=JSON.stringify(i.map(u=>({name:u.name,size:u.size}))),c=JSON.parse(await le(s,a)),l=JSON.parse(await se(s,a));return i.length===1&&/_\d{3}\.r3d$/i.test(e.name)&&!/_001\.r3d$/i.test(e.name)&&o.push("spanned R3D part \u2014 only this part's frames are indexed"),{frames:l.map(u=>({offset:n[u.part??0]+u.essenceOffset,size:u.essenceLength})),w:c.width??0,h:c.height??0,fps:be(c),startFrame:c.timecode?.start_frame??0,dropFrame:c.timecode?.drop_frame??!1,label:"R3D",spec:{codec:"r3d",subbands:Me},geometrySpec:{codec:"r3d",subbands:Fe},index:null,warnings:o}}if(t==="mxf"){let r=Oe(e),i=JSON.parse(await ce(r,e.size));if(!i)throw new Error(`${e.name}: MXF index unreadable`);let n=JSON.parse(await ae(r,e.size)),s=[];for(let f=0;f<n.frame_count;f++)s.push({offset:n.frames[f*2],size:n.frames[f*2+1]});let a=s.filter(f=>f.size===0).length;a&&o.push(`${a} frame(s) had no locatable picture KLV`);let c=i.width??0,l=i.height??0,u=(i.inner_codec??"").toLowerCase(),m=null,d="MXF";return u==="arriraw"?(m={codec:"arriraw",w:c,h:l,scale:F},d="ARRIRAW"):u==="xocn"?(m={codec:"xocn",scale:F,...V?{display:"rec709"}:{}},d="X-OCN"):await ie(r,e.size)?(m={codec:"vc3",scale:F},d="DNxHR"):await oe(r,e.size)?(m={codec:"prores"},d="ProRes"):o.push(`MXF inner codec ${u||"unknown"} not wired to the fingerprint pool`),{frames:m?s:[],w:c,h:l,fps:be(i),startFrame:i.timecode?.start_frame??0,dropFrame:i.timecode?.drop_frame??!1,label:d,spec:m,geometrySpec:m&&m.codec==="arriraw"?{...m,scale:z}:m&&m.codec==="xocn"?{codec:"xocn",scale:z,...V?{display:"rec709"}:{}}:m&&m.codec==="vc3"?{codec:"vc3",scale:z}:null,index:null,warnings:o}}if(t==="isobmff"){let r=await me(e),i=Ee(e.name);if(r.kind==="prores")return{frames:r.offs,w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:K(r.kind),spec:{codec:"prores"},geometrySpec:null,index:r,warnings:o};if(r.kind==="h264"||r.kind==="hevc")return{frames:r.offs,w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:K(r.kind),spec:null,geometrySpec:null,index:r,warnings:o};let n=i==="braw"?{codec:"braw",scale:F}:r.codec==="aprh"||r.codec==="aprn"?{codec:"proresraw",scale:F}:null;return n||o.push(`codec ${r.codec} not wired to the fingerprint pool`),{frames:n?r.offs:[],w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:n?i==="braw"?"BRAW":"ProRes RAW":`unsupported (${r.codec})`,spec:n,geometrySpec:n?{...n,scale:z}:null,index:r,warnings:o}}throw new Error(`${e.name}: unrecognised container`)}var Ae=Number(E("CONFORM_DECODERS")??0)||Math.max(2,Math.min(Math.floor(Q()/2),Math.floor(Z()/2**31))),X=0,_e=[],Ce=async(...e)=>{X>=Ae?await new Promise(t=>_e.push(t)):X++;try{return await te(...e)}finally{let t=_e.shift();t?t():X--}};async function De(){let e=q()==="win32"?"conformtools-decode.exe":"conformtools-decode",t=[E("CONFORM_NATIVE_DECODE"),I(new URL(`./${e}`,import.meta.url)),I(new URL(`../../rust/target/release/${e}`,import.meta.url))].filter(Boolean);for(let o of t)if(await ee(o))return o;return null}var $=class extends Error{constructor(o,r){super(r);this.why=o}};function Mr(e){let t=null;try{t=JSON.parse(e.trim().split(`
3
+ import{a as M}from"./chunk-PFZVET7S.js";import{b as fe,c as pe,f as he}from"./chunk-6V4OEOOX.js";import{f as K,h as me}from"./chunk-AMRJXYL4.js";import{a as de}from"./chunk-3D3Z4TBR.js";import{i as D}from"./chunk-2BPR6LK6.js";import{b as C,d as J,f as R}from"./chunk-NU3X7P4N.js";import{Ha as ue,da as oe,ea as ie,ia as se,na as ae,va as ce,wa as le}from"./chunk-RJ6JA2LZ.js";import{a as ne}from"./chunk-PHAMF4JF.js";import{C as W,I as v,J as A,K as re,N as te,V as b,W as y,X as L,Y as _,b as E,c as Z,d as Q,g as q,p as I,q as B,s as ee,t as O,w as H,y as j}from"./chunk-PLRB2YXJ.js";var V=!1;var F=8,Me=0,Fe=3,z=2;async function Pe(e){let t=new Uint8Array(await e.slice(0,16).arrayBuffer()),o=s=>String.fromCharCode(t[s],t[s+1],t[s+2],t[s+3]);if(t[0]===6&&t[1]===14&&t[2]===43&&t[3]===52)return"mxf";if(o(4)==="RED1"||o(4)==="RED2")return"r3d";let r=t[0]<<24|t[1]<<16|t[2]<<8|t[3],i=o(4);return/^[A-Za-z0-9 ]{4}$/.test(i)&&(r>=8||r===1)&&r<=e.size?"isobmff":null}function Ee(e){let t=e.toLowerCase();return t.endsWith(".braw")?"braw":t.endsWith(".crm")?"crm":"mov"}function Oe(e){return async(t,o)=>new Uint8Array(await e.slice(t,Math.min(t+o,e.size)).arrayBuffer())}function be(e){let t=e.timecode;return!t||!t.fps_denominator?null:t.fps_numerator/t.fps_denominator}async function nr(e){return await ue(),ge?ge.clip(e,V?"rec709":"",()=>we(e)):we(e)}var ge=null;async function we(e){let t=await Pe(e),o=[];if(t==="r3d"){let r=e,i=r.parts&&r.bases?r.parts:[{name:e.name,size:e.size}],n=r.bases??[0],s=async(u,m,d)=>{let f=n[u]+m;return new Uint8Array(await e.slice(f,Math.min(f+d,n[u]+i[u].size)).arrayBuffer())},a=JSON.stringify(i.map(u=>({name:u.name,size:u.size}))),c=JSON.parse(await le(s,a)),l=JSON.parse(await se(s,a));return i.length===1&&/_\d{3}\.r3d$/i.test(e.name)&&!/_001\.r3d$/i.test(e.name)&&o.push("spanned R3D part \u2014 only this part's frames are indexed"),{frames:l.map(u=>({offset:n[u.part??0]+u.essenceOffset,size:u.essenceLength})),w:c.width??0,h:c.height??0,fps:be(c),startFrame:c.timecode?.start_frame??0,dropFrame:c.timecode?.drop_frame??!1,label:"R3D",spec:{codec:"r3d",subbands:Me},geometrySpec:{codec:"r3d",subbands:Fe},index:null,warnings:o}}if(t==="mxf"){let r=Oe(e),i=JSON.parse(await ce(r,e.size));if(!i)throw new Error(`${e.name}: MXF index unreadable`);let n=JSON.parse(await ae(r,e.size)),s=[];for(let f=0;f<n.frame_count;f++)s.push({offset:n.frames[f*2],size:n.frames[f*2+1]});let a=s.filter(f=>f.size===0).length;a&&o.push(`${a} frame(s) had no locatable picture KLV`);let c=i.width??0,l=i.height??0,u=(i.inner_codec??"").toLowerCase(),m=null,d="MXF";return u==="arriraw"?(m={codec:"arriraw",w:c,h:l,scale:F},d="ARRIRAW"):u==="xocn"?(m={codec:"xocn",scale:F,...V?{display:"rec709"}:{}},d="X-OCN"):await ie(r,e.size)?(m={codec:"vc3",scale:F},d="DNxHR"):await oe(r,e.size)?(m={codec:"prores"},d="ProRes"):o.push(`MXF inner codec ${u||"unknown"} not wired to the fingerprint pool`),{frames:m?s:[],w:c,h:l,fps:be(i),startFrame:i.timecode?.start_frame??0,dropFrame:i.timecode?.drop_frame??!1,label:d,spec:m,geometrySpec:m&&m.codec==="arriraw"?{...m,scale:z}:m&&m.codec==="xocn"?{codec:"xocn",scale:z,...V?{display:"rec709"}:{}}:m&&m.codec==="vc3"?{codec:"vc3",scale:z}:null,index:null,warnings:o}}if(t==="isobmff"){let r=await me(e),i=Ee(e.name);if(r.kind==="prores")return{frames:r.offs,w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:K(r.kind),spec:{codec:"prores"},geometrySpec:null,index:r,warnings:o};if(r.kind==="h264"||r.kind==="hevc")return{frames:r.offs,w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:K(r.kind),spec:null,geometrySpec:null,index:r,warnings:o};let n=i==="braw"?{codec:"braw",scale:F}:r.codec==="aprh"||r.codec==="aprn"?{codec:"proresraw",scale:F}:null;return n||o.push(`codec ${r.codec} not wired to the fingerprint pool`),{frames:n?r.offs:[],w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:n?i==="braw"?"BRAW":"ProRes RAW":`unsupported (${r.codec})`,spec:n,geometrySpec:n?{...n,scale:z}:null,index:r,warnings:o}}throw new Error(`${e.name}: unrecognised container`)}var Ae=Number(E("CONFORM_DECODERS")??0)||Math.max(2,Math.min(Math.floor(Q()/2),Math.floor(Z()/2**31))),X=0,_e=[],Ce=async(...e)=>{X>=Ae?await new Promise(t=>_e.push(t)):X++;try{return await te(...e)}finally{let t=_e.shift();t?t():X--}};async function De(){let e=q()==="win32"?"conformtools-decode.exe":"conformtools-decode",t=[E("CONFORM_NATIVE_DECODE"),I(new URL(`./${e}`,import.meta.url)),I(new URL(`../../rust/target/release/${e}`,import.meta.url))].filter(Boolean);for(let o of t)if(await ee(o))return o;return null}var $=class extends Error{constructor(o,r){super(r);this.why=o}};function Mr(e){let t=null;try{t=JSON.parse(e.trim().split(`
4
4
  `).pop())}catch{}if(t?.why==="not_entitled")throw new ne("not_entitled",t.detail??"this machine is not licensed");return t?.detail??e.trim()}function ze(e,t){try{let o=JSON.parse(e.trim().split(`
5
5
  `).pop()??"");return new $(o.why,o.detail)}catch{return new $("decoder",`the native decoder exited ${t}: ${e.trim().slice(-300)}`)}}function Ne(e){let t=e.reduce((i,n)=>i+n.length,0),o=new Uint8Array(t),r=0;for(let i of e)o.set(i,r),r+=i.length;return o}async function ye(e,t,o,r,i){let n=await De();if(!n)throw new $("missing","the native decoder (conformtools-decode) is not installed");let s=null,a=[],c=0,l=d=>{let f=new Uint8Array(d),p=0;for(;p<d;){let h=a[0],g=Math.min(h.length,d-p);f.set(h.subarray(0,g),p),p+=g,g===h.length?a.shift():a[0]=h.subarray(g)}return c-=d,f},u=[e,t,"--width",String(i.width??32768)];i.from!=null&&u.push("--from",String(i.from)),i.count!=null&&u.push("--count",String(i.count)),i.range&&u.push("--range",i.range);let m=await Ce(n,u,d=>{if(a.push(d),c+=d.length,!s){let p=Ne(a.splice(0));a.push(p);let h=p.indexOf(10);if(h<0)return;s=JSON.parse(new TextDecoder().decode(p.subarray(0,h))),l(h+1),o(s)}let f=4+s.w*s.h*(s.bpp??(e==="rgb16"?6:4));for(;c>=f;){let p=l(f);r(new DataView(p.buffer).getUint32(0,!0),p.subarray(4))}},{signal:i.signal});if(m.code!==0||!s)throw ze(m.stderr,m.code)}function xe(e,t,o,r={}){return ye("bgra",e,t,o,r)}function $e(e,t,o,r={}){return ye("rgb16",e,t,(i,n)=>o(i,new Uint16Array(n.buffer,n.byteOffset,n.length>>1)),r)}var Te=["none","rle","zips","zip","piz","pxr24","b44","b44a","dwaa","dwab","htj2k"],N=e=>(e>>4)*10+(e&15);function Ue(e){let t=N(e&63),o=N(e>>>8&127),r=N(e>>>16&127),i=N(e>>>24&63),n=s=>String(s).padStart(2,"0");return`${n(i)}:${n(r)}:${n(o)}${e&64?";":":"}${n(t)}`}function ke(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.length<8||t.getUint32(0,!0)!==20000630)return null;let o={fps:null,timecode:null,width:0,height:0,display:null,compression:null,attributes:[]},r=8,i=()=>{let s=r;for(;r<e.length&&e[r]!==0;)r++;let a=new TextDecoder().decode(e.subarray(s,r));return r++,a},n=s=>({width:t.getInt32(s+8,!0)-t.getInt32(s,!0)+1,height:t.getInt32(s+12,!0)-t.getInt32(s+4,!0)+1});for(;r<e.length;){let s=i();if(!s)break;let a=i();if(r+4>e.length)return null;let c=t.getInt32(r,!0);if(r+=4,c<0||r+c>e.length)return null;if(o.attributes.push(`${s}:${a}`),s==="framesPerSecond"&&a==="rational"&&c>=8){let l=t.getInt32(r,!0),u=t.getUint32(r+4,!0);o.fps=u?l/u:null}else s==="timeCode"&&a==="timecode"&&c>=8?o.timecode=Ue(t.getUint32(r,!0)):s==="dataWindow"&&a==="box2i"&&c>=16?{width:o.width,height:o.height}=n(r):s==="displayWindow"&&a==="box2i"&&c>=16?o.display=n(r):s==="compression"&&c>=1&&(o.compression=Te[e[r]]??`type ${e[r]}`);r+=c}return o}async function Ie(e){let t=e,o=null,r=/^(.*?)\[(\d+)-(\d+)\](.*)$/.exec(b(e));if(await O(e))o=/^(.*?)(\d+)(\.exr)$/i;else{t=y(e);let n=r?[null,r[1],r[2],r[4]]:/^(.*?)(\d+)(\.exr)$/i.exec(b(e));if(!n)return{frames:[e],numbers:[]};let s=a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");o=new RegExp(`^${s(n[1])}(\\d{${n[2].length}})${s(n[3])}$`,"i")}let i=[];for await(let n of v(t)){let s=n.isFile?o.exec(n.name):null;s&&i.push({n:Number(s[s.length===4?2:1]),f:_(t,n.name)})}return i.sort((n,s)=>n.n-s.n),{frames:i.map(n=>n.f),numbers:i.map(n=>n.n)}}async function ve(e){let t=await Ie(e),o=t.frames[0];if(!o)throw new Error(`no .exr frames for '${b(e)}'`);let r=await A(o),i;try{i=ke(await r.readAt(0,Math.min(r.size,1<<20)))}finally{await r.close()}if(!i)throw new Error(`'${b(o)}' is not an OpenEXR file`);let n=Math.max(1,t.frames.length),s=t.numbers.length>1?t.numbers[t.numbers.length-1]-t.numbers[0]+1-t.numbers.length:0,a=i.fps??0;return{id:b(o),kind:"external",target_url:o,local_path:o,content_kind:n>1?"video":"still",source_fps:i.fps??void 0,source_timecode:i.timecode??void 0,source_resolution_w:i.width,source_resolution_h:i.height,available_range:{start:{value:0,rate:a},duration:{value:n,rate:a}},streams:[{kind:"video",codec:"exr",width:i.width,height:i.height,rate:i.fps??void 0,codec_specific:{compression:i.compression}}],vendor_metadata:{exr:{frames:n,first_frame:t.numbers[0]??null,last_frame:t.numbers[t.numbers.length-1]??null,missing_frames:s,display_window:i.display,attributes:i.attributes,fps_source:i.fps!=null?"header framesPerSecond":"not in the header",timecode_source:i.timecode?"header timeCode (first frame)":"not in the header"}}}}var G=new Set([".mov",".mp4",".m4v",".mxf",".wav",".braw",".crm",".r3d",".aif",".aiff"]);async function Be(e){let t=await A(e);return{path:e,file:t,size:t.size}}function He(e){return(t,o)=>e.file.readAt(t,o)}async function je(e){let t=M(b(e));if(!t)return[e];let o=y(e),r=[];for await(let i of v(o)){if(!i.isFile)continue;let n=M(i.name);n&&n.clipBase===t.clipBase&&r.push({n:n.partNumber,p:_(o,i.name)})}return r.sort((i,n)=>i.n-n.n).map(i=>i.p)}async function Y(e){if(await O(e)){let n=[];for await(let s of v(e))s.isFile&&M(s.name)&&n.push(_(e,s.name));if(!n.length)throw new Error(`'${b(e)}' is a folder with no .R3D parts`);e=n.sort()[0]}let t=pe(b(e));if(!t)throw new Error(`unsupported media file '${b(e)}' (supported: ${[...G].join(" ")})`);let o=await je(e),r=await Promise.all(o.map(Be));return{source:he(t,r.map(n=>fe(b(n.path),{fileSize:n.size,read:He(n)}))),parts:r,format:t,anchor:o[0],close:()=>r.forEach(n=>n.file.close())}}async function We(e,t,o,r){if(!/h264|avc|hevc|h265/.test(o)){let i=null,n=await Y(e);try{return await D(n.source,{verb:"decode",index:t,intent:"park"})}catch(s){i=s}finally{n.close()}try{return await Se(e,t,r)}catch(s){throw/no decoder/.test(String(i))?s:i instanceof Error?i:new Error(String(i))}}return Se(e,t,r)}async function kr(e,t,o,r={}){if(/\.mxf$/i.test(e)&&(!o||/h264|avc|mxf/.test(o))){let a=null,c=null;try{await $e(e,l=>{a=l},(l,u)=>{l===t&&(c=u.slice())},{from:t,count:1,range:r.range})}catch(l){if(!(l instanceof $)||!/unsupported|missing/.test(l.why))throw l}if(c&&a){let l=a;return{rgb:c,width:l.w,height:l.h,bits:l.bit_depth??16,decoder:"media-core",full_range:l.full_range??null}}}let i=await We(e,t,o),n=i.width*i.height,s=new Uint16Array(n*3);for(let a=0;a<n;a++)s[a*3]=i.rgba[a*4]*257,s[a*3+1]=i.rgba[a*4+1]*257,s[a*3+2]=i.rgba[a*4+2]*257;return{rgb:s,width:i.width,height:i.height,bits:8,decoder:"8-bit",full_range:null}}async function Se(e,t,o){t=Math.round(t);let r=0,i=0,n=null;if(await xe(e,a=>{r=a.w,i=a.h},(a,c)=>{a===t&&(n=c)},{from:t,count:1,width:o}),!n)throw new Error(`the OS decoder returned no frame ${t} of ${b(e)}`);let s=n;for(let a=0;a<s.length;a+=4){let c=s[a];s[a]=s[a+2],s[a+2]=c}return{rgba:s,width:r,height:i}}async function P(e){if(/\.exr$/i.test(e))return ve(e);let t=await Y(e);try{let o=await D(t.source,{verb:"inspect"});if(!o)throw new Error(`could not read '${b(e)}' as ${t.format}`);return o.target_url=t.anchor,o.local_path=t.anchor,o.id=o.id||b(t.anchor),t.parts.length>1&&((o.vendor_metadata??={}).spanned_parts=t.parts.map(r=>b(r.path))),o.size_bytes=t.parts.reduce((r,i)=>r+i.size,0),o}finally{t.close()}}function Le(e,t,o,r){let i=Math.abs(r*1001-Math.round(r*1001/1e3)*1e3)<1?Math.round(r)*1e3/1001:r,n=Math.floor(e*i/t+1e-6);return{tc:C(n,r),frames:Math.round(o*i/t)}}var Je=e=>String(Math.round(e*1e3)/1e3);function Ir(e,t){let o=e.streams?.find(m=>m.kind==="video"),r=e.streams?.filter(m=>m.kind==="audio")??[],i=e.vendor_metadata?.bext;if(!o&&e.available_range&&r[0]?.rate){let m=r[0].rate,d=e.available_range.duration.value,p=(t?[t]:[24e3/1001,24]).map(h=>{let g=Le(i?.time_reference??0,i?.sample_rate||m,d,h);return`${i?`start TC ${g.tc}, `:""}${g.frames} frames @ ${Je(h)} fps`});return[e.target_url??"",`audio only; ${d} samples (${(d/m).toFixed(3)} s)${i?`; BWF time_reference ${i.time_reference}`:"; no BWF timecode"}`,...p,...t?[]:["(pass fps for the project's rate)"],...r.map((h,g)=>`audio ${r.length>1?`${g+1}: `:""}${h.codec??"pcm"} ${h.channels??"?"}ch ${h.rate} Hz ${h.bit_depth??"?"}-bit`)].join(`
6
6
  `)}let n=e.available_range?.duration?.value??e.declared_duration?.value??null,s=e.source_fps??o?.rate??null,a=e.size_bytes,c=e.vendor_metadata?.spanned_parts,l=o?.codec_specific??{},u=[l.profile?`${l.profile} (${l.fourcc})`:l.fourcc,l.pixel_format,o?.bit_depth?`${o.bit_depth}-bit`:null,l.colr?`colour ${l.colr.primaries}/${l.colr.transfer}/${l.colr.matrix} (primaries/transfer/matrix)`:null].filter(Boolean).join(", ");return[e.target_url??"",o?`${o.codec??"?"} ${o.width??"?"}x${o.height??"?"}${s?` @ ${Math.round(s*1e3)/1e3} fps`:""}${u?`; ${u}`:""}`:"no video track",`start TC ${e.source_timecode??"none"}; ${n!=null?`${n} frames`:"length unknown"}${n!=null&&s?` (${(n/s).toFixed(2)} s)`:""}`,r.length?r.map((m,d)=>{let f=m.codec_specific?.channel_layout;return`audio ${r.length>1?`${d+1}: `:""}${m.codec??"pcm"} ${m.channels??"?"}ch${f?` (${f})`:""} ${m.rate??"?"} Hz ${m.bit_depth??"?"}-bit`}).join(`
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a as m,b as l}from"./chunk-DKGGJM6Z.js";import{Ea as u,Ga as n,Z as c,r as s}from"./chunk-C5IX63YF.js";async function g(r){await n();let e=c(r);return e==="null"?null:JSON.parse(e)}async function d(r){await n();let e;try{e=s(r)}catch{return null}if(e.length<8)return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength),a=t.getUint32(0,!0),i=t.getUint32(4,!0),o=a*i*4;return e.length<8+o?null:{width:a,height:i,rgba:new Uint8ClampedArray(e.subarray(8,8+o))}}async function y(r,e=8){await n();let t=l(u,"decode_exr_preview");if(!t)return d(r);try{return m(t(r,e))}catch{return null}}export{g as a,d as b,y as c};
3
+ import{a as m,b as l}from"./chunk-DKGGJM6Z.js";import{Fa as u,Ha as n,Z as c,r as s}from"./chunk-RJ6JA2LZ.js";async function g(r){await n();let e=c(r);return e==="null"?null:JSON.parse(e)}async function d(r){await n();let e;try{e=s(r)}catch{return null}if(e.length<8)return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength),a=t.getUint32(0,!0),i=t.getUint32(4,!0),o=a*i*4;return e.length<8+o?null:{width:a,height:i,rgba:new Uint8ClampedArray(e.subarray(8,8+o))}}async function y(r,e=8){await n();let t=l(u,"decode_exr_preview");if(!t)return d(r);try{return m(t(r,e))}catch{return null}}export{g as a,d as b,y as c};
package/dist/cli.js CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{$ as V,V as J,X as H,Y as F,_ as G}from"./chunk-OJWIBQK4.js";import"./chunk-OVUCL3YY.js";import"./chunk-UKKRZ574.js";import"./chunk-LFJLRLEP.js";import"./chunk-RFIPLBQ4.js";import"./chunk-SZD4C5MB.js";import{J as L}from"./chunk-BL6L5ZBP.js";import{a as A}from"./chunk-5JBUCVRI.js";import"./chunk-PFISREY4.js";import"./chunk-TXQR2HI2.js";import"./chunk-JV7TZDKJ.js";import"./chunk-3XD6NC4G.js";import"./chunk-PFZVET7S.js";import"./chunk-P7OVDUA5.js";import"./chunk-UCMNH6Q6.js";import"./chunk-5SUGU2YR.js";import"./chunk-NQHQKEP5.js";import"./chunk-6ML26TIK.js";import"./chunk-HGDO3OED.js";import"./chunk-X53BNWNV.js";import"./chunk-DKGGJM6Z.js";import"./chunk-D6YDLKSA.js";import"./chunk-7MC7M2Y5.js";import"./chunk-VS3MKKJ5.js";import"./chunk-XNR7M4VX.js";import"./chunk-AS7IXHYM.js";import{b as W}from"./chunk-NU3X7P4N.js";import"./chunk-C5IX63YF.js";import"./chunk-EJGVNQ3E.js";import{h as D,i as I}from"./chunk-5RSNFPED.js";import"./chunk-3OCQA33E.js";import{b as T,e as c,f as s}from"./chunk-PLRB2YXJ.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";var i=process.stdout,C=22,E=20,R=E/2,Y=(t,n)=>Math.abs(n)<=Math.min(1-.417*Math.abs(t),2.393*(1-Math.abs(t))),nt=(t,n)=>t*t+n*n<=1;function et(t){let n=.62**-t,l=[];for(let r=0;r<E;r++){let p=[];for(let g=0;g<C;g++){let w=(g+.5)/C*2-1,u=(r+.5)/E*2-1,d=!1;if(Y(w,u))for(let $=0;$<6;$++)for(let y of[!1,!0]){let m=.62**$*(y?.77:1)*n,x=.5*Math.max(0,1-m)**2;(y?nt:Y)(w/m,(u-x)/m)&&(d=!y)}p.push(d)}l.push(p)}return l}var M={C:["\u25E2\u2588\u25E3","\u2588 ","\u2588 ","\u25E5\u2588\u25E4"],O:["\u25E2\u2588\u25E3","\u2588 \u2588","\u2588 \u2588","\u25E5\u2588\u25E4"],N:["\u2588\u25E3 \u2588","\u2588\u2588\u25E3\u2588","\u2588\u25E5\u2588\u2588","\u2588 \u25E5\u2588"],F:["\u2588\u2588\u2588","\u2588\u2584\u2584","\u2588 ","\u2588 "],R:["\u2588\u2588\u25E3","\u2588 \u2588","\u2588\u2588\u25E4","\u2588 \u2588"],M:["\u2588\u25E3\u25E2\u2588","\u2588\u25E5\u25E4\u2588","\u2588 \u2588","\u2588 \u2588"],T:["\u2588\u2588\u2588"," \u2588 "," \u2588 "," \u2588 "],L:["\u2588 ","\u2588 ","\u2588 ","\u2588\u2588\u2588"],S:["\u25E2\u2588\u25E3","\u25E5\u25E3 "," \u25E5\u25E3","\u25E5\u2588\u25E4"],".":[" "," "," ","\u25CF"]},B="CONFORM.TOOLS",rt=[...B].reduce((t,n)=>t+M[n][0].length+1,-1);async function K(t){if(!i.isTTY)return!1;let n=!!T("NO_COLOR"),l=/truecolor|24bit/i.test(T("COLORTERM")??""),r=o=>e=>n?e:`\x1B[${o}m${e}\x1B[0m`,p=r(l?"38;2;255;60;0":"38;5;202"),g=r(l?"38;2;255;222;0":"38;5;220"),w=r("1"),u=r("2"),d=(i.columns??80)>=C+4+rt,$=o=>[...B].map(e=>e==="."?p(M[e][o]):w(M[e][o])).join(" "),y=(o,e)=>d&&o>=2&&o<=5?$(o-2):!d&&o===3?`${w("conform")}${p(".")}${w("tools")}`:o===7?e:"",m=(o,e,O=[])=>{let S=et(o),_=[];for(let f=0;f<R;f++){let Z=S[2*f].map((N,ot)=>{let k=S[2*f+1][ot];return N&&k?"\u2588":N?"\u2580":k?"\u2584":" "}).join(""),tt=f>=8?O[f-8]??"":"";_.push(` ${p(Z)} ${tt||y(f,e)}\x1B[K`)}return _.join(`
3
+ import{$ as V,V as J,X as H,Y as F,_ as G}from"./chunk-SYX6W5TS.js";import"./chunk-BW4LRTHG.js";import"./chunk-IPFPZBSC.js";import"./chunk-MS3AWOSG.js";import"./chunk-7SENYEIV.js";import"./chunk-TXQR2HI2.js";import{J as L}from"./chunk-H6WZ43NS.js";import{a as A}from"./chunk-LGUO7PL5.js";import"./chunk-GM6QKY7W.js";import"./chunk-PFISREY4.js";import"./chunk-JV7TZDKJ.js";import"./chunk-VIBEEWPC.js";import"./chunk-PFZVET7S.js";import"./chunk-6V4OEOOX.js";import"./chunk-RGMTLNMF.js";import"./chunk-D4WPRRBT.js";import"./chunk-WN53ARHJ.js";import"./chunk-A7FNR3T5.js";import"./chunk-J2JXLEAI.js";import"./chunk-SGLQY53R.js";import"./chunk-DKGGJM6Z.js";import"./chunk-D6YDLKSA.js";import"./chunk-AMRJXYL4.js";import"./chunk-3D3Z4TBR.js";import"./chunk-2BPR6LK6.js";import"./chunk-GK4YYKJ6.js";import{b as W}from"./chunk-NU3X7P4N.js";import"./chunk-RJ6JA2LZ.js";import"./chunk-F74QMWXE.js";import{h as D,i as I}from"./chunk-JZY2BHQB.js";import"./chunk-PHAMF4JF.js";import{b as T,e as c,f as s}from"./chunk-PLRB2YXJ.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";var i=process.stdout,C=22,E=20,R=E/2,Y=(t,n)=>Math.abs(n)<=Math.min(1-.417*Math.abs(t),2.393*(1-Math.abs(t))),nt=(t,n)=>t*t+n*n<=1;function et(t){let n=.62**-t,l=[];for(let r=0;r<E;r++){let g=[];for(let p=0;p<C;p++){let w=(p+.5)/C*2-1,u=(r+.5)/E*2-1,d=!1;if(Y(w,u))for(let $=0;$<6;$++)for(let y of[!1,!0]){let m=.62**$*(y?.77:1)*n,x=.5*Math.max(0,1-m)**2;(y?nt:Y)(w/m,(u-x)/m)&&(d=!y)}g.push(d)}l.push(g)}return l}var M={C:["\u25E2\u2588\u25E3","\u2588 ","\u2588 ","\u25E5\u2588\u25E4"],O:["\u25E2\u2588\u25E3","\u2588 \u2588","\u2588 \u2588","\u25E5\u2588\u25E4"],N:["\u2588\u25E3 \u2588","\u2588\u2588\u25E3\u2588","\u2588\u25E5\u2588\u2588","\u2588 \u25E5\u2588"],F:["\u2588\u2588\u2588","\u2588\u2584\u2584","\u2588 ","\u2588 "],R:["\u2588\u2588\u25E3","\u2588 \u2588","\u2588\u2588\u25E4","\u2588 \u2588"],M:["\u2588\u25E3\u25E2\u2588","\u2588\u25E5\u25E4\u2588","\u2588 \u2588","\u2588 \u2588"],T:["\u2588\u2588\u2588"," \u2588 "," \u2588 "," \u2588 "],L:["\u2588 ","\u2588 ","\u2588 ","\u2588\u2588\u2588"],S:["\u25E2\u2588\u25E3","\u25E5\u25E3 "," \u25E5\u25E3","\u25E5\u2588\u25E4"],".":[" "," "," ","\u25CF"]},B="CONFORM.TOOLS",rt=[...B].reduce((t,n)=>t+M[n][0].length+1,-1);async function K(t){if(!i.isTTY)return!1;let n=!!T("NO_COLOR"),l=/truecolor|24bit/i.test(T("COLORTERM")??""),r=o=>e=>n?e:`\x1B[${o}m${e}\x1B[0m`,g=r(l?"38;2;255;60;0":"38;5;202"),p=r(l?"38;2;255;222;0":"38;5;220"),w=r("1"),u=r("2"),d=(i.columns??80)>=C+4+rt,$=o=>[...B].map(e=>e==="."?g(M[e][o]):w(M[e][o])).join(" "),y=(o,e)=>d&&o>=2&&o<=5?$(o-2):!d&&o===3?`${w("conform")}${g(".")}${w("tools")}`:o===7?e:"",m=(o,e,O=[])=>{let S=et(o),_=[];for(let f=0;f<R;f++){let Z=S[2*f].map((N,ot)=>{let k=S[2*f+1][ot];return N&&k?"\u2588":N?"\u2580":k?"\u2584":" "}).join(""),tt=f>=8?O[f-8]??"":"";_.push(` ${g(Z)} ${tt||y(f,e)}\x1B[K`)}return _.join(`
4
4
  `)+`
5
5
  `},x=null;t.account.then(o=>{x=o});let P=o=>W(o,24),U=!T("CI")&&T("TERM")!=="dumb";if(i.write(`
6
- `),U){let o=()=>i.write("\x1B[?25h");process.once("SIGINT",()=>{o(),process.exit(130)}),i.write("\x1B[?25l"+m(0,g(`\u25B6 ${P(0)}`)));let e=Date.now(),O=0;for(;x===null||Date.now()-e<900;)await new Promise(S=>setTimeout(S,1e3/24)),O=Math.round((Date.now()-e)*24/1e3),i.write(`\x1B[${R}A\r`+m(O/22%1,`${g(`\u25B6 ${P(O)}`)} ${u("checking your account\u2026")}`));i.write(`\x1B[${R}A\r`),o()}let X=(x??await t.account).split(`
6
+ `),U){let o=()=>i.write("\x1B[?25h");process.once("SIGINT",()=>{o(),process.exit(130)}),i.write("\x1B[?25l"+m(0,p(`\u25B6 ${P(0)}`)));let e=Date.now(),O=0;for(;x===null||Date.now()-e<900;)await new Promise(S=>setTimeout(S,1e3/24)),O=Math.round((Date.now()-e)*24/1e3),i.write(`\x1B[${R}A\r`+m(O/22%1,`${p(`\u25B6 ${P(O)}`)} ${u("checking your account\u2026")}`));i.write(`\x1B[${R}A\r`),o()}let X=(x??await t.account).split(`
7
7
  `);return i.write(m(0,`${u("v")}${t.version} ${u("\xB7 built by post pros")}`,X.map(o=>u(o)))),i.write(`
8
8
  `),!0}var z=()=>K({version:A,account:Promise.race([D().catch(()=>null),new Promise(t=>setTimeout(t,1500,null))]).then(t=>t?I(t):"account: no answer (offline?)")}),st={login:"account_login",logout:"account_logout",whoami:"account_status",status:"account_status",telemetry:"account_telemetry"};c()[0]==="mcp"&&(await import("./mcp.js"),await new Promise(()=>{}));c()[0]==="http"&&(await import("./http.js"),await new Promise(()=>{}));c()[0]==="statusline"&&((await import("./statusline-GMMCFMOA.js")).main(),s(0));if(c()[0]==="setup"){let t=c()[1];t!=="claude"&&(console.error(`conformtools setup <client>: supported: claude${t?` (not ${t} yet)`:""}`),s(2));let{setupClaude:n,setupText:l}=await import("./claude-setup-IIWUB4CE.js");try{console.log(l(await n())),s(0)}catch(r){console.error(r instanceof Error?r.message:String(r)),s(1)}}var q=c().includes("--json"),[a,v]=c().filter(t=>t!=="--json");if(!a||a==="--list"||a==="help"||a==="--help"){await z(),console.log(`conformtools <verb> '<json args>' [--json]
9
9
 
10
10
  login / whoami / logout sign in with your conform.tools Google account
11
- telemetry on|off|status optional outcome telemetry (off by default; see the README, Feedback and privacy)
11
+ telemetry on|off|status outcome telemetry (on by default, content-free; see the README, Feedback and privacy)
12
12
  mcp run as an MCP server (stdio) for Claude Code, Cursor, Codex\u2026
13
13
  http run the local HTTP API on 127.0.0.1:7791
14
14
  `);let t=L()==="hosted";for(let n of G)console.log(` ${n.name.padEnd(22)} ${n.title}${t&&n.protectedStages?.length?" (on conform.tools)":""}`);t&&console.log(`
Binary file
Binary file
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a,b}from"./chunk-HGDO3OED.js";import"./chunk-C5IX63YF.js";import"./chunk-PSANHDZM.js";export{b as decodeCr3Wasm,a as inspectCr3Wasm};
3
+ import{a,b}from"./chunk-J2JXLEAI.js";import"./chunk-RJ6JA2LZ.js";import"./chunk-PSANHDZM.js";export{b as decodeCr3Wasm,a as inspectCr3Wasm};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a,b,c}from"./chunk-6ML26TIK.js";import"./chunk-DKGGJM6Z.js";import"./chunk-C5IX63YF.js";import"./chunk-PSANHDZM.js";export{c as decodeDngPreviewWasm,b as decodeDngWasm,a as inspectDngWasm};
3
+ import{a,b,c}from"./chunk-A7FNR3T5.js";import"./chunk-DKGGJM6Z.js";import"./chunk-RJ6JA2LZ.js";import"./chunk-PSANHDZM.js";export{c as decodeDngPreviewWasm,b as decodeDngWasm,a as inspectDngWasm};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a,b,c}from"./chunk-5SUGU2YR.js";import"./chunk-DKGGJM6Z.js";import"./chunk-C5IX63YF.js";import"./chunk-PSANHDZM.js";export{c as decodeDpxPreviewWasm,b as decodeDpxWasm,a as inspectDpxWasm};
3
+ import{a,b,c}from"./chunk-D4WPRRBT.js";import"./chunk-DKGGJM6Z.js";import"./chunk-RJ6JA2LZ.js";import"./chunk-PSANHDZM.js";export{c as decodeDpxPreviewWasm,b as decodeDpxWasm,a as inspectDpxWasm};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a,b,c}from"./chunk-NQHQKEP5.js";import"./chunk-DKGGJM6Z.js";import"./chunk-C5IX63YF.js";import"./chunk-PSANHDZM.js";export{c as decodeExrPreviewWasm,b as decodeExrWasm,a as inspectExrWasm};
3
+ import{a,b,c}from"./chunk-WN53ARHJ.js";import"./chunk-DKGGJM6Z.js";import"./chunk-RJ6JA2LZ.js";import"./chunk-PSANHDZM.js";export{c as decodeExrPreviewWasm,b as decodeExrWasm,a as inspectExrWasm};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{f as a,g as b,h as c,i as d,j as e,k as f,l as g,m as h,n as i,o as j,p as k,q as l}from"./chunk-IPFPZBSC.js";import"./chunk-H6WZ43NS.js";import"./chunk-PFISREY4.js";import"./chunk-JV7TZDKJ.js";import"./chunk-VIBEEWPC.js";import"./chunk-PFZVET7S.js";import"./chunk-6V4OEOOX.js";import"./chunk-RGMTLNMF.js";import"./chunk-D4WPRRBT.js";import"./chunk-WN53ARHJ.js";import"./chunk-A7FNR3T5.js";import"./chunk-J2JXLEAI.js";import"./chunk-SGLQY53R.js";import"./chunk-DKGGJM6Z.js";import"./chunk-AMRJXYL4.js";import"./chunk-3D3Z4TBR.js";import"./chunk-2BPR6LK6.js";import"./chunk-NU3X7P4N.js";import"./chunk-RJ6JA2LZ.js";import"./chunk-JZY2BHQB.js";import"./chunk-PHAMF4JF.js";import"./chunk-PLRB2YXJ.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";export{i as ASPECTS,a as INPUT_SCALING,e as SIZING_TARGETS,h as alignText,g as alignTimeline,j as aspectOf,k as blankingQc,l as blankingText,c as inputFitRatio,f as offlineLane,d as resolveProps,b as scalingOf};
@@ -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{e as h,f as d,n as w,p as _}from"./chunk-AS7IXHYM.js";import"./chunk-NU3X7P4N.js";import{Ga as u,T as l,V as g}from"./chunk-C5IX63YF.js";import"./chunk-3OCQA33E.js";import{u as y}from"./chunk-PLRB2YXJ.js";import"./chunk-PSANHDZM.js";import{parentPort as p,workerData as C}from"node:worker_threads";import{createCanvas as M,loadImage as A}from"@napi-rs/canvas";var S=(async()=>{await w(C),await u()})(),o=new Map,c=new Map;p.on("message",async t=>{try{await S;let s={};for(let[e,a]of Object.entries(t.images))c.has(a)||c.set(a,await A(await y(a))),s[e]=c.get(a);let m=`${t.fmt.w}x${t.fmt.h}`;o.has(m)||o.set(m,M(t.fmt.w,t.fmt.h));let i=o.get(m).getContext("2d"),v=h(i),r=[],f=null;for(let e=t.from;e<t.to;e++){d(i,t.scene,e/t.fps,t.fmt,v,s);let a=i.getImageData(0,0,t.fmt.w,t.fmt.h).data,n=new Uint8Array(a.buffer,a.byteOffset,a.byteLength);if(f&&_(f,n)){r.push(null);continue}r.push(t.alpha?l(n,t.fmt.w,t.fmt.h,4):g(n,t.fmt.w,t.fmt.h,4)),f=n.slice()}p.postMessage({id:t.id,samples:r},r.filter(e=>!!e).map(e=>e.buffer))}catch(s){p.postMessage({id:t.id,error:s.message??String(s)})}});
3
+ import{e as h,f as d,n as w,p as _}from"./chunk-GK4YYKJ6.js";import"./chunk-NU3X7P4N.js";import{Ha as u,T as l,V as g}from"./chunk-RJ6JA2LZ.js";import"./chunk-PHAMF4JF.js";import{u as y}from"./chunk-PLRB2YXJ.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-SIOE67WL.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};
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-VJOWP4MH.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{Ga as v,ma as g,oa as b}from"./chunk-C5IX63YF.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-74TTDICM.js")).mxfFormat}var O={async inspect(o){return(await m()).inspect(o)},async extract(o){return(await m()).extract(o)},async sparsify(o,t){return(await m()).sparsify(o,t)},async trim(o,t){return(await m()).trim(o,t)},async decode(o,t){return U(o,t)}};export{O as h264MxfFormat};
3
+ import{Ha as v,ma as g,oa as b}from"./chunk-RJ6JA2LZ.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-FJSRFLJC.js")).mxfFormat}var O={async inspect(o){return(await m()).inspect(o)},async extract(o){return(await m()).extract(o)},async sparsify(o,t){return(await m()).sparsify(o,t)},async trim(o,t){return(await m()).trim(o,t)},async decode(o,t){return U(o,t)}};export{O as h264MxfFormat};
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a as C}from"./chunk-RFIPLBQ4.js";import{c as D}from"./chunk-SZD4C5MB.js";import{L as A,O as P,V as N,Y as q}from"./chunk-BL6L5ZBP.js";import"./chunk-5JBUCVRI.js";import"./chunk-PFISREY4.js";import"./chunk-JV7TZDKJ.js";import{k as M}from"./chunk-3XD6NC4G.js";import"./chunk-PFZVET7S.js";import"./chunk-P7OVDUA5.js";import"./chunk-UCMNH6Q6.js";import"./chunk-5SUGU2YR.js";import"./chunk-NQHQKEP5.js";import"./chunk-6ML26TIK.js";import"./chunk-HGDO3OED.js";import"./chunk-X53BNWNV.js";import"./chunk-DKGGJM6Z.js";import"./chunk-7MC7M2Y5.js";import"./chunk-VS3MKKJ5.js";import"./chunk-XNR7M4VX.js";import{b as F}from"./chunk-NU3X7P4N.js";import"./chunk-C5IX63YF.js";import"./chunk-5RSNFPED.js";import"./chunk-3OCQA33E.js";import{H as x,I as E,V as U,W as R,Y as k,m as O,q as S}from"./chunk-PLRB2YXJ.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";var y=s=>{let i=s?.target_url??s?.local_path??"";return i.startsWith("file://")?O(i):i};async function H(s,i){let a=await s.items({timeline:i,kind:"video"}),r=a.items.map(m=>`${m.kind}:${m.track}:${m.start}:${m.end-m.start}`),c=async m=>{let l=await D(m,a.timeline).catch(()=>null);if(!l||!r.every(p=>l.has(p)))return null;let{session:h}=await P(m,"prproj"),u=h.timelines.find(p=>p.name===a.timeline);return u?z(h,u):null};if(a.project_path){let m=await c(a.project_path);if(m)return await T(m),{session:m,from:"the saved project (matches the live sequence)",path:a.project_path};let l=k(R(a.project_path),"Adobe Premiere Pro Auto-Save"),h=U(a.project_path).replace(/\.prproj$/i,""),u=[];try{for await(let p of E(l))p.isFile&&p.name.startsWith(`${h}--`)&&p.name.endsWith(".prproj")&&u.push({path:k(l,p.name),mtime:(await S(k(l,p.name))).mtime?.getTime()??0})}catch{}for(let p of u.sort((g,_)=>_.mtime-g.mtime).slice(0,3)){let g=await c(p.path);if(g&&await T(g),g)return{session:g,from:`Premiere's auto-save of ${new Date(p.mtime).toLocaleTimeString()} (matches the live sequence; the project itself is not saved)`,path:p.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 Z(s,n),await I(n),typeof a.drop_frame=="boolean")for(let m of n.timelines)m.is_drop_frame=a.drop_frame;await T(n);for(let m of n.timelines)for(let l of m.tracks)for(let h of l.items){let u=h;u.scale=null,u.position_x=null,u.position_y=null,u.rotation=null}let o=await s.model(i).then(m=>m.items.filter(l=>Object.keys(l.sizing??{}).length).map(l=>`${l.name??l.file_path.split("/").pop()} (V${l.track} @${l.start-m.start_frame})`)).catch(()=>[]),f=`Premiere's OTIO export carries the cut, not the clips' Motion / Opacity / effects / retimes${o.length?` \u2014 ${o.length} clip(s) here have Motion that will not carry: ${o.slice(0,6).join(", ")}${o.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:f}}async function T(s){let i=new Set;for(let r of s.media_references??[]){if(r.binding_state==="linked")continue;let c=y(r);c&&await S(c).then(e=>e.isFile,()=>!1)&&i.add(R(c))}let a=s;for(let r of i){let c=await C(a,{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);c?.changed&&(a=c.session)}return a!==s&&Object.assign(s,a),(s.media_references??[]).filter(r=>r.binding_state==="linked").length}async function I(s){let i=0;for(let a of s.media_references??[]){if(a.source_resolution_w)continue;let r=y(a),c=r?await M(r).catch(()=>null):null;if(!c)continue;let e=c;for(let t of["source_resolution_w","source_resolution_h","source_pixel_aspect","codec","container","streams"])e[t]!=null&&a[t]==null&&(a[t]=e[t]);a.source_fps??=e.source_fps??null,a.source_timecode??=e.source_timecode??null,!a.available_range&&e.available_range&&(a.available_range=e.available_range),i++}return i}async function ie(s,i){let a=i.timelines.filter(t=>t.offline_reference?.clip_id);if(!a.length)return 0;let r=t=>[...t?.clip_list??[],...(t?.folders??[]).flatMap(r)],c=new Map(r((await s.project({clips:!0})).pool).map(t=>[t.id,t])),e=0;for(let t of a){let n=c.get(t.offline_reference.clip_id);if(n?.file){let o=i.media_references.find(f=>y(f)===n.file);o||(o={id:`offline-ref-${t.id??e}`,kind:"external",name:n.name,target_url:`file://${n.file}`,local_path:n.file},i.media_references.push(o)),t.offline_reference.media_reference_id=o.id,e++}else if(n&&n.name!==t.name&&(n.type==="Timeline"||/compound/i.test(n.type??""))){let{createSession:o}=await import("./store-ZHXLQCGN.js"),f=k(await x("conform-offline-ref-"),`${n.name.replace(/[^\w.-]+/g,"_")}.drt`),m=await s.export(n.type==="Timeline"?{timeline:n.name,out_path:f}:{clip_id:n.id,out_path:f}),{session:l}=await P(m.path,"drt");l=(await A(l))?.session??l,t.offline_reference.session_id=(await o(l,m.path,"drt")).id,e++}else t.offline_reference=null}return e}async function Z(s,i){let a=(await s.projectClips()).clips,r=new Map(a.filter(e=>e.start_frame!=null&&e.fps).map(e=>[e.file,e])),c=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,c++;continue}let n=y(e),o=n?await M(n).catch(()=>null):null;o?.source_timecode&&(e.source_timecode=o.source_timecode,e.source_fps??=o.source_fps??null,c++)}return c}function z(s,i){let a=new Map(s.timelines.map(c=>[c.id,c])),r=[i];for(let c=0;c<r.length;c++)for(let e of r[c].tracks)for(let t of e.items){let n=t.nested_timeline_id,o=n?a.get(n):void 0;o&&!r.includes(o)&&r.push(o)}return{...s,timelines:r}}function V(s,i){let a=new Map((s.media_references??[]).map(n=>[n.id,y(n)])),r=[];for(let n of i.media_references??[]){let o=a.get(n.id),f=y(n);o!==void 0&&f&&f!==o&&r.push({ref_id:n.id,old:o,new:f})}let c=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 o of n.items){let f=o.media_reference_id?c.get(o.media_reference_id):void 0;!f||o.kind!=="clip"||!o.source_range||e.push({track:n.track_index,start:o.timeline_range.start.value,duration:o.timeline_range.duration.value,src_in:o.source_range.start.value,path:f.new,name:o.name??""})}return{media:r,cuts:e}}async function se(s,i){let{session:a,from:r,lossy:c}=await H(s,i.timeline),e=await C(structuredClone(a),{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}=V(a,e.session),o=[`read from ${r}`,...c&&i.mode==="new_version"?[`\u26A0 ${c}`]:[],`matched ${t.length} medi${t.length===1?"um":"a"} under ${i.media_root} (${n.length} clip use${n.length===1?"":"s"} in the sequence)`],f=t.map(u=>` ${u.old.split("/").pop()} \u2192 ${u.new}`);if(i.dry_run||!t.length)return{text:[...o,...f,i.dry_run?"(dry run \u2014 nothing changed in Premiere)":"",e.text.split(`
3
+ import{a as C}from"./chunk-BW4LRTHG.js";import{c as D}from"./chunk-7SENYEIV.js";import{L as A,O as P,V as N,Y as q}from"./chunk-H6WZ43NS.js";import"./chunk-LGUO7PL5.js";import"./chunk-PFISREY4.js";import"./chunk-JV7TZDKJ.js";import{k as M}from"./chunk-VIBEEWPC.js";import"./chunk-PFZVET7S.js";import"./chunk-6V4OEOOX.js";import"./chunk-RGMTLNMF.js";import"./chunk-D4WPRRBT.js";import"./chunk-WN53ARHJ.js";import"./chunk-A7FNR3T5.js";import"./chunk-J2JXLEAI.js";import"./chunk-SGLQY53R.js";import"./chunk-DKGGJM6Z.js";import"./chunk-AMRJXYL4.js";import"./chunk-3D3Z4TBR.js";import"./chunk-2BPR6LK6.js";import{b as F}from"./chunk-NU3X7P4N.js";import"./chunk-RJ6JA2LZ.js";import"./chunk-JZY2BHQB.js";import"./chunk-PHAMF4JF.js";import{H as x,I as E,V as U,W as R,Y as k,m as O,q as S}from"./chunk-PLRB2YXJ.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";var y=s=>{let i=s?.target_url??s?.local_path??"";return i.startsWith("file://")?O(i):i};async function H(s,i){let a=await s.items({timeline:i,kind:"video"}),r=a.items.map(m=>`${m.kind}:${m.track}:${m.start}:${m.end-m.start}`),c=async m=>{let l=await D(m,a.timeline).catch(()=>null);if(!l||!r.every(p=>l.has(p)))return null;let{session:h}=await P(m,"prproj"),u=h.timelines.find(p=>p.name===a.timeline);return u?z(h,u):null};if(a.project_path){let m=await c(a.project_path);if(m)return await T(m),{session:m,from:"the saved project (matches the live sequence)",path:a.project_path};let l=k(R(a.project_path),"Adobe Premiere Pro Auto-Save"),h=U(a.project_path).replace(/\.prproj$/i,""),u=[];try{for await(let p of E(l))p.isFile&&p.name.startsWith(`${h}--`)&&p.name.endsWith(".prproj")&&u.push({path:k(l,p.name),mtime:(await S(k(l,p.name))).mtime?.getTime()??0})}catch{}for(let p of u.sort((g,_)=>_.mtime-g.mtime).slice(0,3)){let g=await c(p.path);if(g&&await T(g),g)return{session:g,from:`Premiere's auto-save of ${new Date(p.mtime).toLocaleTimeString()} (matches the live sequence; the project itself is not saved)`,path:p.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 Z(s,n),await I(n),typeof a.drop_frame=="boolean")for(let m of n.timelines)m.is_drop_frame=a.drop_frame;await T(n);for(let m of n.timelines)for(let l of m.tracks)for(let h of l.items){let u=h;u.scale=null,u.position_x=null,u.position_y=null,u.rotation=null}let o=await s.model(i).then(m=>m.items.filter(l=>Object.keys(l.sizing??{}).length).map(l=>`${l.name??l.file_path.split("/").pop()} (V${l.track} @${l.start-m.start_frame})`)).catch(()=>[]),f=`Premiere's OTIO export carries the cut, not the clips' Motion / Opacity / effects / retimes${o.length?` \u2014 ${o.length} clip(s) here have Motion that will not carry: ${o.slice(0,6).join(", ")}${o.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:f}}async function T(s){let i=new Set;for(let r of s.media_references??[]){if(r.binding_state==="linked")continue;let c=y(r);c&&await S(c).then(e=>e.isFile,()=>!1)&&i.add(R(c))}let a=s;for(let r of i){let c=await C(a,{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);c?.changed&&(a=c.session)}return a!==s&&Object.assign(s,a),(s.media_references??[]).filter(r=>r.binding_state==="linked").length}async function I(s){let i=0;for(let a of s.media_references??[]){if(a.source_resolution_w)continue;let r=y(a),c=r?await M(r).catch(()=>null):null;if(!c)continue;let e=c;for(let t of["source_resolution_w","source_resolution_h","source_pixel_aspect","codec","container","streams"])e[t]!=null&&a[t]==null&&(a[t]=e[t]);a.source_fps??=e.source_fps??null,a.source_timecode??=e.source_timecode??null,!a.available_range&&e.available_range&&(a.available_range=e.available_range),i++}return i}async function ie(s,i){let a=i.timelines.filter(t=>t.offline_reference?.clip_id);if(!a.length)return 0;let r=t=>[...t?.clip_list??[],...(t?.folders??[]).flatMap(r)],c=new Map(r((await s.project({clips:!0})).pool).map(t=>[t.id,t])),e=0;for(let t of a){let n=c.get(t.offline_reference.clip_id);if(n?.file){let o=i.media_references.find(f=>y(f)===n.file);o||(o={id:`offline-ref-${t.id??e}`,kind:"external",name:n.name,target_url:`file://${n.file}`,local_path:n.file},i.media_references.push(o)),t.offline_reference.media_reference_id=o.id,e++}else if(n&&n.name!==t.name&&(n.type==="Timeline"||/compound/i.test(n.type??""))){let{createSession:o}=await import("./store-EXUE5XX5.js"),f=k(await x("conform-offline-ref-"),`${n.name.replace(/[^\w.-]+/g,"_")}.drt`),m=await s.export(n.type==="Timeline"?{timeline:n.name,out_path:f}:{clip_id:n.id,out_path:f}),{session:l}=await P(m.path,"drt");l=(await A(l))?.session??l,t.offline_reference.session_id=(await o(l,m.path,"drt")).id,e++}else t.offline_reference=null}return e}async function Z(s,i){let a=(await s.projectClips()).clips,r=new Map(a.filter(e=>e.start_frame!=null&&e.fps).map(e=>[e.file,e])),c=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,c++;continue}let n=y(e),o=n?await M(n).catch(()=>null):null;o?.source_timecode&&(e.source_timecode=o.source_timecode,e.source_fps??=o.source_fps??null,c++)}return c}function z(s,i){let a=new Map(s.timelines.map(c=>[c.id,c])),r=[i];for(let c=0;c<r.length;c++)for(let e of r[c].tracks)for(let t of e.items){let n=t.nested_timeline_id,o=n?a.get(n):void 0;o&&!r.includes(o)&&r.push(o)}return{...s,timelines:r}}function V(s,i){let a=new Map((s.media_references??[]).map(n=>[n.id,y(n)])),r=[];for(let n of i.media_references??[]){let o=a.get(n.id),f=y(n);o!==void 0&&f&&f!==o&&r.push({ref_id:n.id,old:o,new:f})}let c=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 o of n.items){let f=o.media_reference_id?c.get(o.media_reference_id):void 0;!f||o.kind!=="clip"||!o.source_range||e.push({track:n.track_index,start:o.timeline_range.start.value,duration:o.timeline_range.duration.value,src_in:o.source_range.start.value,path:f.new,name:o.name??""})}return{media:r,cuts:e}}async function se(s,i){let{session:a,from:r,lossy:c}=await H(s,i.timeline),e=await C(structuredClone(a),{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}=V(a,e.session),o=[`read from ${r}`,...c&&i.mode==="new_version"?[`\u26A0 ${c}`]:[],`matched ${t.length} medi${t.length===1?"um":"a"} under ${i.media_root} (${n.length} clip use${n.length===1?"":"s"} in the sequence)`],f=t.map(u=>` ${u.old.split("/").pop()} \u2192 ${u.new}`);if(i.dry_run||!t.length)return{text:[...o,...f,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 p=(await s.projectClips()).clips.flatMap(w=>t.filter(v=>v.old===w.file).map(v=>({clip:w.id,path:v.new,mode:i.mode}))),g=i.mode==="replace"?W(a,e.session,t):new Map,_=g.size?await X(s,new Set(g.keys())):[],b=await s.relinkClips(p),d=b.results.filter(w=>w.ok).length,$=[...o,`${i.mode==="hires"?"attached full-res behind":i.mode==="proxy"?"attached as proxies to":"repointed"} ${d}/${p.length} project clip(s)${i.mode==="proxy"?" (Toggle Proxies in Premiere switches)":""}`,...f,...b.results.filter(w=>!w.ok).map(w=>` refused: ${w.detail??"Premiere refused"}`)],j=_.length?await Y(s,_,g):null;return j&&$.push(...j.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{f as a,g as b,h as c,i as d,j as e}from"./chunk-MS3AWOSG.js";import"./chunk-7SENYEIV.js";import"./chunk-TXQR2HI2.js";import"./chunk-H6WZ43NS.js";import"./chunk-LGUO7PL5.js";import"./chunk-PFISREY4.js";import"./chunk-JV7TZDKJ.js";import"./chunk-VIBEEWPC.js";import"./chunk-PFZVET7S.js";import"./chunk-6V4OEOOX.js";import"./chunk-RGMTLNMF.js";import"./chunk-D4WPRRBT.js";import"./chunk-WN53ARHJ.js";import"./chunk-A7FNR3T5.js";import"./chunk-J2JXLEAI.js";import"./chunk-SGLQY53R.js";import"./chunk-DKGGJM6Z.js";import"./chunk-AMRJXYL4.js";import"./chunk-3D3Z4TBR.js";import"./chunk-2BPR6LK6.js";import"./chunk-NU3X7P4N.js";import"./chunk-RJ6JA2LZ.js";import"./chunk-JZY2BHQB.js";import"./chunk-PHAMF4JF.js";import"./chunk-PLRB2YXJ.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";export{a as AVID_SETUP,b as FLAME_SETUP,c as NUKE_SETUP,e as adapter,d 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 xt}from"./chunk-NFJHWZJX.js";import{$ as yt,G as nt,H as ot,I as dt,J as pt,K as gt,R as ht,S as wt,T as _t,X as b,Y as kt,_ as U}from"./chunk-OJWIBQK4.js";import"./chunk-OVUCL3YY.js";import"./chunk-UKKRZ574.js";import"./chunk-LFJLRLEP.js";import"./chunk-RFIPLBQ4.js";import"./chunk-SZD4C5MB.js";import{J as I,t as mt,u as ft}from"./chunk-BL6L5ZBP.js";import{a as et}from"./chunk-5JBUCVRI.js";import"./chunk-PFISREY4.js";import"./chunk-TXQR2HI2.js";import"./chunk-JV7TZDKJ.js";import"./chunk-3XD6NC4G.js";import"./chunk-PFZVET7S.js";import"./chunk-P7OVDUA5.js";import"./chunk-UCMNH6Q6.js";import"./chunk-5SUGU2YR.js";import"./chunk-NQHQKEP5.js";import"./chunk-6ML26TIK.js";import"./chunk-HGDO3OED.js";import"./chunk-X53BNWNV.js";import"./chunk-DKGGJM6Z.js";import"./chunk-D6YDLKSA.js";import"./chunk-7MC7M2Y5.js";import"./chunk-VS3MKKJ5.js";import"./chunk-XNR7M4VX.js";import"./chunk-AS7IXHYM.js";import"./chunk-NU3X7P4N.js";import"./chunk-C5IX63YF.js";import{B as v,D as lt,t as rt,u as st,v as it,x as at,y as ct,z as ut}from"./chunk-EJGVNQ3E.js";import{n as H}from"./chunk-5RSNFPED.js";import{a as B}from"./chunk-3OCQA33E.js";import{D as L,H as D,I as Z,J as q,Q as tt,V as M,W as J,Y as x,b as E,k as P,q as V,r as W,u as K,v as X,w as A,x as Y,y as $,z as Q}from"./chunk-PLRB2YXJ.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";import C from"node:process";var bt=new Map;function St(t,s,o,T){let i=`${t}:${o}:${T}`,a=bt.get(i);return a||(a=(async()=>{let n=x(P(),"cache","grade-luts",t);await $(n);let l=x(n,`V${o}_${T}.cube`);if(!await W(l)){let{adapter:_}=await import("./hosts-W4AD2MYH.js");if((await _("resolve").clipLut({timeline:s,track:o,start:T,out_path:l})).ok===!1)return null}return l})().catch(()=>null),bt.set(i,a)),a}var Ct=new Set(["/app/convert","/app/canonicalize"]);function Ot(t,s){let o=(s??"").split(";")[0].trim().toLowerCase();return o==="application/json"||o==="application/octet-stream"&&Ct.has(t)}function Nt(t){let s=t.replace(/[\\/:*?"<>|\x00-\x1f]+/g,"_").replace(/[. ]+$/,"")||"timeline";return/^(con|prn|aux|nul|com\d|lpt\d)(\..*)?$/i.test(s)?`_${s}`:s}var F={id:"local",name:"Local",client_name:null,handles:24,local:!0};async function Rt(){try{return JSON.parse(await X(x(P(),"projects","projects.json")))}catch{return[]}}async function Tt(){let t=await b("project",{action:"list"});if(!t.isError){let s=t.structuredContent?.projects??[];return await $(x(P(),"projects")),await Y(x(P(),"projects","projects.json"),JSON.stringify(s)),{projects:[F,...s],offline:!1}}return{projects:[F,...await Rt()],offline:!0,code:String(t.structuredContent?.code??"offline"),reason:String(t.structuredContent?.message??t.content[0]?.text??"")}}async function $t(t){return t==="local"?F:(await Rt()).find(s=>s.id===t)??{id:t,name:t}}async function Pt(t,s,o,T,i=(a,n)=>new Response(a,{headers:{"content-type":n}})){if(s[0]!=="app")return null;let[,a,n,l]=s,_=async()=>t.headers.get("content-type")?.includes("json")?await t.json():{};try{if(a==="policy"&&t.method==="GET"){let{config:e}=await import("./account-HDXVTS5T.js"),r=await fetch(`${e().supabaseUrl}/functions/v1/v1-billing/v1/billing/app-policy`,{signal:AbortSignal.timeout(3e3)}).catch(()=>null);return o(r?.ok?await r.json():{offline:!0})}if(a==="account"&&t.method==="GET"){let e=await b("account_status",{}),r=await H().then(()=>({app:!0}),u=>({app:!1,app_reason:u.message,code:u.code}));return o({...e.structuredContent,...e.structuredContent?.account??{},...r,text:e.content[0]?.text})}{let e=await H().then(()=>null,r=>r);if(e)return o({ok:!1,code:e.code,message:e.message,needs:"app"},e.code==="not_signed_in"?401:402)}if(a==="events"&&t.method==="GET")return T(gt());if(a==="front"&&t.method==="POST"){let e=await t.json();return pt({project:String(e.project??""),view:String(e.view??""),...e.tool?{tool:String(e.tool)}:{}}),o({ok:!0})}if(a==="convert"&&t.method==="POST"){let e=new URL(t.url).searchParams,r=M(e.get("name")||"timeline"),u=e.get("out")||"",g=JSON.parse(e.get("targets")||"[]"),c=JSON.parse(e.get("sequences")||"[]");if(!u||!g.length)return o({ok:!1,error:"a folder and at least one format are needed"},400);let m=await D("conform-te-"),k=x(m,r);await A(k,new Uint8Array(await t.arrayBuffer()));let h=await b("timeline_read",{path:k}),S=h.structuredContent?.session_id??h.content[0]?.text.match(/session_id: (\w+)/)?.[1];if(h.isError||!S)return o({ok:!1,error:h.content[0]?.text??"could not read the timeline"});let p=(await v(S)).session.timelines.filter(y=>y.kind!=="compound"),w=c.length?p.filter(y=>c.includes(y.name??"")):p,d=[],O=0;for(let y of w)for(let R of g){let N=x(u,`${Nt(y.name??"timeline")}.${R.ext}`),z=await b("timeline_write",{session_id:S,target:R.target,out_path:N,...w.length>1||p.length>1?{timeline_id:y.id}:{}});z.isError?d.push(`${y.name} \u2192 ${R.target}: ${z.content[0]?.text}`):O++}return await L(m).catch(()=>{}),o({ok:O>0,savedCount:O,...d.length?{error:d.join(`
3
+ import{a as xt}from"./chunk-NFJHWZJX.js";import{$ as yt,G as nt,H as ot,I as dt,J as pt,K as gt,R as ht,S as wt,T as _t,X as b,Y as kt,_ as U}from"./chunk-SYX6W5TS.js";import"./chunk-BW4LRTHG.js";import"./chunk-IPFPZBSC.js";import"./chunk-MS3AWOSG.js";import"./chunk-7SENYEIV.js";import"./chunk-TXQR2HI2.js";import{J as I,t as mt,u as ft}from"./chunk-H6WZ43NS.js";import{a as et}from"./chunk-LGUO7PL5.js";import"./chunk-GM6QKY7W.js";import"./chunk-PFISREY4.js";import"./chunk-JV7TZDKJ.js";import"./chunk-VIBEEWPC.js";import"./chunk-PFZVET7S.js";import"./chunk-6V4OEOOX.js";import"./chunk-RGMTLNMF.js";import"./chunk-D4WPRRBT.js";import"./chunk-WN53ARHJ.js";import"./chunk-A7FNR3T5.js";import"./chunk-J2JXLEAI.js";import"./chunk-SGLQY53R.js";import"./chunk-DKGGJM6Z.js";import"./chunk-D6YDLKSA.js";import"./chunk-AMRJXYL4.js";import"./chunk-3D3Z4TBR.js";import"./chunk-2BPR6LK6.js";import"./chunk-GK4YYKJ6.js";import"./chunk-NU3X7P4N.js";import"./chunk-RJ6JA2LZ.js";import{B as v,D as lt,t as rt,u as st,v as it,x as at,y as ct,z as ut}from"./chunk-F74QMWXE.js";import{n as H}from"./chunk-JZY2BHQB.js";import{a as B}from"./chunk-PHAMF4JF.js";import{D as L,H as D,I as Z,J as q,Q as tt,V as M,W as J,Y as x,b as E,k as P,q as V,r as W,u as K,v as X,w as A,x as Y,y as $,z as Q}from"./chunk-PLRB2YXJ.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";import C from"node:process";var bt=new Map;function St(t,s,o,T){let i=`${t}:${o}:${T}`,a=bt.get(i);return a||(a=(async()=>{let n=x(P(),"cache","grade-luts",t);await $(n);let l=x(n,`V${o}_${T}.cube`);if(!await W(l)){let{adapter:_}=await import("./hosts-66KSLCFJ.js");if((await _("resolve").clipLut({timeline:s,track:o,start:T,out_path:l})).ok===!1)return null}return l})().catch(()=>null),bt.set(i,a)),a}var Ct=new Set(["/app/convert","/app/canonicalize"]);function Ot(t,s){let o=(s??"").split(";")[0].trim().toLowerCase();return o==="application/json"||o==="application/octet-stream"&&Ct.has(t)}function Nt(t){let s=t.replace(/[\\/:*?"<>|\x00-\x1f]+/g,"_").replace(/[. ]+$/,"")||"timeline";return/^(con|prn|aux|nul|com\d|lpt\d)(\..*)?$/i.test(s)?`_${s}`:s}var F={id:"local",name:"Local",client_name:null,handles:24,local:!0};async function Rt(){try{return JSON.parse(await X(x(P(),"projects","projects.json")))}catch{return[]}}async function Tt(){let t=await b("project",{action:"list"});if(!t.isError){let s=t.structuredContent?.projects??[];return await $(x(P(),"projects")),await Y(x(P(),"projects","projects.json"),JSON.stringify(s)),{projects:[F,...s],offline:!1}}return{projects:[F,...await Rt()],offline:!0,code:String(t.structuredContent?.code??"offline"),reason:String(t.structuredContent?.message??t.content[0]?.text??"")}}async function $t(t){return t==="local"?F:(await Rt()).find(s=>s.id===t)??{id:t,name:t}}async function Pt(t,s,o,T,i=(a,n)=>new Response(a,{headers:{"content-type":n}})){if(s[0]!=="app")return null;let[,a,n,l]=s,_=async()=>t.headers.get("content-type")?.includes("json")?await t.json():{};try{if(a==="policy"&&t.method==="GET"){let{config:e}=await import("./account-NJSA4N67.js"),r=await fetch(`${e().supabaseUrl}/functions/v1/v1-billing/v1/billing/app-policy`,{signal:AbortSignal.timeout(3e3)}).catch(()=>null);return o(r?.ok?await r.json():{offline:!0})}if(a==="account"&&t.method==="GET"){let e=await b("account_status",{}),r=await H().then(()=>({app:!0}),u=>({app:!1,app_reason:u.message,code:u.code}));return o({...e.structuredContent,...e.structuredContent?.account??{},...r,text:e.content[0]?.text})}{let e=await H().then(()=>null,r=>r);if(e)return o({ok:!1,code:e.code,message:e.message,needs:"app"},e.code==="not_signed_in"?401:402)}if(a==="events"&&t.method==="GET")return T(gt());if(a==="front"&&t.method==="POST"){let e=await t.json();return pt({project:String(e.project??""),view:String(e.view??""),...e.tool?{tool:String(e.tool)}:{}}),o({ok:!0})}if(a==="convert"&&t.method==="POST"){let e=new URL(t.url).searchParams,r=M(e.get("name")||"timeline"),u=e.get("out")||"",g=JSON.parse(e.get("targets")||"[]"),c=JSON.parse(e.get("sequences")||"[]");if(!u||!g.length)return o({ok:!1,error:"a folder and at least one format are needed"},400);let m=await D("conform-te-"),k=x(m,r);await A(k,new Uint8Array(await t.arrayBuffer()));let h=await b("timeline_read",{path:k}),S=h.structuredContent?.session_id??h.content[0]?.text.match(/session_id: (\w+)/)?.[1];if(h.isError||!S)return o({ok:!1,error:h.content[0]?.text??"could not read the timeline"});let p=(await v(S)).session.timelines.filter(y=>y.kind!=="compound"),w=c.length?p.filter(y=>c.includes(y.name??"")):p,d=[],O=0;for(let y of w)for(let R of g){let N=x(u,`${Nt(y.name??"timeline")}.${R.ext}`),z=await b("timeline_write",{session_id:S,target:R.target,out_path:N,...w.length>1||p.length>1?{timeline_id:y.id}:{}});z.isError?d.push(`${y.name} \u2192 ${R.target}: ${z.content[0]?.text}`):O++}return await L(m).catch(()=>{}),o({ok:O>0,savedCount:O,...d.length?{error:d.join(`
4
4
  `)}:{}})}if(a==="fs"&&t.method==="POST"){let{op:e,path:r,offset:u=0,length:g=0}=await _();if(e==="statPath"){let c=await V(r).catch(()=>null);return o({ok:!0,result:c?{kind:c.isDirectory?"directory":"file",size:c.size,lastModified:Math.round(c.mtimeMs)}:null})}if(e==="readDir"){let c=[];for await(let m of Z(r))(m.isFile||m.isDirectory)&&c.push({name:m.name,kind:m.isDirectory?"directory":"file"});return o({ok:!0,result:c})}if(e==="readFile"){let c=await q(r);try{return i(await c.readAt(Math.max(0,u),Math.min(Math.max(0,g),16<<20)),"application/octet-stream")}finally{await c.close()}}return o({ok:!1,code:"bad_request",message:`no fs op ${e}`},400)}if(a==="canonicalize"&&t.method==="POST"){let e=new URL(t.url).searchParams,r=JSON.parse(e.get("sequences")||"[]"),u=JSON.parse(e.get("previous")||"[]"),g=await D("conform-te-");try{let c=x(g,M(e.get("name")||"timeline"));await A(c,new Uint8Array(await t.arrayBuffer()));let m=await b("timeline_read",{path:c}),k=m.structuredContent?.session_id??m.content[0]?.text.match(/session_id: (\w+)/)?.[1];if(m.isError||!k)return o({ok:!1,error:m.content[0]?.text??"could not read the timeline"},422);let h=(await v(k)).session,S=h.timelines;if(r.length){let p=new Map;for(let d of u)p.set(d,(p.get(d)??0)+1);let w=new Set;for(let d of r){let O=h.timelines.filter(N=>N.kind!=="compound"&&(N.name??"")===d),y=p.get(d)??0;p.set(d,y+1);let R=O[Math.min(y,O.length-1)];R&&w.add(R)}S=h.timelines.filter(d=>d.kind==="compound"||w.has(d))}return o({ok:!0,session_id:k,session:{...h,timelines:S}})}finally{await L(g).catch(()=>{})}}if(a==="sessions"&&n&&l==="frame"){let e=new URL(t.url).searchParams,r=Math.max(0,Math.round(Number(e.get("f")??0))),u=Math.min(3840,Math.max(64,Number(e.get("w")??1280)|0));try{let k=(await v(n)).session,h=e.get("track")==="offline"?"offline":Number(e.get("track"))||void 0,S;if(e.get("grade")==="resolve"&&h!=="offline"){let w=(()=>{try{return mt(k,{record:r,timeline:e.get("timeline")??void 0,track:h})}catch{return null}})();w&&(S=await St(n,e.get("host_timeline")??void 0,w.video_track,w.record_start)??void 0)}let p=await ft(k,r,u,e.get("timeline")??void 0,h,S);if(p){let w=new Uint8Array(12+p.px.length),d=new DataView(w.buffer);return d.setUint32(0,p.w,!0),d.setUint32(4,p.h,!0),d.setUint32(8,p.order==="bgra"?1:0,!0),w.set(p.px,12),i(w,"application/x-conform-pixels")}}catch(k){return o({ok:!1,code:"no_frame",message:k.message},404)}let g=await b("timeline_frame",{session_id:n,record:r,width:u,...e.get("timeline")?{timeline:e.get("timeline")}:{}}),c=g.structuredContent?.out_path;if(g.isError||!c)return o({ok:!1,code:String(g.structuredContent?.code??"no_frame"),message:g.content[0]?.text??"no picture here"},404);let m=await K(c);return await(M(J(c)).startsWith("conform-frame-")?L(J(c)):Q(c)).catch(()=>{}),i(m,"image/png")}if(a==="sessions"&&n&&t.method==="GET"){let e=await v(n).catch(()=>null);return e?o(e):o({ok:!1,code:"not_found"},404)}if(a==="sessions"&&!n)return o(await lt());if(a!=="projects")return o({ok:!1,code:"not_found"},404);if(!n){if(t.method==="POST"){let e=await _(),r=await b("project",{action:"create",name:e.name,client_name:e.client_name,handles:e.handles});return r.isError?o({...r.structuredContent,text:r.content[0]?.text},422):(await Tt(),o(r.structuredContent))}return o(await Tt())}if(!l){let[e,r,u,g]=await Promise.all([$t(n),st(n).catch(()=>null),ut(n),dt(n)]);await at(n===rt?null:{id:n,name:e.name??n});let{text:c="",...m}=r??{};return o({project:e,context:c,context_meta:m,sessions:u,activity:g.slice(-100).reverse()})}if(l==="sessions"&&t.method==="PUT")return await ct(n,String((await _()).session_id??"")),o({ok:!0});if(l==="context"&&t.method==="PUT"){let e=await _();try{let{text:r,...u}=await it(n,String(e.text??""),e.base===void 0?void 0:e.base);return o({ok:!0,context:r,context_meta:u})}catch(r){if(r instanceof B&&r.code==="context_conflict"){let u=r.data?.current;return o({ok:!1,code:r.code,message:r.message,context:u.context,context_meta:{updated_at:u.context_updated_at,updated_by:u.context_updated_by_name??null}},409)}throw r}}return o({ok:!1,code:"not_found"},404)}catch(e){let r=e instanceof B?e:null;return o({ok:!1,code:r?.code??"internal",message:e.message},r?.code==="not_found"?404:r?.code==="invalid_args"?400:500)}}var Lt=Number(E("CONFORM_HTTP_PORT")??7791);E("CONFORM_EXIT_WITH_PARENT")==="1"&&(C.stdin.on("end",()=>C.exit(0)),C.stdin.on("close",()=>C.exit(0)),C.stdin.resume());var G=E("CONFORM_HTTP_TOKEN")??"",vt=(E("CONFORM_HTTP_ORIGINS")??"https://conform.tools,https://app.conform.tools,http://localhost:5173,http://localhost:3000").split(","),j=(t,s=new Headers)=>{let o=t.headers.get("origin")??"";return vt.includes(o)&&s.set("access-control-allow-origin",o),s.set("access-control-allow-headers","authorization, content-type"),s.set("access-control-allow-methods","GET, POST, PUT, DELETE, OPTIONS"),s.set("access-control-allow-private-network","true"),s.set("vary","origin"),s},Et=new Set,f=(t,s,o=200)=>new Response(JSON.stringify(s),{status:o,headers:j(t,new Headers({"content-type":"application/json"}))});tt({hostname:"127.0.0.1",port:Lt,onListen:t=>{Et=new Set([`127.0.0.1:${t}`,`localhost:${t}`,`[::1]:${t}`]),console.error(`conformtools HTTP API on http://127.0.0.1:${t} (${U.length} verbs)`),xt(t,G)}},async t=>{let s=new URL(t.url),o=(t.headers.get("host")??"").toLowerCase();if(!Et.has(o))return new Response("forbidden host",{status:403});let T=t.headers.get("origin");if(T&&!vt.includes(T))return new Response("forbidden origin",{status:403});if(t.method==="OPTIONS")return new Response(null,{status:204,headers:j(t)});if((t.method==="POST"||t.method==="PUT")&&t.headers.get("content-length")!=="0"&&!Ot(s.pathname,t.headers.get("content-type")))return f(t,{ok:!1,code:"unsupported_media_type",message:"send the body as application/json"},415);if(G&&t.headers.get("authorization")!==`Bearer ${G}`&&s.pathname!=="/health")return f(t,{ok:!1,code:"unauthorized"},401);let i=s.pathname.split("/").filter(Boolean);try{if(s.pathname==="/health")return f(t,{ok:!0,verbs:U.length,version:et,engine:I()});if(i[0]==="verbs"&&i.length===1&&t.method==="GET")return f(t,U.map(n=>({name:n.name,title:n.title,description:n.description,long:!!n.long,input_schema:ot(nt.object(n.inputSchema)),protected_stages:n.protectedStages??[],engine:I()})));if(i[0]==="verbs"&&i.length===2&&t.method==="POST"){let n=yt(i[1]);if(!n)return f(t,{ok:!1,code:"not_found",message:`unknown verb ${i[1]}`},404);let l=t.headers.get("content-type")?.includes("json")?await t.json():{},_=kt(n.name,l);if(!_.ok)return f(t,{..._.result.structuredContent,text:_.result.content[0].text},400);let e=await b(n.name,_.data);return f(t,{...e.structuredContent??{ok:!e.isError},text:e.content.map(r=>r.text).join(`
5
- `)},e.isError?422:200)}if(i[0]==="debug"&&i.length===3&&t.method==="POST"&&Deno.env.get("CONFORM_DEBUG_BRIDGE")==="1"){let{hostBridge:n}=await import("./bridge-D5KPIUSY.js"),l=await n();return await l.waitFor(i[1],5e3)?f(t,{ok:!0,result:await l.request(i[1],i[2],t.headers.get("content-type")?.includes("json")?await t.json():{},12e4)}):f(t,{ok:!1,code:"not_connected"},409)}let a=await Pt(t,i,(n,l)=>f(t,n,l),n=>new Response(n,{headers:j(t,new Headers({"content-type":"text/event-stream","cache-control":"no-cache"}))}),(n,l)=>new Response(n,{headers:j(t,new Headers({"content-type":l,"cache-control":"no-store"}))}));if(a)return a;if(i[0]==="jobs"&&i.length===1)return f(t,await _t());if(i[0]==="jobs"&&i.length===2){if(t.method==="DELETE")return f(t,{ok:wt(i[1])});let n=await ht(i[1]);return n?f(t,n):f(t,{ok:!1,code:"not_found"},404)}return f(t,{ok:!1,code:"not_found"},404)}catch(a){return f(t,{ok:!1,code:"internal",message:a instanceof Error?a.message:String(a)},500)}});
5
+ `)},e.isError?422:200)}if(i[0]==="debug"&&i.length===3&&t.method==="POST"&&Deno.env.get("CONFORM_DEBUG_BRIDGE")==="1"){let{hostBridge:n}=await import("./bridge-UIDAF74E.js"),l=await n();return await l.waitFor(i[1],5e3)?f(t,{ok:!0,result:await l.request(i[1],i[2],t.headers.get("content-type")?.includes("json")?await t.json():{},12e4)}):f(t,{ok:!1,code:"not_connected"},409)}let a=await Pt(t,i,(n,l)=>f(t,n,l),n=>new Response(n,{headers:j(t,new Headers({"content-type":"text/event-stream","cache-control":"no-cache"}))}),(n,l)=>new Response(n,{headers:j(t,new Headers({"content-type":l,"cache-control":"no-store"}))}));if(a)return a;if(i[0]==="jobs"&&i.length===1)return f(t,await _t());if(i[0]==="jobs"&&i.length===2){if(t.method==="DELETE")return f(t,{ok:wt(i[1])});let n=await ht(i[1]);return n?f(t,n):f(t,{ok:!1,code:"not_found"},404)}return f(t,{ok:!1,code:"not_found"},404)}catch(a){return f(t,{ok:!1,code:"internal",message:a instanceof Error?a.message:String(a)},500)}});