mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
fix(producer): cap a render's total sub-composition expansion (#8045)
* fix(producer): cap a render's total sub-composition expansion The 16 MB limit checked each composition file alone, so a few small files that mount each other many times assembled a page far larger, and the pre-flight walk and sub-composition compile redid their work for every mount. The pre-flight walk now reads each file once and charges every mount to one budget: 32 MB of composition HTML across at most 10,000 mounts. Past either limit the render fails with the existing non-retryable COMPOSITION_TOO_LARGE error, before compiling. Sub-composition compilation handles each path once, and the inliner charges each mount to the same budget as it builds the page. * docs: describe the total sub-composition expansion limit * fix(producer): check each mount path and read each fallback file once The pre-flight walk resolved and checked a mount's path on disk for every mount, and the inliner's disk fallback did the same for every mount it inlined. Both now do it once per path, so a refused fan-out costs about half a second instead of several. The test now covers both a fan-out the pre-flight refuses and one inside templates, which only the inliner sees. * fix(producer): the pre-flight charges mounts inside templates to the budget The pre-flight walk could not see mounts inside a <template>, so a template-wrapped fan-out was only refused by the inliner, after seconds of work. The walk now charges those mounts to the same budget without reporting them, since the inliner still only warns about a broken one. The refusal now names which limit it passed, and the tests assert the mount count instead of a time.
This commit is contained in:
@@ -416,6 +416,8 @@ Keep the first exact error rather than only the final “render failed” messag
|
||||
|
||||
A render refuses any composition HTML file, the entry or a sub-composition, that is larger than 16 MB. The error code is `COMPOSITION_TOO_LARGE`. Keep images, fonts and data in separate files and reference them by path instead of inlining them.
|
||||
|
||||
The same error refuses a render whose sub-composition mounts add up to more than 32 MB of composition HTML, or to more than 10,000 mounts. Every mount counts, including each repeat of the same file and each mount nested inside another.
|
||||
|
||||
<Tip>
|
||||
Always watch the exported file itself. Preview proves that the project can play; the output file
|
||||
proves that the delivery is correct.
|
||||
|
||||
@@ -11,22 +11,65 @@ const COMPOSITION_TOO_LARGE = "COMPOSITION_TOO_LARGE" as const;
|
||||
|
||||
const megabytes = (bytes: number) => `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
||||
|
||||
/**
|
||||
* What one render may inline across every sub-composition mount. Each file is checked on its own
|
||||
* above, but a few small files that mount each other many times assemble a page far larger.
|
||||
*/
|
||||
export const MAX_EXPANDED_COMPOSITION_BYTES = 2 * MAX_COMPOSITION_HTML_BYTES;
|
||||
const MAX_COMPOSITION_MOUNTS = 10_000;
|
||||
|
||||
class CompositionTooLargeError extends Error {
|
||||
readonly code = COMPOSITION_TOO_LARGE;
|
||||
// The producer server reads these off the error for the wire envelope.
|
||||
readonly owner = "user" as const;
|
||||
readonly retryable = false as const;
|
||||
readonly publicMetadata: Readonly<{ bytes: number; limitBytes: number }>;
|
||||
|
||||
constructor(file: string, bytes: number) {
|
||||
super(
|
||||
`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.",
|
||||
);
|
||||
constructor(
|
||||
message: string,
|
||||
readonly publicMetadata: Readonly<{
|
||||
bytes: number;
|
||||
limitBytes: number;
|
||||
mounts?: number;
|
||||
exceeded?: "bytes" | "mounts";
|
||||
}>,
|
||||
) {
|
||||
super(message);
|
||||
this.name = "CompositionTooLargeError";
|
||||
this.publicMetadata = { bytes, limitBytes: MAX_COMPOSITION_HTML_BYTES };
|
||||
}
|
||||
}
|
||||
|
||||
const fileTooLarge = (file: string, bytes: number) =>
|
||||
new CompositionTooLargeError(
|
||||
`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.",
|
||||
{ bytes, limitBytes: MAX_COMPOSITION_HTML_BYTES },
|
||||
);
|
||||
|
||||
/** Adds up every mount a render inlines and throws once the total passes either limit. */
|
||||
export class CompositionExpansionBudget {
|
||||
private bytes = 0;
|
||||
private mounts = 0;
|
||||
|
||||
charge(file: string, bytes: number): void {
|
||||
this.bytes += bytes;
|
||||
this.mounts += 1;
|
||||
if (this.bytes <= MAX_EXPANDED_COMPOSITION_BYTES && this.mounts <= MAX_COMPOSITION_MOUNTS) {
|
||||
return;
|
||||
}
|
||||
throw new CompositionTooLargeError(
|
||||
`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.`,
|
||||
{
|
||||
bytes: this.bytes,
|
||||
limitBytes: MAX_EXPANDED_COMPOSITION_BYTES,
|
||||
mounts: this.mounts,
|
||||
exceeded: this.mounts > MAX_COMPOSITION_MOUNTS ? "mounts" : "bytes",
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,5 +86,5 @@ export function assertCompositionFileSize(path: string, file: string): void {
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
if (bytes > MAX_COMPOSITION_HTML_BYTES) throw new CompositionTooLargeError(file, bytes);
|
||||
if (bytes > MAX_COMPOSITION_HTML_BYTES) throw fileTooLarge(file, bytes);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,11 @@ import { mkdtempSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { assertCompositionFileSize, MAX_COMPOSITION_HTML_BYTES } from "./compositionSizeLimit.js";
|
||||
import {
|
||||
assertCompositionFileSize,
|
||||
MAX_COMPOSITION_HTML_BYTES,
|
||||
MAX_EXPANDED_COMPOSITION_BYTES,
|
||||
} from "./compositionSizeLimit.js";
|
||||
import { compileForRender } from "./htmlCompiler.js";
|
||||
import { extractSafeRenderErrorCode } from "./safeRenderErrorCode.js";
|
||||
|
||||
@@ -76,3 +80,78 @@ describe("composition HTML size limit", () => {
|
||||
expect(() => assertCompositionFileSize(dir, "folder")).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
/** A root that mounts `src` `count` times. */
|
||||
const rootMounting = (src: string, count: number) =>
|
||||
ROOT.replace(
|
||||
/<div data-composition-id="scene"[^>]*><\/div>/,
|
||||
`<div data-composition-id="scene" data-composition-src="${src}" data-start="0" data-duration="2"></div>`.repeat(
|
||||
count,
|
||||
),
|
||||
);
|
||||
|
||||
/** A sub-composition that mounts `src` `count` times, as a bare fragment or inside a `<template>`. */
|
||||
const sceneMounting = (id: string, src: string, count: number, template = true) => {
|
||||
const root = `<div data-composition-id="${id}">${`<div data-composition-src="${src}"></div>`.repeat(count)}</div>`;
|
||||
return template ? `<template>${root}</template>` : root;
|
||||
};
|
||||
|
||||
/** Seven files, each mounting the next one ten times. */
|
||||
function fanOut(template: boolean): Record<string, string> {
|
||||
const files: Record<string, string> = { "index.html": rootMounting("level-0.html", 10) };
|
||||
for (let level = 0; level < 6; level += 1) {
|
||||
files[`level-${level}.html`] = sceneMounting(
|
||||
`level-${level}`,
|
||||
`level-${level + 1}.html`,
|
||||
10,
|
||||
template,
|
||||
);
|
||||
}
|
||||
files["level-6.html"] = SCENE;
|
||||
return files;
|
||||
}
|
||||
|
||||
describe("composition expansion budget", () => {
|
||||
it.each([
|
||||
["bare fragments", false],
|
||||
["templates", true],
|
||||
])(
|
||||
"refuses small files that mount each other many times, as %s, before compiling",
|
||||
async (_, template) => {
|
||||
const error = await compileError(project(fanOut(template)));
|
||||
expect(extractSafeRenderErrorCode(error)).toBe("COMPOSITION_TOO_LARGE");
|
||||
expect(String(error)).toContain("10001 mounts");
|
||||
expect(error).toMatchObject({ publicMetadata: { mounts: 10_001, exceeded: "mounts" } });
|
||||
},
|
||||
);
|
||||
|
||||
it("refuses one large file mounted many times", async () => {
|
||||
const big = Math.ceil(MAX_EXPANDED_COMPOSITION_BYTES / 4) + 1;
|
||||
const dir = project({
|
||||
"index.html": rootMounting("scene.html", 4),
|
||||
"scene.html": paddedTo(SCENE, big),
|
||||
});
|
||||
const error = await compileError(dir);
|
||||
expect(extractSafeRenderErrorCode(error)).toBe("COMPOSITION_TOO_LARGE");
|
||||
expect(String(error)).toContain('"scene.html"');
|
||||
});
|
||||
|
||||
it("leaves a missing mount inside a template to the inliner's warning, as before", async () => {
|
||||
const dir = project({
|
||||
"index.html": rootMounting("wrapper.html", 1),
|
||||
"wrapper.html": `<template><div data-composition-id="wrapper"><h1>Kept</h1><div data-composition-src="missing.html"></div></div></template>`,
|
||||
});
|
||||
const compiled = await compileForRender(dir, join(dir, "index.html"), dir);
|
||||
expect(compiled.html).toContain("<h1>Kept</h1>");
|
||||
});
|
||||
|
||||
it("still compiles a scene mounted a few times, once per mount", async () => {
|
||||
const dir = project({
|
||||
"index.html": rootMounting("wrapper.html", 3),
|
||||
"wrapper.html": sceneMounting("wrapper", "scene.html", 2),
|
||||
"scene.html": SCENE,
|
||||
});
|
||||
const compiled = await compileForRender(dir, join(dir, "index.html"), dir);
|
||||
expect(compiled.html.split("<h1>Scene</h1>").length - 1).toBe(6);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -102,7 +102,7 @@ import {
|
||||
import { isPrivateFileUnder, isStudioPrivatePath } from "@hyperframes/core/safe-path";
|
||||
import { linksOutside } from "@hyperframes/studio-server/outside-file";
|
||||
import { extractMediaMetadata, extractAudioMetadata } from "../utils/ffprobe.js";
|
||||
import { assertCompositionFileSize } from "./compositionSizeLimit.js";
|
||||
import { assertCompositionFileSize, CompositionExpansionBudget } from "./compositionSizeLimit.js";
|
||||
import {
|
||||
escapesAssetRoot,
|
||||
isPathInside,
|
||||
@@ -300,6 +300,57 @@ const runsOutsideMarkupUnasked = (
|
||||
const isPrivateCompositionFile = (projectDir: string, filePath: string): boolean =>
|
||||
isPrivateFileUnder(projectDir, filePath, isStudioPrivatePath);
|
||||
|
||||
type CompositionProblem = { srcPath: string; detail: string };
|
||||
|
||||
const mountSrcsUnder = (root: ParentNode): string[] =>
|
||||
[...root.querySelectorAll("[data-composition-src]")]
|
||||
.map((el) => el.getAttribute("data-composition-src"))
|
||||
.filter((srcPath): srcPath is string => !!srcPath && !isUnresolvedAssetPlaceholder(srcPath));
|
||||
|
||||
/** `templated` holds the mounts inside `<template>` content, which a document query does not see. */
|
||||
function compositionSrcsIn(html: string): { mounts: string[]; templated: string[] } {
|
||||
const { document } = parseHTML(html);
|
||||
const templated: string[] = [];
|
||||
const templates = [...document.querySelectorAll("template")];
|
||||
for (let template = templates.pop(); template; template = templates.pop()) {
|
||||
templated.push(...mountSrcsUnder(template.content));
|
||||
templates.push(...template.content.querySelectorAll("template"));
|
||||
}
|
||||
return { mounts: mountSrcsUnder(document), templated };
|
||||
}
|
||||
|
||||
function compositionPathProblem(
|
||||
projectDir: string,
|
||||
filePath: string,
|
||||
assetRoot: string | undefined,
|
||||
outsideFiles: OutsideFilePolicy,
|
||||
): string | null {
|
||||
if (outsideAssetRefusal(projectDir, filePath) === "blocklisted") {
|
||||
return "it is outside the project in a private location";
|
||||
}
|
||||
if (runsOutsideMarkupUnasked(projectDir, filePath, assetRoot, outsideFiles)) {
|
||||
return OUTSIDE_COMPOSITION_NEEDS_FLAG;
|
||||
}
|
||||
if (isPrivateCompositionFile(projectDir, filePath)) {
|
||||
return "it is git metadata, an env file or a private tool record";
|
||||
}
|
||||
return COMPOSITION_FILE.test(filePath) ? null : NOT_A_COMPOSITION_FILE;
|
||||
}
|
||||
|
||||
function readSubCompositionFile(
|
||||
filePath: string,
|
||||
srcPath: string,
|
||||
): { detail: string } | { bytes: number; mounts: string[]; templated: string[] } {
|
||||
assertCompositionFileSize(filePath, srcPath);
|
||||
const read = readProjectFile(filePath);
|
||||
if (read.kind === "missing") return { detail: "the file does not exist" };
|
||||
if (read.kind === "folder") return { detail: "it is a folder, not an HTML file" };
|
||||
const validity = checkSubCompositionUsability(read.text, parseSubCompHtmlForValidity);
|
||||
if (!validity.ok)
|
||||
return { detail: validity.detail ?? "the file is empty or could not be parsed" };
|
||||
return { bytes: Buffer.byteLength(read.text), ...compositionSrcsIn(read.text) };
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively walk every `data-composition-src` reference reachable from
|
||||
* `html` (including nested sub-compositions) and verify each resolves to a
|
||||
@@ -314,98 +365,66 @@ const isPrivateCompositionFile = (projectDir: string, filePath: string): boolean
|
||||
* exchange for failing in milliseconds instead of after the browser has
|
||||
* already launched and waited out a capture timeout.
|
||||
*/
|
||||
// fallow-ignore-next-line complexity
|
||||
function assertSubCompositionsUsable(
|
||||
html: string,
|
||||
projectDir: string,
|
||||
assetRoot: string | undefined,
|
||||
outsideFiles: OutsideFilePolicy,
|
||||
visited: Set<string> = new Set(),
|
||||
): void {
|
||||
const { document } = parseHTML(html);
|
||||
const hosts = [...document.querySelectorAll("[data-composition-src]")];
|
||||
const problems: Array<{ srcPath: string; detail: string }> = [];
|
||||
|
||||
for (const el of hosts) {
|
||||
const srcPath = el.getAttribute("data-composition-src");
|
||||
if (!srcPath) continue;
|
||||
if (isUnresolvedAssetPlaceholder(srcPath)) continue; // __UPPER__ placeholder or unresolved templating token — not a real reference (shared with lint via @hyperframes/parsers)
|
||||
|
||||
const budget = new CompositionExpansionBudget();
|
||||
const files = new Map<string, ReturnType<typeof readSubCompositionFile>>();
|
||||
const problems = new Map<string, CompositionProblem>();
|
||||
const report = (srcPath: string, detail: string) =>
|
||||
problems.set(`${srcPath}\0${detail}`, { srcPath, detail });
|
||||
// The files on the current mount chain. A repeat is a cycle, which the compiler skips silently too.
|
||||
const chain = new Set<string>();
|
||||
const paths = new Map<string, { detail: string } | { filePath: string }>();
|
||||
const resolveMount = (srcPath: string): { detail: string } | { filePath: string } => {
|
||||
const filePath = resolveCompositionPath(projectDir, srcPath, assetRoot);
|
||||
if (filePath === null) {
|
||||
problems.push({ srcPath, detail: "it is outside the project folder" });
|
||||
continue;
|
||||
}
|
||||
if (outsideAssetRefusal(projectDir, filePath) === "blocklisted") {
|
||||
problems.push({ srcPath, detail: "it is outside the project in a private location" });
|
||||
continue;
|
||||
}
|
||||
if (runsOutsideMarkupUnasked(projectDir, filePath, assetRoot, outsideFiles)) {
|
||||
problems.push({ srcPath, detail: OUTSIDE_COMPOSITION_NEEDS_FLAG });
|
||||
continue;
|
||||
}
|
||||
if (isPrivateCompositionFile(projectDir, filePath)) {
|
||||
problems.push({
|
||||
srcPath,
|
||||
detail: "it is git metadata, an env file or a private tool record",
|
||||
});
|
||||
continue;
|
||||
}
|
||||
if (!COMPOSITION_FILE.test(filePath)) {
|
||||
problems.push({ srcPath, detail: NOT_A_COMPOSITION_FILE });
|
||||
continue;
|
||||
}
|
||||
// Circular reference guard. parseSubCompositions (below) silently
|
||||
// `continue`s on a repeat visit with no reporting at all — mirror that
|
||||
// silence here rather than pretend it surfaces an error somewhere else.
|
||||
if (visited.has(filePath)) continue;
|
||||
if (filePath === null) return { detail: "it is outside the project folder" };
|
||||
const detail = compositionPathProblem(projectDir, filePath, assetRoot, outsideFiles);
|
||||
return detail ? { detail } : { filePath };
|
||||
};
|
||||
|
||||
assertCompositionFileSize(filePath, srcPath);
|
||||
const read = readProjectFile(filePath);
|
||||
if (read.kind === "missing") {
|
||||
problems.push({ srcPath, detail: "the file does not exist" });
|
||||
continue;
|
||||
}
|
||||
if (read.kind === "folder") {
|
||||
problems.push({ srcPath, detail: "it is a folder, not an HTML file" });
|
||||
continue;
|
||||
}
|
||||
|
||||
const fileHtml = read.text;
|
||||
const validity = checkSubCompositionUsability(fileHtml, parseSubCompHtmlForValidity);
|
||||
if (!validity.ok) {
|
||||
problems.push({
|
||||
srcPath,
|
||||
detail: validity.detail ?? "the file is empty or could not be parsed",
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
// Recurse into nested sub-compositions so a broken scene three levels
|
||||
// deep is still named directly instead of surfacing as a parent-level
|
||||
// "no error, just missing content" mystery.
|
||||
//
|
||||
// Pass `projectDir` unchanged (not dirname(filePath)) — data-composition-src
|
||||
// is always resolved root-relative, even from within a nested
|
||||
// sub-composition. This must match parseSubCompositions' own recursive
|
||||
// call below exactly (it threads the original projectDir through every
|
||||
// level too), or this pre-flight check resolves nested references to the
|
||||
// wrong path and aborts renders that would have actually succeeded.
|
||||
const nestedVisited = new Set(visited);
|
||||
nestedVisited.add(filePath);
|
||||
try {
|
||||
assertSubCompositionsUsable(fileHtml, projectDir, assetRoot, outsideFiles, nestedVisited);
|
||||
} catch (err) {
|
||||
if (err instanceof EmptyCompositionError) {
|
||||
problems.push(...err.problems);
|
||||
} else {
|
||||
throw err;
|
||||
// data-composition-src resolves root-relative at every level, as parseSubCompositions and the inliner
|
||||
// resolve it, so `projectDir` stays unchanged. Each path is checked, and each file read, once.
|
||||
// A mount inside a template is charged to the budget but not reported: the inliner skips it with a warning.
|
||||
const walk = (srcPaths: readonly string[], quiet: boolean): void => {
|
||||
for (const srcPath of srcPaths) {
|
||||
let resolved = paths.get(srcPath);
|
||||
if (!resolved) {
|
||||
resolved = resolveMount(srcPath);
|
||||
paths.set(srcPath, resolved);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ("detail" in resolved) {
|
||||
if (!quiet) report(srcPath, resolved.detail);
|
||||
continue;
|
||||
}
|
||||
const { filePath } = resolved;
|
||||
if (chain.has(filePath)) continue;
|
||||
|
||||
if (problems.length > 0) {
|
||||
throw new EmptyCompositionError(problems);
|
||||
let file = files.get(filePath);
|
||||
if (!file) {
|
||||
file = readSubCompositionFile(filePath, srcPath);
|
||||
files.set(filePath, file);
|
||||
}
|
||||
if ("detail" in file) {
|
||||
if (!quiet) report(srcPath, file.detail);
|
||||
continue;
|
||||
}
|
||||
budget.charge(srcPath, file.bytes);
|
||||
chain.add(filePath);
|
||||
walk(file.mounts, quiet);
|
||||
walk(file.templated, true);
|
||||
chain.delete(filePath);
|
||||
}
|
||||
};
|
||||
const entry = compositionSrcsIn(html);
|
||||
walk(entry.mounts, false);
|
||||
walk(entry.templated, true);
|
||||
|
||||
if (problems.size > 0) {
|
||||
throw new EmptyCompositionError([...problems.values()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -875,6 +894,7 @@ async function parseSubCompositions(
|
||||
urlByAbsentLocalPath?: ReadonlyMap<string, string>,
|
||||
probes?: SourceProbes,
|
||||
assetRoot?: string,
|
||||
compiledSrcs: Set<string> = new Set(),
|
||||
): Promise<{ subCompositions: Map<string, string> }> {
|
||||
const subCompositions = new Map<string, string>();
|
||||
|
||||
@@ -900,6 +920,9 @@ async function parseSubCompositions(
|
||||
if (visited.has(filePath)) {
|
||||
continue;
|
||||
}
|
||||
// A path compiles the same wherever it is mounted, so each one is compiled once per render.
|
||||
if (compiledSrcs.has(srcPath)) continue;
|
||||
compiledSrcs.add(srcPath);
|
||||
|
||||
assertCompositionFileSize(filePath, srcPath);
|
||||
const read = readProjectFile(filePath);
|
||||
@@ -936,6 +959,7 @@ async function parseSubCompositions(
|
||||
urlByAbsentLocalPath,
|
||||
probes,
|
||||
assetRoot,
|
||||
compiledSrcs,
|
||||
);
|
||||
|
||||
return {
|
||||
@@ -1162,6 +1186,26 @@ function inlineSubCompositions(
|
||||
return { html: emitted ? document.toString() : html, variablesByComp: {} };
|
||||
}
|
||||
|
||||
const budget = new CompositionExpansionBudget();
|
||||
const readOnce = new Map<string, string | null>();
|
||||
const readMountHtml = (srcPath: string): string | null => {
|
||||
const filePath = resolveCompositionFile(projectDir, srcPath, assetRoot);
|
||||
if (filePath) assertCompositionFileSize(filePath, srcPath);
|
||||
const read =
|
||||
filePath && !isPrivateCompositionFile(projectDir, filePath)
|
||||
? readProjectFile(filePath)
|
||||
: null;
|
||||
return read?.kind === "file"
|
||||
? rewriteUnresolvableGsapToCdn(read.text, projectDir, srcPath)
|
||||
: null;
|
||||
};
|
||||
const resolveMountHtml = (srcPath: string): string | null => {
|
||||
const compiled = subCompositions.get(srcPath);
|
||||
if (compiled) return compiled;
|
||||
if (!readOnce.has(srcPath)) readOnce.set(srcPath, readMountHtml(srcPath));
|
||||
return readOnce.get(srcPath) ?? null;
|
||||
};
|
||||
|
||||
// Assign per-instance runtime composition ids before each host is inlined,
|
||||
// mirroring the preview bundler. Initial hosts are assigned as one pre-pass;
|
||||
// hosts discovered by the shared inliner's queue are assigned lazily by the
|
||||
@@ -1189,18 +1233,8 @@ function inlineSubCompositions(
|
||||
readVariableDefaults: readDeclaredDefaults,
|
||||
parseHostVariables: parseHostVariableValues,
|
||||
resolveHtml: (srcPath: string) => {
|
||||
let compHtml = subCompositions.get(srcPath) || null;
|
||||
if (!compHtml) {
|
||||
const filePath = resolveCompositionFile(projectDir, srcPath, assetRoot);
|
||||
if (filePath) assertCompositionFileSize(filePath, srcPath);
|
||||
const read =
|
||||
filePath && !isPrivateCompositionFile(projectDir, filePath)
|
||||
? readProjectFile(filePath)
|
||||
: null;
|
||||
if (read?.kind === "file") {
|
||||
compHtml = rewriteUnresolvableGsapToCdn(read.text, projectDir, srcPath);
|
||||
}
|
||||
}
|
||||
const compHtml = resolveMountHtml(srcPath);
|
||||
if (compHtml) budget.charge(srcPath, Buffer.byteLength(compHtml));
|
||||
return compHtml;
|
||||
},
|
||||
parseHtml: (htmlStr: string) => parseHTML(htmlStr).document as unknown as Document,
|
||||
|
||||
Reference in New Issue
Block a user