@hyperframes/producer 0.9.99 → 0.9.101

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.
@@ -23,16 +23,16 @@ import {
23
23
  existsSync as existsSync26,
24
24
  fstatSync as fstatSync5,
25
25
  lstatSync as lstatSync4,
26
- mkdirSync as mkdirSync14,
26
+ mkdirSync as mkdirSync15,
27
27
  openSync as openSync7,
28
28
  statSync as statSync12,
29
29
  mkdtempSync,
30
- writeFileSync as writeFileSync8,
30
+ writeFileSync as writeFileSync9,
31
31
  rmSync as rmSync14,
32
32
  createReadStream as createReadStream4
33
33
  } from "node:fs";
34
34
  import { AsyncLocalStorage } from "node:async_hooks";
35
- import { basename as basename8, resolve as resolve12, dirname as dirname20, join as join40 } from "node:path";
35
+ import { basename as basename8, resolve as resolve12, dirname as dirname20, join as join41 } from "node:path";
36
36
  import { homedir, tmpdir as tmpdir4 } from "node:os";
37
37
  import { parseArgs } from "node:util";
38
38
  import { isIP } from "node:net";
@@ -52,11 +52,11 @@ import { foreignWritablePath } from "@hyperframes/core/cache-dir";
52
52
  import { audioFailureDiagnostics as audioFailureDiagnostics2, cpuBudget } from "@hyperframes/engine";
53
53
  import {
54
54
  existsSync as existsSync22,
55
- mkdirSync as mkdirSync13,
55
+ mkdirSync as mkdirSync14,
56
56
  readdirSync as readdirSync6,
57
57
  rmSync as rmSync13,
58
58
  statSync as statSync10,
59
- writeFileSync as writeFileSync7,
59
+ writeFileSync as writeFileSync8,
60
60
  copyFileSync as copyFileSync5,
61
61
  appendFileSync
62
62
  } from "fs";
@@ -403,7 +403,7 @@ import {
403
403
  referenceBackgroundResult,
404
404
  createReferenceBackgroundRecorder
405
405
  } from "@hyperframes/engine";
406
- import { join as join35, dirname as dirname16, resolve as resolve10 } from "path";
406
+ import { join as join36, dirname as dirname16, resolve as resolve10 } from "path";
407
407
  import { fromEmptyFolder } from "@hyperframes/parsers/ff-binaries";
408
408
  import { totalmem as totalmem2 } from "node:os";
409
409
  import { randomUUID as randomUUID3 } from "crypto";
@@ -11099,8 +11099,8 @@ async function runCompileStage(input) {
11099
11099
  }
11100
11100
 
11101
11101
  // src/services/render/stages/probeStage.ts
11102
- import { createHash as createHash7 } from "node:crypto";
11103
- import { basename as basename7, join as join24 } from "node:path";
11102
+ import { createHash as createHash8 } from "node:crypto";
11103
+ import { basename as basename7, join as join25 } from "node:path";
11104
11104
  import { parseHTML as parseHTML6 } from "@hyperframes/parsers/linkedom";
11105
11105
  import {
11106
11106
  closeCaptureSession as closeCaptureSession4,
@@ -11153,6 +11153,211 @@ function resolveCaptureSurface(input, quality) {
11153
11153
  };
11154
11154
  }
11155
11155
 
