react-native-gesture-handler 2.22.1 → 2.23.1

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 (275) hide show
  1. package/RNGestureHandler.podspec +8 -0
  2. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +14 -0
  3. package/android/src/main/jni/cpp-adapter.cpp +19 -12
  4. package/apple/RNGestureHandler.mm +15 -8
  5. package/apple/RNGestureHandlerButton.mm +12 -2
  6. package/apple/RNGestureHandlerModule.mm +17 -5
  7. package/lib/commonjs/RNGestureHandlerModule.web.js +2 -2
  8. package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
  9. package/lib/commonjs/components/DrawerLayout.js +6 -0
  10. package/lib/commonjs/components/DrawerLayout.js.map +1 -1
  11. package/lib/commonjs/components/GestureButtons.js +11 -2
  12. package/lib/commonjs/components/GestureButtons.js.map +1 -1
  13. package/lib/commonjs/components/Pressable/Pressable.js +21 -5
  14. package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
  15. package/lib/commonjs/components/Pressable/index.js.map +1 -1
  16. package/lib/commonjs/components/ReanimatedSwipeable.js +49 -20
  17. package/lib/commonjs/components/ReanimatedSwipeable.js.map +1 -1
  18. package/lib/commonjs/components/Text.js +10 -4
  19. package/lib/commonjs/components/Text.js.map +1 -1
  20. package/lib/commonjs/components/touchables/TouchableHighlight.js +2 -0
  21. package/lib/commonjs/components/touchables/TouchableHighlight.js.map +1 -1
  22. package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js +2 -0
  23. package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js.map +1 -1
  24. package/lib/commonjs/components/touchables/TouchableNativeFeedback.js +5 -1
  25. package/lib/commonjs/components/touchables/TouchableNativeFeedback.js.map +1 -1
  26. package/lib/commonjs/components/touchables/TouchableOpacity.js +2 -0
  27. package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -1
  28. package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js +3 -0
  29. package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js.map +1 -1
  30. package/lib/commonjs/findNodeHandle.web.js +9 -1
  31. package/lib/commonjs/findNodeHandle.web.js.map +1 -1
  32. package/lib/commonjs/handlers/FlingGestureHandler.js +8 -0
  33. package/lib/commonjs/handlers/FlingGestureHandler.js.map +1 -1
  34. package/lib/commonjs/handlers/ForceTouchGestureHandler.js +5 -1
  35. package/lib/commonjs/handlers/ForceTouchGestureHandler.js.map +1 -1
  36. package/lib/commonjs/handlers/LongPressGestureHandler.js +8 -0
  37. package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -1
  38. package/lib/commonjs/handlers/NativeViewGestureHandler.js +8 -0
  39. package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +1 -1
  40. package/lib/commonjs/handlers/PanGestureHandler.js +8 -0
  41. package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -1
  42. package/lib/commonjs/handlers/PinchGestureHandler.js +8 -0
  43. package/lib/commonjs/handlers/PinchGestureHandler.js.map +1 -1
  44. package/lib/commonjs/handlers/RotationGestureHandler.js +8 -0
  45. package/lib/commonjs/handlers/RotationGestureHandler.js.map +1 -1
  46. package/lib/commonjs/handlers/TapGestureHandler.js +8 -0
  47. package/lib/commonjs/handlers/TapGestureHandler.js.map +1 -1
  48. package/lib/commonjs/handlers/createHandler.js +6 -2
  49. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  50. package/lib/commonjs/handlers/gestures/GestureDetector/index.js +1 -1
  51. package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -1
  52. package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js +2 -2
  53. package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -1
  54. package/lib/commonjs/handlers/gestures/GestureDetector/utils.js +1 -1
  55. package/lib/commonjs/handlers/gestures/GestureDetector/utils.js.map +1 -1
  56. package/lib/commonjs/handlers/handlersRegistry.js +7 -2
  57. package/lib/commonjs/handlers/handlersRegistry.js.map +1 -1
  58. package/lib/commonjs/index.js.map +1 -1
  59. package/lib/commonjs/utils.js +3 -3
  60. package/lib/commonjs/utils.js.map +1 -1
  61. package/lib/commonjs/web/detectors/RotationGestureDetector.js +22 -22
  62. package/lib/commonjs/web/detectors/RotationGestureDetector.js.map +1 -1
  63. package/lib/commonjs/web/detectors/ScaleGestureDetector.js +24 -24
  64. package/lib/commonjs/web/detectors/ScaleGestureDetector.js.map +1 -1
  65. package/lib/commonjs/web/handlers/FlingGestureHandler.js +6 -6
  66. package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
  67. package/lib/commonjs/web/handlers/GestureHandler.js +112 -92
  68. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  69. package/lib/commonjs/web/handlers/HoverGestureHandler.js +2 -2
  70. package/lib/commonjs/web/handlers/HoverGestureHandler.js.map +1 -1
  71. package/lib/commonjs/web/handlers/LongPressGestureHandler.js +6 -6
  72. package/lib/commonjs/web/handlers/LongPressGestureHandler.js.map +1 -1
  73. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +13 -13
  74. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
  75. package/lib/commonjs/web/handlers/PanGestureHandler.js +15 -15
  76. package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
  77. package/lib/commonjs/web/handlers/PinchGestureHandler.js +15 -15
  78. package/lib/commonjs/web/handlers/PinchGestureHandler.js.map +1 -1
  79. package/lib/commonjs/web/handlers/RotationGestureHandler.js +12 -12
  80. package/lib/commonjs/web/handlers/RotationGestureHandler.js.map +1 -1
  81. package/lib/commonjs/web/handlers/TapGestureHandler.js +4 -4
  82. package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
  83. package/lib/commonjs/web/tools/CircularBuffer.js +15 -15
  84. package/lib/commonjs/web/tools/CircularBuffer.js.map +1 -1
  85. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +40 -40
  86. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  87. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +32 -13
  88. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  89. package/lib/commonjs/web/tools/InteractionManager.js +16 -18
  90. package/lib/commonjs/web/tools/InteractionManager.js.map +1 -1
  91. package/lib/commonjs/web/tools/NodeManager.js +2 -2
  92. package/lib/commonjs/web/tools/NodeManager.js.map +1 -1
  93. package/lib/commonjs/web/tools/PointerTracker.js +18 -18
  94. package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
  95. package/lib/commonjs/web/tools/Vector.js.map +1 -1
  96. package/lib/commonjs/web/tools/VelocityTracker.js +1 -1
  97. package/lib/commonjs/web/tools/VelocityTracker.js.map +1 -1
  98. package/lib/module/RNGestureHandlerModule.web.js +2 -2
  99. package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
  100. package/lib/module/components/DrawerLayout.js +7 -0
  101. package/lib/module/components/DrawerLayout.js.map +1 -1
  102. package/lib/module/components/GestureButtons.js +10 -2
  103. package/lib/module/components/GestureButtons.js.map +1 -1
  104. package/lib/module/components/Pressable/Pressable.js +22 -6
  105. package/lib/module/components/Pressable/Pressable.js.map +1 -1
  106. package/lib/module/components/Pressable/index.js.map +1 -1
  107. package/lib/module/components/ReanimatedSwipeable.js +49 -20
  108. package/lib/module/components/ReanimatedSwipeable.js.map +1 -1
  109. package/lib/module/components/Text.js +8 -3
  110. package/lib/module/components/Text.js.map +1 -1
  111. package/lib/module/components/touchables/TouchableHighlight.js +2 -0
  112. package/lib/module/components/touchables/TouchableHighlight.js.map +1 -1
  113. package/lib/module/components/touchables/TouchableNativeFeedback.android.js +2 -0
  114. package/lib/module/components/touchables/TouchableNativeFeedback.android.js.map +1 -1
  115. package/lib/module/components/touchables/TouchableNativeFeedback.js +6 -1
  116. package/lib/module/components/touchables/TouchableNativeFeedback.js.map +1 -1
  117. package/lib/module/components/touchables/TouchableOpacity.js +5 -0
  118. package/lib/module/components/touchables/TouchableOpacity.js.map +1 -1
  119. package/lib/module/components/touchables/TouchableWithoutFeedback.js +4 -0
  120. package/lib/module/components/touchables/TouchableWithoutFeedback.js.map +1 -1
  121. package/lib/module/findNodeHandle.web.js +8 -1
  122. package/lib/module/findNodeHandle.web.js.map +1 -1
  123. package/lib/module/handlers/FlingGestureHandler.js +7 -0
  124. package/lib/module/handlers/FlingGestureHandler.js.map +1 -1
  125. package/lib/module/handlers/ForceTouchGestureHandler.js +5 -1
  126. package/lib/module/handlers/ForceTouchGestureHandler.js.map +1 -1
  127. package/lib/module/handlers/LongPressGestureHandler.js +7 -0
  128. package/lib/module/handlers/LongPressGestureHandler.js.map +1 -1
  129. package/lib/module/handlers/NativeViewGestureHandler.js +7 -0
  130. package/lib/module/handlers/NativeViewGestureHandler.js.map +1 -1
  131. package/lib/module/handlers/PanGestureHandler.js +7 -0
  132. package/lib/module/handlers/PanGestureHandler.js.map +1 -1
  133. package/lib/module/handlers/PinchGestureHandler.js +11 -0
  134. package/lib/module/handlers/PinchGestureHandler.js.map +1 -1
  135. package/lib/module/handlers/RotationGestureHandler.js +11 -0
  136. package/lib/module/handlers/RotationGestureHandler.js.map +1 -1
  137. package/lib/module/handlers/TapGestureHandler.js +7 -0
  138. package/lib/module/handlers/TapGestureHandler.js.map +1 -1
  139. package/lib/module/handlers/createHandler.js +9 -4
  140. package/lib/module/handlers/createHandler.js.map +1 -1
  141. package/lib/module/handlers/gestures/GestureDetector/index.js +2 -2
  142. package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -1
  143. package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js +2 -2
  144. package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -1
  145. package/lib/module/handlers/gestures/GestureDetector/utils.js +2 -2
  146. package/lib/module/handlers/gestures/GestureDetector/utils.js.map +1 -1
  147. package/lib/module/handlers/handlersRegistry.js +6 -3
  148. package/lib/module/handlers/handlersRegistry.js.map +1 -1
  149. package/lib/module/index.js.map +1 -1
  150. package/lib/module/utils.js +2 -2
  151. package/lib/module/utils.js.map +1 -1
  152. package/lib/module/web/detectors/RotationGestureDetector.js +22 -22
  153. package/lib/module/web/detectors/RotationGestureDetector.js.map +1 -1
  154. package/lib/module/web/detectors/ScaleGestureDetector.js +24 -24
  155. package/lib/module/web/detectors/ScaleGestureDetector.js.map +1 -1
  156. package/lib/module/web/handlers/FlingGestureHandler.js +6 -6
  157. package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
  158. package/lib/module/web/handlers/GestureHandler.js +112 -92
  159. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  160. package/lib/module/web/handlers/HoverGestureHandler.js +2 -2
  161. package/lib/module/web/handlers/HoverGestureHandler.js.map +1 -1
  162. package/lib/module/web/handlers/LongPressGestureHandler.js +6 -6
  163. package/lib/module/web/handlers/LongPressGestureHandler.js.map +1 -1
  164. package/lib/module/web/handlers/NativeViewGestureHandler.js +13 -13
  165. package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
  166. package/lib/module/web/handlers/PanGestureHandler.js +15 -15
  167. package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
  168. package/lib/module/web/handlers/PinchGestureHandler.js +15 -15
  169. package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -1
  170. package/lib/module/web/handlers/RotationGestureHandler.js +12 -12
  171. package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -1
  172. package/lib/module/web/handlers/TapGestureHandler.js +4 -4
  173. package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
  174. package/lib/module/web/tools/CircularBuffer.js +15 -15
  175. package/lib/module/web/tools/CircularBuffer.js.map +1 -1
  176. package/lib/module/web/tools/GestureHandlerOrchestrator.js +40 -40
  177. package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  178. package/lib/module/web/tools/GestureHandlerWebDelegate.js +32 -13
  179. package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  180. package/lib/module/web/tools/InteractionManager.js +16 -16
  181. package/lib/module/web/tools/InteractionManager.js.map +1 -1
  182. package/lib/module/web/tools/NodeManager.js +2 -2
  183. package/lib/module/web/tools/NodeManager.js.map +1 -1
  184. package/lib/module/web/tools/PointerTracker.js +18 -18
  185. package/lib/module/web/tools/PointerTracker.js.map +1 -1
  186. package/lib/module/web/tools/Vector.js.map +1 -1
  187. package/lib/module/web/tools/VelocityTracker.js +1 -1
  188. package/lib/module/web/tools/VelocityTracker.js.map +1 -1
  189. package/lib/typescript/components/DrawerLayout.d.ts +27 -0
  190. package/lib/typescript/components/GestureButtonsProps.d.ts +18 -2
  191. package/lib/typescript/components/Pressable/PressableProps.d.ts +3 -10
  192. package/lib/typescript/components/Pressable/index.d.ts +1 -1
  193. package/lib/typescript/components/ReanimatedSwipeable.d.ts +6 -0
  194. package/lib/typescript/components/touchables/TouchableHighlight.d.ts +5 -0
  195. package/lib/typescript/components/touchables/TouchableNativeFeedback.android.d.ts +2 -0
  196. package/lib/typescript/components/touchables/TouchableNativeFeedback.d.ts +5 -1
  197. package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.d.ts +3 -0
  198. package/lib/typescript/components/touchables/TouchableOpacity.d.ts +5 -0
  199. package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +6 -0
  200. package/lib/typescript/handlers/FlingGestureHandler.d.ts +9 -0
  201. package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +9 -0
  202. package/lib/typescript/handlers/LongPressGestureHandler.d.ts +9 -0
  203. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +9 -0
  204. package/lib/typescript/handlers/PanGestureHandler.d.ts +9 -0
  205. package/lib/typescript/handlers/PinchGestureHandler.d.ts +9 -0
  206. package/lib/typescript/handlers/RotationGestureHandler.d.ts +9 -0
  207. package/lib/typescript/handlers/TapGestureHandler.d.ts +9 -0
  208. package/lib/typescript/handlers/handlersRegistry.d.ts +1 -0
  209. package/lib/typescript/index.d.ts +1 -1
  210. package/lib/typescript/utils.d.ts +1 -1
  211. package/lib/typescript/web/detectors/RotationGestureDetector.d.ts +7 -7
  212. package/lib/typescript/web/detectors/ScaleGestureDetector.d.ts +8 -8
  213. package/lib/typescript/web/handlers/GestureHandler.d.ts +33 -28
  214. package/lib/typescript/web/handlers/IGestureHandler.d.ts +12 -13
  215. package/lib/typescript/web/tools/CircularBuffer.d.ts +3 -3
  216. package/lib/typescript/web/tools/GestureHandlerDelegate.d.ts +1 -1
  217. package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +2 -2
  218. package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts +3 -2
  219. package/lib/typescript/web/tools/InteractionManager.d.ts +2 -2
  220. package/lib/typescript/web/tools/NodeManager.d.ts +1 -1
  221. package/lib/typescript/web/tools/PointerTracker.d.ts +4 -4
  222. package/lib/typescript/web/tools/VelocityTracker.d.ts +1 -1
  223. package/package.json +2 -2
  224. package/src/RNGestureHandlerModule.web.ts +2 -2
  225. package/src/components/DrawerLayout.tsx +29 -0
  226. package/src/components/GestureButtons.tsx +13 -2
  227. package/src/components/GestureButtonsProps.ts +31 -2
  228. package/src/components/Pressable/Pressable.tsx +22 -5
  229. package/src/components/Pressable/PressableProps.tsx +4 -11
  230. package/src/components/Pressable/index.ts +4 -1
  231. package/src/components/ReanimatedSwipeable.tsx +97 -66
  232. package/src/components/Text.tsx +13 -4
  233. package/src/components/touchables/TouchableHighlight.tsx +5 -0
  234. package/src/components/touchables/TouchableNativeFeedback.android.tsx +2 -0
  235. package/src/components/touchables/TouchableNativeFeedback.tsx +6 -1
  236. package/src/components/touchables/TouchableNativeFeedbackProps.tsx +3 -0
  237. package/src/components/touchables/TouchableOpacity.tsx +5 -0
  238. package/src/components/touchables/TouchableWithoutFeedback.tsx +6 -0
  239. package/src/findNodeHandle.web.ts +6 -0
  240. package/src/handlers/FlingGestureHandler.ts +10 -0
  241. package/src/handlers/ForceTouchGestureHandler.ts +9 -0
  242. package/src/handlers/LongPressGestureHandler.ts +10 -0
  243. package/src/handlers/NativeViewGestureHandler.ts +10 -0
  244. package/src/handlers/PanGestureHandler.ts +10 -0
  245. package/src/handlers/PinchGestureHandler.ts +10 -0
  246. package/src/handlers/RotationGestureHandler.ts +10 -0
  247. package/src/handlers/TapGestureHandler.ts +10 -0
  248. package/src/handlers/createHandler.tsx +11 -4
  249. package/src/handlers/gestures/GestureDetector/index.tsx +2 -2
  250. package/src/handlers/gestures/GestureDetector/useViewRefHandler.ts +3 -3
  251. package/src/handlers/gestures/GestureDetector/utils.ts +2 -2
  252. package/src/handlers/handlersRegistry.ts +7 -3
  253. package/src/index.ts +4 -1
  254. package/src/utils.ts +2 -2
  255. package/src/web/detectors/RotationGestureDetector.ts +22 -22
  256. package/src/web/detectors/ScaleGestureDetector.ts +24 -24
  257. package/src/web/handlers/FlingGestureHandler.ts +6 -7
  258. package/src/web/handlers/GestureHandler.ts +115 -105
  259. package/src/web/handlers/HoverGestureHandler.ts +2 -2
  260. package/src/web/handlers/IGestureHandler.ts +12 -13
  261. package/src/web/handlers/LongPressGestureHandler.ts +7 -7
  262. package/src/web/handlers/NativeViewGestureHandler.ts +14 -19
  263. package/src/web/handlers/PanGestureHandler.ts +17 -17
  264. package/src/web/handlers/PinchGestureHandler.ts +17 -21
  265. package/src/web/handlers/RotationGestureHandler.ts +12 -12
  266. package/src/web/handlers/TapGestureHandler.ts +4 -6
  267. package/src/web/tools/CircularBuffer.ts +15 -15
  268. package/src/web/tools/GestureHandlerDelegate.ts +1 -1
  269. package/src/web/tools/GestureHandlerOrchestrator.ts +42 -42
  270. package/src/web/tools/GestureHandlerWebDelegate.ts +32 -13
  271. package/src/web/tools/InteractionManager.ts +16 -16
  272. package/src/web/tools/NodeManager.ts +2 -2
  273. package/src/web/tools/PointerTracker.ts +20 -20
  274. package/src/web/tools/Vector.ts +1 -1
  275. package/src/web/tools/VelocityTracker.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["useViewRefHandler.ts"],"names":["isFabric","tagMessage","getShadowNodeFromRef","useCallback","findNodeHandle","useViewRefHandler","state","updateAttachedGestures","refHandler","ref","viewRef","previousViewTag","firstRender","__DEV__","global","isFormsStackingContext","node","console","error"],"mappings":"AAAA,SAASA,QAAT,EAAmBC,UAAnB,QAAqC,gBAArC;AACA,SAASC,oBAAT,QAAqC,+BAArC;AAGA,SAAgBC,WAAhB,QAAmC,OAAnC;AACA,OAAOC,cAAP,MAA2B,yBAA3B;AAMA;AACA;AACA;AACA,OAAO,SAASC,iBAAT,CACLC,KADK,EAELC,sBAFK,EAGL;AACA,QAAMC,UAAU,GAAGL,WAAW,CAC3BM,GAAD,IAAiC;AAC/B,QAAIA,GAAG,KAAK,IAAZ,EAAkB;AAChB;AACD;;AAEDH,IAAAA,KAAK,CAACI,OAAN,GAAgBD,GAAhB,CAL+B,CAO/B;;AACA,QAAIH,KAAK,CAACK,eAAN,KAA0B,CAAC,CAA/B,EAAkC;AAChCL,MAAAA,KAAK,CAACK,eAAN,GAAwBP,cAAc,CAACE,KAAK,CAACI,OAAP,CAAtC;AACD,KAV8B,CAY/B;AACA;;;AACA,QAAI,CAACJ,KAAK,CAACM,WAAX,EAAwB;AACtBL,MAAAA,sBAAsB,CAAC,IAAD,CAAtB;AACD;;AAED,QAAIM,OAAO,IAAIb,QAAQ,EAAnB,IAAyBc,MAAM,CAACC,sBAApC,EAA4D;AAC1D,YAAMC,IAAI,GAAGd,oBAAoB,CAACO,GAAD,CAAjC;;AACA,UAAIK,MAAM,CAACC,sBAAP,CAA8BC,IAA9B,MAAwC,KAA5C,EAAmD;AACjDC,QAAAA,OAAO,CAACC,KAAR,CACEjB,UAAU,CACR,uEACE,kGAFM,CADZ;AAMD;AACF;AACF,GA9B2B,EA+B5B,CAACK,KAAD,EAAQC,sBAAR,CA/B4B,CAA9B;AAkCA,SAAOC,UAAP;AACD","sourcesContent":["import { isFabric, tagMessage } from '../../../utils';\nimport { getShadowNodeFromRef } from '../../../getShadowNodeFromRef';\n\nimport { GestureDetectorState } from './types';\nimport React, { useCallback } from 'react';\nimport findNodeHandle from '../../../findNodeHandle';\n\ndeclare const global: {\n isFormsStackingContext: (node: unknown) => boolean | null; // JSI function\n};\n\n// Ref handler for the Wrap component attached under the GestureDetector.\n// It's responsible for setting the viewRef on the state and triggering the reattaching of handlers\n// if the view has changed.\nexport function useViewRefHandler(\n state: GestureDetectorState,\n updateAttachedGestures: (skipConfigUpdate?: boolean) => void\n) {\n const refHandler = useCallback(\n (ref: React.Component | null) => {\n if (ref === null) {\n return;\n }\n\n state.viewRef = ref;\n\n // if it's the first render, also set the previousViewTag to prevent reattaching gestures when not needed\n if (state.previousViewTag === -1) {\n state.previousViewTag = findNodeHandle(state.viewRef) as number;\n }\n\n // Pass true as `skipConfigUpdate`. Here we only want to trigger the eventual reattaching of handlers\n // in case the view has changed. If the view doesn't change, the update will be handled by detector.\n if (!state.firstRender) {\n updateAttachedGestures(true);\n }\n\n if (__DEV__ && isFabric() && global.isFormsStackingContext) {\n const node = getShadowNodeFromRef(ref);\n if (global.isFormsStackingContext(node) === false) {\n console.error(\n tagMessage(\n 'GestureDetector has received a child that may get view-flattened. ' +\n '\\nTo prevent it from misbehaving you need to wrap the child with a `<View collapsable={false}>`.'\n )\n );\n }\n }\n },\n [state, updateAttachedGestures]\n );\n\n return refHandler;\n}\n"]}
