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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (339) hide show
  1. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +30 -12
  2. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.h +2 -0
  3. package/Common/cpp/Fabric/FabricUtils.cpp +3 -107
  4. package/Common/cpp/Fabric/FabricUtils.h +3 -24
  5. package/Common/cpp/Fabric/ReanimatedUIManagerBinding.cpp +54 -37
  6. package/Common/cpp/LayoutAnimations/LayoutAnimationType.h +8 -0
  7. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +81 -26
  8. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +20 -3
  9. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +122 -121
  10. package/Common/cpp/NativeModules/NativeReanimatedModule.h +21 -14
  11. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +15 -7
  12. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +8 -4
  13. package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +50 -1
  14. package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +10 -1
  15. package/Common/cpp/ReanimatedRuntime/ReanimatedRuntime.cpp +5 -1
  16. package/Common/cpp/Registries/EventHandlerRegistry.cpp +8 -34
  17. package/Common/cpp/Registries/EventHandlerRegistry.h +7 -13
  18. package/Common/cpp/SharedItems/Shareables.cpp +11 -63
  19. package/Common/cpp/SharedItems/Shareables.h +113 -93
  20. package/Common/cpp/Tools/CollectionUtils.h +14 -0
  21. package/Common/cpp/Tools/JsiUtils.cpp +26 -0
  22. package/Common/cpp/Tools/JsiUtils.h +176 -0
  23. package/Common/cpp/Tools/PlatformDepMethodsHolder.h +5 -5
  24. package/Common/cpp/Tools/ReanimatedVersion.cpp +17 -0
  25. package/Common/cpp/Tools/ReanimatedVersion.h +11 -0
  26. package/Common/cpp/Tools/RuntimeDecorator.cpp +67 -247
  27. package/Common/cpp/Tools/RuntimeDecorator.h +2 -3
  28. package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -2
  29. package/Common/cpp/Tools/WorkletEventHandler.h +14 -6
  30. package/RNReanimated.podspec +2 -1
  31. package/android/CMakeLists.txt +188 -181
  32. package/android/build.gradle +362 -311
  33. package/android/proguard-rules.pro +2 -0
  34. package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +63 -295
  35. package/android/src/main/cpp/LayoutAnimations.cpp +35 -5
  36. package/android/src/main/cpp/LayoutAnimations.h +23 -6
  37. package/android/src/main/cpp/NativeProxy.cpp +143 -98
  38. package/android/src/main/cpp/NativeProxy.h +22 -28
  39. package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +5 -4
  40. package/android/src/main/java/com/swmansion/reanimated/Utils.java +7 -1
  41. package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +10 -3
  42. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +218 -35
  43. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +43 -17
  44. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +6 -2
  45. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedElement.java +19 -0
  46. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +610 -0
  47. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +93 -23
  48. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/AnimationFrameCallback.java +19 -0
  49. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/EventHandler.java +35 -0
  50. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/KeyboardEventDataUpdater.java +16 -0
  51. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +206 -0
  52. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/SensorSetter.java +17 -0
  53. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +9 -3
  54. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +3 -4
  55. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -7
  56. package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +90 -307
  57. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +16 -0
  58. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +63 -0
  59. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +271 -0
  60. package/android/src/reactNativeVersionPatch/nativeHierarchyManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +76 -20
  61. package/ios/LayoutReanimation/REAAnimationsManager.h +31 -5
  62. package/ios/LayoutReanimation/REAAnimationsManager.m +265 -77
  63. package/ios/LayoutReanimation/REAFrame.h +10 -0
  64. package/ios/LayoutReanimation/REAFrame.m +15 -0
  65. package/ios/LayoutReanimation/REAScreensHelper.h +19 -0
  66. package/ios/LayoutReanimation/REAScreensHelper.m +106 -0
  67. package/ios/LayoutReanimation/REASharedElement.h +15 -0
  68. package/ios/LayoutReanimation/REASharedElement.m +16 -0
  69. package/ios/LayoutReanimation/REASharedTransitionManager.h +17 -0
  70. package/ios/LayoutReanimation/REASharedTransitionManager.m +632 -0
  71. package/ios/LayoutReanimation/REASnapshot.h +1 -0
  72. package/ios/LayoutReanimation/REASnapshot.m +96 -11
  73. package/ios/LayoutReanimation/REAUIManager.mm +67 -60
  74. package/ios/REAModule.mm +2 -7
  75. package/ios/REANodesManager.mm +1 -21
  76. package/ios/keyboardObserver/REAKeyboardEventObserver.m +72 -36
  77. package/ios/native/NativeProxy.mm +75 -114
  78. package/ios/native/REAInitializer.mm +2 -7
  79. package/ios/native/REAJSIUtils.h +60 -2
  80. package/ios/sensor/ReanimatedSensor.h +6 -2
  81. package/ios/sensor/ReanimatedSensor.m +43 -7
  82. package/ios/sensor/ReanimatedSensorContainer.h +4 -1
  83. package/ios/sensor/ReanimatedSensorContainer.m +8 -2
  84. package/lib/commonjs/createAnimatedComponent.js +232 -28
  85. package/lib/commonjs/createAnimatedComponent.js.map +1 -1
  86. package/lib/commonjs/reanimated2/Colors.js +43 -22
  87. package/lib/commonjs/reanimated2/Colors.js.map +1 -1
  88. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +18 -35
  89. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  90. package/lib/commonjs/reanimated2/animation/styleAnimation.js +5 -1
  91. package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
  92. package/lib/commonjs/reanimated2/animation/util.js +17 -15
  93. package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
  94. package/lib/commonjs/reanimated2/commonTypes.js +33 -1
  95. package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
  96. package/lib/commonjs/reanimated2/component/FlatList.js +19 -3
  97. package/lib/commonjs/reanimated2/component/FlatList.js.map +1 -1
  98. package/lib/commonjs/reanimated2/core.js +34 -83
  99. package/lib/commonjs/reanimated2/core.js.map +1 -1
  100. package/lib/commonjs/reanimated2/errors.js +66 -0
  101. package/lib/commonjs/reanimated2/errors.js.map +1 -0
  102. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
  103. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  104. package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
  105. package/lib/commonjs/reanimated2/hook/index.js +0 -6
  106. package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
  107. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +5 -2
  108. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  109. package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +13 -1
  110. package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  111. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +1 -1
  112. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
  113. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +89 -16
  114. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  115. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +43 -50
  116. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  117. package/lib/commonjs/reanimated2/hook/useDerivedValue.js +13 -1
  118. package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
  119. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +2 -2
  120. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  121. package/lib/commonjs/reanimated2/hook/utils.js +18 -65
  122. package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
  123. package/lib/commonjs/reanimated2/index.js +13 -0
  124. package/lib/commonjs/reanimated2/index.js.map +1 -1
  125. package/lib/commonjs/reanimated2/initializers.js +196 -0
  126. package/lib/commonjs/reanimated2/initializers.js.map +1 -0
  127. package/lib/commonjs/reanimated2/interpolateColor.js +96 -19
  128. package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
  129. package/lib/commonjs/reanimated2/jestUtils.js +1 -1
  130. package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
  131. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +101 -16
  132. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  133. package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +22 -0
  134. package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
  135. package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js +2 -0
  136. package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js.map +1 -0
  137. package/lib/commonjs/reanimated2/js-reanimated/commonTypes.js.map +1 -1
  138. package/lib/commonjs/reanimated2/js-reanimated/global.js +4 -9
  139. package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
  140. package/lib/commonjs/reanimated2/js-reanimated/index.js +0 -1
  141. package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
  142. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +11 -0
  143. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  144. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +8 -0
  145. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  146. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +16 -12
  147. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  148. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -23
  149. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  150. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -14
  151. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  152. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -14
  153. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  154. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -15
  155. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  156. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -23
  157. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  158. package/lib/commonjs/reanimated2/layoutReanimation/index.js +13 -0
  159. package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
  160. package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +94 -0
  161. package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
  162. package/lib/commonjs/reanimated2/mappers.js +18 -6
  163. package/lib/commonjs/reanimated2/mappers.js.map +1 -1
  164. package/lib/commonjs/reanimated2/mock.js +45 -0
  165. package/lib/commonjs/reanimated2/mock.js.map +1 -1
  166. package/lib/commonjs/reanimated2/mutables.js +4 -2
  167. package/lib/commonjs/reanimated2/mutables.js.map +1 -1
  168. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +42 -0
  169. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +1 -0
  170. package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +15 -0
  171. package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
  172. package/lib/commonjs/reanimated2/pluginUtils.js +11 -0
  173. package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -0
  174. package/lib/commonjs/reanimated2/shareables.js +38 -11
  175. package/lib/commonjs/reanimated2/shareables.js.map +1 -1
  176. package/lib/commonjs/reanimated2/threads.js +114 -4
  177. package/lib/commonjs/reanimated2/threads.js.map +1 -1
  178. package/lib/commonjs/reanimated2/utils.js +7 -0
  179. package/lib/commonjs/reanimated2/utils.js.map +1 -1
  180. package/lib/commonjs/reanimated2/valueSetter.js +1 -3
  181. package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
  182. package/lib/module/createAnimatedComponent.js +229 -29
  183. package/lib/module/createAnimatedComponent.js.map +1 -1
  184. package/lib/module/reanimated2/Colors.js +35 -19
  185. package/lib/module/reanimated2/Colors.js.map +1 -1
  186. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +18 -34
  187. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  188. package/lib/module/reanimated2/animation/styleAnimation.js +5 -1
  189. package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
  190. package/lib/module/reanimated2/animation/util.js +17 -16
  191. package/lib/module/reanimated2/animation/util.js.map +1 -1
  192. package/lib/module/reanimated2/commonTypes.js +29 -0
  193. package/lib/module/reanimated2/commonTypes.js.map +1 -1
  194. package/lib/module/reanimated2/component/FlatList.js +18 -4
  195. package/lib/module/reanimated2/component/FlatList.js.map +1 -1
  196. package/lib/module/reanimated2/core.js +30 -76
  197. package/lib/module/reanimated2/core.js.map +1 -1
  198. package/lib/module/reanimated2/errors.js +58 -0
  199. package/lib/module/reanimated2/errors.js.map +1 -0
  200. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
  201. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  202. package/lib/module/reanimated2/globals.d.js.map +1 -1
  203. package/lib/module/reanimated2/hook/index.js +1 -1
  204. package/lib/module/reanimated2/hook/index.js.map +1 -1
  205. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +5 -2
  206. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  207. package/lib/module/reanimated2/hook/useAnimatedReaction.js +12 -1
  208. package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  209. package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
  210. package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
  211. package/lib/module/reanimated2/hook/useAnimatedSensor.js +88 -13
  212. package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  213. package/lib/module/reanimated2/hook/useAnimatedStyle.js +45 -52
  214. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  215. package/lib/module/reanimated2/hook/useDerivedValue.js +12 -1
  216. package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
  217. package/lib/module/reanimated2/hook/useScrollViewOffset.js +2 -2
  218. package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  219. package/lib/module/reanimated2/hook/utils.js +17 -60
  220. package/lib/module/reanimated2/hook/utils.js.map +1 -1
  221. package/lib/module/reanimated2/index.js +1 -0
  222. package/lib/module/reanimated2/index.js.map +1 -1
  223. package/lib/module/reanimated2/initializers.js +182 -0
  224. package/lib/module/reanimated2/initializers.js.map +1 -0
  225. package/lib/module/reanimated2/interpolateColor.js +96 -19
  226. package/lib/module/reanimated2/interpolateColor.js.map +1 -1
  227. package/lib/module/reanimated2/jestUtils.js +1 -1
  228. package/lib/module/reanimated2/jestUtils.js.map +1 -1
  229. package/lib/module/reanimated2/js-reanimated/JSReanimated.js +101 -16
  230. package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  231. package/lib/module/reanimated2/js-reanimated/Mapper.js +21 -0
  232. package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
  233. package/lib/module/reanimated2/js-reanimated/WebSensor.js +2 -0
  234. package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -0
  235. package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
  236. package/lib/module/reanimated2/js-reanimated/global.js +4 -9
  237. package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
  238. package/lib/module/reanimated2/js-reanimated/index.js +0 -1
  239. package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
  240. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +9 -1
  241. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  242. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js +1 -0
  243. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  244. package/lib/module/reanimated2/layoutReanimation/animationsManager.js +15 -10
  245. package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  246. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -21
  247. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  248. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -12
  249. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  250. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
  251. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  252. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -13
  253. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  254. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -21
  255. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  256. package/lib/module/reanimated2/layoutReanimation/index.js +1 -0
  257. package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
  258. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +82 -0
  259. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
  260. package/lib/module/reanimated2/mappers.js +16 -6
  261. package/lib/module/reanimated2/mappers.js.map +1 -1
  262. package/lib/module/reanimated2/mock.js +45 -0
  263. package/lib/module/reanimated2/mock.js.map +1 -1
  264. package/lib/module/reanimated2/mutables.js +4 -2
  265. package/lib/module/reanimated2/mutables.js.map +1 -1
  266. package/lib/module/reanimated2/platform-specific/checkVersion.js +35 -0
  267. package/lib/module/reanimated2/platform-specific/checkVersion.js.map +1 -0
  268. package/lib/module/reanimated2/platform-specific/checkVersion.web.js +8 -0
  269. package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
  270. package/lib/module/reanimated2/pluginUtils.js +4 -0
  271. package/lib/module/reanimated2/pluginUtils.js.map +1 -0
  272. package/lib/module/reanimated2/shareables.js +38 -9
  273. package/lib/module/reanimated2/shareables.js.map +1 -1
  274. package/lib/module/reanimated2/threads.js +105 -4
  275. package/lib/module/reanimated2/threads.js.map +1 -1
  276. package/lib/module/reanimated2/utils.js +5 -0
  277. package/lib/module/reanimated2/utils.js.map +1 -1
  278. package/lib/module/reanimated2/valueSetter.js +1 -2
  279. package/lib/module/reanimated2/valueSetter.js.map +1 -1
  280. package/package.json +9 -8
  281. package/{plugin.js → plugin/index.js} +173 -228
  282. package/react-native-reanimated.d.ts +57 -10
  283. package/scripts/reanimated_utils.rb +15 -2
  284. package/src/createAnimatedComponent.tsx +238 -28
  285. package/src/reanimated2/Colors.ts +38 -11
  286. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +63 -41
  287. package/src/reanimated2/animation/styleAnimation.ts +8 -1
  288. package/src/reanimated2/animation/util.ts +29 -16
  289. package/src/reanimated2/commonTypes.ts +28 -1
  290. package/src/reanimated2/component/FlatList.tsx +30 -5
  291. package/src/reanimated2/core.ts +45 -75
  292. package/src/reanimated2/errors.ts +57 -0
  293. package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +2 -2
  294. package/src/reanimated2/globals.d.ts +34 -18
  295. package/src/reanimated2/hook/index.ts +1 -1
  296. package/src/reanimated2/hook/useAnimatedKeyboard.ts +10 -4
  297. package/src/reanimated2/hook/useAnimatedReaction.ts +12 -5
  298. package/src/reanimated2/hook/useAnimatedRef.ts +1 -4
  299. package/src/reanimated2/hook/useAnimatedSensor.ts +88 -11
  300. package/src/reanimated2/hook/useAnimatedStyle.ts +43 -45
  301. package/src/reanimated2/hook/useDerivedValue.ts +8 -1
  302. package/src/reanimated2/hook/useScrollViewOffset.ts +2 -2
  303. package/src/reanimated2/hook/utils.ts +15 -61
  304. package/src/reanimated2/index.ts +1 -0
  305. package/src/reanimated2/initializers.ts +184 -0
  306. package/src/reanimated2/interpolateColor.ts +104 -20
  307. package/src/reanimated2/jestUtils.ts +1 -1
  308. package/src/reanimated2/js-reanimated/JSReanimated.ts +105 -18
  309. package/src/reanimated2/js-reanimated/Mapper.ts +32 -0
  310. package/src/reanimated2/js-reanimated/WebSensor.ts +34 -0
  311. package/src/reanimated2/js-reanimated/commonTypes.ts +0 -1
  312. package/src/reanimated2/js-reanimated/global.ts +4 -8
  313. package/src/reanimated2/js-reanimated/index.ts +0 -1
  314. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +13 -1
  315. package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
  316. package/src/reanimated2/layoutReanimation/animationsManager.ts +17 -12
  317. package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +16 -19
  318. package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +14 -11
  319. package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +21 -11
  320. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -11
  321. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +36 -19
  322. package/src/reanimated2/layoutReanimation/index.ts +1 -0
  323. package/src/reanimated2/layoutReanimation/sharedTransitions/index.ts +87 -0
  324. package/src/reanimated2/mappers.ts +17 -6
  325. package/src/reanimated2/mock.ts +128 -0
  326. package/src/reanimated2/mutables.ts +2 -0
  327. package/src/reanimated2/platform-specific/checkVersion.ts +39 -0
  328. package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
  329. package/src/reanimated2/pluginUtils.ts +8 -0
  330. package/src/reanimated2/shareables.ts +47 -11
  331. package/src/reanimated2/threads.ts +103 -1
  332. package/src/reanimated2/utils.ts +6 -0
  333. package/src/reanimated2/valueSetter.ts +1 -2
  334. package/lib/commonjs/reanimated2/time.js +0 -55
  335. package/lib/commonjs/reanimated2/time.js.map +0 -1
  336. package/lib/module/reanimated2/time.js +0 -37
  337. package/lib/module/reanimated2/time.js.map +0 -1
  338. package/src/reanimated2/time.ts +0 -30
  339. /package/android/src/{main/java → reactNativeVersionPatch/ReanimatedUIManager/70}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -0
