Skip to content

Write HTML. Render video. Built for agents.

feat(sdk,studio): ws-1.1 — add set method to GsapTweenSpec; route addGsapAnimation(set) through sdk (#1497)

Vance Ingallsa5016ed4168d
diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts
index 4220acc8f2..7b9a507ec0 100644
--- a/packages/sdk/src/types.ts
+++ b/packages/sdk/src/types.ts
@@ -113,7 +113,7 @@ export interface ElasticHold {
}
export interface GsapTweenSpec {
- method: "from" | "to" | "fromTo";
+ method: "from" | "to" | "fromTo" | "set";
position?: number | string;
duration?: number;
ease?: string;
diff --git a/packages/studio/src/hooks/useGsapAnimationOps.ts b/packages/studio/src/hooks/useGsapAnimationOps.ts
index 66cec59fb7..b5318bcd31 100644
--- a/packages/studio/src/hooks/useGsapAnimationOps.ts
+++ b/packages/studio/src/hooks/useGsapAnimationOps.ts
@@ -126,20 +126,18 @@ export function useGsapAnimationOps({
fromTo: { x: 0, y: 0, opacity: 1 },
};
- // SDK path: addGsapTween only supports from/to/fromTo; "set" stays
- // server-side. Skip the SDK path when an id was just assigned server-side
- // (autoId): the SDK session hasn't reloaded that write yet, so persisting
- // its serialization would clobber the new id — let the server add the
- // tween atomically with the id it wrote.
- if (!autoId && method !== "set" && selection.hfId && sdkSession && sdkDeps) {
+ // Skip SDK path when an id was just assigned server-side (autoId): the
+ // SDK session hasn't reloaded that write yet, so persisting its
+ // serialization would clobber the new id — let the server add the tween
+ // atomically with the id it wrote.
+ if (!autoId && selection.hfId && sdkSession && sdkDeps) {
const targetPath = selection.sourceFile || activeCompPath || "index.html";
const spec = {
- method: method as "to" | "from" | "fromTo",
+ method,
position,
- duration,
- ease: "power2.out" as const,
+ ...(method !== "set" ? { duration, ease: "power2.out" as const } : {}),
properties: toDefaults[method] ?? { opacity: 1 },
- fromProperties: method === "fromTo" ? { opacity: 0 } : undefined,
+ ...(method === "fromTo" ? { fromProperties: { opacity: 0 } } : {}),
};
const handled = await sdkGsapTweenPersist(
targetPath,