@hyperframes/producer 0.9.41 → 0.9.43

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.
@@ -1 +1 @@
1
- export {};
1
+ export declare function parityChromeArgs(width: number, height: number): string[];
@@ -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
@@ -6764,7 +6789,7 @@ import {
6764
6789
 
6765
6790
  // src/services/animatedGifPrep.ts
6766
6791
  import { createHash as createHash4 } from "node:crypto";
6767
- 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";
6768
6793
  import { dirname as dirname6, isAbsolute as isAbsolute2, join as join16, resolve as resolve5 } from "node:path";
6769
6794
  import { parseHTML as parseHTML3 } from "linkedom";
6770
6795
  import { parseAnimatedGifMetadata } from "@hyperframes/core";
@@ -6812,12 +6837,12 @@ function resolveLocalImageSourcePath(src, options) {
6812
6837
  ...protocolRelativeUrlOnShare ? [] : [isAbsolute2(basePath) ? basePath : resolve5(options.projectDir, projectRelative)],
6813
6838
  resolve5(options.downloadDir, normalizedBase)
6814
6839
  ];
6815
- 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);
6816
6841
  return candidates.find((candidate) => existsSync9(candidate) && allowed(candidate)) ?? null;
6817
6842
  }
6818
6843
  function isUsableFile(path) {
6819
6844
  try {
6820
- const stat = statSync6(path);
6845
+ const stat = statSync7(path);
6821
6846
  return stat.isFile() && stat.size > 0;
6822
6847
  } catch {
6823
6848
  return false;
@@ -7081,7 +7106,7 @@ import {
7081
7106
  readFileSync as readFileSync7,
7082
7107
  readSync as readSync3,
7083
7108
  rmSync as rmSync10,
7084
- statSync as statSync7,
7109
+ statSync as statSync8,
7085
7110
  writeFileSync as writeFileSync4
7086
7111
  } from "node:fs";
7087
7112
  import { dirname as dirname7, join as join17, resolve as resolve6 } from "node:path";
@@ -7324,7 +7349,7 @@ function resolveImageSource(src, options) {
7324
7349
  }
7325
7350
  function isUsableFile2(path) {
7326
7351
  try {
7327
- return statSync7(path).size > 0;
7352
+ return statSync8(path).size > 0;
7328
7353
  } catch {
7329
7354
  return false;
7330
7355
  }
@@ -7458,6 +7483,11 @@ function dropMediaOutsideProject(input) {
7458
7483
  if (!src || isRemoteOrInlineSource(src)) return true;
7459
7484
  const path = resolveProjectRelativeSrc3(src, projectDir, compiledDir);
7460
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
+ }
7461
7491
  log.warn(`[Render] Media "${id}" source is missing: it is outside the project folder`, { src });
7462
7492
  return false;
7463
7493
  };
@@ -7584,7 +7614,7 @@ function normalizeCompositionSrcs(html, projectDir) {
7584
7614
  if (!value.includes("%") && !value.startsWith("/")) return whole;
7585
7615
  const file = resolveCompositionSrc(projectDir, value);
7586
7616
  if (file === null) return whole;
7587
- return `${name}${quote}${relative2(projectDir, file).split(sep2).join("/")}${quote}`;
7617
+ return `${name}${quote}${relative2(projectDir, file).split(sep3).join("/")}${quote}`;
7588
7618
  });
7589
7619
  }
