react-native-reanimated 3.0.2 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (473) hide show
  1. package/Common/cpp/Fabric/FabricUtils.h +1 -1
  2. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +38 -27
  3. package/Common/cpp/SharedItems/Shareables.h +22 -0
  4. package/Common/cpp/Tools/PlatformDepMethodsHolder.h +2 -0
  5. package/Common/cpp/Tools/RuntimeDecorator.cpp +4 -1
  6. package/Common/cpp/Tools/RuntimeDecorator.h +2 -1
  7. package/Common/cpp/Tools/SingleInstanceChecker.h +14 -2
  8. package/RNReanimated.podspec +5 -2
  9. package/android/CMakeLists.txt +4 -0
  10. package/android/build.gradle +18 -10
  11. package/android/src/main/cpp/NativeProxy.cpp +316 -337
  12. package/android/src/main/cpp/NativeProxy.h +53 -11
  13. package/android/src/main/java/com/swmansion/reanimated/NativeMethodsHelper.java +7 -12
  14. package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +11 -8
  15. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +21 -14
  16. package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +0 -3
  17. package/ios/Fabric/REAInitializerRCTFabricSurface.mm +1 -0
  18. package/ios/REANodesManager.h +1 -0
  19. package/ios/REANodesManager.mm +30 -4
  20. package/ios/keyboardObserver/REAKeyboardEventObserver.m +51 -130
  21. package/ios/native/NativeMethods.mm +1 -1
  22. package/ios/native/NativeProxy.mm +4 -1
  23. package/ios/native/REAIOSErrorHandler.mm +1 -1
  24. package/ios/native/REAIOSLogger.mm +1 -1
  25. package/ios/native/REAIOSScheduler.mm +1 -1
  26. package/ios/native/REAInitializer.mm +1 -1
  27. package/ios/native/REAMessageThread.mm +2 -2
  28. package/lib/commonjs/Animated.js +0 -8
  29. package/lib/commonjs/Animated.js.map +1 -1
  30. package/lib/commonjs/ConfigHelper.js +8 -19
  31. package/lib/commonjs/ConfigHelper.js.map +1 -1
  32. package/lib/commonjs/createAnimatedComponent.js +20 -158
  33. package/lib/commonjs/createAnimatedComponent.js.map +1 -1
  34. package/lib/commonjs/index.js +0 -9
  35. package/lib/commonjs/index.js.map +1 -1
  36. package/lib/commonjs/index.web.js +0 -7
  37. package/lib/commonjs/index.web.js.map +1 -1
  38. package/lib/commonjs/reanimated2/Bezier.js +14 -34
  39. package/lib/commonjs/reanimated2/Bezier.js.map +1 -1
  40. package/lib/commonjs/reanimated2/Colors.js +60 -132
  41. package/lib/commonjs/reanimated2/Colors.js.map +1 -1
  42. package/lib/commonjs/reanimated2/Easing.js +81 -34
  43. package/lib/commonjs/reanimated2/Easing.js.map +1 -1
  44. package/lib/commonjs/reanimated2/NativeMethods.js +8 -20
  45. package/lib/commonjs/reanimated2/NativeMethods.js.map +1 -1
  46. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +5 -31
  47. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  48. package/lib/commonjs/reanimated2/NativeReanimated/index.js +0 -7
  49. package/lib/commonjs/reanimated2/NativeReanimated/index.js.map +1 -1
  50. package/lib/commonjs/reanimated2/PlatformChecker.js +0 -6
  51. package/lib/commonjs/reanimated2/PlatformChecker.js.map +1 -1
  52. package/lib/commonjs/reanimated2/PropAdapters.js +10 -12
  53. package/lib/commonjs/reanimated2/PropAdapters.js.map +1 -1
  54. package/lib/commonjs/reanimated2/UpdateProps.js +3 -12
  55. package/lib/commonjs/reanimated2/UpdateProps.js.map +1 -1
  56. package/lib/commonjs/reanimated2/ViewDescriptorsSet.js +0 -10
  57. package/lib/commonjs/reanimated2/ViewDescriptorsSet.js.map +1 -1
  58. package/lib/commonjs/reanimated2/WorkletEventHandler.js +5 -22
  59. package/lib/commonjs/reanimated2/WorkletEventHandler.js.map +1 -1
  60. package/lib/commonjs/reanimated2/animation/decay.js +7 -18
  61. package/lib/commonjs/reanimated2/animation/decay.js.map +1 -1
  62. package/lib/commonjs/reanimated2/animation/delay.js +0 -11
  63. package/lib/commonjs/reanimated2/animation/delay.js.map +1 -1
  64. package/lib/commonjs/reanimated2/animation/index.js +0 -8
  65. package/lib/commonjs/reanimated2/animation/index.js.map +1 -1
  66. package/lib/commonjs/reanimated2/animation/repeat.js +6 -22
  67. package/lib/commonjs/reanimated2/animation/repeat.js.map +1 -1
  68. package/lib/commonjs/reanimated2/animation/sequence.js +3 -20
  69. package/lib/commonjs/reanimated2/animation/sequence.js.map +1 -1
  70. package/lib/commonjs/reanimated2/animation/spring.js +11 -23
  71. package/lib/commonjs/reanimated2/animation/spring.js.map +1 -1
  72. package/lib/commonjs/reanimated2/animation/styleAnimation.js +3 -35
  73. package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
  74. package/lib/commonjs/reanimated2/animation/timing.js +0 -11
  75. package/lib/commonjs/reanimated2/animation/timing.js.map +1 -1
  76. package/lib/commonjs/reanimated2/animation/util.js +11 -41
  77. package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
  78. package/lib/commonjs/reanimated2/commonTypes.js +16 -23
  79. package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
  80. package/lib/commonjs/reanimated2/component/FlatList.js +0 -16
  81. package/lib/commonjs/reanimated2/component/FlatList.js.map +1 -1
  82. package/lib/commonjs/reanimated2/component/Image.js +0 -4
  83. package/lib/commonjs/reanimated2/component/Image.js.map +1 -1
  84. package/lib/commonjs/reanimated2/component/ScrollView.js +0 -4
  85. package/lib/commonjs/reanimated2/component/ScrollView.js.map +1 -1
  86. package/lib/commonjs/reanimated2/component/Text.js +0 -4
  87. package/lib/commonjs/reanimated2/component/Text.js.map +1 -1
  88. package/lib/commonjs/reanimated2/component/View.js +0 -4
  89. package/lib/commonjs/reanimated2/component/View.js.map +1 -1
  90. package/lib/commonjs/reanimated2/core.js +6 -48
  91. package/lib/commonjs/reanimated2/core.js.map +1 -1
  92. package/lib/commonjs/reanimated2/errors.js +3 -14
  93. package/lib/commonjs/reanimated2/errors.js.map +1 -1
  94. package/lib/commonjs/reanimated2/fabricUtils.js +3 -5
  95. package/lib/commonjs/reanimated2/fabricUtils.js.map +1 -1
  96. package/lib/commonjs/reanimated2/fabricUtils.web.js +1 -3
  97. package/lib/commonjs/reanimated2/fabricUtils.web.js.map +1 -1
  98. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryJS.js +3 -12
  99. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryJS.js.map +1 -1
  100. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +13 -17
  101. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  102. package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
  103. package/lib/commonjs/reanimated2/hook/Hooks.js +0 -5
  104. package/lib/commonjs/reanimated2/hook/Hooks.js.map +1 -1
  105. package/lib/commonjs/reanimated2/hook/commonTypes.js.map +1 -1
  106. package/lib/commonjs/reanimated2/hook/index.js +0 -12
  107. package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
  108. package/lib/commonjs/reanimated2/hook/useAnimatedGestureHandler.js +4 -17
  109. package/lib/commonjs/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
  110. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +2 -9
  111. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  112. package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +1 -11
  113. package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  114. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +0 -12
  115. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
  116. package/lib/commonjs/reanimated2/hook/useAnimatedScrollHandler.js +2 -9
  117. package/lib/commonjs/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
  118. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +8 -23
  119. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  120. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +13 -71
  121. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  122. package/lib/commonjs/reanimated2/hook/useDerivedValue.js +4 -13
  123. package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
  124. package/lib/commonjs/reanimated2/hook/useFrameCallback.js +0 -5
  125. package/lib/commonjs/reanimated2/hook/useFrameCallback.js.map +1 -1
  126. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +0 -7
  127. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  128. package/lib/commonjs/reanimated2/hook/useSharedValue.js +2 -7
  129. package/lib/commonjs/reanimated2/hook/useSharedValue.js.map +1 -1
  130. package/lib/commonjs/reanimated2/hook/utils.js +8 -39
  131. package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
  132. package/lib/commonjs/reanimated2/index.js +0 -26
  133. package/lib/commonjs/reanimated2/index.js.map +1 -1
  134. package/lib/commonjs/reanimated2/initializers.js +21 -43
  135. package/lib/commonjs/reanimated2/initializers.js.map +1 -1
  136. package/lib/commonjs/reanimated2/interpolateColor.js +6 -43
  137. package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
  138. package/lib/commonjs/reanimated2/interpolation.js +14 -29
  139. package/lib/commonjs/reanimated2/interpolation.js.map +1 -1
  140. package/lib/commonjs/reanimated2/jestUtils.js +11 -44
  141. package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
  142. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +15 -39
  143. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  144. package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +9 -28
  145. package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
  146. package/lib/commonjs/reanimated2/js-reanimated/MapperRegistry.js +7 -37
  147. package/lib/commonjs/reanimated2/js-reanimated/MapperRegistry.js.map +1 -1
  148. package/lib/commonjs/reanimated2/js-reanimated/MutableValue.js +5 -18
  149. package/lib/commonjs/reanimated2/js-reanimated/MutableValue.js.map +1 -1
  150. package/lib/commonjs/reanimated2/js-reanimated/global.js +2 -9
  151. package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
  152. package/lib/commonjs/reanimated2/js-reanimated/index.js +3 -14
  153. package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
  154. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +7 -26
  155. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
  156. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +3 -49
  157. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
  158. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +7 -43
  159. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
  160. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +4 -5
  161. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  162. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +0 -4
  163. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  164. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +4 -23
  165. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  166. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +3 -74
  167. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  168. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Fade.js +3 -53
  169. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
  170. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Flip.js +3 -63
  171. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
  172. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +7 -26
  173. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  174. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +3 -13
  175. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
  176. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +3 -23
  177. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  178. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +3 -43
  179. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
  180. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +3 -43
  181. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  182. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +3 -23
  183. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
  184. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +3 -83
  185. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  186. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/index.js +0 -20
  187. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/index.js.map +1 -1
  188. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +3 -22
  189. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
  190. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +5 -29
  191. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
  192. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +3 -9
  193. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
  194. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +5 -11
  195. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
  196. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +3 -8
  197. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
  198. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +3 -12
  199. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
  200. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/index.js +0 -12
  201. package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/index.js.map +1 -1
  202. package/lib/commonjs/reanimated2/layoutReanimation/index.js +0 -9
  203. package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
  204. package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +3 -17
  205. package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -1
  206. package/lib/commonjs/reanimated2/mappers.js +26 -32
  207. package/lib/commonjs/reanimated2/mappers.js.map +1 -1
  208. package/lib/commonjs/reanimated2/mock.js +5 -15
  209. package/lib/commonjs/reanimated2/mock.js.map +1 -1
  210. package/lib/commonjs/reanimated2/mutables.js +2 -28
  211. package/lib/commonjs/reanimated2/mutables.js.map +1 -1
  212. package/lib/commonjs/reanimated2/platform-specific/RNRenderer.js +0 -2
  213. package/lib/commonjs/reanimated2/platform-specific/RNRenderer.js.map +1 -1
  214. package/lib/commonjs/reanimated2/platform-specific/RNRenderer.web.js.map +1 -1
  215. package/lib/commonjs/reanimated2/platform-specific/checkCppVersion.js +31 -0
  216. package/lib/commonjs/reanimated2/platform-specific/checkCppVersion.js.map +1 -0
  217. package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +0 -2
  218. package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -1
  219. package/lib/commonjs/reanimated2/platform-specific/jsVersion.js +14 -0
  220. package/lib/commonjs/reanimated2/platform-specific/jsVersion.js.map +1 -0
  221. package/lib/commonjs/reanimated2/pluginUtils.js +0 -1
  222. package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -1
  223. package/lib/commonjs/reanimated2/shareables.js +92 -49
  224. package/lib/commonjs/reanimated2/shareables.js.map +1 -1
  225. package/lib/commonjs/reanimated2/threads.js +42 -46
  226. package/lib/commonjs/reanimated2/threads.js.map +1 -1
  227. package/lib/commonjs/reanimated2/utils.js +0 -5
  228. package/lib/commonjs/reanimated2/utils.js.map +1 -1
  229. package/lib/commonjs/reanimated2/valueSetter.js +6 -21
  230. package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
  231. package/lib/commonjs/setAndForwardRef.js +3 -3
  232. package/lib/commonjs/setAndForwardRef.js.map +1 -1
  233. package/lib/module/Animated.js.map +1 -1
  234. package/lib/module/ConfigHelper.js +9 -15
  235. package/lib/module/ConfigHelper.js.map +1 -1
  236. package/lib/module/createAnimatedComponent.js +20 -139
  237. package/lib/module/createAnimatedComponent.js.map +1 -1
  238. package/lib/module/index.js +0 -2
  239. package/lib/module/index.js.map +1 -1
  240. package/lib/module/index.web.js.map +1 -1
  241. package/lib/module/reanimated2/Bezier.js +14 -33
  242. package/lib/module/reanimated2/Bezier.js.map +1 -1
  243. package/lib/module/reanimated2/Colors.js +59 -109
  244. package/lib/module/reanimated2/Colors.js.map +1 -1
  245. package/lib/module/reanimated2/Easing.js +37 -33
  246. package/lib/module/reanimated2/Easing.js.map +1 -1
  247. package/lib/module/reanimated2/NativeMethods.js +8 -15
  248. package/lib/module/reanimated2/NativeMethods.js.map +1 -1
  249. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +5 -27
  250. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  251. package/lib/module/reanimated2/NativeReanimated/index.js +0 -2
  252. package/lib/module/reanimated2/NativeReanimated/index.js.map +1 -1
  253. package/lib/module/reanimated2/PlatformChecker.js.map +1 -1
  254. package/lib/module/reanimated2/PropAdapters.js +12 -10
  255. package/lib/module/reanimated2/PropAdapters.js.map +1 -1
  256. package/lib/module/reanimated2/UpdateProps.js +3 -5
  257. package/lib/module/reanimated2/UpdateProps.js.map +1 -1
  258. package/lib/module/reanimated2/ViewDescriptorsSet.js +0 -6
  259. package/lib/module/reanimated2/ViewDescriptorsSet.js.map +1 -1
  260. package/lib/module/reanimated2/WorkletEventHandler.js +5 -18
  261. package/lib/module/reanimated2/WorkletEventHandler.js.map +1 -1
  262. package/lib/module/reanimated2/animation/decay.js +7 -15
  263. package/lib/module/reanimated2/animation/decay.js.map +1 -1
  264. package/lib/module/reanimated2/animation/delay.js +0 -9
  265. package/lib/module/reanimated2/animation/delay.js.map +1 -1
  266. package/lib/module/reanimated2/animation/index.js.map +1 -1
  267. package/lib/module/reanimated2/animation/repeat.js +6 -20
  268. package/lib/module/reanimated2/animation/repeat.js.map +1 -1
  269. package/lib/module/reanimated2/animation/sequence.js +3 -18
  270. package/lib/module/reanimated2/animation/sequence.js.map +1 -1
  271. package/lib/module/reanimated2/animation/spring.js +11 -21
  272. package/lib/module/reanimated2/animation/spring.js.map +1 -1
  273. package/lib/module/reanimated2/animation/styleAnimation.js +7 -31
  274. package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
  275. package/lib/module/reanimated2/animation/timing.js +0 -8
  276. package/lib/module/reanimated2/animation/timing.js.map +1 -1
  277. package/lib/module/reanimated2/animation/util.js +10 -33
  278. package/lib/module/reanimated2/animation/util.js.map +1 -1
  279. package/lib/module/reanimated2/commonTypes.js +12 -19
  280. package/lib/module/reanimated2/commonTypes.js.map +1 -1
  281. package/lib/module/reanimated2/component/FlatList.js +0 -4
  282. package/lib/module/reanimated2/component/FlatList.js.map +1 -1
  283. package/lib/module/reanimated2/component/Image.js.map +1 -1
  284. package/lib/module/reanimated2/component/ScrollView.js.map +1 -1
  285. package/lib/module/reanimated2/component/Text.js.map +1 -1
  286. package/lib/module/reanimated2/component/View.js.map +1 -1
  287. package/lib/module/reanimated2/core.js +6 -22
  288. package/lib/module/reanimated2/core.js.map +1 -1
  289. package/lib/module/reanimated2/errors.js +3 -13
  290. package/lib/module/reanimated2/errors.js.map +1 -1
  291. package/lib/module/reanimated2/fabricUtils.js +3 -3
  292. package/lib/module/reanimated2/fabricUtils.js.map +1 -1
  293. package/lib/module/reanimated2/fabricUtils.web.js +1 -1
  294. package/lib/module/reanimated2/fabricUtils.web.js.map +1 -1
  295. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js +3 -8
  296. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js.map +1 -1
  297. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +13 -15
  298. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  299. package/lib/module/reanimated2/globals.d.js.map +1 -1
  300. package/lib/module/reanimated2/hook/Hooks.js +3 -2
  301. package/lib/module/reanimated2/hook/Hooks.js.map +1 -1
  302. package/lib/module/reanimated2/hook/commonTypes.js.map +1 -1
  303. package/lib/module/reanimated2/hook/index.js.map +1 -1
  304. package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js +3 -14
  305. package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
  306. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +2 -5
  307. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  308. package/lib/module/reanimated2/hook/useAnimatedReaction.js +1 -7
  309. package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  310. package/lib/module/reanimated2/hook/useAnimatedRef.js +0 -6
  311. package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
  312. package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js +2 -7
  313. package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
  314. package/lib/module/reanimated2/hook/useAnimatedSensor.js +9 -20
  315. package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  316. package/lib/module/reanimated2/hook/useAnimatedStyle.js +13 -59
  317. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  318. package/lib/module/reanimated2/hook/useDerivedValue.js +4 -8
  319. package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
  320. package/lib/module/reanimated2/hook/useFrameCallback.js.map +1 -1
  321. package/lib/module/reanimated2/hook/useScrollViewOffset.js +0 -1
  322. package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  323. package/lib/module/reanimated2/hook/useSharedValue.js +2 -3
  324. package/lib/module/reanimated2/hook/useSharedValue.js.map +1 -1
  325. package/lib/module/reanimated2/hook/utils.js +8 -21
  326. package/lib/module/reanimated2/hook/utils.js.map +1 -1
  327. package/lib/module/reanimated2/index.js.map +1 -1
  328. package/lib/module/reanimated2/initializers.js +23 -37
  329. package/lib/module/reanimated2/initializers.js.map +1 -1
  330. package/lib/module/reanimated2/interpolateColor.js +5 -34
  331. package/lib/module/reanimated2/interpolateColor.js.map +1 -1
  332. package/lib/module/reanimated2/interpolation.js +13 -28
  333. package/lib/module/reanimated2/interpolation.js.map +1 -1
  334. package/lib/module/reanimated2/jestUtils.js +11 -35
  335. package/lib/module/reanimated2/jestUtils.js.map +1 -1
  336. package/lib/module/reanimated2/js-reanimated/JSReanimated.js +15 -35
  337. package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  338. package/lib/module/reanimated2/js-reanimated/Mapper.js +9 -23
  339. package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
  340. package/lib/module/reanimated2/js-reanimated/MapperRegistry.js +7 -35
  341. package/lib/module/reanimated2/js-reanimated/MapperRegistry.js.map +1 -1
  342. package/lib/module/reanimated2/js-reanimated/MutableValue.js +5 -16
  343. package/lib/module/reanimated2/js-reanimated/MutableValue.js.map +1 -1
  344. package/lib/module/reanimated2/js-reanimated/global.js +2 -6
  345. package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
  346. package/lib/module/reanimated2/js-reanimated/index.js +3 -9
  347. package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
  348. package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +7 -23
  349. package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
  350. package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +3 -45
  351. package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
  352. package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +7 -39
  353. package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
  354. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +3 -3
  355. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  356. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  357. package/lib/module/reanimated2/layoutReanimation/animationsManager.js +4 -19
  358. package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  359. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +3 -52
  360. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  361. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js +3 -32
  362. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
  363. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js +3 -38
  364. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
  365. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +7 -16
  366. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  367. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +3 -8
  368. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
  369. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +3 -14
  370. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  371. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +3 -26
  372. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
  373. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +3 -26
  374. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  375. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +3 -14
  376. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
  377. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +3 -50
  378. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  379. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/index.js.map +1 -1
  380. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +3 -17
  381. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
  382. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +5 -23
  383. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
  384. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +3 -5
  385. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
  386. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +5 -6
  387. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
  388. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +3 -5
  389. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
  390. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +3 -8
  391. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
  392. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/index.js.map +1 -1
  393. package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
  394. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +3 -13
  395. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -1
  396. package/lib/module/reanimated2/mappers.js +26 -25
  397. package/lib/module/reanimated2/mappers.js.map +1 -1
  398. package/lib/module/reanimated2/mock.js +5 -15
  399. package/lib/module/reanimated2/mock.js.map +1 -1
  400. package/lib/module/reanimated2/mutables.js +2 -19
  401. package/lib/module/reanimated2/mutables.js.map +1 -1
  402. package/lib/module/reanimated2/platform-specific/RNRenderer.js.map +1 -1
  403. package/lib/module/reanimated2/platform-specific/RNRenderer.web.js.map +1 -1
  404. package/lib/module/reanimated2/platform-specific/checkCppVersion.js +24 -0
  405. package/lib/module/reanimated2/platform-specific/checkCppVersion.js.map +1 -0
  406. package/lib/module/reanimated2/platform-specific/checkVersion.web.js +0 -1
  407. package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -1
  408. package/lib/module/reanimated2/platform-specific/jsVersion.js +7 -0
  409. package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -0
  410. package/lib/module/reanimated2/pluginUtils.js.map +1 -1
  411. package/lib/module/reanimated2/shareables.js +96 -44
  412. package/lib/module/reanimated2/shareables.js.map +1 -1
  413. package/lib/module/reanimated2/threads.js +39 -33
  414. package/lib/module/reanimated2/threads.js.map +1 -1
  415. package/lib/module/reanimated2/utils.js +0 -3
  416. package/lib/module/reanimated2/utils.js.map +1 -1
  417. package/lib/module/reanimated2/valueSetter.js +6 -19
  418. package/lib/module/reanimated2/valueSetter.js.map +1 -1
  419. package/lib/module/setAndForwardRef.js +3 -2
  420. package/lib/module/setAndForwardRef.js.map +1 -1
  421. package/package.json +46 -40
  422. package/plugin/.eslintrc.js +7 -0
  423. package/plugin/README.md +241 -0
  424. package/plugin/build/plugin.js +714 -0
  425. package/plugin/build/plugin.js.map +7 -0
  426. package/plugin/index.js +1 -807
  427. package/plugin/package.json +23 -0
  428. package/plugin/src/buildWorkletString.ts +213 -0
  429. package/plugin/src/commonObjects.ts +60 -0
  430. package/plugin/src/injectVersion.ts +37 -0
  431. package/plugin/src/makeWorklet.ts +375 -0
  432. package/plugin/src/plugin.ts +49 -0
  433. package/plugin/src/processForCalleesWorklets.ts +106 -0
  434. package/plugin/src/processIfGestureHandlerEventCallbackFunctionNode.ts +156 -0
  435. package/plugin/src/processIfWorkletFunction.ts +55 -0
  436. package/plugin/src/processIfWorkletNode.ts +44 -0
  437. package/plugin/src/processInlineStylesWarning.ts +129 -0
  438. package/plugin/src/processWorkletObjectMethod.ts +31 -0
  439. package/plugin/src/types.ts +15 -0
  440. package/plugin/src/utils.ts +6 -0
  441. package/plugin/tsconfig.json +15 -0
  442. package/plugin/yarn.lock +2193 -0
  443. package/react-native-reanimated.d.ts +1 -0
  444. package/scripts/reanimated_utils.rb +2 -2
  445. package/src/createAnimatedComponent.tsx +2 -3
  446. package/src/reanimated2/Easing.ts +19 -0
  447. package/src/reanimated2/NativeMethods.ts +9 -4
  448. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +2 -2
  449. package/src/reanimated2/UpdateProps.ts +2 -2
  450. package/src/reanimated2/animation/decay.ts +7 -1
  451. package/src/reanimated2/animation/styleAnimation.ts +5 -1
  452. package/src/reanimated2/core.ts +4 -4
  453. package/src/reanimated2/errors.ts +1 -0
  454. package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +12 -4
  455. package/src/reanimated2/globals.d.ts +71 -112
  456. package/src/reanimated2/hook/commonTypes.ts +1 -1
  457. package/src/reanimated2/hook/useAnimatedReaction.ts +2 -2
  458. package/src/reanimated2/hook/useAnimatedSensor.ts +2 -2
  459. package/src/reanimated2/initializers.ts +11 -8
  460. package/src/reanimated2/jestUtils.ts +0 -1
  461. package/src/reanimated2/js-reanimated/JSReanimated.ts +5 -1
  462. package/src/reanimated2/js-reanimated/index.ts +1 -1
  463. package/src/reanimated2/mappers.ts +26 -4
  464. package/src/reanimated2/mock.ts +1 -0
  465. package/src/reanimated2/platform-specific/checkCppVersion.ts +29 -0
  466. package/src/reanimated2/platform-specific/jsVersion.ts +6 -0
  467. package/src/reanimated2/shareables.ts +107 -8
  468. package/src/reanimated2/threads.ts +36 -17
  469. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +0 -42
  470. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +0 -1
  471. package/lib/module/reanimated2/platform-specific/checkVersion.js +0 -35
  472. package/lib/module/reanimated2/platform-specific/checkVersion.js.map +0 -1
  473. package/src/reanimated2/platform-specific/checkVersion.ts +0 -39
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useRef","findNodeHandle","useEvent","useSharedValue","scrollEventNames","useScrollViewOffset","aref","offsetRef","event","current","value","contentOffset","x","y","viewTag","registerForEvents"],"sources":["useScrollViewOffset.ts"],"sourcesContent":["import { RefObject, useEffect, useRef } from 'react';\n\nimport type Animated from 'react-native-reanimated';\nimport { ScrollEvent } from './useAnimatedScrollHandler';\nimport { SharedValue } from '../commonTypes';\nimport { findNodeHandle } from 'react-native';\nimport { useEvent } from './utils';\nimport { useSharedValue } from './useSharedValue';\n\nconst scrollEventNames = [\n 'onScroll',\n 'onScrollBeginDrag',\n 'onScrollEndDrag',\n 'onMomentumScrollBegin',\n 'onMomentumScrollEnd',\n];\n\nexport function useScrollViewOffset(\n aref: RefObject<Animated.ScrollView>\n): SharedValue<number> {\n const offsetRef = useRef(useSharedValue(0));\n\n const event = useEvent<ScrollEvent>((event: ScrollEvent) => {\n 'worklet';\n offsetRef.current.value =\n event.contentOffset.x === 0\n ? event.contentOffset.y\n : event.contentOffset.x;\n }, scrollEventNames);\n\n useEffect(() => {\n const viewTag = findNodeHandle(aref.current);\n event.current?.registerForEvents(viewTag as number);\n }, [aref.current]);\n\n return offsetRef.current;\n}\n"],"mappings":"AAAA,SAAoBA,SAApB,EAA+BC,MAA/B,QAA6C,OAA7C;AAKA,SAASC,cAAT,QAA+B,cAA/B;AACA,SAASC,QAAT,QAAyB,SAAzB;AACA,SAASC,cAAT,QAA+B,kBAA/B;AAEA,MAAMC,gBAAgB,GAAG,CACvB,UADuB,EAEvB,mBAFuB,EAGvB,iBAHuB,EAIvB,uBAJuB,EAKvB,qBALuB,CAAzB;AAQA,OAAO,SAASC,mBAAT,CACLC,IADK,EAEgB;EACrB,MAAMC,SAAS,GAAGP,MAAM,CAACG,cAAc,CAAC,CAAD,CAAf,CAAxB;EAEA,MAAMK,KAAK,GAAGN,QAAQ,CAAeM,KAAD,IAAwB;IAC1D;;IACAD,SAAS,CAACE,OAAV,CAAkBC,KAAlB,GACEF,KAAK,CAACG,aAAN,CAAoBC,CAApB,KAA0B,CAA1B,GACIJ,KAAK,CAACG,aAAN,CAAoBE,CADxB,GAEIL,KAAK,CAACG,aAAN,CAAoBC,CAH1B;EAID,CANqB,EAMnBR,gBANmB,CAAtB;EAQAL,SAAS,CAAC,MAAM;IAAA;;IACd,MAAMe,OAAO,GAAGb,cAAc,CAACK,IAAI,CAACG,OAAN,CAA9B;IACA,kBAAAD,KAAK,CAACC,OAAN,kEAAeM,iBAAf,CAAiCD,OAAjC;EACD,CAHQ,EAGN,CAACR,IAAI,CAACG,OAAN,CAHM,CAAT;EAKA,OAAOF,SAAS,CAACE,OAAjB;AACD"}
1
+ {"version":3,"names":["useEffect","useRef","findNodeHandle","useEvent","useSharedValue","scrollEventNames","useScrollViewOffset","aref","offsetRef","event","current","value","contentOffset","x","y","_event$current","viewTag","registerForEvents"],"sources":["useScrollViewOffset.ts"],"sourcesContent":["import { RefObject, useEffect, useRef } from 'react';\n\nimport type Animated from 'react-native-reanimated';\nimport { ScrollEvent } from './useAnimatedScrollHandler';\nimport { SharedValue } from '../commonTypes';\nimport { findNodeHandle } from 'react-native';\nimport { useEvent } from './utils';\nimport { useSharedValue } from './useSharedValue';\n\nconst scrollEventNames = [\n 'onScroll',\n 'onScrollBeginDrag',\n 'onScrollEndDrag',\n 'onMomentumScrollBegin',\n 'onMomentumScrollEnd',\n];\n\nexport function useScrollViewOffset(\n aref: RefObject<Animated.ScrollView>\n): SharedValue<number> {\n const offsetRef = useRef(useSharedValue(0));\n\n const event = useEvent<ScrollEvent>((event: ScrollEvent) => {\n 'worklet';\n offsetRef.current.value =\n event.contentOffset.x === 0\n ? event.contentOffset.y\n : event.contentOffset.x;\n }, scrollEventNames);\n\n useEffect(() => {\n const viewTag = findNodeHandle(aref.current);\n event.current?.registerForEvents(viewTag as number);\n }, [aref.current]);\n\n return offsetRef.current;\n}\n"],"mappings":"AAAA,SAAoBA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAKpD,SAASC,cAAc,QAAQ,cAAc;AAC7C,SAASC,QAAQ,QAAQ,SAAS;AAClC,SAASC,cAAc,QAAQ,kBAAkB;AAEjD,MAAMC,gBAAgB,GAAG,CACvB,UAAU,EACV,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,CACtB;AAED,OAAO,SAASC,mBAAmBA,CACjCC,IAAoC,EACf;EACrB,MAAMC,SAAS,GAAGP,MAAM,CAACG,cAAc,CAAC,CAAC,CAAC,CAAC;EAE3C,MAAMK,KAAK,GAAGN,QAAQ,CAAeM,KAAkB,IAAK;IAC1D,SAAS;;IACTD,SAAS,CAACE,OAAO,CAACC,KAAK,GACrBF,KAAK,CAACG,aAAa,CAACC,CAAC,KAAK,CAAC,GACvBJ,KAAK,CAACG,aAAa,CAACE,CAAC,GACrBL,KAAK,CAACG,aAAa,CAACC,CAAC;EAC7B,CAAC,EAAER,gBAAgB,CAAC;EAEpBL,SAAS,CAAC,MAAM;IAAA,IAAAe,cAAA;IACd,MAAMC,OAAO,GAAGd,cAAc,CAACK,IAAI,CAACG,OAAO,CAAC;IAC5C,CAAAK,cAAA,GAAAN,KAAK,CAACC,OAAO,cAAAK,cAAA,uBAAbA,cAAA,CAAeE,iBAAiB,CAACD,OAAO,CAAW;EACrD,CAAC,EAAE,CAACT,IAAI,CAACG,OAAO,CAAC,CAAC;EAElB,OAAOF,SAAS,CAACE,OAAO;AAC1B"}
@@ -4,18 +4,17 @@ import { makeMutable } from '../core';
4
4
  export function useSharedValue(init) {
5
5
  let oneWayReadsOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
6
6
  const ref = useRef(makeMutable(init, oneWayReadsOnly));
7
-
8
7
  if (ref.current === null) {
9
8
  ref.current = makeMutable(init, oneWayReadsOnly);
10
9
  }
11
-
12
10
  useEffect(() => {
13
11
  return () => {
14
12
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
15
13
  cancelAnimation(ref.current);
16
14
  };
17
- }, []); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
15
+ }, []);
18
16
 
