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
210 lines
9.3 KiB
TypeScript
210 lines
9.3 KiB
TypeScript
/**
|
|
* Make a component's catalog preview answer its variables panel.
|
|
*
|
|
* A component ships two HTML files. The snippet is what the page hands you to
|
|
* paste: it carries `data-composition-variables`, a script that turns a chosen
|
|
* value into a CSS custom property, and CSS written against those properties.
|
|
* `demo.html` stages that component against a background and registers the
|
|
* GSAP timeline that makes the preview move.
|
|
*
|
|
* The catalog preview is built from the demo, and the demo is a hand-authored
|
|
* copy rather than a reference. The copies drifted: of the 168 components that
|
|
* declare variables, 166 demos have no declaration and no reader, so the
|
|
* preview renders constants and the panel cannot move it whatever is picked.
|
|
*
|
|
* There is no single repair, because components come in two shapes. See
|
|
* `snippetOwnsItsMotion` for the split and how it was established. This module
|
|
* handles the shape where the demo owns the motion: it keeps the demo's markup
|
|
* and timeline and layers on the three things the copy lost.
|
|
*
|
|
* 1. the declaration, copied verbatim from the snippet's root
|
|
* 2. the snippet's `<style>`, appended so its var()-driven rules win on
|
|
* document order over the demo's hardcoded copies
|
|
* 3. the snippet's `<script>`, which sets the properties that CSS reads
|
|
*
|
|
* Nothing in the demo's DOM is moved or rewritten, which is what keeps the
|
|
* animation intact.
|
|
*/
|
|
|
|
const DECLARATION = /data-composition-variables\s*=\s*'(\[[\s\S]*?\])'/;
|
|
/** The variables a composition declares on its root, or none when it declares nothing readable. */
|
|
export function declaredVariables(html: string): unknown[] {
|
|
const raw = DECLARATION.exec(html)?.[1];
|
|
if (!raw) return [];
|
|
try {
|
|
const parsed: unknown = JSON.parse(raw);
|
|
return Array.isArray(parsed) ? parsed : [];
|
|
} catch {
|
|
return [];
|
|
}
|
|
}
|
|
|
|
const STYLE_BLOCK = /<style\b[^>]*>[\s\S]*?<\/style>/g;
|
|
const SCRIPT_BLOCK = /<script\b(?![^>]*\bsrc=)[^>]*>[\s\S]*?<\/script>/g;
|
|
const DECLARING_TAG = /<[a-zA-Z][\w-]*\b[^>]*data-composition-variables[\s\S]*?>/;
|
|
const COMPOSITION_ROOT_TAG = /<[a-zA-Z][\w-]*\b[^>]*\bdata-composition-id\b[^>]*>/;
|
|
const INLINE_SCRIPT_OPEN = /<script\b(?![^>]*\bsrc=)[^>]*>/i;
|
|
// Existence checks use their own non-global copy on purpose: `.test()` on a
|
|
// /g regex advances its lastIndex, and these run in a loop over every
|
|
// component, so a shared one would start mid-string and miss on later items.
|
|
const HAS_INLINE_SCRIPT = /<script\b(?![^>]*\bsrc=)[^>]*>[\s\S]*?<\/script>/;
|
|
const BODY_CLOSE = /<\/body>/i;
|
|
|
|
/**
|
|
* Does the snippet bring its own motion, or only a recipe for it?
|
|
*
|
|
* Components come in two shapes and the preview has to be built differently
|
|
* for each. 123 of the 168 that declare variables register their own paused
|
|
* GSAP timeline: those are whole pieces, and the preview is best built from the
|
|
* snippet, which then carries markup, variables and motion together. The other
|
|
* 45 are markup plus a commented recipe, and it is the demo that animates them,
|
|
* so those keep the demo and have the variable machinery layered on.
|
|
*
|
|
* Getting this backwards is not subtle. Build a self-contained component from
|
|
* its demo with the snippet layered on and it keeps rendering its defaults;
|
|
* build a recipe-only one from its snippet and the preview holds still. Both
|
|
* were observed before this split existed.
|
|
*
|
|
* Comments are stripped first, because the recipe is written as one.
|
|
*/
|
|
export function snippetOwnsItsMotion(snippetHtml: string): boolean {
|
|
const live = snippetHtml.replace(/<!--[\s\S]*?-->/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
return live.includes("__timelines") && live.includes("gsap.timeline");
|
|
}
|
|
|
|
/**
|
|
* Components that register a timeline but still render a still frame when the
|
|
* preview is built from their snippet.
|
|
*
|
|
* Both were measured, not guessed: their previews moved before this change and
|
|
* were static after, while every other self-contained component kept moving.
|
|
* The cause is in the pieces themselves rather than in the rule, so they keep
|
|
* the preview they had. That leaves their panel inert, which is the state they
|
|
* were already in, rather than trading an inert panel for a frozen preview.
|
|
*/
|
|
export const SNIPPET_PREVIEW_RENDERS_STILL = new Set(["ascii-render-pass", "star-rating-fill"]);
|
|
|
|
/** The classes the snippet hangs its declaration on, which its script targets. */
|
|
function declaringClasses(snippetHtml: string): string[] {
|
|
const declaring = DECLARING_TAG.exec(snippetHtml);
|
|
const classAttr = declaring ? /class\s*=\s*"([^"]*)"/.exec(declaring[0]) : null;
|
|
return (classAttr?.[1] ?? "").split(/\s+/).filter(Boolean);
|
|
}
|
|
|
|
function openingTagWithClass(html: string, cls: string): string | null {
|
|
const escaped = cls.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
const pattern = new RegExp(
|
|
`<[a-zA-Z][\\w-]*\\b[^>]*class\\s*=\\s*"[^"]*\\b${escaped}\\b[^"]*"[^>]*>`,
|
|
);
|
|
return pattern.exec(html)?.[0] ?? null;
|
|
}
|
|
|
|
/**
|
|
* Where to hang the declaration in the demo.
|
|
*
|
|
* It does not have to be the same element the snippet used: the runtime merges
|
|
* the declared defaults of every `[data-composition-variables]` in the
|
|
* document, so any host in the demo resolves identically. What does matter is
|
|
* that the snippet's script finds its targets, and it finds them by the
|
|
* component's own class, which the demo's copy still carries.
|
|
*
|
|
* The component's own element is preferred over the composition root, because
|
|
* that keeps the payload shaped like the markup a reader would paste.
|
|
*/
|
|
function findDeclarationHost(demoHtml: string, snippetHtml: string): string | null {
|
|
const onOwnClass = declaringClasses(snippetHtml)
|
|
.map((cls) => openingTagWithClass(demoHtml, cls))
|
|
.find(Boolean);
|
|
return onOwnClass ?? compositionRootTag(demoHtml);
|
|
}
|
|
|
|
function compositionRootTag(html: string): string | null {
|
|
return COMPOSITION_ROOT_TAG.exec(html)?.[0] ?? null;
|
|
}
|
|
|
|
function withDeclarationAttribute(tag: string, declaration: string): string {
|
|
const selfClosing = tag.endsWith("/>");
|
|
const body = tag.slice(0, selfClosing ? -2 : -1);
|
|
return `${body} data-composition-variables='${declaration}'${selfClosing ? "/>" : ">"}`;
|
|
}
|
|
|
|
export type LayerResult =
|
|
| { applied: true; html: string }
|
|
| { applied: false; html: string; reason: string };
|
|
|
|
/**
|
|
* Everything that has to hold before a demo can be layered.
|
|
*
|
|
* A table rather than a chain of guards, so the refusals read as a list of
|
|
* conditions with their messages beside them. A component whose preview cannot
|
|
* be made to answer its panel keeps the preview it has rather than getting a
|
|
* half-applied one.
|
|
*/
|
|
const REQUIREMENTS: { fails: (demo: string, snippet: string) => boolean; reason: string }[] = [
|
|
{ fails: (_d, s) => !DECLARATION.test(s), reason: "snippet declares no variables" },
|
|
{ fails: (d) => DECLARATION.test(d), reason: "demo already declares its variables" },
|
|
{ fails: (d) => !BODY_CLOSE.test(d), reason: "demo has no </body> to append to" },
|
|
{ fails: (_d, s) => !HAS_INLINE_SCRIPT.test(s), reason: "snippet has no reader script" },
|
|
{
|
|
fails: (d, s) => !findDeclarationHost(d, s),
|
|
reason: "demo has nowhere to hang the declaration",
|
|
},
|
|
];
|
|
|
|
/** Why this pair cannot be layered, or null when it can. */
|
|
function refuseReason(demoHtml: string, snippetHtml: string): string | null {
|
|
return REQUIREMENTS.find((r) => r.fails(demoHtml, snippetHtml))?.reason ?? null;
|
|
}
|
|
|
|
/**
|
|
* The snippet's own inline blocks, which are the only ones that travel.
|
|
*
|
|
* A `src=` script is a shared dependency the demo already loads, and copying it
|
|
* would re-run a library.
|
|
*/
|
|
function inlineBlocks(snippetHtml: string, pattern: RegExp): string[] {
|
|
return snippetHtml.match(pattern) ?? [];
|
|
}
|
|
|
|
/** Layer a component snippet's variable machinery onto its demo. */
|
|
export function layerVariablesOntoDemo(demoHtml: string, snippetHtml: string): LayerResult {
|
|
const reason = refuseReason(demoHtml, snippetHtml);
|
|
if (reason) return { applied: false, html: demoHtml, reason };
|
|
|
|
const declaration = DECLARATION.exec(snippetHtml)?.[1] as string;
|
|
const host = findDeclarationHost(demoHtml, snippetHtml) as string;
|
|
|
|
const styles = inlineBlocks(snippetHtml, STYLE_BLOCK);
|
|
const scripts = inlineBlocks(snippetHtml, SCRIPT_BLOCK);
|
|
|
|
// Order matters twice, in opposite directions.
|
|
//
|
|
// The styles go last, so the snippet's var()-driven rules win over the
|
|
// demo's hardcoded copies on document order.
|
|
//
|
|
// The script goes FIRST, ahead of the demo's own. Many component scripts
|
|
// rebuild their subtree from the resolved values, and the demo's timeline
|
|
// captures element references when it is built. Running the snippet's script
|
|
// afterwards swapped those elements out from under a live timeline, which
|
|
// animated detached nodes and left the preview frozen: nine previews that
|
|
// used to move went static that way before this ordering was fixed.
|
|
const html = withStylesAppended(withScriptsFirst(demoHtml, scripts), styles).replace(
|
|
host,
|
|
withDeclarationAttribute(host, declaration),
|
|
);
|
|
|
|
return { applied: true, html };
|
|
}
|
|
|
|
function withScriptsFirst(demoHtml: string, scripts: string[]): string {
|
|
const firstDemoScript = INLINE_SCRIPT_OPEN.exec(demoHtml)?.[0];
|
|
const block = scripts.join("\n");
|
|
return firstDemoScript
|
|
? demoHtml.replace(firstDemoScript, `${block}\n${firstDemoScript}`)
|
|
: demoHtml.replace(BODY_CLOSE, `${block}\n</body>`);
|
|
}
|
|
|
|
function withStylesAppended(html: string, styles: string[]): string {
|
|
return html.replace(BODY_CLOSE, `${styles.join("\n")}\n</body>`);
|
|
}
|