@@ -0,0 +1,14 @@
1
+ #pragma once
2
+
3
+ #include <algorithm>
4
+
5
+ namespace reanimated {
6
+ namespace collection {
7
+
8
+ template <class CollectionType, class ValueType>
9
+ inline bool contains(CollectionType &collection, const ValueType &value) {
10
+ return collection.find(value) != collection.end();
11
+ }
12
+
13
+ } // namespace collection
14
+ } // namespace reanimated
@@ -0,0 +1,26 @@
1
+ #include "JsiUtils.h"
2
+ #include <vector>
3
+
4
+ using namespace facebook;
5
+
6
+ namespace reanimated::jsi_utils {
7
+
8
+ jsi::Array convertStringToArray(
9
+ jsi::Runtime &rt,
10
+ const std::string &value,
11
+ const unsigned int expectedSize) {
12
+ std::vector<float> transformMatrixList;
13
+ std::istringstream stringStream(value);
14
+ std::copy(
15
+ std::istream_iterator<float>(stringStream),
16
+ std::istream_iterator<float>(),
17
+ std::back_inserter(transformMatrixList));
18
+ assert(transformMatrixList.size() == expectedSize);
19
+ jsi::Array matrix(rt, expectedSize);
20
+ for (int i = 0; i < expectedSize; i++) {
21
+ matrix.setValueAtIndex(rt, i, transformMatrixList[i]);
22
+ }
23
+ return matrix;
24
+ }
25
+
26
+ } // namespace reanimated::jsi_utils
@@ -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;
@@ -30,69 +44,34 @@ void RuntimeDecorator::decorateRuntime(
30
44
  rt.global().setProperty(
31
45
  rt, "_LABEL", jsi::String::createFromAscii(rt, label));
32
46
 
33
- jsi::Object dummyGlobal(rt);
34
- dummyGlobal.setProperty(rt, "gc", rt.global().getProperty(rt, "gc"));
35
- rt.global().setProperty(rt, "global", dummyGlobal);
36
-
37
- rt.global().setProperty(rt, "jsThis", jsi::Value::undefined());
38
-
39
- auto callback = [](jsi::Runtime &rt,
40
- const jsi::Value &thisValue,
41
- const jsi::Value *args,
42
- size_t count) -> jsi::Value {
43
- const jsi::Value *value = &args[0];
44
- if (value->isString()) {
45
- Logger::log(value->getString(rt).utf8(rt).c_str());
46
- } else if (value->isNumber()) {
47
- Logger::log(value->getNumber());
48
- } else if (value->isUndefined()) {
49
- Logger::log("undefined");
50
- } else {
51
- Logger::log("unsupported value type");
47
+ rt.global().setProperty(rt, "global", rt.global());
48
+
49
+ #ifdef DEBUG
50
+ auto evalWithSourceUrl = [](jsi::Runtime &rt,
51
+ const jsi::Value &thisValue,
52
+ const jsi::Value *args,
53
+ size_t count) -> jsi::Value {
54
+ auto code = std::make_shared<const jsi::StringBuffer>(
55
+ args[0].asString(rt).utf8(rt));
56
+ std::string url;
57
+ if (count > 1 && args[1].isString()) {
58
+ url = args[1].asString(rt).utf8(rt);
52
59
  }
53
- return jsi::Value::undefined();
54
- };
55
- jsi::Value log = jsi::Function::createFromHostFunction(
56
- rt, jsi::PropNameID::forAscii(rt, "_log"), 1, callback);
57
- rt.global().setProperty(rt, "_log", log);
58
60
 
59
- auto setGlobalConsole = [](jsi::Runtime &rt,
60
- const jsi::Value &thisValue,
61
- const jsi::Value *args,
62
- size_t count) -> jsi::Value {
63
- rt.global().setProperty(rt, "console", args[0]);
64
- return jsi::Value::undefined();
61
+ return rt.evaluateJavaScript(code, url);
65
62
  };
63
+
66
64
  rt.global().setProperty(
67
65
  rt,
68
- "_setGlobalConsole",
66
+ "evalWithSourceUrl",
69
67
  jsi::Function::createFromHostFunction(
70
68
  rt,
71
- jsi::PropNameID::forAscii(rt, "_setGlobalConsole"),
69
+ jsi::PropNameID::forAscii(rt, "evalWithSourceUrl"),
72
70
  1,
73
- setGlobalConsole));
74
-
75
- auto chronoNow = [](jsi::Runtime &rt,
76
- const jsi::Value &thisValue,
77
- const jsi::Value *args,
78
- size_t count) -> jsi::Value {
79
- double now = std::chrono::system_clock::now().time_since_epoch() /
80
- std::chrono::milliseconds(1);
81
- return jsi::Value(now);
82
- };
71
+ evalWithSourceUrl));
72
+ #endif // DEBUG
83
73
 
84
- rt.global().setProperty(
85
- rt,
86
- "_chronoNow",
87
- jsi::Function::createFromHostFunction(
88
- rt, jsi::PropNameID::forAscii(rt, "_chronoNow"), 0, chronoNow));
89
- jsi::Object performance(rt);
90
- performance.setProperty(
91
- rt,
92
- "now",
93
- jsi::Function::createFromHostFunction(
94
- rt, jsi::PropNameID::forAscii(rt, "now"), 0, chronoNow));
95
- rt.global().setProperty(rt, "performance", performance);
74
+ jsi_utils::installJsiFunction(rt, "_log", logValue);
96
75
  }
