@hyperframes/producer 0.9.59 → 0.9.63
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 +397 -155
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +67 -67
- package/dist/index.js +475 -203
- package/dist/public-server.js +429 -183
- package/dist/renderRequest.d.ts +3 -0
- package/dist/server.d.ts +2 -0
- package/dist/services/animatedGifPrep.d.ts +2 -2
- package/dist/services/compositionSizeLimit.d.ts +22 -0
- package/dist/services/distributed/plan.d.ts +6 -1
- package/dist/services/distributed/planV2.d.ts +1 -0
- package/dist/services/distributed/projectHash.d.ts +11 -7
- package/dist/services/distributed/renderConfigValidation.d.ts +0 -18
- package/dist/services/distributed/renderSpan.d.ts +1 -0
- package/dist/services/distributed/shared.d.ts +2 -0
- package/dist/services/fileServer.d.ts +1 -0
- package/dist/services/heifImagePrep.d.ts +1 -1
- package/dist/services/htmlCompiler.d.ts +4 -2
- package/dist/services/htmlTagScans.d.ts +1 -0
- package/dist/services/render/outputDimensions.d.ts +6 -0
- package/dist/services/render/stages/encodeStage.d.ts +28 -2
- package/dist/services/render/stages/probeStage.d.ts +7 -0
- package/dist/services/renderOrchestrator.d.ts +5 -0
- package/dist/utils/paths.d.ts +6 -2
- package/dist/verifyStaticPage.d.ts +1 -1
- package/package.json +7 -7
package/dist/distributed.js
CHANGED
|
@@ -87,6 +87,7 @@ import { isSafePath } from "@hyperframes/core/safe-path";
|
|
|
87
87
|
import {
|
|
88
88
|
isCopiedOutsideFileType,
|
|
89
89
|
isPrivateOutsideFile,
|
|
90
|
+
isUploadedOutsideFileType,
|
|
90
91
|
leftOutWarning,
|
|
91
92
|
linksOutside
|
|
92
93
|
} from "@hyperframes/studio-server/outside-file";
|
|
@@ -108,15 +109,17 @@ function isPathInside(childPath, parentPath, options = {}) {
|
|
|
108
109
|
function escapesAssetRoot(path, assetRoot) {
|
|
109
110
|
return assetRoot !== void 0 && !isSafePath(assetRoot, path);
|
|
110
111
|
}
|
|
111
|
-
function outsideAssetRefusal(projectDir, path) {
|
|
112
|
+
function outsideAssetRefusal(projectDir, path, policy = {}) {
|
|
112
113
|
if (!linksOutside(projectDir, path)) return null;
|
|
113
114
|
if (isPrivateOutsideFile(projectDir, path)) return "blocklisted";
|
|
114
115
|
const folder = statSync(path, { throwIfNoEntry: false })?.isDirectory();
|
|
115
|
-
|
|
116
|
+
if (folder || isUploadedOutsideFileType(path)) return null;
|
|
117
|
+
if (!isCopiedOutsideFileType(path)) return "file_type";
|
|
118
|
+
return policy.includeScripts ? null : "script";
|
|
116
119
|
}
|
|
117
120
|
var leftOutOfRender = (file, reference, reason) => leftOutWarning(file, reference, reason, "render");
|
|
118
|
-
function refusesOutsideLink(projectDir, path, warn) {
|
|
119
|
-
const refusal = outsideAssetRefusal(projectDir, path);
|
|
121
|
+
function refusesOutsideLink(projectDir, path, warn, policy = {}) {
|
|
122
|
+
const refusal = outsideAssetRefusal(projectDir, path, policy);
|
|
120
123
|
if (!refusal) return false;
|
|
121
124
|
const file = nodeRelative(projectDir, path).split(sep).join("/");
|
|
122
125
|
warn(leftOutOfRender(file, realFilePath(path), refusal));
|
|
@@ -140,13 +143,13 @@ function formatExportFrameName(index, ext) {
|
|
|
140
143
|
}
|
|
141
144
|
|
|
142
145
|
// src/services/renderOrchestrator.ts
|
|
143
|
-
import { audioFailureDiagnostics as audioFailureDiagnostics2 } from "@hyperframes/engine";
|
|
146
|
+
import { audioFailureDiagnostics as audioFailureDiagnostics2, usableCpuCount as usableCpuCount2 } from "@hyperframes/engine";
|
|
144
147
|
import {
|
|
145
148
|
existsSync as existsSync14,
|
|
146
149
|
mkdirSync as mkdirSync6,
|
|
147
150
|
readdirSync as readdirSync3,
|
|
148
151
|
rmSync as rmSync5,
|
|
149
|
-
statSync as
|
|
152
|
+
statSync as statSync7,
|
|
150
153
|
writeFileSync as writeFileSync5,
|
|
151
154
|
copyFileSync as copyFileSync5,
|
|
152
155
|
appendFileSync
|
|
@@ -298,6 +301,10 @@ function stripPreloadNone(html) {
|
|
|
298
301
|
return attr && attr.index < tagEnd ? [attr.index, attr.index + attr[0].length] : void 0;
|
|
299
302
|
});
|
|
300
303
|
}
|
|
304
|
+
function hasClosedMediaTag(text) {
|
|
305
|
+
const open2 = /<(?:video|audio)\b/i.exec(text);
|
|
306
|
+
return open2 !== null && text.includes(">", open2.index + open2[0].length);
|
|
307
|
+
}
|
|
301
308
|
var REMOTE_SRC_TAGS = {
|
|
302
309
|
media: { opener: "<(?:video|audio)\\b", attr: /\bsrc\s*=\s*["'](https?:\/\/)/gi },
|
|
303
310
|
source: { opener: "<source\\b", attr: /\bsrc\s*=\s*["'](https?:\/\/)/gi },
|
|
@@ -392,7 +399,10 @@ import { Readable } from "node:stream";
|
|
|
392
399
|
import { join as join2, extname, resolve as resolve2, sep as sep2 } from "node:path";
|
|
393
400
|
import { injectScriptsAtHeadStart, injectScriptsIntoHtml } from "@hyperframes/core/compiler";
|
|
394
401
|
import { injectTagsAtHeadStart } from "@hyperframes/core/compiler/html-document";
|
|
395
|
-
import {
|
|
402
|
+
import {
|
|
403
|
+
PREVIEW_FOR_ANOTHER_SITE_META,
|
|
404
|
+
serviceWorkerScriptFetch
|
|
405
|
+
} from "@hyperframes/core/studio-preview-mark";
|
|
396
406
|
import { fpsToNumber, terminalText as terminalText2 } from "@hyperframes/core";
|
|
397
407
|
import { isPrivateFileUnder, isStudioPrivatePath } from "@hyperframes/core/safe-path";
|
|
398
408
|
import { stripSdrPngColourTags } from "@hyperframes/core/compiler/png-colour-tags";
|
|
@@ -1032,7 +1042,8 @@ function createFileServer(options) {
|
|
|
1032
1042
|
compiledDir,
|
|
1033
1043
|
port = 0,
|
|
1034
1044
|
stripEmbeddedRuntime = true,
|
|
1035
|
-
allowOutsideProjectAssets = false
|
|
1045
|
+
allowOutsideProjectAssets = false,
|
|
1046
|
+
includeOutsideScripts = false
|
|
1036
1047
|
} = options;
|
|
1037
1048
|
const preHeadScripts = [
|
|
1038
1049
|
HF_EARLY_STUB,
|
|
@@ -1043,12 +1054,19 @@ function createFileServer(options) {
|
|
|
1043
1054
|
const bodyScripts = options.bodyScripts ?? [buildRenderModeScript(options.fps), HF_BRIDGE_SCRIPT];
|
|
1044
1055
|
const app = new Hono();
|
|
1045
1056
|
const warnLeftOut = (line) => console.warn(`[FileServer] ${terminalText2(line)}`);
|
|
1057
|
+
const outsidePolicy = { includeScripts: includeOutsideScripts };
|
|
1046
1058
|
let listeningPort = -1;
|
|
1047
1059
|
app.use(async function loadEachFileOnlyAsItsNamedType(c, next) {
|
|
1048
1060
|
await next();
|
|
1049
1061
|
c.res.headers.set("X-Content-Type-Options", "nosniff");
|
|
1050
1062
|
});
|
|
1051
1063
|
answerOwnLoopbackHostOnly(app, () => listeningPort);
|
|
1064
|
+
app.use(async function refuseServiceWorkerScripts(c, next) {
|
|
1065
|
+
const serviceWorker = c.req.header("service-worker");
|
|
1066
|
+
if (!serviceWorkerScriptFetch({ serviceWorker, fetchDest: c.req.header("sec-fetch-dest") }))
|
|
1067
|
+
return next();
|
|
1068
|
+
return c.text("Forbidden", 403);
|
|
1069
|
+
});
|
|
1052
1070
|
app.get("/*", async (c) => {
|
|
1053
1071
|
let requestPath = c.req.path;
|
|
1054
1072
|
if (requestPath === "/") requestPath = "/index.html";
|
|
@@ -1060,7 +1078,7 @@ function createFileServer(options) {
|
|
|
1060
1078
|
if (!isPathInside2(candidate, root, { resolveSymlinks })) continue;
|
|
1061
1079
|
if (isPrivateFileUnder(root, candidate, isStudioPrivatePath)) continue;
|
|
1062
1080
|
const checksLinks = allowOutsideProjectAssets && root !== compiledDir;
|
|
1063
|
-
if (checksLinks && refusesOutsideLink(root, candidate, warnLeftOut)) continue;
|
|
1081
|
+
if (checksLinks && refusesOutsideLink(root, candidate, warnLeftOut, outsidePolicy)) continue;
|
|
1064
1082
|
file = openRegularFile(candidate);
|
|
1065
1083
|
if (file) break;
|
|
1066
1084
|
}
|
|
@@ -2407,6 +2425,22 @@ import {
|
|
|
2407
2425
|
resolvePlayableVideoDuration
|
|
2408
2426
|
} from "@hyperframes/engine";
|
|
2409
2427
|
|
|
2428
|
+
// src/services/render/outputDimensions.ts
|
|
2429
|
+
function isExpectedOutputDimensions(value) {
|
|
2430
|
+
return typeof value === "object" && value !== null && "width" in value && "height" in value && typeof value.width === "number" && typeof value.height === "number" && Number.isSafeInteger(value.width) && Number.isSafeInteger(value.height) && value.width > 0 && value.height > 0;
|
|
2431
|
+
}
|
|
2432
|
+
var OutputDimensionsMismatchError = class extends Error {
|
|
2433
|
+
code = "OUTPUT_DIMENSIONS_MISMATCH";
|
|
2434
|
+
constructor() {
|
|
2435
|
+
super("Compiled output dimensions do not match the requested render dimensions.");
|
|
2436
|
+
}
|
|
2437
|
+
};
|
|
2438
|
+
function requireOutputDimensions(expected, width, height) {
|
|
2439
|
+
if (expected !== void 0 && (!isExpectedOutputDimensions(expected) || expected.width !== width || expected.height !== height)) {
|
|
2440
|
+
throw new OutputDimensionsMismatchError();
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2410
2444
|
// src/services/render/stages/compileStage.ts
|
|
2411
2445
|
import { existsSync as existsSync8, writeFileSync as writeFileSync3 } from "node:fs";
|
|
2412
2446
|
import { join as join10, relative as relative3 } from "node:path";
|
|
@@ -2415,6 +2449,61 @@ import { suggestMatchingPreset } from "@hyperframes/core";
|
|
|
2415
2449
|
import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
|
|
2416
2450
|
import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolution";
|
|
2417
2451
|
|
|
2452
|
+
// src/services/compositionSizeLimit.ts
|
|
2453
|
+
import { statSync as statSync3 } from "node:fs";
|
|
2454
|
+
var MAX_COMPOSITION_HTML_BYTES = 16 * 1024 * 1024;
|
|
2455
|
+
var COMPOSITION_TOO_LARGE = "COMPOSITION_TOO_LARGE";
|
|
2456
|
+
var megabytes = (bytes) => `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
2457
|
+
var MAX_EXPANDED_COMPOSITION_BYTES = 2 * MAX_COMPOSITION_HTML_BYTES;
|
|
2458
|
+
var MAX_COMPOSITION_MOUNTS = 1e4;
|
|
2459
|
+
var CompositionTooLargeError = class extends Error {
|
|
2460
|
+
constructor(message, publicMetadata) {
|
|
2461
|
+
super(message);
|
|
2462
|
+
this.publicMetadata = publicMetadata;
|
|
2463
|
+
this.name = "CompositionTooLargeError";
|
|
2464
|
+
}
|
|
2465
|
+
publicMetadata;
|
|
2466
|
+
code = COMPOSITION_TOO_LARGE;
|
|
2467
|
+
// The producer server reads these off the error for the wire envelope.
|
|
2468
|
+
owner = "user";
|
|
2469
|
+
retryable = false;
|
|
2470
|
+
};
|
|
2471
|
+
var fileTooLarge = (file, bytes) => new CompositionTooLargeError(
|
|
2472
|
+
`Composition file "${file}" is ${megabytes(bytes)}, over the ${megabytes(MAX_COMPOSITION_HTML_BYTES)} limit for one composition HTML file. Keep large data such as images, fonts and JSON in separate asset files and reference them by path instead of inlining them.`,
|
|
2473
|
+
{ bytes, limitBytes: MAX_COMPOSITION_HTML_BYTES }
|
|
2474
|
+
);
|
|
2475
|
+
var CompositionExpansionBudget = class {
|
|
2476
|
+
bytes = 0;
|
|
2477
|
+
mounts = 0;
|
|
2478
|
+
charge(file, bytes) {
|
|
2479
|
+
this.bytes += bytes;
|
|
2480
|
+
this.mounts += 1;
|
|
2481
|
+
if (this.bytes <= MAX_EXPANDED_COMPOSITION_BYTES && this.mounts <= MAX_COMPOSITION_MOUNTS) {
|
|
2482
|
+
return;
|
|
2483
|
+
}
|
|
2484
|
+
throw new CompositionTooLargeError(
|
|
2485
|
+
`Sub-composition mounts, ending at "${file}", add up to ${megabytes(this.bytes)} across ${this.mounts} mounts. One render inlines at most ${megabytes(MAX_EXPANDED_COMPOSITION_BYTES)} of composition HTML in at most ${MAX_COMPOSITION_MOUNTS} mounts. Mount large or repeated scenes fewer times.`,
|
|
2486
|
+
{
|
|
2487
|
+
bytes: this.bytes,
|
|
2488
|
+
limitBytes: MAX_EXPANDED_COMPOSITION_BYTES,
|
|
2489
|
+
mounts: this.mounts,
|
|
2490
|
+
exceeded: this.mounts > MAX_COMPOSITION_MOUNTS ? "mounts" : "bytes"
|
|
2491
|
+
}
|
|
2492
|
+
);
|
|
2493
|
+
}
|
|
2494
|
+
};
|
|
2495
|
+
function assertCompositionFileSize(path, file) {
|
|
2496
|
+
let bytes;
|
|
2497
|
+
try {
|
|
2498
|
+
const stats = statSync3(path);
|
|
2499
|
+
if (!stats.isFile()) return;
|
|
2500
|
+
bytes = stats.size;
|
|
2501
|
+
} catch {
|
|
2502
|
+
return;
|
|
2503
|
+
}
|
|
2504
|
+
if (bytes > MAX_COMPOSITION_HTML_BYTES) throw fileTooLarge(file, bytes);
|
|
2505
|
+
}
|
|
2506
|
+
|
|
2418
2507
|
// src/services/htmlCompiler.ts
|
|
2419
2508
|
import { decodedUrlPath } from "@hyperframes/parsers/asset-paths";
|
|
2420
2509
|
import {
|
|
@@ -2501,11 +2590,13 @@ import {
|
|
|
2501
2590
|
import {
|
|
2502
2591
|
isUnresolvedAssetPlaceholder,
|
|
2503
2592
|
namesAnotherNetworkRoot as namesAnotherNetworkRoot2,
|
|
2593
|
+
projectAssetExists,
|
|
2504
2594
|
readProjectFile,
|
|
2505
2595
|
readTextFile,
|
|
2506
2596
|
resolveCompositionSrc
|
|
2507
2597
|
} from "@hyperframes/parsers/asset-resolution";
|
|
2508
2598
|
import { isPrivateFileUnder as isPrivateFileUnder2, isStudioPrivatePath as isStudioPrivatePath2 } from "@hyperframes/core/safe-path";
|
|
2599
|
+
import { linksOutside as linksOutside2 } from "@hyperframes/studio-server/outside-file";
|
|
2509
2600
|
|
|
2510
2601
|
// src/services/renderMediaCollector.ts
|
|
2511
2602
|
import { parseHTML as parseHTML2 } from "linkedom";
|
|
@@ -2699,7 +2790,7 @@ import {
|
|
|
2699
2790
|
|
|
2700
2791
|
// src/services/animatedGifPrep.ts
|
|
2701
2792
|
import { createHash as createHash3 } from "node:crypto";
|
|
2702
|
-
import { copyFileSync as copyFileSync2, existsSync as existsSync5, mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync as rmSync2, statSync as
|
|
2793
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync5, mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync as rmSync2, statSync as statSync4 } from "node:fs";
|
|
2703
2794
|
import { dirname as dirname4, isAbsolute as isAbsolute2, join as join6, resolve as resolve4 } from "node:path";
|
|
2704
2795
|
import { parseHTML as parseHTML3 } from "linkedom";
|
|
2705
2796
|
import { parseAnimatedGifMetadata } from "@hyperframes/core";
|
|
@@ -2752,12 +2843,13 @@ function resolveLocalImageSourcePath(src, options) {
|
|
|
2752
2843
|
isAbsolute2(basePath) ? basePath : resolve4(options.projectDir, projectRelative),
|
|
2753
2844
|
resolve4(options.downloadDir, normalizedBase)
|
|
2754
2845
|
];
|
|
2755
|
-
const
|
|
2846
|
+
const assetRoot = options.allowOutsideFiles ? void 0 : options.projectDir;
|
|
2847
|
+
const allowed = (candidate) => !namesAnotherNetworkRoot(options.projectDir, candidate) && !isPrivateUnderAssetRoots(candidate, [options.projectDir, options.downloadDir]) && (!escapesAssetRoot(candidate, assetRoot) && outsideAssetRefusal(options.projectDir, candidate) !== "blocklisted" || !escapesAssetRoot(candidate, options.downloadDir));
|
|
2756
2848
|
return candidates.find((candidate) => allowed(candidate) && existsSync5(candidate)) ?? null;
|
|
2757
2849
|
}
|
|
2758
2850
|
function isUsableFile(path) {
|
|
2759
2851
|
try {
|
|
2760
|
-
const stat =
|
|
2852
|
+
const stat = statSync4(path);
|
|
2761
2853
|
return stat.isFile() && stat.size > 0;
|
|
2762
2854
|
} catch {
|
|
2763
2855
|
return false;
|
|
@@ -3022,7 +3114,7 @@ import {
|
|
|
3022
3114
|
readFileSync as readFileSync4,
|
|
3023
3115
|
readSync,
|
|
3024
3116
|
rmSync as rmSync3,
|
|
3025
|
-
statSync as
|
|
3117
|
+
statSync as statSync5,
|
|
3026
3118
|
writeFileSync as writeFileSync2
|
|
3027
3119
|
} from "node:fs";
|
|
3028
3120
|
import { dirname as dirname5, join as join7, resolve as resolve5 } from "node:path";
|
|
@@ -3266,7 +3358,7 @@ function resolveImageSource(src, options) {
|
|
|
3266
3358
|
}
|
|
3267
3359
|
function isUsableFile2(path) {
|
|
3268
3360
|
try {
|
|
3269
|
-
return
|
|
3361
|
+
return statSync5(path).size > 0;
|
|
3270
3362
|
} catch {
|
|
3271
3363
|
return false;
|
|
3272
3364
|
}
|
|
@@ -3545,7 +3637,7 @@ Check that each file referenced by data-composition-src contains valid HTML with
|
|
|
3545
3637
|
};
|
|
3546
3638
|
function normalizeCompositionSrcs(html, projectDir) {
|
|
3547
3639
|
return html.replace(/(\bdata-composition-src=)(["'])([^"']*)\2/g, (whole, name, quote, value) => {
|
|
3548
|
-
if (!value.includes("%") &&
|
|
3640
|
+
if (!value.includes("%") && !/^\.?[\\/]/.test(value)) return whole;
|
|
3549
3641
|
const file = resolveCompositionSrc(projectDir, value);
|
|
3550
3642
|
if (file === null) return whole;
|
|
3551
3643
|
return `${name}${quote}${relative2(projectDir, file).split(sep3).join("/")}${quote}`;
|
|
@@ -3561,68 +3653,94 @@ function resolveCompositionFile(projectDir, src, assetRoot) {
|
|
|
3561
3653
|
const file = resolveCompositionPath(projectDir, src, assetRoot);
|
|
3562
3654
|
return file !== null && COMPOSITION_FILE.test(file) ? file : null;
|
|
3563
3655
|
}
|
|
3656
|
+
var OUTSIDE_COMPOSITION_NEEDS_FLAG = "it is outside the project, and any scripts in it would run; move it into the project, or pass --include-outside-files to hyperframes render, to include it";
|
|
3657
|
+
var runsOutsideMarkupUnasked = (projectDir, filePath, assetRoot, outsideFiles) => assetRoot === void 0 && !outsideFiles.includeScripts && linksOutside2(projectDir, filePath);
|
|
3658
|
+
function assertOutsideMarkupAsked(projectDir, filePath, srcPath, assetRoot, outsideFiles) {
|
|
3659
|
+
if (runsOutsideMarkupUnasked(projectDir, filePath, assetRoot, outsideFiles)) {
|
|
3660
|
+
throw new EmptyCompositionError([{ srcPath, detail: OUTSIDE_COMPOSITION_NEEDS_FLAG }]);
|
|
3661
|
+
}
|
|
3662
|
+
}
|
|
3564
3663
|
var isPrivateCompositionFile = (projectDir, filePath) => isPrivateFileUnder2(projectDir, filePath, isStudioPrivatePath2);
|
|
3565
|
-
|
|
3664
|
+
var mountSrcsUnder = (root) => [...root.querySelectorAll("[data-composition-src]")].map((el) => el.getAttribute("data-composition-src")).filter((srcPath) => !!srcPath && !isUnresolvedAssetPlaceholder(srcPath));
|
|
3665
|
+
function compositionSrcsIn(html) {
|
|
3566
3666
|
const { document: document2 } = parseHTML5(html);
|
|
3567
|
-
const
|
|
3568
|
-
const
|
|
3569
|
-
for (
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3667
|
+
const templated = [];
|
|
3668
|
+
const templates = [...document2.querySelectorAll("template")];
|
|
3669
|
+
for (let template = templates.pop(); template; template = templates.pop()) {
|
|
3670
|
+
templated.push(...mountSrcsUnder(template.content));
|
|
3671
|
+
templates.push(...template.content.querySelectorAll("template"));
|
|
3672
|
+
}
|
|
3673
|
+
return { mounts: mountSrcsUnder(document2), templated };
|
|
3674
|
+
}
|
|
3675
|
+
function compositionPathProblem(projectDir, filePath, assetRoot, outsideFiles) {
|
|
3676
|
+
if (outsideAssetRefusal(projectDir, filePath) === "blocklisted") {
|
|
3677
|
+
return "it is outside the project in a private location";
|
|
3678
|
+
}
|
|
3679
|
+
if (runsOutsideMarkupUnasked(projectDir, filePath, assetRoot, outsideFiles)) {
|
|
3680
|
+
return OUTSIDE_COMPOSITION_NEEDS_FLAG;
|
|
3681
|
+
}
|
|
3682
|
+
if (isPrivateCompositionFile(projectDir, filePath)) {
|
|
3683
|
+
return "it is git metadata, an env file or a private tool record";
|
|
3684
|
+
}
|
|
3685
|
+
return COMPOSITION_FILE.test(filePath) ? null : NOT_A_COMPOSITION_FILE;
|
|
3686
|
+
}
|
|
3687
|
+
function readSubCompositionFile(filePath, srcPath) {
|
|
3688
|
+
assertCompositionFileSize(filePath, srcPath);
|
|
3689
|
+
const read = readProjectFile(filePath);
|
|
3690
|
+
if (read.kind === "missing") return { detail: "the file does not exist" };
|
|
3691
|
+
if (read.kind === "folder") return { detail: "it is a folder, not an HTML file" };
|
|
3692
|
+
const validity = checkSubCompositionUsability(read.text, parseSubCompHtmlForValidity);
|
|
3693
|
+
if (!validity.ok)
|
|
3694
|
+
return { detail: validity.detail ?? "the file is empty or could not be parsed" };
|
|
3695
|
+
return { bytes: Buffer.byteLength(read.text), ...compositionSrcsIn(read.text) };
|
|
3696
|
+
}
|
|
3697
|
+
function assertSubCompositionsUsable(html, projectDir, assetRoot, outsideFiles) {
|
|
3698
|
+
const budget = new CompositionExpansionBudget();
|
|
3699
|
+
const files = /* @__PURE__ */ new Map();
|
|
3700
|
+
const problems = /* @__PURE__ */ new Map();
|
|
3701
|
+
const report = (srcPath, detail) => problems.set(`${srcPath}\0${detail}`, { srcPath, detail });
|
|
3702
|
+
const chain = /* @__PURE__ */ new Set();
|
|
3703
|
+
const paths = /* @__PURE__ */ new Map();
|
|
3704
|
+
const resolveMount = (srcPath) => {
|
|
3573
3705
|
const filePath = resolveCompositionPath(projectDir, srcPath, assetRoot);
|
|
3574
|
-
if (filePath === null) {
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
}
|
|
3589
|
-
if (!COMPOSITION_FILE.test(filePath)) {
|
|
3590
|
-
problems.push({ srcPath, detail: NOT_A_COMPOSITION_FILE });
|
|
3591
|
-
continue;
|
|
3592
|
-
}
|
|
3593
|
-
if (visited.has(filePath)) continue;
|
|
3594
|
-
const read = readProjectFile(filePath);
|
|
3595
|
-
if (read.kind === "missing") {
|
|
3596
|
-
problems.push({ srcPath, detail: "the file does not exist" });
|
|
3597
|
-
continue;
|
|
3598
|
-
}
|
|
3599
|
-
if (read.kind === "folder") {
|
|
3600
|
-
problems.push({ srcPath, detail: "it is a folder, not an HTML file" });
|
|
3601
|
-
continue;
|
|
3602
|
-
}
|
|
3603
|
-
const fileHtml = read.text;
|
|
3604
|
-
const validity = checkSubCompositionUsability(fileHtml, parseSubCompHtmlForValidity);
|
|
3605
|
-
if (!validity.ok) {
|
|
3606
|
-
problems.push({
|
|
3607
|
-
srcPath,
|
|
3608
|
-
detail: validity.detail ?? "the file is empty or could not be parsed"
|
|
3609
|
-
});
|
|
3610
|
-
continue;
|
|
3611
|
-
}
|
|
3612
|
-
const nestedVisited = new Set(visited);
|
|
3613
|
-
nestedVisited.add(filePath);
|
|
3614
|
-
try {
|
|
3615
|
-
assertSubCompositionsUsable(fileHtml, projectDir, assetRoot, nestedVisited);
|
|
3616
|
-
} catch (err) {
|
|
3617
|
-
if (err instanceof EmptyCompositionError) {
|
|
3618
|
-
problems.push(...err.problems);
|
|
3619
|
-
} else {
|
|
3620
|
-
throw err;
|
|
3706
|
+
if (filePath === null) return { detail: "it is outside the project folder" };
|
|
3707
|
+
const detail = compositionPathProblem(projectDir, filePath, assetRoot, outsideFiles);
|
|
3708
|
+
return detail ? { detail } : { filePath };
|
|
3709
|
+
};
|
|
3710
|
+
const walk = (srcPaths, quiet) => {
|
|
3711
|
+
for (const srcPath of srcPaths) {
|
|
3712
|
+
let resolved = paths.get(srcPath);
|
|
3713
|
+
if (!resolved) {
|
|
3714
|
+
resolved = resolveMount(srcPath);
|
|
3715
|
+
paths.set(srcPath, resolved);
|
|
3716
|
+
}
|
|
3717
|
+
if ("detail" in resolved) {
|
|
3718
|
+
if (!quiet) report(srcPath, resolved.detail);
|
|
3719
|
+
continue;
|
|
3621
3720
|
}
|
|
3721
|
+
const { filePath } = resolved;
|
|
3722
|
+
if (chain.has(filePath)) continue;
|
|
3723
|
+
let file = files.get(filePath);
|
|
3724
|
+
if (!file) {
|
|
3725
|
+
file = readSubCompositionFile(filePath, srcPath);
|
|
3726
|
+
files.set(filePath, file);
|
|
3727
|
+
}
|
|
3728
|
+
if ("detail" in file) {
|
|
3729
|
+
if (!quiet) report(srcPath, file.detail);
|
|
3730
|
+
continue;
|
|
3731
|
+
}
|
|
3732
|
+
budget.charge(srcPath, file.bytes);
|
|
3733
|
+
chain.add(filePath);
|
|
3734
|
+
walk(file.mounts, quiet);
|
|
3735
|
+
walk(file.templated, true);
|
|
3736
|
+
chain.delete(filePath);
|
|
3622
3737
|
}
|
|
3623
|
-
}
|
|
3624
|
-
|
|
3625
|
-
|
|
3738
|
+
};
|
|
3739
|
+
const entry = compositionSrcsIn(html);
|
|
3740
|
+
walk(entry.mounts, false);
|
|
3741
|
+
walk(entry.templated, true);
|
|
3742
|
+
if (problems.size > 0) {
|
|
3743
|
+
throw new EmptyCompositionError([...problems.values()]);
|
|
3626
3744
|
}
|
|
3627
3745
|
}
|
|
3628
3746
|
var COMPILER_MOUNT_BLOCK_START = "/* __HF_COMPILER_MOUNT_START__ */";
|
|
@@ -3877,7 +3995,7 @@ async function compileHtmlFile(html, projectDir, baseDir, downloadDir, log, urlB
|
|
|
3877
3995
|
compiledHtml = stripCrossoriginAttr(compiledHtml, "audio");
|
|
3878
3996
|
return { html: compiledHtml, unresolvedCompositions };
|
|
3879
3997
|
}
|
|
3880
|
-
async function parseSubCompositions(html, projectDir, downloadDir, visited = /* @__PURE__ */ new Set(), urlByAbsentLocalPath, probes, assetRoot) {
|
|
3998
|
+
async function parseSubCompositions(html, projectDir, downloadDir, visited = /* @__PURE__ */ new Set(), urlByAbsentLocalPath, probes, assetRoot, outsideFiles = {}, compiledSrcs = /* @__PURE__ */ new Set()) {
|
|
3881
3999
|
const subCompositions = /* @__PURE__ */ new Map();
|
|
3882
4000
|
const { document: document2 } = parseHTML5(html);
|
|
3883
4001
|
const compEls = document2.querySelectorAll("[data-composition-src]");
|
|
@@ -3890,6 +4008,10 @@ async function parseSubCompositions(html, projectDir, downloadDir, visited = /*
|
|
|
3890
4008
|
if (visited.has(filePath)) {
|
|
3891
4009
|
continue;
|
|
3892
4010
|
}
|
|
4011
|
+
if (compiledSrcs.has(srcPath)) continue;
|
|
4012
|
+
compiledSrcs.add(srcPath);
|
|
4013
|
+
assertOutsideMarkupAsked(projectDir, filePath, srcPath, assetRoot, outsideFiles);
|
|
4014
|
+
assertCompositionFileSize(filePath, srcPath);
|
|
3893
4015
|
const read = readProjectFile(filePath);
|
|
3894
4016
|
if (read.kind !== "file") {
|
|
3895
4017
|
continue;
|
|
@@ -3918,7 +4040,9 @@ async function parseSubCompositions(html, projectDir, downloadDir, visited = /*
|
|
|
3918
4040
|
item.nestedVisited,
|
|
3919
4041
|
urlByAbsentLocalPath,
|
|
3920
4042
|
probes,
|
|
3921
|
-
assetRoot
|
|
4043
|
+
assetRoot,
|
|
4044
|
+
outsideFiles,
|
|
4045
|
+
compiledSrcs
|
|
3922
4046
|
);
|
|
3923
4047
|
return {
|
|
3924
4048
|
srcPath: item.srcPath,
|
|
@@ -4054,7 +4178,7 @@ function coalesceHeadStylesAndBodyScripts(html) {
|
|
|
4054
4178
|
}
|
|
4055
4179
|
return document2.toString();
|
|
4056
4180
|
}
|
|
4057
|
-
function inlineSubCompositions(html, subCompositions, projectDir, variableOverrides, assetRoot) {
|
|
4181
|
+
function inlineSubCompositions(html, subCompositions, projectDir, variableOverrides, assetRoot, outsideFiles) {
|
|
4058
4182
|
const { document: document2 } = parseHTML5(html);
|
|
4059
4183
|
const head = document2.querySelector("head");
|
|
4060
4184
|
const body = document2.querySelector("body");
|
|
@@ -4067,6 +4191,27 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
|
|
|
4067
4191
|
);
|
|
4068
4192
|
return { html: emitted ? document2.toString() : html, variablesByComp: {} };
|
|
4069
4193
|
}
|
|
4194
|
+
const budget = new CompositionExpansionBudget();
|
|
4195
|
+
const readOnce = /* @__PURE__ */ new Map();
|
|
4196
|
+
const readMountHtml = (srcPath) => {
|
|
4197
|
+
const filePath = resolveCompositionFile(projectDir, srcPath, assetRoot);
|
|
4198
|
+
if (filePath) {
|
|
4199
|
+
assertOutsideMarkupAsked(projectDir, filePath, srcPath, assetRoot, outsideFiles);
|
|
4200
|
+
assertCompositionFileSize(filePath, srcPath);
|
|
4201
|
+
}
|
|
4202
|
+
const read = filePath && !isPrivateCompositionFile(projectDir, filePath) ? readProjectFile(filePath) : null;
|
|
4203
|
+
return read?.kind === "file" ? rewriteUnresolvableGsapToCdn(
|
|
4204
|
+
normalizeCompositionSrcs(read.text, projectDir),
|
|
4205
|
+
projectDir,
|
|
4206
|
+
srcPath
|
|
4207
|
+
) : null;
|
|
4208
|
+
};
|
|
4209
|
+
const resolveMountHtml = (srcPath) => {
|
|
4210
|
+
const compiled = subCompositions.get(srcPath);
|
|
4211
|
+
if (compiled) return compiled;
|
|
4212
|
+
if (!readOnce.has(srcPath)) readOnce.set(srcPath, readMountHtml(srcPath));
|
|
4213
|
+
return readOnce.get(srcPath) ?? null;
|
|
4214
|
+
};
|
|
4070
4215
|
const hostIdentityByElement = new ProducerHostIdentityMap(
|
|
4071
4216
|
document2,
|
|
4072
4217
|
hosts
|
|
@@ -4082,20 +4227,14 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
|
|
|
4082
4227
|
readVariableDefaults: readDeclaredDefaults,
|
|
4083
4228
|
parseHostVariables: parseHostVariableValues,
|
|
4084
4229
|
resolveHtml: (srcPath) => {
|
|
4085
|
-
|
|
4086
|
-
if (
|
|
4087
|
-
const filePath = resolveCompositionFile(projectDir, srcPath, assetRoot);
|
|
4088
|
-
const read = filePath && !isPrivateCompositionFile(projectDir, filePath) ? readProjectFile(filePath) : null;
|
|
4089
|
-
if (read?.kind === "file") {
|
|
4090
|
-
compHtml = rewriteUnresolvableGsapToCdn(read.text, projectDir, srcPath);
|
|
4091
|
-
}
|
|
4092
|
-
}
|
|
4230
|
+
const compHtml = resolveMountHtml(srcPath);
|
|
4231
|
+
if (compHtml) budget.charge(srcPath, Buffer.byteLength(compHtml));
|
|
4093
4232
|
return compHtml;
|
|
4094
4233
|
},
|
|
4095
4234
|
parseHtml: (htmlStr) => parseHTML5(htmlStr).document,
|
|
4096
4235
|
// Mirrors the preview bundler: a sub-composition's SIBLING assets resolve
|
|
4097
4236
|
// against its own directory, project-root refs stay as authored.
|
|
4098
|
-
assetExists: (
|
|
4237
|
+
assetExists: projectAssetExists(projectDir),
|
|
4099
4238
|
// Preserve the authored root wrapper as a child of the host, matching
|
|
4100
4239
|
// the preview bundler's shape (htmlBundler.ts's prepareFlattenedInnerRoot,
|
|
4101
4240
|
// which the runtime compositionLoader mirrors with its own copy for the
|
|
@@ -4300,7 +4439,7 @@ ${safeText}
|
|
|
4300
4439
|
}
|
|
4301
4440
|
return wrappedFragment ? document2.body.innerHTML || "" : document2.toString();
|
|
4302
4441
|
}
|
|
4303
|
-
function collectExternalAssets(html, projectDir, log = defaultLogger, file = "index.html") {
|
|
4442
|
+
function collectExternalAssets(html, projectDir, log = defaultLogger, file = "index.html", policy = {}) {
|
|
4304
4443
|
const absProjectDir = resolve6(projectDir);
|
|
4305
4444
|
const externalAssets = /* @__PURE__ */ new Map();
|
|
4306
4445
|
const leftOut = /* @__PURE__ */ new Set();
|
|
@@ -4313,7 +4452,7 @@ function collectExternalAssets(html, projectDir, log = defaultLogger, file = "in
|
|
|
4313
4452
|
}
|
|
4314
4453
|
const onShare = namesAnotherNetworkRoot2(absProjectDir, absPath);
|
|
4315
4454
|
if (!onShare && !existsSync7(absPath)) return null;
|
|
4316
|
-
const refusal = onShare ? "network_share" : outsideAssetRefusal(absProjectDir, absPath);
|
|
4455
|
+
const refusal = onShare ? "network_share" : outsideAssetRefusal(absProjectDir, absPath, policy);
|
|
4317
4456
|
if (refusal) {
|
|
4318
4457
|
if (!leftOut.has(trimmed)) log.warn(`[Compiler] ${leftOutOfRender(file, trimmed, refusal)}`);
|
|
4319
4458
|
leftOut.add(trimmed);
|
|
@@ -4699,7 +4838,7 @@ function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath) {
|
|
|
4699
4838
|
const entryPath = relative2(projectDir, htmlPath).replace(/\\/g, "/");
|
|
4700
4839
|
if (!entryPath.includes("/")) return html;
|
|
4701
4840
|
const { document: document2 } = parseHTML5(html);
|
|
4702
|
-
const assetExists = (
|
|
4841
|
+
const assetExists = projectAssetExists(projectDir);
|
|
4703
4842
|
rewriteAssetPaths(
|
|
4704
4843
|
document2.querySelectorAll("[src], [href], [srcset]"),
|
|
4705
4844
|
entryPath,
|
|
@@ -4740,18 +4879,23 @@ function bindVariableMediaSources(html, variables) {
|
|
|
4740
4879
|
var entryFileName = (projectDir, htmlPath) => isPathInside(htmlPath, projectDir) ? relative2(projectDir, htmlPath).split(sep3).join("/") : basename3(htmlPath);
|
|
4741
4880
|
async function compileForRender(projectDir, htmlPath, downloadDir, options = {}) {
|
|
4742
4881
|
const assetRoot = options.allowOutsideProjectAssets ? void 0 : projectDir;
|
|
4882
|
+
const outsideFiles = { includeScripts: options.includeOutsideScripts };
|
|
4743
4883
|
if (isPathInside(htmlPath, projectDir) && escapesAssetRoot(htmlPath, assetRoot)) {
|
|
4744
4884
|
throw new Error(`Entry file ${htmlPath} leads outside the project folder`);
|
|
4745
4885
|
}
|
|
4886
|
+
if (isPathInside(htmlPath, projectDir) && runsOutsideMarkupUnasked(projectDir, htmlPath, assetRoot, outsideFiles)) {
|
|
4887
|
+
throw new Error(`Entry file ${htmlPath} ${OUTSIDE_COMPOSITION_NEEDS_FLAG}`);
|
|
4888
|
+
}
|
|
4746
4889
|
if (!COMPOSITION_FILE.test(htmlPath)) {
|
|
4747
4890
|
throw new Error(`Entry file ${htmlPath} is not an .html file, so it is refused`);
|
|
4748
4891
|
}
|
|
4892
|
+
assertCompositionFileSize(htmlPath, basename3(htmlPath));
|
|
4749
4893
|
const entryHtml = rebaseDirectEntryAssetPaths(readTextFile(htmlPath), projectDir, htmlPath);
|
|
4750
4894
|
const rawHtml = bindVariableMediaSources(
|
|
4751
4895
|
normalizeCompositionSrcs(rewriteUnresolvableGsapToCdn(entryHtml, projectDir), projectDir),
|
|
4752
4896
|
options.variables ?? {}
|
|
4753
4897
|
);
|
|
4754
|
-
assertSubCompositionsUsable(rawHtml, projectDir, assetRoot);
|
|
4898
|
+
assertSubCompositionsUsable(rawHtml, projectDir, assetRoot, outsideFiles);
|
|
4755
4899
|
const probes = /* @__PURE__ */ new Map();
|
|
4756
4900
|
const { html: compiledHtml, unresolvedCompositions } = await compileHtmlFile(
|
|
4757
4901
|
rawHtml,
|
|
@@ -4770,7 +4914,8 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
4770
4914
|
void 0,
|
|
4771
4915
|
options.urlByAbsentLocalPath,
|
|
4772
4916
|
probes,
|
|
4773
|
-
assetRoot
|
|
4917
|
+
assetRoot,
|
|
4918
|
+
outsideFiles
|
|
4774
4919
|
);
|
|
4775
4920
|
const fullHtml = ensureFullDocument(compiledHtml);
|
|
4776
4921
|
const { html: inlinedHtml, variablesByComp } = inlineSubCompositions(
|
|
@@ -4778,7 +4923,8 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
4778
4923
|
subCompositions,
|
|
4779
4924
|
projectDir,
|
|
4780
4925
|
options.variables ?? {},
|
|
4781
|
-
assetRoot
|
|
4926
|
+
assetRoot,
|
|
4927
|
+
outsideFiles
|
|
4782
4928
|
);
|
|
4783
4929
|
const sanitizedHtml = stripPreloadNone(inlinedHtml);
|
|
4784
4930
|
const renderModeHints = detectRenderModeHints(sanitizedHtml, options.pageMotionBlur);
|
|
@@ -4832,7 +4978,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
4832
4978
|
cacheDir: options.animatedGifCacheDir,
|
|
4833
4979
|
sourceAssets: remoteImageAssets,
|
|
4834
4980
|
timeoutMs: options.ffmpegProcessTimeout,
|
|
4835
|
-
assetRoot
|
|
4981
|
+
allowOutsideFiles: assetRoot === void 0
|
|
4836
4982
|
});
|
|
4837
4983
|
if (preparedHeifImages.length > 0) {
|
|
4838
4984
|
defaultLogger.debug(`[Compiler] Converted ${preparedHeifImages.length} HEIC image(s) to JPEG`);
|
|
@@ -4848,7 +4994,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
4848
4994
|
cacheDir: options.animatedGifCacheDir,
|
|
4849
4995
|
sourceAssets: gifSourceAssets,
|
|
4850
4996
|
timeoutMs: options.ffmpegProcessTimeout,
|
|
4851
|
-
assetRoot
|
|
4997
|
+
allowOutsideFiles: assetRoot === void 0
|
|
4852
4998
|
});
|
|
4853
4999
|
if (preparedGifs.length > 0) {
|
|
4854
5000
|
defaultLogger.debug(`[Compiler] Prepared ${preparedGifs.length} animated GIF input(s) as WebM`);
|
|
@@ -4863,7 +5009,8 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
4863
5009
|
embeddedHtml,
|
|
4864
5010
|
projectDir,
|
|
4865
5011
|
options.log,
|
|
4866
|
-
entryFileName(projectDir, htmlPath)
|
|
5012
|
+
entryFileName(projectDir, htmlPath),
|
|
5013
|
+
{ includeScripts: options.includeOutsideScripts }
|
|
4867
5014
|
) : { html: embeddedHtml, externalAssets: /* @__PURE__ */ new Map() };
|
|
4868
5015
|
for (const [relPath, absPath] of remoteMediaAssets) {
|
|
4869
5016
|
externalAssets.set(relPath, absPath);
|
|
@@ -5270,7 +5417,7 @@ async function resolveCompositionDurations(page, unresolved) {
|
|
|
5270
5417
|
}
|
|
5271
5418
|
return resolutions;
|
|
5272
5419
|
}
|
|
5273
|
-
async function recompileWithResolutions(compiled, resolutions, projectDir, downloadDir, assetRoot) {
|
|
5420
|
+
async function recompileWithResolutions(compiled, resolutions, projectDir, downloadDir, assetRoot, outsideFiles = {}) {
|
|
5274
5421
|
if (resolutions.length === 0) return compiled;
|
|
5275
5422
|
const html = injectDurations(compiled.html, resolutions);
|
|
5276
5423
|
const { subCompositions } = await parseSubCompositions(
|
|
@@ -5280,7 +5427,8 @@ async function recompileWithResolutions(compiled, resolutions, projectDir, downl
|
|
|
5280
5427
|
void 0,
|
|
5281
5428
|
void 0,
|
|
5282
5429
|
void 0,
|
|
5283
|
-
assetRoot
|
|
5430
|
+
assetRoot,
|
|
5431
|
+
outsideFiles
|
|
5284
5432
|
);
|
|
5285
5433
|
const { videos, audios, images } = compiled;
|
|
5286
5434
|
const remaining = compiled.unresolvedCompositions.filter(
|
|
@@ -5328,6 +5476,7 @@ function resolveEntryHtmlPath(input) {
|
|
|
5328
5476
|
`Entry file "${relative3(projectDir, path)}" leads outside the project folder`
|
|
5329
5477
|
);
|
|
5330
5478
|
}
|
|
5479
|
+
assertCompositionFileSize(path, relative3(projectDir, path));
|
|
5331
5480
|
return readTextFile2(path);
|
|
5332
5481
|
};
|
|
5333
5482
|
const htmlPath = join10(projectDir, entryFile);
|
|
@@ -5389,7 +5538,8 @@ async function runCompileStage(input) {
|
|
|
5389
5538
|
pageMotionBlur: input.pageMotionBlur,
|
|
5390
5539
|
animatedGifCacheDir: animatedGifCacheDir(cfg.extractCacheDir),
|
|
5391
5540
|
ffmpegProcessTimeout: cfg.ffmpegProcessTimeout,
|
|
5392
|
-
allowOutsideProjectAssets: job.config.allowOutsideProjectAssets
|
|
5541
|
+
allowOutsideProjectAssets: job.config.allowOutsideProjectAssets,
|
|
5542
|
+
includeOutsideScripts: job.config.includeOutsideScripts
|
|
5393
5543
|
});
|
|
5394
5544
|
assertNotAborted();
|
|
5395
5545
|
const compileOnlyMs = Date.now() - compileStart;
|
|
@@ -5475,6 +5625,8 @@ async function runCompileStage(input) {
|
|
|
5475
5625
|
});
|
|
5476
5626
|
const outputWidth = Math.round(width * deviceScaleFactor);
|
|
5477
5627
|
const outputHeight = Math.round(height * deviceScaleFactor);
|
|
5628
|
+
requireOutputDimensions(job.config.expectedOutputDimensions, outputWidth, outputHeight);
|
|
5629
|
+
if (job.config.expectedOutputDimensions !== void 0) job.outputDimensionsChecked = true;
|
|
5478
5630
|
if (deviceScaleFactor !== 1) {
|
|
5479
5631
|
log.info("Scaling composition via deviceScaleFactor", {
|
|
5480
5632
|
compositionWidth: width,
|
|
@@ -5569,30 +5721,50 @@ function hasAutoStartVideos(html) {
|
|
|
5569
5721
|
const { document: document2 } = parseHTML6(html);
|
|
5570
5722
|
return document2.querySelector("video[data-hf-auto-start]") !== null;
|
|
5571
5723
|
}
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5724
|
+
var MAX_VARIABLE_SCOPE_STEPS = 1e6;
|
|
5725
|
+
function variableIdsOn(scan, element) {
|
|
5726
|
+
let ids = scan.ids.get(element);
|
|
5727
|
+
if (!ids) {
|
|
5728
|
+
ids = /* @__PURE__ */ new Set([
|
|
5729
|
+
...Object.keys(parseHostVariableValues2(element)),
|
|
5730
|
+
...Object.keys(readDeclaredDefaults2(element))
|
|
5731
|
+
]);
|
|
5732
|
+
scan.ids.set(element, ids);
|
|
5733
|
+
}
|
|
5734
|
+
return ids;
|
|
5735
|
+
}
|
|
5736
|
+
function scopedVariablesFor(scan, element, variablesByComp) {
|
|
5737
|
+
for (let node = element; node; node = node.parentElement) {
|
|
5738
|
+
if (++scan.steps > MAX_VARIABLE_SCOPE_STEPS) return null;
|
|
5739
|
+
if (!node.hasAttribute("data-composition-id")) continue;
|
|
5740
|
+
const compId = node.getAttribute("data-composition-id")?.trim() ?? "";
|
|
5741
|
+
return compId && Object.hasOwn(variablesByComp, compId) ? variablesByComp[compId] : void 0;
|
|
5742
|
+
}
|
|
5743
|
+
return void 0;
|
|
5576
5744
|
}
|
|
5577
|
-
function variableHasValue(element, variableId, variables, variablesByComp) {
|
|
5745
|
+
function variableHasValue(scan, element, variableId, variables, variablesByComp) {
|
|
5578
5746
|
if (variables && Object.hasOwn(variables, variableId)) return true;
|
|
5579
|
-
const scoped = scopedVariablesFor(element, variablesByComp);
|
|
5747
|
+
const scoped = scopedVariablesFor(scan, element, variablesByComp);
|
|
5748
|
+
if (scoped === null) return true;
|
|
5580
5749
|
if (scoped) return Object.hasOwn(scoped, variableId);
|
|
5581
5750
|
for (let scope = element.parentElement; scope; scope = scope.parentElement) {
|
|
5582
|
-
if (
|
|
5583
|
-
if (
|
|
5751
|
+
if (++scan.steps > MAX_VARIABLE_SCOPE_STEPS) return true;
|
|
5752
|
+
if (variableIdsOn(scan, scope).has(variableId)) return true;
|
|
5584
5753
|
}
|
|
5585
|
-
return
|
|
5754
|
+
return variableIdsOn(scan, element.ownerDocument.documentElement).has(variableId);
|
|
5586
5755
|
}
|
|
5587
5756
|
function hasVariableBoundMedia(html, variables, variablesByComp = {}) {
|
|
5588
5757
|
const { document: document2 } = parseHTML6(html);
|
|
5758
|
+
const scan = { ids: /* @__PURE__ */ new Map(), steps: 0 };
|
|
5589
5759
|
return Array.from(
|
|
5590
5760
|
document2.querySelectorAll(
|
|
5591
5761
|
"img[data-var-src], audio[data-var-src], video[data-var-src], source[data-var-src]"
|
|
5592
5762
|
)
|
|
5593
5763
|
).some((element) => {
|
|
5594
5764
|
const variableId = element.getAttribute("data-var-src")?.trim();
|
|
5595
|
-
return Boolean(
|
|
5765
|
+
return Boolean(
|
|
5766
|
+
variableId && variableHasValue(scan, element, variableId, variables, variablesByComp)
|
|
5767
|
+
);
|
|
5596
5768
|
});
|
|
5597
5769
|
}
|
|
5598
5770
|
function authoredMediaStarts(html) {
|
|
@@ -5632,29 +5804,54 @@ function reconcileBrowserMediaEnd(existingEnd, projectedEnd, sourceChanged, dura
|
|
|
5632
5804
|
if (sourceChanged && durationInferred) return projectedEnd;
|
|
5633
5805
|
return existingEnd <= 0 ? projectedEnd : Math.min(existingEnd, projectedEnd);
|
|
5634
5806
|
}
|
|
5807
|
+
var MAX_MEDIA_SELECTOR_WORK = 1e6;
|
|
5808
|
+
var SIBLING_COMBINATOR = /[~+]/;
|
|
5809
|
+
function managedMediaElements(document2) {
|
|
5810
|
+
const managed = [];
|
|
5811
|
+
const pending = [];
|
|
5812
|
+
for (const element of Array.from(document2.children)) pending.push({ element, inMedia: false });
|
|
5813
|
+
for (let next = pending.pop(); next; next = pending.pop()) {
|
|
5814
|
+
const name = next.element.tagName.toLowerCase();
|
|
5815
|
+
const isMedia = name === "video" || name === "audio";
|
|
5816
|
+
if (isMedia || next.inMedia && name === "source") managed.push(next.element);
|
|
5817
|
+
for (const child3 of Array.from(next.element.children)) {
|
|
5818
|
+
pending.push({ element: child3, inMedia: next.inMedia || isMedia });
|
|
5819
|
+
}
|
|
5820
|
+
}
|
|
5821
|
+
return managed;
|
|
5822
|
+
}
|
|
5635
5823
|
function hasRuntimeMediaChanges(html) {
|
|
5636
5824
|
const { document: document2 } = parseHTML6(html);
|
|
5637
5825
|
const scriptBodies = [...document2.querySelectorAll("script")].map(
|
|
5638
5826
|
(script) => script.textContent ?? ""
|
|
5639
5827
|
);
|
|
5640
5828
|
const insertedMedia = scriptBodies.some(
|
|
5641
|
-
(script) => /\bcreateElement\s*\(\s*["'`](?:video|audio)["'`]\s*\)/i.test(script) || /\bnew\s+(?:Audio|Video)\s*\(/i.test(script) ||
|
|
5829
|
+
(script) => /\bcreateElement\s*\(\s*["'`](?:video|audio)["'`]\s*\)/i.test(script) || /\bnew\s+(?:Audio|Video)\s*\(/i.test(script) || hasClosedMediaTag(script)
|
|
5642
5830
|
);
|
|
5643
5831
|
if (insertedMedia) return true;
|
|
5644
|
-
const
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5832
|
+
const managed = managedMediaElements(document2);
|
|
5833
|
+
if (managed.length === 0) return false;
|
|
5834
|
+
const managedIds = new Set(managed.map((element) => element.getAttribute("id")).filter(Boolean));
|
|
5835
|
+
const selectors = /* @__PURE__ */ new Set();
|
|
5836
|
+
let selectorChars = 0;
|
|
5649
5837
|
for (const script of scriptBodies) {
|
|
5650
5838
|
for (const mutation of extractMediaSrcMutations(script)) {
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
if (targets.some(isManagedMedia)) return true;
|
|
5656
|
-
} catch {
|
|
5839
|
+
const id = /^#[A-Za-z_][\w-]*$/.test(mutation.selector) ? mutation.selector.slice(1) : null;
|
|
5840
|
+
if (id) {
|
|
5841
|
+
if (managedIds.has(id)) return true;
|
|
5842
|
+
continue;
|
|
5657
5843
|
}
|
|
5844
|
+
if (selectors.has(mutation.selector)) continue;
|
|
5845
|
+
if (SIBLING_COMBINATOR.test(mutation.selector)) return true;
|
|
5846
|
+
selectors.add(mutation.selector);
|
|
5847
|
+
selectorChars += mutation.selector.length;
|
|
5848
|
+
if (selectorChars * managed.length > MAX_MEDIA_SELECTOR_WORK) return true;
|
|
5849
|
+
}
|
|
5850
|
+
}
|
|
5851
|
+
for (const selector of selectors) {
|
|
5852
|
+
try {
|
|
5853
|
+
if (managed.some((element) => element.matches(selector))) return true;
|
|
5854
|
+
} catch {
|
|
5658
5855
|
}
|
|
5659
5856
|
}
|
|
5660
5857
|
return false;
|
|
@@ -5742,7 +5939,8 @@ async function runProbeStage(input) {
|
|
|
5742
5939
|
port: 0,
|
|
5743
5940
|
preHeadScripts: [VIRTUAL_TIME_SHIM],
|
|
5744
5941
|
fps: job.config.fps,
|
|
5745
|
-
allowOutsideProjectAssets: job.config.allowOutsideProjectAssets
|
|
5942
|
+
allowOutsideProjectAssets: job.config.allowOutsideProjectAssets,
|
|
5943
|
+
includeOutsideScripts: job.config.includeOutsideScripts
|
|
5746
5944
|
});
|
|
5747
5945
|
assertNotAborted();
|
|
5748
5946
|
const motionBlur = job.config.motionBlur;
|
|
@@ -5898,7 +6096,8 @@ async function runProbeStage(input) {
|
|
|
5898
6096
|
resolutions,
|
|
5899
6097
|
projectDir,
|
|
5900
6098
|
join11(workDir, "downloads"),
|
|
5901
|
-
job.config.allowOutsideProjectAssets ? void 0 : projectDir
|
|
6099
|
+
job.config.allowOutsideProjectAssets ? void 0 : projectDir,
|
|
6100
|
+
{ includeScripts: job.config.includeOutsideScripts }
|
|
5902
6101
|
);
|
|
5903
6102
|
assertNotAborted();
|
|
5904
6103
|
composition.videos = compiled.videos;
|
|
@@ -7935,7 +8134,7 @@ import {
|
|
|
7935
8134
|
readdirSync as readdirSync2,
|
|
7936
8135
|
readFileSync as readFileSync6,
|
|
7937
8136
|
rmSync as rmSync4,
|
|
7938
|
-
statSync as
|
|
8137
|
+
statSync as statSync6,
|
|
7939
8138
|
writeFileSync as writeFileSync4
|
|
7940
8139
|
} from "node:fs";
|
|
7941
8140
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
@@ -8064,7 +8263,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
|
8064
8263
|
const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
|
|
8065
8264
|
if (failure) return failure;
|
|
8066
8265
|
}
|
|
8067
|
-
const fileSize = existsSync13(outputPath) ?
|
|
8266
|
+
const fileSize = existsSync13(outputPath) ? statSync6(outputPath).size : 0;
|
|
8068
8267
|
return {
|
|
8069
8268
|
success: true,
|
|
8070
8269
|
outputPath,
|
|
@@ -8087,7 +8286,10 @@ function startEncodeProgress(job, stage, onProgress) {
|
|
|
8087
8286
|
function resolveEngineConfig(input) {
|
|
8088
8287
|
return input.engineConfig ?? input.job.config.producerConfig ?? resolveConfig();
|
|
8089
8288
|
}
|
|
8090
|
-
function
|
|
8289
|
+
function overlapEncoderThreads(workerCount, cpuCount) {
|
|
8290
|
+
return Math.max(1, Math.floor(cpuCount) - Math.floor(workerCount));
|
|
8291
|
+
}
|
|
8292
|
+
function videoEncoderOptions(input, engineCfg, softwareEncoderThreads) {
|
|
8091
8293
|
const { job, preset } = input;
|
|
8092
8294
|
return {
|
|
8093
8295
|
fps: job.config.fps,
|
|
@@ -8107,7 +8309,8 @@ function videoEncoderOptions(input, engineCfg) {
|
|
|
8107
8309
|
// keyframes that survive `-f concat -c copy` at assemble time. In-process
|
|
8108
8310
|
// renders leave both undefined → preserves the existing open-GOP output.
|
|
8109
8311
|
lockGopForChunkConcat: input.lockGopForChunkConcat === true,
|
|
8110
|
-
gopSize: input.gopSize
|
|
8312
|
+
gopSize: input.gopSize,
|
|
8313
|
+
softwareEncoderThreads
|
|
8111
8314
|
};
|
|
8112
8315
|
}
|
|
8113
8316
|
function canEncodeWhileCapturing(input, workerCount, cpuCount) {
|
|
@@ -8123,8 +8326,9 @@ async function readLandedFrame(workerPath, mergedPath) {
|
|
|
8123
8326
|
}
|
|
8124
8327
|
return readFile2(mergedPath);
|
|
8125
8328
|
}
|
|
8126
|
-
function encodeWhileCapturing(input, totalFrames) {
|
|
8329
|
+
function encodeWhileCapturing(input, totalFrames, captureBudget) {
|
|
8127
8330
|
const engineCfg = resolveEngineConfig(input);
|
|
8331
|
+
const softwareEncoderThreads = captureBudget ? overlapEncoderThreads(captureBudget.workerCount, captureBudget.cpuCount) : void 0;
|
|
8128
8332
|
const stop = new AbortController();
|
|
8129
8333
|
const signal = input.abortSignal ? AbortSignal.any([input.abortSignal, stop.signal]) : stop.signal;
|
|
8130
8334
|
const landed = /* @__PURE__ */ new Map();
|
|
@@ -8139,7 +8343,10 @@ function encodeWhileCapturing(input, totalFrames) {
|
|
|
8139
8343
|
let reportFed = null;
|
|
8140
8344
|
const encoder = spawnStreamingEncoder4(
|
|
8141
8345
|
input.videoOnlyPath,
|
|
8142
|
-
{
|
|
8346
|
+
{
|
|
8347
|
+
...videoEncoderOptions(input, engineCfg, softwareEncoderThreads),
|
|
8348
|
+
imageFormat: "jpeg"
|
|
8349
|
+
},
|
|
8143
8350
|
signal,
|
|
8144
8351
|
engineCfg
|
|
8145
8352
|
);
|
|
@@ -8192,7 +8399,7 @@ function encodeWhileCapturing(input, totalFrames) {
|
|
|
8192
8399
|
error: String(failure ?? result?.error)
|
|
8193
8400
|
}
|
|
8194
8401
|
);
|
|
8195
|
-
return runEncodeStage(input);
|
|
8402
|
+
return runEncodeStage({ ...input, hasAudio: false });
|
|
8196
8403
|
},
|
|
8197
8404
|
abort: async () => {
|
|
8198
8405
|
stop.abort();
|
|
@@ -8318,7 +8525,7 @@ function sampleDirectoryBytes(dir) {
|
|
|
8318
8525
|
for (const name of entries) {
|
|
8319
8526
|
const full = join18(current, name);
|
|
8320
8527
|
try {
|
|
8321
|
-
const st =
|
|
8528
|
+
const st = statSync7(full);
|
|
8322
8529
|
if (st.isDirectory()) {
|
|
8323
8530
|
stack.push(full);
|
|
8324
8531
|
} else if (st.isFile()) {
|
|
@@ -8399,7 +8606,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
8399
8606
|
let rangeStart = null;
|
|
8400
8607
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
8401
8608
|
const framePath = join18(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
8402
|
-
const missing = !existsSync14(framePath) ||
|
|
8609
|
+
const missing = !existsSync14(framePath) || statSync7(framePath).size <= 8;
|
|
8403
8610
|
if (missing && rangeStart === null) {
|
|
8404
8611
|
rangeStart = frameIndex;
|
|
8405
8612
|
} else if (!missing && rangeStart !== null) {
|
|
@@ -9002,8 +9209,10 @@ function buildSyntheticRenderJob(input) {
|
|
|
9002
9209
|
producerConfig: input.producerConfig,
|
|
9003
9210
|
variables: input.variables,
|
|
9004
9211
|
strictVariables: input.strictVariables,
|
|
9212
|
+
expectedOutputDimensions: input.expectedOutputDimensions,
|
|
9005
9213
|
pageMotionBlur: input.pageMotionBlur,
|
|
9006
|
-
allowOutsideProjectAssets: input.allowOutsideProjectAssets
|
|
9214
|
+
allowOutsideProjectAssets: input.allowOutsideProjectAssets,
|
|
9215
|
+
includeOutsideScripts: input.includeOutsideScripts
|
|
9007
9216
|
};
|
|
9008
9217
|
return createRenderJob(renderConfig);
|
|
9009
9218
|
}
|
|
@@ -10870,8 +11079,10 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
10870
11079
|
producerConfig: cfg,
|
|
10871
11080
|
variables: config.variables,
|
|
10872
11081
|
strictVariables: config.strictVariables,
|
|
11082
|
+
expectedOutputDimensions: config.expectedOutputDimensions,
|
|
10873
11083
|
pageMotionBlur: config.pageMotionBlur,
|
|
10874
|
-
allowOutsideProjectAssets: options.allowOutsideProjectAssets === true
|
|
11084
|
+
allowOutsideProjectAssets: options.allowOutsideProjectAssets === true,
|
|
11085
|
+
includeOutsideScripts: options.includeOutsideScripts === true
|
|
10875
11086
|
});
|
|
10876
11087
|
const entryFile = config.entryFile ?? "index.html";
|
|
10877
11088
|
const htmlPath = join27(projectDir, entryFile);
|
|
@@ -10892,7 +11103,9 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
10892
11103
|
if (rel === "") return true;
|
|
10893
11104
|
if (leavesRoot(rel)) return false;
|
|
10894
11105
|
if (job.config.allowOutsideProjectAssets) {
|
|
10895
|
-
|
|
11106
|
+
const warn = (line) => log.warn(`[Plan] ${line}`);
|
|
11107
|
+
const policy = { includeScripts: job.config.includeOutsideScripts };
|
|
11108
|
+
if (refusesOutsideLink(projectDir, src, warn, policy)) return false;
|
|
10896
11109
|
} else if (!isSafePath2(projectDir, src)) return false;
|
|
10897
11110
|
const firstSegment = rel.split(sep4, 1)[0];
|
|
10898
11111
|
return firstSegment === void 0 || !PLAN_PROJECT_DIR_SKIP_SEGMENTS.has(firstSegment);
|
|
@@ -11337,6 +11550,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
|
|
|
11337
11550
|
format: config.format,
|
|
11338
11551
|
ffmpegVersion,
|
|
11339
11552
|
producerVersion,
|
|
11553
|
+
...job.outputDimensionsChecked === void 0 ? {} : { outputDimensionsChecked: job.outputDimensionsChecked },
|
|
11340
11554
|
...job.strictVariablesChecked === void 0 ? {} : { strictVariablesChecked: job.strictVariablesChecked }
|
|
11341
11555
|
};
|
|
11342
11556
|
}
|
|
@@ -11381,7 +11595,7 @@ import {
|
|
|
11381
11595
|
readFileSync as readFileSync10,
|
|
11382
11596
|
readdirSync as readdirSync7,
|
|
11383
11597
|
rmSync as rmSync9,
|
|
11384
|
-
statSync as
|
|
11598
|
+
statSync as statSync9,
|
|
11385
11599
|
writeFileSync as writeFileSync10
|
|
11386
11600
|
} from "node:fs";
|
|
11387
11601
|
import { tmpdir } from "node:os";
|
|
@@ -11400,7 +11614,7 @@ import {
|
|
|
11400
11614
|
linkSync as linkSync2,
|
|
11401
11615
|
mkdirSync as mkdirSync11,
|
|
11402
11616
|
rmSync as rmSync8,
|
|
11403
|
-
statSync as
|
|
11617
|
+
statSync as statSync8,
|
|
11404
11618
|
writeFileSync as writeFileSync9
|
|
11405
11619
|
} from "node:fs";
|
|
11406
11620
|
import { renameWithRetry as renameWithRetry9 } from "@hyperframes/engine";
|
|
@@ -11470,7 +11684,7 @@ var LocalPlanV2ArtifactPublisher = class {
|
|
|
11470
11684
|
}
|
|
11471
11685
|
async putBlob(blob) {
|
|
11472
11686
|
const digest = assertPlanV2Sha256(blob.sha256, "published blob sha256");
|
|
11473
|
-
const sourceSize =
|
|
11687
|
+
const sourceSize = statSync8(blob.sourcePath).size;
|
|
11474
11688
|
if (sourceSize !== blob.sizeBytes) {
|
|
11475
11689
|
throw new PlanV2IntegrityError(
|
|
11476
11690
|
`published blob size changed for ${digest}: expected ${blob.sizeBytes}, got ${sourceSize}`
|
|
@@ -11784,7 +11998,7 @@ function publishBlobFor(absolutePath, digests) {
|
|
|
11784
11998
|
return {
|
|
11785
11999
|
sourcePath: absolutePath,
|
|
11786
12000
|
sha256: planFileSha256(absolutePath, digests),
|
|
11787
|
-
sizeBytes:
|
|
12001
|
+
sizeBytes: statSync9(absolutePath).size
|
|
11788
12002
|
};
|
|
11789
12003
|
}
|
|
11790
12004
|
async function putBlobs(publisher, blobs) {
|
|
@@ -11963,7 +12177,10 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
|
|
|
11963
12177
|
sliceChunkAudio: true,
|
|
11964
12178
|
deferAudio: options.deferAudio
|
|
11965
12179
|
});
|
|
11966
|
-
options.onPlanned?.({
|
|
12180
|
+
options.onPlanned?.({
|
|
12181
|
+
strictVariablesChecked: planned.strictVariablesChecked,
|
|
12182
|
+
outputDimensionsChecked: planned.outputDimensionsChecked
|
|
12183
|
+
});
|
|
11967
12184
|
return await publishExecutionPlan(stagingRoot, publisher, { digests, log: config.logger });
|
|
11968
12185
|
} catch (error) {
|
|
11969
12186
|
try {
|
|
@@ -12152,7 +12369,7 @@ function verifyBlob(planV2Dir, artifact) {
|
|
|
12152
12369
|
if (!existsSync21(sourcePath)) {
|
|
12153
12370
|
throw new PlanV2IntegrityError(`missing content-addressed artifact ${artifact.sha256}`);
|
|
12154
12371
|
}
|
|
12155
|
-
const stats =
|
|
12372
|
+
const stats = statSync9(sourcePath);
|
|
12156
12373
|
if (!stats.isFile() || stats.size !== artifact.sizeBytes) {
|
|
12157
12374
|
throw new PlanV2IntegrityError(`artifact size mismatch for ${artifact.path}`);
|
|
12158
12375
|
}
|
|
@@ -12245,7 +12462,7 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
|
|
|
12245
12462
|
for (const artifact of required) {
|
|
12246
12463
|
if (Object.hasOwn(remoteSources, artifact.path)) continue;
|
|
12247
12464
|
const path = join30(planDir, ...artifact.path.split("/"));
|
|
12248
|
-
if (!existsSync21(path) ||
|
|
12465
|
+
if (!existsSync21(path) || statSync9(path).size !== artifact.sizeBytes) {
|
|
12249
12466
|
throw new PlanV2IntegrityError(
|
|
12250
12467
|
`materialized artifact missing or truncated: ${artifact.path}`
|
|
12251
12468
|
);
|
|
@@ -12274,7 +12491,7 @@ import {
|
|
|
12274
12491
|
readFileSync as readFileSync11,
|
|
12275
12492
|
readdirSync as readdirSync8,
|
|
12276
12493
|
rmSync as rmSync10,
|
|
12277
|
-
statSync as
|
|
12494
|
+
statSync as statSync10,
|
|
12278
12495
|
writeFileSync as writeFileSync11
|
|
12279
12496
|
} from "node:fs";
|
|
12280
12497
|
import { basename as basename6, dirname as dirname16, join as join31 } from "node:path";
|
|
@@ -12319,7 +12536,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
12319
12536
|
outputPath,
|
|
12320
12537
|
durationMs: Date.now() - start,
|
|
12321
12538
|
framesEncoded: plan.totalFrames,
|
|
12322
|
-
fileSize:
|
|
12539
|
+
fileSize: statSync10(outputPath).size
|
|
12323
12540
|
};
|
|
12324
12541
|
}
|
|
12325
12542
|
const format = plan.dimensions.format;
|
|
@@ -12366,7 +12583,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
12366
12583
|
});
|
|
12367
12584
|
}
|
|
12368
12585
|
}
|
|
12369
|
-
const fileSize = existsSync22(outputPath) ?
|
|
12586
|
+
const fileSize = existsSync22(outputPath) ? statSync10(outputPath).size : 0;
|
|
12370
12587
|
return {
|
|
12371
12588
|
...referenceBackgroundResult6(plan[REFERENCE_BACKGROUND_FIELD4]),
|
|
12372
12589
|
outputPath,
|
|
@@ -12564,7 +12781,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
12564
12781
|
mkdirSync13(outputPath, { recursive: true });
|
|
12565
12782
|
let globalIdx = 0;
|
|
12566
12783
|
for (const chunkDir of chunkPaths) {
|
|
12567
|
-
if (!
|
|
12784
|
+
if (!statSync10(chunkDir).isDirectory()) {
|
|
12568
12785
|
throw new Error(
|
|
12569
12786
|
`[assemble] png-sequence chunk must be a directory: ${chunkDir} (got a file)`
|
|
12570
12787
|
);
|
|
@@ -12591,7 +12808,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
12591
12808
|
let fileSize = 0;
|
|
12592
12809
|
for (const name of readdirSync8(outputPath)) {
|
|
12593
12810
|
try {
|
|
12594
|
-
fileSize +=
|
|
12811
|
+
fileSize += statSync10(join31(outputPath, name)).size;
|
|
12595
12812
|
} catch {
|
|
12596
12813
|
}
|
|
12597
12814
|
}
|
|
@@ -12622,7 +12839,7 @@ import {
|
|
|
12622
12839
|
probeBeginFrameLiveness as probeBeginFrameLiveness2,
|
|
12623
12840
|
readWebGlVendorInfoFromCanvas,
|
|
12624
12841
|
resolveConfig as resolveConfig5,
|
|
12625
|
-
usableCpuCount as
|
|
12842
|
+
usableCpuCount as usableCpuCount3
|
|
12626
12843
|
} from "@hyperframes/engine";
|
|
12627
12844
|
import { readWebGlVendorInfoFromCanvas as readWebGlVendorInfoFromCanvas2 } from "@hyperframes/engine";
|
|
12628
12845
|
var LEGACY_DISTRIBUTED_VP9_CPU_USED = 2;
|
|
@@ -13152,7 +13369,10 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
13152
13369
|
const captureSession = session;
|
|
13153
13370
|
session = null;
|
|
13154
13371
|
verifyStarted = Date.now();
|
|
13155
|
-
overlap.current = canEncodeWhileCapturing(encodeInput, chunkWorkerCount,
|
|
13372
|
+
overlap.current = canEncodeWhileCapturing(encodeInput, chunkWorkerCount, usableCpuCount3()) ? encodeWhileCapturing(encodeInput, framesInChunk, {
|
|
13373
|
+
workerCount: chunkWorkerCount,
|
|
13374
|
+
cpuCount: usableCpuCount3()
|
|
13375
|
+
}) : null;
|
|
13156
13376
|
await observeRenderStage(
|
|
13157
13377
|
new RenderObservabilityRecorder({ pipelineStartMs: start, log }),
|
|
13158
13378
|
"capture_chunk",
|
|
@@ -13388,6 +13608,12 @@ function validateDistributedRenderConfig(config) {
|
|
|
13388
13608
|
`must be one of ${DISTRIBUTED_FPS2.join(", ")}; got ${String(config.fps)}`
|
|
13389
13609
|
);
|
|
13390
13610
|
}
|
|
13611
|
+
if (config.expectedOutputDimensions !== void 0 && !isExpectedOutputDimensions(config.expectedOutputDimensions)) {
|
|
13612
|
+
throw new InvalidConfigError(
|
|
13613
|
+
"config.expectedOutputDimensions",
|
|
13614
|
+
"must contain positive integer width and height"
|
|
13615
|
+
);
|
|
13616
|
+
}
|
|
13391
13617
|
validateIntDimension("config.width", config.width);
|
|
13392
13618
|
validateIntDimension("config.height", config.height);
|
|
13393
13619
|
if (config.pageMotionBlur !== void 0 && config.pageMotionBlur !== "off") {
|
|
@@ -13643,28 +13869,33 @@ function validateIntDimension(field, value) {
|
|
|
13643
13869
|
}
|
|
13644
13870
|
|
|
13645
13871
|
// src/services/distributed/projectHash.ts
|
|
13646
|
-
import { closeSync as closeSync5, openSync as openSync5, readdirSync as readdirSync10, readSync as readSync4, realpathSync as realpathSync2, statSync as
|
|
13872
|
+
import { closeSync as closeSync5, openSync as openSync5, readdirSync as readdirSync10, readSync as readSync4, realpathSync as realpathSync2, statSync as statSync11 } from "node:fs";
|
|
13647
13873
|
import { createHash as createHash9 } from "node:crypto";
|
|
13648
|
-
import { join as join34 } from "node:path";
|
|
13874
|
+
import { join as join34, sep as sep6 } from "node:path";
|
|
13649
13875
|
import { isPrivateFileUnder as isPrivateFileUnder3, isStudioPrivatePath as isStudioPrivatePath3 } from "@hyperframes/core/safe-path";
|
|
13650
13876
|
var SITE_ID_SCHEME = "site-v2\0";
|
|
13651
13877
|
var READ_CHUNK_BYTES = 256 * 1024;
|
|
13652
13878
|
var isPrivateSitePath = (relPath) => isStudioPrivatePath3(relPath);
|
|
13653
13879
|
function statEntry(full, relPath) {
|
|
13654
13880
|
try {
|
|
13655
|
-
return
|
|
13881
|
+
return statSync11(full);
|
|
13656
13882
|
} catch (err) {
|
|
13657
13883
|
throw new Error(`[listSiteFiles] cannot read ${relPath} (dangling symlink?)`, { cause: err });
|
|
13658
13884
|
}
|
|
13659
13885
|
}
|
|
13660
|
-
function listSiteFiles(projectDir, onPrivate) {
|
|
13886
|
+
function listSiteFiles(projectDir, onPrivate, onOutside = () => {
|
|
13887
|
+
}) {
|
|
13661
13888
|
const files = [];
|
|
13662
|
-
const
|
|
13889
|
+
const root = realpathSync2(projectDir);
|
|
13890
|
+
const ancestors = /* @__PURE__ */ new Set([root]);
|
|
13663
13891
|
function visit(full, relPath) {
|
|
13664
13892
|
if (isPrivateFileUnder3(projectDir, full, isStudioPrivatePath3)) return void onPrivate?.(relPath);
|
|
13665
13893
|
const stat = statEntry(full, relPath);
|
|
13894
|
+
if (!stat.isFile() && !stat.isDirectory()) return;
|
|
13895
|
+
if (onOutside !== "include" && outsideFolder(root, realpathSync2(full))) {
|
|
13896
|
+
return void onOutside(relPath);
|
|
13897
|
+
}
|
|
13666
13898
|
if (stat.isFile()) return void files.push(relPath);
|
|
13667
|
-
if (!stat.isDirectory()) return;
|
|
13668
13899
|
const real = realpathSync2(full);
|
|
13669
13900
|
if (ancestors.has(real)) return;
|
|
13670
13901
|
ancestors.add(real);
|
|
@@ -13680,20 +13911,31 @@ function listSiteFiles(projectDir, onPrivate) {
|
|
|
13680
13911
|
walk(projectDir, "");
|
|
13681
13912
|
return files;
|
|
13682
13913
|
}
|
|
13914
|
+
var outsideFolder = (root, real) => real !== root && !real.startsWith(root + sep6);
|
|
13683
13915
|
var printablePath = (path) => [...path].map((ch) => {
|
|
13684
13916
|
const code = ch.charCodeAt(0);
|
|
13685
13917
|
const control = code < 32 && code !== 9 || code >= 127 && code <= 159;
|
|
13686
13918
|
return control ? `\\x${code.toString(16).padStart(2, "0")}` : ch;
|
|
13687
13919
|
}).join("");
|
|
13688
|
-
function listSiteFilesForUpload(projectDir, onNotice) {
|
|
13920
|
+
function listSiteFilesForUpload(projectDir, onNotice = (message) => console.warn(message), includeOutsideFiles = false) {
|
|
13689
13921
|
const leftOut = [];
|
|
13690
|
-
const
|
|
13922
|
+
const outside = [];
|
|
13923
|
+
const files = listSiteFiles(
|
|
13924
|
+
projectDir,
|
|
13925
|
+
(path) => leftOut.push(path),
|
|
13926
|
+
includeOutsideFiles ? "include" : (path) => outside.push(path)
|
|
13927
|
+
);
|
|
13691
13928
|
if (leftOut.length > 0) {
|
|
13692
13929
|
const more = leftOut.length > 5 ? ` and ${leftOut.length - 5} more` : "";
|
|
13693
|
-
onNotice
|
|
13930
|
+
onNotice(
|
|
13694
13931
|
`[deploySite] left out private files no composition loads (env, Git, credentials, tool state): ${leftOut.slice(0, 5).map(printablePath).join(", ")}${more}`
|
|
13695
13932
|
);
|
|
13696
13933
|
}
|
|
13934
|
+
if (outside.length > 0) {
|
|
13935
|
+
onNotice(
|
|
13936
|
+
`[deploySite] left out files linked in from outside the project: ${outside.map(printablePath).join(", ")}. Pass --include-outside-files (includeOutsideFiles in the SDK) to upload them.`
|
|
13937
|
+
);
|
|
13938
|
+
}
|
|
13697
13939
|
return files;
|
|
13698
13940
|
}
|
|
13699
13941
|
function hashProjectDir(projectDir, files = listSiteFiles(projectDir)) {
|