react-native-reanimated 3.0.0-rc.8 → 3.0.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 (339) hide show
  1. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +30 -12
  2. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.h +2 -0
  3. package/Common/cpp/Fabric/FabricUtils.cpp +3 -107
  4. package/Common/cpp/Fabric/FabricUtils.h +3 -24
  5. package/Common/cpp/Fabric/ReanimatedUIManagerBinding.cpp +54 -37
  6. package/Common/cpp/LayoutAnimations/LayoutAnimationType.h +8 -0
  7. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +81 -26
  8. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +20 -3
  9. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +122 -121
  10. package/Common/cpp/NativeModules/NativeReanimatedModule.h +21 -14
  11. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +15 -7
  12. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +8 -4
  13. package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +50 -1
  14. package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +10 -1
  15. package/Common/cpp/ReanimatedRuntime/ReanimatedRuntime.cpp +5 -1
  16. package/Common/cpp/Registries/EventHandlerRegistry.cpp +8 -34
  17. package/Common/cpp/Registries/EventHandlerRegistry.h +7 -13
  18. package/Common/cpp/SharedItems/Shareables.cpp +11 -63
  19. package/Common/cpp/SharedItems/Shareables.h +113 -93
  20. package/Common/cpp/Tools/CollectionUtils.h +14 -0
  21. package/Common/cpp/Tools/JsiUtils.cpp +26 -0
  22. package/Common/cpp/Tools/JsiUtils.h +176 -0
  23. package/Common/cpp/Tools/PlatformDepMethodsHolder.h +5 -5
  24. package/Common/cpp/Tools/ReanimatedVersion.cpp +17 -0
  25. package/Common/cpp/Tools/ReanimatedVersion.h +11 -0
  26. package/Common/cpp/Tools/RuntimeDecorator.cpp +67 -247
  27. package/Common/cpp/Tools/RuntimeDecorator.h +2 -3
  28. package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -2
  29. package/Common/cpp/Tools/WorkletEventHandler.h +14 -6
  30. package/RNReanimated.podspec +2 -1
  31. package/android/CMakeLists.txt +188 -181
  32. package/android/build.gradle +362 -311
  33. package/android/proguard-rules.pro +2 -0
  34. package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +63 -295
  35. package/android/src/main/cpp/LayoutAnimations.cpp +35 -5
  36. package/android/src/main/cpp/LayoutAnimations.h +23 -6
  37. package/android/src/main/cpp/NativeProxy.cpp +143 -98
  38. package/android/src/main/cpp/NativeProxy.h +22 -28
  39. package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +5 -4
  40. package/android/src/main/java/com/swmansion/reanimated/Utils.java +7 -1
  41. package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +10 -3
  42. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +218 -35
  43. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +43 -17
  44. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +6 -2
  45. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedElement.java +19 -0
  46. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +610 -0
  47. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +93 -23
  48. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/AnimationFrameCallback.java +19 -0
  49. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/EventHandler.java +35 -0
  50. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/KeyboardEventDataUpdater.java +16 -0
  51. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +206 -0
  52. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/SensorSetter.java +17 -0
  53. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +9 -3
  54. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +3 -4
  55. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -7
  56. package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +90 -307
  57. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +16 -0
  58. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +63 -0
  59. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +271 -0
  60. package/android/src/reactNativeVersionPatch/nativeHierarchyManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +76 -20
  61. package/ios/LayoutReanimation/REAAnimationsManager.h +31 -5
  62. package/ios/LayoutReanimation/REAAnimationsManager.m +265 -77
  63. package/ios/LayoutReanimation/REAFrame.h +10 -0
  64. package/ios/LayoutReanimation/REAFrame.m +15 -0
  65. package/ios/LayoutReanimation/REAScreensHelper.h +19 -0
  66. package/ios/LayoutReanimation/REAScreensHelper.m +106 -0
  67. package/ios/LayoutReanimation/REASharedElement.h +15 -0
  68. package/ios/LayoutReanimation/REASharedElement.m +16 -0
  69. package/ios/LayoutReanimation/REASharedTransitionManager.h +17 -0
  70. package/ios/LayoutReanimation/REASharedTransitionManager.m +632 -0
  71. package/ios/LayoutReanimation/REASnapshot.h +1 -0
  72. package/ios/LayoutReanimation/REASnapshot.m +96 -11
  73. package/ios/LayoutReanimation/REAUIManager.mm +67 -60
  74. package/ios/REAModule.mm +2 -7
  75. package/ios/REANodesManager.mm +1 -21
  76. package/ios/keyboardObserver/REAKeyboardEventObserver.m +72 -36
  77. package/ios/native/NativeProxy.mm +75 -114
  78. package/ios/native/REAInitializer.mm +2 -7
  79. package/ios/native/REAJSIUtils.h +60 -2
  80. package/ios/sensor/ReanimatedSensor.h +6 -2
  81. package/ios/sensor/ReanimatedSensor.m +43 -7
  82. package/ios/sensor/ReanimatedSensorContainer.h +4 -1
  83. package/ios/sensor/ReanimatedSensorContainer.m +8 -2
  84. package/lib/commonjs/createAnimatedComponent.js +232 -28
  85. package/lib/commonjs/createAnimatedComponent.js.map +1 -1
  86. package/lib/commonjs/reanimated2/Colors.js +43 -22
  87. package/lib/commonjs/reanimated2/Colors.js.map +1 -1
  88. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +18 -35
  89. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  90. package/lib/commonjs/reanimated2/animation/styleAnimation.js +5 -1
  91. package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
  92. package/lib/commonjs/reanimated2/animation/util.js +17 -15
  93. package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
  94. package/lib/commonjs/reanimated2/commonTypes.js +33 -1
  95. package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
  96. package/lib/commonjs/reanimated2/component/FlatList.js +19 -3
  97. package/lib/commonjs/reanimated2/component/FlatList.js.map +1 -1
  98. package/lib/commonjs/reanimated2/core.js +34 -83
  99. package/lib/commonjs/reanimated2/core.js.map +1 -1
  100. package/lib/commonjs/reanimated2/errors.js +66 -0
  101. package/lib/commonjs/reanimated2/errors.js.map +1 -0
  102. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
  103. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  104. package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
  105. package/lib/commonjs/reanimated2/hook/index.js +0 -6
  106. package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
  107. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +5 -2
  108. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  109. package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +13 -1
  110. package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  111. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +1 -1
  112. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
  113. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +89 -16
  114. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  115. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +43 -50
  116. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  117. package/lib/commonjs/reanimated2/hook/useDerivedValue.js +13 -1
  118. package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
  119. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +2 -2
  120. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  121. package/lib/commonjs/reanimated2/hook/utils.js +18 -65
  122. package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
  123. package/lib/commonjs/reanimated2/index.js +13 -0
  124. package/lib/commonjs/reanimated2/index.js.map +1 -1
  125. package/lib/commonjs/reanimated2/initializers.js +196 -0
  126. package/lib/commonjs/reanimated2/initializers.js.map +1 -0
  127. package/lib/commonjs/reanimated2/interpolateColor.js +96 -19
  128. package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
  129. package/lib/commonjs/reanimated2/jestUtils.js +1 -1
  130. package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
  131. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +101 -16
  132. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  133. package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +22 -0
  134. package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
  135. package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js +2 -0
  136. package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js.map +1 -0
  137. package/lib/commonjs/reanimated2/js-reanimated/commonTypes.js.map +1 -1
  138. package/lib/commonjs/reanimated2/js-reanimated/global.js +4 -9
  139. package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
  140. package/lib/commonjs/reanimated2/js-reanimated/index.js +0 -1
  141. package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
  142. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +11 -0
  143. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  144. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +8 -0
  145. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  146. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +16 -12
  147. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  148. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -23
  149. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  150. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -14
  151. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  152. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -14
  153. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  154. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -15
  155. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  156. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -23
  157. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  158. package/lib/commonjs/reanimated2/layoutReanimation/index.js +13 -0
  159. package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
  160. package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +94 -0
  161. package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
  162. package/lib/commonjs/reanimated2/mappers.js +18 -6
  163. package/lib/commonjs/reanimated2/mappers.js.map +1 -1
  164. package/lib/commonjs/reanimated2/mock.js +45 -0
  165. package/lib/commonjs/reanimated2/mock.js.map +1 -1
  166. package/lib/commonjs/reanimated2/mutables.js +4 -2
  167. package/lib/commonjs/reanimated2/mutables.js.map +1 -1
  168. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +42 -0
  169. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +1 -0
  170. package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +15 -0
  171. package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
  172. package/lib/commonjs/reanimated2/pluginUtils.js +11 -0
  173. package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -0
  174. package/lib/commonjs/reanimated2/shareables.js +38 -11
  175. package/lib/commonjs/reanimated2/shareables.js.map +1 -1
  176. package/lib/commonjs/reanimated2/threads.js +114 -4
  177. package/lib/commonjs/reanimated2/threads.js.map +1 -1
  178. package/lib/commonjs/reanimated2/utils.js +7 -0
  179. package/lib/commonjs/reanimated2/utils.js.map +1 -1
  180. package/lib/commonjs/reanimated2/valueSetter.js +1 -3
  181. package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
  182. package/lib/module/createAnimatedComponent.js +229 -29
  183. package/lib/module/createAnimatedComponent.js.map +1 -1
  184. package/lib/module/reanimated2/Colors.js +35 -19
  185. package/lib/module/reanimated2/Colors.js.map +1 -1
  186. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +18 -34
  187. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  188. package/lib/module/reanimated2/animation/styleAnimation.js +5 -1
  189. package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
  190. package/lib/module/reanimated2/animation/util.js +17 -16
  191. package/lib/module/reanimated2/animation/util.js.map +1 -1
  192. package/lib/module/reanimated2/commonTypes.js +29 -0
  193. package/lib/module/reanimated2/commonTypes.js.map +1 -1
  194. package/lib/module/reanimated2/component/FlatList.js +18 -4
  195. package/lib/module/reanimated2/component/FlatList.js.map +1 -1
  196. package/lib/module/reanimated2/core.js +30 -76
  197. package/lib/module/reanimated2/core.js.map +1 -1
  198. package/lib/module/reanimated2/errors.js +58 -0
  199. package/lib/module/reanimated2/errors.js.map +1 -0
  200. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
  201. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  202. package/lib/module/reanimated2/globals.d.js.map +1 -1
  203. package/lib/module/reanimated2/hook/index.js +1 -1
  204. package/lib/module/reanimated2/hook/index.js.map +1 -1
  205. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +5 -2
  206. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  207. package/lib/module/reanimated2/hook/useAnimatedReaction.js +12 -1
  208. package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  209. package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
  210. package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
  211. package/lib/module/reanimated2/hook/useAnimatedSensor.js +88 -13
  212. package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  213. package/lib/module/reanimated2/hook/useAnimatedStyle.js +45 -52
  214. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  215. package/lib/module/reanimated2/hook/useDerivedValue.js +12 -1
  216. package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
  217. package/lib/module/reanimated2/hook/useScrollViewOffset.js +2 -2
  218. package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  219. package/lib/module/reanimated2/hook/utils.js +17 -60
  220. package/lib/module/reanimated2/hook/utils.js.map +1 -1
  221. package/lib/module/reanimated2/index.js +1 -0
  222. package/lib/module/reanimated2/index.js.map +1 -1
  223. package/lib/module/reanimated2/initializers.js +182 -0
  224. package/lib/module/reanimated2/initializers.js.map +1 -0
  225. package/lib/module/reanimated2/interpolateColor.js +96 -19
  226. package/lib/module/reanimated2/interpolateColor.js.map +1 -1
  227. package/lib/module/reanimated2/jestUtils.js +1 -1
  228. package/lib/module/reanimated2/jestUtils.js.map +1 -1
  229. package/lib/module/reanimated2/js-reanimated/JSReanimated.js +101 -16
  230. package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  231. package/lib/module/reanimated2/js-reanimated/Mapper.js +21 -0
  232. package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
  233. package/lib/module/reanimated2/js-reanimated/WebSensor.js +2 -0
  234. package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -0
  235. package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
  236. package/lib/module/reanimated2/js-reanimated/global.js +4 -9
  237. package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
  238. package/lib/module/reanimated2/js-reanimated/index.js +0 -1
  239. package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
  240. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +9 -1
  241. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  242. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js +1 -0
  243. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  244. package/lib/module/reanimated2/layoutReanimation/animationsManager.js +15 -10
  245. package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  246. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -21
  247. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  248. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -12
  249. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  250. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
  251. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  252. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -13
  253. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  254. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -21
  255. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  256. package/lib/module/reanimated2/layoutReanimation/index.js +1 -0
  257. package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
  258. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +82 -0
  259. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
  260. package/lib/module/reanimated2/mappers.js +16 -6
  261. package/lib/module/reanimated2/mappers.js.map +1 -1
  262. package/lib/module/reanimated2/mock.js +45 -0
  263. package/lib/module/reanimated2/mock.js.map +1 -1
  264. package/lib/module/reanimated2/mutables.js +4 -2
  265. package/lib/module/reanimated2/mutables.js.map +1 -1
  266. package/lib/module/reanimated2/platform-specific/checkVersion.js +35 -0
  267. package/lib/module/reanimated2/platform-specific/checkVersion.js.map +1 -0
  268. package/lib/module/reanimated2/platform-specific/checkVersion.web.js +8 -0
  269. package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
  270. package/lib/module/reanimated2/pluginUtils.js +4 -0
  271. package/lib/module/reanimated2/pluginUtils.js.map +1 -0
  272. package/lib/module/reanimated2/shareables.js +38 -9
  273. package/lib/module/reanimated2/shareables.js.map +1 -1
  274. package/lib/module/reanimated2/threads.js +105 -4
  275. package/lib/module/reanimated2/threads.js.map +1 -1
  276. package/lib/module/reanimated2/utils.js +5 -0
  277. package/lib/module/reanimated2/utils.js.map +1 -1
  278. package/lib/module/reanimated2/valueSetter.js +1 -2
  279. package/lib/module/reanimated2/valueSetter.js.map +1 -1
  280. package/package.json +9 -8
  281. package/{plugin.js → plugin/index.js} +173 -228
  282. package/react-native-reanimated.d.ts +57 -10
  283. package/scripts/reanimated_utils.rb +15 -2
  284. package/src/createAnimatedComponent.tsx +238 -28
  285. package/src/reanimated2/Colors.ts +38 -11
  286. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +63 -41
  287. package/src/reanimated2/animation/styleAnimation.ts +8 -1
  288. package/src/reanimated2/animation/util.ts +29 -16
  289. package/src/reanimated2/commonTypes.ts +28 -1
  290. package/src/reanimated2/component/FlatList.tsx +30 -5
  291. package/src/reanimated2/core.ts +45 -75
  292. package/src/reanimated2/errors.ts +57 -0
  293. package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +2 -2
  294. package/src/reanimated2/globals.d.ts +34 -18
  295. package/src/reanimated2/hook/index.ts +1 -1
  296. package/src/reanimated2/hook/useAnimatedKeyboard.ts +10 -4
  297. package/src/reanimated2/hook/useAnimatedReaction.ts +12 -5
  298. package/src/reanimated2/hook/useAnimatedRef.ts +1 -4
  299. package/src/reanimated2/hook/useAnimatedSensor.ts +88 -11
  300. package/src/reanimated2/hook/useAnimatedStyle.ts +43 -45
  301. package/src/reanimated2/hook/useDerivedValue.ts +8 -1
  302. package/src/reanimated2/hook/useScrollViewOffset.ts +2 -2
  303. package/src/reanimated2/hook/utils.ts +15 -61
  304. package/src/reanimated2/index.ts +1 -0
  305. package/src/reanimated2/initializers.ts +184 -0
  306. package/src/reanimated2/interpolateColor.ts +104 -20
  307. package/src/reanimated2/jestUtils.ts +1 -1
  308. package/src/reanimated2/js-reanimated/JSReanimated.ts +105 -18
  309. package/src/reanimated2/js-reanimated/Mapper.ts +32 -0
  310. package/src/reanimated2/js-reanimated/WebSensor.ts +34 -0
  311. package/src/reanimated2/js-reanimated/commonTypes.ts +0 -1
  312. package/src/reanimated2/js-reanimated/global.ts +4 -8
  313. package/src/reanimated2/js-reanimated/index.ts +0 -1
  314. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +13 -1
  315. package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
  316. package/src/reanimated2/layoutReanimation/animationsManager.ts +17 -12
  317. package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +16 -19
  318. package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +14 -11
  319. package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +21 -11
  320. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -11
  321. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +36 -19
  322. package/src/reanimated2/layoutReanimation/index.ts +1 -0
  323. package/src/reanimated2/layoutReanimation/sharedTransitions/index.ts +87 -0
  324. package/src/reanimated2/mappers.ts +17 -6
  325. package/src/reanimated2/mock.ts +128 -0
  326. package/src/reanimated2/mutables.ts +2 -0
  327. package/src/reanimated2/platform-specific/checkVersion.ts +39 -0
  328. package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
  329. package/src/reanimated2/pluginUtils.ts +8 -0
  330. package/src/reanimated2/shareables.ts +47 -11
  331. package/src/reanimated2/threads.ts +103 -1
  332. package/src/reanimated2/utils.ts +6 -0
  333. package/src/reanimated2/valueSetter.ts +1 -2
  334. package/lib/commonjs/reanimated2/time.js +0 -55
  335. package/lib/commonjs/reanimated2/time.js.map +0 -1
  336. package/lib/module/reanimated2/time.js +0 -37
  337. package/lib/module/reanimated2/time.js.map +0 -1
  338. package/src/reanimated2/time.ts +0 -30
  339. /package/android/src/{main/java → reactNativeVersionPatch/ReanimatedUIManager/70}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -0
