react-native-reanimated 3.8.0 → 3.9.0-layout-animation-experimental

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 (423) hide show
  1. package/Common/cpp/Fabric/ShadowTreeCloner.cpp +5 -2
  2. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +42 -32
  3. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +5 -7
  4. package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp +565 -0
  5. package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.h +74 -0
  6. package/Common/cpp/LayoutAnimations/LayoutAnimationsUtils.h +140 -0
  7. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +216 -58
  8. package/Common/cpp/NativeModules/NativeReanimatedModule.h +32 -11
  9. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +2 -17
  10. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +6 -8
  11. package/Common/cpp/ReanimatedRuntime/RNRuntimeDecorator.cpp +3 -0
  12. package/Common/cpp/ReanimatedRuntime/WorkletRuntime.cpp +3 -4
  13. package/Common/cpp/ReanimatedRuntime/WorkletRuntimeDecorator.cpp +8 -3
  14. package/Common/cpp/SharedItems/Shareables.cpp +31 -5
  15. package/Common/cpp/SharedItems/Shareables.h +18 -2
  16. package/Common/cpp/Tools/JSScheduler.cpp +29 -5
  17. package/Common/cpp/Tools/JSScheduler.h +21 -4
  18. package/Common/cpp/Tools/PlatformDepMethodsHolder.h +6 -2
  19. package/Common/cpp/Tools/UIRuntimeDecorator.cpp +6 -0
  20. package/Common/cpp/Tools/UIRuntimeDecorator.h +1 -0
  21. package/android/CMakeLists.txt +3 -0
  22. package/android/build.gradle +17 -5
  23. package/android/src/main/cpp/NativeProxy.cpp +77 -12
  24. package/android/src/main/cpp/NativeProxy.h +35 -1
  25. package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +58 -19
  26. package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +7 -2
  27. package/android/src/{reactNativeVersionPatch/ReanimatedUIManager/latest → main/java}/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +5 -5
  28. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +10 -6
  29. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +18 -1
  30. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +105 -17
  31. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +2 -1
  32. package/android/src/paper/java/com/swmansion/reanimated/NativeReanimatedModuleSpec.java +37 -0
  33. package/android/src/{main/java/com/swmansion/reanimated → reactNativeVersionPatch/ReanimatedUIManager/73/com/swmansion}/ReanimatedModule.java +4 -3
  34. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/{70 → 73}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +1 -22
  35. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedModule.java +176 -0
  36. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -26
  37. package/android/src/{fabric/java → reactNativeVersionPatch/RuntimeExecutor/73}/com/swmansion/reanimated/NativeProxy.java +16 -4
  38. package/android/src/reactNativeVersionPatch/RuntimeExecutor/latest/com/swmansion/reanimated/NativeProxy.java +143 -0
  39. package/apple/LayoutReanimation/REAAnimationsManager.h +3 -0
  40. package/apple/LayoutReanimation/REAAnimationsManager.m +11 -0
  41. package/apple/LayoutReanimation/REASharedTransitionManager.m +99 -23
  42. package/apple/LayoutReanimation/REASnapshot.h +1 -0
  43. package/apple/LayoutReanimation/REASnapshot.m +78 -37
  44. package/apple/REAModule.h +22 -2
  45. package/apple/REAModule.mm +97 -46
  46. package/apple/REANodesManager.h +3 -3
  47. package/apple/REANodesManager.mm +46 -22
  48. package/apple/native/NativeProxy.h +28 -2
  49. package/apple/native/NativeProxy.mm +65 -195
  50. package/apple/native/PlatformDepMethodsHolderImpl.h +59 -0
  51. package/apple/native/PlatformDepMethodsHolderImpl.mm +429 -0
  52. package/apple/sensor/ReanimatedSensor.m +5 -5
  53. package/lib/module/Animated.js.map +1 -1
  54. package/lib/module/ConfigHelper.js +1 -1
  55. package/lib/module/ConfigHelper.js.map +1 -1
  56. package/lib/module/animationBuilder.js +1 -0
  57. package/lib/module/animationBuilder.js.map +1 -1
  58. package/lib/module/createAnimatedComponent/InlinePropManager.js +4 -4
  59. package/lib/module/createAnimatedComponent/InlinePropManager.js.map +1 -1
  60. package/lib/module/createAnimatedComponent/JSPropsUpdater.js +9 -6
  61. package/lib/module/createAnimatedComponent/JSPropsUpdater.js.map +1 -1
  62. package/lib/module/createAnimatedComponent/JSPropsUpdater.web.js +11 -0
  63. package/lib/module/createAnimatedComponent/JSPropsUpdater.web.js.map +1 -0
  64. package/lib/module/createAnimatedComponent/PropsFilter.js +25 -9
  65. package/lib/module/createAnimatedComponent/PropsFilter.js.map +1 -1
  66. package/lib/module/createAnimatedComponent/commonTypes.js.map +1 -1
  67. package/lib/module/createAnimatedComponent/createAnimatedComponent.js +83 -52
  68. package/lib/module/createAnimatedComponent/createAnimatedComponent.js.map +1 -1
  69. package/lib/module/createAnimatedComponent/getViewInfo.js +37 -0
  70. package/lib/module/createAnimatedComponent/getViewInfo.js.map +1 -0
  71. package/lib/module/createAnimatedComponent/index.js.map +1 -1
  72. package/lib/module/createAnimatedComponent/setAndForwardRef.js +4 -5
  73. package/lib/module/createAnimatedComponent/setAndForwardRef.js.map +1 -1
  74. package/lib/module/createAnimatedComponent/utils.js.map +1 -1
  75. package/lib/module/index.js.map +1 -1
  76. package/lib/module/index.web.js +1 -2
  77. package/lib/module/index.web.js.map +1 -1
  78. package/lib/module/mock.js +12 -12
  79. package/lib/module/mock.js.map +1 -1
  80. package/lib/module/propsAllowlists.js.map +1 -1
  81. package/lib/module/reanimated2/Bezier.js.map +1 -1
  82. package/lib/module/reanimated2/Colors.js +4 -11
  83. package/lib/module/reanimated2/Colors.js.map +1 -1
  84. package/lib/module/reanimated2/Easing.js +3 -7
  85. package/lib/module/reanimated2/Easing.js.map +1 -1
  86. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +16 -13
  87. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  88. package/lib/module/reanimated2/NativeReanimated/index.js.map +1 -1
  89. package/lib/module/reanimated2/NativeReanimated/index.web.js.map +1 -1
  90. package/lib/module/reanimated2/PlatformChecker.js +2 -1
  91. package/lib/module/reanimated2/PlatformChecker.js.map +1 -1
  92. package/lib/module/reanimated2/PropAdapters.js +1 -1
  93. package/lib/module/reanimated2/PropAdapters.js.map +1 -1
  94. package/lib/module/reanimated2/PropsRegistry.js +1 -2
  95. package/lib/module/reanimated2/PropsRegistry.js.map +1 -1
  96. package/lib/module/reanimated2/Sensor.js +2 -2
  97. package/lib/module/reanimated2/Sensor.js.map +1 -1
  98. package/lib/module/reanimated2/SensorContainer.js +2 -2
  99. package/lib/module/reanimated2/SensorContainer.js.map +1 -1
  100. package/lib/module/reanimated2/UpdateLayoutAnimations.js +30 -8
  101. package/lib/module/reanimated2/UpdateLayoutAnimations.js.map +1 -1
  102. package/lib/module/reanimated2/UpdateProps.js.map +1 -1
  103. package/lib/module/reanimated2/ViewDescriptorsSet.js.map +1 -1
  104. package/lib/module/reanimated2/WorkletEventHandler.js +74 -31
  105. package/lib/module/reanimated2/WorkletEventHandler.js.map +1 -1
  106. package/lib/module/reanimated2/animation/clamp.js.map +1 -1
  107. package/lib/module/reanimated2/animation/commonTypes.js.map +1 -1
  108. package/lib/module/reanimated2/animation/decay/decay.js.map +1 -1
  109. package/lib/module/reanimated2/animation/decay/index.js.map +1 -1
  110. package/lib/module/reanimated2/animation/decay/rigidDecay.js.map +1 -1
  111. package/lib/module/reanimated2/animation/decay/rubberBandDecay.js.map +1 -1
  112. package/lib/module/reanimated2/animation/decay/utils.js.map +1 -1
  113. package/lib/module/reanimated2/animation/delay.js.map +1 -1
  114. package/lib/module/reanimated2/animation/index.js.map +1 -1
  115. package/lib/module/reanimated2/animation/repeat.js +1 -6
  116. package/lib/module/reanimated2/animation/repeat.js.map +1 -1
  117. package/lib/module/reanimated2/animation/sequence.js +1 -5
  118. package/lib/module/reanimated2/animation/sequence.js.map +1 -1
  119. package/lib/module/reanimated2/animation/spring.js.map +1 -1
  120. package/lib/module/reanimated2/animation/springUtils.js +8 -10
  121. package/lib/module/reanimated2/animation/springUtils.js.map +1 -1
  122. package/lib/module/reanimated2/animation/styleAnimation.js +5 -4
  123. package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
  124. package/lib/module/reanimated2/animation/timing.js +4 -1
  125. package/lib/module/reanimated2/animation/timing.js.map +1 -1
  126. package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js +1 -2
  127. package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js.map +1 -1
  128. package/lib/module/reanimated2/animation/util.js +22 -2
  129. package/lib/module/reanimated2/animation/util.js.map +1 -1
  130. package/lib/module/reanimated2/commonTypes.js +3 -1
  131. package/lib/module/reanimated2/commonTypes.js.map +1 -1
  132. package/lib/module/reanimated2/component/FlatList.js +1 -0
  133. package/lib/module/reanimated2/component/FlatList.js.map +1 -1
  134. package/lib/module/reanimated2/component/Image.js +1 -0
  135. package/lib/module/reanimated2/component/Image.js.map +1 -1
  136. package/lib/module/reanimated2/component/LayoutAnimationConfig.js +1 -0
  137. package/lib/module/reanimated2/component/LayoutAnimationConfig.js.map +1 -1
  138. package/lib/module/reanimated2/component/PerformanceMonitor.js +169 -0
  139. package/lib/module/reanimated2/component/PerformanceMonitor.js.map +1 -0
  140. package/lib/module/reanimated2/component/ScrollView.js +1 -0
  141. package/lib/module/reanimated2/component/ScrollView.js.map +1 -1
  142. package/lib/module/reanimated2/component/Text.js +1 -0
  143. package/lib/module/reanimated2/component/Text.js.map +1 -1
  144. package/lib/module/reanimated2/component/View.js +1 -0
  145. package/lib/module/reanimated2/component/View.js.map +1 -1
  146. package/lib/module/reanimated2/core.js +6 -15
  147. package/lib/module/reanimated2/core.js.map +1 -1
  148. package/lib/module/reanimated2/errors.js +8 -8
  149. package/lib/module/reanimated2/errors.js.map +1 -1
  150. package/lib/module/reanimated2/fabricUtils.js +33 -8
  151. package/lib/module/reanimated2/fabricUtils.js.map +1 -1
  152. package/lib/module/reanimated2/fabricUtils.web.js.map +1 -1
  153. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js +2 -2
  154. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js.map +1 -1
  155. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  156. package/lib/module/reanimated2/frameCallback/index.js.map +1 -1
  157. package/lib/module/reanimated2/globals.d.js.map +1 -1
  158. package/lib/module/reanimated2/helperTypes.js.map +1 -1
  159. package/lib/module/reanimated2/hook/commonTypes.js.map +1 -1
  160. package/lib/module/reanimated2/hook/index.js.map +1 -1
  161. package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js +1 -0
  162. package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
  163. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +3 -4
  164. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  165. package/lib/module/reanimated2/hook/useAnimatedProps.js.map +1 -1
  166. package/lib/module/reanimated2/hook/useAnimatedReaction.js +1 -0
  167. package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  168. package/lib/module/reanimated2/hook/useAnimatedRef.js +12 -7
  169. package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
  170. package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js +3 -1
  171. package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
  172. package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  173. package/lib/module/reanimated2/hook/useAnimatedStyle.js +3 -6
  174. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  175. package/lib/module/reanimated2/hook/useDerivedValue.js +3 -1
  176. package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
  177. package/lib/module/reanimated2/hook/useEvent.js +4 -5
  178. package/lib/module/reanimated2/hook/useEvent.js.map +1 -1
  179. package/lib/module/reanimated2/hook/useFrameCallback.js +1 -2
  180. package/lib/module/reanimated2/hook/useFrameCallback.js.map +1 -1
  181. package/lib/module/reanimated2/hook/useHandler.js +3 -1
  182. package/lib/module/reanimated2/hook/useHandler.js.map +1 -1
  183. package/lib/module/reanimated2/hook/useReducedMotion.js.map +1 -1
  184. package/lib/module/reanimated2/hook/useScrollViewOffset.js +60 -16
  185. package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  186. package/lib/module/reanimated2/hook/useSharedValue.js.map +1 -1
  187. package/lib/module/reanimated2/hook/useWorkletCallback.js.map +1 -1
  188. package/lib/module/reanimated2/hook/utils.js.map +1 -1
  189. package/lib/module/reanimated2/index.js +2 -0
  190. package/lib/module/reanimated2/index.js.map +1 -1
  191. package/lib/module/reanimated2/initializers.js +1 -5
  192. package/lib/module/reanimated2/initializers.js.map +1 -1
  193. package/lib/module/reanimated2/interpolateColor.js +2 -6
  194. package/lib/module/reanimated2/interpolateColor.js.map +1 -1
  195. package/lib/module/reanimated2/interpolation.js +1 -1
  196. package/lib/module/reanimated2/interpolation.js.map +1 -1
  197. package/lib/module/reanimated2/isSharedValue.js.map +1 -1
  198. package/lib/module/reanimated2/jestUtils.js +3 -6
  199. package/lib/module/reanimated2/jestUtils.js.map +1 -1
  200. package/lib/module/reanimated2/jestUtils.web.js.map +1 -1
  201. package/lib/module/reanimated2/js-reanimated/JSReanimated.js +5 -9
  202. package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  203. package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -1
  204. package/lib/module/reanimated2/js-reanimated/index.js +2 -2
  205. package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
  206. package/lib/module/reanimated2/js-reanimated/react-native-web.d.js.map +1 -1
  207. package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +4 -2
  208. package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
  209. package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +12 -11
  210. package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
  211. package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +12 -10
  212. package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
  213. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  214. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  215. package/lib/module/reanimated2/layoutReanimation/animationsManager.js +11 -4
  216. package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  217. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +22 -22
  218. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  219. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js +22 -22
  220. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
  221. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js +26 -26
  222. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
  223. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +10 -10
  224. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  225. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +6 -6
  226. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
  227. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +10 -10
  228. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  229. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +18 -18
  230. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
  231. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +18 -18
  232. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  233. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +10 -10
  234. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
  235. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +34 -34
  236. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  237. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/index.js.map +1 -1
  238. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +17 -4
  239. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
  240. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +4 -4
  241. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
  242. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +4 -4
  243. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
  244. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +4 -4
  245. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
  246. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +4 -4
  247. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
  248. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +4 -4
  249. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
  250. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/index.js.map +1 -1
  251. package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
  252. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/ProgressTransitionManager.js +16 -12
  253. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/ProgressTransitionManager.js.map +1 -1
  254. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.js +13 -7
  255. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.js.map +1 -1
  256. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.web.js.map +1 -1
  257. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -1
  258. package/lib/module/reanimated2/layoutReanimation/web/animation/Bounce.web.js.map +1 -1
  259. package/lib/module/reanimated2/layoutReanimation/web/animation/Fade.web.js.map +1 -1
  260. package/lib/module/reanimated2/layoutReanimation/web/animation/Flip.web.js.map +1 -1
  261. package/lib/module/reanimated2/layoutReanimation/web/animation/Lightspeed.web.js.map +1 -1
  262. package/lib/module/reanimated2/layoutReanimation/web/animation/Pinwheel.web.js.map +1 -1
  263. package/lib/module/reanimated2/layoutReanimation/web/animation/Roll.web.js.map +1 -1
  264. package/lib/module/reanimated2/layoutReanimation/web/animation/Rotate.web.js.map +1 -1
  265. package/lib/module/reanimated2/layoutReanimation/web/animation/Slide.web.js.map +1 -1
  266. package/lib/module/reanimated2/layoutReanimation/web/animation/Stretch.web.js.map +1 -1
  267. package/lib/module/reanimated2/layoutReanimation/web/animation/Zoom.web.js.map +1 -1
  268. package/lib/module/reanimated2/layoutReanimation/web/animationParser.js +0 -2
  269. package/lib/module/reanimated2/layoutReanimation/web/animationParser.js.map +1 -1
  270. package/lib/module/reanimated2/layoutReanimation/web/animationsManager.js +1 -2
  271. package/lib/module/reanimated2/layoutReanimation/web/animationsManager.js.map +1 -1
  272. package/lib/module/reanimated2/layoutReanimation/web/componentStyle.js +3 -1
  273. package/lib/module/reanimated2/layoutReanimation/web/componentStyle.js.map +1 -1
  274. package/lib/module/reanimated2/layoutReanimation/web/componentUtils.js +6 -7
  275. package/lib/module/reanimated2/layoutReanimation/web/componentUtils.js.map +1 -1
  276. package/lib/module/reanimated2/layoutReanimation/web/config.js.map +1 -1
  277. package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js +2 -2
  278. package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js.map +1 -1
  279. package/lib/module/reanimated2/layoutReanimation/web/domUtils.js +4 -4
  280. package/lib/module/reanimated2/layoutReanimation/web/domUtils.js.map +1 -1
  281. package/lib/module/reanimated2/layoutReanimation/web/index.js.map +1 -1
  282. package/lib/module/reanimated2/layoutReanimation/web/transition/Fading.web.js.map +1 -1
  283. package/lib/module/reanimated2/layoutReanimation/web/transition/Linear.web.js.map +1 -1
  284. package/lib/module/reanimated2/layoutReanimation/web/transition/Sequenced.web.js.map +1 -1
  285. package/lib/module/reanimated2/mappers.js +2 -4
  286. package/lib/module/reanimated2/mappers.js.map +1 -1
  287. package/lib/module/reanimated2/mockedRequestAnimationFrame.js.map +1 -1
  288. package/lib/module/reanimated2/mutables.js +2 -4
  289. package/lib/module/reanimated2/mutables.js.map +1 -1
  290. package/lib/module/reanimated2/platform-specific/RNRenderer.js.map +1 -1
  291. package/lib/module/reanimated2/platform-specific/RNRenderer.web.js.map +1 -1
  292. package/lib/module/reanimated2/platform-specific/checkCppVersion.js.map +1 -1
  293. package/lib/module/reanimated2/platform-specific/jsVersion.js +1 -1
  294. package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -1
  295. package/lib/module/reanimated2/platformFunctions/dispatchCommand.js +2 -4
  296. package/lib/module/reanimated2/platformFunctions/dispatchCommand.js.map +1 -1
  297. package/lib/module/reanimated2/platformFunctions/dispatchCommand.web.js.map +1 -1
  298. package/lib/module/reanimated2/platformFunctions/getRelativeCoords.js +2 -2
  299. package/lib/module/reanimated2/platformFunctions/getRelativeCoords.js.map +1 -1
  300. package/lib/module/reanimated2/platformFunctions/index.js.map +1 -1
  301. package/lib/module/reanimated2/platformFunctions/measure.js.map +1 -1
  302. package/lib/module/reanimated2/platformFunctions/measure.web.js.map +1 -1
  303. package/lib/module/reanimated2/platformFunctions/scrollTo.js.map +1 -1
  304. package/lib/module/reanimated2/platformFunctions/scrollTo.web.js +1 -1
  305. package/lib/module/reanimated2/platformFunctions/scrollTo.web.js.map +1 -1
  306. package/lib/module/reanimated2/platformFunctions/setGestureState.js.map +1 -1
  307. package/lib/module/reanimated2/platformFunctions/setGestureState.web.js.map +1 -1
  308. package/lib/module/reanimated2/platformFunctions/setNativeProps.js.map +1 -1
  309. package/lib/module/reanimated2/platformFunctions/setNativeProps.web.js.map +1 -1
  310. package/lib/module/reanimated2/pluginUtils.js.map +1 -1
  311. package/lib/module/reanimated2/publicGlobals.js.map +1 -1
  312. package/lib/module/reanimated2/runtimes.js +11 -19
  313. package/lib/module/reanimated2/runtimes.js.map +1 -1
  314. package/lib/module/reanimated2/screenTransition/RNScreensTurboModule.js +20 -0
  315. package/lib/module/reanimated2/screenTransition/RNScreensTurboModule.js.map +1 -0
  316. package/lib/module/reanimated2/screenTransition/animationManager.js +41 -0
  317. package/lib/module/reanimated2/screenTransition/animationManager.js.map +1 -0
  318. package/lib/module/reanimated2/screenTransition/commonTypes.js +4 -0
  319. package/lib/module/reanimated2/screenTransition/commonTypes.js.map +1 -0
  320. package/lib/module/reanimated2/screenTransition/index.js +5 -0
  321. package/lib/module/reanimated2/screenTransition/index.js.map +1 -0
  322. package/lib/module/reanimated2/screenTransition/presets.js +157 -0
  323. package/lib/module/reanimated2/screenTransition/presets.js.map +1 -0
  324. package/lib/module/reanimated2/screenTransition/styleUpdater.js +62 -0
  325. package/lib/module/reanimated2/screenTransition/styleUpdater.js.map +1 -0
  326. package/lib/module/reanimated2/screenTransition/swipeSimulator.js +190 -0
  327. package/lib/module/reanimated2/screenTransition/swipeSimulator.js.map +1 -0
  328. package/lib/module/reanimated2/shareableMappingCache.js.map +1 -1
  329. package/lib/module/reanimated2/shareables.js +27 -10
  330. package/lib/module/reanimated2/shareables.js.map +1 -1
  331. package/lib/module/reanimated2/threads.js +9 -34
  332. package/lib/module/reanimated2/threads.js.map +1 -1
  333. package/lib/module/reanimated2/valueSetter.js +1 -2
  334. package/lib/module/reanimated2/valueSetter.js.map +1 -1
  335. package/lib/module/reanimated2/valueUnpacker.js +4 -3
  336. package/lib/module/reanimated2/valueUnpacker.js.map +1 -1
  337. package/lib/module/specs/NativeReanimatedModule.js +5 -0
  338. package/lib/module/specs/NativeReanimatedModule.js.map +1 -0
  339. package/lib/typescript/ConfigHelper.d.ts +1 -0
  340. package/lib/typescript/createAnimatedComponent/InlinePropManager.d.ts +1 -1
  341. package/lib/typescript/createAnimatedComponent/JSPropsUpdater.web.d.ts +6 -0
  342. package/lib/typescript/createAnimatedComponent/PropsFilter.d.ts +3 -0
  343. package/lib/typescript/createAnimatedComponent/getViewInfo.d.ts +9 -0
  344. package/lib/typescript/reanimated2/NativeReanimated/NativeReanimated.d.ts +8 -13
  345. package/lib/typescript/reanimated2/UpdateLayoutAnimations.d.ts +12 -1
  346. package/lib/typescript/reanimated2/WorkletEventHandler.d.ts +16 -9
  347. package/lib/typescript/reanimated2/animation/util.d.ts +2 -0
  348. package/lib/typescript/reanimated2/component/LayoutAnimationConfig.d.ts +1 -1
  349. package/lib/typescript/reanimated2/component/PerformanceMonitor.d.ts +2 -0
  350. package/lib/typescript/reanimated2/core.d.ts +3 -4
  351. package/lib/typescript/reanimated2/hook/commonTypes.d.ts +6 -0
  352. package/lib/typescript/reanimated2/hook/useEvent.d.ts +2 -3
  353. package/lib/typescript/reanimated2/hook/useScrollViewOffset.d.ts +3 -1
  354. package/lib/typescript/reanimated2/index.d.ts +3 -0
  355. package/lib/typescript/reanimated2/js-reanimated/JSReanimated.d.ts +2 -2
  356. package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/commonTypes.d.ts +2 -1
  357. package/lib/typescript/reanimated2/layoutReanimation/sharedTransitions/ProgressTransitionManager.d.ts +2 -2
  358. package/lib/typescript/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.d.ts +2 -2
  359. package/lib/typescript/reanimated2/platform-specific/jsVersion.d.ts +1 -1
  360. package/lib/typescript/reanimated2/screenTransition/RNScreensTurboModule.d.ts +2 -0
  361. package/lib/typescript/reanimated2/screenTransition/animationManager.d.ts +3 -0
  362. package/lib/typescript/reanimated2/screenTransition/commonTypes.d.ts +38 -0
  363. package/lib/typescript/reanimated2/screenTransition/index.d.ts +3 -0
  364. package/lib/typescript/reanimated2/screenTransition/presets.d.ts +11 -0
  365. package/lib/typescript/reanimated2/screenTransition/styleUpdater.d.ts +3 -0
  366. package/lib/typescript/reanimated2/screenTransition/swipeSimulator.d.ts +2 -0
  367. package/lib/typescript/specs/NativeReanimatedModule.d.ts +6 -0
  368. package/package.json +29 -17
  369. package/plugin/build/plugin.js +7 -2
  370. package/src/ConfigHelper.ts +1 -1
  371. package/src/animationBuilder.tsx +2 -0
  372. package/src/createAnimatedComponent/InlinePropManager.ts +2 -2
  373. package/src/createAnimatedComponent/JSPropsUpdater.ts +7 -6
  374. package/src/createAnimatedComponent/JSPropsUpdater.web.ts +26 -0
  375. package/src/createAnimatedComponent/PropsFilter.tsx +31 -6
  376. package/src/createAnimatedComponent/createAnimatedComponent.tsx +108 -60
  377. package/src/createAnimatedComponent/getViewInfo.ts +39 -0
  378. package/src/mock.ts +13 -1
  379. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +33 -35
  380. package/src/reanimated2/PlatformChecker.ts +3 -2
  381. package/src/reanimated2/PropsRegistry.ts +1 -3
  382. package/src/reanimated2/UpdateLayoutAnimations.ts +53 -13
  383. package/src/reanimated2/WorkletEventHandler.ts +98 -39
  384. package/src/reanimated2/animation/styleAnimation.ts +8 -6
  385. package/src/reanimated2/animation/timing.ts +9 -1
  386. package/src/reanimated2/animation/util.ts +28 -3
  387. package/src/reanimated2/commonTypes.ts +4 -1
  388. package/src/reanimated2/component/PerformanceMonitor.tsx +216 -0
  389. package/src/reanimated2/core.ts +9 -31
  390. package/src/reanimated2/errors.ts +1 -0
  391. package/src/reanimated2/fabricUtils.ts +43 -18
  392. package/src/reanimated2/globals.d.ts +11 -1
  393. package/src/reanimated2/hook/commonTypes.ts +10 -0
  394. package/src/reanimated2/hook/useAnimatedRef.ts +20 -11
  395. package/src/reanimated2/hook/useEvent.ts +4 -4
  396. package/src/reanimated2/hook/useScrollViewOffset.ts +94 -23
  397. package/src/reanimated2/index.ts +11 -0
  398. package/src/reanimated2/js-reanimated/JSReanimated.ts +7 -7
  399. package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +4 -0
  400. package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +9 -1
  401. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +9 -1
  402. package/src/reanimated2/layoutReanimation/animationsManager.ts +10 -2
  403. package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +13 -0
  404. package/src/reanimated2/layoutReanimation/sharedTransitions/ProgressTransitionManager.ts +17 -8
  405. package/src/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.ts +26 -7
  406. package/src/reanimated2/layoutReanimation/web/animationsManager.ts +1 -1
  407. package/src/reanimated2/layoutReanimation/web/componentStyle.ts +3 -1
  408. package/src/reanimated2/layoutReanimation/web/componentUtils.ts +1 -1
  409. package/src/reanimated2/layoutReanimation/web/createAnimation.ts +2 -2
  410. package/src/reanimated2/platform-specific/jsVersion.ts +1 -1
  411. package/src/reanimated2/platformFunctions/getRelativeCoords.ts +2 -2
  412. package/src/reanimated2/screenTransition/RNScreensTurboModule.ts +29 -0
  413. package/src/reanimated2/screenTransition/animationManager.ts +45 -0
  414. package/src/reanimated2/screenTransition/commonTypes.ts +63 -0
  415. package/src/reanimated2/screenTransition/index.ts +12 -0
  416. package/src/reanimated2/screenTransition/presets.ts +137 -0
  417. package/src/reanimated2/screenTransition/styleUpdater.ts +73 -0
  418. package/src/reanimated2/screenTransition/swipeSimulator.ts +238 -0
  419. package/src/reanimated2/shareables.ts +29 -6
  420. package/src/reanimated2/valueUnpacker.ts +10 -3
  421. package/src/specs/NativeReanimatedModule.ts +9 -0
  422. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +0 -16
  423. package/android/src/reactNativeVersionPatch/messageQueueThread/67/com/swmansion/reanimated/ReanimatedMessageQueueThread.java +0 -12
