react-native-reanimated 2.3.0-beta.3 → 2.3.2

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 (220) hide show
  1. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +9 -0
  2. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +13 -0
  3. package/Common/cpp/Tools/FeaturesConfig.cpp +5 -0
  4. package/Common/cpp/Tools/RuntimeDecorator.cpp +38 -2
  5. package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +3 -0
  6. package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +5 -0
  7. package/Common/cpp/headers/Tools/FeaturesConfig.h +19 -0
  8. package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +2 -0
  9. package/Common/cpp/headers/Tools/RuntimeDecorator.h +8 -7
  10. package/README.md +1 -1
  11. package/RNReanimated.podspec +20 -3
  12. package/android/build.gradle +31 -5
  13. package/android/expo/linking.gradle +46 -0
  14. package/android/expo/src/main/java/com/swmansion/reanimated/EXReanimatedAdapter.java +12 -0
  15. package/android/expo/src/main/java/expo/modules/adapters/reanimated/EXReanimatedPackage.java +26 -0
  16. package/android/react-native-reanimated-63-hermes.aar +0 -0
  17. package/android/react-native-reanimated-63-jsc.aar +0 -0
  18. package/android/react-native-reanimated-64-hermes.aar +0 -0
  19. package/android/react-native-reanimated-64-jsc.aar +0 -0
  20. package/android/react-native-reanimated-65-hermes.aar +0 -0
  21. package/android/react-native-reanimated-65-jsc.aar +0 -0
  22. package/android/react-native-reanimated-66-hermes.aar +0 -0
  23. package/android/react-native-reanimated-66-jsc.aar +0 -0
  24. package/android/react-native-reanimated-67-hermes.aar +0 -0
  25. package/android/react-native-reanimated-67-jsc.aar +0 -0
  26. package/expo-module.config.json +3 -0
  27. package/ios/LayoutReanimation/REAAnimationsManager.m +64 -19
  28. package/ios/LayoutReanimation/REAUIManager.mm +63 -18
  29. package/ios/Nodes/REAPropsNode.m +1 -1
  30. package/ios/REAEventDispatcher.m +1 -1
  31. package/ios/REAModule.h +0 -2
  32. package/ios/REAModule.m +0 -3
  33. package/ios/REANodesManager.m +1 -0
  34. package/ios/RNGestureHandlerStateManager.h +5 -0
  35. package/ios/native/NativeMethods.h +5 -0
  36. package/ios/native/NativeMethods.mm +8 -1
  37. package/ios/native/NativeProxy.h +1 -0
  38. package/ios/native/NativeProxy.mm +10 -2
  39. package/ios/native/REAInitializer.mm +7 -3
  40. package/lib/src/Animated.js +31 -0
  41. package/lib/{ConfigHelper.js → src/ConfigHelper.js} +0 -0
  42. package/lib/{ReanimatedEventEmitter.js → src/ReanimatedEventEmitter.js} +0 -0
  43. package/lib/{ReanimatedModule.js → src/ReanimatedModule.js} +0 -0
  44. package/lib/{ReanimatedModule.macos.js → src/ReanimatedModule.macos.js} +0 -0
  45. package/lib/{ReanimatedModule.native.js → src/ReanimatedModule.native.js} +0 -0
  46. package/lib/{ReanimatedModule.windows.js → src/ReanimatedModule.windows.js} +0 -0
  47. package/lib/{ReanimatedModuleCompat.js → src/ReanimatedModuleCompat.js} +0 -0
  48. package/lib/{__mocks__ → src/__mocks__}/ReanimatedEventEmitter.js +0 -0
  49. package/lib/{__mocks__ → src/__mocks__}/ReanimatedModule.native.js +0 -0
  50. package/lib/{createAnimatedComponent.js → src/createAnimatedComponent.js} +55 -37
  51. package/lib/src/index.js +31 -0
  52. package/lib/{reanimated1 → src/reanimated1}/Easing.js +0 -0
  53. package/lib/{reanimated1 → src/reanimated1}/SpringConfig.js +0 -0
  54. package/lib/{reanimated1 → src/reanimated1}/Transitioning.js +0 -0
  55. package/lib/{reanimated1 → src/reanimated1}/animations/Animation.js +0 -0
  56. package/lib/{reanimated1 → src/reanimated1}/animations/SpringUtils.js +0 -0
  57. package/lib/{reanimated1 → src/reanimated1}/animations/backwardCompatibleAnimWrapper.js +0 -0
  58. package/lib/{reanimated1 → src/reanimated1}/animations/decay.js +0 -0
  59. package/lib/{reanimated1 → src/reanimated1}/animations/spring.js +0 -0
  60. package/lib/{reanimated1 → src/reanimated1}/animations/timing.js +0 -0
  61. package/lib/{reanimated1 → src/reanimated1}/base.js +0 -0
  62. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedAlways.js +0 -0
  63. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedBezier.js +0 -0
  64. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedBlock.js +0 -0
  65. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCall.js +0 -0
  66. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCallFunc.js +0 -0
  67. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedClock.js +0 -0
  68. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedClockTest.js +0 -0
  69. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCode.js +0 -0
  70. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedConcat.js +0 -0
  71. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCond.js +0 -0
  72. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedDebug.js +0 -0
  73. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedEvent.js +0 -0
  74. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedFunction.js +0 -0
  75. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedNode.js +0 -0
  76. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedOperator.js +0 -0
  77. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedParam.js +0 -0
  78. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedProps.js +0 -0
  79. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedSet.js +0 -0
  80. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedStartClock.js +0 -0
  81. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedStopClock.js +0 -0
  82. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedStyle.js +0 -0
  83. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedTransform.js +0 -0
  84. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedValue.js +0 -0
  85. package/lib/{reanimated1 → src/reanimated1}/core/Core.test.js +1 -1
  86. package/lib/{reanimated1 → src/reanimated1}/core/InternalAnimatedValue.js +0 -0
  87. package/lib/{reanimated1 → src/reanimated1}/core/__mocks__/AnimatedProps.js +0 -0
  88. package/lib/{reanimated1 → src/reanimated1}/core/createEventObjectProxyPolyfill.js +0 -0
  89. package/lib/{reanimated1 → src/reanimated1}/derived/__mocks__/evaluateOnce.js +0 -0
  90. package/lib/{reanimated1 → src/reanimated1}/derived/acc.js +0 -0
  91. package/lib/{reanimated1 → src/reanimated1}/derived/color.js +0 -0
  92. package/lib/{reanimated1 → src/reanimated1}/derived/diff.js +0 -0
  93. package/lib/{reanimated1 → src/reanimated1}/derived/diffClamp.js +0 -0
  94. package/lib/{reanimated1 → src/reanimated1}/derived/evaluateOnce.js +0 -0
  95. package/lib/{reanimated1 → src/reanimated1}/derived/index.js +0 -0
  96. package/lib/{reanimated1 → src/reanimated1}/derived/interpolate.js +0 -0
  97. package/lib/{reanimated1 → src/reanimated1}/derived/interpolateColors.js +0 -0
  98. package/lib/{reanimated1 → src/reanimated1}/derived/onChange.js +0 -0
  99. package/lib/{reanimated1 → src/reanimated1}/derived/useCode.js +0 -0
  100. package/lib/{reanimated1 → src/reanimated1}/index.js +0 -0
  101. package/lib/{reanimated1 → src/reanimated1}/operators.js +0 -0
  102. package/lib/{reanimated1 → src/reanimated1}/useValue.js +0 -0
  103. package/lib/{reanimated1 → src/reanimated1}/val.js +0 -0
  104. package/lib/{reanimated2 → src/reanimated2}/Bezier.js +0 -0
  105. package/lib/{reanimated2 → src/reanimated2}/Colors.js +0 -0
  106. package/lib/{reanimated2 → src/reanimated2}/Easing.js +0 -0
  107. package/lib/{reanimated2 → src/reanimated2}/NativeMethods.js +7 -0
  108. package/lib/{reanimated2 → src/reanimated2}/NativeReanimated/NativeReanimated.js +3 -0
  109. package/lib/{reanimated2 → src/reanimated2}/NativeReanimated/index.js +0 -0
  110. package/lib/{reanimated2 → src/reanimated2}/PlatformChecker.js +0 -0
  111. package/lib/{reanimated2 → src/reanimated2}/PropAdapters.js +0 -0
  112. package/lib/{reanimated2 → src/reanimated2}/UpdateProps.js +1 -1
  113. package/lib/{reanimated2 → src/reanimated2}/ViewDescriptorsSet.js +4 -2
  114. package/lib/{reanimated2 → src/reanimated2}/WorkletEventHandler.js +0 -0
  115. package/lib/{reanimated2 → src/reanimated2}/__mocks__/MutableValue.js +0 -0
  116. package/lib/{reanimated2 → src/reanimated2}/__mocks__/NativeReanimated.js +0 -0
  117. package/lib/{reanimated2 → src/reanimated2}/__mocks__/NativeReanimated.native.js +0 -0
  118. package/lib/{reanimated2 → src/reanimated2}/animation/commonTypes.js +0 -0
  119. package/lib/{reanimated2 → src/reanimated2}/animation/decay.js +0 -0
  120. package/lib/{reanimated2 → src/reanimated2}/animation/delay.js +0 -0
  121. package/lib/{reanimated2 → src/reanimated2}/animation/index.js +0 -0
  122. package/lib/{reanimated2 → src/reanimated2}/animation/repeat.js +0 -0
  123. package/lib/{reanimated2 → src/reanimated2}/animation/sequence.js +0 -0
  124. package/lib/{reanimated2 → src/reanimated2}/animation/spring.js +0 -0
  125. package/lib/{reanimated2 → src/reanimated2}/animation/styleAnimation.js +5 -0
  126. package/lib/{reanimated2 → src/reanimated2}/animation/timing.js +0 -0
  127. package/lib/{reanimated2 → src/reanimated2}/animation/util.js +0 -0
  128. package/lib/{reanimated2 → src/reanimated2}/commonTypes.js +0 -0
  129. package/lib/src/reanimated2/component/FlatList.js +30 -0
  130. package/lib/src/reanimated2/component/WrappedComponents.js +9 -0
  131. package/lib/src/reanimated2/component/index.js +4 -0
  132. package/lib/{reanimated2 → src/reanimated2}/core.js +27 -3
  133. package/lib/{reanimated2 → src/reanimated2}/globals.d.ts +5 -0
  134. package/lib/{reanimated2 → src/reanimated2}/hook/Hooks.js +0 -0
  135. package/lib/{reanimated2 → src/reanimated2}/hook/commonTypes.js +0 -0
  136. package/lib/{reanimated2 → src/reanimated2}/hook/index.js +0 -0
  137. package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedGestureHandler.js +0 -0
  138. package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedReaction.js +0 -0
  139. package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedRef.js +0 -0
  140. package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedScrollHandler.js +0 -0
  141. package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedStyle.js +0 -0
  142. package/lib/{reanimated2 → src/reanimated2}/hook/useDerivedValue.js +0 -0
  143. package/lib/{reanimated2 → src/reanimated2}/hook/useSharedValue.js +0 -0
  144. package/lib/{reanimated2 → src/reanimated2}/hook/utils.js +0 -0
  145. package/lib/{reanimated2 → src/reanimated2}/index.js +0 -0
  146. package/lib/{reanimated2 → src/reanimated2}/interpolation.js +0 -0
  147. package/lib/{reanimated2 → src/reanimated2}/jestUtils.js +0 -0
  148. package/lib/{reanimated2 → src/reanimated2}/js-reanimated/JSReanimated.js +3 -0
  149. package/lib/{reanimated2 → src/reanimated2}/js-reanimated/Mapper.js +4 -1
  150. package/lib/{reanimated2 → src/reanimated2}/js-reanimated/MapperRegistry.js +0 -0
  151. package/lib/{reanimated2 → src/reanimated2}/js-reanimated/MutableValue.js +0 -0
  152. package/lib/{reanimated2 → src/reanimated2}/js-reanimated/index.js +3 -0
  153. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/LayoutAnimationRepository.js +14 -5
  154. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +0 -0
  155. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +0 -0
  156. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/Keyframe.js +0 -0
  157. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/commonTypes.js +0 -0
  158. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/index.js +0 -0
  159. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Bounce.js +0 -0
  160. package/lib/src/reanimated2/layoutReanimation/defaultAnimations/Default.js +36 -0
  161. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Fade.js +0 -0
  162. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Flip.js +8 -8
  163. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Lightspeed.js +0 -0
  164. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Pinwheel.js +0 -0
  165. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Roll.js +0 -0
  166. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Rotate.js +16 -16
  167. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Slide.js +16 -16
  168. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Stretch.js +0 -0
  169. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Zoom.js +4 -4
  170. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/index.js +0 -0
  171. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/CurvedTransition.js +20 -8
  172. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/EntryExitTransition.js +3 -3
  173. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/FadingTransition.js +8 -8
  174. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/JumpingTransition.js +10 -10
  175. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/LinearTransition.js +8 -8
  176. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/SequencedTransition.js +8 -8
  177. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/index.js +0 -0
  178. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/index.js +0 -0
  179. package/lib/{reanimated2 → src/reanimated2}/mock.js +0 -0
  180. package/lib/{reanimated2 → src/reanimated2}/platform-specific/RNRenderer.js +0 -0
  181. package/lib/{reanimated2 → src/reanimated2}/platform-specific/RNRenderer.web.js +0 -0
  182. package/lib/{reanimated2 → src/reanimated2}/utils.js +0 -0
  183. package/lib/{setAndForwardRef.js → src/setAndForwardRef.js} +0 -0
  184. package/mock.js +1 -1
  185. package/package.json +4 -3
  186. package/plugin.js +10 -3
  187. package/react-native-reanimated.d.ts +40 -23
  188. package/src/Animated.js +11 -5
  189. package/src/createAnimatedComponent.tsx +86 -43
  190. package/src/reanimated1/core/Core.test.js +1 -1
  191. package/src/reanimated2/NativeMethods.ts +13 -1
  192. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +4 -0
  193. package/src/reanimated2/UpdateProps.ts +1 -1
  194. package/src/reanimated2/ViewDescriptorsSet.ts +6 -2
  195. package/src/reanimated2/animation/styleAnimation.ts +9 -0
  196. package/src/reanimated2/component/FlatList.tsx +44 -0
  197. package/src/reanimated2/component/WrappedComponents.ts +11 -0
  198. package/src/reanimated2/component/index.ts +9 -0
  199. package/src/reanimated2/core.ts +38 -3
  200. package/src/reanimated2/globals.d.ts +5 -0
  201. package/src/reanimated2/js-reanimated/JSReanimated.ts +6 -0
  202. package/src/reanimated2/js-reanimated/Mapper.ts +3 -1
  203. package/src/reanimated2/js-reanimated/index.ts +5 -0
  204. package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +18 -5
  205. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +39 -20
  206. package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +5 -1
  207. package/src/reanimated2/layoutReanimation/defaultAnimations/Default.ts +21 -15
  208. package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +29 -24
  209. package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +61 -34
  210. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +49 -34
  211. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +17 -12
  212. package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +20 -8
  213. package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +9 -9
  214. package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +8 -8
  215. package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +20 -14
  216. package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +14 -8
  217. package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +24 -12
  218. package/lib/Animated.js +0 -25
  219. package/lib/index.js +0 -25
  220. package/lib/reanimated2/layoutReanimation/defaultAnimations/Default.js +0 -36