@@ -1 +1 @@
1
- {"version":3,"names":["IN_STYLE_UPDATER","initialUpdaterRun","updater","result","recognizePrefixSuffix","value","match","Error","prefix","suffix","number","strippedValue","parseFloat","decorateAnimation","animation","isHigherOrder","baseOnStart","onStart","baseOnFrame","onFrame","animationCopy","Object","assign","callback","prefNumberSuffOnStart","timestamp","previousAnimation","__prefix","__suffix","strippedCurrent","strippedToValue","toValue","current","startValue","paPrefix","paSuffix","paStrippedValue","prefNumberSuffOnFrame","res","tab","colorOnStart","HSVAValue","HSVACurrent","HSVAToValue","isColor","convertToHSVA","forEach","i","index","undefined","push","toRGBA","colorOnFrame","finished","arrayOnStart","v","arrayOnFrame","Array","isArray","defineAnimation","starting","factory","create","_WORKLET","NativeReanimatedModule","native","cancelAnimation","sharedValue","withStartValue"],"sources":["util.ts"],"sourcesContent":["import {\n HigherOrderAnimation,\n NextAnimation,\n DelayAnimation,\n RepeatAnimation,\n SequenceAnimation,\n StyleLayoutAnimation,\n} from './commonTypes';\n/* global _WORKLET */\nimport { ParsedColorArray, convertToHSVA, isColor, toRGBA } from '../Colors';\n\nimport {\n AnimatedStyle,\n SharedValue,\n AnimatableValue,\n Animation,\n AnimationObject,\n Timestamp,\n} from '../commonTypes';\nimport NativeReanimatedModule from '../NativeReanimated';\n\nlet IN_STYLE_UPDATER = false;\n\nexport type UserUpdater = () => AnimatedStyle;\n\nexport function initialUpdaterRun<T>(updater: () => T): T {\n IN_STYLE_UPDATER = true;\n const result = updater();\n IN_STYLE_UPDATER = false;\n return result;\n}\n\ninterface RecognizedPrefixSuffix {\n prefix?: string;\n suffix?: string;\n strippedValue: number;\n}\n\nfunction recognizePrefixSuffix(value: string | number): RecognizedPrefixSuffix {\n 'worklet';\n if (typeof value === 'string') {\n const match = value.match(\n /([A-Za-z]*)(-?\\d*\\.?\\d*)([eE][-+]?[0-9]+)?([A-Za-z%]*)/\n );\n if (!match) {\n throw Error(\n \"Couldn't parse animation value. Check if there isn't any typo.\"\n );\n }\n const prefix = match[1];\n const suffix = match[4];\n // number with scientific notation\n const number = match[2] + (match[3] ?? '');\n return { prefix, suffix, strippedValue: parseFloat(number) };\n } else {\n return { strippedValue: value };\n }\n}\n\nfunction decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(\n animation: T\n): void {\n 'worklet';\n if ((animation as HigherOrderAnimation).isHigherOrder) {\n return;\n }\n\n const baseOnStart = (animation as Animation<AnimationObject>).onStart;\n const baseOnFrame = (animation as Animation<AnimationObject>).onFrame;\n const animationCopy = Object.assign({}, animation);\n delete animationCopy.callback;\n\n const prefNumberSuffOnStart = (\n animation: Animation<AnimationObject>,\n value: string | number,\n timestamp: number,\n previousAnimation: Animation<AnimationObject>\n ) => {\n // recognize prefix, suffix, and updates stripped value on animation start\n const { prefix, suffix, strippedValue } = recognizePrefixSuffix(value);\n animation.__prefix = prefix;\n animation.__suffix = suffix;\n animation.strippedCurrent = strippedValue;\n const { strippedValue: strippedToValue } = recognizePrefixSuffix(\n animation.toValue as string | number\n );\n animation.current = strippedValue;\n animation.startValue = strippedValue;\n animation.toValue = strippedToValue;\n if (previousAnimation && previousAnimation !== animation) {\n const {\n prefix: paPrefix,\n suffix: paSuffix,\n strippedValue: paStrippedValue,\n } = recognizePrefixSuffix(previousAnimation.current as string | number);\n previousAnimation.current = paStrippedValue;\n previousAnimation.__prefix = paPrefix;\n previousAnimation.__suffix = paSuffix;\n }\n\n baseOnStart(animation, strippedValue, timestamp, previousAnimation);\n\n animation.current =\n (animation.__prefix ?? '') +\n animation.current +\n (animation.__suffix ?? '');\n\n if (previousAnimation && previousAnimation !== animation) {\n previousAnimation.current =\n (previousAnimation.__prefix ?? '') +\n previousAnimation.current +\n (previousAnimation.__suffix ?? '');\n }\n };\n const prefNumberSuffOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: number\n ) => {\n animation.current = animation.strippedCurrent;\n const res = baseOnFrame(animation, timestamp);\n animation.strippedCurrent = animation.current;\n animation.current =\n (animation.__prefix ?? '') +\n animation.current +\n (animation.__suffix ?? '');\n return res;\n };\n\n const tab = ['H', 'S', 'V', 'A'];\n const colorOnStart = (\n animation: Animation<AnimationObject>,\n value: string | number,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ): void => {\n let HSVAValue: ParsedColorArray;\n let HSVACurrent: ParsedColorArray;\n let HSVAToValue: ParsedColorArray;\n const res: Array<number> = [];\n if (isColor(value)) {\n HSVACurrent = convertToHSVA(animation.current);\n HSVAValue = convertToHSVA(value);\n if (animation.toValue) {\n HSVAToValue = convertToHSVA(animation.toValue);\n }\n }\n tab.forEach((i, index) => {\n animation[i] = Object.assign({}, animationCopy);\n animation[i].current = HSVACurrent[index];\n animation[i].toValue = HSVAToValue ? HSVAToValue[index] : undefined;\n animation[i].onStart(\n animation[i],\n HSVAValue[index],\n timestamp,\n previousAnimation ? previousAnimation[i] : undefined\n );\n res.push(animation[i].current);\n });\n\n animation.current = toRGBA(res as ParsedColorArray);\n };\n\n const colorOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: Timestamp\n ): boolean => {\n const HSVACurrent = convertToHSVA(animation.current);\n const res: Array<number> = [];\n let finished = true;\n tab.forEach((i, index) => {\n animation[i].current = HSVACurrent[index];\n // @ts-ignore: disable-next-line\n finished &= animation[i].onFrame(animation[i], timestamp);\n res.push(animation[i].current);\n });\n\n animation.current = toRGBA(res as ParsedColorArray);\n return finished;\n };\n\n const arrayOnStart = (\n animation: Animation<AnimationObject>,\n value: Array<number>,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ): void => {\n value.forEach((v, i) => {\n animation[i] = Object.assign({}, animationCopy);\n animation[i].current = v;\n animation[i].toValue = (animation.toValue as Array<number>)[i];\n animation[i].onStart(\n animation[i],\n v,\n timestamp,\n previousAnimation ? previousAnimation[i] : undefined\n );\n });\n\n animation.current = value;\n };\n\n const arrayOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: Timestamp\n ): boolean => {\n let finished = true;\n (animation.current as Array<number>).forEach((v, i) => {\n // @ts-ignore: disable-next-line\n finished &= animation[i].onFrame(animation[i], timestamp);\n (animation.current as Array<number>)[i] = animation[i].current;\n });\n\n return finished;\n };\n\n animation.onStart = (\n animation: Animation<AnimationObject>,\n value: number,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ) => {\n if (isColor(value)) {\n colorOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = colorOnFrame;\n return;\n } else if (Array.isArray(value)) {\n arrayOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = arrayOnFrame;\n return;\n } else if (typeof value === 'string') {\n prefNumberSuffOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = prefNumberSuffOnFrame;\n return;\n }\n baseOnStart(animation, value, timestamp, previousAnimation);\n };\n}\n\ntype AnimationToDecoration<T extends AnimationObject | StyleLayoutAnimation> =\n T extends StyleLayoutAnimation\n ? Record<string, unknown>\n : T extends DelayAnimation\n ? NextAnimation<DelayAnimation>\n : T extends RepeatAnimation\n ? NextAnimation<RepeatAnimation>\n : T extends SequenceAnimation\n ? NextAnimation<SequenceAnimation>\n : AnimatableValue | T;\n\nexport function defineAnimation<\n T extends AnimationObject | StyleLayoutAnimation\n>(starting: AnimationToDecoration<T>, factory: () => T): T {\n 'worklet';\n if (IN_STYLE_UPDATER) {\n return starting as T;\n }\n const create = () => {\n 'worklet';\n const animation = factory();\n decorateAnimation<T>(animation);\n return animation;\n };\n\n if (_WORKLET || !NativeReanimatedModule.native) {\n return create();\n }\n // @ts-ignore: eslint-disable-line\n return create;\n}\n\nexport function cancelAnimation<T>(sharedValue: SharedValue<T>): void {\n 'worklet';\n // setting the current value cancels the animation if one is currently running\n sharedValue.value = sharedValue.value; // eslint-disable-line no-self-assign\n}\n\n// TODO it should work only if there was no animation before.\nexport function withStartValue(\n startValue: AnimatableValue,\n animation: NextAnimation<AnimationObject>\n): Animation<AnimationObject> {\n 'worklet';\n return defineAnimation(startValue, () => {\n 'worklet';\n if (!_WORKLET && typeof animation === 'function') {\n animation = animation();\n }\n (animation as Animation<AnimationObject>).current = startValue;\n return animation as Animation<AnimationObject>;\n });\n}\n"],"mappings":";;;;;;;;;;AASA;;AAUA;;;;AAXA;AAaA,IAAIA,gBAAgB,GAAG,KAAvB;;AAI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kB,OAA1C,GAAoDC,UAApD;IACA,OAAOnB,SAAP;EACD,CAPqB,CAAtB;AAQD"}
1
+ {"version":3,"names":["IN_STYLE_UPDATER","initialUpdaterRun","updater","result","recognizePrefixSuffix","value","match","Error","prefix","suffix","number","strippedValue","parseFloat","decorateAnimation","animation","isHigherOrder","baseOnStart","onStart","baseOnFrame","onFrame","animationCopy","Object","assign","callback","prefNumberSuffOnStart","timestamp","previousAnimation","__prefix","__suffix","strippedCurrent","strippedToValue","toValue","current","startValue","paPrefix","paSuffix","paStrippedValue","prefNumberSuffOnFrame","res","tab","colorOnStart","RGBAValue","RGBACurrent","RGBAToValue","isColor","toLinearSpace","convertToRGBA","forEach","i","index","undefined","push","rgbaArrayToRGBAColor","toGammaSpace","colorOnFrame","finished","arrayOnStart","v","arrayOnFrame","Array","isArray","IS_NATIVE","NativeReanimatedModule","native","defineAnimation","starting","factory","create","_WORKLET","cancelAnimation","sharedValue","withStartValue"],"sources":["util.ts"],"sourcesContent":["import {\n HigherOrderAnimation,\n NextAnimation,\n DelayAnimation,\n RepeatAnimation,\n SequenceAnimation,\n StyleLayoutAnimation,\n} from './commonTypes';\n/* global _WORKLET */\nimport {\n ParsedColorArray,\n isColor,\n convertToRGBA,\n rgbaArrayToRGBAColor,\n toGammaSpace,\n toLinearSpace,\n} from '../Colors';\n\nimport {\n AnimatedStyle,\n SharedValue,\n AnimatableValue,\n Animation,\n AnimationObject,\n Timestamp,\n} from '../commonTypes';\nimport NativeReanimatedModule from '../NativeReanimated';\n\nlet IN_STYLE_UPDATER = false;\n\nexport type UserUpdater = () => AnimatedStyle;\n\nexport function initialUpdaterRun<T>(updater: () => T): T {\n IN_STYLE_UPDATER = true;\n const result = updater();\n IN_STYLE_UPDATER = false;\n return result;\n}\n\ninterface RecognizedPrefixSuffix {\n prefix?: string;\n suffix?: string;\n strippedValue: number;\n}\n\nfunction recognizePrefixSuffix(value: string | number): RecognizedPrefixSuffix {\n 'worklet';\n if (typeof value === 'string') {\n const match = value.match(\n /([A-Za-z]*)(-?\\d*\\.?\\d*)([eE][-+]?[0-9]+)?([A-Za-z%]*)/\n );\n if (!match) {\n throw Error(\n \"Couldn't parse animation value. Check if there isn't any typo.\"\n );\n }\n const prefix = match[1];\n const suffix = match[4];\n // number with scientific notation\n const number = match[2] + (match[3] ?? '');\n return { prefix, suffix, strippedValue: parseFloat(number) };\n } else {\n return { strippedValue: value };\n }\n}\n\nfunction decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(\n animation: T\n): void {\n 'worklet';\n if ((animation as HigherOrderAnimation).isHigherOrder) {\n return;\n }\n\n const baseOnStart = (animation as Animation<AnimationObject>).onStart;\n const baseOnFrame = (animation as Animation<AnimationObject>).onFrame;\n const animationCopy = Object.assign({}, animation);\n delete animationCopy.callback;\n\n const prefNumberSuffOnStart = (\n animation: Animation<AnimationObject>,\n value: string | number,\n timestamp: number,\n previousAnimation: Animation<AnimationObject>\n ) => {\n // recognize prefix, suffix, and updates stripped value on animation start\n const { prefix, suffix, strippedValue } = recognizePrefixSuffix(value);\n animation.__prefix = prefix;\n animation.__suffix = suffix;\n animation.strippedCurrent = strippedValue;\n const { strippedValue: strippedToValue } = recognizePrefixSuffix(\n animation.toValue as string | number\n );\n animation.current = strippedValue;\n animation.startValue = strippedValue;\n animation.toValue = strippedToValue;\n if (previousAnimation && previousAnimation !== animation) {\n const {\n prefix: paPrefix,\n suffix: paSuffix,\n strippedValue: paStrippedValue,\n } = recognizePrefixSuffix(previousAnimation.current as string | number);\n previousAnimation.current = paStrippedValue;\n previousAnimation.__prefix = paPrefix;\n previousAnimation.__suffix = paSuffix;\n }\n\n baseOnStart(animation, strippedValue, timestamp, previousAnimation);\n\n animation.current =\n (animation.__prefix ?? '') +\n animation.current +\n (animation.__suffix ?? '');\n\n if (previousAnimation && previousAnimation !== animation) {\n previousAnimation.current =\n (previousAnimation.__prefix ?? '') +\n previousAnimation.current +\n (previousAnimation.__suffix ?? '');\n }\n };\n const prefNumberSuffOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: number\n ) => {\n animation.current = animation.strippedCurrent;\n const res = baseOnFrame(animation, timestamp);\n animation.strippedCurrent = animation.current;\n animation.current =\n (animation.__prefix ?? '') +\n animation.current +\n (animation.__suffix ?? '');\n return res;\n };\n\n const tab = ['R', 'G', 'B', 'A'];\n const colorOnStart = (\n animation: Animation<AnimationObject>,\n value: string | number,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ): void => {\n let RGBAValue: ParsedColorArray;\n let RGBACurrent: ParsedColorArray;\n let RGBAToValue: ParsedColorArray;\n const res: Array<number> = [];\n if (isColor(value)) {\n RGBACurrent = toLinearSpace(convertToRGBA(animation.current));\n RGBAValue = toLinearSpace(convertToRGBA(value));\n if (animation.toValue) {\n RGBAToValue = toLinearSpace(convertToRGBA(animation.toValue));\n }\n }\n tab.forEach((i, index) => {\n animation[i] = Object.assign({}, animationCopy);\n animation[i].current = RGBACurrent[index];\n animation[i].toValue = RGBAToValue ? RGBAToValue[index] : undefined;\n animation[i].onStart(\n animation[i],\n RGBAValue[index],\n timestamp,\n previousAnimation ? previousAnimation[i] : undefined\n );\n res.push(animation[i].current);\n });\n\n animation.current = rgbaArrayToRGBAColor(\n toGammaSpace(res as ParsedColorArray)\n );\n };\n\n const colorOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: Timestamp\n ): boolean => {\n const RGBACurrent = toLinearSpace(convertToRGBA(animation.current));\n const res: Array<number> = [];\n let finished = true;\n tab.forEach((i, index) => {\n animation[i].current = RGBACurrent[index];\n // @ts-ignore: disable-next-line\n finished &= animation[i].onFrame(animation[i], timestamp);\n res.push(animation[i].current);\n });\n\n animation.current = rgbaArrayToRGBAColor(\n toGammaSpace(res as ParsedColorArray)\n );\n return finished;\n };\n\n const arrayOnStart = (\n animation: Animation<AnimationObject>,\n value: Array<number>,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ): void => {\n value.forEach((v, i) => {\n animation[i] = Object.assign({}, animationCopy);\n animation[i].current = v;\n animation[i].toValue = (animation.toValue as Array<number>)[i];\n animation[i].onStart(\n animation[i],\n v,\n timestamp,\n previousAnimation ? previousAnimation[i] : undefined\n );\n });\n\n animation.current = value;\n };\n\n const arrayOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: Timestamp\n ): boolean => {\n let finished = true;\n (animation.current as Array<number>).forEach((v, i) => {\n // @ts-ignore: disable-next-line\n finished &= animation[i].onFrame(animation[i], timestamp);\n (animation.current as Array<number>)[i] = animation[i].current;\n });\n\n return finished;\n };\n\n animation.onStart = (\n animation: Animation<AnimationObject>,\n value: number,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ) => {\n if (isColor(value)) {\n colorOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = colorOnFrame;\n return;\n } else if (Array.isArray(value)) {\n arrayOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = arrayOnFrame;\n return;\n } else if (typeof value === 'string') {\n prefNumberSuffOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = prefNumberSuffOnFrame;\n return;\n }\n baseOnStart(animation, value, timestamp, previousAnimation);\n };\n}\n\ntype AnimationToDecoration<T extends AnimationObject | StyleLayoutAnimation> =\n T extends StyleLayoutAnimation\n ? Record<string, unknown>\n : T extends DelayAnimation\n ? NextAnimation<DelayAnimation>\n : T extends RepeatAnimation\n ? NextAnimation<RepeatAnimation>\n : T extends SequenceAnimation\n ? NextAnimation<SequenceAnimation>\n : AnimatableValue | T;\n\nconst IS_NATIVE = NativeReanimatedModule.native;\n\nexport function defineAnimation<\n T extends AnimationObject | StyleLayoutAnimation\n>(starting: AnimationToDecoration<T>, factory: () => T): T {\n 'worklet';\n if (IN_STYLE_UPDATER) {\n return starting as T;\n }\n const create = () => {\n 'worklet';\n const animation = factory();\n decorateAnimation<T>(animation);\n return animation;\n };\n\n if (_WORKLET || !IS_NATIVE) {\n return create();\n }\n // @ts-ignore: eslint-disable-line\n return create;\n}\n\nexport function cancelAnimation<T>(sharedValue: SharedValue<T>): void {\n 'worklet';\n // setting the current value cancels the animation if one is currently running\n sharedValue.value = sharedValue.value; // eslint-disable-line no-self-assign\n}\n\n// TODO it should work only if there was no animation before.\nexport function withStartValue(\n startValue: AnimatableValue,\n animation: NextAnimation<AnimationObject>\n): Animation<AnimationObject> {\n 'worklet';\n return defineAnimation(startValue, () => {\n 'worklet';\n if (!_WORKLET && typeof animation === 'function') {\n animation = animation();\n }\n (animation as Animation<AnimationObject>).current = startValue;\n return animation as Animation<AnimationObject>;\n });\n}\n"],"mappings":";;;;;;;;;;AASA;;AAiBA;;;;AAlBA;AAoBA,IAAIA,gBAAgB,GAAG,KAAvB;;AAIO,SAASC,iBAAT,CAA8BC,OAA9B,EAAmD;EACxDF,gBAAgB,GAAG,IAAnB;EACA,MAAMG,MAAM,GAAGD,OAAO,EAAtB;EACAF,gBAAgB,GAAG,KAAnB;EACA,OAAOG,MAAP;AACD;;AAQD,SAASC,qBAAT,CAA+BC,KAA/B,EAA+E;EAC7E;;EACA,IAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;IAC7B,MAAMC,KAAK,GAAGD,KAAK,CAACC,KAAN,CACZ,wDADY,CAAd;;IAGA,IAAI,CAACA,KAAL,EAAY;MACV,MAAMC,KAAK,CACT,gEADS,CAAX;IAGD;;IACD,MAAMC,MAAM,GAAGF,KAAK,CAAC,CAAD,CAApB;IACA,MAAMG,MAAM,GAAGH,KAAK,CAAC,CAAD,CAApB,CAV6B,CAW7B;;IACA,MAAMI,MAAM,GAAGJ,KAAK,CAAC,CAAD,CAAL,IAAYA,KAAK,CAAC,CAAD,CAAL,IAAY,EAAxB,CAAf;IACA,OAAO;MAAEE,MAAF;MAAUC,MAAV;MAAkBE,aAAa,EAAEC,UAAU,CAACF,MAAD;IAA3C,CAAP;EACD,CAdD,MAcO;IACL,OAAO;MAAEC,aAAa,EAAEN;IAAjB,CAAP;EACD;AACF;;AAED,SAASQ,iBAAT,CACEC,SADF,EAEQ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G,MAAM;IACnB;;IACA,MAAMrD,SAAS,GAAGoD,OAAO,EAAzB;IACArD,iBAAiB,CAAIC,SAAJ,CAAjB;IACA,OAAOA,SAAP;EACD,CALD;;EAOA,IAAIsD,QAAQ,IAAI,CAACP,SAAjB,EAA4B;IAC1B,OAAOM,MAAM,EAAb;EACD,CAdwD,CAezD;;;EACA,OAAOA,MAAP;AACD;;AAEM,SAASE,eAAT,CAA4BC,WAA5B,EAA+D;EACpE,UADoE,CAEpE;;EACAA,WAAW,CAACjE,KAAZ,GAAoBiE,WAAW,CAACjE,KAAhC,CAHoE,CAG7B;AACxC,C,CAED;;;AACO,SAASkE,cAAT,CACLtC,UADK,EAELnB,SAFK,EAGuB;EAC5B;;EACA,OAAOkD,eAAe,CAAC/B,UAAD,EAAa,MAAM;IACvC;;IACA,IAAI,CAACmC,QAAD,IAAa,OAAOtD,SAAP,KAAqB,UAAtC,EAAkD;MAChDA,SAAS,GAAGA,SAAS,EAArB;IACD;;IACAA,SAAD,CAA0CkB,OAA1C,GAAoDC,UAApD;IACA,OAAOnB,SAAP;EACD,CAPqB,CAAtB;AAQD"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.KeyboardState = void 0;
6
+ exports.SensorType = exports.KeyboardState = exports.InterfaceOrientation = exports.IOSReferenceFrame = void 0;
7
7
  // The below type is used for HostObjects retured by the JSI API that don't have
8
8
  // any accessable fields or methods but can carry data that is accessed from the
9
9
  // c++ side. We add a field to the type to make it possible for typescript to recognize
@@ -11,6 +11,38 @@ exports.KeyboardState = void 0;
11
11
  // check other methods that may use them. However, this field is not actually defined
12
12
  // nor should be used for anything else as assigning any data to those objects will
13
13
  // throw an error.
14
+ let SensorType;
15
+ exports.SensorType = SensorType;
16
+
17
+ (function (SensorType) {
18
+ SensorType[SensorType["ACCELEROMETER"] = 1] = "ACCELEROMETER";
19
+ SensorType[SensorType["GYROSCOPE"] = 2] = "GYROSCOPE";
20
+ SensorType[SensorType["GRAVITY"] = 3] = "GRAVITY";
21
+ SensorType[SensorType["MAGNETIC_FIELD"] = 4] = "MAGNETIC_FIELD";
22
+ SensorType[SensorType["ROTATION"] = 5] = "ROTATION";
23
+ })(SensorType || (exports.SensorType = SensorType = {}));
24
+
25
+ let IOSReferenceFrame;
26
+ exports.IOSReferenceFrame = IOSReferenceFrame;
27
+
28
+ (function (IOSReferenceFrame) {
29
+ IOSReferenceFrame[IOSReferenceFrame["XArbitraryZVertical"] = 0] = "XArbitraryZVertical";
30
+ IOSReferenceFrame[IOSReferenceFrame["XArbitraryCorrectedZVertical"] = 1] = "XArbitraryCorrectedZVertical";
31
+ IOSReferenceFrame[IOSReferenceFrame["XMagneticNorthZVertical"] = 2] = "XMagneticNorthZVertical";
32
+ IOSReferenceFrame[IOSReferenceFrame["XTrueNorthZVertical"] = 3] = "XTrueNorthZVertical";
33
+ IOSReferenceFrame[IOSReferenceFrame["Auto"] = 4] = "Auto";
34
+ })(IOSReferenceFrame || (exports.IOSReferenceFrame = IOSReferenceFrame = {}));
35
+
36
+ let InterfaceOrientation;
37
+ exports.InterfaceOrientation = InterfaceOrientation;
38
+
39
+ (function (InterfaceOrientation) {
40
+ InterfaceOrientation[InterfaceOrientation["ROTATION_0"] = 0] = "ROTATION_0";
41
+ InterfaceOrientation[InterfaceOrientation["ROTATION_90"] = 90] = "ROTATION_90";
42
+ InterfaceOrientation[InterfaceOrientation["ROTATION_180"] = 180] = "ROTATION_180";
43
+ InterfaceOrientation[InterfaceOrientation["ROTATION_270"] = 270] = "ROTATION_270";
44
+ })(InterfaceOrientation || (exports.InterfaceOrientation = InterfaceOrientation = {}));
45
+
14
46
  let KeyboardState;
15
47
  exports.KeyboardState = KeyboardState;
16
48
 
@@ -1 +1 @@
1
- {"version":3,"names":["KeyboardState"],"sources":["commonTypes.ts"],"sourcesContent":["import {\n PerpectiveTransform,\n RotateTransform,\n RotateXTransform,\n RotateYTransform,\n RotateZTransform,\n ScaleTransform,\n ScaleXTransform,\n ScaleYTransform,\n TranslateXTransform,\n TranslateYTransform,\n SkewXTransform,\n SkewYTransform,\n MatrixTransform,\n ViewStyle,\n TextStyle,\n} from 'react-native';\n\nexport type TransformProperty =\n | PerpectiveTransform\n | RotateTransform\n | RotateXTransform\n | RotateYTransform\n | RotateZTransform\n | ScaleTransform\n | ScaleXTransform\n | ScaleYTransform\n | TranslateXTransform\n | TranslateYTransform\n | SkewXTransform\n | SkewYTransform\n | MatrixTransform;\n\nexport interface StyleProps extends ViewStyle, TextStyle {\n originX?: number;\n originY?: number;\n [key: string]: any;\n}\n\nexport interface AnimatedStyle\n extends Record<string, Animation<AnimationObject>> {\n [key: string]: any;\n transform?: Array<Record<string, Animation<AnimationObject>>>;\n}\nexport interface SharedValue<T> {\n value: T;\n addListener: (listenerID: number, listener: (value: T) => void) => void;\n removeListener: (listenerID: number) => void;\n modify: (modifier: (value: T) => T) => void;\n}\n\n// The below type is used for HostObjects retured by the JSI API that don't have\n// any accessable fields or methods but can carry data that is accessed from the\n// c++ side. We add a field to the type to make it possible for typescript to recognize\n// which JSI methods accept those types as arguments and to be able to correctly type\n// check other methods that may use them. However, this field is not actually defined\n// nor should be used for anything else as assigning any data to those objects will\n// throw an error.\nexport type ShareableRef<T> = {\n __hostObjectShareableJSRef: T;\n};\n\nexport type ShareableSyncDataHolderRef<T> = {\n __hostObjectShareableJSRefSyncDataHolder: T;\n};\n\nexport type MapperRegistry = {\n start: (\n mapperID: number,\n worklet: () => void,\n inputs: SharedValue<any>[],\n outputs?: SharedValue<any>[]\n ) => void;\n stop: (mapperID: number) => void;\n};\n\nexport type Context = Record<string, unknown>;\n\nexport interface WorkletFunction {\n _closure?: Context;\n __workletHash?: number;\n __optimalization?: number;\n}\n\nexport interface BasicWorkletFunction<T> extends WorkletFunction {\n (): T;\n}\n\nexport interface BasicWorkletFunctionOptional<T> extends WorkletFunction {\n (): Partial<T>;\n}\n\nexport interface NativeEvent<T> {\n nativeEvent: T;\n}\nexport interface ComplexWorkletFunction<A extends any[], R>\n extends WorkletFunction {\n (...args: A): R;\n __remoteFunction?: (...args: A) => R;\n}\n\nexport interface NestedObject<T> {\n [key: string]: NestedObjectValues<T>;\n}\n\nexport type NestedObjectValues<T> =\n | T\n | Array<NestedObjectValues<T>>\n | NestedObject<T>;\n\nexport interface AdapterWorkletFunction extends WorkletFunction {\n (value: NestedObject<string | number | AnimationObject>): void;\n}\n\nexport type AnimatableValue = number | string | Array<number>;\n\nexport interface AnimationObject {\n [key: string]: any;\n callback: AnimationCallback;\n current?: AnimatableValue;\n toValue?: AnimationObject['current'];\n startValue?: AnimationObject['current'];\n finished?: boolean;\n strippedCurrent?: number;\n cancelled?: boolean;\n\n __prefix?: string;\n __suffix?: string;\n onFrame: (animation: any, timestamp: Timestamp) => boolean;\n onStart: (\n nextAnimation: any,\n current: any,\n timestamp: Timestamp,\n previousAnimation: any\n ) => void;\n}\n\nexport interface Animation<T extends AnimationObject> extends AnimationObject {\n onFrame: (animation: T, timestamp: Timestamp) => boolean;\n onStart: (\n nextAnimation: T,\n current: T extends NumericAnimation ? number : AnimatableValue,\n timestamp: Timestamp,\n previousAnimation: T\n ) => void;\n}\n\nexport interface NumericAnimation {\n current?: number;\n}\n\nexport type AnimationCallback = (\n finished?: boolean,\n current?: AnimatableValue\n) => void;\n\nexport type Timestamp = number;\n\nexport type Value3D = {\n x: number;\n y: number;\n z: number;\n};\n\nexport type ValueRotation = {\n qw: number;\n qx: number;\n qy: number;\n qz: number;\n yaw: number;\n pitch: number;\n roll: number;\n};\n\nexport type ShadowNodeWrapper = object;\n\nexport enum KeyboardState {\n UNKNOWN = 0,\n OPENING = 1,\n OPEN = 2,\n CLOSING = 3,\n CLOSED = 4,\n}\n\nexport type AnimatedKeyboardInfo = {\n height: SharedValue<number>;\n state: SharedValue<KeyboardState>;\n};\n\nexport interface MeasuredDimensions {\n x: number;\n y: number;\n width: number;\n height: number;\n pageX: number;\n pageY: number;\n}\n"],"mappings":";;;;;;AAmDA;AACA;AACA;AACA;AACA;AACA;AACA;IAuHYA,a;;;WAAAA,a;EAAAA,a,CAAAA,a;EAAAA,a,CAAAA,a;EAAAA,a,CAAAA,a;EAAAA,a,CAAAA,a;EAAAA,a,CAAAA,a;GAAAA,a,6BAAAA,a"}
1
+ {"version":3,"names":["SensorType","IOSReferenceFrame","InterfaceOrientation","KeyboardState"],"sources":["commonTypes.ts"],"sourcesContent":["import {\n PerpectiveTransform,\n RotateTransform,\n RotateXTransform,\n RotateYTransform,\n RotateZTransform,\n ScaleTransform,\n ScaleXTransform,\n ScaleYTransform,\n TranslateXTransform,\n TranslateYTransform,\n SkewXTransform,\n SkewYTransform,\n MatrixTransform,\n ViewStyle,\n TextStyle,\n} from 'react-native';\n\nexport type TransformProperty =\n | PerpectiveTransform\n | RotateTransform\n | RotateXTransform\n | RotateYTransform\n | RotateZTransform\n | ScaleTransform\n | ScaleXTransform\n | ScaleYTransform\n | TranslateXTransform\n | TranslateYTransform\n | SkewXTransform\n | SkewYTransform\n | MatrixTransform;\n\nexport interface StyleProps extends ViewStyle, TextStyle {\n originX?: number;\n originY?: number;\n [key: string]: any;\n}\n\nexport interface AnimatedStyle\n extends Record<string, Animation<AnimationObject>> {\n [key: string]: any;\n transform?: Array<Record<string, Animation<AnimationObject>>>;\n}\nexport interface SharedValue<T> {\n value: T;\n addListener: (listenerID: number, listener: (value: T) => void) => void;\n removeListener: (listenerID: number) => void;\n modify: (modifier: (value: T) => T) => void;\n}\n\n// The below type is used for HostObjects retured by the JSI API that don't have\n// any accessable fields or methods but can carry data that is accessed from the\n// c++ side. We add a field to the type to make it possible for typescript to recognize\n// which JSI methods accept those types as arguments and to be able to correctly type\n// check other methods that may use them. However, this field is not actually defined\n// nor should be used for anything else as assigning any data to those objects will\n// throw an error.\nexport type ShareableRef<T> = {\n __hostObjectShareableJSRef: T;\n};\n\nexport type ShareableSyncDataHolderRef<T> = {\n __hostObjectShareableJSRefSyncDataHolder: T;\n};\n\nexport type MapperRegistry = {\n start: (\n mapperID: number,\n worklet: () => void,\n inputs: SharedValue<any>[],\n outputs?: SharedValue<any>[]\n ) => void;\n stop: (mapperID: number) => void;\n};\n\nexport type Context = Record<string, unknown>;\n\nexport interface WorkletFunction {\n _closure?: Context;\n __workletHash?: number;\n}\n\nexport interface BasicWorkletFunction<T> extends WorkletFunction {\n (): T;\n}\n\nexport interface BasicWorkletFunctionOptional<T> extends WorkletFunction {\n (): Partial<T>;\n}\n\nexport interface NativeEvent<T> {\n nativeEvent: T;\n}\nexport interface ComplexWorkletFunction<A extends any[], R>\n extends WorkletFunction {\n (...args: A): R;\n __remoteFunction?: (...args: A) => R;\n}\n\nexport interface NestedObject<T> {\n [key: string]: NestedObjectValues<T>;\n}\n\nexport type NestedObjectValues<T> =\n | T\n | Array<NestedObjectValues<T>>\n | NestedObject<T>;\n\nexport interface AdapterWorkletFunction extends WorkletFunction {\n (value: NestedObject<string | number | AnimationObject>): void;\n}\n\nexport type AnimatableValue = number | string | Array<number>;\n\nexport interface AnimationObject {\n [key: string]: any;\n callback: AnimationCallback;\n current?: AnimatableValue;\n toValue?: AnimationObject['current'];\n startValue?: AnimationObject['current'];\n finished?: boolean;\n strippedCurrent?: number;\n cancelled?: boolean;\n\n __prefix?: string;\n __suffix?: string;\n onFrame: (animation: any, timestamp: Timestamp) => boolean;\n onStart: (\n nextAnimation: any,\n current: any,\n timestamp: Timestamp,\n previousAnimation: any\n ) => void;\n}\n\nexport interface Animation<T extends AnimationObject> extends AnimationObject {\n onFrame: (animation: T, timestamp: Timestamp) => boolean;\n onStart: (\n nextAnimation: T,\n current: T extends NumericAnimation ? number : AnimatableValue,\n timestamp: Timestamp,\n previousAnimation: T\n ) => void;\n}\n\nexport enum SensorType {\n ACCELEROMETER = 1,\n GYROSCOPE = 2,\n GRAVITY = 3,\n MAGNETIC_FIELD = 4,\n ROTATION = 5,\n}\nexport enum IOSReferenceFrame {\n XArbitraryZVertical,\n XArbitraryCorrectedZVertical,\n XMagneticNorthZVertical,\n XTrueNorthZVertical,\n Auto,\n}\n\nexport interface NumericAnimation {\n current?: number;\n}\n\nexport type AnimationCallback = (\n finished?: boolean,\n current?: AnimatableValue\n) => void;\n\nexport type Timestamp = number;\n\nexport type Value3D = {\n x: number;\n y: number;\n z: number;\n interfaceOrientation: InterfaceOrientation;\n};\n\nexport type ValueRotation = {\n qw: number;\n qx: number;\n qy: number;\n qz: number;\n yaw: number;\n pitch: number;\n roll: number;\n interfaceOrientation: InterfaceOrientation;\n};\n\nexport enum InterfaceOrientation {\n ROTATION_0 = 0,\n ROTATION_90 = 90,\n ROTATION_180 = 180,\n ROTATION_270 = 270,\n}\n\nexport type ShadowNodeWrapper = object;\n\nexport enum KeyboardState {\n UNKNOWN = 0,\n OPENING = 1,\n OPEN = 2,\n CLOSING = 3,\n CLOSED = 4,\n}\n\nexport type AnimatedKeyboardInfo = {\n height: SharedValue<number>;\n state: SharedValue<KeyboardState>;\n};\n\nexport interface MeasuredDimensions {\n x: number;\n y: number;\n width: number;\n height: number;\n pageX: number;\n pageY: number;\n}\n\nexport interface AnimatedKeyboardOptions {\n isStatusBarTranslucentAndroid?: boolean;\n}\n"],"mappings":";;;;;;AAmDA;AACA;AACA;AACA;AACA;AACA;AACA;IAyFYA,U;;;WAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;GAAAA,U,0BAAAA,U;;IAOAC,iB;;;WAAAA,iB;EAAAA,iB,CAAAA,iB;EAAAA,iB,CAAAA,iB;EAAAA,iB,CAAAA,iB;EAAAA,iB,CAAAA,iB;EAAAA,iB,CAAAA,iB;GAAAA,iB,iCAAAA,iB;;IAqCAC,oB;;;WAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,oCAAAA,oB;;IASAC,a;;;WAAAA,a;EAAAA,a,CAAAA,a;EAAAA,a,CAAAA,a;EAAAA,a,CAAAA,a;EAAAA,a,CAAAA,a;EAAAA,a,CAAAA,a;GAAAA,a,6BAAAA,a"}
@@ -23,11 +23,12 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
23
23
 
24
24
  const AnimatedFlatList = (0, _createAnimatedComponent.default)(_reactNative.FlatList);
25
25
 
26
- const createCellRenderer = itemLayoutAnimation => {
26
+ const createCellRenderer = (itemLayoutAnimation, cellStyle) => {
27
27
  const cellRenderer = props => {
28
28
  return /*#__PURE__*/_react.default.createElement(_View.default, {
29
29
  layout: itemLayoutAnimation,
30
- onLayout: props.onLayout
30
+ onLayout: props.onLayout,
31
+ style: cellStyle
31
32
  }, props.children);
32
33
  };
33
34
 
@@ -39,8 +40,9 @@ const ReanimatedFlatlist = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
39
40
  itemLayoutAnimation,
40
41
  ...restProps
41
42
  } = props;
43
+ const cellStyle = restProps !== null && restProps !== void 0 && restProps.inverted ? restProps !== null && restProps !== void 0 && restProps.horizontal ? styles.horizontallyInverted : styles.verticallyInverted : undefined;
42
44
 
43
- const cellRenderer = _react.default.useMemo(() => createCellRenderer(itemLayoutAnimation), []);
45
+ const cellRenderer = _react.default.useMemo(() => createCellRenderer(itemLayoutAnimation, cellStyle), [cellStyle]);
44
46
 
45
47
  return /*#__PURE__*/_react.default.createElement(AnimatedFlatList, _extends({
46
48
  ref: ref
@@ -48,6 +50,20 @@ const ReanimatedFlatlist = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
48
50
  CellRendererComponent: cellRenderer
49
51
  }));
50
52
  });
