@hyperframes/producer 0.9.40 → 0.9.42

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.
@@ -4,7 +4,7 @@
4
4
  import {
5
5
  existsSync as existsSync25,
6
6
  mkdirSync as mkdirSync13,
7
- statSync as statSync11,
7
+ statSync as statSync12,
8
8
  mkdtempSync,
9
9
  writeFileSync as writeFileSync8,
10
10
  rmSync as rmSync13,
@@ -30,7 +30,7 @@ import {
30
30
  mkdirSync as mkdirSync12,
31
31
  readdirSync as readdirSync6,
32
32
  rmSync as rmSync12,
33
- statSync as statSync9,
33
+ statSync as statSync10,
34
34
  writeFileSync as writeFileSync7,
35
35
  copyFileSync as copyFileSync5,
36
36
  appendFileSync
@@ -96,7 +96,7 @@ import { settleOnBrowserSafePort } from "@hyperframes/engine";
96
96
  import {
97
97
  existsSync as existsSync2,
98
98
  realpathSync,
99
- statSync,
99
+ statSync as statSync2,
100
100
  createReadStream,
101
101
  openSync,
102
102
  fstatSync,
@@ -106,7 +106,7 @@ import {
106
106
  } from "node:fs";
107
107
  import { promisify } from "node:util";
108
108
  import { Readable } from "node:stream";
109
- import { join, extname, resolve as resolve2, sep } from "node:path";
109
+ import { join as join2, extname, resolve as resolve2, sep as sep2 } from "node:path";
110
110
  import { injectScriptsAtHeadStart, injectScriptsIntoHtml } from "@hyperframes/core/compiler";
111
111
  import { fpsToNumber } from "@hyperframes/core";
112
112
  import { stripSdrPngColourTags } from "@hyperframes/core/compiler/png-colour-tags";
@@ -227,12 +227,86 @@ var defaultLogger = createConsoleLogger(
227
227
  process.env.HF_DEBUG_RENDER === "1" ? "debug" : "info"
228
228
  );
229
229
 
230
+ // src/utils/paths.ts
231
+ import {
232
+ basename,
233
+ join,
234
+ sep,
235
+ resolve as nodeResolve,
236
+ relative as nodeRelative,
237
+ isAbsolute as nodeIsAbsolute
238
+ } from "node:path";
239
+ import { statSync } from "node:fs";
240
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
241
+ import { isSafePath } from "@hyperframes/core/safe-path";
242
+ import {
243
+ isCopiedOutsideFileType,
244
+ isPrivateOutsideFile,
245
+ leftOutWarning,
246
+ linksOutside
247
+ } from "@hyperframes/studio-server/outside-file";
248
+ import { realFilePath } from "@hyperframes/studio-server/safe-path";
249
+ var DEFAULT_RENDERS_DIR = process.env.PRODUCER_RENDERS_DIR ?? // fileURLToPath (not URL.pathname): on Windows .pathname is "/D:/..." which
250
+ // resolves to a bogus renders dir.
251
+ nodeResolve(fileURLToPath2(import.meta.url), "../../..", "renders");
252
+ var LEADING_PARENT_SEGMENT_RE = /^\.\.(?:[\\/]|$)/;
253
+ function isPathInside(childPath, parentPath, options = {}) {
254
+ const resolvePath = options.pathModule?.resolve ?? nodeResolve;
255
+ const relativePath = options.pathModule?.relative ?? nodeRelative;
256
+ const isPathAbsolute = options.pathModule?.isAbsolute ?? nodeIsAbsolute;
257
+ const absChild = resolvePath(childPath);
258
+ const absParent = resolvePath(parentPath);
259
+ if (absChild === absParent) return true;
260
+ const rel = relativePath(absParent, absChild);
261
+ return rel !== "" && !LEADING_PARENT_SEGMENT_RE.test(rel) && !isPathAbsolute(rel);
262
+ }
263
+ function escapesAssetRoot(path, assetRoot) {
264
+ return assetRoot !== void 0 && !isSafePath(assetRoot, path);
265
+ }
266
+ function outsideAssetRefusal(projectDir, path) {
267
+ if (!linksOutside(projectDir, path)) return null;
268
+ if (isPrivateOutsideFile(projectDir, path)) return "blocklisted";
269
+ const folder = statSync(path, { throwIfNoEntry: false })?.isDirectory();
270
+ return folder || isCopiedOutsideFileType(path) ? null : "file_type";
271
+ }
272
+ var leftOutOfRender = (file, reference, reason) => leftOutWarning(file, reference, reason, "render");
273
+ function refusesOutsideLink(projectDir, path, warn) {
274
+ const refusal = outsideAssetRefusal(projectDir, path);
275
+ if (!refusal) return false;
276
+ const file = nodeRelative(projectDir, path).split(sep).join("/");
277
+ warn(leftOutOfRender(file, realFilePath(path), refusal));
278
+ return true;
279
+ }
280
+ function toExternalAssetKey(absPath) {
281
+ if (absPath.startsWith("hf-ext/")) return absPath;
282
+ let normalised = absPath.replace(/\\/g, "/");
283
+ normalised = normalised.replace(/^\/\/\?\/UNC\//i, "//");
284
+ normalised = normalised.replace(/^\/\/\?\//, "");
285
+ normalised = normalised.replace(/^\/\/([^/]+)\//, "unc/$1/");
286
+ normalised = normalised.replace(/^\/+/, "");
287
+ normalised = normalised.replace(/^([A-Za-z]):\/?/, "$1/");
288
+ return "hf-ext/" + normalised;
289
+ }
290
+ function formatCaptureFrameName(index, ext) {
291
+ return `frame_${String(index).padStart(6, "0")}.${ext}`;
292
+ }
293
+ function formatExportFrameName(index, ext) {
294
+ return `frame_${String(index + 1).padStart(6, "0")}.${ext}`;
295
+ }
296
+ function resolveRenderPaths(projectDir, outputPath, rendersDir = DEFAULT_RENDERS_DIR) {
297
+ const absoluteProjectDir = nodeResolve(projectDir);
298
+ const projectName = basename(absoluteProjectDir);
299
+ const resolvedOutputPath = outputPath ?? join(rendersDir, `${projectName}.mp4`);
300
+ const absoluteOutputPath = nodeResolve(resolvedOutputPath);
301
+ return { absoluteProjectDir, absoluteOutputPath };
302
+ }
303
+
230
304
  // src/services/fileServer.ts
231
305
  var readFileAsync = promisify(readFile);
232
- function isPathInside(child2, parent, options = {}) {
306
+ function isPathInside2(child2, parent, options = {}) {
233
307
  const { resolveSymlinks = false, pathModule } = options;
234
308
  const resolveFn = pathModule?.resolve ?? resolve2;
235
- const separator = pathModule?.sep ?? sep;
309
+ const separator = pathModule?.sep ?? sep2;
236
310
  const resolvedChild = resolveFn(child2);
237
311
  const resolvedParent = resolveFn(parent);
238
312
  const normalizedChild = resolveSymlinks && existsSync2(resolvedChild) ? realpathSync.native(resolvedChild) : resolvedChild;
@@ -759,7 +833,7 @@ function openRegularFile(filePath) {
759
833
  } catch (error) {
760
834
  if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
761
835
  return null;
762
- if (!statSync(filePath, { throwIfNoEntry: false })?.isFile()) return null;
836
+ if (!statSync2(filePath, { throwIfNoEntry: false })?.isFile()) return null;
763
837
  throw error;
764
838
  }
765
839
  let accepted = false;
@@ -788,6 +862,7 @@ function createFileServer(options) {
788
862
  const headScripts = options.headScripts ?? [getVerifiedHyperframeRuntimeSource()];
789
863
  const bodyScripts = options.bodyScripts ?? [buildRenderModeScript(options.fps), HF_BRIDGE_SCRIPT];
790
864
  const app = new Hono();
865
+ const warnLeftOut = (line) => console.warn(`[FileServer] ${line}`);
791
866
  app.get("/*", async (c) => {
792
867
  let requestPath = c.req.path;
793
868
  if (requestPath === "/") requestPath = "/index.html";
@@ -800,9 +875,12 @@ function createFileServer(options) {
800
875
  }).join("/");
801
876
  let file = null;
802
877
  for (const root of compiledDir ? [compiledDir, projectDir] : [projectDir]) {
803
- const candidate = join(root, relativePath);
878
+ const candidate = join2(root, relativePath);
804
879
  const resolveSymlinks = !allowOutsideProjectAssets && root !== compiledDir;
805
- if (isPathInside(candidate, root, { resolveSymlinks })) file = openRegularFile(candidate);
880
+ if (!isPathInside2(candidate, root, { resolveSymlinks })) continue;
881
+ const checksLinks = allowOutsideProjectAssets && root !== compiledDir;
882
+ if (checksLinks && refusesOutsideLink(root, candidate, warnLeftOut)) continue;
883
+ file = openRegularFile(candidate);
806
884
  if (file) break;
807
885
  }
808
886
  if (!file) {
@@ -1048,59 +1126,6 @@ import {
1048
1126
  import {
1049
1127
  mediaIdPathSegment
1050
1128
  } from "@hyperframes/engine";
1051
-
1052
- // src/utils/paths.ts
1053
- import {
1054
- basename,
1055
- join as join2,
1056
- resolve as nodeResolve,
1057
- relative as nodeRelative,
1058
- isAbsolute as nodeIsAbsolute
1059
- } from "node:path";
1060
- import { fileURLToPath as fileURLToPath2 } from "node:url";
1061
- import { isSafePath } from "@hyperframes/core/safe-path";
1062
- var DEFAULT_RENDERS_DIR = process.env.PRODUCER_RENDERS_DIR ?? // fileURLToPath (not URL.pathname): on Windows .pathname is "/D:/..." which
1063
- // resolves to a bogus renders dir.
1064
- nodeResolve(fileURLToPath2(import.meta.url), "../../..", "renders");
1065
- var LEADING_PARENT_SEGMENT_RE = /^\.\.(?:[\\/]|$)/;
1066
- function isPathInside2(childPath, parentPath, options = {}) {
1067
- const resolvePath = options.pathModule?.resolve ?? nodeResolve;
1068
- const relativePath = options.pathModule?.relative ?? nodeRelative;
1069
- const isPathAbsolute = options.pathModule?.isAbsolute ?? nodeIsAbsolute;
1070
- const absChild = resolvePath(childPath);
1071
- const absParent = resolvePath(parentPath);
1072
- if (absChild === absParent) return true;
1073
- const rel = relativePath(absParent, absChild);
1074
- return rel !== "" && !LEADING_PARENT_SEGMENT_RE.test(rel) && !isPathAbsolute(rel);
1075
- }
1076
- function escapesAssetRoot(path, assetRoot) {
1077
- return assetRoot !== void 0 && !isSafePath(assetRoot, path);
1078
- }
1079
- function toExternalAssetKey(absPath) {
1080
- if (absPath.startsWith("hf-ext/")) return absPath;
1081
- let normalised = absPath.replace(/\\/g, "/");
1082
- normalised = normalised.replace(/^\/\/\?\/UNC\//i, "//");
1083
- normalised = normalised.replace(/^\/\/\?\//, "");
1084
- normalised = normalised.replace(/^\/\/([^/]+)\//, "unc/$1/");
1085
- normalised = normalised.replace(/^\/+/, "");
1086
- normalised = normalised.replace(/^([A-Za-z]):\/?/, "$1/");
1087
- return "hf-ext/" + normalised;
1088
- }
1089
- function formatCaptureFrameName(index, ext) {
1090
- return `frame_${String(index).padStart(6, "0")}.${ext}`;
1091
- }
1092
- function formatExportFrameName(index, ext) {
1093
- return `frame_${String(index + 1).padStart(6, "0")}.${ext}`;
1094
- }
1095
- function resolveRenderPaths(projectDir, outputPath, rendersDir = DEFAULT_RENDERS_DIR) {
1096
- const absoluteProjectDir = nodeResolve(projectDir);
1097
- const projectName = basename(absoluteProjectDir);
1098
- const resolvedOutputPath = outputPath ?? join2(rendersDir, `${projectName}.mp4`);
1099
- const absoluteOutputPath = nodeResolve(resolvedOutputPath);
1100
- return { absoluteProjectDir, absoluteOutputPath };
1101
- }
1102
-
1103
- // src/services/render/shared.ts
1104
1129
  var BROWSER_MEDIA_EPSILON = 1e-4;
1105
1130
  function resolveBrowserMediaEnd(start, end, duration) {
1106
1131
  return Number.isFinite(duration) && duration > 0 ? start + duration : end;
@@ -1137,7 +1162,7 @@ function writeCompiledArtifacts(compiled, workDir, includeSummary) {
1137
1162
  writeFileSync(join3(compileDir, "index.html"), compiled.html, "utf-8");
1138
1163
  for (const [srcPath, html] of compiled.subCompositions) {
1139
1164
  const outPath = join3(compileDir, srcPath);
1140
- if (!isPathInside2(outPath, compileDir)) {
1165
+ if (!isPathInside(outPath, compileDir)) {
1141
1166
  console.warn(`[Render] Skipping sub-composition with unsafe path: ${srcPath}`);
1142
1167
  continue;
1143
1168
  }
@@ -1146,7 +1171,7 @@ function writeCompiledArtifacts(compiled, workDir, includeSummary) {
1146
1171
  }
1147
1172
  for (const [relativePath, absolutePath] of compiled.externalAssets) {
1148
1173
  const outPath = resolve3(join3(compileDir, relativePath));
1149
- if (!isPathInside2(outPath, compileDir)) {
1174
+ if (!isPathInside(outPath, compileDir)) {
1150
1175
  console.warn(`[Render] Skipping external asset with unsafe path: ${relativePath}`);
1151
1176
  continue;
1152
1177
  }
@@ -1408,7 +1433,7 @@ function materializeExtractedFramesForCompiledDir(extracted, compiledDir, option
1408
1433
  const compiledFrameRoot = pathModule.join(resolvedCompiledDir, "__hyperframes_video_frames");
1409
1434
  for (const ext of extracted) {
1410
1435
  const resolvedOut = pathModule.resolve(ext.outputDir);
1411
- if (isPathInside2(resolvedOut, resolvedCompiledDir, { pathModule })) continue;
1436
+ if (isPathInside(resolvedOut, resolvedCompiledDir, { pathModule })) continue;
1412
1437
  const linkPath = pathModule.join(compiledFrameRoot, mediaIdPathSegment(ext.videoId));
1413
1438
  if (!fileSystem.existsSync(linkPath)) {
1414
1439
  fileSystem.mkdirSync(pathModule.dirname(linkPath), { recursive: true });
@@ -2138,7 +2163,7 @@ function replanAfterFailure(plan, failure) {
2138
2163
  }
2139
2164
 
2140
2165
  // src/services/render/stages/captureSegmentedStage.ts
2141
- import { existsSync as existsSync6, mkdirSync as mkdirSync3, rmSync as rmSync6, statSync as statSync3 } from "node:fs";
2166
+ import { existsSync as existsSync6, mkdirSync as mkdirSync3, rmSync as rmSync6, statSync as statSync4 } from "node:fs";
2142
2167
  import { join as join9 } from "node:path";
2143
2168
  import {
2144
2169
  captureFrameToBuffer as captureFrameToBuffer2,
@@ -3033,7 +3058,7 @@ async function compositeHdrFrame(ctx, canvas, time, fullStacking, elementFilter,
3033
3058
  }
3034
3059
 
3035
3060
  // src/services/render/stages/captureHdrResources.ts
3036
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync as rmSync5, statSync as statSync2, statfsSync } from "node:fs";
3061
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync as rmSync5, statSync as statSync3, statfsSync } from "node:fs";
3037
3062
  import {
3038
3063
  decodePngToRgb48le,
3039
3064
  extractMediaMetadata as extractMediaMetadata2,
@@ -3448,7 +3473,7 @@ async function extractHdrVideoFrames(args) {
3448
3473
  failureReason: result.failureReason
3449
3474
  });
3450
3475
  }
3451
- return Math.min(Math.floor(statSync2(spec.path).size / frameSize), spec.frames);
3476
+ return Math.min(Math.floor(statSync3(spec.path).size / frameSize), spec.frames);
3452
3477
  }
3453
3478
  });
3454
3479
  const first = await windows.lease(0);
@@ -4743,7 +4768,7 @@ async function captureSegmentToEncoder(ctx, segment) {
4743
4768
  path: segmentPath,
4744
4769
  // Recorded so resume can prove the file on disk is the one that
4745
4770
  // finished; absent only in unit tests, whose fake encoder writes none.
4746
- bytes: existsSync6(segmentPath) ? statSync3(segmentPath).size : 0
4771
+ bytes: existsSync6(segmentPath) ? statSync4(segmentPath).size : 0
4747
4772
  });
4748
4773
  return encodeResult;
4749
4774
  } finally {
@@ -5778,7 +5803,7 @@ function createSegmentVideoFrames(input) {
5778
5803
  }
5779
5804
 
5780
5805
  // src/services/render/videoFrameWindow.ts
5781
- import { readdirSync as readdirSync3, statSync as statSync4 } from "node:fs";
5806
+ import { readdirSync as readdirSync3, statSync as statSync5 } from "node:fs";
5782
5807
  import { join as join13 } from "node:path";
5783
5808
  function shouldWindowVideoFrames(args) {
5784
5809
  return args.segmented && args.env.HF_VIDEO_FRAME_WINDOW?.trim().toLowerCase() === "true";
@@ -5794,7 +5819,7 @@ function directoryBytes(path) {
5794
5819
  for (const entry of entries) {
5795
5820
  const child2 = join13(path, entry.name);
5796
5821
  try {
5797
- bytes += entry.isDirectory() ? directoryBytes(child2) : statSync4(child2).size;
5822
+ bytes += entry.isDirectory() ? directoryBytes(child2) : statSync5(child2).size;
5798
5823
  } catch {
5799
5824
  }
5800
5825
  }
@@ -5823,7 +5848,7 @@ function trackSegmentFramePeak(frames, rootDir, onPeak) {
5823
5848
 
5824
5849
  // src/services/render/segmentManifest.ts
5825
5850
  import { createHash as createHash2 } from "node:crypto";
5826
- import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync4, statSync as statSync5, writeFileSync as writeFileSync3 } from "node:fs";
5851
+ import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync4, statSync as statSync6, writeFileSync as writeFileSync3 } from "node:fs";
5827
5852
  import { join as join14 } from "node:path";
5828
5853
  import { renameWithRetry as renameWithRetry2 } from "@hyperframes/engine";
5829
5854
  var MANIFEST_FILENAME = "segments.json";
@@ -5901,7 +5926,7 @@ async function validateCompletedSegments(manifest, expectedHash, probeFrames) {
5901
5926
  if (manifest.planHash !== expectedHash) return ok;
5902
5927
  for (const entry of manifest.completed) {
5903
5928
  if (!existsSync7(entry.path)) continue;
5904
- const size = statSync5(entry.path).size;
5929
+ const size = statSync6(entry.path).size;
5905
5930
  if (size <= 0 || size !== entry.bytes) continue;
5906
5931
  const frames = await probeFrames(entry.path);
5907
5932
  if (frames !== entry.endFrame - entry.startFrame) continue;
@@ -6499,7 +6524,7 @@ import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolu
6499
6524
  import { decodedUrlPath } from "@hyperframes/parsers/asset-paths";
6500
6525
  import { createHash as createHash6 } from "node:crypto";
6501
6526
  import { createReadStream as createReadStream2, existsSync as existsSync11, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
6502
- import { join as join19, dirname as dirname8, resolve as resolve7, basename as basename5, relative as relative2, sep as sep2 } from "path";
6527
+ import { join as join19, dirname as dirname8, resolve as resolve7, basename as basename5, relative as relative2, sep as sep3 } from "path";
6503
6528
  import { parseHTML as parseHTML5 } from "linkedom";
6504
6529
 
6505
6530
  // src/services/bundledScripts.ts
@@ -6534,6 +6559,7 @@ import {
6534
6559
  rewriteInlineStyleAssetUrls
6535
6560
  } from "@hyperframes/core";
6536
6561
  import { MAX_AUDIO_GAIN } from "@hyperframes/core/audio-gain";
6562
+ import { CAPTURE_CANVAS_SELECTOR } from "@hyperframes/core/html-in-canvas";
6537
6563
  import { readPlaybackRate } from "@hyperframes/parsers/media-duration";
6538
6564
  import { resolveRateSpec } from "@hyperframes/core/speed-ramp";
6539
6565
  import { gsapCdnDist as gsapCdnDist2, normalizeGsapBaseUrl } from "@hyperframes/core/gsap-cdn";
@@ -6763,7 +6789,7 @@ import {
6763
6789
 
6764
6790
  // src/services/animatedGifPrep.ts
6765
6791
  import { createHash as createHash4 } from "node:crypto";
6766
- import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync6 } from "node:fs";
6792
+ import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync7 } from "node:fs";
6767
6793
  import { dirname as dirname6, isAbsolute as isAbsolute2, join as join16, resolve as resolve5 } from "node:path";
6768
6794
  import { parseHTML as parseHTML3 } from "linkedom";
6769
6795
  import { parseAnimatedGifMetadata } from "@hyperframes/core";
@@ -6811,12 +6837,12 @@ function resolveLocalImageSourcePath(src, options) {
6811
6837
  ...protocolRelativeUrlOnShare ? [] : [isAbsolute2(basePath) ? basePath : resolve5(options.projectDir, projectRelative)],
6812
6838
  resolve5(options.downloadDir, normalizedBase)
6813
6839
  ];
6814
- const allowed = (candidate) => !escapesAssetRoot(candidate, options.assetRoot) || !escapesAssetRoot(candidate, options.downloadDir);
6840
+ const allowed = (candidate) => !escapesAssetRoot(candidate, options.assetRoot) && outsideAssetRefusal(options.projectDir, candidate) !== "blocklisted" || !escapesAssetRoot(candidate, options.downloadDir);
6815
6841
  return candidates.find((candidate) => existsSync9(candidate) && allowed(candidate)) ?? null;
6816
6842
  }
6817
6843
  function isUsableFile(path) {
6818
6844
  try {
6819
- const stat = statSync6(path);
6845
+ const stat = statSync7(path);
6820
6846
  return stat.isFile() && stat.size > 0;
6821
6847
  } catch {
6822
6848
  return false;
@@ -7080,7 +7106,7 @@ import {
7080
7106
  readFileSync as readFileSync7,
7081
7107
  readSync as readSync3,
7082
7108
  rmSync as rmSync10,
7083
- statSync as statSync7,
7109
+ statSync as statSync8,
7084
7110
  writeFileSync as writeFileSync4
7085
7111
  } from "node:fs";
7086
7112
  import { dirname as dirname7, join as join17, resolve as resolve6 } from "node:path";
@@ -7323,7 +7349,7 @@ function resolveImageSource(src, options) {
7323
7349
  }
7324
7350
  function isUsableFile2(path) {
7325
7351
  try {
7326
- return statSync7(path).size > 0;
7352
+ return statSync8(path).size > 0;
7327
7353
  } catch {
7328
7354
  return false;
7329
7355
  }
@@ -7457,6 +7483,11 @@ function dropMediaOutsideProject(input) {
7457
7483
  if (!src || isRemoteOrInlineSource(src)) return true;
7458
7484
  const path = resolveProjectRelativeSrc3(src, projectDir, compiledDir);
7459
7485
  if (roots.some((root) => !escapesAssetRoot(path, root))) return true;
7486
+ if (input.allowOutsideProjectAssets) {
7487
+ const refusal = outsideAssetRefusal(projectDir, path);
7488
+ if (refusal) log.warn(`[Render] ${leftOutOfRender(`Media "${id}"`, src, refusal)}`);
7489
+ return refusal === null;
7490
+ }
7460
7491
  log.warn(`[Render] Media "${id}" source is missing: it is outside the project folder`, { src });
7461
7492
  return false;
7462
7493
  };
@@ -7583,7 +7614,7 @@ function normalizeCompositionSrcs(html, projectDir) {
7583
7614
  if (!value.includes("%") && !value.startsWith("/")) return whole;
7584
7615
  const file = resolveCompositionSrc(projectDir, value);
7585
7616
  if (file === null) return whole;
7586
- return `${name}${quote}${relative2(projectDir, file).split(sep2).join("/")}${quote}`;
7617
+ return `${name}${quote}${relative2(projectDir, file).split(sep3).join("/")}${quote}`;
7587
7618
  });
7588
7619
  }
7589
7620
  function resolveCompositionFile(projectDir, src, assetRoot) {
@@ -7604,6 +7635,10 @@ function assertSubCompositionsUsable(html, projectDir, assetRoot, visited = /* @
7604
7635
  problems.push({ srcPath, detail: "it is outside the project folder" });
7605
7636
  continue;
7606
7637
  }
7638
+ if (outsideAssetRefusal(projectDir, filePath) === "blocklisted") {
7639
+ problems.push({ srcPath, detail: "it is outside the project in a private location" });
7640
+ continue;
7641
+ }
7607
7642
  if (isPrivateCompositionFile(projectDir, filePath)) {
7608
7643
  problems.push({ srcPath, detail: "it is git metadata or an env file" });
7609
7644
  continue;
@@ -7664,7 +7699,7 @@ function runtimeRoot(document2) {
7664
7699
  function detectRenderModeHints(html, pageMotionBlur) {
7665
7700
  const reasons = [];
7666
7701
  const { document: document2 } = parseHTML5(html);
7667
- if (document2.querySelector("canvas[layoutsubtree]")) {
7702
+ if (document2.querySelector(CAPTURE_CANVAS_SELECTOR)) {
7668
7703
  reasons.push({
7669
7704
  code: "htmlInCanvas",
7670
7705
  message: "Detected html-in-canvas API (layoutsubtree canvas). Chrome does not support concurrent drawElementImage across multiple workers; render is pinned to a single worker."
@@ -7672,7 +7707,7 @@ function detectRenderModeHints(html, pageMotionBlur) {
7672
7707
  } else if (pageMotionBlur !== "off" && runtimeRoot(document2)?.getAttribute("data-motion-blur") === "on") {
7673
7708
  reasons.push({
7674
7709
  code: "captureMotionBlur",
7675
- message: 'Detected capture motion blur (data-motion-blur="on"), which draws each frame with html-in-canvas; routed through screenshot capture mode.'
7710
+ message: 'Detected motion blur (data-motion-blur="on"), drawn per frame with an SVG filter or, on the capture tier, html-in-canvas; routed through screenshot capture mode.'
7676
7711
  });
7677
7712
  }
7678
7713
  if (document2.querySelector("iframe")) {
@@ -8309,17 +8344,24 @@ ${safeText}
8309
8344
  }
8310
8345
  return wrappedFragment ? document2.body.innerHTML || "" : document2.toString();
8311
8346
  }
8312
- function collectExternalAssets(html, projectDir) {
8347
+ function collectExternalAssets(html, projectDir, log = defaultLogger, file = "index.html") {
8313
8348
  const absProjectDir = resolve7(projectDir);
8314
8349
  const externalAssets = /* @__PURE__ */ new Map();
8350
+ const leftOut = /* @__PURE__ */ new Set();
8315
8351
  function processPath(rawPath) {
8316
8352
  const trimmed = rawPath.trim();
8317
8353
  if (isNonRelativeUrl(trimmed)) return null;
8318
8354
  const absPath = resolve7(absProjectDir, trimmed);
8319
- if (isPathInside2(absPath, absProjectDir)) {
8355
+ if (isPathInside(absPath, absProjectDir)) {
8320
8356
  return null;
8321
8357
  }
8322
8358
  if (!existsSync11(absPath)) return null;
8359
+ const refusal = outsideAssetRefusal(absProjectDir, absPath);
8360
+ if (refusal) {
8361
+ if (!leftOut.has(trimmed)) log.warn(`[Compiler] ${leftOutOfRender(file, trimmed, refusal)}`);
8362
+ leftOut.add(trimmed);
8363
+ return null;
8364
+ }
8323
8365
  const safeKey = toExternalAssetKey(absPath);
8324
8366
  externalAssets.set(safeKey, absPath);
8325
8367
  return safeKey;
@@ -8413,13 +8455,26 @@ async function localizeRemoteMediaSources(html, downloadDir) {
8413
8455
  if (m[1]) urlSet.add(m[1]);
8414
8456
  }
8415
8457
  }
8416
- return downloadAndRewriteUrls(
8458
+ const localized = await downloadAndRewriteUrls(
8417
8459
  urlSet,
8418
8460
  html,
8419
8461
  join19(downloadDir, REMOTE_MEDIA_SUBDIR),
8420
8462
  "Remote media download failed",
8421
8463
  "Localized remote media source(s)"
8422
8464
  );
8465
+ return { ...localized, html: dropBindingOnLocalizedMedia(localized.html) };
8466
+ }
8467
+ function dropBindingOnLocalizedMedia(html) {
8468
+ if (!html.includes("data-var-src")) return html;
8469
+ const { document: document2 } = parseHTML5(html);
8470
+ let changed = false;
8471
+ for (const el of document2.querySelectorAll("video[data-var-src], audio[data-var-src]")) {
8472
+ if (el.closest("[data-variable-values]")) continue;
8473
+ if (!el.getAttribute("src")?.startsWith(`${REMOTE_MEDIA_SUBDIR}/`)) continue;
8474
+ el.removeAttribute("data-var-src");
8475
+ changed = true;
8476
+ }
8477
+ return changed ? document2.toString() : html;
8423
8478
  }
8424
8479
  async function localizeRemoteImageSources(html, downloadDir) {
8425
8480
  const urlSet = /* @__PURE__ */ new Set();
@@ -8552,13 +8607,13 @@ function projectStylesheetFontFamilies(html, projectDir) {
8552
8607
  const href = /\bhref=["']([^"']+)["']/i.exec(tag)?.[1];
8553
8608
  if (!href || /^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(href)) continue;
8554
8609
  const sheet = resolve7(projectDir, decodedUrlPath(href).replace(/^(?:\.?\/)+/, ""));
8555
- if (!isPathInside2(sheet, projectDir) || !existsSync11(sheet)) continue;
8610
+ if (!isPathInside(sheet, projectDir) || !existsSync11(sheet)) continue;
8556
8611
  for (const face of extractFontFaceBlocks(readFileSync8(sheet, "utf8"))) {
8557
8612
  const family = /font-family\s*:\s*([^;}]+)/i.exec(face)?.[1]?.trim().replace(/^['"]|['"]$/g, "");
8558
8613
  const shipsFile = [...face.matchAll(LOCAL_FONTFACE_URL_RE)].some(([, url = ""]) => {
8559
8614
  const path = decodedUrlPath(url);
8560
8615
  const file = path.startsWith("/") ? resolve7(projectDir, `.${path}`) : resolve7(dirname8(sheet), path);
8561
- return isPathInside2(file, projectDir) && existsSync11(file);
8616
+ return isPathInside(file, projectDir) && existsSync11(file);
8562
8617
  });
8563
8618
  if (family && shipsFile) families.push(family);
8564
8619
  }
@@ -8624,7 +8679,7 @@ async function readLocalFont(absPath) {
8624
8679
  }
8625
8680
  return { kind: "inline", buffer: Buffer.concat(chunks, totalBytes) };
8626
8681
  }
8627
- async function embedLocalFontFaces(html, projectDir, assetRoot) {
8682
+ async function embedLocalFontFaces(html, projectDir, assetRoot, log = defaultLogger) {
8628
8683
  const { fontToDataUri: toDataUri } = await import("@hyperframes/core/fonts/embed");
8629
8684
  const styleBlockRe = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
8630
8685
  const fontFaceRe = /@font-face\s*\{([^}]*)\}/gi;
@@ -8645,7 +8700,11 @@ async function embedLocalFontFaces(html, projectDir, assetRoot) {
8645
8700
  const localPath = urlMatch[1];
8646
8701
  if (!localPath || embeddedPaths.has(localPath)) continue;
8647
8702
  const absPath = localPath.startsWith("/") ? localPath : resolve7(projectDir, localPath);
8648
- if (!isPathInside2(absPath, projectDir) || escapesAssetRoot(absPath, assetRoot)) continue;
8703
+ if (!isPathInside(absPath, projectDir) || escapesAssetRoot(absPath, assetRoot)) continue;
8704
+ if (refusesOutsideLink(projectDir, absPath, (line) => log.warn(`[Compiler] ${line}`))) {
8705
+ embeddedPaths.add(localPath);
8706
+ continue;
8707
+ }
8649
8708
  const ext = absPath.match(/\.(woff2?|ttf|otf|ttc)$/i)?.[1]?.toLowerCase() ?? "ttf";
8650
8709
  try {
8651
8710
  if (fileBackedAbsolutePaths.has(absPath)) {
@@ -8709,7 +8768,7 @@ function rewriteUnresolvableGsapToCdn(html, projectDir, compSrcPath) {
8709
8768
  );
8710
8769
  }
8711
8770
  function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath) {
8712
- if (!isPathInside2(htmlPath, projectDir)) return html;
8771
+ if (!isPathInside(htmlPath, projectDir)) return html;
8713
8772
  const entryPath = relative2(projectDir, htmlPath).replace(/\\/g, "/");
8714
8773
  if (!entryPath.includes("/")) return html;
8715
8774
  const { document: document2 } = parseHTML5(html);
@@ -8751,9 +8810,10 @@ function bindVariableMediaSources(html, variables) {
8751
8810
  }
8752
8811
  return changed ? document2.toString() : html;
8753
8812
  }
8813
+ var entryFileName = (projectDir, htmlPath) => isPathInside(htmlPath, projectDir) ? relative2(projectDir, htmlPath).split(sep3).join("/") : basename5(htmlPath);
8754
8814
  async function compileForRender(projectDir, htmlPath, downloadDir, options = {}) {
8755
8815
  const assetRoot = options.allowOutsideProjectAssets ? void 0 : projectDir;
8756
- if (isPathInside2(htmlPath, projectDir) && escapesAssetRoot(htmlPath, assetRoot)) {
8816
+ if (isPathInside(htmlPath, projectDir) && escapesAssetRoot(htmlPath, assetRoot)) {
8757
8817
  throw new Error(`Entry file ${htmlPath} leads outside the project folder`);
8758
8818
  }
8759
8819
  const entryHtml = rebaseDirectEntryAssetPaths(readTextFile(htmlPath), projectDir, htmlPath);
@@ -8865,8 +8925,18 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
8865
8925
  if (preparedGifs.length > 0) {
8866
8926
  defaultLogger.debug(`[Compiler] Prepared ${preparedGifs.length} animated GIF input(s) as WebM`);
8867
8927
  }
8868
- const embeddedHtml = await embedLocalFontFaces(htmlWithPreparedGifs, projectDir, assetRoot);
8869
- const { html, externalAssets } = options.allowOutsideProjectAssets ? collectExternalAssets(embeddedHtml, projectDir) : { html: embeddedHtml, externalAssets: /* @__PURE__ */ new Map() };
8928
+ const embeddedHtml = await embedLocalFontFaces(
8929
+ htmlWithPreparedGifs,
8930
+ projectDir,
8931
+ assetRoot,
8932
+ options.log
8933
+ );
8934
+ const { html, externalAssets } = options.allowOutsideProjectAssets ? collectExternalAssets(
8935
+ embeddedHtml,
8936
+ projectDir,
8937
+ options.log,
8938
+ entryFileName(projectDir, htmlPath)
8939
+ ) : { html: embeddedHtml, externalAssets: /* @__PURE__ */ new Map() };
8870
8940
  for (const [relPath, absPath] of remoteMediaAssets) {
8871
8941
  externalAssets.set(relPath, absPath);
8872
8942
  }
@@ -9437,9 +9507,13 @@ async function runCompileStage(input) {
9437
9507
  width: compiled.width,
9438
9508
  height: compiled.height
9439
9509
  };
9440
- if (!job.config.allowOutsideProjectAssets) {
9441
- dropMediaOutsideProject({ projectDir, workDir, composition, log });
9442
- }
9510
+ dropMediaOutsideProject({
9511
+ projectDir,
9512
+ workDir,
9513
+ composition,
9514
+ log,
9515
+ allowOutsideProjectAssets: job.config.allowOutsideProjectAssets
9516
+ });
9443
9517
  await preflightCompositionAssetMediaTypes({
9444
9518
  projectDir,
9445
9519
  compiledDir: join20(workDir, "compiled"),
@@ -10064,9 +10138,13 @@ async function runProbeStage(input) {
10064
10138
  }
10065
10139
  }
10066
10140
  }
10067
- if (!job.config.allowOutsideProjectAssets) {
10068
- dropMediaOutsideProject({ projectDir, workDir, composition, log });
10069
- }
10141
+ dropMediaOutsideProject({
10142
+ projectDir,
10143
+ workDir,
10144
+ composition,
10145
+ log,
10146
+ allowOutsideProjectAssets: job.config.allowOutsideProjectAssets
10147
+ });
10070
10148
  await preflightCompositionAssetMediaTypes({
10071
10149
  projectDir,
10072
10150
  compiledDir: join21(workDir, "compiled"),
@@ -12840,7 +12918,7 @@ import {
12840
12918
  readdirSync as readdirSync5,
12841
12919
  readFileSync as readFileSync9,
12842
12920
  rmSync as rmSync11,
12843
- statSync as statSync8,
12921
+ statSync as statSync9,
12844
12922
  writeFileSync as writeFileSync6
12845
12923
  } from "node:fs";
12846
12924
  import { readFile as readFile2 } from "node:fs/promises";
@@ -12969,7 +13047,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
12969
13047
  const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
12970
13048
  if (failure) return failure;
12971
13049
  }
12972
- const fileSize = existsSync20(outputPath) ? statSync8(outputPath).size : 0;
13050
+ const fileSize = existsSync20(outputPath) ? statSync9(outputPath).size : 0;
12973
13051
  return {
12974
13052
  success: true,
12975
13053
  outputPath,
@@ -13375,7 +13453,7 @@ function sampleDirectoryBytes(dir) {
13375
13453
  for (const name of entries) {
13376
13454
  const full = join32(current, name);
13377
13455
  try {
13378
- const st = statSync9(full);
13456
+ const st = statSync10(full);
13379
13457
  if (st.isDirectory()) {
13380
13458
  stack.push(full);
13381
13459
  } else if (st.isFile()) {
@@ -13530,7 +13608,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
13530
13608
  let rangeStart = null;
13531
13609
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
13532
13610
  const framePath = join32(framesDir, formatCaptureFrameName(frameIndex, frameExt));
13533
- const missing = !existsSync21(framePath) || statSync9(framePath).size <= 8;
13611
+ const missing = !existsSync21(framePath) || statSync10(framePath).size <= 8;
13534
13612
  if (missing && rangeStart === null) {
13535
13613
  rangeStart = frameIndex;
13536
13614
  } else if (!missing && rangeStart !== null) {
@@ -16463,13 +16541,13 @@ async function executeRenderPipeline(input) {
16463
16541
  import {
16464
16542
  existsSync as existsSync22,
16465
16543
  readFileSync as readFileSync10,
16466
- statSync as statSync10,
16544
+ statSync as statSync11,
16467
16545
  openSync as openSync5,
16468
16546
  fstatSync as fstatSync3,
16469
16547
  closeSync as closeSync5,
16470
16548
  constants as constants3
16471
16549
  } from "node:fs";
16472
- import { resolve as resolve9, join as join33, relative as relative4, isAbsolute as isAbsolute3, sep as sep3 } from "node:path";
16550
+ import { resolve as resolve9, join as join33, relative as relative4, isAbsolute as isAbsolute3, sep as sep4 } from "node:path";
16473
16551
  import { lintHyperframeHtml } from "@hyperframes/lint";
16474
16552
  function isStringRecord(value) {
16475
16553
  if (!value || typeof value !== "object" || Array.isArray(value)) {
@@ -16503,7 +16581,7 @@ function readEntryHtml(filePath) {
16503
16581
  } catch (error) {
16504
16582
  if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
16505
16583
  return null;
16506
- if (!statSync10(filePath, { throwIfNoEntry: false })?.isFile()) return null;
16584
+ if (!statSync11(filePath, { throwIfNoEntry: false })?.isFile()) return null;
16507
16585
  throw error;
16508
16586
  }
16509
16587
  try {
@@ -16515,7 +16593,7 @@ function readEntryHtml(filePath) {
16515
16593
  }
16516
16594
  function readProjectEntryFile(projectDir, preferredEntryFile) {
16517
16595
  const absProjectDir = resolve9(projectDir);
16518
- if (!existsSync22(absProjectDir) || !statSync10(absProjectDir).isDirectory()) {
16596
+ if (!existsSync22(absProjectDir) || !statSync11(absProjectDir).isDirectory()) {
16519
16597
  return { error: `Project directory not found: ${absProjectDir}` };
16520
16598
  }
16521
16599
  const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
@@ -16524,7 +16602,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile) {
16524
16602
  for (const entryFile of entryCandidates) {
16525
16603
  const absoluteEntryPath = resolve9(absProjectDir, entryFile);
16526
16604
  const entryRelativePath = relative4(absProjectDir, absoluteEntryPath);
16527
- if (entryRelativePath === ".." || entryRelativePath.startsWith(`..${sep3}`) || isAbsolute3(entryRelativePath)) {
16605
+ if (entryRelativePath === ".." || entryRelativePath.startsWith(`..${sep4}`) || isAbsolute3(entryRelativePath)) {
16528
16606
  return { error: `Entry file must stay inside project directory: ${entryFile}` };
16529
16607
  }
16530
16608
  const html = readEntryHtml(absoluteEntryPath);
@@ -16701,7 +16779,7 @@ import {
16701
16779
  createReferenceBackgroundRecorder as createReferenceBackgroundRecorder2
16702
16780
  } from "@hyperframes/engine";
16703
16781
  import { audioFailureDiagnostics as audioFailureDiagnostics3 } from "@hyperframes/engine";
16704
- import { extname as extname4, isAbsolute as isAbsolute4, join as join36, relative as relative5, sep as sep4 } from "node:path";
16782
+ import { extname as extname4, isAbsolute as isAbsolute4, join as join36, relative as relative5, sep as sep5 } from "node:path";
16705
16783
  import {
16706
16784
  fpsToNumber as fpsToNumber9,
16707
16785
  HF_COLOR_GRADING_ATTR as HF_COLOR_GRADING_ATTR2
@@ -17322,7 +17400,7 @@ function prepareProjectDirectory(projectDir, options) {
17322
17400
  const candidate = nonEmptyString(projectDir);
17323
17401
  if (!candidate) return null;
17324
17402
  const absProjectDir = resolve10(candidate);
17325
- if (!existsSync25(absProjectDir) || !statSync11(absProjectDir).isDirectory()) {
17403
+ if (!existsSync25(absProjectDir) || !statSync12(absProjectDir).isDirectory()) {
17326
17404
  return { error: `Project directory not found: ${absProjectDir}` };
17327
17405
  }
17328
17406
  const entry = options.entryFile || "index.html";
@@ -17418,7 +17496,7 @@ function cleanupTempDir(dir, log) {
17418
17496
  }
17419
17497
  }
17420
17498
  function outputFileSize(path) {
17421
- return existsSync25(path) ? statSync11(path).size : 0;
17499
+ return existsSync25(path) ? statSync12(path).size : 0;
17422
17500
  }
17423
17501
  function createBlockingProgressReporter(log, requestId) {
17424
17502
  let lastLoggedPct = -10;
@@ -17735,7 +17813,7 @@ function createRenderHandlers(options = {}) {
17735
17813
  store.delete(token);
17736
17814
  return c.json({ success: false, error: "Output artifact file missing" }, 404);
17737
17815
  }
17738
- const stats = statSync11(artifact.path);
17816
+ const stats = statSync12(artifact.path);
17739
17817
  return new Response(createReadStream3(artifact.path), {
17740
17818
  headers: {
17741
17819
  "content-type": "video/mp4",