react-native-reanimated 3.0.0-rc.9 → 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 (329) 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 +105 -109
  10. package/Common/cpp/NativeModules/NativeReanimatedModule.h +19 -12
  11. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +15 -7
  12. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +6 -2
  13. package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +20 -1
  14. package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +9 -0
  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 +9 -63
  19. package/Common/cpp/SharedItems/Shareables.h +77 -72
  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 +49 -230
  27. package/Common/cpp/Tools/RuntimeDecorator.h +0 -2
  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 +28 -4
  62. package/ios/LayoutReanimation/REAAnimationsManager.m +216 -61
  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 +64 -17
  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 +16 -33
  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/core.js +33 -14
  97. package/lib/commonjs/reanimated2/core.js.map +1 -1
  98. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
  99. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  100. package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
  101. package/lib/commonjs/reanimated2/hook/index.js +0 -6
  102. package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
  103. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +5 -2
  104. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  105. package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +13 -1
  106. package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  107. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +1 -1
  108. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
  109. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +89 -16
  110. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  111. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +43 -40
  112. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  113. package/lib/commonjs/reanimated2/hook/useDerivedValue.js +13 -1
  114. package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
  115. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +2 -2
  116. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  117. package/lib/commonjs/reanimated2/hook/utils.js +18 -65
  118. package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
  119. package/lib/commonjs/reanimated2/index.js +13 -0
  120. package/lib/commonjs/reanimated2/index.js.map +1 -1
  121. package/lib/commonjs/reanimated2/initializers.js +71 -32
  122. package/lib/commonjs/reanimated2/initializers.js.map +1 -1
  123. package/lib/commonjs/reanimated2/interpolateColor.js +96 -19
  124. package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
  125. package/lib/commonjs/reanimated2/jestUtils.js +1 -1
  126. package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
  127. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +103 -13
  128. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  129. package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +22 -0
  130. package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
  131. package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js +2 -0
  132. package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js.map +1 -0
  133. package/lib/commonjs/reanimated2/js-reanimated/commonTypes.js.map +1 -1
  134. package/lib/commonjs/reanimated2/js-reanimated/global.js +0 -2
  135. package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
  136. package/lib/commonjs/reanimated2/js-reanimated/index.js +0 -1
  137. package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
  138. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +11 -0
  139. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  140. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +8 -0
  141. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  142. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +17 -9
  143. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  144. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -23
  145. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  146. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -14
  147. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  148. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -14
  149. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  150. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -15
  151. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  152. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -23
  153. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  154. package/lib/commonjs/reanimated2/layoutReanimation/index.js +13 -0
  155. package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
  156. package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +94 -0
  157. package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
  158. package/lib/commonjs/reanimated2/mappers.js +18 -6
  159. package/lib/commonjs/reanimated2/mappers.js.map +1 -1
  160. package/lib/commonjs/reanimated2/mock.js +20 -1
  161. package/lib/commonjs/reanimated2/mock.js.map +1 -1
  162. package/lib/commonjs/reanimated2/mutables.js +4 -2
  163. package/lib/commonjs/reanimated2/mutables.js.map +1 -1
  164. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +42 -0
  165. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +1 -0
  166. package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +15 -0
  167. package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
  168. package/lib/commonjs/reanimated2/pluginUtils.js +11 -0
  169. package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -0
  170. package/lib/commonjs/reanimated2/shareables.js +36 -15
  171. package/lib/commonjs/reanimated2/shareables.js.map +1 -1
  172. package/lib/commonjs/reanimated2/threads.js +114 -4
  173. package/lib/commonjs/reanimated2/threads.js.map +1 -1
  174. package/lib/commonjs/reanimated2/utils.js +7 -0
  175. package/lib/commonjs/reanimated2/utils.js.map +1 -1
  176. package/lib/commonjs/reanimated2/valueSetter.js +1 -3
  177. package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
  178. package/lib/module/createAnimatedComponent.js +229 -29
  179. package/lib/module/createAnimatedComponent.js.map +1 -1
  180. package/lib/module/reanimated2/Colors.js +35 -19
  181. package/lib/module/reanimated2/Colors.js.map +1 -1
  182. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +16 -32
  183. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  184. package/lib/module/reanimated2/animation/styleAnimation.js +5 -1
  185. package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
  186. package/lib/module/reanimated2/animation/util.js +17 -16
  187. package/lib/module/reanimated2/animation/util.js.map +1 -1
  188. package/lib/module/reanimated2/commonTypes.js +29 -0
  189. package/lib/module/reanimated2/commonTypes.js.map +1 -1
  190. package/lib/module/reanimated2/core.js +32 -7
  191. package/lib/module/reanimated2/core.js.map +1 -1
  192. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
  193. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  194. package/lib/module/reanimated2/globals.d.js.map +1 -1
  195. package/lib/module/reanimated2/hook/index.js +1 -1
  196. package/lib/module/reanimated2/hook/index.js.map +1 -1
  197. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +5 -2
  198. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  199. package/lib/module/reanimated2/hook/useAnimatedReaction.js +12 -1
  200. package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  201. package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
  202. package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
  203. package/lib/module/reanimated2/hook/useAnimatedSensor.js +88 -13
  204. package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  205. package/lib/module/reanimated2/hook/useAnimatedStyle.js +46 -43
  206. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  207. package/lib/module/reanimated2/hook/useDerivedValue.js +12 -1
  208. package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
  209. package/lib/module/reanimated2/hook/useScrollViewOffset.js +2 -2
  210. package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  211. package/lib/module/reanimated2/hook/utils.js +17 -60
  212. package/lib/module/reanimated2/hook/utils.js.map +1 -1
  213. package/lib/module/reanimated2/index.js +1 -0
  214. package/lib/module/reanimated2/index.js.map +1 -1
  215. package/lib/module/reanimated2/initializers.js +72 -33
  216. package/lib/module/reanimated2/initializers.js.map +1 -1
  217. package/lib/module/reanimated2/interpolateColor.js +96 -19
  218. package/lib/module/reanimated2/interpolateColor.js.map +1 -1
  219. package/lib/module/reanimated2/jestUtils.js +1 -1
  220. package/lib/module/reanimated2/jestUtils.js.map +1 -1
  221. package/lib/module/reanimated2/js-reanimated/JSReanimated.js +103 -13
  222. package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  223. package/lib/module/reanimated2/js-reanimated/Mapper.js +21 -0
  224. package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
  225. package/lib/module/reanimated2/js-reanimated/WebSensor.js +2 -0
  226. package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -0
  227. package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
  228. package/lib/module/reanimated2/js-reanimated/global.js +0 -2
  229. package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
  230. package/lib/module/reanimated2/js-reanimated/index.js +0 -1
  231. package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
  232. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +9 -1
  233. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  234. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js +1 -0
  235. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  236. package/lib/module/reanimated2/layoutReanimation/animationsManager.js +15 -8
  237. package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  238. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -21
  239. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  240. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -12
  241. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  242. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
  243. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  244. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -13
  245. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  246. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -21
  247. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  248. package/lib/module/reanimated2/layoutReanimation/index.js +1 -0
  249. package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
  250. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +82 -0
  251. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
  252. package/lib/module/reanimated2/mappers.js +16 -6
  253. package/lib/module/reanimated2/mappers.js.map +1 -1
  254. package/lib/module/reanimated2/mock.js +20 -1
  255. package/lib/module/reanimated2/mock.js.map +1 -1
  256. package/lib/module/reanimated2/mutables.js +4 -2
  257. package/lib/module/reanimated2/mutables.js.map +1 -1
  258. package/lib/module/reanimated2/platform-specific/checkVersion.js +35 -0
  259. package/lib/module/reanimated2/platform-specific/checkVersion.js.map +1 -0
  260. package/lib/module/reanimated2/platform-specific/checkVersion.web.js +8 -0
  261. package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
  262. package/lib/module/reanimated2/pluginUtils.js +4 -0
  263. package/lib/module/reanimated2/pluginUtils.js.map +1 -0
  264. package/lib/module/reanimated2/shareables.js +36 -12
  265. package/lib/module/reanimated2/shareables.js.map +1 -1
  266. package/lib/module/reanimated2/threads.js +105 -4
  267. package/lib/module/reanimated2/threads.js.map +1 -1
  268. package/lib/module/reanimated2/utils.js +5 -0
  269. package/lib/module/reanimated2/utils.js.map +1 -1
  270. package/lib/module/reanimated2/valueSetter.js +1 -2
  271. package/lib/module/reanimated2/valueSetter.js.map +1 -1
  272. package/package.json +10 -10
  273. package/{plugin.js → plugin/index.js} +128 -249
  274. package/react-native-reanimated.d.ts +57 -10
  275. package/scripts/reanimated_utils.rb +15 -2
  276. package/src/createAnimatedComponent.tsx +238 -28
  277. package/src/reanimated2/Colors.ts +38 -11
  278. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +52 -39
  279. package/src/reanimated2/animation/styleAnimation.ts +8 -1
  280. package/src/reanimated2/animation/util.ts +29 -16
  281. package/src/reanimated2/commonTypes.ts +28 -1
  282. package/src/reanimated2/core.ts +42 -9
  283. package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +2 -2
  284. package/src/reanimated2/globals.d.ts +12 -15
  285. package/src/reanimated2/hook/index.ts +1 -1
  286. package/src/reanimated2/hook/useAnimatedKeyboard.ts +10 -4
  287. package/src/reanimated2/hook/useAnimatedReaction.ts +12 -5
  288. package/src/reanimated2/hook/useAnimatedRef.ts +1 -4
  289. package/src/reanimated2/hook/useAnimatedSensor.ts +88 -11
  290. package/src/reanimated2/hook/useAnimatedStyle.ts +44 -36
  291. package/src/reanimated2/hook/useDerivedValue.ts +8 -1
  292. package/src/reanimated2/hook/useScrollViewOffset.ts +2 -2
  293. package/src/reanimated2/hook/utils.ts +15 -61
  294. package/src/reanimated2/index.ts +1 -0
  295. package/src/reanimated2/initializers.ts +76 -35
  296. package/src/reanimated2/interpolateColor.ts +104 -20
  297. package/src/reanimated2/jestUtils.ts +1 -1
  298. package/src/reanimated2/js-reanimated/JSReanimated.ts +98 -15
  299. package/src/reanimated2/js-reanimated/Mapper.ts +32 -0
  300. package/src/reanimated2/js-reanimated/WebSensor.ts +34 -0
  301. package/src/reanimated2/js-reanimated/commonTypes.ts +0 -1
  302. package/src/reanimated2/js-reanimated/global.ts +0 -1
  303. package/src/reanimated2/js-reanimated/index.ts +0 -1
  304. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +13 -1
  305. package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
  306. package/src/reanimated2/layoutReanimation/animationsManager.ts +17 -9
  307. package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +16 -19
  308. package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +14 -11
  309. package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +21 -11
  310. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -11
  311. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +36 -19
  312. package/src/reanimated2/layoutReanimation/index.ts +1 -0
  313. package/src/reanimated2/layoutReanimation/sharedTransitions/index.ts +87 -0
  314. package/src/reanimated2/mappers.ts +17 -6
  315. package/src/reanimated2/mock.ts +24 -1
  316. package/src/reanimated2/mutables.ts +2 -0
  317. package/src/reanimated2/platform-specific/checkVersion.ts +39 -0
  318. package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
  319. package/src/reanimated2/pluginUtils.ts +8 -0
  320. package/src/reanimated2/shareables.ts +45 -16
  321. package/src/reanimated2/threads.ts +103 -1
  322. package/src/reanimated2/utils.ts +6 -0
  323. package/src/reanimated2/valueSetter.ts +1 -2
  324. package/lib/commonjs/reanimated2/time.js +0 -55
  325. package/lib/commonjs/reanimated2/time.js.map +0 -1
  326. package/lib/module/reanimated2/time.js +0 -37
  327. package/lib/module/reanimated2/time.js.map +0 -1
  328. package/src/reanimated2/time.ts +0 -30
  329. /package/android/src/{main/java → reactNativeVersionPatch/ReanimatedUIManager/70}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -0
