react-native-reanimated 4.4.1 → 4.4.3

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 (95) hide show
  1. package/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.cpp +12 -5
  2. package/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.cpp +63 -36
  3. package/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.h +6 -8
  4. package/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.cpp +5 -0
  5. package/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +25 -12
  6. package/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +3 -0
  7. package/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.cpp +54 -24
  8. package/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.h +13 -6
  9. package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.cpp +6 -2
  10. package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h +44 -1
  11. package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp +125 -43
  12. package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp +228 -102
  13. package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h +4 -0
  14. package/Common/cpp/reanimated/LayoutAnimations/SharedTransitions.cpp +8 -3
  15. package/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +7 -21
  16. package/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +0 -16
  17. package/android/CMakeLists.txt +6 -0
  18. package/android/build.gradle.kts +21 -1
  19. package/android/src/main/java/com/swmansion/reanimated/NativeProxy.kt +46 -2
  20. package/android/src/main/java/com/swmansion/reanimated/keyboard/KeyboardAnimationCallback.kt +8 -1
  21. package/apple/reanimated/apple/ReanimatedModule.mm +12 -1
  22. package/compatibility.json +1 -1
  23. package/lib/module/PropsRegistryGarbageCollector.js +3 -6
  24. package/lib/module/PropsRegistryGarbageCollector.js.map +1 -1
  25. package/lib/module/animation/styleAnimation.js +4 -3
  26. package/lib/module/animation/styleAnimation.js.map +1 -1
  27. package/lib/module/common/constants/platform.js +4 -4
  28. package/lib/module/common/constants/platform.js.map +1 -1
  29. package/lib/module/createAnimatedComponent/AnimatedComponent.js +1 -1
  30. package/lib/module/createAnimatedComponent/AnimatedComponent.js.map +1 -1
  31. package/lib/module/createAnimatedComponent/getViewInfo.js +3 -1
  32. package/lib/module/createAnimatedComponent/getViewInfo.js.map +1 -1
  33. package/lib/module/css/component/AnimatedComponent.js +0 -2
  34. package/lib/module/css/component/AnimatedComponent.js.map +1 -1
  35. package/lib/module/css/native/managers/CSSManager.js +5 -5
  36. package/lib/module/css/native/managers/CSSManager.js.map +1 -1
  37. package/lib/module/css/native/managers/CSSTransitionsManager.js +8 -1
  38. package/lib/module/css/native/managers/CSSTransitionsManager.js.map +1 -1
  39. package/lib/module/css/svg/native/processors/stroke.js +9 -5
  40. package/lib/module/css/svg/native/processors/stroke.js.map +1 -1
  41. package/lib/module/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +6 -3
  42. package/lib/module/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
  43. package/lib/module/layoutReanimation/animationsManager.js +39 -11
  44. package/lib/module/layoutReanimation/animationsManager.js.map +1 -1
  45. package/lib/module/mappers.js +1 -1
  46. package/lib/module/mappers.js.map +1 -1
  47. package/lib/module/platform-specific/findHostInstance.js +8 -5
  48. package/lib/module/platform-specific/findHostInstance.js.map +1 -1
  49. package/lib/module/platform-specific/jsVersion.js +1 -1
  50. package/lib/module/updateProps/updateProps.js +3 -2
  51. package/lib/module/updateProps/updateProps.js.map +1 -1
  52. package/lib/module/valueSetter.js +6 -7
  53. package/lib/module/valueSetter.js.map +1 -1
  54. package/lib/typescript/PropsRegistryGarbageCollector.d.ts +0 -1
  55. package/lib/typescript/PropsRegistryGarbageCollector.d.ts.map +1 -1
  56. package/lib/typescript/animation/styleAnimation.d.ts +1 -1
  57. package/lib/typescript/animation/styleAnimation.d.ts.map +1 -1
  58. package/lib/typescript/common/constants/platform.d.ts.map +1 -1
  59. package/lib/typescript/createAnimatedComponent/AnimatedComponent.d.ts.map +1 -1
  60. package/lib/typescript/createAnimatedComponent/commonTypes.d.ts +0 -1
  61. package/lib/typescript/createAnimatedComponent/commonTypes.d.ts.map +1 -1
  62. package/lib/typescript/createAnimatedComponent/getViewInfo.d.ts.map +1 -1
  63. package/lib/typescript/css/component/AnimatedComponent.d.ts +0 -1
  64. package/lib/typescript/css/component/AnimatedComponent.d.ts.map +1 -1
  65. package/lib/typescript/css/native/managers/CSSTransitionsManager.d.ts +5 -1
  66. package/lib/typescript/css/native/managers/CSSTransitionsManager.d.ts.map +1 -1
  67. package/lib/typescript/css/svg/native/processors/stroke.d.ts.map +1 -1
  68. package/lib/typescript/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +17 -14
  69. package/lib/typescript/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts.map +1 -1
  70. package/lib/typescript/layoutReanimation/animationsManager.d.ts.map +1 -1
  71. package/lib/typescript/platform-specific/findHostInstance.d.ts.map +1 -1
  72. package/lib/typescript/platform-specific/jsVersion.d.ts +1 -1
  73. package/lib/typescript/platform-specific/types.d.ts +1 -0
  74. package/lib/typescript/platform-specific/types.d.ts.map +1 -1
  75. package/lib/typescript/updateProps/updateProps.d.ts.map +1 -1
  76. package/package.json +3 -3
  77. package/scripts/reanimated_utils.rb +7 -0
  78. package/src/PropsRegistryGarbageCollector.ts +3 -6
  79. package/src/animation/styleAnimation.ts +5 -3
  80. package/src/common/constants/platform.ts +4 -4
  81. package/src/createAnimatedComponent/AnimatedComponent.tsx +3 -1
  82. package/src/createAnimatedComponent/commonTypes.ts +0 -1
  83. package/src/createAnimatedComponent/getViewInfo.ts +3 -1
  84. package/src/css/component/AnimatedComponent.tsx +0 -2
  85. package/src/css/native/managers/CSSManager.ts +8 -8
  86. package/src/css/native/managers/CSSTransitionsManager.ts +9 -2
  87. package/src/css/svg/native/processors/stroke.ts +9 -6
  88. package/src/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +39 -36
  89. package/src/layoutReanimation/animationsManager.ts +41 -11
  90. package/src/mappers.ts +1 -1
  91. package/src/platform-specific/findHostInstance.ts +7 -7
  92. package/src/platform-specific/jsVersion.ts +1 -1
  93. package/src/platform-specific/types.ts +2 -0
  94. package/src/updateProps/updateProps.ts +3 -2
  95. package/src/valueSetter.ts +7 -7