11156
+ // src/services/render/stages/runtimeAudio.ts
11157
+ import { createHash as createHash7 } from "node:crypto";
11158
+ import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync6 } from "node:fs";
11159
+ import { join as join24 } from "node:path";
11160
+ var RUNTIME_AUDIO_SUBDIR = "__hf_runtime_audio";
11161
+ var MAX_INLINE_AUDIO_BYTES = 64 * 1024 * 1024;
11162
+ var MAX_TOTAL_INLINE_AUDIO_BYTES = 128 * 1024 * 1024;
11163
+ var MIME_EXTENSIONS = {
11164
+ "audio/wav": ".wav",
11165
+ "audio/wave": ".wav",
11166
+ "audio/x-wav": ".wav",
11167
+ "audio/mpeg": ".mp3",
11168
+ "audio/mp3": ".mp3",
11169
+ "audio/ogg": ".ogg",
11170
+ "audio/webm": ".webm",
11171
+ "audio/aac": ".m4a",
11172
+ "audio/mp4": ".m4a",
11173
+ "audio/m4a": ".m4a",
11174
+ "audio/x-m4a": ".m4a",
11175
+ "audio/flac": ".flac",
11176
+ "audio/x-flac": ".flac"
11177
+ };
11178
+ var BASE64_BODY = /^[A-Za-z0-9+/]*={0,2}$/;
11179
+ function extensionForMime(mimeType) {
11180
+ const normalized = mimeType.split(";", 1)[0]?.trim().toLowerCase() ?? "";
11181
+ return MIME_EXTENSIONS[normalized] ?? ".bin";
11182
+ }
11183
+ function sameOriginBlobPrefix(fileServerUrl) {
11184
+ try {
11185
+ return `blob:${new URL(fileServerUrl).origin}/`.toLowerCase();
11186
+ } catch {
11187
+ return null;
11188
+ }
11189
+ }
11190
+ function decodeBase64Within(raw, maxBytes) {
11191
+ const compact = raw.replace(/\s+/g, "");
11192
+ if (compact.length === 0 || compact.length % 4 === 1) return null;
11193
+ const maxChars = Math.ceil(maxBytes / 3) * 4;
11194
+ if (compact.length > maxChars || !BASE64_BODY.test(compact)) return null;
11195
+ const bytes = Buffer.from(compact, "base64");
11196
+ return bytes.byteLength > 0 && bytes.byteLength <= maxBytes ? bytes : null;
11197
+ }
11198
+ function decodePercentWithin(payload, maxBytes) {
11199
+ if (payload.length > maxBytes * 3) return null;
11200
+ try {
11201
+ const bytes = Buffer.from(decodeURIComponent(payload), "utf8");
11202
+ return bytes.byteLength > 0 && bytes.byteLength <= maxBytes ? bytes : null;
11203
+ } catch {
11204
+ return null;
11205
+ }
11206
+ }
11207
+ function parseDataHeader(header) {
11208
+ const parts = header.split(";").map((part) => part.trim()).filter(Boolean);
11209
+ const isBase64 = parts.at(-1)?.toLowerCase() === "base64";
11210
+ const first = parts[0] ?? "";
11211
+ const isMime = Boolean(first) && !first.includes("=") && first.toLowerCase() !== "base64";
11212
+ return { isBase64, mimeType: isMime ? first.toLowerCase() : "" };
11213
+ }
11214
+ function decodeDataAudioUri(uri, maxBytes) {
11215
+ const comma = uri.indexOf(",");
11216
+ if (comma < 5) return { ok: false, reason: "malformed_data_uri" };
11217
+ const payload = uri.slice(comma + 1);
11218
+ if (!payload) return { ok: false, reason: "empty" };
11219
+ const { isBase64, mimeType } = parseDataHeader(uri.slice(5, comma));
11220
+ const bytes = isBase64 ? decodeBase64Within(payload, maxBytes) : decodePercentWithin(payload, maxBytes);
11221
+ return bytes ? { ok: true, bytes, mimeType } : { ok: false, reason: "invalid_or_too_large" };
11222
+ }
11223
+ function writeRuntimeAudio(compiledDir, bytes, mimeType) {
11224
+ const digest = createHash7("sha256").update(bytes).digest("hex").slice(0, 16);
11225
+ const filename = `${digest}${extensionForMime(mimeType)}`;
11226
+ const dir = join24(compiledDir, RUNTIME_AUDIO_SUBDIR);
11227
+ mkdirSync11(dir, { recursive: true });
11228
+ const target = join24(dir, filename);
11229
+ try {
11230
+ writeFileSync6(target, bytes, { flag: "wx" });
11231
+ } catch (error) {
11232
+ if (error.code !== "EEXIST") throw error;
11233
+ }
11234
+ return `${RUNTIME_AUDIO_SUBDIR}/${filename}`;
11235
+ }
11236
+ async function readBlobFromPage(page, url, maxBytes) {
11237
+ const result = await page.evaluate(
11238
+ async (blobUrl, limit) => {
11239
+ try {
11240
+ const response = await fetch(blobUrl);
11241
+ if (!response.ok) return { ok: false, reason: `status_${response.status}` };
11242
+ const blob = await response.blob();
11243
+ if (blob.size <= 0) return { ok: false, reason: "empty" };
11244
+ if (blob.size > limit) return { ok: false, reason: "too_large" };
11245
+ const dataUrl = await new Promise((resolve13, reject) => {
11246
+ const reader = new FileReader();
11247
+ reader.onload = () => resolve13(String(reader.result ?? ""));
11248
+ reader.onerror = () => reject(reader.error ?? new Error("read failed"));
11249
+ reader.readAsDataURL(blob);
11250
+ });
11251
+ const comma = dataUrl.indexOf(",");
11252
+ return comma < 0 ? { ok: false, reason: "invalid_data_url" } : { ok: true, base64: dataUrl.slice(comma + 1), mimeType: blob.type || "" };
11253
+ } catch {
11254
+ return { ok: false, reason: "fetch_failed" };
11255
+ }
11256
+ },
11257
+ url,
11258
+ maxBytes
11259
+ );
11260
+ if (!result || typeof result !== "object") return { ok: false, reason: "invalid_response" };
11261
+ const typed = result;
11262
+ if (typed.ok === true && typeof typed.base64 === "string") {
11263
+ return {
11264
+ ok: true,
11265
+ base64: typed.base64,
11266
+ mimeType: typeof typed.mimeType === "string" ? typed.mimeType : ""
11267
+ };
11268
+ }
11269
+ const reason = typed.ok === false && typeof typed.reason === "string" ? typed.reason : "read_failed";
11270
+ return { ok: false, reason };
11271
+ }
11272
+ async function materializeOneBlob(audio, page, compiledDir, clipLimit, log, assertNotAborted) {
11273
+ if (clipLimit <= 0) {
11274
+ log?.warn("[Probe] Runtime audio byte limit reached; cannot materialize blob", {
11275
+ id: audio.id
11276
+ });
11277
+ return null;
11278
+ }
11279
+ const read2 = await readBlobFromPage(page, audio.src, clipLimit);
11280
+ assertNotAborted?.();
11281
+ if (!read2.ok) {
11282
+ log?.warn("[Probe] Could not materialize blob audio source", {
11283
+ id: audio.id,
11284
+ reason: read2.reason
11285
+ });
11286
+ return null;
11287
+ }
11288
+ const bytes = decodeBase64Within(read2.base64, clipLimit);
11289
+ if (!bytes) {
11290
+ log?.warn("[Probe] Blob audio payload was empty, invalid, or exceeded limit", {
11291
+ id: audio.id
11292
+ });
11293
+ return null;
11294
+ }
11295
+ return { path: writeRuntimeAudio(compiledDir, bytes, read2.mimeType), bytes: bytes.byteLength };
11296
+ }
11297
+ async function materializeBlobAudioSources(input) {
11298
+ const prefix = sameOriginBlobPrefix(input.fileServerUrl);
11299
+ if (!prefix) return;
11300
+ const maxPerClip = input.limits?.maxPerClipBytes ?? MAX_INLINE_AUDIO_BYTES;
11301
+ let remaining = input.limits?.maxTotalBytes ?? MAX_TOTAL_INLINE_AUDIO_BYTES;
11302
+ const cachedByUrl = /* @__PURE__ */ new Map();
11303
+ for (const audio of input.audios) {
11304
+ if (!/^blob:/i.test(audio.src)) continue;
11305
+ const cached = cachedByUrl.get(audio.src);
11306
+ if (cached) {
11307
+ audio.src = cached;
11308
+ continue;
11309
+ }
11310
+ if (!audio.src.toLowerCase().startsWith(prefix)) {
11311
+ input.log?.warn("[Probe] Skipping cross-origin blob audio source", { id: audio.id });
11312
+ continue;
11313
+ }
11314
+ const written = await materializeOneBlob(
11315
+ audio,
11316
+ input.page,
11317
+ input.compiledDir,
11318
+ Math.min(maxPerClip, remaining),
11319
+ input.log,
11320
+ input.assertNotAborted
11321
+ );
11322
+ if (!written) continue;
11323
+ remaining -= written.bytes;
11324
+ cachedByUrl.set(audio.src, written.path);
11325
+ audio.src = written.path;
11326
+ }
11327
+ }
11328
+ function materializeDataAudioSources(input) {
11329
+ const maxPerClip = input.limits?.maxPerClipBytes ?? MAX_INLINE_AUDIO_BYTES;
11330
+ let remaining = input.limits?.maxTotalBytes ?? MAX_TOTAL_INLINE_AUDIO_BYTES;
11331
+ const cachedByUri = /* @__PURE__ */ new Map();
11332
+ for (const audio of input.audios) {
11333
+ if (!/^data:/i.test(audio.src)) continue;
11334
+ const cached = cachedByUri.get(audio.src);
11335
+ if (cached) {
11336
+ audio.src = cached;
11337
+ continue;
11338
+ }
11339
+ const clipLimit = Math.min(maxPerClip, remaining);
11340
+ if (clipLimit <= 0) {
11341
+ input.log?.warn("[Probe] Inline audio byte limit reached; cannot materialize data URI", {
11342
+ id: audio.id
11343
+ });
11344
+ continue;
11345
+ }
11346
+ const decoded = decodeDataAudioUri(audio.src, clipLimit);
11347
+ if (!decoded.ok) {
11348
+ input.log?.warn("[Probe] Could not materialize data audio source", {
11349
+ id: audio.id,
11350
+ reason: decoded.reason
11351
+ });
11352
+ continue;
11353
+ }
11354
+ remaining -= decoded.bytes.byteLength;
11355
+ const relativePath = writeRuntimeAudio(input.compiledDir, decoded.bytes, decoded.mimeType);
11356
+ cachedByUri.set(audio.src, relativePath);
11357
+ audio.src = relativePath;
11358
+ }
11359
+ }
11360
+
11156
11361
  // src/services/render/stages/probeStage.ts
11157
11362
  var FRAME_BOUNDARY_EPSILON = 1e-3;
