conformtools 0.6.5 → 0.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -13
- package/dist/account-DJTD3KYK.js +3 -0
- package/dist/arriraw-YIJ3BYNN.js +525 -0
- package/dist/avid-panel/MANIFEST.json +11 -0
- package/dist/avid-panel/avid-manifest.json +46 -0
- package/dist/avid-panel/icon.svg +4 -0
- package/dist/avid-panel/icons/conformtools.svg +4 -0
- package/dist/avid-panel/index.html +26 -0
- package/dist/avid-panel/panel.css +12 -0
- package/dist/avid-panel/panel.js +7 -0
- package/dist/bridge-JQF4V3V2.js +3 -0
- package/dist/browser/timeline_core_bg.wasm +0 -0
- package/dist/chunk-2BPR6LK6.js +3 -0
- package/dist/chunk-3D3Z4TBR.js +3 -0
- package/dist/chunk-55BKURYP.js +378 -0
- package/dist/chunk-5WEZRGXG.js +39 -0
- package/dist/chunk-6V4OEOOX.js +3 -0
- package/dist/chunk-7D7H6VFW.js +3 -0
- package/dist/chunk-A7FNR3T5.js +3 -0
- package/dist/chunk-AACY2V3L.js +3 -0
- package/dist/chunk-AMRJXYL4.js +3 -0
- package/dist/chunk-C2ESM27Z.js +3 -0
- package/dist/chunk-D4WPRRBT.js +3 -0
- package/dist/chunk-D6YDLKSA.js +3 -0
- package/dist/chunk-DKGGJM6Z.js +3 -0
- package/dist/chunk-EUBXH67N.js +7 -0
- package/dist/chunk-GK4YYKJ6.js +19 -0
- package/dist/chunk-GM6QKY7W.js +3 -0
- package/dist/chunk-J2JXLEAI.js +3 -0
- package/dist/chunk-JV7TZDKJ.js +3 -0
- package/dist/chunk-NAFLOZER.js +9 -0
- package/dist/chunk-NFJHWZJX.js +3 -0
- package/dist/chunk-NU3X7P4N.js +3 -0
- package/dist/chunk-P2LL3JMC.js +20 -0
- package/dist/chunk-PFISREY4.js +3 -0
- package/dist/chunk-PFZVET7S.js +3 -0
- package/dist/chunk-PHAMF4JF.js +4 -0
- package/dist/chunk-PLRB2YXJ.js +3 -0
- package/dist/chunk-PSANHDZM.js +3 -0
- package/dist/chunk-RGMTLNMF.js +3 -0
- package/dist/chunk-RJ6JA2LZ.js +3 -0
- package/dist/chunk-S5JDS5PQ.js +5 -0
- package/dist/chunk-SGLQY53R.js +3 -0
- package/dist/chunk-SKFMOLUO.js +8 -0
- package/dist/chunk-SNTAZJ5A.js +6 -0
- package/dist/chunk-TK55FA56.js +3 -0
- package/dist/chunk-TXQR2HI2.js +4 -0
- package/dist/chunk-VIBEEWPC.js +10 -0
- package/dist/chunk-WN53ARHJ.js +3 -0
- package/dist/chunk-XLEINKFL.js +5 -0
- package/dist/claude-setup-IIWUB4CE.js +5 -0
- package/dist/cli.js +17 -0
- package/dist/clip-state-B6JOX3JE.js +3 -0
- package/dist/conformtools-analyze +0 -0
- package/dist/conformtools-decode +0 -0
- package/dist/cr3-wasm-HLJWEV2S.js +3 -0
- package/dist/dng-wasm-CQDLPM5V.js +3 -0
- package/dist/dpx-wasm-TLGMM7BO.js +3 -0
- package/dist/engine-P6H5P6HP.js +5 -0
- package/dist/esm-SFFBP7PS.js +3 -0
- package/dist/exr-wasm-2NPKPTVB.js +3 -0
- package/dist/flame/hook/conformtools_flame/__init__.py +10 -0
- package/dist/flame/hook/conformtools_flame/building.py +191 -0
- package/dist/flame/hook/conformtools_flame/hook.py +177 -0
- package/dist/flame/hook/conformtools_flame/render.py +622 -0
- package/dist/flame/hook/conformtools_flame/util.py +33 -0
- package/dist/flame/hook/conformtools_flame/verbs.py +1037 -0
- package/dist/flame/hook/conformtools_flame_hook.py +42 -0
- package/dist/fonts/gfx/BarlowCondensed-Bold.ttf +0 -0
- package/dist/fonts/gfx/BarlowCondensed-Regular.ttf +0 -0
- package/dist/fonts/gfx/InstrumentSerif-Regular.ttf +0 -0
- package/dist/fonts/gfx/Inter-Bold.ttf +0 -0
- package/dist/fonts/gfx/Inter-Regular.ttf +0 -0
- package/dist/fonts/gfx/JetBrainsMono-Bold.ttf +0 -0
- package/dist/fonts/gfx/JetBrainsMono-Regular.ttf +0 -0
- package/dist/fonts/gfx/OFL.txt +100 -0
- package/dist/framing-SWOD4CWB.js +3 -0
- package/dist/gfx-worker.js +3 -0
- package/dist/h264-JJMZSUWW.js +3 -0
- package/dist/h264-mxf-DCUOGLDU.js +3 -0
- package/dist/host-relink-TWAF6WIG.js +10 -0
- package/dist/hosts-Z666EF7V.js +3 -0
- package/dist/http.js +5 -0
- package/dist/i2o-transfer +0 -0
- package/dist/inspect-FJKYPEXL.js +68 -0
- package/dist/isobmff-VJOWP4MH.js +3 -0
- package/dist/mc-video-5MGGOQN4.js +3 -0
- package/dist/mcp.js +13 -0
- package/dist/media-NZYVREUF.js +3 -0
- package/dist/media_core-YZ3PABEG.js +9 -0
- package/dist/media_core_bg-FDL7GJZP.js +3 -0
- package/dist/media_core_bg-XRBVKQZH.js +3 -0
- package/dist/mxf-FJSRFLJC.js +3 -0
- package/dist/nuke/panel/python/Startup/conformtools_nuke_startup.py +44 -0
- package/dist/nuke/panel/python/conformtools_nuke/__init__.py +10 -0
- package/dist/nuke/panel/python/conformtools_nuke/panel.py +217 -0
- package/dist/nuke/panel/python/conformtools_nuke/verbs.py +837 -0
- package/dist/ops-X7NAREC4.js +3 -0
- package/dist/peer-kit/ctpeer/__init__.py +21 -0
- package/dist/peer-kit/ctpeer/client.py +247 -0
- package/dist/peer-kit/ctpeer/neutral.py +178 -0
- package/dist/peer-kit/ctpeer/pairing.py +139 -0
- package/dist/peer-kit/ctpeer/protocol.py +209 -0
- package/dist/peer-kit/ctpeer/websocket.py +289 -0
- package/dist/premiere-uxp/icons/panel.png +0 -0
- package/dist/premiere-uxp/icons/panel@2x.png +0 -0
- package/dist/premiere-uxp/icons/plugin.png +0 -0
- package/dist/premiere-uxp/icons/plugin@2x.png +0 -0
- package/dist/premiere-uxp/index.html +38 -0
- package/dist/premiere-uxp/index.js +93 -0
- package/dist/premiere-uxp/lib/clipmeta.js +170 -0
- package/dist/premiere-uxp/lib/ctx.js +68 -0
- package/dist/premiere-uxp/lib/edit.js +516 -0
- package/dist/premiere-uxp/lib/handles.js +57 -0
- package/dist/premiere-uxp/lib/markers.js +198 -0
- package/dist/premiere-uxp/lib/pairing.js +67 -0
- package/dist/premiere-uxp/lib/premiere.js +91 -0
- package/dist/premiere-uxp/lib/probe.js +452 -0
- package/dist/premiere-uxp/lib/protocol.js +165 -0
- package/dist/premiere-uxp/lib/render.js +45 -0
- package/dist/premiere-uxp/lib/session.js +85 -0
- package/dist/premiere-uxp/lib/sizing.js +325 -0
- package/dist/premiere-uxp/lib/time.js +88 -0
- package/dist/premiere-uxp/lib/timeline.js +336 -0
- package/dist/premiere-uxp/lib/verbs.js +21 -0
- package/dist/premiere-uxp/lib/write.js +97 -0
- package/dist/premiere-uxp/manifest.json +102 -0
- package/dist/probe-F7WQHMIA.js +3 -0
- package/dist/prores-RIG37OIH.js +526 -0
- package/dist/r3d-CXUNG6VS.js +1025 -0
- package/dist/r3d-T5O6IIZZ.js +3 -0
- package/dist/resolve-bridge.py +2286 -0
- package/dist/resolve-presets/conform.tools.xml +127 -0
- package/dist/source-QGWWLMME.js +3 -0
- package/dist/statusline-GMMCFMOA.js +4 -0
- package/dist/statusline.js +3 -0
- package/dist/still-P4JJNTEO.js +3 -0
- package/dist/still-wasm-DN5LPASS.js +3 -0
- package/dist/store-7IOEBOZY.js +3 -0
- package/dist/tiff-wasm-BPRDR6EB.js +3 -0
- package/dist/timeline-DQG6TVPF.js +3 -0
- package/dist/timeline_core-IOENXK4Z.js +3 -0
- package/dist/timeline_core_bg-JW42YM3G.js +3 -0
- package/dist/udf_bg-B37GKRIH.js +3 -0
- package/dist/wasm/media_core_bg.wasm +0 -0
- package/dist/wasm/udf_bg.wasm +0 -0
- package/dist/wasm-threads/media_core_bg.wasm +0 -0
- package/dist/wav-64SC6P7U.js +3 -0
- package/package.json +6 -4
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
|
|
3
|
+
import{a as 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
|
+
`).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
|
+
`).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
|
+
`)}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(`
|
|
7
|
+
`):"no audio",`${e.reel_name?`reel ${e.reel_name}; `:""}${a!=null?`${(a/1e6).toFixed(1)} MB`:""}${c?`; spanned ${c.length} parts`:""}`].join(`
|
|
8
|
+
`)}var Ke=8*1024*1024,T=e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0));async function Ve(e,t,o){if(e.executable_locally===!1)throw new Error("this trim plan is server-side only");let r=new Map(t.parts.map(n=>[b(n.path),n]));await j(y(o));let i=await re(o);try{await i.truncate(e.total_size),await i.writeAt(0,T(e.dest_header_bytes_base64));for(let n of e.src_byte_ranges){let s=n.src_file_name?r.get(b(n.src_file_name)):t.parts[0];if(!s)throw new Error(`plan references unknown source part '${n.src_file_name}'`);let a=0;for(;a<n.length;){let c=Math.min(Ke,n.length-a),l=await s.file.readAt(n.offset+a,c);if(l.length<c)throw new Error(`short read in ${b(s.path)} at ${n.offset+a}`);await i.writeAt(n.write_to_dest_offset+a,l),a+=c}}e.dest_footer_bytes_base64&&e.dest_footer_offset!=null&&await i.writeAt(e.dest_footer_offset,T(e.dest_footer_bytes_base64));for(let n of e.dest_patches??[])await i.writeAt(n.offset,T(n.bytes_base64))}finally{await i.close()}for(let n of e.dest_sidecar_writes??[])await H(_(y(o),n.name),T(n.bytes_base64))}function Xe(e,t){let o=[];for(let r of e){if(r.kind!=="clip"||!r.source_range)continue;let i=r.source_range.start.value,n=r.source_range.duration.value,s=Math.max(0,Math.floor(i)-t),a=Math.floor(i+n-1)+t;a>=s&&o.push({first_frame:s,last_frame:a})}return de(o)}async function Ge(e,t,o,r,i){let n=await Y(e);try{let s=Xe(t,o);if(!s.length)throw new Error("no usable frame ranges (items need kind=clip with source_range)");let a=await D(n.source,{verb:"trim",selection:{items:t,handles:o}}),c=L(n.anchor),l=n.format==="r3d",u=l?M(b(n.anchor))?.clipBase??b(n.anchor,c):b(n.anchor,c),m=[];for(let[d,f]of a.entries()){let p=f.output_clip_number??(s.length>1?d+1:void 0),h=s[(p??1)-1]??s[0],g=p&&(f.output_clip_count??s.length)>1?`_S${String(p).padStart(3,"0")}`:"",w;if(l){let x=f.output_part_number??d+1;w=_(r,`${u}${g}.RDC`,`${u}_${String(x).padStart(3,"0")}.R3D`),m.push({path:w,bytes:f.total_size,island:h,part:x,clip:p})}else{let x=i&&a.length===1?i:`${u}${g||`_trim_${h.first_frame}-${h.last_frame}`}${c}`;w=_(r,x),m.push({path:w,bytes:f.total_size,island:h,clip:p})}await Ve(f,n,w)}return l||await Ye(e,m,!!i&&a.length===1),{outputs:m,islands:s,format:n.format}}finally{n.close()}}async function Ye(e,t,o){let r=await P(e).catch(()=>null),i=r?.source_fps??r?.streams?.find(n=>n.kind==="video")?.rate??null;if(!(!r?.source_timecode||!i))for(let n of t){if(!n.island)continue;let s=await P(n.path).catch(()=>null),a=s?.available_range?.duration?.value??s?.declared_duration?.value;if(!s?.source_timecode||!a)continue;let c=R(s.source_timecode,i,r.source_timecode);if(c===n.island.first_frame&&c+a-1===n.island.last_frame||(n.island={first_frame:c,last_frame:c+a-1},o))continue;let l=n.path.replace(/_trim_\d+-\d+(\.[^./\\]+)$/,`_trim_${c}-${c+a-1}$1`);l!==n.path&&(await W(n.path,l),n.path=l)}}async function Br(e){let t=await P(e.path),o=t.source_fps??t.streams?.find(p=>p.kind==="video")?.rate??null,r=t.available_range?.duration?.value??t.declared_duration?.value??null;if(!o)throw new Error("cannot trim: no frame rate / timecode track on this file");let i=R(e.in,o,t.source_timecode??null),n=R(e.out,o,t.source_timecode??null);if(e.out_exclusive&&(n-=1),n<i)throw new Error(`out (${n}) is before in (${i})`);if(i<0)throw new Error(`in (${i}) is before the file start (TC ${t.source_timecode})`);if(r!=null&&n>r-1)throw new Error(`out (${n}) is past the last frame (${r-1})`);let s={id:"trim",kind:"clip",source_range:{start:{value:i,rate:o},duration:{value:n-i+1,rate:o}}},a=y(e.path),c;if(e.out_path)try{(await B(e.out_path)).isDirectory?a=e.out_path:(a=y(e.out_path),c=b(e.out_path))}catch{a=y(e.out_path),c=b(e.out_path)}let l=await Ge(e.path,[s],Math.max(0,Math.floor(e.handles??0)),a,c),u=l.islands[0],m=l.outputs.length===1&&l.outputs[0].island?l.outputs[0].island:u,d=m.first_frame,f=m.last_frame;return{outputs:l.outputs,first_frame:d,last_frame:f,frames:f-d+1,fps:o,facts:t,...d!==u.first_frame||f!==u.last_frame?{asked:{first_frame:u.first_frame,last_frame:u.last_frame}}:{}}}function Re(e){let t=[...G].map(o=>o.slice(1)).join("|");return e.toLowerCase().replace(new RegExp(`\\.(${t})(?=[._\\s-]|$)`,"g"),"").replace(/[^a-z0-9]/g,"")}function Ze(e,t){let o=Re(e),r=Re(t);if(r&&o.includes(r))return"name";let i=t.toLowerCase().split(/[^a-z0-9]+/).filter(n=>/\d/.test(n)&&n.length>=3);return i.length&&i.every(n=>o.includes(n))?"id":null}async function Hr(e,t,o){let r=[],i=0,n=null,s=Date.now()+o.time_limit_s*1e3,a=async(c,l)=>{try{for await(let u of v(c)){if(n&&!n.startsWith("folders"))return;if(++i>o.max_entries){n=`stopped after ${o.max_entries} entries (max_entries)`;return}if(Date.now()>s){n=`stopped after ${o.time_limit_s} s (time_limit_s)`;return}if(u.name.startsWith("."))continue;let m=_(c,u.name);if(u.isDirectory)l<o.max_depth?await a(m,l+1):n??=`folders deeper than max_depth=${o.max_depth} not searched (e.g. ${m})`;else if(u.isFile&&G.has(L(u.name).toLowerCase())){let d=Ze(u.name,t);d&&r.push({path:m,match:d,size:(await B(m).catch(()=>({size:0}))).size})}}}catch{}};if(await a(e,0),o.probe)for(let c=0;c<r.length;c+=8)await Promise.all(r.slice(c,c+8).map(async l=>{try{l.facts=await P(l.path)}catch(u){l.error=u.message}}));return r.sort((c,l)=>c.path.localeCompare(l.path)),{hits:r,scanned:i,truncated:n}}function Qe(e){let t=e.streams?.find(a=>a.kind==="video"),o=e.source_fps??t?.rate??null,r=e.available_range?.duration?.value??e.declared_duration?.value??null,i=t?.codec_specific??{},n=e.source_timecode&&o?J(e.source_timecode,o):null,s=n!=null&&r!=null&&o?C((n+r)%(Math.round(o)*86400),o,e.source_timecode.includes(";")):null;return`${t?`${t.codec??"?"}${i.profile?` ${i.profile}`:""} ${t.width??"?"}x${t.height??"?"}`:"no video"}${o?` @ ${Math.round(o*1e3)/1e3} fps`:""}; TC ${e.source_timecode??"none"}${s?`\u2013${s}`:""}; ${r??"?"} fr${r!=null&&o?` (${(r/o).toFixed(2)} s)`:""}`}function jr(e,t,o,r){let i=e.hits.slice(0,r),n=[];e.truncated&&n.push(`TRUNCATED: ${e.truncated} \u2014 the search did NOT cover all of ${t}; the matches below may be incomplete.`),e.hits.length>i.length&&n.push(`TRUNCATED: showing ${i.length} of ${e.hits.length} matches. Pass limit=${e.hits.length} or narrow the query.`),n.push(`${e.hits.length} file${e.hits.length===1?"":"s"} match "${o}" under ${t} (${e.scanned} entries scanned)`);let s=new Map;for(let c of e.hits)s.set(b(c.path).toLowerCase(),(s.get(b(c.path).toLowerCase())??0)+1);let a=[...s].filter(([,c])=>c>1);a.length&&n.push(`same name in several folders: ${a.map(([c,l])=>`${c} \xD7${l}`).join(", ")} \u2014 they can be DIFFERENT clips; match by TC + duration, never by name alone`);for(let c of i)n.push(`- ${c.path}${c.match==="id"?" (id match)":""}
|
|
9
|
+
${c.facts?Qe(c.facts):c.error?`probe failed: ${c.error}`:`${(c.size/1e6).toFixed(1)} MB`}`);return n.join(`
|
|
10
|
+
`)}async function Wr(e,t,o=0){let r=await P(e),i=r.source_fps??r.streams?.find(d=>d.kind==="video")?.rate??null,n=r.available_range?.duration?.value??r.declared_duration?.value??null;if(!i||n==null)throw new Error(`cannot check coverage: ${b(e)} has no frame rate or length`);let s=Math.round(i)*86400,a=r.source_timecode?J(r.source_timecode,i)??0:0,c=!!r.source_timecode?.includes(";"),l=d=>{let f=R(d,i,r.source_timecode??null);return typeof d=="number"||/^\d+$/.test(d.trim())?f:f<-s/2?f+s:f>s/2?f-s:f},u=d=>C(((a+d)%s+s)%s,i,c),m=t.map((d,f)=>{let p=l(d.in),h=l(d.out),g=p,w=n-h,x=g>=0&&w>=0&&h>p,U=Math.max(0,-g),k=Math.max(0,-w),S=[];return h<=p?S.push("out is not after in"):x?S.push(`covered; handles head ${g} / tail ${w} fr`):S.push(`NOT covered: short ${[U?`${U} fr at head`:"",k?`${k} fr at tail`:""].filter(Boolean).join(", ")}`),x&&o&&(g<o||w<o)&&S.push(`handles short of ${o}: ${[g<o?`head by ${o-g}`:"",w<o?`tail by ${o-w}`:""].filter(Boolean).join(", ")}`),{label:d.label??`range ${f+1}`,in_tc:u(p),out_tc:u(h),frames:h-p,covered:x,head:g,tail:w,short_head:U,short_tail:k,note:S.join("; ")}});return{facts:r,rows:m}}export{nr as a,De as b,Mr as c,xe as d,Ie as e,G as f,je as g,Y as h,We as i,kr as j,P as k,Le as l,Ir as m,Xe as n,Ge as o,Br as p,Re as q,Ze as r,Hr as s,Qe as t,jr as u,Wr as v};
|
|
@@ -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{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};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
|
|
3
|
+
import{V as ve,c as me}from"./chunk-5WEZRGXG.js";import{b as ke,f as xe}from"./chunk-NU3X7P4N.js";import{b as ce}from"./chunk-NAFLOZER.js";import{a as ae}from"./chunk-PHAMF4JF.js";function Q(e,n,t,i,s){let r=1-s;return r*r*r*e+3*r*r*s*n+3*r*s*s*t+s*s*s*i}function je(e,n,t){let i=0,s=1;for(let a=0;a<48;a++){let u=(i+s)/2;Q(n[0],n[1],n[2],n[3],u)<e?i=u:s=u}let r=(i+s)/2;return Q(t[0],t[1],t[2],t[3],r)}var le=e=>!!(e.sOutX||e.sOutY||e.sInX||e.sInY);function we(e){return e.some(n=>le(n)||n.interp==="bezier")}var $e=new WeakMap;function He(e,n){let t=$e.get(e);if(t&&t.to===n)return t;let i=e.x,s=e.y,r=n.x,a=n.y,u,f,m,l;le(e)||le(n)?(u=i+(e.sOutX??0),f=s+(e.sOutY??0),m=r+(n.sInX??0),l=a+(n.sInY??0)):(u=i+(r-i)/3,f=s+(a-s)/3,m=r-(r-i)/3,l=a-(a-s)/3);let p=[0],g=i,y=s;for(let h=1;h<=256;h++){let k=h/256,x=Q(i,u,m,r,k),w=Q(s,f,l,a,k);p.push(p[p.length-1]+Math.hypot(x-g,w-y)),g=x,y=w}let v={to:n,arc:p,ctrl:[i,u,m,r,s,f,l,a]};return $e.set(e,v),v}function Se(e,n,t){if(!e.length)return[0,0];let i=e[0],s=e[e.length-1];if(n<=i.time)return[i.x,i.y];if(n>=s.time)return[s.x,s.y];for(let r=0;r<e.length-1;r++){let a=e[r],u=e[r+1];if(!(n>=a.time&&n<u.time))continue;if(a.interp==="hold")return[a.x,a.y];let f=u.time-a.time;if(f<=0)return[u.x,u.y];let m=f/(t||24),{arc:l,ctrl:p}=He(a,u),g=l[l.length-1];if(!(g>1e-12))return[a.x,a.y];let y=m>0?g/m:0,v=a.interp==="bezier"&&a.outSpeed!=null?a.outSpeed:y,h=a.interp==="bezier"&&a.outInfluence!=null?a.outInfluence:1/3,k=u.interp==="bezier"&&u.inSpeed!=null?u.inSpeed:y,x=u.interp==="bezier"&&u.inInfluence!=null?u.inInfluence:1/3,w=1/6,A=(b,M)=>Math.abs(b-M)<1e-9,z=v===0&&A(h,1/3),B=k===0&&A(x,1/3);A(h,w)&&(v=y,h=B?.5:1/3),A(x,w)&&(k=y,x=z?.5:1/3);let j=(n-a.time)/(t||24),S=Math.min(Math.max(je(j,[0,h*m,m-x*m,m],[0,v*h*m,g-k*x*m,g]),0),g),I=1,Z=256;for(;I<Z;){let b=I+Z>>1;l[b]<S?I=b+1:Z=b}let X=l[I-1],c=l[I],_=c>X?(S-X)/(c-X):0,o=(I-1+_)/256;return[Q(p[0],p[1],p[2],p[3],o),Q(p[4],p[5],p[6],p[7],o)]}return[s.x,s.y]}function Me(e,n){if((n==="flip_horizontal"?e.flip_horizontal:e.flip_vertical)===!0)return!0;let i=e.effects;return Array.isArray(i)?i.some(s=>{let r=s;return r?.kind===n&&r.enabled!==!1}):!1}function L(e,n){return typeof e=="number"&&Number.isFinite(e)?e:Array.isArray(e)&&typeof e[n]=="number"?e[n]:null}function Ge(e,n,t,i,s){let r;Array.isArray(e.value)&&Array.isArray(n.value)?r=Math.hypot((L(n.value,0)??0)-(L(e.value,0)??0),(L(n.value,1)??0)-(L(e.value,1)??0)):r=(L(n.value,0)??0)-(L(e.value,0)??0);let a=i/t;if(r===0||!(s>0))return a;let u=k=>{let x=typeof k?.x=="number"?k.x:null,w=typeof k?.y=="number"?k.y:null;if(x===null||w===null)return null;let A=Math.min(Math.max(w,0),1)*t;return{dx:A,dy:x/s/r*A}},f=u(e.tout)??{dx:t/3,dy:t/3/t},m=u(n.tin)??{dx:t/3,dy:t/3/t},l=Math.min(Math.max(f.dx,0),t),p=f.dy,g=t-Math.min(Math.max(m.dx,0),t),y=1-m.dy,v=(k,x,w,A)=>{let z=1-A;return 3*k*A*z*z+3*x*A*A*z+w*A*A*A},h=a;for(let k=0;k<8;k++){let x=v(l,g,t,h)-i,w=1-h,A=3*(l*(w*w-2*h*w)+g*(2*h*w-h*h)+t*h*h);if(Math.abs(A)<1e-9)break;let z=h-x/A;if(!(z>=0&&z<=1))break;if(Math.abs(z-h)<1e-7){h=z;break}h=z}if(Math.abs(v(l,g,t,h)-i)>t*1e-4){let k=0,x=1;for(let w=0;w<40;w++)h=(k+x)/2,v(l,g,t,h)<i?k=h:x=h}return v(p,y,1,h)}function De(e,n,t,i=0,s=0){let a=(e.keyframes??[]).filter(m=>m.parameter_path===n&&typeof m.time?.value=="number").map(m=>({time:m.time.value,value:m.value,interp:m.interp??"linear",tin:m.tangent_in,tout:m.tangent_out,drt:!!m.raw_extraction?.drt_tangent})).sort((m,l)=>m.time-l.time);if(!a.length)return;let u=L(a[0].value,i)??0,f=L(a[a.length-1].value,i)??0;if(t<=a[0].time)return u;if(t>=a[a.length-1].time)return f;for(let m=0;m<a.length-1;m++){let l=a[m],p=a[m+1];if(t>=l.time&&t<=p.time){let g=L(l.value,i)??0,y=L(p.value,i)??0;if(l.interp==="hold")return g;let v=p.time-l.time||1,h=(l.tout||p.tin)&&!l.drt&&!p.drt?Ge(l,p,v,t-l.time,s):(t-l.time)/v;return g+(y-g)*h}}return f}function Ue(e){let n=e.keyframes??[];for(let t of n){if(t.parameter_path==="speed")continue;let i=t.time?.rate;if(typeof i=="number"&&i>0)return i}}function Te(e){let n=e.speed;return typeof n=="number"&&Number.isFinite(n)?Math.abs(n)/100:1}function Qe(e){let n=e,t=n.raw_extraction??void 0,i=f=>{let m=t?.[f];return typeof m=="number"&&Number.isFinite(m)?m:void 0};if(!(n.is_reinterpreted===!0||t?.isReinterpreted===!0))return 1;let r=n.original_fps??i("originalFps"),a=n.interpreted_fps??i("reinterpretedFps");if(r!=null&&a!=null&&r>0&&a>0)return a/r;let u=i("reinterpretationSpeedAdjustment");return u!=null&&u>0?u/100:1}function Ae(e,n){let i=(e.keyframes??[]).filter(a=>a.parameter_path==="speed"&&typeof a.time?.value=="number"&&typeof a.value=="number").map(a=>({x:a.time.value,y:a.value,tan:Array.isArray(a.raw_extraction?.drtNativeTangent)?a.raw_extraction.drtNativeTangent:null})).sort((a,u)=>a.x-u.x);if(i.length<2)return null;let s=(a,u)=>{let f=i[a].tan;if(f&&f.length>=4){if(u==="in"&&f[0])return f[1]/f[0];if(u==="out"&&f[2])return f[3]/f[2]}let m=u==="out"?Math.min(a+1,i.length-1):Math.max(a-1,0),l=Math.min(a,m),p=Math.max(a,m),g=i[p].x-i[l].x;return g>0?(i[p].y-i[l].y)/g:0},r=i.length-1;if(n<=i[0].x)return i[0].y+(n-i[0].x)*s(0,"out");if(n>=i[r].x)return i[r].y+(n-i[r].x)*s(r,"in");for(let a=0;a<r;a++){let u=i[a],f=i[a+1];if(n>f.x)continue;let m=f.x-u.x;if(m<=0)return f.y;let l=(n-u.x)/m,p=l*l,g=p*l,y=s(a,"out"),v=s(a+1,"in");return(2*g-3*p+1)*u.y+(g-2*p+l)*m*y+(-2*g+3*p)*f.y+(g-p)*m*v}return i[r].y}function We(e,n,t){let i=e.timeline_range?.start?.value??0,s=e.timeline_range?.start?.rate||t,r=(n-i)/s,a=e.source_range?.start,u=a&&typeof a.value=="number"&&a.rate?a.value/a.rate:0,f=Ae(e,r);if(f!=null)return(u+f)*t;let m=Te(e);if(e.speed_reverse){let l=e.source_range?.duration,p=l&&typeof l.value=="number"&&l.rate?Math.max(0,l.value-1)/l.rate:0;return(u+p-r*m)*t}return(u+r*m)*t}function Je(e,n){let t=e.timeline_range?.start,i=t?.value??0,s=t?.rate||24,r=e.source_range?.start,a=r?.value??0,u=r?.rate||s,f=Ae(e,(n-i)/s);if(f!=null)return a+f*u;let m=Te(e)*Qe(e),l=(n-i)*(u/s)*m;if(e.speed_reverse){let p=e.source_range?.duration?.value??0;return a+Math.max(0,p-1)-l}return a+l}function qe(e){let n=e.keyframes??[],t=[];for(let i of n){if(i.parameter_path!=="position"||typeof i.time?.value!="number")continue;let s=i.value,r=L(s,0),a=L(s,1);if(r==null||a==null)return null;let u=i.raw_extraction?.tangentPs??void 0,f=(m,l)=>{let p=m?.[l];return typeof p=="number"&&Number.isFinite(p)?p:void 0};t.push({time:i.time.value,x:r,y:a,interp:i.interp??"linear",outSpeed:i.tangent_out?.x??void 0,outInfluence:i.tangent_out?.y??void 0,inSpeed:i.tangent_in?.x??void 0,inInfluence:i.tangent_in?.y??void 0,sOutX:f(u,"spatialOutX"),sOutY:f(u,"spatialOutY"),sInX:f(u,"spatialInX"),sInY:f(u,"spatialInY")})}return t.length<2?null:(t.sort((i,s)=>i.time-s.time),we(t)?t:null)}function ze(e,n){let t=Ue(e)??e.timeline_range?.start?.rate??24,i=We(e,n,t),s=!1,r=(m,l=0)=>{let p=De(e,m,i,l,t);return p!==void 0&&(s=!0),p},a=m=>typeof m=="number"?m:null,u=qe(e);u&&(s=!0);let f=u?Se(u,i,t):null;return{scale:r("scale")??a(e.scale),scaleX:r("scale.x")??a(e.scale_x),scaleY:r("scale.y")??a(e.scale_y),posX:f?f[0]:r("position",0)??r("position.x")??a(e.position_x)??0,posY:f?f[1]:r("position",1)??r("position.y")??a(e.position_y)??0,rotation:r("rotation")??a(e.rotation)??0,anchorX:r("anchor",0)??r("anchor.x")??a(e.anchor_x)??0,anchorY:r("anchor",1)??r("anchor.y")??a(e.anchor_y)??0,opacity:r("opacity")??a(e.opacity),cropL:r("crop.left")??a(e.crop_left)??0,cropR:r("crop.right")??a(e.crop_right)??0,cropT:r("crop.top")??a(e.crop_top)??0,cropB:r("crop.bottom")??a(e.crop_bottom)??0,flipH:Me(e,"flip_horizontal"),flipV:Me(e,"flip_vertical"),animated:s}}function Ie(e,n){return Math.floor(Je(e,n)+1e-9)}var fe={strict:{tolerance_px:1,min_frames:1,gap_frames:0,black_threshold:16},standard:{tolerance_px:2,min_frames:2,gap_frames:1,black_threshold:10},relaxed:{tolerance_px:6,min_frames:4,gap_frames:3,black_threshold:6}},pe="strict",Re={tolerance_px:[0,512],min_frames:[1,600],gap_frames:[0,600],black_threshold:[0,255]};function Fe(e,n={}){let t=(e??pe).trim().toLowerCase(),i=fe[t]??fe[pe],s=fe[t]?t:t==="custom"?"custom":pe,r={...i};for(let a of Object.keys(Re)){let u=n[a];if(u===void 0||!Number.isFinite(Number(u)))continue;let[f,m]=Re[a],l=Math.max(f,Math.min(m,Math.round(Number(u))));l!==r[a]&&(s="custom"),r[a]=l}return{...r,preset:s}}function re(e,n){let t=Number(e),i=Number(n);return!Number.isFinite(t)||!Number.isFinite(i)?!1:t>0&&t>=i}function en(e,n,t){return!(e>0)||!(n>0)||!(t>0)?!1:Math.abs(n/t-e)/e>=.02}function nn(e,n,t,i,s){let r=Math.max(2,Number(s)||0);return Math.abs(e-n)<=r&&Math.abs(t-i)<=r}function rn(e,n,t,i,s,r){return!s||!(s.top>0||s.bottom>0||s.left>0||s.right>0)?!1:Math.abs(e-s.top)<=r&&Math.abs(n-s.bottom)<=r&&Math.abs(t-s.left)<=r&&Math.abs(i-s.right)<=r}var Oe=[["bt","ct"],["bb","cb"],["bl","cl"],["br","cr"]],se=e=>Math.max(0,Math.trunc(Number(e)||0)),ie=e=>Math.max(0,Math.min(1,Number(e)||0));function tn(e,n,t,i,s,r={}){let a=r.tolerance_px??4;i=Math.max(1,Math.trunc(i)),s=Math.max(1,Math.trunc(s));let u=[];for(let f of e??[]){let m=Math.trunc(Number(f.pts)||0),l=se(f.bt),p=se(f.bb),g=se(f.bl),y=se(f.br);if(!re(Math.max(l,p,g,y),a)||rn(l,p,g,y,r.declared_blanking,a))continue;let v=Number(r.expected_aspect_ratio)||0;if(v>0){let x=Math.max(1,i-g-y),w=Math.max(1,s-l-p),A=g<=a&&y<=a,z=l<=a&&p<=a;if((A||z)&&en(v,i,s)&&nn(l,p,g,y,a)&&Math.abs(x/w-v)/v<.02)continue}let h=t+m,k;for(let x of n??[])x.start<=h&&h<x.end&&(!k||x.track>k.track)&&(k=x);k&&u.push({frame_abs:h,bt:l,bb:p,bl:g,br:y,ct:ie(f.ct),cb:ie(f.cb),cl:ie(f.cl),cr:ie(f.cr),source:f.source??"pixels",clip:k})}return u.sort((f,m)=>f.frame_abs-m.frame_abs)}function an(e,n){let t=[];return re(e.bt,n)&&t.push("Top"),re(e.bb,n)&&t.push("Bottom"),re(e.bl,n)&&t.push("Left"),re(e.br,n)&&t.push("Right"),t}function Ce(e,n,t,i,s,r={}){let a=Math.max(1,Math.trunc(r.min_frames??1)),u=Math.max(0,Math.trunc(r.gap_frames??0)),f=r.tolerance_px??4,m=[],l;for(let p of tn(e,n,t,i,s,r)){(!l||l.clip!==p.clip||p.frame_abs-l.end_frame-1>u)&&(l={clip:p.clip,start_frame:p.frame_abs,end_frame:p.frame_abs,frame_count:0,measured:{bt:0,bb:0,bl:0,br:0},coverage:{ct:0,cb:0,cl:0,cr:0},sources:new Set},m.push(l)),l.end_frame=p.frame_abs,l.frame_count++,l.sources.add(p.source);for(let[g,y]of Oe)p[g]>=l.measured[g]&&(l.measured[g]=p[g],l.coverage[y]=p[y])}return m.filter(p=>p.frame_count>=a).map(p=>({...p,duration_frames:p.end_frame-p.start_frame+1,sources:[...p.sources].sort(),zones:an(p.measured,f)}))}function bn(e){let n=new Map;for(let i of e){let s=n.get(i.clip.id);s||(s={clip:i.clip,measured:{bt:0,bb:0,bl:0,br:0},coverage:{ct:0,cb:0,cl:0,cr:0},frames:0,first_frame_abs:i.start_frame,zones:[],sources:[],ranges:[]},n.set(i.clip.id,s)),s.frames+=i.frame_count,s.first_frame_abs=Math.min(s.first_frame_abs,i.start_frame);for(let[r,a]of Oe)i.measured[r]>=s.measured[r]&&(s.measured[r]=i.measured[r],s.coverage[a]=i.coverage[a]);s.sources=[...new Set([...s.sources,...i.sources])].sort(),s.ranges.push(i)}let t=["Top","Bottom","Left","Right"];return[...n.values()].map(i=>{let s=new Set(i.ranges.flatMap(r=>r.zones));return{...i,zones:t.filter(r=>s.has(r)),ranges:i.ranges.sort((r,a)=>r.start_frame-a.start_frame)}}).sort((i,s)=>i.clip.start-s.clip.start)}function _n(e,n=1){let t=Math.max(0,Math.trunc(n)),i=[];for(let s of[...e].sort((r,a)=>r.frame-a.frame)){let r=i.at(-1);if(r&&s.frame-r.end_frame<=t+1){r.end_frame=Math.max(r.end_frame,s.frame),r.frames++,r.darkest=Math.min(r.darkest,s.avg);continue}i.push({start_frame:s.frame,end_frame:s.frame,duration_frames:1,frames:1,darkest:s.avg})}for(let s of i)s.duration_frames=s.end_frame-s.start_frame+1;return i}function ge(e,n){let t=n?e.timelines.find(i=>i.id===n||i.name===n):e.timelines.find(i=>i.kind==="primary")??e.timelines[0];if(!t)throw new Error(n?`no timeline ${n} in this session`:"this session has no timeline");if(!t.resolution_w||!t.resolution_h)throw new Error(`${t.name}: the timeline has no raster (resolution) in the session`);return t}var sn=e=>e.fps_den?e.fps_num/e.fps_den:e.fps_num,W=(e,n)=>ke((e.start_frame??0)+n,sn(e),!!e.is_drop_frame),on=e=>e.split(/[\\/]/).pop()??e,te=e=>e.tracks.filter(n=>n.kind==="Video").sort((n,t)=>n.track_index-t.track_index),K=e=>{let n=e.timeline_range.start.value;return[n,n+e.timeline_range.duration.value]},oe=e=>e.items.filter(n=>n.kind==="clip");function ee(e,n){let t=e.media_references.find(u=>u.id===n.media_reference_id),i=t?.local_path??t?.target_url?.replace(/^file:\/\//,"")??null,s=t?.source_resolution_w??0,r=t?.source_resolution_h??0,a=t?.source_pixel_aspect||1;return{path:i,w:s*a,h:r}}var q=(e,n)=>ze(e,n),be=(e,n)=>Ie(e,n);function Ne(e,n,t,i){if(!(t>0&&i>0))return[e,n];let s=Math.min(e/t,n/i);return[t*s,i*s]}function Le(e,n,t){let i=n-e,s=Math.max(1,Math.min(t,i));return[...new Set(Array.from({length:s},(r,a)=>e+Math.min(i-1,Math.floor((a+.5)*i/s))))]}var un=["fit","fill","crop","stretch"];function Ze(e,n,t){if(t)return t;let i=e.reframe_fit??n.mismatch_policy??"fit";return i==="none"?"crop":un.includes(i)?i:"fit"}function Ve(e,n,t,i,s){if(!(e>0&&n>0)||s==="fit")return[1,1];let r=t/e,a=i/n,u=[r,r],f=[a,a],m=r<=a?u:f,l=s==="crop"?[1,1]:s==="fill"?r>a?u:f:[r,a];return[l[0]/m[0],l[1]/m[1]]}var J=(e,n)=>Math.round(e*10**n)/10**n||0;function _e(e,n,t,i=[1,1]){return{Pan:J(e.position_x*n/i[0],3),Tilt:J(-e.position_y*t/i[1],3),ZoomX:J(e.scale_x/100/i[0],5),ZoomY:J(e.scale_y/100/i[1],5),RotationAngle:J(-e.rotation,3),FlipX:e.flip_h,FlipY:e.flip_v}}var Ke=e=>({scale_x:e.scaleX??e.scale??100,scale_y:e.scaleY??e.scale??100,position_x:e.posX,position_y:e.posY,rotation:e.rotation,flip_h:e.flipH,flip_v:e.flipV}),Ee=e=>(e.scale??100)===100&&(e.scaleX??100)===100&&(e.scaleY??100)===100&&!e.posX&&!e.posY&&!e.rotation&&!e.cropL&&!e.cropR&&!e.cropT&&!e.cropB&&!e.flipH&&!e.flipV,Sn=["edit","input","node"];function Be(e){let n=e.node,t=typeof n=="object"&&n?n:{layer:e.layer??1,node:n};return{...t.node!==void 0&&t.node!==""?{node:t.node}:{},...t.layer&&t.layer!==1?{layer:t.layer}:{}}}var cn={aligned:"Green",animated:"Yellow",no_match:"Red",refused:"Red"};async function mn(e,n){let t=n.offline_reference,i=me(n),s=i,r=Math.max(...n.tracks.flatMap(h=>h.items.map(k=>k.timeline_range.start.value+k.timeline_range.duration.value)),0),a=h=>({kind:"Video",track_index:Math.max(0,...te(n).map(k=>k.track_index))+1,name:"OFFLINE REFERENCE",enabled:!0,items:h});if(t?.session_id){let{getSession:h}=await import("./store-7IOEBOZY.js"),k=(await h(t.session_id)).session,x=k.timelines.find(S=>S.kind==="primary")??k.timelines[0],w=(n.start_frame??0)+(t.frame_offset??0)-(x.start_frame??0),A=te(x).filter(S=>S.enabled!==!1).flatMap(S=>S.items.filter(I=>I.kind==="clip"&&I.enabled!==!1&&I.media_reference_id).map(I=>({i:I,top:S.track_index}))),z=[...new Set(A.flatMap(({i:S})=>[S.timeline_range.start.value,S.timeline_range.start.value+S.timeline_range.duration.value]))].sort((S,I)=>S-I),B=[];for(let S=0;S+1<z.length;S++){let[I,Z]=[z[S],z[S+1]],X=A.filter(({i:R})=>R.timeline_range.start.value<=I&&I<R.timeline_range.start.value+R.timeline_range.duration.value).sort((R,O)=>O.top-R.top)[0],[c,_]=[Math.max(0,I-w),Math.min(r,Z-w)];if(!X||_<=c)continue;let o=X.i,b=B.at(-1);if(b&&b.from===o.id&&b.timeline_range.start.value+b.timeline_range.duration.value===c){b.timeline_range.duration.value+=_-c,b.source_range.duration.value+=_-c;continue}let{id:M,timeline_range:$,source_range:d,media_reference_id:C,keyframes:E,...T}=o;B.push({...T,id:`offline-ref-${B.length}`,from:o.id,kind:"clip",enabled:!0,media_reference_id:`offref:${C}`,timeline_range:{start:{value:c,rate:s},duration:{value:_-c,rate:s}},source_range:{start:{value:d.start.value+(c+w-o.timeline_range.start.value),rate:d.start.rate},duration:{value:_-c,rate:d.start.rate}}})}if(!B.length)throw new ae("not_found",`the offline reference timeline "${x.name}" has no picture over this timeline`);let j=new Set(B.map(S=>String(S.media_reference_id).slice(7)));return{lane:a(B),media:k.media_references.filter(S=>j.has(S.id)).map(S=>({...S,id:`offref:${S.id}`})),name:`timeline ${x.name}`}}let u=t?.media_reference_id?e.media_references.find(h=>h.id===t.media_reference_id):void 0,f=u?.local_path??u?.target_url?.replace(/^file:\/\//,"");if(!u||!f)throw new ae("not_found","this timeline has no offline reference linked in Resolve (Timeline \u203A Link Offline Reference Clip): a movie or another timeline");let{probeMedia:m}=await import("./media-NZYVREUF.js"),l=await m(f),p=l.source_timecode?xe(l.source_timecode,i,null):0,g=l.available_range?.duration?.value??l.declared_duration?.value??null,y=(n.start_frame??0)+(t.frame_offset??0)-p;g!=null&&(y>=g||y+r<=0)&&(y=t.frame_offset??0);let v=g!=null?Math.max(1,Math.min(r,g-y)):r;return{lane:a([{id:"offline-reference",kind:"clip",name:u.name??"offline reference",enabled:!0,media_reference_id:u.id,timeline_range:{start:{value:0,rate:s},duration:{value:v,rate:s}},source_range:{start:{value:y,rate:s},duration:{value:v,rate:s}}}]),media:[],name:u.name??on(f)}}async function Mn(e,n,t,i){if(n.reference_track!=="offline")return await Pe(e,n,t,i);let s=ge(e,n.timeline_id),{lane:r,media:a,name:u}=await mn(e,s);s.tracks.push(r),e.media_references.push(...a);try{return{...await Pe(e,{...n,reference_track:te(s).length,reference_label:"the offline reference"},t,i),reference:`the offline reference (${u})`}}finally{s.tracks.splice(s.tracks.indexOf(r),1),e.media_references=e.media_references.filter(f=>!a.includes(f))}}async function Pe(e,n,t,i){let s=ge(e,n.timeline_id),r=s.resolution_w,a=s.resolution_h,u=te(s),f=u.findIndex(c=>/\b(ref|reference|offline)\b/i.test(String(c.name??""))),m=n.reference_track||(f>=0?f+1:u.length),l=u[m-1];if(!l)throw new Error(`no video track V${m} (the timeline has ${u.length})`);if(n.tracks?.includes(m))throw new ae("invalid_args",`the track to align cannot be the reference track (V${m})`);let p=(n.tracks?.length?n.tracks:u.map((c,_)=>_+1)).filter(c=>c!==m);for(let c of p)if(!u[c-1])throw new Error(`no video track V${c} (the timeline has ${u.length})`);let g=n.input_scaling??"fit",y=n.sizing_target??"edit",v=600,h=(c,_)=>{let o=Math.max(1,_-c);if(n.samples==="ends")return[...new Set([0,.25,.5,.75,1].map($=>c+Math.round($*(Math.max(c,_-1)-c))))];let b=(n.samples??"half")==="half"&&!n.step?Math.max(1,Math.round(me(s)/2)):n.step,M=n.samples==="all"?Math.max(1,Math.ceil(o/v)):b?Math.max(1,Math.floor(b),Math.ceil(o/v)):0;if(M){let $=[];for(let d=c;d<_;d+=M)$.push(d);return $.at(-1)!==_-1&&$.push(_-1),$}return Le(c,_,Math.max(1,Math.min(v,Math.floor(Number(n.samples))||1)))},k=Number(s.start_frame??0),x=[],w=[],A=oe(l),z=n.scope??"all",B=new Set(n.picks??[]);if(z==="selected"&&!B.size)throw new Error("no clips selected: select clips in the timeline, or align the whole timeline");for(let c of p)for(let _ of oe(u[c-1])){let[o,b]=K(_);if(z==="playhead"&&!(o<=(n.at??-1)&&(n.at??-1)<b)||z==="selected"&&!B.has(`${c}:${o}`))continue;let M={item_id:_.id,name:_.name??_.id,track:c,start:o,end:b,record_tc:W(s,o),verdict:"refused",confidence:null,samples:[]};x.push(M);let $=N=>{M.reason=N};if(_.enabled===!1){$("disabled");continue}let d,C=0,E=0;for(let N of A){let[Y,D]=K(N),P=Math.max(o,Y),F=Math.min(b,D);F-P>E-C&&(d=N,C=P,E=F)}if(!d){if(n.reference_label){$(`${n.reference_label} does not cover it (${W(s,o)}\u2013${W(s,b)}): it ends before this clip`);continue}let N=l.items.find(Y=>{let[D,P]=K(Y);return Y.kind!=="clip"&&Y.kind!=="gap"&&Math.min(b,P)>Math.max(o,D)});$(N?`V${m} has ${/compound|stack|timeline/i.test(String(N.kind))?"a compound clip or nested timeline":`a ${N.kind}`} over it, not a movie clip: Align reads a media file there (decompose it, or use Offline ref)`:A.length?`nothing on V${m} over it (${W(s,o)}\u2013${W(s,b)}): the reference does not cover this clip`:`V${m} has no movie clips: pick the track the reference is on, or Offline ref`);continue}let T=ee(e,d),R=ee(e,_);if(!T.path){$(`the reference clip ${d.name??d.id} is not linked (timeline_relink first)`);continue}if(!R.path){$("not linked (timeline_relink first)");continue}let O=h(C,E);if(O.some(N=>!Ee(q(d,N)))){$(`the reference clip ${d.name??d.id} is itself resized; the fit is against its raw picture`);continue}if(T.w>0&&T.h>0&&Math.abs(T.w/T.h-r/a)>.01*(r/a)){$(`the reference ${T.w}x${T.h} does not fill the ${r}x${a} frame`);continue}let ne=N=>N.map(Y=>({ref:T.path,refFrame:be(d,Y),src:R.path,srcFrame:be(_,Y)})),G=Array.from({length:E-C},(N,Y)=>C+Y),H=q(_,o);w.push({row:M,item:_,recs:O,every:G,ask:{pairs:ne(O),every:ne(G),every_t:G.map(N=>N-o),edit:Ke(H),edit_identity:Ee(H),edit_animated:!!H.animated,anchor_off:!!(H.anchorX||H.anchorY),...n.inputs?.get(`${c}:${o+k}`)?.length?{input:n.inputs.get(`${c}:${o+k}`)}:{}}})}let j=w.length?await ce({op:"reframe",items:w.map(c=>c.ask),out:[r,a],target:y},t,i):{items:[],offsets:[]},S=j.offsets;j.items.forEach((c,_)=>{let{row:o,item:b,recs:M,every:$,ask:d}=w[_],C=c.measured==="every"?$:M,E=c.measured==="every"?d.every:d.pairs,T=(({w:R,h:O})=>Ve(R,O,r,a,Ze(b,s,n.input_scaling)))(ee(e,b));o.samples=c.scores.map((R,O)=>({record:C[c.at[O]],ref_frame:E[c.at[O]].refFrame,src_frame:E[c.at[O]].srcFrame,score:R})),Object.assign(o,{verdict:c.verdict,confidence:c.confidence,...c.reason?{reason:c.reason}:{},...c.label?{label:c.label}:{},...c.unchanged?{unchanged:!0}:{},...c.grade_sizing?{grade_sizing:c.grade_sizing}:{}}),c.transform&&(o.transform=c.transform,o.properties=_e(c.edit_transform??c.transform,r,a,T)),c.keys?.length&&(o.keys=c.keys.map(R=>({record:C[c.at[R.j]],transform:R.transform,properties:_e(R.transform,r,a,T),confidence:R.confidence}))),c.grade_keys?.length&&(o.grade_keys=c.grade_keys.map(({shape:R,...O})=>R?.kind==="resolve_dissolve"?{...O,ease_in:R.start,ease_out:R.end}:O),o.grade_keys[0].t>0&&o.grade_keys.unshift({...o.grade_keys[0],t:0,ease_in:void 0,ease_out:void 0})),c.edit_keys?.length&&(o.edit_keys=c.edit_keys[0].t>0?[{...c.edit_keys[0],t:0,shape:void 0},...c.edit_keys]:c.edit_keys)});let I=[];for(let c of x){let _={track:c.track,start:c.start};if(c.verdict==="aligned"&&y==="edit"&&!c.unchanged){let o=c.properties;I.push({op:"properties",item:_,set:{...o.ZoomX!==o.ZoomY?{ZoomGang:!1}:{},...o}})}if(c.verdict==="animated"&&c.edit_keys&&I.push({op:"edit_keys",item:_,keys:c.edit_keys}),c.verdict==="animated"&&c.grade_keys&&I.push({op:"grade_sizing",item:_,target:y==="node"?"node":"input",keys:c.grade_keys,...y==="node"?Be(n):{}}),c.verdict==="aligned"&&c.grade_sizing&&!c.unchanged&&I.push({op:"grade_sizing",item:_,target:y,...c.grade_sizing,...y==="node"?Be(n):{}}),n.markers??!0){let o={aligned:"Aligned",animated:"Animated",no_match:"No match",refused:"Not aligned"}[c.verdict],b=[c.label,c.confidence!=null?`confidence ${c.confidence}`:"",c.reason].filter(Boolean).join(" \xB7 ");I.push({op:"marker_add",frame:c.start,color:cn[c.verdict],name:`${o}: ${c.name}`,note:b,data:"ConformTools:align"})}}let Z;if(n.apply_session){Z=0;for(let c of x.filter(_=>_.verdict==="aligned")){let _=c.transform;ve(e,"transform",{timeline_id:s.id,item_id:c.item_id,scale:_.scale_x,position_x:_.position_x,position_y:_.position_y,rotation:_.rotation});let o=s.tracks.flatMap(b=>b.items).find(b=>b.id===c.item_id);Math.abs(_.scale_x-_.scale_y)>.001&&(o.scale_x=_.scale_x,o.scale_y=_.scale_y),_.flip_h?o.flip_horizontal=!0:delete o.flip_horizontal,_.flip_v?o.flip_vertical=!0:delete o.flip_vertical,Z++}}let X={aligned:0,animated:0,no_match:0,refused:0};for(let c of x)X[c.verdict]++;return{timeline:s.name??s.id,raster:[r,a],reference_track:m,rows:x,counts:X,ops:I,...Z!=null?{applied:Z}:{},input_scaling:g,sizing_target:y,...S.length?{offsets:S}:{}}}function Tn(e){let n=e.counts,t=`${e.timeline} (${e.raster.join("x")}): ${n.aligned} aligned, ${n.animated} animated, ${n.no_match} no match, ${n.refused} not aligned \u2014 against ${e.reference??`V${e.reference_track}`}${e.input_scaling!=="fit"?` (Resolve units for input scaling "${e.input_scaling}")`:""}${e.sizing_target!=="edit"?`; written as Color-page ${e.sizing_target==="input"?"Input Sizing":"node Sizing"} on top of each clip's own edit transform`:""}${e.sizing_target==="edit"&&n.animated?`; the ${n.animated} moving clip(s) get Edit-page keyframes on a copy of the timeline, "${e.timeline} ALIGNED" (Resolve cannot keyframe the Edit page from a script; the copy carries every grade and setting)`:""}${e.applied!=null?`; ${e.applied} transform(s) written into the session`:""}`,i=r=>{let a=r.properties,u=r.grade_sizing,f=u?` \u2192 ${e.sizing_target} sizing Zoom ${u.zoom}${u.height!==1?` Height ${u.height}`:""} Pan ${u.pan} Tilt ${u.tilt} Rotate ${u.rotation}${u.flip_x?" FlipH":""}${u.flip_y?" FlipV":""}`:a?` \u2192 Pan ${a.Pan} Tilt ${a.Tilt} Zoom ${a.ZoomX}${a.ZoomY!==a.ZoomX?`/${a.ZoomY}`:""} Rot ${a.RotationAngle}${a.FlipX?" FlipX":""}${a.FlipY?" FlipY":""}`:"",m=r.grade_keys?.length?` \u2192 ${r.grade_keys.length} keyframes (${e.sizing_target==="node"?"node":"Input"} Sizing)`:r.edit_keys?.length?` \u2192 ${r.edit_keys.length} Edit-page keyframes`:"";return` V${r.track} ${r.record_tc} ${r.name}: ${r.verdict.toUpperCase()}${r.label?` (${r.label})`:""}${f}${m}${r.confidence!=null?`, confidence ${r.confidence}`:""}${r.reason?` \u2014 ${r.reason}`:""}`},s=(e.offsets??[]).map(r=>` the reference differs from the ${r.raster} online by ${r.label} on ${r.clips} of ${r.of} clips: a render / decode difference, not sizing \u2014 taken out of every clip, never written`);return[t,...s,...e.rows.map(i),`host_apply ops ready: ${e.ops.filter(r=>r.op==="properties"||r.op==="grade_sizing").length} ${e.sizing_target==="edit"?"properties":"grade_sizing"}, ${e.ops.filter(r=>r.op==="marker_add").length} markers (data "ConformTools:align")`].join(`
|
|
4
|
+
`)}var de={"16:9":16/9,"1.85":1.85,"2.00":2,"2.20":2.2,"2.35":2.35,"2.39":2.39,"2.76":2.76,"4:3":4/3,"1:1":1,"9:16":9/16,none:null};function ln(e){if(e==null)return null;if(typeof e=="number")return e>0?e:null;if(e in de)return de[e];let n=/^(\d+(?:\.\d+)?)(?:[:/](\d+(?:\.\d+)?))?$/.exec(e.trim());if(!n)throw new Error(`aspect '${e}': one of ${Object.keys(de).join(", ")}, or a ratio like 1.66 or 3:2`);let t=n[2]?Number(n[1])/Number(n[2]):Number(n[1]);return t>0?t:null}function Xe(e,n,t){let i=[],s=e;for(let[r,a]of t)if(!(a<=s)&&(r>=n||(r>s&&i.push([s,Math.min(r,n)]),s=Math.max(s,a),s>=n)))break;return s<n&&i.push([s,n]),i}function Ye(e,n,t){let i=[...e,[n,t]].sort((r,a)=>r[0]-a[0]),s=[];for(let r of i){let a=s.at(-1);a&&r[0]<=a[1]?a[1]=Math.max(a[1],r[1]):s.push([r[0],r[1]])}return s}async function An(e,n,t,i){let s=ge(e,n.timeline_id),r=s.resolution_w,a=s.resolution_h,u=ln(n.aspect),f=Fe(n.strictness),m=!!n.pixels,l=Math.max(1,Math.min(12,Math.floor(n.samples??3))),p=te(s),g=p.filter(o=>o.enabled!==!1),y=[],v=[],h=o=>{let b=ee(e,o);if(!(b.w>0&&b.h>0))return!1;let[M,$]=Ne(r,a,b.w,b.h),d=q(o,K(o)[0]);return!d.animated&&Math.abs(M-r)<.5&&Math.abs($-a)<.5&&(d.scaleX??d.scale??100)===100&&(d.scaleY??d.scale??100)===100&&!d.posX&&!d.posY&&!d.rotation&&!d.cropL&&!d.cropR&&!d.cropT&&!d.cropB},k=new Map,x=[];for(let o of g)k.set(o,x),x=oe(o).filter(b=>b.enabled!==!1&&h(b)).reduce((b,M)=>Ye(b,...K(M)),x);let w=[];for(let o of[...g].reverse()){let b=oe(o).filter(d=>d.enabled!==!1),M=b.reduce((d,C)=>Ye(d,...K(C)),w),$=p.indexOf(o)+1;for(let d of b){let[C,E]=K(d),T=k.get(o)??[],R=Xe(C,E,w).flatMap(([P,F])=>Xe(P,F,T));if(!R.length)continue;let O=ee(e,d);if(!(O.w>0&&O.h>0)){y.push({item_id:d.id,name:d.name??d.id,track:$,reason:"the source raster is unknown (timeline_relink the clip first)"});continue}m&&!O.path&&y.push({item_id:d.id,name:d.name??d.id,track:$,reason:"not linked: its source frames were not measured (timeline_relink first); its transform was checked"});let[ne,G]=Ne(r,a,O.w,O.h),H=q(d,C).animated,N=P=>{let F=q(d,P);return{box:[ne,G],scale:[(F.scaleX??F.scale??100)/100,(F.scaleY??F.scale??100)/100],pos:[F.posX*ne,F.posY*G],rot:F.rotation,anchor:[F.anchorX,F.anchorY],crop:[F.cropL/100,F.cropR/100,F.cropT/100,F.cropB/100],flip:[F.flipH,F.flipV]}},Y=[],D=new Map;for(let[P,F]of R){let ue=new Set(m&&O.path?Le(P,F,l):[]),he=new Set(H?Array.from({length:F-P},(V,U)=>P+U):ue.size?[]:[P]);for(let V of ue)he.add(V);let ye=[...he].sort((V,U)=>V-U);ye.forEach((V,U)=>{D.set(V,[U?V:P,ye[U+1]??F]),Y.push({rec:V,place:N(V),...ue.has(V)?{src:be(d,V)}:{}})})}v.push({item:d,track:$,path:O.path,frames:Y,hold:D,animated:H})}w=M}let A=v.length?await ce({op:"blanking",items:v.map(o=>({path:o.path,frames:o.frames})),out:[r,a],aspect:u},t,i):{items:[],target:[0,0,r,a]},z=A.target,B=[],j=new Map,S=0;A.items.forEach((o,b)=>{let M=v[b],$=new Map;j.set(M.item.id,$);for(let d of o){if(d.bars&&S++,d.black||!d.edges.some(T=>T>0))continue;let[C,E]=M.hold.get(d.rec);for(let T=C;T<E;T++)B.push({pts:T,bt:d.edges[0],bb:d.edges[1],bl:d.edges[2],br:d.edges[3],source:d.bars?"pixels":"geometry"}),$.set(T,d.zoom)}});let I=v.map(o=>({id:o.item.id,name:o.item.name??o.item.id,start:K(o.item)[0],end:K(o.item)[1],track:o.track})),X=Ce(B,I,0,Math.round(z[2]-z[0]),Math.round(z[3]-z[1]),{tolerance_px:f.tolerance_px,min_frames:f.min_frames,gap_frames:f.gap_frames}).map(o=>{let b=1,M=j.get(o.clip.id);for(let $=o.start_frame;$<=o.end_frame;$++){if(!M.has($))continue;let d=M.get($);b=d==null||b==null?null:Math.max(b,d)}return{item_id:o.clip.id,name:o.clip.name,track:o.clip.track,record_start:o.start_frame,record_end:o.end_frame,record_tc:W(s,o.start_frame),frames:o.duration_frames,edges:{top:o.measured.bt,bottom:o.measured.bb,left:o.measured.bl,right:o.measured.br},zones:o.zones,sources:o.sources,zoom_fix:b}}),c=[],_=new Map;for(let o of X)_.set(o.item_id,[..._.get(o.item_id)??[],o]);for(let[o,b]of _){let M=v.find(T=>T.item.id===o);if(M.animated||b.some(T=>T.zoom_fix==null))continue;let $=Math.max(...b.map(T=>T.zoom_fix)),d=ee(e,M.item),C=_e(Ke(q(M.item,K(M.item)[0])),r,a,Ve(d.w,d.h,r,a,Ze(M.item,s,n.input_scaling))),E=T=>Math.ceil(T*$*1e5)/1e5;c.push({op:"properties",item:{track:M.track,start:K(M.item)[0]},set:{ZoomX:E(C.ZoomX),ZoomY:E(C.ZoomY)}})}if(n.markers??!0)for(let o of X){let b=v.find(d=>d.item.id===o.item_id),M=o.zones.map(d=>`${d} ${o.edges[d.toLowerCase()]} px`).join(" \xB7 "),$=b.animated?"keyframed sizing: fix the keys":o.zoom_fix==null?"no zoom about its anchor fills it":`zoom \xD7${o.zoom_fix} fills it`;c.push({op:"marker_add",frame:o.record_start,duration:o.frames,color:"Red",name:`Blanking: ${o.name}`,note:`${M} (${o.sources.join("+")}) \u2014 ${$}`,data:"ConformTools:blanking"})}return{timeline:s.name??s.id,raster:[r,a],aspect:u,target:z,strictness:f,pixels:m,clips_checked:v.length,frames_measured:S,findings:X,refused:y,ops:c}}function zn(e){return[`${e.findings.length?`BLANKING: ${e.findings.length} range(s) on ${new Set(e.findings.map(t=>t.item_id)).size} clip(s)`:"CLEAN: no clip shows black"} \u2014 ${e.timeline} ${e.raster.join("x")}${e.aspect?`, delivered ${J(e.aspect,3)}:1 (black counted inside it only)`:""}; ${e.strictness.preset} (${e.strictness.tolerance_px} px, ${e.strictness.min_frames} frame(s)); ${e.clips_checked} clip(s) by their transform${e.pixels?`, ${e.frames_measured} source frame(s) measured for their own black edges`:" (pixels:false: a black edge baked into a source is not seen)"}`,...e.findings.map(t=>` V${t.track} ${t.record_tc} ${t.name} (${t.frames} frame${t.frames>1?"s":""}): ${t.zones.map(i=>`${i} ${t.edges[i.toLowerCase()]} px`).join(", ")} [${t.sources.join("+")}]${t.zoom_fix?` \u2014 zoom \xD7${t.zoom_fix} fills it`:" \u2014 no zoom about its anchor fills it"}`),...e.refused.map(t=>` V${t.track} ${t.name}: ${t.reason}`),`host_apply ops ready: ${e.ops.filter(t=>t.op==="properties").length} ZoomX/ZoomY fixes, ${e.ops.filter(t=>t.op==="marker_add").length} markers (data "ConformTools:blanking")`].join(`
|
|
5
|
+
`)}export{fe as a,Fe as b,Ce as c,bn as d,_n as e,un as f,Ze as g,Ve as h,_e as i,Sn as j,mn as k,Mn as l,Tn as m,de as n,ln as o,An as p,zn as q};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
|
|
3
|
+
import{B as k,L as h,Y as c,a as m,k as w,l as $,r as i,v as b,x as v,y as R}from"./chunk-PLRB2YXJ.js";import"./chunk-PSANHDZM.js";var y="conformtools-statusline";function x(e,n){let s=e.statusLine;return s&&!String(s.command??"").includes(y)?{settings:e,result:"kept"}:s?.command===n?{settings:e,result:"updated"}:{settings:{...e,statusLine:{type:"command",command:n,padding:0}},result:s?"updated":"installed"}}async function P(){let e=new URL(import.meta.url),n=m(new URL("./statusline.js",e));if(await i(n)){await R(w());let t=c(w(),`${y}.js`);return await k(n,t),`node "${t}"`}let s=m(new URL("../adapters/statusline.ts",e));return await i(s)?`deno run --allow-read --allow-env --no-check "${s}" ${y}`:null}function L(e,n){let s=e.permissions&&typeof e.permissions=="object"?e.permissions:{},t=Array.isArray(s.allow)?s.allow.filter(o=>typeof o=="string"):[];return t.includes(n)?{settings:e,added:!1}:{settings:{...e,permissions:{...s,allow:[...t,n]}},added:!0}}async function U(e={}){let n=e.server??"conformtools",s=`mcp__${n}`,t=e.settingsPath??c($(),".claude","settings.json"),o={};if(await i(t)){let a=await b(t);try{o=a.trim()?JSON.parse(a):{}}catch(r){throw new Error(`${t} is not valid JSON (${r instanceof Error?r.message:r}); fix it first, nothing was changed`)}}let p=L(o,s),d=p.settings,l="skipped",C=p.added,S=e.statusline===!1?null:await P();if(S){let a=x(d,S);d=a.settings,l=a.result}let f;(C||l==="installed"||l==="updated"&&d!==p.settings)&&(await i(t)?(f=`${t}.conformtools-backup`,await k(t,f)):await Deno.mkdir(c(t,".."),{recursive:!0}),await v(t,JSON.stringify(d,null,2)+`
|
|
4
|
+
`));let u="skipped",g;if(e.register!==!1)try{if((await h("claude",["mcp","get",n])).code===0)u="already";else{let r=await h("claude",["mcp","add","-s","user",n,"--","npx","-y","conformtools@latest","mcp"]);u=r.code===0?"added":"failed",r.code!==0&&(g=r.stderr.trim().slice(-300))}}catch(a){u="failed",g=`claude CLI not found (${a instanceof Error?a.message:a}); add the server with: claude mcp add -s user ${n} -- npx -y conformtools@latest mcp`}return{settings:t,rule:s,added:C,backup:f,registered:u,detail:g,statusline:l}}function M(e){return[e.added?`Claude Code: allowed every conform.tools tool (${e.rule}) in ${e.settings}${e.backup?` (backup: ${e.backup})`:""}`:`Claude Code: ${e.rule} was already allowed in ${e.settings}`,{already:"MCP server: already registered",added:"MCP server: registered (claude mcp add -s user)",skipped:"MCP server: not checked",failed:`MCP server: not registered: ${e.detail??"claude mcp add failed"}`}[e.registered],{installed:"Status line: conform.tools (the running job and its progress) at the bottom of Claude Code",updated:"Status line: conform.tools, refreshed",kept:"Status line: you already have one, so it was left as it is (conformtools statusline prints ours)",skipped:"Status line: not installed"}[e.statusline],"Restart Claude Code (or /mcp) to load it. Remove the rule from permissions.allow to be asked again."].join(`
|
|
5
|
+
`)}export{U as setupClaude,M as setupText,L as withAllowRule,x as withStatusLine};
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
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-55BKURYP.js";import"./chunk-S5JDS5PQ.js";import"./chunk-XLEINKFL.js";import"./chunk-EUBXH67N.js";import"./chunk-SNTAZJ5A.js";import"./chunk-TXQR2HI2.js";import{J as L}from"./chunk-5WEZRGXG.js";import{a as A}from"./chunk-P2LL3JMC.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-SKFMOLUO.js";import{h as D,i as I}from"./chunk-NAFLOZER.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
|
+
`)+`
|
|
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,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
|
+
`);return i.write(m(0,`${u("v")}${t.version} ${u("\xB7 built by post pros")}`,X.map(o=>u(o)))),i.write(`
|
|
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
|
+
|
|
10
|
+
login / whoami / logout sign in with your conform.tools Google account
|
|
11
|
+
telemetry on|off|status outcome telemetry (on by default, content-free; see the README, Feedback and privacy)
|
|
12
|
+
mcp run as an MCP server (stdio) for Claude Code, Cursor, Codex\u2026
|
|
13
|
+
http run the local HTTP API on 127.0.0.1:7791
|
|
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(`
|
|
15
|
+
(on conform.tools) = the timeline is read or written by conform.tools; the file and its media stay here`),s(0)}var h=st[a]??a,it=V(h);it||(console.error(`unknown verb '${a}' \u2014 conformtools --list`),s(2));h==="account_login"&&console.error("opening the browser to sign in to conform.tools\u2026");var ct=h==="account_telemetry"&&v&&!v.trim().startsWith("{")?JSON.stringify({action:v.trim()}):v,Q;try{Q=JSON.parse(ct??"{}")}catch{console.error(`arguments must be JSON, e.g. conformtools ${a} '{"path":"\u2026"}'`),s(2)}var j=F(h,Q),b=j.ok?await H(h,j.data):j.result;h==="account_login"&&!b.isError&&!q&&await z()||console.log(q?JSON.stringify(b.structuredContent??{ok:!b.isError,text:b.content.map(t=>t.text).join(`
|
|
16
|
+
`)},null,1):b.content.map(t=>t.text).join(`
|
|
17
|
+
`));await J();s(b.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};
|
|
Binary file
|
|
Binary file
|
|
@@ -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}from"./chunk-J2JXLEAI.js";import"./chunk-RJ6JA2LZ.js";import"./chunk-PSANHDZM.js";export{b as decodeCr3Wasm,a 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,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};
|
|
@@ -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}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};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
|
|
3
|
+
import"./chunk-PSANHDZM.js";function S(){let e=window.__CONFORM_ENGINE__;if(e?.base)return e;let t=new URLSearchParams(window.location.search),r=l=>{try{return sessionStorage.getItem(`conform.engine.${l}`)}catch{return null}},i=(l,c)=>{try{sessionStorage.setItem(`conform.engine.${l}`,c)}catch{}},n=t.get("engine"),o=t.get("token");return n?i("url",n):n=r("url"),o?i("token",o):o=r("token"),{base:n?/^\d+$/.test(n)?`http://127.0.0.1:${n}`:n.replace(/\/$/,""):"http://127.0.0.1:7791",token:o??""}}var g=typeof window>"u"?{base:"http://127.0.0.1:7791",token:""}:S(),f=(e=!0)=>({...e?{"content-type":"application/json"}:{},...g.token?{authorization:`Bearer ${g.token}`}:{}}),y=class extends Error{constructor(r,i){super(i);this.code=r}};async function s(e,t,r,i=[]){let n;try{n=await fetch(`${g.base}${t}`,{method:e,headers:f(),body:r===void 0?void 0:JSON.stringify(r)})}catch{throw new y("engine_down",`the conform.tools engine is not running at ${g.base}`)}let o=await n.json().catch(()=>({}));if(!n.ok&&!("text"in o)&&!i.includes(n.status))throw new y(o.code??String(n.status),o.message??`HTTP ${n.status}`);return o}async function _(e,t,r,i){let n;try{n=await fetch(`${g.base}${e}`,{...t,headers:f(),signal:i})}catch{i?.aborted||r({type:"error",code:"engine_down",message:`the conform.tools engine is not running at ${g.base}`});return}if(!n.ok||!n.body){let c=await n.json().catch(()=>({}));r({type:"error",code:c.code??String(n.status),message:c.message??`HTTP ${n.status}`});return}let o=n.body.getReader(),b=new TextDecoder,l="";for(;;){let{value:c,done:h}=await o.read();if(h)break;l+=b.decode(c,{stream:!0});let u;for(;(u=l.indexOf(`
|
|
4
|
+
|
|
5
|
+
`))>=0;){let m=l.slice(0,u);l=l.slice(u+2),m.startsWith("data: ")&&r(JSON.parse(m.slice(6)))}}}var w=new Set,k=null;function P(){if(k)return;let e=k=new AbortController;(async()=>{for(;!e.signal.aborted;)await _("/app/events",{method:"GET"},t=>{for(let r of w)r(t)},e.signal).catch(()=>{}),e.signal.aborted||await new Promise(t=>setTimeout(t,2e3))})()}var j={base:g.base,health:()=>s("GET","/health"),verb:(e,t={})=>s("POST",`/verbs/${e}`,t),job:e=>s("GET",`/jobs/${e}`),cancelJob:e=>s("DELETE",`/jobs/${e}`),front:e=>s("POST","/app/front",e),account:()=>s("GET","/app/account"),projects:()=>s("GET","/app/projects"),createProject:e=>s("POST","/app/projects",e),project:e=>s("GET",`/app/projects/${e}`),attachSession:(e,t)=>s("PUT",`/app/projects/${e}/sessions`,{session_id:t}),saveContext:(e,t,r)=>s("PUT",`/app/projects/${e}/context`,{text:t,base:r},[409]),frame:async(e,t,r,i,n,o,b)=>{let l=new URLSearchParams({f:String(t),w:String(r),...n?{timeline:n}:{},...o?{track:String(o)}:{},...b?{grade:"resolve",...b.host_timeline?{host_timeline:b.host_timeline}:{}}:{}}),c=await fetch(`${g.base}/app/sessions/${e}/frame?${l}`,{headers:f(!1),signal:i}).catch(()=>null);if(!c?.ok)return null;if(c.headers.get("content-type")!=="application/x-conform-pixels")return createImageBitmap(await c.blob()).catch(()=>null);let h=new Uint8Array(await c.arrayBuffer()),u=new DataView(h.buffer),m=u.getUint32(0,!0),v=u.getUint32(4,!0),T=u.getUint32(8,!0)===1,p=new Uint8ClampedArray(h.buffer,12,m*v*4);for(let d=0;d<p.length;d+=4){if(T){let R=p[d];p[d]=p[d+2],p[d+2]=R}p[d+3]=255}return createImageBitmap(new ImageData(p,m,v)).catch(()=>null)},tools:()=>s("POST","/verbs/tool",{action:"list"}).then(e=>e.tools??[]),blocks:()=>s("POST","/verbs/tool",{action:"blocks"}).then(e=>e.blocks??[]),saveTool:e=>s("POST","/verbs/tool",{action:"save",spec:e},[422]),deleteTool:e=>s("POST","/verbs/tool",{action:"delete",id:e},[422]),toolLayout:()=>s("POST","/verbs/tool",{action:"layout"}).then(e=>e.layout),arrangeTools:e=>s("POST","/verbs/tool",{action:"arrange",layout:e}).then(t=>t.layout),hideTool:(e,t)=>s("POST","/verbs/tool",{action:t?"hide":"show_tool",id:e}).then(r=>r.layout),workspace:e=>s("POST","/verbs/tool",{action:"workspace",project_id:e}).then(t=>t.workspace),saveWorkspace:(e,t)=>s("POST","/verbs/tool",{action:"workspace_save",project_id:e,workspace:t},[422]),exportTools:(e,t)=>s("POST","/verbs/tool",{action:"export",ids:e,path:t},[422]),importTools:e=>s("POST","/verbs/tool",{action:"import",path:e},[422]),hostSetup:(e,t="status")=>s("POST","/verbs/host_setup",{host:e,action:t},[422]),convert:async(e,t)=>{let r=new URLSearchParams({name:e.fileName,out:t,targets:JSON.stringify(e.targets.map(({target:n,ext:o})=>({target:n,ext:o}))),sequences:JSON.stringify(e.sequences)}),i=await fetch(`${g.base}/app/convert?${r}`,{method:"POST",headers:{...f(!1),"content-type":"application/octet-stream"},body:e.bytes});return await i.json().catch(()=>({ok:!1,error:`the engine said ${i.status}`}))},canonicalize:async(e,t=[],r=[])=>{let i=new URLSearchParams({name:e.name,sequences:JSON.stringify(t),previous:JSON.stringify(r)}),n=await fetch(`${g.base}/app/canonicalize?${i}`,{method:"POST",headers:{...f(!1),"content-type":"application/octet-stream"},body:await e.arrayBuffer()}),o=await n.json().catch(()=>({ok:!1,error:`the engine said ${n.status}`}));if(!o.ok)throw new Error(o.error??o.message??`the engine said ${n.status}`);return o},policy:()=>s("GET","/app/policy"),session:e=>s("GET",`/app/sessions/${e}`),onEvent:e=>(w.add(e),P(),()=>{w.delete(e),w.size||(k?.abort(),k=null)}),runs:(e,t)=>s("POST","/verbs/tool_run",{action:"list",project_id:e,...t?{id:t}:{}}).then(r=>r.runs??[])};async function x(e,t){let r=await fetch(`${g.base}/app/fs`,{method:"POST",headers:f(),body:JSON.stringify({op:e,...t})});if(e==="readFile"){if(!r.ok)throw Object.assign(new Error(`could not read ${String(t.path)}`),{name:"NotReadableError"});let n=await r.arrayBuffer();return{result:{byteLength:n.byteLength},bytes:n}}let i=await r.json().catch(()=>({ok:!1}));if(!i.ok)throw Object.assign(new Error(i.message??`the engine said ${r.status}`),{name:"NotFoundError"});return{result:i.result}}var a=()=>typeof window<"u"?window.__TAURI__:void 0,$={available:()=>!!a()?.core?.invoke,licenseStatus:()=>a().core.invoke("license_status"),fingerprint:()=>a().core.invoke("machine_fingerprint"),version:()=>a().app.getVersion(),installUpdate:()=>a().core.invoke("install_update"),importLicense:async()=>{let e=await a().dialog.open({multiple:!1,filters:[{name:"conform.tools licence",extensions:["lic","json"]}]});return typeof e=="string"?a().core.invoke("import_license",{path:e}):null},pickFolder:async()=>{let e=await a().dialog.open({directory:!0,multiple:!1});return typeof e=="string"?e:null},pickFiles:async()=>{let e=await a().dialog.open({directory:!1,multiple:!0});return Array.isArray(e)?e:typeof e=="string"?[e]:[]},pickFile:async()=>{let e=await a().dialog.open({directory:!1,multiple:!1});return typeof e=="string"?e:null},saveFile:async e=>{try{let t=await a().dialog.save({defaultPath:e,filters:[{name:"Recipe",extensions:["json"]}]});return typeof t=="string"?t:null}catch{let t=await a().dialog.open({directory:!0,multiple:!1});return typeof t=="string"?`${t.replace(/[\\/]$/,"")}/${e}`:null}}};export{y as EngineError,j as engine,x as engineFs,$ as shell};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
|
|
3
|
+
import{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,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,10 @@
|
|
|
1
|
+
"""CONFORM.TOOLS host plugin for Autodesk Flame.
|
|
2
|
+
|
|
3
|
+
`verbs.FlamePeer` answers the host-bridge capability verbs from Flame's Python
|
|
4
|
+
API; `hook.Controller` owns the bridge connection, the menu and the
|
|
5
|
+
preferences. `conformtools_flame_hook.py` (installed into a Flame Python hook
|
|
6
|
+
folder) is the only file Flame scans; it puts `conformtools_flame.zip` (this
|
|
7
|
+
package + the vendored `ctpeer` kit) on `sys.path` and forwards the hooks.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__version__ = "0.2.0"
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"""Timelines INTO Flame: `timeline_write.import_file` (decision D7's file
|
|
2
|
+
route - Flame gets ONE engine-written file, never a clip-by-clip build).
|
|
3
|
+
|
|
4
|
+
The app writes the timeline as FCPXML (`hosts/remote.py` NATIVE_FORMAT) with
|
|
5
|
+
the website's production engine, then asks this hook to import it:
|
|
6
|
+
|
|
7
|
+
1. `flame.import_clips(path, reel)` - Stefan's conform pipeline imports
|
|
8
|
+
AAF / FCPXML / OTIO this way (oracle/synth/runtime/flame/conform_pipeline.py).
|
|
9
|
+
The destination is a DESKTOP reel ("CONFORM.TOOLS" reel group, "Timelines"
|
|
10
|
+
reel): library sequences are locked for editing (his render oracle), and
|
|
11
|
+
the next step edits.
|
|
12
|
+
2. RELINK. An imported timeline's segments arrive UNLINKED (born offline,
|
|
13
|
+
source times relative to the media start). For every segment whose file is
|
|
14
|
+
on disk, the media is imported ONCE per path ("Sources" reel) and the
|
|
15
|
+
segment is pointed at it with `smart_replace_media` - in place first,
|
|
16
|
+
`duplicate_source()` + retry only on refusal - then SLIPPED so its source
|
|
17
|
+
in lands where the file says: `smart_replace_media` may re-seat the source
|
|
18
|
+
at the media's start timecode or keep the old offset (both measured by
|
|
19
|
+
Stefan, 2026-07-12/13), so the slip is computed from the state AFTER the
|
|
20
|
+
replace: wanted = clip start TC + relative in (or the in itself when it is
|
|
21
|
+
already a timecode frame inside the clip), `slip(-(wanted - got))`.
|
|
22
|
+
That is his `_relink_one`, the technique his oracle renders real pixels
|
|
23
|
+
with. A segment that will not relink is reported, never fatal.
|
|
24
|
+
3. A long relink must not hold Flame (or the 30 s call): segments past
|
|
25
|
+
`RELINK_BUDGET_S` continue in later idle events, `RELINK_CHUNK` at a time,
|
|
26
|
+
and the answer says how many are still pending.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
from __future__ import annotations
|
|
30
|
+
|
|
31
|
+
import os
|
|
32
|
+
import time
|
|
33
|
+
from typing import Any, Dict, List, Optional, Tuple
|
|
34
|
+
|
|
35
|
+
from ctpeer import PeerError
|
|
36
|
+
|
|
37
|
+
from .util import _s, _v
|
|
38
|
+
|
|
39
|
+
#: Timeline files Flame's `import_clips` reads.
|
|
40
|
+
IMPORTABLE = (".fcpxml", ".xml", ".aaf", ".edl", ".otio")
|
|
41
|
+
REEL_GROUP = "CONFORM.TOOLS"
|
|
42
|
+
TIMELINES_REEL = "Timelines"
|
|
43
|
+
SOURCES_REEL = "Sources"
|
|
44
|
+
#: Seconds of relinking inside the import call; the rest goes on idle events.
|
|
45
|
+
RELINK_BUDGET_S = 10.0
|
|
46
|
+
RELINK_CHUNK = 8
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class BuildVerbs:
|
|
50
|
+
"""Mixed into `verbs.FlamePeer`."""
|
|
51
|
+
|
|
52
|
+
# ── where imports land ──────────────────────────────────────────────
|
|
53
|
+
def _ct_reel(self, name: str) -> Any:
|
|
54
|
+
"""The desktop reel `REEL_GROUP / name`, made when missing."""
|
|
55
|
+
desktop = getattr(self._workspace(), "desktop", None)
|
|
56
|
+
if desktop is None:
|
|
57
|
+
raise PeerError("no_project", "No desktop in this workspace")
|
|
58
|
+
group = None
|
|
59
|
+
for rg in getattr(desktop, "reel_groups", None) or []:
|
|
60
|
+
if _s(getattr(rg, "name", "")) == REEL_GROUP:
|
|
61
|
+
group = rg
|
|
62
|
+
break
|
|
63
|
+
if group is None:
|
|
64
|
+
group = desktop.create_reel_group(REEL_GROUP)
|
|
65
|
+
for reel in getattr(group, "reels", None) or []:
|
|
66
|
+
if _s(getattr(reel, "name", "")) == name:
|
|
67
|
+
return reel
|
|
68
|
+
return group.create_reel(name)
|
|
69
|
+
|
|
70
|
+
# ── relink (Stefan's _relink_one) ───────────────────────────────────
|
|
71
|
+
def _tc_frame(self, t: Any, fps: float) -> int:
|
|
72
|
+
return self._abs(t, fps)
|
|
73
|
+
|
|
74
|
+
def _relink_segment(self, seg: Any, clips: Dict[str, Any], sources: Any) -> Optional[str]:
|
|
75
|
+
"""Point one unlinked segment at its file. None on success, else why not."""
|
|
76
|
+
path = _s(getattr(seg, "file_path", ""))
|
|
77
|
+
if not path or not os.path.exists(path):
|
|
78
|
+
return f"{_s(getattr(seg, 'name', '')) or '?'}: no file at {path or '(none)'}"
|
|
79
|
+
fps = self._rate_of(seg)
|
|
80
|
+
pre_in = self._tc_frame(getattr(seg, "source_in", None), fps)
|
|
81
|
+
clip = clips.get(path)
|
|
82
|
+
if clip is None:
|
|
83
|
+
got = self.flame.import_clips(path, sources) or []
|
|
84
|
+
clip = got[0] if got else None
|
|
85
|
+
if clip is None:
|
|
86
|
+
return f"{os.path.basename(path)}: Flame could not import the media"
|
|
87
|
+
clips[path] = clip
|
|
88
|
+
try:
|
|
89
|
+
seg.smart_replace_media(clip)
|
|
90
|
+
except Exception:
|
|
91
|
+
try:
|
|
92
|
+
seg.duplicate_source()
|
|
93
|
+
seg.smart_replace_media(clip)
|
|
94
|
+
except Exception as e:
|
|
95
|
+
return f"{os.path.basename(path)}: Flame refused the relink ({e})"
|
|
96
|
+
clip_tc = self._tc_frame(getattr(clip, "start_time", None), fps)
|
|
97
|
+
length = self._count(getattr(clip, "duration", None), fps)
|
|
98
|
+
post_in = self._tc_frame(getattr(seg, "source_in", None), fps)
|
|
99
|
+
inside = clip_tc <= pre_in < clip_tc + max(1, length)
|
|
100
|
+
wanted = pre_in if (clip_tc and inside) else clip_tc + pre_in
|
|
101
|
+
delta = wanted - post_in
|
|
102
|
+
if delta:
|
|
103
|
+
try:
|
|
104
|
+
seg.slip(-delta)
|
|
105
|
+
except Exception as e:
|
|
106
|
+
return f"{os.path.basename(path)}: relinked, but the source could not be slipped {delta} frame(s) ({e})"
|
|
107
|
+
return None
|
|
108
|
+
|
|
109
|
+
def _rate_of(self, seg: Any) -> float:
|
|
110
|
+
from .util import parse_rate
|
|
111
|
+
|
|
112
|
+
rate = _s(getattr(seg, "source_frame_rate", ""))
|
|
113
|
+
return parse_rate(rate)[0] if rate else 24.0
|
|
114
|
+
|
|
115
|
+
def _unlinked_segments(self, seq: Any) -> List[Any]:
|
|
116
|
+
out = []
|
|
117
|
+
for track in self._video_tracks(seq) + self._audio_tracks(seq):
|
|
118
|
+
for seg in self._track_segments(track):
|
|
119
|
+
unlinked = _v(getattr(seg, "source_unlinked", None))
|
|
120
|
+
if unlinked is None or bool(unlinked):
|
|
121
|
+
out.append(seg)
|
|
122
|
+
return out
|
|
123
|
+
|
|
124
|
+
def _relink_some(self, todo: List[Any], clips: Dict[str, Any], sources: Any, issues: List[str],
|
|
125
|
+
budget_s: Optional[float]) -> Tuple[int, List[Any]]:
|
|
126
|
+
done, t0 = 0, time.monotonic()
|
|
127
|
+
while todo:
|
|
128
|
+
if budget_s is not None and time.monotonic() - t0 > budget_s:
|
|
129
|
+
break
|
|
130
|
+
seg = todo.pop(0)
|
|
131
|
+
why = self._relink_segment(seg, clips, sources)
|
|
132
|
+
if why:
|
|
133
|
+
issues.append(why)
|
|
134
|
+
else:
|
|
135
|
+
done += 1
|
|
136
|
+
return done, todo
|
|
137
|
+
|
|
138
|
+
def _relink_later(self, todo: List[Any], clips: Dict[str, Any], sources: Any, label: str) -> None:
|
|
139
|
+
"""Continue a relink on idle events, a chunk at a time."""
|
|
140
|
+
state = {"done": 0, "issues": []}
|
|
141
|
+
|
|
142
|
+
def step() -> None:
|
|
143
|
+
chunk, rest = todo[:RELINK_CHUNK], todo[RELINK_CHUNK:]
|
|
144
|
+
done, _ = self._relink_some(chunk, clips, sources, state["issues"], None)
|
|
145
|
+
state["done"] += done
|
|
146
|
+
todo[:] = rest
|
|
147
|
+
if todo:
|
|
148
|
+
self.flame.schedule_idle_event(step)
|
|
149
|
+
else:
|
|
150
|
+
msg = f"{label}: relinked {state['done']} more segment(s)"
|
|
151
|
+
if state["issues"]:
|
|
152
|
+
msg += f", {len(state['issues'])} could not be relinked"
|
|
153
|
+
log = getattr(self, "_log_console", None)
|
|
154
|
+
if callable(log):
|
|
155
|
+
log(msg)
|
|
156
|
+
|
|
157
|
+
self.flame.schedule_idle_event(step)
|
|
158
|
+
|
|
159
|
+
# ── the capability ──────────────────────────────────────────────────
|
|
160
|
+
def v_timeline_write__import_file(self, project: Any = None, path: str = "", sequences: Any = None) -> Dict[str, Any]:
|
|
161
|
+
path = str(path or "")
|
|
162
|
+
ext = os.path.splitext(path)[1].lower()
|
|
163
|
+
if ext not in IMPORTABLE:
|
|
164
|
+
raise PeerError("unsupported_format", f"Flame imports FCPXML, XML, AAF, EDL and OTIO timelines, not {ext or 'this file'}")
|
|
165
|
+
if not os.path.isfile(path):
|
|
166
|
+
raise PeerError("not_found", f"no file at {path}")
|
|
167
|
+
reel = self._ct_reel(TIMELINES_REEL)
|
|
168
|
+
imported = [o for o in (self.flame.import_clips(path, reel) or []) if self._is_sequence(o)]
|
|
169
|
+
self._invalidate_pool()
|
|
170
|
+
if not imported:
|
|
171
|
+
return {"ok": False, "imported": [], "issues": [f"Flame imported no sequence from {os.path.basename(path)}"]}
|
|
172
|
+
issues: List[str] = []
|
|
173
|
+
sources = None
|
|
174
|
+
clips: Dict[str, Any] = {}
|
|
175
|
+
relinked = pending = 0
|
|
176
|
+
for seq in imported:
|
|
177
|
+
todo = self._unlinked_segments(seq)
|
|
178
|
+
if not todo:
|
|
179
|
+
continue
|
|
180
|
+
if sources is None:
|
|
181
|
+
sources = self._ct_reel(SOURCES_REEL)
|
|
182
|
+
done, rest = self._relink_some(todo, clips, sources, issues, RELINK_BUDGET_S)
|
|
183
|
+
relinked += done
|
|
184
|
+
if rest:
|
|
185
|
+
pending += len(rest)
|
|
186
|
+
self._relink_later(rest, clips, sources, _s(getattr(seq, "name", "")))
|
|
187
|
+
if pending:
|
|
188
|
+
issues.append(f"{pending} segment(s) are still relinking in Flame (watch the message bar)")
|
|
189
|
+
self._invalidate_pool()
|
|
190
|
+
return {"ok": True, "imported": [{"name": _s(getattr(s, "name", "")), "handle": self._wrap("seq", s)} for s in imported],
|
|
191
|
+
"issues": issues, "relinked": relinked, "relink_pending": pending}
|