react-native-reanimated 3.0.2 → 3.1.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 (473) hide show
  1. package/Common/cpp/Fabric/FabricUtils.h +1 -1
  2. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +38 -27
  3. package/Common/cpp/SharedItems/Shareables.h +22 -0
  4. package/Common/cpp/Tools/PlatformDepMethodsHolder.h +2 -0
  5. package/Common/cpp/Tools/RuntimeDecorator.cpp +4 -1
  6. package/Common/cpp/Tools/RuntimeDecorator.h +2 -1
  7. package/Common/cpp/Tools/SingleInstanceChecker.h +14 -2
  8. package/RNReanimated.podspec +5 -2
  9. package/android/CMakeLists.txt +4 -0
  10. package/android/build.gradle +18 -10
  11. package/android/src/main/cpp/NativeProxy.cpp +316 -337
  12. package/android/src/main/cpp/NativeProxy.h +53 -11
  13. package/android/src/main/java/com/swmansion/reanimated/NativeMethodsHelper.java +7 -12
  14. package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +11 -8
  15. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +21 -14
  16. package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +0 -3
  17. package/ios/Fabric/REAInitializerRCTFabricSurface.mm +1 -0
  18. package/ios/REANodesManager.h +1 -0
  19. package/ios/REANodesManager.mm +30 -4
  20. package/ios/keyboardObserver/REAKeyboardEventObserver.m +51 -130
  21. package/ios/native/NativeMethods.mm +1 -1
  22. package/ios/native/NativeProxy.mm +4 -1
  23. package/ios/native/REAIOSErrorHandler.mm +1 -1
  24. package/ios/native/REAIOSLogger.mm +1 -1
  25. package/ios/native/REAIOSScheduler.mm +1 -1
  26. package/ios/native/REAInitializer.mm +1 -1
  27. package/ios/native/REAMessageThread.mm +2 -2
  28. package/lib/commonjs/Animated.js +0 -8
  29. package/lib/commonjs/Animated.js.map +1 -1
  30. package/lib/commonjs/ConfigHelper.js +8 -19
  31. package/lib/commonjs/ConfigHelper.js.map +1 -1
  32. package/lib/commonjs/createAnimatedComponent.js +20 -158
  33. package/lib/commonjs/createAnimatedComponent.js.map +1 -1
  34. package/lib/commonjs/index.js +0 -9
  35. package/lib/commonjs/index.js.map +1 -1
  36. package/lib/commonjs/index.web.js +0 -7
  37. package/lib/commonjs/index.web.js.map +1 -1
  38. package/lib/commonjs/reanimated2/Bezier.js +14 -34
  39. package/lib/commonjs/reanimated2/Bezier.js.map +1 -1
  40. package/lib/commonjs/reanimated2/Colors.js +60 -132
  41. package/lib/commonjs/reanimated2/Colors.js.map +1 -1
  42. package/lib/commonjs/reanimated2/Easing.js +81 -34
  43. package/lib/commonjs/reanimated2/Easing.js.map +1 -1
  44. package/lib/commonjs/reanimated2/NativeMethods.js +8 -20
  45. package/lib/commonjs/reanimated2/NativeMethods.js.map +1 -1
  46. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +5 -31
  47. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  48. package/lib/commonjs/reanimated2/NativeReanimated/index.js +0 -7
  49. package/lib/commonjs/reanimated2/NativeReanimated/index.js.map +1 -1
  50. package/lib/commonjs/reanimated2/PlatformChecker.js +0 -6
  51. package/lib/commonjs/reanimated2/PlatformChecker.js.map +1 -1
  52. package/lib/commonjs/reanimated2/PropAdapters.js +10 -12
  53. package/lib/commonjs/reanimated2/PropAdapters.js.map +1 -1
  54. package/lib/commonjs/reanimated2/UpdateProps.js +3 -12
  55. package/lib/commonjs/reanimated2/UpdateProps.js.map +1 -1
  56. package/lib/commonjs/reanimated2/ViewDescriptorsSet.js +0 -10
  57. package/lib/commonjs/reanimated2/ViewDescriptorsSet.js.map +1 -1
  58. package/lib/commonjs/reanimated2/WorkletEventHandler.js +5 -22
  59. package/lib/commonjs/reanimated2/WorkletEventHandler.js.map +1 -1
  60. package/lib/commonjs/reanimated2/animation/decay.js +7 -18
  61. package/lib/commonjs/reanimated2/animation/decay.js.map +1 -1
  62. package/lib/commonjs/reanimated2/animation/delay.js +0 -11
  63. package/lib/commonjs/reanimated2/animation/delay.js.map +1 -1
  64. package/lib/commonjs/reanimated2/animation/index.js +0 -8
  65. package/lib/commonjs/reanimated2/animation/index.js.map +1 -1
  66. package/lib/commonjs/reanimated2/animation/repeat.js +6 -22
  67. package/lib/commonjs/reanimated2/animation/repeat.js.map +1 -1
  68. package/lib/commonjs/reanimated2/animation/sequence.js +3 -20
  69. package/lib/commonjs/reanimated2/animation/sequence.js.map +1 -1
  70. package/lib/commonjs/reanimated2/animation/spring.js +11 -23
  71. package/lib/commonjs/reanimated2/animation/spring.js.map +1 -1
  72. package/lib/commonjs/reanimated2/animation/styleAnimation.js +3 -35
  73. package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
  74. package/lib/commonjs/reanimated2/animation/timing.js +0 -11
  75. package/lib/commonjs/reanimated2/animation/timing.js.map +1 -1
  76. package/lib/commonjs/reanimated2/animation/util.js +11 -41
  77. package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
  78. package/lib/commonjs/reanimated2/commonTypes.js +16 -23
  79. package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
  80. package/lib/commonjs/reanimated2/component/FlatList.js +0 -16
  81. package/lib/commonjs/reanimated2/component/FlatList.js.map +1 -1
  82. package/lib/commonjs/reanimated2/component/Image.js +0 -4
  83. package/lib/commonjs/reanimated2/component/Image.js.map +1 -1
  84. package/lib/commonjs/reanimated2/component/ScrollView.js +0 -4
  85. package/lib/commonjs/reanimated2/component/ScrollView.js.map +1 -1
  86. package/lib/commonjs/reanimated2/component/Text.js +0 -4
  87. package/lib/commonjs/reanimated2/component/Text.js.map +1 -1
  88. package/lib/commonjs/reanimated2/component/View.js +0 -4
  89. package/lib/commonjs/reanimated2/component/View.js.map +1 -1
  90. package/lib/commonjs/reanimated2/core.js +6 -48
  91. package/lib/commonjs/reanimated2/core.js.map +1 -1
  92. package/lib/commonjs/reanimated2/errors.js +3 -14
  93. package/lib/commonjs/reanimated2/errors.js.map +1 -1
  94. package/lib/commonjs/reanimated2/fabricUtils.js +3 -5
  95. package/lib/commonjs/reanimated2/fabricUtils.js.map +1 -1
  96. package/lib/commonjs/reanimated2/fabricUtils.web.js +1 -3
  97. package/lib/commonjs/reanimated2/fabricUtils.web.js.map +1 -1
  98. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryJS.js +3 -12
  99. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryJS.js.map +1 -1
  100. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +13 -17
  101. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  102. package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
  103. package/lib/commonjs/reanimated2/hook/Hooks.js +0 -5
  104. package/lib/commonjs/reanimated2/hook/Hooks.js.map +1 -1
  105. package/lib/commonjs/reanimated2/hook/commonTypes.js.map +1 -1
  106. package/lib/commonjs/reanimated2/hook/index.js +0 -12
  107. package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
  108. package/lib/commonjs/reanimated2/hook/useAnimatedGestureHandler.js +4 -17
  109. package/lib/commonjs/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
  110. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +2 -9
  111. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  112. package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +1 -11
  113. package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  114. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +0 -12
  115. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
  116. package/lib/commonjs/reanimated2/hook/useAnimatedScrollHandler.js +2 -9
  117. package/lib/commonjs/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
  118. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +8 -23
  119. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  120. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +13 -71
  121. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  122. package/lib/commonjs/reanimated2/hook/useDerivedValue.js +4 -13
  123. package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
  124. package/lib/commonjs/reanimated2/hook/useFrameCallback.js +0 -5
  125. package/lib/commonjs/reanimated2/hook/useFrameCallback.js.map +1 -1
  126. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +0 -7
  127. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  128. package/lib/commonjs/reanimated2/hook/useSharedValue.js +2 -7
  129. package/lib/commonjs/reanimated2/hook/useSharedValue.js.map +1 -1
  130. package/lib/commonjs/reanimated2/hook/utils.js +8 -39
  131. package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
  132. package/lib/commonjs/reanimated2/index.js +0 -26
  133. package/lib/commonjs/reanimated2/index.js.map +1 -1
  134. package/lib/commonjs/reanimated2/initializers.js +21 -43
  135. package/lib/commonjs/reanimated2/initializers.js.map +1 -1
  136. package/lib/commonjs/reanimated2/interpolateColor.js +6 -43
  137. package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
  138. package/lib/commonjs/reanimated2/interpolation.js +14 -29
  139. package/lib/commonjs/reanimated2/interpolation.js.map +1 -1
  140. package/lib/commonjs/reanimated2/jestUtils.js +11 -44
  141. package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
  142. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +15 -39
  143. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  144. package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +9 -28
  145. package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
  146. package/lib/commonjs/reanimated2/js-reanimated/MapperRegistry.js +7 -37
  147. package/lib/commonjs/reanimated2/js-reanimated/MapperRegistry.js.map +1 -1
  148. package/lib/commonjs/reanimated2/js-reanimated/MutableValue.js +5 -18
  149. package/lib/commonjs/reanimated2/js-reanimated/MutableValue.js.map +1 -1
  150. package/lib/commonjs/reanimated2/js-reanimated/global.js +2 -9
  151. package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
  152. package/lib/commonjs/reanimated2/js-reanimated/index.js +3 -14
  153. package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
  154. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +7 -26
  155. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
  156. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +3 -49
  157. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
  158. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +7 -43
  159. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
  160. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +4 -5
  161. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  162. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +0 -4
  163. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  164. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +4 -23
  165. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  166. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +3 -74
  167. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  168. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Fade.js +3 -53
  169. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
  170. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Flip.js +3 -63
  171. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
  172. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +7 -26
  173. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  174. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +3 -13
  175. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
  176. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +3 -23
  177. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  178. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +3 -43
  179. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
  180. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +3 -43
  181. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  182. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +3 -23
  183. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
  184. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +3 -83
  185. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  186. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/index.js +0 -20
  187. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/index.js.map +1 -1
  188. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +3 -22
  189. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
  190. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +5 -29
  191. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
  192. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +3 -9
  193. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
  194. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +5 -11
  195. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
  196. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +3 -8
  197. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
  198. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +3 -12
  199. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
  200. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/index.js +0 -12
  201. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/index.js.map +1 -1
  202. package/lib/commonjs/reanimated2/layoutReanimation/index.js +0 -9
  203. package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
  204. package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +3 -17
  205. package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -1
  206. package/lib/commonjs/reanimated2/mappers.js +26 -32
  207. package/lib/commonjs/reanimated2/mappers.js.map +1 -1
  208. package/lib/commonjs/reanimated2/mock.js +5 -15
  209. package/lib/commonjs/reanimated2/mock.js.map +1 -1
  210. package/lib/commonjs/reanimated2/mutables.js +2 -28
  211. package/lib/commonjs/reanimated2/mutables.js.map +1 -1
  212. package/lib/commonjs/reanimated2/platform-specific/RNRenderer.js +0 -2
  213. package/lib/commonjs/reanimated2/platform-specific/RNRenderer.js.map +1 -1
  214. package/lib/commonjs/reanimated2/platform-specific/RNRenderer.web.js.map +1 -1
  215. package/lib/commonjs/reanimated2/platform-specific/checkCppVersion.js +31 -0
  216. package/lib/commonjs/reanimated2/platform-specific/checkCppVersion.js.map +1 -0
  217. package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +0 -2
  218. package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -1
  219. package/lib/commonjs/reanimated2/platform-specific/jsVersion.js +14 -0
  220. package/lib/commonjs/reanimated2/platform-specific/jsVersion.js.map +1 -0
  221. package/lib/commonjs/reanimated2/pluginUtils.js +0 -1
  222. package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -1
  223. package/lib/commonjs/reanimated2/shareables.js +92 -49
  224. package/lib/commonjs/reanimated2/shareables.js.map +1 -1
  225. package/lib/commonjs/reanimated2/threads.js +42 -46
  226. package/lib/commonjs/reanimated2/threads.js.map +1 -1
  227. package/lib/commonjs/reanimated2/utils.js +0 -5
  228. package/lib/commonjs/reanimated2/utils.js.map +1 -1
  229. package/lib/commonjs/reanimated2/valueSetter.js +6 -21
  230. package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
  231. package/lib/commonjs/setAndForwardRef.js +3 -3
  232. package/lib/commonjs/setAndForwardRef.js.map +1 -1
  233. package/lib/module/Animated.js.map +1 -1
  234. package/lib/module/ConfigHelper.js +9 -15
  235. package/lib/module/ConfigHelper.js.map +1 -1
  236. package/lib/module/createAnimatedComponent.js +20 -139
  237. package/lib/module/createAnimatedComponent.js.map +1 -1
  238. package/lib/module/index.js +0 -2
  239. package/lib/module/index.js.map +1 -1
  240. package/lib/module/index.web.js.map +1 -1
  241. package/lib/module/reanimated2/Bezier.js +14 -33
  242. package/lib/module/reanimated2/Bezier.js.map +1 -1
  243. package/lib/module/reanimated2/Colors.js +59 -109
  244. package/lib/module/reanimated2/Colors.js.map +1 -1
  245. package/lib/module/reanimated2/Easing.js +37 -33
  246. package/lib/module/reanimated2/Easing.js.map +1 -1
  247. package/lib/module/reanimated2/NativeMethods.js +8 -15
  248. package/lib/module/reanimated2/NativeMethods.js.map +1 -1
  249. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +5 -27
  250. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  251. package/lib/module/reanimated2/NativeReanimated/index.js +0 -2
  252. package/lib/module/reanimated2/NativeReanimated/index.js.map +1 -1
  253. package/lib/module/reanimated2/PlatformChecker.js.map +1 -1
  254. package/lib/module/reanimated2/PropAdapters.js +12 -10
  255. package/lib/module/reanimated2/PropAdapters.js.map +1 -1
  256. package/lib/module/reanimated2/UpdateProps.js +3 -5
  257. package/lib/module/reanimated2/UpdateProps.js.map +1 -1
  258. package/lib/module/reanimated2/ViewDescriptorsSet.js +0 -6
  259. package/lib/module/reanimated2/ViewDescriptorsSet.js.map +1 -1
  260. package/lib/module/reanimated2/WorkletEventHandler.js +5 -18
  261. package/lib/module/reanimated2/WorkletEventHandler.js.map +1 -1
  262. package/lib/module/reanimated2/animation/decay.js +7 -15
  263. package/lib/module/reanimated2/animation/decay.js.map +1 -1
  264. package/lib/module/reanimated2/animation/delay.js +0 -9
  265. package/lib/module/reanimated2/animation/delay.js.map +1 -1
  266. package/lib/module/reanimated2/animation/index.js.map +1 -1
  267. package/lib/module/reanimated2/animation/repeat.js +6 -20
  268. package/lib/module/reanimated2/animation/repeat.js.map +1 -1
  269. package/lib/module/reanimated2/animation/sequence.js +3 -18
  270. package/lib/module/reanimated2/animation/sequence.js.map +1 -1
  271. package/lib/module/reanimated2/animation/spring.js +11 -21
  272. package/lib/module/reanimated2/animation/spring.js.map +1 -1
  273. package/lib/module/reanimated2/animation/styleAnimation.js +7 -31
  274. package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
  275. package/lib/module/reanimated2/animation/timing.js +0 -8
  276. package/lib/module/reanimated2/animation/timing.js.map +1 -1
  277. package/lib/module/reanimated2/animation/util.js +10 -33
  278. package/lib/module/reanimated2/animation/util.js.map +1 -1
  279. package/lib/module/reanimated2/commonTypes.js +12 -19
  280. package/lib/module/reanimated2/commonTypes.js.map +1 -1
  281. package/lib/module/reanimated2/component/FlatList.js +0 -4
  282. package/lib/module/reanimated2/component/FlatList.js.map +1 -1
  283. package/lib/module/reanimated2/component/Image.js.map +1 -1
  284. package/lib/module/reanimated2/component/ScrollView.js.map +1 -1
  285. package/lib/module/reanimated2/component/Text.js.map +1 -1
  286. package/lib/module/reanimated2/component/View.js.map +1 -1
  287. package/lib/module/reanimated2/core.js +6 -22
  288. package/lib/module/reanimated2/core.js.map +1 -1
  289. package/lib/module/reanimated2/errors.js +3 -13
  290. package/lib/module/reanimated2/errors.js.map +1 -1
  291. package/lib/module/reanimated2/fabricUtils.js +3 -3
  292. package/lib/module/reanimated2/fabricUtils.js.map +1 -1
  293. package/lib/module/reanimated2/fabricUtils.web.js +1 -1
  294. package/lib/module/reanimated2/fabricUtils.web.js.map +1 -1
  295. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js +3 -8
  296. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js.map +1 -1
  297. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +13 -15
  298. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  299. package/lib/module/reanimated2/globals.d.js.map +1 -1
  300. package/lib/module/reanimated2/hook/Hooks.js +3 -2
  301. package/lib/module/reanimated2/hook/Hooks.js.map +1 -1
  302. package/lib/module/reanimated2/hook/commonTypes.js.map +1 -1
  303. package/lib/module/reanimated2/hook/index.js.map +1 -1
  304. package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js +3 -14
  305. package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
  306. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +2 -5
  307. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  308. package/lib/module/reanimated2/hook/useAnimatedReaction.js +1 -7
  309. package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  310. package/lib/module/reanimated2/hook/useAnimatedRef.js +0 -6
  311. package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
  312. package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js +2 -7
  313. package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
  314. package/lib/module/reanimated2/hook/useAnimatedSensor.js +9 -20
  315. package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  316. package/lib/module/reanimated2/hook/useAnimatedStyle.js +13 -59
  317. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  318. package/lib/module/reanimated2/hook/useDerivedValue.js +4 -8
  319. package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
  320. package/lib/module/reanimated2/hook/useFrameCallback.js.map +1 -1
  321. package/lib/module/reanimated2/hook/useScrollViewOffset.js +0 -1
  322. package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  323. package/lib/module/reanimated2/hook/useSharedValue.js +2 -3
  324. package/lib/module/reanimated2/hook/useSharedValue.js.map +1 -1
  325. package/lib/module/reanimated2/hook/utils.js +8 -21
  326. package/lib/module/reanimated2/hook/utils.js.map +1 -1
  327. package/lib/module/reanimated2/index.js.map +1 -1
  328. package/lib/module/reanimated2/initializers.js +23 -37
  329. package/lib/module/reanimated2/initializers.js.map +1 -1
  330. package/lib/module/reanimated2/interpolateColor.js +5 -34
  331. package/lib/module/reanimated2/interpolateColor.js.map +1 -1
  332. package/lib/module/reanimated2/interpolation.js +13 -28
  333. package/lib/module/reanimated2/interpolation.js.map +1 -1
  334. package/lib/module/reanimated2/jestUtils.js +11 -35
  335. package/lib/module/reanimated2/jestUtils.js.map +1 -1
  336. package/lib/module/reanimated2/js-reanimated/JSReanimated.js +15 -35
  337. package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  338. package/lib/module/reanimated2/js-reanimated/Mapper.js +9 -23
  339. package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
  340. package/lib/module/reanimated2/js-reanimated/MapperRegistry.js +7 -35
  341. package/lib/module/reanimated2/js-reanimated/MapperRegistry.js.map +1 -1
  342. package/lib/module/reanimated2/js-reanimated/MutableValue.js +5 -16
  343. package/lib/module/reanimated2/js-reanimated/MutableValue.js.map +1 -1
  344. package/lib/module/reanimated2/js-reanimated/global.js +2 -6
  345. package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
  346. package/lib/module/reanimated2/js-reanimated/index.js +3 -9
  347. package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
  348. package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +7 -23
  349. package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
  350. package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +3 -45
  351. package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
  352. package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +7 -39
  353. package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
  354. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +3 -3
  355. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  356. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  357. package/lib/module/reanimated2/layoutReanimation/animationsManager.js +4 -19
  358. package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  359. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +3 -52
  360. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  361. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js +3 -32
  362. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
  363. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js +3 -38
  364. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
  365. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +7 -16
  366. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  367. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +3 -8
  368. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
  369. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +3 -14
  370. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  371. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +3 -26
  372. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
  373. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +3 -26
  374. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  375. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +3 -14
  376. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
  377. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +3 -50
  378. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  379. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/index.js.map +1 -1
  380. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +3 -17
  381. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
  382. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +5 -23
  383. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
  384. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +3 -5
  385. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
  386. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +5 -6
  387. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
  388. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +3 -5
  389. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
  390. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +3 -8
  391. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
  392. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/index.js.map +1 -1
  393. package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
  394. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +3 -13
  395. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -1
  396. package/lib/module/reanimated2/mappers.js +26 -25
  397. package/lib/module/reanimated2/mappers.js.map +1 -1
  398. package/lib/module/reanimated2/mock.js +5 -15
  399. package/lib/module/reanimated2/mock.js.map +1 -1
  400. package/lib/module/reanimated2/mutables.js +2 -19
  401. package/lib/module/reanimated2/mutables.js.map +1 -1
  402. package/lib/module/reanimated2/platform-specific/RNRenderer.js.map +1 -1
  403. package/lib/module/reanimated2/platform-specific/RNRenderer.web.js.map +1 -1
  404. package/lib/module/reanimated2/platform-specific/checkCppVersion.js +24 -0
  405. package/lib/module/reanimated2/platform-specific/checkCppVersion.js.map +1 -0
  406. package/lib/module/reanimated2/platform-specific/checkVersion.web.js +0 -1
  407. package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -1
  408. package/lib/module/reanimated2/platform-specific/jsVersion.js +7 -0
  409. package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -0
  410. package/lib/module/reanimated2/pluginUtils.js.map +1 -1
  411. package/lib/module/reanimated2/shareables.js +96 -44
  412. package/lib/module/reanimated2/shareables.js.map +1 -1
  413. package/lib/module/reanimated2/threads.js +39 -33
  414. package/lib/module/reanimated2/threads.js.map +1 -1
  415. package/lib/module/reanimated2/utils.js +0 -3
  416. package/lib/module/reanimated2/utils.js.map +1 -1
  417. package/lib/module/reanimated2/valueSetter.js +6 -19
  418. package/lib/module/reanimated2/valueSetter.js.map +1 -1
  419. package/lib/module/setAndForwardRef.js +3 -2
  420. package/lib/module/setAndForwardRef.js.map +1 -1
  421. package/package.json +46 -40
  422. package/plugin/.eslintrc.js +7 -0
  423. package/plugin/README.md +241 -0
  424. package/plugin/build/plugin.js +714 -0
  425. package/plugin/build/plugin.js.map +7 -0
  426. package/plugin/index.js +1 -807
  427. package/plugin/package.json +23 -0
  428. package/plugin/src/buildWorkletString.ts +213 -0
  429. package/plugin/src/commonObjects.ts +60 -0
  430. package/plugin/src/injectVersion.ts +37 -0
  431. package/plugin/src/makeWorklet.ts +375 -0
  432. package/plugin/src/plugin.ts +49 -0
  433. package/plugin/src/processForCalleesWorklets.ts +106 -0
  434. package/plugin/src/processIfGestureHandlerEventCallbackFunctionNode.ts +156 -0
  435. package/plugin/src/processIfWorkletFunction.ts +55 -0
  436. package/plugin/src/processIfWorkletNode.ts +44 -0
  437. package/plugin/src/processInlineStylesWarning.ts +129 -0
  438. package/plugin/src/processWorkletObjectMethod.ts +31 -0
  439. package/plugin/src/types.ts +15 -0
  440. package/plugin/src/utils.ts +6 -0
  441. package/plugin/tsconfig.json +15 -0
  442. package/plugin/yarn.lock +2193 -0
  443. package/react-native-reanimated.d.ts +1 -0
  444. package/scripts/reanimated_utils.rb +2 -2
  445. package/src/createAnimatedComponent.tsx +2 -3
  446. package/src/reanimated2/Easing.ts +19 -0
  447. package/src/reanimated2/NativeMethods.ts +9 -4
  448. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +2 -2
  449. package/src/reanimated2/UpdateProps.ts +2 -2
  450. package/src/reanimated2/animation/decay.ts +7 -1
  451. package/src/reanimated2/animation/styleAnimation.ts +5 -1
  452. package/src/reanimated2/core.ts +4 -4
  453. package/src/reanimated2/errors.ts +1 -0
  454. package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +12 -4
  455. package/src/reanimated2/globals.d.ts +71 -112
  456. package/src/reanimated2/hook/commonTypes.ts +1 -1
  457. package/src/reanimated2/hook/useAnimatedReaction.ts +2 -2
  458. package/src/reanimated2/hook/useAnimatedSensor.ts +2 -2
  459. package/src/reanimated2/initializers.ts +11 -8
  460. package/src/reanimated2/jestUtils.ts +0 -1
  461. package/src/reanimated2/js-reanimated/JSReanimated.ts +5 -1
  462. package/src/reanimated2/js-reanimated/index.ts +1 -1
  463. package/src/reanimated2/mappers.ts +26 -4
  464. package/src/reanimated2/mock.ts +1 -0
  465. package/src/reanimated2/platform-specific/checkCppVersion.ts +29 -0
  466. package/src/reanimated2/platform-specific/jsVersion.ts +6 -0
  467. package/src/reanimated2/shareables.ts +107 -8
  468. package/src/reanimated2/threads.ts +36 -17
  469. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +0 -42
  470. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +0 -1
  471. package/lib/module/reanimated2/platform-specific/checkVersion.js +0 -35
  472. package/lib/module/reanimated2/platform-specific/checkVersion.js.map +0 -1
  473. package/src/reanimated2/platform-specific/checkVersion.ts +0 -39