@@ -1,14 +1,17 @@
1
1
  #import "REAUIManager.h"
2
2
  #import <Foundation/Foundation.h>
3
- #import "RCTComponentData.h"
4
- #import "RCTLayoutAnimation.h"
5
- #import "RCTLayoutAnimationGroup.h"
6
- #import "RCTRootShadowView.h"
7
- #import "RCTRootViewInternal.h"
8
- #import "RCTUIManagerObserverCoordinator.h"
3
+ #include "FeaturesConfig.h"
9
4
  #import "REAIOSScheduler.h"
10
5
  #include "Scheduler.h"
11
6
 
7
+ #import <React/RCTComponentData.h>
8
+ #import <React/RCTLayoutAnimation.h>
9
+ #import <React/RCTLayoutAnimationGroup.h>
10
+ #import <React/RCTModalHostView.h>
11
+ #import <React/RCTRootShadowView.h>
12
+ #import <React/RCTRootViewInternal.h>
13
+ #import <React/RCTUIManagerObserverCoordinator.h>
14
+
12
15
  #if __has_include(<RNScreens/RNSScreen.h>)
13
16
  #import <RNScreens/RNSScreen.h>
14
17
  #endif
@@ -70,16 +73,29 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
70
73
  removeAtIndices:(NSArray<NSNumber *> *)removeAtIndices