7590
7620
  function resolveCompositionFile(projectDir, src, assetRoot) {
@@ -7605,6 +7635,10 @@ function assertSubCompositionsUsable(html, projectDir, assetRoot, visited = /* @
7605
7635
  problems.push({ srcPath, detail: "it is outside the project folder" });
7606
7636
  continue;
7607
7637
  }
7638
+ if (outsideAssetRefusal(projectDir, filePath) === "blocklisted") {
7639
+ problems.push({ srcPath, detail: "it is outside the project in a private location" });
7640
+ continue;
7641
+ }
7608
7642
  if (isPrivateCompositionFile(projectDir, filePath)) {
7609
7643
  problems.push({ srcPath, detail: "it is git metadata or an env file" });
7610
7644
  continue;
@@ -8310,17 +8344,24 @@ ${safeText}
8310
8344
  }
8311
8345
  return wrappedFragment ? document2.body.innerHTML || "" : document2.toString();
8312
8346
  }
8313
- function collectExternalAssets(html, projectDir) {
8347
+ function collectExternalAssets(html, projectDir, log = defaultLogger, file = "index.html") {
8314
8348
  const absProjectDir = resolve7(projectDir);
8315
8349
  const externalAssets = /* @__PURE__ */ new Map();
8350
+ const leftOut = /* @__PURE__ */ new Set();
8316
8351
  function processPath(rawPath) {
8317
8352
  const trimmed = rawPath.trim();
8318
8353
  if (isNonRelativeUrl(trimmed)) return null;
8319
8354
  const absPath = resolve7(absProjectDir, trimmed);
8320
- if (isPathInside2(absPath, absProjectDir)) {
8355
+ if (isPathInside(absPath, absProjectDir)) {
8321
8356
  return null;
8322
8357
  }
8323
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
+ }
8324
8365
  const safeKey = toExternalAssetKey(absPath);
8325
8366
  externalAssets.set(safeKey, absPath);
8326
8367
  return safeKey;
@@ -8566,13 +8607,13 @@ function projectStylesheetFontFamilies(html, projectDir) {
8566
8607
  const href = /\bhref=["']([^"']+)["']/i.exec(tag)?.[1];
8567
8608
  if (!href || /^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(href)) continue;
8568
8609
  const sheet = resolve7(projectDir, decodedUrlPath(href).replace(/^(?:\.?\/)+/, ""));
8569
- if (!isPathInside2(sheet, projectDir) || !existsSync11(sheet)) continue;
8610
+ if (!isPathInside(sheet, projectDir) || !existsSync11(sheet)) continue;
8570
8611
  for (const face of extractFontFaceBlocks(readFileSync8(sheet, "utf8"))) {
8571
8612
  const family = /font-family\s*:\s*([^;}]+)/i.exec(face)?.[1]?.trim().replace(/^['"]|['"]$/g, "");
8572
8613
  const shipsFile = [...face.matchAll(LOCAL_FONTFACE_URL_RE)].some(([, url = ""]) => {
8573
8614
  const path = decodedUrlPath(url);
8574
8615
  const file = path.startsWith("/") ? resolve7(projectDir, `.${path}`) : resolve7(dirname8(sheet), path);
8575
- return isPathInside2(file, projectDir) && existsSync11(file);
8616
+ return isPathInside(file, projectDir) && existsSync11(file);
8576
8617
  });
8577
8618
  if (family && shipsFile) families.push(family);
8578
8619
  }
@@ -8638,7 +8679,7 @@ async function readLocalFont(absPath) {
8638
8679
  }
8639
8680
  return { kind: "inline", buffer: Buffer.concat(chunks, totalBytes) };
8640
8681
  }
8641
- async function embedLocalFontFaces(html, projectDir, assetRoot) {
8682
+ async function embedLocalFontFaces(html, projectDir, assetRoot, log = defaultLogger) {
8642
8683
  const { fontToDataUri: toDataUri } = await import("@hyperframes/core/fonts/embed");
8643
8684
  const styleBlockRe = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
8644
8685
  const fontFaceRe = /@font-face\s*\{([^}]*)\}/gi;
@@ -8659,7 +8700,11 @@ async function embedLocalFontFaces(html, projectDir, assetRoot) {
8659
8700
  const localPath = urlMatch[1];
8660
8701
  if (!localPath || embeddedPaths.has(localPath)) continue;
8661
8702
  const absPath = localPath.startsWith("/") ? localPath : resolve7(projectDir, localPath);
8662
- 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
+ }
8663
8708
  const ext = absPath.match(/\.(woff2?|ttf|otf|ttc)$/i)?.[1]?.toLowerCase() ?? "ttf";
8664
8709
  try {
8665
8710
  if (fileBackedAbsolutePaths.has(absPath)) {
@@ -8723,7 +8768,7 @@ function rewriteUnresolvableGsapToCdn(html, projectDir, compSrcPath) {
8723
8768
  );
8724
8769
  }
8725
8770
  function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath) {
8726
- if (!isPathInside2(htmlPath, projectDir)) return html;
8771
+ if (!isPathInside(htmlPath, projectDir)) return html;
8727
8772
  const entryPath = relative2(projectDir, htmlPath).replace(/\\/g, "/");
8728
8773
  if (!entryPath.includes("/")) return html;
8729
8774
  const { document: document2 } = parseHTML5(html);
@@ -8765,9 +8810,10 @@ function bindVariableMediaSources(html, variables) {
8765
8810
  }
8766
8811
  return changed ? document2.toString() : html;
8767
8812
  }
8813
+ var entryFileName = (projectDir, htmlPath) => isPathInside(htmlPath, projectDir) ? relative2(projectDir, htmlPath).split(sep3).join("/") : basename5(htmlPath);
8768
8814
  async function compileForRender(projectDir, htmlPath, downloadDir, options = {}) {
8769
8815
  const assetRoot = options.allowOutsideProjectAssets ? void 0 : projectDir;
8770
- if (isPathInside2(htmlPath, projectDir) && escapesAssetRoot(htmlPath, assetRoot)) {
8816
+ if (isPathInside(htmlPath, projectDir) && escapesAssetRoot(htmlPath, assetRoot)) {
8771
8817
  throw new Error(`Entry file ${htmlPath} leads outside the project folder`);
8772
8818
  }
8773
8819
  const entryHtml = rebaseDirectEntryAssetPaths(readTextFile(htmlPath), projectDir, htmlPath);
@@ -8879,8 +8925,18 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
8879
8925
  if (preparedGifs.length > 0) {
8880
8926
  defaultLogger.debug(`[Compiler] Prepared ${preparedGifs.length} animated GIF input(s) as WebM`);
8881
8927
  }
8882
- const embeddedHtml = await embedLocalFontFaces(htmlWithPreparedGifs, projectDir, assetRoot);
8883
- 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() };
8884
8940
  for (const [relPath, absPath] of remoteMediaAssets) {
8885
8941
  externalAssets.set(relPath, absPath);
8886
8942
  }
@@ -9451,9 +9507,13 @@ async function runCompileStage(input) {
9451
9507
  width: compiled.width,
9452
9508
  height: compiled.height
9453
9509
  };
9454
- if (!job.config.allowOutsideProjectAssets) {
9455
- dropMediaOutsideProject({ projectDir, workDir, composition, log });
9456
- }
9510
+ dropMediaOutsideProject({
9511
+ projectDir,
9512
+ workDir,
9513
+ composition,
9514
+ log,
9515
+ allowOutsideProjectAssets: job.config.allowOutsideProjectAssets
9516
+ });
9457
9517
  await preflightCompositionAssetMediaTypes({
9458
9518
  projectDir,
9459
9519
  compiledDir: join20(workDir, "compiled"),
@@ -10078,9 +10138,13 @@ async function runProbeStage(input) {
10078
10138
  }
10079
10139
  }
10080
10140
  }
10081
- if (!job.config.allowOutsideProjectAssets) {
10082
- dropMediaOutsideProject({ projectDir, workDir, composition, log });
10083
- }
10141
+ dropMediaOutsideProject({
10142
+ projectDir,
10143
+ workDir,
10144
+ composition,
10145
+ log,
10146
+ allowOutsideProjectAssets: job.config.allowOutsideProjectAssets
10147
+ });
10084
10148
  await preflightCompositionAssetMediaTypes({
10085
10149
  projectDir,
10086
10150
  compiledDir: join21(workDir, "compiled"),
@@ -12854,7 +12918,7 @@ import {
12854
12918
  readdirSync as readdirSync5,
12855
12919
  readFileSync as readFileSync9,
12856
12920
  rmSync as rmSync11,
12857
- statSync as statSync8,
12921
+ statSync as statSync9,
12858
12922
  writeFileSync as writeFileSync6
12859
12923
  } from "node:fs";
12860
12924
  import { readFile as readFile2 } from "node:fs/promises";
@@ -12983,7 +13047,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
12983
13047
  const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
12984
13048
  if (failure) return failure;
12985
13049
  }
12986
- const fileSize = existsSync20(outputPath) ? statSync8(outputPath).size : 0;
13050
+ const fileSize = existsSync20(outputPath) ? statSync9(outputPath).size : 0;
12987
13051
  return {
12988
13052
  success: true,
12989
13053
  outputPath,
@@ -13389,7 +13453,7 @@ function sampleDirectoryBytes(dir) {
13389
13453
  for (const name of entries) {
13390
13454
  const full = join32(current, name);
13391
13455
  try {
13392
- const st = statSync9(full);
13456
+ const st = statSync10(full);
13393
13457
  if (st.isDirectory()) {
13394
13458
  stack.push(full);
13395
13459
  } else if (st.isFile()) {
@@ -13544,7 +13608,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
13544
13608
  let rangeStart = null;
13545
13609
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
13546
13610
  const framePath = join32(framesDir, formatCaptureFrameName(frameIndex, frameExt));
13547
- const missing = !existsSync21(framePath) || statSync9(framePath).size <= 8;
13611
+ const missing = !existsSync21(framePath) || statSync10(framePath).size <= 8;
13548
13612
  if (missing && rangeStart === null) {
13549
13613
  rangeStart = frameIndex;
13550
13614
  } else if (!missing && rangeStart !== null) {
@@ -16477,13 +16541,13 @@ async function executeRenderPipeline(input) {
16477
16541
  import {
16478
16542
  existsSync as existsSync22,
16479
16543
  readFileSync as readFileSync10,
16480
- statSync as statSync10,
16544
+ statSync as statSync11,
16481
16545
  openSync as openSync5,
16482
16546
  fstatSync as fstatSync3,
16483
16547
  closeSync as closeSync5,
16484
16548
  constants as constants3
16485
16549
  } from "node:fs";
16486
- 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";
16487
16551
  import { lintHyperframeHtml } from "@hyperframes/lint";
16488
16552
  function isStringRecord(value) {
16489
16553
  if (!value || typeof value !== "object" || Array.isArray(value)) {
@@ -16517,7 +16581,7 @@ function readEntryHtml(filePath) {
16517
16581
  } catch (error) {
16518
16582
  if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
16519
16583
  return null;
16520
- if (!statSync10(filePath, { throwIfNoEntry: false })?.isFile()) return null;
16584
+ if (!statSync11(filePath, { throwIfNoEntry: false })?.isFile()) return null;
16521
16585
  throw error;
16522
16586
  }
16523
16587
  try {
@@ -16529,7 +16593,7 @@ function readEntryHtml(filePath) {
16529
16593
  }
16530
16594
  function readProjectEntryFile(projectDir, preferredEntryFile) {
16531
16595
  const absProjectDir = resolve9(projectDir);
16532
- if (!existsSync22(absProjectDir) || !statSync10(absProjectDir).isDirectory()) {
16596
+ if (!existsSync22(absProjectDir) || !statSync11(absProjectDir).isDirectory()) {
16533
16597
  return { error: `Project directory not found: ${absProjectDir}` };
16534
16598
  }
16535
16599
  const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
@@ -16538,7 +16602,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile) {
16538
16602
  for (const entryFile of entryCandidates) {
16539
16603
  const absoluteEntryPath = resolve9(absProjectDir, entryFile);
16540
16604
  const entryRelativePath = relative4(absProjectDir, absoluteEntryPath);
16541
- if (entryRelativePath === ".." || entryRelativePath.startsWith(`..${sep3}`) || isAbsolute3(entryRelativePath)) {
16605
+ if (entryRelativePath === ".." || entryRelativePath.startsWith(`..${sep4}`) || isAbsolute3(entryRelativePath)) {
16542
16606
  return { error: `Entry file must stay inside project directory: ${entryFile}` };
16543
16607
  }
16544
16608
  const html = readEntryHtml(absoluteEntryPath);
@@ -16715,7 +16779,7 @@ import {
16715
16779
  createReferenceBackgroundRecorder as createReferenceBackgroundRecorder2
16716
16780
  } from "@hyperframes/engine";
16717
16781
  import { audioFailureDiagnostics as audioFailureDiagnostics3 } from "@hyperframes/engine";
16718
- 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";
16719
16783
  import {
16720
16784
  fpsToNumber as fpsToNumber9,
16721
16785
  HF_COLOR_GRADING_ATTR as HF_COLOR_GRADING_ATTR2
@@ -17336,7 +17400,7 @@ function prepareProjectDirectory(projectDir, options) {
17336
17400
  const candidate = nonEmptyString(projectDir);
17337
17401
  if (!candidate) return null;
17338
17402
  const absProjectDir = resolve10(candidate);
17339
- if (!existsSync25(absProjectDir) || !statSync11(absProjectDir).isDirectory()) {
17403
+ if (!existsSync25(absProjectDir) || !statSync12(absProjectDir).isDirectory()) {
17340
17404
  return { error: `Project directory not found: ${absProjectDir}` };
17341
17405
  }
17342
17406
  const entry = options.entryFile || "index.html";
@@ -17432,7 +17496,7 @@ function cleanupTempDir(dir, log) {
17432
17496
  }
17433
17497
  }
17434
17498
  function outputFileSize(path) {
17435
- return existsSync25(path) ? statSync11(path).size : 0;
17499
+ return existsSync25(path) ? statSync12(path).size : 0;
17436
17500
  }
17437
17501
  function createBlockingProgressReporter(log, requestId) {
17438
17502
  let lastLoggedPct = -10;
@@ -17749,7 +17813,7 @@ function createRenderHandlers(options = {}) {
17749
17813
  store.delete(token);
17750
17814
  return c.json({ success: false, error: "Output artifact file missing" }, 404);
17751
17815
  }
17752
- const stats = statSync11(artifact.path);
17816
+ const stats = statSync12(artifact.path);
17753
17817
  return new Response(createReadStream3(artifact.path), {
17754
17818
  headers: {
17755
17819
  "content-type": "video/mp4",
@@ -33,6 +33,7 @@ export declare function dropMediaOutsideProject(input: {
33
33
  images: ImageElement[];
34
34
  };
35
35
  log: ProducerLogger;
36
+ allowOutsideProjectAssets?: boolean;
36
37
  }): void;
37
38
  /**
38
39
  * Fail early when a successfully-probed local asset cannot satisfy the HTML
@@ -64,7 +64,7 @@ export declare function inlineExternalScripts(html: string): Promise<string>;
64
64
  *
65
65
  * Handles: src/href attributes, CSS url(), inline style url().
66
66
  */
67
- export declare function collectExternalAssets(html: string, projectDir: string): {
67
+ export declare function collectExternalAssets(html: string, projectDir: string, log?: ProducerLogger, file?: string): {
68
68
  html: string;
69
69
  externalAssets: Map<string, string>;
70
70
  };