@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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/server.ts
4
4
  import {
5
- existsSync as existsSync26,
5
+ existsSync as existsSync25,
6
6
  mkdirSync as mkdirSync13,
7
7
  statSync as statSync11,
8
8
  mkdtempSync,
@@ -26,7 +26,7 @@ import {
26
26
  // src/services/renderOrchestrator.ts
27
27
  import { audioFailureDiagnostics as audioFailureDiagnostics2 } from "@hyperframes/engine";
28
28
  import {
29
- existsSync as existsSync22,
29
+ existsSync as existsSync21,
30
30
  mkdirSync as mkdirSync12,
31
31
  readdirSync as readdirSync6,
32
32
  rmSync as rmSync12,
@@ -223,7 +223,9 @@ function createConsoleLogger(level = "info") {
223
223
  }
224
224
  };
225
225
  }
226
- var defaultLogger = createConsoleLogger("info");
226
+ var defaultLogger = createConsoleLogger(
227
+ process.env.HF_DEBUG_RENDER === "1" ? "debug" : "info"
228
+ );
227
229
 
228
230
  // src/services/fileServer.ts
229
231
  var readFileAsync = promisify(readFile);
@@ -1025,7 +1027,7 @@ function assertChromaSubsamplingSdr(config, hasHdrContent) {
1025
1027
  import {
1026
1028
  copyFileSync,
1027
1029
  cpSync,
1028
- existsSync as existsSync4,
1030
+ existsSync as existsSync3,
1029
1031
  mkdirSync,
1030
1032
  rmSync,
1031
1033
  symlinkSync,
@@ -1048,9 +1050,7 @@ import {
1048
1050
  relative as nodeRelative,
1049
1051
  isAbsolute as nodeIsAbsolute
1050
1052
  } from "node:path";
1051
- import { existsSync as existsSync3 } from "node:fs";
1052
1053
  import { fileURLToPath as fileURLToPath2 } from "node:url";
1053
- import { decodedUrlPath } from "@hyperframes/parsers/asset-paths";
1054
1054
  var DEFAULT_RENDERS_DIR = process.env.PRODUCER_RENDERS_DIR ?? // fileURLToPath (not URL.pathname): on Windows .pathname is "/D:/..." which
1055
1055
  // resolves to a bogus renders dir.
1056
1056
  nodeResolve(fileURLToPath2(import.meta.url), "../../..", "renders");
@@ -1088,13 +1088,6 @@ function resolveRenderPaths(projectDir, outputPath, rendersDir = DEFAULT_RENDERS
1088
1088
  const absoluteOutputPath = nodeResolve(resolvedOutputPath);
1089
1089
  return { absoluteProjectDir, absoluteOutputPath };
1090
1090
  }
1091
- function resolveCompositionSrc(projectDir, src) {
1092
- const rooted = (value) => nodeResolve(projectDir, value.replace(/^(?:\.?[\\/])+/, ""));
1093
- const decoded = rooted(decodedUrlPath(src));
1094
- if (!isPathInside2(decoded, projectDir)) return null;
1095
- const raw = rooted(src);
1096
- return !existsSync3(decoded) && isPathInside2(raw, projectDir) && existsSync3(raw) ? raw : decoded;
1097
- }
1098
1091
 
1099
1092
  // src/services/render/shared.ts
1100
1093
  var BROWSER_MEDIA_EPSILON = 1e-4;
@@ -1269,6 +1262,13 @@ var workerPhasesByJob = /* @__PURE__ */ new WeakMap();
1269
1262
  function forgetWorkerPhases(job) {
1270
1263
  workerPhasesByJob.delete(job);
1271
1264
  }
1265
+ var staticDedupActivityByJob = /* @__PURE__ */ new WeakMap();
1266
+ function noteStaticDedupActivity(job) {
1267
+ staticDedupActivityByJob.set(job, (staticDedupActivityByJob.get(job) ?? 0) + 1);
1268
+ }
1269
+ function staticDedupActivity(job) {
1270
+ return staticDedupActivityByJob.get(job) ?? 0;
1271
+ }
1272
1272
  function describeWorkerPhases(job) {
1273
1273
  const phases = workerPhasesByJob.get(job);
1274
1274
  if (!phases?.size) return void 0;
@@ -1302,7 +1302,7 @@ var materializePathModule = {
1302
1302
  isAbsolute
1303
1303
  };
1304
1304
  var materializeFileSystem = {
1305
- existsSync: existsSync4,
1305
+ existsSync: existsSync3,
1306
1306
  mkdirSync,
1307
1307
  symlinkSync,
1308
1308
  cpSync,
@@ -1604,7 +1604,7 @@ var RenderExecutionContext = class {
1604
1604
  };
1605
1605
 
1606
1606
  // src/services/render/artifactTransaction.ts
1607
- import { closeSync as closeSync2, existsSync as existsSync6, fstatSync as fstatSync2, openSync as openSync2, readSync, readdirSync as readdirSync2, rmSync as rmSync3 } from "node:fs";
1607
+ import { closeSync as closeSync2, existsSync as existsSync5, fstatSync as fstatSync2, openSync as openSync2, readSync, readdirSync as readdirSync2, rmSync as rmSync3 } from "node:fs";
1608
1608
  import { basename as basename4, dirname as dirname4, extname as extname2, join as join5, resolve as resolve4 } from "node:path";
1609
1609
  import { HLS_MASTER_PLAYLIST, HLS_VIDEO_PLAYLIST, renameWithRetry } from "@hyperframes/engine";
1610
1610
 
@@ -1617,7 +1617,7 @@ import {
1617
1617
 
1618
1618
  // src/services/render/renderDirOwner.ts
1619
1619
  import {
1620
- existsSync as existsSync5,
1620
+ existsSync as existsSync4,
1621
1621
  lstatSync,
1622
1622
  readFileSync as readFileSync2,
1623
1623
  readdirSync,
@@ -1692,7 +1692,7 @@ function newestWriteMs(path) {
1692
1692
  }
1693
1693
  function isAbandoned(dir, ownerlessIdleMs, now) {
1694
1694
  try {
1695
- if (!lstatSync(dir).isDirectory() || existsSync5(join4(dir, TRANSACTION_BACKUP))) return false;
1695
+ if (!lstatSync(dir).isDirectory() || existsSync4(join4(dir, TRANSACTION_BACKUP))) return false;
1696
1696
  const owner = ownerState(dir);
1697
1697
  if (owner === "gone") return true;
1698
1698
  return owner === "none" && ownerlessIdleMs !== void 0 && now - newestWriteMs(dir) >= ownerlessIdleMs;
@@ -1724,7 +1724,7 @@ function createRenderWorkDir(prefix, outputDir) {
1724
1724
 
1725
1725
  // src/services/render/artifactTransaction.ts
1726
1726
  var defaultFileSystem = {
1727
- existsSync: existsSync6,
1727
+ existsSync: existsSync5,
1728
1728
  renameSync: (source, destination) => renameWithRetry(source, destination),
1729
1729
  rmSync: rmSync3
1730
1730
  };
@@ -1878,7 +1878,7 @@ var ArtifactTransaction = class {
1878
1878
  async assertDirectoryExpectation(expected, files) {
1879
1879
  for (const required of expected.requiredFiles ?? []) {
1880
1880
  const path = join5(this.stagingPath, required);
1881
- if (!existsSync6(path)) {
1881
+ if (!existsSync5(path)) {
1882
1882
  throw new Error(`Render artifact directory is missing ${required}: ${this.stagingPath}`);
1883
1883
  }
1884
1884
  assertReadableNonEmptyFile(path);
@@ -2127,7 +2127,7 @@ function replanAfterFailure(plan, failure) {
2127
2127
  }
2128
2128
 
2129
2129
  // src/services/render/stages/captureSegmentedStage.ts
2130
- import { existsSync as existsSync7, mkdirSync as mkdirSync3, rmSync as rmSync6, statSync as statSync3 } from "node:fs";
2130
+ import { existsSync as existsSync6, mkdirSync as mkdirSync3, rmSync as rmSync6, statSync as statSync3 } from "node:fs";
2131
2131
  import { join as join9 } from "node:path";
2132
2132
  import {
2133
2133
  captureFrameToBuffer as captureFrameToBuffer2,
@@ -4473,7 +4473,7 @@ async function runCaptureStreamingStage(input) {
4473
4473
  const session = probeSession ?? await openSession();
4474
4474
  captureBeyondViewport = session.options.captureBeyondViewport;
4475
4475
  if (probeSession) {
4476
- prepareCaptureSessionForReuse(session, framesDir, videoInjector);
4476
+ await prepareCaptureSessionForReuse(session, framesDir, videoInjector);
4477
4477
  probeSession = null;
4478
4478
  }
4479
4479
  let riskSession = null;
@@ -4731,7 +4731,7 @@ async function captureSegmentToEncoder(ctx, segment) {
4731
4731
  path: segmentPath,
4732
4732
  // Recorded so resume can prove the file on disk is the one that
4733
4733
  // finished; absent only in unit tests, whose fake encoder writes none.
4734
- bytes: existsSync7(segmentPath) ? statSync3(segmentPath).size : 0
4734
+ bytes: existsSync6(segmentPath) ? statSync3(segmentPath).size : 0
4735
4735
  });
4736
4736
  return encodeResult;
4737
4737
  } finally {
@@ -4778,8 +4778,13 @@ function defaultSessionFactory(input) {
4778
4778
  };
4779
4779
  const session = probeSession ?? await openSession();
4780
4780
  if (probeSession) {
4781
- openSegmentedSessionReuse(input, probeSession, injector);
4781
+ const reused = probeSession;
4782
4782
  probeSession = null;
4783
+ await openSegmentedSessionReuse(input, reused, injector).catch(async (error) => {
4784
+ await closeCaptureSession2(reused).catch(() => {
4785
+ });
4786
+ throw error;
4787
+ });
4783
4788
  }
4784
4789
  try {
4785
4790
  if (!session.isInitialized) await withinInitBudget(initializeSession2(session), session);
@@ -4793,8 +4798,8 @@ function defaultSessionFactory(input) {
4793
4798
  }
4794
4799
  };
4795
4800
  }
4796
- function openSegmentedSessionReuse(input, session, injector) {
4797
- prepareCaptureSessionForReuse2(session, input.framesDir, injector());
4801
+ async function openSegmentedSessionReuse(input, session, injector) {
4802
+ await prepareCaptureSessionForReuse2(session, input.framesDir, injector());
4798
4803
  }
4799
4804
  async function openSegmentedSession(input, injector) {
4800
4805
  const captureCfg = input.cfg.forceScreenshot === input.plan.forceScreenshot ? input.cfg : { ...input.cfg, forceScreenshot: input.plan.forceScreenshot };
@@ -5732,7 +5737,7 @@ function trackSegmentFramePeak(frames, rootDir, onPeak) {
5732
5737
 
5733
5738
  // src/services/render/segmentManifest.ts
5734
5739
  import { createHash as createHash2 } from "node:crypto";
5735
- import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync4, statSync as statSync5, writeFileSync as writeFileSync3 } from "node:fs";
5740
+ import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync4, statSync as statSync5, writeFileSync as writeFileSync3 } from "node:fs";
5736
5741
  import { join as join14 } from "node:path";
5737
5742
  import { renameWithRetry as renameWithRetry2 } from "@hyperframes/engine";
5738
5743
  var MANIFEST_FILENAME = "segments.json";
@@ -5780,7 +5785,7 @@ function isManifest(value) {
5780
5785
  }
5781
5786
  function readSegmentManifest(segmentDir) {
5782
5787
  const path = join14(segmentDir, MANIFEST_FILENAME);
5783
- if (!existsSync8(path)) return null;
5788
+ if (!existsSync7(path)) return null;
5784
5789
  try {
5785
5790
  const parsed = JSON.parse(readFileSync4(path, "utf-8"));
5786
5791
  return isManifest(parsed) ? parsed : null;
@@ -5809,7 +5814,7 @@ async function validateCompletedSegments(manifest, expectedHash, probeFrames) {
5809
5814
  const ok = /* @__PURE__ */ new Set();
5810
5815
  if (manifest.planHash !== expectedHash) return ok;
5811
5816
  for (const entry of manifest.completed) {
5812
- if (!existsSync8(entry.path)) continue;
5817
+ if (!existsSync7(entry.path)) continue;
5813
5818
  const size = statSync5(entry.path).size;
5814
5819
  if (size <= 0 || size !== entry.bytes) continue;
5815
5820
  const frames = await probeFrames(entry.path);
@@ -6177,26 +6182,26 @@ var STALL_POLL_MS = 5e3;
6177
6182
  function watchStall(phase, rule) {
6178
6183
  const detail = rule.detail ?? (() => void 0);
6179
6184
  let last = rule.progress();
6185
+ let lastActivity = rule.activity?.();
6180
6186
  let budgetMs = rule.firstProgressMs;
6181
6187
  const silence = createStallClock();
6182
6188
  const pollMs = Math.min(STALL_POLL_MS, rule.noProgressMs, rule.firstProgressMs);
6183
6189
  let attempt;
6184
6190
  let timer;
6185
6191
  let inTail = false;
6192
+ const activityMoved = () => {
6193
+ const activity = rule.activity?.();
6194
+ if (activity === lastActivity) return false;
6195
+ lastActivity = activity;
6196
+ return true;
6197
+ };
6186
6198
  const restartWindow = (ms) => {
6187
6199
  last = rule.progress();
6188
6200
  budgetMs = ms;
6189
6201
  silence.reset();
6190
6202
  };
6191
6203
  const tripped = new Promise((_, reject) => {
6192
- timer = setInterval(() => {
6193
- const current = rule.progress();
6194
- if (rule.complete?.() && !inTail) {
6195
- inTail = true;
6196
- return restartWindow(rule.tailMs ?? rule.noProgressMs);
6197
- }
6198
- if (current !== last) return restartWindow(rule.noProgressMs);
6199
- if (silence.idle(pollMs) < budgetMs) return;
6204
+ const trip = (current) => {
6200
6205
  const error = new RenderStageStalledError(phase, budgetMs, current, detail());
6201
6206
  if (attempt && !attempt.signal.aborted) {
6202
6207
  attempt.abort(error);
@@ -6204,6 +6209,16 @@ function watchStall(phase, rule) {
6204
6209
  }
6205
6210
  clearInterval(timer);
6206
6211
  reject(error);
6212
+ };
6213
+ timer = setInterval(() => {
6214
+ const current = rule.progress();
6215
+ if (rule.complete?.() && !inTail) {
6216
+ inTail = true;
6217
+ return restartWindow(rule.tailMs ?? rule.noProgressMs);
6218
+ }
6219
+ if (current !== last) return restartWindow(rule.noProgressMs);
6220
+ if (activityMoved()) return silence.reset();
6221
+ if (silence.idle(pollMs) >= budgetMs) trip(current);
6207
6222
  }, pollMs);
6208
6223
  });
6209
6224
  const openAttempt = (parent) => {
@@ -6388,21 +6403,21 @@ function countAuthoredTimedClips(html) {
6388
6403
  }
6389
6404
 
6390
6405
  // src/services/render/stages/compileStage.ts
6391
- import { existsSync as existsSync13, writeFileSync as writeFileSync5 } from "node:fs";
6406
+ import { existsSync as existsSync12, writeFileSync as writeFileSync5 } from "node:fs";
6392
6407
  import { join as join19 } from "node:path";
6393
6408
  import { suggestMatchingPreset } from "@hyperframes/core";
6394
6409
  import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
6395
6410
  import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolution";
6396
6411
 
6397
6412
  // src/services/htmlCompiler.ts
6398
- import { decodedUrlPath as decodedUrlPath2 } from "@hyperframes/parsers/asset-paths";
6413
+ import { decodedUrlPath } from "@hyperframes/parsers/asset-paths";
6399
6414
  import { createHash as createHash6 } from "node:crypto";
6400
- import { createReadStream as createReadStream2, existsSync as existsSync12, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
6415
+ import { createReadStream as createReadStream2, existsSync as existsSync11, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
6401
6416
  import { join as join18, dirname as dirname8, resolve as resolve7, basename as basename5, relative as relative2, sep as sep2 } from "path";
6402
6417
  import { parseHTML as parseHTML5 } from "linkedom";
6403
6418
 
6404
6419
  // src/services/bundledScripts.ts
6405
- import { existsSync as existsSync9, readFileSync as readFileSync5 } from "node:fs";
6420
+ import { existsSync as existsSync8, readFileSync as readFileSync5 } from "node:fs";
6406
6421
  import { join as join15 } from "node:path";
6407
6422
  import { gsapCdnDist } from "@hyperframes/core/gsap-cdn";
6408
6423
  var GSAP_VENDOR_DIR_ENV = "HYPERFRAMES_GSAP_VENDOR_DIR";
@@ -6410,7 +6425,7 @@ function bundledScript(url) {
6410
6425
  const dir = process.env[GSAP_VENDOR_DIR_ENV];
6411
6426
  if (!dir || url !== `${gsapCdnDist()}gsap.min.js`) return null;
6412
6427
  const file = join15(dir, "gsap.min.js");
6413
- return existsSync9(file) ? readFileSync5(file) : null;
6428
+ return existsSync8(file) ? readFileSync5(file) : null;
6414
6429
  }
6415
6430
 
6416
6431
  // src/services/htmlCompiler.ts
@@ -6450,6 +6465,7 @@ import {
6450
6465
  emitRootCompositionVariableStyles,
6451
6466
  readDeclaredDefaults,
6452
6467
  parseHostVariableValues,
6468
+ boundMediaSrc,
6453
6469
  headStyleRuns,
6454
6470
  isAlwaysAppliedStyle,
6455
6471
  dedupeFontFaceRules,
@@ -6464,8 +6480,10 @@ import {
6464
6480
  } from "@hyperframes/parsers/sub-composition-validity";
6465
6481
  import {
6466
6482
  isUnresolvedAssetPlaceholder,
6483
+ namesAnotherNetworkRoot as namesAnotherNetworkRoot2,
6467
6484
  readProjectFile,
6468
- readTextFile
6485
+ readTextFile,
6486
+ resolveCompositionSrc
6469
6487
  } from "@hyperframes/parsers/asset-resolution";
6470
6488
 
6471
6489
  // src/services/renderMediaCollector.ts
@@ -6658,11 +6676,12 @@ import {
6658
6676
 
6659
6677
  // src/services/animatedGifPrep.ts
6660
6678
  import { createHash as createHash4 } from "node:crypto";
6661
- import { copyFileSync as copyFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync6 } from "node:fs";
6679
+ import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync6 } from "node:fs";
6662
6680
  import { dirname as dirname6, isAbsolute as isAbsolute2, join as join16, resolve as resolve5 } from "node:path";
6663
6681
  import { parseHTML as parseHTML3 } from "linkedom";
6664
6682
  import { parseAnimatedGifMetadata } from "@hyperframes/core";
6665
6683
  import { DEFAULT_VP9_CPU_USED, runFfmpeg as runFfmpeg2, renameWithRetry as renameWithRetry3 } from "@hyperframes/engine";
6684
+ import { namesAnotherNetworkRoot } from "@hyperframes/parsers/asset-resolution";
6666
6685
  var PREPARED_GIF_SUBDIR = "_animated_gif";
6667
6686
  var CACHE_SCHEMA = "hfgif-v1";
6668
6687
  function splitUrlSuffix(src) {
@@ -6697,14 +6716,15 @@ function resolveLocalImageSourcePath(src, options) {
6697
6716
  const { basePath } = splitUrlSuffix(trimmed);
6698
6717
  const normalizedBase = normalizeRelPath(basePath);
6699
6718
  const mapped = options.sourceAssets?.get(trimmed) ?? options.sourceAssets?.get(basePath) ?? options.sourceAssets?.get(normalizedBase);
6700
- if (mapped && existsSync10(mapped)) return mapped;
6719
+ if (mapped && existsSync9(mapped)) return mapped;
6701
6720
  if (isHttpUrl(trimmed)) return null;
6721
+ const protocolRelativeUrlOnShare = basePath.startsWith("/") && namesAnotherNetworkRoot(options.projectDir, basePath);
6702
6722
  const projectRelative = basePath.startsWith("/") ? basePath.slice(1) : basePath;
6703
6723
  const candidates = [
6704
- isAbsolute2(basePath) ? basePath : resolve5(options.projectDir, projectRelative),
6724
+ ...protocolRelativeUrlOnShare ? [] : [isAbsolute2(basePath) ? basePath : resolve5(options.projectDir, projectRelative)],
6705
6725
  resolve5(options.downloadDir, normalizedBase)
6706
6726
  ];
6707
- return candidates.find((candidate) => existsSync10(candidate)) ?? null;
6727
+ return candidates.find((candidate) => existsSync9(candidate)) ?? null;
6708
6728
  }
6709
6729
  function isUsableFile(path) {
6710
6730
  try {
@@ -6815,10 +6835,10 @@ async function runAnimatedGifTranscode(request) {
6815
6835
  throw result.error ?? new Error(`Animated GIF transcode failed (${result.exitCode}): ${result.stderr.slice(-500)}`);
6816
6836
  }
6817
6837
  async function ensurePreparedWebm(input) {
6818
- if (!existsSync10(dirname6(input.cachePath))) {
6838
+ if (!existsSync9(dirname6(input.cachePath))) {
6819
6839
  mkdirSync7(dirname6(input.cachePath), { recursive: true });
6820
6840
  }
6821
- if (!existsSync10(dirname6(input.outputPath))) {
6841
+ if (!existsSync9(dirname6(input.outputPath))) {
6822
6842
  mkdirSync7(dirname6(input.outputPath), { recursive: true });
6823
6843
  }
6824
6844
  if (!isUsableFile(input.cachePath)) {
@@ -7293,7 +7313,7 @@ import { createStudioPositionSeekReapplyScript } from "@hyperframes/studio-serve
7293
7313
  import { getPositionEditsRenderScript } from "@hyperframes/core/runtime/position-edits-render";
7294
7314
 
7295
7315
  // src/services/assetMediaType.ts
7296
- import { existsSync as existsSync11 } from "node:fs";
7316
+ import { existsSync as existsSync10 } from "node:fs";
7297
7317
  import {
7298
7318
  fingerprintElementId,
7299
7319
  isNotMediaPayload,
@@ -7366,7 +7386,7 @@ async function preflightCompositionAssetMediaTypes(input) {
7366
7386
  input.projectDir,
7367
7387
  input.compiledDir
7368
7388
  );
7369
- if (!existsSync11(resolvedPath)) continue;
7389
+ if (!existsSync10(resolvedPath)) continue;
7370
7390
  byPath.set(resolvedPath, [...byPath.get(resolvedPath) ?? [], reference]);
7371
7391
  }
7372
7392
  const mismatches = [];
@@ -7406,7 +7426,7 @@ async function preflightCompositionAssetMediaTypes(input) {
7406
7426
 
7407
7427
  // src/services/htmlCompiler.ts
7408
7428
  function logRemoteDownloadTelemetry(event) {
7409
- defaultLogger.info("[Compiler] Remote asset download integrity", { ...event });
7429
+ defaultLogger.debug("[Compiler] Remote asset download integrity", { ...event });
7410
7430
  }
7411
7431
  var INFERRED_MEDIA_DURATION_ATTR = "data-hf-inferred-duration";
7412
7432
  function parseSubCompHtmlForValidity(html) {
@@ -7620,7 +7640,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, down
7620
7640
  let filePath = src;
7621
7641
  if (isHttpUrl(src)) {
7622
7642
  const remoteDir = join18(downloadDir, REMOTE_MEDIA_SUBDIR);
7623
- if (!existsSync12(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
7643
+ if (!existsSync11(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
7624
7644
  try {
7625
7645
  filePath = await downloadToTemp(src, remoteDir, void 0, void 0, void 0, {
7626
7646
  onTelemetry: logRemoteDownloadTelemetry
@@ -7629,11 +7649,14 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, down
7629
7649
  return { duration: null, resolvedPath: src };
7630
7650
  }
7631
7651
  } else {
7632
- filePath = decodedUrlPath2(src);
7652
+ filePath = decodedUrlPath(src);
7633
7653
  if (!filePath.startsWith("/")) filePath = join18(baseDir, filePath);
7634
7654
  filePath = urlByAbsentLocalPath?.get(filePath) ?? filePath;
7655
+ if (!isHttpUrl(filePath) && namesAnotherNetworkRoot2(baseDir, filePath)) {
7656
+ return { duration: null, resolvedPath: filePath };
7657
+ }
7635
7658
  }
7636
- if (!isHttpUrl(filePath) && !existsSync12(filePath)) {
7659
+ if (!isHttpUrl(filePath) && !existsSync11(filePath)) {
7637
7660
  return { duration: null, resolvedPath: filePath };
7638
7661
  }
7639
7662
  const withSrcContext = (error) => {
@@ -7982,7 +8005,7 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
7982
8005
  parseHtml: (htmlStr) => parseHTML5(htmlStr).document,
7983
8006
  // Mirrors the preview bundler: a sub-composition's SIBLING assets resolve
7984
8007
  // against its own directory, project-root refs stay as authored.
7985
- assetExists: (path) => existsSync12(resolve7(projectDir, path)),
8008
+ assetExists: (path) => existsSync11(resolve7(projectDir, path)),
7986
8009
  // Preserve the authored root wrapper as a child of the host, matching
7987
8010
  // the preview bundler's shape (htmlBundler.ts's prepareFlattenedInnerRoot,
7988
8011
  // which the runtime compositionLoader mirrors with its own copy for the
@@ -8158,7 +8181,7 @@ ${safeText}
8158
8181
  //# sourceURL=${new URL(src).href}
8159
8182
  `;
8160
8183
  el.replaceWith(inlineScript);
8161
- defaultLogger.info(`[Compiler] Inlined CDN script: ${src}`);
8184
+ defaultLogger.debug(`[Compiler] Inlined CDN script: ${src}`);
8162
8185
  } else {
8163
8186
  if (download.reason instanceof ScriptIntegrityError) throw download.reason;
8164
8187
  defaultLogger.warn(
@@ -8178,7 +8201,7 @@ function collectExternalAssets(html, projectDir) {
8178
8201
  if (isPathInside2(absPath, absProjectDir)) {
8179
8202
  return null;
8180
8203
  }
8181
- if (!existsSync12(absPath)) return null;
8204
+ if (!existsSync11(absPath)) return null;
8182
8205
  const safeKey = toExternalAssetKey(absPath);
8183
8206
  externalAssets.set(safeKey, absPath);
8184
8207
  return safeKey;
@@ -8213,7 +8236,7 @@ function collectExternalAssets(html, projectDir) {
8213
8236
  if (rewritten !== style) el.setAttribute("style", rewritten);
8214
8237
  }
8215
8238
  if (externalAssets.size > 0) {
8216
- defaultLogger.info(
8239
+ defaultLogger.debug(
8217
8240
  `[Compiler] Found ${externalAssets.size} asset(s) outside project directory, will copy to render output`
8218
8241
  );
8219
8242
  }
@@ -8228,7 +8251,7 @@ var REMOTE_SOURCE_TAG_RE = /<source\b[^>]*?\bsrc\s*=\s*["'](https?:\/\/[^"']+)["
8228
8251
  var REMOTE_IMG_TAG_RE = /<img\b[^>]*?(?<![\w-])src\s*=\s*["'](https?:\/\/[^"']+)["'][^>]*>/gi;
8229
8252
  async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLabel, extraRewrite) {
8230
8253
  if (urlSet.size === 0) return { html, remoteMediaAssets: /* @__PURE__ */ new Map() };
8231
- if (!existsSync12(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
8254
+ if (!existsSync11(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
8232
8255
  const urlToLocal = /* @__PURE__ */ new Map();
8233
8256
  await Promise.all(
8234
8257
  [...urlSet].map(async (url) => {
@@ -8260,7 +8283,7 @@ async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLab
8260
8283
  result = result.replaceAll(`"${url}"`, `"${relPath}"`).replaceAll(`'${url}'`, `'${relPath}'`);
8261
8284
  if (extraRewrite) result = extraRewrite(result, url, relPath);
8262
8285
  }
8263
- defaultLogger.info(`[Compiler] ${logLabel} ${urlToLocal.size} to ${REMOTE_MEDIA_SUBDIR}/`);
8286
+ defaultLogger.debug(`[Compiler] ${logLabel} ${urlToLocal.size} to ${REMOTE_MEDIA_SUBDIR}/`);
8264
8287
  return { html: result, remoteMediaAssets };
8265
8288
  }
8266
8289
  async function localizeRemoteMediaSources(html, downloadDir) {
@@ -8397,7 +8420,7 @@ async function inlineExternalFontStylesheets(html) {
8397
8420
  ${fontFaceBlocks.join("\n")}
8398
8421
  </style>`;
8399
8422
  result = result.replace(fullMatch, inlineStyle);
8400
- defaultLogger.info("[Compiler] Inlined external @font-face rule(s)", {
8423
+ defaultLogger.debug("[Compiler] Inlined external @font-face rule(s)", {
8401
8424
  count: fontFaceBlocks.length,
8402
8425
  urlFingerprint: identity.urlFingerprint,
8403
8426
  host: identity.host
@@ -8410,14 +8433,14 @@ function projectStylesheetFontFamilies(html, projectDir) {
8410
8433
  for (const [tag] of html.matchAll(/<link\b[^>]*\brel=["']stylesheet["'][^>]*>/gi)) {
8411
8434
  const href = /\bhref=["']([^"']+)["']/i.exec(tag)?.[1];
8412
8435
  if (!href || /^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(href)) continue;
8413
- const sheet = resolve7(projectDir, decodedUrlPath2(href).replace(/^(?:\.?\/)+/, ""));
8414
- if (!isPathInside2(sheet, projectDir) || !existsSync12(sheet)) continue;
8436
+ const sheet = resolve7(projectDir, decodedUrlPath(href).replace(/^(?:\.?\/)+/, ""));
8437
+ if (!isPathInside2(sheet, projectDir) || !existsSync11(sheet)) continue;
8415
8438
  for (const face of extractFontFaceBlocks(readFileSync8(sheet, "utf8"))) {
8416
8439
  const family = /font-family\s*:\s*([^;}]+)/i.exec(face)?.[1]?.trim().replace(/^['"]|['"]$/g, "");
8417
8440
  const shipsFile = [...face.matchAll(LOCAL_FONTFACE_URL_RE)].some(([, url = ""]) => {
8418
- const path = decodedUrlPath2(url);
8441
+ const path = decodedUrlPath(url);
8419
8442
  const file = path.startsWith("/") ? resolve7(projectDir, `.${path}`) : resolve7(dirname8(sheet), path);
8420
- return isPathInside2(file, projectDir) && existsSync12(file);
8443
+ return isPathInside2(file, projectDir) && existsSync11(file);
8421
8444
  });
8422
8445
  if (family && shipsFile) families.push(family);
8423
8446
  }
@@ -8516,7 +8539,7 @@ async function embedLocalFontFaces(html, projectDir) {
8516
8539
  const font = await readLocalFont(absPath);
8517
8540
  if (font.kind === "file-backed") {
8518
8541
  fileBackedAbsolutePaths.add(absPath);
8519
- defaultLogger.info(
8542
+ defaultLogger.debug(
8520
8543
  `[Compiler] Kept large local font file-backed: ${localPath} (> ${(MAX_LOCAL_FONT_DATA_URI_BYTES / 1024 / 1024).toFixed(1)} MB)`
8521
8544
  );
8522
8545
  embeddedPaths.add(localPath);
@@ -8524,7 +8547,7 @@ async function embedLocalFontFaces(html, projectDir) {
8524
8547
  }
8525
8548
  dataUri = await toDataUri(font.buffer, ext, { compressToWoff2: false });
8526
8549
  dataUriByAbsolutePath.set(absPath, dataUri);
8527
- defaultLogger.info(
8550
+ defaultLogger.debug(
8528
8551
  `[Compiler] Embedded local font file: ${localPath} (${(font.buffer.length / 1024).toFixed(0)} KB \u2192 data URI)`
8529
8552
  );
8530
8553
  }
@@ -8552,14 +8575,17 @@ function renderGsapDist() {
8552
8575
  }
8553
8576
  function rewriteUnresolvableGsapToCdn(html, projectDir, compSrcPath) {
8554
8577
  let gsapDist;
8555
- const exists = (path) => existsSync12(resolve7(projectDir, path));
8578
+ const exists = (path) => {
8579
+ const file = resolve7(projectDir, path);
8580
+ return !namesAnotherNetworkRoot2(projectDir, file) && existsSync11(file);
8581
+ };
8556
8582
  return html.replace(
8557
8583
  /(<script\b[^>]*\bsrc=["'])([^"']*gsap[^"']*\/dist\/([^"']+))(["'][^>]*>)/gi,
8558
8584
  (full, prefix, src, file, suffix) => {
8559
8585
  if (/^https?:\/\//i.test(src)) return full;
8560
8586
  if (exists(compSrcPath ? rewriteAssetPath(compSrcPath, src, exists) : src)) return full;
8561
8587
  gsapDist ??= renderGsapDist();
8562
- defaultLogger.info(`[Compiler] Rewriting missing gsap script: ${src} \u2192 ${gsapDist}${file}`);
8588
+ defaultLogger.debug(`[Compiler] Rewriting missing gsap script: ${src} \u2192 ${gsapDist}${file}`);
8563
8589
  return `${prefix}${gsapDist}${file}${suffix}`;
8564
8590
  }
8565
8591
  );
@@ -8569,7 +8595,7 @@ function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath) {
8569
8595
  const entryPath = relative2(projectDir, htmlPath).replace(/\\/g, "/");
8570
8596
  if (!entryPath.includes("/")) return html;
8571
8597
  const { document: document2 } = parseHTML5(html);
8572
- const assetExists = (path) => existsSync12(resolve7(projectDir, path));
8598
+ const assetExists = (path) => existsSync11(resolve7(projectDir, path));
8573
8599
  rewriteAssetPaths(
8574
8600
  document2.querySelectorAll("[src], [href], [srcset]"),
8575
8601
  entryPath,
@@ -8589,11 +8615,29 @@ function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath) {
8589
8615
  }
8590
8616
  return document2.toString();
8591
8617
  }
8618
+ function bindVariableMediaSources(html, variables) {
8619
+ if (!html.includes("data-var-src")) return html;
8620
+ const { document: document2 } = parseHTML5(html);
8621
+ const declared = {};
8622
+ for (const el of document2.querySelectorAll("[data-composition-variables]")) {
8623
+ Object.assign(declared, readDeclaredDefaults(el));
8624
+ }
8625
+ const values = { ...declared, ...variables };
8626
+ let changed = false;
8627
+ for (const el of document2.querySelectorAll("video[data-var-src], audio[data-var-src]")) {
8628
+ if (el.closest("[data-variable-values]")) continue;
8629
+ const src = boundMediaSrc(el, values);
8630
+ if (src === null || el.getAttribute("src") === src) continue;
8631
+ el.setAttribute("src", src);
8632
+ changed = true;
8633
+ }
8634
+ return changed ? document2.toString() : html;
8635
+ }
8592
8636
  async function compileForRender(projectDir, htmlPath, downloadDir, options = {}) {
8593
8637
  const entryHtml = rebaseDirectEntryAssetPaths(readTextFile(htmlPath), projectDir, htmlPath);
8594
- const rawHtml = normalizeCompositionSrcs(
8595
- rewriteUnresolvableGsapToCdn(entryHtml, projectDir),
8596
- projectDir
8638
+ const rawHtml = bindVariableMediaSources(
8639
+ normalizeCompositionSrcs(rewriteUnresolvableGsapToCdn(entryHtml, projectDir), projectDir),
8640
+ options.variables ?? {}
8597
8641
  );
8598
8642
  assertSubCompositionsUsable(rawHtml, projectDir);
8599
8643
  const probes = /* @__PURE__ */ new Map();
@@ -8677,7 +8721,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
8677
8721
  timeoutMs: options.ffmpegProcessTimeout
8678
8722
  });
8679
8723
  if (preparedHeifImages.length > 0) {
8680
- defaultLogger.info(`[Compiler] Converted ${preparedHeifImages.length} HEIC image(s) to JPEG`);
8724
+ defaultLogger.debug(`[Compiler] Converted ${preparedHeifImages.length} HEIC image(s) to JPEG`);
8681
8725
  }
8682
8726
  const gifSourceAssets = new Map(remoteImageAssets);
8683
8727
  const {
@@ -8692,7 +8736,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
8692
8736
  timeoutMs: options.ffmpegProcessTimeout
8693
8737
  });
8694
8738
  if (preparedGifs.length > 0) {
8695
- defaultLogger.info(`[Compiler] Prepared ${preparedGifs.length} animated GIF input(s) as WebM`);
8739
+ defaultLogger.debug(`[Compiler] Prepared ${preparedGifs.length} animated GIF input(s) as WebM`);
8696
8740
  }
8697
8741
  const embeddedHtml = await embedLocalFontFaces(htmlWithPreparedGifs, projectDir);
8698
8742
  const { html, externalAssets } = collectExternalAssets(embeddedHtml, projectDir);
@@ -8720,7 +8764,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
8720
8764
  for (const video of videos) {
8721
8765
  if (isHttpUrl(video.src)) continue;
8722
8766
  const videoPath = resolve7(projectDir, video.src);
8723
- if (advised.has(videoPath)) continue;
8767
+ if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath)) continue;
8724
8768
  advised.add(videoPath);
8725
8769
  const reencode = `ffmpeg -i "${video.src}" -c:v libx264 -r 30 -g 30 -keyint_min 30 -movflags +faststart -c:a copy output.mp4`;
8726
8770
  (async () => {
@@ -9139,7 +9183,7 @@ function resolveEntryHtmlPath(input) {
9139
9183
  const rawEntry = readTextFile2(htmlPath);
9140
9184
  if (entryFile === "index.html" || !isTemplateEntry(rawEntry)) return htmlPath;
9141
9185
  const projectIndexPath = join19(projectDir, "index.html");
9142
- if (!existsSync13(projectIndexPath)) {
9186
+ if (!existsSync12(projectIndexPath)) {
9143
9187
  throw new Error(
9144
9188
  `Template entry file "${entryFile}" requires a project index.html to extract its render shell.`
9145
9189
  );
@@ -9472,7 +9516,8 @@ async function runProbeStage(input) {
9472
9516
  height,
9473
9517
  needsAlpha,
9474
9518
  deviceScaleFactor,
9475
- subTimelineWaitMemo
9519
+ subTimelineWaitMemo,
9520
+ staticDedupMemo
9476
9521
  } = input;
9477
9522
  let { compiled } = input;
9478
9523
  const probeCfg = cfg.forceScreenshot === forceScreenshot ? cfg : { ...cfg, forceScreenshot };
@@ -9533,7 +9578,11 @@ async function runProbeStage(input) {
9533
9578
  motionBlur,
9534
9579
  pageMotionBlur: job.config.pageMotionBlur,
9535
9580
  requiresWebGpu: compositionRequiresWebGpu(compiled.html),
9536
- subTimelineWaitMemo
9581
+ subTimelineWaitMemo,
9582
+ staticDedupMemo,
9583
+ compositionHash: computeCompositionObservabilityHash(compiled.html),
9584
+ deferStaticDedup: true,
9585
+ onStaticDedupActivity: () => noteStaticDedupActivity(job)
9537
9586
  };
9538
9587
  const PROBE_MAX_ATTEMPTS = 2;
9539
9588
  for (let attempt = 1; attempt <= PROBE_MAX_ATTEMPTS; attempt++) {
@@ -9990,7 +10039,7 @@ function validateRenderDuration(input) {
9990
10039
  }
9991
10040
 
9992
10041
  // src/services/render/stages/extractVideosStage.ts
9993
- import { existsSync as existsSync14 } from "node:fs";
10042
+ import { existsSync as existsSync13 } from "node:fs";
9994
10043
  import { join as join21 } from "node:path";
9995
10044
  import {
9996
10045
  classifyVideoExtractionError,
@@ -10260,7 +10309,7 @@ async function runExtractVideosStage(input) {
10260
10309
  const probeFailures = await Promise.all(
10261
10310
  composition.videos.map(async (v) => {
10262
10311
  const videoPath = resolveProjectRelativeSrc3(v.src, projectDir, compiledDir);
10263
- if (!existsSync14(videoPath)) return null;
10312
+ if (!existsSync13(videoPath)) return null;
10264
10313
  try {
10265
10314
  const attempted = extractionPolicy.maxTransientRetries === 0 ? { result: await extractMediaMetadata3(videoPath), retries: 0 } : await runVideoExtractionWithRetry2(() => extractMediaMetadata3(videoPath), {
10266
10315
  signal: abortSignal,
@@ -10298,7 +10347,7 @@ async function runExtractVideosStage(input) {
10298
10347
  const probed = await Promise.all(
10299
10348
  composition.images.map(async (img) => {
10300
10349
  const imgPath = resolveProjectRelativeSrc3(img.src, projectDir, compiledDir);
10301
- if (!existsSync14(imgPath)) return null;
10350
+ if (!existsSync13(imgPath)) return null;
10302
10351
  const colorSpace = await probeColorSpaceSafely(imgPath, log);
10303
10352
  if (isHdrColorSpace2(colorSpace)) {
10304
10353
  nativeHdrImageIds.add(img.id);
@@ -10418,7 +10467,7 @@ async function appendVideoAudioFromProbe(input) {
10418
10467
  videos.map(async (video) => {
10419
10468
  const path = isHttpUrl2(video.src) ? video.src : resolveProjectRelativeSrc3(video.src, projectDir, compiledDir);
10420
10469
  const readFrom = urlByAbsentLocalPath?.get(path) ?? path;
10421
- if (!isHttpUrl2(readFrom) && !existsSync14(readFrom)) return null;
10470
+ if (!isHttpUrl2(readFrom) && !existsSync13(readFrom)) return null;
10422
10471
  const metadata = await extractMediaMetadata3(readFrom);
10423
10472
  const window2 = await resolveFinalFrameExtractionWindow2(
10424
10473
  readFrom,
@@ -10438,7 +10487,7 @@ async function appendVideoAudioFromProbe(input) {
10438
10487
  }
10439
10488
 
10440
10489
  // src/services/render/videoLayerPassthroughPlan.ts
10441
- import { existsSync as existsSync15 } from "node:fs";
10490
+ import { existsSync as existsSync14 } from "node:fs";
10442
10491
  import {
10443
10492
  buildVideoLayerInput,
10444
10493
  isHttpUrl as isHttpUrl3,
@@ -10506,7 +10555,7 @@ async function planVideoLayerPassthrough(input) {
10506
10555
  const { video } = q;
10507
10556
  if (isHttpUrl3(video.src)) return { reason: "remote_source" };
10508
10557
  const path = resolveProjectRelativeSrc4(video.src, input.projectDir, input.compiledDir);
10509
- if (!existsSync15(path)) return { reason: "source_missing" };
10558
+ if (!existsSync14(path)) return { reason: "source_missing" };
10510
10559
  const layout = await probeVideoLayout(input.page, video.id, input.canvas, input.duration);
10511
10560
  if ("reason" in layout) return layout;
10512
10561
  const layer = await buildVideoLayerInput(
@@ -10521,7 +10570,7 @@ async function planVideoLayerPassthrough(input) {
10521
10570
  }
10522
10571
 
10523
10572
  // src/services/render/stages/audioStage.ts
10524
- import { existsSync as existsSync17 } from "node:fs";
10573
+ import { existsSync as existsSync16 } from "node:fs";
10525
10574
  import { join as join24 } from "node:path";
10526
10575
  import {
10527
10576
  MIXED_AUDIO_FILENAME,
@@ -10532,7 +10581,7 @@ import {
10532
10581
  } from "@hyperframes/engine";
10533
10582
 
10534
10583
  // src/services/render/audioDeliveryLimit.ts
10535
- import { existsSync as existsSync16 } from "node:fs";
10584
+ import { existsSync as existsSync15 } from "node:fs";
10536
10585
  import { dirname as dirname10, join as join23 } from "node:path";
10537
10586
  import {
10538
10587
  applyAudioFxChain,
@@ -11041,7 +11090,7 @@ async function limitDeliveryPeaks(input, deps = {
11041
11090
  applyChain: applyAudioFxChain,
11042
11091
  encode: encodeAac2,
11043
11092
  rename: renameWithRetry6,
11044
- sourceExists: existsSync16
11093
+ sourceExists: existsSync15
11045
11094
  }) {
11046
11095
  const { audioPath, sourcePath, signal, timeoutMs } = input;
11047
11096
  if (!deps.sourceExists(sourcePath)) return { success: true };
@@ -11136,7 +11185,7 @@ async function runAudioStageScoped(input) {
11136
11185
  );
11137
11186
  audioLoweredDb = guard.loweredDb;
11138
11187
  input.log?.info("[audio] phases", { ...result.audioPhaseMs, guard: Date.now() - guardStart });
11139
- if (input.keepDeliverySource && !guard.sourceStale && existsSync17(pcmSourcePath)) {
11188
+ if (input.keepDeliverySource && !guard.sourceStale && existsSync16(pcmSourcePath)) {
11140
11189
  deliverySourcePath = pcmSourcePath;
11141
11190
  }
11142
11191
  }
@@ -11264,7 +11313,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
11264
11313
  }
11265
11314
 
11266
11315
  // src/services/render/stages/captureStage.ts
11267
- import { existsSync as existsSync18, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
11316
+ import { existsSync as existsSync17, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
11268
11317
  import { join as join25 } from "node:path";
11269
11318
  import {
11270
11319
  classifyCaptureFailure as classifyCaptureFailure2,
@@ -11335,7 +11384,7 @@ function diskCaptureShortfallError(needBytes, freeBytes, framesDir, basis, remed
11335
11384
  }
11336
11385
  function measureCaptureFrameBytes(workDir, framesDir) {
11337
11386
  let total = sampleDirectoryBytes(framesDir);
11338
- if (!existsSync18(workDir)) return total;
11387
+ if (!existsSync17(workDir)) return total;
11339
11388
  for (const attempt of readdirSync4(workDir)) {
11340
11389
  if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
11341
11390
  total += sampleDirectoryBytes(join25(workDir, attempt));
@@ -11517,7 +11566,7 @@ async function runSequentialDiskCapture(input, captureOptions, captureCfg, check
11517
11566
  captureBeyondViewport = session.options.captureBeyondViewport;
11518
11567
  try {
11519
11568
  if (probeSession) {
11520
- prepareCaptureSessionForReuse3(session, framesDir, videoInjector);
11569
+ await prepareCaptureSessionForReuse3(session, framesDir, videoInjector);
11521
11570
  probeSession = null;
11522
11571
  }
11523
11572
  await ensureSessionReady(session, {
@@ -11642,7 +11691,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
11642
11691
  }
11643
11692
 
11644
11693
  // src/services/render/stages/captureHdrStage.ts
11645
- import { existsSync as existsSync20, mkdirSync as mkdirSync10 } from "node:fs";
11694
+ import { existsSync as existsSync19, mkdirSync as mkdirSync10 } from "node:fs";
11646
11695
  import { join as join29 } from "node:path";
11647
11696
  import {
11648
11697
  closeCaptureSession as closeCaptureSession7,
@@ -11888,7 +11937,7 @@ import { Worker } from "node:worker_threads";
11888
11937
  import { fileURLToPath as fileURLToPath3, pathToFileURL } from "node:url";
11889
11938
  import { dirname as dirname11, join as join27 } from "node:path";
11890
11939
  import { createRequire } from "node:module";
11891
- import { existsSync as existsSync19 } from "node:fs";
11940
+ import { existsSync as existsSync18 } from "node:fs";
11892
11941
  import { cpus as cpus2 } from "node:os";
11893
11942
  function resolveWorkerEntry(explicit) {
11894
11943
  if (explicit && explicit.length > 0) {
@@ -11901,7 +11950,7 @@ function resolveWorkerEntry(explicit) {
11901
11950
  }
11902
11951
  const moduleDir = dirname11(fileURLToPath3(import.meta.url));
11903
11952
  const jsPath = join27(moduleDir, "shaderTransitionWorker.js");
11904
- if (existsSync19(jsPath)) return { path: jsPath, isTs: false };
11953
+ if (existsSync18(jsPath)) return { path: jsPath, isTs: false };
11905
11954
  const tsPath = join27(moduleDir, "shaderTransitionWorker.ts");
11906
11955
  return { path: tsPath, isTs: true };
11907
11956
  }
@@ -12462,7 +12511,7 @@ async function runCaptureHdrStage(input) {
12462
12511
  }
12463
12512
  const debugDumpEnabled = process.env.KEEP_TEMP === "1";
12464
12513
  const debugDumpDir = debugDumpEnabled ? join29(framesDir, "debug-composite") : null;
12465
- if (debugDumpDir && !existsSync20(debugDumpDir)) {
12514
+ if (debugDumpDir && !existsSync19(debugDumpDir)) {
12466
12515
  mkdirSync10(debugDumpDir, { recursive: true });
12467
12516
  }
12468
12517
  const compositeTransfer = resolveCompositeTransfer(hasHdrContent, effectiveHdr);
@@ -12619,7 +12668,7 @@ async function runCaptureHdrStage(input) {
12619
12668
  // src/services/render/stages/encodeStage.ts
12620
12669
  import {
12621
12670
  copyFileSync as copyFileSync4,
12622
- existsSync as existsSync21,
12671
+ existsSync as existsSync20,
12623
12672
  mkdirSync as mkdirSync11,
12624
12673
  readdirSync as readdirSync5,
12625
12674
  readFileSync as readFileSync9,
@@ -12753,7 +12802,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
12753
12802
  const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
12754
12803
  if (failure) return failure;
12755
12804
  }
12756
- const fileSize = existsSync21(outputPath) ? statSync8(outputPath).size : 0;
12805
+ const fileSize = existsSync20(outputPath) ? statSync8(outputPath).size : 0;
12757
12806
  return {
12758
12807
  success: true,
12759
12808
  outputPath,
@@ -12914,7 +12963,7 @@ async function runEncodeStage(input) {
12914
12963
  const stage5Start = Date.now();
12915
12964
  if (isPngSequence) {
12916
12965
  const encoded = startEncodeProgress(job, "Writing PNG sequence", onProgress);
12917
- if (!existsSync21(outputPath)) mkdirSync11(outputPath, { recursive: true });
12966
+ if (!existsSync20(outputPath)) mkdirSync11(outputPath, { recursive: true });
12918
12967
  const captured = readdirSync5(framesDir).filter((name) => name.endsWith(".png")).sort();
12919
12968
  if (captured.length === 0) {
12920
12969
  throw new Error(
@@ -12925,7 +12974,7 @@ async function runEncodeStage(input) {
12925
12974
  const dst = join30(outputPath, formatExportFrameName(i, "png"));
12926
12975
  copyFileSync4(join30(framesDir, name), dst);
12927
12976
  });
12928
- if (hasAudio && audioOutputPath && existsSync21(audioOutputPath)) {
12977
+ if (hasAudio && audioOutputPath && existsSync20(audioOutputPath)) {
12929
12978
  copyFileSync4(audioOutputPath, join30(outputPath, MIXED_AUDIO_FILENAME2));
12930
12979
  log.info(
12931
12980
  `[Render] png-sequence: ${MIXED_AUDIO_FILENAME2} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME2}`
@@ -13314,7 +13363,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
13314
13363
  let rangeStart = null;
13315
13364
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
13316
13365
  const framePath = join31(framesDir, formatCaptureFrameName(frameIndex, frameExt));
13317
- const missing = !existsSync22(framePath) || statSync9(framePath).size <= 8;
13366
+ const missing = !existsSync21(framePath) || statSync9(framePath).size <= 8;
13318
13367
  if (missing && rangeStart === null) {
13319
13368
  rangeStart = frameIndex;
13320
13369
  } else if (!missing && rangeStart !== null) {
@@ -13421,7 +13470,8 @@ function frameStallRule(job, totalFrames, probeStartupMs) {
13421
13470
  complete: () => (job.framesRendered ?? 0) >= totalFrames,
13422
13471
  tailMs: Math.max(TAIL_STALL_MS, noProgressMs),
13423
13472
  detail: () => describeWorkerPhases(job),
13424
- attemptOpened: () => forgetWorkerPhases(job)
13473
+ attemptOpened: () => forgetWorkerPhases(job),
13474
+ activity: () => staticDedupActivity(job)
13425
13475
  };
13426
13476
  }
13427
13477
  function isRecoverableParallelCaptureError(error) {
@@ -13446,7 +13496,7 @@ function countCapturedFrames(totalFrames, framesDir, frameExt) {
13446
13496
  let captured = 0;
13447
13497
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
13448
13498
  const framePath = join31(framesDir, formatCaptureFrameName(frameIndex, frameExt));
13449
- if (existsSync22(framePath)) captured++;
13499
+ if (existsSync21(framePath)) captured++;
13450
13500
  }
13451
13501
  return captured;
13452
13502
  }
@@ -14112,7 +14162,7 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
14112
14162
  validateChromaSubsamplingConfig(job.config);
14113
14163
  const debugDir = resolveRenderDebugDir();
14114
14164
  const outputDir = dirname13(outputPath);
14115
- if (!existsSync22(outputDir)) mkdirSync12(outputDir, { recursive: true });
14165
+ if (!existsSync21(outputDir)) mkdirSync12(outputDir, { recursive: true });
14116
14166
  const workDir = job.config.debug ? join31(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
14117
14167
  const pipelineStart = Date.now();
14118
14168
  const baseLog = job.config.logger ?? defaultLogger;
@@ -14254,7 +14304,7 @@ async function executeRenderPipeline(input) {
14254
14304
  job.startedAt = /* @__PURE__ */ new Date();
14255
14305
  assertNotAborted();
14256
14306
  assertConfiguredFfmpegBinariesExist();
14257
- if (!existsSync22(workDir)) mkdirSync12(workDir, { recursive: true });
14307
+ if (!existsSync21(workDir)) mkdirSync12(workDir, { recursive: true });
14258
14308
  if (job.config.debug) {
14259
14309
  log.info("[Render] Debug artifacts enabled", { workDir, logPath });
14260
14310
  }
@@ -14284,7 +14334,7 @@ async function executeRenderPipeline(input) {
14284
14334
  });
14285
14335
  const entryFile = job.config.entryFile || "index.html";
14286
14336
  const htmlPath = join31(projectDir, entryFile);
14287
- if (!existsSync22(htmlPath)) {
14337
+ if (!existsSync21(htmlPath)) {
14288
14338
  throw new Error(`Entry file not found: ${htmlPath}`);
14289
14339
  }
14290
14340
  assertNotAborted();
@@ -14376,6 +14426,7 @@ async function executeRenderPipeline(input) {
14376
14426
  (result) => Object.assign(job, result)
14377
14427
  );
14378
14428
  const subTimelineWaitMemo = {};
14429
+ const staticDedupMemo = {};
14379
14430
  const probeResult = await observeRenderStage(
14380
14431
  observability,
14381
14432
  "browser_probe",
@@ -14396,6 +14447,7 @@ async function executeRenderPipeline(input) {
14396
14447
  needsAlpha,
14397
14448
  deviceScaleFactor,
14398
14449
  subTimelineWaitMemo,
14450
+ staticDedupMemo,
14399
14451
  recordReferenceBackground
14400
14452
  }),
14401
14453
  // Browser probe is pre-capture; report `browser calibrating` so a
@@ -14628,7 +14680,7 @@ async function executeRenderPipeline(input) {
14628
14680
  throw new Error("File server failed to initialize before frame capture");
14629
14681
  }
14630
14682
  const framesDir = join31(workDir, "captured-frames");
14631
- if (!existsSync22(framesDir)) mkdirSync12(framesDir, { recursive: true });
14683
+ if (!existsSync21(framesDir)) mkdirSync12(framesDir, { recursive: true });
14632
14684
  updateJobStatus(job, "rendering", "Checking browser GPU", 25, onProgress, {
14633
14685
  code: "start_browsers"
14634
14686
  });
@@ -14687,6 +14739,9 @@ async function executeRenderPipeline(input) {
14687
14739
  videoMetadataHints,
14688
14740
  skipReadinessVideoIds: videoReadinessSkipIds,
14689
14741
  subTimelineWaitMemo,
14742
+ staticDedupMemo,
14743
+ compositionHash,
14744
+ onStaticDedupActivity: () => noteStaticDedupActivity(job),
14690
14745
  // Probe-resolved duration: drawElement self-verification derives its
14691
14746
  // sample frame indices from this so they land inside the drained range.
14692
14747
  compositionDurationSeconds: job.duration,
@@ -16033,7 +16088,7 @@ async function executeRenderPipeline(input) {
16033
16088
  })
16034
16089
  );
16035
16090
  const totalElapsed = Date.now() - pipelineStart;
16036
- const tmpPeakBytes = existsSync22(workDir) ? sampleDirectoryBytes(workDir) : 0;
16091
+ const tmpPeakBytes = existsSync21(workDir) ? sampleDirectoryBytes(workDir) : 0;
16037
16092
  recordTransientRetryObservability();
16038
16093
  observability.checkpoint("pipeline", "artifact validated", { totalElapsedMs: totalElapsed });
16039
16094
  const observabilitySummary = observability.summary({
@@ -16114,7 +16169,7 @@ async function executeRenderPipeline(input) {
16114
16169
  }
16115
16170
  }
16116
16171
  if (job.config.debug) {
16117
- if (!isPngSequence && !isHls && existsSync22(stagedOutputPath)) {
16172
+ if (!isPngSequence && !isHls && existsSync21(stagedOutputPath)) {
16118
16173
  const debugOutput = join31(workDir, `output${videoExt}`);
16119
16174
  copyFileSync5(stagedOutputPath, debugOutput);
16120
16175
  }
@@ -16226,7 +16281,7 @@ async function executeRenderPipeline(input) {
16226
16281
 
16227
16282
  // src/services/hyperframeLint.ts
16228
16283
  import {
16229
- existsSync as existsSync23,
16284
+ existsSync as existsSync22,
16230
16285
  readFileSync as readFileSync10,
16231
16286
  statSync as statSync10,
16232
16287
  openSync as openSync5,
@@ -16280,7 +16335,7 @@ function readEntryHtml(filePath) {
16280
16335
  }
16281
16336
  function readProjectEntryFile(projectDir, preferredEntryFile) {
16282
16337
  const absProjectDir = resolve9(projectDir);
16283
- if (!existsSync23(absProjectDir) || !statSync10(absProjectDir).isDirectory()) {
16338
+ if (!existsSync22(absProjectDir) || !statSync10(absProjectDir).isDirectory()) {
16284
16339
  return { error: `Project directory not found: ${absProjectDir}` };
16285
16340
  }
16286
16341
  const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
@@ -16349,7 +16404,7 @@ async function runHyperframeLint(prepared) {
16349
16404
  import { Worker as Worker2 } from "node:worker_threads";
16350
16405
  import { fileURLToPath as fileURLToPath5 } from "node:url";
16351
16406
  import { dirname as dirname14, join as join33 } from "node:path";
16352
- import { existsSync as existsSync24 } from "node:fs";
16407
+ import { existsSync as existsSync23 } from "node:fs";
16353
16408
  var DEFAULT_HEALTH_PORT = 9848;
16354
16409
  async function startHealthWorker(options = {}) {
16355
16410
  const log = options.logger ?? defaultLogger2();
@@ -16426,7 +16481,7 @@ function resolveWorkerEntry2() {
16426
16481
  const here = dirname14(fileURLToPath5(import.meta.url));
16427
16482
  const candidates = [join33(here, "healthWorkerThread.js"), join33(here, "healthWorkerThread.ts")];
16428
16483
  for (const candidate of candidates) {
16429
- if (existsSync24(candidate)) return candidate;
16484
+ if (existsSync23(candidate)) return candidate;
16430
16485
  }
16431
16486
  return void 0;
16432
16487
  }
@@ -16499,7 +16554,7 @@ import {
16499
16554
  // src/services/distributed/shared.ts
16500
16555
  import { execFile as execFileCallback } from "node:child_process";
16501
16556
  import { dirname as dirname15, join as join34 } from "node:path";
16502
- import { existsSync as existsSync25, readFileSync as readFileSync11 } from "node:fs";
16557
+ import { existsSync as existsSync24, readFileSync as readFileSync11 } from "node:fs";
16503
16558
  import { fileURLToPath as fileURLToPath6 } from "node:url";
16504
16559
  import { promisify as promisify2 } from "node:util";
16505
16560
  import {
@@ -16515,7 +16570,7 @@ function readProducerVersion() {
16515
16570
  let current = startDir;
16516
16571
  for (let i = 0; i < 10; i++) {
16517
16572
  const candidate = join34(current, "package.json");
16518
- if (existsSync25(candidate)) {
16573
+ if (existsSync24(candidate)) {
16519
16574
  try {
16520
16575
  const pkg = JSON.parse(readFileSync11(candidate, "utf-8"));
16521
16576
  if (pkg.name === "@hyperframes/producer" && typeof pkg.version === "string") {
@@ -17015,7 +17070,7 @@ function resolvePreparedRenderOutput(prepared, rendersDir, log) {
17015
17070
  const { input, cleanupProjectDir } = prepared;
17016
17071
  const absoluteOutputPath = resolveOutputPath(input.projectDir, input.outputPath, rendersDir, log);
17017
17072
  const outputDir = dirname16(absoluteOutputPath);
17018
- if (!existsSync26(outputDir)) mkdirSync13(outputDir, { recursive: true });
17073
+ if (!existsSync25(outputDir)) mkdirSync13(outputDir, { recursive: true });
17019
17074
  return { input, cleanupProjectDir, absoluteOutputPath };
17020
17075
  }
17021
17076
  function prepareRenderJob(prepared, rendersDir, log) {
@@ -17072,11 +17127,11 @@ function prepareProjectDirectory(projectDir, options) {
17072
17127
  const candidate = nonEmptyString(projectDir);
17073
17128
  if (!candidate) return null;
17074
17129
  const absProjectDir = resolve10(candidate);
17075
- if (!existsSync26(absProjectDir) || !statSync11(absProjectDir).isDirectory()) {
17130
+ if (!existsSync25(absProjectDir) || !statSync11(absProjectDir).isDirectory()) {
17076
17131
  return { error: `Project directory not found: ${absProjectDir}` };
17077
17132
  }
17078
17133
  const entry = options.entryFile || "index.html";
17079
- if (!existsSync26(resolve10(absProjectDir, entry))) {
17134
+ if (!existsSync25(resolve10(absProjectDir, entry))) {
17080
17135
  return { error: `Entry file "${entry}" not found in project directory: ${absProjectDir}` };
17081
17136
  }
17082
17137
  return { prepared: { input: { projectDir: absProjectDir, ...options } } };
@@ -17168,7 +17223,7 @@ function cleanupTempDir(dir, log) {
17168
17223
  }
17169
17224
  }
17170
17225
  function outputFileSize(path) {
17171
- return existsSync26(path) ? statSync11(path).size : 0;
17226
+ return existsSync25(path) ? statSync11(path).size : 0;
17172
17227
  }
17173
17228
  function createBlockingProgressReporter(log, requestId) {
17174
17229
  let lastLoggedPct = -10;
@@ -17479,7 +17534,7 @@ function createRenderHandlers(options = {}) {
17479
17534
  if (!artifact) {
17480
17535
  return c.json({ success: false, error: "Output artifact not found or expired" }, 404);
17481
17536
  }
17482
- if (!existsSync26(artifact.path)) {
17537
+ if (!existsSync25(artifact.path)) {
17483
17538
  store.delete(token);
17484
17539
  return c.json({ success: false, error: "Output artifact file missing" }, 404);
17485
17540
  }