react-native-reanimated 3.0.0-rc.9 → 3.0.1

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 (331) 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/README.md +1 -1
  31. package/RNReanimated.podspec +2 -1
  32. package/android/CMakeLists.txt +188 -181
  33. package/android/build.gradle +362 -311
  34. package/android/proguard-rules.pro +2 -0
  35. package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +63 -295
  36. package/android/src/main/cpp/LayoutAnimations.cpp +35 -5
  37. package/android/src/main/cpp/LayoutAnimations.h +23 -6
  38. package/android/src/main/cpp/NativeProxy.cpp +143 -98
  39. package/android/src/main/cpp/NativeProxy.h +22 -28
  40. package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +5 -4
  41. package/android/src/main/java/com/swmansion/reanimated/Utils.java +7 -1
  42. package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +10 -3
  43. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +218 -35
  44. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +43 -17
  45. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +6 -2
  46. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedElement.java +19 -0
  47. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +610 -0
  48. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +93 -23
  49. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/AnimationFrameCallback.java +19 -0
  50. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/EventHandler.java +35 -0
  51. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/KeyboardEventDataUpdater.java +16 -0
  52. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +206 -0
  53. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/SensorSetter.java +17 -0
  54. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +9 -3
  55. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +3 -4
  56. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -7
  57. package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +90 -307
  58. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +16 -0
  59. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +63 -0
  60. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +271 -0
  61. package/android/src/reactNativeVersionPatch/nativeHierarchyManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +76 -20
  62. package/ios/LayoutReanimation/REAAnimationsManager.h +28 -4
  63. package/ios/LayoutReanimation/REAAnimationsManager.m +216 -61
  64. package/ios/LayoutReanimation/REAFrame.h +10 -0
  65. package/ios/LayoutReanimation/REAFrame.m +15 -0
  66. package/ios/LayoutReanimation/REAScreensHelper.h +19 -0
  67. package/ios/LayoutReanimation/REAScreensHelper.m +106 -0
  68. package/ios/LayoutReanimation/REASharedElement.h +15 -0
  69. package/ios/LayoutReanimation/REASharedElement.m +16 -0
  70. package/ios/LayoutReanimation/REASharedTransitionManager.h +17 -0
  71. package/ios/LayoutReanimation/REASharedTransitionManager.m +632 -0
  72. package/ios/LayoutReanimation/REASnapshot.h +1 -0
  73. package/ios/LayoutReanimation/REASnapshot.m +96 -11
  74. package/ios/LayoutReanimation/REAUIManager.mm +64 -17
  75. package/ios/REAModule.mm +2 -7
  76. package/ios/REANodesManager.mm +1 -21
  77. package/ios/keyboardObserver/REAKeyboardEventObserver.m +72 -36
  78. package/ios/native/NativeProxy.mm +75 -114
  79. package/ios/native/REAInitializer.mm +2 -7
  80. package/ios/native/REAJSIUtils.h +60 -2
  81. package/ios/sensor/ReanimatedSensor.h +6 -2
  82. package/ios/sensor/ReanimatedSensor.m +43 -7
  83. package/ios/sensor/ReanimatedSensorContainer.h +4 -1
  84. package/ios/sensor/ReanimatedSensorContainer.m +8 -2
  85. package/lib/commonjs/createAnimatedComponent.js +244 -28
  86. package/lib/commonjs/createAnimatedComponent.js.map +1 -1
  87. package/lib/commonjs/reanimated2/Colors.js +43 -22
  88. package/lib/commonjs/reanimated2/Colors.js.map +1 -1
  89. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +16 -33
  90. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  91. package/lib/commonjs/reanimated2/animation/styleAnimation.js +5 -1
  92. package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
  93. package/lib/commonjs/reanimated2/animation/util.js +17 -15
  94. package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
  95. package/lib/commonjs/reanimated2/commonTypes.js +33 -1
  96. package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
  97. package/lib/commonjs/reanimated2/core.js +33 -14
  98. package/lib/commonjs/reanimated2/core.js.map +1 -1
  99. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
  100. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  101. package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
  102. package/lib/commonjs/reanimated2/hook/index.js +0 -6
  103. package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
  104. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +5 -2
  105. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  106. package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +13 -1
  107. package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  108. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +1 -1
  109. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
  110. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +91 -15
  111. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  112. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +43 -40
  113. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  114. package/lib/commonjs/reanimated2/hook/useDerivedValue.js +13 -1
  115. package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
  116. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +2 -2
  117. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  118. package/lib/commonjs/reanimated2/hook/utils.js +18 -65
  119. package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
  120. package/lib/commonjs/reanimated2/index.js +13 -0
  121. package/lib/commonjs/reanimated2/index.js.map +1 -1
  122. package/lib/commonjs/reanimated2/initializers.js +71 -32
  123. package/lib/commonjs/reanimated2/initializers.js.map +1 -1
  124. package/lib/commonjs/reanimated2/interpolateColor.js +96 -19
  125. package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
  126. package/lib/commonjs/reanimated2/jestUtils.js +1 -1
  127. package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
  128. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +103 -13
  129. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  130. package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +22 -0
  131. package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
  132. package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js +2 -0
  133. package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js.map +1 -0
  134. package/lib/commonjs/reanimated2/js-reanimated/commonTypes.js.map +1 -1
  135. package/lib/commonjs/reanimated2/js-reanimated/global.js +0 -2
  136. package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
  137. package/lib/commonjs/reanimated2/js-reanimated/index.js +0 -1
  138. package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
  139. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +11 -0
  140. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  141. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +8 -0
  142. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  143. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +22 -9
  144. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  145. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -23
  146. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  147. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -14
  148. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  149. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -14
  150. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  151. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -15
  152. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  153. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -23
  154. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  155. package/lib/commonjs/reanimated2/layoutReanimation/index.js +13 -0
  156. package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
  157. package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +94 -0
  158. package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
  159. package/lib/commonjs/reanimated2/mappers.js +18 -6
  160. package/lib/commonjs/reanimated2/mappers.js.map +1 -1
  161. package/lib/commonjs/reanimated2/mock.js +20 -1
  162. package/lib/commonjs/reanimated2/mock.js.map +1 -1
  163. package/lib/commonjs/reanimated2/mutables.js +4 -2
  164. package/lib/commonjs/reanimated2/mutables.js.map +1 -1
  165. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +42 -0
  166. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +1 -0
  167. package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +15 -0
  168. package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
  169. package/lib/commonjs/reanimated2/pluginUtils.js +11 -0
  170. package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -0
  171. package/lib/commonjs/reanimated2/shareables.js +36 -15
  172. package/lib/commonjs/reanimated2/shareables.js.map +1 -1
  173. package/lib/commonjs/reanimated2/threads.js +114 -7
  174. package/lib/commonjs/reanimated2/threads.js.map +1 -1
  175. package/lib/commonjs/reanimated2/utils.js +7 -0
  176. package/lib/commonjs/reanimated2/utils.js.map +1 -1
  177. package/lib/commonjs/reanimated2/valueSetter.js +1 -3
  178. package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
  179. package/lib/module/createAnimatedComponent.js +241 -29
  180. package/lib/module/createAnimatedComponent.js.map +1 -1
  181. package/lib/module/reanimated2/Colors.js +35 -19
  182. package/lib/module/reanimated2/Colors.js.map +1 -1
  183. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +16 -32
  184. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  185. package/lib/module/reanimated2/animation/styleAnimation.js +5 -1
  186. package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
  187. package/lib/module/reanimated2/animation/util.js +17 -16
  188. package/lib/module/reanimated2/animation/util.js.map +1 -1
  189. package/lib/module/reanimated2/commonTypes.js +29 -0
  190. package/lib/module/reanimated2/commonTypes.js.map +1 -1
  191. package/lib/module/reanimated2/core.js +32 -7
  192. package/lib/module/reanimated2/core.js.map +1 -1
  193. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
  194. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  195. package/lib/module/reanimated2/globals.d.js.map +1 -1
  196. package/lib/module/reanimated2/hook/index.js +1 -1
  197. package/lib/module/reanimated2/hook/index.js.map +1 -1
  198. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +5 -2
  199. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  200. package/lib/module/reanimated2/hook/useAnimatedReaction.js +12 -1
  201. package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  202. package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
  203. package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
  204. package/lib/module/reanimated2/hook/useAnimatedSensor.js +90 -13
  205. package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  206. package/lib/module/reanimated2/hook/useAnimatedStyle.js +46 -43
  207. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  208. package/lib/module/reanimated2/hook/useDerivedValue.js +12 -1
  209. package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
  210. package/lib/module/reanimated2/hook/useScrollViewOffset.js +2 -2
  211. package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  212. package/lib/module/reanimated2/hook/utils.js +17 -60
  213. package/lib/module/reanimated2/hook/utils.js.map +1 -1
  214. package/lib/module/reanimated2/index.js +1 -0
  215. package/lib/module/reanimated2/index.js.map +1 -1
  216. package/lib/module/reanimated2/initializers.js +72 -33
  217. package/lib/module/reanimated2/initializers.js.map +1 -1
  218. package/lib/module/reanimated2/interpolateColor.js +96 -19
  219. package/lib/module/reanimated2/interpolateColor.js.map +1 -1
  220. package/lib/module/reanimated2/jestUtils.js +1 -1
  221. package/lib/module/reanimated2/jestUtils.js.map +1 -1
  222. package/lib/module/reanimated2/js-reanimated/JSReanimated.js +103 -13
  223. package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  224. package/lib/module/reanimated2/js-reanimated/Mapper.js +21 -0
  225. package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
  226. package/lib/module/reanimated2/js-reanimated/WebSensor.js +2 -0
  227. package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -0
  228. package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
  229. package/lib/module/reanimated2/js-reanimated/global.js +0 -2
  230. package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
  231. package/lib/module/reanimated2/js-reanimated/index.js +0 -1
  232. package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
  233. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +9 -1
  234. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  235. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js +1 -0
  236. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  237. package/lib/module/reanimated2/layoutReanimation/animationsManager.js +20 -8
  238. package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  239. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -21
  240. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  241. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -12
  242. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  243. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
  244. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  245. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -13
  246. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  247. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -21
  248. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  249. package/lib/module/reanimated2/layoutReanimation/index.js +1 -0
  250. package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
  251. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +82 -0
  252. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
  253. package/lib/module/reanimated2/mappers.js +16 -6
  254. package/lib/module/reanimated2/mappers.js.map +1 -1
  255. package/lib/module/reanimated2/mock.js +20 -1
  256. package/lib/module/reanimated2/mock.js.map +1 -1
  257. package/lib/module/reanimated2/mutables.js +4 -2
  258. package/lib/module/reanimated2/mutables.js.map +1 -1
  259. package/lib/module/reanimated2/platform-specific/checkVersion.js +35 -0
  260. package/lib/module/reanimated2/platform-specific/checkVersion.js.map +1 -0
  261. package/lib/module/reanimated2/platform-specific/checkVersion.web.js +8 -0
  262. package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
  263. package/lib/module/reanimated2/pluginUtils.js +4 -0
  264. package/lib/module/reanimated2/pluginUtils.js.map +1 -0
  265. package/lib/module/reanimated2/shareables.js +36 -12
  266. package/lib/module/reanimated2/shareables.js.map +1 -1
  267. package/lib/module/reanimated2/threads.js +105 -7
  268. package/lib/module/reanimated2/threads.js.map +1 -1
  269. package/lib/module/reanimated2/utils.js +5 -0
  270. package/lib/module/reanimated2/utils.js.map +1 -1
  271. package/lib/module/reanimated2/valueSetter.js +1 -2
  272. package/lib/module/reanimated2/valueSetter.js.map +1 -1
  273. package/mock.js +1 -211
  274. package/package.json +10 -10
  275. package/{plugin.js → plugin/index.js} +128 -249
  276. package/react-native-reanimated.d.ts +55 -417
  277. package/scripts/reanimated_utils.rb +15 -2
  278. package/src/createAnimatedComponent.tsx +247 -28
  279. package/src/reanimated2/Colors.ts +38 -11
  280. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +52 -39
  281. package/src/reanimated2/animation/styleAnimation.ts +8 -1
  282. package/src/reanimated2/animation/util.ts +29 -16
  283. package/src/reanimated2/commonTypes.ts +28 -1
  284. package/src/reanimated2/core.ts +42 -9
  285. package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +2 -2
  286. package/src/reanimated2/globals.d.ts +12 -15
  287. package/src/reanimated2/hook/index.ts +1 -1
  288. package/src/reanimated2/hook/useAnimatedKeyboard.ts +10 -4
  289. package/src/reanimated2/hook/useAnimatedReaction.ts +12 -5
  290. package/src/reanimated2/hook/useAnimatedRef.ts +1 -4
  291. package/src/reanimated2/hook/useAnimatedSensor.ts +90 -11
  292. package/src/reanimated2/hook/useAnimatedStyle.ts +44 -36
  293. package/src/reanimated2/hook/useDerivedValue.ts +8 -1
  294. package/src/reanimated2/hook/useScrollViewOffset.ts +2 -2
  295. package/src/reanimated2/hook/utils.ts +15 -61
  296. package/src/reanimated2/index.ts +1 -0
  297. package/src/reanimated2/initializers.ts +76 -35
  298. package/src/reanimated2/interpolateColor.ts +104 -20
  299. package/src/reanimated2/jestUtils.ts +1 -1
  300. package/src/reanimated2/js-reanimated/JSReanimated.ts +98 -15
  301. package/src/reanimated2/js-reanimated/Mapper.ts +32 -0
  302. package/src/reanimated2/js-reanimated/WebSensor.ts +34 -0
  303. package/src/reanimated2/js-reanimated/commonTypes.ts +0 -1
  304. package/src/reanimated2/js-reanimated/global.ts +0 -1
  305. package/src/reanimated2/js-reanimated/index.ts +0 -1
  306. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +13 -1
  307. package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
  308. package/src/reanimated2/layoutReanimation/animationsManager.ts +20 -9
  309. package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +16 -19
  310. package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +14 -11
  311. package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +21 -11
  312. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -11
  313. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +36 -19
  314. package/src/reanimated2/layoutReanimation/index.ts +1 -0
  315. package/src/reanimated2/layoutReanimation/sharedTransitions/index.ts +87 -0
  316. package/src/reanimated2/mappers.ts +17 -6
  317. package/src/reanimated2/mock.ts +25 -2
  318. package/src/reanimated2/mutables.ts +2 -0
  319. package/src/reanimated2/platform-specific/checkVersion.ts +39 -0
  320. package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
  321. package/src/reanimated2/pluginUtils.ts +8 -0
  322. package/src/reanimated2/shareables.ts +45 -16
  323. package/src/reanimated2/threads.ts +103 -4
  324. package/src/reanimated2/utils.ts +6 -0
  325. package/src/reanimated2/valueSetter.ts +1 -2
  326. package/lib/commonjs/reanimated2/time.js +0 -55
  327. package/lib/commonjs/reanimated2/time.js.map +0 -1
  328. package/lib/module/reanimated2/time.js +0 -37
  329. package/lib/module/reanimated2/time.js.map +0 -1
  330. package/src/reanimated2/time.ts +0 -30
  331. /package/android/src/{main/java → reactNativeVersionPatch/ReanimatedUIManager/70}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -0