53
+
54
+ const styles = _reactNative.StyleSheet.create({
55
+ verticallyInverted: {
56
+ transform: [{
57
+ scaleY: -1
58
+ }]
59
+ },
60
+ horizontallyInverted: {
61
+ transform: [{
62
+ scaleX: -1
63
+ }]
64
+ }
65
+ });
66
+
51
67
  var _default = ReanimatedFlatlist;
52
68
  exports.default = _default;
53
69
  //# sourceMappingURL=FlatList.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["AnimatedFlatList","createAnimatedComponent","FlatList","createCellRenderer","itemLayoutAnimation","cellRenderer","props","onLayout","children","ReanimatedFlatlist","forwardRef","ref","restProps","React","useMemo"],"sources":["FlatList.tsx"],"sourcesContent":["import React, { ForwardedRef, forwardRef } from 'react';\nimport { FlatList, FlatListProps, LayoutChangeEvent } from 'react-native';\nimport ReanimatedView from './View';\nimport createAnimatedComponent from '../../createAnimatedComponent';\nimport { ILayoutAnimationBuilder } from '../layoutReanimation/animationBuilder/commonTypes';\n\nconst AnimatedFlatList = createAnimatedComponent(FlatList as any) as any;\n\ninterface AnimatedFlatListProps {\n onLayout: (event: LayoutChangeEvent) => void;\n // implicit `children` prop has been removed in @types/react^18.0.0\n children: React.ReactNode;\n}\n\nconst createCellRenderer = (itemLayoutAnimation?: ILayoutAnimationBuilder) => {\n const cellRenderer = (props: AnimatedFlatListProps) => {\n return (\n <ReanimatedView layout={itemLayoutAnimation} onLayout={props.onLayout}>\n {props.children}\n </ReanimatedView>\n );\n };\n\n return cellRenderer;\n};\n\nexport interface ReanimatedFlatListProps<ItemT> extends FlatListProps<ItemT> {\n itemLayoutAnimation?: ILayoutAnimationBuilder;\n}\n\ntype ReanimatedFlatListFC<T = any> = React.FC<ReanimatedFlatListProps<T>>;\n\nconst ReanimatedFlatlist: ReanimatedFlatListFC = forwardRef(\n (props: ReanimatedFlatListProps<any>, ref: ForwardedRef<FlatList>) => {\n const { itemLayoutAnimation, ...restProps } = props;\n\n const cellRenderer = React.useMemo(\n () => createCellRenderer(itemLayoutAnimation),\n []\n );\n\n return (\n <AnimatedFlatList\n ref={ref}\n {...restProps}\n CellRendererComponent={cellRenderer}\n />\n );\n }\n);\n\nexport default ReanimatedFlatlist;\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;AAGA,MAAMA,gBAAgB,GAAG,IAAAC,gCAAA,EAAwBC,qBAAxB,CAAzB;;AAQA,MAAMC,kBAAkB,GAAIC,mBAAD,IAAmD;EAC5E,MAAMC,YAAY,GAAIC,KAAD,IAAkC;IACrD,oBACE,6BAAC,aAAD;MAAgB,MAAM,EAAEF,mBAAxB;MAA6C,QAAQ,EAAEE,KAAK,CAACC;IAA7D,GACGD,KAAK,CAACE,QADT,CADF;EAKD,CAND;;EAQA,OAAOH,YAAP;AACD,CAVD;;AAkBA,MAAMI,kBAAwC,gBAAG,IAAAC,iBAAA,EAC/C,CAACJ,KAAD,EAAsCK,GAAtC,KAAsE;EACpE,MAAM;IAAEP,mBAAF;IAAuB,GAAGQ;EAA1B,IAAwCN,KAA9C;;EAEA,MAAMD,YAAY,GAAGQ,cAAA,CAAMC,OAAN,CACnB,MAAMX,kBAAkB,CAACC,mBAAD,CADL,EAEnB,EAFmB,CAArB;;EAKA,oBACE,6BAAC,gBAAD;IACE,GAAG,EAAEO;EADP,GAEMC,SAFN;IAGE,qBAAqB,EAAEP;EAHzB,GADF;AAOD,CAhB8C,CAAjD;eAmBeI,kB"}
