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
@@ -5,67 +5,59 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Extrapolation = void 0;
7
7
  exports.interpolate = interpolate;
8
- let Extrapolation;
9
- exports.Extrapolation = Extrapolation;
10
-
11
- (function (Extrapolation) {
8
+ let Extrapolation = /*#__PURE__*/function (Extrapolation) {
12
9
  Extrapolation["IDENTITY"] = "identity";
13
10
  Extrapolation["CLAMP"] = "clamp";
14
11
  Extrapolation["EXTEND"] = "extend";
15
- })(Extrapolation || (exports.Extrapolation = Extrapolation = {}));
16
-
12
+ return Extrapolation;
13
+ }({});
14
+ exports.Extrapolation = Extrapolation;
17
15
  function getVal(type, coef, val, leftEdgeOutput, rightEdgeOutput, x) {
18
16
  'worklet';
19
17
 
20
18
  switch (type) {
21
19
  case Extrapolation.IDENTITY:
22
20
  return x;
23
-
24
21
  case Extrapolation.CLAMP:
25
22
  if (coef * val < coef * leftEdgeOutput) {
26
23
  return leftEdgeOutput;
27
24
  }
28
-
29
25
  return rightEdgeOutput;
30
-
31
26
  case Extrapolation.EXTEND:
32
27
  default:
33
28
  return val;
34
29
  }
35
30
  }
36
-
37
31
  function isExtrapolate(value) {
38
32
  'worklet';
39
33
 
40
34
  return value === Extrapolation.EXTEND || value === Extrapolation.CLAMP || value === Extrapolation.IDENTITY;
41
- } // validates extrapolations type
42
- // if type is correct, converts it to ExtrapolationConfig
43
-
35
+ }
44
36
 
37
+ // validates extrapolations type
38
+ // if type is correct, converts it to ExtrapolationConfig
45
39
  function validateType(type) {
46
- 'worklet'; // initialize extrapolationConfig with default extrapolation
40
+ 'worklet';
47
41
 
42
+ // initialize extrapolationConfig with default extrapolation
48
43
  const extrapolationConfig = {
49
44
  extrapolateLeft: Extrapolation.EXTEND,
50
45
  extrapolateRight: Extrapolation.EXTEND
51
46
  };
52
-
53
47
  if (!type) {
54
48
  return extrapolationConfig;
55
49
  }
56
-
57
50
  if (typeof type === 'string') {
58
51
  if (!isExtrapolate(type)) {
59
52
  throw new Error(`Reanimated: not supported value for "interpolate" \nSupported values: ["extend", "clamp", "identity", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\n Valid example:
60
53
  interpolate(value, [inputRange], [outputRange], "clamp")`);
61
54
  }
62
-
63
55
  extrapolationConfig.extrapolateLeft = type;
64
56
  extrapolationConfig.extrapolateRight = type;
65
57
  return extrapolationConfig;
66
- } // otherwise type is extrapolation config object
67
-
58
+ }
68
59
 
60
+ // otherwise type is extrapolation config object
69
61
  if (type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft) || type.extrapolateRight && !isExtrapolate(type.extrapolateRight)) {
70
62
  throw new Error(`Reanimated: not supported value for "interpolate" \nSupported values: ["extend", "clamp", "identity", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\n Valid example:
71
63
  interpolate(value, [inputRange], [outputRange], {
@@ -73,11 +65,9 @@ function validateType(type) {
73
65
  extrapolateRight: Extrapolation.IDENTITY
74
66
  }})`);
75
67
  }
76
-
77
68
  Object.assign(extrapolationConfig, type);
78
69
  return extrapolationConfig;
79
70
  }
80
-
81
71
  function internalInterpolate(x, narrowedInput, extrapolationConfig) {
82
72
  'worklet';
83
73
 
@@ -91,25 +81,22 @@ function internalInterpolate(x, narrowedInput, extrapolationConfig) {
91
81
  const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);
92
82
  const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);
93
83
  const coef = rightEdgeOutput >= leftEdgeOutput ? 1 : -1;
94
-
95
84
  if (coef * val < coef * leftEdgeOutput) {
96
85
  return getVal(extrapolationConfig.extrapolateLeft, coef, val, leftEdgeOutput, rightEdgeOutput, x);
97
86
  } else if (coef * val > coef * rightEdgeOutput) {
98
87
  return getVal(extrapolationConfig.extrapolateRight, coef, val, leftEdgeOutput, rightEdgeOutput, x);
99
88
  }
100
-
101
89
  return val;
102
- } // TODO: support default values in worklets:
103
- // e.g. function interpolate(x, input, output, type = Extrapolatation.CLAMP)
104
-
90
+ }
105
91
 