17
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
19
18
  return ref.current;
20
19
  }
21
20
  //# sourceMappingURL=useSharedValue.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useRef","cancelAnimation","makeMutable","useSharedValue","init","oneWayReadsOnly","ref","current"],"sources":["useSharedValue.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { cancelAnimation } from '../animation';\nimport { SharedValue } from '../commonTypes';\nimport { makeMutable } from '../core';\n\nexport function useSharedValue<T>(\n init: T,\n oneWayReadsOnly = false\n): SharedValue<T> {\n const ref = useRef<SharedValue<T>>(makeMutable(init, oneWayReadsOnly));\n\n if (ref.current === null) {\n ref.current = makeMutable(init, oneWayReadsOnly);\n }\n\n useEffect(() => {\n return () => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n cancelAnimation(ref.current!);\n };\n }, []);\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return ref.current!;\n}\n"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,OAAlC;AACA,SAASC,eAAT,QAAgC,cAAhC;AAEA,SAASC,WAAT,QAA4B,SAA5B;AAEA,OAAO,SAASC,cAAT,CACLC,IADK,EAGW;EAAA,IADhBC,eACgB,uEADE,KACF;EAChB,MAAMC,GAAG,GAAGN,MAAM,CAAiBE,WAAW,CAACE,IAAD,EAAOC,eAAP,CAA5B,CAAlB;;EAEA,IAAIC,GAAG,CAACC,OAAJ,KAAgB,IAApB,EAA0B;IACxBD,GAAG,CAACC,OAAJ,GAAcL,WAAW,CAACE,IAAD,EAAOC,eAAP,CAAzB;EACD;;EAEDN,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACX;MACAE,eAAe,CAACK,GAAG,CAACC,OAAL,CAAf;IACD,CAHD;EAID,CALQ,EAKN,EALM,CAAT,CAPgB,CAchB;;EACA,OAAOD,GAAG,CAACC,OAAX;AACD"}
