@hyperframes/producer 0.9.56 → 0.9.59

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.
@@ -10,7 +10,7 @@ import {
10
10
  rmSync as rmSync13,
11
11
  createReadStream as createReadStream3
12
12
  } from "node:fs";
13
- import { resolve as resolve10, dirname as dirname17, join as join37 } from "node:path";
13
+ import { resolve as resolve10, dirname as dirname18, join as join37 } from "node:path";
14
14
  import { tmpdir as tmpdir3 } from "node:os";
15
15
  import { parseArgs } from "node:util";
16
16
  import { isIP } from "node:net";
@@ -401,7 +401,7 @@ import { join as join2, extname, resolve as resolve2, sep as sep2 } from "node:p
401
401
  import { injectScriptsAtHeadStart, injectScriptsIntoHtml } from "@hyperframes/core/compiler";
402
402
  import { injectTagsAtHeadStart } from "@hyperframes/core/compiler/html-document";
403
403
  import { PREVIEW_FOR_ANOTHER_SITE_META } from "@hyperframes/core/studio-preview-mark";
404
- import { fpsToNumber } from "@hyperframes/core";
404
+ import { fpsToNumber, terminalText as terminalText2 } from "@hyperframes/core";
405
405
  import { isPrivateFileUnder, isStudioPrivatePath } from "@hyperframes/core/safe-path";
406
406
  import { stripSdrPngColourTags } from "@hyperframes/core/compiler/png-colour-tags";
407
407
  import { openRangeEnd } from "@hyperframes/studio-server/media-range";
@@ -492,6 +492,7 @@ function getHfEarlyStub() {
492
492
  }
493
493
 
494
494
  // src/logger.ts
