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
@@ -0,0 +1 @@
1
+ {"version":3,"names":["callGuardDEV","fn","args","e","global","ErrorUtils","reportFatalError","valueUnpacker","objectToUnpack","category","workletsCache","__workletsCache","handleCache","__handleCache","undefined","Map","WeakMap","workletHash","__workletHash","workletFun","get","initData","__initData","evalWithSourceMap","code","location","sourceMap","evalWithSourceUrl","eval","set","functionInstance","bind","_recur","__init","value","fun","Error","__remoteFunction","setupRequestAnimationFrame","nativeRequestAnimationFrame","requestAnimationFrame","animationFrameCallbacks","lastNativeAnimationFrameTimestamp","__flushAnimationFrame","frameTimestamp","currentCallbacks","forEach","f","flushImmediates","callback","push","length","timestamp","__frameTimestamp","initializeUIRuntime","NativeReanimatedModule","installCoreFunctions","IS_JEST","isJest","setTimeout","performance","now","capturableConsole","console","runOnUIImmediately","error","runOnJS","reportFatalErrorOnJS","message","stack","debug","log","warn","info","setupSetImmediate"],"sources":["initializers.ts"],"sourcesContent":["import { reportFatalErrorOnJS } from './errors';\nimport NativeReanimatedModule from './NativeReanimated';\nimport { isJest } from './PlatformChecker';\nimport {\n runOnJS,\n setupSetImmediate,\n flushImmediates,\n runOnUIImmediately,\n} from './threads';\n\n// callGuard is only used with debug builds\nfunction callGuardDEV<T extends Array<any>, U>(\n fn: (...args: T) => U,\n ...args: T\n): void {\n 'worklet';\n try {\n fn(...args);\n } catch (e) {\n if (global.ErrorUtils) {\n global.ErrorUtils.reportFatalError(e as Error);\n } else {\n throw e;\n }\n }\n}\n\nfunction valueUnpacker(objectToUnpack: any, category?: string): any {\n 'worklet';\n let workletsCache = global.__workletsCache;\n let handleCache = global.__handleCache;\n if (workletsCache === undefined) {\n // init\n workletsCache = global.__workletsCache = new Map();\n handleCache = global.__handleCache = new WeakMap();\n }\n const workletHash = objectToUnpack.__workletHash;\n if (workletHash !== undefined) {\n let workletFun = workletsCache.get(workletHash);\n if (workletFun === undefined) {\n const initData = objectToUnpack.__initData;\n if (global.evalWithSourceMap) {\n // if the runtime (hermes only for now) supports loading source maps\n // we want to use the proper filename for the location as it guarantees\n // that debugger understands and loads the source code of the file where\n // the worklet is defined.\n workletFun = global.evalWithSourceMap(\n '(' + initData.code + '\\n)',\n initData.location,\n initData.sourceMap\n ) as (...args: any[]) => any;\n } else if (global.evalWithSourceUrl) {\n // if the runtime doesn't support loading source maps, in dev mode we\n // can pass source url when evaluating the worklet. Now, instead of using\n // the actual file location we use worklet hash, as it the allows us to\n // properly symbolicate traces (see errors.ts for details)\n workletFun = global.evalWithSourceUrl(\n '(' + initData.code + '\\n)',\n `worklet_${workletHash}`\n ) as (...args: any[]) => any;\n } else {\n // in release we use the regular eval to save on JSI calls\n // eslint-disable-next-line no-eval\n workletFun = eval('(' + initData.code + '\\n)') as (\n ...args: any[]\n ) => any;\n }\n workletsCache.set(workletHash, workletFun);\n }\n const functionInstance = workletFun.bind(objectToUnpack);\n objectToUnpack._recur = functionInstance;\n return functionInstance;\n } else if (objectToUnpack.__init) {\n let value = handleCache!.get(objectToUnpack);\n if (value === undefined) {\n value = objectToUnpack.__init();\n handleCache!.set(objectToUnpack, value);\n }\n return value;\n } else if (category === 'RemoteFunction') {\n const fun = () => {\n throw new Error(`Tried to synchronously call a non-worklet function on the UI thread.\n\nPossible solutions are:\n a) If you want to synchronously execute this method, mark it as a worklet\n b) If you want to execute this function on the JS thread, wrap it using \\`runOnJS\\``);\n };\n fun.__remoteFunction = objectToUnpack;\n return fun;\n } else {\n throw new Error('data type not recognized by unpack method');\n }\n}\n\nfunction setupRequestAnimationFrame() {\n 'worklet';\n\n // Jest mocks requestAnimationFrame API and it does not like if that mock gets overridden\n // so we avoid doing requestAnimationFrame batching in Jest environment.\n const nativeRequestAnimationFrame = global.requestAnimationFrame;\n\n let animationFrameCallbacks: Array<(timestamp: number) => void> = [];\n let lastNativeAnimationFrameTimestamp = -1;\n\n global.__flushAnimationFrame = (frameTimestamp: number) => {\n const currentCallbacks = animationFrameCallbacks;\n animationFrameCallbacks = [];\n currentCallbacks.forEach((f) => f(frameTimestamp));\n flushImmediates();\n };\n\n global.requestAnimationFrame = (\n callback: (timestamp: number) => void\n ): number => {\n animationFrameCallbacks.push(callback);\n if (animationFrameCallbacks.length === 1) {\n // We schedule native requestAnimationFrame only when the first callback\n // is added and then use it to execute all the enqueued callbacks. Once\n // the callbacks are run, we clear the array.\n nativeRequestAnimationFrame((timestamp) => {\n if (lastNativeAnimationFrameTimestamp >= timestamp) {\n // Make sure we only execute the callbacks once for a given frame\n return;\n }\n lastNativeAnimationFrameTimestamp = timestamp;\n global.__frameTimestamp = timestamp;\n global.__flushAnimationFrame(timestamp);\n global.__frameTimestamp = undefined;\n });\n }\n // Reanimated currently does not support cancelling calbacks requested with\n // requestAnimationFrame. We return -1 as identifier which isn't in line\n // with the spec but it should give users better clue in case they actually\n // attempt to store the value returned from rAF and use it for cancelling.\n return -1;\n };\n}\n\nexport function initializeUIRuntime() {\n NativeReanimatedModule.installCoreFunctions(callGuardDEV, valueUnpacker);\n\n const IS_JEST = isJest();\n\n if (IS_JEST) {\n // requestAnimationFrame react-native jest's setup is incorrect as it polyfills\n // the method directly using setTimeout, therefore the callback doesn't get the\n // expected timestamp as the only argument: https://github.com/facebook/react-native/blob/main/jest/setup.js#L28\n // We override this setup here to make sure that callbacks get the proper timestamps\n // when executed. For non-jest environments we define requestAnimationFrame in setupRequestAnimationFrame\n // @ts-ignore TypeScript uses Node definition for rAF, setTimeout, etc which returns a Timeout object rather than a number\n global.requestAnimationFrame = (callback: (timestamp: number) => void) => {\n return setTimeout(() => callback(performance.now()), 0);\n };\n }\n\n const capturableConsole = console;\n runOnUIImmediately(() => {\n 'worklet';\n // setup error handler\n global.ErrorUtils = {\n reportFatalError: (error: Error) => {\n runOnJS(reportFatalErrorOnJS)({\n message: error.message,\n stack: error.stack,\n });\n },\n };\n\n // setup console\n // @ts-ignore TypeScript doesn't like that there are missing methods in console object, but we don't provide all the methods for the UI runtime console version\n global.console = {\n debug: runOnJS(capturableConsole.debug),\n log: runOnJS(capturableConsole.log),\n warn: runOnJS(capturableConsole.warn),\n error: runOnJS(capturableConsole.error),\n info: runOnJS(capturableConsole.info),\n };\n\n if (!IS_JEST) {\n setupSetImmediate();\n setupRequestAnimationFrame();\n }\n })();\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;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AAEH,KAAK,CAACG,OADa;UAE5BC,KAAK,EAAEJ,KAAK,CAACI;QAFe,CAA9B;MAID;IANiB,CAApB,CAHuB,CAYvB;IACA;;IACAjE,MAAM,CAAC2D,OAAP,GAAiB;MACfO,KAAK,EAAE,IAAAJ,gBAAA,EAAQJ,iBAAiB,CAACQ,KAA1B,CADQ;MAEfC,GAAG,EAAE,IAAAL,gBAAA,EAAQJ,iBAAiB,CAACS,GAA1B,CAFU;MAGfC,IAAI,EAAE,IAAAN,gBAAA,EAAQJ,iBAAiB,CAACU,IAA1B,CAHS;MAIfP,KAAK,EAAE,IAAAC,gBAAA,EAAQJ,iBAAiB,CAACG,KAA1B,CAJQ;MAKfQ,IAAI,EAAE,IAAAP,gBAAA,EAAQJ,iBAAiB,CAACW,IAA1B;IALS,CAAjB;;IAQA,IAAI,CAAChB,OAAL,EAAc;MACZ,IAAAiB,0BAAA;MACApC,0BAA0B;IAC3B;EACF,CA1BD;AA2BD"}
@@ -21,23 +21,93 @@ const Extrapolate = {
21
21
  };
22
22
  exports.Extrapolate = Extrapolate;
23
23
 
24
- const interpolateColorsHSV = (value, inputRange, colors) => {
24
+ const interpolateColorsHSV = (value, inputRange, colors, options) => {
25
25
  'worklet';
26
26
 
27
- const h = (0, _interpolation.interpolate)(value, inputRange, colors.h, Extrapolate.CLAMP);
27
+ let h = 0;
28
+ const {
29
+ useCorrectedHSVInterpolation = true
30
+ } = options;
31
+
32
+ if (useCorrectedHSVInterpolation) {
33
+ // if the difference between hues in a range is > 180 deg
34
+ // then move the hue at the right end of the range +/- 360 deg
35
+ // and add the next point in the original place + 0.00001 with original hue
36
+ // to not break the next range
37
+ const correctedInputRange = [inputRange[0]];
38
+ const originalH = colors.h;
39
+ const correctedH = [originalH[0]];
40
+
41
+ for (let i = 1; i < originalH.length; ++i) {
42
+ const d = originalH[i] - originalH[i - 1];
43
+
44
+ if (originalH[i] > originalH[i - 1] && d > 0.5) {
45
+ correctedInputRange.push(inputRange[i]);
46
+ correctedInputRange.push(inputRange[i] + 0.00001);
47
+ correctedH.push(originalH[i] - 1);
48
+ correctedH.push(originalH[i]);
49
+ } else if (originalH[i] < originalH[i - 1] && d < -0.5) {
50
+ correctedInputRange.push(inputRange[i]);
51
+ correctedInputRange.push(inputRange[i] + 0.00001);
52
+ correctedH.push(originalH[i] + 1);
53
+ correctedH.push(originalH[i]);
54
+ } else {
55
+ correctedInputRange.push(inputRange[i]);
56
+ correctedH.push(originalH[i]);
57
+ }
58
+ }
59
+
60
+ h = ((0, _interpolation.interpolate)(value, correctedInputRange, correctedH, Extrapolate.CLAMP) + 1) % 1;
61
+ } else {
62
+ h = (0, _interpolation.interpolate)(value, inputRange, colors.h, Extrapolate.CLAMP);
63
+ }
64
+
28
65
  const s = (0, _interpolation.interpolate)(value, inputRange, colors.s, Extrapolate.CLAMP);
29
66
  const v = (0, _interpolation.interpolate)(value, inputRange, colors.v, Extrapolate.CLAMP);
30
- return (0, _Colors.hsvToColor)(h, s, v);
67
+ const a = (0, _interpolation.interpolate)(value, inputRange, colors.a, Extrapolate.CLAMP);
68
+ return (0, _Colors.hsvToColor)(h, s, v, a);
31
69
  };
32
70
 
33
- const interpolateColorsRGB = (value, inputRange, colors) => {
71
+ const toLinearSpace = (x, gamma) => {
34
72
  'worklet';
35
73
 
36
- const r = (0, _interpolation.interpolate)(value, inputRange, colors.r, Extrapolate.CLAMP);
37
- const g = (0, _interpolation.interpolate)(value, inputRange, colors.g, Extrapolate.CLAMP);
38
- const b = (0, _interpolation.interpolate)(value, inputRange, colors.b, Extrapolate.CLAMP);
74
+ return x.map(v => Math.pow(v / 255, gamma));
75
+ };
76
+
77
+ const toGammaSpace = (x, gamma) => {
78
+ 'worklet';
79
+
80
+ return Math.round(Math.pow(x, 1 / gamma) * 255);
81
+ };
82
+
83
+ const interpolateColorsRGB = (value, inputRange, colors, options) => {
84
+ 'worklet';
85
+
86
+ const {
87
+ gamma = 2.2
88
+ } = options;
89
+ let {
90
+ r: outputR,
91
+ g: outputG,
92
+ b: outputB
93
+ } = colors;
94
+
95
+ if (gamma !== 1) {
96
+ outputR = toLinearSpace(outputR, gamma);
97
+ outputG = toLinearSpace(outputG, gamma);
98
+ outputB = toLinearSpace(outputB, gamma);
99
+ }
100
+
101
+ const r = (0, _interpolation.interpolate)(value, inputRange, outputR, Extrapolate.CLAMP);
102
+ const g = (0, _interpolation.interpolate)(value, inputRange, outputG, Extrapolate.CLAMP);
103
+ const b = (0, _interpolation.interpolate)(value, inputRange, outputB, Extrapolate.CLAMP);
39
104
  const a = (0, _interpolation.interpolate)(value, inputRange, colors.a, Extrapolate.CLAMP);
40
- return (0, _Colors.rgbaColor)(r, g, b, a);
105
+
106
+ if (gamma === 1) {
107
+ return (0, _Colors.rgbaColor)(r, g, b, a);
108
+ }
109
+
110
+ return (0, _Colors.rgbaColor)(toGammaSpace(r, gamma), toGammaSpace(g, gamma), toGammaSpace(b, gamma), a);
41
111
  };
42
112
 
43
113
  const getInterpolateRGB = colors => {
@@ -74,22 +144,26 @@ const getInterpolateHSV = colors => {
74
144
  const h = [];
75
145
  const s = [];
76
146
  const v = [];
147
+ const a = [];
77
148
 
78
149
  for (let i = 0; i < colors.length; ++i) {
79
150
  const color = colors[i];
80
- const processedColor = (0, _Colors.RGBtoHSV)((0, _Colors.processColor)(color));
151
+ const processedColor = (0, _Colors.processColor)(color);
81
152
 
82
- if (processedColor) {
83
- h.push(processedColor.h);
84
- s.push(processedColor.s);
85
- v.push(processedColor.v);
153
+ if (typeof processedColor === 'number') {
154
+ const processedHSVColor = (0, _Colors.RGBtoHSV)((0, _Colors.red)(processedColor), (0, _Colors.green)(processedColor), (0, _Colors.blue)(processedColor));
155
+ h.push(processedHSVColor.h);
156
+ s.push(processedHSVColor.s);
157
+ v.push(processedHSVColor.v);
158
+ a.push((0, _Colors.opacity)(processedColor));
86
159
  }
87
160
  }
88
161
 
89
162
  return {
90
163
  h,
91
164
  s,
92
- v
165
+ v,
166
+ a
93
167
  };
94
168
  };
95
169
 
@@ -97,11 +171,12 @@ const interpolateColor = function (value, inputRange, outputRange) {
97
171
  'worklet';
98
172
 
99
173
  let colorSpace = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'RGB';
174
+ let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
100
175
 
101
176
  if (colorSpace === 'HSV') {
102
- return interpolateColorsHSV(value, inputRange, getInterpolateHSV(outputRange));
177
+ return interpolateColorsHSV(value, inputRange, getInterpolateHSV(outputRange), options);
103
178
  } else if (colorSpace === 'RGB') {
104
- return interpolateColorsRGB(value, inputRange, getInterpolateRGB(outputRange));
179
+ return interpolateColorsRGB(value, inputRange, getInterpolateRGB(outputRange), options);
105
180
  }
106
181
 
107
182
  throw new Error(`Invalid color space provided: ${colorSpace}. Supported values are: ['RGB', 'HSV']`);
@@ -118,11 +193,13 @@ exports.ColorSpace = ColorSpace;
118
193
 
119
194
  function useInterpolateConfig(inputRange, outputRange) {
120
195
  let colorSpace = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ColorSpace.RGB;
196
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
121
197
  return (0, _useSharedValue.useSharedValue)({
122
198
  inputRange,
123
199
  outputRange,
124
200
  colorSpace,
125
- cache: (0, _core.makeMutable)(null)
201
+ cache: (0, _core.makeMutable)(null),
202
+ options
126
203
  });
127
204
  }
128
205
 
@@ -137,14 +214,14 @@ const interpolateSharableColor = (value, interpolateConfig) => {
137
214
  interpolateConfig.value.cache.value = colors;
138
215
  }
139
216
 
140
- return interpolateColorsRGB(value, interpolateConfig.value.inputRange, colors);
217
+ return interpolateColorsRGB(value, interpolateConfig.value.inputRange, colors, interpolateConfig.value.options);
141
218
  } else if (interpolateConfig.value.colorSpace === ColorSpace.HSV) {
142
219
  if (!colors) {
143
220
  colors = getInterpolateHSV(interpolateConfig.value.outputRange);
144
221
  interpolateConfig.value.cache.value = colors;
145
222
  }
146
223
 
147
- return interpolateColorsHSV(value, interpolateConfig.value.inputRange, colors);
224
+ return interpolateColorsHSV(value, interpolateConfig.value.inputRange, colors, interpolateConfig.value.options);
148
225
  }
149
226
 
150
227
  throw new Error(`Invalid color space provided: ${interpolateConfig.value.colorSpace}. Supported values are: ['RGB', 'HSV']`);
@@ -1 +1 @@
1
- {"version":3,"names":["Extrapolate","EXTEND","CLAMP","IDENTITY","interpolateColorsHSV","value","inputRange","colors","h","interpolate","s","v","hsvToColor","interpolateColorsRGB","r","g","b","a","rgbaColor","getInterpolateRGB","i","length","color","processedColor","processColor","undefined","push","red","green","blue","opacity","getInterpolateHSV","RGBtoHSV","interpolateColor","outputRange","colorSpace","Error","ColorSpace","useInterpolateConfig","RGB","useSharedValue","cache","makeMutable","interpolateSharableColor","interpolateConfig","HSV"],"sources":["interpolateColor.ts"],"sourcesContent":["import {\n hsvToColor,\n RGBtoHSV,\n rgbaColor,\n processColor,\n red,\n green,\n blue,\n opacity,\n} from './Colors';\nimport { makeMutable } from './core';\nimport { interpolate } from './interpolation';\nimport { SharedValue } from './commonTypes';\nimport { useSharedValue } from './hook/useSharedValue';\n\nexport const Extrapolate = {\n EXTEND: 'extend',\n CLAMP: 'clamp',\n IDENTITY: 'identity',\n};\n\nconst interpolateColorsHSV = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateHSV\n) => {\n 'worklet';\n const h = interpolate(value, inputRange, colors.h, Extrapolate.CLAMP);\n const s = interpolate(value, inputRange, colors.s, Extrapolate.CLAMP);\n const v = interpolate(value, inputRange, colors.v, Extrapolate.CLAMP);\n return hsvToColor(h, s, v);\n};\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateRGB\n) => {\n 'worklet';\n const r = interpolate(value, inputRange, colors.r, Extrapolate.CLAMP);\n const g = interpolate(value, inputRange, colors.g, Extrapolate.CLAMP);\n const b = interpolate(value, inputRange, colors.b, Extrapolate.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);\n return rgbaColor(r, g, b, a);\n};\n\ninterface InterpolateRGB {\n r: number[];\n g: number[];\n b: number[];\n a: number[];\n}\n\nconst getInterpolateRGB = (\n colors: readonly (string | number)[]\n): InterpolateRGB => {\n 'worklet';\n\n const r = [];\n const g = [];\n const b = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color);\n // explicit check in case if processedColor is 0\n if (processedColor !== null && processedColor !== undefined) {\n r.push(red(processedColor));\n g.push(green(processedColor));\n b.push(blue(processedColor));\n a.push(opacity(processedColor));\n }\n }\n return { r, g, b, a };\n};\n\ninterface InterpolateHSV {\n h: number[];\n s: number[];\n v: number[];\n}\n\nconst getInterpolateHSV = (\n colors: readonly (string | number)[]\n): InterpolateHSV => {\n 'worklet';\n const h = [];\n const s = [];\n const v = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = RGBtoHSV(processColor(color) as any);\n if (processedColor) {\n h.push(processedColor.h);\n s.push(processedColor.s);\n v.push(processedColor.v);\n }\n }\n return { h, s, v };\n};\n\nexport const interpolateColor = (\n value: number,\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace: 'RGB' | 'HSV' = 'RGB'\n): string | number => {\n 'worklet';\n if (colorSpace === 'HSV') {\n return interpolateColorsHSV(\n value,\n inputRange,\n getInterpolateHSV(outputRange)\n );\n } else if (colorSpace === 'RGB') {\n return interpolateColorsRGB(\n value,\n inputRange,\n getInterpolateRGB(outputRange)\n );\n }\n throw new Error(\n `Invalid color space provided: ${colorSpace}. Supported values are: ['RGB', 'HSV']`\n );\n};\n\nexport enum ColorSpace {\n RGB = 0,\n HSV = 1,\n}\n\nexport interface InterpolateConfig {\n inputRange: readonly number[];\n outputRange: readonly (string | number)[];\n colorSpace: ColorSpace;\n cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;\n}\n\nexport function useInterpolateConfig(\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace = ColorSpace.RGB\n): SharedValue<InterpolateConfig> {\n return useSharedValue<InterpolateConfig>({\n inputRange,\n outputRange,\n colorSpace,\n cache: makeMutable<InterpolateRGB | InterpolateHSV | null>(null),\n });\n}\n\nexport const interpolateSharableColor = (\n value: number,\n interpolateConfig: SharedValue<InterpolateConfig>\n): string | number => {\n 'worklet';\n let colors = interpolateConfig.value.cache.value;\n if (interpolateConfig.value.colorSpace === ColorSpace.RGB) {\n if (!colors) {\n colors = getInterpolateRGB(interpolateConfig.value.outputRange);\n interpolateConfig.value.cache.value = colors;\n }\n return interpolateColorsRGB(\n value,\n interpolateConfig.value.inputRange,\n colors as InterpolateRGB\n );\n } else if (interpolateConfig.value.colorSpace === ColorSpace.HSV) {\n if (!colors) {\n colors = getInterpolateHSV(interpolateConfig.value.outputRange);\n interpolateConfig.value.cache.value = colors;\n }\n return interpolateColorsHSV(\n value,\n interpolateConfig.value.inputRange,\n colors as InterpolateHSV\n );\n }\n throw new Error(\n `Invalid color space provided: ${interpolateConfig.value.colorSpace}. Supported values are: ['RGB', 'HSV']`\n );\n};\n"],"mappings":";;;;;;;;AAAA;;AAUA;;AACA;;AAEA;;AAEO,MAAMA,WAAW,GAAG;EACzBC,MAAM,EAAE,QADiB;EAEzBC,KAAK,EAAE,OAFkB;EAGzBC,QAAQ,EAAE;AAHe,CAApB;;;AAMP,MAAMC,oBAAoB,GAAG,CAC3BC,KAD2B,EAE3BC,UAF2B,EAG3BC,MAH2B,KAIxB;EACH;;EACA,MAAMC,CAAC,GAAG,IAAAC,0BAAA,EAAYJ,KAAZ,EAAmBC,UAAnB,EAA+BC,MAAM,CAACC,CAAtC,EAAyCR,WAAW,CAACE,KAArD,CAAV;EACA,MAAMQ,CAAC,GAAG,IAAAD,0BAAA,EAAYJ,KAAZ,EAAmBC,UAAnB,EAA+BC,MAAM,CAACG,CAAtC,EAAyCV,WAAW,CAACE,KAArD,CAAV;EACA,MAAMS,CAAC,GAAG,IAAAF,0BAAA,EAAYJ,KAAZ,EAAmBC,UAAnB,EAA+BC,MAAM,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AIqC,iBAAiB,CAACvC,KAAlB,CAAwB8B,UAAxB,KAAuCE,UAAU,CAACQ,GAAtD,EAA2D;IAChE,IAAI,CAACtC,MAAL,EAAa;MACXA,MAAM,GAAGwB,iBAAiB,CAACa,iBAAiB,CAACvC,KAAlB,CAAwB6B,WAAzB,CAA1B;MACAU,iBAAiB,CAACvC,KAAlB,CAAwBoC,KAAxB,CAA8BpC,KAA9B,GAAsCE,MAAtC;IACD;;IACD,OAAOH,oBAAoB,CACzBC,KADyB,EAEzBuC,iBAAiB,CAACvC,KAAlB,CAAwBC,UAFC,EAGzBC,MAHyB,CAA3B;EAKD;;EACD,MAAM,IAAI6B,KAAJ,CACH,iCAAgCQ,iBAAiB,CAACvC,KAAlB,CAAwB8B,UAAW,wCADhE,CAAN;AAGD,CA9BM"}
1
+ {"version":3,"names":["Extrapolate","EXTEND","CLAMP","IDENTITY","interpolateColorsHSV","value","inputRange","colors","options","h","useCorrectedHSVInterpolation","correctedInputRange","originalH","correctedH","i","length","d","push","interpolate","s","v","a","hsvToColor","toLinearSpace","x","gamma","map","Math","pow","toGammaSpace","round","interpolateColorsRGB","r","outputR","g","outputG","b","outputB","rgbaColor","getInterpolateRGB","color","processedColor","processColor","undefined","red","green","blue","opacity","getInterpolateHSV","processedHSVColor","RGBtoHSV","interpolateColor","outputRange","colorSpace","Error","ColorSpace","useInterpolateConfig","RGB","useSharedValue","cache","makeMutable","interpolateSharableColor","interpolateConfig","HSV"],"sources":["interpolateColor.ts"],"sourcesContent":["import {\n hsvToColor,\n RGBtoHSV,\n rgbaColor,\n processColor,\n red,\n green,\n blue,\n opacity,\n} from './Colors';\nimport { makeMutable } from './core';\nimport { interpolate } from './interpolation';\nimport { SharedValue } from './commonTypes';\nimport { useSharedValue } from './hook/useSharedValue';\n\nexport const Extrapolate = {\n EXTEND: 'extend',\n CLAMP: 'clamp',\n IDENTITY: 'identity',\n};\n\nexport type InterpolationOptions = {\n gamma?: number;\n useCorrectedHSVInterpolation?: boolean;\n};\n\nconst interpolateColorsHSV = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateHSV,\n options: InterpolationOptions\n) => {\n 'worklet';\n let h = 0;\n const { useCorrectedHSVInterpolation = true } = options;\n if (useCorrectedHSVInterpolation) {\n // if the difference between hues in a range is > 180 deg\n // then move the hue at the right end of the range +/- 360 deg\n // and add the next point in the original place + 0.00001 with original hue\n // to not break the next range\n const correctedInputRange = [inputRange[0]];\n const originalH = colors.h;\n const correctedH = [originalH[0]];\n\n for (let i = 1; i < originalH.length; ++i) {\n const d = originalH[i] - originalH[i - 1];\n if (originalH[i] > originalH[i - 1] && d > 0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] - 1);\n correctedH.push(originalH[i]);\n } else if (originalH[i] < originalH[i - 1] && d < -0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] + 1);\n correctedH.push(originalH[i]);\n } else {\n correctedInputRange.push(inputRange[i]);\n correctedH.push(originalH[i]);\n }\n }\n h =\n (interpolate(value, correctedInputRange, correctedH, Extrapolate.CLAMP) +\n 1) %\n 1;\n } else {\n h = interpolate(value, inputRange, colors.h, Extrapolate.CLAMP);\n }\n const s = interpolate(value, inputRange, colors.s, Extrapolate.CLAMP);\n const v = interpolate(value, inputRange, colors.v, Extrapolate.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);\n return hsvToColor(h, s, v, a);\n};\n\nconst toLinearSpace = (x: number[], gamma: number): number[] => {\n 'worklet';\n return x.map((v) => Math.pow(v / 255, gamma));\n};\n\nconst toGammaSpace = (x: number, gamma: number): number => {\n 'worklet';\n return Math.round(Math.pow(x, 1 / gamma) * 255);\n};\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateRGB,\n options: InterpolationOptions\n) => {\n 'worklet';\n const { gamma = 2.2 } = options;\n let { r: outputR, g: outputG, b: outputB } = colors;\n if (gamma !== 1) {\n outputR = toLinearSpace(outputR, gamma);\n outputG = toLinearSpace(outputG, gamma);\n outputB = toLinearSpace(outputB, gamma);\n }\n const r = interpolate(value, inputRange, outputR, Extrapolate.CLAMP);\n const g = interpolate(value, inputRange, outputG, Extrapolate.CLAMP);\n const b = interpolate(value, inputRange, outputB, Extrapolate.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);\n if (gamma === 1) {\n return rgbaColor(r, g, b, a);\n }\n return rgbaColor(\n toGammaSpace(r, gamma),\n toGammaSpace(g, gamma),\n toGammaSpace(b, gamma),\n a\n );\n};\n\ninterface InterpolateRGB {\n r: number[];\n g: number[];\n b: number[];\n a: number[];\n}\n\nconst getInterpolateRGB = (\n colors: readonly (string | number)[]\n): InterpolateRGB => {\n 'worklet';\n\n const r = [];\n const g = [];\n const b = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color);\n // explicit check in case if processedColor is 0\n if (processedColor !== null && processedColor !== undefined) {\n r.push(red(processedColor));\n g.push(green(processedColor));\n b.push(blue(processedColor));\n a.push(opacity(processedColor));\n }\n }\n return { r, g, b, a };\n};\n\ninterface InterpolateHSV {\n h: number[];\n s: number[];\n v: number[];\n a: number[];\n}\n\nconst getInterpolateHSV = (\n colors: readonly (string | number)[]\n): InterpolateHSV => {\n 'worklet';\n const h = [];\n const s = [];\n const v = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color) as any;\n if (typeof processedColor === 'number') {\n const processedHSVColor = RGBtoHSV(\n red(processedColor),\n green(processedColor),\n blue(processedColor)\n );\n\n h.push(processedHSVColor.h);\n s.push(processedHSVColor.s);\n v.push(processedHSVColor.v);\n a.push(opacity(processedColor));\n }\n }\n return { h, s, v, a };\n};\n\nexport const interpolateColor = (\n value: number,\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace: 'RGB' | 'HSV' = 'RGB',\n options: InterpolationOptions = {}\n): string | number => {\n 'worklet';\n if (colorSpace === 'HSV') {\n return interpolateColorsHSV(\n value,\n inputRange,\n getInterpolateHSV(outputRange),\n options\n );\n } else if (colorSpace === 'RGB') {\n return interpolateColorsRGB(\n value,\n inputRange,\n getInterpolateRGB(outputRange),\n options\n );\n }\n throw new Error(\n `Invalid color space provided: ${colorSpace}. Supported values are: ['RGB', 'HSV']`\n );\n};\n\nexport enum ColorSpace {\n RGB = 0,\n HSV = 1,\n}\n\nexport interface InterpolateConfig {\n inputRange: readonly number[];\n outputRange: readonly (string | number)[];\n colorSpace: ColorSpace;\n cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;\n options: InterpolationOptions;\n}\n\nexport function useInterpolateConfig(\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace = ColorSpace.RGB,\n options: InterpolationOptions = {}\n): SharedValue<InterpolateConfig> {\n return useSharedValue<InterpolateConfig>({\n inputRange,\n outputRange,\n colorSpace,\n cache: makeMutable<InterpolateRGB | InterpolateHSV | null>(null),\n options,\n });\n}\n\nexport const interpolateSharableColor = (\n value: number,\n interpolateConfig: SharedValue<InterpolateConfig>\n): string | number => {\n 'worklet';\n let colors = interpolateConfig.value.cache.value;\n if (interpolateConfig.value.colorSpace === ColorSpace.RGB) {\n if (!colors) {\n colors = getInterpolateRGB(interpolateConfig.value.outputRange);\n interpolateConfig.value.cache.value = colors;\n }\n return interpolateColorsRGB(\n value,\n interpolateConfig.value.inputRange,\n colors as InterpolateRGB,\n interpolateConfig.value.options\n );\n } else if (interpolateConfig.value.colorSpace === ColorSpace.HSV) {\n if (!colors) {\n colors = getInterpolateHSV(interpolateConfig.value.outputRange);\n interpolateConfig.value.cache.value = colors;\n }\n return interpolateColorsHSV(\n value,\n interpolateConfig.value.inputRange,\n colors as InterpolateHSV,\n interpolateConfig.value.options\n );\n }\n throw new Error(\n `Invalid color space provided: ${interpolateConfig.value.colorSpace}. Supported values are: ['RGB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CACzB1B,KADyB,EAEzByD,iBAAiB,CAACzD,KAAlB,CAAwBC,UAFC,EAGzBC,MAHyB,EAIzBuD,iBAAiB,CAACzD,KAAlB,CAAwBG,OAJC,CAA3B;EAMD,CAXD,MAWO,IAAIsD,iBAAiB,CAACzD,KAAlB,CAAwBgD,UAAxB,KAAuCE,UAAU,CAACQ,GAAtD,EAA2D;IAChE,IAAI,CAACxD,MAAL,EAAa;MACXA,MAAM,GAAGyC,iBAAiB,CAACc,iBAAiB,CAACzD,KAAlB,CAAwB+C,WAAzB,CAA1B;MACAU,iBAAiB,CAACzD,KAAlB,CAAwBsD,KAAxB,CAA8BtD,KAA9B,GAAsCE,MAAtC;IACD;;IACD,OAAOH,oBAAoB,CACzBC,KADyB,EAEzByD,iBAAiB,CAACzD,KAAlB,CAAwBC,UAFC,EAGzBC,MAHyB,EAIzBuD,iBAAiB,CAACzD,KAAlB,CAAwBG,OAJC,CAA3B;EAMD;;EACD,MAAM,IAAI8C,KAAJ,CACH,iCAAgCQ,iBAAiB,CAACzD,KAAlB,CAAwBgD,UAAW,wCADhE,CAAN;AAGD,CAhCM"}
@@ -149,7 +149,7 @@ const afterTest = () => {
149
149
  };
150
150
 
151
151
  const withReanimatedTimer = animationTest => {
152
- console.warn('This method is deprecated, you shoulddefine your own before and after test hooks to enable jest.useFakeTimers(). Check out the documentation for details on testing');
152
+ console.warn('This method is deprecated, you should define your own before and after test hooks to enable jest.useFakeTimers(). Check out the documentation for details on testing');
153
153
  beforeTest();
154
154
  animationTest();
155
155
  afterTest();
@@ -1 +1 @@
1
- {"version":3,"names":["config","fps","isAnimatedStyle","style","animatedStyle","getAnimatedStyleFromObject","current","value","getCurrentStyle","received","styleObject","props","currentStyle","Array","isArray","forEach","checkEqual","expectStyle","length","i","property","findStyleDiff","expect","requireAllMatch","diffs","isEqual","push","Object","keys","undefined","compareStyle","expectedStyle","message","pass","exact","currentStyleStr","JSON","stringify","expectedStyleStr","differences","map","diff","join","frameTime","beforeTest","jest","useFakeTimers","afterTest","runOnlyPendingTimers","useRealTimers","withReanimatedTimer","animationTest","console","warn","advanceAnimationByTime","time","advanceTimersByTime","advanceAnimationByFrame","count","setUpTests","userConfig","global","expectModule","require","jestGlobals","extend","default","Math","round","toHaveAnimatedStyle","getAnimatedStyle"],"sources":["jestUtils.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R> {\n toHaveAnimatedStyle(\n style: Record<string, unknown>[] | Record<string, unknown>\n ): R;\n }\n }\n}\n\nlet config = {\n fps: 60,\n};\n\nconst isAnimatedStyle = (style) => {\n return !!style.animatedStyle;\n};\n\nconst getAnimatedStyleFromObject = (style) => {\n return style.animatedStyle.current.value;\n};\n\nconst getCurrentStyle = (received) => {\n const styleObject = received.props.style;\n let currentStyle = {};\n if (Array.isArray(styleObject)) {\n received.props.style.forEach((style) => {\n if (isAnimatedStyle(style)) {\n currentStyle = {\n ...currentStyle,\n ...getAnimatedStyleFromObject(style),\n };\n } else {\n currentStyle = {\n ...currentStyle,\n ...style,\n };\n }\n });\n } else {\n if (isAnimatedStyle(styleObject)) {\n currentStyle = getAnimatedStyleFromObject(styleObject);\n } else {\n currentStyle = {\n ...styleObject,\n ...received.props.animatedStyle.value,\n };\n }\n }\n return currentStyle;\n};\n\nconst checkEqual = (currentStyle, expectStyle) => {\n if (Array.isArray(expectStyle)) {\n if (expectStyle.length !== currentStyle.length) return false;\n for (let i = 0; i < currentStyle.length; i++) {\n if (!checkEqual(currentStyle[i], expectStyle[i])) {\n return false;\n }\n }\n } else if (typeof currentStyle === 'object' && currentStyle) {\n for (const property in expectStyle) {\n if (!checkEqual(currentStyle[property], expectStyle[property])) {\n return false;\n }\n }\n } else {\n return currentStyle === expectStyle;\n }\n return true;\n};\n\nconst findStyleDiff = (current, expect, requireAllMatch) => {\n const diffs = [];\n let isEqual = true;\n for (const property in expect) {\n if (!checkEqual(current[property], expect[property])) {\n isEqual = false;\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n\n if (\n requireAllMatch &&\n Object.keys(current).length !== Object.keys(expect).length\n ) {\n isEqual = false;\n for (const property in current) {\n if (expect[property] === undefined) {\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n }\n\n return { isEqual, diffs };\n};\n\nconst compareStyle = (received, expectedStyle, config) => {\n if (!received.props.style) {\n return { message: () => message, pass: false };\n }\n const { exact } = config;\n const currentStyle = getCurrentStyle(received);\n const { isEqual, diffs } = findStyleDiff(currentStyle, expectedStyle, exact);\n\n if (isEqual) {\n return { message: () => 'ok', pass: true };\n }\n\n const currentStyleStr = JSON.stringify(currentStyle);\n const expectedStyleStr = JSON.stringify(expectedStyle);\n const differences = diffs\n .map(\n (diff) =>\n `- '${diff.property}' should be ${JSON.stringify(\n diff.expect\n )}, but is ${JSON.stringify(diff.current)}`\n )\n .join('\\n');\n\n return {\n message: () =>\n `Expected: ${expectedStyleStr}\\nReceived: ${currentStyleStr}\\n\\nDifferences:\\n${differences}`,\n pass: false,\n };\n};\n\nlet frameTime = 1000 / config.fps;\n\nconst beforeTest = () => {\n jest.useFakeTimers();\n};\n\nconst afterTest = () => {\n jest.runOnlyPendingTimers();\n jest.useRealTimers();\n};\n\nexport const withReanimatedTimer = (animationTest) => {\n console.warn(\n 'This method is deprecated, you shoulddefine your own before and after test hooks to enable jest.useFakeTimers(). Check out the documentation for details on testing'\n );\n beforeTest();\n animationTest();\n afterTest();\n};\n\nexport const advanceAnimationByTime = (time = frameTime) => {\n console.warn(\n 'This method is deprecated, use jest.advanceTimersByTime directly'\n );\n jest.advanceTimersByTime(time);\n jest.runOnlyPendingTimers();\n};\n\nexport const advanceAnimationByFrame = (count) => {\n console.warn(\n 'This method is deprecated, use jest.advanceTimersByTime directly'\n );\n jest.advanceTimersByTime(count * frameTime);\n jest.runOnlyPendingTimers();\n};\n\nexport const setUpTests = (userConfig = {}) => {\n let expect = global.expect;\n if (expect === undefined) {\n const expectModule = require('expect');\n expect = expectModule;\n // Starting from Jest 28, \"expect\" package uses named exports instead of default export.\n // So, requiring \"expect\" package doesn't give direct access to \"expect\" function anymore.\n // It gives access to the module object instead.\n // We use this info to detect if the project uses Jest 28 or higher.\n if (typeof expect === 'object') {\n const jestGlobals = require('@jest/globals');\n expect = jestGlobals.expect;\n }\n if (expect === undefined || expect.extend === undefined) {\n expect = expectModule.default;\n }\n }\n\n require('setimmediate');\n frameTime = Math.round(1000 / config.fps);\n\n config = {\n ...config,\n ...userConfig,\n };\n\n expect.extend({\n toHaveAnimatedStyle(received, expectedStyle, config = {}) {\n return compareStyle(received, expectedStyle, config);\n },\n });\n};\n\nexport const getAnimatedStyle = (received) => {\n return getCurrentStyle(received);\n};\n"],"mappings":";;;;;;AAAA;AACA;AAYA,IAAIA,MAAM,GAAG;EACXC,GAAG,EAAE;AADM,CAAb;;AAIA,MAAMC,eAAe,GAAIC,KAAD,IAAW;EACjC,OAAO,CAAC,CAACA,KAAK,CAACC,aAAf;AACD,CAFD;;AAIA,MAAMC,0BAA0B,GAAIF,KAAD,IAAW;EAC5C,OAAOA,KAAK,CAACC,aAAN,CAAoBE,OAApB,CAA4BC,KAAnC;AACD,CAFD;;AAIA,MAAMC,eAAe,GAAIC,QAAD,IAAc;EACpC,MAAMC,WAAW,GAAGD,QAAQ,CAACE,KAAT,CAAeR,KAAnC;EACA,IAAIS,YAAY,GAAG,EAAnB;;EACA,IAAIC,KAAK,CAACC,OAAN,CAAcJ,WAAd,CAAJ,EAAgC;IAC9BD,QAAQ,CAACE,KAAT,CAAeR,KAAf,CAAqBY,OAArB,CAA8BZ,KAAD,IAAW;MACtC,IAAID,eAAe,CAACC,KAAD,CAAnB,EAA4B;QAC1BS,YAAY,GAAG,EACb,GAAGA,YADU;UAEb,GAAGP,0BAA0B,CAACF,KAAD;QAFhB,CAAf;MAID,CALD,MAKO;QACLS,YAAY,GAAG,EAC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StyleFromObject","current","value","getCurrentStyle","received","styleObject","props","currentStyle","Array","isArray","forEach","checkEqual","expectStyle","length","i","property","findStyleDiff","expect","requireAllMatch","diffs","isEqual","push","Object","keys","undefined","compareStyle","expectedStyle","message","pass","exact","currentStyleStr","JSON","stringify","expectedStyleStr","differences","map","diff","join","frameTime","beforeTest","jest","useFakeTimers","afterTest","runOnlyPendingTimers","useRealTimers","withReanimatedTimer","animationTest","console","warn","advanceAnimationByTime","time","advanceTimersByTime","advanceAnimationByFrame","count","setUpTests","userConfig","global","expectModule","require","jestGlobals","extend","default","Math","round","toHaveAnimatedStyle","getAnimatedStyle"],"sources":["jestUtils.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R> {\n toHaveAnimatedStyle(\n style: Record<string, unknown>[] | Record<string, unknown>\n ): R;\n }\n }\n}\n\nlet config = {\n fps: 60,\n};\n\nconst isAnimatedStyle = (style) => {\n return !!style.animatedStyle;\n};\n\nconst getAnimatedStyleFromObject = (style) => {\n return style.animatedStyle.current.value;\n};\n\nconst getCurrentStyle = (received) => {\n const styleObject = received.props.style;\n let currentStyle = {};\n if (Array.isArray(styleObject)) {\n received.props.style.forEach((style) => {\n if (isAnimatedStyle(style)) {\n currentStyle = {\n ...currentStyle,\n ...getAnimatedStyleFromObject(style),\n };\n } else {\n currentStyle = {\n ...currentStyle,\n ...style,\n };\n }\n });\n } else {\n if (isAnimatedStyle(styleObject)) {\n currentStyle = getAnimatedStyleFromObject(styleObject);\n } else {\n currentStyle = {\n ...styleObject,\n ...received.props.animatedStyle.value,\n };\n }\n }\n return currentStyle;\n};\n\nconst checkEqual = (currentStyle, expectStyle) => {\n if (Array.isArray(expectStyle)) {\n if (expectStyle.length !== currentStyle.length) return false;\n for (let i = 0; i < currentStyle.length; i++) {\n if (!checkEqual(currentStyle[i], expectStyle[i])) {\n return false;\n }\n }\n } else if (typeof currentStyle === 'object' && currentStyle) {\n for (const property in expectStyle) {\n if (!checkEqual(currentStyle[property], expectStyle[property])) {\n return false;\n }\n }\n } else {\n return currentStyle === expectStyle;\n }\n return true;\n};\n\nconst findStyleDiff = (current, expect, requireAllMatch) => {\n const diffs = [];\n let isEqual = true;\n for (const property in expect) {\n if (!checkEqual(current[property], expect[property])) {\n isEqual = false;\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n\n if (\n requireAllMatch &&\n Object.keys(current).length !== Object.keys(expect).length\n ) {\n isEqual = false;\n for (const property in current) {\n if (expect[property] === undefined) {\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n }\n\n return { isEqual, diffs };\n};\n\nconst compareStyle = (received, expectedStyle, config) => {\n if (!received.props.style) {\n return { message: () => message, pass: false };\n }\n const { exact } = config;\n const currentStyle = getCurrentStyle(received);\n const { isEqual, diffs } = findStyleDiff(currentStyle, expectedStyle, exact);\n\n if (isEqual) {\n return { message: () => 'ok', pass: true };\n }\n\n const currentStyleStr = JSON.stringify(currentStyle);\n const expectedStyleStr = JSON.stringify(expectedStyle);\n const differences = diffs\n .map(\n (diff) =>\n `- '${diff.property}' should be ${JSON.stringify(\n diff.expect\n )}, but is ${JSON.stringify(diff.current)}`\n )\n .join('\\n');\n\n return {\n message: () =>\n `Expected: ${expectedStyleStr}\\nReceived: ${currentStyleStr}\\n\\nDifferences:\\n${differences}`,\n pass: false,\n };\n};\n\nlet frameTime = 1000 / config.fps;\n\nconst beforeTest = () => {\n jest.useFakeTimers();\n};\n\nconst afterTest = () => {\n jest.runOnlyPendingTimers();\n jest.useRealTimers();\n};\n\nexport const withReanimatedTimer = (animationTest) => {\n console.warn(\n 'This method is deprecated, you should define your own before and after test hooks to enable jest.useFakeTimers(). Check out the documentation for details on testing'\n );\n beforeTest();\n animationTest();\n afterTest();\n};\n\nexport const advanceAnimationByTime = (time = frameTime) => {\n console.warn(\n 'This method is deprecated, use jest.advanceTimersByTime directly'\n );\n jest.advanceTimersByTime(time);\n jest.runOnlyPendingTimers();\n};\n\nexport const advanceAnimationByFrame = (count) => {\n console.warn(\n 'This method is deprecated, use jest.advanceTimersByTime directly'\n );\n jest.advanceTimersByTime(count * frameTime);\n jest.runOnlyPendingTimers();\n};\n\nexport const setUpTests = (userConfig = {}) => {\n let expect = global.expect;\n if (expect === undefined) {\n const expectModule = require('expect');\n expect = expectModule;\n // Starting from Jest 28, \"expect\" package uses named exports instead of default export.\n // So, requiring \"expect\" package doesn't give direct access to \"expect\" function anymore.\n // It gives access to the module object instead.\n // We use this info to detect if the project uses Jest 28 or higher.\n if (typeof expect === 'object') {\n const jestGlobals = require('@jest/globals');\n expect = jestGlobals.expect;\n }\n if (expect === undefined || expect.extend === undefined) {\n expect = expectModule.default;\n }\n }\n\n require('setimmediate');\n frameTime = Math.round(1000 / config.fps);\n\n config = {\n ...config,\n ...userConfig,\n };\n\n expect.extend({\n toHaveAnimatedStyle(received, expectedStyle, config = {}) {\n return compareStyle(received, expectedStyle, config);\n },\n });\n};\n\nexport const getAnimatedStyle = (received) => {\n return getCurrentStyle(received);\n};\n"],"mappings":";;;;;;AAAA;AACA;AAYA,IAAIA,MAAM,GAAG;EACXC,GAAG,EAAE;AADM,CAAb;;AAIA,MAAMC,eAAe,GAAIC,KAAD,IAAW;EACjC,OAAO,CAAC,CAACA,KAAK,CAACC,aAAf;AACD,CAFD;;AAIA,MAAMC,0BAA0B,GAAIF,KAAD,IAAW;EAC5C,OAAOA,KAAK,CAACC,aAAN,CAAoBE,OAApB,CAA4BC,KAAnC;AACD,CAFD;;AAIA,MAAMC,eAAe,GAAIC,QAAD,IAAc;EACpC,MAAMC,WAAW,GAAGD,QAAQ,CAACE,KAAT,CAAeR,KAAnC;EACA,IAAIS,YAAY,GAAG,EAAnB;;EACA,IAAIC,KAAK,CAACC,OAAN,CAAcJ,WAAd,CAAJ,EAAgC;IAC9BD,QAAQ,CAACE,KAAT,CAAeR,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A0B/B,MAA1B,CAAnB;IACD;;EAHW,CAAd;AAKD,CA/BM;;;;AAiCA,MAAMsE,gBAAgB,GAAI7D,QAAD,IAAc;EAC5C,OAAOD,eAAe,CAACC,QAAD,CAAtB;AACD,CAFM"}
@@ -7,7 +7,7 @@ exports.default = void 0;
7
7
 
8
8
  var _NativeReanimated = require("../NativeReanimated/NativeReanimated");
9
9
 
10
- var _PlatformChecker = require("../PlatformChecker");
10
+ var _commonTypes = require("../commonTypes");
11
11
 
12
12
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
13
 
@@ -15,16 +15,9 @@ class JSReanimated extends _NativeReanimated.NativeReanimated {
15
15
  constructor() {
16
16
  super(false);
17
17
 
18
- _defineProperty(this, "_valueUnpacker", undefined);
18
+ _defineProperty(this, "nextSensorId", 0);
19
19
 
20
- if ((0, _PlatformChecker.isJest)()) {
21
- // on node < 16 jest have problems mocking performance.now method which
22
- // results in the tests failing, since date precision isn't that important
23
- // for tests, we use Date.now instead
24
- this.getTimestamp = () => Date.now();
25
- } else {
26
- this.getTimestamp = () => window.performance.now();
27
- }
20
+ _defineProperty(this, "sensors", new Map());
28
21
  }
29
22
 
30
23
  makeShareableClone(value) {
@@ -33,8 +26,7 @@ class JSReanimated extends _NativeReanimated.NativeReanimated {
33
26
  };
34
27
  }
35
28
 
36
- installCoreFunctions(valueUnpacker) {
37
- this._valueUnpacker = valueUnpacker;
29
+ installCoreFunctions(_callGuard, _valueUnpacker) {// noop
38
30
  }
39
31
 
40
32
  scheduleOnUI(worklet) {
@@ -54,12 +46,61 @@ class JSReanimated extends _NativeReanimated.NativeReanimated {
54
46
  console.warn('[Reanimated] enableLayoutAnimations is not available for WEB yet');
55
47
  }
56
48
 
57
- registerSensor() {
58
- console.warn('[Reanimated] useAnimatedSensor is not available on web yet.');
59
- return -1;
49
+ registerSensor(sensorType, interval, iosReferenceFrame, eventHandler) {
50
+ if (!(this.getSensorName(sensorType) in window)) {
51
+ return -1;
52
+ }
53
+
54
+ const sensor = this.initializeSensor(sensorType, interval);
55
+ let callback;
56
+
57
+ if (sensorType === _commonTypes.SensorType.ROTATION) {
58
+ callback = () => {
59
+ const [qw, qx, qy, qz] = sensor.quaternion; // reference: https://stackoverflow.com/questions/5782658/extracting-yaw-from-a-quaternion
60
+
61
+ const yaw = Math.atan2(2.0 * (qy * qz + qw * qx), qw * qw - qx * qx - qy * qy + qz * qz);
62
+ const pitch = Math.sin(-2.0 * (qx * qz - qw * qy));
63
+ const roll = Math.atan2(2.0 * (qx * qy + qw * qz), qw * qw + qx * qx - qy * qy - qz * qz);
64
+ eventHandler({
65
+ qw,
66
+ qx,
67
+ qy,
68
+ qz,
69
+ yaw,
70
+ pitch,
71
+ roll,
72
+ interfaceOrientation: 0
73
+ });
74
+ };
75
+ } else {
76
+ callback = () => {
77
+ const {
78
+ x,
79
+ y,
80
+ z
81
+ } = sensor;
82
+ eventHandler({
83
+ x,
84
+ y,
85
+ z,
86
+ interfaceOrientation: 0
87
+ });
88
+ };
89
+ }
90
+
91
+ sensor.addEventListener('reading', callback);
92
+ sensor.start();
93
+ this.sensors.set(this.nextSensorId, sensor);
94
+ return this.nextSensorId++;
60
95
  }
61
96
 
62
- unregisterSensor() {// noop
97
+ unregisterSensor(id) {
98
+ const sensor = this.sensors.get(id);
99
+
100
+ if (sensor !== undefined) {
101
+ sensor.stop();
102
+ this.sensors.delete(id);
103
+ }
63
104
  }
64
105
 
65
106
  subscribeForKeyboardEvents(_) {
@@ -70,6 +111,50 @@ class JSReanimated extends _NativeReanimated.NativeReanimated {
70
111
  unsubscribeFromKeyboardEvents(_) {// noop
71
112
  }
72
113
 
114
+ initializeSensor(sensorType, interval) {
115
+ const config = interval <= 0 ? {
116
+ referenceFrame: 'device'
117
+ } : {
118
+ frequency: 1000 / interval
119
+ };
120
+
121
+ switch (sensorType) {
122
+ case _commonTypes.SensorType.ACCELEROMETER:
123
+ return new window.Accelerometer(config);
124
+
125
+ case _commonTypes.SensorType.GYROSCOPE:
126
+ return new window.Gyroscope(config);
127
+
128
+ case _commonTypes.SensorType.GRAVITY:
129
+ return new window.GravitySensor(config);
130
+
131
+ case _commonTypes.SensorType.MAGNETIC_FIELD:
132
+ return new window.Magnetometer(config);
133
+
134
+ case _commonTypes.SensorType.ROTATION:
135
+ return new window.AbsoluteOrientationSensor(config);
136
+ }
137
+ }
138
+
139
+ getSensorName(sensorType) {
140
+ switch (sensorType) {
141
+ case _commonTypes.SensorType.ACCELEROMETER:
142
+ return 'Accelerometer';
143
+
144
+ case _commonTypes.SensorType.GRAVITY:
145
+ return 'GravitySensor';
146
+
147
+ case _commonTypes.SensorType.GYROSCOPE:
148
+ return 'Gyroscope';
149
+
150
+ case _commonTypes.SensorType.MAGNETIC_FIELD:
151
+ return 'Magnetometer';
152
+
153
+ case _commonTypes.SensorType.ROTATION:
154
+ return 'AbsoluteOrientationSensor';
155
+ }
156
+ }
157
+
73
158
  }
74
159
 
75
160
  exports.default = JSReanimated;
@@ -1 +1 @@
1
- {"version":3,"names":["JSReanimated","NativeReanimated","constructor","undefined","isJest","getTimestamp","Date","now","window","performance","makeShareableClone","value","__hostObjectShareableJSRef","installCoreFunctions","valueUnpacker","_valueUnpacker","scheduleOnUI","worklet","requestAnimationFrame","registerEventHandler","_eventHash","_eventHandler","unregisterEventHandler","_","enableLayoutAnimations","console","warn","registerSensor","unregisterSensor","subscribeForKeyboardEvents","unsubscribeFromKeyboardEvents"],"sources":["JSReanimated.ts"],"sourcesContent":["import { NativeReanimated } from '../NativeReanimated/NativeReanimated';\nimport { ShareableRef } from '../commonTypes';\nimport { isJest } from '../PlatformChecker';\n\nexport default class JSReanimated extends NativeReanimated {\n _valueUnpacker?: <T>(value: T) => void = undefined;\n\n constructor() {\n super(false);\n if (isJest()) {\n // on node < 16 jest have problems mocking performance.now method which\n // results in the tests failing, since date precision isn't that important\n // for tests, we use Date.now instead\n this.getTimestamp = () => Date.now();\n } else {\n this.getTimestamp = () => window.performance.now();\n }\n }\n\n makeShareableClone<T>(value: T): ShareableRef<T> {\n return { __hostObjectShareableJSRef: value };\n }\n\n installCoreFunctions(valueUnpacker: <T>(value: T) => T): void {\n this._valueUnpacker = valueUnpacker;\n }\n\n scheduleOnUI<T>(worklet: ShareableRef<T>) {\n // @ts-ignore web implementation has still not been updated after the rewrite, this will be addressed once the web implementation updates are ready\n requestAnimationFrame(worklet);\n }\n\n registerEventHandler<T>(\n _eventHash: string,\n _eventHandler: ShareableRef<T>\n ): string {\n // noop\n return '';\n }\n\n unregisterEventHandler(_: string): void {\n // noop\n }\n\n enableLayoutAnimations() {\n console.warn(\n '[Reanimated] enableLayoutAnimations is not available for WEB yet'\n );\n }\n\n registerSensor(): number {\n console.warn('[Reanimated] useAnimatedSensor is not available on web yet.');\n return -1;\n }\n\n unregisterSensor(): void {\n // noop\n }\n\n subscribeForKeyboardEvents(_: ShareableRef<number>): number {\n console.warn(\n '[Reanimated] useAnimatedKeyboard is not available on web yet.'\n );\n return -1;\n }\n\n unsubscribeFromKeyboardEvents(_: number): void {\n // noop\n }\n}\n"],"mappings":";;;;;;;AAAA;;AAEA;;;;AAEe,MAAMA,YAAN,SAA2BC,kCAA3B,CAA4C;EAGzDC,WAAW,GAAG;IACZ,MAAM,KAAN;;IADY,wCAF2BC,SAE3B;;IAEZ,IAAI,IAAAC,uBAAA,GAAJ,EAAc;MACZ;MACA;MACA;MACA,KAAKC,YAAL,GAAoB,MAAMC,IAAI,CAACC,GAAL,EAA1B;IACD,CALD,MAKO;MACL,KAAKF,YAAL,GAAoB,MAAMG,MAAM,CAACC,WAAP,CAAmBF,GAAnB,EAA1B;IACD;EACF;;EAEDG,kBAAkB,CAAIC,KAAJ,EAA+B;IAC/C,OAAO;MAAEC,0BAA0B,EAAED;IAA9B,CAAP;EACD;;EAEDE,oBAAoB,CAACC,aAAD,EAA0C;IAC5D,KAAKC,cAAL,GAAsBD,aAAtB;EACD;;EAEDE,YAAY,CAAIC,OAAJ,EAA8B;IACxC;IACAC,qBAAqB,CAACD,OAAD,CAArB;EACD;;EAEDE,oBAAoB,CAClBC,UADkB,EAElBC,aAFkB,EAGV;IACR;IACA,OAAO,EAAP;EACD;;EAEDC,sBAAsB,CAACC,CAAD,EAAkB,CACtC;EACD;;EAEDC,sBAAsB,GAAG;IACvBC,OAAO,CAACC,IAAR,CACE,kEADF;EAGD;;EAEDC,cAAc,GAAW;IACvBF,OAAO,CAACC,IAAR,CAAa,6DAAb;IACA,OAAO,CAAC,CAAR;EACD;;EAEDE,gBAAgB,GAAS,CACvB;EACD;;EAEDC,0BAA0B,CAACN,CAAD,EAAkC;IAC1DE,OAAO,CAACC,IAAR,CACE,+DADF;IAGA,OAAO,CAAC,CAAR;EACD;;EAEDI,6BAA6B,CAACP,CAAD,EAAkB,CAC7C;EACD;;AAhEwD"}
1
+ {"version":3,"names":["JSReanimated","NativeReanimated","constructor","Map","makeShareableClone","value","__hostObjectShareableJSRef","installCoreFunctions","_callGuard","_valueUnpacker","scheduleOnUI","worklet","requestAnimationFrame","registerEventHandler","_eventHash","_eventHandler","unregisterEventHandler","_","enableLayoutAnimations","console","warn","registerSensor","sensorType","interval","iosReferenceFrame","eventHandler","getSensorName","window","sensor","initializeSensor","callback","SensorType","ROTATION","qw","qx","qy","qz","quaternion","yaw","Math","atan2","pitch","sin","roll","interfaceOrientation","x","y","z","addEventListener","start","sensors","set","nextSensorId","unregisterSensor","id","get","undefined","stop","delete","subscribeForKeyboardEvents","unsubscribeFromKeyboardEvents","config","referenceFrame","frequency","ACCELEROMETER","Accelerometer","GYROSCOPE","Gyroscope","GRAVITY","GravitySensor","MAGNETIC_FIELD","Magnetometer","AbsoluteOrientationSensor"],"sources":["JSReanimated.ts"],"sourcesContent":["import { NativeReanimated } from '../NativeReanimated/NativeReanimated';\nimport {\n SensorType,\n ShareableRef,\n Value3D,\n ValueRotation,\n} from '../commonTypes';\nimport { WebSensor } from './WebSensor';\n\nexport default class JSReanimated extends NativeReanimated {\n nextSensorId = 0;\n sensors = new Map<number, WebSensor>();\n\n constructor() {\n super(false);\n }\n\n makeShareableClone<T>(value: T): ShareableRef<T> {\n return { __hostObjectShareableJSRef: value };\n }\n\n installCoreFunctions(\n _callGuard: <T extends Array<any>, U>(\n fn: (...args: T) => U,\n ...args: T\n ) => void,\n _valueUnpacker: <T>(value: T) => T\n ): void {\n // noop\n }\n\n scheduleOnUI<T>(worklet: ShareableRef<T>) {\n // @ts-ignore web implementation has still not been updated after the rewrite, this will be addressed once the web implementation updates are ready\n requestAnimationFrame(worklet);\n }\n\n registerEventHandler<T>(\n _eventHash: string,\n _eventHandler: ShareableRef<T>\n ): string {\n // noop\n return '';\n }\n\n unregisterEventHandler(_: string): void {\n // noop\n }\n\n enableLayoutAnimations() {\n console.warn(\n '[Reanimated] enableLayoutAnimations is not available for WEB yet'\n );\n }\n\n registerSensor(\n sensorType: SensorType,\n interval: number,\n iosReferenceFrame: number,\n eventHandler: (data: Value3D | ValueRotation) => void\n ): number {\n if (!(this.getSensorName(sensorType) in window)) {\n return -1;\n }\n\n const sensor: WebSensor = this.initializeSensor(sensorType, interval);\n let callback;\n if (sensorType === SensorType.ROTATION) {\n callback = () => {\n const [qw, qx, qy, qz] = sensor.quaternion;\n\n // reference: https://stackoverflow.com/questions/5782658/extracting-yaw-from-a-quaternion\n const yaw = Math.atan2(\n 2.0 * (qy * qz + qw * qx),\n qw * qw - qx * qx - qy * qy + qz * qz\n );\n const pitch = Math.sin(-2.0 * (qx * qz - qw * qy));\n const roll = Math.atan2(\n 2.0 * (qx * qy + qw * qz),\n qw * qw + qx * qx - qy * qy - qz * qz\n );\n eventHandler({\n qw,\n qx,\n qy,\n qz,\n yaw,\n pitch,\n roll,\n interfaceOrientation: 0,\n });\n };\n } else {\n callback = () => {\n const { x, y, z } = sensor;\n eventHandler({ x, y, z, interfaceOrientation: 0 });\n };\n }\n sensor.addEventListener('reading', callback);\n sensor.start();\n\n this.sensors.set(this.nextSensorId, sensor);\n return this.nextSensorId++;\n }\n\n unregisterSensor(id: number): void {\n const sensor: WebSensor | undefined = this.sensors.get(id);\n if (sensor !== undefined) {\n sensor.stop();\n this.sensors.delete(id);\n }\n }\n\n subscribeForKeyboardEvents(_: ShareableRef<number>): number {\n console.warn(\n '[Reanimated] useAnimatedKeyboard is not available on web yet.'\n );\n return -1;\n }\n\n unsubscribeFromKeyboardEvents(_: number): void {\n // noop\n }\n\n initializeSensor(sensorType: SensorType, interval: number): WebSensor {\n const config =\n interval <= 0\n ? { referenceFrame: 'device' }\n : { frequency: 1000 / interval };\n switch (sensorType) {\n case SensorType.ACCELEROMETER:\n return new window.Accelerometer(config);\n case SensorType.GYROSCOPE:\n return new window.Gyroscope(config);\n case SensorType.GRAVITY:\n return new window.GravitySensor(config);\n case SensorType.MAGNETIC_FIELD:\n return new window.Magnetometer(config);\n case SensorType.ROTATION:\n return new window.AbsoluteOrientationSensor(config);\n }\n }\n\n getSensorName(sensorType: SensorType): string {\n switch (sensorType) {\n case SensorType.ACCELEROMETER:\n return 'Accelerometer';\n case SensorType.GRAVITY:\n return 'GravitySensor';\n case SensorType.GYROSCOPE:\n return 'Gyroscope';\n case SensorType.MAGNETIC_FIELD:\n return 'Magnetometer';\n case SensorType.ROTATION:\n return 'AbsoluteOrientationSensor';\n }\n }\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;;;AAQe,MAAMA,YAAN,SAA2BC,kCAA3B,CAA4C;EAIzDC,WAAW,GAAG;IACZ,MAAM,KAAN;;IADY,sCAHC,CAGD;;IAAA,iCAFJ,IAAIC,GAAJ,EAEI;EAEb;;EAEDC,kBAAkB,CAAIC,KAAJ,EAA+B;IAC/C,OAAO;MAAEC,0BAA0B,EAAED;IAA9B,CAAP;EACD;;EAEDE,oBAAoB,CAClBC,UADkB,EAKlBC,cALkB,EAMZ,CACN;EACD;;EAEDC,YAAY,CAAIC,OAAJ,EAA8B;IACxC;IACAC,qBAAqB,CAACD,OAAD,CAArB;EAC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IrC,MAAM,CAACsC,aAAX,CAAyBJ,MAAzB,CAAP;;MACF,KAAK9B,uBAAA,CAAWmC,SAAhB;QACE,OAAO,IAAIvC,MAAM,CAACwC,SAAX,CAAqBN,MAArB,CAAP;;MACF,KAAK9B,uBAAA,CAAWqC,OAAhB;QACE,OAAO,IAAIzC,MAAM,CAAC0C,aAAX,CAAyBR,MAAzB,CAAP;;MACF,KAAK9B,uBAAA,CAAWuC,cAAhB;QACE,OAAO,IAAI3C,MAAM,CAAC4C,YAAX,CAAwBV,MAAxB,CAAP;;MACF,KAAK9B,uBAAA,CAAWC,QAAhB;QACE,OAAO,IAAIL,MAAM,CAAC6C,yBAAX,CAAqCX,MAArC,CAAP;IAVJ;EAYD;;EAEDnC,aAAa,CAACJ,UAAD,EAAiC;IAC5C,QAAQA,UAAR;MACE,KAAKS,uBAAA,CAAWiC,aAAhB;QACE,OAAO,eAAP;;MACF,KAAKjC,uBAAA,CAAWqC,OAAhB;QACE,OAAO,eAAP;;MACF,KAAKrC,uBAAA,CAAWmC,SAAhB;QACE,OAAO,WAAP;;MACF,KAAKnC,uBAAA,CAAWuC,cAAhB;QACE,OAAO,cAAP;;MACF,KAAKvC,uBAAA,CAAWC,QAAhB;QACE,OAAO,2BAAP;IAVJ;EAYD;;AAlJwD"}
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
+ var _PlatformChecker = require("../PlatformChecker");
9
+
8
10
  var _MutableValue = _interopRequireDefault(require("./MutableValue"));
9
11
 
10
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -55,6 +57,8 @@ class Mapper {
55
57
  res.push(value);
56
58
  } else if (Array.isArray(value)) {
57
59
  value.forEach(v => extractMutables(v));
60
+ } else if (isWebDomElement(value)) {// do nothing on dom elements
61
+ // without this check, we get a "Maximum call size exceeded error"
58
62
  } else if (typeof value === 'object') {
59
63
  Object.keys(value).forEach(key => {
60
64
  extractMutables(value[key]);
@@ -71,4 +75,22 @@ class Mapper {
71
75
  exports.default = Mapper;
72
76
 
73
77
  _defineProperty(Mapper, "MAPPER_ID", 1);
78
+
79
+ function isWebDomElement(value) {
80
+ if (!(0, _PlatformChecker.shouldBeUseWeb)()) {
81
+ return false;
82
+ } // https://stackoverflow.com/a/384380/7869175
83
+
84
+
85
+ function isWebNode(o) {
86
+ return typeof Node === 'object' ? o instanceof Node : o && typeof o === 'object' && typeof o.nodeType === 'number' && typeof o.nodeName === 'string';
87
+ }
88
+
89
+ function isWebElement(o) {
90
+ return typeof HTMLElement === 'object' ? o instanceof HTMLElement // DOM2
91
+ : o && typeof o === 'object' && o !== null && o.nodeType === 1 && typeof o.nodeName === 'string';
92
+ }
93
+
94
+ return isWebNode(value) || isWebElement(value);
95
+ }
74
96
  //# sourceMappingURL=Mapper.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Mapper","constructor","module","mapper","inputs","outputs","id","MAPPER_ID","extractMutablesFromArray","markDirty","dirty","maybeRequestRender","forEach","input","addListener","execute","array","res","extractMutables","value","MutableValue","push","Array","isArray","v","Object","keys","key"],"sources":["Mapper.ts"],"sourcesContent":["import { NestedObjectValues } from '../commonTypes';\nimport { JSReanimated } from './commonTypes';\nimport MutableValue from './MutableValue';\n\nexport default class Mapper<T> {\n static MAPPER_ID = 1;\n id: number;\n inputs: MutableValue<T>[];\n outputs: MutableValue<T>[];\n mapper: () => void;\n\n dirty = true;\n\n constructor(\n module: JSReanimated,\n mapper: () => void,\n inputs: NestedObjectValues<MutableValue<T>>[] = [],\n outputs: NestedObjectValues<MutableValue<T>>[] = []\n ) {\n this.id = Mapper.MAPPER_ID++;\n this.inputs = this.extractMutablesFromArray(inputs);\n this.outputs = this.extractMutablesFromArray(outputs);\n this.mapper = mapper;\n\n const markDirty = () => {\n this.dirty = true;\n module.maybeRequestRender();\n };\n\n this.inputs.forEach((input) => {\n input.addListener(markDirty);\n });\n }\n\n execute(): void {\n this.dirty = false;\n this.mapper();\n }\n\n extractMutablesFromArray<T>(\n array: NestedObjectValues<MutableValue<T>>\n ): MutableValue<T>[] {\n const res: MutableValue<T>[] = [];\n\n function extractMutables(value: NestedObjectValues<MutableValue<T>>) {\n if (value == null) {\n // return;\n } else if (value instanceof MutableValue) {\n res.push(value);\n } else if (Array.isArray(value)) {\n value.forEach((v) => extractMutables(v));\n } else if (typeof value === 'object') {\n Object.keys(value).forEach((key) => {\n extractMutables(value[key]);\n });\n }\n }\n\n extractMutables(array);\n return res;\n }\n}\n"],"mappings":";;;;;;;AAEA;;;;;;AAEe,MAAMA,MAAN,CAAgB;EAS7BC,WAAW,CACTC,MADS,EAETC,MAFS,EAKT;IAAA,IAFAC,MAEA,uEAFgD,EAEhD;IAAA,IADAC,OACA,uEADiD,EACjD;;IAAA;;IAAA;;IAAA;;IAAA;;IAAA,+BAPM,IAON;;IACA,KAAKC,EAAL,GAAUN,MAAM,CAACO,SAAP,EAAV;IACA,KAAKH,MAAL,GAAc,KAAKI,wBAAL,CAA8BJ,MAA9B,CAAd;IACA,KAAKC,OAAL,GAAe,KAAKG,wBAAL,CAA8BH,OAA9B,CAAf;IACA,KAAKF,MAAL,GAAcA,MAAd;;IAEA,MAAMM,SAAS,GAAG,MAAM;MACtB,KAAKC,KAAL,GAAa,IAAb;MACAR,MAAM,CAACS,kBAAP;IACD,CAHD;;IAKA,KAAKP,MAAL,CAAYQ,OAAZ,CAAqBC,KAAD,IAAW;MAC7BA,KAAK,CAACC,WAAN,CAAkBL,SAAlB;IACD,CAFD;EAGD;;EAEDM,OAAO,GAAS;IACd,KAAKL,KAAL,GAAa,KAAb;IACA,KAAKP,MAAL;EACD;;EAEDK,wBAAwB,CACtBQ,KADsB,EAEH;IACnB,MAAMC,GAAsB,GAAG,EAA/B;;IAEA,SAASC,eAAT,CAAyBC,KAAzB,EAAqE;MACnE,IAAIA,KAAK,IAAI,IAAb,EAAmB,CACjB;MACD,CAFD,MAEO,IAAIA,KAAK,YAAYC,qBAArB,EAAmC;QACxCH,GAAG,CAACI,IAAJ,CAASF,KAAT;MACD,CAFM,MAEA,IAAIG,KAAK,CAACC,OAAN,CAAcJ,KAAd,CAAJ,EAA0B;QAC/BA,KAAK,CAACP,OAAN,CAAeY,CAAD,IAAON,eAAe,CAACM,CAAD,CAApC;MACD,CAFM,MAEA,IAAI,OAAOL,KAAP,KAAiB,QAArB,EAA+B;QACpCM,MAAM,CAACC,IAAP,CAAYP,KAAZ,EAAmBP,OAAnB,CAA4Be,GAAD,IAAS;UAClCT,eAAe,CAACC,KAAK,CAACQ,GAAD,CAAN,CAAf;QACD,CAFD;MAGD;IACF;;IAEDT,eAAe,CAACF,KAAD,CAAf;IACA,OAAOC,GAAP;EACD;;AAxD4B;;;;gBAAVjB,M,eACA,C"}
1
+ {"version":3,"names":["Mapper","constructor","module","mapper","inputs","outputs","id","MAPPER_ID","extractMutablesFromArray","markDirty","dirty","maybeRequestRender","forEach","input","addListener","execute","array","res","extractMutables","value","MutableValue","push","Array","isArray","v","isWebDomElement","Object","keys","key","shouldBeUseWeb","isWebNode","o","Node","nodeType","nodeName","isWebElement","HTMLElement"],"sources":["Mapper.ts"],"sourcesContent":["import { NestedObjectValues } from '../commonTypes';\nimport { shouldBeUseWeb } from '../PlatformChecker';\nimport { JSReanimated } from './commonTypes';\nimport MutableValue from './MutableValue';\n\nexport default class Mapper<T> {\n static MAPPER_ID = 1;\n id: number;\n inputs: MutableValue<T>[];\n outputs: MutableValue<T>[];\n mapper: () => void;\n\n dirty = true;\n\n constructor(\n module: JSReanimated,\n mapper: () => void,\n inputs: NestedObjectValues<MutableValue<T>>[] = [],\n outputs: NestedObjectValues<MutableValue<T>>[] = []\n ) {\n this.id = Mapper.MAPPER_ID++;\n this.inputs = this.extractMutablesFromArray(inputs);\n this.outputs = this.extractMutablesFromArray(outputs);\n this.mapper = mapper;\n\n const markDirty = () => {\n this.dirty = true;\n module.maybeRequestRender();\n };\n\n this.inputs.forEach((input) => {\n input.addListener(markDirty);\n });\n }\n\n execute(): void {\n this.dirty = false;\n this.mapper();\n }\n\n extractMutablesFromArray<T>(\n array: NestedObjectValues<MutableValue<T>>\n ): MutableValue<T>[] {\n const res: MutableValue<T>[] = [];\n\n function extractMutables(value: NestedObjectValues<MutableValue<T>>) {\n if (value == null) {\n // return;\n } else if (value instanceof MutableValue) {\n res.push(value);\n } else if (Array.isArray(value)) {\n value.forEach((v) => extractMutables(v));\n } else if (isWebDomElement(value)) {\n // do nothing on dom elements\n // without this check, we get a \"Maximum call size exceeded error\"\n } else if (typeof value === 'object') {\n Object.keys(value).forEach((key) => {\n extractMutables(value[key]);\n });\n }\n }\n\n extractMutables(array);\n return res;\n }\n}\n\nfunction isWebDomElement(value: any) {\n if (!shouldBeUseWeb()) {\n return false;\n }\n\n // https://stackoverflow.com/a/384380/7869175\n function isWebNode(o: any) {\n return typeof Node === 'object'\n ? o instanceof Node\n : o &&\n typeof o === 'object' &&\n typeof o.nodeType === 'number' &&\n typeof o.nodeName === 'string';\n }\n\n function isWebElement(o: any) {\n return typeof HTMLElement === 'object'\n ? o instanceof HTMLElement // DOM2\n : o &&\n typeof o === 'object' &&\n o !== null &&\n o.nodeType === 1 &&\n typeof o.nodeName === 'string';\n }\n\n return isWebNode(value) || isWebElement(value);\n}\n"],"mappings":";;;;;;;AACA;;AAEA;;;;;;AAEe,MAAMA,MAAN,CAAgB;EAS7BC,WAAW,CACTC,MADS,EAETC,MAFS,EAKT;IAAA,IAFAC,MAEA,uEAFgD,EAEhD;IAAA,IADAC,OACA,uEADiD,EACjD;;IAAA;;IAAA;;IAAA;;IAAA;;IAAA,+BAPM,IAON;;IACA,KAAKC,EAAL,GAAUN,MAAM,CAACO,SAAP,EAAV;IACA,KAAKH,MAAL,GAAc,KAAKI,wBAAL,CAA8BJ,MAA9B,CAAd;IACA,KAAKC,OAAL,GAAe,KAAKG,wBAAL,CAA8BH,OAA9B,CAAf;IACA,KAAKF,MAAL,GAAcA,MAAd;;IAEA,MAAMM,SAAS,GAA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AC,YAAYC,IADV,GAEHD,CAAC,IACC,OAAOA,CAAP,KAAa,QADf,IAEE,OAAOA,CAAC,CAACE,QAAT,KAAsB,QAFxB,IAGE,OAAOF,CAAC,CAACG,QAAT,KAAsB,QAL5B;EAMD;;EAED,SAASC,YAAT,CAAsBJ,CAAtB,EAA8B;IAC5B,OAAO,OAAOK,WAAP,KAAuB,QAAvB,GACHL,CAAC,YAAYK,WADV,CACsB;IADtB,EAEHL,CAAC,IACC,OAAOA,CAAP,KAAa,QADf,IAEEA,CAAC,KAAK,IAFR,IAGEA,CAAC,CAACE,QAAF,KAAe,CAHjB,IAIE,OAAOF,CAAC,CAACG,QAAT,KAAsB,QAN5B;EAOD;;EAED,OAAOJ,SAAS,CAACX,KAAD,CAAT,IAAoBgB,YAAY,CAAChB,KAAD,CAAvC;AACD"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=WebSensor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["WebSensor.ts"],"sourcesContent":["export declare class WebSensor {\n start: () => void;\n stop: () => void;\n addEventListener: (eventType: string, eventHandler: () => void) => void;\n quaternion: [number, number, number, number];\n x: number;\n y: number;\n z: number;\n}\n\ntype configOptions =\n | {\n referenceFrame: string;\n frequency?: undefined;\n }\n | {\n frequency: number;\n referenceFrame?: undefined;\n };\n\ninterface Constructable<T> {\n new (config: configOptions): T;\n}\n\ndeclare global {\n interface Window {\n Accelerometer: Constructable<WebSensor>;\n GravitySensor: Constructable<WebSensor>;\n Gyroscope: Constructable<WebSensor>;\n Magnetometer: Constructable<WebSensor>;\n AbsoluteOrientationSensor: Constructable<WebSensor>;\n Sensor: Constructable<WebSensor>;\n }\n}\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["commonTypes.ts"],"sourcesContent":["import { Timestamp, NestedObjectValues } from '../commonTypes';\nimport MutableValue from './MutableValue';\n\nexport interface Mapper<T> {\n MAPPER_ID?: number;\n id: number;\n inputs: MutableValue<T>[];\n outputs: MutableValue<T>[];\n mapper: () => void;\n dirty: boolean;\n execute(): void;\n extractMutablesFromArray<T>(\n array: NestedObjectValues<MutableValue<T>>\n ): MutableValue<T>[];\n}\n\nexport interface MapperRegistry<T> {\n sortedMappers: Mapper<T>[];\n mappers: Map<number, Mapper<T>>;\n _module: JSReanimated;\n updatedSinceLastExecute: boolean;\n startMapper(mapper: Mapper<T>): number;\n stopMapper(id: number): void;\n execute(): void;\n updateOrder(): void;\n}\n\nexport interface JSReanimated {\n _valueSetter?: <T>(value: T) => void;\n _renderRequested: boolean;\n _mapperRegistry: MapperRegistry<any>;\n _frames: ((timestamp: Timestamp) => void)[];\n timeProvider: { now: () => number };\n pushFrame(frame: (timestamp: Timestamp) => void): void;\n getTimestamp(): number;\n maybeRequestRender(): void;\n _onRender(timestampMs: number): void;\n installCoreFunctions(valueSetter: <T>(value: T) => void): void;\n makeShareable<T>(value: T): T;\n makeMutable<T>(value: T): MutableValue<T>;\n makeRemote<T>(object: Record<string, any>): T;\n startMapper(\n mapper: () => void,\n inputs: NestedObjectValues<MutableValue<unknown>>[],\n outputs: NestedObjectValues<MutableValue<unknown>>[]\n ): number;\n stopMapper(mapperId: number): void;\n registerEventHandler<T>(_: string, __: (event: T) => void): string;\n unregisterEventHandler(_: string): void;\n enableLayoutAnimations(): void;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["commonTypes.ts"],"sourcesContent":["import { Timestamp, NestedObjectValues } from '../commonTypes';\nimport MutableValue from './MutableValue';\n\nexport interface Mapper<T> {\n MAPPER_ID?: number;\n id: number;\n inputs: MutableValue<T>[];\n outputs: MutableValue<T>[];\n mapper: () => void;\n dirty: boolean;\n execute(): void;\n extractMutablesFromArray<T>(\n array: NestedObjectValues<MutableValue<T>>\n ): MutableValue<T>[];\n}\n\nexport interface MapperRegistry<T> {\n sortedMappers: Mapper<T>[];\n mappers: Map<number, Mapper<T>>;\n _module: JSReanimated;\n updatedSinceLastExecute: boolean;\n startMapper(mapper: Mapper<T>): number;\n stopMapper(id: number): void;\n execute(): void;\n updateOrder(): void;\n}\n\nexport interface JSReanimated {\n _valueSetter?: <T>(value: T) => void;\n _renderRequested: boolean;\n _mapperRegistry: MapperRegistry<any>;\n _frames: ((timestamp: Timestamp) => void)[];\n timeProvider: { now: () => number };\n pushFrame(frame: (timestamp: Timestamp) => void): void;\n maybeRequestRender(): void;\n _onRender(timestampMs: number): void;\n installCoreFunctions(valueSetter: <T>(value: T) => void): void;\n makeShareable<T>(value: T): T;\n makeMutable<T>(value: T): MutableValue<T>;\n makeRemote<T>(object: Record<string, any>): T;\n startMapper(\n mapper: () => void,\n inputs: NestedObjectValues<MutableValue<unknown>>[],\n outputs: NestedObjectValues<MutableValue<unknown>>[]\n ): number;\n stopMapper(mapperId: number): void;\n registerEventHandler<T>(_: string, __: (event: T) => void): string;\n unregisterEventHandler(_: string): void;\n enableLayoutAnimations(): void;\n}\n"],"mappings":""}