@@ -99,7 +99,7 @@ NativeReanimatedModule::NativeReanimatedModule(
99
99
  };
100
100
 
101
101
  auto makeShareableClone = [this](jsi::Runtime &rt, const jsi::Value &value) {
102
- return this->makeShareableClone(rt, value);
102
+ return this->makeShareableClone(rt, value, jsi::Value::undefined());
103
103
  };
104
104
 
105
105
  auto updateDataSynchronously =
@@ -120,8 +120,8 @@ NativeReanimatedModule::NativeReanimatedModule(
120
120
  };
121
121
 
122
122
  auto removeShadowNodeFromRegistry =
123
- [this](jsi::Runtime &rt, const jsi::Value &shadowNodeValue) {
124
- this->removeShadowNodeFromRegistry(rt, shadowNodeValue);
123
+ [this](jsi::Runtime &rt, const jsi::Value &tag) {
124
+ this->removeShadowNodeFromRegistry(rt, tag);
125
125
  };
126
126
 
127
127
  auto measure = [this](jsi::Runtime &rt, const jsi::Value &shadowNodeValue) {
@@ -154,8 +154,6 @@ NativeReanimatedModule::NativeReanimatedModule(
154
154
  makeShareableClone,
155
155
  updateDataSynchronously,
156
156
  platformDepMethodsHolder.getCurrentTime,
157
- platformDepMethodsHolder.registerSensor,
158
- platformDepMethodsHolder.unregisterSensor,
159
157
  platformDepMethodsHolder.setGestureStateFunction,
160
158
  platformDepMethodsHolder.progressLayoutAnimation,
161
159
  platformDepMethodsHolder.endLayoutAnimation);
@@ -246,7 +244,8 @@ jsi::Value NativeReanimatedModule::getDataSynchronously(
246
244
 
247
245
  jsi::Value NativeReanimatedModule::makeShareableClone(
248
246
  jsi::Runtime &rt,
249
- const jsi::Value &value) {
247
+ const jsi::Value &value,
248
+ const jsi::Value &shouldRetainRemote) {
250
249
  std::shared_ptr<Shareable> shareable;
251
250
  if (value.isObject()) {
252
251
  auto object = value.asObject(rt);
@@ -258,18 +257,25 @@ jsi::Value NativeReanimatedModule::makeShareableClone(
258
257
  shareable = std::make_shared<ShareableRemoteFunction>(
259
258
  runtimeHelper, rt, object.asFunction(rt));
260
259
  } else if (object.isArray(rt)) {
261
- shareable = std::make_shared<ShareableArray>(
262
- runtimeHelper, rt, object.asArray(rt));
263
- #ifdef RCT_NEW_ARCH_ENABLED
264
- } else if (object.isHostObject<ShadowNodeWrapper>(rt)) {
265
- shareable = std::make_shared<ShareableShadowNodeWrapper>(
266
- runtimeHelper, rt, object);
267
- #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));
268
269
  } else {
269
- 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
+ }
270
276
  }
271
277
  } else if (value.isString()) {
272
- shareable = std::make_shared<ShareableString>(rt, value.asString(rt));
278
+ shareable = std::make_shared<ShareableString>(value.asString(rt).utf8(rt));
273
279
  } else if (value.isUndefined()) {
274
280
  shareable = std::make_shared<ShareableScalar>();
275
281
  } else if (value.isNull()) {
@@ -278,6 +284,13 @@ jsi::Value NativeReanimatedModule::makeShareableClone(
278
284
  shareable = std::make_shared<ShareableScalar>(value.getBool());
279
285
  } else if (value.isNumber()) {
280
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));
281
294
  } else {
282
295
  throw std::runtime_error("attempted to convert an unsupported value type");
283
296
  }
@@ -288,19 +301,21 @@ jsi::Value NativeReanimatedModule::registerEventHandler(
288
301
  jsi::Runtime &rt,
289
302
  const jsi::Value &eventHash,
290
303
  const jsi::Value &worklet) {
291
- static unsigned long EVENT_HANDLER_ID = 1;
304
+ static uint64_t EVENT_HANDLER_ID = 1;
292
305
 
293
- unsigned long newRegistrationId = EVENT_HANDLER_ID++;
306
+ uint64_t newRegistrationId = EVENT_HANDLER_ID++;
294
307
  auto eventName = eventHash.asString(rt).utf8(rt);
295
308
  auto handlerShareable = extractShareableOrThrow(rt, worklet);
296
309
 
297
310
  scheduler->scheduleOnUI([=] {
298
311
  jsi::Runtime &rt = *runtimeHelper->uiRuntime();
299
- auto handlerFunction =
300
- handlerShareable->getJSValue(rt).asObject(rt).asFunction(rt);
312
+ auto handlerFunction = handlerShareable->getJSValue(rt);
301
313
  auto handler = std::make_shared<WorkletEventHandler>(
302
- newRegistrationId, eventName, std::move(handlerFunction));
303
- eventHandlerRegistry->registerEventHandler(handler);
314
+ runtimeHelper,
315
+ newRegistrationId,
316
+ eventName,
317
+ std::move(handlerFunction));
318
+ eventHandlerRegistry->registerEventHandler(std::move(handler));
304
319
  });
305
320
 
306
321
  return jsi::Value(static_cast<double>(newRegistrationId));
@@ -309,7 +324,7 @@ jsi::Value NativeReanimatedModule::registerEventHandler(
309
324
  void NativeReanimatedModule::unregisterEventHandler(
310
325
  jsi::Runtime &rt,
311
326
  const jsi::Value &registrationId) {
312
- unsigned long id = registrationId.asNumber();
327
+ uint64_t id = registrationId.asNumber();
313
328
  scheduler->scheduleOnUI(
314
329
  [=] { eventHandlerRegistry->unregisterEventHandler(id); });
315
330
  }
@@ -369,37 +384,22 @@ jsi::Value NativeReanimatedModule::configureLayoutAnimation(
369
384
  jsi::Runtime &rt,
370
385
  const jsi::Value &viewTag,
371
386
  const jsi::Value &type,
387
+ const jsi::Value &sharedTransitionTag,
372
388
  const jsi::Value &config) {
373
389
  layoutAnimationsManager_.configureAnimation(
374
390
  viewTag.asNumber(),
375
- type.asString(rt).utf8(rt),
391
+ static_cast<LayoutAnimationType>(type.asNumber()),
392
+ sharedTransitionTag.asString(rt).utf8(rt),
376
393
  extractShareableOrThrow(rt, config));
377
394
  return jsi::Value::undefined();
378
395
  }
379
396
 
380
397
  void NativeReanimatedModule::onEvent(
381
- std::string eventName,
382
- #ifdef RCT_NEW_ARCH_ENABLED
383
- jsi::Value &&payload
384
- #else
385
- std::string eventAsString
386
- #endif
387
- /**/) {
388
- try {
389
- #ifdef RCT_NEW_ARCH_ENABLED
390
- eventHandlerRegistry->processEvent(*runtime, eventName, payload);
391
- #else
392
- eventHandlerRegistry->processEvent(*runtime, eventName, eventAsString);
393
- #endif
394
- } catch (std::exception &e) {
395
- std::string str = e.what();
396
- this->errorHandler->setError(str);
397
- this->errorHandler->raise();
398
- } catch (...) {
399
- std::string str = "OnEvent error";
400
- this->errorHandler->setError(str);
401
- this->errorHandler->raise();
402
- }
398
+ double eventTimestamp,
399
+ const std::string &eventName,
400
+ const jsi::Value &payload) {
401
+ eventHandlerRegistry->processEvent(
402
+ *runtime, eventTimestamp, eventName, payload);
403
403
  }
404
404
 
405
405
  bool NativeReanimatedModule::isAnyHandlerWaitingForEvent(
@@ -415,20 +415,10 @@ void NativeReanimatedModule::maybeRequestRender() {
415
415
  }
416
416
 
417
417
  void NativeReanimatedModule::onRender(double timestampMs) {
418
- try {
419
- std::vector<FrameCallback> callbacks = frameCallbacks;
420
- frameCallbacks.clear();
421
- for (auto &callback : callbacks) {
422
- callback(timestampMs);
423
- }
424
- } catch (std::exception &e) {
425
- std::string str = e.what();
426
- this->errorHandler->setError(str);
427
- this->errorHandler->raise();
428
- } catch (...) {
429
- std::string str = "OnRender error";
430
- this->errorHandler->setError(str);
431
- this->errorHandler->raise();
418
+ std::vector<FrameCallback> callbacks = frameCallbacks;
419
+ frameCallbacks.clear();
420
+ for (auto &callback : callbacks) {
421
+ callback(timestampMs);
432
422
  }
433
423
  }
434
424
 
@@ -436,9 +426,15 @@ jsi::Value NativeReanimatedModule::registerSensor(
436
426
  jsi::Runtime &rt,
437
427
  const jsi::Value &sensorType,
438
428
  const jsi::Value &interval,
429
+ const jsi::Value &iosReferenceFrame,
439
430
  const jsi::Value &sensorDataHandler) {
440
431
  return animatedSensorModule.registerSensor(
441
- rt, runtimeHelper, sensorType, interval, sensorDataHandler);
432
+ rt,
433
+ runtimeHelper,
434
+ sensorType,
435
+ interval,
436
+ iosReferenceFrame,
437
+ sensorDataHandler);
442
438
  }
443
439
 
444
440
  void NativeReanimatedModule::unregisterSensor(
@@ -447,6 +443,10 @@ void NativeReanimatedModule::unregisterSensor(
447
443
  animatedSensorModule.unregisterSensor(sensorId);
448
444
  }
449
445
 
446
+ void NativeReanimatedModule::cleanupSensors() {
447
+ animatedSensorModule.unregisterAllSensors();
448
+ }
449
+
450
450
  #ifdef RCT_NEW_ARCH_ENABLED
451
451
  bool NativeReanimatedModule::isThereAnyLayoutProp(
452
452
  jsi::Runtime &rt,
@@ -463,24 +463,20 @@ bool NativeReanimatedModule::isThereAnyLayoutProp(
463
463
  }
464
464
  return false;
465
465
  }
466
+ #endif // RCT_NEW_ARCH_ENABLED
466
467
 
467
468
  bool NativeReanimatedModule::handleEvent(
468
469
  const std::string &eventName,
469
- jsi::Value &&payload,
470
+ const jsi::Value &payload,
470
471
  double currentTime) {
471
- jsi::Runtime &rt = *runtime.get();
472
- jsi::Object global = rt.global();
473
- jsi::String eventTimestampName =
474
- jsi::String::createFromAscii(rt, "_eventTimestamp");
475
- global.setProperty(rt, eventTimestampName, currentTime);
476
- onEvent(eventName, std::move(payload));
477
- global.setProperty(rt, eventTimestampName, jsi::Value::undefined());
472
+ onEvent(currentTime, eventName, payload);
478
473
 
479
474
  // TODO: return true if Reanimated successfully handled the event
480
475
  // to avoid sending it to JavaScript
481
476
  return false;
482
477
  }
483
478
 
479
+ #ifdef RCT_NEW_ARCH_ENABLED
484
480
  bool NativeReanimatedModule::handleRawEvent(
485
481
  const RawEvent &rawEvent,
486
482
  double currentTime) {
@@ -504,7 +500,13 @@ bool NativeReanimatedModule::handleRawEvent(
504
500
  jsi::Runtime &rt = *runtime.get();
505
501
  jsi::Value payload = payloadFactory(rt);
506
502
 
507
- 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;
508
510
  }
509
511
 
510
512
  void NativeReanimatedModule::updateProps(
@@ -543,36 +545,33 @@ void NativeReanimatedModule::performOperations() {
543
545
  jsi::Runtime &rt = *runtime.get();
544
546
 
545
547
  shadowTreeRegistry.visit(surfaceId_, [&](ShadowTree const &shadowTree) {
548
+ auto lock = newestShadowNodesRegistry_->createLock();
549
+
546
550
  shadowTree.commit([&](RootShadowNode const &oldRootShadowNode) {
547
551
  auto rootNode = oldRootShadowNode.ShadowNode::clone(ShadowNodeFragment{});
548
552
 
549
553
  ShadowTreeCloner shadowTreeCloner{
550
554
  newestShadowNodesRegistry_, uiManager_, surfaceId_};
551
555
 
552
- {
553
- // lock once due to performance reasons
554
- auto lock = newestShadowNodesRegistry_->createLock();
556
+ for (const auto &pair : copiedOperationsQueue) {
557
+ const ShadowNodeFamily &family = pair.first->getFamily();
558
+ react_native_assert(family.getSurfaceId() == surfaceId_);
555
559
 
556
- for (const auto &pair : copiedOperationsQueue) {
557
- const ShadowNodeFamily &family = pair.first->getFamily();
558
- react_native_assert(family.getSurfaceId() == surfaceId_);
560
+ auto newRootNode = shadowTreeCloner.cloneWithNewProps(
561
+ rootNode, family, RawProps(rt, *pair.second));
559
562
 
560
- auto newRootNode = shadowTreeCloner.cloneWithNewProps(
561
- rootNode, family, RawProps(rt, *pair.second));
562
-
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;
568
- }
569
- 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;
570
568
  }
569
+ rootNode = newRootNode;
570
+ }
571
571
 
572
- // remove ShadowNodes and its ancestors from NewestShadowNodesRegistry
573
- for (auto tag : copiedTagsToRemove) {
574
- newestShadowNodesRegistry_->remove(tag);
575
- }
572
+ // remove ShadowNodes and its ancestors from NewestShadowNodesRegistry
573
+ for (auto tag : copiedTagsToRemove) {
574
+ newestShadowNodesRegistry_->remove(tag);
576
575
  }
577
576
 
578
577
  shadowTreeCloner.updateYogaChildren();
@@ -584,9 +583,8 @@ void NativeReanimatedModule::performOperations() {
584
583
 
585
584
  void NativeReanimatedModule::removeShadowNodeFromRegistry(
586
585
  jsi::Runtime &rt,
587
- const jsi::Value &shadowNodeValue) {
588
- auto shadowNode = shadowNodeFromValue(rt, shadowNodeValue);
589
- tagsToRemove_.push_back(shadowNode->getTag());
586
+ const jsi::Value &tag) {
587
+ tagsToRemove_.push_back(tag.asNumber());
590
588
  }
591
589
 
592
590
  void NativeReanimatedModule::dispatchCommand(
@@ -597,9 +595,7 @@ void NativeReanimatedModule::dispatchCommand(
597
595
  ShadowNode::Shared shadowNode = shadowNodeFromValue(rt, shadowNodeValue);
598
596
  std::string commandName = stringFromValue(rt, commandNameValue);
599
597
  folly::dynamic args = commandArgsFromValue(rt, argsValue);
600
-
601
- // TODO: use uiManager_->dispatchCommand once it's public
602
- UIManager_dispatchCommand(uiManager_, shadowNode, commandName, args);
598
+ uiManager_->dispatchCommand(shadowNode, commandName, args);
603
599
  }
604
600
 
605
601
  jsi::Value NativeReanimatedModule::measure(
@@ -608,11 +604,8 @@ jsi::Value NativeReanimatedModule::measure(
608
604
  // based on implementation from UIManagerBinding.cpp
609
605
 
610
606
  auto shadowNode = shadowNodeFromValue(rt, shadowNodeValue);
611
- // TODO: use uiManager_->getRelativeLayoutMetrics once it's public
612
- // auto layoutMetrics = uiManager_->getRelativeLayoutMetrics(
613
- // *shadowNode, nullptr, {/* .includeTransform = */ true});
614
- auto layoutMetrics = UIManager_getRelativeLayoutMetrics(
615
- uiManager_, *shadowNode, nullptr, {/* .includeTransform = */ true});
607
+ auto layoutMetrics = uiManager_->getRelativeLayoutMetrics(
608
+ *shadowNode, nullptr, {/* .includeTransform = */ true});
616
609
 
617
610
  if (layoutMetrics == EmptyLayoutMetrics) {
618
611
  // Originally, in this case React Native returns `{0, 0, 0, 0, 0, 0}`, most
@@ -626,7 +619,8 @@ jsi::Value NativeReanimatedModule::measure(
626
619
 
627
620
  auto layoutableShadowNode =
628
621
  traitCast<LayoutableShadowNode const *>(newestCloneOfShadowNode.get());
629
- facebook::react::Point originRelativeToParent = layoutableShadowNode
622
+ facebook::react::Point originRelativeToParent =
623
+ layoutableShadowNode != nullptr
630
624
  ? layoutableShadowNode->getLayoutMetrics().frame.origin
631
625
  : facebook::react::Point();
632
626
 
@@ -661,15 +655,17 @@ void NativeReanimatedModule::setNewestShadowNodesRegistry(
661
655
 
662
656
  jsi::Value NativeReanimatedModule::subscribeForKeyboardEvents(
663
657
  jsi::Runtime &rt,
664
- const jsi::Value &handlerWorklet) {
658
+ const jsi::Value &handlerWorklet,
659
+ const jsi::Value &isStatusBarTranslucent) {
665
660
  auto shareableHandler = extractShareableOrThrow(rt, handlerWorklet);
666
- auto uiRuntime = runtimeHelper->uiRuntime();
667
- return subscribeForKeyboardEventsFunction([=](int keyboardState, int height) {
668
- jsi::Runtime &rt = *uiRuntime;
669
- auto handler = shareableHandler->getJSValue(rt);
670
- handler.asObject(rt).asFunction(rt).call(
671
- rt, jsi::Value(keyboardState), jsi::Value(height));
672
- });
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());
673
669
  }
674
670
 
675
671
  void NativeReanimatedModule::unsubscribeFromKeyboardEvents(
@@ -52,8 +52,10 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec,
52
52
  const jsi::Value &callGuard,
53
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
 
@@ -30,7 +30,8 @@ class JSI_EXPORT NativeReanimatedModuleSpec : public TurboModule {
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
 
@@ -42,6 +42,11 @@ class HermesExecutorRuntimeAdapter
42
42
  thread_->quitSynchronous();
43
43
  }
44
44
 
45
+ #if REACT_NATIVE_MINOR_VERSION >= 71
46
+ facebook::hermes::HermesRuntime &getRuntime() override {
47
+ return hermesRuntime_;
48
+ }
49
+ #else
45
50
  facebook::jsi::Runtime &getRuntime() override {
46
51
  return hermesRuntime_;
47
52
  }
@@ -49,6 +54,7 @@ class HermesExecutorRuntimeAdapter
49
54
  facebook::hermes::debugger::Debugger &getDebugger() override {
50
55
  return hermesRuntime_.getDebugger();
51
56
  }
57
+ #endif // REACT_NATIVE_MINOR_VERSION
52
58
 
53
59
  // This is not empty in the original implementation, but we decided to tickle
54
60
  // the runtime by running a small piece of code on every frame as using this
@@ -73,8 +79,13 @@ ReanimatedHermesRuntime::ReanimatedHermesRuntime(
73
79
  #if HERMES_ENABLE_DEBUGGER
74
80
  auto adapter =
75
81
  std::make_unique<HermesExecutorRuntimeAdapter>(*runtime_, jsQueue);
82
+ #if REACT_NATIVE_MINOR_VERSION >= 71
83
+ debugToken_ = facebook::hermes::inspector::chrome::enableDebugging(
84
+ std::move(adapter), "Reanimated Runtime");
85
+ #else
76
86
  facebook::hermes::inspector::chrome::enableDebugging(
77
87
  std::move(adapter), "Reanimated Runtime");
88
+ #endif // REACT_NATIVE_MINOR_VERSION
78
89
  #else
79
90
  // This is required by iOS, because there is an assertion in the destructor
80
91
  // that the thread was indeed `quit` before
@@ -103,8 +114,12 @@ ReanimatedHermesRuntime::ReanimatedHermesRuntime(
103
114
  sourceMap = std::make_shared<const jsi::StringBuffer>(
104
115
  args[2].asString(rt).utf8(rt));
105
116
  }
117
+ #if REACT_NATIVE_MINOR_VERSION >= 65
106
118
  return wrappedRuntime->evaluateJavaScriptWithSourceMap(
107
119
  code, sourceMap, sourceURL);
120
+ #else
121
+ return wrappedRuntime->evaluateJavaScript(code, sourceURL);
122
+ #endif
108
123
  });
109
124
  runtime_->global().setProperty(
110
125
  *runtime_, "evalWithSourceMap", evalWithSourceMap);
@@ -114,8 +129,12 @@ ReanimatedHermesRuntime::ReanimatedHermesRuntime(
114
129
  ReanimatedHermesRuntime::~ReanimatedHermesRuntime() {
115
130
  #if HERMES_ENABLE_DEBUGGER
116
131
  // We have to disable debugging before the runtime is destroyed.
132
+ #if REACT_NATIVE_MINOR_VERSION >= 71
133
+ facebook::hermes::inspector::chrome::disableDebugging(debugToken_);
134
+ #else
117
135
  facebook::hermes::inspector::chrome::disableDebugging(*runtime_);
118
- #endif
136
+ #endif // REACT_NATIVE_MINOR_VERSION
137
+ #endif // HERMES_ENABLE_DEBUGGER
119
138
  }
120
139
 
121
140
  } // namespace reanimated
@@ -25,6 +25,10 @@
25
25
  #include <hermes/hermes.h>
26
26
  #endif
27
27
 
28
+ #if REACT_NATIVE_MINOR_VERSION >= 71
29
+ #include <hermes/inspector/chrome/Registration.h>
30
+ #endif
31
+
28
32
  namespace reanimated {
29
33
 
30
34
  using namespace facebook;
@@ -118,6 +122,11 @@ class ReanimatedHermesRuntime
118
122
  private:
119
123
  std::unique_ptr<facebook::hermes::HermesRuntime> runtime_;
120
124
  ReanimatedReentrancyCheck reentrancyCheck_;
125
+ #if HERMES_ENABLE_DEBUGGER
126
+ #if REACT_NATIVE_MINOR_VERSION >= 71
127
+ facebook::hermes::inspector::chrome::DebugSessionToken debugToken_;
128
+ #endif // REACT_NATIVE_MINOR_VERSION >= 71
129
+ #endif // HERMES_ENABLE_DEBUGGER
121
130
  };
122
131
 
123
132
  } // namespace reanimated
@@ -11,8 +11,12 @@
11
11
  #elif JS_RUNTIME_V8
12
12
  #include <v8runtime/V8RuntimeFactory.h>
13
13
  #else
14
+ #if REACT_NATIVE_MINOR_VERSION >= 71
15
+ #include <jsc/JSCRuntime.h>
16
+ #else
14
17
  #include <jsi/JSCRuntime.h>
15
- #endif
18
+ #endif // REACT_NATIVE_MINOR_VERSION
19
+ #endif // JS_RUNTIME
16
20
 
17
21
  namespace reanimated {
18
22