react-native-reanimated 3.6.0 → 3.6.2

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 (263) hide show
  1. package/lib/module/createAnimatedComponent/createAnimatedComponent.js +12 -0
  2. package/lib/module/createAnimatedComponent/createAnimatedComponent.js.map +1 -1
  3. package/lib/module/createAnimatedComponent/setAndForwardRef.js +2 -0
  4. package/lib/module/createAnimatedComponent/setAndForwardRef.js.map +1 -1
  5. package/lib/module/reanimated2/Easing.js +3 -3
  6. package/lib/module/reanimated2/Easing.js.map +1 -1
  7. package/lib/module/reanimated2/PlatformChecker.js.map +1 -1
  8. package/lib/module/reanimated2/animation/decay/decay.js +9 -0
  9. package/lib/module/reanimated2/animation/decay/decay.js.map +1 -1
  10. package/lib/module/reanimated2/animation/decay/utils.js +13 -0
  11. package/lib/module/reanimated2/animation/decay/utils.js.map +1 -1
  12. package/lib/module/reanimated2/animation/delay.js +9 -0
  13. package/lib/module/reanimated2/animation/delay.js.map +1 -1
  14. package/lib/module/reanimated2/animation/repeat.js +11 -0
  15. package/lib/module/reanimated2/animation/repeat.js.map +1 -1
  16. package/lib/module/reanimated2/animation/sequence.js +10 -0
  17. package/lib/module/reanimated2/animation/sequence.js.map +1 -1
  18. package/lib/module/reanimated2/animation/spring.js +9 -0
  19. package/lib/module/reanimated2/animation/spring.js.map +1 -1
  20. package/lib/module/reanimated2/animation/springUtils.js +16 -0
  21. package/lib/module/reanimated2/animation/springUtils.js.map +1 -1
  22. package/lib/module/reanimated2/animation/timing.js +18 -0
  23. package/lib/module/reanimated2/animation/timing.js.map +1 -1
  24. package/lib/module/reanimated2/animation/util.js +7 -0
  25. package/lib/module/reanimated2/animation/util.js.map +1 -1
  26. package/lib/module/reanimated2/commonTypes.js +30 -7
  27. package/lib/module/reanimated2/commonTypes.js.map +1 -1
  28. package/lib/module/reanimated2/component/FlatList.js.map +1 -1
  29. package/lib/module/reanimated2/component/LayoutAnimationConfig.js +7 -0
  30. package/lib/module/reanimated2/component/LayoutAnimationConfig.js.map +1 -1
  31. package/lib/module/reanimated2/component/ScrollView.js.map +1 -1
  32. package/lib/module/reanimated2/globals.d.js.map +1 -1
  33. package/lib/module/reanimated2/helperTypes.js.map +1 -1
  34. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +8 -0
  35. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  36. package/lib/module/reanimated2/hook/useAnimatedProps.js +9 -0
  37. package/lib/module/reanimated2/hook/useAnimatedProps.js.map +1 -1
  38. package/lib/module/reanimated2/hook/useAnimatedReaction.js +6 -4
  39. package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  40. package/lib/module/reanimated2/hook/useAnimatedRef.js +7 -0
  41. package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
  42. package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js +10 -2
  43. package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
  44. package/lib/module/reanimated2/hook/useAnimatedSensor.js +10 -0
  45. package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  46. package/lib/module/reanimated2/hook/useAnimatedStyle.js +8 -0
  47. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  48. package/lib/module/reanimated2/hook/useDerivedValue.js +14 -8
  49. package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
  50. package/lib/module/reanimated2/hook/useEvent.js +7 -6
  51. package/lib/module/reanimated2/hook/useEvent.js.map +1 -1
  52. package/lib/module/reanimated2/hook/useFrameCallback.js +17 -0
  53. package/lib/module/reanimated2/hook/useFrameCallback.js.map +1 -1
  54. package/lib/module/reanimated2/hook/useHandler.js +8 -2
  55. package/lib/module/reanimated2/hook/useHandler.js.map +1 -1
  56. package/lib/module/reanimated2/hook/useReducedMotion.js +9 -0
  57. package/lib/module/reanimated2/hook/useReducedMotion.js.map +1 -1
  58. package/lib/module/reanimated2/hook/useScrollViewOffset.js +8 -0
  59. package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  60. package/lib/module/reanimated2/hook/useSharedValue.js +11 -3
  61. package/lib/module/reanimated2/hook/useSharedValue.js.map +1 -1
  62. package/lib/module/reanimated2/hook/useWorkletCallback.js +3 -0
  63. package/lib/module/reanimated2/hook/useWorkletCallback.js.map +1 -1
  64. package/lib/module/reanimated2/index.js +1 -1
  65. package/lib/module/reanimated2/index.js.map +1 -1
  66. package/lib/module/reanimated2/interpolateColor.js +21 -0
  67. package/lib/module/reanimated2/interpolateColor.js.map +1 -1
  68. package/lib/module/reanimated2/interpolation.js +51 -21
  69. package/lib/module/reanimated2/interpolation.js.map +1 -1
  70. package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +29 -2
  71. package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
  72. package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +67 -2
  73. package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
  74. package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +6 -3
  75. package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
  76. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +4 -0
  77. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  78. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +80 -0
  79. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  80. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js +79 -0
  81. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
  82. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js +96 -0
  83. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
  84. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +31 -0
  85. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  86. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +15 -0
  87. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
  88. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +31 -0
  89. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  90. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +63 -0
  91. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
  92. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +64 -0
  93. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  94. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +32 -0
  95. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
  96. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +128 -0
  97. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  98. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +8 -0
  99. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
  100. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +9 -0
  101. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
  102. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +8 -0
  103. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
  104. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +8 -0
  105. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
  106. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +10 -3
  107. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
  108. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +8 -0
  109. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
  110. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.js +49 -3
  111. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.js.map +1 -1
  112. package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js +4 -4
  113. package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js.map +1 -1
  114. package/lib/module/reanimated2/platform-specific/checkCppVersion.js +0 -2
  115. package/lib/module/reanimated2/platform-specific/checkCppVersion.js.map +1 -1
  116. package/lib/module/reanimated2/platform-specific/jsVersion.js +1 -1
  117. package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -1
  118. package/lib/module/reanimated2/platformFunctions/dispatchCommand.js +9 -0
  119. package/lib/module/reanimated2/platformFunctions/dispatchCommand.js.map +1 -1
  120. package/lib/module/reanimated2/platformFunctions/getRelativeCoords.js +14 -4
  121. package/lib/module/reanimated2/platformFunctions/getRelativeCoords.js.map +1 -1
  122. package/lib/module/reanimated2/platformFunctions/measure.js +7 -0
  123. package/lib/module/reanimated2/platformFunctions/measure.js.map +1 -1
  124. package/lib/module/reanimated2/platformFunctions/scrollTo.js +9 -0
  125. package/lib/module/reanimated2/platformFunctions/scrollTo.js.map +1 -1
  126. package/lib/module/reanimated2/platformFunctions/setNativeProps.js +8 -0
  127. package/lib/module/reanimated2/platformFunctions/setNativeProps.js.map +1 -1
  128. package/lib/module/reanimated2/runtimes.js +8 -0
  129. package/lib/module/reanimated2/runtimes.js.map +1 -1
  130. package/lib/module/reanimated2/threads.js +16 -6
  131. package/lib/module/reanimated2/threads.js.map +1 -1
  132. package/lib/typescript/createAnimatedComponent/createAnimatedComponent.d.ts +12 -0
  133. package/lib/typescript/reanimated2/Easing.d.ts +3 -3
  134. package/lib/typescript/reanimated2/animation/decay/decay.d.ts +8 -0
  135. package/lib/typescript/reanimated2/animation/decay/utils.d.ts +12 -0
  136. package/lib/typescript/reanimated2/animation/delay.d.ts +9 -0
  137. package/lib/typescript/reanimated2/animation/repeat.d.ts +11 -0
  138. package/lib/typescript/reanimated2/animation/sequence.d.ts +8 -0
  139. package/lib/typescript/reanimated2/animation/spring.d.ts +9 -0
  140. package/lib/typescript/reanimated2/animation/springUtils.d.ts +15 -0
  141. package/lib/typescript/reanimated2/animation/timing.d.ts +17 -0
  142. package/lib/typescript/reanimated2/animation/util.d.ts +6 -0
  143. package/lib/typescript/reanimated2/commonTypes.d.ts +25 -7
  144. package/lib/typescript/reanimated2/component/FlatList.d.ts +6 -0
  145. package/lib/typescript/reanimated2/component/LayoutAnimationConfig.d.ts +7 -0
  146. package/lib/typescript/reanimated2/component/ScrollView.d.ts +3 -2
  147. package/lib/typescript/reanimated2/helperTypes.d.ts +45 -3
  148. package/lib/typescript/reanimated2/hook/useAnimatedKeyboard.d.ts +7 -0
  149. package/lib/typescript/reanimated2/hook/useAnimatedProps.d.ts +9 -0
  150. package/lib/typescript/reanimated2/hook/useAnimatedReaction.d.ts +6 -4
  151. package/lib/typescript/reanimated2/hook/useAnimatedRef.d.ts +6 -0
  152. package/lib/typescript/reanimated2/hook/useAnimatedScrollHandler.d.ts +10 -0
  153. package/lib/typescript/reanimated2/hook/useAnimatedSensor.d.ts +8 -0
  154. package/lib/typescript/reanimated2/hook/useAnimatedStyle.d.ts +8 -0
  155. package/lib/typescript/reanimated2/hook/useDerivedValue.d.ts +9 -1
  156. package/lib/typescript/reanimated2/hook/useEvent.d.ts +8 -5
  157. package/lib/typescript/reanimated2/hook/useFrameCallback.d.ts +14 -0
  158. package/lib/typescript/reanimated2/hook/useHandler.d.ts +8 -0
  159. package/lib/typescript/reanimated2/hook/useReducedMotion.d.ts +8 -0
  160. package/lib/typescript/reanimated2/hook/useScrollViewOffset.d.ts +7 -0
  161. package/lib/typescript/reanimated2/hook/useSharedValue.d.ts +8 -1
  162. package/lib/typescript/reanimated2/hook/useWorkletCallback.d.ts +3 -0
  163. package/lib/typescript/reanimated2/index.d.ts +1 -1
  164. package/lib/typescript/reanimated2/interpolateColor.d.ts +17 -0
  165. package/lib/typescript/reanimated2/interpolation.d.ts +30 -2
  166. package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.d.ts +25 -2
  167. package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +56 -1
  168. package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/commonTypes.d.ts +4 -0
  169. package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Bounce.d.ts +70 -0
  170. package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Fade.d.ts +70 -0
  171. package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Flip.d.ts +84 -0
  172. package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.d.ts +28 -0
  173. package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.d.ts +14 -0
  174. package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Roll.d.ts +28 -0
  175. package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Rotate.d.ts +56 -0
  176. package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Slide.d.ts +56 -0
  177. package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Stretch.d.ts +28 -0
  178. package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Zoom.d.ts +112 -0
  179. package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +7 -0
  180. package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +8 -0
  181. package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.d.ts +7 -0
  182. package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +7 -0
  183. package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.d.ts +10 -0
  184. package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +7 -0
  185. package/lib/typescript/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.d.ts +43 -1
  186. package/lib/typescript/reanimated2/layoutReanimation/web/createAnimation.d.ts +4 -4
  187. package/lib/typescript/reanimated2/platform-specific/jsVersion.d.ts +1 -1
  188. package/lib/typescript/reanimated2/platformFunctions/dispatchCommand.d.ts +8 -0
  189. package/lib/typescript/reanimated2/platformFunctions/getRelativeCoords.d.ts +11 -3
  190. package/lib/typescript/reanimated2/platformFunctions/measure.d.ts +7 -0
  191. package/lib/typescript/reanimated2/platformFunctions/scrollTo.d.ts +9 -0
  192. package/lib/typescript/reanimated2/platformFunctions/setNativeProps.d.ts +7 -0
  193. package/lib/typescript/reanimated2/runtimes.d.ts +8 -0
  194. package/lib/typescript/reanimated2/threads.d.ts +17 -2
  195. package/package.json +2 -1
  196. package/src/createAnimatedComponent/createAnimatedComponent.tsx +18 -0
  197. package/src/createAnimatedComponent/setAndForwardRef.ts +2 -0
  198. package/src/reanimated2/Easing.ts +3 -3
  199. package/src/reanimated2/PlatformChecker.ts +1 -1
  200. package/src/reanimated2/animation/decay/decay.ts +8 -0
  201. package/src/reanimated2/animation/decay/utils.ts +12 -0
  202. package/src/reanimated2/animation/delay.ts +9 -0
  203. package/src/reanimated2/animation/repeat.ts +11 -0
  204. package/src/reanimated2/animation/sequence.ts +8 -0
  205. package/src/reanimated2/animation/spring.ts +9 -0
  206. package/src/reanimated2/animation/springUtils.ts +15 -0
  207. package/src/reanimated2/animation/timing.ts +17 -0
  208. package/src/reanimated2/animation/util.ts +6 -0
  209. package/src/reanimated2/commonTypes.ts +25 -7
  210. package/src/reanimated2/component/FlatList.tsx +6 -0
  211. package/src/reanimated2/component/LayoutAnimationConfig.tsx +7 -0
  212. package/src/reanimated2/component/ScrollView.tsx +3 -1
  213. package/src/reanimated2/globals.d.ts +1 -1
  214. package/src/reanimated2/helperTypes.ts +45 -3
  215. package/src/reanimated2/hook/useAnimatedKeyboard.ts +7 -0
  216. package/src/reanimated2/hook/useAnimatedProps.ts +9 -0
  217. package/src/reanimated2/hook/useAnimatedReaction.ts +6 -4
  218. package/src/reanimated2/hook/useAnimatedRef.ts +6 -0
  219. package/src/reanimated2/hook/useAnimatedScrollHandler.ts +10 -0
  220. package/src/reanimated2/hook/useAnimatedSensor.ts +8 -0
  221. package/src/reanimated2/hook/useAnimatedStyle.ts +8 -0
  222. package/src/reanimated2/hook/useDerivedValue.ts +15 -7
  223. package/src/reanimated2/hook/useEvent.ts +9 -6
  224. package/src/reanimated2/hook/useFrameCallback.ts +14 -0
  225. package/src/reanimated2/hook/useHandler.ts +8 -0
  226. package/src/reanimated2/hook/useReducedMotion.ts +8 -0
  227. package/src/reanimated2/hook/useScrollViewOffset.ts +7 -0
  228. package/src/reanimated2/hook/useSharedValue.ts +12 -3
  229. package/src/reanimated2/hook/useWorkletCallback.ts +3 -0
  230. package/src/reanimated2/index.ts +1 -1
  231. package/src/reanimated2/interpolateColor.ts +17 -0
  232. package/src/reanimated2/interpolation.ts +48 -22
  233. package/src/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.ts +26 -3
  234. package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +57 -2
  235. package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +7 -6
  236. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +4 -0
  237. package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +71 -0
  238. package/src/reanimated2/layoutReanimation/defaultAnimations/Fade.ts +70 -1
  239. package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +84 -0
  240. package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +28 -0
  241. package/src/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.ts +14 -0
  242. package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +28 -0
  243. package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +56 -0
  244. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +56 -0
  245. package/src/reanimated2/layoutReanimation/defaultAnimations/Stretch.ts +28 -0
  246. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +112 -0
  247. package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +7 -0
  248. package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +8 -0
  249. package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +7 -0
  250. package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +8 -0
  251. package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +10 -3
  252. package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +7 -0
  253. package/src/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.ts +45 -3
  254. package/src/reanimated2/layoutReanimation/web/createAnimation.ts +4 -4
  255. package/src/reanimated2/platform-specific/checkCppVersion.ts +0 -4
  256. package/src/reanimated2/platform-specific/jsVersion.ts +1 -1
  257. package/src/reanimated2/platformFunctions/dispatchCommand.ts +8 -0
  258. package/src/reanimated2/platformFunctions/getRelativeCoords.ts +12 -4
  259. package/src/reanimated2/platformFunctions/measure.ts +7 -0
  260. package/src/reanimated2/platformFunctions/scrollTo.ts +9 -0
  261. package/src/reanimated2/platformFunctions/setNativeProps.ts +7 -0
  262. package/src/reanimated2/runtimes.ts +8 -0
  263. package/src/reanimated2/threads.ts +18 -7
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useRef","startMapper","stopMapper","makeRemote","updateProps","updatePropsJestWrapper","initialUpdaterRun","useSharedValue","buildWorkletsHash","isAnimated","shallowEqual","validateAnimatedStyles","makeViewDescriptorsSet","useViewRefSet","isJest","shouldBeUseWeb","SHOULD_BE_USE_WEB","prepareAnimation","frameTimestamp","animatedProp","lastAnimation","lastValue","Array","isArray","forEach","prop","index","onFrame","animation","value","current","undefined","callStart","timestamp","onStart","Object","keys","key","runAnimations","result","animationsActive","allFinished","entry","finished","callback","k","styleUpdater","viewDescriptors","updater","state","maybeViewRef","isAnimatedProps","arguments","length","animations","newValues","oldValues","last","nonAnimatedNewValues","hasAnimations","hasNonAnimatedValues","global","__frameTimestamp","_getAnimationTimestamp","frame","isAnimationCancelled","isAnimationRunning","updates","propName","requestAnimationFrame","jestStyleUpdater","animatedStyle","adapters","checkSharedValueUsage","currentKey","element","Error","useAnimatedStyle","dependencies","viewsRef","initRef","inputs","values","__closure","_dependencies","__DEV__","__workletHash","adaptersArray","adaptersHash","push","initialStyle","initial","remoteState","shareableViewDescriptors","fun","updaterFn","adapter","mapperId"],"sources":["useAnimatedStyle.ts"],"sourcesContent":["'use strict';\nimport type { MutableRefObject } from 'react';\nimport { useEffect, useRef } from 'react';\n\nimport { startMapper, stopMapper, makeRemote } from '../core';\nimport updateProps, { updatePropsJestWrapper } from '../UpdateProps';\nimport { initialUpdaterRun } from '../animation';\nimport { useSharedValue } from './useSharedValue';\nimport {\n buildWorkletsHash,\n isAnimated,\n shallowEqual,\n validateAnimatedStyles,\n} from './utils';\nimport type { DefaultStyle, DependencyList, Descriptor } from './commonTypes';\nimport type { ViewDescriptorsSet, ViewRefSet } from '../ViewDescriptorsSet';\nimport { makeViewDescriptorsSet, useViewRefSet } from '../ViewDescriptorsSet';\nimport { isJest, shouldBeUseWeb } from '../PlatformChecker';\nimport type {\n AnimationObject,\n Timestamp,\n NestedObjectValues,\n SharedValue,\n StyleProps,\n __AdapterWorkletFunction,\n __BasicWorkletFunction,\n WorkletFunction,\n} from '../commonTypes';\nimport type { AnimatedStyle } from '../helperTypes';\n\nconst SHOULD_BE_USE_WEB = shouldBeUseWeb();\n\ninterface AnimatedState {\n last: AnimatedStyle<any>;\n animations: AnimatedStyle<any>;\n isAnimationRunning: boolean;\n isAnimationCancelled: boolean;\n}\n\ninterface AnimationRef {\n initial: {\n value: AnimatedStyle<any>;\n updater: () => AnimatedStyle<any>;\n };\n remoteState: AnimatedState;\n viewDescriptors: ViewDescriptorsSet;\n}\n\nfunction prepareAnimation(\n frameTimestamp: number,\n animatedProp: AnimatedStyle<any>,\n lastAnimation: AnimatedStyle<any>,\n lastValue: AnimatedStyle<any>\n): void {\n 'worklet';\n if (Array.isArray(animatedProp)) {\n animatedProp.forEach((prop, index) => {\n prepareAnimation(\n frameTimestamp,\n prop,\n lastAnimation && lastAnimation[index],\n lastValue && lastValue[index]\n );\n });\n // return animatedProp;\n }\n if (typeof animatedProp === 'object' && animatedProp.onFrame) {\n const animation = animatedProp;\n\n let value = animation.current;\n if (lastValue !== undefined) {\n if (typeof lastValue === 'object') {\n if (lastValue.value !== undefined) {\n // previously it was a shared value\n value = lastValue.value;\n } else if (lastValue.onFrame !== undefined) {\n if (lastAnimation?.current !== undefined) {\n // it was an animation before, copy its state\n value = lastAnimation.current;\n } else if (lastValue?.current !== undefined) {\n // it was initialized\n value = lastValue.current;\n }\n }\n } else {\n // previously it was a plain value, just set it as starting point\n value = lastValue;\n }\n }\n\n animation.callStart = (timestamp: Timestamp) => {\n animation.onStart(animation, value, timestamp, lastAnimation);\n };\n animation.callStart(frameTimestamp);\n animation.callStart = null;\n } else if (typeof animatedProp === 'object') {\n // it is an object\n Object.keys(animatedProp).forEach((key) =>\n prepareAnimation(\n frameTimestamp,\n animatedProp[key],\n lastAnimation && lastAnimation[key],\n lastValue && lastValue[key]\n )\n );\n }\n}\n\nfunction runAnimations(\n animation: AnimatedStyle<any>,\n timestamp: Timestamp,\n key: number | string,\n result: AnimatedStyle<any>,\n animationsActive: SharedValue<boolean>\n): boolean {\n 'worklet';\n if (!animationsActive.value) {\n return true;\n }\n if (Array.isArray(animation)) {\n result[key] = [];\n let allFinished = true;\n animation.forEach((entry, index) => {\n if (\n !runAnimations(entry, timestamp, index, result[key], animationsActive)\n ) {\n allFinished = false;\n }\n });\n return allFinished;\n } else if (typeof animation === 'object' && animation.onFrame) {\n let finished = true;\n if (!animation.finished) {\n if (animation.callStart) {\n animation.callStart(timestamp);\n animation.callStart = null;\n }\n finished = animation.onFrame(animation, timestamp);\n animation.timestamp = timestamp;\n if (finished) {\n animation.finished = true;\n animation.callback && animation.callback(true /* finished */);\n }\n }\n result[key] = animation.current;\n return finished;\n } else if (typeof animation === 'object') {\n result[key] = {};\n let allFinished = true;\n Object.keys(animation).forEach((k) => {\n if (\n !runAnimations(\n animation[k],\n timestamp,\n k,\n result[key],\n animationsActive\n )\n ) {\n allFinished = false;\n }\n });\n return allFinished;\n } else {\n result[key] = animation;\n return true;\n }\n}\n\nfunction styleUpdater(\n viewDescriptors: SharedValue<Descriptor[]>,\n updater: __BasicWorkletFunction<AnimatedStyle<any>>,\n state: AnimatedState,\n maybeViewRef: ViewRefSet<any> | undefined,\n animationsActive: SharedValue<boolean>,\n isAnimatedProps = false\n): void {\n 'worklet';\n const animations = state.animations ?? {};\n const newValues = updater() ?? {};\n const oldValues = state.last;\n const nonAnimatedNewValues: StyleProps = {};\n\n let hasAnimations = false;\n let frameTimestamp: number | undefined;\n let hasNonAnimatedValues = false;\n for (const key in newValues) {\n const value = newValues[key];\n if (isAnimated(value)) {\n frameTimestamp = global.__frameTimestamp || _getAnimationTimestamp();\n prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);\n animations[key] = value;\n hasAnimations = true;\n } else {\n hasNonAnimatedValues = true;\n nonAnimatedNewValues[key] = value;\n delete animations[key];\n }\n }\n\n if (hasAnimations) {\n const frame = (timestamp: Timestamp) => {\n const { animations, last, isAnimationCancelled } = state;\n if (isAnimationCancelled) {\n state.isAnimationRunning = false;\n return;\n }\n\n const updates: AnimatedStyle<any> = {};\n let allFinished = true;\n for (const propName in animations) {\n const finished = runAnimations(\n animations[propName],\n timestamp,\n propName,\n updates,\n animationsActive\n );\n if (finished) {\n last[propName] = updates[propName];\n delete animations[propName];\n } else {\n allFinished = false;\n }\n }\n\n if (updates) {\n updateProps(viewDescriptors, updates, maybeViewRef);\n }\n\n if (!allFinished) {\n requestAnimationFrame(frame);\n } else {\n state.isAnimationRunning = false;\n }\n };\n\n state.animations = animations;\n if (!state.isAnimationRunning) {\n state.isAnimationCancelled = false;\n state.isAnimationRunning = true;\n frame(frameTimestamp!);\n }\n\n if (hasNonAnimatedValues) {\n updateProps(viewDescriptors, nonAnimatedNewValues, maybeViewRef);\n }\n } else {\n state.isAnimationCancelled = true;\n state.animations = [];\n\n if (!shallowEqual(oldValues, newValues)) {\n updateProps(viewDescriptors, newValues, maybeViewRef, isAnimatedProps);\n }\n }\n state.last = newValues;\n}\n\nfunction jestStyleUpdater(\n viewDescriptors: SharedValue<Descriptor[]>,\n updater: __BasicWorkletFunction<AnimatedStyle<any>>,\n state: AnimatedState,\n maybeViewRef: ViewRefSet<any> | undefined,\n animationsActive: SharedValue<boolean>,\n animatedStyle: MutableRefObject<AnimatedStyle<any>>,\n adapters: __AdapterWorkletFunction[] = []\n): void {\n 'worklet';\n const animations: AnimatedStyle<any> = state.animations ?? {};\n const newValues = updater() ?? {};\n const oldValues = state.last;\n\n // extract animated props\n let hasAnimations = false;\n let frameTimestamp: number | undefined;\n Object.keys(animations).forEach((key) => {\n const value = newValues[key];\n if (!isAnimated(value)) {\n delete animations[key];\n }\n });\n Object.keys(newValues).forEach((key) => {\n const value = newValues[key];\n if (isAnimated(value)) {\n frameTimestamp = global.__frameTimestamp || _getAnimationTimestamp();\n prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);\n animations[key] = value;\n hasAnimations = true;\n }\n });\n\n function frame(timestamp: Timestamp) {\n const { animations, last, isAnimationCancelled } = state;\n if (isAnimationCancelled) {\n state.isAnimationRunning = false;\n return;\n }\n\n const updates: AnimatedStyle<any> = {};\n let allFinished = true;\n Object.keys(animations).forEach((propName) => {\n const finished = runAnimations(\n animations[propName],\n timestamp,\n propName,\n updates,\n animationsActive\n );\n if (finished) {\n last[propName] = updates[propName];\n delete animations[propName];\n } else {\n allFinished = false;\n }\n });\n\n if (Object.keys(updates).length) {\n updatePropsJestWrapper(\n viewDescriptors,\n updates,\n maybeViewRef,\n animatedStyle,\n adapters\n );\n }\n\n if (!allFinished) {\n requestAnimationFrame(frame);\n } else {\n state.isAnimationRunning = false;\n }\n }\n\n if (hasAnimations) {\n state.animations = animations;\n if (!state.isAnimationRunning) {\n state.isAnimationCancelled = false;\n state.isAnimationRunning = true;\n frame(frameTimestamp!);\n }\n } else {\n state.isAnimationCancelled = true;\n state.animations = [];\n }\n\n // calculate diff\n state.last = newValues;\n\n if (!shallowEqual(oldValues, newValues)) {\n updatePropsJestWrapper(\n viewDescriptors,\n newValues,\n maybeViewRef,\n animatedStyle,\n adapters\n );\n }\n}\n\n// check for invalid usage of shared values in returned object\nfunction checkSharedValueUsage(\n prop: NestedObjectValues<AnimationObject>,\n currentKey?: string\n): void {\n if (Array.isArray(prop)) {\n // if it's an array (i.ex. transform) validate all its elements\n for (const element of prop) {\n checkSharedValueUsage(element, currentKey);\n }\n } else if (\n typeof prop === 'object' &&\n prop !== null &&\n prop.value === undefined\n ) {\n // if it's a nested object, run validation for all its props\n for (const key of Object.keys(prop)) {\n checkSharedValueUsage(prop[key], key);\n }\n } else if (\n currentKey !== undefined &&\n typeof prop === 'object' &&\n prop !== null &&\n prop.value !== undefined\n ) {\n // if shared value is passed insted of its value, throw an error\n throw new Error(\n `[Reanimated] Invalid value passed to \\`${currentKey}\\`, maybe you forgot to use \\`.value\\`?`\n );\n }\n}\n\n// You cannot pass Shared Values to `useAnimatedStyle` directly.\n// @ts-expect-error This overload is required by our API.\nexport function useAnimatedStyle<Style extends DefaultStyle>(\n updater: () => Style,\n dependencies?: DependencyList | null\n): Style;\n\nexport function useAnimatedStyle<Style extends DefaultStyle>(\n updater: WorkletFunction<[], Style>,\n dependencies?: DependencyList | null,\n adapters?: WorkletFunction | WorkletFunction[],\n isAnimatedProps = false\n) {\n const viewsRef: ViewRefSet<unknown> = useViewRefSet();\n const initRef = useRef<AnimationRef>();\n let inputs = Object.values(updater.__closure ?? {});\n if (SHOULD_BE_USE_WEB) {\n if (!inputs.length && dependencies?.length) {\n // let web work without a Babel/SWC plugin\n inputs = dependencies;\n }\n if (__DEV__ && !inputs.length && !dependencies && !updater.__workletHash) {\n throw new Error(\n `[Reanimated] \\`useAnimatedStyle\\` was used without a dependency array or Babel plugin. Please explicitly pass a dependency array, or enable the Babel/SWC plugin.\nFor more, see the docs: \\`https://docs.swmansion.com/react-native-reanimated/docs/guides/web-support#web-without-the-babel-plugin\\`.`\n );\n }\n }\n const adaptersArray = adapters\n ? Array.isArray(adapters)\n ? adapters\n : [adapters]\n : [];\n const adaptersHash = adapters ? buildWorkletsHash(adaptersArray) : null;\n const animationsActive = useSharedValue<boolean>(true);\n const animatedStyle: MutableRefObject<Style> = useRef<Style>({} as Style);\n\n // build dependencies\n if (!dependencies) {\n dependencies = [...inputs, updater.__workletHash];\n } else {\n dependencies.push(updater.__workletHash);\n }\n adaptersHash && dependencies.push(adaptersHash);\n\n if (!initRef.current) {\n const initialStyle = initialUpdaterRun(updater);\n validateAnimatedStyles(initialStyle);\n initRef.current = {\n initial: {\n value: initialStyle,\n updater: updater,\n },\n remoteState: makeRemote<AnimatedState>({\n last: initialStyle,\n animations: {},\n isAnimationCancelled: false,\n isAnimationRunning: false,\n }),\n viewDescriptors: makeViewDescriptorsSet(),\n };\n }\n\n const { initial, remoteState, viewDescriptors } = initRef.current;\n const shareableViewDescriptors = viewDescriptors.shareableViewDescriptors;\n const maybeViewRef = SHOULD_BE_USE_WEB ? viewsRef : undefined;\n\n dependencies.push(shareableViewDescriptors);\n\n useEffect(() => {\n let fun;\n let updaterFn = updater;\n if (adapters) {\n updaterFn = (() => {\n 'worklet';\n const newValues = updater();\n adaptersArray.forEach((adapter) => {\n adapter(newValues);\n });\n return newValues;\n }) as WorkletFunction<[], Style>;\n }\n\n if (isJest()) {\n fun = () => {\n 'worklet';\n jestStyleUpdater(\n shareableViewDescriptors,\n updater,\n remoteState,\n maybeViewRef,\n animationsActive,\n animatedStyle,\n adaptersArray\n );\n };\n } else {\n fun = () => {\n 'worklet';\n styleUpdater(\n shareableViewDescriptors,\n updaterFn,\n remoteState,\n maybeViewRef,\n animationsActive,\n isAnimatedProps\n );\n };\n }\n const mapperId = startMapper(fun, inputs);\n return () => {\n stopMapper(mapperId);\n };\n }, dependencies);\n\n useEffect(() => {\n animationsActive.value = true;\n return () => {\n animationsActive.value = false;\n };\n }, []);\n\n checkSharedValueUsage(initial.value);\n\n if (isJest()) {\n return { viewDescriptors, initial, viewsRef, animatedStyle };\n } else {\n return { viewDescriptors, initial, viewsRef };\n }\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAEzC,SAASC,WAAW,EAAEC,UAAU,EAAEC,UAAU,QAAQ,SAAS;AAC7D,OAAOC,WAAW,IAAIC,sBAAsB,QAAQ,gBAAgB;AACpE,SAASC,iBAAiB,QAAQ,cAAc;AAChD,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SACEC,iBAAiB,EACjBC,UAAU,EACVC,YAAY,EACZC,sBAAsB,QACjB,SAAS;AAGhB,SAASC,sBAAsB,EAAEC,aAAa,QAAQ,uBAAuB;AAC7E,SAASC,MAAM,EAAEC,cAAc,QAAQ,oBAAoB;AAa3D,MAAMC,iBAAiB,GAAGD,cAAc,EAAE;AAkB1C,SAASE,gBAAgBA,CACvBC,cAAsB,EACtBC,YAAgC,EAChCC,aAAiC,EACjCC,SAA6B,EACvB;EACN,SAAS;;EACT,IAAIC,KAAK,CAACC,OAAO,CAACJ,YAAY,CAAC,EAAE;IAC/BA,YAAY,CAACK,OAAO,CAAC,CAACC,IAAI,EAAEC,KAAK,KAAK;MACpCT,gBAAgB,CACdC,cAAc,EACdO,IAAI,EACJL,aAAa,IAAIA,aAAa,CAACM,KAAK,CAAC,EACrCL,SAAS,I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
1
+ {"version":3,"names":["useEffect","useRef","startMapper","stopMapper","makeRemote","updateProps","updatePropsJestWrapper","initialUpdaterRun","useSharedValue","buildWorkletsHash","isAnimated","shallowEqual","validateAnimatedStyles","makeViewDescriptorsSet","useViewRefSet","isJest","shouldBeUseWeb","SHOULD_BE_USE_WEB","prepareAnimation","frameTimestamp","animatedProp","lastAnimation","lastValue","Array","isArray","forEach","prop","index","onFrame","animation","value","current","undefined","callStart","timestamp","onStart","Object","keys","key","runAnimations","result","animationsActive","allFinished","entry","finished","callback","k","styleUpdater","viewDescriptors","updater","state","maybeViewRef","isAnimatedProps","arguments","length","animations","newValues","oldValues","last","nonAnimatedNewValues","hasAnimations","hasNonAnimatedValues","global","__frameTimestamp","_getAnimationTimestamp","frame","isAnimationCancelled","isAnimationRunning","updates","propName","requestAnimationFrame","jestStyleUpdater","animatedStyle","adapters","checkSharedValueUsage","currentKey","element","Error","useAnimatedStyle","dependencies","viewsRef","initRef","inputs","values","__closure","_dependencies","__DEV__","__workletHash","adaptersArray","adaptersHash","push","initialStyle","initial","remoteState","shareableViewDescriptors","fun","updaterFn","adapter","mapperId"],"sources":["useAnimatedStyle.ts"],"sourcesContent":["'use strict';\nimport type { MutableRefObject } from 'react';\nimport { useEffect, useRef } from 'react';\n\nimport { startMapper, stopMapper, makeRemote } from '../core';\nimport updateProps, { updatePropsJestWrapper } from '../UpdateProps';\nimport { initialUpdaterRun } from '../animation';\nimport { useSharedValue } from './useSharedValue';\nimport {\n buildWorkletsHash,\n isAnimated,\n shallowEqual,\n validateAnimatedStyles,\n} from './utils';\nimport type { DefaultStyle, DependencyList, Descriptor } from './commonTypes';\nimport type { ViewDescriptorsSet, ViewRefSet } from '../ViewDescriptorsSet';\nimport { makeViewDescriptorsSet, useViewRefSet } from '../ViewDescriptorsSet';\nimport { isJest, shouldBeUseWeb } from '../PlatformChecker';\nimport type {\n AnimationObject,\n Timestamp,\n NestedObjectValues,\n SharedValue,\n StyleProps,\n __AdapterWorkletFunction,\n __BasicWorkletFunction,\n WorkletFunction,\n} from '../commonTypes';\nimport type { AnimatedStyle } from '../helperTypes';\n\nconst SHOULD_BE_USE_WEB = shouldBeUseWeb();\n\ninterface AnimatedState {\n last: AnimatedStyle<any>;\n animations: AnimatedStyle<any>;\n isAnimationRunning: boolean;\n isAnimationCancelled: boolean;\n}\n\ninterface AnimationRef {\n initial: {\n value: AnimatedStyle<any>;\n updater: () => AnimatedStyle<any>;\n };\n remoteState: AnimatedState;\n viewDescriptors: ViewDescriptorsSet;\n}\n\nfunction prepareAnimation(\n frameTimestamp: number,\n animatedProp: AnimatedStyle<any>,\n lastAnimation: AnimatedStyle<any>,\n lastValue: AnimatedStyle<any>\n): void {\n 'worklet';\n if (Array.isArray(animatedProp)) {\n animatedProp.forEach((prop, index) => {\n prepareAnimation(\n frameTimestamp,\n prop,\n lastAnimation && lastAnimation[index],\n lastValue && lastValue[index]\n );\n });\n // return animatedProp;\n }\n if (typeof animatedProp === 'object' && animatedProp.onFrame) {\n const animation = animatedProp;\n\n let value = animation.current;\n if (lastValue !== undefined) {\n if (typeof lastValue === 'object') {\n if (lastValue.value !== undefined) {\n // previously it was a shared value\n value = lastValue.value;\n } else if (lastValue.onFrame !== undefined) {\n if (lastAnimation?.current !== undefined) {\n // it was an animation before, copy its state\n value = lastAnimation.current;\n } else if (lastValue?.current !== undefined) {\n // it was initialized\n value = lastValue.current;\n }\n }\n } else {\n // previously it was a plain value, just set it as starting point\n value = lastValue;\n }\n }\n\n animation.callStart = (timestamp: Timestamp) => {\n animation.onStart(animation, value, timestamp, lastAnimation);\n };\n animation.callStart(frameTimestamp);\n animation.callStart = null;\n } else if (typeof animatedProp === 'object') {\n // it is an object\n Object.keys(animatedProp).forEach((key) =>\n prepareAnimation(\n frameTimestamp,\n animatedProp[key],\n lastAnimation && lastAnimation[key],\n lastValue && lastValue[key]\n )\n );\n }\n}\n\nfunction runAnimations(\n animation: AnimatedStyle<any>,\n timestamp: Timestamp,\n key: number | string,\n result: AnimatedStyle<any>,\n animationsActive: SharedValue<boolean>\n): boolean {\n 'worklet';\n if (!animationsActive.value) {\n return true;\n }\n if (Array.isArray(animation)) {\n result[key] = [];\n let allFinished = true;\n animation.forEach((entry, index) => {\n if (\n !runAnimations(entry, timestamp, index, result[key], animationsActive)\n ) {\n allFinished = false;\n }\n });\n return allFinished;\n } else if (typeof animation === 'object' && animation.onFrame) {\n let finished = true;\n if (!animation.finished) {\n if (animation.callStart) {\n animation.callStart(timestamp);\n animation.callStart = null;\n }\n finished = animation.onFrame(animation, timestamp);\n animation.timestamp = timestamp;\n if (finished) {\n animation.finished = true;\n animation.callback && animation.callback(true /* finished */);\n }\n }\n result[key] = animation.current;\n return finished;\n } else if (typeof animation === 'object') {\n result[key] = {};\n let allFinished = true;\n Object.keys(animation).forEach((k) => {\n if (\n !runAnimations(\n animation[k],\n timestamp,\n k,\n result[key],\n animationsActive\n )\n ) {\n allFinished = false;\n }\n });\n return allFinished;\n } else {\n result[key] = animation;\n return true;\n }\n}\n\nfunction styleUpdater(\n viewDescriptors: SharedValue<Descriptor[]>,\n updater: __BasicWorkletFunction<AnimatedStyle<any>>,\n state: AnimatedState,\n maybeViewRef: ViewRefSet<any> | undefined,\n animationsActive: SharedValue<boolean>,\n isAnimatedProps = false\n): void {\n 'worklet';\n const animations = state.animations ?? {};\n const newValues = updater() ?? {};\n const oldValues = state.last;\n const nonAnimatedNewValues: StyleProps = {};\n\n let hasAnimations = false;\n let frameTimestamp: number | undefined;\n let hasNonAnimatedValues = false;\n for (const key in newValues) {\n const value = newValues[key];\n if (isAnimated(value)) {\n frameTimestamp = global.__frameTimestamp || _getAnimationTimestamp();\n prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);\n animations[key] = value;\n hasAnimations = true;\n } else {\n hasNonAnimatedValues = true;\n nonAnimatedNewValues[key] = value;\n delete animations[key];\n }\n }\n\n if (hasAnimations) {\n const frame = (timestamp: Timestamp) => {\n const { animations, last, isAnimationCancelled } = state;\n if (isAnimationCancelled) {\n state.isAnimationRunning = false;\n return;\n }\n\n const updates: AnimatedStyle<any> = {};\n let allFinished = true;\n for (const propName in animations) {\n const finished = runAnimations(\n animations[propName],\n timestamp,\n propName,\n updates,\n animationsActive\n );\n if (finished) {\n last[propName] = updates[propName];\n delete animations[propName];\n } else {\n allFinished = false;\n }\n }\n\n if (updates) {\n updateProps(viewDescriptors, updates, maybeViewRef);\n }\n\n if (!allFinished) {\n requestAnimationFrame(frame);\n } else {\n state.isAnimationRunning = false;\n }\n };\n\n state.animations = animations;\n if (!state.isAnimationRunning) {\n state.isAnimationCancelled = false;\n state.isAnimationRunning = true;\n frame(frameTimestamp!);\n }\n\n if (hasNonAnimatedValues) {\n updateProps(viewDescriptors, nonAnimatedNewValues, maybeViewRef);\n }\n } else {\n state.isAnimationCancelled = true;\n state.animations = [];\n\n if (!shallowEqual(oldValues, newValues)) {\n updateProps(viewDescriptors, newValues, maybeViewRef, isAnimatedProps);\n }\n }\n state.last = newValues;\n}\n\nfunction jestStyleUpdater(\n viewDescriptors: SharedValue<Descriptor[]>,\n updater: __BasicWorkletFunction<AnimatedStyle<any>>,\n state: AnimatedState,\n maybeViewRef: ViewRefSet<any> | undefined,\n animationsActive: SharedValue<boolean>,\n animatedStyle: MutableRefObject<AnimatedStyle<any>>,\n adapters: __AdapterWorkletFunction[] = []\n): void {\n 'worklet';\n const animations: AnimatedStyle<any> = state.animations ?? {};\n const newValues = updater() ?? {};\n const oldValues = state.last;\n\n // extract animated props\n let hasAnimations = false;\n let frameTimestamp: number | undefined;\n Object.keys(animations).forEach((key) => {\n const value = newValues[key];\n if (!isAnimated(value)) {\n delete animations[key];\n }\n });\n Object.keys(newValues).forEach((key) => {\n const value = newValues[key];\n if (isAnimated(value)) {\n frameTimestamp = global.__frameTimestamp || _getAnimationTimestamp();\n prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);\n animations[key] = value;\n hasAnimations = true;\n }\n });\n\n function frame(timestamp: Timestamp) {\n const { animations, last, isAnimationCancelled } = state;\n if (isAnimationCancelled) {\n state.isAnimationRunning = false;\n return;\n }\n\n const updates: AnimatedStyle<any> = {};\n let allFinished = true;\n Object.keys(animations).forEach((propName) => {\n const finished = runAnimations(\n animations[propName],\n timestamp,\n propName,\n updates,\n animationsActive\n );\n if (finished) {\n last[propName] = updates[propName];\n delete animations[propName];\n } else {\n allFinished = false;\n }\n });\n\n if (Object.keys(updates).length) {\n updatePropsJestWrapper(\n viewDescriptors,\n updates,\n maybeViewRef,\n animatedStyle,\n adapters\n );\n }\n\n if (!allFinished) {\n requestAnimationFrame(frame);\n } else {\n state.isAnimationRunning = false;\n }\n }\n\n if (hasAnimations) {\n state.animations = animations;\n if (!state.isAnimationRunning) {\n state.isAnimationCancelled = false;\n state.isAnimationRunning = true;\n frame(frameTimestamp!);\n }\n } else {\n state.isAnimationCancelled = true;\n state.animations = [];\n }\n\n // calculate diff\n state.last = newValues;\n\n if (!shallowEqual(oldValues, newValues)) {\n updatePropsJestWrapper(\n viewDescriptors,\n newValues,\n maybeViewRef,\n animatedStyle,\n adapters\n );\n }\n}\n\n// check for invalid usage of shared values in returned object\nfunction checkSharedValueUsage(\n prop: NestedObjectValues<AnimationObject>,\n currentKey?: string\n): void {\n if (Array.isArray(prop)) {\n // if it's an array (i.ex. transform) validate all its elements\n for (const element of prop) {\n checkSharedValueUsage(element, currentKey);\n }\n } else if (\n typeof prop === 'object' &&\n prop !== null &&\n prop.value === undefined\n ) {\n // if it's a nested object, run validation for all its props\n for (const key of Object.keys(prop)) {\n checkSharedValueUsage(prop[key], key);\n }\n } else if (\n currentKey !== undefined &&\n typeof prop === 'object' &&\n prop !== null &&\n prop.value !== undefined\n ) {\n // if shared value is passed insted of its value, throw an error\n throw new Error(\n `[Reanimated] Invalid value passed to \\`${currentKey}\\`, maybe you forgot to use \\`.value\\`?`\n );\n }\n}\n\n/**\n * Lets you create a styles object, similar to StyleSheet styles, which can be animated using shared values.\n *\n * @param updater - A function returning an object with style properties you want to animate.\n * @param dependencies - An optional array of dependencies. Only relevant when using Reanimated without the Babel plugin on the Web.\n * @returns An animated style object which has to be passed to the `style` property of an Animated component you want to animate.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/core/useAnimatedStyle\n */\n// You cannot pass Shared Values to `useAnimatedStyle` directly.\n// @ts-expect-error This overload is required by our API.\nexport function useAnimatedStyle<Style extends DefaultStyle>(\n updater: () => Style,\n dependencies?: DependencyList | null\n): Style;\n\nexport function useAnimatedStyle<Style extends DefaultStyle>(\n updater: WorkletFunction<[], Style>,\n dependencies?: DependencyList | null,\n adapters?: WorkletFunction | WorkletFunction[],\n isAnimatedProps = false\n) {\n const viewsRef: ViewRefSet<unknown> = useViewRefSet();\n const initRef = useRef<AnimationRef>();\n let inputs = Object.values(updater.__closure ?? {});\n if (SHOULD_BE_USE_WEB) {\n if (!inputs.length && dependencies?.length) {\n // let web work without a Babel/SWC plugin\n inputs = dependencies;\n }\n if (__DEV__ && !inputs.length && !dependencies && !updater.__workletHash) {\n throw new Error(\n `[Reanimated] \\`useAnimatedStyle\\` was used without a dependency array or Babel plugin. Please explicitly pass a dependency array, or enable the Babel/SWC plugin.\nFor more, see the docs: \\`https://docs.swmansion.com/react-native-reanimated/docs/guides/web-support#web-without-the-babel-plugin\\`.`\n );\n }\n }\n const adaptersArray = adapters\n ? Array.isArray(adapters)\n ? adapters\n : [adapters]\n : [];\n const adaptersHash = adapters ? buildWorkletsHash(adaptersArray) : null;\n const animationsActive = useSharedValue<boolean>(true);\n const animatedStyle: MutableRefObject<Style> = useRef<Style>({} as Style);\n\n // build dependencies\n if (!dependencies) {\n dependencies = [...inputs, updater.__workletHash];\n } else {\n dependencies.push(updater.__workletHash);\n }\n adaptersHash && dependencies.push(adaptersHash);\n\n if (!initRef.current) {\n const initialStyle = initialUpdaterRun(updater);\n validateAnimatedStyles(initialStyle);\n initRef.current = {\n initial: {\n value: initialStyle,\n updater: updater,\n },\n remoteState: makeRemote<AnimatedState>({\n last: initialStyle,\n animations: {},\n isAnimationCancelled: false,\n isAnimationRunning: false,\n }),\n viewDescriptors: makeViewDescriptorsSet(),\n };\n }\n\n const { initial, remoteState, viewDescriptors } = initRef.current;\n const shareableViewDescriptors = viewDescriptors.shareableViewDescriptors;\n const maybeViewRef = SHOULD_BE_USE_WEB ? viewsRef : undefined;\n\n dependencies.push(shareableViewDescriptors);\n\n useEffect(() => {\n let fun;\n let updaterFn = updater;\n if (adapters) {\n updaterFn = (() => {\n 'worklet';\n const newValues = updater();\n adaptersArray.forEach((adapter) => {\n adapter(newValues);\n });\n return newValues;\n }) as WorkletFunction<[], Style>;\n }\n\n if (isJest()) {\n fun = () => {\n 'worklet';\n jestStyleUpdater(\n shareableViewDescriptors,\n updater,\n remoteState,\n maybeViewRef,\n animationsActive,\n animatedStyle,\n adaptersArray\n );\n };\n } else {\n fun = () => {\n 'worklet';\n styleUpdater(\n shareableViewDescriptors,\n updaterFn,\n remoteState,\n maybeViewRef,\n animationsActive,\n isAnimatedProps\n );\n };\n }\n const mapperId = startMapper(fun, inputs);\n return () => {\n stopMapper(mapperId);\n };\n }, dependencies);\n\n useEffect(() => {\n animationsActive.value = true;\n return () => {\n animationsActive.value = false;\n };\n }, []);\n\n checkSharedValueUsage(initial.value);\n\n if (isJest()) {\n return { viewDescriptors, initial, viewsRef, animatedStyle };\n } else {\n return { viewDescriptors, initial, viewsRef };\n }\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAEzC,SAASC,WAAW,EAAEC,UAAU,EAAEC,UAAU,QAAQ,SAAS;AAC7D,OAAOC,WAAW,IAAIC,sBAAsB,QAAQ,gBAAgB;AACpE,SAASC,iBAAiB,QAAQ,cAAc;AAChD,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SACEC,iBAAiB,EACjBC,UAAU,EACVC,YAAY,EACZC,sBAAsB,QACjB,SAAS;AAGhB,SAASC,sBAAsB,EAAEC,aAAa,QAAQ,uBAAuB;AAC7E,SAASC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AEnB,YAAY,CAAC;EAEhB/E,SAAS,CAAC,MAAM;IACdyC,gBAAgB,CAACX,KAAK,GAAG,IAAI;IAC7B,OAAO,MAAM;MACXW,gBAAgB,CAACX,KAAK,GAAG,KAAK;IAChC,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN4C,qBAAqB,CAACkB,OAAO,CAAC9D,KAAK,CAAC;EAEpC,IAAIf,MAAM,EAAE,EAAE;IACZ,OAAO;MAAEiC,eAAe;MAAE4C,OAAO;MAAEZ,QAAQ;MAAER;IAAc,CAAC;EAC9D,CAAC,MAAM;IACL,OAAO;MAAExB,eAAe;MAAE4C,OAAO;MAAEZ;IAAS,CAAC;EAC/C;AACF"}
@@ -5,11 +5,17 @@ import { initialUpdaterRun } from '../animation';
5
5
  import { makeMutable, startMapper, stopMapper } from '../core';
6
6
  import { shouldBeUseWeb } from '../PlatformChecker';
7
7
 
8
- // @ts-expect-error This overload is required by our API.
9
-
10
- export function useDerivedValue(processor, dependencies) {
8
+ /**
9
+ * Lets you create new shared values based on existing ones while keeping them reactive.
10
+ *
11
+ * @param updater - A function called whenever at least one of the shared values or state used in the function body changes.
12
+ * @param dependencies - An optional array of dependencies. Only relevant when using Reanimated without the Babel plugin on the Web.
13
+ * @returns A new readonly shared value based on a value returned from the updater function
14
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/core/useDerivedValue
15
+ */ // @ts-expect-error This overload is required by our API.
16
+ export function useDerivedValue(updater, dependencies) {
11
17
  const initRef = useRef(null);
12
- let inputs = Object.values(processor.__closure ?? {});
18
+ let inputs = Object.values(updater.__closure ?? {});
13
19
  if (shouldBeUseWeb()) {
14
20
  var _dependencies;
15
21
  if (!inputs.length && (_dependencies = dependencies) !== null && _dependencies !== void 0 && _dependencies.length) {
@@ -20,12 +26,12 @@ export function useDerivedValue(processor, dependencies) {
20
26
 
21
27
  // build dependencies
22
28
  if (dependencies === undefined) {
23
- dependencies = [...inputs, processor.__workletHash];
29
+ dependencies = [...inputs, updater.__workletHash];
24
30
  } else {
25
- dependencies.push(processor.__workletHash);
31
+ dependencies.push(updater.__workletHash);
26
32
  }
27
33
  if (initRef.current === null) {
28
- initRef.current = makeMutable(initialUpdaterRun(processor));
34
+ initRef.current = makeMutable(initialUpdaterRun(updater));
29
35
  }
30
36
 
31
37
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -34,7 +40,7 @@ export function useDerivedValue(processor, dependencies) {
34
40
  const fun = () => {
35
41
  'worklet';
36
42
 
37
- sharedValue.value = processor();
43
+ sharedValue.value = updater();
38
44
  };
39
45
  const mapperId = startMapper(fun, inputs, [sharedValue]);
40
46
  return () => {
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useRef","initialUpdaterRun","makeMutable","startMapper","stopMapper","shouldBeUseWeb","useDerivedValue","processor","dependencies","initRef","inputs","Object","values","__closure","_dependencies","length","undefined","__workletHash","push","current","sharedValue","fun","value","mapperId"],"sources":["useDerivedValue.ts"],"sourcesContent":["'use strict';\nimport { useEffect, useRef } from 'react';\nimport { initialUpdaterRun } from '../animation';\nimport type { SharedValue, WorkletFunction } from '../commonTypes';\nimport { makeMutable, startMapper, stopMapper } from '../core';\nimport type { DependencyList } from './commonTypes';\nimport { shouldBeUseWeb } from '../PlatformChecker';\n\nexport type DerivedValue<Value> = Readonly<SharedValue<Value>>;\n\n// @ts-expect-error This overload is required by our API.\nexport function useDerivedValue<Value>(\n processor: () => Value,\n dependencies?: DependencyList\n): DerivedValue<Value>;\n\nexport function useDerivedValue<Value>(\n processor: WorkletFunction<[], Value>,\n dependencies?: DependencyList\n): DerivedValue<Value> {\n const initRef = useRef<SharedValue<Value> | null>(null);\n let inputs = Object.values(processor.__closure ?? {});\n if (shouldBeUseWeb()) {\n if (!inputs.length && dependencies?.length) {\n // let web work without a Babel/SWC plugin\n inputs = dependencies;\n }\n }\n\n // build dependencies\n if (dependencies === undefined) {\n dependencies = [...inputs, processor.__workletHash];\n } else {\n dependencies.push(processor.__workletHash);\n }\n\n if (initRef.current === null) {\n initRef.current = makeMutable(initialUpdaterRun(processor));\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const sharedValue: SharedValue<Value> = initRef.current!;\n\n useEffect(() => {\n const fun = () => {\n 'worklet';\n sharedValue.value = processor();\n };\n const mapperId = startMapper(fun, inputs, [sharedValue]);\n return () => {\n stopMapper(mapperId);\n };\n }, dependencies);\n\n useEffect(() => {\n return () => {\n initRef.current = null;\n };\n }, []);\n\n return sharedValue;\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACzC,SAASC,iBAAiB,QAAQ,cAAc;AAEhD,SAASC,WAAW,EAAEC,WAAW,EAAEC,UAAU,QAAQ,SAAS;AAE9D,SAASC,cAAc,QAAQ,oBAAoB;;AAInD;;AAMA,OAAO,SAASC,eAAeA,CAC7BC,SAAqC,EACrCC,YAA6B,EACR;EACrB,MAAMC,OAAO,GAAGT,MAAM,CAA4B,IAAI,CAAC;EACvD,IAAIU,MAAM,GAAGC,MAAM,CAACC,MAAM,CAACL,SAAS,CAACM,SAAS,IAAI,CAAC,CAAC,CAAC;EACrD,IAAIR,cAAc,EAAE,EAAE;IAAA,IAAAS,aAAA;IACpB,IAAI,CAACJ,MAAM,CAACK,MAAM,KAAAD,aAAA,GAAIN,YAAY,cAAAM,aAAA,eAAZA,aAAA,CAAcC,MAAM,EAAE;MAC1C;MACAL,MAAM,GAAGF,YAAY;IACvB;EACF;;EAEA;EACA,IAAIA,YAAY,KAAKQ,SAAS,EAAE;IAC9BR,YAAY,GAAG,CAAC,GAAGE,MAAM,EAAEH,SAAS,CAACU,aAAa,CAAC;EACrD,CAAC,MAAM;IACLT,YAAY,CAACU,IAAI,CAACX,SAAS,CAACU,aAAa,CAAC;EAC5C;EAEA,IAAIR,OAAO,CAACU,OAAO,KAAK,IAAI,EAAE;IAC5BV,OAAO,CAACU,OAAO,GAAGjB,WAAW,CAACD,iBAAiB,CAACM,SAAS,CAAC,CAAC;EAC7D;;EAEA;EACA,MAAMa,WAA+B,GAAGX,OAAO,CAACU,OAAQ;EAExDpB,SAAS,CAAC,MAAM;IACd,MAAMsB,GAAG,GAAGA,CAAA,KAAM;MAChB,SAAS;;MACTD,WAAW,CAACE,KAAK,GAAGf,SAAS,EAAE;IACjC,CAAC;IACD,MAAMgB,QAAQ,GAAGpB,WAAW,CAACkB,GAAG,EAAEX,MAAM,EAAE,CAACU,WAAW,CAAC,CAAC;IACxD,OAAO,MAAM;MACXhB,UAAU,CAACmB,QAAQ,CAAC;IACtB,CAAC;EACH,CAAC,EAAEf,YAAY,CAAC;EAEhBT,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACXU,OAAO,CAACU,OAAO,GAAG,IAAI;IACxB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOC,WAAW;AACpB"}
1
+ {"version":3,"names":["useEffect","useRef","initialUpdaterRun","makeMutable","startMapper","stopMapper","shouldBeUseWeb","useDerivedValue","updater","dependencies","initRef","inputs","Object","values","__closure","_dependencies","length","undefined","__workletHash","push","current","sharedValue","fun","value","mapperId"],"sources":["useDerivedValue.ts"],"sourcesContent":["'use strict';\nimport { useEffect, useRef } from 'react';\nimport { initialUpdaterRun } from '../animation';\nimport type { SharedValue, WorkletFunction } from '../commonTypes';\nimport { makeMutable, startMapper, stopMapper } from '../core';\nimport type { DependencyList } from './commonTypes';\nimport { shouldBeUseWeb } from '../PlatformChecker';\n\nexport type DerivedValue<Value> = Readonly<SharedValue<Value>>;\n\n/**\n * Lets you create new shared values based on existing ones while keeping them reactive.\n *\n * @param updater - A function called whenever at least one of the shared values or state used in the function body changes.\n * @param dependencies - An optional array of dependencies. Only relevant when using Reanimated without the Babel plugin on the Web.\n * @returns A new readonly shared value based on a value returned from the updater function\n * @see https://docs.swmansion.com/react-native-reanimated/docs/core/useDerivedValue\n */\n// @ts-expect-error This overload is required by our API.\nexport function useDerivedValue<Value>(\n updater: () => Value,\n dependencies?: DependencyList\n): DerivedValue<Value>;\n\nexport function useDerivedValue<Value>(\n updater: WorkletFunction<[], Value>,\n dependencies?: DependencyList\n): DerivedValue<Value> {\n const initRef = useRef<SharedValue<Value> | null>(null);\n let inputs = Object.values(updater.__closure ?? {});\n if (shouldBeUseWeb()) {\n if (!inputs.length && dependencies?.length) {\n // let web work without a Babel/SWC plugin\n inputs = dependencies;\n }\n }\n\n // build dependencies\n if (dependencies === undefined) {\n dependencies = [...inputs, updater.__workletHash];\n } else {\n dependencies.push(updater.__workletHash);\n }\n\n if (initRef.current === null) {\n initRef.current = makeMutable(initialUpdaterRun(updater));\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const sharedValue: SharedValue<Value> = initRef.current!;\n\n useEffect(() => {\n const fun = () => {\n 'worklet';\n sharedValue.value = updater();\n };\n const mapperId = startMapper(fun, inputs, [sharedValue]);\n return () => {\n stopMapper(mapperId);\n };\n }, dependencies);\n\n useEffect(() => {\n return () => {\n initRef.current = null;\n };\n }, []);\n\n return sharedValue;\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACzC,SAASC,iBAAiB,QAAQ,cAAc;AAEhD,SAASC,WAAW,EAAEC,WAAW,EAAEC,UAAU,QAAQ,SAAS;AAE9D,SAASC,cAAc,QAAQ,oBAAoB;;AAInD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAPA,CAQA;AAMA,OAAO,SAASC,eAAeA,CAC7BC,OAAmC,EACnCC,YAA6B,EACR;EACrB,MAAMC,OAAO,GAAGT,MAAM,CAA4B,IAAI,CAAC;EACvD,IAAIU,MAAM,GAAGC,MAAM,CAACC,MAAM,CAACL,OAAO,CAACM,SAAS,IAAI,CAAC,CAAC,CAAC;EACnD,IAAIR,cAAc,EAAE,EAAE;IAAA,IAAAS,aAAA;IACpB,IAAI,CAACJ,MAAM,CAACK,MAAM,KAAAD,aAAA,GAAIN,YAAY,cAAAM,aAAA,eAAZA,aAAA,CAAcC,MAAM,EAAE;MAC1C;MACAL,MAAM,GAAGF,YAAY;IACvB;EACF;;EAEA;EACA,IAAIA,YAAY,KAAKQ,SAAS,EAAE;IAC9BR,YAAY,GAAG,CAAC,GAAGE,MAAM,EAAEH,OAAO,CAACU,aAAa,CAAC;EACnD,CAAC,MAAM;IACLT,YAAY,CAACU,IAAI,CAACX,OAAO,CAACU,aAAa,CAAC;EAC1C;EAEA,IAAIR,OAAO,CAACU,OAAO,KAAK,IAAI,EAAE;IAC5BV,OAAO,CAACU,OAAO,GAAGjB,WAAW,CAACD,iBAAiB,CAACM,OAAO,CAAC,CAAC;EAC3D;;EAEA;EACA,MAAMa,WAA+B,GAAGX,OAAO,CAACU,OAAQ;EAExDpB,SAAS,CAAC,MAAM;IACd,MAAMsB,GAAG,GAAGA,CAAA,KAAM;MAChB,SAAS;;MACTD,WAAW,CAACE,KAAK,GAAGf,OAAO,EAAE;IAC/B,CAAC;IACD,MAAMgB,QAAQ,GAAGpB,WAAW,CAACkB,GAAG,EAAEX,MAAM,EAAE,CAACU,WAAW,CAAC,CAAC;IACxD,OAAO,MAAM;MACXhB,UAAU,CAACmB,QAAQ,CAAC;IACtB,CAAC;EACH,CAAC,EAAEf,YAAY,CAAC;EAEhBT,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACXU,OAAO,CAACU,OAAO,GAAG,IAAI;IACxB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOC,WAAW;AACpB"}
@@ -8,13 +8,14 @@ import WorkletEventHandler from '../WorkletEventHandler';
8
8
  */
9
9
 
10
10
  /**
11
- * Return type of `useEvent` hook.
11
+ * Lets you run a function whenever a specified native event occurs.
12
+ *
13
+ * @param handler - A function that receives an event object with event data - {@link EventHandler}.
14
+ * @param eventNames - An array of event names the `handler` callback will react to.
15
+ * @param rebuild - Whether the event handler should be rebuilt. Defaults to `false`.
16
+ * @returns A function that will be called when the event occurs - {@link EventHandlerProcessed}.
17
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/useEvent
12
18
  */
13
-
14
- /**
15
- * Real return type of `useEvent` hook - only meant to be used internally.
16
- */
17
-
18
19
  // @ts-expect-error This overload is required by our API.
19
20
  // We don't know which properites of a component that is made into
20
21
  // an AnimatedComponent are event handlers and we don't want to force the user to define it.
@@ -1 +1 @@
1
- {"version":3,"names":["useRef","WorkletEventHandler","useEvent","handler","eventNames","arguments","length","undefined","rebuild","initRef","current","updateWorklet"],"sources":["useEvent.ts"],"sourcesContent":["'use strict';\nimport type { MutableRefObject } from 'react';\nimport { useRef } from 'react';\nimport WorkletEventHandler from '../WorkletEventHandler';\nimport type { ReanimatedEvent } from './commonTypes';\n\n/**\n * Worklet to provide as an argument to `useEvent` hook.\n */\nexport type EventHandler<\n Event extends object,\n Context extends Record<string, unknown> = never\n> = (event: ReanimatedEvent<Event>, context?: Context) => void;\n\n/**\n * Return type of `useEvent` hook.\n */\nexport type EventHandlerProcessed<\n Event extends object,\n Context extends Record<string, unknown> = never\n> = (event: Event, context?: Context) => void;\n\n/**\n * Real return type of `useEvent` hook - only meant to be used internally.\n */\nexport type EventHandlerInternal<Event extends object> = MutableRefObject<\n WorkletEventHandler<Event>\n>;\n\n// @ts-expect-error This overload is required by our API.\n// We don't know which properites of a component that is made into\n// an AnimatedComponent are event handlers and we don't want to force the user to define it.\n// Therefore we disguise `useEvent` return type as a simple function and we handle\n// it being a React Ref in `createAnimatedComponent`.\nexport function useEvent<\n Event extends object,\n Context extends Record<string, unknown> = never\n>(\n handler: EventHandler<Event, Context>,\n eventNames?: string[],\n rebuild?: boolean\n): EventHandlerProcessed<Event, Context>;\n\nexport function useEvent<Event extends object, Context = never>(\n handler: (event: ReanimatedEvent<Event>, context?: Context) => void,\n eventNames: string[] = [],\n rebuild = false\n): EventHandlerInternal<Event> {\n const initRef = useRef<WorkletEventHandler<Event> | null>(null);\n if (initRef.current === null) {\n initRef.current = new WorkletEventHandler<Event>(handler, eventNames);\n } else if (rebuild) {\n initRef.current.updateWorklet(handler);\n }\n\n // We cast it since we don't want to expose initial null value outside.\n return initRef as EventHandlerInternal<Event>;\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,MAAM,QAAQ,OAAO;AAC9B,OAAOC,mBAAmB,MAAM,wBAAwB;;AAGxD;AACA;AACA;;AAMA;AACA;AACA;;AAMA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AAUA,OAAO,SAASC,QAAQA,CACtBC,OAAmE,EAGtC;EAAA,IAF7BC,UAAoB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EAAA,IACzBG,OAAO,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAEf,MAAMI,OAAO,GAAGT,MAAM,CAAoC,IAAI,CAAC;EAC/D,IAAIS,OAAO,CAACC,OAAO,KAAK,IAAI,EAAE;IAC5BD,OAAO,CAACC,OAAO,GAAG,IAAIT,mBAAmB,CAAQE,OAAO,EAAEC,UAAU,CAAC;EACvE,CAAC,MAAM,IAAII,OAAO,EAAE;IAClBC,OAAO,CAACC,OAAO,CAACC,aAAa,CAACR,OAAO,CAAC;EACxC;;EAEA;EACA,OAAOM,OAAO;AAChB"}
1
+ {"version":3,"names":["useRef","WorkletEventHandler","useEvent","handler","eventNames","arguments","length","undefined","rebuild","initRef","current","updateWorklet"],"sources":["useEvent.ts"],"sourcesContent":["'use strict';\nimport type { MutableRefObject } from 'react';\nimport { useRef } from 'react';\nimport WorkletEventHandler from '../WorkletEventHandler';\nimport type { ReanimatedEvent } from './commonTypes';\n\n/**\n * Worklet to provide as an argument to `useEvent` hook.\n */\nexport type EventHandler<\n Event extends object,\n Context extends Record<string, unknown> = never\n> = (event: ReanimatedEvent<Event>, context?: Context) => void;\n\nexport type EventHandlerProcessed<\n Event extends object,\n Context extends Record<string, unknown> = never\n> = (event: Event, context?: Context) => void;\n\nexport type EventHandlerInternal<Event extends object> = MutableRefObject<\n WorkletEventHandler<Event>\n>;\n\n/**\n * Lets you run a function whenever a specified native event occurs.\n *\n * @param handler - A function that receives an event object with event data - {@link EventHandler}.\n * @param eventNames - An array of event names the `handler` callback will react to.\n * @param rebuild - Whether the event handler should be rebuilt. Defaults to `false`.\n * @returns A function that will be called when the event occurs - {@link EventHandlerProcessed}.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/useEvent\n */\n// @ts-expect-error This overload is required by our API.\n// We don't know which properites of a component that is made into\n// an AnimatedComponent are event handlers and we don't want to force the user to define it.\n// Therefore we disguise `useEvent` return type as a simple function and we handle\n// it being a React Ref in `createAnimatedComponent`.\nexport function useEvent<\n Event extends object,\n Context extends Record<string, unknown> = never\n>(\n handler: EventHandler<Event, Context>,\n eventNames?: string[],\n rebuild?: boolean\n): EventHandlerProcessed<Event, Context>;\n\nexport function useEvent<Event extends object, Context = never>(\n handler: (event: ReanimatedEvent<Event>, context?: Context) => void,\n eventNames: string[] = [],\n rebuild = false\n): EventHandlerInternal<Event> {\n const initRef = useRef<WorkletEventHandler<Event> | null>(null);\n if (initRef.current === null) {\n initRef.current = new WorkletEventHandler<Event>(handler, eventNames);\n } else if (rebuild) {\n initRef.current.updateWorklet(handler);\n }\n\n // We cast it since we don't want to expose initial null value outside.\n return initRef as EventHandlerInternal<Event>;\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,MAAM,QAAQ,OAAO;AAC9B,OAAOC,mBAAmB,MAAM,wBAAwB;;AAGxD;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAUA,OAAO,SAASC,QAAQA,CACtBC,OAAmE,EAGtC;EAAA,IAF7BC,UAAoB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EAAA,IACzBG,OAAO,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAEf,MAAMI,OAAO,GAAGT,MAAM,CAAoC,IAAI,CAAC;EAC/D,IAAIS,OAAO,CAACC,OAAO,KAAK,IAAI,EAAE;IAC5BD,OAAO,CAACC,OAAO,GAAG,IAAIT,mBAAmB,CAAQE,OAAO,EAAEC,UAAU,CAAC;EACvE,CAAC,MAAM,IAAII,OAAO,EAAE;IAClBC,OAAO,CAACC,OAAO,CAACC,aAAa,CAACR,OAAO,CAAC;EACxC;;EAEA;EACA,OAAOM,OAAO;AAChB"}
@@ -2,7 +2,24 @@
2
2
 
3
3
  import { useEffect, useRef } from 'react';
4
4
  import FrameCallbackRegistryJS from '../frameCallback/FrameCallbackRegistryJS';
5
+
6
+ /**
7
+ * @param setActive - A function that lets you start the frame callback or stop it from running.
8
+ * @param isActive - A boolean indicating whether a callback is running.
9
+ * @param callbackId - A number indicating a unique identifier of the frame callback.
10
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/useFrameCallback#returns
11
+ */
12
+
5
13
  const frameCallbackRegistry = new FrameCallbackRegistryJS();
14
+
15
+ /**
16
+ * Lets you run a function on every frame update.
17
+ *
18
+ * @param callback - A function executed on every frame update.
19
+ * @param autostart - Whether the callback should start automatically. Defaults to `true`.
20
+ * @returns A frame callback object - {@link FrameCallback}.
21
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/useFrameCallback
22
+ */
6
23
  export function useFrameCallback(callback) {
7
24
  let autostart = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
8
25
  const ref = useRef({
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useRef","FrameCallbackRegistryJS","frameCallbackRegistry","useFrameCallback","callback","autostart","arguments","length","undefined","ref","setActive","isActive","manageStateFrameCallback","current","callbackId","registerFrameCallback","unregisterFrameCallback"],"sources":["useFrameCallback.ts"],"sourcesContent":["'use strict';\nimport { useEffect, useRef } from 'react';\nimport FrameCallbackRegistryJS from '../frameCallback/FrameCallbackRegistryJS';\nimport type { FrameInfo } from '../frameCallback/FrameCallbackRegistryUI';\n\nexport type FrameCallback = {\n setActive: (isActive: boolean) => void;\n isActive: boolean;\n callbackId: number;\n};\nconst frameCallbackRegistry = new FrameCallbackRegistryJS();\n\nexport function useFrameCallback(\n callback: (frameInfo: FrameInfo) => void,\n autostart = true\n): FrameCallback {\n const ref = useRef<FrameCallback>({\n setActive: (isActive: boolean) => {\n frameCallbackRegistry.manageStateFrameCallback(\n ref.current.callbackId,\n isActive\n );\n ref.current.isActive = isActive;\n },\n isActive: autostart,\n callbackId: -1,\n });\n\n useEffect(() => {\n ref.current.callbackId =\n frameCallbackRegistry.registerFrameCallback(callback);\n ref.current.setActive(ref.current.isActive);\n\n return () => {\n frameCallbackRegistry.unregisterFrameCallback(ref.current.callbackId);\n ref.current.callbackId = -1;\n };\n }, [callback, autostart]);\n\n return ref.current;\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACzC,OAAOC,uBAAuB,MAAM,0CAA0C;AAQ9E,MAAMC,qBAAqB,GAAG,IAAID,uBAAuB,EAAE;AAE3D,OAAO,SAASE,gBAAgBA,CAC9BC,QAAwC,EAEzB;EAAA,IADfC,SAAS,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;EAEhB,MAAMG,GAAG,GAAGT,MAAM,CAAgB;IAChCU,SAAS,EAAGC,QAAiB,IAAK;MAChCT,qBAAqB,CAACU,wBAAwB,CAC5CH,GAAG,CAACI,OAAO,CAACC,UAAU,EACtBH,QAAQ,CACT;MACDF,GAAG,CAACI,OAAO,CAACF,QAAQ,GAAGA,QAAQ;IACjC,CAAC;IACDA,QAAQ,EAAEN,SAAS;IACnBS,UAAU,EAAE,CAAC;EACf,CAAC,CAAC;EAEFf,SAAS,CAAC,MAAM;IACdU,GAAG,CAACI,OAAO,CAACC,UAAU,GACpBZ,qBAAqB,CAACa,qBAAqB,CAACX,QAAQ,CAAC;IACvDK,GAAG,CAACI,OAAO,CAACH,SAAS,CAACD,GAAG,CAACI,OAAO,CAACF,QAAQ,CAAC;IAE3C,OAAO,MAAM;MACXT,qBAAqB,CAACc,uBAAuB,CAACP,GAAG,CAACI,OAAO,CAACC,UAAU,CAAC;MACrEL,GAAG,CAACI,OAAO,CAACC,UAAU,GAAG,CAAC,CAAC;IAC7B,CAAC;EACH,CAAC,EAAE,CAACV,QAAQ,EAAEC,SAAS,CAAC,CAAC;EAEzB,OAAOI,GAAG,CAACI,OAAO;AACpB"}
1
+ {"version":3,"names":["useEffect","useRef","FrameCallbackRegistryJS","frameCallbackRegistry","useFrameCallback","callback","autostart","arguments","length","undefined","ref","setActive","isActive","manageStateFrameCallback","current","callbackId","registerFrameCallback","unregisterFrameCallback"],"sources":["useFrameCallback.ts"],"sourcesContent":["'use strict';\nimport { useEffect, useRef } from 'react';\nimport FrameCallbackRegistryJS from '../frameCallback/FrameCallbackRegistryJS';\nimport type { FrameInfo } from '../frameCallback/FrameCallbackRegistryUI';\n\n/**\n * @param setActive - A function that lets you start the frame callback or stop it from running.\n * @param isActive - A boolean indicating whether a callback is running.\n * @param callbackId - A number indicating a unique identifier of the frame callback.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/useFrameCallback#returns\n */\nexport type FrameCallback = {\n setActive: (isActive: boolean) => void;\n isActive: boolean;\n callbackId: number;\n};\nconst frameCallbackRegistry = new FrameCallbackRegistryJS();\n\n/**\n * Lets you run a function on every frame update.\n *\n * @param callback - A function executed on every frame update.\n * @param autostart - Whether the callback should start automatically. Defaults to `true`.\n * @returns A frame callback object - {@link FrameCallback}.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/useFrameCallback\n */\nexport function useFrameCallback(\n callback: (frameInfo: FrameInfo) => void,\n autostart = true\n): FrameCallback {\n const ref = useRef<FrameCallback>({\n setActive: (isActive: boolean) => {\n frameCallbackRegistry.manageStateFrameCallback(\n ref.current.callbackId,\n isActive\n );\n ref.current.isActive = isActive;\n },\n isActive: autostart,\n callbackId: -1,\n });\n\n useEffect(() => {\n ref.current.callbackId =\n frameCallbackRegistry.registerFrameCallback(callback);\n ref.current.setActive(ref.current.isActive);\n\n return () => {\n frameCallbackRegistry.unregisterFrameCallback(ref.current.callbackId);\n ref.current.callbackId = -1;\n };\n }, [callback, autostart]);\n\n return ref.current;\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACzC,OAAOC,uBAAuB,MAAM,0CAA0C;;AAG9E;AACA;AACA;AACA;AACA;AACA;;AAMA,MAAMC,qBAAqB,GAAG,IAAID,uBAAuB,EAAE;;AAE3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,gBAAgBA,CAC9BC,QAAwC,EAEzB;EAAA,IADfC,SAAS,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;EAEhB,MAAMG,GAAG,GAAGT,MAAM,CAAgB;IAChCU,SAAS,EAAGC,QAAiB,IAAK;MAChCT,qBAAqB,CAACU,wBAAwB,CAC5CH,GAAG,CAACI,OAAO,CAACC,UAAU,EACtBH,QAAQ,CACT;MACDF,GAAG,CAACI,OAAO,CAACF,QAAQ,GAAGA,QAAQ;IACjC,CAAC;IACDA,QAAQ,EAAEN,SAAS;IACnBS,UAAU,EAAE,CAAC;EACf,CAAC,CAAC;EAEFf,SAAS,CAAC,MAAM;IACdU,GAAG,CAACI,OAAO,CAACC,UAAU,GACpBZ,qBAAqB,CAACa,qBAAqB,CAACX,QAAQ,CAAC;IACvDK,GAAG,CAACI,OAAO,CAACH,SAAS,CAACD,GAAG,CAACI,OAAO,CAACF,QAAQ,CAAC;IAE3C,OAAO,MAAM;MACXT,qBAAqB,CAACc,uBAAuB,CAACP,GAAG,CAACI,OAAO,CAACC,UAAU,CAAC;MACrEL,GAAG,CAACI,OAAO,CAACC,UAAU,GAAG,CAAC,CAAC;IAC7B,CAAC;EACH,CAAC,EAAE,CAACV,QAAQ,EAAEC,SAAS,CAAC,CAAC;EAEzB,OAAOI,GAAG,CAACI,OAAO;AACpB"}
@@ -5,8 +5,14 @@ import { makeRemote } from '../core';
5
5
  import { isWeb, isJest } from '../PlatformChecker';
6
6
  import { areDependenciesEqual, buildDependencies } from './utils';
7
7
 
8
- // @ts-expect-error This overload is required by our API.
9
-
8
+ /**
9
+ * Lets you find out whether the event handler dependencies have changed.
10
+ *
11
+ * @param handlers - An object of event handlers.
12
+ * @param dependencies - An optional array of dependencies.
13
+ * @returns An object containing a boolean indicating whether the dependencies have changed, and a boolean indicating whether the code is running on the web.
14
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/useHandler
15
+ */ // @ts-expect-error This overload is required by our API.
10
16
  export function useHandler(handlers, dependencies) {
11
17
  const initRef = useRef(null);
12
18
  if (initRef.current === null) {
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useRef","makeRemote","isWeb","isJest","areDependenciesEqual","buildDependencies","useHandler","handlers","dependencies","initRef","current","context","savedDependencies","doDependenciesDiffer","useWeb"],"sources":["useHandler.ts"],"sourcesContent":["'use strict';\nimport { useEffect, useRef } from 'react';\nimport type { WorkletFunction } from '../commonTypes';\nimport { makeRemote } from '../core';\nimport { isWeb, isJest } from '../PlatformChecker';\nimport type { DependencyList, ReanimatedEvent } from './commonTypes';\nimport { areDependenciesEqual, buildDependencies } from './utils';\n\ninterface GeneralHandler<\n Event extends object,\n Context extends Record<string, unknown>\n> {\n (event: ReanimatedEvent<Event>, context: Context): void;\n}\n\ntype GeneralWorkletHandler<\n Event extends object,\n Context extends Record<string, unknown>\n> = WorkletFunction<[event: ReanimatedEvent<Event>, context: Context]>;\n\ntype GeneralHandlers<\n Event extends object,\n Context extends Record<string, unknown>\n> = Record<string, GeneralHandler<Event, Context> | undefined>;\n\ntype GeneralWorkletHandlers<\n Event extends object,\n Context extends Record<string, unknown>\n> = Record<string, GeneralWorkletHandler<Event, Context> | undefined>;\n\ninterface ContextWithDependencies<Context extends Record<string, unknown>> {\n context: Context;\n savedDependencies: DependencyList;\n}\n\nexport interface UseHandlerContext<Context extends Record<string, unknown>> {\n context: Context;\n doDependenciesDiffer: boolean;\n useWeb: boolean;\n}\n\n// @ts-expect-error This overload is required by our API.\nexport function useHandler<\n Event extends object,\n Context extends Record<string, unknown>\n>(\n handlers: GeneralHandlers<Event, Context>,\n dependencies?: DependencyList\n): UseHandlerContext<Context>;\n\nexport function useHandler<\n Event extends object,\n Context extends Record<string, unknown>\n>(\n handlers: GeneralWorkletHandlers<Event, Context>,\n dependencies?: DependencyList\n): UseHandlerContext<Context> {\n const initRef = useRef<ContextWithDependencies<Context> | null>(null);\n if (initRef.current === null) {\n initRef.current = {\n context: makeRemote<Context>({} as Context),\n savedDependencies: [],\n };\n }\n\n useEffect(() => {\n return () => {\n initRef.current = null;\n };\n }, []);\n\n const { context, savedDependencies } = initRef.current;\n\n dependencies = buildDependencies(\n dependencies,\n handlers as Record<string, WorkletFunction | undefined>\n );\n\n const doDependenciesDiffer = !areDependenciesEqual(\n dependencies,\n savedDependencies\n );\n initRef.current.savedDependencies = dependencies;\n const useWeb = isWeb() || isJest();\n\n return { context, doDependenciesDiffer, useWeb };\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAEzC,SAASC,UAAU,QAAQ,SAAS;AACpC,SAASC,KAAK,EAAEC,MAAM,QAAQ,oBAAoB;AAElD,SAASC,oBAAoB,EAAEC,iBAAiB,QAAQ,SAAS;;AAmCjE;;AASA,OAAO,SAASC,UAAUA,CAIxBC,QAAgD,EAChDC,YAA6B,EACD;EAC5B,MAAMC,OAAO,GAAGT,MAAM,CAA0C,IAAI,CAAC;EACrE,IAAIS,OAAO,CAACC,OAAO,KAAK,IAAI,EAAE;IAC5BD,OAAO,CAACC,OAAO,GAAG;MAChBC,OAAO,EAAEV,UAAU,CAAU,CAAC,CAAC,CAAY;MAC3CW,iBAAiB,EAAE;IACrB,CAAC;EACH;EAEAb,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACXU,OAAO,CAACC,OAAO,GAAG,IAAI;IACxB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,MAAM;IAAEC,OAAO;IAAEC;EAAkB,CAAC,GAAGH,OAAO,CAACC,OAAO;EAEtDF,YAAY,GAAGH,iBAAiB,CAC9BG,YAAY,EACZD,QAAQ,CACT;EAED,MAAMM,oBAAoB,GAAG,CAACT,oBAAoB,CAChDI,YAAY,EACZI,iBAAiB,CAClB;EACDH,OAAO,CAACC,OAAO,CAACE,iBAAiB,GAAGJ,YAAY;EAChD,MAAMM,MAAM,GAAGZ,KAAK,EAAE,IAAIC,MAAM,EAAE;EAElC,OAAO;IAAEQ,OAAO;IAAEE,oBAAoB;IAAEC;EAAO,CAAC;AAClD"}
1
+ {"version":3,"names":["useEffect","useRef","makeRemote","isWeb","isJest","areDependenciesEqual","buildDependencies","useHandler","handlers","dependencies","initRef","current","context","savedDependencies","doDependenciesDiffer","useWeb"],"sources":["useHandler.ts"],"sourcesContent":["'use strict';\nimport { useEffect, useRef } from 'react';\nimport type { WorkletFunction } from '../commonTypes';\nimport { makeRemote } from '../core';\nimport { isWeb, isJest } from '../PlatformChecker';\nimport type { DependencyList, ReanimatedEvent } from './commonTypes';\nimport { areDependenciesEqual, buildDependencies } from './utils';\n\ninterface GeneralHandler<\n Event extends object,\n Context extends Record<string, unknown>\n> {\n (event: ReanimatedEvent<Event>, context: Context): void;\n}\n\ntype GeneralWorkletHandler<\n Event extends object,\n Context extends Record<string, unknown>\n> = WorkletFunction<[event: ReanimatedEvent<Event>, context: Context]>;\n\ntype GeneralHandlers<\n Event extends object,\n Context extends Record<string, unknown>\n> = Record<string, GeneralHandler<Event, Context> | undefined>;\n\ntype GeneralWorkletHandlers<\n Event extends object,\n Context extends Record<string, unknown>\n> = Record<string, GeneralWorkletHandler<Event, Context> | undefined>;\n\ninterface ContextWithDependencies<Context extends Record<string, unknown>> {\n context: Context;\n savedDependencies: DependencyList;\n}\n\nexport interface UseHandlerContext<Context extends Record<string, unknown>> {\n context: Context;\n doDependenciesDiffer: boolean;\n useWeb: boolean;\n}\n\n/**\n * Lets you find out whether the event handler dependencies have changed.\n *\n * @param handlers - An object of event handlers.\n * @param dependencies - An optional array of dependencies.\n * @returns An object containing a boolean indicating whether the dependencies have changed, and a boolean indicating whether the code is running on the web.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/useHandler\n */\n// @ts-expect-error This overload is required by our API.\nexport function useHandler<\n Event extends object,\n Context extends Record<string, unknown>\n>(\n handlers: GeneralHandlers<Event, Context>,\n dependencies?: DependencyList\n): UseHandlerContext<Context>;\n\nexport function useHandler<\n Event extends object,\n Context extends Record<string, unknown>\n>(\n handlers: GeneralWorkletHandlers<Event, Context>,\n dependencies?: DependencyList\n): UseHandlerContext<Context> {\n const initRef = useRef<ContextWithDependencies<Context> | null>(null);\n if (initRef.current === null) {\n initRef.current = {\n context: makeRemote<Context>({} as Context),\n savedDependencies: [],\n };\n }\n\n useEffect(() => {\n return () => {\n initRef.current = null;\n };\n }, []);\n\n const { context, savedDependencies } = initRef.current;\n\n dependencies = buildDependencies(\n dependencies,\n handlers as Record<string, WorkletFunction | undefined>\n );\n\n const doDependenciesDiffer = !areDependenciesEqual(\n dependencies,\n savedDependencies\n );\n initRef.current.savedDependencies = dependencies;\n const useWeb = isWeb() || isJest();\n\n return { context, doDependenciesDiffer, useWeb };\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAEzC,SAASC,UAAU,QAAQ,SAAS;AACpC,SAASC,KAAK,EAAEC,MAAM,QAAQ,oBAAoB;AAElD,SAASC,oBAAoB,EAAEC,iBAAiB,QAAQ,SAAS;;AAmCjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAPA,CAQA;AASA,OAAO,SAASC,UAAUA,CAIxBC,QAAgD,EAChDC,YAA6B,EACD;EAC5B,MAAMC,OAAO,GAAGT,MAAM,CAA0C,IAAI,CAAC;EACrE,IAAIS,OAAO,CAACC,OAAO,KAAK,IAAI,EAAE;IAC5BD,OAAO,CAACC,OAAO,GAAG;MAChBC,OAAO,EAAEV,UAAU,CAAU,CAAC,CAAC,CAAY;MAC3CW,iBAAiB,EAAE;IACrB,CAAC;EACH;EAEAb,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACXU,OAAO,CAACC,OAAO,GAAG,IAAI;IACxB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,MAAM;IAAEC,OAAO;IAAEC;EAAkB,CAAC,GAAGH,OAAO,CAACC,OAAO;EAEtDF,YAAY,GAAGH,iBAAiB,CAC9BG,YAAY,EACZD,QAAQ,CACT;EAED,MAAMM,oBAAoB,GAAG,CAACT,oBAAoB,CAChDI,YAAY,EACZI,iBAAiB,CAClB;EACDH,OAAO,CAACC,OAAO,CAACE,iBAAiB,GAAGJ,YAAY;EAChD,MAAMM,MAAM,GAAGZ,KAAK,EAAE,IAAIC,MAAM,EAAE;EAElC,OAAO;IAAEQ,OAAO;IAAEE,oBAAoB;IAAEC;EAAO,CAAC;AAClD"}
@@ -2,6 +2,15 @@
2
2
 
3
3
  import { isReducedMotion } from '../PlatformChecker';
4
4
  const IS_REDUCED_MOTION = isReducedMotion();
5
+
6
+ /**
7
+ * Lets you query the reduced motion system setting.
8
+ *
9
+ * Changing the reduced motion system setting doesn't cause your components to rerender.
10
+ *
11
+ * @returns A boolean indicating whether the reduced motion setting was enabled when the app started.
12
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/device/useReducedMotion
13
+ */
5
14
  export function useReducedMotion() {
6
15
  return IS_REDUCED_MOTION;
7
16
  }
@@ -1 +1 @@
1
- {"version":3,"names":["isReducedMotion","IS_REDUCED_MOTION","useReducedMotion"],"sources":["useReducedMotion.ts"],"sourcesContent":["'use strict';\nimport { isReducedMotion } from '../PlatformChecker';\n\nconst IS_REDUCED_MOTION = isReducedMotion();\n\nexport function useReducedMotion() {\n return IS_REDUCED_MOTION;\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,QAAQ,oBAAoB;AAEpD,MAAMC,iBAAiB,GAAGD,eAAe,EAAE;AAE3C,OAAO,SAASE,gBAAgBA,CAAA,EAAG;EACjC,OAAOD,iBAAiB;AAC1B"}
1
+ {"version":3,"names":["isReducedMotion","IS_REDUCED_MOTION","useReducedMotion"],"sources":["useReducedMotion.ts"],"sourcesContent":["'use strict';\nimport { isReducedMotion } from '../PlatformChecker';\n\nconst IS_REDUCED_MOTION = isReducedMotion();\n\n/**\n * Lets you query the reduced motion system setting.\n *\n * Changing the reduced motion system setting doesn't cause your components to rerender.\n *\n * @returns A boolean indicating whether the reduced motion setting was enabled when the app started.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/device/useReducedMotion\n */\nexport function useReducedMotion() {\n return IS_REDUCED_MOTION;\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,QAAQ,oBAAoB;AAEpD,MAAMC,iBAAiB,GAAGD,eAAe,EAAE;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,gBAAgBA,CAAA,EAAG;EACjC,OAAOD,iBAAiB;AAC1B"}
@@ -5,6 +5,14 @@ import { findNodeHandle } from 'react-native';
5
5
  import { useEvent } from './useEvent';
6
6
  import { useSharedValue } from './useSharedValue';
7
7
  const scrollEventNames = ['onScroll', 'onScrollBeginDrag', 'onScrollEndDrag', 'onMomentumScrollBegin', 'onMomentumScrollEnd'];
8
+
9
+ /**
10
+ * Lets you synchronously get the current offset of a `ScrollView`.
11
+ *
12
+ * @param animatedRef - An [animated ref](https://docs.swmansion.com/react-native-reanimated/docs/core/useAnimatedRef) attached to an Animated.ScrollView component.
13
+ * @returns A shared value which holds the current offset of the `ScrollView`.
14
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/scroll/useScrollViewOffset
15
+ */
8
16
  export function useScrollViewOffset(animatedRef, initialRef) {
9
17
  const offsetRef = useRef(
10
18
  // eslint-disable-next-line react-hooks/rules-of-hooks
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useRef","findNodeHandle","useEvent","useSharedValue","scrollEventNames","useScrollViewOffset","animatedRef","initialRef","offsetRef","undefined","event","current","value","contentOffset","x","y","_event$current","viewTag","registerForEvents","_event$current2","unregisterFromEvents"],"sources":["useScrollViewOffset.ts"],"sourcesContent":["'use strict';\nimport { useEffect, useRef } from 'react';\nimport type { SharedValue } from '../commonTypes';\nimport { findNodeHandle } from 'react-native';\nimport type { EventHandlerInternal } from './useEvent';\nimport { useEvent } from './useEvent';\nimport { useSharedValue } from './useSharedValue';\nimport type { AnimatedScrollView } from '../component/ScrollView';\nimport type {\n AnimatedRef,\n RNNativeScrollEvent,\n ReanimatedScrollEvent,\n} from './commonTypes';\n\nconst scrollEventNames = [\n 'onScroll',\n 'onScrollBeginDrag',\n 'onScrollEndDrag',\n 'onMomentumScrollBegin',\n 'onMomentumScrollEnd',\n];\n\nexport function useScrollViewOffset(\n animatedRef: AnimatedRef<AnimatedScrollView>,\n initialRef?: SharedValue<number>\n): SharedValue<number> {\n const offsetRef = useRef(\n // eslint-disable-next-line react-hooks/rules-of-hooks\n initialRef !== undefined ? initialRef : useSharedValue(0)\n );\n\n const event = useEvent<RNNativeScrollEvent>(\n (event: ReanimatedScrollEvent) => {\n 'worklet';\n offsetRef.current.value =\n event.contentOffset.x === 0\n ? event.contentOffset.y\n : event.contentOffset.x;\n },\n scrollEventNames\n // Read https://github.com/software-mansion/react-native-reanimated/pull/5056\n // for more information about this cast.\n ) as unknown as EventHandlerInternal<ReanimatedScrollEvent>;\n\n useEffect(() => {\n const viewTag = findNodeHandle(animatedRef.current);\n event.current?.registerForEvents(viewTag as number);\n\n return () => {\n event.current?.unregisterFromEvents();\n };\n }, [animatedRef.current]);\n\n return offsetRef.current;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scrollEventNames","useScrollViewOffset","animatedRef","initialRef","offsetRef","undefined","event","current","value","contentOffset","x","y","_event$current","viewTag","registerForEvents","_event$current2","unregisterFromEvents"],"sources":["useScrollViewOffset.ts"],"sourcesContent":["'use strict';\nimport { useEffect, useRef } from 'react';\nimport type { SharedValue } from '../commonTypes';\nimport { findNodeHandle } from 'react-native';\nimport type { EventHandlerInternal } from './useEvent';\nimport { useEvent } from './useEvent';\nimport { useSharedValue } from './useSharedValue';\nimport type { AnimatedScrollView } from '../component/ScrollView';\nimport type {\n AnimatedRef,\n RNNativeScrollEvent,\n ReanimatedScrollEvent,\n} from './commonTypes';\n\nconst scrollEventNames = [\n 'onScroll',\n 'onScrollBeginDrag',\n 'onScrollEndDrag',\n 'onMomentumScrollBegin',\n 'onMomentumScrollEnd',\n];\n\n/**\n * Lets you synchronously get the current offset of a `ScrollView`.\n *\n * @param animatedRef - An [animated ref](https://docs.swmansion.com/react-native-reanimated/docs/core/useAnimatedRef) attached to an Animated.ScrollView component.\n * @returns A shared value which holds the current offset of the `ScrollView`.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/scroll/useScrollViewOffset\n */\nexport function useScrollViewOffset(\n animatedRef: AnimatedRef<AnimatedScrollView>,\n initialRef?: SharedValue<number>\n): SharedValue<number> {\n const offsetRef = useRef(\n // eslint-disable-next-line react-hooks/rules-of-hooks\n initialRef !== undefined ? initialRef : useSharedValue(0)\n );\n\n const event = useEvent<RNNativeScrollEvent>(\n (event: ReanimatedScrollEvent) => {\n 'worklet';\n offsetRef.current.value =\n event.contentOffset.x === 0\n ? event.contentOffset.y\n : event.contentOffset.x;\n },\n scrollEventNames\n // Read https://github.com/software-mansion/react-native-reanimated/pull/5056\n // for more information about this cast.\n ) as unknown as EventHandlerInternal<ReanimatedScrollEvent>;\n\n useEffect(() => {\n const viewTag = findNodeHandle(animatedRef.current);\n event.current?.registerForEvents(viewTag as number);\n\n return () => {\n event.current?.unregisterFromEvents();\n };\n }, [animatedRef.current]);\n\n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,11 +3,19 @@
3
3
  import { useEffect, useRef } from 'react';
4
4
  import { cancelAnimation } from '../animation';
5
5
  import { makeMutable } from '../core';
6
- export function useSharedValue(init) {
6
+
7
+ /**
8
+ * Lets you define [shared values](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#shared-value) in your components.
9
+ *
10
+ * @param initialValue - The value you want to be initially stored to a `.value` property.
11
+ * @returns A shared value with a single `.value` property initially set to the `initialValue` - {@link SharedValue}.
12
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/core/useSharedValue
13
+ */
14
+ export function useSharedValue(initialValue) {
7
15
  let oneWayReadsOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
8
- const ref = useRef(makeMutable(init, oneWayReadsOnly));
16
+ const ref = useRef(makeMutable(initialValue, oneWayReadsOnly));
9
17
  if (ref.current === null) {
10
- ref.current = makeMutable(init, oneWayReadsOnly);
18
+ ref.current = makeMutable(initialValue, oneWayReadsOnly);
11
19
  }
12
20
  useEffect(() => {
13
21
  return () => {
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useRef","cancelAnimation","makeMutable","useSharedValue","init","oneWayReadsOnly","arguments","length","undefined","ref","current"],"sources":["useSharedValue.ts"],"sourcesContent":["'use strict';\nimport { useEffect, useRef } from 'react';\nimport { cancelAnimation } from '../animation';\nimport type { SharedValue } from '../commonTypes';\nimport { makeMutable } from '../core';\n\nexport function useSharedValue<Value>(\n init: Value,\n oneWayReadsOnly = false\n): SharedValue<Value> {\n const ref = useRef<SharedValue<Value>>(makeMutable(init, oneWayReadsOnly));\n\n if (ref.current === null) {\n ref.current = makeMutable(init, oneWayReadsOnly);\n }\n\n useEffect(() => {\n return () => {\n cancelAnimation(ref.current);\n };\n }, []);\n\n return ref.current;\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACzC,SAASC,eAAe,QAAQ,cAAc;AAE9C,SAASC,WAAW,QAAQ,SAAS;AAErC,OAAO,SAASC,cAAcA,CAC5BC,IAAW,EAES;EAAA,IADpBC,eAAe,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAEvB,MAAMG,GAAG,GAAGT,MAAM,CAAqBE,WAAW,CAACE,IAAI,EAAEC,eAAe,CAAC,CAAC;EAE1E,IAAII,GAAG,CAACC,OAAO,KAAK,IAAI,EAAE;IACxBD,GAAG,CAACC,OAAO,GAAGR,WAAW,CAACE,IAAI,EAAEC,eAAe,CAAC;EAClD;EAEAN,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACXE,eAAe,CAACQ,GAAG,CAACC,OAAO,CAAC;IAC9B,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOD,GAAG,CAACC,OAAO;AACpB"}
1
+ {"version":3,"names":["useEffect","useRef","cancelAnimation","makeMutable","useSharedValue","initialValue","oneWayReadsOnly","arguments","length","undefined","ref","current"],"sources":["useSharedValue.ts"],"sourcesContent":["'use strict';\nimport { useEffect, useRef } from 'react';\nimport { cancelAnimation } from '../animation';\nimport type { SharedValue } from '../commonTypes';\nimport { makeMutable } from '../core';\n\n/**\n * Lets you define [shared values](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#shared-value) in your components.\n *\n * @param initialValue - The value you want to be initially stored to a `.value` property.\n * @returns A shared value with a single `.value` property initially set to the `initialValue` - {@link SharedValue}.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/core/useSharedValue\n */\nexport function useSharedValue<Value>(\n initialValue: Value,\n oneWayReadsOnly = false\n): SharedValue<Value> {\n const ref = useRef<SharedValue<Value>>(\n makeMutable(initialValue, oneWayReadsOnly)\n );\n\n if (ref.current === null) {\n ref.current = makeMutable(initialValue, oneWayReadsOnly);\n }\n\n useEffect(() => {\n return () => {\n cancelAnimation(ref.current);\n };\n }, []);\n\n return ref.current;\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACzC,SAASC,eAAe,QAAQ,cAAc;AAE9C,SAASC,WAAW,QAAQ,SAAS;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAC5BC,YAAmB,EAEC;EAAA,IADpBC,eAAe,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAEvB,MAAMG,GAAG,GAAGT,MAAM,CAChBE,WAAW,CAACE,YAAY,EAAEC,eAAe,CAAC,CAC3C;EAED,IAAII,GAAG,CAACC,OAAO,KAAK,IAAI,EAAE;IACxBD,GAAG,CAACC,OAAO,GAAGR,WAAW,CAACE,YAAY,EAAEC,eAAe,CAAC;EAC1D;EAEAN,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACXE,eAAe,CAACQ,GAAG,CAACC,OAAO,CAAC;IAC9B,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOD,GAAG,CAACC,OAAO;AACpB"}
@@ -1,6 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  import { useCallback } from 'react';
4
+ /**
5
+ * @deprecated don't use
6
+ */
4
7
  export function useWorkletCallback(worklet, deps) {
5
8
  return useCallback(worklet, deps ?? []);
6
9
  }
@@ -1 +1 @@
1
- {"version":3,"names":["useCallback","useWorkletCallback","worklet","deps"],"sources":["useWorkletCallback.ts"],"sourcesContent":["'use strict';\nimport { useCallback } from 'react';\nimport type { DependencyList } from './commonTypes';\n\nexport function useWorkletCallback<Args extends unknown[], ReturnValue>(\n worklet: (...args: Args) => ReturnValue,\n deps?: DependencyList\n) {\n return useCallback(worklet, deps ?? []);\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,WAAW,QAAQ,OAAO;AAGnC,OAAO,SAASC,kBAAkBA,CAChCC,OAAuC,EACvCC,IAAqB,EACrB;EACA,OAAOH,WAAW,CAACE,OAAO,EAAEC,IAAI,IAAI,EAAE,CAAC;AACzC"}
1
+ {"version":3,"names":["useCallback","useWorkletCallback","worklet","deps"],"sources":["useWorkletCallback.ts"],"sourcesContent":["'use strict';\nimport { useCallback } from 'react';\nimport type { DependencyList } from './commonTypes';\n\n/**\n * @deprecated don't use\n */\nexport function useWorkletCallback<Args extends unknown[], ReturnValue>(\n worklet: (...args: Args) => ReturnValue,\n deps?: DependencyList\n) {\n return useCallback(worklet, deps ?? []);\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,WAAW,QAAQ,OAAO;AAGnC;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAChCC,OAAuC,EACvCC,IAAqB,EACrB;EACA,OAAOH,WAAW,CAACE,OAAO,EAAEC,IAAI,IAAI,EAAE,CAAC;AACzC"}
@@ -7,7 +7,7 @@ export { cancelAnimation, defineAnimation, withClamp, withDecay, withDelay, with
7
7
  export { Extrapolation, interpolate, clamp } from './interpolation';
8
8
  export {
9
9
  /**
10
- * @deprecated Please use `Extrapolation` instead.
10
+ * @deprecated Please use {@link Extrapolation} instead.
11
11
  */
12
12
  Extrapolate, ColorSpace, interpolateColor, useInterpolateConfig } from './interpolateColor';
13
13
  export { Easing } from './Easing';
@@ -1 +1 @@
1
- {"version":3,"names":["runOnJS","runOnUI","createWorkletRuntime","runOnRuntime","makeMutable","makeShareableCloneRecursive","isReanimated3","isConfigured","enableLayoutAnimations","getViewProp","useAnimatedProps","useEvent","useHandler","useWorkletCallback","useSharedValue","useReducedMotion","useAnimatedStyle","useAnimatedGestureHandler","useAnimatedReaction","useAnimatedRef","useAnimatedScrollHandler","useDerivedValue","useAnimatedSensor","useFrameCallback","useAnimatedKeyboard","useScrollViewOffset","cancelAnimation","defineAnimation","withClamp","withDecay","withDelay","withRepeat","withSequence","withSpring","withTiming","Extrapolation","interpolate","clamp","Extrapolate","ColorSpace","interpolateColor","useInterpolateConfig","Easing","measure","dispatchCommand","scrollTo","setGestureState","setNativeProps","getRelativeCoords","isColor","processColor","convertToRGBA","createAnimatedPropAdapter","BaseAnimationBuilder","ComplexAnimationBuilder","Keyframe","FlipInXUp","FlipInYLeft","FlipInXDown","FlipInYRight","FlipInEasyX","FlipInEasyY","FlipOutXUp","FlipOutYLeft","FlipOutXDown","FlipOutYRight","FlipOutEasyX","FlipOutEasyY","StretchInX","StretchInY","StretchOutX","StretchOutY","FadeIn","FadeInRight","FadeInLeft","FadeInUp","FadeInDown","FadeOut","FadeOutRight","FadeOutLeft","FadeOutUp","FadeOutDown","SlideInRight","SlideInLeft","SlideOutRight","SlideOutLeft","SlideInUp","SlideInDown","SlideOutUp","SlideOutDown","ZoomIn","ZoomInRotate","ZoomInLeft","ZoomInRight","ZoomInUp","ZoomInDown","ZoomInEasyUp","ZoomInEasyDown","ZoomOut","ZoomOutRotate","ZoomOutLeft","ZoomOutRight","ZoomOutUp","ZoomOutDown","ZoomOutEasyUp","ZoomOutEasyDown","BounceIn","BounceInDown","BounceInUp","BounceInLeft","BounceInRight","BounceOut","BounceOutDown","BounceOutUp","BounceOutLeft","BounceOutRight","LightSpeedInRight","LightSpeedInLeft","LightSpeedOutRight","LightSpeedOutLeft","PinwheelIn","PinwheelOut","RotateInDownLeft","RotateInDownRight","RotateInUpLeft","RotateInUpRight","RotateOutDownLeft","RotateOutDownRight","RotateOutUpLeft","RotateOutUpRight","RollInLeft","RollInRight","RollOutLeft","RollOutRight","Layout","LinearTransition","FadingTransition","SequencedTransition","JumpingTransition","CurvedTransition","EntryExitTransition","combineTransition","SharedTransition","SharedTransitionType","isSharedValue","SensorType","IOSReferenceFrame","InterfaceOrientation","KeyboardState","ReduceMotion","getUseOfValueInStyleWarning","withReanimatedTimer","advanceAnimationByTime","advanceAnimationByFrame","setUpTests","getAnimatedStyle","LayoutAnimationConfig","startMapper","stopMapper"],"sources":["index.ts"],"sourcesContent":["'use strict';\n\nimport './publicGlobals';\n\nexport type { WorkletRuntime } from './core';\nexport {\n runOnJS,\n runOnUI,\n createWorkletRuntime,\n runOnRuntime,\n makeMutable,\n makeShareableCloneRecursive,\n isReanimated3,\n isConfigured,\n enableLayoutAnimations,\n getViewProp,\n} from './core';\nexport type {\n GestureHandlers,\n AnimatedRef,\n DerivedValue,\n ScrollHandler,\n ScrollHandlers,\n ScrollHandlerProcessed,\n FrameCallback,\n ScrollEvent,\n EventHandler,\n EventHandlerProcessed,\n UseHandlerContext,\n ReanimatedEvent,\n} from './hook';\nexport {\n useAnimatedProps,\n useEvent,\n useHandler,\n useWorkletCallback,\n useSharedValue,\n useReducedMotion,\n useAnimatedStyle,\n useAnimatedGestureHandler,\n useAnimatedReaction,\n useAnimatedRef,\n useAnimatedScrollHandler,\n useDerivedValue,\n useAnimatedSensor,\n useFrameCallback,\n useAnimatedKeyboard,\n useScrollViewOffset,\n} from './hook';\nexport type {\n DelayAnimation,\n RepeatAnimation,\n SequenceAnimation,\n StyleLayoutAnimation,\n WithTimingConfig,\n TimingAnimation,\n WithSpringConfig,\n SpringAnimation,\n WithDecayConfig,\n DecayAnimation,\n} from './animation';\nexport {\n cancelAnimation,\n defineAnimation,\n withClamp,\n withDecay,\n withDelay,\n withRepeat,\n withSequence,\n withSpring,\n withTiming,\n} from './animation';\nexport type { ExtrapolationConfig, ExtrapolationType } from './interpolation';\nexport { Extrapolation, interpolate, clamp } from './interpolation';\nexport type {\n InterpolationOptions,\n InterpolateConfig,\n InterpolateRGB,\n InterpolateHSV,\n} from './interpolateColor';\nexport {\n /**\n * @deprecated Please use `Extrapolation` instead.\n */\n Extrapolate,\n ColorSpace,\n interpolateColor,\n useInterpolateConfig,\n} from './interpolateColor';\nexport type {\n EasingFunction,\n EasingFn,\n EasingFunctionFactory,\n EasingFactoryFn,\n} from './Easing';\nexport { Easing } from './Easing';\nexport type { ComponentCoords } from './platformFunctions';\nexport {\n measure,\n dispatchCommand,\n scrollTo,\n setGestureState,\n setNativeProps,\n getRelativeCoords,\n} from './platformFunctions';\nexport type { ParsedColorArray } from './Colors';\nexport { isColor, processColor, convertToRGBA } from './Colors';\nexport { createAnimatedPropAdapter } from './PropAdapters';\nexport type {\n LayoutAnimation,\n EntryAnimationsValues,\n ExitAnimationsValues,\n EntryExitAnimationFunction,\n LayoutAnimationsValues,\n LayoutAnimationFunction,\n ILayoutAnimationBuilder,\n IEntryExitAnimationBuilder,\n} from './layoutReanimation';\nexport {\n BaseAnimationBuilder,\n ComplexAnimationBuilder,\n Keyframe,\n // Flip\n FlipInXUp,\n FlipInYLeft,\n FlipInXDown,\n FlipInYRight,\n FlipInEasyX,\n FlipInEasyY,\n FlipOutXUp,\n FlipOutYLeft,\n FlipOutXDown,\n FlipOutYRight,\n FlipOutEasyX,\n FlipOutEasyY,\n // Stretch\n StretchInX,\n StretchInY,\n StretchOutX,\n StretchOutY,\n // Fade\n FadeIn,\n FadeInRight,\n FadeInLeft,\n FadeInUp,\n FadeInDown,\n FadeOut,\n FadeOutRight,\n FadeOutLeft,\n FadeOutUp,\n FadeOutDown,\n // Slide\n SlideInRight,\n SlideInLeft,\n SlideOutRight,\n SlideOutLeft,\n SlideInUp,\n SlideInDown,\n SlideOutUp,\n SlideOutDown,\n // Zoom\n ZoomIn,\n ZoomInRotate,\n ZoomInLeft,\n ZoomInRight,\n ZoomInUp,\n ZoomInDown,\n ZoomInEasyUp,\n ZoomInEasyDown,\n ZoomOut,\n ZoomOutRotate,\n ZoomOutLeft,\n ZoomOutRight,\n ZoomOutUp,\n ZoomOutDown,\n ZoomOutEasyUp,\n ZoomOutEasyDown,\n // Bounce\n BounceIn,\n BounceInDown,\n BounceInUp,\n BounceInLeft,\n BounceInRight,\n BounceOut,\n BounceOutDown,\n BounceOutUp,\n BounceOutLeft,\n BounceOutRight,\n // Lightspeed\n LightSpeedInRight,\n LightSpeedInLeft,\n LightSpeedOutRight,\n LightSpeedOutLeft,\n // Pinwheel\n PinwheelIn,\n PinwheelOut,\n // Rotate\n RotateInDownLeft,\n RotateInDownRight,\n RotateInUpLeft,\n RotateInUpRight,\n RotateOutDownLeft,\n RotateOutDownRight,\n RotateOutUpLeft,\n RotateOutUpRight,\n // Roll\n RollInLeft,\n RollInRight,\n RollOutLeft,\n RollOutRight,\n // Transitions\n Layout,\n LinearTransition,\n FadingTransition,\n SequencedTransition,\n JumpingTransition,\n CurvedTransition,\n EntryExitTransition,\n combineTransition,\n // SET\n SharedTransition,\n SharedTransitionType,\n} from './layoutReanimation';\nexport { isSharedValue } from './isSharedValue';\nexport type {\n StyleProps,\n SharedValue,\n AnimatableValueObject,\n AnimatableValue,\n AnimationObject,\n SensorConfig,\n Animation,\n AnimatedSensor,\n AnimationCallback,\n Value3D,\n ValueRotation,\n AnimatedKeyboardInfo,\n AnimatedKeyboardOptions,\n MeasuredDimensions,\n} from './commonTypes';\nexport {\n SensorType,\n IOSReferenceFrame,\n InterfaceOrientation,\n KeyboardState,\n ReduceMotion,\n} from './commonTypes';\nexport type { FrameInfo } from './frameCallback';\nexport { getUseOfValueInStyleWarning } from './pluginUtils';\nexport {\n withReanimatedTimer,\n advanceAnimationByTime,\n advanceAnimationByFrame,\n setUpTests,\n getAnimatedStyle,\n} from './jestUtils';\nexport { LayoutAnimationConfig } from './component/LayoutAnimationConfig';\nexport type {\n Adaptable,\n AdaptTransforms,\n AnimateProps,\n AnimatedProps,\n AnimatedTransform,\n TransformStyleTypes,\n TransformArrayItem,\n AnimateStyle,\n AnimatedStyle,\n AnimatedStyleProp,\n StylesOrDefault,\n} from './helperTypes';\nexport type { AnimatedScrollViewProps } from './component/ScrollView';\nexport type { FlatListPropsWithLayout } from './component/FlatList';\nexport { startMapper, stopMapper } from './mappers';\n"],"mappings":"AAAA,YAAY;;AAEZ,OAAO,iBAAiB;AAGxB,SACEA,OAAO,EACPC,OAAO,EACPC,oBAAoB,EACpBC,YAAY,EACZC,WAAW,EACXC,2BAA2B,EAC3BC,aAAa,EACbC,YAAY,EACZC,sBAAsB,EACtBC,WAAW,QACN,QAAQ;AAef,SACEC,gBAAgB,EAChBC,QAAQ,EACRC,UAAU,EACVC,kBAAkB,EAClBC,cAAc,EACdC,gBAAgB,EACh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,EACZC,cAAc,EACdC,OAAO,EACPC,aAAa,EACbC,WAAW,EACXC,YAAY,EACZC,SAAS,EACTC,WAAW,EACXC,aAAa,EACbC,eAAe;AACf;AACAC,QAAQ,EACRC,YAAY,EACZC,UAAU,EACVC,YAAY,EACZC,aAAa,EACbC,SAAS,EACTC,aAAa,EACbC,WAAW,EACXC,aAAa,EACbC,cAAc;AACd;AACAC,iBAAiB,EACjBC,gBAAgB,EAChBC,kBAAkB,EAClBC,iBAAiB;AACjB;AACAC,UAAU,EACVC,WAAW;AACX;AACAC,gBAAgB,EAChBC,iBAAiB,EACjBC,cAAc,EACdC,eAAe,EACfC,iBAAiB,EACjBC,kBAAkB,EAClBC,eAAe,EACfC,gBAAgB;AAChB;AACAC,UAAU,EACVC,WAAW,EACXC,WAAW,EACXC,YAAY;AACZ;AACAC,MAAM,EACNC,gBAAgB,EAChBC,gBAAgB,EAChBC,mBAAmB,EACnBC,iBAAiB,EACjBC,gBAAgB,EAChBC,mBAAmB,EACnBC,iBAAiB;AACjB;AACAC,gBAAgB,EAChBC,oBAAoB,QACf,qBAAqB;AAC5B,SAASC,aAAa,QAAQ,iBAAiB;AAiB/C,SACEC,UAAU,EACVC,iBAAiB,EACjBC,oBAAoB,EACpBC,aAAa,EACbC,YAAY,QACP,eAAe;AAEtB,SAASC,2BAA2B,QAAQ,eAAe;AAC3D,SACEC,mBAAmB,EACnBC,sBAAsB,EACtBC,uBAAuB,EACvBC,UAAU,EACVC,gBAAgB,QACX,aAAa;AACpB,SAASC,qBAAqB,QAAQ,mCAAmC;AAgBzE,SAASC,WAAW,EAAEC,UAAU,QAAQ,WAAW"}
1
+ {"version":3,"names":["runOnJS","runOnUI","createWorkletRuntime","runOnRuntime","makeMutable","makeShareableCloneRecursive","isReanimated3","isConfigured","enableLayoutAnimations","getViewProp","useAnimatedProps","useEvent","useHandler","useWorkletCallback","useSharedValue","useReducedMotion","useAnimatedStyle","useAnimatedGestureHandler","useAnimatedReaction","useAnimatedRef","useAnimatedScrollHandler","useDerivedValue","useAnimatedSensor","useFrameCallback","useAnimatedKeyboard","useScrollViewOffset","cancelAnimation","defineAnimation","withClamp","withDecay","withDelay","withRepeat","withSequence","withSpring","withTiming","Extrapolation","interpolate","clamp","Extrapolate","ColorSpace","interpolateColor","useInterpolateConfig","Easing","measure","dispatchCommand","scrollTo","setGestureState","setNativeProps","getRelativeCoords","isColor","processColor","convertToRGBA","createAnimatedPropAdapter","BaseAnimationBuilder","ComplexAnimationBuilder","Keyframe","FlipInXUp","FlipInYLeft","FlipInXDown","FlipInYRight","FlipInEasyX","FlipInEasyY","FlipOutXUp","FlipOutYLeft","FlipOutXDown","FlipOutYRight","FlipOutEasyX","FlipOutEasyY","StretchInX","StretchInY","StretchOutX","StretchOutY","FadeIn","FadeInRight","FadeInLeft","FadeInUp","FadeInDown","FadeOut","FadeOutRight","FadeOutLeft","FadeOutUp","FadeOutDown","SlideInRight","SlideInLeft","SlideOutRight","SlideOutLeft","SlideInUp","SlideInDown","SlideOutUp","SlideOutDown","ZoomIn","ZoomInRotate","ZoomInLeft","ZoomInRight","ZoomInUp","ZoomInDown","ZoomInEasyUp","ZoomInEasyDown","ZoomOut","ZoomOutRotate","ZoomOutLeft","ZoomOutRight","ZoomOutUp","ZoomOutDown","ZoomOutEasyUp","ZoomOutEasyDown","BounceIn","BounceInDown","BounceInUp","BounceInLeft","BounceInRight","BounceOut","BounceOutDown","BounceOutUp","BounceOutLeft","BounceOutRight","LightSpeedInRight","LightSpeedInLeft","LightSpeedOutRight","LightSpeedOutLeft","PinwheelIn","PinwheelOut","RotateInDownLeft","RotateInDownRight","RotateInUpLeft","RotateInUpRight","RotateOutDownLeft","RotateOutDownRight","RotateOutUpLeft","RotateOutUpRight","RollInLeft","RollInRight","RollOutLeft","RollOutRight","Layout","LinearTransition","FadingTransition","SequencedTransition","JumpingTransition","CurvedTransition","EntryExitTransition","combineTransition","SharedTransition","SharedTransitionType","isSharedValue","SensorType","IOSReferenceFrame","InterfaceOrientation","KeyboardState","ReduceMotion","getUseOfValueInStyleWarning","withReanimatedTimer","advanceAnimationByTime","advanceAnimationByFrame","setUpTests","getAnimatedStyle","LayoutAnimationConfig","startMapper","stopMapper"],"sources":["index.ts"],"sourcesContent":["'use strict';\n\nimport './publicGlobals';\n\nexport type { WorkletRuntime } from './core';\nexport {\n runOnJS,\n runOnUI,\n createWorkletRuntime,\n runOnRuntime,\n makeMutable,\n makeShareableCloneRecursive,\n isReanimated3,\n isConfigured,\n enableLayoutAnimations,\n getViewProp,\n} from './core';\nexport type {\n GestureHandlers,\n AnimatedRef,\n DerivedValue,\n ScrollHandler,\n ScrollHandlers,\n ScrollHandlerProcessed,\n FrameCallback,\n ScrollEvent,\n EventHandler,\n EventHandlerProcessed,\n UseHandlerContext,\n ReanimatedEvent,\n} from './hook';\nexport {\n useAnimatedProps,\n useEvent,\n useHandler,\n useWorkletCallback,\n useSharedValue,\n useReducedMotion,\n useAnimatedStyle,\n useAnimatedGestureHandler,\n useAnimatedReaction,\n useAnimatedRef,\n useAnimatedScrollHandler,\n useDerivedValue,\n useAnimatedSensor,\n useFrameCallback,\n useAnimatedKeyboard,\n useScrollViewOffset,\n} from './hook';\nexport type {\n DelayAnimation,\n RepeatAnimation,\n SequenceAnimation,\n StyleLayoutAnimation,\n WithTimingConfig,\n TimingAnimation,\n WithSpringConfig,\n SpringAnimation,\n WithDecayConfig,\n DecayAnimation,\n} from './animation';\nexport {\n cancelAnimation,\n defineAnimation,\n withClamp,\n withDecay,\n withDelay,\n withRepeat,\n withSequence,\n withSpring,\n withTiming,\n} from './animation';\nexport type { ExtrapolationConfig, ExtrapolationType } from './interpolation';\nexport { Extrapolation, interpolate, clamp } from './interpolation';\nexport type {\n InterpolationOptions,\n InterpolateConfig,\n InterpolateRGB,\n InterpolateHSV,\n} from './interpolateColor';\nexport {\n /**\n * @deprecated Please use {@link Extrapolation} instead.\n */\n Extrapolate,\n ColorSpace,\n interpolateColor,\n useInterpolateConfig,\n} from './interpolateColor';\nexport type {\n EasingFunction,\n EasingFn,\n EasingFunctionFactory,\n EasingFactoryFn,\n} from './Easing';\nexport { Easing } from './Easing';\nexport type { ComponentCoords } from './platformFunctions';\nexport {\n measure,\n dispatchCommand,\n scrollTo,\n setGestureState,\n setNativeProps,\n getRelativeCoords,\n} from './platformFunctions';\nexport type { ParsedColorArray } from './Colors';\nexport { isColor, processColor, convertToRGBA } from './Colors';\nexport { createAnimatedPropAdapter } from './PropAdapters';\nexport type {\n LayoutAnimation,\n EntryAnimationsValues,\n ExitAnimationsValues,\n EntryExitAnimationFunction,\n LayoutAnimationsValues,\n LayoutAnimationFunction,\n ILayoutAnimationBuilder,\n IEntryExitAnimationBuilder,\n} from './layoutReanimation';\nexport {\n BaseAnimationBuilder,\n ComplexAnimationBuilder,\n Keyframe,\n // Flip\n FlipInXUp,\n FlipInYLeft,\n FlipInXDown,\n FlipInYRight,\n FlipInEasyX,\n FlipInEasyY,\n FlipOutXUp,\n FlipOutYLeft,\n FlipOutXDown,\n FlipOutYRight,\n FlipOutEasyX,\n FlipOutEasyY,\n // Stretch\n StretchInX,\n StretchInY,\n StretchOutX,\n StretchOutY,\n // Fade\n FadeIn,\n FadeInRight,\n FadeInLeft,\n FadeInUp,\n FadeInDown,\n FadeOut,\n FadeOutRight,\n FadeOutLeft,\n FadeOutUp,\n FadeOutDown,\n // Slide\n SlideInRight,\n SlideInLeft,\n SlideOutRight,\n SlideOutLeft,\n SlideInUp,\n SlideInDown,\n SlideOutUp,\n SlideOutDown,\n // Zoom\n ZoomIn,\n ZoomInRotate,\n ZoomInLeft,\n ZoomInRight,\n ZoomInUp,\n ZoomInDown,\n ZoomInEasyUp,\n ZoomInEasyDown,\n ZoomOut,\n ZoomOutRotate,\n ZoomOutLeft,\n ZoomOutRight,\n ZoomOutUp,\n ZoomOutDown,\n ZoomOutEasyUp,\n ZoomOutEasyDown,\n // Bounce\n BounceIn,\n BounceInDown,\n BounceInUp,\n BounceInLeft,\n BounceInRight,\n BounceOut,\n BounceOutDown,\n BounceOutUp,\n BounceOutLeft,\n BounceOutRight,\n // Lightspeed\n LightSpeedInRight,\n LightSpeedInLeft,\n LightSpeedOutRight,\n LightSpeedOutLeft,\n // Pinwheel\n PinwheelIn,\n PinwheelOut,\n // Rotate\n RotateInDownLeft,\n RotateInDownRight,\n RotateInUpLeft,\n RotateInUpRight,\n RotateOutDownLeft,\n RotateOutDownRight,\n RotateOutUpLeft,\n RotateOutUpRight,\n // Roll\n RollInLeft,\n RollInRight,\n RollOutLeft,\n RollOutRight,\n // Transitions\n Layout,\n LinearTransition,\n FadingTransition,\n SequencedTransition,\n JumpingTransition,\n CurvedTransition,\n EntryExitTransition,\n combineTransition,\n // SET\n SharedTransition,\n SharedTransitionType,\n} from './layoutReanimation';\nexport { isSharedValue } from './isSharedValue';\nexport type {\n StyleProps,\n SharedValue,\n AnimatableValueObject,\n AnimatableValue,\n AnimationObject,\n SensorConfig,\n Animation,\n AnimatedSensor,\n AnimationCallback,\n Value3D,\n ValueRotation,\n AnimatedKeyboardInfo,\n AnimatedKeyboardOptions,\n MeasuredDimensions,\n} from './commonTypes';\nexport {\n SensorType,\n IOSReferenceFrame,\n InterfaceOrientation,\n KeyboardState,\n ReduceMotion,\n} from './commonTypes';\nexport type { FrameInfo } from './frameCallback';\nexport { getUseOfValueInStyleWarning } from './pluginUtils';\nexport {\n withReanimatedTimer,\n advanceAnimationByTime,\n advanceAnimationByFrame,\n setUpTests,\n getAnimatedStyle,\n} from './jestUtils';\nexport { LayoutAnimationConfig } from './component/LayoutAnimationConfig';\nexport type {\n Adaptable,\n AdaptTransforms,\n AnimateProps,\n AnimatedProps,\n AnimatedTransform,\n TransformStyleTypes,\n TransformArrayItem,\n AnimateStyle,\n AnimatedStyle,\n AnimatedStyleProp,\n StylesOrDefault,\n} from './helperTypes';\nexport type { AnimatedScrollViewProps } from './component/ScrollView';\nexport type { FlatListPropsWithLayout } from './component/FlatList';\nexport { startMapper, stopMapper } from './mappers';\n"],"mappings":"AAA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AAmC;AAgBzE,SAASC,WAAW,EAAEC,UAAU,QAAQ,WAAW"}
@@ -9,6 +9,14 @@ import { useSharedValue } from './hook/useSharedValue';
9
9
  * @deprecated Please use Extrapolation instead
10
10
  */
11
11
  export const Extrapolate = Extrapolation;
12
+
13
+ /**
14
+ * Options for color interpolation.
15
+ *
16
+ * @param gamma - Gamma value used in gamma correction. Defaults to `2.2`.
17
+ * @param useCorrectedHSVInterpolation - Whether to reduce the number of colors the interpolation has to go through. Defaults to `true`.
18
+ */
19
+
12
20
  const interpolateColorsHSV = (value, inputRange, colors, options) => {
13
21
  'worklet';
14
22
 
@@ -135,6 +143,19 @@ const getInterpolateHSV = colors => {
135
143
  a
136
144
  };
137
145
  };
146
+
147
+ /**
148
+ * Lets you map a value from a range of numbers to a range of colors using linear interpolation.
149
+ *
150
+ * @param value - A number from the `input` range that is going to be mapped to the color in the `output` range.
151
+ * @param inputRange - An array of numbers specifying the input range of the interpolation.
152
+ * @param outputRange - An array of output colors values (eg. "red", "#00FFCC", "rgba(255, 0, 0, 0.5)").
153
+ * @param colorSpace - The color space to use for interpolation. Defaults to 'RGB'.
154
+ * @param options - Additional options for interpolation - {@link InterpolationOptions}.
155
+ * @returns The color after interpolation from within the output range in rgba(r, g, b, a) format.
156
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/utilities/interpolateColor
157
+ */
158
+
138
159
  export function interpolateColor(value, inputRange, outputRange) {
139
160
  'worklet';
140
161