@hyperframes/producer 0.9.100 → 0.9.102

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.
@@ -10,11 +10,11 @@ import {
10
10
  cpSync as cpSync2,
11
11
  existsSync as existsSync20,
12
12
  linkSync,
13
- mkdirSync as mkdirSync10,
13
+ mkdirSync as mkdirSync11,
14
14
  rmSync as rmSync8,
15
- writeFileSync as writeFileSync8
15
+ writeFileSync as writeFileSync9
16
16
  } from "node:fs";
17
- import { extname as extname4, isAbsolute as isAbsolute4, join as join28, relative as relative7, sep as sep4 } from "node:path";
17
+ import { extname as extname4, isAbsolute as isAbsolute4, join as join29, relative as relative7, sep as sep4 } from "node:path";
18
18
  import {
19
19
  fpsToNumber as fpsToNumber9,
20
20
  HF_COLOR_GRADING_ATTR as HF_COLOR_GRADING_ATTR2
@@ -149,11 +149,11 @@ function formatExportFrameName(index, ext) {
149
149
  import { audioFailureDiagnostics as audioFailureDiagnostics2, cpuBudget } from "@hyperframes/engine";
150
150
  import {
151
151
  existsSync as existsSync15,
152
- mkdirSync as mkdirSync6,
152
+ mkdirSync as mkdirSync7,
153
153
  readdirSync as readdirSync3,
154
154
  rmSync as rmSync6,
155
155
  statSync as statSync7,
156
- writeFileSync as writeFileSync5,
156
+ writeFileSync as writeFileSync6,
157
157
  copyFileSync as copyFileSync5,
158
158
  appendFileSync
159
159
  } from "fs";
@@ -380,7 +380,7 @@ import {
380
380
  referenceBackgroundResult,
381
381
  createReferenceBackgroundRecorder
382
382
  } from "@hyperframes/engine";
383
- import { join as join19, dirname as dirname12, resolve as resolve8 } from "path";
383
+ import { join as join20, dirname as dirname12, resolve as resolve8 } from "path";
384
384
  import { fromEmptyFolder } from "@hyperframes/parsers/ff-binaries";
385
385
  import { randomUUID as randomUUID3 } from "crypto";
386
386
 
@@ -6272,8 +6272,8 @@ async function runCompileStage(input) {
6272
6272
  }
6273
6273
 
6274
6274
  // src/services/render/stages/probeStage.ts
6275
- import { createHash as createHash6 } from "node:crypto";
6276
- import { basename as basename4, join as join12 } from "node:path";
6275
+ import { createHash as createHash7 } from "node:crypto";
6276
+ import { basename as basename4, join as join13 } from "node:path";
6277
6277
  import { parseHTML as parseHTML6 } from "@hyperframes/parsers/linkedom";
6278
6278
  import {
6279
6279
  closeCaptureSession as closeCaptureSession4,
@@ -6326,6 +6326,211 @@ function resolveCaptureSurface(input, quality) {
6326
6326
  };
6327
6327
  }
6328
6328
 
6329
+ // src/services/render/stages/runtimeAudio.ts
6330
+ import { createHash as createHash6 } from "node:crypto";
6331
+ import { mkdirSync as mkdirSync5, writeFileSync as writeFileSync4 } from "node:fs";
6332
+ import { join as join12 } from "node:path";
6333
+ var RUNTIME_AUDIO_SUBDIR = "__hf_runtime_audio";
6334
+ var MAX_INLINE_AUDIO_BYTES = 64 * 1024 * 1024;
6335
+ var MAX_TOTAL_INLINE_AUDIO_BYTES = 128 * 1024 * 1024;
6336
+ var MIME_EXTENSIONS = {
6337
+ "audio/wav": ".wav",
6338
+ "audio/wave": ".wav",
6339
+ "audio/x-wav": ".wav",
6340
+ "audio/mpeg": ".mp3",
6341
+ "audio/mp3": ".mp3",
6342
+ "audio/ogg": ".ogg",
6343
+ "audio/webm": ".webm",
6344
+ "audio/aac": ".m4a",
6345
+ "audio/mp4": ".m4a",
6346
+ "audio/m4a": ".m4a",
6347
+ "audio/x-m4a": ".m4a",
6348
+ "audio/flac": ".flac",
6349
+ "audio/x-flac": ".flac"
6350
+ };
6351
+ var BASE64_BODY = /^[A-Za-z0-9+/]*={0,2}$/;
6352
+ function extensionForMime(mimeType) {
6353
+ const normalized = mimeType.split(";", 1)[0]?.trim().toLowerCase() ?? "";
6354
+ return MIME_EXTENSIONS[normalized] ?? ".bin";
6355
+ }
6356
+ function sameOriginBlobPrefix(fileServerUrl) {
6357
+ try {
6358
+ return `blob:${new URL(fileServerUrl).origin}/`.toLowerCase();
6359
+ } catch {
6360
+ return null;
6361
+ }
6362
+ }
6363
+ function decodeBase64Within(raw, maxBytes) {
6364
+ const compact = raw.replace(/\s+/g, "");
6365
+ if (compact.length === 0 || compact.length % 4 === 1) return null;
6366
+ const maxChars = Math.ceil(maxBytes / 3) * 4;
6367
+ if (compact.length > maxChars || !BASE64_BODY.test(compact)) return null;
6368
+ const bytes = Buffer.from(compact, "base64");
6369
+ return bytes.byteLength > 0 && bytes.byteLength <= maxBytes ? bytes : null;
6370
+ }
6371
+ function decodePercentWithin(payload, maxBytes) {
6372
+ if (payload.length > maxBytes * 3) return null;
6373
+ try {
6374
+ const bytes = Buffer.from(decodeURIComponent(payload), "utf8");
6375
+ return bytes.byteLength > 0 && bytes.byteLength <= maxBytes ? bytes : null;
6376
+ } catch {
6377
+ return null;
6378
+ }
6379
+ }
6380
+ function parseDataHeader(header) {
6381
+ const parts = header.split(";").map((part) => part.trim()).filter(Boolean);
6382
+ const isBase64 = parts.at(-1)?.toLowerCase() === "base64";
6383
+ const first = parts[0] ?? "";
6384
+ const isMime = Boolean(first) && !first.includes("=") && first.toLowerCase() !== "base64";
6385
+ return { isBase64, mimeType: isMime ? first.toLowerCase() : "" };
6386
+ }
6387
+ function decodeDataAudioUri(uri, maxBytes) {
6388
+ const comma = uri.indexOf(",");
6389
+ if (comma < 5) return { ok: false, reason: "malformed_data_uri" };
6390
+ const payload = uri.slice(comma + 1);
6391
+ if (!payload) return { ok: false, reason: "empty" };
6392
+ const { isBase64, mimeType } = parseDataHeader(uri.slice(5, comma));
6393
+ const bytes = isBase64 ? decodeBase64Within(payload, maxBytes) : decodePercentWithin(payload, maxBytes);
6394
+ return bytes ? { ok: true, bytes, mimeType } : { ok: false, reason: "invalid_or_too_large" };
6395
+ }
6396
+ function writeRuntimeAudio(compiledDir, bytes, mimeType) {
6397
+ const digest = createHash6("sha256").update(bytes).digest("hex").slice(0, 16);
6398
+ const filename = `${digest}${extensionForMime(mimeType)}`;
6399
+ const dir = join12(compiledDir, RUNTIME_AUDIO_SUBDIR);
6400
+ mkdirSync5(dir, { recursive: true });
6401
+ const target = join12(dir, filename);
6402
+ try {
6403
+ writeFileSync4(target, bytes, { flag: "wx" });
6404
+ } catch (error) {
6405
+ if (error.code !== "EEXIST") throw error;
6406
+ }
6407
+ return `${RUNTIME_AUDIO_SUBDIR}/${filename}`;
6408
+ }
6409
+ async function readBlobFromPage(page, url, maxBytes) {
6410
+ const result = await page.evaluate(
6411
+ async (blobUrl, limit) => {
6412
+ try {
6413
+ const response = await fetch(blobUrl);
6414
+ if (!response.ok) return { ok: false, reason: `status_${response.status}` };
6415
+ const blob = await response.blob();
6416
+ if (blob.size <= 0) return { ok: false, reason: "empty" };
6417
+ if (blob.size > limit) return { ok: false, reason: "too_large" };
6418
+ const dataUrl = await new Promise((resolve11, reject) => {
6419
+ const reader = new FileReader();
6420
+ reader.onload = () => resolve11(String(reader.result ?? ""));
6421
+ reader.onerror = () => reject(reader.error ?? new Error("read failed"));
6422
+ reader.readAsDataURL(blob);
6423
+ });
6424
+ const comma = dataUrl.indexOf(",");
6425
+ return comma < 0 ? { ok: false, reason: "invalid_data_url" } : { ok: true, base64: dataUrl.slice(comma + 1), mimeType: blob.type || "" };
6426
+ } catch {
6427
+ return { ok: false, reason: "fetch_failed" };
6428
+ }
6429
+ },
6430
+ url,
6431
+ maxBytes
6432
+ );
6433
+ if (!result || typeof result !== "object") return { ok: false, reason: "invalid_response" };
6434
+ const typed = result;
6435
+ if (typed.ok === true && typeof typed.base64 === "string") {
6436
+ return {
6437
+ ok: true,
6438
+ base64: typed.base64,
6439
+ mimeType: typeof typed.mimeType === "string" ? typed.mimeType : ""
6440
+ };
6441
+ }
6442
+ const reason = typed.ok === false && typeof typed.reason === "string" ? typed.reason : "read_failed";
6443
+ return { ok: false, reason };
6444
+ }
6445
+ async function materializeOneBlob(audio, page, compiledDir, clipLimit, log, assertNotAborted) {
6446
+ if (clipLimit <= 0) {
6447
+ log?.warn("[Probe] Runtime audio byte limit reached; cannot materialize blob", {
6448
+ id: audio.id
6449
+ });
6450
+ return null;
6451
+ }
6452
+ const read2 = await readBlobFromPage(page, audio.src, clipLimit);
6453
+ assertNotAborted?.();
6454
+ if (!read2.ok) {
6455
+ log?.warn("[Probe] Could not materialize blob audio source", {
6456
+ id: audio.id,
6457
+ reason: read2.reason
6458
+ });
6459
+ return null;
6460
+ }
6461
+ const bytes = decodeBase64Within(read2.base64, clipLimit);
6462
+ if (!bytes) {
6463
+ log?.warn("[Probe] Blob audio payload was empty, invalid, or exceeded limit", {
6464
+ id: audio.id
6465
+ });
6466
+ return null;
6467
+ }
6468
+ return { path: writeRuntimeAudio(compiledDir, bytes, read2.mimeType), bytes: bytes.byteLength };
6469
+ }
6470
+ async function materializeBlobAudioSources(input) {
6471
+ const prefix = sameOriginBlobPrefix(input.fileServerUrl);
6472
+ if (!prefix) return;
6473
+ const maxPerClip = input.limits?.maxPerClipBytes ?? MAX_INLINE_AUDIO_BYTES;
6474
+ let remaining = input.limits?.maxTotalBytes ?? MAX_TOTAL_INLINE_AUDIO_BYTES;
6475
+ const cachedByUrl = /* @__PURE__ */ new Map();
6476
+ for (const audio of input.audios) {
6477
+ if (!/^blob:/i.test(audio.src)) continue;
6478
+ const cached = cachedByUrl.get(audio.src);
6479
+ if (cached) {
6480
+ audio.src = cached;
6481
+ continue;
6482
+ }
6483
+ if (!audio.src.toLowerCase().startsWith(prefix)) {
6484
+ input.log?.warn("[Probe] Skipping cross-origin blob audio source", { id: audio.id });
6485
+ continue;
6486
+ }
6487
+ const written = await materializeOneBlob(
6488
+ audio,
6489
+ input.page,
6490
+ input.compiledDir,
6491
+ Math.min(maxPerClip, remaining),
6492
+ input.log,
6493
+ input.assertNotAborted
6494
+ );
6495
+ if (!written) continue;
6496
+ remaining -= written.bytes;
6497
+ cachedByUrl.set(audio.src, written.path);
6498
+ audio.src = written.path;
6499
+ }
6500
+ }
6501
+ function materializeDataAudioSources(input) {
6502
+ const maxPerClip = input.limits?.maxPerClipBytes ?? MAX_INLINE_AUDIO_BYTES;
6503
+ let remaining = input.limits?.maxTotalBytes ?? MAX_TOTAL_INLINE_AUDIO_BYTES;
6504
+ const cachedByUri = /* @__PURE__ */ new Map();
6505
+ for (const audio of input.audios) {
6506
+ if (!/^data:/i.test(audio.src)) continue;
6507
+ const cached = cachedByUri.get(audio.src);
6508
+ if (cached) {
6509
+ audio.src = cached;
6510
+ continue;
6511
+ }
6512
+ const clipLimit = Math.min(maxPerClip, remaining);
6513
+ if (clipLimit <= 0) {
6514
+ input.log?.warn("[Probe] Inline audio byte limit reached; cannot materialize data URI", {
6515
+ id: audio.id
6516
+ });
6517
+ continue;
6518
+ }
6519
+ const decoded = decodeDataAudioUri(audio.src, clipLimit);
6520
+ if (!decoded.ok) {
6521
+ input.log?.warn("[Probe] Could not materialize data audio source", {
6522
+ id: audio.id,
6523
+ reason: decoded.reason
6524
+ });
6525
+ continue;
6526
+ }
6527
+ remaining -= decoded.bytes.byteLength;
6528
+ const relativePath = writeRuntimeAudio(input.compiledDir, decoded.bytes, decoded.mimeType);
6529
+ cachedByUri.set(audio.src, relativePath);
6530
+ audio.src = relativePath;
6531
+ }
6532
+ }
6533
+
6329
6534
  // src/services/render/stages/probeStage.ts
6330
6535
  var FRAME_BOUNDARY_EPSILON = 1e-3;
6331
6536
  function durationToFrameCount(duration, fps) {
@@ -6508,6 +6713,7 @@ function hasRuntimeMediaChanges(html) {
6508
6713
  if (insertedMedia) return true;
6509
6714
  const managed = managedMediaElements(document2, false);
6510
6715
  if (managed.length === 0) return false;
6716
+ if (scriptBodies.some((script) => /\bcreateObjectURL\s*\(/.test(script))) return true;
6511
6717
  const managedIds = new Set(managed.map((m) => m.element.getAttribute("id")).filter(Boolean));
6512
6718
  const selectors = /* @__PURE__ */ new Set();
6513
6719
  let work = 0;
@@ -6548,7 +6754,7 @@ function reportedLengthSource(source) {
6548
6754
  if (!source) return null;
6549
6755
  if (source.from !== "media") return { from: source.from };
6550
6756
  const name = basename4(source.src.split(/[?#]/, 1)[0] ?? "");
6551
- const srcHash = createHash6("sha256").update(name).digest("hex").slice(0, 12);
6757
+ const srcHash = createHash7("sha256").update(name).digest("hex").slice(0, 12);
6552
6758
  return { from: "media", tag: source.tag, trimmed: source.trimmed, srcHash };
6553
6759
  }
6554
6760
  var STOPPED = "Preparing the render stopped while ";
@@ -6623,7 +6829,7 @@ async function runProbeStage(input) {
6623
6829
  });
6624
6830
  fileServer = await createFileServer({
6625
6831
  projectDir,
6626
- compiledDir: join12(workDir, "compiled"),
6832
+ compiledDir: join13(workDir, "compiled"),
6627
6833
  port: 0,
6628
6834
  preHeadScripts: [VIRTUAL_TIME_SHIM],
6629
6835
  fps: job.config.fps,
@@ -6637,7 +6843,7 @@ async function runProbeStage(input) {
6637
6843
  composition.videos,
6638
6844
  compiled.html,
6639
6845
  projectDir,
6640
- join12(workDir, "compiled")
6846
+ join13(workDir, "compiled")
6641
6847
  ),
6642
6848
  recordReferenceBackground: input.recordReferenceBackground,
6643
6849
  width,
@@ -6666,7 +6872,7 @@ async function runProbeStage(input) {
6666
6872
  log.info("Creating capture session...", { attempt, maxAttempts: PROBE_MAX_ATTEMPTS });
6667
6873
  probeSession = await createCaptureSession4(
6668
6874
  fileServer.url,
6669
- join12(workDir, "probe"),
6875
+ join13(workDir, "probe"),
6670
6876
  captureOpts,
6671
6877
  null,
6672
6878
  probeCfg
@@ -6752,7 +6958,7 @@ async function runProbeStage(input) {
6752
6958
  });
6753
6959
  probeSession = await createCaptureSession4(
6754
6960
  fileServer.url,
6755
- join12(workDir, "probe-screenshot"),
6961
+ join13(workDir, "probe-screenshot"),
6756
6962
  captureOpts,
6757
6963
  null,
6758
6964
  { ...probeCfg, forceScreenshot: true }
@@ -6796,7 +7002,7 @@ async function runProbeStage(input) {
6796
7002
  compiled,
6797
7003
  resolutions,
6798
7004
  projectDir,
6799
- join12(workDir, "downloads"),
7005
+ join13(workDir, "downloads"),
6800
7006
  job.config.allowOutsideProjectAssets ? void 0 : projectDir,
6801
7007
  { includeScripts: job.config.includeOutsideScripts }
6802
7008
  );
@@ -6945,6 +7151,21 @@ async function runProbeStage(input) {
6945
7151
  }
6946
7152
  }
6947
7153
  }
7154
+ if (fileServer && composition.audios.length > 0) {
7155
+ const compiledDir = join13(workDir, "compiled");
7156
+ const serverUrl = fileServer.url;
7157
+ await probeStep(
7158
+ "reading runtime audio from the browser",
7159
+ () => materializeBlobAudioSources({
7160
+ page: session.page,
7161
+ fileServerUrl: serverUrl,
7162
+ audios: composition.audios,
7163
+ compiledDir,
7164
+ log,
7165
+ assertNotAborted
7166
+ })
7167
+ );
7168
+ }
6948
7169
  if (composition.audios.length > 0) {
6949
7170
  log.info("Discovering audio volume automation...", {
6950
7171
  audioCount: composition.audios.length
@@ -6993,6 +7214,11 @@ async function runProbeStage(input) {
6993
7214
  }
6994
7215
  }
6995
7216
  }
7217
+ materializeDataAudioSources({
7218
+ audios: composition.audios,
7219
+ compiledDir: join13(workDir, "compiled"),
7220
+ log
7221
+ });
6996
7222
  dropMediaOutsideProject({
6997
7223
  projectDir,
6998
7224
  workDir,
@@ -7002,7 +7228,7 @@ async function runProbeStage(input) {
7002
7228
  });
7003
7229
  await preflightCompositionAssetMediaTypes({
7004
7230
  projectDir,
7005
- compiledDir: join12(workDir, "compiled"),
7231
+ compiledDir: join13(workDir, "compiled"),
7006
7232
  composition,
7007
7233
  signal: abortSignal
7008
7234
  });
@@ -7170,7 +7396,7 @@ function validateDistributedDuration(input) {
7170
7396
 
7171
7397
  // src/services/render/stages/extractVideosStage.ts
7172
7398
  import { existsSync as existsSync10 } from "node:fs";
7173
- import { join as join13 } from "node:path";
7399
+ import { join as join14 } from "node:path";
7174
7400
  import {
7175
7401
  classifyVideoExtractionError,
7176
7402
  createFrameLookupTable as createFrameLookupTable3,
@@ -7540,7 +7766,7 @@ async function runExtractVideosStage(input) {
7540
7766
  // because short boundary counts can differ by one frame.
7541
7767
  {
7542
7768
  fps: job.config.fps,
7543
- outputDir: join13(compiledDir, "__hyperframes_video_frames"),
7769
+ outputDir: join14(compiledDir, "__hyperframes_video_frames"),
7544
7770
  format: job.config.videoFrameFormat ?? "auto",
7545
7771
  toneMapHdrToSdr: rendersSdrOnly(job.config, composition),
7546
7772
  timelineEnd: composition.duration,
@@ -7548,7 +7774,7 @@ async function runExtractVideosStage(input) {
7548
7774
  collectProbeFailures: extractionPolicy.failureMode === "enforce",
7549
7775
  deferRangeExtraction,
7550
7776
  shownBoxes,
7551
- contentKeyedDirs: [join13(compiledDir, REMOTE_MEDIA_SUBDIR)],
7777
+ contentKeyedDirs: [join14(compiledDir, REMOTE_MEDIA_SUBDIR)],
7552
7778
  urlByAbsentLocalPath,
7553
7779
  assetRoots,
7554
7780
  onProgress: ({ planned = 0, done = 0 }) => {
@@ -7640,7 +7866,7 @@ async function remoteProbeSource(video, input) {
7640
7866
  if (!isPublicHttpsUrl(video.src)) return null;
7641
7867
  if (!resolveRestrictPageNetwork()) return video.src;
7642
7868
  if (!video.hasAudio || video.hidden) return null;
7643
- const downloadDir = input.downloadDir ?? join13(input.compiledDir, REMOTE_MEDIA_SUBDIR);
7869
+ const downloadDir = input.downloadDir ?? join14(input.compiledDir, REMOTE_MEDIA_SUBDIR);
7644
7870
  try {
7645
7871
  return await downloadToTemp2(video.src, downloadDir, void 0, input.signal, void 0, {
7646
7872
  onTelemetry: writeUrlDownloadTelemetry2
@@ -7690,7 +7916,7 @@ import {
7690
7916
 
7691
7917
  // src/services/render/stages/audioStage.ts
7692
7918
  import { existsSync as existsSync12 } from "node:fs";
7693
- import { join as join16 } from "node:path";
7919
+ import { join as join17 } from "node:path";
7694
7920
  import {
7695
7921
  MIXED_AUDIO_FILENAME,
7696
7922
  audioFailureDiagnostics,
@@ -7702,7 +7928,7 @@ import {
7702
7928
 
7703
7929
  // src/services/render/audioDeliveryLimit.ts
7704
7930
  import { existsSync as existsSync11 } from "node:fs";
7705
- import { dirname as dirname10, join as join15 } from "node:path";
7931
+ import { dirname as dirname10, join as join16 } from "node:path";
7706
7932
  import {
7707
7933
  applyAudioFxChain,
7708
7934
  describeFfmpegFailure as describeFfmpegFailure3,
@@ -7713,7 +7939,7 @@ import {
7713
7939
  // src/services/render/audioPadTrim.ts
7714
7940
  import { ffmpegCwd as ffmpegCwd2, localContainerInputArgs } from "@hyperframes/parsers/ff-binaries";
7715
7941
  import { spawn } from "node:child_process";
7716
- import { dirname as dirname9, join as join14 } from "node:path";
7942
+ import { dirname as dirname9, join as join15 } from "node:path";
7717
7943
  import {
7718
7944
  DEFAULT_CONFIG,
7719
7945
  describeFfmpegFailure as describeFfmpegFailure2,
@@ -7994,7 +8220,7 @@ async function constrainAacTruePeak(input) {
7994
8220
  }
7995
8221
  async function cutSource(input, scratchDir, attenuationDb) {
7996
8222
  if (!input.sourcePath || !input.rewriteSource) return true;
7997
- const cutPath = join14(scratchDir, "source.wav");
8223
+ const cutPath = join15(scratchDir, "source.wav");
7998
8224
  try {
7999
8225
  const result = await input.rewriteSource(input.sourcePath, cutPath, gainFilter(attenuationDb));
8000
8226
  if (!result.success) throw new Error(result.error);
@@ -8009,7 +8235,7 @@ async function enforceAacTruePeak(input) {
8009
8235
  let scratchDir;
8010
8236
  try {
8011
8237
  scratchDir = createStagingDir3(dirname9(input.audioPath), ".true-peak-");
8012
- const correctedPath = join14(scratchDir, "audio.m4a");
8238
+ const correctedPath = join15(scratchDir, "audio.m4a");
8013
8239
  const measurements = [];
8014
8240
  let attenuationDb = 0;
8015
8241
  let sourcePeakDbfs;
@@ -8233,7 +8459,7 @@ async function limitDeliveryPeaks(input, deps = {
8233
8459
  const peak = await deps.measure(audioPath, { timeoutMs, signal });
8234
8460
  if (peak <= AAC_DELIVERY_TRUE_PEAK_DBFS) return { success: true };
8235
8461
  const alternating = ["a", "b"].map(
8236
- (k) => join15(dirname10(sourcePath), `audio-source-limited-${k}.wav`)
8462
+ (k) => join16(dirname10(sourcePath), `audio-source-limited-${k}.wav`)
8237
8463
  );
8238
8464
  let encodedFrom;
8239
8465
  let ceiling = AAC_DELIVERY_TRUE_PEAK_DBFS;
@@ -8306,7 +8532,7 @@ function runAudioStage(input) {
8306
8532
  }
8307
8533
  async function runAudioStageScoped(input) {
8308
8534
  const stageStart = Date.now();
8309
- const pcmSourcePath = join16(input.workDir, "audio-source.wav");
8535
+ const pcmSourcePath = join17(input.workDir, "audio-source.wav");
8310
8536
  const seconds = (frames) => frames * input.fps.den / input.fps.num;
8311
8537
  const duration = seconds(input.totalFrames);
8312
8538
  const window2 = input.frameWindow && {
@@ -8376,7 +8602,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath, window2) {
8376
8602
  assertNotAborted,
8377
8603
  log
8378
8604
  } = input;
8379
- const audioOutputPath = join16(workDir, MIXED_AUDIO_FILENAME);
8605
+ const audioOutputPath = join17(workDir, MIXED_AUDIO_FILENAME);
8380
8606
  let hasAudio = false;
8381
8607
  let audioError;
8382
8608
  let audioFailures;
@@ -8458,7 +8684,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath, window2) {
8458
8684
 
8459
8685
  // src/services/render/stages/captureStage.ts
8460
8686
  import { existsSync as existsSync13, readdirSync, statfsSync } from "node:fs";
8461
- import { join as join17 } from "node:path";
8687
+ import { join as join18 } from "node:path";
8462
8688
  import {
8463
8689
  classifyCaptureFailure as classifyCaptureFailure2,
8464
8690
  frameFileExtension,
@@ -8513,13 +8739,13 @@ function measureCaptureFrameBytes(workDir, framesDir) {
8513
8739
  if (!existsSync13(workDir)) return total;
8514
8740
  for (const attempt of readdirSync(workDir)) {
8515
8741
  if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
8516
- total += sampleDirectoryBytes(join17(workDir, attempt));
8742
+ total += sampleDirectoryBytes(join18(workDir, attempt));
8517
8743
  continue;
8518
8744
  }
8519
8745
  if (!/^capture-attempt-\d+$/.test(attempt)) continue;
8520
- const attemptDir = join17(workDir, attempt);
8746
+ const attemptDir = join18(workDir, attempt);
8521
8747
  for (const name of readdirSync(attemptDir)) {
8522
- if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join17(attemptDir, name));
8748
+ if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join18(attemptDir, name));
8523
8749
  }
8524
8750
  }
8525
8751
  return total;
@@ -8873,15 +9099,15 @@ import { usableCpuCount } from "@hyperframes/engine";
8873
9099
  import {
8874
9100
  copyFileSync as copyFileSync4,
8875
9101
  existsSync as existsSync14,
8876
- mkdirSync as mkdirSync5,
9102
+ mkdirSync as mkdirSync6,
8877
9103
  readdirSync as readdirSync2,
8878
9104
  readFileSync as readFileSync6,
8879
9105
  rmSync as rmSync5,
8880
9106
  statSync as statSync6,
8881
- writeFileSync as writeFileSync4
9107
+ writeFileSync as writeFileSync5
8882
9108
  } from "node:fs";
8883
9109
  import { readFile as readFile2 } from "node:fs/promises";
8884
- import { dirname as dirname11, join as join18 } from "node:path";
9110
+ import { dirname as dirname11, join as join19 } from "node:path";
8885
9111
  import {
8886
9112
  encodeFramesChunkedConcat,
8887
9113
  encodeFramesFromDir,
@@ -8974,7 +9200,7 @@ async function reencodeWithClearedWholeFrames(argsInput, run, startTime) {
8974
9200
  const error = "[FFmpeg] GIF output could not be parsed to clear its frames";
8975
9201
  return gifEncodeFailure(startTime, outputPath, error);
8976
9202
  }
8977
- writeFileSync4(outputPath, gif);
9203
+ writeFileSync5(outputPath, gif);
8978
9204
  return null;
8979
9205
  }
8980
9206
  async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
@@ -9100,7 +9326,7 @@ function encodeWhileCapturing(input, totalFrames, captureBudget) {
9100
9326
  await new Promise((resolve11) => wake = resolve11);
9101
9327
  }
9102
9328
  if (signal.aborted) return;
9103
- const mergedPath = join18(input.framesDir, formatCaptureFrameName(next, "jpg"));
9329
+ const mergedPath = join19(input.framesDir, formatCaptureFrameName(next, "jpg"));
9104
9330
  const frame = await readLandedFrame(landed.get(next), mergedPath);
9105
9331
  landed.delete(next);
9106
9332
  if (!await stream.writeFrame(frame)) {
@@ -9175,7 +9401,7 @@ async function runEncodeStage(input) {
9175
9401
  const stage5Start = Date.now();
9176
9402
  if (isPngSequence) {
9177
9403
  const encoded = startEncodeProgress(job, "Writing PNG sequence", onProgress);
9178
- if (!existsSync14(outputPath)) mkdirSync5(outputPath, { recursive: true });
9404
+ if (!existsSync14(outputPath)) mkdirSync6(outputPath, { recursive: true });
9179
9405
  const captured = readdirSync2(framesDir).filter((name) => name.endsWith(".png")).sort();
9180
9406
  if (captured.length === 0) {
9181
9407
  throw new Error(
@@ -9183,11 +9409,11 @@ async function runEncodeStage(input) {
9183
9409
  );
9184
9410
  }
9185
9411
  captured.forEach((name, i) => {
9186
- const dst = join18(outputPath, formatExportFrameName(i, "png"));
9187
- copyFileSync4(join18(framesDir, name), dst);
9412
+ const dst = join19(outputPath, formatExportFrameName(i, "png"));
9413
+ copyFileSync4(join19(framesDir, name), dst);
9188
9414
  });
9189
9415
  if (hasAudio && audioOutputPath && existsSync14(audioOutputPath)) {
9190
- copyFileSync4(audioOutputPath, join18(outputPath, MIXED_AUDIO_FILENAME2));
9416
+ copyFileSync4(audioOutputPath, join19(outputPath, MIXED_AUDIO_FILENAME2));
9191
9417
  log.info(
9192
9418
  `[Render] png-sequence: ${MIXED_AUDIO_FILENAME2} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME2}`
9193
9419
  );
@@ -9207,7 +9433,7 @@ async function runEncodeStage(input) {
9207
9433
  const encodeResult2 = await encodeGifFromDir(framesDir, framePattern2, outputPath, {
9208
9434
  fps: job.config.fps,
9209
9435
  loop,
9210
- palettePath: join18(dirname11(videoOnlyPath), "gif-palette.png"),
9436
+ palettePath: join19(dirname11(videoOnlyPath), "gif-palette.png"),
9211
9437
  preserveAlpha: needsAlpha,
9212
9438
  signal: abortSignal,
9213
9439
  timeout: engineCfg.ffmpegEncodeTimeout
@@ -9266,7 +9492,7 @@ function sampleDirectoryBytes(dir) {
9266
9492
  continue;
9267
9493
  }
9268
9494
  for (const name of entries) {
9269
- const full = join19(current, name);
9495
+ const full = join20(current, name);
9270
9496
  try {
9271
9497
  const st = statSync7(full);
9272
9498
  if (st.isDirectory()) {
@@ -9348,7 +9574,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
9348
9574
  const ranges = [];
9349
9575
  let rangeStart = null;
9350
9576
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
9351
- const framePath = join19(framesDir, formatCaptureFrameName(frameIndex, frameExt));
9577
+ const framePath = join20(framesDir, formatCaptureFrameName(frameIndex, frameExt));
9352
9578
  const missing = !existsSync15(framePath) || statSync7(framePath).size <= 8;
9353
9579
  if (missing && rangeStart === null) {
9354
9580
  rangeStart = frameIndex;
@@ -9365,7 +9591,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
9365
9591
  function buildMissingFrameRetryBatches(ranges, maxWorkers, workDir, attempt, rangeStart = 0, stride = 1) {
9366
9592
  const workersPerBatch = Math.max(1, Math.floor(maxWorkers));
9367
9593
  const batches = [];
9368
- const outputDirFor = (batchIndex, workerId) => join19(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
9594
+ const outputDirFor = (batchIndex, workerId) => join20(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
9369
9595
  if (stride > 1) {
9370
9596
  const spans = /* @__PURE__ */ new Map();
9371
9597
  for (const range of ranges) {
@@ -9446,7 +9672,7 @@ function isRecoverableParallelCaptureError(error) {
9446
9672
  function countCapturedFrames(totalFrames, framesDir, frameExt) {
9447
9673
  let captured = 0;
9448
9674
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
9449
- const framePath = join19(framesDir, formatCaptureFrameName(frameIndex, frameExt));
9675
+ const framePath = join20(framesDir, formatCaptureFrameName(frameIndex, frameExt));
9450
9676
  if (existsSync15(framePath)) captured++;
9451
9677
  }
9452
9678
  return captured;
@@ -9472,7 +9698,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
9472
9698
  reason: attempt === 0 ? "initial" : pendingTransientRetry ? "transient-retry" : "retry"
9473
9699
  });
9474
9700
  pendingTransientRetry = false;
9475
- const attemptWorkDir = join19(options.workDir, `capture-attempt-${attempt}`);
9701
+ const attemptWorkDir = join20(options.workDir, `capture-attempt-${attempt}`);
9476
9702
  const batches = missingRanges ? buildMissingFrameRetryBatches(
9477
9703
  missingRanges,
9478
9704
  currentWorkers,
@@ -9665,7 +9891,7 @@ function explainStreamingEncodeGate(cfg, outputFormat, workerCount, durationSeco
9665
9891
  var DEFAULT_SEGMENTED_MIN_SECONDS = Number.POSITIVE_INFINITY;
9666
9892
 
9667
9893
  // src/services/distributed/planFrameCost.ts
9668
- import { join as join22 } from "node:path";
9894
+ import { join as join23 } from "node:path";
9669
9895
  import {
9670
9896
  closeCaptureSession as closeCaptureSession9,
9671
9897
  createCaptureSession as createCaptureSession9,
@@ -9675,7 +9901,7 @@ import {
9675
9901
 
9676
9902
  // src/services/distributed/chunkFrames.ts
9677
9903
  import { existsSync as existsSync17, readdirSync as readdirSync4 } from "node:fs";
9678
- import { extname as extname2, join as join21 } from "node:path";
9904
+ import { extname as extname2, join as join22 } from "node:path";
9679
9905
  import {
9680
9906
  compositionRequiresWebGpu as compositionRequiresWebGpu3,
9681
9907
  createVideoFrameInjector as createVideoFrameInjector3,
@@ -9684,7 +9910,7 @@ import {
9684
9910
 
9685
9911
  // src/services/distributed/shared.ts
9686
9912
  import { execFile as execFileCallback } from "node:child_process";
9687
- import { dirname as dirname13, join as join20 } from "node:path";
9913
+ import { dirname as dirname13, join as join21 } from "node:path";
9688
9914
  import { existsSync as existsSync16, readFileSync as readFileSync7 } from "node:fs";
9689
9915
  import { fileURLToPath as fileURLToPath4 } from "node:url";
9690
9916
  import { promisify as promisify2 } from "node:util";
@@ -9700,7 +9926,7 @@ function isPlanAudioArtifactPath(path) {
9700
9926
  }
9701
9927
  function resolvePlanAudioPath(planDir) {
9702
9928
  for (const name of [PLAN_AUDIO_RELATIVE_PATH, PLAN_AUDIO_LEGACY_RELATIVE_PATH]) {
9703
- const candidate = join20(planDir, name);
9929
+ const candidate = join21(planDir, name);
9704
9930
  if (existsSync16(candidate)) return candidate;
9705
9931
  }
9706
9932
  return null;
@@ -9965,7 +10191,7 @@ function readProducerVersion() {
9965
10191
  const startDir = dirname13(fileURLToPath4(import.meta.url));
9966
10192
  let current = startDir;
9967
10193
  for (let i = 0; i < 10; i++) {
9968
- const candidate = join20(current, "package.json");
10194
+ const candidate = join21(current, "package.json");
9969
10195
  if (existsSync16(candidate)) {
9970
10196
  try {
9971
10197
  const pkg = JSON.parse(readFileSync7(candidate, "utf-8"));
@@ -10020,7 +10246,7 @@ function frameNumberFromFileName(name) {
10020
10246
  function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v1") {
10021
10247
  const result = [];
10022
10248
  for (const v of videos) {
10023
- const outputDir = join21(planDir, "video-frames", mediaIdPathSegment3(v.videoId));
10249
+ const outputDir = join22(planDir, "video-frames", mediaIdPathSegment3(v.videoId));
10024
10250
  if (!existsSync17(outputDir)) {
10025
10251
  throw new Error(
10026
10252
  `[renderChunk] planDir missing extracted video frames for ${JSON.stringify(v.videoId)}: ${outputDir} not present. plan() should have written frames here; the planDir is malformed.`
@@ -10039,7 +10265,7 @@ function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v
10039
10265
  if (!frameName) continue;
10040
10266
  const frameNumber = indexMode === "sparse-v2" ? frameNumberFromFileName(frameName) : null;
10041
10267
  const frameIndex = frameNumber === null ? i : frameNumber - 1;
10042
- framePaths.set(frameIndex, join21(outputDir, frameName));
10268
+ framePaths.set(frameIndex, join22(outputDir, frameName));
10043
10269
  }
10044
10270
  result.push({
10045
10271
  videoId: v.videoId,
@@ -10120,7 +10346,7 @@ async function extractDeferredVideoFramesForChunk(input) {
10120
10346
  sourceOf: (video) => {
10121
10347
  const range = planned.get(video.videoId).deferredRange;
10122
10348
  const remoteUrl = remoteSources[range.sourcePath];
10123
- const sourcePath = remoteUrl ?? join21(input.planDir, ...range.sourcePath.split("/"));
10349
+ const sourcePath = remoteUrl ?? join22(input.planDir, ...range.sourcePath.split("/"));
10124
10350
  if (remoteUrl === void 0 && !existsSync17(sourcePath)) {
10125
10351
  throw new RenderChunkValidationError(
10126
10352
  MISSING_PLAN_ARTIFACT,
@@ -10151,12 +10377,12 @@ async function measurePlanSecondsPerFrame(input) {
10151
10377
  planVideos,
10152
10378
  frames: sampled,
10153
10379
  fps: fpsRatio,
10154
- outputRoot: join22(workDir, "frame-cost-video-frames"),
10380
+ outputRoot: join23(workDir, "frame-cost-video-frames"),
10155
10381
  cfg: input.cfg
10156
10382
  })
10157
10383
  ];
10158
10384
  const lookup = extracted.length > 0 ? createFrameLookupTable4(planVideos.videos, extracted, resolveRenderFpsConfig(fpsRatio).value) : null;
10159
- const compiledDir = join22(planDir, "compiled");
10385
+ const compiledDir = join23(planDir, "compiled");
10160
10386
  const fileServer = await createFileServer({
10161
10387
  projectDir: compiledDir,
10162
10388
  compiledDir,
@@ -10168,7 +10394,7 @@ async function measurePlanSecondsPerFrame(input) {
10168
10394
  try {
10169
10395
  session = await createCaptureSession9(
10170
10396
  fileServer.url,
10171
- join22(workDir, "frame-cost"),
10397
+ join23(workDir, "frame-cost"),
10172
10398
  buildChunkCaptureOptions({
10173
10399
  dimensions: { ...input, fpsNum: fps, fpsDen: 1 },
10174
10400
  encoder: input,
@@ -10265,7 +10491,7 @@ function buildWeightedChunkSlices(weights, chunkCount, minFrames, maxFrames) {
10265
10491
  }
10266
10492
 
10267
10493
  // src/services/render/planReferenceBackground.ts
10268
- import { join as join23 } from "node:path";
10494
+ import { join as join24 } from "node:path";
10269
10495
  import {
10270
10496
  closeCaptureSession as closeCaptureSession10,
10271
10497
  createCaptureSession as createCaptureSession10,
@@ -10278,14 +10504,14 @@ async function readPlanReferenceBackground(input) {
10278
10504
  try {
10279
10505
  server = await createFileServer({
10280
10506
  projectDir: input.projectDir,
10281
- compiledDir: join23(input.workDir, "compiled"),
10507
+ compiledDir: join24(input.workDir, "compiled"),
10282
10508
  port: 0,
10283
10509
  preHeadScripts: [VIRTUAL_TIME_SHIM],
10284
10510
  fps: input.options.fps
10285
10511
  });
10286
10512
  session = await createCaptureSession10(
10287
10513
  server.url,
10288
- join23(input.workDir, "reference"),
10514
+ join24(input.workDir, "reference"),
10289
10515
  {
10290
10516
  ...input.options,
10291
10517
  requiresWebGpu: false
@@ -10321,8 +10547,8 @@ async function readPlanReferenceBackground(input) {
10321
10547
  }
10322
10548
 
10323
10549
  // src/services/render/stages/freezePlan.ts
10324
- import { existsSync as existsSync18, mkdirSync as mkdirSync7, readFileSync as readFileSync8, readdirSync as readdirSync5, writeFileSync as writeFileSync6 } from "node:fs";
10325
- import { join as join24, relative as relative5, resolve as resolve9 } from "node:path";
10550
+ import { existsSync as existsSync18, mkdirSync as mkdirSync8, readFileSync as readFileSync8, readdirSync as readdirSync5, writeFileSync as writeFileSync7 } from "node:fs";
10551
+ import { join as join25, relative as relative5, resolve as resolve9 } from "node:path";
10326
10552
  import {
10327
10553
  REFERENCE_BACKGROUND_FIELD,
10328
10554
  referenceBackgroundResult as referenceBackgroundResult3
@@ -10420,12 +10646,12 @@ function readPlanProtocolV1(planJson, capabilities = DISTRIBUTED_RENDER_CAPABILI
10420
10646
  }
10421
10647
 
10422
10648
  // src/services/render/stages/planHash.ts
10423
- import { createHash as createHash7 } from "node:crypto";
10649
+ import { createHash as createHash8 } from "node:crypto";
10424
10650
  import { closeSync as closeSync3, createReadStream as createReadStream3, openSync as openSync3, readSync as readSync2 } from "node:fs";
10425
10651
  var PLAN_HASH_SCHEMA_PREFIX = "hyperframes-plan-hash-v1\0";
10426
10652
  var FIELD_DELIMITER = Buffer.from([0]);
10427
10653
  function computePlanHash(input) {
10428
- const hash = createHash7("sha256");
10654
+ const hash = createHash8("sha256");
10429
10655
  hash.update(PLAN_HASH_SCHEMA_PREFIX, "utf8");
10430
10656
  hash.update(input.compositionHtml);
10431
10657
  hash.update(FIELD_DELIMITER);
@@ -10472,12 +10698,12 @@ function canonicalJsonStringify(value) {
10472
10698
  throw new TypeError(`canonicalJsonStringify: unsupported value type ${typeof value}`);
10473
10699
  }
10474
10700
  function sha256Hex(bytes) {
10475
- const h = createHash7("sha256");
10701
+ const h = createHash8("sha256");
10476
10702
  h.update(bytes);
10477
10703
  return h.digest("hex");
10478
10704
  }
10479
10705
  function sha256File(path) {
10480
- const hash = createHash7("sha256");
10706
+ const hash = createHash8("sha256");
10481
10707
  const buffer = Buffer.allocUnsafe(1024 * 1024);
10482
10708
  const fd = openSync3(path, "r");
10483
10709
  try {
@@ -10492,7 +10718,7 @@ function sha256File(path) {
10492
10718
  return hash.digest("hex");
10493
10719
  }
10494
10720
  async function sha256FileAsync(path) {
10495
- const hash = createHash7("sha256");
10721
+ const hash = createHash8("sha256");
10496
10722
  for await (const chunk of createReadStream3(path, { highWaterMark: 1024 * 1024 })) {
10497
10723
  hash.update(chunk);
10498
10724
  }
@@ -10540,7 +10766,7 @@ function listPlanFiles(planDir) {
10540
10766
  function walk(dir) {
10541
10767
  const entries = readdirSync5(dir, { withFileTypes: true });
10542
10768
  for (const entry of entries) {
10543
- const full = join24(dir, entry.name);
10769
+ const full = join25(dir, entry.name);
10544
10770
  if (entry.isDirectory()) {
10545
10771
  walk(full);
10546
10772
  } else if (entry.isFile()) {
@@ -10581,15 +10807,15 @@ var PLAN_REMOTE_FILES_RELATIVE_PATH = "meta/remote-files.json";
10581
10807
  function writePlanRemoteFiles(planDir, files) {
10582
10808
  if (files.length === 0) return;
10583
10809
  const sorted = [...files].sort((a, b) => a.path < b.path ? -1 : 1);
10584
- writeFileSync6(join24(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH), JSON.stringify(sorted), "utf-8");
10810
+ writeFileSync7(join25(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH), JSON.stringify(sorted), "utf-8");
10585
10811
  }
10586
10812
  function readPlanRemoteFiles(planDir) {
10587
- const path = join24(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH);
10813
+ const path = join25(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH);
10588
10814
  return existsSync18(path) ? JSON.parse(readFileSync8(path, "utf-8")) : [];
10589
10815
  }
10590
10816
  function recomputePlanHashFromPlanDir(planDir, digests) {
10591
- const planJsonPath = join24(planDir, "plan.json");
10592
- const encoderJsonPath = join24(planDir, "meta", "encoder.json");
10817
+ const planJsonPath = join25(planDir, "plan.json");
10818
+ const encoderJsonPath = join25(planDir, "meta", "encoder.json");
10593
10819
  if (!existsSync18(planJsonPath)) {
10594
10820
  throw new Error(`[freezePlan] plan.json missing: ${planJsonPath}`);
10595
10821
  }
@@ -10626,18 +10852,18 @@ async function freezePlan(input) {
10626
10852
  if (!existsSync18(planDir)) {
10627
10853
  throw new Error(`[freezePlan] planDir does not exist: ${planDir}`);
10628
10854
  }
10629
- const metaDir = join24(planDir, "meta");
10630
- if (!existsSync18(metaDir)) mkdirSync7(metaDir, { recursive: true });
10631
- writeFileSync6(
10632
- join24(metaDir, "composition.json"),
10855
+ const metaDir = join25(planDir, "meta");
10856
+ if (!existsSync18(metaDir)) mkdirSync8(metaDir, { recursive: true });
10857
+ writeFileSync7(
10858
+ join25(metaDir, "composition.json"),
10633
10859
  `${JSON.stringify(composition, null, 2)}
10634
10860
  `,
10635
10861
  "utf-8"
10636
10862
  );
10637
10863
  const encoderForCanonical = stripUndefined(encoder);
10638
10864
  const encoderConfigCanonicalJson = canonicalJsonStringify(encoderForCanonical);
10639
- writeFileSync6(join24(metaDir, "encoder.json"), encoderConfigCanonicalJson, "utf-8");
10640
- writeFileSync6(join24(metaDir, "chunks.json"), `${JSON.stringify(chunks, null, 2)}
10865
+ writeFileSync7(join25(metaDir, "encoder.json"), encoderConfigCanonicalJson, "utf-8");
10866
+ writeFileSync7(join25(metaDir, "chunks.json"), `${JSON.stringify(chunks, null, 2)}
10641
10867
  `, "utf-8");
10642
10868
  const { compositionHtml, assets } = collectPlanAssetShas(planDir, digests);
10643
10869
  const planHash = computePlanHash({
@@ -10662,8 +10888,8 @@ async function freezePlan(input) {
10662
10888
  duration: durationSeconds,
10663
10889
  hasAudio
10664
10890
  };
10665
- const planJsonPath = join24(planDir, "plan.json");
10666
- writeFileSync6(planJsonPath, `${JSON.stringify(planJson, null, 2)}
10891
+ const planJsonPath = join25(planDir, "plan.json");
10892
+ writeFileSync7(planJsonPath, `${JSON.stringify(planJson, null, 2)}
10667
10893
  `, "utf-8");
10668
10894
  return { planJsonPath, planHash };
10669
10895
  }
@@ -10704,16 +10930,16 @@ function applyRuntimeEnvSnapshot(snapshot, env = process.env) {
10704
10930
  }
10705
10931
 
10706
10932
  // src/services/distributed/chunkAudio.ts
10707
- import { closeSync as closeSync4, existsSync as existsSync19, ftruncateSync, mkdirSync as mkdirSync9, openSync as openSync4, readFileSync as readFileSync9 } from "node:fs";
10708
- import { writeFileSync as writeFileSync7, writeSync } from "node:fs";
10709
- import { join as join26 } from "node:path";
10933
+ import { closeSync as closeSync4, existsSync as existsSync19, ftruncateSync, mkdirSync as mkdirSync10, openSync as openSync4, readFileSync as readFileSync9 } from "node:fs";
10934
+ import { writeFileSync as writeFileSync8, writeSync } from "node:fs";
10935
+ import { join as join27 } from "node:path";
10710
10936
  import { appendRenderProvenanceArgs, describeFfmpegFailure as describeFfmpegFailure4, runFfmpeg as runFfmpeg7 } from "@hyperframes/engine";
10711
10937
 
10712
10938
  // src/services/distributed/mp4Stitch.ts
10713
- import { createReadStream as createReadStream4, createWriteStream, mkdirSync as mkdirSync8, rmSync as rmSync7 } from "node:fs";
10939
+ import { createReadStream as createReadStream4, createWriteStream, mkdirSync as mkdirSync9, rmSync as rmSync7 } from "node:fs";
10714
10940
  import { open } from "node:fs/promises";
10715
10941
  import { renameWithRetry as renameWithRetry6 } from "@hyperframes/engine";
10716
- import { basename as basename5, dirname as dirname14, join as join25 } from "node:path";
10942
+ import { basename as basename5, dirname as dirname14, join as join26 } from "node:path";
10717
10943
  import { finished, pipeline } from "node:stream/promises";
10718
10944
  import { createStagingDir as createStagingDir4 } from "@hyperframes/core/atomic-file";
10719
10945
  function boxAt(src, off, at, limit) {
@@ -11078,15 +11304,15 @@ async function writeStitchedMp4(chunkPaths, outputPath, audioPath) {
11078
11304
  const sourcePaths = audioPath ? [audioPath, ...chunkPaths] : chunkPaths;
11079
11305
  const layouts = await Promise.all(sourcePaths.map((path) => readMp4Layout(fileRange(path))));
11080
11306
  const header = audioPath ? buildStitchedHeader(layouts.slice(1), layouts[0]) : buildStitchedHeader(layouts);
11081
- mkdirSync8(dirname14(outputPath), { recursive: true });
11307
+ mkdirSync9(dirname14(outputPath), { recursive: true });
11082
11308
  const workDir = createStagingDir4(dirname14(outputPath), `${basename5(outputPath)}.stitch-`);
11083
- const out = createWriteStream(join25(workDir, "out.mp4"));
11309
+ const out = createWriteStream(join26(workDir, "out.mp4"));
11084
11310
  try {
11085
11311
  out.write(header);
11086
11312
  for (const [i, path] of sourcePaths.entries()) await copyPayload(path, layouts[i], i, out);
11087
11313
  out.end();
11088
11314
  await finished(out);
11089
- renameWithRetry6(join25(workDir, "out.mp4"), outputPath);
11315
+ renameWithRetry6(join26(workDir, "out.mp4"), outputPath);
11090
11316
  } finally {
11091
11317
  out.destroy();
11092
11318
  rmSync7(workDir, { recursive: true, force: true });
@@ -11180,7 +11406,7 @@ async function writeChunkAudioSlices(input) {
11180
11406
  });
11181
11407
  const bytes = readFileSync9(input.audioPath);
11182
11408
  const layout = { sizeBytes: bytes.length, payloadStart, payloadEnd, partStarts: {} };
11183
- mkdirSync9(join26(input.planDir, SLICE_DIR), { recursive: true });
11409
+ mkdirSync10(join27(input.planDir, SLICE_DIR), { recursive: true });
11184
11410
  input.chunks.forEach((_, index) => {
11185
11411
  const cut = audioCutForChunk(grid, input.chunks, index, input.fps);
11186
11412
  if (!cut) return;
@@ -11188,17 +11414,17 @@ async function writeChunkAudioSlices(input) {
11188
11414
  const start = offsets[cut.firstPacket];
11189
11415
  layout.partStarts[index] = start;
11190
11416
  const end = offsets[last] + track.sizes[last];
11191
- writeFileSync7(join26(input.planDir, chunkAudioSlicePath(index)), bytes.subarray(start, end));
11417
+ writeFileSync8(join27(input.planDir, chunkAudioSlicePath(index)), bytes.subarray(start, end));
11192
11418
  });
11193
11419
  const frame = [bytes.subarray(0, payloadStart), bytes.subarray(payloadEnd)];
11194
- writeFileSync7(join26(input.planDir, SLICE_FRAME), Buffer.concat(frame));
11195
- writeFileSync7(join26(input.planDir, SLICE_LAYOUT), JSON.stringify(layout));
11420
+ writeFileSync8(join27(input.planDir, SLICE_FRAME), Buffer.concat(frame));
11421
+ writeFileSync8(join27(input.planDir, SLICE_LAYOUT), JSON.stringify(layout));
11196
11422
  }
11197
11423
  function chunkAudioSource(planDir, chunkIndex, scratchPath) {
11198
- const layoutPath = join26(planDir, SLICE_LAYOUT);
11424
+ const layoutPath = join27(planDir, SLICE_LAYOUT);
11199
11425
  if (!existsSync19(layoutPath)) return resolvePlanAudioPath(planDir);
11200
11426
  const layout = JSON.parse(readFileSync9(layoutPath, "utf-8"));
11201
- const frame = readFileSync9(join26(planDir, SLICE_FRAME));
11427
+ const frame = readFileSync9(join27(planDir, SLICE_FRAME));
11202
11428
  const fd = openSync4(scratchPath, "w");
11203
11429
  try {
11204
11430
  writeSync(fd, frame, 0, layout.payloadStart, 0);
@@ -11211,7 +11437,7 @@ function chunkAudioSource(planDir, chunkIndex, scratchPath) {
11211
11437
  );
11212
11438
  const start = layout.partStarts[chunkIndex];
11213
11439
  if (start !== void 0) {
11214
- const part = readFileSync9(join26(planDir, chunkAudioSlicePath(chunkIndex)));
11440
+ const part = readFileSync9(join27(planDir, chunkAudioSlicePath(chunkIndex)));
11215
11441
  writeSync(fd, part, 0, part.length, start);
11216
11442
  }
11217
11443
  ftruncateSync(fd, layout.sizeBytes);
@@ -11265,9 +11491,9 @@ async function muxChunkWithAudio(input) {
11265
11491
  }
11266
11492
 
11267
11493
  // src/services/distributed/planSize.ts
11268
- import { createHash as createHash8 } from "node:crypto";
11494
+ import { createHash as createHash9 } from "node:crypto";
11269
11495
  import { lstatSync, readdirSync as readdirSync6 } from "node:fs";
11270
- import { extname as extname3, join as join27, relative as relative6 } from "node:path";
11496
+ import { extname as extname3, join as join28, relative as relative6 } from "node:path";
11271
11497
  var MAX_TOP_COMPONENTS = 10;
11272
11498
  var SOURCE_MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
11273
11499
  ".aac",
@@ -11295,7 +11521,7 @@ var PLAN_ROOT_CATEGORY = {
11295
11521
  "plan.json": "metadata"
11296
11522
  };
11297
11523
  function hashComponent(value) {
11298
- return createHash8("sha256").update(value).digest("hex").slice(0, 12);
11524
+ return createHash9("sha256").update(value).digest("hex").slice(0, 12);
11299
11525
  }
11300
11526
  function classifyFile(segments, rootKind) {
11301
11527
  const rootName = segments[0] ?? "";
@@ -11379,7 +11605,7 @@ function walkRegularFiles(dir, visit) {
11379
11605
  return;
11380
11606
  }
11381
11607
  for (const entry of entries) {
11382
- const full = join27(dir, entry.name);
11608
+ const full = join28(dir, entry.name);
11383
11609
  if (entry.isDirectory()) {
11384
11610
  walkRegularFiles(full, visit);
11385
11611
  } else if (entry.isFile()) {
@@ -11599,13 +11825,13 @@ function assertPositiveInteger(name, value) {
11599
11825
  }
11600
11826
  var FREEZE_OWNED_PLAN_FILES = [
11601
11827
  "plan.json",
11602
- join28("meta", "composition.json"),
11603
- join28("meta", "encoder.json"),
11604
- join28("meta", "chunks.json")
11828
+ join29("meta", "composition.json"),
11829
+ join29("meta", "encoder.json"),
11830
+ join29("meta", "chunks.json")
11605
11831
  ];
11606
11832
  function removeFreezeOwnedPlanFiles(planDir) {
11607
11833
  for (const relativePath of FREEZE_OWNED_PLAN_FILES) {
11608
- rmSync8(join28(planDir, relativePath), { force: true });
11834
+ rmSync8(join29(planDir, relativePath), { force: true });
11609
11835
  }
11610
11836
  }
11611
11837
  function buildChunkSlices(totalFrames, chunkCount, effectiveChunkSize) {
@@ -11763,19 +11989,19 @@ function createVideoSourceShipper(input) {
11763
11989
  const known = shipped.get(srcPath);
11764
11990
  if (known) return known;
11765
11991
  const stagedRel = pathInside(input.workVideoFramesDir, srcPath);
11766
- const current = stagedRel === null ? srcPath : join28(input.planDir, "video-frames", stagedRel);
11992
+ const current = stagedRel === null ? srcPath : join29(input.planDir, "video-frames", stagedRel);
11767
11993
  let result = null;
11768
11994
  for (const root of stagedRel === null ? [input.workCompiledDir, input.projectDir] : []) {
11769
11995
  const rel = pathInside(root, srcPath);
11770
- if (rel !== null && (existsSync20(join28(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
11996
+ if (rel !== null && (existsSync20(join29(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
11771
11997
  result = ["compiled", ...rel.split(sep4)].join("/");
11772
11998
  break;
11773
11999
  }
11774
12000
  }
11775
12001
  if (result === null) {
11776
12002
  result = `video-sources/${shipped.size}${extname4(current)}`;
11777
- const destination = join28(input.planDir, ...result.split("/"));
11778
- mkdirSync10(join28(input.planDir, "video-sources"), { recursive: true });
12003
+ const destination = join29(input.planDir, ...result.split("/"));
12004
+ mkdirSync11(join29(input.planDir, "video-sources"), { recursive: true });
11779
12005
  try {
11780
12006
  linkSync(current, destination);
11781
12007
  } catch {
@@ -11795,7 +12021,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
11795
12021
  useGpu: false,
11796
12022
  browserGpuMode: "software"
11797
12023
  });
11798
- if (!existsSync20(planDir)) mkdirSync10(planDir, { recursive: true });
12024
+ if (!existsSync20(planDir)) mkdirSync11(planDir, { recursive: true });
11799
12025
  const log = config.logger ?? defaultLogger;
11800
12026
  const sizeLimitBytes = options.executionPlanSizeLimitBytes ?? config.planDirSizeLimitBytes ?? PLAN_DIR_SIZE_LIMIT_BYTES;
11801
12027
  const abortSignal = config.abortSignal;
@@ -11829,15 +12055,15 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
11829
12055
  includeOutsideScripts: options.includeOutsideScripts === true
11830
12056
  });
11831
12057
  const entryFile = config.entryFile ?? "index.html";
11832
- const htmlPath = join28(projectDir, entryFile);
12058
+ const htmlPath = join29(projectDir, entryFile);
11833
12059
  if (!existsSync20(htmlPath)) {
11834
12060
  throw new Error(`[plan] entry file not found: ${htmlPath}`);
11835
12061
  }
11836
- const workDir = join28(planDir, ".plan-work");
12062
+ const workDir = join29(planDir, ".plan-work");
11837
12063
  rmSync8(workDir, { recursive: true, force: true });
11838
- mkdirSync10(workDir, { recursive: true });
11839
- const compiledDir = join28(workDir, "compiled");
11840
- mkdirSync10(compiledDir, { recursive: true });
12064
+ mkdirSync11(workDir, { recursive: true });
12065
+ const compiledDir = join29(workDir, "compiled");
12066
+ mkdirSync11(compiledDir, { recursive: true });
11841
12067
  let stageStarted = Date.now();
11842
12068
  cpSync2(projectDir, compiledDir, {
11843
12069
  recursive: true,
@@ -11856,10 +12082,10 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
11856
12082
  }
11857
12083
  });
11858
12084
  logPlanStage(log, "copy", stageStarted);
11859
- const finalCompiledDir = join28(planDir, "compiled");
12085
+ const finalCompiledDir = join29(planDir, "compiled");
11860
12086
  const needsAlpha = outputNeedsAlpha(config.format);
11861
12087
  const remoteFiles = Object.entries(options.remoteFiles ?? {});
11862
- const remoteLocalPath = (rel) => join28(projectDir, ...rel.split("/"));
12088
+ const remoteLocalPath = (rel) => join29(projectDir, ...rel.split("/"));
11863
12089
  for (const [, file] of remoteFiles) {
11864
12090
  declareContentAddressedUrl(file.url, file.sha256);
11865
12091
  if (file.probeFactsUrl) declareProbeFactsUrl(file.url, file.probeFactsUrl);
@@ -12064,15 +12290,15 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
12064
12290
  let stageStarted = Date.now();
12065
12291
  const extractResult = await extractPlanVideos(c, options.deferVideoExtraction);
12066
12292
  logPlanStage(log, "extract", stageStarted);
12067
- const stagedVideoFrames = join28(compiledDir, "__hyperframes_video_frames");
12068
- const videoFramesDst = join28(planDir, "video-frames");
12293
+ const stagedVideoFrames = join29(compiledDir, "__hyperframes_video_frames");
12294
+ const videoFramesDst = join29(planDir, "video-frames");
12069
12295
  if (existsSync20(videoFramesDst)) rmSync8(videoFramesDst, { recursive: true, force: true });
12070
- const videoSourcesDir = join28(planDir, "video-sources");
12296
+ const videoSourcesDir = join29(planDir, "video-sources");
12071
12297
  rmSync8(videoSourcesDir, { recursive: true, force: true });
12072
12298
  if (existsSync20(stagedVideoFrames)) {
12073
12299
  renameWithRetry7(stagedVideoFrames, videoFramesDst);
12074
12300
  } else {
12075
- mkdirSync10(videoFramesDst, { recursive: true });
12301
+ mkdirSync11(videoFramesDst, { recursive: true });
12076
12302
  }
12077
12303
  if (existsSync20(finalCompiledDir)) rmSync8(finalCompiledDir, { recursive: true, force: true });
12078
12304
  renameWithRetry7(compiledDir, finalCompiledDir);
@@ -12104,7 +12330,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
12104
12330
  };
12105
12331
  })
12106
12332
  });
12107
- mkdirSync10(join28(planDir, "meta"), { recursive: true });
12333
+ mkdirSync11(join29(planDir, "meta"), { recursive: true });
12108
12334
  writePlanRemoteFiles(
12109
12335
  planDir,
12110
12336
  remoteFiles.map(([rel, { sha256, sizeBytes }]) => ({
@@ -12113,8 +12339,8 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
12113
12339
  sizeBytes
12114
12340
  }))
12115
12341
  );
12116
- writeFileSync8(
12117
- join28(planDir, PLAN_VIDEOS_META_RELATIVE_PATH),
12342
+ writeFileSync9(
12343
+ join29(planDir, PLAN_VIDEOS_META_RELATIVE_PATH),
12118
12344
  JSON.stringify(planVideosJson, null, 2),
12119
12345
  "utf-8"
12120
12346
  );
@@ -12194,7 +12420,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
12194
12420
  if (audioResult?.audioError) {
12195
12421
  applyDistributedAudioWarningPolicy(job, audioResult.audioError, audioResult.audioFailures, log);
12196
12422
  }
12197
- const planAudioPath = join28(planDir, PLAN_AUDIO_RELATIVE_PATH);
12423
+ const planAudioPath = join29(planDir, PLAN_AUDIO_RELATIVE_PATH);
12198
12424
  if (audioResult?.hasAudio && existsSync20(audioResult.audioOutputPath)) {
12199
12425
  renameWithRetry7(audioResult.audioOutputPath, planAudioPath);
12200
12426
  }
@@ -12335,15 +12561,15 @@ import {
12335
12561
  copyFileSync as copyFileSync8,
12336
12562
  existsSync as existsSync22,
12337
12563
  lstatSync as lstatSync2,
12338
- mkdirSync as mkdirSync12,
12564
+ mkdirSync as mkdirSync13,
12339
12565
  readFileSync as readFileSync10,
12340
12566
  readdirSync as readdirSync7,
12341
12567
  rmSync as rmSync10,
12342
12568
  statSync as statSync9,
12343
- writeFileSync as writeFileSync10
12569
+ writeFileSync as writeFileSync11
12344
12570
  } from "node:fs";
12345
12571
  import { tmpdir } from "node:os";
12346
- import { dirname as dirname16, isAbsolute as isAbsolute5, join as join31, relative as relative8, resolve as resolve10, sep as sep5 } from "node:path";
12572
+ import { dirname as dirname16, isAbsolute as isAbsolute5, join as join32, relative as relative8, resolve as resolve10, sep as sep5 } from "node:path";
12347
12573
  import { DISTRIBUTED_FPS, isDistributedFps } from "@hyperframes/core";
12348
12574
  import {
12349
12575
  createFrameLookupTable as createFrameLookupTable5,
@@ -12356,13 +12582,13 @@ import {
12356
12582
  copyFileSync as copyFileSync7,
12357
12583
  existsSync as existsSync21,
12358
12584
  linkSync as linkSync2,
12359
- mkdirSync as mkdirSync11,
12585
+ mkdirSync as mkdirSync12,
12360
12586
  rmSync as rmSync9,
12361
12587
  statSync as statSync8,
12362
- writeFileSync as writeFileSync9
12588
+ writeFileSync as writeFileSync10
12363
12589
  } from "node:fs";
12364
12590
  import { renameWithRetry as renameWithRetry8 } from "@hyperframes/engine";
12365
- import { dirname as dirname15, join as join30 } from "node:path";
12591
+ import { dirname as dirname15, join as join31 } from "node:path";
12366
12592
 
12367
12593
  // src/services/distributed/planV2Errors.ts
12368
12594
  var PLAN_V2_INTEGRITY_UNRECOVERABLE = "PLAN_V2_INTEGRITY_UNRECOVERABLE";
@@ -12377,7 +12603,7 @@ var PlanV2IntegrityError = class extends Error {
12377
12603
  };
12378
12604
 
12379
12605
  // src/services/distributed/planV2Layout.ts
12380
- import { join as join29 } from "node:path";
12606
+ import { join as join30 } from "node:path";
12381
12607
  var SHA256_PATTERN = /^[0-9a-f]{64}$/;
12382
12608
  function assertPlanV2Sha256(value, field) {
12383
12609
  if (typeof value !== "string" || !SHA256_PATTERN.test(value)) {
@@ -12387,7 +12613,7 @@ function assertPlanV2Sha256(value, field) {
12387
12613
  }
12388
12614
  function planV2BlobPath(root, sha256) {
12389
12615
  const digest = assertPlanV2Sha256(sha256, "artifact sha256");
12390
- return join29(root, "artifacts", "sha256", digest.slice(0, 2), digest);
12616
+ return join30(root, "artifacts", "sha256", digest.slice(0, 2), digest);
12391
12617
  }
12392
12618
 
12393
12619
  // src/services/distributed/planV2Publisher.ts
@@ -12423,7 +12649,7 @@ var LocalPlanV2ArtifactPublisher = class {
12423
12649
  }
12424
12650
  this.destinationDir = destinationDir;
12425
12651
  this.#linkFile = options.linkFile ?? linkSync2;
12426
- mkdirSync11(dirname15(destinationDir), { recursive: true });
12652
+ mkdirSync12(dirname15(destinationDir), { recursive: true });
12427
12653
  this.temporaryDir = createStagingDir5(dirname15(destinationDir), ".plan-v2-publish-");
12428
12654
  }
12429
12655
  async putBlob(blob) {
@@ -12436,9 +12662,9 @@ var LocalPlanV2ArtifactPublisher = class {
12436
12662
  }
12437
12663
  const destinationPath = planV2BlobPath(this.temporaryDir, digest);
12438
12664
  if (existsSync21(destinationPath)) return;
12439
- mkdirSync11(dirname15(destinationPath), { recursive: true });
12665
+ mkdirSync12(dirname15(destinationPath), { recursive: true });
12440
12666
  const stagingDir = createStagingDir5(dirname15(destinationPath), ".plan-v2-blob-");
12441
- const temporaryPath = join30(stagingDir, "blob");
12667
+ const temporaryPath = join31(stagingDir, "blob");
12442
12668
  try {
12443
12669
  try {
12444
12670
  this.#linkFile(blob.sourcePath, temporaryPath);
@@ -12459,7 +12685,7 @@ var LocalPlanV2ArtifactPublisher = class {
12459
12685
  );
12460
12686
  }
12461
12687
  }
12462
- writeFileSync9(join30(this.temporaryDir, "plan.json"), manifestBytes, "utf-8");
12688
+ writeFileSync10(join31(this.temporaryDir, "plan.json"), manifestBytes, "utf-8");
12463
12689
  renameWithRetry8(this.temporaryDir, this.destinationDir);
12464
12690
  this.#committed = true;
12465
12691
  }
@@ -12505,7 +12731,7 @@ function listFiles(root) {
12505
12731
  const rootResolved = resolve10(root);
12506
12732
  function walk(dir) {
12507
12733
  for (const entry of readdirSync7(dir, { withFileTypes: true })) {
12508
- const absolutePath = join31(dir, entry.name);
12734
+ const absolutePath = join32(dir, entry.name);
12509
12735
  if (entry.isDirectory()) {
12510
12736
  walk(absolutePath);
12511
12737
  } else if (entry.isFile()) {
@@ -12532,13 +12758,13 @@ function assertValidExtractionCacheCompleteSentinel(path) {
12532
12758
  }
12533
12759
  }
12534
12760
  function validateExtractionCacheCompleteSentinels(executionPlanDir) {
12535
- const videoRoot = join31(executionPlanDir, "video-frames");
12761
+ const videoRoot = join32(executionPlanDir, "video-frames");
12536
12762
  if (!existsSync22(videoRoot)) return;
12537
12763
  for (const videoEntry of readdirSync7(videoRoot, { withFileTypes: true })) {
12538
12764
  if (!videoEntry.isDirectory()) continue;
12539
- const videoDir = join31(videoRoot, videoEntry.name);
12765
+ const videoDir = join32(videoRoot, videoEntry.name);
12540
12766
  if (readdirSync7(videoDir).includes(EXTRACTION_CACHE_COMPLETE_SENTINEL)) {
12541
- const sentinelPath = join31(videoDir, EXTRACTION_CACHE_COMPLETE_SENTINEL);
12767
+ const sentinelPath = join32(videoDir, EXTRACTION_CACHE_COMPLETE_SENTINEL);
12542
12768
  assertValidExtractionCacheCompleteSentinel(sentinelPath);
12543
12769
  }
12544
12770
  }
@@ -12585,7 +12811,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
12585
12811
  if (video.deferredRange) {
12586
12812
  const framePaths2 = /* @__PURE__ */ new Map();
12587
12813
  for (let index = 0; index < video.totalFrames; index++) {
12588
- framePaths2.set(index, join31(outputDir, String(index)));
12814
+ framePaths2.set(index, join32(outputDir, String(index)));
12589
12815
  }
12590
12816
  return { ...video, outputDir, framePaths: framePaths2, ownedByLookup: false };
12591
12817
  }
@@ -12593,7 +12819,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
12593
12819
  const framePaths = /* @__PURE__ */ new Map();
12594
12820
  for (const frameName of frameNames) {
12595
12821
  if (frameName === EXTRACTION_CACHE_COMPLETE_SENTINEL) {
12596
- assertValidExtractionCacheCompleteSentinel(join31(outputDir, frameName));
12822
+ assertValidExtractionCacheCompleteSentinel(join32(outputDir, frameName));
12597
12823
  continue;
12598
12824
  }
12599
12825
  const match = /(\d+)(?=\.[^.]+$)/.exec(frameName);
@@ -12612,7 +12838,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
12612
12838
  `duplicate extracted frame index ${frameIndex} in ${outputDir}`
12613
12839
  );
12614
12840
  }
12615
- framePaths.set(frameIndex, join31(outputDir, frameName));
12841
+ framePaths.set(frameIndex, join32(outputDir, frameName));
12616
12842
  }
12617
12843
  return {
12618
12844
  ...video,
@@ -12633,11 +12859,11 @@ function parsePlanVideosJson2(value) {
12633
12859
  }
12634
12860
  }
12635
12861
  function materializeExtractedVideoDirectories(planDir) {
12636
- const videosPath = join31(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
12862
+ const videosPath = join32(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
12637
12863
  if (!existsSync22(videosPath)) return;
12638
12864
  const videos = parsePlanVideosJson2(readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH));
12639
12865
  for (const video of videos.extracted) {
12640
- mkdirSync12(resolveExtractedVideoOutputDir(planDir, video.videoId), { recursive: true });
12866
+ mkdirSync13(resolveExtractedVideoOutputDir(planDir, video.videoId), { recursive: true });
12641
12867
  }
12642
12868
  }
12643
12869
  function parseChunkSlices(value) {
@@ -12667,13 +12893,13 @@ function parseChunkSlices(value) {
12667
12893
  });
12668
12894
  }
12669
12895
  function buildVideoChunkDependencies(executionPlanDir, dimensions) {
12670
- const videoRoot = join31(executionPlanDir, "video-frames");
12896
+ const videoRoot = join32(executionPlanDir, "video-frames");
12671
12897
  const hasExtractedFrames = existsSync22(videoRoot) && listFiles(videoRoot).length > 0;
12672
- const videosPath = join31(executionPlanDir, PLAN_VIDEOS_META_RELATIVE_PATH);
12898
+ const videosPath = join32(executionPlanDir, PLAN_VIDEOS_META_RELATIVE_PATH);
12673
12899
  if (!existsSync22(videosPath)) {
12674
12900
  return hasExtractedFrames ? { mode: "full-source-pack", dependencies: null } : { mode: "exact-rendered-frames", dependencies: /* @__PURE__ */ new Map() };
12675
12901
  }
12676
- const chunksPath = join31(executionPlanDir, "meta", "chunks.json");
12902
+ const chunksPath = join32(executionPlanDir, "meta", "chunks.json");
12677
12903
  const videos = readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH);
12678
12904
  const chunks = readJsonFile(chunksPath, "meta/chunks.json");
12679
12905
  const parsedVideos = parsePlanVideosJson2(videos);
@@ -12728,9 +12954,9 @@ function computeManifestHash(manifest) {
12728
12954
  }
12729
12955
  function writeBlob(sourcePath, destinationPath) {
12730
12956
  if (existsSync22(destinationPath)) return;
12731
- mkdirSync12(dirname16(destinationPath), { recursive: true });
12957
+ mkdirSync13(dirname16(destinationPath), { recursive: true });
12732
12958
  const temporaryDir = createStagingDir6(dirname16(destinationPath), ".plan-v2-blob-");
12733
- const temporaryPath = join31(temporaryDir, "blob");
12959
+ const temporaryPath = join32(temporaryDir, "blob");
12734
12960
  try {
12735
12961
  copyFileSync8(sourcePath, temporaryPath);
12736
12962
  renameWithRetry9(temporaryPath, destinationPath);
@@ -12766,7 +12992,7 @@ async function putTasks(tasks) {
12766
12992
  if (failure) throw failure.reason;
12767
12993
  }
12768
12994
  function buildPlanV2Publication(executionPlanDir, digests) {
12769
- const executionPlanPath = join31(executionPlanDir, "plan.json");
12995
+ const executionPlanPath = join32(executionPlanDir, "plan.json");
12770
12996
  if (!existsSync22(executionPlanPath)) {
12771
12997
  throw new PlanV2IntegrityError(`execution plan is missing plan.json: ${executionPlanPath}`);
12772
12998
  }
@@ -12794,7 +13020,7 @@ function buildPlanV2Publication(executionPlanDir, digests) {
12794
13020
  }
12795
13021
  validateExtractionCacheCompleteSentinels(executionPlanDir);
12796
13022
  const videoDependencyPlan = buildVideoChunkDependencies(executionPlanDir, dimensions);
12797
- const encoder = readJsonFile(join31(executionPlanDir, "meta", "encoder.json"), "meta/encoder.json");
13023
+ const encoder = readJsonFile(join32(executionPlanDir, "meta", "encoder.json"), "meta/encoder.json");
12798
13024
  const files = listFiles(executionPlanDir);
12799
13025
  const chunkAudio = !isRecord3(encoder) || encoder.chunksCarryAudio !== true ? "none" : files.some((file) => chunkAudioSliceTarget(file.path) !== null) ? "sliced" : "whole";
12800
13026
  for (const file of files) {
@@ -12854,14 +13080,14 @@ function createPlanV2FromExecutionPlan(executionPlanDir, planV2Dir) {
12854
13080
  if (publication.storedBlobs.length > 0) {
12855
13081
  throw new PlanV2IntegrityError("a local plan v2 directory cannot reference remote files");
12856
13082
  }
12857
- mkdirSync12(dirname16(planV2Dir), { recursive: true });
13083
+ mkdirSync13(dirname16(planV2Dir), { recursive: true });
12858
13084
  const tempDir = createStagingDir6(dirname16(planV2Dir), ".plan-v2-build-");
12859
13085
  try {
12860
13086
  for (const blob of publication.blobs) {
12861
13087
  writeBlob(blob.sourcePath, planV2BlobPath(tempDir, blob.sha256));
12862
13088
  }
12863
- writeFileSync10(
12864
- join31(tempDir, "plan.json"),
13089
+ writeFileSync11(
13090
+ join32(tempDir, "plan.json"),
12865
13091
  canonicalJsonStringify(publication.manifest),
12866
13092
  "utf-8"
12867
13093
  );
@@ -12913,7 +13139,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
12913
13139
  // artifactTargets ships every compiled/ file to all chunks, so each is in the manifest.
12914
13140
  whileAudioMixes: () => putBlobs(
12915
13141
  publisher,
12916
- listFiles(join31(stagingRoot, "compiled")).map(
13142
+ listFiles(join32(stagingRoot, "compiled")).map(
12917
13143
  (file) => publishBlobFor(file.absolutePath, digests)
12918
13144
  )
12919
13145
  ),
@@ -12954,7 +13180,7 @@ function resultFromManifest(planV2Dir, manifest) {
12954
13180
  isRecord3(executionPlan) ? executionPlan[REFERENCE_BACKGROUND_FIELD3] : void 0
12955
13181
  ),
12956
13182
  planDir: planV2Dir,
12957
- manifestPath: join31(planV2Dir, "plan.json"),
13183
+ manifestPath: join32(planV2Dir, "plan.json"),
12958
13184
  planProtocol: PLAN_PROTOCOL_V2,
12959
13185
  planHash: manifest.planHash,
12960
13186
  sourcePlanV1Hash: getPlanV2ExecutionPlanHash(manifest),
@@ -13090,7 +13316,7 @@ function parsePlanV2Manifest(value) {
13090
13316
  return parsed;
13091
13317
  }
13092
13318
  function readPlanV2Manifest(planV2Dir) {
13093
- const manifestPath = join31(planV2Dir, "plan.json");
13319
+ const manifestPath = join32(planV2Dir, "plan.json");
13094
13320
  if (!existsSync22(manifestPath)) {
13095
13321
  throw new PlanV2IntegrityError(`missing v2 manifest: ${manifestPath}`);
13096
13322
  }
@@ -13135,17 +13361,17 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
13135
13361
  artifact,
13136
13362
  sourcePath: verifyBlob(planV2Dir, artifact)
13137
13363
  }));
13138
- mkdirSync12(dirname16(destinationDir), { recursive: true });
13364
+ mkdirSync13(dirname16(destinationDir), { recursive: true });
13139
13365
  const tempDir = createStagingDir6(dirname16(destinationDir), ".plan-v2-materialize-");
13140
13366
  try {
13141
13367
  for (const { artifact, sourcePath } of verified) {
13142
- const destinationPath = join31(tempDir, ...artifact.path.split("/"));
13143
- mkdirSync12(dirname16(destinationPath), { recursive: true });
13368
+ const destinationPath = join32(tempDir, ...artifact.path.split("/"));
13369
+ mkdirSync13(dirname16(destinationPath), { recursive: true });
13144
13370
  copyFileSync8(sourcePath, destinationPath);
13145
13371
  }
13146
13372
  if (target.role === "chunk") materializeExtractedVideoDirectories(tempDir);
13147
- writeFileSync10(
13148
- join31(tempDir, PLAN_V2_MATERIALIZATION_MARKER),
13373
+ writeFileSync11(
13374
+ join32(tempDir, PLAN_V2_MATERIALIZATION_MARKER),
13149
13375
  canonicalJsonStringify({
13150
13376
  manifest,
13151
13377
  target,
@@ -13168,7 +13394,7 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
13168
13394
  // Join the artifact's OWN name, not the current constant: a plan written
13169
13395
  // before the container change carries the legacy name, and materializing it
13170
13396
  // under the new one would point at a file that was never written.
13171
- audioPath: target.role === "assembler" ? audioArtifact ? join31(destinationDir, audioArtifact.path) : null : null
13397
+ audioPath: target.role === "assembler" ? audioArtifact ? join32(destinationDir, audioArtifact.path) : null : null
13172
13398
  };
13173
13399
  }
13174
13400
  function assertRemoteSources(remoteSources, artifacts) {
@@ -13187,7 +13413,7 @@ function validatePlanV2MaterializedTarget(planDir, expectedTarget) {
13187
13413
  return readValidatedPlanV2Materialization(planDir, expectedTarget)?.manifest ?? null;
13188
13414
  }
13189
13415
  function readValidatedPlanV2Materialization(planDir, expectedTarget) {
13190
- const markerPath = join31(planDir, PLAN_V2_MATERIALIZATION_MARKER);
13416
+ const markerPath = join32(planDir, PLAN_V2_MATERIALIZATION_MARKER);
13191
13417
  if (!existsSync22(markerPath)) return null;
13192
13418
  const marker = readJsonFile(markerPath, "materialization marker");
13193
13419
  if (!isRecord3(marker) || !isRecord3(marker.manifest) || !isRecord3(marker.target)) {
@@ -13205,7 +13431,7 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
13205
13431
  assertRemoteSources(remoteSources, required);
13206
13432
  for (const artifact of required) {
13207
13433
  if (Object.hasOwn(remoteSources, artifact.path)) continue;
13208
- const path = join31(planDir, ...artifact.path.split("/"));
13434
+ const path = join32(planDir, ...artifact.path.split("/"));
13209
13435
  if (!existsSync22(path) || statSync9(path).size !== artifact.sizeBytes) {
13210
13436
  throw new PlanV2IntegrityError(
13211
13437
  `materialized artifact missing or truncated: ${artifact.path}`
@@ -13221,7 +13447,7 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
13221
13447
  // src/services/distributed/planV2Execution.ts
13222
13448
  import { mkdtempSync, rmSync as rmSync13 } from "node:fs";
13223
13449
  import { tmpdir as tmpdir2 } from "node:os";
13224
- import { join as join34 } from "node:path";
13450
+ import { join as join35 } from "node:path";
13225
13451
 
13226
13452
  // src/services/distributed/assemble.ts
13227
13453
  import {
@@ -13231,14 +13457,14 @@ import {
13231
13457
  import {
13232
13458
  cpSync as cpSync3,
13233
13459
  existsSync as existsSync23,
13234
- mkdirSync as mkdirSync13,
13460
+ mkdirSync as mkdirSync14,
13235
13461
  readFileSync as readFileSync11,
13236
13462
  readdirSync as readdirSync8,
13237
13463
  rmSync as rmSync11,
13238
13464
  statSync as statSync10
13239
13465
  } from "node:fs";
13240
13466
  import { localContainerInputArgs as localContainerInputArgs2 } from "@hyperframes/parsers/ff-binaries";
13241
- import { basename as basename6, dirname as dirname17, join as join32 } from "node:path";
13467
+ import { basename as basename6, dirname as dirname17, join as join33 } from "node:path";
13242
13468
  import {
13243
13469
  appendRateCapArgs as appendRateCapArgs2,
13244
13470
  writeVideoConcatList,
@@ -13288,7 +13514,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
13288
13514
  const format = plan.dimensions.format;
13289
13515
  const cfrEncoder = cfr ? readCfrEncoder(planDir, format) : null;
13290
13516
  if (!existsSync23(dirname17(outputPath))) {
13291
- mkdirSync13(dirname17(outputPath), { recursive: true });
13517
+ mkdirSync14(dirname17(outputPath), { recursive: true });
13292
13518
  }
13293
13519
  const workDir = createStagingDir7(dirname17(outputPath), `${basename6(outputPath)}.assemble-work-`);
13294
13520
  const fps = { num: plan.dimensions.fpsNum, den: plan.dimensions.fpsDen };
@@ -13310,7 +13536,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
13310
13536
  };
13311
13537
  try {
13312
13538
  const videoSources = cfrEncoder ? [await reencodeCfr(ctx, chunkPaths, cfrEncoder)] : chunkPaths;
13313
- const finalPath = join32(workDir, `output.${format}`);
13539
+ const finalPath = join33(workDir, `output.${format}`);
13314
13540
  const audio = audioPath !== null && existsSync23(audioPath) ? audioPath : null;
13315
13541
  await writeJoined(ctx, videoSources, audio, finalPath);
13316
13542
  renameWithRetry10(finalPath, outputPath);
@@ -13339,8 +13565,8 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
13339
13565
  };
13340
13566
  }
13341
13567
  function readAssemblePlan(planDir, chunkPaths) {
13342
- const planJsonPath = join32(planDir, "plan.json");
13343
- const chunksJsonPath = join32(planDir, "meta", "chunks.json");
13568
+ const planJsonPath = join33(planDir, "plan.json");
13569
+ const chunksJsonPath = join33(planDir, "meta", "chunks.json");
13344
13570
  if (!existsSync23(planJsonPath)) {
13345
13571
  throw new Error(`[assemble] planDir missing plan.json: ${planJsonPath}`);
13346
13572
  }
@@ -13395,7 +13621,7 @@ function cfrEncodeArgs(inputArgs, encoder, fpsArg) {
13395
13621
  return args;
13396
13622
  }
13397
13623
  async function reencodeCfr(ctx, chunkPaths, encoder) {
13398
- const cfrOutputPath = join32(ctx.workDir, `cfr.${ctx.format}`);
13624
+ const cfrOutputPath = join33(ctx.workDir, `cfr.${ctx.format}`);
13399
13625
  const cfrArgs = cfrEncodeArgs(videoInputArgs(ctx, chunkPaths), encoder, ctx.fpsArg);
13400
13626
  appendRenderProvenanceArgs2(cfrArgs, cfrOutputPath);
13401
13627
  cfrArgs.push("-y", cfrOutputPath);
@@ -13422,7 +13648,7 @@ async function writeJoined(ctx, videoSources, audioPath, finalPath) {
13422
13648
  );
13423
13649
  return;
13424
13650
  }
13425
- const paddedAudioPath = join32(ctx.workDir, "audio-padded.m4a");
13651
+ const paddedAudioPath = join33(ctx.workDir, "audio-padded.m4a");
13426
13652
  const padTrimResult = await ctx.timed(
13427
13653
  "audioMs",
13428
13654
  () => padOrTrimAudioToVideoFrameCount({
@@ -13497,11 +13723,11 @@ function stitchesSeparateAudio(planDir) {
13497
13723
  return lockedAudio(planDir).separateAudio === true;
13498
13724
  }
13499
13725
  function planFormat(planDir) {
13500
- const plan = JSON.parse(readFileSync11(join32(planDir, "plan.json"), "utf-8"));
13726
+ const plan = JSON.parse(readFileSync11(join33(planDir, "plan.json"), "utf-8"));
13501
13727
  return plan.dimensions.format;
13502
13728
  }
13503
13729
  function lockedAudio(planDir) {
13504
- const encoderJsonPath = join32(planDir, "meta", "encoder.json");
13730
+ const encoderJsonPath = join33(planDir, "meta", "encoder.json");
13505
13731
  if (!existsSync23(encoderJsonPath)) return {};
13506
13732
  return JSON.parse(readFileSync11(encoderJsonPath, "utf-8"));
13507
13733
  }
@@ -13511,7 +13737,7 @@ function readCfrEncoder(planDir, format) {
13511
13737
  `[assemble] cfr=true is only supported for format="mp4" (got "${format}"). Stream-copy paths for webm and mov already produce exact avg_frame_rate; cfr re-encode is not needed.`
13512
13738
  );
13513
13739
  }
13514
- const encoderJsonPath = join32(planDir, "meta", "encoder.json");
13740
+ const encoderJsonPath = join33(planDir, "meta", "encoder.json");
13515
13741
  if (!existsSync23(encoderJsonPath)) {
13516
13742
  throw new Error(`[assemble] planDir missing meta/encoder.json: ${encoderJsonPath}`);
13517
13743
  }
@@ -13525,7 +13751,7 @@ function readCfrEncoder(planDir, format) {
13525
13751
  }
13526
13752
  function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, startTimeMs) {
13527
13753
  if (existsSync23(outputPath)) rmSync11(outputPath, { recursive: true, force: true });
13528
- mkdirSync13(outputPath, { recursive: true });
13754
+ mkdirSync14(outputPath, { recursive: true });
13529
13755
  let globalIdx = 0;
13530
13756
  for (const chunkDir of chunkPaths) {
13531
13757
  if (!statSync10(chunkDir).isDirectory()) {
@@ -13538,8 +13764,8 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
13538
13764
  throw new Error(`[assemble] png-sequence chunk has no frames: ${chunkDir}`);
13539
13765
  }
13540
13766
  for (const frame of frames) {
13541
- const dst = join32(outputPath, formatExportFrameName(globalIdx, "png"));
13542
- cpSync3(join32(chunkDir, frame), dst);
13767
+ const dst = join33(outputPath, formatExportFrameName(globalIdx, "png"));
13768
+ cpSync3(join33(chunkDir, frame), dst);
13543
13769
  globalIdx += 1;
13544
13770
  }
13545
13771
  }
@@ -13549,13 +13775,13 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
13549
13775
  );
13550
13776
  }
13551
13777
  if (audioPath !== null && existsSync23(audioPath)) {
13552
- const sidecar = join32(outputPath, MIXED_AUDIO_FILENAME4);
13778
+ const sidecar = join33(outputPath, MIXED_AUDIO_FILENAME4);
13553
13779
  cpSync3(audioPath, sidecar);
13554
13780
  }
13555
13781
  let fileSize = 0;
13556
13782
  for (const name of readdirSync8(outputPath)) {
13557
13783
  try {
13558
- fileSize += statSync10(join32(outputPath, name)).size;
13784
+ fileSize += statSync10(join33(outputPath, name)).size;
13559
13785
  } catch {
13560
13786
  }
13561
13787
  }
@@ -13569,8 +13795,8 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
13569
13795
 
13570
13796
  // src/services/distributed/renderChunk.ts
13571
13797
  import { randomBytes } from "node:crypto";
13572
- import { existsSync as existsSync24, mkdirSync as mkdirSync14, readFileSync as readFileSync12, readdirSync as readdirSync9, rmSync as rmSync12, writeFileSync as writeFileSync11 } from "node:fs";
13573
- import { join as join33 } from "node:path";
13798
+ import { existsSync as existsSync24, mkdirSync as mkdirSync15, readFileSync as readFileSync12, readdirSync as readdirSync9, rmSync as rmSync12, writeFileSync as writeFileSync12 } from "node:fs";
13799
+ import { join as join34 } from "node:path";
13574
13800
  import {
13575
13801
  assertSwiftShader,
13576
13802
  BROWSER_GPU_NOT_SOFTWARE as BROWSER_GPU_NOT_SOFTWARE4,
@@ -13706,7 +13932,7 @@ function hashChunkOutput(outputPath, kind) {
13706
13932
  if (kind === "file") return sha256Hex(readFileSync12(outputPath));
13707
13933
  const entries = readdirSync9(outputPath).filter((name) => /\.(png|jpg|jpeg)$/i.test(name)).sort();
13708
13934
  const lines = entries.map(
13709
- (name) => `${name}\0${sha256Hex(readFileSync12(join33(outputPath, name)))}`
13935
+ (name) => `${name}\0${sha256Hex(readFileSync12(join34(outputPath, name)))}`
13710
13936
  );
13711
13937
  return sha256Hex(lines.join("\0"));
13712
13938
  }
@@ -13723,9 +13949,9 @@ function resolveLockedVp9CpuUsed(lockedEncoder) {
13723
13949
  async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
13724
13950
  const start = Date.now();
13725
13951
  const log = defaultLogger;
13726
- const planJsonPath = join33(planDir, "plan.json");
13727
- const encoderJsonPath = join33(planDir, "meta", "encoder.json");
13728
- const chunksJsonPath = join33(planDir, "meta", "chunks.json");
13952
+ const planJsonPath = join34(planDir, "plan.json");
13953
+ const encoderJsonPath = join34(planDir, "meta", "encoder.json");
13954
+ const chunksJsonPath = join34(planDir, "meta", "chunks.json");
13729
13955
  if (!existsSync24(planJsonPath)) {
13730
13956
  throw new RenderChunkValidationError(
13731
13957
  MISSING_PLAN_ARTIFACT,
@@ -13751,7 +13977,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
13751
13977
  }
13752
13978
  const encoder = JSON.parse(readFileSync12(encoderJsonPath, "utf-8"));
13753
13979
  const chunks = JSON.parse(readFileSync12(chunksJsonPath, "utf-8"));
13754
- const videosJsonPath = join33(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
13980
+ const videosJsonPath = join34(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
13755
13981
  let planVideos = null;
13756
13982
  if (existsSync24(videosJsonPath)) {
13757
13983
  try {
@@ -13783,7 +14009,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
13783
14009
  }
13784
14010
  const range = resolveChunkFrameRange(slice, chunkIndex, options?.frameRange);
13785
14011
  const framesInChunk = range.endFrame - range.startFrame;
13786
- const compiledDir = join33(planDir, "compiled");
14012
+ const compiledDir = join34(planDir, "compiled");
13787
14013
  if (!existsSync24(compiledDir)) {
13788
14014
  throw new RenderChunkValidationError(
13789
14015
  MISSING_PLAN_ARTIFACT,
@@ -13841,9 +14067,9 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
13841
14067
  forceScreenshotExplicitlyOptedOut: !encoder.forceScreenshot
13842
14068
  };
13843
14069
  const workDir = `${outputChunkPath}.work.${process.pid}.${randomBytes(4).toString("hex")}`;
13844
- mkdirSync14(workDir, { recursive: true });
13845
- const framesDir = join33(workDir, "captured-frames");
13846
- mkdirSync14(framesDir, { recursive: true });
14070
+ mkdirSync15(workDir, { recursive: true });
14071
+ const framesDir = join34(workDir, "captured-frames");
14072
+ mkdirSync15(framesDir, { recursive: true });
13847
14073
  const videoFramesDir = `${workDir}.video-frames`;
13848
14074
  const chunkFrameNumbers = Array.from({ length: framesInChunk }, (_, i) => range.startFrame + i);
13849
14075
  const chunkFps = { num: plan.dimensions.fpsNum, den: plan.dimensions.fpsDen };
@@ -13867,7 +14093,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
13867
14093
  dimensions: plan.dimensions,
13868
14094
  encoder,
13869
14095
  videoCount: planVideos?.videos.length ?? 0,
13870
- html: readFileSync12(join33(compiledDir, "index.html"), "utf-8"),
14096
+ html: readFileSync12(join34(compiledDir, "index.html"), "utf-8"),
13871
14097
  // The plan ships a deferred source only to chunks that show it; don't wait on the rest.
13872
14098
  skipReadinessVideoIds: deferredVideos.filter(
13873
14099
  (video) => !shownFrames.get(video.videoId)?.size || remoteVideoIds.has(video.videoId)
@@ -14037,10 +14263,10 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
14037
14263
  const effectiveBitrate = encoder.crf != null ? void 0 : encoder.bitrate;
14038
14264
  const videoOnlyPath = encoder.chunksCarryAudio ? `${outputChunkPath}.video.mp4` : outputChunkPath;
14039
14265
  if (isPngSequence) {
14040
- if (!existsSync24(outputChunkPath)) mkdirSync14(outputChunkPath, { recursive: true });
14266
+ if (!existsSync24(outputChunkPath)) mkdirSync15(outputChunkPath, { recursive: true });
14041
14267
  } else {
14042
- const outDir = join33(outputChunkPath, "..");
14043
- if (!existsSync24(outDir)) mkdirSync14(outDir, { recursive: true });
14268
+ const outDir = join34(outputChunkPath, "..");
14269
+ if (!existsSync24(outDir)) mkdirSync15(outDir, { recursive: true });
14044
14270
  }
14045
14271
  const encodeInput = {
14046
14272
  job,
@@ -14161,7 +14387,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
14161
14387
  resetForScreenshotRetry: () => {
14162
14388
  rmSync12(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
14163
14389
  boxesMeasured();
14164
- mkdirSync14(framesDir, { recursive: true });
14390
+ mkdirSync15(framesDir, { recursive: true });
14165
14391
  capturePerfs.length = 0;
14166
14392
  captureAttempts.length = 0;
14167
14393
  job.framesRendered = 0;
@@ -14253,7 +14479,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
14253
14479
  producerVersion: plan.producerVersion,
14254
14480
  ffmpegVersion
14255
14481
  };
14256
- writeFileSync11(perfPath, `${JSON.stringify(perfPayload, null, 2)}
14482
+ writeFileSync12(perfPath, `${JSON.stringify(perfPayload, null, 2)}
14257
14483
  `, "utf-8");
14258
14484
  try {
14259
14485
  rmSync12(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
@@ -14286,8 +14512,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
14286
14512
 
14287
14513
  // src/services/distributed/planV2Execution.ts
14288
14514
  async function renderChunkV2(planV2Dir, chunkIndex, outputChunkPath, options) {
14289
- const workRoot = mkdtempSync(join34(tmpdir2(), "hf-plan-v2-chunk-"));
14290
- const materializedPlanDir = join34(workRoot, "plan");
14515
+ const workRoot = mkdtempSync(join35(tmpdir2(), "hf-plan-v2-chunk-"));
14516
+ const materializedPlanDir = join35(workRoot, "plan");
14291
14517
  try {
14292
14518
  materializePlanV2Target(planV2Dir, { role: "chunk", chunkIndex }, materializedPlanDir);
14293
14519
  return await renderChunk(materializedPlanDir, chunkIndex, outputChunkPath, options);
@@ -14296,8 +14522,8 @@ async function renderChunkV2(planV2Dir, chunkIndex, outputChunkPath, options) {
14296
14522
  }
14297
14523
  }
14298
14524
  async function assembleV2(planV2Dir, chunkPaths, outputPath, options) {
14299
- const workRoot = mkdtempSync(join34(tmpdir2(), "hf-plan-v2-assembler-"));
14300
- const materializedPlanDir = join34(workRoot, "plan");
14525
+ const workRoot = mkdtempSync(join35(tmpdir2(), "hf-plan-v2-assembler-"));
14526
+ const materializedPlanDir = join35(workRoot, "plan");
14301
14527
  try {
14302
14528
  const materialized = materializePlanV2Target(
14303
14529
  planV2Dir,
@@ -14618,8 +14844,8 @@ function validateIntDimension(field, value) {
14618
14844
 
14619
14845
  // src/services/distributed/projectHash.ts
14620
14846
  import { closeSync as closeSync5, openSync as openSync5, readdirSync as readdirSync10, readSync as readSync4, realpathSync as realpathSync2, statSync as statSync11 } from "node:fs";
14621
- import { createHash as createHash9 } from "node:crypto";
14622
- import { join as join35, sep as sep6 } from "node:path";
14847
+ import { createHash as createHash10 } from "node:crypto";
14848
+ import { join as join36, sep as sep6 } from "node:path";
14623
14849
  import { isPrivateFileUnder as isPrivateFileUnder4, isStudioPrivatePath as isStudioPrivatePath4 } from "@hyperframes/core/safe-path";
14624
14850
  var SITE_ID_SCHEME = "site-v2\0";
14625
14851
  var READ_CHUNK_BYTES = 256 * 1024;
@@ -14653,7 +14879,7 @@ function listSiteFiles(projectDir, onPrivate, onOutside = () => {
14653
14879
  function walk(dir, rel) {
14654
14880
  for (const name of readdirSync10(dir).sort()) {
14655
14881
  if (rel === "" && PLAN_PROJECT_DIR_SKIP_SEGMENTS.has(name)) continue;
14656
- visit(join35(dir, name), rel === "" ? name : `${rel}/${name}`);
14882
+ visit(join36(dir, name), rel === "" ? name : `${rel}/${name}`);
14657
14883
  }
14658
14884
  }
14659
14885
  walk(projectDir, "");
@@ -14687,12 +14913,12 @@ function listSiteFilesForUpload(projectDir, onNotice = (message) => console.warn
14687
14913
  return files;
14688
14914
  }
14689
14915
  function hashProjectDir(projectDir, files = listSiteFiles(projectDir)) {
14690
- const hash = createHash9("sha256").update(SITE_ID_SCHEME);
14916
+ const hash = createHash10("sha256").update(SITE_ID_SCHEME);
14691
14917
  const chunk = Buffer.allocUnsafe(READ_CHUNK_BYTES);
14692
14918
  for (const rel of files) {
14693
14919
  hash.update(rel);
14694
14920
  hash.update("\0");
14695
- const fd = openSync5(join35(projectDir, rel), "r");
14921
+ const fd = openSync5(join36(projectDir, rel), "r");
14696
14922
  try {
14697
14923
  let read2;
14698
14924
  while ((read2 = readSync4(fd, chunk, 0, chunk.length, null)) > 0) {
@@ -14740,7 +14966,7 @@ var isMissing = (result) => result.error?.code === "ENOENT";
14740
14966
  var ffmpegIsMissing = async (signal) => isMissing(await runFfmpeg9(["-version"], { signal }));
14741
14967
 
14742
14968
  // src/services/distributed/probeFacts.ts
14743
- import { writeFileSync as writeFileSync12 } from "node:fs";
14969
+ import { writeFileSync as writeFileSync13 } from "node:fs";
14744
14970
  import { extname as extname6 } from "node:path";
14745
14971
  import { buildProbeFactsText } from "@hyperframes/engine";
14746
14972
  var PROBE_FACTS_EXTENSIONS = /* @__PURE__ */ new Set([".mp4", ".mov", ".m4v", ".webm", ".mkv"]);
@@ -14749,7 +14975,7 @@ function wantsProbeFacts(path) {
14749
14975
  }
14750
14976
  async function buildProbeFacts(inputPath, outputPath, signal) {
14751
14977
  try {
14752
- writeFileSync12(outputPath, await buildProbeFactsText(inputPath, signal));
14978
+ writeFileSync13(outputPath, await buildProbeFactsText(inputPath, signal));
14753
14979
  return "built";
14754
14980
  } catch (error) {
14755
14981
  if (signal?.aborted) throw error;