71
74
  registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)registry
72
75
  {
76
+ if (!reanimated::FeaturesConfig::isLayoutAnimationEnabled()) {
77
+ [super _manageChildren:containerTag
78
+ moveFromIndices:moveFromIndices
79
+ moveToIndices:moveToIndices
80
+ addChildReactTags:addChildReactTags
81
+ addAtIndices:addAtIndices
82
+ removeAtIndices:removeAtIndices
83
+ registry:registry];
84
+ return;
85
+ }
86
+
87
+ // Reanimated changes /start
73
88
  BOOL isUIViewRegistry = ((id)registry == (id)[self valueForKey:@"_viewRegistry"]);
74
89
  id<RCTComponent> container;
75
- NSArray<id<RCTComponent>> *permanentlyRemovedChildren;
90
+ NSMutableArray<id<RCTComponent>> *permanentlyRemovedChildren;
76
91
  if (isUIViewRegistry) {
77
92
  container = registry[containerTag];
78
93
  for (id<RCTComponent> toRemoveChild in _toBeRemovedRegister[containerTag]) {
79
94
  [container removeReactSubview:toRemoveChild];
80
95
  }
81
96
 
82
- permanentlyRemovedChildren = [super _childrenToRemoveFromContainer:container atIndices:removeAtIndices];
97
+ permanentlyRemovedChildren = (NSMutableArray *)[super _childrenToRemoveFromContainer:container
98
+ atIndices:removeAtIndices];
83
99
  if (permanentlyRemovedChildren != nil) {
84
100
  for (id<RCTComponent> permanentlyRemovedChild in permanentlyRemovedChildren) {
85
101
  if (_toBeRemovedRegister[containerTag] == nil) {
@@ -89,6 +105,7 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
89
105
  }
90
106
  }
91
107
  }
108
+ // Reanimated changes /end
92
109
 
93
110
  [super _manageChildren:containerTag
94
111
  moveFromIndices:moveFromIndices
@@ -98,6 +115,7 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
98
115
  removeAtIndices:removeAtIndices
99
116
  registry:registry];
100
117
 
118
+ // Reanimated changes /start
101
119
  if (isUIViewRegistry) {
102
120
  NSMutableDictionary<NSNumber *, id<RCTComponent>> *viewRegistry = [self valueForKey:@"_viewRegistry"];
103
121
  for (id<RCTComponent> toRemoveChild in _toBeRemovedRegister[containerTag]) {
@@ -105,14 +123,27 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
105
123
  if (lastIndex < 0) {
106
124
  lastIndex = 0;
107
125
  }
108
- [container insertReactSubview:toRemoveChild atIndex:lastIndex];
109
- viewRegistry[toRemoveChild.reactTag] = toRemoveChild;
126
+ if ([toRemoveChild isKindOfClass:[RCTModalHostView class]]
127
+ #if __has_include(<RNScreens/RNSScreen.h>)
128
+ || ([toRemoveChild isKindOfClass:[RNSScreenView class]])
129
+ #endif
130
+ ) {
131
+ // we don't want layout animations when removing modals or Screens of native-stack since it brings buggy
132
+ // behavior
133
+ [_toBeRemovedRegister[container.reactTag] removeObject:toRemoveChild];
134
+ [permanentlyRemovedChildren removeObject:toRemoveChild];
135
+
136
+ } else {
137
+ [container insertReactSubview:toRemoveChild atIndex:lastIndex];
138
+ viewRegistry[toRemoveChild.reactTag] = toRemoveChild;
139
+ }
110
140
  }
111
141
 
112
142
  for (UIView *removedChild in permanentlyRemovedChildren) {
113
143
  [self callAnimationForTree:removedChild parentTag:containerTag];
114
144
  }
115
145
  }
146
+ // Reanimated changes /end
116
147
  }
117
148
 
118
149
  - (void)callAnimationForTree:(UIView *)view parentTag:(NSNumber *)parentTag
@@ -239,7 +270,13 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
239
270
  view.hidden = isHidden;
240
271
  }