@@ -10,6 +10,8 @@ import {
10
10
  configureLayoutAnimations,
11
11
  enableLayoutAnimations,
12
12
  runOnUI,
13
+ startMapper,
14
+ stopMapper,
13
15
  } from './reanimated2/core';
14
16
  import {
15
17
  isJest,
@@ -19,9 +21,11 @@ import {
19
21
  import { initialUpdaterRun } from './reanimated2/animation';
20
22
  import {
21
23
  BaseAnimationBuilder,
24
+ DefaultSharedTransition,
22
25
  EntryExitAnimationFunction,
23
26
  ILayoutAnimationBuilder,
24
27
  LayoutAnimationFunction,
28
+ LayoutAnimationType,
25
29
  } from './reanimated2/layoutReanimation';
26
30
  import {
27
31
  SharedValue,
@@ -29,11 +33,14 @@ import {
29
33
  ShadowNodeWrapper,
30
34
  } from './reanimated2/commonTypes';
31
35
  import {
36
+ makeViewDescriptorsSet,
32
37
  ViewDescriptorsSet,
33
38
  ViewRefSet,
34
39
  } from './reanimated2/ViewDescriptorsSet';
35
40
  import { getShadowNodeWrapperFromRef } from './reanimated2/fabricUtils';
36
- import { makeShareableShadowNodeWrapper } from './reanimated2/shareables';
41
+ import updateProps from './reanimated2/UpdateProps';
42
+ import NativeReanimatedModule from './reanimated2/NativeReanimated';
43
+ import { isSharedValue } from './reanimated2';
37
44
 
38
45
  function dummyListener() {
39
46
  // empty listener we use to assign to listener properties for which animated
@@ -108,6 +115,87 @@ const has = <K extends string>(
108
115
  return false;
109
116
  };
110
117
 
118
+ function isInlineStyleTransform(transform: any): boolean {
119
+ if (!transform) {
120
+ return false;
121
+ }
122
+ return transform.some((t: Record<string, any>) => hasInlineStyles(t));
123
+ }
124
+
125
+ function hasInlineStyles(style: StyleProps): boolean {
126
+ if (!style) {
127
+ return false;
128
+ }
129
+ return Object.keys(style).some((key) => {
130
+ const styleValue = style[key];
131
+ return (
132
+ isSharedValue(styleValue) ||
133
+ (key === 'transform' && isInlineStyleTransform(styleValue))
134
+ );
135
+ });
136
+ }
137
+
138
+ function extractSharedValuesMapFromProps(
139
+ props: AnimatedComponentProps<InitialComponentProps>
140
+ ): Record<string, any> {
141
+ const inlineProps: Record<string, any> = {};
142
+
143
+ for (const key in props) {
144
+ const value = props[key];
145
+ if (key === 'style') {
146
+ const styles = flattenArray<StyleProps>(props.style ?? []);
147
+ styles.forEach((style) => {
148
+ if (!style) {
149
+ return;
150
+ }
151
+ for (const [key, styleValue] of Object.entries(style)) {
152
+ if (isSharedValue(styleValue)) {
153
+ inlineProps[key] = styleValue;
154
+ } else if (
155
+ key === 'transform' &&
156
+ isInlineStyleTransform(styleValue)
157
+ ) {
158
+ inlineProps[key] = styleValue;
159
+ }
160
+ }
161
+ });
162
+ } else if (isSharedValue(value)) {
163
+ inlineProps[key] = value;
164
+ }
165
+ }
166
+
167
+ return inlineProps;
168
+ }
169
+
170
+ function inlinePropsHasChanged(styles1: StyleProps, styles2: StyleProps) {
171
+ if (Object.keys(styles1).length !== Object.keys(styles2).length) {
172
+ return true;
173
+ }
174
+
175
+ for (const key of Object.keys(styles1)) {
176
+ if (styles1[key] !== styles2[key]) return true;
177
+ }
178
+
179
+ return false;
180
+ }
181
+
182
+ function getInlinePropsUpdate(inlineProps: Record<string, any>) {
183
+ 'worklet';
184
+ const update: Record<string, any> = {};
185
+ for (const [key, styleValue] of Object.entries(inlineProps)) {
186
+ if (key === 'transform') {
187
+ update[key] = styleValue.map((transform: Record<string, any>) => {
188
+ return getInlinePropsUpdate(transform);
189
+ });
190
+ } else if (isSharedValue(styleValue)) {
191
+ update[key] = styleValue.value;
192
+ } else {
193
+ update[key] = styleValue;
194
+ }
195
+ }
196
+ return update;
197
+ }
198
+
111
199
  interface AnimatedProps extends Record<string, unknown> {
112
200
  viewDescriptors?: ViewDescriptorsSet;
113
201
  viewsRef?: ViewRefSet<unknown>;
@@ -133,6 +221,8 @@ export type AnimatedComponentProps<P extends Record<string, unknown>> = P & {
133
221
  | typeof BaseAnimationBuilder
134
222
  | EntryExitAnimationFunction
135
223
  | Keyframe;
224
+ sharedTransitionTag?: string;
225
+ sharedTransitionStyle?: ILayoutAnimationBuilder;
136
226
  };
137
227
 
138
228
  type Options<P> = {
@@ -170,6 +260,9 @@ export default function createAnimatedComponent(
170
260
  animatedStyle: { value: StyleProps } = { value: {} };
171
261
  initialStyle = {};
172
262
  _component: ComponentRef | null = null;
263
+ _inlinePropsViewDescriptors: ViewDescriptorsSet | null = null;
264
+ _inlinePropsMapperId: number | null = null;
265
+ _inlineProps: StyleProps = {};
173
266
  static displayName: string;
174
267
 
175
268
  constructor(props: AnimatedComponentProps<InitialComponentProps>) {
@@ -182,15 +275,27 @@ export default function createAnimatedComponent(
182
275
  componentWillUnmount() {
183
276
  this._detachNativeEvents();
184
277
  this._detachStyles();
278
+ this._detachInlineProps();
185
279
  }
186
280
 
187
281
  componentDidMount() {
188
282
  this._attachNativeEvents();
189
283
  this._attachAnimatedStyles();
284
+ this._attachInlineProps();
285
+ }
286
+
287
+ _getEventViewRef() {
288
+ // Make sure to get the scrollable node for components that implement
289
+ // `ScrollResponder.Mixin`.
290
+ return this._component?.getScrollableNode
291
+ ? this._component.getScrollableNode()
292
+ : this._component;
190
293
  }
191
294
 
192
295
  _attachNativeEvents() {
193
- const viewTag = findNodeHandle(this);
296
+ const node = this._getEventViewRef();
297
+ const viewTag = findNodeHandle(options?.setNativeProps ? this : node);
298
+
194
299
  for (const key in this.props) {
195
300
  const prop = this.props[key];
196
301
  if (
@@ -229,10 +334,10 @@ export default function createAnimatedComponent(
229
334
  this.props.animatedProps.viewDescriptors.remove(this._viewTag);
230
335
  }
231
336
  if (global._IS_FABRIC) {
232
- const shadowNodeWrapper = getShadowNodeWrapperFromRef(this);
337
+ const viewTag = this._viewTag;
233
338
  runOnUI(() => {
234
339
  'worklet';
235
- _removeShadowNodeFromRegistry(shadowNodeWrapper);
340
+ _removeShadowNodeFromRegistry(viewTag);
236
341
  })();
237
342
  }
238
343
  }
@@ -289,23 +394,16 @@ export default function createAnimatedComponent(
289
394
  }
290
395
  }
291
396
 
292
- _attachAnimatedStyles() {
293
- const styles = this.props.style
294
- ? onlyAnimatedStyles(flattenArray<StyleProps>(this.props.style))
295
- : [];
296
- const prevStyles = this._styles;
297
- this._styles = styles;
298
-
299
- const prevAnimatedProps = this._animatedProps;
300
- this._animatedProps = this.props.animatedProps;
301
-
397
+ _getViewInfo() {
302
398
  let viewTag: number | null;
303
399
  let viewName: string | null;
304
400
  let shadowNodeWrapper: ShadowNodeWrapper | null = null;
401
+ let viewConfig;
305
402
  if (Platform.OS === 'web') {
306
403
  viewTag = findNodeHandle(this);
307
404
  viewName = null;
308
405
  shadowNodeWrapper = null;
406
+ viewConfig = null;
309
407
  } else {
310
408
  // hostInstance can be null for a component that doesn't render anything (render function returns null). Example: svg Stop: https://github.com/react-native-svg/react-native-svg/blob/develop/src/elements/Stop.tsx
311
409
  const hostInstance = RNRenderer.findHostInstance_DEPRECATED(this);
@@ -321,19 +419,36 @@ export default function createAnimatedComponent(
321
419
  * The name we're looking for is in the field named uiViewClassName.
322
420
  */
323
421
  viewName = hostInstance?.viewConfig?.uiViewClassName;
324
- // update UI props whitelist for this view
325
- const hasReanimated2Props =
326
- this.props.animatedProps?.viewDescriptors || styles.length;
327
- if (hasReanimated2Props && hostInstance?.viewConfig) {
328
- adaptViewConfig(hostInstance.viewConfig);
329
- }
422
+
423
+ viewConfig = hostInstance?.viewConfig;
330
424
 
331
425
  if (global._IS_FABRIC) {
332
- shadowNodeWrapper = makeShareableShadowNodeWrapper(
333
- getShadowNodeWrapperFromRef(this)
334
- );
426
+ shadowNodeWrapper = getShadowNodeWrapperFromRef(this);
335
427
  }
336
428
  }
429
+ return { viewTag, viewName, shadowNodeWrapper, viewConfig };
430
+ }
431
+
432
+ _attachAnimatedStyles() {
433
+ const styles = this.props.style
434
+ ? onlyAnimatedStyles(flattenArray<StyleProps>(this.props.style))
435
+ : [];
436
+ const prevStyles = this._styles;
437
+ this._styles = styles;
438
+
439
+ const prevAnimatedProps = this._animatedProps;
440
+ this._animatedProps = this.props.animatedProps;
441
+
442
+ const { viewTag, viewName, shadowNodeWrapper, viewConfig } =
443
+ this._getViewInfo();
444
+
445
+ // update UI props whitelist for this view
446
+ const hasReanimated2Props =
447
+ this.props.animatedProps?.viewDescriptors || styles.length;
448
+ if (hasReanimated2Props && viewConfig) {
449
+ adaptViewConfig(viewConfig);
450
+ }
451
+
337
452
  this._viewTag = viewTag as number;
338
453
 
339
454
  // remove old styles
@@ -399,11 +514,72 @@ export default function createAnimatedComponent(
399
514
  }
400
515
  }
401
516
 
517
+ _attachInlineProps() {
518
+ const newInlineProps: Record<string, any> =
519
+ extractSharedValuesMapFromProps(this.props);
520
+ const hasChanged = inlinePropsHasChanged(
521
+ newInlineProps,
522
+ this._inlineProps
523
+ );
524
+
525
+ if (hasChanged) {
526
+ if (!this._inlinePropsViewDescriptors) {
527
+ this._inlinePropsViewDescriptors = makeViewDescriptorsSet();
528
+
529
+ const { viewTag, viewName, shadowNodeWrapper, viewConfig } =
530
+ this._getViewInfo();
531
+
532
+ if (Object.keys(newInlineProps).length && viewConfig) {
533
+ adaptViewConfig(viewConfig);
534
+ }
535
+
536
+ this._inlinePropsViewDescriptors.add({
537
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
538
+ tag: viewTag!,
539
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
540
+ name: viewName!,
541
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
542
+ shadowNodeWrapper: shadowNodeWrapper!,
543
+ });
544
+ }
545
+ const sharableViewDescriptors =
546
+ this._inlinePropsViewDescriptors.sharableViewDescriptors;
547
+
548
+ const maybeViewRef = NativeReanimatedModule.native
549
+ ? undefined
550
+ : ({ items: new Set([this]) } as ViewRefSet<any>); // see makeViewsRefSet
551
+
552
+ const updaterFunction = () => {
553
+ 'worklet';
554
+ const update = getInlinePropsUpdate(newInlineProps);
555
+ updateProps(sharableViewDescriptors, update, maybeViewRef);
556
+ };
557
+ this._inlineProps = newInlineProps;
558
+ if (this._inlinePropsMapperId) {
559
+ stopMapper(this._inlinePropsMapperId);
560
+ }
561
+ this._inlinePropsMapperId = null;
562
+ if (Object.keys(newInlineProps).length) {
563
+ this._inlinePropsMapperId = startMapper(
564
+ updaterFunction,
565
+ Object.values(newInlineProps)
566
+ );
567
+ }
568
+ }
569
+ }
570
+
571
+ _detachInlineProps() {
572
+ if (this._inlinePropsMapperId) {
573
+ stopMapper(this._inlinePropsMapperId);
574
+ }
575
+ }
576
+
402
577
  componentDidUpdate(
403
578
  prevProps: AnimatedComponentProps<InitialComponentProps>
404
579
  ) {
405
580
  this._reattachNativeEvents(prevProps);
406
581
  this._attachAnimatedStyles();
582
+ this._attachInlineProps();
407
583
  }
408
584
 
409
585
  _setComponentRef = setAndForwardRef<Component>({
@@ -414,19 +590,44 @@ export default function createAnimatedComponent(
414
590
  setLocalRef: (ref) => {
415
591
  // TODO update config
416
592
  const tag = findNodeHandle(ref);
417
- const { layout, entering, exiting } = this.props;
418
- if ((layout || entering || exiting) && tag != null) {
593
+ const { layout, entering, exiting, sharedTransitionTag } = this.props;
594
+ if (
595
+ (layout || entering || exiting || sharedTransitionTag) &&
596
+ tag != null
597
+ ) {
419
598
  if (!shouldBeUseWeb()) {
420
599
  enableLayoutAnimations(true, false);
421
600
  }
422
601
  if (layout) {
423
- configureLayoutAnimations(tag, 'layout', maybeBuild(layout));
602
+ configureLayoutAnimations(
603
+ tag,
604
+ LayoutAnimationType.LAYOUT,
605
+ maybeBuild(layout)
606
+ );
424
607
  }
425
608
  if (entering) {
426
- configureLayoutAnimations(tag, 'entering', maybeBuild(entering));
609
+ configureLayoutAnimations(
610
+ tag,
611
+ LayoutAnimationType.ENTERING,
612
+ maybeBuild(entering)
613
+ );
427
614
  }
428
615
  if (exiting) {
429
- configureLayoutAnimations(tag, 'exiting', maybeBuild(exiting));
616
+ configureLayoutAnimations(
617
+ tag,
618
+ LayoutAnimationType.EXITING,
619
+ maybeBuild(exiting)
620
+ );
621
+ }
622
+ if (sharedTransitionTag) {
623
+ const sharedElementTransition =
624
+ this.props.sharedTransitionStyle ?? DefaultSharedTransition;
625
+ configureLayoutAnimations(
626
+ tag,
627
+ LayoutAnimationType.SHARED_ELEMENT_TRANSITION,
628
+ maybeBuild(sharedElementTransition),
629
+ sharedTransitionTag
630
+ );
430
631
  }
431
632
  }
432
633
 
@@ -456,6 +657,20 @@ export default function createAnimatedComponent(
456
657
  };
457
658
  }
458
659
  return this.initialStyle;
660
+ } else if (hasInlineStyles(style)) {
661
+ if (this._isFirstRender) {
662
+ return getInlinePropsUpdate(style);
663
+ }
664
+ const newStyle: StyleProps = {};
665
+ for (const [key, styleValue] of Object.entries(style)) {
666
+ if (
667
+ !isSharedValue(styleValue) &&
668
+ !(key === 'transform' && isInlineStyleTransform(styleValue))
669
+ ) {
670
+ newStyle[key] = styleValue;
671
+ }
672
+ }
673
+ return newStyle;
459
674
  } else {
460
675
  return style;
461
676
  }
@@ -486,6 +701,10 @@ export default function createAnimatedComponent(
486
701
  } else {
487
702
  props[key] = dummyListener;
488
703
  }
704
+ } else if (isSharedValue(value)) {
705
+ if (this._isFirstRender) {
706
+ props[key] = (value as SharedValue<any>).value;
707
+ }
489
708
  } else if (
490
709
  key !== 'onGestureHandlerStateChange' ||
491
710
  !isChromeDebugger()
@@ -573,11 +573,12 @@ function HSVtoRGB(h: any, s?: any, v?: any) {
573
573
  export const hsvToColor = (
574
574
  h: number,
575
575
  s: number,
576
- v: number
576
+ v: number,
577
+ a: number
577
578
  ): number | string => {
578
579
  'worklet';
579
580
  const { r, g, b } = HSVtoRGB(h, s, v);
580
- return rgbaColor(r, g, b);
581
+ return rgbaColor(r, g, b, a);
581
582
  };
582
583
 
583
584
  export function processColorInitially(
@@ -634,19 +635,45 @@ export function processColor(color: unknown): number | null | undefined {
634
635
 
635
636
  export type ParsedColorArray = [number, number, number, number];
636
637
 
637
- export function convertToHSVA(color: unknown): ParsedColorArray {
638
+ export function convertToRGBA(color: unknown): ParsedColorArray {
638
639
  'worklet';
639
640
  const processedColor = processColorInitially(color)!; // argb;
640
641
  const a = (processedColor >>> 24) / 255;
641
- const r = (processedColor << 8) >>> 24;
642
- const g = (processedColor << 16) >>> 24;
643
- const b = (processedColor << 24) >>> 24;
644
- const { h, s, v } = RGBtoHSV(r, g, b);
645
- return [h, s, v, a];
642
+ const r = ((processedColor << 8) >>> 24) / 255;
643
+ const g = ((processedColor << 16) >>> 24) / 255;
644
+ const b = ((processedColor << 24) >>> 24) / 255;
645
+ return [r, g, b, a];
646
646
  }
647
647
 
648
- export function toRGBA(HSVA: ParsedColorArray): string {
648
+ export function rgbaArrayToRGBAColor(RGBA: ParsedColorArray): string {
649
649
  'worklet';
650
- const { r, g, b } = HSVtoRGB(HSVA[0], HSVA[1], HSVA[2]);
651
- return `rgba(${r}, ${g}, ${b}, ${HSVA[3]})`;
650
+ return `rgba(${Math.round(RGBA[0] * 255)}, ${Math.round(
651
+ RGBA[1] * 255
652
+ )}, ${Math.round(RGBA[2] * 255)}, ${RGBA[3]})`;
653
+ }
654
+
655
+ export function toLinearSpace(
656
+ RGBA: ParsedColorArray,
657
+ gamma = 2.2
658
+ ): ParsedColorArray {
659
+ 'worklet';
660
+ const res = [];
661
+ for (let i = 0; i < 3; ++i) {
662
+ res.push(Math.pow(RGBA[i], gamma));
663
+ }
664
+ res.push(RGBA[3]);
665
+ return res as ParsedColorArray;
666
+ }
667
+
668
+ export function toGammaSpace(
669
+ RGBA: ParsedColorArray,
670
+ gamma = 2.2
671
+ ): ParsedColorArray {
672
+ 'worklet';
673
+ const res = [];
674
+ for (let i = 0; i < 3; ++i) {
675
+ res.push(Math.pow(RGBA[i], 1 / gamma));
676
+ }
677
+ res.push(RGBA[3]);
678
+ return res as ParsedColorArray;
652
679
  }
@@ -1,7 +1,15 @@
1
1
  import { NativeModules } from 'react-native';
2
- import { ShareableRef, ShareableSyncDataHolderRef } from '../commonTypes';
3
- import { LayoutAnimationFunction } from '../layoutReanimation';
4
- import { version as jsVersion } from '../../../package.json';
2
+ import {
3
+ ShareableRef,
4
+ ShareableSyncDataHolderRef,
5
+ Value3D,
6
+ ValueRotation,
7
+ } from '../commonTypes';
8
+ import {
9
+ LayoutAnimationFunction,
10
+ LayoutAnimationType,
11
+ } from '../layoutReanimation';
12
+ import { checkVersion } from '../platform-specific/checkVersion';
5
13
 
6
14
  export class NativeReanimated {
7
15
  native: boolean;
@@ -15,38 +23,19 @@ export class NativeReanimated {
15
23
  this.InnerNativeModule = global.__reanimatedModuleProxy;
16
24
  this.native = native;
17
25
  if (native) {
18
- this.checkVersion();
19
- }
20
- }
21
-
22
- checkVersion(): void {
23
- const cppVersion = global._REANIMATED_VERSION_CPP;
24
- const ok = (() => {
25
- if (
26
- jsVersion.match(/^\d+\.\d+\.\d+$/) &&
27
- cppVersion.match(/^\d+\.\d+\.\d+$/)
28
- ) {
29
- // x.y.z, compare only major and minor, skip patch
30
- const [jsMajor, jsMinor] = jsVersion.split('.');
31
- const [cppMajor, cppMinor] = cppVersion.split('.');
32
- return jsMajor === cppMajor && jsMinor === cppMinor;
33
- } else {
34
- // alpha, beta or rc, compare everything
35
- return jsVersion === cppVersion;
26
+ if (this.InnerNativeModule === undefined) {
27
+ console.error(
28
+ `[Reanimated] The native part of Reanimated doesn't seem to be initialized. This could be caused by\n\
29
+ - not rebuilding the app after installing or upgrading Reanimated\n\
30
+ - trying to run Reanimated on an unsupported platform\n\
31
+ - running in a brownfield app without manually initializing the native library`
32
+ );
33
+ return;
36
34
  }
37
- })();
38
- if (!ok) {
39
- console.error(
40
- `[Reanimated] Mismatch between JavaScript part and native part of Reanimated (${jsVersion} vs. ${cppVersion}). Did you forget to re-build the app after upgrading react-native-reanimated? If you use Expo Go, you must downgrade to ${cppVersion} which is bundled into Expo SDK.`
41
- );
42
- // TODO: detect Expo managed workflow
35
+ checkVersion();
43
36
  }
44
37
  }
45
38
 
46
- getTimestamp(): number {
47
- throw new Error('stub implementation, used on the web only');
48
- }
49
-
50
39
  installCoreFunctions(
51
40
  callGuard: <T extends Array<any>, U>(
52
41
  fn: (...args: T) => U,
@@ -60,8 +49,14 @@ export class NativeReanimated {
60
49
  );
61
50
  }
62
51
 
63
- makeShareableClone<T>(value: T): ShareableRef<T> {
64
- return this.InnerNativeModule.makeShareableClone(value);
52
+ makeShareableClone<T>(
53
+ value: T,
54
+ shouldPersistRemote: boolean
55
+ ): ShareableRef<T> {
56
+ return this.InnerNativeModule.makeShareableClone(
57
+ value,
58
+ shouldPersistRemote
59
+ );
65
60
  }
66
61
 
67
62
  makeSynchronizedDataHolder<T>(
@@ -88,9 +83,15 @@ export class NativeReanimated {
88
83
  registerSensor<T>(
89
84
  sensorType: number,
90
85
  interval: number,
91
- handler: ShareableRef<T>
86
+ iosReferenceFrame: number,
87
+ handler: ShareableRef<T> | ((data: Value3D | ValueRotation) => void)
92
88
  ) {
93
- return this.InnerNativeModule.registerSensor(sensorType, interval, handler);
89
+ return this.InnerNativeModule.registerSensor(
90
+ sensorType,
91
+ interval,
92
+ iosReferenceFrame,
93
+ handler
94
+ );
94
95
  }
95
96
 
96
97
  unregisterSensor(sensorId: number) {
@@ -118,10 +119,16 @@ export class NativeReanimated {
118
119
 
119
120
  configureLayoutAnimation(
120
121
  viewTag: number,
121
- type: string,
122
+ type: LayoutAnimationType,
123
+ sharedTransitionTag: string,
122
124
  config: ShareableRef<Keyframe | LayoutAnimationFunction>
123
125
  ) {
124
- this.InnerNativeModule.configureLayoutAnimation(viewTag, type, config);
126
+ this.InnerNativeModule.configureLayoutAnimation(
127
+ viewTag,
128
+ type,
129
+ sharedTransitionTag,
130
+ config
131
+ );
125
132
  }
126
133
 
127
134
  enableLayoutAnimations(flag: boolean): void {
@@ -132,8 +139,14 @@ export class NativeReanimated {
132
139
  this.InnerNativeModule.configureProps(uiProps, nativeProps);
133
140
  }
134
141
 
135
- subscribeForKeyboardEvents(handler: ShareableRef<number>): number {
136
- return this.InnerNativeModule.subscribeForKeyboardEvents(handler);
142
+ subscribeForKeyboardEvents(
143
+ handler: ShareableRef<number>,
144
+ isStatusBarTranslucent: boolean
145
+ ): number {
146
+ return this.InnerNativeModule.subscribeForKeyboardEvents(
147
+ handler,
148
+ isStatusBarTranslucent
149
+ );
137
150
  }
138
151
 
139
152
  unsubscribeFromKeyboardEvents(listenerId: number): void {
@@ -46,7 +46,7 @@ export function setPath<T>(
46
46
  for (let i = 0; i < keys.length - 1; i++) {
47
47
  // creates entry if there isn't one
48
48
  currObj = currObj as { [key: string]: NestedObjectValues<T> };
49
- if (!currObj[keys[i]]) {
49
+ if (!(keys[i] in currObj)) {
50
50
  // if next key is a number create an array
51
51
  if (typeof keys[i + 1] === 'number') {
52
52
  currObj[keys[i]] = [];
@@ -178,6 +178,13 @@ export function withStyleAnimation(
178
178
  if (prevAnimation && !prevVal) {
179
179
  prevVal = prevAnimation.current;
180
180
  }
181
+ if (prevVal === undefined) {
182
+ console.warn(
183
+ `Initial values for animation are missing for property ${currentEntry.path.join(
184
+ '.'
185
+ )}`
186
+ );
187
+ }
181
188
  setPath(animation.current, currentEntry.path, prevVal);
182
189
  let currentAnimation: AnimationObject;
183
190
  if (