@@ -0,0 +1,565 @@
1
+ #include "LayoutAnimationsProxy.h"
2
+ #include <react/renderer/animations/utils.h>
3
+ #include <react/renderer/mounting/ShadowViewMutation.h>
4
+ #include "NativeReanimatedModule.h"
5
+
6
+ namespace reanimated {
7
+
8
+ std::optional<SurfaceId> LayoutAnimationsProxy::progressLayoutAnimation(int tag, const jsi::Object &newStyle) {
9
+ auto lock = std::unique_lock<std::recursive_mutex>(mutex);
10
+ LOG(INFO) << "progress layout animation for tag " << tag << std::endl;
11
+ auto layoutAnimationIt = layoutAnimations_.find(tag);
12
+
13
+ // TODO: investigate
14
+ if (layoutAnimationIt == layoutAnimations_.end() ||
15
+ bannedTags.contains(tag)) {
16
+ return {};
17
+ }
18
+
19
+ auto &layoutAnimation = layoutAnimationIt->second;
20
+ auto &runtime = nativeReanimatedModule_->getUIRuntime();
21
+
22
+ if (layoutAnimation.opacity && !newStyle.hasProperty(runtime, "opacity")) {
23
+ newStyle.setProperty(runtime, "opacity", jsi::Value(*layoutAnimation.opacity));
24
+ layoutAnimation.opacity.reset();
25
+ }
26
+ auto rawProps =
27
+ std::make_shared<RawProps>(runtime, jsi::Value(runtime, newStyle));
28
+
29
+ PropsParserContext propsParserContext{layoutAnimation.end->surfaceId, *contextContainer_};
30
+ auto newProps = getComponentDescriptorForShadowView(*layoutAnimation.end).cloneProps(propsParserContext, layoutAnimations_.at(tag).end->props, std::move(*rawProps));
31
+ auto &updateMap = surfaceManager.getUpdateMap(layoutAnimation.end->surfaceId);
32
+ updateMap.insert_or_assign(tag, UpdateValues{newProps, Frame(runtime, newStyle)});
33
+
34
+ LOG(INFO) << "free lock" << std::endl;
35
+ return layoutAnimation.end->surfaceId;
36
+ }
37
+
38
+ std::optional<SurfaceId> LayoutAnimationsProxy::endLayoutAnimation(int tag, bool shouldRemove) {
39
+ auto lock = std::unique_lock<std::recursive_mutex>(mutex);
40
+ LOG(INFO) << "end layout animation for " << tag << " - should remove "
41
+ << shouldRemove << std::endl;
42
+ auto layoutAnimationIt = layoutAnimations_.find(tag);
43
+
44
+ // TODO: investigate
45
+ if (layoutAnimationIt == layoutAnimations_.end() ||
46
+ bannedTags.contains(tag)) {
47
+ return {};
48
+ }
49
+
50
+ auto &layoutAnimation = layoutAnimationIt->second;
51
+ auto &cleanupMutations = surfaceManager.getCleanupMutations(layoutAnimation.end->surfaceId);
52
+
53
+ if (shouldRemove) {
54
+ if (nodeForTag.contains(tag)){
55
+ auto node = nodeForTag[tag];
56
+ auto mutationNode = std::static_pointer_cast<MutationNode>(node);
57
+ endAnimationsRecursively(mutationNode, cleanupMutations);
58
+ if (node->parent){
59
+ maybeDropAncestors(node->parent, mutationNode, cleanupMutations);
60
+ }
61
+ }
62
+ }
63
+ auto &updateMap = surfaceManager.getUpdateMap(layoutAnimation.end->surfaceId);
64
+ auto surfaceId = layoutAnimation.end->surfaceId;
65
+ layoutAnimations_.erase(tag);
66
+ updateMap.erase(tag);
67
+
68
+ LOG(INFO) << "free lock" << std::endl;
69
+ return surfaceId;
70
+ }
71
+
72
+ void LayoutAnimationsProxy::endAnimationsRecursively(std::shared_ptr<MutationNode> node, ShadowViewMutationList& mutations) const{
73
+ nodeForTag.erase(node->tag);
74
+ node->isDone = true;
75
+ for (auto it = node->children.rbegin(); it != node->children.rend(); it++) {
76
+ auto &subNode = *it;
77
+ if (!subNode->isDone) {
78
+ cancelAnimation(subNode->tag);
79
+ endAnimationsRecursively(subNode, mutations);
80
+ }
81
+ }
82
+ mutations.push_back(node->mutation);
83
+ if (node->isExiting){
84
+ dropIndex(node->mutation.parentShadowView.tag, node->mutation.index);
85
+ }
86
+ updateIndices(node->mutation);
87
+ nodeForTag.erase(node->tag);
88
+ LOG(INFO) << "delete "<<node->tag<<std::endl;
89
+ mutations.push_back(ShadowViewMutation::DeleteMutation(node->mutation.oldChildShadowView));
90
+ }
91
+
92
+ void LayoutAnimationsProxy::maybeDropAncestors(std::shared_ptr<Node> parent, std::shared_ptr<MutationNode> child, ShadowViewMutationList& cleanupMutations) const{
93
+ parent->removeChild(child);
94
+ if (parent->parent == nullptr){
95
+ return;
96
+ }
97
+
98
+ auto node = std::static_pointer_cast<MutationNode>(parent);
99
+ node->animatedChildren.erase(child->tag);
100
+
101
+ if (node->animatedChildren.empty() && !node->isAnimatingExit){
102
+ for (auto subNode: node->children){
103
+ endAnimationsRecursively(subNode, cleanupMutations);
104
+ }
105
+ nodeForTag.erase(node->tag);
106
+ cleanupMutations.push_back(node->mutation);
107
+ if (layoutAnimations_.contains(node->tag)){
108
+ cancelAnimation(node->tag);
109
+ }
110
+ dropIndex(node->mutation.parentShadowView.tag, node->mutation.index);
111
+ updateIndices(node->mutation);
112
+ LOG(INFO) << "delete "<<node->tag<<std::endl;
113
+ cleanupMutations.push_back(ShadowViewMutation::DeleteMutation(node->mutation.oldChildShadowView));
114
+ maybeDropAncestors(node->parent, node, cleanupMutations);
115
+ }
116
+ }
117
+
118
+ const ComponentDescriptor &LayoutAnimationsProxy::getComponentDescriptorForShadowView(const ShadowView &shadowView) const {
119
+ return componentDescriptorRegistry_->at(shadowView.componentHandle);
120
+ }
121
+
122
+ void LayoutAnimationsProxy::addOngoingAnimations(
123
+ SurfaceId surfaceId,
124
+ ShadowViewMutationList &mutations) const {
125
+ auto& updateMap = surfaceManager.getUpdateMap(surfaceId);
126
+ for (auto &[tag, updateValues] : updateMap) {
127
+ if (!layoutAnimations_.contains(tag)) {
128
+ continue;
129
+ }
130
+ auto &la = layoutAnimations_.at(tag);
131
+ auto &previous = la.current;
132
+ auto &finalView = la.end;
133
+ auto parent = la.parent;
134
+ auto newView = std::make_shared<ShadowView>(*finalView);
135
+ newView->props = updateValues.newProps;
136
+ auto frame = updateValues.frame;
137
+ updateLayoutMetrics(newView->layoutMetrics, frame);
138
+
139
+ mutations.push_back(ShadowViewMutation::UpdateMutation(*previous, *newView, parent));
140
+ la.current = newView;
141
+ }
142
+ updateMap.clear();
143
+ surfaceManager.consumeCleanupMutations(surfaceId, mutations);
144
+ std::stable_sort(mutations.begin(), mutations.end(), &shouldFirstComeBeforeSecondMutation);
145
+ }
146
+
147
+ std::optional<MountingTransaction> LayoutAnimationsProxy::pullTransaction(
148
+ SurfaceId surfaceId,
149
+ MountingTransaction::Number transactionNumber,
150
+ const TransactionTelemetry &telemetry,
151
+ ShadowViewMutationList mutations) const {
152
+ LOG(INFO)<<"\n pullTransaction "<< std::this_thread::get_id()<<" "<<surfaceId<<std::endl;
153
+ auto lock = std::unique_lock<std::recursive_mutex>(mutex);
154
+ PropsParserContext propsParserContext{surfaceId, *contextContainer_};
155
+ ShadowViewMutationList filteredMutations;
156
+
157
+ std::vector<std::shared_ptr<MutationNode>> roots;
158
+
159
+ std::set<Tag> removedTags;
160
+
161
+ // TODO: filter reparentings
162
+ for (auto it = mutations.rbegin(); it != mutations.rend(); it++) {
163
+ auto &mutation = *it;
164
+ if (mutation.type == ShadowViewMutation::Delete){
165
+ removedTags.insert(mutation.oldChildShadowView.tag);
166
+ }
167
+ if (mutation.type == ShadowViewMutation::Remove && removedTags.contains(mutation.oldChildShadowView.tag)) {
168
+ updateIndexForMutation(mutation);
169
+ auto tag = mutation.oldChildShadowView.tag;
170
+ auto parentTag = mutation.parentShadowView.tag;
171
+ // auto parentTag = mutation.parentTag; TODO: uncomment
172
+
173
+ std::shared_ptr<MutationNode> mutationNode;
174
+ std::shared_ptr<Node> node = nodeForTag[tag], parent = nodeForTag[parentTag];
175
+
176
+ if (!node){
177
+ mutationNode = std::make_shared<MutationNode>(mutation);
178
+ } else {
179
+ mutationNode = std::make_shared<MutationNode>(mutation, std::move(*node));
180
+ for (auto subNode: mutationNode->children){
181
+ subNode->parent = mutationNode;
182
+ }
183
+ }
184
+ nodeForTag[tag] = mutationNode;
185
+
186
+ if (!parent){
187
+ parent = std::make_shared<Node>(parentTag);
188
+ nodeForTag[parentTag] = parent;
189
+ }
190
+
191
+ if (!parent->parent){
192
+ roots.push_back(mutationNode);
193
+ }
194
+
195
+ parent->addChild(mutationNode);
196
+ mutationNode->parent = parent;
197
+ }
198
+ }
199
+
200
+ for (auto it= roots.rbegin(); it != roots.rend(); it++) {
201
+ auto &node = *it;
202
+ if (!startAnimationsRecursively(node, true, true, filteredMutations)) {
203
+ if (layoutAnimations_.contains(node->tag)){
204
+ cancelAnimation(node->tag);
205
+ }
206
+ filteredMutations.push_back(node->mutation);
207
+ updateIndices(node->mutation);
208
+ nodeForTag.erase(node->tag);
209
+ node->parent->removeChild(node);
210
+ LOG(INFO) << "delete "<<node->tag<<std::endl;
211
+ filteredMutations.push_back(ShadowViewMutation::DeleteMutation(node->mutation.oldChildShadowView));
212
+ }
213
+ }
214
+
215
+ for (auto &mutation : mutations) {
216
+ if (mutation.parentShadowView.tag == surfaceId){
217
+ surfaceManager.updateWindow(surfaceId, mutation.parentShadowView.layoutMetrics.frame.size.width, mutation.parentShadowView.layoutMetrics.frame.size.height);
218
+ }
219
+
220
+ Tag tag = mutation.type ==
221
+ ShadowViewMutation::Type::Create || mutation.type == ShadowViewMutation::Type::Insert ?
222
+ mutation.newChildShadowView.tag
223
+ : mutation.oldChildShadowView.tag;
224
+
225
+ switch (mutation.type) {
226
+ case ShadowViewMutation::Type::Create:{
227
+ filteredMutations.push_back(mutation);
228
+ break;
229
+ }
230
+ case ShadowViewMutation::Type::Insert: {
231
+ updateIndexForMutation(mutation);
232
+ updateIndices(mutation);
233
+ transferConfigFromNativeTag(mutation.newChildShadowView.props->nativeId, mutation.newChildShadowView.tag);
234
+
235
+ if (!layoutAnimationsManager_->hasLayoutAnimation(tag, ENTERING)) {
236
+ filteredMutations.push_back(mutation);
237
+ continue;
238
+ }
239
+
240
+ startEnteringAnimation(tag, mutation);
241
+ filteredMutations.push_back(mutation);
242
+
243
+ // temporarily set opacity to 0 to prevent flickering on android
244
+ auto newView = std::make_shared<ShadowView>(mutation.newChildShadowView);
245
+ folly::dynamic opacity = folly::dynamic::object("opacity", 0);
246
+ auto newProps = getComponentDescriptorForShadowView(*newView).cloneProps(propsParserContext, newView->props, RawProps(opacity));
247
+ newView->props = newProps;
248
+
249
+ filteredMutations.push_back(ShadowViewMutation::UpdateMutation(mutation.newChildShadowView, *newView, mutation.parentShadowView));
250
+ break;
251
+ }
252
+
253
+ case ShadowViewMutation::Type::Update: {
254
+ if (!layoutAnimationsManager_->hasLayoutAnimation(tag, LAYOUT)) {
255
+ filteredMutations.push_back(mutation);
256
+ continue;
257
+ }
258
+ startLayoutAnimation(tag, mutation);
259
+ break;
260
+ }
261
+
262
+ // REMOVE (w/o INSERT) -- animated exiting | delay mutation, mark the
263
+ // index as used by us
264
+ case ShadowViewMutation::Type::Remove: {
265
+ if (!removedTags.contains(mutation.oldChildShadowView.tag)){
266
+ updateIndexForMutation(mutation);
267
+ filteredMutations.push_back(mutation);
268
+ updateIndices(mutation);
269
+ }
270
+
271
+ break;
272
+ }
273
+
274
+ case ShadowViewMutation::Type::Delete: {
275
+ break;
276
+ }
277
+
278
+ // REMOVEDRELETETREE
279
+ default:
280
+ filteredMutations.push_back(mutation);
281
+ }
282
+ }
283
+
284
+ addOngoingAnimations(surfaceId, filteredMutations);
285
+
286
+ LOG(INFO)<< "free lock" <<std::endl;
287
+ return MountingTransaction{surfaceId, transactionNumber, std::move(filteredMutations), telemetry};
288
+ }
289
+
290
+ bool LayoutAnimationsProxy::startAnimationsRecursively(std::shared_ptr<MutationNode> node, bool shouldRemoveSubviewsWithoutAnimations, bool shouldAnimate, ShadowViewMutationList& mutations) const{
291
+ shouldAnimate = layoutAnimationsManager_->shouldAnimateExiting(node->tag, shouldAnimate);
292
+ if (!std::strcmp(node->mutation.oldChildShadowView.componentName, "RNSScreenStack") || !std::strcmp(node->mutation.oldChildShadowView.componentName, "RNSScreen")){
293
+ shouldAnimate = false;
294
+ }
295
+ bool hasExitAnimation = shouldAnimate && layoutAnimationsManager_->hasLayoutAnimation(node->tag, LayoutAnimationType::EXITING);
296
+ bool hasAnimatedChildren = false;
297
+
298
+ shouldRemoveSubviewsWithoutAnimations = shouldRemoveSubviewsWithoutAnimations && !hasExitAnimation;
299
+ std::vector<std::shared_ptr<MutationNode>> toBeRemoved;
300
+
301
+ for (auto it = node->children.rbegin(); it != node->children.rend(); it++){
302
+ auto &subNode = *it;
303
+ LOG(INFO) << "child "<<subNode->tag<< " "<<subNode->isExiting<<" "<<shouldAnimate<<" "<<shouldRemoveSubviewsWithoutAnimations<< std::endl;
304
+ if (subNode->isExiting){
305
+ if (shouldAnimate){
306
+ node->animatedChildren.insert(subNode->tag);
307
+ hasAnimatedChildren = true;
308
+ }
309
+ else {
310
+ cancelAnimation(subNode->tag);
311
+ endAnimationsRecursively(subNode, mutations);
312
+ }
313
+ } else if (startAnimationsRecursively(subNode, shouldRemoveSubviewsWithoutAnimations, shouldAnimate, mutations)) {
314
+ LOG(INFO) << "child "<<subNode->tag<< " start animations returned true "<<std::endl;
315
+ node->animatedChildren.insert(subNode->tag);
316
+ hasAnimatedChildren = true;
317
+ } else if (shouldRemoveSubviewsWithoutAnimations) {
318
+ if (layoutAnimations_.contains(subNode->tag)){
319
+ cancelAnimation(subNode->tag);
320
+ }
321
+ mutations.push_back(subNode->mutation);
322
+ toBeRemoved.push_back(subNode);
323
+ updateIndices(subNode->mutation);
324
+ nodeForTag.erase(subNode->tag);
325
+ LOG(INFO) << "delete "<<subNode->tag<<std::endl;
326
+ mutations.push_back(ShadowViewMutation::DeleteMutation(subNode->mutation.oldChildShadowView));
327
+ }
328
+ }
329
+
330
+ for (auto& subNode: toBeRemoved){
331
+ node->removeChild(subNode);
332
+ }
333
+
334
+ bool wantAnimateExit = hasExitAnimation || hasAnimatedChildren;
335
+
336
+ if (hasExitAnimation) {
337
+ node->isAnimatingExit = true;
338
+ startExitingAnimation(node->tag, node->mutation);
339
+ }
340
+
341
+ if (!wantAnimateExit) {
342
+ return false;
343
+ }
344
+
345
+ node->isExiting = true;
346
+ takeIndex(node->mutation.parentShadowView.tag, node->mutation.index);
347
+ return true;
348
+ }
349
+
350
+ void LayoutAnimationsProxy::updateIndexForMutation(
351
+ ShadowViewMutation &mutation) const {
352
+ if (mutation.index == -1) {
353
+ return;
354
+ }
355
+ int k = mutation.index, i = 0;
356
+
357
+ int tag = mutation.type == ShadowViewMutation::Insert
358
+ ? mutation.newChildShadowView.tag
359
+ : mutation.oldChildShadowView.tag;
360
+
361
+ if (!indices.contains(mutation.parentShadowView.tag)) {
362
+ return;
363
+ }
364
+
365
+ // !!!
366
+ while (true) {
367
+ if (indices.at(mutation.parentShadowView.tag)->contains(i)) {
368
+ i++;
369
+ continue;
370
+ }
371
+ if (!k) {
372
+ break;
373
+ }
374
+ k--;
375
+ i++;
376
+ }
377
+ LOG(INFO)<<"update index for "<<tag<<" in "<<mutation.parentShadowView.tag<<": "<<mutation.index<<" -> "<<i<<std::endl;
378
+ mutation.index = i;
379
+ }
380
+
381
+ void LayoutAnimationsProxy::updateIndices(ShadowViewMutation &mutation) const {
382
+ int delta = mutation.type == ShadowViewMutation::Insert ? 1 : -1;
383
+ if (!indices.contains(mutation.parentShadowView.tag)) {
384
+ return;
385
+ }
386
+
387
+ auto &s = *indices.at(mutation.parentShadowView.tag);
388
+ auto newS = std::make_shared<std::unordered_set<int>>();
389
+ LOG(INFO)<<"updating indices of "<<mutation.parentShadowView.tag<<"'s children after index "<<mutation.index<<std::endl;
390
+ std::vector<std::shared_ptr<MutationNode>> nodesToFix;
391
+ for (auto i : s) {
392
+ if (i < mutation.index) {
393
+ newS->insert(i);
394
+ } else {
395
+ for (auto &[tag, node] : nodeForTag) {
396
+ if (!node->parent){
397
+ continue;
398
+ }
399
+ auto mutationNode = std::static_pointer_cast<MutationNode>(node);
400
+ if (mutationNode->mutation.parentShadowView.tag == mutation.parentShadowView.tag && mutationNode->mutation.index == i) {
401
+ // !!!
402
+ nodesToFix.push_back(mutationNode);
403
+ break;
404
+ }
405
+ }
406
+ newS->insert(i + delta);
407
+ }
408
+ }
409
+ for (auto node : nodesToFix) {
410
+ LOG(INFO)<<"tag "<<node->mutation.oldChildShadowView.tag<<" index "<<node->mutation.index<<" -> "<<node->mutation.index + delta<<std::endl;
411
+ node->mutation.index += delta;
412
+ }
413
+ indices.insert_or_assign(mutation.parentShadowView.tag, newS);
414
+ }
415
+
416
+ void LayoutAnimationsProxy::takeIndex(Tag parentTag, int index) const {
417
+ LOG(INFO)<<"take index "<<index<<" in parent "<<parentTag<<std::endl;
418
+ if (!indices.contains(parentTag)) {
419
+ indices.insert_or_assign(
420
+ parentTag, std::make_shared<std::unordered_set<int>>());
421
+ }
422
+
423
+ indices.at(parentTag)->insert(index);
424
+ }
425
+
426
+ void LayoutAnimationsProxy::dropIndex(Tag parentTag, int index) const {
427
+ LOG(INFO)<<"drop index "<<index<<" in parent "<<parentTag<<std::endl;
428
+ if (!indices.contains(parentTag)) {
429
+ return;
430
+ }
431
+
432
+ indices.at(parentTag)->erase(index);
433
+ }
434
+
435
+ bool LayoutAnimationsProxy::shouldOverridePullTransaction() const {
436
+ return true;
437
+ }
438
+
439
+ void LayoutAnimationsProxy::startEnteringAnimation(const int tag, ShadowViewMutation& mutation) const {
440
+ LOG(INFO)<<"start entering animation for tag "<<tag<<std::endl;
441
+ auto finalView = std::make_shared<ShadowView>(mutation.newChildShadowView);
442
+ auto current = std::make_shared<ShadowView>(mutation.oldChildShadowView);
443
+ auto& viewProps = static_cast<const ViewProps&>(*mutation.newChildShadowView.props);
444
+ LayoutAnimation la{
445
+ finalView,
446
+ current,
447
+ mutation.oldChildShadowView,
448
+ mutation.parentShadowView,
449
+ viewProps.opacity
450
+ };
451
+ layoutAnimations_.insert_or_assign(tag, la);
452
+
453
+ Snapshot values(mutation.newChildShadowView, surfaceManager.getWindow(mutation.newChildShadowView.surfaceId));
454
+
455
+ nativeReanimatedModule_->uiScheduler_->scheduleOnUI(
456
+ [values, this, tag]() {
457
+ jsi::Runtime &rt = nativeReanimatedModule_->getUIRuntime();
458
+ jsi::Object yogaValues(rt);
459
+ yogaValues.setProperty(rt, "targetOriginX", values.x);
460
+ yogaValues.setProperty(rt, "targetGlobalOriginX", values.x);
461
+ yogaValues.setProperty(rt, "targetOriginY", values.y);
462
+ yogaValues.setProperty(rt, "targetGlobalOriginY", values.y);
463
+ yogaValues.setProperty(rt, "targetWidth", values.width);
464
+ yogaValues.setProperty(rt, "targetHeight", values.height);
465
+ yogaValues.setProperty(rt, "windowWidth", values.windowWidth);
466
+ yogaValues.setProperty(rt, "windowHeight", values.windowHeight);
467
+ nativeReanimatedModule_->layoutAnimationsManager().startLayoutAnimation(rt, tag, LayoutAnimationType::ENTERING, yogaValues);
468
+ });
469
+ }
470
+
471
+ void LayoutAnimationsProxy::startExitingAnimation(const int tag, ShadowViewMutation& mutation) const {
472
+ LOG(INFO)<<"start exiting animation for tag "<<tag<<std::endl;
473
+ auto finalView = std::make_shared<ShadowView>(mutation.oldChildShadowView);
474
+ auto current = std::make_shared<ShadowView>(mutation.oldChildShadowView);
475
+ LayoutAnimation la{
476
+ finalView,
477
+ current,
478
+ mutation.oldChildShadowView,
479
+ mutation.parentShadowView,
480
+ };
481
+ layoutAnimations_.insert_or_assign(mutation.oldChildShadowView.tag, la);
482
+
483
+ Snapshot values(mutation.oldChildShadowView, surfaceManager.getWindow(mutation.oldChildShadowView.surfaceId));
484
+
485
+ nativeReanimatedModule_->uiScheduler_->scheduleOnUI(
486
+ [values, this, tag]() {
487
+ jsi::Runtime &rt = nativeReanimatedModule_->getUIRuntime();
488
+ jsi::Object yogaValues(rt);
489
+ yogaValues.setProperty(rt, "currentOriginX", values.x);
490
+ yogaValues.setProperty(rt, "currentGlobalOriginX", values.x);
491
+ yogaValues.setProperty(rt, "currentOriginY", values.y);
492
+ yogaValues.setProperty(rt, "currentGlobalOriginY", values.y);
493
+ yogaValues.setProperty(rt, "currentWidth", values.width);
494
+ yogaValues.setProperty(rt, "currentHeight", values.height);
495
+ yogaValues.setProperty(rt, "windowWidth", values.windowWidth);
496
+ yogaValues.setProperty(rt, "windowHeight", values.windowHeight);
497
+ nativeReanimatedModule_->layoutAnimationsManager().startLayoutAnimation(rt, tag, LayoutAnimationType::EXITING, yogaValues);
498
+ layoutAnimationsManager_->clearLayoutAnimationConfig(tag);
499
+ });
500
+ }
501
+
502
+ void LayoutAnimationsProxy::startLayoutAnimation(const int tag, ShadowViewMutation& mutation) const {
503
+ LOG(INFO)<<"start layout animation for tag "<<tag<<std::endl;
504
+ auto &oldChild = mutation.oldChildShadowView;
505
+ auto surfaceId = mutation.newChildShadowView.surfaceId;
506
+ if (layoutAnimations_.contains(tag)) {
507
+ oldChild = *layoutAnimations_.at(tag).current;
508
+ }
509
+ auto finalView = std::make_shared<ShadowView>(mutation.newChildShadowView);
510
+ auto current = std::make_shared<ShadowView>(oldChild);
511
+ LayoutAnimation la{finalView, current, oldChild, mutation.parentShadowView};
512
+ layoutAnimations_.insert_or_assign(tag, la);
513
+
514
+ Snapshot currentValues(oldChild, surfaceManager.getWindow(surfaceId));
515
+ Snapshot targetValues(mutation.newChildShadowView, surfaceManager.getWindow(surfaceId));
516
+
517
+ nativeReanimatedModule_->uiScheduler_->scheduleOnUI(
518
+ [currentValues, targetValues, this, tag]() {
519
+ jsi::Runtime &rt = nativeReanimatedModule_->getUIRuntime();
520
+ jsi::Object yogaValues(rt);
521
+ yogaValues.setProperty(rt, "currentOriginX", currentValues.x);
522
+ yogaValues.setProperty(rt, "currentGlobalOriginX", currentValues.x);
523
+ yogaValues.setProperty(rt, "currentOriginY", currentValues.y);
524
+ yogaValues.setProperty(rt, "currentGlobalOriginY", currentValues.y);
525
+ yogaValues.setProperty(rt, "currentWidth", currentValues.width);
526
+ yogaValues.setProperty(rt, "currentHeight", currentValues.height);
527
+ yogaValues.setProperty(rt, "targetOriginX", targetValues.x);
528
+ yogaValues.setProperty(rt, "targetGlobalOriginX", targetValues.x);
529
+ yogaValues.setProperty(rt, "targetOriginY", targetValues.y);
530
+ yogaValues.setProperty(rt, "targetGlobalOriginY", targetValues.y);
531
+ yogaValues.setProperty(rt, "targetWidth", targetValues.width);
532
+ yogaValues.setProperty(rt, "targetHeight", targetValues.height);
533
+ yogaValues.setProperty(rt, "windowWidth", targetValues.windowWidth);
534
+ yogaValues.setProperty(rt, "windowHeight", targetValues.windowHeight);
535
+ nativeReanimatedModule_->layoutAnimationsManager().startLayoutAnimation(rt, tag, LayoutAnimationType::LAYOUT, yogaValues);
536
+ });
537
+ }
538
+
539
+ void LayoutAnimationsProxy::cancelAnimation(const int tag) const{
540
+ bannedTags.insert(tag);
541
+ nativeReanimatedModule_->uiScheduler_->scheduleOnUI(
542
+ [this, tag]() {
543
+ jsi::Runtime &rt = nativeReanimatedModule_->getUIRuntime();
544
+ nativeReanimatedModule_->layoutAnimationsManager().cancelLayoutAnimation(rt, tag);
545
+ });
546
+ }
547
+
548
+ void LayoutAnimationsProxy::transferConfigFromNativeTag(const std::string nativeIdString, const int tag) const{
549
+ if (nativeIdString.empty()){
550
+ return;
551
+ }
552
+ // TODO: handle exception
553
+ auto nativeId = stoi(nativeIdString);
554
+ std::shared_ptr<Shareable> config = nullptr;
555
+ {
556
+ auto lock = std::unique_lock<std::recursive_mutex>(nativeReanimatedModule_->layoutAnimationsManager_->animationsMutex_);
557
+ config = layoutAnimationsManager_->enteringAnimations_[nativeId];
558
+ if (config) {
559
+ layoutAnimationsManager_->enteringAnimations_.insert_or_assign(tag, config);
560
+ }
561
+ layoutAnimationsManager_->enteringAnimations_.erase(nativeId);
562
+ }
563
+ }
564
+
565
+ } // namespace reanimated
@@ -0,0 +1,74 @@
1
+ #pragma once
2
+ #include "LayoutAnimationsManager.h"
3
+ #include "PropsRegistry.h"
4
+ #include <react/renderer/mounting/ShadowView.h>
5
+
6
+ #include <react/renderer/mounting/MountingOverrideDelegate.h>
7
+ #include <react/renderer/componentregistry/ComponentDescriptorFactory.h>
8
+ #include "LayoutAnimationsUtils.h"
9
+
10
+ namespace reanimated {
11
+
12
+ class NativeReanimatedModule;
13
+
14
+ using namespace facebook;
15
+
16
+ struct LayoutAnimation {
17
+ std::shared_ptr<ShadowView> end, current;
18
+ ShadowView start, parent;
19
+ std::optional<double> opacity;
20
+ LayoutAnimation& operator=(const LayoutAnimation& other){
21
+ this->end = other.end;
22
+ return *this;
23
+ }
24
+ };
25
+
26
+ struct LayoutAnimationsProxy : public MountingOverrideDelegate{
27
+ mutable std::unordered_map<Tag, std::shared_ptr<Node>> nodeForTag;
28
+ mutable std::unordered_map<Tag, LayoutAnimation> layoutAnimations_;
29
+ mutable std::unordered_map<Tag, std::shared_ptr<std::unordered_set<int>>> indices;
30
+ mutable std::unordered_set<Tag> animatedTags;
31
+ mutable std::recursive_mutex mutex;
32
+ mutable std::unordered_set<Tag> bannedTags;
33
+ mutable SurfaceManager surfaceManager;
34
+ std::shared_ptr<std::map<Tag, std::string>> tagToNativeID_ = std::make_shared<std::map<Tag, std::string>>();
35
+ std::shared_ptr<LayoutAnimationsManager> layoutAnimationsManager_;
36
+ ContextContainer::Shared contextContainer_;
37
+ NativeReanimatedModule* nativeReanimatedModule_;
38
+ SharedComponentDescriptorRegistry componentDescriptorRegistry_;
39
+ LayoutAnimationsProxy(std::shared_ptr<LayoutAnimationsManager> layoutAnimationsManager_, NativeReanimatedModule* n, SharedComponentDescriptorRegistry componentDescriptorRegistry_, ContextContainer::Shared contextContainer_): layoutAnimationsManager_(layoutAnimationsManager_), contextContainer_(contextContainer_), nativeReanimatedModule_(n), componentDescriptorRegistry_(componentDescriptorRegistry_){}
40
+
41
+ void startEnteringAnimation(const int tag, ShadowViewMutation& mutation) const;
42
+ void startExitingAnimation(const int tag, ShadowViewMutation& mutation) const;
43
+ void startLayoutAnimation(const int tag, ShadowViewMutation& mutation) const;
44
+
45
+ void transferConfigFromNativeTag(const std::string nativeId, const int tag) const;
46
+ std::optional<SurfaceId> progressLayoutAnimation(int tag, const jsi::Object &newStyle);
47
+ std::optional<SurfaceId> endLayoutAnimation(int tag, bool shouldRemove);
48
+ void cancelAnimation(const int tag) const;
49
+
50
+ void addOngoingAnimations(SurfaceId surfaceId, ShadowViewMutationList& mutations) const;
51
+
52
+ void updateIndexForMutation(ShadowViewMutation &mutation) const;
53
+ void updateIndices(ShadowViewMutation &mutation) const;
54
+ void takeIndex(Tag parentTag, int index) const;
55
+ void dropIndex(Tag parentTag, int index) const;
56
+
57
+ void removeRecursively(std::shared_ptr<MutationNode> node, ShadowViewMutationList& mutations) const;
58
+ bool startAnimationsRecursively(std::shared_ptr<MutationNode> node, bool shouldRemoveSubviewsWithoutAnimations, bool shouldAnimate, ShadowViewMutationList& mutations) const;
59
+ void endAnimationsRecursively(std::shared_ptr<MutationNode> node, ShadowViewMutationList& mutations) const;
60
+ void maybeDropAncestors(std::shared_ptr<Node> node, std::shared_ptr<MutationNode> child, ShadowViewMutationList& cleanupMutations) const;
61
+
62
+ const ComponentDescriptor& getComponentDescriptorForShadowView(const ShadowView& shadowView) const;
63
+
64
+ // MountingOverrideDelegate
65
+
66
+ bool shouldOverridePullTransaction() const override;
67
+ std::optional<MountingTransaction> pullTransaction(
68
+ SurfaceId surfaceId,
69
+ MountingTransaction::Number number,
70
+ const TransactionTelemetry& telemetry,
71
+ ShadowViewMutationList mutations) const override;
72
+ };
73
+
74
+ }