react-native-reanimated 3.0.0-rc.1 → 3.0.0-rc.10

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 (377) hide show
  1. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +35 -37
  2. package/Common/cpp/{headers/AnimatedSensor → AnimatedSensor}/AnimatedSensorModule.h +4 -3
  3. package/Common/cpp/Fabric/FabricUtils.cpp +4 -103
  4. package/Common/cpp/{headers/Fabric → Fabric}/FabricUtils.h +3 -24
  5. package/Common/cpp/Fabric/ReanimatedUIManagerBinding.cpp +56 -37
  6. package/Common/cpp/{headers/Fabric → Fabric}/ReanimatedUIManagerBinding.h +0 -0
  7. package/Common/cpp/{headers/Fabric → Fabric}/ShadowTreeCloner.h +1 -1
  8. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +76 -0
  9. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +41 -0
  10. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +205 -191
  11. package/Common/cpp/{headers/NativeModules → NativeModules}/NativeReanimatedModule.h +42 -28
  12. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +36 -29
  13. package/Common/cpp/{headers/NativeModules → NativeModules}/NativeReanimatedModuleSpec.h +20 -13
  14. package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +138 -0
  15. package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +134 -0
  16. package/Common/cpp/ReanimatedRuntime/ReanimatedRuntime.cpp +55 -0
  17. package/Common/cpp/ReanimatedRuntime/ReanimatedRuntime.h +28 -0
  18. package/Common/cpp/ReanimatedRuntime/RuntimeInitialization.md +194 -0
  19. package/Common/cpp/{headers/Registries → Registries}/EventHandlerRegistry.h +0 -0
  20. package/Common/cpp/{headers/Registries → Registries}/NewestShadowNodesRegistry.h +0 -0
  21. package/Common/cpp/{headers/SharedItems → SharedItems}/RuntimeManager.h +1 -34
  22. package/Common/cpp/SharedItems/Shareables.cpp +144 -0
  23. package/Common/cpp/SharedItems/Shareables.h +470 -0
  24. package/Common/cpp/{headers/SharedItems → SharedItems}/SharedParent.h +0 -0
  25. package/Common/cpp/{headers/SpecTools → SpecTools}/ErrorHandler.h +0 -0
  26. package/Common/cpp/{headers/Tools → Tools}/FeaturesConfig.h +0 -0
  27. package/Common/cpp/{headers/Tools → Tools}/PlatformDepMethodsHolder.h +6 -0
  28. package/Common/cpp/{headers/Tools → Tools}/ReanimatedHiddenHeaders.h +1 -1
  29. package/Common/cpp/Tools/ReanimatedVersion.cpp +17 -0
  30. package/Common/cpp/Tools/ReanimatedVersion.h +11 -0
  31. package/Common/cpp/Tools/RuntimeDecorator.cpp +80 -50
  32. package/Common/cpp/{headers/Tools → Tools}/RuntimeDecorator.h +13 -3
  33. package/Common/cpp/Tools/Scheduler.cpp +10 -0
  34. package/Common/cpp/{headers/Tools → Tools}/Scheduler.h +0 -0
  35. package/Common/cpp/Tools/SingleInstanceChecker.h +58 -0
  36. package/Common/cpp/{headers/Tools → Tools}/WorkletEventHandler.h +0 -0
  37. package/RNReanimated.podspec +22 -85
  38. package/android/CMakeLists.txt +199 -209
  39. package/android/build.gradle +708 -339
  40. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  41. package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +26 -33
  42. package/android/src/main/cpp/AndroidErrorHandler.cpp +3 -4
  43. package/android/src/main/cpp/{headers/AndroidErrorHandler.h → AndroidErrorHandler.h} +1 -4
  44. package/android/src/main/cpp/AndroidLogger.cpp +4 -1
  45. package/android/src/main/cpp/{headers/AndroidLogger.h → AndroidLogger.h} +0 -0
  46. package/android/src/main/cpp/{headers/AndroidScheduler.h → AndroidScheduler.h} +0 -0
  47. package/android/src/main/cpp/{headers/JNIHelper.h → JNIHelper.h} +0 -0
  48. package/android/src/main/cpp/LayoutAnimations.cpp +39 -57
  49. package/android/src/main/cpp/LayoutAnimations.h +56 -0
  50. package/android/src/main/cpp/NativeProxy.cpp +69 -46
  51. package/android/src/main/cpp/{headers/NativeProxy.h → NativeProxy.h} +4 -2
  52. package/android/src/main/cpp/{headers/TurboModule.h → TurboModule.h} +0 -0
  53. package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +1 -1
  54. package/android/src/main/java/com/swmansion/reanimated/ReanimatedMessageQueueThreadBase.java +72 -0
  55. package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +5 -4
  56. package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +2 -1
  57. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +240 -222
  58. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +7 -5
  59. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +5 -3
  60. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ViewHierarchyObserver.java +1 -1
  61. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +1 -1
  62. package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +27 -14
  63. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +16 -0
  64. package/android/src/{main/java → reactNativeVersionPatch/ReanimatedUIManager/70}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +1 -1
  65. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +63 -0
  66. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +271 -0
  67. package/android/{rnVersionPatch/62 → src/reactNativeVersionPatch/UIImplementation/64/com/swmansion/reanimated}/layoutReanimation/ReanimatedUIImplementation.java +0 -0
  68. package/android/src/{main/java → reactNativeVersionPatch/UIImplementation/latest}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIImplementation.java +0 -0
  69. package/android/src/reactNativeVersionPatch/messageQueueThread/67/com/swmansion/reanimated/ReanimatedMessageQueueThread.java +12 -0
  70. package/android/src/reactNativeVersionPatch/messageQueueThread/latest/com/swmansion/reanimated/ReanimatedMessageQueueThread.java +12 -0
  71. package/android/{rnVersionPatch/62 → src/reactNativeVersionPatch/nativeHierarchyManager/62/com/swmansion/reanimated}/layoutReanimation/ReanimatedNativeHierarchyManager.java +8 -44
  72. package/android/src/{main/java → reactNativeVersionPatch/nativeHierarchyManager/latest}/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +23 -91
  73. package/ios/LayoutReanimation/REAAnimationsManager.h +20 -8
  74. package/ios/LayoutReanimation/REAAnimationsManager.m +251 -160
  75. package/ios/LayoutReanimation/REAUIManager.mm +36 -83
  76. package/ios/REAModule.mm +35 -5
  77. package/ios/keyboardObserver/REAKeyboardEventObserver.m +1 -1
  78. package/ios/native/NativeProxy.mm +60 -75
  79. package/ios/native/REAInitializer.h +2 -2
  80. package/ios/native/REAInitializer.mm +6 -2
  81. package/ios/native/REAMessageThread.h +22 -0
  82. package/ios/native/REAMessageThread.mm +38 -0
  83. package/ios/native/UIResponder+Reanimated.mm +1 -1
  84. package/lib/commonjs/createAnimatedComponent.js +33 -34
  85. package/lib/commonjs/createAnimatedComponent.js.map +1 -1
  86. package/lib/commonjs/reanimated2/Colors.js +43 -22
  87. package/lib/commonjs/reanimated2/Colors.js.map +1 -1
  88. package/lib/commonjs/reanimated2/NativeMethods.js +67 -31
  89. package/lib/commonjs/reanimated2/NativeMethods.js.map +1 -1
  90. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +32 -23
  91. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  92. package/lib/commonjs/reanimated2/ViewDescriptorsSet.js +27 -55
  93. package/lib/commonjs/reanimated2/ViewDescriptorsSet.js.map +1 -1
  94. package/lib/commonjs/reanimated2/WorkletEventHandler.js +5 -3
  95. package/lib/commonjs/reanimated2/WorkletEventHandler.js.map +1 -1
  96. package/lib/commonjs/reanimated2/animation/delay.js +0 -12
  97. package/lib/commonjs/reanimated2/animation/delay.js.map +1 -1
  98. package/lib/commonjs/reanimated2/animation/repeat.js +0 -24
  99. package/lib/commonjs/reanimated2/animation/repeat.js.map +1 -1
  100. package/lib/commonjs/reanimated2/animation/sequence.js +0 -12
  101. package/lib/commonjs/reanimated2/animation/sequence.js.map +1 -1
  102. package/lib/commonjs/reanimated2/animation/util.js +14 -14
  103. package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
  104. package/lib/commonjs/reanimated2/commonTypes.js +7 -0
  105. package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
  106. package/lib/commonjs/reanimated2/component/FlatList.js +19 -3
  107. package/lib/commonjs/reanimated2/component/FlatList.js.map +1 -1
  108. package/lib/commonjs/reanimated2/core.js +77 -243
  109. package/lib/commonjs/reanimated2/core.js.map +1 -1
  110. package/lib/commonjs/reanimated2/errors.js +66 -0
  111. package/lib/commonjs/reanimated2/errors.js.map +1 -0
  112. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryJS.js +4 -4
  113. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryJS.js.map +1 -1
  114. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +51 -19
  115. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  116. package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
  117. package/lib/commonjs/reanimated2/hook/index.js +8 -0
  118. package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
  119. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +15 -9
  120. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  121. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +18 -8
  122. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
  123. package/lib/commonjs/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
  124. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +27 -36
  125. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  126. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +23 -59
  127. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  128. package/lib/commonjs/reanimated2/hook/useFrameCallback.js.map +1 -1
  129. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +33 -0
  130. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -0
  131. package/lib/commonjs/reanimated2/hook/useSharedValue.js +3 -2
  132. package/lib/commonjs/reanimated2/hook/useSharedValue.js.map +1 -1
  133. package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
  134. package/lib/commonjs/reanimated2/initializers.js +157 -0
  135. package/lib/commonjs/reanimated2/initializers.js.map +1 -0
  136. package/lib/commonjs/reanimated2/interpolateColor.js +96 -19
  137. package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
  138. package/lib/commonjs/reanimated2/jestUtils.js +25 -42
  139. package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
  140. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +14 -103
  141. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  142. package/lib/commonjs/reanimated2/js-reanimated/global.js +4 -7
  143. package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
  144. package/lib/commonjs/reanimated2/js-reanimated/index.js +5 -0
  145. package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
  146. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  147. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  148. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +87 -0
  149. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -0
  150. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -23
  151. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  152. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -14
  153. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  154. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -14
  155. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  156. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -15
  157. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  158. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -23
  159. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  160. package/lib/commonjs/reanimated2/layoutReanimation/index.js +1 -1
  161. package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
  162. package/lib/commonjs/reanimated2/mappers.js +186 -0
  163. package/lib/commonjs/reanimated2/mappers.js.map +1 -0
  164. package/lib/commonjs/reanimated2/mock.js +26 -0
  165. package/lib/commonjs/reanimated2/mock.js.map +1 -1
  166. package/lib/commonjs/reanimated2/mutables.js +173 -0
  167. package/lib/commonjs/reanimated2/mutables.js.map +1 -0
  168. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +33 -0
  169. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +1 -0
  170. package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +15 -0
  171. package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
  172. package/lib/commonjs/reanimated2/shareables.js +159 -0
  173. package/lib/commonjs/reanimated2/shareables.js.map +1 -0
  174. package/lib/commonjs/reanimated2/threads.js +68 -0
  175. package/lib/commonjs/reanimated2/threads.js.map +1 -0
  176. package/lib/commonjs/reanimated2/time.js +55 -0
  177. package/lib/commonjs/reanimated2/time.js.map +1 -0
  178. package/lib/commonjs/reanimated2/utils.js +12 -3
  179. package/lib/commonjs/reanimated2/utils.js.map +1 -1
  180. package/lib/commonjs/reanimated2/valueSetter.js +81 -0
  181. package/lib/commonjs/reanimated2/valueSetter.js.map +1 -0
  182. package/lib/module/createAnimatedComponent.js +33 -34
  183. package/lib/module/createAnimatedComponent.js.map +1 -1
  184. package/lib/module/reanimated2/Colors.js +35 -19
  185. package/lib/module/reanimated2/Colors.js.map +1 -1
  186. package/lib/module/reanimated2/NativeMethods.js +68 -30
  187. package/lib/module/reanimated2/NativeMethods.js.map +1 -1
  188. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +31 -23
  189. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  190. package/lib/module/reanimated2/ViewDescriptorsSet.js +27 -53
  191. package/lib/module/reanimated2/ViewDescriptorsSet.js.map +1 -1
  192. package/lib/module/reanimated2/WorkletEventHandler.js +4 -3
  193. package/lib/module/reanimated2/WorkletEventHandler.js.map +1 -1
  194. package/lib/module/reanimated2/animation/delay.js +0 -10
  195. package/lib/module/reanimated2/animation/delay.js.map +1 -1
  196. package/lib/module/reanimated2/animation/repeat.js +0 -20
  197. package/lib/module/reanimated2/animation/repeat.js.map +1 -1
  198. package/lib/module/reanimated2/animation/sequence.js +0 -10
  199. package/lib/module/reanimated2/animation/sequence.js.map +1 -1
  200. package/lib/module/reanimated2/animation/util.js +15 -15
  201. package/lib/module/reanimated2/animation/util.js.map +1 -1
  202. package/lib/module/reanimated2/commonTypes.js +7 -0
  203. package/lib/module/reanimated2/commonTypes.js.map +1 -1
  204. package/lib/module/reanimated2/component/FlatList.js +18 -4
  205. package/lib/module/reanimated2/component/FlatList.js.map +1 -1
  206. package/lib/module/reanimated2/core.js +34 -229
  207. package/lib/module/reanimated2/core.js.map +1 -1
  208. package/lib/module/reanimated2/errors.js +58 -0
  209. package/lib/module/reanimated2/errors.js.map +1 -0
  210. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js +4 -4
  211. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js.map +1 -1
  212. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +51 -19
  213. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  214. package/lib/module/reanimated2/globals.d.js.map +1 -1
  215. package/lib/module/reanimated2/hook/index.js +1 -0
  216. package/lib/module/reanimated2/hook/index.js.map +1 -1
  217. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +16 -6
  218. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  219. package/lib/module/reanimated2/hook/useAnimatedRef.js +17 -8
  220. package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
  221. package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
  222. package/lib/module/reanimated2/hook/useAnimatedSensor.js +29 -34
  223. package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  224. package/lib/module/reanimated2/hook/useAnimatedStyle.js +26 -62
  225. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  226. package/lib/module/reanimated2/hook/useFrameCallback.js.map +1 -1
  227. package/lib/module/reanimated2/hook/useScrollViewOffset.js +21 -0
  228. package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -0
  229. package/lib/module/reanimated2/hook/useSharedValue.js +3 -2
  230. package/lib/module/reanimated2/hook/useSharedValue.js.map +1 -1
  231. package/lib/module/reanimated2/hook/utils.js.map +1 -1
  232. package/lib/module/reanimated2/initializers.js +143 -0
  233. package/lib/module/reanimated2/initializers.js.map +1 -0
  234. package/lib/module/reanimated2/interpolateColor.js +96 -19
  235. package/lib/module/reanimated2/interpolateColor.js.map +1 -1
  236. package/lib/module/reanimated2/jestUtils.js +25 -40
  237. package/lib/module/reanimated2/jestUtils.js.map +1 -1
  238. package/lib/module/reanimated2/js-reanimated/JSReanimated.js +14 -98
  239. package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  240. package/lib/module/reanimated2/js-reanimated/global.js +4 -7
  241. package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
  242. package/lib/module/reanimated2/js-reanimated/index.js +5 -0
  243. package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
  244. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  245. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  246. package/lib/module/reanimated2/layoutReanimation/animationsManager.js +82 -0
  247. package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -0
  248. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -21
  249. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  250. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -12
  251. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  252. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
  253. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  254. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -13
  255. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  256. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -21
  257. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  258. package/lib/module/reanimated2/layoutReanimation/index.js +1 -1
  259. package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
  260. package/lib/module/reanimated2/mappers.js +173 -0
  261. package/lib/module/reanimated2/mappers.js.map +1 -0
  262. package/lib/module/reanimated2/mock.js +26 -0
  263. package/lib/module/reanimated2/mock.js.map +1 -1
  264. package/lib/module/reanimated2/mutables.js +149 -0
  265. package/lib/module/reanimated2/mutables.js.map +1 -0
  266. package/lib/module/reanimated2/platform-specific/checkVersion.js +25 -0
  267. package/lib/module/reanimated2/platform-specific/checkVersion.js.map +1 -0
  268. package/lib/module/reanimated2/platform-specific/checkVersion.web.js +8 -0
  269. package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
  270. package/lib/module/reanimated2/shareables.js +138 -0
  271. package/lib/module/reanimated2/shareables.js.map +1 -0
  272. package/lib/module/reanimated2/threads.js +56 -0
  273. package/lib/module/reanimated2/threads.js.map +1 -0
  274. package/lib/module/reanimated2/time.js +37 -0
  275. package/lib/module/reanimated2/time.js.map +1 -0
  276. package/lib/module/reanimated2/utils.js +13 -3
  277. package/lib/module/reanimated2/utils.js.map +1 -1
  278. package/lib/module/reanimated2/valueSetter.js +66 -0
  279. package/lib/module/reanimated2/valueSetter.js.map +1 -0
  280. package/package.json +14 -9
  281. package/plugin.js +198 -61
  282. package/react-native-reanimated.d.ts +1250 -0
  283. package/scripts/reanimated_utils.rb +81 -0
  284. package/src/createAnimatedComponent.tsx +44 -44
  285. package/src/reanimated2/Colors.ts +38 -11
  286. package/src/reanimated2/NativeMethods.ts +91 -44
  287. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +54 -45
  288. package/src/reanimated2/ViewDescriptorsSet.ts +30 -69
  289. package/src/reanimated2/WorkletEventHandler.ts +4 -11
  290. package/src/reanimated2/animation/delay.ts +0 -12
  291. package/src/reanimated2/animation/repeat.ts +0 -25
  292. package/src/reanimated2/animation/sequence.ts +0 -13
  293. package/src/reanimated2/animation/util.ts +27 -15
  294. package/src/reanimated2/commonTypes.ts +38 -4
  295. package/src/reanimated2/component/FlatList.tsx +30 -5
  296. package/src/reanimated2/core.ts +79 -260
  297. package/src/reanimated2/errors.ts +57 -0
  298. package/src/reanimated2/frameCallback/FrameCallbackRegistryJS.ts +6 -9
  299. package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +78 -27
  300. package/src/reanimated2/globals.d.ts +94 -27
  301. package/src/reanimated2/hook/index.ts +1 -0
  302. package/src/reanimated2/hook/useAnimatedKeyboard.ts +18 -9
  303. package/src/reanimated2/hook/useAnimatedRef.ts +27 -9
  304. package/src/reanimated2/hook/useAnimatedScrollHandler.ts +3 -1
  305. package/src/reanimated2/hook/useAnimatedSensor.ts +33 -31
  306. package/src/reanimated2/hook/useAnimatedStyle.ts +26 -74
  307. package/src/reanimated2/hook/useFrameCallback.ts +2 -1
  308. package/src/reanimated2/hook/useScrollViewOffset.ts +37 -0
  309. package/src/reanimated2/hook/useSharedValue.ts +6 -3
  310. package/src/reanimated2/hook/utils.ts +1 -1
  311. package/src/reanimated2/initializers.ts +143 -0
  312. package/src/reanimated2/interpolateColor.ts +106 -22
  313. package/src/reanimated2/jestUtils.ts +28 -35
  314. package/src/reanimated2/js-reanimated/JSReanimated.ts +24 -94
  315. package/src/reanimated2/js-reanimated/global.ts +4 -7
  316. package/src/reanimated2/js-reanimated/index.ts +4 -0
  317. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +11 -0
  318. package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
  319. package/src/reanimated2/layoutReanimation/animationsManager.ts +91 -0
  320. package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +16 -19
  321. package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +14 -11
  322. package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +21 -11
  323. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -11
  324. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +36 -19
  325. package/src/reanimated2/layoutReanimation/index.ts +1 -1
  326. package/src/reanimated2/mappers.ts +179 -0
  327. package/src/reanimated2/mock.ts +105 -0
  328. package/src/reanimated2/mutables.ts +151 -0
  329. package/src/reanimated2/platform-specific/checkVersion.ts +28 -0
  330. package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
  331. package/src/reanimated2/shareables.ts +128 -0
  332. package/src/reanimated2/threads.ts +58 -0
  333. package/src/reanimated2/time.ts +30 -0
  334. package/src/reanimated2/utils.ts +12 -5
  335. package/src/reanimated2/valueSetter.ts +64 -0
  336. package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp +0 -43
  337. package/Common/cpp/Registries/MapperRegistry.cpp +0 -145
  338. package/Common/cpp/Registries/WorkletsCache.cpp +0 -38
  339. package/Common/cpp/SharedItems/FrozenObject.cpp +0 -35
  340. package/Common/cpp/SharedItems/MutableValue.cpp +0 -132
  341. package/Common/cpp/SharedItems/MutableValueSetterProxy.cpp +0 -47
  342. package/Common/cpp/SharedItems/RemoteObject.cpp +0 -45
  343. package/Common/cpp/SharedItems/ShareableValue.cpp +0 -525
  344. package/Common/cpp/Tools/JSIStoreValueUser.cpp +0 -55
  345. package/Common/cpp/Tools/Mapper.cpp +0 -86
  346. package/Common/cpp/headers/LayoutAnimations/LayoutAnimationsProxy.h +0 -32
  347. package/Common/cpp/headers/Registries/MapperRegistry.h +0 -29
  348. package/Common/cpp/headers/Registries/WorkletsCache.h +0 -24
  349. package/Common/cpp/headers/SharedItems/FrozenObject.h +0 -36
  350. package/Common/cpp/headers/SharedItems/HostFunctionHandler.h +0 -28
  351. package/Common/cpp/headers/SharedItems/MutableValue.h +0 -54
  352. package/Common/cpp/headers/SharedItems/MutableValueSetterProxy.h +0 -25
  353. package/Common/cpp/headers/SharedItems/RemoteObject.h +0 -35
  354. package/Common/cpp/headers/SharedItems/ShareableValue.h +0 -63
  355. package/Common/cpp/headers/SharedItems/ValueWrapper.h +0 -183
  356. package/Common/cpp/headers/Tools/JSIStoreValueUser.h +0 -37
  357. package/Common/cpp/headers/Tools/Mapper.h +0 -51
  358. package/android/rnVersionPatch/63/layoutReanimation/ReanimatedUIImplementation.java +0 -68
  359. package/android/rnVersionPatch/64/layoutReanimation/ReanimatedUIImplementation.java +0 -68
  360. package/android/rnVersionPatch/65/.gitkeep +0 -0
  361. package/android/rnVersionPatch/66/.gitkeep +0 -0
  362. package/android/rnVersionPatch/67/.gitkeep +0 -0
  363. package/android/rnVersionPatch/68/.gitkeep +0 -0
  364. package/android/rnVersionPatch/backup/.gitkeep +0 -0
  365. package/android/src/main/cpp/headers/LayoutAnimations.h +0 -42
  366. package/android/src/main/java/com/swmansion/reanimated/AndroidErrorHandler.java +0 -8
  367. package/android/src/main/java/com/swmansion/reanimated/ReanimatedJSIModulePackage.java +0 -29
  368. package/lib/commonjs/reanimated2/layoutReanimation/LayoutAnimationRepository.js +0 -97
  369. package/lib/commonjs/reanimated2/layoutReanimation/LayoutAnimationRepository.js.map +0 -1
  370. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Default.js +0 -55
  371. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Default.js.map +0 -1
  372. package/lib/module/reanimated2/layoutReanimation/LayoutAnimationRepository.js +0 -91
  373. package/lib/module/reanimated2/layoutReanimation/LayoutAnimationRepository.js.map +0 -1
  374. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Default.js +0 -40
  375. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Default.js.map +0 -1
  376. package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +0 -75
  377. package/src/reanimated2/layoutReanimation/defaultAnimations/Default.ts +0 -49
