@hyperframes/producer 0.9.67 → 0.9.68

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
@@ -13,7 +13,7 @@ import {
13
13
  mkdirSync as mkdirSync12,
14
14
  readdirSync as readdirSync6,
15
15
  rmSync as rmSync12,
16
- statSync as statSync11,
16
+ statSync as statSync10,
17
17
  writeFileSync as writeFileSync7,
18
18
  copyFileSync as copyFileSync5,
19
19
  appendFileSync
@@ -360,7 +360,7 @@ import {
360
360
  referenceBackgroundResult,
361
361
  createReferenceBackgroundRecorder
362
362
  } from "@hyperframes/engine";
363
- import { join as join33, dirname as dirname14, resolve as resolve9 } from "path";
363
+ import { join as join34, dirname as dirname14, resolve as resolve9 } from "path";
364
364
  import { totalmem as totalmem2 } from "node:os";
365
365
  import { randomUUID } from "crypto";
366
366
  import { fileURLToPath as fileURLToPath4 } from "url";
@@ -2593,8 +2593,8 @@ function replanAfterFailure(plan2, failure) {
2593
2593
  }
2594
2594
 
2595
2595
  // src/services/render/stages/captureSegmentedStage.ts
2596
- import { existsSync as existsSync7, mkdirSync as mkdirSync3, rmSync as rmSync6, statSync as statSync4 } from "node:fs";
2597
- import { join as join10 } from "node:path";
2596
+ import { existsSync as existsSync8, mkdirSync as mkdirSync4, rmSync as rmSync6, statSync as statSync4 } from "node:fs";
2597
+ import { join as join12 } from "node:path";
2598
2598
  import {
2599
2599
  captureFrameToBuffer as captureFrameToBuffer2,
2600
2600
  closeCaptureSession as closeCaptureSession2,
@@ -4281,6 +4281,7 @@ function cleanupEndedHdrVideos(args) {
4281
4281
  }
4282
4282
 
4283
4283
  // src/services/render/segmentPlan.ts
4284
+ import { join as join9 } from "node:path";
4284
4285
  var DEFAULT_SEGMENT_FRAMES = 3e3;
4285
4286
  var MIN_SEGMENT_FRAMES = 30;
4286
4287
  function assertPositiveInteger(name, value) {
@@ -4301,6 +4302,9 @@ function planSegments(totalFrames, segmentFrames) {
4301
4302
  }
4302
4303
  return slices;
4303
4304
  }
4305
+ function segmentOutputPath(segmentDir, index) {
4306
+ return join9(segmentDir, `segment_${String(index).padStart(5, "0")}.mp4`);
4307
+ }
4304
4308
  function resolveSegmentFrames(env) {
4305
4309
  const raw = env.HF_SEGMENT_FRAMES;
4306
4310
  if (raw === void 0 || raw.trim() === "") return DEFAULT_SEGMENT_FRAMES;
@@ -4318,6 +4322,144 @@ function createSegmentQueue(slices) {
4318
4322
  };
4319
4323
  }
4320
4324
 
4325
+ // src/services/render/segmentManifest.ts
4326
+ import { createHash as createHash2, createHmac, timingSafeEqual } from "node:crypto";
4327
+ import {
4328
+ createReadStream as createReadStream2,
4329
+ existsSync as existsSync7,
4330
+ lstatSync as lstatSync3,
4331
+ mkdirSync as mkdirSync3,
4332
+ readFileSync as readFileSync4,
4333
+ writeFileSync as writeFileSync3
4334
+ } from "node:fs";
4335
+ import { join as join10 } from "node:path";
4336
+ import { previewToken } from "@hyperframes/core/preview-proof";
4337
+ import { renameWithRetry as renameWithRetry2 } from "@hyperframes/engine";
4338
+ var MANIFEST_FILENAME = "segments.json";
4339
+ function computeSegmentPlanHash(input) {
4340
+ const ordered = [
4341
+ input.compositionHash,
4342
+ input.cliVersion,
4343
+ String(input.totalFrames),
4344
+ String(input.segmentFrames),
4345
+ `${input.fps.num}/${input.fps.den}`,
4346
+ `${input.width}x${input.height}`,
4347
+ input.codec,
4348
+ input.preset,
4349
+ input.quality === void 0 ? "" : String(input.quality),
4350
+ input.bitrate ?? "",
4351
+ input.pixelFormat ?? "",
4352
+ input.imageFormat,
4353
+ input.useGpu ? "gpu" : "cpu",
4354
+ `${input.outputWidth}x${input.outputHeight}`,
4355
+ input.motionBlur,
4356
+ input.pageMotionBlur ?? "",
4357
+ input.captureQuality === void 0 ? "" : String(input.captureQuality)
4358
+ ];
4359
+ const delivery = [input.maxBitrate, input.bufferSize, input.gopSize].map((v) => v ?? "");
4360
+ if (delivery.some((v) => v !== "")) ordered.push(...delivery.map(String));
4361
+ return createHash2("sha256").update(ordered.join(" ")).digest("hex").slice(0, 16);
4362
+ }
4363
+ function segmentDirFor(projectRendersDir, planHash) {
4364
+ return join10(projectRendersDir, ".hf-segments", planHash);
4365
+ }
4366
+ function hasNumber(value, key) {
4367
+ return key in value && typeof Reflect.get(value, key) === "number";
4368
+ }
4369
+ function hasString(value, key) {
4370
+ return key in value && typeof Reflect.get(value, key) === "string";
4371
+ }
4372
+ function isEntry(value) {
4373
+ if (typeof value !== "object" || value === null) return false;
4374
+ return hasNumber(value, "index") && hasNumber(value, "startFrame") && hasNumber(value, "endFrame") && hasString(value, "path") && hasNumber(value, "bytes") && hasString(value, "sha256") && hasString(value, "completedAt");
4375
+ }
4376
+ function isManifest(value) {
4377
+ if (typeof value !== "object" || value === null) return false;
4378
+ const completed = Reflect.get(value, "completed");
4379
+ return Reflect.get(value, "version") === 1 && hasString(value, "planHash") && hasNumber(value, "totalFrames") && hasNumber(value, "segmentFrames") && Array.isArray(completed) && completed.every(isEntry);
4380
+ }
4381
+ function readSegmentManifest(segmentDir) {
4382
+ const path = join10(segmentDir, MANIFEST_FILENAME);
4383
+ if (!existsSync7(path)) return null;
4384
+ try {
4385
+ const parsed = JSON.parse(readFileSync4(path, "utf-8"));
4386
+ return isManifest(parsed) ? parsed : null;
4387
+ } catch {
4388
+ return null;
4389
+ }
4390
+ }
4391
+ function segmentManifestKey(token = previewToken()) {
4392
+ return token ? createHmac("sha256", token).update("segment-manifest").digest() : null;
4393
+ }
4394
+ function manifestMac(manifest, key) {
4395
+ const signed = [
4396
+ manifest.planHash,
4397
+ manifest.totalFrames,
4398
+ manifest.segmentFrames,
4399
+ manifest.completed.map((e) => [e.index, e.startFrame, e.endFrame, e.bytes, e.sha256])
4400
+ ];
4401
+ return createHmac("sha256", key).update(JSON.stringify(signed)).digest("hex");
4402
+ }
4403
+ function signSegmentManifest(manifest, key) {
4404
+ const { version, planHash, totalFrames, segmentFrames, completed } = manifest;
4405
+ const unsigned = { version, planHash, totalFrames, segmentFrames, completed };
4406
+ return key ? { ...unsigned, mac: manifestMac(unsigned, key) } : unsigned;
4407
+ }
4408
+ function hasValidMac(manifest, key) {
4409
+ if (!key || typeof manifest.mac !== "string") return false;
4410
+ const expected = Buffer.from(manifestMac(manifest, key), "hex");
4411
+ const actual = Buffer.from(manifest.mac, "hex");
4412
+ return actual.length === expected.length && timingSafeEqual(actual, expected);
4413
+ }
4414
+ async function hashSegmentFile(path) {
4415
+ const hash = createHash2("sha256");
4416
+ for await (const chunk of createReadStream2(path)) hash.update(chunk);
4417
+ return hash.digest("hex");
4418
+ }
4419
+ function writeSegmentManifest(segmentDir, manifest, key) {
4420
+ mkdirSync3(segmentDir, { recursive: true });
4421
+ const tmp = join10(segmentDir, `${MANIFEST_FILENAME}.${process.pid}.tmp`);
4422
+ writeFileSync3(tmp, JSON.stringify(signSegmentManifest(manifest, key), null, 2), "utf-8");
4423
+ renameWithRetry2(tmp, join10(segmentDir, MANIFEST_FILENAME));
4424
+ }
4425
+ async function probeSegmentFrameCount(path, probe) {
4426
+ try {
4427
+ const meta = await probe(path);
4428
+ if (!Number.isFinite(meta.videoStreamDurationSeconds) || !Number.isFinite(meta.fps))
4429
+ return null;
4430
+ if (meta.fps <= 0) return null;
4431
+ return Math.round(meta.videoStreamDurationSeconds * meta.fps);
4432
+ } catch {
4433
+ return null;
4434
+ }
4435
+ }
4436
+ function plannedSlice(entry, plan2) {
4437
+ const slice = Number.isInteger(entry.index) ? plan2[entry.index] : void 0;
4438
+ if (!slice || slice.startFrame !== entry.startFrame || slice.endFrame !== entry.endFrame) {
4439
+ return void 0;
4440
+ }
4441
+ return slice;
4442
+ }
4443
+ function isPlainFileOfSize(path, bytes) {
4444
+ const stat = lstatSync3(path, { throwIfNoEntry: false });
4445
+ return stat !== void 0 && stat.isFile() && stat.size > 0 && stat.size === bytes;
4446
+ }
4447
+ async function validateCompletedSegments(manifest, check) {
4448
+ const ok = /* @__PURE__ */ new Set();
4449
+ if (manifest.planHash !== check.expectedHash || !hasValidMac(manifest, check.key)) return ok;
4450
+ for (const entry of manifest.completed) {
4451
+ const slice = plannedSlice(entry, check.plan);
4452
+ if (!slice) continue;
4453
+ const path = segmentOutputPath(check.segmentDir, slice.index);
4454
+ if (!isPlainFileOfSize(path, entry.bytes)) continue;
4455
+ if (await hashSegmentFile(path) !== entry.sha256) continue;
4456
+ const frames = await check.probeFrames(path);
4457
+ if (frames !== slice.endFrame - slice.startFrame) continue;
4458
+ ok.add(slice.index);
4459
+ }
4460
+ return ok;
4461
+ }
4462
+
4321
4463
  // src/services/render/segmentRecycle.ts
4322
4464
  var DEFAULT_SEGMENT_BROWSER_RECYCLE = 3;
4323
4465
  function resolveSegmentBrowserRecycle(env) {
@@ -4335,7 +4477,7 @@ function isTargetLossError(error) {
4335
4477
  // src/services/render/stages/captureStreamingStage.ts
4336
4478
  import { mkdtemp, writeFile } from "node:fs/promises";
4337
4479
  import { tmpdir as tmpdir2 } from "node:os";
4338
- import { join as join9 } from "node:path";
4480
+ import { join as join11 } from "node:path";
4339
4481
  import {
4340
4482
  DrawElementVerificationError,
4341
4483
  captureFrameToBuffer,
@@ -4558,11 +4700,11 @@ async function verifyDrawElementSample(session, idx, buf, ctx) {
4558
4700
  return;
4559
4701
  }
4560
4702
  if (db < verifyMinDb) {
4561
- const dumpDir = await mkdtemp(join9(tmpdir2(), "hf-de-verify-fail-")).catch(() => null);
4703
+ const dumpDir = await mkdtemp(join11(tmpdir2(), "hf-de-verify-fail-")).catch(() => null);
4562
4704
  if (dumpDir) {
4563
4705
  await Promise.all([
4564
- writeFile(join9(dumpDir, `frame-${idx}-de.jpg`), buf),
4565
- writeFile(join9(dumpDir, `frame-${idx}-truth.jpg`), truth)
4706
+ writeFile(join11(dumpDir, `frame-${idx}-de.jpg`), buf),
4707
+ writeFile(join11(dumpDir, `frame-${idx}-truth.jpg`), truth)
4566
4708
  ]).catch(() => {
4567
4709
  });
4568
4710
  }
@@ -5132,9 +5274,6 @@ async function runCaptureStreamingStage(input) {
5132
5274
  }
5133
5275
 
5134
5276
  // src/services/render/stages/captureSegmentedStage.ts
5135
- function segmentOutputPath(segmentDir, index) {
5136
- return join10(segmentDir, `segment_${String(index).padStart(5, "0")}.mp4`);
5137
- }
5138
5277
  function segmentEncoderOptions(base, segment) {
5139
5278
  return {
5140
5279
  ...base,
@@ -5232,7 +5371,8 @@ async function captureSegmentToEncoder(ctx, segment) {
5232
5371
  path: segmentPath,
5233
5372
  // Recorded so resume can prove the file on disk is the one that
5234
5373
  // finished; absent only in unit tests, whose fake encoder writes none.
5235
- bytes: existsSync7(segmentPath) ? statSync4(segmentPath).size : 0
5374
+ bytes: existsSync8(segmentPath) ? statSync4(segmentPath).size : 0,
5375
+ sha256: existsSync8(segmentPath) ? await hashSegmentFile(segmentPath) : ""
5236
5376
  });
5237
5377
  return encodeResult;
5238
5378
  } finally {
@@ -5466,8 +5606,8 @@ async function runCaptureSegmentedStage(input) {
5466
5606
  const { log, dedupPerfs, assertNotAborted } = input;
5467
5607
  const deps = { ...DEFAULT_DEPS, ...input.deps };
5468
5608
  const segments = planSegments(input.totalFrames, input.segmentFrames);
5469
- const segmentDir = input.segmentDir ?? join10(input.workDir, "segments");
5470
- mkdirSync3(segmentDir, { recursive: true });
5609
+ const segmentDir = input.segmentDir ?? join12(input.workDir, "segments");
5610
+ mkdirSync4(segmentDir, { recursive: true });
5471
5611
  const skip = input.completedSegments ?? /* @__PURE__ */ new Set();
5472
5612
  const pending = segments.filter((s) => !skip.has(s.index));
5473
5613
  for (const index of skip) log.info("[Render] segment skipped (resume)", { index });
@@ -5622,7 +5762,7 @@ function startRenderEtaGuard(options) {
5622
5762
  }
5623
5763
 
5624
5764
  // src/services/render/captureCost.ts
5625
- import { join as join11 } from "node:path";
5765
+ import { join as join13 } from "node:path";
5626
5766
  import { fpsToNumber as fpsToNumber4 } from "@hyperframes/core";
5627
5767
  import {
5628
5768
  calculateOptimalWorkers,
@@ -5875,7 +6015,7 @@ async function runCaptureCalibration(input) {
5875
6015
  });
5876
6016
  let calibration;
5877
6017
  try {
5878
- calibration = await runOneCalibration(join11(workDir, "capture-calibration"), calibrationCfg);
6018
+ calibration = await runOneCalibration(join13(workDir, "capture-calibration"), calibrationCfg);
5879
6019
  } catch (error) {
5880
6020
  const shouldFallback = !forceScreenshot && shouldFallbackToScreenshotAfterCalibrationError(error);
5881
6021
  if (!shouldFallback) {
@@ -5909,7 +6049,7 @@ async function runCaptureCalibration(input) {
5909
6049
  const screenshotCfg = createCaptureCalibrationConfig({ ...cfg, forceScreenshot: true });
5910
6050
  try {
5911
6051
  calibration = await runOneCalibration(
5912
- join11(workDir, "capture-calibration-screenshot"),
6052
+ join13(workDir, "capture-calibration-screenshot"),
5913
6053
  screenshotCfg
5914
6054
  );
5915
6055
  } catch (fallbackError) {
@@ -5973,8 +6113,8 @@ function checkPageNeverReady(input) {
5973
6113
  }
5974
6114
 
5975
6115
  // src/services/render/deferredVideoFrames.ts
5976
- import { mkdirSync as mkdirSync4, rmSync as rmSync7 } from "node:fs";
5977
- import { dirname as dirname5, join as join12 } from "node:path";
6116
+ import { mkdirSync as mkdirSync5, rmSync as rmSync7 } from "node:fs";
6117
+ import { dirname as dirname5, join as join14 } from "node:path";
5978
6118
  import {
5979
6119
  createFrameLookupTable,
5980
6120
  extractVideoFramesRange,
@@ -6019,7 +6159,7 @@ async function extractDeferredFrames(input) {
6019
6159
  const shown = shownDeferredFrameIndexes(input, input.frames, input.fps);
6020
6160
  return Promise.all(
6021
6161
  deferred.map(async (video) => {
6022
- const outputDir = join12(input.outputRoot, mediaIdPathSegment2(video.videoId));
6162
+ const outputDir = join14(input.outputRoot, mediaIdPathSegment2(video.videoId));
6023
6163
  const indexes = [...shown.get(video.videoId) ?? []].sort((a, b) => a - b);
6024
6164
  if (indexes.length === 0) {
6025
6165
  return { ...video, outputDir, framePaths: /* @__PURE__ */ new Map(), ownedByLookup: false };
@@ -6075,7 +6215,7 @@ async function extractAllDeferredFrames(extracted, input) {
6075
6215
  maxTransientRetries: input.maxTransientRetries,
6076
6216
  onRetry: () => {
6077
6217
  rmSync7(video.outputDir, { recursive: true, force: true });
6078
- mkdirSync4(video.outputDir, { recursive: true });
6218
+ mkdirSync5(video.outputDir, { recursive: true });
6079
6219
  }
6080
6220
  }
6081
6221
  );
@@ -6166,14 +6306,14 @@ async function measureLocalShownBoxes(page, videos, fps, duration, log) {
6166
6306
  }
6167
6307
 
6168
6308
  // src/services/render/segmentVideoFrames.ts
6169
- import { mkdirSync as mkdirSync5, rmSync as rmSync8 } from "node:fs";
6170
- import { join as join13 } from "node:path";
6309
+ import { mkdirSync as mkdirSync6, rmSync as rmSync8 } from "node:fs";
6310
+ import { join as join15 } from "node:path";
6171
6311
  import {
6172
6312
  createFrameLookupTable as createFrameLookupTable2,
6173
6313
  createVideoFrameInjector
6174
6314
  } from "@hyperframes/engine";
6175
6315
  function segmentFramesDir(rootDir, index) {
6176
- return join13(rootDir, "segment-frames", `segment_${String(index).padStart(5, "0")}`);
6316
+ return join15(rootDir, "segment-frames", `segment_${String(index).padStart(5, "0")}`);
6177
6317
  }
6178
6318
  function createSegmentVideoFrames(input) {
6179
6319
  const extractFrames = input.extractFrames ?? extractDeferredFrames;
@@ -6204,7 +6344,7 @@ function createSegmentVideoFrames(input) {
6204
6344
  let onDemandCalls = 0;
6205
6345
  const onDemandHook = () => Object.assign(
6206
6346
  async (page, time, heldVideoTime) => {
6207
- const dir = join13(
6347
+ const dir = join15(
6208
6348
  input.rootDir,
6209
6349
  "segment-frames",
6210
6350
  `on-demand_${String(onDemandCalls++).padStart(5, "0")}`
@@ -6221,11 +6361,11 @@ function createSegmentVideoFrames(input) {
6221
6361
  );
6222
6362
  return {
6223
6363
  async forFrames(frames, name) {
6224
- const dir = join13(input.rootDir, "segment-frames", name);
6364
+ const dir = join15(input.rootDir, "segment-frames", name);
6225
6365
  const release = () => rmSync8(dir, { recursive: true, force: true });
6226
6366
  try {
6227
6367
  release();
6228
- mkdirSync5(dir, { recursive: true });
6368
+ mkdirSync6(dir, { recursive: true });
6229
6369
  const table = await tableFor([...frames], dir);
6230
6370
  return { injector: () => createVideoFrameInjector(table, input.injectorOptions), release };
6231
6371
  } catch (error) {
@@ -6254,7 +6394,7 @@ function createSegmentVideoFrames(input) {
6254
6394
  folder = dir;
6255
6395
  try {
6256
6396
  rmSync8(dir, { recursive: true, force: true });
6257
- mkdirSync5(dir, { recursive: true });
6397
+ mkdirSync6(dir, { recursive: true });
6258
6398
  injector = await injectorFor(
6259
6399
  Array.from(
6260
6400
  { length: segment.endFrame - segment.startFrame },
@@ -6274,7 +6414,7 @@ function createSegmentVideoFrames(input) {
6274
6414
 
6275
6415
  // src/services/render/videoFrameWindow.ts
6276
6416
  import { readdirSync as readdirSync3, statSync as statSync5 } from "node:fs";
6277
- import { join as join14 } from "node:path";
6417
+ import { join as join16 } from "node:path";
6278
6418
  function shouldWindowVideoFrames(args) {
6279
6419
  return args.segmented && args.env.HF_VIDEO_FRAME_WINDOW?.trim().toLowerCase() === "true";
6280
6420
  }
@@ -6287,7 +6427,7 @@ function directoryBytes(path) {
6287
6427
  return 0;
6288
6428
  }
6289
6429
  for (const entry of entries) {
6290
- const child3 = join14(path, entry.name);
6430
+ const child3 = join16(path, entry.name);
6291
6431
  try {
6292
6432
  bytes += entry.isDirectory() ? directoryBytes(child3) : statSync5(child3).size;
6293
6433
  } catch {
@@ -6305,7 +6445,7 @@ function trackSegmentFramePeak(frames, rootDir, onPeak) {
6305
6445
  ...worker,
6306
6446
  async prepare(segment) {
6307
6447
  await worker.prepare(segment);
6308
- const held = directoryBytes(join14(rootDir, "segment-frames"));
6448
+ const held = directoryBytes(join16(rootDir, "segment-frames"));
6309
6449
  if (held > peak) {
6310
6450
  peak = held;
6311
6451
  onPeak(peak);
@@ -6316,95 +6456,6 @@ function trackSegmentFramePeak(frames, rootDir, onPeak) {
6316
6456
  };
6317
6457
  }
6318
6458
 
6319
- // src/services/render/segmentManifest.ts
6320
- import { createHash as createHash2 } from "node:crypto";
6321
- import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync4, statSync as statSync6, writeFileSync as writeFileSync3 } from "node:fs";
6322
- import { join as join15 } from "node:path";
6323
- import { renameWithRetry as renameWithRetry2 } from "@hyperframes/engine";
6324
- var MANIFEST_FILENAME = "segments.json";
6325
- function computeSegmentPlanHash(input) {
6326
- const ordered = [
6327
- input.compositionHash,
6328
- input.cliVersion,
6329
- String(input.totalFrames),
6330
- String(input.segmentFrames),
6331
- `${input.fps.num}/${input.fps.den}`,
6332
- `${input.width}x${input.height}`,
6333
- input.codec,
6334
- input.preset,
6335
- input.quality === void 0 ? "" : String(input.quality),
6336
- input.bitrate ?? "",
6337
- input.pixelFormat ?? "",
6338
- input.imageFormat,
6339
- input.useGpu ? "gpu" : "cpu",
6340
- `${input.outputWidth}x${input.outputHeight}`,
6341
- input.motionBlur,
6342
- input.pageMotionBlur ?? "",
6343
- input.captureQuality === void 0 ? "" : String(input.captureQuality)
6344
- ];
6345
- const delivery = [input.maxBitrate, input.bufferSize, input.gopSize].map((v) => v ?? "");
6346
- if (delivery.some((v) => v !== "")) ordered.push(...delivery.map(String));
6347
- return createHash2("sha256").update(ordered.join(" ")).digest("hex").slice(0, 16);
6348
- }
6349
- function segmentDirFor(projectRendersDir, planHash) {
6350
- return join15(projectRendersDir, ".hf-segments", planHash);
6351
- }
6352
- function hasNumber(value, key) {
6353
- return key in value && typeof Reflect.get(value, key) === "number";
6354
- }
6355
- function hasString(value, key) {
6356
- return key in value && typeof Reflect.get(value, key) === "string";
6357
- }
6358
- function isEntry(value) {
6359
- if (typeof value !== "object" || value === null) return false;
6360
- return hasNumber(value, "index") && hasNumber(value, "startFrame") && hasNumber(value, "endFrame") && hasString(value, "path") && hasNumber(value, "bytes") && hasString(value, "completedAt");
6361
- }
6362
- function isManifest(value) {
6363
- if (typeof value !== "object" || value === null) return false;
6364
- const completed = Reflect.get(value, "completed");
6365
- return Reflect.get(value, "version") === 1 && hasString(value, "planHash") && hasNumber(value, "totalFrames") && hasNumber(value, "segmentFrames") && Array.isArray(completed) && completed.every(isEntry);
6366
- }
6367
- function readSegmentManifest(segmentDir) {
6368
- const path = join15(segmentDir, MANIFEST_FILENAME);
6369
- if (!existsSync8(path)) return null;
6370
- try {
6371
- const parsed = JSON.parse(readFileSync4(path, "utf-8"));
6372
- return isManifest(parsed) ? parsed : null;
6373
- } catch {
6374
- return null;
6375
- }
6376
- }
6377
- function writeSegmentManifest(segmentDir, manifest) {
6378
- mkdirSync6(segmentDir, { recursive: true });
6379
- const tmp = join15(segmentDir, `${MANIFEST_FILENAME}.${process.pid}.tmp`);
6380
- writeFileSync3(tmp, JSON.stringify(manifest, null, 2), "utf-8");
6381
- renameWithRetry2(tmp, join15(segmentDir, MANIFEST_FILENAME));
6382
- }
6383
- async function probeSegmentFrameCount(path, probe) {
6384
- try {
6385
- const meta = await probe(path);
6386
- if (!Number.isFinite(meta.videoStreamDurationSeconds) || !Number.isFinite(meta.fps))
6387
- return null;
6388
- if (meta.fps <= 0) return null;
6389
- return Math.round(meta.videoStreamDurationSeconds * meta.fps);
6390
- } catch {
6391
- return null;
6392
- }
6393
- }
6394
- async function validateCompletedSegments(manifest, expectedHash, probeFrames) {
6395
- const ok = /* @__PURE__ */ new Set();
6396
- if (manifest.planHash !== expectedHash) return ok;
6397
- for (const entry of manifest.completed) {
6398
- if (!existsSync8(entry.path)) continue;
6399
- const size = statSync6(entry.path).size;
6400
- if (size <= 0 || size !== entry.bytes) continue;
6401
- const frames = await probeFrames(entry.path);
6402
- if (frames !== entry.endFrame - entry.startFrame) continue;
6403
- ok.add(entry.index);
6404
- }
6405
- return ok;
6406
- }
6407
-
6408
6459
  // src/services/render/hdrMode.ts
6409
6460
  import {
6410
6461
  analyzeCompositionHdr,
@@ -7001,14 +7052,14 @@ function requireOutputDimensions(expected, width, height) {
7001
7052
 
7002
7053
  // src/services/render/stages/compileStage.ts
7003
7054
  import { existsSync as existsSync13, writeFileSync as writeFileSync5 } from "node:fs";
7004
- import { join as join21, relative as relative4 } from "node:path";
7055
+ import { join as join22, relative as relative4 } from "node:path";
7005
7056
  import { privateCacheRoot } from "@hyperframes/engine";
7006
7057
  import { suggestMatchingPreset } from "@hyperframes/core";
7007
7058
  import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
7008
7059
  import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolution";
7009
7060
 
7010
7061
  // src/services/compositionSizeLimit.ts
7011
- import { statSync as statSync7 } from "node:fs";
7062
+ import { statSync as statSync6 } from "node:fs";
7012
7063
  var MAX_COMPOSITION_HTML_BYTES = 16 * 1024 * 1024;
7013
7064
  var COMPOSITION_TOO_LARGE = "COMPOSITION_TOO_LARGE";
7014
7065
  var megabytes = (bytes) => `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
@@ -7084,7 +7135,7 @@ var CompositionExpansionBudget = class {
7084
7135
  function assertCompositionFileSize(path, file) {
7085
7136
  let bytes;
7086
7137
  try {
7087
- const stats = statSync7(path);
7138
+ const stats = statSync6(path);
7088
7139
  if (!stats.isFile()) return;
7089
7140
  bytes = stats.size;
7090
7141
  } catch {
@@ -7109,19 +7160,19 @@ import {
7109
7160
  stylesheetLinkMatches
7110
7161
  } from "@hyperframes/parsers/css-url-scans";
7111
7162
  import { createHash as createHash6 } from "node:crypto";
7112
- import { createReadStream as createReadStream2, existsSync as existsSync12, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
7113
- import { join as join20, dirname as dirname9, resolve as resolve8, basename as basename6, relative as relative3, sep as sep4 } from "path";
7163
+ import { createReadStream as createReadStream3, existsSync as existsSync12, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
7164
+ import { join as join21, dirname as dirname9, resolve as resolve8, basename as basename6, relative as relative3, sep as sep4 } from "path";
7114
7165
  import { parseHTML as parseHTML5 } from "linkedom";
7115
7166
 
7116
7167
  // src/services/bundledScripts.ts
7117
7168
  import { existsSync as existsSync9, readFileSync as readFileSync5 } from "node:fs";
7118
- import { join as join16 } from "node:path";
7169
+ import { join as join17 } from "node:path";
7119
7170
  import { gsapCdnDist } from "@hyperframes/core/gsap-cdn";
7120
7171
  var GSAP_VENDOR_DIR_ENV = "HYPERFRAMES_GSAP_VENDOR_DIR";
7121
7172
  function bundledScript(url) {
7122
7173
  const dir = process.env[GSAP_VENDOR_DIR_ENV];
7123
7174
  if (!dir || url !== `${gsapCdnDist()}gsap.min.js`) return null;
7124
- const file = join16(dir, "gsap.min.js");
7175
+ const file = join17(dir, "gsap.min.js");
7125
7176
  return existsSync9(file) ? readFileSync5(file) : null;
7126
7177
  }
7127
7178
 
@@ -7380,8 +7431,8 @@ import {
7380
7431
 
7381
7432
  // src/services/animatedGifPrep.ts
7382
7433
  import { createHash as createHash4 } from "node:crypto";
7383
- import { copyFileSync as copyFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync8 } from "node:fs";
7384
- import { dirname as dirname6, isAbsolute as isAbsolute3, join as join17, resolve as resolve6 } from "node:path";
7434
+ import { copyFileSync as copyFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync7 } from "node:fs";
7435
+ import { dirname as dirname6, isAbsolute as isAbsolute3, join as join18, resolve as resolve6 } from "node:path";
7385
7436
  import { parseHTML as parseHTML3 } from "linkedom";
7386
7437
  import { parseAnimatedGifMetadata } from "@hyperframes/core";
7387
7438
  import {
@@ -7439,7 +7490,7 @@ function resolveLocalImageSourcePath(src, options) {
7439
7490
  }
7440
7491
  function isUsableFile(path) {
7441
7492
  try {
7442
- const stat = statSync8(path);
7493
+ const stat = statSync7(path);
7443
7494
  return stat.isFile() && stat.size > 0;
7444
7495
  } catch {
7445
7496
  return false;
@@ -7634,7 +7685,7 @@ function replaceImageWithVideo(input) {
7634
7685
  return video;
7635
7686
  }
7636
7687
  async function prepareAnimatedGifInputs(html, options) {
7637
- const outputDir = options.outputDir ?? join17(options.downloadDir, PREPARED_GIF_SUBDIR);
7688
+ const outputDir = options.outputDir ?? join18(options.downloadDir, PREPARED_GIF_SUBDIR);
7638
7689
  const outputSrcPrefix = normalizeRelPath(options.outputSrcPrefix ?? PREPARED_GIF_SUBDIR);
7639
7690
  const cacheDir = options.cacheDir ?? outputDir;
7640
7691
  const { document: document2 } = parseHTML3(html);
@@ -7661,8 +7712,8 @@ async function prepareAnimatedGifInputs(html, options) {
7661
7712
  );
7662
7713
  const hash = computePreparedGifHash(bytes, loopIterations, padSeconds);
7663
7714
  const filename = `${CACHE_SCHEMA}-${hash.slice(0, 24)}.webm`;
7664
- const cachePath = join17(cacheDir, filename);
7665
- const outputPath = join17(outputDir, filename);
7715
+ const cachePath = join18(cacheDir, filename);
7716
+ const outputPath = join18(outputDir, filename);
7666
7717
  const outputSrc = `${outputSrcPrefix}/${filename}`;
7667
7718
  await ensurePreparedWebm({
7668
7719
  sourcePath,
@@ -7704,10 +7755,10 @@ import {
7704
7755
  readFileSync as readFileSync7,
7705
7756
  readSync as readSync3,
7706
7757
  rmSync as rmSync10,
7707
- statSync as statSync9,
7758
+ statSync as statSync8,
7708
7759
  writeFileSync as writeFileSync4
7709
7760
  } from "node:fs";
7710
- import { dirname as dirname7, join as join18, resolve as resolve7 } from "node:path";
7761
+ import { dirname as dirname7, join as join19, resolve as resolve7 } from "node:path";
7711
7762
  import { parseHTML as parseHTML4 } from "linkedom";
7712
7763
  import { renameWithRetry as renameWithRetry4, runFfmpeg as runFfmpeg3, runFfprobe, urlInputArgs as urlInputArgs3 } from "@hyperframes/engine";
7713
7764
 
@@ -7948,7 +7999,7 @@ function resolveImageSource(src, options) {
7948
7999
  }
7949
8000
  function isUsableFile2(path) {
7950
8001
  try {
7951
- return statSync9(path).size > 0;
8002
+ return statSync8(path).size > 0;
7952
8003
  } catch {
7953
8004
  return false;
7954
8005
  }
@@ -7982,7 +8033,7 @@ async function ensurePreparedJpeg(source, cachePath, outputPath, options) {
7982
8033
  }
7983
8034
  }
7984
8035
  async function prepareHeifImageInputs(html, options) {
7985
- const outputDir = options.outputDir ?? join18(options.downloadDir, PREPARED_HEIF_SUBDIR);
8036
+ const outputDir = options.outputDir ?? join19(options.downloadDir, PREPARED_HEIF_SUBDIR);
7986
8037
  const outputSrcPrefix = normalizeRelPath(options.outputSrcPrefix ?? PREPARED_HEIF_SUBDIR);
7987
8038
  const cacheDir = options.cacheDir ?? outputDir;
7988
8039
  const preparedAssets = /* @__PURE__ */ new Map();
@@ -8003,7 +8054,7 @@ async function prepareHeifImageInputs(html, options) {
8003
8054
  await Promise.all(
8004
8055
  [...unique].map(
8005
8056
  ([filename, source]) => withMediaProbeSlot(
8006
- () => ensurePreparedJpeg(source, join18(cacheDir, filename), join18(outputDir, filename), options)
8057
+ () => ensurePreparedJpeg(source, join19(cacheDir, filename), join19(outputDir, filename), options)
8007
8058
  ).catch((error) => {
8008
8059
  if (!options.onFailure) throw error;
8009
8060
  failed.add(filename);
@@ -8015,8 +8066,8 @@ async function prepareHeifImageInputs(html, options) {
8015
8066
  if (failed.has(filename)) continue;
8016
8067
  const outputSrc = `${outputSrcPrefix}/${filename}`;
8017
8068
  img.setAttribute("src", outputSrc);
8018
- preparedAssets.set(outputSrc, join18(outputDir, filename));
8019
- preparedImages.push({ sourceSrc: src, outputSrc, outputPath: join18(outputDir, filename) });
8069
+ preparedAssets.set(outputSrc, join19(outputDir, filename));
8070
+ preparedImages.push({ sourceSrc: src, outputSrc, outputPath: join19(outputDir, filename) });
8020
8071
  }
8021
8072
  return { html: document2.toString(), preparedAssets, preparedImages };
8022
8073
  }
@@ -8027,7 +8078,7 @@ import { getPositionEditsRenderScript } from "@hyperframes/core/runtime/position
8027
8078
 
8028
8079
  // src/services/assetMediaType.ts
8029
8080
  import { existsSync as existsSync11 } from "node:fs";
8030
- import { dirname as dirname8, join as join19 } from "node:path";
8081
+ import { dirname as dirname8, join as join20 } from "node:path";
8031
8082
  import {
8032
8083
  fingerprintElementId,
8033
8084
  isHttpUrl as isHttpUrl2,
@@ -8080,11 +8131,11 @@ function assertAssetMediaTypeProfile(expected, profile, elementIdentity) {
8080
8131
  ]);
8081
8132
  }
8082
8133
  function mediaAssetRoots(projectDir, compiledDir) {
8083
- return [projectDir, compiledDir, join19(dirname8(compiledDir), "downloads")];
8134
+ return [projectDir, compiledDir, join20(dirname8(compiledDir), "downloads")];
8084
8135
  }
8085
8136
  function dropMediaOutsideProject(input) {
8086
8137
  const { projectDir, workDir, composition, log } = input;
8087
- const compiledDir = join19(workDir, "compiled");
8138
+ const compiledDir = join20(workDir, "compiled");
8088
8139
  const roots = mediaAssetRoots(projectDir, compiledDir);
8089
8140
  const staysInside = ({ id, src }) => {
8090
8141
  if (!src || isHttpUrl2(src)) return true;
@@ -8435,7 +8486,7 @@ function detectShaderTransitionUsage(html) {
8435
8486
  async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, baseDir, downloadDir, tagName, elementIdentity, log, urlByAbsentLocalPath, probes, assetRoot) {
8436
8487
  let filePath = src;
8437
8488
  if (isHttpUrl(src)) {
8438
- const remoteDir = join20(downloadDir, REMOTE_MEDIA_SUBDIR);
8489
+ const remoteDir = join21(downloadDir, REMOTE_MEDIA_SUBDIR);
8439
8490
  if (!existsSync12(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
8440
8491
  try {
8441
8492
  filePath = await downloadToTemp(src, remoteDir, void 0, void 0, void 0, {
@@ -8446,7 +8497,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, b
8446
8497
  }
8447
8498
  } else {
8448
8499
  filePath = decodedUrlPath(src);
8449
- if (!filePath.startsWith("/")) filePath = join20(baseDir, filePath);
8500
+ if (!filePath.startsWith("/")) filePath = join21(baseDir, filePath);
8450
8501
  if (escapesAssetRoot(filePath, assetRoot) || isPrivateUnderAssetRoots3(filePath, [projectDir, downloadDir])) {
8451
8502
  return { duration: null, resolvedPath: filePath };
8452
8503
  }
@@ -9180,7 +9231,7 @@ async function localizeRemoteMediaSources(html, downloadDir) {
9180
9231
  const localized = await downloadAndRewriteUrls(
9181
9232
  urlSet,
9182
9233
  html,
9183
- join20(downloadDir, REMOTE_MEDIA_SUBDIR),
9234
+ join21(downloadDir, REMOTE_MEDIA_SUBDIR),
9184
9235
  "Remote media download failed",
9185
9236
  "Localized remote media source(s)"
9186
9237
  );
@@ -9203,7 +9254,7 @@ async function localizeRemoteImageSources(html, downloadDir) {
9203
9254
  return downloadAndRewriteUrls(
9204
9255
  urlSet,
9205
9256
  html,
9206
- join20(downloadDir, REMOTE_MEDIA_SUBDIR),
9257
+ join21(downloadDir, REMOTE_MEDIA_SUBDIR),
9207
9258
  "Remote image download failed",
9208
9259
  "Localized remote image source(s)"
9209
9260
  );
@@ -9216,7 +9267,7 @@ async function localizeRemoteBackgroundImages(html, downloadDir) {
9216
9267
  return downloadAndRewriteUrls(
9217
9268
  urlSet,
9218
9269
  html,
9219
- join20(downloadDir, REMOTE_MEDIA_SUBDIR),
9270
+ join21(downloadDir, REMOTE_MEDIA_SUBDIR),
9220
9271
  "Remote background-image download failed",
9221
9272
  "Localized remote background-image(s)",
9222
9273
  // Quoted url('..')/url("..") are rewritten by downloadAndRewriteUrls' default
@@ -9372,7 +9423,7 @@ function localizeFontFaceUrls(html, downloadDir) {
9372
9423
  return downloadAndRewriteUrls(
9373
9424
  collectFontFaceUrls(html),
9374
9425
  html,
9375
- join20(downloadDir, REMOTE_MEDIA_SUBDIR),
9426
+ join21(downloadDir, REMOTE_MEDIA_SUBDIR),
9376
9427
  "Remote font download failed",
9377
9428
  "Localized remote font face(s)",
9378
9429
  (h, url, relPath) => h.replaceAll(`url(${url})`, `url("${relPath}")`)
@@ -9382,7 +9433,7 @@ var MAX_LOCAL_FONT_DATA_URI_BYTES = 5 * 1024 * 1024;
9382
9433
  async function readLocalFont(absPath) {
9383
9434
  const chunks = [];
9384
9435
  let totalBytes = 0;
9385
- for await (const chunk of createReadStream2(absPath)) {
9436
+ for await (const chunk of createReadStream3(absPath)) {
9386
9437
  const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
9387
9438
  totalBytes += buffer.length;
9388
9439
  if (totalBytes > MAX_LOCAL_FONT_DATA_URI_BYTES) {
@@ -10142,7 +10193,7 @@ async function recompileWithResolutions(compiled, resolutions, projectDir, downl
10142
10193
  function animatedGifCacheDir(extractCacheDir) {
10143
10194
  try {
10144
10195
  const root = extractCacheDir && privateCacheRoot(extractCacheDir);
10145
- return root ? join21(root, "animated-gif") : void 0;
10196
+ return root ? join22(root, "animated-gif") : void 0;
10146
10197
  } catch {
10147
10198
  return void 0;
10148
10199
  }
@@ -10170,10 +10221,10 @@ function resolveEntryHtmlPath(input) {
10170
10221
  assertCompositionFileSize(path, relative4(projectDir, path));
10171
10222
  return readTextFile2(path);
10172
10223
  };
10173
- const htmlPath = join21(projectDir, entryFile);
10224
+ const htmlPath = join22(projectDir, entryFile);
10174
10225
  const rawEntry = readEntry(htmlPath);
10175
10226
  if (entryFile === "index.html" || !isTemplateEntry(rawEntry)) return htmlPath;
10176
- const projectIndexPath = join21(projectDir, "index.html");
10227
+ const projectIndexPath = join22(projectDir, "index.html");
10177
10228
  if (!existsSync13(projectIndexPath)) {
10178
10229
  throw new Error(
10179
10230
  `Template entry file "${entryFile}" requires a project index.html to extract its render shell.`
@@ -10189,7 +10240,7 @@ function resolveEntryHtmlPath(input) {
10189
10240
  `Entry file "${entryFile}" is not mounted from index.html via data-composition-src, so it cannot be rendered independently.`
10190
10241
  );
10191
10242
  }
10192
- const wrapperPath = join21(workDir, "standalone-entry.html");
10243
+ const wrapperPath = join22(workDir, "standalone-entry.html");
10193
10244
  writeFileSync5(wrapperPath, standaloneHtml, "utf-8");
10194
10245
  log.info("Extracted standalone entry from index.html host context", { entryFile });
10195
10246
  return wrapperPath;
@@ -10219,7 +10270,7 @@ async function runCompileStage(input) {
10219
10270
  const assetRoot = job.config.allowOutsideProjectAssets ? void 0 : projectDir;
10220
10271
  const htmlPath = resolveEntryHtmlPath({ projectDir, workDir, entryFile, log, assetRoot });
10221
10272
  const compileStart = Date.now();
10222
- const compiled = await compileForRender(projectDir, htmlPath, join21(workDir, "downloads"), {
10273
+ const compiled = await compileForRender(projectDir, htmlPath, join22(workDir, "downloads"), {
10223
10274
  log,
10224
10275
  failClosedFontFetch: failClosedFontFetch === true,
10225
10276
  allowSystemFontCapture,
@@ -10294,7 +10345,7 @@ async function runCompileStage(input) {
10294
10345
  });
10295
10346
  await preflightCompositionAssetMediaTypes({
10296
10347
  projectDir,
10297
- compiledDir: join21(workDir, "compiled"),
10348
+ compiledDir: join22(workDir, "compiled"),
10298
10349
  composition,
10299
10350
  signal: abortSignal
10300
10351
  });
@@ -10342,7 +10393,7 @@ async function runCompileStage(input) {
10342
10393
 
10343
10394
  // src/services/render/stages/probeStage.ts
10344
10395
  import { createHash as createHash7 } from "node:crypto";
10345
- import { basename as basename7, join as join22 } from "node:path";
10396
+ import { basename as basename7, join as join23 } from "node:path";
10346
10397
  import { parseHTML as parseHTML6 } from "linkedom";
10347
10398
  import {
10348
10399
  closeCaptureSession as closeCaptureSession4,
@@ -10656,7 +10707,7 @@ async function runProbeStage(input) {
10656
10707
  });
10657
10708
  fileServer = await createFileServer({
10658
10709
  projectDir,
10659
- compiledDir: join22(workDir, "compiled"),
10710
+ compiledDir: join23(workDir, "compiled"),
10660
10711
  port: 0,
10661
10712
  preHeadScripts: [VIRTUAL_TIME_SHIM],
10662
10713
  fps: job.config.fps,
@@ -10693,7 +10744,7 @@ async function runProbeStage(input) {
10693
10744
  log.info("Creating capture session...", { attempt, maxAttempts: PROBE_MAX_ATTEMPTS });
10694
10745
  probeSession = await createCaptureSession4(
10695
10746
  fileServer.url,
10696
- join22(workDir, "probe"),
10747
+ join23(workDir, "probe"),
10697
10748
  captureOpts,
10698
10749
  null,
10699
10750
  probeCfg
@@ -10778,7 +10829,7 @@ async function runProbeStage(input) {
10778
10829
  });
10779
10830
  probeSession = await createCaptureSession4(
10780
10831
  fileServer.url,
10781
- join22(workDir, "probe-screenshot"),
10832
+ join23(workDir, "probe-screenshot"),
10782
10833
  captureOpts,
10783
10834
  null,
10784
10835
  { ...probeCfg, forceScreenshot: true }
@@ -10816,7 +10867,7 @@ async function runProbeStage(input) {
10816
10867
  compiled,
10817
10868
  resolutions,
10818
10869
  projectDir,
10819
- join22(workDir, "downloads"),
10870
+ join23(workDir, "downloads"),
10820
10871
  job.config.allowOutsideProjectAssets ? void 0 : projectDir,
10821
10872
  { includeScripts: job.config.includeOutsideScripts }
10822
10873
  );
@@ -11016,7 +11067,7 @@ async function runProbeStage(input) {
11016
11067
  });
11017
11068
  await preflightCompositionAssetMediaTypes({
11018
11069
  projectDir,
11019
- compiledDir: join22(workDir, "compiled"),
11070
+ compiledDir: join23(workDir, "compiled"),
11020
11071
  composition,
11021
11072
  signal: abortSignal
11022
11073
  });
@@ -11184,7 +11235,7 @@ function validateDistributedDuration(input) {
11184
11235
 
11185
11236
  // src/services/render/stages/extractVideosStage.ts
11186
11237
  import { existsSync as existsSync14 } from "node:fs";
11187
- import { join as join23 } from "node:path";
11238
+ import { join as join24 } from "node:path";
11188
11239
  import {
11189
11240
  classifyVideoExtractionError,
11190
11241
  createFrameLookupTable as createFrameLookupTable3,
@@ -11548,7 +11599,7 @@ async function runExtractVideosStage(input) {
11548
11599
  // because short boundary counts can differ by one frame.
11549
11600
  {
11550
11601
  fps: job.config.fps,
11551
- outputDir: join23(compiledDir, "__hyperframes_video_frames"),
11602
+ outputDir: join24(compiledDir, "__hyperframes_video_frames"),
11552
11603
  format: job.config.videoFrameFormat ?? "auto",
11553
11604
  toneMapHdrToSdr: rendersSdrOnly(job.config, composition),
11554
11605
  timelineEnd: composition.duration,
@@ -11556,7 +11607,7 @@ async function runExtractVideosStage(input) {
11556
11607
  collectProbeFailures: extractionPolicy.failureMode === "enforce",
11557
11608
  deferRangeExtraction,
11558
11609
  shownBoxes,
11559
- contentKeyedDirs: [join23(compiledDir, REMOTE_MEDIA_SUBDIR)],
11610
+ contentKeyedDirs: [join24(compiledDir, REMOTE_MEDIA_SUBDIR)],
11560
11611
  urlByAbsentLocalPath,
11561
11612
  assetRoots,
11562
11613
  onProgress: ({ planned = 0, done = 0 }) => {
@@ -11648,7 +11699,7 @@ async function remoteProbeSource(video, input) {
11648
11699
  if (!isPublicHttpsUrl(video.src)) return null;
11649
11700
  if (!resolveRestrictPageNetwork()) return video.src;
11650
11701
  if (!video.hasAudio || video.hidden) return null;
11651
- const downloadDir = input.downloadDir ?? join23(input.compiledDir, REMOTE_MEDIA_SUBDIR);
11702
+ const downloadDir = input.downloadDir ?? join24(input.compiledDir, REMOTE_MEDIA_SUBDIR);
11652
11703
  try {
11653
11704
  return await downloadToTemp2(video.src, downloadDir, void 0, input.signal, void 0, {
11654
11705
  onTelemetry: writeUrlDownloadTelemetry2
@@ -11773,7 +11824,7 @@ async function planVideoLayerPassthrough(input) {
11773
11824
 
11774
11825
  // src/services/render/stages/audioStage.ts
11775
11826
  import { existsSync as existsSync17 } from "node:fs";
11776
- import { join as join26 } from "node:path";
11827
+ import { join as join27 } from "node:path";
11777
11828
  import {
11778
11829
  MIXED_AUDIO_FILENAME,
11779
11830
  audioFailureDiagnostics,
@@ -11785,7 +11836,7 @@ import {
11785
11836
 
11786
11837
  // src/services/render/audioDeliveryLimit.ts
11787
11838
  import { existsSync as existsSync16 } from "node:fs";
11788
- import { dirname as dirname11, join as join25 } from "node:path";
11839
+ import { dirname as dirname11, join as join26 } from "node:path";
11789
11840
  import {
11790
11841
  applyAudioFxChain,
11791
11842
  describeFfmpegFailure as describeFfmpegFailure3,
@@ -11795,7 +11846,7 @@ import {
11795
11846
 
11796
11847
  // src/services/render/audioPadTrim.ts
11797
11848
  import { spawn } from "node:child_process";
11798
- import { dirname as dirname10, join as join24 } from "node:path";
11849
+ import { dirname as dirname10, join as join25 } from "node:path";
11799
11850
  import {
11800
11851
  DEFAULT_CONFIG,
11801
11852
  describeFfmpegFailure as describeFfmpegFailure2,
@@ -12076,7 +12127,7 @@ async function constrainAacTruePeak(input) {
12076
12127
  }
12077
12128
  async function cutSource(input, scratchDir, attenuationDb) {
12078
12129
  if (!input.sourcePath || !input.rewriteSource) return true;
12079
- const cutPath = join24(scratchDir, "source.wav");
12130
+ const cutPath = join25(scratchDir, "source.wav");
12080
12131
  try {
12081
12132
  const result = await input.rewriteSource(input.sourcePath, cutPath, gainFilter(attenuationDb));
12082
12133
  if (!result.success) throw new Error(result.error);
@@ -12091,7 +12142,7 @@ async function enforceAacTruePeak(input) {
12091
12142
  let scratchDir;
12092
12143
  try {
12093
12144
  scratchDir = createStagingDir3(dirname10(input.audioPath), ".true-peak-");
12094
- const correctedPath = join24(scratchDir, "audio.m4a");
12145
+ const correctedPath = join25(scratchDir, "audio.m4a");
12095
12146
  const measurements = [];
12096
12147
  let attenuationDb = 0;
12097
12148
  let sourcePeakDbfs;
@@ -12311,7 +12362,7 @@ async function limitDeliveryPeaks(input, deps = {
12311
12362
  const peak = await deps.measure(audioPath, { timeoutMs, signal });
12312
12363
  if (peak <= AAC_DELIVERY_TRUE_PEAK_DBFS) return { success: true };
12313
12364
  const alternating = ["a", "b"].map(
12314
- (k) => join25(dirname11(sourcePath), `audio-source-limited-${k}.wav`)
12365
+ (k) => join26(dirname11(sourcePath), `audio-source-limited-${k}.wav`)
12315
12366
  );
12316
12367
  let encodedFrom;
12317
12368
  let ceiling = AAC_DELIVERY_TRUE_PEAK_DBFS;
@@ -12384,7 +12435,7 @@ function runAudioStage(input) {
12384
12435
  }
12385
12436
  async function runAudioStageScoped(input) {
12386
12437
  const stageStart = Date.now();
12387
- const pcmSourcePath = join26(input.workDir, "audio-source.wav");
12438
+ const pcmSourcePath = join27(input.workDir, "audio-source.wav");
12388
12439
  const duration = input.totalFrames * input.fps.den / input.fps.num;
12389
12440
  let deliverySourcePath;
12390
12441
  try {
@@ -12449,7 +12500,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
12449
12500
  assertNotAborted,
12450
12501
  log
12451
12502
  } = input;
12452
- const audioOutputPath = join26(workDir, MIXED_AUDIO_FILENAME);
12503
+ const audioOutputPath = join27(workDir, MIXED_AUDIO_FILENAME);
12453
12504
  let hasAudio = false;
12454
12505
  let audioError;
12455
12506
  let audioFailures;
@@ -12530,7 +12581,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
12530
12581
 
12531
12582
  // src/services/render/stages/captureStage.ts
12532
12583
  import { existsSync as existsSync18, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
12533
- import { join as join27 } from "node:path";
12584
+ import { join as join28 } from "node:path";
12534
12585
  import {
12535
12586
  classifyCaptureFailure as classifyCaptureFailure2,
12536
12587
  frameFileExtension,
@@ -12603,13 +12654,13 @@ function measureCaptureFrameBytes(workDir, framesDir) {
12603
12654
  if (!existsSync18(workDir)) return total;
12604
12655
  for (const attempt of readdirSync4(workDir)) {
12605
12656
  if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
12606
- total += sampleDirectoryBytes(join27(workDir, attempt));
12657
+ total += sampleDirectoryBytes(join28(workDir, attempt));
12607
12658
  continue;
12608
12659
  }
12609
12660
  if (!/^capture-attempt-\d+$/.test(attempt)) continue;
12610
- const attemptDir = join27(workDir, attempt);
12661
+ const attemptDir = join28(workDir, attempt);
12611
12662
  for (const name of readdirSync4(attemptDir)) {
12612
- if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join27(attemptDir, name));
12663
+ if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join28(attemptDir, name));
12613
12664
  }
12614
12665
  }
12615
12666
  return total;
@@ -12908,7 +12959,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
12908
12959
 
12909
12960
  // src/services/render/stages/captureHdrStage.ts
12910
12961
  import { existsSync as existsSync20, mkdirSync as mkdirSync10 } from "node:fs";
12911
- import { join as join31 } from "node:path";
12962
+ import { join as join32 } from "node:path";
12912
12963
  import {
12913
12964
  closeCaptureSession as closeCaptureSession7,
12914
12965
  cloneCaptureWarnings as cloneCaptureWarnings2,
@@ -12980,7 +13031,7 @@ function createHdrImageTransferCache(options = {}) {
12980
13031
  }
12981
13032
 
12982
13033
  // src/services/render/stages/captureHdrSequentialLoop.ts
12983
- import { join as join28 } from "node:path";
13034
+ import { join as join29 } from "node:path";
12984
13035
  import {
12985
13036
  TRANSITIONS,
12986
13037
  crossfade
@@ -13105,7 +13156,7 @@ async function runSequentialLayeredFrameLoop(input) {
13105
13156
  );
13106
13157
  if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
13107
13158
  writeFileExclusiveSync(
13108
- join28(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
13159
+ join29(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
13109
13160
  normalCanvas
13110
13161
  );
13111
13162
  }
@@ -13137,7 +13188,7 @@ async function runSequentialLayeredFrameLoop(input) {
13137
13188
  }
13138
13189
 
13139
13190
  // src/services/render/stages/captureHdrHybridLoop.ts
13140
- import { join as join30 } from "node:path";
13191
+ import { join as join31 } from "node:path";
13141
13192
  import {
13142
13193
  TRANSITIONS as TRANSITIONS2,
13143
13194
  closeCaptureSession as closeCaptureSession6,
@@ -13151,7 +13202,7 @@ import {
13151
13202
  // src/services/shaderTransitionWorkerPool.ts
13152
13203
  import { Worker } from "node:worker_threads";
13153
13204
  import { fileURLToPath as fileURLToPath3, pathToFileURL } from "node:url";
13154
- import { dirname as dirname12, join as join29 } from "node:path";
13205
+ import { dirname as dirname12, join as join30 } from "node:path";
13155
13206
  import { createRequire } from "node:module";
13156
13207
  import { usableCpuCount } from "@hyperframes/engine";
13157
13208
  import { existsSync as existsSync19 } from "node:fs";
@@ -13165,9 +13216,9 @@ function resolveWorkerEntry(explicit) {
13165
13216
  return { path: override, isTs };
13166
13217
  }
13167
13218
  const moduleDir = dirname12(fileURLToPath3(import.meta.url));
13168
- const jsPath = join29(moduleDir, "shaderTransitionWorker.js");
13219
+ const jsPath = join30(moduleDir, "shaderTransitionWorker.js");
13169
13220
  if (existsSync19(jsPath)) return { path: jsPath, isTs: false };
13170
- const tsPath = join29(moduleDir, "shaderTransitionWorker.ts");
13221
+ const tsPath = join30(moduleDir, "shaderTransitionWorker.ts");
13171
13222
  return { path: tsPath, isTs: true };
13172
13223
  }
13173
13224
  function buildExecArgv(entryIsTs) {
@@ -13535,7 +13586,7 @@ async function runHybridLayeredFrameLoop(input) {
13535
13586
  );
13536
13587
  if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
13537
13588
  writeFileExclusiveSync(
13538
- join30(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
13589
+ join31(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
13539
13590
  canvas
13540
13591
  );
13541
13592
  }
@@ -13731,7 +13782,7 @@ async function runCaptureHdrStage(input) {
13731
13782
  if (hdrVideoFrameSources.has(v.id)) hdrVideoEndTimes.set(v.id, v.end);
13732
13783
  }
13733
13784
  const debugDumpEnabled = process.env.KEEP_TEMP === "1";
13734
- const debugDumpDir = debugDumpEnabled ? join31(framesDir, "debug-composite") : null;
13785
+ const debugDumpDir = debugDumpEnabled ? join32(framesDir, "debug-composite") : null;
13735
13786
  if (debugDumpDir && !existsSync20(debugDumpDir)) {
13736
13787
  mkdirSync10(debugDumpDir, { recursive: true });
13737
13788
  }
@@ -13896,11 +13947,11 @@ import {
13896
13947
  readdirSync as readdirSync5,
13897
13948
  readFileSync as readFileSync9,
13898
13949
  rmSync as rmSync11,
13899
- statSync as statSync10,
13950
+ statSync as statSync9,
13900
13951
  writeFileSync as writeFileSync6
13901
13952
  } from "node:fs";
13902
13953
  import { readFile as readFile2 } from "node:fs/promises";
13903
- import { dirname as dirname13, join as join32 } from "node:path";
13954
+ import { dirname as dirname13, join as join33 } from "node:path";
13904
13955
  import {
13905
13956
  encodeFramesChunkedConcat,
13906
13957
  encodeFramesFromDir,
@@ -14025,7 +14076,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
14025
14076
  const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
14026
14077
  if (failure) return failure;
14027
14078
  }
14028
- const fileSize = existsSync21(outputPath) ? statSync10(outputPath).size : 0;
14079
+ const fileSize = existsSync21(outputPath) ? statSync9(outputPath).size : 0;
14029
14080
  return {
14030
14081
  success: true,
14031
14082
  outputPath,
@@ -14119,7 +14170,7 @@ function encodeWhileCapturing(input, totalFrames, captureBudget) {
14119
14170
  await new Promise((resolve14) => wake = resolve14);
14120
14171
  }
14121
14172
  if (signal.aborted) return;
14122
- const mergedPath = join32(input.framesDir, formatCaptureFrameName(next, "jpg"));
14173
+ const mergedPath = join33(input.framesDir, formatCaptureFrameName(next, "jpg"));
14123
14174
  const frame = await readLandedFrame(landed.get(next), mergedPath);
14124
14175
  landed.delete(next);
14125
14176
  if (!await stream.writeFrame(frame)) {
@@ -14202,11 +14253,11 @@ async function runEncodeStage(input) {
14202
14253
  );
14203
14254
  }
14204
14255
  captured.forEach((name, i) => {
14205
- const dst = join32(outputPath, formatExportFrameName(i, "png"));
14206
- copyFileSync4(join32(framesDir, name), dst);
14256
+ const dst = join33(outputPath, formatExportFrameName(i, "png"));
14257
+ copyFileSync4(join33(framesDir, name), dst);
14207
14258
  });
14208
14259
  if (hasAudio && audioOutputPath && existsSync21(audioOutputPath)) {
14209
- copyFileSync4(audioOutputPath, join32(outputPath, MIXED_AUDIO_FILENAME2));
14260
+ copyFileSync4(audioOutputPath, join33(outputPath, MIXED_AUDIO_FILENAME2));
14210
14261
  log.info(
14211
14262
  `[Render] png-sequence: ${MIXED_AUDIO_FILENAME2} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME2}`
14212
14263
  );
@@ -14226,7 +14277,7 @@ async function runEncodeStage(input) {
14226
14277
  const encodeResult2 = await encodeGifFromDir(framesDir, framePattern2, outputPath, {
14227
14278
  fps: job.config.fps,
14228
14279
  loop,
14229
- palettePath: join32(dirname13(videoOnlyPath), "gif-palette.png"),
14280
+ palettePath: join33(dirname13(videoOnlyPath), "gif-palette.png"),
14230
14281
  preserveAlpha: needsAlpha,
14231
14282
  signal: abortSignal,
14232
14283
  timeout: engineCfg.ffmpegEncodeTimeout
@@ -14437,9 +14488,9 @@ function sampleDirectoryBytes(dir) {
14437
14488
  continue;
14438
14489
  }
14439
14490
  for (const name of entries) {
14440
- const full = join33(current, name);
14491
+ const full = join34(current, name);
14441
14492
  try {
14442
- const st = statSync11(full);
14493
+ const st = statSync10(full);
14443
14494
  if (st.isDirectory()) {
14444
14495
  stack.push(full);
14445
14496
  } else if (st.isFile()) {
@@ -14595,8 +14646,8 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
14595
14646
  const ranges = [];
14596
14647
  let rangeStart = null;
14597
14648
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
14598
- const framePath = join33(framesDir, formatCaptureFrameName(frameIndex, frameExt));
14599
- const missing = !existsSync22(framePath) || statSync11(framePath).size <= 8;
14649
+ const framePath = join34(framesDir, formatCaptureFrameName(frameIndex, frameExt));
14650
+ const missing = !existsSync22(framePath) || statSync10(framePath).size <= 8;
14600
14651
  if (missing && rangeStart === null) {
14601
14652
  rangeStart = frameIndex;
14602
14653
  } else if (!missing && rangeStart !== null) {
@@ -14612,7 +14663,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
14612
14663
  function buildMissingFrameRetryBatches(ranges, maxWorkers, workDir, attempt, rangeStart = 0, stride = 1) {
14613
14664
  const workersPerBatch = Math.max(1, Math.floor(maxWorkers));
14614
14665
  const batches = [];
14615
- const outputDirFor = (batchIndex, workerId) => join33(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
14666
+ const outputDirFor = (batchIndex, workerId) => join34(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
14616
14667
  if (stride > 1) {
14617
14668
  const spans = /* @__PURE__ */ new Map();
14618
14669
  for (const range of ranges) {
@@ -14672,8 +14723,8 @@ function getNextRetryWorkerCount(currentWorkers) {
14672
14723
  return Math.max(1, Math.floor(currentWorkers / 2));
14673
14724
  }
14674
14725
  function resolveRenderWorkDirPrefix(outputPath, jobId, platform2 = process.platform, systemTempDir = tmpdir3()) {
14675
- if (platform2 === "win32" || platform2 === "darwin") return join33(systemTempDir, "hf-render-");
14676
- return join33(dirname14(outputPath), `work-${jobId}-`);
14726
+ if (platform2 === "win32" || platform2 === "darwin") return join34(systemTempDir, "hf-render-");
14727
+ return join34(dirname14(outputPath), `work-${jobId}-`);
14677
14728
  }
14678
14729
  var MAX_TRANSIENT_CAPTURE_RETRIES = 1;
14679
14730
  function isTransientCaptureRetryEligible(failureKind, missing, retriesUsed) {
@@ -14728,7 +14779,7 @@ The composition is too large for the available memory. To reduce memory pressure
14728
14779
  function countCapturedFrames(totalFrames, framesDir, frameExt) {
14729
14780
  let captured = 0;
14730
14781
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
14731
- const framePath = join33(framesDir, formatCaptureFrameName(frameIndex, frameExt));
14782
+ const framePath = join34(framesDir, formatCaptureFrameName(frameIndex, frameExt));
14732
14783
  if (existsSync22(framePath)) captured++;
14733
14784
  }
14734
14785
  return captured;
@@ -14754,7 +14805,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
14754
14805
  reason: attempt === 0 ? "initial" : pendingTransientRetry ? "transient-retry" : "retry"
14755
14806
  });
14756
14807
  pendingTransientRetry = false;
14757
- const attemptWorkDir = join33(options.workDir, `capture-attempt-${attempt}`);
14808
+ const attemptWorkDir = join34(options.workDir, `capture-attempt-${attempt}`);
14758
14809
  const batches = missingRanges ? buildMissingFrameRetryBatches(
14759
14810
  missingRanges,
14760
14811
  currentWorkers,
@@ -15402,7 +15453,7 @@ function deVerifyFallbackTelemetry(err) {
15402
15453
  }
15403
15454
  function resolveRenderDebugDir() {
15404
15455
  const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve9(process.env.PRODUCER_RENDERS_DIR, "..") : resolve9(dirname14(fileURLToPath4(import.meta.url)), "../..");
15405
- return join33(producerRoot, ".debug");
15456
+ return join34(producerRoot, ".debug");
15406
15457
  }
15407
15458
  async function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
15408
15459
  validateHlsRenderConfig(job.config);
@@ -15411,10 +15462,10 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
15411
15462
  const debugDir = resolveRenderDebugDir();
15412
15463
  const outputDir = dirname14(outputPath);
15413
15464
  if (!existsSync22(outputDir)) mkdirSync12(outputDir, { recursive: true });
15414
- const workDir = job.config.debug ? join33(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
15465
+ const workDir = job.config.debug ? join34(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
15415
15466
  const pipelineStart = Date.now();
15416
15467
  const baseLog = job.config.logger ?? defaultLogger;
15417
- const logPath = job.config.debug ? join33(workDir, "render.log") : null;
15468
+ const logPath = job.config.debug ? join34(workDir, "render.log") : null;
15418
15469
  const execution = new RenderExecutionContext({
15419
15470
  request: { renderJobId: job.id, projectDir, outputPath },
15420
15471
  logger: logPath ? createRenderFileLogger(logPath, baseLog) : baseLog,
@@ -15445,6 +15496,15 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
15445
15496
  await execution.dispose();
15446
15497
  }
15447
15498
  }
15499
+ function loadResumeKeyOrWarn(resume, log) {
15500
+ const key = segmentManifestKey();
15501
+ if (resume && !key) {
15502
+ log.warn(
15503
+ "[Render] --resume: no preview token could be read or created, so every segment will be captured again"
15504
+ );
15505
+ }
15506
+ return key;
15507
+ }
15448
15508
  async function executeRenderPipeline(input) {
15449
15509
  const {
15450
15510
  job,
@@ -15482,7 +15542,7 @@ async function executeRenderPipeline(input) {
15482
15542
  imageDecodeFailures: 0
15483
15543
  };
15484
15544
  let hdrPerf;
15485
- const perfOutputPath = join33(workDir, "perf-summary.json");
15545
+ const perfOutputPath = join34(workDir, "perf-summary.json");
15486
15546
  const cfg = { ...job.config.producerConfig ?? resolveConfig2() };
15487
15547
  const observability = new RenderObservabilityRecorder({
15488
15548
  pipelineStartMs: pipelineStart,
@@ -15587,7 +15647,7 @@ async function executeRenderPipeline(input) {
15587
15647
  requestedWorkers: job.config.workers ?? "auto"
15588
15648
  });
15589
15649
  const entryFile = job.config.entryFile || "index.html";
15590
- const htmlPath = join33(projectDir, entryFile);
15650
+ const htmlPath = join34(projectDir, entryFile);
15591
15651
  if (!existsSync22(htmlPath)) {
15592
15652
  throw new Error(`Entry file not found: ${htmlPath}`);
15593
15653
  }
@@ -15684,7 +15744,7 @@ async function executeRenderPipeline(input) {
15684
15744
  const largerThanCanvas = await oversizedVideos(
15685
15745
  composition.videos,
15686
15746
  projectDir,
15687
- join33(workDir, "compiled"),
15747
+ join34(workDir, "compiled"),
15688
15748
  { width: outputWidth, height: outputHeight }
15689
15749
  );
15690
15750
  const probeResult = await observeRenderStage(
@@ -15781,7 +15841,7 @@ async function executeRenderPipeline(input) {
15781
15841
  canvas: { width, height },
15782
15842
  page: probeSession.page,
15783
15843
  projectDir,
15784
- compiledDir: join33(workDir, "compiled")
15844
+ compiledDir: join34(workDir, "compiled")
15785
15845
  });
15786
15846
  if (videoLayerPlan.videoId === void 0) {
15787
15847
  log.info(`[Render] Video layer passthrough off: ${videoLayerPlan.reason}`);
@@ -15799,7 +15859,7 @@ async function executeRenderPipeline(input) {
15799
15859
  updateJobStatus(job, "preprocessing", "Extracting video frames", 10, onProgress, {
15800
15860
  code: "extract_video"
15801
15861
  });
15802
- const compiledDir = join33(workDir, "compiled");
15862
+ const compiledDir = join34(workDir, "compiled");
15803
15863
  const segmentsCapture = (layeredOrEffectRoute) => shouldSegmentCapture({
15804
15864
  env: process.env,
15805
15865
  durationSeconds: probeResult.duration,
@@ -15935,7 +15995,7 @@ async function executeRenderPipeline(input) {
15935
15995
  try {
15936
15996
  fileServer = await createFileServer({
15937
15997
  projectDir,
15938
- compiledDir: join33(workDir, "compiled"),
15998
+ compiledDir: join34(workDir, "compiled"),
15939
15999
  port: 0,
15940
16000
  preHeadScripts: [VIRTUAL_TIME_SHIM],
15941
16001
  fps: job.config.fps,
@@ -15955,7 +16015,7 @@ async function executeRenderPipeline(input) {
15955
16015
  if (!activeFileServer) {
15956
16016
  throw new Error("File server failed to initialize before frame capture");
15957
16017
  }
15958
- const framesDir = join33(workDir, "captured-frames");
16018
+ const framesDir = join34(workDir, "captured-frames");
15959
16019
  if (!existsSync22(framesDir)) mkdirSync12(framesDir, { recursive: true });
15960
16020
  updateJobStatus(job, "rendering", "Checking browser GPU", 25, onProgress, {
15961
16021
  code: "start_browsers"
@@ -16536,7 +16596,7 @@ async function executeRenderPipeline(input) {
16536
16596
  hls: ".mp4"
16537
16597
  };
16538
16598
  const videoExt = FORMAT_EXT[outputFormat] ?? ".mp4";
16539
- const videoOnlyPath = join33(workDir, `video-only${videoExt}`);
16599
+ const videoOnlyPath = join34(workDir, `video-only${videoExt}`);
16540
16600
  let usePageSideCompositingForTransitions = (cfg.enablePageSideCompositing || isGif) && compiled.hasShaderTransitions && !hasHdrContent && outputSupportsPageSideShaderCompositing(outputFormat);
16541
16601
  if (usePageSideCompositingForTransitions) {
16542
16602
  activeFileServer.addPreHeadScript(HF_PAGE_SIDE_COMPOSITING_STUB);
@@ -16853,16 +16913,19 @@ async function executeRenderPipeline(input) {
16853
16913
  pageMotionBlur: job.config.pageMotionBlur,
16854
16914
  captureQuality: captureOptions.quality
16855
16915
  });
16856
- const segmentDir = segmentDirFor(join33(projectDir, "renders"), segmentPlanHash);
16916
+ const segmentDir = segmentDirFor(join34(projectDir, "renders"), segmentPlanHash);
16917
+ const manifestKey = loadResumeKeyOrWarn(job.config.resumeSegments === true, log);
16857
16918
  let completedSegments = /* @__PURE__ */ new Set();
16858
16919
  if (job.config.resumeSegments === true) {
16859
16920
  const existing = readSegmentManifest(segmentDir);
16860
16921
  if (existing) {
16861
- completedSegments = await validateCompletedSegments(
16862
- existing,
16863
- segmentPlanHash,
16864
- (path) => probeSegmentFrameCount(path, extractMediaMetadata5)
16865
- );
16922
+ completedSegments = await validateCompletedSegments(existing, {
16923
+ expectedHash: segmentPlanHash,
16924
+ segmentDir,
16925
+ plan: planSegments(totalFrames, segmentFrames),
16926
+ key: manifestKey,
16927
+ probeFrames: (path) => probeSegmentFrameCount(path, extractMediaMetadata5)
16928
+ });
16866
16929
  log.info(`[Render] resuming: ${completedSegments.size} segments complete`, {
16867
16930
  segmentDir
16868
16931
  });
@@ -16936,7 +16999,7 @@ async function executeRenderPipeline(input) {
16936
16999
  ...segmentManifest.completed.filter((e) => e.index !== entry.index),
16937
17000
  { ...entry, completedAt: (/* @__PURE__ */ new Date()).toISOString() }
16938
17001
  ];
16939
- writeSegmentManifest(segmentDir, segmentManifest);
17002
+ writeSegmentManifest(segmentDir, segmentManifest, manifestKey);
16940
17003
  },
16941
17004
  updateCaptureObservability
16942
17005
  })
@@ -17479,7 +17542,7 @@ async function executeRenderPipeline(input) {
17479
17542
  }
17480
17543
  if (job.config.debug) {
17481
17544
  if (!isPngSequence && !isHls && existsSync22(stagedOutputPath)) {
17482
- const debugOutput = join33(workDir, `output${videoExt}`);
17545
+ const debugOutput = join34(workDir, `output${videoExt}`);
17483
17546
  copyFileSync5(stagedOutputPath, debugOutput);
17484
17547
  }
17485
17548
  }
@@ -17598,14 +17661,14 @@ import {
17598
17661
  referenceBackgroundResult as referenceBackgroundResult6
17599
17662
  } from "@hyperframes/engine";
17600
17663
  import { mkdirSync as mkdirSync20, mkdtempSync, readFileSync as readFileSync15, rmSync as rmSync18 } from "node:fs";
17601
- import { join as join47 } from "node:path";
17664
+ import { join as join48 } from "node:path";
17602
17665
  import { tmpdir as tmpdir5 } from "node:os";
17603
17666
 
17604
17667
  // src/services/distributed/mp4Stitch.ts
17605
- import { createReadStream as createReadStream3, createWriteStream, mkdirSync as mkdirSync13, rmSync as rmSync13 } from "node:fs";
17668
+ import { createReadStream as createReadStream4, createWriteStream, mkdirSync as mkdirSync13, rmSync as rmSync13 } from "node:fs";
17606
17669
  import { open } from "node:fs/promises";
17607
17670
  import { renameWithRetry as renameWithRetry7 } from "@hyperframes/engine";
17608
- import { basename as basename8, dirname as dirname15, join as join34 } from "node:path";
17671
+ import { basename as basename8, dirname as dirname15, join as join35 } from "node:path";
17609
17672
  import { finished, pipeline } from "node:stream/promises";
17610
17673
  import { createStagingDir as createStagingDir4 } from "@hyperframes/core/atomic-file";
17611
17674
  function boxAt(src, off, at, limit) {
@@ -17958,7 +18021,7 @@ function fileRange(path) {
17958
18021
  }
17959
18022
  async function copyPayload(path, layout, index, out) {
17960
18023
  const { payloadStart, payloadEnd } = layout;
17961
- const payload = createReadStream3(path, { start: payloadStart, end: payloadEnd - 1 });
18024
+ const payload = createReadStream4(path, { start: payloadStart, end: payloadEnd - 1 });
17962
18025
  await pipeline(payload, out, { end: false });
17963
18026
  if (payload.bytesRead !== payloadEnd - payloadStart) {
17964
18027
  throw new Error(
@@ -17972,13 +18035,13 @@ async function writeStitchedMp4(chunkPaths, outputPath, audioPath) {
17972
18035
  const header = audioPath ? buildStitchedHeader(layouts.slice(1), layouts[0]) : buildStitchedHeader(layouts);
17973
18036
  mkdirSync13(dirname15(outputPath), { recursive: true });
17974
18037
  const workDir = createStagingDir4(dirname15(outputPath), `${basename8(outputPath)}.stitch-`);
17975
- const out = createWriteStream(join34(workDir, "out.mp4"));
18038
+ const out = createWriteStream(join35(workDir, "out.mp4"));
17976
18039
  try {
17977
18040
  out.write(header);
17978
18041
  for (const [i, path] of sourcePaths.entries()) await copyPayload(path, layouts[i], i, out);
17979
18042
  out.end();
17980
18043
  await finished(out);
17981
- renameWithRetry7(join34(workDir, "out.mp4"), outputPath);
18044
+ renameWithRetry7(join35(workDir, "out.mp4"), outputPath);
17982
18045
  } finally {
17983
18046
  out.destroy();
17984
18047
  rmSync13(workDir, { recursive: true, force: true });
@@ -18001,7 +18064,7 @@ import {
18001
18064
  rmSync as rmSync14,
18002
18065
  writeFileSync as writeFileSync10
18003
18066
  } from "node:fs";
18004
- import { extname as extname6, isAbsolute as isAbsolute4, join as join42, relative as relative7, sep as sep5 } from "node:path";
18067
+ import { extname as extname6, isAbsolute as isAbsolute4, join as join43, relative as relative7, sep as sep5 } from "node:path";
18005
18068
  import {
18006
18069
  fpsToNumber as fpsToNumber9,
18007
18070
  HF_COLOR_GRADING_ATTR as HF_COLOR_GRADING_ATTR2
@@ -18018,7 +18081,7 @@ import {
18018
18081
  } from "@hyperframes/engine";
18019
18082
 
18020
18083
  // src/services/distributed/planFrameCost.ts
18021
- import { join as join37 } from "node:path";
18084
+ import { join as join38 } from "node:path";
18022
18085
  import {
18023
18086
  closeCaptureSession as closeCaptureSession9,
18024
18087
  createCaptureSession as createCaptureSession9,
@@ -18028,7 +18091,7 @@ import {
18028
18091
 
18029
18092
  // src/services/distributed/chunkFrames.ts
18030
18093
  import { existsSync as existsSync24, readdirSync as readdirSync7 } from "node:fs";
18031
- import { extname as extname4, join as join36 } from "node:path";
18094
+ import { extname as extname4, join as join37 } from "node:path";
18032
18095
  import {
18033
18096
  compositionRequiresWebGpu as compositionRequiresWebGpu3,
18034
18097
  createVideoFrameInjector as createVideoFrameInjector3,
@@ -18037,7 +18100,7 @@ import {
18037
18100
 
18038
18101
  // src/services/distributed/shared.ts
18039
18102
  import { execFile as execFileCallback } from "node:child_process";
18040
- import { dirname as dirname16, join as join35 } from "node:path";
18103
+ import { dirname as dirname16, join as join36 } from "node:path";
18041
18104
  import { existsSync as existsSync23, readFileSync as readFileSync10 } from "node:fs";
18042
18105
  import { fileURLToPath as fileURLToPath5 } from "node:url";
18043
18106
  import { promisify as promisify2 } from "node:util";
@@ -18053,7 +18116,7 @@ function isPlanAudioArtifactPath(path) {
18053
18116
  }
18054
18117
  function resolvePlanAudioPath(planDir) {
18055
18118
  for (const name of [PLAN_AUDIO_RELATIVE_PATH, PLAN_AUDIO_LEGACY_RELATIVE_PATH]) {
18056
- const candidate = join35(planDir, name);
18119
+ const candidate = join36(planDir, name);
18057
18120
  if (existsSync23(candidate)) return candidate;
18058
18121
  }
18059
18122
  return null;
@@ -18318,7 +18381,7 @@ function readProducerVersion() {
18318
18381
  const startDir = dirname16(fileURLToPath5(import.meta.url));
18319
18382
  let current = startDir;
18320
18383
  for (let i = 0; i < 10; i++) {
18321
- const candidate = join35(current, "package.json");
18384
+ const candidate = join36(current, "package.json");
18322
18385
  if (existsSync23(candidate)) {
18323
18386
  try {
18324
18387
  const pkg = JSON.parse(readFileSync10(candidate, "utf-8"));
@@ -18373,7 +18436,7 @@ function frameNumberFromFileName(name) {
18373
18436
  function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v1") {
18374
18437
  const result = [];
18375
18438
  for (const v of videos) {
18376
- const outputDir = join36(planDir, "video-frames", mediaIdPathSegment3(v.videoId));
18439
+ const outputDir = join37(planDir, "video-frames", mediaIdPathSegment3(v.videoId));
18377
18440
  if (!existsSync24(outputDir)) {
18378
18441
  throw new Error(
18379
18442
  `[renderChunk] planDir missing extracted video frames for ${JSON.stringify(v.videoId)}: ${outputDir} not present. plan() should have written frames here; the planDir is malformed.`
@@ -18392,7 +18455,7 @@ function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v
18392
18455
  if (!frameName) continue;
18393
18456
  const frameNumber = indexMode === "sparse-v2" ? frameNumberFromFileName(frameName) : null;
18394
18457
  const frameIndex = frameNumber === null ? i : frameNumber - 1;
18395
- framePaths.set(frameIndex, join36(outputDir, frameName));
18458
+ framePaths.set(frameIndex, join37(outputDir, frameName));
18396
18459
  }
18397
18460
  result.push({
18398
18461
  videoId: v.videoId,
@@ -18472,7 +18535,7 @@ async function extractDeferredVideoFramesForChunk(input) {
18472
18535
  sourceOf: (video) => {
18473
18536
  const range = planned.get(video.videoId).deferredRange;
18474
18537
  const remoteUrl = remoteSources[range.sourcePath];
18475
- const sourcePath = remoteUrl ?? join36(input.planDir, ...range.sourcePath.split("/"));
18538
+ const sourcePath = remoteUrl ?? join37(input.planDir, ...range.sourcePath.split("/"));
18476
18539
  if (remoteUrl === void 0 && !existsSync24(sourcePath)) {
18477
18540
  throw new RenderChunkValidationError(
18478
18541
  MISSING_PLAN_ARTIFACT,
@@ -18503,12 +18566,12 @@ async function measurePlanSecondsPerFrame(input) {
18503
18566
  planVideos,
18504
18567
  frames: sampled,
18505
18568
  fps: fpsRatio,
18506
- outputRoot: join37(workDir, "frame-cost-video-frames"),
18569
+ outputRoot: join38(workDir, "frame-cost-video-frames"),
18507
18570
  cfg: input.cfg
18508
18571
  })
18509
18572
  ];
18510
18573
  const lookup = extracted.length > 0 ? createFrameLookupTable4(planVideos.videos, extracted, resolveRenderFpsConfig(fpsRatio).value) : null;
18511
- const compiledDir = join37(planDir, "compiled");
18574
+ const compiledDir = join38(planDir, "compiled");
18512
18575
  const fileServer = await createFileServer({
18513
18576
  projectDir: compiledDir,
18514
18577
  compiledDir,
@@ -18520,7 +18583,7 @@ async function measurePlanSecondsPerFrame(input) {
18520
18583
  try {
18521
18584
  session = await createCaptureSession9(
18522
18585
  fileServer.url,
18523
- join37(workDir, "frame-cost"),
18586
+ join38(workDir, "frame-cost"),
18524
18587
  buildChunkCaptureOptions({
18525
18588
  dimensions: { ...input, fpsNum: fps, fpsDen: 1 },
18526
18589
  encoder: input,
@@ -18617,7 +18680,7 @@ function buildWeightedChunkSlices(weights, chunkCount, minFrames, maxFrames) {
18617
18680
  }
18618
18681
 
18619
18682
  // src/services/render/planReferenceBackground.ts
18620
- import { join as join38 } from "node:path";
18683
+ import { join as join39 } from "node:path";
18621
18684
  import {
18622
18685
  closeCaptureSession as closeCaptureSession10,
18623
18686
  createCaptureSession as createCaptureSession10,
@@ -18630,14 +18693,14 @@ async function readPlanReferenceBackground(input) {
18630
18693
  try {
18631
18694
  server = await createFileServer({
18632
18695
  projectDir: input.projectDir,
18633
- compiledDir: join38(input.workDir, "compiled"),
18696
+ compiledDir: join39(input.workDir, "compiled"),
18634
18697
  port: 0,
18635
18698
  preHeadScripts: [VIRTUAL_TIME_SHIM],
18636
18699
  fps: input.options.fps
18637
18700
  });
18638
18701
  session = await createCaptureSession10(
18639
18702
  server.url,
18640
- join38(input.workDir, "reference"),
18703
+ join39(input.workDir, "reference"),
18641
18704
  {
18642
18705
  ...input.options,
18643
18706
  requiresWebGpu: false
@@ -18674,7 +18737,7 @@ async function readPlanReferenceBackground(input) {
18674
18737
 
18675
18738
  // src/services/render/stages/freezePlan.ts
18676
18739
  import { existsSync as existsSync25, mkdirSync as mkdirSync14, readFileSync as readFileSync11, readdirSync as readdirSync8, writeFileSync as writeFileSync8 } from "node:fs";
18677
- import { join as join39, relative as relative5, resolve as resolve10 } from "node:path";
18740
+ import { join as join40, relative as relative5, resolve as resolve10 } from "node:path";
18678
18741
  import {
18679
18742
  REFERENCE_BACKGROUND_FIELD,
18680
18743
  referenceBackgroundResult as referenceBackgroundResult3
@@ -18773,7 +18836,7 @@ function readPlanProtocolV1(planJson, capabilities = DISTRIBUTED_RENDER_CAPABILI
18773
18836
 
18774
18837
  // src/services/render/stages/planHash.ts
18775
18838
  import { createHash as createHash8 } from "node:crypto";
18776
- import { closeSync as closeSync5, createReadStream as createReadStream4, openSync as openSync5, readSync as readSync5 } from "node:fs";
18839
+ import { closeSync as closeSync5, createReadStream as createReadStream5, openSync as openSync5, readSync as readSync5 } from "node:fs";
18777
18840
  var PLAN_HASH_SCHEMA_PREFIX = "hyperframes-plan-hash-v1\0";
18778
18841
  var FIELD_DELIMITER = Buffer.from([0]);
18779
18842
  function computePlanHash(input) {
@@ -18845,7 +18908,7 @@ function sha256File(path) {
18845
18908
  }
18846
18909
  async function sha256FileAsync(path) {
18847
18910
  const hash = createHash8("sha256");
18848
- for await (const chunk of createReadStream4(path, { highWaterMark: 1024 * 1024 })) {
18911
+ for await (const chunk of createReadStream5(path, { highWaterMark: 1024 * 1024 })) {
18849
18912
  hash.update(chunk);
18850
18913
  }
18851
18914
  return hash.digest("hex");
@@ -18892,7 +18955,7 @@ function listPlanFiles(planDir) {
18892
18955
  function walk(dir) {
18893
18956
  const entries = readdirSync8(dir, { withFileTypes: true });
18894
18957
  for (const entry of entries) {
18895
- const full = join39(dir, entry.name);
18958
+ const full = join40(dir, entry.name);
18896
18959
  if (entry.isDirectory()) {
18897
18960
  walk(full);
18898
18961
  } else if (entry.isFile()) {
@@ -18933,15 +18996,15 @@ var PLAN_REMOTE_FILES_RELATIVE_PATH = "meta/remote-files.json";
18933
18996
  function writePlanRemoteFiles(planDir, files) {
18934
18997
  if (files.length === 0) return;
18935
18998
  const sorted = [...files].sort((a, b) => a.path < b.path ? -1 : 1);
18936
- writeFileSync8(join39(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH), JSON.stringify(sorted), "utf-8");
18999
+ writeFileSync8(join40(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH), JSON.stringify(sorted), "utf-8");
18937
19000
  }
18938
19001
  function readPlanRemoteFiles(planDir) {
18939
- const path = join39(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH);
19002
+ const path = join40(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH);
18940
19003
  return existsSync25(path) ? JSON.parse(readFileSync11(path, "utf-8")) : [];
18941
19004
  }
18942
19005
  function recomputePlanHashFromPlanDir(planDir, digests) {
18943
- const planJsonPath = join39(planDir, "plan.json");
18944
- const encoderJsonPath = join39(planDir, "meta", "encoder.json");
19006
+ const planJsonPath = join40(planDir, "plan.json");
19007
+ const encoderJsonPath = join40(planDir, "meta", "encoder.json");
18945
19008
  if (!existsSync25(planJsonPath)) {
18946
19009
  throw new Error(`[freezePlan] plan.json missing: ${planJsonPath}`);
18947
19010
  }
@@ -18978,18 +19041,18 @@ async function freezePlan(input) {
18978
19041
  if (!existsSync25(planDir)) {
18979
19042
  throw new Error(`[freezePlan] planDir does not exist: ${planDir}`);
18980
19043
  }
18981
- const metaDir = join39(planDir, "meta");
19044
+ const metaDir = join40(planDir, "meta");
18982
19045
  if (!existsSync25(metaDir)) mkdirSync14(metaDir, { recursive: true });
18983
19046
  writeFileSync8(
18984
- join39(metaDir, "composition.json"),
19047
+ join40(metaDir, "composition.json"),
18985
19048
  `${JSON.stringify(composition, null, 2)}
18986
19049
  `,
18987
19050
  "utf-8"
18988
19051
  );
18989
19052
  const encoderForCanonical = stripUndefined(encoder);
18990
19053
  const encoderConfigCanonicalJson = canonicalJsonStringify(encoderForCanonical);
18991
- writeFileSync8(join39(metaDir, "encoder.json"), encoderConfigCanonicalJson, "utf-8");
18992
- writeFileSync8(join39(metaDir, "chunks.json"), `${JSON.stringify(chunks, null, 2)}
19054
+ writeFileSync8(join40(metaDir, "encoder.json"), encoderConfigCanonicalJson, "utf-8");
19055
+ writeFileSync8(join40(metaDir, "chunks.json"), `${JSON.stringify(chunks, null, 2)}
18993
19056
  `, "utf-8");
18994
19057
  const { compositionHtml, assets } = collectPlanAssetShas(planDir, digests);
18995
19058
  const planHash = computePlanHash({
@@ -19014,7 +19077,7 @@ async function freezePlan(input) {
19014
19077
  duration: durationSeconds,
19015
19078
  hasAudio
19016
19079
  };
19017
- const planJsonPath = join39(planDir, "plan.json");
19080
+ const planJsonPath = join40(planDir, "plan.json");
19018
19081
  writeFileSync8(planJsonPath, `${JSON.stringify(planJson, null, 2)}
19019
19082
  `, "utf-8");
19020
19083
  return { planJsonPath, planHash };
@@ -19058,7 +19121,7 @@ function applyRuntimeEnvSnapshot(snapshot, env = process.env) {
19058
19121
  // src/services/distributed/chunkAudio.ts
19059
19122
  import { closeSync as closeSync6, existsSync as existsSync26, ftruncateSync, mkdirSync as mkdirSync15, openSync as openSync6, readFileSync as readFileSync12 } from "node:fs";
19060
19123
  import { writeFileSync as writeFileSync9, writeSync } from "node:fs";
19061
- import { join as join40 } from "node:path";
19124
+ import { join as join41 } from "node:path";
19062
19125
  import { appendRenderProvenanceArgs, describeFfmpegFailure as describeFfmpegFailure4, runFfmpeg as runFfmpeg7 } from "@hyperframes/engine";
19063
19126
  function audioCutForChunk(grid, chunks, index, fps) {
19064
19127
  const firstPacketAt = (frame) => Math.min(
@@ -19146,7 +19209,7 @@ async function writeChunkAudioSlices(input) {
19146
19209
  });
19147
19210
  const bytes = readFileSync12(input.audioPath);
19148
19211
  const layout = { sizeBytes: bytes.length, payloadStart, payloadEnd, partStarts: {} };
19149
- mkdirSync15(join40(input.planDir, SLICE_DIR), { recursive: true });
19212
+ mkdirSync15(join41(input.planDir, SLICE_DIR), { recursive: true });
19150
19213
  input.chunks.forEach((_, index) => {
19151
19214
  const cut = audioCutForChunk(grid, input.chunks, index, input.fps);
19152
19215
  if (!cut) return;
@@ -19154,17 +19217,17 @@ async function writeChunkAudioSlices(input) {
19154
19217
  const start = offsets[cut.firstPacket];
19155
19218
  layout.partStarts[index] = start;
19156
19219
  const end = offsets[last] + track.sizes[last];
19157
- writeFileSync9(join40(input.planDir, chunkAudioSlicePath(index)), bytes.subarray(start, end));
19220
+ writeFileSync9(join41(input.planDir, chunkAudioSlicePath(index)), bytes.subarray(start, end));
19158
19221
  });
19159
19222
  const frame = [bytes.subarray(0, payloadStart), bytes.subarray(payloadEnd)];
19160
- writeFileSync9(join40(input.planDir, SLICE_FRAME), Buffer.concat(frame));
19161
- writeFileSync9(join40(input.planDir, SLICE_LAYOUT), JSON.stringify(layout));
19223
+ writeFileSync9(join41(input.planDir, SLICE_FRAME), Buffer.concat(frame));
19224
+ writeFileSync9(join41(input.planDir, SLICE_LAYOUT), JSON.stringify(layout));
19162
19225
  }
19163
19226
  function chunkAudioSource(planDir, chunkIndex, scratchPath) {
19164
- const layoutPath = join40(planDir, SLICE_LAYOUT);
19227
+ const layoutPath = join41(planDir, SLICE_LAYOUT);
19165
19228
  if (!existsSync26(layoutPath)) return resolvePlanAudioPath(planDir);
19166
19229
  const layout = JSON.parse(readFileSync12(layoutPath, "utf-8"));
19167
- const frame = readFileSync12(join40(planDir, SLICE_FRAME));
19230
+ const frame = readFileSync12(join41(planDir, SLICE_FRAME));
19168
19231
  const fd = openSync6(scratchPath, "w");
19169
19232
  try {
19170
19233
  writeSync(fd, frame, 0, layout.payloadStart, 0);
@@ -19177,7 +19240,7 @@ function chunkAudioSource(planDir, chunkIndex, scratchPath) {
19177
19240
  );
19178
19241
  const start = layout.partStarts[chunkIndex];
19179
19242
  if (start !== void 0) {
19180
- const part = readFileSync12(join40(planDir, chunkAudioSlicePath(chunkIndex)));
19243
+ const part = readFileSync12(join41(planDir, chunkAudioSlicePath(chunkIndex)));
19181
19244
  writeSync(fd, part, 0, part.length, start);
19182
19245
  }
19183
19246
  ftruncateSync(fd, layout.sizeBytes);
@@ -19232,8 +19295,8 @@ async function muxChunkWithAudio(input) {
19232
19295
 
19233
19296
  // src/services/distributed/planSize.ts
19234
19297
  import { createHash as createHash9 } from "node:crypto";
19235
- import { lstatSync as lstatSync3, readdirSync as readdirSync9 } from "node:fs";
19236
- import { extname as extname5, join as join41, relative as relative6 } from "node:path";
19298
+ import { lstatSync as lstatSync4, readdirSync as readdirSync9 } from "node:fs";
19299
+ import { extname as extname5, join as join42, relative as relative6 } from "node:path";
19237
19300
  var MAX_TOP_COMPONENTS = 10;
19238
19301
  var SOURCE_MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
19239
19302
  ".aac",
@@ -19316,7 +19379,7 @@ function addCategoryBytes(result, category, filePath, sizeBytes) {
19316
19379
  function recordFile(result, components, rootDir, rootKind, filePath) {
19317
19380
  let sizeBytes;
19318
19381
  try {
19319
- const stat = lstatSync3(filePath);
19382
+ const stat = lstatSync4(filePath);
19320
19383
  if (!stat.isFile()) return;
19321
19384
  sizeBytes = stat.size;
19322
19385
  } catch {
@@ -19345,7 +19408,7 @@ function walkRegularFiles(dir, visit) {
19345
19408
  return;
19346
19409
  }
19347
19410
  for (const entry of entries) {
19348
- const full = join41(dir, entry.name);
19411
+ const full = join42(dir, entry.name);
19349
19412
  if (entry.isDirectory()) {
19350
19413
  walkRegularFiles(full, visit);
19351
19414
  } else if (entry.isFile()) {
@@ -19561,13 +19624,13 @@ function assertPositiveInteger2(name, value) {
19561
19624
  }
19562
19625
  var FREEZE_OWNED_PLAN_FILES = [
19563
19626
  "plan.json",
19564
- join42("meta", "composition.json"),
19565
- join42("meta", "encoder.json"),
19566
- join42("meta", "chunks.json")
19627
+ join43("meta", "composition.json"),
19628
+ join43("meta", "encoder.json"),
19629
+ join43("meta", "chunks.json")
19567
19630
  ];
19568
19631
  function removeFreezeOwnedPlanFiles(planDir) {
19569
19632
  for (const relativePath of FREEZE_OWNED_PLAN_FILES) {
19570
- rmSync14(join42(planDir, relativePath), { force: true });
19633
+ rmSync14(join43(planDir, relativePath), { force: true });
19571
19634
  }
19572
19635
  }
19573
19636
  function buildChunkSlices(totalFrames, chunkCount, effectiveChunkSize) {
@@ -19725,19 +19788,19 @@ function createVideoSourceShipper(input) {
19725
19788
  const known = shipped.get(srcPath);
19726
19789
  if (known) return known;
19727
19790
  const stagedRel = pathInside(input.workVideoFramesDir, srcPath);
19728
- const current = stagedRel === null ? srcPath : join42(input.planDir, "video-frames", stagedRel);
19791
+ const current = stagedRel === null ? srcPath : join43(input.planDir, "video-frames", stagedRel);
19729
19792
  let result = null;
19730
19793
  for (const root of stagedRel === null ? [input.workCompiledDir, input.projectDir] : []) {
19731
19794
  const rel = pathInside(root, srcPath);
19732
- if (rel !== null && (existsSync27(join42(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
19795
+ if (rel !== null && (existsSync27(join43(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
19733
19796
  result = ["compiled", ...rel.split(sep5)].join("/");
19734
19797
  break;
19735
19798
  }
19736
19799
  }
19737
19800
  if (result === null) {
19738
19801
  result = `video-sources/${shipped.size}${extname6(current)}`;
19739
- const destination = join42(input.planDir, ...result.split("/"));
19740
- mkdirSync16(join42(input.planDir, "video-sources"), { recursive: true });
19802
+ const destination = join43(input.planDir, ...result.split("/"));
19803
+ mkdirSync16(join43(input.planDir, "video-sources"), { recursive: true });
19741
19804
  try {
19742
19805
  linkSync(current, destination);
19743
19806
  } catch {
@@ -19791,14 +19854,14 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
19791
19854
  includeOutsideScripts: options.includeOutsideScripts === true
19792
19855
  });
19793
19856
  const entryFile = config.entryFile ?? "index.html";
19794
- const htmlPath = join42(projectDir, entryFile);
19857
+ const htmlPath = join43(projectDir, entryFile);
19795
19858
  if (!existsSync27(htmlPath)) {
19796
19859
  throw new Error(`[plan] entry file not found: ${htmlPath}`);
19797
19860
  }
19798
- const workDir = join42(planDir, ".plan-work");
19861
+ const workDir = join43(planDir, ".plan-work");
19799
19862
  rmSync14(workDir, { recursive: true, force: true });
19800
19863
  mkdirSync16(workDir, { recursive: true });
19801
- const compiledDir = join42(workDir, "compiled");
19864
+ const compiledDir = join43(workDir, "compiled");
19802
19865
  mkdirSync16(compiledDir, { recursive: true });
19803
19866
  let stageStarted = Date.now();
19804
19867
  cpSync2(projectDir, compiledDir, {
@@ -19818,10 +19881,10 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
19818
19881
  }
19819
19882
  });
19820
19883
  logPlanStage(log, "copy", stageStarted);
19821
- const finalCompiledDir = join42(planDir, "compiled");
19884
+ const finalCompiledDir = join43(planDir, "compiled");
19822
19885
  const needsAlpha = outputNeedsAlpha(config.format);
19823
19886
  const remoteFiles = Object.entries(options.remoteFiles ?? {});
19824
- const remoteLocalPath = (rel) => join42(projectDir, ...rel.split("/"));
19887
+ const remoteLocalPath = (rel) => join43(projectDir, ...rel.split("/"));
19825
19888
  for (const [, file] of remoteFiles) {
19826
19889
  declareContentAddressedUrl(file.url, file.sha256);
19827
19890
  if (file.probeFactsUrl) declareProbeFactsUrl(file.url, file.probeFactsUrl);
@@ -20026,10 +20089,10 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
20026
20089
  let stageStarted = Date.now();
20027
20090
  const extractResult = await extractPlanVideos(c, options.deferVideoExtraction);
20028
20091
  logPlanStage(log, "extract", stageStarted);
20029
- const stagedVideoFrames = join42(compiledDir, "__hyperframes_video_frames");
20030
- const videoFramesDst = join42(planDir, "video-frames");
20092
+ const stagedVideoFrames = join43(compiledDir, "__hyperframes_video_frames");
20093
+ const videoFramesDst = join43(planDir, "video-frames");
20031
20094
  if (existsSync27(videoFramesDst)) rmSync14(videoFramesDst, { recursive: true, force: true });
20032
- const videoSourcesDir = join42(planDir, "video-sources");
20095
+ const videoSourcesDir = join43(planDir, "video-sources");
20033
20096
  rmSync14(videoSourcesDir, { recursive: true, force: true });
20034
20097
  if (existsSync27(stagedVideoFrames)) {
20035
20098
  renameWithRetry8(stagedVideoFrames, videoFramesDst);
@@ -20066,7 +20129,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
20066
20129
  };
20067
20130
  })
20068
20131
  });
20069
- mkdirSync16(join42(planDir, "meta"), { recursive: true });
20132
+ mkdirSync16(join43(planDir, "meta"), { recursive: true });
20070
20133
  writePlanRemoteFiles(
20071
20134
  planDir,
20072
20135
  remoteFiles.map(([rel, { sha256, sizeBytes }]) => ({
@@ -20076,7 +20139,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
20076
20139
  }))
20077
20140
  );
20078
20141
  writeFileSync10(
20079
- join42(planDir, PLAN_VIDEOS_META_RELATIVE_PATH),
20142
+ join43(planDir, PLAN_VIDEOS_META_RELATIVE_PATH),
20080
20143
  JSON.stringify(planVideosJson, null, 2),
20081
20144
  "utf-8"
20082
20145
  );
@@ -20156,7 +20219,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
20156
20219
  if (audioResult?.audioError) {
20157
20220
  applyDistributedAudioWarningPolicy(job, audioResult.audioError, audioResult.audioFailures, log);
20158
20221
  }
20159
- const planAudioPath = join42(planDir, PLAN_AUDIO_RELATIVE_PATH);
20222
+ const planAudioPath = join43(planDir, PLAN_AUDIO_RELATIVE_PATH);
20160
20223
  if (audioResult?.hasAudio && existsSync27(audioResult.audioOutputPath)) {
20161
20224
  renameWithRetry8(audioResult.audioOutputPath, planAudioPath);
20162
20225
  }
@@ -20283,7 +20346,7 @@ async function plan(projectDir, config, planDir, options = {}) {
20283
20346
  // src/services/distributed/renderChunk.ts
20284
20347
  import { randomBytes } from "node:crypto";
20285
20348
  import { existsSync as existsSync30, mkdirSync as mkdirSync19, readFileSync as readFileSync14, readdirSync as readdirSync11, rmSync as rmSync17, writeFileSync as writeFileSync13 } from "node:fs";
20286
- import { join as join46 } from "node:path";
20349
+ import { join as join47 } from "node:path";
20287
20350
  import {
20288
20351
  assertSwiftShader,
20289
20352
  BROWSER_GPU_NOT_SOFTWARE as BROWSER_GPU_NOT_SOFTWARE4,
@@ -20310,16 +20373,16 @@ import {
20310
20373
  import {
20311
20374
  copyFileSync as copyFileSync8,
20312
20375
  existsSync as existsSync29,
20313
- lstatSync as lstatSync4,
20376
+ lstatSync as lstatSync5,
20314
20377
  mkdirSync as mkdirSync18,
20315
20378
  readFileSync as readFileSync13,
20316
20379
  readdirSync as readdirSync10,
20317
20380
  rmSync as rmSync16,
20318
- statSync as statSync13,
20381
+ statSync as statSync12,
20319
20382
  writeFileSync as writeFileSync12
20320
20383
  } from "node:fs";
20321
20384
  import { tmpdir as tmpdir4 } from "node:os";
20322
- import { dirname as dirname18, isAbsolute as isAbsolute5, join as join45, relative as relative8, resolve as resolve11, sep as sep6 } from "node:path";
20385
+ import { dirname as dirname18, isAbsolute as isAbsolute5, join as join46, relative as relative8, resolve as resolve11, sep as sep6 } from "node:path";
20323
20386
  import { DISTRIBUTED_FPS, isDistributedFps } from "@hyperframes/core";
20324
20387
  import {
20325
20388
  createFrameLookupTable as createFrameLookupTable5,
@@ -20334,11 +20397,11 @@ import {
20334
20397
  linkSync as linkSync2,
20335
20398
  mkdirSync as mkdirSync17,
20336
20399
  rmSync as rmSync15,
20337
- statSync as statSync12,
20400
+ statSync as statSync11,
20338
20401
  writeFileSync as writeFileSync11
20339
20402
  } from "node:fs";
20340
20403
  import { renameWithRetry as renameWithRetry9 } from "@hyperframes/engine";
20341
- import { dirname as dirname17, join as join44 } from "node:path";
20404
+ import { dirname as dirname17, join as join45 } from "node:path";
20342
20405
 
20343
20406
  // src/services/distributed/planV2Errors.ts
20344
20407
  var PLAN_V2_INTEGRITY_UNRECOVERABLE = "PLAN_V2_INTEGRITY_UNRECOVERABLE";
@@ -20353,7 +20416,7 @@ var PlanV2IntegrityError = class extends Error {
20353
20416
  };
20354
20417
 
20355
20418
  // src/services/distributed/planV2Layout.ts
20356
- import { join as join43 } from "node:path";
20419
+ import { join as join44 } from "node:path";
20357
20420
  var SHA256_PATTERN = /^[0-9a-f]{64}$/;
20358
20421
  function assertPlanV2Sha256(value, field) {
20359
20422
  if (typeof value !== "string" || !SHA256_PATTERN.test(value)) {
@@ -20363,7 +20426,7 @@ function assertPlanV2Sha256(value, field) {
20363
20426
  }
20364
20427
  function planV2BlobPath(root, sha256) {
20365
20428
  const digest = assertPlanV2Sha256(sha256, "artifact sha256");
20366
- return join43(root, "artifacts", "sha256", digest.slice(0, 2), digest);
20429
+ return join44(root, "artifacts", "sha256", digest.slice(0, 2), digest);
20367
20430
  }
20368
20431
 
20369
20432
  // src/services/distributed/planV2Publisher.ts
@@ -20404,7 +20467,7 @@ var LocalPlanV2ArtifactPublisher = class {
20404
20467
  }
20405
20468
  async putBlob(blob) {
20406
20469
  const digest = assertPlanV2Sha256(blob.sha256, "published blob sha256");
20407
- const sourceSize = statSync12(blob.sourcePath).size;
20470
+ const sourceSize = statSync11(blob.sourcePath).size;
20408
20471
  if (sourceSize !== blob.sizeBytes) {
20409
20472
  throw new PlanV2IntegrityError(
20410
20473
  `published blob size changed for ${digest}: expected ${blob.sizeBytes}, got ${sourceSize}`
@@ -20414,7 +20477,7 @@ var LocalPlanV2ArtifactPublisher = class {
20414
20477
  if (existsSync28(destinationPath)) return;
20415
20478
  mkdirSync17(dirname17(destinationPath), { recursive: true });
20416
20479
  const stagingDir = createStagingDir5(dirname17(destinationPath), ".plan-v2-blob-");
20417
- const temporaryPath = join44(stagingDir, "blob");
20480
+ const temporaryPath = join45(stagingDir, "blob");
20418
20481
  try {
20419
20482
  try {
20420
20483
  this.#linkFile(blob.sourcePath, temporaryPath);
@@ -20435,7 +20498,7 @@ var LocalPlanV2ArtifactPublisher = class {
20435
20498
  );
20436
20499
  }
20437
20500
  }
20438
- writeFileSync11(join44(this.temporaryDir, "plan.json"), manifestBytes, "utf-8");
20501
+ writeFileSync11(join45(this.temporaryDir, "plan.json"), manifestBytes, "utf-8");
20439
20502
  renameWithRetry9(this.temporaryDir, this.destinationDir);
20440
20503
  this.#committed = true;
20441
20504
  }
@@ -20481,7 +20544,7 @@ function listFiles(root) {
20481
20544
  const rootResolved = resolve11(root);
20482
20545
  function walk(dir) {
20483
20546
  for (const entry of readdirSync10(dir, { withFileTypes: true })) {
20484
- const absolutePath = join45(dir, entry.name);
20547
+ const absolutePath = join46(dir, entry.name);
20485
20548
  if (entry.isDirectory()) {
20486
20549
  walk(absolutePath);
20487
20550
  } else if (entry.isFile()) {
@@ -20500,7 +20563,7 @@ function listFiles(root) {
20500
20563
  return files.sort((a, b) => a.path.localeCompare(b.path));
20501
20564
  }
20502
20565
  function assertValidExtractionCacheCompleteSentinel(path) {
20503
- const sentinel = lstatSync4(path);
20566
+ const sentinel = lstatSync5(path);
20504
20567
  if (!sentinel.isFile() || sentinel.size !== 0) {
20505
20568
  throw new PlanV2IntegrityError(
20506
20569
  `${EXTRACTION_CACHE_COMPLETE_SENTINEL} must be a zero-byte regular file`
@@ -20508,13 +20571,13 @@ function assertValidExtractionCacheCompleteSentinel(path) {
20508
20571
  }
20509
20572
  }
20510
20573
  function validateExtractionCacheCompleteSentinels(executionPlanDir) {
20511
- const videoRoot = join45(executionPlanDir, "video-frames");
20574
+ const videoRoot = join46(executionPlanDir, "video-frames");
20512
20575
  if (!existsSync29(videoRoot)) return;
20513
20576
  for (const videoEntry of readdirSync10(videoRoot, { withFileTypes: true })) {
20514
20577
  if (!videoEntry.isDirectory()) continue;
20515
- const videoDir = join45(videoRoot, videoEntry.name);
20578
+ const videoDir = join46(videoRoot, videoEntry.name);
20516
20579
  if (readdirSync10(videoDir).includes(EXTRACTION_CACHE_COMPLETE_SENTINEL)) {
20517
- const sentinelPath = join45(videoDir, EXTRACTION_CACHE_COMPLETE_SENTINEL);
20580
+ const sentinelPath = join46(videoDir, EXTRACTION_CACHE_COMPLETE_SENTINEL);
20518
20581
  assertValidExtractionCacheCompleteSentinel(sentinelPath);
20519
20582
  }
20520
20583
  }
@@ -20561,7 +20624,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
20561
20624
  if (video.deferredRange) {
20562
20625
  const framePaths2 = /* @__PURE__ */ new Map();
20563
20626
  for (let index = 0; index < video.totalFrames; index++) {
20564
- framePaths2.set(index, join45(outputDir, String(index)));
20627
+ framePaths2.set(index, join46(outputDir, String(index)));
20565
20628
  }
20566
20629
  return { ...video, outputDir, framePaths: framePaths2, ownedByLookup: false };
20567
20630
  }
@@ -20569,7 +20632,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
20569
20632
  const framePaths = /* @__PURE__ */ new Map();
20570
20633
  for (const frameName of frameNames) {
20571
20634
  if (frameName === EXTRACTION_CACHE_COMPLETE_SENTINEL) {
20572
- assertValidExtractionCacheCompleteSentinel(join45(outputDir, frameName));
20635
+ assertValidExtractionCacheCompleteSentinel(join46(outputDir, frameName));
20573
20636
  continue;
20574
20637
  }
20575
20638
  const match = /(\d+)(?=\.[^.]+$)/.exec(frameName);
@@ -20588,7 +20651,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
20588
20651
  `duplicate extracted frame index ${frameIndex} in ${outputDir}`
20589
20652
  );
20590
20653
  }
20591
- framePaths.set(frameIndex, join45(outputDir, frameName));
20654
+ framePaths.set(frameIndex, join46(outputDir, frameName));
20592
20655
  }
20593
20656
  return {
20594
20657
  ...video,
@@ -20609,7 +20672,7 @@ function parsePlanVideosJson2(value) {
20609
20672
  }
20610
20673
  }
20611
20674
  function materializeExtractedVideoDirectories(planDir) {
20612
- const videosPath = join45(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
20675
+ const videosPath = join46(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
20613
20676
  if (!existsSync29(videosPath)) return;
20614
20677
  const videos = parsePlanVideosJson2(readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH));
20615
20678
  for (const video of videos.extracted) {
@@ -20643,13 +20706,13 @@ function parseChunkSlices(value) {
20643
20706
  });
20644
20707
  }
20645
20708
  function buildVideoChunkDependencies(executionPlanDir, dimensions) {
20646
- const videoRoot = join45(executionPlanDir, "video-frames");
20709
+ const videoRoot = join46(executionPlanDir, "video-frames");
20647
20710
  const hasExtractedFrames = existsSync29(videoRoot) && listFiles(videoRoot).length > 0;
20648
- const videosPath = join45(executionPlanDir, PLAN_VIDEOS_META_RELATIVE_PATH);
20711
+ const videosPath = join46(executionPlanDir, PLAN_VIDEOS_META_RELATIVE_PATH);
20649
20712
  if (!existsSync29(videosPath)) {
20650
20713
  return hasExtractedFrames ? { mode: "full-source-pack", dependencies: null } : { mode: "exact-rendered-frames", dependencies: /* @__PURE__ */ new Map() };
20651
20714
  }
20652
- const chunksPath = join45(executionPlanDir, "meta", "chunks.json");
20715
+ const chunksPath = join46(executionPlanDir, "meta", "chunks.json");
20653
20716
  const videos = readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH);
20654
20717
  const chunks = readJsonFile(chunksPath, "meta/chunks.json");
20655
20718
  const parsedVideos = parsePlanVideosJson2(videos);
@@ -20706,7 +20769,7 @@ function writeBlob(sourcePath, destinationPath) {
20706
20769
  if (existsSync29(destinationPath)) return;
20707
20770
  mkdirSync18(dirname18(destinationPath), { recursive: true });
20708
20771
  const temporaryDir = createStagingDir6(dirname18(destinationPath), ".plan-v2-blob-");
20709
- const temporaryPath = join45(temporaryDir, "blob");
20772
+ const temporaryPath = join46(temporaryDir, "blob");
20710
20773
  try {
20711
20774
  copyFileSync8(sourcePath, temporaryPath);
20712
20775
  renameWithRetry10(temporaryPath, destinationPath);
@@ -20718,7 +20781,7 @@ function publishBlobFor(absolutePath, digests) {
20718
20781
  return {
20719
20782
  sourcePath: absolutePath,
20720
20783
  sha256: planFileSha256(absolutePath, digests),
20721
- sizeBytes: statSync13(absolutePath).size
20784
+ sizeBytes: statSync12(absolutePath).size
20722
20785
  };
20723
20786
  }
20724
20787
  async function putBlobs(publisher, blobs) {
@@ -20742,7 +20805,7 @@ async function putTasks(tasks) {
20742
20805
  if (failure) throw failure.reason;
20743
20806
  }
20744
20807
  function buildPlanV2Publication(executionPlanDir, digests) {
20745
- const executionPlanPath = join45(executionPlanDir, "plan.json");
20808
+ const executionPlanPath = join46(executionPlanDir, "plan.json");
20746
20809
  if (!existsSync29(executionPlanPath)) {
20747
20810
  throw new PlanV2IntegrityError(`execution plan is missing plan.json: ${executionPlanPath}`);
20748
20811
  }
@@ -20770,7 +20833,7 @@ function buildPlanV2Publication(executionPlanDir, digests) {
20770
20833
  }
20771
20834
  validateExtractionCacheCompleteSentinels(executionPlanDir);
20772
20835
  const videoDependencyPlan = buildVideoChunkDependencies(executionPlanDir, dimensions);
20773
- const encoder = readJsonFile(join45(executionPlanDir, "meta", "encoder.json"), "meta/encoder.json");
20836
+ const encoder = readJsonFile(join46(executionPlanDir, "meta", "encoder.json"), "meta/encoder.json");
20774
20837
  const files = listFiles(executionPlanDir);
20775
20838
  const chunkAudio = !isRecord3(encoder) || encoder.chunksCarryAudio !== true ? "none" : files.some((file) => chunkAudioSliceTarget(file.path) !== null) ? "sliced" : "whole";
20776
20839
  for (const file of files) {
@@ -20837,7 +20900,7 @@ function createPlanV2FromExecutionPlan(executionPlanDir, planV2Dir) {
20837
20900
  writeBlob(blob.sourcePath, planV2BlobPath(tempDir, blob.sha256));
20838
20901
  }
20839
20902
  writeFileSync12(
20840
- join45(tempDir, "plan.json"),
20903
+ join46(tempDir, "plan.json"),
20841
20904
  canonicalJsonStringify(publication.manifest),
20842
20905
  "utf-8"
20843
20906
  );
@@ -20889,7 +20952,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
20889
20952
  // artifactTargets ships every compiled/ file to all chunks, so each is in the manifest.
20890
20953
  whileAudioMixes: () => putBlobs(
20891
20954
  publisher,
20892
- listFiles(join45(stagingRoot, "compiled")).map(
20955
+ listFiles(join46(stagingRoot, "compiled")).map(
20893
20956
  (file) => publishBlobFor(file.absolutePath, digests)
20894
20957
  )
20895
20958
  ),
@@ -20930,7 +20993,7 @@ function resultFromManifest(planV2Dir, manifest) {
20930
20993
  isRecord3(executionPlan) ? executionPlan[REFERENCE_BACKGROUND_FIELD3] : void 0
20931
20994
  ),
20932
20995
  planDir: planV2Dir,
20933
- manifestPath: join45(planV2Dir, "plan.json"),
20996
+ manifestPath: join46(planV2Dir, "plan.json"),
20934
20997
  planProtocol: PLAN_PROTOCOL_V2,
20935
20998
  planHash: manifest.planHash,
20936
20999
  sourcePlanV1Hash: getPlanV2ExecutionPlanHash(manifest),
@@ -21066,7 +21129,7 @@ function parsePlanV2Manifest(value) {
21066
21129
  return parsed;
21067
21130
  }
21068
21131
  function readPlanV2Manifest(planV2Dir) {
21069
- const manifestPath = join45(planV2Dir, "plan.json");
21132
+ const manifestPath = join46(planV2Dir, "plan.json");
21070
21133
  if (!existsSync29(manifestPath)) {
21071
21134
  throw new PlanV2IntegrityError(`missing v2 manifest: ${manifestPath}`);
21072
21135
  }
@@ -21089,7 +21152,7 @@ function verifyBlob(planV2Dir, artifact) {
21089
21152
  if (!existsSync29(sourcePath)) {
21090
21153
  throw new PlanV2IntegrityError(`missing content-addressed artifact ${artifact.sha256}`);
21091
21154
  }
21092
- const stats = statSync13(sourcePath);
21155
+ const stats = statSync12(sourcePath);
21093
21156
  if (!stats.isFile() || stats.size !== artifact.sizeBytes) {
21094
21157
  throw new PlanV2IntegrityError(`artifact size mismatch for ${artifact.path}`);
21095
21158
  }
@@ -21115,13 +21178,13 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
21115
21178
  const tempDir = createStagingDir6(dirname18(destinationDir), ".plan-v2-materialize-");
21116
21179
  try {
21117
21180
  for (const { artifact, sourcePath } of verified) {
21118
- const destinationPath = join45(tempDir, ...artifact.path.split("/"));
21181
+ const destinationPath = join46(tempDir, ...artifact.path.split("/"));
21119
21182
  mkdirSync18(dirname18(destinationPath), { recursive: true });
21120
21183
  copyFileSync8(sourcePath, destinationPath);
21121
21184
  }
21122
21185
  if (target.role === "chunk") materializeExtractedVideoDirectories(tempDir);
21123
21186
  writeFileSync12(
21124
- join45(tempDir, PLAN_V2_MATERIALIZATION_MARKER),
21187
+ join46(tempDir, PLAN_V2_MATERIALIZATION_MARKER),
21125
21188
  canonicalJsonStringify({
21126
21189
  manifest,
21127
21190
  target,
@@ -21144,7 +21207,7 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
21144
21207
  // Join the artifact's OWN name, not the current constant: a plan written
21145
21208
  // before the container change carries the legacy name, and materializing it
21146
21209
  // under the new one would point at a file that was never written.
21147
- audioPath: target.role === "assembler" ? audioArtifact ? join45(destinationDir, audioArtifact.path) : null : null
21210
+ audioPath: target.role === "assembler" ? audioArtifact ? join46(destinationDir, audioArtifact.path) : null : null
21148
21211
  };
21149
21212
  }
21150
21213
  function assertRemoteSources(remoteSources, artifacts) {
@@ -21163,7 +21226,7 @@ function validatePlanV2MaterializedTarget(planDir, expectedTarget) {
21163
21226
  return readValidatedPlanV2Materialization(planDir, expectedTarget)?.manifest ?? null;
21164
21227
  }
21165
21228
  function readValidatedPlanV2Materialization(planDir, expectedTarget) {
21166
- const markerPath = join45(planDir, PLAN_V2_MATERIALIZATION_MARKER);
21229
+ const markerPath = join46(planDir, PLAN_V2_MATERIALIZATION_MARKER);
21167
21230
  if (!existsSync29(markerPath)) return null;
21168
21231
  const marker = readJsonFile(markerPath, "materialization marker");
21169
21232
  if (!isRecord3(marker) || !isRecord3(marker.manifest) || !isRecord3(marker.target)) {
@@ -21181,8 +21244,8 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
21181
21244
  assertRemoteSources(remoteSources, required);
21182
21245
  for (const artifact of required) {
21183
21246
  if (Object.hasOwn(remoteSources, artifact.path)) continue;
21184
- const path = join45(planDir, ...artifact.path.split("/"));
21185
- if (!existsSync29(path) || statSync13(path).size !== artifact.sizeBytes) {
21247
+ const path = join46(planDir, ...artifact.path.split("/"));
21248
+ if (!existsSync29(path) || statSync12(path).size !== artifact.sizeBytes) {
21186
21249
  throw new PlanV2IntegrityError(
21187
21250
  `materialized artifact missing or truncated: ${artifact.path}`
21188
21251
  );
@@ -21313,7 +21376,7 @@ function hashChunkOutput(outputPath, kind) {
21313
21376
  if (kind === "file") return sha256Hex(readFileSync14(outputPath));
21314
21377
  const entries = readdirSync11(outputPath).filter((name) => /\.(png|jpg|jpeg)$/i.test(name)).sort();
21315
21378
  const lines = entries.map(
21316
- (name) => `${name}\0${sha256Hex(readFileSync14(join46(outputPath, name)))}`
21379
+ (name) => `${name}\0${sha256Hex(readFileSync14(join47(outputPath, name)))}`
21317
21380
  );
21318
21381
  return sha256Hex(lines.join("\0"));
21319
21382
  }
@@ -21330,9 +21393,9 @@ function resolveLockedVp9CpuUsed(lockedEncoder) {
21330
21393
  async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
21331
21394
  const start = Date.now();
21332
21395
  const log = defaultLogger;
21333
- const planJsonPath = join46(planDir, "plan.json");
21334
- const encoderJsonPath = join46(planDir, "meta", "encoder.json");
21335
- const chunksJsonPath = join46(planDir, "meta", "chunks.json");
21396
+ const planJsonPath = join47(planDir, "plan.json");
21397
+ const encoderJsonPath = join47(planDir, "meta", "encoder.json");
21398
+ const chunksJsonPath = join47(planDir, "meta", "chunks.json");
21336
21399
  if (!existsSync30(planJsonPath)) {
21337
21400
  throw new RenderChunkValidationError(
21338
21401
  MISSING_PLAN_ARTIFACT,
@@ -21358,7 +21421,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
21358
21421
  }
21359
21422
  const encoder = JSON.parse(readFileSync14(encoderJsonPath, "utf-8"));
21360
21423
  const chunks = JSON.parse(readFileSync14(chunksJsonPath, "utf-8"));
21361
- const videosJsonPath = join46(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
21424
+ const videosJsonPath = join47(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
21362
21425
  let planVideos = null;
21363
21426
  if (existsSync30(videosJsonPath)) {
21364
21427
  try {
@@ -21390,7 +21453,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
21390
21453
  }
21391
21454
  const range = resolveChunkFrameRange(slice, chunkIndex, options?.frameRange);
21392
21455
  const framesInChunk = range.endFrame - range.startFrame;
21393
- const compiledDir = join46(planDir, "compiled");
21456
+ const compiledDir = join47(planDir, "compiled");
21394
21457
  if (!existsSync30(compiledDir)) {
21395
21458
  throw new RenderChunkValidationError(
21396
21459
  MISSING_PLAN_ARTIFACT,
@@ -21449,7 +21512,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
21449
21512
  };
21450
21513
  const workDir = `${outputChunkPath}.work.${process.pid}.${randomBytes(4).toString("hex")}`;
21451
21514
  mkdirSync19(workDir, { recursive: true });
21452
- const framesDir = join46(workDir, "captured-frames");
21515
+ const framesDir = join47(workDir, "captured-frames");
21453
21516
  mkdirSync19(framesDir, { recursive: true });
21454
21517
  const videoFramesDir = `${workDir}.video-frames`;
21455
21518
  const chunkFrameNumbers = Array.from({ length: framesInChunk }, (_, i) => range.startFrame + i);
@@ -21474,7 +21537,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
21474
21537
  dimensions: plan2.dimensions,
21475
21538
  encoder,
21476
21539
  videoCount: planVideos?.videos.length ?? 0,
21477
- html: readFileSync14(join46(compiledDir, "index.html"), "utf-8"),
21540
+ html: readFileSync14(join47(compiledDir, "index.html"), "utf-8"),
21478
21541
  // The plan ships a deferred source only to chunks that show it; don't wait on the rest.
21479
21542
  skipReadinessVideoIds: deferredVideos.filter(
21480
21543
  (video) => !shownFrames.get(video.videoId)?.size || remoteVideoIds.has(video.videoId)
@@ -21645,7 +21708,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
21645
21708
  if (isPngSequence) {
21646
21709
  if (!existsSync30(outputChunkPath)) mkdirSync19(outputChunkPath, { recursive: true });
21647
21710
  } else {
21648
- const outDir = join46(outputChunkPath, "..");
21711
+ const outDir = join47(outputChunkPath, "..");
21649
21712
  if (!existsSync30(outDir)) mkdirSync19(outDir, { recursive: true });
21650
21713
  }
21651
21714
  const encodeInput = {
@@ -21922,10 +21985,10 @@ async function renderSpan(projectDir, config, span, outputPath, options = {}) {
21922
21985
  if (config.cfr === true) {
21923
21986
  throw new RenderSpanUnsupportedError("--start/--end cannot be combined with a cfr re-encode.");
21924
21987
  }
21925
- const workDir = mkdtempSync(join47(tmpdir5(), "hf-render-span-"));
21988
+ const workDir = mkdtempSync(join48(tmpdir5(), "hf-render-span-"));
21926
21989
  try {
21927
- const planDir = join47(workDir, "plan");
21928
- const partsDir = join47(workDir, "parts");
21990
+ const planDir = join48(workDir, "plan");
21991
+ const partsDir = join48(workDir, "parts");
21929
21992
  mkdirSync20(partsDir, { recursive: true });
21930
21993
  const planned = await plan(
21931
21994
  projectDir,
@@ -21944,7 +22007,7 @@ async function renderSpan(projectDir, config, span, outputPath, options = {}) {
21944
22007
  planned.totalFrames
21945
22008
  );
21946
22009
  const slices = JSON.parse(
21947
- readFileSync15(join47(planDir, "meta", "chunks.json"), "utf-8")
22010
+ readFileSync15(join48(planDir, "meta", "chunks.json"), "utf-8")
21948
22011
  );
21949
22012
  const parts = [];
21950
22013
  for (const slice of slices) {
@@ -21954,7 +22017,7 @@ async function renderSpan(projectDir, config, span, outputPath, options = {}) {
21954
22017
  };
21955
22018
  if (range.endFrame <= range.startFrame) continue;
21956
22019
  throwIfAborted(config.abortSignal);
21957
- const part = join47(partsDir, `part-${String(parts.length).padStart(4, "0")}.mp4`);
22020
+ const part = join48(partsDir, `part-${String(parts.length).padStart(4, "0")}.mp4`);
21958
22021
  await renderChunk(planDir, slice.index, part, { frameRange: range });
21959
22022
  parts.push(part);
21960
22023
  }
@@ -22612,13 +22675,13 @@ import {
22612
22675
  import {
22613
22676
  existsSync as existsSync33,
22614
22677
  mkdirSync as mkdirSync21,
22615
- statSync as statSync15,
22678
+ statSync as statSync14,
22616
22679
  mkdtempSync as mkdtempSync2,
22617
22680
  writeFileSync as writeFileSync14,
22618
22681
  rmSync as rmSync19,
22619
- createReadStream as createReadStream5
22682
+ createReadStream as createReadStream6
22620
22683
  } from "node:fs";
22621
- import { resolve as resolve13, dirname as dirname21, join as join50 } from "node:path";
22684
+ import { resolve as resolve13, dirname as dirname21, join as join51 } from "node:path";
22622
22685
  import { tmpdir as tmpdir6 } from "node:os";
22623
22686
  import { parseArgs } from "node:util";
22624
22687
  import { isIP } from "node:net";
@@ -22637,13 +22700,13 @@ import { isSafePath as isSafePath3 } from "@hyperframes/core/safe-path";
22637
22700
  import {
22638
22701
  existsSync as existsSync31,
22639
22702
  readFileSync as readFileSync16,
22640
- statSync as statSync14,
22703
+ statSync as statSync13,
22641
22704
  openSync as openSync7,
22642
22705
  fstatSync as fstatSync3,
22643
22706
  closeSync as closeSync7,
22644
22707
  constants as constants3
22645
22708
  } from "node:fs";
22646
- import { resolve as resolve12, join as join48, relative as relative9, isAbsolute as isAbsolute6, sep as sep7, dirname as dirname19 } from "node:path";
22709
+ import { resolve as resolve12, join as join49, relative as relative9, isAbsolute as isAbsolute6, sep as sep7, dirname as dirname19 } from "node:path";
22647
22710
  import { fileURLToPath as fileURLToPath6 } from "node:url";
22648
22711
  import { Worker as Worker2 } from "node:worker_threads";
22649
22712
  function isStringRecord(value) {
@@ -22678,7 +22741,7 @@ function readEntryHtml(filePath) {
22678
22741
  } catch (error) {
22679
22742
  if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
22680
22743
  return null;
22681
- if (!statSync14(filePath, { throwIfNoEntry: false })?.isFile()) return null;
22744
+ if (!statSync13(filePath, { throwIfNoEntry: false })?.isFile()) return null;
22682
22745
  throw error;
22683
22746
  }
22684
22747
  try {
@@ -22694,7 +22757,7 @@ function leavesProject(absProjectDir, absoluteEntryPath, isAllowedEntry) {
22694
22757
  }
22695
22758
  function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
22696
22759
  const absProjectDir = resolve12(projectDir);
22697
- if (!existsSync31(absProjectDir) || !statSync14(absProjectDir).isDirectory()) {
22760
+ if (!existsSync31(absProjectDir) || !statSync13(absProjectDir).isDirectory()) {
22698
22761
  return { error: `Project directory not found: ${absProjectDir}` };
22699
22762
  }
22700
22763
  const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
@@ -22715,7 +22778,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
22715
22778
  }
22716
22779
  }
22717
22780
  return {
22718
- error: `No HTML entry file found in project directory: ${join48(absProjectDir, preferredEntryFile || "index.html")}`
22781
+ error: `No HTML entry file found in project directory: ${join49(absProjectDir, preferredEntryFile || "index.html")}`
22719
22782
  };
22720
22783
  }
22721
22784
  function prepareHyperframeLintBody(body, isAllowedEntry) {
@@ -22784,7 +22847,7 @@ function freeLintSlot() {
22784
22847
  function resolveLintWorkerEntry() {
22785
22848
  const here = dirname19(fileURLToPath6(import.meta.url));
22786
22849
  for (const name of ["hyperframeLintWorker.js", "hyperframeLintWorker.ts"]) {
22787
- const candidate = join48(here, name);
22850
+ const candidate = join49(here, name);
22788
22851
  if (existsSync31(candidate)) return candidate;
22789
22852
  }
22790
22853
  return void 0;
@@ -22855,7 +22918,7 @@ async function runHyperframeLint(prepared, options = {}) {
22855
22918
  // src/services/healthWorker.ts
22856
22919
  import { Worker as Worker3 } from "node:worker_threads";
22857
22920
  import { fileURLToPath as fileURLToPath7 } from "node:url";
22858
- import { dirname as dirname20, join as join49 } from "node:path";
22921
+ import { dirname as dirname20, join as join50 } from "node:path";
22859
22922
  import { existsSync as existsSync32 } from "node:fs";
22860
22923
  var DEFAULT_HEALTH_PORT = 9848;
22861
22924
  async function startHealthWorker(options = {}) {
@@ -22931,7 +22994,7 @@ function defaultLogger2() {
22931
22994
  }
22932
22995
  function resolveWorkerEntry2() {
22933
22996
  const here = dirname20(fileURLToPath7(import.meta.url));
22934
- const candidates = [join49(here, "healthWorkerThread.js"), join49(here, "healthWorkerThread.ts")];
22997
+ const candidates = [join50(here, "healthWorkerThread.js"), join50(here, "healthWorkerThread.ts")];
22935
22998
  for (const candidate of candidates) {
22936
22999
  if (existsSync32(candidate)) return candidate;
22937
23000
  }
@@ -23181,7 +23244,7 @@ function prepareProjectDirectory(projectDir, options, policy) {
23181
23244
  if (!candidate) return null;
23182
23245
  const absProjectDir = policy ? resolve13(policy.projectsDir, candidate) : resolve13(candidate);
23183
23246
  const shown = policy ? candidate : absProjectDir;
23184
- if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync33(absProjectDir) || !statSync15(absProjectDir).isDirectory()) {
23247
+ if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync33(absProjectDir) || !statSync14(absProjectDir).isDirectory()) {
23185
23248
  return { error: `Project directory not found: ${shown}` };
23186
23249
  }
23187
23250
  const entry = options.entryFile || "index.html";
@@ -23207,8 +23270,8 @@ async function resolveInlineRenderHtml(body) {
23207
23270
  }
23208
23271
  function materializeInlineProject(html, options) {
23209
23272
  const tempRoot = process.env.PRODUCER_TMP_PROJECT_DIR || tmpdir6();
23210
- const tempProjectDir = mkdtempSync2(join50(tempRoot, "producer-project-"));
23211
- writeFileSync14(join50(tempProjectDir, "index.html"), html, "utf-8");
23273
+ const tempProjectDir = mkdtempSync2(join51(tempRoot, "producer-project-"));
23274
+ writeFileSync14(join51(tempProjectDir, "index.html"), html, "utf-8");
23212
23275
  return {
23213
23276
  prepared: {
23214
23277
  input: { projectDir: tempProjectDir, ...options },
@@ -23284,7 +23347,7 @@ function publicPerfSummary(job) {
23284
23347
  return job.perfSummary ? { ...job.perfSummary, renderId: void 0 } : null;
23285
23348
  }
23286
23349
  function outputFileSize(path) {
23287
- return existsSync33(path) ? statSync15(path).size : 0;
23350
+ return existsSync33(path) ? statSync14(path).size : 0;
23288
23351
  }
23289
23352
  function createBlockingProgressReporter(log, requestId) {
23290
23353
  let lastLoggedPct = -10;
@@ -23615,8 +23678,8 @@ function createRenderHandlers(options = {}) {
23615
23678
  store.delete(token);
23616
23679
  return c.json({ success: false, error: "Output artifact file missing" }, 404);
23617
23680
  }
23618
- const stats = statSync15(artifact.path);
23619
- return new Response(createReadStream5(artifact.path), {
23681
+ const stats = statSync14(artifact.path);
23682
+ return new Response(createReadStream6(artifact.path), {
23620
23683
  headers: {
23621
23684
  "content-type": "video/mp4",
23622
23685
  "content-length": String(stats.size),
@@ -23802,7 +23865,7 @@ import { quantizeTimeToFrame, MEDIA_VISUAL_STYLE_PROPERTIES } from "@hyperframes
23802
23865
  // src/services/distributed/planV2Execution.ts
23803
23866
  import { mkdtempSync as mkdtempSync3, rmSync as rmSync21 } from "node:fs";
23804
23867
  import { tmpdir as tmpdir7 } from "node:os";
23805
- import { join as join52 } from "node:path";
23868
+ import { join as join53 } from "node:path";
23806
23869
 
23807
23870
  // src/services/distributed/assemble.ts
23808
23871
  import {
@@ -23816,13 +23879,14 @@ import {
23816
23879
  readFileSync as readFileSync17,
23817
23880
  readdirSync as readdirSync12,
23818
23881
  rmSync as rmSync20,
23819
- statSync as statSync16,
23882
+ statSync as statSync15,
23820
23883
  writeFileSync as writeFileSync15
23821
23884
  } from "node:fs";
23822
- import { basename as basename9, dirname as dirname22, join as join51 } from "node:path";
23885
+ import { basename as basename9, dirname as dirname22, join as join52 } from "node:path";
23823
23886
  import {
23824
23887
  appendRateCapArgs as appendRateCapArgs2,
23825
23888
  appendRenderProvenanceArgs as appendRenderProvenanceArgs2,
23889
+ concatListInputArgs,
23826
23890
  describeFfmpegFailure as describeFfmpegFailure5,
23827
23891
  getEncoderPreset as getEncoderPreset6,
23828
23892
  MIXED_AUDIO_FILENAME as MIXED_AUDIO_FILENAME4,
@@ -23861,7 +23925,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
23861
23925
  outputPath,
23862
23926
  durationMs: Date.now() - start,
23863
23927
  framesEncoded: plan2.totalFrames,
23864
- fileSize: statSync16(outputPath).size
23928
+ fileSize: statSync15(outputPath).size
23865
23929
  };
23866
23930
  }
23867
23931
  const format = plan2.dimensions.format;
@@ -23889,7 +23953,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
23889
23953
  };
23890
23954
  try {
23891
23955
  const videoSources = cfrEncoder ? [await reencodeCfr(ctx, chunkPaths, cfrEncoder)] : chunkPaths;
23892
- const finalPath = join51(workDir, `output.${format}`);
23956
+ const finalPath = join52(workDir, `output.${format}`);
23893
23957
  const audio = audioPath !== null && existsSync34(audioPath) ? audioPath : null;
23894
23958
  await writeJoined(ctx, videoSources, audio, finalPath);
23895
23959
  renameWithRetry11(finalPath, outputPath);
@@ -23908,7 +23972,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
23908
23972
  });
23909
23973
  }
23910
23974
  }
23911
- const fileSize = existsSync34(outputPath) ? statSync16(outputPath).size : 0;
23975
+ const fileSize = existsSync34(outputPath) ? statSync15(outputPath).size : 0;
23912
23976
  return {
23913
23977
  ...referenceBackgroundResult8(plan2[REFERENCE_BACKGROUND_FIELD6]),
23914
23978
  outputPath,
@@ -23918,8 +23982,8 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
23918
23982
  };
23919
23983
  }
23920
23984
  function readAssemblePlan(planDir, chunkPaths) {
23921
- const planJsonPath = join51(planDir, "plan.json");
23922
- const chunksJsonPath = join51(planDir, "meta", "chunks.json");
23985
+ const planJsonPath = join52(planDir, "plan.json");
23986
+ const chunksJsonPath = join52(planDir, "meta", "chunks.json");
23923
23987
  if (!existsSync34(planJsonPath)) {
23924
23988
  throw new Error(`[assemble] planDir missing plan.json: ${planJsonPath}`);
23925
23989
  }
@@ -23970,7 +24034,7 @@ function cfrEncodeArgs(inputArgs, encoder, fpsArg) {
23970
24034
  return args;
23971
24035
  }
23972
24036
  async function reencodeCfr(ctx, chunkPaths, encoder) {
23973
- const cfrOutputPath = join51(ctx.workDir, `cfr.${ctx.format}`);
24037
+ const cfrOutputPath = join52(ctx.workDir, `cfr.${ctx.format}`);
23974
24038
  const cfrArgs = cfrEncodeArgs(videoInputArgs(ctx, chunkPaths), encoder, ctx.fpsArg);
23975
24039
  appendRenderProvenanceArgs2(cfrArgs, cfrOutputPath);
23976
24040
  cfrArgs.push("-y", cfrOutputPath);
@@ -23997,7 +24061,7 @@ async function writeJoined(ctx, videoSources, audioPath, finalPath) {
23997
24061
  );
23998
24062
  return;
23999
24063
  }
24000
- const paddedAudioPath = join51(ctx.workDir, "audio-padded.m4a");
24064
+ const paddedAudioPath = join52(ctx.workDir, "audio-padded.m4a");
24001
24065
  const padTrimResult = await ctx.timed(
24002
24066
  "audioMs",
24003
24067
  () => padOrTrimAudioToVideoFrameCount({
@@ -24037,11 +24101,11 @@ async function writeJoined(ctx, videoSources, audioPath, finalPath) {
24037
24101
  }
24038
24102
  }
24039
24103
  function concatDemuxerInput(chunkPaths, workDir, fpsArg) {
24040
- const listPath = join51(workDir, "concat-list.txt");
24104
+ const listPath = join52(workDir, "concat-list.txt");
24041
24105
  const body = chunkPaths.map((path) => `file '${path.replace(/'/g, "'\\''")}'`).join("\n");
24042
24106
  writeFileSync15(listPath, `${body}
24043
24107
  `, "utf-8");
24044
- return ["-r", fpsArg, "-f", "concat", "-safe", "0", "-i", listPath];
24108
+ return ["-r", fpsArg, ...concatListInputArgs(listPath)];
24045
24109
  }
24046
24110
  async function probeJoinedFrameInfo(videoPaths, fps, signal) {
24047
24111
  const infos = await Promise.all(
@@ -24075,11 +24139,11 @@ function stitchesSeparateAudio(planDir) {
24075
24139
  return lockedAudio(planDir).separateAudio === true;
24076
24140
  }
24077
24141
  function planFormat(planDir) {
24078
- const plan2 = JSON.parse(readFileSync17(join51(planDir, "plan.json"), "utf-8"));
24142
+ const plan2 = JSON.parse(readFileSync17(join52(planDir, "plan.json"), "utf-8"));
24079
24143
  return plan2.dimensions.format;
24080
24144
  }
24081
24145
  function lockedAudio(planDir) {
24082
- const encoderJsonPath = join51(planDir, "meta", "encoder.json");
24146
+ const encoderJsonPath = join52(planDir, "meta", "encoder.json");
24083
24147
  if (!existsSync34(encoderJsonPath)) return {};
24084
24148
  return JSON.parse(readFileSync17(encoderJsonPath, "utf-8"));
24085
24149
  }
@@ -24089,7 +24153,7 @@ function readCfrEncoder(planDir, format) {
24089
24153
  `[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.`
24090
24154
  );
24091
24155
  }
24092
- const encoderJsonPath = join51(planDir, "meta", "encoder.json");
24156
+ const encoderJsonPath = join52(planDir, "meta", "encoder.json");
24093
24157
  if (!existsSync34(encoderJsonPath)) {
24094
24158
  throw new Error(`[assemble] planDir missing meta/encoder.json: ${encoderJsonPath}`);
24095
24159
  }
@@ -24106,7 +24170,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
24106
24170
  mkdirSync22(outputPath, { recursive: true });
24107
24171
  let globalIdx = 0;
24108
24172
  for (const chunkDir of chunkPaths) {
24109
- if (!statSync16(chunkDir).isDirectory()) {
24173
+ if (!statSync15(chunkDir).isDirectory()) {
24110
24174
  throw new Error(
24111
24175
  `[assemble] png-sequence chunk must be a directory: ${chunkDir} (got a file)`
24112
24176
  );
@@ -24116,8 +24180,8 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
24116
24180
  throw new Error(`[assemble] png-sequence chunk has no frames: ${chunkDir}`);
24117
24181
  }
24118
24182
  for (const frame of frames) {
24119
- const dst = join51(outputPath, formatExportFrameName(globalIdx, "png"));
24120
- cpSync3(join51(chunkDir, frame), dst);
24183
+ const dst = join52(outputPath, formatExportFrameName(globalIdx, "png"));
24184
+ cpSync3(join52(chunkDir, frame), dst);
24121
24185
  globalIdx += 1;
24122
24186
  }
24123
24187
  }
@@ -24127,13 +24191,13 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
24127
24191
  );
24128
24192
  }
24129
24193
  if (audioPath !== null && existsSync34(audioPath)) {
24130
- const sidecar = join51(outputPath, MIXED_AUDIO_FILENAME4);
24194
+ const sidecar = join52(outputPath, MIXED_AUDIO_FILENAME4);
24131
24195
  cpSync3(audioPath, sidecar);
24132
24196
  }
24133
24197
  let fileSize = 0;
24134
24198
  for (const name of readdirSync12(outputPath)) {
24135
24199
  try {
24136
- fileSize += statSync16(join51(outputPath, name)).size;
24200
+ fileSize += statSync15(join52(outputPath, name)).size;
24137
24201
  } catch {
24138
24202
  }
24139
24203
  }
@@ -24147,8 +24211,8 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
24147
24211
 
24148
24212
  // src/services/distributed/planV2Execution.ts
24149
24213
  async function renderChunkV2(planV2Dir, chunkIndex, outputChunkPath, options) {
24150
- const workRoot = mkdtempSync3(join52(tmpdir7(), "hf-plan-v2-chunk-"));
24151
- const materializedPlanDir = join52(workRoot, "plan");
24214
+ const workRoot = mkdtempSync3(join53(tmpdir7(), "hf-plan-v2-chunk-"));
24215
+ const materializedPlanDir = join53(workRoot, "plan");
24152
24216
  try {
24153
24217
  materializePlanV2Target(planV2Dir, { role: "chunk", chunkIndex }, materializedPlanDir);
24154
24218
  return await renderChunk(materializedPlanDir, chunkIndex, outputChunkPath, options);
@@ -24157,8 +24221,8 @@ async function renderChunkV2(planV2Dir, chunkIndex, outputChunkPath, options) {
24157
24221
  }
24158
24222
  }
24159
24223
  async function assembleV2(planV2Dir, chunkPaths, outputPath, options) {
24160
- const workRoot = mkdtempSync3(join52(tmpdir7(), "hf-plan-v2-assembler-"));
24161
- const materializedPlanDir = join52(workRoot, "plan");
24224
+ const workRoot = mkdtempSync3(join53(tmpdir7(), "hf-plan-v2-assembler-"));
24225
+ const materializedPlanDir = join53(workRoot, "plan");
24162
24226
  try {
24163
24227
  const materialized = materializePlanV2Target(
24164
24228
  planV2Dir,