@hyperframes/producer 0.9.67 → 0.9.69

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.
@@ -20,13 +20,13 @@ function requireOutputDimensions(expected, width, height) {
20
20
  import {
21
21
  existsSync as existsSync26,
22
22
  mkdirSync as mkdirSync13,
23
- statSync as statSync13,
23
+ statSync as statSync12,
24
24
  mkdtempSync,
25
25
  writeFileSync as writeFileSync8,
26
26
  rmSync as rmSync13,
27
- createReadStream as createReadStream3
27
+ createReadStream as createReadStream4
28
28
  } from "node:fs";
29
- import { resolve as resolve11, dirname as dirname18, join as join38 } from "node:path";
29
+ import { resolve as resolve11, dirname as dirname18, join as join39 } from "node:path";
30
30
  import { tmpdir as tmpdir4 } from "node:os";
31
31
  import { parseArgs } from "node:util";
32
32
  import { isIP } from "node:net";
@@ -48,7 +48,7 @@ import {
48
48
  mkdirSync as mkdirSync12,
49
49
  readdirSync as readdirSync6,
50
50
  rmSync as rmSync12,
51
- statSync as statSync11,
51
+ statSync as statSync10,
52
52
  writeFileSync as writeFileSync7,
53
53
  copyFileSync as copyFileSync5,
54
54
  appendFileSync
@@ -395,7 +395,7 @@ import {
395
395
  referenceBackgroundResult,
396
396
  createReferenceBackgroundRecorder
397
397
  } from "@hyperframes/engine";
398
- import { join as join33, dirname as dirname14, resolve as resolve9 } from "path";
398
+ import { join as join34, dirname as dirname14, resolve as resolve9 } from "path";
399
399
  import { totalmem as totalmem2 } from "node:os";
400
400
  import { randomUUID } from "crypto";
401
401
  import { fileURLToPath as fileURLToPath4 } from "url";
@@ -2624,8 +2624,8 @@ function replanAfterFailure(plan, failure) {
2624
2624
  }
2625
2625
 
2626
2626
  // src/services/render/stages/captureSegmentedStage.ts
2627
- import { existsSync as existsSync7, mkdirSync as mkdirSync3, rmSync as rmSync6, statSync as statSync4 } from "node:fs";
2628
- import { join as join10 } from "node:path";
2627
+ import { existsSync as existsSync8, mkdirSync as mkdirSync4, rmSync as rmSync6, statSync as statSync4 } from "node:fs";
2628
+ import { join as join12 } from "node:path";
2629
2629
  import {
2630
2630
  captureFrameToBuffer as captureFrameToBuffer2,
2631
2631
  closeCaptureSession as closeCaptureSession2,
@@ -4312,6 +4312,7 @@ function cleanupEndedHdrVideos(args) {
4312
4312
  }
4313
4313
 
4314
4314
  // src/services/render/segmentPlan.ts
4315
+ import { join as join9 } from "node:path";
4315
4316
  var DEFAULT_SEGMENT_FRAMES = 3e3;
4316
4317
  var MIN_SEGMENT_FRAMES = 30;
4317
4318
  function assertPositiveInteger(name, value) {
@@ -4332,6 +4333,9 @@ function planSegments(totalFrames, segmentFrames) {
4332
4333
  }
4333
4334
  return slices;
4334
4335
  }
4336
+ function segmentOutputPath(segmentDir, index) {
4337
+ return join9(segmentDir, `segment_${String(index).padStart(5, "0")}.mp4`);
4338
+ }
4335
4339
  function resolveSegmentFrames(env) {
4336
4340
  const raw = env.HF_SEGMENT_FRAMES;
4337
4341
  if (raw === void 0 || raw.trim() === "") return DEFAULT_SEGMENT_FRAMES;
@@ -4349,6 +4353,144 @@ function createSegmentQueue(slices) {
4349
4353
  };
4350
4354
  }
4351
4355
 
4356
+ // src/services/render/segmentManifest.ts
4357
+ import { createHash as createHash2, createHmac, timingSafeEqual } from "node:crypto";
4358
+ import {
4359
+ createReadStream as createReadStream2,
4360
+ existsSync as existsSync7,
4361
+ lstatSync as lstatSync3,
4362
+ mkdirSync as mkdirSync3,
4363
+ readFileSync as readFileSync4,
4364
+ writeFileSync as writeFileSync3
4365
+ } from "node:fs";
4366
+ import { join as join10 } from "node:path";
4367
+ import { previewToken } from "@hyperframes/core/preview-proof";
4368
+ import { renameWithRetry as renameWithRetry2 } from "@hyperframes/engine";
4369
+ var MANIFEST_FILENAME = "segments.json";
4370
+ function computeSegmentPlanHash(input) {
4371
+ const ordered = [
4372
+ input.compositionHash,
4373
+ input.cliVersion,
4374
+ String(input.totalFrames),
4375
+ String(input.segmentFrames),
4376
+ `${input.fps.num}/${input.fps.den}`,
4377
+ `${input.width}x${input.height}`,
4378
+ input.codec,
4379
+ input.preset,
4380
+ input.quality === void 0 ? "" : String(input.quality),
4381
+ input.bitrate ?? "",
4382
+ input.pixelFormat ?? "",
4383
+ input.imageFormat,
4384
+ input.useGpu ? "gpu" : "cpu",
4385
+ `${input.outputWidth}x${input.outputHeight}`,
4386
+ input.motionBlur,
4387
+ input.pageMotionBlur ?? "",
4388
+ input.captureQuality === void 0 ? "" : String(input.captureQuality)
4389
+ ];
4390
+ const delivery = [input.maxBitrate, input.bufferSize, input.gopSize].map((v) => v ?? "");
4391
+ if (delivery.some((v) => v !== "")) ordered.push(...delivery.map(String));
4392
+ return createHash2("sha256").update(ordered.join(" ")).digest("hex").slice(0, 16);
4393
+ }
4394
+ function segmentDirFor(projectRendersDir, planHash) {
4395
+ return join10(projectRendersDir, ".hf-segments", planHash);
4396
+ }
4397
+ function hasNumber(value, key) {
4398
+ return key in value && typeof Reflect.get(value, key) === "number";
4399
+ }
4400
+ function hasString(value, key) {
4401
+ return key in value && typeof Reflect.get(value, key) === "string";
4402
+ }
4403
+ function isEntry(value) {
4404
+ if (typeof value !== "object" || value === null) return false;
4405
+ return hasNumber(value, "index") && hasNumber(value, "startFrame") && hasNumber(value, "endFrame") && hasString(value, "path") && hasNumber(value, "bytes") && hasString(value, "sha256") && hasString(value, "completedAt");
4406
+ }
4407
+ function isManifest(value) {
4408
+ if (typeof value !== "object" || value === null) return false;
4409
+ const completed = Reflect.get(value, "completed");
4410
+ return Reflect.get(value, "version") === 1 && hasString(value, "planHash") && hasNumber(value, "totalFrames") && hasNumber(value, "segmentFrames") && Array.isArray(completed) && completed.every(isEntry);
4411
+ }
4412
+ function readSegmentManifest(segmentDir) {
4413
+ const path = join10(segmentDir, MANIFEST_FILENAME);
4414
+ if (!existsSync7(path)) return null;
4415
+ try {
4416
+ const parsed = JSON.parse(readFileSync4(path, "utf-8"));
4417
+ return isManifest(parsed) ? parsed : null;
4418
+ } catch {
4419
+ return null;
4420
+ }
4421
+ }
4422
+ function segmentManifestKey(token = previewToken()) {
4423
+ return token ? createHmac("sha256", token).update("segment-manifest").digest() : null;
4424
+ }
4425
+ function manifestMac(manifest, key) {
4426
+ const signed = [
4427
+ manifest.planHash,
4428
+ manifest.totalFrames,
4429
+ manifest.segmentFrames,
4430
+ manifest.completed.map((e) => [e.index, e.startFrame, e.endFrame, e.bytes, e.sha256])
4431
+ ];
4432
+ return createHmac("sha256", key).update(JSON.stringify(signed)).digest("hex");
4433
+ }
4434
+ function signSegmentManifest(manifest, key) {
4435
+ const { version, planHash, totalFrames, segmentFrames, completed } = manifest;
4436
+ const unsigned = { version, planHash, totalFrames, segmentFrames, completed };
4437
+ return key ? { ...unsigned, mac: manifestMac(unsigned, key) } : unsigned;
4438
+ }
4439
+ function hasValidMac(manifest, key) {
4440
+ if (!key || typeof manifest.mac !== "string") return false;
4441
+ const expected = Buffer.from(manifestMac(manifest, key), "hex");
4442
+ const actual = Buffer.from(manifest.mac, "hex");
4443
+ return actual.length === expected.length && timingSafeEqual(actual, expected);
4444
+ }
4445
+ async function hashSegmentFile(path) {
4446
+ const hash = createHash2("sha256");
4447
+ for await (const chunk of createReadStream2(path)) hash.update(chunk);
4448
+ return hash.digest("hex");
4449
+ }
4450
+ function writeSegmentManifest(segmentDir, manifest, key) {
4451
+ mkdirSync3(segmentDir, { recursive: true });
4452
+ const tmp = join10(segmentDir, `${MANIFEST_FILENAME}.${process.pid}.tmp`);
4453
+ writeFileSync3(tmp, JSON.stringify(signSegmentManifest(manifest, key), null, 2), "utf-8");
4454
+ renameWithRetry2(tmp, join10(segmentDir, MANIFEST_FILENAME));
4455
+ }
4456
+ async function probeSegmentFrameCount(path, probe) {
4457
+ try {
4458
+ const meta = await probe(path);
4459
+ if (!Number.isFinite(meta.videoStreamDurationSeconds) || !Number.isFinite(meta.fps))
4460
+ return null;
4461
+ if (meta.fps <= 0) return null;
4462
+ return Math.round(meta.videoStreamDurationSeconds * meta.fps);
4463
+ } catch {
4464
+ return null;
4465
+ }
4466
+ }
4467
+ function plannedSlice(entry, plan) {
4468
+ const slice = Number.isInteger(entry.index) ? plan[entry.index] : void 0;
4469
+ if (!slice || slice.startFrame !== entry.startFrame || slice.endFrame !== entry.endFrame) {
4470
+ return void 0;
4471
+ }
4472
+ return slice;
4473
+ }
4474
+ function isPlainFileOfSize(path, bytes) {
4475
+ const stat = lstatSync3(path, { throwIfNoEntry: false });
4476
+ return stat !== void 0 && stat.isFile() && stat.size > 0 && stat.size === bytes;
4477
+ }
4478
+ async function validateCompletedSegments(manifest, check) {
4479
+ const ok = /* @__PURE__ */ new Set();
4480
+ if (manifest.planHash !== check.expectedHash || !hasValidMac(manifest, check.key)) return ok;
4481
+ for (const entry of manifest.completed) {
4482
+ const slice = plannedSlice(entry, check.plan);
4483
+ if (!slice) continue;
4484
+ const path = segmentOutputPath(check.segmentDir, slice.index);
4485
+ if (!isPlainFileOfSize(path, entry.bytes)) continue;
4486
+ if (await hashSegmentFile(path) !== entry.sha256) continue;
4487
+ const frames = await check.probeFrames(path);
4488
+ if (frames !== slice.endFrame - slice.startFrame) continue;
4489
+ ok.add(slice.index);
4490
+ }
4491
+ return ok;
4492
+ }
4493
+
4352
4494
  // src/services/render/segmentRecycle.ts
4353
4495
  var DEFAULT_SEGMENT_BROWSER_RECYCLE = 3;
4354
4496
  function resolveSegmentBrowserRecycle(env) {
@@ -4366,7 +4508,7 @@ function isTargetLossError(error) {
4366
4508
  // src/services/render/stages/captureStreamingStage.ts
4367
4509
  import { mkdtemp, writeFile } from "node:fs/promises";
4368
4510
  import { tmpdir as tmpdir2 } from "node:os";
4369
- import { join as join9 } from "node:path";
4511
+ import { join as join11 } from "node:path";
4370
4512
  import {
4371
4513
  DrawElementVerificationError,
4372
4514
  captureFrameToBuffer,
@@ -4589,11 +4731,11 @@ async function verifyDrawElementSample(session, idx, buf, ctx) {
4589
4731
  return;
4590
4732
  }
4591
4733
  if (db < verifyMinDb) {
4592
- const dumpDir = await mkdtemp(join9(tmpdir2(), "hf-de-verify-fail-")).catch(() => null);
4734
+ const dumpDir = await mkdtemp(join11(tmpdir2(), "hf-de-verify-fail-")).catch(() => null);
4593
4735
  if (dumpDir) {
4594
4736
  await Promise.all([
4595
- writeFile(join9(dumpDir, `frame-${idx}-de.jpg`), buf),
4596
- writeFile(join9(dumpDir, `frame-${idx}-truth.jpg`), truth)
4737
+ writeFile(join11(dumpDir, `frame-${idx}-de.jpg`), buf),
4738
+ writeFile(join11(dumpDir, `frame-${idx}-truth.jpg`), truth)
4597
4739
  ]).catch(() => {
4598
4740
  });
4599
4741
  }
@@ -5163,9 +5305,6 @@ async function runCaptureStreamingStage(input) {
5163
5305
  }
5164
5306
 
5165
5307
  // src/services/render/stages/captureSegmentedStage.ts
5166
- function segmentOutputPath(segmentDir, index) {
5167
- return join10(segmentDir, `segment_${String(index).padStart(5, "0")}.mp4`);
5168
- }
5169
5308
  function segmentEncoderOptions(base, segment) {
5170
5309
  return {
5171
5310
  ...base,
@@ -5263,7 +5402,8 @@ async function captureSegmentToEncoder(ctx, segment) {
5263
5402
  path: segmentPath,
5264
5403
  // Recorded so resume can prove the file on disk is the one that
5265
5404
  // finished; absent only in unit tests, whose fake encoder writes none.
5266
- bytes: existsSync7(segmentPath) ? statSync4(segmentPath).size : 0
5405
+ bytes: existsSync8(segmentPath) ? statSync4(segmentPath).size : 0,
5406
+ sha256: existsSync8(segmentPath) ? await hashSegmentFile(segmentPath) : ""
5267
5407
  });
5268
5408
  return encodeResult;
5269
5409
  } finally {
@@ -5497,8 +5637,8 @@ async function runCaptureSegmentedStage(input) {
5497
5637
  const { log, dedupPerfs, assertNotAborted } = input;
5498
5638
  const deps = { ...DEFAULT_DEPS, ...input.deps };
5499
5639
  const segments = planSegments(input.totalFrames, input.segmentFrames);
5500
- const segmentDir = input.segmentDir ?? join10(input.workDir, "segments");
5501
- mkdirSync3(segmentDir, { recursive: true });
5640
+ const segmentDir = input.segmentDir ?? join12(input.workDir, "segments");
5641
+ mkdirSync4(segmentDir, { recursive: true });
5502
5642
  const skip = input.completedSegments ?? /* @__PURE__ */ new Set();
5503
5643
  const pending = segments.filter((s) => !skip.has(s.index));
5504
5644
  for (const index of skip) log.info("[Render] segment skipped (resume)", { index });
@@ -5653,7 +5793,7 @@ function startRenderEtaGuard(options) {
5653
5793
  }
5654
5794
 
5655
5795
  // src/services/render/captureCost.ts
5656
- import { join as join11 } from "node:path";
5796
+ import { join as join13 } from "node:path";
5657
5797
  import { fpsToNumber as fpsToNumber4 } from "@hyperframes/core";
5658
5798
  import {
5659
5799
  calculateOptimalWorkers,
@@ -5906,7 +6046,7 @@ async function runCaptureCalibration(input) {
5906
6046
  });
5907
6047
  let calibration;
5908
6048
  try {
5909
- calibration = await runOneCalibration(join11(workDir, "capture-calibration"), calibrationCfg);
6049
+ calibration = await runOneCalibration(join13(workDir, "capture-calibration"), calibrationCfg);
5910
6050
  } catch (error) {
5911
6051
  const shouldFallback = !forceScreenshot && shouldFallbackToScreenshotAfterCalibrationError(error);
5912
6052
  if (!shouldFallback) {
@@ -5940,7 +6080,7 @@ async function runCaptureCalibration(input) {
5940
6080
  const screenshotCfg = createCaptureCalibrationConfig({ ...cfg, forceScreenshot: true });
5941
6081
  try {
5942
6082
  calibration = await runOneCalibration(
5943
- join11(workDir, "capture-calibration-screenshot"),
6083
+ join13(workDir, "capture-calibration-screenshot"),
5944
6084
  screenshotCfg
5945
6085
  );
5946
6086
  } catch (fallbackError) {
@@ -6004,8 +6144,8 @@ function checkPageNeverReady(input) {
6004
6144
  }
6005
6145
 
6006
6146
  // src/services/render/deferredVideoFrames.ts
6007
- import { mkdirSync as mkdirSync4, rmSync as rmSync7 } from "node:fs";
6008
- import { dirname as dirname5, join as join12 } from "node:path";
6147
+ import { mkdirSync as mkdirSync5, rmSync as rmSync7 } from "node:fs";
6148
+ import { dirname as dirname5, join as join14 } from "node:path";
6009
6149
  import {
6010
6150
  createFrameLookupTable,
6011
6151
  extractVideoFramesRange,
@@ -6050,7 +6190,7 @@ async function extractDeferredFrames(input) {
6050
6190
  const shown = shownDeferredFrameIndexes(input, input.frames, input.fps);
6051
6191
  return Promise.all(
6052
6192
  deferred.map(async (video) => {
6053
- const outputDir = join12(input.outputRoot, mediaIdPathSegment2(video.videoId));
6193
+ const outputDir = join14(input.outputRoot, mediaIdPathSegment2(video.videoId));
6054
6194
  const indexes = [...shown.get(video.videoId) ?? []].sort((a, b) => a - b);
6055
6195
  if (indexes.length === 0) {
6056
6196
  return { ...video, outputDir, framePaths: /* @__PURE__ */ new Map(), ownedByLookup: false };
@@ -6106,7 +6246,7 @@ async function extractAllDeferredFrames(extracted, input) {
6106
6246
  maxTransientRetries: input.maxTransientRetries,
6107
6247
  onRetry: () => {
6108
6248
  rmSync7(video.outputDir, { recursive: true, force: true });
6109
- mkdirSync4(video.outputDir, { recursive: true });
6249
+ mkdirSync5(video.outputDir, { recursive: true });
6110
6250
  }
6111
6251
  }
6112
6252
  );
@@ -6197,14 +6337,14 @@ async function measureLocalShownBoxes(page, videos, fps, duration, log) {
6197
6337
  }
6198
6338
 
6199
6339
  // src/services/render/segmentVideoFrames.ts
6200
- import { mkdirSync as mkdirSync5, rmSync as rmSync8 } from "node:fs";
6201
- import { join as join13 } from "node:path";
6340
+ import { mkdirSync as mkdirSync6, rmSync as rmSync8 } from "node:fs";
6341
+ import { join as join15 } from "node:path";
6202
6342
  import {
6203
6343
  createFrameLookupTable as createFrameLookupTable2,
6204
6344
  createVideoFrameInjector
6205
6345
  } from "@hyperframes/engine";
6206
6346
  function segmentFramesDir(rootDir, index) {
6207
- return join13(rootDir, "segment-frames", `segment_${String(index).padStart(5, "0")}`);
6347
+ return join15(rootDir, "segment-frames", `segment_${String(index).padStart(5, "0")}`);
6208
6348
  }
6209
6349
  function createSegmentVideoFrames(input) {
6210
6350
  const extractFrames = input.extractFrames ?? extractDeferredFrames;
@@ -6235,7 +6375,7 @@ function createSegmentVideoFrames(input) {
6235
6375
  let onDemandCalls = 0;
6236
6376
  const onDemandHook = () => Object.assign(
6237
6377
  async (page, time, heldVideoTime) => {
6238
- const dir = join13(
6378
+ const dir = join15(
6239
6379
  input.rootDir,
6240
6380
  "segment-frames",
6241
6381
  `on-demand_${String(onDemandCalls++).padStart(5, "0")}`
@@ -6252,11 +6392,11 @@ function createSegmentVideoFrames(input) {
6252
6392
  );
6253
6393
  return {
6254
6394
  async forFrames(frames, name) {
6255
- const dir = join13(input.rootDir, "segment-frames", name);
6395
+ const dir = join15(input.rootDir, "segment-frames", name);
6256
6396
  const release = () => rmSync8(dir, { recursive: true, force: true });
6257
6397
  try {
6258
6398
  release();
6259
- mkdirSync5(dir, { recursive: true });
6399
+ mkdirSync6(dir, { recursive: true });
6260
6400
  const table = await tableFor([...frames], dir);
6261
6401
  return { injector: () => createVideoFrameInjector(table, input.injectorOptions), release };
6262
6402
  } catch (error) {
@@ -6285,7 +6425,7 @@ function createSegmentVideoFrames(input) {
6285
6425
  folder = dir;
6286
6426
  try {
6287
6427
  rmSync8(dir, { recursive: true, force: true });
6288
- mkdirSync5(dir, { recursive: true });
6428
+ mkdirSync6(dir, { recursive: true });
6289
6429
  injector = await injectorFor(
6290
6430
  Array.from(
6291
6431
  { length: segment.endFrame - segment.startFrame },
@@ -6305,7 +6445,7 @@ function createSegmentVideoFrames(input) {
6305
6445
 
6306
6446
  // src/services/render/videoFrameWindow.ts
6307
6447
  import { readdirSync as readdirSync3, statSync as statSync5 } from "node:fs";
6308
- import { join as join14 } from "node:path";
6448
+ import { join as join16 } from "node:path";
6309
6449
  function shouldWindowVideoFrames(args) {
6310
6450
  return args.segmented && args.env.HF_VIDEO_FRAME_WINDOW?.trim().toLowerCase() === "true";
6311
6451
  }
@@ -6318,7 +6458,7 @@ function directoryBytes(path) {
6318
6458
  return 0;
6319
6459
  }
6320
6460
  for (const entry of entries) {
6321
- const child2 = join14(path, entry.name);
6461
+ const child2 = join16(path, entry.name);
6322
6462
  try {
6323
6463
  bytes += entry.isDirectory() ? directoryBytes(child2) : statSync5(child2).size;
6324
6464
  } catch {
@@ -6336,7 +6476,7 @@ function trackSegmentFramePeak(frames, rootDir, onPeak) {
6336
6476
  ...worker,
6337
6477
  async prepare(segment) {
6338
6478
  await worker.prepare(segment);
6339
- const held = directoryBytes(join14(rootDir, "segment-frames"));
6479
+ const held = directoryBytes(join16(rootDir, "segment-frames"));
6340
6480
  if (held > peak) {
6341
6481
  peak = held;
6342
6482
  onPeak(peak);
@@ -6347,95 +6487,6 @@ function trackSegmentFramePeak(frames, rootDir, onPeak) {
6347
6487
  };
6348
6488
  }
6349
6489
 
6350
- // src/services/render/segmentManifest.ts
6351
- import { createHash as createHash2 } from "node:crypto";
6352
- import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync4, statSync as statSync6, writeFileSync as writeFileSync3 } from "node:fs";
6353
- import { join as join15 } from "node:path";
6354
- import { renameWithRetry as renameWithRetry2 } from "@hyperframes/engine";
6355
- var MANIFEST_FILENAME = "segments.json";
6356
- function computeSegmentPlanHash(input) {
6357
- const ordered = [
6358
- input.compositionHash,
6359
- input.cliVersion,
6360
- String(input.totalFrames),
6361
- String(input.segmentFrames),
6362
- `${input.fps.num}/${input.fps.den}`,
6363
- `${input.width}x${input.height}`,
6364
- input.codec,
6365
- input.preset,
6366
- input.quality === void 0 ? "" : String(input.quality),
6367
- input.bitrate ?? "",
6368
- input.pixelFormat ?? "",
6369
- input.imageFormat,
6370
- input.useGpu ? "gpu" : "cpu",
6371
- `${input.outputWidth}x${input.outputHeight}`,
6372
- input.motionBlur,
6373
- input.pageMotionBlur ?? "",
6374
- input.captureQuality === void 0 ? "" : String(input.captureQuality)
6375
- ];
6376
- const delivery = [input.maxBitrate, input.bufferSize, input.gopSize].map((v) => v ?? "");
6377
- if (delivery.some((v) => v !== "")) ordered.push(...delivery.map(String));
6378
- return createHash2("sha256").update(ordered.join(" ")).digest("hex").slice(0, 16);
6379
- }
6380
- function segmentDirFor(projectRendersDir, planHash) {
6381
- return join15(projectRendersDir, ".hf-segments", planHash);
6382
- }
6383
- function hasNumber(value, key) {
6384
- return key in value && typeof Reflect.get(value, key) === "number";
6385
- }
6386
- function hasString(value, key) {
6387
- return key in value && typeof Reflect.get(value, key) === "string";
6388
- }
6389
- function isEntry(value) {
6390
- if (typeof value !== "object" || value === null) return false;
6391
- return hasNumber(value, "index") && hasNumber(value, "startFrame") && hasNumber(value, "endFrame") && hasString(value, "path") && hasNumber(value, "bytes") && hasString(value, "completedAt");
6392
- }
6393
- function isManifest(value) {
6394
- if (typeof value !== "object" || value === null) return false;
6395
- const completed = Reflect.get(value, "completed");
6396
- return Reflect.get(value, "version") === 1 && hasString(value, "planHash") && hasNumber(value, "totalFrames") && hasNumber(value, "segmentFrames") && Array.isArray(completed) && completed.every(isEntry);
6397
- }
6398
- function readSegmentManifest(segmentDir) {
6399
- const path = join15(segmentDir, MANIFEST_FILENAME);
6400
- if (!existsSync8(path)) return null;
6401
- try {
6402
- const parsed = JSON.parse(readFileSync4(path, "utf-8"));
6403
- return isManifest(parsed) ? parsed : null;
6404
- } catch {
6405
- return null;
6406
- }
6407
- }
6408
- function writeSegmentManifest(segmentDir, manifest) {
6409
- mkdirSync6(segmentDir, { recursive: true });
6410
- const tmp = join15(segmentDir, `${MANIFEST_FILENAME}.${process.pid}.tmp`);
6411
- writeFileSync3(tmp, JSON.stringify(manifest, null, 2), "utf-8");
6412
- renameWithRetry2(tmp, join15(segmentDir, MANIFEST_FILENAME));
6413
- }
6414
- async function probeSegmentFrameCount(path, probe) {
6415
- try {
6416
- const meta = await probe(path);
6417
- if (!Number.isFinite(meta.videoStreamDurationSeconds) || !Number.isFinite(meta.fps))
6418
- return null;
6419
- if (meta.fps <= 0) return null;
6420
- return Math.round(meta.videoStreamDurationSeconds * meta.fps);
6421
- } catch {
6422
- return null;
6423
- }
6424
- }
6425
- async function validateCompletedSegments(manifest, expectedHash, probeFrames) {
6426
- const ok = /* @__PURE__ */ new Set();
6427
- if (manifest.planHash !== expectedHash) return ok;
6428
- for (const entry of manifest.completed) {
6429
- if (!existsSync8(entry.path)) continue;
6430
- const size = statSync6(entry.path).size;
6431
- if (size <= 0 || size !== entry.bytes) continue;
6432
- const frames = await probeFrames(entry.path);
6433
- if (frames !== entry.endFrame - entry.startFrame) continue;
6434
- ok.add(entry.index);
6435
- }
6436
- return ok;
6437
- }
6438
-
6439
6490
  // src/services/render/hdrMode.ts
6440
6491
  import {
6441
6492
  analyzeCompositionHdr,
@@ -7016,14 +7067,14 @@ function countAuthoredTimedClips(html) {
7016
7067
 
7017
7068
  // src/services/render/stages/compileStage.ts
7018
7069
  import { existsSync as existsSync13, writeFileSync as writeFileSync5 } from "node:fs";
7019
- import { join as join21, relative as relative4 } from "node:path";
7070
+ import { join as join22, relative as relative4 } from "node:path";
7020
7071
  import { privateCacheRoot } from "@hyperframes/engine";
7021
7072
  import { suggestMatchingPreset } from "@hyperframes/core";
7022
7073
  import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
7023
7074
  import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolution";
7024
7075
 
7025
7076
  // src/services/compositionSizeLimit.ts
7026
- import { statSync as statSync7 } from "node:fs";
7077
+ import { statSync as statSync6 } from "node:fs";
7027
7078
  var MAX_COMPOSITION_HTML_BYTES = 16 * 1024 * 1024;
7028
7079
  var COMPOSITION_TOO_LARGE = "COMPOSITION_TOO_LARGE";
7029
7080
  var megabytes = (bytes) => `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
@@ -7099,7 +7150,7 @@ var CompositionExpansionBudget = class {
7099
7150
  function assertCompositionFileSize(path, file) {
7100
7151
  let bytes;
7101
7152
  try {
7102
- const stats = statSync7(path);
7153
+ const stats = statSync6(path);
7103
7154
  if (!stats.isFile()) return;
7104
7155
  bytes = stats.size;
7105
7156
  } catch {
@@ -7124,19 +7175,19 @@ import {
7124
7175
  stylesheetLinkMatches
7125
7176
  } from "@hyperframes/parsers/css-url-scans";
7126
7177
  import { createHash as createHash6 } from "node:crypto";
7127
- import { createReadStream as createReadStream2, existsSync as existsSync12, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
7128
- import { join as join20, dirname as dirname9, resolve as resolve8, basename as basename6, relative as relative3, sep as sep4 } from "path";
7178
+ import { createReadStream as createReadStream3, existsSync as existsSync12, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
7179
+ import { join as join21, dirname as dirname9, resolve as resolve8, basename as basename6, relative as relative3, sep as sep4 } from "path";
7129
7180
  import { parseHTML as parseHTML5 } from "linkedom";
7130
7181
 
7131
7182
  // src/services/bundledScripts.ts
7132
7183
  import { existsSync as existsSync9, readFileSync as readFileSync5 } from "node:fs";
7133
- import { join as join16 } from "node:path";
7184
+ import { join as join17 } from "node:path";
7134
7185
  import { gsapCdnDist } from "@hyperframes/core/gsap-cdn";
7135
7186
  var GSAP_VENDOR_DIR_ENV = "HYPERFRAMES_GSAP_VENDOR_DIR";
7136
7187
  function bundledScript(url) {
7137
7188
  const dir = process.env[GSAP_VENDOR_DIR_ENV];
7138
7189
  if (!dir || url !== `${gsapCdnDist()}gsap.min.js`) return null;
7139
- const file = join16(dir, "gsap.min.js");
7190
+ const file = join17(dir, "gsap.min.js");
7140
7191
  return existsSync9(file) ? readFileSync5(file) : null;
7141
7192
  }
7142
7193
 
@@ -7395,8 +7446,8 @@ import {
7395
7446
 
7396
7447
  // src/services/animatedGifPrep.ts
7397
7448
  import { createHash as createHash4 } from "node:crypto";
7398
- import { copyFileSync as copyFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync8 } from "node:fs";
7399
- import { dirname as dirname6, isAbsolute as isAbsolute3, join as join17, resolve as resolve6 } from "node:path";
7449
+ import { copyFileSync as copyFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync7 } from "node:fs";
7450
+ import { dirname as dirname6, isAbsolute as isAbsolute3, join as join18, resolve as resolve6 } from "node:path";
7400
7451
  import { parseHTML as parseHTML3 } from "linkedom";
7401
7452
  import { parseAnimatedGifMetadata } from "@hyperframes/core";
7402
7453
  import {
@@ -7454,7 +7505,7 @@ function resolveLocalImageSourcePath(src, options) {
7454
7505
  }
7455
7506
  function isUsableFile(path) {
7456
7507
  try {
7457
- const stat = statSync8(path);
7508
+ const stat = statSync7(path);
7458
7509
  return stat.isFile() && stat.size > 0;
7459
7510
  } catch {
7460
7511
  return false;
@@ -7649,7 +7700,7 @@ function replaceImageWithVideo(input) {
7649
7700
  return video;
7650
7701
  }
7651
7702
  async function prepareAnimatedGifInputs(html, options) {
7652
- const outputDir = options.outputDir ?? join17(options.downloadDir, PREPARED_GIF_SUBDIR);
7703
+ const outputDir = options.outputDir ?? join18(options.downloadDir, PREPARED_GIF_SUBDIR);
7653
7704
  const outputSrcPrefix = normalizeRelPath(options.outputSrcPrefix ?? PREPARED_GIF_SUBDIR);
7654
7705
  const cacheDir = options.cacheDir ?? outputDir;
7655
7706
  const { document: document2 } = parseHTML3(html);
@@ -7676,8 +7727,8 @@ async function prepareAnimatedGifInputs(html, options) {
7676
7727
  );
7677
7728
  const hash = computePreparedGifHash(bytes, loopIterations, padSeconds);
7678
7729
  const filename = `${CACHE_SCHEMA}-${hash.slice(0, 24)}.webm`;
7679
- const cachePath = join17(cacheDir, filename);
7680
- const outputPath = join17(outputDir, filename);
7730
+ const cachePath = join18(cacheDir, filename);
7731
+ const outputPath = join18(outputDir, filename);
7681
7732
  const outputSrc = `${outputSrcPrefix}/${filename}`;
7682
7733
  await ensurePreparedWebm({
7683
7734
  sourcePath,
@@ -7719,10 +7770,10 @@ import {
7719
7770
  readFileSync as readFileSync7,
7720
7771
  readSync as readSync3,
7721
7772
  rmSync as rmSync10,
7722
- statSync as statSync9,
7773
+ statSync as statSync8,
7723
7774
  writeFileSync as writeFileSync4
7724
7775
  } from "node:fs";
7725
- import { dirname as dirname7, join as join18, resolve as resolve7 } from "node:path";
7776
+ import { dirname as dirname7, join as join19, resolve as resolve7 } from "node:path";
7726
7777
  import { parseHTML as parseHTML4 } from "linkedom";
7727
7778
  import { renameWithRetry as renameWithRetry4, runFfmpeg as runFfmpeg3, runFfprobe, urlInputArgs as urlInputArgs3 } from "@hyperframes/engine";
7728
7779
 
@@ -7963,7 +8014,7 @@ function resolveImageSource(src, options) {
7963
8014
  }
7964
8015
  function isUsableFile2(path) {
7965
8016
  try {
7966
- return statSync9(path).size > 0;
8017
+ return statSync8(path).size > 0;
7967
8018
  } catch {
7968
8019
  return false;
7969
8020
  }
@@ -7997,7 +8048,7 @@ async function ensurePreparedJpeg(source, cachePath, outputPath, options) {
7997
8048
  }
7998
8049
  }
7999
8050
  async function prepareHeifImageInputs(html, options) {
8000
- const outputDir = options.outputDir ?? join18(options.downloadDir, PREPARED_HEIF_SUBDIR);
8051
+ const outputDir = options.outputDir ?? join19(options.downloadDir, PREPARED_HEIF_SUBDIR);
8001
8052
  const outputSrcPrefix = normalizeRelPath(options.outputSrcPrefix ?? PREPARED_HEIF_SUBDIR);
8002
8053
  const cacheDir = options.cacheDir ?? outputDir;
8003
8054
  const preparedAssets = /* @__PURE__ */ new Map();
@@ -8018,7 +8069,7 @@ async function prepareHeifImageInputs(html, options) {
8018
8069
  await Promise.all(
8019
8070
  [...unique].map(
8020
8071
  ([filename, source]) => withMediaProbeSlot(
8021
- () => ensurePreparedJpeg(source, join18(cacheDir, filename), join18(outputDir, filename), options)
8072
+ () => ensurePreparedJpeg(source, join19(cacheDir, filename), join19(outputDir, filename), options)
8022
8073
  ).catch((error) => {
8023
8074
  if (!options.onFailure) throw error;
8024
8075
  failed.add(filename);
@@ -8030,19 +8081,22 @@ async function prepareHeifImageInputs(html, options) {
8030
8081
  if (failed.has(filename)) continue;
8031
8082
  const outputSrc = `${outputSrcPrefix}/${filename}`;
8032
8083
  img.setAttribute("src", outputSrc);
8033
- preparedAssets.set(outputSrc, join18(outputDir, filename));
8034
- preparedImages.push({ sourceSrc: src, outputSrc, outputPath: join18(outputDir, filename) });
8084
+ preparedAssets.set(outputSrc, join19(outputDir, filename));
8085
+ preparedImages.push({ sourceSrc: src, outputSrc, outputPath: join19(outputDir, filename) });
8035
8086
  }
8036
8087
  return { html: document2.toString(), preparedAssets, preparedImages };
8037
8088
  }
8038
8089
 
8039
8090
  // src/services/htmlCompiler.ts
8040
- import { createStudioPositionSeekReapplyScript } from "@hyperframes/studio-server/manual-edits-render-script";
8091
+ import {
8092
+ createStudioPositionSeekReapplyScript,
8093
+ htmlHasStudioPositionEdits
8094
+ } from "@hyperframes/studio-server/manual-edits-render-script";
8041
8095
  import { getPositionEditsRenderScript } from "@hyperframes/core/runtime/position-edits-render";
8042
8096
 
8043
8097
  // src/services/assetMediaType.ts
8044
8098
  import { existsSync as existsSync11 } from "node:fs";
8045
- import { dirname as dirname8, join as join19 } from "node:path";
8099
+ import { dirname as dirname8, join as join20 } from "node:path";
8046
8100
  import {
8047
8101
  fingerprintElementId,
8048
8102
  isHttpUrl as isHttpUrl2,
@@ -8095,11 +8149,11 @@ function assertAssetMediaTypeProfile(expected, profile, elementIdentity) {
8095
8149
  ]);
8096
8150
  }
8097
8151
  function mediaAssetRoots(projectDir, compiledDir) {
8098
- return [projectDir, compiledDir, join19(dirname8(compiledDir), "downloads")];
8152
+ return [projectDir, compiledDir, join20(dirname8(compiledDir), "downloads")];
8099
8153
  }
8100
8154
  function dropMediaOutsideProject(input) {
8101
8155
  const { projectDir, workDir, composition, log } = input;
8102
- const compiledDir = join19(workDir, "compiled");
8156
+ const compiledDir = join20(workDir, "compiled");
8103
8157
  const roots = mediaAssetRoots(projectDir, compiledDir);
8104
8158
  const staysInside = ({ id, src }) => {
8105
8159
  if (!src || isHttpUrl2(src)) return true;
@@ -8450,7 +8504,7 @@ function detectShaderTransitionUsage(html) {
8450
8504
  async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, baseDir, downloadDir, tagName, elementIdentity, log, urlByAbsentLocalPath, probes, assetRoot) {
8451
8505
  let filePath = src;
8452
8506
  if (isHttpUrl(src)) {
8453
- const remoteDir = join20(downloadDir, REMOTE_MEDIA_SUBDIR);
8507
+ const remoteDir = join21(downloadDir, REMOTE_MEDIA_SUBDIR);
8454
8508
  if (!existsSync12(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
8455
8509
  try {
8456
8510
  filePath = await downloadToTemp(src, remoteDir, void 0, void 0, void 0, {
@@ -8461,7 +8515,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, b
8461
8515
  }
8462
8516
  } else {
8463
8517
  filePath = decodedUrlPath(src);
8464
- if (!filePath.startsWith("/")) filePath = join20(baseDir, filePath);
8518
+ if (!filePath.startsWith("/")) filePath = join21(baseDir, filePath);
8465
8519
  if (escapesAssetRoot(filePath, assetRoot) || isPrivateUnderAssetRoots3(filePath, [projectDir, downloadDir])) {
8466
8520
  return { duration: null, resolvedPath: filePath };
8467
8521
  }
@@ -9195,7 +9249,7 @@ async function localizeRemoteMediaSources(html, downloadDir) {
9195
9249
  const localized = await downloadAndRewriteUrls(
9196
9250
  urlSet,
9197
9251
  html,
9198
- join20(downloadDir, REMOTE_MEDIA_SUBDIR),
9252
+ join21(downloadDir, REMOTE_MEDIA_SUBDIR),
9199
9253
  "Remote media download failed",
9200
9254
  "Localized remote media source(s)"
9201
9255
  );
@@ -9218,7 +9272,7 @@ async function localizeRemoteImageSources(html, downloadDir) {
9218
9272
  return downloadAndRewriteUrls(
9219
9273
  urlSet,
9220
9274
  html,
9221
- join20(downloadDir, REMOTE_MEDIA_SUBDIR),
9275
+ join21(downloadDir, REMOTE_MEDIA_SUBDIR),
9222
9276
  "Remote image download failed",
9223
9277
  "Localized remote image source(s)"
9224
9278
  );
@@ -9231,7 +9285,7 @@ async function localizeRemoteBackgroundImages(html, downloadDir) {
9231
9285
  return downloadAndRewriteUrls(
9232
9286
  urlSet,
9233
9287
  html,
9234
- join20(downloadDir, REMOTE_MEDIA_SUBDIR),
9288
+ join21(downloadDir, REMOTE_MEDIA_SUBDIR),
9235
9289
  "Remote background-image download failed",
9236
9290
  "Localized remote background-image(s)",
9237
9291
  // Quoted url('..')/url("..") are rewritten by downloadAndRewriteUrls' default
@@ -9384,7 +9438,7 @@ function localizeFontFaceUrls(html, downloadDir) {
9384
9438
  return downloadAndRewriteUrls(
9385
9439
  collectFontFaceUrls(html),
9386
9440
  html,
9387
- join20(downloadDir, REMOTE_MEDIA_SUBDIR),
9441
+ join21(downloadDir, REMOTE_MEDIA_SUBDIR),
9388
9442
  "Remote font download failed",
9389
9443
  "Localized remote font face(s)",
9390
9444
  (h, url, relPath) => h.replaceAll(`url(${url})`, `url("${relPath}")`)
@@ -9394,7 +9448,7 @@ var MAX_LOCAL_FONT_DATA_URI_BYTES = 5 * 1024 * 1024;
9394
9448
  async function readLocalFont(absPath) {
9395
9449
  const chunks = [];
9396
9450
  let totalBytes = 0;
9397
- for await (const chunk of createReadStream2(absPath)) {
9451
+ for await (const chunk of createReadStream3(absPath)) {
9398
9452
  const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
9399
9453
  totalBytes += buffer.length;
9400
9454
  if (totalBytes > MAX_LOCAL_FONT_DATA_URI_BYTES) {
@@ -9647,14 +9701,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
9647
9701
  abortSignal: options.abortSignal
9648
9702
  });
9649
9703
  const assembledHtml = await inlineExternalScripts(coalescedHtml, budget);
9650
- const HF_POSITION_ATTRS = [
9651
- 'data-hf-studio-path-offset="true"',
9652
- 'data-hf-studio-box-size="true"',
9653
- 'data-hf-studio-rotation="true"',
9654
- 'data-hf-studio-motion="'
9655
- ];
9656
- const hasPositionEdits = HF_POSITION_ATTRS.some((attr) => assembledHtml.includes(attr));
9657
- const htmlWithPositionScript = hasPositionEdits ? insertBeforeCloseTag(
9704
+ const htmlWithPositionScript = htmlHasStudioPositionEdits(assembledHtml) ? insertBeforeCloseTag(
9658
9705
  assembledHtml,
9659
9706
  "body",
9660
9707
  `<script>${createStudioPositionSeekReapplyScript()}
@@ -10154,7 +10201,7 @@ async function recompileWithResolutions(compiled, resolutions, projectDir, downl
10154
10201
  function animatedGifCacheDir(extractCacheDir) {
10155
10202
  try {
10156
10203
  const root = extractCacheDir && privateCacheRoot(extractCacheDir);
10157
- return root ? join21(root, "animated-gif") : void 0;
10204
+ return root ? join22(root, "animated-gif") : void 0;
10158
10205
  } catch {
10159
10206
  return void 0;
10160
10207
  }
@@ -10182,10 +10229,10 @@ function resolveEntryHtmlPath(input) {
10182
10229
  assertCompositionFileSize(path, relative4(projectDir, path));
10183
10230
  return readTextFile2(path);
10184
10231
  };
10185
- const htmlPath = join21(projectDir, entryFile);
10232
+ const htmlPath = join22(projectDir, entryFile);
10186
10233
  const rawEntry = readEntry(htmlPath);
10187
10234
  if (entryFile === "index.html" || !isTemplateEntry(rawEntry)) return htmlPath;
10188
- const projectIndexPath = join21(projectDir, "index.html");
10235
+ const projectIndexPath = join22(projectDir, "index.html");
10189
10236
  if (!existsSync13(projectIndexPath)) {
10190
10237
  throw new Error(
10191
10238
  `Template entry file "${entryFile}" requires a project index.html to extract its render shell.`
@@ -10201,7 +10248,7 @@ function resolveEntryHtmlPath(input) {
10201
10248
  `Entry file "${entryFile}" is not mounted from index.html via data-composition-src, so it cannot be rendered independently.`
10202
10249
  );
10203
10250
  }
10204
- const wrapperPath = join21(workDir, "standalone-entry.html");
10251
+ const wrapperPath = join22(workDir, "standalone-entry.html");
10205
10252
  writeFileSync5(wrapperPath, standaloneHtml, "utf-8");
10206
10253
  log.info("Extracted standalone entry from index.html host context", { entryFile });
10207
10254
  return wrapperPath;
@@ -10231,7 +10278,7 @@ async function runCompileStage(input) {
10231
10278
  const assetRoot = job.config.allowOutsideProjectAssets ? void 0 : projectDir;
10232
10279
  const htmlPath = resolveEntryHtmlPath({ projectDir, workDir, entryFile, log, assetRoot });
10233
10280
  const compileStart = Date.now();
10234
- const compiled = await compileForRender(projectDir, htmlPath, join21(workDir, "downloads"), {
10281
+ const compiled = await compileForRender(projectDir, htmlPath, join22(workDir, "downloads"), {
10235
10282
  log,
10236
10283
  failClosedFontFetch: failClosedFontFetch === true,
10237
10284
  allowSystemFontCapture,
@@ -10306,7 +10353,7 @@ async function runCompileStage(input) {
10306
10353
  });
10307
10354
  await preflightCompositionAssetMediaTypes({
10308
10355
  projectDir,
10309
- compiledDir: join21(workDir, "compiled"),
10356
+ compiledDir: join22(workDir, "compiled"),
10310
10357
  composition,
10311
10358
  signal: abortSignal
10312
10359
  });
@@ -10354,7 +10401,7 @@ async function runCompileStage(input) {
10354
10401
 
10355
10402
  // src/services/render/stages/probeStage.ts
10356
10403
  import { createHash as createHash7 } from "node:crypto";
10357
- import { basename as basename7, join as join22 } from "node:path";
10404
+ import { basename as basename7, join as join23 } from "node:path";
10358
10405
  import { parseHTML as parseHTML6 } from "linkedom";
10359
10406
  import {
10360
10407
  closeCaptureSession as closeCaptureSession4,
@@ -10668,7 +10715,7 @@ async function runProbeStage(input) {
10668
10715
  });
10669
10716
  fileServer = await createFileServer({
10670
10717
  projectDir,
10671
- compiledDir: join22(workDir, "compiled"),
10718
+ compiledDir: join23(workDir, "compiled"),
10672
10719
  port: 0,
10673
10720
  preHeadScripts: [VIRTUAL_TIME_SHIM],
10674
10721
  fps: job.config.fps,
@@ -10705,7 +10752,7 @@ async function runProbeStage(input) {
10705
10752
  log.info("Creating capture session...", { attempt, maxAttempts: PROBE_MAX_ATTEMPTS });
10706
10753
  probeSession = await createCaptureSession4(
10707
10754
  fileServer.url,
10708
- join22(workDir, "probe"),
10755
+ join23(workDir, "probe"),
10709
10756
  captureOpts,
10710
10757
  null,
10711
10758
  probeCfg
@@ -10790,7 +10837,7 @@ async function runProbeStage(input) {
10790
10837
  });
10791
10838
  probeSession = await createCaptureSession4(
10792
10839
  fileServer.url,
10793
- join22(workDir, "probe-screenshot"),
10840
+ join23(workDir, "probe-screenshot"),
10794
10841
  captureOpts,
10795
10842
  null,
10796
10843
  { ...probeCfg, forceScreenshot: true }
@@ -10828,7 +10875,7 @@ async function runProbeStage(input) {
10828
10875
  compiled,
10829
10876
  resolutions,
10830
10877
  projectDir,
10831
- join22(workDir, "downloads"),
10878
+ join23(workDir, "downloads"),
10832
10879
  job.config.allowOutsideProjectAssets ? void 0 : projectDir,
10833
10880
  { includeScripts: job.config.includeOutsideScripts }
10834
10881
  );
@@ -11028,7 +11075,7 @@ async function runProbeStage(input) {
11028
11075
  });
11029
11076
  await preflightCompositionAssetMediaTypes({
11030
11077
  projectDir,
11031
- compiledDir: join22(workDir, "compiled"),
11078
+ compiledDir: join23(workDir, "compiled"),
11032
11079
  composition,
11033
11080
  signal: abortSignal
11034
11081
  });
@@ -11164,7 +11211,7 @@ function validateRenderDuration(input) {
11164
11211
 
11165
11212
  // src/services/render/stages/extractVideosStage.ts
11166
11213
  import { existsSync as existsSync14 } from "node:fs";
11167
- import { join as join23 } from "node:path";
11214
+ import { join as join24 } from "node:path";
11168
11215
  import {
11169
11216
  classifyVideoExtractionError,
11170
11217
  createFrameLookupTable as createFrameLookupTable3,
@@ -11523,7 +11570,7 @@ async function runExtractVideosStage(input) {
11523
11570
  // because short boundary counts can differ by one frame.
11524
11571
  {
11525
11572
  fps: job.config.fps,
11526
- outputDir: join23(compiledDir, "__hyperframes_video_frames"),
11573
+ outputDir: join24(compiledDir, "__hyperframes_video_frames"),
11527
11574
  format: job.config.videoFrameFormat ?? "auto",
11528
11575
  toneMapHdrToSdr: rendersSdrOnly(job.config, composition),
11529
11576
  timelineEnd: composition.duration,
@@ -11531,7 +11578,7 @@ async function runExtractVideosStage(input) {
11531
11578
  collectProbeFailures: extractionPolicy.failureMode === "enforce",
11532
11579
  deferRangeExtraction,
11533
11580
  shownBoxes,
11534
- contentKeyedDirs: [join23(compiledDir, REMOTE_MEDIA_SUBDIR)],
11581
+ contentKeyedDirs: [join24(compiledDir, REMOTE_MEDIA_SUBDIR)],
11535
11582
  urlByAbsentLocalPath,
11536
11583
  assetRoots,
11537
11584
  onProgress: ({ planned = 0, done = 0 }) => {
@@ -11623,7 +11670,7 @@ async function remoteProbeSource(video, input) {
11623
11670
  if (!isPublicHttpsUrl(video.src)) return null;
11624
11671
  if (!resolveRestrictPageNetwork()) return video.src;
11625
11672
  if (!video.hasAudio || video.hidden) return null;
11626
- const downloadDir = input.downloadDir ?? join23(input.compiledDir, REMOTE_MEDIA_SUBDIR);
11673
+ const downloadDir = input.downloadDir ?? join24(input.compiledDir, REMOTE_MEDIA_SUBDIR);
11627
11674
  try {
11628
11675
  return await downloadToTemp2(video.src, downloadDir, void 0, input.signal, void 0, {
11629
11676
  onTelemetry: writeUrlDownloadTelemetry2
@@ -11748,7 +11795,7 @@ async function planVideoLayerPassthrough(input) {
11748
11795
 
11749
11796
  // src/services/render/stages/audioStage.ts
11750
11797
  import { existsSync as existsSync17 } from "node:fs";
11751
- import { join as join26 } from "node:path";
11798
+ import { join as join27 } from "node:path";
11752
11799
  import {
11753
11800
  MIXED_AUDIO_FILENAME,
11754
11801
  audioFailureDiagnostics,
@@ -11760,7 +11807,7 @@ import {
11760
11807
 
11761
11808
  // src/services/render/audioDeliveryLimit.ts
11762
11809
  import { existsSync as existsSync16 } from "node:fs";
11763
- import { dirname as dirname11, join as join25 } from "node:path";
11810
+ import { dirname as dirname11, join as join26 } from "node:path";
11764
11811
  import {
11765
11812
  applyAudioFxChain,
11766
11813
  describeFfmpegFailure as describeFfmpegFailure3,
@@ -11770,7 +11817,7 @@ import {
11770
11817
 
11771
11818
  // src/services/render/audioPadTrim.ts
11772
11819
  import { spawn } from "node:child_process";
11773
- import { dirname as dirname10, join as join24 } from "node:path";
11820
+ import { dirname as dirname10, join as join25 } from "node:path";
11774
11821
  import {
11775
11822
  DEFAULT_CONFIG,
11776
11823
  describeFfmpegFailure as describeFfmpegFailure2,
@@ -12051,7 +12098,7 @@ async function constrainAacTruePeak(input) {
12051
12098
  }
12052
12099
  async function cutSource(input, scratchDir, attenuationDb) {
12053
12100
  if (!input.sourcePath || !input.rewriteSource) return true;
12054
- const cutPath = join24(scratchDir, "source.wav");
12101
+ const cutPath = join25(scratchDir, "source.wav");
12055
12102
  try {
12056
12103
  const result = await input.rewriteSource(input.sourcePath, cutPath, gainFilter(attenuationDb));
12057
12104
  if (!result.success) throw new Error(result.error);
@@ -12066,7 +12113,7 @@ async function enforceAacTruePeak(input) {
12066
12113
  let scratchDir;
12067
12114
  try {
12068
12115
  scratchDir = createStagingDir3(dirname10(input.audioPath), ".true-peak-");
12069
- const correctedPath = join24(scratchDir, "audio.m4a");
12116
+ const correctedPath = join25(scratchDir, "audio.m4a");
12070
12117
  const measurements = [];
12071
12118
  let attenuationDb = 0;
12072
12119
  let sourcePeakDbfs;
@@ -12286,7 +12333,7 @@ async function limitDeliveryPeaks(input, deps = {
12286
12333
  const peak = await deps.measure(audioPath, { timeoutMs, signal });
12287
12334
  if (peak <= AAC_DELIVERY_TRUE_PEAK_DBFS) return { success: true };
12288
12335
  const alternating = ["a", "b"].map(
12289
- (k) => join25(dirname11(sourcePath), `audio-source-limited-${k}.wav`)
12336
+ (k) => join26(dirname11(sourcePath), `audio-source-limited-${k}.wav`)
12290
12337
  );
12291
12338
  let encodedFrom;
12292
12339
  let ceiling = AAC_DELIVERY_TRUE_PEAK_DBFS;
@@ -12359,7 +12406,7 @@ function runAudioStage(input) {
12359
12406
  }
12360
12407
  async function runAudioStageScoped(input) {
12361
12408
  const stageStart = Date.now();
12362
- const pcmSourcePath = join26(input.workDir, "audio-source.wav");
12409
+ const pcmSourcePath = join27(input.workDir, "audio-source.wav");
12363
12410
  const duration = input.totalFrames * input.fps.den / input.fps.num;
12364
12411
  let deliverySourcePath;
12365
12412
  try {
@@ -12424,7 +12471,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
12424
12471
  assertNotAborted,
12425
12472
  log
12426
12473
  } = input;
12427
- const audioOutputPath = join26(workDir, MIXED_AUDIO_FILENAME);
12474
+ const audioOutputPath = join27(workDir, MIXED_AUDIO_FILENAME);
12428
12475
  let hasAudio = false;
12429
12476
  let audioError;
12430
12477
  let audioFailures;
@@ -12505,7 +12552,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
12505
12552
 
12506
12553
  // src/services/render/stages/captureStage.ts
12507
12554
  import { existsSync as existsSync18, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
12508
- import { join as join27 } from "node:path";
12555
+ import { join as join28 } from "node:path";
12509
12556
  import {
12510
12557
  classifyCaptureFailure as classifyCaptureFailure2,
12511
12558
  frameFileExtension,
@@ -12578,13 +12625,13 @@ function measureCaptureFrameBytes(workDir, framesDir) {
12578
12625
  if (!existsSync18(workDir)) return total;
12579
12626
  for (const attempt of readdirSync4(workDir)) {
12580
12627
  if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
12581
- total += sampleDirectoryBytes(join27(workDir, attempt));
12628
+ total += sampleDirectoryBytes(join28(workDir, attempt));
12582
12629
  continue;
12583
12630
  }
12584
12631
  if (!/^capture-attempt-\d+$/.test(attempt)) continue;
12585
- const attemptDir = join27(workDir, attempt);
12632
+ const attemptDir = join28(workDir, attempt);
12586
12633
  for (const name of readdirSync4(attemptDir)) {
12587
- if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join27(attemptDir, name));
12634
+ if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join28(attemptDir, name));
12588
12635
  }
12589
12636
  }
12590
12637
  return total;
@@ -12883,7 +12930,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
12883
12930
 
12884
12931
  // src/services/render/stages/captureHdrStage.ts
12885
12932
  import { existsSync as existsSync20, mkdirSync as mkdirSync10 } from "node:fs";
12886
- import { join as join31 } from "node:path";
12933
+ import { join as join32 } from "node:path";
12887
12934
  import {
12888
12935
  closeCaptureSession as closeCaptureSession7,
12889
12936
  cloneCaptureWarnings as cloneCaptureWarnings2,
@@ -12955,7 +13002,7 @@ function createHdrImageTransferCache(options = {}) {
12955
13002
  }
12956
13003
 
12957
13004
  // src/services/render/stages/captureHdrSequentialLoop.ts
12958
- import { join as join28 } from "node:path";
13005
+ import { join as join29 } from "node:path";
12959
13006
  import {
12960
13007
  TRANSITIONS,
12961
13008
  crossfade
@@ -13080,7 +13127,7 @@ async function runSequentialLayeredFrameLoop(input) {
13080
13127
  );
13081
13128
  if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
13082
13129
  writeFileExclusiveSync(
13083
- join28(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
13130
+ join29(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
13084
13131
  normalCanvas
13085
13132
  );
13086
13133
  }
@@ -13112,7 +13159,7 @@ async function runSequentialLayeredFrameLoop(input) {
13112
13159
  }
13113
13160
 
13114
13161
  // src/services/render/stages/captureHdrHybridLoop.ts
13115
- import { join as join30 } from "node:path";
13162
+ import { join as join31 } from "node:path";
13116
13163
  import {
13117
13164
  TRANSITIONS as TRANSITIONS2,
13118
13165
  closeCaptureSession as closeCaptureSession6,
@@ -13126,7 +13173,7 @@ import {
13126
13173
  // src/services/shaderTransitionWorkerPool.ts
13127
13174
  import { Worker } from "node:worker_threads";
13128
13175
  import { fileURLToPath as fileURLToPath3, pathToFileURL } from "node:url";
13129
- import { dirname as dirname12, join as join29 } from "node:path";
13176
+ import { dirname as dirname12, join as join30 } from "node:path";
13130
13177
  import { createRequire } from "node:module";
13131
13178
  import { usableCpuCount } from "@hyperframes/engine";
13132
13179
  import { existsSync as existsSync19 } from "node:fs";
@@ -13140,9 +13187,9 @@ function resolveWorkerEntry(explicit) {
13140
13187
  return { path: override, isTs };
13141
13188
  }
13142
13189
  const moduleDir = dirname12(fileURLToPath3(import.meta.url));
13143
- const jsPath = join29(moduleDir, "shaderTransitionWorker.js");
13190
+ const jsPath = join30(moduleDir, "shaderTransitionWorker.js");
13144
13191
  if (existsSync19(jsPath)) return { path: jsPath, isTs: false };
13145
- const tsPath = join29(moduleDir, "shaderTransitionWorker.ts");
13192
+ const tsPath = join30(moduleDir, "shaderTransitionWorker.ts");
13146
13193
  return { path: tsPath, isTs: true };
13147
13194
  }
13148
13195
  function buildExecArgv(entryIsTs) {
@@ -13510,7 +13557,7 @@ async function runHybridLayeredFrameLoop(input) {
13510
13557
  );
13511
13558
  if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
13512
13559
  writeFileExclusiveSync(
13513
- join30(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
13560
+ join31(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
13514
13561
  canvas
13515
13562
  );
13516
13563
  }
@@ -13706,7 +13753,7 @@ async function runCaptureHdrStage(input) {
13706
13753
  if (hdrVideoFrameSources.has(v.id)) hdrVideoEndTimes.set(v.id, v.end);
13707
13754
  }
13708
13755
  const debugDumpEnabled = process.env.KEEP_TEMP === "1";
13709
- const debugDumpDir = debugDumpEnabled ? join31(framesDir, "debug-composite") : null;
13756
+ const debugDumpDir = debugDumpEnabled ? join32(framesDir, "debug-composite") : null;
13710
13757
  if (debugDumpDir && !existsSync20(debugDumpDir)) {
13711
13758
  mkdirSync10(debugDumpDir, { recursive: true });
13712
13759
  }
@@ -13871,11 +13918,11 @@ import {
13871
13918
  readdirSync as readdirSync5,
13872
13919
  readFileSync as readFileSync9,
13873
13920
  rmSync as rmSync11,
13874
- statSync as statSync10,
13921
+ statSync as statSync9,
13875
13922
  writeFileSync as writeFileSync6
13876
13923
  } from "node:fs";
13877
13924
  import { readFile as readFile2 } from "node:fs/promises";
13878
- import { dirname as dirname13, join as join32 } from "node:path";
13925
+ import { dirname as dirname13, join as join33 } from "node:path";
13879
13926
  import {
13880
13927
  encodeFramesChunkedConcat,
13881
13928
  encodeFramesFromDir,
@@ -14000,7 +14047,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
14000
14047
  const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
14001
14048
  if (failure) return failure;
14002
14049
  }
14003
- const fileSize = existsSync21(outputPath) ? statSync10(outputPath).size : 0;
14050
+ const fileSize = existsSync21(outputPath) ? statSync9(outputPath).size : 0;
14004
14051
  return {
14005
14052
  success: true,
14006
14053
  outputPath,
@@ -14094,7 +14141,7 @@ function encodeWhileCapturing(input, totalFrames, captureBudget) {
14094
14141
  await new Promise((resolve12) => wake = resolve12);
14095
14142
  }
14096
14143
  if (signal.aborted) return;
14097
- const mergedPath = join32(input.framesDir, formatCaptureFrameName(next, "jpg"));
14144
+ const mergedPath = join33(input.framesDir, formatCaptureFrameName(next, "jpg"));
14098
14145
  const frame = await readLandedFrame(landed.get(next), mergedPath);
14099
14146
  landed.delete(next);
14100
14147
  if (!await stream.writeFrame(frame)) {
@@ -14177,11 +14224,11 @@ async function runEncodeStage(input) {
14177
14224
  );
14178
14225
  }
14179
14226
  captured.forEach((name, i) => {
14180
- const dst = join32(outputPath, formatExportFrameName(i, "png"));
14181
- copyFileSync4(join32(framesDir, name), dst);
14227
+ const dst = join33(outputPath, formatExportFrameName(i, "png"));
14228
+ copyFileSync4(join33(framesDir, name), dst);
14182
14229
  });
14183
14230
  if (hasAudio && audioOutputPath && existsSync21(audioOutputPath)) {
14184
- copyFileSync4(audioOutputPath, join32(outputPath, MIXED_AUDIO_FILENAME2));
14231
+ copyFileSync4(audioOutputPath, join33(outputPath, MIXED_AUDIO_FILENAME2));
14185
14232
  log.info(
14186
14233
  `[Render] png-sequence: ${MIXED_AUDIO_FILENAME2} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME2}`
14187
14234
  );
@@ -14201,7 +14248,7 @@ async function runEncodeStage(input) {
14201
14248
  const encodeResult2 = await encodeGifFromDir(framesDir, framePattern2, outputPath, {
14202
14249
  fps: job.config.fps,
14203
14250
  loop,
14204
- palettePath: join32(dirname13(videoOnlyPath), "gif-palette.png"),
14251
+ palettePath: join33(dirname13(videoOnlyPath), "gif-palette.png"),
14205
14252
  preserveAlpha: needsAlpha,
14206
14253
  signal: abortSignal,
14207
14254
  timeout: engineCfg.ffmpegEncodeTimeout
@@ -14412,9 +14459,9 @@ function sampleDirectoryBytes(dir) {
14412
14459
  continue;
14413
14460
  }
14414
14461
  for (const name of entries) {
14415
- const full = join33(current, name);
14462
+ const full = join34(current, name);
14416
14463
  try {
14417
- const st = statSync11(full);
14464
+ const st = statSync10(full);
14418
14465
  if (st.isDirectory()) {
14419
14466
  stack.push(full);
14420
14467
  } else if (st.isFile()) {
@@ -14570,8 +14617,8 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
14570
14617
  const ranges = [];
14571
14618
  let rangeStart = null;
14572
14619
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
14573
- const framePath = join33(framesDir, formatCaptureFrameName(frameIndex, frameExt));
14574
- const missing = !existsSync22(framePath) || statSync11(framePath).size <= 8;
14620
+ const framePath = join34(framesDir, formatCaptureFrameName(frameIndex, frameExt));
14621
+ const missing = !existsSync22(framePath) || statSync10(framePath).size <= 8;
14575
14622
  if (missing && rangeStart === null) {
14576
14623
  rangeStart = frameIndex;
14577
14624
  } else if (!missing && rangeStart !== null) {
@@ -14587,7 +14634,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
14587
14634
  function buildMissingFrameRetryBatches(ranges, maxWorkers, workDir, attempt, rangeStart = 0, stride = 1) {
14588
14635
  const workersPerBatch = Math.max(1, Math.floor(maxWorkers));
14589
14636
  const batches = [];
14590
- const outputDirFor = (batchIndex, workerId) => join33(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
14637
+ const outputDirFor = (batchIndex, workerId) => join34(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
14591
14638
  if (stride > 1) {
14592
14639
  const spans = /* @__PURE__ */ new Map();
14593
14640
  for (const range of ranges) {
@@ -14647,8 +14694,8 @@ function getNextRetryWorkerCount(currentWorkers) {
14647
14694
  return Math.max(1, Math.floor(currentWorkers / 2));
14648
14695
  }
14649
14696
  function resolveRenderWorkDirPrefix(outputPath, jobId, platform2 = process.platform, systemTempDir = tmpdir3()) {
14650
- if (platform2 === "win32" || platform2 === "darwin") return join33(systemTempDir, "hf-render-");
14651
- return join33(dirname14(outputPath), `work-${jobId}-`);
14697
+ if (platform2 === "win32" || platform2 === "darwin") return join34(systemTempDir, "hf-render-");
14698
+ return join34(dirname14(outputPath), `work-${jobId}-`);
14652
14699
  }
14653
14700
  var MAX_TRANSIENT_CAPTURE_RETRIES = 1;
14654
14701
  function isTransientCaptureRetryEligible(failureKind, missing, retriesUsed) {
@@ -14703,7 +14750,7 @@ The composition is too large for the available memory. To reduce memory pressure
14703
14750
  function countCapturedFrames(totalFrames, framesDir, frameExt) {
14704
14751
  let captured = 0;
14705
14752
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
14706
- const framePath = join33(framesDir, formatCaptureFrameName(frameIndex, frameExt));
14753
+ const framePath = join34(framesDir, formatCaptureFrameName(frameIndex, frameExt));
14707
14754
  if (existsSync22(framePath)) captured++;
14708
14755
  }
14709
14756
  return captured;
@@ -14729,7 +14776,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
14729
14776
  reason: attempt === 0 ? "initial" : pendingTransientRetry ? "transient-retry" : "retry"
14730
14777
  });
14731
14778
  pendingTransientRetry = false;
14732
- const attemptWorkDir = join33(options.workDir, `capture-attempt-${attempt}`);
14779
+ const attemptWorkDir = join34(options.workDir, `capture-attempt-${attempt}`);
14733
14780
  const batches = missingRanges ? buildMissingFrameRetryBatches(
14734
14781
  missingRanges,
14735
14782
  currentWorkers,
@@ -15377,7 +15424,7 @@ function deVerifyFallbackTelemetry(err) {
15377
15424
  }
15378
15425
  function resolveRenderDebugDir() {
15379
15426
  const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve9(process.env.PRODUCER_RENDERS_DIR, "..") : resolve9(dirname14(fileURLToPath4(import.meta.url)), "../..");
15380
- return join33(producerRoot, ".debug");
15427
+ return join34(producerRoot, ".debug");
15381
15428
  }
15382
15429
  async function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
15383
15430
  validateHlsRenderConfig(job.config);
@@ -15386,10 +15433,10 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
15386
15433
  const debugDir = resolveRenderDebugDir();
15387
15434
  const outputDir = dirname14(outputPath);
15388
15435
  if (!existsSync22(outputDir)) mkdirSync12(outputDir, { recursive: true });
15389
- const workDir = job.config.debug ? join33(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
15436
+ const workDir = job.config.debug ? join34(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
15390
15437
  const pipelineStart = Date.now();
15391
15438
  const baseLog = job.config.logger ?? defaultLogger;
15392
- const logPath = job.config.debug ? join33(workDir, "render.log") : null;
15439
+ const logPath = job.config.debug ? join34(workDir, "render.log") : null;
15393
15440
  const execution = new RenderExecutionContext({
15394
15441
  request: { renderJobId: job.id, projectDir, outputPath },
15395
15442
  logger: logPath ? createRenderFileLogger(logPath, baseLog) : baseLog,
@@ -15420,6 +15467,15 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
15420
15467
  await execution.dispose();
15421
15468
  }
15422
15469
  }
15470
+ function loadResumeKeyOrWarn(resume, log) {
15471
+ const key = segmentManifestKey();
15472
+ if (resume && !key) {
15473
+ log.warn(
15474
+ "[Render] --resume: no preview token could be read or created, so every segment will be captured again"
15475
+ );
15476
+ }
15477
+ return key;
15478
+ }
15423
15479
  async function executeRenderPipeline(input) {
15424
15480
  const {
15425
15481
  job,
@@ -15457,7 +15513,7 @@ async function executeRenderPipeline(input) {
15457
15513
  imageDecodeFailures: 0
15458
15514
  };
15459
15515
  let hdrPerf;
15460
- const perfOutputPath = join33(workDir, "perf-summary.json");
15516
+ const perfOutputPath = join34(workDir, "perf-summary.json");
15461
15517
  const cfg = { ...job.config.producerConfig ?? resolveConfig2() };
15462
15518
  const observability = new RenderObservabilityRecorder({
15463
15519
  pipelineStartMs: pipelineStart,
@@ -15562,7 +15618,7 @@ async function executeRenderPipeline(input) {
15562
15618
  requestedWorkers: job.config.workers ?? "auto"
15563
15619
  });
15564
15620
  const entryFile = job.config.entryFile || "index.html";
15565
- const htmlPath = join33(projectDir, entryFile);
15621
+ const htmlPath = join34(projectDir, entryFile);
15566
15622
  if (!existsSync22(htmlPath)) {
15567
15623
  throw new Error(`Entry file not found: ${htmlPath}`);
15568
15624
  }
@@ -15659,7 +15715,7 @@ async function executeRenderPipeline(input) {
15659
15715
  const largerThanCanvas = await oversizedVideos(
15660
15716
  composition.videos,
15661
15717
  projectDir,
15662
- join33(workDir, "compiled"),
15718
+ join34(workDir, "compiled"),
15663
15719
  { width: outputWidth, height: outputHeight }
15664
15720
  );
15665
15721
  const probeResult = await observeRenderStage(
@@ -15756,7 +15812,7 @@ async function executeRenderPipeline(input) {
15756
15812
  canvas: { width, height },
15757
15813
  page: probeSession.page,
15758
15814
  projectDir,
15759
- compiledDir: join33(workDir, "compiled")
15815
+ compiledDir: join34(workDir, "compiled")
15760
15816
  });
15761
15817
  if (videoLayerPlan.videoId === void 0) {
15762
15818
  log.info(`[Render] Video layer passthrough off: ${videoLayerPlan.reason}`);
@@ -15774,7 +15830,7 @@ async function executeRenderPipeline(input) {
15774
15830
  updateJobStatus(job, "preprocessing", "Extracting video frames", 10, onProgress, {
15775
15831
  code: "extract_video"
15776
15832
  });
15777
- const compiledDir = join33(workDir, "compiled");
15833
+ const compiledDir = join34(workDir, "compiled");
15778
15834
  const segmentsCapture = (layeredOrEffectRoute) => shouldSegmentCapture({
15779
15835
  env: process.env,
15780
15836
  durationSeconds: probeResult.duration,
@@ -15910,7 +15966,7 @@ async function executeRenderPipeline(input) {
15910
15966
  try {
15911
15967
  fileServer = await createFileServer({
15912
15968
  projectDir,
15913
- compiledDir: join33(workDir, "compiled"),
15969
+ compiledDir: join34(workDir, "compiled"),
15914
15970
  port: 0,
15915
15971
  preHeadScripts: [VIRTUAL_TIME_SHIM],
15916
15972
  fps: job.config.fps,
@@ -15930,7 +15986,7 @@ async function executeRenderPipeline(input) {
15930
15986
  if (!activeFileServer) {
15931
15987
  throw new Error("File server failed to initialize before frame capture");
15932
15988
  }
15933
- const framesDir = join33(workDir, "captured-frames");
15989
+ const framesDir = join34(workDir, "captured-frames");
15934
15990
  if (!existsSync22(framesDir)) mkdirSync12(framesDir, { recursive: true });
15935
15991
  updateJobStatus(job, "rendering", "Checking browser GPU", 25, onProgress, {
15936
15992
  code: "start_browsers"
@@ -16511,7 +16567,7 @@ async function executeRenderPipeline(input) {
16511
16567
  hls: ".mp4"
16512
16568
  };
16513
16569
  const videoExt = FORMAT_EXT[outputFormat] ?? ".mp4";
16514
- const videoOnlyPath = join33(workDir, `video-only${videoExt}`);
16570
+ const videoOnlyPath = join34(workDir, `video-only${videoExt}`);
16515
16571
  let usePageSideCompositingForTransitions = (cfg.enablePageSideCompositing || isGif) && compiled.hasShaderTransitions && !hasHdrContent && outputSupportsPageSideShaderCompositing(outputFormat);
16516
16572
  if (usePageSideCompositingForTransitions) {
16517
16573
  activeFileServer.addPreHeadScript(HF_PAGE_SIDE_COMPOSITING_STUB);
@@ -16828,16 +16884,19 @@ async function executeRenderPipeline(input) {
16828
16884
  pageMotionBlur: job.config.pageMotionBlur,
16829
16885
  captureQuality: captureOptions.quality
16830
16886
  });
16831
- const segmentDir = segmentDirFor(join33(projectDir, "renders"), segmentPlanHash);
16887
+ const segmentDir = segmentDirFor(join34(projectDir, "renders"), segmentPlanHash);
16888
+ const manifestKey = loadResumeKeyOrWarn(job.config.resumeSegments === true, log);
16832
16889
  let completedSegments = /* @__PURE__ */ new Set();
16833
16890
  if (job.config.resumeSegments === true) {
16834
16891
  const existing = readSegmentManifest(segmentDir);
16835
16892
  if (existing) {
16836
- completedSegments = await validateCompletedSegments(
16837
- existing,
16838
- segmentPlanHash,
16839
- (path) => probeSegmentFrameCount(path, extractMediaMetadata5)
16840
- );
16893
+ completedSegments = await validateCompletedSegments(existing, {
16894
+ expectedHash: segmentPlanHash,
16895
+ segmentDir,
16896
+ plan: planSegments(totalFrames, segmentFrames),
16897
+ key: manifestKey,
16898
+ probeFrames: (path) => probeSegmentFrameCount(path, extractMediaMetadata5)
16899
+ });
16841
16900
  log.info(`[Render] resuming: ${completedSegments.size} segments complete`, {
16842
16901
  segmentDir
16843
16902
  });
@@ -16911,7 +16970,7 @@ async function executeRenderPipeline(input) {
16911
16970
  ...segmentManifest.completed.filter((e) => e.index !== entry.index),
16912
16971
  { ...entry, completedAt: (/* @__PURE__ */ new Date()).toISOString() }
16913
16972
  ];
16914
- writeSegmentManifest(segmentDir, segmentManifest);
16973
+ writeSegmentManifest(segmentDir, segmentManifest, manifestKey);
16915
16974
  },
16916
16975
  updateCaptureObservability
16917
16976
  })
@@ -17454,7 +17513,7 @@ async function executeRenderPipeline(input) {
17454
17513
  }
17455
17514
  if (job.config.debug) {
17456
17515
  if (!isPngSequence && !isHls && existsSync22(stagedOutputPath)) {
17457
- const debugOutput = join33(workDir, `output${videoExt}`);
17516
+ const debugOutput = join34(workDir, `output${videoExt}`);
17458
17517
  copyFileSync5(stagedOutputPath, debugOutput);
17459
17518
  }
17460
17519
  }
@@ -17571,13 +17630,13 @@ async function executeRenderPipeline(input) {
17571
17630
  import {
17572
17631
  existsSync as existsSync23,
17573
17632
  readFileSync as readFileSync10,
17574
- statSync as statSync12,
17633
+ statSync as statSync11,
17575
17634
  openSync as openSync5,
17576
17635
  fstatSync as fstatSync3,
17577
17636
  closeSync as closeSync5,
17578
17637
  constants as constants3
17579
17638
  } from "node:fs";
17580
- import { resolve as resolve10, join as join34, relative as relative5, isAbsolute as isAbsolute4, sep as sep5, dirname as dirname15 } from "node:path";
17639
+ import { resolve as resolve10, join as join35, relative as relative5, isAbsolute as isAbsolute4, sep as sep5, dirname as dirname15 } from "node:path";
17581
17640
  import { fileURLToPath as fileURLToPath5 } from "node:url";
17582
17641
  import { Worker as Worker2 } from "node:worker_threads";
17583
17642
  function isStringRecord(value) {
@@ -17612,7 +17671,7 @@ function readEntryHtml(filePath) {
17612
17671
  } catch (error) {
17613
17672
  if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
17614
17673
  return null;
17615
- if (!statSync12(filePath, { throwIfNoEntry: false })?.isFile()) return null;
17674
+ if (!statSync11(filePath, { throwIfNoEntry: false })?.isFile()) return null;
17616
17675
  throw error;
17617
17676
  }
17618
17677
  try {
@@ -17628,7 +17687,7 @@ function leavesProject(absProjectDir, absoluteEntryPath, isAllowedEntry) {
17628
17687
  }
17629
17688
  function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
17630
17689
  const absProjectDir = resolve10(projectDir);
17631
- if (!existsSync23(absProjectDir) || !statSync12(absProjectDir).isDirectory()) {
17690
+ if (!existsSync23(absProjectDir) || !statSync11(absProjectDir).isDirectory()) {
17632
17691
  return { error: `Project directory not found: ${absProjectDir}` };
17633
17692
  }
17634
17693
  const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
@@ -17649,7 +17708,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
17649
17708
  }
17650
17709
  }
17651
17710
  return {
17652
- error: `No HTML entry file found in project directory: ${join34(absProjectDir, preferredEntryFile || "index.html")}`
17711
+ error: `No HTML entry file found in project directory: ${join35(absProjectDir, preferredEntryFile || "index.html")}`
17653
17712
  };
17654
17713
  }
17655
17714
  function prepareHyperframeLintBody(body, isAllowedEntry) {
@@ -17718,7 +17777,7 @@ function freeLintSlot() {
17718
17777
  function resolveLintWorkerEntry() {
17719
17778
  const here = dirname15(fileURLToPath5(import.meta.url));
17720
17779
  for (const name of ["hyperframeLintWorker.js", "hyperframeLintWorker.ts"]) {
17721
- const candidate = join34(here, name);
17780
+ const candidate = join35(here, name);
17722
17781
  if (existsSync23(candidate)) return candidate;
17723
17782
  }
17724
17783
  return void 0;
@@ -17789,7 +17848,7 @@ async function runHyperframeLint(prepared, options = {}) {
17789
17848
  // src/services/healthWorker.ts
17790
17849
  import { Worker as Worker3 } from "node:worker_threads";
17791
17850
  import { fileURLToPath as fileURLToPath6 } from "node:url";
17792
- import { dirname as dirname16, join as join35 } from "node:path";
17851
+ import { dirname as dirname16, join as join36 } from "node:path";
17793
17852
  import { existsSync as existsSync24 } from "node:fs";
17794
17853
  var DEFAULT_HEALTH_PORT = 9848;
17795
17854
  async function startHealthWorker(options = {}) {
@@ -17865,7 +17924,7 @@ function defaultLogger2() {
17865
17924
  }
17866
17925
  function resolveWorkerEntry2() {
17867
17926
  const here = dirname16(fileURLToPath6(import.meta.url));
17868
- const candidates = [join35(here, "healthWorkerThread.js"), join35(here, "healthWorkerThread.ts")];
17927
+ const candidates = [join36(here, "healthWorkerThread.js"), join36(here, "healthWorkerThread.ts")];
17869
17928
  for (const candidate of candidates) {
17870
17929
  if (existsSync24(candidate)) return candidate;
17871
17930
  }
@@ -17907,7 +17966,7 @@ import {
17907
17966
  createReferenceBackgroundRecorder as createReferenceBackgroundRecorder2
17908
17967
  } from "@hyperframes/engine";
17909
17968
  import { audioFailureDiagnostics as audioFailureDiagnostics3 } from "@hyperframes/engine";
17910
- import { extname as extname4, isAbsolute as isAbsolute5, join as join37, relative as relative6, sep as sep6 } from "node:path";
17969
+ import { extname as extname4, isAbsolute as isAbsolute5, join as join38, relative as relative6, sep as sep6 } from "node:path";
17911
17970
  import {
17912
17971
  fpsToNumber as fpsToNumber9,
17913
17972
  HF_COLOR_GRADING_ATTR as HF_COLOR_GRADING_ATTR2
@@ -17940,7 +17999,7 @@ import {
17940
17999
 
17941
18000
  // src/services/distributed/shared.ts
17942
18001
  import { execFile as execFileCallback } from "node:child_process";
17943
- import { dirname as dirname17, join as join36 } from "node:path";
18002
+ import { dirname as dirname17, join as join37 } from "node:path";
17944
18003
  import { existsSync as existsSync25, readFileSync as readFileSync11 } from "node:fs";
17945
18004
  import { fileURLToPath as fileURLToPath7 } from "node:url";
17946
18005
  import { promisify as promisify2 } from "node:util";
@@ -17956,7 +18015,7 @@ function readProducerVersion() {
17956
18015
  const startDir = dirname17(fileURLToPath7(import.meta.url));
17957
18016
  let current = startDir;
17958
18017
  for (let i = 0; i < 10; i++) {
17959
- const candidate = join36(current, "package.json");
18018
+ const candidate = join37(current, "package.json");
17960
18019
  if (existsSync25(candidate)) {
17961
18020
  try {
17962
18021
  const pkg = JSON.parse(readFileSync11(candidate, "utf-8"));
@@ -18054,9 +18113,9 @@ var PLAN_ROOT_CATEGORY = {
18054
18113
  var PLAN_DIR_SIZE_LIMIT_BYTES = 2 * 1024 * 1024 * 1024;
18055
18114
  var FREEZE_OWNED_PLAN_FILES = [
18056
18115
  "plan.json",
18057
- join37("meta", "composition.json"),
18058
- join37("meta", "encoder.json"),
18059
- join37("meta", "chunks.json")
18116
+ join38("meta", "composition.json"),
18117
+ join38("meta", "encoder.json"),
18118
+ join38("meta", "chunks.json")
18060
18119
  ];
18061
18120
 
18062
18121
  // src/services/distributed/renderConfigValidation.ts
@@ -18562,7 +18621,7 @@ function prepareProjectDirectory(projectDir, options, policy) {
18562
18621
  if (!candidate) return null;
18563
18622
  const absProjectDir = policy ? resolve11(policy.projectsDir, candidate) : resolve11(candidate);
18564
18623
  const shown = policy ? candidate : absProjectDir;
18565
- if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync26(absProjectDir) || !statSync13(absProjectDir).isDirectory()) {
18624
+ if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync26(absProjectDir) || !statSync12(absProjectDir).isDirectory()) {
18566
18625
  return { error: `Project directory not found: ${shown}` };
18567
18626
  }
18568
18627
  const entry = options.entryFile || "index.html";
@@ -18588,8 +18647,8 @@ async function resolveInlineRenderHtml(body) {
18588
18647
  }
18589
18648
  function materializeInlineProject(html, options) {
18590
18649
  const tempRoot = process.env.PRODUCER_TMP_PROJECT_DIR || tmpdir4();
18591
- const tempProjectDir = mkdtempSync(join38(tempRoot, "producer-project-"));
18592
- writeFileSync8(join38(tempProjectDir, "index.html"), html, "utf-8");
18650
+ const tempProjectDir = mkdtempSync(join39(tempRoot, "producer-project-"));
18651
+ writeFileSync8(join39(tempProjectDir, "index.html"), html, "utf-8");
18593
18652
  return {
18594
18653
  prepared: {
18595
18654
  input: { projectDir: tempProjectDir, ...options },
@@ -18665,7 +18724,7 @@ function publicPerfSummary(job) {
18665
18724
  return job.perfSummary ? { ...job.perfSummary, renderId: void 0 } : null;
18666
18725
  }
18667
18726
  function outputFileSize(path) {
18668
- return existsSync26(path) ? statSync13(path).size : 0;
18727
+ return existsSync26(path) ? statSync12(path).size : 0;
18669
18728
  }
18670
18729
  function createBlockingProgressReporter(log, requestId) {
18671
18730
  let lastLoggedPct = -10;
@@ -18996,8 +19055,8 @@ function createRenderHandlers(options = {}) {
18996
19055
  store.delete(token);
18997
19056
  return c.json({ success: false, error: "Output artifact file missing" }, 404);
18998
19057
  }
18999
- const stats = statSync13(artifact.path);
19000
- return new Response(createReadStream3(artifact.path), {
19058
+ const stats = statSync12(artifact.path);
19059
+ return new Response(createReadStream4(artifact.path), {
19001
19060
  headers: {
19002
19061
  "content-type": "video/mp4",
19003
19062
  "content-length": String(stats.size),