react-native-gesture-handler 2.7.1 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (232) hide show
  1. package/RNGestureHandler.podspec +1 -1
  2. package/android/build.gradle +53 -46
  3. package/android/noreanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt +3 -3
  4. package/android/reanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt +7 -7
  5. package/android/src/fabric/java/com/swmansion/gesturehandler/ReactContextExtensions.kt +2 -2
  6. package/android/src/main/java/com/swmansion/gesturehandler/RNGestureHandlerPackage.kt +3 -3
  7. package/android/{lib/src/main/java/com/swmansion/gesturehandler → src/main/java/com/swmansion/gesturehandler/core}/FlingGestureHandler.kt +12 -9
  8. package/android/{lib/src/main/java/com/swmansion/gesturehandler → src/main/java/com/swmansion/gesturehandler/core}/GestureHandler.kt +39 -31
  9. package/android/{lib/src/main/java/com/swmansion/gesturehandler → src/main/java/com/swmansion/gesturehandler/core}/GestureHandlerInteractionController.kt +1 -1
  10. package/android/{lib/src/main/java/com/swmansion/gesturehandler → src/main/java/com/swmansion/gesturehandler/core}/GestureHandlerOrchestrator.kt +28 -19
  11. package/android/{lib/src/main/java/com/swmansion/gesturehandler → src/main/java/com/swmansion/gesturehandler/core}/GestureHandlerRegistry.kt +1 -1
  12. package/android/{lib/src/main/java/com/swmansion/gesturehandler → src/main/java/com/swmansion/gesturehandler/core}/GestureUtils.kt +1 -1
  13. package/android/{lib/src/main/java/com/swmansion/gesturehandler → src/main/java/com/swmansion/gesturehandler/core}/LongPressGestureHandler.kt +1 -1
  14. package/android/{lib/src/main/java/com/swmansion/gesturehandler → src/main/java/com/swmansion/gesturehandler/core}/ManualGestureHandler.kt +1 -1
  15. package/android/{lib/src/main/java/com/swmansion/gesturehandler → src/main/java/com/swmansion/gesturehandler/core}/NativeViewGestureHandler.kt +5 -5
  16. package/android/{lib/src/main/java/com/swmansion/gesturehandler → src/main/java/com/swmansion/gesturehandler/core}/OnTouchEventListener.kt +1 -1
  17. package/android/{lib/src/main/java/com/swmansion/gesturehandler → src/main/java/com/swmansion/gesturehandler/core}/PanGestureHandler.kt +7 -5
  18. package/android/{lib/src/main/java/com/swmansion/gesturehandler → src/main/java/com/swmansion/gesturehandler/core}/PinchGestureHandler.kt +11 -4
  19. package/android/{lib/src/main/java/com/swmansion/gesturehandler → src/main/java/com/swmansion/gesturehandler/core}/PointerEventsConfig.kt +1 -1
  20. package/android/{lib/src/main/java/com/swmansion/gesturehandler → src/main/java/com/swmansion/gesturehandler/core}/RotationGestureDetector.kt +1 -1
  21. package/android/{lib/src/main/java/com/swmansion/gesturehandler → src/main/java/com/swmansion/gesturehandler/core}/RotationGestureHandler.kt +7 -2
  22. package/android/{lib/src/main/java/com/swmansion/gesturehandler → src/main/java/com/swmansion/gesturehandler/core}/ScaleGestureDetector.java +1 -1
  23. package/android/{lib/src/main/java/com/swmansion/gesturehandler → src/main/java/com/swmansion/gesturehandler/core}/TapGestureHandler.kt +3 -3
  24. package/android/{lib/src/main/java/com/swmansion/gesturehandler → src/main/java/com/swmansion/gesturehandler/core}/ViewConfigurationHelper.kt +1 -1
  25. package/android/{lib/src/main/java/com/swmansion/gesturehandler → src/main/java/com/swmansion/gesturehandler/react}/Extensions.kt +3 -3
  26. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +8 -6
  27. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.kt +1 -5
  28. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +20 -8
  29. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEventDataExtractor.kt +1 -1
  30. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt +3 -3
  31. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +40 -15
  32. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.kt +2 -2
  33. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +8 -6
  34. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +0 -2
  35. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.kt +4 -2
  36. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt +7 -7
  37. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerTouchEvent.kt +5 -5
  38. package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.kt +2 -2
  39. package/android/src/main/jni/CMakeLists.txt +10 -44
  40. package/android/src/main/jni/cpp-adapter.cpp +16 -13
  41. package/android/src/paper/java/com/swmansion/gesturehandler/ReactContextExtensions.kt +5 -5
  42. package/ios/Handlers/RNFlingHandler.m +39 -37
  43. package/ios/Handlers/RNForceTouchHandler.m +19 -17
  44. package/ios/Handlers/RNLongPressHandler.m +20 -22
  45. package/ios/Handlers/RNManualHandler.m +23 -8
  46. package/ios/Handlers/RNNativeViewHandler.mm +92 -88
  47. package/ios/Handlers/RNPanHandler.m +28 -32
  48. package/ios/Handlers/RNPinchHandler.m +9 -10
  49. package/ios/Handlers/RNRotationHandler.m +11 -14
  50. package/ios/Handlers/RNTapHandler.m +26 -26
  51. package/ios/RNGestureHandler.h +31 -24
  52. package/ios/RNGestureHandler.m +278 -273
  53. package/ios/RNGestureHandlerActionType.h +6 -4
  54. package/ios/RNGestureHandlerButton.m +11 -12
  55. package/ios/RNGestureHandlerButtonComponentView.mm +7 -8
  56. package/ios/RNGestureHandlerButtonManager.m +6 -5
  57. package/ios/RNGestureHandlerDirection.h +4 -4
  58. package/ios/RNGestureHandlerEvents.h +3 -4
  59. package/ios/RNGestureHandlerEvents.m +114 -119
  60. package/ios/RNGestureHandlerManager.h +1 -2
  61. package/ios/RNGestureHandlerManager.mm +176 -178
  62. package/ios/RNGestureHandlerModule.h +1 -2
  63. package/ios/RNGestureHandlerModule.mm +126 -122
  64. package/ios/RNGestureHandlerPointerTracker.h +1 -1
  65. package/ios/RNGestureHandlerPointerTracker.m +40 -37
  66. package/ios/RNGestureHandlerRegistry.h +3 -1
  67. package/ios/RNGestureHandlerRegistry.m +24 -22
  68. package/ios/RNGestureHandlerState.h +6 -6
  69. package/ios/RNGestureHandlerStateManager.h +1 -1
  70. package/ios/RNManualActivationRecognizer.m +9 -9
  71. package/ios/RNRootViewGestureRecognizer.m +36 -39
  72. package/lib/commonjs/RNGestureHandlerModule.macos.js.map +1 -1
  73. package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
  74. package/lib/commonjs/RNGestureHandlerModule.windows.js +156 -0
  75. package/lib/commonjs/RNGestureHandlerModule.windows.js.map +1 -0
  76. package/lib/commonjs/components/DrawerLayout.js +1 -0
  77. package/lib/commonjs/components/DrawerLayout.js.map +1 -1
  78. package/lib/commonjs/components/Swipeable.js.map +1 -1
  79. package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -1
  80. package/lib/commonjs/gestureHandlerRootHOC.js +2 -1
  81. package/lib/commonjs/gestureHandlerRootHOC.js.map +1 -1
  82. package/lib/commonjs/getShadowNodeFromRef.js +2 -2
  83. package/lib/commonjs/getShadowNodeFromRef.js.map +1 -1
  84. package/lib/commonjs/handlers/LongPressGestureHandler.js +3 -1
  85. package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -1
  86. package/lib/commonjs/handlers/TapGestureHandler.js +3 -1
  87. package/lib/commonjs/handlers/TapGestureHandler.js.map +1 -1
  88. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  89. package/lib/commonjs/handlers/gestureHandlerCommon.js +5 -2
  90. package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
  91. package/lib/commonjs/handlers/gestureHandlerTypesCompat.js +4 -0
  92. package/lib/commonjs/handlers/gestures/GestureDetector.js +87 -38
  93. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
  94. package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -1
  95. package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
  96. package/lib/commonjs/handlers/gestures/longPressGesture.js +1 -0
  97. package/lib/commonjs/handlers/gestures/longPressGesture.js.map +1 -1
  98. package/lib/commonjs/handlers/gestures/tapGesture.js +1 -0
  99. package/lib/commonjs/handlers/gestures/tapGesture.js.map +1 -1
  100. package/lib/commonjs/jestUtils/jestUtils.js.map +1 -1
  101. package/lib/commonjs/web/detectors/RotationGestureDetector.js.map +1 -1
  102. package/lib/commonjs/web/handlers/FlingGestureHandler.js +0 -1
  103. package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
  104. package/lib/commonjs/web/handlers/GestureHandler.js +28 -3
  105. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  106. package/lib/commonjs/web/handlers/LongPressGestureHandler.js +0 -2
  107. package/lib/commonjs/web/handlers/LongPressGestureHandler.js.map +1 -1
  108. package/lib/commonjs/web/handlers/ManualGestureHandler.js +15 -0
  109. package/lib/commonjs/web/handlers/ManualGestureHandler.js.map +1 -1
  110. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +0 -2
  111. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
  112. package/lib/commonjs/web/handlers/PanGestureHandler.js +0 -5
  113. package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
  114. package/lib/commonjs/web/handlers/PinchGestureHandler.js +0 -1
  115. package/lib/commonjs/web/handlers/PinchGestureHandler.js.map +1 -1
  116. package/lib/commonjs/web/handlers/RotationGestureHandler.js +0 -1
  117. package/lib/commonjs/web/handlers/RotationGestureHandler.js.map +1 -1
  118. package/lib/commonjs/web/handlers/TapGestureHandler.js +0 -2
  119. package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
  120. package/lib/commonjs/web/interfaces.js.map +1 -1
  121. package/lib/commonjs/web/tools/InteractionManager.js.map +1 -1
  122. package/lib/commonjs/web_hammer/GestureHandler.js.map +1 -1
  123. package/lib/commonjs/web_hammer/NodeManager.js +4 -1
  124. package/lib/commonjs/web_hammer/NodeManager.js.map +1 -1
  125. package/lib/commonjs/web_hammer/PanGestureHandler.js +25 -6
  126. package/lib/commonjs/web_hammer/PanGestureHandler.js.map +1 -1
  127. package/lib/module/RNGestureHandlerModule.macos.js.map +1 -1
  128. package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
  129. package/lib/module/RNGestureHandlerModule.windows.js +117 -0
  130. package/lib/module/RNGestureHandlerModule.windows.js.map +1 -0
  131. package/lib/module/components/DrawerLayout.js +1 -0
  132. package/lib/module/components/DrawerLayout.js.map +1 -1
  133. package/lib/module/components/Swipeable.js.map +1 -1
  134. package/lib/module/components/touchables/TouchableOpacity.js.map +1 -1
  135. package/lib/module/gestureHandlerRootHOC.js +2 -1
  136. package/lib/module/gestureHandlerRootHOC.js.map +1 -1
  137. package/lib/module/getShadowNodeFromRef.js +2 -2
  138. package/lib/module/getShadowNodeFromRef.js.map +1 -1
  139. package/lib/module/handlers/LongPressGestureHandler.js +3 -1
  140. package/lib/module/handlers/LongPressGestureHandler.js.map +1 -1
  141. package/lib/module/handlers/TapGestureHandler.js +3 -1
  142. package/lib/module/handlers/TapGestureHandler.js.map +1 -1
  143. package/lib/module/handlers/createHandler.js.map +1 -1
  144. package/lib/module/handlers/gestureHandlerCommon.js +5 -2
  145. package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
  146. package/lib/module/handlers/gestureHandlerTypesCompat.js +1 -1
  147. package/lib/module/handlers/gestures/GestureDetector.js +89 -39
  148. package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
  149. package/lib/module/handlers/gestures/eventReceiver.js.map +1 -1
  150. package/lib/module/handlers/gestures/gesture.js.map +1 -1
  151. package/lib/module/handlers/gestures/longPressGesture.js +1 -0
  152. package/lib/module/handlers/gestures/longPressGesture.js.map +1 -1
  153. package/lib/module/handlers/gestures/tapGesture.js +1 -0
  154. package/lib/module/handlers/gestures/tapGesture.js.map +1 -1
  155. package/lib/module/jestUtils/jestUtils.js.map +1 -1
  156. package/lib/module/web/detectors/RotationGestureDetector.js.map +1 -1
  157. package/lib/module/web/handlers/FlingGestureHandler.js +0 -1
  158. package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
  159. package/lib/module/web/handlers/GestureHandler.js +28 -3
  160. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  161. package/lib/module/web/handlers/LongPressGestureHandler.js +0 -2
  162. package/lib/module/web/handlers/LongPressGestureHandler.js.map +1 -1
  163. package/lib/module/web/handlers/ManualGestureHandler.js +15 -0
  164. package/lib/module/web/handlers/ManualGestureHandler.js.map +1 -1
  165. package/lib/module/web/handlers/NativeViewGestureHandler.js +0 -2
  166. package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
  167. package/lib/module/web/handlers/PanGestureHandler.js +0 -5
  168. package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
  169. package/lib/module/web/handlers/PinchGestureHandler.js +0 -1
  170. package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -1
  171. package/lib/module/web/handlers/RotationGestureHandler.js +0 -1
  172. package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -1
  173. package/lib/module/web/handlers/TapGestureHandler.js +0 -2
  174. package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
  175. package/lib/module/web/interfaces.js.map +1 -1
  176. package/lib/module/web/tools/InteractionManager.js.map +1 -1
  177. package/lib/module/web_hammer/GestureHandler.js.map +1 -1
  178. package/lib/module/web_hammer/NodeManager.js +4 -1
  179. package/lib/module/web_hammer/NodeManager.js.map +1 -1
  180. package/lib/module/web_hammer/PanGestureHandler.js +25 -6
  181. package/lib/module/web_hammer/PanGestureHandler.js.map +1 -1
  182. package/lib/typescript/RNGestureHandlerModule.macos.d.ts +1 -1
  183. package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -1
  184. package/lib/typescript/RNGestureHandlerModule.windows.d.ts +48 -0
  185. package/lib/typescript/components/DrawerLayout.d.ts +10 -1
  186. package/lib/typescript/components/Swipeable.d.ts +3 -2
  187. package/lib/typescript/fabric/RNGestureHandlerButtonNativeComponent.d.ts +1 -1
  188. package/lib/typescript/fabric/RNGestureHandlerRootViewNativeComponent.d.ts +1 -1
  189. package/lib/typescript/gestureHandlerRootHOC.d.ts +1 -1
  190. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -1
  191. package/lib/typescript/handlers/PanGestureHandler.d.ts +1 -1
  192. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +3 -1
  193. package/lib/typescript/handlers/gestures/GestureDetector.d.ts +3 -1
  194. package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +3 -1
  195. package/lib/typescript/web/interfaces.d.ts +3 -1
  196. package/lib/typescript/web/tools/NodeManager.d.ts +2 -2
  197. package/package.json +17 -14
  198. package/src/RNGestureHandlerModule.macos.ts +2 -2
  199. package/src/RNGestureHandlerModule.web.ts +2 -2
  200. package/src/RNGestureHandlerModule.windows.ts +140 -0
  201. package/src/components/DrawerLayout.tsx +22 -12
  202. package/src/components/Swipeable.tsx +16 -13
  203. package/src/components/touchables/TouchableOpacity.tsx +1 -1
  204. package/src/gestureHandlerRootHOC.tsx +4 -1
  205. package/src/getShadowNodeFromRef.ts +3 -3
  206. package/src/handlers/LongPressGestureHandler.ts +3 -1
  207. package/src/handlers/TapGestureHandler.ts +3 -1
  208. package/src/handlers/createHandler.tsx +13 -15
  209. package/src/handlers/gestureHandlerCommon.ts +9 -4
  210. package/src/handlers/gestureHandlerTypesCompat.ts +34 -17
  211. package/src/handlers/gestures/GestureDetector.tsx +117 -44
  212. package/src/handlers/gestures/eventReceiver.ts +2 -1
  213. package/src/handlers/gestures/gesture.ts +8 -12
  214. package/src/handlers/gestures/longPressGesture.ts +1 -0
  215. package/src/handlers/gestures/tapGesture.ts +1 -0
  216. package/src/jestUtils/jestUtils.ts +3 -4
  217. package/src/web/detectors/RotationGestureDetector.ts +2 -1
  218. package/src/web/handlers/FlingGestureHandler.ts +2 -3
  219. package/src/web/handlers/GestureHandler.ts +30 -11
  220. package/src/web/handlers/LongPressGestureHandler.ts +0 -3
  221. package/src/web/handlers/ManualGestureHandler.ts +10 -1
  222. package/src/web/handlers/NativeViewGestureHandler.ts +0 -2
  223. package/src/web/handlers/PanGestureHandler.ts +0 -6
  224. package/src/web/handlers/PinchGestureHandler.ts +0 -2
  225. package/src/web/handlers/RotationGestureHandler.ts +2 -5
  226. package/src/web/handlers/TapGestureHandler.ts +0 -3
  227. package/src/web/interfaces.ts +3 -0
  228. package/src/web/tools/InteractionManager.ts +2 -3
  229. package/src/web_hammer/GestureHandler.ts +6 -8
  230. package/src/web_hammer/NodeManager.ts +3 -1
  231. package/src/web_hammer/PanGestureHandler.ts +12 -6
  232. package/android/lib/build.gradle +0 -28