97
76
 
98
77
  void RuntimeDecorator::decorateUIRuntime(
@@ -110,8 +89,6 @@ void RuntimeDecorator::decorateUIRuntime(
110
89
  const MakeShareableCloneFunction makeShareableClone,
111
90
  const UpdateDataSynchronouslyFunction updateDataSynchronously,
112
91
  const TimeProviderFunction getCurrentTime,
113
- const RegisterSensorFunction registerSensor,
114
- const UnregisterSensorFunction unregisterSensor,
115
92
  const SetGestureStateFunction setGestureState,
116
93
  const ProgressLayoutAnimationFunction progressLayoutAnimationFunction,
117
94
  const EndLayoutAnimationFunction endLayoutAnimationFunction) {
@@ -119,95 +96,17 @@ void RuntimeDecorator::decorateUIRuntime(
119
96
  rt.global().setProperty(rt, "_UI", jsi::Value(true));
120
97
 
121
98
  #ifdef RCT_NEW_ARCH_ENABLED
122
- auto clb = [updateProps](
123
- jsi::Runtime &rt,
124
- const jsi::Value &thisValue,
125
- const jsi::Value *args,
126
- const size_t count) -> jsi::Value {
127
- updateProps(rt, args[0], args[1]);
128
- return jsi::Value::undefined();
129
- };
130
- jsi::Value updatePropsHostFunction = jsi::Function::createFromHostFunction(
131
- rt, jsi::PropNameID::forAscii(rt, "_updatePropsFabric"), 2, clb);
132
- rt.global().setProperty(rt, "_updatePropsFabric", updatePropsHostFunction);
133
-
134
- auto _removeShadowNodeFromRegistry = [removeShadowNodeFromRegistry](
135
- jsi::Runtime &rt,
136
- const jsi::Value &thisValue,
137
- const jsi::Value *args,
138
- const size_t count) -> jsi::Value {
139
- removeShadowNodeFromRegistry(rt, args[0]);
140
- return jsi::Value::undefined();
141
- };
142
- jsi::Value removeShadowNodeFromRegistryHostFunction =
143
- jsi::Function::createFromHostFunction(
144
- rt,
145
- jsi::PropNameID::forAscii(rt, "_removeShadowNodeFromRegistry"),
146
- 2,
147
- _removeShadowNodeFromRegistry);
148
- rt.global().setProperty(
149
- rt,
150
- "_removeShadowNodeFromRegistry",
151
- removeShadowNodeFromRegistryHostFunction);
152
-
153
- auto clb3 = [dispatchCommand](
154
- jsi::Runtime &rt,
155
- const jsi::Value &thisValue,
156
- const jsi::Value *args,
157
- const size_t count) -> jsi::Value {
158
- dispatchCommand(rt, args[0], args[1], args[2]);
159
- return jsi::Value::undefined();
160
- };
161
- jsi::Value dispatchCommandHostFunction =
162
- jsi::Function::createFromHostFunction(
163
- rt, jsi::PropNameID::forAscii(rt, "_dispatchCommand"), 3, clb3);
164
- rt.global().setProperty(rt, "_dispatchCommand", dispatchCommandHostFunction);
165
-
166
- auto _measure = [measure](
167
- jsi::Runtime &rt,
168
- const jsi::Value &thisValue,
169
- const jsi::Value *args,
170
- const size_t count) -> jsi::Value {
171
- return measure(rt, args[0]);
172
- };
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);
173
104
  #else
174
- auto clb = [updateProps](
175
- jsi::Runtime &rt,
176
- const jsi::Value &thisValue,
177
- const jsi::Value *args,
178
- const size_t count) -> jsi::Value {
179
- const auto viewTag = args[0].asNumber();
180
- const jsi::Value *viewName = &args[1];
181
- const auto params = args[2].asObject(rt);
182
- updateProps(rt, viewTag, *viewName, params);
183
- return jsi::Value::undefined();
184
- };
185
- jsi::Value updatePropsHostFunction = jsi::Function::createFromHostFunction(
186
- rt, jsi::PropNameID::forAscii(rt, "_updatePropsPaper"), 3, clb);
187
- rt.global().setProperty(rt, "_updatePropsPaper", updatePropsHostFunction);
105
+ jsi_utils::installJsiFunction(rt, "_updatePropsPaper", updateProps);
106
+ jsi_utils::installJsiFunction(rt, "_scrollTo", scrollTo);
188
107
 
189
- auto _scrollTo = [scrollTo](
190
- jsi::Runtime &rt,
191
- const jsi::Value &thisValue,
192
- const jsi::Value *args,
193
- const size_t count) -> jsi::Value {
194
- int viewTag = static_cast<int>(args[0].asNumber());
195
- double x = args[1].asNumber();
196
- double y = args[2].asNumber();
197
- bool animated = args[3].getBool();
198
- scrollTo(viewTag, x, y, animated);
199
- return jsi::Value::undefined();
200
- };
201
- jsi::Value scrollToFunction = jsi::Function::createFromHostFunction(
202
- rt, jsi::PropNameID::forAscii(rt, "_scrollTo"), 4, _scrollTo);
203
- rt.global().setProperty(rt, "_scrollTo", scrollToFunction);
204
-
205
- auto _measure = [measure](
206
- jsi::Runtime &rt,
207
- const jsi::Value &thisValue,
208
- const jsi::Value *args,
209
- const size_t count) -> jsi::Value {
210
- 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 {
211
110
  auto result = measure(viewTag);
212
111
  jsi::Object resultObject(rt);
213
112
  for (auto &i : result) {
@@ -215,117 +114,38 @@ void RuntimeDecorator::decorateUIRuntime(
215
114
  }
216
115
  return resultObject;
217
116
  };
218
- #endif // RCT_NEW_ARCH_ENABLED
219
-
220
- jsi::Value measureFunction = jsi::Function::createFromHostFunction(
221
- rt, jsi::PropNameID::forAscii(rt, "_measure"), 1, _measure);
222
- rt.global().setProperty(rt, "_measure", measureFunction);
223
117
 
224
- auto clb2 = [requestFrame](
225
- jsi::Runtime &rt,
226
- const jsi::Value &thisValue,
227
- const jsi::Value *args,
228
- const size_t count) -> jsi::Value {
229
- auto fun =
230
- std::make_shared<jsi::Function>(args[0].asObject(rt).asFunction(rt));
231
- requestFrame([&rt, fun](double timestampMs) {
232
- fun->call(rt, jsi::Value(timestampMs));
233
- });
234
- return jsi::Value::undefined();
235
- };
236
- jsi::Value requestAnimationFrame = jsi::Function::createFromHostFunction(
237
- rt, jsi::PropNameID::forAscii(rt, "requestAnimationFrame"), 1, clb2);
238
- rt.global().setProperty(rt, "requestAnimationFrame", requestAnimationFrame);
239
-
240
- auto clb4 = [scheduleOnJS](
241
- jsi::Runtime &rt,
242
- const jsi::Value &thisValue,
243
- const jsi::Value *args,
244
- const size_t count) -> jsi::Value {
245
- scheduleOnJS(rt, args[0], args[1]);
246
- return jsi::Value::undefined();
247
- };
248
- jsi::Value scheduleOnJSFun = jsi::Function::createFromHostFunction(
249
- rt, jsi::PropNameID::forAscii(rt, "_scheduleOnJS"), 2, clb4);
250
- rt.global().setProperty(rt, "_scheduleOnJS", scheduleOnJSFun);
251
-
252
- auto clb5 = [makeShareableClone](
253
- jsi::Runtime &rt,
254
- const jsi::Value &thisValue,
255
- const jsi::Value *args,
256
- const size_t count) -> jsi::Value {
257
- return makeShareableClone(rt, std::move(args[0]));
258
- };
259
- jsi::Value makeShareableCloneFun = jsi::Function::createFromHostFunction(
260
- rt, jsi::PropNameID::forAscii(rt, "_makeShareableClone"), 1, clb5);
261
- rt.global().setProperty(rt, "_makeShareableClone", makeShareableCloneFun);
118
+ jsi_utils::installJsiFunction(rt, "_measure", _measure);
119
+ #endif // RCT_NEW_ARCH_ENABLED
262
120
 
263
- auto clb51 = [updateDataSynchronously](
264
- jsi::Runtime &rt,
265
- const jsi::Value &thisValue,
266
- const jsi::Value *args,
267
- const size_t count) -> jsi::Value {
268
- updateDataSynchronously(rt, std::move(args[0]), std::move(args[1]));
269
- return jsi::Value::undefined();
270
- };
271
- jsi::Value updateDataSynchronouslyFun = jsi::Function::createFromHostFunction(
272
- rt, jsi::PropNameID::forAscii(rt, "_updateDataSynchronously"), 1, clb51);
273
- rt.global().setProperty(
274
- rt, "_updateDataSynchronously", updateDataSynchronouslyFun);
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);
275
126
 
276
- auto clb6 = [getCurrentTime](
277
- jsi::Runtime &rt,
278
- const jsi::Value &thisValue,
279
- const jsi::Value *args,
280
- const size_t count) -> jsi::Value {
281
- return getCurrentTime();
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());
282
133
  };
283
- jsi::Value timeFun = jsi::Function::createFromHostFunction(
284
- rt, jsi::PropNameID::forAscii(rt, "_getCurrentTime"), 0, clb6);
285
- rt.global().setProperty(rt, "_getCurrentTime", timeFun);
286
-
287
- rt.global().setProperty(rt, "_frameTimestamp", jsi::Value::undefined());
288
- 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);
289
141
 
290
142
  // layout animation
291
- auto clb7 = [progressLayoutAnimationFunction](
292
- jsi::Runtime &rt,
293
- const jsi::Value &thisValue,
294
- const jsi::Value *args,
295
- size_t count) -> jsi::Value {
296
- progressLayoutAnimationFunction(args[0].asNumber(), args[1].asObject(rt));
297
- return jsi::Value::undefined();
298
- };
299
- jsi::Value _notifyAboutProgress = jsi::Function::createFromHostFunction(
300
- rt, jsi::PropNameID::forAscii(rt, "_notifyAboutProgress"), 2, clb7);
301
- rt.global().setProperty(rt, "_notifyAboutProgress", _notifyAboutProgress);
143
+ jsi_utils::installJsiFunction(
144
+ rt, "_notifyAboutProgress", progressLayoutAnimationFunction);
145
+ jsi_utils::installJsiFunction(
146
+ rt, "_notifyAboutEnd", endLayoutAnimationFunction);
302
147
 
303
- auto clb8 = [endLayoutAnimationFunction](
304
- jsi::Runtime &rt,
305
- const jsi::Value &thisValue,
306
- const jsi::Value *args,
307
- size_t count) -> jsi::Value {
308
- endLayoutAnimationFunction(
309
- args[0].asNumber(), args[1].getBool(), args[2].getBool());
310
- return jsi::Value::undefined();
311
- };
312
- jsi::Value _notifyAboutEnd = jsi::Function::createFromHostFunction(
313
- rt, jsi::PropNameID::forAscii(rt, "_notifyAboutEnd"), 2, clb8);
314
- rt.global().setProperty(rt, "_notifyAboutEnd", _notifyAboutEnd);
315
-
316
- auto clb9 = [setGestureState](
317
- jsi::Runtime &rt,
318
- const jsi::Value &thisValue,
319
- const jsi::Value *args,
320
- size_t count) -> jsi::Value {
321
- int handlerTag = static_cast<int>(args[0].asNumber());
322
- int newState = static_cast<int>(args[1].asNumber());
323
- setGestureState(handlerTag, newState);
324
- return jsi::Value::undefined();
325
- };
326
- jsi::Value setGestureStateFunction = jsi::Function::createFromHostFunction(
327
- rt, jsi::PropNameID::forAscii(rt, "_setGestureState"), 2, clb9);
328
- rt.global().setProperty(rt, "_setGestureState", setGestureStateFunction);
148
+ jsi_utils::installJsiFunction(rt, "_setGestureState", setGestureState);
329
149
  }
330
150
 
331
151
  } // namespace reanimated
@@ -11,7 +11,8 @@ using namespace facebook;
11
11
 
12
12
  namespace reanimated {
13
13
 
14
- using RequestFrameFunction = std::function<void(std::function<void(double)>)>;
14
+ using RequestFrameFunction =
15
+ std::function<void(jsi::Runtime &, const jsi::Value &)>;
15
16
  using ScheduleOnJSFunction =
16
17
  std::function<void(jsi::Runtime &, const jsi::Value &, const jsi::Value &)>;
17
18
  using MakeShareableCloneFunction =
@@ -49,8 +50,6 @@ class RuntimeDecorator {
49
50
  const MakeShareableCloneFunction makeShareableClone,
50
51
  const UpdateDataSynchronouslyFunction updateDataSynchronously,
51
52
  const TimeProviderFunction getCurrentTime,
52
- const RegisterSensorFunction registerSensor,
53
- const UnregisterSensorFunction unregisterSensor,
54
53
  const SetGestureStateFunction setGestureState,
55
54
  const ProgressLayoutAnimationFunction progressLayoutAnimationFunction,
56
55
  const EndLayoutAnimationFunction endLayoutAnimationFunction);