@hyperframes/sdk. Types are verified against packages/sdk/src/types.ts and the export barrel at packages/sdk/src/index.ts.
See also: Composition for the main session interface, Edit Operations for the EditOp catalog.
HfId
data-hf-id attribute stamped on every editable element by ensureHfIds. Use HfId wherever you would write a raw string to signal that the value is an element id.
HyperFramesElement
Full DOM-level view of one editable element. Returned bycomp.getElements() and comp.getElement(id).
The element’s
data-hf-id value — unique within the top-level document.Fully-qualified scoped identifier:
host-chain-prefix/leaf, separated by /. For top-level elements scopedId === id. For elements inside inlined sub-compositions the format is "hf-HOST/hf-LEAF" (any depth). Use scopedId — not id — as the canonical key in dispatch() targets, getElement(), find(), and OverrideSet keys when addressing sub-composition elements.Lowercase HTML tag name (
"div", "img", "p", …).Direct child elements. Build a flat list with
flatElements() from @hyperframes/sdk utilities.Inline CSS properties in camelCase, mirroring
CSSStyleDeclaration convention (fontSize, not font-size).The element’s class list.
All HTML attributes except
style, class, and data-hf-* (those are represented elsewhere in the model).The element’s direct text content, intended as the
setText target. Not a full descendant-text snapshot.Timing start in seconds (
data-start). null when the element carries no timing attribute.Timing duration in seconds (
data-duration). null when not set.Zero-based track index (
data-track). null when not set.IDs of GSAP tweens whose target is this element. Pass these to the GSAP tween ops in
dispatch().ElementSnapshot
HyperFramesElement. Used in return types of getElements() and getElement() to signal that the value is a read-only snapshot — it does not update after subsequent mutations.
SdkDocument
The SDK’s in-memory document model. Returned bybuildDocument().
Top-level elements of the composition body. Walk the tree via
.children.Raw contents of the composition’s GSAP
<script> block, if present.Raw contents of the composition’s
<style> block, if present.Composition width in pixels from
data-width on the root element. null if not set.Composition height in pixels from
data-height. null if not set.Total duration in seconds from
data-duration on the root element. null if not set.Build-time snapshot of the
ensureHfIds-stamped HTML. This value is never updated after mutations — call comp.serialize() to get the current document state.OverrideSet
overrides to openComposition(), or read the accumulated delta with comp.getOverrides().
Key format: hfId.prop.path, where:
hfId.style.fontSize— inline style property overridehfId.text— text content overridehfId.attr.src— attribute overridehfId(key only, valuenull) — element removed by uservar.{id}— variable override; value is a scalar or an object (FontValue/ImageValue)
null value = removal marker: the element or property was deleted by the user.
FindQuery
Passed tocomp.find(query) to search elements by descriptor.
Match by lowercase HTML tag name (
"img", "p", …).Match by the element’s direct text content (case-sensitive substring match — implemented with
String.includes).Match by
data-name attribute value.Match by zero-based track index (
data-track).Restrict results to elements inside a specific sub-composition, identified by the host element’s hf-id.
GsapTweenSpec
Describes a single GSAP tween entry to create or update.GSAP tween method.
"from" animates from the given values to the computed values; "to" animates toward the given values; "fromTo" animates from fromProperties to toProperties; "set" snaps without interpolation.Timeline insertion position. A number is seconds from the timeline start. A string is a label-relative offset such as
"intro" or "outro-=0.5". Omit to append.Tween duration in seconds.
GSAP ease string, e.g.
"power3.out", "elastic.out(1, 0.3)", "none".Start-state property map — used by
"from" and "fromTo" methods.End-state property map — used by
"fromTo" method.Animated property map — used by
"to" method.How many times to repeat.
-1 = infinite.Reverse direction on alternating repeats.
GSAP stagger config for multi-target tweens.
KeyframeSpec
A single keyframe entry foraddWithKeyframes and replaceWithKeyframes. This is a structural shape, not a runtime export — you pass plain objects of this form to those methods; it is not re-exported from the @hyperframes/sdk barrel, so there is nothing to import.
Keyframe stop position within the tween, from 0 to 100.
CSS and GSAP property values at this keyframe stop.
Ease applied from this stop to the next.
GSAP endpoint flag. When
true, emitted as numeric _auto: 1 in the generated GSAP script.ElasticHold
Controls the elastic hold (freeze or loop) window for an element.Start of the hold window in seconds.
End of the hold window in seconds.
"freeze" holds the last frame statically; "loop" cycles the animation within the window.FontValue
Object value for afont composition variable. Always an object — never a raw CSS string.
CSS
font-family value, e.g. "Inter" or "'Playfair Display'".Stylesheet URL to load for this font, e.g. a Google Fonts CSS URL.
ImageValue
Object value for animage composition variable. Always an object — never a raw URL string.
Image source URL.
Alternative text for accessibility.
Object-fit behavior for the image within its container. Maps to the CSS
object-fit property.JsonPatchOp
An emit-only subset of RFC 6902 JSON Patch. The SDK never emitsmove, copy, or test ops, and applyPatches() ignores operations outside this subset.
The patch operation type.
RFC 6902 JSON Pointer path to the document location being changed.
New value for
"add" and "replace" ops. Omitted for "remove".PatchEvent
Emitted bycomp.on('patch', handler) after every committed change (single dispatch() or completed batch()).
Always
1. A bump in formatVersion is a breaking change. Hosts should check this value once on startup and reject unknown versions.Forward patches that transform the previous document state into the new state.
Inverse patches that undo this change — apply to the new state to return to the previous state. Store these for host-side undo stacks.
Re-emitted verbatim from the mutation entry. Identify automated patches by checking
origin === ORIGIN_APPLY_PATCHES.Semantic op names from the
EditOp.type field (e.g. ["setStyle", "setText"]). Intended for analytics and history labels. Not versioned — do not use in branching logic.applyPatches(), it must skip events that originated from that call to avoid infinite loops:
CanResult
Returned bycomp.can(op). See Edit Operations for the full usage pattern.
true when dispatch(op) would succeed. false when it would be a no-op or error.Stable error code for
ok: false — safe to use in switch statements. See the code table in Edit Operations.Human-readable explanation of why the op cannot proceed.
Optional actionable suggestion to resolve the issue.
ElementTimingSnapshot
Resolved timing for one element, returned as values in theRecord<HfId, ElementTimingSnapshot> from comp.getElementTimings().
Time in seconds when the element enters. Derived from
data-duration (preferred) or data-end − data-start as fallback, using the same logic as setTiming.Time in seconds when the element exits.
GSAP
addLabel names whose numeric position falls within [enterAt, exitAt] for this element. Parsed fresh from the GSAP script on every getElementTimings() call — never cached.SelectionProxy
Proxy returned bycomp.selection(). Resolves the current selection at call time and applies ops per-id within a single batch. Selection changes between calls are picked up automatically since ids is resolved fresh each time you call comp.selection().
The hf-ids in the current selection at the moment
comp.selection() was called.ElementHandle
A curried element handle returned bycomp.element(id). Holds only the id string — no stale-reference hazard — and provides the same mutation methods as typed methods on Composition.
ORIGIN_APPLY_PATCHES / ORIGIN_LOCAL
origin tag constants:
ORIGIN_APPLY_PATCHES— automatically set bycomp.applyPatches(). Listeners must skip this origin to prevent undo loops when mirroring patch events back into the SDK. Uses a namespaced string (not a unique Symbol) so the sentinel survives realm boundaries such aspostMessageand structured clone, which T3 embedded hosts may use to forward patch events.ORIGIN_LOCAL— default origin used whendispatch()orbatch()is called without an explicitoriginoption. Signals UI-driven user edits.
EditOp
The full union of all dispatchable edit operations. See Edit Operations for the complete catalog with field descriptions and code examples.PersistErrorEvent
Emitted bycomp.on('persist:error', handler) when an autosave write fails. Failures are non-fatal — the session continues operating normally.
Human-readable description of the persist failure.
Optional suggestion for resolving the failure.
Underlying error object, if available.