@@ -12,7 +12,9 @@ function findHostInstanceFastPath(maybeNativeRef: HostInstance | undefined) {
12
12
  if (
13
13
  maybeNativeRef.__internalInstanceHandle &&
14
14
  maybeNativeRef.__nativeTag &&
15
- maybeNativeRef._viewConfig
15
+ // ReactFabricHostComponent (e.g. react-native-macos) exposes `_viewConfig`;
16
+ // ReactNativeElement uses `__viewConfig`.
17
+ (maybeNativeRef.__viewConfig || maybeNativeRef._viewConfig)
16
18
  ) {
17
19
  return maybeNativeRef;
18
20
  }
@@ -55,13 +57,11 @@ export function findHostInstance(
55
57
  resolveFindHostInstance_DEPRECATED();
56
58
  /*
57
59
  The Fabric implementation of `findHostInstance_DEPRECATED` requires a React ref as an argument
58
- rather than a native ref. If a component implements the `getAnimatableRef` method, it must use
59
- the ref provided by this method. It is the component's responsibility to ensure that this is
60
- a valid React ref.
60
+ rather than a native ref. Prefer the resolved component ref when available so components can
61
+ forward their ref to the host view that should be animated. Components that expose an animatable
62
+ ref via `getAnimatableRef` already have it resolved into `_componentRef`.
61
63
  */
62
64
  return findHostInstance_DEPRECATED(
63
- (ref as IAnimatedComponentInternalBase)._hasAnimatedRef
64
- ? (ref as IAnimatedComponentInternalBase)._componentRef
65
- : ref
65
+ (ref as IAnimatedComponentInternalBase)._componentRef ?? ref
66
66
  );
67
67
  }
@@ -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.4.1';
7
+ export const jsVersion = '4.4.3';
@@ -3,5 +3,7 @@
3
3
  export type HostInstance = {
4
4
  __internalInstanceHandle?: Record<string, unknown>;
5
5
  __nativeTag?: number;
6
+ __viewConfig?: Record<string, unknown>;
7
+ // Legacy ReactFabricHostComponent key (e.g. react-native-macos).
6
8
  _viewConfig?: Record<string, unknown>;
7
9
  };
@@ -112,7 +112,7 @@ type NativePropsOperation = {
112
112
  function createUpdatePropsManager() {
113
113
  'worklet';
114
114
  const nativeOperations: NativePropsOperation[] = [];
115
- const jsOperations: JSPropsOperation[] = [];
115
+ let jsOperations: JSPropsOperation[] = [];
116
116
 
117
117
  let flushPending = false;
118
118
 
@@ -165,8 +165,9 @@ function createUpdatePropsManager() {
165
165
  nativeOperations.length = 0;
166
166
  }
167
167
  if (jsOperations.length) {
168
+ // Fresh array each flush: scheduleOnRN caches serialized args by identity.
168
169
  scheduleOnRN(updateJSProps, jsOperations);
169
- jsOperations.length = 0;
170
+ jsOperations = [];
170
171
  }
171
172
  flushPending = false;
172
173
  if (!USE_ANIMATION_BACKEND) {
@@ -9,15 +9,19 @@ export function valueSetter<Value>(
9
9
  'worklet';
10
10
  const previousAnimation = mutable._animation;
11
11
  if (previousAnimation) {
12
- previousAnimation.cancelled = true;
13
12
  mutable._animation = null;
13
+ if (!previousAnimation.finished) {
14
+ previousAnimation.cancelled = true;
15
+ previousAnimation.callback?.(false);
16
+ }
14
17
  }
15
18
  if (
16
19
  typeof value === 'function' ||
17
20
  (value !== null &&
18
21
  typeof value === 'object' &&
19
22
  // TODO TYPESCRIPT fix this after fixing AnimationObject type
20
- (value as unknown as AnimationObject).onFrame !== undefined)
23
+ (value as unknown as AnimationObject).onFrame !== undefined &&
24
+ (value as unknown as AnimationObject).onStart !== undefined)
21
25
  ) {
22
26
  const animation: AnimationObject<Value> =
23
27
  typeof value === 'function'
@@ -47,17 +51,13 @@ export function valueSetter<Value>(
47
51
 
48
52
  const step = (timestamp: number) => {
49
53
  if (animation.cancelled) {
50
- animation.callback?.(false /* finished */);
51
54
  return;
52
55
  }
53
56
  const finished = animation.onFrame(animation, timestamp);
54
- animation.finished = true;
55
57
  animation.timestamp = timestamp;
56
- // TODO TYPESCRIPT
57
- // For now I'll assume that `animation.current` is always defined
58
- // but actually need to dive into animations to understand it
59
58
  mutable._value = animation.current!;
60
59
  if (finished) {
60
+ animation.finished = true;
61
61
  animation.callback?.(true /* finished */);
62
62
  } else {
63
63
  requestAnimationFrame(step);