react-native-reanimated 4.5.2 → 4.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/Common/cpp/reanimated/Fabric/ShadowTreeCloner.cpp +1 -1
  2. package/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.cpp +54 -24
  3. package/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.h +13 -6
  4. package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h +5 -5
  5. package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp +84 -3
  6. package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h +7 -4
  7. package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp +159 -27
  8. package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h +40 -18
  9. package/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +21 -14
  10. package/android/build.gradle.kts +9 -0
  11. package/apple/reanimated/apple/REANodesManager.mm +5 -1
  12. package/lib/module/PropsRegistryGarbageCollector.js +3 -6
  13. package/lib/module/PropsRegistryGarbageCollector.js.map +1 -1
  14. package/lib/module/animation/styleAnimation.js +4 -3
  15. package/lib/module/animation/styleAnimation.js.map +1 -1
  16. package/lib/module/createAnimatedComponent/AnimatedComponent.js +1 -1
  17. package/lib/module/createAnimatedComponent/AnimatedComponent.js.map +1 -1
  18. package/lib/module/layoutReanimation/animationsManager.js +9 -6
  19. package/lib/module/layoutReanimation/animationsManager.js.map +1 -1
  20. package/lib/module/platform-specific/jsVersion.js +1 -1
  21. package/lib/typescript/PropsRegistryGarbageCollector.d.ts +0 -1
  22. package/lib/typescript/PropsRegistryGarbageCollector.d.ts.map +1 -1
  23. package/lib/typescript/animation/styleAnimation.d.ts +1 -1
  24. package/lib/typescript/animation/styleAnimation.d.ts.map +1 -1
  25. package/lib/typescript/createAnimatedComponent/AnimatedComponent.d.ts.map +1 -1
  26. package/lib/typescript/layoutReanimation/animationsManager.d.ts.map +1 -1
  27. package/lib/typescript/platform-specific/jsVersion.d.ts +1 -1
  28. package/package.json +2 -2
  29. package/scripts/reanimated_utils.rb +7 -0
  30. package/src/PropsRegistryGarbageCollector.ts +3 -6
  31. package/src/animation/styleAnimation.ts +5 -3
  32. package/src/createAnimatedComponent/AnimatedComponent.tsx +3 -1
  33. package/src/layoutReanimation/animationsManager.ts +9 -7
  34. package/src/platform-specific/jsVersion.ts +1 -1
@@ -62,6 +62,13 @@ module ReanimatedUtils
62
62
  if ios_sync_ui_props && shared_element_transitions
63
63
  raise "[Reanimated] The feature flags `IOS_SYNCHRONOUSLY_UPDATE_UI_PROPS` and `ENABLE_SHARED_ELEMENT_TRANSITIONS` cannot be enabled simultaneously. Please disable one of them in your package.json"
64
64
  end
65
+
66
+ use_animation_backend = feature_flags['USE_ANIMATION_BACKEND'] == 'true'
67
+ force_react_render_for_settled_animations = feature_flags['FORCE_REACT_RENDER_FOR_SETTLED_ANIMATIONS'] == 'true'
68
+
69
+ if use_animation_backend && force_react_render_for_settled_animations
70
+ raise "[Reanimated] The feature flags `USE_ANIMATION_BACKEND` and `FORCE_REACT_RENDER_FOR_SETTLED_ANIMATIONS` cannot be enabled simultaneously. If you want to use the animation backend, you need to explicitly disable `FORCE_REACT_RENDER_FOR_SETTLED_ANIMATIONS` feature flag (enabled by default) in your package.json"
71
+ end
65
72
  end
66
73
 
67
74
  def get_static_feature_flags()
@@ -11,7 +11,6 @@ import { ReanimatedModule } from './ReanimatedModule';
11
11
  const FLUSH_INTERVAL_MS = 500;
12
12
 
