react-native-reanimated 3.0.0-rc.8 → 3.0.0

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 (339) hide show
  1. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +30 -12
  2. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.h +2 -0
  3. package/Common/cpp/Fabric/FabricUtils.cpp +3 -107
  4. package/Common/cpp/Fabric/FabricUtils.h +3 -24
  5. package/Common/cpp/Fabric/ReanimatedUIManagerBinding.cpp +54 -37
  6. package/Common/cpp/LayoutAnimations/LayoutAnimationType.h +8 -0
  7. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +81 -26
  8. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +20 -3
  9. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +122 -121
  10. package/Common/cpp/NativeModules/NativeReanimatedModule.h +21 -14
  11. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +15 -7
  12. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +8 -4
  13. package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +50 -1
  14. package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +10 -1
  15. package/Common/cpp/ReanimatedRuntime/ReanimatedRuntime.cpp +5 -1
  16. package/Common/cpp/Registries/EventHandlerRegistry.cpp +8 -34
  17. package/Common/cpp/Registries/EventHandlerRegistry.h +7 -13
  18. package/Common/cpp/SharedItems/Shareables.cpp +11 -63
  19. package/Common/cpp/SharedItems/Shareables.h +113 -93
  20. package/Common/cpp/Tools/CollectionUtils.h +14 -0
  21. package/Common/cpp/Tools/JsiUtils.cpp +26 -0
  22. package/Common/cpp/Tools/JsiUtils.h +176 -0
  23. package/Common/cpp/Tools/PlatformDepMethodsHolder.h +5 -5
  24. package/Common/cpp/Tools/ReanimatedVersion.cpp +17 -0
  25. package/Common/cpp/Tools/ReanimatedVersion.h +11 -0
  26. package/Common/cpp/Tools/RuntimeDecorator.cpp +67 -247
  27. package/Common/cpp/Tools/RuntimeDecorator.h +2 -3
  28. package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -2
  29. package/Common/cpp/Tools/WorkletEventHandler.h +14 -6
  30. package/RNReanimated.podspec +2 -1
  31. package/android/CMakeLists.txt +188 -181
  32. package/android/build.gradle +362 -311
  33. package/android/proguard-rules.pro +2 -0
  34. package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +63 -295
  35. package/android/src/main/cpp/LayoutAnimations.cpp +35 -5
  36. package/android/src/main/cpp/LayoutAnimations.h +23 -6
  37. package/android/src/main/cpp/NativeProxy.cpp +143 -98
  38. package/android/src/main/cpp/NativeProxy.h +22 -28
  39. package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +5 -4
  40. package/android/src/main/java/com/swmansion/reanimated/Utils.java +7 -1
  41. package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +10 -3
  42. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +218 -35
  43. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +43 -17
  44. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +6 -2
  45. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedElement.java +19 -0
  46. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +610 -0
  47. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +93 -23
  48. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/AnimationFrameCallback.java +19 -0
  49. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/EventHandler.java +35 -0
  50. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/KeyboardEventDataUpdater.java +16 -0
  51. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +206 -0
  52. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/SensorSetter.java +17 -0
  53. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +9 -3
  54. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +3 -4
  55. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -7
  56. package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +90 -307
  57. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +16 -0
  58. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +63 -0
  59. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +271 -0
  60. package/android/src/reactNativeVersionPatch/nativeHierarchyManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +76 -20
  61. package/ios/LayoutReanimation/REAAnimationsManager.h +31 -5
  62. package/ios/LayoutReanimation/REAAnimationsManager.m +265 -77
  63. package/ios/LayoutReanimation/REAFrame.h +10 -0
  64. package/ios/LayoutReanimation/REAFrame.m +15 -0
  65. package/ios/LayoutReanimation/REAScreensHelper.h +19 -0
  66. package/ios/LayoutReanimation/REAScreensHelper.m +106 -0
  67. package/ios/LayoutReanimation/REASharedElement.h +15 -0
  68. package/ios/LayoutReanimation/REASharedElement.m +16 -0
  69. package/ios/LayoutReanimation/REASharedTransitionManager.h +17 -0
  70. package/ios/LayoutReanimation/REASharedTransitionManager.m +632 -0
  71. package/ios/LayoutReanimation/REASnapshot.h +1 -0
  72. package/ios/LayoutReanimation/REASnapshot.m +96 -11
  73. package/ios/LayoutReanimation/REAUIManager.mm +67 -60
  74. package/ios/REAModule.mm +2 -7
  75. package/ios/REANodesManager.mm +1 -21
  76. package/ios/keyboardObserver/REAKeyboardEventObserver.m +72 -36
  77. package/ios/native/NativeProxy.mm +75 -114
  78. package/ios/native/REAInitializer.mm +2 -7
  79. package/ios/native/REAJSIUtils.h +60 -2
  80. package/ios/sensor/ReanimatedSensor.h +6 -2
  81. package/ios/sensor/ReanimatedSensor.m +43 -7
  82. package/ios/sensor/ReanimatedSensorContainer.h +4 -1
  83. package/ios/sensor/ReanimatedSensorContainer.m +8 -2
  84. package/lib/commonjs/createAnimatedComponent.js +232 -28
  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/NativeReanimated/NativeReanimated.js +18 -35
  89. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  90. package/lib/commonjs/reanimated2/animation/styleAnimation.js +5 -1
  91. package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
  92. package/lib/commonjs/reanimated2/animation/util.js +17 -15
  93. package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
  94. package/lib/commonjs/reanimated2/commonTypes.js +33 -1
  95. package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
  96. package/lib/commonjs/reanimated2/component/FlatList.js +19 -3
  97. package/lib/commonjs/reanimated2/component/FlatList.js.map +1 -1
  98. package/lib/commonjs/reanimated2/core.js +34 -83
  99. package/lib/commonjs/reanimated2/core.js.map +1 -1
  100. package/lib/commonjs/reanimated2/errors.js +66 -0
  101. package/lib/commonjs/reanimated2/errors.js.map +1 -0
  102. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
  103. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  104. package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
  105. package/lib/commonjs/reanimated2/hook/index.js +0 -6
  106. package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
  107. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +5 -2
  108. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  109. package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +13 -1
  110. package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  111. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +1 -1
  112. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
  113. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +89 -16
  114. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  115. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +43 -50
  116. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  117. package/lib/commonjs/reanimated2/hook/useDerivedValue.js +13 -1
  118. package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
  119. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +2 -2
  120. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  121. package/lib/commonjs/reanimated2/hook/utils.js +18 -65
  122. package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
  123. package/lib/commonjs/reanimated2/index.js +13 -0
  124. package/lib/commonjs/reanimated2/index.js.map +1 -1
  125. package/lib/commonjs/reanimated2/initializers.js +196 -0
  126. package/lib/commonjs/reanimated2/initializers.js.map +1 -0
  127. package/lib/commonjs/reanimated2/interpolateColor.js +96 -19
  128. package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
  129. package/lib/commonjs/reanimated2/jestUtils.js +1 -1
  130. package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
  131. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +101 -16
  132. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  133. package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +22 -0
  134. package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
  135. package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js +2 -0
  136. package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js.map +1 -0
  137. package/lib/commonjs/reanimated2/js-reanimated/commonTypes.js.map +1 -1
  138. package/lib/commonjs/reanimated2/js-reanimated/global.js +4 -9
  139. package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
  140. package/lib/commonjs/reanimated2/js-reanimated/index.js +0 -1
  141. package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
  142. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +11 -0
  143. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  144. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +8 -0
  145. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  146. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +16 -12
  147. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  148. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -23
  149. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  150. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -14
  151. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  152. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -14
  153. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  154. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -15
  155. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  156. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -23
  157. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  158. package/lib/commonjs/reanimated2/layoutReanimation/index.js +13 -0
  159. package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
  160. package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +94 -0
  161. package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
  162. package/lib/commonjs/reanimated2/mappers.js +18 -6
  163. package/lib/commonjs/reanimated2/mappers.js.map +1 -1
  164. package/lib/commonjs/reanimated2/mock.js +45 -0
  165. package/lib/commonjs/reanimated2/mock.js.map +1 -1
  166. package/lib/commonjs/reanimated2/mutables.js +4 -2
  167. package/lib/commonjs/reanimated2/mutables.js.map +1 -1
  168. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +42 -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/pluginUtils.js +11 -0
  173. package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -0
  174. package/lib/commonjs/reanimated2/shareables.js +38 -11
  175. package/lib/commonjs/reanimated2/shareables.js.map +1 -1
  176. package/lib/commonjs/reanimated2/threads.js +114 -4
  177. package/lib/commonjs/reanimated2/threads.js.map +1 -1
  178. package/lib/commonjs/reanimated2/utils.js +7 -0
  179. package/lib/commonjs/reanimated2/utils.js.map +1 -1
  180. package/lib/commonjs/reanimated2/valueSetter.js +1 -3
  181. package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
  182. package/lib/module/createAnimatedComponent.js +229 -29
  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/NativeReanimated/NativeReanimated.js +18 -34
  187. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  188. package/lib/module/reanimated2/animation/styleAnimation.js +5 -1
  189. package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
  190. package/lib/module/reanimated2/animation/util.js +17 -16
  191. package/lib/module/reanimated2/animation/util.js.map +1 -1
  192. package/lib/module/reanimated2/commonTypes.js +29 -0
  193. package/lib/module/reanimated2/commonTypes.js.map +1 -1
  194. package/lib/module/reanimated2/component/FlatList.js +18 -4
  195. package/lib/module/reanimated2/component/FlatList.js.map +1 -1
  196. package/lib/module/reanimated2/core.js +30 -76
  197. package/lib/module/reanimated2/core.js.map +1 -1
  198. package/lib/module/reanimated2/errors.js +58 -0
  199. package/lib/module/reanimated2/errors.js.map +1 -0
  200. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
  201. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  202. package/lib/module/reanimated2/globals.d.js.map +1 -1
  203. package/lib/module/reanimated2/hook/index.js +1 -1
  204. package/lib/module/reanimated2/hook/index.js.map +1 -1
  205. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +5 -2
  206. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  207. package/lib/module/reanimated2/hook/useAnimatedReaction.js +12 -1
  208. package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  209. package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
  210. package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
  211. package/lib/module/reanimated2/hook/useAnimatedSensor.js +88 -13
  212. package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  213. package/lib/module/reanimated2/hook/useAnimatedStyle.js +45 -52
  214. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  215. package/lib/module/reanimated2/hook/useDerivedValue.js +12 -1
  216. package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
  217. package/lib/module/reanimated2/hook/useScrollViewOffset.js +2 -2
  218. package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  219. package/lib/module/reanimated2/hook/utils.js +17 -60
  220. package/lib/module/reanimated2/hook/utils.js.map +1 -1
  221. package/lib/module/reanimated2/index.js +1 -0
  222. package/lib/module/reanimated2/index.js.map +1 -1
  223. package/lib/module/reanimated2/initializers.js +182 -0
  224. package/lib/module/reanimated2/initializers.js.map +1 -0
  225. package/lib/module/reanimated2/interpolateColor.js +96 -19
  226. package/lib/module/reanimated2/interpolateColor.js.map +1 -1
  227. package/lib/module/reanimated2/jestUtils.js +1 -1
  228. package/lib/module/reanimated2/jestUtils.js.map +1 -1
  229. package/lib/module/reanimated2/js-reanimated/JSReanimated.js +101 -16
  230. package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  231. package/lib/module/reanimated2/js-reanimated/Mapper.js +21 -0
  232. package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
  233. package/lib/module/reanimated2/js-reanimated/WebSensor.js +2 -0
  234. package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -0
  235. package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
  236. package/lib/module/reanimated2/js-reanimated/global.js +4 -9
  237. package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
  238. package/lib/module/reanimated2/js-reanimated/index.js +0 -1
  239. package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
  240. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +9 -1
  241. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  242. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js +1 -0
  243. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  244. package/lib/module/reanimated2/layoutReanimation/animationsManager.js +15 -10
  245. package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  246. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -21
  247. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  248. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -12
  249. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  250. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
  251. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  252. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -13
  253. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  254. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -21
  255. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  256. package/lib/module/reanimated2/layoutReanimation/index.js +1 -0
  257. package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
  258. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +82 -0
  259. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
  260. package/lib/module/reanimated2/mappers.js +16 -6
  261. package/lib/module/reanimated2/mappers.js.map +1 -1
  262. package/lib/module/reanimated2/mock.js +45 -0
  263. package/lib/module/reanimated2/mock.js.map +1 -1
  264. package/lib/module/reanimated2/mutables.js +4 -2
  265. package/lib/module/reanimated2/mutables.js.map +1 -1
  266. package/lib/module/reanimated2/platform-specific/checkVersion.js +35 -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/pluginUtils.js +4 -0
  271. package/lib/module/reanimated2/pluginUtils.js.map +1 -0
  272. package/lib/module/reanimated2/shareables.js +38 -9
  273. package/lib/module/reanimated2/shareables.js.map +1 -1
  274. package/lib/module/reanimated2/threads.js +105 -4
  275. package/lib/module/reanimated2/threads.js.map +1 -1
  276. package/lib/module/reanimated2/utils.js +5 -0
  277. package/lib/module/reanimated2/utils.js.map +1 -1
  278. package/lib/module/reanimated2/valueSetter.js +1 -2
  279. package/lib/module/reanimated2/valueSetter.js.map +1 -1
  280. package/package.json +9 -8
  281. package/{plugin.js → plugin/index.js} +173 -228
  282. package/react-native-reanimated.d.ts +57 -10
  283. package/scripts/reanimated_utils.rb +15 -2
  284. package/src/createAnimatedComponent.tsx +238 -28
  285. package/src/reanimated2/Colors.ts +38 -11
  286. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +63 -41
  287. package/src/reanimated2/animation/styleAnimation.ts +8 -1
  288. package/src/reanimated2/animation/util.ts +29 -16
  289. package/src/reanimated2/commonTypes.ts +28 -1
  290. package/src/reanimated2/component/FlatList.tsx +30 -5
  291. package/src/reanimated2/core.ts +45 -75
  292. package/src/reanimated2/errors.ts +57 -0
  293. package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +2 -2
  294. package/src/reanimated2/globals.d.ts +34 -18
  295. package/src/reanimated2/hook/index.ts +1 -1
  296. package/src/reanimated2/hook/useAnimatedKeyboard.ts +10 -4
  297. package/src/reanimated2/hook/useAnimatedReaction.ts +12 -5
  298. package/src/reanimated2/hook/useAnimatedRef.ts +1 -4
  299. package/src/reanimated2/hook/useAnimatedSensor.ts +88 -11
  300. package/src/reanimated2/hook/useAnimatedStyle.ts +43 -45
  301. package/src/reanimated2/hook/useDerivedValue.ts +8 -1
  302. package/src/reanimated2/hook/useScrollViewOffset.ts +2 -2
  303. package/src/reanimated2/hook/utils.ts +15 -61
  304. package/src/reanimated2/index.ts +1 -0
  305. package/src/reanimated2/initializers.ts +184 -0
  306. package/src/reanimated2/interpolateColor.ts +104 -20
  307. package/src/reanimated2/jestUtils.ts +1 -1
  308. package/src/reanimated2/js-reanimated/JSReanimated.ts +105 -18
  309. package/src/reanimated2/js-reanimated/Mapper.ts +32 -0
  310. package/src/reanimated2/js-reanimated/WebSensor.ts +34 -0
  311. package/src/reanimated2/js-reanimated/commonTypes.ts +0 -1
  312. package/src/reanimated2/js-reanimated/global.ts +4 -8
  313. package/src/reanimated2/js-reanimated/index.ts +0 -1
  314. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +13 -1
  315. package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
  316. package/src/reanimated2/layoutReanimation/animationsManager.ts +17 -12
  317. package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +16 -19
  318. package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +14 -11
  319. package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +21 -11
  320. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -11
  321. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +36 -19
  322. package/src/reanimated2/layoutReanimation/index.ts +1 -0
  323. package/src/reanimated2/layoutReanimation/sharedTransitions/index.ts +87 -0
  324. package/src/reanimated2/mappers.ts +17 -6
  325. package/src/reanimated2/mock.ts +128 -0
  326. package/src/reanimated2/mutables.ts +2 -0
  327. package/src/reanimated2/platform-specific/checkVersion.ts +39 -0
  328. package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
  329. package/src/reanimated2/pluginUtils.ts +8 -0
  330. package/src/reanimated2/shareables.ts +47 -11
  331. package/src/reanimated2/threads.ts +103 -1
  332. package/src/reanimated2/utils.ts +6 -0
  333. package/src/reanimated2/valueSetter.ts +1 -2
  334. package/lib/commonjs/reanimated2/time.js +0 -55
  335. package/lib/commonjs/reanimated2/time.js.map +0 -1
  336. package/lib/module/reanimated2/time.js +0 -37
  337. package/lib/module/reanimated2/time.js.map +0 -1
  338. package/src/reanimated2/time.ts +0 -30
  339. /package/android/src/{main/java → reactNativeVersionPatch/ReanimatedUIManager/70}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -0
