react-native-gesture-handler 1.10.3 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (384) hide show
  1. package/README.md +10 -8
  2. package/android/build.gradle +49 -1
  3. package/android/common/src/main/java/com/swmansion/common/GestureHandlerStateManager.kt +5 -0
  4. package/android/gradle.properties +19 -0
  5. package/android/lib/src/main/java/com/swmansion/gesturehandler/BaseGestureHandlerInteractionController.kt +18 -0
  6. package/android/lib/src/main/java/com/swmansion/gesturehandler/Extensions.kt +11 -0
  7. package/android/lib/src/main/java/com/swmansion/gesturehandler/FlingGestureHandler.kt +96 -0
  8. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +744 -0
  9. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerInteractionController.kt +8 -0
  10. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.kt +596 -0
  11. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistry.kt +8 -0
  12. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistryImpl.kt +21 -0
  13. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureUtils.kt +49 -0
  14. package/android/lib/src/main/java/com/swmansion/gesturehandler/LongPressGestureHandler.kt +97 -0
  15. package/android/lib/src/main/java/com/swmansion/gesturehandler/ManualGestureHandler.kt +11 -0
  16. package/android/lib/src/main/java/com/swmansion/gesturehandler/NativeViewGestureHandler.kt +129 -0
  17. package/android/lib/src/main/java/com/swmansion/gesturehandler/OnTouchEventListener.kt +9 -0
  18. package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.kt +292 -0
  19. package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.kt +90 -0
  20. package/android/lib/src/main/java/com/swmansion/gesturehandler/{PointerEventsConfig.java → PointerEventsConfig.kt} +3 -5
  21. package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureDetector.kt +125 -0
  22. package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.kt +81 -0
  23. package/android/lib/src/main/java/com/swmansion/gesturehandler/TapGestureHandler.kt +167 -0
  24. package/android/lib/src/main/java/com/swmansion/gesturehandler/ViewConfigurationHelper.kt +10 -0
  25. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +348 -0
  26. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.kt +57 -0
  27. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +59 -0
  28. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEventDataExtractor.kt +8 -0
  29. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt +61 -0
  30. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +686 -0
  31. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerPackage.kt +17 -0
  32. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.kt +95 -0
  33. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +132 -0
  34. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootInterface.kt +5 -0
  35. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +68 -0
  36. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.kt +34 -0
  37. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt +66 -0
  38. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerTouchEvent.kt +69 -0
  39. package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.kt +51 -0
  40. package/ios/Handlers/RNFlingHandler.m +78 -5
  41. package/ios/Handlers/RNForceTouchHandler.m +29 -4
  42. package/ios/Handlers/RNLongPressHandler.m +105 -3
  43. package/ios/Handlers/RNManualHandler.h +4 -0
  44. package/ios/Handlers/RNManualHandler.m +73 -0
  45. package/ios/Handlers/RNNativeViewHandler.m +30 -2
  46. package/ios/Handlers/RNPanHandler.m +64 -4
  47. package/ios/Handlers/RNPinchHandler.m +61 -2
  48. package/ios/Handlers/RNRotationHandler.m +60 -1
  49. package/ios/Handlers/RNTapHandler.m +55 -8
  50. package/ios/RNGestureHandler.h +18 -4
  51. package/ios/RNGestureHandler.m +123 -13
  52. package/ios/RNGestureHandler.xcodeproj/project.xcworkspace/xcuserdata/jakubpiasecki.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  53. package/ios/RNGestureHandler.xcodeproj/xcuserdata/jakubpiasecki.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
  54. package/ios/RNGestureHandlerEvents.h +9 -0
  55. package/ios/RNGestureHandlerEvents.m +34 -0
  56. package/ios/RNGestureHandlerManager.h +7 -0
  57. package/ios/RNGestureHandlerManager.m +62 -34
  58. package/ios/RNGestureHandlerModule.m +39 -3
  59. package/ios/RNGestureHandlerPointerTracker.h +25 -0
  60. package/ios/RNGestureHandlerPointerTracker.m +237 -0
  61. package/ios/RNGestureHandlerRegistry.h +1 -0
  62. package/ios/RNGestureHandlerRegistry.m +10 -0
  63. package/ios/RNGestureHandlerStateManager.h +5 -0
  64. package/ios/RNManualActivationRecognizer.h +10 -0
  65. package/ios/RNManualActivationRecognizer.m +80 -0
  66. package/ios/RNRootViewGestureRecognizer.m +1 -1
  67. package/ios/RNTouchEventType.h +9 -0
  68. package/lib/commonjs/EventType.js +16 -0
  69. package/lib/commonjs/EventType.js.map +1 -0
  70. package/lib/commonjs/GestureHandlerRootView.android.js +1 -13
  71. package/lib/commonjs/GestureHandlerRootView.android.js.map +1 -1
  72. package/lib/commonjs/GestureHandlerRootView.js +11 -3
  73. package/lib/commonjs/GestureHandlerRootView.js.map +1 -1
  74. package/lib/commonjs/RNGestureHandlerModule.js +3 -1
  75. package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
  76. package/lib/commonjs/RNGestureHandlerModule.web.js +2 -2
  77. package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
  78. package/lib/commonjs/components/DrawerLayout.js +41 -37
  79. package/lib/commonjs/components/DrawerLayout.js.map +1 -1
  80. package/lib/commonjs/components/GestureButtons.js.map +1 -1
  81. package/lib/commonjs/components/GestureComponents.js +31 -12
  82. package/lib/commonjs/components/GestureComponents.js.map +1 -1
  83. package/lib/commonjs/components/Swipeable.js +10 -6
  84. package/lib/commonjs/components/Swipeable.js.map +1 -1
  85. package/lib/commonjs/components/touchables/GenericTouchable.js +2 -1
  86. package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
  87. package/lib/commonjs/components/touchables/TouchableOpacity.js +1 -1
  88. package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -1
  89. package/lib/commonjs/gestureHandlerRootHOC.js +1 -1
  90. package/lib/commonjs/gestureHandlerRootHOC.js.map +1 -1
  91. package/lib/commonjs/handlers/FlingGestureHandler.js +23 -0
  92. package/lib/commonjs/handlers/FlingGestureHandler.js.map +1 -0
  93. package/lib/commonjs/handlers/ForceTouchGestureHandler.js +44 -0
  94. package/lib/commonjs/handlers/ForceTouchGestureHandler.js.map +1 -0
  95. package/lib/commonjs/handlers/LongPressGestureHandler.js +23 -0
  96. package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -0
  97. package/lib/commonjs/handlers/NativeViewGestureHandler.js +6 -4
  98. package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +1 -1
  99. package/lib/commonjs/handlers/PanGestureHandler.js +121 -0
  100. package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -0
  101. package/lib/commonjs/handlers/PinchGestureHandler.js +21 -0
  102. package/lib/commonjs/handlers/PinchGestureHandler.js.map +1 -0
  103. package/lib/commonjs/handlers/RotationGestureHandler.js +21 -0
  104. package/lib/commonjs/handlers/RotationGestureHandler.js.map +1 -0
  105. package/lib/commonjs/handlers/TapGestureHandler.js +23 -0
  106. package/lib/commonjs/handlers/TapGestureHandler.js.map +1 -0
  107. package/lib/commonjs/handlers/createHandler.js +65 -84
  108. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  109. package/lib/commonjs/handlers/gestureHandlerCommon.js +80 -0
  110. package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -0
  111. package/lib/commonjs/handlers/gestures/GestureDetector.js +440 -0
  112. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -0
  113. package/lib/commonjs/handlers/gestures/eventReceiver.js +135 -0
  114. package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -0
  115. package/lib/commonjs/handlers/gestures/flingGesture.js +34 -0
  116. package/lib/commonjs/handlers/gestures/flingGesture.js.map +1 -0
  117. package/lib/commonjs/handlers/gestures/forceTouchGesture.js +65 -0
  118. package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -0
  119. package/lib/commonjs/handlers/gestures/gesture.js +193 -0
  120. package/lib/commonjs/handlers/gestures/gesture.js.map +1 -0
  121. package/lib/commonjs/handlers/gestures/gestureComposition.js +94 -0
  122. package/lib/commonjs/handlers/gestures/gestureComposition.js.map +1 -0
  123. package/lib/commonjs/handlers/gestures/gestureObjects.js +85 -0
  124. package/lib/commonjs/handlers/gestures/gestureObjects.js.map +1 -0
  125. package/lib/commonjs/handlers/gestures/gestureStateManager.js +58 -0
  126. package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -0
  127. package/lib/commonjs/handlers/gestures/longPressGesture.js +34 -0
  128. package/lib/commonjs/handlers/gestures/longPressGesture.js.map +1 -0
  129. package/lib/commonjs/handlers/gestures/manualGesture.js +31 -0
  130. package/lib/commonjs/handlers/gestures/manualGesture.js.map +1 -0
  131. package/lib/commonjs/handlers/gestures/nativeGesture.js +34 -0
  132. package/lib/commonjs/handlers/gestures/nativeGesture.js.map +1 -0
  133. package/lib/commonjs/handlers/gestures/panGesture.js +144 -0
  134. package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -0
  135. package/lib/commonjs/handlers/gestures/pinchGesture.js +45 -0
  136. package/lib/commonjs/handlers/gestures/pinchGesture.js.map +1 -0
  137. package/lib/commonjs/handlers/gestures/reanimatedWrapper.js +24 -0
  138. package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -0
  139. package/lib/commonjs/handlers/gestures/rotationGesture.js +45 -0
  140. package/lib/commonjs/handlers/gestures/rotationGesture.js.map +1 -0
  141. package/lib/commonjs/handlers/gestures/tapGesture.js +59 -0
  142. package/lib/commonjs/handlers/gestures/tapGesture.js.map +1 -0
  143. package/lib/commonjs/handlers/handlersRegistry.js +31 -0
  144. package/lib/commonjs/handlers/handlersRegistry.js.map +1 -0
  145. package/lib/commonjs/index.js +40 -8
  146. package/lib/commonjs/index.js.map +1 -1
  147. package/lib/commonjs/init.js +13 -0
  148. package/lib/commonjs/init.js.map +1 -0
  149. package/lib/commonjs/mocks.js +31 -2
  150. package/lib/commonjs/mocks.js.map +1 -1
  151. package/lib/commonjs/utils.js +15 -0
  152. package/lib/commonjs/utils.js.map +1 -0
  153. package/lib/commonjs/web/Errors.js +1 -1
  154. package/lib/commonjs/web/Errors.js.map +1 -1
  155. package/lib/commonjs/web/GestureHandler.js +4 -6
  156. package/lib/commonjs/web/GestureHandler.js.map +1 -1
  157. package/lib/commonjs/web/NodeManager.js +8 -2
  158. package/lib/commonjs/web/NodeManager.js.map +1 -1
  159. package/lib/module/EventType.js +8 -0
  160. package/lib/module/EventType.js.map +1 -0
  161. package/lib/module/GestureHandlerRootView.android.js +2 -14
  162. package/lib/module/GestureHandlerRootView.android.js.map +1 -1
  163. package/lib/module/GestureHandlerRootView.js +5 -1
  164. package/lib/module/GestureHandlerRootView.js.map +1 -1
  165. package/lib/module/RNGestureHandlerModule.js +3 -1
  166. package/lib/module/RNGestureHandlerModule.js.map +1 -1
  167. package/lib/module/RNGestureHandlerModule.web.js +2 -2
  168. package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
  169. package/lib/module/components/DrawerLayout.js +43 -40
  170. package/lib/module/components/DrawerLayout.js.map +1 -1
  171. package/lib/module/components/GestureButtons.js.map +1 -1
  172. package/lib/module/components/GestureComponents.js +29 -11
  173. package/lib/module/components/GestureComponents.js.map +1 -1
  174. package/lib/module/components/Swipeable.js +9 -6
  175. package/lib/module/components/Swipeable.js.map +1 -1
  176. package/lib/module/components/touchables/GenericTouchable.js +2 -1
  177. package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
  178. package/lib/module/components/touchables/TouchableOpacity.js +1 -1
  179. package/lib/module/components/touchables/TouchableOpacity.js.map +1 -1
  180. package/lib/module/gestureHandlerRootHOC.js +1 -1
  181. package/lib/module/gestureHandlerRootHOC.js.map +1 -1
  182. package/lib/module/handlers/FlingGestureHandler.js +10 -0
  183. package/lib/module/handlers/FlingGestureHandler.js.map +1 -0
  184. package/lib/module/handlers/ForceTouchGestureHandler.js +29 -0
  185. package/lib/module/handlers/ForceTouchGestureHandler.js.map +1 -0
  186. package/lib/module/handlers/LongPressGestureHandler.js +10 -0
  187. package/lib/module/handlers/LongPressGestureHandler.js.map +1 -0
  188. package/lib/module/handlers/NativeViewGestureHandler.js +4 -3
  189. package/lib/module/handlers/NativeViewGestureHandler.js.map +1 -1
  190. package/lib/module/handlers/PanGestureHandler.js +106 -0
  191. package/lib/module/handlers/PanGestureHandler.js.map +1 -0
  192. package/lib/module/handlers/PinchGestureHandler.js +9 -0
  193. package/lib/module/handlers/PinchGestureHandler.js.map +1 -0
  194. package/lib/module/handlers/RotationGestureHandler.js +9 -0
  195. package/lib/module/handlers/RotationGestureHandler.js.map +1 -0
  196. package/lib/module/handlers/TapGestureHandler.js +10 -0
  197. package/lib/module/handlers/TapGestureHandler.js.map +1 -0
  198. package/lib/module/handlers/createHandler.js +55 -77
  199. package/lib/module/handlers/createHandler.js.map +1 -1
  200. package/lib/module/handlers/gestureHandlerCommon.js +66 -0
  201. package/lib/module/handlers/gestureHandlerCommon.js.map +1 -0
  202. package/lib/module/handlers/gestures/GestureDetector.js +402 -0
  203. package/lib/module/handlers/gestures/GestureDetector.js.map +1 -0
  204. package/lib/module/handlers/gestures/eventReceiver.js +120 -0
  205. package/lib/module/handlers/gestures/eventReceiver.js.map +1 -0
  206. package/lib/module/handlers/gestures/flingGesture.js +24 -0
  207. package/lib/module/handlers/gestures/flingGesture.js.map +1 -0
  208. package/lib/module/handlers/gestures/forceTouchGesture.js +56 -0
  209. package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -0
  210. package/lib/module/handlers/gestures/gesture.js +175 -0
  211. package/lib/module/handlers/gestures/gesture.js.map +1 -0
  212. package/lib/module/handlers/gestures/gestureComposition.js +79 -0
  213. package/lib/module/handlers/gestures/gestureComposition.js.map +1 -0
  214. package/lib/module/handlers/gestures/gestureObjects.js +67 -0
  215. package/lib/module/handlers/gestures/gestureObjects.js.map +1 -0
  216. package/lib/module/handlers/gestures/gestureStateManager.js +48 -0
  217. package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -0
  218. package/lib/module/handlers/gestures/longPressGesture.js +24 -0
  219. package/lib/module/handlers/gestures/longPressGesture.js.map +1 -0
  220. package/lib/module/handlers/gestures/manualGesture.js +22 -0
  221. package/lib/module/handlers/gestures/manualGesture.js.map +1 -0
  222. package/lib/module/handlers/gestures/nativeGesture.js +24 -0
  223. package/lib/module/handlers/gestures/nativeGesture.js.map +1 -0
  224. package/lib/module/handlers/gestures/panGesture.js +135 -0
  225. package/lib/module/handlers/gestures/panGesture.js.map +1 -0
  226. package/lib/module/handlers/gestures/pinchGesture.js +36 -0
  227. package/lib/module/handlers/gestures/pinchGesture.js.map +1 -0
  228. package/lib/module/handlers/gestures/reanimatedWrapper.js +19 -0
  229. package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -0
  230. package/lib/module/handlers/gestures/rotationGesture.js +36 -0
  231. package/lib/module/handlers/gestures/rotationGesture.js.map +1 -0
  232. package/lib/module/handlers/gestures/tapGesture.js +49 -0
  233. package/lib/module/handlers/gestures/tapGesture.js.map +1 -0
  234. package/lib/module/handlers/handlersRegistry.js +16 -0
  235. package/lib/module/handlers/handlersRegistry.js.map +1 -0
  236. package/lib/module/index.js +11 -1
  237. package/lib/module/index.js.map +1 -1
  238. package/lib/module/init.js +5 -0
  239. package/lib/module/init.js.map +1 -0
  240. package/lib/module/mocks.js +31 -2
  241. package/lib/module/mocks.js.map +1 -1
  242. package/lib/module/utils.js +8 -0
  243. package/lib/module/utils.js.map +1 -0
  244. package/lib/module/web/Errors.js +1 -1
  245. package/lib/module/web/Errors.js.map +1 -1
  246. package/lib/module/web/GestureHandler.js +4 -6
  247. package/lib/module/web/GestureHandler.js.map +1 -1
  248. package/lib/module/web/NodeManager.js +8 -2
  249. package/lib/module/web/NodeManager.js.map +1 -1
  250. package/lib/typescript/EventType.d.ts +8 -0
  251. package/lib/typescript/GestureHandlerRootView.android.d.ts +2 -4
  252. package/lib/typescript/GestureHandlerRootView.d.ts +5 -2
  253. package/lib/typescript/RNGestureHandlerModule.d.ts +1 -1
  254. package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -1
  255. package/lib/typescript/components/DrawerLayout.d.ts +50 -1
  256. package/lib/typescript/components/GestureButtons.d.ts +36 -0
  257. package/lib/typescript/components/GestureComponents.d.ts +8 -35
  258. package/lib/typescript/components/Swipeable.d.ts +73 -6
  259. package/lib/typescript/components/touchables/GenericTouchable.d.ts +2 -2
  260. package/lib/typescript/components/touchables/TouchableHighlight.d.ts +1 -0
  261. package/lib/typescript/components/touchables/TouchableOpacity.d.ts +1 -0
  262. package/lib/typescript/handlers/FlingGestureHandler.d.ts +33 -0
  263. package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +43 -0
  264. package/lib/typescript/handlers/LongPressGestureHandler.d.ts +55 -0
  265. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +19 -4
  266. package/lib/typescript/handlers/PanGestureHandler.d.ts +137 -0
  267. package/lib/typescript/handlers/PinchGestureHandler.d.ts +28 -0
  268. package/lib/typescript/handlers/RotationGestureHandler.d.ts +28 -0
  269. package/lib/typescript/handlers/TapGestureHandler.d.ts +56 -0
  270. package/lib/typescript/handlers/createHandler.d.ts +1 -1
  271. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +62 -0
  272. package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +8 -1
  273. package/lib/typescript/handlers/gestures/GestureDetector.d.ts +16 -0
  274. package/lib/typescript/handlers/gestures/eventReceiver.d.ts +2 -0
  275. package/lib/typescript/handlers/gestures/flingGesture.d.ts +9 -0
  276. package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +16 -0
  277. package/lib/typescript/handlers/gestures/gesture.d.ts +97 -0
  278. package/lib/typescript/handlers/gestures/gestureComposition.d.ts +21 -0
  279. package/lib/typescript/handlers/gestures/gestureObjects.d.ts +39 -0
  280. package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +9 -0
  281. package/lib/typescript/handlers/gestures/longPressGesture.d.ts +9 -0
  282. package/lib/typescript/handlers/gestures/manualGesture.d.ts +7 -0
  283. package/lib/typescript/handlers/gestures/nativeGesture.d.ts +9 -0
  284. package/lib/typescript/handlers/gestures/panGesture.d.ts +26 -0
  285. package/lib/typescript/handlers/gestures/pinchGesture.d.ts +12 -0
  286. package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +14 -0
  287. package/lib/typescript/handlers/gestures/rotationGesture.d.ts +12 -0
  288. package/lib/typescript/handlers/gestures/tapGesture.d.ts +14 -0
  289. package/lib/typescript/handlers/handlersRegistry.d.ts +6 -0
  290. package/lib/typescript/index.d.ts +29 -2
  291. package/lib/typescript/init.d.ts +1 -0
  292. package/lib/typescript/mocks.d.ts +21 -2
  293. package/lib/typescript/utils.d.ts +1 -0
  294. package/lib/typescript/web/FlingGestureHandler.d.ts +0 -1
  295. package/lib/typescript/web/GestureHandler.d.ts +0 -1
  296. package/lib/typescript/web/PanGestureHandler.d.ts +0 -1
  297. package/lib/typescript/web/PinchGestureHandler.d.ts +0 -1
  298. package/lib/typescript/web/PressGestureHandler.d.ts +0 -1
  299. package/lib/typescript/web/RotationGestureHandler.d.ts +0 -1
  300. package/lib/typescript/web/TapGestureHandler.d.ts +0 -1
  301. package/package.json +8 -5
  302. package/src/EventType.ts +10 -0
  303. package/src/GestureHandlerRootView.android.tsx +9 -25
  304. package/src/GestureHandlerRootView.tsx +11 -2
  305. package/src/RNGestureHandlerModule.ts +5 -1
  306. package/src/RNGestureHandlerModule.web.ts +1 -0
  307. package/src/components/DrawerLayout.tsx +114 -41
  308. package/src/components/GestureButtons.tsx +45 -5
  309. package/src/components/GestureComponents.tsx +47 -41
  310. package/src/components/Swipeable.tsx +108 -21
  311. package/src/components/touchables/GenericTouchable.tsx +2 -1
  312. package/src/components/touchables/TouchableOpacity.tsx +1 -1
  313. package/src/handlers/FlingGestureHandler.ts +57 -0
  314. package/src/handlers/ForceTouchGestureHandler.ts +83 -0
  315. package/src/handlers/LongPressGestureHandler.ts +84 -0
  316. package/src/handlers/NativeViewGestureHandler.ts +31 -7
  317. package/src/handlers/PanGestureHandler.ts +321 -0
  318. package/src/handlers/PinchGestureHandler.ts +46 -0
  319. package/src/handlers/RotationGestureHandler.ts +46 -0
  320. package/src/handlers/TapGestureHandler.ts +90 -0
  321. package/src/handlers/createHandler.ts +67 -79
  322. package/src/handlers/gestureHandlerCommon.ts +185 -0
  323. package/src/handlers/gestureHandlerTypesCompat.ts +19 -5
  324. package/src/handlers/gestures/GestureDetector.tsx +519 -0
  325. package/src/handlers/gestures/eventReceiver.ts +151 -0
  326. package/src/handlers/gestures/flingGesture.ts +27 -0
  327. package/src/handlers/gestures/forceTouchGesture.ts +74 -0
  328. package/src/handlers/gestures/gesture.ts +292 -0
  329. package/src/handlers/gestures/gestureComposition.ts +109 -0
  330. package/src/handlers/gestures/gestureObjects.ts +79 -0
  331. package/src/handlers/gestures/gestureStateManager.ts +60 -0
  332. package/src/handlers/gestures/longPressGesture.ts +27 -0
  333. package/src/handlers/gestures/manualGesture.ts +31 -0
  334. package/src/handlers/gestures/nativeGesture.ts +27 -0
  335. package/src/handlers/gestures/panGesture.ts +147 -0
  336. package/src/handlers/gestures/pinchGesture.ts +51 -0
  337. package/src/handlers/gestures/reanimatedWrapper.ts +45 -0
  338. package/src/handlers/gestures/rotationGesture.ts +51 -0
  339. package/src/handlers/gestures/tapGesture.ts +52 -0
  340. package/src/handlers/handlersRegistry.ts +22 -0
  341. package/src/index.ts +57 -17
  342. package/src/init.ts +5 -0
  343. package/src/mocks.ts +42 -2
  344. package/src/utils.ts +7 -0
  345. package/src/web/GestureHandler.ts +1 -2
  346. package/src/web/NodeManager.ts +5 -0
  347. package/android/lib/src/main/java/com/swmansion/gesturehandler/BaseGestureHandlerInteractionController.java +0 -23
  348. package/android/lib/src/main/java/com/swmansion/gesturehandler/FlingGestureHandler.java +0 -110
  349. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.java +0 -531
  350. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerInteractionController.java +0 -8
  351. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.java +0 -543
  352. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistry.java +0 -10
  353. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistryImpl.java +0 -29
  354. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureUtils.java +0 -53
  355. package/android/lib/src/main/java/com/swmansion/gesturehandler/LongPressGestureHandler.java +0 -81
  356. package/android/lib/src/main/java/com/swmansion/gesturehandler/NativeViewGestureHandler.java +0 -110
  357. package/android/lib/src/main/java/com/swmansion/gesturehandler/OnTouchEventListener.java +0 -8
  358. package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.java +0 -312
  359. package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.java +0 -109
  360. package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureDetector.java +0 -169
  361. package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.java +0 -96
  362. package/android/lib/src/main/java/com/swmansion/gesturehandler/TapGestureHandler.java +0 -172
  363. package/android/lib/src/main/java/com/swmansion/gesturehandler/ViewConfigurationHelper.java +0 -10
  364. package/android/src/main/java/com/facebook/react/views/modal/RNGHModalUtils.java +0 -21
  365. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.java +0 -296
  366. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.java +0 -72
  367. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.java +0 -77
  368. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEventDataExtractor.java +0 -8
  369. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.java +0 -86
  370. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.java +0 -731
  371. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerPackage.java +0 -31
  372. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.java +0 -101
  373. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.java +0 -151
  374. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootInterface.java +0 -7
  375. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.java +0 -76
  376. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.java +0 -49
  377. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.java +0 -82
  378. package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.java +0 -61
  379. package/lib/commonjs/handlers/gestureHandlers.js +0 -236
  380. package/lib/commonjs/handlers/gestureHandlers.js.map +0 -1
  381. package/lib/module/handlers/gestureHandlers.js +0 -216
  382. package/lib/module/handlers/gestureHandlers.js.map +0 -1
  383. package/lib/typescript/handlers/gestureHandlers.d.ts +0 -158
  384. package/src/handlers/gestureHandlers.ts +0 -511