241
272
 
242
- REASnapshot *snapshotBefore = [[REASnapshot alloc] init:view];
273
+ // Reanimated changes /start
274
+ REASnapshot *snapshotBefore;
275
+ if (reanimated::FeaturesConfig::isLayoutAnimationEnabled()) {
276
+ snapshotBefore = [[REASnapshot alloc] init:view];
277
+ }
278
+ // Reanimated changes /end
279
+
243
280
  if (creatingLayoutAnimation) {
244
281
  // Animate view creation
245
282
  [view reactSetFrame:frame];
@@ -285,18 +322,23 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
285
322
  completion(YES);
286
323
  }
287
324
 
288
- if (isNew) {
289
- REASnapshot *snapshot = [[REASnapshot alloc] init:view];
290
- [_animationsManager onViewCreate:view after:snapshot];
291
- } else {
292
- REASnapshot *snapshotAfter = [[REASnapshot alloc] init:view];
293
- [_animationsManager onViewUpdate:view before:snapshotBefore after:snapshotAfter];
325
+ // Reanimated changes /start
326
+ if (reanimated::FeaturesConfig::isLayoutAnimationEnabled()) {
327
+ if (isNew) {
328
+ REASnapshot *snapshot = [[REASnapshot alloc] init:view];
329
+ [_animationsManager onViewCreate:view after:snapshot];
330
+ } else {
331
+ REASnapshot *snapshotAfter = [[REASnapshot alloc] init:view];
332
+ [_animationsManager onViewUpdate:view before:snapshotBefore after:snapshotAfter];
333
+ }
294
334
  }
295
335
  }
