react-native-reanimated 2.9.1 → 2.11.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 (257) hide show
  1. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +7 -4
  2. package/Common/cpp/{headers/AnimatedSensor → AnimatedSensor}/AnimatedSensorModule.h +0 -0
  3. package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp +2 -0
  4. package/Common/cpp/{headers/LayoutAnimations → LayoutAnimations}/LayoutAnimationsProxy.h +0 -0
  5. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +40 -0
  6. package/Common/cpp/{headers/NativeModules → NativeModules}/NativeReanimatedModule.h +13 -0
  7. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +25 -0
  8. package/Common/cpp/{headers/NativeModules → NativeModules}/NativeReanimatedModuleSpec.h +9 -1
  9. package/Common/cpp/{headers/Registries → Registries}/EventHandlerRegistry.h +0 -0
  10. package/Common/cpp/Registries/MapperRegistry.cpp +3 -1
  11. package/Common/cpp/{headers/Registries → Registries}/MapperRegistry.h +0 -0
  12. package/Common/cpp/Registries/WorkletsCache.cpp +3 -0
  13. package/Common/cpp/{headers/Registries → Registries}/WorkletsCache.h +0 -0
  14. package/Common/cpp/{headers/SharedItems → SharedItems}/FrozenObject.h +0 -0
  15. package/Common/cpp/{headers/SharedItems → SharedItems}/HostFunctionHandler.h +0 -0
  16. package/Common/cpp/SharedItems/MutableValue.cpp +2 -0
  17. package/Common/cpp/{headers/SharedItems → SharedItems}/MutableValue.h +0 -0
  18. package/Common/cpp/{headers/SharedItems → SharedItems}/MutableValueSetterProxy.h +0 -0
  19. package/Common/cpp/{headers/SharedItems → SharedItems}/RemoteObject.h +0 -0
  20. package/Common/cpp/{headers/SharedItems → SharedItems}/RuntimeManager.h +0 -0
  21. package/Common/cpp/SharedItems/ShareableValue.cpp +7 -2
  22. package/Common/cpp/{headers/SharedItems → SharedItems}/ShareableValue.h +0 -0
  23. package/Common/cpp/{headers/SharedItems → SharedItems}/SharedParent.h +0 -0
  24. package/Common/cpp/{headers/SharedItems → SharedItems}/ValueWrapper.h +0 -0
  25. package/Common/cpp/{headers/SpecTools → SpecTools}/ErrorHandler.h +0 -0
  26. package/Common/cpp/{headers/Tools → Tools}/FeaturesConfig.h +0 -0
  27. package/Common/cpp/Tools/JSIStoreValueUser.cpp +2 -2
  28. package/Common/cpp/{headers/Tools → Tools}/JSIStoreValueUser.h +0 -0
  29. package/Common/cpp/{headers/Tools → Tools}/Mapper.h +0 -0
  30. package/Common/cpp/{headers/Tools → Tools}/PlatformDepMethodsHolder.h +5 -0
  31. package/Common/cpp/{headers/Tools → Tools}/ReanimatedHiddenHeaders.h +1 -1
  32. package/Common/cpp/{headers/Tools → Tools}/RuntimeDecorator.h +0 -0
  33. package/Common/cpp/{headers/Tools → Tools}/Scheduler.h +0 -0
  34. package/Common/cpp/Tools/SingleInstanceChecker.h +58 -0
  35. package/Common/cpp/{headers/Tools → Tools}/WorkletEventHandler.h +0 -0
  36. package/RNReanimated.podspec +18 -58
  37. package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
  38. package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
  39. package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
  40. package/android/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  41. package/android/.gradle/{7.2 → 7.5.1}/dependencies-accessors/gc.properties +0 -0
  42. package/android/.gradle/7.5.1/executionHistory/executionHistory.bin +0 -0
  43. package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
  44. package/android/.gradle/{7.2 → 7.5.1}/fileChanges/last-build.bin +0 -0
  45. package/android/.gradle/7.5.1/fileHashes/fileHashes.bin +0 -0
  46. package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
  47. package/android/.gradle/{7.2 → 7.5.1}/fileHashes/resourceHashesCache.bin +0 -0
  48. package/android/.gradle/{7.2 → 7.5.1}/gc.properties +0 -0
  49. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  50. package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
  51. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  52. package/android/.gradle/file-system.probe +0 -0
  53. package/android/CMakeLists.txt +223 -113
  54. package/android/build.gradle +480 -195
  55. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  56. package/android/react-native-reanimated-66-hermes.aar +0 -0
  57. package/android/react-native-reanimated-66-jsc.aar +0 -0
  58. package/android/react-native-reanimated-67-hermes.aar +0 -0
  59. package/android/react-native-reanimated-67-jsc.aar +0 -0
  60. package/android/react-native-reanimated-68-hermes.aar +0 -0
  61. package/android/react-native-reanimated-68-jsc.aar +0 -0
  62. package/android/react-native-reanimated-69-hermes.aar +0 -0
  63. package/android/react-native-reanimated-69-jsc.aar +0 -0
  64. package/android/react-native-reanimated-70-hermes.aar +0 -0
  65. package/android/react-native-reanimated-70-jsc.aar +0 -0
  66. package/{lib/types/lib/reanimated2/platform-specific/RNRenderer.web.d.ts → android/rnVersionPatch/70/.gitkeep} +0 -0
  67. package/android/src/main/cpp/AndroidErrorHandler.cpp +3 -4
  68. package/android/src/main/cpp/{headers/AndroidErrorHandler.h → AndroidErrorHandler.h} +1 -4
  69. package/android/src/main/cpp/AndroidLogger.cpp +4 -1
  70. package/android/src/main/cpp/{headers/AndroidLogger.h → AndroidLogger.h} +0 -0
  71. package/android/src/main/cpp/{headers/AndroidScheduler.h → AndroidScheduler.h} +0 -0
  72. package/android/src/main/cpp/{headers/JNIHelper.h → JNIHelper.h} +0 -0
  73. package/android/src/main/cpp/{headers/LayoutAnimations.h → LayoutAnimations.h} +0 -0
  74. package/android/src/main/cpp/NativeProxy.cpp +60 -28
  75. package/android/src/main/cpp/{headers/NativeProxy.h → NativeProxy.h} +29 -0
  76. package/android/src/main/cpp/OnLoad.cpp +1 -0
  77. package/android/src/main/cpp/{headers/TurboModule.h → TurboModule.h} +0 -0
  78. package/android/src/main/java/com/swmansion/reanimated/NativeProxy.java +29 -5
  79. package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +3 -1
  80. package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +166 -0
  81. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +19 -16
  82. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +5 -1
  83. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorType.java +1 -1
  84. package/ios/{REAModule.m → REAModule.mm} +12 -0
  85. package/ios/REANodesManager.m +31 -8
  86. package/ios/keyboardObserver/REAKeyboardEventObserver.h +17 -0
  87. package/ios/keyboardObserver/REAKeyboardEventObserver.m +198 -0
  88. package/ios/native/NativeProxy.mm +24 -3
  89. package/ios/native/REAInitializer.h +2 -2
  90. package/ios/native/REAInitializer.mm +10 -14
  91. package/ios/native/UIResponder+Reanimated.mm +1 -1
  92. package/ios/sensor/ReanimatedSensor.m +26 -17
  93. package/lib/index.js +11 -3
  94. package/lib/index.web.js +6 -0
  95. package/lib/reanimated2/Colors.js +1 -1
  96. package/lib/reanimated2/NativeMethods.js +34 -17
  97. package/lib/reanimated2/NativeReanimated/NativeReanimated.js +6 -0
  98. package/lib/reanimated2/animation/util.js +4 -1
  99. package/lib/reanimated2/commonTypes.js +8 -1
  100. package/lib/reanimated2/component/FlatList.js +5 -5
  101. package/lib/reanimated2/core.js +5 -4
  102. package/lib/reanimated2/frameCallback/FrameCallbackRegistryJS.js +32 -0
  103. package/lib/reanimated2/frameCallback/FrameCallbackRegistryUI.js +76 -0
  104. package/lib/reanimated2/globals.d.ts +5 -2
  105. package/lib/reanimated2/hook/index.js +3 -0
  106. package/lib/reanimated2/hook/useAnimatedKeyboard.js +31 -0
  107. package/lib/reanimated2/hook/useAnimatedSensor.js +3 -3
  108. package/lib/reanimated2/hook/useFrameCallback.js +23 -0
  109. package/lib/reanimated2/hook/useScrollViewOffset.js +26 -0
  110. package/lib/reanimated2/jestUtils.js +11 -3
  111. package/lib/reanimated2/js-reanimated/JSReanimated.js +7 -0
  112. package/lib/reanimated2/js-reanimated/global.js +33 -22
  113. package/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.js +1 -1
  114. package/lib/reanimated2/utils.js +10 -3
  115. package/lib/types/{lib/Animated.d.ts → Animated.d.ts} +0 -0
  116. package/lib/types/{lib/ConfigHelper.d.ts → ConfigHelper.d.ts} +0 -0
  117. package/lib/types/{lib/ReanimatedEventEmitter.d.ts → ReanimatedEventEmitter.d.ts} +0 -0
  118. package/lib/types/{lib/ReanimatedModule.d.ts → ReanimatedModule.d.ts} +0 -0
  119. package/lib/types/{lib/ReanimatedModule.macos.d.ts → ReanimatedModule.macos.d.ts} +0 -0
  120. package/lib/types/{lib/ReanimatedModule.native.d.ts → ReanimatedModule.native.d.ts} +0 -0
  121. package/lib/types/{lib/ReanimatedModule.windows.d.ts → ReanimatedModule.windows.d.ts} +0 -0
  122. package/lib/types/{lib/ReanimatedModuleCompat.d.ts → ReanimatedModuleCompat.d.ts} +0 -0
  123. package/lib/types/{lib/createAnimatedComponent.d.ts → createAnimatedComponent.d.ts} +0 -0
  124. package/lib/types/index.d.ts +4 -0
  125. package/lib/types/{lib/index.d.ts → index.web.d.ts} +0 -0
  126. package/lib/types/{lib/reanimated2 → reanimated2}/Bezier.d.ts +0 -0
  127. package/lib/types/{lib/reanimated2 → reanimated2}/Colors.d.ts +0 -0
  128. package/lib/types/{lib/reanimated2 → reanimated2}/Easing.d.ts +0 -0
  129. package/lib/types/{lib/reanimated2 → reanimated2}/NativeMethods.d.ts +3 -10
  130. package/lib/types/{lib/reanimated2 → reanimated2}/NativeReanimated/NativeReanimated.d.ts +3 -1
  131. package/lib/types/{lib/reanimated2 → reanimated2}/NativeReanimated/index.d.ts +0 -0
  132. package/lib/types/{lib/reanimated2 → reanimated2}/PlatformChecker.d.ts +0 -0
  133. package/lib/types/{lib/reanimated2 → reanimated2}/PropAdapters.d.ts +0 -0
  134. package/lib/types/{lib/reanimated2 → reanimated2}/UpdateProps.d.ts +0 -0
  135. package/lib/types/{lib/reanimated2 → reanimated2}/ViewDescriptorsSet.d.ts +0 -0
  136. package/lib/types/{lib/reanimated2 → reanimated2}/WorkletEventHandler.d.ts +0 -0
  137. package/lib/types/{lib/reanimated2 → reanimated2}/__mocks__/MutableValue.d.ts +0 -0
  138. package/lib/types/{lib/reanimated2 → reanimated2}/__mocks__/NativeReanimated.d.ts +0 -0
  139. package/lib/types/{lib/reanimated2 → reanimated2}/animation/commonTypes.d.ts +0 -0
  140. package/lib/types/{lib/reanimated2 → reanimated2}/animation/decay.d.ts +0 -0
  141. package/lib/types/{lib/reanimated2 → reanimated2}/animation/delay.d.ts +0 -0
  142. package/lib/types/{lib/reanimated2 → reanimated2}/animation/index.d.ts +0 -0
  143. package/lib/types/{lib/reanimated2 → reanimated2}/animation/repeat.d.ts +0 -0
  144. package/lib/types/{lib/reanimated2 → reanimated2}/animation/sequence.d.ts +0 -0
  145. package/lib/types/{lib/reanimated2 → reanimated2}/animation/spring.d.ts +0 -0
  146. package/lib/types/{lib/reanimated2 → reanimated2}/animation/styleAnimation.d.ts +0 -0
  147. package/lib/types/{lib/reanimated2 → reanimated2}/animation/timing.d.ts +0 -0
  148. package/lib/types/{lib/reanimated2 → reanimated2}/animation/util.d.ts +0 -0
  149. package/lib/types/{lib/reanimated2 → reanimated2}/commonTypes.d.ts +20 -0
  150. package/lib/types/{lib/reanimated2 → reanimated2}/component/FlatList.d.ts +2 -2
  151. package/lib/types/{lib/reanimated2 → reanimated2}/component/Image.d.ts +0 -0
  152. package/lib/types/{lib/reanimated2 → reanimated2}/component/ScrollView.d.ts +0 -0
  153. package/lib/types/{lib/reanimated2 → reanimated2}/component/Text.d.ts +0 -0
  154. package/lib/types/{lib/reanimated2 → reanimated2}/component/View.d.ts +0 -0
  155. package/lib/types/{lib/reanimated2 → reanimated2}/core.d.ts +0 -0
  156. package/lib/types/reanimated2/frameCallback/FrameCallbackRegistryJS.d.ts +8 -0
  157. package/lib/types/reanimated2/frameCallback/FrameCallbackRegistryUI.d.ts +6 -0
  158. package/lib/types/{lib/reanimated2 → reanimated2}/hook/Hooks.d.ts +0 -0
  159. package/lib/types/{lib/reanimated2 → reanimated2}/hook/commonTypes.d.ts +0 -0
  160. package/lib/types/{lib/reanimated2 → reanimated2}/hook/index.d.ts +4 -0
  161. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedGestureHandler.d.ts +0 -0
  162. package/lib/types/reanimated2/hook/useAnimatedKeyboard.d.ts +2 -0
  163. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedReaction.d.ts +0 -0
  164. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedRef.d.ts +0 -0
  165. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedScrollHandler.d.ts +1 -2
  166. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedSensor.d.ts +1 -1
  167. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedStyle.d.ts +0 -0
  168. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useDerivedValue.d.ts +0 -0
  169. package/lib/types/reanimated2/hook/useFrameCallback.d.ts +7 -0
  170. package/lib/types/reanimated2/hook/useScrollViewOffset.d.ts +4 -0
  171. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useSharedValue.d.ts +0 -0
  172. package/lib/types/{lib/reanimated2 → reanimated2}/hook/utils.d.ts +0 -0
  173. package/lib/types/{lib/reanimated2 → reanimated2}/index.d.ts +0 -0
  174. package/lib/types/{lib/reanimated2 → reanimated2}/interpolateColor.d.ts +0 -0
  175. package/lib/types/{lib/reanimated2 → reanimated2}/interpolation.d.ts +0 -0
  176. package/lib/types/{lib/reanimated2 → reanimated2}/jestUtils.d.ts +1 -1
  177. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/JSReanimated.d.ts +3 -1
  178. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/Mapper.d.ts +0 -0
  179. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/MapperRegistry.d.ts +0 -0
  180. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/MutableValue.d.ts +0 -0
  181. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/commonTypes.d.ts +0 -0
  182. package/lib/types/reanimated2/js-reanimated/global.d.ts +2 -0
  183. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/index.d.ts +0 -0
  184. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/LayoutAnimationRepository.d.ts +0 -0
  185. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/BaseAnimationBuilder.d.ts +0 -0
  186. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +0 -0
  187. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/Keyframe.d.ts +0 -0
  188. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/commonTypes.d.ts +0 -0
  189. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/index.d.ts +0 -0
  190. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Bounce.d.ts +0 -0
  191. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Default.d.ts +0 -0
  192. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Fade.d.ts +0 -0
  193. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Flip.d.ts +0 -0
  194. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Lightspeed.d.ts +0 -0
  195. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Pinwheel.d.ts +0 -0
  196. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Roll.d.ts +0 -0
  197. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Rotate.d.ts +0 -0
  198. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Slide.d.ts +0 -0
  199. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Stretch.d.ts +0 -0
  200. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Zoom.d.ts +0 -0
  201. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/index.d.ts +0 -0
  202. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +0 -0
  203. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +0 -0
  204. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/FadingTransition.d.ts +0 -0
  205. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +0 -0
  206. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/LinearTransition.d.ts +0 -0
  207. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +0 -0
  208. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/index.d.ts +0 -0
  209. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/index.d.ts +0 -0
  210. package/lib/types/{lib/reanimated2 → reanimated2}/mock.d.ts +0 -0
  211. package/lib/types/{lib/reanimated2 → reanimated2}/platform-specific/RNRenderer.d.ts +0 -0
  212. package/lib/types/reanimated2/platform-specific/RNRenderer.web.d.ts +0 -0
  213. package/lib/types/{lib/reanimated2 → reanimated2}/utils.d.ts +5 -1
  214. package/lib/types/{lib/setAndForwardRef.d.ts → setAndForwardRef.d.ts} +0 -0
  215. package/mock.js +1 -0
  216. package/package.json +8 -8
  217. package/plugin.js +8 -17
  218. package/react-native-reanimated.d.ts +67 -12
  219. package/scripts/reanimated_utils.rb +65 -0
  220. package/src/index.ts +11 -3
  221. package/src/index.web.ts +7 -0
  222. package/src/reanimated2/Colors.ts +1 -1
  223. package/src/reanimated2/NativeMethods.ts +47 -30
  224. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +9 -0
  225. package/src/reanimated2/animation/util.ts +8 -1
  226. package/src/reanimated2/commonTypes.ts +24 -0
  227. package/src/reanimated2/component/FlatList.tsx +29 -19
  228. package/src/reanimated2/core.ts +8 -8
  229. package/src/reanimated2/frameCallback/FrameCallbackRegistryJS.ts +40 -0
  230. package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +115 -0
  231. package/src/reanimated2/globals.d.ts +5 -2
  232. package/src/reanimated2/hook/index.ts +4 -0
  233. package/src/reanimated2/hook/useAnimatedKeyboard.ts +35 -0
  234. package/src/reanimated2/hook/useAnimatedScrollHandler.ts +3 -1
  235. package/src/reanimated2/hook/useAnimatedSensor.ts +5 -5
  236. package/src/reanimated2/hook/useFrameCallback.ts +40 -0
  237. package/src/reanimated2/hook/useScrollViewOffset.ts +36 -0
  238. package/src/reanimated2/jestUtils.ts +11 -3
  239. package/src/reanimated2/js-reanimated/JSReanimated.ts +16 -1
  240. package/src/reanimated2/js-reanimated/global.ts +41 -29
  241. package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +1 -1
  242. package/src/reanimated2/utils.ts +12 -5
  243. package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  244. package/android/.gradle/7.2/executionHistory/executionHistory.bin +0 -0
  245. package/android/.gradle/7.2/executionHistory/executionHistory.lock +0 -0
  246. package/android/.gradle/7.2/fileHashes/fileHashes.bin +0 -0
  247. package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
  248. package/android/.gradle/checksums/checksums.lock +0 -0
  249. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  250. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  251. package/android/react-native-reanimated-65-hermes.aar +0 -0
  252. package/android/react-native-reanimated-65-jsc.aar +0 -0
  253. package/android/src/main/java/com/swmansion/reanimated/AndroidErrorHandler.java +0 -8
  254. package/lib/reanimated2/__mocks__/NativeReanimated.native.js +0 -20
  255. package/lib/types/lib/reanimated2/__mocks__/NativeReanimated.native.d.ts +0 -13
  256. package/lib/types/lib/reanimated2/js-reanimated/global.d.ts +0 -1
  257. package/lib/types/react-native-reanimated-tests.d.ts +0 -1
