-
Notifications
You must be signed in to change notification settings - Fork 4.2k
fix(studio): respect GSAP transform ownership #2986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
miguel-heygen
merged 2 commits into
fix/gsap-helper-defaults
from
fix/gsap-transform-ownership
Aug 4, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import { editabilityForProvenance, type GsapAnimation } from "@hyperframes/core/gsap-parser"; | ||
|
|
||
| export type GsapEditBlockReason = "no-selector" | "unroll-required" | "source-uneditable"; | ||
|
|
||
| export type GsapEditOutcome = | ||
| | { status: "persisted" } | ||
| | { status: "blocked"; reason: GsapEditBlockReason }; | ||
|
|
||
| const COPY: Record<GsapEditBlockReason, string> = { | ||
| "no-selector": "This layer needs a stable selector before Studio can save the edit.", | ||
| "unroll-required": | ||
| "This motion comes from a helper or loop. Choose Unroll to edit it explicitly.", | ||
| "source-uneditable": "This animation is computed at runtime. Edit the animation in the Code tab.", | ||
| }; | ||
|
|
||
| export class GsapEditBlockedError extends Error { | ||
| constructor(readonly reason: GsapEditBlockReason) { | ||
| super(COPY[reason]); | ||
| this.name = "GsapEditBlockedError"; | ||
| } | ||
| } | ||
|
|
||
| export function assertGsapEditPersisted(outcome: GsapEditOutcome): void { | ||
| if (outcome.status === "blocked") throw new GsapEditBlockedError(outcome.reason); | ||
| } | ||
|
|
||
| function assertGsapAnimationDirectlyEditable(animation: GsapAnimation): void { | ||
| const editability = editabilityForProvenance(animation.provenance); | ||
| if (editability === "unroll") throw new GsapEditBlockedError("unroll-required"); | ||
| if ( | ||
| editability === "source" || | ||
| animation.hasUnresolvedKeyframes || | ||
| animation.hasUnresolvedSelector | ||
| ) { | ||
| throw new GsapEditBlockedError("source-uneditable"); | ||
| } | ||
| } | ||
|
|
||
| export function isGsapEditBlockedError(error: unknown): error is GsapEditBlockedError { | ||
| return error instanceof GsapEditBlockedError; | ||
| } | ||
|
|
||
| export function animationWritesAnyProperty( | ||
| animation: GsapAnimation, | ||
| properties: ReadonlySet<string>, | ||
| ): boolean { | ||
| return ( | ||
| Object.keys(animation.properties ?? {}).some((property) => properties.has(property)) || | ||
| Object.keys(animation.fromProperties ?? {}).some((property) => properties.has(property)) || | ||
| !!animation.keyframes?.keyframes.some((keyframe) => | ||
| Object.keys(keyframe.properties).some((property) => properties.has(property)), | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| /** Fail-closed ownership check shared by drag, resize, rotate, and inspector edits. */ | ||
| export function directEditOutcomeForProperties( | ||
| animations: GsapAnimation[], | ||
| properties: ReadonlySet<string>, | ||
| ): GsapEditOutcome { | ||
| try { | ||
| for (const animation of animations) { | ||
| if (animationWritesAnyProperty(animation, properties)) { | ||
| assertGsapAnimationDirectlyEditable(animation); | ||
| } | ||
| } | ||
| return { status: "persisted" }; | ||
| } catch (error) { | ||
| if (isGsapEditBlockedError(error)) return { status: "blocked", reason: error.reason }; | ||
| throw error; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.