mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-23 19:46:11 +00:00
* fix(core): give the preview bundler the render's expansion budget The preview bundler inlined every sub-composition mount with only a depth limit, so a few small files that mount each other many times assembled a page without bound. The producer's expansion budget now lives in core, and the bundler charges every mount and the scripts and styles generated for it to that budget, and checks each file's size before reading it. Studio preview shows the refusal instead of falling back to the raw page, whose mounts the browser would expand the same way. * refactor: drop comments the names already carry * test(core): give the preview fan-out budget test a 30 s timeout The flake gate saw it pass 9 of 10 runs under CPU contention, timing out at the default 5 s. The neighbouring scoper bound tests use 30 s too.
17 lines
609 B
TypeScript
17 lines
609 B
TypeScript
import {
|
|
refusedPreviewMessage,
|
|
STUDIO_PREVIEW_ERRORS,
|
|
} from "@hyperframes/core/studio-preview-mark";
|
|
|
|
const htmlText = (text: string) =>
|
|
text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
|
|
export function previewRefusalPage(message: string): string {
|
|
const script = JSON.stringify(message).replace(/</g, "\\u003c");
|
|
return `<!doctype html><meta charset="utf-8"><script>window.${STUDIO_PREVIEW_ERRORS}=[${script}]</script><p>${htmlText(message)}</p>`;
|
|
}
|
|
|
|
export function previewErrorPage(status: number): string {
|
|
return previewRefusalPage(refusedPreviewMessage(status));
|
|
}
|