1
+ {"version":3,"names":["AnimatedFlatList","createAnimatedComponent","FlatList","createCellRenderer","itemLayoutAnimation","cellStyle","cellRenderer","props","onLayout","children","ReanimatedFlatlist","forwardRef","ref","restProps","inverted","horizontal","styles","horizontallyInverted","verticallyInverted","undefined","React","useMemo","StyleSheet","create","transform","scaleY","scaleX"],"sources":["FlatList.tsx"],"sourcesContent":["import React, { ForwardedRef, forwardRef } from 'react';\nimport {\n FlatList,\n FlatListProps,\n LayoutChangeEvent,\n StyleSheet,\n} from 'react-native';\nimport ReanimatedView from './View';\nimport createAnimatedComponent from '../../createAnimatedComponent';\nimport { ILayoutAnimationBuilder } from '../layoutReanimation/animationBuilder/commonTypes';\nimport { StyleProps } from '../commonTypes';\n\nconst AnimatedFlatList = createAnimatedComponent(FlatList as any) as any;\n\ninterface AnimatedFlatListProps {\n onLayout: (event: LayoutChangeEvent) => void;\n // implicit `children` prop has been removed in @types/react^18.0.0\n children: React.ReactNode;\n inverted?: boolean;\n horizontal?: boolean;\n}\n\nconst createCellRenderer = (\n itemLayoutAnimation?: ILayoutAnimationBuilder,\n cellStyle?: StyleProps\n) => {\n const cellRenderer = (props: AnimatedFlatListProps) => {\n return (\n <ReanimatedView\n layout={itemLayoutAnimation}\n onLayout={props.onLayout}\n style={cellStyle}>\n {props.children}\n </ReanimatedView>\n );\n };\n\n return cellRenderer;\n};\n\nexport interface ReanimatedFlatListProps<ItemT> extends FlatListProps<ItemT> {\n itemLayoutAnimation?: ILayoutAnimationBuilder;\n}\n\ntype ReanimatedFlatListFC<T = any> = React.FC<ReanimatedFlatListProps<T>>;\n\nconst ReanimatedFlatlist: ReanimatedFlatListFC = forwardRef(\n (props: ReanimatedFlatListProps<any>, ref: ForwardedRef<FlatList>) => {\n const { itemLayoutAnimation, ...restProps } = props;\n\n const cellStyle = restProps?.inverted\n ? restProps?.horizontal\n ? styles.horizontallyInverted\n : styles.verticallyInverted\n : undefined;\n\n const cellRenderer = React.useMemo(\n () => createCellRenderer(itemLayoutAnimation, cellStyle),\n [cellStyle]\n );\n\n return (\n <AnimatedFlatList\n ref={ref}\n {...restProps}\n CellRendererComponent={cellRenderer}\n />\n );\n }\n);\n\nconst styles = StyleSheet.create({\n verticallyInverted: { transform: [{ scaleY: -1 }] },\n horizontallyInverted: { transform: [{ scaleX: -1 }] },\n});\n\nexport default ReanimatedFlatlist;\n"],"mappings":";;;;;;;AAAA;;AACA;;AAMA;;AACA;;;;;;;;;;AAIA,MAAMA,gBAAgB,GAAG,IAAAC,gCAAA,EAAwBC,qBAAxB,CAAzB;;AAUA,MAAMC,kBAAkB,GAAG,CACzBC,mBADyB,EAEzBC,SAFyB,KAGtB;EACH,MAAMC,YAAY,GAAIC,KAAD,IAAkC;IACrD,oBACE,6BAAC,aAAD;MACE,MAAM,EAAEH,mBADV;MAEE,QAAQ,EAAEG,KAAK,CAACC,QAFlB;MAGE,KAAK,EAAEH;IAHT,GAIGE,KAAK,CAACE,QAJT,CADF;EAQD,CATD;;EAWA,OAAOH,YAAP;AACD,CAhBD;;AAwBA,MAAMI,kBAAwC,gBAAG,IAAAC,iBAAA,EAC/C,CAACJ,KAAD,EAAsCK,GAAtC,KAAsE;EACpE,MAAM;IAAER,mBAAF;IAAuB,GAAGS;EAA1B,IAAwCN,KAA9C;EAEA,MAAMF,SAAS,GAAGQ,SAAS,SAAT,IAAAA,SAAS,WAAT,IAAAA,SAAS,CAAEC,QAAX,GACdD,SAAS,SAAT,IAAAA,SAAS,WAAT,IAAAA,SAAS,CAAEE,UAAX,GACEC,MAAM,CAACC,oBADT,GAEED,MAAM,CAACE,kBAHK,GAIdC,SAJJ;;EAMA,MAAMb,YAAY,GAAGc,cAAA,CAAMC,OAAN,CACnB,MAAMlB,kBAAkB,CAACC,mBAAD,EAAsBC,SAAtB,CADL,EAEnB,CAACA,SAAD,CAFmB,CAArB;;EAKA,oBACE,6BAAC,gBAAD;IACE,GAAG,EAAEO;EADP,GAEMC,SAFN;IAGE,qBAAqB,EAAEP;EAHzB,GADF;AAOD,CAtB8C,CAAjD;;AAyBA,MAAMU,MAAM,GAAGM,uBAAA,CAAWC,MAAX,CAAkB;EAC/BL,kBAAkB,EAAE;IAAEM,SAAS,EAAE,CAAC;MAAEC,MAAM,EAAE,CAAC;IAAX,CAAD;EAAb,CADW;EAE/BR,oBAAoB,EAAE;IAAEO,SAAS,EAAE,CAAC;MAAEE,MAAM,EAAE,CAAC;IAAX,CAAD;EAAb;AAFS,CAAlB,CAAf;;eAKehB,kB"}
@@ -7,12 +7,6 @@ exports.checkPluginState = void 0;
7
7
  exports.configureLayoutAnimations = configureLayoutAnimations;
