@hyperframes/producer 0.9.36 → 0.9.38

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.
@@ -14,11 +14,12 @@ import {
14
14
  rmSync as rmSync7,
15
15
  writeFileSync as writeFileSync8
16
16
  } from "node:fs";
17
- import { extname as extname4, isAbsolute as isAbsolute3, join as join26, relative as relative5, sep as sep3 } from "node:path";
17
+ import { extname as extname4, isAbsolute as isAbsolute3, join as join27, relative as relative6, sep as sep3 } from "node:path";
18
18
  import {
19
19
  fpsToNumber as fpsToNumber9,
20
20
  HF_COLOR_GRADING_ATTR as HF_COLOR_GRADING_ATTR2
21
21
  } from "@hyperframes/core";
22
+ import { isSafePath as isSafePath2 } from "@hyperframes/core/safe-path";
22
23
  import {
23
24
  getEncoderPreset as getEncoderPreset4,
24
25
  keyframeIntervalToGopSize as keyframeIntervalToGopSize3,
@@ -130,7 +131,7 @@ import {
130
131
  referenceBackgroundResult,
131
132
  createReferenceBackgroundRecorder
132
133
  } from "@hyperframes/engine";
133
- import { join as join17, dirname as dirname10, resolve as resolve7 } from "path";
134
+ import { join as join18, dirname as dirname10, resolve as resolve7 } from "path";
134
135
  import { randomUUID } from "crypto";
135
136
 
136
137
  // src/services/fileServer.ts
@@ -772,7 +773,13 @@ function openRegularFile(filePath) {
772
773
  }
773
774
  }
