@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.
@@ -8,7 +8,7 @@ import { audioFailureDiagnostics as audioFailureDiagnostics3 } from "@hyperframe
8
8
  import {
9
9
  copyFileSync as copyFileSync6,
10
10
  cpSync as cpSync2,
11
- existsSync as existsSync20,
11
+ existsSync as existsSync19,
12
12
  linkSync,
13
13
  mkdirSync as mkdirSync10,
14
14
  rmSync as rmSync7,
@@ -66,12 +66,14 @@ function createConsoleLogger(level = "info") {
66
66
  }
67
67
  };
68
68
  }
69
- var defaultLogger = createConsoleLogger("info");
69
+ var defaultLogger = createConsoleLogger(
70
+ process.env.HF_DEBUG_RENDER === "1" ? "debug" : "info"
71
+ );
70
72
 
71
73
  // src/services/renderOrchestrator.ts
72
74
  import { audioFailureDiagnostics as audioFailureDiagnostics2 } from "@hyperframes/engine";
73
75
  import {
74
- existsSync as existsSync15,
76
+ existsSync as existsSync14,
75
77
  mkdirSync as mkdirSync6,
76
78
  readdirSync as readdirSync3,
77
79
  rmSync as rmSync5,
@@ -953,7 +955,7 @@ function chunkGopFrames(framesInChunk, intervalFrames) {
953
955
  import {
954
956
  copyFileSync,
955
957
  cpSync,
956
- existsSync as existsSync4,
958
+ existsSync as existsSync3,
957
959
  mkdirSync,
958
960
  rmSync,
959
961
  symlinkSync,
@@ -976,9 +978,7 @@ import {
976
978
  relative as nodeRelative,
977
979
  isAbsolute as nodeIsAbsolute
978
980
  } from "node:path";
979
- import { existsSync as existsSync3 } from "node:fs";
980
981
  import { fileURLToPath as fileURLToPath2 } from "node:url";
981
- import { decodedUrlPath } from "@hyperframes/parsers/asset-paths";
982
982
  var DEFAULT_RENDERS_DIR = process.env.PRODUCER_RENDERS_DIR ?? // fileURLToPath (not URL.pathname): on Windows .pathname is "/D:/..." which
983
983
  // resolves to a bogus renders dir.
984
984
  nodeResolve(fileURLToPath2(import.meta.url), "../../..", "renders");
@@ -1009,13 +1009,6 @@ function formatCaptureFrameName(index, ext) {
1009
1009
  function formatExportFrameName(index, ext) {
1010
1010
  return `frame_${String(index + 1).padStart(6, "0")}.${ext}`;
1011
1011
  }
1012
- function resolveCompositionSrc(projectDir, src) {
1013
- const rooted = (value) => nodeResolve(projectDir, value.replace(/^(?:\.?[\\/])+/, ""));
1014
- const decoded = rooted(decodedUrlPath(src));
1015
- if (!isPathInside2(decoded, projectDir)) return null;
1016
- const raw = rooted(src);
1017
- return !existsSync3(decoded) && isPathInside2(raw, projectDir) && existsSync3(raw) ? raw : decoded;
1018
- }
1019
1012
 
1020
1013
  // src/services/render/shared.ts
1021
1014
  var BROWSER_MEDIA_EPSILON = 1e-4;
@@ -1165,6 +1158,13 @@ var workerPhasesByJob = /* @__PURE__ */ new WeakMap();
1165
1158
  function forgetWorkerPhases(job) {
1166
1159
  workerPhasesByJob.delete(job);
1167
1160
  }
1161
+ var staticDedupActivityByJob = /* @__PURE__ */ new WeakMap();
1162
+ function noteStaticDedupActivity(job) {
1163
+ staticDedupActivityByJob.set(job, (staticDedupActivityByJob.get(job) ?? 0) + 1);
1164
+ }
1165
+ function staticDedupActivity(job) {
1166
+ return staticDedupActivityByJob.get(job) ?? 0;
1167
+ }
1168
1168
  function describeWorkerPhases(job) {
1169
1169
  const phases = workerPhasesByJob.get(job);
1170
1170
  if (!phases?.size) return void 0;
@@ -1198,7 +1198,7 @@ var materializePathModule = {
1198
1198
  isAbsolute
1199
1199
  };
1200
1200
  var materializeFileSystem = {
1201
- existsSync: existsSync4,
1201
+ existsSync: existsSync3,
1202
1202
  mkdirSync,
1203
1203
  symlinkSync,
1204
1204
  cpSync,
@@ -1811,6 +1811,7 @@ function resolveVideoCaptureBeyondViewport(videoCount) {
1811
1811
  }
1812
1812
 
1813
1813
  // src/services/render/observability.ts
1814
+ import { createHash as createHash2 } from "node:crypto";
1814
1815
  import { redactTelemetryString } from "@hyperframes/core";
1815
1816
  import { CaptureFailure as CaptureFailure2 } from "@hyperframes/engine";
1816
1817
  var MAX_EVENTS = 160;
@@ -1856,6 +1857,9 @@ var RESERVED_LOG_KEYS = /* @__PURE__ */ new Set([
1856
1857
  function sanitizeObservationMessage(value) {
1857
1858
  return redactTelemetryString(value);
1858
1859
  }
1860
+ function computeCompositionObservabilityHash(compiledHtml) {
1861
+ return createHash2("sha256").update(compiledHtml, "utf8").digest("hex").slice(0, 16);
1862
+ }
1859
1863
  function sanitizeObservationData(data) {
1860
1864
  if (!data) return void 0;
1861
1865
  const sanitized = {};
@@ -2058,26 +2062,26 @@ var STALL_POLL_MS = 5e3;
2058
2062
  function watchStall(phase, rule) {
2059
2063
  const detail = rule.detail ?? (() => void 0);
2060
2064
  let last = rule.progress();
2065
+ let lastActivity = rule.activity?.();
2061
2066
  let budgetMs = rule.firstProgressMs;
2062
2067
  const silence = createStallClock();
2063
2068
  const pollMs = Math.min(STALL_POLL_MS, rule.noProgressMs, rule.firstProgressMs);
2064
2069
  let attempt;
2065
2070
  let timer;
2066
2071
  let inTail = false;
2072
+ const activityMoved = () => {
2073
+ const activity = rule.activity?.();
2074
+ if (activity === lastActivity) return false;
2075
+ lastActivity = activity;
2076
+ return true;
2077
+ };
2067
2078
  const restartWindow = (ms) => {
2068
2079
  last = rule.progress();
2069
2080
  budgetMs = ms;
2070
2081
  silence.reset();
2071
2082
  };
2072
2083
  const tripped = new Promise((_, reject) => {
2073
- timer = setInterval(() => {
2074
- const current = rule.progress();
2075
- if (rule.complete?.() && !inTail) {
2076
- inTail = true;
2077
- return restartWindow(rule.tailMs ?? rule.noProgressMs);
2078
- }
2079
- if (current !== last) return restartWindow(rule.noProgressMs);
2080
- if (silence.idle(pollMs) < budgetMs) return;
2084
+ const trip = (current) => {
2081
2085
  const error = new RenderStageStalledError(phase, budgetMs, current, detail());
2082
2086
  if (attempt && !attempt.signal.aborted) {
2083
2087
  attempt.abort(error);
@@ -2085,6 +2089,16 @@ function watchStall(phase, rule) {
2085
2089
  }
2086
2090
  clearInterval(timer);
2087
2091
  reject(error);
2092
+ };
2093
+ timer = setInterval(() => {
2094
+ const current = rule.progress();
2095
+ if (rule.complete?.() && !inTail) {
2096
+ inTail = true;
2097
+ return restartWindow(rule.tailMs ?? rule.noProgressMs);
2098
+ }
2099
+ if (current !== last) return restartWindow(rule.noProgressMs);
2100
+ if (activityMoved()) return silence.reset();
2101
+ if (silence.idle(pollMs) >= budgetMs) trip(current);
2088
2102
  }, pollMs);
2089
2103
  });
2090
2104
  const openAttempt = (parent) => {
@@ -2152,21 +2166,21 @@ import {
2152
2166
  } from "@hyperframes/engine";
2153
2167
 
2154
2168
  // src/services/render/stages/compileStage.ts
2155
- import { existsSync as existsSync9, writeFileSync as writeFileSync3 } from "node:fs";
2169
+ import { existsSync as existsSync8, writeFileSync as writeFileSync3 } from "node:fs";
2156
2170
  import { join as join9 } from "node:path";
2157
2171
  import { suggestMatchingPreset } from "@hyperframes/core";
2158
2172
  import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
2159
2173
  import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolution";
2160
2174
 
2161
2175
  // src/services/htmlCompiler.ts
2162
- import { decodedUrlPath as decodedUrlPath2 } from "@hyperframes/parsers/asset-paths";
2163
- import { createHash as createHash4 } from "node:crypto";
2164
- import { createReadStream as createReadStream2, existsSync as existsSync8, mkdirSync as mkdirSync4, readFileSync as readFileSync5 } from "fs";
2176
+ import { decodedUrlPath } from "@hyperframes/parsers/asset-paths";
2177
+ import { createHash as createHash5 } from "node:crypto";
2178
+ import { createReadStream as createReadStream2, existsSync as existsSync7, mkdirSync as mkdirSync4, readFileSync as readFileSync5 } from "fs";
2165
2179
  import { join as join8, dirname as dirname6, resolve as resolve6, basename as basename3, relative as relative2, sep as sep2 } from "path";
2166
2180
  import { parseHTML as parseHTML5 } from "linkedom";
2167
2181
 
2168
2182
  // src/services/bundledScripts.ts
2169
- import { existsSync as existsSync5, readFileSync as readFileSync2 } from "node:fs";
2183
+ import { existsSync as existsSync4, readFileSync as readFileSync2 } from "node:fs";
2170
2184
  import { join as join5 } from "node:path";
2171
2185
  import { gsapCdnDist } from "@hyperframes/core/gsap-cdn";
2172
2186
  var GSAP_VENDOR_DIR_ENV = "HYPERFRAMES_GSAP_VENDOR_DIR";
@@ -2174,7 +2188,7 @@ function bundledScript(url) {
2174
2188
  const dir = process.env[GSAP_VENDOR_DIR_ENV];
2175
2189
  if (!dir || url !== `${gsapCdnDist()}gsap.min.js`) return null;
2176
2190
  const file = join5(dir, "gsap.min.js");
2177
- return existsSync5(file) ? readFileSync2(file) : null;
2191
+ return existsSync4(file) ? readFileSync2(file) : null;
2178
2192
  }
2179
2193
 
2180
2194
  // src/services/htmlCompiler.ts
@@ -2214,6 +2228,7 @@ import {
2214
2228
  emitRootCompositionVariableStyles,
2215
2229
  readDeclaredDefaults,
2216
2230
  parseHostVariableValues,
2231
+ boundMediaSrc,
2217
2232
  headStyleRuns,
2218
2233
  isAlwaysAppliedStyle,
2219
2234
  dedupeFontFaceRules,
@@ -2228,8 +2243,10 @@ import {
2228
2243
  } from "@hyperframes/parsers/sub-composition-validity";
2229
2244
  import {
2230
2245
  isUnresolvedAssetPlaceholder,
2246
+ namesAnotherNetworkRoot as namesAnotherNetworkRoot2,
2231
2247
  readProjectFile,
2232
- readTextFile
2248
+ readTextFile,
2249
+ resolveCompositionSrc
2233
2250
  } from "@hyperframes/parsers/asset-resolution";
2234
2251
 
2235
2252
  // src/services/renderMediaCollector.ts
@@ -2421,12 +2438,13 @@ import {
2421
2438
  } from "@hyperframes/core/fonts/embed";
2422
2439
 
2423
2440
  // src/services/animatedGifPrep.ts
2424
- import { createHash as createHash2 } from "node:crypto";
2425
- import { copyFileSync as copyFileSync2, existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync as rmSync2, statSync as statSync2 } from "node:fs";
2441
+ import { createHash as createHash3 } from "node:crypto";
2442
+ import { copyFileSync as copyFileSync2, existsSync as existsSync5, mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync as rmSync2, statSync as statSync2 } from "node:fs";
2426
2443
  import { dirname as dirname4, isAbsolute as isAbsolute2, join as join6, resolve as resolve4 } from "node:path";
2427
2444
  import { parseHTML as parseHTML3 } from "linkedom";
2428
2445
  import { parseAnimatedGifMetadata } from "@hyperframes/core";
2429
2446
  import { DEFAULT_VP9_CPU_USED, runFfmpeg as runFfmpeg2, renameWithRetry as renameWithRetry3 } from "@hyperframes/engine";
2447
+ import { namesAnotherNetworkRoot } from "@hyperframes/parsers/asset-resolution";
2430
2448
  var PREPARED_GIF_SUBDIR = "_animated_gif";
2431
2449
  var CACHE_SCHEMA = "hfgif-v1";
2432
2450
  function splitUrlSuffix(src) {
@@ -2461,14 +2479,15 @@ function resolveLocalImageSourcePath(src, options) {
2461
2479
  const { basePath } = splitUrlSuffix(trimmed);
2462
2480
  const normalizedBase = normalizeRelPath(basePath);
2463
2481
  const mapped = options.sourceAssets?.get(trimmed) ?? options.sourceAssets?.get(basePath) ?? options.sourceAssets?.get(normalizedBase);
2464
- if (mapped && existsSync6(mapped)) return mapped;
2482
+ if (mapped && existsSync5(mapped)) return mapped;
2465
2483
  if (isHttpUrl(trimmed)) return null;
2484
+ const protocolRelativeUrlOnShare = basePath.startsWith("/") && namesAnotherNetworkRoot(options.projectDir, basePath);
2466
2485
  const projectRelative = basePath.startsWith("/") ? basePath.slice(1) : basePath;
2467
2486
  const candidates = [
2468
- isAbsolute2(basePath) ? basePath : resolve4(options.projectDir, projectRelative),
2487
+ ...protocolRelativeUrlOnShare ? [] : [isAbsolute2(basePath) ? basePath : resolve4(options.projectDir, projectRelative)],
2469
2488
  resolve4(options.downloadDir, normalizedBase)
2470
2489
  ];
2471
- return candidates.find((candidate) => existsSync6(candidate)) ?? null;
2490
+ return candidates.find((candidate) => existsSync5(candidate)) ?? null;
2472
2491
  }
2473
2492
  function isUsableFile(path) {
2474
2493
  try {
@@ -2479,7 +2498,7 @@ function isUsableFile(path) {
2479
2498
  }
2480
2499
  }
2481
2500
  function computePreparedGifHash(bytes, loopIterations, padSeconds) {
2482
- return createHash2("sha256").update(CACHE_SCHEMA).update("\0").update(String(loopIterations)).update("\0").update(String(padSeconds)).update("\0").update(bytes).digest("hex");
2501
+ return createHash3("sha256").update(CACHE_SCHEMA).update("\0").update(String(loopIterations)).update("\0").update(String(padSeconds)).update("\0").update(bytes).digest("hex");
2483
2502
  }
2484
2503
  function resolveLoop(metadata, override) {
2485
2504
  if (override != null) return override;
@@ -2579,10 +2598,10 @@ async function runAnimatedGifTranscode(request) {
2579
2598
  throw result.error ?? new Error(`Animated GIF transcode failed (${result.exitCode}): ${result.stderr.slice(-500)}`);
2580
2599
  }
2581
2600
  async function ensurePreparedWebm(input) {
2582
- if (!existsSync6(dirname4(input.cachePath))) {
2601
+ if (!existsSync5(dirname4(input.cachePath))) {
2583
2602
  mkdirSync2(dirname4(input.cachePath), { recursive: true });
2584
2603
  }
2585
- if (!existsSync6(dirname4(input.outputPath))) {
2604
+ if (!existsSync5(dirname4(input.outputPath))) {
2586
2605
  mkdirSync2(dirname4(input.outputPath), { recursive: true });
2587
2606
  }
2588
2607
  if (!isUsableFile(input.cachePath)) {
@@ -2727,7 +2746,7 @@ async function prepareAnimatedGifInputs(html, options) {
2727
2746
  }
2728
2747
 
2729
2748
  // src/services/heifImagePrep.ts
2730
- import { createHash as createHash3 } from "node:crypto";
2749
+ import { createHash as createHash4 } from "node:crypto";
2731
2750
  import {
2732
2751
  closeSync as closeSync2,
2733
2752
  copyFileSync as copyFileSync3,
@@ -3025,7 +3044,7 @@ async function prepareHeifImageInputs(html, options) {
3025
3044
  const src = (img.getAttribute("src") || "").trim();
3026
3045
  const source = src ? resolveImageSource(src, options) : null;
3027
3046
  if (!source) continue;
3028
- const hash = createHash3("sha256").update(CACHE_SCHEMA2).update("\0").update(source.bytes).digest("hex");
3047
+ const hash = createHash4("sha256").update(CACHE_SCHEMA2).update("\0").update(source.bytes).digest("hex");
3029
3048
  found.push({ img, src, source, filename: `${CACHE_SCHEMA2}-${hash.slice(0, 24)}.jpg` });
3030
3049
  }
3031
3050
  if (found.length === 0) return { html, preparedAssets, preparedImages };
@@ -3057,7 +3076,7 @@ import { createStudioPositionSeekReapplyScript } from "@hyperframes/studio-serve
3057
3076
  import { getPositionEditsRenderScript } from "@hyperframes/core/runtime/position-edits-render";
3058
3077
 
3059
3078
  // src/services/assetMediaType.ts
3060
- import { existsSync as existsSync7 } from "node:fs";
3079
+ import { existsSync as existsSync6 } from "node:fs";
3061
3080
  import {
3062
3081
  fingerprintElementId,
3063
3082
  isNotMediaPayload,
@@ -3130,7 +3149,7 @@ async function preflightCompositionAssetMediaTypes(input) {
3130
3149
  input.projectDir,
3131
3150
  input.compiledDir
3132
3151
  );
3133
- if (!existsSync7(resolvedPath)) continue;
3152
+ if (!existsSync6(resolvedPath)) continue;
3134
3153
  byPath.set(resolvedPath, [...byPath.get(resolvedPath) ?? [], reference]);
3135
3154
  }
3136
3155
  const mismatches = [];
@@ -3170,7 +3189,7 @@ async function preflightCompositionAssetMediaTypes(input) {
3170
3189
 
3171
3190
  // src/services/htmlCompiler.ts
3172
3191
  function logRemoteDownloadTelemetry(event) {
3173
- defaultLogger.info("[Compiler] Remote asset download integrity", { ...event });
3192
+ defaultLogger.debug("[Compiler] Remote asset download integrity", { ...event });
3174
3193
  }
3175
3194
  var INFERRED_MEDIA_DURATION_ATTR = "data-hf-inferred-duration";
3176
3195
  function parseSubCompHtmlForValidity(html) {
@@ -3384,7 +3403,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, down
3384
3403
  let filePath = src;
3385
3404
  if (isHttpUrl(src)) {
3386
3405
  const remoteDir = join8(downloadDir, REMOTE_MEDIA_SUBDIR);
3387
- if (!existsSync8(remoteDir)) mkdirSync4(remoteDir, { recursive: true });
3406
+ if (!existsSync7(remoteDir)) mkdirSync4(remoteDir, { recursive: true });
3388
3407
  try {
3389
3408
  filePath = await downloadToTemp(src, remoteDir, void 0, void 0, void 0, {
3390
3409
  onTelemetry: logRemoteDownloadTelemetry
@@ -3393,11 +3412,14 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, down
3393
3412
  return { duration: null, resolvedPath: src };
3394
3413
  }
3395
3414
  } else {
3396
- filePath = decodedUrlPath2(src);
3415
+ filePath = decodedUrlPath(src);
3397
3416
  if (!filePath.startsWith("/")) filePath = join8(baseDir, filePath);
3398
3417
  filePath = urlByAbsentLocalPath?.get(filePath) ?? filePath;
3418
+ if (!isHttpUrl(filePath) && namesAnotherNetworkRoot2(baseDir, filePath)) {
3419
+ return { duration: null, resolvedPath: filePath };
3420
+ }
3399
3421
  }
3400
- if (!isHttpUrl(filePath) && !existsSync8(filePath)) {
3422
+ if (!isHttpUrl(filePath) && !existsSync7(filePath)) {
3401
3423
  return { duration: null, resolvedPath: filePath };
3402
3424
  }
3403
3425
  const withSrcContext = (error) => {
@@ -3746,7 +3768,7 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
3746
3768
  parseHtml: (htmlStr) => parseHTML5(htmlStr).document,
3747
3769
  // Mirrors the preview bundler: a sub-composition's SIBLING assets resolve
3748
3770
  // against its own directory, project-root refs stay as authored.
3749
- assetExists: (path) => existsSync8(resolve6(projectDir, path)),
3771
+ assetExists: (path) => existsSync7(resolve6(projectDir, path)),
3750
3772
  // Preserve the authored root wrapper as a child of the host, matching
3751
3773
  // the preview bundler's shape (htmlBundler.ts's prepareFlattenedInnerRoot,
3752
3774
  // which the runtime compositionLoader mirrors with its own copy for the
@@ -3871,7 +3893,7 @@ function matchesScriptIntegrity(bytes, metadata) {
3871
3893
  (alg) => hashes.some((hash) => hash[1]?.toLowerCase() === alg)
3872
3894
  );
3873
3895
  if (!strongest) return true;
3874
- const actual = createHash4(strongest).update(bytes).digest();
3896
+ const actual = createHash5(strongest).update(bytes).digest();
3875
3897
  return hashes.some(
3876
3898
  (hash) => hash[1]?.toLowerCase() === strongest && actual.equals(Buffer.from(hash[2], "base64"))
3877
3899
  );
@@ -3922,7 +3944,7 @@ ${safeText}
3922
3944
  //# sourceURL=${new URL(src).href}
3923
3945
  `;
3924
3946
  el.replaceWith(inlineScript);
3925
- defaultLogger.info(`[Compiler] Inlined CDN script: ${src}`);
3947
+ defaultLogger.debug(`[Compiler] Inlined CDN script: ${src}`);
3926
3948
  } else {
3927
3949
  if (download.reason instanceof ScriptIntegrityError) throw download.reason;
3928
3950
  defaultLogger.warn(
@@ -3942,7 +3964,7 @@ function collectExternalAssets(html, projectDir) {
3942
3964
  if (isPathInside2(absPath, absProjectDir)) {
3943
3965
  return null;
3944
3966
  }
3945
- if (!existsSync8(absPath)) return null;
3967
+ if (!existsSync7(absPath)) return null;
3946
3968
  const safeKey = toExternalAssetKey(absPath);
3947
3969
  externalAssets.set(safeKey, absPath);
3948
3970
  return safeKey;
@@ -3977,7 +3999,7 @@ function collectExternalAssets(html, projectDir) {
3977
3999
  if (rewritten !== style) el.setAttribute("style", rewritten);
3978
4000
  }
3979
4001
  if (externalAssets.size > 0) {
3980
- defaultLogger.info(
4002
+ defaultLogger.debug(
3981
4003
  `[Compiler] Found ${externalAssets.size} asset(s) outside project directory, will copy to render output`
3982
4004
  );
3983
4005
  }
@@ -3992,7 +4014,7 @@ var REMOTE_SOURCE_TAG_RE = /<source\b[^>]*?\bsrc\s*=\s*["'](https?:\/\/[^"']+)["
3992
4014
  var REMOTE_IMG_TAG_RE = /<img\b[^>]*?(?<![\w-])src\s*=\s*["'](https?:\/\/[^"']+)["'][^>]*>/gi;
3993
4015
  async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLabel, extraRewrite) {
3994
4016
  if (urlSet.size === 0) return { html, remoteMediaAssets: /* @__PURE__ */ new Map() };
3995
- if (!existsSync8(remoteDir)) mkdirSync4(remoteDir, { recursive: true });
4017
+ if (!existsSync7(remoteDir)) mkdirSync4(remoteDir, { recursive: true });
3996
4018
  const urlToLocal = /* @__PURE__ */ new Map();
3997
4019
  await Promise.all(
3998
4020
  [...urlSet].map(async (url) => {
@@ -4024,7 +4046,7 @@ async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLab
4024
4046
  result = result.replaceAll(`"${url}"`, `"${relPath}"`).replaceAll(`'${url}'`, `'${relPath}'`);
4025
4047
  if (extraRewrite) result = extraRewrite(result, url, relPath);
4026
4048
  }
4027
- defaultLogger.info(`[Compiler] ${logLabel} ${urlToLocal.size} to ${REMOTE_MEDIA_SUBDIR}/`);
4049
+ defaultLogger.debug(`[Compiler] ${logLabel} ${urlToLocal.size} to ${REMOTE_MEDIA_SUBDIR}/`);
4028
4050
  return { html: result, remoteMediaAssets };
4029
4051
  }
4030
4052
  async function localizeRemoteMediaSources(html, downloadDir) {
@@ -4161,7 +4183,7 @@ async function inlineExternalFontStylesheets(html) {
4161
4183
  ${fontFaceBlocks.join("\n")}
4162
4184
  </style>`;
4163
4185
  result = result.replace(fullMatch, inlineStyle);
4164
- defaultLogger.info("[Compiler] Inlined external @font-face rule(s)", {
4186
+ defaultLogger.debug("[Compiler] Inlined external @font-face rule(s)", {
4165
4187
  count: fontFaceBlocks.length,
4166
4188
  urlFingerprint: identity.urlFingerprint,
4167
4189
  host: identity.host
@@ -4174,14 +4196,14 @@ function projectStylesheetFontFamilies(html, projectDir) {
4174
4196
  for (const [tag] of html.matchAll(/<link\b[^>]*\brel=["']stylesheet["'][^>]*>/gi)) {
4175
4197
  const href = /\bhref=["']([^"']+)["']/i.exec(tag)?.[1];
4176
4198
  if (!href || /^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(href)) continue;
4177
- const sheet = resolve6(projectDir, decodedUrlPath2(href).replace(/^(?:\.?\/)+/, ""));
4178
- if (!isPathInside2(sheet, projectDir) || !existsSync8(sheet)) continue;
4199
+ const sheet = resolve6(projectDir, decodedUrlPath(href).replace(/^(?:\.?\/)+/, ""));
4200
+ if (!isPathInside2(sheet, projectDir) || !existsSync7(sheet)) continue;
4179
4201
  for (const face of extractFontFaceBlocks(readFileSync5(sheet, "utf8"))) {
4180
4202
  const family = /font-family\s*:\s*([^;}]+)/i.exec(face)?.[1]?.trim().replace(/^['"]|['"]$/g, "");
4181
4203
  const shipsFile = [...face.matchAll(LOCAL_FONTFACE_URL_RE)].some(([, url = ""]) => {
4182
- const path = decodedUrlPath2(url);
4204
+ const path = decodedUrlPath(url);
4183
4205
  const file = path.startsWith("/") ? resolve6(projectDir, `.${path}`) : resolve6(dirname6(sheet), path);
4184
- return isPathInside2(file, projectDir) && existsSync8(file);
4206
+ return isPathInside2(file, projectDir) && existsSync7(file);
4185
4207
  });
4186
4208
  if (family && shipsFile) families.push(family);
4187
4209
  }
@@ -4280,7 +4302,7 @@ async function embedLocalFontFaces(html, projectDir) {
4280
4302
  const font = await readLocalFont(absPath);
4281
4303
  if (font.kind === "file-backed") {
4282
4304
  fileBackedAbsolutePaths.add(absPath);
4283
- defaultLogger.info(
4305
+ defaultLogger.debug(
4284
4306
  `[Compiler] Kept large local font file-backed: ${localPath} (> ${(MAX_LOCAL_FONT_DATA_URI_BYTES / 1024 / 1024).toFixed(1)} MB)`
4285
4307
  );
4286
4308
  embeddedPaths.add(localPath);
@@ -4288,7 +4310,7 @@ async function embedLocalFontFaces(html, projectDir) {
4288
4310
  }
4289
4311
  dataUri = await toDataUri(font.buffer, ext, { compressToWoff2: false });
4290
4312
  dataUriByAbsolutePath.set(absPath, dataUri);
4291
- defaultLogger.info(
4313
+ defaultLogger.debug(
4292
4314
  `[Compiler] Embedded local font file: ${localPath} (${(font.buffer.length / 1024).toFixed(0)} KB \u2192 data URI)`
4293
4315
  );
4294
4316
  }
@@ -4316,14 +4338,17 @@ function renderGsapDist() {
4316
4338
  }
4317
4339
  function rewriteUnresolvableGsapToCdn(html, projectDir, compSrcPath) {
4318
4340
  let gsapDist;
4319
- const exists = (path) => existsSync8(resolve6(projectDir, path));
4341
+ const exists = (path) => {
4342
+ const file = resolve6(projectDir, path);
4343
+ return !namesAnotherNetworkRoot2(projectDir, file) && existsSync7(file);
4344
+ };
4320
4345
  return html.replace(
4321
4346
  /(<script\b[^>]*\bsrc=["'])([^"']*gsap[^"']*\/dist\/([^"']+))(["'][^>]*>)/gi,
4322
4347
  (full, prefix, src, file, suffix) => {
4323
4348
  if (/^https?:\/\//i.test(src)) return full;
4324
4349
  if (exists(compSrcPath ? rewriteAssetPath(compSrcPath, src, exists) : src)) return full;
4325
4350
  gsapDist ??= renderGsapDist();
4326
- defaultLogger.info(`[Compiler] Rewriting missing gsap script: ${src} \u2192 ${gsapDist}${file}`);
4351
+ defaultLogger.debug(`[Compiler] Rewriting missing gsap script: ${src} \u2192 ${gsapDist}${file}`);
4327
4352
  return `${prefix}${gsapDist}${file}${suffix}`;
4328
4353
  }
4329
4354
  );
@@ -4333,7 +4358,7 @@ function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath) {
4333
4358
  const entryPath = relative2(projectDir, htmlPath).replace(/\\/g, "/");
4334
4359
  if (!entryPath.includes("/")) return html;
4335
4360
  const { document: document2 } = parseHTML5(html);
4336
- const assetExists = (path) => existsSync8(resolve6(projectDir, path));
4361
+ const assetExists = (path) => existsSync7(resolve6(projectDir, path));
4337
4362
  rewriteAssetPaths(
4338
4363
  document2.querySelectorAll("[src], [href], [srcset]"),
4339
4364
  entryPath,
@@ -4353,11 +4378,29 @@ function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath) {
4353
4378
  }
4354
4379
  return document2.toString();
4355
4380
  }
4381
+ function bindVariableMediaSources(html, variables) {
4382
+ if (!html.includes("data-var-src")) return html;
4383
+ const { document: document2 } = parseHTML5(html);
4384
+ const declared = {};
4385
+ for (const el of document2.querySelectorAll("[data-composition-variables]")) {
4386
+ Object.assign(declared, readDeclaredDefaults(el));
4387
+ }
4388
+ const values = { ...declared, ...variables };
4389
+ let changed = false;
4390
+ for (const el of document2.querySelectorAll("video[data-var-src], audio[data-var-src]")) {
4391
+ if (el.closest("[data-variable-values]")) continue;
4392
+ const src = boundMediaSrc(el, values);
4393
+ if (src === null || el.getAttribute("src") === src) continue;
4394
+ el.setAttribute("src", src);
4395
+ changed = true;
4396
+ }
4397
+ return changed ? document2.toString() : html;
4398
+ }
4356
4399
  async function compileForRender(projectDir, htmlPath, downloadDir, options = {}) {
4357
4400
  const entryHtml = rebaseDirectEntryAssetPaths(readTextFile(htmlPath), projectDir, htmlPath);
4358
- const rawHtml = normalizeCompositionSrcs(
4359
- rewriteUnresolvableGsapToCdn(entryHtml, projectDir),
4360
- projectDir
4401
+ const rawHtml = bindVariableMediaSources(
4402
+ normalizeCompositionSrcs(rewriteUnresolvableGsapToCdn(entryHtml, projectDir), projectDir),
4403
+ options.variables ?? {}
4361
4404
  );
4362
4405
  assertSubCompositionsUsable(rawHtml, projectDir);
4363
4406
  const probes = /* @__PURE__ */ new Map();
@@ -4441,7 +4484,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
4441
4484
  timeoutMs: options.ffmpegProcessTimeout
4442
4485
  });
4443
4486
  if (preparedHeifImages.length > 0) {
4444
- defaultLogger.info(`[Compiler] Converted ${preparedHeifImages.length} HEIC image(s) to JPEG`);
4487
+ defaultLogger.debug(`[Compiler] Converted ${preparedHeifImages.length} HEIC image(s) to JPEG`);
4445
4488
  }
4446
4489
  const gifSourceAssets = new Map(remoteImageAssets);
4447
4490
  const {
@@ -4456,7 +4499,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
4456
4499
  timeoutMs: options.ffmpegProcessTimeout
4457
4500
  });
4458
4501
  if (preparedGifs.length > 0) {
4459
- defaultLogger.info(`[Compiler] Prepared ${preparedGifs.length} animated GIF input(s) as WebM`);
4502
+ defaultLogger.debug(`[Compiler] Prepared ${preparedGifs.length} animated GIF input(s) as WebM`);
4460
4503
  }
4461
4504
  const embeddedHtml = await embedLocalFontFaces(htmlWithPreparedGifs, projectDir);
4462
4505
  const { html, externalAssets } = collectExternalAssets(embeddedHtml, projectDir);
@@ -4484,7 +4527,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
4484
4527
  for (const video of videos) {
4485
4528
  if (isHttpUrl(video.src)) continue;
4486
4529
  const videoPath = resolve6(projectDir, video.src);
4487
- if (advised.has(videoPath)) continue;
4530
+ if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath)) continue;
4488
4531
  advised.add(videoPath);
4489
4532
  const reencode = `ffmpeg -i "${video.src}" -c:v libx264 -r 30 -g 30 -keyint_min 30 -movflags +faststart -c:a copy output.mp4`;
4490
4533
  (async () => {
@@ -4903,7 +4946,7 @@ function resolveEntryHtmlPath(input) {
4903
4946
  const rawEntry = readTextFile2(htmlPath);
4904
4947
  if (entryFile === "index.html" || !isTemplateEntry(rawEntry)) return htmlPath;
4905
4948
  const projectIndexPath = join9(projectDir, "index.html");
4906
- if (!existsSync9(projectIndexPath)) {
4949
+ if (!existsSync8(projectIndexPath)) {
4907
4950
  throw new Error(
4908
4951
  `Template entry file "${entryFile}" requires a project index.html to extract its render shell.`
4909
4952
  );
@@ -5058,7 +5101,7 @@ async function runCompileStage(input) {
5058
5101
  }
5059
5102
 
5060
5103
  // src/services/render/stages/probeStage.ts
5061
- import { createHash as createHash5 } from "node:crypto";
5104
+ import { createHash as createHash6 } from "node:crypto";
5062
5105
  import { basename as basename4, join as join10 } from "node:path";
5063
5106
  import { parseHTML as parseHTML6 } from "linkedom";
5064
5107
  import {
@@ -5218,7 +5261,7 @@ function reportedLengthSource(source) {
5218
5261
  if (!source) return null;
5219
5262
  if (source.from !== "media") return { from: source.from };
5220
5263
  const name = basename4(source.src.split(/[?#]/, 1)[0] ?? "");
5221
- const srcHash = createHash5("sha256").update(name).digest("hex").slice(0, 12);
5264
+ const srcHash = createHash6("sha256").update(name).digest("hex").slice(0, 12);
5222
5265
  return { from: "media", tag: source.tag, trimmed: source.trimmed, srcHash };
5223
5266
  }
5224
5267
  async function runProbeStage(input) {
@@ -5236,7 +5279,8 @@ async function runProbeStage(input) {
5236
5279
  height,
5237
5280
  needsAlpha,
5238
5281
  deviceScaleFactor,
5239
- subTimelineWaitMemo
5282
+ subTimelineWaitMemo,
5283
+ staticDedupMemo
5240
5284
  } = input;
5241
5285
  let { compiled } = input;
5242
5286
  const probeCfg = cfg.forceScreenshot === forceScreenshot ? cfg : { ...cfg, forceScreenshot };
@@ -5297,7 +5341,11 @@ async function runProbeStage(input) {
5297
5341
  motionBlur,
5298
5342
  pageMotionBlur: job.config.pageMotionBlur,
5299
5343
  requiresWebGpu: compositionRequiresWebGpu(compiled.html),
5300
- subTimelineWaitMemo
5344
+ subTimelineWaitMemo,
5345
+ staticDedupMemo,
5346
+ compositionHash: computeCompositionObservabilityHash(compiled.html),
5347
+ deferStaticDedup: true,
5348
+ onStaticDedupActivity: () => noteStaticDedupActivity(job)
5301
5349
  };
5302
5350
  const PROBE_MAX_ATTEMPTS = 2;
5303
5351
  for (let attempt = 1; attempt <= PROBE_MAX_ATTEMPTS; attempt++) {
@@ -5786,7 +5834,7 @@ function validateDistributedDuration(input) {
5786
5834
  }
5787
5835
 
5788
5836
  // src/services/render/stages/extractVideosStage.ts
5789
- import { existsSync as existsSync10 } from "node:fs";
5837
+ import { existsSync as existsSync9 } from "node:fs";
5790
5838
  import { join as join11 } from "node:path";
5791
5839
  import {
5792
5840
  classifyVideoExtractionError,
@@ -6061,7 +6109,7 @@ async function runExtractVideosStage(input) {
6061
6109
  const probeFailures = await Promise.all(
6062
6110
  composition.videos.map(async (v) => {
6063
6111
  const videoPath = resolveProjectRelativeSrc3(v.src, projectDir, compiledDir);
6064
- if (!existsSync10(videoPath)) return null;
6112
+ if (!existsSync9(videoPath)) return null;
6065
6113
  try {
6066
6114
  const attempted = extractionPolicy.maxTransientRetries === 0 ? { result: await extractMediaMetadata3(videoPath), retries: 0 } : await runVideoExtractionWithRetry2(() => extractMediaMetadata3(videoPath), {
6067
6115
  signal: abortSignal,
@@ -6099,7 +6147,7 @@ async function runExtractVideosStage(input) {
6099
6147
  const probed = await Promise.all(
6100
6148
  composition.images.map(async (img) => {
6101
6149
  const imgPath = resolveProjectRelativeSrc3(img.src, projectDir, compiledDir);
6102
- if (!existsSync10(imgPath)) return null;
6150
+ if (!existsSync9(imgPath)) return null;
6103
6151
  const colorSpace = await probeColorSpaceSafely(imgPath, log);
6104
6152
  if (isHdrColorSpace2(colorSpace)) {
6105
6153
  nativeHdrImageIds.add(img.id);
@@ -6219,7 +6267,7 @@ async function appendVideoAudioFromProbe(input) {
6219
6267
  videos.map(async (video) => {
6220
6268
  const path = isHttpUrl2(video.src) ? video.src : resolveProjectRelativeSrc3(video.src, projectDir, compiledDir);
6221
6269
  const readFrom = urlByAbsentLocalPath?.get(path) ?? path;
6222
- if (!isHttpUrl2(readFrom) && !existsSync10(readFrom)) return null;
6270
+ if (!isHttpUrl2(readFrom) && !existsSync9(readFrom)) return null;
6223
6271
  const metadata = await extractMediaMetadata3(readFrom);
6224
6272
  const window2 = await resolveFinalFrameExtractionWindow2(
6225
6273
  readFrom,
@@ -6247,7 +6295,7 @@ import {
6247
6295
  } from "@hyperframes/engine";
6248
6296
 
6249
6297
  // src/services/render/stages/audioStage.ts
6250
- import { existsSync as existsSync12 } from "node:fs";
6298
+ import { existsSync as existsSync11 } from "node:fs";
6251
6299
  import { join as join14 } from "node:path";
6252
6300
  import {
6253
6301
  MIXED_AUDIO_FILENAME,
@@ -6258,7 +6306,7 @@ import {
6258
6306
  } from "@hyperframes/engine";
6259
6307
 
6260
6308
  // src/services/render/audioDeliveryLimit.ts
6261
- import { existsSync as existsSync11 } from "node:fs";
6309
+ import { existsSync as existsSync10 } from "node:fs";
6262
6310
  import { dirname as dirname8, join as join13 } from "node:path";
6263
6311
  import {
6264
6312
  applyAudioFxChain,
@@ -6767,7 +6815,7 @@ async function limitDeliveryPeaks(input, deps = {
6767
6815
  applyChain: applyAudioFxChain,
6768
6816
  encode: encodeAac2,
6769
6817
  rename: renameWithRetry6,
6770
- sourceExists: existsSync11
6818
+ sourceExists: existsSync10
6771
6819
  }) {
6772
6820
  const { audioPath, sourcePath, signal, timeoutMs } = input;
6773
6821
  if (!deps.sourceExists(sourcePath)) return { success: true };
@@ -6862,7 +6910,7 @@ async function runAudioStageScoped(input) {
6862
6910
  );
6863
6911
  audioLoweredDb = guard.loweredDb;
6864
6912
  input.log?.info("[audio] phases", { ...result.audioPhaseMs, guard: Date.now() - guardStart });
6865
- if (input.keepDeliverySource && !guard.sourceStale && existsSync12(pcmSourcePath)) {
6913
+ if (input.keepDeliverySource && !guard.sourceStale && existsSync11(pcmSourcePath)) {
6866
6914
  deliverySourcePath = pcmSourcePath;
6867
6915
  }
6868
6916
  }
@@ -6990,7 +7038,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
6990
7038
  }
6991
7039
 
6992
7040
  // src/services/render/stages/captureStage.ts
6993
- import { existsSync as existsSync13, readdirSync, statfsSync } from "node:fs";
7041
+ import { existsSync as existsSync12, readdirSync, statfsSync } from "node:fs";
6994
7042
  import { join as join15 } from "node:path";
6995
7043
  import {
6996
7044
  classifyCaptureFailure as classifyCaptureFailure2,
@@ -7042,7 +7090,7 @@ function diskCaptureShortfallError(needBytes, freeBytes, framesDir, basis, remed
7042
7090
  }
7043
7091
  function measureCaptureFrameBytes(workDir, framesDir) {
7044
7092
  let total = sampleDirectoryBytes(framesDir);
7045
- if (!existsSync13(workDir)) return total;
7093
+ if (!existsSync12(workDir)) return total;
7046
7094
  for (const attempt of readdirSync(workDir)) {
7047
7095
  if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
7048
7096
  total += sampleDirectoryBytes(join15(workDir, attempt));
@@ -7224,7 +7272,7 @@ async function runSequentialDiskCapture(input, captureOptions, captureCfg, check
7224
7272
  captureBeyondViewport = session.options.captureBeyondViewport;
7225
7273
  try {
7226
7274
  if (probeSession) {
7227
- prepareCaptureSessionForReuse3(session, framesDir, videoInjector);
7275
+ await prepareCaptureSessionForReuse3(session, framesDir, videoInjector);
7228
7276
  probeSession = null;
7229
7277
  }
7230
7278
  await ensureSessionReady(session, {
@@ -7383,7 +7431,7 @@ import {
7383
7431
  // src/services/render/stages/encodeStage.ts
7384
7432
  import {
7385
7433
  copyFileSync as copyFileSync4,
7386
- existsSync as existsSync14,
7434
+ existsSync as existsSync13,
7387
7435
  mkdirSync as mkdirSync5,
7388
7436
  readdirSync as readdirSync2,
7389
7437
  readFileSync as readFileSync6,
@@ -7517,7 +7565,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
7517
7565
  const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
7518
7566
  if (failure) return failure;
7519
7567
  }
7520
- const fileSize = existsSync14(outputPath) ? statSync4(outputPath).size : 0;
7568
+ const fileSize = existsSync13(outputPath) ? statSync4(outputPath).size : 0;
7521
7569
  return {
7522
7570
  success: true,
7523
7571
  outputPath,
@@ -7678,7 +7726,7 @@ async function runEncodeStage(input) {
7678
7726
  const stage5Start = Date.now();
7679
7727
  if (isPngSequence) {
7680
7728
  const encoded = startEncodeProgress(job, "Writing PNG sequence", onProgress);
7681
- if (!existsSync14(outputPath)) mkdirSync5(outputPath, { recursive: true });
7729
+ if (!existsSync13(outputPath)) mkdirSync5(outputPath, { recursive: true });
7682
7730
  const captured = readdirSync2(framesDir).filter((name) => name.endsWith(".png")).sort();
7683
7731
  if (captured.length === 0) {
7684
7732
  throw new Error(
@@ -7689,7 +7737,7 @@ async function runEncodeStage(input) {
7689
7737
  const dst = join16(outputPath, formatExportFrameName(i, "png"));
7690
7738
  copyFileSync4(join16(framesDir, name), dst);
7691
7739
  });
7692
- if (hasAudio && audioOutputPath && existsSync14(audioOutputPath)) {
7740
+ if (hasAudio && audioOutputPath && existsSync13(audioOutputPath)) {
7693
7741
  copyFileSync4(audioOutputPath, join16(outputPath, MIXED_AUDIO_FILENAME2));
7694
7742
  log.info(
7695
7743
  `[Render] png-sequence: ${MIXED_AUDIO_FILENAME2} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME2}`
@@ -7852,7 +7900,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
7852
7900
  let rangeStart = null;
7853
7901
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
7854
7902
  const framePath = join17(framesDir, formatCaptureFrameName(frameIndex, frameExt));
7855
- const missing = !existsSync15(framePath) || statSync5(framePath).size <= 8;
7903
+ const missing = !existsSync14(framePath) || statSync5(framePath).size <= 8;
7856
7904
  if (missing && rangeStart === null) {
7857
7905
  rangeStart = frameIndex;
7858
7906
  } else if (!missing && rangeStart !== null) {
@@ -7935,7 +7983,8 @@ function frameStallRule(job, totalFrames, probeStartupMs) {
7935
7983
  complete: () => (job.framesRendered ?? 0) >= totalFrames,
7936
7984
  tailMs: Math.max(TAIL_STALL_MS, noProgressMs),
7937
7985
  detail: () => describeWorkerPhases(job),
7938
- attemptOpened: () => forgetWorkerPhases(job)
7986
+ attemptOpened: () => forgetWorkerPhases(job),
7987
+ activity: () => staticDedupActivity(job)
7939
7988
  };
7940
7989
  }
7941
7990
  function isRecoverableParallelCaptureError(error) {
@@ -7949,7 +7998,7 @@ function countCapturedFrames(totalFrames, framesDir, frameExt) {
7949
7998
  let captured = 0;
7950
7999
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
7951
8000
  const framePath = join17(framesDir, formatCaptureFrameName(frameIndex, frameExt));
7952
- if (existsSync15(framePath)) captured++;
8001
+ if (existsSync14(framePath)) captured++;
7953
8002
  }
7954
8003
  return captured;
7955
8004
  }
@@ -8176,7 +8225,7 @@ import {
8176
8225
  } from "@hyperframes/engine";
8177
8226
 
8178
8227
  // src/services/distributed/chunkFrames.ts
8179
- import { existsSync as existsSync17, readdirSync as readdirSync4 } from "node:fs";
8228
+ import { existsSync as existsSync16, readdirSync as readdirSync4 } from "node:fs";
8180
8229
  import { extname as extname2, join as join19 } from "node:path";
8181
8230
  import {
8182
8231
  compositionRequiresWebGpu as compositionRequiresWebGpu3,
@@ -8187,7 +8236,7 @@ import {
8187
8236
  // src/services/distributed/shared.ts
8188
8237
  import { execFile as execFileCallback } from "node:child_process";
8189
8238
  import { dirname as dirname11, join as join18 } from "node:path";
8190
- import { existsSync as existsSync16, readFileSync as readFileSync7 } from "node:fs";
8239
+ import { existsSync as existsSync15, readFileSync as readFileSync7 } from "node:fs";
8191
8240
  import { fileURLToPath as fileURLToPath3 } from "node:url";
8192
8241
  import { promisify as promisify2 } from "node:util";
8193
8242
  import {
@@ -8203,7 +8252,7 @@ function isPlanAudioArtifactPath(path) {
8203
8252
  function resolvePlanAudioPath(planDir) {
8204
8253
  for (const name of [PLAN_AUDIO_RELATIVE_PATH, PLAN_AUDIO_LEGACY_RELATIVE_PATH]) {
8205
8254
  const candidate = join18(planDir, name);
8206
- if (existsSync16(candidate)) return candidate;
8255
+ if (existsSync15(candidate)) return candidate;
8207
8256
  }
8208
8257
  return null;
8209
8258
  }
@@ -8464,7 +8513,7 @@ function readProducerVersion() {
8464
8513
  let current = startDir;
8465
8514
  for (let i = 0; i < 10; i++) {
8466
8515
  const candidate = join18(current, "package.json");
8467
- if (existsSync16(candidate)) {
8516
+ if (existsSync15(candidate)) {
8468
8517
  try {
8469
8518
  const pkg = JSON.parse(readFileSync7(candidate, "utf-8"));
8470
8519
  if (pkg.name === "@hyperframes/producer" && typeof pkg.version === "string") {
@@ -8519,7 +8568,7 @@ function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v
8519
8568
  const result = [];
8520
8569
  for (const v of videos) {
8521
8570
  const outputDir = join19(planDir, "video-frames", mediaIdPathSegment3(v.videoId));
8522
- if (!existsSync17(outputDir)) {
8571
+ if (!existsSync16(outputDir)) {
8523
8572
  throw new Error(
8524
8573
  `[renderChunk] planDir missing extracted video frames for ${JSON.stringify(v.videoId)}: ${outputDir} not present. plan() should have written frames here; the planDir is malformed.`
8525
8574
  );
@@ -8618,7 +8667,7 @@ async function extractDeferredVideoFramesForChunk(input) {
8618
8667
  const range = planned.get(video.videoId).deferredRange;
8619
8668
  const remoteUrl = remoteSources[range.sourcePath];
8620
8669
  const sourcePath = remoteUrl ?? join19(input.planDir, ...range.sourcePath.split("/"));
8621
- if (remoteUrl === void 0 && !existsSync17(sourcePath)) {
8670
+ if (remoteUrl === void 0 && !existsSync16(sourcePath)) {
8622
8671
  throw new RenderChunkValidationError(
8623
8672
  MISSING_PLAN_ARTIFACT,
8624
8673
  `[renderChunk] planDir is missing the source for video ${JSON.stringify(video.videoId)}: ${range.sourcePath}`
@@ -8818,7 +8867,7 @@ async function readPlanReferenceBackground(input) {
8818
8867
  }
8819
8868
 
8820
8869
  // src/services/render/stages/freezePlan.ts
8821
- import { existsSync as existsSync18, mkdirSync as mkdirSync7, readFileSync as readFileSync8, readdirSync as readdirSync5, writeFileSync as writeFileSync6 } from "node:fs";
8870
+ import { existsSync as existsSync17, mkdirSync as mkdirSync7, readFileSync as readFileSync8, readdirSync as readdirSync5, writeFileSync as writeFileSync6 } from "node:fs";
8822
8871
  import { join as join22, relative as relative3, resolve as resolve8 } from "node:path";
8823
8872
  import {
8824
8873
  REFERENCE_BACKGROUND_FIELD,
@@ -8917,12 +8966,12 @@ function readPlanProtocolV1(planJson, capabilities = DISTRIBUTED_RENDER_CAPABILI
8917
8966
  }
8918
8967
 
8919
8968
  // src/services/render/stages/planHash.ts
8920
- import { createHash as createHash6 } from "node:crypto";
8969
+ import { createHash as createHash7 } from "node:crypto";
8921
8970
  import { closeSync as closeSync3, createReadStream as createReadStream3, openSync as openSync3, readSync as readSync2 } from "node:fs";
8922
8971
  var PLAN_HASH_SCHEMA_PREFIX = "hyperframes-plan-hash-v1\0";
8923
8972
  var FIELD_DELIMITER = Buffer.from([0]);
8924
8973
  function computePlanHash(input) {
8925
- const hash = createHash6("sha256");
8974
+ const hash = createHash7("sha256");
8926
8975
  hash.update(PLAN_HASH_SCHEMA_PREFIX, "utf8");
8927
8976
  hash.update(input.compositionHtml);
8928
8977
  hash.update(FIELD_DELIMITER);
@@ -8969,12 +9018,12 @@ function canonicalJsonStringify(value) {
8969
9018
  throw new TypeError(`canonicalJsonStringify: unsupported value type ${typeof value}`);
8970
9019
  }
8971
9020
  function sha256Hex(bytes) {
8972
- const h = createHash6("sha256");
9021
+ const h = createHash7("sha256");
8973
9022
  h.update(bytes);
8974
9023
  return h.digest("hex");
8975
9024
  }
8976
9025
  function sha256File(path) {
8977
- const hash = createHash6("sha256");
9026
+ const hash = createHash7("sha256");
8978
9027
  const buffer = Buffer.allocUnsafe(1024 * 1024);
8979
9028
  const fd = openSync3(path, "r");
8980
9029
  try {
@@ -8989,7 +9038,7 @@ function sha256File(path) {
8989
9038
  return hash.digest("hex");
8990
9039
  }
8991
9040
  async function sha256FileAsync(path) {
8992
- const hash = createHash6("sha256");
9041
+ const hash = createHash7("sha256");
8993
9042
  for await (const chunk of createReadStream3(path, { highWaterMark: 1024 * 1024 })) {
8994
9043
  hash.update(chunk);
8995
9044
  }
@@ -9012,7 +9061,7 @@ function planFileSha256(absolutePath, digests) {
9012
9061
  return sha256;
9013
9062
  }
9014
9063
  async function prehashPlanFiles(dir, digests) {
9015
- if (!existsSync18(dir)) return;
9064
+ if (!existsSync17(dir)) return;
9016
9065
  for (const { absolutePath } of listPlanFiles(dir)) {
9017
9066
  if (!digests.has(absolutePath)) digests.set(absolutePath, await sha256FileAsync(absolutePath));
9018
9067
  }
@@ -9082,15 +9131,15 @@ function writePlanRemoteFiles(planDir, files) {
9082
9131
  }
9083
9132
  function readPlanRemoteFiles(planDir) {
9084
9133
  const path = join22(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH);
9085
- return existsSync18(path) ? JSON.parse(readFileSync8(path, "utf-8")) : [];
9134
+ return existsSync17(path) ? JSON.parse(readFileSync8(path, "utf-8")) : [];
9086
9135
  }
9087
9136
  function recomputePlanHashFromPlanDir(planDir, digests) {
9088
9137
  const planJsonPath = join22(planDir, "plan.json");
9089
9138
  const encoderJsonPath = join22(planDir, "meta", "encoder.json");
9090
- if (!existsSync18(planJsonPath)) {
9139
+ if (!existsSync17(planJsonPath)) {
9091
9140
  throw new Error(`[freezePlan] plan.json missing: ${planJsonPath}`);
9092
9141
  }
9093
- if (!existsSync18(encoderJsonPath)) {
9142
+ if (!existsSync17(encoderJsonPath)) {
9094
9143
  throw new Error(`[freezePlan] meta/encoder.json missing: ${encoderJsonPath}`);
9095
9144
  }
9096
9145
  const planJson = JSON.parse(readFileSync8(planJsonPath, "utf-8"));
@@ -9120,11 +9169,11 @@ async function freezePlan(input) {
9120
9169
  hasAudio,
9121
9170
  digests
9122
9171
  } = input;
9123
- if (!existsSync18(planDir)) {
9172
+ if (!existsSync17(planDir)) {
9124
9173
  throw new Error(`[freezePlan] planDir does not exist: ${planDir}`);
9125
9174
  }
9126
9175
  const metaDir = join22(planDir, "meta");
9127
- if (!existsSync18(metaDir)) mkdirSync7(metaDir, { recursive: true });
9176
+ if (!existsSync17(metaDir)) mkdirSync7(metaDir, { recursive: true });
9128
9177
  writeFileSync6(
9129
9178
  join22(metaDir, "composition.json"),
9130
9179
  `${JSON.stringify(composition, null, 2)}
@@ -9201,7 +9250,7 @@ function applyRuntimeEnvSnapshot(snapshot, env = process.env) {
9201
9250
  }
9202
9251
 
9203
9252
  // src/services/distributed/chunkAudio.ts
9204
- import { closeSync as closeSync4, existsSync as existsSync19, ftruncateSync, mkdirSync as mkdirSync9, openSync as openSync4, readFileSync as readFileSync9 } from "node:fs";
9253
+ import { closeSync as closeSync4, existsSync as existsSync18, ftruncateSync, mkdirSync as mkdirSync9, openSync as openSync4, readFileSync as readFileSync9 } from "node:fs";
9205
9254
  import { writeFileSync as writeFileSync7, writeSync } from "node:fs";
9206
9255
  import { join as join24 } from "node:path";
9207
9256
  import { appendRenderProvenanceArgs, describeFfmpegFailure as describeFfmpegFailure4, runFfmpeg as runFfmpeg7 } from "@hyperframes/engine";
@@ -9693,7 +9742,7 @@ async function writeChunkAudioSlices(input) {
9693
9742
  }
9694
9743
  function chunkAudioSource(planDir, chunkIndex, scratchPath) {
9695
9744
  const layoutPath = join24(planDir, SLICE_LAYOUT);
9696
- if (!existsSync19(layoutPath)) return resolvePlanAudioPath(planDir);
9745
+ if (!existsSync18(layoutPath)) return resolvePlanAudioPath(planDir);
9697
9746
  const layout = JSON.parse(readFileSync9(layoutPath, "utf-8"));
9698
9747
  const frame = readFileSync9(join24(planDir, SLICE_FRAME));
9699
9748
  const fd = openSync4(scratchPath, "w");
@@ -9762,7 +9811,7 @@ async function muxChunkWithAudio(input) {
9762
9811
  }
9763
9812
 
9764
9813
  // src/services/distributed/planSize.ts
9765
- import { createHash as createHash7 } from "node:crypto";
9814
+ import { createHash as createHash8 } from "node:crypto";
9766
9815
  import { lstatSync, readdirSync as readdirSync6 } from "node:fs";
9767
9816
  import { extname as extname3, join as join25, relative as relative4 } from "node:path";
9768
9817
  var MAX_TOP_COMPONENTS = 10;
@@ -9792,7 +9841,7 @@ var PLAN_ROOT_CATEGORY = {
9792
9841
  "plan.json": "metadata"
9793
9842
  };
9794
9843
  function hashComponent(value) {
9795
- return createHash7("sha256").update(value).digest("hex").slice(0, 12);
9844
+ return createHash8("sha256").update(value).digest("hex").slice(0, 12);
9796
9845
  }
9797
9846
  function classifyFile(segments, rootKind) {
9798
9847
  const rootName = segments[0] ?? "";
@@ -10261,7 +10310,7 @@ function createVideoSourceShipper(input) {
10261
10310
  let result = null;
10262
10311
  for (const root of stagedRel === null ? [input.workCompiledDir, input.projectDir] : []) {
10263
10312
  const rel = pathInside(root, srcPath);
10264
- if (rel !== null && (existsSync20(join26(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
10313
+ if (rel !== null && (existsSync19(join26(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
10265
10314
  result = ["compiled", ...rel.split(sep3)].join("/");
10266
10315
  break;
10267
10316
  }
@@ -10289,7 +10338,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
10289
10338
  useGpu: false,
10290
10339
  browserGpuMode: "software"
10291
10340
  });
10292
- if (!existsSync20(planDir)) mkdirSync10(planDir, { recursive: true });
10341
+ if (!existsSync19(planDir)) mkdirSync10(planDir, { recursive: true });
10293
10342
  const log = config.logger ?? defaultLogger;
10294
10343
  const sizeLimitBytes = options.executionPlanSizeLimitBytes ?? config.planDirSizeLimitBytes ?? PLAN_DIR_SIZE_LIMIT_BYTES;
10295
10344
  const abortSignal = config.abortSignal;
@@ -10320,7 +10369,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
10320
10369
  });
10321
10370
  const entryFile = config.entryFile ?? "index.html";
10322
10371
  const htmlPath = join26(projectDir, entryFile);
10323
- if (!existsSync20(htmlPath)) {
10372
+ if (!existsSync19(htmlPath)) {
10324
10373
  throw new Error(`[plan] entry file not found: ${htmlPath}`);
10325
10374
  }
10326
10375
  const workDir = join26(planDir, ".plan-work");
@@ -10548,15 +10597,15 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
10548
10597
  logPlanStage(log, "extract", stageStarted);
10549
10598
  const stagedVideoFrames = join26(compiledDir, "__hyperframes_video_frames");
10550
10599
  const videoFramesDst = join26(planDir, "video-frames");
10551
- if (existsSync20(videoFramesDst)) rmSync7(videoFramesDst, { recursive: true, force: true });
10600
+ if (existsSync19(videoFramesDst)) rmSync7(videoFramesDst, { recursive: true, force: true });
10552
10601
  const videoSourcesDir = join26(planDir, "video-sources");
10553
10602
  rmSync7(videoSourcesDir, { recursive: true, force: true });
10554
- if (existsSync20(stagedVideoFrames)) {
10603
+ if (existsSync19(stagedVideoFrames)) {
10555
10604
  renameWithRetry8(stagedVideoFrames, videoFramesDst);
10556
10605
  } else {
10557
10606
  mkdirSync10(videoFramesDst, { recursive: true });
10558
10607
  }
10559
- if (existsSync20(finalCompiledDir)) rmSync7(finalCompiledDir, { recursive: true, force: true });
10608
+ if (existsSync19(finalCompiledDir)) rmSync7(finalCompiledDir, { recursive: true, force: true });
10560
10609
  renameWithRetry8(compiledDir, finalCompiledDir);
10561
10610
  const shipVideoSource = createVideoSourceShipper({
10562
10611
  planDir,
@@ -10677,10 +10726,10 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
10677
10726
  applyDistributedAudioWarningPolicy(job, audioResult.audioError, audioResult.audioFailures, log);
10678
10727
  }
10679
10728
  const planAudioPath = join26(planDir, PLAN_AUDIO_RELATIVE_PATH);
10680
- if (audioResult?.hasAudio && existsSync20(audioResult.audioOutputPath)) {
10729
+ if (audioResult?.hasAudio && existsSync19(audioResult.audioOutputPath)) {
10681
10730
  renameWithRetry8(audioResult.audioOutputPath, planAudioPath);
10682
10731
  }
10683
- if (chunksCarryAudio && existsSync20(planAudioPath)) {
10732
+ if (chunksCarryAudio && existsSync19(planAudioPath)) {
10684
10733
  if (options.sliceChunkAudio) {
10685
10734
  stageStarted = Date.now();
10686
10735
  await writeChunkAudioSlices({
@@ -10793,7 +10842,7 @@ async function buildPlanAudio(projectDir, config, workRoot, outputPath, options
10793
10842
  if (mixed.audioError) {
10794
10843
  applyDistributedAudioWarningPolicy(c.job, mixed.audioError, mixed.audioFailures, c.log);
10795
10844
  }
10796
- if (!mixed.hasAudio || !existsSync20(mixed.audioOutputPath)) return { hasAudio: false };
10845
+ if (!mixed.hasAudio || !existsSync19(mixed.audioOutputPath)) return { hasAudio: false };
10797
10846
  renameWithRetry8(mixed.audioOutputPath, outputPath);
10798
10847
  return { hasAudio: true };
10799
10848
  } finally {
@@ -10808,7 +10857,7 @@ import {
10808
10857
  } from "@hyperframes/engine";
10809
10858
  import {
10810
10859
  copyFileSync as copyFileSync8,
10811
- existsSync as existsSync22,
10860
+ existsSync as existsSync21,
10812
10861
  lstatSync as lstatSync2,
10813
10862
  mkdirSync as mkdirSync12,
10814
10863
  readFileSync as readFileSync10,
@@ -10829,7 +10878,7 @@ import {
10829
10878
  // src/services/distributed/planV2Publisher.ts
10830
10879
  import {
10831
10880
  copyFileSync as copyFileSync7,
10832
- existsSync as existsSync21,
10881
+ existsSync as existsSync20,
10833
10882
  linkSync as linkSync2,
10834
10883
  mkdirSync as mkdirSync11,
10835
10884
  rmSync as rmSync8,
@@ -10898,7 +10947,7 @@ var LocalPlanV2ArtifactPublisher = class {
10898
10947
  #linkFile;
10899
10948
  #committed = false;
10900
10949
  constructor(destinationDir, options = {}) {
10901
- if (existsSync21(destinationDir)) {
10950
+ if (existsSync20(destinationDir)) {
10902
10951
  throw new PlanV2IntegrityError(`output directory already exists: ${destinationDir}`);
10903
10952
  }
10904
10953
  this.destinationDir = destinationDir;
@@ -10915,7 +10964,7 @@ var LocalPlanV2ArtifactPublisher = class {
10915
10964
  );
10916
10965
  }
10917
10966
  const destinationPath = planV2BlobPath(this.temporaryDir, digest);
10918
- if (existsSync21(destinationPath)) return;
10967
+ if (existsSync20(destinationPath)) return;
10919
10968
  mkdirSync11(dirname13(destinationPath), { recursive: true });
10920
10969
  const stagingDir = createStagingDir5(dirname13(destinationPath), ".plan-v2-blob-");
10921
10970
  const temporaryPath = join28(stagingDir, "blob");
@@ -10933,7 +10982,7 @@ var LocalPlanV2ArtifactPublisher = class {
10933
10982
  }
10934
10983
  async commitManifest(manifestBytes) {
10935
10984
  for (const digest of new Set(manifestDigests(manifestBytes))) {
10936
- if (!existsSync21(planV2BlobPath(this.temporaryDir, digest))) {
10985
+ if (!existsSync20(planV2BlobPath(this.temporaryDir, digest))) {
10937
10986
  throw new PlanV2IntegrityError(
10938
10987
  `cannot commit manifest before referenced blob is durable: ${digest}`
10939
10988
  );
@@ -11013,7 +11062,7 @@ function assertValidExtractionCacheCompleteSentinel(path) {
11013
11062
  }
11014
11063
  function validateExtractionCacheCompleteSentinels(executionPlanDir) {
11015
11064
  const videoRoot = join29(executionPlanDir, "video-frames");
11016
- if (!existsSync22(videoRoot)) return;
11065
+ if (!existsSync21(videoRoot)) return;
11017
11066
  for (const videoEntry of readdirSync7(videoRoot, { withFileTypes: true })) {
11018
11067
  if (!videoEntry.isDirectory()) continue;
11019
11068
  const videoDir = join29(videoRoot, videoEntry.name);
@@ -11114,7 +11163,7 @@ function parsePlanVideosJson2(value) {
11114
11163
  }
11115
11164
  function materializeExtractedVideoDirectories(planDir) {
11116
11165
  const videosPath = join29(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
11117
- if (!existsSync22(videosPath)) return;
11166
+ if (!existsSync21(videosPath)) return;
11118
11167
  const videos = parsePlanVideosJson2(readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH));
11119
11168
  for (const video of videos.extracted) {
11120
11169
  mkdirSync12(resolveExtractedVideoOutputDir(planDir, video.videoId), { recursive: true });
@@ -11148,9 +11197,9 @@ function parseChunkSlices(value) {
11148
11197
  }
11149
11198
  function buildVideoChunkDependencies(executionPlanDir, dimensions) {
11150
11199
  const videoRoot = join29(executionPlanDir, "video-frames");
11151
- const hasExtractedFrames = existsSync22(videoRoot) && listFiles(videoRoot).length > 0;
11200
+ const hasExtractedFrames = existsSync21(videoRoot) && listFiles(videoRoot).length > 0;
11152
11201
  const videosPath = join29(executionPlanDir, PLAN_VIDEOS_META_RELATIVE_PATH);
11153
- if (!existsSync22(videosPath)) {
11202
+ if (!existsSync21(videosPath)) {
11154
11203
  return hasExtractedFrames ? { mode: "full-source-pack", dependencies: null } : { mode: "exact-rendered-frames", dependencies: /* @__PURE__ */ new Map() };
11155
11204
  }
11156
11205
  const chunksPath = join29(executionPlanDir, "meta", "chunks.json");
@@ -11207,7 +11256,7 @@ function computeManifestHash(manifest) {
11207
11256
  return sha256Hex(`${PLAN_V2_HASH_PREFIX}${canonicalJsonStringify(manifestPayload(manifest))}`);
11208
11257
  }
11209
11258
  function writeBlob(sourcePath, destinationPath) {
11210
- if (existsSync22(destinationPath)) return;
11259
+ if (existsSync21(destinationPath)) return;
11211
11260
  mkdirSync12(dirname14(destinationPath), { recursive: true });
11212
11261
  const temporaryDir = createStagingDir6(dirname14(destinationPath), ".plan-v2-blob-");
11213
11262
  const temporaryPath = join29(temporaryDir, "blob");
@@ -11247,7 +11296,7 @@ async function putTasks(tasks) {
11247
11296
  }
11248
11297
  function buildPlanV2Publication(executionPlanDir, digests) {
11249
11298
  const executionPlanPath = join29(executionPlanDir, "plan.json");
11250
- if (!existsSync22(executionPlanPath)) {
11299
+ if (!existsSync21(executionPlanPath)) {
11251
11300
  throw new PlanV2IntegrityError(`execution plan is missing plan.json: ${executionPlanPath}`);
11252
11301
  }
11253
11302
  const executionPlanValue = readJsonFile(executionPlanPath, "execution plan.json");
@@ -11327,7 +11376,7 @@ function buildPlanV2Publication(executionPlanDir, digests) {
11327
11376
  };
11328
11377
  }
11329
11378
  function createPlanV2FromExecutionPlan(executionPlanDir, planV2Dir) {
11330
- if (existsSync22(planV2Dir)) {
11379
+ if (existsSync21(planV2Dir)) {
11331
11380
  throw new PlanV2IntegrityError(`output directory already exists: ${planV2Dir}`);
11332
11381
  }
11333
11382
  const publication = buildPlanV2Publication(executionPlanDir);
@@ -11413,7 +11462,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
11413
11462
  }
11414
11463
  }
11415
11464
  async function planV2(projectDir, config, planV2Dir) {
11416
- if (existsSync22(planV2Dir)) {
11465
+ if (existsSync21(planV2Dir)) {
11417
11466
  throw new PlanV2IntegrityError(`output directory already exists: ${planV2Dir}`);
11418
11467
  }
11419
11468
  const publisher = new LocalPlanV2ArtifactPublisher(planV2Dir);
@@ -11567,7 +11616,7 @@ function parsePlanV2Manifest(value) {
11567
11616
  }
11568
11617
  function readPlanV2Manifest(planV2Dir) {
11569
11618
  const manifestPath = join29(planV2Dir, "plan.json");
11570
- if (!existsSync22(manifestPath)) {
11619
+ if (!existsSync21(manifestPath)) {
11571
11620
  throw new PlanV2IntegrityError(`missing v2 manifest: ${manifestPath}`);
11572
11621
  }
11573
11622
  const value = readJsonFile(manifestPath, "v2 manifest");
@@ -11586,7 +11635,7 @@ function listPlanV2ArtifactsForTarget(manifest, target) {
11586
11635
  }
11587
11636
  function verifyBlob(planV2Dir, artifact) {
11588
11637
  const sourcePath = planV2BlobPath(planV2Dir, artifact.sha256);
11589
- if (!existsSync22(sourcePath)) {
11638
+ if (!existsSync21(sourcePath)) {
11590
11639
  throw new PlanV2IntegrityError(`missing content-addressed artifact ${artifact.sha256}`);
11591
11640
  }
11592
11641
  const stats = statSync7(sourcePath);
@@ -11599,7 +11648,7 @@ function verifyBlob(planV2Dir, artifact) {
11599
11648
  return sourcePath;
11600
11649
  }
11601
11650
  function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}) {
11602
- if (existsSync22(destinationDir)) {
11651
+ if (existsSync21(destinationDir)) {
11603
11652
  throw new PlanV2IntegrityError(`materialization destination already exists: ${destinationDir}`);
11604
11653
  }
11605
11654
  const manifest = readPlanV2Manifest(planV2Dir);
@@ -11664,7 +11713,7 @@ function validatePlanV2MaterializedTarget(planDir, expectedTarget) {
11664
11713
  }
11665
11714
  function readValidatedPlanV2Materialization(planDir, expectedTarget) {
11666
11715
  const markerPath = join29(planDir, PLAN_V2_MATERIALIZATION_MARKER);
11667
- if (!existsSync22(markerPath)) return null;
11716
+ if (!existsSync21(markerPath)) return null;
11668
11717
  const marker = readJsonFile(markerPath, "materialization marker");
11669
11718
  if (!isRecord3(marker) || !isRecord3(marker.manifest) || !isRecord3(marker.target)) {
11670
11719
  throw new PlanV2IntegrityError("malformed materialization marker");
@@ -11682,7 +11731,7 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
11682
11731
  for (const artifact of required) {
11683
11732
  if (Object.hasOwn(remoteSources, artifact.path)) continue;
11684
11733
  const path = join29(planDir, ...artifact.path.split("/"));
11685
- if (!existsSync22(path) || statSync7(path).size !== artifact.sizeBytes) {
11734
+ if (!existsSync21(path) || statSync7(path).size !== artifact.sizeBytes) {
11686
11735
  throw new PlanV2IntegrityError(
11687
11736
  `materialized artifact missing or truncated: ${artifact.path}`
11688
11737
  );
@@ -11706,7 +11755,7 @@ import {
11706
11755
  } from "@hyperframes/engine";
11707
11756
  import {
11708
11757
  cpSync as cpSync3,
11709
- existsSync as existsSync23,
11758
+ existsSync as existsSync22,
11710
11759
  mkdirSync as mkdirSync13,
11711
11760
  readFileSync as readFileSync11,
11712
11761
  readdirSync as readdirSync8,
@@ -11761,7 +11810,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
11761
11810
  }
11762
11811
  const format = plan.dimensions.format;
11763
11812
  const cfrEncoder = cfr ? readCfrEncoder(planDir, format) : null;
11764
- if (!existsSync23(dirname15(outputPath))) {
11813
+ if (!existsSync22(dirname15(outputPath))) {
11765
11814
  mkdirSync13(dirname15(outputPath), { recursive: true });
11766
11815
  }
11767
11816
  const workDir = createStagingDir7(dirname15(outputPath), `${basename6(outputPath)}.assemble-work-`);
@@ -11785,7 +11834,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
11785
11834
  try {
11786
11835
  const videoSources = cfrEncoder ? [await reencodeCfr(ctx, chunkPaths, cfrEncoder)] : chunkPaths;
11787
11836
  const finalPath = join30(workDir, `output.${format}`);
11788
- const audio = audioPath !== null && existsSync23(audioPath) ? audioPath : null;
11837
+ const audio = audioPath !== null && existsSync22(audioPath) ? audioPath : null;
11789
11838
  await writeJoined(ctx, videoSources, audio, finalPath);
11790
11839
  renameWithRetry11(finalPath, outputPath);
11791
11840
  log.info("[assemble] stage timings", {
@@ -11803,7 +11852,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
11803
11852
  });
11804
11853
  }
11805
11854
  }
11806
- const fileSize = existsSync23(outputPath) ? statSync8(outputPath).size : 0;
11855
+ const fileSize = existsSync22(outputPath) ? statSync8(outputPath).size : 0;
11807
11856
  return {
11808
11857
  ...referenceBackgroundResult6(plan[REFERENCE_BACKGROUND_FIELD4]),
11809
11858
  outputPath,
@@ -11815,13 +11864,13 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
11815
11864
  function readAssemblePlan(planDir, chunkPaths) {
11816
11865
  const planJsonPath = join30(planDir, "plan.json");
11817
11866
  const chunksJsonPath = join30(planDir, "meta", "chunks.json");
11818
- if (!existsSync23(planJsonPath)) {
11867
+ if (!existsSync22(planJsonPath)) {
11819
11868
  throw new Error(`[assemble] planDir missing plan.json: ${planJsonPath}`);
11820
11869
  }
11821
11870
  const plan = JSON.parse(readFileSync11(planJsonPath, "utf-8"));
11822
11871
  readPlanProtocolV1(plan, DISTRIBUTED_RENDER_CAPABILITIES.roles.assembler);
11823
11872
  validatePlanV2MaterializedTarget(planDir, { role: "assembler" });
11824
- if (!existsSync23(chunksJsonPath)) {
11873
+ if (!existsSync22(chunksJsonPath)) {
11825
11874
  throw new Error(`[assemble] planDir missing meta/chunks.json: ${chunksJsonPath}`);
11826
11875
  }
11827
11876
  const chunks = JSON.parse(readFileSync11(chunksJsonPath, "utf-8"));
@@ -11836,7 +11885,7 @@ function readAssemblePlan(planDir, chunkPaths) {
11836
11885
  }
11837
11886
  }
11838
11887
  for (const path of chunkPaths.flat()) {
11839
- if (!existsSync23(path)) {
11888
+ if (!existsSync22(path)) {
11840
11889
  throw new Error(`[assemble] chunk path does not exist: ${path}`);
11841
11890
  }
11842
11891
  }
@@ -11975,7 +12024,7 @@ function planFormat(planDir) {
11975
12024
  }
11976
12025
  function lockedAudio(planDir) {
11977
12026
  const encoderJsonPath = join30(planDir, "meta", "encoder.json");
11978
- if (!existsSync23(encoderJsonPath)) return {};
12027
+ if (!existsSync22(encoderJsonPath)) return {};
11979
12028
  return JSON.parse(readFileSync11(encoderJsonPath, "utf-8"));
11980
12029
  }
11981
12030
  function readCfrEncoder(planDir, format) {
@@ -11985,7 +12034,7 @@ function readCfrEncoder(planDir, format) {
11985
12034
  );
11986
12035
  }
11987
12036
  const encoderJsonPath = join30(planDir, "meta", "encoder.json");
11988
- if (!existsSync23(encoderJsonPath)) {
12037
+ if (!existsSync22(encoderJsonPath)) {
11989
12038
  throw new Error(`[assemble] planDir missing meta/encoder.json: ${encoderJsonPath}`);
11990
12039
  }
11991
12040
  const encoderJson = JSON.parse(readFileSync11(encoderJsonPath, "utf-8"));
@@ -11997,7 +12046,7 @@ function readCfrEncoder(planDir, format) {
11997
12046
  return encoderJson;
11998
12047
  }
11999
12048
  function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, startTimeMs) {
12000
- if (existsSync23(outputPath)) rmSync10(outputPath, { recursive: true, force: true });
12049
+ if (existsSync22(outputPath)) rmSync10(outputPath, { recursive: true, force: true });
12001
12050
  mkdirSync13(outputPath, { recursive: true });
12002
12051
  let globalIdx = 0;
12003
12052
  for (const chunkDir of chunkPaths) {
@@ -12021,7 +12070,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
12021
12070
  `[assemble] png-sequence frame count mismatch: merged ${globalIdx} frames vs plan.totalFrames=${totalFrames}. Using on-disk count.`
12022
12071
  );
12023
12072
  }
12024
- if (audioPath !== null && existsSync23(audioPath)) {
12073
+ if (audioPath !== null && existsSync22(audioPath)) {
12025
12074
  const sidecar = join30(outputPath, MIXED_AUDIO_FILENAME4);
12026
12075
  cpSync3(audioPath, sidecar);
12027
12076
  }
@@ -12042,7 +12091,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
12042
12091
 
12043
12092
  // src/services/distributed/renderChunk.ts
12044
12093
  import { randomBytes } from "node:crypto";
12045
- import { existsSync as existsSync24, mkdirSync as mkdirSync14, readFileSync as readFileSync12, readdirSync as readdirSync9, rmSync as rmSync11, writeFileSync as writeFileSync12 } from "node:fs";
12094
+ import { existsSync as existsSync23, mkdirSync as mkdirSync14, readFileSync as readFileSync12, readdirSync as readdirSync9, rmSync as rmSync11, writeFileSync as writeFileSync12 } from "node:fs";
12046
12095
  import { cpus } from "node:os";
12047
12096
  import { join as join31 } from "node:path";
12048
12097
  import {
@@ -12199,7 +12248,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
12199
12248
  const planJsonPath = join31(planDir, "plan.json");
12200
12249
  const encoderJsonPath = join31(planDir, "meta", "encoder.json");
12201
12250
  const chunksJsonPath = join31(planDir, "meta", "chunks.json");
12202
- if (!existsSync24(planJsonPath)) {
12251
+ if (!existsSync23(planJsonPath)) {
12203
12252
  throw new RenderChunkValidationError(
12204
12253
  MISSING_PLAN_ARTIFACT,
12205
12254
  `[renderChunk] planDir is missing required artifact: ${planJsonPath}`
@@ -12215,7 +12264,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
12215
12264
  const v2Manifest = v2Materialization?.manifest ?? null;
12216
12265
  const remoteSources = v2Materialization?.remoteSources ?? {};
12217
12266
  for (const required of [encoderJsonPath, chunksJsonPath]) {
12218
- if (!existsSync24(required)) {
12267
+ if (!existsSync23(required)) {
12219
12268
  throw new RenderChunkValidationError(
12220
12269
  MISSING_PLAN_ARTIFACT,
12221
12270
  `[renderChunk] planDir is missing required artifact: ${required}`
@@ -12226,7 +12275,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
12226
12275
  const chunks = JSON.parse(readFileSync12(chunksJsonPath, "utf-8"));
12227
12276
  const videosJsonPath = join31(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
12228
12277
  let planVideos = null;
12229
- if (existsSync24(videosJsonPath)) {
12278
+ if (existsSync23(videosJsonPath)) {
12230
12279
  try {
12231
12280
  planVideos = validatePlanVideosForChunk(JSON.parse(readFileSync12(videosJsonPath, "utf-8")));
12232
12281
  } catch (err) {
@@ -12257,7 +12306,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
12257
12306
  const range = resolveChunkFrameRange(slice, chunkIndex, options?.frameRange);
12258
12307
  const framesInChunk = range.endFrame - range.startFrame;
12259
12308
  const compiledDir = join31(planDir, "compiled");
12260
- if (!existsSync24(compiledDir)) {
12309
+ if (!existsSync23(compiledDir)) {
12261
12310
  throw new RenderChunkValidationError(
12262
12311
  MISSING_PLAN_ARTIFACT,
12263
12312
  `[renderChunk] planDir missing compiled/ directory: ${compiledDir}`
@@ -12349,6 +12398,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
12349
12398
  deferredVideos.filter((video) => remoteVideoIds.has(video.videoId))
12350
12399
  )
12351
12400
  });
12401
+ captureOptions.onStaticDedupActivity = () => noteStaticDedupActivity(job);
12352
12402
  const captureFrames = effectiveChunkFrames(framesInChunk, slice.captureCost);
12353
12403
  const chunkWorkerCount = resolveChunkCaptureWorkers(
12354
12404
  captureFrames,
@@ -12508,10 +12558,10 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
12508
12558
  const effectiveBitrate = encoder.crf != null ? void 0 : encoder.bitrate;
12509
12559
  const videoOnlyPath = encoder.chunksCarryAudio ? `${outputChunkPath}.video.mp4` : outputChunkPath;
12510
12560
  if (isPngSequence) {
12511
- if (!existsSync24(outputChunkPath)) mkdirSync14(outputChunkPath, { recursive: true });
12561
+ if (!existsSync23(outputChunkPath)) mkdirSync14(outputChunkPath, { recursive: true });
12512
12562
  } else {
12513
12563
  const outDir = join31(outputChunkPath, "..");
12514
- if (!existsSync24(outDir)) mkdirSync14(outDir, { recursive: true });
12564
+ if (!existsSync23(outDir)) mkdirSync14(outDir, { recursive: true });
12515
12565
  }
12516
12566
  const encodeInput = {
12517
12567
  job,
@@ -13077,7 +13127,7 @@ function validateIntDimension(field, value) {
13077
13127
 
13078
13128
  // src/services/distributed/projectHash.ts
13079
13129
  import { closeSync as closeSync5, openSync as openSync5, readdirSync as readdirSync10, readSync as readSync4, realpathSync as realpathSync2, statSync as statSync9 } from "node:fs";
13080
- import { createHash as createHash8 } from "node:crypto";
13130
+ import { createHash as createHash9 } from "node:crypto";
13081
13131
  import { join as join33 } from "node:path";
13082
13132
  var SITE_ID_SCHEME = "site-v2\0";
13083
13133
  var READ_CHUNK_BYTES = 256 * 1024;
@@ -13114,7 +13164,7 @@ function listSiteFiles(projectDir) {
13114
13164
  return files;
13115
13165
  }
13116
13166
  function hashProjectDir(projectDir, files = listSiteFiles(projectDir)) {
13117
- const hash = createHash8("sha256").update(SITE_ID_SCHEME);
13167
+ const hash = createHash9("sha256").update(SITE_ID_SCHEME);
13118
13168
  const chunk = Buffer.allocUnsafe(READ_CHUNK_BYTES);
13119
13169
  for (const rel of files) {
13120
13170
  hash.update(rel);