@@ -166,8 +166,8 @@ class NativeProxy : public jni::HybridClass<NativeProxy> {
166
166
  jni::global_ref<NativeProxy::javaobject> javaPart_;
167
167
  jsi::Runtime *runtime_;
168
168
  std::shared_ptr<facebook::react::CallInvoker> jsCallInvoker_;
169
- std::shared_ptr<NativeReanimatedModule> _nativeReanimatedModule;
170
- jni::global_ref<LayoutAnimations::javaobject> layoutAnimations;
169
+ std::shared_ptr<NativeReanimatedModule> nativeReanimatedModule_;
170
+ jni::global_ref<LayoutAnimations::javaobject> layoutAnimations_;
171
171
  std::shared_ptr<Scheduler> scheduler_;
172
172
  #ifdef RCT_NEW_ARCH_ENABLED
173
173
  std::shared_ptr<NewestShadowNodesRegistry> newestShadowNodesRegistry_;
@@ -188,22 +188,25 @@ class NativeProxy : public jni::HybridClass<NativeProxy> {
188
188
  void installJSIBindings(
189
189
  jni::alias_ref<JavaMessageQueueThread::javaobject> messageQueueThread);
190
190
  #endif
191
+ PlatformDepMethodsHolder getPlatformDependentMethods();
192
+ void setGlobalProperties(
193
+ jsi::Runtime &jsRuntime,
194
+ const std::shared_ptr<jsi::Runtime> &reanimatedRuntime);
195
+ void setupLayoutAnimations();
196
+
197
+ double getCurrentTime();
191
198
  bool isAnyHandlerWaitingForEvent(std::string);
192
199
  void performOperations();
193
- void requestRender(std::function<void(double)> onRender);
194
- void registerEventHandler(std::function<void(
195
- jni::alias_ref<JString>,
196
- jni::alias_ref<react::WritableMap>)> handler);
200
+ void requestRender(std::function<void(double)> onRender, jsi::Runtime &rt);
201
+ void registerEventHandler();
202
+ void maybeFlushUIUpdatesQueue();
197
203
  void setGestureState(int handlerTag, int newState);
198
204
  int registerSensor(
199
205
  int sensorType,
200
206
  int interval,
207
+ int iosReferenceFrame,
201
208
  std::function<void(double[], int)> setter);
202
209
  void unregisterSensor(int sensorId);
203
- void configureProps(
204
- jsi::Runtime &rt,
205
- const jsi::Value &uiProps,
206
- const jsi::Value &nativeProps);
207
210
  int subscribeForKeyboardEvents(
208
211
  std::function<void(int, int)> keyboardEventDataUpdater,
209
212
  bool isStatusBarTranslucent);
@@ -211,10 +214,49 @@ class NativeProxy : public jni::HybridClass<NativeProxy> {
211
214
  #ifdef RCT_NEW_ARCH_ENABLED
212
215
  // nothing
213
216
  #else
214
- void updateProps(jsi::Runtime &rt, int viewTag, const jsi::Object &props);
217
+ jsi::Value
218
+ obtainProp(jsi::Runtime &rt, const int viewTag, const jsi::String &propName);
219
+ void configureProps(
220
+ jsi::Runtime &rt,
221
+ const jsi::Value &uiProps,
222
+ const jsi::Value &nativeProps);
223
+ void updateProps(
224
+ jsi::Runtime &rt,
225
+ int viewTag,
226
+ const jsi::Value &viewName,
227
+ const jsi::Object &props);
215
228
  void scrollTo(int viewTag, double x, double y, bool animated);
216
229
  std::vector<std::pair<std::string, double>> measure(int viewTag);
217
230
  #endif
231
+ void handleEvent(
232
+ jni::alias_ref<JString> eventKey,
233
+ jni::alias_ref<react::WritableMap> event);
234
+
235
+ void progressLayoutAnimation(
236
+ int tag,
237
+ const jsi::Object &newProps,
238
+ bool isSharedTransition);
239
+
240
+ /***
241
+ * Wraps a method of `NativeProxy` in a function object capturing `this`
242
+ * @tparam TReturn return type of passed method
243
+ * @tparam TParams paramater types of passed method
244
+ * @param methodPtr pointer to method to be wrapped
245
+ * @return a function object with the same signature as the method, calling
246
+ * that method on `this`
247
+ */
248
+ template <class TReturn, class... TParams>
249
+ std::function<TReturn(TParams...)> bindThis(
250
+ TReturn (NativeProxy::*methodPtr)(TParams...)) {
251
+ return [this, methodPtr](TParams &&...args) {
252
+ return (this->*methodPtr)(std::forward<TParams>(args)...);
253
+ };
254
+ }
255
+
256
+ template <class Signature>
257
+ JMethod<Signature> getJniMethod(std::string const &methodName) {
258
+ return javaPart_->getClass()->getMethod<Signature>(methodName.c_str());
259
+ }
218
260
 
219
261
  explicit NativeProxy(
220
262
  jni::alias_ref<NativeProxy::jhybridobject> jThis,
@@ -39,11 +39,9 @@ public class NativeMethodsHelper {
39
39
  public static void scrollTo(View view, double argX, double argY, boolean animated) {
40
40
  int x = Math.round(PixelUtil.toPixelFromDIP(argX));
41
41
  int y = Math.round(PixelUtil.toPixelFromDIP(argY));
42
- boolean horizontal = false;
42
+ boolean isHorizontal = view instanceof ReactHorizontalScrollView;
43
43
 
44
- if (view instanceof ReactHorizontalScrollView) {
45
- horizontal = true;
46
- } else {
44
+ if (!isHorizontal) {
47
45
  if (view instanceof ReactSwipeRefreshLayout) {
48
46
  view = findScrollView((ReactSwipeRefreshLayout) view);
49
47
  }
@@ -56,17 +54,14 @@ public class NativeMethodsHelper {
56
54
  }
57
55
 
58
56
  if (animated) {
59
- if (horizontal) {
60
- ((ReactHorizontalScrollView) view).smoothScrollTo((int) x, (int) y);
57
+ final View finalView = view;
58
+ if (isHorizontal) {
59
+ view.post(() -> ((ReactHorizontalScrollView) finalView).smoothScrollTo(x, y));
61
60
  } else {
62
- ((ReactScrollView) view).smoothScrollTo((int) x, (int) y);
61
+ view.post(() -> ((ReactScrollView) finalView).smoothScrollTo(x, y));
63
62
  }
64
63
  } else {
65
- if (horizontal) {
66
- ((ReactHorizontalScrollView) view).scrollTo((int) x, (int) y);
67
- } else {
68
- ((ReactScrollView) view).scrollTo((int) x, (int) y);
69
- }
64
+ view.scrollTo(x, y);
70
65
  }
71
66
  }
72
67
 
@@ -36,6 +36,7 @@ import java.util.Queue;
36
36
  import java.util.Set;
37
37
  import java.util.concurrent.ConcurrentLinkedQueue;
38
38
  import java.util.concurrent.Semaphore;
39
+ import java.util.concurrent.TimeUnit;
39
40
  import java.util.concurrent.atomic.AtomicBoolean;
40
41
  import javax.annotation.Nullable;
41
42
 
@@ -163,6 +164,10 @@ public class NodesManager implements EventDispatcherListener {
163
164
  }
164
165
  }
165
166
 
167
+ public boolean isAnimationRunning() {
168
+ return mCallbackPosted.get();
169
+ }
170
+
166
171
  public void onHostResume() {
167
172
  if (mCallbackPosted.getAndSet(false)) {
168
173
  startUpdatingOnAnimationFrame();
@@ -183,7 +188,7 @@ public class NodesManager implements EventDispatcherListener {
183
188
  }
184
189
  }
185
190
 
186
- private void performOperations() {
191
+ public void performOperations() {
187
192
  if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
188
193
  mNativeProxy.performOperations();
189
194
  } else if (!mOperationsInBatch.isEmpty()) {
@@ -218,13 +223,11 @@ public class NodesManager implements EventDispatcherListener {
218
223
  }
219
224
  });
220
225
  if (trySynchronously) {
221
- while (true) {
222
- try {
223
- semaphore.acquire();
224
- break;
225
- } catch (InterruptedException e) {
226
- // noop
227
- }
226
+ try {
227
+ semaphore.tryAcquire(16, TimeUnit.MILLISECONDS);
228
+ } catch (InterruptedException e) {
229
+ // if the thread is interruped we just continue and let the layout update happen
230
+ // asynchronously
228
231
  }
229
232
  }
230
233
  }
@@ -88,39 +88,39 @@ public abstract class NativeProxyCommon {
88
88
  }
89
89
 
90
90
  @DoNotStrip
91
- private void requestRender(AnimationFrameCallback callback) {
91
+ public void requestRender(AnimationFrameCallback callback) {
92
92
  mNodesManager.postOnAnimation(callback);
93
93
  }
94
94
 
95
95
  @DoNotStrip
96
- private void updateProps(int viewTag, Map<String, Object> props) {
96
+ public void updateProps(int viewTag, Map<String, Object> props) {
97
97
  mNodesManager.updateProps(viewTag, props);
98
98
  }
99
99
 
100
100
  @DoNotStrip
101
- private void synchronouslyUpdateUIProps(int viewTag, ReadableMap uiProps) {
101
+ public void synchronouslyUpdateUIProps(int viewTag, ReadableMap uiProps) {
102
102
  mNodesManager.synchronouslyUpdateUIProps(viewTag, uiProps);
103
103
  }
104
104
 
105
105
  @DoNotStrip
106
- private String obtainProp(int viewTag, String propName) {
106
+ public String obtainProp(int viewTag, String propName) {
107
107
  return mNodesManager.obtainProp(viewTag, propName);
108
108
  }
109
109
 
110
110
  @DoNotStrip
111
- private void scrollTo(int viewTag, double x, double y, boolean animated) {
111
+ public void scrollTo(int viewTag, double x, double y, boolean animated) {
112
112
  mNodesManager.scrollTo(viewTag, x, y, animated);
113
113
  }
114
114
 
115
115
  @DoNotStrip
116
- private void setGestureState(int handlerTag, int newState) {
116
+ public void setGestureState(int handlerTag, int newState) {
117
117
  if (gestureHandlerStateManager != null) {
118
118
  gestureHandlerStateManager.setGestureHandlerState(handlerTag, newState);
119
119
  }
120
120
  }
121
121
 
122
122
  @DoNotStrip
123
- private long getCurrentTime() {
123
+ public long getCurrentTime() {
124
124
  if (slowAnimationsEnabled) {
125
125
  final long ANIMATIONS_DRAG_FACTOR = 10;
126
126
  return this.firstUptime
@@ -131,12 +131,12 @@ public abstract class NativeProxyCommon {
131
131
  }
132
132
 
133
133
  @DoNotStrip
134
- private float[] measure(int viewTag) {
134
+ public float[] measure(int viewTag) {
135
135
  return mNodesManager.measure(viewTag);
136
136
  }
137
137
 
138
138
  @DoNotStrip
139
- private void configureProps(ReadableNativeArray uiProps, ReadableNativeArray nativeProps) {
139
+ public void configureProps(ReadableNativeArray uiProps, ReadableNativeArray nativeProps) {
140
140
  Set<String> uiPropsSet = convertProps(uiProps);
141
141
  Set<String> nativePropsSet = convertProps(nativeProps);
142
142
  mNodesManager.configureProps(uiPropsSet, nativePropsSet);
@@ -152,31 +152,31 @@ public abstract class NativeProxyCommon {
152
152
  }
153
153
 
154
154
  @DoNotStrip
155
- private void registerEventHandler(EventHandler handler) {
155
+ public void registerEventHandler(EventHandler handler) {
156
156
  handler.mCustomEventNamesResolver = mNodesManager.getEventNameResolver();
157
157
  mNodesManager.registerEventHandler(handler);
158
158
  }
159
159
 
160
160
  @DoNotStrip
161
- private int registerSensor(int sensorType, int interval, SensorSetter setter) {
161
+ public int registerSensor(int sensorType, int interval, SensorSetter setter) {
162
162
  return reanimatedSensorContainer.registerSensor(
163
163
  ReanimatedSensorType.getInstanceById(sensorType), interval, setter);
164
164
  }
165
165
 
166
166
  @DoNotStrip
167
- private void unregisterSensor(int sensorId) {
167
+ public void unregisterSensor(int sensorId) {
168
168
  reanimatedSensorContainer.unregisterSensor(sensorId);
169
169
  }
170
170
 
171
171
  @DoNotStrip
172
- private int subscribeForKeyboardEvents(
172
+ public int subscribeForKeyboardEvents(
173
173
  KeyboardEventDataUpdater keyboardEventDataUpdater, boolean isStatusBarTranslucent) {
174
174
  return reanimatedKeyboardEventListener.subscribeForKeyboardEvents(
175
175
  keyboardEventDataUpdater, isStatusBarTranslucent);
176
176
  }
177
177
 
178
178
  @DoNotStrip
179
- private void unsubscribeFromKeyboardEvents(int listenerId) {
179
+ public void unsubscribeFromKeyboardEvents(int listenerId) {
180
180
  reanimatedKeyboardEventListener.unsubscribeFromKeyboardEvents(listenerId);
181
181
  }
182
182
 
@@ -203,4 +203,11 @@ public abstract class NativeProxyCommon {
203
203
 
204
204
  animationsManager.setNativeMethods(NativeProxy.createNativeMethodsHolder(layoutAnimations));
205
205
  }
206
+
207
+ @DoNotStrip
208
+ void maybeFlushUIUpdatesQueue() {
209
+ if (!mNodesManager.isAnimationRunning()) {
210
+ mNodesManager.performOperations();
211
+ }
212
+ }
206
213
  }
@@ -2,14 +2,11 @@ package com.swmansion.reanimated;
2
2
 
3
3
  import static com.swmansion.reanimated.Utils.simplifyStringNumbersList;
4
4
 
5
- import android.util.Log;
6
-
7
5
  import com.facebook.jni.HybridData;
8
6
  import com.facebook.proguard.annotations.DoNotStrip;
9
7
  import com.facebook.react.bridge.ReactApplicationContext;
10
8
  import com.facebook.react.bridge.queue.MessageQueueThread;
11
9
  import com.facebook.react.turbomodule.core.CallInvokerHolderImpl;
12
- import com.swmansion.reanimated.layoutReanimation.AnimationsManager;
13
10
  import com.swmansion.reanimated.layoutReanimation.LayoutAnimations;
14
11
  import com.swmansion.reanimated.layoutReanimation.NativeMethodsHolder;
15
12
  import com.swmansion.reanimated.nativeProxy.NativeProxyCommon;
@@ -66,6 +66,7 @@
66
66
  {
67
67
  // This method should never be called.
68
68
  react_native_assert(false);
69
+ return nullptr;
69
70
  }
70
71
 
71
72
  @end
@@ -55,5 +55,6 @@ typedef void (^REAPerformOperations)();
55
55
  trySynchronously:(BOOL)trySync;
56
56
  - (NSString *)obtainProp:(nonnull NSNumber *)viewTag propName:(nonnull NSString *)propName;
57
57
  #endif
58
+ - (void)maybeFlushUIUpdatesQueue;
58
59
 
59
60
  @end
@@ -96,6 +96,8 @@ using namespace facebook::react;
96
96
  BOOL _tryRunBatchUpdatesSynchronously;
97
97
  REAEventHandler _eventHandler;
98
98
  volatile void (^_mounting)(void);
99
+ NSObject *_syncLayoutUpdatesWaitLock;
100
+ volatile BOOL _syncLayoutUpdatesWaitTimedOut;
99
101
  NSMutableDictionary<NSNumber *, ComponentUpdate *> *_componentUpdateBuffer;
100
102
  NSMutableDictionary<NSNumber *, UIView *> *_viewRegistry;
101
103
  #ifdef RCT_NEW_ARCH_ENABLED
@@ -123,6 +125,7 @@ using namespace facebook::react;
123
125
  _operationsInBatch = [NSMutableDictionary new];
124
126
  _componentUpdateBuffer = [NSMutableDictionary new];
125
127
  _viewRegistry = [_uiManager valueForKey:@"_viewRegistry"];
128
+ _syncLayoutUpdatesWaitLock = [NSObject new];
126
129
  }
127
130
 
128
131
  _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(onAnimationFrame:)];
@@ -241,8 +244,14 @@ using namespace facebook::react;
241
244
  - (BOOL)uiManager:(RCTUIManager *)manager performMountingWithBlock:(RCTUIManagerMountingBlock)block
242
245
  {
243
246
  RCTAssert(_mounting == nil, @"Mouting block is expected to not be set");
244
- _mounting = block;
245
- return YES;
247
+ @synchronized(_syncLayoutUpdatesWaitLock) {
248
+ if (_syncLayoutUpdatesWaitTimedOut) {
249
+ return NO;
250
+ } else {
251
+ _mounting = block;
252
+ return YES;
253
+ }
254
+ }
246
255
  }
247
256
 
248
257
  - (void)performOperations
@@ -260,6 +269,7 @@ using namespace facebook::react;
260
269
 
261
270
  __weak __typeof__(self) weakSelf = self;
262
271
  dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
272
+ _syncLayoutUpdatesWaitTimedOut = NO;
263
273
  RCTExecuteOnUIManagerQueue(^{
264
274
  __typeof__(self) strongSelf = weakSelf;
265
275
  if (strongSelf == nil) {
@@ -276,7 +286,7 @@ using namespace facebook::react;
276
286
  }
277
287
 
278
288
  if (canUpdateSynchronously) {
279
- [strongSelf.uiManager runSyncUIUpdatesWithObserver:self];
289
+ [strongSelf.uiManager runSyncUIUpdatesWithObserver:strongSelf];
280
290
  dispatch_semaphore_signal(semaphore);
281
291
  }
282
292
  // In case canUpdateSynchronously=true we still have to send uiManagerWillPerformMounting event
@@ -284,7 +294,16 @@ using namespace facebook::react;
284
294
  [strongSelf.uiManager setNeedsLayout];
285
295
  });
286
296
  if (trySynchronously) {
287
- dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
297
+ // The 16ms timeout here aims to match the frame duration. It may make sense to read that parameter
298
+ // from CADisplayLink but it is easier to hardcode it for the time being.
299
+ // The reason why we use frame duration here is that if takes longer than one frame to complete layout tasks
300
+ // there is no point of synchronizing layout with the UI interaction as we get that one frame delay anyways.
301
+ long result = dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, 16 * NSEC_PER_MSEC));
302
+ if (result != 0) {
303
+ @synchronized(_syncLayoutUpdatesWaitLock) {
304
+ _syncLayoutUpdatesWaitTimedOut = YES;
305
+ }
306
+ }
288
307
  }
289
308
 
290
309
  if (_mounting) {
@@ -494,4 +513,11 @@ using namespace facebook::react;
494
513
 
495
514
  #endif // RCT_NEW_ARCH_ENABLED
496
515
 
516
+ - (void)maybeFlushUIUpdatesQueue
517
+ {
518
+ if ([_displayLink isPaused]) {
519
+ [self performOperations];
520
+ }
521
+ }
522
+
497
523
  @end
@@ -12,13 +12,11 @@ typedef NS_ENUM(NSUInteger, KeyboardState) {
12
12
  };
13
13
 
14
14
  @implementation REAKeyboardEventObserver {
15
+ UIView *_measuringView;
15
16
  NSNumber *_nextListenerId;
16
17
  NSMutableDictionary *_listeners;
17
- CADisplayLink *displayLink;
18
- int _windowsCount;
19
- UIView *_keyboardView;
18
+ CADisplayLink *_displayLink;
20
19
  KeyboardState _state;
21
- bool _shouldInvalidateDisplayLink;
22
20
  }
23
21
 
24
22
  - (instancetype)init
@@ -27,52 +25,16 @@ typedef NS_ENUM(NSUInteger, KeyboardState) {
27
25
  _listeners = [[NSMutableDictionary alloc] init];
28
26
  _nextListenerId = @0;
29
27
  _state = UNKNOWN;
30
- _shouldInvalidateDisplayLink = false;
31
28
 
32
29
  NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
33
30
 
34
31
  [notificationCenter addObserver:self
35
- selector:@selector(clearListeners)
32
+ selector:@selector(cleanupListeners)
36
33
  name:RCTBridgeDidInvalidateModulesNotification
37
34
  object:nil];
38
35
  return self;
39
36
  }
40
37
 
41
- // copied from
42
- // https://github.com/tonlabs/UIKit/blob/bd5651e4723d547bde0cb86ca1c27813cedab4a9/casts/keyboard/ios/UIKitKeyboardIosFrameListener.m
43
- - (UIView *)findKeyboardView
44
- {
45
- for (UIWindow *window in [UIApplication.sharedApplication.windows objectEnumerator]) {
46
- if ([window isKindOfClass:NSClassFromString(@"UITextEffectsWindow")]) {
47
- for (UIView *containerView in window.subviews) {
48
- if ([containerView isKindOfClass:NSClassFromString(@"UIInputSetContainerView")]) {
49
- for (UIView *hostView in containerView.subviews) {
50
- if ([hostView isKindOfClass:NSClassFromString(@"UIInputSetHostView")]) {
51
- return hostView;
52
- }
53
- }
54
- }
55
- }
56
- }
57
- }
58
- return nil;
59
- }
60
-
61
- - (UIView *)getKeyboardView
62
- {
63
- /**
64
- * If the count of windows has changed it means there might be a new UITextEffectsWindow,
65
- * thus we have to obtain a new `keyboardView`
66
- */
67
- int windowsCount = [UIApplication.sharedApplication.windows count];
68
-
69
- if (_keyboardView == nil || windowsCount != _windowsCount) {
70
- _keyboardView = [self findKeyboardView];
71
- _windowsCount = windowsCount;
72
- }
73
- return _keyboardView;
74
- }
75
-
76
38
  #if TARGET_OS_TV
77
39
  - (int)subscribeForKeyboardEvents:(KeyboardEventListenerBlock)listener
78
40
  {
@@ -86,72 +48,61 @@ typedef NS_ENUM(NSUInteger, KeyboardState) {
86
48
  }
87
49
  #else
88
50
 
89
- - (void)runAnimation
51
+ - (void)runUpdater
90
52
  {
91
- if (!displayLink) {
92
- displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(updateKeyboardFrame)];
93
- [displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
53
+ if (!_displayLink) {
54
+ _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(updateKeyboardFrame)];
55
+ _displayLink.preferredFramesPerSecond = 120; // will fallback to 60 fps for devices without Pro Motion display
56
+ [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
94
57
  }
95
- }
96
-
97
- - (void)stopAnimation
98
- {
58
+ _displayLink.paused = NO;
99
59
  [self updateKeyboardFrame];
100
- // there might be a case that keyboard will change height in the next frame
101
- // (for example changing keyboard language so that suggestions appear)
102
- // so we invalidate display link after we handle that in the next frame
103
- _shouldInvalidateDisplayLink = true;
104
60
  }
105
61
 
106
62
  - (void)updateKeyboardFrame
107
63
  {
108
- UIView *keyboardView = [self getKeyboardView];
109
- if (keyboardView == nil) {
110
- return;
64
+ BOOL isAnimatingKeyboardChange = _measuringView.layer.presentationLayer.animationKeys.count != 0;
65
+ CGRect measuringFrame =
66
+ isAnimatingKeyboardChange ? _measuringView.layer.presentationLayer.frame : _measuringView.frame;
67
+ CGFloat keyboardHeight = measuringFrame.size.height;
68
+
69
+ if (!isAnimatingKeyboardChange) {
70
+ // measuring view is no longer running an animation, we should settle in OPEN/CLOSE state
71
+ if (_state == OPENING || _state == CLOSING) {
72
+ _state = _state == OPENING ? OPEN : CLOSED;
73
+ }
74
+ // stop display link updates if no animation is running
75
+ _displayLink.paused = YES;
111
76
  }
112
77
 
113
- CGFloat keyboardHeight = [self computeKeyboardHeight:keyboardView];
114
78
  for (NSString *key in _listeners.allKeys) {
115
79
  ((KeyboardEventListenerBlock)_listeners[key])(_state, keyboardHeight);
116
80
  }
117
-
118
- if (_shouldInvalidateDisplayLink) {
119
- _shouldInvalidateDisplayLink = false;
120
- [displayLink invalidate];
121
- displayLink = nil;
122
- }
123
81
  }
124
82
 
125
- - (CGFloat)computeKeyboardHeight:(UIView *)keyboardView
83
+ - (void)keyboardWillChangeFrame:(NSNotification *)notification
126
84
  {
127
- CGFloat keyboardFrameY = [keyboardView.layer presentationLayer].frame.origin.y;
128
- CGFloat keyboardWindowH = keyboardView.window.bounds.size.height;
129
- CGFloat keyboardHeight = keyboardWindowH - keyboardFrameY;
130
- return keyboardHeight;
131
- }
85
+ NSDictionary *userInfo = [notification userInfo];
86
+ CGRect beginFrame = [[userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue];
87
+ CGRect endFrame = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
88
+ NSTimeInterval animationDuration = [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
89
+ CGSize windowSize = [[[UIApplication sharedApplication] delegate] window].frame.size;
132
90
 
133
- - (void)keyboardWillShow:(NSNotification *)notification
134
- {
135
- _state = OPENING;
136
- [self runAnimation];
137
- }
138
-
139
- - (void)keyboardDidShow:(NSNotification *)notification
140
- {
141
- _state = OPEN;
142
- [self stopAnimation];
143
- }
91
+ CGFloat beginHeight = windowSize.height - beginFrame.origin.y;
92
+ CGFloat endHeight = windowSize.height - endFrame.origin.y;
144
93
 
145
- - (void)keyboardWillHide:(NSNotification *)notification
146
- {
147
- _state = CLOSING;
148
- [self runAnimation];
149
- }
94
+ if (endHeight > 0 && _state != OPEN) {
95
+ _state = OPENING;
96
+ } else if (endHeight == 0 && _state != CLOSED) {
97
+ _state = CLOSING;
98
+ }
150
99
 
151
- - (void)keyboardDidHide:(NSNotification *)notification
152
- {
153
- _state = CLOSED;
154
- [self stopAnimation];
100
+ _measuringView.frame = CGRectMake(0, -1, 0, beginHeight);
101
+ [UIView animateWithDuration:animationDuration
102
+ animations:^{
103
+ self->_measuringView.frame = CGRectMake(0, -1, 0, endHeight);
104
+ }];
105
+ [self runUpdater];
155
106
  }
156
107
 
157
108
  - (int)subscribeForKeyboardEvents:(KeyboardEventListenerBlock)listener
@@ -159,34 +110,21 @@ typedef NS_ENUM(NSUInteger, KeyboardState) {
159
110
  NSNumber *listenerId = [_nextListenerId copy];
160
111
  _nextListenerId = [NSNumber numberWithInt:[_nextListenerId intValue] + 1];
161
112
  RCTExecuteOnMainQueue(^() {
113
+ if (!self->_measuringView) {
114
+ self->_measuringView = [[UIView alloc] initWithFrame:CGRectMake(0, -1, 0, 0)];
115
+ UIWindow *keyWindow = [[[UIApplication sharedApplication] delegate] window];
116
+ [keyWindow addSubview:self->_measuringView];
117
+ }
162
118
  if ([self->_listeners count] == 0) {
163
119
  NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
164
120
 
165
121
  [notificationCenter addObserver:self
166
- selector:@selector(keyboardWillHide:)
167
- name:UIKeyboardWillHideNotification
168
- object:nil];
169
-
170
- [notificationCenter addObserver:self
171
- selector:@selector(keyboardWillShow:)
172
- name:UIKeyboardWillShowNotification
173
- object:nil];
174
-
175
- [notificationCenter addObserver:self
176
- selector:@selector(keyboardDidHide:)
177
- name:UIKeyboardDidHideNotification
178
- object:nil];
179
-
180
- [notificationCenter addObserver:self
181
- selector:@selector(keyboardDidShow:)
182
- name:UIKeyboardDidShowNotification
122
+ selector:@selector(keyboardWillChangeFrame:)
123
+ name:UIKeyboardWillChangeFrameNotification
183
124
  object:nil];
184
125
  }
185
126
 
186
127
  [self->_listeners setObject:listener forKey:listenerId];
187
- if (self->_state == UNKNOWN) {
188
- [self recognizeInitialKeyboardState];
189
- }
190
128
  });
191
129
  return [listenerId intValue];
192
130
  }
@@ -197,34 +135,17 @@ typedef NS_ENUM(NSUInteger, KeyboardState) {
197
135
  NSNumber *_listenerId = [NSNumber numberWithInt:listenerId];
198
136
  [self->_listeners removeObjectForKey:_listenerId];
199
137
  if ([self->_listeners count] == 0) {
200
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
201
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
202
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardDidHideNotification object:nil];
203
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardDidShowNotification object:nil];
204
- }
205
- });
206
- }
207
-
208
- - (void)recognizeInitialKeyboardState
209
- {
210
- RCTExecuteOnMainQueue(^() {
211
- UIView *keyboardView = [self getKeyboardView];
212
- if (keyboardView == nil) {
213
- self->_state = CLOSED;
214
- } else {
215
- CGFloat keyboardHeight = [self computeKeyboardHeight:keyboardView];
216
- self->_state = keyboardHeight == 0 ? CLOSED : OPEN;
138
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillChangeFrameNotification object:nil];
217
139
  }
218
- [self updateKeyboardFrame];
219
140
  });
220
141
  }
221
142
 
222
- - (void)clearListeners
143
+ - (void)cleanupListeners
223
144
  {
224
145
  RCTUnsafeExecuteOnMainQueueSync(^() {
225
146
  [self->_listeners removeAllObjects];
226
- [self->displayLink invalidate];
227
- self->displayLink = nil;
147
+ [self->_displayLink invalidate];
148
+ self->_displayLink = nil;
228
149
  [[NSNotificationCenter defaultCenter] removeObserver:self];
229
150
  });
230
151
  }
@@ -51,4 +51,4 @@ void setGestureState(id<RNGestureHandlerStateManager> gestureHandlerStateManager
51
51
  }
52
52
  }
53
53
 
54
- }
54
+ } // namespace reanimated