@@ -1,16 +1,17 @@
1
1
  #include "AnimatedSensorModule.h"
2
- #include "MutableValue.h"
3
- #include "ValueWrapper.h"
2
+
3
+ #include <memory>
4
+ #include <utility>
5
+
6
+ #include "Shareables.h"
4
7
 
5
8
  namespace reanimated {
6
9
 
7
10
  AnimatedSensorModule::AnimatedSensorModule(
8
- const PlatformDepMethodsHolder &platformDepMethodsHolder,
9
- RuntimeManager *runtimeManager)
11
+ const PlatformDepMethodsHolder &platformDepMethodsHolder)
10
12
  : platformRegisterSensorFunction_(platformDepMethodsHolder.registerSensor),
11
13
  platformUnregisterSensorFunction_(
12
- platformDepMethodsHolder.unregisterSensor),
13
- runtimeManager_(runtimeManager) {}
14
+ platformDepMethodsHolder.unregisterSensor) {}
14
15
 
15
16
  AnimatedSensorModule::~AnimatedSensorModule() {
16
17
  // It is called during app reload because app reload doesn't call hooks
@@ -22,41 +23,38 @@ AnimatedSensorModule::~AnimatedSensorModule() {
22
23
 
23
24
  jsi::Value AnimatedSensorModule::registerSensor(
24
25
  jsi::Runtime &rt,
25
- const jsi::Value &sensorType,
26
+ const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
27
+ const jsi::Value &sensorTypeValue,
26
28
  const jsi::Value &interval,
27
- const jsi::Value &sensorDataContainer) {
28
- std::shared_ptr<ShareableValue> sensorsData = ShareableValue::adapt(
29
- rt, sensorDataContainer.getObject(rt), runtimeManager_);
30
- auto &mutableObject =
31
- ValueWrapper::asMutableValue(sensorsData->valueContainer);
29
+ const jsi::Value &sensorDataHandler) {
30
+ SensorType sensorType = static_cast<SensorType>(sensorTypeValue.asNumber());
32
31
 
33
- std::function<void(double[])> setter;
34
- if (sensorType.asNumber() == SensorType::ROTATION_VECTOR) {
35
- setter = [&, mutableObject](double newValues[]) {
36
- jsi::Runtime &runtime = *runtimeManager_->runtime.get();
37
- jsi::Object value(runtime);
38
- value.setProperty(runtime, "qx", newValues[0]);
39
- value.setProperty(runtime, "qy", newValues[1]);
40
- value.setProperty(runtime, "qz", newValues[2]);
41
- value.setProperty(runtime, "qw", newValues[3]);
42
- value.setProperty(runtime, "yaw", newValues[4]);
43
- value.setProperty(runtime, "pitch", newValues[5]);
44
- value.setProperty(runtime, "roll", newValues[6]);
45
- mutableObject->setValue(runtime, std::move(value));
46
- };
47
- } else {
48
- setter = [&, mutableObject](double newValues[]) {
49
- jsi::Runtime &runtime = *runtimeManager_->runtime.get();
50
- jsi::Object value(runtime);
51
- value.setProperty(runtime, "x", newValues[0]);
52
- value.setProperty(runtime, "y", newValues[1]);
53
- value.setProperty(runtime, "z", newValues[2]);
54
- mutableObject->setValue(runtime, std::move(value));
55
- };
56
- }
32
+ auto shareableHandler = extractShareableOrThrow(rt, sensorDataHandler);
33
+ auto uiRuntime = runtimeHelper->uiRuntime();
57
34
 
58
35
  int sensorId = platformRegisterSensorFunction_(
59
- sensorType.asNumber(), interval.asNumber(), setter);
36
+ sensorType, interval.asNumber(), [=](double newValues[]) {
37
+ jsi::Runtime &rt = *uiRuntime;
38
+ auto handler =
39
+ shareableHandler->getJSValue(rt).asObject(rt).asFunction(rt);
40
+ if (sensorType == SensorType::ROTATION_VECTOR) {
41
+ jsi::Object value(rt);
42
+ value.setProperty(rt, "qx", newValues[0]);
43
+ value.setProperty(rt, "qy", newValues[1]);
44
+ value.setProperty(rt, "qz", newValues[2]);
45
+ value.setProperty(rt, "qw", newValues[3]);
46
+ value.setProperty(rt, "yaw", newValues[4]);
47
+ value.setProperty(rt, "pitch", newValues[5]);
48
+ value.setProperty(rt, "roll", newValues[6]);
49
+ handler.call(rt, value);
50
+ } else {
51
+ jsi::Object value(rt);
52
+ value.setProperty(rt, "x", newValues[0]);
53
+ value.setProperty(rt, "y", newValues[1]);
54
+ value.setProperty(rt, "z", newValues[2]);
55
+ handler.call(rt, value);
56
+ }
57
+ });
60
58
  if (sensorId != -1) {
61
59
  sensorsIds_.insert(sensorId);
62
60
  }
@@ -1,10 +1,12 @@
1
1
  #pragma once
2
2
 
3
3
  #include <jsi/jsi.h>
4
+ #include <memory>
4
5
  #include <unordered_set>
5
6
 
6
7
  #include "PlatformDepMethodsHolder.h"
7
8
  #include "RuntimeManager.h"
9
+ #include "Shareables.h"
8
10
 
9
11
  namespace reanimated {
10
12
 
@@ -22,16 +24,15 @@ class AnimatedSensorModule {
22
24
  std::unordered_set<int> sensorsIds_;
23
25
  RegisterSensorFunction platformRegisterSensorFunction_;
24
26
  UnregisterSensorFunction platformUnregisterSensorFunction_;
25
- RuntimeManager *runtimeManager_;
26
27
 
27
28
  public:
28
29
  AnimatedSensorModule(
29
- const PlatformDepMethodsHolder &platformDepMethodsHolder,
30
- RuntimeManager *runtimeManager);
30
+ const PlatformDepMethodsHolder &platformDepMethodsHolder);
31
31
  ~AnimatedSensorModule();
32
32
 
33
33
  jsi::Value registerSensor(
34
34
  jsi::Runtime &rt,
35
+ const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
35
36
  const jsi::Value &sensorType,
36
37
  const jsi::Value &interval,
37
38
  const jsi::Value &sensorDataContainer);
@@ -1,12 +1,13 @@
1
1
  #ifdef RCT_NEW_ARCH_ENABLED
2
2
 
3
- #if RNVERSION < 69
3
+ #if REACT_NATIVE_MINOR_VERSION < 69
4
4
  #error \
5
5
  "Reanimated 3 does not support React Native 0.68.x when Fabric is enabled. Please upgrade to React Native 0.69.0 or newer if you want to use Reanimated with the new architecture."
6
6
  #endif
7
7
 
8
8
  #include "FabricUtils.h"
9
9
 
10
+ #include <react/renderer/debug/SystraceSection.h>
10
11
  #include <react/renderer/uimanager/UIManagerBinding.h>
11
12
 
12
13
  using namespace facebook::react;
@@ -22,110 +23,10 @@ RuntimeExecutor getRuntimeExecutorFromBinding(Binding *binding) {
22
23
  }
23
24
  #endif
24
25
 
25
- inline static const UIManagerPublic *getUIManagerPublic(
26
- const UIManager *uiManager) {
27
- return reinterpret_cast<const UIManagerPublic *>(uiManager);
28
- }
29
-
30
26
  std::shared_ptr<const ContextContainer> getContextContainerFromUIManager(
31
27
  const UIManager *uiManager) {
32
- return getUIManagerPublic(uiManager)->contextContainer_;
33
- }
34
-
35
- inline static UIManagerDelegate *getDelegateFromUIManager(
36
- const UIManager *uiManager) {
37
- return getUIManagerPublic(uiManager)->delegate_;
38
- }
39
-
40
- void UIManager_dispatchCommand(
41
- const std::shared_ptr<UIManager> &uiManager,
42
- const ShadowNode::Shared &shadowNode,
43
- std::string const &commandName,
44
- folly::dynamic const &args) {
45
- auto delegate_ = getDelegateFromUIManager(&*uiManager);
46
-
47
- // copied from UIManager.cpp
48
- if (delegate_) {
49
- delegate_->uiManagerDidDispatchCommand(shadowNode, commandName, args);
50
- }
51
- }
52
-
53
- LayoutMetrics UIManager_getRelativeLayoutMetrics(
54
- const std::shared_ptr<UIManager> &uiManager,
55
- ShadowNode const &shadowNode,
56
- ShadowNode const *ancestorShadowNode,
57
- LayoutableShadowNode::LayoutInspectingPolicy policy) {
58
- // based on implementation from UIManager.cpp
59
- const auto &shadowTreeRegistry = uiManager->getShadowTreeRegistry();
60
-
61
- // We might store here an owning pointer to `ancestorShadowNode` to ensure
62
- // that the node is not deallocated during method execution lifetime.
63
- auto owningAncestorShadowNode = ShadowNode::Shared{};
64
-
65
- if (!ancestorShadowNode) {
66
- shadowTreeRegistry.visit(
67
- shadowNode.getSurfaceId(), [&](ShadowTree const &shadowTree) {
68
- owningAncestorShadowNode =
69
- shadowTree.getCurrentRevision().rootShadowNode;
70
- ancestorShadowNode = owningAncestorShadowNode.get();
71
- });
72
- } else {
73
- // It is possible for JavaScript (or other callers) to have a reference
74
- // to a previous version of ShadowNodes, but we enforce that
75
- // metrics are only calculated on most recently committed versions.
76
- owningAncestorShadowNode =
77
- uiManager->getNewestCloneOfShadowNode(*ancestorShadowNode);
78
- ancestorShadowNode = owningAncestorShadowNode.get();
79
- }
80
-
81
- auto layoutableAncestorShadowNode =
82
- traitCast<LayoutableShadowNode const *>(ancestorShadowNode);
83
-
84
- if (!layoutableAncestorShadowNode) {
85
- return EmptyLayoutMetrics;
86
- }
87
-
88
- return LayoutableShadowNode::computeRelativeLayoutMetrics(
89
- shadowNode.getFamily(), *layoutableAncestorShadowNode, policy);
90
- }
91
-
92
- ShadowNode::Shared UIManager_cloneNode(
93
- const UIManager *uiManager,
94
- const ShadowNode::Shared &shadowNode,
95
- const ShadowNode::SharedListOfShared &children,
96
- const RawProps *rawProps) {
97
- auto delegate_ = getDelegateFromUIManager(uiManager);
98
- auto contextContainer_ = getContextContainerFromUIManager(uiManager);
99
-
100
- // copied from UIManager.cpp
101
- PropsParserContext propsParserContext{
102
- shadowNode->getFamily().getSurfaceId(), *contextContainer_.get()};
103
-
104
- auto &componentDescriptor = shadowNode->getComponentDescriptor();
105
- auto clonedShadowNode = componentDescriptor.cloneShadowNode(
106
- *shadowNode,
107
- {
108
- /* .props = */
109
- rawProps ? componentDescriptor.cloneProps(
110
- propsParserContext, shadowNode->getProps(), *rawProps)
111
- : ShadowNodeFragment::propsPlaceholder(),
112
- /* .children = */ children,
113
- });
114
-
115
- if (delegate_) {
116
- delegate_->uiManagerDidCloneShadowNode(
117
- *shadowNode.get(), *clonedShadowNode);
118
- }
119
-
120
- return clonedShadowNode;
121
- }
122
-
123
- void UIManager_appendChild(
124
- const ShadowNode::Shared &parentShadowNode,
125
- const ShadowNode::Shared &childShadowNode) {
126
- // copied from UIManager.cpp
127
- auto &componentDescriptor = parentShadowNode->getComponentDescriptor();
128
- componentDescriptor.appendChild(parentShadowNode, childShadowNode);
28
+ return reinterpret_cast<const UIManagerPublic *>(uiManager)
29
+ ->contextContainer_;
129
30
  }
130
31
 
131
32
  } // namespace reanimated
@@ -2,15 +2,16 @@
2
2
  #ifdef RCT_NEW_ARCH_ENABLED
3
3
 
4
4
  #ifdef ANDROID
5
- #include <Binding.h>
6
5
  #include <fbjni/fbjni.h>
6
+ #include <react/fabric/Binding.h>
7
7
  #endif
8
8
  #include <react/renderer/uimanager/UIManager.h>
9
9
 
10
10
  #include <memory>
11
11
  #include <string>
12
12
 
13
- using namespace facebook::react;
13
+ using namespace facebook;
14
+ using namespace react;
14
15
 
15
16
  namespace reanimated {
16
17
 
@@ -52,28 +53,6 @@ RuntimeExecutor getRuntimeExecutorFromBinding(Binding *binding);
52
53
  std::shared_ptr<const ContextContainer> getContextContainerFromUIManager(
53
54
  const UIManager *uiManager);
54
55
 
55
- void UIManager_dispatchCommand(
56
- const std::shared_ptr<UIManager> &uiManager,
57
- const ShadowNode::Shared &shadowNode,
58
- std::string const &commandName,
59
- folly::dynamic const &args);
60
-
61
- LayoutMetrics UIManager_getRelativeLayoutMetrics(
62
- const std::shared_ptr<UIManager> &uiManager,
63
- ShadowNode const &shadowNode,
64
- ShadowNode const *ancestorShadowNode,
65
- LayoutableShadowNode::LayoutInspectingPolicy policy);
66
-
67
- ShadowNode::Shared UIManager_cloneNode(
68
- const UIManager *uiManager,
69
- const ShadowNode::Shared &shadowNode,
70
- const ShadowNode::SharedListOfShared &children = nullptr,
71
- const RawProps *rawProps = nullptr);
72
-
73
- void UIManager_appendChild(
74
- const ShadowNode::Shared &parentShadowNode,
75
- const ShadowNode::Shared &childShadowNode);
76
-
77
56
  } // namespace reanimated
78
57
 
79
58
  #endif // RCT_NEW_ARCH_ENABLED
@@ -4,6 +4,10 @@
4
4
  #include "FabricUtils.h"
5
5
  #include "NewestShadowNodesRegistry.h"
6
6
 
7
+ #include <react/renderer/debug/SystraceSection.h>
8
+
9
+ #include <utility>
10
+
7
11
  using namespace facebook;
8
12
  using namespace react;
9
13
 
@@ -49,7 +53,7 @@ ReanimatedUIManagerBinding::ReanimatedUIManagerBinding(
49
53
  RuntimeExecutor runtimeExecutor,
50
54
  std::unique_ptr<EventHandler const> eventHandler,
51
55
  std::shared_ptr<NewestShadowNodesRegistry> newestShadowNodesRegistry)
52
- : UIManagerBinding(uiManager, runtimeExecutor),
56
+ : UIManagerBinding(uiManager),
53
57
  uiManager_(std::move(uiManager)),
54
58
  newestShadowNodesRegistry_(newestShadowNodesRegistry) {
55
59
  if (eventHandler != nullptr) {
@@ -60,25 +64,44 @@ ReanimatedUIManagerBinding::ReanimatedUIManagerBinding(
60
64
 
61
65
  ReanimatedUIManagerBinding::~ReanimatedUIManagerBinding() {}
62
66
 
63
- static inline ShadowNode::Shared cloneNode(
67
+ static inline ShadowNode::Shared cloneNodeUsingNewest(
64
68
  UIManager *uiManager,
65
69
  NewestShadowNodesRegistry *newestShadowNodesRegistry,
66
- const ShadowNode::Shared &shadowNode,
67
- const ShadowNode::SharedListOfShared &children = nullptr,
68
- const RawProps *rawProps = nullptr) {
70
+ ShadowNode const &shadowNode,
71
+ ShadowNode::SharedListOfShared const &children = nullptr,
72
+ RawProps const *rawProps = nullptr) {
69
73
  {
70
74
  auto lock = newestShadowNodesRegistry->createLock();
71
- auto newest = newestShadowNodesRegistry->get(shadowNode->getTag());
75
+ auto newest = newestShadowNodesRegistry->get(shadowNode.getTag());
72
76
  if (newest != nullptr) {
73
77
  // ShadowNode managed by Reanimated, use newest ShadowNode from registry
74
- auto clone = UIManager_cloneNode(uiManager, newest, children, rawProps);
78
+ auto clone = uiManager->cloneNode(*newest, children, rawProps);
75
79
  newestShadowNodesRegistry->update(clone);
76
80
  return clone;
77
81
  }
78
82
  } // release lock since we don't need registry anymore
79
83
 
80
84
  // ShadowNode not managed by Reanimated (yet?)
81
- return UIManager_cloneNode(uiManager, shadowNode, children, rawProps);
85
+ return uiManager->cloneNode(shadowNode, children, rawProps);
86
+ }
87
+
88
+ static inline void appendChildUsingNewest(
89
+ UIManager *uiManager,
90
+ NewestShadowNodesRegistry *newestShadowNodesRegistry,
91
+ const ShadowNode::Shared &parentShadowNode,
92
+ const ShadowNode::Shared &childShadowNode) {
93
+ {
94
+ auto lock = newestShadowNodesRegistry->createLock();
95
+ auto newestChildShadowNode =
96
+ newestShadowNodesRegistry->get(childShadowNode->getTag());
97
+ if (newestChildShadowNode != nullptr) {
98
+ uiManager->appendChild(parentShadowNode, newestChildShadowNode);
99
+ return;
100
+ }
101
+ } // release lock since we don't need registry anymore
102
+
103
+ // child ShadowNode not managed by Reanimated (yet?)
104
+ uiManager->appendChild(parentShadowNode, childShadowNode);
82
105
  }
83
106
 
84
107
  jsi::Value ReanimatedUIManagerBinding::get(
@@ -92,6 +115,7 @@ jsi::Value ReanimatedUIManagerBinding::get(
92
115
 
93
116
  // based on implementation from UIManagerBinding.cpp
94
117
  auto methodName = name.utf8(runtime);
118
+ SystraceSection s("ReanimatedUIManagerBinding::get", "name", methodName);
95
119
  UIManager *uiManager = uiManager_.get();
96
120
  NewestShadowNodesRegistry *newestShadowNodesRegistry =
97
121
  newestShadowNodesRegistry_.get();
@@ -104,15 +128,15 @@ jsi::Value ReanimatedUIManagerBinding::get(
104
128
  1,
105
129
  [uiManager, newestShadowNodesRegistry](
106
130
  jsi::Runtime &runtime,
107
- jsi::Value const &thisValue,
131
+ jsi::Value const & /*thisValue*/,
108
132
  jsi::Value const *arguments,
109
- size_t count) noexcept -> jsi::Value {
133
+ size_t /*count*/) noexcept -> jsi::Value {
110
134
  return valueFromShadowNode(
111
135
  runtime,
112
- cloneNode(
136
+ cloneNodeUsingNewest(
113
137
  uiManager,
114
138
  newestShadowNodesRegistry,
115
- shadowNodeFromValue(runtime, arguments[0])));
139
+ *shadowNodeFromValue(runtime, arguments[0])));
116
140
  });
117
141
  }
118
142
 
@@ -124,15 +148,15 @@ jsi::Value ReanimatedUIManagerBinding::get(
124
148
  1,
125
149
  [uiManager, newestShadowNodesRegistry](
126
150
  jsi::Runtime &runtime,
127
- jsi::Value const &thisValue,
151
+ jsi::Value const & /*thisValue*/,
128
152
  jsi::Value const *arguments,
129
- size_t count) noexcept -> jsi::Value {
153
+ size_t /*count*/) noexcept -> jsi::Value {
130
154
  return valueFromShadowNode(
131
155
  runtime,
132
- cloneNode(
156
+ cloneNodeUsingNewest(
133
157
  uiManager,
134
158
  newestShadowNodesRegistry,
135
- shadowNodeFromValue(runtime, arguments[0]),
159
+ *shadowNodeFromValue(runtime, arguments[0]),
136
160
  ShadowNode::emptySharedShadowNodeSharedList()));
137
161
  });
138
162
  }
@@ -145,16 +169,16 @@ jsi::Value ReanimatedUIManagerBinding::get(
145
169
  2,
146
170
  [uiManager, newestShadowNodesRegistry](
147
171
  jsi::Runtime &runtime,
148
- jsi::Value const &thisValue,
172
+ jsi::Value const & /*thisValue*/,
149
173
  jsi::Value const *arguments,
150
- size_t count) noexcept -> jsi::Value {
174
+ size_t /*count*/) noexcept -> jsi::Value {
151
175
  auto const &rawProps = RawProps(runtime, arguments[1]);
152
176
  return valueFromShadowNode(
153
177
  runtime,
154
- cloneNode(
178
+ cloneNodeUsingNewest(
155
179
  uiManager,
156
180
  newestShadowNodesRegistry,
157
- shadowNodeFromValue(runtime, arguments[0]),
181
+ *shadowNodeFromValue(runtime, arguments[0]),
158
182
  nullptr,
159
183
  &rawProps));
160
184
  });
@@ -168,16 +192,16 @@ jsi::Value ReanimatedUIManagerBinding::get(
168
192
  2,
169
193
  [uiManager, newestShadowNodesRegistry](
170
194
  jsi::Runtime &runtime,
171
- jsi::Value const &thisValue,
195
+ jsi::Value const & /*thisValue*/,
172
196
  jsi::Value const *arguments,
173
- size_t count) noexcept -> jsi::Value {
197
+ size_t /*count*/) noexcept -> jsi::Value {
174
198
  auto const &rawProps = RawProps(runtime, arguments[1]);
175
199
  return valueFromShadowNode(
176
200
  runtime,
177
- cloneNode(
201
+ cloneNodeUsingNewest(
178
202
  uiManager,
179
203
  newestShadowNodesRegistry,
180
- shadowNodeFromValue(runtime, arguments[0]),
204
+ *shadowNodeFromValue(runtime, arguments[0]),
181
205
  ShadowNode::emptySharedShadowNodeSharedList(),
182
206
  &rawProps));
183
207
  });
@@ -188,21 +212,16 @@ jsi::Value ReanimatedUIManagerBinding::get(
188
212
  runtime,
189
213
  name,
190
214
  2,
191
- [newestShadowNodesRegistry](
215
+ [uiManager, newestShadowNodesRegistry](
192
216
  jsi::Runtime &runtime,
193
- jsi::Value const &thisValue,
217
+ jsi::Value const & /*thisValue*/,
194
218
  jsi::Value const *arguments,
195
- size_t count) noexcept -> jsi::Value {
196
- auto parent = shadowNodeFromValue(runtime, arguments[0]);
197
- auto child = shadowNodeFromValue(runtime, arguments[1]);
198
- {
199
- auto lock = newestShadowNodesRegistry->createLock();
200
- auto newest = newestShadowNodesRegistry->get(child->getTag());
201
- if (newest != nullptr) {
202
- child = newest;
203
- }
204
- }
205
- UIManager_appendChild(parent, child);
219
+ size_t /*count*/) noexcept -> jsi::Value {
220
+ appendChildUsingNewest(
221
+ uiManager,
222
+ newestShadowNodesRegistry,
223
+ shadowNodeFromValue(runtime, arguments[0]),
224
+ shadowNodeFromValue(runtime, arguments[1]));
206
225
  return jsi::Value::undefined();
207
226
  });
208
227
  }
@@ -31,8 +31,8 @@ class ShadowTreeCloner {
31
31
  void updateYogaChildren();
32
32
 
33
33
  private:
34
- PropsParserContext propsParserContext_;
35
34
  std::shared_ptr<NewestShadowNodesRegistry> newestShadowNodesRegistry_;
35
+ PropsParserContext propsParserContext_;
36
36
  std::set<ShadowNode *> yogaChildrenUpdates_;
37
37
  };
38
38
 
@@ -0,0 +1,76 @@
1
+ #include "LayoutAnimationsManager.h"
2
+ #include "Shareables.h"
3
+
4
+ #include <utility>
5
+
6
+ namespace reanimated {
7
+
8
+ void LayoutAnimationsManager::configureAnimation(
9
+ int tag,
10
+ const std::string &type,
11
+ std::shared_ptr<Shareable> config) {
12
+ auto lock = std::unique_lock<std::mutex>(animationsMutex_);
13
+ if (type == "entering") {
14
+ enteringAnimations_[tag] = config;
15
+ } else if (type == "exiting") {
16
+ exitingAnimations_[tag] = config;
17
+ } else if (type == "layout") {
18
+ layoutAnimations_[tag] = config;
19
+ }
20
+ }
21
+
22
+ bool LayoutAnimationsManager::hasLayoutAnimation(
23
+ int tag,
24
+ const std::string &type) {
25
+ auto lock = std::unique_lock<std::mutex>(animationsMutex_);
26
+ if (type == "entering") {
27
+ return enteringAnimations_.find(tag) != enteringAnimations_.end();
28
+ } else if (type == "exiting") {
29
+ return exitingAnimations_.find(tag) != exitingAnimations_.end();
30
+ } else if (type == "layout") {
31
+ return layoutAnimations_.find(tag) != layoutAnimations_.end();
32
+ }
33
+ return false;
34
+ }
35
+
36
+ void LayoutAnimationsManager::clearLayoutAnimationConfig(int tag) {
37
+ auto lock = std::unique_lock<std::mutex>(animationsMutex_);
38
+ enteringAnimations_.erase(tag);
39
+ exitingAnimations_.erase(tag);
40
+ layoutAnimations_.erase(tag);
41
+ }
42
+
43
+ void LayoutAnimationsManager::startLayoutAnimation(
44
+ jsi::Runtime &rt,
45
+ int tag,
46
+ const std::string &type,
47
+ const jsi::Object &values) {
48
+ std::shared_ptr<Shareable> config, viewShareable;
49
+ {
50
+ auto lock = std::unique_lock<std::mutex>(animationsMutex_);
51
+ if (type == "entering") {
52
+ config = enteringAnimations_[tag];
53
+ } else if (type == "exiting") {
54
+ config = exitingAnimations_[tag];
55
+ } else if (type == "layout") {
56
+ config = layoutAnimations_[tag];
57
+ }
58
+ }
59
+
60
+ // TODO: cache the following!!
61
+ jsi::Value layoutAnimationRepositoryAsValue =
62
+ rt.global()
63
+ .getPropertyAsObject(rt, "global")
64
+ .getProperty(rt, "LayoutAnimationsManager");
65
+ jsi::Function startAnimationForTag =
66
+ layoutAnimationRepositoryAsValue.getObject(rt).getPropertyAsFunction(
67
+ rt, "start");
68
+ startAnimationForTag.call(
69
+ rt,
70
+ jsi::Value(tag),
71
+ jsi::String::createFromAscii(rt, type),
72
+ values,
73
+ config->getJSValue(rt));
74
+ }
75
+
76
+ } // namespace reanimated
@@ -0,0 +1,41 @@
1
+ #pragma once
2
+
3
+ #include "ErrorHandler.h"
4
+ #include "Shareables.h"
5
+
6
+ #include <jsi/jsi.h>
7
+ #include <stdio.h>
8
+ #include <functional>
9
+ #include <memory>
10
+ #include <mutex>
11
+ #include <string>
12
+ #include <unordered_map>
13
+
14
+ namespace reanimated {
15
+
16
+ using namespace facebook;
17
+
18
+ class LayoutAnimationsManager {
19
+ public:
20
+ void configureAnimation(
21
+ int tag,
22
+ const std::string &type,
23
+ std::shared_ptr<Shareable> config);
24
+ bool hasLayoutAnimation(int tag, const std::string &type);
25
+ void startLayoutAnimation(
26
+ jsi::Runtime &rt,
27
+ int tag,
28
+ const std::string &type,
29
+ const jsi::Object &values);
30
+ void clearLayoutAnimationConfig(int tag);
31
+
32
+ private:
33
+ std::unordered_map<int, std::shared_ptr<Shareable>> enteringAnimations_;
34
+ std::unordered_map<int, std::shared_ptr<Shareable>> exitingAnimations_;
35
+ std::unordered_map<int, std::shared_ptr<Shareable>> layoutAnimations_;
36
+ mutable std::mutex
37
+ animationsMutex_; // Protects `enteringAnimations_`, `exitingAnimations_`,
38
+ // `layoutAnimations_` and `viewSharedValues_`.
39
+ };
40
+
41
+ } // namespace reanimated