@@ -509,9 +509,9 @@
509
509
  _nativeProps = nativePropsSet;
510
510
  }
511
511
 
512
- - (BOOL)isNotNativeViewFullyMounted:(NSNumber *)viewTag
512
+ - (BOOL)isNativeViewMounted:(NSNumber *)viewTag
513
513
  {
514
- return _viewRegistry[viewTag].superview == nil;
514
+ return _viewRegistry[viewTag].superview != nil;
515
515
  }
516
516
 
517
517
  - (void)setValueForNodeID:(nonnull NSNumber *)nodeID value:(nonnull NSNumber *)newValue
@@ -529,7 +529,17 @@
529
529
  withName:(nonnull NSString *)viewName
530
530
  {
531
531
  ComponentUpdate *lastSnapshot = _componentUpdateBuffer[viewTag];
532
- if ([self isNotNativeViewFullyMounted:viewTag] || lastSnapshot != nil) {
532
+ BOOL isNativeViewMounted = [self isNativeViewMounted:viewTag];
533
+
534
+ if (lastSnapshot != nil) {
535
+ NSMutableDictionary *lastProps = lastSnapshot.props;
536
+ for (NSString *key in props) {
537
+ [lastProps setValue:props[key] forKey:key];
538
+ }
539
+ }
540
+
541
+ // If the component isn't mounted, we will bail early with a scheduled update
542
+ if (!isNativeViewMounted) {
533
543
  if (lastSnapshot == nil) {
534
544
  ComponentUpdate *propsSnapshot = [ComponentUpdate new];
535
545
  propsSnapshot.props = [props mutableCopy];
@@ -537,15 +547,28 @@
537
547
  propsSnapshot.viewName = viewName;
538
548
  _componentUpdateBuffer[viewTag] = propsSnapshot;
539
549
  atomic_store(&_shouldFlushUpdateBuffer, true);
540
- } else {
541
- NSMutableDictionary *lastProps = lastSnapshot.props;
542
- for (NSString *key in props) {
543
- [lastProps setValue:props[key] forKey:key];
544
- }
545
550
  }
551
+
546
552
  return;
547
553
  }
548
554
 
555
+ // The component may have been mounted with a pending snapshot (due to a race condition),
556
+ // so we should attempt run the update. Otherwise, the next call to -maybeFlushUpdateBuffer
557
+ // will only arrive when a new component is mounted (which might be never!)
558
+ //
559
+ // If there are 0 remaining items in the buffer, we can skip the run in -maybeFlushUpdateBuffer.
560
+ if (lastSnapshot != nil && isNativeViewMounted) {
561
+ props = lastSnapshot.props;
562
+ viewTag = lastSnapshot.viewTag;
563
+ viewName = lastSnapshot.viewName;
564
+
565
+ [_componentUpdateBuffer removeObjectForKey:viewTag];
566
+
567
+ if (_componentUpdateBuffer.count == 0) {
568
+ atomic_store(&_shouldFlushUpdateBuffer, false);
569
+ }
570
+ }
571
+
549
572
  // TODO: refactor PropsNode to also use this function
550
573
  NSMutableDictionary *uiProps = [NSMutableDictionary new];
551
574
  NSMutableDictionary *nativeProps = [NSMutableDictionary new];
@@ -0,0 +1,17 @@
1
+ #ifndef REAKeyboardEventManager_h
2
+ #define REAKeyboardEventManager_h
3
+
4
+ #import <RNReanimated/REAEventDispatcher.h>
5
+ #import <React/RCTEventDispatcher.h>
6
+
7
+ typedef void (^KeyboardEventListenerBlock)(int keyboardState, int height);
8
+
9
+ @interface REAKeyboardEventObserver : NSObject
10
+
11
+ - (instancetype)init;
12
+ - (int)subscribeForKeyboardEvents:(KeyboardEventListenerBlock)listener;
13
+ - (void)unsubscribeFromKeyboardEvents:(int)listenerId;
14
+
15
+ @end
16
+
17
+ #endif /* REAKeyboardEventManager_h */
@@ -0,0 +1,198 @@
1
+ #import "REAKeyboardEventObserver.h"
2
+ #import <Foundation/Foundation.h>
3
+ #import <React/RCTDefines.h>
4
+ #import <React/RCTUIManager.h>
5
+
6
+ typedef NS_ENUM(NSUInteger, KeyboardState) {
7
+ UNKNOWN = 0,
8
+ OPENING = 1,
9
+ OPEN = 2,
10
+ CLOSING = 3,
11
+ CLOSED = 4,
12
+ };
13
+
14
+ @implementation REAKeyboardEventObserver {
15
+ NSNumber *_nextListenerId;
16
+ NSMutableDictionary *_listeners;
17
+ CADisplayLink *displayLink;
18
+ int _windowsCount;
19
+ UIView *_keyboardView;
20
+ KeyboardState _state;
21
+ }
22
+
23
+ - (instancetype)init
24
+ {
25
+ self = [super init];
26
+ _listeners = [[NSMutableDictionary alloc] init];
27
+ _nextListenerId = @0;
28
+ _state = UNKNOWN;
29
+ return self;
30
+ }
31
+
32
+ // copied from
33
+ // https://github.com/tonlabs/UIKit/blob/bd5651e4723d547bde0cb86ca1c27813cedab4a9/casts/keyboard/ios/UIKitKeyboardIosFrameListener.m
34
+ - (UIView *)findKeyboardView
35
+ {
36
+ for (UIWindow *window in [UIApplication.sharedApplication.windows objectEnumerator]) {
37
+ if ([window isKindOfClass:NSClassFromString(@"UITextEffectsWindow")]) {
38
+ for (UIView *containerView in window.subviews) {
39
+ if ([containerView isKindOfClass:NSClassFromString(@"UIInputSetContainerView")]) {
40
+ for (UIView *hostView in containerView.subviews) {
41
+ if ([hostView isKindOfClass:NSClassFromString(@"UIInputSetHostView")]) {
42
+ return hostView;
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }
49
+ return nil;
50
+ }
51
+
52
+ - (UIView *)getKeyboardView
53
+ {
54
+ /**
55
+ * If the count of windows has changed it means there might be a new UITextEffectsWindow,
56
+ * thus we have to obtain a new `keyboardView`
57
+ */
58
+ int windowsCount = [UIApplication.sharedApplication.windows count];
59
+
60
+ if (_keyboardView == nil || windowsCount != _windowsCount) {
61
+ _keyboardView = [self findKeyboardView];
62
+ _windowsCount = windowsCount;
63
+ }
64
+ return _keyboardView;
65
+ }
66
+
67
+ #if TARGET_OS_TV
68
+ - (int)subscribeForKeyboardEvents:(KeyboardEventListenerBlock)listener
69
+ {
70
+ NSLog(@"Keyboard handling is not supported on tvOS");
71
+ return 0;
72
+ }
73
+
74
+ - (void)unsubscribeFromKeyboardEvents:(int)listenerId
75
+ {
76
+ NSLog(@"Keyboard handling is not supported on tvOS");
77
+ }
78
+ #else
79
+
80
+ - (void)runAnimation
81
+ {
82
+ displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(updateKeyboardFrame)];
83
+ [displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
84
+ }
85
+
86
+ - (void)stopAnimation
87
+ {
88
+ [displayLink invalidate];
89
+ displayLink = nil;
90
+ [self updateKeyboardFrame];
91
+ }
92
+
93
+ - (void)updateKeyboardFrame
94
+ {
95
+ UIView *keyboardView = [self getKeyboardView];
96
+ if (keyboardView == nil) {
97
+ return;
98
+ }
99
+
100
+ CGFloat keyboardHeight = [self computeKeyboardHeight:keyboardView];
101
+ for (NSString *key in _listeners.allKeys) {
102
+ ((KeyboardEventListenerBlock)_listeners[key])(_state, keyboardHeight);
103
+ }
104
+ }
105
+
106
+ - (CGFloat)computeKeyboardHeight:(UIView *)keyboardView
107
+ {
108
+ CGFloat keyboardFrameY = [keyboardView.layer presentationLayer].frame.origin.y;
109
+ CGFloat keyboardWindowH = keyboardView.window.bounds.size.height;
110
+ CGFloat keyboardHeight = keyboardWindowH - keyboardFrameY;
111
+ return keyboardHeight;
112
+ }
113
+
114
+ - (void)keyboardWillShow:(NSNotification *)notification
115
+ {
116
+ _state = OPENING;
117
+ [self runAnimation];
118
+ }
119
+
120
+ - (void)keyboardDidShow:(NSNotification *)notification
121
+ {
122
+ _state = OPEN;
123
+ [self stopAnimation];
124
+ }
125
+
126
+ - (void)keyboardWillHide:(NSNotification *)notification
127
+ {
128
+ _state = CLOSING;
129
+ [self runAnimation];
130
+ }
131
+
132
+ - (void)keyboardDidHide:(NSNotification *)notification
133
+ {
134
+ _state = CLOSED;
135
+ [self stopAnimation];
136
+ }
137
+
138
+ - (int)subscribeForKeyboardEvents:(KeyboardEventListenerBlock)listener
139
+ {
140
+ NSNumber *listenerId = [_nextListenerId copy];
141
+ _nextListenerId = [NSNumber numberWithInt:[_nextListenerId intValue] + 1];
142
+ if ([_listeners count] == 0) {
143
+ NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
144
+
145
+ [notificationCenter addObserver:self
146
+ selector:@selector(keyboardWillHide:)
147
+ name:UIKeyboardWillHideNotification
148
+ object:nil];
149
+
150
+ [notificationCenter addObserver:self
151
+ selector:@selector(keyboardWillShow:)
152
+ name:UIKeyboardWillShowNotification
153
+ object:nil];
154
+
155
+ [notificationCenter addObserver:self
156
+ selector:@selector(keyboardDidHide:)
157
+ name:UIKeyboardDidHideNotification
158
+ object:nil];
159
+
160
+ [notificationCenter addObserver:self
161
+ selector:@selector(keyboardDidShow:)
162
+ name:UIKeyboardDidShowNotification
163
+ object:nil];
164
+ }
165
+
166
+ [_listeners setObject:listener forKey:listenerId];
167
+ if (_state == UNKNOWN) {
168
+ [self recognizeInitialKeyboardState];
169
+ }
170
+ return [listenerId intValue];
171
+ }
172
+
173
+ - (void)unsubscribeFromKeyboardEvents:(int)listenerId
174
+ {
175
+ NSNumber *_listenerId = [NSNumber numberWithInt:listenerId];
176
+ [_listeners removeObjectForKey:_listenerId];
177
+ if ([_listeners count] == 0) {
178
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
179
+ }
180
+ }
181
+
182
+ - (void)recognizeInitialKeyboardState
183
+ {
184
+ RCTExecuteOnMainQueue(^() {
185
+ UIView *keyboardView = [self getKeyboardView];
186
+ if (keyboardView == nil) {
187
+ self->_state = CLOSED;
188
+ } else {
189
+ CGFloat keyboardHeight = [self computeKeyboardHeight:keyboardView];
190
+ self->_state = keyboardHeight == 0 ? CLOSED : OPEN;
191
+ }
192
+ [self updateKeyboardFrame];
193
+ });
194
+ }
195
+
196
+ #endif
197
+
198
+ @end
@@ -4,6 +4,7 @@
4
4
  #import <RNReanimated/REAAnimationsManager.h>
5
5
  #import <RNReanimated/REAIOSErrorHandler.h>
6
6
  #import <RNReanimated/REAIOSScheduler.h>
7
+ #import <RNReanimated/REAKeyboardEventObserver.h>
7
8
  #import <RNReanimated/REAModule.h>
8
9
  #import <RNReanimated/REANodesManager.h>
9
10
  #import <RNReanimated/REAUIManager.h>
@@ -200,8 +201,10 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
200
201
  }
201
202
  };
202
203
 
203
- auto requestRender = [reanimatedModule, &module](std::function<void(double)> onRender, jsi::Runtime &rt) {
204
- [reanimatedModule.nodesManager postOnAnimation:^(CADisplayLink *displayLink) {
204
+ auto nodesManager = reanimatedModule.nodesManager;
205
+
206
+ auto requestRender = [nodesManager, &module](std::function<void(double)> onRender, jsi::Runtime &rt) {
207
+ [nodesManager postOnAnimation:^(CADisplayLink *displayLink) {
205
208
  double frameTimestamp = calculateTimestampWithSlowAnimations(displayLink.targetTimestamp) * 1000;
206
209
  jsi::Object global = rt.global();
207
210
  jsi::String frameTimestampName = jsi::String::createFromAscii(rt, "_frameTimestamp");
@@ -297,6 +300,21 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
297
300
  auto unregisterSensorFunction = [=](int sensorId) { [reanimatedSensorContainer unregisterSensor:sensorId]; };
298
301
  // end sensors
299
302
 
303
+ // keyboard events
304
+
305
+ static REAKeyboardEventObserver *keyboardObserver = [[REAKeyboardEventObserver alloc] init];
306
+ auto subscribeForKeyboardEventsFunction =
307
+ [](std::function<void(int keyboardState, int height)> keyboardEventDataUpdater) {
308
+ return [keyboardObserver subscribeForKeyboardEvents:^(int keyboardState, int height) {
309
+ keyboardEventDataUpdater(keyboardState, height);
310
+ }];
311
+ };
312
+
313
+ auto unsubscribeFromKeyboardEventsFunction = [](int listenerId) {
314
+ [keyboardObserver unsubscribeFromKeyboardEvents:listenerId];
315
+ };
316
+ // end keyboard events
317
+
300
318
  PlatformDepMethodsHolder platformDepMethodsHolder = {
301
319
  requestRender,
302
320
  propUpdater,
@@ -306,7 +324,10 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
306
324
  registerSensorFunction,
307
325
  unregisterSensorFunction,
308
326
  setGestureStateFunction,
309
- configurePropsFunction};
327
+ configurePropsFunction,
328
+ subscribeForKeyboardEventsFunction,
329
+ unsubscribeFromKeyboardEventsFunction,
330
+ };
310
331
 
311
332
  module = std::make_shared<NativeReanimatedModule>(
312
333
  jsInvoker,
@@ -7,11 +7,11 @@
7
7
  #import <ReactCommon/RCTTurboModuleManager.h>
8
8
  #import <jsireact/JSIExecutor.h>
9
9
 
10
- #if RNVERSION >= 64
10
+ #if REACT_NATIVE_MINOR_VERSION >= 64
11
11
  #import <React/RCTJSIExecutorRuntimeInstaller.h>
12
12
  #endif
13
13
 
14
- #if RNVERSION < 63
14
+ #if REACT_NATIVE_MINOR_VERSION < 63
15
15
  #import <ReactCommon/BridgeJSCallInvoker.h>
16
16
  #endif
17
17
 
@@ -24,7 +24,7 @@ JSIExecutor::RuntimeInstaller REAJSIExecutorRuntimeInstaller(
24
24
 
25
25
  [bridge moduleForClass:[RCTEventDispatcher class]];
26
26
  RCTEventDispatcher *eventDispatcher = [REAEventDispatcher new];
27
- #if RNVERSION >= 66
27
+ #if REACT_NATIVE_MINOR_VERSION >= 66
28
28
  RCTCallableJSModules *callableJSModules = [RCTCallableJSModules new];
29
29
  [bridge setValue:callableJSModules forKey:@"_callableJSModules"];
30
30
  [callableJSModules setBridge:bridge];
@@ -39,26 +39,22 @@ JSIExecutor::RuntimeInstaller REAJSIExecutorRuntimeInstaller(
39
39
  if (!bridge) {
40
40
  return;
41
41
  }
42
- #if RNVERSION >= 63
42
+ #if REACT_NATIVE_MINOR_VERSION >= 63
43
43
  auto reanimatedModule = reanimated::createReanimatedModule(bridge, bridge.jsCallInvoker);
44
44
  #else
45
45
  auto callInvoker = std::make_shared<react::BridgeJSCallInvoker>(bridge.reactInstance);
46
46
  auto reanimatedModule = reanimated::createReanimatedModule(bridge, callInvoker);
47
47
  #endif
48
- auto workletRuntimeValue = runtime
49
- .global()
50
- .getProperty(runtime, "ArrayBuffer")
51
- .asObject(runtime)
52
- .asFunction(runtime)
53
- .callAsConstructor(runtime, {static_cast<double>(sizeof(void*))});
54
- uintptr_t* workletRuntimeData = reinterpret_cast<uintptr_t*>(
55
- workletRuntimeValue.getObject(runtime).getArrayBuffer(runtime).data(runtime));
48
+ auto workletRuntimeValue = runtime.global()
49
+ .getProperty(runtime, "ArrayBuffer")
50
+ .asObject(runtime)
51
+ .asFunction(runtime)
52
+ .callAsConstructor(runtime, {static_cast<double>(sizeof(void *))});
53
+ uintptr_t *workletRuntimeData =
54
+ reinterpret_cast<uintptr_t *>(workletRuntimeValue.getObject(runtime).getArrayBuffer(runtime).data(runtime));
56
55
  workletRuntimeData[0] = reinterpret_cast<uintptr_t>(reanimatedModule->runtime.get());
57
56
 
58
- runtime.global().setProperty(
59
- runtime,
60
- "_WORKLET_RUNTIME",
61
- workletRuntimeValue);
57
+ runtime.global().setProperty(runtime, "_WORKLET_RUNTIME", workletRuntimeValue);
62
58
 
63
59
  runtime.global().setProperty(
64
60
  runtime,
@@ -20,7 +20,7 @@ typedef JSCExecutorFactory ExecutorFactory;
20
20
  {
21
21
  const auto installer = reanimated::REAJSIExecutorRuntimeInstaller(bridge, NULL);
22
22
 
23
- #if RNVERSION >= 64
23
+ #if REACT_NATIVE_MINOR_VERSION >= 64
24
24
  // installs globals such as console, nativePerformanceNow, etc.
25
25
  return std::make_unique<ExecutorFactory>(RCTJSIExecutorRuntimeInstaller(installer));
26
26
  #else
@@ -7,7 +7,11 @@
7
7
  {
8
8
  self = [super init];
9
9
  _sensorType = sensorType;
10
- _interval = interval / 1000; // in seconds
10
+ if (interval == -1) {
11
+ _interval = 1.0 / UIScreen.mainScreen.maximumFramesPerSecond;
12
+ } else {
13
+ _interval = interval / 1000.0; // in seconds
14
+ }
11
15
  _setter = setter;
12
16
  _motionManager = [[CMMotionManager alloc] init];
13
17
  return self;
@@ -59,18 +63,21 @@
59
63
  }
60
64
  [_motionManager setAccelerometerUpdateInterval:_interval];
61
65
  [_motionManager startAccelerometerUpdates];
62
- [_motionManager
63
- startAccelerometerUpdatesToQueue:[NSOperationQueue mainQueue]
64
- withHandler:^(CMAccelerometerData *sensorData, NSError *error) {
65
- double currentTime = [[NSProcessInfo processInfo] systemUptime];
66
- if (currentTime - self->_lastTimestamp < self->_interval) {
67
- return;
68
- }
69
- double data[] = {
70
- sensorData.acceleration.x, sensorData.acceleration.y, sensorData.acceleration.z};
71
- self->_setter(data);
72
- self->_lastTimestamp = currentTime;
73
- }];
66
+ [_motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue mainQueue]
67
+ withHandler:^(CMAccelerometerData *sensorData, NSError *error) {
68
+ double currentTime = [[NSProcessInfo processInfo] systemUptime];
69
+ if (currentTime - self->_lastTimestamp < self->_interval) {
70
+ return;
71
+ }
72
+ double G = 9.81;
73
+ // convert G to m/s^2
74
+ double data[] = {
75
+ sensorData.acceleration.x * G,
76
+ sensorData.acceleration.y * G,
77
+ sensorData.acceleration.z * G};
78
+ self->_setter(data);
79
+ self->_lastTimestamp = currentTime;
80
+ }];
74
81
 
75
82
  return true;
76
83
  }
@@ -89,7 +96,10 @@
89
96
  if (currentTime - self->_lastTimestamp < self->_interval) {
90
97
  return;
91
98
  }
92
- double data[] = {sensorData.gravity.x, sensorData.gravity.y, sensorData.gravity.z};
99
+ double G = 9.81;
100
+ // convert G to m/s^2
101
+ double data[] = {
102
+ sensorData.gravity.x * G, sensorData.gravity.y * G, sensorData.gravity.z * G};
93
103
  self->_setter(data);
94
104
  self->_lastTimestamp = currentTime;
95
105
  }];
@@ -128,7 +138,7 @@
128
138
  [_motionManager setDeviceMotionUpdateInterval:_interval];
129
139
 
130
140
  [_motionManager setShowsDeviceMovementDisplay:YES];
131
- [_motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXTrueNorthZVertical
141
+ [_motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXArbitraryZVertical
132
142
  toQueue:[NSOperationQueue mainQueue]
133
143
  withHandler:^(CMDeviceMotion *sensorData, NSError *error) {
134
144
  double currentTime = [[NSProcessInfo processInfo] systemUptime];
@@ -143,8 +153,7 @@
143
153
  attitude.quaternion.w,
144
154
  attitude.yaw,
145
155
  attitude.pitch,
146
- attitude.roll
147
- };
156
+ attitude.roll};
148
157
  self->_setter(data);
149
158
  self->_lastTimestamp = currentTime;
150
159
  }];
package/lib/index.js CHANGED
@@ -1,6 +1,14 @@
1
- // tree-shaken side effects
2
- import './reanimated2/js-reanimated/global';
1
+ import * as Animated from './Animated';
2
+ import webGlobalIsInitialized from './reanimated2/js-reanimated/global';
3
+ if (!webGlobalIsInitialized) {
4
+ /*
5
+ `webGlobalIsInitialized` should always be `true`,
6
+ but we need to use `webGlobalIsInitialized` somewhere to ensure function execution,
7
+ in another way, the bundler can remove unused variables.
8
+ */
9
+ console.error('[Reanimated] Unable to initialize global objects for web.');
10
+ }
3
11
  // @ts-ignore backward compatibility with treeshaking
4
12
  export * from './reanimated1';
5
13
  export * from './reanimated2';
6
- export * as default from './Animated';
14
+ export default Animated;
@@ -0,0 +1,6 @@
1
+ // tree-shaken side effects
2
+ import './reanimated2/js-reanimated/global';
3
+ // @ts-ignore backward compatibility with treeshaking
4
+ export * from './reanimated1';
5
+ export * from './reanimated2';
6
+ export * as default from './Animated'; // If this line fails, you probably forgot some installation steps. Check out the installation guide here: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/ 1) Make sure reanimated's babel plugin is installed in your babel.config.js (you should have 'react-native-reanimated/plugin' listed there - also see the above link for details) 2) Make sure you reset build cache after updating the config, run: yarn start --reset-cache
@@ -9,7 +9,7 @@
9
9
  import { Platform } from 'react-native';
10
10
  import { makeRemote, makeShareable, isConfigured } from './core';
11
11
  // var INTEGER = '[-+]?\\d+';
12
- const NUMBER = '[-+]?\\d*\\.?\\d+';
12
+ const NUMBER = '[-+]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)';
13
13
  const PERCENTAGE = NUMBER + '%';
14
14
  function call(...args) {
15
15
  'worklet';
@@ -3,30 +3,47 @@ import { shouldBeUseWeb } from './PlatformChecker';
3
3
  export function getTag(view) {
4
4
  return findNodeHandle(view);
5
5
  }
6
- const isNativeIndefined = shouldBeUseWeb();
6
+ const isNative = !shouldBeUseWeb();
7
7
  export function measure(animatedRef) {
8
8
  'worklet';
9
- if (!_WORKLET || isNativeIndefined) {
10
- console.warn('[reanimated.measure] method cannot be used for web or Chrome Debugger');
11
- return {
12
- x: NaN,
13
- y: NaN,
14
- width: NaN,
15
- height: NaN,
16
- pageX: NaN,
17
- pageY: NaN,
18
- };
9
+ if (!isNative) {
10
+ console.warn('[Reanimated] measure() cannot be used on web or Chrome Debugger');
11
+ return null;
12
+ }
13
+ if (!_WORKLET) {
14
+ console.warn('[Reanimated] measure() was called from the main JS context. Measure is ' +
15
+ 'only available in the UI runtime. This may also happen if measure() ' +
16
+ 'was called by a worklet in the useAnimatedStyle hook, because useAnimatedStyle ' +
17
+ 'calls the given worklet on the JS runtime during render. If you want to ' +
18
+ 'prevent this warning then wrap the call with `if (_WORKLET)`. Then it will ' +
19
+ 'only be called on the UI runtime after the render has been completed.');
20
+ return null;
19
21
  }
20
22
  const viewTag = animatedRef();
21
- const result = _measure(viewTag);
22
- if (result.x === -1234567) {
23
- throw new Error(`The view with tag ${viewTag} could not be measured`);
23
+ if (viewTag === -1) {
24
+ console.warn(`[Reanimated] The view with tag ${viewTag} is not a valid argument for measure(). This may be because the view is not currently rendered, which may not be a bug (e.g. an off-screen FlatList item).`);
25
+ return null;
26
+ }
27
+ const measured = _measure(viewTag);
28
+ if (measured === null) {
29
+ console.warn(`[Reanimated] The view with tag ${viewTag} has some undefined, not-yet-computed or meaningless value of \`LayoutMetrics\` type. This may be because the view is not currently rendered, which may not be a bug (e.g. an off-screen FlatList item).`);
30
+ return null;
31
+ }
32
+ else if (measured.x === -1234567) {
33
+ console.warn(`[Reanimated] The view with tag ${viewTag} returned an invalid measurement response`);
34
+ return null;
35
+ }
36
+ else if (isNaN(measured.x)) {
37
+ console.warn(`[Reanimated] The view with tag ${viewTag} gets view-flattened on Android. To disable view-flattening, set \`collapsable={false}\` on this component.`);
38
+ return null;
39
+ }
40
+ else {
41
+ return measured;
24
42
  }
25
- return result;
26
43
  }
27
44
  export function scrollTo(animatedRef, x, y, animated) {
28
45
  'worklet';
29
- if (!_WORKLET || isNativeIndefined) {
46
+ if (!_WORKLET || !isNative) {
30
47
  return;
31
48
  }
32
49
  const viewTag = animatedRef();
@@ -34,7 +51,7 @@ export function scrollTo(animatedRef, x, y, animated) {
34
51
  }
35
52
  export function setGestureState(handlerTag, newState) {
36
53
  'worklet';
37
- if (!_WORKLET || isNativeIndefined) {
54
+ if (!_WORKLET || !isNative) {
38
55
  console.warn('[Reanimated] You can not use setGestureState in non-worklet function.');
39
56
  return;
40
57
  }
@@ -47,4 +47,10 @@ export class NativeReanimated {
47
47
  configureProps(uiProps, nativeProps) {
48
48
  this.InnerNativeModule.configureProps(uiProps, nativeProps);
49
49
  }
50
+ subscribeForKeyboardEvents(keyboardEventData) {
51
+ return this.InnerNativeModule.subscribeForKeyboardEvents(keyboardEventData);
52
+ }
53
+ unsubscribeFromKeyboardEvents(listenerId) {
54
+ this.InnerNativeModule.unsubscribeFromKeyboardEvents(listenerId);
55
+ }
50
56
  }
@@ -47,7 +47,10 @@ function decorateAnimation(animation) {
47
47
  animation.startValue = strippedValue;
48
48
  animation.toValue = strippedToValue;
49
49
  if (previousAnimation && previousAnimation !== animation) {
50
- previousAnimation.current = previousAnimation.strippedCurrent;
50
+ const { prefix: paPrefix, suffix: paSuffix, strippedValue: paStrippedValue, } = recognizePrefixSuffix(previousAnimation.current);
51
+ previousAnimation.current = paStrippedValue;
52
+ previousAnimation.__prefix = paPrefix;
53
+ previousAnimation.__suffix = paSuffix;
51
54
  }
52
55
  baseOnStart(animation, strippedValue, timestamp, previousAnimation);
53
56
  animation.current =
@@ -1 +1,8 @@
1
- export {};
1
+ export var KeyboardState;
2
+ (function (KeyboardState) {
3
+ KeyboardState[KeyboardState["UNKNOWN"] = 0] = "UNKNOWN";
4
+ KeyboardState[KeyboardState["OPENING"] = 1] = "OPENING";
5
+ KeyboardState[KeyboardState["OPEN"] = 2] = "OPEN";
6
+ KeyboardState[KeyboardState["CLOSING"] = 3] = "CLOSING";
7
+ KeyboardState[KeyboardState["CLOSED"] = 4] = "CLOSED";
8
+ })(KeyboardState || (KeyboardState = {}));
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import React from 'react';
12
+ import React, { forwardRef } from 'react';
13
13
  import { FlatList } from 'react-native';
14
14
  import ReanimatedView from './View';
15
15
  import createAnimatedComponent from '../../createAnimatedComponent';
@@ -22,9 +22,9 @@ const createCellRenderer = (itemLayoutAnimation) => {
22
22
  };
23
23
  return cellRenderer;
24
24
  };
25
- const ReanimatedFlatlist = (_a) => {
26
- var { itemLayoutAnimation } = _a, restProps = __rest(_a, ["itemLayoutAnimation"]);
25
+ const ReanimatedFlatlist = forwardRef((props, ref) => {
26
+ const { itemLayoutAnimation } = props, restProps = __rest(props, ["itemLayoutAnimation"]);
27
27
  const cellRenderer = React.useMemo(() => createCellRenderer(itemLayoutAnimation), []);
28
- return (<AnimatedFlatList {...restProps} CellRendererComponent={cellRenderer}/>);
29
- };
28
+ return (<AnimatedFlatList ref={ref} {...restProps} CellRendererComponent={cellRenderer}/>);
29
+ });
30
30
  export default ReanimatedFlatlist;