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
@@ -0,0 +1,176 @@
1
+ #pragma once
2
+
3
+ #include <jsi/jsi.h>
4
+ #include <sstream>
5
+ #include <string>
6
+ #include <tuple>
7
+ #include <utility>
8
+
9
+ using namespace facebook;
10
+
11
+ namespace reanimated {
12
+ namespace jsi_utils {
13
+
14
+ // `get` functions take a pointer to `jsi::Value` and
15
+ // call an appropriate method to cast to the native type
16
+ template <typename T>
17
+ inline T get(jsi::Runtime &rt, const jsi::Value *value);
18
+
19
+ template <>
20
+ inline double get<double>(jsi::Runtime &rt, const jsi::Value *value) {
21
+ return value->asNumber();
22
+ }
23
+
24
+ template <>
25
+ inline int get<int>(jsi::Runtime &rt, const jsi::Value *value) {
26
+ return value->asNumber();
27
+ }
28
+
29
+ template <>
30
+ inline bool get<bool>(jsi::Runtime &rt, const jsi::Value *value) {
31
+ if (!value->isBool()) {
32
+ throw jsi::JSINativeException("Expected a boolean");
33
+ }
34
+ return value->getBool();
35
+ }
36
+
37
+ template <>
38
+ inline jsi::Object get<jsi::Object>(jsi::Runtime &rt, const jsi::Value *value) {
39
+ return value->asObject(rt);
40
+ }
41
+
42
+ template <>
43
+ inline jsi::Value const &get<jsi::Value const &>(
44
+ jsi::Runtime &rt,
45
+ const jsi::Value *value) {
46
+ return *value;
47
+ }
48
+
49
+ // `convertArgs` functions take a variadic template parameter of target (C++)
50
+ // argument types `Targs` and a `jsi::Value` array `args`, and converts `args`
51
+ // to a tuple of typed C++ arguments to be passed to the native implementation.
52
+ // This is accomplished by dispatching (at compile time) to the correct
53
+ // implementation based on the first type of `Targs`, using SFINAE to select the
54
+ // correct specialization, and concatenating with the result of recursion on the
55
+ // rest of `Targs`
56
+
57
+ // BEGIN implementations for `convertArgs` specializations.
58
+ // specialization for empty `Targs` - returns an empty tuple
59
+ template <typename... Args>
60
+ inline std::enable_if_t<(sizeof...(Args) == 0), std::tuple<>> convertArgs(
61
+ jsi::Runtime &rt,
62
+ const jsi::Value *args) {
63
+ return std::make_tuple();
64
+ }
65
+
66
+ // calls `get<First>` on the first argument to retrieve the native type,
67
+ // then calls recursively on the rest of `args`
68
+ // and returns the concatenation of results
69
+ template <typename T, typename... Rest>
70
+ inline std::tuple<T, Rest...> convertArgs(
71
+ jsi::Runtime &rt,
72
+ const jsi::Value *args) {
73
+ auto arg = std::tuple<T>(get<T>(rt, args));
74
+ auto rest = convertArgs<Rest...>(rt, std::next(args));
75
+ return std::tuple_cat(std::move(arg), std::move(rest));
76
+ }
77
+ // END implementations for `convertArgs` specializations.
78
+
79
+ // returns a tuple with the result of casting `args` to appropriate
80
+ // native C++ types needed to call `function`
81
+ template <typename Ret, typename... Args>
82
+ std::tuple<Args...> getArgsForFunction(
83
+ std::function<Ret(Args...)> function,
84
+ jsi::Runtime &rt,
85
+ const jsi::Value *args,
86
+ const size_t count) {
87
+ assert(sizeof...(Args) == count);
88
+ return convertArgs<Args...>(rt, args);
89
+ }
90
+
91
+ // returns a tuple with the result of casting `args` to appropriate
92
+ // native C++ types needed to call `function`,
93
+ // passing `rt` as the first argument
94
+ template <typename Ret, typename... Args>
95
+ std::tuple<jsi::Runtime &, Args...> getArgsForFunction(
96
+ std::function<Ret(jsi::Runtime &, Args...)> function,
97
+ jsi::Runtime &rt,
98
+ const jsi::Value *args,
99
+ const size_t count) {
100
+ assert(sizeof...(Args) == count);
101
+ return std::tuple_cat(std::tie(rt), convertArgs<Args...>(rt, args));
102
+ }
103
+
104
+ // calls `function` with `args`
105
+ template <typename Ret, typename... Args>
106
+ inline jsi::Value apply(
107
+ std::function<Ret(Args...)> function,
108
+ std::tuple<Args...> args) {
109
+ return std::apply(function, std::move(args));
110
+ }
111
+
112
+ // calls void-returning `function` with `args`,
113
+ // and returns `undefined`
114
+ template <typename... Args>
115
+ inline jsi::Value apply(
116
+ std::function<void(Args...)> function,
117
+ std::tuple<Args...> args) {
118
+ std::apply(function, std::move(args));
119
+ return jsi::Value::undefined();
120
+ }
121
+
122
+ // returns a function with JSI calling convention
123
+ // from a native function `function`
124
+ template <typename Fun>
125
+ jsi::HostFunctionType createHostFunction(Fun function) {
126
+ return [function](
127
+ jsi::Runtime &rt,
128
+ const jsi::Value &thisValue,
129
+ const jsi::Value *args,
130
+ const size_t count) {
131
+ auto argz = getArgsForFunction(function, rt, args, count);
132
+ return apply(function, std::move(argz));
133
+ };
134
+ }
135
+
136
+ // used to determine if `function<Ret(Args...)>`
137
+ // takes `Runtime &` as its first argument
138
+ template <typename... Args>
139
+ struct takes_runtime {
140
+ static constexpr size_t value = 0;
141
+ };
142
+
143
+ // specialization for `function<Ret(Runtime &, Rest...)`
144
+ template <typename... Rest>
145
+ struct takes_runtime<jsi::Runtime &, Rest...> {
146
+ static constexpr size_t value = 1;
147
+ };
148
+
149
+ // creates a JSI compatible function from `function`
150
+ // and installs it as a global function named `name`
151
+ // in the `rt` JS runtime
152
+ template <typename Ret, typename... Args>
153
+ void installJsiFunction(
154
+ jsi::Runtime &rt,
155
+ std::string_view name,
156
+ std::function<Ret(Args...)> function) {
157
+ auto clb = createHostFunction(function);
158
+ auto argsCount = sizeof...(Args) - takes_runtime<Args...>::value;
159
+ jsi::Value jsiFunction = jsi::Function::createFromHostFunction(
160
+ rt, jsi::PropNameID::forAscii(rt, name.data()), argsCount, clb);
161
+ rt.global().setProperty(rt, name.data(), jsiFunction);
162
+ }
163
+
164
+ // this should take care of passing types convertible to `function`
165
+ template <typename Fun>
166
+ void installJsiFunction(jsi::Runtime &rt, std::string_view name, Fun function) {
167
+ installJsiFunction(rt, name, std::function(std::forward<Fun>(function)));
168
+ }
169
+
170
+ jsi::Array convertStringToArray(
171
+ jsi::Runtime &rt,
172
+ const std::string &value,
173
+ const unsigned int expectedSize);
174
+
175
+ } // namespace jsi_utils
176
+ } // namespace reanimated
@@ -27,7 +27,7 @@ using UpdatePropsFunction = std::function<void(
27
27
  const jsi::Value &shadowNodeValue,
28
28
  const jsi::Value &props)>;
