@hyperframes/producer 0.9.32 → 0.9.34

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 {
@@ -5211,14 +5254,21 @@ function hasRuntimeMediaChanges(html) {
5211
5254
  }
5212
5255
  return false;
5213
5256
  }
5257
+ function checksVariablesInBrowser(config) {
5258
+ return config.strictVariables === true && Object.keys(config.variables ?? {}).length > 0;
5259
+ }
5260
+ function strictVariablesAttestation(config, probeSession) {
5261
+ if (config.strictVariables !== true) return void 0;
5262
+ return !checksVariablesInBrowser(config) || probeSession?.strictVariablesChecked === true;
5263
+ }
5214
5264
  function probeRequiresBrowser(args) {
5215
- return args.durationSeconds <= 0 || args.unresolvedCompositionCount > 0 || args.hasAutoStart || args.hasScriptedAudio || args.hasVariableMedia || args.hasInsertedMedia;
5265
+ return args.requiresVariablesCheck === true || args.durationSeconds <= 0 || args.unresolvedCompositionCount > 0 || args.hasAutoStart || args.hasScriptedAudio || args.hasVariableMedia || args.hasInsertedMedia;
5216
5266
  }
5217
5267
  function reportedLengthSource(source) {
5218
5268
  if (!source) return null;
5219
5269
  if (source.from !== "media") return { from: source.from };
5220
5270
  const name = basename4(source.src.split(/[?#]/, 1)[0] ?? "");
5221
- const srcHash = createHash5("sha256").update(name).digest("hex").slice(0, 12);
5271
+ const srcHash = createHash6("sha256").update(name).digest("hex").slice(0, 12);
5222
5272
  return { from: "media", tag: source.tag, trimmed: source.trimmed, srcHash };
5223
5273
  }
5224
5274
  async function runProbeStage(input) {
@@ -5236,7 +5286,8 @@ async function runProbeStage(input) {
5236
5286
  height,
5237
5287
  needsAlpha,
5238
5288
  deviceScaleFactor,
5239
- subTimelineWaitMemo
5289
+ subTimelineWaitMemo,
5290
+ staticDedupMemo
5240
5291
  } = input;
5241
5292
  let { compiled } = input;
5242
5293
  const probeCfg = cfg.forceScreenshot === forceScreenshot ? cfg : { ...cfg, forceScreenshot };
@@ -5259,7 +5310,8 @@ async function runProbeStage(input) {
5259
5310
  hasAutoStart,
5260
5311
  hasScriptedAudio,
5261
5312
  hasVariableMedia,
5262
- hasInsertedMedia
5313
+ hasInsertedMedia,
5314
+ requiresVariablesCheck: checksVariablesInBrowser(job.config)
5263
5315
  });
5264
5316
  try {
5265
5317
  if (needsBrowser) {
@@ -5293,11 +5345,16 @@ async function runProbeStage(input) {
5293
5345
  job.config.quality
5294
5346
  ),
5295
5347
  variables: job.config.variables,
5348
+ strictVariables: job.config.strictVariables,
5296
5349
  deviceScaleFactor,
5297
5350
  motionBlur,
5298
5351
  pageMotionBlur: job.config.pageMotionBlur,
5299
5352
  requiresWebGpu: compositionRequiresWebGpu(compiled.html),
5300
- subTimelineWaitMemo
5353
+ subTimelineWaitMemo,
5354
+ staticDedupMemo,
5355
+ compositionHash: computeCompositionObservabilityHash(compiled.html),
5356
+ deferStaticDedup: true,
5357
+ onStaticDedupActivity: () => noteStaticDedupActivity(job)
5301
5358
  };
5302
5359
  const PROBE_MAX_ATTEMPTS = 2;
5303
5360
  for (let attempt = 1; attempt <= PROBE_MAX_ATTEMPTS; attempt++) {
@@ -5694,6 +5751,7 @@ async function runProbeStage(input) {
5694
5751
  }
5695
5752
  }
5696
5753
  return {
5754
+ strictVariablesChecked: strictVariablesAttestation(job.config, probeSession),
5697
5755
  compiled,
5698
5756
  fileServer,
5699
5757
  probeSession,
@@ -5786,7 +5844,7 @@ function validateDistributedDuration(input) {
5786
5844
  }
5787
5845
 
5788
5846
  // src/services/render/stages/extractVideosStage.ts
5789
- import { existsSync as existsSync10 } from "node:fs";
5847
+ import { existsSync as existsSync9 } from "node:fs";
5790
5848
  import { join as join11 } from "node:path";
5791
5849
  import {
5792
5850
  classifyVideoExtractionError,
@@ -6061,7 +6119,7 @@ async function runExtractVideosStage(input) {
6061
6119
  const probeFailures = await Promise.all(
6062
6120
  composition.videos.map(async (v) => {
6063
6121
  const videoPath = resolveProjectRelativeSrc3(v.src, projectDir, compiledDir);
6064
- if (!existsSync10(videoPath)) return null;
6122
+ if (!existsSync9(videoPath)) return null;
6065
6123
  try {
6066
6124
  const attempted = extractionPolicy.maxTransientRetries === 0 ? { result: await extractMediaMetadata3(videoPath), retries: 0 } : await runVideoExtractionWithRetry2(() => extractMediaMetadata3(videoPath), {
6067
6125
  signal: abortSignal,
@@ -6099,7 +6157,7 @@ async function runExtractVideosStage(input) {
6099
6157
  const probed = await Promise.all(
6100
6158
  composition.images.map(async (img) => {
6101
6159
  const imgPath = resolveProjectRelativeSrc3(img.src, projectDir, compiledDir);
6102
- if (!existsSync10(imgPath)) return null;
6160
+ if (!existsSync9(imgPath)) return null;
6103
6161
  const colorSpace = await probeColorSpaceSafely(imgPath, log);
6104
6162
  if (isHdrColorSpace2(colorSpace)) {
6105
6163
  nativeHdrImageIds.add(img.id);
@@ -6219,7 +6277,7 @@ async function appendVideoAudioFromProbe(input) {
6219
6277
  videos.map(async (video) => {
6220
6278
  const path = isHttpUrl2(video.src) ? video.src : resolveProjectRelativeSrc3(video.src, projectDir, compiledDir);
6221
6279
  const readFrom = urlByAbsentLocalPath?.get(path) ?? path;
6222
- if (!isHttpUrl2(readFrom) && !existsSync10(readFrom)) return null;
6280
+ if (!isHttpUrl2(readFrom) && !existsSync9(readFrom)) return null;
6223
6281
  const metadata = await extractMediaMetadata3(readFrom);
6224
6282
  const window2 = await resolveFinalFrameExtractionWindow2(
6225
6283
  readFrom,
@@ -6247,7 +6305,7 @@ import {
6247
6305
  } from "@hyperframes/engine";
6248
6306
 
6249
6307
  // src/services/render/stages/audioStage.ts
6250
- import { existsSync as existsSync12 } from "node:fs";
6308
+ import { existsSync as existsSync11 } from "node:fs";
6251
6309
  import { join as join14 } from "node:path";
6252
6310
  import {
6253
6311
  MIXED_AUDIO_FILENAME,
@@ -6258,7 +6316,7 @@ import {
6258
6316
  } from "@hyperframes/engine";
6259
6317
 
6260
6318
  // src/services/render/audioDeliveryLimit.ts
6261
- import { existsSync as existsSync11 } from "node:fs";
6319
+ import { existsSync as existsSync10 } from "node:fs";
6262
6320
  import { dirname as dirname8, join as join13 } from "node:path";
6263
6321
  import {
6264
6322
  applyAudioFxChain,
@@ -6767,7 +6825,7 @@ async function limitDeliveryPeaks(input, deps = {
6767
6825
  applyChain: applyAudioFxChain,
6768
6826
  encode: encodeAac2,
6769
6827
  rename: renameWithRetry6,
6770
- sourceExists: existsSync11
6828
+ sourceExists: existsSync10
6771
6829
  }) {
6772
6830
  const { audioPath, sourcePath, signal, timeoutMs } = input;
6773
6831
  if (!deps.sourceExists(sourcePath)) return { success: true };
@@ -6862,7 +6920,7 @@ async function runAudioStageScoped(input) {
6862
6920
  );
6863
6921
  audioLoweredDb = guard.loweredDb;
6864
6922
  input.log?.info("[audio] phases", { ...result.audioPhaseMs, guard: Date.now() - guardStart });
6865
- if (input.keepDeliverySource && !guard.sourceStale && existsSync12(pcmSourcePath)) {
6923
+ if (input.keepDeliverySource && !guard.sourceStale && existsSync11(pcmSourcePath)) {
6866
6924
  deliverySourcePath = pcmSourcePath;
6867
6925
  }
6868
6926
  }
@@ -6990,7 +7048,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
6990
7048
  }
6991
7049
 
6992
7050
  // src/services/render/stages/captureStage.ts
6993
- import { existsSync as existsSync13, readdirSync, statfsSync } from "node:fs";
7051
+ import { existsSync as existsSync12, readdirSync, statfsSync } from "node:fs";
6994
7052
  import { join as join15 } from "node:path";
6995
7053
  import {
6996
7054
  classifyCaptureFailure as classifyCaptureFailure2,
@@ -7042,7 +7100,7 @@ function diskCaptureShortfallError(needBytes, freeBytes, framesDir, basis, remed
7042
7100
  }
7043
7101
  function measureCaptureFrameBytes(workDir, framesDir) {
7044
7102
  let total = sampleDirectoryBytes(framesDir);
7045
- if (!existsSync13(workDir)) return total;
7103
+ if (!existsSync12(workDir)) return total;
7046
7104
  for (const attempt of readdirSync(workDir)) {
7047
7105
  if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
7048
7106
  total += sampleDirectoryBytes(join15(workDir, attempt));
@@ -7224,7 +7282,7 @@ async function runSequentialDiskCapture(input, captureOptions, captureCfg, check
7224
7282
  captureBeyondViewport = session.options.captureBeyondViewport;
7225
7283
  try {
7226
7284
  if (probeSession) {
7227
- prepareCaptureSessionForReuse3(session, framesDir, videoInjector);
7285
+ await prepareCaptureSessionForReuse3(session, framesDir, videoInjector);
7228
7286
  probeSession = null;
7229
7287
  }
7230
7288
  await ensureSessionReady(session, {
@@ -7383,7 +7441,7 @@ import {
7383
7441
  // src/services/render/stages/encodeStage.ts
7384
7442
  import {
7385
7443
  copyFileSync as copyFileSync4,
7386
- existsSync as existsSync14,
7444
+ existsSync as existsSync13,
7387
7445
  mkdirSync as mkdirSync5,
7388
7446
  readdirSync as readdirSync2,
7389
7447
  readFileSync as readFileSync6,
@@ -7517,7 +7575,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
7517
7575
  const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
7518
7576
  if (failure) return failure;
7519
7577
  }
7520
- const fileSize = existsSync14(outputPath) ? statSync4(outputPath).size : 0;
7578
+ const fileSize = existsSync13(outputPath) ? statSync4(outputPath).size : 0;
7521
7579
  return {
7522
7580
  success: true,
7523
7581
  outputPath,
@@ -7678,7 +7736,7 @@ async function runEncodeStage(input) {
7678
7736
  const stage5Start = Date.now();
7679
7737
  if (isPngSequence) {
7680
7738
  const encoded = startEncodeProgress(job, "Writing PNG sequence", onProgress);
7681
- if (!existsSync14(outputPath)) mkdirSync5(outputPath, { recursive: true });
7739
+ if (!existsSync13(outputPath)) mkdirSync5(outputPath, { recursive: true });
7682
7740
  const captured = readdirSync2(framesDir).filter((name) => name.endsWith(".png")).sort();
7683
7741
  if (captured.length === 0) {
7684
7742
  throw new Error(
@@ -7689,7 +7747,7 @@ async function runEncodeStage(input) {
7689
7747
  const dst = join16(outputPath, formatExportFrameName(i, "png"));
7690
7748
  copyFileSync4(join16(framesDir, name), dst);
7691
7749
  });
7692
- if (hasAudio && audioOutputPath && existsSync14(audioOutputPath)) {
7750
+ if (hasAudio && audioOutputPath && existsSync13(audioOutputPath)) {
7693
7751
  copyFileSync4(audioOutputPath, join16(outputPath, MIXED_AUDIO_FILENAME2));
7694
7752
  log.info(
7695
7753
  `[Render] png-sequence: ${MIXED_AUDIO_FILENAME2} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME2}`
@@ -7852,7 +7910,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
7852
7910
  let rangeStart = null;
7853
7911
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
7854
7912
  const framePath = join17(framesDir, formatCaptureFrameName(frameIndex, frameExt));
7855
- const missing = !existsSync15(framePath) || statSync5(framePath).size <= 8;
7913
+ const missing = !existsSync14(framePath) || statSync5(framePath).size <= 8;
7856
7914
  if (missing && rangeStart === null) {
7857
7915
  rangeStart = frameIndex;
7858
7916
  } else if (!missing && rangeStart !== null) {
@@ -7935,7 +7993,8 @@ function frameStallRule(job, totalFrames, probeStartupMs) {
7935
7993
  complete: () => (job.framesRendered ?? 0) >= totalFrames,
7936
7994
  tailMs: Math.max(TAIL_STALL_MS, noProgressMs),
7937
7995
  detail: () => describeWorkerPhases(job),
7938
- attemptOpened: () => forgetWorkerPhases(job)
7996
+ attemptOpened: () => forgetWorkerPhases(job),
7997
+ activity: () => staticDedupActivity(job)
7939
7998
  };
7940
7999
  }
7941
8000
  function isRecoverableParallelCaptureError(error) {
@@ -7949,7 +8008,7 @@ function countCapturedFrames(totalFrames, framesDir, frameExt) {
7949
8008
  let captured = 0;
7950
8009
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
7951
8010
  const framePath = join17(framesDir, formatCaptureFrameName(frameIndex, frameExt));
7952
- if (existsSync15(framePath)) captured++;
8011
+ if (existsSync14(framePath)) captured++;
7953
8012
  }
7954
8013
  return captured;
7955
8014
  }
@@ -8176,7 +8235,7 @@ import {
8176
8235
  } from "@hyperframes/engine";
8177
8236
 
8178
8237
  // src/services/distributed/chunkFrames.ts
8179
- import { existsSync as existsSync17, readdirSync as readdirSync4 } from "node:fs";
8238
+ import { existsSync as existsSync16, readdirSync as readdirSync4 } from "node:fs";
8180
8239
  import { extname as extname2, join as join19 } from "node:path";
8181
8240
  import {
8182
8241
  compositionRequiresWebGpu as compositionRequiresWebGpu3,
@@ -8187,7 +8246,7 @@ import {
8187
8246
  // src/services/distributed/shared.ts
8188
8247
  import { execFile as execFileCallback } from "node:child_process";
8189
8248
  import { dirname as dirname11, join as join18 } from "node:path";
8190
- import { existsSync as existsSync16, readFileSync as readFileSync7 } from "node:fs";
8249
+ import { existsSync as existsSync15, readFileSync as readFileSync7 } from "node:fs";
8191
8250
  import { fileURLToPath as fileURLToPath3 } from "node:url";
8192
8251
  import { promisify as promisify2 } from "node:util";
8193
8252
  import {
@@ -8203,7 +8262,7 @@ function isPlanAudioArtifactPath(path) {
8203
8262
  function resolvePlanAudioPath(planDir) {
8204
8263
  for (const name of [PLAN_AUDIO_RELATIVE_PATH, PLAN_AUDIO_LEGACY_RELATIVE_PATH]) {
8205
8264
  const candidate = join18(planDir, name);
8206
- if (existsSync16(candidate)) return candidate;
8265
+ if (existsSync15(candidate)) return candidate;
8207
8266
  }
8208
8267
  return null;
8209
8268
  }
@@ -8453,6 +8512,7 @@ function buildSyntheticRenderJob(input) {
8453
8512
  strictness: input.strictness,
8454
8513
  producerConfig: input.producerConfig,
8455
8514
  variables: input.variables,
8515
+ strictVariables: input.strictVariables,
8456
8516
  pageMotionBlur: input.pageMotionBlur
8457
8517
  };
8458
8518
  return createRenderJob(renderConfig);
@@ -8464,7 +8524,7 @@ function readProducerVersion() {
8464
8524
  let current = startDir;
8465
8525
  for (let i = 0; i < 10; i++) {
8466
8526
  const candidate = join18(current, "package.json");
8467
- if (existsSync16(candidate)) {
8527
+ if (existsSync15(candidate)) {
8468
8528
  try {
8469
8529
  const pkg = JSON.parse(readFileSync7(candidate, "utf-8"));
8470
8530
  if (pkg.name === "@hyperframes/producer" && typeof pkg.version === "string") {
@@ -8519,7 +8579,7 @@ function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v
8519
8579
  const result = [];
8520
8580
  for (const v of videos) {
8521
8581
  const outputDir = join19(planDir, "video-frames", mediaIdPathSegment3(v.videoId));
8522
- if (!existsSync17(outputDir)) {
8582
+ if (!existsSync16(outputDir)) {
8523
8583
  throw new Error(
8524
8584
  `[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
8585
  );
@@ -8618,7 +8678,7 @@ async function extractDeferredVideoFramesForChunk(input) {
8618
8678
  const range = planned.get(video.videoId).deferredRange;
8619
8679
  const remoteUrl = remoteSources[range.sourcePath];
8620
8680
  const sourcePath = remoteUrl ?? join19(input.planDir, ...range.sourcePath.split("/"));
8621
- if (remoteUrl === void 0 && !existsSync17(sourcePath)) {
8681
+ if (remoteUrl === void 0 && !existsSync16(sourcePath)) {
8622
8682
  throw new RenderChunkValidationError(
8623
8683
  MISSING_PLAN_ARTIFACT,
8624
8684
  `[renderChunk] planDir is missing the source for video ${JSON.stringify(video.videoId)}: ${range.sourcePath}`
@@ -8818,7 +8878,7 @@ async function readPlanReferenceBackground(input) {
8818
8878
  }
8819
8879
 
8820
8880
  // 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";
8881
+ import { existsSync as existsSync17, mkdirSync as mkdirSync7, readFileSync as readFileSync8, readdirSync as readdirSync5, writeFileSync as writeFileSync6 } from "node:fs";
8822
8882
  import { join as join22, relative as relative3, resolve as resolve8 } from "node:path";
8823
8883
  import {
8824
8884
  REFERENCE_BACKGROUND_FIELD,
@@ -8917,12 +8977,12 @@ function readPlanProtocolV1(planJson, capabilities = DISTRIBUTED_RENDER_CAPABILI
8917
8977
  }
8918
8978
 
8919
8979
  // src/services/render/stages/planHash.ts
8920
- import { createHash as createHash6 } from "node:crypto";
8980
+ import { createHash as createHash7 } from "node:crypto";
8921
8981
  import { closeSync as closeSync3, createReadStream as createReadStream3, openSync as openSync3, readSync as readSync2 } from "node:fs";
8922
8982
  var PLAN_HASH_SCHEMA_PREFIX = "hyperframes-plan-hash-v1\0";
8923
8983
  var FIELD_DELIMITER = Buffer.from([0]);
8924
8984
  function computePlanHash(input) {
8925
- const hash = createHash6("sha256");
8985
+ const hash = createHash7("sha256");
8926
8986
  hash.update(PLAN_HASH_SCHEMA_PREFIX, "utf8");
8927
8987
  hash.update(input.compositionHtml);
8928
8988
  hash.update(FIELD_DELIMITER);
@@ -8969,12 +9029,12 @@ function canonicalJsonStringify(value) {
8969
9029
  throw new TypeError(`canonicalJsonStringify: unsupported value type ${typeof value}`);
8970
9030
  }
8971
9031
  function sha256Hex(bytes) {
8972
- const h = createHash6("sha256");
9032
+ const h = createHash7("sha256");
8973
9033
  h.update(bytes);
8974
9034
  return h.digest("hex");
8975
9035
  }
8976
9036
  function sha256File(path) {
8977
- const hash = createHash6("sha256");
9037
+ const hash = createHash7("sha256");
8978
9038
  const buffer = Buffer.allocUnsafe(1024 * 1024);
8979
9039
  const fd = openSync3(path, "r");
8980
9040
  try {
@@ -8989,7 +9049,7 @@ function sha256File(path) {
8989
9049
  return hash.digest("hex");
8990
9050
  }
8991
9051
  async function sha256FileAsync(path) {
8992
- const hash = createHash6("sha256");
9052
+ const hash = createHash7("sha256");
8993
9053
  for await (const chunk of createReadStream3(path, { highWaterMark: 1024 * 1024 })) {
8994
9054
  hash.update(chunk);
8995
9055
  }
@@ -9012,7 +9072,7 @@ function planFileSha256(absolutePath, digests) {
9012
9072
  return sha256;
9013
9073
  }
9014
9074
  async function prehashPlanFiles(dir, digests) {
9015
- if (!existsSync18(dir)) return;
9075
+ if (!existsSync17(dir)) return;
9016
9076
  for (const { absolutePath } of listPlanFiles(dir)) {
9017
9077
  if (!digests.has(absolutePath)) digests.set(absolutePath, await sha256FileAsync(absolutePath));
9018
9078
  }
@@ -9082,15 +9142,15 @@ function writePlanRemoteFiles(planDir, files) {
9082
9142
  }
9083
9143
  function readPlanRemoteFiles(planDir) {
9084
9144
  const path = join22(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH);
9085
- return existsSync18(path) ? JSON.parse(readFileSync8(path, "utf-8")) : [];
9145
+ return existsSync17(path) ? JSON.parse(readFileSync8(path, "utf-8")) : [];
9086
9146
  }
9087
9147
  function recomputePlanHashFromPlanDir(planDir, digests) {
9088
9148
  const planJsonPath = join22(planDir, "plan.json");
9089
9149
  const encoderJsonPath = join22(planDir, "meta", "encoder.json");
9090
- if (!existsSync18(planJsonPath)) {
9150
+ if (!existsSync17(planJsonPath)) {
9091
9151
  throw new Error(`[freezePlan] plan.json missing: ${planJsonPath}`);
9092
9152
  }
9093
- if (!existsSync18(encoderJsonPath)) {
9153
+ if (!existsSync17(encoderJsonPath)) {
9094
9154
  throw new Error(`[freezePlan] meta/encoder.json missing: ${encoderJsonPath}`);
9095
9155
  }
9096
9156
  const planJson = JSON.parse(readFileSync8(planJsonPath, "utf-8"));
@@ -9120,11 +9180,11 @@ async function freezePlan(input) {
9120
9180
  hasAudio,
9121
9181
  digests
9122
9182
  } = input;
9123
- if (!existsSync18(planDir)) {
9183
+ if (!existsSync17(planDir)) {
9124
9184
  throw new Error(`[freezePlan] planDir does not exist: ${planDir}`);
9125
9185
  }
9126
9186
  const metaDir = join22(planDir, "meta");
9127
- if (!existsSync18(metaDir)) mkdirSync7(metaDir, { recursive: true });
9187
+ if (!existsSync17(metaDir)) mkdirSync7(metaDir, { recursive: true });
9128
9188
  writeFileSync6(
9129
9189
  join22(metaDir, "composition.json"),
9130
9190
  `${JSON.stringify(composition, null, 2)}
@@ -9201,7 +9261,7 @@ function applyRuntimeEnvSnapshot(snapshot, env = process.env) {
9201
9261
  }
9202
9262
 
9203
9263
  // 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";
9264
+ import { closeSync as closeSync4, existsSync as existsSync18, ftruncateSync, mkdirSync as mkdirSync9, openSync as openSync4, readFileSync as readFileSync9 } from "node:fs";
9205
9265
  import { writeFileSync as writeFileSync7, writeSync } from "node:fs";
9206
9266
  import { join as join24 } from "node:path";
9207
9267
  import { appendRenderProvenanceArgs, describeFfmpegFailure as describeFfmpegFailure4, runFfmpeg as runFfmpeg7 } from "@hyperframes/engine";
@@ -9693,7 +9753,7 @@ async function writeChunkAudioSlices(input) {
9693
9753
  }
9694
9754
  function chunkAudioSource(planDir, chunkIndex, scratchPath) {
9695
9755
  const layoutPath = join24(planDir, SLICE_LAYOUT);
9696
- if (!existsSync19(layoutPath)) return resolvePlanAudioPath(planDir);
9756
+ if (!existsSync18(layoutPath)) return resolvePlanAudioPath(planDir);
9697
9757
  const layout = JSON.parse(readFileSync9(layoutPath, "utf-8"));
9698
9758
  const frame = readFileSync9(join24(planDir, SLICE_FRAME));
9699
9759
  const fd = openSync4(scratchPath, "w");
@@ -9762,7 +9822,7 @@ async function muxChunkWithAudio(input) {
9762
9822
  }
9763
9823
 
9764
9824
  // src/services/distributed/planSize.ts
9765
- import { createHash as createHash7 } from "node:crypto";
9825
+ import { createHash as createHash8 } from "node:crypto";
9766
9826
  import { lstatSync, readdirSync as readdirSync6 } from "node:fs";
9767
9827
  import { extname as extname3, join as join25, relative as relative4 } from "node:path";
9768
9828
  var MAX_TOP_COMPONENTS = 10;
@@ -9792,7 +9852,7 @@ var PLAN_ROOT_CATEGORY = {
9792
9852
  "plan.json": "metadata"
9793
9853
  };
9794
9854
  function hashComponent(value) {
9795
- return createHash7("sha256").update(value).digest("hex").slice(0, 12);
9855
+ return createHash8("sha256").update(value).digest("hex").slice(0, 12);
9796
9856
  }
9797
9857
  function classifyFile(segments, rootKind) {
9798
9858
  const rootName = segments[0] ?? "";
@@ -10261,7 +10321,7 @@ function createVideoSourceShipper(input) {
10261
10321
  let result = null;
10262
10322
  for (const root of stagedRel === null ? [input.workCompiledDir, input.projectDir] : []) {
10263
10323
  const rel = pathInside(root, srcPath);
10264
- if (rel !== null && (existsSync20(join26(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
10324
+ if (rel !== null && (existsSync19(join26(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
10265
10325
  result = ["compiled", ...rel.split(sep3)].join("/");
10266
10326
  break;
10267
10327
  }
@@ -10289,7 +10349,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
10289
10349
  useGpu: false,
10290
10350
  browserGpuMode: "software"
10291
10351
  });
10292
- if (!existsSync20(planDir)) mkdirSync10(planDir, { recursive: true });
10352
+ if (!existsSync19(planDir)) mkdirSync10(planDir, { recursive: true });
10293
10353
  const log = config.logger ?? defaultLogger;
10294
10354
  const sizeLimitBytes = options.executionPlanSizeLimitBytes ?? config.planDirSizeLimitBytes ?? PLAN_DIR_SIZE_LIMIT_BYTES;
10295
10355
  const abortSignal = config.abortSignal;
@@ -10316,11 +10376,12 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
10316
10376
  logger: config.logger,
10317
10377
  producerConfig: cfg,
10318
10378
  variables: config.variables,
10379
+ strictVariables: config.strictVariables,
10319
10380
  pageMotionBlur: config.pageMotionBlur
10320
10381
  });
10321
10382
  const entryFile = config.entryFile ?? "index.html";
10322
10383
  const htmlPath = join26(projectDir, entryFile);
10323
- if (!existsSync20(htmlPath)) {
10384
+ if (!existsSync19(htmlPath)) {
10324
10385
  throw new Error(`[plan] entry file not found: ${htmlPath}`);
10325
10386
  }
10326
10387
  const workDir = join26(planDir, ".plan-work");
@@ -10428,6 +10489,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
10428
10489
  logPlanStage(log, "reference_background", stageStarted);
10429
10490
  }
10430
10491
  compiled = probeResult.compiled;
10492
+ job.strictVariablesChecked = probeResult.strictVariablesChecked;
10431
10493
  job.duration = probeResult.duration;
10432
10494
  job.totalFrames = probeResult.totalFrames;
10433
10495
  const totalFrames = probeResult.totalFrames;
@@ -10548,15 +10610,15 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
10548
10610
  logPlanStage(log, "extract", stageStarted);
10549
10611
  const stagedVideoFrames = join26(compiledDir, "__hyperframes_video_frames");
10550
10612
  const videoFramesDst = join26(planDir, "video-frames");
10551
- if (existsSync20(videoFramesDst)) rmSync7(videoFramesDst, { recursive: true, force: true });
10613
+ if (existsSync19(videoFramesDst)) rmSync7(videoFramesDst, { recursive: true, force: true });
10552
10614
  const videoSourcesDir = join26(planDir, "video-sources");
10553
10615
  rmSync7(videoSourcesDir, { recursive: true, force: true });
10554
- if (existsSync20(stagedVideoFrames)) {
10616
+ if (existsSync19(stagedVideoFrames)) {
10555
10617
  renameWithRetry8(stagedVideoFrames, videoFramesDst);
10556
10618
  } else {
10557
10619
  mkdirSync10(videoFramesDst, { recursive: true });
10558
10620
  }
10559
- if (existsSync20(finalCompiledDir)) rmSync7(finalCompiledDir, { recursive: true, force: true });
10621
+ if (existsSync19(finalCompiledDir)) rmSync7(finalCompiledDir, { recursive: true, force: true });
10560
10622
  renameWithRetry8(compiledDir, finalCompiledDir);
10561
10623
  const shipVideoSource = createVideoSourceShipper({
10562
10624
  planDir,
@@ -10677,10 +10739,10 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
10677
10739
  applyDistributedAudioWarningPolicy(job, audioResult.audioError, audioResult.audioFailures, log);
10678
10740
  }
10679
10741
  const planAudioPath = join26(planDir, PLAN_AUDIO_RELATIVE_PATH);
10680
- if (audioResult?.hasAudio && existsSync20(audioResult.audioOutputPath)) {
10742
+ if (audioResult?.hasAudio && existsSync19(audioResult.audioOutputPath)) {
10681
10743
  renameWithRetry8(audioResult.audioOutputPath, planAudioPath);
10682
10744
  }
10683
- if (chunksCarryAudio && existsSync20(planAudioPath)) {
10745
+ if (chunksCarryAudio && existsSync19(planAudioPath)) {
10684
10746
  if (options.sliceChunkAudio) {
10685
10747
  stageStarted = Date.now();
10686
10748
  await writeChunkAudioSlices({
@@ -10775,7 +10837,8 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
10775
10837
  height,
10776
10838
  format: config.format,
10777
10839
  ffmpegVersion,
10778
- producerVersion
10840
+ producerVersion,
10841
+ ...job.strictVariablesChecked === void 0 ? {} : { strictVariablesChecked: job.strictVariablesChecked }
10779
10842
  };
10780
10843
  }
10781
10844
  async function buildPlanAudio(projectDir, config, workRoot, outputPath, options = {}) {
@@ -10793,7 +10856,7 @@ async function buildPlanAudio(projectDir, config, workRoot, outputPath, options
10793
10856
  if (mixed.audioError) {
10794
10857
  applyDistributedAudioWarningPolicy(c.job, mixed.audioError, mixed.audioFailures, c.log);
10795
10858
  }
10796
- if (!mixed.hasAudio || !existsSync20(mixed.audioOutputPath)) return { hasAudio: false };
10859
+ if (!mixed.hasAudio || !existsSync19(mixed.audioOutputPath)) return { hasAudio: false };
10797
10860
  renameWithRetry8(mixed.audioOutputPath, outputPath);
10798
10861
  return { hasAudio: true };
10799
10862
  } finally {
@@ -10808,7 +10871,7 @@ import {
10808
10871
  } from "@hyperframes/engine";
10809
10872
  import {
10810
10873
  copyFileSync as copyFileSync8,
10811
- existsSync as existsSync22,
10874
+ existsSync as existsSync21,
10812
10875
  lstatSync as lstatSync2,
10813
10876
  mkdirSync as mkdirSync12,
10814
10877
  readFileSync as readFileSync10,
@@ -10829,7 +10892,7 @@ import {
10829
10892
  // src/services/distributed/planV2Publisher.ts
10830
10893
  import {
10831
10894
  copyFileSync as copyFileSync7,
10832
- existsSync as existsSync21,
10895
+ existsSync as existsSync20,
10833
10896
  linkSync as linkSync2,
10834
10897
  mkdirSync as mkdirSync11,
10835
10898
  rmSync as rmSync8,
@@ -10898,7 +10961,7 @@ var LocalPlanV2ArtifactPublisher = class {
10898
10961
  #linkFile;
10899
10962
  #committed = false;
10900
10963
  constructor(destinationDir, options = {}) {
10901
- if (existsSync21(destinationDir)) {
10964
+ if (existsSync20(destinationDir)) {
10902
10965
  throw new PlanV2IntegrityError(`output directory already exists: ${destinationDir}`);
10903
10966
  }
10904
10967
  this.destinationDir = destinationDir;
@@ -10915,7 +10978,7 @@ var LocalPlanV2ArtifactPublisher = class {
10915
10978
  );
10916
10979
  }
10917
10980
  const destinationPath = planV2BlobPath(this.temporaryDir, digest);
10918
- if (existsSync21(destinationPath)) return;
10981
+ if (existsSync20(destinationPath)) return;
10919
10982
  mkdirSync11(dirname13(destinationPath), { recursive: true });
10920
10983
  const stagingDir = createStagingDir5(dirname13(destinationPath), ".plan-v2-blob-");
10921
10984
  const temporaryPath = join28(stagingDir, "blob");
@@ -10933,7 +10996,7 @@ var LocalPlanV2ArtifactPublisher = class {
10933
10996
  }
10934
10997
  async commitManifest(manifestBytes) {
10935
10998
  for (const digest of new Set(manifestDigests(manifestBytes))) {
10936
- if (!existsSync21(planV2BlobPath(this.temporaryDir, digest))) {
10999
+ if (!existsSync20(planV2BlobPath(this.temporaryDir, digest))) {
10937
11000
  throw new PlanV2IntegrityError(
10938
11001
  `cannot commit manifest before referenced blob is durable: ${digest}`
10939
11002
  );
@@ -11013,7 +11076,7 @@ function assertValidExtractionCacheCompleteSentinel(path) {
11013
11076
  }
11014
11077
  function validateExtractionCacheCompleteSentinels(executionPlanDir) {
11015
11078
  const videoRoot = join29(executionPlanDir, "video-frames");
11016
- if (!existsSync22(videoRoot)) return;
11079
+ if (!existsSync21(videoRoot)) return;
11017
11080
  for (const videoEntry of readdirSync7(videoRoot, { withFileTypes: true })) {
11018
11081
  if (!videoEntry.isDirectory()) continue;
11019
11082
  const videoDir = join29(videoRoot, videoEntry.name);
@@ -11114,7 +11177,7 @@ function parsePlanVideosJson2(value) {
11114
11177
  }
11115
11178
  function materializeExtractedVideoDirectories(planDir) {
11116
11179
  const videosPath = join29(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
11117
- if (!existsSync22(videosPath)) return;
11180
+ if (!existsSync21(videosPath)) return;
11118
11181
  const videos = parsePlanVideosJson2(readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH));
11119
11182
  for (const video of videos.extracted) {
11120
11183
  mkdirSync12(resolveExtractedVideoOutputDir(planDir, video.videoId), { recursive: true });
@@ -11148,9 +11211,9 @@ function parseChunkSlices(value) {
11148
11211
  }
11149
11212
  function buildVideoChunkDependencies(executionPlanDir, dimensions) {
11150
11213
  const videoRoot = join29(executionPlanDir, "video-frames");
11151
- const hasExtractedFrames = existsSync22(videoRoot) && listFiles(videoRoot).length > 0;
11214
+ const hasExtractedFrames = existsSync21(videoRoot) && listFiles(videoRoot).length > 0;
11152
11215
  const videosPath = join29(executionPlanDir, PLAN_VIDEOS_META_RELATIVE_PATH);
11153
- if (!existsSync22(videosPath)) {
11216
+ if (!existsSync21(videosPath)) {
11154
11217
  return hasExtractedFrames ? { mode: "full-source-pack", dependencies: null } : { mode: "exact-rendered-frames", dependencies: /* @__PURE__ */ new Map() };
11155
11218
  }
11156
11219
  const chunksPath = join29(executionPlanDir, "meta", "chunks.json");
@@ -11207,7 +11270,7 @@ function computeManifestHash(manifest) {
11207
11270
  return sha256Hex(`${PLAN_V2_HASH_PREFIX}${canonicalJsonStringify(manifestPayload(manifest))}`);
11208
11271
  }
11209
11272
  function writeBlob(sourcePath, destinationPath) {
11210
- if (existsSync22(destinationPath)) return;
11273
+ if (existsSync21(destinationPath)) return;
11211
11274
  mkdirSync12(dirname14(destinationPath), { recursive: true });
11212
11275
  const temporaryDir = createStagingDir6(dirname14(destinationPath), ".plan-v2-blob-");
11213
11276
  const temporaryPath = join29(temporaryDir, "blob");
@@ -11247,7 +11310,7 @@ async function putTasks(tasks) {
11247
11310
  }
11248
11311
  function buildPlanV2Publication(executionPlanDir, digests) {
11249
11312
  const executionPlanPath = join29(executionPlanDir, "plan.json");
11250
- if (!existsSync22(executionPlanPath)) {
11313
+ if (!existsSync21(executionPlanPath)) {
11251
11314
  throw new PlanV2IntegrityError(`execution plan is missing plan.json: ${executionPlanPath}`);
11252
11315
  }
11253
11316
  const executionPlanValue = readJsonFile(executionPlanPath, "execution plan.json");
@@ -11327,7 +11390,7 @@ function buildPlanV2Publication(executionPlanDir, digests) {
11327
11390
  };
11328
11391
  }
11329
11392
  function createPlanV2FromExecutionPlan(executionPlanDir, planV2Dir) {
11330
- if (existsSync22(planV2Dir)) {
11393
+ if (existsSync21(planV2Dir)) {
11331
11394
  throw new PlanV2IntegrityError(`output directory already exists: ${planV2Dir}`);
11332
11395
  }
11333
11396
  const publication = buildPlanV2Publication(executionPlanDir);
@@ -11385,7 +11448,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
11385
11448
  const stagingRoot = createStagingDir6(options.stagingParentDir ?? tmpdir(), ".execution-plan-");
11386
11449
  const digests = /* @__PURE__ */ new Map();
11387
11450
  try {
11388
- await buildLocalExecutionPlan(projectDir, config, stagingRoot, {
11451
+ const planned = await buildLocalExecutionPlan(projectDir, config, stagingRoot, {
11389
11452
  executionPlanSizeLimitBytes: Number.MAX_SAFE_INTEGER,
11390
11453
  deferVideoExtraction: true,
11391
11454
  remoteFiles: options.remoteFiles,
@@ -11401,6 +11464,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
11401
11464
  sliceChunkAudio: true,
11402
11465
  deferAudio: options.deferAudio
11403
11466
  });
11467
+ options.onPlanned?.({ strictVariablesChecked: planned.strictVariablesChecked });
11404
11468
  return await publishExecutionPlan(stagingRoot, publisher, { digests, log: config.logger });
11405
11469
  } catch (error) {
11406
11470
  try {
@@ -11413,7 +11477,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
11413
11477
  }
11414
11478
  }
11415
11479
  async function planV2(projectDir, config, planV2Dir) {
11416
- if (existsSync22(planV2Dir)) {
11480
+ if (existsSync21(planV2Dir)) {
11417
11481
  throw new PlanV2IntegrityError(`output directory already exists: ${planV2Dir}`);
11418
11482
  }
11419
11483
  const publisher = new LocalPlanV2ArtifactPublisher(planV2Dir);
@@ -11567,7 +11631,7 @@ function parsePlanV2Manifest(value) {
11567
11631
  }
11568
11632
  function readPlanV2Manifest(planV2Dir) {
11569
11633
  const manifestPath = join29(planV2Dir, "plan.json");
11570
- if (!existsSync22(manifestPath)) {
11634
+ if (!existsSync21(manifestPath)) {
11571
11635
  throw new PlanV2IntegrityError(`missing v2 manifest: ${manifestPath}`);
11572
11636
  }
11573
11637
  const value = readJsonFile(manifestPath, "v2 manifest");
@@ -11586,7 +11650,7 @@ function listPlanV2ArtifactsForTarget(manifest, target) {
11586
11650
  }
11587
11651
  function verifyBlob(planV2Dir, artifact) {
11588
11652
  const sourcePath = planV2BlobPath(planV2Dir, artifact.sha256);
11589
- if (!existsSync22(sourcePath)) {
11653
+ if (!existsSync21(sourcePath)) {
11590
11654
  throw new PlanV2IntegrityError(`missing content-addressed artifact ${artifact.sha256}`);
11591
11655
  }
11592
11656
  const stats = statSync7(sourcePath);
@@ -11599,7 +11663,7 @@ function verifyBlob(planV2Dir, artifact) {
11599
11663
  return sourcePath;
11600
11664
  }
11601
11665
  function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}) {
11602
- if (existsSync22(destinationDir)) {
11666
+ if (existsSync21(destinationDir)) {
11603
11667
  throw new PlanV2IntegrityError(`materialization destination already exists: ${destinationDir}`);
11604
11668
  }
11605
11669
  const manifest = readPlanV2Manifest(planV2Dir);
@@ -11664,7 +11728,7 @@ function validatePlanV2MaterializedTarget(planDir, expectedTarget) {
11664
11728
  }
11665
11729
  function readValidatedPlanV2Materialization(planDir, expectedTarget) {
11666
11730
  const markerPath = join29(planDir, PLAN_V2_MATERIALIZATION_MARKER);
11667
- if (!existsSync22(markerPath)) return null;
11731
+ if (!existsSync21(markerPath)) return null;
11668
11732
  const marker = readJsonFile(markerPath, "materialization marker");
11669
11733
  if (!isRecord3(marker) || !isRecord3(marker.manifest) || !isRecord3(marker.target)) {
11670
11734
  throw new PlanV2IntegrityError("malformed materialization marker");
@@ -11682,7 +11746,7 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
11682
11746
  for (const artifact of required) {
11683
11747
  if (Object.hasOwn(remoteSources, artifact.path)) continue;
11684
11748
  const path = join29(planDir, ...artifact.path.split("/"));
11685
- if (!existsSync22(path) || statSync7(path).size !== artifact.sizeBytes) {
11749
+ if (!existsSync21(path) || statSync7(path).size !== artifact.sizeBytes) {
11686
11750
  throw new PlanV2IntegrityError(
11687
11751
  `materialized artifact missing or truncated: ${artifact.path}`
11688
11752
  );
@@ -11706,7 +11770,7 @@ import {
11706
11770
  } from "@hyperframes/engine";
11707
11771
  import {
11708
11772
  cpSync as cpSync3,
11709
- existsSync as existsSync23,
11773
+ existsSync as existsSync22,
11710
11774
  mkdirSync as mkdirSync13,
11711
11775
  readFileSync as readFileSync11,
11712
11776
  readdirSync as readdirSync8,
@@ -11761,7 +11825,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
11761
11825
  }
11762
11826
  const format = plan.dimensions.format;
11763
11827
  const cfrEncoder = cfr ? readCfrEncoder(planDir, format) : null;
11764
- if (!existsSync23(dirname15(outputPath))) {
11828
+ if (!existsSync22(dirname15(outputPath))) {
11765
11829
  mkdirSync13(dirname15(outputPath), { recursive: true });
11766
11830
  }
11767
11831
  const workDir = createStagingDir7(dirname15(outputPath), `${basename6(outputPath)}.assemble-work-`);
@@ -11785,7 +11849,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
11785
11849
  try {
11786
11850
  const videoSources = cfrEncoder ? [await reencodeCfr(ctx, chunkPaths, cfrEncoder)] : chunkPaths;
11787
11851
  const finalPath = join30(workDir, `output.${format}`);
11788
- const audio = audioPath !== null && existsSync23(audioPath) ? audioPath : null;
11852
+ const audio = audioPath !== null && existsSync22(audioPath) ? audioPath : null;
11789
11853
  await writeJoined(ctx, videoSources, audio, finalPath);
11790
11854
  renameWithRetry11(finalPath, outputPath);
11791
11855
  log.info("[assemble] stage timings", {
@@ -11803,7 +11867,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
11803
11867
  });
11804
11868
  }
11805
11869
  }
11806
- const fileSize = existsSync23(outputPath) ? statSync8(outputPath).size : 0;
11870
+ const fileSize = existsSync22(outputPath) ? statSync8(outputPath).size : 0;
11807
11871
  return {
11808
11872
  ...referenceBackgroundResult6(plan[REFERENCE_BACKGROUND_FIELD4]),
11809
11873
  outputPath,
@@ -11815,13 +11879,13 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
11815
11879
  function readAssemblePlan(planDir, chunkPaths) {
11816
11880
  const planJsonPath = join30(planDir, "plan.json");
11817
11881
  const chunksJsonPath = join30(planDir, "meta", "chunks.json");
11818
- if (!existsSync23(planJsonPath)) {
11882
+ if (!existsSync22(planJsonPath)) {
11819
11883
  throw new Error(`[assemble] planDir missing plan.json: ${planJsonPath}`);
11820
11884
  }
11821
11885
  const plan = JSON.parse(readFileSync11(planJsonPath, "utf-8"));
11822
11886
  readPlanProtocolV1(plan, DISTRIBUTED_RENDER_CAPABILITIES.roles.assembler);
11823
11887
  validatePlanV2MaterializedTarget(planDir, { role: "assembler" });
11824
- if (!existsSync23(chunksJsonPath)) {
11888
+ if (!existsSync22(chunksJsonPath)) {
11825
11889
  throw new Error(`[assemble] planDir missing meta/chunks.json: ${chunksJsonPath}`);
11826
11890
  }
11827
11891
  const chunks = JSON.parse(readFileSync11(chunksJsonPath, "utf-8"));
@@ -11836,7 +11900,7 @@ function readAssemblePlan(planDir, chunkPaths) {
11836
11900
  }
11837
11901
  }
11838
11902
  for (const path of chunkPaths.flat()) {
11839
- if (!existsSync23(path)) {
11903
+ if (!existsSync22(path)) {
11840
11904
  throw new Error(`[assemble] chunk path does not exist: ${path}`);
11841
11905
  }
11842
11906
  }
@@ -11975,7 +12039,7 @@ function planFormat(planDir) {
11975
12039
  }
11976
12040
  function lockedAudio(planDir) {
11977
12041
  const encoderJsonPath = join30(planDir, "meta", "encoder.json");
11978
- if (!existsSync23(encoderJsonPath)) return {};
12042
+ if (!existsSync22(encoderJsonPath)) return {};
11979
12043
  return JSON.parse(readFileSync11(encoderJsonPath, "utf-8"));
11980
12044
  }
11981
12045
  function readCfrEncoder(planDir, format) {
@@ -11985,7 +12049,7 @@ function readCfrEncoder(planDir, format) {
11985
12049
  );
11986
12050
  }
11987
12051
  const encoderJsonPath = join30(planDir, "meta", "encoder.json");
11988
- if (!existsSync23(encoderJsonPath)) {
12052
+ if (!existsSync22(encoderJsonPath)) {
11989
12053
  throw new Error(`[assemble] planDir missing meta/encoder.json: ${encoderJsonPath}`);
11990
12054
  }
11991
12055
  const encoderJson = JSON.parse(readFileSync11(encoderJsonPath, "utf-8"));
@@ -11997,7 +12061,7 @@ function readCfrEncoder(planDir, format) {
11997
12061
  return encoderJson;
11998
12062
  }
11999
12063
  function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, startTimeMs) {
12000
- if (existsSync23(outputPath)) rmSync10(outputPath, { recursive: true, force: true });
12064
+ if (existsSync22(outputPath)) rmSync10(outputPath, { recursive: true, force: true });
12001
12065
  mkdirSync13(outputPath, { recursive: true });
12002
12066
  let globalIdx = 0;
12003
12067
  for (const chunkDir of chunkPaths) {
@@ -12021,7 +12085,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
12021
12085
  `[assemble] png-sequence frame count mismatch: merged ${globalIdx} frames vs plan.totalFrames=${totalFrames}. Using on-disk count.`
12022
12086
  );
12023
12087
  }
12024
- if (audioPath !== null && existsSync23(audioPath)) {
12088
+ if (audioPath !== null && existsSync22(audioPath)) {
12025
12089
  const sidecar = join30(outputPath, MIXED_AUDIO_FILENAME4);
12026
12090
  cpSync3(audioPath, sidecar);
12027
12091
  }
@@ -12042,7 +12106,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
12042
12106
 
12043
12107
  // src/services/distributed/renderChunk.ts
12044
12108
  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";
12109
+ import { existsSync as existsSync23, mkdirSync as mkdirSync14, readFileSync as readFileSync12, readdirSync as readdirSync9, rmSync as rmSync11, writeFileSync as writeFileSync12 } from "node:fs";
12046
12110
  import { cpus } from "node:os";
12047
12111
  import { join as join31 } from "node:path";
12048
12112
  import {
@@ -12199,7 +12263,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
12199
12263
  const planJsonPath = join31(planDir, "plan.json");
12200
12264
  const encoderJsonPath = join31(planDir, "meta", "encoder.json");
12201
12265
  const chunksJsonPath = join31(planDir, "meta", "chunks.json");
12202
- if (!existsSync24(planJsonPath)) {
12266
+ if (!existsSync23(planJsonPath)) {
12203
12267
  throw new RenderChunkValidationError(
12204
12268
  MISSING_PLAN_ARTIFACT,
12205
12269
  `[renderChunk] planDir is missing required artifact: ${planJsonPath}`
@@ -12215,7 +12279,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
12215
12279
  const v2Manifest = v2Materialization?.manifest ?? null;
12216
12280
  const remoteSources = v2Materialization?.remoteSources ?? {};
12217
12281
  for (const required of [encoderJsonPath, chunksJsonPath]) {
12218
- if (!existsSync24(required)) {
12282
+ if (!existsSync23(required)) {
12219
12283
  throw new RenderChunkValidationError(
12220
12284
  MISSING_PLAN_ARTIFACT,
12221
12285
  `[renderChunk] planDir is missing required artifact: ${required}`
@@ -12226,7 +12290,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
12226
12290
  const chunks = JSON.parse(readFileSync12(chunksJsonPath, "utf-8"));
12227
12291
  const videosJsonPath = join31(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
12228
12292
  let planVideos = null;
12229
- if (existsSync24(videosJsonPath)) {
12293
+ if (existsSync23(videosJsonPath)) {
12230
12294
  try {
12231
12295
  planVideos = validatePlanVideosForChunk(JSON.parse(readFileSync12(videosJsonPath, "utf-8")));
12232
12296
  } catch (err) {
@@ -12257,7 +12321,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
12257
12321
  const range = resolveChunkFrameRange(slice, chunkIndex, options?.frameRange);
12258
12322
  const framesInChunk = range.endFrame - range.startFrame;
12259
12323
  const compiledDir = join31(planDir, "compiled");
12260
- if (!existsSync24(compiledDir)) {
12324
+ if (!existsSync23(compiledDir)) {
12261
12325
  throw new RenderChunkValidationError(
12262
12326
  MISSING_PLAN_ARTIFACT,
12263
12327
  `[renderChunk] planDir missing compiled/ directory: ${compiledDir}`
@@ -12349,6 +12413,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
12349
12413
  deferredVideos.filter((video) => remoteVideoIds.has(video.videoId))
12350
12414
  )
12351
12415
  });
12416
+ captureOptions.onStaticDedupActivity = () => noteStaticDedupActivity(job);
12352
12417
  const captureFrames = effectiveChunkFrames(framesInChunk, slice.captureCost);
12353
12418
  const chunkWorkerCount = resolveChunkCaptureWorkers(
12354
12419
  captureFrames,
@@ -12508,10 +12573,10 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
12508
12573
  const effectiveBitrate = encoder.crf != null ? void 0 : encoder.bitrate;
12509
12574
  const videoOnlyPath = encoder.chunksCarryAudio ? `${outputChunkPath}.video.mp4` : outputChunkPath;
12510
12575
  if (isPngSequence) {
12511
- if (!existsSync24(outputChunkPath)) mkdirSync14(outputChunkPath, { recursive: true });
12576
+ if (!existsSync23(outputChunkPath)) mkdirSync14(outputChunkPath, { recursive: true });
12512
12577
  } else {
12513
12578
  const outDir = join31(outputChunkPath, "..");
12514
- if (!existsSync24(outDir)) mkdirSync14(outDir, { recursive: true });
12579
+ if (!existsSync23(outDir)) mkdirSync14(outDir, { recursive: true });
12515
12580
  }
12516
12581
  const encodeInput = {
12517
12582
  job,
@@ -12983,6 +13048,9 @@ function validateDistributedRenderConfig(config) {
12983
13048
  if (config.variables !== void 0) {
12984
13049
  validateVariablesPayload(config.variables);
12985
13050
  }
13051
+ if (config.strictVariables !== void 0 && typeof config.strictVariables !== "boolean") {
13052
+ throw new InvalidConfigError("config.strictVariables", "must be a boolean");
13053
+ }
12986
13054
  if (config.engineConfig !== void 0) {
12987
13055
  try {
12988
13056
  validateEngineConfigSnapshot(config.engineConfig);
@@ -13077,7 +13145,7 @@ function validateIntDimension(field, value) {
13077
13145
 
13078
13146
  // src/services/distributed/projectHash.ts
13079
13147
  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";
13148
+ import { createHash as createHash9 } from "node:crypto";
13081
13149
  import { join as join33 } from "node:path";
13082
13150
  var SITE_ID_SCHEME = "site-v2\0";
13083
13151
  var READ_CHUNK_BYTES = 256 * 1024;
@@ -13114,7 +13182,7 @@ function listSiteFiles(projectDir) {
13114
13182
  return files;
13115
13183
  }
13116
13184
  function hashProjectDir(projectDir, files = listSiteFiles(projectDir)) {
13117
- const hash = createHash8("sha256").update(SITE_ID_SCHEME);
13185
+ const hash = createHash9("sha256").update(SITE_ID_SCHEME);
13118
13186
  const chunk = Buffer.allocUnsafe(READ_CHUNK_BYTES);
13119
13187
  for (const rel of files) {
13120
13188
  hash.update(rel);