8
8
  exports.configureProps = configureProps;
9
9
  exports.enableLayoutAnimations = enableLayoutAnimations;
10
- Object.defineProperty(exports, "getTimestamp", {
11
- enumerable: true,
12
- get: function () {
13
- return _time.getTimestamp;
14
- }
15
- });
16
10
  exports.getViewProp = getViewProp;
17
11
  exports.makeShareable = exports.makeRemote = exports.makeMutable = exports.isConfiguredCheck = exports.isConfigured = void 0;
18
12
  exports.registerEventHandler = registerEventHandler;
@@ -47,22 +41,15 @@ var _PlatformChecker = require("./PlatformChecker");
47
41
 
48
42
  var _shareables = require("./shareables");
49
43
 
50
- var _threads = require("./threads");
51
-
52
44
  var _mappers = require("./mappers");
53
45
 
54
46
  var _mutables = require("./mutables");
55
47
 
56
- var _time = require("./time");
48
+ var _initializers = require("./initializers");
57
49
 
58
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
50
+ var _threads = require("./threads");
59
51
 
60
- /* global _setGlobalConsole */
61
- if (global._setGlobalConsole === undefined) {
62
- // it can happen when Reanimated plugin wasn't added, but the user uses the only API from version 1
63
- global._setGlobalConsole = () => {// noop
64
- };
65
- }
52
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
66
53
 
67
54
  const testWorklet = () => {
68
55
  'worklet';
@@ -136,96 +123,58 @@ function getViewProp(viewTag, propName) {
136
123
  });
137
124
  }
138
125
 