@@ -1,22 +1,16 @@
1
- var _UIManager$getViewMan, _UIManager$getViewMan2, _UIManager$getConstan;
1
+ var _UIManagerAny$getView, _UIManagerAny$getView2, _UIManagerAny$getCons;
2
2
 
3
3
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
4
 
5
5
  import * as React from 'react';
6
- import { findNodeHandle as findNodeHandleRN, NativeModules, Platform, Touchable } from 'react-native'; // @ts-ignore - it isn't typed by TS & don't have definitelyTyped types
6
+ import { Platform, Touchable, UIManager, DeviceEventEmitter } from 'react-native'; // @ts-ignore - it isn't typed by TS & don't have definitelyTyped types
7
7
 
8
- import deepEqual from 'fbjs/lib/areEqual';
8
+ import deepEqual from 'lodash/isEqual';
9
9
  import RNGestureHandlerModule from '../RNGestureHandlerModule';
10
10
  import { State } from '../State';
11
-
12
- function findNodeHandle(node) {
13
- if (Platform.OS === 'web') return node;
14
- return findNodeHandleRN(node);
15
- }
16
-
17
- const {
18
- UIManager = {}
19
- } = NativeModules;
11
+ import { handlerIDToTag, getNextHandlerTag } from './handlersRegistry';
12
+ import { filterConfig, findNodeHandle } from './gestureHandlerCommon';
13
+ const UIManagerAny = UIManager;
20
14
  const customGHEventsConfig = {
21
15
  onGestureHandlerEvent: {
22
16
  registrationName: 'onGestureHandlerEvent'
@@ -29,13 +23,13 @@ const customGHEventsConfig = {
29
23
  // Once new event types are registered with react it is possible to dispatch these
30
24
  // events to all kind of native views.
31
25
 
32
- UIManager.genericDirectEventTypes = { ...UIManager.genericDirectEventTypes,
26
+ UIManagerAny.genericDirectEventTypes = { ...UIManagerAny.genericDirectEventTypes,
33
27
  ...customGHEventsConfig
34
28
  }; // In newer versions of RN the `genericDirectEventTypes` is located in the object
35
29
  // returned by UIManager.getViewManagerConfig('getConstants') or in older RN UIManager.getConstants(), we need to add it there as well to make
36
30
  // it compatible with RN 61+
37
31
 
38
- const UIManagerConstants = (_UIManager$getViewMan = (_UIManager$getViewMan2 = UIManager.getViewManagerConfig) === null || _UIManager$getViewMan2 === void 0 ? void 0 : _UIManager$getViewMan2.call(UIManager, 'getConstants')) !== null && _UIManager$getViewMan !== void 0 ? _UIManager$getViewMan : (_UIManager$getConstan = UIManager.getConstants) === null || _UIManager$getConstan === void 0 ? void 0 : _UIManager$getConstan.call(UIManager);
32
+ const UIManagerConstants = (_UIManagerAny$getView = (_UIManagerAny$getView2 = UIManagerAny.getViewManagerConfig) === null || _UIManagerAny$getView2 === void 0 ? void 0 : _UIManagerAny$getView2.call(UIManagerAny, 'getConstants')) !== null && _UIManagerAny$getView !== void 0 ? _UIManagerAny$getView : (_UIManagerAny$getCons = UIManagerAny.getConstants) === null || _UIManagerAny$getCons === void 0 ? void 0 : _UIManagerAny$getCons.call(UIManagerAny);
39
33
 
40
34
  if (UIManagerConstants) {
41
35
  UIManagerConstants.genericDirectEventTypes = { ...UIManagerConstants.genericDirectEventTypes,
@@ -49,72 +43,26 @@ const {
49
43
  },
50
44
  clearJSResponder: oldClearJSResponder = () => {//no operation
51
45
  }
52
- } = UIManager;
46
+ } = UIManagerAny;
53
47
 
54
- UIManager.setJSResponder = (tag, blockNativeResponder) => {
48
+ UIManagerAny.setJSResponder = (tag, blockNativeResponder) => {
55
49
  RNGestureHandlerModule.handleSetJSResponder(tag, blockNativeResponder);
56
50
  oldSetJSResponder(tag, blockNativeResponder);
57
51
  };
58
52
 
59
- UIManager.clearJSResponder = () => {
53
+ UIManagerAny.clearJSResponder = () => {
60
54
  RNGestureHandlerModule.handleClearJSResponder();
61
55
  oldClearJSResponder();
62
56
  };
63
57
 
64
- let handlerTag = 1;
65
- const handlerIDToTag = {};
66
-
67
- function isConfigParam(param, name) {
68
- // param !== Object(param) returns false if `param` is a function
69
- // or an object and returns true if `param` is null
70
- return param !== undefined && (param !== Object(param) || !('__isNative' in param)) && name !== 'onHandlerStateChange' && name !== 'onGestureEvent';
71
- }
72
-
73
- function filterConfig(props, validProps, defaults = {}) {
74
- const res = { ...defaults
75
- };
76
- validProps.forEach(key => {
77
- const value = props[key];
78
-
79
- if (isConfigParam(value, key)) {
80
- let value = props[key];
81
-
82
- if (key === 'simultaneousHandlers' || key === 'waitFor') {
83
- value = transformIntoHandlerTags(props[key]);
84
- } else if (key === 'hitSlop') {
85
- if (typeof value !== 'object') {
86
- value = {
87
- top: value,
88
- left: value,
89
- bottom: value,
90
- right: value
91
- };
92
- }
93
- }
58
+ let allowTouches = true;
59
+ const DEV_ON_ANDROID = __DEV__ && Platform.OS === 'android'; // Toggled inspector blocks touch events in order to allow inspecting on Android
60
+ // This needs to be a global variable in order to set initial state for `allowTouches` property in Handler component
94
61
 
95
- res[key] = value;
96
- }
62
+ if (DEV_ON_ANDROID) {
63
+ DeviceEventEmitter.addListener('toggleElementInspector', () => {
64
+ allowTouches = !allowTouches;
97
65
  });
98
- return res;
99
- }
100
-
101
- function transformIntoHandlerTags(handlerIDs) {
102
- if (!Array.isArray(handlerIDs)) {
103
- handlerIDs = [handlerIDs];
104
- }
105
-
106
- if (Platform.OS === 'web') {
107
- return handlerIDs.map(({
108
- current
109
- }) => current).filter(handle => handle);
110
- } // converts handler string IDs into their numeric tags
111
-
112
-
113
- return handlerIDs.map(handlerID => {
114
- var _handlerID$current;
115
-
116
- return handlerIDToTag[handlerID] || ((_handlerID$current = handlerID.current) === null || _handlerID$current === void 0 ? void 0 : _handlerID$current.handlerTag) || -1;
117
- }).filter(handlerTag => handlerTag > 0);
118
66
  }
119
67
 
120
68
  function hasUnresolvedRefs(props) {
@@ -138,7 +86,16 @@ const stateToPropMappings = {
138
86
  [State.ACTIVE]: 'onActivated',
139
87
  [State.END]: 'onEnded'
140
88
  };
141
- // TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.
89
+ let showedRngh2Notice = false;
90
+
91
+ function showRngh2NoticeIfNeeded() {
92
+ if (!showedRngh2Notice) {
93
+ console.warn("[react-native-gesture-handler] Seems like you're using an old API with gesture components, check out new Gestures system!");
94
+ showedRngh2Notice = true;
95
+ }
96
+ } // TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.
97
+
98
+
142
99
  export default function createHandler({
143
100
  name,
144
101
  allowedProps = [],
@@ -162,6 +119,8 @@ export default function createHandler({
162
119
 
163
120
  _defineProperty(this, "updateEnqueued", null);
164
121
 
122
+ _defineProperty(this, "inspectorToggleListener", void 0);
123
+
165
124
  _defineProperty(this, "onGestureHandlerEvent", event => {
166
125
  if (event.nativeEvent.handlerTag === this.handlerTag) {
167
126
  var _this$props$onGesture, _this$props;
@@ -220,9 +179,9 @@ export default function createHandler({
220
179
 
221
180
  if (Platform.OS === 'web') {
222
181
  // typecast due to dynamic resolution, attachGestureHandler should have web version signature in this branch
223
- RNGestureHandlerModule.attachGestureHandler(this.handlerTag, newViewTag, this.propsRef);
182
+ RNGestureHandlerModule.attachGestureHandler(this.handlerTag, newViewTag, false, this.propsRef);
224
183
  } else {
225
- RNGestureHandlerModule.attachGestureHandler(this.handlerTag, newViewTag);
184
+ RNGestureHandlerModule.attachGestureHandler(this.handlerTag, newViewTag, false);
226
185
  }
227
186
  });
228
187
 
@@ -231,27 +190,43 @@ export default function createHandler({
231
190
  RNGestureHandlerModule.updateGestureHandler(this.handlerTag, newConfig);
232
191
  });
233
192
 
234
- this.handlerTag = handlerTag++;
193
+ this.handlerTag = getNextHandlerTag();
235
194
  this.config = {};
236
195
  this.propsRef = /*#__PURE__*/React.createRef();
196
+ this.state = {
197
+ allowTouches
198
+ };
237
199
 
238
200
  if (props.id) {
239
201
  if (handlerIDToTag[props.id] !== undefined) {
240
- throw new Error("Handler with ID \"".concat(props.id, "\" already registered"));
202
+ throw new Error(`Handler with ID "${props.id}" already registered`);
241
203
  }
242
204
 
243
205
  handlerIDToTag[props.id] = this.handlerTag;
244
206
  }
207
+
208
+ if (__DEV__) {
209
+ showRngh2NoticeIfNeeded();
210
+ }
245
211
  }
246
212
 
247
213
  componentDidMount() {
248
214
  const props = this.props;
249
215
 
216
+ if (DEV_ON_ANDROID) {
217
+ this.inspectorToggleListener = DeviceEventEmitter.addListener('toggleElementInspector', () => {
218
+ this.setState(_ => ({
219
+ allowTouches
220
+ }));
221
+ this.update();
222
+ });
223
+ }
224
+
250
225
  if (hasUnresolvedRefs(props)) {
251
226
  // If there are unresolved refs (e.g. ".current" has not yet been set)
252
227
  // passed as `simultaneousHandlers` or `waitFor`, we enqueue a call to
253
228
  // _update method that will try to update native handler props using
254
- // setImmediate. This makes it so _update function gets called after all
229
+ // setImmediate. This makes it so update() function gets called after all
255
230
  // react components are mounted and we expect the missing ref object to
256
231
  // be resolved by then.
257
232
  this.updateEnqueued = setImmediate(() => {
@@ -275,6 +250,9 @@ export default function createHandler({
275
250
  }
276
251
 
277
252
  componentWillUnmount() {
253
+ var _this$inspectorToggle;
254
+
255
+ (_this$inspectorToggle = this.inspectorToggleListener) === null || _this$inspectorToggle === void 0 ? void 0 : _this$inspectorToggle.remove();
278
256
  RNGestureHandlerModule.dropGestureHandler(this.handlerTag);
279
257
 
280
258
  if (this.updateEnqueued) {
@@ -352,8 +330,8 @@ export default function createHandler({
352
330
  }
353
331
 
354
332
  const events = {
355
- onGestureHandlerEvent: gestureEventHandler,
356
- onGestureHandlerStateChange: gestureStateEventHandler
333
+ onGestureHandlerEvent: this.state.allowTouches ? gestureEventHandler : undefined,
334
+ onGestureHandlerStateChange: this.state.allowTouches ? gestureStateEventHandler : undefined
357
335
  };
358
336
  this.propsRef.current = events;
359
337
  const child = React.Children.only(this.props.children);
@@ -1 +1 @@
1
- {"version":3,"sources":["createHandler.ts"],"names":["React","findNodeHandle","findNodeHandleRN","NativeModules","Platform","Touchable","deepEqual","RNGestureHandlerModule","State","node","OS","UIManager","customGHEventsConfig","onGestureHandlerEvent","registrationName","onGestureHandlerStateChange","genericDirectEventTypes","UIManagerConstants","getViewManagerConfig","getConstants","setJSResponder","oldSetJSResponder","clearJSResponder","oldClearJSResponder","tag","blockNativeResponder","handleSetJSResponder","handleClearJSResponder","handlerTag","handlerIDToTag","isConfigParam","param","name","undefined","Object","filterConfig","props","validProps","defaults","res","forEach","key","value","transformIntoHandlerTags","top","left","bottom","right","handlerIDs","Array","isArray","map","current","filter","handle","handlerID","hasUnresolvedRefs","extract","refs","some","r","stateToPropMappings","UNDETERMINED","BEGAN","FAILED","CANCELLED","ACTIVE","END","createHandler","allowedProps","config","transformProps","customNativeProps","Handler","Component","constructor","event","nativeEvent","onGestureEvent","onHandlerStateChange","state","stateEventName","eventHandler","viewNode","child","Children","only","children","ref","newConfig","createGestureHandler","newViewTag","viewTag","attachGestureHandler","propsRef","updateGestureHandler","createRef","id","Error","componentDidMount","updateEnqueued","setImmediate","update","componentDidUpdate","componentWillUnmount","dropGestureHandler","clearImmediate","setNativeProps","updates","mergedProps","render","gestureEventHandler","gestureStateEventHandler","events","grandChildren","TOUCH_TARGET_DEBUG","type","displayName","toArray","push","renderDebugView","color","hitSlop","cloneElement","refHandler","collapsable"],"mappings":";;;;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,cAAc,IAAIC,gBADpB,EAEEC,aAFF,EAGEC,QAHF,EAIEC,SAJF,QAKO,cALP,C,CAMA;;AACA,OAAOC,SAAP,MAAsB,mBAAtB;AACA,OAAOC,sBAAP,MAAmC,2BAAnC;AAEA,SAASC,KAAT,QAAsB,UAAtB;;AASA,SAASP,cAAT,CACEQ,IADF,EAEyE;AACvE,MAAIL,QAAQ,CAACM,EAAT,KAAgB,KAApB,EAA2B,OAAOD,IAAP;AAC3B,SAAOP,gBAAgB,CAACO,IAAD,CAAvB;AACD;;AAED,MAAM;AAAEE,EAAAA,SAAS,GAAG;AAAd,IAAqBR,aAA3B;AAEA,MAAMS,oBAAoB,GAAG;AAC3BC,EAAAA,qBAAqB,EAAE;AAAEC,IAAAA,gBAAgB,EAAE;AAApB,GADI;AAE3BC,EAAAA,2BAA2B,EAAE;AAC3BD,IAAAA,gBA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WAAGZ;AAHL,OAFK,EAOLC,aAPK,CAAP;AASD;;AA1Q8D;;AADS,kBACpEzC,OADoE,iBAEnDzC,IAFmD;;AA6Q1E,SAAOyC,OAAP;AACD","sourcesContent":["import * as React from 'react';\nimport {\n findNodeHandle as findNodeHandleRN,\n NativeModules,\n Platform,\n Touchable,\n} from 'react-native';\n// @ts-ignore - it isn't typed by TS & don't have definitelyTyped types\nimport deepEqual from 'fbjs/lib/areEqual';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\nimport type RNGestureHandlerModuleWeb from '../RNGestureHandlerModule.web';\nimport { State } from '../State';\n\nimport {\n BaseGestureHandlerProps,\n GestureEvent,\n HandlerStateChangeEvent,\n} from './gestureHandlers';\nimport { ValueOf } from '../typeUtils';\n\nfunction 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\nconst { UIManager = {} } = NativeModules;\n\nconst customGHEventsConfig = {\n onGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n onGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\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.\nUIManager.genericDirectEventTypes = {\n ...UIManager.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 UIManager.getViewManagerConfig?.('getConstants') ??\n UIManager.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} = UIManager;\nUIManager.setJSResponder = (tag: number, blockNativeResponder: boolean) => {\n RNGestureHandlerModule.handleSetJSResponder(tag, blockNativeResponder);\n oldSetJSResponder(tag, blockNativeResponder);\n};\nUIManager.clearJSResponder = () => {\n RNGestureHandlerModule.handleClearJSResponder();\n oldClearJSResponder();\n};\n\nlet handlerTag = 1;\nconst handlerIDToTag: Record<string, number> = {};\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\nfunction filterConfig(\n props: Record<string, unknown>,\n validProps: string[],\n defaults: Record<string, unknown> = {}\n) {\n const res = { ...defaults };\n validProps.forEach((key) => {\n const value = props[key];\n if (isConfigParam(value, key)) {\n let value = props[key];\n if (key === 'simultaneousHandlers' || key === 'waitFor') {\n value = transformIntoHandlerTags(props[key]);\n } else if (key === 'hitSlop') {\n if (typeof value !== 'object') {\n value = { top: value, left: value, bottom: value, right: value };\n }\n }\n res[key] = value;\n }\n });\n return res;\n}\n\nfunction transformIntoHandlerTags(handlerIDs: any) {\n if (!Array.isArray(handlerIDs)) {\n handlerIDs = [handlerIDs];\n }\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\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 class Handler extends React.Component<T & InternalEventHandlers> {\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\n constructor(props: T & InternalEventHandlers) {\n super(props);\n this.handlerTag = handlerTag++;\n this.config = {};\n this.propsRef = React.createRef();\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 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 RNGestureHandlerModule.dropGestureHandler(this.handlerTag);\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 this.props.onGestureEvent?.(event);\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 this.props.onHandlerStateChange?.(event);\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 this.propsRef\n );\n } else {\n RNGestureHandlerModule.attachGestureHandler(\n this.handlerTag,\n newViewTag\n );\n }\n };\n\n private updateGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.updateGestureHandler(this.handlerTag, newConfig);\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: gestureEventHandler,\n onGestureHandlerStateChange: gestureStateEventHandler,\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 ...events,\n },\n grandChildren\n );\n }\n }\n return Handler;\n}\n"]}
1
+ {"version":3,"sources":["createHandler.ts"],"names":["React","Platform","Touchable","UIManager","DeviceEventEmitter","deepEqual","RNGestureHandlerModule","State","handlerIDToTag","getNextHandlerTag","filterConfig","findNodeHandle","UIManagerAny","customGHEventsConfig","onGestureHandlerEvent","registrationName","onGestureHandlerStateChange","genericDirectEventTypes","UIManagerConstants","getViewManagerConfig","getConstants","setJSResponder","oldSetJSResponder","clearJSResponder","oldClearJSResponder","tag","blockNativeResponder","handleSetJSResponder","handleClearJSResponder","allowTouches","DEV_ON_ANDROID","__DEV__","OS","addListener","hasUnresolvedRefs","props","extract","refs","Array","isArray","current","some","r","stateToPropMappings","UNDETERMINED","undefined","BEGAN","FAILED","CANCELLED","ACTIVE","END","showedRngh2Notice","showRngh2NoticeIfNeeded","console","warn","createHandler","name","allowedProps","config","transformProps","customNativeProps","Handler","Component","constructor","event","nativeEvent","handlerTag","onGestureEvent","onHandlerStateChange","state","stateEventName","eventHandler","node","viewNode","child","Children","only","children","ref","newConfig","createGestureHandler","newViewTag","viewTag","attachGestureHandler","propsRef","updateGestureHandler","createRef","id","Error","componentDidMount","inspectorToggleListener","setState","_","update","updateEnqueued","setImmediate","componentDidUpdate","componentWillUnmount","remove","dropGestureHandler","clearImmediate","handlerID","setNativeProps","updates","mergedProps","render","gestureEventHandler","gestureStateEventHandler","events","grandChildren","TOUCH_TARGET_DEBUG","type","displayName","toArray","push","renderDebugView","color","hitSlop","cloneElement","refHandler","collapsable"],"mappings":";;;;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,QADF,EAEEC,SAFF,EAGEC,SAHF,EAIEC,kBAJF,QAMO,cANP,C,CAOA;;AACA,OAAOC,SAAP,MAAsB,gBAAtB;AACA,OAAOC,sBAAP,MAAmC,2BAAnC;AAEA,SAASC,KAAT,QAAsB,UAAtB;AACA,SAASC,cAAT,EAAyBC,iBAAzB,QAAkD,oBAAlD;AAEA,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AAIgC,aAAa,GAAGnC,KAAK,CAACvC,KAAN,CAAY0C,QAAhC;;AACA,UACE3E,SAAS,CAAC4G,kBAAV,IACApC,KAAK,CAACqC,IADN,KAECrC,KAAK,CAACqC,IAAN,KAAe,wBAAf,IACCrC,KAAK,CAACqC,IAAN,CAAWvD,IAAX,KAAoB,MADrB,IAECkB,KAAK,CAACqC,IAAN,CAAWC,WAAX,KAA2B,MAJ7B,CADF,EAME;AACAH,QAAAA,aAAa,GAAG7G,KAAK,CAAC2E,QAAN,CAAesC,OAAf,CAAuBJ,aAAvB,CAAhB;AACAA,QAAAA,aAAa,CAACK,IAAd,CACEhH,SAAS,CAACiH,eAAV,CAA0B;AACxBC,UAAAA,KAAK,EAAE,mBADiB;AAExBC,UAAAA,OAAO,EAAE3C,KAAK,CAACvC,KAAN,CAAYkF;AAFG,SAA1B,CADF;AAMD;;AAED,0BAAOrH,KAAK,CAACsH,YAAN,CACL5C,KADK,EAEL;AACEI,QAAAA,GAAG,EAAE,KAAKyC,UADZ;AAEEC,QAAAA,WAAW,EAAE,KAFf;AAGE,WAAGZ;AAHL,OAFK,EAOLC,aAPK,CAAP;AASD;;AAhSD;;AAPwE,kBAIpEhD,OAJoE,iBAQnDL,IARmD;;AAyS1E,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 { handlerIDToTag, getNextHandlerTag } from './handlersRegistry';\n\nimport {\n BaseGestureHandlerProps,\n filterConfig,\n GestureEvent,\n HandlerStateChangeEvent,\n findNodeHandle,\n} from './gestureHandlerCommon';\nimport { ValueOf } from '../typeUtils';\n\nconst UIManagerAny = UIManager as any;\n\nconst customGHEventsConfig = {\n onGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n onGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\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\nlet showedRngh2Notice = false;\nfunction showRngh2NoticeIfNeeded() {\n if (!showedRngh2Notice) {\n console.warn(\n \"[react-native-gesture-handler] Seems like you're using an old API with gesture components, check out new Gestures system!\"\n );\n showedRngh2Notice = true;\n }\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 if (__DEV__) {\n showRngh2NoticeIfNeeded();\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 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 this.props.onGestureEvent?.(event);\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 this.props.onHandlerStateChange?.(event);\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 false,\n this.propsRef\n );\n } else {\n RNGestureHandlerModule.attachGestureHandler(\n this.handlerTag,\n newViewTag,\n false\n );\n }\n };\n\n private updateGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.updateGestureHandler(this.handlerTag, newConfig);\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 ...events,\n },\n grandChildren\n );\n }\n }\n return Handler;\n}\n"]}
@@ -0,0 +1,66 @@
1
+ // Previous types exported gesture handlers as classes which creates an interface and variable, both named the same as class.
2
+ // Without those types, we'd introduce breaking change, forcing users to prefix every handler type specification with typeof
3
+ // e.g. React.createRef<TapGestureHandler> -> React.createRef<typeof TapGestureHandler>.
4
+ // See https://www.typescriptlang.org/docs/handbook/classes.html#constructor-functions for reference.
5
+ import { Platform, findNodeHandle as findNodeHandleRN } from 'react-native';
6
+ import { handlerIDToTag } from './handlersRegistry';
7
+ import { toArray } from '../utils';
8
+ const commonProps = ['id', 'enabled', 'shouldCancelWhenOutside', 'hitSlop'];
9
+ const componentInteractionProps = ['waitFor', 'simultaneousHandlers'];
10
+ export const baseGestureHandlerProps = [...commonProps, ...componentInteractionProps, 'onBegan', 'onFailed', 'onCancelled', 'onActivated', 'onEnded', 'onGestureEvent', 'onHandlerStateChange'];
11
+ export const baseGestureHandlerWithMonitorProps = [...commonProps, 'needsPointerData', 'manualActivation'];
12
+
13
+ function isConfigParam(param, name) {
14
+ // param !== Object(param) returns false if `param` is a function
15
+ // or an object and returns true if `param` is null
16
+ return param !== undefined && (param !== Object(param) || !('__isNative' in param)) && name !== 'onHandlerStateChange' && name !== 'onGestureEvent';
17
+ }
18
+
19
+ export function filterConfig(props, validProps, defaults = {}) {
20
+ const filteredConfig = { ...defaults
21
+ };
22
+
23
+ for (const key of validProps) {
24
+ let value = props[key];
25
+
26
+ if (isConfigParam(value, key)) {
27
+ if (key === 'simultaneousHandlers' || key === 'waitFor') {
28
+ value = transformIntoHandlerTags(props[key]);
29
+ } else if (key === 'hitSlop' && typeof value !== 'object') {
30
+ value = {
31
+ top: value,
32
+ left: value,
33
+ bottom: value,
34
+ right: value
35
+ };
36
+ }
37
+
38
+ filteredConfig[key] = value;
39
+ }
40
+ }
41
+
42
+ return filteredConfig;
43
+ }
44
+
45
+ function transformIntoHandlerTags(handlerIDs) {
46
+ handlerIDs = toArray(handlerIDs);
47
+
48
+ if (Platform.OS === 'web') {
49
+ return handlerIDs.map(({
50
+ current
51
+ }) => current).filter(handle => handle);
52
+ } // converts handler string IDs into their numeric tags
53
+
54
+
55
+ return handlerIDs.map(handlerID => {
56
+ var _handlerID$current;
57
+
58
+ return handlerIDToTag[handlerID] || ((_handlerID$current = handlerID.current) === null || _handlerID$current === void 0 ? void 0 : _handlerID$current.handlerTag) || -1;
59
+ }).filter(handlerTag => handlerTag > 0);
60
+ }
61
+
62
+ export function findNodeHandle(node) {
63
+ if (Platform.OS === 'web') return node;
64
+ return findNodeHandleRN(node);
65
+ }
66
+ //# sourceMappingURL=gestureHandlerCommon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["gestureHandlerCommon.ts"],"names":["Platform","findNodeHandle","findNodeHandleRN","handlerIDToTag","toArray","commonProps","componentInteractionProps","baseGestureHandlerProps","baseGestureHandlerWithMonitorProps","isConfigParam","param","name","undefined","Object","filterConfig","props","validProps","defaults","filteredConfig","key","value","transformIntoHandlerTags","top","left","bottom","right","handlerIDs","OS","map","current","filter","handle","handlerID","handlerTag","node"],"mappings":"AAAA;AACA;AACA;AACA;AAEA,SAASA,QAAT,EAAmBC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B,OAAOC,KAAP,KAAiB,QAA1C,EAAoD;AACzDA,QAAAA,KAAK,GAAG;AAAEE,UAAAA,GAAG,EAAEF,KAAP;AAAcG,UAAAA,IAAI,EAAEH,KAApB;AAA2BI,UAAAA,MAAM,EAAEJ,KAAnC;AAA0CK,UAAAA,KAAK,EAAEL;AAAjD,SAAR;AACD;;AACDF,MAAAA,cAAc,CAACC,GAAD,CAAd,GAAsBC,KAAtB;AACD;AACF;;AACD,SAAOF,cAAP;AACD;;AAED,SAASG,wBAAT,CAAkCK,UAAlC,EAAmD;AACjDA,EAAAA,UAAU,GAAGtB,OAAO,CAACsB,UAAD,CAApB;;AAEA,MAAI1B,QAAQ,CAAC2B,EAAT,KAAgB,KAApB,EAA2B;AACzB,WAAOD,UAAU,CACdE,GADI,CACA,CAAC;AAAEC,MAAAA;AAAF,KAAD,KAAmCA,OADnC,EAEJC,MAFI,CAEIC,MAAD,IAAiBA,MAFpB,CAAP;AAGD,GAPgD,CAQjD;;;AACA,SAAOL,UAAU,CACdE,GADI,CAEFI,SAAD;AAAA;;AAAA,WACE7B,cAAc,CAAC6B,SAAD,CAAd,2BAA6BA,SAAS,CAACH,OAAvC,uDAA6B,mBAAmBI,UAAhD,KAA8D,CAAC,CADjE;AAAA,GAFG,EAKJH,MALI,CAKIG,UAAD,IAAwBA,UAAU,GAAG,CALxC,CAAP;AAMD;;AAED,OAAO,SAAShC,cAAT,CACLiC,IADK,EAEkE;AACvE,MAAIlC,QAAQ,CAAC2B,EAAT,KAAgB,KAApB,EAA2B,OAAOO,IAAP;AAC3B,SAAOhC,gBAAgB,CAACgC,IAAD,CAAvB;AACD","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 { EventType } from '../EventType';\nimport { ValueOf } from '../typeUtils';\nimport { handlerIDToTag } from './handlersRegistry';\nimport { toArray } from '../utils';\n\nconst commonProps = [\n 'id',\n 'enabled',\n 'shouldCancelWhenOutside',\n 'hitSlop',\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}\n\nexport interface HandlerStateChangeEventPayload {\n handlerTag: number;\n numberOfPointers: number;\n state: ValueOf<typeof State>;\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: EventType;\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 // 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"]}