29
29
  using RemoveShadowNodeFromRegistryFunction =
30
- std::function<void(jsi::Runtime &rt, const jsi::Value &shadowNodeValue)>;
30
+ std::function<void(jsi::Runtime &rt, const jsi::Value &tag)>;
31
31
  using DispatchCommandFunction = std::function<void(
32
32
  jsi::Runtime &rt,
33
33
  const jsi::Value &shadowNodeValue,
@@ -42,7 +42,7 @@ using UpdatePropsFunction = std::function<void(
42
42
  jsi::Runtime &rt,
43
43
  int viewTag,
44
44
  const jsi::Value &viewName,
45
- const jsi::Object &object)>;
45
+ jsi::Object object)>;
46
46
  using ScrollToFunction = std::function<void(int, double, double, bool)>;
47
47
  using MeasureFunction =
48
48
  std::function<std::vector<std::pair<std::string, double>>(int)>;
@@ -54,11 +54,11 @@ using RequestRender =
54
54
  using TimeProviderFunction = std::function<double(void)>;
55
55
 
56
56
  using ProgressLayoutAnimationFunction =
57
- std::function<void(int, const jsi::Object &newProps)>;
57
+ std::function<void(int, jsi::Object newProps, bool isSharedTransition)>;
58
58
  using EndLayoutAnimationFunction = std::function<void(int, bool, bool)>;