774
775
  function createFileServer(options) {
775
- const { projectDir, compiledDir, port = 0, stripEmbeddedRuntime = true } = options;
776
+ const {
777
+ projectDir,
778
+ compiledDir,
779
+ port = 0,
780
+ stripEmbeddedRuntime = true,
781
+ allowOutsideProjectAssets = false
782
+ } = options;
776
783
  const preHeadScripts = [
777
784
  HF_EARLY_STUB,
778
785
  RENDER_CAPTURE_MODE_SHIM,
@@ -794,7 +801,8 @@ function createFileServer(options) {
794
801
  let file = null;
795
802
  for (const root of compiledDir ? [compiledDir, projectDir] : [projectDir]) {
796
803
  const candidate = join(root, relativePath);
797
- if (isPathInside(candidate, root)) file = openRegularFile(candidate);
804
+ const resolveSymlinks = !allowOutsideProjectAssets && root !== compiledDir;
805
+ if (isPathInside(candidate, root, { resolveSymlinks })) file = openRegularFile(candidate);
798
806
  if (file) break;
799
807
  }
800
808
  if (!file) {
@@ -979,6 +987,7 @@ import {
979
987
  isAbsolute as nodeIsAbsolute
980
988
  } from "node:path";
981
989
  import { fileURLToPath as fileURLToPath2 } from "node:url";
990
+ import { isSafePath } from "@hyperframes/core/safe-path";
982
991
  var DEFAULT_RENDERS_DIR = process.env.PRODUCER_RENDERS_DIR ?? // fileURLToPath (not URL.pathname): on Windows .pathname is "/D:/..." which
983
992
  // resolves to a bogus renders dir.
984
993
  nodeResolve(fileURLToPath2(import.meta.url), "../../..", "renders");
@@ -993,6 +1002,9 @@ function isPathInside2(childPath, parentPath, options = {}) {
993
1002
  const rel = relativePath(absParent, absChild);
994
1003
  return rel !== "" && !LEADING_PARENT_SEGMENT_RE.test(rel) && !isPathAbsolute(rel);
995
1004
  }
1005
+ function escapesAssetRoot(path, assetRoot) {
1006
+ return assetRoot !== void 0 && !isSafePath(assetRoot, path);
1007
+ }
996
1008
  function toExternalAssetKey(absPath) {
997
1009
  if (absPath.startsWith("hf-ext/")) return absPath;
998
1010
  let normalised = absPath.replace(/\\/g, "/");
@@ -2167,7 +2179,7 @@ import {
2167
2179
 
2168
2180
  // src/services/render/stages/compileStage.ts
2169
2181
  import { existsSync as existsSync8, writeFileSync as writeFileSync3 } from "node:fs";
2170
- import { join as join9 } from "node:path";
2182
+ import { join as join10, relative as relative3 } from "node:path";
2171
2183
  import { suggestMatchingPreset } from "@hyperframes/core";
2172
2184
  import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
2173
2185
  import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolution";
@@ -2176,7 +2188,7 @@ import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolu
2176
2188
  import { decodedUrlPath } from "@hyperframes/parsers/asset-paths";
2177
2189
  import { createHash as createHash5 } from "node:crypto";
2178
2190
  import { createReadStream as createReadStream2, existsSync as existsSync7, mkdirSync as mkdirSync4, readFileSync as readFileSync5 } from "fs";
2179
- import { join as join8, dirname as dirname6, resolve as resolve6, basename as basename3, relative as relative2, sep as sep2 } from "path";
2191
+ import { join as join9, dirname as dirname6, resolve as resolve6, basename as basename3, relative as relative2, sep as sep2 } from "path";
2180
2192
  import { parseHTML as parseHTML5 } from "linkedom";
2181
2193
 
2182
2194
  // src/services/bundledScripts.ts
@@ -2488,7 +2500,8 @@ function resolveLocalImageSourcePath(src, options) {
2488
2500
  ...protocolRelativeUrlOnShare ? [] : [isAbsolute2(basePath) ? basePath : resolve4(options.projectDir, projectRelative)],
2489
2501
  resolve4(options.downloadDir, normalizedBase)
2490
2502
  ];
2491
- return candidates.find((candidate) => existsSync5(candidate)) ?? null;
2503
+ const allowed = (candidate) => !escapesAssetRoot(candidate, options.assetRoot) || !escapesAssetRoot(candidate, options.downloadDir);
2504
+ return candidates.find((candidate) => existsSync5(candidate) && allowed(candidate)) ?? null;
2492
2505
  }
2493
2506
  function isUsableFile(path) {
2494
2507
  try {
@@ -3078,6 +3091,7 @@ import { getPositionEditsRenderScript } from "@hyperframes/core/runtime/position
3078
3091
 
3079
3092
  // src/services/assetMediaType.ts
3080
3093
  import { existsSync as existsSync6 } from "node:fs";
3094
+ import { join as join8 } from "node:path";
3081
3095
  import {
3082
3096
  fingerprintElementId,
3083
3097
  isNotMediaPayload,
@@ -3124,6 +3138,21 @@ function assertAssetMediaTypeProfile(expected, profile, elementIdentity) {
3124
3138
  function isRemoteOrInlineSource(src) {
3125
3139
  return /^(?:https?:|data:|blob:|about:)/i.test(src.trim());
3126
3140
  }
3141
+ function dropMediaOutsideProject(input) {
3142
+ const { projectDir, workDir, composition, log } = input;
3143
+ const compiledDir = join8(workDir, "compiled");
3144
+ const roots = [projectDir, compiledDir, join8(workDir, "downloads")];
3145
+ const staysInside = ({ id, src }) => {
3146
+ if (!src || isRemoteOrInlineSource(src)) return true;
3147
+ const path = resolveProjectRelativeSrc2(src, projectDir, compiledDir);
3148
+ if (roots.some((root) => !escapesAssetRoot(path, root))) return true;
3149
+ log.warn(`[Render] Media "${id}" source is missing: it is outside the project folder`, { src });
3150
+ return false;
3151
+ };
3152
+ composition.videos = composition.videos.filter(staysInside);
3153
+ composition.audios = composition.audios.filter(staysInside);
3154
+ composition.images = composition.images.filter(staysInside);
3155
+ }
3127
3156
  async function preflightCompositionAssetMediaTypes(input) {
3128
3157
  const references = [
3129
3158
  ...input.composition.videos.map((asset) => ({
@@ -3246,8 +3275,12 @@ function normalizeCompositionSrcs(html, projectDir) {
3246
3275
  return `${name}${quote}${relative2(projectDir, file).split(sep2).join("/")}${quote}`;
3247
3276
  });
3248
3277
  }
3278
+ function resolveCompositionFile(projectDir, src, assetRoot) {
3279
+ const file = resolveCompositionSrc(projectDir, src);
3280
+ return file === null || escapesAssetRoot(file, assetRoot) ? null : file;
3281
+ }
3249
3282
  var isPrivateCompositionFile = (projectDir, filePath) => isPrivateFileUnder(projectDir, filePath, isVcsOrSecretPath);
3250
- function assertSubCompositionsUsable(html, projectDir, visited = /* @__PURE__ */ new Set()) {
3283
+ function assertSubCompositionsUsable(html, projectDir, assetRoot, visited = /* @__PURE__ */ new Set()) {
3251
3284
  const { document: document2 } = parseHTML5(html);
3252
3285
  const hosts = [...document2.querySelectorAll("[data-composition-src]")];
3253
3286
  const problems = [];
@@ -3255,7 +3288,7 @@ function assertSubCompositionsUsable(html, projectDir, visited = /* @__PURE__ */
3255
3288
  const srcPath = el.getAttribute("data-composition-src");
3256
3289
  if (!srcPath) continue;
3257
3290
  if (isUnresolvedAssetPlaceholder(srcPath)) continue;
3258
- const filePath = resolveCompositionSrc(projectDir, srcPath);
3291
+ const filePath = resolveCompositionFile(projectDir, srcPath, assetRoot);
3259
3292
  if (filePath === null) {
3260
3293
  problems.push({ srcPath, detail: "it is outside the project folder" });
3261
3294
  continue;
@@ -3286,7 +3319,7 @@ function assertSubCompositionsUsable(html, projectDir, visited = /* @__PURE__ */
3286
3319
  const nestedVisited = new Set(visited);
3287
3320
  nestedVisited.add(filePath);
3288
3321
  try {
3289
- assertSubCompositionsUsable(fileHtml, projectDir, nestedVisited);
3322
+ assertSubCompositionsUsable(fileHtml, projectDir, assetRoot, nestedVisited);
3290
3323
  } catch (err) {
3291
3324
  if (err instanceof EmptyCompositionError) {
3292
3325
  problems.push(...err.problems);
@@ -3405,10 +3438,10 @@ function detectShaderTransitionUsage(html) {
3405
3438
  }
3406
3439
  return false;
3407
3440
  }
3408
- async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, downloadDir, tagName, elementIdentity, log, urlByAbsentLocalPath, probes) {
3441
+ async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, downloadDir, tagName, elementIdentity, log, urlByAbsentLocalPath, probes, assetRoot) {
3409
3442
  let filePath = src;
3410
3443
  if (isHttpUrl(src)) {
3411
- const remoteDir = join8(downloadDir, REMOTE_MEDIA_SUBDIR);
3444
+ const remoteDir = join9(downloadDir, REMOTE_MEDIA_SUBDIR);
3412
3445
  if (!existsSync7(remoteDir)) mkdirSync4(remoteDir, { recursive: true });
3413
3446
  try {
3414
3447
  filePath = await downloadToTemp(src, remoteDir, void 0, void 0, void 0, {
@@ -3419,7 +3452,8 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, down
3419
3452
  }
3420
3453
  } else {
3421
3454
  filePath = decodedUrlPath(src);
3422
- if (!filePath.startsWith("/")) filePath = join8(baseDir, filePath);
3455
+ if (!filePath.startsWith("/")) filePath = join9(baseDir, filePath);
3456
+ if (escapesAssetRoot(filePath, assetRoot)) return { duration: null, resolvedPath: filePath };
3423
3457
  filePath = urlByAbsentLocalPath?.get(filePath) ?? filePath;
3424
3458
  if (!isHttpUrl(filePath) && namesAnotherNetworkRoot2(baseDir, filePath)) {
3425
3459
  return { duration: null, resolvedPath: filePath };
@@ -3495,7 +3529,7 @@ function markInferredVariableMediaDurations(html, unresolvedMedia) {
3495
3529
  }
3496
3530
  return changed ? document2.toString() : html;
3497
3531
  }
3498
- async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocalPath, probes) {
3532
+ async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocalPath, probes, assetRoot) {
3499
3533
  const { html: staticCompiled, unresolved } = compileTimingAttrs(html);
3500
3534
  const mediaUnresolved = unresolved.filter(
3501
3535
  (el) => (el.tagName === "video" || el.tagName === "audio") && el.src
@@ -3513,7 +3547,8 @@ async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocal
3513
3547
  el.id,
3514
3548
  log,
3515
3549
  urlByAbsentLocalPath,
3516
- probes
3550
+ probes,
3551
+ assetRoot
3517
3552
  ).then(({ duration }) => ({ id: el.id, duration }))
3518
3553
  )
3519
3554
  );
@@ -3536,7 +3571,8 @@ async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocal
3536
3571
  el.id,
3537
3572
  log,
3538
3573
  void 0,
3539
- probes
3574
+ probes,
3575
+ assetRoot
3540
3576
  );
3541
3577
  return { id: el.id, tagName: el.tagName, duration: el.duration, maxDuration, src: el.src };
3542
3578
  })
@@ -3558,7 +3594,7 @@ async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocal
3558
3594
  compiledHtml = compiledHtml.replace(/(<audio\b[^>]*)\s+crossorigin(?:=["'][^"']*["'])?/gi, "$1");
3559
3595
  return { html: compiledHtml, unresolvedCompositions };
3560
3596
  }
3561
- async function parseSubCompositions(html, projectDir, downloadDir, visited = /* @__PURE__ */ new Set(), urlByAbsentLocalPath, probes) {
3597
+ async function parseSubCompositions(html, projectDir, downloadDir, visited = /* @__PURE__ */ new Set(), urlByAbsentLocalPath, probes, assetRoot) {
3562
3598
  const subCompositions = /* @__PURE__ */ new Map();
3563
3599
  const { document: document2 } = parseHTML5(html);
3564
3600
  const compEls = document2.querySelectorAll("[data-composition-src]");
@@ -3566,7 +3602,7 @@ async function parseSubCompositions(html, projectDir, downloadDir, visited = /*
3566
3602
  for (const el of compEls) {
3567
3603
  const srcPath = el.getAttribute("data-composition-src");
3568
3604
  if (!srcPath) continue;
3569
- const filePath = resolveCompositionSrc(projectDir, srcPath);
3605
+ const filePath = resolveCompositionFile(projectDir, srcPath, assetRoot);
3570
3606
  if (filePath === null || isPrivateCompositionFile(projectDir, filePath)) continue;
3571
3607
  if (visited.has(filePath)) {
3572
3608
  continue;
@@ -3588,7 +3624,8 @@ async function parseSubCompositions(html, projectDir, downloadDir, visited = /*
3588
3624
  downloadDir,
3589
3625
  void 0,
3590
3626
  urlByAbsentLocalPath,
3591
- probes
3627
+ probes,
3628
+ assetRoot
3592
3629
  );
3593
3630
  const nested = await parseSubCompositions(
3594
3631
  compiledSub,
@@ -3596,7 +3633,8 @@ async function parseSubCompositions(html, projectDir, downloadDir, visited = /*
3596
3633
  downloadDir,
3597
3634
  item.nestedVisited,
3598
3635
  urlByAbsentLocalPath,
3599
- probes
3636
+ probes,
3637
+ assetRoot
3600
3638
  );
3601
3639
  return {
3602
3640
  srcPath: item.srcPath,
@@ -3733,7 +3771,7 @@ function coalesceHeadStylesAndBodyScripts(html) {
3733
3771
  }
3734
3772
  return document2.toString();
3735
3773
  }
3736
- function inlineSubCompositions(html, subCompositions, projectDir, variableOverrides = {}) {
3774
+ function inlineSubCompositions(html, subCompositions, projectDir, variableOverrides, assetRoot) {
3737
3775
  const { document: document2 } = parseHTML5(html);
3738
3776
  const head = document2.querySelector("head");
3739
3777
  const body = document2.querySelector("body");
@@ -3763,7 +3801,7 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
3763
3801
  resolveHtml: (srcPath) => {
3764
3802
  let compHtml = subCompositions.get(srcPath) || null;
3765
3803
  if (!compHtml) {
3766
- const filePath = resolveCompositionSrc(projectDir, srcPath);
3804
+ const filePath = resolveCompositionFile(projectDir, srcPath, assetRoot);
3767
3805
  const read = filePath && !isPrivateCompositionFile(projectDir, filePath) ? readProjectFile(filePath) : null;
3768
3806
  if (read?.kind === "file") {
3769
3807
  compHtml = rewriteUnresolvableGsapToCdn(read.text, projectDir, srcPath);
@@ -4067,7 +4105,7 @@ async function localizeRemoteMediaSources(html, downloadDir) {
4067
4105
  return downloadAndRewriteUrls(
4068
4106
  urlSet,
4069
4107
  html,
4070
- join8(downloadDir, REMOTE_MEDIA_SUBDIR),
4108
+ join9(downloadDir, REMOTE_MEDIA_SUBDIR),
4071
4109
  "Remote media download failed",
4072
4110
  "Localized remote media source(s)"
4073
4111
  );
@@ -4082,7 +4120,7 @@ async function localizeRemoteImageSources(html, downloadDir) {
4082
4120
  return downloadAndRewriteUrls(
4083
4121
  urlSet,
4084
4122
  html,
4085
- join8(downloadDir, REMOTE_MEDIA_SUBDIR),
4123
+ join9(downloadDir, REMOTE_MEDIA_SUBDIR),
4086
4124
  "Remote image download failed",
4087
4125
  "Localized remote image source(s)"
4088
4126
  );
@@ -4098,7 +4136,7 @@ async function localizeRemoteBackgroundImages(html, downloadDir) {
4098
4136
  return downloadAndRewriteUrls(
4099
4137
  urlSet,
4100
4138
  html,
4101
- join8(downloadDir, REMOTE_MEDIA_SUBDIR),
4139
+ join9(downloadDir, REMOTE_MEDIA_SUBDIR),
4102
4140
  "Remote background-image download failed",
4103
4141
  "Localized remote background-image(s)",
4104
4142
  // Quoted url('..')/url("..") are rewritten by downloadAndRewriteUrls' default
@@ -4250,7 +4288,7 @@ function localizeFontFaceUrls(html, downloadDir) {
4250
4288
  return downloadAndRewriteUrls(
4251
4289
  collectFontFaceUrls(html),
4252
4290
  html,
4253
- join8(downloadDir, REMOTE_MEDIA_SUBDIR),
4291
+ join9(downloadDir, REMOTE_MEDIA_SUBDIR),
4254
4292
  "Remote font download failed",
4255
4293
  "Localized remote font face(s)",
4256
4294
  (h, url, relPath) => h.replaceAll(`url(${url})`, `url("${relPath}")`)
@@ -4275,7 +4313,7 @@ async function readLocalFont(absPath) {
4275
4313
  }
4276
4314
  return { kind: "inline", buffer: Buffer.concat(chunks, totalBytes) };
4277
4315
  }
4278
- async function embedLocalFontFaces(html, projectDir) {
4316
+ async function embedLocalFontFaces(html, projectDir, assetRoot) {
4279
4317
  const { fontToDataUri: toDataUri } = await import("@hyperframes/core/fonts/embed");
4280
4318
  const styleBlockRe = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
4281
4319
  const fontFaceRe = /@font-face\s*\{([^}]*)\}/gi;
@@ -4296,7 +4334,7 @@ async function embedLocalFontFaces(html, projectDir) {
4296
4334
  const localPath = urlMatch[1];
4297
4335
  if (!localPath || embeddedPaths.has(localPath)) continue;
4298
4336
  const absPath = localPath.startsWith("/") ? localPath : resolve6(projectDir, localPath);
4299
- if (!isPathInside2(absPath, projectDir)) continue;
4337
+ if (!isPathInside2(absPath, projectDir) || escapesAssetRoot(absPath, assetRoot)) continue;
4300
4338
  const ext = absPath.match(/\.(woff2?|ttf|otf|ttc)$/i)?.[1]?.toLowerCase() ?? "ttf";
4301
4339
  try {
4302
4340
  if (fileBackedAbsolutePaths.has(absPath)) {
@@ -4403,12 +4441,16 @@ function bindVariableMediaSources(html, variables) {
4403
4441
  return changed ? document2.toString() : html;
4404
4442
  }
4405
4443
  async function compileForRender(projectDir, htmlPath, downloadDir, options = {}) {
4444
+ const assetRoot = options.allowOutsideProjectAssets ? void 0 : projectDir;
4445
+ if (isPathInside2(htmlPath, projectDir) && escapesAssetRoot(htmlPath, assetRoot)) {
4446
+ throw new Error(`Entry file ${htmlPath} leads outside the project folder`);
4447
+ }
4406
4448
  const entryHtml = rebaseDirectEntryAssetPaths(readTextFile(htmlPath), projectDir, htmlPath);
4407
4449
  const rawHtml = bindVariableMediaSources(
4408
4450
  normalizeCompositionSrcs(rewriteUnresolvableGsapToCdn(entryHtml, projectDir), projectDir),
4409
4451
  options.variables ?? {}
4410
4452
  );
4411
- assertSubCompositionsUsable(rawHtml, projectDir);
4453
+ assertSubCompositionsUsable(rawHtml, projectDir, assetRoot);
4412
4454
  const probes = /* @__PURE__ */ new Map();
4413
4455
  const { html: compiledHtml, unresolvedCompositions } = await compileHtmlFile(
4414
4456
  rawHtml,
@@ -4416,7 +4458,8 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
4416
4458
  downloadDir,
4417
4459
  options.log,
4418
4460
  options.urlByAbsentLocalPath,
4419
- probes
4461
+ probes,
4462
+ assetRoot
4420
4463
  );
4421
4464
  const { subCompositions } = await parseSubCompositions(
4422
4465
  compiledHtml,
@@ -4424,14 +4467,16 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
4424
4467
  downloadDir,
4425
4468
  void 0,
4426
4469
  options.urlByAbsentLocalPath,
4427
- probes
4470
+ probes,
4471
+ assetRoot
4428
4472
  );
4429
4473
  const fullHtml = ensureFullDocument(compiledHtml);
4430
4474
  const inlinedHtml = inlineSubCompositions(
4431
4475
  fullHtml,
4432
4476
  subCompositions,
4433
4477
  projectDir,
4434
- options.variables ?? {}
4478
+ options.variables ?? {},
4479
+ assetRoot
4435
4480
  );
4436
4481
  const sanitizedHtml = inlinedHtml.replace(
4437
4482
  /(<(?:video|audio)\b[^>]*?)\s+preload\s*=\s*["']none["']/gi,
@@ -4487,7 +4532,8 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
4487
4532
  downloadDir,
4488
4533
  cacheDir: options.animatedGifCacheDir,
4489
4534
  sourceAssets: remoteImageAssets,
4490
- timeoutMs: options.ffmpegProcessTimeout
4535
+ timeoutMs: options.ffmpegProcessTimeout,
4536
+ assetRoot
4491
4537
  });
4492
4538
  if (preparedHeifImages.length > 0) {
4493
4539
  defaultLogger.debug(`[Compiler] Converted ${preparedHeifImages.length} HEIC image(s) to JPEG`);
@@ -4502,13 +4548,14 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
4502
4548
  downloadDir,
4503
4549
  cacheDir: options.animatedGifCacheDir,
4504
4550
  sourceAssets: gifSourceAssets,
4505
- timeoutMs: options.ffmpegProcessTimeout
4551
+ timeoutMs: options.ffmpegProcessTimeout,
4552
+ assetRoot
4506
4553
  });
4507
4554
  if (preparedGifs.length > 0) {
4508
4555
  defaultLogger.debug(`[Compiler] Prepared ${preparedGifs.length} animated GIF input(s) as WebM`);
4509
4556
  }
4510
- const embeddedHtml = await embedLocalFontFaces(htmlWithPreparedGifs, projectDir);
4511
- const { html, externalAssets } = collectExternalAssets(embeddedHtml, projectDir);
4557
+ const embeddedHtml = await embedLocalFontFaces(htmlWithPreparedGifs, projectDir, assetRoot);
4558
+ const { html, externalAssets } = options.allowOutsideProjectAssets ? collectExternalAssets(embeddedHtml, projectDir) : { html: embeddedHtml, externalAssets: /* @__PURE__ */ new Map() };
4512
4559
  for (const [relPath, absPath] of remoteMediaAssets) {
4513
4560
  externalAssets.set(relPath, absPath);
4514
4561
  }
@@ -4533,7 +4580,8 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
4533
4580
  for (const video of videos) {
4534
4581
  if (isHttpUrl(video.src)) continue;
4535
4582
  const videoPath = resolve6(projectDir, video.src);
4536
- if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath)) continue;
4583
+ if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath) || !existsSync7(videoPath) || escapesAssetRoot(videoPath, assetRoot))
4584
+ continue;
4537
4585
  advised.add(videoPath);
4538
4586
  const reencode = `ffmpeg -i "${video.src}" -c:v libx264 -r 30 -g 30 -keyint_min 30 -movflags +faststart -c:a copy output.mp4`;
4539
4587
  (async () => {
@@ -4912,10 +4960,18 @@ async function resolveCompositionDurations(page, unresolved) {
4912
4960
  }
4913
4961
  return resolutions;
4914
4962
  }
4915
- async function recompileWithResolutions(compiled, resolutions, projectDir, downloadDir) {
4963
+ async function recompileWithResolutions(compiled, resolutions, projectDir, downloadDir, assetRoot) {
4916
4964
  if (resolutions.length === 0) return compiled;
4917
4965
  const html = injectDurations(compiled.html, resolutions);
4918
- const { subCompositions } = await parseSubCompositions(html, projectDir, downloadDir);
4966
+ const { subCompositions } = await parseSubCompositions(
4967
+ html,
4968
+ projectDir,
4969
+ downloadDir,
4970
+ void 0,
4971
+ void 0,
4972
+ void 0,
4973
+ assetRoot
4974
+ );
4919
4975
  const { videos, audios, images } = compiled;
4920
4976
  const remaining = compiled.unresolvedCompositions.filter(
4921
4977
  (c) => !resolutions.some((r) => r.id === c.id)
@@ -4948,17 +5004,25 @@ function adaptAspectAgnosticResolution(requested, aspectAgnostic, width, height,
4948
5004
  }
4949
5005
  function resolveEntryHtmlPath(input) {
4950
5006
  const { projectDir, workDir, entryFile, log } = input;
4951
- const htmlPath = join9(projectDir, entryFile);
4952
- const rawEntry = readTextFile2(htmlPath);
5007
+ const readEntry = (path) => {
5008
+ if (escapesAssetRoot(path, input.assetRoot)) {
5009
+ throw new Error(
5010
+ `Entry file "${relative3(projectDir, path)}" leads outside the project folder`
5011
+ );
5012
+ }
5013
+ return readTextFile2(path);
5014
+ };
5015
+ const htmlPath = join10(projectDir, entryFile);
5016
+ const rawEntry = readEntry(htmlPath);
4953
5017
  if (entryFile === "index.html" || !isTemplateEntry(rawEntry)) return htmlPath;
4954
- const projectIndexPath = join9(projectDir, "index.html");
5018
+ const projectIndexPath = join10(projectDir, "index.html");
4955
5019
  if (!existsSync8(projectIndexPath)) {
4956
5020
  throw new Error(
4957
5021
  `Template entry file "${entryFile}" requires a project index.html to extract its render shell.`
4958
5022
  );
4959
5023
  }
4960
5024
  const standaloneHtml = extractStandaloneEntryFromIndex(
4961
- readTextFile2(projectIndexPath),
5025
+ readEntry(projectIndexPath),
4962
5026
  entryFile,
4963
5027
  rawEntry
4964
5028
  );
@@ -4967,7 +5031,7 @@ function resolveEntryHtmlPath(input) {
4967
5031
  `Entry file "${entryFile}" is not mounted from index.html via data-composition-src, so it cannot be rendered independently.`
4968
5032
  );
4969
5033
  }
4970
- const wrapperPath = join9(workDir, "standalone-entry.html");
5034
+ const wrapperPath = join10(workDir, "standalone-entry.html");
4971
5035
  writeFileSync3(wrapperPath, standaloneHtml, "utf-8");
4972
5036
  log.info("Extracted standalone entry from index.html host context", { entryFile });
4973
5037
  return wrapperPath;
@@ -4994,9 +5058,10 @@ async function runCompileStage(input) {
4994
5058
  allowSystemFontCapture,
4995
5059
  abortSignal
4996
5060
  } = input;
4997
- const htmlPath = resolveEntryHtmlPath({ projectDir, workDir, entryFile, log });
5061
+ const assetRoot = job.config.allowOutsideProjectAssets ? void 0 : projectDir;
5062
+ const htmlPath = resolveEntryHtmlPath({ projectDir, workDir, entryFile, log, assetRoot });
4998
5063
  const compileStart = Date.now();
4999
- const compiled = await compileForRender(projectDir, htmlPath, join9(workDir, "downloads"), {
5064
+ const compiled = await compileForRender(projectDir, htmlPath, join10(workDir, "downloads"), {
5000
5065
  log,
5001
5066
  failClosedFontFetch: failClosedFontFetch === true,
5002
5067
  allowSystemFontCapture,
@@ -5004,8 +5069,9 @@ async function runCompileStage(input) {
5004
5069
  variables: input.variables,
5005
5070
  urlByAbsentLocalPath: input.urlByAbsentLocalPath,
5006
5071
  pageMotionBlur: input.pageMotionBlur,
5007
- animatedGifCacheDir: cfg.extractCacheDir ? join9(cfg.extractCacheDir, "animated-gif") : void 0,
5008
- ffmpegProcessTimeout: cfg.ffmpegProcessTimeout
5072
+ animatedGifCacheDir: cfg.extractCacheDir ? join10(cfg.extractCacheDir, "animated-gif") : void 0,
5073
+ ffmpegProcessTimeout: cfg.ffmpegProcessTimeout,
5074
+ allowOutsideProjectAssets: job.config.allowOutsideProjectAssets
5009
5075
  });
5010
5076
  assertNotAborted();
5011
5077
  const compileOnlyMs = Date.now() - compileStart;
@@ -5060,9 +5126,12 @@ async function runCompileStage(input) {
5060
5126
  width: compiled.width,
5061
5127
  height: compiled.height
5062
5128
  };
5129
+ if (!job.config.allowOutsideProjectAssets) {
5130
+ dropMediaOutsideProject({ projectDir, workDir, composition, log });
5131
+ }
5063
5132
  await preflightCompositionAssetMediaTypes({
5064
5133
  projectDir,
5065
- compiledDir: join9(workDir, "compiled"),
5134
+ compiledDir: join10(workDir, "compiled"),
5066
5135
  composition,
5067
5136
  signal: abortSignal
5068
5137
  });
@@ -5108,7 +5177,7 @@ async function runCompileStage(input) {
5108
5177
 
5109
5178
  // src/services/render/stages/probeStage.ts
5110
5179
  import { createHash as createHash6 } from "node:crypto";
5111
- import { basename as basename4, join as join10 } from "node:path";
5180
+ import { basename as basename4, join as join11 } from "node:path";
5112
5181
  import { parseHTML as parseHTML6 } from "linkedom";
5113
5182
  import {
5114
5183
  closeCaptureSession as closeCaptureSession4,
@@ -5334,10 +5403,11 @@ async function runProbeStage(input) {
5334
5403
  });
5335
5404
  fileServer = await createFileServer({
5336
5405
  projectDir,
5337
- compiledDir: join10(workDir, "compiled"),
5406
+ compiledDir: join11(workDir, "compiled"),
5338
5407
  port: 0,
5339
5408
  preHeadScripts: [VIRTUAL_TIME_SHIM],
5340
- fps: job.config.fps
5409
+ fps: job.config.fps,
5410
+ allowOutsideProjectAssets: job.config.allowOutsideProjectAssets
5341
5411
  });
5342
5412
  assertNotAborted();
5343
5413
  const motionBlur = job.config.motionBlur;
@@ -5369,7 +5439,7 @@ async function runProbeStage(input) {
5369
5439
  log.info("Creating capture session...", { attempt, maxAttempts: PROBE_MAX_ATTEMPTS });
5370
5440
  probeSession = await createCaptureSession4(
5371
5441
  fileServer.url,
5372
- join10(workDir, "probe"),
5442
+ join11(workDir, "probe"),
5373
5443
  captureOpts,
5374
5444
  null,
5375
5445
  probeCfg
@@ -5454,7 +5524,7 @@ async function runProbeStage(input) {
5454
5524
  });
5455
5525
  probeSession = await createCaptureSession4(
5456
5526
  fileServer.url,
5457
- join10(workDir, "probe-screenshot"),
5527
+ join11(workDir, "probe-screenshot"),
5458
5528
  captureOpts,
5459
5529
  null,
5460
5530
  { ...probeCfg, forceScreenshot: true }
@@ -5492,7 +5562,8 @@ async function runProbeStage(input) {
5492
5562
  compiled,
5493
5563
  resolutions,
5494
5564
  projectDir,
5495
- join10(workDir, "downloads")
5565
+ join11(workDir, "downloads"),
5566
+ job.config.allowOutsideProjectAssets ? void 0 : projectDir
5496
5567
  );
5497
5568
  assertNotAborted();
5498
5569
  composition.videos = compiled.videos;
@@ -5681,9 +5752,12 @@ async function runProbeStage(input) {
5681
5752
  }
5682
5753
  }
5683
5754
  }
5755
+ if (!job.config.allowOutsideProjectAssets) {
5756
+ dropMediaOutsideProject({ projectDir, workDir, composition, log });
5757
+ }
5684
5758
  await preflightCompositionAssetMediaTypes({
5685
5759
  projectDir,
5686
- compiledDir: join10(workDir, "compiled"),
5760
+ compiledDir: join11(workDir, "compiled"),
5687
5761
  composition,
5688
5762
  signal: abortSignal
5689
5763
  });
@@ -5851,7 +5925,7 @@ function validateDistributedDuration(input) {
5851
5925
 
5852
5926
  // src/services/render/stages/extractVideosStage.ts
5853
5927
  import { existsSync as existsSync9 } from "node:fs";
5854
- import { join as join11 } from "node:path";
5928
+ import { join as join12 } from "node:path";
5855
5929
  import {
5856
5930
  classifyVideoExtractionError,
5857
5931
  createFrameLookupTable as createFrameLookupTable3,
@@ -6197,14 +6271,14 @@ async function runExtractVideosStage(input) {
6197
6271
  // because short boundary counts can differ by one frame.
6198
6272
  {
6199
6273
  fps: job.config.fps,
6200
- outputDir: join11(compiledDir, "__hyperframes_video_frames"),
6274
+ outputDir: join12(compiledDir, "__hyperframes_video_frames"),
6201
6275
  format: job.config.videoFrameFormat ?? "auto",
6202
6276
  toneMapHdrToSdr: rendersSdrOnly(job.config, composition),
6203
6277
  timelineEnd: composition.duration,
6204
6278
  maxTransientRetries: extractionPolicy.maxTransientRetries,
6205
6279
  collectProbeFailures: extractionPolicy.failureMode === "enforce",
6206
6280
  deferRangeExtraction,
6207
- contentKeyedDirs: [join11(compiledDir, REMOTE_MEDIA_SUBDIR)],
6281
+ contentKeyedDirs: [join12(compiledDir, REMOTE_MEDIA_SUBDIR)],
6208
6282
  urlByAbsentLocalPath,
6209
6283
  onProgress: ({ planned = 0, done = 0 }) => {
6210
6284
  framesPlanned += planned;
@@ -6312,7 +6386,7 @@ import {
6312
6386
 
6313
6387
  // src/services/render/stages/audioStage.ts
6314
6388
  import { existsSync as existsSync11 } from "node:fs";
6315
- import { join as join14 } from "node:path";
6389
+ import { join as join15 } from "node:path";
6316
6390
  import {
6317
6391
  MIXED_AUDIO_FILENAME,
6318
6392
  audioFailureDiagnostics,
@@ -6323,7 +6397,7 @@ import {
6323
6397
 
6324
6398
  // src/services/render/audioDeliveryLimit.ts
6325
6399
  import { existsSync as existsSync10 } from "node:fs";
6326
- import { dirname as dirname8, join as join13 } from "node:path";
6400
+ import { dirname as dirname8, join as join14 } from "node:path";
6327
6401
  import {
6328
6402
  applyAudioFxChain,
6329
6403
  describeFfmpegFailure as describeFfmpegFailure3,
@@ -6333,7 +6407,7 @@ import {
6333
6407
 
6334
6408
  // src/services/render/audioPadTrim.ts
6335
6409
  import { spawn } from "node:child_process";
6336
- import { dirname as dirname7, join as join12 } from "node:path";
6410
+ import { dirname as dirname7, join as join13 } from "node:path";
6337
6411
  import {
6338
6412
  DEFAULT_CONFIG,
6339
6413
  describeFfmpegFailure as describeFfmpegFailure2,
@@ -6613,7 +6687,7 @@ async function constrainAacTruePeak(input) {
6613
6687
  }
6614
6688
  async function cutSource(input, scratchDir, attenuationDb) {
6615
6689
  if (!input.sourcePath || !input.rewriteSource) return true;
6616
- const cutPath = join12(scratchDir, "source.wav");
6690
+ const cutPath = join13(scratchDir, "source.wav");
6617
6691
  try {
6618
6692
  const result = await input.rewriteSource(input.sourcePath, cutPath, gainFilter(attenuationDb));
6619
6693
  if (!result.success) throw new Error(result.error);
@@ -6628,7 +6702,7 @@ async function enforceAacTruePeak(input) {
6628
6702
  let scratchDir;
6629
6703
  try {
6630
6704
  scratchDir = createStagingDir3(dirname7(input.audioPath), ".true-peak-");
6631
- const correctedPath = join12(scratchDir, "audio.m4a");
6705
+ const correctedPath = join13(scratchDir, "audio.m4a");
6632
6706
  const measurements = [];
6633
6707
  let attenuationDb = 0;
6634
6708
  let sourcePeakDbfs;
@@ -6838,7 +6912,7 @@ async function limitDeliveryPeaks(input, deps = {
6838
6912
  const peak = await deps.measure(audioPath, { timeoutMs, signal });
6839
6913
  if (peak <= AAC_DELIVERY_TRUE_PEAK_DBFS) return { success: true };
6840
6914
  const alternating = ["a", "b"].map(
6841
- (k) => join13(dirname8(sourcePath), `audio-source-limited-${k}.wav`)
6915
+ (k) => join14(dirname8(sourcePath), `audio-source-limited-${k}.wav`)
6842
6916
  );
6843
6917
  let encodedFrom;
6844
6918
  let ceiling = AAC_DELIVERY_TRUE_PEAK_DBFS;
@@ -6910,7 +6984,7 @@ function runAudioStage(input) {
6910
6984
  }
6911
6985
  async function runAudioStageScoped(input) {
6912
6986
  const stageStart = Date.now();
6913
- const pcmSourcePath = join14(input.workDir, "audio-source.wav");
6987
+ const pcmSourcePath = join15(input.workDir, "audio-source.wav");
6914
6988
  const duration = input.totalFrames * input.fps.den / input.fps.num;
6915
6989
  let deliverySourcePath;
6916
6990
  try {
@@ -6975,7 +7049,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
6975
7049
  assertNotAborted,
6976
7050
  log
6977
7051
  } = input;
6978
- const audioOutputPath = join14(workDir, MIXED_AUDIO_FILENAME);
7052
+ const audioOutputPath = join15(workDir, MIXED_AUDIO_FILENAME);
6979
7053
  let hasAudio = false;
6980
7054
  let audioError;
6981
7055
  let audioFailures;
@@ -6986,7 +7060,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
6986
7060
  audioResult = await processCompositionAudio(
6987
7061
  audios,
6988
7062
  projectDir,
6989
- join14(workDir, "audio-work"),
7063
+ join15(workDir, "audio-work"),
6990
7064
  audioOutputPath,
6991
7065
  duration,
6992
7066
  abortSignal,
@@ -7055,7 +7129,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
7055
7129
 
7056
7130
  // src/services/render/stages/captureStage.ts
7057
7131
  import { existsSync as existsSync12, readdirSync, statfsSync } from "node:fs";
7058
- import { join as join15 } from "node:path";
7132
+ import { join as join16 } from "node:path";
7059
7133
  import {
7060
7134
  classifyCaptureFailure as classifyCaptureFailure2,
7061
7135
  frameFileExtension,
@@ -7109,13 +7183,13 @@ function measureCaptureFrameBytes(workDir, framesDir) {
7109
7183
  if (!existsSync12(workDir)) return total;
7110
7184
  for (const attempt of readdirSync(workDir)) {
7111
7185
  if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
7112
- total += sampleDirectoryBytes(join15(workDir, attempt));
7186
+ total += sampleDirectoryBytes(join16(workDir, attempt));
7113
7187
  continue;
7114
7188
  }
7115
7189
  if (!/^capture-attempt-\d+$/.test(attempt)) continue;
7116
- const attemptDir = join15(workDir, attempt);
7190
+ const attemptDir = join16(workDir, attempt);
7117
7191
  for (const name of readdirSync(attemptDir)) {
7118
- if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join15(attemptDir, name));
7192
+ if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join16(attemptDir, name));
7119
7193
  }
7120
7194
  }
7121
7195
  return total;
@@ -7456,7 +7530,7 @@ import {
7456
7530
  writeFileSync as writeFileSync4
7457
7531
  } from "node:fs";
7458
7532
  import { readFile as readFile2 } from "node:fs/promises";
7459
- import { dirname as dirname9, join as join16 } from "node:path";
7533
+ import { dirname as dirname9, join as join17 } from "node:path";
7460
7534
  import {
7461
7535
  encodeFramesChunkedConcat,
7462
7536
  encodeFramesFromDir,
@@ -7667,7 +7741,7 @@ function encodeWhileCapturing(input, totalFrames) {
7667
7741
  await new Promise((resolve10) => wake = resolve10);
7668
7742
  }
7669
7743
  if (signal.aborted) return;
7670
- const mergedPath = join16(input.framesDir, formatCaptureFrameName(next, "jpg"));
7744
+ const mergedPath = join17(input.framesDir, formatCaptureFrameName(next, "jpg"));
7671
7745
  const frame = await readLandedFrame(landed.get(next), mergedPath);
7672
7746
  landed.delete(next);
7673
7747
  if (!await stream.writeFrame(frame)) {
@@ -7750,11 +7824,11 @@ async function runEncodeStage(input) {
7750
7824
  );
7751
7825
  }
7752
7826
  captured.forEach((name, i) => {
7753
- const dst = join16(outputPath, formatExportFrameName(i, "png"));
7754
- copyFileSync4(join16(framesDir, name), dst);
7827
+ const dst = join17(outputPath, formatExportFrameName(i, "png"));
7828
+ copyFileSync4(join17(framesDir, name), dst);
7755
7829
  });
7756
7830
  if (hasAudio && audioOutputPath && existsSync13(audioOutputPath)) {
7757
- copyFileSync4(audioOutputPath, join16(outputPath, MIXED_AUDIO_FILENAME2));
7831
+ copyFileSync4(audioOutputPath, join17(outputPath, MIXED_AUDIO_FILENAME2));
7758
7832
  log.info(
7759
7833
  `[Render] png-sequence: ${MIXED_AUDIO_FILENAME2} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME2}`
7760
7834
  );
@@ -7774,7 +7848,7 @@ async function runEncodeStage(input) {
7774
7848
  const encodeResult2 = await encodeGifFromDir(framesDir, framePattern2, outputPath, {
7775
7849
  fps: job.config.fps,
7776
7850
  loop,
7777
- palettePath: join16(dirname9(videoOnlyPath), "gif-palette.png"),
7851
+ palettePath: join17(dirname9(videoOnlyPath), "gif-palette.png"),
7778
7852
  preserveAlpha: needsAlpha,
7779
7853
  signal: abortSignal,
7780
7854
  timeout: engineCfg.ffmpegEncodeTimeout
@@ -7833,7 +7907,7 @@ function sampleDirectoryBytes(dir) {
7833
7907
  continue;
7834
7908
  }
7835
7909
  for (const name of entries) {
7836
- const full = join17(current, name);
7910
+ const full = join18(current, name);
7837
7911
  try {
7838
7912
  const st = statSync5(full);
7839
7913
  if (st.isDirectory()) {
@@ -7915,7 +7989,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
7915
7989
  const ranges = [];
7916
7990
  let rangeStart = null;
7917
7991
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
7918
- const framePath = join17(framesDir, formatCaptureFrameName(frameIndex, frameExt));
7992
+ const framePath = join18(framesDir, formatCaptureFrameName(frameIndex, frameExt));
7919
7993
  const missing = !existsSync14(framePath) || statSync5(framePath).size <= 8;
7920
7994
  if (missing && rangeStart === null) {
7921
7995
  rangeStart = frameIndex;
@@ -7932,7 +8006,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
7932
8006
  function buildMissingFrameRetryBatches(ranges, maxWorkers, workDir, attempt, rangeStart = 0, stride = 1) {
7933
8007
  const workersPerBatch = Math.max(1, Math.floor(maxWorkers));
7934
8008
  const batches = [];
7935
- const outputDirFor = (batchIndex, workerId) => join17(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
8009
+ const outputDirFor = (batchIndex, workerId) => join18(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
7936
8010
  if (stride > 1) {
7937
8011
  const spans = /* @__PURE__ */ new Map();
7938
8012
  for (const range of ranges) {
@@ -8013,7 +8087,7 @@ function isRecoverableParallelCaptureError(error) {
8013
8087
  function countCapturedFrames(totalFrames, framesDir, frameExt) {
8014
8088
  let captured = 0;
8015
8089
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
8016
- const framePath = join17(framesDir, formatCaptureFrameName(frameIndex, frameExt));
8090
+ const framePath = join18(framesDir, formatCaptureFrameName(frameIndex, frameExt));
8017
8091
  if (existsSync14(framePath)) captured++;
8018
8092
  }
8019
8093
  return captured;
@@ -8039,7 +8113,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
8039
8113
  reason: attempt === 0 ? "initial" : pendingTransientRetry ? "transient-retry" : "retry"
8040
8114
  });
8041
8115
  pendingTransientRetry = false;
8042
- const attemptWorkDir = join17(options.workDir, `capture-attempt-${attempt}`);
8116
+ const attemptWorkDir = join18(options.workDir, `capture-attempt-${attempt}`);
8043
8117
  const batches = missingRanges ? buildMissingFrameRetryBatches(
8044
8118
  missingRanges,
8045
8119
  currentWorkers,
@@ -8232,7 +8306,7 @@ function explainStreamingEncodeGate(cfg, outputFormat, workerCount, durationSeco
8232
8306
  var DEFAULT_SEGMENTED_MIN_SECONDS = Number.POSITIVE_INFINITY;
8233
8307
 
8234
8308
  // src/services/distributed/planFrameCost.ts
8235
- import { join as join20 } from "node:path";
8309
+ import { join as join21 } from "node:path";
8236
8310
  import {
8237
8311
  closeCaptureSession as closeCaptureSession9,
8238
8312
  createCaptureSession as createCaptureSession9,
@@ -8242,7 +8316,7 @@ import {
8242
8316
 
8243
8317
  // src/services/distributed/chunkFrames.ts
8244
8318
  import { existsSync as existsSync16, readdirSync as readdirSync4 } from "node:fs";
8245
- import { extname as extname2, join as join19 } from "node:path";
8319
+ import { extname as extname2, join as join20 } from "node:path";
8246
8320
  import {
8247
8321
  compositionRequiresWebGpu as compositionRequiresWebGpu3,
8248
8322
  createVideoFrameInjector as createVideoFrameInjector3,
@@ -8251,7 +8325,7 @@ import {
8251
8325
 
8252
8326
  // src/services/distributed/shared.ts
8253
8327
  import { execFile as execFileCallback } from "node:child_process";
8254
- import { dirname as dirname11, join as join18 } from "node:path";
8328
+ import { dirname as dirname11, join as join19 } from "node:path";
8255
8329
  import { existsSync as existsSync15, readFileSync as readFileSync7 } from "node:fs";
8256
8330
  import { fileURLToPath as fileURLToPath3 } from "node:url";
8257
8331
  import { promisify as promisify2 } from "node:util";
@@ -8267,7 +8341,7 @@ function isPlanAudioArtifactPath(path) {
8267
8341
  }
8268
8342
  function resolvePlanAudioPath(planDir) {
8269
8343
  for (const name of [PLAN_AUDIO_RELATIVE_PATH, PLAN_AUDIO_LEGACY_RELATIVE_PATH]) {
8270
- const candidate = join18(planDir, name);
8344
+ const candidate = join19(planDir, name);
8271
8345
  if (existsSync15(candidate)) return candidate;
8272
8346
  }
8273
8347
  return null;
@@ -8519,7 +8593,8 @@ function buildSyntheticRenderJob(input) {
8519
8593
  producerConfig: input.producerConfig,
8520
8594
  variables: input.variables,
8521
8595
  strictVariables: input.strictVariables,
8522
- pageMotionBlur: input.pageMotionBlur
8596
+ pageMotionBlur: input.pageMotionBlur,
8597
+ allowOutsideProjectAssets: input.allowOutsideProjectAssets
8523
8598
  };
8524
8599
  return createRenderJob(renderConfig);
8525
8600
  }
@@ -8529,7 +8604,7 @@ function readProducerVersion() {
8529
8604
  const startDir = dirname11(fileURLToPath3(import.meta.url));
8530
8605
  let current = startDir;
8531
8606
  for (let i = 0; i < 10; i++) {
8532
- const candidate = join18(current, "package.json");
8607
+ const candidate = join19(current, "package.json");
8533
8608
  if (existsSync15(candidate)) {
8534
8609
  try {
8535
8610
  const pkg = JSON.parse(readFileSync7(candidate, "utf-8"));
@@ -8584,7 +8659,7 @@ function frameNumberFromFileName(name) {
8584
8659
  function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v1") {
8585
8660
  const result = [];
8586
8661
  for (const v of videos) {
8587
- const outputDir = join19(planDir, "video-frames", mediaIdPathSegment3(v.videoId));
8662
+ const outputDir = join20(planDir, "video-frames", mediaIdPathSegment3(v.videoId));
8588
8663
  if (!existsSync16(outputDir)) {
8589
8664
  throw new Error(
8590
8665
  `[renderChunk] planDir missing extracted video frames for ${JSON.stringify(v.videoId)}: ${outputDir} not present. plan() should have written frames here; the planDir is malformed.`
@@ -8603,7 +8678,7 @@ function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v
8603
8678
  if (!frameName) continue;
8604
8679
  const frameNumber = indexMode === "sparse-v2" ? frameNumberFromFileName(frameName) : null;
8605
8680
  const frameIndex = frameNumber === null ? i : frameNumber - 1;
8606
- framePaths.set(frameIndex, join19(outputDir, frameName));
8681
+ framePaths.set(frameIndex, join20(outputDir, frameName));
8607
8682
  }
8608
8683
  result.push({
8609
8684
  videoId: v.videoId,
@@ -8683,7 +8758,7 @@ async function extractDeferredVideoFramesForChunk(input) {
8683
8758
  sourceOf: (video) => {
8684
8759
  const range = planned.get(video.videoId).deferredRange;
8685
8760
  const remoteUrl = remoteSources[range.sourcePath];
8686
- const sourcePath = remoteUrl ?? join19(input.planDir, ...range.sourcePath.split("/"));
8761
+ const sourcePath = remoteUrl ?? join20(input.planDir, ...range.sourcePath.split("/"));
8687
8762
  if (remoteUrl === void 0 && !existsSync16(sourcePath)) {
8688
8763
  throw new RenderChunkValidationError(
8689
8764
  MISSING_PLAN_ARTIFACT,
@@ -8714,12 +8789,12 @@ async function measurePlanSecondsPerFrame(input) {
8714
8789
  planVideos,
8715
8790
  frames: sampled,
8716
8791
  fps: fpsRatio,
8717
- outputRoot: join20(workDir, "frame-cost-video-frames"),
8792
+ outputRoot: join21(workDir, "frame-cost-video-frames"),
8718
8793
  cfg: input.cfg
8719
8794
  })
8720
8795
  ];
8721
8796
  const lookup = extracted.length > 0 ? createFrameLookupTable4(planVideos.videos, extracted, resolveRenderFpsConfig(fpsRatio).value) : null;
8722
- const compiledDir = join20(planDir, "compiled");
8797
+ const compiledDir = join21(planDir, "compiled");
8723
8798
  const fileServer = await createFileServer({
8724
8799
  projectDir: compiledDir,
8725
8800
  compiledDir,
@@ -8731,7 +8806,7 @@ async function measurePlanSecondsPerFrame(input) {
8731
8806
  try {
8732
8807
  session = await createCaptureSession9(
8733
8808
  fileServer.url,
8734
- join20(workDir, "frame-cost"),
8809
+ join21(workDir, "frame-cost"),
8735
8810
  buildChunkCaptureOptions({
8736
8811
  dimensions: { ...input, fpsNum: fps, fpsDen: 1 },
8737
8812
  encoder: input,
@@ -8828,7 +8903,7 @@ function buildWeightedChunkSlices(weights, chunkCount, minFrames, maxFrames) {
8828
8903
  }
8829
8904
 
8830
8905
  // src/services/render/planReferenceBackground.ts
8831
- import { join as join21 } from "node:path";
8906
+ import { join as join22 } from "node:path";
8832
8907
  import {
8833
8908
  closeCaptureSession as closeCaptureSession10,
8834
8909
  createCaptureSession as createCaptureSession10,
@@ -8841,14 +8916,14 @@ async function readPlanReferenceBackground(input) {
8841
8916
  try {
8842
8917
  server = await createFileServer({
8843
8918
  projectDir: input.projectDir,
8844
- compiledDir: join21(input.workDir, "compiled"),
8919
+ compiledDir: join22(input.workDir, "compiled"),
8845
8920
  port: 0,
8846
8921
  preHeadScripts: [VIRTUAL_TIME_SHIM],
8847
8922
  fps: input.options.fps
8848
8923
  });
8849
8924
  session = await createCaptureSession10(
8850
8925
  server.url,
8851
- join21(input.workDir, "reference"),
8926
+ join22(input.workDir, "reference"),
8852
8927
  {
8853
8928
  ...input.options,
8854
8929
  requiresWebGpu: false
@@ -8885,7 +8960,7 @@ async function readPlanReferenceBackground(input) {
8885
8960
 
8886
8961
  // src/services/render/stages/freezePlan.ts
8887
8962
  import { existsSync as existsSync17, mkdirSync as mkdirSync7, readFileSync as readFileSync8, readdirSync as readdirSync5, writeFileSync as writeFileSync6 } from "node:fs";
8888
- import { join as join22, relative as relative3, resolve as resolve8 } from "node:path";
8963
+ import { join as join23, relative as relative4, resolve as resolve8 } from "node:path";
8889
8964
  import {
8890
8965
  REFERENCE_BACKGROUND_FIELD,
8891
8966
  referenceBackgroundResult as referenceBackgroundResult3
@@ -9103,12 +9178,12 @@ function listPlanFiles(planDir) {
9103
9178
  function walk(dir) {
9104
9179
  const entries = readdirSync5(dir, { withFileTypes: true });
9105
9180
  for (const entry of entries) {
9106
- const full = join22(dir, entry.name);
9181
+ const full = join23(dir, entry.name);
9107
9182
  if (entry.isDirectory()) {
9108
9183
  walk(full);
9109
9184
  } else if (entry.isFile()) {
9110
9185
  results.push({
9111
- planRelativePath: relative3(rootResolved, full).split(/[\\/]+/).join("/"),
9186
+ planRelativePath: relative4(rootResolved, full).split(/[\\/]+/).join("/"),
9112
9187
  absolutePath: full
9113
9188
  });
9114
9189
  }
@@ -9144,15 +9219,15 @@ var PLAN_REMOTE_FILES_RELATIVE_PATH = "meta/remote-files.json";
9144
9219
  function writePlanRemoteFiles(planDir, files) {
9145
9220
  if (files.length === 0) return;
9146
9221
  const sorted = [...files].sort((a, b) => a.path < b.path ? -1 : 1);
9147
- writeFileSync6(join22(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH), JSON.stringify(sorted), "utf-8");
9222
+ writeFileSync6(join23(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH), JSON.stringify(sorted), "utf-8");
9148
9223
  }
9149
9224
  function readPlanRemoteFiles(planDir) {
9150
- const path = join22(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH);
9225
+ const path = join23(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH);
9151
9226
  return existsSync17(path) ? JSON.parse(readFileSync8(path, "utf-8")) : [];
9152
9227
  }
9153
9228
  function recomputePlanHashFromPlanDir(planDir, digests) {
9154
- const planJsonPath = join22(planDir, "plan.json");
9155
- const encoderJsonPath = join22(planDir, "meta", "encoder.json");
9229
+ const planJsonPath = join23(planDir, "plan.json");
9230
+ const encoderJsonPath = join23(planDir, "meta", "encoder.json");
9156
9231
  if (!existsSync17(planJsonPath)) {
9157
9232
  throw new Error(`[freezePlan] plan.json missing: ${planJsonPath}`);
9158
9233
  }
@@ -9189,18 +9264,18 @@ async function freezePlan(input) {
9189
9264
  if (!existsSync17(planDir)) {
9190
9265
  throw new Error(`[freezePlan] planDir does not exist: ${planDir}`);
9191
9266
  }
9192
- const metaDir = join22(planDir, "meta");
9267
+ const metaDir = join23(planDir, "meta");
9193
9268
  if (!existsSync17(metaDir)) mkdirSync7(metaDir, { recursive: true });
9194
9269
  writeFileSync6(
9195
- join22(metaDir, "composition.json"),
9270
+ join23(metaDir, "composition.json"),
9196
9271
  `${JSON.stringify(composition, null, 2)}
9197
9272
  `,
9198
9273
  "utf-8"
9199
9274
  );
9200
9275
  const encoderForCanonical = stripUndefined(encoder);
9201
9276
  const encoderConfigCanonicalJson = canonicalJsonStringify(encoderForCanonical);
9202
- writeFileSync6(join22(metaDir, "encoder.json"), encoderConfigCanonicalJson, "utf-8");
9203
- writeFileSync6(join22(metaDir, "chunks.json"), `${JSON.stringify(chunks, null, 2)}
9277
+ writeFileSync6(join23(metaDir, "encoder.json"), encoderConfigCanonicalJson, "utf-8");
9278
+ writeFileSync6(join23(metaDir, "chunks.json"), `${JSON.stringify(chunks, null, 2)}
9204
9279
  `, "utf-8");
9205
9280
  const { compositionHtml, assets } = collectPlanAssetShas(planDir, digests);
9206
9281
  const planHash = computePlanHash({
@@ -9225,7 +9300,7 @@ async function freezePlan(input) {
9225
9300
  duration: durationSeconds,
9226
9301
  hasAudio
9227
9302
  };
9228
- const planJsonPath = join22(planDir, "plan.json");
9303
+ const planJsonPath = join23(planDir, "plan.json");
9229
9304
  writeFileSync6(planJsonPath, `${JSON.stringify(planJson, null, 2)}
9230
9305
  `, "utf-8");
9231
9306
  return { planJsonPath, planHash };
@@ -9269,14 +9344,14 @@ function applyRuntimeEnvSnapshot(snapshot, env = process.env) {
9269
9344
  // src/services/distributed/chunkAudio.ts
9270
9345
  import { closeSync as closeSync4, existsSync as existsSync18, ftruncateSync, mkdirSync as mkdirSync9, openSync as openSync4, readFileSync as readFileSync9 } from "node:fs";
9271
9346
  import { writeFileSync as writeFileSync7, writeSync } from "node:fs";
9272
- import { join as join24 } from "node:path";
9347
+ import { join as join25 } from "node:path";
9273
9348
  import { appendRenderProvenanceArgs, describeFfmpegFailure as describeFfmpegFailure4, runFfmpeg as runFfmpeg7 } from "@hyperframes/engine";
9274
9349
 
9275
9350
  // src/services/distributed/mp4Stitch.ts
9276
9351
  import { createReadStream as createReadStream4, createWriteStream, mkdirSync as mkdirSync8, rmSync as rmSync6 } from "node:fs";
9277
9352
  import { open } from "node:fs/promises";
9278
9353
  import { renameWithRetry as renameWithRetry7 } from "@hyperframes/engine";
9279
- import { basename as basename5, dirname as dirname12, join as join23 } from "node:path";
9354
+ import { basename as basename5, dirname as dirname12, join as join24 } from "node:path";
9280
9355
  import { finished, pipeline } from "node:stream/promises";
9281
9356
  import { createStagingDir as createStagingDir4 } from "@hyperframes/core/atomic-file";
9282
9357
  function boxAt(src, off, at, limit) {
@@ -9643,13 +9718,13 @@ async function writeStitchedMp4(chunkPaths, outputPath, audioPath) {
9643
9718
  const header = audioPath ? buildStitchedHeader(layouts.slice(1), layouts[0]) : buildStitchedHeader(layouts);
9644
9719
  mkdirSync8(dirname12(outputPath), { recursive: true });
9645
9720
  const workDir = createStagingDir4(dirname12(outputPath), `${basename5(outputPath)}.stitch-`);
9646
- const out = createWriteStream(join23(workDir, "out.mp4"));
9721
+ const out = createWriteStream(join24(workDir, "out.mp4"));
9647
9722
  try {
9648
9723
  out.write(header);
9649
9724
  for (const [i, path] of sourcePaths.entries()) await copyPayload(path, layouts[i], i, out);
9650
9725
  out.end();
9651
9726
  await finished(out);
9652
- renameWithRetry7(join23(workDir, "out.mp4"), outputPath);
9727
+ renameWithRetry7(join24(workDir, "out.mp4"), outputPath);
9653
9728
  } finally {
9654
9729
  out.destroy();
9655
9730
  rmSync6(workDir, { recursive: true, force: true });
@@ -9743,7 +9818,7 @@ async function writeChunkAudioSlices(input) {
9743
9818
  });
9744
9819
  const bytes = readFileSync9(input.audioPath);
9745
9820
  const layout = { sizeBytes: bytes.length, payloadStart, payloadEnd, partStarts: {} };
9746
- mkdirSync9(join24(input.planDir, SLICE_DIR), { recursive: true });
9821
+ mkdirSync9(join25(input.planDir, SLICE_DIR), { recursive: true });
9747
9822
  input.chunks.forEach((_, index) => {
9748
9823
  const cut = audioCutForChunk(grid, input.chunks, index, input.fps);
9749
9824
  if (!cut) return;
@@ -9751,17 +9826,17 @@ async function writeChunkAudioSlices(input) {
9751
9826
  const start = offsets[cut.firstPacket];
9752
9827
  layout.partStarts[index] = start;
9753
9828
  const end = offsets[last] + track.sizes[last];
9754
- writeFileSync7(join24(input.planDir, chunkAudioSlicePath(index)), bytes.subarray(start, end));
9829
+ writeFileSync7(join25(input.planDir, chunkAudioSlicePath(index)), bytes.subarray(start, end));
9755
9830
  });
9756
9831
  const frame = [bytes.subarray(0, payloadStart), bytes.subarray(payloadEnd)];
9757
- writeFileSync7(join24(input.planDir, SLICE_FRAME), Buffer.concat(frame));
9758
- writeFileSync7(join24(input.planDir, SLICE_LAYOUT), JSON.stringify(layout));
9832
+ writeFileSync7(join25(input.planDir, SLICE_FRAME), Buffer.concat(frame));
9833
+ writeFileSync7(join25(input.planDir, SLICE_LAYOUT), JSON.stringify(layout));
9759
9834
  }
9760
9835
  function chunkAudioSource(planDir, chunkIndex, scratchPath) {
9761
- const layoutPath = join24(planDir, SLICE_LAYOUT);
9836
+ const layoutPath = join25(planDir, SLICE_LAYOUT);
9762
9837
  if (!existsSync18(layoutPath)) return resolvePlanAudioPath(planDir);
9763
9838
  const layout = JSON.parse(readFileSync9(layoutPath, "utf-8"));
9764
- const frame = readFileSync9(join24(planDir, SLICE_FRAME));
9839
+ const frame = readFileSync9(join25(planDir, SLICE_FRAME));
9765
9840
  const fd = openSync4(scratchPath, "w");
9766
9841
  try {
9767
9842
  writeSync(fd, frame, 0, layout.payloadStart, 0);
@@ -9774,7 +9849,7 @@ function chunkAudioSource(planDir, chunkIndex, scratchPath) {
9774
9849
  );
9775
9850
  const start = layout.partStarts[chunkIndex];
9776
9851
  if (start !== void 0) {
9777
- const part = readFileSync9(join24(planDir, chunkAudioSlicePath(chunkIndex)));
9852
+ const part = readFileSync9(join25(planDir, chunkAudioSlicePath(chunkIndex)));
9778
9853
  writeSync(fd, part, 0, part.length, start);
9779
9854
  }
9780
9855
  ftruncateSync(fd, layout.sizeBytes);
@@ -9830,7 +9905,7 @@ async function muxChunkWithAudio(input) {
9830
9905
  // src/services/distributed/planSize.ts
9831
9906
  import { createHash as createHash8 } from "node:crypto";
9832
9907
  import { lstatSync, readdirSync as readdirSync6 } from "node:fs";
9833
- import { extname as extname3, join as join25, relative as relative4 } from "node:path";
9908
+ import { extname as extname3, join as join26, relative as relative5 } from "node:path";
9834
9909
  var MAX_TOP_COMPONENTS = 10;
9835
9910
  var SOURCE_MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
9836
9911
  ".aac",
@@ -9919,7 +9994,7 @@ function recordFile(result, components, rootDir, rootKind, filePath) {
9919
9994
  } catch {
9920
9995
  return;
9921
9996
  }
9922
- const rel = relative4(rootDir, filePath);
9997
+ const rel = relative5(rootDir, filePath);
9923
9998
  const segments = rel.split(/[\\/]+/).filter(Boolean);
9924
9999
  const classified = classifyFile(segments, rootKind);
9925
10000
  result.totalBytes += sizeBytes;
@@ -9942,7 +10017,7 @@ function walkRegularFiles(dir, visit) {
9942
10017
  return;
9943
10018
  }
9944
10019
  for (const entry of entries) {
9945
- const full = join25(dir, entry.name);
10020
+ const full = join26(dir, entry.name);
9946
10021
  if (entry.isDirectory()) {
9947
10022
  walkRegularFiles(full, visit);
9948
10023
  } else if (entry.isFile()) {
@@ -10162,13 +10237,13 @@ function assertPositiveInteger(name, value) {
10162
10237
  }
10163
10238
  var FREEZE_OWNED_PLAN_FILES = [
10164
10239
  "plan.json",
10165
- join26("meta", "composition.json"),
10166
- join26("meta", "encoder.json"),
10167
- join26("meta", "chunks.json")
10240
+ join27("meta", "composition.json"),
10241
+ join27("meta", "encoder.json"),
10242
+ join27("meta", "chunks.json")
10168
10243
  ];
10169
10244
  function removeFreezeOwnedPlanFiles(planDir) {
10170
10245
  for (const relativePath of FREEZE_OWNED_PLAN_FILES) {
10171
- rmSync7(join26(planDir, relativePath), { force: true });
10246
+ rmSync7(join27(planDir, relativePath), { force: true });
10172
10247
  }
10173
10248
  }
10174
10249
  function buildChunkSlices(totalFrames, chunkCount, effectiveChunkSize) {
@@ -10307,7 +10382,7 @@ function resolveDistributedEngineConfig(config) {
10307
10382
  };
10308
10383
  }
10309
10384
  function pathInside(root, path) {
10310
- const rel = relative5(root, path);
10385
+ const rel = relative6(root, path);
10311
10386
  return rel === "" || rel.startsWith("..") || isAbsolute3(rel) ? null : rel;
10312
10387
  }
10313
10388
  function stableSourcePath(roots, srcPath) {
@@ -10323,19 +10398,19 @@ function createVideoSourceShipper(input) {
10323
10398
  const known = shipped.get(srcPath);
10324
10399
  if (known) return known;
10325
10400
  const stagedRel = pathInside(input.workVideoFramesDir, srcPath);
10326
- const current = stagedRel === null ? srcPath : join26(input.planDir, "video-frames", stagedRel);
10401
+ const current = stagedRel === null ? srcPath : join27(input.planDir, "video-frames", stagedRel);
10327
10402
  let result = null;
10328
10403
  for (const root of stagedRel === null ? [input.workCompiledDir, input.projectDir] : []) {
10329
10404
  const rel = pathInside(root, srcPath);
10330
- if (rel !== null && (existsSync19(join26(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
10405
+ if (rel !== null && (existsSync19(join27(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
10331
10406
  result = ["compiled", ...rel.split(sep3)].join("/");
10332
10407
  break;
10333
10408
  }
10334
10409
  }
10335
10410
  if (result === null) {
10336
10411
  result = `video-sources/${shipped.size}${extname4(current)}`;
10337
- const destination = join26(input.planDir, ...result.split("/"));
10338
- mkdirSync10(join26(input.planDir, "video-sources"), { recursive: true });
10412
+ const destination = join27(input.planDir, ...result.split("/"));
10413
+ mkdirSync10(join27(input.planDir, "video-sources"), { recursive: true });
10339
10414
  try {
10340
10415
  linkSync(current, destination);
10341
10416
  } catch {
@@ -10383,34 +10458,36 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
10383
10458
  producerConfig: cfg,
10384
10459
  variables: config.variables,
10385
10460
  strictVariables: config.strictVariables,
10386
- pageMotionBlur: config.pageMotionBlur
10461
+ pageMotionBlur: config.pageMotionBlur,
10462
+ allowOutsideProjectAssets: options.allowOutsideProjectAssets === true
10387
10463
  });
10388
10464
  const entryFile = config.entryFile ?? "index.html";
10389
- const htmlPath = join26(projectDir, entryFile);
10465
+ const htmlPath = join27(projectDir, entryFile);
10390
10466
  if (!existsSync19(htmlPath)) {
10391
10467
  throw new Error(`[plan] entry file not found: ${htmlPath}`);
10392
10468
  }
10393
- const workDir = join26(planDir, ".plan-work");
10469
+ const workDir = join27(planDir, ".plan-work");
10394
10470
  rmSync7(workDir, { recursive: true, force: true });
10395
10471
  mkdirSync10(workDir, { recursive: true });
10396
- const compiledDir = join26(workDir, "compiled");
10472
+ const compiledDir = join27(workDir, "compiled");
10397
10473
  mkdirSync10(compiledDir, { recursive: true });
10398
10474
  let stageStarted = Date.now();
10399
10475
  cpSync2(projectDir, compiledDir, {
10400
10476
  recursive: true,
10401
10477
  dereference: true,
10402
10478
  filter: (src) => {
10403
- const rel = relative5(projectDir, src);
10479
+ const rel = relative6(projectDir, src);
10404
10480
  if (rel === "" || rel.startsWith("..")) return true;
10481
+ if (!job.config.allowOutsideProjectAssets && !isSafePath2(projectDir, src)) return false;
10405
10482
  const firstSegment = rel.split(sep3, 1)[0];
10406
10483
  return firstSegment === void 0 || !PLAN_PROJECT_DIR_SKIP_SEGMENTS.has(firstSegment);
10407
10484
  }
10408
10485
  });
10409
10486
  logPlanStage(log, "copy", stageStarted);
10410
- const finalCompiledDir = join26(planDir, "compiled");
10487
+ const finalCompiledDir = join27(planDir, "compiled");
10411
10488
  const needsAlpha = outputNeedsAlpha(config.format);
10412
10489
  const remoteFiles = Object.entries(options.remoteFiles ?? {});
10413
- const remoteLocalPath = (rel) => join26(projectDir, ...rel.split("/"));
10490
+ const remoteLocalPath = (rel) => join27(projectDir, ...rel.split("/"));
10414
10491
  for (const [, file] of remoteFiles) {
10415
10492
  declareContentAddressedUrl(file.url, file.sha256);
10416
10493
  if (file.probeFactsUrl) declareProbeFactsUrl(file.url, file.probeFactsUrl);
@@ -10614,10 +10691,10 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
10614
10691
  let stageStarted = Date.now();
10615
10692
  const extractResult = await extractPlanVideos(c, options.deferVideoExtraction);
10616
10693
  logPlanStage(log, "extract", stageStarted);
10617
- const stagedVideoFrames = join26(compiledDir, "__hyperframes_video_frames");
10618
- const videoFramesDst = join26(planDir, "video-frames");
10694
+ const stagedVideoFrames = join27(compiledDir, "__hyperframes_video_frames");
10695
+ const videoFramesDst = join27(planDir, "video-frames");
10619
10696
  if (existsSync19(videoFramesDst)) rmSync7(videoFramesDst, { recursive: true, force: true });
10620
- const videoSourcesDir = join26(planDir, "video-sources");
10697
+ const videoSourcesDir = join27(planDir, "video-sources");
10621
10698
  rmSync7(videoSourcesDir, { recursive: true, force: true });
10622
10699
  if (existsSync19(stagedVideoFrames)) {
10623
10700
  renameWithRetry8(stagedVideoFrames, videoFramesDst);
@@ -10654,7 +10731,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
10654
10731
  };
10655
10732
  })
10656
10733
  });
10657
- mkdirSync10(join26(planDir, "meta"), { recursive: true });
10734
+ mkdirSync10(join27(planDir, "meta"), { recursive: true });
10658
10735
  writePlanRemoteFiles(
10659
10736
  planDir,
10660
10737
  remoteFiles.map(([rel, { sha256, sizeBytes }]) => ({
@@ -10664,7 +10741,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
10664
10741
  }))
10665
10742
  );
10666
10743
  writeFileSync8(
10667
- join26(planDir, PLAN_VIDEOS_META_RELATIVE_PATH),
10744
+ join27(planDir, PLAN_VIDEOS_META_RELATIVE_PATH),
10668
10745
  JSON.stringify(planVideosJson, null, 2),
10669
10746
  "utf-8"
10670
10747
  );
@@ -10744,7 +10821,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
10744
10821
  if (audioResult?.audioError) {
10745
10822
  applyDistributedAudioWarningPolicy(job, audioResult.audioError, audioResult.audioFailures, log);
10746
10823
  }
10747
- const planAudioPath = join26(planDir, PLAN_AUDIO_RELATIVE_PATH);
10824
+ const planAudioPath = join27(planDir, PLAN_AUDIO_RELATIVE_PATH);
10748
10825
  if (audioResult?.hasAudio && existsSync19(audioResult.audioOutputPath)) {
10749
10826
  renameWithRetry8(audioResult.audioOutputPath, planAudioPath);
10750
10827
  }
@@ -10887,7 +10964,7 @@ import {
10887
10964
  writeFileSync as writeFileSync10
10888
10965
  } from "node:fs";
10889
10966
  import { tmpdir } from "node:os";
10890
- import { dirname as dirname14, isAbsolute as isAbsolute4, join as join29, relative as relative6, resolve as resolve9, sep as sep4 } from "node:path";
10967
+ import { dirname as dirname14, isAbsolute as isAbsolute4, join as join30, relative as relative7, resolve as resolve9, sep as sep4 } from "node:path";
10891
10968
  import { DISTRIBUTED_FPS, isDistributedFps } from "@hyperframes/core";
10892
10969
  import {
10893
10970
  createFrameLookupTable as createFrameLookupTable5,
@@ -10906,7 +10983,7 @@ import {
10906
10983
  writeFileSync as writeFileSync9
10907
10984
  } from "node:fs";
10908
10985
  import { renameWithRetry as renameWithRetry9 } from "@hyperframes/engine";
10909
- import { dirname as dirname13, join as join28 } from "node:path";
10986
+ import { dirname as dirname13, join as join29 } from "node:path";
10910
10987
 
10911
10988
  // src/services/distributed/planV2Errors.ts
10912
10989
  var PLAN_V2_INTEGRITY_UNRECOVERABLE = "PLAN_V2_INTEGRITY_UNRECOVERABLE";
@@ -10921,7 +10998,7 @@ var PlanV2IntegrityError = class extends Error {
10921
10998
  };
10922
10999
 
10923
11000
  // src/services/distributed/planV2Layout.ts
10924
- import { join as join27 } from "node:path";
11001
+ import { join as join28 } from "node:path";
10925
11002
  var SHA256_PATTERN = /^[0-9a-f]{64}$/;
10926
11003
  function assertPlanV2Sha256(value, field) {
10927
11004
  if (typeof value !== "string" || !SHA256_PATTERN.test(value)) {
@@ -10931,7 +11008,7 @@ function assertPlanV2Sha256(value, field) {
10931
11008
  }
10932
11009
  function planV2BlobPath(root, sha256) {
10933
11010
  const digest = assertPlanV2Sha256(sha256, "artifact sha256");
10934
- return join27(root, "artifacts", "sha256", digest.slice(0, 2), digest);
11011
+ return join28(root, "artifacts", "sha256", digest.slice(0, 2), digest);
10935
11012
  }
10936
11013
 
10937
11014
  // src/services/distributed/planV2Publisher.ts
@@ -10987,7 +11064,7 @@ var LocalPlanV2ArtifactPublisher = class {
10987
11064
  if (existsSync20(destinationPath)) return;
10988
11065
  mkdirSync11(dirname13(destinationPath), { recursive: true });
10989
11066
  const stagingDir = createStagingDir5(dirname13(destinationPath), ".plan-v2-blob-");
10990
- const temporaryPath = join28(stagingDir, "blob");
11067
+ const temporaryPath = join29(stagingDir, "blob");
10991
11068
  try {
10992
11069
  try {
10993
11070
  this.#linkFile(blob.sourcePath, temporaryPath);
@@ -11008,7 +11085,7 @@ var LocalPlanV2ArtifactPublisher = class {
11008
11085
  );
11009
11086
  }
11010
11087
  }
11011
- writeFileSync9(join28(this.temporaryDir, "plan.json"), manifestBytes, "utf-8");
11088
+ writeFileSync9(join29(this.temporaryDir, "plan.json"), manifestBytes, "utf-8");
11012
11089
  renameWithRetry9(this.temporaryDir, this.destinationDir);
11013
11090
  this.#committed = true;
11014
11091
  }
@@ -11054,12 +11131,12 @@ function listFiles(root) {
11054
11131
  const rootResolved = resolve9(root);
11055
11132
  function walk(dir) {
11056
11133
  for (const entry of readdirSync7(dir, { withFileTypes: true })) {
11057
- const absolutePath = join29(dir, entry.name);
11134
+ const absolutePath = join30(dir, entry.name);
11058
11135
  if (entry.isDirectory()) {
11059
11136
  walk(absolutePath);
11060
11137
  } else if (entry.isFile()) {
11061
11138
  files.push({
11062
- path: relative6(rootResolved, absolutePath).split(sep4).join("/"),
11139
+ path: relative7(rootResolved, absolutePath).split(sep4).join("/"),
11063
11140
  absolutePath
11064
11141
  });
11065
11142
  } else {
@@ -11081,13 +11158,13 @@ function assertValidExtractionCacheCompleteSentinel(path) {
11081
11158
  }
11082
11159
  }
11083
11160
  function validateExtractionCacheCompleteSentinels(executionPlanDir) {
11084
- const videoRoot = join29(executionPlanDir, "video-frames");
11161
+ const videoRoot = join30(executionPlanDir, "video-frames");
11085
11162
  if (!existsSync21(videoRoot)) return;
11086
11163
  for (const videoEntry of readdirSync7(videoRoot, { withFileTypes: true })) {
11087
11164
  if (!videoEntry.isDirectory()) continue;
11088
- const videoDir = join29(videoRoot, videoEntry.name);
11165
+ const videoDir = join30(videoRoot, videoEntry.name);
11089
11166
  if (readdirSync7(videoDir).includes(EXTRACTION_CACHE_COMPLETE_SENTINEL)) {
11090
- const sentinelPath = join29(videoDir, EXTRACTION_CACHE_COMPLETE_SENTINEL);
11167
+ const sentinelPath = join30(videoDir, EXTRACTION_CACHE_COMPLETE_SENTINEL);
11091
11168
  assertValidExtractionCacheCompleteSentinel(sentinelPath);
11092
11169
  }
11093
11170
  }
@@ -11134,7 +11211,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
11134
11211
  if (video.deferredRange) {
11135
11212
  const framePaths2 = /* @__PURE__ */ new Map();
11136
11213
  for (let index = 0; index < video.totalFrames; index++) {
11137
- framePaths2.set(index, join29(outputDir, String(index)));
11214
+ framePaths2.set(index, join30(outputDir, String(index)));
11138
11215
  }
11139
11216
  return { ...video, outputDir, framePaths: framePaths2, ownedByLookup: false };
11140
11217
  }
@@ -11142,7 +11219,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
11142
11219
  const framePaths = /* @__PURE__ */ new Map();
11143
11220
  for (const frameName of frameNames) {
11144
11221
  if (frameName === EXTRACTION_CACHE_COMPLETE_SENTINEL) {
11145
- assertValidExtractionCacheCompleteSentinel(join29(outputDir, frameName));
11222
+ assertValidExtractionCacheCompleteSentinel(join30(outputDir, frameName));
11146
11223
  continue;
11147
11224
  }
11148
11225
  const match = /(\d+)(?=\.[^.]+$)/.exec(frameName);
@@ -11161,7 +11238,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
11161
11238
  `duplicate extracted frame index ${frameIndex} in ${outputDir}`
11162
11239
  );
11163
11240
  }
11164
- framePaths.set(frameIndex, join29(outputDir, frameName));
11241
+ framePaths.set(frameIndex, join30(outputDir, frameName));
11165
11242
  }
11166
11243
  return {
11167
11244
  ...video,
@@ -11182,7 +11259,7 @@ function parsePlanVideosJson2(value) {
11182
11259
  }
11183
11260
  }
11184
11261
  function materializeExtractedVideoDirectories(planDir) {
11185
- const videosPath = join29(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
11262
+ const videosPath = join30(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
11186
11263
  if (!existsSync21(videosPath)) return;
11187
11264
  const videos = parsePlanVideosJson2(readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH));
11188
11265
  for (const video of videos.extracted) {
@@ -11216,13 +11293,13 @@ function parseChunkSlices(value) {
11216
11293
  });
11217
11294
  }
11218
11295
  function buildVideoChunkDependencies(executionPlanDir, dimensions) {
11219
- const videoRoot = join29(executionPlanDir, "video-frames");
11296
+ const videoRoot = join30(executionPlanDir, "video-frames");
11220
11297
  const hasExtractedFrames = existsSync21(videoRoot) && listFiles(videoRoot).length > 0;
11221
- const videosPath = join29(executionPlanDir, PLAN_VIDEOS_META_RELATIVE_PATH);
11298
+ const videosPath = join30(executionPlanDir, PLAN_VIDEOS_META_RELATIVE_PATH);
11222
11299
  if (!existsSync21(videosPath)) {
11223
11300
  return hasExtractedFrames ? { mode: "full-source-pack", dependencies: null } : { mode: "exact-rendered-frames", dependencies: /* @__PURE__ */ new Map() };
11224
11301
  }
11225
- const chunksPath = join29(executionPlanDir, "meta", "chunks.json");
11302
+ const chunksPath = join30(executionPlanDir, "meta", "chunks.json");
11226
11303
  const videos = readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH);
11227
11304
  const chunks = readJsonFile(chunksPath, "meta/chunks.json");
11228
11305
  const parsedVideos = parsePlanVideosJson2(videos);
@@ -11259,7 +11336,7 @@ function collectChunkVideoDependencies(input) {
11259
11336
  for (let frame = chunk.startFrame; frame < chunk.endFrame; frame++) {
11260
11337
  const globalTime = frame * input.fpsDen / input.fpsNum;
11261
11338
  for (const [videoId, payload] of input.table.getActiveFramePayloads(globalTime)) {
11262
- const path = input.deferredSources.get(videoId) ?? relative6(resolve9(input.executionPlanDir), payload.framePath).split(sep4).join("/");
11339
+ const path = input.deferredSources.get(videoId) ?? relative7(resolve9(input.executionPlanDir), payload.framePath).split(sep4).join("/");
11263
11340
  assertSafeRelativePath(path);
11264
11341
  const indexes = mutable.get(path) ?? /* @__PURE__ */ new Set();
11265
11342
  indexes.add(chunk.index);
@@ -11279,7 +11356,7 @@ function writeBlob(sourcePath, destinationPath) {
11279
11356
  if (existsSync21(destinationPath)) return;
11280
11357
  mkdirSync12(dirname14(destinationPath), { recursive: true });
11281
11358
  const temporaryDir = createStagingDir6(dirname14(destinationPath), ".plan-v2-blob-");
11282
- const temporaryPath = join29(temporaryDir, "blob");
11359
+ const temporaryPath = join30(temporaryDir, "blob");
11283
11360
  try {
11284
11361
  copyFileSync8(sourcePath, temporaryPath);
11285
11362
  renameWithRetry10(temporaryPath, destinationPath);
@@ -11315,7 +11392,7 @@ async function putTasks(tasks) {
11315
11392
  if (failure) throw failure.reason;
11316
11393
  }
11317
11394
  function buildPlanV2Publication(executionPlanDir, digests) {
11318
- const executionPlanPath = join29(executionPlanDir, "plan.json");
11395
+ const executionPlanPath = join30(executionPlanDir, "plan.json");
11319
11396
  if (!existsSync21(executionPlanPath)) {
11320
11397
  throw new PlanV2IntegrityError(`execution plan is missing plan.json: ${executionPlanPath}`);
11321
11398
  }
@@ -11343,7 +11420,7 @@ function buildPlanV2Publication(executionPlanDir, digests) {
11343
11420
  }
11344
11421
  validateExtractionCacheCompleteSentinels(executionPlanDir);
11345
11422
  const videoDependencyPlan = buildVideoChunkDependencies(executionPlanDir, dimensions);
11346
- const encoder = readJsonFile(join29(executionPlanDir, "meta", "encoder.json"), "meta/encoder.json");
11423
+ const encoder = readJsonFile(join30(executionPlanDir, "meta", "encoder.json"), "meta/encoder.json");
11347
11424
  const files = listFiles(executionPlanDir);
11348
11425
  const chunkAudio = !isRecord3(encoder) || encoder.chunksCarryAudio !== true ? "none" : files.some((file) => chunkAudioSliceTarget(file.path) !== null) ? "sliced" : "whole";
11349
11426
  for (const file of files) {
@@ -11410,7 +11487,7 @@ function createPlanV2FromExecutionPlan(executionPlanDir, planV2Dir) {
11410
11487
  writeBlob(blob.sourcePath, planV2BlobPath(tempDir, blob.sha256));
11411
11488
  }
11412
11489
  writeFileSync10(
11413
- join29(tempDir, "plan.json"),
11490
+ join30(tempDir, "plan.json"),
11414
11491
  canonicalJsonStringify(publication.manifest),
11415
11492
  "utf-8"
11416
11493
  );
@@ -11462,7 +11539,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
11462
11539
  // artifactTargets ships every compiled/ file to all chunks, so each is in the manifest.
11463
11540
  whileAudioMixes: () => putBlobs(
11464
11541
  publisher,
11465
- listFiles(join29(stagingRoot, "compiled")).map(
11542
+ listFiles(join30(stagingRoot, "compiled")).map(
11466
11543
  (file) => publishBlobFor(file.absolutePath, digests)
11467
11544
  )
11468
11545
  ),
@@ -11500,7 +11577,7 @@ function resultFromManifest(planV2Dir, manifest) {
11500
11577
  isRecord3(executionPlan) ? executionPlan[REFERENCE_BACKGROUND_FIELD3] : void 0
11501
11578
  ),
11502
11579
  planDir: planV2Dir,
11503
- manifestPath: join29(planV2Dir, "plan.json"),
11580
+ manifestPath: join30(planV2Dir, "plan.json"),
11504
11581
  planProtocol: PLAN_PROTOCOL_V2,
11505
11582
  planHash: manifest.planHash,
11506
11583
  sourcePlanV1Hash: getPlanV2ExecutionPlanHash(manifest),
@@ -11636,7 +11713,7 @@ function parsePlanV2Manifest(value) {
11636
11713
  return parsed;
11637
11714
  }
11638
11715
  function readPlanV2Manifest(planV2Dir) {
11639
- const manifestPath = join29(planV2Dir, "plan.json");
11716
+ const manifestPath = join30(planV2Dir, "plan.json");
11640
11717
  if (!existsSync21(manifestPath)) {
11641
11718
  throw new PlanV2IntegrityError(`missing v2 manifest: ${manifestPath}`);
11642
11719
  }
@@ -11685,13 +11762,13 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
11685
11762
  const tempDir = createStagingDir6(dirname14(destinationDir), ".plan-v2-materialize-");
11686
11763
  try {
11687
11764
  for (const { artifact, sourcePath } of verified) {
11688
- const destinationPath = join29(tempDir, ...artifact.path.split("/"));
11765
+ const destinationPath = join30(tempDir, ...artifact.path.split("/"));
11689
11766
  mkdirSync12(dirname14(destinationPath), { recursive: true });
11690
11767
  copyFileSync8(sourcePath, destinationPath);
11691
11768
  }
11692
11769
  if (target.role === "chunk") materializeExtractedVideoDirectories(tempDir);
11693
11770
  writeFileSync10(
11694
- join29(tempDir, PLAN_V2_MATERIALIZATION_MARKER),
11771
+ join30(tempDir, PLAN_V2_MATERIALIZATION_MARKER),
11695
11772
  canonicalJsonStringify({
11696
11773
  manifest,
11697
11774
  target,
@@ -11714,7 +11791,7 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
11714
11791
  // Join the artifact's OWN name, not the current constant: a plan written
11715
11792
  // before the container change carries the legacy name, and materializing it
11716
11793
  // under the new one would point at a file that was never written.
11717
- audioPath: target.role === "assembler" ? audioArtifact ? join29(destinationDir, audioArtifact.path) : null : null
11794
+ audioPath: target.role === "assembler" ? audioArtifact ? join30(destinationDir, audioArtifact.path) : null : null
11718
11795
  };
11719
11796
  }
11720
11797
  function assertRemoteSources(remoteSources, artifacts) {
@@ -11733,7 +11810,7 @@ function validatePlanV2MaterializedTarget(planDir, expectedTarget) {
11733
11810
  return readValidatedPlanV2Materialization(planDir, expectedTarget)?.manifest ?? null;
11734
11811
  }
11735
11812
  function readValidatedPlanV2Materialization(planDir, expectedTarget) {
11736
- const markerPath = join29(planDir, PLAN_V2_MATERIALIZATION_MARKER);
11813
+ const markerPath = join30(planDir, PLAN_V2_MATERIALIZATION_MARKER);
11737
11814
  if (!existsSync21(markerPath)) return null;
11738
11815
  const marker = readJsonFile(markerPath, "materialization marker");
11739
11816
  if (!isRecord3(marker) || !isRecord3(marker.manifest) || !isRecord3(marker.target)) {
@@ -11751,7 +11828,7 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
11751
11828
  assertRemoteSources(remoteSources, required);
11752
11829
  for (const artifact of required) {
11753
11830
  if (Object.hasOwn(remoteSources, artifact.path)) continue;
11754
- const path = join29(planDir, ...artifact.path.split("/"));
11831
+ const path = join30(planDir, ...artifact.path.split("/"));
11755
11832
  if (!existsSync21(path) || statSync7(path).size !== artifact.sizeBytes) {
11756
11833
  throw new PlanV2IntegrityError(
11757
11834
  `materialized artifact missing or truncated: ${artifact.path}`
@@ -11767,7 +11844,7 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
11767
11844
  // src/services/distributed/planV2Execution.ts
11768
11845
  import { mkdtempSync, rmSync as rmSync12 } from "node:fs";
11769
11846
  import { tmpdir as tmpdir2 } from "node:os";
11770
- import { join as join32 } from "node:path";
11847
+ import { join as join33 } from "node:path";
11771
11848
 
11772
11849
  // src/services/distributed/assemble.ts
11773
11850
  import {
@@ -11784,7 +11861,7 @@ import {
11784
11861
  statSync as statSync8,
11785
11862
  writeFileSync as writeFileSync11
11786
11863
  } from "node:fs";
11787
- import { basename as basename6, dirname as dirname15, join as join30 } from "node:path";
11864
+ import { basename as basename6, dirname as dirname15, join as join31 } from "node:path";
11788
11865
  import {
11789
11866
  appendRateCapArgs as appendRateCapArgs2,
11790
11867
  appendRenderProvenanceArgs as appendRenderProvenanceArgs2,
@@ -11854,7 +11931,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
11854
11931
  };
11855
11932
  try {
11856
11933
  const videoSources = cfrEncoder ? [await reencodeCfr(ctx, chunkPaths, cfrEncoder)] : chunkPaths;
11857
- const finalPath = join30(workDir, `output.${format}`);
11934
+ const finalPath = join31(workDir, `output.${format}`);
11858
11935
  const audio = audioPath !== null && existsSync22(audioPath) ? audioPath : null;
11859
11936
  await writeJoined(ctx, videoSources, audio, finalPath);
11860
11937
  renameWithRetry11(finalPath, outputPath);
@@ -11883,8 +11960,8 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
11883
11960
  };
11884
11961
  }
11885
11962
  function readAssemblePlan(planDir, chunkPaths) {
11886
- const planJsonPath = join30(planDir, "plan.json");
11887
- const chunksJsonPath = join30(planDir, "meta", "chunks.json");
11963
+ const planJsonPath = join31(planDir, "plan.json");
11964
+ const chunksJsonPath = join31(planDir, "meta", "chunks.json");
11888
11965
  if (!existsSync22(planJsonPath)) {
11889
11966
  throw new Error(`[assemble] planDir missing plan.json: ${planJsonPath}`);
11890
11967
  }
@@ -11935,7 +12012,7 @@ function cfrEncodeArgs(inputArgs, encoder, fpsArg) {
11935
12012
  return args;
11936
12013
  }
11937
12014
  async function reencodeCfr(ctx, chunkPaths, encoder) {
11938
- const cfrOutputPath = join30(ctx.workDir, `cfr.${ctx.format}`);
12015
+ const cfrOutputPath = join31(ctx.workDir, `cfr.${ctx.format}`);
11939
12016
  const cfrArgs = cfrEncodeArgs(videoInputArgs(ctx, chunkPaths), encoder, ctx.fpsArg);
11940
12017
  appendRenderProvenanceArgs2(cfrArgs, cfrOutputPath);
11941
12018
  cfrArgs.push("-y", cfrOutputPath);
@@ -11962,7 +12039,7 @@ async function writeJoined(ctx, videoSources, audioPath, finalPath) {
11962
12039
  );
11963
12040
  return;
11964
12041
  }
11965
- const paddedAudioPath = join30(ctx.workDir, "audio-padded.m4a");
12042
+ const paddedAudioPath = join31(ctx.workDir, "audio-padded.m4a");
11966
12043
  const padTrimResult = await ctx.timed(
11967
12044
  "audioMs",
11968
12045
  () => padOrTrimAudioToVideoFrameCount({
@@ -12002,7 +12079,7 @@ async function writeJoined(ctx, videoSources, audioPath, finalPath) {
12002
12079
  }
12003
12080
  }
12004
12081
  function concatDemuxerInput(chunkPaths, workDir, fpsArg) {
12005
- const listPath = join30(workDir, "concat-list.txt");
12082
+ const listPath = join31(workDir, "concat-list.txt");
12006
12083
  const body = chunkPaths.map((path) => `file '${path.replace(/'/g, "'\\''")}'`).join("\n");
12007
12084
  writeFileSync11(listPath, `${body}
12008
12085
  `, "utf-8");
@@ -12040,11 +12117,11 @@ function stitchesSeparateAudio(planDir) {
12040
12117
  return lockedAudio(planDir).separateAudio === true;
12041
12118
  }
12042
12119
  function planFormat(planDir) {
12043
- const plan = JSON.parse(readFileSync11(join30(planDir, "plan.json"), "utf-8"));
12120
+ const plan = JSON.parse(readFileSync11(join31(planDir, "plan.json"), "utf-8"));
12044
12121
  return plan.dimensions.format;
12045
12122
  }
12046
12123
  function lockedAudio(planDir) {
12047
- const encoderJsonPath = join30(planDir, "meta", "encoder.json");
12124
+ const encoderJsonPath = join31(planDir, "meta", "encoder.json");
12048
12125
  if (!existsSync22(encoderJsonPath)) return {};
12049
12126
  return JSON.parse(readFileSync11(encoderJsonPath, "utf-8"));
12050
12127
  }
@@ -12054,7 +12131,7 @@ function readCfrEncoder(planDir, format) {
12054
12131
  `[assemble] cfr=true is only supported for format="mp4" (got "${format}"). Stream-copy paths for webm and mov already produce exact avg_frame_rate; cfr re-encode is not needed.`
12055
12132
  );
12056
12133
  }
12057
- const encoderJsonPath = join30(planDir, "meta", "encoder.json");
12134
+ const encoderJsonPath = join31(planDir, "meta", "encoder.json");
12058
12135
  if (!existsSync22(encoderJsonPath)) {
12059
12136
  throw new Error(`[assemble] planDir missing meta/encoder.json: ${encoderJsonPath}`);
12060
12137
  }
@@ -12081,8 +12158,8 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
12081
12158
  throw new Error(`[assemble] png-sequence chunk has no frames: ${chunkDir}`);
12082
12159
  }
12083
12160
  for (const frame of frames) {
12084
- const dst = join30(outputPath, formatExportFrameName(globalIdx, "png"));
12085
- cpSync3(join30(chunkDir, frame), dst);
12161
+ const dst = join31(outputPath, formatExportFrameName(globalIdx, "png"));
12162
+ cpSync3(join31(chunkDir, frame), dst);
12086
12163
  globalIdx += 1;
12087
12164
  }
12088
12165
  }
@@ -12092,13 +12169,13 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
12092
12169
  );
12093
12170
  }
12094
12171
  if (audioPath !== null && existsSync22(audioPath)) {
12095
- const sidecar = join30(outputPath, MIXED_AUDIO_FILENAME4);
12172
+ const sidecar = join31(outputPath, MIXED_AUDIO_FILENAME4);
12096
12173
  cpSync3(audioPath, sidecar);
12097
12174
  }
12098
12175
  let fileSize = 0;
12099
12176
  for (const name of readdirSync8(outputPath)) {
12100
12177
  try {
12101
- fileSize += statSync8(join30(outputPath, name)).size;
12178
+ fileSize += statSync8(join31(outputPath, name)).size;
12102
12179
  } catch {
12103
12180
  }
12104
12181
  }
@@ -12114,7 +12191,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
12114
12191
  import { randomBytes } from "node:crypto";
12115
12192
  import { existsSync as existsSync23, mkdirSync as mkdirSync14, readFileSync as readFileSync12, readdirSync as readdirSync9, rmSync as rmSync11, writeFileSync as writeFileSync12 } from "node:fs";
12116
12193
  import { cpus } from "node:os";
12117
- import { join as join31 } from "node:path";
12194
+ import { join as join32 } from "node:path";
12118
12195
  import {
12119
12196
  assertSwiftShader,
12120
12197
  BROWSER_GPU_NOT_SOFTWARE as BROWSER_GPU_NOT_SOFTWARE4,
@@ -12249,7 +12326,7 @@ function hashChunkOutput(outputPath, kind) {
12249
12326
  if (kind === "file") return sha256Hex(readFileSync12(outputPath));
12250
12327
  const entries = readdirSync9(outputPath).filter((name) => /\.(png|jpg|jpeg)$/i.test(name)).sort();
12251
12328
  const lines = entries.map(
12252
- (name) => `${name}\0${sha256Hex(readFileSync12(join31(outputPath, name)))}`
12329
+ (name) => `${name}\0${sha256Hex(readFileSync12(join32(outputPath, name)))}`
12253
12330
  );
12254
12331
  return sha256Hex(lines.join("\0"));
12255
12332
  }
@@ -12266,9 +12343,9 @@ function resolveLockedVp9CpuUsed(lockedEncoder) {
12266
12343
  async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
12267
12344
  const start = Date.now();
12268
12345
  const log = defaultLogger;
12269
- const planJsonPath = join31(planDir, "plan.json");
12270
- const encoderJsonPath = join31(planDir, "meta", "encoder.json");
12271
- const chunksJsonPath = join31(planDir, "meta", "chunks.json");
12346
+ const planJsonPath = join32(planDir, "plan.json");
12347
+ const encoderJsonPath = join32(planDir, "meta", "encoder.json");
12348
+ const chunksJsonPath = join32(planDir, "meta", "chunks.json");
12272
12349
  if (!existsSync23(planJsonPath)) {
12273
12350
  throw new RenderChunkValidationError(
12274
12351
  MISSING_PLAN_ARTIFACT,
@@ -12294,7 +12371,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
12294
12371
  }
12295
12372
  const encoder = JSON.parse(readFileSync12(encoderJsonPath, "utf-8"));
12296
12373
  const chunks = JSON.parse(readFileSync12(chunksJsonPath, "utf-8"));
12297
- const videosJsonPath = join31(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
12374
+ const videosJsonPath = join32(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
12298
12375
  let planVideos = null;
12299
12376
  if (existsSync23(videosJsonPath)) {
12300
12377
  try {
@@ -12326,7 +12403,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
12326
12403
  }
12327
12404
  const range = resolveChunkFrameRange(slice, chunkIndex, options?.frameRange);
12328
12405
  const framesInChunk = range.endFrame - range.startFrame;
12329
- const compiledDir = join31(planDir, "compiled");
12406
+ const compiledDir = join32(planDir, "compiled");
12330
12407
  if (!existsSync23(compiledDir)) {
12331
12408
  throw new RenderChunkValidationError(
12332
12409
  MISSING_PLAN_ARTIFACT,
@@ -12385,7 +12462,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
12385
12462
  };
12386
12463
  const workDir = `${outputChunkPath}.work.${process.pid}.${randomBytes(4).toString("hex")}`;
12387
12464
  mkdirSync14(workDir, { recursive: true });
12388
- const framesDir = join31(workDir, "captured-frames");
12465
+ const framesDir = join32(workDir, "captured-frames");
12389
12466
  mkdirSync14(framesDir, { recursive: true });
12390
12467
  const videoFramesDir = `${workDir}.video-frames`;
12391
12468
  const chunkFrameNumbers = Array.from({ length: framesInChunk }, (_, i) => range.startFrame + i);
@@ -12410,7 +12487,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
12410
12487
  dimensions: plan.dimensions,
12411
12488
  encoder,
12412
12489
  videoCount: planVideos?.videos.length ?? 0,
12413
- html: readFileSync12(join31(compiledDir, "index.html"), "utf-8"),
12490
+ html: readFileSync12(join32(compiledDir, "index.html"), "utf-8"),
12414
12491
  // The plan ships a deferred source only to chunks that show it; don't wait on the rest.
12415
12492
  skipReadinessVideoIds: deferredVideos.filter(
12416
12493
  (video) => !shownFrames.get(video.videoId)?.size || remoteVideoIds.has(video.videoId)
@@ -12581,7 +12658,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
12581
12658
  if (isPngSequence) {
12582
12659
  if (!existsSync23(outputChunkPath)) mkdirSync14(outputChunkPath, { recursive: true });
12583
12660
  } else {
12584
- const outDir = join31(outputChunkPath, "..");
12661
+ const outDir = join32(outputChunkPath, "..");
12585
12662
  if (!existsSync23(outDir)) mkdirSync14(outDir, { recursive: true });
12586
12663
  }
12587
12664
  const encodeInput = {
@@ -12825,8 +12902,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
12825
12902
 
12826
12903
  // src/services/distributed/planV2Execution.ts
12827
12904
  async function renderChunkV2(planV2Dir, chunkIndex, outputChunkPath, options) {
12828
- const workRoot = mkdtempSync(join32(tmpdir2(), "hf-plan-v2-chunk-"));
12829
- const materializedPlanDir = join32(workRoot, "plan");
12905
+ const workRoot = mkdtempSync(join33(tmpdir2(), "hf-plan-v2-chunk-"));
12906
+ const materializedPlanDir = join33(workRoot, "plan");
12830
12907
  try {
12831
12908
  materializePlanV2Target(planV2Dir, { role: "chunk", chunkIndex }, materializedPlanDir);
12832
12909
  return await renderChunk(materializedPlanDir, chunkIndex, outputChunkPath, options);
@@ -12835,8 +12912,8 @@ async function renderChunkV2(planV2Dir, chunkIndex, outputChunkPath, options) {
12835
12912
  }
12836
12913
  }
12837
12914
  async function assembleV2(planV2Dir, chunkPaths, outputPath, options) {
12838
- const workRoot = mkdtempSync(join32(tmpdir2(), "hf-plan-v2-assembler-"));
12839
- const materializedPlanDir = join32(workRoot, "plan");
12915
+ const workRoot = mkdtempSync(join33(tmpdir2(), "hf-plan-v2-assembler-"));
12916
+ const materializedPlanDir = join33(workRoot, "plan");
12840
12917
  try {
12841
12918
  const materialized = materializePlanV2Target(
12842
12919
  planV2Dir,
@@ -13152,7 +13229,7 @@ function validateIntDimension(field, value) {
13152
13229
  // src/services/distributed/projectHash.ts
13153
13230
  import { closeSync as closeSync5, openSync as openSync5, readdirSync as readdirSync10, readSync as readSync4, realpathSync as realpathSync2, statSync as statSync9 } from "node:fs";
13154
13231
  import { createHash as createHash9 } from "node:crypto";
13155
- import { join as join33 } from "node:path";
13232
+ import { join as join34 } from "node:path";
13156
13233
  var SITE_ID_SCHEME = "site-v2\0";
13157
13234
  var READ_CHUNK_BYTES = 256 * 1024;
13158
13235
  var ENV_FILE = /^\.env([._-].*|rc)?$/i;
@@ -13163,7 +13240,7 @@ function listSiteFiles(projectDir) {
13163
13240
  function walk(dir, rel) {
13164
13241
  for (const name of readdirSync10(dir).sort()) {
13165
13242
  if (leftOut(rel, name)) continue;
13166
- const full = join33(dir, name);
13243
+ const full = join34(dir, name);
13167
13244
  const relPath = rel === "" ? name : `${rel}/${name}`;
13168
13245
  let stat;
13169
13246
  try {
@@ -13193,7 +13270,7 @@ function hashProjectDir(projectDir, files = listSiteFiles(projectDir)) {
13193
13270
  for (const rel of files) {
13194
13271
  hash.update(rel);
13195
13272
  hash.update("\0");
13196
- const fd = openSync5(join33(projectDir, rel), "r");
13273
+ const fd = openSync5(join34(projectDir, rel), "r");
13197
13274
  try {
13198
13275
  let read;
13199
13276
  while ((read = readSync4(fd, chunk, 0, chunk.length, null)) > 0) {