296
336
 
297
337
  [_animationsManager removeLeftovers];
298
338
  // Clean up
339
+ // uiManager->_layoutAnimationGroup = nil;
299
340
  [uiManager setValue:nil forKey:@"_layoutAnimationGroup"];
341
+ // Reanimated changes /end
300
342
  };
301
343
  }
302
344
 
@@ -331,7 +373,10 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
331
373
  NSMutableDictionary<NSNumber *, id<RCTComponent>> *viewRegistry = [self valueForKey:@"_viewRegistry"];
332
374
  [view.reactSuperview removeReactSubview:view];
333
375
  id<RCTComponent> parentView = viewRegistry[tag];
334
- [parentView removeReactSubview:view];
376
+ @try {
377
+ [parentView removeReactSubview:view];
378
+ } @catch (id anException) {
379
+ }
335
380
  #if __has_include(<RNScreens/RNSScreen.h>)
336
381
  if ([view isKindOfClass:[RNSScreenView class]]) {
337
382
  [parentView didUpdateReactSubviews];
@@ -4,9 +4,9 @@
4
4
  #import "REANodesManager.h"
5
5
  #import "REAStyleNode.h"
6
6
 
7
+ #import <React/RCTComponentData.h>
7
8
  #import <React/RCTLog.h>
8
9
  #import <React/RCTUIManager.h>
9
- #import "React/RCTComponentData.h"
10
10
 
11
11
  @implementation REAPropsNode {
12
12
  NSNumber *_connectedViewTag;
@@ -7,7 +7,7 @@
7
7
 
8
8
  - (void)sendEvent:(id<RCTEvent>)event
9
9
  {
10
- [[_bridge_reanimated moduleForName:@"ReanimatedModule"] eventDispatcherWillDispatchEvent:event];
10
+ [[[self bridge] moduleForName:@"ReanimatedModule"] eventDispatcherWillDispatchEvent:event];
11
11
  [super sendEvent:event];
12
12
  }
13
13
 
package/ios/REAModule.h CHANGED
@@ -7,8 +7,6 @@
7
7
 
8
8
  #import "REAValueNode.h"
9
9
 
10
- extern RCTBridge *_bridge_reanimated;
11
-
12
10
  @interface REAModule : RCTEventEmitter <RCTBridgeModule, RCTEventDispatcherObserver, RCTUIManagerObserver>
13
11
 
14
12
  @property (nonatomic, readonly) REANodesManager *nodesManager;
package/ios/REAModule.m CHANGED
@@ -6,8 +6,6 @@
6
6
 
7
7
  typedef void (^AnimatedOperation)(REANodesManager *nodesManager);
8
8
 
9
- RCTBridge *_bridge_reanimated = nil;
10
-
11
9
  @implementation REAModule {
12
10
  NSMutableArray<AnimatedOperation> *_operations;
13
11
  REATransitionManager *_transitionManager;
@@ -17,7 +15,6 @@ RCT_EXPORT_MODULE(ReanimatedModule);
17
15
 
18
16
  - (void)invalidate
19
17
  {
20
- _bridge_reanimated = nil;
21
18
  _transitionManager = nil;
22
19
  [_nodesManager invalidate];
23
20
  [self.bridge.uiManager.observerCoordinator removeObserver:self];
@@ -116,6 +116,7 @@
116
116
  }
117
117
 
118
118
  _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(onAnimationFrame:)];
119
+ _displayLink.preferredFramesPerSecond = 120; // will fallback to 60 fps for devices without Pro Motion display
119
120
  [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
120
121
  [_displayLink setPaused:true];
121
122
  return self;
@@ -0,0 +1,5 @@
1
+ @protocol RNGestureHandlerStateManager
2
+
3
+ - (void)setGestureState:(int)state forHandler:(int)handlerTag;
4
+
5
+ @end
@@ -5,6 +5,7 @@
5
5
  #include <utility>
6
6
  #include <vector>
7
7
  #import <vector>
8
+ #import "RNGestureHandlerStateManager.h"
8
9
 
9
10
  namespace reanimated {
10
11
 
@@ -17,5 +18,9 @@ void scrollTo(
17
18
  double x,
18
19
  double y,
19
20
  bool animated);
21
+ void setGestureState(
22
+ id<RNGestureHandlerStateManager> gestureHandlerStateManager,
23
+ int handlerTag,
24
+ int newState);
20
25
 
21
26
  } // namespace reanimated
@@ -18,7 +18,7 @@ std::vector<std::pair<std::string, double>> measure(int viewTag, RCTUIManager *u
18
18
  rootView = rootView.superview;
19
19
  }
20
20
 
21
- if (rootView == nil || (![rootView isReactRootView])) {
21
+ if (rootView == nil) {
22
22
  return std::vector<std::pair<std::string, double>>(1, std::make_pair("x", -1234567.0));
23
23
  }
24
24
 
@@ -44,4 +44,11 @@ void scrollTo(int scrollViewTag, RCTUIManager *uiManager, double x, double y, bo
44
44
  [scrollView scrollToOffset:(CGPoint){(CGFloat)x, (CGFloat)y} animated:animated];
45
45
  }
46
46
 
47
+ void setGestureState(id<RNGestureHandlerStateManager> gestureHandlerStateManager, int handlerTag, int newState)
48
+ {
49
+ if (gestureHandlerStateManager != nil) {
50
+ [gestureHandlerStateManager setGestureState:newState forHandler:handlerTag];
51
+ }
52
+ }
53
+
47
54
  }
@@ -7,6 +7,7 @@
7
7
  namespace reanimated {
8
8
 
9
9
  std::shared_ptr<reanimated::NativeReanimatedModule> createReanimatedModule(
10
+ RCTBridge *bridge,
10
11
  std::shared_ptr<facebook::react::CallInvoker> jsInvoker);
11
12
 
12
13
  }
@@ -12,6 +12,7 @@
12
12
  #import "REAModule.h"
13
13
  #import "REANodesManager.h"
14
14
  #import "REAUIManager.h"
15
+ #import "RNGestureHandlerStateManager.h"
15
16
 
16
17
  #if __has_include(<reacthermes/HermesExecutorFactory.h>)
17
18
  #import <reacthermes/HermesExecutorFactory.h>
@@ -86,9 +87,10 @@ static id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &v
86
87
  throw std::runtime_error("Unsupported jsi::jsi::Value kind");
87
88
  }
88
89
 
89
- std::shared_ptr<NativeReanimatedModule> createReanimatedModule(std::shared_ptr<CallInvoker> jsInvoker)
90
+ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
91
+ RCTBridge *bridge,
92
+ std::shared_ptr<CallInvoker> jsInvoker)
90
93
  {
91
- RCTBridge *bridge = _bridge_reanimated;
92
94
  REAModule *reanimatedModule = [bridge moduleForClass:[REAModule class]];
93
95
 
94
96
  auto propUpdater = [reanimatedModule](
@@ -111,6 +113,11 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(std::shared_ptr<C
111
113
  scrollTo(viewTag, uiManager, x, y, animated);
112
114
  };
113
115
 
116
+ id<RNGestureHandlerStateManager> gestureHandlerStateManager = [bridge moduleForName:@"RNGestureHandlerModule"];
117
+ auto setGestureStateFunction = [gestureHandlerStateManager](int handlerTag, int newState) {
118
+ setGestureState(gestureHandlerStateManager, handlerTag, newState);
119
+ };
120
+
114
121
  auto propObtainer = [reanimatedModule](
115
122
  jsi::Runtime &rt, const int viewTag, const jsi::String &propName) -> jsi::Value {
116
123
  NSString *propNameConverted = [NSString stringWithFormat:@"%s", propName.utf8(rt).c_str()];
@@ -223,6 +230,7 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(std::shared_ptr<C
223
230
  scrollToFunction,
224
231
  measuringFunction,
225
232
  getCurrentTime,
233
+ setGestureStateFunction,
226
234
  };
227
235
 
228
236
  module = std::make_shared<NativeReanimatedModule>(
@@ -35,17 +35,21 @@ JSIExecutor::RuntimeInstaller REAJSIExecutorRuntimeInstaller(
35
35
  [eventDispatcher setBridge:bridge];
36
36
  #endif
37
37
  [bridge updateModuleWithInstance:eventDispatcher];
38
- _bridge_reanimated = bridge;
39
38
  const auto runtimeInstaller = [bridge, runtimeInstallerToWrap](facebook::jsi::Runtime &runtime) {
40
39
  if (!bridge) {
41
40
  return;
42
41
  }
43
42
  #if RNVERSION >= 63
44
- auto reanimatedModule = reanimated::createReanimatedModule(bridge.jsCallInvoker);
43
+ auto reanimatedModule = reanimated::createReanimatedModule(bridge, bridge.jsCallInvoker);
45
44
  #else
46
45
  auto callInvoker = std::make_shared<react::BridgeJSCallInvoker>(bridge.reactInstance);
47
- auto reanimatedModule = reanimated::createReanimatedModule(callInvoker);
46
+ auto reanimatedModule = reanimated::createReanimatedModule(bridge, callInvoker);
48
47
  #endif
48
+ runtime.global().setProperty(
49
+ runtime,
50
+ "_WORKLET_RUNTIME",
51
+ static_cast<double>(reinterpret_cast<std::uintptr_t>(reanimatedModule->runtime.get())));
52
+
49
53
  runtime.global().setProperty(
50
54
  runtime,
51
55
  jsi::PropNameID::forAscii(runtime, "__reanimatedModuleProxy"),
@@ -0,0 +1,31 @@
1
+ import { LogBox } from 'react-native';
2
+ import createAnimatedComponent from './createAnimatedComponent';
3
+ import {
4
+ addWhitelistedNativeProps,
5
+ addWhitelistedUIProps,
6
+ } from './ConfigHelper';
7
+ import * as reanimated1 from './reanimated1';
8
+ import ReanimatedComponents from './reanimated2/component';
9
+
10
+ const Animated = {
11
+ // components
12
+ ...ReanimatedComponents,
13
+ createAnimatedComponent,
14
+ // configuration
15
+ addWhitelistedNativeProps,
16
+ addWhitelistedUIProps,
17
+ // reanimated 1
18
+ ...reanimated1,
19
+ };
20
+
21
+ export * from './reanimated2';
22
+ export * from './reanimated1';
23
+ export default Animated;
24
+
25
+ // I think we can ignore this message as long as Gesture Handler doesn't
26
+ // try to load the Reanimated module. I figured it should be here instead of
27
+ // RNGH because this prevents the message from being displayed for all
28
+ // versions of RNGH.
29
+ LogBox.ignoreLogs([
30
+ 'RCTBridge required dispatch_sync to load RNGestureHandlerModule. This may lead to deadlocks',
31
+ ]);
File without changes
@@ -15,9 +15,9 @@ import './reanimated2/layoutReanimation/LayoutAnimationRepository';
15
15
  import invariant from 'invariant';
16
16
  import { adaptViewConfig } from './ConfigHelper';
17
17
  import { RNRenderer } from './reanimated2/platform-specific/RNRenderer';
18
- import { makeMutable, runOnUI } from './reanimated2/core';
18
+ import { makeMutable, runOnUI, enableLayoutAnimations, } from './reanimated2/core';
19
19
  import { DefaultEntering, DefaultExiting, DefaultLayout, } from './reanimated2/layoutReanimation/defaultAnimations/Default';
20
- import { isJest, isChromeDebugger } from './reanimated2/PlatformChecker';
20
+ import { isJest, isChromeDebugger, shouldBeUseWeb, } from './reanimated2/PlatformChecker';
21
21
  import { initialUpdaterRun } from './reanimated2/animation';
22
22
  const NODE_MAPPING = new Map();
23
23
  function listener(data) {
@@ -58,6 +58,15 @@ function flattenArray(array) {
58
58
  _flattenArray(array);
59
59
  return resultArr;
60
60
  }
61
+ function onlyAnimatedStyles(styles) {
62
+ return styles.filter((style) => style === null || style === void 0 ? void 0 : style.viewDescriptors);
63
+ }
64
+ function isSameAnimatedStyle(style1, style2) {
65
+ // We cannot use equality check to compare useAnimatedStyle outputs directly.
66
+ // Instead, we can compare its viewsRefs.
67
+ return (style1 === null || style1 === void 0 ? void 0 : style1.viewsRef) === (style2 === null || style2 === void 0 ? void 0 : style2.viewsRef);
68
+ }
69
+ const isSameAnimatedProps = isSameAnimatedStyle;
61
70
  const has = (key, x) => {
62
71
  if (typeof x === 'function' || typeof x === 'object') {
63
72
  if (x === null || x === undefined) {
@@ -111,6 +120,9 @@ export default function createAnimatedComponent(Component, options) {
111
120
  const tag = findNodeHandle(ref);
112
121
  if ((this.props.layout || this.props.entering || this.props.exiting) &&
113
122
  tag != null) {
123
+ if (!shouldBeUseWeb()) {
124
+ enableLayoutAnimations(true, false);
125
+ }
114
126
  let layout = this.props.layout ? this.props.layout : DefaultLayout;
115
127
  let entering = this.props.entering
116
128
  ? this.props.entering
@@ -213,9 +225,7 @@ export default function createAnimatedComponent(Component, options) {
213
225
  }
214
226
  else if (this._viewTag !== -1 && this._styles !== null) {
215
227
  for (const style of this._styles) {
216
- if (style === null || style === void 0 ? void 0 : style.viewDescriptors) {
217
- style.viewDescriptors.remove(this._viewTag);
218
- }
228
+ style.viewDescriptors.remove(this._viewTag);
219
229
  }
220
230
  if ((_a = this.props.animatedProps) === null || _a === void 0 ? void 0 : _a.viewDescriptors) {
221
231
  this.props.animatedProps.viewDescriptors.remove(this._viewTag);
@@ -309,8 +319,13 @@ export default function createAnimatedComponent(Component, options) {
309
319
  }
310
320
  _attachAnimatedStyles() {
311
321
  var _a, _b, _c;
312
- const styles = flattenArray((_a = this.props.style) !== null && _a !== void 0 ? _a : []);
322
+ const styles = this.props.style
323
+ ? onlyAnimatedStyles(flattenArray(this.props.style))
324
+ : [];
325
+ const prevStyles = this._styles;
313
326
  this._styles = styles;
327
+ const prevAnimatedProps = this._animatedProps;
328
+ this._animatedProps = this.props.animatedProps;
314
329
  let viewTag;
315
330
  let viewName;
316
331
  if (Platform.OS === 'web') {
@@ -329,30 +344,48 @@ export default function createAnimatedComponent(Component, options) {
329
344
  * RN uses viewConfig for components for storing different properties of the component(example: https://github.com/facebook/react-native/blob/master/Libraries/Components/ScrollView/ScrollViewViewConfig.js#L16).
330
345
  * The name we're looking for is in the field named uiViewClassName.
331
346
  */
332
- viewName = (_b = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.viewConfig) === null || _b === void 0 ? void 0 : _b.uiViewClassName;
347
+ viewName = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.viewConfig) === null || _a === void 0 ? void 0 : _a.uiViewClassName;
333
348
  // update UI props whitelist for this view
334
- if (hostInstance &&
335
- this._hasReanimated2Props(styles) &&
336
- hostInstance.viewConfig) {
349
+ const hasReanimated2Props = ((_b = this.props.animatedProps) === null || _b === void 0 ? void 0 : _b.viewDescriptors) || styles.length;
350
+ if (hasReanimated2Props && (hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.viewConfig)) {
337
351
  adaptViewConfig(hostInstance.viewConfig);
338
352
  }
339
353
  }
340
354
  this._viewTag = viewTag;
341
- styles.forEach((style) => {
342
- if (style === null || style === void 0 ? void 0 : style.viewDescriptors) {
343
- style.viewDescriptors.add({ tag: viewTag, name: viewName });
344
- if (isJest()) {
345
- /**
346
- * We need to connect Jest's TestObject instance whose contains just props object
347
- * with the updateProps() function where we update the properties of the component.
348
- * We can't update props object directly because TestObject contains a copy of props - look at render function:
349
- * const props = this._filterNonAnimatedProps(this.props);
350
- */
351
- this.animatedStyle.value = Object.assign(Object.assign({}, this.animatedStyle.value), style.initial.value);
352
- style.animatedStyle.current = this.animatedStyle;
355
+ // remove old styles
356
+ if (prevStyles) {
357
+ // in most of the cases, views have only a single animated style and it remains unchanged
358
+ const hasOneSameStyle = styles.length === 1 &&
359
+ prevStyles.length === 1 &&
360
+ isSameAnimatedStyle(styles[0], prevStyles[0]);
361
+ if (!hasOneSameStyle) {
362
+ // otherwise, remove each style that is not present in new styles
363
+ for (const prevStyle of prevStyles) {
364
+ const isPresent = styles.some((style) => isSameAnimatedStyle(style, prevStyle));
365
+ if (!isPresent) {
366
+ prevStyle.viewDescriptors.remove(viewTag);
367
+ }
353
368
  }
354
369
  }
370
+ }
371
+ styles.forEach((style) => {
372
+ style.viewDescriptors.add({ tag: viewTag, name: viewName });
373
+ if (isJest()) {
374
+ /**
375
+ * We need to connect Jest's TestObject instance whose contains just props object
376
+ * with the updateProps() function where we update the properties of the component.
377
+ * We can't update props object directly because TestObject contains a copy of props - look at render function:
378
+ * const props = this._filterNonAnimatedProps(this.props);
379
+ */
380
+ this.animatedStyle.value = Object.assign(Object.assign({}, this.animatedStyle.value), style.initial.value);
381
+ style.animatedStyle.current = this.animatedStyle;
382
+ }
355
383
  });
384
+ // detach old animatedProps
385
+ if (prevAnimatedProps &&
386
+ !isSameAnimatedProps(prevAnimatedProps, this.props.animatedProps)) {
387
+ prevAnimatedProps.viewDescriptors.remove(viewTag);
388
+ }
356
389
  // attach animatedProps property
357
390
  if ((_c = this.props.animatedProps) === null || _c === void 0 ? void 0 : _c.viewDescriptors) {
358
391
  this.props.animatedProps.viewDescriptors.add({
@@ -363,21 +396,6 @@ export default function createAnimatedComponent(Component, options) {
363
396
  });
364
397
  }
365
398
  }
366
- _hasReanimated2Props(flattenStyles) {
367
- var _a;
368
- if ((_a = this.props.animatedProps) === null || _a === void 0 ? void 0 : _a.viewDescriptors) {
369
- return true;
370
- }
371
- if (this.props.style) {
372
- for (const style of flattenStyles) {
373
- // eslint-disable-next-line no-prototype-builtins
374
- if (style === null || style === void 0 ? void 0 : style.hasOwnProperty('viewDescriptors')) {
375
- return true;
376
- }
377
- }
378
- }
379
- return false;
380
- }
381
399
  _detachPropUpdater() {
382
400
  const viewTag = findNodeHandle(this);
383
401
  NODE_MAPPING.delete(viewTag);
@@ -0,0 +1,31 @@
1
+ import { LogBox } from 'react-native';
2
+ import createAnimatedComponent from './createAnimatedComponent';
3
+ import {
4
+ addWhitelistedNativeProps,
5
+ addWhitelistedUIProps,
6
+ } from './ConfigHelper';
7
+ import * as reanimated1 from './reanimated1';
8
+ import ReanimatedComponents from './reanimated2/component';
9
+
10
+ const Animated = {
11
+ // components
12
+ ...ReanimatedComponents,
13
+ createAnimatedComponent,
14
+ // configuration
15
+ addWhitelistedNativeProps,
16
+ addWhitelistedUIProps,
17
+ // reanimated 1
18
+ ...reanimated1,
19
+ };
20
+
21
+ export * from './reanimated2';
22
+ export * from './reanimated1';
23
+ export default Animated;
24
+
25
+ // I think we can ignore this message as long as Gesture Handler doesn't
26
+ // try to load the Reanimated module. I figured it should be here instead of
27
+ // RNGH because this prevents the message from being displayed for all
28
+ // versions of RNGH.
29
+ LogBox.ignoreLogs([
30
+ 'RCTBridge required dispatch_sync to load RNGestureHandlerModule. This may lead to deadlocks',
31
+ ]);
File without changes
File without changes