conformtools 0.5.1

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 (60) hide show
  1. package/README.md +92 -0
  2. package/dist/arriraw-Y5VXHXNX.js +525 -0
  3. package/dist/browser/timeline_core_bg.wasm +0 -0
  4. package/dist/chunk-35U7WGES.js +3 -0
  5. package/dist/chunk-3XTUTEKJ.js +102 -0
  6. package/dist/chunk-7D7H6VFW.js +3 -0
  7. package/dist/chunk-AACY2V3L.js +3 -0
  8. package/dist/chunk-AHNDJFQR.js +3 -0
  9. package/dist/chunk-C2ESM27Z.js +3 -0
  10. package/dist/chunk-DKGGJM6Z.js +3 -0
  11. package/dist/chunk-DRHOPOC7.js +3 -0
  12. package/dist/chunk-HJXRLQOI.js +3 -0
  13. package/dist/chunk-IDDQR56R.js +7 -0
  14. package/dist/chunk-JEMLKBH2.js +3 -0
  15. package/dist/chunk-NYB4ISL3.js +3 -0
  16. package/dist/chunk-P7OVDUA5.js +3 -0
  17. package/dist/chunk-PSANHDZM.js +3 -0
  18. package/dist/chunk-QDWB7QU7.js +3 -0
  19. package/dist/chunk-RXHNBSER.js +3 -0
  20. package/dist/chunk-SP5RGDAM.js +3 -0
  21. package/dist/chunk-TK55FA56.js +3 -0
  22. package/dist/chunk-UCMNH6Q6.js +3 -0
  23. package/dist/chunk-UUMHVA7R.js +3 -0
  24. package/dist/chunk-WWGQFOB2.js +64 -0
  25. package/dist/chunk-YPRTUS5W.js +3 -0
  26. package/dist/cli.js +11 -0
  27. package/dist/clip-state-B6JOX3JE.js +3 -0
  28. package/dist/cr3-wasm-X6Q4YMUU.js +3 -0
  29. package/dist/dng-wasm-EAB24KDN.js +3 -0
  30. package/dist/dpx-wasm-OX2D24ZB.js +3 -0
  31. package/dist/esm-SFFBP7PS.js +3 -0
  32. package/dist/exr-wasm-Z6BBPJSN.js +3 -0
  33. package/dist/h264-JHQCJTWP.js +3 -0
  34. package/dist/h264-mxf-4M63NBQK.js +3 -0
  35. package/dist/http.js +4 -0
  36. package/dist/inspect-6OM4FTVW.js +46 -0
  37. package/dist/isobmff-XL33CVJR.js +3 -0
  38. package/dist/mcp.js +13 -0
  39. package/dist/media_core-VSTO6CS4.js +9 -0
  40. package/dist/media_core_bg-BKXQLNFA.js +3 -0
  41. package/dist/media_core_bg-XIM7Y4R3.js +3 -0
  42. package/dist/mxf-VIANACTI.js +3 -0
  43. package/dist/onnxruntime-web-stub-PKJ2NZBF.js +3 -0
  44. package/dist/ops-7HVBBXUQ.js +3 -0
  45. package/dist/prores-TQEZ3KFH.js +526 -0
  46. package/dist/r3d-2QCFX7UX.js +3 -0
  47. package/dist/r3d-AT6NNIY3.js +1025 -0
  48. package/dist/source-BDJAUQVR.js +3 -0
  49. package/dist/sscd-sweep-IXM4OD7O.js +3 -0
  50. package/dist/still-E4HLCCST.js +3 -0
  51. package/dist/tiff-wasm-XYTQNL2F.js +3 -0
  52. package/dist/timeline_core-VK2ZWPCO.js +3 -0
  53. package/dist/timeline_core_bg-QEOVAIWP.js +3 -0
  54. package/dist/udf_bg-UTQ6BVXX.js +3 -0
  55. package/dist/wasm/media_core_bg.wasm +0 -0
  56. package/dist/wasm/udf_bg.wasm +0 -0
  57. package/dist/wasm-threads/media_core_bg.wasm +0 -0
  58. package/dist/wav-DXF73Y56.js +3 -0
  59. package/dist/zod-IPSV75LP.js +3 -0
  60. package/package.json +41 -0
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ var s={scrub:{output:"rgba8",detail:"coarse"},thumbnail:{output:"rgba8",detail:"coarse"},park:{output:"rgba8",detail:"exact"},render:{output:"rgba8",detail:"exact"},transcode:{output:"rgb16",detail:"exact"}};function p(e){let t=new DataView(e.buffer,e.byteOffset,8),r=t.getUint32(0,!0),n=t.getUint32(4,!0),o=e.slice(8);return{width:r,height:n,rgb16:new Uint16Array(o.buffer,o.byteOffset,r*n*3)}}var a=class extends Error{constructor(r,n){super(`COVERAGE_MISS: frame ${r} not in linked media (${n} frames)`);this.index=r;this.frameCount=n;this.name="CoverageMissError"}},m=/(?:[A-Z0-9]+_)?COVERAGE_MISS\s+(\{[\s\S]*\})/;function u(e){let r=(e instanceof Error?e.message:String(e??"")).match(m);if(!r)return null;try{return JSON.parse(r[1])}catch{return{reason:"coverage_miss"}}}var i=class extends Error{constructor(r){super(`DELIVERY_COVERAGE_MISS: ${r.reason}`+(r.cut_in!=null?` cut [${r.cut_in}..${r.cut_out}] file_frames ${r.file_frames}`:""));this.detail=r;this.name="DeliveryCoverageMissError"}};function l(e){return e instanceof i?e.detail:u(e)}var d={mov:()=>import("./isobmff-XL33CVJR.js").then(e=>e.isobmffFormat),crm:()=>import("./isobmff-XL33CVJR.js").then(e=>e.isobmffFormat),braw:()=>import("./isobmff-XL33CVJR.js").then(e=>e.isobmffFormat),wav:()=>import("./wav-DXF73Y56.js").then(e=>e.wavFormat),mxf:()=>import("./mxf-VIANACTI.js").then(e=>e.mxfFormat),r3d:()=>import("./r3d-2QCFX7UX.js").then(e=>e.r3dFormat),still:()=>import("./still-E4HLCCST.js").then(e=>e.stillFormat),avc1:()=>import("./h264-JHQCJTWP.js").then(e=>e.h264Format),avc3:()=>import("./h264-JHQCJTWP.js").then(e=>e.h264Format),h264:()=>import("./h264-JHQCJTWP.js").then(e=>e.h264Format),hvc1:()=>import("./h264-JHQCJTWP.js").then(e=>e.h264Format),hev1:()=>import("./h264-JHQCJTWP.js").then(e=>e.h264Format),hevc:()=>import("./h264-JHQCJTWP.js").then(e=>e.h264Format),h264_mxf:()=>import("./h264-mxf-4M63NBQK.js").then(e=>e.h264MxfFormat)};async function c(e){let t=d[e];return t?await t():null}async function f(e){let t=await c(e.format);if(!t)throw new Error(`extract: no handler for format '${e.format}'`);return t.extract(e)}async function b(e,t){let r=await c(e.format);if(!r){if(t.verb==="inspect")return null;throw new Error(`mediaOp: no handler for format '${e.format}' (verb ${t.verb})`)}switch(t.verb){case"inspect":{let n=await r.inspect(e);return n&&(n.source_facts_origin="probed"),n}case"sparsify":return r.sparsify(e,t.selection);case"trim":return r.trim(e,t.selection);case"decode":{let{output:n,detail:o}=s[t.intent];if(n==="rgb16"){if(!r.decode16)throw new Error(`mediaOp: format '${e.format}' has no 16-bit decoder (intent '${t.intent}')`);return r.decode16(e,t.index)}if(!r.decode)throw new Error(`mediaOp: format '${e.format}' has no decoder (no viewer)`);return r.decode(e,t.index,{detail:o})}}}export{s as a,p as b,a as c,u as d,i as e,l as f,c as g,f as h,b as i};
package/dist/cli.js ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{b as e,c as s,e as c,i as a,j as l,k as m}from"./chunk-3XTUTEKJ.js";import"./chunk-HJXRLQOI.js";import"./chunk-DRHOPOC7.js";import"./chunk-35U7WGES.js";import"./chunk-P7OVDUA5.js";import"./chunk-RXHNBSER.js";import"./chunk-UCMNH6Q6.js";import"./chunk-QDWB7QU7.js";import"./chunk-AHNDJFQR.js";import"./chunk-TK55FA56.js";import"./chunk-JEMLKBH2.js";import"./chunk-YPRTUS5W.js";import"./chunk-UUMHVA7R.js";import"./chunk-WWGQFOB2.js";import"./chunk-C2ESM27Z.js";import"./chunk-NYB4ISL3.js";import"./chunk-PSANHDZM.js";var g={login:"account_login",logout:"account_logout",whoami:"account_status",status:"account_status"};e()[0]==="mcp"&&(await import("./mcp.js"),await new Promise(()=>{}));e()[0]==="http"&&(await import("./http.js"),await new Promise(()=>{}));var f=e().includes("--json"),[t,p]=e().filter(o=>o!=="--json");if(!t||t==="--list"||t==="help"||t==="--help"){console.log(`conformtools <verb> '<json args>' [--json]
4
+
5
+ login / whoami / logout sign in with your conform.tools Google account
6
+ mcp run as an MCP server (stdio) for Claude Code, Cursor, Codex\u2026
7
+ http run the local HTTP API on 127.0.0.1:7791
8
+ `);let o=c()==="hosted";for(let n of l)console.log(` ${n.name.padEnd(22)} ${n.title}${o&&n.protectedStages?.length?" (on conform.tools)":""}`);o&&console.log(`
9
+ (on conform.tools) = the timeline is read or written by conform.tools; the file and its media stay here`),s(0)}var i=g[t]??t,u=m(i);u||(console.error(`unknown verb '${t}' \u2014 conformtools --list`),s(2));i==="account_login"&&console.error("opening the browser to sign in to conform.tools\u2026");var h=Object.fromEntries(Object.entries(u.inputSchema).map(([o,n])=>[o,n])),{z:d}=await import("./zod-IPSV75LP.js"),w=d.object(h).parse(JSON.parse(p??"{}")),r=await a(i,w);console.log(f?JSON.stringify(r.structuredContent??{ok:!r.isError,text:r.content.map(o=>o.text).join(`
10
+ `)},null,1):r.content.map(o=>o.text).join(`
11
+ `));s(r.isError?1:0);
@@ -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"./chunk-PSANHDZM.js";function h(r){let e=new Uint32Array(1);return e[0]=r>>>0,new Float32Array(e.buffer)[0]}function U(r,e){if(r.length<12)return null;let a=new DataView(r.buffer,r.byteOffset,r.byteLength);if(a.getUint32(0,!1)!==1095911248||a.getUint32(4,!0)!==1)return null;let u=8,y=t=>{if(t<0||u+t>r.length)return null;let o=r.subarray(u,u+t);return u+=t,o},l=()=>{if(u+4>r.length)return null;let t=a.getUint32(u,!0);return u+=4,t},i=l();if(i===null)return null;let g=y(i);if(!g)return null;let n;try{n=JSON.parse(new TextDecoder().decode(g))}catch{return null}let w=l();if(w===null)return null;let c=y(w);if(!c)return null;let A=l();if(A===null)return null;if(A===0)return!e||e.key!==n.key||n.has_state?null:{key:n.key,essence:c,state:e.state};if(A!==6)return null;let s=[];for(let t=0;t<6;t++){let o=l();if(o===null||u+o>r.length)return null;s.push(r.slice(u,u+o)),u+=o}let f=t=>new Float32Array(t.buffer,t.byteOffset,t.byteLength>>>2),m=t=>new Uint16Array(t.buffer,t.byteOffset,t.byteLength>>>1);if(!Array.isArray(n.gains_8_24)||n.gains_8_24.length!==4||!Array.isArray(n.cp_bits)||n.cp_bits.length!==4)return null;let _={width:n.w,height:n.h,gains8_24:Uint32Array.from(n.gains_8_24),prepDecompand:f(s[0]),prepRecompand:m(s[1]),rptab:f(s[2]),gridA:f(s[3]),gridB:f(s[4]),finalLut:f(s[5]),cp:Float32Array.from(n.cp_bits,h),k2:h(n.k2_bits)};return{key:n.key,essence:c,state:_}}function p(r){let e=Math.round(r*65535);return e>0?e>65535?65535:e:0}function b(r){let e=r.width*r.height,a=new Uint16Array(e*3),{r:u,g:y,b:l}=r;for(let i=0;i<e;i++)a[3*i]=p(u[i]),a[3*i+1]=p(y[i]),a[3*i+2]=p(l[i]);return a}export{b as arrirawFrameToRgb16,U as parseArrirawGpuPayload,p as quantizeLogC4};
@@ -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{N as s,l as o,ua as r}from"./chunk-UUMHVA7R.js";import"./chunk-PSANHDZM.js";async function d(t){await r();let e=s(t);return e==="null"?null:JSON.parse(e)}async function l(t){await r();let e;try{e=o(t)}catch{return null}if(e.length<8)return null;let n=new DataView(e.buffer,e.byteOffset,e.byteLength),a=n.getUint32(0,!0),i=n.getUint32(4,!0),u=a*i*4;return e.length<8+u?null:{width:a,height:i,rgba:new Uint8ClampedArray(e.subarray(8,8+u))}}export{l as decodeCr3Wasm,d as inspectCr3Wasm};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{a as c,b as m}from"./chunk-DKGGJM6Z.js";import{O as s,n as d,sa as u,ua as t}from"./chunk-UUMHVA7R.js";import"./chunk-PSANHDZM.js";async function h(r){await t();let e=s(r);return e==="null"?null:JSON.parse(e)}async function g(r){await t();let e;try{e=d(r)}catch{return null}if(e.length<8)return null;let n=new DataView(e.buffer,e.byteOffset,e.byteLength),i=n.getUint32(0,!0),a=n.getUint32(4,!0),o=i*a*4;return e.length<8+o?null:{width:i,height:a,rgba:new Uint8ClampedArray(e.subarray(8,8+o))}}async function y(r,e=8){await t();let n=m(u,"decode_dng_preview");if(!n)return g(r);try{return c(n(r,e))}catch{return null}}export{y as decodeDngPreviewWasm,g as decodeDngWasm,h as inspectDngWasm};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{a as s,b as m}from"./chunk-DKGGJM6Z.js";import{P as c,o as u,sa as d,ua as n}from"./chunk-UUMHVA7R.js";import"./chunk-PSANHDZM.js";async function x(r){await n();let e=c(r);return e==="null"?null:JSON.parse(e)}async function p(r){await n();let e;try{e=u(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=m(d,"decode_dpx_preview");if(!t)return p(r);try{return s(t(r,e))}catch{return null}}export{y as decodeDpxPreviewWasm,p as decodeDpxWasm,x as inspectDpxWasm};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";export{k as AsyncCompress,A as AsyncDecompress,c as AsyncDeflate,o as AsyncGunzip,k as AsyncGzip,g as AsyncInflate,P as AsyncUnzipInflate,w as AsyncUnzlib,J as AsyncZipDeflate,s as AsyncZlib,j as Compress,D as DecodeUTF8,z as Decompress,b as Deflate,E as EncodeUTF8,a as FlateErrorCode,n as Gunzip,j as Gzip,f as Inflate,Q as Unzip,O as UnzipInflate,N as UnzipPassThrough,v as Unzlib,K as Zip,I as ZipDeflate,H as ZipPassThrough,r as Zlib,l as compress,m as compressSync,B as decompress,C as decompressSync,d as deflate,e as deflateSync,p as gunzip,q as gunzipSync,l as gzip,m as gzipSync,h as inflate,i as inflateSync,G as strFromU8,F as strToU8,R as unzip,S as unzipSync,x as unzlib,y as unzlibSync,L as zip,M as zipSync,t as zlib,u as zlibSync};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{a as m,b as l}from"./chunk-DKGGJM6Z.js";import{Q as c,p as s,sa as u,ua as n}from"./chunk-UUMHVA7R.js";import"./chunk-PSANHDZM.js";async function y(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 h(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{h as decodeExrPreviewWasm,d as decodeExrWasm,y 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{a as v,b as S}from"./chunk-SP5RGDAM.js";import{a as M}from"./chunk-QDWB7QU7.js";import{a as F}from"./chunk-TK55FA56.js";import"./chunk-PSANHDZM.js";var V=8,H=1500,P=new WeakMap;async function C(t){let o=P.get(t);return o||(o=k(t),P.set(t,o)),o}async function k(t){if(typeof VideoDecoder>"u")throw new Error("h264: WebCodecs (VideoDecoder) not available in this context");let o=t.parts[0],e=await F({fileSize:o.fileSize,read:o.read}),a=S(v(e)),r=M(e);if(!r)throw new Error("h264: no H.264/HEVC config in container");let s=r.decodeToPres.length||a.length,f=new Int32Array(s);for(let n=0;n<r.decodeToPres.length;n++)f[r.decodeToPres[n]]=n;let u=[];for(let n=0;n<r.keyframes.length;n++){let l=r.keyframes[n],m=n+1<r.keyframes.length?r.keyframes[n+1]:a.length;u.push([l,m])}let c={offs:a,cfg:r,gops:u,presToDecode:f,count:s,dec:null,wanted:-1,got:null,gotResolve:null,fedThrough:-1,queue:Promise.resolve()};return c.dec=new VideoDecoder({output:n=>{Number(n.timestamp)===c.wanted&&!c.got?(c.got=n,c.gotResolve?.()):n.close()},error:()=>{c.fedThrough=-1}}),c.dec.configure({codec:r.codec,description:r.description,optimizeForLatency:!0,hardwareAcceleration:"prefer-hardware"}),c}function R(t,o){let e=0,a=t.length-1,r=0;for(;e<=a;){let s=e+a>>1;t[s][0]<=o?(r=s,e=s+1):a=s-1}return r}async function I(t){let o=t.codedWidth,e=t.codedHeight;try{let a=o*e*4,r=new Uint8Array(a);return await t.copyTo(r,{format:"RGBA",colorSpace:"srgb"}),{width:o,height:e,rgba:r}}catch{let r=new OffscreenCanvas(o,e).getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("h264: no 2d context for frame readback");r.drawImage(t,0,0);let s=r.getImageData(0,0,o,e);return{width:o,height:e,rgba:new Uint8Array(s.data.buffer)}}}async function O(t,o){let e=await C(t);if(e.count===0)throw new Error("h264: empty clip");if(o<0||o>=e.count)throw new Error(`COVERAGE_MISS: frame ${o} outside 0..${e.count-1}`);let a,r=new Promise(f=>{a=f}),s=e.queue;e.queue=e.queue.then(()=>r),await s;try{let f=t.parts[0],u=e.presToDecode[o],c=R(e.gops,u),[n,l]=e.gops[c];for(let m=0;m<2;m++){let T=m===0&&e.fedThrough>n&&e.fedThrough<=l&&u>=e.fedThrough,w=T?e.fedThrough:n;if(!T&&e.fedThrough!==-1){try{await e.dec.flush()}catch{}e.fedThrough=-1}let h=Math.min(l,u+1+V);e.wanted=o,e.got=null;let D=new Promise(d=>{e.gotResolve=d});if(h>w){let d=1/0,y=0;for(let i=w;i<h;i++)d=Math.min(d,e.offs[i].offset),y=Math.max(y,e.offs[i].offset+e.offs[i].size);let E=await f.read(d,y-d);for(let i=w;i<h;i++){let b=e.offs[i];e.dec.decode(new EncodedVideoChunk({type:i===n?"key":"delta",timestamp:e.cfg.decodeToPres[i],data:E.subarray(b.offset-d,b.offset-d+b.size)}))}e.fedThrough=h}let A=new Promise(d=>setTimeout(d,H));if(await Promise.race([D,A]),!e.got){try{await e.dec.flush()}catch{}e.fedThrough=-1}let p=e.got;if(e.wanted=-1,e.gotResolve=null,e.got=null,!!p)try{return await I(p)}finally{p.close()}}throw new Error(`h264: frame ${o} did not decode`)}finally{a()}}async function g(){return(await import("./isobmff-XL33CVJR.js")).isobmffFormat}var U={async inspect(t){return(await g()).inspect(t)},async extract(t){return(await g()).extract(t)},async sparsify(t,o){return(await g()).sparsify(t,o)},async trim(t,o){return(await g()).trim(t,o)},async decode(t,o){return O(t,o)}};export{U as h264Format};
@@ -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{ca as g,ea as b,ua as v}from"./chunk-UUMHVA7R.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-VIANACTI.js")).mxfFormat}var O={async inspect(o){return(await m()).inspect(o)},async extract(o){return(await m()).extract(o)},async sparsify(o,t){return(await m()).sparsify(o,t)},async trim(o,t){return(await m()).trim(o,t)},async decode(o,t){return U(o,t)}};export{O as h264MxfFormat};
package/dist/http.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{a as p,c as d}from"./chunk-IDDQR56R.js";import{a as c,d as h,e as u,f,g,h as T,i as O,j as a}from"./chunk-3XTUTEKJ.js";import"./chunk-HJXRLQOI.js";import"./chunk-DRHOPOC7.js";import"./chunk-35U7WGES.js";import"./chunk-P7OVDUA5.js";import"./chunk-RXHNBSER.js";import"./chunk-UCMNH6Q6.js";import"./chunk-QDWB7QU7.js";import"./chunk-AHNDJFQR.js";import"./chunk-TK55FA56.js";import"./chunk-JEMLKBH2.js";import"./chunk-YPRTUS5W.js";import"./chunk-UUMHVA7R.js";import{Zd as m}from"./chunk-WWGQFOB2.js";import"./chunk-C2ESM27Z.js";import"./chunk-NYB4ISL3.js";import"./chunk-PSANHDZM.js";var b=Number(c("CONFORM_HTTP_PORT")??7791),w=c("CONFORM_HTTP_TOKEN")??"",S=(c("CONFORM_HTTP_ORIGINS")??"https://conform.tools,https://app.conform.tools,http://localhost:5173,http://localhost:3000").split(","),E=(e,n=new Headers)=>{let t=e.headers.get("origin")??"";return S.includes(t)&&n.set("access-control-allow-origin",t),n.set("access-control-allow-headers","authorization, content-type"),n.set("access-control-allow-methods","GET, POST, DELETE, OPTIONS"),n.set("access-control-allow-private-network","true"),n.set("vary","origin"),n},s=(e,n,t=200)=>new Response(JSON.stringify(n),{status:t,headers:E(e,new Headers({"content-type":"application/json"}))});h({hostname:"127.0.0.1",port:b,onListen:e=>console.error(`conformtools HTTP API on http://127.0.0.1:${e} (${a.length} verbs)`)},async e=>{let n=new URL(e.url);if(e.method==="OPTIONS")return new Response(null,{status:204,headers:E(e)});if(w&&e.headers.get("authorization")!==`Bearer ${w}`&&n.pathname!=="/health")return s(e,{ok:!1,code:"unauthorized"},401);let t=n.pathname.split("/").filter(Boolean);try{if(n.pathname==="/health")return s(e,{ok:!0,verbs:a.length,version:p,engine:u()});if(t[0]==="verbs"&&t.length===1&&e.method==="GET")return s(e,a.map(o=>({name:o.name,title:o.title,description:o.description,long:!!o.long,input_schema:d(m.object(o.inputSchema)),protected_stages:o.protectedStages??[],engine:u()})));if(t[0]==="verbs"&&t.length===2&&e.method==="POST"){let o=a.find(r=>r.name===t[1]);if(!o)return s(e,{ok:!1,code:"not_found",message:`unknown verb ${t[1]}`},404);let R=e.headers.get("content-type")?.includes("json")?await e.json():{},l=m.object(o.inputSchema).safeParse(R);if(!l.success)return s(e,{ok:!1,code:"invalid_args",message:l.error.issues.map(r=>`${r.path.join(".")}: ${r.message}`).join("; ")},400);let i=await O(o.name,l.data);return s(e,{...i.structuredContent??{ok:!i.isError},text:i.content.map(r=>r.text).join(`
4
+ `)},i.isError?422:200)}if(t[0]==="jobs"&&t.length===1)return s(e,await T());if(t[0]==="jobs"&&t.length===2){if(e.method==="DELETE")return s(e,{ok:g(t[1])});let o=await f(t[1]);return o?s(e,o):s(e,{ok:!1,code:"not_found"},404)}return s(e,{ok:!1,code:"not_found"},404)}catch(o){return s(e,{ok:!1,code:"internal",message:o instanceof Error?o.message:String(o)},500)}});