Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
docs(sdk): fix dispatch/can contract, second stale GSAP site, media-start layers
ukimsanov8e658bd6c932
diff --git a/docs/reference/html-schema.mdx b/docs/reference/html-schema.mdxindex 4d63b4f1a4..178a72eb81 100644--- a/docs/reference/html-schema.mdx+++ b/docs/reference/html-schema.mdx@@ -122,7 +122,7 @@ Audio has no visual lifecycle.| Attribute | Applies to | Meaning || --- | --- | --- |-| `data-media-start`<br />(runtime alias: `data-playback-start`) | Video, audio, nested composition | Offset into the source file, used by trim and split. Prefer `data-media-start`: it is read everywhere — parser, timing compiler, and runtime. `data-playback-start` is a runtime-only alias that takes precedence in the player when both are set, but the compiler and parser read only `data-media-start`, so a lone `data-playback-start` will not shift trim/split timing. |+| `data-media-start` / `data-playback-start` | Video, audio, nested composition | Offset into the source file, used by trim and split. The two names are read by different layers with different precedence: the timing compiler and HTML parser read only `data-media-start`, while the runtime player, Studio, and the CLI read `data-playback-start` first and fall back to `data-media-start`. Studio writes `data-playback-start` for nested compositions and any element authored with it. Set **one**; authoring both is what causes the two layers to diverge. || `data-playback-rate` | Video, audio, nested composition | Playback multiplier from `0.1` to `5` || `data-volume` | Video and audio | Static volume from `0` to `1` || `data-has-audio="true"` | Video | Declares that the video contributes audio |diff --git a/docs/sdk/guides/timing-and-animation.mdx b/docs/sdk/guides/timing-and-animation.mdxindex d0e7dd7806..b183152734 100644--- a/docs/sdk/guides/timing-and-animation.mdx+++ b/docs/sdk/guides/timing-and-animation.mdx@@ -182,30 +182,30 @@ if (firstAnimId) {}```-### Feature-detecting advanced ops+### Gating an op with `can()`-Some GSAP operations (such as `setGsapKeyframe`, arc paths, and label ops) require the parser engine, which ships in a later phase. Use `can()` to gate them before dispatching:+`dispatch()` does not run validation, so gate any op that can fail with `can()`+first and skip it when the result is not `ok`. Adding a tween or a label attaches+to a timeline — without a `gsap.timeline()` in the script, `can()` returns+`E_NO_GSAP_TIMELINE`:```typescript-const check = comp.can({- type: "setGsapTween",- animationId: firstAnimId,- properties: { ease: "power3.inOut" },-});+const op = {+ type: "addGsapTween",+ target: "hf-title",+ tween: { method: "to", properties: { opacity: 1 }, duration: 0.5 },+} as const;+const check = comp.can(op);if (!check.ok) {if (check.code === "E_NO_GSAP_TIMELINE") {- // No gsap.timeline() in this composition — prompt to add one, or skip+ // No gsap.timeline() in this composition — add one (var tl = gsap.timeline(...)) or skipconsole.warn("GSAP timeline not available:", check.message);}return;}-comp.dispatch({- type: "setGsapTween",- animationId: firstAnimId,- properties: { ease: "power3.inOut" },-});+comp.dispatch(op);```Stable error codes returned by `can()`:diff --git a/docs/sdk/reference/edit-operations.mdx b/docs/sdk/reference/edit-operations.mdxindex ef394de251..abb1386c93 100644--- a/docs/sdk/reference/edit-operations.mdx+++ b/docs/sdk/reference/edit-operations.mdx@@ -76,7 +76,7 @@ Stable `code` values for `ok: false`:| `E_NO_GSAP_SCRIPT` | Op requires a GSAP `<script>` block; none found in the document. |<Note>- `E_NO_GSAP_TIMELINE` is raised by the two ops that attach to a timeline — `addGsapTween` and `addLabel`. If the composition's GSAP script has no `gsap.timeline()` declaration, `can()` returns `{ ok: false, code: 'E_NO_GSAP_TIMELINE' }`; add `var tl = gsap.timeline(...)` and it succeeds. Don't `dispatch()` after a failed `can()` — a rejected op applies nothing (no patches, script unchanged).+ `E_NO_GSAP_TIMELINE` is raised by the two ops that attach to a timeline — `addGsapTween` and `addLabel`. If the composition's GSAP script has no `gsap.timeline()` declaration, `can()` returns `{ ok: false, code: 'E_NO_GSAP_TIMELINE' }`; add `var tl = gsap.timeline(...)` and it succeeds. `dispatch()` does not consult `can()` — call `can()` first and skip the op when it fails.</Note>See also: [`Composition`](/sdk/reference/composition) for the typed-method wrappers, [`Types`](/sdk/reference/types) for `CanResult` and `EditOp`.@@ -318,7 +318,7 @@ comp.dispatch({ type: "removeVariable", id: "brandColor" });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.<Note>- Only `addGsapTween` here needs a `gsap.timeline()` to attach to — without one, `can()` returns `{ ok: false, code: 'E_NO_GSAP_TIMELINE' }`, so declare a timeline and retry. `setGsapTween`, `removeGsapTween` and `removeGsapProperty` edit or remove an existing tween and don't require it. A failed `can()` means `dispatch()` applies nothing.+ Only `addGsapTween` here needs a `gsap.timeline()` to attach to — without one, `can()` returns `{ ok: false, code: 'E_NO_GSAP_TIMELINE' }`, so declare a timeline and retry. `setGsapTween`, `removeGsapTween` and `removeGsapProperty` edit or remove an existing tween and don't require it. `dispatch()` does not consult `can()` — call `can()` first and skip the op when it fails.</Note>| `type` | Key fields | What it does |diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.tsindex d43c603e7e..ba902e7d07 100644--- a/packages/sdk/src/types.ts+++ b/packages/sdk/src/types.ts@@ -592,7 +592,8 @@ export interface Composition {* Dry-run validation — would dispatch(op) succeed?* Returns {ok:true} when dispatch would mutate the document, {ok:false,code,message} otherwise.* Use as a feature-detection gate: `const r = comp.can(op); if (!r.ok) return;`- * Phase 3b ops return {ok:false,code:'E_NO_GSAP_TIMELINE'} until parser engine ships.+ * addGsapTween / addLabel return {ok:false,code:'E_NO_GSAP_TIMELINE'} when the+ * script has no gsap.timeline() declaration to attach to.*/can(op: EditOp): CanResult;