@@ -1,6 +1,6 @@
1
1
  var _Reanimated$default$c, _Reanimated$default;
2
2
 
3
- import React, { useEffect, useRef } from 'react';
3
+ import React, { useEffect, useRef, useState } from 'react';
4
4
  import { BaseGesture, CALLBACK_TYPE } from './gesture';
5
5
  import { Reanimated } from './reanimatedWrapper';
6
6
  import { registerHandler, unregisterHandler } from '../handlersRegistry';
@@ -73,10 +73,11 @@ function attachHandlers({
73
73
  gestureConfig,
74
74
  gesture,
75
75
  viewTag,
76
- webEventHandlersRef
76
+ webEventHandlersRef,
77
+ mountedRef
77
78
  }) {
78
79
  if (!preparedGesture.firstExecution) {
79
- gestureConfig === null || gestureConfig === void 0 ? void 0 : gestureConfig.initialize();
80
+ gestureConfig.initialize();
80
81
  } else {
81
82
  preparedGesture.firstExecution = false;
82
83
  } // use setImmediate to extract handlerTags, because all refs should be initialized
@@ -84,7 +85,11 @@ function attachHandlers({
84
85
 
85
86
 
86
87
  setImmediate(() => {
87
- gestureConfig === null || gestureConfig === void 0 ? void 0 : gestureConfig.prepare();
88
+ if (!mountedRef.current) {
89
+ return;
90
+ }
91
+
92
+ gestureConfig.prepare();
88
93
  });
89
94
 
90
95
  for (const handler of gesture) {
@@ -96,6 +101,10 @@ function attachHandlers({
96
101
 
97
102
 
98
103
  setImmediate(() => {
104
+ if (!mountedRef.current) {
105
+ return;
106
+ }
107
+
99
108
  for (const handler of gesture) {
100
109
  let requireToFail = [];
101
110
 
@@ -138,7 +147,7 @@ function attachHandlers({
138
147
  }
139
148
 
140
149
  function updateHandlers(preparedGesture, gestureConfig, gesture, mountedRef) {
141
- gestureConfig === null || gestureConfig === void 0 ? void 0 : gestureConfig.prepare();
150
+ gestureConfig.prepare();
142
151
 
143
152
  for (let i = 0; i < gesture.length; i++) {
144
153
  const handler = preparedGesture.config[i];
@@ -398,7 +407,7 @@ function validateDetectorChildren(ref) {
398
407
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
399
408
  const wrapType = REACT_NATIVE_VERSION.minor > 63 || REACT_NATIVE_VERSION.major > 0 ? // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
400
409
  ref._reactInternals.elementType : // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
401
- ref._reactInternalFiber.elementType; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
410
+ ref._reactInternalFiber.elementType; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
402
411
 
403
412
  let instance = RNRenderer.findHostInstance_DEPRECATED(ref)._internalFiberInstanceHandleDEV; // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
404
413
 
@@ -415,14 +424,28 @@ function validateDetectorChildren(ref) {
415
424
  }
416
425
  }
417
426
 
418
- export const GestureDetector = props => {
419
- var _gestureConfig$toGest, _gestureConfig$toGest2;
427
+ const applyUserSelectProp = (userSelect, gesture) => {
428
+ for (const g of gesture.toGestureArray()) {
429
+ g.config.userSelect = userSelect;
430
+ }
431
+ };
420
432
 
433
+ export const GestureDetector = props => {
421
434
  const gestureConfig = props.gesture;
422
- const gesture = (_gestureConfig$toGest = gestureConfig === null || gestureConfig === void 0 ? void 0 : (_gestureConfig$toGest2 = gestureConfig.toGestureArray) === null || _gestureConfig$toGest2 === void 0 ? void 0 : _gestureConfig$toGest2.call(gestureConfig)) !== null && _gestureConfig$toGest !== void 0 ? _gestureConfig$toGest : [];
423
- const useReanimatedHook = gesture.some(g => g.shouldUseReanimated);
424
- const viewRef = useRef(null);
425
- const firstRenderRef = useRef(true);
435
+
436
+ if (props.userSelect) {
437
+ applyUserSelectProp(props.userSelect, gestureConfig);
438
+ }
439
+
440
+ const gesture = gestureConfig.toGestureArray();
441
+ const useReanimatedHook = gesture.some(g => g.shouldUseReanimated); // store state in ref to prevent unnecessary renders
442
+
443
+ const state = useRef({
444
+ firstRender: true,
445
+ viewRef: null,
446
+ previousViewTag: -1,
447
+ forceReattach: false
448
+ }).current;
426
449
  const mountedRef = useRef(false);
427
450
  const webEventHandlersRef = useRef({
428
451
  onGestureHandlerEvent: e => {
@@ -432,6 +455,12 @@ export const GestureDetector = props => {
432
455
  onGestureHandlerEvent(e.nativeEvent);
433
456
  } : undefined
434
457
  });
458
+ const [renderState, setRenderState] = useState(false);
459
+
460
+ function forceRender() {
461
+ setRenderState(!renderState);
462
+ }
463
+
435
464
  const preparedGesture = React.useRef({
436
465
  config: gesture,
437
466
  animatedEventHandler: null,
@@ -442,16 +471,42 @@ export const GestureDetector = props => {
442
471
 
443
472
  if (useReanimatedHook !== preparedGesture.useReanimatedHook) {
444
473
  throw new Error(tagMessage('You cannot change the thread the callbacks are ran on while the app is running'));
474
+ }
475
+
476
+ function onHandlersUpdate(skipConfigUpdate) {
477
+ // if the underlying view has changed we need to reattach handlers to the new view
478
+ const viewTag = findNodeHandle(state.viewRef);
479
+ const forceReattach = viewTag !== state.previousViewTag;
480
+
481
+ if (forceReattach || needsToReattach(preparedGesture, gesture)) {
482
+ validateDetectorChildren(state.viewRef);
483
+ dropHandlers(preparedGesture);
484
+ attachHandlers({
485
+ preparedGesture,
486
+ gestureConfig,
487
+ gesture,
488
+ webEventHandlersRef,
489
+ viewTag,
490
+ mountedRef
491
+ });
492
+ state.previousViewTag = viewTag;
493
+ state.forceReattach = forceReattach;
494
+
495
+ if (forceReattach) {
496
+ forceRender();
497
+ }
498
+ } else if (!skipConfigUpdate) {
499
+ updateHandlers(preparedGesture, gestureConfig, gesture, mountedRef);
500
+ }
445
501
  } // Reanimated event should be rebuilt only when gestures are reattached, otherwise
446
502
  // config update will be enough as all necessary items are stored in shared values anyway
447
503
 
448
504
 
449
- const needsToRebuildReanimatedEvent = preparedGesture.firstExecution || needsToReattach(preparedGesture, gesture);
505
+ const needsToRebuildReanimatedEvent = preparedGesture.firstExecution || needsToReattach(preparedGesture, gesture) || state.forceReattach;
506
+ state.forceReattach = false;
450
507
 
451
508
  if (preparedGesture.firstExecution) {
452
- var _gestureConfig$initia;
453
-
454
- gestureConfig === null || gestureConfig === void 0 ? void 0 : (_gestureConfig$initia = gestureConfig.initialize) === null || _gestureConfig$initia === void 0 ? void 0 : _gestureConfig$initia.call(gestureConfig);
509
+ gestureConfig.initialize();
455
510
  }
456
511
 
457
512
  if (useReanimatedHook) {
@@ -461,16 +516,17 @@ export const GestureDetector = props => {
461
516
  }
462
517
 
463
518
  useEffect(() => {
464
- firstRenderRef.current = true;
519
+ const viewTag = findNodeHandle(state.viewRef);
520
+ state.firstRender = true;
465
521
  mountedRef.current = true;
466
- const viewTag = findNodeHandle(viewRef.current);
467
- validateDetectorChildren(viewRef.current);
522
+ validateDetectorChildren(state.viewRef);
468
523
  attachHandlers({
469
524
  preparedGesture,
470
525
  gestureConfig,
471
526
  gesture,
527
+ webEventHandlersRef,
472
528
  viewTag,
473
- webEventHandlersRef
529
+ mountedRef
474
530
  });
475
531
  return () => {
476
532
  mountedRef.current = false;
@@ -478,31 +534,25 @@ export const GestureDetector = props => {
478
534
  };
479
535
  }, []);
480
536
  useEffect(() => {
481
- if (!firstRenderRef.current) {
482
- const viewTag = findNodeHandle(viewRef.current);
483
-
484
- if (needsToReattach(preparedGesture, gesture)) {
485
- validateDetectorChildren(viewRef.current);
486
- dropHandlers(preparedGesture);
487
- attachHandlers({
488
- preparedGesture,
489
- gestureConfig,
490
- gesture,
491
- viewTag,
492
- webEventHandlersRef
493
- });
494
- } else {
495
- updateHandlers(preparedGesture, gestureConfig, gesture, mountedRef);
496
- }
537
+ if (!state.firstRender) {
538
+ onHandlersUpdate();
497
539
  } else {
498
- firstRenderRef.current = false;
540
+ state.firstRender = false;
499
541
  }
500
542
  }, [props]);
501
543
 
502
544
  const refFunction = ref => {
503
545
  if (ref !== null) {
504
- //@ts-ignore Just setting the ref
505
- viewRef.current = ref;
546
+ // @ts-ignore Just setting the view ref
547
+ state.viewRef = ref; // if it's the first render, also set the previousViewTag to prevent reattaching gestures when not needed
548
+
549
+ if (state.previousViewTag === -1) {
550
+ state.previousViewTag = findNodeHandle(state.viewRef);
551
+ } // pass true as `skipConfigUpdate`, here we only want to trigger the eventual reattaching of handlers
552
+ // in case the view has changed, while config update would be handled be the `useEffect` above
553
+
554
+
555
+ onHandlersUpdate(true);
506
556
 
507
557
  if (isFabric()) {
508
558
  const node = getShadowNodeFromRef(ref);
@@ -1 +1 @@
1
- {"version":3,"sources":["GestureDetector.tsx"],"names":["React","useEffect","useRef","BaseGesture","CALLBACK_TYPE","Reanimated","registerHandler","unregisterHandler","RNGestureHandlerModule","baseGestureHandlerWithMonitorProps","filterConfig","findNodeHandle","scheduleFlushOperations","GestureStateManager","flingGestureHandlerProps","forceTouchGestureHandlerProps","longPressGestureHandlerProps","panGestureHandlerProps","panGestureHandlerCustomNativeProps","tapGestureHandlerProps","State","TouchEventType","ActionType","isFabric","REACT_NATIVE_VERSION","tagMessage","getShadowNodeFromRef","Platform","onGestureHandlerEvent","RNRenderer","isExperimentalWebImplementationEnabled","ALLOWED_PROPS","convertToHandlerTag","ref","handlerTag","current","extractValidHandlerTags","interactionGroup","map","filter","tag","dropHandlers","preparedGesture","handler","config","dropGestureHandler","testId","checkGestureCallbacksForWorklets","gesture","runOnJS","areSomeNotWorklets","handlers","isWorklet","includes","areSomeWorklets","console","error","attachHandlers","gestureConfig","viewTag","webEventHandlersRef","firstExecution","initialize","setImmediate","prepare","createGestureHandler","handlerName","requireToFail","simultaneousWith","updateGestureHandler","simultaneousHandlers","waitFor","actionType","shouldUseReanimated","REANIMATED_WORKLET","JS_FUNCTION_NEW_API","OS","attachGestureHandler","JS_FUNCTION_OLD_API","animatedHandlers","isAnimatedGesture","g","value","updateHandlers","mountedRef","i","length","previousHandlersValue","newHandlersValue","shouldUpdateSharedValue","gestureId","needsToReattach","isStateChangeEvent","event","oldState","isTouchEvent","eventType","getHandler","type","BEGAN","onBegin","START","onStart","UPDATE","onUpdate","CHANGE","onChange","END","onEnd","FINALIZE","onFinalize","TOUCHES_DOWN","onTouchesDown","TOUCHES_MOVE","onTouchesMove","TOUCHES_UP","onTouchesUp","TOUCHES_CANCELLED","onTouchesCancelled","touchEventTypeToCallbackType","UNDEFINED","runWorklet","args","warn","useAnimatedGesture","needsRebuild","sharedHandlersCallbacks","useSharedValue","lastUpdateEvent","stateControllers","callback","currentCallback","UNDETERMINED","state","ACTIVE","undefined","FAILED","CANCELLED","create","changeEventCalculator","useEvent","animatedEventHandler","validateDetectorChildren","__DEV__","wrapType","minor","major","_reactInternals","elementType","_reactInternalFiber","instance","findHostInstance_DEPRECATED","_internalFiberInstanceHandleDEV","sibling","Error","return","GestureDetector","props","toGestureArray","useReanimatedHook","some","viewRef","firstRenderRef","e","nativeEvent","onGestureHandlerStateChange","needsToRebuildReanimatedEvent","refFunction","node","global","isFormsStackingContext","children","Wrap","Component","render","child","Children","only","cloneElement","collapsable","AnimatedWrap","default","createAnimatedComponent"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,QAAoD,OAApD;AACA,SAGEC,WAHF,EAKEC,aALF,QAMO,WANP;AAOA,SAASC,UAAT,QAAwC,qBAAxC;AACA,SAASC,eAAT,EAA0BC,iBAA1B,QAAmD,qBAAnD;AACA,OAAOC,sBAAP,MAAmC,8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KpB,KAAL,CAAWc,QAA/B,CAAnB;AACA,0BAAO3K,KAAK,CAACkL,YAAN,CACLH,KADK,EAEL;AAAEI,QAAAA,WAAW,EAAE;AAAf,OAFK,EAGL;AACAJ,MAAAA,KAAK,CAAClB,KAAN,CAAYc,QAJP,CAAP;AAMD,KAbD,CAaE,OAAOR,CAAP,EAAU;AACV,YAAM,IAAIT,KAAJ,CACJjI,UAAU,CACP,2KADO,CADN,CAAN;AAKD;AACF;;AAtBA;;AAyBH,MAAM2J,YAAY,4BAAG/K,UAAH,aAAGA,UAAH,8CAAGA,UAAU,CAAEgL,OAAf,wDAAG,oBAAqBC,uBAArB,CAA6CV,IAA7C,CAAH,yEAAyDA,IAA3E","sourcesContent":["import React, { useEffect, useRef, RefObject } from 'react';\nimport {\n GestureType,\n HandlerCallbacks,\n BaseGesture,\n GestureRef,\n CALLBACK_TYPE,\n} from './gesture';\nimport { Reanimated, SharedValue } from './reanimatedWrapper';\nimport { registerHandler, unregisterHandler } from '../handlersRegistry';\nimport RNGestureHandlerModule from '../../RNGestureHandlerModule';\nimport {\n baseGestureHandlerWithMonitorProps,\n filterConfig,\n findNodeHandle,\n GestureTouchEvent,\n GestureUpdateEvent,\n GestureStateChangeEvent,\n HandlerStateChangeEvent,\n scheduleFlushOperations,\n} from '../gestureHandlerCommon';\nimport {\n GestureStateManager,\n GestureStateManagerType,\n} from './gestureStateManager';\nimport { flingGestureHandlerProps } from '../FlingGestureHandler';\nimport { forceTouchGestureHandlerProps } from '../ForceTouchGestureHandler';\nimport { longPressGestureHandlerProps } from '../LongPressGestureHandler';\nimport {\n panGestureHandlerProps,\n panGestureHandlerCustomNativeProps,\n} from '../PanGestureHandler';\nimport { tapGestureHandlerProps } from '../TapGestureHandler';\nimport { State } from '../../State';\nimport { TouchEventType } from '../../TouchEventType';\nimport { ComposedGesture } from './gestureComposition';\nimport { ActionType } from '../../ActionType';\nimport { isFabric, REACT_NATIVE_VERSION, tagMessage } from '../../utils';\nimport { getShadowNodeFromRef } from '../../getShadowNodeFromRef';\nimport { Platform } from 'react-native';\nimport type RNGestureHandlerModuleWeb from '../../RNGestureHandlerModule.web';\nimport { onGestureHandlerEvent } from './eventReceiver';\nimport { RNRenderer } from '../../RNRenderer';\nimport { isExperimentalWebImplementationEnabled } from '../../EnableExperimentalWebImplementation';\n\ndeclare const global: {\n isFormsStackingContext: (node: unknown) => boolean | null; // JSI function\n};\n\nconst ALLOWED_PROPS = [\n ...baseGestureHandlerWithMonitorProps,\n ...tapGestureHandlerProps,\n ...panGestureHandlerProps,\n ...panGestureHandlerCustomNativeProps,\n ...longPressGestureHandlerProps,\n ...forceTouchGestureHandlerProps,\n ...flingGestureHandlerProps,\n];\n\nexport type GestureConfigReference = {\n config: GestureType[];\n animatedEventHandler: unknown;\n animatedHandlers: SharedValue<\n HandlerCallbacks<Record<string, unknown>>[] | null\n > | null;\n firstExecution: boolean;\n useReanimatedHook: boolean;\n};\n\nfunction convertToHandlerTag(ref: GestureRef): number {\n if (typeof ref === 'number') {\n return ref;\n } else if (ref instanceof BaseGesture) {\n return ref.handlerTag;\n } else {\n // @ts-ignore in this case it should be a ref either to gesture object or\n // a gesture handler component, in both cases handlerTag property exists\n return ref.current?.handlerTag ?? -1;\n }\n}\n\nfunction extractValidHandlerTags(interactionGroup: GestureRef[] | undefined) {\n return (\n interactionGroup?.map(convertToHandlerTag)?.filter((tag) => tag > 0) ?? []\n );\n}\n\nfunction dropHandlers(preparedGesture: GestureConfigReference) {\n for (const handler of preparedGesture.config) {\n RNGestureHandlerModule.dropGestureHandler(handler.handlerTag);\n\n unregisterHandler(handler.handlerTag, handler.config.testId);\n }\n\n scheduleFlushOperations();\n}\n\nfunction checkGestureCallbacksForWorklets(gesture: GestureType) {\n // if a gesture is explicitly marked to run on the JS thread there is no need to check\n // if callbacks are worklets as the user is aware they will be ran on the JS thread\n if (gesture.config.runOnJS) {\n return;\n }\n\n const areSomeNotWorklets = gesture.handlers.isWorklet.includes(false);\n const areSomeWorklets = gesture.handlers.isWorklet.includes(true);\n\n // if some of the callbacks are worklets and some are not, and the gesture is not\n // explicitly marked with `.runOnJS(true)` show an error\n if (areSomeNotWorklets && areSomeWorklets) {\n console.error(\n tagMessage(\n `Some of the callbacks in the gesture are worklets and some are not. Either make sure that all calbacks are marked as 'worklet' if you wish to run them on the UI thread or use '.runOnJS(true)' modifier on the gesture explicitly to run all callbacks on the JS thread.`\n )\n );\n }\n}\n\ninterface WebEventHandler {\n onGestureHandlerEvent: (event: HandlerStateChangeEvent<unknown>) => void;\n onGestureHandlerStateChange?: (\n event: HandlerStateChangeEvent<unknown>\n ) => void;\n}\n\ninterface AttachHandlersConfig {\n preparedGesture: GestureConfigReference;\n gestureConfig: ComposedGesture | GestureType | undefined;\n gesture: GestureType[];\n viewTag: number;\n webEventHandlersRef: React.RefObject<WebEventHandler>;\n}\n\nfunction attachHandlers({\n preparedGesture,\n gestureConfig,\n gesture,\n viewTag,\n webEventHandlersRef,\n}: AttachHandlersConfig) {\n if (!preparedGesture.firstExecution) {\n gestureConfig?.initialize();\n } else {\n preparedGesture.firstExecution = false;\n }\n\n // use setImmediate to extract handlerTags, because all refs should be initialized\n // when it's ran\n setImmediate(() => {\n gestureConfig?.prepare();\n });\n\n for (const handler of gesture) {\n checkGestureCallbacksForWorklets(handler);\n RNGestureHandlerModule.createGestureHandler(\n handler.handlerName,\n handler.handlerTag,\n filterConfig(handler.config, ALLOWED_PROPS)\n );\n\n registerHandler(handler.handlerTag, handler, handler.config.testId);\n }\n\n // use setImmediate to extract handlerTags, because all refs should be initialized\n // when it's ran\n setImmediate(() => {\n for (const handler of gesture) {\n let requireToFail: number[] = [];\n if (handler.config.requireToFail) {\n requireToFail = extractValidHandlerTags(handler.config.requireToFail);\n }\n\n let simultaneousWith: number[] = [];\n if (handler.config.simultaneousWith) {\n simultaneousWith = extractValidHandlerTags(\n handler.config.simultaneousWith\n );\n }\n\n RNGestureHandlerModule.updateGestureHandler(\n handler.handlerTag,\n filterConfig(handler.config, ALLOWED_PROPS, {\n simultaneousHandlers: simultaneousWith,\n waitFor: requireToFail,\n })\n );\n }\n\n scheduleFlushOperations();\n });\n\n preparedGesture.config = gesture;\n\n for (const gesture of preparedGesture.config) {\n const actionType = gesture.shouldUseReanimated\n ? ActionType.REANIMATED_WORKLET\n : ActionType.JS_FUNCTION_NEW_API;\n\n if (Platform.OS === 'web') {\n (RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler)(\n gesture.handlerTag,\n viewTag,\n ActionType.JS_FUNCTION_OLD_API, // ignored on web\n webEventHandlersRef\n );\n } else {\n RNGestureHandlerModule.attachGestureHandler(\n gesture.handlerTag,\n viewTag,\n actionType\n );\n }\n }\n\n if (preparedGesture.animatedHandlers) {\n const isAnimatedGesture = (g: GestureType) => g.shouldUseReanimated;\n\n preparedGesture.animatedHandlers.value = (gesture\n .filter(isAnimatedGesture)\n .map((g) => g.handlers) as unknown) as HandlerCallbacks<\n Record<string, unknown>\n >[];\n }\n}\n\nfunction updateHandlers(\n preparedGesture: GestureConfigReference,\n gestureConfig: ComposedGesture | GestureType | undefined,\n gesture: GestureType[],\n mountedRef: RefObject<boolean>\n) {\n gestureConfig?.prepare();\n\n for (let i = 0; i < gesture.length; i++) {\n const handler = preparedGesture.config[i];\n checkGestureCallbacksForWorklets(handler);\n\n // only update handlerTag when it's actually different, it may be the same\n // if gesture config object is wrapped with useMemo\n if (gesture[i].handlerTag !== handler.handlerTag) {\n gesture[i].handlerTag = handler.handlerTag;\n gesture[i].handlers.handlerTag = handler.handlerTag;\n }\n }\n\n // use setImmediate to extract handlerTags, because when it's ran, all refs should be updated\n // and handlerTags in BaseGesture references should be updated in the loop above (we need to wait\n // in case of external relations)\n setImmediate(() => {\n if (!mountedRef.current) {\n return;\n }\n for (let i = 0; i < gesture.length; i++) {\n const handler = preparedGesture.config[i];\n\n handler.config = gesture[i].config;\n handler.handlers = gesture[i].handlers;\n\n const requireToFail = extractValidHandlerTags(\n handler.config.requireToFail\n );\n\n const simultaneousWith = extractValidHandlerTags(\n handler.config.simultaneousWith\n );\n\n RNGestureHandlerModule.updateGestureHandler(\n handler.handlerTag,\n filterConfig(handler.config, ALLOWED_PROPS, {\n simultaneousHandlers: simultaneousWith,\n waitFor: requireToFail,\n })\n );\n\n registerHandler(handler.handlerTag, handler, handler.config.testId);\n }\n\n if (preparedGesture.animatedHandlers) {\n const previousHandlersValue =\n preparedGesture.animatedHandlers.value ?? [];\n const newHandlersValue = (preparedGesture.config\n .filter((g) => g.shouldUseReanimated) // ignore gestures that shouldn't run on UI\n .map((g) => g.handlers) as unknown) as HandlerCallbacks<\n Record<string, unknown>\n >[];\n\n // if amount of gesture configs changes, we need to update the callbacks in shared value\n let shouldUpdateSharedValue =\n previousHandlersValue.length !== newHandlersValue.length;\n\n if (!shouldUpdateSharedValue) {\n // if the amount is the same, we need to check if any of the configs inside has changed\n for (let i = 0; i < newHandlersValue.length; i++) {\n if (\n // we can use the `gestureId` prop as it's unique for every config instance\n newHandlersValue[i].gestureId !== previousHandlersValue[i].gestureId\n ) {\n shouldUpdateSharedValue = true;\n break;\n }\n }\n }\n\n if (shouldUpdateSharedValue) {\n preparedGesture.animatedHandlers.value = newHandlersValue;\n }\n }\n\n scheduleFlushOperations();\n });\n}\n\nfunction needsToReattach(\n preparedGesture: GestureConfigReference,\n gesture: GestureType[]\n) {\n if (gesture.length !== preparedGesture.config.length) {\n return true;\n }\n for (let i = 0; i < gesture.length; i++) {\n if (\n gesture[i].handlerName !== preparedGesture.config[i].handlerName ||\n gesture[i].shouldUseReanimated !==\n preparedGesture.config[i].shouldUseReanimated\n ) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction isStateChangeEvent(\n event: GestureUpdateEvent | GestureStateChangeEvent | GestureTouchEvent\n): event is GestureStateChangeEvent {\n 'worklet';\n // @ts-ignore Yes, the oldState prop is missing on GestureTouchEvent, that's the point\n return event.oldState != null;\n}\n\nfunction isTouchEvent(\n event: GestureUpdateEvent | GestureStateChangeEvent | GestureTouchEvent\n): event is GestureTouchEvent {\n 'worklet';\n return event.eventType != null;\n}\n\nfunction getHandler(\n type: CALLBACK_TYPE,\n gesture: HandlerCallbacks<Record<string, unknown>>\n) {\n 'worklet';\n switch (type) {\n case CALLBACK_TYPE.BEGAN:\n return gesture.onBegin;\n case CALLBACK_TYPE.START:\n return gesture.onStart;\n case CALLBACK_TYPE.UPDATE:\n return gesture.onUpdate;\n case CALLBACK_TYPE.CHANGE:\n return gesture.onChange;\n case CALLBACK_TYPE.END:\n return gesture.onEnd;\n case CALLBACK_TYPE.FINALIZE:\n return gesture.onFinalize;\n case CALLBACK_TYPE.TOUCHES_DOWN:\n return gesture.onTouchesDown;\n case CALLBACK_TYPE.TOUCHES_MOVE:\n return gesture.onTouchesMove;\n case CALLBACK_TYPE.TOUCHES_UP:\n return gesture.onTouchesUp;\n case CALLBACK_TYPE.TOUCHES_CANCELLED:\n return gesture.onTouchesCancelled;\n }\n}\n\nfunction touchEventTypeToCallbackType(\n eventType: TouchEventType\n): CALLBACK_TYPE {\n 'worklet';\n switch (eventType) {\n case TouchEventType.TOUCHES_DOWN:\n return CALLBACK_TYPE.TOUCHES_DOWN;\n case TouchEventType.TOUCHES_MOVE:\n return CALLBACK_TYPE.TOUCHES_MOVE;\n case TouchEventType.TOUCHES_UP:\n return CALLBACK_TYPE.TOUCHES_UP;\n case TouchEventType.TOUCHES_CANCELLED:\n return CALLBACK_TYPE.TOUCHES_CANCELLED;\n }\n return CALLBACK_TYPE.UNDEFINED;\n}\n\nfunction runWorklet(\n type: CALLBACK_TYPE,\n gesture: HandlerCallbacks<Record<string, unknown>>,\n event: GestureStateChangeEvent | GestureUpdateEvent | GestureTouchEvent,\n ...args: any[]\n) {\n 'worklet';\n const handler = getHandler(type, gesture);\n if (gesture.isWorklet[type]) {\n // @ts-ignore Logic below makes sure the correct event is send to the\n // correct handler.\n handler?.(event, ...args);\n } else if (handler) {\n console.warn(tagMessage('Animated gesture callback must be a worklet'));\n }\n}\n\nfunction useAnimatedGesture(\n preparedGesture: GestureConfigReference,\n needsRebuild: boolean\n) {\n if (!Reanimated) {\n return;\n }\n\n // Hooks are called conditionally, but the condition is whether the\n // react-native-reanimated is installed, which shouldn't change while running\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const sharedHandlersCallbacks = Reanimated.useSharedValue<\n HandlerCallbacks<Record<string, unknown>>[] | null\n >(null);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const lastUpdateEvent = Reanimated.useSharedValue<\n (GestureUpdateEvent | undefined)[]\n >([]);\n\n // not every gesture needs a state controller, init them lazily\n const stateControllers: GestureStateManagerType[] = [];\n\n const callback = (\n event: GestureStateChangeEvent | GestureUpdateEvent | GestureTouchEvent\n ) => {\n 'worklet';\n\n const currentCallback = sharedHandlersCallbacks.value;\n if (!currentCallback) {\n return;\n }\n\n for (let i = 0; i < currentCallback.length; i++) {\n const gesture = currentCallback[i];\n\n if (event.handlerTag === gesture.handlerTag) {\n if (isStateChangeEvent(event)) {\n if (\n event.oldState === State.UNDETERMINED &&\n event.state === State.BEGAN\n ) {\n runWorklet(CALLBACK_TYPE.BEGAN, gesture, event);\n } else if (\n (event.oldState === State.BEGAN ||\n event.oldState === State.UNDETERMINED) &&\n event.state === State.ACTIVE\n ) {\n runWorklet(CALLBACK_TYPE.START, gesture, event);\n lastUpdateEvent.value[gesture.handlerTag] = undefined;\n } else if (\n event.oldState !== event.state &&\n event.state === State.END\n ) {\n if (event.oldState === State.ACTIVE) {\n runWorklet(CALLBACK_TYPE.END, gesture, event, true);\n }\n runWorklet(CALLBACK_TYPE.FINALIZE, gesture, event, true);\n } else if (\n (event.state === State.FAILED || event.state === State.CANCELLED) &&\n event.state !== event.oldState\n ) {\n if (event.oldState === State.ACTIVE) {\n runWorklet(CALLBACK_TYPE.END, gesture, event, false);\n }\n runWorklet(CALLBACK_TYPE.FINALIZE, gesture, event, false);\n }\n } else if (isTouchEvent(event)) {\n if (!stateControllers[i]) {\n stateControllers[i] = GestureStateManager.create(event.handlerTag);\n }\n\n if (event.eventType !== TouchEventType.UNDETERMINED) {\n runWorklet(\n touchEventTypeToCallbackType(event.eventType),\n gesture,\n event,\n stateControllers[i]\n );\n }\n } else {\n runWorklet(CALLBACK_TYPE.UPDATE, gesture, event);\n\n if (gesture.onChange && gesture.changeEventCalculator) {\n runWorklet(\n CALLBACK_TYPE.CHANGE,\n gesture,\n gesture.changeEventCalculator?.(\n event,\n lastUpdateEvent.value[gesture.handlerTag]\n )\n );\n\n lastUpdateEvent.value[gesture.handlerTag] = event;\n }\n }\n }\n }\n };\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const event = Reanimated.useEvent(\n callback,\n ['onGestureHandlerStateChange', 'onGestureHandlerEvent'],\n needsRebuild\n );\n\n preparedGesture.animatedEventHandler = event;\n preparedGesture.animatedHandlers = sharedHandlersCallbacks;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction validateDetectorChildren(ref: any) {\n // finds the first native view under the Wrap component and traverses the fiber tree upwards\n // to check whether there is more than one native view as a pseudo-direct child of GestureDetector\n // i.e. this is not ok:\n // Wrap\n // |\n // / \\\n // / \\\n // / \\\n // / \\\n // NativeView NativeView\n //\n // but this is fine:\n // Wrap\n // |\n // NativeView\n // |\n // / \\\n // / \\\n // / \\\n // / \\\n // NativeView NativeView\n if (__DEV__ && Platform.OS !== 'web') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const wrapType =\n REACT_NATIVE_VERSION.minor > 63 || REACT_NATIVE_VERSION.major > 0\n ? // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ref._reactInternals.elementType\n : // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ref._reactInternalFiber.elementType;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n let instance = RNRenderer.findHostInstance_DEPRECATED(ref)\n ._internalFiberInstanceHandleDEV;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n while (instance && instance.elementType !== wrapType) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (instance.sibling) {\n throw new Error(\n 'GestureDetector has more than one native view as its children. This can happen if you are using a custom component that renders multiple views, like React.Fragment. You should wrap content of GestureDetector with a <View> or <Animated.View>.'\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n instance = instance.return;\n }\n }\n}\n\ninterface GestureDetectorProps {\n gesture?: ComposedGesture | GestureType;\n children?: React.ReactNode;\n}\nexport const GestureDetector = (props: GestureDetectorProps) => {\n const gestureConfig = props.gesture;\n const gesture = gestureConfig?.toGestureArray?.() ?? [];\n const useReanimatedHook = gesture.some((g) => g.shouldUseReanimated);\n const viewRef = useRef(null);\n const firstRenderRef = useRef(true);\n const mountedRef = useRef(false);\n const webEventHandlersRef = useRef<WebEventHandler>({\n onGestureHandlerEvent: (e: HandlerStateChangeEvent<unknown>) => {\n onGestureHandlerEvent(e.nativeEvent);\n },\n onGestureHandlerStateChange: isExperimentalWebImplementationEnabled()\n ? (e: HandlerStateChangeEvent<unknown>) => {\n onGestureHandlerEvent(e.nativeEvent);\n }\n : undefined,\n });\n\n const preparedGesture = React.useRef<GestureConfigReference>({\n config: gesture,\n animatedEventHandler: null,\n animatedHandlers: null,\n firstExecution: true,\n useReanimatedHook: useReanimatedHook,\n }).current;\n\n if (useReanimatedHook !== preparedGesture.useReanimatedHook) {\n throw new Error(\n tagMessage(\n 'You cannot change the thread the callbacks are ran on while the app is running'\n )\n );\n }\n\n // Reanimated event should be rebuilt only when gestures are reattached, otherwise\n // config update will be enough as all necessary items are stored in shared values anyway\n const needsToRebuildReanimatedEvent =\n preparedGesture.firstExecution || needsToReattach(preparedGesture, gesture);\n\n if (preparedGesture.firstExecution) {\n gestureConfig?.initialize?.();\n }\n\n if (useReanimatedHook) {\n // Whether animatedGesture or gesture is used shouldn't change while the app is running\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useAnimatedGesture(preparedGesture, needsToRebuildReanimatedEvent);\n }\n\n useEffect(() => {\n firstRenderRef.current = true;\n mountedRef.current = true;\n const viewTag = findNodeHandle(viewRef.current) as number;\n\n validateDetectorChildren(viewRef.current);\n attachHandlers({\n preparedGesture,\n gestureConfig,\n gesture,\n viewTag,\n webEventHandlersRef,\n });\n\n return () => {\n mountedRef.current = false;\n dropHandlers(preparedGesture);\n };\n }, []);\n\n useEffect(() => {\n if (!firstRenderRef.current) {\n const viewTag = findNodeHandle(viewRef.current) as number;\n\n if (needsToReattach(preparedGesture, gesture)) {\n validateDetectorChildren(viewRef.current);\n dropHandlers(preparedGesture);\n attachHandlers({\n preparedGesture,\n gestureConfig,\n gesture,\n viewTag,\n webEventHandlersRef,\n });\n } else {\n updateHandlers(preparedGesture, gestureConfig, gesture, mountedRef);\n }\n } else {\n firstRenderRef.current = false;\n }\n }, [props]);\n\n const refFunction = (ref: unknown) => {\n if (ref !== null) {\n //@ts-ignore Just setting the ref\n viewRef.current = ref;\n\n if (isFabric()) {\n const node = getShadowNodeFromRef(ref);\n if (global.isFormsStackingContext(node) === false) {\n console.error(\n tagMessage(\n 'GestureDetector has received a child that may get view-flattened. ' +\n '\\nTo prevent it from misbehaving you need to wrap the child with a `<View collapsable={false}>`.'\n )\n );\n }\n }\n }\n };\n\n if (useReanimatedHook) {\n return (\n <AnimatedWrap\n ref={refFunction}\n onGestureHandlerEvent={preparedGesture.animatedEventHandler}>\n {props.children}\n </AnimatedWrap>\n );\n } else {\n return <Wrap ref={refFunction}>{props.children}</Wrap>;\n }\n};\n\nclass Wrap extends React.Component<{\n onGestureHandlerEvent?: unknown;\n // implicit `children` prop has been removed in @types/react^18.0.0\n children?: React.ReactNode;\n}> {\n render() {\n try {\n // I don't think that fighting with types over such a simple function is worth it\n // The only thing it does is add 'collapsable: false' to the child component\n // to make sure it is in the native view hierarchy so the detector can find\n // correct viewTag to attach to.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const child: any = React.Children.only(this.props.children);\n return React.cloneElement(\n child,\n { collapsable: false },\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n child.props.children\n );\n } catch (e) {\n throw new Error(\n tagMessage(\n `GestureDetector got more than one view as a child. If you want the gesture to work on multiple views, wrap them with a common parent and attach the gesture to that view.`\n )\n );\n }\n }\n}\n\nconst AnimatedWrap = Reanimated?.default?.createAnimatedComponent(Wrap) ?? Wrap;\n"]}
1
+ {"version":3,"sources":["GestureDetector.tsx"],"names":["React","useEffect","useRef","useState","BaseGesture","CALLBACK_TYPE","Reanimated","registerHandler","unregisterHandler","RNGestureHandlerModule","baseGestureHandlerWithMonitorProps","filterConfig","findNodeHandle","scheduleFlushOperations","GestureStateManager","flingGestureHandlerProps","forceTouchGestureHandlerProps","longPressGestureHandlerProps","panGestureHandlerProps","panGestureHandlerCustomNativeProps","tapGestureHandlerProps","State","TouchEventType","ActionType","isFabric","REACT_NATIVE_VERSION","tagMessage","getShadowNodeFromRef","Platform","onGestureHandlerEvent","RNRenderer","isExperimentalWebImplementationEnabled","ALLOWED_PROPS","convertToHandlerTag","ref","handlerTag","current","extractValidHandlerTags","interactionGroup","map","filter","tag","dropHandlers","preparedGesture","handler","config","dropGestureHandler","testId","checkGestureCallbacksForWorklets","gesture","runOnJS","areSomeNotWorklets","handlers","isWorklet","includes","areSomeWorklets","console","error","attachHandlers","gestureConfig","viewTag","webEventHandlersRef","mountedRef","firstExecution","initialize","setImmediate","prepare","createGestureHandler","handlerName","requireToFail","simultaneousWith","updateGestureHandler","simultaneousHandlers","waitFor","actionType","shouldUseReanimated","REANIMATED_WORKLET","JS_FUNCTION_NEW_API","OS","attachGestureHandler","JS_FUNCTION_OLD_API","animatedHandlers","isAnimatedGesture","g","value","updateHandlers","i","length","previousHandlersValue","newHandlersValue","shouldUpdateSharedValue","gestureId","needsToReattach","isStateChangeEvent","event","oldState","isTouchEvent","eventType","getHandler","type","BEGAN","onBegin","START","onStart","UPDATE","onUpdate","CHANGE","onChange","END","onEnd","FINALIZE","onFinalize","TOUCHES_DOWN","onTouchesDown","TOUCHES_MOVE","onTouchesMove","TOUCHES_UP","onTouchesUp","TOUCHES_CANCELLED","onTouchesCancelled","touchEventTypeToCallbackType","UNDEFINED","runWorklet","args","warn","useAnimatedGesture","needsRebuild","sharedHandlersCallbacks","useSharedValue","lastUpdateEvent","stateControllers","callback","currentCallback","UNDETERMINED","state","ACTIVE","undefined","FAILED","CANCELLED","create","changeEventCalculator","useEvent","animatedEventHandler","validateDetectorChildren","__DEV__","wrapType","minor","major","_reactInternals","elementType","_reactInternalFiber","instance","findHostInstance_DEPRECATED","_internalFiberInstanceHandleDEV","sibling","Error","return","applyUserSelectProp","userSelect","toGestureArray","GestureDetector","props","useReanimatedHook","some","firstRender","viewRef","previousViewTag","forceReattach","e","nativeEvent","onGestureHandlerStateChange","renderState","setRenderState","forceRender","onHandlersUpdate","skipConfigUpdate","needsToRebuildReanimatedEvent","refFunction","node","global","isFormsStackingContext","children","Wrap","Component","render","child","Children","only","cloneElement","collapsable","AnimatedWrap","default","createAnimatedComponent"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,EAAmCC,QAAnC,QAAmD,OAAnD;AACA,SAGEC,WAHF,EAKEC,aALF,QAMO,WANP;AAOA,SAASC,UAAT,QAAwC,qBAAxC;AACA,SAASC,eAAT,EAA0BC,iBAA1B,QAAmD,qBAAnD;AACA,OAAOC,sBAAP,MAAmC,8BAAnC;AACA,SACEC,kCADF,EAEEC,YAFF,EAGEC,cAHF,EAQEC,uBARF,QAUO,yBAVP;AAWA,SACEC,mBADF,QAGO,uBAHP;AAIA,SAASC,wBAAT,QAAyC,wBAAzC;AACA,SAASC,6BAAT,QAA8C,6BAA9C;AACA,SAASC,4BAAT,QAA6C,4BAA7C;AACA,SACEC,sBADF,EAEEC,kCAFF,QAGO,sBAHP;AAIA,SAASC,sBAAT,QAAuC,sBAAvC;AAC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AU,CAAEyL,OAAf,wDAAG,oBAAqBC,uBAArB,CAA6CV,IAA7C,CAAH,yEAAyDA,IAA3E","sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport {\n GestureType,\n HandlerCallbacks,\n BaseGesture,\n GestureRef,\n CALLBACK_TYPE,\n} from './gesture';\nimport { Reanimated, SharedValue } from './reanimatedWrapper';\nimport { registerHandler, unregisterHandler } from '../handlersRegistry';\nimport RNGestureHandlerModule from '../../RNGestureHandlerModule';\nimport {\n baseGestureHandlerWithMonitorProps,\n filterConfig,\n findNodeHandle,\n GestureTouchEvent,\n GestureUpdateEvent,\n GestureStateChangeEvent,\n HandlerStateChangeEvent,\n scheduleFlushOperations,\n UserSelect,\n} from '../gestureHandlerCommon';\nimport {\n GestureStateManager,\n GestureStateManagerType,\n} from './gestureStateManager';\nimport { flingGestureHandlerProps } from '../FlingGestureHandler';\nimport { forceTouchGestureHandlerProps } from '../ForceTouchGestureHandler';\nimport { longPressGestureHandlerProps } from '../LongPressGestureHandler';\nimport {\n panGestureHandlerProps,\n panGestureHandlerCustomNativeProps,\n} from '../PanGestureHandler';\nimport { tapGestureHandlerProps } from '../TapGestureHandler';\nimport { State } from '../../State';\nimport { TouchEventType } from '../../TouchEventType';\nimport { ComposedGesture } from './gestureComposition';\nimport { ActionType } from '../../ActionType';\nimport { isFabric, REACT_NATIVE_VERSION, tagMessage } from '../../utils';\nimport { getShadowNodeFromRef } from '../../getShadowNodeFromRef';\nimport { Platform } from 'react-native';\nimport type RNGestureHandlerModuleWeb from '../../RNGestureHandlerModule.web';\nimport { onGestureHandlerEvent } from './eventReceiver';\nimport { RNRenderer } from '../../RNRenderer';\nimport { isExperimentalWebImplementationEnabled } from '../../EnableExperimentalWebImplementation';\n\ndeclare const global: {\n isFormsStackingContext: (node: unknown) => boolean | null; // JSI function\n};\n\nconst ALLOWED_PROPS = [\n ...baseGestureHandlerWithMonitorProps,\n ...tapGestureHandlerProps,\n ...panGestureHandlerProps,\n ...panGestureHandlerCustomNativeProps,\n ...longPressGestureHandlerProps,\n ...forceTouchGestureHandlerProps,\n ...flingGestureHandlerProps,\n];\n\nexport type GestureConfigReference = {\n config: GestureType[];\n animatedEventHandler: unknown;\n animatedHandlers: SharedValue<\n HandlerCallbacks<Record<string, unknown>>[] | null\n > | null;\n firstExecution: boolean;\n useReanimatedHook: boolean;\n};\n\nfunction convertToHandlerTag(ref: GestureRef): number {\n if (typeof ref === 'number') {\n return ref;\n } else if (ref instanceof BaseGesture) {\n return ref.handlerTag;\n } else {\n // @ts-ignore in this case it should be a ref either to gesture object or\n // a gesture handler component, in both cases handlerTag property exists\n return ref.current?.handlerTag ?? -1;\n }\n}\n\nfunction extractValidHandlerTags(interactionGroup: GestureRef[] | undefined) {\n return (\n interactionGroup?.map(convertToHandlerTag)?.filter((tag) => tag > 0) ?? []\n );\n}\n\nfunction dropHandlers(preparedGesture: GestureConfigReference) {\n for (const handler of preparedGesture.config) {\n RNGestureHandlerModule.dropGestureHandler(handler.handlerTag);\n\n unregisterHandler(handler.handlerTag, handler.config.testId);\n }\n\n scheduleFlushOperations();\n}\n\nfunction checkGestureCallbacksForWorklets(gesture: GestureType) {\n // if a gesture is explicitly marked to run on the JS thread there is no need to check\n // if callbacks are worklets as the user is aware they will be ran on the JS thread\n if (gesture.config.runOnJS) {\n return;\n }\n\n const areSomeNotWorklets = gesture.handlers.isWorklet.includes(false);\n const areSomeWorklets = gesture.handlers.isWorklet.includes(true);\n\n // if some of the callbacks are worklets and some are not, and the gesture is not\n // explicitly marked with `.runOnJS(true)` show an error\n if (areSomeNotWorklets && areSomeWorklets) {\n console.error(\n tagMessage(\n `Some of the callbacks in the gesture are worklets and some are not. Either make sure that all calbacks are marked as 'worklet' if you wish to run them on the UI thread or use '.runOnJS(true)' modifier on the gesture explicitly to run all callbacks on the JS thread.`\n )\n );\n }\n}\n\ninterface WebEventHandler {\n onGestureHandlerEvent: (event: HandlerStateChangeEvent<unknown>) => void;\n onGestureHandlerStateChange?: (\n event: HandlerStateChangeEvent<unknown>\n ) => void;\n}\n\ninterface AttachHandlersConfig {\n preparedGesture: GestureConfigReference;\n gestureConfig: ComposedGesture | GestureType;\n gesture: GestureType[];\n viewTag: number;\n webEventHandlersRef: React.RefObject<WebEventHandler>;\n mountedRef: React.RefObject<boolean>;\n}\n\nfunction attachHandlers({\n preparedGesture,\n gestureConfig,\n gesture,\n viewTag,\n webEventHandlersRef,\n mountedRef,\n}: AttachHandlersConfig) {\n if (!preparedGesture.firstExecution) {\n gestureConfig.initialize();\n } else {\n preparedGesture.firstExecution = false;\n }\n\n // use setImmediate to extract handlerTags, because all refs should be initialized\n // when it's ran\n setImmediate(() => {\n if (!mountedRef.current) {\n return;\n }\n gestureConfig.prepare();\n });\n\n for (const handler of gesture) {\n checkGestureCallbacksForWorklets(handler);\n RNGestureHandlerModule.createGestureHandler(\n handler.handlerName,\n handler.handlerTag,\n filterConfig(handler.config, ALLOWED_PROPS)\n );\n\n registerHandler(handler.handlerTag, handler, handler.config.testId);\n }\n\n // use setImmediate to extract handlerTags, because all refs should be initialized\n // when it's ran\n setImmediate(() => {\n if (!mountedRef.current) {\n return;\n }\n for (const handler of gesture) {\n let requireToFail: number[] = [];\n if (handler.config.requireToFail) {\n requireToFail = extractValidHandlerTags(handler.config.requireToFail);\n }\n\n let simultaneousWith: number[] = [];\n if (handler.config.simultaneousWith) {\n simultaneousWith = extractValidHandlerTags(\n handler.config.simultaneousWith\n );\n }\n\n RNGestureHandlerModule.updateGestureHandler(\n handler.handlerTag,\n filterConfig(handler.config, ALLOWED_PROPS, {\n simultaneousHandlers: simultaneousWith,\n waitFor: requireToFail,\n })\n );\n }\n\n scheduleFlushOperations();\n });\n\n preparedGesture.config = gesture;\n\n for (const gesture of preparedGesture.config) {\n const actionType = gesture.shouldUseReanimated\n ? ActionType.REANIMATED_WORKLET\n : ActionType.JS_FUNCTION_NEW_API;\n\n if (Platform.OS === 'web') {\n (\n RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler\n )(\n gesture.handlerTag,\n viewTag,\n ActionType.JS_FUNCTION_OLD_API, // ignored on web\n webEventHandlersRef\n );\n } else {\n RNGestureHandlerModule.attachGestureHandler(\n gesture.handlerTag,\n viewTag,\n actionType\n );\n }\n }\n\n if (preparedGesture.animatedHandlers) {\n const isAnimatedGesture = (g: GestureType) => g.shouldUseReanimated;\n\n preparedGesture.animatedHandlers.value = gesture\n .filter(isAnimatedGesture)\n .map((g) => g.handlers) as unknown as HandlerCallbacks<\n Record<string, unknown>\n >[];\n }\n}\n\nfunction updateHandlers(\n preparedGesture: GestureConfigReference,\n gestureConfig: ComposedGesture | GestureType,\n gesture: GestureType[],\n mountedRef: React.RefObject<boolean>\n) {\n gestureConfig.prepare();\n\n for (let i = 0; i < gesture.length; i++) {\n const handler = preparedGesture.config[i];\n checkGestureCallbacksForWorklets(handler);\n\n // only update handlerTag when it's actually different, it may be the same\n // if gesture config object is wrapped with useMemo\n if (gesture[i].handlerTag !== handler.handlerTag) {\n gesture[i].handlerTag = handler.handlerTag;\n gesture[i].handlers.handlerTag = handler.handlerTag;\n }\n }\n\n // use setImmediate to extract handlerTags, because when it's ran, all refs should be updated\n // and handlerTags in BaseGesture references should be updated in the loop above (we need to wait\n // in case of external relations)\n setImmediate(() => {\n if (!mountedRef.current) {\n return;\n }\n for (let i = 0; i < gesture.length; i++) {\n const handler = preparedGesture.config[i];\n\n handler.config = gesture[i].config;\n handler.handlers = gesture[i].handlers;\n\n const requireToFail = extractValidHandlerTags(\n handler.config.requireToFail\n );\n\n const simultaneousWith = extractValidHandlerTags(\n handler.config.simultaneousWith\n );\n\n RNGestureHandlerModule.updateGestureHandler(\n handler.handlerTag,\n filterConfig(handler.config, ALLOWED_PROPS, {\n simultaneousHandlers: simultaneousWith,\n waitFor: requireToFail,\n })\n );\n\n registerHandler(handler.handlerTag, handler, handler.config.testId);\n }\n\n if (preparedGesture.animatedHandlers) {\n const previousHandlersValue =\n preparedGesture.animatedHandlers.value ?? [];\n const newHandlersValue = preparedGesture.config\n .filter((g) => g.shouldUseReanimated) // ignore gestures that shouldn't run on UI\n .map((g) => g.handlers) as unknown as HandlerCallbacks<\n Record<string, unknown>\n >[];\n\n // if amount of gesture configs changes, we need to update the callbacks in shared value\n let shouldUpdateSharedValue =\n previousHandlersValue.length !== newHandlersValue.length;\n\n if (!shouldUpdateSharedValue) {\n // if the amount is the same, we need to check if any of the configs inside has changed\n for (let i = 0; i < newHandlersValue.length; i++) {\n if (\n // we can use the `gestureId` prop as it's unique for every config instance\n newHandlersValue[i].gestureId !== previousHandlersValue[i].gestureId\n ) {\n shouldUpdateSharedValue = true;\n break;\n }\n }\n }\n\n if (shouldUpdateSharedValue) {\n preparedGesture.animatedHandlers.value = newHandlersValue;\n }\n }\n\n scheduleFlushOperations();\n });\n}\n\nfunction needsToReattach(\n preparedGesture: GestureConfigReference,\n gesture: GestureType[]\n) {\n if (gesture.length !== preparedGesture.config.length) {\n return true;\n }\n for (let i = 0; i < gesture.length; i++) {\n if (\n gesture[i].handlerName !== preparedGesture.config[i].handlerName ||\n gesture[i].shouldUseReanimated !==\n preparedGesture.config[i].shouldUseReanimated\n ) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction isStateChangeEvent(\n event: GestureUpdateEvent | GestureStateChangeEvent | GestureTouchEvent\n): event is GestureStateChangeEvent {\n 'worklet';\n // @ts-ignore Yes, the oldState prop is missing on GestureTouchEvent, that's the point\n return event.oldState != null;\n}\n\nfunction isTouchEvent(\n event: GestureUpdateEvent | GestureStateChangeEvent | GestureTouchEvent\n): event is GestureTouchEvent {\n 'worklet';\n return event.eventType != null;\n}\n\nfunction getHandler(\n type: CALLBACK_TYPE,\n gesture: HandlerCallbacks<Record<string, unknown>>\n) {\n 'worklet';\n switch (type) {\n case CALLBACK_TYPE.BEGAN:\n return gesture.onBegin;\n case CALLBACK_TYPE.START:\n return gesture.onStart;\n case CALLBACK_TYPE.UPDATE:\n return gesture.onUpdate;\n case CALLBACK_TYPE.CHANGE:\n return gesture.onChange;\n case CALLBACK_TYPE.END:\n return gesture.onEnd;\n case CALLBACK_TYPE.FINALIZE:\n return gesture.onFinalize;\n case CALLBACK_TYPE.TOUCHES_DOWN:\n return gesture.onTouchesDown;\n case CALLBACK_TYPE.TOUCHES_MOVE:\n return gesture.onTouchesMove;\n case CALLBACK_TYPE.TOUCHES_UP:\n return gesture.onTouchesUp;\n case CALLBACK_TYPE.TOUCHES_CANCELLED:\n return gesture.onTouchesCancelled;\n }\n}\n\nfunction touchEventTypeToCallbackType(\n eventType: TouchEventType\n): CALLBACK_TYPE {\n 'worklet';\n switch (eventType) {\n case TouchEventType.TOUCHES_DOWN:\n return CALLBACK_TYPE.TOUCHES_DOWN;\n case TouchEventType.TOUCHES_MOVE:\n return CALLBACK_TYPE.TOUCHES_MOVE;\n case TouchEventType.TOUCHES_UP:\n return CALLBACK_TYPE.TOUCHES_UP;\n case TouchEventType.TOUCHES_CANCELLED:\n return CALLBACK_TYPE.TOUCHES_CANCELLED;\n }\n return CALLBACK_TYPE.UNDEFINED;\n}\n\nfunction runWorklet(\n type: CALLBACK_TYPE,\n gesture: HandlerCallbacks<Record<string, unknown>>,\n event: GestureStateChangeEvent | GestureUpdateEvent | GestureTouchEvent,\n ...args: any[]\n) {\n 'worklet';\n const handler = getHandler(type, gesture);\n if (gesture.isWorklet[type]) {\n // @ts-ignore Logic below makes sure the correct event is send to the\n // correct handler.\n handler?.(event, ...args);\n } else if (handler) {\n console.warn(tagMessage('Animated gesture callback must be a worklet'));\n }\n}\n\nfunction useAnimatedGesture(\n preparedGesture: GestureConfigReference,\n needsRebuild: boolean\n) {\n if (!Reanimated) {\n return;\n }\n\n // Hooks are called conditionally, but the condition is whether the\n // react-native-reanimated is installed, which shouldn't change while running\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const sharedHandlersCallbacks = Reanimated.useSharedValue<\n HandlerCallbacks<Record<string, unknown>>[] | null\n >(null);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const lastUpdateEvent = Reanimated.useSharedValue<\n (GestureUpdateEvent | undefined)[]\n >([]);\n\n // not every gesture needs a state controller, init them lazily\n const stateControllers: GestureStateManagerType[] = [];\n\n const callback = (\n event: GestureStateChangeEvent | GestureUpdateEvent | GestureTouchEvent\n ) => {\n 'worklet';\n\n const currentCallback = sharedHandlersCallbacks.value;\n if (!currentCallback) {\n return;\n }\n\n for (let i = 0; i < currentCallback.length; i++) {\n const gesture = currentCallback[i];\n\n if (event.handlerTag === gesture.handlerTag) {\n if (isStateChangeEvent(event)) {\n if (\n event.oldState === State.UNDETERMINED &&\n event.state === State.BEGAN\n ) {\n runWorklet(CALLBACK_TYPE.BEGAN, gesture, event);\n } else if (\n (event.oldState === State.BEGAN ||\n event.oldState === State.UNDETERMINED) &&\n event.state === State.ACTIVE\n ) {\n runWorklet(CALLBACK_TYPE.START, gesture, event);\n lastUpdateEvent.value[gesture.handlerTag] = undefined;\n } else if (\n event.oldState !== event.state &&\n event.state === State.END\n ) {\n if (event.oldState === State.ACTIVE) {\n runWorklet(CALLBACK_TYPE.END, gesture, event, true);\n }\n runWorklet(CALLBACK_TYPE.FINALIZE, gesture, event, true);\n } else if (\n (event.state === State.FAILED || event.state === State.CANCELLED) &&\n event.state !== event.oldState\n ) {\n if (event.oldState === State.ACTIVE) {\n runWorklet(CALLBACK_TYPE.END, gesture, event, false);\n }\n runWorklet(CALLBACK_TYPE.FINALIZE, gesture, event, false);\n }\n } else if (isTouchEvent(event)) {\n if (!stateControllers[i]) {\n stateControllers[i] = GestureStateManager.create(event.handlerTag);\n }\n\n if (event.eventType !== TouchEventType.UNDETERMINED) {\n runWorklet(\n touchEventTypeToCallbackType(event.eventType),\n gesture,\n event,\n stateControllers[i]\n );\n }\n } else {\n runWorklet(CALLBACK_TYPE.UPDATE, gesture, event);\n\n if (gesture.onChange && gesture.changeEventCalculator) {\n runWorklet(\n CALLBACK_TYPE.CHANGE,\n gesture,\n gesture.changeEventCalculator?.(\n event,\n lastUpdateEvent.value[gesture.handlerTag]\n )\n );\n\n lastUpdateEvent.value[gesture.handlerTag] = event;\n }\n }\n }\n }\n };\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const event = Reanimated.useEvent(\n callback,\n ['onGestureHandlerStateChange', 'onGestureHandlerEvent'],\n needsRebuild\n );\n\n preparedGesture.animatedEventHandler = event;\n preparedGesture.animatedHandlers = sharedHandlersCallbacks;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction validateDetectorChildren(ref: any) {\n // finds the first native view under the Wrap component and traverses the fiber tree upwards\n // to check whether there is more than one native view as a pseudo-direct child of GestureDetector\n // i.e. this is not ok:\n // Wrap\n // |\n // / \\\n // / \\\n // / \\\n // / \\\n // NativeView NativeView\n //\n // but this is fine:\n // Wrap\n // |\n // NativeView\n // |\n // / \\\n // / \\\n // / \\\n // / \\\n // NativeView NativeView\n if (__DEV__ && Platform.OS !== 'web') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const wrapType =\n REACT_NATIVE_VERSION.minor > 63 || REACT_NATIVE_VERSION.major > 0\n ? // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ref._reactInternals.elementType\n : // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ref._reactInternalFiber.elementType;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n let instance =\n RNRenderer.findHostInstance_DEPRECATED(\n ref\n )._internalFiberInstanceHandleDEV;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n while (instance && instance.elementType !== wrapType) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (instance.sibling) {\n throw new Error(\n 'GestureDetector has more than one native view as its children. This can happen if you are using a custom component that renders multiple views, like React.Fragment. You should wrap content of GestureDetector with a <View> or <Animated.View>.'\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n instance = instance.return;\n }\n }\n}\n\nconst applyUserSelectProp = (\n userSelect: UserSelect,\n gesture: ComposedGesture | GestureType\n): void => {\n for (const g of gesture.toGestureArray()) {\n g.config.userSelect = userSelect;\n }\n};\n\ninterface GestureDetectorProps {\n gesture: ComposedGesture | GestureType;\n userSelect?: UserSelect;\n children?: React.ReactNode;\n}\ninterface GestureDetectorState {\n firstRender: boolean;\n viewRef: React.Component | null;\n previousViewTag: number;\n forceReattach: boolean;\n}\nexport const GestureDetector = (props: GestureDetectorProps) => {\n const gestureConfig = props.gesture;\n\n if (props.userSelect) {\n applyUserSelectProp(props.userSelect, gestureConfig);\n }\n\n const gesture = gestureConfig.toGestureArray();\n const useReanimatedHook = gesture.some((g) => g.shouldUseReanimated);\n\n // store state in ref to prevent unnecessary renders\n const state = useRef<GestureDetectorState>({\n firstRender: true,\n viewRef: null,\n previousViewTag: -1,\n forceReattach: false,\n }).current;\n const mountedRef = useRef(false);\n const webEventHandlersRef = useRef<WebEventHandler>({\n onGestureHandlerEvent: (e: HandlerStateChangeEvent<unknown>) => {\n onGestureHandlerEvent(e.nativeEvent);\n },\n onGestureHandlerStateChange: isExperimentalWebImplementationEnabled()\n ? (e: HandlerStateChangeEvent<unknown>) => {\n onGestureHandlerEvent(e.nativeEvent);\n }\n : undefined,\n });\n\n const [renderState, setRenderState] = useState(false);\n function forceRender() {\n setRenderState(!renderState);\n }\n\n const preparedGesture = React.useRef<GestureConfigReference>({\n config: gesture,\n animatedEventHandler: null,\n animatedHandlers: null,\n firstExecution: true,\n useReanimatedHook: useReanimatedHook,\n }).current;\n\n if (useReanimatedHook !== preparedGesture.useReanimatedHook) {\n throw new Error(\n tagMessage(\n 'You cannot change the thread the callbacks are ran on while the app is running'\n )\n );\n }\n\n function onHandlersUpdate(skipConfigUpdate?: boolean) {\n // if the underlying view has changed we need to reattach handlers to the new view\n const viewTag = findNodeHandle(state.viewRef) as number;\n const forceReattach = viewTag !== state.previousViewTag;\n\n if (forceReattach || needsToReattach(preparedGesture, gesture)) {\n validateDetectorChildren(state.viewRef);\n dropHandlers(preparedGesture);\n attachHandlers({\n preparedGesture,\n gestureConfig,\n gesture,\n webEventHandlersRef,\n viewTag,\n mountedRef,\n });\n\n state.previousViewTag = viewTag;\n state.forceReattach = forceReattach;\n if (forceReattach) {\n forceRender();\n }\n } else if (!skipConfigUpdate) {\n updateHandlers(preparedGesture, gestureConfig, gesture, mountedRef);\n }\n }\n\n // Reanimated event should be rebuilt only when gestures are reattached, otherwise\n // config update will be enough as all necessary items are stored in shared values anyway\n const needsToRebuildReanimatedEvent =\n preparedGesture.firstExecution ||\n needsToReattach(preparedGesture, gesture) ||\n state.forceReattach;\n\n state.forceReattach = false;\n\n if (preparedGesture.firstExecution) {\n gestureConfig.initialize();\n }\n\n if (useReanimatedHook) {\n // Whether animatedGesture or gesture is used shouldn't change while the app is running\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useAnimatedGesture(preparedGesture, needsToRebuildReanimatedEvent);\n }\n\n useEffect(() => {\n const viewTag = findNodeHandle(state.viewRef) as number;\n state.firstRender = true;\n mountedRef.current = true;\n\n validateDetectorChildren(state.viewRef);\n\n attachHandlers({\n preparedGesture,\n gestureConfig,\n gesture,\n webEventHandlersRef,\n viewTag,\n mountedRef,\n });\n\n return () => {\n mountedRef.current = false;\n dropHandlers(preparedGesture);\n };\n }, []);\n\n useEffect(() => {\n if (!state.firstRender) {\n onHandlersUpdate();\n } else {\n state.firstRender = false;\n }\n }, [props]);\n\n const refFunction = (ref: unknown) => {\n if (ref !== null) {\n // @ts-ignore Just setting the view ref\n state.viewRef = ref;\n\n // if it's the first render, also set the previousViewTag to prevent reattaching gestures when not needed\n if (state.previousViewTag === -1) {\n state.previousViewTag = findNodeHandle(state.viewRef) as number;\n }\n\n // pass true as `skipConfigUpdate`, here we only want to trigger the eventual reattaching of handlers\n // in case the view has changed, while config update would be handled be the `useEffect` above\n onHandlersUpdate(true);\n\n if (isFabric()) {\n const node = getShadowNodeFromRef(ref);\n if (global.isFormsStackingContext(node) === false) {\n console.error(\n tagMessage(\n 'GestureDetector has received a child that may get view-flattened. ' +\n '\\nTo prevent it from misbehaving you need to wrap the child with a `<View collapsable={false}>`.'\n )\n );\n }\n }\n }\n };\n\n if (useReanimatedHook) {\n return (\n <AnimatedWrap\n ref={refFunction}\n onGestureHandlerEvent={preparedGesture.animatedEventHandler}>\n {props.children}\n </AnimatedWrap>\n );\n } else {\n return <Wrap ref={refFunction}>{props.children}</Wrap>;\n }\n};\n\nclass Wrap extends React.Component<{\n onGestureHandlerEvent?: unknown;\n // implicit `children` prop has been removed in @types/react^18.0.0\n children?: React.ReactNode;\n}> {\n render() {\n try {\n // I don't think that fighting with types over such a simple function is worth it\n // The only thing it does is add 'collapsable: false' to the child component\n // to make sure it is in the native view hierarchy so the detector can find\n // correct viewTag to attach to.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const child: any = React.Children.only(this.props.children);\n return React.cloneElement(\n child,\n { collapsable: false },\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n child.props.children\n );\n } catch (e) {\n throw new Error(\n tagMessage(\n `GestureDetector got more than one view as a child. If you want the gesture to work on multiple views, wrap them with a common parent and attach the gesture to that view.`\n )\n );\n }\n }\n}\n\nconst AnimatedWrap = Reanimated?.default?.createAnimatedComponent(Wrap) ?? Wrap;\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["eventReceiver.ts"],"names":["DeviceEventEmitter","State","TouchEventType","findHandler","findOldGestureHandler","GestureStateManager","gestureHandlerEventSubscription","gestureHandlerStateChangeEventSubscription","gestureStateManagers","Map","lastUpdateEvent","isStateChangeEvent","event","oldState","isTouchEvent","eventType","onGestureHandlerEvent","handler","handlerTag","UNDETERMINED","state","BEGAN","handlers","onBegin","ACTIVE","onStart","END","onEnd","onFinalize","undefined","FAILED","CANCELLED","delete","has","set","create","manager","get","TOUCHES_DOWN","onTouchesDown","TOUCHES_MOVE","onTouchesMove","TOUCHES_UP","onTouchesUp","TOUCHES_CANCELLED","onTouchesCancelled","onUpdate","onChange","changeEventCalculator","oldHandler","nativeEvent","onGestureStateChange","onGestureEvent","startListening","stopListening","addListener","remove"],"mappings":"AAAA,SAASA,kBAAT,QAAwD,cAAxD;AACA,SAASC,KAAT,QAAsB,aAAtB;AACA,SAASC,cAAT,QAA+B,sBAA/B;AAMA,SAASC,WAAT,EAAsBC,qBAAtB,QAAmD,qBAAnD;AAEA,SACEC,mBADF,QAGO,uBAHP;AAKA,IAAIC,+BAA2D,GAAG,IAAlE;AACA,IAAIC,0CAAsE,GAAG,IAA7E;AAEA,MAAMC,oBAA0D,GAAG,IAAIC,GAAJ,EAAnE;AAKA,MAAMC,eAAmD,GAAG,EAA5D;;AAEA,SAASC,kBAAT,CACEC,KADF,EAEoC;AAClC;AACA,SAAOA,KAAK,CAACC,QAAN,IAAkB,IAAzB;AACD;;AAED,SAASC,YAAT,CACEF,KADF,EAE8B;AAC5B,SAAOA,KAAK,CAACG,SAAN,IAAmB,IAA1B;AACD;;AAED,OAAO,SAASC,qBAAT,CACLJ,KADK,EAEL;AAAA;;AACA,QAAMK,OAAO,GAAGd,WAAW,CAACS,KAAK,CAACM,UAAP,CAA3B;;AAIA,MAAID,OAAJ,EAAa;AACX,QAAIN,kBAAkB,CAACC,KAAD,CAAtB,EAA+B;AAC7B,UACEA,KAAK,CAACC,QAAN,KAAmBZ,KAAK,CAACkB,YAAzB,IACAP,KAAK,CAACQ,KAAN,KAAgBnB,KAAK,CAACoB,KAFxB,EAGE;AAAA;;AACA,sDAAAJ,OAAO,CAACK,QAAR,EAAiBC,OAAjB,wGAA2BX,KAA3B;AACD,OALD,MAKO,IACL,CAACA,KAAK,CAACC,QAAN,KAAmBZ,KAAK,CAACoB,KAAzB,IACCT,KAAK,CAACC,QAAN,KAAmBZ,KAAK,CAACkB,YAD3B,KAEAP,KAAK,CAACQ,KAAN,KAAgBnB,KAAK,CAACuB,MAHjB,EAIL;AAAA;;AACA,uDAAAP,OAAO,CAACK,QAAR,EAAiBG,OAAjB,yGAA2Bb,K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eAAe,CAACO,OAAO,CAACK,QAAR,CAAiBJ,UAAlB,CAAf,GAA+CN,KAA/C;AACD;AACF;AACF,GAtED,MAsEO;AACL,UAAMqC,UAAU,GAAG7C,qBAAqB,CAACQ,KAAK,CAACM,UAAP,CAAxC;;AACA,QAAI+B,UAAJ,EAAgB;AACd,YAAMC,WAAW,GAAG;AAAEA,QAAAA,WAAW,EAAEtC;AAAf,OAApB;;AACA,UAAID,kBAAkB,CAACC,KAAD,CAAtB,EAA+B;AAC7BqC,QAAAA,UAAU,CAACE,oBAAX,CAAgCD,WAAhC;AACD,OAFD,MAEO;AACLD,QAAAA,UAAU,CAACG,cAAX,CAA0BF,WAA1B;AACD;;AACD;AACD;AACF;AACF;AAED,OAAO,SAASG,cAAT,GAA0B;AAC/BC,EAAAA,aAAa;AAEbhD,EAAAA,+BAA+B,GAAGN,kBAAkB,CAACuD,WAAnB,CAChC,uBADgC,EAEhCvC,qBAFgC,CAAlC;AAKAT,EAAAA,0CAA0C,GAAGP,kBAAkB,CAACuD,WAAnB,CAC3C,6BAD2C,EAE3CvC,qBAF2C,CAA7C;AAID;AAED,OAAO,SAASsC,aAAT,GAAyB;AAC9B,MAAIhD,+BAAJ,EAAqC;AACnCA,IAAAA,+BAA+B,CAACkD,MAAhC;AACAlD,IAAAA,+BAA+B,GAAG,IAAlC;AACD;;AAED,MAAIC,0CAAJ,EAAgD;AAC9CA,IAAAA,0CAA0C,CAACiD,MAA3C;AACAjD,IAAAA,0CAA0C,GAAG,IAA7C;AACD;AACF","sourcesContent":["import { DeviceEventEmitter, EmitterSubscription } from 'react-native';\nimport { State } from '../../State';\nimport { TouchEventType } from '../../TouchEventType';\nimport {\n GestureTouchEvent,\n GestureUpdateEvent,\n GestureStateChangeEvent,\n} from '../gestureHandlerCommon';\nimport { findHandler, findOldGestureHandler } from '../handlersRegistry';\nimport { BaseGesture } from './gesture';\nimport {\n GestureStateManager,\n GestureStateManagerType,\n} from './gestureStateManager';\n\nlet gestureHandlerEventSubscription: EmitterSubscription | null = null;\nlet gestureHandlerStateChangeEventSubscription: EmitterSubscription | null = null;\n\nconst gestureStateManagers: Map<number, GestureStateManagerType> = new Map<\n number,\n GestureStateManagerType\n>();\n\nconst lastUpdateEvent: (GestureUpdateEvent | undefined)[] = [];\n\nfunction isStateChangeEvent(\n event: GestureUpdateEvent | GestureStateChangeEvent | GestureTouchEvent\n): event is GestureStateChangeEvent {\n // @ts-ignore oldState doesn't exist on GestureTouchEvent and that's the point\n return event.oldState != null;\n}\n\nfunction isTouchEvent(\n event: GestureUpdateEvent | GestureStateChangeEvent | GestureTouchEvent\n): event is GestureTouchEvent {\n return event.eventType != null;\n}\n\nexport function onGestureHandlerEvent(\n event: GestureUpdateEvent | GestureStateChangeEvent | GestureTouchEvent\n) {\n const handler = findHandler(event.handlerTag) as BaseGesture<\n Record<string, unknown>\n >;\n\n if (handler) {\n if (isStateChangeEvent(event)) {\n if (\n event.oldState === State.UNDETERMINED &&\n event.state === State.BEGAN\n ) {\n handler.handlers.onBegin?.(event);\n } else if (\n (event.oldState === State.BEGAN ||\n event.oldState === State.UNDETERMINED) &&\n event.state === State.ACTIVE\n ) {\n handler.handlers.onStart?.(event);\n lastUpdateEvent[handler.handlers.handlerTag] = event;\n } else if (event.oldState !== event.state && event.state === State.END) {\n if (event.oldState === State.ACTIVE) {\n handler.handlers.onEnd?.(event, true);\n }\n handler.handlers.onFinalize?.(event, true);\n lastUpdateEvent[handler.handlers.handlerTag] = undefined;\n } else if (\n (event.state === State.FAILED || event.state === State.CANCELLED) &&\n event.oldState !== event.state\n ) {\n if (event.oldState === State.ACTIVE) {\n handler.handlers.onEnd?.(event, false);\n }\n handler.handlers.onFinalize?.(event, false);\n gestureStateManagers.delete(event.handlerTag);\n lastUpdateEvent[handler.handlers.handlerTag] = undefined;\n }\n } else if (isTouchEvent(event)) {\n if (!gestureStateManagers.has(event.handlerTag)) {\n gestureStateManagers.set(\n event.handlerTag,\n GestureStateManager.create(event.handlerTag)\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const manager = gestureStateManagers.get(event.handlerTag)!;\n\n switch (event.eventType) {\n case TouchEventType.TOUCHES_DOWN:\n handler.handlers?.onTouchesDown?.(event, manager);\n break;\n case TouchEventType.TOUCHES_MOVE:\n handler.handlers?.onTouchesMove?.(event, manager);\n break;\n case TouchEventType.TOUCHES_UP:\n handler.handlers?.onTouchesUp?.(event, manager);\n break;\n case TouchEventType.TOUCHES_CANCELLED:\n handler.handlers?.onTouchesCancelled?.(event, manager);\n break;\n }\n } else {\n handler.handlers.onUpdate?.(event);\n\n if (handler.handlers.onChange && handler.handlers.changeEventCalculator) {\n handler.handlers.onChange?.(\n handler.handlers.changeEventCalculator?.(\n event,\n lastUpdateEvent[handler.handlers.handlerTag]\n )\n );\n\n lastUpdateEvent[handler.handlers.handlerTag] = event;\n }\n }\n } else {\n const oldHandler = findOldGestureHandler(event.handlerTag);\n if (oldHandler) {\n const nativeEvent = { nativeEvent: event };\n if (isStateChangeEvent(event)) {\n oldHandler.onGestureStateChange(nativeEvent);\n } else {\n oldHandler.onGestureEvent(nativeEvent);\n }\n return;\n }\n }\n}\n\nexport function startListening() {\n stopListening();\n\n gestureHandlerEventSubscription = DeviceEventEmitter.addListener(\n 'onGestureHandlerEvent',\n onGestureHandlerEvent\n );\n\n gestureHandlerStateChangeEventSubscription = DeviceEventEmitter.addListener(\n 'onGestureHandlerStateChange',\n onGestureHandlerEvent\n );\n}\n\nexport function stopListening() {\n if (gestureHandlerEventSubscription) {\n gestureHandlerEventSubscription.remove();\n gestureHandlerEventSubscription = null;\n }\n\n if (gestureHandlerStateChangeEventSubscription) {\n gestureHandlerStateChangeEventSubscription.remove();\n gestureHandlerStateChangeEventSubscription = null;\n }\n}\n"]}
1
+ {"version":3,"sources":["eventReceiver.ts"],"names":["DeviceEventEmitter","State","TouchEventType","findHandler","findOldGestureHandler","GestureStateManager","gestureHandlerEventSubscription","gestureHandlerStateChangeEventSubscription","gestureStateManagers","Map","lastUpdateEvent","isStateChangeEvent","event","oldState","isTouchEvent","eventType","onGestureHandlerEvent","handler","handlerTag","UNDETERMINED","state","BEGAN","handlers","onBegin","ACTIVE","onStart","END","onEnd","onFinalize","undefined","FAILED","CANCELLED","delete","has","set","create","manager","get","TOUCHES_DOWN","onTouchesDown","TOUCHES_MOVE","onTouchesMove","TOUCHES_UP","onTouchesUp","TOUCHES_CANCELLED","onTouchesCancelled","onUpdate","onChange","changeEventCalculator","oldHandler","nativeEvent","onGestureStateChange","onGestureEvent","startListening","stopListening","addListener","remove"],"mappings":"AAAA,SAASA,kBAAT,QAAwD,cAAxD;AACA,SAASC,KAAT,QAAsB,aAAtB;AACA,SAASC,cAAT,QAA+B,sBAA/B;AAMA,SAASC,WAAT,EAAsBC,qBAAtB,QAAmD,qBAAnD;AAEA,SACEC,mBADF,QAGO,uBAHP;AAKA,IAAIC,+BAA2D,GAAG,IAAlE;AACA,IAAIC,0CAAsE,GACxE,IADF;AAGA,MAAMC,oBAA0D,GAAG,IAAIC,GAAJ,EAAnE;AAKA,MAAMC,eAAmD,GAAG,EAA5D;;AAEA,SAASC,kBAAT,CACEC,KADF,EAEoC;AAClC;AACA,SAAOA,KAAK,CAACC,QAAN,IAAkB,IAAzB;AACD;;AAED,SAASC,YAAT,CACEF,KADF,EAE8B;AAC5B,SAAOA,KAAK,CAACG,SAAN,IAAmB,IAA1B;AACD;;AAED,OAAO,SAASC,qBAAT,CACLJ,KADK,EAEL;AAAA;;AACA,QAAMK,OAAO,GAAGd,WAAW,CAACS,KAAK,CAACM,UAAP,CAA3B;;AAIA,MAAID,OAAJ,EAAa;AACX,QAAIN,kBAAkB,CAACC,KAAD,CAAtB,EAA+B;AAC7B,UACEA,KAAK,CAACC,QAAN,KAAmBZ,KAAK,CAACkB,YAAzB,IACAP,KAAK,CAACQ,KAAN,KAAgBnB,KAAK,CAACoB,KAFxB,EAGE;AAAA;;AACA,sDAAAJ,OAAO,CAACK,QAAR,EAAiBC,OAAjB,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viceEventEmitter, EmitterSubscription } from 'react-native';\nimport { State } from '../../State';\nimport { TouchEventType } from '../../TouchEventType';\nimport {\n GestureTouchEvent,\n GestureUpdateEvent,\n GestureStateChangeEvent,\n} from '../gestureHandlerCommon';\nimport { findHandler, findOldGestureHandler } from '../handlersRegistry';\nimport { BaseGesture } from './gesture';\nimport {\n GestureStateManager,\n GestureStateManagerType,\n} from './gestureStateManager';\n\nlet gestureHandlerEventSubscription: EmitterSubscription | null = null;\nlet gestureHandlerStateChangeEventSubscription: EmitterSubscription | null =\n null;\n\nconst gestureStateManagers: Map<number, GestureStateManagerType> = new Map<\n number,\n GestureStateManagerType\n>();\n\nconst lastUpdateEvent: (GestureUpdateEvent | undefined)[] = [];\n\nfunction isStateChangeEvent(\n event: GestureUpdateEvent | GestureStateChangeEvent | GestureTouchEvent\n): event is GestureStateChangeEvent {\n // @ts-ignore oldState doesn't exist on GestureTouchEvent and that's the point\n return event.oldState != null;\n}\n\nfunction isTouchEvent(\n event: GestureUpdateEvent | GestureStateChangeEvent | GestureTouchEvent\n): event is GestureTouchEvent {\n return event.eventType != null;\n}\n\nexport function onGestureHandlerEvent(\n event: GestureUpdateEvent | GestureStateChangeEvent | GestureTouchEvent\n) {\n const handler = findHandler(event.handlerTag) as BaseGesture<\n Record<string, unknown>\n >;\n\n if (handler) {\n if (isStateChangeEvent(event)) {\n if (\n event.oldState === State.UNDETERMINED &&\n event.state === State.BEGAN\n ) {\n handler.handlers.onBegin?.(event);\n } else if (\n (event.oldState === State.BEGAN ||\n event.oldState === State.UNDETERMINED) &&\n event.state === State.ACTIVE\n ) {\n handler.handlers.onStart?.(event);\n lastUpdateEvent[handler.handlers.handlerTag] = event;\n } else if (event.oldState !== event.state && event.state === State.END) {\n if (event.oldState === State.ACTIVE) {\n handler.handlers.onEnd?.(event, true);\n }\n handler.handlers.onFinalize?.(event, true);\n lastUpdateEvent[handler.handlers.handlerTag] = undefined;\n } else if (\n (event.state === State.FAILED || event.state === State.CANCELLED) &&\n event.oldState !== event.state\n ) {\n if (event.oldState === State.ACTIVE) {\n handler.handlers.onEnd?.(event, false);\n }\n handler.handlers.onFinalize?.(event, false);\n gestureStateManagers.delete(event.handlerTag);\n lastUpdateEvent[handler.handlers.handlerTag] = undefined;\n }\n } else if (isTouchEvent(event)) {\n if (!gestureStateManagers.has(event.handlerTag)) {\n gestureStateManagers.set(\n event.handlerTag,\n GestureStateManager.create(event.handlerTag)\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const manager = gestureStateManagers.get(event.handlerTag)!;\n\n switch (event.eventType) {\n case TouchEventType.TOUCHES_DOWN:\n handler.handlers?.onTouchesDown?.(event, manager);\n break;\n case TouchEventType.TOUCHES_MOVE:\n handler.handlers?.onTouchesMove?.(event, manager);\n break;\n case TouchEventType.TOUCHES_UP:\n handler.handlers?.onTouchesUp?.(event, manager);\n break;\n case TouchEventType.TOUCHES_CANCELLED:\n handler.handlers?.onTouchesCancelled?.(event, manager);\n break;\n }\n } else {\n handler.handlers.onUpdate?.(event);\n\n if (handler.handlers.onChange && handler.handlers.changeEventCalculator) {\n handler.handlers.onChange?.(\n handler.handlers.changeEventCalculator?.(\n event,\n lastUpdateEvent[handler.handlers.handlerTag]\n )\n );\n\n lastUpdateEvent[handler.handlers.handlerTag] = event;\n }\n }\n } else {\n const oldHandler = findOldGestureHandler(event.handlerTag);\n if (oldHandler) {\n const nativeEvent = { nativeEvent: event };\n if (isStateChangeEvent(event)) {\n oldHandler.onGestureStateChange(nativeEvent);\n } else {\n oldHandler.onGestureEvent(nativeEvent);\n }\n return;\n }\n }\n}\n\nexport function startListening() {\n stopListening();\n\n gestureHandlerEventSubscription = DeviceEventEmitter.addListener(\n 'onGestureHandlerEvent',\n onGestureHandlerEvent\n );\n\n gestureHandlerStateChangeEventSubscription = DeviceEventEmitter.addListener(\n 'onGestureHandlerStateChange',\n onGestureHandlerEvent\n );\n}\n\nexport function stopListening() {\n if (gestureHandlerEventSubscription) {\n gestureHandlerEventSubscription.remove();\n gestureHandlerEventSubscription = null;\n }\n\n if (gestureHandlerStateChangeEventSubscription) {\n gestureHandlerStateChangeEventSubscription.remove();\n gestureHandlerStateChangeEventSubscription = null;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["gesture.ts"],"names":["getNextHandlerTag","isRemoteDebuggingEnabled","CALLBACK_TYPE","UNDEFINED","BEGAN","START","UPDATE","CHANGE","END","FINALIZE","TOUCHES_DOWN","TOUCHES_MOVE","TOUCHES_UP","TOUCHES_CANCELLED","Gesture","nextGestureId","BaseGesture","constructor","gestureId","handlerTag","isWorklet","handlers","addDependency","key","gesture","value","config","Array","concat","withRef","ref","callback","__workletHash","undefined","onBegin","onStart","onEnd","onFinalize","onTouchesDown","needsPointerData","onTouchesMove","onTouchesUp","onTouchesCancelled","enabled","shouldCancelWhenOutside","hitSlop","runOnJS","simultaneousWithExternalGesture","gestures","requireExternalGestureToFail","withTestId","id","testId","cancelsTouchesInView","initialize","current","toGestureArray","prepare","shouldUseReanimated","includes","ContinousBaseGesture","onUpdate","onChange","manualActivation"],"mappings":";;AASA,SAASA,iBAAT,QAAkC,qBAAlC;AAQA,SAASC,wBAAT,QAAyC,aAAzC;AA+DA,OAAO,MAAMC,aAAa,GAAG;AAC3BC,EAAAA,SAAS,EAAE,CADgB;AAE3BC,EAAAA,KAAK,EAAE,CAFoB;AAG3BC,EAAAA,KAAK,EAAE,CAHoB;AAI3BC,EAAAA,MAAM,EAAE,CAJmB;AAK3BC,EAAAA,MAAM,EAAE,CALmB;AAM3BC,EAAAA,GAAG,EAAE,CANsB;AAO3BC,EAAAA,QAAQ,EAAE,CAPiB;AAQ3BC,EAAAA,YAAY,EAAE,CARa;AAS3BC,EAAAA,YAAY,EAAE,CATa;AAU3BC,EAAAA,UAAU,EAAE,CAVe;AAW3BC,EAAAA,iBAAiB,EAAE;AAXQ,CAAtB,C,CAcP;AACA;;AAGA,OAAO,MAAeC,OAAf,CAAuB;AAoB9B,IAAIC,a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KV,QAAL,CAAcD,SAAd,CAAwBlB,aAAa,CAACK,MAAtC,IAAgD,KAAKa,SAAL,CAAeW,QAAf,CAAhD;AACA,WAAO,IAAP;AACD;;AAEDgC,EAAAA,gBAAgB,CAACA,gBAAD,EAA4B;AAC1C,SAAKrC,MAAL,CAAYqC,gBAAZ,GAA+BA,gBAA/B;AACA,WAAO,IAAP;AACD;;AApBkC","sourcesContent":["import { FlingGestureHandlerEventPayload } from '../FlingGestureHandler';\nimport { ForceTouchGestureHandlerEventPayload } from '../ForceTouchGestureHandler';\nimport {\n HitSlop,\n CommonGestureConfig,\n GestureTouchEvent,\n GestureStateChangeEvent,\n GestureUpdateEvent,\n} from '../gestureHandlerCommon';\nimport { getNextHandlerTag } from '../handlersRegistry';\nimport { GestureStateManagerType } from './gestureStateManager';\nimport { LongPressGestureHandlerEventPayload } from '../LongPressGestureHandler';\nimport { PanGestureHandlerEventPayload } from '../PanGestureHandler';\nimport { PinchGestureHandlerEventPayload } from '../PinchGestureHandler';\nimport { RotationGestureHandlerEventPayload } from '../RotationGestureHandler';\nimport { TapGestureHandlerEventPayload } from '../TapGestureHandler';\nimport { NativeViewGestureHandlerPayload } from '../NativeViewGestureHandler';\nimport { isRemoteDebuggingEnabled } from '../../utils';\n\nexport type GestureType =\n | BaseGesture<Record<string, unknown>>\n | BaseGesture<Record<string, never>>\n | BaseGesture<TapGestureHandlerEventPayload>\n | BaseGesture<PanGestureHandlerEventPayload>\n | BaseGesture<LongPressGestureHandlerEventPayload>\n | BaseGesture<RotationGestureHandlerEventPayload>\n | BaseGesture<PinchGestureHandlerEventPayload>\n | BaseGesture<FlingGestureHandlerEventPayload>\n | BaseGesture<ForceTouchGestureHandlerEventPayload>\n | BaseGesture<NativeViewGestureHandlerPayload>;\n\nexport type GestureRef =\n | number\n | GestureType\n | React.RefObject<GestureType | undefined>\n | React.RefObject<React.ComponentType | undefined>; // allow adding a ref to a gesture handler\nexport interface BaseGestureConfig\n extends CommonGestureConfig,\n Record<string, unknown> {\n ref?: React.MutableRefObject<GestureType | undefined>;\n requireToFail?: GestureRef[];\n simultaneousWith?: GestureRef[];\n needsPointerData?: boolean;\n manualActivation?: boolean;\n runOnJS?: boolean;\n testId?: string;\n cancelsTouchesInView?: boolean;\n}\n\ntype TouchEventHandlerType = (\n event: GestureTouchEvent,\n stateManager: GestureStateManagerType\n) => void;\n\nexport type HandlerCallbacks<EventPayloadT extends Record<string, unknown>> = {\n gestureId: number;\n handlerTag: number;\n onBegin?: (event: GestureStateChangeEvent<EventPayloadT>) => void;\n onStart?: (event: GestureStateChangeEvent<EventPayloadT>) => void;\n onEnd?: (\n event: GestureStateChangeEvent<EventPayloadT>,\n success: boolean\n ) => void;\n onFinalize?: (\n event: GestureStateChangeEvent<EventPayloadT>,\n success: boolean\n ) => void;\n onUpdate?: (event: GestureUpdateEvent<EventPayloadT>) => void;\n onChange?: (event: any) => void;\n onTouchesDown?: TouchEventHandlerType;\n onTouchesMove?: TouchEventHandlerType;\n onTouchesUp?: TouchEventHandlerType;\n onTouchesCancelled?: TouchEventHandlerType;\n changeEventCalculator?: (\n current: GestureUpdateEvent<Record<string, unknown>>,\n previous?: GestureUpdateEvent<Record<string, unknown>>\n ) => GestureUpdateEvent<Record<string, unknown>>;\n isWorklet: boolean[];\n};\n\nexport const CALLBACK_TYPE = {\n UNDEFINED: 0,\n BEGAN: 1,\n START: 2,\n UPDATE: 3,\n CHANGE: 4,\n END: 5,\n FINALIZE: 6,\n TOUCHES_DOWN: 7,\n TOUCHES_MOVE: 8,\n TOUCHES_UP: 9,\n TOUCHES_CANCELLED: 10,\n} as const;\n\n// Allow using CALLBACK_TYPE as object and type\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type CALLBACK_TYPE = typeof CALLBACK_TYPE[keyof typeof CALLBACK_TYPE];\n\nexport abstract class Gesture {\n /**\n * Return array of gestures, providing the same interface for creating and updating\n * handlers, no matter which object was used to create gesture instance.\n */\n abstract toGestureArray(): GestureType[];\n\n /**\n * Assign handlerTag to the gesture instance and set ref.current (if a ref is set)\n */\n abstract initialize(): void;\n\n /**\n * Make sure that values of properties defining relations are arrays. Do any necessary\n * preprocessing required to configure relations between handlers. Called just before\n * updating the handler on the native side.\n */\n abstract prepare(): void;\n}\n\nlet nextGestureId = 0;\nexport abstract class BaseGesture<\n EventPayloadT extends Record<string, unknown>\n> extends Gesture {\n private gestureId = -1;\n public handlerTag = -1;\n public handlerName = '';\n public config: BaseGestureConfig = {};\n public handlers: HandlerCallbacks<EventPayloadT> = {\n gestureId: -1,\n handlerTag: -1,\n isWorklet: [],\n };\n\n constructor() {\n super();\n\n // Used to check whether the gesture config has been updated when wrapping it\n // with `useMemo`. Since every config will have a unique id, when the dependencies\n // don't change, the config won't be recreated and the id will stay the same.\n // If the id is different, it means that the config has changed and the gesture\n // needs to be updated.\n this.gestureId = nextGestureId++;\n this.handlers.gestureId = this.gestureId;\n }\n\n private addDependency(\n key: 'simultaneousWith' | 'requireToFail',\n gesture: Exclude<GestureRef, number>\n ) {\n const value = this.config[key];\n this.config[key] = value\n ? Array<GestureRef>().concat(value, gesture)\n : [gesture];\n }\n\n withRef(ref: React.MutableRefObject<GestureType | undefined>) {\n this.config.ref = ref;\n return this;\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-types\n protected isWorklet(callback: Function) {\n //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false\n return callback.__workletHash !== undefined;\n }\n\n onBegin(callback: (event: GestureStateChangeEvent<EventPayloadT>) => void) {\n this.handlers.onBegin = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.BEGAN] = this.isWorklet(callback);\n return this;\n }\n\n onStart(callback: (event: GestureStateChangeEvent<EventPayloadT>) => void) {\n this.handlers.onStart = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.START] = this.isWorklet(callback);\n return this;\n }\n\n onEnd(\n callback: (\n event: GestureStateChangeEvent<EventPayloadT>,\n success: boolean\n ) => void\n ) {\n this.handlers.onEnd = callback;\n //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false\n this.handlers.isWorklet[CALLBACK_TYPE.END] = this.isWorklet(callback);\n return this;\n }\n\n onFinalize(\n callback: (\n event: GestureStateChangeEvent<EventPayloadT>,\n success: boolean\n ) => void\n ) {\n this.handlers.onFinalize = callback;\n //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false\n this.handlers.isWorklet[CALLBACK_TYPE.FINALIZE] = this.isWorklet(callback);\n return this;\n }\n\n onTouchesDown(callback: TouchEventHandlerType) {\n this.config.needsPointerData = true;\n this.handlers.onTouchesDown = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_DOWN] = this.isWorklet(\n callback\n );\n\n return this;\n }\n\n onTouchesMove(callback: TouchEventHandlerType) {\n this.config.needsPointerData = true;\n this.handlers.onTouchesMove = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_MOVE] = this.isWorklet(\n callback\n );\n\n return this;\n }\n\n onTouchesUp(callback: TouchEventHandlerType) {\n this.config.needsPointerData = true;\n this.handlers.onTouchesUp = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_UP] = this.isWorklet(\n callback\n );\n\n return this;\n }\n\n onTouchesCancelled(callback: TouchEventHandlerType) {\n this.config.needsPointerData = true;\n this.handlers.onTouchesCancelled = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_CANCELLED] = this.isWorklet(\n callback\n );\n\n return this;\n }\n\n enabled(enabled: boolean) {\n this.config.enabled = enabled;\n return this;\n }\n\n shouldCancelWhenOutside(value: boolean) {\n this.config.shouldCancelWhenOutside = value;\n return this;\n }\n\n hitSlop(hitSlop: HitSlop) {\n this.config.hitSlop = hitSlop;\n return this;\n }\n\n runOnJS(runOnJS: boolean) {\n this.config.runOnJS = runOnJS;\n return this;\n }\n\n simultaneousWithExternalGesture(...gestures: Exclude<GestureRef, number>[]) {\n for (const gesture of gestures) {\n this.addDependency('simultaneousWith', gesture);\n }\n return this;\n }\n\n requireExternalGestureToFail(...gestures: Exclude<GestureRef, number>[]) {\n for (const gesture of gestures) {\n this.addDependency('requireToFail', gesture);\n }\n return this;\n }\n\n withTestId(id: string) {\n this.config.testId = id;\n return this;\n }\n\n cancelsTouchesInView(value: boolean) {\n this.config.cancelsTouchesInView = value;\n return this;\n }\n\n initialize() {\n this.handlerTag = getNextHandlerTag();\n\n this.handlers = { ...this.handlers, handlerTag: this.handlerTag };\n\n if (this.config.ref) {\n this.config.ref.current = this as GestureType;\n }\n }\n\n toGestureArray(): GestureType[] {\n return [this as GestureType];\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n prepare() {}\n\n get shouldUseReanimated(): boolean {\n // use Reanimated when runOnJS isn't set explicitly,\n // and all defined callbacks are worklets,\n // and remote debugging is disabled\n return (\n this.config.runOnJS !== true &&\n !this.handlers.isWorklet.includes(false) &&\n !isRemoteDebuggingEnabled()\n );\n }\n}\n\nexport abstract class ContinousBaseGesture<\n EventPayloadT extends Record<string, unknown>,\n EventChangePayloadT extends Record<string, unknown>\n> extends BaseGesture<EventPayloadT> {\n onUpdate(callback: (event: GestureUpdateEvent<EventPayloadT>) => void) {\n this.handlers.onUpdate = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.UPDATE] = this.isWorklet(callback);\n return this;\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<EventPayloadT & EventChangePayloadT>\n ) => void\n ) {\n this.handlers.onChange = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.CHANGE] = this.isWorklet(callback);\n return this;\n }\n\n manualActivation(manualActivation: boolean) {\n this.config.manualActivation = manualActivation;\n return this;\n }\n}\n"]}
1
+ {"version":3,"sources":["gesture.ts"],"names":["getNextHandlerTag","isRemoteDebuggingEnabled","CALLBACK_TYPE","UNDEFINED","BEGAN","START","UPDATE","CHANGE","END","FINALIZE","TOUCHES_DOWN","TOUCHES_MOVE","TOUCHES_UP","TOUCHES_CANCELLED","Gesture","nextGestureId","BaseGesture","constructor","gestureId","handlerTag","isWorklet","handlers","addDependency","key","gesture","value","config","Array","concat","withRef","ref","callback","__workletHash","undefined","onBegin","onStart","onEnd","onFinalize","onTouchesDown","needsPointerData","onTouchesMove","onTouchesUp","onTouchesCancelled","enabled","shouldCancelWhenOutside","hitSlop","runOnJS","simultaneousWithExternalGesture","gestures","requireExternalGestureToFail","withTestId","id","testId","cancelsTouchesInView","initialize","current","toGestureArray","prepare","shouldUseReanimated","includes","ContinousBaseGesture","onUpdate","onChange","manualActivation"],"mappings":";;AASA,SAASA,iBAAT,QAAkC,qBAAlC;AAQA,SAASC,wBAAT,QAAyC,aAAzC;AA+DA,OAAO,MAAMC,aAAa,GAAG;AAC3BC,EAAAA,SAAS,EAAE,CADgB;AAE3BC,EAAAA,KAAK,EAAE,CAFoB;AAG3BC,EAAAA,KAAK,EAAE,CAHoB;AAI3BC,EAAAA,MAAM,EAAE,CAJmB;AAK3BC,EAAAA,MAAM,EAAE,CALmB;AAM3BC,EAAAA,GAAG,EAAE,CANsB;AAO3BC,EAAAA,QAAQ,EAAE,CAPiB;AAQ3BC,EAAAA,YAAY,EAAE,CARa;AAS3BC,EAAAA,YAAY,EAAE,CATa;AAU3BC,EAAAA,UAAU,EAAE,CAVe;AAW3BC,EAAAA,iBAAiB,EAAE;AAXQ,CAAtB,C,CAcP;AACA;;AAGA,OAAO,MAAeC,OAAf,CAAuB;AAoB9B,IAAIC,aAAa,GAAG,CAApB;AACA,OAAO,MAAeC,WAAf,SAEGF,OAFH,CAEW;AAWhBG,EAAAA,WAAW,GAAG;AACZ,YADY,CAGZ;AACA;AACA;AACA;AACA;;AAPY,uCAVM,CAAC,CAUP;;AAAA,wCATM,CAAC,CASP;;AAAA,yCARO,EAQP;;AAAA,oCAPqB,EAOrB;;AAAA,sCANqC;AACjDC,MAAAA,SAAS,EAAE,CAAC,CADqC;AAEjDC,MAAAA,UAAU,EAAE,CAAC,CAFoC;AAGjDC,MAAAA,SAAS,EAAE;AAHsC,KAMrC;;AAQZ,SAAKF,SAAL,GAAiB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,KAAhB;;AAEA,QAAI,KAAKO,MAAL,CAAYI,GAAhB,EAAqB;AACnB,WAAKJ,MAAL,CAAYI,GAAZ,CAAgByB,OAAhB,GAA0B,IAA1B;AACD;AACF;;AAEDC,EAAAA,cAAc,GAAkB;AAC9B,WAAO,CAAC,IAAD,CAAP;AACD,GA5Ke,CA8KhB;;;AACAC,EAAAA,OAAO,GAAG,CAAE;;AAEW,MAAnBC,mBAAmB,GAAY;AACjC;AACA;AACA;AACA,WACE,KAAKhC,MAAL,CAAYoB,OAAZ,KAAwB,IAAxB,IACA,CAAC,KAAKzB,QAAL,CAAcD,SAAd,CAAwBuC,QAAxB,CAAiC,KAAjC,CADD,IAEA,CAAC1D,wBAAwB,EAH3B;AAKD;;AA1Le;AA6LlB,OAAO,MAAe2D,oBAAf,SAGG5C,WAHH,CAG8B;AACnC6C,EAAAA,QAAQ,CAAC9B,QAAD,EAA+D;AACrE,SAAKV,QAAL,CAAcwC,QAAd,GAAyB9B,QAAzB;AACA,SAAKV,QAAL,CAAcD,SAAd,CAAwBlB,aAAa,CAACI,MAAtC,IAAgD,KAAKc,SAAL,CAAeW,QAAf,CAAhD;AACA,WAAO,IAAP;AACD;;AAED+B,EAAAA,QAAQ,CACN/B,QADM,EAIN;AACA,SAAKV,QAAL,CAAcyC,QAAd,GAAyB/B,QAAzB;AACA,SAAKV,QAAL,CAAcD,SAAd,CAAwBlB,aAAa,CAACK,MAAtC,IAAgD,KAAKa,SAAL,CAAeW,QAAf,CAAhD;AACA,WAAO,IAAP;AACD;;AAEDgC,EAAAA,gBAAgB,CAACA,gBAAD,EAA4B;AAC1C,SAAKrC,MAAL,CAAYqC,gBAAZ,GAA+BA,gBAA/B;AACA,WAAO,IAAP;AACD;;AApBkC","sourcesContent":["import { FlingGestureHandlerEventPayload } from '../FlingGestureHandler';\nimport { ForceTouchGestureHandlerEventPayload } from '../ForceTouchGestureHandler';\nimport {\n HitSlop,\n CommonGestureConfig,\n GestureTouchEvent,\n GestureStateChangeEvent,\n GestureUpdateEvent,\n} from '../gestureHandlerCommon';\nimport { getNextHandlerTag } from '../handlersRegistry';\nimport { GestureStateManagerType } from './gestureStateManager';\nimport { LongPressGestureHandlerEventPayload } from '../LongPressGestureHandler';\nimport { PanGestureHandlerEventPayload } from '../PanGestureHandler';\nimport { PinchGestureHandlerEventPayload } from '../PinchGestureHandler';\nimport { RotationGestureHandlerEventPayload } from '../RotationGestureHandler';\nimport { TapGestureHandlerEventPayload } from '../TapGestureHandler';\nimport { NativeViewGestureHandlerPayload } from '../NativeViewGestureHandler';\nimport { isRemoteDebuggingEnabled } from '../../utils';\n\nexport type GestureType =\n | BaseGesture<Record<string, unknown>>\n | BaseGesture<Record<string, never>>\n | BaseGesture<TapGestureHandlerEventPayload>\n | BaseGesture<PanGestureHandlerEventPayload>\n | BaseGesture<LongPressGestureHandlerEventPayload>\n | BaseGesture<RotationGestureHandlerEventPayload>\n | BaseGesture<PinchGestureHandlerEventPayload>\n | BaseGesture<FlingGestureHandlerEventPayload>\n | BaseGesture<ForceTouchGestureHandlerEventPayload>\n | BaseGesture<NativeViewGestureHandlerPayload>;\n\nexport type GestureRef =\n | number\n | GestureType\n | React.RefObject<GestureType | undefined>\n | React.RefObject<React.ComponentType | undefined>; // allow adding a ref to a gesture handler\nexport interface BaseGestureConfig\n extends CommonGestureConfig,\n Record<string, unknown> {\n ref?: React.MutableRefObject<GestureType | undefined>;\n requireToFail?: GestureRef[];\n simultaneousWith?: GestureRef[];\n needsPointerData?: boolean;\n manualActivation?: boolean;\n runOnJS?: boolean;\n testId?: string;\n cancelsTouchesInView?: boolean;\n}\n\ntype TouchEventHandlerType = (\n event: GestureTouchEvent,\n stateManager: GestureStateManagerType\n) => void;\n\nexport type HandlerCallbacks<EventPayloadT extends Record<string, unknown>> = {\n gestureId: number;\n handlerTag: number;\n onBegin?: (event: GestureStateChangeEvent<EventPayloadT>) => void;\n onStart?: (event: GestureStateChangeEvent<EventPayloadT>) => void;\n onEnd?: (\n event: GestureStateChangeEvent<EventPayloadT>,\n success: boolean\n ) => void;\n onFinalize?: (\n event: GestureStateChangeEvent<EventPayloadT>,\n success: boolean\n ) => void;\n onUpdate?: (event: GestureUpdateEvent<EventPayloadT>) => void;\n onChange?: (event: any) => void;\n onTouchesDown?: TouchEventHandlerType;\n onTouchesMove?: TouchEventHandlerType;\n onTouchesUp?: TouchEventHandlerType;\n onTouchesCancelled?: TouchEventHandlerType;\n changeEventCalculator?: (\n current: GestureUpdateEvent<Record<string, unknown>>,\n previous?: GestureUpdateEvent<Record<string, unknown>>\n ) => GestureUpdateEvent<Record<string, unknown>>;\n isWorklet: boolean[];\n};\n\nexport const CALLBACK_TYPE = {\n UNDEFINED: 0,\n BEGAN: 1,\n START: 2,\n UPDATE: 3,\n CHANGE: 4,\n END: 5,\n FINALIZE: 6,\n TOUCHES_DOWN: 7,\n TOUCHES_MOVE: 8,\n TOUCHES_UP: 9,\n TOUCHES_CANCELLED: 10,\n} as const;\n\n// Allow using CALLBACK_TYPE as object and type\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type CALLBACK_TYPE = typeof CALLBACK_TYPE[keyof typeof CALLBACK_TYPE];\n\nexport abstract class Gesture {\n /**\n * Return array of gestures, providing the same interface for creating and updating\n * handlers, no matter which object was used to create gesture instance.\n */\n abstract toGestureArray(): GestureType[];\n\n /**\n * Assign handlerTag to the gesture instance and set ref.current (if a ref is set)\n */\n abstract initialize(): void;\n\n /**\n * Make sure that values of properties defining relations are arrays. Do any necessary\n * preprocessing required to configure relations between handlers. Called just before\n * updating the handler on the native side.\n */\n abstract prepare(): void;\n}\n\nlet nextGestureId = 0;\nexport abstract class BaseGesture<\n EventPayloadT extends Record<string, unknown>\n> extends Gesture {\n private gestureId = -1;\n public handlerTag = -1;\n public handlerName = '';\n public config: BaseGestureConfig = {};\n public handlers: HandlerCallbacks<EventPayloadT> = {\n gestureId: -1,\n handlerTag: -1,\n isWorklet: [],\n };\n\n constructor() {\n super();\n\n // Used to check whether the gesture config has been updated when wrapping it\n // with `useMemo`. Since every config will have a unique id, when the dependencies\n // don't change, the config won't be recreated and the id will stay the same.\n // If the id is different, it means that the config has changed and the gesture\n // needs to be updated.\n this.gestureId = nextGestureId++;\n this.handlers.gestureId = this.gestureId;\n }\n\n private addDependency(\n key: 'simultaneousWith' | 'requireToFail',\n gesture: Exclude<GestureRef, number>\n ) {\n const value = this.config[key];\n this.config[key] = value\n ? Array<GestureRef>().concat(value, gesture)\n : [gesture];\n }\n\n withRef(ref: React.MutableRefObject<GestureType | undefined>) {\n this.config.ref = ref;\n return this;\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-types\n protected isWorklet(callback: Function) {\n //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false\n return callback.__workletHash !== undefined;\n }\n\n onBegin(callback: (event: GestureStateChangeEvent<EventPayloadT>) => void) {\n this.handlers.onBegin = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.BEGAN] = this.isWorklet(callback);\n return this;\n }\n\n onStart(callback: (event: GestureStateChangeEvent<EventPayloadT>) => void) {\n this.handlers.onStart = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.START] = this.isWorklet(callback);\n return this;\n }\n\n onEnd(\n callback: (\n event: GestureStateChangeEvent<EventPayloadT>,\n success: boolean\n ) => void\n ) {\n this.handlers.onEnd = callback;\n //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false\n this.handlers.isWorklet[CALLBACK_TYPE.END] = this.isWorklet(callback);\n return this;\n }\n\n onFinalize(\n callback: (\n event: GestureStateChangeEvent<EventPayloadT>,\n success: boolean\n ) => void\n ) {\n this.handlers.onFinalize = callback;\n //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false\n this.handlers.isWorklet[CALLBACK_TYPE.FINALIZE] = this.isWorklet(callback);\n return this;\n }\n\n onTouchesDown(callback: TouchEventHandlerType) {\n this.config.needsPointerData = true;\n this.handlers.onTouchesDown = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_DOWN] =\n this.isWorklet(callback);\n\n return this;\n }\n\n onTouchesMove(callback: TouchEventHandlerType) {\n this.config.needsPointerData = true;\n this.handlers.onTouchesMove = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_MOVE] =\n this.isWorklet(callback);\n\n return this;\n }\n\n onTouchesUp(callback: TouchEventHandlerType) {\n this.config.needsPointerData = true;\n this.handlers.onTouchesUp = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_UP] =\n this.isWorklet(callback);\n\n return this;\n }\n\n onTouchesCancelled(callback: TouchEventHandlerType) {\n this.config.needsPointerData = true;\n this.handlers.onTouchesCancelled = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_CANCELLED] =\n this.isWorklet(callback);\n\n return this;\n }\n\n enabled(enabled: boolean) {\n this.config.enabled = enabled;\n return this;\n }\n\n shouldCancelWhenOutside(value: boolean) {\n this.config.shouldCancelWhenOutside = value;\n return this;\n }\n\n hitSlop(hitSlop: HitSlop) {\n this.config.hitSlop = hitSlop;\n return this;\n }\n\n runOnJS(runOnJS: boolean) {\n this.config.runOnJS = runOnJS;\n return this;\n }\n\n simultaneousWithExternalGesture(...gestures: Exclude<GestureRef, number>[]) {\n for (const gesture of gestures) {\n this.addDependency('simultaneousWith', gesture);\n }\n return this;\n }\n\n requireExternalGestureToFail(...gestures: Exclude<GestureRef, number>[]) {\n for (const gesture of gestures) {\n this.addDependency('requireToFail', gesture);\n }\n return this;\n }\n\n withTestId(id: string) {\n this.config.testId = id;\n return this;\n }\n\n cancelsTouchesInView(value: boolean) {\n this.config.cancelsTouchesInView = value;\n return this;\n }\n\n initialize() {\n this.handlerTag = getNextHandlerTag();\n\n this.handlers = { ...this.handlers, handlerTag: this.handlerTag };\n\n if (this.config.ref) {\n this.config.ref.current = this as GestureType;\n }\n }\n\n toGestureArray(): GestureType[] {\n return [this as GestureType];\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n prepare() {}\n\n get shouldUseReanimated(): boolean {\n // use Reanimated when runOnJS isn't set explicitly,\n // and all defined callbacks are worklets,\n // and remote debugging is disabled\n return (\n this.config.runOnJS !== true &&\n !this.handlers.isWorklet.includes(false) &&\n !isRemoteDebuggingEnabled()\n );\n }\n}\n\nexport abstract class ContinousBaseGesture<\n EventPayloadT extends Record<string, unknown>,\n EventChangePayloadT extends Record<string, unknown>\n> extends BaseGesture<EventPayloadT> {\n onUpdate(callback: (event: GestureUpdateEvent<EventPayloadT>) => void) {\n this.handlers.onUpdate = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.UPDATE] = this.isWorklet(callback);\n return this;\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<EventPayloadT & EventChangePayloadT>\n ) => void\n ) {\n this.handlers.onChange = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.CHANGE] = this.isWorklet(callback);\n return this;\n }\n\n manualActivation(manualActivation: boolean) {\n this.config.manualActivation = manualActivation;\n return this;\n }\n}\n"]}
@@ -8,6 +8,7 @@ export class LongPressGesture extends BaseGesture {
8
8
  _defineProperty(this, "config", {});
9
9
 
10
10
  this.handlerName = 'LongPressGestureHandler';
11
+ this.shouldCancelWhenOutside(true);
11
12
  }
12
13
 
13
14
  minDuration(duration) {
@@ -1 +1 @@
1
- {"version":3,"sources":["longPressGesture.ts"],"names":["BaseGesture","LongPressGesture","constructor","handlerName","minDuration","duration","config","minDurationMs","maxDistance","distance","maxDist"],"mappings":";;AAAA,SAASA,WAAT,QAA+C,WAA/C;AAMA,OAAO,MAAMC,gBAAN,SAA+BD,WAA/B,CAAgF;AAGrFE,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAF8C,EAE9C;;AAGZ,SAAKC,WAAL,GAAmB,yBAAnB;AACD;;AAEDC,EAAAA,WAAW,CAACC,QAAD,EAAmB;AAC5B,SAAKC,MAAL,CAAYC,aAAZ,GAA4BF,QAA5B;AACA,WAAO,IAAP;AACD;;AAEDG,EAAAA,WAAW,CAACC,QAAD,EAAmB;AAC5B,SAAKH,MAAL,CAAYI,OAAZ,GAAsBD,QAAtB;AACA,WAAO,IAAP;AACD;;AAjBoF","sourcesContent":["import { BaseGesture, BaseGestureConfig } from './gesture';\nimport {\n LongPressGestureConfig,\n LongPressGestureHandlerEventPayload,\n} from '../LongPressGestureHandler';\n\nexport class LongPressGesture extends BaseGesture<LongPressGestureHandlerEventPayload> {\n public config: BaseGestureConfig & LongPressGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'LongPressGestureHandler';\n }\n\n minDuration(duration: number) {\n this.config.minDurationMs = duration;\n return this;\n }\n\n maxDistance(distance: number) {\n this.config.maxDist = distance;\n return this;\n }\n}\n\nexport type LongPressGestureType = InstanceType<typeof LongPressGesture>;\n"]}
1
+ {"version":3,"sources":["longPressGesture.ts"],"names":["BaseGesture","LongPressGesture","constructor","handlerName","shouldCancelWhenOutside","minDuration","duration","config","minDurationMs","maxDistance","distance","maxDist"],"mappings":";;AAAA,SAASA,WAAT,QAA+C,WAA/C;AAMA,OAAO,MAAMC,gBAAN,SAA+BD,WAA/B,CAAgF;AAGrFE,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAF8C,EAE9C;;AAGZ,SAAKC,WAAL,GAAmB,yBAAnB;AACA,SAAKC,uBAAL,CAA6B,IAA7B;AACD;;AAEDC,EAAAA,WAAW,CAACC,QAAD,EAAmB;AAC5B,SAAKC,MAAL,CAAYC,aAAZ,GAA4BF,QAA5B;AACA,WAAO,IAAP;AACD;;AAEDG,EAAAA,WAAW,CAACC,QAAD,EAAmB;AAC5B,SAAKH,MAAL,CAAYI,OAAZ,GAAsBD,QAAtB;AACA,WAAO,IAAP;AACD;;AAlBoF","sourcesContent":["import { BaseGesture, BaseGestureConfig } from './gesture';\nimport {\n LongPressGestureConfig,\n LongPressGestureHandlerEventPayload,\n} from '../LongPressGestureHandler';\n\nexport class LongPressGesture extends BaseGesture<LongPressGestureHandlerEventPayload> {\n public config: BaseGestureConfig & LongPressGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'LongPressGestureHandler';\n this.shouldCancelWhenOutside(true);\n }\n\n minDuration(duration: number) {\n this.config.minDurationMs = duration;\n return this;\n }\n\n maxDistance(distance: number) {\n this.config.maxDist = distance;\n return this;\n }\n}\n\nexport type LongPressGestureType = InstanceType<typeof LongPressGesture>;\n"]}
@@ -8,6 +8,7 @@ export class TapGesture extends BaseGesture {
8
8
  _defineProperty(this, "config", {});
9
9
 
10
10
  this.handlerName = 'TapGestureHandler';
11
+ this.shouldCancelWhenOutside(true);
11
12
  }
12
13
 
13
14
  minPointers(minPointers) {