react-native-gesture-handler 2.4.1 → 2.6.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 (382) hide show
  1. package/README.md +4 -2
  2. package/RNGestureHandler.podspec +17 -5
  3. package/android/build.gradle +71 -15
  4. package/android/lib/src/main/java/com/swmansion/gesturehandler/FlingGestureHandler.kt +2 -1
  5. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +9 -5
  6. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.kt +32 -6
  7. package/android/lib/src/main/java/com/swmansion/gesturehandler/LongPressGestureHandler.kt +5 -2
  8. package/android/lib/src/main/java/com/swmansion/gesturehandler/NativeViewGestureHandler.kt +105 -23
  9. package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.kt +30 -2
  10. package/android/lib/src/main/java/com/swmansion/gesturehandler/TapGestureHandler.kt +3 -2
  11. package/android/src/fabric/java/com/swmansion/gesturehandler/RNGestureHandlerComponentsRegistry.java +1 -1
  12. package/android/src/main/java/com/swmansion/gesturehandler/RNGestureHandlerPackage.kt +0 -8
  13. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +74 -84
  14. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt +7 -1
  15. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +5 -1
  16. package/android/src/main/jni/CMakeLists.txt +59 -0
  17. package/android/src/paper/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +12 -9
  18. package/android/src/paper/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerInterface.java +1 -0
  19. package/ios/Handlers/RNFlingHandler.m +43 -1
  20. package/ios/Handlers/{RNNativeViewHandler.m → RNNativeViewHandler.mm} +13 -1
  21. package/ios/Handlers/RNPanHandler.m +27 -0
  22. package/ios/RNGestureHandler.h +1 -0
  23. package/ios/RNGestureHandler.m +22 -4
  24. package/ios/RNGestureHandlerButtonComponentView.mm +1 -1
  25. package/ios/RNGestureHandlerManager.mm +10 -7
  26. package/ios/RNGestureHandlerModule.mm +4 -1
  27. package/ios/RNGestureHandlerRootViewComponentView.mm +1 -1
  28. package/ios/RNManualActivationRecognizer.m +10 -3
  29. package/ios/RNRootViewGestureRecognizer.m +12 -1
  30. package/lib/commonjs/EnableExperimentalWebImplementation.js +24 -0
  31. package/lib/commonjs/EnableExperimentalWebImplementation.js.map +1 -0
  32. package/lib/commonjs/RNGestureHandlerModule.macos.js +138 -0
  33. package/lib/commonjs/RNGestureHandlerModule.macos.js.map +1 -0
  34. package/lib/commonjs/RNGestureHandlerModule.web.js +87 -25
  35. package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
  36. package/lib/commonjs/RNRenderer.js +16 -0
  37. package/lib/commonjs/RNRenderer.js.map +1 -0
  38. package/lib/commonjs/RNRenderer.web.js +11 -0
  39. package/lib/commonjs/RNRenderer.web.js.map +1 -0
  40. package/lib/commonjs/components/DrawerLayout.js +41 -12
  41. package/lib/commonjs/components/DrawerLayout.js.map +1 -1
  42. package/lib/commonjs/components/GestureButtons.js +42 -9
  43. package/lib/commonjs/components/GestureButtons.js.map +1 -1
  44. package/lib/commonjs/components/GestureComponents.js +41 -4
  45. package/lib/commonjs/components/GestureComponents.js.map +1 -1
  46. package/lib/commonjs/components/GestureComponents.web.js +7 -2
  47. package/lib/commonjs/components/GestureComponents.web.js.map +1 -1
  48. package/lib/commonjs/components/Swipeable.js +3 -1
  49. package/lib/commonjs/components/Swipeable.js.map +1 -1
  50. package/lib/commonjs/components/touchables/GenericTouchable.js +5 -1
  51. package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
  52. package/lib/commonjs/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -1
  53. package/lib/commonjs/handlers/ForceTouchGestureHandler.js +2 -1
  54. package/lib/commonjs/handlers/ForceTouchGestureHandler.js.map +1 -1
  55. package/lib/commonjs/handlers/PanGestureHandler.js +1 -1
  56. package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -1
  57. package/lib/commonjs/handlers/PressabilityDebugView.js +14 -0
  58. package/lib/commonjs/handlers/PressabilityDebugView.js.map +1 -0
  59. package/lib/commonjs/handlers/PressabilityDebugView.web.js +12 -0
  60. package/lib/commonjs/handlers/PressabilityDebugView.web.js.map +1 -0
  61. package/lib/commonjs/handlers/createHandler.js +33 -12
  62. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  63. package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
  64. package/lib/commonjs/handlers/gestures/GestureDetector.js +150 -75
  65. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
  66. package/lib/commonjs/handlers/gestures/gesture.js +13 -2
  67. package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
  68. package/lib/commonjs/handlers/gestures/gestureStateManager.js +13 -9
  69. package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -1
  70. package/lib/commonjs/handlers/gestures/panGesture.js +5 -0
  71. package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -1
  72. package/lib/commonjs/handlers/gestures/reanimatedWrapper.js +7 -0
  73. package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -1
  74. package/lib/commonjs/index.js +14 -0
  75. package/lib/commonjs/index.js.map +1 -1
  76. package/lib/commonjs/utils.js +6 -3
  77. package/lib/commonjs/utils.js.map +1 -1
  78. package/lib/commonjs/web/constants.js +3 -51
  79. package/lib/commonjs/web/constants.js.map +1 -1
  80. package/lib/commonjs/web/detectors/RotationGestureDetector.js +169 -0
  81. package/lib/commonjs/web/detectors/RotationGestureDetector.js.map +1 -0
  82. package/lib/commonjs/web/detectors/ScaleGestureDetector.js +167 -0
  83. package/lib/commonjs/web/detectors/ScaleGestureDetector.js.map +1 -0
  84. package/lib/commonjs/web/handlers/FlingGestureHandler.js +154 -0
  85. package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -0
  86. package/lib/commonjs/web/handlers/GestureHandler.js +538 -0
  87. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -0
  88. package/lib/commonjs/web/handlers/LongPressGestureHandler.js +147 -0
  89. package/lib/commonjs/web/handlers/LongPressGestureHandler.js.map +1 -0
  90. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +116 -0
  91. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -0
  92. package/lib/commonjs/web/handlers/PanGestureHandler.js +451 -0
  93. package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -0
  94. package/lib/commonjs/web/handlers/PinchGestureHandler.js +171 -0
  95. package/lib/commonjs/web/handlers/PinchGestureHandler.js.map +1 -0
  96. package/lib/commonjs/web/handlers/RotationGestureHandler.js +187 -0
  97. package/lib/commonjs/web/handlers/RotationGestureHandler.js.map +1 -0
  98. package/lib/commonjs/web/handlers/TapGestureHandler.js +296 -0
  99. package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -0
  100. package/lib/commonjs/web/interfaces.js +34 -0
  101. package/lib/commonjs/web/interfaces.js.map +1 -0
  102. package/lib/commonjs/web/tools/EventManager.js +169 -0
  103. package/lib/commonjs/web/tools/EventManager.js.map +1 -0
  104. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +283 -0
  105. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -0
  106. package/lib/commonjs/web/tools/InteractionManager.js +102 -0
  107. package/lib/commonjs/web/tools/InteractionManager.js.map +1 -0
  108. package/lib/commonjs/web/tools/NodeManager.js +48 -0
  109. package/lib/commonjs/web/tools/NodeManager.js.map +1 -0
  110. package/lib/commonjs/web/tools/PointerTracker.js +132 -0
  111. package/lib/commonjs/web/tools/PointerTracker.js.map +1 -0
  112. package/lib/commonjs/{web → web_hammer}/DiscreteGestureHandler.js +0 -0
  113. package/lib/commonjs/{web → web_hammer}/DiscreteGestureHandler.js.map +0 -0
  114. package/lib/commonjs/{web → web_hammer}/DraggingGestureHandler.js +0 -0
  115. package/lib/commonjs/{web → web_hammer}/DraggingGestureHandler.js.map +0 -0
  116. package/lib/commonjs/{web → web_hammer}/Errors.js +0 -0
  117. package/lib/commonjs/{web → web_hammer}/Errors.js.map +0 -0
  118. package/lib/commonjs/{web → web_hammer}/FlingGestureHandler.js +0 -0
  119. package/lib/commonjs/{web → web_hammer}/FlingGestureHandler.js.map +0 -0
  120. package/lib/commonjs/{web → web_hammer}/GestureHandler.js +83 -42
  121. package/lib/commonjs/web_hammer/GestureHandler.js.map +1 -0
  122. package/lib/commonjs/{web → web_hammer}/IndiscreteGestureHandler.js +0 -0
  123. package/lib/commonjs/{web → web_hammer}/IndiscreteGestureHandler.js.map +0 -0
  124. package/lib/commonjs/{web → web_hammer}/LongPressGestureHandler.js +0 -0
  125. package/lib/commonjs/{web → web_hammer}/LongPressGestureHandler.js.map +0 -0
  126. package/lib/commonjs/{web → web_hammer}/NativeViewGestureHandler.js +4 -0
  127. package/lib/commonjs/web_hammer/NativeViewGestureHandler.js.map +1 -0
  128. package/lib/commonjs/{web → web_hammer}/NodeManager.js +0 -0
  129. package/lib/commonjs/web_hammer/NodeManager.js.map +1 -0
  130. package/lib/commonjs/{web → web_hammer}/PanGestureHandler.js +0 -0
  131. package/lib/commonjs/{web → web_hammer}/PanGestureHandler.js.map +0 -0
  132. package/lib/commonjs/{web → web_hammer}/PinchGestureHandler.js +0 -0
  133. package/lib/commonjs/{web → web_hammer}/PinchGestureHandler.js.map +0 -0
  134. package/lib/commonjs/{web → web_hammer}/PressGestureHandler.js +0 -0
  135. package/lib/commonjs/{web → web_hammer}/PressGestureHandler.js.map +0 -0
  136. package/lib/commonjs/{web → web_hammer}/RotationGestureHandler.js +0 -0
  137. package/lib/commonjs/{web → web_hammer}/RotationGestureHandler.js.map +0 -0
  138. package/lib/commonjs/{web → web_hammer}/TapGestureHandler.js +0 -0
  139. package/lib/commonjs/{web → web_hammer}/TapGestureHandler.js.map +0 -0
  140. package/lib/commonjs/web_hammer/constants.js +64 -0
  141. package/lib/commonjs/web_hammer/constants.js.map +1 -0
  142. package/lib/commonjs/{web → web_hammer}/utils.js +0 -0
  143. package/lib/commonjs/{web → web_hammer}/utils.js.map +1 -1
  144. package/lib/module/EnableExperimentalWebImplementation.js +15 -0
  145. package/lib/module/EnableExperimentalWebImplementation.js.map +1 -0
  146. package/lib/module/RNGestureHandlerModule.macos.js +102 -0
  147. package/lib/module/RNGestureHandlerModule.macos.js.map +1 -0
  148. package/lib/module/RNGestureHandlerModule.web.js +73 -24
  149. package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
  150. package/lib/module/RNRenderer.js +4 -0
  151. package/lib/module/RNRenderer.js.map +1 -0
  152. package/lib/module/RNRenderer.web.js +4 -0
  153. package/lib/module/RNRenderer.web.js.map +1 -0
  154. package/lib/module/components/DrawerLayout.js +41 -12
  155. package/lib/module/components/DrawerLayout.js.map +1 -1
  156. package/lib/module/components/GestureButtons.js +43 -9
  157. package/lib/module/components/GestureButtons.js.map +1 -1
  158. package/lib/module/components/GestureComponents.js +39 -4
  159. package/lib/module/components/GestureComponents.js.map +1 -1
  160. package/lib/module/components/GestureComponents.web.js +6 -2
  161. package/lib/module/components/GestureComponents.web.js.map +1 -1
  162. package/lib/module/components/Swipeable.js +3 -1
  163. package/lib/module/components/Swipeable.js.map +1 -1
  164. package/lib/module/components/touchables/GenericTouchable.js +5 -1
  165. package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
  166. package/lib/module/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -1
  167. package/lib/module/handlers/ForceTouchGestureHandler.js +1 -1
  168. package/lib/module/handlers/ForceTouchGestureHandler.js.map +1 -1
  169. package/lib/module/handlers/PanGestureHandler.js +1 -1
  170. package/lib/module/handlers/PanGestureHandler.js.map +1 -1
  171. package/lib/module/handlers/PressabilityDebugView.js +3 -0
  172. package/lib/module/handlers/PressabilityDebugView.js.map +1 -0
  173. package/lib/module/handlers/PressabilityDebugView.web.js +5 -0
  174. package/lib/module/handlers/PressabilityDebugView.web.js.map +1 -0
  175. package/lib/module/handlers/createHandler.js +35 -14
  176. package/lib/module/handlers/createHandler.js.map +1 -1
  177. package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
  178. package/lib/module/handlers/gestures/GestureDetector.js +147 -74
  179. package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
  180. package/lib/module/handlers/gestures/gesture.js +13 -2
  181. package/lib/module/handlers/gestures/gesture.js.map +1 -1
  182. package/lib/module/handlers/gestures/gestureStateManager.js +13 -9
  183. package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -1
  184. package/lib/module/handlers/gestures/panGesture.js +5 -0
  185. package/lib/module/handlers/gestures/panGesture.js.map +1 -1
  186. package/lib/module/handlers/gestures/reanimatedWrapper.js +7 -0
  187. package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -1
  188. package/lib/module/index.js +2 -1
  189. package/lib/module/index.js.map +1 -1
  190. package/lib/module/utils.js +2 -1
  191. package/lib/module/utils.js.map +1 -1
  192. package/lib/module/web/constants.js +1 -36
  193. package/lib/module/web/constants.js.map +1 -1
  194. package/lib/module/web/detectors/RotationGestureDetector.js +159 -0
  195. package/lib/module/web/detectors/RotationGestureDetector.js.map +1 -0
  196. package/lib/module/web/detectors/ScaleGestureDetector.js +156 -0
  197. package/lib/module/web/detectors/ScaleGestureDetector.js.map +1 -0
  198. package/lib/module/web/handlers/FlingGestureHandler.js +139 -0
  199. package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -0
  200. package/lib/module/web/handlers/GestureHandler.js +521 -0
  201. package/lib/module/web/handlers/GestureHandler.js.map +1 -0
  202. package/lib/module/web/handlers/LongPressGestureHandler.js +133 -0
  203. package/lib/module/web/handlers/LongPressGestureHandler.js.map +1 -0
  204. package/lib/module/web/handlers/NativeViewGestureHandler.js +103 -0
  205. package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -0
  206. package/lib/module/web/handlers/PanGestureHandler.js +434 -0
  207. package/lib/module/web/handlers/PanGestureHandler.js.map +1 -0
  208. package/lib/module/web/handlers/PinchGestureHandler.js +155 -0
  209. package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -0
  210. package/lib/module/web/handlers/RotationGestureHandler.js +171 -0
  211. package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -0
  212. package/lib/module/web/handlers/TapGestureHandler.js +281 -0
  213. package/lib/module/web/handlers/TapGestureHandler.js.map +1 -0
  214. package/lib/module/web/interfaces.js +26 -0
  215. package/lib/module/web/interfaces.js.map +1 -0
  216. package/lib/module/web/tools/EventManager.js +160 -0
  217. package/lib/module/web/tools/EventManager.js.map +1 -0
  218. package/lib/module/web/tools/GestureHandlerOrchestrator.js +270 -0
  219. package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -0
  220. package/lib/module/web/tools/InteractionManager.js +93 -0
  221. package/lib/module/web/tools/InteractionManager.js.map +1 -0
  222. package/lib/module/web/tools/NodeManager.js +39 -0
  223. package/lib/module/web/tools/NodeManager.js.map +1 -0
  224. package/lib/module/web/tools/PointerTracker.js +122 -0
  225. package/lib/module/web/tools/PointerTracker.js.map +1 -0
  226. package/lib/module/{web → web_hammer}/DiscreteGestureHandler.js +0 -0
  227. package/lib/module/{web → web_hammer}/DiscreteGestureHandler.js.map +0 -0
  228. package/lib/module/{web → web_hammer}/DraggingGestureHandler.js +0 -0
  229. package/lib/module/{web → web_hammer}/DraggingGestureHandler.js.map +0 -0
  230. package/lib/module/{web → web_hammer}/Errors.js +0 -0
  231. package/lib/module/{web → web_hammer}/Errors.js.map +0 -0
  232. package/lib/module/{web → web_hammer}/FlingGestureHandler.js +0 -0
  233. package/lib/module/{web → web_hammer}/FlingGestureHandler.js.map +0 -0
  234. package/lib/module/{web → web_hammer}/GestureHandler.js +83 -42
  235. package/lib/module/web_hammer/GestureHandler.js.map +1 -0
  236. package/lib/module/{web → web_hammer}/IndiscreteGestureHandler.js +0 -0
  237. package/lib/module/{web → web_hammer}/IndiscreteGestureHandler.js.map +0 -0
  238. package/lib/module/{web → web_hammer}/LongPressGestureHandler.js +0 -0
  239. package/lib/module/{web → web_hammer}/LongPressGestureHandler.js.map +0 -0
  240. package/lib/module/{web → web_hammer}/NativeViewGestureHandler.js +4 -0
  241. package/lib/module/web_hammer/NativeViewGestureHandler.js.map +1 -0
  242. package/lib/module/{web → web_hammer}/NodeManager.js +0 -0
  243. package/lib/module/web_hammer/NodeManager.js.map +1 -0
  244. package/lib/module/{web → web_hammer}/PanGestureHandler.js +0 -0
  245. package/lib/module/{web → web_hammer}/PanGestureHandler.js.map +0 -0
  246. package/lib/module/{web → web_hammer}/PinchGestureHandler.js +0 -0
  247. package/lib/module/{web → web_hammer}/PinchGestureHandler.js.map +0 -0
  248. package/lib/module/{web → web_hammer}/PressGestureHandler.js +0 -0
  249. package/lib/module/{web → web_hammer}/PressGestureHandler.js.map +0 -0
  250. package/lib/module/{web → web_hammer}/RotationGestureHandler.js +0 -0
  251. package/lib/module/{web → web_hammer}/RotationGestureHandler.js.map +0 -0
  252. package/lib/module/{web → web_hammer}/TapGestureHandler.js +0 -0
  253. package/lib/module/{web → web_hammer}/TapGestureHandler.js.map +0 -0
  254. package/lib/module/web_hammer/constants.js +43 -0
  255. package/lib/module/web_hammer/constants.js.map +1 -0
  256. package/lib/module/{web → web_hammer}/utils.js +0 -0
  257. package/lib/module/{web → web_hammer}/utils.js.map +1 -1
  258. package/lib/typescript/EnableExperimentalWebImplementation.d.ts +2 -0
  259. package/lib/typescript/RNGestureHandlerModule.macos.d.ts +44 -0
  260. package/lib/typescript/RNGestureHandlerModule.web.d.ts +29 -18
  261. package/lib/typescript/RNRenderer.d.ts +1 -0
  262. package/lib/typescript/RNRenderer.web.d.ts +3 -0
  263. package/lib/typescript/components/DrawerLayout.d.ts +4 -1
  264. package/lib/typescript/components/GestureButtons.d.ts +22 -0
  265. package/lib/typescript/components/GestureComponents.d.ts +7 -3
  266. package/lib/typescript/components/GestureComponents.web.d.ts +1 -0
  267. package/lib/typescript/components/Swipeable.d.ts +1 -1
  268. package/lib/typescript/fabric/RNGestureHandlerButtonNativeComponent.d.ts +1 -0
  269. package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +2 -2
  270. package/lib/typescript/handlers/PanGestureHandler.d.ts +2 -1
  271. package/lib/typescript/handlers/PressabilityDebugView.d.ts +1 -0
  272. package/lib/typescript/handlers/PressabilityDebugView.web.d.ts +1 -0
  273. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +1 -0
  274. package/lib/typescript/handlers/gestures/GestureDetector.d.ts +2 -1
  275. package/lib/typescript/handlers/gestures/gesture.d.ts +3 -0
  276. package/lib/typescript/handlers/gestures/panGesture.d.ts +1 -0
  277. package/lib/typescript/index.d.ts +2 -1
  278. package/lib/typescript/web/constants.d.ts +1 -33
  279. package/lib/typescript/web/detectors/RotationGestureDetector.d.ts +30 -0
  280. package/lib/typescript/web/detectors/ScaleGestureDetector.d.ts +30 -0
  281. package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +31 -0
  282. package/lib/typescript/web/handlers/GestureHandler.d.ts +84 -0
  283. package/lib/typescript/web/handlers/LongPressGestureHandler.d.ts +33 -0
  284. package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +16 -0
  285. package/lib/typescript/web/handlers/PanGestureHandler.d.ts +68 -0
  286. package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +30 -0
  287. package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +30 -0
  288. package/lib/typescript/web/handlers/TapGestureHandler.d.ts +49 -0
  289. package/lib/typescript/web/interfaces.d.ts +97 -0
  290. package/lib/typescript/web/tools/EventManager.d.ts +28 -0
  291. package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +28 -0
  292. package/lib/typescript/web/tools/InteractionManager.d.ts +13 -0
  293. package/lib/typescript/web/tools/NodeManager.d.ts +11 -0
  294. package/lib/typescript/web/tools/PointerTracker.d.ts +28 -0
  295. package/lib/typescript/{web → web_hammer}/DiscreteGestureHandler.d.ts +0 -0
  296. package/lib/typescript/{web → web_hammer}/DraggingGestureHandler.d.ts +0 -0
  297. package/lib/typescript/{web → web_hammer}/Errors.d.ts +0 -0
  298. package/lib/typescript/{web → web_hammer}/FlingGestureHandler.d.ts +1 -0
  299. package/lib/typescript/{web → web_hammer}/GestureHandler.d.ts +6 -0
  300. package/lib/typescript/{web → web_hammer}/IndiscreteGestureHandler.d.ts +1 -0
  301. package/lib/typescript/{web → web_hammer}/LongPressGestureHandler.d.ts +1 -0
  302. package/lib/typescript/{web → web_hammer}/NativeViewGestureHandler.d.ts +1 -0
  303. package/lib/typescript/web_hammer/NodeManager.d.ts +8 -0
  304. package/lib/typescript/{web → web_hammer}/PanGestureHandler.d.ts +1 -0
  305. package/lib/typescript/{web → web_hammer}/PinchGestureHandler.d.ts +0 -0
  306. package/lib/typescript/{web → web_hammer}/PressGestureHandler.d.ts +2 -0
  307. package/lib/typescript/{web → web_hammer}/RotationGestureHandler.d.ts +0 -0
  308. package/lib/typescript/{web → web_hammer}/TapGestureHandler.d.ts +1 -0
  309. package/lib/typescript/web_hammer/constants.d.ts +39 -0
  310. package/lib/typescript/{web → web_hammer}/utils.d.ts +0 -0
  311. package/package.json +1 -1
  312. package/src/EnableExperimentalWebImplementation.ts +18 -0
  313. package/src/RNGestureHandlerModule.macos.ts +114 -0
  314. package/src/RNGestureHandlerModule.web.ts +89 -26
  315. package/src/RNRenderer.ts +3 -0
  316. package/src/RNRenderer.web.ts +3 -0
  317. package/src/components/DrawerLayout.tsx +37 -14
  318. package/src/components/GestureButtons.tsx +64 -0
  319. package/src/components/GestureComponents.tsx +66 -6
  320. package/src/components/GestureComponents.web.tsx +5 -0
  321. package/src/components/Swipeable.tsx +3 -1
  322. package/src/components/touchables/GenericTouchable.tsx +2 -0
  323. package/src/fabric/RNGestureHandlerButtonNativeComponent.ts +1 -0
  324. package/src/handlers/ForceTouchGestureHandler.ts +3 -2
  325. package/src/handlers/PanGestureHandler.ts +2 -0
  326. package/src/handlers/PressabilityDebugView.tsx +2 -0
  327. package/src/handlers/PressabilityDebugView.web.tsx +4 -0
  328. package/src/handlers/{createHandler.ts → createHandler.tsx} +45 -19
  329. package/src/handlers/gestureHandlerCommon.ts +2 -0
  330. package/src/handlers/gestures/GestureDetector.tsx +185 -93
  331. package/src/handlers/gestures/gesture.ts +16 -0
  332. package/src/handlers/gestures/gestureStateManager.ts +13 -8
  333. package/src/handlers/gestures/panGesture.ts +5 -0
  334. package/src/handlers/gestures/reanimatedWrapper.ts +7 -0
  335. package/src/index.ts +3 -0
  336. package/src/utils.ts +3 -1
  337. package/src/web/constants.ts +1 -41
  338. package/src/web/detectors/RotationGestureDetector.ts +199 -0
  339. package/src/web/detectors/ScaleGestureDetector.ts +208 -0
  340. package/src/web/handlers/FlingGestureHandler.ts +146 -0
  341. package/src/web/handlers/GestureHandler.ts +572 -0
  342. package/src/web/handlers/LongPressGestureHandler.ts +122 -0
  343. package/src/web/handlers/NativeViewGestureHandler.ts +109 -0
  344. package/src/web/handlers/PanGestureHandler.ts +488 -0
  345. package/src/web/handlers/PinchGestureHandler.ts +162 -0
  346. package/src/web/handlers/RotationGestureHandler.ts +181 -0
  347. package/src/web/handlers/TapGestureHandler.ts +275 -0
  348. package/src/web/interfaces.ts +114 -0
  349. package/src/web/tools/EventManager.ts +186 -0
  350. package/src/web/tools/GestureHandlerOrchestrator.ts +329 -0
  351. package/src/web/tools/InteractionManager.ts +108 -0
  352. package/src/web/tools/NodeManager.ts +43 -0
  353. package/src/web/tools/PointerTracker.ts +130 -0
  354. package/src/{web → web_hammer}/DiscreteGestureHandler.ts +0 -0
  355. package/src/{web → web_hammer}/DraggingGestureHandler.ts +0 -0
  356. package/src/{web → web_hammer}/Errors.ts +0 -0
  357. package/src/{web → web_hammer}/FlingGestureHandler.ts +0 -0
  358. package/src/{web → web_hammer}/GestureHandler.ts +102 -55
  359. package/src/{web → web_hammer}/IndiscreteGestureHandler.ts +0 -0
  360. package/src/{web → web_hammer}/LongPressGestureHandler.ts +0 -0
  361. package/src/{web → web_hammer}/NativeViewGestureHandler.ts +4 -0
  362. package/src/{web → web_hammer}/NodeManager.ts +6 -3
  363. package/src/{web → web_hammer}/PanGestureHandler.ts +0 -0
  364. package/src/{web → web_hammer}/PinchGestureHandler.ts +0 -0
  365. package/src/{web → web_hammer}/PressGestureHandler.ts +0 -0
  366. package/src/{web → web_hammer}/RotationGestureHandler.ts +0 -0
  367. package/src/{web → web_hammer}/TapGestureHandler.ts +0 -0
  368. package/src/web_hammer/constants.ts +48 -0
  369. package/src/{web → web_hammer}/utils.ts +1 -1
  370. package/android/src/main/jni/Android.mk +0 -53
  371. package/android/src/main/jni/OnLoad.cpp +0 -9
  372. package/android/src/main/jni/RNGestureHandlerComponentsRegistry.cpp +0 -71
  373. package/android/src/main/jni/RNGestureHandlerComponentsRegistry.h +0 -34
  374. package/ios/RNGestureHandler.xcodeproj/project.xcworkspace/xcuserdata/jakubpiasecki.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  375. package/ios/RNGestureHandler.xcodeproj/xcuserdata/jakubpiasecki.xcuserdatad/xcschemes/xcschememanagement.plist +0 -19
  376. package/lib/commonjs/web/GestureHandler.js.map +0 -1
  377. package/lib/commonjs/web/NativeViewGestureHandler.js.map +0 -1
  378. package/lib/commonjs/web/NodeManager.js.map +0 -1
  379. package/lib/module/web/GestureHandler.js.map +0 -1
  380. package/lib/module/web/NativeViewGestureHandler.js.map +0 -1
  381. package/lib/module/web/NodeManager.js.map +0 -1
  382. package/lib/typescript/web/NodeManager.d.ts +0 -8
@@ -1 +1 @@
1
- {"version":3,"sources":["createHandler.ts"],"names":["UIManagerAny","UIManager","customGHEventsConfigFabricAndroid","topOnGestureHandlerEvent","registrationName","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","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","REANIMATED_WORKLET","NATIVE_ANIMATED_EVENT","updateGestureHandler","createRef","id","handlerIDToTag","Error","componentDidMount","inspectorToggleListener","setState","_","update","updateEnqueued","setImmediate","componentDidUpdate","componentWillUnmount","remove","dropGestureHandler","clearImmediate","handlerID","setNativeProps","updates","mergedProps","render","gestureEventHandler","gestureStateEventHandler","events","grandChildren","Touchable","TOUCH_TARGET_DEBUG","type","displayName","toArray","push","renderDebugView","color","hitSlop","cloneElement","refHandler","collapsable","handlerType","testID"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;AACA;;AAEA;;AACA;;AAMA;;AASA;;AACA;;;;;;;;;;;;AAEA,MAAMA,YAAY,GAAGC,sBAArB;AAEA,MAAMC,iCAAiC,GAAG;AACxCC,EAAAA,wBAAwB,EAAE;AAAEC,IAAAA,gBAAgB,EAAE;AAApB,GADc;AAExCC,EAAAA,8BAA8B,EAAE;AAC9BD,IAAAA,gBAAgB,EAAE;AADY;AAFQ,CAA1C;AAOA,MAAME,oBAAoB,GAAG;AAC3BC,EAAAA,qBAAqB,EAAE;AAAEH,IAAAA,gBAAgB,EAAE;AAApB,GADI;AAE3BI,EAAAA,2BAA2B,EAAE;AAC3BJ,IAAAA,gBAAgB,EAAE;AADS,GAFF;AAM3B;AACA;AACA;AACA;AACA;AACA;AACA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,QAA/B,CAAnB;AACA,UAAIuC,aAAa,GAAG1C,KAAK,CAACrC,KAAN,CAAYwC,QAAhC;;AACA,UACEwC,uBAAUC,kBAAV,IACA5C,KAAK,CAAC6C,IADN,KAEC7C,KAAK,CAAC6C,IAAN,KAAe,wBAAf,IACC7C,KAAK,CAAC6C,IAAN,CAAWhE,IAAX,KAAoB,MADrB,IAECmB,KAAK,CAAC6C,IAAN,CAAWC,WAAX,KAA2B,MAJ7B,CADF,EAME;AACAJ,QAAAA,aAAa,GAAGvD,KAAK,CAACc,QAAN,CAAe8C,OAAf,CAAuBL,aAAvB,CAAhB;AACAA,QAAAA,aAAa,CAACM,IAAd,CACEL,uBAAUM,eAAV,CAA0B;AACxBC,UAAAA,KAAK,EAAE,mBADiB;AAExBC,UAAAA,OAAO,EAAEnD,KAAK,CAACrC,KAAN,CAAYwF;AAFG,SAA1B,CADF;AAMD;;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,KAAK7F,KAAL,CAAW6F,MAAb,mEAAuBxD,KAAK,CAACrC,KAAN,CAAY6F,MAT3C;AAUE,WAAGf;AAVL,OAFK,EAcLC,aAdK,CAAP;AAgBD;;AApUD;;AAPwE,kBAIpExD,OAJoE,iBAQnDL,IARmD;;AA6U1E,SAAOK,OAAP;AACD","sourcesContent":["import * as React from 'react';\nimport {\n Platform,\n Touchable,\n UIManager,\n DeviceEventEmitter,\n EmitterSubscription,\n} from 'react-native';\n// @ts-ignore - it isn't typed by TS & don't have definitelyTyped types\nimport deepEqual from 'lodash/isEqual';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\nimport type RNGestureHandlerModuleWeb from '../RNGestureHandlerModule.web';\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 } from '../utils';\nimport { ActionType } from '../ActionType';\n\nconst UIManagerAny = UIManager as any;\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<\n 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\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\n private handlerTag: number;\n private config: Record<string, unknown>;\n private propsRef: React.MutableRefObject<unknown>;\n private viewNode: any;\n private viewTag?: number;\n private updateEnqueued: ReturnType<typeof setImmediate> | null = null;\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.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\n if (DEV_ON_ANDROID) {\n this.inspectorToggleListener = DeviceEventEmitter.addListener(\n 'toggleElementInspector',\n () => {\n this.setState((_) => ({ allowTouches }));\n this.update();\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 // setImmediate. 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 this.updateEnqueued = setImmediate(() => {\n this.updateEnqueued = null;\n this.update();\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();\n }\n\n componentWillUnmount() {\n this.inspectorToggleListener?.remove();\n RNGestureHandlerModule.dropGestureHandler(this.handlerTag);\n scheduleFlushOperations();\n if (this.updateEnqueued) {\n clearImmediate(this.updateEnqueued);\n }\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 (RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler)(\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 if (\n this.props?.onGestureEvent &&\n 'current' in this.props.onGestureEvent\n ) {\n // Reanimated worklet\n return ActionType.REANIMATED_WORKLET;\n } else if (\n this.props?.onGestureEvent &&\n '__isNative' in this.props.onGestureEvent\n ) {\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() {\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 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 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 {\n onGestureEvent,\n onGestureHandlerEvent,\n }: OnGestureEventHandlers = 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 const child: any = React.Children.only(this.props.children);\n let grandChildren = child.props.children;\n if (\n Touchable.TOUCH_TARGET_DEBUG &&\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 Touchable.renderDebugView({\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","customGHEventsConfigFabricAndroid","topOnGestureHandlerEvent","registrationName","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","REANIMATED_WORKLET","NATIVE_ANIMATED_EVENT","updateGestureHandler","createRef","id","handlerIDToTag","Error","componentDidMount","inspectorToggleListener","setState","_","update","updateEnqueued","setImmediate","componentDidUpdate","componentWillUnmount","remove","dropGestureHandler","clearImmediate","handlerID","remainingTries","setNativeProps","updates","mergedProps","render","gestureEventHandler","gestureStateEventHandler","events","e","grandChildren","type","displayName","toArray","push","hitSlop","cloneElement","refHandler","collapsable","handlerType","testID"],"mappings":";;;;;;;AAAA;;AACA;;AAOA;;AACA;;AAEA;;AACA;;AAMA;;AASA;;AACA;;AACA;;;;;;;;;;;;AAEA,MAAMA,YAAY,GAAGC,sBAArB;AAEA,MAAMC,iCAAiC,GAAG;AACxCC,EAAAA,wBAAwB,EAAE;AAAEC,IAAAA,gBAAgB,EAAE;AAApB,GADc;AAExCC,EAAAA,8BAA8B,EAAE;AAC9BD,IAAAA,gBAAgB,EAAE;AADY;AAFQ,CAA1C;AAOA,MAAME,oBAAoB,GAAG;AAC3BC,EAAAA,qBAAqB,EAAE;AAAEH,IAAAA,gBAAgB,EAAE;AAApB,GADI;AAE3BI,EAAAA,2BAA2B,EAAE;AAC3BJ,IAAAA,gBAAgB,EAAE;AADS,GAFF;AAM3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAI,0BACFK,sBAASC,EAAT,KAAgB,SADd,IAEFR,iCAFF;AAd2B,CAA7B,C,CAmBA;AACA;AACA;AACA;;AACAF,YAAY,CAACW,uBAAb,GAAuC,EACrC,GAAGX,YAAY,CAACW,uBADqB;AAErC,KAAGL;AAFkC,CAAvC,C,CAIA;AACA;AACA;;AACA,MAAMM,kBAAkB,sDACtBZ,YAAY,CAACa,oBADS,2DACtB,4BAAAb,YAAY,EAAwB,cAAxB,CADU,kGAEtBA,YAAY,CAACc,YAFS,0DAEtB,2BAAAd,YAAY,CAFd;;AAIA,IAAIY,kBAAJ,EAAwB;AACtBA,EAAAA,kBAAkB,CAACD,uBAAnB,GAA6C,EAC3C,GAAGC,kBAAkB,CAACD,uBADqB;AAE3C,OAAGL;AAFwC,G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,EAAU;AACV,cAAM,IAAItB,KAAJ,CACJ,uBACG,GAAExC,IAAK,4JADV,CADI,CAAN;AAKD;;AAED,UAAI+D,aAAa,GAAG5C,KAAK,CAACtC,KAAN,CAAYyC,QAAhC;;AACA,UACE7C,OAAO,IACP0C,KAAK,CAAC6C,IADN,KAEC7C,KAAK,CAAC6C,IAAN,KAAe,wBAAf,IACC7C,KAAK,CAAC6C,IAAN,CAAWhE,IAAX,KAAoB,MADrB,IAECmB,KAAK,CAAC6C,IAAN,CAAWC,WAAX,KAA2B,MAJ7B,CADF,EAME;AACAF,QAAAA,aAAa,GAAGzD,KAAK,CAACc,QAAN,CAAe8C,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,EAAEhD,KAAK,CAACtC,KAAN,CAAYuF;AAHvB,UADF;AAOD;;AAED,0BAAO9D,KAAK,CAAC+D,YAAN,CACLlD,KADK,EAEL;AACEI,QAAAA,GAAG,EAAE,KAAK+C,UADZ;AAEEC,QAAAA,WAAW,EAAE,KAFf;AAGE,YAAI,0BACA;AACEC,UAAAA,WAAW,EAAExE,IADf;AAEEW,UAAAA,UAAU,EAAE,KAAKA;AAFnB,SADA,GAKA,EALJ,CAHF;AASE8D,QAAAA,MAAM,wBAAE,KAAK5F,KAAL,CAAW4F,MAAb,mEAAuBtD,KAAK,CAACtC,KAAN,CAAY4F,MAT3C;AAUE,WAAGZ;AAVL,OAFK,EAcLE,aAdK,CAAP;AAgBD;;AA5VD;;AAPwE,kBAIpE1D,OAJoE,iBAQnDL,IARmD;;AAqW1E,SAAOK,OAAP;AACD","sourcesContent":["import * as React from 'react';\nimport {\n Platform,\n UIManager,\n DeviceEventEmitter,\n EmitterSubscription,\n} from 'react-native';\n// @ts-ignore - it isn't typed by TS & don't have definitelyTyped types\nimport deepEqual from 'lodash/isEqual';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\nimport type RNGestureHandlerModuleWeb from '../RNGestureHandlerModule.web';\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';\n\nconst UIManagerAny = UIManager as any;\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<\n 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\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\n private handlerTag: number;\n private config: Record<string, unknown>;\n private propsRef: React.MutableRefObject<unknown>;\n private viewNode: any;\n private viewTag?: number;\n private updateEnqueued: ReturnType<typeof setImmediate> | null = null;\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.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\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 // setImmediate. 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 this.updateEnqueued = setImmediate(() => {\n this.updateEnqueued = null;\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 RNGestureHandlerModule.dropGestureHandler(this.handlerTag);\n scheduleFlushOperations();\n if (this.updateEnqueued) {\n clearImmediate(this.updateEnqueued);\n }\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 (RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler)(\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 if (\n this.props?.onGestureEvent &&\n 'current' in this.props.onGestureEvent\n ) {\n // Reanimated worklet\n return ActionType.REANIMATED_WORKLET;\n } else if (\n this.props?.onGestureEvent &&\n '__isNative' in this.props.onGestureEvent\n ) {\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 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 this.updateEnqueued = setImmediate(() => {\n this.updateEnqueued = null;\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 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 {\n onGestureEvent,\n onGestureHandlerEvent,\n }: OnGestureEventHandlers = this.props;\n\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 +1 @@
1
- {"version":3,"sources":["gestureHandlerCommon.ts"],"names":["commonProps","componentInteractionProps","baseGestureHandlerProps","baseGestureHandlerWithMonitorProps","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","scheduledFlushOperationsId","scheduleFlushOperations","requestAnimationFrame","RNGestureHandlerModule","flushOperations"],"mappings":";;;;;;;;;;AAKA;;AAKA;;AACA;;AACA;;;;AAZA;AACA;AACA;AACA;AAWA,MAAMA,WAAW,GAAG,CAClB,IADkB,EAElB,SAFkB,EAGlB,yBAHkB,EAIlB,SAJkB,EAKlB,sBALkB,CAApB;AAQA,MAAMC,yBAAyB,GAAG,CAAC,SAAD,EAAY,sBAAZ,CAAlC;AAEO,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;;;AA8FP,SAASI,aAAT,CAAuBC,KAAvB,EAAuCC,IAAvC,EAAqD;AACnD;AACA;AACA,SACED,KAAK,KAAKE,SAAV,KACCF,KAAK,KAAKG,MAAM,CAACH,KAAD,CAAhB,IACC,EAAE,gBAAiBA,KAAnB,CAFF,KAGAC,IAAI,KAAK,sBAHT,IAIAA,IAAI,KAAK,gBALX;AAOD;;AAEM,SAASG,YAAT,CACLC,KADK,EAELC,UAFK,EAGLC,QAAiC,GAAG,EAH/B,EAIL;AACA,QAAMC,cAAc,GAAG,EAAE,GAAGD;AAAL,GAAvB;;AACA,OAAK,MAAME,GAAX,IAAkBH,UAAlB,EAA8B;AAC5B,QAAII,KAAK,GAAGL,KAAK,CAACI,GAAD,CAAjB;;AACA,QAAIV,aAAa,CAACW,KAAD,EAAQD,GAAR,CAAjB,EAA+B;AAC7B,UAAIA,GAAG,KAAK,sBAAR,IAAkCA,GAAG,KAAK,SAA9C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AM;AACvDC,sCAAuBC,eAAvB;;AAEAJ,MAAAA,0BAA0B,GAAG,IAA7B;AACD,KAJiD,CAAlD;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';\n\nconst commonProps = [\n 'id',\n 'enabled',\n 'shouldCancelWhenOutside',\n 'hitSlop',\n 'cancelsTouchesInView',\n] as const;\n\nconst componentInteractionProps = ['waitFor', 'simultaneousHandlers'] 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}\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\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<\n 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};\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 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};\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') return node;\n return findNodeHandleRN(node);\n}\n\nlet scheduledFlushOperationsId: ReturnType<\n typeof requestAnimationFrame\n> | null = null;\n\nexport function scheduleFlushOperations() {\n if (scheduledFlushOperationsId === null) {\n scheduledFlushOperationsId = requestAnimationFrame(() => {\n RNGestureHandlerModule.flushOperations();\n\n scheduledFlushOperationsId = null;\n });\n }\n}\n"]}
1
+ {"version":3,"sources":["gestureHandlerCommon.ts"],"names":["commonProps","componentInteractionProps","baseGestureHandlerProps","baseGestureHandlerWithMonitorProps","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","scheduledFlushOperationsId","scheduleFlushOperations","requestAnimationFrame","RNGestureHandlerModule","flushOperations"],"mappings":";;;;;;;;;;AAKA;;AAKA;;AACA;;AACA;;;;AAZA;AACA;AACA;AACA;AAWA,MAAMA,WAAW,GAAG,CAClB,IADkB,EAElB,SAFkB,EAGlB,yBAHkB,EAIlB,SAJkB,EAKlB,sBALkB,CAApB;AAQA,MAAMC,yBAAyB,GAAG,CAAC,SAAD,EAAY,sBAAZ,CAAlC;AAEO,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;;;AAgGP,SAASI,aAAT,CAAuBC,KAAvB,EAAuCC,IAAvC,EAAqD;AACnD;AACA;AACA,SACED,KAAK,KAAKE,SAAV,KACCF,KAAK,KAAKG,MAAM,CAACH,KAAD,CAAhB,IACC,EAAE,gBAAiBA,KAAnB,CAFF,KAGAC,IAAI,KAAK,sBAHT,IAIAA,IAAI,KAAK,gBALX;AAOD;;AAEM,SAASG,YAAT,CACLC,KADK,EAELC,UAFK,EAGLC,QAAiC,GAAG,EAH/B,EAIL;AACA,QAAMC,cAAc,GAAG,EAAE,GAAGD;AAAL,GAAvB;;AACA,OAAK,MAAME,GAAX,IAAkBH,UAAlB,EAA8B;AAC5B,QAAII,KAAK,GAAGL,KAAK,CAACI,GAAD,CAAjB;;AACA,QAAIV,aAAa,CAACW,KAAD,EAAQD,GAAR,CAAjB,EAA+B;AAC7B,UAAIA,GAAG,KAAK,sBAAR,IAAkCA,GAAG,KAAK,SAA9C,EAAyD;AACvDC,QAAAA,KAAK,GAAGC,wBAAwB,CAACN,KAAK,CAACI,GAAD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ACD,KAJiD,CAAlD;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';\n\nconst commonProps = [\n 'id',\n 'enabled',\n 'shouldCancelWhenOutside',\n 'hitSlop',\n 'cancelsTouchesInView',\n] as const;\n\nconst componentInteractionProps = ['waitFor', 'simultaneousHandlers'] 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}\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\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<\n 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};\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 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') return node;\n return findNodeHandleRN(node);\n}\n\nlet scheduledFlushOperationsId: ReturnType<\n typeof requestAnimationFrame\n> | null = null;\n\nexport function scheduleFlushOperations() {\n if (scheduledFlushOperationsId === null) {\n scheduledFlushOperationsId = requestAnimationFrame(() => {\n RNGestureHandlerModule.flushOperations();\n\n scheduledFlushOperationsId = null;\n });\n }\n}\n"]}
@@ -43,6 +43,10 @@ var _reactNative = require("react-native");
43
43
 
44
44
  var _eventReceiver = require("./eventReceiver");
45
45
 
46
+ var _RNRenderer = require("../../RNRenderer");
47
+
48
+ var _EnableExperimentalWebImplementation = require("../../EnableExperimentalWebImplementation");
49
+
46
50
  var _Reanimated$default$c, _Reanimated$default;
47
51
 
48
52
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -204,8 +208,28 @@ function updateHandlers(preparedGesture, gestureConfig, gesture) {
204
208
  }
205
209
 
206
210
  if (preparedGesture.animatedHandlers) {
207
- preparedGesture.animatedHandlers.value = preparedGesture.config.filter(g => g.shouldUseReanimated) // ignore gestures that shouldn't run on UI
208
- .map(g => g.handlers);
211
+ var _preparedGesture$anim;
212
+
213
+ const previousHandlersValue = (_preparedGesture$anim = preparedGesture.animatedHandlers.value) !== null && _preparedGesture$anim !== void 0 ? _preparedGesture$anim : [];
214
+ const newHandlersValue = preparedGesture.config.filter(g => g.shouldUseReanimated) // ignore gestures that shouldn't run on UI
215
+ .map(g => g.handlers); // if amount of gesture configs changes, we need to update the callbacks in shared value
216
+
217
+ let shouldUpdateSharedValue = previousHandlersValue.length !== newHandlersValue.length;
218
+
219
+ if (!shouldUpdateSharedValue) {
220
+ // if the amount is the same, we need to check if any of the configs inside has changed
221
+ for (let i = 0; i < newHandlersValue.length; i++) {
222
+ if ( // we can use the `gestureId` prop as it's unique for every config instance
223
+ newHandlersValue[i].gestureId !== previousHandlersValue[i].gestureId) {
224
+ shouldUpdateSharedValue = true;
225
+ break;
226
+ }
227
+ }
228
+ }
229
+
230
+ if (shouldUpdateSharedValue) {
231
+ preparedGesture.animatedHandlers.value = newHandlersValue;
232
+ }
209
233
  }
210
234
 
211
235
  (0, _gestureHandlerCommon.scheduleFlushOperations)();
@@ -226,91 +250,91 @@ function needsToReattach(preparedGesture, gesture) {
226
250
  return false;
227
251
  }
228
252
 
229
- function useAnimatedGesture(preparedGesture, needsRebuild) {
230
- if (!_reanimatedWrapper.Reanimated) {
231
- return;
232
- }
253
+ function isStateChangeEvent(event) {
254
+ 'worklet'; // @ts-ignore Yes, the oldState prop is missing on GestureTouchEvent, that's the point
233
255
 
234
- function isStateChangeEvent(event) {
235
- 'worklet'; // @ts-ignore Yes, the oldState prop is missing on GestureTouchEvent, that's the point
236
-
237
- return event.oldState != null;
238
- }
256
+ return event.oldState != null;
257
+ }
239
258
 
240
- function isTouchEvent(event) {
241
- 'worklet';
259
+ function isTouchEvent(event) {
260
+ 'worklet';
242
261
 
243
- return event.eventType != null;
244
- }
262
+ return event.eventType != null;
263
+ }
245
264
 
246
- function getHandler(type, gesture) {
247
- 'worklet';
265
+ function getHandler(type, gesture) {
266
+ 'worklet';
248
267
 
249
- switch (type) {
250
- case _gesture.CALLBACK_TYPE.BEGAN:
251
- return gesture.onBegin;
268
+ switch (type) {
269
+ case _gesture.CALLBACK_TYPE.BEGAN:
270
+ return gesture.onBegin;
252
271
 
253
- case _gesture.CALLBACK_TYPE.START:
254
- return gesture.onStart;
272
+ case _gesture.CALLBACK_TYPE.START:
273
+ return gesture.onStart;
255
274
 
256
- case _gesture.CALLBACK_TYPE.UPDATE:
257
- return gesture.onUpdate;
275
+ case _gesture.CALLBACK_TYPE.UPDATE:
276
+ return gesture.onUpdate;
258
277
 
259
- case _gesture.CALLBACK_TYPE.CHANGE:
260
- return gesture.onChange;
278
+ case _gesture.CALLBACK_TYPE.CHANGE:
279
+ return gesture.onChange;
261
280
 
262
- case _gesture.CALLBACK_TYPE.END:
263
- return gesture.onEnd;
281
+ case _gesture.CALLBACK_TYPE.END:
282
+ return gesture.onEnd;
264
283
 
265
- case _gesture.CALLBACK_TYPE.FINALIZE:
266
- return gesture.onFinalize;
284
+ case _gesture.CALLBACK_TYPE.FINALIZE:
285
+ return gesture.onFinalize;
267
286
 
268
- case _gesture.CALLBACK_TYPE.TOUCHES_DOWN:
269
- return gesture.onTouchesDown;
287
+ case _gesture.CALLBACK_TYPE.TOUCHES_DOWN:
288
+ return gesture.onTouchesDown;
270
289
 
271
- case _gesture.CALLBACK_TYPE.TOUCHES_MOVE:
272
- return gesture.onTouchesMove;
290
+ case _gesture.CALLBACK_TYPE.TOUCHES_MOVE:
291
+ return gesture.onTouchesMove;
273
292
 
274
- case _gesture.CALLBACK_TYPE.TOUCHES_UP:
275
- return gesture.onTouchesUp;
293
+ case _gesture.CALLBACK_TYPE.TOUCHES_UP:
294
+ return gesture.onTouchesUp;
276
295
 
277
- case _gesture.CALLBACK_TYPE.TOUCHES_CANCELLED:
278
- return gesture.onTouchesCancelled;
279
- }
296
+ case _gesture.CALLBACK_TYPE.TOUCHES_CANCELLED:
297
+ return gesture.onTouchesCancelled;
280
298
  }
299
+ }
281
300
 
282
- function touchEventTypeToCallbackType(eventType) {
283
- 'worklet';
284
-
285
- switch (eventType) {
286
- case _TouchEventType.TouchEventType.TOUCHES_DOWN:
287
- return _gesture.CALLBACK_TYPE.TOUCHES_DOWN;
301
+ function touchEventTypeToCallbackType(eventType) {
302
+ 'worklet';
288
303
 
289
- case _TouchEventType.TouchEventType.TOUCHES_MOVE:
290
- return _gesture.CALLBACK_TYPE.TOUCHES_MOVE;
304
+ switch (eventType) {
305
+ case _TouchEventType.TouchEventType.TOUCHES_DOWN:
306
+ return _gesture.CALLBACK_TYPE.TOUCHES_DOWN;
291
307
 
292
- case _TouchEventType.TouchEventType.TOUCHES_UP:
293
- return _gesture.CALLBACK_TYPE.TOUCHES_UP;
308
+ case _TouchEventType.TouchEventType.TOUCHES_MOVE:
309
+ return _gesture.CALLBACK_TYPE.TOUCHES_MOVE;
294
310
 
295
- case _TouchEventType.TouchEventType.TOUCHES_CANCELLED:
296
- return _gesture.CALLBACK_TYPE.TOUCHES_CANCELLED;
297
- }
311
+ case _TouchEventType.TouchEventType.TOUCHES_UP:
312
+ return _gesture.CALLBACK_TYPE.TOUCHES_UP;
298
313
 
299
- return _gesture.CALLBACK_TYPE.UNDEFINED;
314
+ case _TouchEventType.TouchEventType.TOUCHES_CANCELLED:
315
+ return _gesture.CALLBACK_TYPE.TOUCHES_CANCELLED;
300
316
  }
301
317
 
302
- function runWorklet(type, gesture, event, ...args) {
303
- 'worklet';
318
+ return _gesture.CALLBACK_TYPE.UNDEFINED;
319
+ }
304
320
 
305
- const handler = getHandler(type, gesture);
321
+ function runWorklet(type, gesture, event, ...args) {
322
+ 'worklet';
306
323
 
307
- if (gesture.isWorklet[type]) {
308
- // @ts-ignore Logic below makes sure the correct event is send to the
309
- // correct handler.
310
- handler === null || handler === void 0 ? void 0 : handler(event, ...args);
311
- } else if (handler) {
312
- console.warn((0, _utils.tagMessage)('Animated gesture callback must be a worklet'));
313
- }
324
+ const handler = getHandler(type, gesture);
325
+
326
+ if (gesture.isWorklet[type]) {
327
+ // @ts-ignore Logic below makes sure the correct event is send to the
328
+ // correct handler.
329
+ handler === null || handler === void 0 ? void 0 : handler(event, ...args);
330
+ } else if (handler) {
331
+ console.warn((0, _utils.tagMessage)('Animated gesture callback must be a worklet'));
332
+ }
333
+ }
334
+
335
+ function useAnimatedGesture(preparedGesture, needsRebuild) {
336
+ if (!_reanimatedWrapper.Reanimated) {
337
+ return;
314
338
  } // Hooks are called conditionally, but the condition is whether the
315
339
  // react-native-reanimated is installed, which shouldn't change while running
316
340
  // eslint-disable-next-line react-hooks/rules-of-hooks
@@ -383,6 +407,48 @@ function useAnimatedGesture(preparedGesture, needsRebuild) {
383
407
 
384
408
  preparedGesture.animatedEventHandler = event;
385
409
  preparedGesture.animatedHandlers = sharedHandlersCallbacks;
410
+ } // eslint-disable-next-line @typescript-eslint/no-explicit-any
411
+
412
+
413
+ function validateDetectorChildren(ref) {
414
+ // finds the first native view under the Wrap component and traverses the fiber tree upwards
415
+ // to check whether there is more than one native view as a pseudo-direct child of GestureDetector
416
+ // i.e. this is not ok:
417
+ // Wrap
418
+ // |
419
+ // / \
420
+ // / \
421
+ // / \
422
+ // / \
423
+ // NativeView NativeView
424
+ //
425
+ // but this is fine:
426
+ // Wrap
427
+ // |
428
+ // NativeView
429
+ // |
430
+ // / \
431
+ // / \
432
+ // / \
433
+ // / \
434
+ // NativeView NativeView
435
+ if (__DEV__ && _reactNative.Platform.OS !== 'web') {
436
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
437
+ const wrapType = ref._reactInternals.elementType; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
438
+
439
+ let instance = _RNRenderer.RNRenderer.findHostInstance_DEPRECATED(ref)._internalFiberInstanceHandleDEV; // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
440
+
441
+
442
+ while (instance && instance.elementType !== wrapType) {
443
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
444
+ if (instance.sibling) {
445
+ throw new Error('GestureDetector has more than one native view as its children. This can happen if you are using a custom component that renders multiple views, like React.Fragment. You should wrap content of GestureDetector with a <View> or <Animated.View>.');
446
+ } // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
447
+
448
+
449
+ instance = instance.return;
450
+ }
451
+ }
386
452
  }
387
453
 
388
454
  const GestureDetector = props => {
@@ -396,7 +462,10 @@ const GestureDetector = props => {
396
462
  const webEventHandlersRef = (0, _react.useRef)({
397
463
  onGestureHandlerEvent: e => {
398
464
  (0, _eventReceiver.onGestureHandlerEvent)(e.nativeEvent);
399
- }
465
+ },
466
+ onGestureHandlerStateChange: (0, _EnableExperimentalWebImplementation.isExperimentalWebImplementationEnabled)() ? e => {
467
+ (0, _eventReceiver.onGestureHandlerEvent)(e.nativeEvent);
468
+ } : undefined
400
469
  });
401
470
 
402
471
  const preparedGesture = _react.default.useRef({
@@ -430,6 +499,7 @@ const GestureDetector = props => {
430
499
  (0, _react.useEffect)(() => {
431
500
  firstRenderRef.current = true;
432
501
  const viewTag = (0, _gestureHandlerCommon.findNodeHandle)(viewRef.current);
502
+ validateDetectorChildren(viewRef.current);
433
503
  attachHandlers({
434
504
  preparedGesture,
435
505
  gestureConfig,
@@ -446,6 +516,7 @@ const GestureDetector = props => {
446
516
  const viewTag = (0, _gestureHandlerCommon.findNodeHandle)(viewRef.current);
447
517
 
448
518
  if (needsToReattach(preparedGesture, gesture)) {
519
+ validateDetectorChildren(viewRef.current);
449
520
  dropHandlers(preparedGesture);
450
521
  attachHandlers({
451
522
  preparedGesture,
@@ -493,17 +564,21 @@ exports.GestureDetector = GestureDetector;
493
564
 
494
565
  class Wrap extends _react.default.Component {
495
566
  render() {
496
- // I don't think that fighting with types over such a simple function is worth it
497
- // The only thing it does is add 'collapsable: false' to the child component
498
- // to make sure it is in the native view hierarchy so the detector can find
499
- // correct viewTag to attach to.
500
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
501
- const child = _react.default.Children.only(this.props.children);
502
-
503
- return /*#__PURE__*/_react.default.cloneElement(child, {
504
- collapsable: false
505
- }, // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
506
- child.props.children);
567
+ try {
568
+ // I don't think that fighting with types over such a simple function is worth it
569
+ // The only thing it does is add 'collapsable: false' to the child component
570
+ // to make sure it is in the native view hierarchy so the detector can find
571
+ // correct viewTag to attach to.
572
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
573
+ const child = _react.default.Children.only(this.props.children);
574
+
575
+ return /*#__PURE__*/_react.default.cloneElement(child, {
576
+ collapsable: false
577
+ }, // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
578
+ child.props.children);
579
+ } catch (e) {
580
+ 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.`));
581
+ }
507
582
  }
508
583
 
509
584
  }