11158
11363
  function durationToFrameCount(duration, fps) {
@@ -11339,6 +11544,7 @@ function hasRuntimeMediaChanges(html) {
11339
11544
  if (insertedMedia) return true;
11340
11545
  const managed = managedMediaElements(document2, false);
11341
11546
  if (managed.length === 0) return false;
11547
+ if (scriptBodies.some((script) => /\bcreateObjectURL\s*\(/.test(script))) return true;
11342
11548
  const managedIds = new Set(managed.map((m) => m.element.getAttribute("id")).filter(Boolean));
11343
11549
  const selectors = /* @__PURE__ */ new Set();
11344
11550
  let work = 0;
@@ -11379,7 +11585,7 @@ function reportedLengthSource(source) {
11379
11585
  if (!source) return null;
11380
11586
  if (source.from !== "media") return { from: source.from };
11381
11587
  const name = basename7(source.src.split(/[?#]/, 1)[0] ?? "");
11382
- const srcHash = createHash7("sha256").update(name).digest("hex").slice(0, 12);
11588
+ const srcHash = createHash8("sha256").update(name).digest("hex").slice(0, 12);
11383
11589
  return { from: "media", tag: source.tag, trimmed: source.trimmed, srcHash };
11384
11590
  }
11385
11591
  var STOPPED = "Preparing the render stopped while ";
@@ -11454,7 +11660,7 @@ async function runProbeStage(input) {
11454
11660
  });
11455
11661
  fileServer = await createFileServer({
11456
11662
  projectDir,
11457
- compiledDir: join24(workDir, "compiled"),
11663
+ compiledDir: join25(workDir, "compiled"),
11458
11664
  port: 0,
11459
11665
  preHeadScripts: [VIRTUAL_TIME_SHIM],
11460
11666
  fps: job.config.fps,
@@ -11468,7 +11674,7 @@ async function runProbeStage(input) {
11468
11674
  composition.videos,
11469
11675
  compiled.html,
11470
11676
  projectDir,
11471
- join24(workDir, "compiled")
11677
+ join25(workDir, "compiled")
11472
11678
  ),
11473
11679
  recordReferenceBackground: input.recordReferenceBackground,
11474
11680
  width,
@@ -11497,7 +11703,7 @@ async function runProbeStage(input) {
11497
11703
  log.info("Creating capture session...", { attempt, maxAttempts: PROBE_MAX_ATTEMPTS });
11498
11704
  probeSession = await createCaptureSession4(
11499
11705
  fileServer.url,
11500
- join24(workDir, "probe"),
11706
+ join25(workDir, "probe"),
11501
11707
  captureOpts,
11502
11708
  null,
11503
11709
  probeCfg
@@ -11583,7 +11789,7 @@ async function runProbeStage(input) {
11583
11789
  });
11584
11790
  probeSession = await createCaptureSession4(
11585
11791
  fileServer.url,
11586
- join24(workDir, "probe-screenshot"),
11792
+ join25(workDir, "probe-screenshot"),
11587
11793
  captureOpts,
11588
11794
  null,
11589
11795
  { ...probeCfg, forceScreenshot: true }
@@ -11627,7 +11833,7 @@ async function runProbeStage(input) {
11627
11833
  compiled,
11628
11834
  resolutions,
11629
11835
  projectDir,
11630
- join24(workDir, "downloads"),
11836
+ join25(workDir, "downloads"),
11631
11837
  job.config.allowOutsideProjectAssets ? void 0 : projectDir,
11632
11838
  { includeScripts: job.config.includeOutsideScripts }
11633
11839
  );
@@ -11776,6 +11982,21 @@ async function runProbeStage(input) {
11776
11982
  }
11777
11983
  }
11778
11984
  }
11985
+ if (fileServer && composition.audios.length > 0) {
11986
+ const compiledDir = join25(workDir, "compiled");
11987
+ const serverUrl = fileServer.url;
11988
+ await probeStep(
11989
+ "reading runtime audio from the browser",
11990
+ () => materializeBlobAudioSources({
11991
+ page: session.page,
11992
+ fileServerUrl: serverUrl,
11993
+ audios: composition.audios,
11994
+ compiledDir,
11995
+ log,
11996
+ assertNotAborted
11997
+ })
11998
+ );
11999
+ }
11779
12000
  if (composition.audios.length > 0) {
11780
12001
  log.info("Discovering audio volume automation...", {
11781
12002
  audioCount: composition.audios.length
@@ -11824,6 +12045,11 @@ async function runProbeStage(input) {
11824
12045
  }
11825
12046
  }
11826
12047
  }
12048
+ materializeDataAudioSources({
12049
+ audios: composition.audios,
12050
+ compiledDir: join25(workDir, "compiled"),
12051
+ log
12052
+ });
11827
12053
  dropMediaOutsideProject({
11828
12054
  projectDir,
11829
12055
  workDir,
@@ -11833,7 +12059,7 @@ async function runProbeStage(input) {
11833
12059
  });
11834
12060
  await preflightCompositionAssetMediaTypes({
11835
12061
  projectDir,
11836
- compiledDir: join24(workDir, "compiled"),
12062
+ compiledDir: join25(workDir, "compiled"),
11837
12063
  composition,
11838
12064
  signal: abortSignal
11839
12065
  });
@@ -11969,7 +12195,7 @@ function validateRenderDuration(input) {
11969
12195
 
11970
12196
  // src/services/render/stages/extractVideosStage.ts
11971
12197
  import { existsSync as existsSync14 } from "node:fs";
11972
- import { join as join25 } from "node:path";
12198
+ import { join as join26 } from "node:path";
11973
12199
  import {
11974
12200
  classifyVideoExtractionError,
11975
12201
  createFrameLookupTable as createFrameLookupTable3,
@@ -12334,7 +12560,7 @@ async function runExtractVideosStage(input) {
12334
12560
  // because short boundary counts can differ by one frame.
12335
12561
  {
12336
12562
  fps: job.config.fps,
12337
- outputDir: join25(compiledDir, "__hyperframes_video_frames"),
12563
+ outputDir: join26(compiledDir, "__hyperframes_video_frames"),
12338
12564
  format: job.config.videoFrameFormat ?? "auto",
12339
12565
  toneMapHdrToSdr: rendersSdrOnly(job.config, composition),
12340
12566
  timelineEnd: composition.duration,
@@ -12342,7 +12568,7 @@ async function runExtractVideosStage(input) {
12342
12568
  collectProbeFailures: extractionPolicy.failureMode === "enforce",
12343
12569
  deferRangeExtraction,
12344
12570
  shownBoxes,
12345
- contentKeyedDirs: [join25(compiledDir, REMOTE_MEDIA_SUBDIR)],
12571
+ contentKeyedDirs: [join26(compiledDir, REMOTE_MEDIA_SUBDIR)],
12346
12572
  urlByAbsentLocalPath,
12347
12573
  assetRoots,
12348
12574
  onProgress: ({ planned = 0, done = 0 }) => {
@@ -12434,7 +12660,7 @@ async function remoteProbeSource(video, input) {
12434
12660
  if (!isPublicHttpsUrl(video.src)) return null;
12435
12661
  if (!resolveRestrictPageNetwork()) return video.src;
12436
12662
  if (!video.hasAudio || video.hidden) return null;
12437
- const downloadDir = input.downloadDir ?? join25(input.compiledDir, REMOTE_MEDIA_SUBDIR);
12663
+ const downloadDir = input.downloadDir ?? join26(input.compiledDir, REMOTE_MEDIA_SUBDIR);
12438
12664
  try {
12439
12665
  return await downloadToTemp2(video.src, downloadDir, void 0, input.signal, void 0, {
12440
12666
  onTelemetry: writeUrlDownloadTelemetry2
@@ -12559,7 +12785,7 @@ async function planVideoLayerPassthrough(input) {
12559
12785
 
12560
12786
  // src/services/render/stages/audioStage.ts
12561
12787
  import { existsSync as existsSync17 } from "node:fs";
12562
- import { join as join28 } from "node:path";
12788
+ import { join as join29 } from "node:path";
12563
12789
  import {
12564
12790
  MIXED_AUDIO_FILENAME,
12565
12791
  audioFailureDiagnostics,
@@ -12571,7 +12797,7 @@ import {
12571
12797
 
12572
12798
  // src/services/render/audioDeliveryLimit.ts
12573
12799
  import { existsSync as existsSync16 } from "node:fs";
12574
- import { dirname as dirname13, join as join27 } from "node:path";
12800
+ import { dirname as dirname13, join as join28 } from "node:path";
12575
12801
  import {
12576
12802
  applyAudioFxChain,
12577
12803
  describeFfmpegFailure as describeFfmpegFailure3,
@@ -12582,7 +12808,7 @@ import {
12582
12808
  // src/services/render/audioPadTrim.ts
12583
12809
  import { ffmpegCwd as ffmpegCwd2, localContainerInputArgs } from "@hyperframes/parsers/ff-binaries";
12584
12810
  import { spawn } from "node:child_process";
12585
- import { dirname as dirname12, join as join26 } from "node:path";
12811
+ import { dirname as dirname12, join as join27 } from "node:path";
12586
12812
  import {
12587
12813
  DEFAULT_CONFIG,
12588
12814
  describeFfmpegFailure as describeFfmpegFailure2,
@@ -12863,7 +13089,7 @@ async function constrainAacTruePeak(input) {
12863
13089
  }
12864
13090
  async function cutSource(input, scratchDir, attenuationDb) {
12865
13091
  if (!input.sourcePath || !input.rewriteSource) return true;
12866
- const cutPath = join26(scratchDir, "source.wav");
13092
+ const cutPath = join27(scratchDir, "source.wav");
12867
13093
  try {
12868
13094
  const result = await input.rewriteSource(input.sourcePath, cutPath, gainFilter(attenuationDb));
12869
13095
  if (!result.success) throw new Error(result.error);
@@ -12878,7 +13104,7 @@ async function enforceAacTruePeak(input) {
12878
13104
  let scratchDir;
12879
13105
  try {
12880
13106
  scratchDir = createStagingDir3(dirname12(input.audioPath), ".true-peak-");
12881
- const correctedPath = join26(scratchDir, "audio.m4a");
13107
+ const correctedPath = join27(scratchDir, "audio.m4a");
12882
13108
  const measurements = [];
12883
13109
  let attenuationDb = 0;
12884
13110
  let sourcePeakDbfs;
@@ -13102,7 +13328,7 @@ async function limitDeliveryPeaks(input, deps = {
13102
13328
  const peak = await deps.measure(audioPath, { timeoutMs, signal });
13103
13329
  if (peak <= AAC_DELIVERY_TRUE_PEAK_DBFS) return { success: true };
13104
13330
  const alternating = ["a", "b"].map(
13105
- (k) => join27(dirname13(sourcePath), `audio-source-limited-${k}.wav`)
13331
+ (k) => join28(dirname13(sourcePath), `audio-source-limited-${k}.wav`)
13106
13332
  );
13107
13333
  let encodedFrom;
13108
13334
  let ceiling = AAC_DELIVERY_TRUE_PEAK_DBFS;
@@ -13175,7 +13401,7 @@ function runAudioStage(input) {
13175
13401
  }
13176
13402
  async function runAudioStageScoped(input) {
13177
13403
  const stageStart = Date.now();
13178
- const pcmSourcePath = join28(input.workDir, "audio-source.wav");
13404
+ const pcmSourcePath = join29(input.workDir, "audio-source.wav");
13179
13405
  const seconds = (frames) => frames * input.fps.den / input.fps.num;
13180
13406
  const duration = seconds(input.totalFrames);
13181
13407
  const window2 = input.frameWindow && {
@@ -13245,7 +13471,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath, window2) {
13245
13471
  assertNotAborted,
13246
13472
  log
13247
13473
  } = input;
13248
- const audioOutputPath = join28(workDir, MIXED_AUDIO_FILENAME);
13474
+ const audioOutputPath = join29(workDir, MIXED_AUDIO_FILENAME);
13249
13475
  let hasAudio = false;
13250
13476
  let audioError;
13251
13477
  let audioFailures;
@@ -13327,7 +13553,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath, window2) {
13327
13553
 
13328
13554
  // src/services/render/stages/captureStage.ts
13329
13555
  import { existsSync as existsSync18, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
13330
- import { join as join29 } from "node:path";
13556
+ import { join as join30 } from "node:path";
13331
13557
  import {
13332
13558
  classifyCaptureFailure as classifyCaptureFailure2,
13333
13559
  frameFileExtension,
@@ -13401,13 +13627,13 @@ function measureCaptureFrameBytes(workDir, framesDir) {
13401
13627
  if (!existsSync18(workDir)) return total;
13402
13628
  for (const attempt of readdirSync4(workDir)) {
13403
13629
  if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
13404
- total += sampleDirectoryBytes(join29(workDir, attempt));
13630
+ total += sampleDirectoryBytes(join30(workDir, attempt));
13405
13631
  continue;
13406
13632
  }
13407
13633
  if (!/^capture-attempt-\d+$/.test(attempt)) continue;
13408
- const attemptDir = join29(workDir, attempt);
13634
+ const attemptDir = join30(workDir, attempt);
13409
13635
  for (const name of readdirSync4(attemptDir)) {
13410
- if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join29(attemptDir, name));
13636
+ if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join30(attemptDir, name));
13411
13637
  }
13412
13638
  }
13413
13639
  return total;
@@ -13723,8 +13949,8 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
13723
13949
  }
13724
13950
 
13725
13951
  // src/services/render/stages/captureHdrStage.ts
13726
- import { existsSync as existsSync20, mkdirSync as mkdirSync11 } from "node:fs";
13727
- import { join as join33 } from "node:path";
13952
+ import { existsSync as existsSync20, mkdirSync as mkdirSync12 } from "node:fs";
13953
+ import { join as join34 } from "node:path";
13728
13954
  import {
13729
13955
  closeCaptureSession as closeCaptureSession7,
13730
13956
  cloneCaptureWarnings as cloneCaptureWarnings2,
@@ -13796,7 +14022,7 @@ function createHdrImageTransferCache(options = {}) {
13796
14022
  }
13797
14023
 
13798
14024
  // src/services/render/stages/captureHdrSequentialLoop.ts
13799
- import { join as join30 } from "node:path";
14025
+ import { join as join31 } from "node:path";
13800
14026
  import {
13801
14027
  TRANSITIONS as TRANSITIONS2,
13802
14028
  crossfade
@@ -13930,7 +14156,7 @@ async function runSequentialLayeredFrameLoop(input) {
13930
14156
  );
13931
14157
  if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
13932
14158
  writeFileExclusiveSync(
13933
- join30(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
14159
+ join31(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
13934
14160
  normalCanvas
13935
14161
  );
13936
14162
  }
@@ -13962,7 +14188,7 @@ async function runSequentialLayeredFrameLoop(input) {
13962
14188
  }
13963
14189
 
13964
14190
  // src/services/render/stages/captureHdrHybridLoop.ts
13965
- import { join as join32 } from "node:path";
14191
+ import { join as join33 } from "node:path";
13966
14192
  import {
13967
14193
  TRANSITIONS as TRANSITIONS3,
13968
14194
  closeCaptureSession as closeCaptureSession6,
@@ -13976,7 +14202,7 @@ import {
13976
14202
  // src/services/shaderTransitionWorkerPool.ts
13977
14203
  import { Worker as Worker2 } from "node:worker_threads";
13978
14204
  import { fileURLToPath as fileURLToPath4, pathToFileURL } from "node:url";
13979
- import { dirname as dirname14, join as join31 } from "node:path";
14205
+ import { dirname as dirname14, join as join32 } from "node:path";
13980
14206
  import { createRequire } from "node:module";
13981
14207
  import { usableCpuCount } from "@hyperframes/engine";
13982
14208
  import { existsSync as existsSync19 } from "node:fs";
@@ -13990,9 +14216,9 @@ function resolveWorkerEntry(explicit) {
13990
14216
  return { path: override, isTs };
13991
14217
  }
13992
14218
  const moduleDir = dirname14(fileURLToPath4(import.meta.url));
13993
- const jsPath = join31(moduleDir, "shaderTransitionWorker.js");
14219
+ const jsPath = join32(moduleDir, "shaderTransitionWorker.js");
13994
14220
  if (existsSync19(jsPath)) return { path: jsPath, isTs: false };
13995
- const tsPath = join31(moduleDir, "shaderTransitionWorker.ts");
14221
+ const tsPath = join32(moduleDir, "shaderTransitionWorker.ts");
13996
14222
  return { path: tsPath, isTs: true };
13997
14223
  }
13998
14224
  function buildExecArgv(entryIsTs) {
@@ -14372,7 +14598,7 @@ async function runHybridLayeredFrameLoop(input) {
14372
14598
  );
14373
14599
  if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
14374
14600
  writeFileExclusiveSync(
14375
- join32(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
14601
+ join33(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
14376
14602
  canvas
14377
14603
  );
14378
14604
  }
@@ -14581,9 +14807,9 @@ async function runCaptureHdrStage(input) {
14581
14807
  if (hdrVideoFrameSources.has(v.id)) hdrVideoEndTimes.set(v.id, v.end);
14582
14808
  }
14583
14809
  const debugDumpEnabled = process.env.KEEP_TEMP === "1";
14584
- const debugDumpDir = debugDumpEnabled ? join33(framesDir, "debug-composite") : null;
14810
+ const debugDumpDir = debugDumpEnabled ? join34(framesDir, "debug-composite") : null;
14585
14811
  if (debugDumpDir && !existsSync20(debugDumpDir)) {
14586
- mkdirSync11(debugDumpDir, { recursive: true });
14812
+ mkdirSync12(debugDumpDir, { recursive: true });
14587
14813
  }
14588
14814
  const compositeTransfer = resolveCompositeTransfer(hasHdrContent, effectiveHdr);
14589
14815
  const hdrTargetTransfer = compositeTransfer === "srgb" ? void 0 : compositeTransfer;
@@ -14746,15 +14972,15 @@ async function runCaptureHdrStage(input) {
14746
14972
  import {
14747
14973
  copyFileSync as copyFileSync4,
14748
14974
  existsSync as existsSync21,
14749
- mkdirSync as mkdirSync12,
14975
+ mkdirSync as mkdirSync13,
14750
14976
  readdirSync as readdirSync5,
14751
14977
  readFileSync as readFileSync10,
14752
14978
  rmSync as rmSync12,
14753
14979
  statSync as statSync9,
14754
- writeFileSync as writeFileSync6
14980
+ writeFileSync as writeFileSync7
14755
14981
  } from "node:fs";
14756
14982
  import { readFile as readFile2 } from "node:fs/promises";
14757
- import { dirname as dirname15, join as join34 } from "node:path";
14983
+ import { dirname as dirname15, join as join35 } from "node:path";
14758
14984
  import {
14759
14985
  encodeFramesChunkedConcat,
14760
14986
  encodeFramesFromDir,
@@ -14847,7 +15073,7 @@ async function reencodeWithClearedWholeFrames(argsInput, run, startTime) {
14847
15073
  const error = "[FFmpeg] GIF output could not be parsed to clear its frames";
14848
15074
  return gifEncodeFailure(startTime, outputPath, error);
14849
15075
  }
14850
- writeFileSync6(outputPath, gif);
15076
+ writeFileSync7(outputPath, gif);
14851
15077
  return null;
14852
15078
  }
14853
15079
  async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
@@ -14973,7 +15199,7 @@ function encodeWhileCapturing(input, totalFrames, captureBudget) {
14973
15199
  await new Promise((resolve13) => wake = resolve13);
14974
15200
  }
14975
15201
  if (signal.aborted) return;
14976
- const mergedPath = join34(input.framesDir, formatCaptureFrameName(next, "jpg"));
15202
+ const mergedPath = join35(input.framesDir, formatCaptureFrameName(next, "jpg"));
14977
15203
  const frame = await readLandedFrame(landed.get(next), mergedPath);
14978
15204
  landed.delete(next);
14979
15205
  if (!await stream.writeFrame(frame)) {
@@ -15048,7 +15274,7 @@ async function runEncodeStage(input) {
15048
15274
  const stage5Start = Date.now();
15049
15275
  if (isPngSequence) {
15050
15276
  const encoded = startEncodeProgress(job, "Writing PNG sequence", onProgress);
15051
- if (!existsSync21(outputPath)) mkdirSync12(outputPath, { recursive: true });
15277
+ if (!existsSync21(outputPath)) mkdirSync13(outputPath, { recursive: true });
15052
15278
  const captured = readdirSync5(framesDir).filter((name) => name.endsWith(".png")).sort();
15053
15279
  if (captured.length === 0) {
15054
15280
  throw new Error(
@@ -15056,11 +15282,11 @@ async function runEncodeStage(input) {
15056
15282
  );
15057
15283
  }
15058
15284
  captured.forEach((name, i) => {
15059
- const dst = join34(outputPath, formatExportFrameName(i, "png"));
15060
- copyFileSync4(join34(framesDir, name), dst);
15285
+ const dst = join35(outputPath, formatExportFrameName(i, "png"));
15286
+ copyFileSync4(join35(framesDir, name), dst);
15061
15287
  });
15062
15288
  if (hasAudio && audioOutputPath && existsSync21(audioOutputPath)) {
15063
- copyFileSync4(audioOutputPath, join34(outputPath, MIXED_AUDIO_FILENAME2));
15289
+ copyFileSync4(audioOutputPath, join35(outputPath, MIXED_AUDIO_FILENAME2));
15064
15290
  log.info(
15065
15291
  `[Render] png-sequence: ${MIXED_AUDIO_FILENAME2} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME2}`
15066
15292
  );
@@ -15080,7 +15306,7 @@ async function runEncodeStage(input) {
15080
15306
  const encodeResult2 = await encodeGifFromDir(framesDir, framePattern2, outputPath, {
15081
15307
  fps: job.config.fps,
15082
15308
  loop,
15083
- palettePath: join34(dirname15(videoOnlyPath), "gif-palette.png"),
15309
+ palettePath: join35(dirname15(videoOnlyPath), "gif-palette.png"),
15084
15310
  preserveAlpha: needsAlpha,
15085
15311
  signal: abortSignal,
15086
15312
  timeout: engineCfg.ffmpegEncodeTimeout
@@ -15291,7 +15517,7 @@ function sampleDirectoryBytes(dir) {
15291
15517
  continue;
15292
15518
  }
15293
15519
  for (const name of entries) {
15294
- const full = join35(current, name);
15520
+ const full = join36(current, name);
15295
15521
  try {
15296
15522
  const st = statSync10(full);
15297
15523
  if (st.isDirectory()) {
@@ -15456,7 +15682,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
15456
15682
  const ranges = [];
15457
15683
  let rangeStart = null;
15458
15684
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
15459
- const framePath = join35(framesDir, formatCaptureFrameName(frameIndex, frameExt));
15685
+ const framePath = join36(framesDir, formatCaptureFrameName(frameIndex, frameExt));
15460
15686
  const missing = !existsSync22(framePath) || statSync10(framePath).size <= 8;
15461
15687
  if (missing && rangeStart === null) {
15462
15688
  rangeStart = frameIndex;
@@ -15473,7 +15699,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
15473
15699
  function buildMissingFrameRetryBatches(ranges, maxWorkers, workDir, attempt, rangeStart = 0, stride = 1) {
15474
15700
  const workersPerBatch = Math.max(1, Math.floor(maxWorkers));
15475
15701
  const batches = [];
15476
- const outputDirFor = (batchIndex, workerId) => join35(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
15702
+ const outputDirFor = (batchIndex, workerId) => join36(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
15477
15703
  if (stride > 1) {
15478
15704
  const spans = /* @__PURE__ */ new Map();
15479
15705
  for (const range of ranges) {
@@ -15533,8 +15759,8 @@ function getNextRetryWorkerCount(currentWorkers) {
15533
15759
  return Math.max(1, Math.floor(currentWorkers / 2));
15534
15760
  }
15535
15761
  function resolveRenderWorkDirPrefix(outputPath, jobId, platform2 = process.platform, systemTempDir = tmpdir3()) {
15536
- if (platform2 === "win32" || platform2 === "darwin") return join35(systemTempDir, "hf-render-");
15537
- return join35(dirname16(outputPath), `work-${jobId}-`);
15762
+ if (platform2 === "win32" || platform2 === "darwin") return join36(systemTempDir, "hf-render-");
15763
+ return join36(dirname16(outputPath), `work-${jobId}-`);
15538
15764
  }
15539
15765
  var MAX_TRANSIENT_CAPTURE_RETRIES = 1;
15540
15766
  function isTransientCaptureRetryEligible(failureKind, missing, retriesUsed) {
@@ -15589,7 +15815,7 @@ The composition is too large for the available memory. To reduce memory pressure
15589
15815
  function countCapturedFrames(totalFrames, framesDir, frameExt) {
15590
15816
  let captured = 0;
15591
15817
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
15592
- const framePath = join35(framesDir, formatCaptureFrameName(frameIndex, frameExt));
15818
+ const framePath = join36(framesDir, formatCaptureFrameName(frameIndex, frameExt));
15593
15819
  if (existsSync22(framePath)) captured++;
15594
15820
  }
15595
15821
  return captured;
@@ -15615,7 +15841,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
15615
15841
  reason: attempt === 0 ? "initial" : pendingTransientRetry ? "transient-retry" : "retry"
15616
15842
  });
15617
15843
  pendingTransientRetry = false;
15618
- const attemptWorkDir = join35(options.workDir, `capture-attempt-${attempt}`);
15844
+ const attemptWorkDir = join36(options.workDir, `capture-attempt-${attempt}`);
15619
15845
  const batches = missingRanges ? buildMissingFrameRetryBatches(
15620
15846
  missingRanges,
15621
15847
  currentWorkers,
@@ -16263,7 +16489,7 @@ function deVerifyFallbackTelemetry(err) {
16263
16489
  }
16264
16490
  function resolveRenderDebugDir() {
16265
16491
  const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve10(process.env.PRODUCER_RENDERS_DIR, "..") : resolve10(dirname16(fileURLToPath5(import.meta.url)), "../..");
16266
- return join35(producerRoot, ".debug");
16492
+ return join36(producerRoot, ".debug");
16267
16493
  }
16268
16494
  function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
16269
16495
  return fromEmptyFolder(
@@ -16283,11 +16509,11 @@ async function renderJob(job, projectDir, outputPath, progressSink, abortSignal,
16283
16509
  validateChromaSubsamplingConfig(job.config);
16284
16510
  const debugDir = resolveRenderDebugDir();
16285
16511
  const outputDir = dirname16(outputPath);
16286
- if (!existsSync22(outputDir)) mkdirSync13(outputDir, { recursive: true });
16287
- const workDir = job.config.debug ? join35(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
16512
+ if (!existsSync22(outputDir)) mkdirSync14(outputDir, { recursive: true });
16513
+ const workDir = job.config.debug ? join36(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
16288
16514
  const pipelineStart = Date.now();
16289
16515
  const baseLog = job.config.logger ?? defaultLogger;
16290
- const logPath = job.config.debug ? join35(workDir, "render.log") : null;
16516
+ const logPath = job.config.debug ? join36(workDir, "render.log") : null;
16291
16517
  const execution = new RenderExecutionContext({
16292
16518
  request: { renderJobId: job.id, projectDir, outputPath },
16293
16519
  logger: logPath ? createRenderFileLogger(logPath, baseLog) : baseLog,
@@ -16364,7 +16590,7 @@ async function executeRenderPipeline(input) {
16364
16590
  imageDecodeFailures: 0
16365
16591
  };
16366
16592
  let hdrPerf;
16367
- const perfOutputPath = join35(workDir, "perf-summary.json");
16593
+ const perfOutputPath = join36(workDir, "perf-summary.json");
16368
16594
  const cfg = { ...job.config.producerConfig ?? resolveConfig2() };
16369
16595
  const observability = new RenderObservabilityRecorder({
16370
16596
  pipelineStartMs: pipelineStart,
@@ -16443,7 +16669,7 @@ async function executeRenderPipeline(input) {
16443
16669
  job.startedAt = /* @__PURE__ */ new Date();
16444
16670
  assertNotAborted();
16445
16671
  assertConfiguredFfmpegBinariesExist();
16446
- if (!existsSync22(workDir)) mkdirSync13(workDir, { recursive: true });
16672
+ if (!existsSync22(workDir)) mkdirSync14(workDir, { recursive: true });
16447
16673
  if (job.config.debug) {
16448
16674
  log.info("[Render] Debug artifacts enabled", { workDir, logPath });
16449
16675
  }
@@ -16472,7 +16698,7 @@ async function executeRenderPipeline(input) {
16472
16698
  requestedWorkers: job.config.workers ?? "auto"
16473
16699
  });
16474
16700
  const entryFile = job.config.entryFile || "index.html";
16475
- const htmlPath = join35(projectDir, entryFile);
16701
+ const htmlPath = join36(projectDir, entryFile);
16476
16702
  if (!existsSync22(htmlPath)) {
16477
16703
  throw new Error(`Entry file not found: ${htmlPath}`);
16478
16704
  }
@@ -16570,7 +16796,7 @@ async function executeRenderPipeline(input) {
16570
16796
  const largerThanCanvas = await oversizedVideos(
16571
16797
  composition.videos,
16572
16798
  projectDir,
16573
- join35(workDir, "compiled"),
16799
+ join36(workDir, "compiled"),
16574
16800
  { width: outputWidth, height: outputHeight }
16575
16801
  );
16576
16802
  const probeResult = await observeRenderStage(
@@ -16670,7 +16896,7 @@ async function executeRenderPipeline(input) {
16670
16896
  canvas: { width, height },
16671
16897
  page: probeSession.page,
16672
16898
  projectDir,
16673
- compiledDir: join35(workDir, "compiled")
16899
+ compiledDir: join36(workDir, "compiled")
16674
16900
  });
16675
16901
  if (videoLayerPlan.videoId === void 0) {
16676
16902
  log.info(`[Render] Video layer passthrough off: ${videoLayerPlan.reason}`);
@@ -16688,7 +16914,7 @@ async function executeRenderPipeline(input) {
16688
16914
  updateJobStatus(job, "preprocessing", "Extracting video frames", 10, onProgress, {
16689
16915
  code: "extract_video"
16690
16916
  });
16691
- const compiledDir = join35(workDir, "compiled");
16917
+ const compiledDir = join36(workDir, "compiled");
16692
16918
  const segmentsCapture = (layeredOrEffectRoute) => shouldSegmentCapture({
16693
16919
  env: process.env,
16694
16920
  durationSeconds: probeResult.duration,
@@ -16830,7 +17056,7 @@ async function executeRenderPipeline(input) {
16830
17056
  try {
16831
17057
  fileServer = await createFileServer({
16832
17058
  projectDir,
16833
- compiledDir: join35(workDir, "compiled"),
17059
+ compiledDir: join36(workDir, "compiled"),
16834
17060
  port: 0,
16835
17061
  preHeadScripts: [VIRTUAL_TIME_SHIM],
16836
17062
  fps: job.config.fps,
@@ -16850,8 +17076,8 @@ async function executeRenderPipeline(input) {
16850
17076
  if (!activeFileServer) {
16851
17077
  throw new Error("File server failed to initialize before frame capture");
16852
17078
  }
16853
- const framesDir = join35(workDir, "captured-frames");
16854
- if (!existsSync22(framesDir)) mkdirSync13(framesDir, { recursive: true });
17079
+ const framesDir = join36(workDir, "captured-frames");
17080
+ if (!existsSync22(framesDir)) mkdirSync14(framesDir, { recursive: true });
16855
17081
  updateJobStatus(job, "rendering", "Checking browser GPU", 25, onProgress, {
16856
17082
  code: "start_browsers"
16857
17083
  });
@@ -17230,7 +17456,7 @@ async function executeRenderPipeline(input) {
17230
17456
  softwareOutcome = await runCaptureCalibration({
17231
17457
  ...calibrationInput,
17232
17458
  cfg: calibrationCaptureConfig({ ...cfg, browserGpuMode: "software" }),
17233
- workDir: join35(workDir, "software-gpu"),
17459
+ workDir: join36(workDir, "software-gpu"),
17234
17460
  forceScreenshot: applyConcreteGpuScreenshotClamp(
17235
17461
  captureForceScreenshot,
17236
17462
  "software",
@@ -17517,7 +17743,7 @@ async function executeRenderPipeline(input) {
17517
17743
  hls: ".mp4"
17518
17744
  };
17519
17745
  const videoExt = FORMAT_EXT[outputFormat] ?? ".mp4";
17520
- const videoOnlyPath = join35(workDir, `video-only${videoExt}`);
17746
+ const videoOnlyPath = join36(workDir, `video-only${videoExt}`);
17521
17747
  let usePageSideCompositingForTransitions = (cfg.enablePageSideCompositing || isGif) && compiled.hasShaderTransitions && !hasHdrContent && outputSupportsPageSideShaderCompositing(outputFormat);
17522
17748
  if (usePageSideCompositingForTransitions) {
17523
17749
  activeFileServer.addPreHeadScript(HF_PAGE_SIDE_COMPOSITING_STUB);
@@ -18274,7 +18500,7 @@ async function executeRenderPipeline(input) {
18274
18500
  "drawElement capture failed; retrying with a fresh screenshot session"
18275
18501
  );
18276
18502
  rmSync13(framesDir, { recursive: true, force: true });
18277
- mkdirSync13(framesDir, { recursive: true });
18503
+ mkdirSync14(framesDir, { recursive: true });
18278
18504
  resetCaptureAttemptProgress(job);
18279
18505
  dedupPerfs.length = 0;
18280
18506
  cfg.useDrawElement = false;
@@ -18453,7 +18679,7 @@ async function executeRenderPipeline(input) {
18453
18679
  job.perfSummary = perfSummary;
18454
18680
  if (job.config.debug) {
18455
18681
  try {
18456
- writeFileSync7(perfOutputPath, JSON.stringify(perfSummary, null, 2), "utf-8");
18682
+ writeFileSync8(perfOutputPath, JSON.stringify(perfSummary, null, 2), "utf-8");
18457
18683
  } catch (err) {
18458
18684
  log.debug("Failed to write perf summary", {
18459
18685
  perfOutputPath,
@@ -18463,7 +18689,7 @@ async function executeRenderPipeline(input) {
18463
18689
  }
18464
18690
  if (job.config.debug) {
18465
18691
  if (!isPngSequence && !isHls && existsSync22(stagedOutputPath)) {
18466
- const debugOutput = join35(workDir, `output${videoExt}`);
18692
+ const debugOutput = join36(workDir, `output${videoExt}`);
18467
18693
  copyFileSync5(stagedOutputPath, debugOutput);
18468
18694
  }
18469
18695
  }
@@ -18587,7 +18813,7 @@ import {
18587
18813
  closeSync as closeSync6,
18588
18814
  constants as constants4
18589
18815
  } from "node:fs";
18590
- import { resolve as resolve11, join as join36, relative as relative6, isAbsolute as isAbsolute5, sep as sep5, dirname as dirname17 } from "node:path";
18816
+ import { resolve as resolve11, join as join37, relative as relative6, isAbsolute as isAbsolute5, sep as sep5, dirname as dirname17 } from "node:path";
18591
18817
  import { fileURLToPath as fileURLToPath6 } from "node:url";
18592
18818
  import { Worker as Worker3 } from "node:worker_threads";
18593
18819
  function isStringRecord(value) {
@@ -18659,7 +18885,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
18659
18885
  }
18660
18886
  }
18661
18887
  return {
18662
- error: `No HTML entry file found in project directory: ${join36(absProjectDir, preferredEntryFile || "index.html")}`
18888
+ error: `No HTML entry file found in project directory: ${join37(absProjectDir, preferredEntryFile || "index.html")}`
18663
18889
  };
18664
18890
  }
18665
18891
  function prepareHyperframeLintBody(body, isAllowedEntry) {
@@ -18728,7 +18954,7 @@ function freeLintSlot() {
18728
18954
  function resolveLintWorkerEntry() {
18729
18955
  const here = dirname17(fileURLToPath6(import.meta.url));
18730
18956
  for (const name of ["hyperframeLintWorker.js", "hyperframeLintWorker.ts"]) {
18731
- const candidate = join36(here, name);
18957
+ const candidate = join37(here, name);
18732
18958
  if (existsSync23(candidate)) return candidate;
18733
18959
  }
18734
18960
  return void 0;
@@ -18799,7 +19025,7 @@ async function runHyperframeLint(prepared, options = {}) {
18799
19025
  // src/services/healthWorker.ts
18800
19026
  import { Worker as Worker4 } from "node:worker_threads";
18801
19027
  import { fileURLToPath as fileURLToPath7 } from "node:url";
18802
- import { dirname as dirname18, join as join37 } from "node:path";
19028
+ import { dirname as dirname18, join as join38 } from "node:path";
18803
19029
  import { existsSync as existsSync24 } from "node:fs";
18804
19030
  var DEFAULT_HEALTH_PORT = 9848;
18805
19031
  async function startHealthWorker(options = {}) {
@@ -18875,7 +19101,7 @@ function defaultLogger2() {
18875
19101
  }
18876
19102
  function resolveWorkerEntry2() {
18877
19103
  const here = dirname18(fileURLToPath7(import.meta.url));
18878
- const candidates = [join37(here, "healthWorkerThread.js"), join37(here, "healthWorkerThread.ts")];
19104
+ const candidates = [join38(here, "healthWorkerThread.js"), join38(here, "healthWorkerThread.ts")];
18879
19105
  for (const candidate of candidates) {
18880
19106
  if (existsSync24(candidate)) return candidate;
18881
19107
  }
@@ -18917,7 +19143,7 @@ import {
18917
19143
  createReferenceBackgroundRecorder as createReferenceBackgroundRecorder2
18918
19144
  } from "@hyperframes/engine";
18919
19145
  import { audioFailureDiagnostics as audioFailureDiagnostics3 } from "@hyperframes/engine";
18920
- import { extname as extname4, isAbsolute as isAbsolute6, join as join39, relative as relative7, sep as sep6 } from "node:path";
19146
+ import { extname as extname4, isAbsolute as isAbsolute6, join as join40, relative as relative7, sep as sep6 } from "node:path";
18921
19147
  import {
18922
19148
  fpsToNumber as fpsToNumber9,
18923
19149
  HF_COLOR_GRADING_ATTR as HF_COLOR_GRADING_ATTR2
@@ -18950,7 +19176,7 @@ import {
18950
19176
 
18951
19177
  // src/services/distributed/shared.ts
18952
19178
  import { execFile as execFileCallback } from "node:child_process";
18953
- import { dirname as dirname19, join as join38 } from "node:path";
19179
+ import { dirname as dirname19, join as join39 } from "node:path";
18954
19180
  import { existsSync as existsSync25, readFileSync as readFileSync12 } from "node:fs";
18955
19181
  import { fileURLToPath as fileURLToPath8 } from "node:url";
18956
19182
  import { promisify as promisify2 } from "node:util";
@@ -18966,7 +19192,7 @@ function readProducerVersion() {
18966
19192
  const startDir = dirname19(fileURLToPath8(import.meta.url));
18967
19193
  let current = startDir;
18968
19194
  for (let i = 0; i < 10; i++) {
18969
- const candidate = join38(current, "package.json");
19195
+ const candidate = join39(current, "package.json");
18970
19196
  if (existsSync25(candidate)) {
18971
19197
  try {
18972
19198
  const pkg = JSON.parse(readFileSync12(candidate, "utf-8"));
@@ -19064,9 +19290,9 @@ var PLAN_ROOT_CATEGORY = {
19064
19290
  var PLAN_DIR_SIZE_LIMIT_BYTES = 2 * 1024 * 1024 * 1024;
19065
19291
  var FREEZE_OWNED_PLAN_FILES = [
19066
19292
  "plan.json",
19067
- join39("meta", "composition.json"),
19068
- join39("meta", "encoder.json"),
19069
- join39("meta", "chunks.json")
19293
+ join40("meta", "composition.json"),
19294
+ join40("meta", "encoder.json"),
19295
+ join40("meta", "chunks.json")
19070
19296
  ];
19071
19297
 
19072
19298
  // src/services/distributed/renderConfigValidation.ts
@@ -19503,11 +19729,11 @@ function buildRenderJobConfig(input, outputPath, log) {
19503
19729
  function resolvePreparedRenderOutput(prepared, rendersDir, log, confineOutput) {
19504
19730
  const { input, cleanupProjectDir } = prepared;
19505
19731
  const serverNamed = input.outputPath == null;
19506
- const outputCandidate = input.outputPath ?? join40(rendersDir, `${basename8(resolve12(input.projectDir))}-${crypto.randomUUID()}.mp4`);
19732
+ const outputCandidate = input.outputPath ?? join41(rendersDir, `${basename8(resolve12(input.projectDir))}-${crypto.randomUUID()}.mp4`);
19507
19733
  const absoluteOutputPath = resolveOutputPath(input.projectDir, outputCandidate, rendersDir, log);
19508
19734
  const outputDir = dirname20(absoluteOutputPath);
19509
19735
  if (confineOutput) {
19510
- mkdirSync14(rendersDir, { recursive: true, mode: SERVER_FOLDER_MODE });
19736
+ mkdirSync15(rendersDir, { recursive: true, mode: SERVER_FOLDER_MODE });
19511
19737
  if (!isSafePath4(rendersDir, absoluteOutputPath)) {
19512
19738
  throw new Error("outputPath must be inside the renders directory");
19513
19739
  }
@@ -19518,7 +19744,7 @@ function resolvePreparedRenderOutput(prepared, rendersDir, log, confineOutput) {
19518
19744
  );
19519
19745
  }
19520
19746
  }
19521
- if (!existsSync26(outputDir)) mkdirSync14(outputDir, { recursive: true, mode: SERVER_FOLDER_MODE });
19747
+ if (!existsSync26(outputDir)) mkdirSync15(outputDir, { recursive: true, mode: SERVER_FOLDER_MODE });
19522
19748
  return { input, cleanupProjectDir, absoluteOutputPath, serverNamed };
19523
19749
  }
19524
19750
  var STICKY_BIT = 512;
@@ -19629,8 +19855,8 @@ async function resolveInlineRenderHtml(body) {
19629
19855
  }
19630
19856
  function materializeInlineProject(html, options) {
19631
19857
  const tempRoot = process.env.PRODUCER_TMP_PROJECT_DIR || tmpdir4();
19632
- const tempProjectDir = mkdtempSync(join40(tempRoot, "producer-project-"));
19633
- writeFileSync8(join40(tempProjectDir, "index.html"), html, "utf-8");
19858
+ const tempProjectDir = mkdtempSync(join41(tempRoot, "producer-project-"));
19859
+ writeFileSync9(join41(tempProjectDir, "index.html"), html, "utf-8");
19634
19860
  return {
19635
19861
  prepared: {
19636
19862
  input: { projectDir: tempProjectDir, ...options },
@@ -19842,7 +20068,7 @@ function createRenderHandlers(options = {}) {
19842
20068
  const log = options.logger ?? defaultLogger;
19843
20069
  const getRequestId = options.getRequestId ?? ((c) => c.req.header("x-request-id") || crypto.randomUUID());
19844
20070
  const outputUrlPrefix = options.outputUrlPrefix ?? "/outputs";
19845
- const rendersDir = options.rendersDir ?? process.env.PRODUCER_RENDERS_DIR ?? mkdtempSync(join40(tmpdir4(), "hyperframes-renders-"));
20071
+ const rendersDir = options.rendersDir ?? process.env.PRODUCER_RENDERS_DIR ?? mkdtempSync(join41(tmpdir4(), "hyperframes-renders-"));
19846
20072
  const policy = options.confineRequests ? resolveRenderRequestPolicy(options) : void 0;
19847
20073
  const artifactTtlMs = options.artifactTtlMs ?? Number(process.env.PRODUCER_OUTPUT_ARTIFACT_TTL_MS || 15 * 60 * 1e3);
19848
20074
  const store = createArtifactStore(artifactTtlMs, log);
@@ -20220,12 +20446,12 @@ function serverAuth(options, hostname2, port) {
20220
20446
  );
20221
20447
  }
20222
20448
  const file = resolve12(
20223
- options.authTokenFile?.trim() || process.env.PRODUCER_AUTH_TOKEN_FILE?.trim() || join40(homedir(), ".hyperframes", "producer", `${port}.token`)
20449
+ options.authTokenFile?.trim() || process.env.PRODUCER_AUTH_TOKEN_FILE?.trim() || join41(homedir(), ".hyperframes", "producer", `${port}.token`)
20224
20450
  );
20225
20451
  const token = crypto.randomBytes(32).toString("base64url");
20226
- mkdirSync14(dirname20(file), { recursive: true, mode: 448 });
20452
+ mkdirSync15(dirname20(file), { recursive: true, mode: 448 });
20227
20453
  rmSync14(file, { force: true });
20228
- writeFileSync8(file, `${token}
20454
+ writeFileSync9(file, `${token}
20229
20455
  `, { flag: "wx", mode: 384 });
20230
20456
  return { token, generatedFile: file };
20231
20457
  }