mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-10-30 17:27:09 +00:00
* feat(catalog): add the seven 3D-motion pieces as installable registry blocks Each piece ships as a registry block with a CDN poster and preview, a live catalog detail page and its source. Scripts travel inside the catalog payload (shared vendor libraries fetched once, item scripts inline, the one HDR as a data URI) because the docs host only serves fonts, images and JSON. NO_ESSAY_COMMENTS_OK: the long comment blocks are in vendored libraries and the ported frost source under registry/blocks, not hand-written here. HF_MAX_NONLFS_KB=6000: four hosted texture PNGs under docs/public/catalog/items are runtime assets the docs host must serve as files. fallow skipped locally: it audits against origin/main and this branch is stacked on an older main. * chore(catalog): regenerate gallery data and nav after rebasing onto main * fix(catalog): read the install manifest through the bounded project reader * fix(catalog): a script the inliner missed fails the payload instead of shipping a dead URL * refactor(catalog): the leftover-script check reuses the reference finder * fix(catalog): frost and glass textures load from the CDN and the iteration presets are gone * chore(catalog): regenerate the frost and glass payloads and nav * fix(catalog): frost and glass textures are hosted through the registry url field, not hardcoded * chore(catalog): regenerate the frost and glass payloads against the hosted texture URLs * fix(catalog): the hosted-reference rewrite refuses a bare name it cannot safely replace * ci(catalog): verify changed catalog payloads in headless Chrome and check the docs catalog * feat(catalog): every item page follows the shared layout with a Tune panel and tabs * fix(catalog): let the texture-mask item host its masks so its tile plays live * chore(catalog): regenerate item pages, gallery data and the texture-mask payload * chore(catalog): regenerate item pages after merging main * fix(catalog): declared-only variables get the Tune panel, Code and Docs tabs capped * feat(catalog): give the blend-difference caption a demo scene so its tile plays live * chore(catalog): live payload for the blend-difference caption * perf(catalog): heavy 3d pieces compile and draw before ready, not on the first visible frame * feat(catalog): the avatar promo card hosts its videos, audio and fonts on the CDN * feat(catalog): the avatar promo card tile plays live from its CDN-hosted media * chore(catalog): the avatar promo card plays live, no allowlist left * chore(catalog): shorten two comment blocks * chore(catalog): trim first-party comment blocks to the comment-check limits * chore(catalog): shorten two frost source comments * fix(catalog): the Docs tab renders as prose again, and the detail page honours reduced motion Frame-mode pages carry no prose wrapper, and the detail component sat inside not-prose, so the Docs slot's headings, paragraphs, links and lists had no styling at all. The slots now carry their own prose classes and the chrome around them keeps not-prose. The recorded clip also gets the reduced-motion guard the docs-snippet check requires, and the generator reads stability from the source metadata type so the scripts typecheck passes. * fix(catalog): docs-tab paragraphs render as blocks Mintlify emits paragraphs as inline spans, so two paragraphs in the Docs slot ran together. * fix(ci): drop the duplicate docs_catalog job output git's line-based auto-merge silently duplicated the outputs key when main and this branch each added it on non-adjacent lines during the rebase; oxfmt's yaml parser rejects the repeated map key. * fix(catalog): close four CodeQL alerts in the frost source * chore(catalog): allowlist the avatar-promo-card CDN asset deletions, format sync-docs-catalog check-no-main-deletions.mjs was rejecting 11 local mp4/font files this branch already deleted in favor of CDN hosting; scripts/sync-docs-catalog.mjs had one line over the 100-col print width from an earlier edit in this branch. * fix(catalog): detail tabs use docs prose spacing, Install first; previews skip no-WebGPU runners * fix(catalog): the docs tab scrolls with the page instead of a capped inner box * refactor(catalog): split the payload asset and verify scripts into single-purpose helpers * refactor(catalog): split the preview generator into single-purpose helpers * ci(catalog): fail when the committed catalog differs from generator output The docs host serves the committed catalog and nothing regenerates it, so a stale copy shipped silently. The catalog payloads job now generates into a temp dir and compares it with the committed tree. * chore(catalog): regenerate docs/public/catalog with the refactored scripts One full regeneration from an empty output tree with the current scripts. The tree grows from 58.4 MB to 65.1 MB. Two hosted assets are about 2 MB each (an avatar png and a wav); the same bytes are already committed under assets/, so HF_MAX_NONLFS_KB is raised for this commit only. * fix(catalog): run the catalog script tests under the runner they are written for The rebase put three node:test files in the vitest half of test:scripts, where they report "No test suite found". They now sit in the node --test list. * fix(catalog): a WebGPU item without an adapter shows its recorded clip and says why * ci(catalog): the drift check runs from a committed fetch mirror with no network Generation now serves every font and CDN script fetch from scripts/catalog-fetch-mirror and fails when a fetch is not in it, even if the caller swallowed the error. CATALOG_FETCH_MIRROR=record refreshes the mirror from the live network. The docs_catalog filter also watches packages/core, packages/producer and the mirror, and the 13 re-hashed font files are listed in ALLOWED_DELETIONS. * chore(catalog): clean up the temp font cache and sort the mirror index without a locale * fix(catalog): hide Tune when the clip stands in, time out the adapter request, share one check * fix(catalog): the adapter probe survives a sync throw and a hang; test the clip guard * fix(catalog): keep the adapter probe inside the component, Mintlify evaluates only exports * fix(catalog): run the detail and page generator tests in CI; no Tune flash while probing WebGPU * docs(catalog): credit vendored libraries and make each SKILL.md list what the block installs CREDITS.md names every vendored dependency with its upstream and licence, and flags the two leaf textures whose origin is still to be confirmed. Each SKILL.md Files table now comes from the block manifest and its install and render paths point at compositions/<name>/. A test checks that every path a SKILL.md names is a manifest file that exists. * fix(catalog): a declared WebGPU item passes verify by its manifest tag, not by console wording verify-catalog-payloads forgave a missing adapter only by matching the markup and the message, which library-reported errors and widgets never satisfy. The webgpu tag in the item manifest is now the owner: a tagged item ignores its page and console errors, an untagged one gets no forgiveness, and a marker payload with no html is listed instead of crashing the run. * docs(catalog): correct the credits per block and guard the mount and render paths CREDITS.md states the three.js version and vendored-or-CDN status per block, adds d3-delaunay, Clipper on the CDN and the Google Fonts loads, and lists every texture with no known origin. The SKILL.md test now also checks the mount and render paths against the manifest composition. * test(catalog): read each block manifest once in the SKILL.md file test The two checks shared a copied manifest read, which fallow flagged as a clone with a high score. * fix(catalog): commit the hosted item files a gitignore rule kept out, and check git not the disk The compositions/ and *-ad/ ignore rules matched folder names under docs/public/catalog/items, so 33 hosted fonts, textures and marks were generated but never committed and would 404 on the docs host. The rules now have a negation for that tree and the files are added. The drift check read the checkout, where git-ignored files still exist, so it passed locally and failed only in CI. It now unpacks HEAD with git archive and compares that. * fix(catalog): a tile keeps its poster until the composition has painted * fix(catalog): a tagged WebGPU item forgives only the adapter-absent error, and test the wiring The manifest webgpu tag now decides whether an item may lack an adapter, and the error wording decides which lines are that absence. Any other page or console error on the item, and every failed request, still fails. The per-item decision is one exported function the tests drive, marker payloads are parsed by a tested helper, and the SKILL.md variable counts are checked against their tables (cuboid-carousel said forty-nine for forty). * fix(catalog): the pinned group's posters load eagerly at high priority * fix(catalog): type the tile reveal test so the scripts typecheck passes * fix(catalog): stop the adapter signature matching an unrelated failed adapter request failed to request .*adapter also matched errors about other adapters. It now matches only a request for the WebGPU adapter, so a tagged item cannot hide an unrelated failure behind it. * test(catalog): a tagged item still fails on an error about some other adapter * feat(catalog): the install command sits above the preview, as on the live catalog * fix(catalog): find the install slot through Mintlify's child wrapper * fix(docs): catalog copy buttons keep their size when the label swaps to Copied * refactor(docs): name the shown copy label once in the catalog copy button * fix(docs): primary catalog button keeps a readable label on hover and after copy * fix(docs): inset the catalog tab strip and tab content to match the boxed panels
317 lines
12 KiB
TypeScript
317 lines
12 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { existsSync, mkdirSync, mkdtempSync, readdirSync, writeFileSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { describe, it } from "node:test";
|
|
import {
|
|
externalizeDataUris,
|
|
hostItemDirectory,
|
|
localReferences,
|
|
MAX_HOSTED_DIRECTORY_BYTES,
|
|
probableReferences,
|
|
processAssets,
|
|
withBaseHref,
|
|
} from "./catalog-payload-assets.ts";
|
|
|
|
function project(files: Record<string, string | Buffer>): string {
|
|
const dir = mkdtempSync(join(tmpdir(), "hf-payload-assets-"));
|
|
for (const [name, contents] of Object.entries(files)) {
|
|
const path = join(dir, name);
|
|
mkdirSync(join(path, ".."), { recursive: true });
|
|
writeFileSync(path, contents);
|
|
}
|
|
return dir;
|
|
}
|
|
|
|
function target() {
|
|
return { dir: mkdtempSync(join(tmpdir(), "hf-payload-out-")), urlBase: "/public/catalog/assets" };
|
|
}
|
|
|
|
describe("localReferences", () => {
|
|
it("finds files referenced by attribute and by CSS url()", () => {
|
|
const html = `<img src="assets/logo.png"><style>@font-face{src:url('fonts/inter.woff2')}</style>`;
|
|
assert.deepEqual(localReferences(html).sort(), ["assets/logo.png", "fonts/inter.woff2"]);
|
|
});
|
|
|
|
it("ignores a shader source assigned to a variable ending in src", () => {
|
|
// The whole reason the pattern demands a non-identifier character first.
|
|
const html = `<script>var vertSrc = "attribute vec2 a_pos; void main(){}";</script>`;
|
|
assert.deepEqual(localReferences(html), []);
|
|
});
|
|
|
|
it("ignores in-document fragment references, encoded or not", () => {
|
|
const html = `<rect filter="url(#noise)"></rect><rect filter="url(%23grain)"></rect>`;
|
|
assert.deepEqual(localReferences(html), []);
|
|
});
|
|
|
|
it("ignores anything already addressable by the browser", () => {
|
|
const html = `<img src="https://cdn.example.com/a.png"><img src="data:image/png;base64,AA">`;
|
|
assert.deepEqual(localReferences(html), []);
|
|
});
|
|
|
|
it("ignores a path assigned to an identifier, which is code and not markup", () => {
|
|
// `configSrc` names a file the composition fetches at runtime and parses.
|
|
// Rewriting it would corrupt the script, so the leading non-identifier
|
|
// character in the pattern is what keeps this out.
|
|
const html = `<script>var configSrc = "config.json";</script>`;
|
|
assert.deepEqual(localReferences(html), []);
|
|
});
|
|
|
|
it("still finds a property assignment, where the dot is not an identifier char", () => {
|
|
const html = `<script>img.src = "assets/hero.png";</script>`;
|
|
assert.deepEqual(localReferences(html), ["assets/hero.png"]);
|
|
});
|
|
|
|
it("ignores references with no known extension", () => {
|
|
const html = `<a href="/docs/guide">guide</a><div style="background:url(gradient)"></div>`;
|
|
assert.deepEqual(localReferences(html), []);
|
|
});
|
|
});
|
|
|
|
describe("processAssets", () => {
|
|
it("writes a publishable asset once and links to it", () => {
|
|
const dir = project({ "assets/logo.png": Buffer.from([0x89, 0x50]) });
|
|
const out = target();
|
|
const result = processAssets(`<img src="assets/logo.png">`, dir, out);
|
|
|
|
assert.equal(result.hosted, 1);
|
|
assert.equal(result.inlined, 0);
|
|
assert.deepEqual(result.unresolved, []);
|
|
assert.match(result.html, /^<img src="\/public\/catalog\/assets\/[0-9a-f]{16}\.png">$/);
|
|
assert.equal(readdirSync(out.dir).length, 1);
|
|
});
|
|
|
|
it("stores one copy when two items share a byte-identical font", () => {
|
|
// The reason for content addressing: the catalog's fonts were being
|
|
// base64'd into a hundred payloads apiece.
|
|
const font = Buffer.from("a-font-file");
|
|
const one = project({ "a.woff2": font });
|
|
const two = project({ "nested/b.woff2": font });
|
|
const out = target();
|
|
|
|
const first = processAssets(`<style>@font-face{src:url(a.woff2)}</style>`, one, out);
|
|
const second = processAssets(`<style>@font-face{src:url(nested/b.woff2)}</style>`, two, out);
|
|
|
|
assert.equal(readdirSync(out.dir).length, 1);
|
|
const url = /\/public\/catalog\/assets\/[0-9a-f]{16}\.woff2/;
|
|
assert.equal(first.html.match(url)?.[0], second.html.match(url)?.[0]);
|
|
});
|
|
|
|
it("inlines a type the host will not publish", () => {
|
|
// `.glb` returns 404 from the docs host, so a link would break the preview.
|
|
const dir = project({ "scene.glb": Buffer.from([0x67, 0x6c]) });
|
|
const out = target();
|
|
const result = processAssets(`<model-viewer src="scene.glb">`, dir, out);
|
|
|
|
assert.equal(result.inlined, 1);
|
|
assert.equal(result.hosted, 0);
|
|
assert.match(result.html, /data:model\/gltf-binary;base64,/);
|
|
assert.ok(!existsSync(join(out.dir, "scene.glb")));
|
|
});
|
|
|
|
it("embeds a script as a data URI when no inliner owns the item", () => {
|
|
const dir = project({ "lib/a.js": "var a=1;" });
|
|
const result = processAssets(`<script src="lib/a.js"></script>`, dir, target());
|
|
|
|
assert.match(result.html, /src="data:text\/javascript;base64,/);
|
|
assert.deepEqual(result.unresolved, []);
|
|
});
|
|
|
|
it("leaves a script tag untouched when the caller's inliner owns it", () => {
|
|
const dir = project({ "lib/a.js": "var a=1;" });
|
|
const result = processAssets(`<script src="lib/a.js"></script>`, dir, target(), true);
|
|
|
|
assert.equal(result.html, `<script src="lib/a.js"></script>`);
|
|
assert.deepEqual(result.unresolved, ["lib/a.js"]);
|
|
});
|
|
|
|
it("gives the same output twice, so regeneration writes no new bytes", () => {
|
|
const dir = project({ "a.png": Buffer.from([0x01]) });
|
|
const first = processAssets(`<img src="a.png">`, dir, target());
|
|
const second = processAssets(`<img src="a.png">`, dir, target());
|
|
|
|
assert.equal(first.html, second.html);
|
|
});
|
|
|
|
it("replaces every occurrence of the same reference", () => {
|
|
const dir = project({ "a.png": Buffer.from([0x01]) });
|
|
const result = processAssets(`<img src="a.png"><img src="a.png">`, dir, target());
|
|
|
|
assert.equal(result.html.match(/\/public\/catalog\/assets\//g)?.length, 2);
|
|
});
|
|
|
|
it("reports a reference whose file is missing rather than dropping it", () => {
|
|
// A runtime-built path such as `masks/${slug}.png` lands here, and the item
|
|
// has to keep its video instead of shipping a preview with holes in it.
|
|
const result = processAssets(`<img src="masks/gone.png">`, project({}), target());
|
|
|
|
assert.deepEqual(result.unresolved, ["masks/gone.png"]);
|
|
});
|
|
|
|
it("refuses a reference that climbs out of the project directory", () => {
|
|
const dir = project({ "keep.png": Buffer.from([0x01]) });
|
|
const result = processAssets(`<img src="../../etc/passwd.png">`, dir, target());
|
|
|
|
assert.deepEqual(result.unresolved, ["../../etc/passwd.png"]);
|
|
assert.equal(result.hosted, 0);
|
|
});
|
|
|
|
it("leaves a composition with no local references untouched", () => {
|
|
const html = `<div data-composition-id="x"></div>`;
|
|
const result = processAssets(html, project({}), target());
|
|
|
|
assert.deepEqual(result, { html, hosted: 0, inlined: 0, unresolved: [] });
|
|
});
|
|
});
|
|
|
|
describe("externalizeDataUris", () => {
|
|
const font = (n: number) => Buffer.alloc(n, 7).toString("base64");
|
|
|
|
it("pulls an embedded font out into a shared file", () => {
|
|
// Compositions arrive with fonts already embedded, which is where the bulk
|
|
// of the catalog's payload weight came from.
|
|
const out = target();
|
|
const result = externalizeDataUris(
|
|
`<style>@font-face{src:url(data:font/woff2;base64,${font(8000)})}</style>`,
|
|
out,
|
|
);
|
|
|
|
assert.equal(result.externalized, 1);
|
|
assert.match(result.html, /url\(\/public\/catalog\/assets\/[0-9a-f]{16}\.woff2\)/);
|
|
assert.equal(readdirSync(out.dir).length, 1);
|
|
});
|
|
|
|
it("stores one copy when two payloads embed the same font", () => {
|
|
const out = target();
|
|
const blob = font(8000);
|
|
externalizeDataUris(`<style>src:url(data:font/woff2;base64,${blob})</style>`, out);
|
|
externalizeDataUris(
|
|
`<b>other item</b><style>src:url(data:font/woff2;base64,${blob})</style>`,
|
|
out,
|
|
);
|
|
|
|
assert.equal(readdirSync(out.dir).length, 1);
|
|
});
|
|
|
|
it("leaves a small blob alone, where a request costs more than the bytes", () => {
|
|
const out = target();
|
|
const result = externalizeDataUris(`<img src="data:image/png;base64,${font(64)}">`, out);
|
|
|
|
assert.equal(result.externalized, 0);
|
|
assert.ok(!existsSync(out.dir) || readdirSync(out.dir).length === 0);
|
|
});
|
|
|
|
it("leaves a type the host will not publish embedded", () => {
|
|
const out = target();
|
|
const result = externalizeDataUris(
|
|
`<a href="data:model/gltf-binary;base64,${font(8000)}">`,
|
|
out,
|
|
);
|
|
|
|
assert.equal(result.externalized, 0);
|
|
assert.match(result.html, /data:model\/gltf-binary/);
|
|
});
|
|
});
|
|
|
|
describe("probableReferences", () => {
|
|
it("finds a model a script loads by name", () => {
|
|
// `loader.load("models/iphone.glb")` is how the 3D blocks fetch their
|
|
// model, and no attribute or url() pattern can see it.
|
|
const html = `<script>loader.load("models/iphone.glb", cb);</script>`;
|
|
assert.deepEqual(probableReferences(html), ["models/iphone.glb"]);
|
|
});
|
|
|
|
it("does not repeat a reference an attribute already covers", () => {
|
|
const html = `<img src="a.png"><script>preload("a.png")</script>`;
|
|
assert.deepEqual(probableReferences(html), []);
|
|
});
|
|
});
|
|
|
|
describe("processAssets with script-loaded files", () => {
|
|
it("inlines a model loaded by name, since the host will not publish glb", () => {
|
|
const dir = project({ "models/iphone.glb": Buffer.alloc(64, 3) });
|
|
const result = processAssets(
|
|
`<script>loader.load("models/iphone.glb")</script>`,
|
|
dir,
|
|
target(),
|
|
);
|
|
|
|
assert.equal(result.inlined, 1);
|
|
assert.match(result.html, /data:model\/gltf-binary;base64,/);
|
|
assert.deepEqual(result.unresolved, []);
|
|
});
|
|
|
|
it("ignores a name that is not a file, rather than failing the item", () => {
|
|
// An ordinary string that happens to look like a filename must not push an
|
|
// item onto the video fallback.
|
|
const result = processAssets(
|
|
`<script>track("checkout.step.png")</script>`,
|
|
project({}),
|
|
target(),
|
|
);
|
|
|
|
assert.deepEqual(result.unresolved, []);
|
|
assert.equal(result.hosted + result.inlined, 0);
|
|
});
|
|
|
|
it("still fails an item whose markup points at a missing file", () => {
|
|
const result = processAssets(`<img src="gone.png">`, project({}), target());
|
|
|
|
assert.deepEqual(result.unresolved, ["gone.png"]);
|
|
});
|
|
});
|
|
|
|
describe("hostItemDirectory", () => {
|
|
it("publishes the item's files at the paths it will ask for", () => {
|
|
// The texture blocks build `compositions/components/<name>.png` at run
|
|
// 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 result = hostItemDirectory(dir, out.dir, "/public/catalog/items/x/");
|
|
|
|
assert.deepEqual(result, { status: "hosted", baseHref: "/public/catalog/items/x/" });
|
|
assert.ok(existsSync(join(out.dir, "compositions/components/lava.png")));
|
|
});
|
|
|
|
it("mirrors _downloads to the root, where the compiler's references point", () => {
|
|
const dir = project({ "_downloads/_remote_media/f.woff2": Buffer.from([2]) });
|
|
const out = target();
|
|
hostItemDirectory(dir, out.dir, "/base/");
|
|
|
|
assert.ok(existsSync(join(out.dir, "_remote_media/f.woff2")));
|
|
});
|
|
|
|
it("skips a type the host will not publish", () => {
|
|
const dir = project({ "scene.glb": Buffer.from([3]) });
|
|
const out = target();
|
|
|
|
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);
|
|
});
|
|
});
|
|
|
|
describe("withBaseHref", () => {
|
|
it("puts the base first in the head, ahead of anything that resolves a URL", () => {
|
|
const html = withBaseHref("<html><head><link href='a.css'></head><body></body></html>", "/b/");
|
|
assert.ok(html.indexOf('<base href="/b/">') < html.indexOf("<link"));
|
|
});
|
|
|
|
it("gives a headless document a head to put it in", () => {
|
|
assert.ok(
|
|
withBaseHref("<html><body>x</body></html>", "/b/").includes('<head><base href="/b/"></head>'),
|
|
);
|
|
});
|
|
|
|
it("changes nothing when there is nothing to serve", () => {
|
|
const html = "<html><head></head></html>";
|
|
assert.equal(withBaseHref(html, ""), html);
|
|
});
|
|
});
|