From efc91fc877d89d8057611dd87c81220be46df9a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Tue, 17 Nov 2026 09:03:19 +0000 Subject: [PATCH] feat(studio): an element's source-parsed animations are part of Studio's API (#8061) --- packages/studio/src/elementAnimations.test.ts | 13 +++++++++++++ packages/studio/src/index.ts | 1 + 2 files changed, 14 insertions(+) create mode 100644 packages/studio/src/elementAnimations.test.ts diff --git a/packages/studio/src/elementAnimations.test.ts b/packages/studio/src/elementAnimations.test.ts new file mode 100644 index 0000000000..8a3b8ec0f8 --- /dev/null +++ b/packages/studio/src/elementAnimations.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from "vitest"; +import type { GsapAnimation } from "@hyperframes/core/gsap-parser"; +import { getAnimationsForElement } from "./index"; + +const tween = (targetSelector: string) => ({ targetSelector }) as GsapAnimation; + +describe("an element's animations from Studio's public API", () => { + it("are the parsed tweens that address it by id or selector, read where a sealed preview's host can", () => { + const parsed = [tween("#title"), tween(".card, .hero"), tween("#other")]; + expect(getAnimationsForElement(parsed, { id: "title", selector: null })).toEqual([parsed[0]]); + expect(getAnimationsForElement(parsed, { id: null, selector: ".hero" })).toEqual([parsed[1]]); + }); +}); diff --git a/packages/studio/src/index.ts b/packages/studio/src/index.ts index 2662f64dc5..dd7d60678b 100644 --- a/packages/studio/src/index.ts +++ b/packages/studio/src/index.ts @@ -117,6 +117,7 @@ export { ImageThumbnail } from "./player/components/ImageThumbnail"; export type { ImageThumbnailProps } from "./player/components/ImageThumbnail"; export { useRenderClipContent } from "./hooks/useRenderClipContent"; export { useThumbnailStill } from "./hooks/useThumbnailStill"; +export { fetchParsedAnimations, getAnimationsForElement } from "./hooks/useGsapTweenCache"; export type { ThumbnailStill, UseThumbnailStillOptions } from "./hooks/useThumbnailStill"; export type { UseRenderClipContentOptions } from "./hooks/useRenderClipContent"; export type { ThumbnailPriority } from "./player/lib/thumbnailScheduler";