mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-09 20:07:39 +00:00
feat(studio): GSAP tween editing in Design panel (#1102)
* feat(studio): GSAP tween editing in Design panel
Add a GSAP animation editor to the studio Design panel: select an element,
view and edit its tweens (properties, easing, timing), add/delete animations,
and drag custom bezier speed curves — all persisted back to the composition
HTML. Gated behind VITE_STUDIO_ENABLE_GSAP_PANEL.
Parsing of existing GSAP source now uses a recast + Babel AST parser instead of
regex, giving scope resolution, stable tween IDs, and round-trip preservation of
extras and unresolved raw values.
recast compiles to CommonJS that calls require("fs"), which breaks browser and
Vite SSR bundles. To contain it, @hyperframes/core is split into an isomorphic
layer and a Node-only AST layer:
- gsapSerialize.ts holds the recast-free helpers (serialization, keyframe
conversion, validation, shared types). htmlParser.ts is now fully isomorphic.
- parseGsapScript and the script-mutation helpers live in gsapParser.ts,
reachable only via the @hyperframes/core/gsap-parser subpath, loaded
server-side by the studio-api mutation routes and the linter via dynamic
import (recast stays external under SSR).
- The barrel and the gsap-constants subpath are recast-free, so studio browser
bundles never trace recast.
Adds AST parser unit + stress coverage and e2e helpers for the panel.
* fix(lint): await async lintHyperframeHtml in all callers
lintHyperframeHtml became async (gsap rules use dynamic import)
but lintProject and check-hyperframe-static weren't awaiting it,
causing typecheck failures and runtime crashes in CI.
Also wire LintRule type in gsap rules to fix fallow unused-type
finding, and suppress render.ts exported-for-tests symbols.
This commit is contained in:
@@ -18,33 +18,33 @@ describe("lintHyperframeHtml — orchestrator", () => {
|
||||
</body>
|
||||
</html>`;
|
||||
|
||||
it("reports no errors for a valid composition", () => {
|
||||
const result = lintHyperframeHtml(validComposition);
|
||||
it("reports no errors for a valid composition", async () => {
|
||||
const result = await lintHyperframeHtml(validComposition);
|
||||
expect(result.ok).toBe(true);
|
||||
expect(result.errorCount).toBe(0);
|
||||
});
|
||||
|
||||
it("attaches filePath to findings when option is set", () => {
|
||||
it("attaches filePath to findings when option is set", async () => {
|
||||
const html = "<html><body><div></div></body></html>";
|
||||
const result = lintHyperframeHtml(html, { filePath: "test.html" });
|
||||
const result = await lintHyperframeHtml(html, { filePath: "test.html" });
|
||||
for (const finding of result.findings) {
|
||||
expect(finding.file).toBe("test.html");
|
||||
}
|
||||
});
|
||||
|
||||
it("deduplicates identical findings", () => {
|
||||
it("deduplicates identical findings", async () => {
|
||||
const html = `
|
||||
<html><body>
|
||||
<div id="root"></div>
|
||||
<script>const tl = gsap.timeline();</script>
|
||||
</body></html>`;
|
||||
const result = lintHyperframeHtml(html);
|
||||
const result = await lintHyperframeHtml(html);
|
||||
const codes = result.findings.map((f) => `${f.code}|${f.message}`);
|
||||
const uniqueCodes = [...new Set(codes)];
|
||||
expect(codes.length).toBe(uniqueCodes.length);
|
||||
});
|
||||
|
||||
it("strips <template> wrapper before linting composition files", () => {
|
||||
it("strips <template> wrapper before linting composition files", async () => {
|
||||
const html = `<template id="my-comp-template">
|
||||
<div data-composition-id="my-comp" data-width="1920" data-height="1080"
|
||||
style="position:relative;width:1920px;height:1080px;">
|
||||
@@ -57,7 +57,7 @@ describe("lintHyperframeHtml — orchestrator", () => {
|
||||
window.__timelines["my-comp"] = tl;
|
||||
</script>
|
||||
</template>`;
|
||||
const result = lintHyperframeHtml(html, { filePath: "compositions/my-comp.html" });
|
||||
const result = await lintHyperframeHtml(html, { filePath: "compositions/my-comp.html" });
|
||||
const missing = result.findings.filter(
|
||||
(f) => f.code === "missing-composition-id" || f.code === "missing-dimensions",
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user