Skip to main content
Every mutation in the SDK is expressed as an EditOp — a plain data object with a discriminated type field. You can submit ops individually through dispatch(), validate them with can(), or group them into a single undo/persist step with batch().
Every element op requires an explicit target (an HfId string or HfId[] array). There is no selection-implicit mutation — the SDK never reads the current selection to decide what to edit. The typed methods on Composition (such as comp.setText() and comp.setStyle()) are convenience sugar that construct and dispatch these same ops.

dispatch, batch, and can

dispatch

Applies op immediately. Emits a patch event, persists if an adapter is attached, and records a history entry. The optional origin is forwarded verbatim in the resulting PatchEvent; use it to label the source of the change (e.g. "user", "agent", or your own string constant).

batch

Groups all dispatch() calls made inside fn into a single undo step, a single persist write, and a single patch event. Use batch() when several mutations belong together logically.

can

Dry-runs op without mutating the document. Returns { ok: true } when dispatch(op) would succeed, or { ok: false; code: string; message: string; hint?: string } when it would be a no-op or error. Use can() as a feature-detection gate before rendering controls or applying optional operations:
Stable code values for ok: false:
Several Phase-3b GSAP ops (addGsapTween, setGsapTween, removeGsapTween, addGsapKeyframe, setGsapKeyframe, removeGsapKeyframe, etc.) return { ok: false, code: 'E_NO_GSAP_TIMELINE' } from can() until the parser engine ships. dispatch() still applies those ops structurally even when can() returns false.
See also: Composition for the typed-method wrappers, Types for CanResult and EditOp.

Element edits

These ops target one or more elements by explicit hf-id. target accepts a single HfId string or an HfId[] array; when an array is given the op is applied to each id individually within a single batch.

setStyle

styles keys are camelCase property names, matching CSSStyleDeclaration convention.

setText

setAttribute

setTiming

setHold

hold is an ElasticHold object:

moveElement

Sets the element’s position via data-x / data-y attributes. Coordinates are in composition-space pixels.

Structure

These ops mutate document structure (add/remove/reorder elements, apply class-level styles, or change composition metadata). They do not take a target field in the same form as element edits.

addElement

parent is the hf-id of the parent element, or null to insert at the document body root. index is the zero-based sibling index (append if >= childCount). html must be a single-root HTML fragment and must not contain <script>.
Use the typed comp.addElement(parent, index, html) method to get back the minted hf-id.

reorderElements

Each entry sets z-index on one element. Elements must be non-statically positioned for z-index to take effect — the caller must ensure position is set.

setClassStyle

deleteAllForSelector

setCompositionMetadata


Variables


GSAP tweens

These ops add, edit, and remove GSAP tween entries in the composition’s GSAP script block. They operate by animationId — a stable string identifier minted when a tween is created. Use comp.addGsapTween() or addWithKeyframes to mint a new id; the typed wrapper returns it directly.
Several GSAP ops require the parser engine to be active. Until it ships, can() returns { ok: false, code: 'E_NO_GSAP_TIMELINE' } for these ops. dispatch() still applies the op structurally.

addGsapTween

tween is a GsapTweenSpec object:
GsapTweenSpec fields:

setGsapTween

Only the fields you supply are changed; omit any field to leave it unchanged.

removeGsapProperty


Keyframes

Keyframe ops work with tweens that use CSS @keyframes-style percentage arrays rather than a single fromProperties/toProperties shape.

materializeKeyframes

keyframes is an array of { percentage, properties, ease? } objects:

addWithKeyframes / replaceWithKeyframes

position is a number (seconds) — unlike GsapTweenSpec.position, label-relative strings are not accepted here.
After replaceWithKeyframes, position-derived tween IDs renumber. Re-query comp.getElement(id).animationIds to discover the new ID rather than assuming it matches the old one.
KeyframeSpec fields:

Labels

GSAP timeline labels mark named positions (in seconds) in the master timeline. Labels are referenced in GsapTweenSpec.position as strings like "intro" or "intro+=0.5".

Arc paths

Arc path ops control the motion path of a GSAP tween — the curve along which an element travels.

setArcPath

config shape:

updateArcSegment