Files
hyperframes/packages/cli/src/commands/figma/download.ts
T
Vance IngallsandClaude Fable 5 ee7a96147a feat(core,cli): figma component import with binding-aware node-to-html mapper (M3) (#1872)
resolveBindings: scan the full tree (boundVariables + style ids, alias
chains, children) and partition exact-ID-only against the binding index
before any CSS is emitted per spec 7.1 - never value matching.

nodeToHtml: absolute geometry at figma bounds inside a fixed-size root,
solid/linear-gradient fills, corner radius, opacity, drop shadow, blur,
text styles; resolved bindings emit var(--slug, literal), unresolved
bake literals with data-figma-unresolved; visible:false respected;
vectors/boolean ops route to a rasterize list.

hyperframes figma component: tree -> bindings -> html, rasterize
fallback via Phase-1 asset export with src backfill, registry-item
packaging, unresolved-binding guidance in output.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 18:19:01 -07:00

16 lines
733 B
TypeScript

import { exceedsFreezeCap, MAX_FREEZE_BYTES } from "@hyperframes/core/figma";
/** Fetch a short-lived figma CDN render url into bytes. */
export async function downloadRender(url: string): Promise<Uint8Array> {
const res = await fetch(url);
if (!res.ok) throw new Error(`figma render download failed: HTTP ${res.status}`);
// Reject oversized responses before buffering the body — the freeze cap
// alone only fires after the full allocation.
const declared = Number(res.headers.get("content-length") ?? 0);
if (exceedsFreezeCap(declared))
throw new Error(
`figma render download failed: content-length ${declared} exceeds ${MAX_FREEZE_BYTES} cap`,
);
return new Uint8Array(await res.arrayBuffer());
}