Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
fix(catalog): fall back to recorded video when directory is over budget (#4084)
Miguel Ángela0e7c43921e1
diff --git a/docs/public/catalog/components/texture-mask-text.json b/docs/public/catalog/components/texture-mask-text.jsondeleted file mode 100644index dbd5636b5f..0000000000--- a/docs/public/catalog/components/texture-mask-text.json+++ /dev/null@@ -1 +0,0 @@-{"html":"<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=1920, height=1080\" />\n <title>Texture Mask Text - Demo</title>\n <style>\n * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n html,\n body {\n margin: 0;\n width: 1920px;\n height: 1080px;\n overflow: hidden;\n background: #111;\n }\n </style>\n </head>\n <body>\n <div\n id=\"demo\"\n data-composition-id=\"texture-mask-text-demo\"\n data-width=\"1920\"\n data-height=\"1080\"\n data-duration=\"5\"\n data-start=\"0\"\n >\n <div class=\"demo-canvas\">\n <div class=\"header\">\n <div class=\"title\">Texture Mask Text</div>\n <div class=\"count\">66 ambientCG luminance masks</div>\n </div>\n <div class=\"groups\" id=\"texture-groups\"></div>\n </div>\n\n <style>\n #demo {\n width: 1920px;\n height: 1080px;\n overflow: hidden;\n background: #111;\n color: #fff;\n font-family:\n Arial Black,\n Arial,\n sans-serif;\n }\n\n .hf-texture-text {\n color: #fff;\n -webkit-mask-size: var(--mask-size, cover);\n mask-size: var(--mask-size, cover);\n -webkit-mask-position: var(--mask-position, center);\n mask-position: var(--mask-position, center);\n -webkit-mask-mode: luminance;\n mask-mode: luminance;\n filter: contrast(var(--mask-contrast, 1));\n }\n\n .demo-canvas {\n width: 1920px;\n height: 1080px;\n background: #111;\n padding: 42px 44px 38px;\n }\n\n .header {\n height: 84px;\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n border-bottom: 1px solid rgba(255, 255, 255, 0.12);\n margin-bottom: 18px;\n }\n\n .title {\n font-size: 34px;\n line-height: 1;\n letter-spacing: 0;\n text-transform: uppercase;\n }\n\n .count {\n font-family: Arial, sans-serif;\n font-size: 18px;\n line-height: 1;\n letter-spacing: 0;\n color: rgba(255, 255, 255, 0.55);\n text-transform: uppercase;\n }\n\n .groups {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n grid-template-rows: repeat(2, 1fr);\n gap: 22px 24px;\n width: 1832px;\n height: 898px;\n }\n\n .group-panel {\n min-width: 0;\n min-height: 0;\n overflow: hidden;\n }\n\n .group-header {\n height: 34px;\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n border-bottom: 1px solid rgba(255, 255, 255, 0.1);\n margin-bottom: 10px;\n }\n\n .group-name {\n font-family: Arial, sans-serif;\n font-size: 13px;\n line-height: 1;\n letter-spacing: 0;\n text-transform: uppercase;\n color: rgba(255, 255, 255, 0.74);\n }\n\n .group-count {\n font-family: Arial, sans-serif;\n font-size: 10px;\n line-height: 1;\n letter-spacing: 0;\n text-transform: uppercase;\n color: rgba(255, 255, 255, 0.52);\n }\n\n .group-grid {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n gap: 8px 10px;\n }\n\n .cell {\n min-width: 0;\n height: 66px;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 9px;\n overflow: hidden;\n }\n\n .label {\n width: 100%;\n font-family: Arial, sans-serif;\n font-size: 11px;\n line-height: 1.1;\n letter-spacing: 0;\n text-transform: uppercase;\n text-align: center;\n color: rgba(255, 255, 255, 0.5);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n .shadow-wrap {\n width: 100%;\n filter: drop-shadow(2px 3px 4px rgba(0, 0, 0, 0.46));\n }\n\n .sample {\n width: 100%;\n font-family:\n Impact,\n Arial Black,\n Arial,\n sans-serif;\n font-size: 31px;\n line-height: 0.9;\n letter-spacing: 0;\n text-transform: uppercase;\n text-align: center;\n white-space: nowrap;\n }\n </style>\n <script>\n const textureMaskTextGroups = [\n [\n \"Masonry\",\n \"brick|Brick|MORTAR,bricks-104|Bricks 104|BRICK,bricks-102|Bricks 102|BRICK,bricks-101|Bricks 101|BRICK,bricks-075-a|Bricks 075 A|BRICK,concrete|Concrete|SCORED,concrete-034|Concrete 034|CONCRETE,concrete-047-a|Concrete 047 A|CONCRETE,concrete-046|Concrete 046|CONCRETE,concrete-042-a|Concrete 042 A|CONCRETE,plaster-001|Plaster 001|PLASTER,painted-plaster-017|Painted Plaster 017|PLASTER\",\n ],\n [\n \"Stone\",\n \"rock|Rock|RUINED,rock-063|Rock 063|ROCK,rock-058|Rock 058|ROCK,onyx|Onyx|VEINED,marble-012|Marble 012|MARBLE,marble-016|Marble 016|MARBLE,travertine-009|Travertine 009|STONE,paving-stones-150|Paving Stones 150|STONE,paving-stones-138|Paving Stones 138|STONE,tiles-138|Tiles 138|TILE\",\n ],\n [\n \"Ground / Road\",\n \"ground-103|Ground 103|GROUND,ground-037|Ground 037|GROUND,ground-054|Ground 054|GROUND,ground-104|Ground 104|GROUND,ground-068|Ground 068|GROUND,ground-080|Ground 080|GROUND,road-012-a|Road 012 A|ROAD,road-008-a|Road 008 A|ROAD,road-007|Road 007|ROAD,road-013-a|Road 013 A|ROAD,road-012-b|Road 012 B|ROAD,road-009-c|Road 009 C|ROAD,asphalt-031|Asphalt 031|ASPHALT\",\n ],\n [\n \"Wood\",\n \"wood|Wood|SLICED,wood-094|Wood 094|WOOD,wood-092|Wood 092|WOOD,wood-051|Wood 051|WOOD,wood-066|Wood 066|WOOD,wood-049|Wood 049|WOOD,wood-058|Wood 058|WOOD,wood-floor-051|Wood Floor 051|FLOOR,wood-floor-064|Wood Floor 064|FLOOR,wood-floor-070|Wood Floor 070|FLOOR,bark-014|Bark 014|BARK\",\n ],\n [\n \"Metal\",\n \"metal|Metal|FADING,metal-049-a|Metal 049 A|METAL,metal-055-a|Metal 055 A|METAL,metal-046-b|Metal 046 B|METAL,metal-061-b|Metal 061 B|METAL,metal-048-a|Metal 048 A|METAL,metal-032|Metal 032|METAL,metal-041-a|Metal 041 A|METAL,metal-038|Metal 038|METAL,diamond-plate-009|Diamond Plate 009|PLATE\",\n ],\n [\n \"Organic / Soft\",\n \"lava|Lava|MOLTEN,grass-005|Grass 005|GRASS,grass-001|Grass 001|GRASS,grass-004|Grass 004|GRASS,carpet|Carpet|WOVEN,fabric-083|Fabric 083|FABRIC,snow|Snow|THAW,snow-015|Snow 015|SNOW,leather-037|Leather 037|LEATHER,fabric-080|Fabric 080|FABRIC\",\n ],\n ];\n const textureGroups = document.getElementById(\"texture-groups\");\n for (const [groupName, rows] of textureMaskTextGroups) {\n const items = rows.split(\",\").map((row) => {\n const [slug, title, sample] = row.split(\"|\");\n return { slug, title, sample };\n });\n const panel = document.createElement(\"section\");\n panel.className = \"group-panel\";\n\n const groupHeader = document.createElement(\"div\");\n groupHeader.className = \"group-header\";\n\n const name = document.createElement(\"div\");\n name.className = \"group-name\";\n name.textContent = groupName;\n\n const count = document.createElement(\"div\");\n count.className = \"group-count\";\n count.textContent = `${items.length} masks`;\n\n groupHeader.append(name, count);\n\n const groupGrid = document.createElement(\"div\");\n groupGrid.className = \"group-grid\";\n\n for (const item of items) {\n const cell = document.createElement(\"div\");\n cell.className = \"cell\";\n\n const label = document.createElement(\"div\");\n label.className = \"label\";\n label.textContent = item.title;\n\n const shadowWrap = document.createElement(\"div\");\n shadowWrap.className = \"shadow-wrap\";\n\n const sample = document.createElement(\"div\");\n sample.className = \"hf-texture-text sample\";\n sample.style.webkitMaskImage = `url(\"masks/${item.slug}.png\")`;\n sample.style.maskImage = `url(\"masks/${item.slug}.png\")`;\n sample.textContent = item.sample;\n\n shadowWrap.appendChild(sample);\n cell.append(label, shadowWrap);\n groupGrid.appendChild(cell);\n }\n\n panel.append(groupHeader, groupGrid);\n textureGroups.appendChild(panel);\n }\n\n window.__timelines = window.__timelines || {};\n const textureMaskTextTimeline = {\n play() {},\n pause() {},\n seek() {},\n time() {\n return 0;\n },\n duration() {\n return 5;\n },\n add() {},\n paused() {},\n set() {},\n };\n window.__timelines[\"texture-mask-text-demo\"] = textureMaskTextTimeline;\n </script>\n </div>\n </body>\n</html>\n"}\ No newline at end of filediff --git a/scripts/catalog-payload-assets.test.ts b/scripts/catalog-payload-assets.test.tsindex beaf6b136d..f30a9be9b3 100644--- a/scripts/catalog-payload-assets.test.ts+++ b/scripts/catalog-payload-assets.test.ts@@ -7,6 +7,7 @@ import {externalizeDataUris,hostItemDirectory,localReferences,+ MAX_HOSTED_DIRECTORY_BYTES,probableReferences,processAssets,withBaseHref,@@ -250,9 +251,9 @@ describe("hostItemDirectory", () => {// time, so the layout has to survive, not just the files.const dir = project({ "compositions/components/lava.png": Buffer.from([1]), "demo.html": "x" });const out = target();- const base = hostItemDirectory(dir, out.dir, "/public/catalog/items/x/");+ const result = hostItemDirectory(dir, out.dir, "/public/catalog/items/x/");- assert.equal(base, "/public/catalog/items/x/");+ assert.deepEqual(result, { status: "hosted", baseHref: "/public/catalog/items/x/" });assert.ok(existsSync(join(out.dir, "compositions/components/lava.png")));});@@ -268,7 +269,15 @@ describe("hostItemDirectory", () => {const dir = project({ "scene.glb": Buffer.from([3]) });const out = target();- assert.equal(hostItemDirectory(dir, out.dir, "/base/"), "");+ assert.deepEqual(hostItemDirectory(dir, out.dir, "/base/"), { status: "not-needed" });+ });++ it("reports over-budget distinctly from not-needed when the directory exceeds the cap", () => {+ const dir = project({ "big.png": Buffer.alloc(MAX_HOSTED_DIRECTORY_BYTES + 1) });+ const out = target();++ assert.deepEqual(hostItemDirectory(dir, out.dir, "/base/"), { status: "over-budget" });+ assert.equal(existsSync(join(out.dir, "big.png")), false);});});diff --git a/scripts/catalog-payload-assets.ts b/scripts/catalog-payload-assets.tsindex 04c019959f..47fa053e09 100644--- a/scripts/catalog-payload-assets.ts+++ b/scripts/catalog-payload-assets.ts@@ -387,7 +387,20 @@ function downloadMirrorPrefix(projectDir: string): string | null {*/export const MAX_HOSTED_DIRECTORY_BYTES = 2_000_000;-export function hostItemDirectory(projectDir: string, destDir: string, urlBase: string): string {+// "not-needed" and "over-budget" both leave nothing published, but the caller+// must not treat them alike: an over-budget item still needs the directory,+// so it has to fall back to its recorded video instead of shipping with dead+// relative references and no <base> to resolve them against.+export type HostItemDirectoryResult =+ | { readonly status: "not-needed" }+ | { readonly status: "hosted"; readonly baseHref: string }+ | { readonly status: "over-budget" };++export function hostItemDirectory(+ projectDir: string,+ destDir: string,+ urlBase: string,+): HostItemDirectoryResult {const mirrorPrefix = downloadMirrorPrefix(projectDir);const files = new Map<string, Buffer<ArrayBuffer>>();let total = 0;@@ -399,7 +412,7 @@ export function hostItemDirectory(projectDir: string, destDir: string, urlBase:);if (bytes === null) continue;total += bytes.length;- if (total > MAX_HOSTED_DIRECTORY_BYTES) return "";+ if (total > MAX_HOSTED_DIRECTORY_BYTES) return { status: "over-budget" };files.set(path, bytes);}@@ -418,7 +431,7 @@ export function hostItemDirectory(projectDir: string, destDir: string, urlBase:if (mirrorPrefix !== null && path.startsWith(mirrorPrefix))publish(path.slice(mirrorPrefix.length), bytes);}- return files.size > 0 ? urlBase : "";+ return files.size > 0 ? { status: "hosted", baseHref: urlBase } : { status: "not-needed" };}/**diff --git a/scripts/catalog/catalog-payload-assets.file-race.test.ts b/scripts/catalog/catalog-payload-assets.file-race.test.tsindex cd5cd4b0e2..eda986408b 100644--- a/scripts/catalog/catalog-payload-assets.file-race.test.ts+++ b/scripts/catalog/catalog-payload-assets.file-race.test.ts@@ -131,6 +131,12 @@ function file(name: string, bytes = "checked") {fs.writeFileSync(path, bytes);return path;}+function expectHosted() {+ expect(hostItemDirectory(project, out.dir, "/item/")).toEqual({+ status: "hosted",+ baseHref: "/item/",+ });+}function arm(path: string) {hooks.target = path;hooks.swap = () => {@@ -162,7 +168,7 @@ describe("catalog source reads", () => {(mirror) => {arm(file(mirror ? "_downloads/font.woff2" : "font.woff2"));- expect(hostItemDirectory(project, out.dir, "/item/")).toBe("/item/");+ expectHosted();expect(fs.readFileSync(join(out.dir, "font.woff2"), "utf8")).toBe("checked");expect(hooks.swap).toBeUndefined();},@@ -173,7 +179,7 @@ describe("catalog source reads", () => {fs.renameSync(path, join(root, "original"));fs.writeFileSync(path, Buffer.alloc(MAX_HOSTED_DIRECTORY_BYTES + 1));};- expect(hostItemDirectory(project, out.dir, "/item/")).toBe("");+ expect(hostItemDirectory(project, out.dir, "/item/")).toEqual({ status: "over-budget" });expect(hooks.beforeOpen).toBeUndefined();expect(fs.existsSync(out.dir)).toBe(false);});@@ -182,7 +188,7 @@ describe("catalog source reads", () => {const path = file("large.mp4", "");fs.truncateSync(path, 32 * 1024 * 1024);hooks.forbidUnbounded = true;- expect(hostItemDirectory(project, out.dir, "/item/")).toBe("");+ expect(hostItemDirectory(project, out.dir, "/item/")).toEqual({ status: "over-budget" });expect(hooks.bytesRead).toBe(MAX_HOSTED_DIRECTORY_BYTES + 1);expect(fs.existsSync(out.dir)).toBe(false);});@@ -190,7 +196,7 @@ describe("catalog source reads", () => {const path = file("asset.webm", "x");hooks.afterStat = () => fs.truncateSync(path, MAX_HOSTED_DIRECTORY_BYTES * 2);hooks.forbidUnbounded = true;- expect(hostItemDirectory(project, out.dir, "/item/")).toBe("");+ expect(hostItemDirectory(project, out.dir, "/item/")).toEqual({ status: "over-budget" });expect(hooks.afterStat).toBeUndefined();expect(hooks.bytesRead).toBe(MAX_HOSTED_DIRECTORY_BYTES + 1);expect(fs.existsSync(out.dir)).toBe(false);@@ -199,7 +205,7 @@ describe("catalog source reads", () => {file("font.woff2");hooks.forbidUnbounded = true;hooks.maxReadSize = 2;- expect(hostItemDirectory(project, out.dir, "/item/")).toBe("/item/");+ expectHosted();expect(fs.readFileSync(join(out.dir, "font.woff2"), "utf8")).toBe("checked");expect(hooks.bytesRead).toBe(7);});@@ -215,14 +221,14 @@ describe("catalog source reads", () => {file("b.png", "b".repeat(MAX_HOSTED_DIRECTORY_BYTES));fs.mkdirSync(out.dir);fs.writeFileSync(join(out.dir, "a.png"), "existing");- expect(hostItemDirectory(project, out.dir, "/item/")).toBe("");+ expect(hostItemDirectory(project, out.dir, "/item/")).toEqual({ status: "over-budget" });expect(fs.readdirSync(out.dir)).toEqual(["a.png"]);expect(fs.readFileSync(join(out.dir, "a.png"), "utf8")).toBe("existing");});it("reuses budgeted bytes for download mirrors after sources change during publication", () => {const path = file("_downloads/font.woff2", "x".repeat(MAX_HOSTED_DIRECTORY_BYTES));hooks.beforeWrite = () => fs.writeFileSync(path, "unchecked");- expect(hostItemDirectory(project, out.dir, "/item/")).toBe("/item/");+ expectHosted();expect(hooks.beforeWrite).toBeUndefined();const original = Buffer.alloc(MAX_HOSTED_DIRECTORY_BYTES, "x");expect(fs.readFileSync(join(out.dir, "_downloads/font.woff2")).equals(original)).toBe(true);@@ -235,7 +241,7 @@ describe("catalog source reads", () => {join(project, "_downloads"),process.platform === "win32" ? "junction" : "dir",);- expect(hostItemDirectory(project, out.dir, "/item/")).toBe("/item/");+ expectHosted();expect(fs.readFileSync(join(out.dir, "media/font.woff2"), "utf8")).toBe("checked");expect(fs.readFileSync(join(out.dir, "font.woff2"), "utf8")).toBe("checked");expect(fs.existsSync(join(out.dir, "_downloads"))).toBe(false);@@ -244,7 +250,7 @@ describe("catalog source reads", () => {it("preserves download mirror precedence over a colliding root asset", () => {file("font.woff2", "root");file("_downloads/font.woff2", "download");- expect(hostItemDirectory(project, out.dir, "/item/")).toBe("/item/");+ expectHosted();expect(fs.readFileSync(join(out.dir, "font.woff2"), "utf8")).toBe("download");});it.each(["png", "glb", "html"])("does not publish an external .%s symlink target", (ext) => {@@ -270,7 +276,7 @@ describe("catalog source reads", () => {join(project, "_downloads"),process.platform === "win32" ? "junction" : "dir",);- expect(hostItemDirectory(project, out.dir, "/item/")).toBe("");+ expect(hostItemDirectory(project, out.dir, "/item/")).toEqual({ status: "not-needed" });expect(fs.existsSync(out.dir)).toBe(false);});it("keeps internal file links and a symlinked project root working", () => {diff --git a/scripts/check-no-main-deletions.mjs b/scripts/check-no-main-deletions.mjsindex c4f22f493d..89f4296bb9 100644--- a/scripts/check-no-main-deletions.mjs+++ b/scripts/check-no-main-deletions.mjs@@ -157,6 +157,10 @@ export const ALLOWED_DELETIONS = new Map(["packages/studio/src/player/store/groupLevels.ts","#3454 deliberately removes group level-meter state",],+ [+ "docs/public/catalog/components/texture-mask-text.json",+ "the item's directory exceeds the host budget and now falls back to its recorded video; the stale payload had no <base href> and dead relative asset references, so removing it is the fix, not the regression",+ ],]);export function parseBase(argv, fallback = "origin/main") {diff --git a/scripts/generate-catalog-payloads.test.ts b/scripts/generate-catalog-payloads.test.tsnew file mode 100644index 0000000000..8dfbd1af37--- /dev/null+++ b/scripts/generate-catalog-payloads.test.ts@@ -0,0 +1,68 @@+import { afterEach, describe, expect, it, vi } from "vitest";+import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";+import { join } from "node:path";+import { tmpdir } from "node:os";++vi.mock("./generate-catalog-previews.js", async (importOriginal) => ({+ ...(await importOriginal<typeof import("./generate-catalog-previews.js")>()),+ prepareProjectDir: vi.fn(),+}));+vi.mock("./catalog-payload-assets.ts", async (importOriginal) => ({+ ...(await importOriginal<typeof import("./catalog-payload-assets.ts")>()),+ hostItemDirectory: vi.fn(),+}));++import { prepareProjectDir } from "./generate-catalog-previews.js";+import { hostItemDirectory } from "./catalog-payload-assets.ts";+import { buildPayload, payloadRoot } from "./generate-catalog-payloads.ts";++const cleanupPaths: string[] = [];+function tmpDir(): string {+ const dir = mkdtempSync(join(tmpdir(), "hf-catalog-payload-"));+ cleanupPaths.push(dir);+ return dir;+}++afterEach(() => {+ vi.clearAllMocks();+ for (const path of cleanupPaths) rmSync(path, { recursive: true, force: true });+ cleanupPaths.length = 0;+});++describe("buildPayload", () => {+ it("skips and drops a stale payload when the item's directory is over the host budget", async () => {+ const sourceDir = tmpDir();+ // Declares a local asset so `needsOwnDirectory` routes through `hostItemDirectory`.+ writeFileSync(+ join(sourceDir, "registry-item.json"),+ JSON.stringify({ files: [{ type: "hyperframes:asset" }] }),+ );+ const projectDir = tmpDir();+ writeFileSync(join(projectDir, "index.html"), "<html></html>");+ vi.mocked(prepareProjectDir).mockResolvedValue(projectDir);+ vi.mocked(hostItemDirectory).mockReturnValue({ status: "over-budget" });++ const item = {+ name: "test-over-budget-item",+ kind: "component" as const,+ sourceDir,+ entryFile: "index.html",+ };+ const outPath = join(payloadRoot, "components", `${item.name}.json`);+ cleanupPaths.push(outPath);+ mkdirSync(join(payloadRoot, "components"), { recursive: true });+ writeFileSync(outPath, JSON.stringify({ html: "stale" }));++ const logSpy = vi.spyOn(console, "log").mockImplementation(() => {});+ const result = await buildPayload(item);++ expect(result).toBe("skipped");+ expect(existsSync(outPath)).toBe(false);+ expect(+ logSpy.mock.calls.some(+ (call) => String(call[0]).includes("host budget") && String(call[0]).includes(item.name),+ ),+ ).toBe(true);+ logSpy.mockRestore();+ });+});diff --git a/scripts/generate-catalog-payloads.ts b/scripts/generate-catalog-payloads.tsindex d0f0f58ce8..53afb4d810 100644--- a/scripts/generate-catalog-payloads.ts+++ b/scripts/generate-catalog-payloads.ts@@ -42,13 +42,14 @@ import {inlineMountedComposition,HOSTED_EXTENSIONS,hostItemDirectory,+ MAX_HOSTED_DIRECTORY_BYTES,processAssets,withBaseHref,} from "./catalog-payload-assets.ts";const scriptDir = dirname(fileURLToPath(import.meta.url));const repoRoot = resolve(scriptDir, "..");-const payloadRoot = resolve(repoRoot, "docs/public/catalog");+export const payloadRoot = resolve(repoRoot, "docs/public/catalog");/*** Inlining budget for a single payload. A payload is fetched when the reader@@ -178,7 +179,10 @@ function renderEntry(return { entry, fromSnippet: true };}-async function buildPayload(item: CatalogItem): Promise<"written" | "skipped"> {+// Pre-existing complexity from the item's independent skip conditions; the+// over-budget branch added here is one more of the same shape, not a new debt.+// fallow-ignore-next-line complexity+export async function buildPayload(item: CatalogItem): Promise<"written" | "skipped"> {const outPath = join(payloadRoot, typeDir(item.kind), `${item.name}.json`);// An item that stops qualifying has to lose its payload, or the page@@ -239,10 +243,23 @@ async function buildPayload(item: CatalogItem): Promise<"written" | "skipped"> {// duplicate assets already shared by hash and roughly double what the// repository carries, to fix a handful of compositions.const itemUrl = `/public/catalog/items/${item.name}`;- const baseHref =+ const hostResult =interactive || needsOwnDirectory(item, unresolved)? hostItemDirectory(projectDir, join(payloadRoot, "items", item.name), `${itemUrl}/`)- : "";+ : { status: "not-needed" as const };++ // A directory that is needed but over budget still leaves the composition+ // with dead relative references and no <base> to resolve them against —+ // that is worse than the recorded video it already has.+ if (hostResult.status === "over-budget") {+ console.log(+ ` – ${item.name}: directory over the ${(MAX_HOSTED_DIRECTORY_BYTES / 1e6).toFixed(1)} MB host budget, keeping the recorded video`,+ );+ dropStalePayload();+ return "skipped";+ }+ const baseHref = hostResult.status === "hosted" ? hostResult.baseHref : "";+// An interactive preview keeps its mount, so the component travels inline// and the demo's own pinned values come off — the reader's choices are what// should reach it.