@hyperframes/producer 0.9.86 → 0.9.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  // src/services/renderOrchestrator.ts
10
10
  import { audioFailureDiagnostics as audioFailureDiagnostics2, cpuBudget } from "@hyperframes/engine";
11
11
  import {
12
- existsSync as existsSync21,
12
+ existsSync as existsSync22,
13
13
  mkdirSync as mkdirSync12,
14
14
  readdirSync as readdirSync6,
15
15
  rmSync as rmSync12,
@@ -360,10 +360,10 @@ import {
360
360
  referenceBackgroundResult,
361
361
  createReferenceBackgroundRecorder
362
362
  } from "@hyperframes/engine";
363
- import { join as join34, dirname as dirname14, resolve as resolve9 } from "path";
363
+ import { join as join35, dirname as dirname15, resolve as resolve9 } from "path";
364
364
  import { totalmem as totalmem2 } from "node:os";
365
365
  import { randomUUID } from "crypto";
366
- import { fileURLToPath as fileURLToPath4 } from "url";
366
+ import { fileURLToPath as fileURLToPath5 } from "url";
367
367
 
368
368
  // src/services/fileServer.ts
369
369
  import { Hono } from "hono";
@@ -7132,14 +7132,20 @@ function requireOutputDimensions(expected, width, height) {
7132
7132
  }
7133
7133
 
7134
7134
  // src/services/render/stages/compileStage.ts
7135
- import { existsSync as existsSync12, writeFileSync as writeFileSync4 } from "node:fs";
7136
- import { join as join22, relative as relative4 } from "node:path";
7135
+ import { existsSync as existsSync13, writeFileSync as writeFileSync4 } from "node:fs";
7136
+ import { join as join23, relative as relative4 } from "node:path";
7137
7137
  import { privateCacheRoot } from "@hyperframes/engine";
7138
7138
  import { suggestMatchingPreset } from "@hyperframes/core";
7139
7139
  import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
7140
7140
  import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolution";
7141
7141
  import { assertCompositionFileSize as assertCompositionFileSize2 } from "@hyperframes/core/compiler";
7142
7142
 
7143
+ // src/services/compileInWorker.ts
7144
+ import { existsSync as existsSync12 } from "node:fs";
7145
+ import { dirname as dirname10, join as join22 } from "node:path";
7146
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
7147
+ import { Worker } from "node:worker_threads";
7148
+
7143
7149
  // src/services/htmlCompiler.ts
7144
7150
  import { decodedUrlPath } from "@hyperframes/parsers/asset-paths";
7145
7151
  import {
@@ -10455,11 +10461,119 @@ async function recompileWithResolutions(compiled, resolutions, projectDir, downl
10455
10461
  };
10456
10462
  }
10457
10463
 
10464
+ // src/services/compileInWorker.ts
10465
+ var DEFAULT_COMPILE_TIMEOUT_MS = 10 * 60 * 1e3;
10466
+ var TERMINATE_GRACE_MS = 2e3;
10467
+ var ADVISORY_GRACE_MS = 3e4;
10468
+ var MAX_TIMER_MS = 2 ** 31 - 1;
10469
+ var CompileTimeoutError = class extends Error {
10470
+ code = "COMPILE_TIMEOUT";
10471
+ owner = "user";
10472
+ retryable = false;
10473
+ publicMetadata;
10474
+ constructor(timeoutMs) {
10475
+ super(
10476
+ `Compiling the composition took longer than ${Math.round(timeoutMs / 1e3)} s, so it was stopped. Very large pages, or pages with very many style rules or media tags, are the usual cause.`
10477
+ );
10478
+ this.name = "CompileTimeoutError";
10479
+ this.publicMetadata = { timeoutMs };
10480
+ }
10481
+ };
10482
+ function compileTimeoutMs() {
10483
+ const fromEnv = Number(process.env.HYPERFRAMES_COMPILE_TIMEOUT_MS);
10484
+ return Number.isInteger(fromEnv) && fromEnv > 0 ? Math.min(fromEnv, MAX_TIMER_MS) : DEFAULT_COMPILE_TIMEOUT_MS;
10485
+ }
10486
+ var warnedMissingEntry = false;
10487
+ function resolveCompileWorkerEntry(explicit, log) {
10488
+ if (explicit) return explicit;
10489
+ const fromEnv = process.env.HF_COMPILE_WORKER_ENTRY;
10490
+ if (fromEnv) {
10491
+ if (existsSync12(fromEnv)) return fromEnv;
10492
+ if (!warnedMissingEntry) {
10493
+ warnedMissingEntry = true;
10494
+ log?.warn(
10495
+ "[Compiler] HF_COMPILE_WORKER_ENTRY names a missing file, so compiles run on the main thread with no deadline",
10496
+ { entry: fromEnv }
10497
+ );
10498
+ }
10499
+ return void 0;
10500
+ }
10501
+ const sibling = join22(dirname10(fileURLToPath3(import.meta.url)), "compileWorker.js");
10502
+ return existsSync12(sibling) ? sibling : void 0;
10503
+ }
10504
+ function rebuildError({ name, message, stack, props }) {
10505
+ const error = Object.assign(new Error(message), props);
10506
+ error.name = name;
10507
+ if (stack) error.stack = stack;
10508
+ return error;
10509
+ }
10510
+ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, options = {}, worker = {}) {
10511
+ const { log, abortSignal, ...cloneable } = options;
10512
+ const entry = resolveCompileWorkerEntry(worker.entry, log);
10513
+ if (!entry) return compileForRender(projectDir, htmlPath, downloadDir, options);
10514
+ abortSignal?.throwIfAborted();
10515
+ const timeoutMs = worker.timeoutMs ?? compileTimeoutMs();
10516
+ return new Promise((resolve14, reject) => {
10517
+ const thread = new Worker(entry, {
10518
+ workerData: { projectDir, htmlPath, downloadDir, options: cloneable }
10519
+ });
10520
+ let settled = false;
10521
+ const settle = (finish) => {
10522
+ if (settled) return;
10523
+ settled = true;
10524
+ clearTimeout(timer);
10525
+ abortSignal?.removeEventListener("abort", onAbort);
10526
+ finish();
10527
+ };
10528
+ const stop = () => {
10529
+ thread.postMessage({ type: "abort" });
10530
+ setTimeout(() => void thread.terminate(), TERMINATE_GRACE_MS).unref();
10531
+ };
10532
+ const timer = setTimeout(() => {
10533
+ stop();
10534
+ settle(() => reject(new CompileTimeoutError(timeoutMs)));
10535
+ }, timeoutMs);
10536
+ const onAbort = () => {
10537
+ stop();
10538
+ settle(() => reject(abortSignal?.reason ?? new Error("Compile aborted")));
10539
+ };
10540
+ abortSignal?.addEventListener("abort", onAbort, { once: true });
10541
+ const retire = (graceMs) => {
10542
+ thread.unref();
10543
+ setTimeout(() => void thread.terminate(), graceMs).unref();
10544
+ };
10545
+ thread.on(
10546
+ "message",
10547
+ (message) => {
10548
+ if (message.type === "log" && message.level) {
10549
+ log?.[message.level](message.message ?? "", message.meta);
10550
+ } else if (message.type === "result" && message.compiled) {
10551
+ const { compiled } = message;
10552
+ settle(() => resolve14(compiled));
10553
+ retire(ADVISORY_GRACE_MS);
10554
+ } else if (message.type === "error" && message.error) {
10555
+ const { error } = message;
10556
+ settle(() => reject(rebuildError(error)));
10557
+ thread.postMessage({ type: "abort" });
10558
+ retire(TERMINATE_GRACE_MS);
10559
+ }
10560
+ }
10561
+ );
10562
+ thread.on("error", (error) => settle(() => reject(error)));
10563
+ thread.on(
10564
+ "exit",
10565
+ (code) => settle(
10566
+ () => reject(new Error(`The compile worker exited with code ${code} before answering`))
10567
+ )
10568
+ );
10569
+ });
10570
+ }
10571
+
10458
10572
  // src/services/render/stages/compileStage.ts