1
+ {"version":3,"names":["useEffect","useRef","cancelAnimation","makeMutable","useSharedValue","init","oneWayReadsOnly","arguments","length","undefined","ref","current"],"sources":["useSharedValue.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { cancelAnimation } from '../animation';\nimport { SharedValue } from '../commonTypes';\nimport { makeMutable } from '../core';\n\nexport function useSharedValue<T>(\n init: T,\n oneWayReadsOnly = false\n): SharedValue<T> {\n const ref = useRef<SharedValue<T>>(makeMutable(init, oneWayReadsOnly));\n\n if (ref.current === null) {\n ref.current = makeMutable(init, oneWayReadsOnly);\n }\n\n useEffect(() => {\n return () => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n cancelAnimation(ref.current!);\n };\n }, []);\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return ref.current!;\n}\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACzC,SAASC,eAAe,QAAQ,cAAc;AAE9C,SAASC,WAAW,QAAQ,SAAS;AAErC,OAAO,SAASC,cAAcA,CAC5BC,IAAO,EAES;EAAA,IADhBC,eAAe,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAEvB,MAAMG,GAAG,GAAGT,MAAM,CAAiBE,WAAW,CAACE,IAAI,EAAEC,eAAe,CAAC,CAAC;EAEtE,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;MACX;MACAE,eAAe,CAACQ,GAAG,CAACC,OAAO,CAAE;IAC/B,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;;EAEN;EACA,OAAOD,GAAG,CAACC,OAAO;AACpB"}
@@ -8,25 +8,21 @@ export function useEvent(handler) {
8
8
  let eventNames = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
9
9
  let rebuild = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
10
10
  const initRef = useRef(null);
11
-
12
11
  if (initRef.current === null) {
13
12
  initRef.current = new WorkletEventHandler(handler, eventNames);
14
13
  } else if (rebuild) {
15
14
  initRef.current.updateWorklet(handler);
16
15
  }
17
-
18
16
  return initRef;
19
17
  }
20
18
  export function useHandler(handlers, dependencies) {
21
19
  const initRef = useRef(null);
22
-
23
20
  if (initRef.current === null) {
24
21
  initRef.current = {
25
22
  context: makeRemote({}),
26
23
  savedDependencies: []
27
24
  };
28
25
  }
29
-
30
26
  useEffect(() => {
31
27
  return () => {
32
28
  initRef.current = null;
@@ -45,16 +41,18 @@ export function useHandler(handlers, dependencies) {
45
41
  doDependenciesDiffer,
46
42
  useWeb
47
43
  };
48
- } // builds one big hash from multiple worklets' hashes
44
+ }
49
45
 
46
+ // builds one big hash from multiple worklets' hashes
50
47
  export function buildWorkletsHash(handlers) {
51
- return Object.values(handlers).reduce((acc, worklet) => // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
48
+ return Object.values(handlers).reduce((acc, worklet) =>
49
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
52
50
  acc + worklet.__workletHash.toString(), '');
53
- } // builds dependencies array for gesture handlers
51
+ }
54
52
 
53
+ // builds dependencies array for gesture handlers
55
54
  export function buildDependencies(dependencies, handlers) {
56
55
  const handlersList = Object.values(handlers).filter(handler => handler !== undefined);
57
-
58
56
  if (!dependencies) {
59
57
  dependencies = handlersList.map(handler => {
60
58
  return {
@@ -65,10 +63,10 @@ export function buildDependencies(dependencies, handlers) {
65
63
  } else {
66
64
  dependencies.push(buildWorkletsHash(handlersList));
67
65
  }
68
-
69
66
  return dependencies;
70
- } // this is supposed to work as useEffect comparison
67
+ }
71
68
 
69
+ // this is supposed to work as useEffect comparison
72
70
  export function areDependenciesEqual(nextDeps, prevDeps) {
73
71
  function is(x, y) {
74
72
  /* eslint-disable no-self-compare */
@@ -77,32 +75,26 @@ export function areDependenciesEqual(nextDeps, prevDeps) {
77
75
  }
78
76
 
79
77
  const objectIs = typeof Object.is === 'function' ? Object.is : is;
80
-
81
78
  function areHookInputsEqual(nextDeps, prevDeps) {
82
79
  if (!nextDeps || !prevDeps || prevDeps.length !== nextDeps.length) {
83
80
  return false;
84
81
  }
85
-
86
82
  for (let i = 0; i < prevDeps.length; ++i) {
87
83
  if (!objectIs(nextDeps[i], prevDeps[i])) {
88
84
  return false;
89
85
  }
90
86
  }
91
-
92
87
  return true;
93
88
  }
94
-
95
89
  return areHookInputsEqual(nextDeps, prevDeps);
96
90
  }
97
91
  export function hasColorProps(updates) {
98
92
  const colorPropsSet = new Set(colorProps);
99
-
100
93
  for (const key in updates) {
101
94
  if (colorPropsSet.has(key)) {
102
95
  return true;
103
96
  }
104
97
  }
105
-
106
98
  return false;
107
99
  }
108
100
  export function parseColors(updates) {
@@ -113,7 +105,6 @@ export function parseColors(updates) {
113
105
  // value could be an animation in which case processColor will recognize it and will return undefined
114
106
  // -> in such a case we don't want to override style of that key
115
107
  const processedColor = processColor(updates[key]);
116
-
117
108
  if (processedColor !== undefined) {
118
109
  updates[key] = processedColor;
119
110
  }
@@ -132,7 +123,6 @@ export function isAnimated(prop) {
132
123
  return Object.values(prop).some(isAnimated);
133
124
  }
134
125
  }
135
-
136
126
  return false;
137
127
  }
138
128
  export function shallowEqual(a, b) {
@@ -140,17 +130,14 @@ export function shallowEqual(a, b) {
140
130
 
141
131
  const aKeys = Object.keys(a);
142
132
  const bKeys = Object.keys(b);
143
-
144
133
  if (aKeys.length !== bKeys.length) {
145
134
  return false;
146
135
  }
147
-
148
136
  for (let i = 0; i < aKeys.length; i++) {
149
137
  if (a[aKeys[i]] !== b[aKeys[i]]) {
150
138
  return false;
151
139
  }
152
140
  }
153
-
154
141
  return true;
155
142
  }
156
143
  export const validateAnimatedStyles = styles => {
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useRef","processColor","makeRemote","isWeb","isJest","colorProps","WorkletEventHandler","useEvent","handler","eventNames","rebuild","initRef","current","updateWorklet","useHandler","handlers","dependencies","context","savedDependencies","buildDependencies","doDependenciesDiffer","areDependenciesEqual","useWeb","buildWorkletsHash","Object","values","reduce","acc","worklet","__workletHash","toString","handlersList","filter","undefined","map","workletHash","closure","_closure","push","nextDeps","prevDeps","is","x","y","objectIs","areHookInputsEqual","length","i","hasColorProps","updates","colorPropsSet","Set","key","has","parseColors","indexOf","processedColor","isAnimated","prop","Array","isArray","some","onFrame","shallowEqual","a","b","aKeys","keys","bKeys","validateAnimatedStyles","styles","Error"],"sources":["utils.ts"],"sourcesContent":["import { MutableRefObject, useEffect, useRef } from 'react';\nimport { processColor } from '../Colors';\nimport {\n AnimatedStyle,\n Context,\n NativeEvent,\n NestedObjectValues,\n WorkletFunction,\n AnimationObject,\n} from '../commonTypes';\nimport { makeRemote } from '../core';\nimport { isWeb, isJest } from '../PlatformChecker';\nimport { colorProps } from '../UpdateProps';\nimport WorkletEventHandler from '../WorkletEventHandler';\nimport { ContextWithDependencies, DependencyList } from './commonTypes';\n\ninterface Handler<T, TContext extends Context> extends WorkletFunction {\n (event: T, context: TContext): void;\n}\n\ninterface Handlers<T, TContext extends Context> {\n [key: string]: Handler<T, TContext> | undefined;\n}\n\nexport interface UseHandlerContext<TContext extends Context> {\n context: TContext;\n doDependenciesDiffer: boolean;\n useWeb: boolean;\n}\n\nexport function useEvent<T extends NativeEvent<T>>(\n handler: (event: T) => void,\n eventNames: string[] = [],\n rebuild = false\n): MutableRefObject<WorkletEventHandler<T> | null> {\n const initRef = useRef<WorkletEventHandler<T> | null>(null);\n if (initRef.current === null) {\n initRef.current = new WorkletEventHandler(handler, eventNames);\n } else if (rebuild) {\n initRef.current.updateWorklet(handler);\n }\n\n return initRef;\n}\n\nexport function useHandler<T, TContext extends Context>(\n handlers: Handlers<T, TContext>,\n dependencies?: DependencyList\n): UseHandlerContext<TContext> {\n const initRef = useRef<ContextWithDependencies<TContext> | null>(null);\n if (initRef.current === null) {\n initRef.current = {\n context: makeRemote<TContext>({} as TContext),\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(dependencies, handlers);\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\n// builds one big hash from multiple worklets' hashes\nexport function buildWorkletsHash(\n handlers: Record<string, WorkletFunction> | Array<WorkletFunction>\n): string {\n return Object.values(handlers).reduce(\n (acc: string, worklet: WorkletFunction) =>\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n acc + worklet.__workletHash!.toString(),\n ''\n );\n}\n\n// builds dependencies array for gesture handlers\nexport function buildDependencies(\n dependencies: DependencyList,\n handlers: Record<string, WorkletFunction | undefined>\n): Array<unknown> {\n const handlersList: WorkletFunction[] = Object.values(handlers).filter(\n (handler) => handler !== undefined\n ) as WorkletFunction[];\n if (!dependencies) {\n dependencies = handlersList.map((handler) => {\n return {\n workletHash: handler.__workletHash,\n closure: handler._closure,\n };\n });\n } else {\n dependencies.push(buildWorkletsHash(handlersList));\n }\n return dependencies;\n}\n\n// this is supposed to work as useEffect comparison\nexport function areDependenciesEqual(\n nextDeps: DependencyList,\n prevDeps: DependencyList\n): boolean {\n function is(x: number, y: number) {\n /* eslint-disable no-self-compare */\n return (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y);\n /* eslint-enable no-self-compare */\n }\n const objectIs: (nextDeps: unknown, prevDeps: unknown) => boolean =\n typeof Object.is === 'function' ? Object.is : is;\n\n function areHookInputsEqual(\n nextDeps: DependencyList,\n prevDeps: DependencyList\n ): boolean {\n if (!nextDeps || !prevDeps || prevDeps.length !== nextDeps.length) {\n return false;\n }\n for (let i = 0; i < prevDeps.length; ++i) {\n if (!objectIs(nextDeps[i], prevDeps[i])) {\n return false;\n }\n }\n return true;\n }\n\n return areHookInputsEqual(nextDeps, prevDeps);\n}\n\nexport function hasColorProps(updates: AnimatedStyle): boolean {\n const colorPropsSet = new Set(colorProps);\n for (const key in updates) {\n if (colorPropsSet.has(key)) {\n return true;\n }\n }\n return false;\n}\n\nexport function parseColors(updates: AnimatedStyle): void {\n 'worklet';\n for (const key in updates) {\n if (colorProps.indexOf(key) !== -1) {\n // value could be an animation in which case processColor will recognize it and will return undefined\n // -> in such a case we don't want to override style of that key\n const processedColor = processColor(updates[key]);\n if (processedColor !== undefined) {\n updates[key] = processedColor;\n }\n }\n }\n}\n\nexport function isAnimated(prop: NestedObjectValues<AnimationObject>): boolean {\n 'worklet';\n if (Array.isArray(prop)) {\n return prop.some(isAnimated);\n } else if (typeof prop === 'object') {\n if (prop.onFrame !== undefined) {\n return true;\n } else {\n return Object.values(prop).some(isAnimated);\n }\n }\n return false;\n}\n\nexport function shallowEqual(a: any, b: any) {\n 'worklet';\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n for (let i = 0; i < aKeys.length; i++) {\n if (a[aKeys[i]] !== b[aKeys[i]]) {\n return false;\n }\n }\n return true;\n}\n\nexport const validateAnimatedStyles = (styles: AnimatedStyle): void => {\n 'worklet';\n if (typeof styles !== 'object') {\n throw new Error(\n `useAnimatedStyle has to return an object, found ${typeof styles} instead`\n );\n } else if (Array.isArray(styles)) {\n throw new Error(\n 'useAnimatedStyle has to return an object and cannot return static styles combined with dynamic ones. Please do merging where a component receives props.'\n );\n }\n};\n"],"mappings":"AAAA,SAA2BA,SAA3B,EAAsCC,MAAtC,QAAoD,OAApD;AACA,SAASC,YAAT,QAA6B,WAA7B;AASA,SAASC,UAAT,QAA2B,SAA3B;AACA,SAASC,KAAT,EAAgBC,MAAhB,QAA8B,oBAA9B;AACA,SAASC,UAAT,QAA2B,gBAA3B;AACA,OAAOC,mBAAP,MAAgC,wBAAhC;AAiBA,OAAO,SAASC,QAAT,CACLC,OADK,EAI4C;EAAA,IAFjDC,UAEiD,uEAF1B,EAE0B;EAAA,IADjDC,OACiD,uEADvC,KACuC;EACjD,MAAMC,OAAO,GAAGX,MAAM,CAAgC,IAAhC,CAAtB;;EACA,IAAIW,OAAO,CAACC,OAAR,KAAoB,IAAxB,EAA8B;IAC5BD,OAAO,CAACC,OAAR,GAAkB,IAAIN,mBAAJ,CAAwBE,OAAxB,EAAiCC,UAAjC,CAAlB;EACD,CAFD,MAEO,IAAIC,OAAJ,EAAa;IAClBC,OAAO,CAACC,OAAR,CAAgBC,aAAhB,CAA8BL,OAA9B;EACD;;EAED,OAAOG,OAAP;AACD;AAED,OAAO,SAASG,UAAT,CACLC,QADK,EAELC,YAFK,EAGwB;EAC7B,MAAML,OAAO,GAAGX,MAAM,CAA2C,IAA3C,CAAtB;;E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,GAAG,CAAb,EAAgBA,CAAC,GAAGmB,KAAK,CAACpB,MAA1B,EAAkCC,CAAC,EAAnC,EAAuC;IACrC,IAAIiB,CAAC,CAACE,KAAK,CAACnB,CAAD,CAAN,CAAD,KAAgBkB,CAAC,CAACC,KAAK,CAACnB,CAAD,CAAN,CAArB,EAAiC;MAC/B,OAAO,KAAP;IACD;EACF;;EACD,OAAO,IAAP;AACD;AAED,OAAO,MAAMsB,sBAAsB,GAAIC,MAAD,IAAiC;EACrE;;EACA,IAAI,OAAOA,MAAP,KAAkB,QAAtB,EAAgC;IAC9B,MAAM,IAAIC,KAAJ,CACH,mDAAkD,OAAOD,MAAO,UAD7D,CAAN;EAGD,CAJD,MAIO,IAAIX,KAAK,CAACC,OAAN,CAAcU,MAAd,CAAJ,EAA2B;IAChC,MAAM,IAAIC,KAAJ,CACJ,0JADI,CAAN;EAGD;AACF,CAXM"}
1
+ {"version":3,"names":["useEffect","useRef","processColor","makeRemote","isWeb","isJest","colorProps","WorkletEventHandler","useEvent","handler","eventNames","arguments","length","undefined","rebuild","initRef","current","updateWorklet","useHandler","handlers","dependencies","context","savedDependencies","buildDependencies","doDependenciesDiffer","areDependenciesEqual","useWeb","buildWorkletsHash","Object","values","reduce","acc","worklet","__workletHash","toString","handlersList","filter","map","workletHash","closure","_closure","push","nextDeps","prevDeps","is","x","y","objectIs","areHookInputsEqual","i","hasColorProps","updates","colorPropsSet","Set","key","has","parseColors","indexOf","processedColor","isAnimated","prop","Array","isArray","some","onFrame","shallowEqual","a","b","aKeys","keys","bKeys","validateAnimatedStyles","styles","Error"],"sources":["utils.ts"],"sourcesContent":["import { MutableRefObject, useEffect, useRef } from 'react';\nimport { processColor } from '../Colors';\nimport {\n AnimatedStyle,\n Context,\n NativeEvent,\n NestedObjectValues,\n WorkletFunction,\n AnimationObject,\n} from '../commonTypes';\nimport { makeRemote } from '../core';\nimport { isWeb, isJest } from '../PlatformChecker';\nimport { colorProps } from '../UpdateProps';\nimport WorkletEventHandler from '../WorkletEventHandler';\nimport { ContextWithDependencies, DependencyList } from './commonTypes';\n\ninterface Handler<T, TContext extends Context> extends WorkletFunction {\n (event: T, context: TContext): void;\n}\n\ninterface Handlers<T, TContext extends Context> {\n [key: string]: Handler<T, TContext> | undefined;\n}\n\nexport interface UseHandlerContext<TContext extends Context> {\n context: TContext;\n doDependenciesDiffer: boolean;\n useWeb: boolean;\n}\n\nexport function useEvent<T extends NativeEvent<T>>(\n handler: (event: T) => void,\n eventNames: string[] = [],\n rebuild = false\n): MutableRefObject<WorkletEventHandler<T> | null> {\n const initRef = useRef<WorkletEventHandler<T> | null>(null);\n if (initRef.current === null) {\n initRef.current = new WorkletEventHandler(handler, eventNames);\n } else if (rebuild) {\n initRef.current.updateWorklet(handler);\n }\n\n return initRef;\n}\n\nexport function useHandler<T, TContext extends Context>(\n handlers: Handlers<T, TContext>,\n dependencies?: DependencyList\n): UseHandlerContext<TContext> {\n const initRef = useRef<ContextWithDependencies<TContext> | null>(null);\n if (initRef.current === null) {\n initRef.current = {\n context: makeRemote<TContext>({} as TContext),\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(dependencies, handlers);\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\n// builds one big hash from multiple worklets' hashes\nexport function buildWorkletsHash(\n handlers: Record<string, WorkletFunction> | Array<WorkletFunction>\n): string {\n return Object.values(handlers).reduce(\n (acc: string, worklet: WorkletFunction) =>\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n acc + worklet.__workletHash!.toString(),\n ''\n );\n}\n\n// builds dependencies array for gesture handlers\nexport function buildDependencies(\n dependencies: DependencyList,\n handlers: Record<string, WorkletFunction | undefined>\n): Array<unknown> {\n const handlersList: WorkletFunction[] = Object.values(handlers).filter(\n (handler) => handler !== undefined\n ) as WorkletFunction[];\n if (!dependencies) {\n dependencies = handlersList.map((handler) => {\n return {\n workletHash: handler.__workletHash,\n closure: handler._closure,\n };\n });\n } else {\n dependencies.push(buildWorkletsHash(handlersList));\n }\n return dependencies;\n}\n\n// this is supposed to work as useEffect comparison\nexport function areDependenciesEqual(\n nextDeps: DependencyList,\n prevDeps: DependencyList\n): boolean {\n function is(x: number, y: number) {\n /* eslint-disable no-self-compare */\n return (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y);\n /* eslint-enable no-self-compare */\n }\n const objectIs: (nextDeps: unknown, prevDeps: unknown) => boolean =\n typeof Object.is === 'function' ? Object.is : is;\n\n function areHookInputsEqual(\n nextDeps: DependencyList,\n prevDeps: DependencyList\n ): boolean {\n if (!nextDeps || !prevDeps || prevDeps.length !== nextDeps.length) {\n return false;\n }\n for (let i = 0; i < prevDeps.length; ++i) {\n if (!objectIs(nextDeps[i], prevDeps[i])) {\n return false;\n }\n }\n return true;\n }\n\n return areHookInputsEqual(nextDeps, prevDeps);\n}\n\nexport function hasColorProps(updates: AnimatedStyle): boolean {\n const colorPropsSet = new Set(colorProps);\n for (const key in updates) {\n if (colorPropsSet.has(key)) {\n return true;\n }\n }\n return false;\n}\n\nexport function parseColors(updates: AnimatedStyle): void {\n 'worklet';\n for (const key in updates) {\n if (colorProps.indexOf(key) !== -1) {\n // value could be an animation in which case processColor will recognize it and will return undefined\n // -> in such a case we don't want to override style of that key\n const processedColor = processColor(updates[key]);\n if (processedColor !== undefined) {\n updates[key] = processedColor;\n }\n }\n }\n}\n\nexport function isAnimated(prop: NestedObjectValues<AnimationObject>): boolean {\n 'worklet';\n if (Array.isArray(prop)) {\n return prop.some(isAnimated);\n } else if (typeof prop === 'object') {\n if (prop.onFrame !== undefined) {\n return true;\n } else {\n return Object.values(prop).some(isAnimated);\n }\n }\n return false;\n}\n\nexport function shallowEqual(a: any, b: any) {\n 'worklet';\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n for (let i = 0; i < aKeys.length; i++) {\n if (a[aKeys[i]] !== b[aKeys[i]]) {\n return false;\n }\n }\n return true;\n}\n\nexport const validateAnimatedStyles = (styles: AnimatedStyle): void => {\n 'worklet';\n if (typeof styles !== 'object') {\n throw new Error(\n `useAnimatedStyle has to return an object, found ${typeof styles} instead`\n );\n } else if (Array.isArray(styles)) {\n throw new Error(\n 'useAnimatedStyle has to return an object and cannot return static styles combined with dynamic ones. Please do merging where a component receives props.'\n );\n }\n};\n"],"mappings":"AAAA,SAA2BA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAC3D,SAASC,YAAY,QAAQ,WAAW;AASxC,SAASC,UAAU,QAAQ,SAAS;AACpC,SAASC,KAAK,EAAEC,MAAM,QAAQ,oBAAoB;AAClD,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,OAAOC,mBAAmB,MAAM,wBAAwB;AAiBxD,OAAO,SAASC,QAAQA,CACtBC,OAA2B,EAGsB;EAAA,IAFjDC,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,GAAGd,MAAM,CAAgC,IAAI,CAAC;EAC3D,IAAIc,OAAO,CAACC,OAAO,KAAK,IAAI,EAAE;IAC5BD,OAAO,CAACC,OAAO,GAAG,IAAIT,mBAAmB,CAACE,OAAO,EAAEC,UAAU,CAAC;EAChE,CAAC,MAAM,IAAII,OAAO,EAAE;IAClBC,OAAO,CAACC,OAAO,CAACC,aAAa,CAACR,OAAO,CAAC;EACxC;EAEA,OAAOM,OAAO;AAChB;AAEA,OAAO,SAASG,UAAUA,CACxBC,QAA+B,EAC/BC,YAA6B,EACA;EAC7B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,MAAM,EAAE;IACjC,OAAO,KAAK;EACd;EACA,KAAK,IAAIqC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGmB,KAAK,CAACxD,MAAM,EAAEqC,CAAC,EAAE,EAAE;IACrC,IAAIiB,CAAC,CAACE,KAAK,CAACnB,CAAC,CAAC,CAAC,KAAKkB,CAAC,CAACC,KAAK,CAACnB,CAAC,CAAC,CAAC,EAAE;MAC/B,OAAO,KAAK;IACd;EACF;EACA,OAAO,IAAI;AACb;AAEA,OAAO,MAAMsB,sBAAsB,GAAIC,MAAqB,IAAW;EACrE,SAAS;;EACT,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;IAC9B,MAAM,IAAIC,KAAK,CACZ,mDAAkD,OAAOD,MAAO,UAAS,CAC3E;EACH,CAAC,MAAM,IAAIX,KAAK,CAACC,OAAO,CAACU,MAAM,CAAC,EAAE;IAChC,MAAM,IAAIC,KAAK,CACb,0JAA0J,CAC3J;EACH;AACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './core';\nexport * from './hook';\nexport * from './animation';\nexport * from './interpolation';\nexport * from './interpolateColor';\nexport * from './Easing';\nexport * from './NativeMethods';\nexport * from './Colors';\nexport * from './PropAdapters';\nexport * from './layoutReanimation';\nexport * from './utils';\nexport * from './commonTypes';\nexport * from './pluginUtils';\n"],"mappings":"AAAA,cAAc,QAAd;AACA,cAAc,QAAd;AACA,cAAc,aAAd;AACA,cAAc,iBAAd;AACA,cAAc,oBAAd;AACA,cAAc,UAAd;AACA,cAAc,iBAAd;AACA,cAAc,UAAd;AACA,cAAc,gBAAd;AACA,cAAc,qBAAd;AACA,cAAc,SAAd;AACA,cAAc,eAAd;AACA,cAAc,eAAd"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './core';\nexport * from './hook';\nexport * from './animation';\nexport * from './interpolation';\nexport * from './interpolateColor';\nexport * from './Easing';\nexport * from './NativeMethods';\nexport * from './Colors';\nexport * from './PropAdapters';\nexport * from './layoutReanimation';\nexport * from './utils';\nexport * from './commonTypes';\nexport * from './pluginUtils';\n"],"mappings":"AAAA,cAAc,QAAQ;AACtB,cAAc,QAAQ;AACtB,cAAc,aAAa;AAC3B,cAAc,iBAAiB;AAC/B,cAAc,oBAAoB;AAClC,cAAc,UAAU;AACxB,cAAc,iBAAiB;AAC/B,cAAc,UAAU;AACxB,cAAc,gBAAgB;AAC9B,cAAc,qBAAqB;AACnC,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,eAAe"}
@@ -1,46 +1,40 @@
1
1
  import { reportFatalErrorOnJS } from './errors';
2
2
  import NativeReanimatedModule from './NativeReanimated';
3
3
  import { isJest } from './PlatformChecker';
4
- import { runOnJS, setupSetImmediate, flushImmediates, runOnUIImmediately } from './threads'; // callGuard is only used with debug builds
4
+ import { runOnJS, setupMicrotasks, callMicrotasks, runOnUIImmediately } from './threads';
5
5
 
6
+ // callGuard is only used with debug builds
6
7
  function callGuardDEV(fn) {
7
8
  'worklet';
8
9
 
9
10
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
10
11
  args[_key - 1] = arguments[_key];
11
12
  }
12
-
13
13
  try {
14
14
  fn(...args);
15
15
  } catch (e) {
16
- if (global.ErrorUtils) {
17
- global.ErrorUtils.reportFatalError(e);
16
+ if (global.__ErrorUtils) {
17
+ global.__ErrorUtils.reportFatalError(e);
18
18
  } else {
19
19
  throw e;
20
20
  }
21
21
  }
22
22
  }
23
-
24
23
  function valueUnpacker(objectToUnpack, category) {
25
24
  'worklet';
26
25
 
27
26
  let workletsCache = global.__workletsCache;
28
27
  let handleCache = global.__handleCache;
29
-
30
28
  if (workletsCache === undefined) {
31
29
  // init
32
30
  workletsCache = global.__workletsCache = new Map();
33
31
  handleCache = global.__handleCache = new WeakMap();
34
32
  }
35
-
36
33
  const workletHash = objectToUnpack.__workletHash;
37
-
38
34
  if (workletHash !== undefined) {
39
35
  let workletFun = workletsCache.get(workletHash);
40
-
41
36
  if (workletFun === undefined) {
42
37
  const initData = objectToUnpack.__initData;
43
-
44
38
  if (global.evalWithSourceMap) {
45
39
  // if the runtime (hermes only for now) supports loading source maps
46
40
  // we want to use the proper filename for the location as it guarantees
@@ -58,21 +52,17 @@ function valueUnpacker(objectToUnpack, category) {
58
52
  // eslint-disable-next-line no-eval
59
53
  workletFun = eval('(' + initData.code + '\n)');
60
54
  }
61
-
62
55
  workletsCache.set(workletHash, workletFun);
63
56
  }
64
-
65
57
  const functionInstance = workletFun.bind(objectToUnpack);
66
58
  objectToUnpack._recur = functionInstance;
67
59
  return functionInstance;
68
60
  } else if (objectToUnpack.__init) {
69
61
  let value = handleCache.get(objectToUnpack);
70
-
71
62
  if (value === undefined) {
72
63
  value = objectToUnpack.__init();
73
64
  handleCache.set(objectToUnpack, value);
74
65
  }
75
-
76
66
  return value;
77
67
  } else if (category === 'RemoteFunction') {
78
68
  const fun = () => {
@@ -82,32 +72,28 @@ Possible solutions are:
82
72
  a) If you want to synchronously execute this method, mark it as a worklet
83
73
  b) If you want to execute this function on the JS thread, wrap it using \`runOnJS\``);
84
74
  };
85
-
86
75
  fun.__remoteFunction = objectToUnpack;
87
76
  return fun;
88
77
  } else {
89
78
  throw new Error('data type not recognized by unpack method');
90
79
  }
91
80
  }
92
-
93
81
  function setupRequestAnimationFrame() {
94
- 'worklet'; // Jest mocks requestAnimationFrame API and it does not like if that mock gets overridden
95
- // so we avoid doing requestAnimationFrame batching in Jest environment.
82
+ 'worklet';
96
83
 
84
+ // Jest mocks requestAnimationFrame API and it does not like if that mock gets overridden
85
+ // so we avoid doing requestAnimationFrame batching in Jest environment.
97
86
  const nativeRequestAnimationFrame = global.requestAnimationFrame;
98
87
  let animationFrameCallbacks = [];
99
88
  let lastNativeAnimationFrameTimestamp = -1;
100
-
101
89
  global.__flushAnimationFrame = frameTimestamp => {
102
90
  const currentCallbacks = animationFrameCallbacks;
103
91
  animationFrameCallbacks = [];
104
92
  currentCallbacks.forEach(f => f(frameTimestamp));
105
- flushImmediates();
93
+ callMicrotasks();
106
94
  };
107
-
108
95
  global.requestAnimationFrame = callback => {
109
96
  animationFrameCallbacks.push(callback);
110
-
111
97
  if (animationFrameCallbacks.length === 1) {
112
98
  // We schedule native requestAnimationFrame only when the first callback
113
99
  // is added and then use it to execute all the enqueued callbacks. Once
@@ -117,28 +103,22 @@ function setupRequestAnimationFrame() {
117
103
  // Make sure we only execute the callbacks once for a given frame
118
104
  return;
119
105
  }
120
-
121
106
  lastNativeAnimationFrameTimestamp = timestamp;
122
107
  global.__frameTimestamp = timestamp;
123
-
124
108
  global.__flushAnimationFrame(timestamp);
125
-
126
109
  global.__frameTimestamp = undefined;
127
110
  });
128
- } // Reanimated currently does not support cancelling callbacks requested with
111
+ }
112
+ // Reanimated currently does not support cancelling callbacks requested with
129
113
  // requestAnimationFrame. We return -1 as identifier which isn't in line
130
114
  // with the spec but it should give users better clue in case they actually
131
115
  // attempt to store the value returned from rAF and use it for cancelling.
132
-
133
-
134
116
  return -1;
135
117
  };
136
118
  }
137
-
138
119
  export function initializeUIRuntime() {
139
120
  NativeReanimatedModule.installCoreFunctions(callGuardDEV, valueUnpacker);
140
121
  const IS_JEST = isJest();
141
-
142
122
  if (IS_JEST) {
143
123
  // requestAnimationFrame react-native jest's setup is incorrect as it polyfills
144
124
  // the method directly using setTimeout, therefore the callback doesn't get the
@@ -151,30 +131,36 @@ export function initializeUIRuntime() {
151
131
  };
152
132
  }
153
133
 
154
- const capturableConsole = console;
134
+ // We really have to create a copy of console here. Function runOnJS we use on elements inside
135
+ // this object makes it not configurable
136
+ const capturableConsole = {
137
+ ...console
138
+ };
155
139
  runOnUIImmediately(() => {
156
- 'worklet'; // setup error handler
140
+ 'worklet';
157
141
 
158
- global.ErrorUtils = {
142
+ // setup error handler
143
+ global.__ErrorUtils = {
159
144
  reportFatalError: error => {
160
145
  runOnJS(reportFatalErrorOnJS)({
161
146
  message: error.message,
162
147
  stack: error.stack
163
148
  });
164
149
  }
165
- }; // setup console
166
- // @ts-ignore TypeScript doesn't like that there are missing methods in console object, but we don't provide all the methods for the UI runtime console version
150
+ };
167
151
 
152
+ // setup console
153
+ // @ts-ignore TypeScript doesn't like that there are missing methods in console object, but we don't provide all the methods for the UI runtime console version
168
154
  global.console = {
155
+ assert: runOnJS(capturableConsole.assert),
169
156
  debug: runOnJS(capturableConsole.debug),
170
157
  log: runOnJS(capturableConsole.log),
171
158
  warn: runOnJS(capturableConsole.warn),
172
159
  error: runOnJS(capturableConsole.error),
173
160
  info: runOnJS(capturableConsole.info)
174
161
  };
175
-
176
162
  if (!IS_JEST) {
177
- setupSetImmediate();
163
+ setupMicrotasks();
178
164
  setupRequestAnimationFrame();
179
165
  }
180
166
  })();
@@ -1 +1 @@
1
- {"version":3,"names":["reportFatalErrorOnJS","NativeReanimatedModule","isJest","runOnJS","setupSetImmediate","flushImmediates","runOnUIImmediately","callGuardDEV","fn","args","e","global","ErrorUtils","reportFatalError","valueUnpacker","objectToUnpack","category","workletsCache","__workletsCache","handleCache","__handleCache","undefined","Map","WeakMap","workletHash","__workletHash","workletFun","get","initData","__initData","evalWithSourceMap","code","location","sourceMap","evalWithSourceUrl","eval","set","functionInstance","bind","_recur","__init","value","fun","Error","__remoteFunction","setupRequestAnimationFrame","nativeRequestAnimationFrame","requestAnimationFrame","animationFrameCallbacks","lastNativeAnimationFrameTimestamp","__flushAnimationFrame","frameTimestamp","currentCallbacks","forEach","f","callback","push","length","timestamp","__frameTimestamp","initializeUIRuntime","installCoreFunctions","IS_JEST","setTimeout","performance","now","capturableConsole","console","error","message","stack","debug","log","warn","info"],"sources":["initializers.ts"],"sourcesContent":["import { reportFatalErrorOnJS } from './errors';\nimport NativeReanimatedModule from './NativeReanimated';\nimport { isJest } from './PlatformChecker';\nimport {\n runOnJS,\n setupSetImmediate,\n flushImmediates,\n runOnUIImmediately,\n} from './threads';\n\n// callGuard is only used with debug builds\nfunction callGuardDEV<T extends Array<any>, U>(\n fn: (...args: T) => U,\n ...args: T\n): void {\n 'worklet';\n try {\n fn(...args);\n } catch (e) {\n if (global.ErrorUtils) {\n global.ErrorUtils.reportFatalError(e as Error);\n } else {\n throw e;\n }\n }\n}\n\nfunction valueUnpacker(objectToUnpack: any, category?: string): any {\n 'worklet';\n let workletsCache = global.__workletsCache;\n let handleCache = global.__handleCache;\n if (workletsCache === undefined) {\n // init\n workletsCache = global.__workletsCache = new Map();\n handleCache = global.__handleCache = new WeakMap();\n }\n const workletHash = objectToUnpack.__workletHash;\n if (workletHash !== undefined) {\n let workletFun = workletsCache.get(workletHash);\n if (workletFun === undefined) {\n const initData = objectToUnpack.__initData;\n if (global.evalWithSourceMap) {\n // if the runtime (hermes only for now) supports loading source maps\n // we want to use the proper filename for the location as it guarantees\n // that debugger understands and loads the source code of the file where\n // the worklet is defined.\n workletFun = global.evalWithSourceMap(\n '(' + initData.code + '\\n)',\n initData.location,\n initData.sourceMap\n ) as (...args: any[]) => any;\n } else if (global.evalWithSourceUrl) {\n // if the runtime doesn't support loading source maps, in dev mode we\n // can pass source url when evaluating the worklet. Now, instead of using\n // the actual file location we use worklet hash, as it the allows us to\n // properly symbolicate traces (see errors.ts for details)\n workletFun = global.evalWithSourceUrl(\n '(' + initData.code + '\\n)',\n `worklet_${workletHash}`\n ) as (...args: any[]) => any;\n } else {\n // in release we use the regular eval to save on JSI calls\n // eslint-disable-next-line no-eval\n workletFun = eval('(' + initData.code + '\\n)') as (\n ...args: any[]\n ) => any;\n }\n workletsCache.set(workletHash, workletFun);\n }\n const functionInstance = workletFun.bind(objectToUnpack);\n objectToUnpack._recur = functionInstance;\n return functionInstance;\n } else if (objectToUnpack.__init) {\n let value = handleCache!.get(objectToUnpack);\n if (value === undefined) {\n value = objectToUnpack.__init();\n handleCache!.set(objectToUnpack, value);\n }\n return value;\n } else if (category === 'RemoteFunction') {\n const fun = () => {\n throw new Error(`Tried to synchronously call a non-worklet function on the UI thread.\n\nPossible solutions are:\n a) If you want to synchronously execute this method, mark it as a worklet\n b) If you want to execute this function on the JS thread, wrap it using \\`runOnJS\\``);\n };\n fun.__remoteFunction = objectToUnpack;\n return fun;\n } else {\n throw new Error('data type not recognized by unpack method');\n }\n}\n\nfunction setupRequestAnimationFrame() {\n 'worklet';\n\n // Jest mocks requestAnimationFrame API and it does not like if that mock gets overridden\n // so we avoid doing requestAnimationFrame batching in Jest environment.\n const nativeRequestAnimationFrame = global.requestAnimationFrame;\n\n let animationFrameCallbacks: Array<(timestamp: number) => void> = [];\n let lastNativeAnimationFrameTimestamp = -1;\n\n global.__flushAnimationFrame = (frameTimestamp: number) => {\n const currentCallbacks = animationFrameCallbacks;\n animationFrameCallbacks = [];\n currentCallbacks.forEach((f) => f(frameTimestamp));\n flushImmediates();\n };\n\n global.requestAnimationFrame = (\n callback: (timestamp: number) => void\n ): number => {\n animationFrameCallbacks.push(callback);\n if (animationFrameCallbacks.length === 1) {\n // We schedule native requestAnimationFrame only when the first callback\n // is added and then use it to execute all the enqueued callbacks. Once\n // the callbacks are run, we clear the array.\n nativeRequestAnimationFrame((timestamp) => {\n if (lastNativeAnimationFrameTimestamp >= timestamp) {\n // Make sure we only execute the callbacks once for a given frame\n return;\n }\n lastNativeAnimationFrameTimestamp = timestamp;\n global.__frameTimestamp = timestamp;\n global.__flushAnimationFrame(timestamp);\n global.__frameTimestamp = undefined;\n });\n }\n // Reanimated currently does not support cancelling callbacks requested with\n // requestAnimationFrame. We return -1 as identifier which isn't in line\n // with the spec but it should give users better clue in case they actually\n // attempt to store the value returned from rAF and use it for cancelling.\n return -1;\n };\n}\n\nexport function initializeUIRuntime() {\n NativeReanimatedModule.installCoreFunctions(callGuardDEV, valueUnpacker);\n\n const IS_JEST = isJest();\n\n if (IS_JEST) {\n // requestAnimationFrame react-native jest's setup is incorrect as it polyfills\n // the method directly using setTimeout, therefore the callback doesn't get the\n // expected timestamp as the only argument: https://github.com/facebook/react-native/blob/main/jest/setup.js#L28\n // We override this setup here to make sure that callbacks get the proper timestamps\n // when executed. For non-jest environments we define requestAnimationFrame in setupRequestAnimationFrame\n // @ts-ignore TypeScript uses Node definition for rAF, setTimeout, etc which returns a Timeout object rather than a number\n global.requestAnimationFrame = (callback: (timestamp: number) => void) => {\n return setTimeout(() => callback(performance.now()), 0);\n };\n }\n\n const capturableConsole = console;\n runOnUIImmediately(() => {\n 'worklet';\n // setup error handler\n global.ErrorUtils = {\n reportFatalError: (error: Error) => {\n runOnJS(reportFatalErrorOnJS)({\n message: error.message,\n stack: error.stack,\n });\n },\n };\n\n // setup console\n // @ts-ignore TypeScript doesn't like that there are missing methods in console object, but we don't provide all the methods for the UI runtime console version\n global.console = {\n debug: runOnJS(capturableConsole.debug),\n log: runOnJS(capturableConsole.log),\n warn: runOnJS(capturableConsole.warn),\n error: runOnJS(capturableConsole.error),\n info: runOnJS(capturableConsole.info),\n };\n\n if (!IS_JEST) {\n setupSetImmediate();\n setupRequestAnimationFrame();\n }\n })();\n}\n"],"mappings":"AAAA,SAASA,oBAAT,QAAqC,UAArC;AACA,OAAOC,sBAAP,MAAmC,oBAAnC;AACA,SAASC,MAAT,QAAuB,mBAAvB;AACA,SACEC,OADF,EAEEC,iBAFF,EAGEC,eAHF,EAIEC,kBAJF,QAKO,WALP,C,CAOA;;AACA,SAASC,YAAT,CACEC,EADF,EAGQ;EACN;;EADM,kCADHC,IACG;IADHA,IACG;EAAA;;EAEN,IAAI;IACFD,EAAE,CAAC,GAAGC,IAAJ,CAAF;EACD,CAFD,CAEE,OAAOC,CAAP,EAAU;IACV,IAAIC,MAAM,CAACC,UAAX,EAAuB;MACrBD,MAAM,CAACC,UAAP,CAAkBC,gBAAlB,CAAmCH,CAAnC;IACD,CAFD,MAEO;MACL,MAAMA,CAAN;IACD;EACF;AACF;;AAED,SAASI,aAAT,CAAuBC,cAAvB,EAA4CC,QAA5C,EAAoE;EAClE;;EACA,IAAIC,aAAa,GAAGN,MAAM,CAACO,eAA3B;EACA,IAAIC,WAAW,GA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E,CAAjB;;IAQA,IAAI,CAACZ,OAAL,EAAc;MACZ1D,iBAAiB;MACjByC,0BAA0B;IAC3B;EACF,CA1BiB,CAAlB;AA2BD"}
1
+ {"version":3,"names":["reportFatalErrorOnJS","NativeReanimatedModule","isJest","runOnJS","setupMicrotasks","callMicrotasks","runOnUIImmediately","callGuardDEV","fn","_len","arguments","length","args","Array","_key","e","global","__ErrorUtils","reportFatalError","valueUnpacker","objectToUnpack","category","workletsCache","__workletsCache","handleCache","__handleCache","undefined","Map","WeakMap","workletHash","__workletHash","workletFun","get","initData","__initData","evalWithSourceMap","code","location","sourceMap","evalWithSourceUrl","eval","set","functionInstance","bind","_recur","__init","value","fun","Error","__remoteFunction","setupRequestAnimationFrame","nativeRequestAnimationFrame","requestAnimationFrame","animationFrameCallbacks","lastNativeAnimationFrameTimestamp","__flushAnimationFrame","frameTimestamp","currentCallbacks","forEach","f","callback","push","timestamp","__frameTimestamp","initializeUIRuntime","installCoreFunctions","IS_JEST","setTimeout","performance","now","capturableConsole","console","error","message","stack","assert","debug","log","warn","info"],"sources":["initializers.ts"],"sourcesContent":["import { reportFatalErrorOnJS } from './errors';\nimport NativeReanimatedModule from './NativeReanimated';\nimport { isJest } from './PlatformChecker';\nimport {\n runOnJS,\n setupMicrotasks,\n callMicrotasks,\n runOnUIImmediately,\n} from './threads';\n\n// callGuard is only used with debug builds\nfunction callGuardDEV<T extends Array<any>, U>(\n fn: (...args: T) => U,\n ...args: T\n): void {\n 'worklet';\n try {\n fn(...args);\n } catch (e) {\n if (global.__ErrorUtils) {\n global.__ErrorUtils.reportFatalError(e as Error);\n } else {\n throw e;\n }\n }\n}\n\nfunction valueUnpacker(objectToUnpack: any, category?: string): any {\n 'worklet';\n let workletsCache = global.__workletsCache;\n let handleCache = global.__handleCache;\n if (workletsCache === undefined) {\n // init\n workletsCache = global.__workletsCache = new Map();\n handleCache = global.__handleCache = new WeakMap();\n }\n const workletHash = objectToUnpack.__workletHash;\n if (workletHash !== undefined) {\n let workletFun = workletsCache.get(workletHash);\n if (workletFun === undefined) {\n const initData = objectToUnpack.__initData;\n if (global.evalWithSourceMap) {\n // if the runtime (hermes only for now) supports loading source maps\n // we want to use the proper filename for the location as it guarantees\n // that debugger understands and loads the source code of the file where\n // the worklet is defined.\n workletFun = global.evalWithSourceMap(\n '(' + initData.code + '\\n)',\n initData.location,\n initData.sourceMap\n ) as (...args: any[]) => any;\n } else if (global.evalWithSourceUrl) {\n // if the runtime doesn't support loading source maps, in dev mode we\n // can pass source url when evaluating the worklet. Now, instead of using\n // the actual file location we use worklet hash, as it the allows us to\n // properly symbolicate traces (see errors.ts for details)\n workletFun = global.evalWithSourceUrl(\n '(' + initData.code + '\\n)',\n `worklet_${workletHash}`\n ) as (...args: any[]) => any;\n } else {\n // in release we use the regular eval to save on JSI calls\n // eslint-disable-next-line no-eval\n workletFun = eval('(' + initData.code + '\\n)') as (\n ...args: any[]\n ) => any;\n }\n workletsCache.set(workletHash, workletFun);\n }\n const functionInstance = workletFun.bind(objectToUnpack);\n objectToUnpack._recur = functionInstance;\n return functionInstance;\n } else if (objectToUnpack.__init) {\n let value = handleCache!.get(objectToUnpack);\n if (value === undefined) {\n value = objectToUnpack.__init();\n handleCache!.set(objectToUnpack, value);\n }\n return value;\n } else if (category === 'RemoteFunction') {\n const fun = () => {\n throw new Error(`Tried to synchronously call a non-worklet function on the UI thread.\n\nPossible solutions are:\n a) If you want to synchronously execute this method, mark it as a worklet\n b) If you want to execute this function on the JS thread, wrap it using \\`runOnJS\\``);\n };\n fun.__remoteFunction = objectToUnpack;\n return fun;\n } else {\n throw new Error('data type not recognized by unpack method');\n }\n}\n\nfunction setupRequestAnimationFrame() {\n 'worklet';\n\n // Jest mocks requestAnimationFrame API and it does not like if that mock gets overridden\n // so we avoid doing requestAnimationFrame batching in Jest environment.\n const nativeRequestAnimationFrame = global.requestAnimationFrame;\n\n let animationFrameCallbacks: Array<(timestamp: number) => void> = [];\n let lastNativeAnimationFrameTimestamp = -1;\n\n global.__flushAnimationFrame = (frameTimestamp: number) => {\n const currentCallbacks = animationFrameCallbacks;\n animationFrameCallbacks = [];\n currentCallbacks.forEach((f) => f(frameTimestamp));\n callMicrotasks();\n };\n\n global.requestAnimationFrame = (\n callback: (timestamp: number) => void\n ): number => {\n animationFrameCallbacks.push(callback);\n if (animationFrameCallbacks.length === 1) {\n // We schedule native requestAnimationFrame only when the first callback\n // is added and then use it to execute all the enqueued callbacks. Once\n // the callbacks are run, we clear the array.\n nativeRequestAnimationFrame((timestamp) => {\n if (lastNativeAnimationFrameTimestamp >= timestamp) {\n // Make sure we only execute the callbacks once for a given frame\n return;\n }\n lastNativeAnimationFrameTimestamp = timestamp;\n global.__frameTimestamp = timestamp;\n global.__flushAnimationFrame(timestamp);\n global.__frameTimestamp = undefined;\n });\n }\n // Reanimated currently does not support cancelling callbacks requested with\n // requestAnimationFrame. We return -1 as identifier which isn't in line\n // with the spec but it should give users better clue in case they actually\n // attempt to store the value returned from rAF and use it for cancelling.\n return -1;\n };\n}\n\nexport function initializeUIRuntime() {\n NativeReanimatedModule.installCoreFunctions(callGuardDEV, valueUnpacker);\n\n const IS_JEST = isJest();\n\n if (IS_JEST) {\n // requestAnimationFrame react-native jest's setup is incorrect as it polyfills\n // the method directly using setTimeout, therefore the callback doesn't get the\n // expected timestamp as the only argument: https://github.com/facebook/react-native/blob/main/jest/setup.js#L28\n // We override this setup here to make sure that callbacks get the proper timestamps\n // when executed. For non-jest environments we define requestAnimationFrame in setupRequestAnimationFrame\n // @ts-ignore TypeScript uses Node definition for rAF, setTimeout, etc which returns a Timeout object rather than a number\n global.requestAnimationFrame = (callback: (timestamp: number) => void) => {\n return setTimeout(() => callback(performance.now()), 0);\n };\n }\n\n // We really have to create a copy of console here. Function runOnJS we use on elements inside\n // this object makes it not configurable\n const capturableConsole = { ...console };\n runOnUIImmediately(() => {\n 'worklet';\n // setup error handler\n global.__ErrorUtils = {\n reportFatalError: (error: Error) => {\n runOnJS(reportFatalErrorOnJS)({\n message: error.message,\n stack: error.stack,\n });\n },\n };\n\n // setup console\n // @ts-ignore TypeScript doesn't like that there are missing methods in console object, but we don't provide all the methods for the UI runtime console version\n global.console = {\n assert: runOnJS(capturableConsole.assert),\n debug: runOnJS(capturableConsole.debug),\n log: runOnJS(capturableConsole.log),\n warn: runOnJS(capturableConsole.warn),\n error: runOnJS(capturableConsole.error),\n info: runOnJS(capturableConsole.info),\n };\n\n if (!IS_JEST) {\n setupMicrotasks();\n setupRequestAnimationFrame();\n }\n })();\n}\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,UAAU;AAC/C,OAAOC,sBAAsB,MAAM,oBAAoB;AACvD,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SACEC,OAAO,EACPC,eAAe,EACfC,cAAc,EACdC,kBAAkB,QACb,WAAW;;AAElB;AACA,SAASC,YAAYA,CACnBC,EAAqB,EAEf;EACN,SAAS;;EAAC,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAFPC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,OAAAA,IAAA,WAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAAJF,IAAI,CAAAE,IAAA,QAAAJ,SAAA,CAAAI,IAAA;EAAA;EAGP,IAAI;IACFN,EAAE,CAAC,GAAGI,IAAI,CAAC;EACb,CAAC,CAAC,OAAOG,CAAC,EAAE;IACV,IAAIC,MAAM,CAACC,YAAY,EAAE;MACvBD,MAAM,CAACC,YAAY,CAACC,gBAAgB,CAACH,CAAC,CAAU;IAClD,CAAC,MAAM;MACL,MAAMA,CAAC;IACT;EACF;AACF;AAEA,SAASI,aAAaA,CAACC,cAAmB,EAAEC,QAAiB,EAAO;EAClE,SAAS;;EACT,IAAIC,aAAa,GAAGN,MAAM,CAACO,eAAe;EAC1C,IAAIC,WAAW,GAAGR,MAAM,CAACS,aAAa;EACtC,IAAIH,aAAa,KAAKI,SAAS,EAAE;IAC/B;IACAJ,aAAa,GAAGN,MAAM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