Skip to content

Tree-shakable AnimationManager - #840

Open
jfboeve wants to merge 3 commits into
mainfrom
feat/treeshake-animation-manager
Open

Tree-shakable AnimationManager #840
jfboeve wants to merge 3 commits into
mainfrom
feat/treeshake-animation-manager

Conversation

@jfboeve

@jfboeve jfboeve commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

This pull request refactors the animation system to introduce a new AnimationManager interface and a concrete implementation called CoreAnimationManager. It standardizes how animations are created and managed, updates the API for animating nodes, and ensures consistent usage across the codebase and tests. The changes also update type signatures and dependency injection for improved flexibility and testability.

Animation System Refactor

  • Introduced a new AnimationManager interface and implemented it as CoreAnimationManager, clarifying animation management responsibilities and exposing a consistent API (animate, animateNode, and update). (src/core/animations/AnimationManager.ts) [1] [2]
  • Updated all usages of the old createAnimation method to the new animate method in the codebase and tests, ensuring consistency. (src/core/animations/AnimationManager.test.ts, src/core/animations/CoreAnimationController.test.ts) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]

CoreNode Animation API Changes

  • Removed the animate method from CoreNode and replaced it with a property that delegates to stage.animationManager.animateNode, aligning with the new animation manager API. (src/core/CoreNode.ts) [1] [2]
  • Cleaned up unused imports related to animation settings and controllers in CoreNode. (src/core/CoreNode.ts)

Renderer and Stage Integration

  • Updated Stage and renderer initialization to accept an animationManager instance via options, improving dependency injection and flexibility. (src/core/Stage.ts, examples/index.ts) [1] [2] [3] [4] [5] [6] [7]

Type and Dependency Updates

  • Updated type imports and usages to reference CoreAnimationManager where appropriate, ensuring type safety and clarity throughout the codebase. (src/core/animations/CoreAnimationController.ts) [1] [2]

These changes collectively modernize the animation system, improve code clarity, and make the animation API more flexible and consistent. This also allows you to implement your own animation manager.

@jfboeve
jfboeve requested a review from wouterlucas July 15, 2026 10:51
@jfboeve jfboeve changed the title Make AnimationManager tree-shakable Tree-shakable AnimationManager Jul 16, 2026

@wouterlucas wouterlucas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok - stopped reviewing

Think your agent did this silly thing with extending the animation manager class which makes it very messy.

RendererMain is its own class
Animation Manager can be an abstract type

The old animation manager should implement said abstract class

You can provide the animation manager, or not if you chose not to use one, on renderer main init.

Comment thread src/main-api/Renderer.ts
maxRetryCount?: number;
};
export type RendererMainSettings<A extends AnimationManager> =
RendererRuntimeSettings &

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this A extends AnimationManager ?

Comment thread src/main-api/Renderer.ts
readonly root: INode;
export class RendererMain<
A extends AnimationManager = AnimationManager,
> extends EventEmitter {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here - why are we extending?

Comment thread src/main-api/Renderer.ts

assertTruthy(
settings.animationManager,
'An animation manager must be provided in settings.animationManager',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it? can be null to right? if we dont want to use an animation manager

Comment thread src/main-api/Renderer.ts
this.inspector = new inspector(
this.canvas,
settings as RendererMainSettings,
settings as RendererMainSettings<A>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🫣

Comment thread src/main-api/Renderer.ts

// Extract the root node
this.root = this.stage.root as unknown as INode;
this.root = this.stage.root as unknown as INode<A>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🫣

Comment thread src/main-api/Renderer.ts
createNode<ShNode extends CoreShaderNode<any>>(
props: Partial<INodeProps<ShNode>>,
): INode<ShNode> {
props: Partial<INodeProps<A, ShNode>>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stahhpp its leaking everywhere 🫣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants