react-native-gesture-handler 2.16.1 → 2.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (369) hide show
  1. package/README.md +9 -3
  2. package/android/build.gradle +105 -0
  3. package/android/gradle.properties +7 -0
  4. package/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +7 -7
  5. package/android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt +16 -8
  6. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +9 -5
  7. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt +4 -0
  8. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +1 -1
  9. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerTouchEvent.kt +1 -0
  10. package/apple/RNGestureHandlerButtonComponentView.mm +10 -0
  11. package/apple/RNGestureHandlerModule.mm +2 -3
  12. package/lib/commonjs/RNGestureHandlerModule.js +4 -97
  13. package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
  14. package/lib/commonjs/RNGestureHandlerModule.web.js +109 -0
  15. package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -0
  16. package/lib/commonjs/RNRenderer.js +10 -5
  17. package/lib/commonjs/RNRenderer.js.map +1 -1
  18. package/lib/commonjs/RNRenderer.web.js +11 -0
  19. package/lib/commonjs/RNRenderer.web.js.map +1 -0
  20. package/lib/commonjs/components/GestureButtons.js +27 -12
  21. package/lib/commonjs/components/GestureButtons.js.map +1 -1
  22. package/lib/commonjs/components/GestureComponents.js +82 -19
  23. package/lib/commonjs/components/GestureComponents.js.map +1 -1
  24. package/lib/commonjs/components/GestureComponents.web.js +52 -0
  25. package/lib/commonjs/components/GestureComponents.web.js.map +1 -0
  26. package/lib/commonjs/components/GestureHandlerButton.js +3 -13
  27. package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
  28. package/lib/commonjs/components/GestureHandlerButton.web.js +24 -0
  29. package/lib/commonjs/components/GestureHandlerButton.web.js.map +1 -0
  30. package/lib/commonjs/components/GestureHandlerRootView.js +6 -0
  31. package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -1
  32. package/lib/commonjs/components/{GestureHandlerRootView.native.js → GestureHandlerRootView.web.js} +1 -7
  33. package/lib/commonjs/components/GestureHandlerRootView.web.js.map +1 -0
  34. package/lib/commonjs/getReactNativeVersion.js +12 -1
  35. package/lib/commonjs/getReactNativeVersion.js.map +1 -1
  36. package/lib/commonjs/getReactNativeVersion.web.js +11 -0
  37. package/lib/commonjs/getReactNativeVersion.web.js.map +1 -0
  38. package/lib/commonjs/getShadowNodeFromRef.js +34 -5
  39. package/lib/commonjs/getShadowNodeFromRef.js.map +1 -1
  40. package/lib/commonjs/getShadowNodeFromRef.web.js +15 -0
  41. package/lib/commonjs/getShadowNodeFromRef.web.js.map +1 -0
  42. package/lib/commonjs/handlers/PressabilityDebugView.js +7 -5
  43. package/lib/commonjs/handlers/PressabilityDebugView.js.map +1 -1
  44. package/lib/commonjs/handlers/PressabilityDebugView.web.js +12 -0
  45. package/lib/commonjs/handlers/PressabilityDebugView.web.js.map +1 -0
  46. package/lib/commonjs/handlers/createHandler.js +1 -3
  47. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  48. package/lib/commonjs/handlers/customDirectEventTypes.js +8 -5
  49. package/lib/commonjs/handlers/customDirectEventTypes.js.map +1 -1
  50. package/lib/commonjs/handlers/customDirectEventTypes.web.js +11 -0
  51. package/lib/commonjs/handlers/customDirectEventTypes.web.js.map +1 -0
  52. package/lib/commonjs/handlers/gestureHandlerCommon.js +3 -3
  53. package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
  54. package/lib/commonjs/handlers/gestures/GestureDetector/Wrap.js +42 -0
  55. package/lib/commonjs/handlers/gestures/GestureDetector/Wrap.js.map +1 -0
  56. package/lib/commonjs/handlers/gestures/GestureDetector/attachHandlers.js +83 -0
  57. package/lib/commonjs/handlers/gestures/GestureDetector/attachHandlers.js.map +1 -0
  58. package/lib/commonjs/handlers/gestures/GestureDetector/dropHandlers.js +25 -0
  59. package/lib/commonjs/handlers/gestures/GestureDetector/dropHandlers.js.map +1 -0
  60. package/lib/commonjs/handlers/gestures/GestureDetector/index.js +143 -0
  61. package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -0
  62. package/lib/commonjs/handlers/gestures/GestureDetector/needsToReattach.js +25 -0
  63. package/lib/commonjs/handlers/gestures/GestureDetector/needsToReattach.js.map +1 -0
  64. package/lib/commonjs/handlers/gestures/GestureDetector/types.js +6 -0
  65. package/lib/commonjs/handlers/gestures/GestureDetector/types.js.map +1 -0
  66. package/lib/commonjs/handlers/gestures/GestureDetector/updateHandlers.js +80 -0
  67. package/lib/commonjs/handlers/gestures/GestureDetector/updateHandlers.js.map +1 -0
  68. package/lib/commonjs/handlers/gestures/GestureDetector/useAnimatedGesture.js +180 -0
  69. package/lib/commonjs/handlers/gestures/GestureDetector/useAnimatedGesture.js.map +1 -0
  70. package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js +55 -0
  71. package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -0
  72. package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js +47 -0
  73. package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -0
  74. package/lib/commonjs/handlers/gestures/GestureDetector/utils.js +176 -0
  75. package/lib/commonjs/handlers/gestures/GestureDetector/utils.js.map +1 -0
  76. package/lib/commonjs/handlers/gestures/gestureComposition.js +3 -1
  77. package/lib/commonjs/handlers/gestures/gestureComposition.js.map +1 -1
  78. package/lib/commonjs/handlers/gestures/gestureStateManager.js +8 -0
  79. package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -1
  80. package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -1
  81. package/lib/commonjs/utils.js +36 -0
  82. package/lib/commonjs/utils.js.map +1 -1
  83. package/lib/commonjs/web/detectors/RotationGestureDetector.js +6 -8
  84. package/lib/commonjs/web/detectors/RotationGestureDetector.js.map +1 -1
  85. package/lib/commonjs/web/detectors/ScaleGestureDetector.js +5 -6
  86. package/lib/commonjs/web/detectors/ScaleGestureDetector.js.map +1 -1
  87. package/lib/commonjs/web/handlers/FlingGestureHandler.js +1 -0
  88. package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
  89. package/lib/commonjs/web/handlers/GestureHandler.js +56 -64
  90. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  91. package/lib/commonjs/web/handlers/LongPressGestureHandler.js +1 -0
  92. package/lib/commonjs/web/handlers/LongPressGestureHandler.js.map +1 -1
  93. package/lib/commonjs/web/handlers/ManualGestureHandler.js +1 -0
  94. package/lib/commonjs/web/handlers/ManualGestureHandler.js.map +1 -1
  95. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +7 -4
  96. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
  97. package/lib/commonjs/web/handlers/PanGestureHandler.js +28 -18
  98. package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
  99. package/lib/commonjs/web/handlers/PinchGestureHandler.js +1 -0
  100. package/lib/commonjs/web/handlers/PinchGestureHandler.js.map +1 -1
  101. package/lib/commonjs/web/handlers/RotationGestureHandler.js +1 -0
  102. package/lib/commonjs/web/handlers/RotationGestureHandler.js.map +1 -1
  103. package/lib/commonjs/web/handlers/TapGestureHandler.js +18 -12
  104. package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
  105. package/lib/commonjs/web/interfaces.js.map +1 -1
  106. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +1 -6
  107. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  108. package/lib/commonjs/web/tools/PointerEventManager.js +7 -2
  109. package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
  110. package/lib/commonjs/web/tools/PointerTracker.js +89 -57
  111. package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
  112. package/lib/commonjs/web/tools/TouchEventManager.js +6 -2
  113. package/lib/commonjs/web/tools/TouchEventManager.js.map +1 -1
  114. package/lib/commonjs/web/tools/Vector.js +2 -1
  115. package/lib/commonjs/web/tools/Vector.js.map +1 -1
  116. package/lib/commonjs/web/utils.js +31 -0
  117. package/lib/commonjs/web/utils.js.map +1 -1
  118. package/lib/module/RNGestureHandlerModule.js +4 -84
  119. package/lib/module/RNGestureHandlerModule.js.map +1 -1
  120. package/lib/module/RNGestureHandlerModule.web.js +85 -0
  121. package/lib/module/RNGestureHandlerModule.web.js.map +1 -0
  122. package/lib/module/RNRenderer.js +3 -3
  123. package/lib/module/RNRenderer.js.map +1 -1
  124. package/lib/module/RNRenderer.web.js +4 -0
  125. package/lib/module/RNRenderer.web.js.map +1 -0
  126. package/lib/module/components/GestureButtons.js +24 -6
  127. package/lib/module/components/GestureButtons.js.map +1 -1
  128. package/lib/module/components/GestureComponents.js +80 -18
  129. package/lib/module/components/GestureComponents.js.map +1 -1
  130. package/lib/module/components/GestureComponents.web.js +28 -0
  131. package/lib/module/components/GestureComponents.web.js.map +1 -0
  132. package/lib/module/components/GestureHandlerButton.js +2 -8
  133. package/lib/module/components/GestureHandlerButton.js.map +1 -1
  134. package/lib/module/components/GestureHandlerButton.web.js +9 -0
  135. package/lib/module/components/GestureHandlerButton.web.js.map +1 -0
  136. package/lib/module/components/GestureHandlerRootView.js +5 -0
  137. package/lib/module/components/GestureHandlerRootView.js.map +1 -1
  138. package/lib/module/components/{GestureHandlerRootView.native.js → GestureHandlerRootView.web.js} +1 -6
  139. package/lib/module/components/GestureHandlerRootView.web.js.map +1 -0
  140. package/lib/module/getReactNativeVersion.js +7 -1
  141. package/lib/module/getReactNativeVersion.js.map +1 -1
  142. package/lib/module/getReactNativeVersion.web.js +4 -0
  143. package/lib/module/getReactNativeVersion.web.js.map +1 -0
  144. package/lib/module/getShadowNodeFromRef.js +33 -4
  145. package/lib/module/getShadowNodeFromRef.js.map +1 -1
  146. package/lib/module/getShadowNodeFromRef.web.js +8 -0
  147. package/lib/module/getShadowNodeFromRef.web.js.map +1 -0
  148. package/lib/module/handlers/PressabilityDebugView.js +2 -4
  149. package/lib/module/handlers/PressabilityDebugView.js.map +1 -1
  150. package/lib/module/handlers/PressabilityDebugView.web.js +5 -0
  151. package/lib/module/handlers/PressabilityDebugView.web.js.map +1 -0
  152. package/lib/module/handlers/createHandler.js +2 -4
  153. package/lib/module/handlers/createHandler.js.map +1 -1
  154. package/lib/module/handlers/customDirectEventTypes.js +2 -4
  155. package/lib/module/handlers/customDirectEventTypes.js.map +1 -1
  156. package/lib/module/handlers/customDirectEventTypes.web.js +5 -0
  157. package/lib/module/handlers/customDirectEventTypes.web.js.map +1 -0
  158. package/lib/module/handlers/gestureHandlerCommon.js +1 -1
  159. package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
  160. package/lib/module/handlers/gestures/GestureDetector/Wrap.js +26 -0
  161. package/lib/module/handlers/gestures/GestureDetector/Wrap.js.map +1 -0
  162. package/lib/module/handlers/gestures/GestureDetector/attachHandlers.js +65 -0
  163. package/lib/module/handlers/gestures/GestureDetector/attachHandlers.js.map +1 -0
  164. package/lib/module/handlers/gestures/GestureDetector/dropHandlers.js +12 -0
  165. package/lib/module/handlers/gestures/GestureDetector/dropHandlers.js.map +1 -0
  166. package/lib/module/handlers/gestures/GestureDetector/index.js +115 -0
  167. package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -0
  168. package/lib/module/handlers/gestures/GestureDetector/needsToReattach.js +18 -0
  169. package/lib/module/handlers/gestures/GestureDetector/needsToReattach.js.map +1 -0
  170. package/lib/module/handlers/gestures/GestureDetector/types.js +2 -0
  171. package/lib/module/handlers/gestures/GestureDetector/types.js.map +1 -0
  172. package/lib/module/handlers/gestures/GestureDetector/updateHandlers.js +64 -0
  173. package/lib/module/handlers/gestures/GestureDetector/updateHandlers.js.map +1 -0
  174. package/lib/module/handlers/gestures/GestureDetector/useAnimatedGesture.js +165 -0
  175. package/lib/module/handlers/gestures/GestureDetector/useAnimatedGesture.js.map +1 -0
  176. package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js +41 -0
  177. package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -0
  178. package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js +36 -0
  179. package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -0
  180. package/lib/module/handlers/gestures/GestureDetector/utils.js +142 -0
  181. package/lib/module/handlers/gestures/GestureDetector/utils.js.map +1 -0
  182. package/lib/module/handlers/gestures/gestureComposition.js +3 -1
  183. package/lib/module/handlers/gestures/gestureComposition.js.map +1 -1
  184. package/lib/module/handlers/gestures/gestureStateManager.js +8 -0
  185. package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -1
  186. package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -1
  187. package/lib/module/utils.js +34 -0
  188. package/lib/module/utils.js.map +1 -1
  189. package/lib/module/web/detectors/RotationGestureDetector.js +6 -8
  190. package/lib/module/web/detectors/RotationGestureDetector.js.map +1 -1
  191. package/lib/module/web/detectors/ScaleGestureDetector.js +5 -6
  192. package/lib/module/web/detectors/ScaleGestureDetector.js.map +1 -1
  193. package/lib/module/web/handlers/FlingGestureHandler.js +1 -0
  194. package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
  195. package/lib/module/web/handlers/GestureHandler.js +56 -64
  196. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  197. package/lib/module/web/handlers/LongPressGestureHandler.js +1 -0
  198. package/lib/module/web/handlers/LongPressGestureHandler.js.map +1 -1
  199. package/lib/module/web/handlers/ManualGestureHandler.js +1 -0
  200. package/lib/module/web/handlers/ManualGestureHandler.js.map +1 -1
  201. package/lib/module/web/handlers/NativeViewGestureHandler.js +7 -4
  202. package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
  203. package/lib/module/web/handlers/PanGestureHandler.js +28 -18
  204. package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
  205. package/lib/module/web/handlers/PinchGestureHandler.js +1 -0
  206. package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -1
  207. package/lib/module/web/handlers/RotationGestureHandler.js +1 -0
  208. package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -1
  209. package/lib/module/web/handlers/TapGestureHandler.js +18 -12
  210. package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
  211. package/lib/module/web/interfaces.js.map +1 -1
  212. package/lib/module/web/tools/GestureHandlerOrchestrator.js +1 -6
  213. package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  214. package/lib/module/web/tools/PointerEventManager.js +8 -3
  215. package/lib/module/web/tools/PointerEventManager.js.map +1 -1
  216. package/lib/module/web/tools/PointerTracker.js +89 -57
  217. package/lib/module/web/tools/PointerTracker.js.map +1 -1
  218. package/lib/module/web/tools/TouchEventManager.js +7 -3
  219. package/lib/module/web/tools/TouchEventManager.js.map +1 -1
  220. package/lib/module/web/tools/Vector.js +2 -1
  221. package/lib/module/web/tools/Vector.js.map +1 -1
  222. package/lib/module/web/utils.js +29 -0
  223. package/lib/module/web/utils.js.map +1 -1
  224. package/lib/typescript/RNGestureHandlerModule.d.ts +2 -15
  225. package/lib/typescript/RNGestureHandlerModule.web.d.ts +15 -0
  226. package/lib/typescript/RNRenderer.d.ts +1 -3
  227. package/lib/typescript/RNRenderer.web.d.ts +3 -0
  228. package/lib/typescript/components/GestureButtons.d.ts +3 -34
  229. package/lib/typescript/components/GestureComponents.d.ts +21 -7
  230. package/lib/typescript/components/GestureComponents.web.d.ts +8 -0
  231. package/lib/typescript/components/GestureHandlerButton.d.ts +3 -3
  232. package/lib/typescript/components/GestureHandlerButton.web.d.ts +4 -0
  233. package/lib/typescript/getReactNativeVersion.d.ts +4 -1
  234. package/lib/typescript/getReactNativeVersion.web.d.ts +1 -0
  235. package/lib/typescript/getShadowNodeFromRef.d.ts +1 -1
  236. package/lib/typescript/getShadowNodeFromRef.web.d.ts +1 -0
  237. package/lib/typescript/handlers/PressabilityDebugView.d.ts +1 -1
  238. package/lib/typescript/handlers/PressabilityDebugView.web.d.ts +1 -0
  239. package/lib/typescript/handlers/customDirectEventTypes.d.ts +1 -2
  240. package/lib/typescript/handlers/customDirectEventTypes.web.d.ts +2 -0
  241. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +3 -2
  242. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.d.ts +13 -0
  243. package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.d.ts +13 -0
  244. package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.d.ts +2 -0
  245. package/lib/typescript/handlers/gestures/{GestureDetector.d.ts → GestureDetector/index.d.ts} +4 -12
  246. package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.d.ts +3 -0
  247. package/lib/typescript/handlers/gestures/GestureDetector/types.d.ts +20 -0
  248. package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.d.ts +4 -0
  249. package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.d.ts +2 -0
  250. package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.d.ts +5 -0
  251. package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.d.ts +3 -0
  252. package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +12 -0
  253. package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +1 -1
  254. package/lib/typescript/utils.d.ts +10 -0
  255. package/lib/typescript/web/handlers/GestureHandler.d.ts +1 -0
  256. package/lib/typescript/web/interfaces.d.ts +1 -0
  257. package/lib/typescript/web/tools/PointerTracker.d.ts +34 -31
  258. package/lib/typescript/web/utils.d.ts +4 -0
  259. package/package.json +5 -5
  260. package/src/RNGestureHandlerModule.ts +4 -104
  261. package/src/RNGestureHandlerModule.web.ts +105 -0
  262. package/src/RNRenderer.ts +3 -3
  263. package/src/RNRenderer.web.ts +3 -0
  264. package/src/components/GestureButtons.tsx +36 -4
  265. package/src/components/GestureComponents.tsx +131 -24
  266. package/src/components/GestureComponents.web.tsx +41 -0
  267. package/src/components/GestureHandlerButton.tsx +4 -5
  268. package/src/components/GestureHandlerButton.web.tsx +6 -0
  269. package/src/components/GestureHandlerRootView.tsx +6 -0
  270. package/src/components/{GestureHandlerRootView.native.tsx → GestureHandlerRootView.web.tsx} +0 -6
  271. package/src/getReactNativeVersion.ts +9 -1
  272. package/src/getReactNativeVersion.web.ts +3 -0
  273. package/src/getShadowNodeFromRef.ts +41 -4
  274. package/src/getShadowNodeFromRef.web.ts +7 -0
  275. package/src/handlers/PressabilityDebugView.tsx +2 -4
  276. package/src/handlers/PressabilityDebugView.web.tsx +4 -0
  277. package/src/handlers/createHandler.tsx +1 -3
  278. package/src/handlers/customDirectEventTypes.ts +2 -5
  279. package/src/handlers/customDirectEventTypes.web.ts +5 -0
  280. package/src/handlers/gestureHandlerCommon.ts +4 -1
  281. package/src/handlers/gestures/GestureDetector/Wrap.tsx +35 -0
  282. package/src/handlers/gestures/GestureDetector/attachHandlers.ts +112 -0
  283. package/src/handlers/gestures/GestureDetector/dropHandlers.ts +14 -0
  284. package/src/handlers/gestures/GestureDetector/index.tsx +187 -0
  285. package/src/handlers/gestures/GestureDetector/needsToReattach.ts +27 -0
  286. package/src/handlers/gestures/GestureDetector/types.ts +32 -0
  287. package/src/handlers/gestures/GestureDetector/updateHandlers.ts +94 -0
  288. package/src/handlers/gestures/GestureDetector/useAnimatedGesture.ts +206 -0
  289. package/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts +69 -0
  290. package/src/handlers/gestures/GestureDetector/useViewRefHandler.ts +54 -0
  291. package/src/handlers/gestures/GestureDetector/utils.ts +185 -0
  292. package/src/handlers/gestures/gestureComposition.ts +2 -0
  293. package/src/handlers/gestures/gestureStateManager.ts +12 -4
  294. package/src/handlers/gestures/reanimatedWrapper.ts +19 -17
  295. package/src/utils.ts +39 -0
  296. package/src/web/detectors/RotationGestureDetector.ts +6 -8
  297. package/src/web/detectors/ScaleGestureDetector.ts +5 -6
  298. package/src/web/handlers/FlingGestureHandler.ts +2 -0
  299. package/src/web/handlers/GestureHandler.ts +53 -62
  300. package/src/web/handlers/LongPressGestureHandler.ts +2 -0
  301. package/src/web/handlers/ManualGestureHandler.ts +2 -0
  302. package/src/web/handlers/NativeViewGestureHandler.ts +8 -4
  303. package/src/web/handlers/PanGestureHandler.ts +32 -19
  304. package/src/web/handlers/PinchGestureHandler.ts +2 -0
  305. package/src/web/handlers/RotationGestureHandler.ts +2 -0
  306. package/src/web/handlers/TapGestureHandler.ts +20 -12
  307. package/src/web/interfaces.ts +1 -0
  308. package/src/web/tools/GestureHandlerOrchestrator.ts +1 -7
  309. package/src/web/tools/PointerEventManager.ts +10 -3
  310. package/src/web/tools/PointerTracker.ts +81 -74
  311. package/src/web/tools/TouchEventManager.ts +5 -3
  312. package/src/web/tools/Vector.ts +2 -4
  313. package/src/web/utils.ts +34 -0
  314. package/lib/commonjs/RNGestureHandlerModule.native.js +0 -16
  315. package/lib/commonjs/RNGestureHandlerModule.native.js.map +0 -1
  316. package/lib/commonjs/RNRenderer.native.js +0 -16
  317. package/lib/commonjs/RNRenderer.native.js.map +0 -1
  318. package/lib/commonjs/components/GestureComponents.native.js +0 -115
  319. package/lib/commonjs/components/GestureComponents.native.js.map +0 -1
  320. package/lib/commonjs/components/GestureHandlerButton.native.js +0 -14
  321. package/lib/commonjs/components/GestureHandlerButton.native.js.map +0 -1
  322. package/lib/commonjs/components/GestureHandlerRootView.native.js.map +0 -1
  323. package/lib/commonjs/getReactNativeVersion.native.js +0 -22
  324. package/lib/commonjs/getReactNativeVersion.native.js.map +0 -1
  325. package/lib/commonjs/getShadowNodeFromRef.native.js +0 -44
  326. package/lib/commonjs/getShadowNodeFromRef.native.js.map +0 -1
  327. package/lib/commonjs/handlers/PressabilityDebugView.native.js +0 -14
  328. package/lib/commonjs/handlers/PressabilityDebugView.native.js.map +0 -1
  329. package/lib/commonjs/handlers/customDirectEventTypes.native.js +0 -14
  330. package/lib/commonjs/handlers/customDirectEventTypes.native.js.map +0 -1
  331. package/lib/commonjs/handlers/gestures/GestureDetector.js +0 -704
  332. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +0 -1
  333. package/lib/module/RNGestureHandlerModule.native.js +0 -5
  334. package/lib/module/RNGestureHandlerModule.native.js.map +0 -1
  335. package/lib/module/RNRenderer.native.js +0 -4
  336. package/lib/module/RNRenderer.native.js.map +0 -1
  337. package/lib/module/components/GestureComponents.native.js +0 -90
  338. package/lib/module/components/GestureComponents.native.js.map +0 -1
  339. package/lib/module/components/GestureHandlerButton.native.js +0 -3
  340. package/lib/module/components/GestureHandlerButton.native.js.map +0 -1
  341. package/lib/module/components/GestureHandlerRootView.native.js.map +0 -1
  342. package/lib/module/getReactNativeVersion.native.js +0 -10
  343. package/lib/module/getReactNativeVersion.native.js.map +0 -1
  344. package/lib/module/getShadowNodeFromRef.native.js +0 -37
  345. package/lib/module/getShadowNodeFromRef.native.js.map +0 -1
  346. package/lib/module/handlers/PressabilityDebugView.native.js +0 -3
  347. package/lib/module/handlers/PressabilityDebugView.native.js.map +0 -1
  348. package/lib/module/handlers/customDirectEventTypes.native.js +0 -3
  349. package/lib/module/handlers/customDirectEventTypes.native.js.map +0 -1
  350. package/lib/module/handlers/gestures/GestureDetector.js +0 -654
  351. package/lib/module/handlers/gestures/GestureDetector.js.map +0 -1
  352. package/lib/typescript/RNGestureHandlerModule.native.d.ts +0 -2
  353. package/lib/typescript/RNRenderer.native.d.ts +0 -1
  354. package/lib/typescript/components/GestureComponents.native.d.ts +0 -22
  355. package/lib/typescript/components/GestureHandlerButton.native.d.ts +0 -4
  356. package/lib/typescript/getReactNativeVersion.native.d.ts +0 -4
  357. package/lib/typescript/getShadowNodeFromRef.native.d.ts +0 -1
  358. package/lib/typescript/handlers/PressabilityDebugView.native.d.ts +0 -1
  359. package/lib/typescript/handlers/customDirectEventTypes.native.d.ts +0 -1
  360. package/src/RNGestureHandlerModule.native.ts +0 -5
  361. package/src/RNRenderer.native.ts +0 -3
  362. package/src/components/GestureComponents.native.tsx +0 -148
  363. package/src/components/GestureHandlerButton.native.tsx +0 -5
  364. package/src/getReactNativeVersion.native.ts +0 -11
  365. package/src/getShadowNodeFromRef.native.ts +0 -44
  366. package/src/handlers/PressabilityDebugView.native.tsx +0 -2
  367. package/src/handlers/customDirectEventTypes.native.ts +0 -2
  368. package/src/handlers/gestures/GestureDetector.tsx +0 -894
  369. /package/lib/typescript/components/{GestureHandlerRootView.native.d.ts → GestureHandlerRootView.web.d.ts} +0 -0
@@ -4,12 +4,41 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getShadowNodeFromRef = getShadowNodeFromRef;
7
-
8
7
  // Used by GestureDetector (unsupported on web at the moment) to check whether the
9
- // attached view may get flattened on Fabric. Original implementation causes errors
8
+ // attached view may get flattened on Fabric. This implementation causes errors
10
9
  // on web due to the static resolution of `require` statements by webpack breaking
11
- // the conditional importing.
12
- function getShadowNodeFromRef(_ref) {
13
- return null;
10
+ // the conditional importing. Solved by making .web file.
11
+ let findHostInstance_DEPRECATED;
12
+ let getInternalInstanceHandleFromPublicInstance;
13
+
14
+ function getShadowNodeFromRef(ref) {
15
+ // load findHostInstance_DEPRECATED lazily because it may not be available before render
16
+ if (findHostInstance_DEPRECATED === undefined) {
17
+ try {
18
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
19
+ findHostInstance_DEPRECATED = // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access
20
+ require('react-native/Libraries/Renderer/shims/ReactFabric').findHostInstance_DEPRECATED;
21
+ } catch (e) {
22
+ findHostInstance_DEPRECATED = _ref => null;
23
+ }
24
+ } // load findHostInstance_DEPRECATED lazily because it may not be available before render
25
+
26
+
27
+ if (getInternalInstanceHandleFromPublicInstance === undefined) {
28
+ try {
29
+ var _require$getInternalI;
30
+
31
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
32
+ getInternalInstanceHandleFromPublicInstance = // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access
33
+ (_require$getInternalI = require('react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance').getInternalInstanceHandleFromPublicInstance) !== null && _require$getInternalI !== void 0 ? _require$getInternalI : // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
34
+ ref => ref._internalInstanceHandle;
35
+ } catch (e) {
36
+ getInternalInstanceHandleFromPublicInstance = ref => // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
37
+ ref._internalInstanceHandle;
38
+ }
39
+ } // @ts-ignore Fabric
40
+
41
+
42
+ return getInternalInstanceHandleFromPublicInstance(findHostInstance_DEPRECATED(ref)).stateNode.node;
14
43
  }
15
44
  //# sourceMappingURL=getShadowNodeFromRef.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["getShadowNodeFromRef.ts"],"names":["getShadowNodeFromRef","_ref"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACO,SAASA,oBAAT,CAA8BC,IAA9B,EAAyC;AAC9C,SAAO,IAAP;AACD","sourcesContent":["// Used by GestureDetector (unsupported on web at the moment) to check whether the\n// attached view may get flattened on Fabric. Original implementation causes errors\n// on web due to the static resolution of `require` statements by webpack breaking\n// the conditional importing.\nexport function getShadowNodeFromRef(_ref: any) {\n return null;\n}\n"]}
1
+ {"version":3,"sources":["getShadowNodeFromRef.ts"],"names":["findHostInstance_DEPRECATED","getInternalInstanceHandleFromPublicInstance","getShadowNodeFromRef","ref","undefined","require","e","_ref","_internalInstanceHandle","stateNode","node"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA,IAAIA,2BAAJ;AACA,IAAIC,2CAAJ;;AAIO,SAASC,oBAAT,CAA8BC,GAA9B,EAA4C;AACjD;AACA,MAAIH,2BAA2B,KAAKI,SAApC,EAA+C;AAC7C,QAAI;AACF;AACAJ,MAAAA,2BAA2B,GACzB;AACAK,MAAAA,OAAO,CAAC,mDAAD,CAAP,CAA6DL,2BAF/D;AAGD,KALD,CAKE,OAAOM,CAAP,EAAU;AACVN,MAAAA,2BAA2B,GAAIO,IAAD,IAAmB,IAAjD;AACD;AACF,GAXgD,CAajD;;;AACA,MAAIN,2CAA2C,KAAKG,SAApD,EAA+D;AAC7D,QAAI;AAAA;;AACF;AACAH,MAAAA,2CAA2C,GACzC;AADyC,+BAEzCI,OAAO,CAAC,wFAAD,CAAP,CACGJ,2CAHsC,yEAIzC;AACEE,MAAAA,GAAD,IAAcA,GAAG,CAACK,uBALrB;AAMD,KARD,CAQE,OAAOF,CAAP,EAAU;AACVL,MAAAA,2CAA2C,GAAIE,GAAD,IAC5C;AACAA,MAAAA,GAAG,CAACK,uBAFN;AAGD;AACF,GA5BgD,CA8BjD;;;AACA,SAAOP,2CAA2C,CAChDD,2BAA2B,CAACG,GAAD,CADqB,CAA3C,CAELM,SAFK,CAEKC,IAFZ;AAGD","sourcesContent":["// Used by GestureDetector (unsupported on web at the moment) to check whether the\n// attached view may get flattened on Fabric. This implementation causes errors\n// on web due to the static resolution of `require` statements by webpack breaking\n// the conditional importing. Solved by making .web file.\nlet findHostInstance_DEPRECATED: (ref: unknown) => void;\nlet getInternalInstanceHandleFromPublicInstance: (ref: unknown) => {\n stateNode: { node: unknown };\n};\n\nexport function getShadowNodeFromRef(ref: unknown) {\n // load findHostInstance_DEPRECATED lazily because it may not be available before render\n if (findHostInstance_DEPRECATED === undefined) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n findHostInstance_DEPRECATED =\n // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access\n require('react-native/Libraries/Renderer/shims/ReactFabric').findHostInstance_DEPRECATED;\n } catch (e) {\n findHostInstance_DEPRECATED = (_ref: unknown) => null;\n }\n }\n\n // load findHostInstance_DEPRECATED lazily because it may not be available before render\n if (getInternalInstanceHandleFromPublicInstance === undefined) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n getInternalInstanceHandleFromPublicInstance =\n // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access\n require('react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance')\n .getInternalInstanceHandleFromPublicInstance ??\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return\n ((ref: any) => ref._internalInstanceHandle);\n } catch (e) {\n getInternalInstanceHandleFromPublicInstance = (ref: any) =>\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return\n ref._internalInstanceHandle;\n }\n }\n\n // @ts-ignore Fabric\n return getInternalInstanceHandleFromPublicInstance(\n findHostInstance_DEPRECATED(ref)\n ).stateNode.node;\n}\n"]}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getShadowNodeFromRef = getShadowNodeFromRef;
7
+
8
+ // Used by GestureDetector (unsupported on web at the moment) to check whether the
9
+ // attached view may get flattened on Fabric. Original implementation causes errors
10
+ // on web due to the static resolution of `require` statements by webpack breaking
11
+ // the conditional importing.
12
+ function getShadowNodeFromRef(_ref) {
13
+ return null;
14
+ }
15
+ //# sourceMappingURL=getShadowNodeFromRef.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["getShadowNodeFromRef.web.ts"],"names":["getShadowNodeFromRef","_ref"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACO,SAASA,oBAAT,CAA8BC,IAA9B,EAAyC;AAC9C,SAAO,IAAP;AACD","sourcesContent":["// Used by GestureDetector (unsupported on web at the moment) to check whether the\n// attached view may get flattened on Fabric. Original implementation causes errors\n// on web due to the static resolution of `require` statements by webpack breaking\n// the conditional importing.\nexport function getShadowNodeFromRef(_ref: any) {\n return null;\n}\n"]}
@@ -3,10 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.PressabilityDebugView = PressabilityDebugView;
6
+ Object.defineProperty(exports, "PressabilityDebugView", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _PressabilityDebug.PressabilityDebugView;
10
+ }
11
+ });
7
12
 
8
- // PressabilityDebugView is not implemented in react-native-web
9
- function PressabilityDebugView() {
10
- return null;
11
- }
13
+ var _PressabilityDebug = require("react-native/Libraries/Pressability/PressabilityDebug");
12
14
  //# sourceMappingURL=PressabilityDebugView.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["PressabilityDebugView.tsx"],"names":["PressabilityDebugView"],"mappings":";;;;;;;AAAA;AACO,SAASA,qBAAT,GAAiC;AACtC,SAAO,IAAP;AACD","sourcesContent":["// PressabilityDebugView is not implemented in react-native-web\nexport function PressabilityDebugView() {\n return null;\n}\n"]}
1
+ {"version":3,"sources":["PressabilityDebugView.tsx"],"names":[],"mappings":";;;;;;;;;;;;AACA","sourcesContent":["// @ts-ignore it's not exported so we need to import it from path\nexport { PressabilityDebugView } from 'react-native/Libraries/Pressability/PressabilityDebug';\n"]}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PressabilityDebugView = PressabilityDebugView;
7
+
8
+ // PressabilityDebugView is not implemented in react-native-web
9
+ function PressabilityDebugView() {
10
+ return null;
11
+ }
12
+ //# sourceMappingURL=PressabilityDebugView.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["PressabilityDebugView.web.tsx"],"names":["PressabilityDebugView"],"mappings":";;;;;;;AAAA;AACO,SAASA,qBAAT,GAAiC;AACtC,SAAO,IAAP;AACD","sourcesContent":["// PressabilityDebugView is not implemented in react-native-web\nexport function PressabilityDebugView() {\n return null;\n}\n"]}
@@ -11,8 +11,6 @@ var _reactNative = require("react-native");
11
11
 
12
12
  var _customDirectEventTypes = require("./customDirectEventTypes");
13
13
 
14
- var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
15
-
16
14
  var _RNGestureHandlerModule = _interopRequireDefault(require("../RNGestureHandlerModule"));
17
15
 
18
16
  var _State = require("../State");
@@ -363,7 +361,7 @@ function createHandler({
363
361
  } else {
364
362
  const newConfig = (0, _gestureHandlerCommon.filterConfig)(transformProps ? transformProps(this.props) : this.props, [...allowedProps, ...customNativeProps], config);
365
363
 
366
- if (!(0, _isEqual.default)(this.config, newConfig)) {
364
+ if (!(0, _utils.deepEqual)(this.config, newConfig)) {
367
365
  this.updateGestureHandler(newConfig);
368
366
  }
369
367
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["createHandler.tsx"],"names":["UIManagerAny","UIManager","customDirectEventTypes","topGestureHandlerEvent","registrationName","customGHEventsConfigFabricAndroid","topOnGestureHandlerEvent","topOnGestureHandlerStateChange","customGHEventsConfig","onGestureHandlerEvent","onGestureHandlerStateChange","Platform","OS","genericDirectEventTypes","UIManagerConstants","getViewManagerConfig","getConstants","setJSResponder","oldSetJSResponder","clearJSResponder","oldClearJSResponder","tag","blockNativeResponder","RNGestureHandlerModule","handleSetJSResponder","handleClearJSResponder","allowTouches","DEV_ON_ANDROID","__DEV__","DeviceEventEmitter","addListener","hasUnresolvedRefs","props","extract","refs","Array","isArray","current","some","r","stateToPropMappings","State","UNDETERMINED","undefined","BEGAN","FAILED","CANCELLED","ACTIVE","END","UNRESOLVED_REFS_RETRY_LIMIT","createHandler","name","allowedProps","config","transformProps","customNativeProps","Handler","React","Component","constructor","event","nativeEvent","handlerTag","onGestureEvent","onHandlerStateChange","state","stateEventName","eventHandler","node","viewNode","child","Children","only","children","ref","newConfig","createGestureHandler","newViewTag","viewTag","attachGestureHandler","ActionType","JS_FUNCTION_OLD_API","propsRef","onGestureStateChange","actionType","isGestureHandlerWorklet","isStateChangeHandlerWorklet","isReanimatedHandler","REANIMATED_WORKLET","NATIVE_ANIMATED_EVENT","updateGestureHandler","createRef","isMountedRef","id","handlerIDToTag","Error","componentDidMount","inspectorToggleListener","setState","_","update","componentDidUpdate","componentWillUnmount","remove","dropGestureHandler","handlerID","remainingTries","setNativeProps","updates","mergedProps","render","context","gestureEventHandler","gestureStateEventHandler","events","e","grandChildren","type","displayName","toArray","push","hitSlop","cloneElement","refHandler","collapsable","handlerType","testID","GestureHandlerRootViewContext"],"mappings":";;;;;;;AAAA;;AACA;;AAMA;;AAEA;;AACA;;AACA;;AACA;;AAMA;;AASA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;AAEA,MAAMA,YAAY,GAAGC,sBAArB;AAEAC,+CAAuBC,sBAAvB,GAAgD;AAC9CC,EAAAA,gBAAgB,EAAE;AAD4B,CAAhD;AAIA,MAAMC,iCAAiC,GAAG;AACxCC,EAAAA,wBAAwB,EAAE;AAAEF,IAAAA,gBAAgB,EAAE;AAApB,GADc;AAExCG,EAAAA,8BAA8B,EAAE;AAC9BH,IAAAA,gBAAgB,EAAE;AADY;AAFQ,CAA1C;AAOA,MAAMI,oBAAoB,GAAG;AAC3BC,EAAAA,qBAAqB,EAAE;AAAEL,IAAAA,gBAAgB,EAAE;AAApB,GADI;AAE3BM,EAAAA,2BAA2B,EAAE;AAC3BN,IAAAA,gBAAgB,EAAE;AADS,GAFF;AAM3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAI,0BACFO,sBAASC,EAAT,KAAgB,SADd,IAEFP,iCAFF;AAd2B,CAA7B,C,CAmBA;AACA;AACA;AACA;;AACAL,YAAY,CAACa,uBAAb,GAAuC,EACrC,GAAGb,YAAY,CAACa,uBADqB;AAErC,KAAGL;AAFkC,CAAvC,C,CAIA;AACA;AACA;;AACA,MAAMM,kBAAkB,sDACtBd,YAAY,CAACe,oBADS,2DACtB,4BAAAf,YAAY,EAAwB,cAAxB,CADU,kGAEtBA,YAAY,CAACgB,YAFS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;;AAED,0BAAOhE,KAAK,CAACiE,YAAN,CACLpD,KADK,EAEL;AACEI,QAAAA,GAAG,EAAE,KAAKiD,UADZ;AAEEC,QAAAA,WAAW,EAAE,KAFf;AAGE,YAAI,0BACA;AACEC,UAAAA,WAAW,EAAE1E,IADf;AAEEW,UAAAA,UAAU,EAAE,KAAKA;AAFnB,SADA,GAKA,EALJ,CAHF;AASEgE,QAAAA,MAAM,wBAAE,KAAK9F,KAAL,CAAW8F,MAAb,mEAAuBxD,KAAK,CAACtC,KAAN,CAAY8F,MAT3C;AAUE,WAAGZ;AAVL,OAFK,EAcLE,aAdK,CAAP;AAgBD;;AA3WD;;AAPwE,kBAIpE5D,OAJoE,iBAQnDL,IARmD;;AAAA,kBAIpEK,OAJoE,iBASnDuE,sCATmD;;AAoX1E,SAAOvE,OAAP;AACD","sourcesContent":["import * as React from 'react';\nimport {\n Platform,\n UIManager,\n DeviceEventEmitter,\n EmitterSubscription,\n} from 'react-native';\nimport { customDirectEventTypes } from './customDirectEventTypes';\n// @ts-ignore - it isn't typed by TS & don't have definitelyTyped types\nimport deepEqual from 'lodash/isEqual';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\nimport { State } from '../State';\nimport {\n handlerIDToTag,\n getNextHandlerTag,\n registerOldGestureHandler,\n} from './handlersRegistry';\n\nimport {\n BaseGestureHandlerProps,\n filterConfig,\n GestureEvent,\n HandlerStateChangeEvent,\n findNodeHandle,\n scheduleFlushOperations,\n} from './gestureHandlerCommon';\nimport { ValueOf } from '../typeUtils';\nimport { isFabric, isJestEnv, tagMessage } from '../utils';\nimport { ActionType } from '../ActionType';\nimport { PressabilityDebugView } from './PressabilityDebugView';\nimport GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';\nimport { ghQueueMicrotask } from '../ghQueueMicrotask';\n\nconst UIManagerAny = UIManager as any;\n\ncustomDirectEventTypes.topGestureHandlerEvent = {\n registrationName: 'onGestureHandlerEvent',\n};\n\nconst customGHEventsConfigFabricAndroid = {\n topOnGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n topOnGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n};\n\nconst customGHEventsConfig = {\n onGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n onGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n\n // When using React Native Gesture Handler for Animated.event with useNativeDriver: true\n // on Android with Fabric enabled, the native part still sends the native events to JS\n // but prefixed with \"top\". We cannot simply rename the events above so they are prefixed\n // with \"top\" instead of \"on\" because in such case Animated.events would not be registered.\n // That's why we need to register another pair of event names.\n // The incoming events will be queued but never handled.\n // Without this piece of code below, you'll get the following JS error:\n // Unsupported top level event type \"topOnGestureHandlerEvent\" dispatched\n ...(isFabric() &&\n Platform.OS === 'android' &&\n customGHEventsConfigFabricAndroid),\n};\n\n// Add gesture specific events to genericDirectEventTypes object exported from UIManager\n// native module.\n// Once new event types are registered with react it is possible to dispatch these\n// events to all kind of native views.\nUIManagerAny.genericDirectEventTypes = {\n ...UIManagerAny.genericDirectEventTypes,\n ...customGHEventsConfig,\n};\n// In newer versions of RN the `genericDirectEventTypes` is located in the object\n// returned by UIManager.getViewManagerConfig('getConstants') or in older RN UIManager.getConstants(), we need to add it there as well to make\n// it compatible with RN 61+\nconst UIManagerConstants =\n UIManagerAny.getViewManagerConfig?.('getConstants') ??\n UIManagerAny.getConstants?.();\n\nif (UIManagerConstants) {\n UIManagerConstants.genericDirectEventTypes = {\n ...UIManagerConstants.genericDirectEventTypes,\n ...customGHEventsConfig,\n };\n}\n\n// Wrap JS responder calls and notify gesture handler manager\nconst {\n setJSResponder: oldSetJSResponder = () => {\n //no operation\n },\n clearJSResponder: oldClearJSResponder = () => {\n //no operation\n },\n} = UIManagerAny;\nUIManagerAny.setJSResponder = (tag: number, blockNativeResponder: boolean) => {\n RNGestureHandlerModule.handleSetJSResponder(tag, blockNativeResponder);\n oldSetJSResponder(tag, blockNativeResponder);\n};\nUIManagerAny.clearJSResponder = () => {\n RNGestureHandlerModule.handleClearJSResponder();\n oldClearJSResponder();\n};\n\nlet allowTouches = true;\nconst DEV_ON_ANDROID = __DEV__ && Platform.OS === 'android';\n// Toggled inspector blocks touch events in order to allow inspecting on Android\n// This needs to be a global variable in order to set initial state for `allowTouches` property in Handler component\nif (DEV_ON_ANDROID) {\n DeviceEventEmitter.addListener('toggleElementInspector', () => {\n allowTouches = !allowTouches;\n });\n}\n\ntype HandlerProps<T extends Record<string, unknown>> = Readonly<\n React.PropsWithChildren<BaseGestureHandlerProps<T>>\n>;\nfunction hasUnresolvedRefs<T extends Record<string, unknown>>(\n props: HandlerProps<T>\n) {\n // TODO(TS) - add type for extract arg\n const extract = (refs: any | any[]) => {\n if (!Array.isArray(refs)) {\n return refs && refs.current === null;\n }\n return refs.some((r) => r && r.current === null);\n };\n return extract(props['simultaneousHandlers']) || extract(props['waitFor']);\n}\n\nconst stateToPropMappings = {\n [State.UNDETERMINED]: undefined,\n [State.BEGAN]: 'onBegan',\n [State.FAILED]: 'onFailed',\n [State.CANCELLED]: 'onCancelled',\n [State.ACTIVE]: 'onActivated',\n [State.END]: 'onEnded',\n} as const;\n\ntype CreateHandlerArgs<HandlerPropsT extends Record<string, unknown>> =\n Readonly<{\n name: string;\n allowedProps: Readonly<Extract<keyof HandlerPropsT, string>[]>;\n config: Readonly<Record<string, unknown>>;\n transformProps?: (props: HandlerPropsT) => HandlerPropsT;\n customNativeProps?: Readonly<string[]>;\n }>;\n\n// TODO(TS) fix event types\ntype InternalEventHandlers = {\n onGestureHandlerEvent?: (event: any) => void;\n onGestureHandlerStateChange?: (event: any) => void;\n};\n\ntype AttachGestureHandlerWeb = (\n handlerTag: number,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n newView: any,\n _actionType: ActionType,\n propsRef: React.RefObject<unknown>\n) => void;\n\nconst UNRESOLVED_REFS_RETRY_LIMIT = 1;\n\n// TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.\nexport default function createHandler<\n T extends BaseGestureHandlerProps<U>,\n U extends Record<string, unknown>\n>({\n name,\n allowedProps = [],\n config = {},\n transformProps,\n customNativeProps = [],\n}: CreateHandlerArgs<T>): React.ComponentType<T & React.RefAttributes<any>> {\n interface HandlerState {\n allowTouches: boolean;\n }\n class Handler extends React.Component<\n T & InternalEventHandlers,\n HandlerState\n > {\n static displayName = name;\n static contextType = GestureHandlerRootViewContext;\n\n private handlerTag: number;\n private config: Record<string, unknown>;\n private propsRef: React.MutableRefObject<unknown>;\n private isMountedRef: React.MutableRefObject<boolean | null>;\n private viewNode: any;\n private viewTag?: number;\n private inspectorToggleListener?: EmitterSubscription;\n\n constructor(props: T & InternalEventHandlers) {\n super(props);\n this.handlerTag = getNextHandlerTag();\n this.config = {};\n this.propsRef = React.createRef();\n this.isMountedRef = React.createRef();\n this.state = { allowTouches };\n if (props.id) {\n if (handlerIDToTag[props.id] !== undefined) {\n throw new Error(`Handler with ID \"${props.id}\" already registered`);\n }\n handlerIDToTag[props.id] = this.handlerTag;\n }\n }\n\n componentDidMount() {\n const props: HandlerProps<U> = this.props;\n this.isMountedRef.current = true;\n\n if (DEV_ON_ANDROID) {\n this.inspectorToggleListener = DeviceEventEmitter.addListener(\n 'toggleElementInspector',\n () => {\n this.setState((_) => ({ allowTouches }));\n this.update(UNRESOLVED_REFS_RETRY_LIMIT);\n }\n );\n }\n if (hasUnresolvedRefs(props)) {\n // If there are unresolved refs (e.g. \".current\" has not yet been set)\n // passed as `simultaneousHandlers` or `waitFor`, we enqueue a call to\n // _update method that will try to update native handler props using\n // queueMicrotask. This makes it so update() function gets called after all\n // react components are mounted and we expect the missing ref object to\n // be resolved by then.\n ghQueueMicrotask(() => {\n this.update(UNRESOLVED_REFS_RETRY_LIMIT);\n });\n }\n\n this.createGestureHandler(\n filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n )\n );\n\n this.attachGestureHandler(findNodeHandle(this.viewNode) as number); // TODO(TS) - check if this can be null\n }\n\n componentDidUpdate() {\n const viewTag = findNodeHandle(this.viewNode);\n if (this.viewTag !== viewTag) {\n this.attachGestureHandler(viewTag as number); // TODO(TS) - check interaction between _viewTag & findNodeHandle\n }\n this.update(UNRESOLVED_REFS_RETRY_LIMIT);\n }\n\n componentWillUnmount() {\n this.inspectorToggleListener?.remove();\n this.isMountedRef.current = false;\n RNGestureHandlerModule.dropGestureHandler(this.handlerTag);\n scheduleFlushOperations();\n // We can't use this.props.id directly due to TS generic type narrowing bug, see https://github.com/microsoft/TypeScript/issues/13995 for more context\n const handlerID: string | undefined = this.props.id;\n if (handlerID) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete handlerIDToTag[handlerID];\n }\n }\n\n private onGestureHandlerEvent = (event: GestureEvent<U>) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n if (typeof this.props.onGestureEvent === 'function') {\n this.props.onGestureEvent?.(event);\n }\n } else {\n this.props.onGestureHandlerEvent?.(event);\n }\n };\n\n // TODO(TS) - make sure this is right type for event\n private onGestureHandlerStateChange = (\n event: HandlerStateChangeEvent<U>\n ) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n if (typeof this.props.onHandlerStateChange === 'function') {\n this.props.onHandlerStateChange?.(event);\n }\n\n const state: ValueOf<typeof State> = event.nativeEvent.state;\n const stateEventName = stateToPropMappings[state];\n const eventHandler = stateEventName && this.props[stateEventName];\n if (eventHandler && typeof eventHandler === 'function') {\n eventHandler(event);\n }\n } else {\n this.props.onGestureHandlerStateChange?.(event);\n }\n };\n\n private refHandler = (node: any) => {\n this.viewNode = node;\n\n const child = React.Children.only(this.props.children);\n // TODO(TS) fix ref type\n const { ref }: any = child;\n if (ref !== null) {\n if (typeof ref === 'function') {\n ref(node);\n } else {\n ref.current = node;\n }\n }\n };\n\n private createGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.createGestureHandler(\n name,\n this.handlerTag,\n newConfig\n );\n };\n\n private attachGestureHandler = (newViewTag: number) => {\n this.viewTag = newViewTag;\n\n if (Platform.OS === 'web') {\n // typecast due to dynamic resolution, attachGestureHandler should have web version signature in this branch\n (\n RNGestureHandlerModule.attachGestureHandler as AttachGestureHandlerWeb\n )(\n this.handlerTag,\n newViewTag,\n ActionType.JS_FUNCTION_OLD_API, // ignored on web\n this.propsRef\n );\n } else {\n registerOldGestureHandler(this.handlerTag, {\n onGestureEvent: this.onGestureHandlerEvent,\n onGestureStateChange: this.onGestureHandlerStateChange,\n });\n\n const actionType = (() => {\n const onGestureEvent = this.props?.onGestureEvent;\n const isGestureHandlerWorklet =\n onGestureEvent &&\n ('current' in onGestureEvent ||\n 'workletEventHandler' in onGestureEvent);\n const onHandlerStateChange = this.props?.onHandlerStateChange;\n const isStateChangeHandlerWorklet =\n onHandlerStateChange &&\n ('current' in onHandlerStateChange ||\n 'workletEventHandler' in onHandlerStateChange);\n const isReanimatedHandler =\n isGestureHandlerWorklet || isStateChangeHandlerWorklet;\n if (isReanimatedHandler) {\n // Reanimated worklet\n return ActionType.REANIMATED_WORKLET;\n } else if (onGestureEvent && '__isNative' in onGestureEvent) {\n // Animated.event with useNativeDriver: true\n return ActionType.NATIVE_ANIMATED_EVENT;\n } else {\n // JS callback or Animated.event with useNativeDriver: false\n return ActionType.JS_FUNCTION_OLD_API;\n }\n })();\n\n RNGestureHandlerModule.attachGestureHandler(\n this.handlerTag,\n newViewTag,\n actionType\n );\n }\n\n scheduleFlushOperations();\n };\n\n private updateGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.updateGestureHandler(this.handlerTag, newConfig);\n scheduleFlushOperations();\n };\n\n private update(remainingTries: number) {\n if (!this.isMountedRef.current) {\n return;\n }\n\n const props: HandlerProps<U> = this.props;\n\n // When ref is set via a function i.e. `ref={(r) => refObject.current = r}` instead of\n // `ref={refObject}` it's possible that it won't be resolved in time. Seems like trying\n // again is easy enough fix.\n if (hasUnresolvedRefs(props) && remainingTries > 0) {\n ghQueueMicrotask(() => {\n this.update(remainingTries - 1);\n });\n } else {\n const newConfig = filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n );\n if (!deepEqual(this.config, newConfig)) {\n this.updateGestureHandler(newConfig);\n }\n }\n }\n\n setNativeProps(updates: any) {\n const mergedProps = { ...this.props, ...updates };\n const newConfig = filterConfig(\n transformProps ? transformProps(mergedProps) : mergedProps,\n [...allowedProps, ...customNativeProps],\n config\n );\n this.updateGestureHandler(newConfig);\n }\n\n render() {\n if (__DEV__ && !this.context && !isJestEnv() && Platform.OS !== 'web') {\n throw new Error(\n name +\n ' must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.'\n );\n }\n\n let gestureEventHandler = this.onGestureHandlerEvent;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureEventHandlers = {\n onGestureEvent?: BaseGestureHandlerProps<U>['onGestureEvent'];\n onGestureHandlerEvent?: InternalEventHandlers['onGestureHandlerEvent'];\n };\n const { onGestureEvent, onGestureHandlerEvent }: OnGestureEventHandlers =\n this.props;\n if (onGestureEvent && typeof onGestureEvent !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerEvent) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureEventHandler = onGestureEvent;\n } else {\n if (\n onGestureHandlerEvent &&\n typeof onGestureHandlerEvent !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n\n let gestureStateEventHandler = this.onGestureHandlerStateChange;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureStateChangeHandlers = {\n onHandlerStateChange?: BaseGestureHandlerProps<U>['onHandlerStateChange'];\n onGestureHandlerStateChange?: InternalEventHandlers['onGestureHandlerStateChange'];\n };\n const {\n onHandlerStateChange,\n onGestureHandlerStateChange,\n }: OnGestureStateChangeHandlers = this.props;\n if (onHandlerStateChange && typeof onHandlerStateChange !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerStateChange) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureStateEventHandler = onHandlerStateChange;\n } else {\n if (\n onGestureHandlerStateChange &&\n typeof onGestureHandlerStateChange !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n const events = {\n onGestureHandlerEvent: this.state.allowTouches\n ? gestureEventHandler\n : undefined,\n onGestureHandlerStateChange: this.state.allowTouches\n ? gestureStateEventHandler\n : undefined,\n };\n\n this.propsRef.current = events;\n\n let child: any = null;\n try {\n child = React.Children.only(this.props.children);\n } catch (e) {\n throw new Error(\n tagMessage(\n `${name} got more than one view as a child. If you want the gesture to work on multiple views, wrap them with a common parent and attach the gesture to that view.`\n )\n );\n }\n\n let grandChildren = child.props.children;\n if (\n __DEV__ &&\n child.type &&\n (child.type === 'RNGestureHandlerButton' ||\n child.type.name === 'View' ||\n child.type.displayName === 'View')\n ) {\n grandChildren = React.Children.toArray(grandChildren);\n grandChildren.push(\n <PressabilityDebugView\n key=\"pressabilityDebugView\"\n color=\"mediumspringgreen\"\n hitSlop={child.props.hitSlop}\n />\n );\n }\n\n return React.cloneElement(\n child,\n {\n ref: this.refHandler,\n collapsable: false,\n ...(isJestEnv()\n ? {\n handlerType: name,\n handlerTag: this.handlerTag,\n }\n : {}),\n testID: this.props.testID ?? child.props.testID,\n ...events,\n },\n grandChildren\n );\n }\n }\n return Handler;\n}\n"]}
1
+ {"version":3,"sources":["createHandler.tsx"],"names":["UIManagerAny","UIManager","customDirectEventTypes","topGestureHandlerEvent","registrationName","customGHEventsConfigFabricAndroid","topOnGestureHandlerEvent","topOnGestureHandlerStateChange","customGHEventsConfig","onGestureHandlerEvent","onGestureHandlerStateChange","Platform","OS","genericDirectEventTypes","UIManagerConstants","getViewManagerConfig","getConstants","setJSResponder","oldSetJSResponder","clearJSResponder","oldClearJSResponder","tag","blockNativeResponder","RNGestureHandlerModule","handleSetJSResponder","handleClearJSResponder","allowTouches","DEV_ON_ANDROID","__DEV__","DeviceEventEmitter","addListener","hasUnresolvedRefs","props","extract","refs","Array","isArray","current","some","r","stateToPropMappings","State","UNDETERMINED","undefined","BEGAN","FAILED","CANCELLED","ACTIVE","END","UNRESOLVED_REFS_RETRY_LIMIT","createHandler","name","allowedProps","config","transformProps","customNativeProps","Handler","React","Component","constructor","event","nativeEvent","handlerTag","onGestureEvent","onHandlerStateChange","state","stateEventName","eventHandler","node","viewNode","child","Children","only","children","ref","newConfig","createGestureHandler","newViewTag","viewTag","attachGestureHandler","ActionType","JS_FUNCTION_OLD_API","propsRef","onGestureStateChange","actionType","isGestureHandlerWorklet","isStateChangeHandlerWorklet","isReanimatedHandler","REANIMATED_WORKLET","NATIVE_ANIMATED_EVENT","updateGestureHandler","createRef","isMountedRef","id","handlerIDToTag","Error","componentDidMount","inspectorToggleListener","setState","_","update","componentDidUpdate","componentWillUnmount","remove","dropGestureHandler","handlerID","remainingTries","setNativeProps","updates","mergedProps","render","context","gestureEventHandler","gestureStateEventHandler","events","e","grandChildren","type","displayName","toArray","push","hitSlop","cloneElement","refHandler","collapsable","handlerType","testID","GestureHandlerRootViewContext"],"mappings":";;;;;;;AAAA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AAMA;;AASA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;AAEA,MAAMA,YAAY,GAAGC,sBAArB;AAEAC,+CAAuBC,sBAAvB,GAAgD;AAC9CC,EAAAA,gBAAgB,EAAE;AAD4B,CAAhD;AAIA,MAAMC,iCAAiC,GAAG;AACxCC,EAAAA,wBAAwB,EAAE;AAAEF,IAA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FD,CAEE,OAAO0C,CAAP,EAAU;AACV,cAAM,IAAIpB,KAAJ,CACJ,uBACG,GAAE5C,IAAK,4JADV,CADI,CAAN;AAKD;;AAED,UAAIiE,aAAa,GAAG9C,KAAK,CAACtC,KAAN,CAAYyC,QAAhC;;AACA,UACE7C,OAAO,IACP0C,KAAK,CAAC+C,IADN,KAEC/C,KAAK,CAAC+C,IAAN,KAAe,wBAAf,IACC/C,KAAK,CAAC+C,IAAN,CAAWlE,IAAX,KAAoB,MADrB,IAECmB,KAAK,CAAC+C,IAAN,CAAWC,WAAX,KAA2B,MAJ7B,CADF,EAME;AACAF,QAAAA,aAAa,GAAG3D,KAAK,CAACc,QAAN,CAAegD,OAAf,CAAuBH,aAAvB,CAAhB;AACAA,QAAAA,aAAa,CAACI,IAAd,eACE,oBAAC,4CAAD;AACE,UAAA,GAAG,EAAC,uBADN;AAEE,UAAA,KAAK,EAAC,mBAFR;AAGE,UAAA,OAAO,EAAElD,KAAK,CAACtC,KAAN,CAAYyF;AAHvB,UADF;AAOD;;AAED,0BAAOhE,KAAK,CAACiE,YAAN,CACLpD,KADK,EAEL;AACEI,QAAAA,GAAG,EAAE,KAAKiD,UADZ;AAEEC,QAAAA,WAAW,EAAE,KAFf;AAGE,YAAI,0BACA;AACEC,UAAAA,WAAW,EAAE1E,IADf;AAEEW,UAAAA,UAAU,EAAE,KAAKA;AAFnB,SADA,GAKA,EALJ,CAHF;AASEgE,QAAAA,MAAM,wBAAE,KAAK9F,KAAL,CAAW8F,MAAb,mEAAuBxD,KAAK,CAACtC,KAAN,CAAY8F,MAT3C;AAUE,WAAGZ;AAVL,OAFK,EAcLE,aAdK,CAAP;AAgBD;;AA3WD;;AAPwE,kBAIpE5D,OAJoE,iBAQnDL,IARmD;;AAAA,kBAIpEK,OAJoE,iBASnDuE,sCATmD;;AAoX1E,SAAOvE,OAAP;AACD","sourcesContent":["import * as React from 'react';\nimport {\n Platform,\n UIManager,\n DeviceEventEmitter,\n EmitterSubscription,\n} from 'react-native';\nimport { customDirectEventTypes } from './customDirectEventTypes';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\nimport { State } from '../State';\nimport {\n handlerIDToTag,\n getNextHandlerTag,\n registerOldGestureHandler,\n} from './handlersRegistry';\n\nimport {\n BaseGestureHandlerProps,\n filterConfig,\n GestureEvent,\n HandlerStateChangeEvent,\n findNodeHandle,\n scheduleFlushOperations,\n} from './gestureHandlerCommon';\nimport { ValueOf } from '../typeUtils';\nimport { deepEqual, isFabric, isJestEnv, tagMessage } from '../utils';\nimport { ActionType } from '../ActionType';\nimport { PressabilityDebugView } from './PressabilityDebugView';\nimport GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';\nimport { ghQueueMicrotask } from '../ghQueueMicrotask';\n\nconst UIManagerAny = UIManager as any;\n\ncustomDirectEventTypes.topGestureHandlerEvent = {\n registrationName: 'onGestureHandlerEvent',\n};\n\nconst customGHEventsConfigFabricAndroid = {\n topOnGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n topOnGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n};\n\nconst customGHEventsConfig = {\n onGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n onGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n\n // When using React Native Gesture Handler for Animated.event with useNativeDriver: true\n // on Android with Fabric enabled, the native part still sends the native events to JS\n // but prefixed with \"top\". We cannot simply rename the events above so they are prefixed\n // with \"top\" instead of \"on\" because in such case Animated.events would not be registered.\n // That's why we need to register another pair of event names.\n // The incoming events will be queued but never handled.\n // Without this piece of code below, you'll get the following JS error:\n // Unsupported top level event type \"topOnGestureHandlerEvent\" dispatched\n ...(isFabric() &&\n Platform.OS === 'android' &&\n customGHEventsConfigFabricAndroid),\n};\n\n// Add gesture specific events to genericDirectEventTypes object exported from UIManager\n// native module.\n// Once new event types are registered with react it is possible to dispatch these\n// events to all kind of native views.\nUIManagerAny.genericDirectEventTypes = {\n ...UIManagerAny.genericDirectEventTypes,\n ...customGHEventsConfig,\n};\n// In newer versions of RN the `genericDirectEventTypes` is located in the object\n// returned by UIManager.getViewManagerConfig('getConstants') or in older RN UIManager.getConstants(), we need to add it there as well to make\n// it compatible with RN 61+\nconst UIManagerConstants =\n UIManagerAny.getViewManagerConfig?.('getConstants') ??\n UIManagerAny.getConstants?.();\n\nif (UIManagerConstants) {\n UIManagerConstants.genericDirectEventTypes = {\n ...UIManagerConstants.genericDirectEventTypes,\n ...customGHEventsConfig,\n };\n}\n\n// Wrap JS responder calls and notify gesture handler manager\nconst {\n setJSResponder: oldSetJSResponder = () => {\n //no operation\n },\n clearJSResponder: oldClearJSResponder = () => {\n //no operation\n },\n} = UIManagerAny;\nUIManagerAny.setJSResponder = (tag: number, blockNativeResponder: boolean) => {\n RNGestureHandlerModule.handleSetJSResponder(tag, blockNativeResponder);\n oldSetJSResponder(tag, blockNativeResponder);\n};\nUIManagerAny.clearJSResponder = () => {\n RNGestureHandlerModule.handleClearJSResponder();\n oldClearJSResponder();\n};\n\nlet allowTouches = true;\nconst DEV_ON_ANDROID = __DEV__ && Platform.OS === 'android';\n// Toggled inspector blocks touch events in order to allow inspecting on Android\n// This needs to be a global variable in order to set initial state for `allowTouches` property in Handler component\nif (DEV_ON_ANDROID) {\n DeviceEventEmitter.addListener('toggleElementInspector', () => {\n allowTouches = !allowTouches;\n });\n}\n\ntype HandlerProps<T extends Record<string, unknown>> = Readonly<\n React.PropsWithChildren<BaseGestureHandlerProps<T>>\n>;\nfunction hasUnresolvedRefs<T extends Record<string, unknown>>(\n props: HandlerProps<T>\n) {\n // TODO(TS) - add type for extract arg\n const extract = (refs: any | any[]) => {\n if (!Array.isArray(refs)) {\n return refs && refs.current === null;\n }\n return refs.some((r) => r && r.current === null);\n };\n return extract(props['simultaneousHandlers']) || extract(props['waitFor']);\n}\n\nconst stateToPropMappings = {\n [State.UNDETERMINED]: undefined,\n [State.BEGAN]: 'onBegan',\n [State.FAILED]: 'onFailed',\n [State.CANCELLED]: 'onCancelled',\n [State.ACTIVE]: 'onActivated',\n [State.END]: 'onEnded',\n} as const;\n\ntype CreateHandlerArgs<HandlerPropsT extends Record<string, unknown>> =\n Readonly<{\n name: string;\n allowedProps: Readonly<Extract<keyof HandlerPropsT, string>[]>;\n config: Readonly<Record<string, unknown>>;\n transformProps?: (props: HandlerPropsT) => HandlerPropsT;\n customNativeProps?: Readonly<string[]>;\n }>;\n\n// TODO(TS) fix event types\ntype InternalEventHandlers = {\n onGestureHandlerEvent?: (event: any) => void;\n onGestureHandlerStateChange?: (event: any) => void;\n};\n\ntype AttachGestureHandlerWeb = (\n handlerTag: number,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n newView: any,\n _actionType: ActionType,\n propsRef: React.RefObject<unknown>\n) => void;\n\nconst UNRESOLVED_REFS_RETRY_LIMIT = 1;\n\n// TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.\nexport default function createHandler<\n T extends BaseGestureHandlerProps<U>,\n U extends Record<string, unknown>\n>({\n name,\n allowedProps = [],\n config = {},\n transformProps,\n customNativeProps = [],\n}: CreateHandlerArgs<T>): React.ComponentType<T & React.RefAttributes<any>> {\n interface HandlerState {\n allowTouches: boolean;\n }\n class Handler extends React.Component<\n T & InternalEventHandlers,\n HandlerState\n > {\n static displayName = name;\n static contextType = GestureHandlerRootViewContext;\n\n private handlerTag: number;\n private config: Record<string, unknown>;\n private propsRef: React.MutableRefObject<unknown>;\n private isMountedRef: React.MutableRefObject<boolean | null>;\n private viewNode: any;\n private viewTag?: number;\n private inspectorToggleListener?: EmitterSubscription;\n\n constructor(props: T & InternalEventHandlers) {\n super(props);\n this.handlerTag = getNextHandlerTag();\n this.config = {};\n this.propsRef = React.createRef();\n this.isMountedRef = React.createRef();\n this.state = { allowTouches };\n if (props.id) {\n if (handlerIDToTag[props.id] !== undefined) {\n throw new Error(`Handler with ID \"${props.id}\" already registered`);\n }\n handlerIDToTag[props.id] = this.handlerTag;\n }\n }\n\n componentDidMount() {\n const props: HandlerProps<U> = this.props;\n this.isMountedRef.current = true;\n\n if (DEV_ON_ANDROID) {\n this.inspectorToggleListener = DeviceEventEmitter.addListener(\n 'toggleElementInspector',\n () => {\n this.setState((_) => ({ allowTouches }));\n this.update(UNRESOLVED_REFS_RETRY_LIMIT);\n }\n );\n }\n if (hasUnresolvedRefs(props)) {\n // If there are unresolved refs (e.g. \".current\" has not yet been set)\n // passed as `simultaneousHandlers` or `waitFor`, we enqueue a call to\n // _update method that will try to update native handler props using\n // queueMicrotask. This makes it so update() function gets called after all\n // react components are mounted and we expect the missing ref object to\n // be resolved by then.\n ghQueueMicrotask(() => {\n this.update(UNRESOLVED_REFS_RETRY_LIMIT);\n });\n }\n\n this.createGestureHandler(\n filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n )\n );\n\n this.attachGestureHandler(findNodeHandle(this.viewNode) as number); // TODO(TS) - check if this can be null\n }\n\n componentDidUpdate() {\n const viewTag = findNodeHandle(this.viewNode);\n if (this.viewTag !== viewTag) {\n this.attachGestureHandler(viewTag as number); // TODO(TS) - check interaction between _viewTag & findNodeHandle\n }\n this.update(UNRESOLVED_REFS_RETRY_LIMIT);\n }\n\n componentWillUnmount() {\n this.inspectorToggleListener?.remove();\n this.isMountedRef.current = false;\n RNGestureHandlerModule.dropGestureHandler(this.handlerTag);\n scheduleFlushOperations();\n // We can't use this.props.id directly due to TS generic type narrowing bug, see https://github.com/microsoft/TypeScript/issues/13995 for more context\n const handlerID: string | undefined = this.props.id;\n if (handlerID) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete handlerIDToTag[handlerID];\n }\n }\n\n private onGestureHandlerEvent = (event: GestureEvent<U>) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n if (typeof this.props.onGestureEvent === 'function') {\n this.props.onGestureEvent?.(event);\n }\n } else {\n this.props.onGestureHandlerEvent?.(event);\n }\n };\n\n // TODO(TS) - make sure this is right type for event\n private onGestureHandlerStateChange = (\n event: HandlerStateChangeEvent<U>\n ) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n if (typeof this.props.onHandlerStateChange === 'function') {\n this.props.onHandlerStateChange?.(event);\n }\n\n const state: ValueOf<typeof State> = event.nativeEvent.state;\n const stateEventName = stateToPropMappings[state];\n const eventHandler = stateEventName && this.props[stateEventName];\n if (eventHandler && typeof eventHandler === 'function') {\n eventHandler(event);\n }\n } else {\n this.props.onGestureHandlerStateChange?.(event);\n }\n };\n\n private refHandler = (node: any) => {\n this.viewNode = node;\n\n const child = React.Children.only(this.props.children);\n // TODO(TS) fix ref type\n const { ref }: any = child;\n if (ref !== null) {\n if (typeof ref === 'function') {\n ref(node);\n } else {\n ref.current = node;\n }\n }\n };\n\n private createGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.createGestureHandler(\n name,\n this.handlerTag,\n newConfig\n );\n };\n\n private attachGestureHandler = (newViewTag: number) => {\n this.viewTag = newViewTag;\n\n if (Platform.OS === 'web') {\n // typecast due to dynamic resolution, attachGestureHandler should have web version signature in this branch\n (\n RNGestureHandlerModule.attachGestureHandler as AttachGestureHandlerWeb\n )(\n this.handlerTag,\n newViewTag,\n ActionType.JS_FUNCTION_OLD_API, // ignored on web\n this.propsRef\n );\n } else {\n registerOldGestureHandler(this.handlerTag, {\n onGestureEvent: this.onGestureHandlerEvent,\n onGestureStateChange: this.onGestureHandlerStateChange,\n });\n\n const actionType = (() => {\n const onGestureEvent = this.props?.onGestureEvent;\n const isGestureHandlerWorklet =\n onGestureEvent &&\n ('current' in onGestureEvent ||\n 'workletEventHandler' in onGestureEvent);\n const onHandlerStateChange = this.props?.onHandlerStateChange;\n const isStateChangeHandlerWorklet =\n onHandlerStateChange &&\n ('current' in onHandlerStateChange ||\n 'workletEventHandler' in onHandlerStateChange);\n const isReanimatedHandler =\n isGestureHandlerWorklet || isStateChangeHandlerWorklet;\n if (isReanimatedHandler) {\n // Reanimated worklet\n return ActionType.REANIMATED_WORKLET;\n } else if (onGestureEvent && '__isNative' in onGestureEvent) {\n // Animated.event with useNativeDriver: true\n return ActionType.NATIVE_ANIMATED_EVENT;\n } else {\n // JS callback or Animated.event with useNativeDriver: false\n return ActionType.JS_FUNCTION_OLD_API;\n }\n })();\n\n RNGestureHandlerModule.attachGestureHandler(\n this.handlerTag,\n newViewTag,\n actionType\n );\n }\n\n scheduleFlushOperations();\n };\n\n private updateGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.updateGestureHandler(this.handlerTag, newConfig);\n scheduleFlushOperations();\n };\n\n private update(remainingTries: number) {\n if (!this.isMountedRef.current) {\n return;\n }\n\n const props: HandlerProps<U> = this.props;\n\n // When ref is set via a function i.e. `ref={(r) => refObject.current = r}` instead of\n // `ref={refObject}` it's possible that it won't be resolved in time. Seems like trying\n // again is easy enough fix.\n if (hasUnresolvedRefs(props) && remainingTries > 0) {\n ghQueueMicrotask(() => {\n this.update(remainingTries - 1);\n });\n } else {\n const newConfig = filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n );\n if (!deepEqual(this.config, newConfig)) {\n this.updateGestureHandler(newConfig);\n }\n }\n }\n\n setNativeProps(updates: any) {\n const mergedProps = { ...this.props, ...updates };\n const newConfig = filterConfig(\n transformProps ? transformProps(mergedProps) : mergedProps,\n [...allowedProps, ...customNativeProps],\n config\n );\n this.updateGestureHandler(newConfig);\n }\n\n render() {\n if (__DEV__ && !this.context && !isJestEnv() && Platform.OS !== 'web') {\n throw new Error(\n name +\n ' must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.'\n );\n }\n\n let gestureEventHandler = this.onGestureHandlerEvent;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureEventHandlers = {\n onGestureEvent?: BaseGestureHandlerProps<U>['onGestureEvent'];\n onGestureHandlerEvent?: InternalEventHandlers['onGestureHandlerEvent'];\n };\n const { onGestureEvent, onGestureHandlerEvent }: OnGestureEventHandlers =\n this.props;\n if (onGestureEvent && typeof onGestureEvent !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerEvent) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureEventHandler = onGestureEvent;\n } else {\n if (\n onGestureHandlerEvent &&\n typeof onGestureHandlerEvent !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n\n let gestureStateEventHandler = this.onGestureHandlerStateChange;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureStateChangeHandlers = {\n onHandlerStateChange?: BaseGestureHandlerProps<U>['onHandlerStateChange'];\n onGestureHandlerStateChange?: InternalEventHandlers['onGestureHandlerStateChange'];\n };\n const {\n onHandlerStateChange,\n onGestureHandlerStateChange,\n }: OnGestureStateChangeHandlers = this.props;\n if (onHandlerStateChange && typeof onHandlerStateChange !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerStateChange) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureStateEventHandler = onHandlerStateChange;\n } else {\n if (\n onGestureHandlerStateChange &&\n typeof onGestureHandlerStateChange !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n const events = {\n onGestureHandlerEvent: this.state.allowTouches\n ? gestureEventHandler\n : undefined,\n onGestureHandlerStateChange: this.state.allowTouches\n ? gestureStateEventHandler\n : undefined,\n };\n\n this.propsRef.current = events;\n\n let child: any = null;\n try {\n child = React.Children.only(this.props.children);\n } catch (e) {\n throw new Error(\n tagMessage(\n `${name} got more than one view as a child. If you want the gesture to work on multiple views, wrap them with a common parent and attach the gesture to that view.`\n )\n );\n }\n\n let grandChildren = child.props.children;\n if (\n __DEV__ &&\n child.type &&\n (child.type === 'RNGestureHandlerButton' ||\n child.type.name === 'View' ||\n child.type.displayName === 'View')\n ) {\n grandChildren = React.Children.toArray(grandChildren);\n grandChildren.push(\n <PressabilityDebugView\n key=\"pressabilityDebugView\"\n color=\"mediumspringgreen\"\n hitSlop={child.props.hitSlop}\n />\n );\n }\n\n return React.cloneElement(\n child,\n {\n ref: this.refHandler,\n collapsable: false,\n ...(isJestEnv()\n ? {\n handlerType: name,\n handlerTag: this.handlerTag,\n }\n : {}),\n testID: this.props.testID ?? child.props.testID,\n ...events,\n },\n grandChildren\n );\n }\n }\n return Handler;\n}\n"]}
@@ -3,9 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.customDirectEventTypes = void 0;
7
- // customDirectEventTypes doesn't exist in react-native-web, therefore importing it
8
- // directly in createHandler.tsx would end in crash.
9
- const customDirectEventTypes = {};
10
- exports.customDirectEventTypes = customDirectEventTypes;
6
+ Object.defineProperty(exports, "customDirectEventTypes", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _ReactNativeViewConfigRegistry.customDirectEventTypes;
10
+ }
11
+ });
12
+
13
+ var _ReactNativeViewConfigRegistry = require("react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry");
11
14
  //# sourceMappingURL=customDirectEventTypes.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["customDirectEventTypes.ts"],"names":["customDirectEventTypes"],"mappings":";;;;;;AAAA;AACA;AACA,MAAMA,sBAAsB,GAAG,EAA/B","sourcesContent":["// customDirectEventTypes doesn't exist in react-native-web, therefore importing it\n// directly in createHandler.tsx would end in crash.\nconst customDirectEventTypes = {};\n\nexport { customDirectEventTypes };\n"]}
1
+ {"version":3,"sources":["customDirectEventTypes.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA","sourcesContent":["// @ts-ignore - its taken straight from RN\nexport { customDirectEventTypes } from 'react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry';\n"]}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.customDirectEventTypes = void 0;
7
+ // customDirectEventTypes doesn't exist in react-native-web, therefore importing it
8
+ // directly in createHandler.tsx would end in crash.
9
+ const customDirectEventTypes = {};
10
+ exports.customDirectEventTypes = customDirectEventTypes;
11
+ //# sourceMappingURL=customDirectEventTypes.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["customDirectEventTypes.web.ts"],"names":["customDirectEventTypes"],"mappings":";;;;;;AAAA;AACA;AACA,MAAMA,sBAAsB,GAAG,EAA/B","sourcesContent":["// customDirectEventTypes doesn't exist in react-native-web, therefore importing it\n// directly in createHandler.tsx would end in crash.\nconst customDirectEventTypes = {};\n\nexport { customDirectEventTypes };\n"]}
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.filterConfig = filterConfig;
7
7
  exports.findNodeHandle = findNodeHandle;
8
8
  exports.scheduleFlushOperations = scheduleFlushOperations;
9
- exports.MouseButton = exports.baseGestureHandlerWithMonitorProps = exports.baseGestureHandlerProps = void 0;
9
+ exports.MouseButton = exports.baseGestureHandlerWithDetectorProps = exports.baseGestureHandlerProps = void 0;
10
10
 
11
11
  var _reactNative = require("react-native");
12
12
 
@@ -28,8 +28,8 @@ const commonProps = ['id', 'enabled', 'shouldCancelWhenOutside', 'hitSlop', 'can
28
28
  const componentInteractionProps = ['waitFor', 'simultaneousHandlers', 'blocksHandlers'];
29
29
  const baseGestureHandlerProps = [...commonProps, ...componentInteractionProps, 'onBegan', 'onFailed', 'onCancelled', 'onActivated', 'onEnded', 'onGestureEvent', 'onHandlerStateChange'];
30
30
  exports.baseGestureHandlerProps = baseGestureHandlerProps;
31
- const baseGestureHandlerWithMonitorProps = [...commonProps, 'needsPointerData', 'manualActivation'];
32
- exports.baseGestureHandlerWithMonitorProps = baseGestureHandlerWithMonitorProps;
31
+ const baseGestureHandlerWithDetectorProps = [...commonProps, 'needsPointerData', 'manualActivation'];
32
+ exports.baseGestureHandlerWithDetectorProps = baseGestureHandlerWithDetectorProps;
33
33
  let MouseButton;
34
34
  exports.MouseButton = MouseButton;
35
35
 
@@ -1 +1 @@
1
- {"version":3,"sources":["gestureHandlerCommon.ts"],"names":["commonProps","componentInteractionProps","baseGestureHandlerProps","baseGestureHandlerWithMonitorProps","MouseButton","isConfigParam","param","name","undefined","Object","filterConfig","props","validProps","defaults","filteredConfig","key","value","transformIntoHandlerTags","top","left","bottom","right","handlerIDs","Platform","OS","map","current","filter","handle","handlerID","handlerIDToTag","handlerTag","findNodeHandle","node","flushOperationsScheduled","scheduleFlushOperations","RNGestureHandlerModule","flushOperations"],"mappings":";;;;;;;;;;AAKA;;AAKA;;AACA;;AACA;;AACA;;;;AAbA;AACA;AACA;AACA;AAaA,MAAMA,WAAW,GAAG,CAClB,IADkB,EAElB,SAFkB,EAGlB,yBAHkB,EAIlB,SAJkB,EAKlB,sBALkB,EAMlB,YANkB,EAOlB,cAPkB,EAQlB,aARkB,EASlB,mBATkB,EAUlB,aAVkB,CAApB;AAaA,MAAMC,yBAAyB,GAAG,CAChC,SADgC,EAEhC,sBAFgC,EAGhC,gBAHgC,CAAlC;AAMO,MAAMC,uBAAuB,GAAG,CACrC,GAAGF,WADkC,EAErC,GAAGC,yBAFkC,EAGrC,SAHqC,EAIrC,UAJqC,EAKrC,aALqC,EAMrC,aANqC,EAOrC,SAPqC,EAQrC,gBARqC,EASrC,sBATqC,CAAhC;;AAYA,MAAME,kCAAkC,GAAG,CAChD,GAAGH,WAD6C,EAEhD,kBAFgD,EAGhD,kBAHgD,CAA3C;;IAoEKI,W;;;WAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAA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KAApB,EAA2B;AACzB,WAAOF,UAAU,CACdG,GADI,CACA,CAAC;AAAEC,MAAAA;AAAF,KAAD,KAAmCA,OADnC,EAEJC,MAFI,CAEIC,MAAD,IAAiBA,MAFpB,CAAP;AAGD,GAPgD,CAQjD;;;AACA,SAAON,UAAU,CACdG,GADI,CAEFI,SAAD;AAAA;;AAAA,WACEC,iCAAeD,SAAf,4BAA6BA,SAAS,CAACH,OAAvC,uDAA6B,mBAAmBK,UAAhD,KAA8D,CAAC,CADjE;AAAA,GAFG,EAKJJ,MALI,CAKII,UAAD,IAAwBA,UAAU,GAAG,CALxC,CAAP;AAMD;;AAEM,SAASC,cAAT,CACLC,IADK,EAEkE;AACvE,MAAIV,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzB,WAAOS,IAAP;AACD;;AACD,SAAO,iCAAiBA,IAAjB,CAAP;AACD;;AAED,IAAIC,wBAAwB,GAAG,KAA/B;;AAEO,SAASC,uBAAT,GAAmC;AACxC,MAAI,CAACD,wBAAL,EAA+B;AAC7BA,IAAAA,wBAAwB,GAAG,IAA3B;AACA,4CAAiB,MAAM;AACrBE,sCAAuBC,eAAvB;;AAEAH,MAAAA,wBAAwB,GAAG,KAA3B;AACD,KAJD;AAKD;AACF","sourcesContent":["// Previous types exported gesture handlers as classes which creates an interface and variable, both named the same as class.\n// Without those types, we'd introduce breaking change, forcing users to prefix every handler type specification with typeof\n// e.g. React.createRef<TapGestureHandler> -> React.createRef<typeof TapGestureHandler>.\n// See https://www.typescriptlang.org/docs/handbook/classes.html#constructor-functions for reference.\nimport * as React from 'react';\nimport { Platform, findNodeHandle as findNodeHandleRN } from 'react-native';\n\nimport { State } from '../State';\nimport { TouchEventType } from '../TouchEventType';\nimport { ValueOf } from '../typeUtils';\nimport { handlerIDToTag } from './handlersRegistry';\nimport { toArray } from '../utils';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\nimport { ghQueueMicrotask } from '../ghQueueMicrotask';\nimport { PointerType } from '../PointerType';\n\nconst commonProps = [\n 'id',\n 'enabled',\n 'shouldCancelWhenOutside',\n 'hitSlop',\n 'cancelsTouchesInView',\n 'userSelect',\n 'activeCursor',\n 'mouseButton',\n 'enableContextMenu',\n 'touchAction',\n] as const;\n\nconst componentInteractionProps = [\n 'waitFor',\n 'simultaneousHandlers',\n 'blocksHandlers',\n] as const;\n\nexport const baseGestureHandlerProps = [\n ...commonProps,\n ...componentInteractionProps,\n 'onBegan',\n 'onFailed',\n 'onCancelled',\n 'onActivated',\n 'onEnded',\n 'onGestureEvent',\n 'onHandlerStateChange',\n] as const;\n\nexport const baseGestureHandlerWithMonitorProps = [\n ...commonProps,\n 'needsPointerData',\n 'manualActivation',\n];\n\nexport interface GestureEventPayload {\n handlerTag: number;\n numberOfPointers: number;\n state: ValueOf<typeof State>;\n pointerType: PointerType;\n}\nexport interface HandlerStateChangeEventPayload extends GestureEventPayload {\n oldState: ValueOf<typeof State>;\n}\n\nexport type HitSlop =\n | number\n | Partial<\n Record<\n 'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal',\n number\n >\n >\n | Record<'width' | 'left', number>\n | Record<'width' | 'right', number>\n | Record<'height' | 'top', number>\n | Record<'height' | 'bottom', number>;\n\nexport type UserSelect = 'none' | 'auto' | 'text';\nexport type ActiveCursor =\n | 'auto'\n | 'default'\n | 'none'\n | 'context-menu'\n | 'help'\n | 'pointer'\n | 'progress'\n | 'wait'\n | 'cell'\n | 'crosshair'\n | 'text'\n | 'vertical-text'\n | 'alias'\n | 'copy'\n | 'move'\n | 'no-drop'\n | 'not-allowed'\n | 'grab'\n | 'grabbing'\n | 'e-resize'\n | 'n-resize'\n | 'ne-resize'\n | 'nw-resize'\n | 's-resize'\n | 'se-resize'\n | 'sw-resize'\n | 'w-resize'\n | 'ew-resize'\n | 'ns-resize'\n | 'nesw-resize'\n | 'nwse-resize'\n | 'col-resize'\n | 'row-resize'\n | 'all-scroll'\n | 'zoom-in'\n | 'zoom-out';\n\nexport enum MouseButton {\n LEFT = 1,\n RIGHT = 2,\n MIDDLE = 4,\n BUTTON_4 = 8,\n BUTTON_5 = 16,\n ALL = 31,\n}\n\nexport type TouchAction =\n | 'auto'\n | 'none'\n | 'pan-x'\n | 'pan-left'\n | 'pan-right'\n | 'pan-y'\n | 'pan-up'\n | 'pan-down'\n | 'pinch-zoom'\n | 'manipulation'\n | 'inherit'\n | 'initial'\n | 'revert'\n | 'revert-layer'\n | 'unset';\n\n//TODO(TS) events in handlers\n\nexport interface GestureEvent<ExtraEventPayloadT = Record<string, unknown>> {\n nativeEvent: Readonly<GestureEventPayload & ExtraEventPayloadT>;\n}\nexport interface HandlerStateChangeEvent<\n ExtraEventPayloadT = Record<string, unknown>\n> {\n nativeEvent: Readonly<HandlerStateChangeEventPayload & ExtraEventPayloadT>;\n}\n\nexport type TouchData = {\n id: number;\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\n\nexport type GestureTouchEvent = {\n handlerTag: number;\n numberOfTouches: number;\n state: ValueOf<typeof State>;\n eventType: TouchEventType;\n allTouches: TouchData[];\n changedTouches: TouchData[];\n};\n\nexport type GestureUpdateEvent<GestureEventPayloadT = Record<string, unknown>> =\n GestureEventPayload & GestureEventPayloadT;\n\nexport type GestureStateChangeEvent<\n GestureStateChangeEventPayloadT = Record<string, unknown>\n> = HandlerStateChangeEventPayload & GestureStateChangeEventPayloadT;\n\nexport type CommonGestureConfig = {\n enabled?: boolean;\n shouldCancelWhenOutside?: boolean;\n hitSlop?: HitSlop;\n userSelect?: UserSelect;\n activeCursor?: ActiveCursor;\n mouseButton?: MouseButton;\n enableContextMenu?: boolean;\n touchAction?: TouchAction;\n};\n\n// Events payloads are types instead of interfaces due to TS limitation.\n// See https://github.com/microsoft/TypeScript/issues/15300 for more info.\nexport type BaseGestureHandlerProps<\n ExtraEventPayloadT extends Record<string, unknown> = Record<string, unknown>\n> = CommonGestureConfig & {\n id?: string;\n waitFor?: React.Ref<unknown> | React.Ref<unknown>[];\n simultaneousHandlers?: React.Ref<unknown> | React.Ref<unknown>[];\n blocksHandlers?: React.Ref<unknown> | React.Ref<unknown>[];\n testID?: string;\n cancelsTouchesInView?: boolean;\n // TODO(TS) - fix event types\n onBegan?: (event: HandlerStateChangeEvent) => void;\n onFailed?: (event: HandlerStateChangeEvent) => void;\n onCancelled?: (event: HandlerStateChangeEvent) => void;\n onActivated?: (event: HandlerStateChangeEvent) => void;\n onEnded?: (event: HandlerStateChangeEvent) => void;\n\n //TODO(TS) consider using NativeSyntheticEvent\n onGestureEvent?: (event: GestureEvent<ExtraEventPayloadT>) => void;\n onHandlerStateChange?: (\n event: HandlerStateChangeEvent<ExtraEventPayloadT>\n ) => void;\n // implicit `children` prop has been removed in @types/react^18.0.0\n children?: React.ReactNode;\n};\n\nfunction isConfigParam(param: unknown, name: string) {\n // param !== Object(param) returns false if `param` is a function\n // or an object and returns true if `param` is null\n return (\n param !== undefined &&\n (param !== Object(param) ||\n !('__isNative' in (param as Record<string, unknown>))) &&\n name !== 'onHandlerStateChange' &&\n name !== 'onGestureEvent'\n );\n}\n\nexport function filterConfig(\n props: Record<string, unknown>,\n validProps: string[],\n defaults: Record<string, unknown> = {}\n) {\n const filteredConfig = { ...defaults };\n for (const key of validProps) {\n let value = props[key];\n if (isConfigParam(value, key)) {\n if (key === 'simultaneousHandlers' || key === 'waitFor') {\n value = transformIntoHandlerTags(props[key]);\n } else if (key === 'hitSlop' && typeof value !== 'object') {\n value = { top: value, left: value, bottom: value, right: value };\n }\n filteredConfig[key] = value;\n }\n }\n return filteredConfig;\n}\n\nfunction transformIntoHandlerTags(handlerIDs: any) {\n handlerIDs = toArray(handlerIDs);\n\n if (Platform.OS === 'web') {\n return handlerIDs\n .map(({ current }: { current: any }) => current)\n .filter((handle: any) => handle);\n }\n // converts handler string IDs into their numeric tags\n return handlerIDs\n .map(\n (handlerID: any) =>\n handlerIDToTag[handlerID] || handlerID.current?.handlerTag || -1\n )\n .filter((handlerTag: number) => handlerTag > 0);\n}\n\nexport function findNodeHandle(\n node: null | number | React.Component<any, any> | React.ComponentClass<any>\n): null | number | React.Component<any, any> | React.ComponentClass<any> {\n if (Platform.OS === 'web') {\n return node;\n }\n return findNodeHandleRN(node);\n}\n\nlet flushOperationsScheduled = false;\n\nexport function scheduleFlushOperations() {\n if (!flushOperationsScheduled) {\n flushOperationsScheduled = true;\n ghQueueMicrotask(() => {\n RNGestureHandlerModule.flushOperations();\n\n flushOperationsScheduled = false;\n });\n }\n}\n"]}
1
+ {"version":3,"sources":["gestureHandlerCommon.ts"],"names":["commonProps","componentInteractionProps","baseGestureHandlerProps","baseGestureHandlerWithDetectorProps","MouseButton","isConfigParam","param","name","undefined","Object","filterConfig","props","validProps","defaults","filteredConfig","key","value","transformIntoHandlerTags","top","left","bottom","right","handlerIDs","Platform","OS","map","current","filter","handle","handlerID","handlerIDToTag","handlerTag","findNodeHandle","node","flushOperationsScheduled","scheduleFlushOperations","RNGestureHandlerModule","flushOperations"],"mappings":";;;;;;;;;;AAKA;;AAKA;;AACA;;AACA;;AACA;;;;AAbA;AACA;AACA;AACA;AAaA,MAAMA,WAAW,GAAG,CAClB,IADkB,EAElB,SAFkB,EAGlB,yBAHkB,EAIlB,SAJkB,EAKlB,sBALkB,EAMlB,YANkB,EAOlB,cAPkB,EAQlB,aARkB,EASlB,mBATkB,EAUlB,aAVkB,CAApB;AAaA,MAAMC,yBAAyB,GAAG,CAChC,SADgC,EAEhC,sBAFgC,EAGhC,gBAHgC,CAAlC;AAMO,MAAMC,uBAAuB,GAAG,CACrC,GAAGF,WADkC,EAErC,GAAGC,yBAFkC,EAGrC,SAHqC,EAIrC,UAJqC,EAKrC,aALqC,EAMrC,aANqC,EAOrC,SAPqC,EAQrC,gBARqC,EASrC,sBATqC,CAAhC;;AAYA,MAAME,mCAAmC,GAAG,CACjD,GAAGH,WAD8C,EAEjD,kBAFiD,EAGjD,kBAHiD,CAA5C;;IAsEKI,W;;;WAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA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R,CAAb;;AAEA,MAAIC,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzB,WAAOF,UAAU,CACdG,GADI,CACA,CAAC;AAAEC,MAAAA;AAAF,KAAD,KAAmCA,OADnC,EAEJC,MAFI,CAEIC,MAAD,IAAiBA,MAFpB,CAAP;AAGD,GAPgD,CAQjD;;;AACA,SAAON,UAAU,CACdG,GADI,CAEFI,SAAD;AAAA;;AAAA,WACEC,iCAAeD,SAAf,4BAA6BA,SAAS,CAACH,OAAvC,uDAA6B,mBAAmBK,UAAhD,KAA8D,CAAC,CADjE;AAAA,GAFG,EAKJJ,MALI,CAKII,UAAD,IAAwBA,UAAU,GAAG,CALxC,CAAP;AAMD;;AAEM,SAASC,cAAT,CACLC,IADK,EAEkE;AACvE,MAAIV,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzB,WAAOS,IAAP;AACD;;AACD,SAAO,iCAAiBA,IAAjB,CAAP;AACD;;AAED,IAAIC,wBAAwB,GAAG,KAA/B;;AAEO,SAASC,uBAAT,GAAmC;AACxC,MAAI,CAACD,wBAAL,EAA+B;AAC7BA,IAAAA,wBAAwB,GAAG,IAA3B;AACA,4CAAiB,MAAM;AACrBE,sCAAuBC,eAAvB;;AAEAH,MAAAA,wBAAwB,GAAG,KAA3B;AACD,KAJD;AAKD;AACF","sourcesContent":["// Previous types exported gesture handlers as classes which creates an interface and variable, both named the same as class.\n// Without those types, we'd introduce breaking change, forcing users to prefix every handler type specification with typeof\n// e.g. React.createRef<TapGestureHandler> -> React.createRef<typeof TapGestureHandler>.\n// See https://www.typescriptlang.org/docs/handbook/classes.html#constructor-functions for reference.\nimport * as React from 'react';\nimport { Platform, findNodeHandle as findNodeHandleRN } from 'react-native';\n\nimport { State } from '../State';\nimport { TouchEventType } from '../TouchEventType';\nimport { ValueOf } from '../typeUtils';\nimport { handlerIDToTag } from './handlersRegistry';\nimport { toArray } from '../utils';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\nimport { ghQueueMicrotask } from '../ghQueueMicrotask';\nimport { PointerType } from '../PointerType';\n\nconst commonProps = [\n 'id',\n 'enabled',\n 'shouldCancelWhenOutside',\n 'hitSlop',\n 'cancelsTouchesInView',\n 'userSelect',\n 'activeCursor',\n 'mouseButton',\n 'enableContextMenu',\n 'touchAction',\n] as const;\n\nconst componentInteractionProps = [\n 'waitFor',\n 'simultaneousHandlers',\n 'blocksHandlers',\n] as const;\n\nexport const baseGestureHandlerProps = [\n ...commonProps,\n ...componentInteractionProps,\n 'onBegan',\n 'onFailed',\n 'onCancelled',\n 'onActivated',\n 'onEnded',\n 'onGestureEvent',\n 'onHandlerStateChange',\n] as const;\n\nexport const baseGestureHandlerWithDetectorProps = [\n ...commonProps,\n 'needsPointerData',\n 'manualActivation',\n];\n\nexport interface GestureEventPayload {\n handlerTag: number;\n numberOfPointers: number;\n state: ValueOf<typeof State>;\n pointerType: PointerType;\n}\nexport interface HandlerStateChangeEventPayload extends GestureEventPayload {\n oldState: ValueOf<typeof State>;\n}\n\nexport type HitSlop =\n | number\n | null\n | undefined\n | Partial<\n Record<\n 'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal',\n number\n >\n >\n | Record<'width' | 'left', number>\n | Record<'width' | 'right', number>\n | Record<'height' | 'top', number>\n | Record<'height' | 'bottom', number>;\n\nexport type UserSelect = 'none' | 'auto' | 'text';\nexport type ActiveCursor =\n | 'auto'\n | 'default'\n | 'none'\n | 'context-menu'\n | 'help'\n | 'pointer'\n | 'progress'\n | 'wait'\n | 'cell'\n | 'crosshair'\n | 'text'\n | 'vertical-text'\n | 'alias'\n | 'copy'\n | 'move'\n | 'no-drop'\n | 'not-allowed'\n | 'grab'\n | 'grabbing'\n | 'e-resize'\n | 'n-resize'\n | 'ne-resize'\n | 'nw-resize'\n | 's-resize'\n | 'se-resize'\n | 'sw-resize'\n | 'w-resize'\n | 'ew-resize'\n | 'ns-resize'\n | 'nesw-resize'\n | 'nwse-resize'\n | 'col-resize'\n | 'row-resize'\n | 'all-scroll'\n | 'zoom-in'\n | 'zoom-out';\n\nexport enum MouseButton {\n LEFT = 1,\n RIGHT = 2,\n MIDDLE = 4,\n BUTTON_4 = 8,\n BUTTON_5 = 16,\n ALL = 31,\n}\n\nexport type TouchAction =\n | 'auto'\n | 'none'\n | 'pan-x'\n | 'pan-left'\n | 'pan-right'\n | 'pan-y'\n | 'pan-up'\n | 'pan-down'\n | 'pinch-zoom'\n | 'manipulation'\n | 'inherit'\n | 'initial'\n | 'revert'\n | 'revert-layer'\n | 'unset';\n\n//TODO(TS) events in handlers\n\nexport interface GestureEvent<ExtraEventPayloadT = Record<string, unknown>> {\n nativeEvent: Readonly<GestureEventPayload & ExtraEventPayloadT>;\n}\nexport interface HandlerStateChangeEvent<\n ExtraEventPayloadT = Record<string, unknown>\n> {\n nativeEvent: Readonly<HandlerStateChangeEventPayload & ExtraEventPayloadT>;\n}\n\nexport type TouchData = {\n id: number;\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\n\nexport type GestureTouchEvent = {\n handlerTag: number;\n numberOfTouches: number;\n state: ValueOf<typeof State>;\n eventType: TouchEventType;\n allTouches: TouchData[];\n changedTouches: TouchData[];\n pointerType: PointerType;\n};\n\nexport type GestureUpdateEvent<GestureEventPayloadT = Record<string, unknown>> =\n GestureEventPayload & GestureEventPayloadT;\n\nexport type GestureStateChangeEvent<\n GestureStateChangeEventPayloadT = Record<string, unknown>\n> = HandlerStateChangeEventPayload & GestureStateChangeEventPayloadT;\n\nexport type CommonGestureConfig = {\n enabled?: boolean;\n shouldCancelWhenOutside?: boolean;\n hitSlop?: HitSlop;\n userSelect?: UserSelect;\n activeCursor?: ActiveCursor;\n mouseButton?: MouseButton;\n enableContextMenu?: boolean;\n touchAction?: TouchAction;\n};\n\n// Events payloads are types instead of interfaces due to TS limitation.\n// See https://github.com/microsoft/TypeScript/issues/15300 for more info.\nexport type BaseGestureHandlerProps<\n ExtraEventPayloadT extends Record<string, unknown> = Record<string, unknown>\n> = CommonGestureConfig & {\n id?: string;\n waitFor?: React.Ref<unknown> | React.Ref<unknown>[];\n simultaneousHandlers?: React.Ref<unknown> | React.Ref<unknown>[];\n blocksHandlers?: React.Ref<unknown> | React.Ref<unknown>[];\n testID?: string;\n cancelsTouchesInView?: boolean;\n // TODO(TS) - fix event types\n onBegan?: (event: HandlerStateChangeEvent) => void;\n onFailed?: (event: HandlerStateChangeEvent) => void;\n onCancelled?: (event: HandlerStateChangeEvent) => void;\n onActivated?: (event: HandlerStateChangeEvent) => void;\n onEnded?: (event: HandlerStateChangeEvent) => void;\n\n //TODO(TS) consider using NativeSyntheticEvent\n onGestureEvent?: (event: GestureEvent<ExtraEventPayloadT>) => void;\n onHandlerStateChange?: (\n event: HandlerStateChangeEvent<ExtraEventPayloadT>\n ) => void;\n // implicit `children` prop has been removed in @types/react^18.0.0\n children?: React.ReactNode;\n};\n\nfunction isConfigParam(param: unknown, name: string) {\n // param !== Object(param) returns false if `param` is a function\n // or an object and returns true if `param` is null\n return (\n param !== undefined &&\n (param !== Object(param) ||\n !('__isNative' in (param as Record<string, unknown>))) &&\n name !== 'onHandlerStateChange' &&\n name !== 'onGestureEvent'\n );\n}\n\nexport function filterConfig(\n props: Record<string, unknown>,\n validProps: string[],\n defaults: Record<string, unknown> = {}\n) {\n const filteredConfig = { ...defaults };\n for (const key of validProps) {\n let value = props[key];\n if (isConfigParam(value, key)) {\n if (key === 'simultaneousHandlers' || key === 'waitFor') {\n value = transformIntoHandlerTags(props[key]);\n } else if (key === 'hitSlop' && typeof value !== 'object') {\n value = { top: value, left: value, bottom: value, right: value };\n }\n filteredConfig[key] = value;\n }\n }\n return filteredConfig;\n}\n\nfunction transformIntoHandlerTags(handlerIDs: any) {\n handlerIDs = toArray(handlerIDs);\n\n if (Platform.OS === 'web') {\n return handlerIDs\n .map(({ current }: { current: any }) => current)\n .filter((handle: any) => handle);\n }\n // converts handler string IDs into their numeric tags\n return handlerIDs\n .map(\n (handlerID: any) =>\n handlerIDToTag[handlerID] || handlerID.current?.handlerTag || -1\n )\n .filter((handlerTag: number) => handlerTag > 0);\n}\n\nexport function findNodeHandle(\n node: null | number | React.Component<any, any> | React.ComponentClass<any>\n): null | number | React.Component<any, any> | React.ComponentClass<any> {\n if (Platform.OS === 'web') {\n return node;\n }\n return findNodeHandleRN(node);\n}\n\nlet flushOperationsScheduled = false;\n\nexport function scheduleFlushOperations() {\n if (!flushOperationsScheduled) {\n flushOperationsScheduled = true;\n ghQueueMicrotask(() => {\n RNGestureHandlerModule.flushOperations();\n\n flushOperationsScheduled = false;\n });\n }\n}\n"]}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AnimatedWrap = exports.Wrap = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _reanimatedWrapper = require("../reanimatedWrapper");
11
+
12
+ var _utils = require("../../../utils");
13
+
14
+ var _Reanimated$default$c, _Reanimated$default;
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ class Wrap extends _react.default.Component {
19
+ render() {
20
+ try {
21
+ // I don't think that fighting with types over such a simple function is worth it
22
+ // The only thing it does is add 'collapsable: false' to the child component
23
+ // to make sure it is in the native view hierarchy so the detector can find
24
+ // correct viewTag to attach to.
25
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
+ const child = _react.default.Children.only(this.props.children);
27
+
28
+ return /*#__PURE__*/_react.default.cloneElement(child, {
29
+ collapsable: false
30
+ }, // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
31
+ child.props.children);
32
+ } catch (e) {
33
+ throw new Error((0, _utils.tagMessage)(`GestureDetector got more than one view as a child. If you want the gesture to work on multiple views, wrap them with a common parent and attach the gesture to that view.`));
34
+ }
35
+ }
36
+
37
+ }
38
+
39
+ exports.Wrap = Wrap;
40
+ const AnimatedWrap = (_Reanimated$default$c = _reanimatedWrapper.Reanimated === null || _reanimatedWrapper.Reanimated === void 0 ? void 0 : (_Reanimated$default = _reanimatedWrapper.Reanimated.default) === null || _Reanimated$default === void 0 ? void 0 : _Reanimated$default.createAnimatedComponent(Wrap)) !== null && _Reanimated$default$c !== void 0 ? _Reanimated$default$c : Wrap;
41
+ exports.AnimatedWrap = AnimatedWrap;
42
+ //# sourceMappingURL=Wrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["Wrap.tsx"],"names":["Wrap","React","Component","render","child","Children","only","props","children","cloneElement","collapsable","e","Error","AnimatedWrap","Reanimated","default","createAnimatedComponent"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;AAEO,MAAMA,IAAN,SAAmBC,eAAMC,SAAzB,CAIJ;AACDC,EAAAA,MAAM,GAAG;AACP,QAAI;AACF;AACA;AACA;AACA;AACA;AACA,YAAMC,KAAU,GAAGH,eAAMI,QAAN,CAAeC,IAAf,CAAoB,KAAKC,KAAL,CAAWC,QAA/B,CAAnB;;AACA,0BAAOP,eAAMQ,YAAN,CACLL,KADK,EAEL;AAAEM,QAAAA,WAAW,EAAE;AAAf,OAFK,EAGL;AACAN,MAAAA,KAAK,CAACG,KAAN,CAAYC,QAJP,CAAP;AAMD,KAbD,CAaE,OAAOG,CAAP,EAAU;AACV,YAAM,IAAIC,KAAJ,CACJ,uBACG,2KADH,CADI,CAAN;AAKD;AACF;;AAtBA;;;AAyBI,MAAMC,YAAY,4BACvBC,6BADuB,aACvBA,6BADuB,8CACvBA,8BAAYC,OADW,wDACvB,oBAAqBC,uBAArB,CAA6ChB,IAA7C,CADuB,yEAC+BA,IADjD","sourcesContent":["import React from 'react';\nimport { Reanimated } from '../reanimatedWrapper';\nimport { tagMessage } from '../../../utils';\n\nexport class Wrap extends React.Component<{\n onGestureHandlerEvent?: unknown;\n // implicit `children` prop has been removed in @types/react^18.0.0\n children?: React.ReactNode;\n}> {\n render() {\n try {\n // I don't think that fighting with types over such a simple function is worth it\n // The only thing it does is add 'collapsable: false' to the child component\n // to make sure it is in the native view hierarchy so the detector can find\n // correct viewTag to attach to.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const child: any = React.Children.only(this.props.children);\n return React.cloneElement(\n child,\n { collapsable: false },\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n child.props.children\n );\n } catch (e) {\n throw new Error(\n tagMessage(\n `GestureDetector got more than one view as a child. If you want the gesture to work on multiple views, wrap them with a common parent and attach the gesture to that view.`\n )\n );\n }\n }\n}\n\nexport const AnimatedWrap =\n Reanimated?.default?.createAnimatedComponent(Wrap) ?? Wrap;\n"]}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.attachHandlers = attachHandlers;
7
+
8
+ var _handlersRegistry = require("../../handlersRegistry");
9
+
10
+ var _RNGestureHandlerModule = _interopRequireDefault(require("../../../RNGestureHandlerModule"));
11
+
12
+ var _gestureHandlerCommon = require("../../gestureHandlerCommon");
13
+
14
+ var _ActionType = require("../../../ActionType");
15
+
16
+ var _reactNative = require("react-native");
17
+
18
+ var _ghQueueMicrotask = require("../../../ghQueueMicrotask");
19
+
20
+ var _utils = require("./utils");
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+
24
+ function attachHandlers({
25
+ preparedGesture,
26
+ gestureConfig,
27
+ gesturesToAttach,
28
+ viewTag,
29
+ webEventHandlersRef
30
+ }) {
31
+ gestureConfig.initialize(); // use queueMicrotask to extract handlerTags, because all refs should be initialized
32
+ // when it's ran
33
+
34
+ (0, _ghQueueMicrotask.ghQueueMicrotask)(() => {
35
+ if (!preparedGesture.isMounted) {
36
+ return;
37
+ }
38
+
39
+ gestureConfig.prepare();
40
+ });
41
+
42
+ for (const handler of gesturesToAttach) {
43
+ (0, _utils.checkGestureCallbacksForWorklets)(handler);
44
+
45
+ _RNGestureHandlerModule.default.createGestureHandler(handler.handlerName, handler.handlerTag, (0, _gestureHandlerCommon.filterConfig)(handler.config, _utils.ALLOWED_PROPS));
46
+
47
+ (0, _handlersRegistry.registerHandler)(handler.handlerTag, handler, handler.config.testId);
48
+ } // use queueMicrotask to extract handlerTags, because all refs should be initialized
49
+ // when it's ran
50
+
51
+
52
+ (0, _ghQueueMicrotask.ghQueueMicrotask)(() => {
53
+ if (!preparedGesture.isMounted) {
54
+ return;
55
+ }
56
+
57
+ for (const handler of gesturesToAttach) {
58
+ _RNGestureHandlerModule.default.updateGestureHandler(handler.handlerTag, (0, _gestureHandlerCommon.filterConfig)(handler.config, _utils.ALLOWED_PROPS, (0, _utils.extractGestureRelations)(handler)));
59
+ }
60
+
61
+ (0, _gestureHandlerCommon.scheduleFlushOperations)();
62
+ });
63
+
64
+ for (const gesture of gesturesToAttach) {
65
+ const actionType = gesture.shouldUseReanimated ? _ActionType.ActionType.REANIMATED_WORKLET : _ActionType.ActionType.JS_FUNCTION_NEW_API;
66
+
67
+ if (_reactNative.Platform.OS === 'web') {
68
+ _RNGestureHandlerModule.default.attachGestureHandler(gesture.handlerTag, viewTag, _ActionType.ActionType.JS_FUNCTION_OLD_API, // ignored on web
69
+ webEventHandlersRef);
70
+ } else {
71
+ _RNGestureHandlerModule.default.attachGestureHandler(gesture.handlerTag, viewTag, actionType);
72
+ }
73
+ }
74
+
75
+ preparedGesture.attachedGestures = gesturesToAttach;
76
+
77
+ if (preparedGesture.animatedHandlers) {
78
+ const isAnimatedGesture = g => g.shouldUseReanimated;
79
+
80
+ preparedGesture.animatedHandlers.value = gesturesToAttach.filter(isAnimatedGesture).map(g => g.handlers);
81
+ }
82
+ }
83
+ //# sourceMappingURL=attachHandlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["attachHandlers.ts"],"names":["attachHandlers","preparedGesture","gestureConfig","gesturesToAttach","viewTag","webEventHandlersRef","initialize","isMounted","prepare","handler","RNGestureHandlerModule","createGestureHandler","handlerName","handlerTag","config","ALLOWED_PROPS","testId","updateGestureHandler","gesture","actionType","shouldUseReanimated","ActionType","REANIMATED_WORKLET","JS_FUNCTION_NEW_API","Platform","OS","attachGestureHandler","JS_FUNCTION_OLD_API","attachedGestures","animatedHandlers","isAnimatedGesture","g","value","filter","map","handlers"],"mappings":";;;;;;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AAEA;;AAEA;;;;AAcO,SAASA,cAAT,CAAwB;AAC7BC,EAAAA,eAD6B;AAE7BC,EAAAA,aAF6B;AAG7BC,EAAAA,gBAH6B;AAI7BC,EAAAA,OAJ6B;AAK7BC,EAAAA;AAL6B,CAAxB,EAMkB;AACvBH,EAAAA,aAAa,CAACI,UAAd,GADuB,CAGvB;AACA;;AACA,0CAAiB,MAAM;AACrB,QAAI,CAACL,eAAe,CAACM,SAArB,EAAgC;AAC9B;AACD;;AACDL,IAAAA,aAAa,CAACM,OAAd;AACD,GALD;;AAOA,OAAK,MAAMC,OAAX,IAAsBN,gBAAtB,EAAwC;AACtC,iDAAiCM,OAAjC;;AACAC,oCAAuBC,oBAAvB,CACEF,OAAO,CAACG,WADV,EAEEH,OAAO,CAACI,UAFV,EAGE,wCAAaJ,OAAO,CAACK,MAArB,EAA6BC,oBAA7B,CAHF;;AAMA,2CAAgBN,OAAO,CAACI,UAAxB,EAAoCJ,OAApC,EAA6CA,OAAO,CAACK,MAAR,CAAeE,MAA5D;AACD,GArBsB,CAuBvB;AACA;;;AACA,0CAAiB,MAAM;AACrB,QAAI,CAACf,eAAe,CAACM,SAArB,EAAgC;AAC9B;AACD;;AACD,SAAK,MAAME,OAAX,IAAsBN,gBAAtB,EAAwC;AACtCO,sCAAuBO,oBAAvB,CACER,OAAO,CAACI,UADV,EAEE,wCACEJ,OAAO,CAACK,MADV,EAEEC,oBAFF,EAGE,oCAAwBN,OAAxB,CAHF,CAFF;AAQD;;AAED;AACD,GAhBD;;AAkBA,OAAK,MAAMS,OAAX,IAAsBf,gBAAtB,EAAwC;AACtC,UAAMgB,UAAU,GAAGD,OAAO,CAACE,mBAAR,GACfC,uBAAWC,kBADI,GAEfD,uBAAWE,mBAFf;;AAIA,QAAIC,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AAEvBf,sCAAuBgB,oBADzB,CAGER,OAAO,CAACL,UAHV,EAIET,OAJF,EAKEiB,uBAAWM,mBALb,EAKkC;AAChCtB,MAAAA,mBANF;AAQD,KATD,MASO;AACLK,sCAAuBgB,oBAAvB,CACER,OAAO,CAACL,UADV,EAEET,OAFF,EAGEe,UAHF;AAKD;AACF;;AAEDlB,EAAAA,eAAe,CAAC2B,gBAAhB,GAAmCzB,gBAAnC;;AAEA,MAAIF,eAAe,CAAC4B,gBAApB,EAAsC;AACpC,UAAMC,iBAAiB,GAAIC,CAAD,IAAoBA,CAAC,CAACX,mBAAhD;;AAEAnB,IAAAA,eAAe,CAAC4B,gBAAhB,CAAiCG,KAAjC,GAAyC7B,gBAAgB,CACtD8B,MADsC,CAC/BH,iBAD+B,EAEtCI,GAFsC,CAEjCH,CAAD,IAAOA,CAAC,CAACI,QAFyB,CAAzC;AAKD;AACF","sourcesContent":["import React from 'react';\nimport { GestureType, HandlerCallbacks } from '../gesture';\nimport { registerHandler } from '../../handlersRegistry';\nimport RNGestureHandlerModule from '../../../RNGestureHandlerModule';\nimport {\n filterConfig,\n scheduleFlushOperations,\n} from '../../gestureHandlerCommon';\nimport { ComposedGesture } from '../gestureComposition';\nimport { ActionType } from '../../../ActionType';\nimport { Platform } from 'react-native';\nimport type RNGestureHandlerModuleWeb from '../../../RNGestureHandlerModule.web';\nimport { ghQueueMicrotask } from '../../../ghQueueMicrotask';\nimport { AttachedGestureState, WebEventHandler } from './types';\nimport {\n extractGestureRelations,\n checkGestureCallbacksForWorklets,\n ALLOWED_PROPS,\n} from './utils';\n\ninterface AttachHandlersConfig {\n preparedGesture: AttachedGestureState;\n gestureConfig: ComposedGesture | GestureType;\n gesturesToAttach: GestureType[];\n viewTag: number;\n webEventHandlersRef: React.RefObject<WebEventHandler>;\n}\n\nexport function attachHandlers({\n preparedGesture,\n gestureConfig,\n gesturesToAttach,\n viewTag,\n webEventHandlersRef,\n}: AttachHandlersConfig) {\n gestureConfig.initialize();\n\n // use queueMicrotask to extract handlerTags, because all refs should be initialized\n // when it's ran\n ghQueueMicrotask(() => {\n if (!preparedGesture.isMounted) {\n return;\n }\n gestureConfig.prepare();\n });\n\n for (const handler of gesturesToAttach) {\n checkGestureCallbacksForWorklets(handler);\n RNGestureHandlerModule.createGestureHandler(\n handler.handlerName,\n handler.handlerTag,\n filterConfig(handler.config, ALLOWED_PROPS)\n );\n\n registerHandler(handler.handlerTag, handler, handler.config.testId);\n }\n\n // use queueMicrotask to extract handlerTags, because all refs should be initialized\n // when it's ran\n ghQueueMicrotask(() => {\n if (!preparedGesture.isMounted) {\n return;\n }\n for (const handler of gesturesToAttach) {\n RNGestureHandlerModule.updateGestureHandler(\n handler.handlerTag,\n filterConfig(\n handler.config,\n ALLOWED_PROPS,\n extractGestureRelations(handler)\n )\n );\n }\n\n scheduleFlushOperations();\n });\n\n for (const gesture of gesturesToAttach) {\n const actionType = gesture.shouldUseReanimated\n ? ActionType.REANIMATED_WORKLET\n : ActionType.JS_FUNCTION_NEW_API;\n\n if (Platform.OS === 'web') {\n (\n RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler\n )(\n gesture.handlerTag,\n viewTag,\n ActionType.JS_FUNCTION_OLD_API, // ignored on web\n webEventHandlersRef\n );\n } else {\n RNGestureHandlerModule.attachGestureHandler(\n gesture.handlerTag,\n viewTag,\n actionType\n );\n }\n }\n\n preparedGesture.attachedGestures = gesturesToAttach;\n\n if (preparedGesture.animatedHandlers) {\n const isAnimatedGesture = (g: GestureType) => g.shouldUseReanimated;\n\n preparedGesture.animatedHandlers.value = gesturesToAttach\n .filter(isAnimatedGesture)\n .map((g) => g.handlers) as unknown as HandlerCallbacks<\n Record<string, unknown>\n >[];\n }\n}\n"]}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.dropHandlers = dropHandlers;
7
+
8
+ var _handlersRegistry = require("../../handlersRegistry");
9
+
10
+ var _RNGestureHandlerModule = _interopRequireDefault(require("../../../RNGestureHandlerModule"));
11
+
12
+ var _gestureHandlerCommon = require("../../gestureHandlerCommon");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ function dropHandlers(preparedGesture) {
17
+ for (const handler of preparedGesture.attachedGestures) {
18
+ _RNGestureHandlerModule.default.dropGestureHandler(handler.handlerTag);
19
+
20
+ (0, _handlersRegistry.unregisterHandler)(handler.handlerTag, handler.config.testId);
21
+ }
22
+
23
+ (0, _gestureHandlerCommon.scheduleFlushOperations)();
24
+ }
25
+ //# sourceMappingURL=dropHandlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["dropHandlers.ts"],"names":["dropHandlers","preparedGesture","handler","attachedGestures","RNGestureHandlerModule","dropGestureHandler","handlerTag","config","testId"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAGO,SAASA,YAAT,CAAsBC,eAAtB,EAA6D;AAClE,OAAK,MAAMC,OAAX,IAAsBD,eAAe,CAACE,gBAAtC,EAAwD;AACtDC,oCAAuBC,kBAAvB,CAA0CH,OAAO,CAACI,UAAlD;;AAEA,6CAAkBJ,OAAO,CAACI,UAA1B,EAAsCJ,OAAO,CAACK,MAAR,CAAeC,MAArD;AACD;;AAED;AACD","sourcesContent":["import { unregisterHandler } from '../../handlersRegistry';\nimport RNGestureHandlerModule from '../../../RNGestureHandlerModule';\nimport { scheduleFlushOperations } from '../../gestureHandlerCommon';\nimport { AttachedGestureState } from './types';\n\nexport function dropHandlers(preparedGesture: AttachedGestureState) {\n for (const handler of preparedGesture.attachedGestures) {\n RNGestureHandlerModule.dropGestureHandler(handler.handlerTag);\n\n unregisterHandler(handler.handlerTag, handler.config.testId);\n }\n\n scheduleFlushOperations();\n}\n"]}