1
+ {"version":3,"sources":["useViewRefHandler.ts"],"names":["isFabric","tagMessage","getShadowNodeFromRef","useCallback","findNodeHandle","useViewRefHandler","state","updateAttachedGestures","refHandler","ref","viewRef","previousViewTag","firstRender","__DEV__","global","isViewFlatteningDisabled","node","console","error"],"mappings":"AAAA,SAASA,QAAT,EAAmBC,UAAnB,QAAqC,gBAArC;AACA,SAASC,oBAAT,QAAqC,+BAArC;AAGA,SAAgBC,WAAhB,QAAmC,OAAnC;AACA,OAAOC,cAAP,MAA2B,yBAA3B;AAMA;AACA;AACA;AACA,OAAO,SAASC,iBAAT,CACLC,KADK,EAELC,sBAFK,EAGL;AACA,QAAMC,UAAU,GAAGL,WAAW,CAC3BM,GAAD,IAAiC;AAC/B,QAAIA,GAAG,KAAK,IAAZ,EAAkB;AAChB;AACD;;AAEDH,IAAAA,KAAK,CAACI,OAAN,GAAgBD,GAAhB,CAL+B,CAO/B;;AACA,QAAIH,KAAK,CAACK,eAAN,KAA0B,CAAC,CAA/B,EAAkC;AAChCL,MAAAA,KAAK,CAACK,eAAN,GAAwBP,cAAc,CAACE,KAAK,CAACI,OAAP,CAAtC;AACD,KAV8B,CAY/B;AACA;;;AACA,QAAI,CAACJ,KAAK,CAACM,WAAX,EAAwB;AACtBL,MAAAA,sBAAsB,CAAC,IAAD,CAAtB;AACD;;AAED,QAAIM,OAAO,IAAIb,QAAQ,EAAnB,IAAyBc,MAAM,CAACC,wBAApC,EAA8D;AAC5D,YAAMC,IAAI,GAAGd,oBAAoB,CAACO,GAAD,CAAjC;;AACA,UAAIK,MAAM,CAACC,wBAAP,CAAgCC,IAAhC,MAA0C,KAA9C,EAAqD;AACnDC,QAAAA,OAAO,CAACC,KAAR,CACEjB,UAAU,CACR,uEACE,kGAFM,CADZ;AAMD;AACF;AACF,GA9B2B,EA+B5B,CAACK,KAAD,EAAQC,sBAAR,CA/B4B,CAA9B;AAkCA,SAAOC,UAAP;AACD","sourcesContent":["import { isFabric, tagMessage } from '../../../utils';\nimport { getShadowNodeFromRef } from '../../../getShadowNodeFromRef';\n\nimport { GestureDetectorState } from './types';\nimport React, { useCallback } from 'react';\nimport findNodeHandle from '../../../findNodeHandle';\n\ndeclare const global: {\n isViewFlatteningDisabled: (node: unknown) => boolean | null; // JSI function\n};\n\n// Ref handler for the Wrap component attached under the GestureDetector.\n// It's responsible for setting the viewRef on the state and triggering the reattaching of handlers\n// if the view has changed.\nexport function useViewRefHandler(\n state: GestureDetectorState,\n updateAttachedGestures: (skipConfigUpdate?: boolean) => void\n) {\n const refHandler = useCallback(\n (ref: React.Component | null) => {\n if (ref === null) {\n return;\n }\n\n state.viewRef = ref;\n\n // if it's the first render, also set the previousViewTag to prevent reattaching gestures when not needed\n if (state.previousViewTag === -1) {\n state.previousViewTag = findNodeHandle(state.viewRef) as number;\n }\n\n // Pass true as `skipConfigUpdate`. Here we only want to trigger the eventual reattaching of handlers\n // in case the view has changed. If the view doesn't change, the update will be handled by detector.\n if (!state.firstRender) {\n updateAttachedGestures(true);\n }\n\n if (__DEV__ && isFabric() && global.isViewFlatteningDisabled) {\n const node = getShadowNodeFromRef(ref);\n if (global.isViewFlatteningDisabled(node) === false) {\n console.error(\n tagMessage(\n 'GestureDetector has received a child that may get view-flattened. ' +\n '\\nTo prevent it from misbehaving you need to wrap the child with a `<View collapsable={false}>`.'\n )\n );\n }\n }\n },\n [state, updateAttachedGestures]\n );\n\n return refHandler;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { Platform } from 'react-native';
2
- import { isJestEnv, tagMessage } from '../../../utils';
2
+ import { isTestEnv, tagMessage } from '../../../utils';
3
3
  import { BaseGesture } from '../gesture';
4
4
  import { flingGestureHandlerProps } from '../../FlingGestureHandler';
5
5
  import { forceTouchGestureHandlerProps } from '../../ForceTouchGestureHandler';
@@ -74,7 +74,7 @@ export function checkGestureCallbacksForWorklets(gesture) {
74
74
  const areAllNotWorklets = !areSomeWorklets && areSomeNotWorklets; // If none of the callbacks are worklets and the gesture is not explicitly marked with
75
75
  // `.runOnJS(true)` show a warning
76
76
 
77
- if (areAllNotWorklets && !isJestEnv()) {
77
+ if (areAllNotWorklets && !isTestEnv()) {
78
78
  console.warn(tagMessage(`None of the callbacks in the gesture are worklets. If you wish to run them on the JS thread use '.runOnJS(true)' modifier on the gesture to make this explicit. Otherwise, mark the callbacks as 'worklet' to run them on the UI thread.`));
79
79
  }
80
80
  } // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1 +1 @@
1
- {"version":3,"sources":["utils.ts"],"names":["Platform","isJestEnv","tagMessage","BaseGesture","flingGestureHandlerProps","forceTouchGestureHandlerProps","longPressGestureHandlerProps","panGestureHandlerProps","panGestureHandlerCustomNativeProps","tapGestureHandlerProps","hoverGestureHandlerProps","nativeViewGestureHandlerProps","baseGestureHandlerWithDetectorProps","isNewWebImplementationEnabled","getReactNativeVersion","RNRenderer","useCallback","useRef","useState","Reanimated","onGestureHandlerEvent","ALLOWED_PROPS","convertToHandlerTag","ref","handlerTag","current","extractValidHandlerTags","interactionGroup","map","filter","tag","extractGestureRelations","gesture","requireToFail","config","simultaneousWith","blocksHandlers","waitFor","simultaneousHandlers","checkGestureCallbacksForWorklets","__DEV__","runOnJS","areSomeNotWorklets","handlers","isWorklet","includes","areSomeWorklets","console","error","undefined","areAllNotWorklets","warn","validateDetectorChildren","OS","REACT_NATIVE_VERSION","wrapType","minor","major","_reactInternals","elementType","_reactInternalFiber","instance","findHostInstance_DEPRECATED","_internalFiberInstanceHandleDEV","sibling","Error","return","useForceRender","renderState","setRenderState","forceRender","useWebEventHandlers","e","nativeEvent","onGestureHandlerStateChange"],"mappings":"AAAA,SAASA,QAAT,QAAyB,cAAzB;AAEA,SAASC,SAAT,EAAoBC,UAApB,QAAsC,gBAAtC;AACA,SAAqBC,WAArB,QAAqD,YAArD;AAEA,SAASC,wBAAT,QAAyC,2BAAzC;AACA,SAASC,6BAAT,QAA8C,gCAA9C;AACA,SAASC,4BAAT,QAA6C,+BAA7C;AACA,SACEC,sBADF,EAEEC,kCAFF,QAGO,yBAHP;AAIA,SAASC,sBAAT,QAAuC,yBAAvC;AACA,SAASC,wBAAT,QAAyC,iBAAzC;AACA,SAASC,6BAAT,QAA8C,gCAA9C;AACA,SAEEC,mCAFF,QAGO,4BAHP;AAIA,SAASC,6BAAT,QAA8C,qCAA9C;AACA,SAASC,qBAAT,QAAsC,gCAAtC;AACA,SAASC,UAAT,QAA2B,qBAA3B;AACA,SAASC,WAAT,EAAsBC,MAAtB,EAA8BC,QAA9B,QAA8C,OAA9C;AACA,SAASC,UAAT,QAA2B,sBAA3B;AACA,SAASC,qBAAT,QAAsC,kBAA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AwBD,WAL9B,CAHoC,CASpC;;AACA,QAAIE,QAAQ,GACV9C,UAAU,CAAC+C,2BAAX,CACEvC,GADF,EAEEwC,+BAHJ,CAVoC,CAepC;;;AACA,WAAOF,QAAQ,IAAIA,QAAQ,CAACF,WAAT,KAAyBJ,QAA5C,EAAsD;AACpD;AACA,UAAIM,QAAQ,CAACG,OAAb,EAAsB;AACpB,cAAM,IAAIC,KAAJ,CACJ,mPADI,CAAN;AAGD,OANmD,CAQpD;;;AACAJ,MAAAA,QAAQ,GAAGA,QAAQ,CAACK,MAApB;AACD;AACF;AACF;AAED,OAAO,SAASC,cAAT,GAA0B;AAC/B,QAAM,CAACC,WAAD,EAAcC,cAAd,IAAgCnD,QAAQ,CAAC,KAAD,CAA9C;AACA,QAAMoD,WAAW,GAAGtD,WAAW,CAAC,MAAM;AACpCqD,IAAAA,cAAc,CAAC,CAACD,WAAF,CAAd;AACD,GAF8B,EAE5B,CAACA,WAAD,EAAcC,cAAd,CAF4B,CAA/B;AAIA,SAAOC,WAAP;AACD;AAED,OAAO,SAASC,mBAAT,GAA+B;AACpC,SAAOtD,MAAM,CAAkB;AAC7BG,IAAAA,qBAAqB,EAAGoD,CAAD,IAAyC;AAC9DpD,MAAAA,qBAAqB,CAACoD,CAAC,CAACC,WAAH,CAArB;AACD,KAH4B;AAI7BC,IAAAA,2BAA2B,EAAE7D,6BAA6B,KACrD2D,CAAD,IAAyC;AACvCpD,MAAAA,qBAAqB,CAACoD,CAAC,CAACC,WAAH,CAArB;AACD,KAHqD,GAItDxB;AARyB,GAAlB,CAAb;AAUD","sourcesContent":["import { Platform } from 'react-native';\n\nimport { isJestEnv, tagMessage } from '../../../utils';\nimport { GestureRef, BaseGesture, GestureType } from '../gesture';\n\nimport { flingGestureHandlerProps } from '../../FlingGestureHandler';\nimport { forceTouchGestureHandlerProps } from '../../ForceTouchGestureHandler';\nimport { longPressGestureHandlerProps } from '../../LongPressGestureHandler';\nimport {\n panGestureHandlerProps,\n panGestureHandlerCustomNativeProps,\n} from '../../PanGestureHandler';\nimport { tapGestureHandlerProps } from '../../TapGestureHandler';\nimport { hoverGestureHandlerProps } from '../hoverGesture';\nimport { nativeViewGestureHandlerProps } from '../../NativeViewGestureHandler';\nimport {\n HandlerStateChangeEvent,\n baseGestureHandlerWithDetectorProps,\n} from '../../gestureHandlerCommon';\nimport { isNewWebImplementationEnabled } from '../../../EnableNewWebImplementation';\nimport { getReactNativeVersion } from '../../../getReactNativeVersion';\nimport { RNRenderer } from '../../../RNRenderer';\nimport { useCallback, useRef, useState } from 'react';\nimport { Reanimated } from '../reanimatedWrapper';\nimport { onGestureHandlerEvent } from '../eventReceiver';\nimport { WebEventHandler } from './types';\n\nexport const ALLOWED_PROPS = [\n ...baseGestureHandlerWithDetectorProps,\n ...tapGestureHandlerProps,\n ...panGestureHandlerProps,\n ...panGestureHandlerCustomNativeProps,\n ...longPressGestureHandlerProps,\n ...forceTouchGestureHandlerProps,\n ...flingGestureHandlerProps,\n ...hoverGestureHandlerProps,\n ...nativeViewGestureHandlerProps,\n];\n\nfunction convertToHandlerTag(ref: GestureRef): number {\n if (typeof ref === 'number') {\n return ref;\n } else if (ref instanceof BaseGesture) {\n return ref.handlerTag;\n } else {\n // @ts-ignore in this case it should be a ref either to gesture object or\n // a gesture handler component, in both cases handlerTag property exists\n return ref.current?.handlerTag ?? -1;\n }\n}\n\nfunction extractValidHandlerTags(interactionGroup: GestureRef[] | undefined) {\n return (\n interactionGroup?.map(convertToHandlerTag)?.filter((tag) => tag > 0) ?? []\n );\n}\n\nexport function extractGestureRelations(gesture: GestureType) {\n const requireToFail = extractValidHandlerTags(gesture.config.requireToFail);\n const simultaneousWith = extractValidHandlerTags(\n gesture.config.simultaneousWith\n );\n const blocksHandlers = extractValidHandlerTags(gesture.config.blocksHandlers);\n\n return {\n waitFor: requireToFail,\n simultaneousHandlers: simultaneousWith,\n blocksHandlers: blocksHandlers,\n };\n}\n\nexport function checkGestureCallbacksForWorklets(gesture: GestureType) {\n if (!__DEV__) {\n return;\n }\n // If a gesture is explicitly marked to run on the JS thread there is no need to check\n // if callbacks are worklets as the user is aware they will be ran on the JS thread\n if (gesture.config.runOnJS) {\n return;\n }\n\n const areSomeNotWorklets = gesture.handlers.isWorklet.includes(false);\n const areSomeWorklets = gesture.handlers.isWorklet.includes(true);\n\n // If some of the callbacks are worklets and some are not, and the gesture is not\n // explicitly marked with `.runOnJS(true)` show an error\n if (areSomeNotWorklets && areSomeWorklets) {\n console.error(\n tagMessage(\n `Some of the callbacks in the gesture are worklets and some are not. Either make sure that all calbacks are marked as 'worklet' if you wish to run them on the UI thread or use '.runOnJS(true)' modifier on the gesture explicitly to run all callbacks on the JS thread.`\n )\n );\n }\n\n if (Reanimated === undefined) {\n // If Reanimated is not available, we can't run worklets, so we shouldn't show the warning\n return;\n }\n\n const areAllNotWorklets = !areSomeWorklets && areSomeNotWorklets;\n // If none of the callbacks are worklets and the gesture is not explicitly marked with\n // `.runOnJS(true)` show a warning\n if (areAllNotWorklets && !isJestEnv()) {\n console.warn(\n tagMessage(\n `None of the callbacks in the gesture are worklets. If you wish to run them on the JS thread use '.runOnJS(true)' modifier on the gesture to make this explicit. Otherwise, mark the callbacks as 'worklet' to run them on the UI thread.`\n )\n );\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function validateDetectorChildren(ref: any) {\n // Finds the first native view under the Wrap component and traverses the fiber tree upwards\n // to check whether there is more than one native view as a pseudo-direct child of GestureDetector\n // i.e. this is not ok:\n // Wrap\n // |\n // / \\\n // / \\\n // / \\\n // / \\\n // NativeView NativeView\n //\n // but this is fine:\n // Wrap\n // |\n // NativeView\n // |\n // / \\\n // / \\\n // / \\\n // / \\\n // NativeView NativeView\n if (__DEV__ && Platform.OS !== 'web') {\n const REACT_NATIVE_VERSION = getReactNativeVersion();\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const wrapType =\n REACT_NATIVE_VERSION.minor > 63 || REACT_NATIVE_VERSION.major > 0\n ? // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ref._reactInternals.elementType\n : // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ref._reactInternalFiber.elementType;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n let instance =\n RNRenderer.findHostInstance_DEPRECATED(\n ref\n )._internalFiberInstanceHandleDEV;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n while (instance && instance.elementType !== wrapType) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (instance.sibling) {\n throw new Error(\n 'GestureDetector has more than one native view as its children. This can happen if you are using a custom component that renders multiple views, like React.Fragment. You should wrap content of GestureDetector with a <View> or <Animated.View>.'\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n instance = instance.return;\n }\n }\n}\n\nexport function useForceRender() {\n const [renderState, setRenderState] = useState(false);\n const forceRender = useCallback(() => {\n setRenderState(!renderState);\n }, [renderState, setRenderState]);\n\n return forceRender;\n}\n\nexport function useWebEventHandlers() {\n return useRef<WebEventHandler>({\n onGestureHandlerEvent: (e: HandlerStateChangeEvent<unknown>) => {\n onGestureHandlerEvent(e.nativeEvent);\n },\n onGestureHandlerStateChange: isNewWebImplementationEnabled()\n ? (e: HandlerStateChangeEvent<unknown>) => {\n onGestureHandlerEvent(e.nativeEvent);\n }\n : undefined,\n });\n}\n"]}
1
+ {"version":3,"sources":["utils.ts"],"names":["Platform","isTestEnv","tagMessage","BaseGesture","flingGestureHandlerProps","forceTouchGestureHandlerProps","longPressGestureHandlerProps","panGestureHandlerProps","panGestureHandlerCustomNativeProps","tapGestureHandlerProps","hoverGestureHandlerProps","nativeViewGestureHandlerProps","baseGestureHandlerWithDetectorProps","isNewWebImplementationEnabled","getReactNativeVersion","RNRenderer","useCallback","useRef","useState","Reanimated","onGestureHandlerEvent","ALLOWED_PROPS","convertToHandlerTag","ref","handlerTag","current","extractValidHandlerTags","interactionGroup","map","filter","tag","extractGestureRelations","gesture","requireToFail","config","simultaneousWith","blocksHandlers","waitFor","simultaneousHandlers","checkGestureCallbacksForWorklets","__DEV__","runOnJS","areSomeNotWorklets","handlers","isWorklet","includes","areSomeWorklets","console","error","undefined","areAllNotWorklets","warn","validateDetectorChildren","OS","REACT_NATIVE_VERSION","wrapType","minor","major","_reactInternals","elementType","_reactInternalFiber","instance","findHostInstance_DEPRECATED","_internalFiberInstanceHandleDEV","sibling","Error","return","useForceRender","renderState","setRenderState","forceRender","useWebEventHandlers","e","nativeEvent","onGestureHandlerStateChange"],"mappings":"AAAA,SAASA,QAAT,QAAyB,cAAzB;AAEA,SAASC,SAAT,EAAoBC,UAApB,QAAsC,gBAAtC;AACA,SAAqBC,WAArB,QAAqD,YAArD;AAEA,SAASC,wBAAT,QAAyC,2BAAzC;AACA,SAASC,6BAAT,QAA8C,gCAA9C;AACA,SAASC,4BAAT,QAA6C,+BAA7C;AACA,SACEC,sBADF,EAEEC,kCAFF,QAGO,yBAHP;AAIA,SAASC,sBAAT,QAAuC,yBAAvC;AACA,SAASC,wBAAT,QAAyC,iBAAzC;AACA,SAASC,6BAAT,QAA8C,gCAA9C;AACA,SAEEC,mCAFF,QAGO,4BAHP;AAIA,SAASC,6BAAT,QAA8C,qCAA9C;AACA,SAASC,qBAAT,QAAsC,gCAAtC;AACA,SAASC,UAAT,QAA2B,qBAA3B;AACA,SAASC,WAAT,EAAsBC,MAAtB,EAA8BC,QAA9B,QAA8C,OAA9C;AACA,SAASC,UAAT,QAA2B,sBAA3B;AACA,SAASC,qBAAT,QAAsC,kBAAtC;AAGA,OAAO,MAAMC,aAAa,GAAG,CAC3B,GAAGT,mCADwB,EAE3B,GAAGH,sBAFwB,EAG3B,GAAGF,sBAHwB,EAI3B,GAAGC,kCAJwB,EAK3B,GAAGF,4BALwB,EAM3B,GAAGD,6BANwB,EAO3B,GAAGD,wBAPwB,EAQ3B,GAAGM,wBARwB,EAS3B,GAAGC,6BATwB,CAAtB;;A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,IAAIC,KAAJ,CACJ,mPADI,CAAN;AAGD,OANmD,CAQpD;;;AACAJ,MAAAA,QAAQ,GAAGA,QAAQ,CAACK,MAApB;AACD;AACF;AACF;AAED,OAAO,SAASC,cAAT,GAA0B;AAC/B,QAAM,CAACC,WAAD,EAAcC,cAAd,IAAgCnD,QAAQ,CAAC,KAAD,CAA9C;AACA,QAAMoD,WAAW,GAAGtD,WAAW,CAAC,MAAM;AACpCqD,IAAAA,cAAc,CAAC,CAACD,WAAF,CAAd;AACD,GAF8B,EAE5B,CAACA,WAAD,EAAcC,cAAd,CAF4B,CAA/B;AAIA,SAAOC,WAAP;AACD;AAED,OAAO,SAASC,mBAAT,GAA+B;AACpC,SAAOtD,MAAM,CAAkB;AAC7BG,IAAAA,qBAAqB,EAAGoD,CAAD,IAAyC;AAC9DpD,MAAAA,qBAAqB,CAACoD,CAAC,CAACC,WAAH,CAArB;AACD,KAH4B;AAI7BC,IAAAA,2BAA2B,EAAE7D,6BAA6B,KACrD2D,CAAD,IAAyC;AACvCpD,MAAAA,qBAAqB,CAACoD,CAAC,CAACC,WAAH,CAArB;AACD,KAHqD,GAItDxB;AARyB,GAAlB,CAAb;AAUD","sourcesContent":["import { Platform } from 'react-native';\n\nimport { isTestEnv, tagMessage } from '../../../utils';\nimport { GestureRef, BaseGesture, GestureType } from '../gesture';\n\nimport { flingGestureHandlerProps } from '../../FlingGestureHandler';\nimport { forceTouchGestureHandlerProps } from '../../ForceTouchGestureHandler';\nimport { longPressGestureHandlerProps } from '../../LongPressGestureHandler';\nimport {\n panGestureHandlerProps,\n panGestureHandlerCustomNativeProps,\n} from '../../PanGestureHandler';\nimport { tapGestureHandlerProps } from '../../TapGestureHandler';\nimport { hoverGestureHandlerProps } from '../hoverGesture';\nimport { nativeViewGestureHandlerProps } from '../../NativeViewGestureHandler';\nimport {\n HandlerStateChangeEvent,\n baseGestureHandlerWithDetectorProps,\n} from '../../gestureHandlerCommon';\nimport { isNewWebImplementationEnabled } from '../../../EnableNewWebImplementation';\nimport { getReactNativeVersion } from '../../../getReactNativeVersion';\nimport { RNRenderer } from '../../../RNRenderer';\nimport { useCallback, useRef, useState } from 'react';\nimport { Reanimated } from '../reanimatedWrapper';\nimport { onGestureHandlerEvent } from '../eventReceiver';\nimport { WebEventHandler } from './types';\n\nexport const ALLOWED_PROPS = [\n ...baseGestureHandlerWithDetectorProps,\n ...tapGestureHandlerProps,\n ...panGestureHandlerProps,\n ...panGestureHandlerCustomNativeProps,\n ...longPressGestureHandlerProps,\n ...forceTouchGestureHandlerProps,\n ...flingGestureHandlerProps,\n ...hoverGestureHandlerProps,\n ...nativeViewGestureHandlerProps,\n];\n\nfunction convertToHandlerTag(ref: GestureRef): number {\n if (typeof ref === 'number') {\n return ref;\n } else if (ref instanceof BaseGesture) {\n return ref.handlerTag;\n } else {\n // @ts-ignore in this case it should be a ref either to gesture object or\n // a gesture handler component, in both cases handlerTag property exists\n return ref.current?.handlerTag ?? -1;\n }\n}\n\nfunction extractValidHandlerTags(interactionGroup: GestureRef[] | undefined) {\n return (\n interactionGroup?.map(convertToHandlerTag)?.filter((tag) => tag > 0) ?? []\n );\n}\n\nexport function extractGestureRelations(gesture: GestureType) {\n const requireToFail = extractValidHandlerTags(gesture.config.requireToFail);\n const simultaneousWith = extractValidHandlerTags(\n gesture.config.simultaneousWith\n );\n const blocksHandlers = extractValidHandlerTags(gesture.config.blocksHandlers);\n\n return {\n waitFor: requireToFail,\n simultaneousHandlers: simultaneousWith,\n blocksHandlers: blocksHandlers,\n };\n}\n\nexport function checkGestureCallbacksForWorklets(gesture: GestureType) {\n if (!__DEV__) {\n return;\n }\n // If a gesture is explicitly marked to run on the JS thread there is no need to check\n // if callbacks are worklets as the user is aware they will be ran on the JS thread\n if (gesture.config.runOnJS) {\n return;\n }\n\n const areSomeNotWorklets = gesture.handlers.isWorklet.includes(false);\n const areSomeWorklets = gesture.handlers.isWorklet.includes(true);\n\n // If some of the callbacks are worklets and some are not, and the gesture is not\n // explicitly marked with `.runOnJS(true)` show an error\n if (areSomeNotWorklets && areSomeWorklets) {\n console.error(\n tagMessage(\n `Some of the callbacks in the gesture are worklets and some are not. Either make sure that all calbacks are marked as 'worklet' if you wish to run them on the UI thread or use '.runOnJS(true)' modifier on the gesture explicitly to run all callbacks on the JS thread.`\n )\n );\n }\n\n if (Reanimated === undefined) {\n // If Reanimated is not available, we can't run worklets, so we shouldn't show the warning\n return;\n }\n\n const areAllNotWorklets = !areSomeWorklets && areSomeNotWorklets;\n // If none of the callbacks are worklets and the gesture is not explicitly marked with\n // `.runOnJS(true)` show a warning\n if (areAllNotWorklets && !isTestEnv()) {\n console.warn(\n tagMessage(\n `None of the callbacks in the gesture are worklets. If you wish to run them on the JS thread use '.runOnJS(true)' modifier on the gesture to make this explicit. Otherwise, mark the callbacks as 'worklet' to run them on the UI thread.`\n )\n );\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function validateDetectorChildren(ref: any) {\n // Finds the first native view under the Wrap component and traverses the fiber tree upwards\n // to check whether there is more than one native view as a pseudo-direct child of GestureDetector\n // i.e. this is not ok:\n // Wrap\n // |\n // / \\\n // / \\\n // / \\\n // / \\\n // NativeView NativeView\n //\n // but this is fine:\n // Wrap\n // |\n // NativeView\n // |\n // / \\\n // / \\\n // / \\\n // / \\\n // NativeView NativeView\n if (__DEV__ && Platform.OS !== 'web') {\n const REACT_NATIVE_VERSION = getReactNativeVersion();\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const wrapType =\n REACT_NATIVE_VERSION.minor > 63 || REACT_NATIVE_VERSION.major > 0\n ? // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ref._reactInternals.elementType\n : // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ref._reactInternalFiber.elementType;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n let instance =\n RNRenderer.findHostInstance_DEPRECATED(\n ref\n )._internalFiberInstanceHandleDEV;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n while (instance && instance.elementType !== wrapType) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (instance.sibling) {\n throw new Error(\n 'GestureDetector has more than one native view as its children. This can happen if you are using a custom component that renders multiple views, like React.Fragment. You should wrap content of GestureDetector with a <View> or <Animated.View>.'\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n instance = instance.return;\n }\n }\n}\n\nexport function useForceRender() {\n const [renderState, setRenderState] = useState(false);\n const forceRender = useCallback(() => {\n setRenderState(!renderState);\n }, [renderState, setRenderState]);\n\n return forceRender;\n}\n\nexport function useWebEventHandlers() {\n return useRef<WebEventHandler>({\n onGestureHandlerEvent: (e: HandlerStateChangeEvent<unknown>) => {\n onGestureHandlerEvent(e.nativeEvent);\n },\n onGestureHandlerStateChange: isNewWebImplementationEnabled()\n ? (e: HandlerStateChangeEvent<unknown>) => {\n onGestureHandlerEvent(e.nativeEvent);\n }\n : undefined,\n });\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { isJestEnv } from '../utils';
1
+ import { isTestEnv } from '../utils';
2
2
  export const handlerIDToTag = {};
3
3
  const gestures = new Map();
4
4
  const oldHandlers = new Map();
@@ -6,17 +6,20 @@ const testIDs = new Map();
6
6
  export function registerHandler(handlerTag, handler, testID) {
7
7
  gestures.set(handlerTag, handler);
8
8
 
9
- if (isJestEnv() && testID) {
9
+ if (isTestEnv() && testID) {
10
10
  testIDs.set(testID, handlerTag);
11
11
  }
12
12
  }
13
13
  export function registerOldGestureHandler(handlerTag, handler) {
14
14
  oldHandlers.set(handlerTag, handler);
15
15
  }
16
+ export function unregisterOldGestureHandler(handlerTag) {
17
+ oldHandlers.delete(handlerTag);
18
+ }
16
19
  export function unregisterHandler(handlerTag, testID) {
17
20
  gestures.delete(handlerTag);
18
21
 
19
- if (isJestEnv() && testID) {
22
+ if (isTestEnv() && testID) {
20
23
  testIDs.delete(testID);
21
24
  }
22
25
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["handlersRegistry.ts"],"names":["isJestEnv","handlerIDToTag","gestures","Map","oldHandlers","testIDs","registerHandler","handlerTag","handler","testID","set","registerOldGestureHandler","unregisterHandler","delete","findHandler","get","findOldGestureHandler","findHandlerByTestID","undefined"],"mappings":"AAAA,SAASA,SAAT,QAA0B,UAA1B;AAIA,OAAO,MAAMC,cAAsC,GAAG,EAA/C;AACP,MAAMC,QAAQ,GAAG,IAAIC,GAAJ,EAAjB;AACA,MAAMC,WAAW,GAAG,IAAID,GAAJ,EAApB;AACA,MAAME,OAAO,GAAG,IAAIF,GAAJ,EAAhB;AAEA,OAAO,SAASG,eAAT,CACLC,UADK,EAELC,OAFK,EAGLC,MAHK,EAIL;AACAP,EAAAA,QAAQ,CAACQ,GAAT,CAAaH,UAAb,EAAyBC,OAAzB;;AACA,MAAIR,SAAS,MAAMS,MAAnB,EAA2B;AACzBJ,IAAAA,OAAO,CAACK,GAAR,CAAYD,MAAZ,EAAoBF,UAApB;AACD;AACF;AAED,OAAO,SAASI,yBAAT,CACLJ,UADK,EAELC,OAFK,EAGL;AACAJ,EAAAA,WAAW,CAACM,GAAZ,CAAgBH,UAAhB,EAA4BC,OAA5B;AACD;AAED,OAAO,SAASI,iBAAT,CAA2BL,UAA3B,EAA+CE,MAA/C,EAAgE;AACrEP,EAAAA,QAAQ,CAACW,MAAT,CAAgBN,UAAhB;;AACA,MAAIP,SAAS,MAAMS,MAAnB,EAA2B;AACzBJ,IAAAA,OAAO,CAACQ,MAAR,CAAeJ,MAAf;AACD;AACF;AAED,OAAO,SAASK,WAAT,CAAqBP,UAArB,EAAyC;AAC9C,SAAOL,QAAQ,CAACa,GAAT,CAAaR,UAAb,CAAP;AACD;AAED,OAAO,SAASS,qBAAT,CAA+BT,UAA/B,EAAmD;AACxD,SAAOH,WAAW,CAACW,GAAZ,CAAgBR,UAAhB,CAAP;AACD;AAED,OAAO,SAASU,mBAAT,CAA6BR,MAA7B,EAA6C;AAClD,QAAMF,UAAU,GAAGF,OAAO,CAACU,GAAR,CAAYN,MAAZ,CAAnB;;AACA,MAAIF,UAAU,KAAKW,SAAnB,EAA8B;AAAA;;AAC5B,2BAAOJ,WAAW,CAACP,UAAD,CAAlB,uDAAkC,IAAlC;AACD;;AACD,SAAO,IAAP;AACD","sourcesContent":["import { isJestEnv } from '../utils';\nimport { GestureType } from './gestures/gesture';\nimport { GestureEvent, HandlerStateChangeEvent } from './gestureHandlerCommon';\n\nexport const handlerIDToTag: Record<string, number> = {};\nconst gestures = new Map<number, GestureType>();\nconst oldHandlers = new Map<number, GestureHandlerCallbacks>();\nconst testIDs = new Map<string, number>();\n\nexport function registerHandler(\n handlerTag: number,\n handler: GestureType,\n testID?: string\n) {\n gestures.set(handlerTag, handler);\n if (isJestEnv() && testID) {\n testIDs.set(testID, handlerTag);\n }\n}\n\nexport function registerOldGestureHandler(\n handlerTag: number,\n handler: GestureHandlerCallbacks\n) {\n oldHandlers.set(handlerTag, handler);\n}\n\nexport function unregisterHandler(handlerTag: number, testID?: string) {\n gestures.delete(handlerTag);\n if (isJestEnv() && testID) {\n testIDs.delete(testID);\n }\n}\n\nexport function findHandler(handlerTag: number) {\n return gestures.get(handlerTag);\n}\n\nexport function findOldGestureHandler(handlerTag: number) {\n return oldHandlers.get(handlerTag);\n}\n\nexport function findHandlerByTestID(testID: string) {\n const handlerTag = testIDs.get(testID);\n if (handlerTag !== undefined) {\n return findHandler(handlerTag) ?? null;\n }\n return null;\n}\n\nexport interface GestureHandlerCallbacks {\n onGestureEvent: (event: GestureEvent<any>) => void;\n onGestureStateChange: (event: HandlerStateChangeEvent<any>) => void;\n}\n"]}
1
+ {"version":3,"sources":["handlersRegistry.ts"],"names":["isTestEnv","handlerIDToTag","gestures","Map","oldHandlers","testIDs","registerHandler","handlerTag","handler","testID","set","registerOldGestureHandler","unregisterOldGestureHandler","delete","unregisterHandler","findHandler","get","findOldGestureHandler","findHandlerByTestID","undefined"],"mappings":"AAAA,SAASA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A8B;AAAA;;AAC5B,2BAAOJ,WAAW,CAACR,UAAD,CAAlB,uDAAkC,IAAlC;AACD;;AACD,SAAO,IAAP;AACD","sourcesContent":["import { isTestEnv } from '../utils';\nimport { GestureType } from './gestures/gesture';\nimport { GestureEvent, HandlerStateChangeEvent } from './gestureHandlerCommon';\n\nexport const handlerIDToTag: Record<string, number> = {};\nconst gestures = new Map<number, GestureType>();\nconst oldHandlers = new Map<number, GestureHandlerCallbacks>();\nconst testIDs = new Map<string, number>();\n\nexport function registerHandler(\n handlerTag: number,\n handler: GestureType,\n testID?: string\n) {\n gestures.set(handlerTag, handler);\n if (isTestEnv() && testID) {\n testIDs.set(testID, handlerTag);\n }\n}\n\nexport function registerOldGestureHandler(\n handlerTag: number,\n handler: GestureHandlerCallbacks\n) {\n oldHandlers.set(handlerTag, handler);\n}\n\nexport function unregisterOldGestureHandler(handlerTag: number) {\n oldHandlers.delete(handlerTag);\n}\n\nexport function unregisterHandler(handlerTag: number, testID?: string) {\n gestures.delete(handlerTag);\n if (isTestEnv() && testID) {\n testIDs.delete(testID);\n }\n}\n\nexport function findHandler(handlerTag: number) {\n return gestures.get(handlerTag);\n}\n\nexport function findOldGestureHandler(handlerTag: number) {\n return oldHandlers.get(handlerTag);\n}\n\nexport function findHandlerByTestID(testID: string) {\n const handlerTag = testIDs.get(testID);\n if (handlerTag !== undefined) {\n return findHandler(handlerTag) ?? null;\n }\n return null;\n}\n\nexport interface GestureHandlerCallbacks {\n onGestureEvent: (event: GestureEvent<any>) => void;\n onGestureStateChange: (event: HandlerStateChangeEvent<any>) => void;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["initialize","Directions","State","PointerType","default","gestureHandlerRootHOC","GestureHandlerRootView","MouseButton","TapGestureHandler","ForceTouchGestureHandler","LongPressGestureHandler","PanGestureHandler","PinchGestureHandler","RotationGestureHandler","FlingGestureHandler","createNativeWrapper","GestureDetector","GestureObjects","Gesture","NativeViewGestureHandler","RawButton","BaseButton","RectButton","BorderlessButton","PureNativeButton","TouchableHighlight","TouchableNativeFeedback","TouchableOpacity","TouchableWithoutFeedback","ScrollView","Switch","TextInput","DrawerLayoutAndroid","FlatList","RefreshControl","Text","HoverEffect","Swipeable","Pressable","DrawerLayout","enableExperimentalWebImplementation","enableLegacyWebImplementation"],"mappings":"AAAA,SAASA,UAAT,QAA2B,QAA3B;AAEA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,KAAT,QAAsB,SAAtB;AACA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,OAAO,IAAIC,qBAApB,QAAiD,oCAAjD;AACA,SAASD,OAAO,IAAIE,sBAApB,QAAkD,qCAAlD;AAeA,SAASC,WAAT,QAA4B,iCAA5B;AAsBA,SAASC,iBAAT,QAAkC,8BAAlC;AACA,SAASC,wBAAT,QAAyC,qCAAzC;AACA,SAASC,uBAAT,QAAwC,oCAAxC;AACA,SAASC,iBAAT,QAAkC,8BAAlC;AACA,SAASC,mBAAT,QAAoC,gCAApC;AACA,SAASC,sBAAT,QAAuC,mCAAvC;AACA,SAASC,mBAAT,QAAoC,gCAApC;AACA,SAASV,OAAO,IAAIW,mBAApB,QAA+C,gCAA/C;AAEA,SAASC,eAAT,QAAgC,qCAAhC;AACA,SAASC,cAAc,IAAIC,OAA3B,QAA0C,oCAA1C;AAkBA,SAASC,wBAAT,QAAyC,qCAAzC;AAOA,SACEC,SADF,EAEEC,UAFF,EAGEC,UAHF,EAIEC,gBAJF,EAKEC,gBALF,QAMO,6BANP;AAYA,SACEC,kBADF,EAEEC,uBAFF,EAGEC,gBAHF,EAIEC,wBAJF,QAKO,yBALP;AAMA,SACEC,UADF,EAEEC,MAFF,EAGEC,SAHF,EAIEC,mBAJF,EAKEC,QALF,EAMEC,cANF,QAOO,gCAPP;AAQA,SAASC,IAAT,QAAqB,mBAArB;AACA,SAASC,WAAT,QAA4B,kCAA5B;AAyCA,SAAShC,OAAO,IAAIiC,SAApB,QAAqC,wBAArC;AAEA,SAASjC,OAAO,IAAIkC,SAApB,QAAqC,wBAArC;AAUA,SAASlC,OAAO,IAAImC,YAApB,QAAwC,2BAAxC;AAEA,SACEC,mCADF,EAEEC,6BAFF,QAGO,8BAHP;AAKAzC,UAAU","sourcesContent":["import { initialize } from './init';\n\nexport { Directions } from './Directions';\nexport { State } from './State';\nexport { PointerType } from './PointerType';\nexport { default as gestureHandlerRootHOC } from './components/gestureHandlerRootHOC';\nexport { default as GestureHandlerRootView } from './components/GestureHandlerRootView';\nexport type {\n // Event types\n GestureEvent,\n HandlerStateChangeEvent,\n // Event payloads types\n GestureEventPayload,\n HandlerStateChangeEventPayload,\n // Pointer events\n GestureTouchEvent,\n TouchData,\n // New api event types\n GestureUpdateEvent,\n GestureStateChangeEvent,\n} from './handlers/gestureHandlerCommon';\nexport { MouseButton } from './handlers/gestureHandlerCommon';\nexport type { GestureType } from './handlers/gestures/gesture';\nexport type {\n TapGestureHandlerEventPayload,\n ForceTouchGestureHandlerEventPayload,\n LongPressGestureHandlerEventPayload,\n PanGestureHandlerEventPayload,\n PinchGestureHandlerEventPayload,\n RotationGestureHandlerEventPayload,\n NativeViewGestureHandlerPayload,\n FlingGestureHandlerEventPayload,\n} from './handlers/GestureHandlerEventPayload';\nexport type { TapGestureHandlerProps } from './handlers/TapGestureHandler';\nexport type { ForceTouchGestureHandlerProps } from './handlers/ForceTouchGestureHandler';\nexport type { ForceTouchGestureChangeEventPayload } from './handlers/gestures/forceTouchGesture';\nexport type { LongPressGestureHandlerProps } from './handlers/LongPressGestureHandler';\nexport type { PanGestureHandlerProps } from './handlers/PanGestureHandler';\nexport type { PanGestureChangeEventPayload } from './handlers/gestures/panGesture';\nexport type { PinchGestureHandlerProps } from './handlers/PinchGestureHandler';\nexport type { PinchGestureChangeEventPayload } from './handlers/gestures/pinchGesture';\nexport type { RotationGestureHandlerProps } from './handlers/RotationGestureHandler';\nexport type { FlingGestureHandlerProps } from './handlers/FlingGestureHandler';\nexport { TapGestureHandler } from './handlers/TapGestureHandler';\nexport { ForceTouchGestureHandler } from './handlers/ForceTouchGestureHandler';\nexport { LongPressGestureHandler } from './handlers/LongPressGestureHandler';\nexport { PanGestureHandler } from './handlers/PanGestureHandler';\nexport { PinchGestureHandler } from './handlers/PinchGestureHandler';\nexport { RotationGestureHandler } from './handlers/RotationGestureHandler';\nexport { FlingGestureHandler } from './handlers/FlingGestureHandler';\nexport { default as createNativeWrapper } from './handlers/createNativeWrapper';\nexport type { NativeViewGestureHandlerProps } from './handlers/NativeViewGestureHandler';\nexport { GestureDetector } from './handlers/gestures/GestureDetector';\nexport { GestureObjects as Gesture } from './handlers/gestures/gestureObjects';\nexport type { TapGestureType as TapGesture } from './handlers/gestures/tapGesture';\nexport type { PanGestureType as PanGesture } from './handlers/gestures/panGesture';\nexport type { FlingGestureType as FlingGesture } from './handlers/gestures/flingGesture';\nexport type { LongPressGestureType as LongPressGesture } from './handlers/gestures/longPressGesture';\nexport type { PinchGestureType as PinchGesture } from './handlers/gestures/pinchGesture';\nexport type { RotationGestureType as RotationGesture } from './handlers/gestures/rotationGesture';\nexport type { ForceTouchGestureType as ForceTouchGesture } from './handlers/gestures/forceTouchGesture';\nexport type { NativeGestureType as NativeGesture } from './handlers/gestures/nativeGesture';\nexport type { ManualGestureType as ManualGesture } from './handlers/gestures/manualGesture';\nexport type { HoverGestureType as HoverGesture } from './handlers/gestures/hoverGesture';\nexport type {\n ComposedGestureType as ComposedGesture,\n RaceGestureType as RaceGesture,\n SimultaneousGestureType as SimultaneousGesture,\n ExclusiveGestureType as ExclusiveGesture,\n} from './handlers/gestures/gestureComposition';\nexport type { GestureStateManagerType as GestureStateManager } from './handlers/gestures/gestureStateManager';\nexport { NativeViewGestureHandler } from './handlers/NativeViewGestureHandler';\nexport type {\n RawButtonProps,\n BaseButtonProps,\n RectButtonProps,\n BorderlessButtonProps,\n} from './components/GestureButtonsProps';\nexport {\n RawButton,\n BaseButton,\n RectButton,\n BorderlessButton,\n PureNativeButton,\n} from './components/GestureButtons';\nexport type {\n TouchableHighlightProps,\n TouchableOpacityProps,\n TouchableWithoutFeedbackProps,\n} from './components/touchables';\nexport {\n TouchableHighlight,\n TouchableNativeFeedback,\n TouchableOpacity,\n TouchableWithoutFeedback,\n} from './components/touchables';\nexport {\n ScrollView,\n Switch,\n TextInput,\n DrawerLayoutAndroid,\n FlatList,\n RefreshControl,\n} from './components/GestureComponents';\nexport { Text } from './components/Text';\nexport { HoverEffect } from './handlers/gestures/hoverGesture';\nexport type {\n // Events\n GestureHandlerGestureEvent,\n GestureHandlerStateChangeEvent,\n // Event payloads\n GestureHandlerGestureEventNativeEvent,\n GestureHandlerStateChangeNativeEvent,\n NativeViewGestureHandlerGestureEvent,\n NativeViewGestureHandlerStateChangeEvent,\n TapGestureHandlerGestureEvent,\n TapGestureHandlerStateChangeEvent,\n ForceTouchGestureHandlerGestureEvent,\n ForceTouchGestureHandlerStateChangeEvent,\n LongPressGestureHandlerGestureEvent,\n LongPressGestureHandlerStateChangeEvent,\n PanGestureHandlerGestureEvent,\n PanGestureHandlerStateChangeEvent,\n PinchGestureHandlerGestureEvent,\n PinchGestureHandlerStateChangeEvent,\n RotationGestureHandlerGestureEvent,\n RotationGestureHandlerStateChangeEvent,\n FlingGestureHandlerGestureEvent,\n FlingGestureHandlerStateChangeEvent,\n // Handlers props\n NativeViewGestureHandlerProperties,\n TapGestureHandlerProperties,\n LongPressGestureHandlerProperties,\n PanGestureHandlerProperties,\n PinchGestureHandlerProperties,\n RotationGestureHandlerProperties,\n FlingGestureHandlerProperties,\n ForceTouchGestureHandlerProperties,\n // Buttons props\n RawButtonProperties,\n BaseButtonProperties,\n RectButtonProperties,\n BorderlessButtonProperties,\n} from './handlers/gestureHandlerTypesCompat';\n\nexport type { SwipeableProps } from './components/Swipeable';\nexport { default as Swipeable } from './components/Swipeable';\nexport type { PressableProps } from './components/Pressable';\nexport { default as Pressable } from './components/Pressable';\n\nexport type {\n DrawerLayoutProps,\n DrawerPosition,\n DrawerState,\n DrawerType,\n DrawerLockMode,\n DrawerKeyboardDismissMode,\n} from './components/DrawerLayout';\nexport { default as DrawerLayout } from './components/DrawerLayout';\n\nexport {\n enableExperimentalWebImplementation,\n enableLegacyWebImplementation,\n} from './EnableNewWebImplementation';\n\ninitialize();\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":["initialize","Directions","State","PointerType","default","gestureHandlerRootHOC","GestureHandlerRootView","MouseButton","TapGestureHandler","ForceTouchGestureHandler","LongPressGestureHandler","PanGestureHandler","PinchGestureHandler","RotationGestureHandler","FlingGestureHandler","createNativeWrapper","GestureDetector","GestureObjects","Gesture","NativeViewGestureHandler","RawButton","BaseButton","RectButton","BorderlessButton","PureNativeButton","TouchableHighlight","TouchableNativeFeedback","TouchableOpacity","TouchableWithoutFeedback","ScrollView","Switch","TextInput","DrawerLayoutAndroid","FlatList","RefreshControl","Text","HoverEffect","Swipeable","Pressable","DrawerLayout","enableExperimentalWebImplementation","enableLegacyWebImplementation"],"mappings":"AAAA,SAASA,UAAT,QAA2B,QAA3B;AAEA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,KAAT,QAAsB,SAAtB;AACA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,OAAO,IAAIC,qBAApB,QAAiD,oCAAjD;AACA,SAASD,OAAO,IAAIE,sBAApB,QAAkD,qCAAlD;AAeA,SAASC,WAAT,QAA4B,iCAA5B;AAsBA,SAASC,iBAAT,QAAkC,8BAAlC;AACA,SAASC,wBAAT,QAAyC,qCAAzC;AACA,SAASC,uBAAT,QAAwC,oCAAxC;AACA,SAASC,iBAAT,QAAkC,8BAAlC;AACA,SAASC,mBAAT,QAAoC,gCAApC;AACA,SAASC,sBAAT,QAAuC,mCAAvC;AACA,SAASC,mBAAT,QAAoC,gCAApC;AACA,SAASV,OAAO,IAAIW,mBAApB,QAA+C,gCAA/C;AAEA,SAASC,eAAT,QAAgC,qCAAhC;AACA,SAASC,cAAc,IAAIC,OAA3B,QAA0C,oCAA1C;AAkBA,SAASC,wBAAT,QAAyC,qCAAzC;AAOA,SACEC,SADF,EAEEC,UAFF,EAGEC,UAHF,EAIEC,gBAJF,EAKEC,gBALF,QAMO,6BANP;AAYA,SACEC,kBADF,EAEEC,uBAFF,EAGEC,gBAHF,EAIEC,wBAJF,QAKO,yBALP;AAMA,SACEC,UADF,EAEEC,MAFF,EAGEC,SAHF,EAIEC,mBAJF,EAKEC,QALF,EAMEC,cANF,QAOO,gCAPP;AAQA,SAASC,IAAT,QAAqB,mBAArB;AACA,SAASC,WAAT,QAA4B,kCAA5B;AAyCA,SAAShC,OAAO,IAAIiC,SAApB,QAAqC,wBAArC;AAKA,SAASjC,OAAO,IAAIkC,SAApB,QAAqC,wBAArC;AAUA,SAASlC,OAAO,IAAImC,YAApB,QAAwC,2BAAxC;AAEA,SACEC,mCADF,EAEEC,6BAFF,QAGO,8BAHP;AAKAzC,UAAU","sourcesContent":["import { initialize } from './init';\n\nexport { Directions } from './Directions';\nexport { State } from './State';\nexport { PointerType } from './PointerType';\nexport { default as gestureHandlerRootHOC } from './components/gestureHandlerRootHOC';\nexport { default as GestureHandlerRootView } from './components/GestureHandlerRootView';\nexport type {\n // Event types\n GestureEvent,\n HandlerStateChangeEvent,\n // Event payloads types\n GestureEventPayload,\n HandlerStateChangeEventPayload,\n // Pointer events\n GestureTouchEvent,\n TouchData,\n // New api event types\n GestureUpdateEvent,\n GestureStateChangeEvent,\n} from './handlers/gestureHandlerCommon';\nexport { MouseButton } from './handlers/gestureHandlerCommon';\nexport type { GestureType } from './handlers/gestures/gesture';\nexport type {\n TapGestureHandlerEventPayload,\n ForceTouchGestureHandlerEventPayload,\n LongPressGestureHandlerEventPayload,\n PanGestureHandlerEventPayload,\n PinchGestureHandlerEventPayload,\n RotationGestureHandlerEventPayload,\n NativeViewGestureHandlerPayload,\n FlingGestureHandlerEventPayload,\n} from './handlers/GestureHandlerEventPayload';\nexport type { TapGestureHandlerProps } from './handlers/TapGestureHandler';\nexport type { ForceTouchGestureHandlerProps } from './handlers/ForceTouchGestureHandler';\nexport type { ForceTouchGestureChangeEventPayload } from './handlers/gestures/forceTouchGesture';\nexport type { LongPressGestureHandlerProps } from './handlers/LongPressGestureHandler';\nexport type { PanGestureHandlerProps } from './handlers/PanGestureHandler';\nexport type { PanGestureChangeEventPayload } from './handlers/gestures/panGesture';\nexport type { PinchGestureHandlerProps } from './handlers/PinchGestureHandler';\nexport type { PinchGestureChangeEventPayload } from './handlers/gestures/pinchGesture';\nexport type { RotationGestureHandlerProps } from './handlers/RotationGestureHandler';\nexport type { FlingGestureHandlerProps } from './handlers/FlingGestureHandler';\nexport { TapGestureHandler } from './handlers/TapGestureHandler';\nexport { ForceTouchGestureHandler } from './handlers/ForceTouchGestureHandler';\nexport { LongPressGestureHandler } from './handlers/LongPressGestureHandler';\nexport { PanGestureHandler } from './handlers/PanGestureHandler';\nexport { PinchGestureHandler } from './handlers/PinchGestureHandler';\nexport { RotationGestureHandler } from './handlers/RotationGestureHandler';\nexport { FlingGestureHandler } from './handlers/FlingGestureHandler';\nexport { default as createNativeWrapper } from './handlers/createNativeWrapper';\nexport type { NativeViewGestureHandlerProps } from './handlers/NativeViewGestureHandler';\nexport { GestureDetector } from './handlers/gestures/GestureDetector';\nexport { GestureObjects as Gesture } from './handlers/gestures/gestureObjects';\nexport type { TapGestureType as TapGesture } from './handlers/gestures/tapGesture';\nexport type { PanGestureType as PanGesture } from './handlers/gestures/panGesture';\nexport type { FlingGestureType as FlingGesture } from './handlers/gestures/flingGesture';\nexport type { LongPressGestureType as LongPressGesture } from './handlers/gestures/longPressGesture';\nexport type { PinchGestureType as PinchGesture } from './handlers/gestures/pinchGesture';\nexport type { RotationGestureType as RotationGesture } from './handlers/gestures/rotationGesture';\nexport type { ForceTouchGestureType as ForceTouchGesture } from './handlers/gestures/forceTouchGesture';\nexport type { NativeGestureType as NativeGesture } from './handlers/gestures/nativeGesture';\nexport type { ManualGestureType as ManualGesture } from './handlers/gestures/manualGesture';\nexport type { HoverGestureType as HoverGesture } from './handlers/gestures/hoverGesture';\nexport type {\n ComposedGestureType as ComposedGesture,\n RaceGestureType as RaceGesture,\n SimultaneousGestureType as SimultaneousGesture,\n ExclusiveGestureType as ExclusiveGesture,\n} from './handlers/gestures/gestureComposition';\nexport type { GestureStateManagerType as GestureStateManager } from './handlers/gestures/gestureStateManager';\nexport { NativeViewGestureHandler } from './handlers/NativeViewGestureHandler';\nexport type {\n RawButtonProps,\n BaseButtonProps,\n RectButtonProps,\n BorderlessButtonProps,\n} from './components/GestureButtonsProps';\nexport {\n RawButton,\n BaseButton,\n RectButton,\n BorderlessButton,\n PureNativeButton,\n} from './components/GestureButtons';\nexport type {\n TouchableHighlightProps,\n TouchableOpacityProps,\n TouchableWithoutFeedbackProps,\n} from './components/touchables';\nexport {\n TouchableHighlight,\n TouchableNativeFeedback,\n TouchableOpacity,\n TouchableWithoutFeedback,\n} from './components/touchables';\nexport {\n ScrollView,\n Switch,\n TextInput,\n DrawerLayoutAndroid,\n FlatList,\n RefreshControl,\n} from './components/GestureComponents';\nexport { Text } from './components/Text';\nexport { HoverEffect } from './handlers/gestures/hoverGesture';\nexport type {\n // Events\n GestureHandlerGestureEvent,\n GestureHandlerStateChangeEvent,\n // Event payloads\n GestureHandlerGestureEventNativeEvent,\n GestureHandlerStateChangeNativeEvent,\n NativeViewGestureHandlerGestureEvent,\n NativeViewGestureHandlerStateChangeEvent,\n TapGestureHandlerGestureEvent,\n TapGestureHandlerStateChangeEvent,\n ForceTouchGestureHandlerGestureEvent,\n ForceTouchGestureHandlerStateChangeEvent,\n LongPressGestureHandlerGestureEvent,\n LongPressGestureHandlerStateChangeEvent,\n PanGestureHandlerGestureEvent,\n PanGestureHandlerStateChangeEvent,\n PinchGestureHandlerGestureEvent,\n PinchGestureHandlerStateChangeEvent,\n RotationGestureHandlerGestureEvent,\n RotationGestureHandlerStateChangeEvent,\n FlingGestureHandlerGestureEvent,\n FlingGestureHandlerStateChangeEvent,\n // Handlers props\n NativeViewGestureHandlerProperties,\n TapGestureHandlerProperties,\n LongPressGestureHandlerProperties,\n PanGestureHandlerProperties,\n PinchGestureHandlerProperties,\n RotationGestureHandlerProperties,\n FlingGestureHandlerProperties,\n ForceTouchGestureHandlerProperties,\n // Buttons props\n RawButtonProperties,\n BaseButtonProperties,\n RectButtonProperties,\n BorderlessButtonProperties,\n} from './handlers/gestureHandlerTypesCompat';\n\nexport type { SwipeableProps } from './components/Swipeable';\nexport { default as Swipeable } from './components/Swipeable';\nexport type {\n PressableProps,\n PressableStateCallbackType,\n} from './components/Pressable';\nexport { default as Pressable } from './components/Pressable';\n\nexport type {\n DrawerLayoutProps,\n DrawerPosition,\n DrawerState,\n DrawerType,\n DrawerLockMode,\n DrawerKeyboardDismissMode,\n} from './components/DrawerLayout';\nexport { default as DrawerLayout } from './components/DrawerLayout';\n\nexport {\n enableExperimentalWebImplementation,\n enableLegacyWebImplementation,\n} from './EnableNewWebImplementation';\n\ninitialize();\n"]}
@@ -24,9 +24,9 @@ export function withPrevAndCurrent(array, mapFn) {
24
24
  export function hasProperty(object, key) {
25
25
  return Object.prototype.hasOwnProperty.call(object, key);
26
26
  }
27
- export function isJestEnv() {
27
+ export function isTestEnv() {
28
28
  // @ts-ignore Do not use `@types/node` because it will prioritise Node types over RN types which breaks the types (ex. setTimeout) in React Native projects.
29
- return hasProperty(global, 'process') && !!process.env.JEST_WORKER_ID;
29
+ return hasProperty(global, 'process') && process.env.NODE_ENV === 'test';
30
30
  }
31
31
  export function tagMessage(msg) {
32
32
  return `[react-native-gesture-handler] ${msg}`;
@@ -1 +1 @@
1
- {"version":3,"sources":["utils.ts"],"names":["toArray","object","Array","isArray","withPrevAndCurrent","array","mapFn","previousArr","currentArr","transformedArr","forEach","current","i","previous","transformed","push","hasProperty","key","Object","prototype","hasOwnProperty","call","isJestEnv","global","process","env","JEST_WORKER_ID","tagMessage","msg","isFabric","nativeFabricUIManager","isRemoteDebuggingEnabled","localGlobal","nativeCallSyncHook","__REMOTEDEV__","RN$Bridgeless","deepEqual","obj1","obj2","keys1","keys","keys2","length","includes","INT32_MAX"],"mappings":"AAAA,OAAO,SAASA,OAAT,CAAoBC,MAApB,EAA0C;AAC/C,MAAI,CAACC,KAAK,CAACC,OAAN,CAAcF,MAAd,CAAL,EAA4B;AAC1B,WAAO,CAACA,MAAD,CAAP;AACD;;AAED,SAAOA,MAAP;AACD;AAMD,OAAO,SAASG,kBAAT,CACLC,KADK,EAELC,KAFK,EAGU;AACf,QAAMC,WAAmC,GAAG,CAAC,IAAD,CAA5C;AACA,QAAMC,UAAU,GAAG,CAAC,GAAGH,KAAJ,CAAnB;AACA,QAAMI,cAA6B,GAAG,EAAtC;AACAD,EAAAA,UAAU,CAACE,OAAX,CAAmB,CAACC,OAAD,EAAUC,CAAV,KAAgB;AACjC;AACA;AACA;AACA,UAAMC,QAAQ,GAAGN,WAAW,CAACK,CAAD,CAA5B;AACA,UAAME,WAAW,GAAGR,KAAK,CAACO,QAAD,EAAWF,OAAX,CAAzB;AACAJ,IAAAA,WAAW,CAACQ,IAAZ,CAAiBD,WAAjB;AACAL,IAAAA,cAAc,CAACM,IAAf,CAAoBD,WAApB;AACD,GARD;AASA,SAAOL,cAAP;AACD,C,CAED;;AACA,OAAO,SAASO,WAAT,CAAqBf,MAArB,EAAqCgB,GAArC,EAAkD;AACvD,SAAOC,MAAM,CAACC,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCpB,MAArC,EAA6CgB,GAA7C,CAAP;AACD;AAED,OAAO,SAASK,SAAT,GAA8B;AACnC;AACA,SAAON,WAAW,CAACO,MAAD,EAAS,SAAT,CAAX,IAAkC,CAAC,CAACC,OAAO,CAACC,GAAR,CAAYC,cAAvD;AACD;AAED,OAAO,SAASC,UAAT,CAAoBC,GAApB,EAAiC;AACtC,SAAQ,kCAAiCA,GAAI,EAA7C;AACD,C,CAED;AACA;;AACA,OAAO,SAASC,QAAT,GAA6B;AAAA;;AAClC;AACA,SAAO,CAAC,aAACN,MAAD,oCAAC,QAAQO,qBAAT,CAAR;AACD;AAED,OAAO,SAASC,wBAAT,GAA6C;AAClD;AACA;AACA,QAAMC,WAAW,GAAGT,MAApB;AACA,SACE,CAAC,CAACS,WAAW,CAACC,kBAAb,IAAmC,CAAC,CAACD,WAAW,CAACE,aAAlD,KACA,CAACF,WAAW,CAACG,aAFf;AAID;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,SAAT,CAAmBC,IAAnB,EAA8BC,IAA9B,EAAyC;AAC9C,MAAID,IAAI,KAAKC,IAAb,EAAmB;AACjB,WAAO,IAAP;AACD;;AAED,MACE,OAAOD,IAAP,KAAgB,QAAhB,IACA,OAAOC,IAAP,KAAgB,QADhB,IAEAD,IAAI,KAAK,IAFT,IAGAC,IAAI,KAAK,IAJX,EAKE;AACA,WAAO,KAAP;AACD;;AAED,QAAMC,KAAK,GAAGrB,MAAM,CAACsB,IAAP,CAAYH,IAAZ,CAAd;AACA,QAAMI,KAAK,GAAGvB,MAAM,CAACsB,IAAP,CAAYF,IAAZ,CAAd;;AAEA,MAAIC,KAAK,CAACG,MAAN,KAAiBD,KAAK,CAACC,MAA3B,EAAmC;AACjC,WAAO,KAAP;AACD;;AAED,OAAK,MAAMzB,GAAX,IAAkBsB,KAAlB,EAAyB;AACvB,QAAI,CAACE,KAAK,CAACE,QAAN,CAAe1B,GAAf,CAAD,IAAwB,CAACmB,SAAS,CAACC,IAAI,CAACpB,GAAD,CAAL,EAAYqB,IAAI,CAACrB,GAAD,CAAhB,CAAtC,EAA8D;AAC5D,aAAO,KAAP;AACD;AACF;;AAED,SAAO,IAAP;AACD;AAED,OAAO,MAAM2B,SAAS,GAAG,KAAK,EAAL,GAAU,CAA5B","sourcesContent":["export function toArray<T>(object: T | T[]): T[] {\n if (!Array.isArray(object)) {\n return [object];\n }\n\n return object;\n}\n\nexport type withPrevAndCurrentMapFn<T, Transformed> = (\n previous: Transformed | null,\n current: T\n) => Transformed;\nexport function withPrevAndCurrent<T, Transformed>(\n array: T[],\n mapFn: withPrevAndCurrentMapFn<T, Transformed>\n): Transformed[] {\n const previousArr: (null | Transformed)[] = [null];\n const currentArr = [...array];\n const transformedArr: Transformed[] = [];\n currentArr.forEach((current, i) => {\n // This type cast is fine and solves problem mentioned in https://github.com/software-mansion/react-native-gesture-handler/pull/2867 (namely that `previous` can be undefined).\n // Unfortunately, linter on our CI does not allow this type of casting as it is unnecessary. To bypass that we use eslint-disable.\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const previous = previousArr[i] as Transformed | null;\n const transformed = mapFn(previous, current);\n previousArr.push(transformed);\n transformedArr.push(transformed);\n });\n return transformedArr;\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function hasProperty(object: object, key: string) {\n return Object.prototype.hasOwnProperty.call(object, key);\n}\n\nexport function isJestEnv(): boolean {\n // @ts-ignore Do not use `@types/node` because it will prioritise Node types over RN types which breaks the types (ex. setTimeout) in React Native projects.\n return hasProperty(global, 'process') && !!process.env.JEST_WORKER_ID;\n}\n\nexport function tagMessage(msg: string) {\n return `[react-native-gesture-handler] ${msg}`;\n}\n\n// Helper method to check whether Fabric is enabled, however global.nativeFabricUIManager\n// may not be initialized before the first render\nexport function isFabric(): boolean {\n // @ts-expect-error nativeFabricUIManager is not yet included in the RN types\n return !!global?.nativeFabricUIManager;\n}\n\nexport function isRemoteDebuggingEnabled(): boolean {\n // react-native-reanimated checks if in remote debugging in the same way\n // @ts-ignore global is available but node types are not included\n const localGlobal = global as any;\n return (\n (!localGlobal.nativeCallSyncHook || !!localGlobal.__REMOTEDEV__) &&\n !localGlobal.RN$Bridgeless\n );\n}\n\n/**\n * Recursively compares two objects for deep equality.\n *\n * **Note:** This function does not support cyclic references.\n *\n * @param obj1 - The first object to compare.\n * @param obj2 - The second object to compare.\n * @returns `true` if the objects are deeply equal, `false` otherwise.\n */\nexport function deepEqual(obj1: any, obj2: any) {\n if (obj1 === obj2) {\n return true;\n }\n\n if (\n typeof obj1 !== 'object' ||\n typeof obj2 !== 'object' ||\n obj1 === null ||\n obj2 === null\n ) {\n return false;\n }\n\n const keys1 = Object.keys(obj1);\n const keys2 = Object.keys(obj2);\n\n if (keys1.length !== keys2.length) {\n return false;\n }\n\n for (const key of keys1) {\n if (!keys2.includes(key) || !deepEqual(obj1[key], obj2[key])) {\n return false;\n }\n }\n\n return true;\n}\n\nexport const INT32_MAX = 2 ** 31 - 1;\n"]}
1
+ {"version":3,"sources":["utils.ts"],"names":["toArray","object","Array","isArray","withPrevAndCurrent","array","mapFn","previousArr","currentArr","transformedArr","forEach","current","i","previous","transformed","push","hasProperty","key","Object","prototype","hasOwnProperty","call","isTestEnv","global","process","env","NODE_ENV","tagMessage","msg","isFabric","nativeFabricUIManager","isRemoteDebuggingEnabled","localGlobal","nativeCallSyncHook","__REMOTEDEV__","RN$Bridgeless","deepEqual","obj1","obj2","keys1","keys","keys2","length","includes","INT32_MAX"],"mappings":"AAAA,OAAO,SAASA,OAAT,CAAoBC,MAApB,EAA0C;AAC/C,MAAI,CAACC,KAAK,CAACC,OAAN,CAAcF,MAAd,CAAL,EAA4B;AAC1B,WAAO,CAACA,MAAD,CAAP;AACD;;AAED,SAAOA,MAAP;AACD;AAMD,OAAO,SAASG,kBAAT,CACLC,KADK,EAELC,KAFK,EAGU;AACf,QAAMC,WAAmC,GAAG,CAAC,IAAD,CAA5C;AACA,QAAMC,UAAU,GAAG,CAAC,GAAGH,KAAJ,CAAnB;AACA,QAAMI,cAA6B,GAAG,EAAtC;AACAD,EAAAA,UAAU,CAACE,OAAX,CAAmB,CAACC,OAAD,EAAUC,CAAV,KAAgB;AACjC;AACA;AACA;AACA,UAAMC,QAAQ,GAAGN,WAAW,CAACK,CAAD,CAA5B;AACA,UAAME,WAAW,GAAGR,KAAK,CAACO,QAAD,EAAWF,OAAX,CAAzB;AACAJ,IAAAA,WAAW,CAACQ,IAAZ,CAAiBD,WAAjB;AACAL,IAAAA,cAAc,CAACM,IAAf,C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AN,KAAiBD,KAAK,CAACC,MAA3B,EAAmC;AACjC,WAAO,KAAP;AACD;;AAED,OAAK,MAAMzB,GAAX,IAAkBsB,KAAlB,EAAyB;AACvB,QAAI,CAACE,KAAK,CAACE,QAAN,CAAe1B,GAAf,CAAD,IAAwB,CAACmB,SAAS,CAACC,IAAI,CAACpB,GAAD,CAAL,EAAYqB,IAAI,CAACrB,GAAD,CAAhB,CAAtC,EAA8D;AAC5D,aAAO,KAAP;AACD;AACF;;AAED,SAAO,IAAP;AACD;AAED,OAAO,MAAM2B,SAAS,GAAG,KAAK,EAAL,GAAU,CAA5B","sourcesContent":["export function toArray<T>(object: T | T[]): T[] {\n if (!Array.isArray(object)) {\n return [object];\n }\n\n return object;\n}\n\nexport type withPrevAndCurrentMapFn<T, Transformed> = (\n previous: Transformed | null,\n current: T\n) => Transformed;\nexport function withPrevAndCurrent<T, Transformed>(\n array: T[],\n mapFn: withPrevAndCurrentMapFn<T, Transformed>\n): Transformed[] {\n const previousArr: (null | Transformed)[] = [null];\n const currentArr = [...array];\n const transformedArr: Transformed[] = [];\n currentArr.forEach((current, i) => {\n // This type cast is fine and solves problem mentioned in https://github.com/software-mansion/react-native-gesture-handler/pull/2867 (namely that `previous` can be undefined).\n // Unfortunately, linter on our CI does not allow this type of casting as it is unnecessary. To bypass that we use eslint-disable.\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const previous = previousArr[i] as Transformed | null;\n const transformed = mapFn(previous, current);\n previousArr.push(transformed);\n transformedArr.push(transformed);\n });\n return transformedArr;\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function hasProperty(object: object, key: string) {\n return Object.prototype.hasOwnProperty.call(object, key);\n}\n\nexport function isTestEnv(): boolean {\n // @ts-ignore Do not use `@types/node` because it will prioritise Node types over RN types which breaks the types (ex. setTimeout) in React Native projects.\n return hasProperty(global, 'process') && process.env.NODE_ENV === 'test';\n}\n\nexport function tagMessage(msg: string) {\n return `[react-native-gesture-handler] ${msg}`;\n}\n\n// Helper method to check whether Fabric is enabled, however global.nativeFabricUIManager\n// may not be initialized before the first render\nexport function isFabric(): boolean {\n // @ts-expect-error nativeFabricUIManager is not yet included in the RN types\n return !!global?.nativeFabricUIManager;\n}\n\nexport function isRemoteDebuggingEnabled(): boolean {\n // react-native-reanimated checks if in remote debugging in the same way\n // @ts-ignore global is available but node types are not included\n const localGlobal = global as any;\n return (\n (!localGlobal.nativeCallSyncHook || !!localGlobal.__REMOTEDEV__) &&\n !localGlobal.RN$Bridgeless\n );\n}\n\n/**\n * Recursively compares two objects for deep equality.\n *\n * **Note:** This function does not support cyclic references.\n *\n * @param obj1 - The first object to compare.\n * @param obj2 - The second object to compare.\n * @returns `true` if the objects are deeply equal, `false` otherwise.\n */\nexport function deepEqual(obj1: any, obj2: any) {\n if (obj1 === obj2) {\n return true;\n }\n\n if (\n typeof obj1 !== 'object' ||\n typeof obj2 !== 'object' ||\n obj1 === null ||\n obj2 === null\n ) {\n return false;\n }\n\n const keys1 = Object.keys(obj1);\n const keys2 = Object.keys(obj2);\n\n if (keys1.length !== keys2.length) {\n return false;\n }\n\n for (const key of keys1) {\n if (!keys2.includes(key) || !deepEqual(obj1[key], obj2[key])) {\n return false;\n }\n }\n\n return true;\n}\n\nexport const INT32_MAX = 2 ** 31 - 1;\n"]}
@@ -15,11 +15,11 @@ export default class RotationGestureDetector {
15
15
 
16
16
  _defineProperty(this, "previousAngle", 0);
17
17
 
18
- _defineProperty(this, "rotation", 0);
18
+ _defineProperty(this, "_rotation", 0);
19
19
 
20
- _defineProperty(this, "anchorX", 0);
20
+ _defineProperty(this, "_anchorX", 0);
21
21
 
22
- _defineProperty(this, "anchorY", 0);
22
+ _defineProperty(this, "_anchorY", 0);
23
23
 
24
24
  _defineProperty(this, "isInProgress", false);
25
25
 
@@ -38,23 +38,23 @@ export default class RotationGestureDetector {
38
38
  const secondPointerCoords = tracker.getLastAbsoluteCoords(secondPointerID);
39
39
  const vectorX = secondPointerCoords.x - firstPointerCoords.x;
40
40
  const vectorY = secondPointerCoords.y - firstPointerCoords.y;
41
- this.anchorX = (firstPointerCoords.x + secondPointerCoords.x) / 2;
42
- this.anchorY = (firstPointerCoords.y + secondPointerCoords.y) / 2; // Angle diff should be positive when rotating in clockwise direction
41
+ this._anchorX = (firstPointerCoords.x + secondPointerCoords.x) / 2;
42
+ this._anchorY = (firstPointerCoords.y + secondPointerCoords.y) / 2; // Angle diff should be positive when rotating in clockwise direction
43
43
 
44
44
  const angle = -Math.atan2(vectorY, vectorX);
45
- this.rotation = Number.isNaN(this.previousAngle) ? 0 : this.previousAngle - angle;
45
+ this._rotation = Number.isNaN(this.previousAngle) ? 0 : this.previousAngle - angle;
46
46
  this.previousAngle = angle;
47
47
 
48
48
  if (this.rotation > Math.PI) {
49
- this.rotation -= Math.PI;
49
+ this._rotation -= Math.PI;
50
50
  } else if (this.rotation < -Math.PI) {
51
- this.rotation += Math.PI;
51
+ this._rotation += Math.PI;
52
52
  }
53
53
 
54
54
  if (this.rotation > Math.PI / 2) {
55
- this.rotation -= Math.PI;
55
+ this._rotation -= Math.PI;
56
56
  } else if (this.rotation < -Math.PI / 2) {
57
- this.rotation += Math.PI;
57
+ this._rotation += Math.PI;
58
58
  }
59
59
  }
60
60
 
@@ -73,7 +73,7 @@ export default class RotationGestureDetector {
73
73
  return;
74
74
  }
75
75
 
76
- const pointerIDs = tracker.getData().keys();
76
+ const pointerIDs = tracker.trackedPointers.keys();
77
77
  this.keyPointers[0] = pointerIDs.next().value;
78
78
  this.keyPointers[1] = pointerIDs.next().value;
79
79
  }
@@ -128,25 +128,25 @@ export default class RotationGestureDetector {
128
128
  return true;
129
129
  }
130
130
 
131
- getTimeDelta() {
132
- return this.currentTime + this.previousTime;
131
+ reset() {
132
+ this.keyPointers = [NaN, NaN];
133
+ this.isInProgress = false;
133
134
  }
134
135
 
135
- getAnchorX() {
136
- return this.anchorX;
136
+ get anchorX() {
137
+ return this._anchorX;
137
138
  }
138
139
 
139
- getAnchorY() {
140
- return this.anchorY;
140
+ get anchorY() {
141
+ return this._anchorY;
141
142
  }
142
143
 
143
- getRotation() {
144
- return this.rotation;
144
+ get rotation() {
145
+ return this._rotation;
145
146
  }
146
147
 
147
- reset() {
148
- this.keyPointers = [NaN, NaN];
149
- this.isInProgress = false;
148
+ get timeDelta() {
149
+ return this.currentTime + this.previousTime;
150
150
  }
151
151
 
152
152
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["RotationGestureDetector.ts"],"names":["EventTypes","RotationGestureDetector","constructor","callbacks","NaN","onRotationBegin","onRotation","onRotationEnd","updateCurrent","event","tracker","previousTime","currentTime","time","firstPointerID","secondPointerID","keyPointers","firstPointerCoords","getLastAbsoluteCoords","secondPointerCoords","vectorX","x","vectorY","y","anchorX","anchorY","angle","Math","atan2","rotation","Number","isNaN","previousAngle","PI","finish","isInProgress","setKeyPointers","pointerIDs","getData","keys","next","value","onTouchEvent","eventType","DOWN","ADDITIONAL_POINTER_DOWN","MOVE","ADDITIONAL_POINTER_UP","indexOf","pointerId","UP","getTimeDelta","getAnchorX","getAnchorY","getRotation","reset"],"mappings":";;AAAA,SAAuBA,UAAvB,QAAyC,eAAzC;AASA,eAAe,MAAMC,uBAAN,CAEf;AAkBEC,EAAAA,WAAW,CAACC,SAAD,EAAqC;AAAA;;AAAA;;AAAA;;AAAA,yCAb1B,CAa0B;;AAAA,0CAZzB,CAYyB;;AAAA,2CAVxB,CAUwB;;AAAA,sCAT7B,CAS6B;;AAAA,qCAP9B,CAO8B;;AAAA,qCAN9B,CAM8B;;AAAA,0CAJzB,KAIyB;;AAAA,yCAFhB,CAACC,GAAD,EAAMA,GAAN,CAEgB;;AAC9C,SAAKC,eAAL,GAAuBF,SAAS,CAACE,eAAjC;AACA,SAAKC,UAAL,GAAkBH,SAAS,CAACG,UAA5B;AACA,SAAKC,aAAL,GAAqBJ,SAAS,CAACI,aAA/B;AACD;;AAEOC,EAAAA,aAAa,CAACC,KAAD,EAAsBC,OAAtB,EAAqD;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AEF,WAAKL,UAAU,CAAC8C,IAAhB;AACE,YAAI,CAAC,KAAKX,YAAV,EAAwB;AACtB;AACD;;AAED,aAAK3B,aAAL,CAAmBC,KAAnB,EAA0BC,OAA1B;AACA,aAAKJ,UAAL,CAAgB,IAAhB;AAEA;;AAEF,WAAKN,UAAU,CAAC+C,qBAAhB;AACE,YAAI,CAAC,KAAKZ,YAAV,EAAwB;AACtB;AACD;;AAED,YAAI,KAAKnB,WAAL,CAAiBgC,OAAjB,CAAyBvC,KAAK,CAACwC,SAA/B,KAA6C,CAAjD,EAAoD;AAClD,eAAKf,MAAL;AACD;;AAED;;AAEF,WAAKlC,UAAU,CAACkD,EAAhB;AACE,YAAI,KAAKf,YAAT,EAAuB;AACrB,eAAKD,MAAL;AACD;;AACD;AA7CJ;;AAgDA,WAAO,IAAP;AACD;;AAEMiB,EAAAA,YAAY,GAAW;AAC5B,WAAO,KAAKvC,WAAL,GAAmB,KAAKD,YAA/B;AACD;;AAEMyC,EAAAA,UAAU,GAAW;AAC1B,WAAO,KAAK5B,OAAZ;AACD;;AAEM6B,EAAAA,UAAU,GAAW;AAC1B,WAAO,KAAK5B,OAAZ;AACD;;AAEM6B,EAAAA,WAAW,GAAW;AAC3B,WAAO,KAAKzB,QAAZ;AACD;;AAEM0B,EAAAA,KAAK,GAAS;AACnB,SAAKvC,WAAL,GAAmB,CAACZ,GAAD,EAAMA,GAAN,CAAnB;AACA,SAAK+B,YAAL,GAAoB,KAApB;AACD;;AAzJH","sourcesContent":["import { AdaptedEvent, EventTypes } from '../interfaces';\nimport PointerTracker from '../tools/PointerTracker';\n\nexport interface RotationGestureListener {\n onRotationBegin: (detector: RotationGestureDetector) => boolean;\n onRotation: (detector: RotationGestureDetector) => boolean;\n onRotationEnd: (detector: RotationGestureDetector) => void;\n}\n\nexport default class RotationGestureDetector\n implements RotationGestureListener\n{\n onRotationBegin: (detector: RotationGestureDetector) => boolean;\n onRotation: (detector: RotationGestureDetector) => boolean;\n onRotationEnd: (detector: RotationGestureDetector) => void;\n\n private currentTime = 0;\n private previousTime = 0;\n\n private previousAngle = 0;\n private rotation = 0;\n\n private anchorX = 0;\n private anchorY = 0;\n\n private isInProgress = false;\n\n private keyPointers: number[] = [NaN, NaN];\n\n constructor(callbacks: RotationGestureListener) {\n this.onRotationBegin = callbacks.onRotationBegin;\n this.onRotation = callbacks.onRotation;\n this.onRotationEnd = callbacks.onRotationEnd;\n }\n\n private updateCurrent(event: AdaptedEvent, tracker: PointerTracker): void {\n this.previousTime = this.currentTime;\n this.currentTime = event.time;\n\n const [firstPointerID, secondPointerID] = this.keyPointers;\n\n const firstPointerCoords = tracker.getLastAbsoluteCoords(firstPointerID);\n const secondPointerCoords = tracker.getLastAbsoluteCoords(secondPointerID);\n\n const vectorX: number = secondPointerCoords.x - firstPointerCoords.x;\n const vectorY: number = secondPointerCoords.y - firstPointerCoords.y;\n\n this.anchorX = (firstPointerCoords.x + secondPointerCoords.x) / 2;\n this.anchorY = (firstPointerCoords.y + secondPointerCoords.y) / 2;\n\n // Angle diff should be positive when rotating in clockwise direction\n const angle: number = -Math.atan2(vectorY, vectorX);\n\n this.rotation = Number.isNaN(this.previousAngle)\n ? 0\n : this.previousAngle - angle;\n\n this.previousAngle = angle;\n\n if (this.rotation > Math.PI) {\n this.rotation -= Math.PI;\n } else if (this.rotation < -Math.PI) {\n this.rotation += Math.PI;\n }\n\n if (this.rotation > Math.PI / 2) {\n this.rotation -= Math.PI;\n } else if (this.rotation < -Math.PI / 2) {\n this.rotation += Math.PI;\n }\n }\n\n private finish(): void {\n if (!this.isInProgress) {\n return;\n }\n\n this.isInProgress = false;\n this.keyPointers = [NaN, NaN];\n this.onRotationEnd(this);\n }\n\n private setKeyPointers(tracker: PointerTracker): void {\n if (this.keyPointers[0] && this.keyPointers[1]) {\n return;\n }\n\n const pointerIDs: IterableIterator<number> = tracker.getData().keys();\n\n this.keyPointers[0] = pointerIDs.next().value as number;\n this.keyPointers[1] = pointerIDs.next().value as number;\n }\n\n public onTouchEvent(event: AdaptedEvent, tracker: PointerTracker): boolean {\n switch (event.eventType) {\n case EventTypes.DOWN:\n this.isInProgress = false;\n break;\n\n case EventTypes.ADDITIONAL_POINTER_DOWN:\n if (this.isInProgress) {\n break;\n }\n this.isInProgress = true;\n\n this.previousTime = event.time;\n this.previousAngle = NaN;\n\n this.setKeyPointers(tracker);\n\n this.updateCurrent(event, tracker);\n this.onRotationBegin(this);\n break;\n\n case EventTypes.MOVE:\n if (!this.isInProgress) {\n break;\n }\n\n this.updateCurrent(event, tracker);\n this.onRotation(this);\n\n break;\n\n case EventTypes.ADDITIONAL_POINTER_UP:\n if (!this.isInProgress) {\n break;\n }\n\n if (this.keyPointers.indexOf(event.pointerId) >= 0) {\n this.finish();\n }\n\n break;\n\n case EventTypes.UP:\n if (this.isInProgress) {\n this.finish();\n }\n break;\n }\n\n return true;\n }\n\n public getTimeDelta(): number {\n return this.currentTime + this.previousTime;\n }\n\n public getAnchorX(): number {\n return this.anchorX;\n }\n\n public getAnchorY(): number {\n return this.anchorY;\n }\n\n public getRotation(): number {\n return this.rotation;\n }\n\n public reset(): void {\n this.keyPointers = [NaN, NaN];\n this.isInProgress = false;\n }\n}\n"]}
1
+ {"version":3,"sources":["RotationGestureDetector.ts"],"names":["EventTypes","RotationGestureDetector","constructor","callbacks","NaN","onRotationBegin","onRotation","onRotationEnd","updateCurrent","event","tracker","previousTime","currentTime","time","firstPointerID","secondPointerID","keyPointers","firstPointerCoords","getLastAbsoluteCoords","secondPointerCoords","vectorX","x","vectorY","y","_anchorX","_anchorY","angle","Math","atan2","_rotation","Number","isNaN","previousAngle","rotation","PI","finish","isInProgress","setKeyPointers","pointerIDs","trackedPointers","keys","next","value","onTouchEvent","eventType","DOWN","ADDITIONAL_POINTER_DOWN","MOVE","ADDITIONAL_POINTER_UP","indexOf","pointerId","UP","reset","anchorX","anchorY","timeDelta"],"mappings":";;AAAA,SAAuBA,UAAvB,QAAyC,eAAzC;AASA,eAAe,MAAMC,uBA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;AACD;;AAEkB,MAARQ,QAAQ,GAAG;AACpB,WAAO,KAAKJ,SAAZ;AACD;;AAEmB,MAAT0B,SAAS,GAAG;AACrB,WAAO,KAAK3C,WAAL,GAAmB,KAAKD,YAA/B;AACD;;AAzJH","sourcesContent":["import { AdaptedEvent, EventTypes } from '../interfaces';\nimport PointerTracker from '../tools/PointerTracker';\n\nexport interface RotationGestureListener {\n onRotationBegin: (detector: RotationGestureDetector) => boolean;\n onRotation: (detector: RotationGestureDetector) => boolean;\n onRotationEnd: (detector: RotationGestureDetector) => void;\n}\n\nexport default class RotationGestureDetector\n implements RotationGestureListener\n{\n onRotationBegin: (detector: RotationGestureDetector) => boolean;\n onRotation: (detector: RotationGestureDetector) => boolean;\n onRotationEnd: (detector: RotationGestureDetector) => void;\n\n private currentTime = 0;\n private previousTime = 0;\n\n private previousAngle = 0;\n private _rotation = 0;\n\n private _anchorX = 0;\n private _anchorY = 0;\n\n private isInProgress = false;\n\n private keyPointers: number[] = [NaN, NaN];\n\n constructor(callbacks: RotationGestureListener) {\n this.onRotationBegin = callbacks.onRotationBegin;\n this.onRotation = callbacks.onRotation;\n this.onRotationEnd = callbacks.onRotationEnd;\n }\n\n private updateCurrent(event: AdaptedEvent, tracker: PointerTracker): void {\n this.previousTime = this.currentTime;\n this.currentTime = event.time;\n\n const [firstPointerID, secondPointerID] = this.keyPointers;\n\n const firstPointerCoords = tracker.getLastAbsoluteCoords(firstPointerID);\n const secondPointerCoords = tracker.getLastAbsoluteCoords(secondPointerID);\n\n const vectorX: number = secondPointerCoords.x - firstPointerCoords.x;\n const vectorY: number = secondPointerCoords.y - firstPointerCoords.y;\n\n this._anchorX = (firstPointerCoords.x + secondPointerCoords.x) / 2;\n this._anchorY = (firstPointerCoords.y + secondPointerCoords.y) / 2;\n\n // Angle diff should be positive when rotating in clockwise direction\n const angle: number = -Math.atan2(vectorY, vectorX);\n\n this._rotation = Number.isNaN(this.previousAngle)\n ? 0\n : this.previousAngle - angle;\n\n this.previousAngle = angle;\n\n if (this.rotation > Math.PI) {\n this._rotation -= Math.PI;\n } else if (this.rotation < -Math.PI) {\n this._rotation += Math.PI;\n }\n\n if (this.rotation > Math.PI / 2) {\n this._rotation -= Math.PI;\n } else if (this.rotation < -Math.PI / 2) {\n this._rotation += Math.PI;\n }\n }\n\n private finish(): void {\n if (!this.isInProgress) {\n return;\n }\n\n this.isInProgress = false;\n this.keyPointers = [NaN, NaN];\n this.onRotationEnd(this);\n }\n\n private setKeyPointers(tracker: PointerTracker): void {\n if (this.keyPointers[0] && this.keyPointers[1]) {\n return;\n }\n\n const pointerIDs: IterableIterator<number> = tracker.trackedPointers.keys();\n\n this.keyPointers[0] = pointerIDs.next().value as number;\n this.keyPointers[1] = pointerIDs.next().value as number;\n }\n\n public onTouchEvent(event: AdaptedEvent, tracker: PointerTracker): boolean {\n switch (event.eventType) {\n case EventTypes.DOWN:\n this.isInProgress = false;\n break;\n\n case EventTypes.ADDITIONAL_POINTER_DOWN:\n if (this.isInProgress) {\n break;\n }\n this.isInProgress = true;\n\n this.previousTime = event.time;\n this.previousAngle = NaN;\n\n this.setKeyPointers(tracker);\n\n this.updateCurrent(event, tracker);\n this.onRotationBegin(this);\n break;\n\n case EventTypes.MOVE:\n if (!this.isInProgress) {\n break;\n }\n\n this.updateCurrent(event, tracker);\n this.onRotation(this);\n\n break;\n\n case EventTypes.ADDITIONAL_POINTER_UP:\n if (!this.isInProgress) {\n break;\n }\n\n if (this.keyPointers.indexOf(event.pointerId) >= 0) {\n this.finish();\n }\n\n break;\n\n case EventTypes.UP:\n if (this.isInProgress) {\n this.finish();\n }\n break;\n }\n\n return true;\n }\n\n public reset(): void {\n this.keyPointers = [NaN, NaN];\n this.isInProgress = false;\n }\n\n public get anchorX() {\n return this._anchorX;\n }\n\n public get anchorY() {\n return this._anchorY;\n }\n\n public get rotation() {\n return this._rotation;\n }\n\n public get timeDelta() {\n return this.currentTime + this.previousTime;\n }\n}\n"]}
@@ -10,11 +10,11 @@ export default class ScaleGestureDetector {
10
10
 
11
11
  _defineProperty(this, "onScaleEnd", void 0);
12
12
 
13
- _defineProperty(this, "focusX", void 0);
13
+ _defineProperty(this, "_focusX", void 0);
14
14
 
15
- _defineProperty(this, "focusY", void 0);
15
+ _defineProperty(this, "_focusY", void 0);
16
16
 
17
- _defineProperty(this, "currentSpan", void 0);
17
+ _defineProperty(this, "_currentSpan", void 0);
18
18
 
19
19
  _defineProperty(this, "prevSpan", void 0);
20
20
 
@@ -40,7 +40,7 @@ export default class ScaleGestureDetector {
40
40
  onTouchEvent(event, tracker) {
41
41
  this.currentTime = event.time;
42
42
  const action = event.eventType;
43
- const numOfPointers = tracker.getTrackedPointersCount();
43
+ const numOfPointers = tracker.trackedPointersCount;
44
44
  const streamComplete = action === EventTypes.UP || action === EventTypes.ADDITIONAL_POINTER_UP || action === EventTypes.CANCEL;
45
45
 
46
46
  if (action === EventTypes.DOWN || streamComplete) {
@@ -66,7 +66,7 @@ export default class ScaleGestureDetector {
66
66
 
67
67
  let devSumX = 0;
68
68
  let devSumY = 0;
69
- tracker.getData().forEach((value, key) => {
69
+ tracker.trackedPointers.forEach((value, key) => {
70
70
  if (key === ignoredPointer) {
71
71
  return;
72
72
  }
@@ -81,8 +81,8 @@ export default class ScaleGestureDetector {
81
81
  const span = Math.hypot(spanX, spanY); // Begin/end events
82
82
 
83
83
  const wasInProgress = this.inProgress;
84
- this.focusX = focusX;
85
- this.focusY = focusY;
84
+ this._focusX = focusX;
85
+ this._focusY = focusY;
86
86
 
87
87
  if (this.inProgress && (span < this.minSpan || configChanged)) {
88
88
  this.onScaleEnd(this);
@@ -91,11 +91,11 @@ export default class ScaleGestureDetector {
91
91
  }
92
92
 
93
93
  if (configChanged) {
94
- this.initialSpan = this.prevSpan = this.currentSpan = span;
94
+ this.initialSpan = this.prevSpan = this._currentSpan = span;
95
95
  }
96
96
 
97
97
  if (!this.inProgress && span >= this.minSpan && (wasInProgress || Math.abs(span - this.initialSpan) > this.spanSlop)) {
98
- this.prevSpan = this.currentSpan = span;
98
+ this.prevSpan = this._currentSpan = span;
99
99
  this.prevTime = this.currentTime;
100
100
  this.inProgress = this.onScaleBegin(this);
101
101
  } // Handle motion
@@ -105,7 +105,7 @@ export default class ScaleGestureDetector {
105
105
  return true;
106
106
  }
107
107
 
108
- this.currentSpan = span;
108
+ this._currentSpan = span;
109
109
 
110
110
  if (this.inProgress && !this.onScale(this)) {
111
111
  return true;
@@ -116,28 +116,28 @@ export default class ScaleGestureDetector {
116
116
  return true;
117
117
  }
118
118
 
119
- getCurrentSpan() {
120
- return this.currentSpan;
121
- }
119
+ calculateScaleFactor(numOfPointers) {
120
+ if (numOfPointers < 2) {
121
+ return 1;
122
+ }
122
123
 
123
- getFocusX() {
124
- return this.focusX;
124
+ return this.prevSpan > 0 ? this.currentSpan / this.prevSpan : 1;
125
125
  }
126
126
 
127
- getFocusY() {
128
- return this.focusY;
127
+ get currentSpan() {
128
+ return this._currentSpan;
129
129
  }
130
130
 
131
- getTimeDelta() {
132
- return this.currentTime - this.prevTime;
131
+ get focusX() {
132
+ return this._focusX;
133
133
  }
134
134
 
135
- getScaleFactor(numOfPointers) {
136
- if (numOfPointers < 2) {
137
- return 1;
138
- }
135
+ get focusY() {
136
+ return this._focusY;
137
+ }
139
138
 
140
- return this.prevSpan > 0 ? this.currentSpan / this.prevSpan : 1;
139
+ get timeDelta() {
140
+ return this.currentTime - this.prevTime;
141
141
  }
142
142
 
143
143
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["ScaleGestureDetector.ts"],"names":["DEFAULT_TOUCH_SLOP","EventTypes","ScaleGestureDetector","constructor","callbacks","onScaleBegin","onScale","onScaleEnd","spanSlop","minSpan","onTouchEvent","event","tracker","currentTime","time","action","eventType","numOfPointers","getTrackedPointersCount","streamComplete","UP","ADDITIONAL_POINTER_UP","CANCEL","DOWN","inProgress","initialSpan","configChanged","ADDITIONAL_POINTER_DOWN","pointerUp","ignoredPointer","pointerId","undefined","div","coordsSum","getAbsoluteCoordsSum","focusX","x","focusY","y","devSumX","devSumY","getData","forEach","value","key","Math","abs","abosoluteCoords","devX","devY","spanX","spanY","span","hypot","wasInProgress","prevSpan","currentSpan","prevTime","MOVE","getCurrentSpan","getFocusX","getFocusY","getTimeDelta","getScaleFactor"],"mappings":";;AAAA,SAASA,kBAAT,QAAmC,cAAnC;AACA,SAAuBC,UAAvB,QAAyC,eAAzC;AAUA,eAAe,MAAMC,oBAAN,CAA2D;AAoBxEC,EAAAA,WAAW,CAACC,SAAD,EAAkC;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,wCALxB,KAKwB;;AAAA;;AAAA;;AAC3C,SAAKC,YAAL,GAAoBD,SAAS,CAACC,YAA9B;AACA,SAAKC,OAAL,GAAeF,SAAS,CAACE,OAAzB;AACA,SAAKC,UAAL,GAAkBH,SAAS,CAACG,UAA5B;AAEA,SAAKC,QAAL,GAAgBR,kBAAkB,GAAG,CAArC;AACA,SAAKS,OAAL,GAAe,CAAf;AACD;;AAEMC,EAAAA,YAAY,CAACC,KAAD,EAAsBC,OAAtB,EAAwD;AACzE,SAAKC,WAAL,GAAmBF,KAAK,CAACG,IAAzB;AAEA,UAAMC,MAAkB,GAAGJ,KAAK,CAACK,SAAjC;AACA,UAAMC,aAAa,GAAGL,OAAO,CAACM,uBAAR,EAAtB;AAEA,UAAMC,cAAuB,GAC3BJ,MAAM,KAAKd,UAAU,CAACmB,EAAtB,IACAL,MAAM,KAAKd,UAAU,CAACoB,qBADtB,IAEAN,MAAM,KAAKd,UAAU,CAACqB,MAHxB;;AAKA,QAAIP,MAAM,KAAKd,UAAU,CAACsB,IAAtB,IAA8BJ,cAAlC,EAAkD;AAChD,UAAI,KAAKK,UAAT,EAAqB;AACnB,aAAKjB,UAAL,CAAgB,IAAhB;AACA,aAAKiB,UAAL,GAAkB,KAAlB;AACA,aAAKC,WAAL,GAAmB,CAAnB;AACD;;AAED,UAAIN,cAAJ,E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AZ;AACD;;AAEMI,EAAAA,SAAS,GAAW;AACzB,WAAO,KAAKzB,MAAZ;AACD;;AAEM0B,EAAAA,SAAS,GAAW;AACzB,WAAO,KAAKxB,MAAZ;AACD;;AAEMyB,EAAAA,YAAY,GAAW;AAC5B,WAAO,KAAKjD,WAAL,GAAmB,KAAK4C,QAA/B;AACD;;AAEMM,EAAAA,cAAc,CAAC9C,aAAD,EAAgC;AACnD,QAAIA,aAAa,GAAG,CAApB,EAAuB;AACrB,aAAO,CAAP;AACD;;AAED,WAAO,KAAKsC,QAAL,GAAgB,CAAhB,GAAoB,KAAKC,WAAL,GAAmB,KAAKD,QAA5C,GAAuD,CAA9D;AACD;;AA9JuE","sourcesContent":["import { DEFAULT_TOUCH_SLOP } from '../constants';\nimport { AdaptedEvent, EventTypes } from '../interfaces';\n\nimport PointerTracker from '../tools/PointerTracker';\n\nexport interface ScaleGestureListener {\n onScaleBegin: (detector: ScaleGestureDetector) => boolean;\n onScale: (detector: ScaleGestureDetector) => boolean;\n onScaleEnd: (detector: ScaleGestureDetector) => void;\n}\n\nexport default class ScaleGestureDetector implements ScaleGestureListener {\n public onScaleBegin: (detector: ScaleGestureDetector) => boolean;\n public onScale: (detector: ScaleGestureDetector) => boolean;\n public onScaleEnd: (detector: ScaleGestureDetector) => void;\n\n private focusX!: number;\n private focusY!: number;\n\n private currentSpan!: number;\n private prevSpan!: number;\n private initialSpan!: number;\n\n private currentTime!: number;\n private prevTime!: number;\n\n private inProgress = false;\n\n private spanSlop: number;\n private minSpan: number;\n\n constructor(callbacks: ScaleGestureListener) {\n this.onScaleBegin = callbacks.onScaleBegin;\n this.onScale = callbacks.onScale;\n this.onScaleEnd = callbacks.onScaleEnd;\n\n this.spanSlop = DEFAULT_TOUCH_SLOP * 2;\n this.minSpan = 0;\n }\n\n public onTouchEvent(event: AdaptedEvent, tracker: PointerTracker): boolean {\n this.currentTime = event.time;\n\n const action: EventTypes = event.eventType;\n const numOfPointers = tracker.getTrackedPointersCount();\n\n const streamComplete: boolean =\n action === EventTypes.UP ||\n action === EventTypes.ADDITIONAL_POINTER_UP ||\n action === EventTypes.CANCEL;\n\n if (action === EventTypes.DOWN || streamComplete) {\n if (this.inProgress) {\n this.onScaleEnd(this);\n this.inProgress = false;\n this.initialSpan = 0;\n }\n\n if (streamComplete) {\n return true;\n }\n }\n\n const configChanged: boolean =\n action === EventTypes.DOWN ||\n action === EventTypes.ADDITIONAL_POINTER_UP ||\n action === EventTypes.ADDITIONAL_POINTER_DOWN;\n\n const pointerUp = action === EventTypes.ADDITIONAL_POINTER_UP;\n\n const ignoredPointer: number | undefined = pointerUp\n ? event.pointerId\n : undefined;\n\n // Determine focal point\n\n const div: number = pointerUp ? numOfPointers - 1 : numOfPointers;\n\n const coordsSum = tracker.getAbsoluteCoordsSum();\n\n const focusX = coordsSum.x / div;\n const focusY = coordsSum.y / div;\n\n // Determine average deviation from focal point\n\n let devSumX = 0;\n let devSumY = 0;\n\n tracker.getData().forEach((value, key) => {\n if (key === ignoredPointer) {\n return;\n }\n\n devSumX += Math.abs(value.abosoluteCoords.x - focusX);\n devSumY += Math.abs(value.abosoluteCoords.y - focusY);\n });\n\n const devX: number = devSumX / div;\n const devY: number = devSumY / div;\n\n const spanX: number = devX * 2;\n const spanY: number = devY * 2;\n\n const span = Math.hypot(spanX, spanY);\n\n // Begin/end events\n const wasInProgress: boolean = this.inProgress;\n this.focusX = focusX;\n this.focusY = focusY;\n\n if (this.inProgress && (span < this.minSpan || configChanged)) {\n this.onScaleEnd(this);\n this.inProgress = false;\n this.initialSpan = span;\n }\n\n if (configChanged) {\n this.initialSpan = this.prevSpan = this.currentSpan = span;\n }\n\n if (\n !this.inProgress &&\n span >= this.minSpan &&\n (wasInProgress || Math.abs(span - this.initialSpan) > this.spanSlop)\n ) {\n this.prevSpan = this.currentSpan = span;\n this.prevTime = this.currentTime;\n this.inProgress = this.onScaleBegin(this);\n }\n\n // Handle motion\n if (action !== EventTypes.MOVE) {\n return true;\n }\n\n this.currentSpan = span;\n\n if (this.inProgress && !this.onScale(this)) {\n return true;\n }\n\n this.prevSpan = this.currentSpan;\n this.prevTime = this.currentTime;\n\n return true;\n }\n\n public getCurrentSpan(): number {\n return this.currentSpan;\n }\n\n public getFocusX(): number {\n return this.focusX;\n }\n\n public getFocusY(): number {\n return this.focusY;\n }\n\n public getTimeDelta(): number {\n return this.currentTime - this.prevTime;\n }\n\n public getScaleFactor(numOfPointers: number): number {\n if (numOfPointers < 2) {\n return 1;\n }\n\n return this.prevSpan > 0 ? this.currentSpan / this.prevSpan : 1;\n }\n}\n"]}
1
+ {"version":3,"sources":["ScaleGestureDetector.ts"],"names":["DEFAULT_TOUCH_SLOP","EventTypes","ScaleGestureDetector","constructor","callbacks","onScaleBegin","onScale","onScaleEnd","spanSlop","minSpan","onTouchEvent","event","tracker","currentTime","time","action","eventType","numOfPointers","trackedPointersCount","streamComplete","UP","ADDITIONAL_POINTER_UP","CANCEL","DOWN","inProgress","initialSpan","configChanged","ADDITIONAL_POINTER_DOWN","pointerUp","ignoredPointer","pointerId","undefined","div","coordsSum","getAbsoluteCoordsSum","focusX","x","focusY","y","devSumX","devSumY","trackedPointers","forEach","value","key","Math","abs","abosoluteCoords","devX","devY","spanX","spanY","span","hypot","wasInProgress","_focusX","_focusY","prevSpan","_currentSpan","prevTime","MOVE","currentSpan","calculateScaleFactor","timeDelta"],"mappings":";;AAAA,SAASA,kBAAT,QAAmC,cAAnC;AACA,SAAuBC,UAAvB,QAAyC,eAAzC;AAUA,eAAe,MAAMC,oBAAN,CAA2D;AAoBxEC,EAAAA,WAAW,CAACC,SAAD,EAAkC;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,wCALxB,KAKwB;;AAAA;;AAAA;;AAC3C,SAAKC,YAAL,GAAoBD,SAAS,CAACC,YAA9B;AACA,SAAKC,OAAL,GAAeF,SAAS,CAACE,OAAzB;AACA,SAAKC,UAAL,GAAkBH,SA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,KAAK3C,OADb,KAEC6C,aAAa,IAAIT,IAAI,CAACC,GAAL,CAASM,IAAI,GAAG,KAAK3B,WAArB,IAAoC,KAAKjB,QAF3D,CADF,EAIE;AACA,WAAKiD,QAAL,GAAgB,KAAKC,YAAL,GAAoBN,IAApC;AACA,WAAKO,QAAL,GAAgB,KAAK9C,WAArB;AACA,WAAKW,UAAL,GAAkB,KAAKnB,YAAL,CAAkB,IAAlB,CAAlB;AACD,KAxFwE,CA0FzE;;;AACA,QAAIU,MAAM,KAAKd,UAAU,CAAC2D,IAA1B,EAAgC;AAC9B,aAAO,IAAP;AACD;;AAED,SAAKF,YAAL,GAAoBN,IAApB;;AAEA,QAAI,KAAK5B,UAAL,IAAmB,CAAC,KAAKlB,OAAL,CAAa,IAAb,CAAxB,EAA4C;AAC1C,aAAO,IAAP;AACD;;AAED,SAAKmD,QAAL,GAAgB,KAAKI,WAArB;AACA,SAAKF,QAAL,GAAgB,KAAK9C,WAArB;AAEA,WAAO,IAAP;AACD;;AAEMiD,EAAAA,oBAAoB,CAAC7C,aAAD,EAAgC;AACzD,QAAIA,aAAa,GAAG,CAApB,EAAuB;AACrB,aAAO,CAAP;AACD;;AAED,WAAO,KAAKwC,QAAL,GAAgB,CAAhB,GAAoB,KAAKI,WAAL,GAAmB,KAAKJ,QAA5C,GAAuD,CAA9D;AACD;;AAEqB,MAAXI,WAAW,GAAG;AACvB,WAAO,KAAKH,YAAZ;AACD;;AAEgB,MAANvB,MAAM,GAAG;AAClB,WAAO,KAAKoB,OAAZ;AACD;;AAEgB,MAANlB,MAAM,GAAG;AAClB,WAAO,KAAKmB,OAAZ;AACD;;AAEmB,MAATO,SAAS,GAAG;AACrB,WAAO,KAAKlD,WAAL,GAAmB,KAAK8C,QAA/B;AACD;;AA9JuE","sourcesContent":["import { DEFAULT_TOUCH_SLOP } from '../constants';\nimport { AdaptedEvent, EventTypes } from '../interfaces';\n\nimport PointerTracker from '../tools/PointerTracker';\n\nexport interface ScaleGestureListener {\n onScaleBegin: (detector: ScaleGestureDetector) => boolean;\n onScale: (detector: ScaleGestureDetector) => boolean;\n onScaleEnd: (detector: ScaleGestureDetector) => void;\n}\n\nexport default class ScaleGestureDetector implements ScaleGestureListener {\n public onScaleBegin: (detector: ScaleGestureDetector) => boolean;\n public onScale: (detector: ScaleGestureDetector) => boolean;\n public onScaleEnd: (detector: ScaleGestureDetector) => void;\n\n private _focusX!: number;\n private _focusY!: number;\n\n private _currentSpan!: number;\n private prevSpan!: number;\n private initialSpan!: number;\n\n private currentTime!: number;\n private prevTime!: number;\n\n private inProgress = false;\n\n private spanSlop: number;\n private minSpan: number;\n\n constructor(callbacks: ScaleGestureListener) {\n this.onScaleBegin = callbacks.onScaleBegin;\n this.onScale = callbacks.onScale;\n this.onScaleEnd = callbacks.onScaleEnd;\n\n this.spanSlop = DEFAULT_TOUCH_SLOP * 2;\n this.minSpan = 0;\n }\n\n public onTouchEvent(event: AdaptedEvent, tracker: PointerTracker): boolean {\n this.currentTime = event.time;\n\n const action: EventTypes = event.eventType;\n const numOfPointers = tracker.trackedPointersCount;\n\n const streamComplete: boolean =\n action === EventTypes.UP ||\n action === EventTypes.ADDITIONAL_POINTER_UP ||\n action === EventTypes.CANCEL;\n\n if (action === EventTypes.DOWN || streamComplete) {\n if (this.inProgress) {\n this.onScaleEnd(this);\n this.inProgress = false;\n this.initialSpan = 0;\n }\n\n if (streamComplete) {\n return true;\n }\n }\n\n const configChanged: boolean =\n action === EventTypes.DOWN ||\n action === EventTypes.ADDITIONAL_POINTER_UP ||\n action === EventTypes.ADDITIONAL_POINTER_DOWN;\n\n const pointerUp = action === EventTypes.ADDITIONAL_POINTER_UP;\n\n const ignoredPointer: number | undefined = pointerUp\n ? event.pointerId\n : undefined;\n\n // Determine focal point\n\n const div: number = pointerUp ? numOfPointers - 1 : numOfPointers;\n\n const coordsSum = tracker.getAbsoluteCoordsSum();\n\n const focusX = coordsSum.x / div;\n const focusY = coordsSum.y / div;\n\n // Determine average deviation from focal point\n\n let devSumX = 0;\n let devSumY = 0;\n\n tracker.trackedPointers.forEach((value, key) => {\n if (key === ignoredPointer) {\n return;\n }\n\n devSumX += Math.abs(value.abosoluteCoords.x - focusX);\n devSumY += Math.abs(value.abosoluteCoords.y - focusY);\n });\n\n const devX: number = devSumX / div;\n const devY: number = devSumY / div;\n\n const spanX: number = devX * 2;\n const spanY: number = devY * 2;\n\n const span = Math.hypot(spanX, spanY);\n\n // Begin/end events\n const wasInProgress: boolean = this.inProgress;\n this._focusX = focusX;\n this._focusY = focusY;\n\n if (this.inProgress && (span < this.minSpan || configChanged)) {\n this.onScaleEnd(this);\n this.inProgress = false;\n this.initialSpan = span;\n }\n\n if (configChanged) {\n this.initialSpan = this.prevSpan = this._currentSpan = span;\n }\n\n if (\n !this.inProgress &&\n span >= this.minSpan &&\n (wasInProgress || Math.abs(span - this.initialSpan) > this.spanSlop)\n ) {\n this.prevSpan = this._currentSpan = span;\n this.prevTime = this.currentTime;\n this.inProgress = this.onScaleBegin(this);\n }\n\n // Handle motion\n if (action !== EventTypes.MOVE) {\n return true;\n }\n\n this._currentSpan = span;\n\n if (this.inProgress && !this.onScale(this)) {\n return true;\n }\n\n this.prevSpan = this.currentSpan;\n this.prevTime = this.currentTime;\n\n return true;\n }\n\n public calculateScaleFactor(numOfPointers: number): number {\n if (numOfPointers < 2) {\n return 1;\n }\n\n return this.prevSpan > 0 ? this.currentSpan / this.prevSpan : 1;\n }\n\n public get currentSpan() {\n return this._currentSpan;\n }\n\n public get focusX() {\n return this._focusX;\n }\n\n public get focusY() {\n return this._focusY;\n }\n\n public get timeDelta() {\n return this.currentTime - this.prevTime;\n }\n}\n"]}
@@ -104,25 +104,25 @@ export default class FlingGestureHandler extends GestureHandler {
104
104
  }
105
105
 
106
106
  newPointerAction() {
107
- if (this.currentState === State.UNDETERMINED) {
107
+ if (this.state === State.UNDETERMINED) {
108
108
  this.startFling();
109
109
  }
110
110
 
111
- if (this.currentState !== State.BEGAN) {
111
+ if (this.state !== State.BEGAN) {
112
112
  return;
113
113
  }
114
114
 
115
115
  this.tryEndFling();
116
116
 
117
- if (this.tracker.getTrackedPointersCount() > this.maxNumberOfPointersSimultaneously) {
118
- this.maxNumberOfPointersSimultaneously = this.tracker.getTrackedPointersCount();
117
+ if (this.tracker.trackedPointersCount > this.maxNumberOfPointersSimultaneously) {
118
+ this.maxNumberOfPointersSimultaneously = this.tracker.trackedPointersCount;
119
119
  }
120
120
  }
121
121
 
122
122
  pointerMoveAction(event) {
123
123
  this.tracker.track(event);
124
124
 
125
- if (this.currentState !== State.BEGAN) {
125
+ if (this.state !== State.BEGAN) {
126
126
  return;
127
127
  }
128
128
 
@@ -151,7 +151,7 @@ export default class FlingGestureHandler extends GestureHandler {
151
151
  }
152
152
 
153
153
  onUp(event) {
154
- if (this.currentState === State.BEGAN) {
154
+ if (this.state === State.BEGAN) {
155
155
  this.endFling();
156
156
  }
157
157