@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.
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  // src/services/renderOrchestrator.ts
10
10
  import { audioFailureDiagnostics as audioFailureDiagnostics2 } from "@hyperframes/engine";
11
11
  import {
12
- existsSync as existsSync22,
12
+ existsSync as existsSync21,
13
13
  mkdirSync as mkdirSync12,
14
14
  readdirSync as readdirSync6,
15
15
  rmSync as rmSync12,
@@ -206,7 +206,9 @@ function createConsoleLogger(level = "info") {
206
206
  }
207
207
  };
208
208
  }
209
- var defaultLogger = createConsoleLogger("info");
209
+ var defaultLogger = createConsoleLogger(
210
+ process.env.HF_DEBUG_RENDER === "1" ? "debug" : "info"
211
+ );
210
212
 
211
213
  // src/services/fileServer.ts
212
214
  var readFileAsync = promisify(readFile);
@@ -1011,7 +1013,7 @@ function assertChromaSubsamplingSdr(config, hasHdrContent) {
1011
1013
  import {
1012
1014
  copyFileSync,
1013
1015
  cpSync,
1014
- existsSync as existsSync4,
1016
+ existsSync as existsSync3,
1015
1017
  mkdirSync,
1016
1018
  rmSync,
1017
1019
  symlinkSync,
@@ -1034,9 +1036,7 @@ import {
1034
1036
  relative as nodeRelative,
1035
1037
  isAbsolute as nodeIsAbsolute
1036
1038
  } from "node:path";
1037
- import { existsSync as existsSync3 } from "node:fs";
1038
1039
  import { fileURLToPath as fileURLToPath2 } from "node:url";
1039
- import { decodedUrlPath } from "@hyperframes/parsers/asset-paths";
1040
1040
  var DEFAULT_RENDERS_DIR = process.env.PRODUCER_RENDERS_DIR ?? // fileURLToPath (not URL.pathname): on Windows .pathname is "/D:/..." which
1041
1041
  // resolves to a bogus renders dir.
1042
1042
  nodeResolve(fileURLToPath2(import.meta.url), "../../..", "renders");
@@ -1074,13 +1074,6 @@ function resolveRenderPaths(projectDir, outputPath, rendersDir = DEFAULT_RENDERS
1074
1074
  const absoluteOutputPath = nodeResolve(resolvedOutputPath);
1075
1075
  return { absoluteProjectDir, absoluteOutputPath };
1076
1076
  }
1077
- function resolveCompositionSrc(projectDir, src) {
1078
- const rooted = (value) => nodeResolve(projectDir, value.replace(/^(?:\.?[\\/])+/, ""));
1079
- const decoded = rooted(decodedUrlPath(src));
1080
- if (!isPathInside2(decoded, projectDir)) return null;
1081
- const raw = rooted(src);
1082
- return !existsSync3(decoded) && isPathInside2(raw, projectDir) && existsSync3(raw) ? raw : decoded;
1083
- }
1084
1077
 
1085
1078
  // src/services/render/shared.ts
1086
1079
  var BROWSER_MEDIA_EPSILON = 1e-4;
@@ -1255,6 +1248,13 @@ var workerPhasesByJob = /* @__PURE__ */ new WeakMap();
1255
1248
  function forgetWorkerPhases(job) {
1256
1249
  workerPhasesByJob.delete(job);
1257
1250
  }
1251
+ var staticDedupActivityByJob = /* @__PURE__ */ new WeakMap();
1252
+ function noteStaticDedupActivity(job) {
1253
+ staticDedupActivityByJob.set(job, (staticDedupActivityByJob.get(job) ?? 0) + 1);
1254
+ }
1255
+ function staticDedupActivity(job) {
1256
+ return staticDedupActivityByJob.get(job) ?? 0;
1257
+ }
1258
1258
  function describeWorkerPhases(job) {
1259
1259
  const phases = workerPhasesByJob.get(job);
1260
1260
  if (!phases?.size) return void 0;
@@ -1288,7 +1288,7 @@ var materializePathModule = {
1288
1288
  isAbsolute
1289
1289
  };
1290
1290
  var materializeFileSystem = {
1291
- existsSync: existsSync4,
1291
+ existsSync: existsSync3,
1292
1292
  mkdirSync,
1293
1293
  symlinkSync,
1294
1294
  cpSync,
@@ -1590,7 +1590,7 @@ var RenderExecutionContext = class {
1590
1590
  };
1591
1591
 
1592
1592
  // src/services/render/artifactTransaction.ts
1593
- import { closeSync as closeSync2, existsSync as existsSync6, fstatSync as fstatSync2, openSync as openSync2, readSync, readdirSync as readdirSync2, rmSync as rmSync3 } from "node:fs";
1593
+ import { closeSync as closeSync2, existsSync as existsSync5, fstatSync as fstatSync2, openSync as openSync2, readSync, readdirSync as readdirSync2, rmSync as rmSync3 } from "node:fs";
1594
1594
  import { basename as basename4, dirname as dirname4, extname as extname2, join as join5, resolve as resolve4 } from "node:path";
1595
1595
  import { HLS_MASTER_PLAYLIST, HLS_VIDEO_PLAYLIST, renameWithRetry } from "@hyperframes/engine";
1596
1596
 
@@ -1603,7 +1603,7 @@ import {
1603
1603
 
1604
1604
  // src/services/render/renderDirOwner.ts
1605
1605
  import {
1606
- existsSync as existsSync5,
1606
+ existsSync as existsSync4,
1607
1607
  lstatSync,
1608
1608
  readFileSync as readFileSync2,
1609
1609
  readdirSync,
@@ -1679,7 +1679,7 @@ function newestWriteMs(path) {
1679
1679
  }
1680
1680
  function isAbandoned(dir, ownerlessIdleMs, now) {
1681
1681
  try {
1682
- if (!lstatSync(dir).isDirectory() || existsSync5(join4(dir, TRANSACTION_BACKUP))) return false;
1682
+ if (!lstatSync(dir).isDirectory() || existsSync4(join4(dir, TRANSACTION_BACKUP))) return false;
1683
1683
  const owner = ownerState(dir);
1684
1684
  if (owner === "gone") return true;
1685
1685
  return owner === "none" && ownerlessIdleMs !== void 0 && now - newestWriteMs(dir) >= ownerlessIdleMs;
@@ -1711,7 +1711,7 @@ function createRenderWorkDir(prefix, outputDir) {
1711
1711
 
1712
1712
  // src/services/render/artifactTransaction.ts
1713
1713
  var defaultFileSystem = {
1714
- existsSync: existsSync6,
1714
+ existsSync: existsSync5,
1715
1715
  renameSync: (source, destination) => renameWithRetry(source, destination),
1716
1716
  rmSync: rmSync3
1717
1717
  };
@@ -1865,7 +1865,7 @@ var ArtifactTransaction = class {
1865
1865
  async assertDirectoryExpectation(expected, files) {
1866
1866
  for (const required of expected.requiredFiles ?? []) {
1867
1867
  const path = join5(this.stagingPath, required);
1868
- if (!existsSync6(path)) {
1868
+ if (!existsSync5(path)) {
1869
1869
  throw new Error(`Render artifact directory is missing ${required}: ${this.stagingPath}`);
1870
1870
  }
1871
1871
  assertReadableNonEmptyFile(path);
@@ -2114,7 +2114,7 @@ function replanAfterFailure(plan2, failure) {
2114
2114
  }
2115
2115
 
2116
2116
  // src/services/render/stages/captureSegmentedStage.ts
2117
- import { existsSync as existsSync7, mkdirSync as mkdirSync3, rmSync as rmSync6, statSync as statSync3 } from "node:fs";
2117
+ import { existsSync as existsSync6, mkdirSync as mkdirSync3, rmSync as rmSync6, statSync as statSync3 } from "node:fs";
2118
2118
  import { join as join9 } from "node:path";
2119
2119
  import {
2120
2120
  captureFrameToBuffer as captureFrameToBuffer2,
@@ -4460,7 +4460,7 @@ async function runCaptureStreamingStage(input) {
4460
4460
  const session = probeSession ?? await openSession();
4461
4461
  captureBeyondViewport = session.options.captureBeyondViewport;
4462
4462
  if (probeSession) {
4463
- prepareCaptureSessionForReuse(session, framesDir, videoInjector);
4463
+ await prepareCaptureSessionForReuse(session, framesDir, videoInjector);
4464
4464
  probeSession = null;
4465
4465
  }
4466
4466
  let riskSession = null;
@@ -4718,7 +4718,7 @@ async function captureSegmentToEncoder(ctx, segment) {
4718
4718
  path: segmentPath,
4719
4719
  // Recorded so resume can prove the file on disk is the one that
4720
4720
  // finished; absent only in unit tests, whose fake encoder writes none.
4721
- bytes: existsSync7(segmentPath) ? statSync3(segmentPath).size : 0
4721
+ bytes: existsSync6(segmentPath) ? statSync3(segmentPath).size : 0
4722
4722
  });
4723
4723
  return encodeResult;
4724
4724
  } finally {
@@ -4765,8 +4765,13 @@ function defaultSessionFactory(input) {
4765
4765
  };
4766
4766
  const session = probeSession ?? await openSession();
4767
4767
  if (probeSession) {
4768
- openSegmentedSessionReuse(input, probeSession, injector);
4768
+ const reused = probeSession;
4769
4769
  probeSession = null;
4770
+ await openSegmentedSessionReuse(input, reused, injector).catch(async (error) => {
4771
+ await closeCaptureSession2(reused).catch(() => {
4772
+ });
4773
+ throw error;
4774
+ });
4770
4775
  }
4771
4776
  try {
4772
4777
  if (!session.isInitialized) await withinInitBudget(initializeSession2(session), session);
@@ -4780,8 +4785,8 @@ function defaultSessionFactory(input) {
4780
4785
  }
4781
4786
  };
4782
4787
  }
4783
- function openSegmentedSessionReuse(input, session, injector) {
4784
- prepareCaptureSessionForReuse2(session, input.framesDir, injector());
4788
+ async function openSegmentedSessionReuse(input, session, injector) {
4789
+ await prepareCaptureSessionForReuse2(session, input.framesDir, injector());
4785
4790
  }
4786
4791
  async function openSegmentedSession(input, injector) {
4787
4792
  const captureCfg = input.cfg.forceScreenshot === input.plan.forceScreenshot ? input.cfg : { ...input.cfg, forceScreenshot: input.plan.forceScreenshot };
@@ -5719,7 +5724,7 @@ function trackSegmentFramePeak(frames, rootDir, onPeak) {
5719
5724
 
5720
5725
  // src/services/render/segmentManifest.ts
5721
5726
  import { createHash as createHash2 } from "node:crypto";
5722
- import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync4, statSync as statSync5, writeFileSync as writeFileSync3 } from "node:fs";
5727
+ import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync4, statSync as statSync5, writeFileSync as writeFileSync3 } from "node:fs";
5723
5728
  import { join as join14 } from "node:path";
5724
5729
  import { renameWithRetry as renameWithRetry2 } from "@hyperframes/engine";
5725
5730
  var MANIFEST_FILENAME = "segments.json";
@@ -5767,7 +5772,7 @@ function isManifest(value) {
5767
5772
  }
5768
5773
  function readSegmentManifest(segmentDir) {
5769
5774
  const path = join14(segmentDir, MANIFEST_FILENAME);
5770
- if (!existsSync8(path)) return null;
5775
+ if (!existsSync7(path)) return null;
5771
5776
  try {
5772
5777
  const parsed = JSON.parse(readFileSync4(path, "utf-8"));
5773
5778
  return isManifest(parsed) ? parsed : null;
@@ -5796,7 +5801,7 @@ async function validateCompletedSegments(manifest, expectedHash, probeFrames) {
5796
5801
  const ok = /* @__PURE__ */ new Set();
5797
5802
  if (manifest.planHash !== expectedHash) return ok;
5798
5803
  for (const entry of manifest.completed) {
5799
- if (!existsSync8(entry.path)) continue;
5804
+ if (!existsSync7(entry.path)) continue;
5800
5805
  const size = statSync5(entry.path).size;
5801
5806
  if (size <= 0 || size !== entry.bytes) continue;
5802
5807
  const frames = await probeFrames(entry.path);
@@ -6164,26 +6169,26 @@ var STALL_POLL_MS = 5e3;
6164
6169
  function watchStall(phase, rule) {
6165
6170
  const detail = rule.detail ?? (() => void 0);
6166
6171
  let last = rule.progress();
6172
+ let lastActivity = rule.activity?.();
6167
6173
  let budgetMs = rule.firstProgressMs;
6168
6174
  const silence = createStallClock();
6169
6175
  const pollMs = Math.min(STALL_POLL_MS, rule.noProgressMs, rule.firstProgressMs);
6170
6176
  let attempt;
6171
6177
  let timer;
6172
6178
  let inTail = false;
6179
+ const activityMoved = () => {
6180
+ const activity = rule.activity?.();
6181
+ if (activity === lastActivity) return false;
6182
+ lastActivity = activity;
6183
+ return true;
6184
+ };
6173
6185
  const restartWindow = (ms) => {
6174
6186
  last = rule.progress();
6175
6187
  budgetMs = ms;
6176
6188
  silence.reset();
6177
6189
  };
6178
6190
  const tripped = new Promise((_, reject) => {
6179
- timer = setInterval(() => {
6180
- const current = rule.progress();
6181
- if (rule.complete?.() && !inTail) {
6182
- inTail = true;
6183
- return restartWindow(rule.tailMs ?? rule.noProgressMs);
6184
- }
6185
- if (current !== last) return restartWindow(rule.noProgressMs);
6186
- if (silence.idle(pollMs) < budgetMs) return;
6191
+ const trip = (current) => {
6187
6192
  const error = new RenderStageStalledError(phase, budgetMs, current, detail());
6188
6193
  if (attempt && !attempt.signal.aborted) {
6189
6194
  attempt.abort(error);
@@ -6191,6 +6196,16 @@ function watchStall(phase, rule) {
6191
6196
  }
6192
6197
  clearInterval(timer);
6193
6198
  reject(error);
6199
+ };
6200
+ timer = setInterval(() => {
6201
+ const current = rule.progress();
6202
+ if (rule.complete?.() && !inTail) {
6203
+ inTail = true;
6204
+ return restartWindow(rule.tailMs ?? rule.noProgressMs);
6205
+ }
6206
+ if (current !== last) return restartWindow(rule.noProgressMs);
6207
+ if (activityMoved()) return silence.reset();
6208
+ if (silence.idle(pollMs) >= budgetMs) trip(current);
6194
6209
  }, pollMs);
6195
6210
  });
6196
6211
  const openAttempt = (parent) => {
@@ -6375,21 +6390,21 @@ function countAuthoredTimedClips(html) {
6375
6390
  }
6376
6391
 
6377
6392
  // src/services/render/stages/compileStage.ts
6378
- import { existsSync as existsSync13, writeFileSync as writeFileSync5 } from "node:fs";
6393
+ import { existsSync as existsSync12, writeFileSync as writeFileSync5 } from "node:fs";
6379
6394
  import { join as join19 } from "node:path";
6380
6395
  import { suggestMatchingPreset } from "@hyperframes/core";
6381
6396
  import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
6382
6397
  import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolution";
6383
6398
 
6384
6399
  // src/services/htmlCompiler.ts
6385
- import { decodedUrlPath as decodedUrlPath2 } from "@hyperframes/parsers/asset-paths";
6400
+ import { decodedUrlPath } from "@hyperframes/parsers/asset-paths";
6386
6401
  import { createHash as createHash6 } from "node:crypto";
6387
- import { createReadStream as createReadStream2, existsSync as existsSync12, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
6402
+ import { createReadStream as createReadStream2, existsSync as existsSync11, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
6388
6403
  import { join as join18, dirname as dirname8, resolve as resolve7, basename as basename5, relative as relative2, sep as sep2 } from "path";
6389
6404
  import { parseHTML as parseHTML5 } from "linkedom";
6390
6405
 
6391
6406
  // src/services/bundledScripts.ts
6392
- import { existsSync as existsSync9, readFileSync as readFileSync5 } from "node:fs";
6407
+ import { existsSync as existsSync8, readFileSync as readFileSync5 } from "node:fs";
6393
6408
  import { join as join15 } from "node:path";
6394
6409
  import { gsapCdnDist } from "@hyperframes/core/gsap-cdn";
6395
6410
  var GSAP_VENDOR_DIR_ENV = "HYPERFRAMES_GSAP_VENDOR_DIR";
@@ -6397,7 +6412,7 @@ function bundledScript(url) {
6397
6412
  const dir = process.env[GSAP_VENDOR_DIR_ENV];
6398
6413
  if (!dir || url !== `${gsapCdnDist()}gsap.min.js`) return null;
6399
6414
  const file = join15(dir, "gsap.min.js");
6400
- return existsSync9(file) ? readFileSync5(file) : null;
6415
+ return existsSync8(file) ? readFileSync5(file) : null;
6401
6416
  }
6402
6417
 
6403
6418
  // src/services/htmlCompiler.ts
@@ -6437,6 +6452,7 @@ import {
6437
6452
  emitRootCompositionVariableStyles,
6438
6453
  readDeclaredDefaults,
6439
6454
  parseHostVariableValues,
6455
+ boundMediaSrc,
6440
6456
  headStyleRuns,
6441
6457
  isAlwaysAppliedStyle,
6442
6458
  dedupeFontFaceRules,
@@ -6451,8 +6467,10 @@ import {
6451
6467
  } from "@hyperframes/parsers/sub-composition-validity";
6452
6468
  import {
6453
6469
  isUnresolvedAssetPlaceholder,
6470
+ namesAnotherNetworkRoot as namesAnotherNetworkRoot2,
6454
6471
  readProjectFile,
6455
- readTextFile
6472
+ readTextFile,
6473
+ resolveCompositionSrc
6456
6474
  } from "@hyperframes/parsers/asset-resolution";
6457
6475
 
6458
6476
  // src/services/renderMediaCollector.ts
@@ -6645,11 +6663,12 @@ import {
6645
6663
 
6646
6664
  // src/services/animatedGifPrep.ts
6647
6665
  import { createHash as createHash4 } from "node:crypto";
6648
- import { copyFileSync as copyFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync6 } from "node:fs";
6666
+ import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync6 } from "node:fs";
6649
6667
  import { dirname as dirname6, isAbsolute as isAbsolute2, join as join16, resolve as resolve5 } from "node:path";
6650
6668
  import { parseHTML as parseHTML3 } from "linkedom";
6651
6669
  import { parseAnimatedGifMetadata } from "@hyperframes/core";
6652
6670
  import { DEFAULT_VP9_CPU_USED, runFfmpeg as runFfmpeg2, renameWithRetry as renameWithRetry3 } from "@hyperframes/engine";
6671
+ import { namesAnotherNetworkRoot } from "@hyperframes/parsers/asset-resolution";
6653
6672
  var PREPARED_GIF_SUBDIR = "_animated_gif";
6654
6673
  var CACHE_SCHEMA = "hfgif-v1";
6655
6674
  function splitUrlSuffix(src) {
@@ -6684,14 +6703,15 @@ function resolveLocalImageSourcePath(src, options) {
6684
6703
  const { basePath } = splitUrlSuffix(trimmed);
6685
6704
  const normalizedBase = normalizeRelPath(basePath);
6686
6705
  const mapped = options.sourceAssets?.get(trimmed) ?? options.sourceAssets?.get(basePath) ?? options.sourceAssets?.get(normalizedBase);
6687
- if (mapped && existsSync10(mapped)) return mapped;
6706
+ if (mapped && existsSync9(mapped)) return mapped;
6688
6707
  if (isHttpUrl(trimmed)) return null;
6708
+ const protocolRelativeUrlOnShare = basePath.startsWith("/") && namesAnotherNetworkRoot(options.projectDir, basePath);
6689
6709
  const projectRelative = basePath.startsWith("/") ? basePath.slice(1) : basePath;
6690
6710
  const candidates = [
6691
- isAbsolute2(basePath) ? basePath : resolve5(options.projectDir, projectRelative),
6711
+ ...protocolRelativeUrlOnShare ? [] : [isAbsolute2(basePath) ? basePath : resolve5(options.projectDir, projectRelative)],
6692
6712
  resolve5(options.downloadDir, normalizedBase)
6693
6713
  ];
6694
- return candidates.find((candidate) => existsSync10(candidate)) ?? null;
6714
+ return candidates.find((candidate) => existsSync9(candidate)) ?? null;
6695
6715
  }
6696
6716
  function isUsableFile(path) {
6697
6717
  try {
@@ -6802,10 +6822,10 @@ async function runAnimatedGifTranscode(request) {
6802
6822
  throw result.error ?? new Error(`Animated GIF transcode failed (${result.exitCode}): ${result.stderr.slice(-500)}`);
6803
6823
  }
6804
6824
  async function ensurePreparedWebm(input) {
6805
- if (!existsSync10(dirname6(input.cachePath))) {
6825
+ if (!existsSync9(dirname6(input.cachePath))) {
6806
6826
  mkdirSync7(dirname6(input.cachePath), { recursive: true });
6807
6827
  }
6808
- if (!existsSync10(dirname6(input.outputPath))) {
6828
+ if (!existsSync9(dirname6(input.outputPath))) {
6809
6829
  mkdirSync7(dirname6(input.outputPath), { recursive: true });
6810
6830
  }
6811
6831
  if (!isUsableFile(input.cachePath)) {
@@ -7280,7 +7300,7 @@ import { createStudioPositionSeekReapplyScript } from "@hyperframes/studio-serve
7280
7300
  import { getPositionEditsRenderScript } from "@hyperframes/core/runtime/position-edits-render";
7281
7301
 
7282
7302
  // src/services/assetMediaType.ts
7283
- import { existsSync as existsSync11 } from "node:fs";
7303
+ import { existsSync as existsSync10 } from "node:fs";
7284
7304
  import {
7285
7305
  fingerprintElementId,
7286
7306
  isNotMediaPayload,
@@ -7353,7 +7373,7 @@ async function preflightCompositionAssetMediaTypes(input) {
7353
7373
  input.projectDir,
7354
7374
  input.compiledDir
7355
7375
  );
7356
- if (!existsSync11(resolvedPath)) continue;
7376
+ if (!existsSync10(resolvedPath)) continue;
7357
7377
  byPath.set(resolvedPath, [...byPath.get(resolvedPath) ?? [], reference]);
7358
7378
  }
7359
7379
  const mismatches = [];
@@ -7393,7 +7413,7 @@ async function preflightCompositionAssetMediaTypes(input) {
7393
7413
 
7394
7414
  // src/services/htmlCompiler.ts
7395
7415
  function logRemoteDownloadTelemetry(event) {
7396
- defaultLogger.info("[Compiler] Remote asset download integrity", { ...event });
7416
+ defaultLogger.debug("[Compiler] Remote asset download integrity", { ...event });
7397
7417
  }
7398
7418
  var INFERRED_MEDIA_DURATION_ATTR = "data-hf-inferred-duration";
7399
7419
  function parseSubCompHtmlForValidity(html) {
@@ -7607,7 +7627,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, down
7607
7627
  let filePath = src;
7608
7628
  if (isHttpUrl(src)) {
7609
7629
  const remoteDir = join18(downloadDir, REMOTE_MEDIA_SUBDIR);
7610
- if (!existsSync12(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
7630
+ if (!existsSync11(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
7611
7631
  try {
7612
7632
  filePath = await downloadToTemp(src, remoteDir, void 0, void 0, void 0, {
7613
7633
  onTelemetry: logRemoteDownloadTelemetry
@@ -7616,11 +7636,14 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, down
7616
7636
  return { duration: null, resolvedPath: src };
7617
7637
  }
7618
7638
  } else {
7619
- filePath = decodedUrlPath2(src);
7639
+ filePath = decodedUrlPath(src);
7620
7640
  if (!filePath.startsWith("/")) filePath = join18(baseDir, filePath);
7621
7641
  filePath = urlByAbsentLocalPath?.get(filePath) ?? filePath;
7642
+ if (!isHttpUrl(filePath) && namesAnotherNetworkRoot2(baseDir, filePath)) {
7643
+ return { duration: null, resolvedPath: filePath };
7644
+ }
7622
7645
  }
7623
- if (!isHttpUrl(filePath) && !existsSync12(filePath)) {
7646
+ if (!isHttpUrl(filePath) && !existsSync11(filePath)) {
7624
7647
  return { duration: null, resolvedPath: filePath };
7625
7648
  }
7626
7649
  const withSrcContext = (error) => {
@@ -7969,7 +7992,7 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
7969
7992
  parseHtml: (htmlStr) => parseHTML5(htmlStr).document,
7970
7993
  // Mirrors the preview bundler: a sub-composition's SIBLING assets resolve
7971
7994
  // against its own directory, project-root refs stay as authored.
7972
- assetExists: (path) => existsSync12(resolve7(projectDir, path)),
7995
+ assetExists: (path) => existsSync11(resolve7(projectDir, path)),
7973
7996
  // Preserve the authored root wrapper as a child of the host, matching
7974
7997
  // the preview bundler's shape (htmlBundler.ts's prepareFlattenedInnerRoot,
7975
7998
  // which the runtime compositionLoader mirrors with its own copy for the
@@ -8145,7 +8168,7 @@ ${safeText}
8145
8168
  //# sourceURL=${new URL(src).href}
8146
8169
  `;
8147
8170
  el.replaceWith(inlineScript);
8148
- defaultLogger.info(`[Compiler] Inlined CDN script: ${src}`);
8171
+ defaultLogger.debug(`[Compiler] Inlined CDN script: ${src}`);
8149
8172
  } else {
8150
8173
  if (download.reason instanceof ScriptIntegrityError) throw download.reason;
8151
8174
  defaultLogger.warn(
@@ -8165,7 +8188,7 @@ function collectExternalAssets(html, projectDir) {
8165
8188
  if (isPathInside2(absPath, absProjectDir)) {
8166
8189
  return null;
8167
8190
  }
8168
- if (!existsSync12(absPath)) return null;
8191
+ if (!existsSync11(absPath)) return null;
8169
8192
  const safeKey = toExternalAssetKey(absPath);
8170
8193
  externalAssets.set(safeKey, absPath);
8171
8194
  return safeKey;
@@ -8200,7 +8223,7 @@ function collectExternalAssets(html, projectDir) {
8200
8223
  if (rewritten !== style) el.setAttribute("style", rewritten);
8201
8224
  }
8202
8225
  if (externalAssets.size > 0) {
8203
- defaultLogger.info(
8226
+ defaultLogger.debug(
8204
8227
  `[Compiler] Found ${externalAssets.size} asset(s) outside project directory, will copy to render output`
8205
8228
  );
8206
8229
  }
@@ -8215,7 +8238,7 @@ var REMOTE_SOURCE_TAG_RE = /<source\b[^>]*?\bsrc\s*=\s*["'](https?:\/\/[^"']+)["
8215
8238
  var REMOTE_IMG_TAG_RE = /<img\b[^>]*?(?<![\w-])src\s*=\s*["'](https?:\/\/[^"']+)["'][^>]*>/gi;
8216
8239
  async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLabel, extraRewrite) {
8217
8240
  if (urlSet.size === 0) return { html, remoteMediaAssets: /* @__PURE__ */ new Map() };
8218
- if (!existsSync12(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
8241
+ if (!existsSync11(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
8219
8242
  const urlToLocal = /* @__PURE__ */ new Map();
8220
8243
  await Promise.all(
8221
8244
  [...urlSet].map(async (url) => {
@@ -8247,7 +8270,7 @@ async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLab
8247
8270
  result = result.replaceAll(`"${url}"`, `"${relPath}"`).replaceAll(`'${url}'`, `'${relPath}'`);
8248
8271
  if (extraRewrite) result = extraRewrite(result, url, relPath);
8249
8272
  }
8250
- defaultLogger.info(`[Compiler] ${logLabel} ${urlToLocal.size} to ${REMOTE_MEDIA_SUBDIR}/`);
8273
+ defaultLogger.debug(`[Compiler] ${logLabel} ${urlToLocal.size} to ${REMOTE_MEDIA_SUBDIR}/`);
8251
8274
  return { html: result, remoteMediaAssets };
8252
8275
  }
8253
8276
  async function localizeRemoteMediaSources(html, downloadDir) {
@@ -8384,7 +8407,7 @@ async function inlineExternalFontStylesheets(html) {
8384
8407
  ${fontFaceBlocks.join("\n")}
8385
8408
  </style>`;
8386
8409
  result = result.replace(fullMatch, inlineStyle);
8387
- defaultLogger.info("[Compiler] Inlined external @font-face rule(s)", {
8410
+ defaultLogger.debug("[Compiler] Inlined external @font-face rule(s)", {
8388
8411
  count: fontFaceBlocks.length,
8389
8412
  urlFingerprint: identity.urlFingerprint,
8390
8413
  host: identity.host
@@ -8397,14 +8420,14 @@ function projectStylesheetFontFamilies(html, projectDir) {
8397
8420
  for (const [tag] of html.matchAll(/<link\b[^>]*\brel=["']stylesheet["'][^>]*>/gi)) {
8398
8421
  const href = /\bhref=["']([^"']+)["']/i.exec(tag)?.[1];
8399
8422
  if (!href || /^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(href)) continue;
8400
- const sheet = resolve7(projectDir, decodedUrlPath2(href).replace(/^(?:\.?\/)+/, ""));
8401
- if (!isPathInside2(sheet, projectDir) || !existsSync12(sheet)) continue;
8423
+ const sheet = resolve7(projectDir, decodedUrlPath(href).replace(/^(?:\.?\/)+/, ""));
8424
+ if (!isPathInside2(sheet, projectDir) || !existsSync11(sheet)) continue;
8402
8425
  for (const face of extractFontFaceBlocks(readFileSync8(sheet, "utf8"))) {
8403
8426
  const family = /font-family\s*:\s*([^;}]+)/i.exec(face)?.[1]?.trim().replace(/^['"]|['"]$/g, "");
8404
8427
  const shipsFile = [...face.matchAll(LOCAL_FONTFACE_URL_RE)].some(([, url = ""]) => {
8405
- const path = decodedUrlPath2(url);
8428
+ const path = decodedUrlPath(url);
8406
8429
  const file = path.startsWith("/") ? resolve7(projectDir, `.${path}`) : resolve7(dirname8(sheet), path);
8407
- return isPathInside2(file, projectDir) && existsSync12(file);
8430
+ return isPathInside2(file, projectDir) && existsSync11(file);
8408
8431
  });
8409
8432
  if (family && shipsFile) families.push(family);
8410
8433
  }
@@ -8506,7 +8529,7 @@ async function embedLocalFontFaces(html, projectDir) {
8506
8529
  const font = await readLocalFont(absPath);
8507
8530
  if (font.kind === "file-backed") {
8508
8531
  fileBackedAbsolutePaths.add(absPath);
8509
- defaultLogger.info(
8532
+ defaultLogger.debug(
8510
8533
  `[Compiler] Kept large local font file-backed: ${localPath} (> ${(MAX_LOCAL_FONT_DATA_URI_BYTES / 1024 / 1024).toFixed(1)} MB)`
8511
8534
  );
8512
8535
  embeddedPaths.add(localPath);
@@ -8514,7 +8537,7 @@ async function embedLocalFontFaces(html, projectDir) {
8514
8537
  }
8515
8538
  dataUri = await toDataUri(font.buffer, ext, { compressToWoff2: false });
8516
8539
  dataUriByAbsolutePath.set(absPath, dataUri);
8517
- defaultLogger.info(
8540
+ defaultLogger.debug(
8518
8541
  `[Compiler] Embedded local font file: ${localPath} (${(font.buffer.length / 1024).toFixed(0)} KB \u2192 data URI)`
8519
8542
  );
8520
8543
  }
@@ -8542,14 +8565,17 @@ function renderGsapDist() {
8542
8565
  }
8543
8566
  function rewriteUnresolvableGsapToCdn(html, projectDir, compSrcPath) {
8544
8567
  let gsapDist;
8545
- const exists = (path) => existsSync12(resolve7(projectDir, path));
8568
+ const exists = (path) => {
8569
+ const file = resolve7(projectDir, path);
8570
+ return !namesAnotherNetworkRoot2(projectDir, file) && existsSync11(file);
8571
+ };
8546
8572
  return html.replace(
8547
8573
  /(<script\b[^>]*\bsrc=["'])([^"']*gsap[^"']*\/dist\/([^"']+))(["'][^>]*>)/gi,
8548
8574
  (full, prefix, src, file, suffix) => {
8549
8575
  if (/^https?:\/\//i.test(src)) return full;
8550
8576
  if (exists(compSrcPath ? rewriteAssetPath(compSrcPath, src, exists) : src)) return full;
8551
8577
  gsapDist ??= renderGsapDist();
8552
- defaultLogger.info(`[Compiler] Rewriting missing gsap script: ${src} \u2192 ${gsapDist}${file}`);
8578
+ defaultLogger.debug(`[Compiler] Rewriting missing gsap script: ${src} \u2192 ${gsapDist}${file}`);
8553
8579
  return `${prefix}${gsapDist}${file}${suffix}`;
8554
8580
  }
8555
8581
  );
@@ -8559,7 +8585,7 @@ function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath) {
8559
8585
  const entryPath = relative2(projectDir, htmlPath).replace(/\\/g, "/");
8560
8586
  if (!entryPath.includes("/")) return html;
8561
8587
  const { document: document2 } = parseHTML5(html);
8562
- const assetExists = (path) => existsSync12(resolve7(projectDir, path));
8588
+ const assetExists = (path) => existsSync11(resolve7(projectDir, path));
8563
8589
  rewriteAssetPaths(
8564
8590
  document2.querySelectorAll("[src], [href], [srcset]"),
8565
8591
  entryPath,
@@ -8579,11 +8605,29 @@ function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath) {
8579
8605
  }
8580
8606
  return document2.toString();
8581
8607
  }
8608
+ function bindVariableMediaSources(html, variables) {
8609
+ if (!html.includes("data-var-src")) return html;
8610
+ const { document: document2 } = parseHTML5(html);
8611
+ const declared = {};
8612
+ for (const el of document2.querySelectorAll("[data-composition-variables]")) {
8613
+ Object.assign(declared, readDeclaredDefaults(el));
8614
+ }
8615
+ const values = { ...declared, ...variables };
8616
+ let changed = false;
8617
+ for (const el of document2.querySelectorAll("video[data-var-src], audio[data-var-src]")) {
8618
+ if (el.closest("[data-variable-values]")) continue;
8619
+ const src = boundMediaSrc(el, values);
8620
+ if (src === null || el.getAttribute("src") === src) continue;
8621
+ el.setAttribute("src", src);
8622
+ changed = true;
8623
+ }
8624
+ return changed ? document2.toString() : html;
8625
+ }
8582
8626
  async function compileForRender(projectDir, htmlPath, downloadDir, options = {}) {
8583
8627
  const entryHtml = rebaseDirectEntryAssetPaths(readTextFile(htmlPath), projectDir, htmlPath);
8584
- const rawHtml = normalizeCompositionSrcs(
8585
- rewriteUnresolvableGsapToCdn(entryHtml, projectDir),
8586
- projectDir
8628
+ const rawHtml = bindVariableMediaSources(
8629
+ normalizeCompositionSrcs(rewriteUnresolvableGsapToCdn(entryHtml, projectDir), projectDir),
8630
+ options.variables ?? {}
8587
8631
  );
8588
8632
  assertSubCompositionsUsable(rawHtml, projectDir);
8589
8633
  const probes = /* @__PURE__ */ new Map();
@@ -8667,7 +8711,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
8667
8711
  timeoutMs: options.ffmpegProcessTimeout
8668
8712
  });
8669
8713
  if (preparedHeifImages.length > 0) {
8670
- defaultLogger.info(`[Compiler] Converted ${preparedHeifImages.length} HEIC image(s) to JPEG`);
8714
+ defaultLogger.debug(`[Compiler] Converted ${preparedHeifImages.length} HEIC image(s) to JPEG`);
8671
8715
  }
8672
8716
  const gifSourceAssets = new Map(remoteImageAssets);
8673
8717
  const {
@@ -8682,7 +8726,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
8682
8726
  timeoutMs: options.ffmpegProcessTimeout
8683
8727
  });
8684
8728
  if (preparedGifs.length > 0) {
8685
- defaultLogger.info(`[Compiler] Prepared ${preparedGifs.length} animated GIF input(s) as WebM`);
8729
+ defaultLogger.debug(`[Compiler] Prepared ${preparedGifs.length} animated GIF input(s) as WebM`);
8686
8730
  }
8687
8731
  const embeddedHtml = await embedLocalFontFaces(htmlWithPreparedGifs, projectDir);
8688
8732
  const { html, externalAssets } = collectExternalAssets(embeddedHtml, projectDir);
@@ -8710,7 +8754,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
8710
8754
  for (const video of videos) {
8711
8755
  if (isHttpUrl(video.src)) continue;
8712
8756
  const videoPath = resolve7(projectDir, video.src);
8713
- if (advised.has(videoPath)) continue;
8757
+ if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath)) continue;
8714
8758
  advised.add(videoPath);
8715
8759
  const reencode = `ffmpeg -i "${video.src}" -c:v libx264 -r 30 -g 30 -keyint_min 30 -movflags +faststart -c:a copy output.mp4`;
8716
8760
  (async () => {
@@ -9129,7 +9173,7 @@ function resolveEntryHtmlPath(input) {
9129
9173
  const rawEntry = readTextFile2(htmlPath);
9130
9174
  if (entryFile === "index.html" || !isTemplateEntry(rawEntry)) return htmlPath;
9131
9175
  const projectIndexPath = join19(projectDir, "index.html");
9132
- if (!existsSync13(projectIndexPath)) {
9176
+ if (!existsSync12(projectIndexPath)) {
9133
9177
  throw new Error(
9134
9178
  `Template entry file "${entryFile}" requires a project index.html to extract its render shell.`
9135
9179
  );
@@ -9437,8 +9481,15 @@ function hasRuntimeMediaChanges(html) {
9437
9481
  }
9438
9482
  return false;
9439
9483
  }
9484
+ function checksVariablesInBrowser(config) {
9485
+ return config.strictVariables === true && Object.keys(config.variables ?? {}).length > 0;
9486
+ }
9487
+ function strictVariablesAttestation(config, probeSession) {
9488
+ if (config.strictVariables !== true) return void 0;
9489
+ return !checksVariablesInBrowser(config) || probeSession?.strictVariablesChecked === true;
9490
+ }
9440
9491
  function probeRequiresBrowser(args) {
9441
- return args.durationSeconds <= 0 || args.unresolvedCompositionCount > 0 || args.hasAutoStart || args.hasScriptedAudio || args.hasVariableMedia || args.hasInsertedMedia;
9492
+ return args.requiresVariablesCheck === true || args.durationSeconds <= 0 || args.unresolvedCompositionCount > 0 || args.hasAutoStart || args.hasScriptedAudio || args.hasVariableMedia || args.hasInsertedMedia;
9442
9493
  }
9443
9494
  function reportedLengthSource(source) {
9444
9495
  if (!source) return null;
@@ -9462,7 +9513,8 @@ async function runProbeStage(input) {
9462
9513
  height,
9463
9514
  needsAlpha,
9464
9515
  deviceScaleFactor,
9465
- subTimelineWaitMemo
9516
+ subTimelineWaitMemo,
9517
+ staticDedupMemo
9466
9518
  } = input;
9467
9519
  let { compiled } = input;
9468
9520
  const probeCfg = cfg.forceScreenshot === forceScreenshot ? cfg : { ...cfg, forceScreenshot };
@@ -9485,7 +9537,8 @@ async function runProbeStage(input) {
9485
9537
  hasAutoStart,
9486
9538
  hasScriptedAudio,
9487
9539
  hasVariableMedia,
9488
- hasInsertedMedia
9540
+ hasInsertedMedia,
9541
+ requiresVariablesCheck: checksVariablesInBrowser(job.config)
9489
9542
  });
9490
9543
  try {
9491
9544
  if (needsBrowser) {
@@ -9519,11 +9572,16 @@ async function runProbeStage(input) {
9519
9572
  job.config.quality
9520
9573
  ),
9521
9574
  variables: job.config.variables,
9575
+ strictVariables: job.config.strictVariables,
9522
9576
  deviceScaleFactor,
9523
9577
  motionBlur,
9524
9578
  pageMotionBlur: job.config.pageMotionBlur,
9525
9579
  requiresWebGpu: compositionRequiresWebGpu(compiled.html),
9526
- subTimelineWaitMemo
9580
+ subTimelineWaitMemo,
9581
+ staticDedupMemo,
9582
+ compositionHash: computeCompositionObservabilityHash(compiled.html),
9583
+ deferStaticDedup: true,
9584
+ onStaticDedupActivity: () => noteStaticDedupActivity(job)
9527
9585
  };
9528
9586
  const PROBE_MAX_ATTEMPTS = 2;
9529
9587
  for (let attempt = 1; attempt <= PROBE_MAX_ATTEMPTS; attempt++) {
@@ -9920,6 +9978,7 @@ async function runProbeStage(input) {
9920
9978
  }
9921
9979
  }
9922
9980
  return {
9981
+ strictVariablesChecked: strictVariablesAttestation(job.config, probeSession),
9923
9982
  compiled,
9924
9983
  fileServer,
9925
9984
  probeSession,
@@ -10012,7 +10071,7 @@ function validateDistributedDuration(input) {
10012
10071
  }
10013
10072
 
10014
10073
  // src/services/render/stages/extractVideosStage.ts
10015
- import { existsSync as existsSync14 } from "node:fs";
10074
+ import { existsSync as existsSync13 } from "node:fs";
10016
10075
  import { join as join21 } from "node:path";
10017
10076
  import {
10018
10077
  classifyVideoExtractionError,
@@ -10287,7 +10346,7 @@ async function runExtractVideosStage(input) {
10287
10346
  const probeFailures = await Promise.all(
10288
10347
  composition.videos.map(async (v) => {
10289
10348
  const videoPath = resolveProjectRelativeSrc3(v.src, projectDir, compiledDir);
10290
- if (!existsSync14(videoPath)) return null;
10349
+ if (!existsSync13(videoPath)) return null;
10291
10350
  try {
10292
10351
  const attempted = extractionPolicy.maxTransientRetries === 0 ? { result: await extractMediaMetadata3(videoPath), retries: 0 } : await runVideoExtractionWithRetry2(() => extractMediaMetadata3(videoPath), {
10293
10352
  signal: abortSignal,
@@ -10325,7 +10384,7 @@ async function runExtractVideosStage(input) {
10325
10384
  const probed = await Promise.all(
10326
10385
  composition.images.map(async (img) => {
10327
10386
  const imgPath = resolveProjectRelativeSrc3(img.src, projectDir, compiledDir);
10328
- if (!existsSync14(imgPath)) return null;
10387
+ if (!existsSync13(imgPath)) return null;
10329
10388
  const colorSpace = await probeColorSpaceSafely(imgPath, log);
10330
10389
  if (isHdrColorSpace2(colorSpace)) {
10331
10390
  nativeHdrImageIds.add(img.id);
@@ -10445,7 +10504,7 @@ async function appendVideoAudioFromProbe(input) {
10445
10504
  videos.map(async (video) => {
10446
10505
  const path = isHttpUrl2(video.src) ? video.src : resolveProjectRelativeSrc3(video.src, projectDir, compiledDir);
10447
10506
  const readFrom = urlByAbsentLocalPath?.get(path) ?? path;
10448
- if (!isHttpUrl2(readFrom) && !existsSync14(readFrom)) return null;
10507
+ if (!isHttpUrl2(readFrom) && !existsSync13(readFrom)) return null;
10449
10508
  const metadata = await extractMediaMetadata3(readFrom);
10450
10509
  const window2 = await resolveFinalFrameExtractionWindow2(
10451
10510
  readFrom,
@@ -10465,7 +10524,7 @@ async function appendVideoAudioFromProbe(input) {
10465
10524
  }
10466
10525
 
10467
10526
  // src/services/render/videoLayerPassthroughPlan.ts
10468
- import { existsSync as existsSync15 } from "node:fs";
10527
+ import { existsSync as existsSync14 } from "node:fs";
10469
10528
  import {
10470
10529
  buildVideoLayerInput,
10471
10530
  isHttpUrl as isHttpUrl3,
@@ -10533,7 +10592,7 @@ async function planVideoLayerPassthrough(input) {
10533
10592
  const { video } = q;
10534
10593
  if (isHttpUrl3(video.src)) return { reason: "remote_source" };
10535
10594
  const path = resolveProjectRelativeSrc4(video.src, input.projectDir, input.compiledDir);
10536
- if (!existsSync15(path)) return { reason: "source_missing" };
10595
+ if (!existsSync14(path)) return { reason: "source_missing" };
10537
10596
  const layout = await probeVideoLayout(input.page, video.id, input.canvas, input.duration);
10538
10597
  if ("reason" in layout) return layout;
10539
10598
  const layer = await buildVideoLayerInput(
@@ -10548,7 +10607,7 @@ async function planVideoLayerPassthrough(input) {
10548
10607
  }
10549
10608
 
10550
10609
  // src/services/render/stages/audioStage.ts
10551
- import { existsSync as existsSync17 } from "node:fs";
10610
+ import { existsSync as existsSync16 } from "node:fs";
10552
10611
  import { join as join24 } from "node:path";
10553
10612
  import {
10554
10613
  MIXED_AUDIO_FILENAME,
@@ -10559,7 +10618,7 @@ import {
10559
10618
  } from "@hyperframes/engine";
10560
10619
 
10561
10620
  // src/services/render/audioDeliveryLimit.ts
10562
- import { existsSync as existsSync16 } from "node:fs";
10621
+ import { existsSync as existsSync15 } from "node:fs";
10563
10622
  import { dirname as dirname10, join as join23 } from "node:path";
10564
10623
  import {
10565
10624
  applyAudioFxChain,
@@ -11068,7 +11127,7 @@ async function limitDeliveryPeaks(input, deps = {
11068
11127
  applyChain: applyAudioFxChain,
11069
11128
  encode: encodeAac2,
11070
11129
  rename: renameWithRetry6,
11071
- sourceExists: existsSync16
11130
+ sourceExists: existsSync15
11072
11131
  }) {
11073
11132
  const { audioPath, sourcePath, signal, timeoutMs } = input;
11074
11133
  if (!deps.sourceExists(sourcePath)) return { success: true };
@@ -11163,7 +11222,7 @@ async function runAudioStageScoped(input) {
11163
11222
  );
11164
11223
  audioLoweredDb = guard.loweredDb;
11165
11224
  input.log?.info("[audio] phases", { ...result.audioPhaseMs, guard: Date.now() - guardStart });
11166
- if (input.keepDeliverySource && !guard.sourceStale && existsSync17(pcmSourcePath)) {
11225
+ if (input.keepDeliverySource && !guard.sourceStale && existsSync16(pcmSourcePath)) {
11167
11226
  deliverySourcePath = pcmSourcePath;
11168
11227
  }
11169
11228
  }
@@ -11291,7 +11350,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
11291
11350
  }
11292
11351
 
11293
11352
  // src/services/render/stages/captureStage.ts
11294
- import { existsSync as existsSync18, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
11353
+ import { existsSync as existsSync17, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
11295
11354
  import { join as join25 } from "node:path";
11296
11355
  import {
11297
11356
  classifyCaptureFailure as classifyCaptureFailure2,
@@ -11362,7 +11421,7 @@ function diskCaptureShortfallError(needBytes, freeBytes, framesDir, basis, remed
11362
11421
  }
11363
11422
  function measureCaptureFrameBytes(workDir, framesDir) {
11364
11423
  let total = sampleDirectoryBytes(framesDir);
11365
- if (!existsSync18(workDir)) return total;
11424
+ if (!existsSync17(workDir)) return total;
11366
11425
  for (const attempt of readdirSync4(workDir)) {
11367
11426
  if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
11368
11427
  total += sampleDirectoryBytes(join25(workDir, attempt));
@@ -11544,7 +11603,7 @@ async function runSequentialDiskCapture(input, captureOptions, captureCfg, check
11544
11603
  captureBeyondViewport = session.options.captureBeyondViewport;
11545
11604
  try {
11546
11605
  if (probeSession) {
11547
- prepareCaptureSessionForReuse3(session, framesDir, videoInjector);
11606
+ await prepareCaptureSessionForReuse3(session, framesDir, videoInjector);
11548
11607
  probeSession = null;
11549
11608
  }
11550
11609
  await ensureSessionReady(session, {
@@ -11669,7 +11728,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
11669
11728
  }
11670
11729
 
11671
11730
  // src/services/render/stages/captureHdrStage.ts
11672
- import { existsSync as existsSync20, mkdirSync as mkdirSync10 } from "node:fs";
11731
+ import { existsSync as existsSync19, mkdirSync as mkdirSync10 } from "node:fs";
11673
11732
  import { join as join29 } from "node:path";
11674
11733
  import {
11675
11734
  closeCaptureSession as closeCaptureSession7,
@@ -11915,7 +11974,7 @@ import { Worker } from "node:worker_threads";
11915
11974
  import { fileURLToPath as fileURLToPath3, pathToFileURL } from "node:url";
11916
11975
  import { dirname as dirname11, join as join27 } from "node:path";
11917
11976
  import { createRequire } from "node:module";
11918
- import { existsSync as existsSync19 } from "node:fs";
11977
+ import { existsSync as existsSync18 } from "node:fs";
11919
11978
  import { cpus as cpus2 } from "node:os";
11920
11979
  function resolveWorkerEntry(explicit) {
11921
11980
  if (explicit && explicit.length > 0) {
@@ -11928,7 +11987,7 @@ function resolveWorkerEntry(explicit) {
11928
11987
  }
11929
11988
  const moduleDir = dirname11(fileURLToPath3(import.meta.url));
11930
11989
  const jsPath = join27(moduleDir, "shaderTransitionWorker.js");
11931
- if (existsSync19(jsPath)) return { path: jsPath, isTs: false };
11990
+ if (existsSync18(jsPath)) return { path: jsPath, isTs: false };
11932
11991
  const tsPath = join27(moduleDir, "shaderTransitionWorker.ts");
11933
11992
  return { path: tsPath, isTs: true };
11934
11993
  }
@@ -12489,7 +12548,7 @@ async function runCaptureHdrStage(input) {
12489
12548
  }
12490
12549
  const debugDumpEnabled = process.env.KEEP_TEMP === "1";
12491
12550
  const debugDumpDir = debugDumpEnabled ? join29(framesDir, "debug-composite") : null;
12492
- if (debugDumpDir && !existsSync20(debugDumpDir)) {
12551
+ if (debugDumpDir && !existsSync19(debugDumpDir)) {
12493
12552
  mkdirSync10(debugDumpDir, { recursive: true });
12494
12553
  }
12495
12554
  const compositeTransfer = resolveCompositeTransfer(hasHdrContent, effectiveHdr);
@@ -12646,7 +12705,7 @@ async function runCaptureHdrStage(input) {
12646
12705
  // src/services/render/stages/encodeStage.ts
12647
12706
  import {
12648
12707
  copyFileSync as copyFileSync4,
12649
- existsSync as existsSync21,
12708
+ existsSync as existsSync20,
12650
12709
  mkdirSync as mkdirSync11,
12651
12710
  readdirSync as readdirSync5,
12652
12711
  readFileSync as readFileSync9,
@@ -12780,7 +12839,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
12780
12839
  const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
12781
12840
  if (failure) return failure;
12782
12841
  }
12783
- const fileSize = existsSync21(outputPath) ? statSync8(outputPath).size : 0;
12842
+ const fileSize = existsSync20(outputPath) ? statSync8(outputPath).size : 0;
12784
12843
  return {
12785
12844
  success: true,
12786
12845
  outputPath,
@@ -12941,7 +13000,7 @@ async function runEncodeStage(input) {
12941
13000
  const stage5Start = Date.now();
12942
13001
  if (isPngSequence) {
12943
13002
  const encoded = startEncodeProgress(job, "Writing PNG sequence", onProgress);
12944
- if (!existsSync21(outputPath)) mkdirSync11(outputPath, { recursive: true });
13003
+ if (!existsSync20(outputPath)) mkdirSync11(outputPath, { recursive: true });
12945
13004
  const captured = readdirSync5(framesDir).filter((name) => name.endsWith(".png")).sort();
12946
13005
  if (captured.length === 0) {
12947
13006
  throw new Error(
@@ -12952,7 +13011,7 @@ async function runEncodeStage(input) {
12952
13011
  const dst = join30(outputPath, formatExportFrameName(i, "png"));
12953
13012
  copyFileSync4(join30(framesDir, name), dst);
12954
13013
  });
12955
- if (hasAudio && audioOutputPath && existsSync21(audioOutputPath)) {
13014
+ if (hasAudio && audioOutputPath && existsSync20(audioOutputPath)) {
12956
13015
  copyFileSync4(audioOutputPath, join30(outputPath, MIXED_AUDIO_FILENAME2));
12957
13016
  log.info(
12958
13017
  `[Render] png-sequence: ${MIXED_AUDIO_FILENAME2} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME2}`
@@ -13341,7 +13400,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
13341
13400
  let rangeStart = null;
13342
13401
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
13343
13402
  const framePath = join31(framesDir, formatCaptureFrameName(frameIndex, frameExt));
13344
- const missing = !existsSync22(framePath) || statSync9(framePath).size <= 8;
13403
+ const missing = !existsSync21(framePath) || statSync9(framePath).size <= 8;
13345
13404
  if (missing && rangeStart === null) {
13346
13405
  rangeStart = frameIndex;
13347
13406
  } else if (!missing && rangeStart !== null) {
@@ -13448,7 +13507,8 @@ function frameStallRule(job, totalFrames, probeStartupMs) {
13448
13507
  complete: () => (job.framesRendered ?? 0) >= totalFrames,
13449
13508
  tailMs: Math.max(TAIL_STALL_MS, noProgressMs),
13450
13509
  detail: () => describeWorkerPhases(job),
13451
- attemptOpened: () => forgetWorkerPhases(job)
13510
+ attemptOpened: () => forgetWorkerPhases(job),
13511
+ activity: () => staticDedupActivity(job)
13452
13512
  };
13453
13513
  }
13454
13514
  function isRecoverableParallelCaptureError(error) {
@@ -13473,7 +13533,7 @@ function countCapturedFrames(totalFrames, framesDir, frameExt) {
13473
13533
  let captured = 0;
13474
13534
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
13475
13535
  const framePath = join31(framesDir, formatCaptureFrameName(frameIndex, frameExt));
13476
- if (existsSync22(framePath)) captured++;
13536
+ if (existsSync21(framePath)) captured++;
13477
13537
  }
13478
13538
  return captured;
13479
13539
  }
@@ -14139,7 +14199,7 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
14139
14199
  validateChromaSubsamplingConfig(job.config);
14140
14200
  const debugDir = resolveRenderDebugDir();
14141
14201
  const outputDir = dirname13(outputPath);
14142
- if (!existsSync22(outputDir)) mkdirSync12(outputDir, { recursive: true });
14202
+ if (!existsSync21(outputDir)) mkdirSync12(outputDir, { recursive: true });
14143
14203
  const workDir = job.config.debug ? join31(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
14144
14204
  const pipelineStart = Date.now();
14145
14205
  const baseLog = job.config.logger ?? defaultLogger;
@@ -14281,7 +14341,7 @@ async function executeRenderPipeline(input) {
14281
14341
  job.startedAt = /* @__PURE__ */ new Date();
14282
14342
  assertNotAborted();
14283
14343
  assertConfiguredFfmpegBinariesExist();
14284
- if (!existsSync22(workDir)) mkdirSync12(workDir, { recursive: true });
14344
+ if (!existsSync21(workDir)) mkdirSync12(workDir, { recursive: true });
14285
14345
  if (job.config.debug) {
14286
14346
  log.info("[Render] Debug artifacts enabled", { workDir, logPath });
14287
14347
  }
@@ -14311,7 +14371,7 @@ async function executeRenderPipeline(input) {
14311
14371
  });
14312
14372
  const entryFile = job.config.entryFile || "index.html";
14313
14373
  const htmlPath = join31(projectDir, entryFile);
14314
- if (!existsSync22(htmlPath)) {
14374
+ if (!existsSync21(htmlPath)) {
14315
14375
  throw new Error(`Entry file not found: ${htmlPath}`);
14316
14376
  }
14317
14377
  assertNotAborted();
@@ -14403,6 +14463,7 @@ async function executeRenderPipeline(input) {
14403
14463
  (result) => Object.assign(job, result)
14404
14464
  );
14405
14465
  const subTimelineWaitMemo = {};
14466
+ const staticDedupMemo = {};
14406
14467
  const probeResult = await observeRenderStage(
14407
14468
  observability,
14408
14469
  "browser_probe",
@@ -14423,6 +14484,7 @@ async function executeRenderPipeline(input) {
14423
14484
  needsAlpha,
14424
14485
  deviceScaleFactor,
14425
14486
  subTimelineWaitMemo,
14487
+ staticDedupMemo,
14426
14488
  recordReferenceBackground
14427
14489
  }),
14428
14490
  // Browser probe is pre-capture; report `browser calibrating` so a
@@ -14434,6 +14496,7 @@ async function executeRenderPipeline(input) {
14434
14496
  compositionHash = computeCompositionObservabilityHash(compiled.html);
14435
14497
  fileServer = probeResult.fileServer;
14436
14498
  probeSession = probeResult.probeSession;
14499
+ job.strictVariablesChecked = probeResult.strictVariablesChecked;
14437
14500
  lastBrowserConsole = probeResult.lastBrowserConsole;
14438
14501
  let resolvedCaptureBeyondViewport = probeSession?.options.captureBeyondViewport;
14439
14502
  if (resolvedCaptureBeyondViewport !== void 0) {
@@ -14655,7 +14718,7 @@ async function executeRenderPipeline(input) {
14655
14718
  throw new Error("File server failed to initialize before frame capture");
14656
14719
  }
14657
14720
  const framesDir = join31(workDir, "captured-frames");
14658
- if (!existsSync22(framesDir)) mkdirSync12(framesDir, { recursive: true });
14721
+ if (!existsSync21(framesDir)) mkdirSync12(framesDir, { recursive: true });
14659
14722
  updateJobStatus(job, "rendering", "Checking browser GPU", 25, onProgress, {
14660
14723
  code: "start_browsers"
14661
14724
  });
@@ -14714,6 +14777,9 @@ async function executeRenderPipeline(input) {
14714
14777
  videoMetadataHints,
14715
14778
  skipReadinessVideoIds: videoReadinessSkipIds,
14716
14779
  subTimelineWaitMemo,
14780
+ staticDedupMemo,
14781
+ compositionHash,
14782
+ onStaticDedupActivity: () => noteStaticDedupActivity(job),
14717
14783
  // Probe-resolved duration: drawElement self-verification derives its
14718
14784
  // sample frame indices from this so they land inside the drained range.
14719
14785
  compositionDurationSeconds: job.duration,
@@ -16060,7 +16126,7 @@ async function executeRenderPipeline(input) {
16060
16126
  })
16061
16127
  );
16062
16128
  const totalElapsed = Date.now() - pipelineStart;
16063
- const tmpPeakBytes = existsSync22(workDir) ? sampleDirectoryBytes(workDir) : 0;
16129
+ const tmpPeakBytes = existsSync21(workDir) ? sampleDirectoryBytes(workDir) : 0;
16064
16130
  recordTransientRetryObservability();
16065
16131
  observability.checkpoint("pipeline", "artifact validated", { totalElapsedMs: totalElapsed });
16066
16132
  const observabilitySummary = observability.summary({
@@ -16141,7 +16207,7 @@ async function executeRenderPipeline(input) {
16141
16207
  }
16142
16208
  }
16143
16209
  if (job.config.debug) {
16144
- if (!isPngSequence && !isHls && existsSync22(stagedOutputPath)) {
16210
+ if (!isPngSequence && !isHls && existsSync21(stagedOutputPath)) {
16145
16211
  const debugOutput = join31(workDir, `output${videoExt}`);
16146
16212
  copyFileSync5(stagedOutputPath, debugOutput);
16147
16213
  }
@@ -16654,7 +16720,7 @@ import { audioFailureDiagnostics as audioFailureDiagnostics3 } from "@hyperframe
16654
16720
  import {
16655
16721
  copyFileSync as copyFileSync6,
16656
16722
  cpSync as cpSync2,
16657
- existsSync as existsSync27,
16723
+ existsSync as existsSync26,
16658
16724
  linkSync,
16659
16725
  mkdirSync as mkdirSync16,
16660
16726
  rmSync as rmSync14,
@@ -16685,7 +16751,7 @@ import {
16685
16751
  } from "@hyperframes/engine";
16686
16752
 
16687
16753
  // src/services/distributed/chunkFrames.ts
16688
- import { existsSync as existsSync24, readdirSync as readdirSync7 } from "node:fs";
16754
+ import { existsSync as existsSync23, readdirSync as readdirSync7 } from "node:fs";
16689
16755
  import { extname as extname4, join as join34 } from "node:path";
16690
16756
  import {
16691
16757
  compositionRequiresWebGpu as compositionRequiresWebGpu3,
@@ -16696,7 +16762,7 @@ import {
16696
16762
  // src/services/distributed/shared.ts
16697
16763
  import { execFile as execFileCallback } from "node:child_process";
16698
16764
  import { dirname as dirname15, join as join33 } from "node:path";
16699
- import { existsSync as existsSync23, readFileSync as readFileSync10 } from "node:fs";
16765
+ import { existsSync as existsSync22, readFileSync as readFileSync10 } from "node:fs";
16700
16766
  import { fileURLToPath as fileURLToPath5 } from "node:url";
16701
16767
  import { promisify as promisify2 } from "node:util";
16702
16768
  import {
@@ -16712,7 +16778,7 @@ function isPlanAudioArtifactPath(path) {
16712
16778
  function resolvePlanAudioPath(planDir) {
16713
16779
  for (const name of [PLAN_AUDIO_RELATIVE_PATH, PLAN_AUDIO_LEGACY_RELATIVE_PATH]) {
16714
16780
  const candidate = join33(planDir, name);
16715
- if (existsSync23(candidate)) return candidate;
16781
+ if (existsSync22(candidate)) return candidate;
16716
16782
  }
16717
16783
  return null;
16718
16784
  }
@@ -16962,6 +17028,7 @@ function buildSyntheticRenderJob(input) {
16962
17028
  strictness: input.strictness,
16963
17029
  producerConfig: input.producerConfig,
16964
17030
  variables: input.variables,
17031
+ strictVariables: input.strictVariables,
16965
17032
  pageMotionBlur: input.pageMotionBlur
16966
17033
  };
16967
17034
  return createRenderJob(renderConfig);
@@ -16973,7 +17040,7 @@ function readProducerVersion() {
16973
17040
  let current = startDir;
16974
17041
  for (let i = 0; i < 10; i++) {
16975
17042
  const candidate = join33(current, "package.json");
16976
- if (existsSync23(candidate)) {
17043
+ if (existsSync22(candidate)) {
16977
17044
  try {
16978
17045
  const pkg = JSON.parse(readFileSync10(candidate, "utf-8"));
16979
17046
  if (pkg.name === "@hyperframes/producer" && typeof pkg.version === "string") {
@@ -17028,7 +17095,7 @@ function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v
17028
17095
  const result = [];
17029
17096
  for (const v of videos) {
17030
17097
  const outputDir = join34(planDir, "video-frames", mediaIdPathSegment3(v.videoId));
17031
- if (!existsSync24(outputDir)) {
17098
+ if (!existsSync23(outputDir)) {
17032
17099
  throw new Error(
17033
17100
  `[renderChunk] planDir missing extracted video frames for ${JSON.stringify(v.videoId)}: ${outputDir} not present. plan() should have written frames here; the planDir is malformed.`
17034
17101
  );
@@ -17127,7 +17194,7 @@ async function extractDeferredVideoFramesForChunk(input) {
17127
17194
  const range = planned.get(video.videoId).deferredRange;
17128
17195
  const remoteUrl = remoteSources[range.sourcePath];
17129
17196
  const sourcePath = remoteUrl ?? join34(input.planDir, ...range.sourcePath.split("/"));
17130
- if (remoteUrl === void 0 && !existsSync24(sourcePath)) {
17197
+ if (remoteUrl === void 0 && !existsSync23(sourcePath)) {
17131
17198
  throw new RenderChunkValidationError(
17132
17199
  MISSING_PLAN_ARTIFACT,
17133
17200
  `[renderChunk] planDir is missing the source for video ${JSON.stringify(video.videoId)}: ${range.sourcePath}`
@@ -17327,7 +17394,7 @@ async function readPlanReferenceBackground(input) {
17327
17394
  }
17328
17395
 
17329
17396
  // src/services/render/stages/freezePlan.ts
17330
- import { existsSync as existsSync25, mkdirSync as mkdirSync14, readFileSync as readFileSync11, readdirSync as readdirSync8, writeFileSync as writeFileSync8 } from "node:fs";
17397
+ import { existsSync as existsSync24, mkdirSync as mkdirSync14, readFileSync as readFileSync11, readdirSync as readdirSync8, writeFileSync as writeFileSync8 } from "node:fs";
17331
17398
  import { join as join37, relative as relative3, resolve as resolve9 } from "node:path";
17332
17399
  import {
17333
17400
  REFERENCE_BACKGROUND_FIELD,
@@ -17521,7 +17588,7 @@ function planFileSha256(absolutePath, digests) {
17521
17588
  return sha256;
17522
17589
  }
17523
17590
  async function prehashPlanFiles(dir, digests) {
17524
- if (!existsSync25(dir)) return;
17591
+ if (!existsSync24(dir)) return;
17525
17592
  for (const { absolutePath } of listPlanFiles(dir)) {
17526
17593
  if (!digests.has(absolutePath)) digests.set(absolutePath, await sha256FileAsync(absolutePath));
17527
17594
  }
@@ -17591,15 +17658,15 @@ function writePlanRemoteFiles(planDir, files) {
17591
17658
  }
17592
17659
  function readPlanRemoteFiles(planDir) {
17593
17660
  const path = join37(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH);
17594
- return existsSync25(path) ? JSON.parse(readFileSync11(path, "utf-8")) : [];
17661
+ return existsSync24(path) ? JSON.parse(readFileSync11(path, "utf-8")) : [];
17595
17662
  }
17596
17663
  function recomputePlanHashFromPlanDir(planDir, digests) {
17597
17664
  const planJsonPath = join37(planDir, "plan.json");
17598
17665
  const encoderJsonPath = join37(planDir, "meta", "encoder.json");
17599
- if (!existsSync25(planJsonPath)) {
17666
+ if (!existsSync24(planJsonPath)) {
17600
17667
  throw new Error(`[freezePlan] plan.json missing: ${planJsonPath}`);
17601
17668
  }
17602
- if (!existsSync25(encoderJsonPath)) {
17669
+ if (!existsSync24(encoderJsonPath)) {
17603
17670
  throw new Error(`[freezePlan] meta/encoder.json missing: ${encoderJsonPath}`);
17604
17671
  }
17605
17672
  const planJson = JSON.parse(readFileSync11(planJsonPath, "utf-8"));
@@ -17629,11 +17696,11 @@ async function freezePlan(input) {
17629
17696
  hasAudio,
17630
17697
  digests
17631
17698
  } = input;
17632
- if (!existsSync25(planDir)) {
17699
+ if (!existsSync24(planDir)) {
17633
17700
  throw new Error(`[freezePlan] planDir does not exist: ${planDir}`);
17634
17701
  }
17635
17702
  const metaDir = join37(planDir, "meta");
17636
- if (!existsSync25(metaDir)) mkdirSync14(metaDir, { recursive: true });
17703
+ if (!existsSync24(metaDir)) mkdirSync14(metaDir, { recursive: true });
17637
17704
  writeFileSync8(
17638
17705
  join37(metaDir, "composition.json"),
17639
17706
  `${JSON.stringify(composition, null, 2)}
@@ -17710,7 +17777,7 @@ function applyRuntimeEnvSnapshot(snapshot, env = process.env) {
17710
17777
  }
17711
17778
 
17712
17779
  // src/services/distributed/chunkAudio.ts
17713
- import { closeSync as closeSync6, existsSync as existsSync26, ftruncateSync, mkdirSync as mkdirSync15, openSync as openSync6, readFileSync as readFileSync12 } from "node:fs";
17780
+ import { closeSync as closeSync6, existsSync as existsSync25, ftruncateSync, mkdirSync as mkdirSync15, openSync as openSync6, readFileSync as readFileSync12 } from "node:fs";
17714
17781
  import { writeFileSync as writeFileSync9, writeSync } from "node:fs";
17715
17782
  import { join as join38 } from "node:path";
17716
17783
  import { appendRenderProvenanceArgs, describeFfmpegFailure as describeFfmpegFailure4, runFfmpeg as runFfmpeg7 } from "@hyperframes/engine";
@@ -17816,7 +17883,7 @@ async function writeChunkAudioSlices(input) {
17816
17883
  }
17817
17884
  function chunkAudioSource(planDir, chunkIndex, scratchPath) {
17818
17885
  const layoutPath = join38(planDir, SLICE_LAYOUT);
17819
- if (!existsSync26(layoutPath)) return resolvePlanAudioPath(planDir);
17886
+ if (!existsSync25(layoutPath)) return resolvePlanAudioPath(planDir);
17820
17887
  const layout = JSON.parse(readFileSync12(layoutPath, "utf-8"));
17821
17888
  const frame = readFileSync12(join38(planDir, SLICE_FRAME));
17822
17889
  const fd = openSync6(scratchPath, "w");
@@ -18380,7 +18447,7 @@ function createVideoSourceShipper(input) {
18380
18447
  let result = null;
18381
18448
  for (const root of stagedRel === null ? [input.workCompiledDir, input.projectDir] : []) {
18382
18449
  const rel = pathInside(root, srcPath);
18383
- if (rel !== null && (existsSync27(join40(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
18450
+ if (rel !== null && (existsSync26(join40(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
18384
18451
  result = ["compiled", ...rel.split(sep3)].join("/");
18385
18452
  break;
18386
18453
  }
@@ -18408,7 +18475,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
18408
18475
  useGpu: false,
18409
18476
  browserGpuMode: "software"
18410
18477
  });
18411
- if (!existsSync27(planDir)) mkdirSync16(planDir, { recursive: true });
18478
+ if (!existsSync26(planDir)) mkdirSync16(planDir, { recursive: true });
18412
18479
  const log = config.logger ?? defaultLogger;
18413
18480
  const sizeLimitBytes = options.executionPlanSizeLimitBytes ?? config.planDirSizeLimitBytes ?? PLAN_DIR_SIZE_LIMIT_BYTES;
18414
18481
  const abortSignal = config.abortSignal;
@@ -18435,11 +18502,12 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
18435
18502
  logger: config.logger,
18436
18503
  producerConfig: cfg,
18437
18504
  variables: config.variables,
18505
+ strictVariables: config.strictVariables,
18438
18506
  pageMotionBlur: config.pageMotionBlur
18439
18507
  });
18440
18508
  const entryFile = config.entryFile ?? "index.html";
18441
18509
  const htmlPath = join40(projectDir, entryFile);
18442
- if (!existsSync27(htmlPath)) {
18510
+ if (!existsSync26(htmlPath)) {
18443
18511
  throw new Error(`[plan] entry file not found: ${htmlPath}`);
18444
18512
  }
18445
18513
  const workDir = join40(planDir, ".plan-work");
@@ -18547,6 +18615,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
18547
18615
  logPlanStage(log, "reference_background", stageStarted);
18548
18616
  }
18549
18617
  compiled = probeResult.compiled;
18618
+ job.strictVariablesChecked = probeResult.strictVariablesChecked;
18550
18619
  job.duration = probeResult.duration;
18551
18620
  job.totalFrames = probeResult.totalFrames;
18552
18621
  const totalFrames = probeResult.totalFrames;
@@ -18667,15 +18736,15 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
18667
18736
  logPlanStage(log, "extract", stageStarted);
18668
18737
  const stagedVideoFrames = join40(compiledDir, "__hyperframes_video_frames");
18669
18738
  const videoFramesDst = join40(planDir, "video-frames");
18670
- if (existsSync27(videoFramesDst)) rmSync14(videoFramesDst, { recursive: true, force: true });
18739
+ if (existsSync26(videoFramesDst)) rmSync14(videoFramesDst, { recursive: true, force: true });
18671
18740
  const videoSourcesDir = join40(planDir, "video-sources");
18672
18741
  rmSync14(videoSourcesDir, { recursive: true, force: true });
18673
- if (existsSync27(stagedVideoFrames)) {
18742
+ if (existsSync26(stagedVideoFrames)) {
18674
18743
  renameWithRetry8(stagedVideoFrames, videoFramesDst);
18675
18744
  } else {
18676
18745
  mkdirSync16(videoFramesDst, { recursive: true });
18677
18746
  }
18678
- if (existsSync27(finalCompiledDir)) rmSync14(finalCompiledDir, { recursive: true, force: true });
18747
+ if (existsSync26(finalCompiledDir)) rmSync14(finalCompiledDir, { recursive: true, force: true });
18679
18748
  renameWithRetry8(compiledDir, finalCompiledDir);
18680
18749
  const shipVideoSource = createVideoSourceShipper({
18681
18750
  planDir,
@@ -18796,10 +18865,10 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
18796
18865
  applyDistributedAudioWarningPolicy(job, audioResult.audioError, audioResult.audioFailures, log);
18797
18866
  }
18798
18867
  const planAudioPath = join40(planDir, PLAN_AUDIO_RELATIVE_PATH);
18799
- if (audioResult?.hasAudio && existsSync27(audioResult.audioOutputPath)) {
18868
+ if (audioResult?.hasAudio && existsSync26(audioResult.audioOutputPath)) {
18800
18869
  renameWithRetry8(audioResult.audioOutputPath, planAudioPath);
18801
18870
  }
18802
- if (chunksCarryAudio && existsSync27(planAudioPath)) {
18871
+ if (chunksCarryAudio && existsSync26(planAudioPath)) {
18803
18872
  if (options.sliceChunkAudio) {
18804
18873
  stageStarted = Date.now();
18805
18874
  await writeChunkAudioSlices({
@@ -18894,7 +18963,8 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
18894
18963
  height,
18895
18964
  format: config.format,
18896
18965
  ffmpegVersion,
18897
- producerVersion
18966
+ producerVersion,
18967
+ ...job.strictVariablesChecked === void 0 ? {} : { strictVariablesChecked: job.strictVariablesChecked }
18898
18968
  };
18899
18969
  }
18900
18970
  async function plan(projectDir, config, planDir, options = {}) {
@@ -18911,13 +18981,14 @@ async function plan(projectDir, config, planDir, options = {}) {
18911
18981
  height: executionPlan.height,
18912
18982
  format: executionPlan.format,
18913
18983
  ffmpegVersion: executionPlan.ffmpegVersion,
18914
- producerVersion: executionPlan.producerVersion
18984
+ producerVersion: executionPlan.producerVersion,
18985
+ ...executionPlan.strictVariablesChecked === void 0 ? {} : { strictVariablesChecked: executionPlan.strictVariablesChecked }
18915
18986
  };
18916
18987
  }
18917
18988
 
18918
18989
  // src/services/distributed/renderChunk.ts
18919
18990
  import { randomBytes } from "node:crypto";
18920
- import { existsSync as existsSync30, mkdirSync as mkdirSync19, readFileSync as readFileSync14, readdirSync as readdirSync11, rmSync as rmSync17, writeFileSync as writeFileSync13 } from "node:fs";
18991
+ import { existsSync as existsSync29, mkdirSync as mkdirSync19, readFileSync as readFileSync14, readdirSync as readdirSync11, rmSync as rmSync17, writeFileSync as writeFileSync13 } from "node:fs";
18921
18992
  import { cpus as cpus3 } from "node:os";
18922
18993
  import { join as join44 } from "node:path";
18923
18994
  import {
@@ -18944,7 +19015,7 @@ import {
18944
19015
  } from "@hyperframes/engine";
18945
19016
  import {
18946
19017
  copyFileSync as copyFileSync8,
18947
- existsSync as existsSync29,
19018
+ existsSync as existsSync28,
18948
19019
  lstatSync as lstatSync3,
18949
19020
  mkdirSync as mkdirSync18,
18950
19021
  readFileSync as readFileSync13,
@@ -18965,7 +19036,7 @@ import {
18965
19036
  // src/services/distributed/planV2Publisher.ts
18966
19037
  import {
18967
19038
  copyFileSync as copyFileSync7,
18968
- existsSync as existsSync28,
19039
+ existsSync as existsSync27,
18969
19040
  linkSync as linkSync2,
18970
19041
  mkdirSync as mkdirSync17,
18971
19042
  rmSync as rmSync15,
@@ -19034,7 +19105,7 @@ var LocalPlanV2ArtifactPublisher = class {
19034
19105
  #linkFile;
19035
19106
  #committed = false;
19036
19107
  constructor(destinationDir, options = {}) {
19037
- if (existsSync28(destinationDir)) {
19108
+ if (existsSync27(destinationDir)) {
19038
19109
  throw new PlanV2IntegrityError(`output directory already exists: ${destinationDir}`);
19039
19110
  }
19040
19111
  this.destinationDir = destinationDir;
@@ -19051,7 +19122,7 @@ var LocalPlanV2ArtifactPublisher = class {
19051
19122
  );
19052
19123
  }
19053
19124
  const destinationPath = planV2BlobPath(this.temporaryDir, digest);
19054
- if (existsSync28(destinationPath)) return;
19125
+ if (existsSync27(destinationPath)) return;
19055
19126
  mkdirSync17(dirname16(destinationPath), { recursive: true });
19056
19127
  const stagingDir = createStagingDir5(dirname16(destinationPath), ".plan-v2-blob-");
19057
19128
  const temporaryPath = join42(stagingDir, "blob");
@@ -19069,7 +19140,7 @@ var LocalPlanV2ArtifactPublisher = class {
19069
19140
  }
19070
19141
  async commitManifest(manifestBytes) {
19071
19142
  for (const digest of new Set(manifestDigests(manifestBytes))) {
19072
- if (!existsSync28(planV2BlobPath(this.temporaryDir, digest))) {
19143
+ if (!existsSync27(planV2BlobPath(this.temporaryDir, digest))) {
19073
19144
  throw new PlanV2IntegrityError(
19074
19145
  `cannot commit manifest before referenced blob is durable: ${digest}`
19075
19146
  );
@@ -19149,7 +19220,7 @@ function assertValidExtractionCacheCompleteSentinel(path) {
19149
19220
  }
19150
19221
  function validateExtractionCacheCompleteSentinels(executionPlanDir) {
19151
19222
  const videoRoot = join43(executionPlanDir, "video-frames");
19152
- if (!existsSync29(videoRoot)) return;
19223
+ if (!existsSync28(videoRoot)) return;
19153
19224
  for (const videoEntry of readdirSync10(videoRoot, { withFileTypes: true })) {
19154
19225
  if (!videoEntry.isDirectory()) continue;
19155
19226
  const videoDir = join43(videoRoot, videoEntry.name);
@@ -19250,7 +19321,7 @@ function parsePlanVideosJson2(value) {
19250
19321
  }
19251
19322
  function materializeExtractedVideoDirectories(planDir) {
19252
19323
  const videosPath = join43(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
19253
- if (!existsSync29(videosPath)) return;
19324
+ if (!existsSync28(videosPath)) return;
19254
19325
  const videos = parsePlanVideosJson2(readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH));
19255
19326
  for (const video of videos.extracted) {
19256
19327
  mkdirSync18(resolveExtractedVideoOutputDir(planDir, video.videoId), { recursive: true });
@@ -19284,9 +19355,9 @@ function parseChunkSlices(value) {
19284
19355
  }
19285
19356
  function buildVideoChunkDependencies(executionPlanDir, dimensions) {
19286
19357
  const videoRoot = join43(executionPlanDir, "video-frames");
19287
- const hasExtractedFrames = existsSync29(videoRoot) && listFiles(videoRoot).length > 0;
19358
+ const hasExtractedFrames = existsSync28(videoRoot) && listFiles(videoRoot).length > 0;
19288
19359
  const videosPath = join43(executionPlanDir, PLAN_VIDEOS_META_RELATIVE_PATH);
19289
- if (!existsSync29(videosPath)) {
19360
+ if (!existsSync28(videosPath)) {
19290
19361
  return hasExtractedFrames ? { mode: "full-source-pack", dependencies: null } : { mode: "exact-rendered-frames", dependencies: /* @__PURE__ */ new Map() };
19291
19362
  }
19292
19363
  const chunksPath = join43(executionPlanDir, "meta", "chunks.json");
@@ -19343,7 +19414,7 @@ function computeManifestHash(manifest) {
19343
19414
  return sha256Hex(`${PLAN_V2_HASH_PREFIX}${canonicalJsonStringify(manifestPayload(manifest))}`);
19344
19415
  }
19345
19416
  function writeBlob(sourcePath, destinationPath) {
19346
- if (existsSync29(destinationPath)) return;
19417
+ if (existsSync28(destinationPath)) return;
19347
19418
  mkdirSync18(dirname17(destinationPath), { recursive: true });
19348
19419
  const temporaryDir = createStagingDir6(dirname17(destinationPath), ".plan-v2-blob-");
19349
19420
  const temporaryPath = join43(temporaryDir, "blob");
@@ -19383,7 +19454,7 @@ async function putTasks(tasks) {
19383
19454
  }
19384
19455
  function buildPlanV2Publication(executionPlanDir, digests) {
19385
19456
  const executionPlanPath = join43(executionPlanDir, "plan.json");
19386
- if (!existsSync29(executionPlanPath)) {
19457
+ if (!existsSync28(executionPlanPath)) {
19387
19458
  throw new PlanV2IntegrityError(`execution plan is missing plan.json: ${executionPlanPath}`);
19388
19459
  }
19389
19460
  const executionPlanValue = readJsonFile(executionPlanPath, "execution plan.json");
@@ -19463,7 +19534,7 @@ function buildPlanV2Publication(executionPlanDir, digests) {
19463
19534
  };
19464
19535
  }
19465
19536
  function createPlanV2FromExecutionPlan(executionPlanDir, planV2Dir) {
19466
- if (existsSync29(planV2Dir)) {
19537
+ if (existsSync28(planV2Dir)) {
19467
19538
  throw new PlanV2IntegrityError(`output directory already exists: ${planV2Dir}`);
19468
19539
  }
19469
19540
  const publication = buildPlanV2Publication(executionPlanDir);
@@ -19521,7 +19592,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
19521
19592
  const stagingRoot = createStagingDir6(options.stagingParentDir ?? tmpdir3(), ".execution-plan-");
19522
19593
  const digests = /* @__PURE__ */ new Map();
19523
19594
  try {
19524
- await buildLocalExecutionPlan(projectDir, config, stagingRoot, {
19595
+ const planned = await buildLocalExecutionPlan(projectDir, config, stagingRoot, {
19525
19596
  executionPlanSizeLimitBytes: Number.MAX_SAFE_INTEGER,
19526
19597
  deferVideoExtraction: true,
19527
19598
  remoteFiles: options.remoteFiles,
@@ -19537,6 +19608,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
19537
19608
  sliceChunkAudio: true,
19538
19609
  deferAudio: options.deferAudio
19539
19610
  });
19611
+ options.onPlanned?.({ strictVariablesChecked: planned.strictVariablesChecked });
19540
19612
  return await publishExecutionPlan(stagingRoot, publisher, { digests, log: config.logger });
19541
19613
  } catch (error) {
19542
19614
  try {
@@ -19549,7 +19621,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
19549
19621
  }
19550
19622
  }
19551
19623
  async function planV2(projectDir, config, planV2Dir) {
19552
- if (existsSync29(planV2Dir)) {
19624
+ if (existsSync28(planV2Dir)) {
19553
19625
  throw new PlanV2IntegrityError(`output directory already exists: ${planV2Dir}`);
19554
19626
  }
19555
19627
  const publisher = new LocalPlanV2ArtifactPublisher(planV2Dir);
@@ -19703,7 +19775,7 @@ function parsePlanV2Manifest(value) {
19703
19775
  }
19704
19776
  function readPlanV2Manifest(planV2Dir) {
19705
19777
  const manifestPath = join43(planV2Dir, "plan.json");
19706
- if (!existsSync29(manifestPath)) {
19778
+ if (!existsSync28(manifestPath)) {
19707
19779
  throw new PlanV2IntegrityError(`missing v2 manifest: ${manifestPath}`);
19708
19780
  }
19709
19781
  const value = readJsonFile(manifestPath, "v2 manifest");
@@ -19722,7 +19794,7 @@ function listPlanV2ArtifactsForTarget(manifest, target) {
19722
19794
  }
19723
19795
  function verifyBlob(planV2Dir, artifact) {
19724
19796
  const sourcePath = planV2BlobPath(planV2Dir, artifact.sha256);
19725
- if (!existsSync29(sourcePath)) {
19797
+ if (!existsSync28(sourcePath)) {
19726
19798
  throw new PlanV2IntegrityError(`missing content-addressed artifact ${artifact.sha256}`);
19727
19799
  }
19728
19800
  const stats = statSync11(sourcePath);
@@ -19735,7 +19807,7 @@ function verifyBlob(planV2Dir, artifact) {
19735
19807
  return sourcePath;
19736
19808
  }
19737
19809
  function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}) {
19738
- if (existsSync29(destinationDir)) {
19810
+ if (existsSync28(destinationDir)) {
19739
19811
  throw new PlanV2IntegrityError(`materialization destination already exists: ${destinationDir}`);
19740
19812
  }
19741
19813
  const manifest = readPlanV2Manifest(planV2Dir);
@@ -19800,7 +19872,7 @@ function validatePlanV2MaterializedTarget(planDir, expectedTarget) {
19800
19872
  }
19801
19873
  function readValidatedPlanV2Materialization(planDir, expectedTarget) {
19802
19874
  const markerPath = join43(planDir, PLAN_V2_MATERIALIZATION_MARKER);
19803
- if (!existsSync29(markerPath)) return null;
19875
+ if (!existsSync28(markerPath)) return null;
19804
19876
  const marker = readJsonFile(markerPath, "materialization marker");
19805
19877
  if (!isRecord3(marker) || !isRecord3(marker.manifest) || !isRecord3(marker.target)) {
19806
19878
  throw new PlanV2IntegrityError("malformed materialization marker");
@@ -19818,7 +19890,7 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
19818
19890
  for (const artifact of required) {
19819
19891
  if (Object.hasOwn(remoteSources, artifact.path)) continue;
19820
19892
  const path = join43(planDir, ...artifact.path.split("/"));
19821
- if (!existsSync29(path) || statSync11(path).size !== artifact.sizeBytes) {
19893
+ if (!existsSync28(path) || statSync11(path).size !== artifact.sizeBytes) {
19822
19894
  throw new PlanV2IntegrityError(
19823
19895
  `materialized artifact missing or truncated: ${artifact.path}`
19824
19896
  );
@@ -19969,7 +20041,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
19969
20041
  const planJsonPath = join44(planDir, "plan.json");
19970
20042
  const encoderJsonPath = join44(planDir, "meta", "encoder.json");
19971
20043
  const chunksJsonPath = join44(planDir, "meta", "chunks.json");
19972
- if (!existsSync30(planJsonPath)) {
20044
+ if (!existsSync29(planJsonPath)) {
19973
20045
  throw new RenderChunkValidationError(
19974
20046
  MISSING_PLAN_ARTIFACT,
19975
20047
  `[renderChunk] planDir is missing required artifact: ${planJsonPath}`
@@ -19985,7 +20057,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
19985
20057
  const v2Manifest = v2Materialization?.manifest ?? null;
19986
20058
  const remoteSources = v2Materialization?.remoteSources ?? {};
19987
20059
  for (const required of [encoderJsonPath, chunksJsonPath]) {
19988
- if (!existsSync30(required)) {
20060
+ if (!existsSync29(required)) {
19989
20061
  throw new RenderChunkValidationError(
19990
20062
  MISSING_PLAN_ARTIFACT,
19991
20063
  `[renderChunk] planDir is missing required artifact: ${required}`
@@ -19996,7 +20068,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
19996
20068
  const chunks = JSON.parse(readFileSync14(chunksJsonPath, "utf-8"));
19997
20069
  const videosJsonPath = join44(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
19998
20070
  let planVideos = null;
19999
- if (existsSync30(videosJsonPath)) {
20071
+ if (existsSync29(videosJsonPath)) {
20000
20072
  try {
20001
20073
  planVideos = validatePlanVideosForChunk(JSON.parse(readFileSync14(videosJsonPath, "utf-8")));
20002
20074
  } catch (err) {
@@ -20027,7 +20099,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
20027
20099
  const range = resolveChunkFrameRange(slice, chunkIndex, options?.frameRange);
20028
20100
  const framesInChunk = range.endFrame - range.startFrame;
20029
20101
  const compiledDir = join44(planDir, "compiled");
20030
- if (!existsSync30(compiledDir)) {
20102
+ if (!existsSync29(compiledDir)) {
20031
20103
  throw new RenderChunkValidationError(
20032
20104
  MISSING_PLAN_ARTIFACT,
20033
20105
  `[renderChunk] planDir missing compiled/ directory: ${compiledDir}`
@@ -20119,6 +20191,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
20119
20191
  deferredVideos.filter((video) => remoteVideoIds.has(video.videoId))
20120
20192
  )
20121
20193
  });
20194
+ captureOptions.onStaticDedupActivity = () => noteStaticDedupActivity(job);
20122
20195
  const captureFrames = effectiveChunkFrames(framesInChunk, slice.captureCost);
20123
20196
  const chunkWorkerCount = resolveChunkCaptureWorkers(
20124
20197
  captureFrames,
@@ -20278,10 +20351,10 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
20278
20351
  const effectiveBitrate = encoder.crf != null ? void 0 : encoder.bitrate;
20279
20352
  const videoOnlyPath = encoder.chunksCarryAudio ? `${outputChunkPath}.video.mp4` : outputChunkPath;
20280
20353
  if (isPngSequence) {
20281
- if (!existsSync30(outputChunkPath)) mkdirSync19(outputChunkPath, { recursive: true });
20354
+ if (!existsSync29(outputChunkPath)) mkdirSync19(outputChunkPath, { recursive: true });
20282
20355
  } else {
20283
20356
  const outDir = join44(outputChunkPath, "..");
20284
- if (!existsSync30(outDir)) mkdirSync19(outDir, { recursive: true });
20357
+ if (!existsSync29(outDir)) mkdirSync19(outDir, { recursive: true });
20285
20358
  }
20286
20359
  const encodeInput = {
20287
20360
  job,
@@ -20611,7 +20684,8 @@ var SAFE_RENDER_ERROR_CODES = /* @__PURE__ */ new Set([
20611
20684
  "ENCODER_INTERRUPTED",
20612
20685
  "RENDER_TOO_SLOW",
20613
20686
  "RENDER_STAGE_STALLED",
20614
- "PAGE_NEVER_READY"
20687
+ "PAGE_NEVER_READY",
20688
+ "VARIABLES_INVALID"
20615
20689
  ]);
20616
20690
  function extractSafeRenderErrorCode(error) {
20617
20691
  if (typeof error !== "object" || error === null || !("code" in error)) return void 0;
@@ -20830,6 +20904,9 @@ function validateDistributedRenderConfig(config) {
20830
20904
  if (config.variables !== void 0) {
20831
20905
  validateVariablesPayload(config.variables);
20832
20906
  }
20907
+ if (config.strictVariables !== void 0 && typeof config.strictVariables !== "boolean") {
20908
+ throw new InvalidConfigError("config.strictVariables", "must be a boolean");
20909
+ }
20833
20910
  if (config.engineConfig !== void 0) {
20834
20911
  try {
20835
20912
  validateEngineConfigSnapshot(config.engineConfig);
@@ -21024,6 +21101,9 @@ function assertRequestOptionObjects(options) {
21024
21101
  if (options.variables !== void 0 && !isPlainObject(options.variables)) {
21025
21102
  throw new Error("Render request variables must be a JSON object");
21026
21103
  }
21104
+ if (options.strictVariables !== void 0 && typeof options.strictVariables !== "boolean") {
21105
+ throw new Error("Render request strictVariables must be a boolean");
21106
+ }
21027
21107
  if (options.distributed !== void 0) assertDistributedOptions(options.distributed);
21028
21108
  }
21029
21109
  function assertRequestOptions(options) {
@@ -21136,7 +21216,8 @@ function distributedConfigFromRequest(request, runtime = {}) {
21136
21216
  strictness: options.strictness,
21137
21217
  abortSignal: runtime.abortSignal,
21138
21218
  planDirSizeLimitBytes: distributed.planDirSizeLimitBytes,
21139
- variables: options.variables
21219
+ variables: options.variables,
21220
+ strictVariables: options.strictVariables
21140
21221
  };
21141
21222
  }
21142
21223
  function optionalProperty(key, value) {
@@ -21177,7 +21258,8 @@ function renderRequestFromDistributedConfig(input) {
21177
21258
  ...optionalProperty("hdrMode", config.hdrMode),
21178
21259
  ...optionalProperty("strictness", config.strictness),
21179
21260
  ...optionalProperty("entryFile", config.entryFile),
21180
- ...optionalProperty("variables", config.variables)
21261
+ ...optionalProperty("variables", config.variables),
21262
+ ...optionalProperty("strictVariables", config.strictVariables)
21181
21263
  };
21182
21264
  return createRenderRequest({
21183
21265
  projectDir: input.projectDir,
@@ -21211,7 +21293,7 @@ import {
21211
21293
 
21212
21294
  // src/server.ts
21213
21295
  import {
21214
- existsSync as existsSync33,
21296
+ existsSync as existsSync32,
21215
21297
  mkdirSync as mkdirSync21,
21216
21298
  statSync as statSync13,
21217
21299
  mkdtempSync as mkdtempSync2,
@@ -21234,7 +21316,7 @@ import {
21234
21316
 
21235
21317
  // src/services/hyperframeLint.ts
21236
21318
  import {
21237
- existsSync as existsSync31,
21319
+ existsSync as existsSync30,
21238
21320
  readFileSync as readFileSync16,
21239
21321
  statSync as statSync12,
21240
21322
  openSync as openSync7,
@@ -21288,7 +21370,7 @@ function readEntryHtml(filePath) {
21288
21370
  }
21289
21371
  function readProjectEntryFile(projectDir, preferredEntryFile) {
21290
21372
  const absProjectDir = resolve11(projectDir);
21291
- if (!existsSync31(absProjectDir) || !statSync12(absProjectDir).isDirectory()) {
21373
+ if (!existsSync30(absProjectDir) || !statSync12(absProjectDir).isDirectory()) {
21292
21374
  return { error: `Project directory not found: ${absProjectDir}` };
21293
21375
  }
21294
21376
  const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
@@ -21357,7 +21439,7 @@ async function runHyperframeLint(prepared) {
21357
21439
  import { Worker as Worker2 } from "node:worker_threads";
21358
21440
  import { fileURLToPath as fileURLToPath6 } from "node:url";
21359
21441
  import { dirname as dirname18, join as join47 } from "node:path";
21360
- import { existsSync as existsSync32 } from "node:fs";
21442
+ import { existsSync as existsSync31 } from "node:fs";
21361
21443
  var DEFAULT_HEALTH_PORT = 9848;
21362
21444
  async function startHealthWorker(options = {}) {
21363
21445
  const log = options.logger ?? defaultLogger2();
@@ -21434,7 +21516,7 @@ function resolveWorkerEntry2() {
21434
21516
  const here = dirname18(fileURLToPath6(import.meta.url));
21435
21517
  const candidates = [join47(here, "healthWorkerThread.js"), join47(here, "healthWorkerThread.ts")];
21436
21518
  for (const candidate of candidates) {
21437
- if (existsSync32(candidate)) return candidate;
21519
+ if (existsSync31(candidate)) return candidate;
21438
21520
  }
21439
21521
  return void 0;
21440
21522
  }
@@ -21461,6 +21543,9 @@ function extractSafeRenderErrorMetadata(error) {
21461
21543
  ...isPlainObject2(publicMetadata) ? { errorMetadata: publicMetadata } : {}
21462
21544
  };
21463
21545
  }
21546
+ function strictVariablesResult(job) {
21547
+ return job.strictVariablesChecked === void 0 ? {} : { strictVariablesChecked: job.strictVariablesChecked };
21548
+ }
21464
21549
  function parseServerFps(value) {
21465
21550
  if (typeof value !== "number" && typeof value !== "string") return DEFAULT_SERVER_FPS;
21466
21551
  const parsed = parseFps(value);
@@ -21519,7 +21604,7 @@ function parseRenderOptions(body) {
21519
21604
  bufferSize,
21520
21605
  chromaSubsampling
21521
21606
  } = encoder.ok ? encoder.options : {};
21522
- const { variables, outputResolution, outputResolutionAspectAgnostic } = parseRenderOverrides(body);
21607
+ const { variables, strictVariables, outputResolution, outputResolutionAspectAgnostic } = parseRenderOverrides(body);
21523
21608
  return {
21524
21609
  outputPath,
21525
21610
  fps,
@@ -21540,6 +21625,7 @@ function parseRenderOptions(body) {
21540
21625
  format,
21541
21626
  outputDynamicRange,
21542
21627
  variables,
21628
+ strictVariables,
21543
21629
  outputResolution,
21544
21630
  outputResolutionAspectAgnostic,
21545
21631
  videoFrameFormat
@@ -21550,10 +21636,11 @@ function isPlainObject2(value) {
21550
21636
  }
21551
21637
  function parseRenderOverrides(body) {
21552
21638
  const variables = isPlainObject2(body.variables) ? body.variables : void 0;
21639
+ const strictVariables = body.strictVariables === true ? true : void 0;
21553
21640
  const rawOutputResolution = typeof body.outputResolution === "string" ? body.outputResolution : void 0;
21554
21641
  const outputResolution = rawOutputResolution ? normalizeResolutionFlag(rawOutputResolution) : void 0;
21555
21642
  const outputResolutionAspectAgnostic = outputResolution ? isAspectAgnosticResolutionAlias(rawOutputResolution) : void 0;
21556
- return { variables, outputResolution, outputResolutionAspectAgnostic };
21643
+ return { variables, strictVariables, outputResolution, outputResolutionAspectAgnostic };
21557
21644
  }
21558
21645
  function buildRenderJobConfig(input, outputPath, log) {
21559
21646
  const request = createRenderRequest({
@@ -21577,6 +21664,7 @@ function buildRenderJobConfig(input, outputPath, log) {
21577
21664
  strictness: input.strictness,
21578
21665
  entryFile: input.entryFile,
21579
21666
  variables: input.variables,
21667
+ strictVariables: input.strictVariables,
21580
21668
  outputResolution: input.outputResolution,
21581
21669
  outputResolutionAspectAgnostic: input.outputResolutionAspectAgnostic,
21582
21670
  videoFrameFormat: input.videoFrameFormat,
@@ -21590,7 +21678,7 @@ function resolvePreparedRenderOutput(prepared, rendersDir, log) {
21590
21678
  const { input, cleanupProjectDir } = prepared;
21591
21679
  const absoluteOutputPath = resolveOutputPath(input.projectDir, input.outputPath, rendersDir, log);
21592
21680
  const outputDir = dirname19(absoluteOutputPath);
21593
- if (!existsSync33(outputDir)) mkdirSync21(outputDir, { recursive: true });
21681
+ if (!existsSync32(outputDir)) mkdirSync21(outputDir, { recursive: true });
21594
21682
  return { input, cleanupProjectDir, absoluteOutputPath };
21595
21683
  }
21596
21684
  function prepareRenderJob(prepared, rendersDir, log) {
@@ -21615,6 +21703,9 @@ function validateRenderOverrides(body) {
21615
21703
  if (body.variables !== void 0 && !isPlainObject2(body.variables)) {
21616
21704
  return 'variables must be a JSON object keyed by variable id (e.g. {"title":"Hello"})';
21617
21705
  }
21706
+ if (body.strictVariables !== void 0 && typeof body.strictVariables !== "boolean") {
21707
+ return "strictVariables must be a boolean";
21708
+ }
21618
21709
  if (body.outputDynamicRange !== void 0 && parseServerOutputDynamicRange(body.outputDynamicRange) === void 0) {
21619
21710
  return 'outputDynamicRange must be one of: "auto", "hdr", "sdr"';
21620
21711
  }
@@ -21647,11 +21738,11 @@ function prepareProjectDirectory(projectDir, options) {
21647
21738
  const candidate = nonEmptyString(projectDir);
21648
21739
  if (!candidate) return null;
21649
21740
  const absProjectDir = resolve12(candidate);
21650
- if (!existsSync33(absProjectDir) || !statSync13(absProjectDir).isDirectory()) {
21741
+ if (!existsSync32(absProjectDir) || !statSync13(absProjectDir).isDirectory()) {
21651
21742
  return { error: `Project directory not found: ${absProjectDir}` };
21652
21743
  }
21653
21744
  const entry = options.entryFile || "index.html";
21654
- if (!existsSync33(resolve12(absProjectDir, entry))) {
21745
+ if (!existsSync32(resolve12(absProjectDir, entry))) {
21655
21746
  return { error: `Entry file "${entry}" not found in project directory: ${absProjectDir}` };
21656
21747
  }
21657
21748
  return { prepared: { input: { projectDir: absProjectDir, ...options } } };
@@ -21743,7 +21834,7 @@ function cleanupTempDir(dir, log) {
21743
21834
  }
21744
21835
  }
21745
21836
  function outputFileSize(path) {
21746
- return existsSync33(path) ? statSync13(path).size : 0;
21837
+ return existsSync32(path) ? statSync13(path).size : 0;
21747
21838
  }
21748
21839
  function createBlockingProgressReporter(log, requestId) {
21749
21840
  let lastLoggedPct = -10;
@@ -21933,7 +22024,8 @@ function createRenderHandlers(options = {}) {
21933
22024
  videoDurationSeconds: job.duration ?? null,
21934
22025
  outcome: job.outcome ?? "completed",
21935
22026
  warnings: job.warnings,
21936
- perf: job.perfSummary ?? null
22027
+ perf: job.perfSummary ?? null,
22028
+ ...strictVariablesResult(job)
21937
22029
  });
21938
22030
  } catch (error) {
21939
22031
  const durationMs = Date.now() - t0;
@@ -22029,7 +22121,8 @@ function createRenderHandlers(options = {}) {
22029
22121
  outcome: job.outcome ?? "completed",
22030
22122
  warnings: job.warnings,
22031
22123
  perf: job.perfSummary ?? null,
22032
- producerVersion: readProducerVersion()
22124
+ producerVersion: readProducerVersion(),
22125
+ ...strictVariablesResult(job)
22033
22126
  })
22034
22127
  });
22035
22128
  } catch (error) {
@@ -22054,7 +22147,7 @@ function createRenderHandlers(options = {}) {
22054
22147
  if (!artifact) {
22055
22148
  return c.json({ success: false, error: "Output artifact not found or expired" }, 404);
22056
22149
  }
22057
- if (!existsSync33(artifact.path)) {
22150
+ if (!existsSync32(artifact.path)) {
22058
22151
  store.delete(token);
22059
22152
  return c.json({ success: false, error: "Output artifact file missing" }, 404);
22060
22153
  }
@@ -22177,7 +22270,7 @@ import {
22177
22270
  } from "@hyperframes/engine";
22178
22271
  import {
22179
22272
  cpSync as cpSync3,
22180
- existsSync as existsSync34,
22273
+ existsSync as existsSync33,
22181
22274
  mkdirSync as mkdirSync22,
22182
22275
  readFileSync as readFileSync17,
22183
22276
  readdirSync as readdirSync12,
@@ -22232,7 +22325,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
22232
22325
  }
22233
22326
  const format = plan2.dimensions.format;
22234
22327
  const cfrEncoder = cfr ? readCfrEncoder(planDir, format) : null;
22235
- if (!existsSync34(dirname20(outputPath))) {
22328
+ if (!existsSync33(dirname20(outputPath))) {
22236
22329
  mkdirSync22(dirname20(outputPath), { recursive: true });
22237
22330
  }
22238
22331
  const workDir = createStagingDir7(dirname20(outputPath), `${basename8(outputPath)}.assemble-work-`);
@@ -22256,7 +22349,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
22256
22349
  try {
22257
22350
  const videoSources = cfrEncoder ? [await reencodeCfr(ctx, chunkPaths, cfrEncoder)] : chunkPaths;
22258
22351
  const finalPath = join49(workDir, `output.${format}`);
22259
- const audio = audioPath !== null && existsSync34(audioPath) ? audioPath : null;
22352
+ const audio = audioPath !== null && existsSync33(audioPath) ? audioPath : null;
22260
22353
  await writeJoined(ctx, videoSources, audio, finalPath);
22261
22354
  renameWithRetry11(finalPath, outputPath);
22262
22355
  log.info("[assemble] stage timings", {
@@ -22274,7 +22367,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
22274
22367
  });
22275
22368
  }
22276
22369
  }
22277
- const fileSize = existsSync34(outputPath) ? statSync14(outputPath).size : 0;
22370
+ const fileSize = existsSync33(outputPath) ? statSync14(outputPath).size : 0;
22278
22371
  return {
22279
22372
  ...referenceBackgroundResult8(plan2[REFERENCE_BACKGROUND_FIELD6]),
22280
22373
  outputPath,
@@ -22286,13 +22379,13 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
22286
22379
  function readAssemblePlan(planDir, chunkPaths) {
22287
22380
  const planJsonPath = join49(planDir, "plan.json");
22288
22381
  const chunksJsonPath = join49(planDir, "meta", "chunks.json");
22289
- if (!existsSync34(planJsonPath)) {
22382
+ if (!existsSync33(planJsonPath)) {
22290
22383
  throw new Error(`[assemble] planDir missing plan.json: ${planJsonPath}`);
22291
22384
  }
22292
22385
  const plan2 = JSON.parse(readFileSync17(planJsonPath, "utf-8"));
22293
22386
  readPlanProtocolV1(plan2, DISTRIBUTED_RENDER_CAPABILITIES.roles.assembler);
22294
22387
  validatePlanV2MaterializedTarget(planDir, { role: "assembler" });
22295
- if (!existsSync34(chunksJsonPath)) {
22388
+ if (!existsSync33(chunksJsonPath)) {
22296
22389
  throw new Error(`[assemble] planDir missing meta/chunks.json: ${chunksJsonPath}`);
22297
22390
  }
22298
22391
  const chunks = JSON.parse(readFileSync17(chunksJsonPath, "utf-8"));
@@ -22307,7 +22400,7 @@ function readAssemblePlan(planDir, chunkPaths) {
22307
22400
  }
22308
22401
  }
22309
22402
  for (const path of chunkPaths.flat()) {
22310
- if (!existsSync34(path)) {
22403
+ if (!existsSync33(path)) {
22311
22404
  throw new Error(`[assemble] chunk path does not exist: ${path}`);
22312
22405
  }
22313
22406
  }
@@ -22446,7 +22539,7 @@ function planFormat(planDir) {
22446
22539
  }
22447
22540
  function lockedAudio(planDir) {
22448
22541
  const encoderJsonPath = join49(planDir, "meta", "encoder.json");
22449
- if (!existsSync34(encoderJsonPath)) return {};
22542
+ if (!existsSync33(encoderJsonPath)) return {};
22450
22543
  return JSON.parse(readFileSync17(encoderJsonPath, "utf-8"));
22451
22544
  }
22452
22545
  function readCfrEncoder(planDir, format) {
@@ -22456,7 +22549,7 @@ function readCfrEncoder(planDir, format) {
22456
22549
  );
22457
22550
  }
22458
22551
  const encoderJsonPath = join49(planDir, "meta", "encoder.json");
22459
- if (!existsSync34(encoderJsonPath)) {
22552
+ if (!existsSync33(encoderJsonPath)) {
22460
22553
  throw new Error(`[assemble] planDir missing meta/encoder.json: ${encoderJsonPath}`);
22461
22554
  }
22462
22555
  const encoderJson = JSON.parse(readFileSync17(encoderJsonPath, "utf-8"));
@@ -22468,7 +22561,7 @@ function readCfrEncoder(planDir, format) {
22468
22561
  return encoderJson;
22469
22562
  }
22470
22563
  function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, startTimeMs) {
22471
- if (existsSync34(outputPath)) rmSync20(outputPath, { recursive: true, force: true });
22564
+ if (existsSync33(outputPath)) rmSync20(outputPath, { recursive: true, force: true });
22472
22565
  mkdirSync22(outputPath, { recursive: true });
22473
22566
  let globalIdx = 0;
22474
22567
  for (const chunkDir of chunkPaths) {
@@ -22492,7 +22585,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
22492
22585
  `[assemble] png-sequence frame count mismatch: merged ${globalIdx} frames vs plan.totalFrames=${totalFrames}. Using on-disk count.`
22493
22586
  );
22494
22587
  }
22495
- if (audioPath !== null && existsSync34(audioPath)) {
22588
+ if (audioPath !== null && existsSync33(audioPath)) {
22496
22589
  const sidecar = join49(outputPath, MIXED_AUDIO_FILENAME4);
22497
22590
  cpSync3(audioPath, sidecar);
22498
22591
  }