@@ -58,8 +58,11 @@ NativeReanimatedModule::NativeReanimatedModule(
58
58
  platformDepMethodsHolder.configurePropsFunction)
59
59
  #endif
60
60
  {
61
- auto requestAnimationFrame = [=](FrameCallback callback) {
62
- frameCallbacks.push_back(callback);
61
+ auto requestAnimationFrame = [=](jsi::Runtime &rt, const jsi::Value &fn) {
62
+ auto jsFunction = std::make_shared<jsi::Value>(rt, fn);
63
+ frameCallbacks.push_back([=](double timestamp) {
64
+ runtimeHelper->runOnUIGuarded(*jsFunction, jsi::Value(timestamp));
65
+ });
63
66
  maybeRequestRender();
64
67
  };
65
68
 
@@ -96,7 +99,7 @@ NativeReanimatedModule::NativeReanimatedModule(
96
99
  };
97
100
 
98
101
  auto makeShareableClone = [this](jsi::Runtime &rt, const jsi::Value &value) {
99
- return this->makeShareableClone(rt, value);
102
+ return this->makeShareableClone(rt, value, jsi::Value::undefined());
100
103
  };
101
104
 
102
105
  auto updateDataSynchronously =
@@ -117,8 +120,8 @@ NativeReanimatedModule::NativeReanimatedModule(
117
120
  };
118
121
 
119
122
  auto removeShadowNodeFromRegistry =
120
- [this](jsi::Runtime &rt, const jsi::Value &shadowNodeValue) {
121
- this->removeShadowNodeFromRegistry(rt, shadowNodeValue);
123
+ [this](jsi::Runtime &rt, const jsi::Value &tag) {
124
+ this->removeShadowNodeFromRegistry(rt, tag);
122
125
  };
123
126
 
124
127
  auto measure = [this](jsi::Runtime &rt, const jsi::Value &shadowNodeValue) {
@@ -151,8 +154,6 @@ NativeReanimatedModule::NativeReanimatedModule(
151
154
  makeShareableClone,
152
155
  updateDataSynchronously,
153
156
  platformDepMethodsHolder.getCurrentTime,
154
- platformDepMethodsHolder.registerSensor,
155
- platformDepMethodsHolder.unregisterSensor,
156
157
  platformDepMethodsHolder.setGestureStateFunction,
157
158
  platformDepMethodsHolder.progressLayoutAnimation,
158
159
  platformDepMethodsHolder.endLayoutAnimation);
@@ -174,24 +175,28 @@ NativeReanimatedModule::NativeReanimatedModule(
174
175
 
175
176
  void NativeReanimatedModule::installCoreFunctions(
176
177
  jsi::Runtime &rt,
177
- const jsi::Value &valueUnpacker,
178
- const jsi::Value &layoutAnimationStartFunction) {
178
+ const jsi::Value &callGuard,
179
+ const jsi::Value &valueUnpacker) {
179
180
  if (!runtimeHelper) {
180
181
  // initialize runtimeHelper here if not already present. We expect only one
181
182
  // instace of the helper to exists.
182
183
  runtimeHelper =
183
184
  std::make_shared<JSRuntimeHelper>(&rt, this->runtime.get(), scheduler);
184
185
  }
186
+ runtimeHelper->callGuard =
187
+ std::make_unique<CoreFunction>(runtimeHelper.get(), callGuard);
185
188
  runtimeHelper->valueUnpacker =
186
- std::make_shared<CoreFunction>(runtimeHelper.get(), valueUnpacker);
189
+ std::make_unique<CoreFunction>(runtimeHelper.get(), valueUnpacker);
187
190
  }
188
191
 
189
192
  NativeReanimatedModule::~NativeReanimatedModule() {
190
193
  if (runtimeHelper) {
194
+ runtimeHelper->callGuard = nullptr;
191
195
  runtimeHelper->valueUnpacker = nullptr;
192
- // event handler registry stores some JSI values from UI runtime, so it has
193
- // to go away before we tear down the runtime
196
+ // event handler registry and frame callbacks store some JSI values from UI
197
+ // runtime, so they have to go away before we tear down the runtime
194
198
  eventHandlerRegistry.reset();
199
+ frameCallbacks.clear();
195
200
  runtime.reset();
196
201
  // make sure uiRuntimeDestroyed is set after the runtime is deallocated
197
202
  runtimeHelper->uiRuntimeDestroyed = true;
@@ -205,13 +210,11 @@ void NativeReanimatedModule::scheduleOnUI(
205
210
  assert(
206
211
  shareableWorklet->valueType() == Shareable::WorkletType &&
207
212
  "only worklets can be scheduled to run on UI");
208
- auto uiRuntime = runtimeHelper->uiRuntime();
209
- frameCallbacks.push_back([=](double timestamp) {
210
- jsi::Runtime &rt = *uiRuntime;
213
+ scheduler->scheduleOnUI([=] {
214
+ jsi::Runtime &rt = *runtimeHelper->uiRuntime();
211
215
  auto workletValue = shareableWorklet->getJSValue(rt);
212
- workletValue.asObject(rt).asFunction(rt).call(rt);
216
+ runtimeHelper->runOnUIGuarded(workletValue);
213
217
  });
214
- maybeRequestRender();
215
218
  }
216
219
 
217
220
  jsi::Value NativeReanimatedModule::makeSynchronizedDataHolder(
@@ -241,7 +244,8 @@ jsi::Value NativeReanimatedModule::getDataSynchronously(
241
244
 
242
245
  jsi::Value NativeReanimatedModule::makeShareableClone(
243
246
  jsi::Runtime &rt,
244
- const jsi::Value &value) {
247
+ const jsi::Value &value,
248
+ const jsi::Value &shouldRetainRemote) {
245
249
  std::shared_ptr<Shareable> shareable;
246
250
  if (value.isObject()) {
247
251
  auto object = value.asObject(rt);
@@ -253,18 +257,25 @@ jsi::Value NativeReanimatedModule::makeShareableClone(
253
257
  shareable = std::make_shared<ShareableRemoteFunction>(
254
258
  runtimeHelper, rt, object.asFunction(rt));
255
259
  } else if (object.isArray(rt)) {
256
- shareable = std::make_shared<ShareableArray>(
257
- runtimeHelper, rt, object.asArray(rt));
258
- #ifdef RCT_NEW_ARCH_ENABLED
259
- } else if (object.isHostObject<ShadowNodeWrapper>(rt)) {
260
- shareable = std::make_shared<ShareableShadowNodeWrapper>(
261
- runtimeHelper, rt, object);
262
- #endif
260
+ if (shouldRetainRemote.isBool() && shouldRetainRemote.getBool()) {
261
+ shareable = std::make_shared<RetainingShareable<ShareableArray>>(
262
+ runtimeHelper, rt, object.asArray(rt));
263
+ } else {
264
+ shareable = std::make_shared<ShareableArray>(rt, object.asArray(rt));
265
+ }
266
+ } else if (object.isHostObject(rt)) {
267
+ shareable = std::make_shared<ShareableHostObject>(
268
+ runtimeHelper, rt, object.getHostObject(rt));
263
269
  } else {
264
- shareable = std::make_shared<ShareableObject>(runtimeHelper, rt, object);
270
+ if (shouldRetainRemote.isBool() && shouldRetainRemote.getBool()) {
271
+ shareable = std::make_shared<RetainingShareable<ShareableObject>>(
272
+ runtimeHelper, rt, object);
273
+ } else {
274
+ shareable = std::make_shared<ShareableObject>(rt, object);
275
+ }
265
276
  }
266
277
  } else if (value.isString()) {
267
- shareable = std::make_shared<ShareableString>(rt, value.asString(rt));
278
+ shareable = std::make_shared<ShareableString>(value.asString(rt).utf8(rt));
268
279
  } else if (value.isUndefined()) {
269
280
  shareable = std::make_shared<ShareableScalar>();
270
281
  } else if (value.isNull()) {
@@ -273,6 +284,13 @@ jsi::Value NativeReanimatedModule::makeShareableClone(
273
284
  shareable = std::make_shared<ShareableScalar>(value.getBool());
274
285
  } else if (value.isNumber()) {
275
286
  shareable = std::make_shared<ShareableScalar>(value.getNumber());
287
+ } else if (value.isSymbol()) {
288
+ // TODO: this is only a placeholder implementation, here we replace symbols
289
+ // with strings in order to make certain objects to be captured. There isn't
290
+ // yet any usecase for using symbols on the UI runtime so it is fine to keep
291
+ // it like this for now.
292
+ shareable =
293
+ std::make_shared<ShareableString>(value.getSymbol(rt).toString(rt));
276
294
  } else {
277
295
  throw std::runtime_error("attempted to convert an unsupported value type");
278
296
  }
@@ -283,19 +301,21 @@ jsi::Value NativeReanimatedModule::registerEventHandler(
283
301
  jsi::Runtime &rt,
284
302
  const jsi::Value &eventHash,
285
303
  const jsi::Value &worklet) {
286
- static unsigned long EVENT_HANDLER_ID = 1;
304
+ static uint64_t EVENT_HANDLER_ID = 1;
287
305
 
288
- unsigned long newRegistrationId = EVENT_HANDLER_ID++;
306
+ uint64_t newRegistrationId = EVENT_HANDLER_ID++;
289
307
  auto eventName = eventHash.asString(rt).utf8(rt);
290
308
  auto handlerShareable = extractShareableOrThrow(rt, worklet);
291
309
 
292
310
  scheduler->scheduleOnUI([=] {
293
311
  jsi::Runtime &rt = *runtimeHelper->uiRuntime();
294
- auto handlerFunction =
295
- handlerShareable->getJSValue(rt).asObject(rt).asFunction(rt);
312
+ auto handlerFunction = handlerShareable->getJSValue(rt);
296
313
  auto handler = std::make_shared<WorkletEventHandler>(
297
- newRegistrationId, eventName, std::move(handlerFunction));
298
- eventHandlerRegistry->registerEventHandler(handler);
314
+ runtimeHelper,
315
+ newRegistrationId,
316
+ eventName,
317
+ std::move(handlerFunction));
318
+ eventHandlerRegistry->registerEventHandler(std::move(handler));
299
319
  });
300
320
 
301
321
  return jsi::Value(static_cast<double>(newRegistrationId));
@@ -304,7 +324,7 @@ jsi::Value NativeReanimatedModule::registerEventHandler(
304
324
  void NativeReanimatedModule::unregisterEventHandler(
305
325
  jsi::Runtime &rt,
306
326
  const jsi::Value &registrationId) {
307
- unsigned long id = registrationId.asNumber();
327
+ uint64_t id = registrationId.asNumber();
308
328
  scheduler->scheduleOnUI(
309
329
  [=] { eventHandlerRegistry->unregisterEventHandler(id); });
310
330
  }
@@ -364,37 +384,22 @@ jsi::Value NativeReanimatedModule::configureLayoutAnimation(
364
384
  jsi::Runtime &rt,
365
385
  const jsi::Value &viewTag,
366
386
  const jsi::Value &type,
387
+ const jsi::Value &sharedTransitionTag,
367
388
  const jsi::Value &config) {
368
389
  layoutAnimationsManager_.configureAnimation(
369
390
  viewTag.asNumber(),
370
- type.asString(rt).utf8(rt),
391
+ static_cast<LayoutAnimationType>(type.asNumber()),
392
+ sharedTransitionTag.asString(rt).utf8(rt),
371
393
  extractShareableOrThrow(rt, config));
372
394
  return jsi::Value::undefined();
373
395
  }
374
396
 
375
397
  void NativeReanimatedModule::onEvent(
376
- std::string eventName,
377
- #ifdef RCT_NEW_ARCH_ENABLED
378
- jsi::Value &&payload
379
- #else
380
- std::string eventAsString
381
- #endif
382
- /**/) {
383
- try {
384
- #ifdef RCT_NEW_ARCH_ENABLED
385
- eventHandlerRegistry->processEvent(*runtime, eventName, payload);
386
- #else
387
- eventHandlerRegistry->processEvent(*runtime, eventName, eventAsString);
388
- #endif
389
- } catch (std::exception &e) {
390
- std::string str = e.what();
391
- this->errorHandler->setError(str);
392
- this->errorHandler->raise();
393
- } catch (...) {
394
- std::string str = "OnEvent error";
395
- this->errorHandler->setError(str);
396
- this->errorHandler->raise();
397
- }
398
+ double eventTimestamp,
399
+ const std::string &eventName,
400
+ const jsi::Value &payload) {
401
+ eventHandlerRegistry->processEvent(
402
+ *runtime, eventTimestamp, eventName, payload);
398
403
  }
399
404
 
400
405
  bool NativeReanimatedModule::isAnyHandlerWaitingForEvent(
@@ -410,20 +415,10 @@ void NativeReanimatedModule::maybeRequestRender() {
410
415
  }
411
416
 
412
417
  void NativeReanimatedModule::onRender(double timestampMs) {
413
- try {
414
- std::vector<FrameCallback> callbacks = frameCallbacks;
415
- frameCallbacks.clear();
416
- for (auto &callback : callbacks) {
417
- callback(timestampMs);
418
- }
419
- } catch (std::exception &e) {
420
- std::string str = e.what();
421
- this->errorHandler->setError(str);
422
- this->errorHandler->raise();
423
- } catch (...) {
424
- std::string str = "OnRender error";
425
- this->errorHandler->setError(str);
426
- this->errorHandler->raise();
418
+ std::vector<FrameCallback> callbacks = frameCallbacks;
419
+ frameCallbacks.clear();
420
+ for (auto &callback : callbacks) {
421
+ callback(timestampMs);
427
422
  }
428
423
  }
429
424
 
@@ -431,9 +426,15 @@ jsi::Value NativeReanimatedModule::registerSensor(
431
426
  jsi::Runtime &rt,
432
427
  const jsi::Value &sensorType,
433
428
  const jsi::Value &interval,
429
+ const jsi::Value &iosReferenceFrame,
434
430
  const jsi::Value &sensorDataHandler) {
435
431
  return animatedSensorModule.registerSensor(
436
- rt, runtimeHelper, sensorType, interval, sensorDataHandler);
432
+ rt,
433
+ runtimeHelper,
434
+ sensorType,
435
+ interval,
436
+ iosReferenceFrame,
437
+ sensorDataHandler);
437
438
  }
438
439
 
439
440
  void NativeReanimatedModule::unregisterSensor(
@@ -442,6 +443,10 @@ void NativeReanimatedModule::unregisterSensor(
442
443
  animatedSensorModule.unregisterSensor(sensorId);
443
444
  }
444
445
 
446
+ void NativeReanimatedModule::cleanupSensors() {
447
+ animatedSensorModule.unregisterAllSensors();
448
+ }
449
+
445
450
  #ifdef RCT_NEW_ARCH_ENABLED
446
451
  bool NativeReanimatedModule::isThereAnyLayoutProp(
447
452
  jsi::Runtime &rt,
@@ -458,24 +463,20 @@ bool NativeReanimatedModule::isThereAnyLayoutProp(
458
463
  }
459
464
  return false;
460
465
  }
466
+ #endif // RCT_NEW_ARCH_ENABLED
461
467
 
462
468
  bool NativeReanimatedModule::handleEvent(
463
469
  const std::string &eventName,
464
- jsi::Value &&payload,
470
+ const jsi::Value &payload,
465
471
  double currentTime) {
466
- jsi::Runtime &rt = *runtime.get();
467
- jsi::Object global = rt.global();
468
- jsi::String eventTimestampName =
469
- jsi::String::createFromAscii(rt, "_eventTimestamp");
470
- global.setProperty(rt, eventTimestampName, currentTime);
471
- onEvent(eventName, std::move(payload));
472
- global.setProperty(rt, eventTimestampName, jsi::Value::undefined());
472
+ onEvent(currentTime, eventName, payload);
473
473
 
474
474
  // TODO: return true if Reanimated successfully handled the event
475
475
  // to avoid sending it to JavaScript
476
476
  return false;
477
477
  }
478
478
 
479
+ #ifdef RCT_NEW_ARCH_ENABLED
479
480
  bool NativeReanimatedModule::handleRawEvent(
480
481
  const RawEvent &rawEvent,
481
482
  double currentTime) {
@@ -499,7 +500,13 @@ bool NativeReanimatedModule::handleRawEvent(
499
500
  jsi::Runtime &rt = *runtime.get();
500
501
  jsi::Value payload = payloadFactory(rt);
501
502
 
502
- return handleEvent(eventName, std::move(payload), currentTime);
503
+ auto res = handleEvent(eventName, std::move(payload), currentTime);
504
+ // TODO: we should call performOperations conditionally if event is handled
505
+ // (res == true), but for now handleEvent always returns false. Thankfully,
506
+ // performOperations does not trigger a lot of code if there is nothing to be
507
+ // done so this is fine for now.
508
+ performOperations();
509
+ return res;
503
510
  }
504
511
 
505
512
  void NativeReanimatedModule::updateProps(
@@ -538,36 +545,33 @@ void NativeReanimatedModule::performOperations() {
538
545
  jsi::Runtime &rt = *runtime.get();
539
546
 
540
547
  shadowTreeRegistry.visit(surfaceId_, [&](ShadowTree const &shadowTree) {
548
+ auto lock = newestShadowNodesRegistry_->createLock();
549
+
541
550
  shadowTree.commit([&](RootShadowNode const &oldRootShadowNode) {
542
551
  auto rootNode = oldRootShadowNode.ShadowNode::clone(ShadowNodeFragment{});
543
552
 
544
553
  ShadowTreeCloner shadowTreeCloner{
545
554
  newestShadowNodesRegistry_, uiManager_, surfaceId_};
546
555
 
547
- {
548
- // lock once due to performance reasons
549
- auto lock = newestShadowNodesRegistry_->createLock();
550
-
551
- for (const auto &pair : copiedOperationsQueue) {
552
- const ShadowNodeFamily &family = pair.first->getFamily();
553
- react_native_assert(family.getSurfaceId() == surfaceId_);
556
+ for (const auto &pair : copiedOperationsQueue) {
557
+ const ShadowNodeFamily &family = pair.first->getFamily();
558
+ react_native_assert(family.getSurfaceId() == surfaceId_);
554
559
 
555
- auto newRootNode = shadowTreeCloner.cloneWithNewProps(
556
- rootNode, family, RawProps(rt, *pair.second));
560
+ auto newRootNode = shadowTreeCloner.cloneWithNewProps(
561
+ rootNode, family, RawProps(rt, *pair.second));
557
562
 
558
- if (newRootNode == nullptr) {
559
- // this happens when React removed the component but Reanimated
560
- // still tries to animate it, let's skip update for this specific
561
- // component
562
- continue;
563
- }
564
- rootNode = newRootNode;
563
+ if (newRootNode == nullptr) {
564
+ // this happens when React removed the component but Reanimated
565
+ // still tries to animate it, let's skip update for this specific
566
+ // component
567
+ continue;
565
568
  }
569
+ rootNode = newRootNode;
570
+ }
566
571
 
567
- // remove ShadowNodes and its ancestors from NewestShadowNodesRegistry
568
- for (auto tag : copiedTagsToRemove) {
569
- newestShadowNodesRegistry_->remove(tag);
570
- }
572
+ // remove ShadowNodes and its ancestors from NewestShadowNodesRegistry
573
+ for (auto tag : copiedTagsToRemove) {
574
+ newestShadowNodesRegistry_->remove(tag);
571
575
  }
572
576
 
573
577
  shadowTreeCloner.updateYogaChildren();
@@ -579,9 +583,8 @@ void NativeReanimatedModule::performOperations() {
579
583
 
580
584
  void NativeReanimatedModule::removeShadowNodeFromRegistry(
581
585
  jsi::Runtime &rt,
582
- const jsi::Value &shadowNodeValue) {
583
- auto shadowNode = shadowNodeFromValue(rt, shadowNodeValue);
584
- tagsToRemove_.push_back(shadowNode->getTag());
586
+ const jsi::Value &tag) {
587
+ tagsToRemove_.push_back(tag.asNumber());
585
588
  }
586
589
 
587
590
  void NativeReanimatedModule::dispatchCommand(
@@ -592,9 +595,7 @@ void NativeReanimatedModule::dispatchCommand(
592
595
  ShadowNode::Shared shadowNode = shadowNodeFromValue(rt, shadowNodeValue);
593
596
  std::string commandName = stringFromValue(rt, commandNameValue);
594
597
  folly::dynamic args = commandArgsFromValue(rt, argsValue);
595
-
596
- // TODO: use uiManager_->dispatchCommand once it's public
597
- UIManager_dispatchCommand(uiManager_, shadowNode, commandName, args);
598
+ uiManager_->dispatchCommand(shadowNode, commandName, args);
598
599
  }
599
600
 
600
601
  jsi::Value NativeReanimatedModule::measure(
@@ -603,11 +604,8 @@ jsi::Value NativeReanimatedModule::measure(
603
604
  // based on implementation from UIManagerBinding.cpp
604
605
 
605
606
  auto shadowNode = shadowNodeFromValue(rt, shadowNodeValue);
606
- // TODO: use uiManager_->getRelativeLayoutMetrics once it's public
607
- // auto layoutMetrics = uiManager_->getRelativeLayoutMetrics(
608
- // *shadowNode, nullptr, {/* .includeTransform = */ true});
609
- auto layoutMetrics = UIManager_getRelativeLayoutMetrics(
610
- uiManager_, *shadowNode, nullptr, {/* .includeTransform = */ true});
607
+ auto layoutMetrics = uiManager_->getRelativeLayoutMetrics(
608
+ *shadowNode, nullptr, {/* .includeTransform = */ true});
611
609
 
612
610
  if (layoutMetrics == EmptyLayoutMetrics) {
613
611
  // Originally, in this case React Native returns `{0, 0, 0, 0, 0, 0}`, most
@@ -621,7 +619,8 @@ jsi::Value NativeReanimatedModule::measure(
621
619
 
622
620
  auto layoutableShadowNode =
623
621
  traitCast<LayoutableShadowNode const *>(newestCloneOfShadowNode.get());
624
- facebook::react::Point originRelativeToParent = layoutableShadowNode
622
+ facebook::react::Point originRelativeToParent =
623
+ layoutableShadowNode != nullptr
625
624
  ? layoutableShadowNode->getLayoutMetrics().frame.origin
626
625
  : facebook::react::Point();
627
626
 
@@ -656,15 +655,17 @@ void NativeReanimatedModule::setNewestShadowNodesRegistry(
656
655
 
657
656
  jsi::Value NativeReanimatedModule::subscribeForKeyboardEvents(
658
657
  jsi::Runtime &rt,
659
- const jsi::Value &handlerWorklet) {
658
+ const jsi::Value &handlerWorklet,
659
+ const jsi::Value &isStatusBarTranslucent) {
660
660
  auto shareableHandler = extractShareableOrThrow(rt, handlerWorklet);
661
- auto uiRuntime = runtimeHelper->uiRuntime();
662
- return subscribeForKeyboardEventsFunction([=](int keyboardState, int height) {
663
- jsi::Runtime &rt = *uiRuntime;
664
- auto handler = shareableHandler->getJSValue(rt);
665
- handler.asObject(rt).asFunction(rt).call(
666
- rt, jsi::Value(keyboardState), jsi::Value(height));
667
- });
661
+ return subscribeForKeyboardEventsFunction(
662
+ [=](int keyboardState, int height) {
663
+ jsi::Runtime &rt = *runtimeHelper->uiRuntime();
664
+ auto handler = shareableHandler->getJSValue(rt);
665
+ runtimeHelper->runOnUIGuarded(
666
+ handler, jsi::Value(keyboardState), jsi::Value(height));
667
+ },
668
+ isStatusBarTranslucent.getBool());
668
669
  }
669
670
 
670
671
  void NativeReanimatedModule::unsubscribeFromKeyboardEvents(
@@ -49,11 +49,13 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec,
49
49
 
50
50
  void installCoreFunctions(
51
51
  jsi::Runtime &rt,
52
- const jsi::Value &workletMaker,
53
- const jsi::Value &layoutAnimationStartFunction) override;
52
+ const jsi::Value &callGuard,
53
+ const jsi::Value &valueUnpacker) override;
54
54
 
55
- jsi::Value makeShareableClone(jsi::Runtime &rt, const jsi::Value &value)
56
- override;
55
+ jsi::Value makeShareableClone(
56
+ jsi::Runtime &rt,
57
+ const jsi::Value &value,
58
+ const jsi::Value &shouldRetainRemote) override;
57
59
 
58
60
  jsi::Value makeSynchronizedDataHolder(
59
61
  jsi::Runtime &rt,
@@ -92,14 +94,16 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec,
92
94
  jsi::Runtime &rt,
93
95
  const jsi::Value &viewTag,
94
96
  const jsi::Value &type,
97
+ const jsi::Value &sharedTransitionTag,
95
98
  const jsi::Value &config) override;
96
99
 
97
100
  void onRender(double timestampMs);
98
- #ifdef RCT_NEW_ARCH_ENABLED
99
- void onEvent(std::string eventName, jsi::Value &&eventAsString);
100
- #else
101
- void onEvent(std::string eventName, std::string eventAsString);
102
- #endif
101
+
102
+ void onEvent(
103
+ double eventTimestamp,
104
+ const std::string &eventName,
105
+ const jsi::Value &payload);
106
+
103
107
  bool isAnyHandlerWaitingForEvent(std::string eventName);
104
108
 
105
109
  void maybeRequestRender();
@@ -107,7 +111,7 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec,
107
111
 
108
112
  bool handleEvent(
109
113
  const std::string &eventName,
110
- jsi::Value &&payload,
114
+ const jsi::Value &payload,
111
115
  double currentTime);
112
116
 
113
117
  #ifdef RCT_NEW_ARCH_ENABLED
@@ -118,9 +122,7 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec,
118
122
  const jsi::Value &shadowNodeValue,
119
123
  const jsi::Value &props);
120
124
 
121
- void removeShadowNodeFromRegistry(
122
- jsi::Runtime &rt,
123
- const jsi::Value &shadowNodeValue);
125
+ void removeShadowNodeFromRegistry(jsi::Runtime &rt, const jsi::Value &tag);
124
126
 
125
127
  void performOperations();
126
128
 
@@ -142,11 +144,16 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec,
142
144
  jsi::Runtime &rt,
143
145
  const jsi::Value &sensorType,
144
146
  const jsi::Value &interval,
147
+ const jsi::Value &iosReferenceFrame,
145
148
  const jsi::Value &sensorDataContainer) override;
146
149
  void unregisterSensor(jsi::Runtime &rt, const jsi::Value &sensorId) override;
150
+
151
+ void cleanupSensors();
152
+
147
153
  jsi::Value subscribeForKeyboardEvents(
148
154
  jsi::Runtime &rt,
149
- const jsi::Value &keyboardEventContainer) override;
155
+ const jsi::Value &keyboardEventContainer,
156
+ const jsi::Value &isStatusBarTranslucent) override;
150
157
  void unsubscribeFromKeyboardEvents(
151
158
  jsi::Runtime &rt,
152
159
  const jsi::Value &listenerId) override;
@@ -24,7 +24,7 @@ static jsi::Value SPEC_PREFIX(makeShareableClone)(
24
24
  const jsi::Value *args,
25
25
  size_t count) {
26
26
  return static_cast<NativeReanimatedModuleSpec *>(&turboModule)
27
- ->makeShareableClone(rt, std::move(args[0]));
27
+ ->makeShareableClone(rt, std::move(args[0]), std::move(args[1]));
28
28
  }
29
29
 
30
30
  // Sync methods
@@ -106,7 +106,11 @@ static jsi::Value SPEC_PREFIX(registerSensor)(
106
106
  size_t count) {
107
107
  return static_cast<NativeReanimatedModuleSpec *>(&turboModule)
108
108
  ->registerSensor(
109
- rt, std::move(args[0]), std::move(args[1]), std::move(args[2]));
109
+ rt,
110
+ std::move(args[0]),
111
+ std::move(args[1]),
112
+ std::move(args[2]),
113
+ std::move(args[3]));
110
114
  }
111
115
 
112
116
  static jsi::Value SPEC_PREFIX(unregisterSensor)(
@@ -135,7 +139,7 @@ static jsi::Value SPEC_PREFIX(subscribeForKeyboardEvents)(
135
139
  const jsi::Value *args,
136
140
  size_t count) {
137
141
  return static_cast<NativeReanimatedModuleSpec *>(&turboModule)
138
- ->subscribeForKeyboardEvents(rt, std::move(args[0]));
142
+ ->subscribeForKeyboardEvents(rt, std::move(args[0]), std::move(args[1]));
139
143
  }
140
144
 
141
145
  static jsi::Value SPEC_PREFIX(unsubscribeFromKeyboardEvents)(
@@ -155,7 +159,11 @@ static jsi::Value SPEC_PREFIX(configureLayoutAnimation)(
155
159
  size_t count) {
156
160
  return static_cast<NativeReanimatedModuleSpec *>(&turboModule)
157
161
  ->configureLayoutAnimation(
158
- rt, std::move(args[0]), std::move(args[1]), std::move(args[2]));
162
+ rt,
163
+ std::move(args[0]),
164
+ std::move(args[1]),
165
+ std::move(args[2]),
166
+ std::move(args[3]));
159
167
  }
160
168
 
161
169
  NativeReanimatedModuleSpec::NativeReanimatedModuleSpec(
@@ -165,7 +173,7 @@ NativeReanimatedModuleSpec::NativeReanimatedModuleSpec(
165
173
  MethodMetadata{2, SPEC_PREFIX(installCoreFunctions)};
166
174
 
167
175
  methodMap_["makeShareableClone"] =
168
- MethodMetadata{1, SPEC_PREFIX(makeShareableClone)};
176
+ MethodMetadata{2, SPEC_PREFIX(makeShareableClone)};
169
177
 
170
178
  methodMap_["makeSynchronizedDataHolder"] =
171
179
  MethodMetadata{1, SPEC_PREFIX(makeSynchronizedDataHolder)};
@@ -182,12 +190,12 @@ NativeReanimatedModuleSpec::NativeReanimatedModuleSpec(
182
190
  methodMap_["getViewProp"] = MethodMetadata{3, SPEC_PREFIX(getViewProp)};
183
191
  methodMap_["enableLayoutAnimations"] =
184
192
  MethodMetadata{2, SPEC_PREFIX(enableLayoutAnimations)};
185
- methodMap_["registerSensor"] = MethodMetadata{3, SPEC_PREFIX(registerSensor)};
193
+ methodMap_["registerSensor"] = MethodMetadata{4, SPEC_PREFIX(registerSensor)};
186
194
  methodMap_["unregisterSensor"] =
187
195
  MethodMetadata{1, SPEC_PREFIX(unregisterSensor)};
188
196
  methodMap_["configureProps"] = MethodMetadata{2, SPEC_PREFIX(configureProps)};
189
197
  methodMap_["subscribeForKeyboardEvents"] =
190
- MethodMetadata{1, SPEC_PREFIX(subscribeForKeyboardEvents)};
198
+ MethodMetadata{2, SPEC_PREFIX(subscribeForKeyboardEvents)};
191
199
  methodMap_["unsubscribeFromKeyboardEvents"] =
192
200
  MethodMetadata{1, SPEC_PREFIX(unsubscribeFromKeyboardEvents)};
193
201
 
@@ -24,13 +24,14 @@ class JSI_EXPORT NativeReanimatedModuleSpec : public TurboModule {
24
24
  public:
25
25
  virtual void installCoreFunctions(
26
26
  jsi::Runtime &rt,
27
- const jsi::Value &valueUnpacker,
28
- const jsi::Value &layoutAnimationStartFunction) = 0;
27
+ const jsi::Value &callGuard,
28
+ const jsi::Value &valueUnpacker) = 0;
29
29
 
30
30
  // SharedValue
31
31
  virtual jsi::Value makeShareableClone(
32
32
  jsi::Runtime &rt,
33
- const jsi::Value &value) = 0;
33
+ const jsi::Value &value,
34
+ const jsi::Value &shouldRetainRemote) = 0;
34
35
 
35
36
  // Synchronized data objects
36
37
  virtual jsi::Value makeSynchronizedDataHolder(
@@ -64,6 +65,7 @@ class JSI_EXPORT NativeReanimatedModuleSpec : public TurboModule {
64
65
  jsi::Runtime &rt,
65
66
  const jsi::Value &sensorType,
66
67
  const jsi::Value &interval,
68
+ const jsi::Value &iosReferenceFrame,
67
69
  const jsi::Value &sensorDataContainer) = 0;
68
70
  virtual void unregisterSensor(
69
71
  jsi::Runtime &rt,
@@ -72,7 +74,8 @@ class JSI_EXPORT NativeReanimatedModuleSpec : public TurboModule {
72
74
  // keyboard
73
75
  virtual jsi::Value subscribeForKeyboardEvents(
74
76
  jsi::Runtime &rt,
75
- const jsi::Value &keyboardEventContainer) = 0;
77
+ const jsi::Value &keyboardEventContainer,
78
+ const jsi::Value &isStatusBarTranslucent) = 0;
76
79
  virtual void unsubscribeFromKeyboardEvents(
77
80
  jsi::Runtime &rt,
78
81
  const jsi::Value &listenerId) = 0;
@@ -91,6 +94,7 @@ class JSI_EXPORT NativeReanimatedModuleSpec : public TurboModule {
91
94
  jsi::Runtime &rt,
92
95
  const jsi::Value &viewTag,
93
96
  const jsi::Value &type,
97
+ const jsi::Value &sharedTransitionTag,
94
98
  const jsi::Value &config) = 0;
95
99
  };
96
100