Files
Vance IngallsandClaude Sonnet 5.5 ffcef8f886 feat(core): harden the capture motion blur runtime lifecycle (#5968)
Make the lifecycle from the previous change safe for real compositions.

- Frames are drawn in device pixels: the canvases and the compositor buffers
  follow the page's scale, so a 2x render is not blurred at half resolution.
- A render never gives up mid-video: a frame whose capture throws is plain
  DOM and the next one wraps again; in Studio, three capture exceptions in a
  row turn blur off. (Paint timeouts render plain and never count; they are
  handled in the previous change.)
- A hidden preview tab rests on plain DOM instead of waiting on paints that
  never come.
- Timeline callbacks no longer fire during the mover scan, even with
  data-motion-blur-events="on".
- Wrapping and unwrapping the root no longer reload iframes, restart CSS
  animations or leak timing invalidations: each move runs through the
  runtime's record filter and the adapters re-seek right after it. The waapi
  adapter drops animations Chrome cancelled, limited to browser-created CSS
  animations (a small, separate hunk in adapters/waapi.ts).
- Studio preview holds the playback seek while a blurred frame is in flight,
  so the poses and both captures belong to the same time.
- The host exposes now() for the re-seek.
- Tests for the wrap, two-phase and painting paths, and for the guards that
  survived a deliberate break.

Folded review fixes: R4, R8, R9 (runtime, init and waapi parts), R11, T1.

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 11:04:10 -07:00
..
2026-10-21 15:52:17 +00:00

@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