139
- function valueUnpacker(objectToUnpack, category) {
140
- 'worklet';
141
-
142
- let workletsCache = global.__workletsCache;
143
- let handleCache = global.__handleCache;
144
-
145
- if (workletsCache === undefined) {
146
- // init
147
- workletsCache = global.__workletsCache = new Map();
148
- handleCache = global.__handleCache = new WeakMap();
149
- }
150
-
151
- if (objectToUnpack.__workletHash) {
152
- let workletFun = workletsCache.get(objectToUnpack.__workletHash);
153
-
154
- if (workletFun === undefined) {
155
- // eslint-disable-next-line no-eval
156
- workletFun = eval('(' + objectToUnpack.asString + '\n)');
157
- workletsCache.set(objectToUnpack.__workletHash, workletFun);
158
- }
159
-
160
- const functionInstance = workletFun.bind(objectToUnpack);
161
- objectToUnpack._recur = functionInstance;
162
- return functionInstance;
163
- } else if (objectToUnpack.__init) {
164
- let value = handleCache.get(objectToUnpack);
165
-
166
- if (value === undefined) {
167
- value = objectToUnpack.__init();
168
- handleCache.set(objectToUnpack, value);
169
- }
126
+ function registerEventHandler(eventHash, eventHandler) {
127
+ function handleAndFlushImmediates(eventTimestamp, event) {
128
+ 'worklet';
170
129
 
171
- return value;
172
- } else if (category === 'RemoteFunction') {
173
- const fun = () => {
174
- throw new Error(`Tried to synchronously call a non-worklet function on the UI thread.
130
+ global.__frameTimestamp = eventTimestamp;
131
+ eventHandler(event);
175
132
 
176
- Possible solutions are:
177
- a) If you want to synchronously execute this method, mark it as a worklet
178
- b) If you want to execute this function on the JS thread, wrap it using \`runOnJS\``);
179
- };
133
+ global.__flushAnimationFrame(eventTimestamp);
180
134
 
181
- fun.__remoteFunction = objectToUnpack;
182
- return fun;
183
- } else {
184
- throw new Error('data type not recognized by unpack method');
135
+ global.__frameTimestamp = undefined;
185
136
  }
186
- }
187
137
 
188
- function registerEventHandler(eventHash, eventHandler) {
189
- return _NativeReanimated.default.registerEventHandler(eventHash, (0, _shareables.makeShareableCloneRecursive)(eventHandler));
138
+ return _NativeReanimated.default.registerEventHandler(eventHash, (0, _shareables.makeShareableCloneRecursive)(handleAndFlushImmediates));
190
139
  }
191
140
 
192
141
  function unregisterEventHandler(id) {
193
142
  return _NativeReanimated.default.unregisterEventHandler(id);
194
143
  }
195
144
 
196
- function subscribeForKeyboardEvents(eventHandler) {
197
- return _NativeReanimated.default.subscribeForKeyboardEvents((0, _shareables.makeShareableCloneRecursive)(eventHandler));
145
+ function subscribeForKeyboardEvents(eventHandler, options) {
146
+ // TODO: this should really go with the same code path as other events, that is
147
+ // via registerEventHandler. For now we are copying the code from there.
148
+ function handleAndFlushImmediates(state, height) {
149
+ 'worklet';
150
+
151
+ const now = performance.now();
152
+ global.__frameTimestamp = now;
153
+ eventHandler(state, height);
154
+
155
+ global.__flushAnimationFrame(now);
156
+
157
+ global.__frameTimestamp = undefined;
158
+ }
159
+
160
+ return _NativeReanimated.default.subscribeForKeyboardEvents((0, _shareables.makeShareableCloneRecursive)(handleAndFlushImmediates), options.isStatusBarTranslucentAndroid ?? false);
198
161
  }
199
162
 
200
163
  function unsubscribeFromKeyboardEvents(listenerId) {
201
164
  return _NativeReanimated.default.unsubscribeFromKeyboardEvents(listenerId);
202
165
  }
203
166
 
204
- function registerSensor(sensorType, interval, eventHandler) {
205
- return _NativeReanimated.default.registerSensor(sensorType, interval, (0, _shareables.makeShareableCloneRecursive)(eventHandler));
167
+ function registerSensor(sensorType, interval, iosReferenceFrame, eventHandler) {
168
+ return _NativeReanimated.default.registerSensor(sensorType, interval, iosReferenceFrame, (0, _shareables.makeShareableCloneRecursive)(eventHandler));
206
169
  }
207
170
 
208
171
  function unregisterSensor(listenerId) {
209
172
  return _NativeReanimated.default.unregisterSensor(listenerId);
210
- }
173
+ } // initialize UI runtime if applicable
211
174
 
212
- _NativeReanimated.default.installCoreFunctions(valueUnpacker);
213
175
 
214
176
  if (!(0, _PlatformChecker.isWeb)() && isConfigured()) {
215
- const capturableConsole = console;
216
- (0, _threads.runOnUI)(() => {
217
- 'worklet';
218
-
219
- const console = {
220
- debug: (0, _threads.runOnJS)(capturableConsole.debug),
221
- log: (0, _threads.runOnJS)(capturableConsole.log),
222
- warn: (0, _threads.runOnJS)(capturableConsole.warn),
223
- error: (0, _threads.runOnJS)(capturableConsole.error),
224
- info: (0, _threads.runOnJS)(capturableConsole.info)
225
- };
226
-
227
- _setGlobalConsole(console);
228
- })();
177
+ (0, _initializers.initializeUIRuntime)();
229
178
  }
230
179
 
231
180
  let featuresConfig = {
@@ -251,7 +200,9 @@ function enableLayoutAnimations(flag) {
251
200
  }
252
201
 
253
202
  function configureLayoutAnimations(viewTag, type, config) {
254
- _NativeReanimated.default.configureLayoutAnimation(viewTag, type, (0, _shareables.makeShareableCloneRecursive)(config));
203
+ let sharedTransitionTag = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
204
+
205
+ _NativeReanimated.default.configureLayoutAnimation(viewTag, type, sharedTransitionTag, (0, _shareables.makeShareableCloneRecursive)(config));
255
206
  }
256
207
 
257
208
  function configureProps(uiProps, nativeProps) {
@@ -1 +1 @@
1
- {"version":3,"names":["global","_setGlobalConsole","undefined","testWorklet","throwUninitializedReanimatedException","Error","checkPluginState","throwError","__workletHash","shouldBeUseWeb","isConfigured","isConfiguredCheck","configurationCheckWrapper","__DEV__","fn","startMapper","startMapperUnwrapped","makeShareable","makeShareableUnwrapped","makeMutable","makeMutableUnwrapped","makeRemote","makeRemoteUnwrapped","_WORKLET","_log","s","console","log","getViewProp","viewTag","propName","_IS_FABRIC","Promise","resolve","reject","NativeReanimatedModule","result","substr","valueUnpacker","objectToUnpack","category","workletsCache","__workletsCache","handleCache","__handleCache","Map","WeakMap","workletFun","get","eval","asString","set","functionInstance","bind","_recur","__init","value","fun","__remoteFunction","registerEventHandler","eventHash","eventHandler","makeShareableCloneRecursive","unregisterEventHandler","id","subscribeForKeyboardEvents","unsubscribeFromKeyboardEvents","listenerId","registerSensor","sensorType","interval","unregisterSensor","installCoreFunctions","isWeb","capturableConsole","runOnUI","debug","runOnJS","warn","error","info","featuresConfig","enableLayoutAnimations","setByUser","flag","isCallByUser","configureLayoutAnimations","type","config","configureLayoutAnimation","configureProps","uiProps","nativeProps","nativeShouldBeMock"],"sources":["core.ts"],"sourcesContent":["/* global _setGlobalConsole */\nimport NativeReanimatedModule from './NativeReanimated';\nimport { nativeShouldBeMock, shouldBeUseWeb, isWeb } from './PlatformChecker';\nimport { BasicWorkletFunction, Value3D, ValueRotation } from './commonTypes';\nimport {\n makeShareableCloneRecursive,\n makeShareable as makeShareableUnwrapped,\n} from './shareables';\nimport { runOnUI, runOnJS } from './threads';\nimport { startMapper as startMapperUnwrapped } from './mappers';\nimport {\n makeMutable as makeMutableUnwrapped,\n makeRemote as makeRemoteUnwrapped,\n} from './mutables';\nimport { LayoutAnimationFunction } from './layoutReanimation';\n\nexport { stopMapper } from './mappers';\nexport { runOnJS, runOnUI } from './threads';\nexport { getTimestamp } from './time';\n\nif (global._setGlobalConsole === undefined) {\n // it can happen when Reanimated plugin wasn't added, but the user uses the only API from version 1\n global._setGlobalConsole = () => {\n // noop\n };\n}\n\nexport type ReanimatedConsole = Pick<\n Console,\n 'debug' | 'log' | 'warn' | 'info' | 'error'\n>;\n\nconst testWorklet: BasicWorkletFunction<void> = () => {\n 'worklet';\n};\n\nconst throwUninitializedReanimatedException = () => {\n throw new Error(\n \"Failed to initialize react-native-reanimated library, make sure you followed installation steps here: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/ \\n1) Make sure reanimated's babel plugin is installed in your babel.config.js (you should have 'react-native-reanimated/plugin' listed there - also see the above link for details) \\n2) Make sure you reset build cache after updating the config, run: yarn start --reset-cache\"\n );\n};\n\nexport const checkPluginState: (throwError: boolean) => boolean = (\n throwError = true\n) => {\n if (!testWorklet.__workletHash && !shouldBeUseWeb()) {\n if (throwError) {\n throwUninitializedReanimatedException();\n }\n return false;\n }\n return true;\n};\n\nexport const isConfigured: (throwError?: boolean) => boolean = (\n throwError = false\n) => {\n return checkPluginState(throwError);\n};\n\nexport const isConfiguredCheck: () => void = () => {\n checkPluginState(true);\n};\n\nconst configurationCheckWrapper = __DEV__\n ? <T extends Array<any>, U>(fn: (...args: T) => U) => {\n return (...args: T): U => {\n isConfigured(true);\n return fn(...args);\n };\n }\n : <T extends Array<any>, U>(fn: (...args: T) => U) => fn;\n\nexport const startMapper = __DEV__\n ? configurationCheckWrapper(startMapperUnwrapped)\n : startMapperUnwrapped;\n\nexport const makeShareable = __DEV__\n ? configurationCheckWrapper(makeShareableUnwrapped)\n : makeShareableUnwrapped;\n\nexport const makeMutable = __DEV__\n ? configurationCheckWrapper(makeMutableUnwrapped)\n : makeMutableUnwrapped;\n\nexport const makeRemote = __DEV__\n ? configurationCheckWrapper(makeRemoteUnwrapped)\n : makeRemoteUnwrapped;\n\nglobal._WORKLET = false;\nglobal._log = function (s: string) {\n console.log(s);\n};\n\nexport function getViewProp<T>(viewTag: string, propName: string): Promise<T> {\n if (global._IS_FABRIC) {\n throw new Error(\n '[react-native-reanimated] `getViewProp` is not supported on Fabric yet'\n );\n }\n\n return new Promise((resolve, reject) => {\n return NativeReanimatedModule.getViewProp(\n viewTag,\n propName,\n (result: T) => {\n if (typeof result === 'string' && result.substr(0, 6) === 'error:') {\n reject(result);\n } else {\n resolve(result);\n }\n }\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 if (objectToUnpack.__workletHash) {\n let workletFun = workletsCache.get(objectToUnpack.__workletHash);\n if (workletFun === undefined) {\n // eslint-disable-next-line no-eval\n workletFun = eval('(' + objectToUnpack.asString + '\\n)') as (\n ...args: any[]\n ) => any;\n workletsCache.set(objectToUnpack.__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\nexport function registerEventHandler<T>(\n eventHash: string,\n eventHandler: (event: T) => void\n): string {\n return NativeReanimatedModule.registerEventHandler(\n eventHash,\n makeShareableCloneRecursive(eventHandler)\n );\n}\n\nexport function unregisterEventHandler(id: string): void {\n return NativeReanimatedModule.unregisterEventHandler(id);\n}\n\nexport function subscribeForKeyboardEvents(\n eventHandler: (state: number, height: number) => void\n): number {\n return NativeReanimatedModule.subscribeForKeyboardEvents(\n makeShareableCloneRecursive(eventHandler)\n );\n}\n\nexport function unsubscribeFromKeyboardEvents(listenerId: number): void {\n return NativeReanimatedModule.unsubscribeFromKeyboardEvents(listenerId);\n}\n\nexport function registerSensor(\n sensorType: number,\n interval: number,\n eventHandler: (data: Value3D | ValueRotation) => void\n): number {\n return NativeReanimatedModule.registerSensor(\n sensorType,\n interval,\n makeShareableCloneRecursive(eventHandler)\n );\n}\n\nexport function unregisterSensor(listenerId: number): void {\n return NativeReanimatedModule.unregisterSensor(listenerId);\n}\n\nNativeReanimatedModule.installCoreFunctions(valueUnpacker);\n\nif (!isWeb() && isConfigured()) {\n const capturableConsole = console;\n runOnUI(() => {\n 'worklet';\n const 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 _setGlobalConsole(console);\n })();\n}\n\ntype FeaturesConfig = {\n enableLayoutAnimations: boolean;\n setByUser: boolean;\n};\n\nlet featuresConfig: FeaturesConfig = {\n enableLayoutAnimations: false,\n setByUser: false,\n};\n\nexport function enableLayoutAnimations(\n flag: boolean,\n isCallByUser = true\n): void {\n if (isCallByUser) {\n featuresConfig = {\n enableLayoutAnimations: flag,\n setByUser: true,\n };\n NativeReanimatedModule.enableLayoutAnimations(flag);\n } else if (\n !featuresConfig.setByUser &&\n featuresConfig.enableLayoutAnimations !== flag\n ) {\n featuresConfig.enableLayoutAnimations = flag;\n NativeReanimatedModule.enableLayoutAnimations(flag);\n }\n}\n\nexport function configureLayoutAnimations(\n viewTag: number,\n type: string,\n config: LayoutAnimationFunction | Keyframe\n): void {\n NativeReanimatedModule.configureLayoutAnimation(\n viewTag,\n type,\n makeShareableCloneRecursive(config)\n );\n}\n\nexport function configureProps(uiProps: string[], nativeProps: string[]): void {\n if (!nativeShouldBeMock()) {\n NativeReanimatedModule.configureProps(uiProps, nativeProps);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;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;EAAA,IADNC,YACM,uEADS,IACT;;EACN,IAAIA,YAAJ,EAAkB;IAChBJ,cAAc,GAAG;MACfC,sBAAsB,EAAEE,IADT;MAEfD,SAAS,EAAE;IAFI,CAAjB;;IAIAhD,yBAAA,CAAuB+C,sBAAvB,CAA8CE,IAA9C;EACD,CAND,MAMO,IACL,CAACH,cAAc,CAACE,SAAhB,IACAF,cAAc,CAACC,sBAAf,KAA0CE,IAFrC,EAGL;IACAH,cAAc,CAACC,sBAAf,GAAwCE,IAAxC;;IACAjD,yBAAA,CAAuB+C,sBAAvB,CAA8CE,IAA9C;EACD;AACF;;AAEM,SAASE,yBAAT,CACLzD,OADK,EAEL0D,IAFK,EAGLC,MAHK,EAIC;EACNrD,yBAAA,CAAuBsD,wBAAvB,CACE5D,OADF,EAEE0D,IAFF,EAGE,IAAAzB,uCAAA,EAA4B0B,MAA5B,CAHF;AAKD;;AAEM,SAASE,cAAT,CAAwBC,OAAxB,EAA2CC,WAA3C,EAAwE;EAC7E,IAAI,CAAC,IAAAC,mCAAA,GAAL,EAA2B;IACzB1D,yBAAA,CAAuBuD,cAAvB,CAAsCC,OAAtC,EAA+CC,WAA/C;EACD;AACF"}
1
+ {"version":3,"names":["testWorklet","throwUninitializedReanimatedException","Error","checkPluginState","throwError","__workletHash","shouldBeUseWeb","isConfigured","isConfiguredCheck","configurationCheckWrapper","__DEV__","fn","startMapper","startMapperUnwrapped","makeShareable","makeShareableUnwrapped","makeMutable","makeMutableUnwrapped","makeRemote","makeRemoteUnwrapped","global","_WORKLET","_log","s","console","log","getViewProp","viewTag","propName","_IS_FABRIC","Promise","resolve","reject","NativeReanimatedModule","result","substr","registerEventHandler","eventHash","eventHandler","handleAndFlushImmediates","eventTimestamp","event","__frameTimestamp","__flushAnimationFrame","undefined","makeShareableCloneRecursive","unregisterEventHandler","id","subscribeForKeyboardEvents","options","state","height","now","performance","isStatusBarTranslucentAndroid","unsubscribeFromKeyboardEvents","listenerId","registerSensor","sensorType","interval","iosReferenceFrame","unregisterSensor","isWeb","initializeUIRuntime","featuresConfig","enableLayoutAnimations","setByUser","flag","isCallByUser","configureLayoutAnimations","type","config","sharedTransitionTag","configureLayoutAnimation","configureProps","uiProps","nativeProps","nativeShouldBeMock"],"sources":["core.ts"],"sourcesContent":["import NativeReanimatedModule from './NativeReanimated';\nimport { nativeShouldBeMock, shouldBeUseWeb, isWeb } from './PlatformChecker';\nimport {\n AnimatedKeyboardOptions,\n BasicWorkletFunction,\n Value3D,\n ValueRotation,\n} from './commonTypes';\nimport {\n makeShareableCloneRecursive,\n makeShareable as makeShareableUnwrapped,\n} from './shareables';\nimport { startMapper as startMapperUnwrapped } from './mappers';\nimport {\n makeMutable as makeMutableUnwrapped,\n makeRemote as makeRemoteUnwrapped,\n} from './mutables';\nimport {\n LayoutAnimationFunction,\n LayoutAnimationType,\n} from './layoutReanimation';\nimport { initializeUIRuntime } from './initializers';\n\nexport { stopMapper } from './mappers';\nexport { runOnJS, runOnUI } from './threads';\n\nexport type ReanimatedConsole = Pick<\n Console,\n 'debug' | 'log' | 'warn' | 'info' | 'error'\n>;\n\nconst testWorklet: BasicWorkletFunction<void> = () => {\n 'worklet';\n};\n\nconst throwUninitializedReanimatedException = () => {\n throw new Error(\n \"Failed to initialize react-native-reanimated library, make sure you followed installation steps here: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/ \\n1) Make sure reanimated's babel plugin is installed in your babel.config.js (you should have 'react-native-reanimated/plugin' listed there - also see the above link for details) \\n2) Make sure you reset build cache after updating the config, run: yarn start --reset-cache\"\n );\n};\n\nexport const checkPluginState: (throwError: boolean) => boolean = (\n throwError = true\n) => {\n if (!testWorklet.__workletHash && !shouldBeUseWeb()) {\n if (throwError) {\n throwUninitializedReanimatedException();\n }\n return false;\n }\n return true;\n};\n\nexport const isConfigured: (throwError?: boolean) => boolean = (\n throwError = false\n) => {\n return checkPluginState(throwError);\n};\n\nexport const isConfiguredCheck: () => void = () => {\n checkPluginState(true);\n};\n\nconst configurationCheckWrapper = __DEV__\n ? <T extends Array<any>, U>(fn: (...args: T) => U) => {\n return (...args: T): U => {\n isConfigured(true);\n return fn(...args);\n };\n }\n : <T extends Array<any>, U>(fn: (...args: T) => U) => fn;\n\nexport const startMapper = __DEV__\n ? configurationCheckWrapper(startMapperUnwrapped)\n : startMapperUnwrapped;\n\nexport const makeShareable = __DEV__\n ? configurationCheckWrapper(makeShareableUnwrapped)\n : makeShareableUnwrapped;\n\nexport const makeMutable = __DEV__\n ? configurationCheckWrapper(makeMutableUnwrapped)\n : makeMutableUnwrapped;\n\nexport const makeRemote = __DEV__\n ? configurationCheckWrapper(makeRemoteUnwrapped)\n : makeRemoteUnwrapped;\n\nglobal._WORKLET = false;\nglobal._log = function (s: string) {\n console.log(s);\n};\n\nexport function getViewProp<T>(viewTag: string, propName: string): Promise<T> {\n if (global._IS_FABRIC) {\n throw new Error(\n '[react-native-reanimated] `getViewProp` is not supported on Fabric yet'\n );\n }\n\n return new Promise((resolve, reject) => {\n return NativeReanimatedModule.getViewProp(\n viewTag,\n propName,\n (result: T) => {\n if (typeof result === 'string' && result.substr(0, 6) === 'error:') {\n reject(result);\n } else {\n resolve(result);\n }\n }\n );\n });\n}\n\nexport function registerEventHandler<T>(\n eventHash: string,\n eventHandler: (event: T) => void\n): string {\n function handleAndFlushImmediates(eventTimestamp: number, event: T) {\n 'worklet';\n global.__frameTimestamp = eventTimestamp;\n eventHandler(event);\n global.__flushAnimationFrame(eventTimestamp);\n global.__frameTimestamp = undefined;\n }\n return NativeReanimatedModule.registerEventHandler(\n eventHash,\n makeShareableCloneRecursive(handleAndFlushImmediates)\n );\n}\n\nexport function unregisterEventHandler(id: string): void {\n return NativeReanimatedModule.unregisterEventHandler(id);\n}\n\nexport function subscribeForKeyboardEvents(\n eventHandler: (state: number, height: number) => void,\n options: AnimatedKeyboardOptions\n): number {\n // TODO: this should really go with the same code path as other events, that is\n // via registerEventHandler. For now we are copying the code from there.\n function handleAndFlushImmediates(state: number, height: number) {\n 'worklet';\n const now = performance.now();\n global.__frameTimestamp = now;\n eventHandler(state, height);\n global.__flushAnimationFrame(now);\n global.__frameTimestamp = undefined;\n }\n return NativeReanimatedModule.subscribeForKeyboardEvents(\n makeShareableCloneRecursive(handleAndFlushImmediates),\n options.isStatusBarTranslucentAndroid ?? false\n );\n}\n\nexport function unsubscribeFromKeyboardEvents(listenerId: number): void {\n return NativeReanimatedModule.unsubscribeFromKeyboardEvents(listenerId);\n}\n\nexport function registerSensor(\n sensorType: number,\n interval: number,\n iosReferenceFrame: number,\n eventHandler: (\n data: Value3D | ValueRotation,\n orientationDegrees: number\n ) => void\n): number {\n return NativeReanimatedModule.registerSensor(\n sensorType,\n interval,\n iosReferenceFrame,\n makeShareableCloneRecursive(eventHandler)\n );\n}\n\nexport function unregisterSensor(listenerId: number): void {\n return NativeReanimatedModule.unregisterSensor(listenerId);\n}\n\n// initialize UI runtime if applicable\nif (!isWeb() && isConfigured()) {\n initializeUIRuntime();\n}\n\ntype FeaturesConfig = {\n enableLayoutAnimations: boolean;\n setByUser: boolean;\n};\n\nlet featuresConfig: FeaturesConfig = {\n enableLayoutAnimations: false,\n setByUser: false,\n};\n\nexport function enableLayoutAnimations(\n flag: boolean,\n isCallByUser = true\n): void {\n if (isCallByUser) {\n featuresConfig = {\n enableLayoutAnimations: flag,\n setByUser: true,\n };\n NativeReanimatedModule.enableLayoutAnimations(flag);\n } else if (\n !featuresConfig.setByUser &&\n featuresConfig.enableLayoutAnimations !== flag\n ) {\n featuresConfig.enableLayoutAnimations = flag;\n NativeReanimatedModule.enableLayoutAnimations(flag);\n }\n}\n\nexport function configureLayoutAnimations(\n viewTag: number,\n type: LayoutAnimationType,\n config: LayoutAnimationFunction | Keyframe,\n sharedTransitionTag = ''\n): void {\n NativeReanimatedModule.configureLayoutAnimation(\n viewTag,\n type,\n sharedTransitionTag,\n makeShareableCloneRecursive(config)\n );\n}\n\nexport function configureProps(uiProps: string[], nativeProps: string[]): void {\n if (!nativeShouldBeMock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AjB;;IAIAjC,yBAAA,CAAuBgC,sBAAvB,CAA8CE,IAA9C;EACD,CAND,MAMO,IACL,CAACH,cAAc,CAACE,SAAhB,IACAF,cAAc,CAACC,sBAAf,KAA0CE,IAFrC,EAGL;IACAH,cAAc,CAACC,sBAAf,GAAwCE,IAAxC;;IACAlC,yBAAA,CAAuBgC,sBAAvB,CAA8CE,IAA9C;EACD;AACF;;AAEM,SAASE,yBAAT,CACL1C,OADK,EAEL2C,IAFK,EAGLC,MAHK,EAKC;EAAA,IADNC,mBACM,uEADgB,EAChB;;EACNvC,yBAAA,CAAuBwC,wBAAvB,CACE9C,OADF,EAEE2C,IAFF,EAGEE,mBAHF,EAIE,IAAA3B,uCAAA,EAA4B0B,MAA5B,CAJF;AAMD;;AAEM,SAASG,cAAT,CAAwBC,OAAxB,EAA2CC,WAA3C,EAAwE;EAC7E,IAAI,CAAC,IAAAC,mCAAA,GAAL,EAA2B;IACzB5C,yBAAA,CAAuByC,cAAvB,CAAsCC,OAAtC,EAA+CC,WAA/C;EACD;AACF"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.registerWorkletStackDetails = registerWorkletStackDetails;
7
+ exports.reportFatalErrorOnJS = reportFatalErrorOnJS;
8
+
9
+ const _workletStackDetails = new Map();
10
+
11
+ function registerWorkletStackDetails(hash, stackDetails) {
12
+ _workletStackDetails.set(hash, stackDetails);
13
+ }
14
+
15
+ function getBundleOffset(error) {
16
+ var _error$stack, _error$stack$split;
17
+
18
+ const frame = (_error$stack = error.stack) === null || _error$stack === void 0 ? void 0 : (_error$stack$split = _error$stack.split('\n')) === null || _error$stack$split === void 0 ? void 0 : _error$stack$split[0];
19
+
20
+ if (frame) {
21
+ const parsedFrame = /@([^@]+):(\d+):(\d+)/.exec(frame);
22
+
23
+ if (parsedFrame) {
24
+ const [, file, line, col] = parsedFrame;
25
+ return [file, Number(line), Number(col)];
26
+ }
27
+ }
28
+
29
+ return ['unknown', 0, 0];
30
+ }
31
+
32
+ function processStack(stack) {
33
+ const workletStackEntries = stack.match(/worklet_(\d+):(\d+):(\d+)/g);
34
+ let result = stack;
35
+ workletStackEntries === null || workletStackEntries === void 0 ? void 0 : workletStackEntries.forEach(match => {
36
+ const [, hash, origLine, origCol] = match.split(/:|_/).map(Number);
37
+
38
+ const errorDetails = _workletStackDetails.get(hash);
39
+
40
+ if (!errorDetails) {
41
+ return;
42
+ }
43
+
44
+ const [error, lineOffset, colOffset] = errorDetails;
45
+ const [bundleFile, bundleLine, bundleCol] = getBundleOffset(error);
46
+ const line = origLine + bundleLine + lineOffset;
47
+ const col = origCol + bundleCol + colOffset;
48
+ result = result.replace(match, `${bundleFile}:${line}:${col}`);
49
+ });
50
+ return result;
51
+ }
52
+
53
+ function reportFatalErrorOnJS(_ref) {
54
+ let {
55
+ message,
56
+ stack
57
+ } = _ref;
58
+ const error = new Error();
59
+ error.message = message;
60
+ error.stack = stack ? processStack(stack) : undefined;
61
+ error.name = 'ReanimatedError'; // @ts-ignore React Native's ErrorUtils implementation extends the Error type with jsEngine field
62
+
63
+ error.jsEngine = 'reanimated';
64
+ global.ErrorUtils.reportFatalError(error);
65
+ }
66
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_workletStackDetails","Map","registerWorkletStackDetails","hash","stackDetails","set","getBundleOffset","error","frame","stack","split","parsedFrame","exec","file","line","col","Number","processStack","workletStackEntries","match","result","forEach","origLine","origCol","map","errorDetails","get","lineOffset","colOffset","bundleFile","bundleLine","bundleCol","replace","reportFatalErrorOnJS","message","Error","undefined","name","jsEngine","global","ErrorUtils","reportFatalError"],"sources":["errors.ts"],"sourcesContent":["type StackDetails = [Error, number, number];\n\nconst _workletStackDetails = new Map<number, StackDetails>();\n\nexport function registerWorkletStackDetails(\n hash: number,\n stackDetails: StackDetails\n) {\n _workletStackDetails.set(hash, stackDetails);\n}\n\nfunction getBundleOffset(error: Error): [string, number, number] {\n const frame = error.stack?.split('\\n')?.[0];\n if (frame) {\n const parsedFrame = /@([^@]+):(\\d+):(\\d+)/.exec(frame);\n if (parsedFrame) {\n const [, file, line, col] = parsedFrame;\n return [file, Number(line), Number(col)];\n }\n }\n return ['unknown', 0, 0];\n}\n\nfunction processStack(stack: string): string {\n const workletStackEntries = stack.match(/worklet_(\\d+):(\\d+):(\\d+)/g);\n let result = stack;\n workletStackEntries?.forEach((match) => {\n const [, hash, origLine, origCol] = match.split(/:|_/).map(Number);\n const errorDetails = _workletStackDetails.get(hash);\n if (!errorDetails) {\n return;\n }\n const [error, lineOffset, colOffset] = errorDetails;\n const [bundleFile, bundleLine, bundleCol] = getBundleOffset(error);\n const line = origLine + bundleLine + lineOffset;\n const col = origCol + bundleCol + colOffset;\n\n result = result.replace(match, `${bundleFile}:${line}:${col}`);\n });\n return result;\n}\n\nexport function reportFatalErrorOnJS({\n message,\n stack,\n}: {\n message: string;\n stack?: string;\n}) {\n const error = new Error();\n error.message = message;\n error.stack = stack ? processStack(stack) : undefined;\n error.name = 'ReanimatedError';\n // @ts-ignore React Native's ErrorUtils implementation extends the Error type with jsEngine field\n error.jsEngine = 'reanimated';\n global.ErrorUtils.reportFatalError(error);\n}\n"],"mappings":";;;;;;;;AAEA,MAAMA,oBAAoB,GAAG,IAAIC,GAAJ,EAA7B;;AAEO,SAASC,2BAAT,CACLC,IADK,EAELC,YAFK,EAGL;EACAJ,oBAAoB,CAACK,GAArB,CAAyBF,IAAzB,EAA+BC,YAA/B;AACD;;AAED,SAASE,eAAT,CAAyBC,KAAzB,EAAiE;EAAA;;EAC/D,MAAMC,KAAK,mBAAGD,KAAK,CAACE,KAAT,uEAAG,aAAaC,KAAb,CAAmB,IAAnB,CAAH,uDAAG,mBAA2B,CAA3B,CAAd;;EACA,IAAIF,KAAJ,EAAW;IACT,MAAMG,WAAW,GAAG,uBAAuBC,IAAvB,CAA4BJ,KAA5B,CAApB;;IACA,IAAIG,WAAJ,EAAiB;M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,KAAK,GAAG,IAAI4B,KAAJ,EAAd;EACA5B,KAAK,CAAC2B,OAAN,GAAgBA,OAAhB;EACA3B,KAAK,CAACE,KAAN,GAAcA,KAAK,GAAGQ,YAAY,CAACR,KAAD,CAAf,GAAyB2B,SAA5C;EACA7B,KAAK,CAAC8B,IAAN,GAAa,iBAAb,CAJC,CAKD;;EACA9B,KAAK,CAAC+B,QAAN,GAAiB,YAAjB;EACAC,MAAM,CAACC,UAAP,CAAkBC,gBAAlB,CAAmClC,KAAnC;AACD"}
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.prepareUIRegistry = void 0;
7
7
 
8
- var _core = require("../core");
8
+ var _threads = require("../threads");
9
9
 
10
- const prepareUIRegistry = (0, _core.runOnUI)(() => {
10
+ const prepareUIRegistry = (0, _threads.runOnUIImmediately)(() => {
11
11
  'worklet';
12
12
 
13
13
  const frameCallbackRegistry = {
@@ -1 +1 @@
1
- {"version":3,"names":["prepareUIRegistry","runOnUI","frameCallbackRegistry","Map","activeFrameCallbacks","Set","previousFrameTimestamp","runCallbacks","loop","timestamp","delta","forEach","callbackId","callbackDetails","get","startTime","callback","timeSincePreviousFrame","timeSinceFirstFrame","size","requestAnimationFrame","registerFrameCallback","set","unregisterFrameCallback","manageStateFrameCallback","delete","state","add","global","_frameCallbackRegistry"],"sources":["FrameCallbackRegistryUI.ts"],"sourcesContent":["import { runOnUI } from '../core';\n\ntype CallbackDetails = {\n callback: (frameInfo: FrameInfo) => void;\n startTime: number | null;\n};\n\nexport type FrameInfo = {\n timestamp: number;\n timeSincePreviousFrame: number | null;\n timeSinceFirstFrame: number;\n};\n\nexport interface FrameCallbackRegistryUI {\n frameCallbackRegistry: Map<number, CallbackDetails>;\n activeFrameCallbacks: Set<number>;\n previousFrameTimestamp: number | null;\n runCallbacks: () => void;\n registerFrameCallback: (\n callback: (frameInfo: FrameInfo) => void,\n callbackId: number\n ) => void;\n unregisterFrameCallback: (callbackId: number) => void;\n manageStateFrameCallback: (callbackId: number, state: boolean) => void;\n}\n\nexport const prepareUIRegistry = runOnUI(() => {\n 'worklet';\n\n const frameCallbackRegistry: FrameCallbackRegistryUI = {\n frameCallbackRegistry: new Map<number, CallbackDetails>(),\n activeFrameCallbacks: new Set<number>(),\n previousFrameTimestamp: null,\n\n runCallbacks() {\n const loop = (timestamp: number) => {\n if (this.previousFrameTimestamp === null) {\n this.previousFrameTimestamp = timestamp;\n }\n\n const delta = timestamp - this.previousFrameTimestamp;\n\n this.activeFrameCallbacks.forEach((callbackId: number) => {\n const callbackDetails = this.frameCallbackRegistry.get(callbackId)!;\n\n const { startTime } = callbackDetails;\n\n if (startTime === null) {\n // First frame\n callbackDetails.startTime = timestamp;\n\n callbackDetails.callback({\n timestamp,\n timeSincePreviousFrame: null,\n timeSinceFirstFrame: 0,\n });\n } else {\n // Next frame\n callbackDetails.callback({\n timestamp,\n timeSincePreviousFrame: delta,\n timeSinceFirstFrame: timestamp - startTime,\n });\n }\n });\n\n if (this.activeFrameCallbacks.size > 0) {\n this.previousFrameTimestamp = timestamp;\n requestAnimationFrame(loop);\n } else {\n this.previousFrameTimestamp = null;\n }\n };\n\n // runCallback() should only be called after registering a callback,\n // so if there is only one active callback, then it means that there were\n // zero previously and the loop isn't running yet.\n if (this.activeFrameCallbacks.size === 1) {\n requestAnimationFrame(loop);\n }\n },\n\n registerFrameCallback(\n callback: (frameInfo: FrameInfo) => void,\n callbackId: number\n ) {\n this.frameCallbackRegistry.set(callbackId, {\n callback: callback,\n startTime: null,\n });\n },\n\n unregisterFrameCallback(callbackId: number) {\n this.manageStateFrameCallback(callbackId, false);\n this.frameCallbackRegistry.delete(callbackId);\n },\n\n manageStateFrameCallback(callbackId: number, state: boolean) {\n if (callbackId === -1) {\n return;\n }\n if (state) {\n this.activeFrameCallbacks.add(callbackId);\n this.runCallbacks();\n } else {\n const callback = this.frameCallbackRegistry.get(callbackId)!;\n callback.startTime = null;\n\n this.activeFrameCallbacks.delete(callbackId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ADa,CAwCb;MACA;MACA;;;MACA,IAAI,KAAKF,oBAAL,CAA0Be,IAA1B,KAAmC,CAAvC,EAA0C;QACxCC,qBAAqB,CAACZ,IAAD,CAArB;MACD;IACF,CAnDoD;;IAqDrDa,qBAAqB,CACnBL,QADmB,EAEnBJ,UAFmB,EAGnB;MACA,KAAKV,qBAAL,CAA2BoB,GAA3B,CAA+BV,UAA/B,EAA2C;QACzCI,QAAQ,EAAEA,QAD+B;QAEzCD,SAAS,EAAE;MAF8B,CAA3C;IAID,CA7DoD;;IA+DrDQ,uBAAuB,CAACX,UAAD,EAAqB;MAC1C,KAAKY,wBAAL,CAA8BZ,UAA9B,EAA0C,KAA1C;MACA,KAAKV,qBAAL,CAA2BuB,MAA3B,CAAkCb,UAAlC;IACD,CAlEoD;;IAoErDY,wBAAwB,CAACZ,UAAD,EAAqBc,KAArB,EAAqC;MAC3D,IAAId,UAAU,KAAK,CAAC,CAApB,EAAuB;QACrB;MACD;;MACD,IAAIc,KAAJ,EAAW;QACT,KAAKtB,oBAAL,CAA0BuB,GAA1B,CAA8Bf,UAA9B;QACA,KAAKL,YAAL;MACD,CAHD,MAGO;QACL,MAAMS,QAAQ,GAAG,KAAKd,qBAAL,CAA2BY,GAA3B,CAA+BF,UAA/B,CAAjB;QACAI,QAAQ,CAACD,SAAT,GAAqB,IAArB;QAEA,KAAKX,oBAAL,CAA0BqB,MAA1B,CAAiCb,UAAjC;MACD;IACF;;EAjFoD,CAAvD;EAoFAgB,MAAM,CAACC,sBAAP,GAAgC3B,qBAAhC;AACD,CAxFgC,CAA1B"}
1
+ {"version":3,"names":["prepareUIRegistry","runOnUIImmediately","frameCallbackRegistry","Map","activeFrameCallbacks","Set","previousFrameTimestamp","runCallbacks","loop","timestamp","delta","forEach","callbackId","callbackDetails","get","startTime","callback","timeSincePreviousFrame","timeSinceFirstFrame","size","requestAnimationFrame","registerFrameCallback","set","unregisterFrameCallback","manageStateFrameCallback","delete","state","add","global","_frameCallbackRegistry"],"sources":["FrameCallbackRegistryUI.ts"],"sourcesContent":["import { runOnUIImmediately } from '../threads';\n\ntype CallbackDetails = {\n callback: (frameInfo: FrameInfo) => void;\n startTime: number | null;\n};\n\nexport type FrameInfo = {\n timestamp: number;\n timeSincePreviousFrame: number | null;\n timeSinceFirstFrame: number;\n};\n\nexport interface FrameCallbackRegistryUI {\n frameCallbackRegistry: Map<number, CallbackDetails>;\n activeFrameCallbacks: Set<number>;\n previousFrameTimestamp: number | null;\n runCallbacks: () => void;\n registerFrameCallback: (\n callback: (frameInfo: FrameInfo) => void,\n callbackId: number\n ) => void;\n unregisterFrameCallback: (callbackId: number) => void;\n manageStateFrameCallback: (callbackId: number, state: boolean) => void;\n}\n\nexport const prepareUIRegistry = runOnUIImmediately(() => {\n 'worklet';\n\n const frameCallbackRegistry: FrameCallbackRegistryUI = {\n frameCallbackRegistry: new Map<number, CallbackDetails>(),\n activeFrameCallbacks: new Set<number>(),\n previousFrameTimestamp: null,\n\n runCallbacks() {\n const loop = (timestamp: number) => {\n if (this.previousFrameTimestamp === null) {\n this.previousFrameTimestamp = timestamp;\n }\n\n const delta = timestamp - this.previousFrameTimestamp;\n\n this.activeFrameCallbacks.forEach((callbackId: number) => {\n const callbackDetails = this.frameCallbackRegistry.get(callbackId)!;\n\n const { startTime } = callbackDetails;\n\n if (startTime === null) {\n // First frame\n callbackDetails.startTime = timestamp;\n\n callbackDetails.callback({\n timestamp,\n timeSincePreviousFrame: null,\n timeSinceFirstFrame: 0,\n });\n } else {\n // Next frame\n callbackDetails.callback({\n timestamp,\n timeSincePreviousFrame: delta,\n timeSinceFirstFrame: timestamp - startTime,\n });\n }\n });\n\n if (this.activeFrameCallbacks.size > 0) {\n this.previousFrameTimestamp = timestamp;\n requestAnimationFrame(loop);\n } else {\n this.previousFrameTimestamp = null;\n }\n };\n\n // runCallback() should only be called after registering a callback,\n // so if there is only one active callback, then it means that there were\n // zero previously and the loop isn't running yet.\n if (this.activeFrameCallbacks.size === 1) {\n requestAnimationFrame(loop);\n }\n },\n\n registerFrameCallback(\n callback: (frameInfo: FrameInfo) => void,\n callbackId: number\n ) {\n this.frameCallbackRegistry.set(callbackId, {\n callback: callback,\n startTime: null,\n });\n },\n\n unregisterFrameCallback(callbackId: number) {\n this.manageStateFrameCallback(callbackId, false);\n this.frameCallbackRegistry.delete(callbackId);\n },\n\n manageStateFrameCallback(callbackId: number, state: boolean) {\n if (callbackId === -1) {\n return;\n }\n if (state) {\n this.activeFrameCallbacks.add(callbackId);\n this.runCallbacks();\n } else {\n const callback = this.frameCallbackRegistry.get(callbackId)!;\n callback.startTime = null;\n\n this.activeFrameCallbacks.delete(callbackId);\n }\n },\n };\n\n global._frameCallbackRegistry = frameCallbackRegistry;\n});\n"],"mappings":";;;;;;;AAAA;;AA0BO,MAAMA,iBAAiB,GAAG,IAAAC,2BAAA,EAAmB,MAAM;EACxD;;EAEA,MAAMC,qBAA8C,GAAG;IACrDA,qBAAqB,EAAE,IAAIC,GAAJ,EAD8B;IAErDC,oBAAoB,EAAE,IAAIC,GAAJ,EAF+B;IAGrDC,sBAAsB,EAAE,IAH6B;;IAKrDC,YAAY,GAAG;MACb,MAAMC,IAAI,GAAIC,SAAD,IAAuB;QAClC,IAAI,KAAKH,sBAAL,KAAgC,IAApC,EAA0C;UACxC,KAAKA,sBAAL,GAA8BG,SAA9B;QACD;;QAED,MAAMC,KAAK,GAAGD,SAAS,GAAG,KAAKH,sBAA/B;QAEA,KAAKF,oBAAL,CAA0BO,OAA1B,CAAmCC,UAAD,IAAwB;UACxD,MAAMC,eAAe,GAAG,KAAKX,qBAAL,CAA2BY,GAA3B,CAA+BF,UAA/B,CAAxB;UAEA,MAAM;YAAEG;UAAF,IAAgBF,eAAtB;;UAEA,IAAIE,SAAS,KAAK,IAAlB,EAAwB;YACtB;YACAF,eAAe,CAACE,SAAhB,GAA4BN,SAA5B;YAEAI,eAAe,CAACG,QAAhB,CAAyB;cACvBP,SADuB;cAEvBQ,sBAAsB,EAAE,IAFD;cAG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EA,KAAKX,oBAAL,CAA0BqB,MAA1B,CAAiCb,UAAjC;MACD;IACF;;EAjFoD,CAAvD;EAoFAgB,MAAM,CAACC,sBAAP,GAAgC3B,qBAAhC;AACD,CAxFgC,CAA1B"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["globals.d.ts"],"sourcesContent":["import type {\n AnimatedStyle,\n StyleProps,\n MeasuredDimensions,\n MapperRegistry,\n ShareableRef,\n ShareableSyncDataHolderRef,\n} from './commonTypes';\nimport type { ReanimatedConsole } from './core';\nimport type { FrameCallbackRegistryUI } from './frameCallback/FrameCallbackRegistryUI';\nimport type { ShadowNodeWrapper } from './hook/commonTypes';\nimport { LayoutAnimationStartFunction } from './layoutReanimation';\nimport type { NativeReanimated } from './NativeReanimated/NativeReanimated';\n\ndeclare global {\n const _WORKLET: boolean;\n const _IS_FABRIC: boolean;\n const _REANIMATED_VERSION_CPP: string;\n const _frameTimestamp: number | null;\n const _eventTimestamp: number;\n const __reanimatedModuleProxy: NativeReanimated;\n const _setGlobalConsole: (console?: ReanimatedConsole) => void;\n const _log: (s: string) => void;\n const _getCurrentTime: () => number;\n const _getTimestamp: () => number;\n const _notifyAboutProgress: (tag: number, value: number) => void;\n const _notifyAboutEnd: (\n tag: number,\n finished: boolean,\n removeView: boolean\n ) => void;\n const _setGestureState: (handlerTag: number, newState: number) => void;\n const _makeShareableClone: (value: any) => any;\n const _updateDataSynchronously: (\n dataHolder: ShareableSyncDataHolderRef,\n data: ShareableRef\n ) => void;\n const _scheduleOnJS: (fun: ShareableRef, args?: ShareableRef) => void;\n const _updatePropsPaper: (\n tag: number,\n name: string,\n updates: StyleProps | AnimatedStyle\n ) => void;\n const _updatePropsFabric: (\n shadowNodeWrapper: ShadowNodeWrapper,\n props: StyleProps | AnimatedStyle\n ) => void;\n const _removeShadowNodeFromRegistry: (\n shadowNodeWrapper: ShadowNodeWrapper\n ) => void;\n const _measure: (viewTag: number) => MeasuredDimensions;\n const _scrollTo: (\n viewTag: number,\n x: number,\n y: number,\n animated: boolean\n ) => void;\n const _dispatchCommand: (\n shadowNodeWrapper: ShadowNodeWrapper,\n commandName: string,\n args: Array<unknown>\n ) => void;\n const _chronoNow: () => number;\n const performance: { now: () => number };\n const ReanimatedDataMock: {\n now: () => number;\n };\n const _frameCallbackRegistry: FrameCallbackRegistryUI;\n\n namespace NodeJS {\n interface Global {\n _WORKLET: boolean;\n _IS_FABRIC: boolean;\n _REANIMATED_VERSION_CPP: string;\n _frameTimestamp: number | null;\n _eventTimestamp: number;\n __reanimatedModuleProxy: NativeReanimated;\n _setGlobalConsole: (console?: ReanimatedConsole) => void;\n _log: (s: string) => void;\n _getCurrentTime: () => number;\n _getTimestamp: () => number;\n _setGestureState: (handlerTag: number, newState: number) => void;\n _makeShareableClone: (value: any) => any;\n _updateDataSynchronously: (\n ShareableSyncDataHolderRef,\n ShareableRef\n ) => void;\n _scheduleOnJS: (fun: ShareableRef, args?: ShareableRef) => void;\n _updatePropsPaper: (\n tag: number,\n name: string,\n updates: StyleProps | AnimatedStyle\n ) => void;\n _updatePropsFabric: (\n shadowNodeWrapper: ShadowNodeWrapper,\n props: StyleProps | AnimatedStyle\n ) => void;\n _removeShadowNodeFromRegistry: (\n shadowNodeWrapper: ShadowNodeWrapper\n ) => void;\n _measure: (viewTag: number) => MeasuredDimensions;\n _scrollTo: (\n viewTag: number,\n x: number,\n y: number,\n animated: boolean\n ) => void;\n _dispatchCommand: (\n shadowNodeWrapper: ShadowNodeWrapper,\n commandName: string,\n args: Array<unknown>\n ) => void;\n _chronoNow: () => number;\n performance: { now: () => number };\n LayoutAnimationsManager: {\n start: LayoutAnimationStartFunction;\n };\n ReanimatedDataMock: {\n now: () => number;\n };\n _frameCallbackRegistry: FrameCallbackRegistryUI;\n __workletsCache?: Map<string, (...args: any[]) => any>;\n __handleCache?: WeakMap<any, any>;\n __mapperRegistry?: MapperRegistry;\n }\n }\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["globals.d.ts"],"sourcesContent":["import type {\n AnimatedStyle,\n StyleProps,\n MeasuredDimensions,\n MapperRegistry,\n ShareableRef,\n ShareableSyncDataHolderRef,\n} from './commonTypes';\nimport type { FrameCallbackRegistryUI } from './frameCallback/FrameCallbackRegistryUI';\nimport type { ShadowNodeWrapper } from './hook/commonTypes';\nimport { LayoutAnimationStartFunction } from './layoutReanimation';\nimport type { NativeReanimated } from './NativeReanimated/NativeReanimated';\n\ndeclare global {\n const _WORKLET: boolean;\n const _IS_FABRIC: boolean;\n const _REANIMATED_VERSION_CPP: string;\n const __reanimatedModuleProxy: NativeReanimated;\n const evalWithSourceMap: (\n js: string,\n sourceURL: string,\n sourceMap: string\n ) => any;\n const evalWithSourceUrl: (js: string, sourceURL: string) => any;\n const _log: (s: string) => void;\n const _getCurrentTime: () => number;\n const _notifyAboutProgress: (\n tag: number,\n value: number,\n isSharedTransition: boolean\n ) => void;\n const _notifyAboutEnd: (\n tag: number,\n finished: boolean,\n removeView: boolean\n ) => void;\n const _setGestureState: (handlerTag: number, newState: number) => void;\n const _makeShareableClone: (value: any) => any;\n const _updateDataSynchronously: (\n dataHolder: ShareableSyncDataHolderRef,\n data: ShareableRef\n ) => void;\n const _scheduleOnJS: (fun: ShareableRef, args?: ShareableRef) => void;\n const _updatePropsPaper: (\n tag: number,\n name: string,\n updates: StyleProps | AnimatedStyle\n ) => void;\n const _updatePropsFabric: (\n shadowNodeWrapper: ShadowNodeWrapper,\n props: StyleProps | AnimatedStyle\n ) => void;\n const _removeShadowNodeFromRegistry: (viewTag: number) => void;\n const _measure: (viewTag: number) => MeasuredDimensions;\n const _scrollTo: (\n viewTag: number,\n x: number,\n y: number,\n animated: boolean\n ) => void;\n const _dispatchCommand: (\n shadowNodeWrapper: ShadowNodeWrapper,\n commandName: string,\n args: Array<unknown>\n ) => void;\n const performance: { now: () => number };\n const ReanimatedDataMock: {\n now: () => number;\n };\n const ErrorUtils: {\n reportFatalError: (error: Error) => void;\n };\n const _frameCallbackRegistry: FrameCallbackRegistryUI;\n const requestAnimationFrame: (callback: (time: number) => void) => number;\n const setImmediate: (callback: (time: number) => void) => number;\n const console: Console;\n\n namespace NodeJS {\n interface Global {\n _WORKLET: boolean;\n _IS_FABRIC: boolean;\n _REANIMATED_VERSION_CPP: string;\n __reanimatedModuleProxy: NativeReanimated;\n __frameTimestamp?: number;\n evalWithSourceMap: (\n js: string,\n sourceURL: string,\n sourceMap: string\n ) => any;\n evalWithSourceUrl: (js: string, sourceURL: string) => any;\n _log: (s: string) => void;\n _getCurrentTime: () => number;\n _setGestureState: (handlerTag: number, newState: number) => void;\n _makeShareableClone: (value: any) => any;\n _updateDataSynchronously: (\n ShareableSyncDataHolderRef,\n ShareableRef\n ) => void;\n _scheduleOnJS: (fun: ShareableRef, args?: ShareableRef) => void;\n _updatePropsPaper: (\n tag: number,\n name: string,\n updates: StyleProps | AnimatedStyle\n ) => void;\n _updatePropsFabric: (\n shadowNodeWrapper: ShadowNodeWrapper,\n props: StyleProps | AnimatedStyle\n ) => void;\n _removeShadowNodeFromRegistry: (viewTag: number) => void;\n _measure: (viewTag: number) => MeasuredDimensions;\n _scrollTo: (\n viewTag: number,\n x: number,\n y: number,\n animated: boolean\n ) => void;\n _dispatchCommand: (\n shadowNodeWrapper: ShadowNodeWrapper,\n commandName: string,\n args: Array<unknown>\n ) => void;\n performance: { now: () => number };\n LayoutAnimationsManager: {\n start: LayoutAnimationStartFunction;\n };\n ReanimatedDataMock: {\n now: () => number;\n };\n ErrorUtils: {\n reportFatalError: (error: Error) => void;\n };\n _frameCallbackRegistry: FrameCallbackRegistryUI;\n __workletsCache?: Map<string, (...args: any[]) => any>;\n __handleCache?: WeakMap<any, any>;\n __mapperRegistry?: MapperRegistry;\n __flushImmediates: () => void;\n __flushAnimationFrame: (frameTimestamp: number) => void;\n requestAnimationFrame: (callback: (time: number) => void) => number;\n setImmediate: (callback: (time: number) => void) => number;\n console: Console;\n }\n }\n}\n"],"mappings":""}