495
+ import { terminalText } from "@hyperframes/core";
495
496
  var LOG_LEVEL_PRIORITY = {
496
497
  error: 0,
497
498
  warn: 1,
@@ -501,26 +502,26 @@ var LOG_LEVEL_PRIORITY = {
501
502
  function createConsoleLogger(level = "info") {
502
503
  const threshold = LOG_LEVEL_PRIORITY[level];
503
504
  const shouldLog = (msgLevel) => LOG_LEVEL_PRIORITY[msgLevel] <= threshold;
504
- const formatMeta = (meta) => meta ? ` ${JSON.stringify(meta)}` : "";
505
+ const formatMeta = (meta) => meta ? ` ${terminalText(JSON.stringify(meta))}` : "";
505
506
  return {
506
507
  error(message, meta) {
507
508
  if (shouldLog("error")) {
508
- console.error(`[ERROR] ${message}${formatMeta(meta)}`);
509
+ console.error(`[ERROR] ${terminalText(message)}${formatMeta(meta)}`);
509
510
  }
510
511
  },
511
512
  warn(message, meta) {
512
513
  if (shouldLog("warn")) {
513
- console.warn(`[WARN] ${message}${formatMeta(meta)}`);
514
+ console.warn(`[WARN] ${terminalText(message)}${formatMeta(meta)}`);
514
515
  }
515
516
  },
516
517
  info(message, meta) {
517
518
  if (shouldLog("info")) {
518
- console.error(`[INFO] ${message}${formatMeta(meta)}`);
519
+ console.error(`[INFO] ${terminalText(message)}${formatMeta(meta)}`);
519
520
  }
520
521
  },
521
522
  debug(message, meta) {
522
523
  if (shouldLog("debug")) {
523
- console.error(`[DEBUG] ${message}${formatMeta(meta)}`);
524
+ console.error(`[DEBUG] ${terminalText(message)}${formatMeta(meta)}`);
524
525
  }
525
526
  },
526
527
  isLevelEnabled(msgLevel) {
@@ -1169,7 +1170,7 @@ function createFileServer(options) {
1169
1170
  const headScripts = options.headScripts ?? [getVerifiedHyperframeRuntimeSource()];
1170
1171
  const bodyScripts = options.bodyScripts ?? [buildRenderModeScript(options.fps), HF_BRIDGE_SCRIPT];
1171
1172
  const app = new Hono();
1172
- const warnLeftOut = (line) => console.warn(`[FileServer] ${line}`);
1173
+ const warnLeftOut = (line) => console.warn(`[FileServer] ${terminalText2(line)}`);
1173
1174
  let listeningPort = -1;
1174
1175
  app.use(async function loadEachFileOnlyAsItsNamedType(c, next) {
1175
1176
  await next();
@@ -1193,7 +1194,7 @@ function createFileServer(options) {
1193
1194
  }
1194
1195
  if (!file) {
1195
1196
  if (!/favicon\.ico$/i.test(requestPath)) {
1196
- console.warn(`[FileServer] 404 Not Found: ${requestPath}`);
1197
+ console.warn(`[FileServer] 404 Not Found: ${terminalText2(requestPath)}`);
1197
1198
  }
1198
1199
  return c.text("Not found", 404);
1199
1200
  }
@@ -1431,7 +1432,8 @@ import {
1431
1432
  import { basename as basename2, dirname as dirname2, isAbsolute, join as join3, relative, resolve as resolve3 } from "node:path";
1432
1433
  import {
1433
1434
  CANVAS_DIMENSIONS,
1434
- checkOutputResolutionCompatibility
1435
+ checkOutputResolutionCompatibility,
1436
+ terminalText as terminalText3
1435
1437
  } from "@hyperframes/core";
1436
1438
  import {
1437
1439
  mediaIdPathSegment
@@ -1476,7 +1478,7 @@ function writeCompiledArtifacts(compiled, workDir, includeSummary) {
1476
1478
  for (const [srcPath, html] of compiled.subCompositions) {
1477
1479
  const outPath = join3(compileDir, srcPath);
1478
1480
  if (!isPathInside(outPath, compileDir)) {
1479
- console.warn(`[Render] Skipping sub-composition with unsafe path: ${srcPath}`);
1481
+ console.warn(`[Render] Skipping sub-composition with unsafe path: ${terminalText3(srcPath)}`);
1480
1482
  continue;
1481
1483
  }
1482
1484
  mkdirSync(dirname2(outPath), { recursive: true });
@@ -1485,7 +1487,9 @@ function writeCompiledArtifacts(compiled, workDir, includeSummary) {
1485
1487
  for (const [relativePath, absolutePath] of compiled.externalAssets) {
1486
1488
  const outPath = resolve3(join3(compileDir, relativePath));
1487
1489
  if (!isPathInside(outPath, compileDir)) {
1488
- console.warn(`[Render] Skipping external asset with unsafe path: ${relativePath}`);
1490
+ console.warn(
1491
+ `[Render] Skipping external asset with unsafe path: ${terminalText3(relativePath)}`
1492
+ );
1489
1493
  continue;
1490
1494
  }
1491
1495
  mkdirSync(dirname2(outPath), { recursive: true });
@@ -1592,6 +1596,30 @@ function reportEncodeProgress(job, done, total, onProgress, from) {
1592
1596
  "encoding"
1593
1597
  );
1594
1598
  }
1599
+ var AUDIO_STAGE = "Processing audio tracks";
1600
+ var AUDIO_WAIT_REPORT_MS = 5e3;
1601
+ function audioWaitReporter(job, onProgress) {
1602
+ let waiting2 = false;
1603
+ let reportedAt = -Infinity;
1604
+ return {
1605
+ progressed() {
1606
+ const now = Date.now();
1607
+ if (!waiting2 || now - reportedAt < AUDIO_WAIT_REPORT_MS) return;
1608
+ reportedAt = now;
1609
+ updateJobStatus(job, job.status, AUDIO_STAGE, job.progress, onProgress, {
1610
+ code: "process_audio"
1611
+ });
1612
+ },
1613
+ async wait(audio) {
1614
+ waiting2 = true;
1615
+ try {
1616
+ return await audio;
1617
+ } finally {
1618
+ waiting2 = false;
1619
+ }
1620
+ }
1621
+ };
1622
+ }
1595
1623
  var lastAssembleReportAt = /* @__PURE__ */ new WeakMap();
1596
1624
  function reportAssembleProgress(job, done, total, onProgress) {
1597
1625
  if (total <= 0) return;
@@ -3384,6 +3412,7 @@ import {
3384
3412
  resolveProjectRelativeSrc,
3385
3413
  resolveVideoExtractionWindow,
3386
3414
  runFfmpeg,
3415
+ urlInputArgs,
3387
3416
  videoStartOnMediaTimeline
3388
3417
  } from "@hyperframes/engine";
3389
3418
  import { fpsToFfmpegArg, fpsToNumber as fpsToNumber3 } from "@hyperframes/core";
@@ -3676,7 +3705,15 @@ function hdrWindowFrames(frameSize, windowBytes) {
3676
3705
  return Math.max(8, Math.floor(windowBytes / frameSize));
3677
3706
  }
3678
3707
  async function probeFirstTick(srcPath, mediaStart, fps, runFfmpegImpl, abortSignal) {
3679
- const args = ["-ss", String(mediaStart), "-i", srcPath, "-frames:v", "1"];
3708
+ const args = [
3709
+ ...urlInputArgs(srcPath),
3710
+ "-ss",
3711
+ String(mediaStart),
3712
+ "-i",
3713
+ srcPath,
3714
+ "-frames:v",
3715
+ "1"
3716
+ ];
3680
3717
  const result = await runFfmpegImpl([...args, ...["-vf", "showinfo", "-f", "null", "-"]], {
3681
3718
  signal: abortSignal
3682
3719
  });
@@ -3750,6 +3787,7 @@ async function extractHdrVideoFrames(args) {
3750
3787
  // Decode before seeking for the one-frame path. Input-side seeking can
3751
3788
  // return zero frames for valid unindexed/negative-base transports.
3752
3789
  [
3790
+ ...urlInputArgs(srcPath),
3753
3791
  "-i",
3754
3792
  srcPath,
3755
3793
  "-ss",
@@ -3834,6 +3872,7 @@ function hdrWindowFfmpegArgs(a) {
3834
3872
  const filters = [`fps=${a.fpsArg}:start_time=${(a.firstTick / a.fps).toFixed(6)}`, a.scale];
3835
3873
  if (trim > 0) filters.push(`trim=start_frame=${trim}`);
3836
3874
  return [
3875
+ ...urlInputArgs(a.srcPath),
3837
3876
  ...["-ss", (a.ffmpegSeek + seekFrame / a.fps).toFixed(6), "-i", a.srcPath],
3838
3877
  ...["-vf", filters.join(","), "-frames:v", String(a.frames), "-fps_mode", "passthrough"]
3839
3878
  ];
@@ -6909,7 +6948,8 @@ import {
6909
6948
  rewriteAssetPath,
6910
6949
  rewriteAssetPaths,
6911
6950
  rewriteCssAssetUrls,
6912
- rewriteInlineStyleAssetUrls
6951
+ rewriteInlineStyleAssetUrls,
6952
+ terminalText as terminalText4
6913
6953
  } from "@hyperframes/core";
6914
6954
  import { MAX_AUDIO_GAIN } from "@hyperframes/core/audio-gain";
6915
6955
  import { CAPTURE_CANVAS_SELECTOR } from "@hyperframes/core/html-in-canvas";
@@ -7120,6 +7160,7 @@ function placeAudio(audio, window2) {
7120
7160
  import {
7121
7161
  analyzeKeyframeIntervals,
7122
7162
  assertMediaPayload,
7163
+ isPrivateUnderAssetRoots as isPrivateUnderAssetRoots3,
7123
7164
  NotMediaPayloadError as NotMediaPayloadError2,
7124
7165
  parseMasterFxChain,
7125
7166
  probeMediaProfile as probeMediaProfile2
@@ -7147,7 +7188,13 @@ import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as
7147
7188
  import { dirname as dirname6, isAbsolute as isAbsolute2, join as join16, resolve as resolve5 } from "node:path";
7148
7189
  import { parseHTML as parseHTML3 } from "linkedom";
7149
7190
  import { parseAnimatedGifMetadata } from "@hyperframes/core";
7150
- import { DEFAULT_VP9_CPU_USED, runFfmpeg as runFfmpeg2, renameWithRetry as renameWithRetry3 } from "@hyperframes/engine";
7191
+ import {
7192
+ DEFAULT_VP9_CPU_USED,
7193
+ isPrivateUnderAssetRoots,
7194
+ runFfmpeg as runFfmpeg2,
7195
+ renameWithRetry as renameWithRetry3,
7196
+ urlInputArgs as urlInputArgs2
7197
+ } from "@hyperframes/engine";
7151
7198
  import { namesAnotherNetworkRoot } from "@hyperframes/parsers/asset-resolution";
7152
7199
  var PREPARED_GIF_SUBDIR = "_animated_gif";
7153
7200
  var CACHE_SCHEMA = "hfgif-v1";
@@ -7190,7 +7237,7 @@ function resolveLocalImageSourcePath(src, options) {
7190
7237
  isAbsolute2(basePath) ? basePath : resolve5(options.projectDir, projectRelative),
7191
7238
  resolve5(options.downloadDir, normalizedBase)
7192
7239
  ];
7193
- const allowed = (candidate) => !namesAnotherNetworkRoot(options.projectDir, candidate) && (!escapesAssetRoot(candidate, options.assetRoot) && outsideAssetRefusal(options.projectDir, candidate) !== "blocklisted" || !escapesAssetRoot(candidate, options.downloadDir));
7240
+ const allowed = (candidate) => !namesAnotherNetworkRoot(options.projectDir, candidate) && !isPrivateUnderAssetRoots(candidate, [options.projectDir, options.downloadDir]) && (!escapesAssetRoot(candidate, options.assetRoot) && outsideAssetRefusal(options.projectDir, candidate) !== "blocklisted" || !escapesAssetRoot(candidate, options.downloadDir));
7194
7241
  return candidates.find((candidate) => allowed(candidate) && existsSync9(candidate)) ?? null;
7195
7242
  }
7196
7243
  function isUsableFile(path) {
@@ -7259,6 +7306,7 @@ function buildAnimatedGifTranscodeArgs(input) {
7259
7306
  args.push(
7260
7307
  "-ignore_loop",
7261
7308
  "1",
7309
+ ...urlInputArgs2(input.inputPath),
7262
7310
  "-i",
7263
7311
  input.inputPath,
7264
7312
  "-an",
@@ -7464,7 +7512,7 @@ import {
7464
7512
  } from "node:fs";
7465
7513
  import { dirname as dirname7, join as join17, resolve as resolve6 } from "node:path";
7466
7514
  import { parseHTML as parseHTML4 } from "linkedom";
7467
- import { renameWithRetry as renameWithRetry4, runFfmpeg as runFfmpeg3, runFfprobe } from "@hyperframes/engine";
7515
+ import { renameWithRetry as renameWithRetry4, runFfmpeg as runFfmpeg3, runFfprobe, urlInputArgs as urlInputArgs3 } from "@hyperframes/engine";
7468
7516
 
7469
7517
  // src/services/heifRotation.ts
7470
7518
  function* boxes(buf, start, end) {
@@ -7663,6 +7711,7 @@ async function convertHeifToJpeg(request) {
7663
7711
  "-hide_banner",
7664
7712
  "-loglevel",
7665
7713
  "error",
7714
+ ...urlInputArgs3(request.inputPath),
7666
7715
  "-i",
7667
7716
  request.inputPath,
7668
7717
  ...mapArgs,
@@ -7786,7 +7835,9 @@ import {
7786
7835
  fingerprintElementId,
7787
7836
  isHttpUrl as isHttpUrl2,
7788
7837
  isInsideAssetRoots,
7838
+ isNotImagePayload,
7789
7839
  isNotMediaPayload,
7840
+ isPrivateUnderAssetRoots as isPrivateUnderAssetRoots2,
7790
7841
  playlistLeavesItsFolder,
7791
7842
  NotMediaPayloadError,
7792
7843
  probeMediaProfile,
@@ -7841,6 +7892,10 @@ function dropMediaOutsideProject(input) {
7841
7892
  const staysInside = ({ id, src }) => {
7842
7893
  if (!src || isHttpUrl2(src)) return true;
7843
7894
  const path = resolveProjectRelativeSrc3(src, projectDir, compiledDir);
7895
+ if (isPrivateUnderAssetRoots2(path, roots)) {
7896
+ log.warn(`[Render] Media "${id}" source is missing: it is a private project file`, { src });
7897
+ return false;
7898
+ }
7844
7899
  if (isInsideAssetRoots(path, roots)) return true;
7845
7900
  if (input.allowOutsideProjectAssets) {
7846
7901
  const refusal = outsideAssetRefusal(projectDir, path);
@@ -7857,6 +7912,8 @@ function dropMediaOutsideProject(input) {
7857
7912
  async function notMediaReferences(path, references) {
7858
7913
  const videos = references.filter((ref) => ref.expected === "video");
7859
7914
  if (videos.length > 0 && await isNotMediaPayload(path)) return videos;
7915
+ const images = references.filter((ref) => ref.expected === "image");
7916
+ if (images.length > 0 && await isNotImagePayload(path)) return images;
7860
7917
  return await playlistLeavesItsFolder(path) ? references : [];
7861
7918
  }
7862
7919
  async function preflightCompositionAssetMediaTypes(input) {
@@ -8145,7 +8202,7 @@ function detectShaderTransitionUsage(html) {
8145
8202
  }
8146
8203
  return false;
8147
8204
  }
8148
- async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, downloadDir, tagName, elementIdentity, log, urlByAbsentLocalPath, probes, assetRoot) {
8205
+ async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, baseDir, downloadDir, tagName, elementIdentity, log, urlByAbsentLocalPath, probes, assetRoot) {
8149
8206
  let filePath = src;
8150
8207
  if (isHttpUrl(src)) {
8151
8208
  const remoteDir = join19(downloadDir, REMOTE_MEDIA_SUBDIR);
@@ -8160,7 +8217,9 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, down
8160
8217
  } else {
8161
8218
  filePath = decodedUrlPath(src);
8162
8219
  if (!filePath.startsWith("/")) filePath = join19(baseDir, filePath);
8163
- if (escapesAssetRoot(filePath, assetRoot)) return { duration: null, resolvedPath: filePath };
8220
+ if (escapesAssetRoot(filePath, assetRoot) || isPrivateUnderAssetRoots3(filePath, [projectDir, downloadDir])) {
8221
+ return { duration: null, resolvedPath: filePath };
8222
+ }
8164
8223
  filePath = urlByAbsentLocalPath?.get(filePath) ?? filePath;
8165
8224
  if (!isHttpUrl(filePath) && namesAnotherNetworkRoot2(baseDir, filePath)) {
8166
8225
  return { duration: null, resolvedPath: filePath };
@@ -8236,7 +8295,7 @@ function markInferredVariableMediaDurations(html, unresolvedMedia) {
8236
8295
  }
8237
8296
  return changed ? document2.toString() : html;
8238
8297
  }
8239
- async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocalPath, probes, assetRoot) {
8298
+ async function compileHtmlFile(html, projectDir, baseDir, downloadDir, log, urlByAbsentLocalPath, probes, assetRoot) {
8240
8299
  const { html: staticCompiled, unresolved } = compileTimingAttrs(html);
8241
8300
  const mediaUnresolved = unresolved.filter(
8242
8301
  (el) => (el.tagName === "video" || el.tagName === "audio") && el.src
@@ -8248,6 +8307,7 @@ async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocal
8248
8307
  el.src,
8249
8308
  el.mediaStart,
8250
8309
  el.playbackRate,
8310
+ projectDir,
8251
8311
  baseDir,
8252
8312
  downloadDir,
8253
8313
  el.tagName,
@@ -8272,6 +8332,7 @@ async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocal
8272
8332
  el.src,
8273
8333
  el.mediaStart,
8274
8334
  el.playbackRate,
8335
+ projectDir,
8275
8336
  baseDir,
8276
8337
  downloadDir,
8277
8338
  el.tagName,
@@ -8327,6 +8388,7 @@ async function parseSubCompositions(html, projectDir, downloadDir, visited = /*
8327
8388
  workItems.map(async (item) => {
8328
8389
  const { html: compiledSub } = await compileHtmlFile(
8329
8390
  rewriteUnresolvableGsapToCdn(item.rawSubHtml, projectDir, item.srcPath),
8391
+ projectDir,
8330
8392
  dirname9(item.filePath),
8331
8393
  downloadDir,
8332
8394
  void 0,
@@ -8488,7 +8550,7 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
8488
8550
  {},
8489
8551
  variableOverrides
8490
8552
  );
8491
- return emitted ? document2.toString() : html;
8553
+ return { html: emitted ? document2.toString() : html, variablesByComp: {} };
8492
8554
  }
8493
8555
  const hostIdentityByElement = new ProducerHostIdentityMap(
8494
8556
  document2,
@@ -8529,7 +8591,9 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
8529
8591
  flattenInnerRoot: prepareFlattenedInnerRoot,
8530
8592
  onMissingComposition: (srcPath, reason) => {
8531
8593
  console.warn(
8532
- `[Compiler] Skipping sub-composition "${srcPath}": ${reason ?? "the file is missing or empty"}.`
8594
+ terminalText4(
8595
+ `[Compiler] Skipping sub-composition "${srcPath}": ${reason ?? "the file is missing or empty"}.`
8596
+ )
8533
8597
  );
8534
8598
  }
8535
8599
  }
@@ -8600,7 +8664,7 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
8600
8664
  variableOverrides
8601
8665
  );
8602
8666
  assignMediaRenderIds(document2);
8603
- return document2.toString();
8667
+ return { html: document2.toString(), variablesByComp: result.variablesByComp };
8604
8668
  }
8605
8669
  function ensureFullDocument(html) {
8606
8670
  const trimmed = html.trim();
@@ -9055,6 +9119,7 @@ async function embedLocalFontFaces(html, projectDir, assetRoot, log = defaultLog
9055
9119
  embeddedPaths.add(localPath);
9056
9120
  continue;
9057
9121
  }
9122
+ if (isPrivateCompositionFile(projectDir, absPath)) continue;
9058
9123
  const ext = absPath.match(/\.(woff2?|ttf|otf|ttc)$/i)?.[1]?.toLowerCase() ?? "ttf";
9059
9124
  try {
9060
9125
  if (fileBackedAbsolutePaths.has(absPath)) {
@@ -9176,6 +9241,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
9176
9241
  const { html: compiledHtml, unresolvedCompositions } = await compileHtmlFile(
9177
9242
  rawHtml,
9178
9243
  projectDir,
9244
+ projectDir,
9179
9245
  downloadDir,
9180
9246
  options.log,
9181
9247
  options.urlByAbsentLocalPath,
@@ -9192,7 +9258,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
9192
9258
  assetRoot
9193
9259
  );
9194
9260
  const fullHtml = ensureFullDocument(compiledHtml);
9195
- const inlinedHtml = inlineSubCompositions(
9261
+ const { html: inlinedHtml, variablesByComp } = inlineSubCompositions(
9196
9262
  fullHtml,
9197
9263
  subCompositions,
9198
9264
  projectDir,
@@ -9308,7 +9374,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
9308
9374
  for (const video of videos) {
9309
9375
  if (isHttpUrl(video.src)) continue;
9310
9376
  const videoPath = resolve7(projectDir, video.src);
9311
- if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath) || !existsSync11(videoPath) || escapesAssetRoot(videoPath, assetRoot))
9377
+ if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath) || !existsSync11(videoPath) || escapesAssetRoot(videoPath, assetRoot) || isPrivateUnderAssetRoots3(videoPath, [projectDir, downloadDir]))
9312
9378
  continue;
9313
9379
  advised.add(videoPath);
9314
9380
  const reencode = `ffmpeg -i "${video.src}" -c:v libx264 -r 30 -g 30 -keyint_min 30 -movflags +faststart -c:a copy output.mp4`;
@@ -9345,6 +9411,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
9345
9411
  gradedCanvas,
9346
9412
  ...masterFxChain ? { masterFxChain } : {},
9347
9413
  unresolvedCompositions,
9414
+ variablesByComp,
9348
9415
  externalAssets,
9349
9416
  width,
9350
9417
  height,
@@ -9938,7 +10005,8 @@ import {
9938
10005
  readMediaStart as readMediaStart2,
9939
10006
  shiftRateLane as shiftRateLane2,
9940
10007
  sourceTimeAt as sourceTimeAt3,
9941
- timeAtSourceTime
10008
+ timeAtSourceTime,
10009
+ terminalText as terminalText5
9942
10010
  } from "@hyperframes/core";
9943
10011
  import { parseHostVariableValues as parseHostVariableValues2, readDeclaredDefaults as readDeclaredDefaults2 } from "@hyperframes/core/compiler";
9944
10012
  import { extractMediaSrcMutations } from "@hyperframes/parsers";
@@ -9986,15 +10054,22 @@ function hasAutoStartVideos(html) {
9986
10054
  const { document: document2 } = parseHTML6(html);
9987
10055
  return document2.querySelector("video[data-hf-auto-start]") !== null;
9988
10056
  }
9989
- function variableHasValue(element, variableId, variables) {
10057
+ function scopedVariablesFor(element, variablesByComp) {
10058
+ const scope = element.closest("[data-composition-id]");
10059
+ const compId = scope?.getAttribute("data-composition-id")?.trim() ?? "";
10060
+ return compId && Object.hasOwn(variablesByComp, compId) ? variablesByComp[compId] : void 0;
10061
+ }
10062
+ function variableHasValue(element, variableId, variables, variablesByComp) {
9990
10063
  if (variables && Object.hasOwn(variables, variableId)) return true;
10064
+ const scoped = scopedVariablesFor(element, variablesByComp);
10065
+ if (scoped) return Object.hasOwn(scoped, variableId);
9991
10066
  for (let scope = element.parentElement; scope; scope = scope.parentElement) {
9992
10067
  if (Object.hasOwn(parseHostVariableValues2(scope), variableId)) return true;
9993
10068
  if (Object.hasOwn(readDeclaredDefaults2(scope), variableId)) return true;
9994
10069
  }
9995
10070
  return Object.hasOwn(readDeclaredDefaults2(element.ownerDocument.documentElement), variableId);
9996
10071
  }
9997
- function hasVariableBoundMedia(html, variables) {
10072
+ function hasVariableBoundMedia(html, variables, variablesByComp = {}) {
9998
10073
  const { document: document2 } = parseHTML6(html);
9999
10074
  return Array.from(
10000
10075
  document2.querySelectorAll(
@@ -10002,7 +10077,7 @@ function hasVariableBoundMedia(html, variables) {
10002
10077
  )
10003
10078
  ).some((element) => {
10004
10079
  const variableId = element.getAttribute("data-var-src")?.trim();
10005
- return Boolean(variableId && variableHasValue(element, variableId, variables));
10080
+ return Boolean(variableId && variableHasValue(element, variableId, variables, variablesByComp));
10006
10081
  });
10007
10082
  }
10008
10083
  function authoredMediaStarts(html) {
@@ -10117,7 +10192,11 @@ async function runProbeStage(input) {
10117
10192
  compiled.html,
10118
10193
  composition.audios.length
10119
10194
  );
10120
- const hasVariableMedia = hasVariableBoundMedia(compiled.html, job.config.variables);
10195
+ const hasVariableMedia = hasVariableBoundMedia(
10196
+ compiled.html,
10197
+ job.config.variables,
10198
+ compiled.variablesByComp
10199
+ );
10121
10200
  const hasInsertedMedia = hasRuntimeMediaChanges(compiled.html);
10122
10201
  const needsBrowser = cfg.videoLayerPassthrough || input.measuresShownBoxes === true || probeRequiresBrowser({
10123
10202
  durationSeconds: composition.duration,
@@ -10571,7 +10650,7 @@ async function runProbeStage(input) {
10571
10650
  failures: failedRequests.slice(0, 10)
10572
10651
  });
10573
10652
  for (const line of failedRequests.slice(0, 5)) {
10574
- console.warn(`[Render] Asset load failure: ${line}`);
10653
+ console.warn(`[Render] Asset load failure: ${terminalText5(line)}`);
10575
10654
  }
10576
10655
  }
10577
10656
  }
@@ -10652,7 +10731,7 @@ import {
10652
10731
  resolveFinalFrameExtractionWindow as resolveFinalFrameExtractionWindow2,
10653
10732
  resolveVideoExtractionWindow as resolveVideoExtractionWindow2,
10654
10733
  isHttpUrl as isHttpUrl3,
10655
- isInsideAssetRoots as isInsideAssetRoots2,
10734
+ assetRootsRefusal,
10656
10735
  assertPublicHttpsUrl,
10657
10736
  downloadToTemp as downloadToTemp2,
10658
10737
  resolveRestrictPageNetwork,
@@ -11085,7 +11164,7 @@ function isPublicHttpsUrl(url) {
11085
11164
  }
11086
11165
  }
11087
11166
  function opensLocally(path, assetRoots) {
11088
- return existsSync13(path) && (!assetRoots || isInsideAssetRoots2(path, assetRoots));
11167
+ return existsSync13(path) && (!assetRoots || assetRootsRefusal(path, assetRoots) === null);
11089
11168
  }
11090
11169
  function localProbeSource(src, input) {
11091
11170
  const path = resolveProjectRelativeSrc4(src, input.projectDir, input.compiledDir);
@@ -11228,7 +11307,8 @@ import {
11228
11307
  audioFailureDiagnostics,
11229
11308
  processCompositionAudio,
11230
11309
  removeScratch as removeScratch2,
11231
- collectScratchLeftovers
11310
+ collectScratchLeftovers,
11311
+ withFfmpegProgress
11232
11312
  } from "@hyperframes/engine";
11233
11313
 
11234
11314
  // src/services/render/audioDeliveryLimit.ts
@@ -11254,7 +11334,8 @@ import {
11254
11334
  removeScratch,
11255
11335
  renameWithRetry as renameWithRetry5,
11256
11336
  runFfmpeg as runFfmpeg5,
11257
- trackChildProcess
11337
+ trackChildProcess,
11338
+ withPublicOnlyProxy
11258
11339
  } from "@hyperframes/engine";
11259
11340
  import { redactKnownPaths, redactTelemetryString as redactTelemetryString3 } from "@hyperframes/core";
11260
11341
 
@@ -11696,7 +11777,17 @@ async function runFfprobeJson(args, signal) {
11696
11777
  if (!args.includes("--")) {
11697
11778
  throw new Error('[audioPadTrim] ffprobe args must terminate options with "--".');
11698
11779
  }
11780
+ const proxying = withPublicOnlyProxy(args, [args.indexOf("--") + 1]);
11781
+ const routed = proxying && await proxying;
11782
+ try {
11783
+ return await spawnFfprobeJson(routed?.args ?? args, routed?.env, signal);
11784
+ } finally {
11785
+ await routed?.close();
11786
+ }
11787
+ }
11788
+ async function spawnFfprobeJson(args, env, signal) {
11699
11789
  const proc = spawn(getFfprobeBinary(), args, {
11790
+ ...env && { env },
11700
11791
  stdio: ["ignore", "pipe", "pipe"],
11701
11792
  windowsHide: true
11702
11793
  });
@@ -11812,7 +11903,8 @@ function assertAudioNotInterrupted(failures) {
11812
11903
  }
11813
11904
  function runAudioStage(input) {
11814
11905
  return collectScratchLeftovers(
11815
- () => runAudioStageScoped(input),
11906
+ () => withFfmpegProgress(input.onFfmpegProgress ?? (() => {
11907
+ }), () => runAudioStageScoped(input)),
11816
11908
  (left) => {
11817
11909
  if (left.length > 0) input.log?.warn("[audio] scratch left behind", { count: left.length });
11818
11910
  }
@@ -15317,9 +15409,10 @@ async function executeRenderPipeline(input) {
15317
15409
  nativeHdrVideoCount: nativeHdrVideoIds.size,
15318
15410
  nativeHdrImageCount: nativeHdrImageIds.size
15319
15411
  });
15320
- updateJobStatus(job, "preprocessing", "Processing audio tracks", 20, onProgress, {
15412
+ updateJobStatus(job, "preprocessing", AUDIO_STAGE, 20, onProgress, {
15321
15413
  code: "process_audio"
15322
15414
  });
15415
+ const audioWait = audioWaitReporter(job, onProgress);
15323
15416
  const audioStage = observeRenderStage(
15324
15417
  observability,
15325
15418
  "audio_process",
@@ -15338,7 +15431,8 @@ async function executeRenderPipeline(input) {
15338
15431
  abortSignal: executionSignal,
15339
15432
  assertNotAborted,
15340
15433
  log,
15341
- keepDeliverySource: true
15434
+ keepDeliverySource: true,
15435
+ onFfmpegProgress: audioWait.progressed
15342
15436
  })
15343
15437
  );
15344
15438
  pendingAudio = audioStage.catch(() => void 0);
@@ -16148,7 +16242,7 @@ async function executeRenderPipeline(input) {
16148
16242
  }
16149
16243
  const effectiveQuality = job.config.crf ?? preset.quality;
16150
16244
  const effectiveBitrate = job.config.crf != null ? void 0 : job.config.videoBitrate;
16151
- const audioResult = await audioStage;
16245
+ const audioResult = await audioWait.wait(audioStage);
16152
16246
  const { audioOutputPath, deliverySourcePath, hasAudio } = audioResult;
16153
16247
  perfStages.audioProcessMs = audioResult.audioProcessMs;
16154
16248
  recordLimiterAttenuation(job, audioResult.audioLoweredDb);
@@ -17004,8 +17098,9 @@ import {
17004
17098
  closeSync as closeSync5,
17005
17099
  constants as constants3
17006
17100
  } from "node:fs";
17007
- import { resolve as resolve9, join as join33, relative as relative4, isAbsolute as isAbsolute3, sep as sep4 } from "node:path";
17008
- import { lintHyperframeHtml } from "@hyperframes/lint";
17101
+ import { resolve as resolve9, join as join33, relative as relative4, isAbsolute as isAbsolute3, sep as sep4, dirname as dirname15 } from "node:path";
17102
+ import { fileURLToPath as fileURLToPath5 } from "node:url";
17103
+ import { Worker as Worker2 } from "node:worker_threads";
17009
17104
  function isStringRecord(value) {
17010
17105
  if (!value || typeof value !== "object" || Array.isArray(value)) {
17011
17106
  return false;
@@ -17111,17 +17206,111 @@ function prepareHyperframeLintBody(body, isAllowedEntry) {
17111
17206
  }
17112
17207
  return { error: "Missing lint source: provide projectDir, files, or html" };
17113
17208
  }
17114
- async function runHyperframeLint(prepared) {
17115
- return lintHyperframeHtml(prepared.html, {
17116
- filePath: prepared.entryFile,
17117
- compSrcPath: prepared.entryFile
17209
+ var LINT_HEAP_MB = 512;
17210
+ var LINT_TIMEOUT_MS = 15e3;
17211
+ var LINT_MAX_WORKERS = 2;
17212
+ var waiting = [];
17213
+ var running = 0;
17214
+ function takeLintSlot(limit, waitMs) {
17215
+ if (running < limit) {
17216
+ running++;
17217
+ return Promise.resolve(true);
17218
+ }
17219
+ return new Promise((resolve11) => {
17220
+ const entry = () => {
17221
+ clearTimeout(timer);
17222
+ running++;
17223
+ resolve11(true);
17224
+ };
17225
+ const timer = setTimeout(
17226
+ () => {
17227
+ waiting.splice(waiting.indexOf(entry), 1);
17228
+ resolve11(false);
17229
+ },
17230
+ Math.max(0, waitMs)
17231
+ );
17232
+ waiting.push(entry);
17233
+ });
17234
+ }
17235
+ function freeLintSlot() {
17236
+ running--;
17237
+ waiting.shift()?.();
17238
+ }
17239
+ function resolveLintWorkerEntry() {
17240
+ const here = dirname15(fileURLToPath5(import.meta.url));
17241
+ for (const name of ["hyperframeLintWorker.js", "hyperframeLintWorker.ts"]) {
17242
+ const candidate = join33(here, name);
17243
+ if (existsSync22(candidate)) return candidate;
17244
+ }
17245
+ return void 0;
17246
+ }
17247
+ function abortedLintResult(filePath, afterMs) {
17248
+ return {
17249
+ ok: false,
17250
+ errorCount: 1,
17251
+ warningCount: 0,
17252
+ infoCount: 0,
17253
+ findings: [
17254
+ {
17255
+ code: "lint_aborted",
17256
+ severity: "error",
17257
+ message: "This composition's script could not be checked: linting it ran too long or out of memory, so it was stopped. A very large or deeply nested script is the usual cause.",
17258
+ file: filePath
17259
+ }
17260
+ ],
17261
+ timings: { totalMs: afterMs, groupMs: {}, slowestRule: "", slowestRuleMs: 0 }
17262
+ };
17263
+ }
17264
+ async function runHyperframeLint(prepared, options = {}) {
17265
+ const began = performance.now();
17266
+ const aborted = () => abortedLintResult(prepared.entryFile, Math.round(performance.now() - began));
17267
+ const entry = options.workerEntry ?? resolveLintWorkerEntry();
17268
+ if (!entry) return aborted();
17269
+ const timeoutMs = options.timeoutMs ?? LINT_TIMEOUT_MS;
17270
+ const gotSlot = await takeLintSlot(options.maxWorkers ?? LINT_MAX_WORKERS, timeoutMs);
17271
+ if (!gotSlot) return aborted();
17272
+ const remainingMs = Math.max(0, timeoutMs - (performance.now() - began));
17273
+ return new Promise((resolvePromise, reject) => {
17274
+ let worker;
17275
+ try {
17276
+ worker = new Worker2(entry, {
17277
+ workerData: {
17278
+ html: prepared.html,
17279
+ opts: { filePath: prepared.entryFile, compSrcPath: prepared.entryFile }
17280
+ },
17281
+ resourceLimits: { maxOldGenerationSizeMb: options.heapMb ?? LINT_HEAP_MB },
17282
+ stdout: false,
17283
+ stderr: false
17284
+ });
17285
+ } catch {
17286
+ freeLintSlot();
17287
+ resolvePromise(aborted());
17288
+ return;
17289
+ }
17290
+ let settled = false;
17291
+ const settle = (finish) => {
17292
+ if (settled) return;
17293
+ settled = true;
17294
+ clearTimeout(timer);
17295
+ void worker.terminate().finally(freeLintSlot);
17296
+ finish();
17297
+ };
17298
+ const timer = setTimeout(() => settle(() => resolvePromise(aborted())), remainingMs);
17299
+ worker.on(
17300
+ "message",
17301
+ (message) => settle(
17302
+ () => message.result ? resolvePromise(message.result) : reject(new Error(message.error))
17303
+ )
17304
+ );
17305
+ worker.on("error", () => settle(() => resolvePromise(aborted())));
17306
+ worker.on("exit", () => settle(() => resolvePromise(aborted())));
17118
17307
  });
17119
17308
  }
17120
17309
 
17121
17310
  // src/services/healthWorker.ts
17122
- import { Worker as Worker2 } from "node:worker_threads";
17123
- import { fileURLToPath as fileURLToPath5 } from "node:url";
17124
- import { dirname as dirname15, join as join34 } from "node:path";
17311
+ import { Worker as Worker3 } from "node:worker_threads";
17312
+ import { fileURLToPath as fileURLToPath6 } from "node:url";
17313
+ import { dirname as dirname16, join as join34 } from "node:path";
17125
17314
  import { existsSync as existsSync23 } from "node:fs";
17126
17315
  var DEFAULT_HEALTH_PORT = 9848;
17127
17316
  async function startHealthWorker(options = {}) {
@@ -17133,7 +17322,7 @@ async function startHealthWorker(options = {}) {
17133
17322
  "[healthWorker] could not resolve worker entry. Pass options.workerEntry or ensure healthWorkerThread.{js,ts} is co-located."
17134
17323
  );
17135
17324
  }
17136
- const worker = new Worker2(entry, {
17325
+ const worker = new Worker3(entry, {
17137
17326
  workerData: { port },
17138
17327
  // Keep stdio inherited so the worker's console logs land in the pod logs
17139
17328
  // alongside the main thread's.
@@ -17196,7 +17385,7 @@ function defaultLogger2() {
17196
17385
  };
17197
17386
  }
17198
17387
  function resolveWorkerEntry2() {
17199
- const here = dirname15(fileURLToPath5(import.meta.url));
17388
+ const here = dirname16(fileURLToPath6(import.meta.url));
17200
17389
  const candidates = [join34(here, "healthWorkerThread.js"), join34(here, "healthWorkerThread.ts")];
17201
17390
  for (const candidate of candidates) {
17202
17391
  if (existsSync23(candidate)) return candidate;
@@ -17272,9 +17461,9 @@ import {
17272
17461
 
17273
17462
  // src/services/distributed/shared.ts
17274
17463
  import { execFile as execFileCallback } from "node:child_process";
17275
- import { dirname as dirname16, join as join35 } from "node:path";
17464
+ import { dirname as dirname17, join as join35 } from "node:path";
17276
17465
  import { existsSync as existsSync24, readFileSync as readFileSync11 } from "node:fs";
17277
- import { fileURLToPath as fileURLToPath6 } from "node:url";
17466
+ import { fileURLToPath as fileURLToPath7 } from "node:url";
17278
17467
  import { promisify as promisify2 } from "node:util";
17279
17468
  import {
17280
17469
  getFfmpegBinary,
@@ -17285,7 +17474,7 @@ var execFile = promisify2(execFileCallback);
17285
17474
  var cachedProducerVersion = null;
17286
17475
  function readProducerVersion() {
17287
17476
  if (cachedProducerVersion !== null) return cachedProducerVersion;
17288
- const startDir = dirname16(fileURLToPath6(import.meta.url));
17477
+ const startDir = dirname17(fileURLToPath7(import.meta.url));
17289
17478
  let current = startDir;
17290
17479
  for (let i = 0; i < 10; i++) {
17291
17480
  const candidate = join35(current, "package.json");
@@ -17299,7 +17488,7 @@ function readProducerVersion() {
17299
17488
  } catch {
17300
17489
  }
17301
17490
  }
17302
- const parent = dirname16(current);
17491
+ const parent = dirname17(current);
17303
17492
  if (parent === current) break;
17304
17493
  current = parent;
17305
17494
  }
@@ -17805,7 +17994,7 @@ function resolvePreparedRenderOutput(prepared, rendersDir, log, confineOutput) {
17805
17994
  throw new Error("outputPath must be inside the renders directory");
17806
17995
  }
17807
17996
  }
17808
- const outputDir = dirname17(absoluteOutputPath);
17997
+ const outputDir = dirname18(absoluteOutputPath);
17809
17998
  if (!existsSync25(outputDir)) mkdirSync13(outputDir, { recursive: true });
17810
17999
  return { input, cleanupProjectDir, absoluteOutputPath };
17811
18000
  }