@hyperframes/producer 0.9.59 → 0.9.61
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 +380 -150
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +64 -64
- package/dist/index.js +407 -162
- package/dist/public-server.js +362 -143
- 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 +9 -4
- 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 +26 -1
- 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/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
mkdirSync as mkdirSync12,
|
|
14
14
|
readdirSync as readdirSync6,
|
|
15
15
|
rmSync as rmSync12,
|
|
16
|
-
statSync as
|
|
16
|
+
statSync as statSync11,
|
|
17
17
|
writeFileSync as writeFileSync7,
|
|
18
18
|
copyFileSync as copyFileSync5,
|
|
19
19
|
appendFileSync
|
|
@@ -181,6 +181,10 @@ function stripPreloadNone(html) {
|
|
|
181
181
|
return attr && attr.index < tagEnd ? [attr.index, attr.index + attr[0].length] : void 0;
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
|
+
function hasClosedMediaTag(text) {
|
|
185
|
+
const open2 = /<(?:video|audio)\b/i.exec(text);
|
|
186
|
+
return open2 !== null && text.includes(">", open2.index + open2[0].length);
|
|
187
|
+
}
|
|
184
188
|
var REMOTE_SRC_TAGS = {
|
|
185
189
|
media: { opener: "<(?:video|audio)\\b", attr: /\bsrc\s*=\s*["'](https?:\/\/)/gi },
|
|
186
190
|
source: { opener: "<source\\b", attr: /\bsrc\s*=\s*["'](https?:\/\/)/gi },
|
|
@@ -529,6 +533,7 @@ import { isSafePath } from "@hyperframes/core/safe-path";
|
|
|
529
533
|
import {
|
|
530
534
|
isCopiedOutsideFileType,
|
|
531
535
|
isPrivateOutsideFile,
|
|
536
|
+
isUploadedOutsideFileType,
|
|
532
537
|
leftOutWarning,
|
|
533
538
|
linksOutside
|
|
534
539
|
} from "@hyperframes/studio-server/outside-file";
|
|
@@ -550,15 +555,17 @@ function isPathInside(childPath, parentPath, options = {}) {
|
|
|
550
555
|
function escapesAssetRoot(path, assetRoot) {
|
|
551
556
|
return assetRoot !== void 0 && !isSafePath(assetRoot, path);
|
|
552
557
|
}
|
|
553
|
-
function outsideAssetRefusal(projectDir, path) {
|
|
558
|
+
function outsideAssetRefusal(projectDir, path, policy = {}) {
|
|
554
559
|
if (!linksOutside(projectDir, path)) return null;
|
|
555
560
|
if (isPrivateOutsideFile(projectDir, path)) return "blocklisted";
|
|
556
561
|
const folder = statSync(path, { throwIfNoEntry: false })?.isDirectory();
|
|
557
|
-
|
|
562
|
+
if (folder || isUploadedOutsideFileType(path)) return null;
|
|
563
|
+
if (!isCopiedOutsideFileType(path)) return "file_type";
|
|
564
|
+
return policy.includeScripts ? null : "script";
|
|
558
565
|
}
|
|
559
566
|
var leftOutOfRender = (file, reference, reason) => leftOutWarning(file, reference, reason, "render");
|
|
560
|
-
function refusesOutsideLink(projectDir, path, warn) {
|
|
561
|
-
const refusal = outsideAssetRefusal(projectDir, path);
|
|
567
|
+
function refusesOutsideLink(projectDir, path, warn, policy = {}) {
|
|
568
|
+
const refusal = outsideAssetRefusal(projectDir, path, policy);
|
|
562
569
|
if (!refusal) return false;
|
|
563
570
|
const file = nodeRelative(projectDir, path).split(sep).join("/");
|
|
564
571
|
warn(leftOutOfRender(file, realFilePath(path), refusal));
|
|
@@ -1141,7 +1148,8 @@ function createFileServer(options) {
|
|
|
1141
1148
|
compiledDir,
|
|
1142
1149
|
port = 0,
|
|
1143
1150
|
stripEmbeddedRuntime = true,
|
|
1144
|
-
allowOutsideProjectAssets = false
|
|
1151
|
+
allowOutsideProjectAssets = false,
|
|
1152
|
+
includeOutsideScripts = false
|
|
1145
1153
|
} = options;
|
|
1146
1154
|
const preHeadScripts = [
|
|
1147
1155
|
HF_EARLY_STUB,
|
|
@@ -1152,6 +1160,7 @@ function createFileServer(options) {
|
|
|
1152
1160
|
const bodyScripts = options.bodyScripts ?? [buildRenderModeScript(options.fps), HF_BRIDGE_SCRIPT];
|
|
1153
1161
|
const app = new Hono();
|
|
1154
1162
|
const warnLeftOut = (line) => console.warn(`[FileServer] ${terminalText2(line)}`);
|
|
1163
|
+
const outsidePolicy = { includeScripts: includeOutsideScripts };
|
|
1155
1164
|
let listeningPort = -1;
|
|
1156
1165
|
app.use(async function loadEachFileOnlyAsItsNamedType(c, next) {
|
|
1157
1166
|
await next();
|
|
@@ -1169,7 +1178,7 @@ function createFileServer(options) {
|
|
|
1169
1178
|
if (!isPathInside2(candidate, root, { resolveSymlinks })) continue;
|
|
1170
1179
|
if (isPrivateFileUnder(root, candidate, isStudioPrivatePath)) continue;
|
|
1171
1180
|
const checksLinks = allowOutsideProjectAssets && root !== compiledDir;
|
|
1172
|
-
if (checksLinks && refusesOutsideLink(root, candidate, warnLeftOut)) continue;
|
|
1181
|
+
if (checksLinks && refusesOutsideLink(root, candidate, warnLeftOut, outsidePolicy)) continue;
|
|
1173
1182
|
file = openRegularFile(candidate);
|
|
1174
1183
|
if (file) break;
|
|
1175
1184
|
}
|
|
@@ -2733,9 +2742,10 @@ function frameWeightedAvgMs(perfs, avgOf) {
|
|
|
2733
2742
|
function aggregateDedup(perfs) {
|
|
2734
2743
|
if (perfs.length === 0) return void 0;
|
|
2735
2744
|
const armed = perfs.some((p) => p.staticDedupArmed);
|
|
2736
|
-
const
|
|
2737
|
-
...new Set(
|
|
2738
|
-
|
|
2745
|
+
const distinctUnarmed = (values) => {
|
|
2746
|
+
const distinct = armed ? [] : [...new Set(values.filter((v) => !!v))].sort();
|
|
2747
|
+
return distinct.length > 0 ? distinct.join("|") : void 0;
|
|
2748
|
+
};
|
|
2739
2749
|
const verificationPerfs = perfs.filter((perf) => perf.staticDedupVerificationOutcome);
|
|
2740
2750
|
const verificationOutcomes = [
|
|
2741
2751
|
...new Set(
|
|
@@ -2747,7 +2757,8 @@ function aggregateDedup(perfs) {
|
|
|
2747
2757
|
armed,
|
|
2748
2758
|
predictedFrames: perfs.reduce((sum2, p) => sum2 + (p.staticDedupPredicted ?? 0), 0),
|
|
2749
2759
|
reusedFrames: perfs.reduce((sum2, p) => sum2 + (p.staticDedupReused ?? 0), 0),
|
|
2750
|
-
skipReason:
|
|
2760
|
+
skipReason: distinctUnarmed(perfs.map((p) => p.staticDedupSkipReason)),
|
|
2761
|
+
ineligibleCause: distinctUnarmed(perfs.map((p) => p.staticDedupIneligibleCause)),
|
|
2751
2762
|
...verificationPerfs.length === 0 ? {} : {
|
|
2752
2763
|
verifiedFrames: verificationPerfs.reduce(
|
|
2753
2764
|
(sum2, perf) => sum2 + (perf.staticDedupVerified ?? 0),
|
|
@@ -6877,6 +6888,22 @@ function countAuthoredTimedClips(html) {
|
|
|
6877
6888
|
return document2.querySelectorAll("[data-start]").length;
|
|
6878
6889
|
}
|
|
6879
6890
|
|
|
6891
|
+
// src/services/render/outputDimensions.ts
|
|
6892
|
+
function isExpectedOutputDimensions(value) {
|
|
6893
|
+
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;
|
|
6894
|
+
}
|
|
6895
|
+
var OutputDimensionsMismatchError = class extends Error {
|
|
6896
|
+
code = "OUTPUT_DIMENSIONS_MISMATCH";
|
|
6897
|
+
constructor() {
|
|
6898
|
+
super("Compiled output dimensions do not match the requested render dimensions.");
|
|
6899
|
+
}
|
|
6900
|
+
};
|
|
6901
|
+
function requireOutputDimensions(expected, width, height) {
|
|
6902
|
+
if (expected !== void 0 && (!isExpectedOutputDimensions(expected) || expected.width !== width || expected.height !== height)) {
|
|
6903
|
+
throw new OutputDimensionsMismatchError();
|
|
6904
|
+
}
|
|
6905
|
+
}
|
|
6906
|
+
|
|
6880
6907
|
// src/services/render/stages/compileStage.ts
|
|
6881
6908
|
import { existsSync as existsSync12, writeFileSync as writeFileSync5 } from "node:fs";
|
|
6882
6909
|
import { join as join20, relative as relative3 } from "node:path";
|
|
@@ -6885,6 +6912,61 @@ import { suggestMatchingPreset } from "@hyperframes/core";
|
|
|
6885
6912
|
import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
|
|
6886
6913
|
import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolution";
|
|
6887
6914
|
|
|
6915
|
+
// src/services/compositionSizeLimit.ts
|
|
6916
|
+
import { statSync as statSync7 } from "node:fs";
|
|
6917
|
+
var MAX_COMPOSITION_HTML_BYTES = 16 * 1024 * 1024;
|
|
6918
|
+
var COMPOSITION_TOO_LARGE = "COMPOSITION_TOO_LARGE";
|
|
6919
|
+
var megabytes = (bytes) => `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
6920
|
+
var MAX_EXPANDED_COMPOSITION_BYTES = 2 * MAX_COMPOSITION_HTML_BYTES;
|
|
6921
|
+
var MAX_COMPOSITION_MOUNTS = 1e4;
|
|
6922
|
+
var CompositionTooLargeError = class extends Error {
|
|
6923
|
+
constructor(message, publicMetadata) {
|
|
6924
|
+
super(message);
|
|
6925
|
+
this.publicMetadata = publicMetadata;
|
|
6926
|
+
this.name = "CompositionTooLargeError";
|
|
6927
|
+
}
|
|
6928
|
+
publicMetadata;
|
|
6929
|
+
code = COMPOSITION_TOO_LARGE;
|
|
6930
|
+
// The producer server reads these off the error for the wire envelope.
|
|
6931
|
+
owner = "user";
|
|
6932
|
+
retryable = false;
|
|
6933
|
+
};
|
|
6934
|
+
var fileTooLarge = (file, bytes) => new CompositionTooLargeError(
|
|
6935
|
+
`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.`,
|
|
6936
|
+
{ bytes, limitBytes: MAX_COMPOSITION_HTML_BYTES }
|
|
6937
|
+
);
|
|
6938
|
+
var CompositionExpansionBudget = class {
|
|
6939
|
+
bytes = 0;
|
|
6940
|
+
mounts = 0;
|
|
6941
|
+
charge(file, bytes) {
|
|
6942
|
+
this.bytes += bytes;
|
|
6943
|
+
this.mounts += 1;
|
|
6944
|
+
if (this.bytes <= MAX_EXPANDED_COMPOSITION_BYTES && this.mounts <= MAX_COMPOSITION_MOUNTS) {
|
|
6945
|
+
return;
|
|
6946
|
+
}
|
|
6947
|
+
throw new CompositionTooLargeError(
|
|
6948
|
+
`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.`,
|
|
6949
|
+
{
|
|
6950
|
+
bytes: this.bytes,
|
|
6951
|
+
limitBytes: MAX_EXPANDED_COMPOSITION_BYTES,
|
|
6952
|
+
mounts: this.mounts,
|
|
6953
|
+
exceeded: this.mounts > MAX_COMPOSITION_MOUNTS ? "mounts" : "bytes"
|
|
6954
|
+
}
|
|
6955
|
+
);
|
|
6956
|
+
}
|
|
6957
|
+
};
|
|
6958
|
+
function assertCompositionFileSize(path, file) {
|
|
6959
|
+
let bytes;
|
|
6960
|
+
try {
|
|
6961
|
+
const stats = statSync7(path);
|
|
6962
|
+
if (!stats.isFile()) return;
|
|
6963
|
+
bytes = stats.size;
|
|
6964
|
+
} catch {
|
|
6965
|
+
return;
|
|
6966
|
+
}
|
|
6967
|
+
if (bytes > MAX_COMPOSITION_HTML_BYTES) throw fileTooLarge(file, bytes);
|
|
6968
|
+
}
|
|
6969
|
+
|
|
6888
6970
|
// src/services/htmlCompiler.ts
|
|
6889
6971
|
import { decodedUrlPath } from "@hyperframes/parsers/asset-paths";
|
|
6890
6972
|
import {
|
|
@@ -6971,11 +7053,13 @@ import {
|
|
|
6971
7053
|
import {
|
|
6972
7054
|
isUnresolvedAssetPlaceholder,
|
|
6973
7055
|
namesAnotherNetworkRoot as namesAnotherNetworkRoot2,
|
|
7056
|
+
projectAssetExists,
|
|
6974
7057
|
readProjectFile,
|
|
6975
7058
|
readTextFile,
|
|
6976
7059
|
resolveCompositionSrc
|
|
6977
7060
|
} from "@hyperframes/parsers/asset-resolution";
|
|
6978
7061
|
import { isPrivateFileUnder as isPrivateFileUnder2, isStudioPrivatePath as isStudioPrivatePath2 } from "@hyperframes/core/safe-path";
|
|
7062
|
+
import { linksOutside as linksOutside2 } from "@hyperframes/studio-server/outside-file";
|
|
6979
7063
|
|
|
6980
7064
|
// src/services/renderMediaCollector.ts
|
|
6981
7065
|
import { parseHTML as parseHTML2 } from "linkedom";
|
|
@@ -7169,7 +7253,7 @@ import {
|
|
|
7169
7253
|
|
|
7170
7254
|
// src/services/animatedGifPrep.ts
|
|
7171
7255
|
import { createHash as createHash4 } from "node:crypto";
|
|
7172
|
-
import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as
|
|
7256
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync8 } from "node:fs";
|
|
7173
7257
|
import { dirname as dirname6, isAbsolute as isAbsolute2, join as join16, resolve as resolve5 } from "node:path";
|
|
7174
7258
|
import { parseHTML as parseHTML3 } from "linkedom";
|
|
7175
7259
|
import { parseAnimatedGifMetadata } from "@hyperframes/core";
|
|
@@ -7222,12 +7306,13 @@ function resolveLocalImageSourcePath(src, options) {
|
|
|
7222
7306
|
isAbsolute2(basePath) ? basePath : resolve5(options.projectDir, projectRelative),
|
|
7223
7307
|
resolve5(options.downloadDir, normalizedBase)
|
|
7224
7308
|
];
|
|
7225
|
-
const
|
|
7309
|
+
const assetRoot = options.allowOutsideFiles ? void 0 : options.projectDir;
|
|
7310
|
+
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));
|
|
7226
7311
|
return candidates.find((candidate) => allowed(candidate) && existsSync9(candidate)) ?? null;
|
|
7227
7312
|
}
|
|
7228
7313
|
function isUsableFile(path) {
|
|
7229
7314
|
try {
|
|
7230
|
-
const stat =
|
|
7315
|
+
const stat = statSync8(path);
|
|
7231
7316
|
return stat.isFile() && stat.size > 0;
|
|
7232
7317
|
} catch {
|
|
7233
7318
|
return false;
|
|
@@ -7492,7 +7577,7 @@ import {
|
|
|
7492
7577
|
readFileSync as readFileSync7,
|
|
7493
7578
|
readSync as readSync3,
|
|
7494
7579
|
rmSync as rmSync10,
|
|
7495
|
-
statSync as
|
|
7580
|
+
statSync as statSync9,
|
|
7496
7581
|
writeFileSync as writeFileSync4
|
|
7497
7582
|
} from "node:fs";
|
|
7498
7583
|
import { dirname as dirname7, join as join17, resolve as resolve6 } from "node:path";
|
|
@@ -7736,7 +7821,7 @@ function resolveImageSource(src, options) {
|
|
|
7736
7821
|
}
|
|
7737
7822
|
function isUsableFile2(path) {
|
|
7738
7823
|
try {
|
|
7739
|
-
return
|
|
7824
|
+
return statSync9(path).size > 0;
|
|
7740
7825
|
} catch {
|
|
7741
7826
|
return false;
|
|
7742
7827
|
}
|
|
@@ -8015,7 +8100,7 @@ Check that each file referenced by data-composition-src contains valid HTML with
|
|
|
8015
8100
|
};
|
|
8016
8101
|
function normalizeCompositionSrcs(html, projectDir) {
|
|
8017
8102
|
return html.replace(/(\bdata-composition-src=)(["'])([^"']*)\2/g, (whole, name, quote, value) => {
|
|
8018
|
-
if (!value.includes("%") &&
|
|
8103
|
+
if (!value.includes("%") && !/^\.?[\\/]/.test(value)) return whole;
|
|
8019
8104
|
const file = resolveCompositionSrc(projectDir, value);
|
|
8020
8105
|
if (file === null) return whole;
|
|
8021
8106
|
return `${name}${quote}${relative2(projectDir, file).split(sep3).join("/")}${quote}`;
|
|
@@ -8031,68 +8116,94 @@ function resolveCompositionFile(projectDir, src, assetRoot) {
|
|
|
8031
8116
|
const file = resolveCompositionPath(projectDir, src, assetRoot);
|
|
8032
8117
|
return file !== null && COMPOSITION_FILE.test(file) ? file : null;
|
|
8033
8118
|
}
|
|
8119
|
+
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";
|
|
8120
|
+
var runsOutsideMarkupUnasked = (projectDir, filePath, assetRoot, outsideFiles) => assetRoot === void 0 && !outsideFiles.includeScripts && linksOutside2(projectDir, filePath);
|
|
8121
|
+
function assertOutsideMarkupAsked(projectDir, filePath, srcPath, assetRoot, outsideFiles) {
|
|
8122
|
+
if (runsOutsideMarkupUnasked(projectDir, filePath, assetRoot, outsideFiles)) {
|
|
8123
|
+
throw new EmptyCompositionError([{ srcPath, detail: OUTSIDE_COMPOSITION_NEEDS_FLAG }]);
|
|
8124
|
+
}
|
|
8125
|
+
}
|
|
8034
8126
|
var isPrivateCompositionFile = (projectDir, filePath) => isPrivateFileUnder2(projectDir, filePath, isStudioPrivatePath2);
|
|
8035
|
-
|
|
8127
|
+
var mountSrcsUnder = (root) => [...root.querySelectorAll("[data-composition-src]")].map((el) => el.getAttribute("data-composition-src")).filter((srcPath) => !!srcPath && !isUnresolvedAssetPlaceholder(srcPath));
|
|
8128
|
+
function compositionSrcsIn(html) {
|
|
8036
8129
|
const { document: document2 } = parseHTML5(html);
|
|
8037
|
-
const
|
|
8038
|
-
const
|
|
8039
|
-
for (
|
|
8040
|
-
|
|
8041
|
-
|
|
8042
|
-
|
|
8130
|
+
const templated = [];
|
|
8131
|
+
const templates = [...document2.querySelectorAll("template")];
|
|
8132
|
+
for (let template = templates.pop(); template; template = templates.pop()) {
|
|
8133
|
+
templated.push(...mountSrcsUnder(template.content));
|
|
8134
|
+
templates.push(...template.content.querySelectorAll("template"));
|
|
8135
|
+
}
|
|
8136
|
+
return { mounts: mountSrcsUnder(document2), templated };
|
|
8137
|
+
}
|
|
8138
|
+
function compositionPathProblem(projectDir, filePath, assetRoot, outsideFiles) {
|
|
8139
|
+
if (outsideAssetRefusal(projectDir, filePath) === "blocklisted") {
|
|
8140
|
+
return "it is outside the project in a private location";
|
|
8141
|
+
}
|
|
8142
|
+
if (runsOutsideMarkupUnasked(projectDir, filePath, assetRoot, outsideFiles)) {
|
|
8143
|
+
return OUTSIDE_COMPOSITION_NEEDS_FLAG;
|
|
8144
|
+
}
|
|
8145
|
+
if (isPrivateCompositionFile(projectDir, filePath)) {
|
|
8146
|
+
return "it is git metadata, an env file or a private tool record";
|
|
8147
|
+
}
|
|
8148
|
+
return COMPOSITION_FILE.test(filePath) ? null : NOT_A_COMPOSITION_FILE;
|
|
8149
|
+
}
|
|
8150
|
+
function readSubCompositionFile(filePath, srcPath) {
|
|
8151
|
+
assertCompositionFileSize(filePath, srcPath);
|
|
8152
|
+
const read = readProjectFile(filePath);
|
|
8153
|
+
if (read.kind === "missing") return { detail: "the file does not exist" };
|
|
8154
|
+
if (read.kind === "folder") return { detail: "it is a folder, not an HTML file" };
|
|
8155
|
+
const validity = checkSubCompositionUsability(read.text, parseSubCompHtmlForValidity);
|
|
8156
|
+
if (!validity.ok)
|
|
8157
|
+
return { detail: validity.detail ?? "the file is empty or could not be parsed" };
|
|
8158
|
+
return { bytes: Buffer.byteLength(read.text), ...compositionSrcsIn(read.text) };
|
|
8159
|
+
}
|
|
8160
|
+
function assertSubCompositionsUsable(html, projectDir, assetRoot, outsideFiles) {
|
|
8161
|
+
const budget = new CompositionExpansionBudget();
|
|
8162
|
+
const files = /* @__PURE__ */ new Map();
|
|
8163
|
+
const problems = /* @__PURE__ */ new Map();
|
|
8164
|
+
const report = (srcPath, detail) => problems.set(`${srcPath}\0${detail}`, { srcPath, detail });
|
|
8165
|
+
const chain = /* @__PURE__ */ new Set();
|
|
8166
|
+
const paths = /* @__PURE__ */ new Map();
|
|
8167
|
+
const resolveMount = (srcPath) => {
|
|
8043
8168
|
const filePath = resolveCompositionPath(projectDir, srcPath, assetRoot);
|
|
8044
|
-
if (filePath === null) {
|
|
8045
|
-
|
|
8046
|
-
|
|
8047
|
-
|
|
8048
|
-
|
|
8049
|
-
|
|
8050
|
-
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
if (read.kind === "missing") {
|
|
8066
|
-
problems.push({ srcPath, detail: "the file does not exist" });
|
|
8067
|
-
continue;
|
|
8068
|
-
}
|
|
8069
|
-
if (read.kind === "folder") {
|
|
8070
|
-
problems.push({ srcPath, detail: "it is a folder, not an HTML file" });
|
|
8071
|
-
continue;
|
|
8072
|
-
}
|
|
8073
|
-
const fileHtml = read.text;
|
|
8074
|
-
const validity = checkSubCompositionUsability(fileHtml, parseSubCompHtmlForValidity);
|
|
8075
|
-
if (!validity.ok) {
|
|
8076
|
-
problems.push({
|
|
8077
|
-
srcPath,
|
|
8078
|
-
detail: validity.detail ?? "the file is empty or could not be parsed"
|
|
8079
|
-
});
|
|
8080
|
-
continue;
|
|
8081
|
-
}
|
|
8082
|
-
const nestedVisited = new Set(visited);
|
|
8083
|
-
nestedVisited.add(filePath);
|
|
8084
|
-
try {
|
|
8085
|
-
assertSubCompositionsUsable(fileHtml, projectDir, assetRoot, nestedVisited);
|
|
8086
|
-
} catch (err) {
|
|
8087
|
-
if (err instanceof EmptyCompositionError) {
|
|
8088
|
-
problems.push(...err.problems);
|
|
8089
|
-
} else {
|
|
8090
|
-
throw err;
|
|
8169
|
+
if (filePath === null) return { detail: "it is outside the project folder" };
|
|
8170
|
+
const detail = compositionPathProblem(projectDir, filePath, assetRoot, outsideFiles);
|
|
8171
|
+
return detail ? { detail } : { filePath };
|
|
8172
|
+
};
|
|
8173
|
+
const walk = (srcPaths, quiet) => {
|
|
8174
|
+
for (const srcPath of srcPaths) {
|
|
8175
|
+
let resolved = paths.get(srcPath);
|
|
8176
|
+
if (!resolved) {
|
|
8177
|
+
resolved = resolveMount(srcPath);
|
|
8178
|
+
paths.set(srcPath, resolved);
|
|
8179
|
+
}
|
|
8180
|
+
if ("detail" in resolved) {
|
|
8181
|
+
if (!quiet) report(srcPath, resolved.detail);
|
|
8182
|
+
continue;
|
|
8183
|
+
}
|
|
8184
|
+
const { filePath } = resolved;
|
|
8185
|
+
if (chain.has(filePath)) continue;
|
|
8186
|
+
let file = files.get(filePath);
|
|
8187
|
+
if (!file) {
|
|
8188
|
+
file = readSubCompositionFile(filePath, srcPath);
|
|
8189
|
+
files.set(filePath, file);
|
|
8091
8190
|
}
|
|
8191
|
+
if ("detail" in file) {
|
|
8192
|
+
if (!quiet) report(srcPath, file.detail);
|
|
8193
|
+
continue;
|
|
8194
|
+
}
|
|
8195
|
+
budget.charge(srcPath, file.bytes);
|
|
8196
|
+
chain.add(filePath);
|
|
8197
|
+
walk(file.mounts, quiet);
|
|
8198
|
+
walk(file.templated, true);
|
|
8199
|
+
chain.delete(filePath);
|
|
8092
8200
|
}
|
|
8093
|
-
}
|
|
8094
|
-
|
|
8095
|
-
|
|
8201
|
+
};
|
|
8202
|
+
const entry = compositionSrcsIn(html);
|
|
8203
|
+
walk(entry.mounts, false);
|
|
8204
|
+
walk(entry.templated, true);
|
|
8205
|
+
if (problems.size > 0) {
|
|
8206
|
+
throw new EmptyCompositionError([...problems.values()]);
|
|
8096
8207
|
}
|
|
8097
8208
|
}
|
|
8098
8209
|
var COMPILER_MOUNT_BLOCK_START = "/* __HF_COMPILER_MOUNT_START__ */";
|
|
@@ -8347,7 +8458,7 @@ async function compileHtmlFile(html, projectDir, baseDir, downloadDir, log, urlB
|
|
|
8347
8458
|
compiledHtml = stripCrossoriginAttr(compiledHtml, "audio");
|
|
8348
8459
|
return { html: compiledHtml, unresolvedCompositions };
|
|
8349
8460
|
}
|
|
8350
|
-
async function parseSubCompositions(html, projectDir, downloadDir, visited = /* @__PURE__ */ new Set(), urlByAbsentLocalPath, probes, assetRoot) {
|
|
8461
|
+
async function parseSubCompositions(html, projectDir, downloadDir, visited = /* @__PURE__ */ new Set(), urlByAbsentLocalPath, probes, assetRoot, outsideFiles = {}, compiledSrcs = /* @__PURE__ */ new Set()) {
|
|
8351
8462
|
const subCompositions = /* @__PURE__ */ new Map();
|
|
8352
8463
|
const { document: document2 } = parseHTML5(html);
|
|
8353
8464
|
const compEls = document2.querySelectorAll("[data-composition-src]");
|
|
@@ -8360,6 +8471,10 @@ async function parseSubCompositions(html, projectDir, downloadDir, visited = /*
|
|
|
8360
8471
|
if (visited.has(filePath)) {
|
|
8361
8472
|
continue;
|
|
8362
8473
|
}
|
|
8474
|
+
if (compiledSrcs.has(srcPath)) continue;
|
|
8475
|
+
compiledSrcs.add(srcPath);
|
|
8476
|
+
assertOutsideMarkupAsked(projectDir, filePath, srcPath, assetRoot, outsideFiles);
|
|
8477
|
+
assertCompositionFileSize(filePath, srcPath);
|
|
8363
8478
|
const read = readProjectFile(filePath);
|
|
8364
8479
|
if (read.kind !== "file") {
|
|
8365
8480
|
continue;
|
|
@@ -8388,7 +8503,9 @@ async function parseSubCompositions(html, projectDir, downloadDir, visited = /*
|
|
|
8388
8503
|
item.nestedVisited,
|
|
8389
8504
|
urlByAbsentLocalPath,
|
|
8390
8505
|
probes,
|
|
8391
|
-
assetRoot
|
|
8506
|
+
assetRoot,
|
|
8507
|
+
outsideFiles,
|
|
8508
|
+
compiledSrcs
|
|
8392
8509
|
);
|
|
8393
8510
|
return {
|
|
8394
8511
|
srcPath: item.srcPath,
|
|
@@ -8524,7 +8641,7 @@ function coalesceHeadStylesAndBodyScripts(html) {
|
|
|
8524
8641
|
}
|
|
8525
8642
|
return document2.toString();
|
|
8526
8643
|
}
|
|
8527
|
-
function inlineSubCompositions(html, subCompositions, projectDir, variableOverrides, assetRoot) {
|
|
8644
|
+
function inlineSubCompositions(html, subCompositions, projectDir, variableOverrides, assetRoot, outsideFiles) {
|
|
8528
8645
|
const { document: document2 } = parseHTML5(html);
|
|
8529
8646
|
const head = document2.querySelector("head");
|
|
8530
8647
|
const body = document2.querySelector("body");
|
|
@@ -8537,6 +8654,27 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
|
|
|
8537
8654
|
);
|
|
8538
8655
|
return { html: emitted ? document2.toString() : html, variablesByComp: {} };
|
|
8539
8656
|
}
|
|
8657
|
+
const budget = new CompositionExpansionBudget();
|
|
8658
|
+
const readOnce = /* @__PURE__ */ new Map();
|
|
8659
|
+
const readMountHtml = (srcPath) => {
|
|
8660
|
+
const filePath = resolveCompositionFile(projectDir, srcPath, assetRoot);
|
|
8661
|
+
if (filePath) {
|
|
8662
|
+
assertOutsideMarkupAsked(projectDir, filePath, srcPath, assetRoot, outsideFiles);
|
|
8663
|
+
assertCompositionFileSize(filePath, srcPath);
|
|
8664
|
+
}
|
|
8665
|
+
const read = filePath && !isPrivateCompositionFile(projectDir, filePath) ? readProjectFile(filePath) : null;
|
|
8666
|
+
return read?.kind === "file" ? rewriteUnresolvableGsapToCdn(
|
|
8667
|
+
normalizeCompositionSrcs(read.text, projectDir),
|
|
8668
|
+
projectDir,
|
|
8669
|
+
srcPath
|
|
8670
|
+
) : null;
|
|
8671
|
+
};
|
|
8672
|
+
const resolveMountHtml = (srcPath) => {
|
|
8673
|
+
const compiled = subCompositions.get(srcPath);
|
|
8674
|
+
if (compiled) return compiled;
|
|
8675
|
+
if (!readOnce.has(srcPath)) readOnce.set(srcPath, readMountHtml(srcPath));
|
|
8676
|
+
return readOnce.get(srcPath) ?? null;
|
|
8677
|
+
};
|
|
8540
8678
|
const hostIdentityByElement = new ProducerHostIdentityMap(
|
|
8541
8679
|
document2,
|
|
8542
8680
|
hosts
|
|
@@ -8552,20 +8690,14 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
|
|
|
8552
8690
|
readVariableDefaults: readDeclaredDefaults,
|
|
8553
8691
|
parseHostVariables: parseHostVariableValues,
|
|
8554
8692
|
resolveHtml: (srcPath) => {
|
|
8555
|
-
|
|
8556
|
-
if (
|
|
8557
|
-
const filePath = resolveCompositionFile(projectDir, srcPath, assetRoot);
|
|
8558
|
-
const read = filePath && !isPrivateCompositionFile(projectDir, filePath) ? readProjectFile(filePath) : null;
|
|
8559
|
-
if (read?.kind === "file") {
|
|
8560
|
-
compHtml = rewriteUnresolvableGsapToCdn(read.text, projectDir, srcPath);
|
|
8561
|
-
}
|
|
8562
|
-
}
|
|
8693
|
+
const compHtml = resolveMountHtml(srcPath);
|
|
8694
|
+
if (compHtml) budget.charge(srcPath, Buffer.byteLength(compHtml));
|
|
8563
8695
|
return compHtml;
|
|
8564
8696
|
},
|
|
8565
8697
|
parseHtml: (htmlStr) => parseHTML5(htmlStr).document,
|
|
8566
8698
|
// Mirrors the preview bundler: a sub-composition's SIBLING assets resolve
|
|
8567
8699
|
// against its own directory, project-root refs stay as authored.
|
|
8568
|
-
assetExists: (
|
|
8700
|
+
assetExists: projectAssetExists(projectDir),
|
|
8569
8701
|
// Preserve the authored root wrapper as a child of the host, matching
|
|
8570
8702
|
// the preview bundler's shape (htmlBundler.ts's prepareFlattenedInnerRoot,
|
|
8571
8703
|
// which the runtime compositionLoader mirrors with its own copy for the
|
|
@@ -8770,7 +8902,7 @@ ${safeText}
|
|
|
8770
8902
|
}
|
|
8771
8903
|
return wrappedFragment ? document2.body.innerHTML || "" : document2.toString();
|
|
8772
8904
|
}
|
|
8773
|
-
function collectExternalAssets(html, projectDir, log = defaultLogger, file = "index.html") {
|
|
8905
|
+
function collectExternalAssets(html, projectDir, log = defaultLogger, file = "index.html", policy = {}) {
|
|
8774
8906
|
const absProjectDir = resolve7(projectDir);
|
|
8775
8907
|
const externalAssets = /* @__PURE__ */ new Map();
|
|
8776
8908
|
const leftOut = /* @__PURE__ */ new Set();
|
|
@@ -8783,7 +8915,7 @@ function collectExternalAssets(html, projectDir, log = defaultLogger, file = "in
|
|
|
8783
8915
|
}
|
|
8784
8916
|
const onShare = namesAnotherNetworkRoot2(absProjectDir, absPath);
|
|
8785
8917
|
if (!onShare && !existsSync11(absPath)) return null;
|
|
8786
|
-
const refusal = onShare ? "network_share" : outsideAssetRefusal(absProjectDir, absPath);
|
|
8918
|
+
const refusal = onShare ? "network_share" : outsideAssetRefusal(absProjectDir, absPath, policy);
|
|
8787
8919
|
if (refusal) {
|
|
8788
8920
|
if (!leftOut.has(trimmed)) log.warn(`[Compiler] ${leftOutOfRender(file, trimmed, refusal)}`);
|
|
8789
8921
|
leftOut.add(trimmed);
|
|
@@ -9172,7 +9304,7 @@ function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath) {
|
|
|
9172
9304
|
const entryPath = relative2(projectDir, htmlPath).replace(/\\/g, "/");
|
|
9173
9305
|
if (!entryPath.includes("/")) return html;
|
|
9174
9306
|
const { document: document2 } = parseHTML5(html);
|
|
9175
|
-
const assetExists = (
|
|
9307
|
+
const assetExists = projectAssetExists(projectDir);
|
|
9176
9308
|
rewriteAssetPaths(
|
|
9177
9309
|
document2.querySelectorAll("[src], [href], [srcset]"),
|
|
9178
9310
|
entryPath,
|
|
@@ -9213,18 +9345,23 @@ function bindVariableMediaSources(html, variables) {
|
|
|
9213
9345
|
var entryFileName = (projectDir, htmlPath) => isPathInside(htmlPath, projectDir) ? relative2(projectDir, htmlPath).split(sep3).join("/") : basename5(htmlPath);
|
|
9214
9346
|
async function compileForRender(projectDir, htmlPath, downloadDir, options = {}) {
|
|
9215
9347
|
const assetRoot = options.allowOutsideProjectAssets ? void 0 : projectDir;
|
|
9348
|
+
const outsideFiles = { includeScripts: options.includeOutsideScripts };
|
|
9216
9349
|
if (isPathInside(htmlPath, projectDir) && escapesAssetRoot(htmlPath, assetRoot)) {
|
|
9217
9350
|
throw new Error(`Entry file ${htmlPath} leads outside the project folder`);
|
|
9218
9351
|
}
|
|
9352
|
+
if (isPathInside(htmlPath, projectDir) && runsOutsideMarkupUnasked(projectDir, htmlPath, assetRoot, outsideFiles)) {
|
|
9353
|
+
throw new Error(`Entry file ${htmlPath} ${OUTSIDE_COMPOSITION_NEEDS_FLAG}`);
|
|
9354
|
+
}
|
|
9219
9355
|
if (!COMPOSITION_FILE.test(htmlPath)) {
|
|
9220
9356
|
throw new Error(`Entry file ${htmlPath} is not an .html file, so it is refused`);
|
|
9221
9357
|
}
|
|
9358
|
+
assertCompositionFileSize(htmlPath, basename5(htmlPath));
|
|
9222
9359
|
const entryHtml = rebaseDirectEntryAssetPaths(readTextFile(htmlPath), projectDir, htmlPath);
|
|
9223
9360
|
const rawHtml = bindVariableMediaSources(
|
|
9224
9361
|
normalizeCompositionSrcs(rewriteUnresolvableGsapToCdn(entryHtml, projectDir), projectDir),
|
|
9225
9362
|
options.variables ?? {}
|
|
9226
9363
|
);
|
|
9227
|
-
assertSubCompositionsUsable(rawHtml, projectDir, assetRoot);
|
|
9364
|
+
assertSubCompositionsUsable(rawHtml, projectDir, assetRoot, outsideFiles);
|
|
9228
9365
|
const probes = /* @__PURE__ */ new Map();
|
|
9229
9366
|
const { html: compiledHtml, unresolvedCompositions } = await compileHtmlFile(
|
|
9230
9367
|
rawHtml,
|
|
@@ -9243,7 +9380,8 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
9243
9380
|
void 0,
|
|
9244
9381
|
options.urlByAbsentLocalPath,
|
|
9245
9382
|
probes,
|
|
9246
|
-
assetRoot
|
|
9383
|
+
assetRoot,
|
|
9384
|
+
outsideFiles
|
|
9247
9385
|
);
|
|
9248
9386
|
const fullHtml = ensureFullDocument(compiledHtml);
|
|
9249
9387
|
const { html: inlinedHtml, variablesByComp } = inlineSubCompositions(
|
|
@@ -9251,7 +9389,8 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
9251
9389
|
subCompositions,
|
|
9252
9390
|
projectDir,
|
|
9253
9391
|
options.variables ?? {},
|
|
9254
|
-
assetRoot
|
|
9392
|
+
assetRoot,
|
|
9393
|
+
outsideFiles
|
|
9255
9394
|
);
|
|
9256
9395
|
const sanitizedHtml = stripPreloadNone(inlinedHtml);
|
|
9257
9396
|
const renderModeHints = detectRenderModeHints(sanitizedHtml, options.pageMotionBlur);
|
|
@@ -9305,7 +9444,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
9305
9444
|
cacheDir: options.animatedGifCacheDir,
|
|
9306
9445
|
sourceAssets: remoteImageAssets,
|
|
9307
9446
|
timeoutMs: options.ffmpegProcessTimeout,
|
|
9308
|
-
assetRoot
|
|
9447
|
+
allowOutsideFiles: assetRoot === void 0
|
|
9309
9448
|
});
|
|
9310
9449
|
if (preparedHeifImages.length > 0) {
|
|
9311
9450
|
defaultLogger.debug(`[Compiler] Converted ${preparedHeifImages.length} HEIC image(s) to JPEG`);
|
|
@@ -9321,7 +9460,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
9321
9460
|
cacheDir: options.animatedGifCacheDir,
|
|
9322
9461
|
sourceAssets: gifSourceAssets,
|
|
9323
9462
|
timeoutMs: options.ffmpegProcessTimeout,
|
|
9324
|
-
assetRoot
|
|
9463
|
+
allowOutsideFiles: assetRoot === void 0
|
|
9325
9464
|
});
|
|
9326
9465
|
if (preparedGifs.length > 0) {
|
|
9327
9466
|
defaultLogger.debug(`[Compiler] Prepared ${preparedGifs.length} animated GIF input(s) as WebM`);
|
|
@@ -9336,7 +9475,8 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
9336
9475
|
embeddedHtml,
|
|
9337
9476
|
projectDir,
|
|
9338
9477
|
options.log,
|
|
9339
|
-
entryFileName(projectDir, htmlPath)
|
|
9478
|
+
entryFileName(projectDir, htmlPath),
|
|
9479
|
+
{ includeScripts: options.includeOutsideScripts }
|
|
9340
9480
|
) : { html: embeddedHtml, externalAssets: /* @__PURE__ */ new Map() };
|
|
9341
9481
|
for (const [relPath, absPath] of remoteMediaAssets) {
|
|
9342
9482
|
externalAssets.set(relPath, absPath);
|
|
@@ -9743,7 +9883,7 @@ async function resolveCompositionDurations(page, unresolved) {
|
|
|
9743
9883
|
}
|
|
9744
9884
|
return resolutions;
|
|
9745
9885
|
}
|
|
9746
|
-
async function recompileWithResolutions(compiled, resolutions, projectDir, downloadDir, assetRoot) {
|
|
9886
|
+
async function recompileWithResolutions(compiled, resolutions, projectDir, downloadDir, assetRoot, outsideFiles = {}) {
|
|
9747
9887
|
if (resolutions.length === 0) return compiled;
|
|
9748
9888
|
const html = injectDurations(compiled.html, resolutions);
|
|
9749
9889
|
const { subCompositions } = await parseSubCompositions(
|
|
@@ -9753,7 +9893,8 @@ async function recompileWithResolutions(compiled, resolutions, projectDir, downl
|
|
|
9753
9893
|
void 0,
|
|
9754
9894
|
void 0,
|
|
9755
9895
|
void 0,
|
|
9756
|
-
assetRoot
|
|
9896
|
+
assetRoot,
|
|
9897
|
+
outsideFiles
|
|
9757
9898
|
);
|
|
9758
9899
|
const { videos, audios, images } = compiled;
|
|
9759
9900
|
const remaining = compiled.unresolvedCompositions.filter(
|
|
@@ -9801,6 +9942,7 @@ function resolveEntryHtmlPath(input) {
|
|
|
9801
9942
|
`Entry file "${relative3(projectDir, path)}" leads outside the project folder`
|
|
9802
9943
|
);
|
|
9803
9944
|
}
|
|
9945
|
+
assertCompositionFileSize(path, relative3(projectDir, path));
|
|
9804
9946
|
return readTextFile2(path);
|
|
9805
9947
|
};
|
|
9806
9948
|
const htmlPath = join20(projectDir, entryFile);
|
|
@@ -9862,7 +10004,8 @@ async function runCompileStage(input) {
|
|
|
9862
10004
|
pageMotionBlur: input.pageMotionBlur,
|
|
9863
10005
|
animatedGifCacheDir: animatedGifCacheDir(cfg.extractCacheDir),
|
|
9864
10006
|
ffmpegProcessTimeout: cfg.ffmpegProcessTimeout,
|
|
9865
|
-
allowOutsideProjectAssets: job.config.allowOutsideProjectAssets
|
|
10007
|
+
allowOutsideProjectAssets: job.config.allowOutsideProjectAssets,
|
|
10008
|
+
includeOutsideScripts: job.config.includeOutsideScripts
|
|
9866
10009
|
});
|
|
9867
10010
|
assertNotAborted();
|
|
9868
10011
|
const compileOnlyMs = Date.now() - compileStart;
|
|
@@ -9948,6 +10091,8 @@ async function runCompileStage(input) {
|
|
|
9948
10091
|
});
|
|
9949
10092
|
const outputWidth = Math.round(width * deviceScaleFactor);
|
|
9950
10093
|
const outputHeight = Math.round(height * deviceScaleFactor);
|
|
10094
|
+
requireOutputDimensions(job.config.expectedOutputDimensions, outputWidth, outputHeight);
|
|
10095
|
+
if (job.config.expectedOutputDimensions !== void 0) job.outputDimensionsChecked = true;
|
|
9951
10096
|
if (deviceScaleFactor !== 1) {
|
|
9952
10097
|
log.info("Scaling composition via deviceScaleFactor", {
|
|
9953
10098
|
compositionWidth: width,
|
|
@@ -10042,30 +10187,50 @@ function hasAutoStartVideos(html) {
|
|
|
10042
10187
|
const { document: document2 } = parseHTML6(html);
|
|
10043
10188
|
return document2.querySelector("video[data-hf-auto-start]") !== null;
|
|
10044
10189
|
}
|
|
10045
|
-
|
|
10046
|
-
|
|
10047
|
-
|
|
10048
|
-
|
|
10190
|
+
var MAX_VARIABLE_SCOPE_STEPS = 1e6;
|
|
10191
|
+
function variableIdsOn(scan, element) {
|
|
10192
|
+
let ids = scan.ids.get(element);
|
|
10193
|
+
if (!ids) {
|
|
10194
|
+
ids = /* @__PURE__ */ new Set([
|
|
10195
|
+
...Object.keys(parseHostVariableValues2(element)),
|
|
10196
|
+
...Object.keys(readDeclaredDefaults2(element))
|
|
10197
|
+
]);
|
|
10198
|
+
scan.ids.set(element, ids);
|
|
10199
|
+
}
|
|
10200
|
+
return ids;
|
|
10201
|
+
}
|
|
10202
|
+
function scopedVariablesFor(scan, element, variablesByComp) {
|
|
10203
|
+
for (let node = element; node; node = node.parentElement) {
|
|
10204
|
+
if (++scan.steps > MAX_VARIABLE_SCOPE_STEPS) return null;
|
|
10205
|
+
if (!node.hasAttribute("data-composition-id")) continue;
|
|
10206
|
+
const compId = node.getAttribute("data-composition-id")?.trim() ?? "";
|
|
10207
|
+
return compId && Object.hasOwn(variablesByComp, compId) ? variablesByComp[compId] : void 0;
|
|
10208
|
+
}
|
|
10209
|
+
return void 0;
|
|
10049
10210
|
}
|
|
10050
|
-
function variableHasValue(element, variableId, variables, variablesByComp) {
|
|
10211
|
+
function variableHasValue(scan, element, variableId, variables, variablesByComp) {
|
|
10051
10212
|
if (variables && Object.hasOwn(variables, variableId)) return true;
|
|
10052
|
-
const scoped = scopedVariablesFor(element, variablesByComp);
|
|
10213
|
+
const scoped = scopedVariablesFor(scan, element, variablesByComp);
|
|
10214
|
+
if (scoped === null) return true;
|
|
10053
10215
|
if (scoped) return Object.hasOwn(scoped, variableId);
|
|
10054
10216
|
for (let scope = element.parentElement; scope; scope = scope.parentElement) {
|
|
10055
|
-
if (
|
|
10056
|
-
if (
|
|
10217
|
+
if (++scan.steps > MAX_VARIABLE_SCOPE_STEPS) return true;
|
|
10218
|
+
if (variableIdsOn(scan, scope).has(variableId)) return true;
|
|
10057
10219
|
}
|
|
10058
|
-
return
|
|
10220
|
+
return variableIdsOn(scan, element.ownerDocument.documentElement).has(variableId);
|
|
10059
10221
|
}
|
|
10060
10222
|
function hasVariableBoundMedia(html, variables, variablesByComp = {}) {
|
|
10061
10223
|
const { document: document2 } = parseHTML6(html);
|
|
10224
|
+
const scan = { ids: /* @__PURE__ */ new Map(), steps: 0 };
|
|
10062
10225
|
return Array.from(
|
|
10063
10226
|
document2.querySelectorAll(
|
|
10064
10227
|
"img[data-var-src], audio[data-var-src], video[data-var-src], source[data-var-src]"
|
|
10065
10228
|
)
|
|
10066
10229
|
).some((element) => {
|
|
10067
10230
|
const variableId = element.getAttribute("data-var-src")?.trim();
|
|
10068
|
-
return Boolean(
|
|
10231
|
+
return Boolean(
|
|
10232
|
+
variableId && variableHasValue(scan, element, variableId, variables, variablesByComp)
|
|
10233
|
+
);
|
|
10069
10234
|
});
|
|
10070
10235
|
}
|
|
10071
10236
|
function authoredMediaStarts(html) {
|
|
@@ -10105,29 +10270,54 @@ function reconcileBrowserMediaEnd(existingEnd, projectedEnd, sourceChanged, dura
|
|
|
10105
10270
|
if (sourceChanged && durationInferred) return projectedEnd;
|
|
10106
10271
|
return existingEnd <= 0 ? projectedEnd : Math.min(existingEnd, projectedEnd);
|
|
10107
10272
|
}
|
|
10273
|
+
var MAX_MEDIA_SELECTOR_WORK = 1e6;
|
|
10274
|
+
var SIBLING_COMBINATOR = /[~+]/;
|
|
10275
|
+
function managedMediaElements(document2) {
|
|
10276
|
+
const managed = [];
|
|
10277
|
+
const pending = [];
|
|
10278
|
+
for (const element of Array.from(document2.children)) pending.push({ element, inMedia: false });
|
|
10279
|
+
for (let next = pending.pop(); next; next = pending.pop()) {
|
|
10280
|
+
const name = next.element.tagName.toLowerCase();
|
|
10281
|
+
const isMedia = name === "video" || name === "audio";
|
|
10282
|
+
if (isMedia || next.inMedia && name === "source") managed.push(next.element);
|
|
10283
|
+
for (const child3 of Array.from(next.element.children)) {
|
|
10284
|
+
pending.push({ element: child3, inMedia: next.inMedia || isMedia });
|
|
10285
|
+
}
|
|
10286
|
+
}
|
|
10287
|
+
return managed;
|
|
10288
|
+
}
|
|
10108
10289
|
function hasRuntimeMediaChanges(html) {
|
|
10109
10290
|
const { document: document2 } = parseHTML6(html);
|
|
10110
10291
|
const scriptBodies = [...document2.querySelectorAll("script")].map(
|
|
10111
10292
|
(script) => script.textContent ?? ""
|
|
10112
10293
|
);
|
|
10113
10294
|
const insertedMedia = scriptBodies.some(
|
|
10114
|
-
(script) => /\bcreateElement\s*\(\s*["'`](?:video|audio)["'`]\s*\)/i.test(script) || /\bnew\s+(?:Audio|Video)\s*\(/i.test(script) ||
|
|
10295
|
+
(script) => /\bcreateElement\s*\(\s*["'`](?:video|audio)["'`]\s*\)/i.test(script) || /\bnew\s+(?:Audio|Video)\s*\(/i.test(script) || hasClosedMediaTag(script)
|
|
10115
10296
|
);
|
|
10116
10297
|
if (insertedMedia) return true;
|
|
10117
|
-
const
|
|
10118
|
-
|
|
10119
|
-
|
|
10120
|
-
|
|
10121
|
-
|
|
10298
|
+
const managed = managedMediaElements(document2);
|
|
10299
|
+
if (managed.length === 0) return false;
|
|
10300
|
+
const managedIds = new Set(managed.map((element) => element.getAttribute("id")).filter(Boolean));
|
|
10301
|
+
const selectors = /* @__PURE__ */ new Set();
|
|
10302
|
+
let selectorChars = 0;
|
|
10122
10303
|
for (const script of scriptBodies) {
|
|
10123
10304
|
for (const mutation of extractMediaSrcMutations(script)) {
|
|
10124
|
-
|
|
10125
|
-
|
|
10126
|
-
|
|
10127
|
-
|
|
10128
|
-
if (targets.some(isManagedMedia)) return true;
|
|
10129
|
-
} catch {
|
|
10305
|
+
const id = /^#[A-Za-z_][\w-]*$/.test(mutation.selector) ? mutation.selector.slice(1) : null;
|
|
10306
|
+
if (id) {
|
|
10307
|
+
if (managedIds.has(id)) return true;
|
|
10308
|
+
continue;
|
|
10130
10309
|
}
|
|
10310
|
+
if (selectors.has(mutation.selector)) continue;
|
|
10311
|
+
if (SIBLING_COMBINATOR.test(mutation.selector)) return true;
|
|
10312
|
+
selectors.add(mutation.selector);
|
|
10313
|
+
selectorChars += mutation.selector.length;
|
|
10314
|
+
if (selectorChars * managed.length > MAX_MEDIA_SELECTOR_WORK) return true;
|
|
10315
|
+
}
|
|
10316
|
+
}
|
|
10317
|
+
for (const selector of selectors) {
|
|
10318
|
+
try {
|
|
10319
|
+
if (managed.some((element) => element.matches(selector))) return true;
|
|
10320
|
+
} catch {
|
|
10131
10321
|
}
|
|
10132
10322
|
}
|
|
10133
10323
|
return false;
|
|
@@ -10215,7 +10405,8 @@ async function runProbeStage(input) {
|
|
|
10215
10405
|
port: 0,
|
|
10216
10406
|
preHeadScripts: [VIRTUAL_TIME_SHIM],
|
|
10217
10407
|
fps: job.config.fps,
|
|
10218
|
-
allowOutsideProjectAssets: job.config.allowOutsideProjectAssets
|
|
10408
|
+
allowOutsideProjectAssets: job.config.allowOutsideProjectAssets,
|
|
10409
|
+
includeOutsideScripts: job.config.includeOutsideScripts
|
|
10219
10410
|
});
|
|
10220
10411
|
assertNotAborted();
|
|
10221
10412
|
const motionBlur = job.config.motionBlur;
|
|
@@ -10371,7 +10562,8 @@ async function runProbeStage(input) {
|
|
|
10371
10562
|
resolutions,
|
|
10372
10563
|
projectDir,
|
|
10373
10564
|
join21(workDir, "downloads"),
|
|
10374
|
-
job.config.allowOutsideProjectAssets ? void 0 : projectDir
|
|
10565
|
+
job.config.allowOutsideProjectAssets ? void 0 : projectDir,
|
|
10566
|
+
{ includeScripts: job.config.includeOutsideScripts }
|
|
10375
10567
|
);
|
|
10376
10568
|
assertNotAborted();
|
|
10377
10569
|
composition.videos = compiled.videos;
|
|
@@ -13449,7 +13641,7 @@ import {
|
|
|
13449
13641
|
readdirSync as readdirSync5,
|
|
13450
13642
|
readFileSync as readFileSync9,
|
|
13451
13643
|
rmSync as rmSync11,
|
|
13452
|
-
statSync as
|
|
13644
|
+
statSync as statSync10,
|
|
13453
13645
|
writeFileSync as writeFileSync6
|
|
13454
13646
|
} from "node:fs";
|
|
13455
13647
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
@@ -13578,7 +13770,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
|
13578
13770
|
const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
|
|
13579
13771
|
if (failure) return failure;
|
|
13580
13772
|
}
|
|
13581
|
-
const fileSize = existsSync20(outputPath) ?
|
|
13773
|
+
const fileSize = existsSync20(outputPath) ? statSync10(outputPath).size : 0;
|
|
13582
13774
|
return {
|
|
13583
13775
|
success: true,
|
|
13584
13776
|
outputPath,
|
|
@@ -13601,7 +13793,10 @@ function startEncodeProgress(job, stage, onProgress) {
|
|
|
13601
13793
|
function resolveEngineConfig(input) {
|
|
13602
13794
|
return input.engineConfig ?? input.job.config.producerConfig ?? resolveConfig();
|
|
13603
13795
|
}
|
|
13604
|
-
function
|
|
13796
|
+
function overlapEncoderThreads(workerCount, cpuCount) {
|
|
13797
|
+
return Math.max(1, Math.floor(cpuCount) - Math.floor(workerCount));
|
|
13798
|
+
}
|
|
13799
|
+
function videoEncoderOptions(input, engineCfg, softwareEncoderThreads) {
|
|
13605
13800
|
const { job, preset } = input;
|
|
13606
13801
|
return {
|
|
13607
13802
|
fps: job.config.fps,
|
|
@@ -13621,7 +13816,8 @@ function videoEncoderOptions(input, engineCfg) {
|
|
|
13621
13816
|
// keyframes that survive `-f concat -c copy` at assemble time. In-process
|
|
13622
13817
|
// renders leave both undefined → preserves the existing open-GOP output.
|
|
13623
13818
|
lockGopForChunkConcat: input.lockGopForChunkConcat === true,
|
|
13624
|
-
gopSize: input.gopSize
|
|
13819
|
+
gopSize: input.gopSize,
|
|
13820
|
+
softwareEncoderThreads
|
|
13625
13821
|
};
|
|
13626
13822
|
}
|
|
13627
13823
|
function canEncodeWhileCapturing(input, workerCount, cpuCount) {
|
|
@@ -13637,8 +13833,9 @@ async function readLandedFrame(workerPath, mergedPath) {
|
|
|
13637
13833
|
}
|
|
13638
13834
|
return readFile2(mergedPath);
|
|
13639
13835
|
}
|
|
13640
|
-
function encodeWhileCapturing(input, totalFrames) {
|
|
13836
|
+
function encodeWhileCapturing(input, totalFrames, captureBudget) {
|
|
13641
13837
|
const engineCfg = resolveEngineConfig(input);
|
|
13838
|
+
const softwareEncoderThreads = captureBudget ? overlapEncoderThreads(captureBudget.workerCount, captureBudget.cpuCount) : void 0;
|
|
13642
13839
|
const stop = new AbortController();
|
|
13643
13840
|
const signal = input.abortSignal ? AbortSignal.any([input.abortSignal, stop.signal]) : stop.signal;
|
|
13644
13841
|
const landed = /* @__PURE__ */ new Map();
|
|
@@ -13653,7 +13850,10 @@ function encodeWhileCapturing(input, totalFrames) {
|
|
|
13653
13850
|
let reportFed = null;
|
|
13654
13851
|
const encoder = spawnStreamingEncoder4(
|
|
13655
13852
|
input.videoOnlyPath,
|
|
13656
|
-
{
|
|
13853
|
+
{
|
|
13854
|
+
...videoEncoderOptions(input, engineCfg, softwareEncoderThreads),
|
|
13855
|
+
imageFormat: "jpeg"
|
|
13856
|
+
},
|
|
13657
13857
|
signal,
|
|
13658
13858
|
engineCfg
|
|
13659
13859
|
);
|
|
@@ -13984,7 +14184,7 @@ function sampleDirectoryBytes(dir) {
|
|
|
13984
14184
|
for (const name of entries) {
|
|
13985
14185
|
const full = join32(current, name);
|
|
13986
14186
|
try {
|
|
13987
|
-
const st =
|
|
14187
|
+
const st = statSync11(full);
|
|
13988
14188
|
if (st.isDirectory()) {
|
|
13989
14189
|
stack.push(full);
|
|
13990
14190
|
} else if (st.isFile()) {
|
|
@@ -14139,7 +14339,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
14139
14339
|
let rangeStart = null;
|
|
14140
14340
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
14141
14341
|
const framePath = join32(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
14142
|
-
const missing = !existsSync21(framePath) ||
|
|
14342
|
+
const missing = !existsSync21(framePath) || statSync11(framePath).size <= 8;
|
|
14143
14343
|
if (missing && rangeStart === null) {
|
|
14144
14344
|
rangeStart = frameIndex;
|
|
14145
14345
|
} else if (!missing && rangeStart !== null) {
|
|
@@ -15476,7 +15676,8 @@ async function executeRenderPipeline(input) {
|
|
|
15476
15676
|
port: 0,
|
|
15477
15677
|
preHeadScripts: [VIRTUAL_TIME_SHIM],
|
|
15478
15678
|
fps: job.config.fps,
|
|
15479
|
-
allowOutsideProjectAssets: job.config.allowOutsideProjectAssets
|
|
15679
|
+
allowOutsideProjectAssets: job.config.allowOutsideProjectAssets,
|
|
15680
|
+
includeOutsideScripts: job.config.includeOutsideScripts
|
|
15480
15681
|
});
|
|
15481
15682
|
assertNotAborted();
|
|
15482
15683
|
observability.stageEnd("file_server", fileServerStart);
|
|
@@ -16765,7 +16966,10 @@ async function executeRenderPipeline(input) {
|
|
|
16765
16966
|
assertNotAborted,
|
|
16766
16967
|
onProgress
|
|
16767
16968
|
};
|
|
16768
|
-
const overlap = !cfg.useDrawElement && workerSizing !== void 0 && canEncodeWhileCapturing(encodeInput, capturePlan.workerCount, workerSizing.cpuCount) ? encodeWhileCapturing(encodeInput, totalFrames
|
|
16969
|
+
const overlap = !cfg.useDrawElement && workerSizing !== void 0 && canEncodeWhileCapturing(encodeInput, capturePlan.workerCount, workerSizing.cpuCount) ? encodeWhileCapturing(encodeInput, totalFrames, {
|
|
16970
|
+
workerCount: capturePlan.workerCount,
|
|
16971
|
+
cpuCount: workerSizing.cpuCount
|
|
16972
|
+
}) : null;
|
|
16769
16973
|
const captureFrameStart = Date.now();
|
|
16770
16974
|
const invokeDiskCapture = (diskPlan) => observeRenderStage(
|
|
16771
16975
|
observability,
|
|
@@ -17826,8 +18030,10 @@ function buildSyntheticRenderJob(input) {
|
|
|
17826
18030
|
producerConfig: input.producerConfig,
|
|
17827
18031
|
variables: input.variables,
|
|
17828
18032
|
strictVariables: input.strictVariables,
|
|
18033
|
+
expectedOutputDimensions: input.expectedOutputDimensions,
|
|
17829
18034
|
pageMotionBlur: input.pageMotionBlur,
|
|
17830
|
-
allowOutsideProjectAssets: input.allowOutsideProjectAssets
|
|
18035
|
+
allowOutsideProjectAssets: input.allowOutsideProjectAssets,
|
|
18036
|
+
includeOutsideScripts: input.includeOutsideScripts
|
|
17831
18037
|
};
|
|
17832
18038
|
return createRenderJob(renderConfig);
|
|
17833
18039
|
}
|
|
@@ -19304,8 +19510,10 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
19304
19510
|
producerConfig: cfg,
|
|
19305
19511
|
variables: config.variables,
|
|
19306
19512
|
strictVariables: config.strictVariables,
|
|
19513
|
+
expectedOutputDimensions: config.expectedOutputDimensions,
|
|
19307
19514
|
pageMotionBlur: config.pageMotionBlur,
|
|
19308
|
-
allowOutsideProjectAssets: options.allowOutsideProjectAssets === true
|
|
19515
|
+
allowOutsideProjectAssets: options.allowOutsideProjectAssets === true,
|
|
19516
|
+
includeOutsideScripts: options.includeOutsideScripts === true
|
|
19309
19517
|
});
|
|
19310
19518
|
const entryFile = config.entryFile ?? "index.html";
|
|
19311
19519
|
const htmlPath = join41(projectDir, entryFile);
|
|
@@ -19326,7 +19534,9 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
19326
19534
|
if (rel === "") return true;
|
|
19327
19535
|
if (leavesRoot(rel)) return false;
|
|
19328
19536
|
if (job.config.allowOutsideProjectAssets) {
|
|
19329
|
-
|
|
19537
|
+
const warn = (line) => log.warn(`[Plan] ${line}`);
|
|
19538
|
+
const policy = { includeScripts: job.config.includeOutsideScripts };
|
|
19539
|
+
if (refusesOutsideLink(projectDir, src, warn, policy)) return false;
|
|
19330
19540
|
} else if (!isSafePath2(projectDir, src)) return false;
|
|
19331
19541
|
const firstSegment = rel.split(sep4, 1)[0];
|
|
19332
19542
|
return firstSegment === void 0 || !PLAN_PROJECT_DIR_SKIP_SEGMENTS.has(firstSegment);
|
|
@@ -19771,6 +19981,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
|
|
|
19771
19981
|
format: config.format,
|
|
19772
19982
|
ffmpegVersion,
|
|
19773
19983
|
producerVersion,
|
|
19984
|
+
...job.outputDimensionsChecked === void 0 ? {} : { outputDimensionsChecked: job.outputDimensionsChecked },
|
|
19774
19985
|
...job.strictVariablesChecked === void 0 ? {} : { strictVariablesChecked: job.strictVariablesChecked }
|
|
19775
19986
|
};
|
|
19776
19987
|
}
|
|
@@ -19789,6 +20000,7 @@ async function plan(projectDir, config, planDir, options = {}) {
|
|
|
19789
20000
|
format: executionPlan.format,
|
|
19790
20001
|
ffmpegVersion: executionPlan.ffmpegVersion,
|
|
19791
20002
|
producerVersion: executionPlan.producerVersion,
|
|
20003
|
+
...executionPlan.outputDimensionsChecked === void 0 ? {} : { outputDimensionsChecked: executionPlan.outputDimensionsChecked },
|
|
19792
20004
|
...executionPlan.strictVariablesChecked === void 0 ? {} : { strictVariablesChecked: executionPlan.strictVariablesChecked }
|
|
19793
20005
|
};
|
|
19794
20006
|
}
|
|
@@ -19828,7 +20040,7 @@ import {
|
|
|
19828
20040
|
readFileSync as readFileSync13,
|
|
19829
20041
|
readdirSync as readdirSync10,
|
|
19830
20042
|
rmSync as rmSync16,
|
|
19831
|
-
statSync as
|
|
20043
|
+
statSync as statSync13,
|
|
19832
20044
|
writeFileSync as writeFileSync12
|
|
19833
20045
|
} from "node:fs";
|
|
19834
20046
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
@@ -19847,7 +20059,7 @@ import {
|
|
|
19847
20059
|
linkSync as linkSync2,
|
|
19848
20060
|
mkdirSync as mkdirSync17,
|
|
19849
20061
|
rmSync as rmSync15,
|
|
19850
|
-
statSync as
|
|
20062
|
+
statSync as statSync12,
|
|
19851
20063
|
writeFileSync as writeFileSync11
|
|
19852
20064
|
} from "node:fs";
|
|
19853
20065
|
import { renameWithRetry as renameWithRetry9 } from "@hyperframes/engine";
|
|
@@ -19917,7 +20129,7 @@ var LocalPlanV2ArtifactPublisher = class {
|
|
|
19917
20129
|
}
|
|
19918
20130
|
async putBlob(blob) {
|
|
19919
20131
|
const digest = assertPlanV2Sha256(blob.sha256, "published blob sha256");
|
|
19920
|
-
const sourceSize =
|
|
20132
|
+
const sourceSize = statSync12(blob.sourcePath).size;
|
|
19921
20133
|
if (sourceSize !== blob.sizeBytes) {
|
|
19922
20134
|
throw new PlanV2IntegrityError(
|
|
19923
20135
|
`published blob size changed for ${digest}: expected ${blob.sizeBytes}, got ${sourceSize}`
|
|
@@ -20231,7 +20443,7 @@ function publishBlobFor(absolutePath, digests) {
|
|
|
20231
20443
|
return {
|
|
20232
20444
|
sourcePath: absolutePath,
|
|
20233
20445
|
sha256: planFileSha256(absolutePath, digests),
|
|
20234
|
-
sizeBytes:
|
|
20446
|
+
sizeBytes: statSync13(absolutePath).size
|
|
20235
20447
|
};
|
|
20236
20448
|
}
|
|
20237
20449
|
async function putBlobs(publisher, blobs) {
|
|
@@ -20410,7 +20622,10 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
|
|
|
20410
20622
|
sliceChunkAudio: true,
|
|
20411
20623
|
deferAudio: options.deferAudio
|
|
20412
20624
|
});
|
|
20413
|
-
options.onPlanned?.({
|
|
20625
|
+
options.onPlanned?.({
|
|
20626
|
+
strictVariablesChecked: planned.strictVariablesChecked,
|
|
20627
|
+
outputDimensionsChecked: planned.outputDimensionsChecked
|
|
20628
|
+
});
|
|
20414
20629
|
return await publishExecutionPlan(stagingRoot, publisher, { digests, log: config.logger });
|
|
20415
20630
|
} catch (error) {
|
|
20416
20631
|
try {
|
|
@@ -20599,7 +20814,7 @@ function verifyBlob(planV2Dir, artifact) {
|
|
|
20599
20814
|
if (!existsSync28(sourcePath)) {
|
|
20600
20815
|
throw new PlanV2IntegrityError(`missing content-addressed artifact ${artifact.sha256}`);
|
|
20601
20816
|
}
|
|
20602
|
-
const stats =
|
|
20817
|
+
const stats = statSync13(sourcePath);
|
|
20603
20818
|
if (!stats.isFile() || stats.size !== artifact.sizeBytes) {
|
|
20604
20819
|
throw new PlanV2IntegrityError(`artifact size mismatch for ${artifact.path}`);
|
|
20605
20820
|
}
|
|
@@ -20692,7 +20907,7 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
|
|
|
20692
20907
|
for (const artifact of required) {
|
|
20693
20908
|
if (Object.hasOwn(remoteSources, artifact.path)) continue;
|
|
20694
20909
|
const path = join44(planDir, ...artifact.path.split("/"));
|
|
20695
|
-
if (!existsSync28(path) ||
|
|
20910
|
+
if (!existsSync28(path) || statSync13(path).size !== artifact.sizeBytes) {
|
|
20696
20911
|
throw new PlanV2IntegrityError(
|
|
20697
20912
|
`materialized artifact missing or truncated: ${artifact.path}`
|
|
20698
20913
|
);
|
|
@@ -21233,7 +21448,10 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
21233
21448
|
const captureSession = session;
|
|
21234
21449
|
session = null;
|
|
21235
21450
|
verifyStarted = Date.now();
|
|
21236
|
-
overlap.current = canEncodeWhileCapturing(encodeInput, chunkWorkerCount, usableCpuCount2()) ? encodeWhileCapturing(encodeInput, framesInChunk
|
|
21451
|
+
overlap.current = canEncodeWhileCapturing(encodeInput, chunkWorkerCount, usableCpuCount2()) ? encodeWhileCapturing(encodeInput, framesInChunk, {
|
|
21452
|
+
workerCount: chunkWorkerCount,
|
|
21453
|
+
cpuCount: usableCpuCount2()
|
|
21454
|
+
}) : null;
|
|
21237
21455
|
await observeRenderStage(
|
|
21238
21456
|
new RenderObservabilityRecorder({ pipelineStartMs: start, log }),
|
|
21239
21457
|
"capture_chunk",
|
|
@@ -21438,7 +21656,11 @@ async function renderSpan(projectDir, config, span, outputPath, options = {}) {
|
|
|
21438
21656
|
projectDir,
|
|
21439
21657
|
{ ...config, rejectOnSystemFonts: false, failClosedFontFetch: false },
|
|
21440
21658
|
planDir,
|
|
21441
|
-
{
|
|
21659
|
+
{
|
|
21660
|
+
chunksCarryAudio: true,
|
|
21661
|
+
allowOutsideProjectAssets: options.allowOutsideProjectAssets,
|
|
21662
|
+
includeOutsideScripts: options.includeOutsideScripts
|
|
21663
|
+
}
|
|
21442
21664
|
);
|
|
21443
21665
|
const { startFrame, endFrame } = spanFrameRange(
|
|
21444
21666
|
span.startSeconds,
|
|
@@ -21487,7 +21709,9 @@ var SAFE_RENDER_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
|
21487
21709
|
"RENDER_TOO_SLOW",
|
|
21488
21710
|
"RENDER_STAGE_STALLED",
|
|
21489
21711
|
"PAGE_NEVER_READY",
|
|
21490
|
-
"VARIABLES_INVALID"
|
|
21712
|
+
"VARIABLES_INVALID",
|
|
21713
|
+
"OUTPUT_DIMENSIONS_MISMATCH",
|
|
21714
|
+
"COMPOSITION_TOO_LARGE"
|
|
21491
21715
|
]);
|
|
21492
21716
|
function extractSafeRenderErrorCode(error) {
|
|
21493
21717
|
if (typeof error !== "object" || error === null || !("code" in error)) return void 0;
|
|
@@ -21547,6 +21771,12 @@ function validateDistributedRenderConfig(config) {
|
|
|
21547
21771
|
`must be one of ${DISTRIBUTED_FPS2.join(", ")}; got ${String(config.fps)}`
|
|
21548
21772
|
);
|
|
21549
21773
|
}
|
|
21774
|
+
if (config.expectedOutputDimensions !== void 0 && !isExpectedOutputDimensions(config.expectedOutputDimensions)) {
|
|
21775
|
+
throw new InvalidConfigError(
|
|
21776
|
+
"config.expectedOutputDimensions",
|
|
21777
|
+
"must contain positive integer width and height"
|
|
21778
|
+
);
|
|
21779
|
+
}
|
|
21550
21780
|
validateIntDimension("config.width", config.width);
|
|
21551
21781
|
validateIntDimension("config.height", config.height);
|
|
21552
21782
|
if (config.pageMotionBlur !== void 0 && config.pageMotionBlur !== "off") {
|
|
@@ -21900,6 +22130,11 @@ function assertRequestOptionScalars(options) {
|
|
|
21900
22130
|
}
|
|
21901
22131
|
function assertRequestOptionObjects(options) {
|
|
21902
22132
|
validateEngineConfigSnapshot2(options.engineConfig);
|
|
22133
|
+
if (options.expectedOutputDimensions !== void 0 && !isExpectedOutputDimensions(options.expectedOutputDimensions)) {
|
|
22134
|
+
throw new Error(
|
|
22135
|
+
"Render request expectedOutputDimensions must contain positive integer width and height"
|
|
22136
|
+
);
|
|
22137
|
+
}
|
|
21903
22138
|
if (options.variables !== void 0 && !isPlainObject(options.variables)) {
|
|
21904
22139
|
throw new Error("Render request variables must be a JSON object");
|
|
21905
22140
|
}
|
|
@@ -21965,7 +22200,8 @@ function renderConfigFromRequest(request, runtime = {}) {
|
|
|
21965
22200
|
...options,
|
|
21966
22201
|
producerConfig: engineConfig,
|
|
21967
22202
|
logger: runtime.logger,
|
|
21968
|
-
allowOutsideProjectAssets: runtime.allowOutsideProjectAssets === true
|
|
22203
|
+
allowOutsideProjectAssets: runtime.allowOutsideProjectAssets === true,
|
|
22204
|
+
includeOutsideScripts: runtime.includeOutsideScripts === true
|
|
21969
22205
|
};
|
|
21970
22206
|
}
|
|
21971
22207
|
function distributedFps(fps) {
|
|
@@ -22020,7 +22256,8 @@ function distributedConfigFromRequest(request, runtime = {}) {
|
|
|
22020
22256
|
abortSignal: runtime.abortSignal,
|
|
22021
22257
|
planDirSizeLimitBytes: distributed.planDirSizeLimitBytes,
|
|
22022
22258
|
variables: options.variables,
|
|
22023
|
-
strictVariables: options.strictVariables
|
|
22259
|
+
strictVariables: options.strictVariables,
|
|
22260
|
+
expectedOutputDimensions: options.expectedOutputDimensions
|
|
22024
22261
|
};
|
|
22025
22262
|
}
|
|
22026
22263
|
function optionalProperty(key, value) {
|
|
@@ -22062,7 +22299,8 @@ function renderRequestFromDistributedConfig(input) {
|
|
|
22062
22299
|
...optionalProperty("strictness", config.strictness),
|
|
22063
22300
|
...optionalProperty("entryFile", config.entryFile),
|
|
22064
22301
|
...optionalProperty("variables", config.variables),
|
|
22065
|
-
...optionalProperty("strictVariables", config.strictVariables)
|
|
22302
|
+
...optionalProperty("strictVariables", config.strictVariables),
|
|
22303
|
+
...optionalProperty("expectedOutputDimensions", config.expectedOutputDimensions)
|
|
22066
22304
|
};
|
|
22067
22305
|
return createRenderRequest({
|
|
22068
22306
|
projectDir: input.projectDir,
|
|
@@ -22099,7 +22337,7 @@ import {
|
|
|
22099
22337
|
import {
|
|
22100
22338
|
existsSync as existsSync32,
|
|
22101
22339
|
mkdirSync as mkdirSync21,
|
|
22102
|
-
statSync as
|
|
22340
|
+
statSync as statSync15,
|
|
22103
22341
|
mkdtempSync as mkdtempSync2,
|
|
22104
22342
|
writeFileSync as writeFileSync14,
|
|
22105
22343
|
rmSync as rmSync19,
|
|
@@ -22124,7 +22362,7 @@ import { isSafePath as isSafePath3 } from "@hyperframes/core/safe-path";
|
|
|
22124
22362
|
import {
|
|
22125
22363
|
existsSync as existsSync30,
|
|
22126
22364
|
readFileSync as readFileSync16,
|
|
22127
|
-
statSync as
|
|
22365
|
+
statSync as statSync14,
|
|
22128
22366
|
openSync as openSync7,
|
|
22129
22367
|
fstatSync as fstatSync3,
|
|
22130
22368
|
closeSync as closeSync7,
|
|
@@ -22165,7 +22403,7 @@ function readEntryHtml(filePath) {
|
|
|
22165
22403
|
} catch (error) {
|
|
22166
22404
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
|
|
22167
22405
|
return null;
|
|
22168
|
-
if (!
|
|
22406
|
+
if (!statSync14(filePath, { throwIfNoEntry: false })?.isFile()) return null;
|
|
22169
22407
|
throw error;
|
|
22170
22408
|
}
|
|
22171
22409
|
try {
|
|
@@ -22181,7 +22419,7 @@ function leavesProject(absProjectDir, absoluteEntryPath, isAllowedEntry) {
|
|
|
22181
22419
|
}
|
|
22182
22420
|
function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
|
|
22183
22421
|
const absProjectDir = resolve11(projectDir);
|
|
22184
|
-
if (!existsSync30(absProjectDir) || !
|
|
22422
|
+
if (!existsSync30(absProjectDir) || !statSync14(absProjectDir).isDirectory()) {
|
|
22185
22423
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
22186
22424
|
}
|
|
22187
22425
|
const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
|
|
@@ -22530,6 +22768,7 @@ function parseRenderOptions(body) {
|
|
|
22530
22768
|
outputDynamicRange,
|
|
22531
22769
|
variables,
|
|
22532
22770
|
strictVariables,
|
|
22771
|
+
expectedOutputDimensions: isExpectedOutputDimensions(body.expectedOutputDimensions) ? body.expectedOutputDimensions : void 0,
|
|
22533
22772
|
outputResolution,
|
|
22534
22773
|
outputResolutionAspectAgnostic,
|
|
22535
22774
|
videoFrameFormat
|
|
@@ -22569,6 +22808,7 @@ function buildRenderJobConfig(input, outputPath, log) {
|
|
|
22569
22808
|
entryFile: input.entryFile,
|
|
22570
22809
|
variables: input.variables,
|
|
22571
22810
|
strictVariables: input.strictVariables,
|
|
22811
|
+
expectedOutputDimensions: input.expectedOutputDimensions,
|
|
22572
22812
|
outputResolution: input.outputResolution,
|
|
22573
22813
|
outputResolutionAspectAgnostic: input.outputResolutionAspectAgnostic,
|
|
22574
22814
|
videoFrameFormat: input.videoFrameFormat,
|
|
@@ -22613,6 +22853,9 @@ function validateRenderOverrides(body) {
|
|
|
22613
22853
|
if (body.variables !== void 0 && !isPlainObject2(body.variables)) {
|
|
22614
22854
|
return 'variables must be a JSON object keyed by variable id (e.g. {"title":"Hello"})';
|
|
22615
22855
|
}
|
|
22856
|
+
if (body.expectedOutputDimensions !== void 0 && !isExpectedOutputDimensions(body.expectedOutputDimensions)) {
|
|
22857
|
+
return "expectedOutputDimensions must contain positive integer width and height";
|
|
22858
|
+
}
|
|
22616
22859
|
if (body.strictVariables !== void 0 && typeof body.strictVariables !== "boolean") {
|
|
22617
22860
|
return "strictVariables must be a boolean";
|
|
22618
22861
|
}
|
|
@@ -22663,7 +22906,7 @@ function prepareProjectDirectory(projectDir, options, policy) {
|
|
|
22663
22906
|
if (!candidate) return null;
|
|
22664
22907
|
const absProjectDir = policy ? resolve12(policy.projectsDir, candidate) : resolve12(candidate);
|
|
22665
22908
|
const shown = policy ? candidate : absProjectDir;
|
|
22666
|
-
if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync32(absProjectDir) || !
|
|
22909
|
+
if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync32(absProjectDir) || !statSync15(absProjectDir).isDirectory()) {
|
|
22667
22910
|
return { error: `Project directory not found: ${shown}` };
|
|
22668
22911
|
}
|
|
22669
22912
|
const entry = options.entryFile || "index.html";
|
|
@@ -22766,7 +23009,7 @@ function publicPerfSummary(job) {
|
|
|
22766
23009
|
return job.perfSummary ? { ...job.perfSummary, renderId: void 0 } : null;
|
|
22767
23010
|
}
|
|
22768
23011
|
function outputFileSize(path) {
|
|
22769
|
-
return existsSync32(path) ?
|
|
23012
|
+
return existsSync32(path) ? statSync15(path).size : 0;
|
|
22770
23013
|
}
|
|
22771
23014
|
function createBlockingProgressReporter(log, requestId) {
|
|
22772
23015
|
let lastLoggedPct = -10;
|
|
@@ -22969,7 +23212,8 @@ function createRenderHandlers(options = {}) {
|
|
|
22969
23212
|
outcome: job.outcome ?? "completed",
|
|
22970
23213
|
warnings: job.warnings,
|
|
22971
23214
|
perf: policy ? publicPerfSummary(job) : job.perfSummary ?? null,
|
|
22972
|
-
...strictVariablesResult(job)
|
|
23215
|
+
...strictVariablesResult(job),
|
|
23216
|
+
...job.outputDimensionsChecked === void 0 ? {} : { outputDimensionsChecked: job.outputDimensionsChecked }
|
|
22973
23217
|
});
|
|
22974
23218
|
} catch (error) {
|
|
22975
23219
|
const durationMs = Date.now() - t0;
|
|
@@ -23066,7 +23310,8 @@ function createRenderHandlers(options = {}) {
|
|
|
23066
23310
|
warnings: job.warnings,
|
|
23067
23311
|
perf: policy ? publicPerfSummary(job) : job.perfSummary ?? null,
|
|
23068
23312
|
producerVersion: readProducerVersion(),
|
|
23069
|
-
...strictVariablesResult(job)
|
|
23313
|
+
...strictVariablesResult(job),
|
|
23314
|
+
...job.outputDimensionsChecked === void 0 ? {} : { outputDimensionsChecked: job.outputDimensionsChecked }
|
|
23070
23315
|
})
|
|
23071
23316
|
});
|
|
23072
23317
|
} catch (error) {
|
|
@@ -23095,7 +23340,7 @@ function createRenderHandlers(options = {}) {
|
|
|
23095
23340
|
store.delete(token);
|
|
23096
23341
|
return c.json({ success: false, error: "Output artifact file missing" }, 404);
|
|
23097
23342
|
}
|
|
23098
|
-
const stats =
|
|
23343
|
+
const stats = statSync15(artifact.path);
|
|
23099
23344
|
return new Response(createReadStream5(artifact.path), {
|
|
23100
23345
|
headers: {
|
|
23101
23346
|
"content-type": "video/mp4",
|
|
@@ -23296,7 +23541,7 @@ import {
|
|
|
23296
23541
|
readFileSync as readFileSync17,
|
|
23297
23542
|
readdirSync as readdirSync12,
|
|
23298
23543
|
rmSync as rmSync20,
|
|
23299
|
-
statSync as
|
|
23544
|
+
statSync as statSync16,
|
|
23300
23545
|
writeFileSync as writeFileSync15
|
|
23301
23546
|
} from "node:fs";
|
|
23302
23547
|
import { basename as basename8, dirname as dirname22, join as join50 } from "node:path";
|
|
@@ -23341,7 +23586,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
23341
23586
|
outputPath,
|
|
23342
23587
|
durationMs: Date.now() - start,
|
|
23343
23588
|
framesEncoded: plan2.totalFrames,
|
|
23344
|
-
fileSize:
|
|
23589
|
+
fileSize: statSync16(outputPath).size
|
|
23345
23590
|
};
|
|
23346
23591
|
}
|
|
23347
23592
|
const format = plan2.dimensions.format;
|
|
@@ -23388,7 +23633,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
23388
23633
|
});
|
|
23389
23634
|
}
|
|
23390
23635
|
}
|
|
23391
|
-
const fileSize = existsSync33(outputPath) ?
|
|
23636
|
+
const fileSize = existsSync33(outputPath) ? statSync16(outputPath).size : 0;
|
|
23392
23637
|
return {
|
|
23393
23638
|
...referenceBackgroundResult8(plan2[REFERENCE_BACKGROUND_FIELD6]),
|
|
23394
23639
|
outputPath,
|
|
@@ -23586,7 +23831,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
23586
23831
|
mkdirSync22(outputPath, { recursive: true });
|
|
23587
23832
|
let globalIdx = 0;
|
|
23588
23833
|
for (const chunkDir of chunkPaths) {
|
|
23589
|
-
if (!
|
|
23834
|
+
if (!statSync16(chunkDir).isDirectory()) {
|
|
23590
23835
|
throw new Error(
|
|
23591
23836
|
`[assemble] png-sequence chunk must be a directory: ${chunkDir} (got a file)`
|
|
23592
23837
|
);
|
|
@@ -23613,7 +23858,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
23613
23858
|
let fileSize = 0;
|
|
23614
23859
|
for (const name of readdirSync12(outputPath)) {
|
|
23615
23860
|
try {
|
|
23616
|
-
fileSize +=
|
|
23861
|
+
fileSize += statSync16(join50(outputPath, name)).size;
|
|
23617
23862
|
} catch {
|
|
23618
23863
|
}
|
|
23619
23864
|
}
|