@hyperframes/producer 0.9.37 → 0.9.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/distributed.js +286 -209
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +64 -64
- package/dist/index.js +326 -247
- package/dist/public-server.js +197 -121
- package/dist/regression-harness-distributed.d.ts +1 -0
- package/dist/regression-harness.d.ts +2 -0
- package/dist/renderRequest.d.ts +1 -0
- package/dist/services/animatedGifPrep.d.ts +2 -1
- package/dist/services/assetMediaType.d.ts +12 -0
- package/dist/services/distributed/plan.d.ts +3 -1
- package/dist/services/distributed/renderSpan.d.ts +3 -1
- package/dist/services/distributed/shared.d.ts +1 -0
- package/dist/services/fileServer.d.ts +2 -0
- package/dist/services/heifImagePrep.d.ts +1 -0
- package/dist/services/htmlCompiler.d.ts +3 -1
- package/dist/services/render/stages/compileStage.d.ts +1 -0
- package/dist/services/renderOrchestrator.d.ts +2 -0
- package/dist/utils/paths.d.ts +2 -0
- package/package.json +7 -7
package/dist/public-server.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
rmSync as rmSync13,
|
|
11
11
|
createReadStream as createReadStream3
|
|
12
12
|
} from "node:fs";
|
|
13
|
-
import { resolve as resolve10, dirname as dirname16, join as
|
|
13
|
+
import { resolve as resolve10, dirname as dirname16, join as join37 } from "node:path";
|
|
14
14
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
15
15
|
import { parseArgs } from "node:util";
|
|
16
16
|
import crypto from "node:crypto";
|
|
@@ -84,7 +84,7 @@ import {
|
|
|
84
84
|
referenceBackgroundResult,
|
|
85
85
|
createReferenceBackgroundRecorder
|
|
86
86
|
} from "@hyperframes/engine";
|
|
87
|
-
import { join as
|
|
87
|
+
import { join as join32, dirname as dirname13, resolve as resolve8 } from "path";
|
|
88
88
|
import { totalmem as totalmem2 } from "node:os";
|
|
89
89
|
import { randomUUID } from "crypto";
|
|
90
90
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
@@ -773,7 +773,13 @@ function openRegularFile(filePath) {
|
|
|
773
773
|
}
|
|
774
774
|
}
|
|
775
775
|
function createFileServer(options) {
|
|
776
|
-
const {
|
|
776
|
+
const {
|
|
777
|
+
projectDir,
|
|
778
|
+
compiledDir,
|
|
779
|
+
port = 0,
|
|
780
|
+
stripEmbeddedRuntime = true,
|
|
781
|
+
allowOutsideProjectAssets = false
|
|
782
|
+
} = options;
|
|
777
783
|
const preHeadScripts = [
|
|
778
784
|
HF_EARLY_STUB,
|
|
779
785
|
RENDER_CAPTURE_MODE_SHIM,
|
|
@@ -795,7 +801,8 @@ function createFileServer(options) {
|
|
|
795
801
|
let file = null;
|
|
796
802
|
for (const root of compiledDir ? [compiledDir, projectDir] : [projectDir]) {
|
|
797
803
|
const candidate = join(root, relativePath);
|
|
798
|
-
|
|
804
|
+
const resolveSymlinks = !allowOutsideProjectAssets && root !== compiledDir;
|
|
805
|
+
if (isPathInside(candidate, root, { resolveSymlinks })) file = openRegularFile(candidate);
|
|
799
806
|
if (file) break;
|
|
800
807
|
}
|
|
801
808
|
if (!file) {
|
|
@@ -1051,6 +1058,7 @@ import {
|
|
|
1051
1058
|
isAbsolute as nodeIsAbsolute
|
|
1052
1059
|
} from "node:path";
|
|
1053
1060
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
1061
|
+
import { isSafePath } from "@hyperframes/core/safe-path";
|
|
1054
1062
|
var DEFAULT_RENDERS_DIR = process.env.PRODUCER_RENDERS_DIR ?? // fileURLToPath (not URL.pathname): on Windows .pathname is "/D:/..." which
|
|
1055
1063
|
// resolves to a bogus renders dir.
|
|
1056
1064
|
nodeResolve(fileURLToPath2(import.meta.url), "../../..", "renders");
|
|
@@ -1065,6 +1073,9 @@ function isPathInside2(childPath, parentPath, options = {}) {
|
|
|
1065
1073
|
const rel = relativePath(absParent, absChild);
|
|
1066
1074
|
return rel !== "" && !LEADING_PARENT_SEGMENT_RE.test(rel) && !isPathAbsolute(rel);
|
|
1067
1075
|
}
|
|
1076
|
+
function escapesAssetRoot(path, assetRoot) {
|
|
1077
|
+
return assetRoot !== void 0 && !isSafePath(assetRoot, path);
|
|
1078
|
+
}
|
|
1068
1079
|
function toExternalAssetKey(absPath) {
|
|
1069
1080
|
if (absPath.startsWith("hf-ext/")) return absPath;
|
|
1070
1081
|
let normalised = absPath.replace(/\\/g, "/");
|
|
@@ -6404,7 +6415,7 @@ function countAuthoredTimedClips(html) {
|
|
|
6404
6415
|
|
|
6405
6416
|
// src/services/render/stages/compileStage.ts
|
|
6406
6417
|
import { existsSync as existsSync12, writeFileSync as writeFileSync5 } from "node:fs";
|
|
6407
|
-
import { join as
|
|
6418
|
+
import { join as join20, relative as relative3 } from "node:path";
|
|
6408
6419
|
import { suggestMatchingPreset } from "@hyperframes/core";
|
|
6409
6420
|
import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
|
|
6410
6421
|
import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolution";
|
|
@@ -6413,7 +6424,7 @@ import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolu
|
|
|
6413
6424
|
import { decodedUrlPath } from "@hyperframes/parsers/asset-paths";
|
|
6414
6425
|
import { createHash as createHash6 } from "node:crypto";
|
|
6415
6426
|
import { createReadStream as createReadStream2, existsSync as existsSync11, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
|
|
6416
|
-
import { join as
|
|
6427
|
+
import { join as join19, dirname as dirname8, resolve as resolve7, basename as basename5, relative as relative2, sep as sep2 } from "path";
|
|
6417
6428
|
import { parseHTML as parseHTML5 } from "linkedom";
|
|
6418
6429
|
|
|
6419
6430
|
// src/services/bundledScripts.ts
|
|
@@ -6725,7 +6736,8 @@ function resolveLocalImageSourcePath(src, options) {
|
|
|
6725
6736
|
...protocolRelativeUrlOnShare ? [] : [isAbsolute2(basePath) ? basePath : resolve5(options.projectDir, projectRelative)],
|
|
6726
6737
|
resolve5(options.downloadDir, normalizedBase)
|
|
6727
6738
|
];
|
|
6728
|
-
|
|
6739
|
+
const allowed = (candidate) => !escapesAssetRoot(candidate, options.assetRoot) || !escapesAssetRoot(candidate, options.downloadDir);
|
|
6740
|
+
return candidates.find((candidate) => existsSync9(candidate) && allowed(candidate)) ?? null;
|
|
6729
6741
|
}
|
|
6730
6742
|
function isUsableFile(path) {
|
|
6731
6743
|
try {
|
|
@@ -7315,6 +7327,7 @@ import { getPositionEditsRenderScript } from "@hyperframes/core/runtime/position
|
|
|
7315
7327
|
|
|
7316
7328
|
// src/services/assetMediaType.ts
|
|
7317
7329
|
import { existsSync as existsSync10 } from "node:fs";
|
|
7330
|
+
import { join as join18 } from "node:path";
|
|
7318
7331
|
import {
|
|
7319
7332
|
fingerprintElementId,
|
|
7320
7333
|
isNotMediaPayload,
|
|
@@ -7361,6 +7374,21 @@ function assertAssetMediaTypeProfile(expected, profile, elementIdentity) {
|
|
|
7361
7374
|
function isRemoteOrInlineSource(src) {
|
|
7362
7375
|
return /^(?:https?:|data:|blob:|about:)/i.test(src.trim());
|
|
7363
7376
|
}
|
|
7377
|
+
function dropMediaOutsideProject(input) {
|
|
7378
|
+
const { projectDir, workDir, composition, log } = input;
|
|
7379
|
+
const compiledDir = join18(workDir, "compiled");
|
|
7380
|
+
const roots = [projectDir, compiledDir, join18(workDir, "downloads")];
|
|
7381
|
+
const staysInside = ({ id, src }) => {
|
|
7382
|
+
if (!src || isRemoteOrInlineSource(src)) return true;
|
|
7383
|
+
const path = resolveProjectRelativeSrc2(src, projectDir, compiledDir);
|
|
7384
|
+
if (roots.some((root) => !escapesAssetRoot(path, root))) return true;
|
|
7385
|
+
log.warn(`[Render] Media "${id}" source is missing: it is outside the project folder`, { src });
|
|
7386
|
+
return false;
|
|
7387
|
+
};
|
|
7388
|
+
composition.videos = composition.videos.filter(staysInside);
|
|
7389
|
+
composition.audios = composition.audios.filter(staysInside);
|
|
7390
|
+
composition.images = composition.images.filter(staysInside);
|
|
7391
|
+
}
|
|
7364
7392
|
async function preflightCompositionAssetMediaTypes(input) {
|
|
7365
7393
|
const references = [
|
|
7366
7394
|
...input.composition.videos.map((asset) => ({
|
|
@@ -7483,8 +7511,12 @@ function normalizeCompositionSrcs(html, projectDir) {
|
|
|
7483
7511
|
return `${name}${quote}${relative2(projectDir, file).split(sep2).join("/")}${quote}`;
|
|
7484
7512
|
});
|
|
7485
7513
|
}
|
|
7514
|
+
function resolveCompositionFile(projectDir, src, assetRoot) {
|
|
7515
|
+
const file = resolveCompositionSrc(projectDir, src);
|
|
7516
|
+
return file === null || escapesAssetRoot(file, assetRoot) ? null : file;
|
|
7517
|
+
}
|
|
7486
7518
|
var isPrivateCompositionFile = (projectDir, filePath) => isPrivateFileUnder(projectDir, filePath, isVcsOrSecretPath);
|
|
7487
|
-
function assertSubCompositionsUsable(html, projectDir, visited = /* @__PURE__ */ new Set()) {
|
|
7519
|
+
function assertSubCompositionsUsable(html, projectDir, assetRoot, visited = /* @__PURE__ */ new Set()) {
|
|
7488
7520
|
const { document: document2 } = parseHTML5(html);
|
|
7489
7521
|
const hosts = [...document2.querySelectorAll("[data-composition-src]")];
|
|
7490
7522
|
const problems = [];
|
|
@@ -7492,7 +7524,7 @@ function assertSubCompositionsUsable(html, projectDir, visited = /* @__PURE__ */
|
|
|
7492
7524
|
const srcPath = el.getAttribute("data-composition-src");
|
|
7493
7525
|
if (!srcPath) continue;
|
|
7494
7526
|
if (isUnresolvedAssetPlaceholder(srcPath)) continue;
|
|
7495
|
-
const filePath =
|
|
7527
|
+
const filePath = resolveCompositionFile(projectDir, srcPath, assetRoot);
|
|
7496
7528
|
if (filePath === null) {
|
|
7497
7529
|
problems.push({ srcPath, detail: "it is outside the project folder" });
|
|
7498
7530
|
continue;
|
|
@@ -7523,7 +7555,7 @@ function assertSubCompositionsUsable(html, projectDir, visited = /* @__PURE__ */
|
|
|
7523
7555
|
const nestedVisited = new Set(visited);
|
|
7524
7556
|
nestedVisited.add(filePath);
|
|
7525
7557
|
try {
|
|
7526
|
-
assertSubCompositionsUsable(fileHtml, projectDir, nestedVisited);
|
|
7558
|
+
assertSubCompositionsUsable(fileHtml, projectDir, assetRoot, nestedVisited);
|
|
7527
7559
|
} catch (err) {
|
|
7528
7560
|
if (err instanceof EmptyCompositionError) {
|
|
7529
7561
|
problems.push(...err.problems);
|
|
@@ -7642,10 +7674,10 @@ function detectShaderTransitionUsage(html) {
|
|
|
7642
7674
|
}
|
|
7643
7675
|
return false;
|
|
7644
7676
|
}
|
|
7645
|
-
async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, downloadDir, tagName, elementIdentity, log, urlByAbsentLocalPath, probes) {
|
|
7677
|
+
async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, downloadDir, tagName, elementIdentity, log, urlByAbsentLocalPath, probes, assetRoot) {
|
|
7646
7678
|
let filePath = src;
|
|
7647
7679
|
if (isHttpUrl(src)) {
|
|
7648
|
-
const remoteDir =
|
|
7680
|
+
const remoteDir = join19(downloadDir, REMOTE_MEDIA_SUBDIR);
|
|
7649
7681
|
if (!existsSync11(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
|
|
7650
7682
|
try {
|
|
7651
7683
|
filePath = await downloadToTemp(src, remoteDir, void 0, void 0, void 0, {
|
|
@@ -7656,7 +7688,8 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, down
|
|
|
7656
7688
|
}
|
|
7657
7689
|
} else {
|
|
7658
7690
|
filePath = decodedUrlPath(src);
|
|
7659
|
-
if (!filePath.startsWith("/")) filePath =
|
|
7691
|
+
if (!filePath.startsWith("/")) filePath = join19(baseDir, filePath);
|
|
7692
|
+
if (escapesAssetRoot(filePath, assetRoot)) return { duration: null, resolvedPath: filePath };
|
|
7660
7693
|
filePath = urlByAbsentLocalPath?.get(filePath) ?? filePath;
|
|
7661
7694
|
if (!isHttpUrl(filePath) && namesAnotherNetworkRoot2(baseDir, filePath)) {
|
|
7662
7695
|
return { duration: null, resolvedPath: filePath };
|
|
@@ -7732,7 +7765,7 @@ function markInferredVariableMediaDurations(html, unresolvedMedia) {
|
|
|
7732
7765
|
}
|
|
7733
7766
|
return changed ? document2.toString() : html;
|
|
7734
7767
|
}
|
|
7735
|
-
async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocalPath, probes) {
|
|
7768
|
+
async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocalPath, probes, assetRoot) {
|
|
7736
7769
|
const { html: staticCompiled, unresolved } = compileTimingAttrs(html);
|
|
7737
7770
|
const mediaUnresolved = unresolved.filter(
|
|
7738
7771
|
(el) => (el.tagName === "video" || el.tagName === "audio") && el.src
|
|
@@ -7750,7 +7783,8 @@ async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocal
|
|
|
7750
7783
|
el.id,
|
|
7751
7784
|
log,
|
|
7752
7785
|
urlByAbsentLocalPath,
|
|
7753
|
-
probes
|
|
7786
|
+
probes,
|
|
7787
|
+
assetRoot
|
|
7754
7788
|
).then(({ duration }) => ({ id: el.id, duration }))
|
|
7755
7789
|
)
|
|
7756
7790
|
);
|
|
@@ -7773,7 +7807,8 @@ async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocal
|
|
|
7773
7807
|
el.id,
|
|
7774
7808
|
log,
|
|
7775
7809
|
void 0,
|
|
7776
|
-
probes
|
|
7810
|
+
probes,
|
|
7811
|
+
assetRoot
|
|
7777
7812
|
);
|
|
7778
7813
|
return { id: el.id, tagName: el.tagName, duration: el.duration, maxDuration, src: el.src };
|
|
7779
7814
|
})
|
|
@@ -7795,7 +7830,7 @@ async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocal
|
|
|
7795
7830
|
compiledHtml = compiledHtml.replace(/(<audio\b[^>]*)\s+crossorigin(?:=["'][^"']*["'])?/gi, "$1");
|
|
7796
7831
|
return { html: compiledHtml, unresolvedCompositions };
|
|
7797
7832
|
}
|
|
7798
|
-
async function parseSubCompositions(html, projectDir, downloadDir, visited = /* @__PURE__ */ new Set(), urlByAbsentLocalPath, probes) {
|
|
7833
|
+
async function parseSubCompositions(html, projectDir, downloadDir, visited = /* @__PURE__ */ new Set(), urlByAbsentLocalPath, probes, assetRoot) {
|
|
7799
7834
|
const subCompositions = /* @__PURE__ */ new Map();
|
|
7800
7835
|
const { document: document2 } = parseHTML5(html);
|
|
7801
7836
|
const compEls = document2.querySelectorAll("[data-composition-src]");
|
|
@@ -7803,7 +7838,7 @@ async function parseSubCompositions(html, projectDir, downloadDir, visited = /*
|
|
|
7803
7838
|
for (const el of compEls) {
|
|
7804
7839
|
const srcPath = el.getAttribute("data-composition-src");
|
|
7805
7840
|
if (!srcPath) continue;
|
|
7806
|
-
const filePath =
|
|
7841
|
+
const filePath = resolveCompositionFile(projectDir, srcPath, assetRoot);
|
|
7807
7842
|
if (filePath === null || isPrivateCompositionFile(projectDir, filePath)) continue;
|
|
7808
7843
|
if (visited.has(filePath)) {
|
|
7809
7844
|
continue;
|
|
@@ -7825,7 +7860,8 @@ async function parseSubCompositions(html, projectDir, downloadDir, visited = /*
|
|
|
7825
7860
|
downloadDir,
|
|
7826
7861
|
void 0,
|
|
7827
7862
|
urlByAbsentLocalPath,
|
|
7828
|
-
probes
|
|
7863
|
+
probes,
|
|
7864
|
+
assetRoot
|
|
7829
7865
|
);
|
|
7830
7866
|
const nested = await parseSubCompositions(
|
|
7831
7867
|
compiledSub,
|
|
@@ -7833,7 +7869,8 @@ async function parseSubCompositions(html, projectDir, downloadDir, visited = /*
|
|
|
7833
7869
|
downloadDir,
|
|
7834
7870
|
item.nestedVisited,
|
|
7835
7871
|
urlByAbsentLocalPath,
|
|
7836
|
-
probes
|
|
7872
|
+
probes,
|
|
7873
|
+
assetRoot
|
|
7837
7874
|
);
|
|
7838
7875
|
return {
|
|
7839
7876
|
srcPath: item.srcPath,
|
|
@@ -7970,7 +8007,7 @@ function coalesceHeadStylesAndBodyScripts(html) {
|
|
|
7970
8007
|
}
|
|
7971
8008
|
return document2.toString();
|
|
7972
8009
|
}
|
|
7973
|
-
function inlineSubCompositions(html, subCompositions, projectDir, variableOverrides
|
|
8010
|
+
function inlineSubCompositions(html, subCompositions, projectDir, variableOverrides, assetRoot) {
|
|
7974
8011
|
const { document: document2 } = parseHTML5(html);
|
|
7975
8012
|
const head = document2.querySelector("head");
|
|
7976
8013
|
const body = document2.querySelector("body");
|
|
@@ -8000,7 +8037,7 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
|
|
|
8000
8037
|
resolveHtml: (srcPath) => {
|
|
8001
8038
|
let compHtml = subCompositions.get(srcPath) || null;
|
|
8002
8039
|
if (!compHtml) {
|
|
8003
|
-
const filePath =
|
|
8040
|
+
const filePath = resolveCompositionFile(projectDir, srcPath, assetRoot);
|
|
8004
8041
|
const read = filePath && !isPrivateCompositionFile(projectDir, filePath) ? readProjectFile(filePath) : null;
|
|
8005
8042
|
if (read?.kind === "file") {
|
|
8006
8043
|
compHtml = rewriteUnresolvableGsapToCdn(read.text, projectDir, srcPath);
|
|
@@ -8304,7 +8341,7 @@ async function localizeRemoteMediaSources(html, downloadDir) {
|
|
|
8304
8341
|
return downloadAndRewriteUrls(
|
|
8305
8342
|
urlSet,
|
|
8306
8343
|
html,
|
|
8307
|
-
|
|
8344
|
+
join19(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
8308
8345
|
"Remote media download failed",
|
|
8309
8346
|
"Localized remote media source(s)"
|
|
8310
8347
|
);
|
|
@@ -8319,7 +8356,7 @@ async function localizeRemoteImageSources(html, downloadDir) {
|
|
|
8319
8356
|
return downloadAndRewriteUrls(
|
|
8320
8357
|
urlSet,
|
|
8321
8358
|
html,
|
|
8322
|
-
|
|
8359
|
+
join19(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
8323
8360
|
"Remote image download failed",
|
|
8324
8361
|
"Localized remote image source(s)"
|
|
8325
8362
|
);
|
|
@@ -8335,7 +8372,7 @@ async function localizeRemoteBackgroundImages(html, downloadDir) {
|
|
|
8335
8372
|
return downloadAndRewriteUrls(
|
|
8336
8373
|
urlSet,
|
|
8337
8374
|
html,
|
|
8338
|
-
|
|
8375
|
+
join19(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
8339
8376
|
"Remote background-image download failed",
|
|
8340
8377
|
"Localized remote background-image(s)",
|
|
8341
8378
|
// Quoted url('..')/url("..") are rewritten by downloadAndRewriteUrls' default
|
|
@@ -8487,7 +8524,7 @@ function localizeFontFaceUrls(html, downloadDir) {
|
|
|
8487
8524
|
return downloadAndRewriteUrls(
|
|
8488
8525
|
collectFontFaceUrls(html),
|
|
8489
8526
|
html,
|
|
8490
|
-
|
|
8527
|
+
join19(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
8491
8528
|
"Remote font download failed",
|
|
8492
8529
|
"Localized remote font face(s)",
|
|
8493
8530
|
(h, url, relPath) => h.replaceAll(`url(${url})`, `url("${relPath}")`)
|
|
@@ -8512,7 +8549,7 @@ async function readLocalFont(absPath) {
|
|
|
8512
8549
|
}
|
|
8513
8550
|
return { kind: "inline", buffer: Buffer.concat(chunks, totalBytes) };
|
|
8514
8551
|
}
|
|
8515
|
-
async function embedLocalFontFaces(html, projectDir) {
|
|
8552
|
+
async function embedLocalFontFaces(html, projectDir, assetRoot) {
|
|
8516
8553
|
const { fontToDataUri: toDataUri } = await import("@hyperframes/core/fonts/embed");
|
|
8517
8554
|
const styleBlockRe = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
|
|
8518
8555
|
const fontFaceRe = /@font-face\s*\{([^}]*)\}/gi;
|
|
@@ -8533,7 +8570,7 @@ async function embedLocalFontFaces(html, projectDir) {
|
|
|
8533
8570
|
const localPath = urlMatch[1];
|
|
8534
8571
|
if (!localPath || embeddedPaths.has(localPath)) continue;
|
|
8535
8572
|
const absPath = localPath.startsWith("/") ? localPath : resolve7(projectDir, localPath);
|
|
8536
|
-
if (!isPathInside2(absPath, projectDir)) continue;
|
|
8573
|
+
if (!isPathInside2(absPath, projectDir) || escapesAssetRoot(absPath, assetRoot)) continue;
|
|
8537
8574
|
const ext = absPath.match(/\.(woff2?|ttf|otf|ttc)$/i)?.[1]?.toLowerCase() ?? "ttf";
|
|
8538
8575
|
try {
|
|
8539
8576
|
if (fileBackedAbsolutePaths.has(absPath)) {
|
|
@@ -8640,12 +8677,16 @@ function bindVariableMediaSources(html, variables) {
|
|
|
8640
8677
|
return changed ? document2.toString() : html;
|
|
8641
8678
|
}
|
|
8642
8679
|
async function compileForRender(projectDir, htmlPath, downloadDir, options = {}) {
|
|
8680
|
+
const assetRoot = options.allowOutsideProjectAssets ? void 0 : projectDir;
|
|
8681
|
+
if (isPathInside2(htmlPath, projectDir) && escapesAssetRoot(htmlPath, assetRoot)) {
|
|
8682
|
+
throw new Error(`Entry file ${htmlPath} leads outside the project folder`);
|
|
8683
|
+
}
|
|
8643
8684
|
const entryHtml = rebaseDirectEntryAssetPaths(readTextFile(htmlPath), projectDir, htmlPath);
|
|
8644
8685
|
const rawHtml = bindVariableMediaSources(
|
|
8645
8686
|
normalizeCompositionSrcs(rewriteUnresolvableGsapToCdn(entryHtml, projectDir), projectDir),
|
|
8646
8687
|
options.variables ?? {}
|
|
8647
8688
|
);
|
|
8648
|
-
assertSubCompositionsUsable(rawHtml, projectDir);
|
|
8689
|
+
assertSubCompositionsUsable(rawHtml, projectDir, assetRoot);
|
|
8649
8690
|
const probes = /* @__PURE__ */ new Map();
|
|
8650
8691
|
const { html: compiledHtml, unresolvedCompositions } = await compileHtmlFile(
|
|
8651
8692
|
rawHtml,
|
|
@@ -8653,7 +8694,8 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
8653
8694
|
downloadDir,
|
|
8654
8695
|
options.log,
|
|
8655
8696
|
options.urlByAbsentLocalPath,
|
|
8656
|
-
probes
|
|
8697
|
+
probes,
|
|
8698
|
+
assetRoot
|
|
8657
8699
|
);
|
|
8658
8700
|
const { subCompositions } = await parseSubCompositions(
|
|
8659
8701
|
compiledHtml,
|
|
@@ -8661,14 +8703,16 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
8661
8703
|
downloadDir,
|
|
8662
8704
|
void 0,
|
|
8663
8705
|
options.urlByAbsentLocalPath,
|
|
8664
|
-
probes
|
|
8706
|
+
probes,
|
|
8707
|
+
assetRoot
|
|
8665
8708
|
);
|
|
8666
8709
|
const fullHtml = ensureFullDocument(compiledHtml);
|
|
8667
8710
|
const inlinedHtml = inlineSubCompositions(
|
|
8668
8711
|
fullHtml,
|
|
8669
8712
|
subCompositions,
|
|
8670
8713
|
projectDir,
|
|
8671
|
-
options.variables ?? {}
|
|
8714
|
+
options.variables ?? {},
|
|
8715
|
+
assetRoot
|
|
8672
8716
|
);
|
|
8673
8717
|
const sanitizedHtml = inlinedHtml.replace(
|
|
8674
8718
|
/(<(?:video|audio)\b[^>]*?)\s+preload\s*=\s*["']none["']/gi,
|
|
@@ -8724,7 +8768,8 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
8724
8768
|
downloadDir,
|
|
8725
8769
|
cacheDir: options.animatedGifCacheDir,
|
|
8726
8770
|
sourceAssets: remoteImageAssets,
|
|
8727
|
-
timeoutMs: options.ffmpegProcessTimeout
|
|
8771
|
+
timeoutMs: options.ffmpegProcessTimeout,
|
|
8772
|
+
assetRoot
|
|
8728
8773
|
});
|
|
8729
8774
|
if (preparedHeifImages.length > 0) {
|
|
8730
8775
|
defaultLogger.debug(`[Compiler] Converted ${preparedHeifImages.length} HEIC image(s) to JPEG`);
|
|
@@ -8739,13 +8784,14 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
8739
8784
|
downloadDir,
|
|
8740
8785
|
cacheDir: options.animatedGifCacheDir,
|
|
8741
8786
|
sourceAssets: gifSourceAssets,
|
|
8742
|
-
timeoutMs: options.ffmpegProcessTimeout
|
|
8787
|
+
timeoutMs: options.ffmpegProcessTimeout,
|
|
8788
|
+
assetRoot
|
|
8743
8789
|
});
|
|
8744
8790
|
if (preparedGifs.length > 0) {
|
|
8745
8791
|
defaultLogger.debug(`[Compiler] Prepared ${preparedGifs.length} animated GIF input(s) as WebM`);
|
|
8746
8792
|
}
|
|
8747
|
-
const embeddedHtml = await embedLocalFontFaces(htmlWithPreparedGifs, projectDir);
|
|
8748
|
-
const { html, externalAssets } = collectExternalAssets(embeddedHtml, projectDir);
|
|
8793
|
+
const embeddedHtml = await embedLocalFontFaces(htmlWithPreparedGifs, projectDir, assetRoot);
|
|
8794
|
+
const { html, externalAssets } = options.allowOutsideProjectAssets ? collectExternalAssets(embeddedHtml, projectDir) : { html: embeddedHtml, externalAssets: /* @__PURE__ */ new Map() };
|
|
8749
8795
|
for (const [relPath, absPath] of remoteMediaAssets) {
|
|
8750
8796
|
externalAssets.set(relPath, absPath);
|
|
8751
8797
|
}
|
|
@@ -8770,7 +8816,8 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
8770
8816
|
for (const video of videos) {
|
|
8771
8817
|
if (isHttpUrl(video.src)) continue;
|
|
8772
8818
|
const videoPath = resolve7(projectDir, video.src);
|
|
8773
|
-
if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath))
|
|
8819
|
+
if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath) || !existsSync11(videoPath) || escapesAssetRoot(videoPath, assetRoot))
|
|
8820
|
+
continue;
|
|
8774
8821
|
advised.add(videoPath);
|
|
8775
8822
|
const reencode = `ffmpeg -i "${video.src}" -c:v libx264 -r 30 -g 30 -keyint_min 30 -movflags +faststart -c:a copy output.mp4`;
|
|
8776
8823
|
(async () => {
|
|
@@ -9149,10 +9196,18 @@ async function resolveCompositionDurations(page, unresolved) {
|
|
|
9149
9196
|
}
|
|
9150
9197
|
return resolutions;
|
|
9151
9198
|
}
|
|
9152
|
-
async function recompileWithResolutions(compiled, resolutions, projectDir, downloadDir) {
|
|
9199
|
+
async function recompileWithResolutions(compiled, resolutions, projectDir, downloadDir, assetRoot) {
|
|
9153
9200
|
if (resolutions.length === 0) return compiled;
|
|
9154
9201
|
const html = injectDurations(compiled.html, resolutions);
|
|
9155
|
-
const { subCompositions } = await parseSubCompositions(
|
|
9202
|
+
const { subCompositions } = await parseSubCompositions(
|
|
9203
|
+
html,
|
|
9204
|
+
projectDir,
|
|
9205
|
+
downloadDir,
|
|
9206
|
+
void 0,
|
|
9207
|
+
void 0,
|
|
9208
|
+
void 0,
|
|
9209
|
+
assetRoot
|
|
9210
|
+
);
|
|
9156
9211
|
const { videos, audios, images } = compiled;
|
|
9157
9212
|
const remaining = compiled.unresolvedCompositions.filter(
|
|
9158
9213
|
(c) => !resolutions.some((r) => r.id === c.id)
|
|
@@ -9185,17 +9240,25 @@ function adaptAspectAgnosticResolution(requested, aspectAgnostic, width, height,
|
|
|
9185
9240
|
}
|
|
9186
9241
|
function resolveEntryHtmlPath(input) {
|
|
9187
9242
|
const { projectDir, workDir, entryFile, log } = input;
|
|
9188
|
-
const
|
|
9189
|
-
|
|
9243
|
+
const readEntry = (path) => {
|
|
9244
|
+
if (escapesAssetRoot(path, input.assetRoot)) {
|
|
9245
|
+
throw new Error(
|
|
9246
|
+
`Entry file "${relative3(projectDir, path)}" leads outside the project folder`
|
|
9247
|
+
);
|
|
9248
|
+
}
|
|
9249
|
+
return readTextFile2(path);
|
|
9250
|
+
};
|
|
9251
|
+
const htmlPath = join20(projectDir, entryFile);
|
|
9252
|
+
const rawEntry = readEntry(htmlPath);
|
|
9190
9253
|
if (entryFile === "index.html" || !isTemplateEntry(rawEntry)) return htmlPath;
|
|
9191
|
-
const projectIndexPath =
|
|
9254
|
+
const projectIndexPath = join20(projectDir, "index.html");
|
|
9192
9255
|
if (!existsSync12(projectIndexPath)) {
|
|
9193
9256
|
throw new Error(
|
|
9194
9257
|
`Template entry file "${entryFile}" requires a project index.html to extract its render shell.`
|
|
9195
9258
|
);
|
|
9196
9259
|
}
|
|
9197
9260
|
const standaloneHtml = extractStandaloneEntryFromIndex(
|
|
9198
|
-
|
|
9261
|
+
readEntry(projectIndexPath),
|
|
9199
9262
|
entryFile,
|
|
9200
9263
|
rawEntry
|
|
9201
9264
|
);
|
|
@@ -9204,7 +9267,7 @@ function resolveEntryHtmlPath(input) {
|
|
|
9204
9267
|
`Entry file "${entryFile}" is not mounted from index.html via data-composition-src, so it cannot be rendered independently.`
|
|
9205
9268
|
);
|
|
9206
9269
|
}
|
|
9207
|
-
const wrapperPath =
|
|
9270
|
+
const wrapperPath = join20(workDir, "standalone-entry.html");
|
|
9208
9271
|
writeFileSync5(wrapperPath, standaloneHtml, "utf-8");
|
|
9209
9272
|
log.info("Extracted standalone entry from index.html host context", { entryFile });
|
|
9210
9273
|
return wrapperPath;
|
|
@@ -9231,9 +9294,10 @@ async function runCompileStage(input) {
|
|
|
9231
9294
|
allowSystemFontCapture,
|
|
9232
9295
|
abortSignal
|
|
9233
9296
|
} = input;
|
|
9234
|
-
const
|
|
9297
|
+
const assetRoot = job.config.allowOutsideProjectAssets ? void 0 : projectDir;
|
|
9298
|
+
const htmlPath = resolveEntryHtmlPath({ projectDir, workDir, entryFile, log, assetRoot });
|
|
9235
9299
|
const compileStart = Date.now();
|
|
9236
|
-
const compiled = await compileForRender(projectDir, htmlPath,
|
|
9300
|
+
const compiled = await compileForRender(projectDir, htmlPath, join20(workDir, "downloads"), {
|
|
9237
9301
|
log,
|
|
9238
9302
|
failClosedFontFetch: failClosedFontFetch === true,
|
|
9239
9303
|
allowSystemFontCapture,
|
|
@@ -9241,8 +9305,9 @@ async function runCompileStage(input) {
|
|
|
9241
9305
|
variables: input.variables,
|
|
9242
9306
|
urlByAbsentLocalPath: input.urlByAbsentLocalPath,
|
|
9243
9307
|
pageMotionBlur: input.pageMotionBlur,
|
|
9244
|
-
animatedGifCacheDir: cfg.extractCacheDir ?
|
|
9245
|
-
ffmpegProcessTimeout: cfg.ffmpegProcessTimeout
|
|
9308
|
+
animatedGifCacheDir: cfg.extractCacheDir ? join20(cfg.extractCacheDir, "animated-gif") : void 0,
|
|
9309
|
+
ffmpegProcessTimeout: cfg.ffmpegProcessTimeout,
|
|
9310
|
+
allowOutsideProjectAssets: job.config.allowOutsideProjectAssets
|
|
9246
9311
|
});
|
|
9247
9312
|
assertNotAborted();
|
|
9248
9313
|
const compileOnlyMs = Date.now() - compileStart;
|
|
@@ -9297,9 +9362,12 @@ async function runCompileStage(input) {
|
|
|
9297
9362
|
width: compiled.width,
|
|
9298
9363
|
height: compiled.height
|
|
9299
9364
|
};
|
|
9365
|
+
if (!job.config.allowOutsideProjectAssets) {
|
|
9366
|
+
dropMediaOutsideProject({ projectDir, workDir, composition, log });
|
|
9367
|
+
}
|
|
9300
9368
|
await preflightCompositionAssetMediaTypes({
|
|
9301
9369
|
projectDir,
|
|
9302
|
-
compiledDir:
|
|
9370
|
+
compiledDir: join20(workDir, "compiled"),
|
|
9303
9371
|
composition,
|
|
9304
9372
|
signal: abortSignal
|
|
9305
9373
|
});
|
|
@@ -9345,7 +9413,7 @@ async function runCompileStage(input) {
|
|
|
9345
9413
|
|
|
9346
9414
|
// src/services/render/stages/probeStage.ts
|
|
9347
9415
|
import { createHash as createHash7 } from "node:crypto";
|
|
9348
|
-
import { basename as basename6, join as
|
|
9416
|
+
import { basename as basename6, join as join21 } from "node:path";
|
|
9349
9417
|
import { parseHTML as parseHTML6 } from "linkedom";
|
|
9350
9418
|
import {
|
|
9351
9419
|
closeCaptureSession as closeCaptureSession4,
|
|
@@ -9571,10 +9639,11 @@ async function runProbeStage(input) {
|
|
|
9571
9639
|
});
|
|
9572
9640
|
fileServer = await createFileServer({
|
|
9573
9641
|
projectDir,
|
|
9574
|
-
compiledDir:
|
|
9642
|
+
compiledDir: join21(workDir, "compiled"),
|
|
9575
9643
|
port: 0,
|
|
9576
9644
|
preHeadScripts: [VIRTUAL_TIME_SHIM],
|
|
9577
|
-
fps: job.config.fps
|
|
9645
|
+
fps: job.config.fps,
|
|
9646
|
+
allowOutsideProjectAssets: job.config.allowOutsideProjectAssets
|
|
9578
9647
|
});
|
|
9579
9648
|
assertNotAborted();
|
|
9580
9649
|
const motionBlur = job.config.motionBlur;
|
|
@@ -9606,7 +9675,7 @@ async function runProbeStage(input) {
|
|
|
9606
9675
|
log.info("Creating capture session...", { attempt, maxAttempts: PROBE_MAX_ATTEMPTS });
|
|
9607
9676
|
probeSession = await createCaptureSession4(
|
|
9608
9677
|
fileServer.url,
|
|
9609
|
-
|
|
9678
|
+
join21(workDir, "probe"),
|
|
9610
9679
|
captureOpts,
|
|
9611
9680
|
null,
|
|
9612
9681
|
probeCfg
|
|
@@ -9691,7 +9760,7 @@ async function runProbeStage(input) {
|
|
|
9691
9760
|
});
|
|
9692
9761
|
probeSession = await createCaptureSession4(
|
|
9693
9762
|
fileServer.url,
|
|
9694
|
-
|
|
9763
|
+
join21(workDir, "probe-screenshot"),
|
|
9695
9764
|
captureOpts,
|
|
9696
9765
|
null,
|
|
9697
9766
|
{ ...probeCfg, forceScreenshot: true }
|
|
@@ -9729,7 +9798,8 @@ async function runProbeStage(input) {
|
|
|
9729
9798
|
compiled,
|
|
9730
9799
|
resolutions,
|
|
9731
9800
|
projectDir,
|
|
9732
|
-
|
|
9801
|
+
join21(workDir, "downloads"),
|
|
9802
|
+
job.config.allowOutsideProjectAssets ? void 0 : projectDir
|
|
9733
9803
|
);
|
|
9734
9804
|
assertNotAborted();
|
|
9735
9805
|
composition.videos = compiled.videos;
|
|
@@ -9918,9 +9988,12 @@ async function runProbeStage(input) {
|
|
|
9918
9988
|
}
|
|
9919
9989
|
}
|
|
9920
9990
|
}
|
|
9991
|
+
if (!job.config.allowOutsideProjectAssets) {
|
|
9992
|
+
dropMediaOutsideProject({ projectDir, workDir, composition, log });
|
|
9993
|
+
}
|
|
9921
9994
|
await preflightCompositionAssetMediaTypes({
|
|
9922
9995
|
projectDir,
|
|
9923
|
-
compiledDir:
|
|
9996
|
+
compiledDir: join21(workDir, "compiled"),
|
|
9924
9997
|
composition,
|
|
9925
9998
|
signal: abortSignal
|
|
9926
9999
|
});
|
|
@@ -10056,7 +10129,7 @@ function validateRenderDuration(input) {
|
|
|
10056
10129
|
|
|
10057
10130
|
// src/services/render/stages/extractVideosStage.ts
|
|
10058
10131
|
import { existsSync as existsSync13 } from "node:fs";
|
|
10059
|
-
import { join as
|
|
10132
|
+
import { join as join22 } from "node:path";
|
|
10060
10133
|
import {
|
|
10061
10134
|
classifyVideoExtractionError,
|
|
10062
10135
|
createFrameLookupTable as createFrameLookupTable3,
|
|
@@ -10397,14 +10470,14 @@ async function runExtractVideosStage(input) {
|
|
|
10397
10470
|
// because short boundary counts can differ by one frame.
|
|
10398
10471
|
{
|
|
10399
10472
|
fps: job.config.fps,
|
|
10400
|
-
outputDir:
|
|
10473
|
+
outputDir: join22(compiledDir, "__hyperframes_video_frames"),
|
|
10401
10474
|
format: job.config.videoFrameFormat ?? "auto",
|
|
10402
10475
|
toneMapHdrToSdr: rendersSdrOnly(job.config, composition),
|
|
10403
10476
|
timelineEnd: composition.duration,
|
|
10404
10477
|
maxTransientRetries: extractionPolicy.maxTransientRetries,
|
|
10405
10478
|
collectProbeFailures: extractionPolicy.failureMode === "enforce",
|
|
10406
10479
|
deferRangeExtraction,
|
|
10407
|
-
contentKeyedDirs: [
|
|
10480
|
+
contentKeyedDirs: [join22(compiledDir, REMOTE_MEDIA_SUBDIR)],
|
|
10408
10481
|
urlByAbsentLocalPath,
|
|
10409
10482
|
onProgress: ({ planned = 0, done = 0 }) => {
|
|
10410
10483
|
framesPlanned += planned;
|
|
@@ -10587,7 +10660,7 @@ async function planVideoLayerPassthrough(input) {
|
|
|
10587
10660
|
|
|
10588
10661
|
// src/services/render/stages/audioStage.ts
|
|
10589
10662
|
import { existsSync as existsSync16 } from "node:fs";
|
|
10590
|
-
import { join as
|
|
10663
|
+
import { join as join25 } from "node:path";
|
|
10591
10664
|
import {
|
|
10592
10665
|
MIXED_AUDIO_FILENAME,
|
|
10593
10666
|
audioFailureDiagnostics,
|
|
@@ -10598,7 +10671,7 @@ import {
|
|
|
10598
10671
|
|
|
10599
10672
|
// src/services/render/audioDeliveryLimit.ts
|
|
10600
10673
|
import { existsSync as existsSync15 } from "node:fs";
|
|
10601
|
-
import { dirname as dirname10, join as
|
|
10674
|
+
import { dirname as dirname10, join as join24 } from "node:path";
|
|
10602
10675
|
import {
|
|
10603
10676
|
applyAudioFxChain,
|
|
10604
10677
|
describeFfmpegFailure as describeFfmpegFailure3,
|
|
@@ -10608,7 +10681,7 @@ import {
|
|
|
10608
10681
|
|
|
10609
10682
|
// src/services/render/audioPadTrim.ts
|
|
10610
10683
|
import { spawn } from "node:child_process";
|
|
10611
|
-
import { dirname as dirname9, join as
|
|
10684
|
+
import { dirname as dirname9, join as join23 } from "node:path";
|
|
10612
10685
|
import {
|
|
10613
10686
|
DEFAULT_CONFIG,
|
|
10614
10687
|
describeFfmpegFailure as describeFfmpegFailure2,
|
|
@@ -10888,7 +10961,7 @@ async function constrainAacTruePeak(input) {
|
|
|
10888
10961
|
}
|
|
10889
10962
|
async function cutSource(input, scratchDir, attenuationDb) {
|
|
10890
10963
|
if (!input.sourcePath || !input.rewriteSource) return true;
|
|
10891
|
-
const cutPath =
|
|
10964
|
+
const cutPath = join23(scratchDir, "source.wav");
|
|
10892
10965
|
try {
|
|
10893
10966
|
const result = await input.rewriteSource(input.sourcePath, cutPath, gainFilter(attenuationDb));
|
|
10894
10967
|
if (!result.success) throw new Error(result.error);
|
|
@@ -10903,7 +10976,7 @@ async function enforceAacTruePeak(input) {
|
|
|
10903
10976
|
let scratchDir;
|
|
10904
10977
|
try {
|
|
10905
10978
|
scratchDir = createStagingDir3(dirname9(input.audioPath), ".true-peak-");
|
|
10906
|
-
const correctedPath =
|
|
10979
|
+
const correctedPath = join23(scratchDir, "audio.m4a");
|
|
10907
10980
|
const measurements = [];
|
|
10908
10981
|
let attenuationDb = 0;
|
|
10909
10982
|
let sourcePeakDbfs;
|
|
@@ -11113,7 +11186,7 @@ async function limitDeliveryPeaks(input, deps = {
|
|
|
11113
11186
|
const peak = await deps.measure(audioPath, { timeoutMs, signal });
|
|
11114
11187
|
if (peak <= AAC_DELIVERY_TRUE_PEAK_DBFS) return { success: true };
|
|
11115
11188
|
const alternating = ["a", "b"].map(
|
|
11116
|
-
(k) =>
|
|
11189
|
+
(k) => join24(dirname10(sourcePath), `audio-source-limited-${k}.wav`)
|
|
11117
11190
|
);
|
|
11118
11191
|
let encodedFrom;
|
|
11119
11192
|
let ceiling = AAC_DELIVERY_TRUE_PEAK_DBFS;
|
|
@@ -11185,7 +11258,7 @@ function runAudioStage(input) {
|
|
|
11185
11258
|
}
|
|
11186
11259
|
async function runAudioStageScoped(input) {
|
|
11187
11260
|
const stageStart = Date.now();
|
|
11188
|
-
const pcmSourcePath =
|
|
11261
|
+
const pcmSourcePath = join25(input.workDir, "audio-source.wav");
|
|
11189
11262
|
const duration = input.totalFrames * input.fps.den / input.fps.num;
|
|
11190
11263
|
let deliverySourcePath;
|
|
11191
11264
|
try {
|
|
@@ -11250,7 +11323,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
11250
11323
|
assertNotAborted,
|
|
11251
11324
|
log
|
|
11252
11325
|
} = input;
|
|
11253
|
-
const audioOutputPath =
|
|
11326
|
+
const audioOutputPath = join25(workDir, MIXED_AUDIO_FILENAME);
|
|
11254
11327
|
let hasAudio = false;
|
|
11255
11328
|
let audioError;
|
|
11256
11329
|
let audioFailures;
|
|
@@ -11261,7 +11334,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
11261
11334
|
audioResult = await processCompositionAudio(
|
|
11262
11335
|
audios,
|
|
11263
11336
|
projectDir,
|
|
11264
|
-
|
|
11337
|
+
join25(workDir, "audio-work"),
|
|
11265
11338
|
audioOutputPath,
|
|
11266
11339
|
duration,
|
|
11267
11340
|
abortSignal,
|
|
@@ -11330,7 +11403,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
11330
11403
|
|
|
11331
11404
|
// src/services/render/stages/captureStage.ts
|
|
11332
11405
|
import { existsSync as existsSync17, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
|
|
11333
|
-
import { join as
|
|
11406
|
+
import { join as join26 } from "node:path";
|
|
11334
11407
|
import {
|
|
11335
11408
|
classifyCaptureFailure as classifyCaptureFailure2,
|
|
11336
11409
|
frameFileExtension,
|
|
@@ -11403,13 +11476,13 @@ function measureCaptureFrameBytes(workDir, framesDir) {
|
|
|
11403
11476
|
if (!existsSync17(workDir)) return total;
|
|
11404
11477
|
for (const attempt of readdirSync4(workDir)) {
|
|
11405
11478
|
if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
|
|
11406
|
-
total += sampleDirectoryBytes(
|
|
11479
|
+
total += sampleDirectoryBytes(join26(workDir, attempt));
|
|
11407
11480
|
continue;
|
|
11408
11481
|
}
|
|
11409
11482
|
if (!/^capture-attempt-\d+$/.test(attempt)) continue;
|
|
11410
|
-
const attemptDir =
|
|
11483
|
+
const attemptDir = join26(workDir, attempt);
|
|
11411
11484
|
for (const name of readdirSync4(attemptDir)) {
|
|
11412
|
-
if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(
|
|
11485
|
+
if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join26(attemptDir, name));
|
|
11413
11486
|
}
|
|
11414
11487
|
}
|
|
11415
11488
|
return total;
|
|
@@ -11708,7 +11781,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
|
|
|
11708
11781
|
|
|
11709
11782
|
// src/services/render/stages/captureHdrStage.ts
|
|
11710
11783
|
import { existsSync as existsSync19, mkdirSync as mkdirSync10 } from "node:fs";
|
|
11711
|
-
import { join as
|
|
11784
|
+
import { join as join30 } from "node:path";
|
|
11712
11785
|
import {
|
|
11713
11786
|
closeCaptureSession as closeCaptureSession7,
|
|
11714
11787
|
cloneCaptureWarnings as cloneCaptureWarnings2,
|
|
@@ -11780,7 +11853,7 @@ function createHdrImageTransferCache(options = {}) {
|
|
|
11780
11853
|
}
|
|
11781
11854
|
|
|
11782
11855
|
// src/services/render/stages/captureHdrSequentialLoop.ts
|
|
11783
|
-
import { join as
|
|
11856
|
+
import { join as join27 } from "node:path";
|
|
11784
11857
|
import {
|
|
11785
11858
|
TRANSITIONS,
|
|
11786
11859
|
crossfade
|
|
@@ -11905,7 +11978,7 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
11905
11978
|
);
|
|
11906
11979
|
if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
|
|
11907
11980
|
writeFileExclusiveSync(
|
|
11908
|
-
|
|
11981
|
+
join27(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
|
|
11909
11982
|
normalCanvas
|
|
11910
11983
|
);
|
|
11911
11984
|
}
|
|
@@ -11937,7 +12010,7 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
11937
12010
|
}
|
|
11938
12011
|
|
|
11939
12012
|
// src/services/render/stages/captureHdrHybridLoop.ts
|
|
11940
|
-
import { join as
|
|
12013
|
+
import { join as join29 } from "node:path";
|
|
11941
12014
|
import {
|
|
11942
12015
|
TRANSITIONS as TRANSITIONS2,
|
|
11943
12016
|
closeCaptureSession as closeCaptureSession6,
|
|
@@ -11951,7 +12024,7 @@ import {
|
|
|
11951
12024
|
// src/services/shaderTransitionWorkerPool.ts
|
|
11952
12025
|
import { Worker } from "node:worker_threads";
|
|
11953
12026
|
import { fileURLToPath as fileURLToPath3, pathToFileURL } from "node:url";
|
|
11954
|
-
import { dirname as dirname11, join as
|
|
12027
|
+
import { dirname as dirname11, join as join28 } from "node:path";
|
|
11955
12028
|
import { createRequire } from "node:module";
|
|
11956
12029
|
import { existsSync as existsSync18 } from "node:fs";
|
|
11957
12030
|
import { cpus as cpus2 } from "node:os";
|
|
@@ -11965,9 +12038,9 @@ function resolveWorkerEntry(explicit) {
|
|
|
11965
12038
|
return { path: override, isTs };
|
|
11966
12039
|
}
|
|
11967
12040
|
const moduleDir = dirname11(fileURLToPath3(import.meta.url));
|
|
11968
|
-
const jsPath =
|
|
12041
|
+
const jsPath = join28(moduleDir, "shaderTransitionWorker.js");
|
|
11969
12042
|
if (existsSync18(jsPath)) return { path: jsPath, isTs: false };
|
|
11970
|
-
const tsPath =
|
|
12043
|
+
const tsPath = join28(moduleDir, "shaderTransitionWorker.ts");
|
|
11971
12044
|
return { path: tsPath, isTs: true };
|
|
11972
12045
|
}
|
|
11973
12046
|
function buildExecArgv(entryIsTs) {
|
|
@@ -12335,7 +12408,7 @@ async function runHybridLayeredFrameLoop(input) {
|
|
|
12335
12408
|
);
|
|
12336
12409
|
if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
|
|
12337
12410
|
writeFileExclusiveSync(
|
|
12338
|
-
|
|
12411
|
+
join29(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
|
|
12339
12412
|
canvas
|
|
12340
12413
|
);
|
|
12341
12414
|
}
|
|
@@ -12526,7 +12599,7 @@ async function runCaptureHdrStage(input) {
|
|
|
12526
12599
|
if (hdrVideoFrameSources.has(v.id)) hdrVideoEndTimes.set(v.id, v.end);
|
|
12527
12600
|
}
|
|
12528
12601
|
const debugDumpEnabled = process.env.KEEP_TEMP === "1";
|
|
12529
|
-
const debugDumpDir = debugDumpEnabled ?
|
|
12602
|
+
const debugDumpDir = debugDumpEnabled ? join30(framesDir, "debug-composite") : null;
|
|
12530
12603
|
if (debugDumpDir && !existsSync19(debugDumpDir)) {
|
|
12531
12604
|
mkdirSync10(debugDumpDir, { recursive: true });
|
|
12532
12605
|
}
|
|
@@ -12693,7 +12766,7 @@ import {
|
|
|
12693
12766
|
writeFileSync as writeFileSync6
|
|
12694
12767
|
} from "node:fs";
|
|
12695
12768
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
12696
|
-
import { dirname as dirname12, join as
|
|
12769
|
+
import { dirname as dirname12, join as join31 } from "node:path";
|
|
12697
12770
|
import {
|
|
12698
12771
|
encodeFramesChunkedConcat,
|
|
12699
12772
|
encodeFramesFromDir,
|
|
@@ -12904,7 +12977,7 @@ function encodeWhileCapturing(input, totalFrames) {
|
|
|
12904
12977
|
await new Promise((resolve11) => wake = resolve11);
|
|
12905
12978
|
}
|
|
12906
12979
|
if (signal.aborted) return;
|
|
12907
|
-
const mergedPath =
|
|
12980
|
+
const mergedPath = join31(input.framesDir, formatCaptureFrameName(next, "jpg"));
|
|
12908
12981
|
const frame = await readLandedFrame(landed.get(next), mergedPath);
|
|
12909
12982
|
landed.delete(next);
|
|
12910
12983
|
if (!await stream.writeFrame(frame)) {
|
|
@@ -12987,11 +13060,11 @@ async function runEncodeStage(input) {
|
|
|
12987
13060
|
);
|
|
12988
13061
|
}
|
|
12989
13062
|
captured.forEach((name, i) => {
|
|
12990
|
-
const dst =
|
|
12991
|
-
copyFileSync4(
|
|
13063
|
+
const dst = join31(outputPath, formatExportFrameName(i, "png"));
|
|
13064
|
+
copyFileSync4(join31(framesDir, name), dst);
|
|
12992
13065
|
});
|
|
12993
13066
|
if (hasAudio && audioOutputPath && existsSync20(audioOutputPath)) {
|
|
12994
|
-
copyFileSync4(audioOutputPath,
|
|
13067
|
+
copyFileSync4(audioOutputPath, join31(outputPath, MIXED_AUDIO_FILENAME2));
|
|
12995
13068
|
log.info(
|
|
12996
13069
|
`[Render] png-sequence: ${MIXED_AUDIO_FILENAME2} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME2}`
|
|
12997
13070
|
);
|
|
@@ -13011,7 +13084,7 @@ async function runEncodeStage(input) {
|
|
|
13011
13084
|
const encodeResult2 = await encodeGifFromDir(framesDir, framePattern2, outputPath, {
|
|
13012
13085
|
fps: job.config.fps,
|
|
13013
13086
|
loop,
|
|
13014
|
-
palettePath:
|
|
13087
|
+
palettePath: join31(dirname12(videoOnlyPath), "gif-palette.png"),
|
|
13015
13088
|
preserveAlpha: needsAlpha,
|
|
13016
13089
|
signal: abortSignal,
|
|
13017
13090
|
timeout: engineCfg.ffmpegEncodeTimeout
|
|
@@ -13222,7 +13295,7 @@ function sampleDirectoryBytes(dir) {
|
|
|
13222
13295
|
continue;
|
|
13223
13296
|
}
|
|
13224
13297
|
for (const name of entries) {
|
|
13225
|
-
const full =
|
|
13298
|
+
const full = join32(current, name);
|
|
13226
13299
|
try {
|
|
13227
13300
|
const st = statSync9(full);
|
|
13228
13301
|
if (st.isDirectory()) {
|
|
@@ -13378,7 +13451,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
13378
13451
|
const ranges = [];
|
|
13379
13452
|
let rangeStart = null;
|
|
13380
13453
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
13381
|
-
const framePath =
|
|
13454
|
+
const framePath = join32(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
13382
13455
|
const missing = !existsSync21(framePath) || statSync9(framePath).size <= 8;
|
|
13383
13456
|
if (missing && rangeStart === null) {
|
|
13384
13457
|
rangeStart = frameIndex;
|
|
@@ -13395,7 +13468,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
13395
13468
|
function buildMissingFrameRetryBatches(ranges, maxWorkers, workDir, attempt, rangeStart = 0, stride = 1) {
|
|
13396
13469
|
const workersPerBatch = Math.max(1, Math.floor(maxWorkers));
|
|
13397
13470
|
const batches = [];
|
|
13398
|
-
const outputDirFor = (batchIndex, workerId) =>
|
|
13471
|
+
const outputDirFor = (batchIndex, workerId) => join32(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
|
|
13399
13472
|
if (stride > 1) {
|
|
13400
13473
|
const spans = /* @__PURE__ */ new Map();
|
|
13401
13474
|
for (const range of ranges) {
|
|
@@ -13455,8 +13528,8 @@ function getNextRetryWorkerCount(currentWorkers) {
|
|
|
13455
13528
|
return Math.max(1, Math.floor(currentWorkers / 2));
|
|
13456
13529
|
}
|
|
13457
13530
|
function resolveRenderWorkDirPrefix(outputPath, jobId, platform2 = process.platform, systemTempDir = tmpdir2()) {
|
|
13458
|
-
if (platform2 === "win32" || platform2 === "darwin") return
|
|
13459
|
-
return
|
|
13531
|
+
if (platform2 === "win32" || platform2 === "darwin") return join32(systemTempDir, "hf-render-");
|
|
13532
|
+
return join32(dirname13(outputPath), `work-${jobId}-`);
|
|
13460
13533
|
}
|
|
13461
13534
|
var MAX_TRANSIENT_CAPTURE_RETRIES = 1;
|
|
13462
13535
|
function isTransientCaptureRetryEligible(failureKind, missing, retriesUsed) {
|
|
@@ -13511,7 +13584,7 @@ The composition is too large for the available memory. To reduce memory pressure
|
|
|
13511
13584
|
function countCapturedFrames(totalFrames, framesDir, frameExt) {
|
|
13512
13585
|
let captured = 0;
|
|
13513
13586
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
13514
|
-
const framePath =
|
|
13587
|
+
const framePath = join32(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
13515
13588
|
if (existsSync21(framePath)) captured++;
|
|
13516
13589
|
}
|
|
13517
13590
|
return captured;
|
|
@@ -13537,7 +13610,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
|
|
|
13537
13610
|
reason: attempt === 0 ? "initial" : pendingTransientRetry ? "transient-retry" : "retry"
|
|
13538
13611
|
});
|
|
13539
13612
|
pendingTransientRetry = false;
|
|
13540
|
-
const attemptWorkDir =
|
|
13613
|
+
const attemptWorkDir = join32(options.workDir, `capture-attempt-${attempt}`);
|
|
13541
13614
|
const batches = missingRanges ? buildMissingFrameRetryBatches(
|
|
13542
13615
|
missingRanges,
|
|
13543
13616
|
currentWorkers,
|
|
@@ -14170,7 +14243,7 @@ function deVerifyFallbackTelemetry(err) {
|
|
|
14170
14243
|
}
|
|
14171
14244
|
function resolveRenderDebugDir() {
|
|
14172
14245
|
const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve8(process.env.PRODUCER_RENDERS_DIR, "..") : resolve8(dirname13(fileURLToPath4(import.meta.url)), "../..");
|
|
14173
|
-
return
|
|
14246
|
+
return join32(producerRoot, ".debug");
|
|
14174
14247
|
}
|
|
14175
14248
|
async function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
|
|
14176
14249
|
validateHlsRenderConfig(job.config);
|
|
@@ -14179,10 +14252,10 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
|
|
|
14179
14252
|
const debugDir = resolveRenderDebugDir();
|
|
14180
14253
|
const outputDir = dirname13(outputPath);
|
|
14181
14254
|
if (!existsSync21(outputDir)) mkdirSync12(outputDir, { recursive: true });
|
|
14182
|
-
const workDir = job.config.debug ?
|
|
14255
|
+
const workDir = job.config.debug ? join32(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
|
|
14183
14256
|
const pipelineStart = Date.now();
|
|
14184
14257
|
const baseLog = job.config.logger ?? defaultLogger;
|
|
14185
|
-
const logPath = job.config.debug ?
|
|
14258
|
+
const logPath = job.config.debug ? join32(workDir, "render.log") : null;
|
|
14186
14259
|
const execution = new RenderExecutionContext({
|
|
14187
14260
|
request: { renderJobId: job.id, projectDir, outputPath },
|
|
14188
14261
|
logger: logPath ? createRenderFileLogger(logPath, baseLog) : baseLog,
|
|
@@ -14244,7 +14317,7 @@ async function executeRenderPipeline(input) {
|
|
|
14244
14317
|
imageDecodeFailures: 0
|
|
14245
14318
|
};
|
|
14246
14319
|
let hdrPerf;
|
|
14247
|
-
const perfOutputPath =
|
|
14320
|
+
const perfOutputPath = join32(workDir, "perf-summary.json");
|
|
14248
14321
|
const cfg = { ...job.config.producerConfig ?? resolveConfig2() };
|
|
14249
14322
|
const observability = new RenderObservabilityRecorder({
|
|
14250
14323
|
pipelineStartMs: pipelineStart,
|
|
@@ -14349,7 +14422,7 @@ async function executeRenderPipeline(input) {
|
|
|
14349
14422
|
requestedWorkers: job.config.workers ?? "auto"
|
|
14350
14423
|
});
|
|
14351
14424
|
const entryFile = job.config.entryFile || "index.html";
|
|
14352
|
-
const htmlPath =
|
|
14425
|
+
const htmlPath = join32(projectDir, entryFile);
|
|
14353
14426
|
if (!existsSync21(htmlPath)) {
|
|
14354
14427
|
throw new Error(`Entry file not found: ${htmlPath}`);
|
|
14355
14428
|
}
|
|
@@ -14529,7 +14602,7 @@ async function executeRenderPipeline(input) {
|
|
|
14529
14602
|
canvas: { width, height },
|
|
14530
14603
|
page: probeSession.page,
|
|
14531
14604
|
projectDir,
|
|
14532
|
-
compiledDir:
|
|
14605
|
+
compiledDir: join32(workDir, "compiled")
|
|
14533
14606
|
});
|
|
14534
14607
|
if (videoLayerPlan.videoId === void 0) {
|
|
14535
14608
|
log.info(`[Render] Video layer passthrough off: ${videoLayerPlan.reason}`);
|
|
@@ -14547,7 +14620,7 @@ async function executeRenderPipeline(input) {
|
|
|
14547
14620
|
updateJobStatus(job, "preprocessing", "Extracting video frames", 10, onProgress, {
|
|
14548
14621
|
code: "extract_video"
|
|
14549
14622
|
});
|
|
14550
|
-
const compiledDir =
|
|
14623
|
+
const compiledDir = join32(workDir, "compiled");
|
|
14551
14624
|
const segmentsCapture = (layeredOrEffectRoute) => shouldSegmentCapture({
|
|
14552
14625
|
env: process.env,
|
|
14553
14626
|
durationSeconds: probeResult.duration,
|
|
@@ -14678,10 +14751,11 @@ async function executeRenderPipeline(input) {
|
|
|
14678
14751
|
try {
|
|
14679
14752
|
fileServer = await createFileServer({
|
|
14680
14753
|
projectDir,
|
|
14681
|
-
compiledDir:
|
|
14754
|
+
compiledDir: join32(workDir, "compiled"),
|
|
14682
14755
|
port: 0,
|
|
14683
14756
|
preHeadScripts: [VIRTUAL_TIME_SHIM],
|
|
14684
|
-
fps: job.config.fps
|
|
14757
|
+
fps: job.config.fps,
|
|
14758
|
+
allowOutsideProjectAssets: job.config.allowOutsideProjectAssets
|
|
14685
14759
|
});
|
|
14686
14760
|
assertNotAborted();
|
|
14687
14761
|
observability.stageEnd("file_server", fileServerStart);
|
|
@@ -14696,7 +14770,7 @@ async function executeRenderPipeline(input) {
|
|
|
14696
14770
|
if (!activeFileServer) {
|
|
14697
14771
|
throw new Error("File server failed to initialize before frame capture");
|
|
14698
14772
|
}
|
|
14699
|
-
const framesDir =
|
|
14773
|
+
const framesDir = join32(workDir, "captured-frames");
|
|
14700
14774
|
if (!existsSync21(framesDir)) mkdirSync12(framesDir, { recursive: true });
|
|
14701
14775
|
updateJobStatus(job, "rendering", "Checking browser GPU", 25, onProgress, {
|
|
14702
14776
|
code: "start_browsers"
|
|
@@ -15275,7 +15349,7 @@ async function executeRenderPipeline(input) {
|
|
|
15275
15349
|
hls: ".mp4"
|
|
15276
15350
|
};
|
|
15277
15351
|
const videoExt = FORMAT_EXT[outputFormat] ?? ".mp4";
|
|
15278
|
-
const videoOnlyPath =
|
|
15352
|
+
const videoOnlyPath = join32(workDir, `video-only${videoExt}`);
|
|
15279
15353
|
const usePageSideCompositingForTransitions = (cfg.enablePageSideCompositing || isGif) && compiled.hasShaderTransitions && !hasHdrContent && outputSupportsPageSideShaderCompositing(outputFormat);
|
|
15280
15354
|
if (usePageSideCompositingForTransitions) {
|
|
15281
15355
|
activeFileServer.addPreHeadScript(HF_PAGE_SIDE_COMPOSITING_STUB);
|
|
@@ -15564,7 +15638,7 @@ async function executeRenderPipeline(input) {
|
|
|
15564
15638
|
pageMotionBlur: job.config.pageMotionBlur,
|
|
15565
15639
|
captureQuality: captureOptions.quality
|
|
15566
15640
|
});
|
|
15567
|
-
const segmentDir = segmentDirFor(
|
|
15641
|
+
const segmentDir = segmentDirFor(join32(projectDir, "renders"), segmentPlanHash);
|
|
15568
15642
|
let completedSegments = /* @__PURE__ */ new Set();
|
|
15569
15643
|
if (job.config.resumeSegments === true) {
|
|
15570
15644
|
const existing = readSegmentManifest(segmentDir);
|
|
@@ -16187,7 +16261,7 @@ async function executeRenderPipeline(input) {
|
|
|
16187
16261
|
}
|
|
16188
16262
|
if (job.config.debug) {
|
|
16189
16263
|
if (!isPngSequence && !isHls && existsSync21(stagedOutputPath)) {
|
|
16190
|
-
const debugOutput =
|
|
16264
|
+
const debugOutput = join32(workDir, `output${videoExt}`);
|
|
16191
16265
|
copyFileSync5(stagedOutputPath, debugOutput);
|
|
16192
16266
|
}
|
|
16193
16267
|
}
|
|
@@ -16306,7 +16380,7 @@ import {
|
|
|
16306
16380
|
closeSync as closeSync5,
|
|
16307
16381
|
constants as constants3
|
|
16308
16382
|
} from "node:fs";
|
|
16309
|
-
import { resolve as resolve9, join as
|
|
16383
|
+
import { resolve as resolve9, join as join33, relative as relative4, isAbsolute as isAbsolute3, sep as sep3 } from "node:path";
|
|
16310
16384
|
import { lintHyperframeHtml } from "@hyperframes/lint";
|
|
16311
16385
|
function isStringRecord(value) {
|
|
16312
16386
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
@@ -16360,7 +16434,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile) {
|
|
|
16360
16434
|
);
|
|
16361
16435
|
for (const entryFile of entryCandidates) {
|
|
16362
16436
|
const absoluteEntryPath = resolve9(absProjectDir, entryFile);
|
|
16363
|
-
const entryRelativePath =
|
|
16437
|
+
const entryRelativePath = relative4(absProjectDir, absoluteEntryPath);
|
|
16364
16438
|
if (entryRelativePath === ".." || entryRelativePath.startsWith(`..${sep3}`) || isAbsolute3(entryRelativePath)) {
|
|
16365
16439
|
return { error: `Entry file must stay inside project directory: ${entryFile}` };
|
|
16366
16440
|
}
|
|
@@ -16374,7 +16448,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile) {
|
|
|
16374
16448
|
}
|
|
16375
16449
|
}
|
|
16376
16450
|
return {
|
|
16377
|
-
error: `No HTML entry file found in project directory: ${
|
|
16451
|
+
error: `No HTML entry file found in project directory: ${join33(absProjectDir, preferredEntryFile || "index.html")}`
|
|
16378
16452
|
};
|
|
16379
16453
|
}
|
|
16380
16454
|
function prepareHyperframeLintBody(body) {
|
|
@@ -16420,7 +16494,7 @@ async function runHyperframeLint(prepared) {
|
|
|
16420
16494
|
// src/services/healthWorker.ts
|
|
16421
16495
|
import { Worker as Worker2 } from "node:worker_threads";
|
|
16422
16496
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
16423
|
-
import { dirname as dirname14, join as
|
|
16497
|
+
import { dirname as dirname14, join as join34 } from "node:path";
|
|
16424
16498
|
import { existsSync as existsSync23 } from "node:fs";
|
|
16425
16499
|
var DEFAULT_HEALTH_PORT = 9848;
|
|
16426
16500
|
async function startHealthWorker(options = {}) {
|
|
@@ -16496,7 +16570,7 @@ function defaultLogger2() {
|
|
|
16496
16570
|
}
|
|
16497
16571
|
function resolveWorkerEntry2() {
|
|
16498
16572
|
const here = dirname14(fileURLToPath5(import.meta.url));
|
|
16499
|
-
const candidates = [
|
|
16573
|
+
const candidates = [join34(here, "healthWorkerThread.js"), join34(here, "healthWorkerThread.ts")];
|
|
16500
16574
|
for (const candidate of candidates) {
|
|
16501
16575
|
if (existsSync23(candidate)) return candidate;
|
|
16502
16576
|
}
|
|
@@ -16538,11 +16612,12 @@ import {
|
|
|
16538
16612
|
createReferenceBackgroundRecorder as createReferenceBackgroundRecorder2
|
|
16539
16613
|
} from "@hyperframes/engine";
|
|
16540
16614
|
import { audioFailureDiagnostics as audioFailureDiagnostics3 } from "@hyperframes/engine";
|
|
16541
|
-
import { extname as extname4, isAbsolute as isAbsolute4, join as
|
|
16615
|
+
import { extname as extname4, isAbsolute as isAbsolute4, join as join36, relative as relative5, sep as sep4 } from "node:path";
|
|
16542
16616
|
import {
|
|
16543
16617
|
fpsToNumber as fpsToNumber9,
|
|
16544
16618
|
HF_COLOR_GRADING_ATTR as HF_COLOR_GRADING_ATTR2
|
|
16545
16619
|
} from "@hyperframes/core";
|
|
16620
|
+
import { isSafePath as isSafePath2 } from "@hyperframes/core/safe-path";
|
|
16546
16621
|
import {
|
|
16547
16622
|
getEncoderPreset as getEncoderPreset4,
|
|
16548
16623
|
keyframeIntervalToGopSize as keyframeIntervalToGopSize3,
|
|
@@ -16570,7 +16645,7 @@ import {
|
|
|
16570
16645
|
|
|
16571
16646
|
// src/services/distributed/shared.ts
|
|
16572
16647
|
import { execFile as execFileCallback } from "node:child_process";
|
|
16573
|
-
import { dirname as dirname15, join as
|
|
16648
|
+
import { dirname as dirname15, join as join35 } from "node:path";
|
|
16574
16649
|
import { existsSync as existsSync24, readFileSync as readFileSync11 } from "node:fs";
|
|
16575
16650
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
16576
16651
|
import { promisify as promisify2 } from "node:util";
|
|
@@ -16586,7 +16661,7 @@ function readProducerVersion() {
|
|
|
16586
16661
|
const startDir = dirname15(fileURLToPath6(import.meta.url));
|
|
16587
16662
|
let current = startDir;
|
|
16588
16663
|
for (let i = 0; i < 10; i++) {
|
|
16589
|
-
const candidate =
|
|
16664
|
+
const candidate = join35(current, "package.json");
|
|
16590
16665
|
if (existsSync24(candidate)) {
|
|
16591
16666
|
try {
|
|
16592
16667
|
const pkg = JSON.parse(readFileSync11(candidate, "utf-8"));
|
|
@@ -16684,9 +16759,9 @@ var PLAN_ROOT_CATEGORY = {
|
|
|
16684
16759
|
var PLAN_DIR_SIZE_LIMIT_BYTES = 2 * 1024 * 1024 * 1024;
|
|
16685
16760
|
var FREEZE_OWNED_PLAN_FILES = [
|
|
16686
16761
|
"plan.json",
|
|
16687
|
-
|
|
16688
|
-
|
|
16689
|
-
|
|
16762
|
+
join36("meta", "composition.json"),
|
|
16763
|
+
join36("meta", "encoder.json"),
|
|
16764
|
+
join36("meta", "chunks.json")
|
|
16690
16765
|
];
|
|
16691
16766
|
|
|
16692
16767
|
// src/services/distributed/renderConfigValidation.ts
|
|
@@ -16921,7 +16996,8 @@ function renderConfigFromRequest(request, runtime = {}) {
|
|
|
16921
16996
|
return {
|
|
16922
16997
|
...options,
|
|
16923
16998
|
producerConfig: engineConfig,
|
|
16924
|
-
logger: runtime.logger
|
|
16999
|
+
logger: runtime.logger,
|
|
17000
|
+
allowOutsideProjectAssets: runtime.allowOutsideProjectAssets === true
|
|
16925
17001
|
};
|
|
16926
17002
|
}
|
|
16927
17003
|
|
|
@@ -17182,8 +17258,8 @@ async function resolveInlineRenderHtml(body) {
|
|
|
17182
17258
|
}
|
|
17183
17259
|
function materializeInlineProject(html, options) {
|
|
17184
17260
|
const tempRoot = process.env.PRODUCER_TMP_PROJECT_DIR || tmpdir3();
|
|
17185
|
-
const tempProjectDir = mkdtempSync(
|
|
17186
|
-
writeFileSync8(
|
|
17261
|
+
const tempProjectDir = mkdtempSync(join37(tempRoot, "producer-project-"));
|
|
17262
|
+
writeFileSync8(join37(tempProjectDir, "index.html"), html, "utf-8");
|
|
17187
17263
|
return {
|
|
17188
17264
|
prepared: {
|
|
17189
17265
|
input: { projectDir: tempProjectDir, ...options },
|