59
59
 
60
60
  using RegisterSensorFunction =
61
- std::function<int(int, int, std::function<void(double[])>)>;
61
+ std::function<int(int, int, int, std::function<void(double[], int)>)>;
62
62
  using UnregisterSensorFunction = std::function<void(int)>;
63
63
  using SetGestureStateFunction = std::function<void(int, int)>;
64
64
  using ConfigurePropsFunction = std::function<void(
@@ -66,7 +66,7 @@ using ConfigurePropsFunction = std::function<void(
66
66
  const jsi::Value &uiProps,
67
67
  const jsi::Value &nativeProps)>;
68
68
  using KeyboardEventSubscribeFunction =
69
- std::function<int(std::function<void(int, int)>)>;
69
+ std::function<int(std::function<void(int, int)>, bool)>;
70
70
  using KeyboardEventUnsubscribeFunction = std::function<void(int)>;
71
71
 
72
72
  struct PlatformDepMethodsHolder {
@@ -0,0 +1,17 @@
1
+ #include "ReanimatedVersion.h"
2
+
3
+ #ifdef REANIMATED_VERSION
4
+ #define STRINGIZE(x) #x
5
+ #define STRINGIZE2(x) STRINGIZE(x)
6
+ #define REANIMATED_VERSION_STRING STRINGIZE2(REANIMATED_VERSION)
7
+ #endif // REANIMATED_VERSION
8
+
9
+ using namespace facebook;
10
+
11
+ namespace reanimated {
12
+
13
+ jsi::String getReanimatedVersionString(jsi::Runtime &rt) {
14
+ return jsi::String::createFromUtf8(rt, REANIMATED_VERSION_STRING);
15
+ }
16
+
17
+ }; // namespace reanimated
@@ -0,0 +1,11 @@
1
+ #pragma once
2
+
3
+ #include <jsi/jsi.h>
4
+
5
+ using namespace facebook;
6
+
7
+ namespace reanimated {
8
+
9
+ jsi::String getReanimatedVersionString(jsi::Runtime &rt);
10
+
11
+ };
@@ -4,10 +4,24 @@
4
4
  #include <memory>
5
5
  #include <unordered_map>
6
6
  #include <utility>
7
+ #include "JsiUtils.h"
7
8
  #include "ReanimatedHiddenHeaders.h"
8
9
 
9
10
  namespace reanimated {
10
11
 
12
+ static const std::function<void(jsi::Runtime &, jsi::Value const &)> logValue =
13
+ [](jsi::Runtime &rt, jsi::Value const &value) {
14
+ if (value.isString()) {
15
+ Logger::log(value.getString(rt).utf8(rt).c_str());
16
+ } else if (value.isNumber()) {
17
+ Logger::log(value.getNumber());
18
+ } else if (value.isUndefined()) {
19
+ Logger::log("undefined");
20
+ } else {
21
+ Logger::log("unsupported value type");
22
+ }
23
+ };
24
+
11
25
  std::unordered_map<RuntimePointer, RuntimeType>
12
26
  &RuntimeDecorator::runtimeRegistry() {
13
27
  static std::unordered_map<RuntimePointer, RuntimeType> runtimeRegistry;
@@ -57,47 +71,7 @@ void RuntimeDecorator::decorateRuntime(
57
71
  evalWithSourceUrl));
58
72
  #endif // DEBUG
59
73
 
60
- auto callback = [](jsi::Runtime &rt,
61
- const jsi::Value &thisValue,
62
- const jsi::Value *args,
63
- size_t count) -> jsi::Value {
64
- const jsi::Value *value = &args[0];
65
- if (value->isString()) {
66
- Logger::log(value->getString(rt).utf8(rt).c_str());
67
- } else if (value->isNumber()) {
68
- Logger::log(value->getNumber());
69
- } else if (value->isUndefined()) {
70
- Logger::log("undefined");
71
- } else {
72
- Logger::log("unsupported value type");
73
- }
74
- return jsi::Value::undefined();
75
- };
76
- jsi::Value log = jsi::Function::createFromHostFunction(
77
- rt, jsi::PropNameID::forAscii(rt, "_log"), 1, callback);
78
- rt.global().setProperty(rt, "_log", log);
79
-
80
- auto chronoNow = [](jsi::Runtime &rt,
81
- const jsi::Value &thisValue,
82
- const jsi::Value *args,
83
- size_t count) -> jsi::Value {
84
- double now = std::chrono::system_clock::now().time_since_epoch() /
85
- std::chrono::milliseconds(1);
86
- return jsi::Value(now);
87
- };
88
-
89
- rt.global().setProperty(
90
- rt,
91
- "_chronoNow",
92
- jsi::Function::createFromHostFunction(
93
- rt, jsi::PropNameID::forAscii(rt, "_chronoNow"), 0, chronoNow));
94
- jsi::Object performance(rt);
95
- performance.setProperty(
96
- rt,
97
- "now",
98
- jsi::Function::createFromHostFunction(
99
- rt, jsi::PropNameID::forAscii(rt, "now"), 0, chronoNow));
100
- rt.global().setProperty(rt, "performance", performance);
74
+ jsi_utils::installJsiFunction(rt, "_log", logValue);
101
75
  }
102
76
 
103
77
  void RuntimeDecorator::decorateUIRuntime(
@@ -115,8 +89,6 @@ void RuntimeDecorator::decorateUIRuntime(
115
89
  const MakeShareableCloneFunction makeShareableClone,
116
90
  const UpdateDataSynchronouslyFunction updateDataSynchronously,
117
91
  const TimeProviderFunction getCurrentTime,
118
- const RegisterSensorFunction registerSensor,
119
- const UnregisterSensorFunction unregisterSensor,
120
92
  const SetGestureStateFunction setGestureState,
121
93
  const ProgressLayoutAnimationFunction progressLayoutAnimationFunction,
122
94
  const EndLayoutAnimationFunction endLayoutAnimationFunction) {
@@ -124,95 +96,17 @@ void RuntimeDecorator::decorateUIRuntime(
124
96
  rt.global().setProperty(rt, "_UI", jsi::Value(true));
125
97
 
126
98
  #ifdef RCT_NEW_ARCH_ENABLED
127
- auto clb = [updateProps](
128
- jsi::Runtime &rt,
129
- const jsi::Value &thisValue,
130
- const jsi::Value *args,
131
- const size_t count) -> jsi::Value {
132
- updateProps(rt, args[0], args[1]);
133
- return jsi::Value::undefined();
134
- };
135
- jsi::Value updatePropsHostFunction = jsi::Function::createFromHostFunction(
136
- rt, jsi::PropNameID::forAscii(rt, "_updatePropsFabric"), 2, clb);
137
- rt.global().setProperty(rt, "_updatePropsFabric", updatePropsHostFunction);
138
-
139
- auto _removeShadowNodeFromRegistry = [removeShadowNodeFromRegistry](
140
- jsi::Runtime &rt,
141
- const jsi::Value &thisValue,
142
- const jsi::Value *args,
143
- const size_t count) -> jsi::Value {
144
- removeShadowNodeFromRegistry(rt, args[0]);
145
- return jsi::Value::undefined();
146
- };
147
- jsi::Value removeShadowNodeFromRegistryHostFunction =
148
- jsi::Function::createFromHostFunction(
149
- rt,
150
- jsi::PropNameID::forAscii(rt, "_removeShadowNodeFromRegistry"),
151
- 2,
152
- _removeShadowNodeFromRegistry);
153
- rt.global().setProperty(
154
- rt,
155
- "_removeShadowNodeFromRegistry",
156
- removeShadowNodeFromRegistryHostFunction);
157
-
158
- auto clb3 = [dispatchCommand](
159
- jsi::Runtime &rt,
160
- const jsi::Value &thisValue,
161
- const jsi::Value *args,
162
- const size_t count) -> jsi::Value {
163
- dispatchCommand(rt, args[0], args[1], args[2]);
164
- return jsi::Value::undefined();
165
- };
166
- jsi::Value dispatchCommandHostFunction =
167
- jsi::Function::createFromHostFunction(
168
- rt, jsi::PropNameID::forAscii(rt, "_dispatchCommand"), 3, clb3);
169
- rt.global().setProperty(rt, "_dispatchCommand", dispatchCommandHostFunction);
170
-
171
- auto _measure = [measure](
172
- jsi::Runtime &rt,
173
- const jsi::Value &thisValue,
174
- const jsi::Value *args,
175
- const size_t count) -> jsi::Value {
176
- return measure(rt, args[0]);
177
- };
99
+ jsi_utils::installJsiFunction(rt, "_updatePropsFabric", updateProps);
100
+ jsi_utils::installJsiFunction(
101
+ rt, "_removeShadowNodeFromRegistry", removeShadowNodeFromRegistry);
102
+ jsi_utils::installJsiFunction(rt, "_dispatchCommand", dispatchCommand);
103
+ jsi_utils::installJsiFunction(rt, "_measure", measure);
178
104
  #else
179
- auto clb = [updateProps](
180
- jsi::Runtime &rt,
181
- const jsi::Value &thisValue,
182
- const jsi::Value *args,
183
- const size_t count) -> jsi::Value {
184
- const auto viewTag = args[0].asNumber();
185
- const jsi::Value *viewName = &args[1];
186
- const auto params = args[2].asObject(rt);
187
- updateProps(rt, viewTag, *viewName, params);
188
- return jsi::Value::undefined();
189
- };
190
- jsi::Value updatePropsHostFunction = jsi::Function::createFromHostFunction(
191
- rt, jsi::PropNameID::forAscii(rt, "_updatePropsPaper"), 3, clb);
192
- rt.global().setProperty(rt, "_updatePropsPaper", updatePropsHostFunction);
193
-
194
- auto _scrollTo = [scrollTo](
195
- jsi::Runtime &rt,
196
- const jsi::Value &thisValue,
197
- const jsi::Value *args,
198
- const size_t count) -> jsi::Value {
199
- int viewTag = static_cast<int>(args[0].asNumber());
200
- double x = args[1].asNumber();
201
- double y = args[2].asNumber();
202
- bool animated = args[3].getBool();
203
- scrollTo(viewTag, x, y, animated);
204
- return jsi::Value::undefined();
205
- };
206
- jsi::Value scrollToFunction = jsi::Function::createFromHostFunction(
207
- rt, jsi::PropNameID::forAscii(rt, "_scrollTo"), 4, _scrollTo);
208
- rt.global().setProperty(rt, "_scrollTo", scrollToFunction);
105
+ jsi_utils::installJsiFunction(rt, "_updatePropsPaper", updateProps);
106
+ jsi_utils::installJsiFunction(rt, "_scrollTo", scrollTo);
209
107
 
210
- auto _measure = [measure](
211
- jsi::Runtime &rt,
212
- const jsi::Value &thisValue,
213
- const jsi::Value *args,
214
- const size_t count) -> jsi::Value {
215
- int viewTag = static_cast<int>(args[0].asNumber());
108
+ std::function<jsi::Value(jsi::Runtime &, int)> _measure =
109
+ [measure](jsi::Runtime &rt, int viewTag) -> jsi::Value {
216
110
  auto result = measure(viewTag);
217
111
  jsi::Object resultObject(rt);
218
112
  for (auto &i : result) {
@@ -220,113 +114,38 @@ void RuntimeDecorator::decorateUIRuntime(
220
114
  }
221
115
  return resultObject;
222
116
  };
223
- #endif // RCT_NEW_ARCH_ENABLED
224
-
225
- jsi::Value measureFunction = jsi::Function::createFromHostFunction(
226
- rt, jsi::PropNameID::forAscii(rt, "_measure"), 1, _measure);
227
- rt.global().setProperty(rt, "_measure", measureFunction);
228
117
 
229
- auto clb2 = [requestFrame](
230
- jsi::Runtime &rt,
231
- const jsi::Value &thisValue,
232
- const jsi::Value *args,
233
- const size_t count) -> jsi::Value {
234
- requestFrame(rt, std::move(args[0]));
235
- return jsi::Value::undefined();
236
- };
237
- jsi::Value requestAnimationFrame = jsi::Function::createFromHostFunction(
238
- rt, jsi::PropNameID::forAscii(rt, "requestAnimationFrame"), 1, clb2);
239
- rt.global().setProperty(rt, "requestAnimationFrame", requestAnimationFrame);
240
-
241
- auto clb4 = [scheduleOnJS](
242
- jsi::Runtime &rt,
243
- const jsi::Value &thisValue,
244
- const jsi::Value *args,
245
- const size_t count) -> jsi::Value {
246
- scheduleOnJS(rt, args[0], args[1]);
247
- return jsi::Value::undefined();
248
- };
249
- jsi::Value scheduleOnJSFun = jsi::Function::createFromHostFunction(
250
- rt, jsi::PropNameID::forAscii(rt, "_scheduleOnJS"), 2, clb4);
251
- rt.global().setProperty(rt, "_scheduleOnJS", scheduleOnJSFun);
118
+ jsi_utils::installJsiFunction(rt, "_measure", _measure);
119
+ #endif // RCT_NEW_ARCH_ENABLED
252
120
 
253
- auto clb5 = [makeShareableClone](
254
- jsi::Runtime &rt,
255
- const jsi::Value &thisValue,
256
- const jsi::Value *args,
257
- const size_t count) -> jsi::Value {
258
- return makeShareableClone(rt, std::move(args[0]));
259
- };
260
- jsi::Value makeShareableCloneFun = jsi::Function::createFromHostFunction(
261
- rt, jsi::PropNameID::forAscii(rt, "_makeShareableClone"), 1, clb5);
262
- rt.global().setProperty(rt, "_makeShareableClone", makeShareableCloneFun);
121
+ jsi_utils::installJsiFunction(rt, "requestAnimationFrame", requestFrame);
122
+ jsi_utils::installJsiFunction(rt, "_scheduleOnJS", scheduleOnJS);
123
+ jsi_utils::installJsiFunction(rt, "_makeShareableClone", makeShareableClone);
124
+ jsi_utils::installJsiFunction(
125
+ rt, "_updateDataSynchronously", updateDataSynchronously);
263
126
 
264
- auto clb51 = [updateDataSynchronously](
265
- jsi::Runtime &rt,
266
- const jsi::Value &thisValue,
267
- const jsi::Value *args,
268
- const size_t count) -> jsi::Value {
269
- updateDataSynchronously(rt, std::move(args[0]), std::move(args[1]));
270
- return jsi::Value::undefined();
127
+ auto performanceNow = [getCurrentTime](
128
+ jsi::Runtime &rt,
129
+ const jsi::Value &thisValue,
130
+ const jsi::Value *args,
131
+ size_t count) -> jsi::Value {
132
+ return jsi::Value(getCurrentTime());
271
133
  };
272
- jsi::Value updateDataSynchronouslyFun = jsi::Function::createFromHostFunction(
273
- rt, jsi::PropNameID::forAscii(rt, "_updateDataSynchronously"), 1, clb51);
274
- rt.global().setProperty(
275
- rt, "_updateDataSynchronously", updateDataSynchronouslyFun);
276
-
277
- auto clb6 = [getCurrentTime](
278
- jsi::Runtime &rt,
279
- const jsi::Value &thisValue,
280
- const jsi::Value *args,
281
- const size_t count) -> jsi::Value {
282
- return getCurrentTime();
283
- };
284
- jsi::Value timeFun = jsi::Function::createFromHostFunction(
285
- rt, jsi::PropNameID::forAscii(rt, "_getCurrentTime"), 0, clb6);
286
- rt.global().setProperty(rt, "_getCurrentTime", timeFun);
287
-
288
- rt.global().setProperty(rt, "_frameTimestamp", jsi::Value::undefined());
289
- rt.global().setProperty(rt, "_eventTimestamp", jsi::Value::undefined());
134
+ jsi::Object performance(rt);
135
+ performance.setProperty(
136
+ rt,
137
+ "now",
138
+ jsi::Function::createFromHostFunction(
139
+ rt, jsi::PropNameID::forAscii(rt, "now"), 0, performanceNow));
140
+ rt.global().setProperty(rt, "performance", performance);
290
141
 
291
142
  // layout animation
292
- auto clb7 = [progressLayoutAnimationFunction](
293
- jsi::Runtime &rt,
294
- const jsi::Value &thisValue,
295
- const jsi::Value *args,
296
- size_t count) -> jsi::Value {
297
- progressLayoutAnimationFunction(args[0].asNumber(), args[1].asObject(rt));
298
- return jsi::Value::undefined();
299
- };
300
- jsi::Value _notifyAboutProgress = jsi::Function::createFromHostFunction(
301
- rt, jsi::PropNameID::forAscii(rt, "_notifyAboutProgress"), 2, clb7);
302
- rt.global().setProperty(rt, "_notifyAboutProgress", _notifyAboutProgress);
143
+ jsi_utils::installJsiFunction(
144
+ rt, "_notifyAboutProgress", progressLayoutAnimationFunction);
145
+ jsi_utils::installJsiFunction(
146
+ rt, "_notifyAboutEnd", endLayoutAnimationFunction);
303
147
 
304
- auto clb8 = [endLayoutAnimationFunction](
305
- jsi::Runtime &rt,
306
- const jsi::Value &thisValue,
307
- const jsi::Value *args,
308
- size_t count) -> jsi::Value {
309
- endLayoutAnimationFunction(
310
- args[0].asNumber(), args[1].getBool(), args[2].getBool());
311
- return jsi::Value::undefined();
312
- };
313
- jsi::Value _notifyAboutEnd = jsi::Function::createFromHostFunction(
314
- rt, jsi::PropNameID::forAscii(rt, "_notifyAboutEnd"), 2, clb8);
315
- rt.global().setProperty(rt, "_notifyAboutEnd", _notifyAboutEnd);
316
-
317
- auto clb9 = [setGestureState](
318
- jsi::Runtime &rt,
319
- const jsi::Value &thisValue,
320
- const jsi::Value *args,
321
- size_t count) -> jsi::Value {
322
- int handlerTag = static_cast<int>(args[0].asNumber());
323
- int newState = static_cast<int>(args[1].asNumber());
324
- setGestureState(handlerTag, newState);
325
- return jsi::Value::undefined();
326
- };
327
- jsi::Value setGestureStateFunction = jsi::Function::createFromHostFunction(
328
- rt, jsi::PropNameID::forAscii(rt, "_setGestureState"), 2, clb9);
329
- rt.global().setProperty(rt, "_setGestureState", setGestureStateFunction);
148
+ jsi_utils::installJsiFunction(rt, "_setGestureState", setGestureState);
330
149
  }
331
150
 
332
151
  } // namespace reanimated
@@ -50,8 +50,6 @@ class RuntimeDecorator {
50
50
  const MakeShareableCloneFunction makeShareableClone,
51
51
  const UpdateDataSynchronouslyFunction updateDataSynchronously,
52
52
  const TimeProviderFunction getCurrentTime,
53
- const RegisterSensorFunction registerSensor,
54
- const UnregisterSensorFunction unregisterSensor,
55
53
  const SetGestureStateFunction setGestureState,
56
54
  const ProgressLayoutAnimationFunction progressLayoutAnimationFunction,
57
55
  const EndLayoutAnimationFunction endLayoutAnimationFunction);
@@ -3,9 +3,10 @@
3
3
  namespace reanimated {
4
4
 
5
5
  void WorkletEventHandler::process(
6
- jsi::Runtime &rt,
6
+ double eventTimestamp,
7
7
  const jsi::Value &eventValue) {
8
- handler.callWithThis(rt, handler, eventValue);
8
+ _runtimeHelper->runOnUIGuarded(
9
+ _handlerFunction, jsi::Value(eventTimestamp), eventValue);
9
10
  }
10
11
 
11
12
  } // namespace reanimated
@@ -1,9 +1,12 @@
1
1
  #pragma once
2
2
 
3
3
  #include <jsi/jsi.h>
4
+ #include <memory>
4
5
  #include <string>
5
6
  #include <utility>
6
7
 
8
+ #include "Shareables.h"
9
+
7
10
  using namespace facebook;
8
11
 
9
12
  namespace reanimated {
@@ -14,17 +17,22 @@ class WorkletEventHandler {
14
17
  friend EventHandlerRegistry;
15
18
 
16
19
  private:
17
- unsigned long id;
20
+ std::shared_ptr<JSRuntimeHelper> _runtimeHelper;
21
+ uint64_t id;
18
22
  std::string eventName;
19
- jsi::Function handler;
23
+ jsi::Value _handlerFunction;
20
24
 
21
25
  public:
22
26
  WorkletEventHandler(
23
- unsigned long id,
27
+ const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
28
+ uint64_t id,
24
29
  std::string eventName,
25
- jsi::Function &&handler)
26
- : id(id), eventName(eventName), handler(std::move(handler)) {}
27
- void process(jsi::Runtime &rt, const jsi::Value &eventValue);
30
+ jsi::Value &&handlerFunction)
31
+ : _runtimeHelper(runtimeHelper),
32
+ id(id),
33
+ eventName(eventName),
34
+ _handlerFunction(std::move(handlerFunction)) {}
35
+ void process(double eventTimestamp, const jsi::Value &eventValue);
28
36
  };
29
37
 
30
38
  } // namespace reanimated
@@ -5,13 +5,14 @@ reanimated_package_json = JSON.parse(File.read(File.join(__dir__, "package.json"
5
5
  config = find_config()
6
6
  assert_no_multiple_instances(config)
7
7
  assert_no_reanimated2_with_new_architecture(reanimated_package_json)
8
+ assert_latest_react_native_with_new_architecture(config, reanimated_package_json)
8
9
 
9
10
  fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
10
11
  folly_prefix = config[:react_native_minor_version] >= 64 ? 'RCT-' : ''
11
12
  folly_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32 -DREACT_NATIVE_MINOR_VERSION=' + config[:react_native_minor_version].to_s
12
13
  folly_compiler_flags = folly_flags + ' ' + '-Wno-comma -Wno-shorten-64-to-32'
13
14
  boost_compiler_flags = '-Wno-documentation'
14
- fabric_flags = fabric_enabled ? '-DRN_FABRIC_ENABLED -DRCT_NEW_ARCH_ENABLED' : ''
15
+ fabric_flags = fabric_enabled ? '-DRCT_NEW_ARCH_ENABLED' : ''
15
16
  version_flag = '-DREANIMATED_VERSION=' + reanimated_package_json["version"]
16
17
 
17
18
  Pod::Spec.new do |s|