@hyperframes/producer 0.9.32 → 0.9.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  // src/services/renderOrchestrator.ts
10
10
  import { audioFailureDiagnostics as audioFailureDiagnostics2 } from "@hyperframes/engine";
11
11
  import {
12
- existsSync as existsSync22,
12
+ existsSync as existsSync21,
13
13
  mkdirSync as mkdirSync12,
14
14
  readdirSync as readdirSync6,
15
15
  rmSync as rmSync12,
@@ -206,7 +206,9 @@ function createConsoleLogger(level = "info") {
206
206
  }
207
207
  };
208
208
  }
209
- var defaultLogger = createConsoleLogger("info");
209
+ var defaultLogger = createConsoleLogger(
210
+ process.env.HF_DEBUG_RENDER === "1" ? "debug" : "info"
211
+ );
210
212
 
211
213
  // src/services/fileServer.ts
212
214
  var readFileAsync = promisify(readFile);
@@ -1011,7 +1013,7 @@ function assertChromaSubsamplingSdr(config, hasHdrContent) {
1011
1013
  import {
1012
1014
  copyFileSync,
1013
1015
  cpSync,
1014
- existsSync as existsSync4,
1016
+ existsSync as existsSync3,
1015
1017
  mkdirSync,
1016
1018
  rmSync,
1017
1019
  symlinkSync,
@@ -1034,9 +1036,7 @@ import {
1034
1036
  relative as nodeRelative,
1035
1037
  isAbsolute as nodeIsAbsolute
1036
1038
  } from "node:path";
1037
- import { existsSync as existsSync3 } from "node:fs";
1038
1039
  import { fileURLToPath as fileURLToPath2 } from "node:url";
1039
- import { decodedUrlPath } from "@hyperframes/parsers/asset-paths";
1040
1040
  var DEFAULT_RENDERS_DIR = process.env.PRODUCER_RENDERS_DIR ?? // fileURLToPath (not URL.pathname): on Windows .pathname is "/D:/..." which
1041
1041
  // resolves to a bogus renders dir.
1042
1042
  nodeResolve(fileURLToPath2(import.meta.url), "../../..", "renders");
@@ -1074,13 +1074,6 @@ function resolveRenderPaths(projectDir, outputPath, rendersDir = DEFAULT_RENDERS
1074
1074
  const absoluteOutputPath = nodeResolve(resolvedOutputPath);
1075
1075
  return { absoluteProjectDir, absoluteOutputPath };
1076
1076
  }
1077
- function resolveCompositionSrc(projectDir, src) {
1078
- const rooted = (value) => nodeResolve(projectDir, value.replace(/^(?:\.?[\\/])+/, ""));
1079
- const decoded = rooted(decodedUrlPath(src));
1080
- if (!isPathInside2(decoded, projectDir)) return null;
1081
- const raw = rooted(src);
1082
- return !existsSync3(decoded) && isPathInside2(raw, projectDir) && existsSync3(raw) ? raw : decoded;
1083
- }
1084
1077
 
1085
1078
  // src/services/render/shared.ts
1086
1079
  var BROWSER_MEDIA_EPSILON = 1e-4;
@@ -1255,6 +1248,13 @@ var workerPhasesByJob = /* @__PURE__ */ new WeakMap();
1255
1248
  function forgetWorkerPhases(job) {
1256
1249
  workerPhasesByJob.delete(job);
1257
1250
  }
1251
+ var staticDedupActivityByJob = /* @__PURE__ */ new WeakMap();
1252
+ function noteStaticDedupActivity(job) {
1253
+ staticDedupActivityByJob.set(job, (staticDedupActivityByJob.get(job) ?? 0) + 1);
1254
+ }
1255
+ function staticDedupActivity(job) {
1256
+ return staticDedupActivityByJob.get(job) ?? 0;
1257
+ }
1258
1258
  function describeWorkerPhases(job) {
1259
1259
  const phases = workerPhasesByJob.get(job);
1260
1260
  if (!phases?.size) return void 0;
@@ -1288,7 +1288,7 @@ var materializePathModule = {
1288
1288
  isAbsolute
1289
1289
  };
1290
1290
  var materializeFileSystem = {
1291
- existsSync: existsSync4,
1291
+ existsSync: existsSync3,
1292
1292
  mkdirSync,
1293
1293
  symlinkSync,
1294
1294
  cpSync,
@@ -1590,7 +1590,7 @@ var RenderExecutionContext = class {
1590
1590
  };
1591
1591
 
1592
1592
  // src/services/render/artifactTransaction.ts
1593
- import { closeSync as closeSync2, existsSync as existsSync6, fstatSync as fstatSync2, openSync as openSync2, readSync, readdirSync as readdirSync2, rmSync as rmSync3 } from "node:fs";
1593
+ import { closeSync as closeSync2, existsSync as existsSync5, fstatSync as fstatSync2, openSync as openSync2, readSync, readdirSync as readdirSync2, rmSync as rmSync3 } from "node:fs";
1594
1594
  import { basename as basename4, dirname as dirname4, extname as extname2, join as join5, resolve as resolve4 } from "node:path";
1595
1595
  import { HLS_MASTER_PLAYLIST, HLS_VIDEO_PLAYLIST, renameWithRetry } from "@hyperframes/engine";
1596
1596
 
@@ -1603,7 +1603,7 @@ import {
1603
1603
 
1604
1604
  // src/services/render/renderDirOwner.ts
1605
1605
  import {
1606
- existsSync as existsSync5,
1606
+ existsSync as existsSync4,
1607
1607
  lstatSync,
1608
1608
  readFileSync as readFileSync2,
1609
1609
  readdirSync,
@@ -1679,7 +1679,7 @@ function newestWriteMs(path) {
1679
1679
  }
1680
1680
  function isAbandoned(dir, ownerlessIdleMs, now) {
1681
1681
  try {
1682
- if (!lstatSync(dir).isDirectory() || existsSync5(join4(dir, TRANSACTION_BACKUP))) return false;
1682
+ if (!lstatSync(dir).isDirectory() || existsSync4(join4(dir, TRANSACTION_BACKUP))) return false;
1683
1683
  const owner = ownerState(dir);
1684
1684
  if (owner === "gone") return true;
1685
1685
  return owner === "none" && ownerlessIdleMs !== void 0 && now - newestWriteMs(dir) >= ownerlessIdleMs;
@@ -1711,7 +1711,7 @@ function createRenderWorkDir(prefix, outputDir) {
1711
1711
 
1712
1712
  // src/services/render/artifactTransaction.ts
1713
1713
  var defaultFileSystem = {
1714
- existsSync: existsSync6,
1714
+ existsSync: existsSync5,
1715
1715
  renameSync: (source, destination) => renameWithRetry(source, destination),
1716
1716
  rmSync: rmSync3
1717
1717
  };
@@ -1865,7 +1865,7 @@ var ArtifactTransaction = class {
1865
1865
  async assertDirectoryExpectation(expected, files) {
1866
1866
  for (const required of expected.requiredFiles ?? []) {
1867
1867
  const path = join5(this.stagingPath, required);
1868
- if (!existsSync6(path)) {
1868
+ if (!existsSync5(path)) {
1869
1869
  throw new Error(`Render artifact directory is missing ${required}: ${this.stagingPath}`);
1870
1870
  }
1871
1871
  assertReadableNonEmptyFile(path);
@@ -2114,7 +2114,7 @@ function replanAfterFailure(plan2, failure) {
2114
2114
  }
2115
2115
 
2116
2116
  // src/services/render/stages/captureSegmentedStage.ts
2117
- import { existsSync as existsSync7, mkdirSync as mkdirSync3, rmSync as rmSync6, statSync as statSync3 } from "node:fs";
2117
+ import { existsSync as existsSync6, mkdirSync as mkdirSync3, rmSync as rmSync6, statSync as statSync3 } from "node:fs";
2118
2118
  import { join as join9 } from "node:path";
2119
2119
  import {
2120
2120
  captureFrameToBuffer as captureFrameToBuffer2,
@@ -4460,7 +4460,7 @@ async function runCaptureStreamingStage(input) {
4460
4460
  const session = probeSession ?? await openSession();
4461
4461
  captureBeyondViewport = session.options.captureBeyondViewport;
4462
4462
  if (probeSession) {
4463
- prepareCaptureSessionForReuse(session, framesDir, videoInjector);
4463
+ await prepareCaptureSessionForReuse(session, framesDir, videoInjector);
4464
4464
  probeSession = null;
4465
4465
  }
4466
4466
  let riskSession = null;
@@ -4718,7 +4718,7 @@ async function captureSegmentToEncoder(ctx, segment) {
4718
4718
  path: segmentPath,
4719
4719
  // Recorded so resume can prove the file on disk is the one that
4720
4720
  // finished; absent only in unit tests, whose fake encoder writes none.
4721
- bytes: existsSync7(segmentPath) ? statSync3(segmentPath).size : 0
4721
+ bytes: existsSync6(segmentPath) ? statSync3(segmentPath).size : 0
4722
4722
  });
4723
4723
  return encodeResult;
4724
4724
  } finally {
@@ -4765,8 +4765,13 @@ function defaultSessionFactory(input) {
4765
4765
  };
4766
4766
  const session = probeSession ?? await openSession();
4767
4767
  if (probeSession) {
4768
- openSegmentedSessionReuse(input, probeSession, injector);
4768
+ const reused = probeSession;
4769
4769
  probeSession = null;
4770
+ await openSegmentedSessionReuse(input, reused, injector).catch(async (error) => {
4771
+ await closeCaptureSession2(reused).catch(() => {
4772
+ });
4773
+ throw error;
4774
+ });
4770
4775
  }
4771
4776
  try {
4772
4777
  if (!session.isInitialized) await withinInitBudget(initializeSession2(session), session);
@@ -4780,8 +4785,8 @@ function defaultSessionFactory(input) {
4780
4785
  }
4781
4786
  };
4782
4787
  }
4783
- function openSegmentedSessionReuse(input, session, injector) {
4784
- prepareCaptureSessionForReuse2(session, input.framesDir, injector());
4788
+ async function openSegmentedSessionReuse(input, session, injector) {
4789
+ await prepareCaptureSessionForReuse2(session, input.framesDir, injector());
4785
4790
  }
4786
4791
  async function openSegmentedSession(input, injector) {
4787
4792
  const captureCfg = input.cfg.forceScreenshot === input.plan.forceScreenshot ? input.cfg : { ...input.cfg, forceScreenshot: input.plan.forceScreenshot };
@@ -5719,7 +5724,7 @@ function trackSegmentFramePeak(frames, rootDir, onPeak) {
5719
5724
 
5720
5725
  // src/services/render/segmentManifest.ts
5721
5726
  import { createHash as createHash2 } from "node:crypto";
5722
- import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync4, statSync as statSync5, writeFileSync as writeFileSync3 } from "node:fs";
5727
+ import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync4, statSync as statSync5, writeFileSync as writeFileSync3 } from "node:fs";
5723
5728
  import { join as join14 } from "node:path";
5724
5729
  import { renameWithRetry as renameWithRetry2 } from "@hyperframes/engine";
5725
5730
  var MANIFEST_FILENAME = "segments.json";
@@ -5767,7 +5772,7 @@ function isManifest(value) {
5767
5772
  }
5768
5773
  function readSegmentManifest(segmentDir) {
5769
5774
  const path = join14(segmentDir, MANIFEST_FILENAME);
5770
- if (!existsSync8(path)) return null;
5775
+ if (!existsSync7(path)) return null;
5771
5776
  try {
5772
5777
  const parsed = JSON.parse(readFileSync4(path, "utf-8"));
5773
5778
  return isManifest(parsed) ? parsed : null;
@@ -5796,7 +5801,7 @@ async function validateCompletedSegments(manifest, expectedHash, probeFrames) {
5796
5801
  const ok = /* @__PURE__ */ new Set();
5797
5802
  if (manifest.planHash !== expectedHash) return ok;
5798
5803
  for (const entry of manifest.completed) {
5799
- if (!existsSync8(entry.path)) continue;
5804
+ if (!existsSync7(entry.path)) continue;
5800
5805
  const size = statSync5(entry.path).size;
5801
5806
  if (size <= 0 || size !== entry.bytes) continue;
5802
5807
  const frames = await probeFrames(entry.path);
@@ -6164,26 +6169,26 @@ var STALL_POLL_MS = 5e3;
6164
6169
  function watchStall(phase, rule) {
6165
6170
  const detail = rule.detail ?? (() => void 0);
6166
6171
  let last = rule.progress();
6172
+ let lastActivity = rule.activity?.();
6167
6173
  let budgetMs = rule.firstProgressMs;
6168
6174
  const silence = createStallClock();
6169
6175
  const pollMs = Math.min(STALL_POLL_MS, rule.noProgressMs, rule.firstProgressMs);
6170
6176
  let attempt;
6171
6177
  let timer;
6172
6178
  let inTail = false;
6179
+ const activityMoved = () => {
6180
+ const activity = rule.activity?.();
6181
+ if (activity === lastActivity) return false;
6182
+ lastActivity = activity;
6183
+ return true;
6184
+ };
6173
6185
  const restartWindow = (ms) => {
6174
6186
  last = rule.progress();
6175
6187
  budgetMs = ms;
6176
6188
  silence.reset();
6177
6189
  };
6178
6190
  const tripped = new Promise((_, reject) => {
6179
- timer = setInterval(() => {
6180
- const current = rule.progress();
6181
- if (rule.complete?.() && !inTail) {
6182
- inTail = true;
6183
- return restartWindow(rule.tailMs ?? rule.noProgressMs);
6184
- }
6185
- if (current !== last) return restartWindow(rule.noProgressMs);
6186
- if (silence.idle(pollMs) < budgetMs) return;
6191
+ const trip = (current) => {
6187
6192
  const error = new RenderStageStalledError(phase, budgetMs, current, detail());
6188
6193
  if (attempt && !attempt.signal.aborted) {
6189
6194
  attempt.abort(error);
@@ -6191,6 +6196,16 @@ function watchStall(phase, rule) {
6191
6196
  }
6192
6197
  clearInterval(timer);
6193
6198
  reject(error);
6199
+ };
6200
+ timer = setInterval(() => {
6201
+ const current = rule.progress();
6202
+ if (rule.complete?.() && !inTail) {
6203
+ inTail = true;
6204
+ return restartWindow(rule.tailMs ?? rule.noProgressMs);
6205
+ }
6206
+ if (current !== last) return restartWindow(rule.noProgressMs);
6207
+ if (activityMoved()) return silence.reset();
6208
+ if (silence.idle(pollMs) >= budgetMs) trip(current);
6194
6209
  }, pollMs);
6195
6210
  });
6196
6211
  const openAttempt = (parent) => {
@@ -6375,21 +6390,21 @@ function countAuthoredTimedClips(html) {
6375
6390
  }
6376
6391
 
6377
6392
  // src/services/render/stages/compileStage.ts
6378
- import { existsSync as existsSync13, writeFileSync as writeFileSync5 } from "node:fs";
6393
+ import { existsSync as existsSync12, writeFileSync as writeFileSync5 } from "node:fs";
6379
6394
  import { join as join19 } from "node:path";
6380
6395
  import { suggestMatchingPreset } from "@hyperframes/core";
6381
6396
  import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
6382
6397
  import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolution";
6383
6398
 
6384
6399
  // src/services/htmlCompiler.ts
6385
- import { decodedUrlPath as decodedUrlPath2 } from "@hyperframes/parsers/asset-paths";
6400
+ import { decodedUrlPath } from "@hyperframes/parsers/asset-paths";
6386
6401
  import { createHash as createHash6 } from "node:crypto";
6387
- import { createReadStream as createReadStream2, existsSync as existsSync12, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
6402
+ import { createReadStream as createReadStream2, existsSync as existsSync11, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
6388
6403
  import { join as join18, dirname as dirname8, resolve as resolve7, basename as basename5, relative as relative2, sep as sep2 } from "path";
6389
6404
  import { parseHTML as parseHTML5 } from "linkedom";
6390
6405
 
6391
6406
  // src/services/bundledScripts.ts
6392
- import { existsSync as existsSync9, readFileSync as readFileSync5 } from "node:fs";
6407
+ import { existsSync as existsSync8, readFileSync as readFileSync5 } from "node:fs";
6393
6408
  import { join as join15 } from "node:path";
6394
6409
  import { gsapCdnDist } from "@hyperframes/core/gsap-cdn";
6395
6410
  var GSAP_VENDOR_DIR_ENV = "HYPERFRAMES_GSAP_VENDOR_DIR";
@@ -6397,7 +6412,7 @@ function bundledScript(url) {
6397
6412
  const dir = process.env[GSAP_VENDOR_DIR_ENV];
6398
6413
  if (!dir || url !== `${gsapCdnDist()}gsap.min.js`) return null;
6399
6414
  const file = join15(dir, "gsap.min.js");
6400
- return existsSync9(file) ? readFileSync5(file) : null;
6415
+ return existsSync8(file) ? readFileSync5(file) : null;
6401
6416
  }
6402
6417
 
6403
6418
  // src/services/htmlCompiler.ts
@@ -6437,6 +6452,7 @@ import {
6437
6452
  emitRootCompositionVariableStyles,
6438
6453
  readDeclaredDefaults,
6439
6454
  parseHostVariableValues,
6455
+ boundMediaSrc,
6440
6456
  headStyleRuns,
6441
6457
  isAlwaysAppliedStyle,
6442
6458
  dedupeFontFaceRules,
@@ -6451,8 +6467,10 @@ import {
6451
6467
  } from "@hyperframes/parsers/sub-composition-validity";
6452
6468
  import {
6453
6469
  isUnresolvedAssetPlaceholder,
6470
+ namesAnotherNetworkRoot as namesAnotherNetworkRoot2,
6454
6471
  readProjectFile,
6455
- readTextFile
6472
+ readTextFile,
6473
+ resolveCompositionSrc
6456
6474
  } from "@hyperframes/parsers/asset-resolution";
6457
6475
 
6458
6476
  // src/services/renderMediaCollector.ts
@@ -6645,11 +6663,12 @@ import {
6645
6663
 
6646
6664
  // src/services/animatedGifPrep.ts
6647
6665
  import { createHash as createHash4 } from "node:crypto";
6648
- import { copyFileSync as copyFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync6 } from "node:fs";
6666
+ import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync6 } from "node:fs";
6649
6667
  import { dirname as dirname6, isAbsolute as isAbsolute2, join as join16, resolve as resolve5 } from "node:path";
6650
6668
  import { parseHTML as parseHTML3 } from "linkedom";
6651
6669
  import { parseAnimatedGifMetadata } from "@hyperframes/core";
6652
6670
  import { DEFAULT_VP9_CPU_USED, runFfmpeg as runFfmpeg2, renameWithRetry as renameWithRetry3 } from "@hyperframes/engine";
6671
+ import { namesAnotherNetworkRoot } from "@hyperframes/parsers/asset-resolution";
6653
6672
  var PREPARED_GIF_SUBDIR = "_animated_gif";
6654
6673
  var CACHE_SCHEMA = "hfgif-v1";
6655
6674
  function splitUrlSuffix(src) {
@@ -6684,14 +6703,15 @@ function resolveLocalImageSourcePath(src, options) {
6684
6703
  const { basePath } = splitUrlSuffix(trimmed);
6685
6704
  const normalizedBase = normalizeRelPath(basePath);
6686
6705
  const mapped = options.sourceAssets?.get(trimmed) ?? options.sourceAssets?.get(basePath) ?? options.sourceAssets?.get(normalizedBase);
6687
- if (mapped && existsSync10(mapped)) return mapped;
6706
+ if (mapped && existsSync9(mapped)) return mapped;
6688
6707
  if (isHttpUrl(trimmed)) return null;
6708
+ const protocolRelativeUrlOnShare = basePath.startsWith("/") && namesAnotherNetworkRoot(options.projectDir, basePath);
6689
6709
  const projectRelative = basePath.startsWith("/") ? basePath.slice(1) : basePath;
6690
6710
  const candidates = [
6691
- isAbsolute2(basePath) ? basePath : resolve5(options.projectDir, projectRelative),
6711
+ ...protocolRelativeUrlOnShare ? [] : [isAbsolute2(basePath) ? basePath : resolve5(options.projectDir, projectRelative)],
6692
6712
  resolve5(options.downloadDir, normalizedBase)
6693
6713
  ];
6694
- return candidates.find((candidate) => existsSync10(candidate)) ?? null;
6714
+ return candidates.find((candidate) => existsSync9(candidate)) ?? null;
6695
6715
  }
6696
6716
  function isUsableFile(path) {
6697
6717
  try {
@@ -6802,10 +6822,10 @@ async function runAnimatedGifTranscode(request) {
6802
6822
  throw result.error ?? new Error(`Animated GIF transcode failed (${result.exitCode}): ${result.stderr.slice(-500)}`);
6803
6823
  }
6804
6824
  async function ensurePreparedWebm(input) {
6805
- if (!existsSync10(dirname6(input.cachePath))) {
6825
+ if (!existsSync9(dirname6(input.cachePath))) {
6806
6826
  mkdirSync7(dirname6(input.cachePath), { recursive: true });
6807
6827
  }
6808
- if (!existsSync10(dirname6(input.outputPath))) {
6828
+ if (!existsSync9(dirname6(input.outputPath))) {
6809
6829
  mkdirSync7(dirname6(input.outputPath), { recursive: true });
6810
6830
  }
6811
6831
  if (!isUsableFile(input.cachePath)) {
@@ -7280,7 +7300,7 @@ import { createStudioPositionSeekReapplyScript } from "@hyperframes/studio-serve
7280
7300
  import { getPositionEditsRenderScript } from "@hyperframes/core/runtime/position-edits-render";
7281
7301
 
7282
7302
  // src/services/assetMediaType.ts
7283
- import { existsSync as existsSync11 } from "node:fs";
7303
+ import { existsSync as existsSync10 } from "node:fs";
7284
7304
  import {
7285
7305
  fingerprintElementId,
7286
7306
  isNotMediaPayload,
@@ -7353,7 +7373,7 @@ async function preflightCompositionAssetMediaTypes(input) {
7353
7373
  input.projectDir,
7354
7374
  input.compiledDir
7355
7375
  );
7356
- if (!existsSync11(resolvedPath)) continue;
7376
+ if (!existsSync10(resolvedPath)) continue;
7357
7377
  byPath.set(resolvedPath, [...byPath.get(resolvedPath) ?? [], reference]);
7358
7378
  }
7359
7379
  const mismatches = [];
@@ -7393,7 +7413,7 @@ async function preflightCompositionAssetMediaTypes(input) {
7393
7413
 
7394
7414
  // src/services/htmlCompiler.ts
7395
7415
  function logRemoteDownloadTelemetry(event) {
7396
- defaultLogger.info("[Compiler] Remote asset download integrity", { ...event });
7416
+ defaultLogger.debug("[Compiler] Remote asset download integrity", { ...event });
7397
7417
  }
7398
7418
  var INFERRED_MEDIA_DURATION_ATTR = "data-hf-inferred-duration";
7399
7419
  function parseSubCompHtmlForValidity(html) {
@@ -7607,7 +7627,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, down
7607
7627
  let filePath = src;
7608
7628
  if (isHttpUrl(src)) {
7609
7629
  const remoteDir = join18(downloadDir, REMOTE_MEDIA_SUBDIR);
7610
- if (!existsSync12(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
7630
+ if (!existsSync11(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
7611
7631
  try {
7612
7632
  filePath = await downloadToTemp(src, remoteDir, void 0, void 0, void 0, {
7613
7633
  onTelemetry: logRemoteDownloadTelemetry
@@ -7616,11 +7636,14 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, down
7616
7636
  return { duration: null, resolvedPath: src };
7617
7637
  }
7618
7638
  } else {
7619
- filePath = decodedUrlPath2(src);
7639
+ filePath = decodedUrlPath(src);
7620
7640
  if (!filePath.startsWith("/")) filePath = join18(baseDir, filePath);
7621
7641
  filePath = urlByAbsentLocalPath?.get(filePath) ?? filePath;
7642
+ if (!isHttpUrl(filePath) && namesAnotherNetworkRoot2(baseDir, filePath)) {
7643
+ return { duration: null, resolvedPath: filePath };
7644
+ }
7622
7645
  }
7623
- if (!isHttpUrl(filePath) && !existsSync12(filePath)) {
7646
+ if (!isHttpUrl(filePath) && !existsSync11(filePath)) {
7624
7647
  return { duration: null, resolvedPath: filePath };
7625
7648
  }
7626
7649
  const withSrcContext = (error) => {
@@ -7969,7 +7992,7 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
7969
7992
  parseHtml: (htmlStr) => parseHTML5(htmlStr).document,
7970
7993
  // Mirrors the preview bundler: a sub-composition's SIBLING assets resolve
7971
7994
  // against its own directory, project-root refs stay as authored.
7972
- assetExists: (path) => existsSync12(resolve7(projectDir, path)),
7995
+ assetExists: (path) => existsSync11(resolve7(projectDir, path)),
7973
7996
  // Preserve the authored root wrapper as a child of the host, matching
7974
7997
  // the preview bundler's shape (htmlBundler.ts's prepareFlattenedInnerRoot,
7975
7998
  // which the runtime compositionLoader mirrors with its own copy for the
@@ -8145,7 +8168,7 @@ ${safeText}
8145
8168
  //# sourceURL=${new URL(src).href}
8146
8169
  `;
8147
8170
  el.replaceWith(inlineScript);
8148
- defaultLogger.info(`[Compiler] Inlined CDN script: ${src}`);
8171
+ defaultLogger.debug(`[Compiler] Inlined CDN script: ${src}`);
8149
8172
  } else {
8150
8173
  if (download.reason instanceof ScriptIntegrityError) throw download.reason;
8151
8174
  defaultLogger.warn(
@@ -8165,7 +8188,7 @@ function collectExternalAssets(html, projectDir) {
8165
8188
  if (isPathInside2(absPath, absProjectDir)) {
8166
8189
  return null;
8167
8190
  }
8168
- if (!existsSync12(absPath)) return null;
8191
+ if (!existsSync11(absPath)) return null;
8169
8192
  const safeKey = toExternalAssetKey(absPath);
8170
8193
  externalAssets.set(safeKey, absPath);
8171
8194
  return safeKey;
@@ -8200,7 +8223,7 @@ function collectExternalAssets(html, projectDir) {
8200
8223
  if (rewritten !== style) el.setAttribute("style", rewritten);
8201
8224
  }
8202
8225
  if (externalAssets.size > 0) {
8203
- defaultLogger.info(
8226
+ defaultLogger.debug(
8204
8227
  `[Compiler] Found ${externalAssets.size} asset(s) outside project directory, will copy to render output`
8205
8228
  );
8206
8229
  }
@@ -8215,7 +8238,7 @@ var REMOTE_SOURCE_TAG_RE = /<source\b[^>]*?\bsrc\s*=\s*["'](https?:\/\/[^"']+)["
8215
8238
  var REMOTE_IMG_TAG_RE = /<img\b[^>]*?(?<![\w-])src\s*=\s*["'](https?:\/\/[^"']+)["'][^>]*>/gi;
8216
8239
  async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLabel, extraRewrite) {
8217
8240
  if (urlSet.size === 0) return { html, remoteMediaAssets: /* @__PURE__ */ new Map() };
8218
- if (!existsSync12(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
8241
+ if (!existsSync11(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
8219
8242
  const urlToLocal = /* @__PURE__ */ new Map();
8220
8243
  await Promise.all(
8221
8244
  [...urlSet].map(async (url) => {
@@ -8247,7 +8270,7 @@ async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLab
8247
8270
  result = result.replaceAll(`"${url}"`, `"${relPath}"`).replaceAll(`'${url}'`, `'${relPath}'`);
8248
8271
  if (extraRewrite) result = extraRewrite(result, url, relPath);
8249
8272
  }
8250
- defaultLogger.info(`[Compiler] ${logLabel} ${urlToLocal.size} to ${REMOTE_MEDIA_SUBDIR}/`);
8273
+ defaultLogger.debug(`[Compiler] ${logLabel} ${urlToLocal.size} to ${REMOTE_MEDIA_SUBDIR}/`);
8251
8274
  return { html: result, remoteMediaAssets };
8252
8275
  }
8253
8276
  async function localizeRemoteMediaSources(html, downloadDir) {
@@ -8384,7 +8407,7 @@ async function inlineExternalFontStylesheets(html) {
8384
8407
  ${fontFaceBlocks.join("\n")}
8385
8408
  </style>`;
8386
8409
  result = result.replace(fullMatch, inlineStyle);
8387
- defaultLogger.info("[Compiler] Inlined external @font-face rule(s)", {
8410
+ defaultLogger.debug("[Compiler] Inlined external @font-face rule(s)", {
8388
8411
  count: fontFaceBlocks.length,
8389
8412
  urlFingerprint: identity.urlFingerprint,
8390
8413
  host: identity.host
@@ -8397,14 +8420,14 @@ function projectStylesheetFontFamilies(html, projectDir) {
8397
8420
  for (const [tag] of html.matchAll(/<link\b[^>]*\brel=["']stylesheet["'][^>]*>/gi)) {
8398
8421
  const href = /\bhref=["']([^"']+)["']/i.exec(tag)?.[1];
8399
8422
  if (!href || /^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(href)) continue;
8400
- const sheet = resolve7(projectDir, decodedUrlPath2(href).replace(/^(?:\.?\/)+/, ""));
8401
- if (!isPathInside2(sheet, projectDir) || !existsSync12(sheet)) continue;
8423
+ const sheet = resolve7(projectDir, decodedUrlPath(href).replace(/^(?:\.?\/)+/, ""));
8424
+ if (!isPathInside2(sheet, projectDir) || !existsSync11(sheet)) continue;
8402
8425
  for (const face of extractFontFaceBlocks(readFileSync8(sheet, "utf8"))) {
8403
8426
  const family = /font-family\s*:\s*([^;}]+)/i.exec(face)?.[1]?.trim().replace(/^['"]|['"]$/g, "");
8404
8427
  const shipsFile = [...face.matchAll(LOCAL_FONTFACE_URL_RE)].some(([, url = ""]) => {
8405
- const path = decodedUrlPath2(url);
8428
+ const path = decodedUrlPath(url);
8406
8429
  const file = path.startsWith("/") ? resolve7(projectDir, `.${path}`) : resolve7(dirname8(sheet), path);
8407
- return isPathInside2(file, projectDir) && existsSync12(file);
8430
+ return isPathInside2(file, projectDir) && existsSync11(file);
8408
8431
  });
8409
8432
  if (family && shipsFile) families.push(family);
8410
8433
  }
@@ -8506,7 +8529,7 @@ async function embedLocalFontFaces(html, projectDir) {
8506
8529
  const font = await readLocalFont(absPath);
8507
8530
  if (font.kind === "file-backed") {
8508
8531
  fileBackedAbsolutePaths.add(absPath);
8509
- defaultLogger.info(
8532
+ defaultLogger.debug(
8510
8533
  `[Compiler] Kept large local font file-backed: ${localPath} (> ${(MAX_LOCAL_FONT_DATA_URI_BYTES / 1024 / 1024).toFixed(1)} MB)`
8511
8534
  );
8512
8535
  embeddedPaths.add(localPath);
@@ -8514,7 +8537,7 @@ async function embedLocalFontFaces(html, projectDir) {
8514
8537
  }
8515
8538
  dataUri = await toDataUri(font.buffer, ext, { compressToWoff2: false });
8516
8539
  dataUriByAbsolutePath.set(absPath, dataUri);
8517
- defaultLogger.info(
8540
+ defaultLogger.debug(
8518
8541
  `[Compiler] Embedded local font file: ${localPath} (${(font.buffer.length / 1024).toFixed(0)} KB \u2192 data URI)`
8519
8542
  );
8520
8543
  }
@@ -8542,14 +8565,17 @@ function renderGsapDist() {
8542
8565
  }
8543
8566
  function rewriteUnresolvableGsapToCdn(html, projectDir, compSrcPath) {
8544
8567
  let gsapDist;
8545
- const exists = (path) => existsSync12(resolve7(projectDir, path));
8568
+ const exists = (path) => {
8569
+ const file = resolve7(projectDir, path);
8570
+ return !namesAnotherNetworkRoot2(projectDir, file) && existsSync11(file);
8571
+ };
8546
8572
  return html.replace(
8547
8573
  /(<script\b[^>]*\bsrc=["'])([^"']*gsap[^"']*\/dist\/([^"']+))(["'][^>]*>)/gi,
8548
8574
  (full, prefix, src, file, suffix) => {
8549
8575
  if (/^https?:\/\//i.test(src)) return full;
8550
8576
  if (exists(compSrcPath ? rewriteAssetPath(compSrcPath, src, exists) : src)) return full;
8551
8577
  gsapDist ??= renderGsapDist();
8552
- defaultLogger.info(`[Compiler] Rewriting missing gsap script: ${src} \u2192 ${gsapDist}${file}`);
8578
+ defaultLogger.debug(`[Compiler] Rewriting missing gsap script: ${src} \u2192 ${gsapDist}${file}`);
8553
8579
  return `${prefix}${gsapDist}${file}${suffix}`;
8554
8580
  }
8555
8581
  );
@@ -8559,7 +8585,7 @@ function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath) {
8559
8585
  const entryPath = relative2(projectDir, htmlPath).replace(/\\/g, "/");
8560
8586
  if (!entryPath.includes("/")) return html;
8561
8587
  const { document: document2 } = parseHTML5(html);
8562
- const assetExists = (path) => existsSync12(resolve7(projectDir, path));
8588
+ const assetExists = (path) => existsSync11(resolve7(projectDir, path));
8563
8589
  rewriteAssetPaths(
8564
8590
  document2.querySelectorAll("[src], [href], [srcset]"),
8565
8591
  entryPath,
@@ -8579,11 +8605,29 @@ function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath) {
8579
8605
  }
8580
8606
  return document2.toString();
8581
8607
  }
8608
+ function bindVariableMediaSources(html, variables) {
8609
+ if (!html.includes("data-var-src")) return html;
8610
+ const { document: document2 } = parseHTML5(html);
8611
+ const declared = {};
8612
+ for (const el of document2.querySelectorAll("[data-composition-variables]")) {
8613
+ Object.assign(declared, readDeclaredDefaults(el));
8614
+ }
8615
+ const values = { ...declared, ...variables };
8616
+ let changed = false;
8617
+ for (const el of document2.querySelectorAll("video[data-var-src], audio[data-var-src]")) {
8618
+ if (el.closest("[data-variable-values]")) continue;
8619
+ const src = boundMediaSrc(el, values);
8620
+ if (src === null || el.getAttribute("src") === src) continue;
8621
+ el.setAttribute("src", src);
8622
+ changed = true;
8623
+ }
8624
+ return changed ? document2.toString() : html;
8625
+ }
8582
8626
  async function compileForRender(projectDir, htmlPath, downloadDir, options = {}) {
8583
8627
  const entryHtml = rebaseDirectEntryAssetPaths(readTextFile(htmlPath), projectDir, htmlPath);
8584
- const rawHtml = normalizeCompositionSrcs(
8585
- rewriteUnresolvableGsapToCdn(entryHtml, projectDir),
8586
- projectDir
8628
+ const rawHtml = bindVariableMediaSources(
8629
+ normalizeCompositionSrcs(rewriteUnresolvableGsapToCdn(entryHtml, projectDir), projectDir),
8630
+ options.variables ?? {}
8587
8631
  );
8588
8632
  assertSubCompositionsUsable(rawHtml, projectDir);
8589
8633
  const probes = /* @__PURE__ */ new Map();
@@ -8667,7 +8711,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
8667
8711
  timeoutMs: options.ffmpegProcessTimeout
8668
8712
  });
8669
8713
  if (preparedHeifImages.length > 0) {
8670
- defaultLogger.info(`[Compiler] Converted ${preparedHeifImages.length} HEIC image(s) to JPEG`);
8714
+ defaultLogger.debug(`[Compiler] Converted ${preparedHeifImages.length} HEIC image(s) to JPEG`);
8671
8715
  }
8672
8716
  const gifSourceAssets = new Map(remoteImageAssets);
8673
8717
  const {
@@ -8682,7 +8726,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
8682
8726
  timeoutMs: options.ffmpegProcessTimeout
8683
8727
  });
8684
8728
  if (preparedGifs.length > 0) {
8685
- defaultLogger.info(`[Compiler] Prepared ${preparedGifs.length} animated GIF input(s) as WebM`);
8729
+ defaultLogger.debug(`[Compiler] Prepared ${preparedGifs.length} animated GIF input(s) as WebM`);
8686
8730
  }
8687
8731
  const embeddedHtml = await embedLocalFontFaces(htmlWithPreparedGifs, projectDir);
8688
8732
  const { html, externalAssets } = collectExternalAssets(embeddedHtml, projectDir);
@@ -8710,7 +8754,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
8710
8754
  for (const video of videos) {
8711
8755
  if (isHttpUrl(video.src)) continue;
8712
8756
  const videoPath = resolve7(projectDir, video.src);
8713
- if (advised.has(videoPath)) continue;
8757
+ if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath)) continue;
8714
8758
  advised.add(videoPath);
8715
8759
  const reencode = `ffmpeg -i "${video.src}" -c:v libx264 -r 30 -g 30 -keyint_min 30 -movflags +faststart -c:a copy output.mp4`;
8716
8760
  (async () => {
@@ -9129,7 +9173,7 @@ function resolveEntryHtmlPath(input) {
9129
9173
  const rawEntry = readTextFile2(htmlPath);
9130
9174
  if (entryFile === "index.html" || !isTemplateEntry(rawEntry)) return htmlPath;
9131
9175
  const projectIndexPath = join19(projectDir, "index.html");
9132
- if (!existsSync13(projectIndexPath)) {
9176
+ if (!existsSync12(projectIndexPath)) {
9133
9177
  throw new Error(
9134
9178
  `Template entry file "${entryFile}" requires a project index.html to extract its render shell.`
9135
9179
  );
@@ -9462,7 +9506,8 @@ async function runProbeStage(input) {
9462
9506
  height,
9463
9507
  needsAlpha,
9464
9508
  deviceScaleFactor,
9465
- subTimelineWaitMemo
9509
+ subTimelineWaitMemo,
9510
+ staticDedupMemo
9466
9511
  } = input;
9467
9512
  let { compiled } = input;
9468
9513
  const probeCfg = cfg.forceScreenshot === forceScreenshot ? cfg : { ...cfg, forceScreenshot };
@@ -9523,7 +9568,11 @@ async function runProbeStage(input) {
9523
9568
  motionBlur,
9524
9569
  pageMotionBlur: job.config.pageMotionBlur,
9525
9570
  requiresWebGpu: compositionRequiresWebGpu(compiled.html),
9526
- subTimelineWaitMemo
9571
+ subTimelineWaitMemo,
9572
+ staticDedupMemo,
9573
+ compositionHash: computeCompositionObservabilityHash(compiled.html),
9574
+ deferStaticDedup: true,
9575
+ onStaticDedupActivity: () => noteStaticDedupActivity(job)
9527
9576
  };
9528
9577
  const PROBE_MAX_ATTEMPTS = 2;
9529
9578
  for (let attempt = 1; attempt <= PROBE_MAX_ATTEMPTS; attempt++) {
@@ -10012,7 +10061,7 @@ function validateDistributedDuration(input) {
10012
10061
  }
10013
10062
 
10014
10063
  // src/services/render/stages/extractVideosStage.ts
10015
- import { existsSync as existsSync14 } from "node:fs";
10064
+ import { existsSync as existsSync13 } from "node:fs";
10016
10065
  import { join as join21 } from "node:path";
10017
10066
  import {
10018
10067
  classifyVideoExtractionError,
@@ -10287,7 +10336,7 @@ async function runExtractVideosStage(input) {
10287
10336
  const probeFailures = await Promise.all(
10288
10337
  composition.videos.map(async (v) => {
10289
10338
  const videoPath = resolveProjectRelativeSrc3(v.src, projectDir, compiledDir);
10290
- if (!existsSync14(videoPath)) return null;
10339
+ if (!existsSync13(videoPath)) return null;
10291
10340
  try {
10292
10341
  const attempted = extractionPolicy.maxTransientRetries === 0 ? { result: await extractMediaMetadata3(videoPath), retries: 0 } : await runVideoExtractionWithRetry2(() => extractMediaMetadata3(videoPath), {
10293
10342
  signal: abortSignal,
@@ -10325,7 +10374,7 @@ async function runExtractVideosStage(input) {
10325
10374
  const probed = await Promise.all(
10326
10375
  composition.images.map(async (img) => {
10327
10376
  const imgPath = resolveProjectRelativeSrc3(img.src, projectDir, compiledDir);
10328
- if (!existsSync14(imgPath)) return null;
10377
+ if (!existsSync13(imgPath)) return null;
10329
10378
  const colorSpace = await probeColorSpaceSafely(imgPath, log);
10330
10379
  if (isHdrColorSpace2(colorSpace)) {
10331
10380
  nativeHdrImageIds.add(img.id);
@@ -10445,7 +10494,7 @@ async function appendVideoAudioFromProbe(input) {
10445
10494
  videos.map(async (video) => {
10446
10495
  const path = isHttpUrl2(video.src) ? video.src : resolveProjectRelativeSrc3(video.src, projectDir, compiledDir);
10447
10496
  const readFrom = urlByAbsentLocalPath?.get(path) ?? path;
10448
- if (!isHttpUrl2(readFrom) && !existsSync14(readFrom)) return null;
10497
+ if (!isHttpUrl2(readFrom) && !existsSync13(readFrom)) return null;
10449
10498
  const metadata = await extractMediaMetadata3(readFrom);
10450
10499
  const window2 = await resolveFinalFrameExtractionWindow2(
10451
10500
  readFrom,
@@ -10465,7 +10514,7 @@ async function appendVideoAudioFromProbe(input) {
10465
10514
  }
10466
10515
 
10467
10516
  // src/services/render/videoLayerPassthroughPlan.ts
10468
- import { existsSync as existsSync15 } from "node:fs";
10517
+ import { existsSync as existsSync14 } from "node:fs";
10469
10518
  import {
10470
10519
  buildVideoLayerInput,
10471
10520
  isHttpUrl as isHttpUrl3,
@@ -10533,7 +10582,7 @@ async function planVideoLayerPassthrough(input) {
10533
10582
  const { video } = q;
10534
10583
  if (isHttpUrl3(video.src)) return { reason: "remote_source" };
10535
10584
  const path = resolveProjectRelativeSrc4(video.src, input.projectDir, input.compiledDir);
10536
- if (!existsSync15(path)) return { reason: "source_missing" };
10585
+ if (!existsSync14(path)) return { reason: "source_missing" };
10537
10586
  const layout = await probeVideoLayout(input.page, video.id, input.canvas, input.duration);
10538
10587
  if ("reason" in layout) return layout;
10539
10588
  const layer = await buildVideoLayerInput(
@@ -10548,7 +10597,7 @@ async function planVideoLayerPassthrough(input) {
10548
10597
  }
10549
10598
 
10550
10599
  // src/services/render/stages/audioStage.ts
10551
- import { existsSync as existsSync17 } from "node:fs";
10600
+ import { existsSync as existsSync16 } from "node:fs";
10552
10601
  import { join as join24 } from "node:path";
10553
10602
  import {
10554
10603
  MIXED_AUDIO_FILENAME,
@@ -10559,7 +10608,7 @@ import {
10559
10608
  } from "@hyperframes/engine";
10560
10609
 
10561
10610
  // src/services/render/audioDeliveryLimit.ts
10562
- import { existsSync as existsSync16 } from "node:fs";
10611
+ import { existsSync as existsSync15 } from "node:fs";
10563
10612
  import { dirname as dirname10, join as join23 } from "node:path";
10564
10613
  import {
10565
10614
  applyAudioFxChain,
@@ -11068,7 +11117,7 @@ async function limitDeliveryPeaks(input, deps = {
11068
11117
  applyChain: applyAudioFxChain,
11069
11118
  encode: encodeAac2,
11070
11119
  rename: renameWithRetry6,
11071
- sourceExists: existsSync16
11120
+ sourceExists: existsSync15
11072
11121
  }) {
11073
11122
  const { audioPath, sourcePath, signal, timeoutMs } = input;
11074
11123
  if (!deps.sourceExists(sourcePath)) return { success: true };
@@ -11163,7 +11212,7 @@ async function runAudioStageScoped(input) {
11163
11212
  );
11164
11213
  audioLoweredDb = guard.loweredDb;
11165
11214
  input.log?.info("[audio] phases", { ...result.audioPhaseMs, guard: Date.now() - guardStart });
11166
- if (input.keepDeliverySource && !guard.sourceStale && existsSync17(pcmSourcePath)) {
11215
+ if (input.keepDeliverySource && !guard.sourceStale && existsSync16(pcmSourcePath)) {
11167
11216
  deliverySourcePath = pcmSourcePath;
11168
11217
  }
11169
11218
  }
@@ -11291,7 +11340,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
11291
11340
  }
11292
11341
 
11293
11342
  // src/services/render/stages/captureStage.ts
11294
- import { existsSync as existsSync18, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
11343
+ import { existsSync as existsSync17, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
11295
11344
  import { join as join25 } from "node:path";
11296
11345
  import {
11297
11346
  classifyCaptureFailure as classifyCaptureFailure2,
@@ -11362,7 +11411,7 @@ function diskCaptureShortfallError(needBytes, freeBytes, framesDir, basis, remed
11362
11411
  }
11363
11412
  function measureCaptureFrameBytes(workDir, framesDir) {
11364
11413
  let total = sampleDirectoryBytes(framesDir);
11365
- if (!existsSync18(workDir)) return total;
11414
+ if (!existsSync17(workDir)) return total;
11366
11415
  for (const attempt of readdirSync4(workDir)) {
11367
11416
  if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
11368
11417
  total += sampleDirectoryBytes(join25(workDir, attempt));
@@ -11544,7 +11593,7 @@ async function runSequentialDiskCapture(input, captureOptions, captureCfg, check
11544
11593
  captureBeyondViewport = session.options.captureBeyondViewport;
11545
11594
  try {
11546
11595
  if (probeSession) {
11547
- prepareCaptureSessionForReuse3(session, framesDir, videoInjector);
11596
+ await prepareCaptureSessionForReuse3(session, framesDir, videoInjector);
11548
11597
  probeSession = null;
11549
11598
  }
11550
11599
  await ensureSessionReady(session, {
@@ -11669,7 +11718,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
11669
11718
  }
11670
11719
 
11671
11720
  // src/services/render/stages/captureHdrStage.ts
11672
- import { existsSync as existsSync20, mkdirSync as mkdirSync10 } from "node:fs";
11721
+ import { existsSync as existsSync19, mkdirSync as mkdirSync10 } from "node:fs";
11673
11722
  import { join as join29 } from "node:path";
11674
11723
  import {
11675
11724
  closeCaptureSession as closeCaptureSession7,
@@ -11915,7 +11964,7 @@ import { Worker } from "node:worker_threads";
11915
11964
  import { fileURLToPath as fileURLToPath3, pathToFileURL } from "node:url";
11916
11965
  import { dirname as dirname11, join as join27 } from "node:path";
11917
11966
  import { createRequire } from "node:module";
11918
- import { existsSync as existsSync19 } from "node:fs";
11967
+ import { existsSync as existsSync18 } from "node:fs";
11919
11968
  import { cpus as cpus2 } from "node:os";
11920
11969
  function resolveWorkerEntry(explicit) {
11921
11970
  if (explicit && explicit.length > 0) {
@@ -11928,7 +11977,7 @@ function resolveWorkerEntry(explicit) {
11928
11977
  }
11929
11978
  const moduleDir = dirname11(fileURLToPath3(import.meta.url));
11930
11979
  const jsPath = join27(moduleDir, "shaderTransitionWorker.js");
11931
- if (existsSync19(jsPath)) return { path: jsPath, isTs: false };
11980
+ if (existsSync18(jsPath)) return { path: jsPath, isTs: false };
11932
11981
  const tsPath = join27(moduleDir, "shaderTransitionWorker.ts");
11933
11982
  return { path: tsPath, isTs: true };
11934
11983
  }
@@ -12489,7 +12538,7 @@ async function runCaptureHdrStage(input) {
12489
12538
  }
12490
12539
  const debugDumpEnabled = process.env.KEEP_TEMP === "1";
12491
12540
  const debugDumpDir = debugDumpEnabled ? join29(framesDir, "debug-composite") : null;
12492
- if (debugDumpDir && !existsSync20(debugDumpDir)) {
12541
+ if (debugDumpDir && !existsSync19(debugDumpDir)) {
12493
12542
  mkdirSync10(debugDumpDir, { recursive: true });
12494
12543
  }
12495
12544
  const compositeTransfer = resolveCompositeTransfer(hasHdrContent, effectiveHdr);
@@ -12646,7 +12695,7 @@ async function runCaptureHdrStage(input) {
12646
12695
  // src/services/render/stages/encodeStage.ts
12647
12696
  import {
12648
12697
  copyFileSync as copyFileSync4,
12649
- existsSync as existsSync21,
12698
+ existsSync as existsSync20,
12650
12699
  mkdirSync as mkdirSync11,
12651
12700
  readdirSync as readdirSync5,
12652
12701
  readFileSync as readFileSync9,
@@ -12780,7 +12829,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
12780
12829
  const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
12781
12830
  if (failure) return failure;
12782
12831
  }
12783
- const fileSize = existsSync21(outputPath) ? statSync8(outputPath).size : 0;
12832
+ const fileSize = existsSync20(outputPath) ? statSync8(outputPath).size : 0;
12784
12833
  return {
12785
12834
  success: true,
12786
12835
  outputPath,
@@ -12941,7 +12990,7 @@ async function runEncodeStage(input) {
12941
12990
  const stage5Start = Date.now();
12942
12991
  if (isPngSequence) {
12943
12992
  const encoded = startEncodeProgress(job, "Writing PNG sequence", onProgress);
12944
- if (!existsSync21(outputPath)) mkdirSync11(outputPath, { recursive: true });
12993
+ if (!existsSync20(outputPath)) mkdirSync11(outputPath, { recursive: true });
12945
12994
  const captured = readdirSync5(framesDir).filter((name) => name.endsWith(".png")).sort();
12946
12995
  if (captured.length === 0) {
12947
12996
  throw new Error(
@@ -12952,7 +13001,7 @@ async function runEncodeStage(input) {
12952
13001
  const dst = join30(outputPath, formatExportFrameName(i, "png"));
12953
13002
  copyFileSync4(join30(framesDir, name), dst);
12954
13003
  });
12955
- if (hasAudio && audioOutputPath && existsSync21(audioOutputPath)) {
13004
+ if (hasAudio && audioOutputPath && existsSync20(audioOutputPath)) {
12956
13005
  copyFileSync4(audioOutputPath, join30(outputPath, MIXED_AUDIO_FILENAME2));
12957
13006
  log.info(
12958
13007
  `[Render] png-sequence: ${MIXED_AUDIO_FILENAME2} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME2}`
@@ -13341,7 +13390,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
13341
13390
  let rangeStart = null;
13342
13391
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
13343
13392
  const framePath = join31(framesDir, formatCaptureFrameName(frameIndex, frameExt));
13344
- const missing = !existsSync22(framePath) || statSync9(framePath).size <= 8;
13393
+ const missing = !existsSync21(framePath) || statSync9(framePath).size <= 8;
13345
13394
  if (missing && rangeStart === null) {
13346
13395
  rangeStart = frameIndex;
13347
13396
  } else if (!missing && rangeStart !== null) {
@@ -13448,7 +13497,8 @@ function frameStallRule(job, totalFrames, probeStartupMs) {
13448
13497
  complete: () => (job.framesRendered ?? 0) >= totalFrames,
13449
13498
  tailMs: Math.max(TAIL_STALL_MS, noProgressMs),
13450
13499
  detail: () => describeWorkerPhases(job),
13451
- attemptOpened: () => forgetWorkerPhases(job)
13500
+ attemptOpened: () => forgetWorkerPhases(job),
13501
+ activity: () => staticDedupActivity(job)
13452
13502
  };
13453
13503
  }
13454
13504
  function isRecoverableParallelCaptureError(error) {
@@ -13473,7 +13523,7 @@ function countCapturedFrames(totalFrames, framesDir, frameExt) {
13473
13523
  let captured = 0;
13474
13524
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
13475
13525
  const framePath = join31(framesDir, formatCaptureFrameName(frameIndex, frameExt));
13476
- if (existsSync22(framePath)) captured++;
13526
+ if (existsSync21(framePath)) captured++;
13477
13527
  }
13478
13528
  return captured;
13479
13529
  }
@@ -14139,7 +14189,7 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
14139
14189
  validateChromaSubsamplingConfig(job.config);
14140
14190
  const debugDir = resolveRenderDebugDir();
14141
14191
  const outputDir = dirname13(outputPath);
14142
- if (!existsSync22(outputDir)) mkdirSync12(outputDir, { recursive: true });
14192
+ if (!existsSync21(outputDir)) mkdirSync12(outputDir, { recursive: true });
14143
14193
  const workDir = job.config.debug ? join31(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
14144
14194
  const pipelineStart = Date.now();
14145
14195
  const baseLog = job.config.logger ?? defaultLogger;
@@ -14281,7 +14331,7 @@ async function executeRenderPipeline(input) {
14281
14331
  job.startedAt = /* @__PURE__ */ new Date();
14282
14332
  assertNotAborted();
14283
14333
  assertConfiguredFfmpegBinariesExist();
14284
- if (!existsSync22(workDir)) mkdirSync12(workDir, { recursive: true });
14334
+ if (!existsSync21(workDir)) mkdirSync12(workDir, { recursive: true });
14285
14335
  if (job.config.debug) {
14286
14336
  log.info("[Render] Debug artifacts enabled", { workDir, logPath });
14287
14337
  }
@@ -14311,7 +14361,7 @@ async function executeRenderPipeline(input) {
14311
14361
  });
14312
14362
  const entryFile = job.config.entryFile || "index.html";
14313
14363
  const htmlPath = join31(projectDir, entryFile);
14314
- if (!existsSync22(htmlPath)) {
14364
+ if (!existsSync21(htmlPath)) {
14315
14365
  throw new Error(`Entry file not found: ${htmlPath}`);
14316
14366
  }
14317
14367
  assertNotAborted();
@@ -14403,6 +14453,7 @@ async function executeRenderPipeline(input) {
14403
14453
  (result) => Object.assign(job, result)
14404
14454
  );
14405
14455
  const subTimelineWaitMemo = {};
14456
+ const staticDedupMemo = {};
14406
14457
  const probeResult = await observeRenderStage(
14407
14458
  observability,
14408
14459
  "browser_probe",
@@ -14423,6 +14474,7 @@ async function executeRenderPipeline(input) {
14423
14474
  needsAlpha,
14424
14475
  deviceScaleFactor,
14425
14476
  subTimelineWaitMemo,
14477
+ staticDedupMemo,
14426
14478
  recordReferenceBackground
14427
14479
  }),
14428
14480
  // Browser probe is pre-capture; report `browser calibrating` so a
@@ -14655,7 +14707,7 @@ async function executeRenderPipeline(input) {
14655
14707
  throw new Error("File server failed to initialize before frame capture");
14656
14708
  }
14657
14709
  const framesDir = join31(workDir, "captured-frames");
14658
- if (!existsSync22(framesDir)) mkdirSync12(framesDir, { recursive: true });
14710
+ if (!existsSync21(framesDir)) mkdirSync12(framesDir, { recursive: true });
14659
14711
  updateJobStatus(job, "rendering", "Checking browser GPU", 25, onProgress, {
14660
14712
  code: "start_browsers"
14661
14713
  });
@@ -14714,6 +14766,9 @@ async function executeRenderPipeline(input) {
14714
14766
  videoMetadataHints,
14715
14767
  skipReadinessVideoIds: videoReadinessSkipIds,
14716
14768
  subTimelineWaitMemo,
14769
+ staticDedupMemo,
14770
+ compositionHash,
14771
+ onStaticDedupActivity: () => noteStaticDedupActivity(job),
14717
14772
  // Probe-resolved duration: drawElement self-verification derives its
14718
14773
  // sample frame indices from this so they land inside the drained range.
14719
14774
  compositionDurationSeconds: job.duration,
@@ -16060,7 +16115,7 @@ async function executeRenderPipeline(input) {
16060
16115
  })
16061
16116
  );
16062
16117
  const totalElapsed = Date.now() - pipelineStart;
16063
- const tmpPeakBytes = existsSync22(workDir) ? sampleDirectoryBytes(workDir) : 0;
16118
+ const tmpPeakBytes = existsSync21(workDir) ? sampleDirectoryBytes(workDir) : 0;
16064
16119
  recordTransientRetryObservability();
16065
16120
  observability.checkpoint("pipeline", "artifact validated", { totalElapsedMs: totalElapsed });
16066
16121
  const observabilitySummary = observability.summary({
@@ -16141,7 +16196,7 @@ async function executeRenderPipeline(input) {
16141
16196
  }
16142
16197
  }
16143
16198
  if (job.config.debug) {
16144
- if (!isPngSequence && !isHls && existsSync22(stagedOutputPath)) {
16199
+ if (!isPngSequence && !isHls && existsSync21(stagedOutputPath)) {
16145
16200
  const debugOutput = join31(workDir, `output${videoExt}`);
16146
16201
  copyFileSync5(stagedOutputPath, debugOutput);
16147
16202
  }
@@ -16654,7 +16709,7 @@ import { audioFailureDiagnostics as audioFailureDiagnostics3 } from "@hyperframe
16654
16709
  import {
16655
16710
  copyFileSync as copyFileSync6,
16656
16711
  cpSync as cpSync2,
16657
- existsSync as existsSync27,
16712
+ existsSync as existsSync26,
16658
16713
  linkSync,
16659
16714
  mkdirSync as mkdirSync16,
16660
16715
  rmSync as rmSync14,
@@ -16685,7 +16740,7 @@ import {
16685
16740
  } from "@hyperframes/engine";
16686
16741
 
16687
16742
  // src/services/distributed/chunkFrames.ts
16688
- import { existsSync as existsSync24, readdirSync as readdirSync7 } from "node:fs";
16743
+ import { existsSync as existsSync23, readdirSync as readdirSync7 } from "node:fs";
16689
16744
  import { extname as extname4, join as join34 } from "node:path";
16690
16745
  import {
16691
16746
  compositionRequiresWebGpu as compositionRequiresWebGpu3,
@@ -16696,7 +16751,7 @@ import {
16696
16751
  // src/services/distributed/shared.ts
16697
16752
  import { execFile as execFileCallback } from "node:child_process";
16698
16753
  import { dirname as dirname15, join as join33 } from "node:path";
16699
- import { existsSync as existsSync23, readFileSync as readFileSync10 } from "node:fs";
16754
+ import { existsSync as existsSync22, readFileSync as readFileSync10 } from "node:fs";
16700
16755
  import { fileURLToPath as fileURLToPath5 } from "node:url";
16701
16756
  import { promisify as promisify2 } from "node:util";
16702
16757
  import {
@@ -16712,7 +16767,7 @@ function isPlanAudioArtifactPath(path) {
16712
16767
  function resolvePlanAudioPath(planDir) {
16713
16768
  for (const name of [PLAN_AUDIO_RELATIVE_PATH, PLAN_AUDIO_LEGACY_RELATIVE_PATH]) {
16714
16769
  const candidate = join33(planDir, name);
16715
- if (existsSync23(candidate)) return candidate;
16770
+ if (existsSync22(candidate)) return candidate;
16716
16771
  }
16717
16772
  return null;
16718
16773
  }
@@ -16973,7 +17028,7 @@ function readProducerVersion() {
16973
17028
  let current = startDir;
16974
17029
  for (let i = 0; i < 10; i++) {
16975
17030
  const candidate = join33(current, "package.json");
16976
- if (existsSync23(candidate)) {
17031
+ if (existsSync22(candidate)) {
16977
17032
  try {
16978
17033
  const pkg = JSON.parse(readFileSync10(candidate, "utf-8"));
16979
17034
  if (pkg.name === "@hyperframes/producer" && typeof pkg.version === "string") {
@@ -17028,7 +17083,7 @@ function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v
17028
17083
  const result = [];
17029
17084
  for (const v of videos) {
17030
17085
  const outputDir = join34(planDir, "video-frames", mediaIdPathSegment3(v.videoId));
17031
- if (!existsSync24(outputDir)) {
17086
+ if (!existsSync23(outputDir)) {
17032
17087
  throw new Error(
17033
17088
  `[renderChunk] planDir missing extracted video frames for ${JSON.stringify(v.videoId)}: ${outputDir} not present. plan() should have written frames here; the planDir is malformed.`
17034
17089
  );
@@ -17127,7 +17182,7 @@ async function extractDeferredVideoFramesForChunk(input) {
17127
17182
  const range = planned.get(video.videoId).deferredRange;
17128
17183
  const remoteUrl = remoteSources[range.sourcePath];
17129
17184
  const sourcePath = remoteUrl ?? join34(input.planDir, ...range.sourcePath.split("/"));
17130
- if (remoteUrl === void 0 && !existsSync24(sourcePath)) {
17185
+ if (remoteUrl === void 0 && !existsSync23(sourcePath)) {
17131
17186
  throw new RenderChunkValidationError(
17132
17187
  MISSING_PLAN_ARTIFACT,
17133
17188
  `[renderChunk] planDir is missing the source for video ${JSON.stringify(video.videoId)}: ${range.sourcePath}`
@@ -17327,7 +17382,7 @@ async function readPlanReferenceBackground(input) {
17327
17382
  }
17328
17383
 
17329
17384
  // src/services/render/stages/freezePlan.ts
17330
- import { existsSync as existsSync25, mkdirSync as mkdirSync14, readFileSync as readFileSync11, readdirSync as readdirSync8, writeFileSync as writeFileSync8 } from "node:fs";
17385
+ import { existsSync as existsSync24, mkdirSync as mkdirSync14, readFileSync as readFileSync11, readdirSync as readdirSync8, writeFileSync as writeFileSync8 } from "node:fs";
17331
17386
  import { join as join37, relative as relative3, resolve as resolve9 } from "node:path";
17332
17387
  import {
17333
17388
  REFERENCE_BACKGROUND_FIELD,
@@ -17521,7 +17576,7 @@ function planFileSha256(absolutePath, digests) {
17521
17576
  return sha256;
17522
17577
  }
17523
17578
  async function prehashPlanFiles(dir, digests) {
17524
- if (!existsSync25(dir)) return;
17579
+ if (!existsSync24(dir)) return;
17525
17580
  for (const { absolutePath } of listPlanFiles(dir)) {
17526
17581
  if (!digests.has(absolutePath)) digests.set(absolutePath, await sha256FileAsync(absolutePath));
17527
17582
  }
@@ -17591,15 +17646,15 @@ function writePlanRemoteFiles(planDir, files) {
17591
17646
  }
17592
17647
  function readPlanRemoteFiles(planDir) {
17593
17648
  const path = join37(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH);
17594
- return existsSync25(path) ? JSON.parse(readFileSync11(path, "utf-8")) : [];
17649
+ return existsSync24(path) ? JSON.parse(readFileSync11(path, "utf-8")) : [];
17595
17650
  }
17596
17651
  function recomputePlanHashFromPlanDir(planDir, digests) {
17597
17652
  const planJsonPath = join37(planDir, "plan.json");
17598
17653
  const encoderJsonPath = join37(planDir, "meta", "encoder.json");
17599
- if (!existsSync25(planJsonPath)) {
17654
+ if (!existsSync24(planJsonPath)) {
17600
17655
  throw new Error(`[freezePlan] plan.json missing: ${planJsonPath}`);
17601
17656
  }
17602
- if (!existsSync25(encoderJsonPath)) {
17657
+ if (!existsSync24(encoderJsonPath)) {
17603
17658
  throw new Error(`[freezePlan] meta/encoder.json missing: ${encoderJsonPath}`);
17604
17659
  }
17605
17660
  const planJson = JSON.parse(readFileSync11(planJsonPath, "utf-8"));
@@ -17629,11 +17684,11 @@ async function freezePlan(input) {
17629
17684
  hasAudio,
17630
17685
  digests
17631
17686
  } = input;
17632
- if (!existsSync25(planDir)) {
17687
+ if (!existsSync24(planDir)) {
17633
17688
  throw new Error(`[freezePlan] planDir does not exist: ${planDir}`);
17634
17689
  }
17635
17690
  const metaDir = join37(planDir, "meta");
17636
- if (!existsSync25(metaDir)) mkdirSync14(metaDir, { recursive: true });
17691
+ if (!existsSync24(metaDir)) mkdirSync14(metaDir, { recursive: true });
17637
17692
  writeFileSync8(
17638
17693
  join37(metaDir, "composition.json"),
17639
17694
  `${JSON.stringify(composition, null, 2)}
@@ -17710,7 +17765,7 @@ function applyRuntimeEnvSnapshot(snapshot, env = process.env) {
17710
17765
  }
17711
17766
 
17712
17767
  // src/services/distributed/chunkAudio.ts
17713
- import { closeSync as closeSync6, existsSync as existsSync26, ftruncateSync, mkdirSync as mkdirSync15, openSync as openSync6, readFileSync as readFileSync12 } from "node:fs";
17768
+ import { closeSync as closeSync6, existsSync as existsSync25, ftruncateSync, mkdirSync as mkdirSync15, openSync as openSync6, readFileSync as readFileSync12 } from "node:fs";
17714
17769
  import { writeFileSync as writeFileSync9, writeSync } from "node:fs";
17715
17770
  import { join as join38 } from "node:path";
17716
17771
  import { appendRenderProvenanceArgs, describeFfmpegFailure as describeFfmpegFailure4, runFfmpeg as runFfmpeg7 } from "@hyperframes/engine";
@@ -17816,7 +17871,7 @@ async function writeChunkAudioSlices(input) {
17816
17871
  }
17817
17872
  function chunkAudioSource(planDir, chunkIndex, scratchPath) {
17818
17873
  const layoutPath = join38(planDir, SLICE_LAYOUT);
17819
- if (!existsSync26(layoutPath)) return resolvePlanAudioPath(planDir);
17874
+ if (!existsSync25(layoutPath)) return resolvePlanAudioPath(planDir);
17820
17875
  const layout = JSON.parse(readFileSync12(layoutPath, "utf-8"));
17821
17876
  const frame = readFileSync12(join38(planDir, SLICE_FRAME));
17822
17877
  const fd = openSync6(scratchPath, "w");
@@ -18380,7 +18435,7 @@ function createVideoSourceShipper(input) {
18380
18435
  let result = null;
18381
18436
  for (const root of stagedRel === null ? [input.workCompiledDir, input.projectDir] : []) {
18382
18437
  const rel = pathInside(root, srcPath);
18383
- if (rel !== null && (existsSync27(join40(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
18438
+ if (rel !== null && (existsSync26(join40(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
18384
18439
  result = ["compiled", ...rel.split(sep3)].join("/");
18385
18440
  break;
18386
18441
  }
@@ -18408,7 +18463,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
18408
18463
  useGpu: false,
18409
18464
  browserGpuMode: "software"
18410
18465
  });
18411
- if (!existsSync27(planDir)) mkdirSync16(planDir, { recursive: true });
18466
+ if (!existsSync26(planDir)) mkdirSync16(planDir, { recursive: true });
18412
18467
  const log = config.logger ?? defaultLogger;
18413
18468
  const sizeLimitBytes = options.executionPlanSizeLimitBytes ?? config.planDirSizeLimitBytes ?? PLAN_DIR_SIZE_LIMIT_BYTES;
18414
18469
  const abortSignal = config.abortSignal;
@@ -18439,7 +18494,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
18439
18494
  });
18440
18495
  const entryFile = config.entryFile ?? "index.html";
18441
18496
  const htmlPath = join40(projectDir, entryFile);
18442
- if (!existsSync27(htmlPath)) {
18497
+ if (!existsSync26(htmlPath)) {
18443
18498
  throw new Error(`[plan] entry file not found: ${htmlPath}`);
18444
18499
  }
18445
18500
  const workDir = join40(planDir, ".plan-work");
@@ -18667,15 +18722,15 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
18667
18722
  logPlanStage(log, "extract", stageStarted);
18668
18723
  const stagedVideoFrames = join40(compiledDir, "__hyperframes_video_frames");
18669
18724
  const videoFramesDst = join40(planDir, "video-frames");
18670
- if (existsSync27(videoFramesDst)) rmSync14(videoFramesDst, { recursive: true, force: true });
18725
+ if (existsSync26(videoFramesDst)) rmSync14(videoFramesDst, { recursive: true, force: true });
18671
18726
  const videoSourcesDir = join40(planDir, "video-sources");
18672
18727
  rmSync14(videoSourcesDir, { recursive: true, force: true });
18673
- if (existsSync27(stagedVideoFrames)) {
18728
+ if (existsSync26(stagedVideoFrames)) {
18674
18729
  renameWithRetry8(stagedVideoFrames, videoFramesDst);
18675
18730
  } else {
18676
18731
  mkdirSync16(videoFramesDst, { recursive: true });
18677
18732
  }
18678
- if (existsSync27(finalCompiledDir)) rmSync14(finalCompiledDir, { recursive: true, force: true });
18733
+ if (existsSync26(finalCompiledDir)) rmSync14(finalCompiledDir, { recursive: true, force: true });
18679
18734
  renameWithRetry8(compiledDir, finalCompiledDir);
18680
18735
  const shipVideoSource = createVideoSourceShipper({
18681
18736
  planDir,
@@ -18796,10 +18851,10 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
18796
18851
  applyDistributedAudioWarningPolicy(job, audioResult.audioError, audioResult.audioFailures, log);
18797
18852
  }
18798
18853
  const planAudioPath = join40(planDir, PLAN_AUDIO_RELATIVE_PATH);
18799
- if (audioResult?.hasAudio && existsSync27(audioResult.audioOutputPath)) {
18854
+ if (audioResult?.hasAudio && existsSync26(audioResult.audioOutputPath)) {
18800
18855
  renameWithRetry8(audioResult.audioOutputPath, planAudioPath);
18801
18856
  }
18802
- if (chunksCarryAudio && existsSync27(planAudioPath)) {
18857
+ if (chunksCarryAudio && existsSync26(planAudioPath)) {
18803
18858
  if (options.sliceChunkAudio) {
18804
18859
  stageStarted = Date.now();
18805
18860
  await writeChunkAudioSlices({
@@ -18917,7 +18972,7 @@ async function plan(projectDir, config, planDir, options = {}) {
18917
18972
 
18918
18973
  // src/services/distributed/renderChunk.ts
18919
18974
  import { randomBytes } from "node:crypto";
18920
- import { existsSync as existsSync30, mkdirSync as mkdirSync19, readFileSync as readFileSync14, readdirSync as readdirSync11, rmSync as rmSync17, writeFileSync as writeFileSync13 } from "node:fs";
18975
+ import { existsSync as existsSync29, mkdirSync as mkdirSync19, readFileSync as readFileSync14, readdirSync as readdirSync11, rmSync as rmSync17, writeFileSync as writeFileSync13 } from "node:fs";
18921
18976
  import { cpus as cpus3 } from "node:os";
18922
18977
  import { join as join44 } from "node:path";
18923
18978
  import {
@@ -18944,7 +18999,7 @@ import {
18944
18999
  } from "@hyperframes/engine";
18945
19000
  import {
18946
19001
  copyFileSync as copyFileSync8,
18947
- existsSync as existsSync29,
19002
+ existsSync as existsSync28,
18948
19003
  lstatSync as lstatSync3,
18949
19004
  mkdirSync as mkdirSync18,
18950
19005
  readFileSync as readFileSync13,
@@ -18965,7 +19020,7 @@ import {
18965
19020
  // src/services/distributed/planV2Publisher.ts
18966
19021
  import {
18967
19022
  copyFileSync as copyFileSync7,
18968
- existsSync as existsSync28,
19023
+ existsSync as existsSync27,
18969
19024
  linkSync as linkSync2,
18970
19025
  mkdirSync as mkdirSync17,
18971
19026
  rmSync as rmSync15,
@@ -19034,7 +19089,7 @@ var LocalPlanV2ArtifactPublisher = class {
19034
19089
  #linkFile;
19035
19090
  #committed = false;
19036
19091
  constructor(destinationDir, options = {}) {
19037
- if (existsSync28(destinationDir)) {
19092
+ if (existsSync27(destinationDir)) {
19038
19093
  throw new PlanV2IntegrityError(`output directory already exists: ${destinationDir}`);
19039
19094
  }
19040
19095
  this.destinationDir = destinationDir;
@@ -19051,7 +19106,7 @@ var LocalPlanV2ArtifactPublisher = class {
19051
19106
  );
19052
19107
  }
19053
19108
  const destinationPath = planV2BlobPath(this.temporaryDir, digest);
19054
- if (existsSync28(destinationPath)) return;
19109
+ if (existsSync27(destinationPath)) return;
19055
19110
  mkdirSync17(dirname16(destinationPath), { recursive: true });
19056
19111
  const stagingDir = createStagingDir5(dirname16(destinationPath), ".plan-v2-blob-");
19057
19112
  const temporaryPath = join42(stagingDir, "blob");
@@ -19069,7 +19124,7 @@ var LocalPlanV2ArtifactPublisher = class {
19069
19124
  }
19070
19125
  async commitManifest(manifestBytes) {
19071
19126
  for (const digest of new Set(manifestDigests(manifestBytes))) {
19072
- if (!existsSync28(planV2BlobPath(this.temporaryDir, digest))) {
19127
+ if (!existsSync27(planV2BlobPath(this.temporaryDir, digest))) {
19073
19128
  throw new PlanV2IntegrityError(
19074
19129
  `cannot commit manifest before referenced blob is durable: ${digest}`
19075
19130
  );
@@ -19149,7 +19204,7 @@ function assertValidExtractionCacheCompleteSentinel(path) {
19149
19204
  }
19150
19205
  function validateExtractionCacheCompleteSentinels(executionPlanDir) {
19151
19206
  const videoRoot = join43(executionPlanDir, "video-frames");
19152
- if (!existsSync29(videoRoot)) return;
19207
+ if (!existsSync28(videoRoot)) return;
19153
19208
  for (const videoEntry of readdirSync10(videoRoot, { withFileTypes: true })) {
19154
19209
  if (!videoEntry.isDirectory()) continue;
19155
19210
  const videoDir = join43(videoRoot, videoEntry.name);
@@ -19250,7 +19305,7 @@ function parsePlanVideosJson2(value) {
19250
19305
  }
19251
19306
  function materializeExtractedVideoDirectories(planDir) {
19252
19307
  const videosPath = join43(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
19253
- if (!existsSync29(videosPath)) return;
19308
+ if (!existsSync28(videosPath)) return;
19254
19309
  const videos = parsePlanVideosJson2(readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH));
19255
19310
  for (const video of videos.extracted) {
19256
19311
  mkdirSync18(resolveExtractedVideoOutputDir(planDir, video.videoId), { recursive: true });
@@ -19284,9 +19339,9 @@ function parseChunkSlices(value) {
19284
19339
  }
19285
19340
  function buildVideoChunkDependencies(executionPlanDir, dimensions) {
19286
19341
  const videoRoot = join43(executionPlanDir, "video-frames");
19287
- const hasExtractedFrames = existsSync29(videoRoot) && listFiles(videoRoot).length > 0;
19342
+ const hasExtractedFrames = existsSync28(videoRoot) && listFiles(videoRoot).length > 0;
19288
19343
  const videosPath = join43(executionPlanDir, PLAN_VIDEOS_META_RELATIVE_PATH);
19289
- if (!existsSync29(videosPath)) {
19344
+ if (!existsSync28(videosPath)) {
19290
19345
  return hasExtractedFrames ? { mode: "full-source-pack", dependencies: null } : { mode: "exact-rendered-frames", dependencies: /* @__PURE__ */ new Map() };
19291
19346
  }
19292
19347
  const chunksPath = join43(executionPlanDir, "meta", "chunks.json");
@@ -19343,7 +19398,7 @@ function computeManifestHash(manifest) {
19343
19398
  return sha256Hex(`${PLAN_V2_HASH_PREFIX}${canonicalJsonStringify(manifestPayload(manifest))}`);
19344
19399
  }
19345
19400
  function writeBlob(sourcePath, destinationPath) {
19346
- if (existsSync29(destinationPath)) return;
19401
+ if (existsSync28(destinationPath)) return;
19347
19402
  mkdirSync18(dirname17(destinationPath), { recursive: true });
19348
19403
  const temporaryDir = createStagingDir6(dirname17(destinationPath), ".plan-v2-blob-");
19349
19404
  const temporaryPath = join43(temporaryDir, "blob");
@@ -19383,7 +19438,7 @@ async function putTasks(tasks) {
19383
19438
  }
19384
19439
  function buildPlanV2Publication(executionPlanDir, digests) {
19385
19440
  const executionPlanPath = join43(executionPlanDir, "plan.json");
19386
- if (!existsSync29(executionPlanPath)) {
19441
+ if (!existsSync28(executionPlanPath)) {
19387
19442
  throw new PlanV2IntegrityError(`execution plan is missing plan.json: ${executionPlanPath}`);
19388
19443
  }
19389
19444
  const executionPlanValue = readJsonFile(executionPlanPath, "execution plan.json");
@@ -19463,7 +19518,7 @@ function buildPlanV2Publication(executionPlanDir, digests) {
19463
19518
  };
19464
19519
  }
19465
19520
  function createPlanV2FromExecutionPlan(executionPlanDir, planV2Dir) {
19466
- if (existsSync29(planV2Dir)) {
19521
+ if (existsSync28(planV2Dir)) {
19467
19522
  throw new PlanV2IntegrityError(`output directory already exists: ${planV2Dir}`);
19468
19523
  }
19469
19524
  const publication = buildPlanV2Publication(executionPlanDir);
@@ -19549,7 +19604,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
19549
19604
  }
19550
19605
  }
19551
19606
  async function planV2(projectDir, config, planV2Dir) {
19552
- if (existsSync29(planV2Dir)) {
19607
+ if (existsSync28(planV2Dir)) {
19553
19608
  throw new PlanV2IntegrityError(`output directory already exists: ${planV2Dir}`);
19554
19609
  }
19555
19610
  const publisher = new LocalPlanV2ArtifactPublisher(planV2Dir);
@@ -19703,7 +19758,7 @@ function parsePlanV2Manifest(value) {
19703
19758
  }
19704
19759
  function readPlanV2Manifest(planV2Dir) {
19705
19760
  const manifestPath = join43(planV2Dir, "plan.json");
19706
- if (!existsSync29(manifestPath)) {
19761
+ if (!existsSync28(manifestPath)) {
19707
19762
  throw new PlanV2IntegrityError(`missing v2 manifest: ${manifestPath}`);
19708
19763
  }
19709
19764
  const value = readJsonFile(manifestPath, "v2 manifest");
@@ -19722,7 +19777,7 @@ function listPlanV2ArtifactsForTarget(manifest, target) {
19722
19777
  }
19723
19778
  function verifyBlob(planV2Dir, artifact) {
19724
19779
  const sourcePath = planV2BlobPath(planV2Dir, artifact.sha256);
19725
- if (!existsSync29(sourcePath)) {
19780
+ if (!existsSync28(sourcePath)) {
19726
19781
  throw new PlanV2IntegrityError(`missing content-addressed artifact ${artifact.sha256}`);
19727
19782
  }
19728
19783
  const stats = statSync11(sourcePath);
@@ -19735,7 +19790,7 @@ function verifyBlob(planV2Dir, artifact) {
19735
19790
  return sourcePath;
19736
19791
  }
19737
19792
  function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}) {
19738
- if (existsSync29(destinationDir)) {
19793
+ if (existsSync28(destinationDir)) {
19739
19794
  throw new PlanV2IntegrityError(`materialization destination already exists: ${destinationDir}`);
19740
19795
  }
19741
19796
  const manifest = readPlanV2Manifest(planV2Dir);
@@ -19800,7 +19855,7 @@ function validatePlanV2MaterializedTarget(planDir, expectedTarget) {
19800
19855
  }
19801
19856
  function readValidatedPlanV2Materialization(planDir, expectedTarget) {
19802
19857
  const markerPath = join43(planDir, PLAN_V2_MATERIALIZATION_MARKER);
19803
- if (!existsSync29(markerPath)) return null;
19858
+ if (!existsSync28(markerPath)) return null;
19804
19859
  const marker = readJsonFile(markerPath, "materialization marker");
19805
19860
  if (!isRecord3(marker) || !isRecord3(marker.manifest) || !isRecord3(marker.target)) {
19806
19861
  throw new PlanV2IntegrityError("malformed materialization marker");
@@ -19818,7 +19873,7 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
19818
19873
  for (const artifact of required) {
19819
19874
  if (Object.hasOwn(remoteSources, artifact.path)) continue;
19820
19875
  const path = join43(planDir, ...artifact.path.split("/"));
19821
- if (!existsSync29(path) || statSync11(path).size !== artifact.sizeBytes) {
19876
+ if (!existsSync28(path) || statSync11(path).size !== artifact.sizeBytes) {
19822
19877
  throw new PlanV2IntegrityError(
19823
19878
  `materialized artifact missing or truncated: ${artifact.path}`
19824
19879
  );
@@ -19969,7 +20024,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
19969
20024
  const planJsonPath = join44(planDir, "plan.json");
19970
20025
  const encoderJsonPath = join44(planDir, "meta", "encoder.json");
19971
20026
  const chunksJsonPath = join44(planDir, "meta", "chunks.json");
19972
- if (!existsSync30(planJsonPath)) {
20027
+ if (!existsSync29(planJsonPath)) {
19973
20028
  throw new RenderChunkValidationError(
19974
20029
  MISSING_PLAN_ARTIFACT,
19975
20030
  `[renderChunk] planDir is missing required artifact: ${planJsonPath}`
@@ -19985,7 +20040,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
19985
20040
  const v2Manifest = v2Materialization?.manifest ?? null;
19986
20041
  const remoteSources = v2Materialization?.remoteSources ?? {};
19987
20042
  for (const required of [encoderJsonPath, chunksJsonPath]) {
19988
- if (!existsSync30(required)) {
20043
+ if (!existsSync29(required)) {
19989
20044
  throw new RenderChunkValidationError(
19990
20045
  MISSING_PLAN_ARTIFACT,
19991
20046
  `[renderChunk] planDir is missing required artifact: ${required}`
@@ -19996,7 +20051,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
19996
20051
  const chunks = JSON.parse(readFileSync14(chunksJsonPath, "utf-8"));
19997
20052
  const videosJsonPath = join44(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
19998
20053
  let planVideos = null;
19999
- if (existsSync30(videosJsonPath)) {
20054
+ if (existsSync29(videosJsonPath)) {
20000
20055
  try {
20001
20056
  planVideos = validatePlanVideosForChunk(JSON.parse(readFileSync14(videosJsonPath, "utf-8")));
20002
20057
  } catch (err) {
@@ -20027,7 +20082,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
20027
20082
  const range = resolveChunkFrameRange(slice, chunkIndex, options?.frameRange);
20028
20083
  const framesInChunk = range.endFrame - range.startFrame;
20029
20084
  const compiledDir = join44(planDir, "compiled");
20030
- if (!existsSync30(compiledDir)) {
20085
+ if (!existsSync29(compiledDir)) {
20031
20086
  throw new RenderChunkValidationError(
20032
20087
  MISSING_PLAN_ARTIFACT,
20033
20088
  `[renderChunk] planDir missing compiled/ directory: ${compiledDir}`
@@ -20119,6 +20174,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
20119
20174
  deferredVideos.filter((video) => remoteVideoIds.has(video.videoId))
20120
20175
  )
20121
20176
  });
20177
+ captureOptions.onStaticDedupActivity = () => noteStaticDedupActivity(job);
20122
20178
  const captureFrames = effectiveChunkFrames(framesInChunk, slice.captureCost);
20123
20179
  const chunkWorkerCount = resolveChunkCaptureWorkers(
20124
20180
  captureFrames,
@@ -20278,10 +20334,10 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
20278
20334
  const effectiveBitrate = encoder.crf != null ? void 0 : encoder.bitrate;
20279
20335
  const videoOnlyPath = encoder.chunksCarryAudio ? `${outputChunkPath}.video.mp4` : outputChunkPath;
20280
20336
  if (isPngSequence) {
20281
- if (!existsSync30(outputChunkPath)) mkdirSync19(outputChunkPath, { recursive: true });
20337
+ if (!existsSync29(outputChunkPath)) mkdirSync19(outputChunkPath, { recursive: true });
20282
20338
  } else {
20283
20339
  const outDir = join44(outputChunkPath, "..");
20284
- if (!existsSync30(outDir)) mkdirSync19(outDir, { recursive: true });
20340
+ if (!existsSync29(outDir)) mkdirSync19(outDir, { recursive: true });
20285
20341
  }
20286
20342
  const encodeInput = {
20287
20343
  job,
@@ -21211,7 +21267,7 @@ import {
21211
21267
 
21212
21268
  // src/server.ts
21213
21269
  import {
21214
- existsSync as existsSync33,
21270
+ existsSync as existsSync32,
21215
21271
  mkdirSync as mkdirSync21,
21216
21272
  statSync as statSync13,
21217
21273
  mkdtempSync as mkdtempSync2,
@@ -21234,7 +21290,7 @@ import {
21234
21290
 
21235
21291
  // src/services/hyperframeLint.ts
21236
21292
  import {
21237
- existsSync as existsSync31,
21293
+ existsSync as existsSync30,
21238
21294
  readFileSync as readFileSync16,
21239
21295
  statSync as statSync12,
21240
21296
  openSync as openSync7,
@@ -21288,7 +21344,7 @@ function readEntryHtml(filePath) {
21288
21344
  }
21289
21345
  function readProjectEntryFile(projectDir, preferredEntryFile) {
21290
21346
  const absProjectDir = resolve11(projectDir);
21291
- if (!existsSync31(absProjectDir) || !statSync12(absProjectDir).isDirectory()) {
21347
+ if (!existsSync30(absProjectDir) || !statSync12(absProjectDir).isDirectory()) {
21292
21348
  return { error: `Project directory not found: ${absProjectDir}` };
21293
21349
  }
21294
21350
  const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
@@ -21357,7 +21413,7 @@ async function runHyperframeLint(prepared) {
21357
21413
  import { Worker as Worker2 } from "node:worker_threads";
21358
21414
  import { fileURLToPath as fileURLToPath6 } from "node:url";
21359
21415
  import { dirname as dirname18, join as join47 } from "node:path";
21360
- import { existsSync as existsSync32 } from "node:fs";
21416
+ import { existsSync as existsSync31 } from "node:fs";
21361
21417
  var DEFAULT_HEALTH_PORT = 9848;
21362
21418
  async function startHealthWorker(options = {}) {
21363
21419
  const log = options.logger ?? defaultLogger2();
@@ -21434,7 +21490,7 @@ function resolveWorkerEntry2() {
21434
21490
  const here = dirname18(fileURLToPath6(import.meta.url));
21435
21491
  const candidates = [join47(here, "healthWorkerThread.js"), join47(here, "healthWorkerThread.ts")];
21436
21492
  for (const candidate of candidates) {
21437
- if (existsSync32(candidate)) return candidate;
21493
+ if (existsSync31(candidate)) return candidate;
21438
21494
  }
21439
21495
  return void 0;
21440
21496
  }
@@ -21590,7 +21646,7 @@ function resolvePreparedRenderOutput(prepared, rendersDir, log) {
21590
21646
  const { input, cleanupProjectDir } = prepared;
21591
21647
  const absoluteOutputPath = resolveOutputPath(input.projectDir, input.outputPath, rendersDir, log);
21592
21648
  const outputDir = dirname19(absoluteOutputPath);
21593
- if (!existsSync33(outputDir)) mkdirSync21(outputDir, { recursive: true });
21649
+ if (!existsSync32(outputDir)) mkdirSync21(outputDir, { recursive: true });
21594
21650
  return { input, cleanupProjectDir, absoluteOutputPath };
21595
21651
  }
21596
21652
  function prepareRenderJob(prepared, rendersDir, log) {
@@ -21647,11 +21703,11 @@ function prepareProjectDirectory(projectDir, options) {
21647
21703
  const candidate = nonEmptyString(projectDir);
21648
21704
  if (!candidate) return null;
21649
21705
  const absProjectDir = resolve12(candidate);
21650
- if (!existsSync33(absProjectDir) || !statSync13(absProjectDir).isDirectory()) {
21706
+ if (!existsSync32(absProjectDir) || !statSync13(absProjectDir).isDirectory()) {
21651
21707
  return { error: `Project directory not found: ${absProjectDir}` };
21652
21708
  }
21653
21709
  const entry = options.entryFile || "index.html";
21654
- if (!existsSync33(resolve12(absProjectDir, entry))) {
21710
+ if (!existsSync32(resolve12(absProjectDir, entry))) {
21655
21711
  return { error: `Entry file "${entry}" not found in project directory: ${absProjectDir}` };
21656
21712
  }
21657
21713
  return { prepared: { input: { projectDir: absProjectDir, ...options } } };
@@ -21743,7 +21799,7 @@ function cleanupTempDir(dir, log) {
21743
21799
  }
21744
21800
  }
21745
21801
  function outputFileSize(path) {
21746
- return existsSync33(path) ? statSync13(path).size : 0;
21802
+ return existsSync32(path) ? statSync13(path).size : 0;
21747
21803
  }
21748
21804
  function createBlockingProgressReporter(log, requestId) {
21749
21805
  let lastLoggedPct = -10;
@@ -22054,7 +22110,7 @@ function createRenderHandlers(options = {}) {
22054
22110
  if (!artifact) {
22055
22111
  return c.json({ success: false, error: "Output artifact not found or expired" }, 404);
22056
22112
  }
22057
- if (!existsSync33(artifact.path)) {
22113
+ if (!existsSync32(artifact.path)) {
22058
22114
  store.delete(token);
22059
22115
  return c.json({ success: false, error: "Output artifact file missing" }, 404);
22060
22116
  }
@@ -22177,7 +22233,7 @@ import {
22177
22233
  } from "@hyperframes/engine";
22178
22234
  import {
22179
22235
  cpSync as cpSync3,
22180
- existsSync as existsSync34,
22236
+ existsSync as existsSync33,
22181
22237
  mkdirSync as mkdirSync22,
22182
22238
  readFileSync as readFileSync17,
22183
22239
  readdirSync as readdirSync12,
@@ -22232,7 +22288,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
22232
22288
  }
22233
22289
  const format = plan2.dimensions.format;
22234
22290
  const cfrEncoder = cfr ? readCfrEncoder(planDir, format) : null;
22235
- if (!existsSync34(dirname20(outputPath))) {
22291
+ if (!existsSync33(dirname20(outputPath))) {
22236
22292
  mkdirSync22(dirname20(outputPath), { recursive: true });
22237
22293
  }
22238
22294
  const workDir = createStagingDir7(dirname20(outputPath), `${basename8(outputPath)}.assemble-work-`);
@@ -22256,7 +22312,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
22256
22312
  try {
22257
22313
  const videoSources = cfrEncoder ? [await reencodeCfr(ctx, chunkPaths, cfrEncoder)] : chunkPaths;
22258
22314
  const finalPath = join49(workDir, `output.${format}`);
22259
- const audio = audioPath !== null && existsSync34(audioPath) ? audioPath : null;
22315
+ const audio = audioPath !== null && existsSync33(audioPath) ? audioPath : null;
22260
22316
  await writeJoined(ctx, videoSources, audio, finalPath);
22261
22317
  renameWithRetry11(finalPath, outputPath);
22262
22318
  log.info("[assemble] stage timings", {
@@ -22274,7 +22330,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
22274
22330
  });
22275
22331
  }
22276
22332
  }
22277
- const fileSize = existsSync34(outputPath) ? statSync14(outputPath).size : 0;
22333
+ const fileSize = existsSync33(outputPath) ? statSync14(outputPath).size : 0;
22278
22334
  return {
22279
22335
  ...referenceBackgroundResult8(plan2[REFERENCE_BACKGROUND_FIELD6]),
22280
22336
  outputPath,
@@ -22286,13 +22342,13 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
22286
22342
  function readAssemblePlan(planDir, chunkPaths) {
22287
22343
  const planJsonPath = join49(planDir, "plan.json");
22288
22344
  const chunksJsonPath = join49(planDir, "meta", "chunks.json");
22289
- if (!existsSync34(planJsonPath)) {
22345
+ if (!existsSync33(planJsonPath)) {
22290
22346
  throw new Error(`[assemble] planDir missing plan.json: ${planJsonPath}`);
22291
22347
  }
22292
22348
  const plan2 = JSON.parse(readFileSync17(planJsonPath, "utf-8"));
22293
22349
  readPlanProtocolV1(plan2, DISTRIBUTED_RENDER_CAPABILITIES.roles.assembler);
22294
22350
  validatePlanV2MaterializedTarget(planDir, { role: "assembler" });
22295
- if (!existsSync34(chunksJsonPath)) {
22351
+ if (!existsSync33(chunksJsonPath)) {
22296
22352
  throw new Error(`[assemble] planDir missing meta/chunks.json: ${chunksJsonPath}`);
22297
22353
  }
22298
22354
  const chunks = JSON.parse(readFileSync17(chunksJsonPath, "utf-8"));
@@ -22307,7 +22363,7 @@ function readAssemblePlan(planDir, chunkPaths) {
22307
22363
  }
22308
22364
  }
22309
22365
  for (const path of chunkPaths.flat()) {
22310
- if (!existsSync34(path)) {
22366
+ if (!existsSync33(path)) {
22311
22367
  throw new Error(`[assemble] chunk path does not exist: ${path}`);
22312
22368
  }
22313
22369
  }
@@ -22446,7 +22502,7 @@ function planFormat(planDir) {
22446
22502
  }
22447
22503
  function lockedAudio(planDir) {
22448
22504
  const encoderJsonPath = join49(planDir, "meta", "encoder.json");
22449
- if (!existsSync34(encoderJsonPath)) return {};
22505
+ if (!existsSync33(encoderJsonPath)) return {};
22450
22506
  return JSON.parse(readFileSync17(encoderJsonPath, "utf-8"));
22451
22507
  }
22452
22508
  function readCfrEncoder(planDir, format) {
@@ -22456,7 +22512,7 @@ function readCfrEncoder(planDir, format) {
22456
22512
  );
22457
22513
  }
22458
22514
  const encoderJsonPath = join49(planDir, "meta", "encoder.json");
22459
- if (!existsSync34(encoderJsonPath)) {
22515
+ if (!existsSync33(encoderJsonPath)) {
22460
22516
  throw new Error(`[assemble] planDir missing meta/encoder.json: ${encoderJsonPath}`);
22461
22517
  }
22462
22518
  const encoderJson = JSON.parse(readFileSync17(encoderJsonPath, "utf-8"));
@@ -22468,7 +22524,7 @@ function readCfrEncoder(planDir, format) {
22468
22524
  return encoderJson;
22469
22525
  }
22470
22526
  function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, startTimeMs) {
22471
- if (existsSync34(outputPath)) rmSync20(outputPath, { recursive: true, force: true });
22527
+ if (existsSync33(outputPath)) rmSync20(outputPath, { recursive: true, force: true });
22472
22528
  mkdirSync22(outputPath, { recursive: true });
22473
22529
  let globalIdx = 0;
22474
22530
  for (const chunkDir of chunkPaths) {
@@ -22492,7 +22548,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
22492
22548
  `[assemble] png-sequence frame count mismatch: merged ${globalIdx} frames vs plan.totalFrames=${totalFrames}. Using on-disk count.`
22493
22549
  );
22494
22550
  }
22495
- if (audioPath !== null && existsSync34(audioPath)) {
22551
+ if (audioPath !== null && existsSync33(audioPath)) {
22496
22552
  const sidecar = join49(outputPath, MIXED_AUDIO_FILENAME4);
22497
22553
  cpSync3(audioPath, sidecar);
22498
22554
  }