* fix(core): detect template entries structurally isTemplateEntry only matched a raw file that starts with <template>, so the full-document sub-composition shape (<!doctype html><html><body><template> <div data-composition-id>...</template></body></html>) was not recognised and resolveEntryHtmlPath compiled the raw file, whose root sits in an inert template: no timeline, no duration, "Composition has zero duration". A template entry is now a document whose <template> holds the composition root with no live composition root outside it. Detection and extraction share one lookup (locateSceneRoot), the same one readSceneRoot uses. — Jerrai * fix(core): drop comments from the template lookup The comment ratchet allows no net rise in a file's comment share; the PR description carries the explanation. — Jerrai * fix(core): find the scene template among several templates locateSceneRoot read only the first <template>, so a scene template that follows another template was treated as not a template entry. Scan every template and take the first whose content holds a composition root. * fix(core): drop the added comment (comment ratchet) * chore: raise the inspector unpacked size budget by 0.5% The inspector bundles core; the multi-template scene lookup added a few hundred bytes and put it 10 bytes over the 1% tolerance. * fix(core): refuse a file with several scene templates, naming them * chore: trim the inspector size budget bump to what is needed * fix(core): render the first scene template and lint the ambiguity instead of failing A file with several scene templates and no live root rendered its first one before; locateSceneRoot threw and stopped such projects rendering. It returns the first again, and the multiple_scene_templates lint warning names each. Co-authored-by: Jerrai <jerrai@heygen.com> * chore(core): drop the locateSceneRoot comment line the comment ratchet counts Co-authored-by: Jerrai <jerrai@heygen.com> * fix(core): one shared scene-template pick for the compiler, the inliner and the loader A scene template after a card template was detected by locateSceneRoot but mounted from the first template of any kind, so it rendered blank. findSceneTemplate picks the first template holding a composition root and locateSceneRoot, resolveSubCompositionContent and the loader all use it. Co-authored-by: Jerrai <jerrai@heygen.com>
@hyperframes/core
Types, parsers, generators, compiler, linter, runtime, and frame adapters for the Hyperframes video framework.
Install
npm install @hyperframes/core
Most users don't need to install core directly — the CLI, producer, and studio packages depend on it internally.
What's inside
| Module | Description |
|---|---|
| Types | TimelineElement, CompositionSpec, Asset, canvas dimensions, defaults |
| Parsers | parseHtml — extract timeline elements from HTML; parseGsapScript — parse GSAP animations |
| Generators | generateHyperframesHtml — produce valid Hyperframes HTML from a composition spec |
| Compiler | compileTimingAttrs — resolve data-start / data-duration into absolute times |
| Linter | lintHyperframeHtml — validate Hyperframes HTML (missing attributes, overlapping tracks, etc.) |
| Runtime | IIFE script injected into the browser — manages seek, media playback, and the window.__hf protocol |
| Frame Adapters | Pluggable animation drivers (GSAP, Lottie, CSS, or custom) |
Generated composition trust
Composition generators require trusted authors for code-bearing inputs. styles and
generateHyperframesStyles preserve authored CSS, which can load external resources.
animations may contain __raw: values that are emitted as JavaScript;
includeScripts: true includes executable timeline code. serializeGsapAnimations
also accepts raw preamble, postamble, and a code-bearing timelineVar. Never fill
these inputs with untrusted data. Attribute encoding and closing-tag containment
are not a sandbox; render untrusted compositions in an appropriately isolated
execution environment and never serve them on a privileged origin.
Text content retains the supported inline-formatting sanitizer contract. The clip parser intentionally flattens inner formatting to text, so parse/generate is not a lossless replacement for editing the source HTML.
Frame Adapters
A frame adapter tells the engine how to seek your animation to a specific frame:
import { createGSAPFrameAdapter } from "@hyperframes/core";
const adapter = createGSAPFrameAdapter({
getTimeline: () => gsap.timeline(),
compositionId: "my-video",
});
Implement FrameAdapter for custom animation runtimes:
import type { FrameAdapter } from "@hyperframes/core";
const myAdapter: FrameAdapter = {
id: "my-adapter",
getDurationFrames: () => 300,
seekFrame: (frame) => {
/* seek your animation */
},
};
Parsing and generating HTML
import { parseHtml, generateHyperframesHtml } from "@hyperframes/core";
const { elements, metadata } = parseHtml(htmlString);
const html = generateHyperframesHtml(spec);
Linting
import { lintHyperframeHtml } from "@hyperframes/core/lint";
const result = lintHyperframeHtml(htmlString);
// result.findings: { severity, message, elementId }[]
Documentation
Full documentation: hyperframes.heygen.com/packages/core
Related packages
@hyperframes/engine— rendering engine that drives the browser@hyperframes/producer— full render pipeline (capture + encode)hyperframes— CLI