92
+ // TODO: support default values in worklets:
93
+ // e.g. function interpolate(x, input, output, type = Extrapolatation.CLAMP)
106
94
  function interpolate(x, input, output, type) {
107
95
  'worklet';
108
96
 
109
97
  if (input.length < 2 || output.length < 2) {
110
98
  throw Error('Interpolation input and output should contain at least two values.');
111
99
  }
112
-
113
100
  const extrapolationConfig = validateType(type);
114
101
  const length = input.length;
115
102
  const narrowedInput = {
@@ -118,7 +105,6 @@ function interpolate(x, input, output, type) {
118
105
  leftEdgeOutput: output[0],
119
106
  rightEdgeOutput: output[1]
120
107
  };
121
-
122
108
  if (length > 2) {
123
109
  if (x > input[length - 1]) {
124
110
  narrowedInput.leftEdgeInput = input[length - 2];
@@ -137,7 +123,6 @@ function interpolate(x, input, output, type) {
137
123
  }
138
124
  }
139
125
  }
140
-
141
126
  return internalInterpolate(x, narrowedInput, extrapolationConfig);
142
127
  }
143
128
  //# sourceMappingURL=interpolation.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Extrapolation","getVal","type","coef","val","leftEdgeOutput","rightEdgeOutput","x","IDENTITY","CLAMP","EXTEND","isExtrapolate","value","validateType","extrapolationConfig","extrapolateLeft","extrapolateRight","Error","Object","assign","internalInterpolate","narrowedInput","leftEdgeInput","rightEdgeInput","progress","interpolate","input","output","length","i"],"sources":["interpolation.ts"],"sourcesContent":["export enum Extrapolation {\n IDENTITY = 'identity',\n CLAMP = 'clamp',\n EXTEND = 'extend',\n}\n\ninterface InterpolationNarrowedInput {\n leftEdgeInput: number;\n rightEdgeInput: number;\n leftEdgeOutput: number;\n rightEdgeOutput: number;\n}\n\nexport interface ExtrapolationConfig {\n extrapolateLeft?: Extrapolation | string;\n extrapolateRight?: Extrapolation | string;\n}\n\ninterface RequiredExtrapolationConfig {\n extrapolateLeft: Extrapolation;\n extrapolateRight: Extrapolation;\n}\n\nexport type ExtrapolationType =\n | ExtrapolationConfig\n | Extrapolation\n | string\n | undefined;\n\nfunction getVal(\n type: Extrapolation,\n coef: number,\n val: number,\n leftEdgeOutput: number,\n rightEdgeOutput: number,\n x: number\n): number {\n 'worklet';\n\n switch (type) {\n case Extrapolation.IDENTITY:\n return x;\n case Extrapolation.CLAMP:\n if (coef * val < coef * leftEdgeOutput) {\n return leftEdgeOutput;\n }\n return rightEdgeOutput;\n case Extrapolation.EXTEND:\n default:\n return val;\n }\n}\n\nfunction isExtrapolate(value: string): value is Extrapolation {\n 'worklet';\n\n return (\n value === Extrapolation.EXTEND ||\n value === Extrapolation.CLAMP ||\n value === Extrapolation.IDENTITY\n );\n}\n\n// validates extrapolations type\n// if type is correct, converts it to ExtrapolationConfig\nfunction validateType(type: ExtrapolationType): RequiredExtrapolationConfig {\n 'worklet';\n // initialize extrapolationConfig with default extrapolation\n const extrapolationConfig: RequiredExtrapolationConfig = {\n extrapolateLeft: Extrapolation.EXTEND,\n extrapolateRight: Extrapolation.EXTEND,\n };\n\n if (!type) {\n return extrapolationConfig;\n }\n\n if (typeof type === 'string') {\n if (!isExtrapolate(type)) {\n throw new Error(\n `Reanimated: not supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], \"clamp\")`\n );\n }\n extrapolationConfig.extrapolateLeft = type;\n extrapolationConfig.extrapolateRight = type;\n return extrapolationConfig;\n }\n\n // otherwise type is extrapolation config object\n if (\n (type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft)) ||\n (type.extrapolateRight && !isExtrapolate(type.extrapolateRight))\n ) {\n throw new Error(\n `Reanimated: not supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], {\n extrapolateLeft: Extrapolation.CLAMP,\n extrapolateRight: Extrapolation.IDENTITY\n }})`\n );\n }\n\n Object.assign(extrapolationConfig, type);\n return extrapolationConfig;\n}\n\nfunction internalInterpolate(\n x: number,\n narrowedInput: InterpolationNarrowedInput,\n extrapolationConfig: RequiredExtrapolationConfig\n) {\n 'worklet';\n const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =\n narrowedInput;\n if (rightEdgeInput - leftEdgeInput === 0) return leftEdgeOutput;\n const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);\n const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);\n const coef = rightEdgeOutput >= leftEdgeOutput ? 1 : -1;\n\n if (coef * val < coef * leftEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateLeft,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n } else if (coef * val > coef * rightEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateRight,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n }\n\n return val;\n}\n\n// TODO: support default values in worklets:\n// e.g. function interpolate(x, input, output, type = Extrapolatation.CLAMP)\nexport function interpolate(\n x: number,\n input: readonly number[],\n output: readonly number[],\n type?: ExtrapolationType\n): number {\n 'worklet';\n if (input.length < 2 || output.length < 2) {\n throw Error(\n 'Interpolation input and output should contain at least two values.'\n );\n }\n\n const extrapolationConfig = validateType(type);\n const length = input.length;\n const narrowedInput: InterpolationNarrowedInput = {\n leftEdgeInput: input[0],\n rightEdgeInput: input[1],\n leftEdgeOutput: output[0],\n rightEdgeOutput: output[1],\n };\n if (length > 2) {\n if (x > input[length - 1]) {\n narrowedInput.leftEdgeInput = input[length - 2];\n narrowedInput.rightEdgeInput = input[length - 1];\n narrowedInput.leftEdgeOutput = output[length - 2];\n narrowedInput.rightEdgeOutput = output[length - 1];\n } else {\n for (let i = 1; i < length; ++i) {\n if (x <= input[i]) {\n narrowedInput.leftEdgeInput = input[i - 1];\n narrowedInput.rightEdgeInput = input[i];\n narrowedInput.leftEdgeOutput = output[i - 1];\n narrowedInput.rightEdgeOutput = output[i];\n break;\n }\n }\n }\n }\n\n return internalInterpolate(x, narrowedInput, extrapolationConfig);\n}\n"],"mappings":";;;;;;;IAAYA,a;;;WAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;GAAAA,a,6BAAAA,a;;AA6BZ,SAASC,MAAT,CACEC,IADF,EAEEC,IAFF,EAGEC,GAHF,EAIEC,cAJF,EAKEC,eALF,EAMEC,CANF,EAOU;EACR;;EAEA,QAAQL,IAAR;IACE,KAAKF,aAAa,CAACQ,QAAnB;MACE,OAAOD,CAAP;;IACF,KAAKP,aAAa,CAACS,KAAnB;MACE,IAAIN,IAAI,GAAGC,GAAP,GAAaD,IAAI,GAAGE,cAAxB,EAAwC;QACtC,OAAOA,cAAP;MACD;;MACD,OAAOC,eAAP;;IACF,KAAKN,aAAa,CAACU,MAAnB;IACA;MACE,OAAON,GAAP;EA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B,CAAlD;;EAMA,IAAIC,MAAM,GAAG,CAAb,EAAgB;IACd,IAAIrB,CAAC,GAAGmB,KAAK,CAACE,MAAM,GAAG,CAAV,CAAb,EAA2B;MACzBP,aAAa,CAACC,aAAd,GAA8BI,KAAK,CAACE,MAAM,GAAG,CAAV,CAAnC;MACAP,aAAa,CAACE,cAAd,GAA+BG,KAAK,CAACE,MAAM,GAAG,CAAV,CAApC;MACAP,aAAa,CAAChB,cAAd,GAA+BsB,MAAM,CAACC,MAAM,GAAG,CAAV,CAArC;MACAP,aAAa,CAACf,eAAd,GAAgCqB,MAAM,CAACC,MAAM,GAAG,CAAV,CAAtC;IACD,CALD,MAKO;MACL,KAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,MAApB,EAA4B,EAAEC,CAA9B,EAAiC;QAC/B,IAAItB,CAAC,IAAImB,KAAK,CAACG,CAAD,CAAd,EAAmB;UACjBR,aAAa,CAACC,aAAd,GAA8BI,KAAK,CAACG,CAAC,GAAG,CAAL,CAAnC;UACAR,aAAa,CAACE,cAAd,GAA+BG,KAAK,CAACG,CAAD,CAApC;UACAR,aAAa,CAAChB,cAAd,GAA+BsB,MAAM,CAACE,CAAC,GAAG,CAAL,CAArC;UACAR,aAAa,CAACf,eAAd,GAAgCqB,MAAM,CAACE,CAAD,CAAtC;UACA;QACD;MACF;IACF;EACF;;EAED,OAAOT,mBAAmB,CAACb,CAAD,EAAIc,aAAJ,EAAmBP,mBAAnB,CAA1B;AACD"}
1
+ {"version":3,"names":["Extrapolation","exports","getVal","type","coef","val","leftEdgeOutput","rightEdgeOutput","x","IDENTITY","CLAMP","EXTEND","isExtrapolate","value","validateType","extrapolationConfig","extrapolateLeft","extrapolateRight","Error","Object","assign","internalInterpolate","narrowedInput","leftEdgeInput","rightEdgeInput","progress","interpolate","input","output","length","i"],"sources":["interpolation.ts"],"sourcesContent":["export enum Extrapolation {\n IDENTITY = 'identity',\n CLAMP = 'clamp',\n EXTEND = 'extend',\n}\n\ninterface InterpolationNarrowedInput {\n leftEdgeInput: number;\n rightEdgeInput: number;\n leftEdgeOutput: number;\n rightEdgeOutput: number;\n}\n\nexport interface ExtrapolationConfig {\n extrapolateLeft?: Extrapolation | string;\n extrapolateRight?: Extrapolation | string;\n}\n\ninterface RequiredExtrapolationConfig {\n extrapolateLeft: Extrapolation;\n extrapolateRight: Extrapolation;\n}\n\nexport type ExtrapolationType =\n | ExtrapolationConfig\n | Extrapolation\n | string\n | undefined;\n\nfunction getVal(\n type: Extrapolation,\n coef: number,\n val: number,\n leftEdgeOutput: number,\n rightEdgeOutput: number,\n x: number\n): number {\n 'worklet';\n\n switch (type) {\n case Extrapolation.IDENTITY:\n return x;\n case Extrapolation.CLAMP:\n if (coef * val < coef * leftEdgeOutput) {\n return leftEdgeOutput;\n }\n return rightEdgeOutput;\n case Extrapolation.EXTEND:\n default:\n return val;\n }\n}\n\nfunction isExtrapolate(value: string): value is Extrapolation {\n 'worklet';\n\n return (\n value === Extrapolation.EXTEND ||\n value === Extrapolation.CLAMP ||\n value === Extrapolation.IDENTITY\n );\n}\n\n// validates extrapolations type\n// if type is correct, converts it to ExtrapolationConfig\nfunction validateType(type: ExtrapolationType): RequiredExtrapolationConfig {\n 'worklet';\n // initialize extrapolationConfig with default extrapolation\n const extrapolationConfig: RequiredExtrapolationConfig = {\n extrapolateLeft: Extrapolation.EXTEND,\n extrapolateRight: Extrapolation.EXTEND,\n };\n\n if (!type) {\n return extrapolationConfig;\n }\n\n if (typeof type === 'string') {\n if (!isExtrapolate(type)) {\n throw new Error(\n `Reanimated: not supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], \"clamp\")`\n );\n }\n extrapolationConfig.extrapolateLeft = type;\n extrapolationConfig.extrapolateRight = type;\n return extrapolationConfig;\n }\n\n // otherwise type is extrapolation config object\n if (\n (type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft)) ||\n (type.extrapolateRight && !isExtrapolate(type.extrapolateRight))\n ) {\n throw new Error(\n `Reanimated: not supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], {\n extrapolateLeft: Extrapolation.CLAMP,\n extrapolateRight: Extrapolation.IDENTITY\n }})`\n );\n }\n\n Object.assign(extrapolationConfig, type);\n return extrapolationConfig;\n}\n\nfunction internalInterpolate(\n x: number,\n narrowedInput: InterpolationNarrowedInput,\n extrapolationConfig: RequiredExtrapolationConfig\n) {\n 'worklet';\n const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =\n narrowedInput;\n if (rightEdgeInput - leftEdgeInput === 0) return leftEdgeOutput;\n const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);\n const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);\n const coef = rightEdgeOutput >= leftEdgeOutput ? 1 : -1;\n\n if (coef * val < coef * leftEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateLeft,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n } else if (coef * val > coef * rightEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateRight,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n }\n\n return val;\n}\n\n// TODO: support default values in worklets:\n// e.g. function interpolate(x, input, output, type = Extrapolatation.CLAMP)\nexport function interpolate(\n x: number,\n input: readonly number[],\n output: readonly number[],\n type?: ExtrapolationType\n): number {\n 'worklet';\n if (input.length < 2 || output.length < 2) {\n throw Error(\n 'Interpolation input and output should contain at least two values.'\n );\n }\n\n const extrapolationConfig = validateType(type);\n const length = input.length;\n const narrowedInput: InterpolationNarrowedInput = {\n leftEdgeInput: input[0],\n rightEdgeInput: input[1],\n leftEdgeOutput: output[0],\n rightEdgeOutput: output[1],\n };\n if (length > 2) {\n if (x > input[length - 1]) {\n narrowedInput.leftEdgeInput = input[length - 2];\n narrowedInput.rightEdgeInput = input[length - 1];\n narrowedInput.leftEdgeOutput = output[length - 2];\n narrowedInput.rightEdgeOutput = output[length - 1];\n } else {\n for (let i = 1; i < length; ++i) {\n if (x <= input[i]) {\n narrowedInput.leftEdgeInput = input[i - 1];\n narrowedInput.rightEdgeInput = input[i];\n narrowedInput.leftEdgeOutput = output[i - 1];\n narrowedInput.rightEdgeOutput = output[i];\n break;\n }\n }\n }\n }\n\n return internalInterpolate(x, narrowedInput, extrapolationConfig);\n}\n"],"mappings":";;;;;;;IAAYA,aAAa,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;AAAAC,OAAA,CAAAD,aAAA,GAAAA,aAAA;AA6BzB,SAASE,MAAMA,CACbC,IAAmB,EACnBC,IAAY,EACZC,GAAW,EACXC,cAAsB,EACtBC,eAAuB,EACvBC,CAAS,EACD;EACR,SAAS;;EAET,QAAQL,IAAI;IACV,KAAKH,aAAa,CAACS,QAAQ;MACzB,OAAOD,CAAC;IACV,KAAKR,aAAa,CAACU,KAAK;MACtB,IAAIN,IAAI,GAAGC,GAAG,GAAGD,IAAI,GAAGE,cAAc,EAAE;QACtC,OAAOA,cAAc;MACvB;MACA,OAAOC,eAAe;IACxB,KAAKP,aAAa,CAACW,MAAM;IACzB;MACE,OAAON,GAAG;EAAC;AAEjB;AAEA,SAASO,aAAaA,CAACC,KAAa,EAA0B;EAC5D,SAAS;;EAET,OACEA,KAAK,KAAKb,aAAa,CAACW,MAAM,IAC9BE,KAAK,KAAKb,aAAa,CAACU,KAAK,IAC7BG,KAAK,KAAKb,aAAa,CAACS,QAAQ;AAEpC;;AAEA;AACA;AACA,SAASK,YAAYA,CAACX,IAAuB,EAA+B;EAC1E,SAAS;;EACT;EACA,MAAMY,mBAAgD,GAAG;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,MAAM,GAAG,CAAC,CAAC;MACjDP,aAAa,CAACf,eAAe,GAAGqB,MAAM,CAACC,MAAM,GAAG,CAAC,CAAC;IACpD,CAAC,MAAM;MACL,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,MAAM,EAAE,EAAEC,CAAC,EAAE;QAC/B,IAAItB,CAAC,IAAImB,KAAK,CAACG,CAAC,CAAC,EAAE;UACjBR,aAAa,CAACC,aAAa,GAAGI,KAAK,CAACG,CAAC,GAAG,CAAC,CAAC;UAC1CR,aAAa,CAACE,cAAc,GAAGG,KAAK,CAACG,CAAC,CAAC;UACvCR,aAAa,CAAChB,cAAc,GAAGsB,MAAM,CAACE,CAAC,GAAG,CAAC,CAAC;UAC5CR,aAAa,CAACf,eAAe,GAAGqB,MAAM,CAACE,CAAC,CAAC;UACzC;QACF;MACF;IACF;EACF;EAEA,OAAOT,mBAAmB,CAACb,CAAC,EAAEc,aAAa,EAAEP,mBAAmB,CAAC;AACnE"}
@@ -6,30 +6,29 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.withReanimatedTimer = exports.setUpTests = exports.getAnimatedStyle = exports.advanceAnimationByTime = exports.advanceAnimationByFrame = void 0;
7
7
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
8
8
  // @ts-nocheck
9
+
9
10
  let config = {
10
11
  fps: 60
11
12
  };
12
-
13
13
  const isAnimatedStyle = style => {
14
14
  return !!style.animatedStyle;
15
15
  };
16
-
17
16
  const getAnimatedStyleFromObject = style => {
18
17
  return style.animatedStyle.current.value;
19
18
  };
20
-
21
19
  const getCurrentStyle = received => {
22
20
  const styleObject = received.props.style;
23
21
  let currentStyle = {};
24
-
25
22
  if (Array.isArray(styleObject)) {
26
23
  received.props.style.forEach(style => {
27
24
  if (isAnimatedStyle(style)) {
28
- currentStyle = { ...currentStyle,
25
+ currentStyle = {
26
+ ...currentStyle,
29
27
  ...getAnimatedStyleFromObject(style)
30
28
  };
31
29
  } else {
32
- currentStyle = { ...currentStyle,
30
+ currentStyle = {
31
+ ...currentStyle,
33
32
  ...style
34
33
  };
35
34
  }
@@ -38,19 +37,17 @@ const getCurrentStyle = received => {
38
37
  if (isAnimatedStyle(styleObject)) {
39
38
  currentStyle = getAnimatedStyleFromObject(styleObject);
40
39
  } else {
41
- currentStyle = { ...styleObject,
40
+ currentStyle = {
41
+ ...styleObject,
42
42
  ...received.props.animatedStyle.value
43
43
  };
44
44
  }
45
45
  }
46
-
47
46
  return currentStyle;
48
47
  };
49
-
50
48
  const checkEqual = (currentStyle, expectStyle) => {
51
49
  if (Array.isArray(expectStyle)) {
52
50
  if (expectStyle.length !== currentStyle.length) return false;
53
-
54
51
  for (let i = 0; i < currentStyle.length; i++) {
55
52
  if (!checkEqual(currentStyle[i], expectStyle[i])) {
56
53
  return false;
@@ -65,14 +62,11 @@ const checkEqual = (currentStyle, expectStyle) => {
65
62
  } else {
66
63
  return currentStyle === expectStyle;
67
64
  }
68
-
69
65
  return true;
70
66
  };
71
-
72
67
  const findStyleDiff = (current, expect, requireAllMatch) => {
73
68
  const diffs = [];
74
69
  let isEqual = true;
75
-
76
70
  for (const property in expect) {
77
71
  if (!checkEqual(current[property], expect[property])) {
78
72
  isEqual = false;
@@ -83,10 +77,8 @@ const findStyleDiff = (current, expect, requireAllMatch) => {
83
77
  });
84
78
  }
85
79
  }
86
-
87
80
  if (requireAllMatch && Object.keys(current).length !== Object.keys(expect).length) {
88
81
  isEqual = false;
89
-
90
82
  for (const property in current) {
91
83
  if (expect[property] === undefined) {
92
84
  diffs.push({
@@ -97,13 +89,11 @@ const findStyleDiff = (current, expect, requireAllMatch) => {
97
89
  }
98
90
  }
99
91
  }
100
-
101
92
  return {
102
93
  isEqual,
103
94
  diffs
104
95
  };
105
96
  };
106
-
107
97
  const compareStyle = (received, expectedStyle, config) => {
108
98
  if (!received.props.style) {
109
99
  return {
@@ -111,7 +101,6 @@ const compareStyle = (received, expectedStyle, config) => {
111
101
  pass: false
112
102
  };
113
103
  }
114
-
115
104
  const {
116
105
  exact
117
106
  } = config;
@@ -120,14 +109,12 @@ const compareStyle = (received, expectedStyle, config) => {
120
109
  isEqual,
121
110
  diffs
122
111
  } = findStyleDiff(currentStyle, expectedStyle, exact);
123
-
124
112
  if (isEqual) {
125
113
  return {
126
114
  message: () => 'ok',
127
115
  pass: true
128
116
  };
129
117
  }
130
-
131
118
  const currentStyleStr = JSON.stringify(currentStyle);
132
119
  const expectedStyleStr = JSON.stringify(expectedStyle);
133
120
  const differences = diffs.map(diff => `- '${diff.property}' should be ${JSON.stringify(diff.expect)}, but is ${JSON.stringify(diff.current)}`).join('\n');
@@ -136,71 +123,55 @@ const compareStyle = (received, expectedStyle, config) => {
136
123
  pass: false
137
124
  };
138
125
  };
139
-
140
126
  let frameTime = 1000 / config.fps;
141
-
142
127
  const beforeTest = () => {
143
128
  jest.useFakeTimers();
144
129
  };
145
-
146
130
  const afterTest = () => {
147
131
  jest.runOnlyPendingTimers();
148
132
  jest.useRealTimers();
149
133
  };
150
-
151
134
  const withReanimatedTimer = animationTest => {
152
135
  console.warn('This method is deprecated, you should define your own before and after test hooks to enable jest.useFakeTimers(). Check out the documentation for details on testing');
153
136
  beforeTest();
154
137
  animationTest();
155
138
  afterTest();
156
139
  };
157
-
158
140
  exports.withReanimatedTimer = withReanimatedTimer;
159
-
160
141
  const advanceAnimationByTime = function () {
161
142
  let time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : frameTime;
162
143
  console.warn('This method is deprecated, use jest.advanceTimersByTime directly');
163
144
  jest.advanceTimersByTime(time);
164
145
  jest.runOnlyPendingTimers();
165
146
  };
166
-
167
147
  exports.advanceAnimationByTime = advanceAnimationByTime;
168
-
169
148
  const advanceAnimationByFrame = count => {
170
149
  console.warn('This method is deprecated, use jest.advanceTimersByTime directly');
171
150
  jest.advanceTimersByTime(count * frameTime);
172
151
  jest.runOnlyPendingTimers();
173
152
  };
174
-
175
153
  exports.advanceAnimationByFrame = advanceAnimationByFrame;
176
-
177
154
  const setUpTests = function () {
178
155
  let userConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
179
156
  let expect = global.expect;
180
-
181
157
  if (expect === undefined) {
182
158
  const expectModule = require('expect');
183
-
184
- expect = expectModule; // Starting from Jest 28, "expect" package uses named exports instead of default export.
159
+ expect = expectModule;
160
+ // Starting from Jest 28, "expect" package uses named exports instead of default export.
185
161
  // So, requiring "expect" package doesn't give direct access to "expect" function anymore.
186
162
  // It gives access to the module object instead.
187
163
  // We use this info to detect if the project uses Jest 28 or higher.
188
-
189
164
  if (typeof expect === 'object') {
190
165
  const jestGlobals = require('@jest/globals');
191
-
192
166
  expect = jestGlobals.expect;
193
167
  }
194
-
195
168
  if (expect === undefined || expect.extend === undefined) {
196
169
  expect = expectModule.default;
197
170
  }
198
171
  }
199
-
200
- require('setimmediate');
201
-
202
172
  frameTime = Math.round(1000 / config.fps);
203
- config = { ...config,
173
+ config = {
174
+ ...config,
204
175
  ...userConfig
205
176
  };
206
177
  expect.extend({
@@ -208,15 +179,11 @@ const setUpTests = function () {
208
179
  let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
209
180
  return compareStyle(received, expectedStyle, config);
210
181
  }
211
-
212
182
  });
213
183
  };
214
-
215
184
  exports.setUpTests = setUpTests;
216
-
217
185
  const getAnimatedStyle = received => {
218
186
  return getCurrentStyle(received);
219
187
  };
220
-
221
188
  exports.getAnimatedStyle = getAnimatedStyle;
222
189
  //# sourceMappingURL=jestUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["config","fps","isAnimatedStyle","style","animatedStyle","getAnimatedStyleFromObject","current","value","getCurrentStyle","received","styleObject","props","currentStyle","Array","isArray","forEach","checkEqual","expectStyle","length","i","property","findStyleDiff","expect","requireAllMatch","diffs","isEqual","push","Object","keys","undefined","compareStyle","expectedStyle","message","pass","exact","currentStyleStr","JSON","stringify","expectedStyleStr","differences","map","diff","join","frameTime","beforeTest","jest","useFakeTimers","afterTest","runOnlyPendingTimers","useRealTimers","withReanimatedTimer","animationTest","console","warn","advanceAnimationByTime","time","advanceTimersByTime","advanceAnimationByFrame","count","setUpTests","userConfig","global","expectModule","require","jestGlobals","extend","default","Math","round","toHaveAnimatedStyle","getAnimatedStyle"],"sources":["jestUtils.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R> {\n toHaveAnimatedStyle(\n style: Record<string, unknown>[] | Record<string, unknown>\n ): R;\n }\n }\n}\n\nlet config = {\n fps: 60,\n};\n\nconst isAnimatedStyle = (style) => {\n return !!style.animatedStyle;\n};\n\nconst getAnimatedStyleFromObject = (style) => {\n return style.animatedStyle.current.value;\n};\n\nconst getCurrentStyle = (received) => {\n const styleObject = received.props.style;\n let currentStyle = {};\n if (Array.isArray(styleObject)) {\n received.props.style.forEach((style) => {\n if (isAnimatedStyle(style)) {\n currentStyle = {\n ...currentStyle,\n ...getAnimatedStyleFromObject(style),\n };\n } else {\n currentStyle = {\n ...currentStyle,\n ...style,\n };\n }\n });\n } else {\n if (isAnimatedStyle(styleObject)) {\n currentStyle = getAnimatedStyleFromObject(styleObject);\n } else {\n currentStyle = {\n ...styleObject,\n ...received.props.animatedStyle.value,\n };\n }\n }\n return currentStyle;\n};\n\nconst checkEqual = (currentStyle, expectStyle) => {\n if (Array.isArray(expectStyle)) {\n if (expectStyle.length !== currentStyle.length) return false;\n for (let i = 0; i < currentStyle.length; i++) {\n if (!checkEqual(currentStyle[i], expectStyle[i])) {\n return false;\n }\n }\n } else if (typeof currentStyle === 'object' && currentStyle) {\n for (const property in expectStyle) {\n if (!checkEqual(currentStyle[property], expectStyle[property])) {\n return false;\n }\n }\n } else {\n return currentStyle === expectStyle;\n }\n return true;\n};\n\nconst findStyleDiff = (current, expect, requireAllMatch) => {\n const diffs = [];\n let isEqual = true;\n for (const property in expect) {\n if (!checkEqual(current[property], expect[property])) {\n isEqual = false;\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n\n if (\n requireAllMatch &&\n Object.keys(current).length !== Object.keys(expect).length\n ) {\n isEqual = false;\n for (const property in current) {\n if (expect[property] === undefined) {\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n }\n\n return { isEqual, diffs };\n};\n\nconst compareStyle = (received, expectedStyle, config) => {\n if (!received.props.style) {\n return { message: () => message, pass: false };\n }\n const { exact } = config;\n const currentStyle = getCurrentStyle(received);\n const { isEqual, diffs } = findStyleDiff(currentStyle, expectedStyle, exact);\n\n if (isEqual) {\n return { message: () => 'ok', pass: true };\n }\n\n const currentStyleStr = JSON.stringify(currentStyle);\n const expectedStyleStr = JSON.stringify(expectedStyle);\n const differences = diffs\n .map(\n (diff) =>\n `- '${diff.property}' should be ${JSON.stringify(\n diff.expect\n )}, but is ${JSON.stringify(diff.current)}`\n )\n .join('\\n');\n\n return {\n message: () =>\n `Expected: ${expectedStyleStr}\\nReceived: ${currentStyleStr}\\n\\nDifferences:\\n${differences}`,\n pass: false,\n };\n};\n\nlet frameTime = 1000 / config.fps;\n\nconst beforeTest = () => {\n jest.useFakeTimers();\n};\n\nconst afterTest = () => {\n jest.runOnlyPendingTimers();\n jest.useRealTimers();\n};\n\nexport const withReanimatedTimer = (animationTest) => {\n console.warn(\n 'This method is deprecated, you should define your own before and after test hooks to enable jest.useFakeTimers(). Check out the documentation for details on testing'\n );\n beforeTest();\n animationTest();\n afterTest();\n};\n\nexport const advanceAnimationByTime = (time = frameTime) => {\n console.warn(\n 'This method is deprecated, use jest.advanceTimersByTime directly'\n );\n jest.advanceTimersByTime(time);\n jest.runOnlyPendingTimers();\n};\n\nexport const advanceAnimationByFrame = (count) => {\n console.warn(\n 'This method is deprecated, use jest.advanceTimersByTime directly'\n );\n jest.advanceTimersByTime(count * frameTime);\n jest.runOnlyPendingTimers();\n};\n\nexport const setUpTests = (userConfig = {}) => {\n let expect = global.expect;\n if (expect === undefined) {\n const expectModule = require('expect');\n expect = expectModule;\n // Starting from Jest 28, \"expect\" package uses named exports instead of default export.\n // So, requiring \"expect\" package doesn't give direct access to \"expect\" function anymore.\n // It gives access to the module object instead.\n // We use this info to detect if the project uses Jest 28 or higher.\n if (typeof expect === 'object') {\n const jestGlobals = require('@jest/globals');\n expect = jestGlobals.expect;\n }\n if (expect === undefined || expect.extend === undefined) {\n expect = expectModule.default;\n }\n }\n\n require('setimmediate');\n frameTime = Math.round(1000 / config.fps);\n\n config = {\n ...config,\n ...userConfig,\n };\n\n expect.extend({\n toHaveAnimatedStyle(received, expectedStyle, config = {}) {\n return compareStyle(received, expectedStyle, config);\n },\n });\n};\n\nexport const getAnimatedStyle = (received) => {\n return getCurrentStyle(received);\n};\n"],"mappings":";;;;;;AAAA;AACA;AAYA,IAAIA,MAAM,GAAG;EACXC,GAAG,EAAE;AADM,CAAb;;AAIA,MAAMC,eAAe,GAAIC,KAAD,IAAW;EACjC,OAAO,CAAC,CAACA,KAAK,CAACC,aAAf;AACD,CAFD;;AAIA,MAAMC,0BAA0B,GAAIF,KAAD,IAAW;EAC5C,OAAOA,KAAK,CAACC,aAAN,CAAoBE,OAApB,CAA4BC,KAAnC;AACD,CAFD;;AAIA,MAAMC,eAAe,GAAIC,QAAD,IAAc;EACpC,MAAMC,WAAW,GAAGD,QAAQ,CAACE,KAAT,CAAeR,KAAnC;EACA,IAAIS,YAAY,GAAG,EAAnB;;EACA,IAAIC,KAAK,CAACC,OAAN,CAAcJ,WAAd,CAAJ,EAAgC;IAC9BD,QAAQ,CAACE,KAAT,CAAeR,KAAf,CAAqBY,OAArB,CAA8BZ,KAAD,IAAW;MACtC,IAAID,eAAe,CAACC,KAAD,CAAnB,EAA4B;QAC1BS,YAAY,GAAG,EACb,GAAGA,YADU;UAEb,GAAGP,0BAA0B,CAACF,KAAD;QAFhB,CAAf;MAID,CALD,MAKO;QACLS,YAAY,GAAG,EACb,GAAGA,YADU;UAEb,GAAGT;QAF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F;EAGAR,IAAI,CAACW,mBAAL,CAAyBE,KAAK,GAAGf,SAAjC;EACAE,IAAI,CAACG,oBAAL;AACD,CANM;;;;AAQA,MAAMW,UAAU,GAAG,YAAqB;EAAA,IAApBC,UAAoB,uEAAP,EAAO;EAC7C,IAAItC,MAAM,GAAGuC,MAAM,CAACvC,MAApB;;EACA,IAAIA,MAAM,KAAKO,SAAf,EAA0B;IACxB,MAAMiC,YAAY,GAAGC,OAAO,CAAC,QAAD,CAA5B;;IACAzC,MAAM,GAAGwC,YAAT,CAFwB,CAGxB;IACA;IACA;IACA;;IACA,IAAI,OAAOxC,MAAP,KAAkB,QAAtB,EAAgC;MAC9B,MAAM0C,WAAW,GAAGD,OAAO,CAAC,eAAD,CAA3B;;MACAzC,MAAM,GAAG0C,WAAW,CAAC1C,MAArB;IACD;;IACD,IAAIA,MAAM,KAAKO,SAAX,IAAwBP,MAAM,CAAC2C,MAAP,KAAkBpC,SAA9C,EAAyD;MACvDP,MAAM,GAAGwC,YAAY,CAACI,OAAtB;IACD;EACF;;EAEDH,OAAO,CAAC,cAAD,CAAP;;EACApB,SAAS,GAAGwB,IAAI,CAACC,KAAL,CAAW,OAAOpE,MAAM,CAACC,GAAzB,CAAZ;EAEAD,MAAM,GAAG,EACP,GAAGA,MADI;IAEP,GAAG4D;EAFI,CAAT;EAKAtC,MAAM,CAAC2C,MAAP,CAAc;IACZI,mBAAmB,CAAC5D,QAAD,EAAWsB,aAAX,EAAuC;MAAA,IAAb/B,MAAa,uEAAJ,EAAI;MACxD,OAAO8B,YAAY,CAACrB,QAAD,EAAWsB,aAAX,EAA0B/B,MAA1B,CAAnB;IACD;;EAHW,CAAd;AAKD,CA/BM;;;;AAiCA,MAAMsE,gBAAgB,GAAI7D,QAAD,IAAc;EAC5C,OAAOD,eAAe,CAACC,QAAD,CAAtB;AACD,CAFM"}
1
+ {"version":3,"names":["config","fps","isAnimatedStyle","style","animatedStyle","getAnimatedStyleFromObject","current","value","getCurrentStyle","received","styleObject","props","currentStyle","Array","isArray","forEach","checkEqual","expectStyle","length","i","property","findStyleDiff","expect","requireAllMatch","diffs","isEqual","push","Object","keys","undefined","compareStyle","expectedStyle","message","pass","exact","currentStyleStr","JSON","stringify","expectedStyleStr","differences","map","diff","join","frameTime","beforeTest","jest","useFakeTimers","afterTest","runOnlyPendingTimers","useRealTimers","withReanimatedTimer","animationTest","console","warn","exports","advanceAnimationByTime","time","arguments","advanceTimersByTime","advanceAnimationByFrame","count","setUpTests","userConfig","global","expectModule","require","jestGlobals","extend","default","Math","round","toHaveAnimatedStyle","getAnimatedStyle"],"sources":["jestUtils.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R> {\n toHaveAnimatedStyle(\n style: Record<string, unknown>[] | Record<string, unknown>\n ): R;\n }\n }\n}\n\nlet config = {\n fps: 60,\n};\n\nconst isAnimatedStyle = (style) => {\n return !!style.animatedStyle;\n};\n\nconst getAnimatedStyleFromObject = (style) => {\n return style.animatedStyle.current.value;\n};\n\nconst getCurrentStyle = (received) => {\n const styleObject = received.props.style;\n let currentStyle = {};\n if (Array.isArray(styleObject)) {\n received.props.style.forEach((style) => {\n if (isAnimatedStyle(style)) {\n currentStyle = {\n ...currentStyle,\n ...getAnimatedStyleFromObject(style),\n };\n } else {\n currentStyle = {\n ...currentStyle,\n ...style,\n };\n }\n });\n } else {\n if (isAnimatedStyle(styleObject)) {\n currentStyle = getAnimatedStyleFromObject(styleObject);\n } else {\n currentStyle = {\n ...styleObject,\n ...received.props.animatedStyle.value,\n };\n }\n }\n return currentStyle;\n};\n\nconst checkEqual = (currentStyle, expectStyle) => {\n if (Array.isArray(expectStyle)) {\n if (expectStyle.length !== currentStyle.length) return false;\n for (let i = 0; i < currentStyle.length; i++) {\n if (!checkEqual(currentStyle[i], expectStyle[i])) {\n return false;\n }\n }\n } else if (typeof currentStyle === 'object' && currentStyle) {\n for (const property in expectStyle) {\n if (!checkEqual(currentStyle[property], expectStyle[property])) {\n return false;\n }\n }\n } else {\n return currentStyle === expectStyle;\n }\n return true;\n};\n\nconst findStyleDiff = (current, expect, requireAllMatch) => {\n const diffs = [];\n let isEqual = true;\n for (const property in expect) {\n if (!checkEqual(current[property], expect[property])) {\n isEqual = false;\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n\n if (\n requireAllMatch &&\n Object.keys(current).length !== Object.keys(expect).length\n ) {\n isEqual = false;\n for (const property in current) {\n if (expect[property] === undefined) {\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n }\n\n return { isEqual, diffs };\n};\n\nconst compareStyle = (received, expectedStyle, config) => {\n if (!received.props.style) {\n return { message: () => message, pass: false };\n }\n const { exact } = config;\n const currentStyle = getCurrentStyle(received);\n const { isEqual, diffs } = findStyleDiff(currentStyle, expectedStyle, exact);\n\n if (isEqual) {\n return { message: () => 'ok', pass: true };\n }\n\n const currentStyleStr = JSON.stringify(currentStyle);\n const expectedStyleStr = JSON.stringify(expectedStyle);\n const differences = diffs\n .map(\n (diff) =>\n `- '${diff.property}' should be ${JSON.stringify(\n diff.expect\n )}, but is ${JSON.stringify(diff.current)}`\n )\n .join('\\n');\n\n return {\n message: () =>\n `Expected: ${expectedStyleStr}\\nReceived: ${currentStyleStr}\\n\\nDifferences:\\n${differences}`,\n pass: false,\n };\n};\n\nlet frameTime = 1000 / config.fps;\n\nconst beforeTest = () => {\n jest.useFakeTimers();\n};\n\nconst afterTest = () => {\n jest.runOnlyPendingTimers();\n jest.useRealTimers();\n};\n\nexport const withReanimatedTimer = (animationTest) => {\n console.warn(\n 'This method is deprecated, you should define your own before and after test hooks to enable jest.useFakeTimers(). Check out the documentation for details on testing'\n );\n beforeTest();\n animationTest();\n afterTest();\n};\n\nexport const advanceAnimationByTime = (time = frameTime) => {\n console.warn(\n 'This method is deprecated, use jest.advanceTimersByTime directly'\n );\n jest.advanceTimersByTime(time);\n jest.runOnlyPendingTimers();\n};\n\nexport const advanceAnimationByFrame = (count) => {\n console.warn(\n 'This method is deprecated, use jest.advanceTimersByTime directly'\n );\n jest.advanceTimersByTime(count * frameTime);\n jest.runOnlyPendingTimers();\n};\n\nexport const setUpTests = (userConfig = {}) => {\n let expect = global.expect;\n if (expect === undefined) {\n const expectModule = require('expect');\n expect = expectModule;\n // Starting from Jest 28, \"expect\" package uses named exports instead of default export.\n // So, requiring \"expect\" package doesn't give direct access to \"expect\" function anymore.\n // It gives access to the module object instead.\n // We use this info to detect if the project uses Jest 28 or higher.\n if (typeof expect === 'object') {\n const jestGlobals = require('@jest/globals');\n expect = jestGlobals.expect;\n }\n if (expect === undefined || expect.extend === undefined) {\n expect = expectModule.default;\n }\n }\n\n frameTime = Math.round(1000 / config.fps);\n\n config = {\n ...config,\n ...userConfig,\n };\n\n expect.extend({\n toHaveAnimatedStyle(received, expectedStyle, config = {}) {\n return compareStyle(received, expectedStyle, config);\n },\n });\n};\n\nexport const getAnimatedStyle = (received) => {\n return getCurrentStyle(received);\n};\n"],"mappings":";;;;;;AAAA;AACA;;AAYA,IAAIA,MAAM,GAAG;EACXC,GAAG,EAAE;AACP,CAAC;AAED,MAAMC,eAAe,GAAIC,KAAK,IAAK;EACjC,OAAO,CAAC,CAACA,KAAK,CAACC,aAAa;AAC9B,CAAC;AAED,MAAMC,0BAA0B,GAAIF,KAAK,IAAK;EAC5C,OAAOA,KAAK,CAACC,aAAa,CAACE,OAAO,CAACC,KAAK;AAC1C,CAAC;AAED,MAAMC,eAAe,GAAIC,QAAQ,IAAK;EACpC,MAAMC,WAAW,GAAGD,QAAQ,CAACE,KAAK,CAACR,KAAK;EACxC,IAAIS,YAAY,GAAG,CAAC,CAAC;EACrB,IAAIC,KAAK,CAACC,OAAO,CAACJ,WAAW,CAAC,EAAE;IAC9BD,QAAQ,CAACE,KAAK,CAACR,KAAK,CAACY,OAAO,CAAEZ,KAAK,IAAK;MACt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ACC,KAAK,CAAC,IAAI,GAAGtE,MAAM,CAACC,GAAG,CAAC;EAEzCD,MAAM,GAAG;IACP,GAAGA,MAAM;IACT,GAAG8D;EACL,CAAC;EAEDxC,MAAM,CAAC6C,MAAM,CAAC;IACZI,mBAAmBA,CAAC9D,QAAQ,EAAEsB,aAAa,EAAe;MAAA,IAAb/B,MAAM,GAAAyD,SAAA,CAAAvC,MAAA,QAAAuC,SAAA,QAAA5B,SAAA,GAAA4B,SAAA,MAAG,CAAC,CAAC;MACtD,OAAO3B,YAAY,CAACrB,QAAQ,EAAEsB,aAAa,EAAE/B,MAAM,CAAC;IACtD;EACF,CAAC,CAAC;AACJ,CAAC;AAACsD,OAAA,CAAAO,UAAA,GAAAA,UAAA;AAEK,MAAMW,gBAAgB,GAAI/D,QAAQ,IAAK;EAC5C,OAAOD,eAAe,CAACC,QAAQ,CAAC;AAClC,CAAC;AAAC6C,OAAA,CAAAkB,gBAAA,GAAAA,gBAAA"}
@@ -4,60 +4,53 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _NativeReanimated = require("../NativeReanimated/NativeReanimated");
9
-
10
8
  var _commonTypes = require("../commonTypes");
11
-
12
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
-
9
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
11
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
14
12
  class JSReanimated extends _NativeReanimated.NativeReanimated {
15
13
  constructor() {
16
14
  super(false);
17
-
18
15
  _defineProperty(this, "nextSensorId", 0);
19
-
20
16
  _defineProperty(this, "sensors", new Map());
21
17
  }
22
-
23
18
  makeShareableClone(value) {
24
19
  return {
25
20
  __hostObjectShareableJSRef: value
26
21
  };
27
22
  }
28
-
29
- installCoreFunctions(_callGuard, _valueUnpacker) {// noop
23
+ installCoreFunctions(_callGuard, _valueUnpacker) {
24
+ // noop
30
25
  }
31
-
32
26
  scheduleOnUI(worklet) {
33
27
  // @ts-ignore web implementation has still not been updated after the rewrite, this will be addressed once the web implementation updates are ready
34
28
  requestAnimationFrame(worklet);
35
29
  }
36
-
37
30
  registerEventHandler(_eventHash, _eventHandler) {
38
31
  // noop
39
32
  return '';
40
33
  }
41
-
42
- unregisterEventHandler(_) {// noop
34
+ unregisterEventHandler(_) {
35
+ // noop
43
36
  }
44
-
45
37
  enableLayoutAnimations() {
46
- console.warn('[Reanimated] enableLayoutAnimations is not available for WEB yet');
38
+ console.warn('[Reanimated] Layout Animations are not supported on web yet.');
39
+ }
40
+ configureLayoutAnimation() {
41
+ // no-op
47
42
  }
48
-
49
43
  registerSensor(sensorType, interval, iosReferenceFrame, eventHandler) {
50
44
  if (!(this.getSensorName(sensorType) in window)) {
51
45
  return -1;
52
46
  }
53
-
54
47
  const sensor = this.initializeSensor(sensorType, interval);
55
48
  let callback;
56
-
57
49
  if (sensorType === _commonTypes.SensorType.ROTATION) {
58
50
  callback = () => {
59
- const [qw, qx, qy, qz] = sensor.quaternion; // reference: https://stackoverflow.com/questions/5782658/extracting-yaw-from-a-quaternion
51
+ const [qw, qx, qy, qz] = sensor.quaternion;
60
52
 
53
+ // reference: https://stackoverflow.com/questions/5782658/extracting-yaw-from-a-quaternion
61
54
  const yaw = Math.atan2(2.0 * (qy * qz + qw * qx), qw * qw - qx * qx - qy * qy + qz * qz);
62
55
  const pitch = Math.sin(-2.0 * (qx * qz - qw * qy));
63
56
  const roll = Math.atan2(2.0 * (qx * qy + qw * qz), qw * qw + qx * qx - qy * qy - qz * qz);
@@ -87,75 +80,58 @@ class JSReanimated extends _NativeReanimated.NativeReanimated {
87
80
  });
88
81
  };
89
82
  }
90
-
91
83
  sensor.addEventListener('reading', callback);
92
84
  sensor.start();
93
85
  this.sensors.set(this.nextSensorId, sensor);
94
86
  return this.nextSensorId++;
95
87
  }
96
-
97
88
  unregisterSensor(id) {
98
89
  const sensor = this.sensors.get(id);
99
-
100
90
  if (sensor !== undefined) {
101
91
  sensor.stop();
102
92
  this.sensors.delete(id);
103
93
  }
104
94
  }
105
-
106
95
  subscribeForKeyboardEvents(_) {
107
96
  console.warn('[Reanimated] useAnimatedKeyboard is not available on web yet.');
108
97
  return -1;
109
98
  }
110
-
111
- unsubscribeFromKeyboardEvents(_) {// noop
99
+ unsubscribeFromKeyboardEvents(_) {
100
+ // noop
112
101
  }
113
-
114
102
  initializeSensor(sensorType, interval) {
115
103
  const config = interval <= 0 ? {
116
104
  referenceFrame: 'device'
117
105
  } : {
118
106
  frequency: 1000 / interval
119
107
  };
120
-
121
108
  switch (sensorType) {
122
109
  case _commonTypes.SensorType.ACCELEROMETER:
123
110
  return new window.Accelerometer(config);
124
-
125
111
  case _commonTypes.SensorType.GYROSCOPE:
126
112
  return new window.Gyroscope(config);
127
-
128
113
  case _commonTypes.SensorType.GRAVITY:
129
114
  return new window.GravitySensor(config);
130
-
131
115
  case _commonTypes.SensorType.MAGNETIC_FIELD:
132
116
  return new window.Magnetometer(config);
133
-
134
117
  case _commonTypes.SensorType.ROTATION:
135
118
  return new window.AbsoluteOrientationSensor(config);
136
119
  }
137
120
  }
138
-
139
121
  getSensorName(sensorType) {
140
122
  switch (sensorType) {
141
123
  case _commonTypes.SensorType.ACCELEROMETER:
142
124
  return 'Accelerometer';
143
-
144
125
  case _commonTypes.SensorType.GRAVITY:
145
126
  return 'GravitySensor';
146
-
147
127
  case _commonTypes.SensorType.GYROSCOPE:
148
128
  return 'Gyroscope';
149
-
150
129
  case _commonTypes.SensorType.MAGNETIC_FIELD:
151
130
  return 'Magnetometer';
152
-
153
131
  case _commonTypes.SensorType.ROTATION:
154
132
  return 'AbsoluteOrientationSensor';
155
133
  }
156
134
  }
157
-
158
135
  }
159
-
160
136
  exports.default = JSReanimated;
161
137
  //# sourceMappingURL=JSReanimated.js.map