conformtools 0.6.9 → 0.6.11
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 +53 -22
- package/dist/account-IUWNSDG5.js +3 -0
- package/dist/analysis-engine-M7W32RRC.js +3 -0
- package/dist/bridge-SV7PCLQY.js +3 -0
- package/dist/browser/timeline_core_bg.wasm +0 -0
- package/dist/{chunk-TXQR2HI2.js → chunk-2CY2OOOJ.js} +1 -1
- package/dist/chunk-2QT5MMBP.js +499 -0
- package/dist/chunk-2WBGXD27.js +8 -0
- package/dist/chunk-5YULBQJX.js +3 -0
- package/dist/chunk-5YWO2LBG.js +3 -0
- package/dist/chunk-64X5DLH5.js +6 -0
- package/dist/{chunk-GM6QKY7W.js → chunk-6HZP2OJA.js} +1 -1
- package/dist/chunk-6NLB5TZ2.js +7 -0
- package/dist/chunk-6VP6G7CY.js +10 -0
- package/dist/{chunk-3D3Z4TBR.js → chunk-DGXZB7MO.js} +1 -1
- package/dist/chunk-DPA26AOI.js +3 -0
- package/dist/{chunk-A7FNR3T5.js → chunk-EEDLRRKU.js} +1 -1
- package/dist/chunk-G3SZDPDS.js +3 -0
- package/dist/chunk-IK6RKNS5.js +3 -0
- package/dist/chunk-IN6XVTUS.js +3 -0
- package/dist/{chunk-D4WPRRBT.js → chunk-ISKNIQVO.js} +1 -1
- package/dist/chunk-JKOB3U54.js +3 -0
- package/dist/{chunk-2BPR6LK6.js → chunk-JXTRQ3UG.js} +1 -1
- package/dist/chunk-LVGGCRDW.js +3 -0
- package/dist/chunk-N34DQ6MH.js +14 -0
- package/dist/chunk-NSQP6CTA.js +20 -0
- package/dist/chunk-QTFFVLVJ.js +8 -0
- package/dist/chunk-RKIRHMON.js +5 -0
- package/dist/chunk-ROPKSAFP.js +6 -0
- package/dist/{chunk-GTJ3EM6H.js → chunk-S6KP52OG.js} +1 -1
- package/dist/chunk-THVX57I3.js +4 -0
- package/dist/chunk-VE423Z2L.js +132 -0
- package/dist/chunk-WJ5EWXP2.js +3 -0
- package/dist/chunk-XDI6CPPV.js +3 -0
- package/dist/chunk-XF3YMBI7.js +3 -0
- package/dist/chunk-XIAG7ACN.js +7 -0
- package/dist/chunk-YU3SUSK3.js +3 -0
- package/dist/chunk-YUO3UWPH.js +3 -0
- package/dist/claude-setup-REU4AOKX.js +13 -0
- package/dist/cli.js +8 -8
- package/dist/{cr3-wasm-HLJWEV2S.js → cr3-wasm-NYCB34ND.js} +1 -1
- package/dist/{dng-wasm-CQDLPM5V.js → dng-wasm-XCPPBXPZ.js} +1 -1
- package/dist/{dpx-wasm-TLGMM7BO.js → dpx-wasm-XACWNFPB.js} +1 -1
- package/dist/emscripten-module-Q67P5WYC-HW3D2R5O.js +2161 -0
- package/dist/engine-274GQLUB.js +5 -0
- package/dist/{exr-wasm-2NPKPTVB.js → exr-wasm-FQBUR6QT.js} +1 -1
- package/dist/ffi-7KTOX2T4.js +3 -0
- package/dist/flame/hook/conformtools_flame/verbs.py +9 -9
- package/dist/framing-ZTMYZR2S.js +3 -0
- package/dist/gfx-worker.js +1 -1
- package/dist/{h264-JJMZSUWW.js → h264-B2TLLEMI.js} +1 -1
- package/dist/{h264-mxf-DCUOGLDU.js → h264-mxf-3GED5PBT.js} +1 -1
- package/dist/host-relink-FHNXXMHW.js +10 -0
- package/dist/hosted-BWAYLJXR.js +3 -0
- package/dist/hosts-Y6HGDRLM.js +3 -0
- package/dist/http.js +3 -3
- package/dist/{inspect-FJKYPEXL.js → inspect-RJFJQSHZ.js} +3 -3
- package/dist/{isobmff-VJOWP4MH.js → isobmff-C5A2EFKH.js} +1 -1
- package/dist/{mc-video-5MGGOQN4.js → mc-video-ARKIHPA7.js} +1 -1
- package/dist/mcp.js +7 -7
- package/dist/{media-NZYVREUF.js → media-22VAJIVT.js} +1 -1
- package/dist/media_core-XOKN7UUF.js +9 -0
- package/dist/module-ES6BEMUI-L6VQ7K3J.js +3 -0
- package/dist/module-asyncify-2EFITU5U-Z4EEM6X7.js +3 -0
- package/dist/mxf-CQSI6H5T.js +3 -0
- package/dist/nuke/panel/python/conformtools_nuke/verbs.py +5 -5
- package/dist/{ops-X7NAREC4.js → ops-BCTGDBXT.js} +1 -1
- package/dist/peer-kit/ctpeer/__init__.py +1 -1
- package/dist/peer-kit/ctpeer/neutral.py +10 -10
- package/dist/premiere-uxp/lib/edit.js +94 -9
- package/dist/premiere-uxp/lib/markers.js +12 -11
- package/dist/premiere-uxp/lib/probe.js +6 -3
- package/dist/premiere-uxp/lib/verbs.js +1 -1
- package/dist/premiere-uxp/manifest.json +1 -1
- package/dist/{probe-F7WQHMIA.js → probe-72QZKMCC.js} +1 -1
- package/dist/{r3d-T5O6IIZZ.js → r3d-FX7V4BIE.js} +1 -1
- package/dist/{r3d-CXUNG6VS.js → r3d-I6EYEYX7.js} +1 -1
- package/dist/resolve-bridge.py +725 -88
- package/dist/sequence-patch-CN4VC5W3.js +3 -0
- package/dist/{still-P4JJNTEO.js → still-WUCFH2WX.js} +1 -1
- package/dist/{still-wasm-DN5LPASS.js → still-wasm-RTPOMH7S.js} +1 -1
- package/dist/store-H676BOKI.js +3 -0
- package/dist/{tiff-wasm-BPRDR6EB.js → tiff-wasm-N2S267IA.js} +1 -1
- package/dist/timeline-5TGA5HBY.js +3 -0
- package/dist/timeline_core-ZKQQHUA2.js +3 -0
- package/dist/wasm/media_core_bg.wasm +0 -0
- package/dist/wasm-threads/media_core_bg.wasm +0 -0
- package/dist/{wav-64SC6P7U.js → wav-HSCUCY4U.js} +1 -1
- package/package.json +10 -1
- package/dist/account-M53GEV7P.js +0 -3
- package/dist/bridge-SX5TW4LC.js +0 -3
- package/dist/chunk-5BSXYKLN.js +0 -20
- package/dist/chunk-623EA3TK.js +0 -6
- package/dist/chunk-AMRJXYL4.js +0 -3
- package/dist/chunk-DQGINJDV.js +0 -5
- package/dist/chunk-GK4YYKJ6.js +0 -19
- package/dist/chunk-GRQJGEGV.js +0 -378
- package/dist/chunk-HNBA43BF.js +0 -5
- package/dist/chunk-J2JXLEAI.js +0 -3
- package/dist/chunk-MWDF2R26.js +0 -7
- package/dist/chunk-NFJHWZJX.js +0 -3
- package/dist/chunk-PFISREY4.js +0 -3
- package/dist/chunk-PLRB2YXJ.js +0 -3
- package/dist/chunk-QVH44I66.js +0 -39
- package/dist/chunk-RJ6JA2LZ.js +0 -3
- package/dist/chunk-SGLQY53R.js +0 -3
- package/dist/chunk-VIBEEWPC.js +0 -10
- package/dist/chunk-WN53ARHJ.js +0 -3
- package/dist/chunk-XCKQHL4G.js +0 -9
- package/dist/claude-setup-IIWUB4CE.js +0 -5
- package/dist/conformtools-analyze +0 -0
- package/dist/conformtools-decode +0 -0
- package/dist/engine-P6H5P6HP.js +0 -5
- package/dist/framing-3XIVHSUZ.js +0 -3
- package/dist/host-relink-UWML4C7W.js +0 -10
- package/dist/hosts-SRS5TEM6.js +0 -3
- package/dist/i2o-transfer +0 -0
- package/dist/media_core-YZ3PABEG.js +0 -9
- package/dist/mxf-FJSRFLJC.js +0 -3
- package/dist/store-53BBZBND.js +0 -3
- package/dist/timeline-C3OZJBCZ.js +0 -3
- package/dist/timeline_core-IOENXK4Z.js +0 -3
|
@@ -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{Ia as r,X as s,o}from"./chunk-DPA26AOI.js";async function d(t){await r();let e=s(t);return e==="null"?null:JSON.parse(e)}async function l(t){await r();let e;try{e=o(t)}catch{return null}if(e.length<8)return null;let n=new DataView(e.buffer,e.byteOffset,e.byteLength),a=n.getUint32(0,!0),i=n.getUint32(4,!0),u=a*i*4;return e.length<8+u?null:{width:a,height:i,rgba:new Uint8ClampedArray(e.subarray(8,8+u))}}export{d as a,l as b};
|
|
@@ -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{Da as d,Ia as l}from"./chunk-DPA26AOI.js";var u=[{codec:"prores",label:"Apple ProRes",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"preview tier is DC-only 1/8 COLOR (2026-08-05 \u2014 was gray luma; Y+Cb+Cr DC walks, no AC/IDCT) \u2014 the realtime tier for BOTH playback and scrub: full 4K XQ decode is ~170ms/frame + a 35MB RGBA hand-off, which can hold neither 24fps nor a smooth scrub; the parked frame upgrades to full via the standard 160ms park timer (scrubPreview flipped true 2026-08-05 with the color preview \u2014 the old 'full decode is scrub-fast' held for 2K 422, not 4K XQ). Both wrappers: .mov (sample table) and MXF OP1a (RDD 44, 2026-07-28 \u2014 is_prores_mxf routes the identical icpf bitstream through the walker via decode_prores_mxf; Suite ap4h fixture gated byte-exact vs ffmpeg 10-bit, rust tests/prores_mxf_gate.rs)"},{codec:"prores_raw",label:"Apple ProRes RAW",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"preview tier is a TRUE DC-only Bayer decode: the DC-DPCM segment is a strict prefix of each tile component's bitstream, so the preview reads just those prefixes (no AC walk, no IDCT), lands the exact closed-form value the full IDCT produces, and runs the SAME develop on the 1/8 grid (tier_parity gate). Decode = Apple's own reconstruction (RE'd from AppleProResRAWCodec.bundle 2026-10-22): bit-exact vs VideoToolbox's software decode on iPhone 17 Pro / Sony a7S III / Panasonic; the ffmpeg 8.0 byte-exact path remains as decode_bayer. Develop = the ProRes RAW SDK as DaVinci Resolve runs it (kernels transcribed from its Metal AIR, parameters RE'd from Resolve and captured live): noise-gated edge-directed demosaic, mired-interpolated per-CCT WB + forward matrix from the moov (iPhone; header color otherwise), Apple Log / Apple Wide Gamut output matching a Resolve 21 render to f32 rounding (97.9% of 10-bit codes identical end to end; the rest is Resolve's hardware-decode LSB noise). Viewer tiers render ACEScct log (2026-07-26 \u2014 no baked Rec.709/sRGB; the transcode-grade log form); decode_prores_raw_tier takes the clip's container color."},{codec:"h264",label:"H.264 / AVC",full:!0,preview:!0,luma:!1,scrubPreview:!0,backend:"webcodecs",notes:"scrub = nearest-keyframe snap (1 decode); exact frame on park; FALLBACK (2026-10-27): where WebCodecs is absent or refuses the config (Firefox + HEVC, Chrome without HEVC hardware, most 4:2:2 10-bit), and for containers the TS players cannot walk (MKV/WebM, raw Annex-B, fragmented MP4), the identify chain labels the clip 'h264_wasm' and media-core's own decoder answers through the mcvideo lane (wasm video_open/video_decode \u2014 rust video::lane, gated byte-exact vs ffmpeg in tests/h264_mov_gate.rs / hevc_gate.rs / annexb_gate.rs); WebCodecs stays first"},{codec:"hevc",label:"HEVC / H.265",full:!0,preview:!0,luma:!1,scrubPreview:!0,backend:"webcodecs",notes:"scrub = nearest-keyframe snap (1 decode); exact frame on park; FALLBACK (2026-10-27): where WebCodecs is absent or refuses the config (Firefox + HEVC, Chrome without HEVC hardware, most 4:2:2 10-bit), and for containers the TS players cannot walk (MKV/WebM, raw Annex-B, fragmented MP4), the identify chain labels the clip 'hevc_wasm' and media-core's own decoder answers through the mcvideo lane (wasm video_open/video_decode \u2014 rust video::lane, gated byte-exact vs ffmpeg in tests/h264_mov_gate.rs / hevc_gate.rs / annexb_gate.rs); WebCodecs stays first"},{codec:"xavc",label:"Sony XAVC-Intra",full:!0,preview:!1,luma:!1,scrubPreview:!1,backend:"webcodecs",notes:"all-intra; already scrub-fast"},{codec:"h264_mxf",label:"H.264 long-GOP (MXF)",full:!0,preview:!0,luma:!1,scrubPreview:!0,backend:"webcodecs",notes:"Camera proxies (Sony CTAPA and kin): H.264 High long-GOP in MXF OP1a. SEPARATE from 'xavc' because XAVC-Intra is all-intra and this is not \u2014 measured on a 1224-frame CTAPA proxy: IBBP, I every 12, but a true RAP (index flag 0x80) only every 48; the intervening I-frames are open-GOP (flag 0x40) and are NOT legal entry points. Decoded by LongGopPlayer: walk the GOP from its RAP, first AU 'key' and the rest 'delta', outputs taken in EMISSION order (WebCodecs owns the B-frame reorder, so the index's temporal_offset is never interpreted). Whole GOP is cached, so any scrub inside those 2s is free. Until 2026-08-10 these files were misidentified as xavc and decoded one isolated AU at a time (submit + flush), so every P/B frame hit a decoder with no reference state, only the leading IDR ever decoded, and the viewer showed frame 0 forever. Gated by oracle/i2o/e2e/mxf-longgop-playback.spec.ts against ffmpeg"},{codec:"r3d",label:"RED R3D",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"Full + preview render NATIVE RWG/Log3G10 (2026-07-26 \u2014 IPP2 output LUT removed from decoders; display transforms are downstream)"},{codec:"arriraw",label:"ARRIRAW",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"EVERY STAGE BYTE-EXACT vs the ARRI SDK (2026-07-27): prep, the ADA-7 demosaic (0 of 15,690,240), the LuMaTaLu color kernel (0 of 31,457,280 \u2014 closed by transcribing the SDK's own f32 op order: the LUT index is fmul-then-fadd not a fused mul_add, the B-spline weights are evaluated expanded with the sixth applied last, and the bicubic accumulates columns before rows), the 1:1 resample (identity) and AfaScaler+BufferScaler (0 of 43,739,136). The shipped master still omits AfaScaler's Rec.709 YCbCr detail and its Jenkins-hash grain \u2014 added looks, not native signal \u2014 so the end-to-end floor gate vs the SDK's DEFAULT output reads 0.16/255; color is no part of that number. exact AWG4/LogC4 develop (2026-07-21, vs ARRI SDK); preview is color via the same per-clip develop plan (tier gate corr \u22650.997). Pre-A35 12-bit ALEV-III (Mini/Mini LF) fully wired 2026-07-26: Gen2 develop to native AWG3/LogC3, SDK-gated MAE<0.8/255, probe inner_codec 'arriraw-alev3' \u2192 decode_arriraw12_mxf; other ALEV3 bodies decode flagged calib:parametric-alev3-family-unvalidated"},{codec:"dnxhr",label:"Avid DNxHR / DNxHD",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"DC-only 1/8 preview tier is COLOR (2026-08-05 \u2014 was gray luma) \u2014 playback + scrub ride it (4K/UHD DNxHR full decodes aren't scrub-fast); park upgrades to full"},{codec:"crm",label:"Canon Cinema RAW Light",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"preview LL tier develops through the SAME tone-exact Canon Log 2 path as Full (2026-07-26 \u2014 replaced the placeholder tone map that drifted -46/255)"},{codec:"braw",label:"Blackmagic RAW",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"per-clip WB develop (bmdf wkel/wtin \u2192 wb_grid tables; Pocket-6K-family sweep-validated); preview is COLOUR-accurate native Gen5 log (gate corr \u22650.996 vs downsampled full). PER-FRAME HEADER LAW (2026-10-27, rust braw::frame_law): family, dequant tables, grain quantisers and edge-strength width are computed from each frame's own header exactly as BlackmagicRawAPI does \u2014 transcribed from the 5.1 binary (dequant builder 0xb98d4: luma M*(qi+4)/32, chroma M*max((qi+5)>>1,4)/32, transposed, DC capped by hdr +0x20/+0x22; M = the frame's in-header matrix (Pocket 6K v2 headers) or a built-in bank entry picked by +0x24; grain setup 0x50358: lo = trunc(hdr+0x1c*40/119), hi = 2*lo, chroma = trunc(hdr+0x1e*80/119); driver select 0x50490 from version/type/strength width). It reproduces all six previously captured quantiser pairs and both Pocket 6K grain captures bit for bit. The ladder only sets the deblock ramp, and ladder AND quant index change frame to frame inside a clip (SAN census: 10,959 frames, 8 ladders, qi 0..53 on one Pocket 6K), so the old ladder-keyed registry (now a witness list, braw::PROFILES) was refusing most Pocket 6K frames and mis-decoding others. A frame is refused with calib:unsupported-entropy-profile only when its header resolves to a decoder driver not yet transcribed. Byte-exact frame gates: (0,0,0,1) C013/C060 8\xD78 byte-exact; and the 12\xD712 family (SHIPPED 2026-07-26) \u2014 (1,2,3,4) URSA 12K, plus BOTH PYXIS encodes (0,1,2,4) and (0,0,1,2), which are the same camera at the same raster with quantisers half a step apart. That family is 12\xD712 luma / 12\xD76 chroma, 2 luma + Cb + Cr per unit off one threaded bit-reader; all four walks (full, multithreaded, DC preview, color preview) are parametric over it. GRAIN + EDGE FILTER MODELLED 2026-07-26 \u2014 the decode is now essentially the SDK's literal output: the synthesized high-frequency PRNG grain is reproduced (scatter map verified 0 mismatches over 76,896 observations across two clips), its per-frame seed turns out to be carried IN the bitstream (16 BE bytes before the first tile) and re-seeded per tile as s1 ^= broadcast16(region<<5|vtile), and the post-IDCT block-edge filter (A*b + B*(a+c) >> 4) is applied. The filter's per-block STRENGTH byte is solved too (2026-07-26): it is transmitted, not derived - each unit ends with a [ctx+0x68]-bit field on its own reader (the skip the walk used to call 'hf_bias' and discard), packing four 2-bit weight selectors per block (bits 7:6/5:4 = the horizontal cut's two 6-px column spans, 3:2/1:0 = the vertical cut's two 6-px row spans); and the four weights are master[ladder[k]] with master[i] = (16-2i, i), so the header ladder IS the deblock strength ramp and no future profile needs a capture for it. BRAW IS BYTE-EXACT (2026-07-26). Frame-gated vs the SDK's own decoded.bin, through BOTH the oracle bitstream and the real .braw container path: all four captures \u2014 C060 (8x8), URSA 12K, and both PYXIS encodes \u2014 now differ from the SDK in ZERO samples, luma and chroma alike, across 208,099,712 luma samples; the gates assert max == 0 rather than a mean bound, because a tolerance cannot tell 'clean' from 'one wrong block in 400,000'. The last drift (11,248 URSA pixels off by one, ~0.014%) was never a modelling gap: the SDK computes an Arai-Agui-Nakajima SCALED DCT \u2014 coefficients premultiplied by s[u]*s[v] = c(k)/(2*cos(k*pi/2N)), then a unit-scale radix-3 x radix-4 butterfly \u2014 so a dense basis multiply is the same function through a DIFFERENT operation graph and rounds differently in f32, which is why f32, f32+FMA and f64 all missed. Both transforms (luma 12x12 @0x6e9c8, chroma 12x6 @0x6fc68) are now the SDK's literal dataflow, machine-transcribed by oracle/media/braw/t12_transcribe.py \u2014 a symbolic byte-slot emulator of the unrolled NEON \u2014 into the generated rust/media-core/src/codecs/braw_t12_idct.rs. The 8x8 family gains the same seed fix (whole-frame grain, no captured constant) AND the same edge filter: it was never a different algorithm, only a different compiled copy (@0x6b6a4) whose ladder (0,0,0,1) resolves to three identities plus one weak tap - C060 Y 1.76 -> 0.003. Also solved by censusing where the residual sat: the SDK runs horizontal before vertical; a vertical cut is governed by the block to its LEFT; the frame's final vertical cut is not filtered (the SDK handles cuts in pairs and drops the pair whose second cut leaves the frame); and the 8x8 byte is a nibble per block (7:6 h / 5:4 v for block 0, 3:2 h / 1:0 v for block 1). Both PYXIS profiles now carry captured grain quantisers (the PARIS original's were read once its volume was remounted). Also gated: the multithreaded walk is byte-identical to single-threaded, and both preview tiers are exact block means of the full decode (corr 1.0000). Pocket 6K (driver sym1569, single-context scan-wrapping core, inline transforms) byte-exact at qi 7 and qi 27 (C040); the SAN Pocket 6K frames at every other ladder (incl. C030's (0,2,3,4) qi 11) decode through the same driver on law-derived tables \u2014 their SDK frame gates (tests/braw_san_law.rs) pass byte-exact (2026-10-27: all 10 SAN frames \u2014 nine Pocket 6K across eight ladders, qi 4..44, plus C104 f567 \u2014 differ from the 5.1 SDK in zero Y/Cb/Cr samples). URSA 12K 8:1-type header (v5, flags 0x0914: type 3) DECODED BYTE-EXACT (2026-10-27): the SDK decodes it at full resolution through its SCALE-1 driver 0x66fdc (the scale-0 row, 0x65248, only parses), which is sym1575 apart from its tables \u2014 6\xD712 coded blocks become 8\xD78 / 8\xD74 output blocks (12336\xD74032 coded \u2192 8224\xD75376), three sub-streams in a four-slot offset table, early-stopping entropy cores 0x735fc / 0x7392c, type-3 prescale rows into the shared 8\xD78 IDCT, inline chroma butterfly. Gated against the 5.1 SDK on both SAN clips (A003_09021503_C013 f0/f70, A005_09021941_C016 f0/f121): 0 differing Y/Cb/Cr samples; multithreaded walk identical. Two fixes landed with it for every 8\xD78 family: the shared IDCT's pass-1 c0 tap is unfused for coefficient columns 4..7, and the chroma grain pre-load (GRAIN_CHROMA8) + the inline chroma butterfly (Cb copy fused, Cr copy not) replace a never-gated matrix form. SAN census: 10,959 / 10,959 frames now resolve to a transcribed driver. See oracle/media/braw/ENTROPY_PROFILE_RE.md \xA714"},{codec:"xocn",label:"Sony X-OCN",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"Full + preview render NATIVE S-Gamut3/S-Log3 (2026-07-26 \u2014 replaced the adaptive display transform); preview = LL-band-only decode (~1/8 per axis, ~90x faster), colour-consistent with Full by construction. Fitted sensors: Burano LT/8K (SBRg), Venice ST (SBRe), VENICE 2 8.6K (SBRf, 2026-07-26 \u2014 decodes via the same parametric geometry, own C0_VENICE2 matrix R\xB2\u22650.9994). X-OCN IS BYTE-EXACT ACROSS MODES (2026-07-27): LT 6K, Venice ST and Burano 8K all decode to ZERO differing samples vs libSonyRawDev's own decoder output \u2014 86,293,760 samples over the three, gated in tests/xocn_variant_gate.rs against hashes of the SDK's planes. Venice ST and 8K previously lost their top and bottom rows (28 and 12 rows; the interiors were already exact) because the band row ranges were formulas in the LL strip count n, read off the LT capture (y0=10, y1=8n-2 and friends) \u2014 those hold only when 8n == h + 12, which is an LT coincidence. The real rule (xocn::phase_chain): the standalone band carries the frame's h rows CENTRED in its 8n coded rows, and every coarser level is the even subset of the level below, so lo = a[k] and y14 = a[k] + n[k] fall out per level and reproduce LT's captured constants exactly. Settled by MEASURING the bitstream \u2014 strips are byte-aligned, so the row count of a strip is the count whose decode consumes its byte size (harness xocnstrip) \u2014 not by sweeping constants. The write-side dy row shift that used to paper over the phase is gone. SBRf/VENICE 2 decodes through the same path but is not yet re-gated byte-exact (fixture on PARIS)"},{codec:"mpeg2",label:"MPEG-2 / MPEG-1",full:!0,preview:!0,luma:!0,scrubPreview:!1,backend:"wasm",notes:"media-core's own decoder (2026-10-27): XDCAM HD422/EX, HDV, IMX, DVD and broadcast streams in MXF / MOV / PS / TS / ES / AVI through the mcvideo lane (video_open/video_decode, rust video::lane \u2192 video::mpeg2_range): long-GOP from the I frame before the window, display order from the stream's own temporal references; a miss decodes a window of frames and keeps it. decode_mpeg2_{rgba,preview,luma} are the I-frame sample tiers (DC-only 1/8 color preview). Gated sample-identical to ffmpeg (tests/mpeg2_gate.rs)"},{codec:"dv",label:"DV / DVCPRO / DVCPRO HD",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"media-core's own decoder (2026-10-27), all-intra: DV25 / DVCPRO50 / DVCPRO HD in MXF / MOV / AVI / raw .dv through the mcvideo lane; scrub rides the DC-only 1/8 color preview, park upgrades to full. decode_dv_{rgba,preview,luma} are the frame tiers. Gated vs ffmpeg (tests/dv_gate.rs)"},{codec:"qtraw",label:"QuickTime raw / Animation / Motion-JPEG",full:!0,preview:!1,luma:!1,scrubPreview:!1,backend:"wasm",notes:"media-core's codecs::qtraw through the mcvideo lane (2026-10-27): uncompressed raw/2vuy/v210, Animation (rle \u2014 a delta codec, painted forward from the sync sample before the window), Motion-JPEG (jpeg/mjpa/AVDJ/dmb1 on media-core's JPEG decoder, the JPEG's own raster); clean aperture applied. No browser decodes any of them. Gated vs ffmpeg (media-native mov_simple tests; RGB/Animation lossless-identical)"},{codec:"legacy",label:"Legacy & web video (MPEG-4 Part 2, H.263 / Sorenson, DivX 3, VC-1 / WMV, VP6, Cinepak, SVQ3, AV1)",full:!0,preview:!1,luma:!1,scrubPreview:!1,backend:"wasm",notes:"media-core's legacy decoders through the mcvideo lane (2026-10-27): MOV / MP4 / 3GP, Matroska / WebM, AVI, ASF / WMV, FLV (H.264 in AVI / ASF / FLV too \u2014 only this reader indexes them). Sample-identical to ffmpeg 7.1.1 on 378 of 379 SAN files (the one is ffmpeg concealing a WMV9 picture it misreads); AV1 34,606 / 34,606 frames. Not covered: interlaced VC-1 / VP6, H.263 PB-frames, MS-MPEG4 v1/v2, WMV1/2, AV1 profiles 1/2 and 12-bit"},{codec:"uncompressed",label:"Uncompressed MXF",full:!0,preview:!1,luma:!1,scrubPreview:!1,backend:"wasm",notes:"Avid 1:1 / alpha mattes / SMPTE 384 uncompressed pictures through the mcvideo lane (qtraw::decode_mxf_uncompressed by the descriptor's PictureLayout, 2026-10-27). Not yet gated against a browser-side fixture (no ffmpeg recipe writes one)"}],h=new Map(u.map(t=>[t.codec,t]));function a(t){let e=(t??"").toLowerCase().trim();return e?e==="aprn"||e==="aprh"?"prores_raw":e==="prores_mxf"||e.startsWith("ap")?"prores":e==="arriraw-alev3"?"arriraw":e==="avc1"||e==="avc3"||e==="h264"?"h264":e.startsWith("hvc")||e.startsWith("hev")||e==="h265"?"hevc":e.startsWith("avd")||e==="dnxh"||e==="dnxhd"?"dnxhr":e==="redcode"?"r3d":e==="h264_wasm"?"h264":e==="hevc_wasm"?"hevc":h.has(e)?e:null:null}function p(t){let e=(t??"").toLowerCase().trim();if(!e)return null;if(e==="aprn"||e==="aprh"||a(e)==="prores_raw"||e==="ap4h"||e==="ap4x")return 12;if(e.startsWith("ap"))return 10;let r=a(e);return r==="r3d"?16:r==="arriraw"||r==="braw"?12:r==="xocn"?16:r==="crm"?12:/dnxhr.?(hqx|444)/.test(e)?10:null}function b(t,e){if(typeof e!="number")return null;let r=a(t);return r==="h264"?[66,77,88,100].includes(e)?8:e===110?10:null:r==="hevc"?e===1?8:e===2?10:null:null}function w(t){let e=(t??"").toLowerCase().trim();if(!e)return null;if(e==="ap4h"||e==="ap4x")return"4:4:4";let r=a(e);return r==="prores_raw"||r==="r3d"||r==="arriraw"||r==="braw"||r==="xocn"||r==="crm"?"bayer":r==="prores"?"4:2:2":/dnxhr.?444/.test(e)?"4:4:4":/dnxhr.?(hqx|hq|sq|lb)/.test(e)?"4:2:2":null}function v(t){let e=t.toLowerCase().replace(/[^0-9a-z]/g,"");return e==="bayer"||e==="raw"?"bayer":e.length>=3&&/^\d+$/.test(e)?e.split("").join(":"):e}function c(t){let e=a(t);return e==="prores"||e==="h264"||e==="hevc"?e:"other"}var f={prores:"ProRes",h264:"H.264",hevc:"HEVC",r3d:"R3D",arriraw:"ARRIRAW",xocn:"X-OCN",vc3:"DNxHR",braw:"BRAW",proresraw:"ProRes RAW",other:"unsupported"};function x(t){return f[t]??"unsupported"}function m(t){let e=JSON.parse(t),r=e.frames??[],o=r.length>>1,n=new Array(o);for(let s=0,i=0;i<o;s+=2,i++)n[i]={offset:r[s],size:r[s+1]};return{offs:n,codec:e.codec,kind:c(e.codec),w:e.width,h:e.height,fps:e.fps??null,startFrame:e.start_frame??0,dropFrame:e.drop_frame??!1}}async function D(t){await l();let r=await d((o,n)=>t.slice(o,o+n).arrayBuffer().then(s=>new Uint8Array(s)),t.size,"mov");return m(r)}export{a,p as b,b as c,w as d,v as e,x as f,m as g,D as h};
|
|
@@ -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 F}from"./chunk-PHAMF4JF.js";import{$ as i,A as m,B as v,D as R,E as g,F as D,K as $,Y as k,m as b,s as x,t as p,x as S,z as _}from"./chunk-G3SZDPDS.js";var A="_originalframes",y="zAPPLIED_PATCHES",u=t=>t.replace(/[\\/][^\\/]+[\\/]?$/,""),T=()=>i(b(),"move-undo");async function P(t){let n=[];for await(let a of $(t))a.isFile&&!a.name.startsWith(".")&&n.push(a.name);return n.sort()}async function O(t){let n=[];for await(let a of $(u(t)))a.isDirectory&&/patch/i.test(a.name)&&a.name!==y&&n.push(a.name);return n.sort()}async function C(t,n){let a=new Set(await P(t)),e=[];for(let r of n){let s=i(u(t),r);if(await p(s))for(let w of await P(s))e.push({file:w,folder:r,replaces:a.has(w)})}return e}async function j(t,n,a){if(!await p(t)||!(await x(t)).isDirectory)throw new F("invalid_args",`not a folder: ${t}`);let e=u(t),r=[],s=[];for(let o of await C(t,n)){if(a&&!a.has(`${o.folder}/${o.file}`))continue;if(!o.replaces){r.push(`${o.file}: not in the sequence`);continue}let f=i(t,o.file),c=i(e,o.folder,o.file),l=`${t}${A}`,d=i(l,o.file);for(let h=1;await p(d);h++)d=i(`${t}${A}${String(h).padStart(2,"0")}`,o.file);await m(u(d));try{await g(f,d)}catch(h){r.push(`${o.file}: ${h.message}`);continue}try{await R(c,f)}catch(h){await g(d,f).catch(()=>{}),r.push(`${o.file}: ${h.message}`);continue}s.push({file:o.file,backup:d,patch_src:c,applied:c,folder:o.folder}),l=""}let w=[];if(s.length){let o=i(e,y);await m(o);for(let f of new Set(s.map(c=>c.folder))){let c=i(o,f);for(let l=1;await p(c);l++)c=i(o,`${f}_${l}`);try{await g(i(e,f),c),w.push({from:i(e,f),to:c});for(let l of s)l.folder===f&&(l.applied=i(c,l.file))}catch(l){r.push(`${f}: not filed under ${y} (${l.message})`)}}}if(!s.length)return{patched:0,errors:r};let E=`files-${Date.now().toString(36)}`;return await m(T()),await _(i(T(),`${E}.json`),JSON.stringify({patch:!0,sequence:t,entries:s.map(({folder:o,...f})=>f),folders:w})),{patched:s.length,errors:r,undo_id:E}}async function J(t){let n=[];for(let e of t.folders)await p(e.to)&&!await p(e.from)&&await g(e.to,e.from).catch(r=>n.push({path:e.to,error:r.message}));let a=0;for(let e of t.entries){let r=i(t.sequence,e.file);if(await p(e.backup))try{await p(r)&&await v(r),await g(e.backup,r),a++}catch(s){n.push({path:r,error:s.message})}}for(let e of new Set([...t.entries.map(r=>u(r.backup)),...t.folders.map(r=>u(r.to))]))if(await p(e)&&!(await P(e)).length){let r=!0;for await(let s of $(e)){r=!1;break}r&&await D(e).catch(()=>{})}return{restored:a,failed:n}}var L=t=>k(t),U=async t=>JSON.parse(await S(t));export{A as a,y as b,O as c,C as d,j as e,J as f,L as g,U as h};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
|
|
3
|
+
import{a as ut}from"./chunk-2CY2OOOJ.js";import{a as fe,b as mt}from"./chunk-ROPKSAFP.js";import{rc as lt,wb as ct}from"./chunk-VE423Z2L.js";import{a as pt}from"./chunk-NSQP6CTA.js";import{M as at,S as Y}from"./chunk-C2ESM27Z.js";import{b as Pe,d as it}from"./chunk-NU3X7P4N.js";import{$ as F,A as Q,D as tt,F as pe,J as G,K as rt,N as me,T as nt,U as ot,Y as st,Z as de,b as I,g as V,h as Qe,n as Te,q as Ye,r as Xe,t as ae,u as ce,w as le,x as Ze,y as et,z as ue}from"./chunk-G3SZDPDS.js";function dt(r,e){let t=async()=>{throw new Error(`${r}: ${e}`)},n={ok:!1,reason:e};return{host:r,wired:!1,support:async()=>({export:n,open:n,render:n,markers:n,renderplugin:n}),export:t,open:t,renderStart:t,renderStatus:t,renderCancel:t}}var Vt=ArrayBuffer,O=Uint8Array,ge=Uint16Array,Gt=Int16Array;var he=Int32Array,Ee=function(r,e,t){if(O.prototype.slice)return O.prototype.slice.call(r,e,t);(e==null||e<0)&&(e=0),(t==null||t>r.length)&&(t=r.length);var n=new O(t-e);return n.set(r.subarray(e,t)),n},Z=function(r,e,t,n){if(O.prototype.fill)return O.prototype.fill.call(r,e,t,n);for((t==null||t<0)&&(t=0),(n==null||n>r.length)&&(n=r.length);t<n;++t)r[t]=e;return r},qt=function(r,e,t,n){if(O.prototype.copyWithin)return O.prototype.copyWithin.call(r,e,t,n);for((t==null||t<0)&&(t=0),(n==null||n>r.length)&&(n=r.length);t<n;)r[e++]=r[t++]};var zt=["invalid zstd data","window size too large (>2046MB)","invalid block type","FSE accuracy too high","match distance too far back","unexpected EOF"],$=function(r,e,t){var n=new Error(e||zt[r]);if(n.code=r,Error.captureStackTrace&&Error.captureStackTrace(n,$),!t)throw n;return n},ft=function(r,e,t){for(var n=0,o=0;n<t;++n)o|=r[e++]<<(n<<3);return o},Jt=function(r,e){return(r[e]|r[e+1]<<8|r[e+2]<<16|r[e+3]<<24)>>>0},Wt=function(r,e){var t=r[0]|r[1]<<8|r[2]<<16;if(t==3126568&&r[3]==253){var n=r[4],o=n>>5&1,s=n>>2&1,i=n&3,m=n>>6;n&8&&$(0);var a=6-o,c=i==3?4:i,u=ft(r,a,c);a+=c;var d=m?1<<m:o,f=ft(r,a,d)+(m==1&&256),h=f;if(!o){var l=1<<10+(r[5]>>3);h=l+(l>>3)*(r[5]&7)}h>2145386496&&$(1);var p=new O((e==1?f||h:e?0:h)+12);return p[0]=1,p[4]=4,p[8]=8,{b:a+d,y:0,l:0,d:u,w:e&&e!=1?e:p.subarray(12),e:h,o:new he(p.buffer,0,3),u:f,c:s,m:Math.min(131072,h)}}else if((t>>4|r[3]<<20)==25481893)return Jt(r,4)+8;$(0)},H=function(r){for(var e=0;1<<e<=r;++e);return e-1},ee=function(r,e,t){var n=(e<<3)+4,o=(r[e]&15)+5;o>t&&$(3);for(var s=1<<o,i=s,m=-1,a=-1,c=-1,u=s,d=new Vt(512+(s<<2)),f=new Gt(d,0,256),h=new ge(d,0,256),l=new ge(d,512,s),p=512+(s<<1),g=new O(d,p,s),S=new O(d,p+s);m<255&&i>0;){var _=H(i+1),v=n>>3,A=(1<<_+1)-1,x=(r[v]|r[v+1]<<8|r[v+2]<<16)>>(n&7)&A,b=(1<<_)-1,w=A-i-1,T=x&b;if(T<w?(n+=_,x=T):(n+=_+1,x>b&&(x-=w)),f[++m]=--x,x==-1?(i+=x,g[--u]=m):i-=x,!x)do{var P=n>>3;a=(r[P]|r[P+1]<<8)>>(n&7)&3,n+=2,m+=a}while(a==3)}(m>255||i)&&$(0);for(var E=0,N=(s>>1)+(s>>3)+3,C=s-1,M=0;M<=m;++M){var y=f[M];if(y<1){h[M]=-y;continue}for(c=0;c<y;++c){g[E]=M;do E=E+N&C;while(E>=u)}}for(E&&$(0),c=0;c<s;++c){var k=h[g[c]]++,L=S[c]=o-H(k);l[c]=(k<<L)-s}return[n+7>>3,{b:o,s:g,n:S,t:l}]},Kt=function(r,e){var t=0,n=-1,o=new O(292),s=r[e],i=o.subarray(0,256),m=o.subarray(256,268),a=new ge(o.buffer,268);if(s<128){var c=ee(r,e+1,6),u=c[0],d=c[1];e+=s;var f=u<<3,h=r[e];h||$(0);for(var l=0,p=0,g=d.b,S=g,_=(++e<<3)-8+H(h);_-=g,!(_<f);){var v=_>>3;if(l+=(r[v]|r[v+1]<<8)>>(_&7)&(1<<g)-1,i[++n]=d.s[l],_-=S,_<f)break;v=_>>3,p+=(r[v]|r[v+1]<<8)>>(_&7)&(1<<S)-1,i[++n]=d.s[p],g=d.n[l],l=d.t[l],S=d.n[p],p=d.t[p]}++n>255&&$(0)}else{for(n=s-127;t<n;t+=2){var A=r[++e];i[t]=A>>4,i[t+1]=A&15}++e}var x=0;for(t=0;t<n;++t){var b=i[t];b>11&&$(0),x+=b&&1<<b-1}var w=H(x)+1,T=1<<w,P=T-x;for(P&P-1&&$(0),i[n++]=H(P)+1,t=0;t<n;++t){var b=i[t];++m[i[t]=b&&w+1-b]}var E=new O(T<<1),N=E.subarray(0,T),C=E.subarray(T);for(a[w]=0,t=w;t>0;--t){var M=a[t];Z(C,t,M,a[t-1]=M+m[t]*(1<<w-t))}for(a[0]!=T&&$(0),t=0;t<n;++t){var y=i[t];if(y){var k=a[y];Z(N,t,k,a[y]=k+(1<<w-y))}}return[e,{n:C,b:w,s:N}]},Qt=ee(new O([81,16,99,140,49,198,24,99,12,33,196,24,99,102,102,134,70,146,4]),0,6)[1],Yt=ee(new O([33,20,196,24,99,140,33,132,16,66,8,33,132,16,66,8,33,68,68,68,68,68,68,68,68,36,9]),0,6)[1],Xt=ee(new O([32,132,16,66,102,70,68,68,68,68,36,73,2]),0,5)[1],gt=function(r,e){for(var t=r.length,n=new he(t),o=0;o<t;++o)n[o]=e,e+=1<<r[o];return n},Oe=new O(new he([0,0,0,0,16843009,50528770,134678020,202050057,269422093]).buffer,0,36),Zt=gt(Oe,0),Me=new O(new he([0,0,0,0,0,0,0,0,16843009,50528770,117769220,185207048,252579084,16]).buffer,0,53),er=gt(Me,3),X=function(r,e,t){var n=r.length,o=e.length,s=r[n-1],i=(1<<t.b)-1,m=-t.b;s||$(0);for(var a=0,c=t.b,u=(n<<3)-8+H(s)-c,d=-1;u>m&&d<o;){var f=u>>3,h=(r[f]|r[f+1]<<8|r[f+2]<<16)>>(u&7);a=(a<<c|h)&i,e[++d]=t.s[a],u-=c=t.n[a]}(u!=m||d+1!=o)&&$(0)},tr=function(r,e,t){var n=6,o=e.length,s=o+3>>2,i=s<<1,m=s+i;X(r.subarray(n,n+=r[0]|r[1]<<8),e.subarray(0,s),t),X(r.subarray(n,n+=r[2]|r[3]<<8),e.subarray(s,i),t),X(r.subarray(n,n+=r[4]|r[5]<<8),e.subarray(i,m),t),X(r.subarray(n),e.subarray(m),t)},rr=function(r,e,t){var n,o=e.b,s=r[o],i=s>>1&3;e.l=s&1;var m=s>>3|r[o+1]<<5|r[o+2]<<13,a=(o+=3)+m;if(i==1)return o>=r.length?void 0:(e.b=o+1,t?(Z(t,r[o],e.y,e.y+=m),t):Z(new O(m),r[o]));if(!(a>r.length)){if(i==0)return e.b=a,t?(t.set(r.subarray(o,a),e.y),e.y+=m,t):Ee(r,o,a);if(i==2){var c=r[o],u=c&3,d=c>>2&3,f=c>>4,h=0,l=0;u<2?d&1?f|=r[++o]<<4|(d&2&&r[++o]<<12):f=c>>3:(l=d,d<2?(f|=(r[++o]&63)<<4,h=r[o]>>6|r[++o]<<2):d==2?(f|=r[++o]<<4|(r[++o]&3)<<12,h=r[o]>>2|r[++o]<<6):(f|=r[++o]<<4|(r[++o]&63)<<12,h=r[o]>>6|r[++o]<<2|r[++o]<<10)),++o;var p=t?t.subarray(e.y,e.y+e.m):new O(e.m),g=p.length-f;if(u==0)p.set(r.subarray(o,o+=f),g);else if(u==1)Z(p,r[o++],g);else{var S=e.h;if(u==2){var _=Kt(r,o);h+=o-(o=_[0]),e.h=S=_[1]}else S||$(0);(l?tr:X)(r.subarray(o,o+=h),p.subarray(g),S)}var v=r[o++];if(v){v==255?v=(r[o++]|r[o++]<<8)+32512:v>127&&(v=v-128<<8|r[o++]);var A=r[o++];A&3&&$(0);for(var x=[Yt,Xt,Qt],b=2;b>-1;--b){var w=A>>(b<<1)+2&3;if(w==1){var T=new O([0,0,r[o++]]);x[b]={s:T.subarray(2,3),n:T.subarray(0,1),t:new ge(T.buffer,0,1),b:0}}else w==2?(n=ee(r,o,9-(b&1)),o=n[0],x[b]=n[1]):w==3&&(e.t||$(0),x[b]=e.t[b])}var P=e.t=x,E=P[0],N=P[1],C=P[2],M=r[a-1];M||$(0);var y=(a<<3)-8+H(M)-C.b,k=y>>3,L=0,re=(r[k]|r[k+1]<<8)>>(y&7)&(1<<C.b)-1;k=(y-=N.b)>>3;var ne=(r[k]|r[k+1]<<8)>>(y&7)&(1<<N.b)-1;k=(y-=E.b)>>3;var oe=(r[k]|r[k+1]<<8)>>(y&7)&(1<<E.b)-1;for(++v;--v;){var Ae=C.s[re],qe=C.n[re],Re=E.s[oe],ze=E.n[oe],Je=N.s[ne],We=N.n[ne];k=(y-=Je)>>3;var Ke=1<<Je,U=Ke+((r[k]|r[k+1]<<8|r[k+2]<<16|r[k+3]<<24)>>>(y&7)&Ke-1);k=(y-=Me[Re])>>3;var J=er[Re]+((r[k]|r[k+1]<<8|r[k+2]<<16)>>(y&7)&(1<<Me[Re])-1);k=(y-=Oe[Ae])>>3;var se=Zt[Ae]+((r[k]|r[k+1]<<8|r[k+2]<<16)>>(y&7)&(1<<Oe[Ae])-1);if(k=(y-=qe)>>3,re=C.t[re]+((r[k]|r[k+1]<<8)>>(y&7)&(1<<qe)-1),k=(y-=ze)>>3,oe=E.t[oe]+((r[k]|r[k+1]<<8)>>(y&7)&(1<<ze)-1),k=(y-=We)>>3,ne=N.t[ne]+((r[k]|r[k+1]<<8)>>(y&7)&(1<<We)-1),U>3)e.o[2]=e.o[1],e.o[1]=e.o[0],e.o[0]=U-=3;else{var ie=U-(se!=0);ie?(U=ie==3?e.o[0]-1:e.o[ie],ie>1&&(e.o[2]=e.o[1]),e.o[1]=e.o[0],e.o[0]=U):U=e.o[0]}for(var b=0;b<se;++b)p[L+b]=p[g+b];L+=se,g+=se;var W=L-U;if(W<0){var K=-W,Bt=e.e+W;K>J&&(K=J);for(var b=0;b<K;++b)p[L+b]=e.w[Bt+b];L+=K,J-=K,W=0}for(var b=0;b<J;++b)p[L+b]=p[W+b];L+=J}if(L!=g)for(;g<p.length;)p[L++]=p[g++];else L=p.length;t?e.y+=L:p=Ee(p,0,L)}else if(t){if(e.y+=f,g)for(var b=0;b<f;++b)p[b]=p[g+b]}else g&&(p=Ee(p,g));return e.b=a,p}$(2)}},nr=function(r,e){if(r.length==1)return r[0];for(var t=new O(e),n=0,o=0;n<r.length;++n){var s=r[n];t.set(s,o),o+=s.length}return t};function we(r,e){for(var t=[],n=+!e,o=0,s=0;r.length;){var i=Wt(r,n||e);if(typeof i=="object"){for(n?(e=null,i.w.length==i.u&&(t.push(e=i.w),s+=i.u)):(t.push(e),i.e=0);!i.l;){var m=rr(r,i,e);m||$(5),e?i.e=i.y:(t.push(m),s+=m.length,qt(i.w,0,m.length),i.w.set(m,i.w.length-m.length))}o=i.b+i.c*4}else o=i;r=r.subarray(o)}return nr(t,s)}function D(r){let e=[],t=0,n=()=>{let s=0,i=1;for(;;){let m=r[t++];if(s+=(m&127)*i,i*=128,!(m&128))return s}},o=s=>Array.from(s,i=>i.toString(16).padStart(2,"0")).join("");for(;t<r.length;){let s=t,i=n(),m=Math.floor(i/8),a=i&7,c;if(a===0){let u=t;n(),c=r.slice(u,t)}else if(a===2){let u=n();c=r.slice(t,t+u),t+=u}else if(a===5)c=r.slice(t,t+4),t+=4;else if(a===1)c=r.slice(t,t+8),t+=8;else throw new Error(`wire type ${a}`);e.push([m,a,o(r.slice(s,t)),c])}return e}var or=r=>Array.from(r,e=>e.toString(16).padStart(2,"0")).join(""),yt=r=>Uint8Array.from(r.match(/../g)??[],e=>parseInt(e,16));function ye(r){let e=r.trim().toLowerCase();if(e.startsWith("80"))return e;if(e.startsWith("81"))return"80"+or(we(yt(e.slice(2))));throw new Error(`grade body: unknown encoding 0x${e.slice(0,2)}`)}function ht(r){let e={};for(let t of r.matchAll(/<ListMgt::LmVersion DbId="[^"]+">([\s\S]*?)<\/ListMgt::LmVersion>/g)){let n=/<Name>([^<]*)<\/Name>/.exec(t[1])?.[1],o=/<Body>([0-9a-fA-F]+)<\/Body>/.exec(t[1])?.[1];n&&o&&(e[n]=ye(o))}return e}function wt(r){let e=new Map;for(let t of r.matchAll(/<ListMgt::LmVersion DbId="([^"]+)">([\s\S]*?)<\/ListMgt::LmVersion>/g)){let n=/<Body>([0-9a-fA-F]+)<\/Body>/.exec(t[2])?.[1];n&&e.set(t[1],ye(n))}return e}function _t(r){let e=Y(r),t=c=>new TextDecoder().decode(e[c]),n=Object.keys(e).find(c=>c.startsWith("SeqContainer/")&&c.endsWith(".xml"));if(!n)throw new Error("grade bodies: no SeqContainer in the .drt");let o=new Map,s=new Map,i=Object.keys(e).filter(c=>c.startsWith("MediaPool/")&&c.endsWith(".xml"));for(let c of i)for(let u of t(c).matchAll(/<Sm2MpVideoClip DbId="([^"]+)">([\s\S]*?)<\/Sm2MpVideoClip>/g)){let d=/<pLmVerTable>([\s\S]*?)<\/pLmVerTable>/.exec(u[2]);d&&(o.set(u[1],ht(d[1])),s.set(u[1],wt(d[1])))}let m=new Map,a=0;for(let c of t(n).matchAll(/<Sm2TiTrack DbId="[^"]+">([\s\S]*?)<\/Sm2TiTrack>/g))if(/<Type>([^<]*)<\/Type>/.exec(c[1])?.[1]==="0"){a++;for(let u of c[1].matchAll(/<Sm2TiVideoClip DbId="[^"]+">([\s\S]*?)<\/Sm2TiVideoClip>/g)){let d=u[1],f=/<Start>(-?\d+)<\/Start>/.exec(d)?.[1],h=/<Name>([^<]*)<\/Name>/.exec(d)?.[1]??"";if(f===void 0)continue;let l=/<pLmVerTable>([\s\S]*?)<\/pLmVerTable>/.exec(d),p=/<MediaRef>([^<]+)<\/MediaRef>/.exec(d)?.[1],g=l&&/<pActive>([^<]+)<\/pActive>/.exec(l[1])?.[1],S=g?wt(l[1]).get(g)??(p?s.get(p)?.get(g):void 0):void 0;m.set(`${a}:${f}`,{name:h,local:l?ht(l[1]):{},remote:p&&o.get(p)||{},...S?{active:S}:{}})}}return m}function on(r){let e=a=>D(a),t=a=>{let c=0,u=1;for(let d of a)if(c+=(d&127)*u,u*=128,!(d&128))break;return c},n=e(yt(r.slice(2))).find(a=>a[0]===3&&a[1]===2&&e(a[3]).some(c=>c[0]===8&&t(c[3])===84)),s=(n?e(n[3]).filter(a=>a[0]===9).flatMap(a=>e(a[3])):[]).find(a=>a[0]===1&&a[1]===2&&e(a[3]).some(c=>c[0]===1&&c[1]===0&&t(c[3])===10));return s?e(s[3]).filter(a=>a[0]===6&&a[1]===2).map(a=>{let c=e(a[3]),u=t(c.find(h=>h[0]===1&&h[1]===0)?.[3]??new Uint8Array([0]))/2,d=c.find(h=>h[0]===2&&h[1]===2)?.[3]??new Uint8Array,f={t:u,zoom:1,height:1,rotation:0,pan:0,tilt:0,flip_x:!1,flip_y:!1};for(let h of e(d)){if(h[0]===5&&h[1]===2){let A=e(h[3]);f.ease_in=t(A.find(x=>x[0]===1)?.[3]??new Uint8Array([1])),f.ease_out=t(A.find(x=>x[0]===2)?.[3]??new Uint8Array([1]));continue}if(h[0]!==3||h[1]!==2)continue;let l=e(h[3]),p=t(l.find(A=>A[0]===1)?.[3]??new Uint8Array),g=l.find(A=>A[0]===2)?.[3],S=g&&e(g).find(A=>A[0]===1&&A[1]===5),_=g&&e(g).find(A=>A[0]===2&&A[1]===0),v=S?new DataView(S[3].buffer,S[3].byteOffset,4).getFloat32(0,!0):_?t(_[3]):void 0;v!==void 0&&(p===271581186?f.height=v:p===271581187?f.zoom=v:p===271581188?f.rotation=v:p===271581189?f.pan=v:p===271581190?f.tilt=v:p===271581191?f.flip_y=!!v:p===271581192&&(f.flip_x=!!v))}return f}).sort((a,c)=>a.t-c.t):[]}var sr=r=>Array.from(r,e=>e.toString(16).padStart(2,"0")).join(""),B=r=>Uint8Array.from(r.match(/../g)??[],e=>parseInt(e,16)),bt=r=>{let e=[];do e.push(r&127|(r>127?128:0)),r=Math.floor(r/128);while(r);return e};function St(r){let e=B(r.trim());if(e.length<9)throw new Error("EffectFiltersBA: too short");if(e[8]===128)return e.slice(9);if(e[8]===129)return we(e.slice(9));throw new Error(`EffectFiltersBA: unknown encoding 0x${e[8].toString(16)}`)}function ir(r){let e=new Uint8Array(9);return new DataView(e.buffer).setUint32(0,2),new DataView(e.buffer).setUint32(4,r.length+1),e[8]=128,sr(new Uint8Array([...e,...r]))}var $e=r=>{let e=D(r).find(t=>t[0]===1&&t[1]===0);return e?ar(e[3]):-1};function ar(r){let e=0,t=1;for(let n of r)if(e+=(n&127)*t,t*=128,!(n&128))break;return e}var Ne=(r,e)=>new Uint8Array([...bt(r<<3|2),...bt(e.length),...e]);function cr(r,e){let t=new DataView(r.buffer,r.byteOffset,r.byteLength),n=-t.getInt32(0)/16;if(!Number.isInteger(n)||n<2||r.length!==4+n*16||r[10]!==12)return r;let o=Array.from({length:n},(a,c)=>({frame:t.getUint32(4+c*16,!0),value:t.getFloat64(4+c*16+8,!0)})),s=o.map(a=>e(a.frame));if(!s.slice(0,-1).some(Boolean))return r;let i=new Uint8Array(4+n*64),m=new DataView(i.buffer);return m.setInt32(0,-(n*64)),o.forEach((a,c)=>{let u=4+c*64;m.setUint32(u,a.frame,!0),i[u+6]=13,m.setFloat64(u+8,a.value,!0);let d=c>0?s[c-1]:void 0,f=c<n-1?s[c]:void 0;d&&m.setFloat64(u+16,-(d.in/10)*(a.frame-o[c-1].frame),!0),f&&m.setFloat64(u+32,f.out/10*(o[c+1].frame-a.frame),!0)}),i}function lr(r,e){let t=[];for(let n of D(r))if(n[0]===9&&n[1]===2&&n[3].length){let o=D(n[3]).map(s=>s[0]===10&&s[1]===2?[...Ne(10,cr(s[3],e))]:[...B(s[2])]).flat();t.push(...Ne(9,new Uint8Array(o)))}else t.push(...B(n[2]));return new Uint8Array(t)}function ur(r){let e=[];for(let t of D(r)){if(t[0]!==9||t[1]!==2||!t[3].length)continue;let n=D(t[3]).find(i=>i[0]===10&&i[1]===2)?.[3];if(!n||n.length<4)continue;let o=new DataView(n.buffer,n.byteOffset,n.byteLength),s=-o.getInt32(0)/16;Number.isInteger(s)&&s>e.length&&n.length===4+s*16&&Array.from({length:s},(i,m)=>n[4+m*16+6]).every(i=>i===12)&&(e=Array.from({length:s},(i,m)=>o.getUint32(4+m*16,!0)))}return e}function pr(r,e){let t=D(e).find(s=>s[0]===1&&s[1]===2&&$e(s[3])===4);if(!t)throw new Error("the written clip carries no Transform group");let n=[],o=!1;for(let s of r?D(r):[]){if(s[0]===1&&s[1]===2&&$e(s[3])===4){o||(n.push(...B(t[2])),o=!0);continue}n.push(...B(s[2]))}return o||n.push(...B(t[2])),new Uint8Array(n)}function vt(r){let e=[],t=0;for(let n of r.matchAll(/<Sm2TiTrack DbId="[^"]+">([\s\S]*?)<\/Sm2TiTrack>/g)){if(/<Type>([^<]*)<\/Type>/.exec(n[1])?.[1]!=="0")continue;t++;let o=n.index+n[0].indexOf(n[1]);for(let s of n[1].matchAll(/<Sm2TiVideoClip DbId="[^"]+">([\s\S]*?)<\/Sm2TiVideoClip>/g)){let i=/<Start>(-?\d+)<\/Start>/.exec(s[1])?.[1];i!==void 0&&e.push({track:t,start:Number(i),at:o+s.index,end:o+s.index+s[0].length,body:s[0]})}}return e}var kt=r=>Object.keys(r).find(e=>e.startsWith("SeqContainer/")&&e.endsWith(".xml"));function xt(r,e,t,n){let o=Y(r),s=Y(e),i=kt(o),m=kt(s);if(!i||!m)throw new Error("no SeqContainer in the .drt");let a=new TextDecoder().decode(o[i]),c=vt(a),u=vt(new TextDecoder().decode(s[m])),d=[],f=[],h=[];for(let p of t){let g=`V${p.item.track}@${p.item.start}`,S=c.find(y=>y.track===p.item.track&&y.start===p.item.start+n),_=S?c.filter(y=>y.track===S.track).indexOf(S):-1,v=_>=0?u.filter(y=>y.track===p.item.track)[_]:void 0,A=v&&/<EffectFiltersBA>([0-9a-fA-F]+)<\/EffectFiltersBA>/.exec(v.body)?.[1];if(!S||!A){f.push(g);continue}let x=/<EffectFiltersBA>([0-9a-fA-F]*)<\/EffectFiltersBA>/.exec(S.body),b=D(St(A)),w=b.find(y=>y[0]===1&&y[1]===2&&$e(y[3])===4),T=w?ur(w[3]):[];if(T.length!==p.keys.length){f.push(`${g} (the engine wrote ${T.length} keys for ${p.keys.length})`);continue}let P=new Map(T.map((y,k)=>[y,p.keys[k].shape])),E=new Uint8Array(b.flatMap(y=>y===w?[...Ne(1,lr(y[3],k=>P.get(k)))]:[...B(y[2])])),N=pr(x?.[1]?St(x[1]):null,E),C=`<EffectFiltersBA>${ir(N)}</EffectFiltersBA>`,M=x?S.body.replace(x[0],C):S.body.replace(/(<\/Sm2TiVideoClip>)$/,`${C}$1`);h.push({at:S.at,end:S.end,body:M}),d.push(g)}for(let p of h.sort((g,S)=>S.at-g.at))a=a.slice(0,p.at)+p.body+a.slice(p.end);let l={...o,[i]:new TextEncoder().encode(a)};return{drt:at(l),keyed:d,missing:f}}function At(r,e,t){let n=r.source_range,o=r.timeline_range,s=n?.start.rate||t,i=n?.start.value??0,m=n?.duration&&o?.duration&&o.duration.value?n.duration.value/n.duration.rate/(o.duration.value/o.duration.rate)*s/t:s/t,a=[],c=0;for(let f of e){let h={value:i+f.t*m,rate:s},l=(p,g)=>a.push({id:`${r.id}-align-${c++}`,parameter_path:p,time:h,value:g,interp:"linear"});l("scale",f.transform.scale_x),e.some(p=>Math.abs(p.transform.scale_y-p.transform.scale_x)>.001)&&l("scale.y",f.transform.scale_y),l("position.x",f.transform.position_x),l("position.y",f.transform.position_y),l("rotation",f.transform.rotation)}let u=e[0].transform,d=(r.keyframes??[]).filter(f=>!/^(scale|position|rotation)/.test(String(f.parameter_path)));Object.assign(r,{scale:u.scale_x,position_x:u.position_x,position_y:u.position_y,rotation:u.rotation,keyframes:[...d,...a]}),Math.abs(u.scale_y-u.scale_x)>.001&&Object.assign(r,{scale_x:u.scale_x,scale_y:u.scale_y}),u.flip_h?r.flip_horizontal=!0:delete r.flip_horizontal,u.flip_v?r.flip_vertical=!0:delete r.flip_vertical}function Tt(r=V()){if(r==="win32"){let e=I("PROGRAMDATA")??"C:\\ProgramData",t=I("PROGRAMFILES")??"C:\\Program Files";return{api:`${e}\\Blackmagic Design\\DaVinci Resolve\\Support\\Developer\\Scripting`,lib:`${t}\\Blackmagic Design\\DaVinci Resolve\\fusionscript.dll`}}return r==="linux"?{api:"/opt/resolve/Developer/Scripting",lib:"/opt/resolve/libs/Fusion/fusionscript.so"}:{api:"/Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Scripting",lib:"/Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/fusionscript.so"}}async function mr(r){let e=I("RESOLVE_SCRIPT_LIB");if(e)return e;if(r==="darwin"){let n=(await me("ps",["-axo","comm="])).stdout.split(`
|
|
4
|
+
`).map(o=>o.trim()).find(o=>/\/Contents\/MacOS\/Resolve$/.test(o));if(n){let o=n.replace(/\/MacOS\/Resolve$/,"/Libraries/Fusion/fusionscript.so");if(await ae(o))return o}}return Tt(r).lib}async function dr(){for(let r of["./bridge.py","./resolve-bridge.py"]){let e=Xe(new URL(r,import.meta.url));if(await ce(e))return e}throw new Error("resolve: bridge.py is missing from this install")}var Ce=new Map;function fr(r){return Ce.has(r)||Ce.set(r,me(r,["-c","import sys; print(sys.base_prefix)"],{timeoutMs:2e4}).then(e=>e.stdout.trim().split(`
|
|
5
|
+
`).pop()||void 0).catch(()=>{})),Ce.get(r)}var gr=["PYTHON3HOME","FUSION_PYTHON3HOME","FUSION_PYTHON3_HOME","FUSION_PYTHON36_HOME"],hr=async(r,e,t)=>{let n=V(),{api:o}=Tt(n),s=Qe(),i=n==="win32"?await fr(s):void 0,m=await G("ct-bridge-"),a=F(m,"args.json"),c;try{await ue(a,JSON.stringify(e)),c=await me(s,[await dr(),r,`@${a}`],{env:{RESOLVE_SCRIPT_API:I("RESOLVE_SCRIPT_API")??o,RESOLVE_SCRIPT_LIB:await mr(n),PYTHONPATH:F(I("RESOLVE_SCRIPT_API")??o,"Modules"),...i?Object.fromEntries(gr.map(d=>[d,i])):{}},timeoutMs:t})}finally{await pe(m).catch(()=>{})}let u=c.stdout.trim().split(`
|
|
6
|
+
`).pop()??"";try{return JSON.parse(u)}catch{return{ok:!1,why:"bridge",detail:c.code==="ENOENT"||/Microsoft Store/.test(c.stderr)?`${s} is not installed (Resolve's scripting needs Python 3: python.org)`:c.stderr.trim().split(`
|
|
7
|
+
`).pop()||(typeof c.code=="string"?`the Resolve bridge could not start: ${c.code}`:`no answer from Resolve within ${Math.round(t/1e3)} s`)}}},q=class extends Error{constructor(t,n){super(n);this.why=t}},wr={module:"Install DaVinci Resolve (its scripting module ships with it).",no_connection:"Start Resolve and set Preferences > System > General > External scripting using: Local (Resolve Studio).",no_project:"Open a project in Resolve."},_e=class{constructor(e=hr){this.runner=e;this.host="resolve";this.restore=new Map;this.startNotes=new Map}async call(e,t={},n=6e4){let o=await this.runner(e,t,n);if(o.ok)return o;throw o.why==="resolve_error"&&/NoneType' object is not callable/.test(String(o.detail))&&!(await this.runner("version",{},1e4)).ok?new q("host_quit",`resolve: Resolve stopped responding during ${e} (it may have quit; see its log, ResolveDebug.txt). Restart Resolve and try again.`):new q(o.why??"unknown",`resolve: ${o.detail||o.why}`)}async support(){let e=await this.runner("version",{},15e3),t=e.ok?e.product==="DaVinci Resolve Studio"?{ok:!0}:{ok:!1,reason:`${e.product} has no external scripting (Resolve Studio has)`}:{ok:!1,reason:e.detail??String(e.why),setup:wr[e.why??""]},n=t;if(t.ok){let o=await ut();n=o.readiness==="ready"||o.readiness==="unknown"?{ok:!0}:{ok:!1,reason:`renderplugin: ${o.readiness}`,setup:o.next}}return{export:t,open:t,render:t,markers:t,renderplugin:n}}async current(){return await this.call("current")}async project(e){return await this.call("project",e,e.export_dir||e.grades?9e5:12e4)}async clipLut(e){return await this.call("clip_lut",e,6e4)}async items(e){return await this.call("items",e,e.selected?15e3:12e4)}async apply(e){let t=e.ops.filter(o=>o.op==="edit_keys");if(t.length){let o=e.ops.filter(a=>a.op!=="edit_keys"),s=o.length?await this.apply({...e,ops:o}):{project:"",timeline:e.timeline??"",results:[],undo:[],applied:0,failed:0},i=await this.alignedCopy(e,t),m=i.results.filter(a=>a.ok).length;return{...s,project:s.project||i.project,timeline:s.timeline||i.timeline,results:[...s.results,...i.results],applied:s.applied+m,failed:s.failed+i.results.length-m}}let n=e.ops.filter(o=>(o.op==="grade_sizing"&&(o.target==="input"||o.target==="node")&&!o.reset||o.op==="node_structure")&&o.item&&"track"in o.item);for(let o of n){let s=o.node_structure??o.structure_path;if(!s)continue;let i=/<Body>([0-9a-fA-F]+)<\/Body>/.exec(new TextDecoder().decode(await le(s)))?.[1];if(!i)throw new q("usage",`${s}: not a Resolve grade still (.drx with a <Body>)`);o.structure=ye(i),o.structure_name=s}if(n.length){let{grades:o,t0:s}=await this.grades(e.timeline,e.into?{into:e.into,scratch_project:e.scratch_project}:{}),i=m=>{let a=m.item;return o.get(`${a.track}:${a.start+s}`)};for(let m of n){let a=i(m);a&&(m.bodies={local:a.local,remote:a.remote})}}return await this.call("apply",e,6e4+e.ops.length*200)}async alignedCopy(e,t){let n=e.into?{into:e.into,scratch_project:e.scratch_project}:{},o=await G("ct-aligned-"),s=i=>({project:"",timeline:e.timeline??"",results:t.map(()=>({op:"edit_keys",ok:!1,refused:["aligned copy"],detail:`refused: ${i}; nothing changed`}))});try{let i=F(o,"export.drt"),m=await this.call("export",{timeline:e.timeline,out_path:i,...n}),a=String(m.timeline),c=Number(m.start_frame??0),{session:u}=await lt(i,"drt"),d=u.timelines[0],f=(d.fps_num??24)/(d.fps_den??1),h=d.tracks.filter(w=>String(w.kind).toLowerCase()==="video"),l=w=>Math.round(w.value*f/w.rate),p=[],g=[];for(let w of t){let T=h[w.item.track-1]?.items.find(P=>{let E=P.timeline_range?.start;return E&&[w.item.start,w.item.start+c].includes(l(E))});T?(At(T,w.keys,f),p.push(w)):g.push(`V${w.item.track}@${w.item.start}`)}let S=await ct("resolve-drt",u),_=typeof S.body=="string"?new TextEncoder().encode(S.body):S.body,v=xt(await le(i),_,p,c);if(!v.keyed.length)return s(`no clip could be keyed (${[...g,...v.missing].join(", ")})`);let A=F(o,`${a.replace(/[^\w.-]+/g,"_").slice(0,100)}_ALIGNED.drt`);await et(A,v.drt);let x=await this.call("open",{path:A,name:`${a} ALIGNED`,link_existing:!0,same_as:a,...n}),b=new Map([...g.map(w=>[w,"not found in the timeline's export"]),...v.missing.map(w=>[w.split(" ")[0],w])]);return{project:String(x.project??""),timeline:String(x.timeline??""),results:t.map(w=>{let T=`V${w.item.track}@${w.item.start}`;return b.has(T)?{op:"edit_keys",ok:!1,refused:["not keyed"],detail:`refused: ${b.get(T)}; nothing changed`}:{op:"edit_keys",ok:!0,detail:`${w.keys.length} Edit-page keyframes on "${x.timeline}" (a copy of "${a}" with every grade and setting; "${a}" itself unchanged)`}})}}catch(i){return s(i instanceof Error?i.message:String(i))}finally{await pe(o).catch(()=>{})}}async grades(e,t){let n=await G("ct-grades-");try{let o=F(n,"grades.drt"),s=await this.call("export",{timeline:e,out_path:o,...t});return{grades:await le(o).then(_t).catch(()=>new Map),t0:Number(s.start_frame??0)}}finally{await pe(n).catch(()=>{})}}async presets(e){return await this.call("presets",e,12e4)}async presetAuthor(e){return await this.call("preset_author",e,6e4)}async export(e){if(!e.out_path)throw new q("usage","resolve: export needs out_path");let t=await this.call("export",{timeline:e.timeline,out_path:e.out_path,...e.clip_id?{clip_id:e.clip_id}:{}});return{path:String(t.path),format:"drt",project:String(t.project),timeline:String(t.timeline)}}async open(e){let t=await this.call("open",{path:e.path,into:e.into??"current",name:e.name,media_dir:e.media_dirs?.[0],stay:e.stay??!1,folder:e.folder,create_folder:e.create_folder??!1,link_existing:e.link_existing??!1,...e.settings_from?{settings_from:e.settings_from}:{}},3e5),n=[...t.notes??[]];return(e.media_dirs?.length??0)>1&&n.push(`Resolve searches one media folder per import; used ${e.media_dirs[0]}`),{project:String(t.project),timeline:String(t.timeline),notes:n,restored:!!t.restored,...t.folder?{folder:String(t.folder)}:{},...t.settings?{settings:String(t.settings)}:{}}}async renderStart(e){let t=await this.call("render_start",{...e}),n=String(t.job_id);if(t.queued)return{job_id:n,state:"queued",percent:0,notes:["left in Resolve's render queue: start it on the Deliver page"]};this.restore.set(n,t.restore);let o=t.rejected_settings??[];return o.length&&this.startNotes.set(n,[`Resolve refused render setting(s) ${o.join(", ")} for this format; the rest were applied`]),{job_id:n,state:"queued",percent:0}}async renderStatus(e){let t=await this.call("render_status",{job_id:e},15e3),n={job_id:e,state:t.state,percent:Number(t.percent??0)};if(t.error&&(n.error=String(t.error)),n.state==="complete"||n.state==="failed"){let o=await this.call("render_finish",{job_id:e,restore:this.restore.get(e)});this.restore.delete(e),o.output&&(n.outputs=[String(o.output)]);let s=[...this.startNotes.get(e)??[],...o.tracks?[Rt(o)]:[]];this.startNotes.delete(e),s.length&&(n.notes=s)}return n}async renderCancel(e){let t=await this.call("render_cancel",{job_id:e,restore:this.restore.get(e)});return this.restore.delete(e),{job_id:e,state:"cancelled",percent:0,...t.output?{outputs:[String(t.output)]}:{},...t.tracks?{notes:[Rt(t)]}:{}}}},Rt=r=>{let e=r.tracks.map(t=>`V${t}`).join(", ");return r.tracks_restored?`video track(s) ${e} switched back on`:`could NOT switch video track(s) ${e} back on: re-enable them on the Edit page`};async function wn(r,e){let t=[];for await(let n of rt(r))n.isFile&&n.name.startsWith(e)&&t.push(F(r,n.name));return t.sort()}var yr="ws://localhost:1985",Pt="localhost",Et="conform_tools",Ot="conform.tools ",Mt="Video_Full",_r=r=>!!r&&typeof r=="object"&&"_handle"in r&&"_id"in r,z=class extends Error{constructor(t,n){super(n);this.code=t}},Fe=class r{constructor(e){this.ws=e;this.next=1;this.waiting=new Map;e.onMessage(t=>{let n;try{n=JSON.parse(t)}catch{return}let o=typeof n.id=="number"?this.waiting.get(n.id):void 0;if(!o)return;if(this.waiting.delete(n.id),n.error===void 0||n.error===null)return o.ok(n.result??null);let s=n.error;o.no(typeof s=="string"?new z(n.code??-1,s):new z(s.code??n.code??-1,s.message??JSON.stringify(s)))}),e.onClose(()=>{for(let t of this.waiting.values())t.no(new z("closed","Baselight closed the FLAPI connection"));this.waiting.clear()})}static async connect(e,t=3e3){let n=new r(await pt(e,{maxBytes:67108864,timeoutMs:t})),o=await br();return o&&await n.call("authenticate",{username:I("USER")??I("USERNAME")??"conform",token:o},null,t).catch(()=>null),n}call(e,t={},n=null,o=12e4){let s=this.next++;return new Promise((i,m)=>{let a=setTimeout(()=>{this.waiting.delete(s),m(new z("timeout",`${e}: no answer from Baselight within ${Math.round(o/1e3)} s`))},o);this.waiting.set(s,{ok:c=>{clearTimeout(a),i(c)},no:c=>{clearTimeout(a),m(c)}}),this.ws.send(JSON.stringify({jsonrpc:"2.0",method:e,target:n?n._id:null,params:t,id:s}))})}async forget(...e){for(let t of e)_r(t)&&await this.call("forget",{},t).catch(()=>null)}close(){this.ws.close()}};async function br(){let r=I("FLAPI_TOKEN");if(r)return r.trim();let e=V()==="darwin"?F(Te(),"Library","Preferences","FilmLight","flapi-token"):F(Te(),".filmlight","flapi-token");try{return(await Ze(e)).trim()||null}catch{return null}}var $t=(...r)=>Object.fromEntries(r.map(e=>[e,1])),Sr={[-30]:30,[-31]:30,[-32]:30,[-34]:25,[-35]:24};function be(r){if(!r||typeof r!="object")return null;let e=typeof r.fps=="string"?{TC_30DF:-30,TC_60HDF:-31}[r.fps]??Number(r.fps):r.fps,t=e>0?e:Sr[e]??30,n=((r.h*60+r.m)*60+r.s)*t+r.f;if(e!==-30&&e!==-31)return n;let o=r.h*60+r.m;return n-2*(o-Math.floor(o/10))}function vr(r,e,t){let n=Math.round(e),o=r;if(t&&n===30){let c=Math.floor(o/17982),u=o%17982;o+=18*c+(u>2?2*Math.floor((u-2)/1798):0)}let s=o%n,i=Math.floor(o/n)%60,m=Math.floor(o/n/60)%60;return{_type:"timecode",h:Math.floor(o/n/3600)%24,m,s:i,f:s,phase:0,fps:t&&n===30?-30:n,wrap:24}}function Nt(r){let e=Math.round(r);return Math.abs(r-e)<.005?e:Math.abs(r-e*1e3/1001)<.01?e*1e3/1001:r}var j=class extends Error{constructor(t,n){super(`baselight: ${n}`);this.why=t}},kr={darwin:"/Applications/Baselight",linux:"/usr/fl/baselight"},Se=class{constructor(e){this.url=e;this.host="baselight";this.jobs=new Map}async conn(e=3e3){let t=this.url??I("CONFORM_BASELIGHT_URL")??yr;try{return await Fe.connect(t,e)}catch(n){let o=await ae(kr[V()]??"/nonexistent");throw new j(o?"not_running":"not_installed",o?`Baselight is not answering FLAPI at ${t} (${n.message})`:"Baselight is not installed on this machine")}}async with(e){let t=await this.conn();try{return await e(t)}catch(n){throw n instanceof j?n:new j("flapi",n.message)}finally{t.close()}}async support(){let e;try{let t=await this.with(n=>n.call("Application.get_application_info"));e=/baselight|daylight/i.test(t.Product??"")?{ok:!0}:{ok:!1,reason:`the FLAPI server is ${t.Product??"unknown"}, not the Baselight app (port 1984 is the headless flapid)`,setup:"Point CONFORM_BASELIGHT_URL at the running Baselight (ws://localhost:1985)."}}catch(t){let n=t instanceof j?t.why:"flapi";e={ok:!1,reason:t.message.replace(/^baselight: /,""),setup:n==="not_installed"?"Install FilmLight Baselight (FLAPI ships with it; nothing else to install).":"Start Baselight. Its API server listens on port 1985 by default (Preferences > Advanced > API Server)."}}return{export:e,open:e,render:e,markers:{ok:!1,reason:"not wired for Baselight yet (FLAPI has marks: Scene.add_mark)"},renderplugin:{ok:!1,reason:"the renderplugin is a DaVinci Resolve plugin"}}}async scenePath(e,t,n){if(t?.includes(":")){let i=await e.call("Scene.parse_path",{str:t});return{host:i.Host,job:i.Job,scene:i.Scene}}let o=await this.current(e),s=n??o?.job;if(t&&s)return{host:o?.host??Pt,job:s,scene:t};if(!o)throw new j("no_scene",t?`no job to find scene "${t}" in: pass project (the job) or "host:job:scene"`:'no scene is open in Baselight: open one, or name it ("host:job:scene")');return o}async current(e){let t=await e.call("Application.get").catch(()=>null);if(!t)return null;try{let n=await e.call("Application.get_current_scene",{},t);if(!n)return null;try{let o=await e.call("Scene.get_scene_pathname",{},n),[s,i,...m]=o.split(":");return m.length?{host:s,job:i,scene:m.join(":")}:null}finally{await e.forget(n)}}finally{await e.forget(t)}}async export(e){if(!e.out_path)throw new j("usage","export needs out_path");return await this.with(async t=>{let n=await this.scenePath(t,e.timeline),o=await t.call("Scene.open_scene",{scenepath:{Host:n.host,Job:n.job,Scene:n.scene},flags:$t("OPENFLAG_READ_ONLY")});try{let s=await Rr(t,o,n.scene);await Q(de(e.out_path)),await ue(e.out_path,JSON.stringify(s,null,1))}finally{await t.call("Scene.close_scene",{},o).catch(()=>null),await t.forget(o)}return{path:e.out_path,format:"otio",project:n.job,timeline:n.scene}})}async open(e){let{readTimeline:t}=await import("./timeline-5TGA5HBY.js"),{session:n}=await t(e.path),o=n.timelines.find(u=>u.kind!=="compound")??n.timelines[0];if(!o)throw new j("usage",`no timeline in ${e.path}`);let s=new Map((n.media_references??[]).map(u=>[u.id,u])),i=o.fps_num/o.fps_den,m=o.tracks.filter(u=>u.kind==="Video").sort((u,d)=>u.track_index-d.track_index),a=[];m.length>1&&a.push(`placed V1 only: Baselight builds layers above a shot, which FLAPI cannot place in time; ${m.slice(1).reduce((u,d)=>u+d.items.filter(f=>f.kind==="clip").length,0)} clip(s) on V2+ not placed`);let c=(m[0]?.items??[]).filter(u=>u.kind==="clip"||u.kind==="gap").sort((u,d)=>u.timeline_range.start.value-d.timeline_range.start.value);return await this.with(async u=>{let d=e.into==="scratch"?null:await this.current(u);e.into!=="scratch"&&!d&&a.push(`no scene open in Baselight, so it went into our job ${Et}`);let f=d?.job??Et,h=d?.host??Pt;await u.call("JobManager.job_exists",{host:h,jobname:f})||await u.call("JobManager.create_job",{host:h,jobname:f});let l=(e.name??o.name??"conform.tools").replace(/[:/\\]+/g,"_"),p=l;for(let w=2;await u.call("JobManager.scene_exists",{host:h,jobname:f,scenename:p});w++)p=`${l} ${w}`;let g=await u.call("FormatSet.factory_formats"),S=o.resolution_w&&o.resolution_h?await u.call("FormatSet.get_basic_format_name",{width:o.resolution_w,height:o.resolution_h},g):null;await u.forget(g);let _=await u.call("Scene.new_scene",{scenepath:{Host:h,Job:f,Scene:p},options:{format:S,colourspace:Mt,frame_rate:i}},null,3e5),v=0,A=0,x=0,b=0;try{await u.call("Scene.start_delta",{name:"conform.tools open"},_);try{let w=0;for(let P of c){let E=P.timeline_range.start.value,N=P.timeline_range.duration.value;if(E>w&&(await Le(u,_,E-w),x++),w=Math.max(w,E+N),P.kind==="gap"){await Le(u,_,N),x++;continue}let M=(P.media_reference_id?s.get(P.media_reference_id):void 0)?.target_url?.replace(/^file:\/\//,""),y=P.source_range,k=M&&y?await Ar(u,M,Math.round(y.start.value),Math.round(y.start.value)+N-1):null;if(!k){await Le(u,_,N),A++;continue}y&&Math.abs(y.duration.value-N)>.5&&b++;let L=await u.call("Scene.insert_sequence",{sequence:k,where:"INSERT_END",relativeTo:null,colourSpace:null,format:null,frameRate:i},_);await u.forget(k,L),v++}let T=await u.call("Scene.get_scene_settings",{},_);await u.call("SceneSettings.set",{values:{StartTimecode:vr(o.start_frame??0,i,!!o.is_drop_frame)}},T),await u.forget(T),await u.call("Scene.end_delta",{},_)}catch(w){throw await u.call("Scene.cancel_delta",{},_).catch(()=>null),w}await u.call("Scene.save_scene",{},_,3e5)}catch(w){throw await u.call("Scene.close_scene",{},_).catch(()=>null),await u.forget(_),await u.call("JobManager.delete_scene",{host:h,jobname:f,scenename:p}).catch(()=>null),w}return await u.call("Scene.close_scene",{},_),await u.forget(_),a.unshift(`new scene ${h}:${f}:${p}: ${v} shot(s)${x?`, ${x} gap(s) as black`:""}`),A&&a.push(`${A} clip(s) had no media on disk at their path: placed as black of the same length (relink in Baselight's Conform view)`),b&&a.push(`${b} retimed clip(s) placed at normal speed: FLAPI has no retime setter`),p!==l&&a.push(`"${l}" was taken in ${f}: named "${p}"`),e.media_dirs?.length&&a.push("media_dirs not used: Baselight places each clip from its own path"),e.stay&&a.push("stay: FLAPI cannot switch the scene the app shows; open it from the Scenes browser"),{project:f,timeline:p,notes:a,restored:!0}})}async renderStart(e){if(e.disable_tracks?.length)throw new j("usage","disable_tracks: a Baselight render takes every layer or one (RenderTrack); leave the tracks out in the scene");if(e.audio_tracks?.length||e.renderplugin)throw new j("usage","audio_tracks and renderplugin are DaVinci Resolve options");return await this.with(async t=>{let n=await this.scenePath(t,e.timeline,e.project),o=await t.call("Scene.open_scene",{scenepath:{Host:n.host,Job:n.job,Scene:n.scene},flags:$t("OPENFLAG_READ_ONLY")}),s=null,i=null;try{s=await t.call("RenderSetup.create_from_scene",{scene:o});let m=await t.call("RenderSetup.get_num_deliverables",{},s),a=0;if(e.preset){let l=await t.call("RenderSetup.get_deliverable_names",{},s);if(a=l.indexOf(e.preset),a<0)throw new j("usage",`no deliverable "${e.preset}" in ${n.scene} (it has: ${l.join(", ")||"none"})`)}let c=await t.call("RenderSetup.get_deliverable",{index:a},s),u=e.name??n.scene.replace(/[^\w.-]+/g,"_");Object.assign(c,{Disabled:0,Container:"",OutputDirectory:e.target_dir,FileNamePrefix:u}),e.preset||Object.assign(c,{Name:"conform.tools",IsMovie:1,FileType:"lqtmov",MovieCodec:"apch",ImageOptions:{},FileNameExtension:".mov",RenderColourSpace:Mt,HandleEmptyFrames:"GMREB_BLACK",HandleIncompleteStacks:"GMREB_BLACK",HandleError:"BLACK",EmbedTimecode:1}),e.audio||(c.AudioCodec=""),await Q(e.target_dir),await t.call("RenderSetup.set_deliverable",{index:a,deliverable:c},s);for(let l=0;l<m;l++)l!==a&&await t.call("RenderSetup.set_deliverable_enabled",{index:l,enabled:0},s);if(e.range){let l=await t.call("Scene.get_scene_settings",{},o),p=be(await t.call("SceneSettings.get_single",{key:"StartTimecode"},l))??0;await t.forget(l);let g=e.range.in>=p?p:0;await t.call("RenderSetup.set_frames",{frames:[{Start:e.range.in-g,End:e.range.out-g}]},s)}else await t.call("RenderSetup.select_all",{},s);let d=await t.call("RenderSetup.get_output_filename_for_deliverable",{index:a},s);i=await t.call("QueueManager.create_local");let f=await t.call("RenderSetup.submit_to_queue",{queue:i,opname:`${Ot}${u}`},s),h=String(f.ID);return this.jobs.set(h,{op:f.ID,out:d,notes:f.Warning?[`Baselight: ${f.Warning}`]:[]}),{job_id:h,state:"queued",percent:0}}finally{await t.forget(s,i),await t.call("Scene.close_scene",{},o).catch(()=>null),await t.forget(o)}})}async ours(e,t,n){let o=Number(n),s=await e.call("QueueManager.get_operation",{id:o},t).catch(()=>null),i=String(s?.Description??s?.Name??"");if(!this.jobs.has(n)&&!i.startsWith(Ot))throw new j("not_ours",`queue operation ${n} is not a conform.tools render: left alone`);return o}async renderStatus(e){return await this.with(async t=>{let n=await t.call("QueueManager.create_local");try{let o=await this.ours(t,n,e),s=await t.call("QueueManager.get_operation_status",{id:o},n),i=xr(s.Status),m=Number(s.Progress??0),a={job_id:e,state:i,percent:i==="complete"?100:Math.round(m<=1?m*100:m)};if(i==="failed"||i==="complete"&&s.Errors){let u=(await t.call("QueueManager.get_operation_log",{id:o},n).catch(()=>[])).filter(d=>/fail|error|warn/i.test(d.Type)).slice(-6).map(d=>`${d.Message}${d.Detail?`: ${d.Detail}`:""}`);a.error=[s.ProgressText,...u].filter(Boolean).join("; ")||"Baselight reported a failed render",i==="complete"&&(a.state="failed")}if(a.state==="complete"||a.state==="failed"||a.state==="cancelled"){let c=this.jobs.get(e);a.state==="complete"&&c&&(a.outputs=[c.out]),c?.notes.length&&(a.notes=c.notes),await t.call("QueueManager.delete_operation",{id:o},n).catch(()=>null),this.jobs.delete(e)}return a}finally{await t.forget(n)}})}async renderCancel(e){return await this.with(async t=>{let n=await t.call("QueueManager.create_local");try{let o=await this.ours(t,n,e);return await t.call("QueueManager.delete_operation",{id:o},n),this.jobs.delete(e),{job_id:e,state:"cancelled",percent:0}}finally{await t.forget(n)}})}};function xr(r){let e=String(r).replace(/^OPSTATUS_/i,"").toLowerCase();return e==="done"?"complete":e==="active"?"rendering":e==="stopped"?"cancelled":e==="failed"||e==="crashed"||e==="toonew"?"failed":"queued"}async function Le(r,e,t){let n=await r.call("Scene.insert_blank",{red:0,green:0,blue:0,duration:t,where:"INSERT_END",relativeTo:null,colourSpace:null},e);await r.forget(n)}async function Ar(r,e,t,n){let o=await r.call("SequenceDescriptor.get_for_template",{template:e,start:null,end:null}).catch(()=>[]);if(!o?.length)return null;let s=await r.call("SequenceDescriptor.get_start_handle",{},o[0]);await r.forget(...o);let i=await r.call("SequenceDescriptor.get_for_template",{template:e,start:s+t,end:s+n});return i?.length?(await r.forget(...i.slice(1)),i[0]):null}var Ie=(r,e)=>({OTIO_SCHEMA:"RationalTime.1",rate:e,value:r}),je=(r,e,t)=>({OTIO_SCHEMA:"TimeRange.1",start_time:Ie(r,t),duration:Ie(e,t)});async function Rr(r,e,t){let n=Nt(await r.call("Scene.get_working_frame_rate",{},e)),o=await r.call("Scene.get_scene_settings",{},e),s=be(await r.call("SceneSettings.get_single",{key:"StartTimecode"},o))??0;await r.forget(o);let i=await r.call("Scene.get_num_shots",{},e),m=i?await r.call("Scene.get_shot_ids",{firstIndex:0,lastIndex:i-1},e):[],a=[];for(let d of m){let f=Math.round(d.StartFrame),h=Math.round(d.EndFrame),l=await r.call("Scene.get_shot",{shot_id:d.ShotId},e);try{let p=await r.call("Shot.get_sequence_descriptor",{},l).catch(()=>null);if(!p){a.push({start:f,end:h,name:`shot ${d.ShotId}`});continue}try{let g=Nt(await r.call("Shot.get_frame_rate",{},l))||n,S=be(await r.call("Shot.get_src_start_timecode",{},l)),_=await r.call("Shot.get_src_start_frame",{},l),v=await r.call("Shot.get_src_end_frame",{},l),x=await r.call("SequenceDescriptor.is_movie",{},p)?Ye(await r.call("SequenceDescriptor.get_path",{},p),await r.call("SequenceDescriptor.get_name",{},p)):await r.call("SequenceDescriptor.get_full_filename_with_d",{},p),b=await r.call("SequenceDescriptor.get_name",{},p),w=await r.call("SequenceDescriptor.get_tape",{index:0},p).catch(()=>""),T=await r.call("SequenceDescriptor.get_start_frame",{},p),P=await r.call("SequenceDescriptor.get_start_handle",{},p),E=await r.call("SequenceDescriptor.get_end_handle",{},p),C=(be(await r.call("SequenceDescriptor.get_start_timecode",{index:0},p))??0)-(T-P),M=Math.round(v-_),y=h-f,k={OTIO_SCHEMA:"Clip.2",name:b,enabled:!0,source_range:je(S??C+(_-P),y,g),media_references:{DEFAULT_MEDIA:{OTIO_SCHEMA:"ExternalReference.1",target_url:x,available_range:je(C,E-P+1,g),available_image_bounds:null,name:b,metadata:{}}},active_media_reference_key:"DEFAULT_MEDIA",effects:M&&M!==y?[{OTIO_SCHEMA:"LinearTimeWarp.1",name:"",effect_name:"LinearTimeWarp",time_scalar:M/y,metadata:{}}]:[],markers:[],metadata:w?{baselight:{tape:w}}:{}};a.push({start:f,end:h,name:b,clip:k})}finally{await r.forget(p)}}finally{await r.forget(l)}}let c=[];for(let d of[...a].sort((f,h)=>f.start-h.start)){if(!d.clip)continue;let f=c.find(h=>h[h.length-1].end<=d.start);f?f.push(d):c.push([d])}let u=c.map((d,f)=>{let h=[],l=0;for(let p of d)p.start>l&&h.push({OTIO_SCHEMA:"Gap.1",name:"",enabled:!0,source_range:je(0,p.start-l,n),effects:[],markers:[],metadata:{}}),h.push(p.clip),l=p.end;return{OTIO_SCHEMA:"Track.1",name:`V${f+1}`,kind:"Video",enabled:!0,children:h,source_range:null,effects:[],markers:[],metadata:{}}});return{OTIO_SCHEMA:"Timeline.1",name:t,metadata:{baselight:{shots:m.length}},global_start_time:Ie(s,n),tracks:{OTIO_SCHEMA:"Stack.1",name:"tracks",enabled:!0,children:u,source_range:null,effects:[],markers:[],metadata:{}}}}var Tr="127.0.0.1:31416",Pr="/ptsl.PTSL/SendGrpcRequest",Er="CONFORM.TOOLS",Or="CONFORM.TOOLS Desktop",De=[2025,6,0],te=[2025,6],Ve=1e4,Ct=5e3,Mr="ConformTools",$r="Start Pro Tools 2025.6 or newer with a session open (PTSL, its scripting door, listens on 127.0.0.1:31416).",Ue={GetTrackList:3,HostReadyCheck:13,ExportSessionInfoAsText:30,GetSessionSampleRate:35,GetSessionTimeCodeRate:38,GetSessionFeetFramesRate:39,GetSessionName:42,GetSessionPath:43,GetSessionStartTime:44,GetSessionLength:45,GetPTSLVersion:55,GetTransportState:59,ClearMemoryLocation:61,EditMemoryLocation:68,GetMemoryLocations:69,RegisterConnection:70,CreateMemoryLocation:71,SetTimelineSelection:81,GetTimelineSelection:82,GetSessionIDs:97,GetMainCounterFormat:102},Nr=[3,6],Cr=[4,7],Lt=106,Lr=new TextEncoder,jr=new TextDecoder;function ve(r,e){for(;r>127;)e.push(r&127|128),r=Math.floor(r/128);e.push(r)}function jt(r){let e=[];for(let[t,n]of r){if(typeof n=="number"){n&&(ve(t<<3,e),ve(n,e));continue}let o=typeof n=="string"?Lr.encode(n):n;if(o.length){ve(t<<3|2,e),ve(o.length,e);for(let s of o)e.push(s)}}return new Uint8Array(e)}function Ft(r){let e=new Map,t=0,n=()=>{let o=0,s=1,i;do i=r[t++],o+=(i&127)*s,s*=128;while(i&128&&t<r.length);return o};for(;t<r.length;){let o=n(),s=Math.floor(o/8),i=o&7;if(i===0)e.set(s,n());else if(i===2){let m=n();e.set(s,r.subarray(t,t+m)),t+=m}else if(i===1)t+=8;else if(i===5)t+=4;else throw new R("bad_answer",`Pro Tools sent a reply that is not protobuf (wire type ${i})`)}return e}var It=r=>r instanceof Uint8Array?jr.decode(r):"",Fr=r=>typeof r=="number"?r:0;function Ir(r,e,t){let n=jt([[2,r],[3,De[0]],[4,e],[5,De[1]],[6,De[2]]]);return jt([[1,n],[2,t]])}function Dr(r){let e=Ft(r),t=e.get(1);return{status:t instanceof Uint8Array?Fr(Ft(t).get(3)):0,body:It(e.get(2)),error:It(e.get(3))}}var R=class extends Error{constructor(t,n,o){super(n);this.code=t;this.errors=o}};function Ur(r){let e=null;try{e=JSON.parse(r)}catch{}let t=Array.isArray(e)?e:e&&typeof e=="object"?Array.isArray(e.errors)?e.errors:[e]:[],n=t.find(a=>!a.is_warning)??t[0],o=String(n?.command_error_message||r.trim()||"Pro Tools refused the command"),s=n?.command_error_type,m=s===Lt||s==="PT_NoOpenedSession"||s==="CEType_PT_NoOpenedSession"||s===String(Lt)?"no_session":/session id|not registered|register/i.test(o)?"not_registered":"command_failed";return new R(m,o,t.length?t:void 0)}var Ge=class{constructor(e=Tr){this.sessionId="";this.version=null;this.queue=Promise.resolve();let t=/^(127\.\d{1,3}\.\d{1,3}\.\d{1,3}):(\d{1,5})$/.exec(e)??/^\[(::1)\]:(\d{1,5})$/.exec(e);if(!t)throw new R("refused",`${e} is not a loopback IP address and port; PTSL is loopback only`);this.host=t[1],this.port=Number(t[2])}async send(e,t,n){let o;try{o=await ot(this.host,this.port,Pr,Ir(e,this.sessionId,t),n)}catch(i){throw this.sessionId="",this.version=null,i instanceof nt?i.code==="unavailable"?new R("not_running",`Pro Tools is not running (nothing answered on ${this.host}:${this.port})`):i.code==="deadline"?new R("timeout",`Pro Tools did not answer in ${n} ms (a modal dialog or a long command?)`):i.grpcStatus===12?new R("not_ptsl",`the program on ${this.host}:${this.port} is not Pro Tools`):new R("transport",`PTSL transport error: ${i.message}`):i}let s=Dr(o);if(Nr.includes(s.status)){if(!s.body.trim())return null;try{return JSON.parse(s.body)}catch{throw new R("bad_answer","Pro Tools sent a body that is not JSON")}}throw Cr.includes(s.status)?Ur(s.error):new R("bad_status",`Pro Tools answered with task status ${s.status}`)}async handshake(){if(!this.sessionId){let e=await this.send(Ue.RegisterConnection,JSON.stringify({company_name:Er,application_name:Or}),Ct);if(!e?.session_id)throw new R("not_registered","Pro Tools did not give conform.tools a session id");this.sessionId=e.session_id}if(!this.version){let e=await this.send(Ue.GetPTSLVersion,"",Ct),t=o=>Number(e?.[o]??0)||0,n=[t("version"),t("version_minor"),t("version_revision")];if(n[0]<te[0]||n[0]===te[0]&&n[1]<te[1])throw this.sessionId="",new R("host_too_old",`Pro Tools ${n[0]}.${n[1]} is too old; conform.tools needs Pro Tools ${te[0]}.${te[1]} or newer`);this.version=n}}call(e,t,n=Ve){let o=async()=>{if(e==="RegisterConnection")throw new R("refused","RegisterConnection is sent by the client itself");let i=Ue[e];if(i===void 0)throw new R("unknown_command",`${e} is not a PTSL command conform.tools sends`);let m=t==null?"":typeof t=="string"?t:JSON.stringify(t);for(let a=0;;a++){if(await this.handshake(),e==="GetPTSLVersion"){let[c,u,d]=this.version;return{version:c,version_minor:u,version_revision:d}}try{return await this.send(i,m,n)}catch(c){if(c instanceof R&&c.code==="not_registered"&&a===0){this.sessionId="";continue}throw c}}},s=this.queue.then(o,o);return this.queue=s.catch(()=>{}),s}},He={23976:24e3/1001,24:24,25:25,2997:3e4/1001,30:30,47952:48e3/1001,48:48,50:50,5994:6e4/1001,60:60,100:100,11988:12e4/1001,120:120},Hr={1:["23976",!1],2:["24",!1],3:["25",!1],4:["2997",!1],5:["2997",!0],6:["30",!1],7:["30",!0],8:["47952",!1],9:["48",!1],10:["50",!1],11:["5994",!1],12:["5994",!0],13:["60",!1],14:["60",!0],15:["100",!1],16:["11988",!1],17:["11988",!0],18:["120",!1],19:["120",!0]};function Br(r){if(typeof r=="number"||typeof r=="string"&&/^\d+$/.test(r.trim())){let t=Hr[Number(r)];return t?{fps:He[t[0]],drop:t[1]}:null}let e=/Fps(\d+)(Drop)?/i.exec(String(r??""));return e&&He[e[1]]?{fps:He[e[1]],drop:!!e[2]}:null}var Vr=/^-?\d{1,2}[:;.]\d{2}[:;.]\d{2}[:;.,]\d{2,3}(\.\d+)?$/,Gr=/^(?:(\d+):)?(\d+):(\d{2}(?:\.\d+)?)$/;function Be(r,e){let t=String(r??"").trim();if(Vr.test(t))return it(t.replace(/\.\d+$/,""),e.rate.fps,e.rate.drop);if(/^-?\d+$/.test(t))return e.start+Math.floor(Number(t)*e.rate.fps/e.sampleRate+1e-9);let n=Gr.exec(t);return n?e.start+Math.floor((Number(n[1]??0)*3600+Number(n[2])*60+Number(n[3]))*e.rate.fps+1e-9):null}var ke=["Blue","Cyan","Green","Yellow","Red","Pink","Purple","Fuchsia","Rose","Lavender","Sky","Mint","Lemon","Sand","Cocoa","Cream"],Dt=r=>{let e=Number(r);return e>=1?ke[(e-1)%ke.length]:ke[0]},qr=r=>Math.max(0,ke.findIndex(e=>e.toLowerCase()===String(r??"").toLowerCase()))+1,Ut=/(?:^| )\[ct:((?:[^[\]\\]|\\.)*)\]$/s;function zr(r,e){return!e&&!Ut.test(r)?r:`${r}${r?" ":""}[ct:${e.replace(/[\\[\]]/g,t=>`\\${t}`)}]`}function Jr(r){let e=Ut.exec(r);return e?{note:r.slice(0,e.index),data:e[1].replace(/\\(.)/gs,"$1")}:{note:r,data:""}}function Wr(r){return!r.includes(":")||r.includes("/")||r.includes("\\")?r:`/Volumes/${r.split(":").filter(Boolean).join("/")}`}var xe=class{constructor(e=new Ge){this.ptsl=e;this.host="protools"}async sessionName(e=Ve){try{return String((await this.ptsl.call("GetSessionName",null,e)).session_name??"")}catch(t){if(t instanceof R&&t.code==="no_session")return"";throw t}}async sessionPath(e=Ve){let t=await this.ptsl.call("GetSessionPath",null,e),n=typeof t.session_path=="string"?t.session_path:t.session_path?.path??"";return n?Wr(n):""}async current(e=2e3){try{let t=await this.sessionName(e);return t?{project:t,project_path:await this.sessionPath(e).catch(()=>"")}:null}catch{return null}}async facts(){let e=await this.sessionName();if(!e)throw new R("no_session","protools: no session is open");let t=(await this.ptsl.call("GetSessionTimeCodeRate")).current_setting,n=Br(t);if(!n)throw new R("bad_answer",`protools: a timecode rate conform.tools does not know (${t})`);let o=/(\d{4,6})/.exec(String((await this.ptsl.call("GetSessionSampleRate")).sample_rate??""));if(!o)throw new R("bad_answer","protools: Pro Tools reported a sample rate conform.tools does not know");let s=(await this.ptsl.call("GetSessionStartTime")).session_start_time,i={name:e,rate:n,sampleRate:Number(o[1]),start:0},m=Be(s,i);if(m==null)throw new R("bad_answer",`protools: a session start conform.tools cannot read (${s})`);return{...i,start:m}}async support(){let e={ok:!1,reason:"Pro Tools holds one session at a time, and importing a timeline changes it; write a .ptx or AAF with timeline_write and open that in Pro Tools"},t={ok:!1,reason:"bouncing from Pro Tools (ExportMix) is not wired"},n={ok:!1,reason:"the renderplugin is a DaVinci Resolve plugin"},o;try{o=await this.sessionName(3e3)?{ok:!0}:{ok:!1,reason:"Pro Tools is running with no session open"}}catch(s){o={ok:!1,reason:s instanceof Error?s.message:String(s),setup:$r}}return{export:o,open:e,render:t,markers:o,renderplugin:n}}async export(e){let t=await this.sessionName();if(!t)throw new R("no_session","protools: no session is open");if(e.timeline&&e.timeline!==t)throw new R("not_found",`protools: the open session is "${t}"; Pro Tools has one timeline per session`);let n=await this.sessionPath();if(!n||!await ce(n))throw new R("no_file",`protools: session "${t}" has no saved .ptx on disk${n?` (${n})`:""}; save it in Pro Tools first`);let o=e.out_path??F(await G("conform-protools-"),st(n));return await Q(de(o)),await tt(n,o),{path:o,format:"ptx",project:t,timeline:t}}open(){return Promise.reject(new R("unsupported","protools: open is not supported: Pro Tools holds one session, and importing a timeline into it changes it"))}renderStart(){return Promise.reject(new R("unsupported","protools: rendering (a bounce) is not wired"))}renderStatus(){return this.renderStart()}renderCancel(){return this.renderStart()}async project(){let e=await this.facts(),t=await this.sessionPath().catch(()=>""),n=[],o=[];try{let i=await this.ptsl.call("GetTrackList",{page_limit:1e3,track_filter_list:[{filter:"All",is_inverted:!1}]}),m={video:0,audio:0};for(let a of i.track_list??[]){let c=/video/i.test(String(a.type))?"video":"audio",u=a.track_attributes??{},d=u.is_inactive===!0||/^(true|.*_?(set|on|inactive))$/i.test(String(u.is_inactive??""));n.push({kind:c,index:++m[c],name:String(a.name??""),enabled:!d})}}catch(i){o.push(`tracks not read: ${i instanceof Error?i.message:String(i)}`)}let s=(await this.locations(e).catch(()=>({locs:[]}))).locs.length;return{project:e.name,timeline:e.name,timelines:[e.name],session_path:t,fps:e.rate.fps,drop_frame:e.rate.drop,sample_rate:e.sampleRate,start_tc:Pe(e.start,e.rate.fps,e.rate.drop),ptsl_version:this.ptsl.version?.join("."),markers:s,notes:o,tracks:n,jobs:[],found:{},pool:{path:"",clips:0,folders:[]}}}async locations(e){let t=[];for(let o=0;;){let s=await this.ptsl.call("GetMemoryLocations",{pagination_request:{limit:1e3,offset:o}}),i=(s.memory_locations??[]).filter(m=>m&&typeof m=="object");if(t.push(...i),o+=i.length,!i.length||o>=Number((s.pagination_response??s.stats)?.total??0))break}let n=[];for(let o of t){let s=o.time_properties,i=typeof s=="number"||/^\d+$/.test(String(s))?{1:"Marker",2:"Selection"}[Number(s)]:String(s??"").split("_").pop();if(i!=="Marker"&&i!=="Selection")continue;let m=Be(o.start_time,e);if(m==null)continue;let a=i==="Selection"?Be(o.end_time,e):null,{note:c,data:u}=Jr(String(o.comments??""));n.push({number:Number(o.number)||0,frame:m-e.start,duration:a==null?1:Math.max(1,a-m),name:String(o.name??""),note:c,data:u,color:Dt(o.color_index),raw:o})}return n.sort((o,s)=>o.frame-s.frame||o.number-s.number),{locs:n.filter((o,s)=>s===0||n[s-1].frame!==o.frame),numbers:t.map(o=>Number(o.number)||0)}}async writeFormat(){let e=await this.ptsl.call("GetMainCounterFormat"),t=e.current_setting??e.current_type,n=typeof t=="number"||/^\d+$/.test(String(t))?{3:"TimeCode",5:"Samples"}[Number(t)]:String(t??"").split("_").pop();if(n==="TimeCode")return"timecode";if(n==="Samples")return"samples";throw new R("counter_format","protools: set Pro Tools' main counter to Timecode or Samples to edit markers from conform.tools")}async apply(e){let t=await this.facts();if(e.timeline&&e.timeline!==t.name)throw new R("not_found",`protools: the open session is "${t.name}"`);let{locs:n,numbers:o}=await this.locations(t),s=new Map(n.map(l=>[l.frame,l])),i=null,m=l=>i==="samples"?String(Math.round(l*t.sampleRate/t.rate.fps)):Pe(t.start+l,t.rate.fps,t.rate.drop),a=async(l,p)=>{let g=Math.max(1,Math.round(l.duration??1)),S=p?.number??Math.max(0,...o)+1,_=p?.raw??{},v={number:S,name:l.name??"",start_time:m(l.frame),end_time:m(l.frame+(g>1?g:0)),time_properties:g>1?"TP_Selection":"TP_Marker",reference:_.reference||"MLR_Absolute",general_properties:_.general_properties||{zoom_settings:!1,pre_post_roll_times:!1,track_visibility:!1,track_heights:!1,group_enables:!1,window_configuration:!1},comments:zr(l.note??"",l.data??""),color_index:qr(l.color),location:_.location||"MLC_MainRuler",..._.track_name?{track_name:_.track_name}:{}};await this.ptsl.call("CreateMemoryLocation",v),o.push(S),s.set(l.frame,{number:S,frame:l.frame,duration:g,name:l.name??"",note:l.note??"",data:l.data??"",color:Dt(v.color_index),raw:v})},c=async l=>{await this.ptsl.call("ClearMemoryLocation",{location_list:[l.number]}),s.delete(l.frame),o.splice(o.indexOf(l.number),1)},u=l=>({op:"marker_add",frame:l.frame,color:l.color,name:l.name,note:l.note,duration:l.duration,...l.data?{data:l.data}:{}}),d=[],f=[];for(let l of e.ops){let p=Number(l.frame);try{if(!l.op.startsWith("marker_")||l.item){d.push({op:l.op,ok:!1,detail:`protools: '${l.op}' is not reachable over PTSL (timeline markers only)`});continue}if(!Number.isInteger(p)){d.push({op:l.op,ok:!1,detail:"frame must be a whole number"});continue}i??=await this.writeFormat();let g=s.get(p);if(l.op==="marker_add")g&&await c(g),await a({frame:p,color:l.color,name:l.name,note:l.note,duration:Number(l.duration??1),data:l.data||Mr}),d.push({op:l.op,ok:!0}),f.unshift({op:"marker_delete",frame:p},...g?[u(g)]:[]);else if(l.op==="marker_update"){if(!g){d.push({op:l.op,ok:!1,detail:`no marker at frame ${p}`});continue}let S=l.to_frame!==void 0?Number(l.to_frame):p;if(!Number.isInteger(S)){d.push({op:l.op,ok:!1,detail:"to_frame must be a whole number"});continue}if(S!==p&&s.has(S)){d.push({op:l.op,ok:!1,detail:`frame ${S} already has a marker`});continue}await c(g);let _=(v,A)=>l[v]!==void 0?l[v]:A;await a({frame:S,color:_("color",g.color),name:_("name",g.name),note:_("note",g.note),duration:Number(_("duration",g.duration)),data:_("data",g.data)},g),d.push({op:l.op,ok:!0}),f.unshift({op:"marker_update",frame:S,color:g.color,name:g.name,note:g.note,duration:g.duration,data:g.data,...S!==p?{to_frame:p}:{}})}else if(l.op==="marker_delete"){if(!g){d.push({op:l.op,ok:!1,detail:`no marker at frame ${p}`});continue}await c(g),d.push({op:l.op,ok:!0}),f.unshift(u(g))}else d.push({op:l.op,ok:!1,detail:`protools: unknown marker op '${l.op}'`})}catch(g){d.push({op:l.op,ok:!1,detail:g instanceof Error?g.message:String(g)})}}let h=d.filter(l=>l.ok).length;return{project:t.name,timeline:t.name,results:d,undo:f,applied:h,failed:d.length-h}}};var Kr="Install the conform.tools panel in Media Composer (mcp/hosts/avid/panel: package it, copy the .avpi into PanelSDKPlugins; an unsigned panel needs Avid's Feature Toggle Files), then open Tools > CONFORM.TOOLS. Its page loads from this engine's host bridge (port 48127) and connects by itself.",Qr="Install the conform.tools hook (host_setup host=flame action=install_panel), then in Flame: Flame menu > Python > Rescan Python Hooks (or restart Flame), then Flame menu > CONFORM.TOOLS > Connect to CONFORM.TOOLS (or Connect Automatically).",Yr="Install the conform.tools panel (host_setup host=nuke action=install_panel) and restart Nuke Studio / Hiero, then CONFORM.TOOLS > Connect (or tick Connect automatically in its panel).",Ht={resolve:new _e,premiere:new mt,avid:new fe({host:"avid",label:"Media Composer",setup:Kr}),flame:new fe({host:"flame",label:"Flame",setup:Qr,items:!0}),nuke:new fe({host:"nuke",label:"Nuke Studio",setup:Yr,items:!0}),baselight:new Se,protools:new xe};function Mn(r,e){Ht[r]=e}function $n(r){return Ht[r]??dt(r,"not wired yet")}export{_t as a,on as b,hr as c,wn as d,xe as e,Kr as f,Qr as g,Yr as h,Mn as i,$n as j};
|
|
@@ -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 o,b as l,c,d as m,e as d,f as h,g as f,i as v,j as w,k as y}from"./chunk-QTFFVLVJ.js";var S=class extends h{async evalCodeAsync(e,t="eval.js",s){let i=s===void 0?1:0,n=d(s),r=0;try{r=await this.memory.newHeapCharPointer(e).consume(a=>this.ffi.QTS_Eval_MaybeAsync(this.ctx.value,a.value.ptr,a.value.strlen,t,i,n))}catch(a){throw this.runtime.debugLog("QTS_Eval_MaybeAsync threw",a),a}let u=this.ffi.QTS_ResolveException(this.ctx.value,r);return u?(this.ffi.QTS_FreeValuePointer(this.ctx.value,r),this.fail(this.memory.heapValueHandle(u))):this.success(this.memory.heapValueHandle(r))}newAsyncifiedFunction(e,t){return this.newFunction(e,t)}},x=class extends f{constructor(e){super(e)}newContext(e={}){let t=m(e.intrinsics),s=new l(this.ffi.QTS_NewContext(this.rt.value,t),void 0,n=>{this.contextMap.delete(n),this.callbacks.deleteContext(n),this.ffi.QTS_FreeContext(n)}),i=new S({module:this.module,ctx:s,ffi:this.ffi,rt:this.rt,ownedLifetimes:[],runtime:this,callbacks:this.callbacks});return this.contextMap.set(s.value,i),i}setModuleLoader(e,t){super.setModuleLoader(e,t)}setMaxStackSize(e){return super.setMaxStackSize(e)}},k=class extends y{constructor(e,t){super(e,t),this.ffi=t,this.module=e}newRuntime(e={}){let t=new l(this.ffi.QTS_NewRuntime(),void 0,i=>{this.callbacks.deleteRuntime(i),this.ffi.QTS_FreeRuntime(i)}),s=new x({module:this.module,ffi:this.ffi,rt:t,callbacks:this.callbacks});return v(s,e),e.moduleLoader&&s.setModuleLoader(e.moduleLoader),s}newContext(e={}){let t=this.newRuntime(),s=e.ownedLifetimes?e.ownedLifetimes.concat([t]):[t],i=t.newContext({...e,ownedLifetimes:s});return t.context=i,i}evalCode(){throw new o("QuickJSWASMModuleAsyncify.evalCode: use evalCodeAsync instead")}evalCodeAsync(e,t){return c.withScopeAsync(async s=>{let i=s.manage(this.newContext());w(i.runtime,t);let n=await i.evalCodeAsync(e,"eval.js");if(t.memoryLimitBytes!==void 0&&i.runtime.setMemoryLimit(-1),n.error)throw i.dump(s.manage(n.error));return i.dump(s.manage(n.value))})}};export{k as a};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
|
|
3
|
+
import{a as c,b as m}from"./chunk-DKGGJM6Z.js";import{Ga as u,Ia as n,K as f,aa as s}from"./chunk-DPA26AOI.js";async function y(r){await n();let e=s(r);return e==="null"?null:JSON.parse(e)}async function d(r){await n();let e;try{e=f(r)}catch{return null}if(e.length<8)return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength),i=t.getUint32(0,!0),a=t.getUint32(4,!0),o=i*a*4;return e.length<8+o?null:{width:i,height:a,rgba:new Uint8ClampedArray(e.subarray(8,8+o))}}async function b(r,e=8){await n();let t=m(u,"decode_tiff_preview");if(!t)return d(r);try{return c(t(r,e))}catch{return null}}export{y as a,d as b,b as c};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
|
|
3
|
+
import{$ as c,A as P,D as p,N as w,a as h,m as C,n as v,t as u,x as y,z as m}from"./chunk-G3SZDPDS.js";import"./chunk-PSANHDZM.js";var b="conformtools-statusline";function O(e,n){let t=e.statusLine;return t&&!String(t.command??"").includes(b)?{settings:e,result:"kept"}:t?.command===n?{settings:e,result:"updated"}:{settings:{...e,statusLine:{type:"command",command:n,padding:0}},result:t?"updated":"installed"}}async function _(){let e=new URL(import.meta.url),n=h(new URL("./statusline.js",e));if(await u(n)){await P(C());let s=c(C(),`${b}.js`);return await p(n,s),`node "${s}"`}let t=h(new URL("../adapters/statusline.ts",e));return await u(t)?`deno run --allow-read --allow-env --no-check "${t}" ${b}`:null}function A(e,n){let t=e.permissions&&typeof e.permissions=="object"?e.permissions:{},s=Array.isArray(t.allow)?t.allow.filter(o=>typeof o=="string"):[];return s.includes(n)?{settings:e,added:!1}:{settings:{...e,permissions:{...t,allow:[...s,n]}},added:!0}}async function T(e={}){let n=e.server??"conformtools",t=`mcp__${n}`,s=e.settingsPath??c(v(),".claude","settings.json"),o={};if(await u(s)){let r=await y(s);try{o=r.trim()?JSON.parse(r):{}}catch(d){throw new Error(`${s} is not valid JSON (${d instanceof Error?d.message:d}); fix it first, nothing was changed`)}}let a=A(o,t),i=a.settings,l="skipped",f=a.added,R=e.statusline===!1?null:await _();if(R){let r=O(i,R);i=r.settings,l=r.result}let k;(f||l==="installed"||l==="updated"&&i!==a.settings)&&(await u(s)?(k=`${s}.conformtools-backup`,await p(s,k)):await Deno.mkdir(c(s,".."),{recursive:!0}),await m(s,JSON.stringify(i,null,2)+`
|
|
4
|
+
`));let g="skipped",x;if(e.register!==!1)try{let r=await w("claude",["mcp","get",n]),d=r.code===0&&r.stdout.includes("conformtools@latest")&&!r.stdout.includes("--prefer-online");if(r.code===0&&!d)g="already";else{d&&await w("claude",["mcp","remove","-s","user",n]);let $=await w("claude",["mcp","add","-s","user",n,"--","npx",...S]);g=$.code===0?d?"updated":"added":"failed",$.code!==0&&(x=$.stderr.trim().slice(-300))}}catch(r){g="failed",x=`claude CLI not found (${r instanceof Error?r.message:r}); add the server with: claude mcp add -s user ${n} -- npx ${S.join(" ")}`}return{settings:s,rule:t,added:f,backup:k,registered:g,detail:x,statusline:l}}function U(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); every new session runs the newest version",updated:"MCP server: registered again so every new session runs the newest version (it was set up to keep a cached copy)",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
|
+
`)}var S=["-y","--prefer-online","conformtools@latest","mcp"],L='args = ["-y", "conformtools@latest", "mcp"]',j=e=>`[mcp_servers.${e}]
|
|
6
|
+
command = "npx"
|
|
7
|
+
args = ${JSON.stringify(S).replace(/","/g,'", "')}
|
|
8
|
+
`;async function D(e={}){let n=e.server??"conformtools",t=e.configPath??c(v(),".codex","config.toml"),s=await u(t)?await y(t):"",o=new RegExp(`^\\s*\\[mcp_servers\\.(?:"${n}"|${n})\\][^\\n]*(?:\\n(?!\\s*\\[)[^\\n]*)*`,"m").exec(s);if(o){if(!o[0].includes(L))return{config:t,registered:"already"};let i=`${t}.conformtools-backup`;await p(t,i);let l=j(n).split(`
|
|
9
|
+
`).find(f=>f.startsWith("args = "));return await m(t,s.slice(0,o.index)+o[0].replace(L,l)+s.slice(o.index+o[0].length)),{config:t,registered:"updated",backup:i}}let a;return s?(a=`${t}.conformtools-backup`,await p(t,a)):await Deno.mkdir(c(t,".."),{recursive:!0}),await m(t,`${s}${s&&!s.endsWith(`
|
|
10
|
+
`)?`
|
|
11
|
+
`:""}${s?`
|
|
12
|
+
`:""}${j(n)}`),{config:t,registered:"added",backup:a}}function E(e){return[e.registered==="added"?`Codex: conform.tools MCP server added to ${e.config}${e.backup?` (backup: ${e.backup})`:""}; every new session runs the newest version`:e.registered==="updated"?`Codex: conform.tools in ${e.config} set to run the newest version on every start${e.backup?` (backup: ${e.backup})`:""}`:`Codex: conform.tools is already in ${e.config}`,"Restart Codex to load it."].join(`
|
|
13
|
+
`)}export{S as LAUNCH_ARGS,j as codexTable,E as codexText,T as setupClaude,D as setupCodex,U as setupText,A as withAllowRule,O as withStatusLine};
|
package/dist/cli.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
|
|
3
|
-
import{
|
|
3
|
+
import{i as F,j as G,l as V,m as Y}from"./chunk-2QT5MMBP.js";import"./chunk-XF3YMBI7.js";import"./chunk-YU3SUSK3.js";import"./chunk-QTFFVLVJ.js";import"./chunk-5YULBQJX.js";import"./chunk-6HZP2OJA.js";import"./chunk-RKIRHMON.js";import"./chunk-XIAG7ACN.js";import"./chunk-2CY2OOOJ.js";import"./chunk-ROPKSAFP.js";import{ic as J,jc as H,vb as L}from"./chunk-VE423Z2L.js";import"./chunk-IN6XVTUS.js";import"./chunk-6VP6G7CY.js";import"./chunk-PFZVET7S.js";import"./chunk-THVX57I3.js";import"./chunk-LVGGCRDW.js";import"./chunk-NSQP6CTA.js";import{a as A}from"./chunk-IK6RKNS5.js";import"./chunk-YUO3UWPH.js";import"./chunk-JV7TZDKJ.js";import"./chunk-6V4OEOOX.js";import"./chunk-RGMTLNMF.js";import"./chunk-ISKNIQVO.js";import"./chunk-JKOB3U54.js";import"./chunk-EEDLRRKU.js";import"./chunk-DKGGJM6Z.js";import"./chunk-WJ5EWXP2.js";import"./chunk-C2ESM27Z.js";import"./chunk-D6YDLKSA.js";import"./chunk-XDI6CPPV.js";import"./chunk-DGXZB7MO.js";import"./chunk-JXTRQ3UG.js";import"./chunk-2WBGXD27.js";import"./chunk-N34DQ6MH.js";import{b as W}from"./chunk-NU3X7P4N.js";import"./chunk-DPA26AOI.js";import"./chunk-S6KP52OG.js";import{e as D,f as I}from"./chunk-6NLB5TZ2.js";import"./chunk-64X5DLH5.js";import"./chunk-PHAMF4JF.js";import{b as T,e as l,f as i}from"./chunk-G3SZDPDS.js";import"./chunk-PSANHDZM.js";var c=process.stdout,R=22,E=20,C=E/2,B=(t,n)=>Math.abs(n)<=Math.min(1-.417*Math.abs(t),2.393*(1-Math.abs(t))),et=(t,n)=>t*t+n*n<=1;function rt(t){let n=.62**-t,m=[];for(let r=0;r<E;r++){let a=[];for(let s=0;s<R;s++){let w=(s+.5)/R*2-1,f=(r+.5)/E*2-1,h=!1;if(B(w,f))for(let x=0;x<6;x++)for(let $ of[!1,!0]){let p=.62**x*($?.77:1)*n,y=.5*Math.max(0,1-p)**2;($?et:B)(w/p,(f-y)/p)&&(h=!$)}a.push(h)}m.push(a)}return m}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"]},K="CONFORM.TOOLS",st=[...K].reduce((t,n)=>t+M[n][0].length+1,-1);async function q(t){if(!c.isTTY)return!1;let n=!!T("NO_COLOR"),m=/truecolor|24bit/i.test(T("COLORTERM")??""),r=o=>e=>n?e:`\x1B[${o}m${e}\x1B[0m`,a=r(m?"38;2;255;60;0":"38;5;202"),s=r(m?"38;2;255;222;0":"38;5;220"),w=r("1"),f=r("2"),h=(c.columns??80)>=R+4+st,x=o=>[...K].map(e=>e==="."?a(M[e][o]):w(M[e][o])).join(" "),$=(o,e)=>h&&o>=2&&o<=5?x(o-2):!h&&o===3?`${w("conform")}${a(".")}${w("tools")}`:o===7?e:"",p=(o,e,O=[])=>{let S=rt(o),_=[];for(let g=0;g<C;g++){let tt=S[2*g].map((N,nt)=>{let k=S[2*g+1][nt];return N&&k?"\u2588":N?"\u2580":k?"\u2584":" "}).join(""),ot=g>=8?O[g-8]??"":"";_.push(` ${a(tt)} ${ot||$(g,e)}\x1B[K`)}return _.join(`
|
|
4
4
|
`)+`
|
|
5
|
-
`},
|
|
6
|
-
`),
|
|
7
|
-
`);return
|
|
8
|
-
`),!0}var
|
|
5
|
+
`},y=null;t.account.then(o=>{y=o});let P=o=>W(o,24),X=!T("CI")&&T("TERM")!=="dumb";if(c.write(`
|
|
6
|
+
`),X){let o=()=>c.write("\x1B[?25h");process.once("SIGINT",()=>{o(),process.exit(130)}),c.write("\x1B[?25l"+p(0,s(`\u25B6 ${P(0)}`)));let e=Date.now(),O=0;for(;y===null||Date.now()-e<900;)await new Promise(S=>setTimeout(S,1e3/24)),O=Math.round((Date.now()-e)*24/1e3),c.write(`\x1B[${C}A\r`+p(O/22%1,`${s(`\u25B6 ${P(O)}`)} ${f("checking your account\u2026")}`));c.write(`\x1B[${C}A\r`),o()}let Z=(y??await t.account).split(`
|
|
7
|
+
`);return c.write(p(0,`${f("v")}${t.version} ${f("\xB7 built by post pros")}`,Z.map(o=>f(o)))),c.write(`
|
|
8
|
+
`),!0}var Q=()=>q({version:A,account:Promise.race([D().catch(()=>null),new Promise(t=>setTimeout(t,1500,null))]).then(t=>t?I(t):"account: no answer (offline?)")}),it={login:"account_login",logout:"account_logout",whoami:"account_status",status:"account_status",telemetry:"account_telemetry"};l()[0]==="mcp"&&(await import("./mcp.js"),await new Promise(()=>{}));l()[0]==="http"&&(await import("./http.js"),await new Promise(()=>{}));l()[0]==="statusline"&&((await import("./statusline-GMMCFMOA.js")).main(),i(0));if(l()[0]==="setup"){let t=l()[1];t!=="claude"&&t!=="codex"&&(console.error(`conformtools setup <client>: supported: claude, codex${t?` (not ${t} yet)`:""}`),i(2));let{setupClaude:n,setupText:m,setupCodex:r,codexText:a}=await import("./claude-setup-REU4AOKX.js");try{console.log(t==="codex"?a(await r()):m(await n())),i(0)}catch(s){console.error(s instanceof Error?s.message:String(s)),i(1)}}H("cli");var z=l().includes("--json"),[u,v]=l().filter(t=>t!=="--json");if(!u||u==="--list"||u==="help"||u==="--help"){await Q(),console.log(`conformtools <verb> '<json args>' [--json]
|
|
9
9
|
|
|
10
10
|
login / whoami / logout sign in with your conform.tools Google account
|
|
11
11
|
telemetry on|off|status outcome telemetry (on by default, content-free; see the README, Feedback and privacy)
|
|
12
12
|
mcp run as an MCP server (stdio) for Claude Code, Cursor, Codex\u2026
|
|
13
13
|
http run the local HTTP API on 127.0.0.1:7791
|
|
14
|
-
`);let t=L()==="hosted";for(let n of
|
|
15
|
-
(on conform.tools) = the timeline is read or written by conform.tools; the file and its media stay here`),
|
|
14
|
+
`);let t=L()==="hosted";for(let n of V)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`),i(0)}var d=it[u]??u,ct=Y(d);ct||(console.error(`unknown verb '${u}' \u2014 conformtools --list`),i(2));d==="account_login"&&console.error("opening the browser to sign in to conform.tools\u2026");var at=d==="account_telemetry"&&v&&!v.trim().startsWith("{")?JSON.stringify({action:v.trim()}):v,U;try{U=JSON.parse(at??"{}")}catch{console.error(`arguments must be JSON, e.g. conformtools ${u} '{"path":"\u2026"}'`),i(2)}var j=G(d,U),b=j.ok?await F(d,j.data):j.result;d==="account_login"&&!b.isError&&!z&&await Q()||console.log(z?JSON.stringify(b.structuredContent??{ok:!b.isError,text:b.content.map(t=>t.text).join(`
|
|
16
16
|
`)},null,1):b.content.map(t=>t.text).join(`
|
|
17
|
-
`));await J();
|
|
17
|
+
`));await J();i(b.isError?1:0);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
|
|
3
|
-
import{a,b}from"./chunk-
|
|
3
|
+
import{a,b}from"./chunk-WJ5EWXP2.js";import"./chunk-DPA26AOI.js";import"./chunk-PSANHDZM.js";export{b as decodeCr3Wasm,a as inspectCr3Wasm};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
|
|
3
|
-
import{a,b,c}from"./chunk-
|
|
3
|
+
import{a,b,c}from"./chunk-EEDLRRKU.js";import"./chunk-DKGGJM6Z.js";import"./chunk-DPA26AOI.js";import"./chunk-PSANHDZM.js";export{c as decodeDngPreviewWasm,b as decodeDngWasm,a as inspectDngWasm};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
|
|
3
|
-
import{a,b,c}from"./chunk-
|
|
3
|
+
import{a,b,c}from"./chunk-ISKNIQVO.js";import"./chunk-DKGGJM6Z.js";import"./chunk-DPA26AOI.js";import"./chunk-PSANHDZM.js";export{c as decodeDpxPreviewWasm,b as decodeDpxWasm,a as inspectDpxWasm};
|