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
@@ -1,9 +1,10 @@
1
1
  import { defineAnimation } from './util';
2
2
  import { withTiming } from './timing';
3
3
  import { ColorProperties } from '../UpdateProps';
4
- import { processColor } from '../Colors'; // resolves path to value for nested objects
5
- // if path cannot be resolved returns undefined
4
+ import { processColor } from '../Colors';
6
5
 
6
+ // resolves path to value for nested objects
7
+ // if path cannot be resolved returns undefined
7
8
  export function resolvePath(obj, path) {
8
9
  'worklet';
9
10
 
@@ -11,24 +12,23 @@ export function resolvePath(obj, path) {
11
12
  return keys.reduce((acc, current) => {
12
13
  if (Array.isArray(acc) && typeof current === 'number') {
13
14
  return acc[current];
14
- } else if (typeof acc === 'object' && current in acc) {
15
+ } else if (acc !== null && typeof acc === 'object' && current in acc) {
15
16
  return acc[current];
16
17
  }
17
-
18
18
  return undefined;
19
19
  }, obj);
20
- } // set value at given path
20
+ }
21
+
22
+ // set value at given path
21
23
 
22
24
  export function setPath(obj, path, value) {
23
25
  'worklet';
24
26
 
25
27
  const keys = Array.isArray(path) ? path : [path];
26
28
  let currObj = obj;
27
-
28
29
  for (let i = 0; i < keys.length - 1; i++) {
29
30
  // creates entry if there isn't one
30
31
  currObj = currObj;
31
-
32
32
  if (!(keys[i] in currObj)) {
33
33
  // if next key is a number create an array
34
34
  if (typeof keys[i + 1] === 'number') {
@@ -37,10 +37,8 @@ export function setPath(obj, path, value) {
37
37
  currObj[keys[i]] = {};
38
38
  }
39
39
  }
40
-
41
40
  currObj = currObj[keys[i]];
42
41
  }
43
-
44
42
  currObj[keys[keys.length - 1]] = value;
45
43
  }
46
44
  export function withStyleAnimation(styleAnimations) {
@@ -55,10 +53,8 @@ export function withStyleAnimation(styleAnimations) {
55
53
  value: animation.styleAnimations,
56
54
  path: []
57
55
  }];
58
-
59
56
  while (entriesToCheck.length > 0) {
60
57
  const currentEntry = entriesToCheck.pop();
61
-
62
58
  if (Array.isArray(currentEntry.value)) {
63
59
  for (let index = 0; index < currentEntry.value.length; index++) {
64
60
  entriesToCheck.push({
@@ -76,43 +72,33 @@ export function withStyleAnimation(styleAnimations) {
76
72
  }
77
73
  } else {
78
74
  const currentStyleAnimation = currentEntry.value;
79
-
80
75
  if (currentStyleAnimation.finished) {
81
76
  continue;
82
77
  }
83
-
84
78
  const finished = currentStyleAnimation.onFrame(currentStyleAnimation, now);
85
-
86
79
  if (finished) {
87
80
  currentStyleAnimation.finished = true;
88
-
89
81
  if (currentStyleAnimation.callback) {
90
82
  currentStyleAnimation.callback(true);
91
83
  }
92
84
  } else {
93
85
  stillGoing = true;
94
86
  }
95
-
96
87
  if (ColorProperties.includes(currentEntry.path[0])) {
97
88
  currentStyleAnimation.current = processColor(currentStyleAnimation.current);
98
89
  }
99
-
100
90
  setPath(animation.current, currentEntry.path, currentStyleAnimation.current);
101
91
  }
102
92
  }
103
-
104
93
  return !stillGoing;
105
94
  };
106
-
107
95
  const onStart = (animation, value, now, previousAnimation) => {
108
96
  const entriesToCheck = [{
109
97
  value: styleAnimations,
110
98
  path: []
111
99
  }];
112
-
113
100
  while (entriesToCheck.length > 0) {
114
101
  const currentEntry = entriesToCheck.pop();
115
-
116
102
  if (Array.isArray(currentEntry.value)) {
117
103
  for (let index = 0; index < currentEntry.value.length; index++) {
118
104
  entriesToCheck.push({
@@ -130,18 +116,14 @@ export function withStyleAnimation(styleAnimations) {
130
116
  } else {
131
117
  const prevAnimation = resolvePath(previousAnimation === null || previousAnimation === void 0 ? void 0 : previousAnimation.styleAnimations, currentEntry.path);
132
118
  let prevVal = resolvePath(value, currentEntry.path);
133
-
134
119
  if (prevAnimation && !prevVal) {
135
120
  prevVal = prevAnimation.current;
136
121
  }
137
-
138
122
  if (prevVal === undefined) {
139
123
  console.warn(`Initial values for animation are missing for property ${currentEntry.path.join('.')}`);
140
124
  }
141
-
142
125
  setPath(animation.current, currentEntry.path, prevVal);
143
126
  let currentAnimation;
144
-
145
127
  if (typeof currentEntry.value !== 'object' || !currentEntry.value.onStart) {
146
128
  currentAnimation = withTiming(currentEntry.value, {
147
129
  duration: 0
@@ -150,19 +132,15 @@ export function withStyleAnimation(styleAnimations) {
150
132
  } else {
151
133
  currentAnimation = currentEntry.value;
152
134
  }
153
-
154
135
  currentAnimation.onStart(currentAnimation, prevVal, now, prevAnimation);
155
136
  }
156
137
  }
157
138
  };
158
-
159
139
  const callback = finished => {
160
140
  if (!finished) {
161
141
  const animationsToCheck = [styleAnimations];
162
-
163
142
  while (animationsToCheck.length > 0) {
164
143
  const currentAnimation = animationsToCheck.pop();
165
-
166
144
  if (Array.isArray(currentAnimation)) {
167
145
  for (const element of currentAnimation) {
168
146
  animationsToCheck.push(element);
@@ -173,7 +151,6 @@ export function withStyleAnimation(styleAnimations) {
173
151
  }
174
152
  } else {
175
153
  const currentStyleAnimation = currentAnimation;
176
-
177
154
  if (!currentStyleAnimation.finished && currentStyleAnimation.callback) {
178
155
  currentStyleAnimation.callback(false);
179
156
  }
@@ -181,7 +158,6 @@ export function withStyleAnimation(styleAnimations) {
181
158
  }
182
159
  }
183
160
  };
184
-
185
161
  return {
186
162
  isHigherOrder: true,
187
163
  onFrame,
@@ -1 +1 @@
1
- {"version":3,"names":["defineAnimation","withTiming","ColorProperties","processColor","resolvePath","obj","path","keys","Array","isArray","reduce","acc","current","undefined","setPath","value","currObj","i","length","withStyleAnimation","styleAnimations","onFrame","animation","now","stillGoing","entriesToCheck","currentEntry","pop","index","push","concat","key","Object","currentStyleAnimation","finished","callback","includes","onStart","previousAnimation","prevAnimation","prevVal","console","warn","join","currentAnimation","duration","animationsToCheck","element","values","isHigherOrder"],"sources":["styleAnimation.ts"],"sourcesContent":["import { defineAnimation } from './util';\nimport {\n Timestamp,\n AnimatableValue,\n AnimationObject,\n Animation,\n AnimatedStyle,\n NestedObject,\n NestedObjectValues,\n} from '../commonTypes';\nimport { StyleLayoutAnimation } from './commonTypes';\nimport { withTiming } from './timing';\nimport { ColorProperties } from '../UpdateProps';\nimport { processColor } from '../Colors';\n\n// resolves path to value for nested objects\n// if path cannot be resolved returns undefined\nexport function resolvePath<T>(\n obj: NestedObject<T>,\n path: AnimatableValue[] | AnimatableValue\n): NestedObjectValues<T> | undefined {\n 'worklet';\n const keys: AnimatableValue[] = Array.isArray(path) ? path : [path];\n return keys.reduce<NestedObjectValues<T> | undefined>((acc, current) => {\n if (Array.isArray(acc) && typeof current === 'number') {\n return acc[current];\n } else if (typeof acc === 'object' && (current as number | string) in acc) {\n return (acc as { [key: string]: NestedObjectValues<T> })[\n current as number | string\n ];\n }\n return undefined;\n }, obj);\n}\n\n// set value at given path\ntype Path = Array<string | number> | string | number;\nexport function setPath<T>(\n obj: NestedObject<T>,\n path: Path,\n value: NestedObjectValues<T>\n): void {\n 'worklet';\n const keys: Path = Array.isArray(path) ? path : [path];\n let currObj: NestedObjectValues<T> = obj;\n for (let i = 0; i < keys.length - 1; i++) {\n // creates entry if there isn't one\n currObj = currObj as { [key: string]: NestedObjectValues<T> };\n if (!(keys[i] in currObj)) {\n // if next key is a number create an array\n if (typeof keys[i + 1] === 'number') {\n currObj[keys[i]] = [];\n } else {\n currObj[keys[i]] = {};\n }\n }\n currObj = currObj[keys[i]];\n }\n\n (currObj as { [key: string]: NestedObjectValues<T> })[keys[keys.length - 1]] =\n value;\n}\n\ninterface NestedObjectEntry<T> {\n value: NestedObjectValues<T>;\n path: (string | number)[];\n}\n\nexport function withStyleAnimation(\n styleAnimations: AnimatedStyle\n): StyleLayoutAnimation {\n 'worklet';\n return defineAnimation<StyleLayoutAnimation>({}, () => {\n 'worklet';\n\n const onFrame = (\n animation: StyleLayoutAnimation,\n now: Timestamp\n ): boolean => {\n let stillGoing = false;\n const entriesToCheck: NestedObjectEntry<AnimationObject>[] = [\n { value: animation.styleAnimations, path: [] },\n ];\n while (entriesToCheck.length > 0) {\n const currentEntry: NestedObjectEntry<AnimationObject> =\n entriesToCheck.pop() as NestedObjectEntry<AnimationObject>;\n if (Array.isArray(currentEntry.value)) {\n for (let index = 0; index < currentEntry.value.length; index++) {\n entriesToCheck.push({\n value: currentEntry.value[index],\n path: currentEntry.path.concat(index),\n });\n }\n } else if (\n typeof currentEntry.value === 'object' &&\n currentEntry.value.onFrame === undefined\n ) {\n // nested object\n for (const key of Object.keys(currentEntry.value)) {\n entriesToCheck.push({\n value: currentEntry.value[key],\n path: currentEntry.path.concat(key),\n });\n }\n } else {\n const currentStyleAnimation: AnimationObject =\n currentEntry.value as AnimationObject;\n if (currentStyleAnimation.finished) {\n continue;\n }\n const finished = currentStyleAnimation.onFrame(\n currentStyleAnimation,\n now\n );\n if (finished) {\n currentStyleAnimation.finished = true;\n if (currentStyleAnimation.callback) {\n currentStyleAnimation.callback(true);\n }\n } else {\n stillGoing = true;\n }\n\n if (ColorProperties.includes(currentEntry.path[0] as string)) {\n currentStyleAnimation.current = processColor(\n currentStyleAnimation.current\n ) as number;\n }\n\n setPath(\n animation.current,\n currentEntry.path,\n currentStyleAnimation.current\n );\n }\n }\n return !stillGoing;\n };\n\n const onStart = (\n animation: StyleLayoutAnimation,\n value: AnimatedStyle,\n now: Timestamp,\n previousAnimation: StyleLayoutAnimation\n ): void => {\n const entriesToCheck: NestedObjectEntry<\n AnimationObject | AnimatableValue\n >[] = [{ value: styleAnimations, path: [] }];\n while (entriesToCheck.length > 0) {\n const currentEntry: NestedObjectEntry<\n AnimationObject | AnimatableValue\n > = entriesToCheck.pop() as NestedObjectEntry<\n AnimationObject | AnimatableValue\n >;\n if (Array.isArray(currentEntry.value)) {\n for (let index = 0; index < currentEntry.value.length; index++) {\n entriesToCheck.push({\n value: currentEntry.value[index],\n path: currentEntry.path.concat(index),\n });\n }\n } else if (\n typeof currentEntry.value === 'object' &&\n currentEntry.value.onStart === undefined\n ) {\n for (const key of Object.keys(currentEntry.value)) {\n entriesToCheck.push({\n value: currentEntry.value[key],\n path: currentEntry.path.concat(key),\n });\n }\n } else {\n const prevAnimation = resolvePath(\n previousAnimation?.styleAnimations,\n currentEntry.path\n );\n let prevVal = resolvePath(value, currentEntry.path);\n if (prevAnimation && !prevVal) {\n prevVal = prevAnimation.current;\n }\n if (prevVal === undefined) {\n console.warn(\n `Initial values for animation are missing for property ${currentEntry.path.join(\n '.'\n )}`\n );\n }\n setPath(animation.current, currentEntry.path, prevVal);\n let currentAnimation: AnimationObject;\n if (\n typeof currentEntry.value !== 'object' ||\n !currentEntry.value.onStart\n ) {\n currentAnimation = withTiming(\n currentEntry.value as AnimatableValue,\n { duration: 0 }\n );\n setPath(\n animation.styleAnimations,\n currentEntry.path,\n currentAnimation\n );\n } else {\n currentAnimation = currentEntry.value as Animation<AnimationObject>;\n }\n currentAnimation.onStart(\n currentAnimation,\n prevVal,\n now,\n prevAnimation\n );\n }\n }\n };\n\n const callback = (finished: boolean): void => {\n if (!finished) {\n const animationsToCheck: NestedObjectValues<AnimationObject>[] = [\n styleAnimations,\n ];\n while (animationsToCheck.length > 0) {\n const currentAnimation: NestedObjectValues<AnimationObject> =\n animationsToCheck.pop() as NestedObjectValues<AnimationObject>;\n if (Array.isArray(currentAnimation)) {\n for (const element of currentAnimation) {\n animationsToCheck.push(element);\n }\n } else if (\n typeof currentAnimation === 'object' &&\n currentAnimation.onStart === undefined\n ) {\n for (const value of Object.values(currentAnimation)) {\n animationsToCheck.push(value);\n }\n } else {\n const currentStyleAnimation: AnimationObject =\n currentAnimation as AnimationObject;\n if (\n !currentStyleAnimation.finished &&\n currentStyleAnimation.callback\n ) {\n currentStyleAnimation.callback(false);\n }\n }\n }\n }\n };\n\n return {\n isHigherOrder: true,\n onFrame,\n onStart,\n current: {},\n styleAnimations,\n callback,\n } as StyleLayoutAnimation;\n });\n}\n"],"mappings":"AAAA,SAASA,eAAT,QAAgC,QAAhC;AAWA,SAASC,UAAT,QAA2B,UAA3B;AACA,SAASC,eAAT,QAAgC,gBAAhC;AACA,SAASC,YAAT,QAA6B,WAA7B,C,CAEA;AACA;;AACA,OAAO,SAASC,WAAT,CACLC,GADK,EAELC,IAFK,EAG8B;EACnC;;EACA,MAAMC,IAAuB,GAAGC,KAAK,CAACC,OAAN,CAAcH,IAAd,IAAsBA,IAAtB,GAA6B,CAACA,IAAD,CAA7D;EACA,OAAOC,IAAI,CAACG,MAAL,CAA+C,CAACC,GAAD,EAAMC,OAAN,KAAkB;IACtE,IAAIJ,KAAK,CAACC,OAAN,CAAcE,GAAd,KAAsB,OAAOC,OAAP,KAAmB,QAA7C,EAAuD;MACrD,OAAOD,GAAG,CAACC,OAAD,CAAV;IACD,CAFD,MAEO,IAAI,OAAOD,GAAP,KAAe,QAAf,IAA4BC,OAAD,IAAgCD,GAA/D,EAAoE;MACzE,OAAQA,GAAD,CACLC,OADK,CAAP;IAGD;;IACD,OAAOC,SAAP;EACD,CATM,EASJR,GATI,CAAP;AAUD,C,CAED;;AAEA,OAAO,SAASS,OAAT,CACLT,GADK,EAELC,IAFK,EAGLS,KAHK,EAIC;EACN;;EACA,MAAMR,IAAU,GAAGC,KAAK,CAACC,OAAN,CAAcH,IAAd,IAAsBA,I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AAlC,EAAqC;UACnC,MAAM0B,gBAAqD,GACzDE,iBAAiB,CAACnB,GAAlB,EADF;;UAEA,IAAInB,KAAK,CAACC,OAAN,CAAcmC,gBAAd,CAAJ,EAAqC;YACnC,KAAK,MAAMG,OAAX,IAAsBH,gBAAtB,EAAwC;cACtCE,iBAAiB,CAACjB,IAAlB,CAAuBkB,OAAvB;YACD;UACF,CAJD,MAIO,IACL,OAAOH,gBAAP,KAA4B,QAA5B,IACAA,gBAAgB,CAACP,OAAjB,KAA6BxB,SAFxB,EAGL;YACA,KAAK,MAAME,KAAX,IAAoBiB,MAAM,CAACgB,MAAP,CAAcJ,gBAAd,CAApB,EAAqD;cACnDE,iBAAiB,CAACjB,IAAlB,CAAuBd,KAAvB;YACD;UACF,CAPM,MAOA;YACL,MAAMkB,qBAAsC,GAC1CW,gBADF;;YAEA,IACE,CAACX,qBAAqB,CAACC,QAAvB,IACAD,qBAAqB,CAACE,QAFxB,EAGE;cACAF,qBAAqB,CAACE,QAAtB,CAA+B,KAA/B;YACD;UACF;QACF;MACF;IACF,CA/BD;;IAiCA,OAAO;MACLc,aAAa,EAAE,IADV;MAEL5B,OAFK;MAGLgB,OAHK;MAILzB,OAAO,EAAE,EAJJ;MAKLQ,eALK;MAMLe;IANK,CAAP;EAQD,CAxLqB,CAAtB;AAyLD"}
1
+ {"version":3,"names":["defineAnimation","withTiming","ColorProperties","processColor","resolvePath","obj","path","keys","Array","isArray","reduce","acc","current","undefined","setPath","value","currObj","i","length","withStyleAnimation","styleAnimations","onFrame","animation","now","stillGoing","entriesToCheck","currentEntry","pop","index","push","concat","key","Object","currentStyleAnimation","finished","callback","includes","onStart","previousAnimation","prevAnimation","prevVal","console","warn","join","currentAnimation","duration","animationsToCheck","element","values","isHigherOrder"],"sources":["styleAnimation.ts"],"sourcesContent":["import { defineAnimation } from './util';\nimport {\n Timestamp,\n AnimatableValue,\n AnimationObject,\n Animation,\n AnimatedStyle,\n NestedObject,\n NestedObjectValues,\n} from '../commonTypes';\nimport { StyleLayoutAnimation } from './commonTypes';\nimport { withTiming } from './timing';\nimport { ColorProperties } from '../UpdateProps';\nimport { processColor } from '../Colors';\n\n// resolves path to value for nested objects\n// if path cannot be resolved returns undefined\nexport function resolvePath<T>(\n obj: NestedObject<T>,\n path: AnimatableValue[] | AnimatableValue\n): NestedObjectValues<T> | undefined {\n 'worklet';\n const keys: AnimatableValue[] = Array.isArray(path) ? path : [path];\n return keys.reduce<NestedObjectValues<T> | undefined>((acc, current) => {\n if (Array.isArray(acc) && typeof current === 'number') {\n return acc[current];\n } else if (\n acc !== null &&\n typeof acc === 'object' &&\n (current as number | string) in acc\n ) {\n return (acc as { [key: string]: NestedObjectValues<T> })[\n current as number | string\n ];\n }\n return undefined;\n }, obj);\n}\n\n// set value at given path\ntype Path = Array<string | number> | string | number;\nexport function setPath<T>(\n obj: NestedObject<T>,\n path: Path,\n value: NestedObjectValues<T>\n): void {\n 'worklet';\n const keys: Path = Array.isArray(path) ? path : [path];\n let currObj: NestedObjectValues<T> = obj;\n for (let i = 0; i < keys.length - 1; i++) {\n // creates entry if there isn't one\n currObj = currObj as { [key: string]: NestedObjectValues<T> };\n if (!(keys[i] in currObj)) {\n // if next key is a number create an array\n if (typeof keys[i + 1] === 'number') {\n currObj[keys[i]] = [];\n } else {\n currObj[keys[i]] = {};\n }\n }\n currObj = currObj[keys[i]];\n }\n\n (currObj as { [key: string]: NestedObjectValues<T> })[keys[keys.length - 1]] =\n value;\n}\n\ninterface NestedObjectEntry<T> {\n value: NestedObjectValues<T>;\n path: (string | number)[];\n}\n\nexport function withStyleAnimation(\n styleAnimations: AnimatedStyle\n): StyleLayoutAnimation {\n 'worklet';\n return defineAnimation<StyleLayoutAnimation>({}, () => {\n 'worklet';\n\n const onFrame = (\n animation: StyleLayoutAnimation,\n now: Timestamp\n ): boolean => {\n let stillGoing = false;\n const entriesToCheck: NestedObjectEntry<AnimationObject>[] = [\n { value: animation.styleAnimations, path: [] },\n ];\n while (entriesToCheck.length > 0) {\n const currentEntry: NestedObjectEntry<AnimationObject> =\n entriesToCheck.pop() as NestedObjectEntry<AnimationObject>;\n if (Array.isArray(currentEntry.value)) {\n for (let index = 0; index < currentEntry.value.length; index++) {\n entriesToCheck.push({\n value: currentEntry.value[index],\n path: currentEntry.path.concat(index),\n });\n }\n } else if (\n typeof currentEntry.value === 'object' &&\n currentEntry.value.onFrame === undefined\n ) {\n // nested object\n for (const key of Object.keys(currentEntry.value)) {\n entriesToCheck.push({\n value: currentEntry.value[key],\n path: currentEntry.path.concat(key),\n });\n }\n } else {\n const currentStyleAnimation: AnimationObject =\n currentEntry.value as AnimationObject;\n if (currentStyleAnimation.finished) {\n continue;\n }\n const finished = currentStyleAnimation.onFrame(\n currentStyleAnimation,\n now\n );\n if (finished) {\n currentStyleAnimation.finished = true;\n if (currentStyleAnimation.callback) {\n currentStyleAnimation.callback(true);\n }\n } else {\n stillGoing = true;\n }\n\n if (ColorProperties.includes(currentEntry.path[0] as string)) {\n currentStyleAnimation.current = processColor(\n currentStyleAnimation.current\n ) as number;\n }\n\n setPath(\n animation.current,\n currentEntry.path,\n currentStyleAnimation.current\n );\n }\n }\n return !stillGoing;\n };\n\n const onStart = (\n animation: StyleLayoutAnimation,\n value: AnimatedStyle,\n now: Timestamp,\n previousAnimation: StyleLayoutAnimation\n ): void => {\n const entriesToCheck: NestedObjectEntry<\n AnimationObject | AnimatableValue\n >[] = [{ value: styleAnimations, path: [] }];\n while (entriesToCheck.length > 0) {\n const currentEntry: NestedObjectEntry<\n AnimationObject | AnimatableValue\n > = entriesToCheck.pop() as NestedObjectEntry<\n AnimationObject | AnimatableValue\n >;\n if (Array.isArray(currentEntry.value)) {\n for (let index = 0; index < currentEntry.value.length; index++) {\n entriesToCheck.push({\n value: currentEntry.value[index],\n path: currentEntry.path.concat(index),\n });\n }\n } else if (\n typeof currentEntry.value === 'object' &&\n currentEntry.value.onStart === undefined\n ) {\n for (const key of Object.keys(currentEntry.value)) {\n entriesToCheck.push({\n value: currentEntry.value[key],\n path: currentEntry.path.concat(key),\n });\n }\n } else {\n const prevAnimation = resolvePath(\n previousAnimation?.styleAnimations,\n currentEntry.path\n );\n let prevVal = resolvePath(value, currentEntry.path);\n if (prevAnimation && !prevVal) {\n prevVal = prevAnimation.current;\n }\n if (prevVal === undefined) {\n console.warn(\n `Initial values for animation are missing for property ${currentEntry.path.join(\n '.'\n )}`\n );\n }\n setPath(animation.current, currentEntry.path, prevVal);\n let currentAnimation: AnimationObject;\n if (\n typeof currentEntry.value !== 'object' ||\n !currentEntry.value.onStart\n ) {\n currentAnimation = withTiming(\n currentEntry.value as AnimatableValue,\n { duration: 0 }\n );\n setPath(\n animation.styleAnimations,\n currentEntry.path,\n currentAnimation\n );\n } else {\n currentAnimation = currentEntry.value as Animation<AnimationObject>;\n }\n currentAnimation.onStart(\n currentAnimation,\n prevVal,\n now,\n prevAnimation\n );\n }\n }\n };\n\n const callback = (finished: boolean): void => {\n if (!finished) {\n const animationsToCheck: NestedObjectValues<AnimationObject>[] = [\n styleAnimations,\n ];\n while (animationsToCheck.length > 0) {\n const currentAnimation: NestedObjectValues<AnimationObject> =\n animationsToCheck.pop() as NestedObjectValues<AnimationObject>;\n if (Array.isArray(currentAnimation)) {\n for (const element of currentAnimation) {\n animationsToCheck.push(element);\n }\n } else if (\n typeof currentAnimation === 'object' &&\n currentAnimation.onStart === undefined\n ) {\n for (const value of Object.values(currentAnimation)) {\n animationsToCheck.push(value);\n }\n } else {\n const currentStyleAnimation: AnimationObject =\n currentAnimation as AnimationObject;\n if (\n !currentStyleAnimation.finished &&\n currentStyleAnimation.callback\n ) {\n currentStyleAnimation.callback(false);\n }\n }\n }\n }\n };\n\n return {\n isHigherOrder: true,\n onFrame,\n onStart,\n current: {},\n styleAnimations,\n callback,\n } as StyleLayoutAnimation;\n });\n}\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,QAAQ;AAWxC,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,eAAe,QAAQ,gBA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AC/BD,qBAAqB,CAACE,QAAQ,EAC9B;cACAF,qBAAqB,CAACE,QAAQ,CAAC,KAAK,CAAC;YACvC;UACF;QACF;MACF;IACF,CAAC;IAED,OAAO;MACLc,aAAa,EAAE,IAAI;MACnB5B,OAAO;MACPgB,OAAO;MACPzB,OAAO,EAAE,CAAC,CAAC;MACXQ,eAAe;MACfe;IACF,CAAC;EACH,CAAC,CAAC;AACJ"}
@@ -10,11 +10,9 @@ export function withTiming(toValue, userConfig, callback) {
10
10
  duration: 300,
11
11
  easing: Easing.inOut(Easing.quad)
12
12
  };
13
-
14
13
  if (userConfig) {
15
14
  Object.keys(userConfig).forEach(key => config[key] = userConfig[key]);
16
15
  }
17
-
18
16
  function timing(animation, now) {
19
17
  const {
20
18
  toValue,
@@ -22,19 +20,16 @@ export function withTiming(toValue, userConfig, callback) {
22
20
  startValue
23
21
  } = animation;
24
22
  const runtime = now - startTime;
25
-
26
23
  if (runtime >= config.duration) {
27
24
  // reset startTime to avoid reusing finished animation config in `start` method
28
25
  animation.startTime = 0;
29
26
  animation.current = toValue;
30
27
  return true;
31
28
  }
32
-
33
29
  const progress = animation.easing(runtime / config.duration);
34
30
  animation.current = startValue + (toValue - startValue) * progress;
35
31
  return false;
36
32
  }
37
-
38
33
  function onStart(animation, value, now, previousAnimation) {
39
34
  if (previousAnimation && previousAnimation.type === 'timing' && previousAnimation.toValue === toValue && previousAnimation.startTime) {
40
35
  // to maintain continuity of timing animations we check if we are starting
@@ -46,16 +41,13 @@ export function withTiming(toValue, userConfig, callback) {
46
41
  animation.startTime = now;
47
42
  animation.startValue = value;
48
43
  }
49
-
50
44
  animation.current = value;
51
-
52
45
  if (typeof config.easing === 'object') {
53
46
  animation.easing = config.easing.factory();
54
47
  } else {
55
48
  animation.easing = config.easing;
56
49
  }
57
50
  }
58
-
59
51
  return {
60
52
  type: 'timing',
61
53
  onFrame: timing,
@@ -1 +1 @@
1
- {"version":3,"names":["Easing","defineAnimation","withTiming","toValue","userConfig","callback","config","duration","easing","inOut","quad","Object","keys","forEach","key","timing","animation","now","startTime","startValue","runtime","current","progress","onStart","value","previousAnimation","type","factory","onFrame"],"sources":["timing.ts"],"sourcesContent":["import { Easing, EasingFn, EasingFactoryFn } from '../Easing';\nimport { defineAnimation } from './util';\nimport {\n Animation,\n AnimationCallback,\n Timestamp,\n AnimatableValue,\n} from '../commonTypes';\n\ninterface TimingConfig {\n duration?: number;\n easing?: EasingFn | EasingFactoryFn;\n}\n\nexport interface TimingAnimation extends Animation<TimingAnimation> {\n type: string;\n easing: EasingFn;\n startValue: AnimatableValue;\n startTime: Timestamp;\n progress: number;\n toValue: AnimatableValue;\n current: AnimatableValue;\n}\n\nexport interface InnerTimingAnimation\n extends Omit<TimingAnimation, 'toValue' | 'current'> {\n toValue: number;\n current: number;\n}\n\nexport function withTiming(\n toValue: AnimatableValue,\n userConfig?: TimingConfig,\n callback?: AnimationCallback\n): Animation<TimingAnimation> {\n 'worklet';\n\n return defineAnimation<TimingAnimation>(toValue, () => {\n 'worklet';\n const config: Required<TimingConfig> = {\n duration: 300,\n easing: Easing.inOut(Easing.quad),\n };\n if (userConfig) {\n Object.keys(userConfig).forEach(\n (key) =>\n ((config as any)[key] = userConfig[key as keyof typeof userConfig])\n );\n }\n\n function timing(animation: InnerTimingAnimation, now: Timestamp): boolean {\n const { toValue, startTime, startValue } = animation;\n const runtime = now - startTime;\n\n if (runtime >= config.duration) {\n // reset startTime to avoid reusing finished animation config in `start` method\n animation.startTime = 0;\n animation.current = toValue;\n return true;\n }\n const progress = animation.easing(runtime / config.duration);\n animation.current =\n (startValue as number) + (toValue - (startValue as number)) * progress;\n return false;\n }\n\n function onStart(\n animation: TimingAnimation,\n value: number,\n now: Timestamp,\n previousAnimation: Animation<TimingAnimation>\n ): void {\n if (\n previousAnimation &&\n (previousAnimation as TimingAnimation).type === 'timing' &&\n (previousAnimation as TimingAnimation).toValue === toValue &&\n (previousAnimation as TimingAnimation).startTime\n ) {\n // to maintain continuity of timing animations we check if we are starting\n // new timing over the old one with the same parameters. If so, we want\n // to copy animation timeline properties\n animation.startTime = (previousAnimation as TimingAnimation).startTime;\n animation.startValue = (\n previousAnimation as TimingAnimation\n ).startValue;\n } else {\n animation.startTime = now;\n animation.startValue = value;\n }\n animation.current = value;\n if (typeof config.easing === 'object') {\n animation.easing = config.easing.factory();\n } else {\n animation.easing = config.easing;\n }\n }\n\n return {\n type: 'timing',\n onFrame: timing,\n onStart: onStart as (animation: TimingAnimation, now: number) => boolean,\n progress: 0,\n toValue,\n startValue: 0,\n startTime: 0,\n easing: () => 0,\n current: toValue,\n callback,\n } as TimingAnimation;\n });\n}\n"],"mappings":"AAAA,SAASA,MAAT,QAAkD,WAAlD;AACA,SAASC,eAAT,QAAgC,QAAhC;AA6BA,OAAO,SAASC,UAAT,CACLC,OADK,EAELC,UAFK,EAGLC,QAHK,EAIuB;EAC5B;;EAEA,OAAOJ,eAAe,CAAkBE,OAAlB,EAA2B,MAAM;IACrD;;IACA,MAAMG,MAA8B,GAAG;MACrCC,QAAQ,EAAE,GAD2B;MAErCC,MAAM,EAAER,MAAM,CAACS,KAAP,CAAaT,MAAM,CAACU,IAApB;IAF6B,CAAvC;;IAIA,IAAIN,UAAJ,EAAgB;MACdO,MAAM,CAACC,IAAP,CAAYR,UAAZ,EAAwBS,OAAxB,CACGC,GAAD,IACIR,MAAD,CAAgBQ,GAAhB,IAAuBV,UAAU,CAACU,GAAD,CAFtC;IAID;;IAED,SAASC,MAAT,CAAgBC,SAAhB,EAAiDC,GAAjD,EAA0E;MACxE,MAAM;QAAEd,OAAF;QAAWe,SAAX;QAAsBC;MAAtB,IAAqCH,SAA3C;MACA,MAAMI,OAAO,GAAGH,GAAG,GAAGC,SAAtB;;MAEA,IAAIE,OAAO,IAAId,MAAM,CAACC,QAAtB,EAAgC;QAC9B;QACAS,SAAS,CAACE,SAAV,GAAsB,CAAtB;QACAF,SAAS,CAACK,OAAV,GAAoBlB,OAApB;QACA,OAAO,IAAP;MACD;;MACD,MAAMmB,QAAQ,GAAGN,SAAS,CAACR,MAAV,CAAiBY,OAAO,GAAGd,MAAM,CAACC,QAAlC,CAAjB;MACAS,SAAS,CAACK,OAAV,GACGF,UAAD,GAAyB,CAAChB,OAAO,GAAIgB,UAAZ,IAAqCG,QADhE;MAEA,OAAO,KAAP;IACD;;IAED,SAASC,OAAT,CACEP,SADF,EAEEQ,KAFF,EAGEP,GAHF,EAIEQ,iBAJF,EAKQ;MACN,IACEA,iBAAiB,IAChBA,iBAAD,CAAuCC,IAAvC,KAAgD,QADhD,IAECD,iBAAD,CAAuCtB,OAAvC,KAAmDA,OAFnD,IAGCsB,iBAAD,CAAuCP,SAJzC,EAKE;QACA;QACA;QACA;QACAF,SAAS,CAACE,SAAV,GAAuBO,iBAAD,CAAuCP,SAA7D;QACAF,SAAS,CAACG,UAAV,GACEM,iBADqB,CAErBN,UAFF;MAGD,CAbD,MAaO;QACLH,SAAS,CAACE,SAAV,GAAsBD,GAAtB;QACAD,SAAS,CAACG,UAAV,GAAuBK,KAAvB;MACD;;MACDR,SAAS,CAACK,OAAV,GAAoBG,KAApB;;MACA,IAAI,OAAOlB,MAAM,CAACE,MAAd,KAAyB,QAA7B,EAAuC;QACrCQ,SAAS,CAACR,MAAV,GAAmBF,MAAM,CAACE,MAAP,CAAcmB,OAAd,EAAnB;MACD,CAFD,MAEO;QACLX,SAAS,CAACR,MAAV,GAAmBF,MAAM,CAACE,MAA1B;MACD;IACF;;IAED,OAAO;MACLkB,IAAI,EAAE,QADD;MAELE,OAAO,EAAEb,MAFJ;MAGLQ,OAAO,EAAEA,OAHJ;MAILD,QAAQ,EAAE,CAJL;MAKLnB,OALK;MAMLgB,UAAU,EAAE,CANP;MAOLD,SAAS,EAAE,CAPN;MAQLV,MAAM,EAAE,MAAM,CART;MASLa,OAAO,EAAElB,OATJ;MAULE;IAVK,CAAP;EAYD,CAxEqB,CAAtB;AAyED"}
1
+ {"version":3,"names":["Easing","defineAnimation","withTiming","toValue","userConfig","callback","config","duration","easing","inOut","quad","Object","keys","forEach","key","timing","animation","now","startTime","startValue","runtime","current","progress","onStart","value","previousAnimation","type","factory","onFrame"],"sources":["timing.ts"],"sourcesContent":["import { Easing, EasingFn, EasingFactoryFn } from '../Easing';\nimport { defineAnimation } from './util';\nimport {\n Animation,\n AnimationCallback,\n Timestamp,\n AnimatableValue,\n} from '../commonTypes';\n\ninterface TimingConfig {\n duration?: number;\n easing?: EasingFn | EasingFactoryFn;\n}\n\nexport interface TimingAnimation extends Animation<TimingAnimation> {\n type: string;\n easing: EasingFn;\n startValue: AnimatableValue;\n startTime: Timestamp;\n progress: number;\n toValue: AnimatableValue;\n current: AnimatableValue;\n}\n\nexport interface InnerTimingAnimation\n extends Omit<TimingAnimation, 'toValue' | 'current'> {\n toValue: number;\n current: number;\n}\n\nexport function withTiming(\n toValue: AnimatableValue,\n userConfig?: TimingConfig,\n callback?: AnimationCallback\n): Animation<TimingAnimation> {\n 'worklet';\n\n return defineAnimation<TimingAnimation>(toValue, () => {\n 'worklet';\n const config: Required<TimingConfig> = {\n duration: 300,\n easing: Easing.inOut(Easing.quad),\n };\n if (userConfig) {\n Object.keys(userConfig).forEach(\n (key) =>\n ((config as any)[key] = userConfig[key as keyof typeof userConfig])\n );\n }\n\n function timing(animation: InnerTimingAnimation, now: Timestamp): boolean {\n const { toValue, startTime, startValue } = animation;\n const runtime = now - startTime;\n\n if (runtime >= config.duration) {\n // reset startTime to avoid reusing finished animation config in `start` method\n animation.startTime = 0;\n animation.current = toValue;\n return true;\n }\n const progress = animation.easing(runtime / config.duration);\n animation.current =\n (startValue as number) + (toValue - (startValue as number)) * progress;\n return false;\n }\n\n function onStart(\n animation: TimingAnimation,\n value: number,\n now: Timestamp,\n previousAnimation: Animation<TimingAnimation>\n ): void {\n if (\n previousAnimation &&\n (previousAnimation as TimingAnimation).type === 'timing' &&\n (previousAnimation as TimingAnimation).toValue === toValue &&\n (previousAnimation as TimingAnimation).startTime\n ) {\n // to maintain continuity of timing animations we check if we are starting\n // new timing over the old one with the same parameters. If so, we want\n // to copy animation timeline properties\n animation.startTime = (previousAnimation as TimingAnimation).startTime;\n animation.startValue = (\n previousAnimation as TimingAnimation\n ).startValue;\n } else {\n animation.startTime = now;\n animation.startValue = value;\n }\n animation.current = value;\n if (typeof config.easing === 'object') {\n animation.easing = config.easing.factory();\n } else {\n animation.easing = config.easing;\n }\n }\n\n return {\n type: 'timing',\n onFrame: timing,\n onStart: onStart as (animation: TimingAnimation, now: number) => boolean,\n progress: 0,\n toValue,\n startValue: 0,\n startTime: 0,\n easing: () => 0,\n current: toValue,\n callback,\n } as TimingAnimation;\n });\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAmC,WAAW;AAC7D,SAASC,eAAe,QAAQ,QAAQ;AA6BxC,OAAO,SAASC,UAAUA,CACxBC,OAAwB,EACxBC,UAAyB,EACzBC,QAA4B,EACA;EAC5B,SAAS;;EAET,OAAOJ,eAAe,CAAkBE,OAAO,EAAE,MAAM;IACrD,SAAS;;IACT,MAAMG,MAA8B,GAAG;MACrCC,QAAQ,EAAE,GAAG;MACbC,MAAM,EAAER,MAAM,CAACS,KAAK,CAACT,MAAM,CAACU,IAAI;IAClC,CAAC;IACD,IAAIN,UAAU,EAAE;MACdO,MAAM,CAACC,IAAI,CAACR,UAAU,CAAC,CAACS,OAAO,CAC5BC,GAAG,IACAR,MAAM,CAASQ,GAAG,CAAC,GAAGV,UAAU,CAACU,GAAG,CAA6B,CACtE;IACH;IAEA,SAASC,MAAMA,CAACC,SAA+B,EAAEC,GAAc,EAAW;MACxE,MAAM;QAAEd,OAAO;QAAEe,SAAS;QAAEC;MAAW,CAAC,GAAGH,SAAS;MACpD,MAAMI,OAAO,GAAGH,GAAG,GAAGC,SAAS;MAE/B,IAAIE,OAAO,IAAId,MAAM,CAACC,QAAQ,EAAE;QAC9B;QACAS,SAAS,CAACE,SAAS,GAAG,CAAC;QACvBF,SAAS,CAACK,OAAO,GAAGlB,OAAO;QAC3B,OAAO,I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8
  IN_STYLE_UPDATER = false;
9
9
  return result;
10
10
  }
11
-
12
11
  function recognizePrefixSuffix(value) {
13
12
  'worklet';
14
13
 
15
14
  if (typeof value === 'string') {
16
15
  const match = value.match(/([A-Za-z]*)(-?\d*\.?\d*)([eE][-+]?[0-9]+)?([A-Za-z%]*)/);
17
-
18
16
  if (!match) {
19
17
  throw Error("Couldn't parse animation value. Check if there isn't any typo.");
20
18
  }
21
-
22
19
  const prefix = match[1];
23
- const suffix = match[4]; // number with scientific notation
24
-
20
+ const suffix = match[4];
21
+ // number with scientific notation
25
22
  const number = match[2] + (match[3] ?? '');
26
23
  return {
27
24
  prefix,
@@ -34,19 +31,16 @@ function recognizePrefixSuffix(value) {
34
31
  };
35
32
  }
36
33
  }
37
-
38
34
  function decorateAnimation(animation) {
39
35
  'worklet';
40
36
 
41
37
  if (animation.isHigherOrder) {
42
38
  return;
43
39
  }
44
-
45
40
  const baseOnStart = animation.onStart;
46
41
  const baseOnFrame = animation.onFrame;
47
42
  const animationCopy = Object.assign({}, animation);
48
43
  delete animationCopy.callback;
49
-
50
44
  const prefNumberSuffOnStart = (animation, value, timestamp, previousAnimation) => {
51
45
  // recognize prefix, suffix, and updates stripped value on animation start
52
46
  const {
@@ -63,7 +57,6 @@ function decorateAnimation(animation) {
63
57
  animation.current = strippedValue;
64
58
  animation.startValue = strippedValue;
65
59
  animation.toValue = strippedToValue;
66
-
67
60
  if (previousAnimation && previousAnimation !== animation) {
68
61
  const {
69
62
  prefix: paPrefix,
@@ -74,15 +67,12 @@ function decorateAnimation(animation) {
74
67
  previousAnimation.__prefix = paPrefix;
75
68
  previousAnimation.__suffix = paSuffix;
76
69
  }
77
-
78
70
  baseOnStart(animation, strippedValue, timestamp, previousAnimation);
79
71
  animation.current = (animation.__prefix ?? '') + animation.current + (animation.__suffix ?? '');
80
-
81
72
  if (previousAnimation && previousAnimation !== animation) {
82
73
  previousAnimation.current = (previousAnimation.__prefix ?? '') + previousAnimation.current + (previousAnimation.__suffix ?? '');
83
74
  }
84
75
  };
85
-
86
76
  const prefNumberSuffOnFrame = (animation, timestamp) => {
87
77
  animation.current = animation.strippedCurrent;
88
78
  const res = baseOnFrame(animation, timestamp);
@@ -90,24 +80,19 @@ function decorateAnimation(animation) {
90
80
  animation.current = (animation.__prefix ?? '') + animation.current + (animation.__suffix ?? '');
91
81
  return res;
92
82
  };
93
-
94
83
  const tab = ['R', 'G', 'B', 'A'];
95
-
96
84
  const colorOnStart = (animation, value, timestamp, previousAnimation) => {
97
85
  let RGBAValue;
98
86
  let RGBACurrent;
99
87
  let RGBAToValue;
100
88
  const res = [];
101
-
102
89
  if (isColor(value)) {
103
90
  RGBACurrent = toLinearSpace(convertToRGBA(animation.current));
104
91
  RGBAValue = toLinearSpace(convertToRGBA(value));
105
-
106
92
  if (animation.toValue) {
107
93
  RGBAToValue = toLinearSpace(convertToRGBA(animation.toValue));
108
94
  }
109
95
  }
110
-
111
96
  tab.forEach((i, index) => {
112
97
  animation[i] = Object.assign({}, animationCopy);
113
98
  animation[i].current = RGBACurrent[index];
@@ -117,21 +102,19 @@ function decorateAnimation(animation) {
117
102
  });
118
103
  animation.current = rgbaArrayToRGBAColor(toGammaSpace(res));
119
104
  };
120
-
121
105
  const colorOnFrame = (animation, timestamp) => {
122
106
  const RGBACurrent = toLinearSpace(convertToRGBA(animation.current));
123
107
  const res = [];
124
108
  let finished = true;
125
109
  tab.forEach((i, index) => {
126
- animation[i].current = RGBACurrent[index]; // @ts-ignore: disable-next-line
127
-
110
+ animation[i].current = RGBACurrent[index];
111
+ // @ts-ignore: disable-next-line
128
112
  finished &= animation[i].onFrame(animation[i], timestamp);
129
113
  res.push(animation[i].current);
130
114
  });
131
115
  animation.current = rgbaArrayToRGBAColor(toGammaSpace(res));
132
116
  return finished;
133
117
  };
134
-
135
118
  const arrayOnStart = (animation, value, timestamp, previousAnimation) => {
136
119
  value.forEach((v, i) => {
137
120
  animation[i] = Object.assign({}, animationCopy);
@@ -141,7 +124,6 @@ function decorateAnimation(animation) {
141
124
  });
142
125
  animation.current = value;
143
126
  };
144
-
145
127
  const arrayOnFrame = (animation, timestamp) => {
146
128
  let finished = true;
147
129
  animation.current.forEach((v, i) => {
@@ -151,7 +133,6 @@ function decorateAnimation(animation) {
151
133
  });
152
134
  return finished;
153
135
  };
154
-
155
136
  animation.onStart = (animation, value, timestamp, previousAnimation) => {
156
137
  if (isColor(value)) {
157
138
  colorOnStart(animation, value, timestamp, previousAnimation);
@@ -166,11 +147,9 @@ function decorateAnimation(animation) {
166
147
  animation.onFrame = prefNumberSuffOnFrame;
167
148
  return;
168
149
  }
169
-
170
150
  baseOnStart(animation, value, timestamp, previousAnimation);
171
151
  };
172
152
  }
173
-
174
153
  const IS_NATIVE = NativeReanimatedModule.native;
175
154
  export function defineAnimation(starting, factory) {
176
155
  'worklet';
@@ -178,7 +157,6 @@ export function defineAnimation(starting, factory) {
178
157
  if (IN_STYLE_UPDATER) {
179
158
  return starting;
180
159
  }
181
-
182
160
  const create = () => {
183
161
  'worklet';
184
162
 
@@ -186,20 +164,20 @@ export function defineAnimation(starting, factory) {
186
164
  decorateAnimation(animation);
187
165
  return animation;
188
166
  };
189
-
190
167
  if (_WORKLET || !IS_NATIVE) {
191
168
  return create();
192
- } // @ts-ignore: eslint-disable-line
193
-
194
-
169
+ }
170
+ // @ts-ignore: eslint-disable-line
195
171
  return create;
196
172
  }
197
173
  export function cancelAnimation(sharedValue) {
198
- 'worklet'; // setting the current value cancels the animation if one is currently running
174
+ 'worklet';
199
175
 
176
+ // setting the current value cancels the animation if one is currently running
200
177
  sharedValue.value = sharedValue.value; // eslint-disable-line no-self-assign
201
- } // TODO it should work only if there was no animation before.
178
+ }
202
179
 
180
+ // TODO it should work only if there was no animation before.
203
181
  export function withStartValue(startValue, animation) {
204
182
  'worklet';
205
183
 
@@ -209,7 +187,6 @@ export function withStartValue(startValue, animation) {
209
187
  if (!_WORKLET && typeof animation === 'function') {
210
188
  animation = animation();
211
189
  }
212
-
213
190
  animation.current = startValue;
214
191
  return animation;
215
192
  });
@@ -1 +1 @@
1
- {"version":3,"names":["isColor","convertToRGBA","rgbaArrayToRGBAColor","toGammaSpace","toLinearSpace","NativeReanimatedModule","IN_STYLE_UPDATER","initialUpdaterRun","updater","result","recognizePrefixSuffix","value","match","Error","prefix","suffix","number","strippedValue","parseFloat","decorateAnimation","animation","isHigherOrder","baseOnStart","onStart","baseOnFrame","onFrame","animationCopy","Object","assign","callback","prefNumberSuffOnStart","timestamp","previousAnimation","__prefix","__suffix","strippedCurrent","strippedToValue","toValue","current","startValue","paPrefix","paSuffix","paStrippedValue","prefNumberSuffOnFrame","res","tab","colorOnStart","RGBAValue","RGBACurrent","RGBAToValue","forEach","i","index","undefined","push","colorOnFrame","finished","arrayOnStart","v","arrayOnFrame","Array","isArray","IS_NATIVE","native","defineAnimation","starting","factory","create","_WORKLET","cancelAnimation","sharedValue","withStartValue"],"sources":["util.ts"],"sourcesContent":["import {\n HigherOrderAnimation,\n NextAnimation,\n DelayAnimation,\n RepeatAnimation,\n SequenceAnimation,\n StyleLayoutAnimation,\n} from './commonTypes';\n/* global _WORKLET */\nimport {\n ParsedColorArray,\n isColor,\n convertToRGBA,\n rgbaArrayToRGBAColor,\n toGammaSpace,\n toLinearSpace,\n} from '../Colors';\n\nimport {\n AnimatedStyle,\n SharedValue,\n AnimatableValue,\n Animation,\n AnimationObject,\n Timestamp,\n} from '../commonTypes';\nimport NativeReanimatedModule from '../NativeReanimated';\n\nlet IN_STYLE_UPDATER = false;\n\nexport type UserUpdater = () => AnimatedStyle;\n\nexport function initialUpdaterRun<T>(updater: () => T): T {\n IN_STYLE_UPDATER = true;\n const result = updater();\n IN_STYLE_UPDATER = false;\n return result;\n}\n\ninterface RecognizedPrefixSuffix {\n prefix?: string;\n suffix?: string;\n strippedValue: number;\n}\n\nfunction recognizePrefixSuffix(value: string | number): RecognizedPrefixSuffix {\n 'worklet';\n if (typeof value === 'string') {\n const match = value.match(\n /([A-Za-z]*)(-?\\d*\\.?\\d*)([eE][-+]?[0-9]+)?([A-Za-z%]*)/\n );\n if (!match) {\n throw Error(\n \"Couldn't parse animation value. Check if there isn't any typo.\"\n );\n }\n const prefix = match[1];\n const suffix = match[4];\n // number with scientific notation\n const number = match[2] + (match[3] ?? '');\n return { prefix, suffix, strippedValue: parseFloat(number) };\n } else {\n return { strippedValue: value };\n }\n}\n\nfunction decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(\n animation: T\n): void {\n 'worklet';\n if ((animation as HigherOrderAnimation).isHigherOrder) {\n return;\n }\n\n const baseOnStart = (animation as Animation<AnimationObject>).onStart;\n const baseOnFrame = (animation as Animation<AnimationObject>).onFrame;\n const animationCopy = Object.assign({}, animation);\n delete animationCopy.callback;\n\n const prefNumberSuffOnStart = (\n animation: Animation<AnimationObject>,\n value: string | number,\n timestamp: number,\n previousAnimation: Animation<AnimationObject>\n ) => {\n // recognize prefix, suffix, and updates stripped value on animation start\n const { prefix, suffix, strippedValue } = recognizePrefixSuffix(value);\n animation.__prefix = prefix;\n animation.__suffix = suffix;\n animation.strippedCurrent = strippedValue;\n const { strippedValue: strippedToValue } = recognizePrefixSuffix(\n animation.toValue as string | number\n );\n animation.current = strippedValue;\n animation.startValue = strippedValue;\n animation.toValue = strippedToValue;\n if (previousAnimation && previousAnimation !== animation) {\n const {\n prefix: paPrefix,\n suffix: paSuffix,\n strippedValue: paStrippedValue,\n } = recognizePrefixSuffix(previousAnimation.current as string | number);\n previousAnimation.current = paStrippedValue;\n previousAnimation.__prefix = paPrefix;\n previousAnimation.__suffix = paSuffix;\n }\n\n baseOnStart(animation, strippedValue, timestamp, previousAnimation);\n\n animation.current =\n (animation.__prefix ?? '') +\n animation.current +\n (animation.__suffix ?? '');\n\n if (previousAnimation && previousAnimation !== animation) {\n previousAnimation.current =\n (previousAnimation.__prefix ?? '') +\n previousAnimation.current +\n (previousAnimation.__suffix ?? '');\n }\n };\n const prefNumberSuffOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: number\n ) => {\n animation.current = animation.strippedCurrent;\n const res = baseOnFrame(animation, timestamp);\n animation.strippedCurrent = animation.current;\n animation.current =\n (animation.__prefix ?? '') +\n animation.current +\n (animation.__suffix ?? '');\n return res;\n };\n\n const tab = ['R', 'G', 'B', 'A'];\n const colorOnStart = (\n animation: Animation<AnimationObject>,\n value: string | number,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ): void => {\n let RGBAValue: ParsedColorArray;\n let RGBACurrent: ParsedColorArray;\n let RGBAToValue: ParsedColorArray;\n const res: Array<number> = [];\n if (isColor(value)) {\n RGBACurrent = toLinearSpace(convertToRGBA(animation.current));\n RGBAValue = toLinearSpace(convertToRGBA(value));\n if (animation.toValue) {\n RGBAToValue = toLinearSpace(convertToRGBA(animation.toValue));\n }\n }\n tab.forEach((i, index) => {\n animation[i] = Object.assign({}, animationCopy);\n animation[i].current = RGBACurrent[index];\n animation[i].toValue = RGBAToValue ? RGBAToValue[index] : undefined;\n animation[i].onStart(\n animation[i],\n RGBAValue[index],\n timestamp,\n previousAnimation ? previousAnimation[i] : undefined\n );\n res.push(animation[i].current);\n });\n\n animation.current = rgbaArrayToRGBAColor(\n toGammaSpace(res as ParsedColorArray)\n );\n };\n\n const colorOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: Timestamp\n ): boolean => {\n const RGBACurrent = toLinearSpace(convertToRGBA(animation.current));\n const res: Array<number> = [];\n let finished = true;\n tab.forEach((i, index) => {\n animation[i].current = RGBACurrent[index];\n // @ts-ignore: disable-next-line\n finished &= animation[i].onFrame(animation[i], timestamp);\n res.push(animation[i].current);\n });\n\n animation.current = rgbaArrayToRGBAColor(\n toGammaSpace(res as ParsedColorArray)\n );\n return finished;\n };\n\n const arrayOnStart = (\n animation: Animation<AnimationObject>,\n value: Array<number>,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ): void => {\n value.forEach((v, i) => {\n animation[i] = Object.assign({}, animationCopy);\n animation[i].current = v;\n animation[i].toValue = (animation.toValue as Array<number>)[i];\n animation[i].onStart(\n animation[i],\n v,\n timestamp,\n previousAnimation ? previousAnimation[i] : undefined\n );\n });\n\n animation.current = value;\n };\n\n const arrayOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: Timestamp\n ): boolean => {\n let finished = true;\n (animation.current as Array<number>).forEach((v, i) => {\n // @ts-ignore: disable-next-line\n finished &= animation[i].onFrame(animation[i], timestamp);\n (animation.current as Array<number>)[i] = animation[i].current;\n });\n\n return finished;\n };\n\n animation.onStart = (\n animation: Animation<AnimationObject>,\n value: number,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ) => {\n if (isColor(value)) {\n colorOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = colorOnFrame;\n return;\n } else if (Array.isArray(value)) {\n arrayOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = arrayOnFrame;\n return;\n } else if (typeof value === 'string') {\n prefNumberSuffOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = prefNumberSuffOnFrame;\n return;\n }\n baseOnStart(animation, value, timestamp, previousAnimation);\n };\n}\n\ntype AnimationToDecoration<T extends AnimationObject | StyleLayoutAnimation> =\n T extends StyleLayoutAnimation\n ? Record<string, unknown>\n : T extends DelayAnimation\n ? NextAnimation<DelayAnimation>\n : T extends RepeatAnimation\n ? NextAnimation<RepeatAnimation>\n : T extends SequenceAnimation\n ? NextAnimation<SequenceAnimation>\n : AnimatableValue | T;\n\nconst IS_NATIVE = NativeReanimatedModule.native;\n\nexport function defineAnimation<\n T extends AnimationObject | StyleLayoutAnimation\n>(starting: AnimationToDecoration<T>, factory: () => T): T {\n 'worklet';\n if (IN_STYLE_UPDATER) {\n return starting as T;\n }\n const create = () => {\n 'worklet';\n const animation = factory();\n decorateAnimation<T>(animation);\n return animation;\n };\n\n if (_WORKLET || !IS_NATIVE) {\n return create();\n }\n // @ts-ignore: eslint-disable-line\n return create;\n}\n\nexport function cancelAnimation<T>(sharedValue: SharedValue<T>): void {\n 'worklet';\n // setting the current value cancels the animation if one is currently running\n sharedValue.value = sharedValue.value; // eslint-disable-line no-self-assign\n}\n\n// TODO it should work only if there was no animation before.\nexport function withStartValue(\n startValue: AnimatableValue,\n animation: NextAnimation<AnimationObject>\n): Animation<AnimationObject> {\n 'worklet';\n return defineAnimation(startValue, () => {\n 'worklet';\n if (!_WORKLET && typeof animation === 'function') {\n animation = animation();\n }\n (animation as Animation<AnimationObject>).current = startValue;\n return animation as Animation<AnimationObject>;\n });\n}\n"],"mappings":"AAQA;AACA,SAEEA,OAFF,EAGEC,aAHF,EAIEC,oBAJF,EAKEC,YALF,EAMEC,aANF,QAOO,WAPP;AAiBA,OAAOC,sBAAP,MAAmC,qBAAnC;AAEA,IAAIC,gBAAgB,GAAG,KAAvB;AAIA,OAAO,SAASC,iBAAT,CAA8BC,OAA9B,EAAmD;EACxDF,gBAAgB,GAAG,IAAnB;EACA,MAAMG,MAAM,GAAGD,OAAO,EAAtB;EACAF,gBAAgB,GAAG,KAAnB;EACA,OAAOG,MAAP;AACD;;AAQD,SAASC,qBAAT,CAA+BC,KAA/B,EAA+E;EAC7E;;EACA,IAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;IAC7B,MAAMC,KAAK,GAAGD,KAAK,CAACC,KAAN,CACZ,wDADY,CAAd;;IAGA,IAAI,CAACA,KAAL,EAAY;MACV,MAAMC,KAAK,CACT,gEADS,CAAX;IAGD;;IACD,MAAMC,MAAM,GAAGF,KAAK,CAAC,CAAD,CAApB;IACA,MAAMG,MAAM,GAAGH,KAAK,CAAC,CAAD,CAApB,CAV6B,CAW7B;;IACA,MAAMI,MAAM,GAAGJ,KAAK,CAAC,CAAD,CAAL,IAAYA,KAAK,CAAC,CAAD,CAAL,IAAY,EAAxB,CAAf;IACA,OAAO;MAAEE,MAAF;MAAUC,MAAV;MAAkBE,aAAa,EAAEC,UAAU,CAACF,MAAD;IAA3C,CAAP;EACD,CAdD,MAcO;IACL,OAAO;MAAEC,aAAa,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AAM/C,SAAS,GAAG8C,OAAO,EAAzB;IACA/C,iBAAiB,CAAIC,SAAJ,CAAjB;IACA,OAAOA,SAAP;EACD,CALD;;EAOA,IAAIgD,QAAQ,IAAI,CAACN,SAAjB,EAA4B;IAC1B,OAAOK,MAAM,EAAb;EACD,CAdwD,CAezD;;;EACA,OAAOA,MAAP;AACD;AAED,OAAO,SAASE,eAAT,CAA4BC,WAA5B,EAA+D;EACpE,UADoE,CAEpE;;EACAA,WAAW,CAAC3D,KAAZ,GAAoB2D,WAAW,CAAC3D,KAAhC,CAHoE,CAG7B;AACxC,C,CAED;;AACA,OAAO,SAAS4D,cAAT,CACLhC,UADK,EAELnB,SAFK,EAGuB;EAC5B;;EACA,OAAO4C,eAAe,CAACzB,UAAD,EAAa,MAAM;IACvC;;IACA,IAAI,CAAC6B,QAAD,IAAa,OAAOhD,SAAP,KAAqB,UAAtC,EAAkD;MAChDA,SAAS,GAAGA,SAAS,EAArB;IACD;;IACAA,SAAD,CAA0CkB,OAA1C,GAAoDC,UAApD;IACA,OAAOnB,SAAP;EACD,CAPqB,CAAtB;AAQD"}
1
+ {"version":3,"names":["isColor","convertToRGBA","rgbaArrayToRGBAColor","toGammaSpace","toLinearSpace","NativeReanimatedModule","IN_STYLE_UPDATER","initialUpdaterRun","updater","result","recognizePrefixSuffix","value","match","Error","prefix","suffix","number","strippedValue","parseFloat","decorateAnimation","animation","isHigherOrder","baseOnStart","onStart","baseOnFrame","onFrame","animationCopy","Object","assign","callback","prefNumberSuffOnStart","timestamp","previousAnimation","__prefix","__suffix","strippedCurrent","strippedToValue","toValue","current","startValue","paPrefix","paSuffix","paStrippedValue","prefNumberSuffOnFrame","res","tab","colorOnStart","RGBAValue","RGBACurrent","RGBAToValue","forEach","i","index","undefined","push","colorOnFrame","finished","arrayOnStart","v","arrayOnFrame","Array","isArray","IS_NATIVE","native","defineAnimation","starting","factory","create","_WORKLET","cancelAnimation","sharedValue","withStartValue"],"sources":["util.ts"],"sourcesContent":["import {\n HigherOrderAnimation,\n NextAnimation,\n DelayAnimation,\n RepeatAnimation,\n SequenceAnimation,\n StyleLayoutAnimation,\n} from './commonTypes';\n/* global _WORKLET */\nimport {\n ParsedColorArray,\n isColor,\n convertToRGBA,\n rgbaArrayToRGBAColor,\n toGammaSpace,\n toLinearSpace,\n} from '../Colors';\n\nimport {\n AnimatedStyle,\n SharedValue,\n AnimatableValue,\n Animation,\n AnimationObject,\n Timestamp,\n} from '../commonTypes';\nimport NativeReanimatedModule from '../NativeReanimated';\n\nlet IN_STYLE_UPDATER = false;\n\nexport type UserUpdater = () => AnimatedStyle;\n\nexport function initialUpdaterRun<T>(updater: () => T): T {\n IN_STYLE_UPDATER = true;\n const result = updater();\n IN_STYLE_UPDATER = false;\n return result;\n}\n\ninterface RecognizedPrefixSuffix {\n prefix?: string;\n suffix?: string;\n strippedValue: number;\n}\n\nfunction recognizePrefixSuffix(value: string | number): RecognizedPrefixSuffix {\n 'worklet';\n if (typeof value === 'string') {\n const match = value.match(\n /([A-Za-z]*)(-?\\d*\\.?\\d*)([eE][-+]?[0-9]+)?([A-Za-z%]*)/\n );\n if (!match) {\n throw Error(\n \"Couldn't parse animation value. Check if there isn't any typo.\"\n );\n }\n const prefix = match[1];\n const suffix = match[4];\n // number with scientific notation\n const number = match[2] + (match[3] ?? '');\n return { prefix, suffix, strippedValue: parseFloat(number) };\n } else {\n return { strippedValue: value };\n }\n}\n\nfunction decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(\n animation: T\n): void {\n 'worklet';\n if ((animation as HigherOrderAnimation).isHigherOrder) {\n return;\n }\n\n const baseOnStart = (animation as Animation<AnimationObject>).onStart;\n const baseOnFrame = (animation as Animation<AnimationObject>).onFrame;\n const animationCopy = Object.assign({}, animation);\n delete animationCopy.callback;\n\n const prefNumberSuffOnStart = (\n animation: Animation<AnimationObject>,\n value: string | number,\n timestamp: number,\n previousAnimation: Animation<AnimationObject>\n ) => {\n // recognize prefix, suffix, and updates stripped value on animation start\n const { prefix, suffix, strippedValue } = recognizePrefixSuffix(value);\n animation.__prefix = prefix;\n animation.__suffix = suffix;\n animation.strippedCurrent = strippedValue;\n const { strippedValue: strippedToValue } = recognizePrefixSuffix(\n animation.toValue as string | number\n );\n animation.current = strippedValue;\n animation.startValue = strippedValue;\n animation.toValue = strippedToValue;\n if (previousAnimation && previousAnimation !== animation) {\n const {\n prefix: paPrefix,\n suffix: paSuffix,\n strippedValue: paStrippedValue,\n } = recognizePrefixSuffix(previousAnimation.current as string | number);\n previousAnimation.current = paStrippedValue;\n previousAnimation.__prefix = paPrefix;\n previousAnimation.__suffix = paSuffix;\n }\n\n baseOnStart(animation, strippedValue, timestamp, previousAnimation);\n\n animation.current =\n (animation.__prefix ?? '') +\n animation.current +\n (animation.__suffix ?? '');\n\n if (previousAnimation && previousAnimation !== animation) {\n previousAnimation.current =\n (previousAnimation.__prefix ?? '') +\n previousAnimation.current +\n (previousAnimation.__suffix ?? '');\n }\n };\n const prefNumberSuffOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: number\n ) => {\n animation.current = animation.strippedCurrent;\n const res = baseOnFrame(animation, timestamp);\n animation.strippedCurrent = animation.current;\n animation.current =\n (animation.__prefix ?? '') +\n animation.current +\n (animation.__suffix ?? '');\n return res;\n };\n\n const tab = ['R', 'G', 'B', 'A'];\n const colorOnStart = (\n animation: Animation<AnimationObject>,\n value: string | number,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ): void => {\n let RGBAValue: ParsedColorArray;\n let RGBACurrent: ParsedColorArray;\n let RGBAToValue: ParsedColorArray;\n const res: Array<number> = [];\n if (isColor(value)) {\n RGBACurrent = toLinearSpace(convertToRGBA(animation.current));\n RGBAValue = toLinearSpace(convertToRGBA(value));\n if (animation.toValue) {\n RGBAToValue = toLinearSpace(convertToRGBA(animation.toValue));\n }\n }\n tab.forEach((i, index) => {\n animation[i] = Object.assign({}, animationCopy);\n animation[i].current = RGBACurrent[index];\n animation[i].toValue = RGBAToValue ? RGBAToValue[index] : undefined;\n animation[i].onStart(\n animation[i],\n RGBAValue[index],\n timestamp,\n previousAnimation ? previousAnimation[i] : undefined\n );\n res.push(animation[i].current);\n });\n\n animation.current = rgbaArrayToRGBAColor(\n toGammaSpace(res as ParsedColorArray)\n );\n };\n\n const colorOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: Timestamp\n ): boolean => {\n const RGBACurrent = toLinearSpace(convertToRGBA(animation.current));\n const res: Array<number> = [];\n let finished = true;\n tab.forEach((i, index) => {\n animation[i].current = RGBACurrent[index];\n // @ts-ignore: disable-next-line\n finished &= animation[i].onFrame(animation[i], timestamp);\n res.push(animation[i].current);\n });\n\n animation.current = rgbaArrayToRGBAColor(\n toGammaSpace(res as ParsedColorArray)\n );\n return finished;\n };\n\n const arrayOnStart = (\n animation: Animation<AnimationObject>,\n value: Array<number>,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ): void => {\n value.forEach((v, i) => {\n animation[i] = Object.assign({}, animationCopy);\n animation[i].current = v;\n animation[i].toValue = (animation.toValue as Array<number>)[i];\n animation[i].onStart(\n animation[i],\n v,\n timestamp,\n previousAnimation ? previousAnimation[i] : undefined\n );\n });\n\n animation.current = value;\n };\n\n const arrayOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: Timestamp\n ): boolean => {\n let finished = true;\n (animation.current as Array<number>).forEach((v, i) => {\n // @ts-ignore: disable-next-line\n finished &= animation[i].onFrame(animation[i], timestamp);\n (animation.current as Array<number>)[i] = animation[i].current;\n });\n\n return finished;\n };\n\n animation.onStart = (\n animation: Animation<AnimationObject>,\n value: number,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ) => {\n if (isColor(value)) {\n colorOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = colorOnFrame;\n return;\n } else if (Array.isArray(value)) {\n arrayOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = arrayOnFrame;\n return;\n } else if (typeof value === 'string') {\n prefNumberSuffOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = prefNumberSuffOnFrame;\n return;\n }\n baseOnStart(animation, value, timestamp, previousAnimation);\n };\n}\n\ntype AnimationToDecoration<T extends AnimationObject | StyleLayoutAnimation> =\n T extends StyleLayoutAnimation\n ? Record<string, unknown>\n : T extends DelayAnimation\n ? NextAnimation<DelayAnimation>\n : T extends RepeatAnimation\n ? NextAnimation<RepeatAnimation>\n : T extends SequenceAnimation\n ? NextAnimation<SequenceAnimation>\n : AnimatableValue | T;\n\nconst IS_NATIVE = NativeReanimatedModule.native;\n\nexport function defineAnimation<\n T extends AnimationObject | StyleLayoutAnimation\n>(starting: AnimationToDecoration<T>, factory: () => T): T {\n 'worklet';\n if (IN_STYLE_UPDATER) {\n return starting as T;\n }\n const create = () => {\n 'worklet';\n const animation = factory();\n decorateAnimation<T>(animation);\n return animation;\n };\n\n if (_WORKLET || !IS_NATIVE) {\n return create();\n }\n // @ts-ignore: eslint-disable-line\n return create;\n}\n\nexport function cancelAnimation<T>(sharedValue: SharedValue<T>): void {\n 'worklet';\n // setting the current value cancels the animation if one is currently running\n sharedValue.value = sharedValue.value; // eslint-disable-line no-self-assign\n}\n\n// TODO it should work only if there was no animation before.\nexport function withStartValue(\n startValue: AnimatableValue,\n animation: NextAnimation<AnimationObject>\n): Animation<AnimationObject> {\n 'worklet';\n return defineAnimation(startValue, () => {\n 'worklet';\n if (!_WORKLET && typeof animation === 'function') {\n animation = animation();\n }\n (animation as Animation<AnimationObject>).current = startValue;\n return animation as Animation<AnimationObject>;\n });\n}\n"],"mappings":"AAQA;AACA,SAEEA,OAAO,EACPC,aAAa,EACbC,oBAAoB,EACpBC,YAAY,EACZC,aAAa,QACR,WAAW;AAUlB,OAAOC,sBAAsB,MAAM,qBAAqB;AAExD,IAAIC,gBAAgB,GAAG,KAAK;AAI5B,OAAO,SAASC,iBAAiBA,CAAIC,OAAgB,EAAK;EACxDF,gBAAgB,GAAG,IAAI;EACvB,MAAMG,MAAM,GAAGD,OA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ACCA,SAAS,CAAgCkB,OAAO,GAAGC,UAAU;IAC9D,OAAOnB,SAAS;EAClB,CAAC,CAAC;AACJ"}
@@ -5,42 +5,35 @@
5
5
  // check other methods that may use them. However, this field is not actually defined
6
6
  // nor should be used for anything else as assigning any data to those objects will
7
7
  // throw an error.
8
- export let SensorType;
9
-
10
- (function (SensorType) {
8
+ export let SensorType = /*#__PURE__*/function (SensorType) {
11
9
  SensorType[SensorType["ACCELEROMETER"] = 1] = "ACCELEROMETER";
12
10
  SensorType[SensorType["GYROSCOPE"] = 2] = "GYROSCOPE";
13
11
  SensorType[SensorType["GRAVITY"] = 3] = "GRAVITY";
14
12
  SensorType[SensorType["MAGNETIC_FIELD"] = 4] = "MAGNETIC_FIELD";
15
13
  SensorType[SensorType["ROTATION"] = 5] = "ROTATION";
16
- })(SensorType || (SensorType = {}));
17
-
18
- export let IOSReferenceFrame;
19
-
20
- (function (IOSReferenceFrame) {
14
+ return SensorType;
15
+ }({});
16
+ export let IOSReferenceFrame = /*#__PURE__*/function (IOSReferenceFrame) {
21
17
  IOSReferenceFrame[IOSReferenceFrame["XArbitraryZVertical"] = 0] = "XArbitraryZVertical";
22
18
  IOSReferenceFrame[IOSReferenceFrame["XArbitraryCorrectedZVertical"] = 1] = "XArbitraryCorrectedZVertical";
23
19
  IOSReferenceFrame[IOSReferenceFrame["XMagneticNorthZVertical"] = 2] = "XMagneticNorthZVertical";
24
20
  IOSReferenceFrame[IOSReferenceFrame["XTrueNorthZVertical"] = 3] = "XTrueNorthZVertical";
25
21
  IOSReferenceFrame[IOSReferenceFrame["Auto"] = 4] = "Auto";
26
- })(IOSReferenceFrame || (IOSReferenceFrame = {}));
27
-
28
- export let InterfaceOrientation;
29
-
30
- (function (InterfaceOrientation) {
22
+ return IOSReferenceFrame;
23
+ }({});
24
+ export let InterfaceOrientation = /*#__PURE__*/function (InterfaceOrientation) {
31
25
  InterfaceOrientation[InterfaceOrientation["ROTATION_0"] = 0] = "ROTATION_0";
32
26
  InterfaceOrientation[InterfaceOrientation["ROTATION_90"] = 90] = "ROTATION_90";
33
27
  InterfaceOrientation[InterfaceOrientation["ROTATION_180"] = 180] = "ROTATION_180";
34
28
  InterfaceOrientation[InterfaceOrientation["ROTATION_270"] = 270] = "ROTATION_270";
35
- })(InterfaceOrientation || (InterfaceOrientation = {}));
36
-
37
- export let KeyboardState;
38
-
39
- (function (KeyboardState) {
29
+ return InterfaceOrientation;
30
+ }({});
31
+ export let KeyboardState = /*#__PURE__*/function (KeyboardState) {
40
32
  KeyboardState[KeyboardState["UNKNOWN"] = 0] = "UNKNOWN";
41
33
  KeyboardState[KeyboardState["OPENING"] = 1] = "OPENING";
42
34
  KeyboardState[KeyboardState["OPEN"] = 2] = "OPEN";
43
35
  KeyboardState[KeyboardState["CLOSING"] = 3] = "CLOSING";
44
36
  KeyboardState[KeyboardState["CLOSED"] = 4] = "CLOSED";
45
- })(KeyboardState || (KeyboardState = {}));
37
+ return KeyboardState;
38
+ }({});
46
39
  //# sourceMappingURL=commonTypes.js.map