13
13
  export const PropsRegistryGarbageCollector = {
14
- viewsCount: 0,
15
14
  viewsMap: new Map<number, IAnimatedComponentInternal>(),
16
15
  intervalId: null as NodeJS.Timeout | null,
17
16
 
@@ -25,16 +24,14 @@ export const PropsRegistryGarbageCollector = {
25
24
  return;
26
25
  }
27
26
  this.viewsMap.set(viewTag, component);
28
- this.viewsCount++;
29
- if (this.viewsCount === 1) {
27
+ if (this.viewsMap.size === 1) {
30
28
  this.registerInterval();
31
29
  }
32
30
  },
33
31
 
34
32
  unregisterView(viewTag: number) {
35
- this.viewsMap.delete(viewTag);
36
- this.viewsCount--;
37
- if (this.viewsCount === 0) {
33
+ const deleted = this.viewsMap.delete(viewTag);
34
+ if (deleted && this.viewsMap.size === 0) {
38
35
  this.unregisterInterval();
39
36
  }
40
37
  },
@@ -73,7 +73,8 @@ interface NestedObjectEntry<T> {
73
73
 
74
74
  export function withStyleAnimation(
75
75
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
76
- styleAnimations: AnimatedStyle<any>
76
+ styleAnimations: AnimatedStyle<any>,
77
+ callback?: (finished: boolean) => void
77
78
  ): StyleLayoutAnimation {
78
79
  'worklet';
79
80
  return defineAnimation<StyleLayoutAnimation>({}, () => {
@@ -236,7 +237,7 @@ export function withStyleAnimation(
236
237
  }
237
238
  };
238
239
 
239
- const callback = (finished: boolean): void => {
240
+ const styleAnimationCallback = (finished: boolean): void => {
240
241
  if (!finished) {
241
242
  const animationsToCheck: NestedObjectValues<AnimationObject>[] = [
242
243
  styleAnimations,
@@ -267,6 +268,7 @@ export function withStyleAnimation(
267
268
  }
268
269
  }
269
270
  }
271
+ callback?.(finished);
270
272
  };
271
273
 
272
274
  return {
@@ -275,7 +277,7 @@ export function withStyleAnimation(
275
277
  onStart,
276
278
  current: {},
277
279
  styleAnimations,
278
- callback,
280
+ callback: styleAnimationCallback,
279
281
  } as StyleLayoutAnimation;
280
282
  });
281
283
  }
@@ -51,7 +51,9 @@ if (IS_WEB) {
51
51
  }
52
52
 
53
53
  const FORCE_REACT_RENDER_FOR_SETTLED_ANIMATIONS =
54
- getStaticFeatureFlag('FORCE_REACT_RENDER_FOR_SETTLED_ANIMATIONS') && !IS_WEB;
54
+ getStaticFeatureFlag('FORCE_REACT_RENDER_FOR_SETTLED_ANIMATIONS') &&
55
+ !getStaticFeatureFlag('USE_ANIMATION_BACKEND') &&
56
+ !IS_WEB;
55
57
 
56
58
  export type Options<P> = {
57
59
  setNativeProps?: (ref: AnimatedComponentRef, props: P) => void;
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { runOnUISync } from 'react-native-worklets';
4
4
 
5
- import { withStyleAnimation } from '../animation';
5
+ import { cancelAnimation, withStyleAnimation } from '../animation';
6
6
  import { SHOULD_BE_USE_WEB } from '../common';
7
7
  import type {
8
8
  LayoutAnimation,
@@ -102,9 +102,7 @@ function createLayoutAnimationManager(): {
102
102
  value._value = style.initialValues;
103
103
  }
104
104
 
105
- const animation = withStyleAnimation(currentAnimation);
106
-
107
- animation.callback = (finished?: boolean) => {
105
+ const animation = withStyleAnimation(currentAnimation, (finished) => {
108
106
  if (finished) {
109
107
  currentAnimationForTag.delete(tag);
110
108
  mutableValuesForTag.delete(tag);
@@ -112,9 +110,9 @@ function createLayoutAnimationManager(): {
112
110
  stopObservingProgress(tag, value, scheduleFlush, shouldRemoveView);
113
111
  }
114
112
  if (style.callback) {
115
- style.callback(finished === undefined ? false : finished);
113
+ style.callback(finished);
116
114
  }
117
- };
115
+ });
118
116
 
119
117
  startObservingProgress(tag, value, scheduleFlush);
120
118
  value.value = animation;
@@ -124,7 +122,11 @@ function createLayoutAnimationManager(): {
124
122
  if (!value) {
125
123
  return;
126
124
  }
127
- stopObservingProgress(tag, value, scheduleFlush);
125
+ // native already made its cleanup, so we just do cleanup here on JS side
126
+ value.removeListener(tag + TAG_OFFSET);
127
+ cancelAnimation(value);
128
+ currentAnimationForTag.delete(tag);
129
+ mutableValuesForTag.delete(tag);
128
130
  },
129
131
  };
130
132
  }
@@ -4,4 +4,4 @@
4
4
  * version used to build the native part of the library in runtime. Remember to
5
5
  * keep this in sync with the version declared in `package.json`
6
6
  */
7
- export const jsVersion = '4.5.2';
7
+ export const jsVersion = '4.5.4';