Skip to content

Commit 0cbfc2d

Browse files
authored
refactor: move animate property to sdk runtime (#5171)
Vite 6 is having troubles bundling app which depends on whole sdk. Plus it may increase app bundle size.
1 parent 7fa57b2 commit 0cbfc2d

5 files changed

Lines changed: 13 additions & 16 deletions

File tree

apps/builder/app/builder/features/navigator/navigator-tree.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ import {
2020
TreeSortableItem,
2121
type TreeDropTarget,
2222
} from "@webstudio-is/design-system";
23-
import {
24-
animationCanPlayOnCanvasAttribute,
25-
showAttribute,
26-
} from "@webstudio-is/react-sdk";
23+
import { showAttribute } from "@webstudio-is/react-sdk";
2724
import {
2825
ROOT_INSTANCE_ID,
2926
collectionComponent,
@@ -34,6 +31,7 @@ import {
3431
type Instance,
3532
type WsComponentMeta,
3633
} from "@webstudio-is/sdk";
34+
import { animationCanPlayOnCanvasProperty } from "@webstudio-is/sdk/runtime";
3735
import {
3836
EyeClosedIcon,
3937
EyeOpenIcon,
@@ -675,7 +673,7 @@ export const NavigatorTree = () => {
675673

676674
// Hook memory prop
677675
const isAnimationSelected =
678-
propValues?.get(animationCanPlayOnCanvasAttribute) === true;
676+
propValues?.get(animationCanPlayOnCanvasProperty) === true;
679677

680678
const props = propsByInstanceId.get(item.instance.id);
681679
const actionProp = props?.find(

packages/react-sdk/src/props.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ export const componentAttribute = "data-ws-component" as const;
128128
export const showAttribute = "data-ws-show" as const;
129129
export const collapsedAttribute = "data-ws-collapsed" as const;
130130
export const textContentAttribute = "data-ws-text-content" as const;
131-
export const animationCanPlayOnCanvasAttribute =
132-
"data-ws-animation-can-play-on-canvas";
133131

134132
/**
135133
* Copyright (c) Meta Platforms, Inc. and affiliates.

packages/sdk-components-animation/src/animate-children.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import {
2-
animationCanPlayOnCanvasAttribute,
3-
type Hook,
4-
} from "@webstudio-is/react-sdk";
5-
import type { AnimationAction } from "@webstudio-is/sdk";
61
import { forwardRef, type ElementRef } from "react";
2+
import type { Hook } from "@webstudio-is/react-sdk";
3+
import type { AnimationAction } from "@webstudio-is/sdk";
4+
import { animationCanPlayOnCanvasProperty } from "@webstudio-is/sdk/runtime";
75

86
type ScrollProps = {
97
debug?: boolean;
@@ -30,7 +28,7 @@ export const hooksAnimateChildren: Hook = {
3028
) {
3129
context.setMemoryProp(
3230
event.instancePath[0],
33-
animationCanPlayOnCanvasAttribute,
31+
animationCanPlayOnCanvasProperty,
3432
undefined
3533
);
3634
}
@@ -42,7 +40,7 @@ export const hooksAnimateChildren: Hook = {
4240
) {
4341
context.setMemoryProp(
4442
event.instancePath[0],
45-
animationCanPlayOnCanvasAttribute,
43+
animationCanPlayOnCanvasProperty,
4644
true
4745
);
4846
}

packages/sdk/src/runtime.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ export const getTagFromProps = (
1010
return props[tagProperty] as string | undefined;
1111
};
1212

13-
export const indexProperty = "data-ws-index" as const;
13+
export const indexProperty = "data-ws-index";
1414

1515
export const getIndexWithinAncestorFromProps = (
1616
props: Record<string, unknown>
1717
) => {
1818
return props[indexProperty] as string | undefined;
1919
};
20+
21+
export const animationCanPlayOnCanvasProperty =
22+
"data-ws-animation-can-play-on-canvas";

0 commit comments

Comments
 (0)