10459
10573
  function animatedGifCacheDir(extractCacheDir) {
10460
10574
  try {
10461
10575
  const root = extractCacheDir && privateCacheRoot(extractCacheDir);
10462
- return root ? join22(root, "animated-gif") : void 0;
10576
+ return root ? join23(root, "animated-gif") : void 0;
10463
10577
  } catch {
10464
10578
  return void 0;
10465
10579
  }
@@ -10487,11 +10601,11 @@ function resolveEntryHtmlPath(input) {
10487
10601
  assertCompositionFileSize2(path, relative4(projectDir, path));
10488
10602
  return readTextFile2(path);
10489
10603
  };
10490
- const htmlPath = join22(projectDir, entryFile);
10604
+ const htmlPath = join23(projectDir, entryFile);
10491
10605
  const rawEntry = readEntry(htmlPath);
10492
10606
  if (entryFile === "index.html" || !isTemplateEntry(rawEntry)) return htmlPath;
10493
- const projectIndexPath = join22(projectDir, "index.html");
10494
- if (!existsSync12(projectIndexPath)) {
10607
+ const projectIndexPath = join23(projectDir, "index.html");
10608
+ if (!existsSync13(projectIndexPath)) {
10495
10609
  throw new Error(
10496
10610
  `Template entry file "${entryFile}" requires a project index.html to extract its render shell.`
10497
10611
  );
@@ -10506,7 +10620,7 @@ function resolveEntryHtmlPath(input) {
10506
10620
  `Entry file "${entryFile}" is not mounted from index.html via data-composition-src, so it cannot be rendered independently.`
10507
10621
  );
10508
10622
  }
10509
- const wrapperPath = join22(workDir, "standalone-entry.html");
10623
+ const wrapperPath = join23(workDir, "standalone-entry.html");
10510
10624
  writeFileSync4(wrapperPath, standaloneHtml, "utf-8");
10511
10625
  log.info("Extracted standalone entry from index.html host context", { entryFile });
10512
10626
  return wrapperPath;
@@ -10536,19 +10650,24 @@ async function runCompileStage(input) {
10536
10650
  const assetRoot = job.config.allowOutsideProjectAssets ? void 0 : projectDir;
10537
10651
  const htmlPath = resolveEntryHtmlPath({ projectDir, workDir, entryFile, log, assetRoot });
10538
10652
  const compileStart = Date.now();
10539
- const compiled = await compileForRender(projectDir, htmlPath, join22(workDir, "downloads"), {
10540
- log,
10541
- failClosedFontFetch: failClosedFontFetch === true,
10542
- allowSystemFontCapture,
10543
- abortSignal,
10544
- variables: input.variables,
10545
- urlByAbsentLocalPath: input.urlByAbsentLocalPath,
10546
- pageMotionBlur: input.pageMotionBlur,
10547
- animatedGifCacheDir: animatedGifCacheDir(cfg.extractCacheDir),
10548
- ffmpegProcessTimeout: cfg.ffmpegProcessTimeout,
10549
- allowOutsideProjectAssets: job.config.allowOutsideProjectAssets,
10550
- includeOutsideScripts: job.config.includeOutsideScripts
10551
- });
10653
+ const compiled = await compileForRenderInWorker(
10654
+ projectDir,
10655
+ htmlPath,
10656
+ join23(workDir, "downloads"),
10657
+ {
10658
+ log,
10659
+ failClosedFontFetch: failClosedFontFetch === true,
10660
+ allowSystemFontCapture,
10661
+ abortSignal,
10662
+ variables: input.variables,
10663
+ urlByAbsentLocalPath: input.urlByAbsentLocalPath,
10664
+ pageMotionBlur: input.pageMotionBlur,
10665
+ animatedGifCacheDir: animatedGifCacheDir(cfg.extractCacheDir),
10666
+ ffmpegProcessTimeout: cfg.ffmpegProcessTimeout,
10667
+ allowOutsideProjectAssets: job.config.allowOutsideProjectAssets,
10668
+ includeOutsideScripts: job.config.includeOutsideScripts
10669
+ }
10670
+ );
10552
10671
  assertNotAborted();
10553
10672
  const compileOnlyMs = Date.now() - compileStart;
10554
10673
  let deCompileGate;
@@ -10611,7 +10730,7 @@ async function runCompileStage(input) {
10611
10730
  });
10612
10731
  await preflightCompositionAssetMediaTypes({
10613
10732
  projectDir,
10614
- compiledDir: join22(workDir, "compiled"),
10733
+ compiledDir: join23(workDir, "compiled"),
10615
10734
  composition,
10616
10735
  signal: abortSignal
10617
10736
  });
@@ -10659,7 +10778,7 @@ async function runCompileStage(input) {
10659
10778
 
10660
10779
  // src/services/render/stages/probeStage.ts
10661
10780
  import { createHash as createHash7 } from "node:crypto";
10662
- import { basename as basename7, join as join23 } from "node:path";
10781
+ import { basename as basename7, join as join24 } from "node:path";
10663
10782
  import { parseHTML as parseHTML6 } from "linkedom";
10664
10783
  import {
10665
10784
  closeCaptureSession as closeCaptureSession4,
@@ -11013,7 +11132,7 @@ async function runProbeStage(input) {
11013
11132
  });
11014
11133
  fileServer = await createFileServer({
11015
11134
  projectDir,
11016
- compiledDir: join23(workDir, "compiled"),
11135
+ compiledDir: join24(workDir, "compiled"),
11017
11136
  port: 0,
11018
11137
  preHeadScripts: [VIRTUAL_TIME_SHIM],
11019
11138
  fps: job.config.fps,
@@ -11027,7 +11146,7 @@ async function runProbeStage(input) {
11027
11146
  composition.videos,
11028
11147
  compiled.html,
11029
11148
  projectDir,
11030
- join23(workDir, "compiled")
11149
+ join24(workDir, "compiled")
11031
11150
  ),
11032
11151
  recordReferenceBackground: input.recordReferenceBackground,
11033
11152
  width,
@@ -11056,7 +11175,7 @@ async function runProbeStage(input) {
11056
11175
  log.info("Creating capture session...", { attempt, maxAttempts: PROBE_MAX_ATTEMPTS });
11057
11176
  probeSession = await createCaptureSession4(
11058
11177
  fileServer.url,
11059
- join23(workDir, "probe"),
11178
+ join24(workDir, "probe"),
11060
11179
  captureOpts,
11061
11180
  null,
11062
11181
  probeCfg
@@ -11142,7 +11261,7 @@ async function runProbeStage(input) {
11142
11261
  });
11143
11262
  probeSession = await createCaptureSession4(
11144
11263
  fileServer.url,
11145
- join23(workDir, "probe-screenshot"),
11264
+ join24(workDir, "probe-screenshot"),
11146
11265
  captureOpts,
11147
11266
  null,
11148
11267
  { ...probeCfg, forceScreenshot: true }
@@ -11186,7 +11305,7 @@ async function runProbeStage(input) {
11186
11305
  compiled,
11187
11306
  resolutions,
11188
11307
  projectDir,
11189
- join23(workDir, "downloads"),
11308
+ join24(workDir, "downloads"),
11190
11309
  job.config.allowOutsideProjectAssets ? void 0 : projectDir,
11191
11310
  { includeScripts: job.config.includeOutsideScripts }
11192
11311
  );
@@ -11392,7 +11511,7 @@ async function runProbeStage(input) {
11392
11511
  });
11393
11512
  await preflightCompositionAssetMediaTypes({
11394
11513
  projectDir,
11395
- compiledDir: join23(workDir, "compiled"),
11514
+ compiledDir: join24(workDir, "compiled"),
11396
11515
  composition,
11397
11516
  signal: abortSignal
11398
11517
  });
@@ -11559,8 +11678,8 @@ function validateDistributedDuration(input) {
11559
11678
  }
11560
11679
 
11561
11680
  // src/services/render/stages/extractVideosStage.ts
11562
- import { existsSync as existsSync13 } from "node:fs";
11563
- import { join as join24 } from "node:path";
11681
+ import { existsSync as existsSync14 } from "node:fs";
11682
+ import { join as join25 } from "node:path";
11564
11683
  import {
11565
11684
  classifyVideoExtractionError,
11566
11685
  createFrameLookupTable as createFrameLookupTable3,
@@ -11930,7 +12049,7 @@ async function runExtractVideosStage(input) {
11930
12049
  // because short boundary counts can differ by one frame.
11931
12050
  {
11932
12051
  fps: job.config.fps,
11933
- outputDir: join24(compiledDir, "__hyperframes_video_frames"),
12052
+ outputDir: join25(compiledDir, "__hyperframes_video_frames"),
11934
12053
  format: job.config.videoFrameFormat ?? "auto",
11935
12054
  toneMapHdrToSdr: rendersSdrOnly(job.config, composition),
11936
12055
  timelineEnd: composition.duration,
@@ -11938,7 +12057,7 @@ async function runExtractVideosStage(input) {
11938
12057
  collectProbeFailures: extractionPolicy.failureMode === "enforce",
11939
12058
  deferRangeExtraction,
11940
12059
  shownBoxes,
11941
- contentKeyedDirs: [join24(compiledDir, REMOTE_MEDIA_SUBDIR)],
12060
+ contentKeyedDirs: [join25(compiledDir, REMOTE_MEDIA_SUBDIR)],
11942
12061
  urlByAbsentLocalPath,
11943
12062
  assetRoots,
11944
12063
  onProgress: ({ planned = 0, done = 0 }) => {
@@ -12018,7 +12137,7 @@ function isPublicHttpsUrl(url) {
12018
12137
  }
12019
12138
  }
12020
12139
  function opensLocally(path, assetRoots) {
12021
- return existsSync13(path) && (!assetRoots || assetRootsRefusal(path, assetRoots) === null);
12140
+ return existsSync14(path) && (!assetRoots || assetRootsRefusal(path, assetRoots) === null);
12022
12141
  }
12023
12142
  function localProbeSource(src, input) {
12024
12143
  const path = resolveProjectRelativeSrc5(src, input.projectDir, input.compiledDir);
@@ -12030,7 +12149,7 @@ async function remoteProbeSource(video, input) {
12030
12149
  if (!isPublicHttpsUrl(video.src)) return null;
12031
12150
  if (!resolveRestrictPageNetwork()) return video.src;
12032
12151
  if (!video.hasAudio || video.hidden) return null;
12033
- const downloadDir = input.downloadDir ?? join24(input.compiledDir, REMOTE_MEDIA_SUBDIR);
12152
+ const downloadDir = input.downloadDir ?? join25(input.compiledDir, REMOTE_MEDIA_SUBDIR);
12034
12153
  try {
12035
12154
  return await downloadToTemp2(video.src, downloadDir, void 0, input.signal, void 0, {
12036
12155
  onTelemetry: writeUrlDownloadTelemetry2
@@ -12071,7 +12190,7 @@ async function appendVideoAudioFromProbe(input) {
12071
12190
  }
12072
12191
 
12073
12192
  // src/services/render/videoLayerPassthroughPlan.ts
12074
- import { existsSync as existsSync14 } from "node:fs";
12193
+ import { existsSync as existsSync15 } from "node:fs";
12075
12194
  import {
12076
12195
  buildVideoLayerInput,
12077
12196
  isHttpUrl as isHttpUrl4,
@@ -12139,7 +12258,7 @@ async function planVideoLayerPassthrough(input) {
12139
12258
  const { video } = q;
12140
12259
  if (isHttpUrl4(video.src)) return { reason: "remote_source" };
12141
12260
  const path = resolveProjectRelativeSrc6(video.src, input.projectDir, input.compiledDir);
12142
- if (!existsSync14(path)) return { reason: "source_missing" };
12261
+ if (!existsSync15(path)) return { reason: "source_missing" };
12143
12262
  const layout = await probeVideoLayout(input.page, video.id, input.canvas, input.duration);
12144
12263
  if ("reason" in layout) return layout;
12145
12264
  const layer = await buildVideoLayerInput(
@@ -12154,8 +12273,8 @@ async function planVideoLayerPassthrough(input) {
12154
12273
  }
12155
12274
 
12156
12275
  // src/services/render/stages/audioStage.ts
12157
- import { existsSync as existsSync16 } from "node:fs";
12158
- import { join as join27 } from "node:path";
12276
+ import { existsSync as existsSync17 } from "node:fs";
12277
+ import { join as join28 } from "node:path";
12159
12278
  import {
12160
12279
  MIXED_AUDIO_FILENAME,
12161
12280
  audioFailureDiagnostics,
@@ -12166,8 +12285,8 @@ import {
12166
12285
  } from "@hyperframes/engine";
12167
12286
 
12168
12287
  // src/services/render/audioDeliveryLimit.ts
12169
- import { existsSync as existsSync15 } from "node:fs";
12170
- import { dirname as dirname11, join as join26 } from "node:path";
12288
+ import { existsSync as existsSync16 } from "node:fs";
12289
+ import { dirname as dirname12, join as join27 } from "node:path";
12171
12290
  import {
12172
12291
  applyAudioFxChain,
12173
12292
  describeFfmpegFailure as describeFfmpegFailure3,
@@ -12178,7 +12297,7 @@ import {
12178
12297
  // src/services/render/audioPadTrim.ts
12179
12298
  import { localContainerInputArgs } from "@hyperframes/parsers/ff-binaries";
12180
12299
  import { spawn } from "node:child_process";
12181
- import { dirname as dirname10, join as join25 } from "node:path";
12300
+ import { dirname as dirname11, join as join26 } from "node:path";
12182
12301
  import {
12183
12302
  DEFAULT_CONFIG,
12184
12303
  describeFfmpegFailure as describeFfmpegFailure2,
@@ -12459,7 +12578,7 @@ async function constrainAacTruePeak(input) {
12459
12578
  }
12460
12579
  async function cutSource(input, scratchDir, attenuationDb) {
12461
12580
  if (!input.sourcePath || !input.rewriteSource) return true;
12462
- const cutPath = join25(scratchDir, "source.wav");
12581
+ const cutPath = join26(scratchDir, "source.wav");
12463
12582
  try {
12464
12583
  const result = await input.rewriteSource(input.sourcePath, cutPath, gainFilter(attenuationDb));
12465
12584
  if (!result.success) throw new Error(result.error);
@@ -12473,8 +12592,8 @@ async function cutSource(input, scratchDir, attenuationDb) {
12473
12592
  async function enforceAacTruePeak(input) {
12474
12593
  let scratchDir;
12475
12594
  try {
12476
- scratchDir = createStagingDir3(dirname10(input.audioPath), ".true-peak-");
12477
- const correctedPath = join25(scratchDir, "audio.m4a");
12595
+ scratchDir = createStagingDir3(dirname11(input.audioPath), ".true-peak-");
12596
+ const correctedPath = join26(scratchDir, "audio.m4a");
12478
12597
  const measurements = [];
12479
12598
  let attenuationDb = 0;
12480
12599
  let sourcePeakDbfs;
@@ -12690,14 +12809,14 @@ async function limitDeliveryPeaks(input, deps = {
12690
12809
  applyChain: applyAudioFxChain,
12691
12810
  encode: encodeAac2,
12692
12811
  rename: renameWithRetry5,
12693
- sourceExists: existsSync15
12812
+ sourceExists: existsSync16
12694
12813
  }) {
12695
12814
  const { audioPath, sourcePath, signal, timeoutMs } = input;
12696
12815
  if (!deps.sourceExists(sourcePath)) return { success: true };
12697
12816
  const peak = await deps.measure(audioPath, { timeoutMs, signal });
12698
12817
  if (peak <= AAC_DELIVERY_TRUE_PEAK_DBFS) return { success: true };
12699
12818
  const alternating = ["a", "b"].map(
12700
- (k) => join26(dirname11(sourcePath), `audio-source-limited-${k}.wav`)
12819
+ (k) => join27(dirname12(sourcePath), `audio-source-limited-${k}.wav`)
12701
12820
  );
12702
12821
  let encodedFrom;
12703
12822
  let ceiling = AAC_DELIVERY_TRUE_PEAK_DBFS;
@@ -12770,7 +12889,7 @@ function runAudioStage(input) {
12770
12889
  }
12771
12890
  async function runAudioStageScoped(input) {
12772
12891
  const stageStart = Date.now();
12773
- const pcmSourcePath = join27(input.workDir, "audio-source.wav");
12892
+ const pcmSourcePath = join28(input.workDir, "audio-source.wav");
12774
12893
  const duration = input.totalFrames * input.fps.den / input.fps.num;
12775
12894
  let deliverySourcePath;
12776
12895
  try {
@@ -12786,7 +12905,7 @@ async function runAudioStageScoped(input) {
12786
12905
  );
12787
12906
  audioLoweredDb = guard.loweredDb;
12788
12907
  input.log?.info("[audio] phases", { ...result.audioPhaseMs, guard: Date.now() - guardStart });
12789
- if (input.keepDeliverySource && !guard.sourceStale && existsSync16(pcmSourcePath)) {
12908
+ if (input.keepDeliverySource && !guard.sourceStale && existsSync17(pcmSourcePath)) {
12790
12909
  deliverySourcePath = pcmSourcePath;
12791
12910
  }
12792
12911
  }
@@ -12835,7 +12954,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
12835
12954
  assertNotAborted,
12836
12955
  log
12837
12956
  } = input;
12838
- const audioOutputPath = join27(workDir, MIXED_AUDIO_FILENAME);
12957
+ const audioOutputPath = join28(workDir, MIXED_AUDIO_FILENAME);
12839
12958
  let hasAudio = false;
12840
12959
  let audioError;
12841
12960
  let audioFailures;
@@ -12915,8 +13034,8 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
12915
13034
  }
12916
13035
 
12917
13036
  // src/services/render/stages/captureStage.ts
12918
- import { existsSync as existsSync17, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
12919
- import { join as join28 } from "node:path";
13037
+ import { existsSync as existsSync18, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
13038
+ import { join as join29 } from "node:path";
12920
13039
  import {
12921
13040
  classifyCaptureFailure as classifyCaptureFailure2,
12922
13041
  frameFileExtension,
@@ -12986,16 +13105,16 @@ function diskCaptureShortfallError(needBytes, freeBytes, framesDir, basis, remed
12986
13105
  }
12987
13106
  function measureCaptureFrameBytes(workDir, framesDir) {
12988
13107
  let total = sampleDirectoryBytes(framesDir);
12989
- if (!existsSync17(workDir)) return total;
13108
+ if (!existsSync18(workDir)) return total;
12990
13109
  for (const attempt of readdirSync4(workDir)) {
12991
13110
  if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
12992
- total += sampleDirectoryBytes(join28(workDir, attempt));
13111
+ total += sampleDirectoryBytes(join29(workDir, attempt));
12993
13112
  continue;
12994
13113
  }
12995
13114
  if (!/^capture-attempt-\d+$/.test(attempt)) continue;
12996
- const attemptDir = join28(workDir, attempt);
13115
+ const attemptDir = join29(workDir, attempt);
12997
13116
  for (const name of readdirSync4(attemptDir)) {
12998
- if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join28(attemptDir, name));
13117
+ if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join29(attemptDir, name));
12999
13118
  }
13000
13119
  }
13001
13120
  return total;
@@ -13293,8 +13412,8 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
13293
13412
  }
13294
13413
 
13295
13414
  // src/services/render/stages/captureHdrStage.ts
13296
- import { existsSync as existsSync19, mkdirSync as mkdirSync10 } from "node:fs";
13297
- import { join as join32 } from "node:path";
13415
+ import { existsSync as existsSync20, mkdirSync as mkdirSync10 } from "node:fs";
13416
+ import { join as join33 } from "node:path";
13298
13417
  import {
13299
13418
  closeCaptureSession as closeCaptureSession7,
13300
13419
  cloneCaptureWarnings as cloneCaptureWarnings2,
@@ -13366,7 +13485,7 @@ function createHdrImageTransferCache(options = {}) {
13366
13485
  }
13367
13486
 
13368
13487
  // src/services/render/stages/captureHdrSequentialLoop.ts
13369
- import { join as join29 } from "node:path";
13488
+ import { join as join30 } from "node:path";
13370
13489
  import {
13371
13490
  TRANSITIONS,
13372
13491
  crossfade
@@ -13491,7 +13610,7 @@ async function runSequentialLayeredFrameLoop(input) {
13491
13610
  );
13492
13611
  if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
13493
13612
  writeFileExclusiveSync(
13494
- join29(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
13613
+ join30(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
13495
13614
  normalCanvas
13496
13615
  );
13497
13616
  }
@@ -13523,7 +13642,7 @@ async function runSequentialLayeredFrameLoop(input) {
13523
13642
  }
13524
13643
 
13525
13644
  // src/services/render/stages/captureHdrHybridLoop.ts
13526
- import { join as join31 } from "node:path";
13645
+ import { join as join32 } from "node:path";
13527
13646
  import {
13528
13647
  TRANSITIONS as TRANSITIONS2,
13529
13648
  closeCaptureSession as closeCaptureSession6,
@@ -13535,12 +13654,12 @@ import {
13535
13654
  } from "@hyperframes/engine";
13536
13655
 
13537
13656
  // src/services/shaderTransitionWorkerPool.ts
13538
- import { Worker } from "node:worker_threads";
13539
- import { fileURLToPath as fileURLToPath3, pathToFileURL } from "node:url";
13540
- import { dirname as dirname12, join as join30 } from "node:path";
13657
+ import { Worker as Worker2 } from "node:worker_threads";
13658
+ import { fileURLToPath as fileURLToPath4, pathToFileURL } from "node:url";
13659
+ import { dirname as dirname13, join as join31 } from "node:path";
13541
13660
  import { createRequire } from "node:module";
13542
13661
  import { usableCpuCount } from "@hyperframes/engine";
13543
- import { existsSync as existsSync18 } from "node:fs";
13662
+ import { existsSync as existsSync19 } from "node:fs";
13544
13663
  function resolveWorkerEntry(explicit) {
13545
13664
  if (explicit && explicit.length > 0) {
13546
13665
  return { path: explicit, isTs: explicit.endsWith(".ts") };
@@ -13550,10 +13669,10 @@ function resolveWorkerEntry(explicit) {
13550
13669
  const isTs = override.endsWith(".ts");
13551
13670
  return { path: override, isTs };
13552
13671
  }
13553
- const moduleDir = dirname12(fileURLToPath3(import.meta.url));
13554
- const jsPath = join30(moduleDir, "shaderTransitionWorker.js");
13555
- if (existsSync18(jsPath)) return { path: jsPath, isTs: false };
13556
- const tsPath = join30(moduleDir, "shaderTransitionWorker.ts");
13672
+ const moduleDir = dirname13(fileURLToPath4(import.meta.url));
13673
+ const jsPath = join31(moduleDir, "shaderTransitionWorker.js");
13674
+ if (existsSync19(jsPath)) return { path: jsPath, isTs: false };
13675
+ const tsPath = join31(moduleDir, "shaderTransitionWorker.ts");
13557
13676
  return { path: tsPath, isTs: true };
13558
13677
  }
13559
13678
  function buildExecArgv(entryIsTs) {
@@ -13674,7 +13793,7 @@ async function createShaderTransitionWorkerPool(opts) {
13674
13793
  };
13675
13794
  try {
13676
13795
  for (let i = 0; i < size; i++) {
13677
- const worker = new Worker(entry, { execArgv });
13796
+ const worker = new Worker2(entry, { execArgv });
13678
13797
  const slot = { worker, busy: false, current: null, dead: false };
13679
13798
  worker.on("message", (msg) => onWorkerMessage(slot, msg));
13680
13799
  worker.on(
@@ -13921,7 +14040,7 @@ async function runHybridLayeredFrameLoop(input) {
13921
14040
  );
13922
14041
  if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
13923
14042
  writeFileExclusiveSync(
13924
- join31(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
14043
+ join32(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
13925
14044
  canvas
13926
14045
  );
13927
14046
  }
@@ -14117,8 +14236,8 @@ async function runCaptureHdrStage(input) {
14117
14236
  if (hdrVideoFrameSources.has(v.id)) hdrVideoEndTimes.set(v.id, v.end);
14118
14237
  }
14119
14238
  const debugDumpEnabled = process.env.KEEP_TEMP === "1";
14120
- const debugDumpDir = debugDumpEnabled ? join32(framesDir, "debug-composite") : null;
14121
- if (debugDumpDir && !existsSync19(debugDumpDir)) {
14239
+ const debugDumpDir = debugDumpEnabled ? join33(framesDir, "debug-composite") : null;
14240
+ if (debugDumpDir && !existsSync20(debugDumpDir)) {
14122
14241
  mkdirSync10(debugDumpDir, { recursive: true });
14123
14242
  }
14124
14243
  const compositeTransfer = resolveCompositeTransfer(hasHdrContent, effectiveHdr);
@@ -14277,7 +14396,7 @@ async function runCaptureHdrStage(input) {
14277
14396
  // src/services/render/stages/encodeStage.ts
14278
14397
  import {
14279
14398
  copyFileSync as copyFileSync4,
14280
- existsSync as existsSync20,
14399
+ existsSync as existsSync21,
14281
14400
  mkdirSync as mkdirSync11,
14282
14401
  readdirSync as readdirSync5,
14283
14402
  readFileSync as readFileSync9,
@@ -14286,7 +14405,7 @@ import {
14286
14405
  writeFileSync as writeFileSync5
14287
14406
  } from "node:fs";
14288
14407
  import { readFile as readFile2 } from "node:fs/promises";
14289
- import { dirname as dirname13, join as join33 } from "node:path";
14408
+ import { dirname as dirname14, join as join34 } from "node:path";
14290
14409
  import {
14291
14410
  encodeFramesChunkedConcat,
14292
14411
  encodeFramesFromDir,
@@ -14411,7 +14530,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
14411
14530
  const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
14412
14531
  if (failure) return failure;
14413
14532
  }
14414
- const fileSize = existsSync20(outputPath) ? statSync9(outputPath).size : 0;
14533
+ const fileSize = existsSync21(outputPath) ? statSync9(outputPath).size : 0;
14415
14534
  return {
14416
14535
  success: true,
14417
14536
  outputPath,
@@ -14505,7 +14624,7 @@ function encodeWhileCapturing(input, totalFrames, captureBudget) {
14505
14624
  await new Promise((resolve14) => wake = resolve14);
14506
14625
  }
14507
14626
  if (signal.aborted) return;
14508
- const mergedPath = join33(input.framesDir, formatCaptureFrameName(next, "jpg"));
14627
+ const mergedPath = join34(input.framesDir, formatCaptureFrameName(next, "jpg"));
14509
14628
  const frame = await readLandedFrame(landed.get(next), mergedPath);
14510
14629
  landed.delete(next);
14511
14630
  if (!await stream.writeFrame(frame)) {
@@ -14580,7 +14699,7 @@ async function runEncodeStage(input) {
14580
14699
  const stage5Start = Date.now();
14581
14700
  if (isPngSequence) {
14582
14701
  const encoded = startEncodeProgress(job, "Writing PNG sequence", onProgress);
14583
- if (!existsSync20(outputPath)) mkdirSync11(outputPath, { recursive: true });
14702
+ if (!existsSync21(outputPath)) mkdirSync11(outputPath, { recursive: true });
14584
14703
  const captured = readdirSync5(framesDir).filter((name) => name.endsWith(".png")).sort();
14585
14704
  if (captured.length === 0) {
14586
14705
  throw new Error(
@@ -14588,11 +14707,11 @@ async function runEncodeStage(input) {
14588
14707
  );
14589
14708
  }
14590
14709
  captured.forEach((name, i) => {
14591
- const dst = join33(outputPath, formatExportFrameName(i, "png"));
14592
- copyFileSync4(join33(framesDir, name), dst);
14710
+ const dst = join34(outputPath, formatExportFrameName(i, "png"));
14711
+ copyFileSync4(join34(framesDir, name), dst);
14593
14712
  });
14594
- if (hasAudio && audioOutputPath && existsSync20(audioOutputPath)) {
14595
- copyFileSync4(audioOutputPath, join33(outputPath, MIXED_AUDIO_FILENAME2));
14713
+ if (hasAudio && audioOutputPath && existsSync21(audioOutputPath)) {
14714
+ copyFileSync4(audioOutputPath, join34(outputPath, MIXED_AUDIO_FILENAME2));
14596
14715
  log.info(
14597
14716
  `[Render] png-sequence: ${MIXED_AUDIO_FILENAME2} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME2}`
14598
14717
  );
@@ -14612,7 +14731,7 @@ async function runEncodeStage(input) {
14612
14731
  const encodeResult2 = await encodeGifFromDir(framesDir, framePattern2, outputPath, {
14613
14732
  fps: job.config.fps,
14614
14733
  loop,
14615
- palettePath: join33(dirname13(videoOnlyPath), "gif-palette.png"),
14734
+ palettePath: join34(dirname14(videoOnlyPath), "gif-palette.png"),
14616
14735
  preserveAlpha: needsAlpha,
14617
14736
  signal: abortSignal,
14618
14737
  timeout: engineCfg.ffmpegEncodeTimeout
@@ -14823,7 +14942,7 @@ function sampleDirectoryBytes(dir) {
14823
14942
  continue;
14824
14943
  }
14825
14944
  for (const name of entries) {
14826
- const full = join34(current, name);
14945
+ const full = join35(current, name);
14827
14946
  try {
14828
14947
  const st = statSync10(full);
14829
14948
  if (st.isDirectory()) {
@@ -14981,8 +15100,8 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
14981
15100
  const ranges = [];
14982
15101
  let rangeStart = null;
14983
15102
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
14984
- const framePath = join34(framesDir, formatCaptureFrameName(frameIndex, frameExt));
14985
- const missing = !existsSync21(framePath) || statSync10(framePath).size <= 8;
15103
+ const framePath = join35(framesDir, formatCaptureFrameName(frameIndex, frameExt));
15104
+ const missing = !existsSync22(framePath) || statSync10(framePath).size <= 8;
14986
15105
  if (missing && rangeStart === null) {
14987
15106
  rangeStart = frameIndex;
14988
15107
  } else if (!missing && rangeStart !== null) {
@@ -14998,7 +15117,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
14998
15117
  function buildMissingFrameRetryBatches(ranges, maxWorkers, workDir, attempt, rangeStart = 0, stride = 1) {
14999
15118
  const workersPerBatch = Math.max(1, Math.floor(maxWorkers));
15000
15119
  const batches = [];
15001
- const outputDirFor = (batchIndex, workerId) => join34(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
15120
+ const outputDirFor = (batchIndex, workerId) => join35(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
15002
15121
  if (stride > 1) {
15003
15122
  const spans = /* @__PURE__ */ new Map();
15004
15123
  for (const range of ranges) {
@@ -15058,8 +15177,8 @@ function getNextRetryWorkerCount(currentWorkers) {
15058
15177
  return Math.max(1, Math.floor(currentWorkers / 2));
15059
15178
  }
15060
15179
  function resolveRenderWorkDirPrefix(outputPath, jobId, platform2 = process.platform, systemTempDir = tmpdir3()) {
15061
- if (platform2 === "win32" || platform2 === "darwin") return join34(systemTempDir, "hf-render-");
15062
- return join34(dirname14(outputPath), `work-${jobId}-`);
15180
+ if (platform2 === "win32" || platform2 === "darwin") return join35(systemTempDir, "hf-render-");
15181
+ return join35(dirname15(outputPath), `work-${jobId}-`);
15063
15182
  }
15064
15183
  var MAX_TRANSIENT_CAPTURE_RETRIES = 1;
15065
15184
  function isTransientCaptureRetryEligible(failureKind, missing, retriesUsed) {
@@ -15114,8 +15233,8 @@ The composition is too large for the available memory. To reduce memory pressure
15114
15233
  function countCapturedFrames(totalFrames, framesDir, frameExt) {
15115
15234
  let captured = 0;
15116
15235
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
15117
- const framePath = join34(framesDir, formatCaptureFrameName(frameIndex, frameExt));
15118
- if (existsSync21(framePath)) captured++;
15236
+ const framePath = join35(framesDir, formatCaptureFrameName(frameIndex, frameExt));
15237
+ if (existsSync22(framePath)) captured++;
15119
15238
  }
15120
15239
  return captured;
15121
15240
  }
@@ -15140,7 +15259,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
15140
15259
  reason: attempt === 0 ? "initial" : pendingTransientRetry ? "transient-retry" : "retry"
15141
15260
  });
15142
15261
  pendingTransientRetry = false;
15143
- const attemptWorkDir = join34(options.workDir, `capture-attempt-${attempt}`);
15262
+ const attemptWorkDir = join35(options.workDir, `capture-attempt-${attempt}`);
15144
15263
  const batches = missingRanges ? buildMissingFrameRetryBatches(
15145
15264
  missingRanges,
15146
15265
  currentWorkers,
@@ -15787,20 +15906,20 @@ function deVerifyFallbackTelemetry(err) {
15787
15906
  };
15788
15907
  }
15789
15908
  function resolveRenderDebugDir() {
15790
- const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve9(process.env.PRODUCER_RENDERS_DIR, "..") : resolve9(dirname14(fileURLToPath4(import.meta.url)), "../..");
15791
- return join34(producerRoot, ".debug");
15909
+ const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve9(process.env.PRODUCER_RENDERS_DIR, "..") : resolve9(dirname15(fileURLToPath5(import.meta.url)), "../..");
15910
+ return join35(producerRoot, ".debug");
15792
15911
  }
15793
15912
  async function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
15794
15913
  validateHlsRenderConfig(job.config);
15795
15914
  validateDeliveryEncoderConfig(job.config);
15796
15915
  validateChromaSubsamplingConfig(job.config);
15797
15916
  const debugDir = resolveRenderDebugDir();
15798
- const outputDir = dirname14(outputPath);
15799
- if (!existsSync21(outputDir)) mkdirSync12(outputDir, { recursive: true });
15800
- const workDir = job.config.debug ? join34(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
15917
+ const outputDir = dirname15(outputPath);
15918
+ if (!existsSync22(outputDir)) mkdirSync12(outputDir, { recursive: true });
15919
+ const workDir = job.config.debug ? join35(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
15801
15920
  const pipelineStart = Date.now();
15802
15921
  const baseLog = job.config.logger ?? defaultLogger;
15803
- const logPath = job.config.debug ? join34(workDir, "render.log") : null;
15922
+ const logPath = job.config.debug ? join35(workDir, "render.log") : null;
15804
15923
  const execution = new RenderExecutionContext({
15805
15924
  request: { renderJobId: job.id, projectDir, outputPath },
15806
15925
  logger: logPath ? createRenderFileLogger(logPath, baseLog) : baseLog,
@@ -15877,7 +15996,7 @@ async function executeRenderPipeline(input) {
15877
15996
  imageDecodeFailures: 0
15878
15997
  };
15879
15998
  let hdrPerf;
15880
- const perfOutputPath = join34(workDir, "perf-summary.json");
15999
+ const perfOutputPath = join35(workDir, "perf-summary.json");
15881
16000
  const cfg = { ...job.config.producerConfig ?? resolveConfig2() };
15882
16001
  const observability = new RenderObservabilityRecorder({
15883
16002
  pipelineStartMs: pipelineStart,
@@ -15953,7 +16072,7 @@ async function executeRenderPipeline(input) {
15953
16072
  job.startedAt = /* @__PURE__ */ new Date();
15954
16073
  assertNotAborted();
15955
16074
  assertConfiguredFfmpegBinariesExist();
15956
- if (!existsSync21(workDir)) mkdirSync12(workDir, { recursive: true });
16075
+ if (!existsSync22(workDir)) mkdirSync12(workDir, { recursive: true });
15957
16076
  if (job.config.debug) {
15958
16077
  log.info("[Render] Debug artifacts enabled", { workDir, logPath });
15959
16078
  }
@@ -15982,8 +16101,8 @@ async function executeRenderPipeline(input) {
15982
16101
  requestedWorkers: job.config.workers ?? "auto"
15983
16102
  });
15984
16103
  const entryFile = job.config.entryFile || "index.html";
15985
- const htmlPath = join34(projectDir, entryFile);
15986
- if (!existsSync21(htmlPath)) {
16104
+ const htmlPath = join35(projectDir, entryFile);
16105
+ if (!existsSync22(htmlPath)) {
15987
16106
  throw new Error(`Entry file not found: ${htmlPath}`);
15988
16107
  }
15989
16108
  assertNotAborted();
@@ -16080,7 +16199,7 @@ async function executeRenderPipeline(input) {
16080
16199
  const largerThanCanvas = await oversizedVideos(
16081
16200
  composition.videos,
16082
16201
  projectDir,
16083
- join34(workDir, "compiled"),
16202
+ join35(workDir, "compiled"),
16084
16203
  { width: outputWidth, height: outputHeight }
16085
16204
  );
16086
16205
  const probeResult = await observeRenderStage(
@@ -16177,7 +16296,7 @@ async function executeRenderPipeline(input) {
16177
16296
  canvas: { width, height },
16178
16297
  page: probeSession.page,
16179
16298
  projectDir,
16180
- compiledDir: join34(workDir, "compiled")
16299
+ compiledDir: join35(workDir, "compiled")
16181
16300
  });
16182
16301
  if (videoLayerPlan.videoId === void 0) {
16183
16302
  log.info(`[Render] Video layer passthrough off: ${videoLayerPlan.reason}`);
@@ -16195,7 +16314,7 @@ async function executeRenderPipeline(input) {
16195
16314
  updateJobStatus(job, "preprocessing", "Extracting video frames", 10, onProgress, {
16196
16315
  code: "extract_video"
16197
16316
  });
16198
- const compiledDir = join34(workDir, "compiled");
16317
+ const compiledDir = join35(workDir, "compiled");
16199
16318
  const segmentsCapture = (layeredOrEffectRoute) => shouldSegmentCapture({
16200
16319
  env: process.env,
16201
16320
  durationSeconds: probeResult.duration,
@@ -16336,7 +16455,7 @@ async function executeRenderPipeline(input) {
16336
16455
  try {
16337
16456
  fileServer = await createFileServer({
16338
16457
  projectDir,
16339
- compiledDir: join34(workDir, "compiled"),
16458
+ compiledDir: join35(workDir, "compiled"),
16340
16459
  port: 0,
16341
16460
  preHeadScripts: [VIRTUAL_TIME_SHIM],
16342
16461
  fps: job.config.fps,
@@ -16356,8 +16475,8 @@ async function executeRenderPipeline(input) {
16356
16475
  if (!activeFileServer) {
16357
16476
  throw new Error("File server failed to initialize before frame capture");
16358
16477
  }
16359
- const framesDir = join34(workDir, "captured-frames");
16360
- if (!existsSync21(framesDir)) mkdirSync12(framesDir, { recursive: true });
16478
+ const framesDir = join35(workDir, "captured-frames");
16479
+ if (!existsSync22(framesDir)) mkdirSync12(framesDir, { recursive: true });
16361
16480
  updateJobStatus(job, "rendering", "Checking browser GPU", 25, onProgress, {
16362
16481
  code: "start_browsers"
16363
16482
  });
@@ -16937,7 +17056,7 @@ async function executeRenderPipeline(input) {
16937
17056
  hls: ".mp4"
16938
17057
  };
16939
17058
  const videoExt = FORMAT_EXT[outputFormat] ?? ".mp4";
16940
- const videoOnlyPath = join34(workDir, `video-only${videoExt}`);
17059
+ const videoOnlyPath = join35(workDir, `video-only${videoExt}`);
16941
17060
  let usePageSideCompositingForTransitions = (cfg.enablePageSideCompositing || isGif) && compiled.hasShaderTransitions && !hasHdrContent && outputSupportsPageSideShaderCompositing(outputFormat);
16942
17061
  if (usePageSideCompositingForTransitions) {
16943
17062
  activeFileServer.addPreHeadScript(HF_PAGE_SIDE_COMPOSITING_STUB);
@@ -17799,7 +17918,7 @@ async function executeRenderPipeline(input) {
17799
17918
  })
17800
17919
  );
17801
17920
  const totalElapsed = Date.now() - pipelineStart;
17802
- const tmpPeakBytes = existsSync21(workDir) ? sampleDirectoryBytes(workDir) : 0;
17921
+ const tmpPeakBytes = existsSync22(workDir) ? sampleDirectoryBytes(workDir) : 0;
17803
17922
  recordTransientRetryObservability();
17804
17923
  observability.checkpoint("pipeline", "artifact validated", { totalElapsedMs: totalElapsed });
17805
17924
  const observabilitySummary = observability.summary({
@@ -17880,8 +17999,8 @@ async function executeRenderPipeline(input) {
17880
17999
  }
17881
18000
  }
17882
18001
  if (job.config.debug) {
17883
- if (!isPngSequence && !isHls && existsSync21(stagedOutputPath)) {
17884
- const debugOutput = join34(workDir, `output${videoExt}`);
18002
+ if (!isPngSequence && !isHls && existsSync22(stagedOutputPath)) {
18003
+ const debugOutput = join35(workDir, `output${videoExt}`);
17885
18004
  copyFileSync5(stagedOutputPath, debugOutput);
17886
18005
  }
17887
18006
  }
@@ -18000,14 +18119,14 @@ import {
18000
18119
  referenceBackgroundResult as referenceBackgroundResult6
18001
18120
  } from "@hyperframes/engine";
18002
18121
  import { mkdirSync as mkdirSync20, mkdtempSync, readFileSync as readFileSync15, rmSync as rmSync18 } from "node:fs";
18003
- import { join as join48 } from "node:path";
18122
+ import { join as join49 } from "node:path";
18004
18123
  import { tmpdir as tmpdir5 } from "node:os";
18005
18124
 
18006
18125
  // src/services/distributed/mp4Stitch.ts
18007
18126
  import { createReadStream as createReadStream4, createWriteStream, mkdirSync as mkdirSync13, rmSync as rmSync13 } from "node:fs";
18008
18127
  import { open } from "node:fs/promises";
18009
18128
  import { renameWithRetry as renameWithRetry6 } from "@hyperframes/engine";
18010
- import { basename as basename8, dirname as dirname15, join as join35 } from "node:path";
18129
+ import { basename as basename8, dirname as dirname16, join as join36 } from "node:path";
18011
18130
  import { finished, pipeline } from "node:stream/promises";
18012
18131
  import { createStagingDir as createStagingDir4 } from "@hyperframes/core/atomic-file";
18013
18132
  function boxAt(src, off, at, limit) {
@@ -18372,15 +18491,15 @@ async function writeStitchedMp4(chunkPaths, outputPath, audioPath) {
18372
18491
  const sourcePaths = audioPath ? [audioPath, ...chunkPaths] : chunkPaths;
18373
18492
  const layouts = await Promise.all(sourcePaths.map((path) => readMp4Layout(fileRange(path))));
18374
18493
  const header = audioPath ? buildStitchedHeader(layouts.slice(1), layouts[0]) : buildStitchedHeader(layouts);
18375
- mkdirSync13(dirname15(outputPath), { recursive: true });
18376
- const workDir = createStagingDir4(dirname15(outputPath), `${basename8(outputPath)}.stitch-`);
18377
- const out = createWriteStream(join35(workDir, "out.mp4"));
18494
+ mkdirSync13(dirname16(outputPath), { recursive: true });
18495
+ const workDir = createStagingDir4(dirname16(outputPath), `${basename8(outputPath)}.stitch-`);
18496
+ const out = createWriteStream(join36(workDir, "out.mp4"));
18378
18497
  try {
18379
18498
  out.write(header);
18380
18499
  for (const [i, path] of sourcePaths.entries()) await copyPayload(path, layouts[i], i, out);
18381
18500
  out.end();
18382
18501
  await finished(out);
18383
- renameWithRetry6(join35(workDir, "out.mp4"), outputPath);
18502
+ renameWithRetry6(join36(workDir, "out.mp4"), outputPath);
18384
18503
  } finally {
18385
18504
  out.destroy();
18386
18505
  rmSync13(workDir, { recursive: true, force: true });
@@ -18397,13 +18516,13 @@ import { audioFailureDiagnostics as audioFailureDiagnostics3 } from "@hyperframe
18397
18516
  import {
18398
18517
  copyFileSync as copyFileSync6,
18399
18518
  cpSync as cpSync2,
18400
- existsSync as existsSync26,
18519
+ existsSync as existsSync27,
18401
18520
  linkSync,
18402
18521
  mkdirSync as mkdirSync16,
18403
18522
  rmSync as rmSync14,
18404
18523
  writeFileSync as writeFileSync9
18405
18524
  } from "node:fs";
18406
- import { extname as extname6, isAbsolute as isAbsolute4, join as join43, relative as relative7, sep as sep5 } from "node:path";
18525
+ import { extname as extname6, isAbsolute as isAbsolute4, join as join44, relative as relative7, sep as sep5 } from "node:path";
18407
18526
  import {
18408
18527
  fpsToNumber as fpsToNumber9,
18409
18528
  HF_COLOR_GRADING_ATTR as HF_COLOR_GRADING_ATTR2
@@ -18420,7 +18539,7 @@ import {
18420
18539
  } from "@hyperframes/engine";
18421
18540
 
18422
18541
  // src/services/distributed/planFrameCost.ts
18423
- import { join as join38 } from "node:path";
18542
+ import { join as join39 } from "node:path";
18424
18543
  import {
18425
18544
  closeCaptureSession as closeCaptureSession9,
18426
18545
  createCaptureSession as createCaptureSession9,
@@ -18429,8 +18548,8 @@ import {
18429
18548
  } from "@hyperframes/engine";
18430
18549
 
18431
18550
  // src/services/distributed/chunkFrames.ts
18432
- import { existsSync as existsSync23, readdirSync as readdirSync7 } from "node:fs";
18433
- import { extname as extname4, join as join37 } from "node:path";
18551
+ import { existsSync as existsSync24, readdirSync as readdirSync7 } from "node:fs";
18552
+ import { extname as extname4, join as join38 } from "node:path";
18434
18553
  import {
18435
18554
  compositionRequiresWebGpu as compositionRequiresWebGpu3,
18436
18555
  createVideoFrameInjector as createVideoFrameInjector3,
@@ -18439,9 +18558,9 @@ import {
18439
18558
 
18440
18559
  // src/services/distributed/shared.ts
18441
18560
  import { execFile as execFileCallback } from "node:child_process";
18442
- import { dirname as dirname16, join as join36 } from "node:path";
18443
- import { existsSync as existsSync22, readFileSync as readFileSync10 } from "node:fs";
18444
- import { fileURLToPath as fileURLToPath5 } from "node:url";
18561
+ import { dirname as dirname17, join as join37 } from "node:path";
18562
+ import { existsSync as existsSync23, readFileSync as readFileSync10 } from "node:fs";
18563
+ import { fileURLToPath as fileURLToPath6 } from "node:url";
18445
18564
  import { promisify as promisify2 } from "node:util";
18446
18565
  import {
18447
18566
  getFfmpegBinary,
@@ -18455,8 +18574,8 @@ function isPlanAudioArtifactPath(path) {
18455
18574
  }
18456
18575
  function resolvePlanAudioPath(planDir) {
18457
18576
  for (const name of [PLAN_AUDIO_RELATIVE_PATH, PLAN_AUDIO_LEGACY_RELATIVE_PATH]) {
18458
- const candidate = join36(planDir, name);
18459
- if (existsSync22(candidate)) return candidate;
18577
+ const candidate = join37(planDir, name);
18578
+ if (existsSync23(candidate)) return candidate;
18460
18579
  }
18461
18580
  return null;
18462
18581
  }
@@ -18717,11 +18836,11 @@ function buildSyntheticRenderJob(input) {
18717
18836
  var cachedProducerVersion = null;
18718
18837
  function readProducerVersion() {
18719
18838
  if (cachedProducerVersion !== null) return cachedProducerVersion;
18720
- const startDir = dirname16(fileURLToPath5(import.meta.url));
18839
+ const startDir = dirname17(fileURLToPath6(import.meta.url));
18721
18840
  let current = startDir;
18722
18841
  for (let i = 0; i < 10; i++) {
18723
- const candidate = join36(current, "package.json");
18724
- if (existsSync22(candidate)) {
18842
+ const candidate = join37(current, "package.json");
18843
+ if (existsSync23(candidate)) {
18725
18844
  try {
18726
18845
  const pkg = JSON.parse(readFileSync10(candidate, "utf-8"));
18727
18846
  if (pkg.name === "@hyperframes/producer" && typeof pkg.version === "string") {
@@ -18731,7 +18850,7 @@ function readProducerVersion() {
18731
18850
  } catch {
18732
18851
  }
18733
18852
  }
18734
- const parent = dirname16(current);
18853
+ const parent = dirname17(current);
18735
18854
  if (parent === current) break;
18736
18855
  current = parent;
18737
18856
  }
@@ -18775,8 +18894,8 @@ function frameNumberFromFileName(name) {
18775
18894
  function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v1") {
18776
18895
  const result = [];
18777
18896
  for (const v of videos) {
18778
- const outputDir = join37(planDir, "video-frames", mediaIdPathSegment3(v.videoId));
18779
- if (!existsSync23(outputDir)) {
18897
+ const outputDir = join38(planDir, "video-frames", mediaIdPathSegment3(v.videoId));
18898
+ if (!existsSync24(outputDir)) {
18780
18899
  throw new Error(
18781
18900
  `[renderChunk] planDir missing extracted video frames for ${JSON.stringify(v.videoId)}: ${outputDir} not present. plan() should have written frames here; the planDir is malformed.`
18782
18901
  );
@@ -18794,7 +18913,7 @@ function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v
18794
18913
  if (!frameName) continue;
18795
18914
  const frameNumber = indexMode === "sparse-v2" ? frameNumberFromFileName(frameName) : null;
18796
18915
  const frameIndex = frameNumber === null ? i : frameNumber - 1;
18797
- framePaths.set(frameIndex, join37(outputDir, frameName));
18916
+ framePaths.set(frameIndex, join38(outputDir, frameName));
18798
18917
  }
18799
18918
  result.push({
18800
18919
  videoId: v.videoId,
@@ -18874,8 +18993,8 @@ async function extractDeferredVideoFramesForChunk(input) {
18874
18993
  sourceOf: (video) => {
18875
18994
  const range = planned.get(video.videoId).deferredRange;
18876
18995
  const remoteUrl = remoteSources[range.sourcePath];
18877
- const sourcePath = remoteUrl ?? join37(input.planDir, ...range.sourcePath.split("/"));
18878
- if (remoteUrl === void 0 && !existsSync23(sourcePath)) {
18996
+ const sourcePath = remoteUrl ?? join38(input.planDir, ...range.sourcePath.split("/"));
18997
+ if (remoteUrl === void 0 && !existsSync24(sourcePath)) {
18879
18998
  throw new RenderChunkValidationError(
18880
18999
  MISSING_PLAN_ARTIFACT,
18881
19000
  `[renderChunk] planDir is missing the source for video ${JSON.stringify(video.videoId)}: ${range.sourcePath}`
@@ -18905,12 +19024,12 @@ async function measurePlanSecondsPerFrame(input) {
18905
19024
  planVideos,
18906
19025
  frames: sampled,
18907
19026
  fps: fpsRatio,
18908
- outputRoot: join38(workDir, "frame-cost-video-frames"),
19027
+ outputRoot: join39(workDir, "frame-cost-video-frames"),
18909
19028
  cfg: input.cfg
18910
19029
  })
18911
19030
  ];
18912
19031
  const lookup = extracted.length > 0 ? createFrameLookupTable4(planVideos.videos, extracted, resolveRenderFpsConfig(fpsRatio).value) : null;
18913
- const compiledDir = join38(planDir, "compiled");
19032
+ const compiledDir = join39(planDir, "compiled");
18914
19033
  const fileServer = await createFileServer({
18915
19034
  projectDir: compiledDir,
18916
19035
  compiledDir,
@@ -18922,7 +19041,7 @@ async function measurePlanSecondsPerFrame(input) {
18922
19041
  try {
18923
19042
  session = await createCaptureSession9(
18924
19043
  fileServer.url,
18925
- join38(workDir, "frame-cost"),
19044
+ join39(workDir, "frame-cost"),
18926
19045
  buildChunkCaptureOptions({
18927
19046
  dimensions: { ...input, fpsNum: fps, fpsDen: 1 },
18928
19047
  encoder: input,
@@ -19019,7 +19138,7 @@ function buildWeightedChunkSlices(weights, chunkCount, minFrames, maxFrames) {
19019
19138
  }
19020
19139
 
19021
19140
  // src/services/render/planReferenceBackground.ts
19022
- import { join as join39 } from "node:path";
19141
+ import { join as join40 } from "node:path";
19023
19142
  import {
19024
19143
  closeCaptureSession as closeCaptureSession10,
19025
19144
  createCaptureSession as createCaptureSession10,
@@ -19032,14 +19151,14 @@ async function readPlanReferenceBackground(input) {
19032
19151
  try {
19033
19152
  server = await createFileServer({
19034
19153
  projectDir: input.projectDir,
19035
- compiledDir: join39(input.workDir, "compiled"),
19154
+ compiledDir: join40(input.workDir, "compiled"),
19036
19155
  port: 0,
19037
19156
  preHeadScripts: [VIRTUAL_TIME_SHIM],
19038
19157
  fps: input.options.fps
19039
19158
  });
19040
19159
  session = await createCaptureSession10(
19041
19160
  server.url,
19042
- join39(input.workDir, "reference"),
19161
+ join40(input.workDir, "reference"),
19043
19162
  {
19044
19163
  ...input.options,
19045
19164
  requiresWebGpu: false
@@ -19075,8 +19194,8 @@ async function readPlanReferenceBackground(input) {
19075
19194
  }
19076
19195
 
19077
19196
  // src/services/render/stages/freezePlan.ts
19078
- import { existsSync as existsSync24, mkdirSync as mkdirSync14, readFileSync as readFileSync11, readdirSync as readdirSync8, writeFileSync as writeFileSync7 } from "node:fs";
19079
- import { join as join40, relative as relative5, resolve as resolve10 } from "node:path";
19197
+ import { existsSync as existsSync25, mkdirSync as mkdirSync14, readFileSync as readFileSync11, readdirSync as readdirSync8, writeFileSync as writeFileSync7 } from "node:fs";
19198
+ import { join as join41, relative as relative5, resolve as resolve10 } from "node:path";
19080
19199
  import {
19081
19200
  REFERENCE_BACKGROUND_FIELD,
19082
19201
  referenceBackgroundResult as referenceBackgroundResult3
@@ -19269,7 +19388,7 @@ function planFileSha256(absolutePath, digests) {
19269
19388
  return sha256;
19270
19389
  }
19271
19390
  async function prehashPlanFiles(dir, digests) {
19272
- if (!existsSync24(dir)) return;
19391
+ if (!existsSync25(dir)) return;
19273
19392
  for (const { absolutePath } of listPlanFiles(dir)) {
19274
19393
  if (!digests.has(absolutePath)) digests.set(absolutePath, await sha256FileAsync(absolutePath));
19275
19394
  }
@@ -19294,7 +19413,7 @@ function listPlanFiles(planDir) {
19294
19413
  function walk(dir) {
19295
19414
  const entries = readdirSync8(dir, { withFileTypes: true });
19296
19415
  for (const entry of entries) {
19297
- const full = join40(dir, entry.name);
19416
+ const full = join41(dir, entry.name);
19298
19417
  if (entry.isDirectory()) {
19299
19418
  walk(full);
19300
19419
  } else if (entry.isFile()) {
@@ -19335,19 +19454,19 @@ var PLAN_REMOTE_FILES_RELATIVE_PATH = "meta/remote-files.json";
19335
19454
  function writePlanRemoteFiles(planDir, files) {
19336
19455
  if (files.length === 0) return;
19337
19456
  const sorted = [...files].sort((a, b) => a.path < b.path ? -1 : 1);
19338
- writeFileSync7(join40(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH), JSON.stringify(sorted), "utf-8");
19457
+ writeFileSync7(join41(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH), JSON.stringify(sorted), "utf-8");
19339
19458
  }
19340
19459
  function readPlanRemoteFiles(planDir) {
19341
- const path = join40(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH);
19342
- return existsSync24(path) ? JSON.parse(readFileSync11(path, "utf-8")) : [];
19460
+ const path = join41(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH);
19461
+ return existsSync25(path) ? JSON.parse(readFileSync11(path, "utf-8")) : [];
19343
19462
  }
19344
19463
  function recomputePlanHashFromPlanDir(planDir, digests) {
19345
- const planJsonPath = join40(planDir, "plan.json");
19346
- const encoderJsonPath = join40(planDir, "meta", "encoder.json");
19347
- if (!existsSync24(planJsonPath)) {
19464
+ const planJsonPath = join41(planDir, "plan.json");
19465
+ const encoderJsonPath = join41(planDir, "meta", "encoder.json");
19466
+ if (!existsSync25(planJsonPath)) {
19348
19467
  throw new Error(`[freezePlan] plan.json missing: ${planJsonPath}`);
19349
19468
  }
19350
- if (!existsSync24(encoderJsonPath)) {
19469
+ if (!existsSync25(encoderJsonPath)) {
19351
19470
  throw new Error(`[freezePlan] meta/encoder.json missing: ${encoderJsonPath}`);
19352
19471
  }
19353
19472
  const planJson = JSON.parse(readFileSync11(planJsonPath, "utf-8"));
@@ -19377,21 +19496,21 @@ async function freezePlan(input) {
19377
19496
  hasAudio,
19378
19497
  digests
19379
19498
  } = input;
19380
- if (!existsSync24(planDir)) {
19499
+ if (!existsSync25(planDir)) {
19381
19500
  throw new Error(`[freezePlan] planDir does not exist: ${planDir}`);
19382
19501
  }
19383
- const metaDir = join40(planDir, "meta");
19384
- if (!existsSync24(metaDir)) mkdirSync14(metaDir, { recursive: true });
19502
+ const metaDir = join41(planDir, "meta");
19503
+ if (!existsSync25(metaDir)) mkdirSync14(metaDir, { recursive: true });
19385
19504
  writeFileSync7(
19386
- join40(metaDir, "composition.json"),
19505
+ join41(metaDir, "composition.json"),
19387
19506
  `${JSON.stringify(composition, null, 2)}
19388
19507
  `,
19389
19508
  "utf-8"
19390
19509
  );
19391
19510
  const encoderForCanonical = stripUndefined(encoder);
19392
19511
  const encoderConfigCanonicalJson = canonicalJsonStringify(encoderForCanonical);
19393
- writeFileSync7(join40(metaDir, "encoder.json"), encoderConfigCanonicalJson, "utf-8");
19394
- writeFileSync7(join40(metaDir, "chunks.json"), `${JSON.stringify(chunks, null, 2)}
19512
+ writeFileSync7(join41(metaDir, "encoder.json"), encoderConfigCanonicalJson, "utf-8");
19513
+ writeFileSync7(join41(metaDir, "chunks.json"), `${JSON.stringify(chunks, null, 2)}
19395
19514
  `, "utf-8");
19396
19515
  const { compositionHtml, assets } = collectPlanAssetShas(planDir, digests);
19397
19516
  const planHash = computePlanHash({
@@ -19416,7 +19535,7 @@ async function freezePlan(input) {
19416
19535
  duration: durationSeconds,
19417
19536
  hasAudio
19418
19537
  };
19419
- const planJsonPath = join40(planDir, "plan.json");
19538
+ const planJsonPath = join41(planDir, "plan.json");
19420
19539
  writeFileSync7(planJsonPath, `${JSON.stringify(planJson, null, 2)}
19421
19540
  `, "utf-8");
19422
19541
  return { planJsonPath, planHash };
@@ -19458,9 +19577,9 @@ function applyRuntimeEnvSnapshot(snapshot, env = process.env) {
19458
19577
  }
19459
19578
 
19460
19579
  // src/services/distributed/chunkAudio.ts
19461
- import { closeSync as closeSync7, existsSync as existsSync25, ftruncateSync, mkdirSync as mkdirSync15, openSync as openSync7, readFileSync as readFileSync12 } from "node:fs";
19580
+ import { closeSync as closeSync7, existsSync as existsSync26, ftruncateSync, mkdirSync as mkdirSync15, openSync as openSync7, readFileSync as readFileSync12 } from "node:fs";
19462
19581
  import { writeFileSync as writeFileSync8, writeSync } from "node:fs";
19463
- import { join as join41 } from "node:path";
19582
+ import { join as join42 } from "node:path";
19464
19583
  import { appendRenderProvenanceArgs, describeFfmpegFailure as describeFfmpegFailure4, runFfmpeg as runFfmpeg7 } from "@hyperframes/engine";
19465
19584
  function audioCutForChunk(grid, chunks, index, fps) {
19466
19585
  const firstPacketAt = (frame) => Math.min(
@@ -19548,7 +19667,7 @@ async function writeChunkAudioSlices(input) {
19548
19667
  });
19549
19668
  const bytes = readFileSync12(input.audioPath);
19550
19669
  const layout = { sizeBytes: bytes.length, payloadStart, payloadEnd, partStarts: {} };
19551
- mkdirSync15(join41(input.planDir, SLICE_DIR), { recursive: true });
19670
+ mkdirSync15(join42(input.planDir, SLICE_DIR), { recursive: true });
19552
19671
  input.chunks.forEach((_, index) => {
19553
19672
  const cut = audioCutForChunk(grid, input.chunks, index, input.fps);
19554
19673
  if (!cut) return;
@@ -19556,17 +19675,17 @@ async function writeChunkAudioSlices(input) {
19556
19675
  const start = offsets[cut.firstPacket];
19557
19676
  layout.partStarts[index] = start;
19558
19677
  const end = offsets[last] + track.sizes[last];
19559
- writeFileSync8(join41(input.planDir, chunkAudioSlicePath(index)), bytes.subarray(start, end));
19678
+ writeFileSync8(join42(input.planDir, chunkAudioSlicePath(index)), bytes.subarray(start, end));
19560
19679
  });
19561
19680
  const frame = [bytes.subarray(0, payloadStart), bytes.subarray(payloadEnd)];
19562
- writeFileSync8(join41(input.planDir, SLICE_FRAME), Buffer.concat(frame));
19563
- writeFileSync8(join41(input.planDir, SLICE_LAYOUT), JSON.stringify(layout));
19681
+ writeFileSync8(join42(input.planDir, SLICE_FRAME), Buffer.concat(frame));
19682
+ writeFileSync8(join42(input.planDir, SLICE_LAYOUT), JSON.stringify(layout));
19564
19683
  }
19565
19684
  function chunkAudioSource(planDir, chunkIndex, scratchPath) {
19566
- const layoutPath = join41(planDir, SLICE_LAYOUT);
19567
- if (!existsSync25(layoutPath)) return resolvePlanAudioPath(planDir);
19685
+ const layoutPath = join42(planDir, SLICE_LAYOUT);
19686
+ if (!existsSync26(layoutPath)) return resolvePlanAudioPath(planDir);
19568
19687
  const layout = JSON.parse(readFileSync12(layoutPath, "utf-8"));
19569
- const frame = readFileSync12(join41(planDir, SLICE_FRAME));
19688
+ const frame = readFileSync12(join42(planDir, SLICE_FRAME));
19570
19689
  const fd = openSync7(scratchPath, "w");
19571
19690
  try {
19572
19691
  writeSync(fd, frame, 0, layout.payloadStart, 0);
@@ -19579,7 +19698,7 @@ function chunkAudioSource(planDir, chunkIndex, scratchPath) {
19579
19698
  );
19580
19699
  const start = layout.partStarts[chunkIndex];
19581
19700
  if (start !== void 0) {
19582
- const part = readFileSync12(join41(planDir, chunkAudioSlicePath(chunkIndex)));
19701
+ const part = readFileSync12(join42(planDir, chunkAudioSlicePath(chunkIndex)));
19583
19702
  writeSync(fd, part, 0, part.length, start);
19584
19703
  }
19585
19704
  ftruncateSync(fd, layout.sizeBytes);
@@ -19635,7 +19754,7 @@ async function muxChunkWithAudio(input) {
19635
19754
  // src/services/distributed/planSize.ts
19636
19755
  import { createHash as createHash9 } from "node:crypto";
19637
19756
  import { lstatSync as lstatSync4, readdirSync as readdirSync9 } from "node:fs";
19638
- import { extname as extname5, join as join42, relative as relative6 } from "node:path";
19757
+ import { extname as extname5, join as join43, relative as relative6 } from "node:path";
19639
19758
  var MAX_TOP_COMPONENTS = 10;
19640
19759
  var SOURCE_MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
19641
19760
  ".aac",
@@ -19747,7 +19866,7 @@ function walkRegularFiles(dir, visit) {
19747
19866
  return;
19748
19867
  }
19749
19868
  for (const entry of entries) {
19750
- const full = join42(dir, entry.name);
19869
+ const full = join43(dir, entry.name);
19751
19870
  if (entry.isDirectory()) {
19752
19871
  walkRegularFiles(full, visit);
19753
19872
  } else if (entry.isFile()) {
@@ -19963,13 +20082,13 @@ function assertPositiveInteger2(name, value) {
19963
20082
  }
19964
20083
  var FREEZE_OWNED_PLAN_FILES = [
19965
20084
  "plan.json",
19966
- join43("meta", "composition.json"),
19967
- join43("meta", "encoder.json"),
19968
- join43("meta", "chunks.json")
20085
+ join44("meta", "composition.json"),
20086
+ join44("meta", "encoder.json"),
20087
+ join44("meta", "chunks.json")
19969
20088
  ];
19970
20089
  function removeFreezeOwnedPlanFiles(planDir) {
19971
20090
  for (const relativePath of FREEZE_OWNED_PLAN_FILES) {
19972
- rmSync14(join43(planDir, relativePath), { force: true });
20091
+ rmSync14(join44(planDir, relativePath), { force: true });
19973
20092
  }
19974
20093
  }
19975
20094
  function buildChunkSlices(totalFrames, chunkCount, effectiveChunkSize) {
@@ -20127,19 +20246,19 @@ function createVideoSourceShipper(input) {
20127
20246
  const known = shipped.get(srcPath);
20128
20247
  if (known) return known;
20129
20248
  const stagedRel = pathInside(input.workVideoFramesDir, srcPath);
20130
- const current = stagedRel === null ? srcPath : join43(input.planDir, "video-frames", stagedRel);
20249
+ const current = stagedRel === null ? srcPath : join44(input.planDir, "video-frames", stagedRel);
20131
20250
  let result = null;
20132
20251
  for (const root of stagedRel === null ? [input.workCompiledDir, input.projectDir] : []) {
20133
20252
  const rel = pathInside(root, srcPath);
20134
- if (rel !== null && (existsSync26(join43(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
20253
+ if (rel !== null && (existsSync27(join44(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
20135
20254
  result = ["compiled", ...rel.split(sep5)].join("/");
20136
20255
  break;
20137
20256
  }
20138
20257
  }
20139
20258
  if (result === null) {
20140
20259
  result = `video-sources/${shipped.size}${extname6(current)}`;
20141
- const destination = join43(input.planDir, ...result.split("/"));
20142
- mkdirSync16(join43(input.planDir, "video-sources"), { recursive: true });
20260
+ const destination = join44(input.planDir, ...result.split("/"));
20261
+ mkdirSync16(join44(input.planDir, "video-sources"), { recursive: true });
20143
20262
  try {
20144
20263
  linkSync(current, destination);
20145
20264
  } catch {
@@ -20159,7 +20278,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
20159
20278
  useGpu: false,
20160
20279
  browserGpuMode: "software"
20161
20280
  });
20162
- if (!existsSync26(planDir)) mkdirSync16(planDir, { recursive: true });
20281
+ if (!existsSync27(planDir)) mkdirSync16(planDir, { recursive: true });
20163
20282
  const log = config.logger ?? defaultLogger;
20164
20283
  const sizeLimitBytes = options.executionPlanSizeLimitBytes ?? config.planDirSizeLimitBytes ?? PLAN_DIR_SIZE_LIMIT_BYTES;
20165
20284
  const abortSignal = config.abortSignal;
@@ -20193,14 +20312,14 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
20193
20312
  includeOutsideScripts: options.includeOutsideScripts === true
20194
20313
  });
20195
20314
  const entryFile = config.entryFile ?? "index.html";
20196
- const htmlPath = join43(projectDir, entryFile);
20197
- if (!existsSync26(htmlPath)) {
20315
+ const htmlPath = join44(projectDir, entryFile);
20316
+ if (!existsSync27(htmlPath)) {
20198
20317
  throw new Error(`[plan] entry file not found: ${htmlPath}`);
20199
20318
  }
20200
- const workDir = join43(planDir, ".plan-work");
20319
+ const workDir = join44(planDir, ".plan-work");
20201
20320
  rmSync14(workDir, { recursive: true, force: true });
20202
20321
  mkdirSync16(workDir, { recursive: true });
20203
- const compiledDir = join43(workDir, "compiled");
20322
+ const compiledDir = join44(workDir, "compiled");
20204
20323
  mkdirSync16(compiledDir, { recursive: true });
20205
20324
  let stageStarted = Date.now();
20206
20325
  cpSync2(projectDir, compiledDir, {
@@ -20220,10 +20339,10 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
20220
20339
  }
20221
20340
  });
20222
20341
  logPlanStage(log, "copy", stageStarted);
20223
- const finalCompiledDir = join43(planDir, "compiled");
20342
+ const finalCompiledDir = join44(planDir, "compiled");
20224
20343
  const needsAlpha = outputNeedsAlpha(config.format);
20225
20344
  const remoteFiles = Object.entries(options.remoteFiles ?? {});
20226
- const remoteLocalPath = (rel) => join43(projectDir, ...rel.split("/"));
20345
+ const remoteLocalPath = (rel) => join44(projectDir, ...rel.split("/"));
20227
20346
  for (const [, file] of remoteFiles) {
20228
20347
  declareContentAddressedUrl(file.url, file.sha256);
20229
20348
  if (file.probeFactsUrl) declareProbeFactsUrl(file.url, file.probeFactsUrl);
@@ -20428,17 +20547,17 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
20428
20547
  let stageStarted = Date.now();
20429
20548
  const extractResult = await extractPlanVideos(c, options.deferVideoExtraction);
20430
20549
  logPlanStage(log, "extract", stageStarted);
20431
- const stagedVideoFrames = join43(compiledDir, "__hyperframes_video_frames");
20432
- const videoFramesDst = join43(planDir, "video-frames");
20433
- if (existsSync26(videoFramesDst)) rmSync14(videoFramesDst, { recursive: true, force: true });
20434
- const videoSourcesDir = join43(planDir, "video-sources");
20550
+ const stagedVideoFrames = join44(compiledDir, "__hyperframes_video_frames");
20551
+ const videoFramesDst = join44(planDir, "video-frames");
20552
+ if (existsSync27(videoFramesDst)) rmSync14(videoFramesDst, { recursive: true, force: true });
20553
+ const videoSourcesDir = join44(planDir, "video-sources");
20435
20554
  rmSync14(videoSourcesDir, { recursive: true, force: true });
20436
- if (existsSync26(stagedVideoFrames)) {
20555
+ if (existsSync27(stagedVideoFrames)) {
20437
20556
  renameWithRetry7(stagedVideoFrames, videoFramesDst);
20438
20557
  } else {
20439
20558
  mkdirSync16(videoFramesDst, { recursive: true });
20440
20559
  }
20441
- if (existsSync26(finalCompiledDir)) rmSync14(finalCompiledDir, { recursive: true, force: true });
20560
+ if (existsSync27(finalCompiledDir)) rmSync14(finalCompiledDir, { recursive: true, force: true });
20442
20561
  renameWithRetry7(compiledDir, finalCompiledDir);
20443
20562
  const shipVideoSource = createVideoSourceShipper({
20444
20563
  planDir,
@@ -20468,7 +20587,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
20468
20587
  };
20469
20588
  })
20470
20589
  });
20471
- mkdirSync16(join43(planDir, "meta"), { recursive: true });
20590
+ mkdirSync16(join44(planDir, "meta"), { recursive: true });
20472
20591
  writePlanRemoteFiles(
20473
20592
  planDir,
20474
20593
  remoteFiles.map(([rel, { sha256, sizeBytes }]) => ({
@@ -20478,7 +20597,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
20478
20597
  }))
20479
20598
  );
20480
20599
  writeFileSync9(
20481
- join43(planDir, PLAN_VIDEOS_META_RELATIVE_PATH),
20600
+ join44(planDir, PLAN_VIDEOS_META_RELATIVE_PATH),
20482
20601
  JSON.stringify(planVideosJson, null, 2),
20483
20602
  "utf-8"
20484
20603
  );
@@ -20558,11 +20677,11 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
20558
20677
  if (audioResult?.audioError) {
20559
20678
  applyDistributedAudioWarningPolicy(job, audioResult.audioError, audioResult.audioFailures, log);
20560
20679
  }
20561
- const planAudioPath = join43(planDir, PLAN_AUDIO_RELATIVE_PATH);
20562
- if (audioResult?.hasAudio && existsSync26(audioResult.audioOutputPath)) {
20680
+ const planAudioPath = join44(planDir, PLAN_AUDIO_RELATIVE_PATH);
20681
+ if (audioResult?.hasAudio && existsSync27(audioResult.audioOutputPath)) {
20563
20682
  renameWithRetry7(audioResult.audioOutputPath, planAudioPath);
20564
20683
  }
20565
- if (chunksCarryAudio && existsSync26(planAudioPath)) {
20684
+ if (chunksCarryAudio && existsSync27(planAudioPath)) {
20566
20685
  if (options.sliceChunkAudio) {
20567
20686
  stageStarted = Date.now();
20568
20687
  await writeChunkAudioSlices({
@@ -20684,8 +20803,8 @@ async function plan(projectDir, config, planDir, options = {}) {
20684
20803
 
20685
20804
  // src/services/distributed/renderChunk.ts
20686
20805
  import { randomBytes } from "node:crypto";
20687
- import { existsSync as existsSync29, mkdirSync as mkdirSync19, readFileSync as readFileSync14, readdirSync as readdirSync11, rmSync as rmSync17, writeFileSync as writeFileSync12 } from "node:fs";
20688
- import { join as join47 } from "node:path";
20806
+ import { existsSync as existsSync30, mkdirSync as mkdirSync19, readFileSync as readFileSync14, readdirSync as readdirSync11, rmSync as rmSync17, writeFileSync as writeFileSync12 } from "node:fs";
20807
+ import { join as join48 } from "node:path";
20689
20808
  import {
20690
20809
  assertSwiftShader,
20691
20810
  BROWSER_GPU_NOT_SOFTWARE as BROWSER_GPU_NOT_SOFTWARE4,
@@ -20711,7 +20830,7 @@ import {
20711
20830
  } from "@hyperframes/engine";
20712
20831
  import {
20713
20832
  copyFileSync as copyFileSync8,
20714
- existsSync as existsSync28,
20833
+ existsSync as existsSync29,
20715
20834
  lstatSync as lstatSync5,
20716
20835
  mkdirSync as mkdirSync18,
20717
20836
  readFileSync as readFileSync13,
@@ -20721,7 +20840,7 @@ import {
20721
20840
  writeFileSync as writeFileSync11
20722
20841
  } from "node:fs";
20723
20842
  import { tmpdir as tmpdir4 } from "node:os";
20724
- import { dirname as dirname18, isAbsolute as isAbsolute5, join as join46, relative as relative8, resolve as resolve11, sep as sep6 } from "node:path";
20843
+ import { dirname as dirname19, isAbsolute as isAbsolute5, join as join47, relative as relative8, resolve as resolve11, sep as sep6 } from "node:path";
20725
20844
  import { DISTRIBUTED_FPS, isDistributedFps } from "@hyperframes/core";
20726
20845
  import {
20727
20846
  createFrameLookupTable as createFrameLookupTable5,
@@ -20732,7 +20851,7 @@ import {
20732
20851
  // src/services/distributed/planV2Publisher.ts
20733
20852
  import {
20734
20853
  copyFileSync as copyFileSync7,
20735
- existsSync as existsSync27,
20854
+ existsSync as existsSync28,
20736
20855
  linkSync as linkSync2,
20737
20856
  mkdirSync as mkdirSync17,
20738
20857
  rmSync as rmSync15,
@@ -20740,7 +20859,7 @@ import {
20740
20859
  writeFileSync as writeFileSync10
20741
20860
  } from "node:fs";
20742
20861
  import { renameWithRetry as renameWithRetry8 } from "@hyperframes/engine";
20743
- import { dirname as dirname17, join as join45 } from "node:path";
20862
+ import { dirname as dirname18, join as join46 } from "node:path";
20744
20863
 
20745
20864
  // src/services/distributed/planV2Errors.ts
20746
20865
  var PLAN_V2_INTEGRITY_UNRECOVERABLE = "PLAN_V2_INTEGRITY_UNRECOVERABLE";
@@ -20755,7 +20874,7 @@ var PlanV2IntegrityError = class extends Error {
20755
20874
  };
20756
20875
 
20757
20876
  // src/services/distributed/planV2Layout.ts
20758
- import { join as join44 } from "node:path";
20877
+ import { join as join45 } from "node:path";
20759
20878
  var SHA256_PATTERN = /^[0-9a-f]{64}$/;
20760
20879
  function assertPlanV2Sha256(value, field) {
20761
20880
  if (typeof value !== "string" || !SHA256_PATTERN.test(value)) {
@@ -20765,7 +20884,7 @@ function assertPlanV2Sha256(value, field) {
20765
20884
  }
20766
20885
  function planV2BlobPath(root, sha256) {
20767
20886
  const digest = assertPlanV2Sha256(sha256, "artifact sha256");
20768
- return join44(root, "artifacts", "sha256", digest.slice(0, 2), digest);
20887
+ return join45(root, "artifacts", "sha256", digest.slice(0, 2), digest);
20769
20888
  }
20770
20889
 
20771
20890
  // src/services/distributed/planV2Publisher.ts
@@ -20796,13 +20915,13 @@ var LocalPlanV2ArtifactPublisher = class {
20796
20915
  #linkFile;
20797
20916
  #committed = false;
20798
20917
  constructor(destinationDir, options = {}) {
20799
- if (existsSync27(destinationDir)) {
20918
+ if (existsSync28(destinationDir)) {
20800
20919
  throw new PlanV2IntegrityError(`output directory already exists: ${destinationDir}`);
20801
20920
  }
20802
20921
  this.destinationDir = destinationDir;
20803
20922
  this.#linkFile = options.linkFile ?? linkSync2;
20804
- mkdirSync17(dirname17(destinationDir), { recursive: true });
20805
- this.temporaryDir = createStagingDir5(dirname17(destinationDir), ".plan-v2-publish-");
20923
+ mkdirSync17(dirname18(destinationDir), { recursive: true });
20924
+ this.temporaryDir = createStagingDir5(dirname18(destinationDir), ".plan-v2-publish-");
20806
20925
  }
20807
20926
  async putBlob(blob) {
20808
20927
  const digest = assertPlanV2Sha256(blob.sha256, "published blob sha256");
@@ -20813,10 +20932,10 @@ var LocalPlanV2ArtifactPublisher = class {
20813
20932
  );
20814
20933
  }
20815
20934
  const destinationPath = planV2BlobPath(this.temporaryDir, digest);
20816
- if (existsSync27(destinationPath)) return;
20817
- mkdirSync17(dirname17(destinationPath), { recursive: true });
20818
- const stagingDir = createStagingDir5(dirname17(destinationPath), ".plan-v2-blob-");
20819
- const temporaryPath = join45(stagingDir, "blob");
20935
+ if (existsSync28(destinationPath)) return;
20936
+ mkdirSync17(dirname18(destinationPath), { recursive: true });
20937
+ const stagingDir = createStagingDir5(dirname18(destinationPath), ".plan-v2-blob-");
20938
+ const temporaryPath = join46(stagingDir, "blob");
20820
20939
  try {
20821
20940
  try {
20822
20941
  this.#linkFile(blob.sourcePath, temporaryPath);
@@ -20831,13 +20950,13 @@ var LocalPlanV2ArtifactPublisher = class {
20831
20950
  }
20832
20951
  async commitManifest(manifestBytes) {
20833
20952
  for (const digest of new Set(manifestDigests(manifestBytes))) {
20834
- if (!existsSync27(planV2BlobPath(this.temporaryDir, digest))) {
20953
+ if (!existsSync28(planV2BlobPath(this.temporaryDir, digest))) {
20835
20954
  throw new PlanV2IntegrityError(
20836
20955
  `cannot commit manifest before referenced blob is durable: ${digest}`
20837
20956
  );
20838
20957
  }
20839
20958
  }
20840
- writeFileSync10(join45(this.temporaryDir, "plan.json"), manifestBytes, "utf-8");
20959
+ writeFileSync10(join46(this.temporaryDir, "plan.json"), manifestBytes, "utf-8");
20841
20960
  renameWithRetry8(this.temporaryDir, this.destinationDir);
20842
20961
  this.#committed = true;
20843
20962
  }
@@ -20883,7 +21002,7 @@ function listFiles(root) {
20883
21002
  const rootResolved = resolve11(root);
20884
21003
  function walk(dir) {
20885
21004
  for (const entry of readdirSync10(dir, { withFileTypes: true })) {
20886
- const absolutePath = join46(dir, entry.name);
21005
+ const absolutePath = join47(dir, entry.name);
20887
21006
  if (entry.isDirectory()) {
20888
21007
  walk(absolutePath);
20889
21008
  } else if (entry.isFile()) {
@@ -20910,13 +21029,13 @@ function assertValidExtractionCacheCompleteSentinel(path) {
20910
21029
  }
20911
21030
  }
20912
21031
  function validateExtractionCacheCompleteSentinels(executionPlanDir) {
20913
- const videoRoot = join46(executionPlanDir, "video-frames");
20914
- if (!existsSync28(videoRoot)) return;
21032
+ const videoRoot = join47(executionPlanDir, "video-frames");
21033
+ if (!existsSync29(videoRoot)) return;
20915
21034
  for (const videoEntry of readdirSync10(videoRoot, { withFileTypes: true })) {
20916
21035
  if (!videoEntry.isDirectory()) continue;
20917
- const videoDir = join46(videoRoot, videoEntry.name);
21036
+ const videoDir = join47(videoRoot, videoEntry.name);
20918
21037
  if (readdirSync10(videoDir).includes(EXTRACTION_CACHE_COMPLETE_SENTINEL)) {
20919
- const sentinelPath = join46(videoDir, EXTRACTION_CACHE_COMPLETE_SENTINEL);
21038
+ const sentinelPath = join47(videoDir, EXTRACTION_CACHE_COMPLETE_SENTINEL);
20920
21039
  assertValidExtractionCacheCompleteSentinel(sentinelPath);
20921
21040
  }
20922
21041
  }
@@ -20963,7 +21082,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
20963
21082
  if (video.deferredRange) {
20964
21083
  const framePaths2 = /* @__PURE__ */ new Map();
20965
21084
  for (let index = 0; index < video.totalFrames; index++) {
20966
- framePaths2.set(index, join46(outputDir, String(index)));
21085
+ framePaths2.set(index, join47(outputDir, String(index)));
20967
21086
  }
20968
21087
  return { ...video, outputDir, framePaths: framePaths2, ownedByLookup: false };
20969
21088
  }
@@ -20971,7 +21090,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
20971
21090
  const framePaths = /* @__PURE__ */ new Map();
20972
21091
  for (const frameName of frameNames) {
20973
21092
  if (frameName === EXTRACTION_CACHE_COMPLETE_SENTINEL) {
20974
- assertValidExtractionCacheCompleteSentinel(join46(outputDir, frameName));
21093
+ assertValidExtractionCacheCompleteSentinel(join47(outputDir, frameName));
20975
21094
  continue;
20976
21095
  }
20977
21096
  const match = /(\d+)(?=\.[^.]+$)/.exec(frameName);
@@ -20990,7 +21109,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
20990
21109
  `duplicate extracted frame index ${frameIndex} in ${outputDir}`
20991
21110
  );
20992
21111
  }
20993
- framePaths.set(frameIndex, join46(outputDir, frameName));
21112
+ framePaths.set(frameIndex, join47(outputDir, frameName));
20994
21113
  }
20995
21114
  return {
20996
21115
  ...video,
@@ -21011,8 +21130,8 @@ function parsePlanVideosJson2(value) {
21011
21130
  }
21012
21131
  }
21013
21132
  function materializeExtractedVideoDirectories(planDir) {
21014
- const videosPath = join46(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
21015
- if (!existsSync28(videosPath)) return;
21133
+ const videosPath = join47(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
21134
+ if (!existsSync29(videosPath)) return;
21016
21135
  const videos = parsePlanVideosJson2(readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH));
21017
21136
  for (const video of videos.extracted) {
21018
21137
  mkdirSync18(resolveExtractedVideoOutputDir(planDir, video.videoId), { recursive: true });
@@ -21045,13 +21164,13 @@ function parseChunkSlices(value) {
21045
21164
  });
21046
21165
  }
21047
21166
  function buildVideoChunkDependencies(executionPlanDir, dimensions) {
21048
- const videoRoot = join46(executionPlanDir, "video-frames");
21049
- const hasExtractedFrames = existsSync28(videoRoot) && listFiles(videoRoot).length > 0;
21050
- const videosPath = join46(executionPlanDir, PLAN_VIDEOS_META_RELATIVE_PATH);
21051
- if (!existsSync28(videosPath)) {
21167
+ const videoRoot = join47(executionPlanDir, "video-frames");
21168
+ const hasExtractedFrames = existsSync29(videoRoot) && listFiles(videoRoot).length > 0;
21169
+ const videosPath = join47(executionPlanDir, PLAN_VIDEOS_META_RELATIVE_PATH);
21170
+ if (!existsSync29(videosPath)) {
21052
21171
  return hasExtractedFrames ? { mode: "full-source-pack", dependencies: null } : { mode: "exact-rendered-frames", dependencies: /* @__PURE__ */ new Map() };
21053
21172
  }
21054
- const chunksPath = join46(executionPlanDir, "meta", "chunks.json");
21173
+ const chunksPath = join47(executionPlanDir, "meta", "chunks.json");
21055
21174
  const videos = readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH);
21056
21175
  const chunks = readJsonFile(chunksPath, "meta/chunks.json");
21057
21176
  const parsedVideos = parsePlanVideosJson2(videos);
@@ -21105,10 +21224,10 @@ function computeManifestHash(manifest) {
21105
21224
  return sha256Hex(`${PLAN_V2_HASH_PREFIX}${canonicalJsonStringify(manifestPayload(manifest))}`);
21106
21225
  }
21107
21226
  function writeBlob(sourcePath, destinationPath) {
21108
- if (existsSync28(destinationPath)) return;
21109
- mkdirSync18(dirname18(destinationPath), { recursive: true });
21110
- const temporaryDir = createStagingDir6(dirname18(destinationPath), ".plan-v2-blob-");
21111
- const temporaryPath = join46(temporaryDir, "blob");
21227
+ if (existsSync29(destinationPath)) return;
21228
+ mkdirSync18(dirname19(destinationPath), { recursive: true });
21229
+ const temporaryDir = createStagingDir6(dirname19(destinationPath), ".plan-v2-blob-");
21230
+ const temporaryPath = join47(temporaryDir, "blob");
21112
21231
  try {
21113
21232
  copyFileSync8(sourcePath, temporaryPath);
21114
21233
  renameWithRetry9(temporaryPath, destinationPath);
@@ -21144,8 +21263,8 @@ async function putTasks(tasks) {
21144
21263
  if (failure) throw failure.reason;
21145
21264
  }
21146
21265
  function buildPlanV2Publication(executionPlanDir, digests) {
21147
- const executionPlanPath = join46(executionPlanDir, "plan.json");
21148
- if (!existsSync28(executionPlanPath)) {
21266
+ const executionPlanPath = join47(executionPlanDir, "plan.json");
21267
+ if (!existsSync29(executionPlanPath)) {
21149
21268
  throw new PlanV2IntegrityError(`execution plan is missing plan.json: ${executionPlanPath}`);
21150
21269
  }
21151
21270
  const executionPlanValue = readJsonFile(executionPlanPath, "execution plan.json");
@@ -21172,7 +21291,7 @@ function buildPlanV2Publication(executionPlanDir, digests) {
21172
21291
  }
21173
21292
  validateExtractionCacheCompleteSentinels(executionPlanDir);
21174
21293
  const videoDependencyPlan = buildVideoChunkDependencies(executionPlanDir, dimensions);
21175
- const encoder = readJsonFile(join46(executionPlanDir, "meta", "encoder.json"), "meta/encoder.json");
21294
+ const encoder = readJsonFile(join47(executionPlanDir, "meta", "encoder.json"), "meta/encoder.json");
21176
21295
  const files = listFiles(executionPlanDir);
21177
21296
  const chunkAudio = !isRecord3(encoder) || encoder.chunksCarryAudio !== true ? "none" : files.some((file) => chunkAudioSliceTarget(file.path) !== null) ? "sliced" : "whole";
21178
21297
  for (const file of files) {
@@ -21225,21 +21344,21 @@ function buildPlanV2Publication(executionPlanDir, digests) {
21225
21344
  };
21226
21345
  }
21227
21346
  function createPlanV2FromExecutionPlan(executionPlanDir, planV2Dir) {
21228
- if (existsSync28(planV2Dir)) {
21347
+ if (existsSync29(planV2Dir)) {
21229
21348
  throw new PlanV2IntegrityError(`output directory already exists: ${planV2Dir}`);
21230
21349
  }
21231
21350
  const publication = buildPlanV2Publication(executionPlanDir);
21232
21351
  if (publication.storedBlobs.length > 0) {
21233
21352
  throw new PlanV2IntegrityError("a local plan v2 directory cannot reference remote files");
21234
21353
  }
21235
- mkdirSync18(dirname18(planV2Dir), { recursive: true });
21236
- const tempDir = createStagingDir6(dirname18(planV2Dir), ".plan-v2-build-");
21354
+ mkdirSync18(dirname19(planV2Dir), { recursive: true });
21355
+ const tempDir = createStagingDir6(dirname19(planV2Dir), ".plan-v2-build-");
21237
21356
  try {
21238
21357
  for (const blob of publication.blobs) {
21239
21358
  writeBlob(blob.sourcePath, planV2BlobPath(tempDir, blob.sha256));
21240
21359
  }
21241
21360
  writeFileSync11(
21242
- join46(tempDir, "plan.json"),
21361
+ join47(tempDir, "plan.json"),
21243
21362
  canonicalJsonStringify(publication.manifest),
21244
21363
  "utf-8"
21245
21364
  );
@@ -21291,7 +21410,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
21291
21410
  // artifactTargets ships every compiled/ file to all chunks, so each is in the manifest.
21292
21411
  whileAudioMixes: () => putBlobs(
21293
21412
  publisher,
21294
- listFiles(join46(stagingRoot, "compiled")).map(
21413
+ listFiles(join47(stagingRoot, "compiled")).map(
21295
21414
  (file) => publishBlobFor(file.absolutePath, digests)
21296
21415
  )
21297
21416
  ),
@@ -21315,12 +21434,12 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
21315
21434
  }
21316
21435
  }
21317
21436
  async function planV2(projectDir, config, planV2Dir) {
21318
- if (existsSync28(planV2Dir)) {
21437
+ if (existsSync29(planV2Dir)) {
21319
21438
  throw new PlanV2IntegrityError(`output directory already exists: ${planV2Dir}`);
21320
21439
  }
21321
21440
  const publisher = new LocalPlanV2ArtifactPublisher(planV2Dir);
21322
21441
  const manifest = await planV2WithPublisher(projectDir, config, publisher, {
21323
- stagingParentDir: dirname18(planV2Dir)
21442
+ stagingParentDir: dirname19(planV2Dir)
21324
21443
  });
21325
21444
  return resultFromManifest(planV2Dir, manifest);
21326
21445
  }
@@ -21332,7 +21451,7 @@ function resultFromManifest(planV2Dir, manifest) {
21332
21451
  isRecord3(executionPlan) ? executionPlan[REFERENCE_BACKGROUND_FIELD3] : void 0
21333
21452
  ),
21334
21453
  planDir: planV2Dir,
21335
- manifestPath: join46(planV2Dir, "plan.json"),
21454
+ manifestPath: join47(planV2Dir, "plan.json"),
21336
21455
  planProtocol: PLAN_PROTOCOL_V2,
21337
21456
  planHash: manifest.planHash,
21338
21457
  sourcePlanV1Hash: getPlanV2ExecutionPlanHash(manifest),
@@ -21468,8 +21587,8 @@ function parsePlanV2Manifest(value) {
21468
21587
  return parsed;
21469
21588
  }
21470
21589
  function readPlanV2Manifest(planV2Dir) {
21471
- const manifestPath = join46(planV2Dir, "plan.json");
21472
- if (!existsSync28(manifestPath)) {
21590
+ const manifestPath = join47(planV2Dir, "plan.json");
21591
+ if (!existsSync29(manifestPath)) {
21473
21592
  throw new PlanV2IntegrityError(`missing v2 manifest: ${manifestPath}`);
21474
21593
  }
21475
21594
  const value = readJsonFile(manifestPath, "v2 manifest");
@@ -21488,7 +21607,7 @@ function listPlanV2ArtifactsForTarget(manifest, target) {
21488
21607
  }
21489
21608
  function verifyBlob(planV2Dir, artifact) {
21490
21609
  const sourcePath = planV2BlobPath(planV2Dir, artifact.sha256);
21491
- if (!existsSync28(sourcePath)) {
21610
+ if (!existsSync29(sourcePath)) {
21492
21611
  throw new PlanV2IntegrityError(`missing content-addressed artifact ${artifact.sha256}`);
21493
21612
  }
21494
21613
  const stats = statSync12(sourcePath);
@@ -21501,7 +21620,7 @@ function verifyBlob(planV2Dir, artifact) {
21501
21620
  return sourcePath;
21502
21621
  }
21503
21622
  function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}) {
21504
- if (existsSync28(destinationDir)) {
21623
+ if (existsSync29(destinationDir)) {
21505
21624
  throw new PlanV2IntegrityError(`materialization destination already exists: ${destinationDir}`);
21506
21625
  }
21507
21626
  const manifest = readPlanV2Manifest(planV2Dir);
@@ -21513,17 +21632,17 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
21513
21632
  artifact,
21514
21633
  sourcePath: verifyBlob(planV2Dir, artifact)
21515
21634
  }));
21516
- mkdirSync18(dirname18(destinationDir), { recursive: true });
21517
- const tempDir = createStagingDir6(dirname18(destinationDir), ".plan-v2-materialize-");
21635
+ mkdirSync18(dirname19(destinationDir), { recursive: true });
21636
+ const tempDir = createStagingDir6(dirname19(destinationDir), ".plan-v2-materialize-");
21518
21637
  try {
21519
21638
  for (const { artifact, sourcePath } of verified) {
21520
- const destinationPath = join46(tempDir, ...artifact.path.split("/"));
21521
- mkdirSync18(dirname18(destinationPath), { recursive: true });
21639
+ const destinationPath = join47(tempDir, ...artifact.path.split("/"));
21640
+ mkdirSync18(dirname19(destinationPath), { recursive: true });
21522
21641
  copyFileSync8(sourcePath, destinationPath);
21523
21642
  }
21524
21643
  if (target.role === "chunk") materializeExtractedVideoDirectories(tempDir);
21525
21644
  writeFileSync11(
21526
- join46(tempDir, PLAN_V2_MATERIALIZATION_MARKER),
21645
+ join47(tempDir, PLAN_V2_MATERIALIZATION_MARKER),
21527
21646
  canonicalJsonStringify({
21528
21647
  manifest,
21529
21648
  target,
@@ -21546,7 +21665,7 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
21546
21665
  // Join the artifact's OWN name, not the current constant: a plan written
21547
21666
  // before the container change carries the legacy name, and materializing it
21548
21667
  // under the new one would point at a file that was never written.
21549
- audioPath: target.role === "assembler" ? audioArtifact ? join46(destinationDir, audioArtifact.path) : null : null
21668
+ audioPath: target.role === "assembler" ? audioArtifact ? join47(destinationDir, audioArtifact.path) : null : null
21550
21669
  };
21551
21670
  }
21552
21671
  function assertRemoteSources(remoteSources, artifacts) {
@@ -21565,8 +21684,8 @@ function validatePlanV2MaterializedTarget(planDir, expectedTarget) {
21565
21684
  return readValidatedPlanV2Materialization(planDir, expectedTarget)?.manifest ?? null;
21566
21685
  }
21567
21686
  function readValidatedPlanV2Materialization(planDir, expectedTarget) {
21568
- const markerPath = join46(planDir, PLAN_V2_MATERIALIZATION_MARKER);
21569
- if (!existsSync28(markerPath)) return null;
21687
+ const markerPath = join47(planDir, PLAN_V2_MATERIALIZATION_MARKER);
21688
+ if (!existsSync29(markerPath)) return null;
21570
21689
  const marker = readJsonFile(markerPath, "materialization marker");
21571
21690
  if (!isRecord3(marker) || !isRecord3(marker.manifest) || !isRecord3(marker.target)) {
21572
21691
  throw new PlanV2IntegrityError("malformed materialization marker");
@@ -21583,8 +21702,8 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
21583
21702
  assertRemoteSources(remoteSources, required);
21584
21703
  for (const artifact of required) {
21585
21704
  if (Object.hasOwn(remoteSources, artifact.path)) continue;
21586
- const path = join46(planDir, ...artifact.path.split("/"));
21587
- if (!existsSync28(path) || statSync12(path).size !== artifact.sizeBytes) {
21705
+ const path = join47(planDir, ...artifact.path.split("/"));
21706
+ if (!existsSync29(path) || statSync12(path).size !== artifact.sizeBytes) {
21588
21707
  throw new PlanV2IntegrityError(
21589
21708
  `materialized artifact missing or truncated: ${artifact.path}`
21590
21709
  );
@@ -21715,7 +21834,7 @@ function hashChunkOutput(outputPath, kind) {
21715
21834
  if (kind === "file") return sha256Hex(readFileSync14(outputPath));
21716
21835
  const entries = readdirSync11(outputPath).filter((name) => /\.(png|jpg|jpeg)$/i.test(name)).sort();
21717
21836
  const lines = entries.map(
21718
- (name) => `${name}\0${sha256Hex(readFileSync14(join47(outputPath, name)))}`
21837
+ (name) => `${name}\0${sha256Hex(readFileSync14(join48(outputPath, name)))}`
21719
21838
  );
21720
21839
  return sha256Hex(lines.join("\0"));
21721
21840
  }
@@ -21732,10 +21851,10 @@ function resolveLockedVp9CpuUsed(lockedEncoder) {
21732
21851
  async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
21733
21852
  const start = Date.now();
21734
21853
  const log = defaultLogger;
21735
- const planJsonPath = join47(planDir, "plan.json");
21736
- const encoderJsonPath = join47(planDir, "meta", "encoder.json");
21737
- const chunksJsonPath = join47(planDir, "meta", "chunks.json");
21738
- if (!existsSync29(planJsonPath)) {
21854
+ const planJsonPath = join48(planDir, "plan.json");
21855
+ const encoderJsonPath = join48(planDir, "meta", "encoder.json");
21856
+ const chunksJsonPath = join48(planDir, "meta", "chunks.json");
21857
+ if (!existsSync30(planJsonPath)) {
21739
21858
  throw new RenderChunkValidationError(
21740
21859
  MISSING_PLAN_ARTIFACT,
21741
21860
  `[renderChunk] planDir is missing required artifact: ${planJsonPath}`
@@ -21751,7 +21870,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
21751
21870
  const v2Manifest = v2Materialization?.manifest ?? null;
21752
21871
  const remoteSources = v2Materialization?.remoteSources ?? {};
21753
21872
  for (const required of [encoderJsonPath, chunksJsonPath]) {
21754
- if (!existsSync29(required)) {
21873
+ if (!existsSync30(required)) {
21755
21874
  throw new RenderChunkValidationError(
21756
21875
  MISSING_PLAN_ARTIFACT,
21757
21876
  `[renderChunk] planDir is missing required artifact: ${required}`
@@ -21760,9 +21879,9 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
21760
21879
  }
21761
21880
  const encoder = JSON.parse(readFileSync14(encoderJsonPath, "utf-8"));
21762
21881
  const chunks = JSON.parse(readFileSync14(chunksJsonPath, "utf-8"));
21763
- const videosJsonPath = join47(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
21882
+ const videosJsonPath = join48(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
21764
21883
  let planVideos = null;
21765
- if (existsSync29(videosJsonPath)) {
21884
+ if (existsSync30(videosJsonPath)) {
21766
21885
  try {
21767
21886
  planVideos = validatePlanVideosForChunk(JSON.parse(readFileSync14(videosJsonPath, "utf-8")));
21768
21887
  } catch (err) {
@@ -21792,8 +21911,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
21792
21911
  }
21793
21912
  const range = resolveChunkFrameRange(slice, chunkIndex, options?.frameRange);
21794
21913
  const framesInChunk = range.endFrame - range.startFrame;
21795
- const compiledDir = join47(planDir, "compiled");
21796
- if (!existsSync29(compiledDir)) {
21914
+ const compiledDir = join48(planDir, "compiled");
21915
+ if (!existsSync30(compiledDir)) {
21797
21916
  throw new RenderChunkValidationError(
21798
21917
  MISSING_PLAN_ARTIFACT,
21799
21918
  `[renderChunk] planDir missing compiled/ directory: ${compiledDir}`
@@ -21851,7 +21970,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
21851
21970
  };
21852
21971
  const workDir = `${outputChunkPath}.work.${process.pid}.${randomBytes(4).toString("hex")}`;
21853
21972
  mkdirSync19(workDir, { recursive: true });
21854
- const framesDir = join47(workDir, "captured-frames");
21973
+ const framesDir = join48(workDir, "captured-frames");
21855
21974
  mkdirSync19(framesDir, { recursive: true });
21856
21975
  const videoFramesDir = `${workDir}.video-frames`;
21857
21976
  const chunkFrameNumbers = Array.from({ length: framesInChunk }, (_, i) => range.startFrame + i);
@@ -21876,7 +21995,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
21876
21995
  dimensions: plan2.dimensions,
21877
21996
  encoder,
21878
21997
  videoCount: planVideos?.videos.length ?? 0,
21879
- html: readFileSync14(join47(compiledDir, "index.html"), "utf-8"),
21998
+ html: readFileSync14(join48(compiledDir, "index.html"), "utf-8"),
21880
21999
  // The plan ships a deferred source only to chunks that show it; don't wait on the rest.
21881
22000
  skipReadinessVideoIds: deferredVideos.filter(
21882
22001
  (video) => !shownFrames.get(video.videoId)?.size || remoteVideoIds.has(video.videoId)
@@ -22045,10 +22164,10 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
22045
22164
  const effectiveBitrate = encoder.crf != null ? void 0 : encoder.bitrate;
22046
22165
  const videoOnlyPath = encoder.chunksCarryAudio ? `${outputChunkPath}.video.mp4` : outputChunkPath;
22047
22166
  if (isPngSequence) {
22048
- if (!existsSync29(outputChunkPath)) mkdirSync19(outputChunkPath, { recursive: true });
22167
+ if (!existsSync30(outputChunkPath)) mkdirSync19(outputChunkPath, { recursive: true });
22049
22168
  } else {
22050
- const outDir = join47(outputChunkPath, "..");
22051
- if (!existsSync29(outDir)) mkdirSync19(outDir, { recursive: true });
22169
+ const outDir = join48(outputChunkPath, "..");
22170
+ if (!existsSync30(outDir)) mkdirSync19(outDir, { recursive: true });
22052
22171
  }
22053
22172
  const encodeInput = {
22054
22173
  job,
@@ -22324,10 +22443,10 @@ async function renderSpan(projectDir, config, span, outputPath, options = {}) {
22324
22443
  if (config.cfr === true) {
22325
22444
  throw new RenderSpanUnsupportedError("--start/--end cannot be combined with a cfr re-encode.");
22326
22445
  }
22327
- const workDir = mkdtempSync(join48(tmpdir5(), "hf-render-span-"));
22446
+ const workDir = mkdtempSync(join49(tmpdir5(), "hf-render-span-"));
22328
22447
  try {
22329
- const planDir = join48(workDir, "plan");
22330
- const partsDir = join48(workDir, "parts");
22448
+ const planDir = join49(workDir, "plan");
22449
+ const partsDir = join49(workDir, "parts");
22331
22450
  mkdirSync20(partsDir, { recursive: true });
22332
22451
  const planned = await plan(
22333
22452
  projectDir,
@@ -22346,7 +22465,7 @@ async function renderSpan(projectDir, config, span, outputPath, options = {}) {
22346
22465
  planned.totalFrames
22347
22466
  );
22348
22467
  const slices = JSON.parse(
22349
- readFileSync15(join48(planDir, "meta", "chunks.json"), "utf-8")
22468
+ readFileSync15(join49(planDir, "meta", "chunks.json"), "utf-8")
22350
22469
  );
22351
22470
  const parts = [];
22352
22471
  for (const slice of slices) {
@@ -22356,7 +22475,7 @@ async function renderSpan(projectDir, config, span, outputPath, options = {}) {
22356
22475
  };
22357
22476
  if (range.endFrame <= range.startFrame) continue;
22358
22477
  throwIfAborted(config.abortSignal);
22359
- const part = join48(partsDir, `part-${String(parts.length).padStart(4, "0")}.mp4`);
22478
+ const part = join49(partsDir, `part-${String(parts.length).padStart(4, "0")}.mp4`);
22360
22479
  await renderChunk(planDir, slice.index, part, { frameRange: range });
22361
22480
  parts.push(part);
22362
22481
  }
@@ -22388,7 +22507,8 @@ var SAFE_RENDER_ERROR_CODES = /* @__PURE__ */ new Set([
22388
22507
  "PAGE_NEVER_READY",
22389
22508
  "VARIABLES_INVALID",
22390
22509
  "OUTPUT_DIMENSIONS_MISMATCH",
22391
- "COMPOSITION_TOO_LARGE"
22510
+ "COMPOSITION_TOO_LARGE",
22511
+ "COMPILE_TIMEOUT"
22392
22512
  ]);
22393
22513
  function extractSafeRenderErrorCode(error) {
22394
22514
  if (typeof error !== "object" || error === null || !("code" in error)) return void 0;
@@ -23012,7 +23132,7 @@ import {
23012
23132
 
23013
23133
  // src/server.ts
23014
23134
  import {
23015
- existsSync as existsSync32,
23135
+ existsSync as existsSync33,
23016
23136
  mkdirSync as mkdirSync21,
23017
23137
  statSync as statSync14,
23018
23138
  mkdtempSync as mkdtempSync2,
@@ -23020,7 +23140,7 @@ import {
23020
23140
  rmSync as rmSync19,
23021
23141
  createReadStream as createReadStream6
23022
23142
  } from "node:fs";
23023
- import { resolve as resolve13, dirname as dirname21, join as join51 } from "node:path";
23143
+ import { resolve as resolve13, dirname as dirname22, join as join52 } from "node:path";
23024
23144
  import { tmpdir as tmpdir6 } from "node:os";
23025
23145
  import { parseArgs } from "node:util";
23026
23146
  import { isIP } from "node:net";
@@ -23037,7 +23157,7 @@ import { isSafePath as isSafePath4 } from "@hyperframes/core/safe-path";
23037
23157
 
23038
23158
  // src/services/hyperframeLint.ts
23039
23159
  import {
23040
- existsSync as existsSync30,
23160
+ existsSync as existsSync31,
23041
23161
  readFileSync as readFileSync16,
23042
23162
  statSync as statSync13,
23043
23163
  openSync as openSync8,
@@ -23045,9 +23165,9 @@ import {
23045
23165
  closeSync as closeSync8,
23046
23166
  constants as constants4
23047
23167
  } from "node:fs";
23048
- import { resolve as resolve12, join as join49, relative as relative9, isAbsolute as isAbsolute6, sep as sep7, dirname as dirname19 } from "node:path";
23049
- import { fileURLToPath as fileURLToPath6 } from "node:url";
23050
- import { Worker as Worker2 } from "node:worker_threads";
23168
+ import { resolve as resolve12, join as join50, relative as relative9, isAbsolute as isAbsolute6, sep as sep7, dirname as dirname20 } from "node:path";
23169
+ import { fileURLToPath as fileURLToPath7 } from "node:url";
23170
+ import { Worker as Worker3 } from "node:worker_threads";
23051
23171
  function isStringRecord(value) {
23052
23172
  if (!value || typeof value !== "object" || Array.isArray(value)) {
23053
23173
  return false;
@@ -23096,7 +23216,7 @@ function leavesProject(absProjectDir, absoluteEntryPath, isAllowedEntry) {
23096
23216
  }
23097
23217
  function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
23098
23218
  const absProjectDir = resolve12(projectDir);
23099
- if (!existsSync30(absProjectDir) || !statSync13(absProjectDir).isDirectory()) {
23219
+ if (!existsSync31(absProjectDir) || !statSync13(absProjectDir).isDirectory()) {
23100
23220
  return { error: `Project directory not found: ${absProjectDir}` };
23101
23221
  }
23102
23222
  const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
@@ -23117,7 +23237,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
23117
23237
  }
23118
23238
  }
23119
23239
  return {
23120
- error: `No HTML entry file found in project directory: ${join49(absProjectDir, preferredEntryFile || "index.html")}`
23240
+ error: `No HTML entry file found in project directory: ${join50(absProjectDir, preferredEntryFile || "index.html")}`
23121
23241
  };
23122
23242
  }
23123
23243
  function prepareHyperframeLintBody(body, isAllowedEntry) {
@@ -23184,10 +23304,10 @@ function freeLintSlot() {
23184
23304
  waiting.shift()?.();
23185
23305
  }
23186
23306
  function resolveLintWorkerEntry() {
23187
- const here = dirname19(fileURLToPath6(import.meta.url));
23307
+ const here = dirname20(fileURLToPath7(import.meta.url));
23188
23308
  for (const name of ["hyperframeLintWorker.js", "hyperframeLintWorker.ts"]) {
23189
- const candidate = join49(here, name);
23190
- if (existsSync30(candidate)) return candidate;
23309
+ const candidate = join50(here, name);
23310
+ if (existsSync31(candidate)) return candidate;
23191
23311
  }
23192
23312
  return void 0;
23193
23313
  }
@@ -23220,7 +23340,7 @@ async function runHyperframeLint(prepared, options = {}) {
23220
23340
  return new Promise((resolvePromise, reject) => {
23221
23341
  let worker;
23222
23342
  try {
23223
- worker = new Worker2(entry, {
23343
+ worker = new Worker3(entry, {
23224
23344
  workerData: {
23225
23345
  html: prepared.html,
23226
23346
  opts: { filePath: prepared.entryFile, compSrcPath: prepared.entryFile }
@@ -23255,10 +23375,10 @@ async function runHyperframeLint(prepared, options = {}) {
23255
23375
  }
23256
23376
 
23257
23377
  // src/services/healthWorker.ts
23258
- import { Worker as Worker3 } from "node:worker_threads";
23259
- import { fileURLToPath as fileURLToPath7 } from "node:url";
23260
- import { dirname as dirname20, join as join50 } from "node:path";
23261
- import { existsSync as existsSync31 } from "node:fs";
23378
+ import { Worker as Worker4 } from "node:worker_threads";
23379
+ import { fileURLToPath as fileURLToPath8 } from "node:url";
23380
+ import { dirname as dirname21, join as join51 } from "node:path";
23381
+ import { existsSync as existsSync32 } from "node:fs";
23262
23382
  var DEFAULT_HEALTH_PORT = 9848;
23263
23383
  async function startHealthWorker(options = {}) {
23264
23384
  const log = options.logger ?? defaultLogger2();
@@ -23269,7 +23389,7 @@ async function startHealthWorker(options = {}) {
23269
23389
  "[healthWorker] could not resolve worker entry. Pass options.workerEntry or ensure healthWorkerThread.{js,ts} is co-located."
23270
23390
  );
23271
23391
  }
23272
- const worker = new Worker3(entry, {
23392
+ const worker = new Worker4(entry, {
23273
23393
  workerData: { port },
23274
23394
  // Keep stdio inherited so the worker's console logs land in the pod logs
23275
23395
  // alongside the main thread's.
@@ -23332,10 +23452,10 @@ function defaultLogger2() {
23332
23452
  };
23333
23453
  }
23334
23454
  function resolveWorkerEntry2() {
23335
- const here = dirname20(fileURLToPath7(import.meta.url));
23336
- const candidates = [join50(here, "healthWorkerThread.js"), join50(here, "healthWorkerThread.ts")];
23455
+ const here = dirname21(fileURLToPath8(import.meta.url));
23456
+ const candidates = [join51(here, "healthWorkerThread.js"), join51(here, "healthWorkerThread.ts")];
23337
23457
  for (const candidate of candidates) {
23338
- if (existsSync31(candidate)) return candidate;
23458
+ if (existsSync32(candidate)) return candidate;
23339
23459
  }
23340
23460
  return void 0;
23341
23461
  }
@@ -23504,8 +23624,8 @@ function resolvePreparedRenderOutput(prepared, rendersDir, log, confineOutput) {
23504
23624
  throw new Error("outputPath must be inside the renders directory");
23505
23625
  }
23506
23626
  }
23507
- const outputDir = dirname21(absoluteOutputPath);
23508
- if (!existsSync32(outputDir)) mkdirSync21(outputDir, { recursive: true });
23627
+ const outputDir = dirname22(absoluteOutputPath);
23628
+ if (!existsSync33(outputDir)) mkdirSync21(outputDir, { recursive: true });
23509
23629
  return { input, cleanupProjectDir, absoluteOutputPath };
23510
23630
  }
23511
23631
  function prepareRenderJob(prepared, rendersDir, log, confineOutput) {
@@ -23583,12 +23703,12 @@ function prepareProjectDirectory(projectDir, options, policy) {
23583
23703
  if (!candidate) return null;
23584
23704
  const absProjectDir = policy ? resolve13(policy.projectsDir, candidate) : resolve13(candidate);
23585
23705
  const shown = policy ? candidate : absProjectDir;
23586
- if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync32(absProjectDir) || !statSync14(absProjectDir).isDirectory()) {
23706
+ if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync33(absProjectDir) || !statSync14(absProjectDir).isDirectory()) {
23587
23707
  return { error: `Project directory not found: ${shown}` };
23588
23708
  }
23589
23709
  const entry = options.entryFile || "index.html";
23590
23710
  const entryPath = resolve13(absProjectDir, entry);
23591
- if (policy && !isAllowedEntryPath(policy, absProjectDir, entryPath) || !existsSync32(entryPath)) {
23711
+ if (policy && !isAllowedEntryPath(policy, absProjectDir, entryPath) || !existsSync33(entryPath)) {
23592
23712
  return { error: `Entry file "${entry}" not found in project directory: ${shown}` };
23593
23713
  }
23594
23714
  return { prepared: { input: { projectDir: absProjectDir, ...options } } };
@@ -23609,8 +23729,8 @@ async function resolveInlineRenderHtml(body) {
23609
23729
  }
23610
23730
  function materializeInlineProject(html, options) {
23611
23731
  const tempRoot = process.env.PRODUCER_TMP_PROJECT_DIR || tmpdir6();
23612
- const tempProjectDir = mkdtempSync2(join51(tempRoot, "producer-project-"));
23613
- writeFileSync13(join51(tempProjectDir, "index.html"), html, "utf-8");
23732
+ const tempProjectDir = mkdtempSync2(join52(tempRoot, "producer-project-"));
23733
+ writeFileSync13(join52(tempProjectDir, "index.html"), html, "utf-8");
23614
23734
  return {
23615
23735
  prepared: {
23616
23736
  input: { projectDir: tempProjectDir, ...options },
@@ -23686,7 +23806,7 @@ function publicPerfSummary(job) {
23686
23806
  return job.perfSummary ? { ...job.perfSummary, renderId: void 0 } : null;
23687
23807
  }
23688
23808
  function outputFileSize(path) {
23689
- return existsSync32(path) ? statSync14(path).size : 0;
23809
+ return existsSync33(path) ? statSync14(path).size : 0;
23690
23810
  }
23691
23811
  function createBlockingProgressReporter(log, requestId) {
23692
23812
  let lastLoggedPct = -10;
@@ -24013,7 +24133,7 @@ function createRenderHandlers(options = {}) {
24013
24133
  if (!artifact) {
24014
24134
  return c.json({ success: false, error: "Output artifact not found or expired" }, 404);
24015
24135
  }
24016
- if (!existsSync32(artifact.path)) {
24136
+ if (!existsSync33(artifact.path)) {
24017
24137
  store.delete(token);
24018
24138
  return c.json({ success: false, error: "Output artifact file missing" }, 404);
24019
24139
  }
@@ -24204,7 +24324,7 @@ import { quantizeTimeToFrame, MEDIA_VISUAL_STYLE_PROPERTIES } from "@hyperframes
24204
24324
  // src/services/distributed/planV2Execution.ts
24205
24325
  import { mkdtempSync as mkdtempSync3, rmSync as rmSync21 } from "node:fs";
24206
24326
  import { tmpdir as tmpdir7 } from "node:os";
24207
- import { join as join53 } from "node:path";
24327
+ import { join as join54 } from "node:path";
24208
24328
 
24209
24329
  // src/services/distributed/assemble.ts
24210
24330
  import {
@@ -24213,7 +24333,7 @@ import {
24213
24333
  } from "@hyperframes/engine";
24214
24334
  import {
24215
24335
  cpSync as cpSync3,
24216
- existsSync as existsSync33,
24336
+ existsSync as existsSync34,
24217
24337
  mkdirSync as mkdirSync22,
24218
24338
  readFileSync as readFileSync17,
24219
24339
  readdirSync as readdirSync12,
@@ -24221,7 +24341,7 @@ import {
24221
24341
  statSync as statSync15
24222
24342
  } from "node:fs";
24223
24343
  import { localContainerInputArgs as localContainerInputArgs2 } from "@hyperframes/parsers/ff-binaries";
24224
- import { basename as basename9, dirname as dirname22, join as join52 } from "node:path";
24344
+ import { basename as basename9, dirname as dirname23, join as join53 } from "node:path";
24225
24345
  import {
24226
24346
  appendRateCapArgs as appendRateCapArgs2,
24227
24347
  writeVideoConcatList,
@@ -24270,10 +24390,10 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
24270
24390
  }
24271
24391
  const format = plan2.dimensions.format;
24272
24392
  const cfrEncoder = cfr ? readCfrEncoder(planDir, format) : null;
24273
- if (!existsSync33(dirname22(outputPath))) {
24274
- mkdirSync22(dirname22(outputPath), { recursive: true });
24393
+ if (!existsSync34(dirname23(outputPath))) {
24394
+ mkdirSync22(dirname23(outputPath), { recursive: true });
24275
24395
  }
24276
- const workDir = createStagingDir7(dirname22(outputPath), `${basename9(outputPath)}.assemble-work-`);
24396
+ const workDir = createStagingDir7(dirname23(outputPath), `${basename9(outputPath)}.assemble-work-`);
24277
24397
  const fps = { num: plan2.dimensions.fpsNum, den: plan2.dimensions.fpsDen };
24278
24398
  const stageMs = {};
24279
24399
  const ctx = {
@@ -24293,8 +24413,8 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
24293
24413
  };
24294
24414
  try {
24295
24415
  const videoSources = cfrEncoder ? [await reencodeCfr(ctx, chunkPaths, cfrEncoder)] : chunkPaths;
24296
- const finalPath = join52(workDir, `output.${format}`);
24297
- const audio = audioPath !== null && existsSync33(audioPath) ? audioPath : null;
24416
+ const finalPath = join53(workDir, `output.${format}`);
24417
+ const audio = audioPath !== null && existsSync34(audioPath) ? audioPath : null;
24298
24418
  await writeJoined(ctx, videoSources, audio, finalPath);
24299
24419
  renameWithRetry10(finalPath, outputPath);
24300
24420
  log.info("[assemble] stage timings", {
@@ -24312,7 +24432,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
24312
24432
  });
24313
24433
  }
24314
24434
  }
24315
- const fileSize = existsSync33(outputPath) ? statSync15(outputPath).size : 0;
24435
+ const fileSize = existsSync34(outputPath) ? statSync15(outputPath).size : 0;
24316
24436
  return {
24317
24437
  ...referenceBackgroundResult8(plan2[REFERENCE_BACKGROUND_FIELD6]),
24318
24438
  outputPath,
@@ -24322,15 +24442,15 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
24322
24442
  };
24323
24443
  }
24324
24444
  function readAssemblePlan(planDir, chunkPaths) {
24325
- const planJsonPath = join52(planDir, "plan.json");
24326
- const chunksJsonPath = join52(planDir, "meta", "chunks.json");
24327
- if (!existsSync33(planJsonPath)) {
24445
+ const planJsonPath = join53(planDir, "plan.json");
24446
+ const chunksJsonPath = join53(planDir, "meta", "chunks.json");
24447
+ if (!existsSync34(planJsonPath)) {
24328
24448
  throw new Error(`[assemble] planDir missing plan.json: ${planJsonPath}`);
24329
24449
  }
24330
24450
  const plan2 = JSON.parse(readFileSync17(planJsonPath, "utf-8"));
24331
24451
  readPlanProtocolV1(plan2, DISTRIBUTED_RENDER_CAPABILITIES.roles.assembler);
24332
24452
  validatePlanV2MaterializedTarget(planDir, { role: "assembler" });
24333
- if (!existsSync33(chunksJsonPath)) {
24453
+ if (!existsSync34(chunksJsonPath)) {
24334
24454
  throw new Error(`[assemble] planDir missing meta/chunks.json: ${chunksJsonPath}`);
24335
24455
  }
24336
24456
  const chunks = JSON.parse(readFileSync17(chunksJsonPath, "utf-8"));
@@ -24345,7 +24465,7 @@ function readAssemblePlan(planDir, chunkPaths) {
24345
24465
  }
24346
24466
  }
24347
24467
  for (const path of chunkPaths.flat()) {
24348
- if (!existsSync33(path)) {
24468
+ if (!existsSync34(path)) {
24349
24469
  throw new Error(`[assemble] chunk path does not exist: ${path}`);
24350
24470
  }
24351
24471
  }
@@ -24378,7 +24498,7 @@ function cfrEncodeArgs(inputArgs, encoder, fpsArg) {
24378
24498
  return args;
24379
24499
  }
24380
24500
  async function reencodeCfr(ctx, chunkPaths, encoder) {
24381
- const cfrOutputPath = join52(ctx.workDir, `cfr.${ctx.format}`);
24501
+ const cfrOutputPath = join53(ctx.workDir, `cfr.${ctx.format}`);
24382
24502
  const cfrArgs = cfrEncodeArgs(videoInputArgs(ctx, chunkPaths), encoder, ctx.fpsArg);
24383
24503
  appendRenderProvenanceArgs2(cfrArgs, cfrOutputPath);
24384
24504
  cfrArgs.push("-y", cfrOutputPath);
@@ -24405,7 +24525,7 @@ async function writeJoined(ctx, videoSources, audioPath, finalPath) {
24405
24525
  );
24406
24526
  return;
24407
24527
  }
24408
- const paddedAudioPath = join52(ctx.workDir, "audio-padded.m4a");
24528
+ const paddedAudioPath = join53(ctx.workDir, "audio-padded.m4a");
24409
24529
  const padTrimResult = await ctx.timed(
24410
24530
  "audioMs",
24411
24531
  () => padOrTrimAudioToVideoFrameCount({
@@ -24480,12 +24600,12 @@ function stitchesSeparateAudio(planDir) {
24480
24600
  return lockedAudio(planDir).separateAudio === true;
24481
24601
  }
24482
24602
  function planFormat(planDir) {
24483
- const plan2 = JSON.parse(readFileSync17(join52(planDir, "plan.json"), "utf-8"));
24603
+ const plan2 = JSON.parse(readFileSync17(join53(planDir, "plan.json"), "utf-8"));
24484
24604
  return plan2.dimensions.format;
24485
24605
  }
24486
24606
  function lockedAudio(planDir) {
24487
- const encoderJsonPath = join52(planDir, "meta", "encoder.json");
24488
- if (!existsSync33(encoderJsonPath)) return {};
24607
+ const encoderJsonPath = join53(planDir, "meta", "encoder.json");
24608
+ if (!existsSync34(encoderJsonPath)) return {};
24489
24609
  return JSON.parse(readFileSync17(encoderJsonPath, "utf-8"));
24490
24610
  }
24491
24611
  function readCfrEncoder(planDir, format) {
@@ -24494,8 +24614,8 @@ function readCfrEncoder(planDir, format) {
24494
24614
  `[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.`
24495
24615
  );
24496
24616
  }
24497
- const encoderJsonPath = join52(planDir, "meta", "encoder.json");
24498
- if (!existsSync33(encoderJsonPath)) {
24617
+ const encoderJsonPath = join53(planDir, "meta", "encoder.json");
24618
+ if (!existsSync34(encoderJsonPath)) {
24499
24619
  throw new Error(`[assemble] planDir missing meta/encoder.json: ${encoderJsonPath}`);
24500
24620
  }
24501
24621
  const encoderJson = JSON.parse(readFileSync17(encoderJsonPath, "utf-8"));
@@ -24507,7 +24627,7 @@ function readCfrEncoder(planDir, format) {
24507
24627
  return encoderJson;
24508
24628
  }
24509
24629
  function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, startTimeMs) {
24510
- if (existsSync33(outputPath)) rmSync20(outputPath, { recursive: true, force: true });
24630
+ if (existsSync34(outputPath)) rmSync20(outputPath, { recursive: true, force: true });
24511
24631
  mkdirSync22(outputPath, { recursive: true });
24512
24632
  let globalIdx = 0;
24513
24633
  for (const chunkDir of chunkPaths) {
@@ -24521,8 +24641,8 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
24521
24641
  throw new Error(`[assemble] png-sequence chunk has no frames: ${chunkDir}`);
24522
24642
  }
24523
24643
  for (const frame of frames) {
24524
- const dst = join52(outputPath, formatExportFrameName(globalIdx, "png"));
24525
- cpSync3(join52(chunkDir, frame), dst);
24644
+ const dst = join53(outputPath, formatExportFrameName(globalIdx, "png"));
24645
+ cpSync3(join53(chunkDir, frame), dst);
24526
24646
  globalIdx += 1;
24527
24647
  }
24528
24648
  }
@@ -24531,14 +24651,14 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
24531
24651
  `[assemble] png-sequence frame count mismatch: merged ${globalIdx} frames vs plan.totalFrames=${totalFrames}. Using on-disk count.`
24532
24652
  );
24533
24653
  }
24534
- if (audioPath !== null && existsSync33(audioPath)) {
24535
- const sidecar = join52(outputPath, MIXED_AUDIO_FILENAME4);
24654
+ if (audioPath !== null && existsSync34(audioPath)) {
24655
+ const sidecar = join53(outputPath, MIXED_AUDIO_FILENAME4);
24536
24656
  cpSync3(audioPath, sidecar);
24537
24657
  }
24538
24658
  let fileSize = 0;
24539
24659
  for (const name of readdirSync12(outputPath)) {
24540
24660
  try {
24541
- fileSize += statSync15(join52(outputPath, name)).size;
24661
+ fileSize += statSync15(join53(outputPath, name)).size;
24542
24662
  } catch {
24543
24663
  }
24544
24664
  }
@@ -24552,8 +24672,8 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
24552
24672
 
24553
24673
  // src/services/distributed/planV2Execution.ts
24554
24674
  async function renderChunkV2(planV2Dir, chunkIndex, outputChunkPath, options) {
24555
- const workRoot = mkdtempSync3(join53(tmpdir7(), "hf-plan-v2-chunk-"));
24556
- const materializedPlanDir = join53(workRoot, "plan");
24675
+ const workRoot = mkdtempSync3(join54(tmpdir7(), "hf-plan-v2-chunk-"));
24676
+ const materializedPlanDir = join54(workRoot, "plan");
24557
24677
  try {
24558
24678
  materializePlanV2Target(planV2Dir, { role: "chunk", chunkIndex }, materializedPlanDir);
24559
24679
  return await renderChunk(materializedPlanDir, chunkIndex, outputChunkPath, options);
@@ -24562,8 +24682,8 @@ async function renderChunkV2(planV2Dir, chunkIndex, outputChunkPath, options) {
24562
24682
  }
24563
24683
  }
24564
24684
  async function assembleV2(planV2Dir, chunkPaths, outputPath, options) {
24565
- const workRoot = mkdtempSync3(join53(tmpdir7(), "hf-plan-v2-assembler-"));
24566
- const materializedPlanDir = join53(workRoot, "plan");
24685
+ const workRoot = mkdtempSync3(join54(tmpdir7(), "hf-plan-v2-assembler-"));
24686
+ const materializedPlanDir = join54(workRoot, "plan");
24567
24687
  try {
24568
24688
  const materialized = materializePlanV2Target(
24569
24689
  planV2Dir,