react-native-gesture-handler 2.18.1 → 2.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (210) hide show
  1. package/README.md +1 -0
  2. package/android/build.gradle +11 -29
  3. package/android/fabric/src/main/java/com/swmansion/gesturehandler/ReactContextExtensions.kt +1 -1
  4. package/android/paper/src/main/java/com/swmansion/gesturehandler/ReactContextExtensions.kt +1 -1
  5. package/android/src/main/AndroidManifest.xml +1 -3
  6. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +21 -21
  7. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +2 -2
  8. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureUtils.kt +1 -0
  9. package/android/src/main/java/com/swmansion/gesturehandler/core/HoverGestureHandler.kt +16 -0
  10. package/android/src/main/java/com/swmansion/gesturehandler/core/LongPressGestureHandler.kt +80 -4
  11. package/android/src/main/java/com/swmansion/gesturehandler/core/PanGestureHandler.kt +8 -0
  12. package/android/src/main/java/com/swmansion/gesturehandler/core/PinchGestureHandler.kt +2 -1
  13. package/android/src/main/java/com/swmansion/gesturehandler/core/ScaleGestureDetector.java +10 -0
  14. package/android/src/main/java/com/swmansion/gesturehandler/core/StylusData.kt +103 -0
  15. package/android/src/main/java/com/swmansion/gesturehandler/core/Vector.kt +2 -2
  16. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +24 -15
  17. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +3 -0
  18. package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/HoverGestureHandlerEventDataBuilder.kt +7 -0
  19. package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/PanGestureHandlerEventDataBuilder.kt +7 -0
  20. package/android/src/main/jni/CMakeLists.txt +18 -9
  21. package/apple/Handlers/RNFlingHandler.h +1 -0
  22. package/apple/Handlers/RNFlingHandler.m +153 -19
  23. package/apple/Handlers/RNHoverHandler.m +44 -2
  24. package/apple/Handlers/RNLongPressHandler.m +111 -20
  25. package/apple/Handlers/RNManualHandler.m +53 -29
  26. package/apple/Handlers/RNNativeViewHandler.mm +22 -15
  27. package/apple/Handlers/RNPanHandler.m +57 -7
  28. package/apple/Handlers/RNRotationHandler.m +1 -1
  29. package/apple/RNGHStylusData.h +77 -0
  30. package/apple/RNGHStylusData.m +37 -0
  31. package/apple/RNGHUIKit.h +2 -0
  32. package/apple/RNGHVector.h +31 -0
  33. package/apple/RNGHVector.m +67 -0
  34. package/apple/RNGestureHandler.h +7 -0
  35. package/apple/{RNGestureHandler.m → RNGestureHandler.mm} +63 -1
  36. package/apple/RNGestureHandlerButtonComponentView.mm +41 -0
  37. package/apple/RNGestureHandlerDirection.h +25 -0
  38. package/apple/RNGestureHandlerEvents.h +3 -1
  39. package/apple/RNGestureHandlerEvents.m +11 -3
  40. package/lib/commonjs/PointerType.js +2 -1
  41. package/lib/commonjs/PointerType.js.map +1 -1
  42. package/lib/commonjs/components/GestureButtons.js +5 -1
  43. package/lib/commonjs/components/GestureButtons.js.map +1 -1
  44. package/lib/commonjs/components/GestureComponents.js.map +1 -1
  45. package/lib/commonjs/components/Pressable/Pressable.js +66 -78
  46. package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
  47. package/lib/commonjs/components/Pressable/index.js +0 -8
  48. package/lib/commonjs/components/Pressable/index.js.map +1 -1
  49. package/lib/commonjs/components/Pressable/utils.js +1 -23
  50. package/lib/commonjs/components/Pressable/utils.js.map +1 -1
  51. package/lib/commonjs/components/ReanimatedSwipeable.js +60 -41
  52. package/lib/commonjs/components/ReanimatedSwipeable.js.map +1 -1
  53. package/lib/commonjs/handlers/GestureHandlerEventPayload.js +4 -0
  54. package/lib/commonjs/handlers/LongPressGestureHandler.js +1 -1
  55. package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -1
  56. package/lib/commonjs/handlers/createHandler.js +2 -1
  57. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  58. package/lib/commonjs/handlers/gestures/GestureDetector/utils.js +1 -1
  59. package/lib/commonjs/handlers/gestures/GestureDetector/utils.js.map +1 -1
  60. package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
  61. package/lib/commonjs/handlers/gestures/hoverGesture.js.map +1 -1
  62. package/lib/commonjs/handlers/gestures/longPressGesture.js +10 -0
  63. package/lib/commonjs/handlers/gestures/longPressGesture.js.map +1 -1
  64. package/lib/commonjs/jestUtils/jestUtils.js +12 -4
  65. package/lib/commonjs/jestUtils/jestUtils.js.map +1 -1
  66. package/lib/commonjs/mocks.js +16 -3
  67. package/lib/commonjs/mocks.js.map +1 -1
  68. package/lib/commonjs/utils.js +4 -0
  69. package/lib/commonjs/utils.js.map +1 -1
  70. package/lib/commonjs/web/constants.js +3 -3
  71. package/lib/commonjs/web/constants.js.map +1 -1
  72. package/lib/commonjs/web/handlers/GestureHandler.js +2 -3
  73. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  74. package/lib/commonjs/web/handlers/HoverGestureHandler.js +18 -1
  75. package/lib/commonjs/web/handlers/HoverGestureHandler.js.map +1 -1
  76. package/lib/commonjs/web/handlers/LongPressGestureHandler.js +43 -9
  77. package/lib/commonjs/web/handlers/LongPressGestureHandler.js.map +1 -1
  78. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +14 -3
  79. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
  80. package/lib/commonjs/web/handlers/PanGestureHandler.js +12 -1
  81. package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
  82. package/lib/commonjs/web/interfaces.js.map +1 -1
  83. package/lib/commonjs/web/tools/EventManager.js.map +1 -1
  84. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +55 -11
  85. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  86. package/lib/commonjs/web/tools/KeyboardEventManager.js +110 -0
  87. package/lib/commonjs/web/tools/KeyboardEventManager.js.map +1 -0
  88. package/lib/commonjs/web/tools/PointerEventManager.js +3 -37
  89. package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
  90. package/lib/commonjs/web/tools/Vector.js +4 -2
  91. package/lib/commonjs/web/tools/Vector.js.map +1 -1
  92. package/lib/commonjs/web/utils.js +187 -13
  93. package/lib/commonjs/web/utils.js.map +1 -1
  94. package/lib/module/PointerType.js +2 -1
  95. package/lib/module/PointerType.js.map +1 -1
  96. package/lib/module/components/GestureButtons.js +5 -1
  97. package/lib/module/components/GestureButtons.js.map +1 -1
  98. package/lib/module/components/GestureComponents.js.map +1 -1
  99. package/lib/module/components/Pressable/Pressable.js +67 -78
  100. package/lib/module/components/Pressable/Pressable.js.map +1 -1
  101. package/lib/module/components/Pressable/index.js +0 -1
  102. package/lib/module/components/Pressable/index.js.map +1 -1
  103. package/lib/module/components/Pressable/utils.js +1 -22
  104. package/lib/module/components/Pressable/utils.js.map +1 -1
  105. package/lib/module/components/ReanimatedSwipeable.js +58 -37
  106. package/lib/module/components/ReanimatedSwipeable.js.map +1 -1
  107. package/lib/module/handlers/GestureHandlerEventPayload.js +1 -1
  108. package/lib/module/handlers/LongPressGestureHandler.js +1 -1
  109. package/lib/module/handlers/LongPressGestureHandler.js.map +1 -1
  110. package/lib/module/handlers/createHandler.js +2 -1
  111. package/lib/module/handlers/createHandler.js.map +1 -1
  112. package/lib/module/handlers/gestures/GestureDetector/utils.js +2 -2
  113. package/lib/module/handlers/gestures/GestureDetector/utils.js.map +1 -1
  114. package/lib/module/handlers/gestures/gesture.js.map +1 -1
  115. package/lib/module/handlers/gestures/hoverGesture.js.map +1 -1
  116. package/lib/module/handlers/gestures/longPressGesture.js +10 -0
  117. package/lib/module/handlers/gestures/longPressGesture.js.map +1 -1
  118. package/lib/module/jestUtils/jestUtils.js +12 -4
  119. package/lib/module/jestUtils/jestUtils.js.map +1 -1
  120. package/lib/module/mocks.js +13 -3
  121. package/lib/module/mocks.js.map +1 -1
  122. package/lib/module/utils.js +1 -0
  123. package/lib/module/utils.js.map +1 -1
  124. package/lib/module/web/constants.js +1 -1
  125. package/lib/module/web/constants.js.map +1 -1
  126. package/lib/module/web/handlers/GestureHandler.js +2 -3
  127. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  128. package/lib/module/web/handlers/HoverGestureHandler.js +18 -1
  129. package/lib/module/web/handlers/HoverGestureHandler.js.map +1 -1
  130. package/lib/module/web/handlers/LongPressGestureHandler.js +43 -9
  131. package/lib/module/web/handlers/LongPressGestureHandler.js.map +1 -1
  132. package/lib/module/web/handlers/NativeViewGestureHandler.js +14 -3
  133. package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
  134. package/lib/module/web/handlers/PanGestureHandler.js +12 -1
  135. package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
  136. package/lib/module/web/interfaces.js.map +1 -1
  137. package/lib/module/web/tools/EventManager.js.map +1 -1
  138. package/lib/module/web/tools/GestureHandlerWebDelegate.js +54 -10
  139. package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  140. package/lib/module/web/tools/KeyboardEventManager.js +96 -0
  141. package/lib/module/web/tools/KeyboardEventManager.js.map +1 -0
  142. package/lib/module/web/tools/PointerEventManager.js +4 -38
  143. package/lib/module/web/tools/PointerEventManager.js.map +1 -1
  144. package/lib/module/web/tools/Vector.js +5 -3
  145. package/lib/module/web/tools/Vector.js.map +1 -1
  146. package/lib/module/web/utils.js +184 -13
  147. package/lib/module/web/utils.js.map +1 -1
  148. package/lib/typescript/PointerType.d.ts +2 -1
  149. package/lib/typescript/components/GestureComponents.d.ts +1 -1
  150. package/lib/typescript/components/Pressable/index.d.ts +1 -1
  151. package/lib/typescript/components/Pressable/utils.d.ts +3 -5
  152. package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts +35 -0
  153. package/lib/typescript/handlers/LongPressGestureHandler.d.ts +5 -1
  154. package/lib/typescript/handlers/gestures/gesture.d.ts +2 -2
  155. package/lib/typescript/handlers/gestures/hoverGesture.d.ts +1 -6
  156. package/lib/typescript/handlers/gestures/longPressGesture.d.ts +5 -0
  157. package/lib/typescript/handlers/handlersRegistry.d.ts +1 -1
  158. package/lib/typescript/jestUtils/jestUtils.d.ts +1 -1
  159. package/lib/typescript/mocks.d.ts +4 -3
  160. package/lib/typescript/utils.d.ts +1 -0
  161. package/lib/typescript/web/constants.d.ts +1 -1
  162. package/lib/typescript/web/handlers/GestureHandler.d.ts +1 -1
  163. package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +2 -0
  164. package/lib/typescript/web/handlers/LongPressGestureHandler.d.ts +3 -0
  165. package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +1 -0
  166. package/lib/typescript/web/handlers/PanGestureHandler.d.ts +3 -1
  167. package/lib/typescript/web/interfaces.d.ts +9 -4
  168. package/lib/typescript/web/tools/EventManager.d.ts +2 -2
  169. package/lib/typescript/web/tools/GestureHandlerDelegate.d.ts +1 -0
  170. package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts +6 -0
  171. package/lib/typescript/web/tools/KeyboardEventManager.d.ts +13 -0
  172. package/lib/typescript/web/utils.d.ts +2 -1
  173. package/package.json +3 -3
  174. package/src/PointerType.ts +1 -0
  175. package/src/components/GestureButtons.tsx +2 -1
  176. package/src/components/GestureComponents.tsx +1 -1
  177. package/src/components/Pressable/Pressable.tsx +77 -70
  178. package/src/components/Pressable/index.ts +1 -1
  179. package/src/components/Pressable/utils.ts +5 -49
  180. package/src/components/ReanimatedSwipeable.tsx +70 -47
  181. package/src/handlers/GestureHandlerEventPayload.ts +42 -0
  182. package/src/handlers/LongPressGestureHandler.ts +6 -0
  183. package/src/handlers/createHandler.tsx +1 -0
  184. package/src/handlers/gestures/GestureDetector/utils.ts +2 -2
  185. package/src/handlers/gestures/gesture.ts +3 -1
  186. package/src/handlers/gestures/hoverGesture.ts +1 -7
  187. package/src/handlers/gestures/longPressGesture.ts +9 -0
  188. package/src/jestUtils/jestUtils.ts +9 -1
  189. package/src/{mocks.ts → mocks.tsx} +8 -3
  190. package/src/utils.ts +2 -0
  191. package/src/web/constants.ts +1 -1
  192. package/src/web/handlers/GestureHandler.ts +4 -2
  193. package/src/web/handlers/HoverGestureHandler.ts +16 -2
  194. package/src/web/handlers/LongPressGestureHandler.ts +49 -10
  195. package/src/web/handlers/NativeViewGestureHandler.ts +14 -4
  196. package/src/web/handlers/PanGestureHandler.ts +14 -1
  197. package/src/web/interfaces.ts +10 -4
  198. package/src/web/tools/EventManager.ts +2 -4
  199. package/src/web/tools/GestureHandlerDelegate.ts +1 -0
  200. package/src/web/tools/GestureHandlerWebDelegate.ts +67 -10
  201. package/src/web/tools/KeyboardEventManager.ts +91 -0
  202. package/src/web/tools/PointerEventManager.ts +2 -38
  203. package/src/web/tools/Vector.ts +4 -3
  204. package/src/web/utils.ts +188 -13
  205. package/lib/commonjs/web/tools/TouchEventManager.js +0 -164
  206. package/lib/commonjs/web/tools/TouchEventManager.js.map +0 -1
  207. package/lib/module/web/tools/TouchEventManager.js +0 -149
  208. package/lib/module/web/tools/TouchEventManager.js.map +0 -1
  209. package/lib/typescript/web/tools/TouchEventManager.d.ts +0 -11
  210. package/src/web/tools/TouchEventManager.ts +0 -175
@@ -1 +1 @@
1
- {"version":3,"sources":["utils.ts"],"names":["Platform","tagMessage","BaseGesture","flingGestureHandlerProps","forceTouchGestureHandlerProps","longPressGestureHandlerProps","panGestureHandlerProps","panGestureHandlerCustomNativeProps","tapGestureHandlerProps","hoverGestureHandlerProps","nativeViewGestureHandlerProps","baseGestureHandlerWithDetectorProps","isNewWebImplementationEnabled","getReactNativeVersion","RNRenderer","useCallback","useRef","useState","Reanimated","onGestureHandlerEvent","ALLOWED_PROPS","convertToHandlerTag","ref","handlerTag","current","extractValidHandlerTags","interactionGroup","map","filter","tag","extractGestureRelations","gesture","requireToFail","config","simultaneousWith","blocksHandlers","waitFor","simultaneousHandlers","checkGestureCallbacksForWorklets","__DEV__","runOnJS","areSomeNotWorklets","handlers","isWorklet","includes","areSomeWorklets","console","error","undefined","areAllNotWorklets","warn","validateDetectorChildren","OS","REACT_NATIVE_VERSION","wrapType","minor","major","_reactInternals","elementType","_reactInternalFiber","instance","findHostInstance_DEPRECATED","_internalFiberInstanceHandleDEV","sibling","Error","return","useForceRender","renderState","setRenderState","forceRender","useWebEventHandlers","e","nativeEvent","onGestureHandlerStateChange"],"mappings":"AAAA,SAASA,QAAT,QAAyB,cAAzB;AAEA,SAASC,UAAT,QAA2B,gBAA3B;AACA,SAAqBC,WAArB,QAAqD,YAArD;AAEA,SAASC,wBAAT,QAAyC,2BAAzC;AACA,SAASC,6BAAT,QAA8C,gCAA9C;AACA,SAASC,4BAAT,QAA6C,+BAA7C;AACA,SACEC,sBADF,EAEEC,kCAFF,QAGO,yBAHP;AAIA,SAASC,sBAAT,QAAuC,yBAAvC;AACA,SAASC,wBAAT,QAAyC,iBAAzC;AACA,SAASC,6BAAT,QAA8C,gCAA9C;AACA,SAEEC,mCAFF,QAGO,4BAHP;AAIA,SAASC,6BAAT,QAA8C,qCAA9C;AACA,SAASC,qBAAT,QAAsC,gCAAtC;AACA,SAASC,UAAT,QAA2B,qBAA3B;AACA,SAASC,WAAT,EAAsBC,MAAtB,EAA8BC,QAA9B,QAA8C,OAA9C;AACA,SAASC,UAAT,QAA2B,sBAA3B;AACA,SAASC,qBAAT,QAAsC,kBAAtC;AAGA,OAAO,MAAMC,aAAa,GAAG,CAC3B,GAAGT,mCADwB,EAE3B,GAAGH,sBAFwB,EAG3B,GAAGF,sBAHwB,EAI3B,GAAGC,kCAJwB,EAK3B,GAAGF,4BALwB,EAM3B,GAAGD,6BANwB,EAO3B,GAAGD,wBAPwB,EAQ3B,GAAGM,wBARwB,EAS3B,GAAGC,6BATwB,CAAtB;;AAYP,SAASW,mBAAT,CAA6BC,GAA7B,EAAsD;AACpD,MAAI,OAAOA,GAAP,KAAe,QAAnB,EAA6B;AAC3B,WAAOA,GAAP;AACD,GAFD,MAEO,IAAIA,GAAG,YAAYpB,WAAnB,EAAgC;AACrC,WAAOoB,GAAG,CAACC,U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CAA9C;AACA,QAAMoD,WAAW,GAAGtD,WAAW,CAAC,MAAM;AACpCqD,IAAAA,cAAc,CAAC,CAACD,WAAF,CAAd;AACD,GAF8B,EAE5B,CAACA,WAAD,EAAcC,cAAd,CAF4B,CAA/B;AAIA,SAAOC,WAAP;AACD;AAED,OAAO,SAASC,mBAAT,GAA+B;AACpC,SAAOtD,MAAM,CAAkB;AAC7BG,IAAAA,qBAAqB,EAAGoD,CAAD,IAAyC;AAC9DpD,MAAAA,qBAAqB,CAACoD,CAAC,CAACC,WAAH,CAArB;AACD,KAH4B;AAI7BC,IAAAA,2BAA2B,EAAE7D,6BAA6B,KACrD2D,CAAD,IAAyC;AACvCpD,MAAAA,qBAAqB,CAACoD,CAAC,CAACC,WAAH,CAArB;AACD,KAHqD,GAItDxB;AARyB,GAAlB,CAAb;AAUD","sourcesContent":["import { Platform } from 'react-native';\n\nimport { tagMessage } from '../../../utils';\nimport { GestureRef, BaseGesture, GestureType } from '../gesture';\n\nimport { flingGestureHandlerProps } from '../../FlingGestureHandler';\nimport { forceTouchGestureHandlerProps } from '../../ForceTouchGestureHandler';\nimport { longPressGestureHandlerProps } from '../../LongPressGestureHandler';\nimport {\n panGestureHandlerProps,\n panGestureHandlerCustomNativeProps,\n} from '../../PanGestureHandler';\nimport { tapGestureHandlerProps } from '../../TapGestureHandler';\nimport { hoverGestureHandlerProps } from '../hoverGesture';\nimport { nativeViewGestureHandlerProps } from '../../NativeViewGestureHandler';\nimport {\n HandlerStateChangeEvent,\n baseGestureHandlerWithDetectorProps,\n} from '../../gestureHandlerCommon';\nimport { isNewWebImplementationEnabled } from '../../../EnableNewWebImplementation';\nimport { getReactNativeVersion } from '../../../getReactNativeVersion';\nimport { RNRenderer } from '../../../RNRenderer';\nimport { useCallback, useRef, useState } from 'react';\nimport { Reanimated } from '../reanimatedWrapper';\nimport { onGestureHandlerEvent } from '../eventReceiver';\nimport { WebEventHandler } from './types';\n\nexport const ALLOWED_PROPS = [\n ...baseGestureHandlerWithDetectorProps,\n ...tapGestureHandlerProps,\n ...panGestureHandlerProps,\n ...panGestureHandlerCustomNativeProps,\n ...longPressGestureHandlerProps,\n ...forceTouchGestureHandlerProps,\n ...flingGestureHandlerProps,\n ...hoverGestureHandlerProps,\n ...nativeViewGestureHandlerProps,\n];\n\nfunction convertToHandlerTag(ref: GestureRef): number {\n if (typeof ref === 'number') {\n return ref;\n } else if (ref instanceof BaseGesture) {\n return ref.handlerTag;\n } else {\n // @ts-ignore in this case it should be a ref either to gesture object or\n // a gesture handler component, in both cases handlerTag property exists\n return ref.current?.handlerTag ?? -1;\n }\n}\n\nfunction extractValidHandlerTags(interactionGroup: GestureRef[] | undefined) {\n return (\n interactionGroup?.map(convertToHandlerTag)?.filter((tag) => tag > 0) ?? []\n );\n}\n\nexport function extractGestureRelations(gesture: GestureType) {\n const requireToFail = extractValidHandlerTags(gesture.config.requireToFail);\n const simultaneousWith = extractValidHandlerTags(\n gesture.config.simultaneousWith\n );\n const blocksHandlers = extractValidHandlerTags(gesture.config.blocksHandlers);\n\n return {\n waitFor: requireToFail,\n simultaneousHandlers: simultaneousWith,\n blocksHandlers: blocksHandlers,\n };\n}\n\nexport function checkGestureCallbacksForWorklets(gesture: GestureType) {\n if (!__DEV__) {\n return;\n }\n // If a gesture is explicitly marked to run on the JS thread there is no need to check\n // if callbacks are worklets as the user is aware they will be ran on the JS thread\n if (gesture.config.runOnJS) {\n return;\n }\n\n const areSomeNotWorklets = gesture.handlers.isWorklet.includes(false);\n const areSomeWorklets = gesture.handlers.isWorklet.includes(true);\n\n // If some of the callbacks are worklets and some are not, and the gesture is not\n // explicitly marked with `.runOnJS(true)` show an error\n if (areSomeNotWorklets && areSomeWorklets) {\n console.error(\n tagMessage(\n `Some of the callbacks in the gesture are worklets and some are not. Either make sure that all calbacks are marked as 'worklet' if you wish to run them on the UI thread or use '.runOnJS(true)' modifier on the gesture explicitly to run all callbacks on the JS thread.`\n )\n );\n }\n\n if (Reanimated === undefined) {\n // If Reanimated is not available, we can't run worklets, so we shouldn't show the warning\n return;\n }\n\n const areAllNotWorklets = !areSomeWorklets && areSomeNotWorklets;\n // If none of the callbacks are worklets and the gesture is not explicitly marked with\n // `.runOnJS(true)` show a warning\n if (areAllNotWorklets) {\n console.warn(\n tagMessage(\n `None of the callbacks in the gesture are worklets. If you wish to run them on the JS thread use '.runOnJS(true)' modifier on the gesture to make this explicit. Otherwise, mark the callbacks as 'worklet' to run them on the UI thread.`\n )\n );\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function validateDetectorChildren(ref: any) {\n // Finds the first native view under the Wrap component and traverses the fiber tree upwards\n // to check whether there is more than one native view as a pseudo-direct child of GestureDetector\n // i.e. this is not ok:\n // Wrap\n // |\n // / \\\n // / \\\n // / \\\n // / \\\n // NativeView NativeView\n //\n // but this is fine:\n // Wrap\n // |\n // NativeView\n // |\n // / \\\n // / \\\n // / \\\n // / \\\n // NativeView NativeView\n if (__DEV__ && Platform.OS !== 'web') {\n const REACT_NATIVE_VERSION = getReactNativeVersion();\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const wrapType =\n REACT_NATIVE_VERSION.minor > 63 || REACT_NATIVE_VERSION.major > 0\n ? // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ref._reactInternals.elementType\n : // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ref._reactInternalFiber.elementType;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n let instance =\n RNRenderer.findHostInstance_DEPRECATED(\n ref\n )._internalFiberInstanceHandleDEV;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n while (instance && instance.elementType !== wrapType) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (instance.sibling) {\n throw new Error(\n 'GestureDetector has more than one native view as its children. This can happen if you are using a custom component that renders multiple views, like React.Fragment. You should wrap content of GestureDetector with a <View> or <Animated.View>.'\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n instance = instance.return;\n }\n }\n}\n\nexport function useForceRender() {\n const [renderState, setRenderState] = useState(false);\n const forceRender = useCallback(() => {\n setRenderState(!renderState);\n }, [renderState, setRenderState]);\n\n return forceRender;\n}\n\nexport function useWebEventHandlers() {\n return useRef<WebEventHandler>({\n onGestureHandlerEvent: (e: HandlerStateChangeEvent<unknown>) => {\n onGestureHandlerEvent(e.nativeEvent);\n },\n onGestureHandlerStateChange: isNewWebImplementationEnabled()\n ? (e: HandlerStateChangeEvent<unknown>) => {\n onGestureHandlerEvent(e.nativeEvent);\n }\n : undefined,\n });\n}\n"]}
1
+ {"version":3,"sources":["utils.ts"],"names":["Platform","isJestEnv","tagMessage","BaseGesture","flingGestureHandlerProps","forceTouchGestureHandlerProps","longPressGestureHandlerProps","panGestureHandlerProps","panGestureHandlerCustomNativeProps","tapGestureHandlerProps","hoverGestureHandlerProps","nativeViewGestureHandlerProps","baseGestureHandlerWithDetectorProps","isNewWebImplementationEnabled","getReactNativeVersion","RNRenderer","useCallback","useRef","useState","Reanimated","onGestureHandlerEvent","ALLOWED_PROPS","convertToHandlerTag","ref","handlerTag","current","extractValidHandlerTags","interactionGroup","map","filter","tag","extractGestureRelations","gesture","requireToFail","config","simultaneousWith","blocksHandlers","waitFor","simultaneousHandlers","checkGestureCallbacksForWorklets","__DEV__","runOnJS","areSomeNotWorklets","handlers","isWorklet","includes","areSomeWorklets","console","error","undefined","areAllNotWorklets","warn","validateDetectorChildren","OS","REACT_NATIVE_VERSION","wrapType","minor","major","_reactInternals","elementType","_reactInternalFiber","instance","findHostInstance_DEPRECATED","_internalFiberInstanceHandleDEV","sibling","Error","return","useForceRender","renderState","setRenderState","forceRender","useWebEventHandlers","e","nativeEvent","onGestureHandlerStateChange"],"mappings":"AAAA,SAASA,QAAT,QAAyB,cAAzB;AAEA,SAASC,SAAT,EAAoBC,UAApB,QAAsC,gBAAtC;AACA,SAAqBC,WAArB,QAAqD,YAArD;A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EAAGoD,CAAD,IAAyC;AAC9DpD,MAAAA,qBAAqB,CAACoD,CAAC,CAACC,WAAH,CAArB;AACD,KAH4B;AAI7BC,IAAAA,2BAA2B,EAAE7D,6BAA6B,KACrD2D,CAAD,IAAyC;AACvCpD,MAAAA,qBAAqB,CAACoD,CAAC,CAACC,WAAH,CAArB;AACD,KAHqD,GAItDxB;AARyB,GAAlB,CAAb;AAUD","sourcesContent":["import { Platform } from 'react-native';\n\nimport { isJestEnv, tagMessage } from '../../../utils';\nimport { GestureRef, BaseGesture, GestureType } from '../gesture';\n\nimport { flingGestureHandlerProps } from '../../FlingGestureHandler';\nimport { forceTouchGestureHandlerProps } from '../../ForceTouchGestureHandler';\nimport { longPressGestureHandlerProps } from '../../LongPressGestureHandler';\nimport {\n panGestureHandlerProps,\n panGestureHandlerCustomNativeProps,\n} from '../../PanGestureHandler';\nimport { tapGestureHandlerProps } from '../../TapGestureHandler';\nimport { hoverGestureHandlerProps } from '../hoverGesture';\nimport { nativeViewGestureHandlerProps } from '../../NativeViewGestureHandler';\nimport {\n HandlerStateChangeEvent,\n baseGestureHandlerWithDetectorProps,\n} from '../../gestureHandlerCommon';\nimport { isNewWebImplementationEnabled } from '../../../EnableNewWebImplementation';\nimport { getReactNativeVersion } from '../../../getReactNativeVersion';\nimport { RNRenderer } from '../../../RNRenderer';\nimport { useCallback, useRef, useState } from 'react';\nimport { Reanimated } from '../reanimatedWrapper';\nimport { onGestureHandlerEvent } from '../eventReceiver';\nimport { WebEventHandler } from './types';\n\nexport const ALLOWED_PROPS = [\n ...baseGestureHandlerWithDetectorProps,\n ...tapGestureHandlerProps,\n ...panGestureHandlerProps,\n ...panGestureHandlerCustomNativeProps,\n ...longPressGestureHandlerProps,\n ...forceTouchGestureHandlerProps,\n ...flingGestureHandlerProps,\n ...hoverGestureHandlerProps,\n ...nativeViewGestureHandlerProps,\n];\n\nfunction convertToHandlerTag(ref: GestureRef): number {\n if (typeof ref === 'number') {\n return ref;\n } else if (ref instanceof BaseGesture) {\n return ref.handlerTag;\n } else {\n // @ts-ignore in this case it should be a ref either to gesture object or\n // a gesture handler component, in both cases handlerTag property exists\n return ref.current?.handlerTag ?? -1;\n }\n}\n\nfunction extractValidHandlerTags(interactionGroup: GestureRef[] | undefined) {\n return (\n interactionGroup?.map(convertToHandlerTag)?.filter((tag) => tag > 0) ?? []\n );\n}\n\nexport function extractGestureRelations(gesture: GestureType) {\n const requireToFail = extractValidHandlerTags(gesture.config.requireToFail);\n const simultaneousWith = extractValidHandlerTags(\n gesture.config.simultaneousWith\n );\n const blocksHandlers = extractValidHandlerTags(gesture.config.blocksHandlers);\n\n return {\n waitFor: requireToFail,\n simultaneousHandlers: simultaneousWith,\n blocksHandlers: blocksHandlers,\n };\n}\n\nexport function checkGestureCallbacksForWorklets(gesture: GestureType) {\n if (!__DEV__) {\n return;\n }\n // If a gesture is explicitly marked to run on the JS thread there is no need to check\n // if callbacks are worklets as the user is aware they will be ran on the JS thread\n if (gesture.config.runOnJS) {\n return;\n }\n\n const areSomeNotWorklets = gesture.handlers.isWorklet.includes(false);\n const areSomeWorklets = gesture.handlers.isWorklet.includes(true);\n\n // If some of the callbacks are worklets and some are not, and the gesture is not\n // explicitly marked with `.runOnJS(true)` show an error\n if (areSomeNotWorklets && areSomeWorklets) {\n console.error(\n tagMessage(\n `Some of the callbacks in the gesture are worklets and some are not. Either make sure that all calbacks are marked as 'worklet' if you wish to run them on the UI thread or use '.runOnJS(true)' modifier on the gesture explicitly to run all callbacks on the JS thread.`\n )\n );\n }\n\n if (Reanimated === undefined) {\n // If Reanimated is not available, we can't run worklets, so we shouldn't show the warning\n return;\n }\n\n const areAllNotWorklets = !areSomeWorklets && areSomeNotWorklets;\n // If none of the callbacks are worklets and the gesture is not explicitly marked with\n // `.runOnJS(true)` show a warning\n if (areAllNotWorklets && !isJestEnv()) {\n console.warn(\n tagMessage(\n `None of the callbacks in the gesture are worklets. If you wish to run them on the JS thread use '.runOnJS(true)' modifier on the gesture to make this explicit. Otherwise, mark the callbacks as 'worklet' to run them on the UI thread.`\n )\n );\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function validateDetectorChildren(ref: any) {\n // Finds the first native view under the Wrap component and traverses the fiber tree upwards\n // to check whether there is more than one native view as a pseudo-direct child of GestureDetector\n // i.e. this is not ok:\n // Wrap\n // |\n // / \\\n // / \\\n // / \\\n // / \\\n // NativeView NativeView\n //\n // but this is fine:\n // Wrap\n // |\n // NativeView\n // |\n // / \\\n // / \\\n // / \\\n // / \\\n // NativeView NativeView\n if (__DEV__ && Platform.OS !== 'web') {\n const REACT_NATIVE_VERSION = getReactNativeVersion();\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const wrapType =\n REACT_NATIVE_VERSION.minor > 63 || REACT_NATIVE_VERSION.major > 0\n ? // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ref._reactInternals.elementType\n : // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ref._reactInternalFiber.elementType;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n let instance =\n RNRenderer.findHostInstance_DEPRECATED(\n ref\n )._internalFiberInstanceHandleDEV;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n while (instance && instance.elementType !== wrapType) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (instance.sibling) {\n throw new Error(\n 'GestureDetector has more than one native view as its children. This can happen if you are using a custom component that renders multiple views, like React.Fragment. You should wrap content of GestureDetector with a <View> or <Animated.View>.'\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n instance = instance.return;\n }\n }\n}\n\nexport function useForceRender() {\n const [renderState, setRenderState] = useState(false);\n const forceRender = useCallback(() => {\n setRenderState(!renderState);\n }, [renderState, setRenderState]);\n\n return forceRender;\n}\n\nexport function useWebEventHandlers() {\n return useRef<WebEventHandler>({\n onGestureHandlerEvent: (e: HandlerStateChangeEvent<unknown>) => {\n onGestureHandlerEvent(e.nativeEvent);\n },\n onGestureHandlerStateChange: isNewWebImplementationEnabled()\n ? (e: HandlerStateChangeEvent<unknown>) => {\n onGestureHandlerEvent(e.nativeEvent);\n }\n : undefined,\n });\n}\n"]}
@@ -1 +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","activeCursor","mouseButton","runOnJS","simultaneousWithExternalGesture","gestures","requireExternalGestureToFail","blocksExternalGesture","withTestId","id","testId","cancelsTouchesInView","initialize","current","toGestureArray","prepare","shouldUseReanimated","includes","ContinousBaseGesture","onUpdate","onChange","manualActivation"],"mappings":";;AASA,SAASA,iBAAT,QAAkC,sBAAlC;AAYA,SAASC,wBAAT,QAAyC,aAAzC;AAgEA,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;;AAG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","sourcesContent":["import {\n HitSlop,\n CommonGestureConfig,\n GestureTouchEvent,\n GestureStateChangeEvent,\n GestureUpdateEvent,\n ActiveCursor,\n MouseButton,\n} from '../gestureHandlerCommon';\nimport { getNextHandlerTag } from '../getNextHandlerTag';\nimport { GestureStateManagerType } from './gestureStateManager';\nimport type {\n FlingGestureHandlerEventPayload,\n ForceTouchGestureHandlerEventPayload,\n LongPressGestureHandlerEventPayload,\n PanGestureHandlerEventPayload,\n PinchGestureHandlerEventPayload,\n RotationGestureHandlerEventPayload,\n TapGestureHandlerEventPayload,\n NativeViewGestureHandlerPayload,\n} from '../GestureHandlerEventPayload';\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 blocksHandlers?: 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' | 'blocksHandlers',\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 /**\n * Sets a `ref` to the gesture object, allowing for interoperability with the old API.\n * @param ref\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 /**\n * Set the callback that is being called when given gesture handler starts receiving touches.\n * At the moment of this callback the handler is in `BEGAN` state and we don't know yet if it will recognize the gesture at all.\n * @param callback\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 /**\n * Set the callback that is being called when the gesture is recognized by the handler and it transitions to the `ACTIVE` state.\n * @param callback\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 /**\n * Set the callback that is being called when the gesture that was recognized by the handler finishes and handler reaches `END` state.\n * It will be called only if the handler was previously in the `ACTIVE` state.\n * @param callback\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 /**\n * Set the callback that is being called when the handler finalizes handling gesture - the gesture was recognized and has finished or it failed to recognize.\n * @param callback\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 /**\n * Set the `onTouchesDown` callback which is called every time a pointer is placed on the screen.\n * @param callback\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 /**\n * Set the `onTouchesMove` callback which is called every time a pointer is moved on the screen.\n * @param callback\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 /**\n * Set the `onTouchesUp` callback which is called every time a pointer is lifted from the screen.\n * @param callback\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 /**\n * Set the `onTouchesCancelled` callback which is called every time a pointer stops being tracked, for example when the gesture finishes.\n * @param callback\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 /**\n * Indicates whether the given handler should be analyzing stream of touch events or not.\n * @param enabled\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#enabledvalue-boolean\n */\n enabled(enabled: boolean) {\n this.config.enabled = enabled;\n return this;\n }\n\n /**\n * When true the handler will cancel or fail recognition (depending on its current state) whenever the finger leaves the area of the connected view.\n * @param value\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#shouldcancelwhenoutsidevalue-boolean\n */\n shouldCancelWhenOutside(value: boolean) {\n this.config.shouldCancelWhenOutside = value;\n return this;\n }\n\n /**\n * This parameter enables control over what part of the connected view area can be used to begin recognizing the gesture.\n * When a negative number is provided the bounds of the view will reduce the area by the given number of points in each of the sides evenly.\n * @param hitSlop\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#hitslopsettings\n */\n hitSlop(hitSlop: HitSlop) {\n this.config.hitSlop = hitSlop;\n return this;\n }\n\n /**\n * #### Web only\n * This parameter allows to specify which `cursor` should be used when gesture activates.\n * Supports all CSS cursor values (e.g. `\"grab\"`, `\"zoom-in\"`). Default value is set to `\"auto\"`.\n * @param activeCursor\n */\n activeCursor(activeCursor: ActiveCursor) {\n this.config.activeCursor = activeCursor;\n return this;\n }\n\n /**\n * #### Web & Android only\n * Allows users to choose which mouse button should handler respond to.\n * Arguments can be combined using `|` operator, e.g. `mouseButton(MouseButton.LEFT | MouseButton.RIGHT)`.\n * Default value is set to `MouseButton.LEFT`.\n * @param mouseButton\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#mousebuttonvalue-mousebutton-web--android-only\n */\n mouseButton(mouseButton: MouseButton) {\n this.config.mouseButton = mouseButton;\n return this;\n }\n\n /**\n * When `react-native-reanimated` is installed, the callbacks passed to the gestures are automatically workletized and run on the UI thread when called.\n * This option allows for changing this behavior: when `true`, all the callbacks will be run on the JS thread instead of the UI thread, regardless of whether they are worklets or not.\n * Defaults to `false`.\n * @param runOnJS\n */\n runOnJS(runOnJS: boolean) {\n this.config.runOnJS = runOnJS;\n return this;\n }\n\n /**\n * Allows gestures across different components to be recognized simultaneously.\n * @param gestures\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#simultaneouswithexternalgesture\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 /**\n * Allows to delay activation of the handler until all handlers passed as arguments to this method fail (or don't begin at all).\n * @param gestures\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#requireexternalgesturetofail\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 /**\n * Works similarily to `requireExternalGestureToFail` but the direction of the relation is reversed - instead of being one-to-many relation, it's many-to-one.\n * @param gestures\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#blocksexternalgesture\n */\n blocksExternalGesture(...gestures: Exclude<GestureRef, number>[]) {\n for (const gesture of gestures) {\n this.addDependency('blocksHandlers', gesture);\n }\n return this;\n }\n\n /**\n * Sets a `testID` property for gesture object, allowing for querying for it in tests.\n * @param id\n */\n withTestId(id: string) {\n this.config.testId = id;\n return this;\n }\n\n /**\n * #### iOS only\n * When `true`, the handler will cancel touches for native UI components (`UIButton`, `UISwitch`, etc) it's attached to when it becomes `ACTIVE`.\n * Default value is `true`.\n * @param value\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 // 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 /**\n * Set the callback that is being called every time the gesture receives an update while it's active.\n * @param callback\n */\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 /**\n * Set the callback that is being called every time the gesture receives an update while it's active.\n * This callback will receive information about change in value in relation to the last received event.\n * @param callback\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 /**\n * When `true` the handler will not activate by itself even if its activation criteria are met.\n * Instead you can manipulate its state using state manager.\n * @param manualActivation\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","activeCursor","mouseButton","runOnJS","simultaneousWithExternalGesture","gestures","requireExternalGestureToFail","blocksExternalGesture","withTestId","id","testId","cancelsTouchesInView","initialize","current","toGestureArray","prepare","shouldUseReanimated","includes","ContinousBaseGesture","onUpdate","onChange","manualActivation"],"mappings":";;AASA,SAASA,iBAAT,QAAkC,sBAAlC;AAaA,SAASC,wBAAT,QAAyC,aAAzC;AAiEA,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,GAAiBH,aAAa,EAA9B;AACA,SAAKM,QAAL,CAAcH,SAAd,GAA0B,KAAKA,SAA/B;AACD;;AAEOI,EAAAA,aAAa,CACnBC,GADmB,EAEnBC,OAFmB,EAGnB;AACA,UAAMC,KAAK,GAAG,KAAKC,MAAL,CAAYH,GAAZ,CAAd;AAC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AACA;AACEgD,EAAAA,QAAQ,CAACjC,QAAD,EAA+D;AACrE,SAAKV,QAAL,CAAc2C,QAAd,GAAyBjC,QAAzB;AACA,SAAKV,QAAL,CAAcD,SAAd,CAAwBlB,aAAa,CAACI,MAAtC,IAAgD,KAAKc,SAAL,CAAeW,QAAf,CAAhD;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEkC,EAAAA,QAAQ,CACNlC,QADM,EAIN;AACA,SAAKV,QAAL,CAAc4C,QAAd,GAAyBlC,QAAzB;AACA,SAAKV,QAAL,CAAcD,SAAd,CAAwBlB,aAAa,CAACK,MAAtC,IAAgD,KAAKa,SAAL,CAAeW,QAAf,CAAhD;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEmC,EAAAA,gBAAgB,CAACA,gBAAD,EAA4B;AAC1C,SAAKxC,MAAL,CAAYwC,gBAAZ,GAA+BA,gBAA/B;AACA,WAAO,IAAP;AACD;;AAlCkC","sourcesContent":["import {\n HitSlop,\n CommonGestureConfig,\n GestureTouchEvent,\n GestureStateChangeEvent,\n GestureUpdateEvent,\n ActiveCursor,\n MouseButton,\n} from '../gestureHandlerCommon';\nimport { getNextHandlerTag } from '../getNextHandlerTag';\nimport { GestureStateManagerType } from './gestureStateManager';\nimport type {\n FlingGestureHandlerEventPayload,\n ForceTouchGestureHandlerEventPayload,\n LongPressGestureHandlerEventPayload,\n PanGestureHandlerEventPayload,\n PinchGestureHandlerEventPayload,\n RotationGestureHandlerEventPayload,\n TapGestureHandlerEventPayload,\n NativeViewGestureHandlerPayload,\n HoverGestureHandlerEventPayload,\n} from '../GestureHandlerEventPayload';\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 | BaseGesture<HoverGestureHandlerEventPayload>;\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 blocksHandlers?: 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' | 'blocksHandlers',\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 /**\n * Sets a `ref` to the gesture object, allowing for interoperability with the old API.\n * @param ref\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 /**\n * Set the callback that is being called when given gesture handler starts receiving touches.\n * At the moment of this callback the handler is in `BEGAN` state and we don't know yet if it will recognize the gesture at all.\n * @param callback\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 /**\n * Set the callback that is being called when the gesture is recognized by the handler and it transitions to the `ACTIVE` state.\n * @param callback\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 /**\n * Set the callback that is being called when the gesture that was recognized by the handler finishes and handler reaches `END` state.\n * It will be called only if the handler was previously in the `ACTIVE` state.\n * @param callback\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 /**\n * Set the callback that is being called when the handler finalizes handling gesture - the gesture was recognized and has finished or it failed to recognize.\n * @param callback\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 /**\n * Set the `onTouchesDown` callback which is called every time a pointer is placed on the screen.\n * @param callback\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 /**\n * Set the `onTouchesMove` callback which is called every time a pointer is moved on the screen.\n * @param callback\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 /**\n * Set the `onTouchesUp` callback which is called every time a pointer is lifted from the screen.\n * @param callback\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 /**\n * Set the `onTouchesCancelled` callback which is called every time a pointer stops being tracked, for example when the gesture finishes.\n * @param callback\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 /**\n * Indicates whether the given handler should be analyzing stream of touch events or not.\n * @param enabled\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#enabledvalue-boolean\n */\n enabled(enabled: boolean) {\n this.config.enabled = enabled;\n return this;\n }\n\n /**\n * When true the handler will cancel or fail recognition (depending on its current state) whenever the finger leaves the area of the connected view.\n * @param value\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#shouldcancelwhenoutsidevalue-boolean\n */\n shouldCancelWhenOutside(value: boolean) {\n this.config.shouldCancelWhenOutside = value;\n return this;\n }\n\n /**\n * This parameter enables control over what part of the connected view area can be used to begin recognizing the gesture.\n * When a negative number is provided the bounds of the view will reduce the area by the given number of points in each of the sides evenly.\n * @param hitSlop\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#hitslopsettings\n */\n hitSlop(hitSlop: HitSlop) {\n this.config.hitSlop = hitSlop;\n return this;\n }\n\n /**\n * #### Web only\n * This parameter allows to specify which `cursor` should be used when gesture activates.\n * Supports all CSS cursor values (e.g. `\"grab\"`, `\"zoom-in\"`). Default value is set to `\"auto\"`.\n * @param activeCursor\n */\n activeCursor(activeCursor: ActiveCursor) {\n this.config.activeCursor = activeCursor;\n return this;\n }\n\n /**\n * #### Web & Android only\n * Allows users to choose which mouse button should handler respond to.\n * Arguments can be combined using `|` operator, e.g. `mouseButton(MouseButton.LEFT | MouseButton.RIGHT)`.\n * Default value is set to `MouseButton.LEFT`.\n * @param mouseButton\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#mousebuttonvalue-mousebutton-web--android-only\n */\n mouseButton(mouseButton: MouseButton) {\n this.config.mouseButton = mouseButton;\n return this;\n }\n\n /**\n * When `react-native-reanimated` is installed, the callbacks passed to the gestures are automatically workletized and run on the UI thread when called.\n * This option allows for changing this behavior: when `true`, all the callbacks will be run on the JS thread instead of the UI thread, regardless of whether they are worklets or not.\n * Defaults to `false`.\n * @param runOnJS\n */\n runOnJS(runOnJS: boolean) {\n this.config.runOnJS = runOnJS;\n return this;\n }\n\n /**\n * Allows gestures across different components to be recognized simultaneously.\n * @param gestures\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#simultaneouswithexternalgesture\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 /**\n * Allows to delay activation of the handler until all handlers passed as arguments to this method fail (or don't begin at all).\n * @param gestures\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#requireexternalgesturetofail\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 /**\n * Works similarily to `requireExternalGestureToFail` but the direction of the relation is reversed - instead of being one-to-many relation, it's many-to-one.\n * @param gestures\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#blocksexternalgesture\n */\n blocksExternalGesture(...gestures: Exclude<GestureRef, number>[]) {\n for (const gesture of gestures) {\n this.addDependency('blocksHandlers', gesture);\n }\n return this;\n }\n\n /**\n * Sets a `testID` property for gesture object, allowing for querying for it in tests.\n * @param id\n */\n withTestId(id: string) {\n this.config.testId = id;\n return this;\n }\n\n /**\n * #### iOS only\n * When `true`, the handler will cancel touches for native UI components (`UIButton`, `UISwitch`, etc) it's attached to when it becomes `ACTIVE`.\n * Default value is `true`.\n * @param value\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 // 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 /**\n * Set the callback that is being called every time the gesture receives an update while it's active.\n * @param callback\n */\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 /**\n * Set the callback that is being called every time the gesture receives an update while it's active.\n * This callback will receive information about change in value in relation to the last received event.\n * @param callback\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 /**\n * When `true` the handler will not activate by itself even if its activation criteria are met.\n * Instead you can manipulate its state using state manager.\n * @param manualActivation\n */\n manualActivation(manualActivation: boolean) {\n this.config.manualActivation = manualActivation;\n return this;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["hoverGesture.ts"],"names":["ContinousBaseGesture","HoverEffect","hoverGestureHandlerProps","changeEventCalculator","current","previous","changePayload","undefined","changeX","x","changeY","y","HoverGesture","constructor","handlerName","effect","config","hoverEffect","onChange","callback","handlers"],"mappings":";;AAAA,SAA4BA,oBAA5B,QAAwD,WAAxD;AAeA,WAAYC,WAAZ;;WAAYA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;GAAAA,W,KAAAA,W;;AAUZ,OAAO,MAAMC,wBAAwB,GAAG,CAAC,aAAD,CAAjC;;AAEP,SAASC,qBAAT,CACEC,OADF,EAEEC,QAFF,EAGE;AACA;;AACA,MAAIC,aAAJ;;AACA,MAAID,QAAQ,KAAKE,SAAjB,EAA4B;AAC1BD,IAAAA,aAAa,GAAG;AACdE,MAAAA,OAAO,EAAEJ,OAAO,CAACK,CADH;AAEdC,MAAAA,OAAO,EAAEN,OAAO,CAACO;AAFH,KAAhB;AAID,GALD,MAKO;AACLL,IAAAA,aAAa,GAAG;AACdE,MAAAA,OAAO,EAAEJ,OAAO,CAACK,CAAR,GAAYJ,QAAQ,CAACI,CADhB;AAEdC,MAAAA,OAAO,EAAEN,OAAO,CAACO,CAAR,GAAYN,QAAQ,CAACM;AAFhB,KAAhB;AAID;;AAED,SAAO,EAAE,GAAGP,OAAL;AAAc,OAAGE;AAAjB,GAAP;AACD;;AAED,OAAO,MAAMM,YAAN,SAA2BZ,oBAA3B,CAGL;AAGAa,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAF0C,EAE1C;;AAGZ,SAAKC,WAAL,GAAmB,qBAAnB;AACD;AAED;AACF;AACA;AACA;;;AACEC,EAAAA,MAAM,CAACA,MAAD,EAAsB;AAC1B,SAAKC,MAAL,CAAYC,WAAZ,GAA0BF,MAA1B;AACA,WAAO,IAAP;AACD;;AAEDG,EAAAA,QAAQ,CACNC,QADM,EAMN;AACA;AACA,SAAKC,QAAL,CAAcjB,qBAAd,GAAsCA,qBAAtC;AACA,WAAO,MAAMe,QAAN,CAAeC,QAAf,CAAP;AACD;;AA5BD","sourcesContent":["import { BaseGestureConfig, ContinousBaseGesture } from './gesture';\nimport { GestureUpdateEvent } from '../gestureHandlerCommon';\n\nexport type HoverGestureHandlerEventPayload = {\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\n\nexport type HoverGestureChangeEventPayload = {\n changeX: number;\n changeY: number;\n};\n\nexport enum HoverEffect {\n NONE = 0,\n LIFT = 1,\n HIGHLIGHT = 2,\n}\n\nexport interface HoverGestureConfig {\n hoverEffect?: HoverEffect;\n}\n\nexport const hoverGestureHandlerProps = ['hoverEffect'] as const;\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent<HoverGestureHandlerEventPayload>,\n previous?: GestureUpdateEvent<HoverGestureHandlerEventPayload>\n) {\n 'worklet';\n let changePayload: HoverGestureChangeEventPayload;\n if (previous === undefined) {\n changePayload = {\n changeX: current.x,\n changeY: current.y,\n };\n } else {\n changePayload = {\n changeX: current.x - previous.x,\n changeY: current.y - previous.y,\n };\n }\n\n return { ...current, ...changePayload };\n}\n\nexport class HoverGesture extends ContinousBaseGesture<\n HoverGestureHandlerEventPayload,\n HoverGestureChangeEventPayload\n> {\n public config: BaseGestureConfig & HoverGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'HoverGestureHandler';\n }\n\n /**\n * #### iOS only\n * Sets the visual hover effect.\n */\n effect(effect: HoverEffect) {\n this.config.hoverEffect = effect;\n return this;\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<\n HoverGestureHandlerEventPayload & HoverGestureChangeEventPayload\n >\n ) => void\n ) {\n // @ts-ignore TS being overprotective, HoverGestureHandlerEventPayload is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type HoverGestureType = InstanceType<typeof HoverGesture>;\n"]}
1
+ {"version":3,"sources":["hoverGesture.ts"],"names":["ContinousBaseGesture","HoverEffect","hoverGestureHandlerProps","changeEventCalculator","current","previous","changePayload","undefined","changeX","x","changeY","y","HoverGesture","constructor","handlerName","effect","config","hoverEffect","onChange","callback","handlers"],"mappings":";;AAAA,SAA4BA,oBAA5B,QAAwD,WAAxD;AASA,WAAYC,WAAZ;;WAAYA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;GAAAA,W,KAAAA,W;;AAUZ,OAAO,MAAMC,wBAAwB,GAAG,CAAC,aAAD,CAAjC;;AAEP,SAASC,qBAAT,CACEC,OADF,EAEEC,QAFF,EAGE;AACA;;AACA,MAAIC,aAAJ;;AACA,MAAID,QAAQ,KAAKE,SAAjB,EAA4B;AAC1BD,IAAAA,aAAa,GAAG;AACdE,MAAAA,OAAO,EAAEJ,OAAO,CAACK,CADH;AAEdC,MAAAA,OAAO,EAAEN,OAAO,CAACO;AAFH,KAAhB;AAID,GALD,MAKO;AACLL,IAAAA,aAAa,GAAG;AACdE,MAAAA,OAAO,EAAEJ,OAAO,CAACK,CAAR,GAAYJ,QAAQ,CAACI,CADhB;AAEdC,MAAAA,OAAO,EAAEN,OAAO,CAACO,CAAR,GAAYN,QAAQ,CAACM;AAFhB,KAAhB;AAID;;AAED,SAAO,EAAE,GAAGP,OAAL;AAAc,OAAGE;AAAjB,GAAP;AACD;;AAED,OAAO,MAAMM,YAAN,SAA2BZ,oBAA3B,CAGL;AAGAa,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAF0C,EAE1C;;AAGZ,SAAKC,WAAL,GAAmB,qBAAnB;AACD;AAED;AACF;AACA;AACA;;;AACEC,EAAAA,MAAM,CAACA,MAAD,EAAsB;AAC1B,SAAKC,MAAL,CAAYC,WAAZ,GAA0BF,MAA1B;AACA,WAAO,IAAP;AACD;;AAEDG,EAAAA,QAAQ,CACNC,QADM,EAMN;AACA;AACA,SAAKC,QAAL,CAAcjB,qBAAd,GAAsCA,qBAAtC;AACA,WAAO,MAAMe,QAAN,CAAeC,QAAf,CAAP;AACD;;AA5BD","sourcesContent":["import { BaseGestureConfig, ContinousBaseGesture } from './gesture';\nimport { GestureUpdateEvent } from '../gestureHandlerCommon';\nimport type { HoverGestureHandlerEventPayload } from '../GestureHandlerEventPayload';\n\nexport type HoverGestureChangeEventPayload = {\n changeX: number;\n changeY: number;\n};\n\nexport enum HoverEffect {\n NONE = 0,\n LIFT = 1,\n HIGHLIGHT = 2,\n}\n\nexport interface HoverGestureConfig {\n hoverEffect?: HoverEffect;\n}\n\nexport const hoverGestureHandlerProps = ['hoverEffect'] as const;\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent<HoverGestureHandlerEventPayload>,\n previous?: GestureUpdateEvent<HoverGestureHandlerEventPayload>\n) {\n 'worklet';\n let changePayload: HoverGestureChangeEventPayload;\n if (previous === undefined) {\n changePayload = {\n changeX: current.x,\n changeY: current.y,\n };\n } else {\n changePayload = {\n changeX: current.x - previous.x,\n changeY: current.y - previous.y,\n };\n }\n\n return { ...current, ...changePayload };\n}\n\nexport class HoverGesture extends ContinousBaseGesture<\n HoverGestureHandlerEventPayload,\n HoverGestureChangeEventPayload\n> {\n public config: BaseGestureConfig & HoverGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'HoverGestureHandler';\n }\n\n /**\n * #### iOS only\n * Sets the visual hover effect.\n */\n effect(effect: HoverEffect) {\n this.config.hoverEffect = effect;\n return this;\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<\n HoverGestureHandlerEventPayload & HoverGestureChangeEventPayload\n >\n ) => void\n ) {\n // @ts-ignore TS being overprotective, HoverGestureHandlerEventPayload is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type HoverGestureType = InstanceType<typeof HoverGesture>;\n"]}
@@ -32,6 +32,16 @@ export class LongPressGesture extends BaseGesture {
32
32
  this.config.maxDist = distance;
33
33
  return this;
34
34
  }
35
+ /**
36
+ * Determine exact number of points required to handle the long press gesture.
37
+ * @param pointers
38
+ */
39
+
40
+
41
+ numberOfPointers(pointers) {
42
+ this.config.numberOfPointers = pointers;
43
+ return this;
44
+ }
35
45
 
36
46
  }
37
47
  //# sourceMappingURL=longPressGesture.js.map
@@ -1 +1 @@
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;AAIA,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;AAED;AACF;AACA;AACA;AACA;;;AACEC,EAAAA,WAAW,CAACC,QAAD,EAAmB;AAC5B,SAAKC,MAAL,CAAYC,aAAZ,GAA4BF,QAA5B;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEG,EAAAA,WAAW,CAACC,QAAD,EAAmB;AAC5B,SAAKH,MAAL,CAAYI,OAAZ,GAAsBD,QAAtB;AACA,WAAO,IAAP;AACD;;AA5BoF","sourcesContent":["import { BaseGesture, BaseGestureConfig } from './gesture';\nimport { LongPressGestureConfig } from '../LongPressGestureHandler';\nimport type { LongPressGestureHandlerEventPayload } from '../GestureHandlerEventPayload';\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 /**\n * Minimum time, expressed in milliseconds, that a finger must remain pressed on the corresponding view.\n * The default value is 500.\n * @param duration\n */\n minDuration(duration: number) {\n this.config.minDurationMs = duration;\n return this;\n }\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is allowed to travel during a long press gesture.\n * @param distance\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/long-press-gesture#maxdistancevalue-number\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","numberOfPointers","pointers"],"mappings":";;AAAA,SAASA,WAAT,QAA+C,WAA/C;AAIA,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;AAED;AACF;AACA;AACA;AACA;;;AACEC,EAAAA,WAAW,CAACC,QAAD,EAAmB;AAC5B,SAAKC,MAAL,CAAYC,aAAZ,GAA4BF,QAA5B;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEG,EAAAA,WAAW,CAACC,QAAD,EAAmB;AAC5B,SAAKH,MAAL,CAAYI,OAAZ,GAAsBD,QAAtB;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;;;AACEE,EAAAA,gBAAgB,CAACC,QAAD,EAAmB;AACjC,SAAKN,MAAL,CAAYK,gBAAZ,GAA+BC,QAA/B;AACA,WAAO,IAAP;AACD;;AArCoF","sourcesContent":["import { BaseGesture, BaseGestureConfig } from './gesture';\nimport { LongPressGestureConfig } from '../LongPressGestureHandler';\nimport type { LongPressGestureHandlerEventPayload } from '../GestureHandlerEventPayload';\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 /**\n * Minimum time, expressed in milliseconds, that a finger must remain pressed on the corresponding view.\n * The default value is 500.\n * @param duration\n */\n minDuration(duration: number) {\n this.config.minDurationMs = duration;\n return this;\n }\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is allowed to travel during a long press gesture.\n * @param distance\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/long-press-gesture#maxdistancevalue-number\n */\n maxDistance(distance: number) {\n this.config.maxDist = distance;\n return this;\n }\n\n /**\n * Determine exact number of points required to handle the long press gesture.\n * @param pointers\n */\n numberOfPointers(pointers: number) {\n this.config.numberOfPointers = pointers;\n return this;\n }\n}\n\nexport type LongPressGestureType = InstanceType<typeof LongPressGesture>;\n"]}
@@ -59,7 +59,8 @@ const handlersDefaultEvents = {
59
59
  translationY: 0,
60
60
  velocityX: 3,
61
61
  velocityY: 0,
62
- numberOfPointers: 1
62
+ numberOfPointers: 1,
63
+ stylusData: undefined
63
64
  },
64
65
  [pinchHandlerName]: {
65
66
  focalX: 0,
@@ -290,7 +291,8 @@ function getHandlerData(componentOrGesture) {
290
291
  DeviceEventEmitter.emit(eventName, args.nativeEvent);
291
292
  },
292
293
  handlerType: gesture.handlerName,
293
- handlerTag: gesture.handlerTag
294
+ handlerTag: gesture.handlerTag,
295
+ enabled: gesture.config.enabled
294
296
  };
295
297
  }
296
298
 
@@ -300,7 +302,8 @@ function getHandlerData(componentOrGesture) {
300
302
  fireEvent(gestureHandlerComponent, eventName, args);
301
303
  },
302
304
  handlerType: gestureHandlerComponent.props.handlerType,
303
- handlerTag: gestureHandlerComponent.props.handlerTag
305
+ handlerTag: gestureHandlerComponent.props.handlerTag,
306
+ enabled: gestureHandlerComponent.props.enabled
304
307
  };
305
308
  }
306
309
 
@@ -308,9 +311,14 @@ export function fireGestureHandler(componentOrGesture, eventList = []) {
308
311
  const {
309
312
  emitEvent,
310
313
  handlerType,
311
- handlerTag
314
+ handlerTag,
315
+ enabled
312
316
  } = getHandlerData(componentOrGesture);
313
317
 
318
+ if (enabled === false) {
319
+ return;
320
+ }
321
+
314
322
  let _ = fillMissingStatesTransitions(eventList, isDiscreteHandler(handlerType));
315
323
 
316
324
  _ = _.map(fillMissingDefaultsFor({
@@ -1 +1 @@
1
- {"version":3,"sources":["jestUtils.ts"],"names":["invariant","DeviceEventEmitter","flingHandlerName","forceTouchHandlerName","BaseGesture","findHandlerByTestID","longPressHandlerName","nativeViewHandlerName","panHandlerName","pinchHandlerName","rotationHandlerName","tapHandlerName","State","hasProperty","withPrevAndCurrent","fireEvent","_element","_name","_data","require","_e","handlersDefaultEvents","x","y","absoluteX","absoluteY","numberOfPointers","force","duration","pointerInside","translationX","translationY","velocityX","velocityY","focalX","focalY","scale","velocity","anchorX","anchorY","rotation","isGesture","componentOrGesture","wrapWithNativeEvent","event","nativeEvent","fillOldStateChanges","previousEvent","currentEvent","isFirstEvent","oldState","UNDETERMINED","isGestureStateEvent","state","validateStateTransitions","stringify","JSON","errorMsgWithBothEvents","description","errorMsgWithCurrentEvent","BEGAN","fillMissingDefaultsFor","handlerType","handlerTag","isDiscreteHandler","fillMissingStatesTransitions","events","_events","lastEvent","length","firstEvent","shouldDuplicateFirstEvent","hasState","duplicated","unshift","shouldDuplicateLastEvent","END","FAILED","CANCELLED","push","isWithoutState","noEventsLeft","trueFn","fillEventsForCurrentState","shouldConsumeEvent","shouldTransitionToNextState","peekCurrentEvent","peekNextEvent","consumeCurrentEvent","shift","nextEvent","currentRequiredState","REQUIRED_EVENTS","currentStateIdx","eventData","shouldUseEvent","transformedEvents","ACTIVE","hasAllStates","iterations","nextRequiredState","e","getHandlerData","gesture","emitEvent","eventName","args","emit","handlerName","gestureHandlerComponent","props","fireGestureHandler","eventList","_","map","lastSentEvent","hasChangedState","getByGestureTestId","testID","handler","Error"],"mappings":"AAAA,OAAOA,SAAP,MAAsB,WAAtB;AACA,SAASC,kBAAT,QAAmC,cAAnC;AAEA,SAEEC,gBAFF,QAGO,iCAHP;AAIA,SAEEC,qBAFF,QAGO,sCAHP;AAWA,SAASC,WAAT,QAAyC,8BAAzC;AAOA,SAASC,mBAAT,QAAoC,8BAApC;AACA,SAEEC,oBAFF,QAGO,qCAHP;AAcA,SAEEC,qBAFF,QAGO,sCAHP;AAIA,SAEEC,cAFF,QAGO,+BAHP;AAIA,SAEEC,gBAFF,QAGO,iCAHP;AAIA,SAEEC,mBAFF,QAGO,oCAHP;AAIA,SAEEC,cAFF,QAGO,+BAHP;AAIA,SAASC,KAAT,QAAsB,UAAtB;AACA,SAASC,WAAT,EAAsBC,kBAAtB,QAAgD,UAAhD,C,CAEA;;AACA,IAAIC,SAAS,GAAG,CACdC,QADc,EAEdC,KAFc,EAGd,GAAGC,KAHW,KAIX,CACH;AACD,CAND;;AAQA,IAAI;AACF;AACAH,EAAAA,SAAS,GAAGI,OAAO,CAAC,+BAAD,CAAP,CAAyCJ,SAArD;AACD,CAHD,CAGE,OAAOK,EAAP,EAAW,CACX;AACD;;AAyBD,MAAMC,qBAA2C,GAAG;AAClD,GAACnB,gBAAD,GAAoB;AAClBoB,IAAAA,CAAC,EAAE,CADe;AAElBC,IAAAA,CAAC,EAAE,CAFe;AAGlBC,IAAAA,SAAS,EAAE,CAHO;AAIlBC,IAAAA,SAAS,EAAE,CAJO;AAKlBC,IAAAA,gBAAgB,EAAE;AALA,GAD8B;AAQlD,GAACvB,qBAAD,GAAyB;AACvBmB,IAAAA,CAAC,EAAE,CADoB;AAEvBC,IAAAA,CAAC,EAAE,CAFoB;AAGvBC,IAAAA,SAAS,EAAE,CAHY;AAIvBC,IAAAA,SAAS,EAAE,CAJY;AAKvBE,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AMvE,mBAAN,CAAJ;AAEA,QAAMuB,MAAM,GAAG+C,CAAf;AAEA,QAAM3C,UAAU,GAAGJ,MAAM,CAACuB,KAAP,EAAnB;AAEAe,EAAAA,SAAS,CAAC,6BAAD,EAAgClC,UAAhC,CAAT;AACA,MAAI6C,aAAa,GAAG7C,UAApB;;AACA,OAAK,MAAM1B,KAAX,IAAoBsB,MAApB,EAA4B;AAC1B,UAAMkD,eAAe,GACnBD,aAAa,CAACtE,WAAd,CAA0BQ,KAA1B,KAAoCT,KAAK,CAACC,WAAN,CAAkBQ,KADxD;;AAGA,QAAI+D,eAAJ,EAAqB;AACnBZ,MAAAA,SAAS,CAAC,6BAAD,EAAgC5D,KAAhC,CAAT;AACD,KAFD,MAEO;AACL4D,MAAAA,SAAS,CAAC,uBAAD,EAA0B5D,KAA1B,CAAT;AACD;;AACDuE,IAAAA,aAAa,GAAGvE,KAAhB;AACD;AACF;AAED,OAAO,SAASyE,kBAAT,CAA4BC,MAA5B,EAA4C;AACjD,QAAMC,OAAO,GAAGlH,mBAAmB,CAACiH,MAAD,CAAnC;;AACA,MAAIC,OAAO,KAAK,IAAhB,EAAsB;AACpB,UAAM,IAAIC,KAAJ,CAAW,qBAAoBF,MAAO,mBAAtC,CAAN;AACD;;AACD,SAAOC,OAAP;AACD","sourcesContent":["import invariant from 'invariant';\nimport { DeviceEventEmitter } from 'react-native';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport {\n FlingGestureHandler,\n flingHandlerName,\n} from '../handlers/FlingGestureHandler';\nimport {\n ForceTouchGestureHandler,\n forceTouchHandlerName,\n} from '../handlers/ForceTouchGestureHandler';\nimport {\n BaseGestureHandlerProps,\n GestureEvent,\n HandlerStateChangeEvent,\n} from '../handlers/gestureHandlerCommon';\nimport { FlingGesture } from '../handlers/gestures/flingGesture';\nimport { ForceTouchGesture } from '../handlers/gestures/forceTouchGesture';\nimport { BaseGesture, GestureType } from '../handlers/gestures/gesture';\nimport { LongPressGesture } from '../handlers/gestures/longPressGesture';\nimport { NativeGesture } from '../handlers/gestures/nativeGesture';\nimport { PanGesture } from '../handlers/gestures/panGesture';\nimport { PinchGesture } from '../handlers/gestures/pinchGesture';\nimport { RotationGesture } from '../handlers/gestures/rotationGesture';\nimport { TapGesture } from '../handlers/gestures/tapGesture';\nimport { findHandlerByTestID } from '../handlers/handlersRegistry';\nimport {\n LongPressGestureHandler,\n longPressHandlerName,\n} from '../handlers/LongPressGestureHandler';\nimport type {\n FlingGestureHandlerEventPayload,\n ForceTouchGestureHandlerEventPayload,\n LongPressGestureHandlerEventPayload,\n NativeViewGestureHandlerPayload,\n PanGestureHandlerEventPayload,\n PinchGestureHandlerEventPayload,\n RotationGestureHandlerEventPayload,\n TapGestureHandlerEventPayload,\n} from '../handlers/GestureHandlerEventPayload';\nimport {\n NativeViewGestureHandler,\n nativeViewHandlerName,\n} from '../handlers/NativeViewGestureHandler';\nimport {\n PanGestureHandler,\n panHandlerName,\n} from '../handlers/PanGestureHandler';\nimport {\n PinchGestureHandler,\n pinchHandlerName,\n} from '../handlers/PinchGestureHandler';\nimport {\n RotationGestureHandler,\n rotationHandlerName,\n} from '../handlers/RotationGestureHandler';\nimport {\n TapGestureHandler,\n tapHandlerName,\n} from '../handlers/TapGestureHandler';\nimport { State } from '../State';\nimport { hasProperty, withPrevAndCurrent } from '../utils';\n\n// Load fireEvent conditionally, so RNGH may be used in setups without testing-library\nlet fireEvent = (\n _element: ReactTestInstance,\n _name: string,\n ..._data: any[]\n) => {\n // NOOP\n};\n\ntry {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n fireEvent = require('@testing-library/react-native').fireEvent;\n} catch (_e) {\n // Do nothing if not available\n}\n\ntype GestureHandlerTestEvent<\n TEventPayload extends Record<string, unknown> = Record<string, unknown>\n> = (\n | GestureEvent<TEventPayload>\n | HandlerStateChangeEvent<TEventPayload>\n)['nativeEvent'];\n\ntype HandlerNames = keyof DefaultEventsMapping;\n\ntype WithNumberOfPointers<T> = {\n [P in keyof T]: T[P] & { numberOfPointers: number };\n};\ntype DefaultEventsMapping = WithNumberOfPointers<{\n [flingHandlerName]: FlingGestureHandlerEventPayload;\n [forceTouchHandlerName]: ForceTouchGestureHandlerEventPayload;\n [longPressHandlerName]: LongPressGestureHandlerEventPayload;\n [nativeViewHandlerName]: NativeViewGestureHandlerPayload;\n [panHandlerName]: PanGestureHandlerEventPayload;\n [pinchHandlerName]: PinchGestureHandlerEventPayload;\n [rotationHandlerName]: RotationGestureHandlerEventPayload;\n [tapHandlerName]: TapGestureHandlerEventPayload;\n}>;\n\nconst handlersDefaultEvents: DefaultEventsMapping = {\n [flingHandlerName]: {\n x: 0,\n y: 0,\n absoluteX: 0,\n absoluteY: 0,\n numberOfPointers: 1,\n },\n [forceTouchHandlerName]: {\n x: 0,\n y: 0,\n absoluteX: 0,\n absoluteY: 0,\n force: 1,\n numberOfPointers: 1,\n },\n [longPressHandlerName]: {\n x: 0,\n y: 0,\n absoluteX: 0,\n absoluteY: 0,\n duration: 100,\n numberOfPointers: 1,\n },\n [nativeViewHandlerName]: {\n pointerInside: true,\n numberOfPointers: 1,\n },\n [panHandlerName]: {\n x: 0,\n y: 0,\n absoluteX: 0,\n absoluteY: 0,\n translationX: 100,\n translationY: 0,\n velocityX: 3,\n velocityY: 0,\n numberOfPointers: 1,\n },\n [pinchHandlerName]: {\n focalX: 0,\n focalY: 0,\n scale: 2,\n velocity: 1,\n numberOfPointers: 2,\n },\n [rotationHandlerName]: {\n anchorX: 0,\n anchorY: 0,\n rotation: 3.14,\n velocity: 2,\n numberOfPointers: 2,\n },\n [tapHandlerName]: {\n x: 0,\n y: 0,\n absoluteX: 0,\n absoluteY: 0,\n numberOfPointers: 1,\n },\n};\n\nfunction isGesture(\n componentOrGesture: ReactTestInstance | GestureType\n): componentOrGesture is GestureType {\n return componentOrGesture instanceof BaseGesture;\n}\n\ninterface WrappedGestureHandlerTestEvent {\n nativeEvent: GestureHandlerTestEvent;\n}\nfunction wrapWithNativeEvent(\n event: GestureHandlerTestEvent\n): WrappedGestureHandlerTestEvent {\n return { nativeEvent: event };\n}\n\nfunction fillOldStateChanges(\n previousEvent: GestureHandlerTestEvent | null,\n currentEvent: Omit<GestureHandlerTestEvent, 'oldState'>\n): GestureHandlerTestEvent {\n const isFirstEvent = previousEvent === null;\n if (isFirstEvent) {\n return {\n oldState: State.UNDETERMINED,\n ...currentEvent,\n } as GestureHandlerTestEvent;\n }\n\n const isGestureStateEvent = previousEvent.state !== currentEvent.state;\n if (isGestureStateEvent) {\n return {\n oldState: previousEvent?.state,\n ...currentEvent,\n } as GestureHandlerTestEvent;\n } else {\n return currentEvent as GestureHandlerTestEvent;\n }\n}\n\ntype EventWithStates = Partial<\n Pick<GestureHandlerTestEvent, 'oldState' | 'state'>\n>;\nfunction validateStateTransitions(\n previousEvent: EventWithStates | null,\n currentEvent: EventWithStates\n) {\n function stringify(event: Record<string, unknown> | null) {\n return JSON.stringify(event, null, 2);\n }\n function errorMsgWithBothEvents(description: string) {\n return `${description}, invalid event: ${stringify(\n currentEvent\n )}, previous event: ${stringify(previousEvent)}`;\n }\n\n function errorMsgWithCurrentEvent(description: string) {\n return `${description}, invalid event: ${stringify(currentEvent)}`;\n }\n\n invariant(\n hasProperty(currentEvent, 'state'),\n errorMsgWithCurrentEvent('every event must have state')\n );\n\n const isFirstEvent = previousEvent === null;\n if (isFirstEvent) {\n invariant(\n currentEvent.state === State.BEGAN,\n errorMsgWithCurrentEvent('first event must have BEGAN state')\n );\n }\n\n if (previousEvent !== null) {\n if (previousEvent.state !== currentEvent.state) {\n invariant(\n hasProperty(currentEvent, 'oldState'),\n errorMsgWithCurrentEvent(\n 'when state changes, oldState field should be present'\n )\n );\n invariant(\n currentEvent.oldState === previousEvent.state,\n errorMsgWithBothEvents(\n \"when state changes, oldState should be the same as previous event' state\"\n )\n );\n }\n }\n\n return currentEvent;\n}\n\ntype EventWithoutStates = Omit<GestureHandlerTestEvent, 'oldState' | 'state'>;\ninterface HandlerInfo {\n handlerType: HandlerNames;\n handlerTag: number;\n}\nfunction fillMissingDefaultsFor({\n handlerType,\n handlerTag,\n}: HandlerInfo): (\n event: Partial<GestureHandlerTestEvent>\n) => EventWithoutStates {\n return (event) => {\n return {\n ...handlersDefaultEvents[handlerType],\n ...event,\n handlerTag,\n };\n };\n}\n\nfunction isDiscreteHandler(handlerType: HandlerNames) {\n return (\n handlerType === 'TapGestureHandler' ||\n handlerType === 'LongPressGestureHandler'\n );\n}\n\nfunction fillMissingStatesTransitions(\n events: EventWithoutStates[],\n isDiscreteHandler: boolean\n): EventWithoutStates[] {\n type Event = EventWithoutStates | null;\n const _events = [...events];\n const lastEvent = _events[_events.length - 1] ?? null;\n const firstEvent = _events[0] ?? null;\n\n const shouldDuplicateFirstEvent =\n !isDiscreteHandler && !hasState(State.BEGAN)(firstEvent);\n if (shouldDuplicateFirstEvent) {\n const duplicated = { ...firstEvent, state: State.BEGAN };\n // @ts-ignore badly typed, property may exist and we don't want to copy it\n delete duplicated.oldState;\n _events.unshift(duplicated);\n }\n\n const shouldDuplicateLastEvent =\n !hasState(State.END)(lastEvent) ||\n !hasState(State.FAILED)(lastEvent) ||\n !hasState(State.CANCELLED)(lastEvent);\n\n if (shouldDuplicateLastEvent) {\n const duplicated = { ...lastEvent, state: State.END };\n // @ts-ignore badly typed, property may exist and we don't want to copy it\n delete duplicated.oldState;\n _events.push(duplicated);\n }\n\n function isWithoutState(event: Event) {\n return event !== null && !hasProperty(event, 'state');\n }\n function hasState(state: State) {\n return (event: Event) => event !== null && event.state === state;\n }\n function noEventsLeft(event: Event) {\n return event === null;\n }\n\n function trueFn() {\n return true;\n }\n interface Args {\n shouldConsumeEvent?: (event: Event) => boolean;\n shouldTransitionToNextState?: (nextEvent: Event) => boolean;\n }\n function fillEventsForCurrentState({\n shouldConsumeEvent = trueFn,\n shouldTransitionToNextState = trueFn,\n }: Args) {\n function peekCurrentEvent(): Event {\n return _events[0] ?? null;\n }\n function peekNextEvent(): Event {\n return _events[1] ?? null;\n }\n function consumeCurrentEvent() {\n _events.shift();\n }\n const currentEvent = peekCurrentEvent();\n const nextEvent = peekNextEvent();\n const currentRequiredState = REQUIRED_EVENTS[currentStateIdx];\n\n let eventData = {};\n const shouldUseEvent = shouldConsumeEvent(currentEvent);\n if (shouldUseEvent) {\n eventData = currentEvent!;\n consumeCurrentEvent();\n }\n transformedEvents.push({ state: currentRequiredState, ...eventData });\n if (shouldTransitionToNextState(nextEvent)) {\n currentStateIdx++;\n }\n }\n\n const REQUIRED_EVENTS = [State.BEGAN, State.ACTIVE, State.END];\n\n let currentStateIdx = 0;\n const transformedEvents: EventWithoutStates[] = [];\n let hasAllStates;\n let iterations = 0;\n do {\n const nextRequiredState = REQUIRED_EVENTS[currentStateIdx];\n if (nextRequiredState === State.BEGAN) {\n fillEventsForCurrentState({\n shouldConsumeEvent: (e: Event) =>\n isWithoutState(e) || hasState(State.BEGAN)(e),\n });\n } else if (nextRequiredState === State.ACTIVE) {\n const shouldConsumeEvent = (e: Event) =>\n isWithoutState(e) || hasState(State.ACTIVE)(e);\n const shouldTransitionToNextState = (nextEvent: Event) =>\n noEventsLeft(nextEvent) ||\n hasState(State.END)(nextEvent) ||\n hasState(State.FAILED)(nextEvent) ||\n hasState(State.CANCELLED)(nextEvent);\n\n fillEventsForCurrentState({\n shouldConsumeEvent,\n shouldTransitionToNextState,\n });\n } else if (nextRequiredState === State.END) {\n fillEventsForCurrentState({});\n }\n hasAllStates = currentStateIdx === REQUIRED_EVENTS.length;\n\n invariant(\n iterations++ <= 500,\n 'exceeded max number of iterations, please report a bug in RNGH repository with your test case'\n );\n } while (!hasAllStates);\n\n return transformedEvents;\n}\n\ntype EventEmitter = (\n eventName: string,\n args: { nativeEvent: GestureHandlerTestEvent }\n) => void;\ninterface HandlerData {\n emitEvent: EventEmitter;\n handlerType: HandlerNames;\n handlerTag: number;\n}\nfunction getHandlerData(\n componentOrGesture: ReactTestInstance | GestureType\n): HandlerData {\n if (isGesture(componentOrGesture)) {\n const gesture = componentOrGesture;\n return {\n emitEvent: (eventName, args) => {\n DeviceEventEmitter.emit(eventName, args.nativeEvent);\n },\n handlerType: gesture.handlerName as HandlerNames,\n handlerTag: gesture.handlerTag,\n };\n }\n const gestureHandlerComponent = componentOrGesture;\n return {\n emitEvent: (eventName, args) => {\n fireEvent(gestureHandlerComponent, eventName, args);\n },\n handlerType: gestureHandlerComponent.props.handlerType as HandlerNames,\n handlerTag: gestureHandlerComponent.props.handlerTag as number,\n };\n}\ntype AllGestures =\n | TapGesture\n | PanGesture\n | LongPressGesture\n | RotationGesture\n | PinchGesture\n | FlingGesture\n | ForceTouchGesture\n | NativeGesture;\n\ntype AllHandlers =\n | TapGestureHandler\n | PanGestureHandler\n | LongPressGestureHandler\n | RotationGestureHandler\n | PinchGestureHandler\n | FlingGestureHandler\n | ForceTouchGestureHandler\n | NativeViewGestureHandler;\n\n// prettier-ignore\ntype ClassComponentConstructor<P> = new (props: P) => React.Component<P, any, any>;\n\ntype ExtractPayloadFromProps<T> = T extends BaseGestureHandlerProps<\n infer TPayload\n>\n ? TPayload\n : never;\n\ntype ExtractConfig<T> = T extends BaseGesture<infer TGesturePayload>\n ? TGesturePayload\n : T extends ClassComponentConstructor<infer THandlerProps>\n ? ExtractPayloadFromProps<THandlerProps>\n : Record<string, unknown>;\n\nexport function fireGestureHandler<THandler extends AllGestures | AllHandlers>(\n componentOrGesture: ReactTestInstance | GestureType,\n eventList: Partial<GestureHandlerTestEvent<ExtractConfig<THandler>>>[] = []\n): void {\n const { emitEvent, handlerType, handlerTag } =\n getHandlerData(componentOrGesture);\n\n let _ = fillMissingStatesTransitions(\n eventList,\n isDiscreteHandler(handlerType)\n );\n _ = _.map(fillMissingDefaultsFor({ handlerTag, handlerType }));\n _ = withPrevAndCurrent(_, fillOldStateChanges);\n _ = withPrevAndCurrent(_, validateStateTransitions);\n // @ts-ignore TODO\n _ = _.map(wrapWithNativeEvent);\n\n const events = _ as unknown as WrappedGestureHandlerTestEvent[];\n\n const firstEvent = events.shift()!;\n\n emitEvent('onGestureHandlerStateChange', firstEvent);\n let lastSentEvent = firstEvent;\n for (const event of events) {\n const hasChangedState =\n lastSentEvent.nativeEvent.state !== event.nativeEvent.state;\n\n if (hasChangedState) {\n emitEvent('onGestureHandlerStateChange', event);\n } else {\n emitEvent('onGestureHandlerEvent', event);\n }\n lastSentEvent = event;\n }\n}\n\nexport function getByGestureTestId(testID: string) {\n const handler = findHandlerByTestID(testID);\n if (handler === null) {\n throw new Error(`Handler with id: '${testID}' cannot be found`);\n }\n return handler;\n}\n"]}
1
+ {"version":3,"sources":["jestUtils.ts"],"names":["invariant","DeviceEventEmitter","flingHandlerName","forceTouchHandlerName","BaseGesture","findHandlerByTestID","longPressHandlerName","nativeViewHandlerName","panHandlerName","pinchHandlerName","rotationHandlerName","tapHandlerName","State","hasProperty","withPrevAndCurrent","fireEvent","_element","_name","_data","require","_e","handlersDefaultEvents","x","y","absoluteX","absoluteY","numberOfPointers","force","duration","pointerInside","translationX","translationY","velocityX","velocityY","stylusData","undefined","focalX","focalY","scale","velocity","anchorX","anchorY","rotation","isGesture","componentOrGesture","wrapWithNativeEvent","event","nativeEvent","fillOldStateChanges","previousEvent","currentEvent","isFirstEvent","oldState","UNDETERMINED","isGestureStateEvent","state","validateStateTransitions","stringify","JSON","errorMsgWithBothEvents","description","errorMsgWithCurrentEvent","BEGAN","fillMissingDefaultsFor","handlerType","handlerTag","isDiscreteHandler","fillMissingStatesTransitions","events","_events","lastEvent","length","firstEvent","shouldDuplicateFirstEvent","hasState","duplicated","unshift","shouldDuplicateLastEvent","END","FAILED","CANCELLED","push","isWithoutState","noEventsLeft","trueFn","fillEventsForCurrentState","shouldConsumeEvent","shouldTransitionToNextState","peekCurrentEvent","peekNextEvent","consumeCurrentEvent","shift","nextEvent","currentRequiredState","REQUIRED_EVENTS","currentStateIdx","eventData","shouldUseEvent","transformedEvents","ACTIVE","hasAllStates","iterations","nextRequiredState","e","getHandlerData","gesture","emitEvent","eventName","args","emit","handlerName","enabled","config","gestureHandlerComponent","props","fireGestureHandler","eventList","_","map","lastSentEvent","hasChangedState","getByGestureTestId","testID","handler","Error"],"mappings":"AAAA,OAAOA,SAAP,MAAsB,WAAtB;AACA,SAASC,kBAAT,QAAmC,cAAnC;AAEA,SAEEC,gBAFF,QAGO,iCAHP;AAIA,SAEEC,qBAFF,QAGO,sCAHP;AAWA,SAASC,WAAT,QAAyC,8BAAzC;AAOA,SAASC,mBAAT,QAAoC,8BAApC;AACA,SAEEC,oBAFF,QAGO,qCAHP;AAcA,SAEEC,qBAFF,QAGO,sCAHP;AAIA,SAEEC,cAFF,QAGO,+BAHP;AAIA,SAEEC,gBAFF,QAGO,iCAHP;AAIA,SAEEC,mBAFF,QAGO,oCAHP;AAIA,SAEEC,cAFF,QAGO,+BAHP;AAIA,SAASC,KAAT,QAAsB,UAAtB;AACA,SAASC,WAAT,EAAsBC,kBAAtB,QAAgD,UAAhD,C,CAEA;;AACA,IAAIC,SAAS,GAAG,CACdC,QADc,EAEdC,KAFc,EAGd,GAAGC,KAHW,KAIX,CACH;AACD,CAND;;AAQA,IAAI;AACF;AACAH,EAAAA,SAAS,GAAGI,OAAO,CAAC,+BAAD,CAAP,CAAyCJ,SAArD;AACD,CAHD,CAGE,OAAOK,EAAP,EAAW,CACX;AACD;;AAyBD,MAAMC,qBAA2C,GAAG;AAClD,GAACnB,gBAAD,GAAoB;AAClBoB,IAAAA,CAAC,EAAE,CADe;AAElBC,IAAAA,CAAC,EAAE,CAFe;AAGlBC,IAAAA,SAAS,EAAE,CAHO;AAIlBC,IAAAA,SAAS,EAAE,CAJO;AAKlBC,IAAAA,gBAAgB,EAAE;AALA,GAD8B;AAQlD,GAACvB,qBAAD,GAAyB;AACvBmB,IAAAA,CAAC,EAAE,CADoB;AAEvBC,IAAAA,CAAC,EAAE,CAFoB;AAGvBC,IAAAA,SAAS,EAAE,CAHY;AAIvBC,IAAAA,SAAS,EAAE,CAJY;AAKvBE,IAAAA,KAAK,EAAE,CALgB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qD,EAAAA,CAAC,GAAGvG,kBAAkB,CAACuG,CAAD,EAAIrE,mBAAJ,CAAtB;AACAqE,EAAAA,CAAC,GAAGvG,kBAAkB,CAACuG,CAAD,EAAI7D,wBAAJ,CAAtB,CAdM,CAeN;;AACA6D,EAAAA,CAAC,GAAGA,CAAC,CAACC,GAAF,CAAMzE,mBAAN,CAAJ;AAEA,QAAMuB,MAAM,GAAGiD,CAAf;AAEA,QAAM7C,UAAU,GAAGJ,MAAM,CAACuB,KAAP,EAAnB;AAEAe,EAAAA,SAAS,CAAC,6BAAD,EAAgClC,UAAhC,CAAT;AACA,MAAI+C,aAAa,GAAG/C,UAApB;;AACA,OAAK,MAAM1B,KAAX,IAAoBsB,MAApB,EAA4B;AAC1B,UAAMoD,eAAe,GACnBD,aAAa,CAACxE,WAAd,CAA0BQ,KAA1B,KAAoCT,KAAK,CAACC,WAAN,CAAkBQ,KADxD;;AAGA,QAAIiE,eAAJ,EAAqB;AACnBd,MAAAA,SAAS,CAAC,6BAAD,EAAgC5D,KAAhC,CAAT;AACD,KAFD,MAEO;AACL4D,MAAAA,SAAS,CAAC,uBAAD,EAA0B5D,KAA1B,CAAT;AACD;;AACDyE,IAAAA,aAAa,GAAGzE,KAAhB;AACD;AACF;AAED,OAAO,SAAS2E,kBAAT,CAA4BC,MAA5B,EAA4C;AACjD,QAAMC,OAAO,GAAGtH,mBAAmB,CAACqH,MAAD,CAAnC;;AACA,MAAIC,OAAO,KAAK,IAAhB,EAAsB;AACpB,UAAM,IAAIC,KAAJ,CAAW,qBAAoBF,MAAO,mBAAtC,CAAN;AACD;;AACD,SAAOC,OAAP;AACD","sourcesContent":["import invariant from 'invariant';\nimport { DeviceEventEmitter } from 'react-native';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport {\n FlingGestureHandler,\n flingHandlerName,\n} from '../handlers/FlingGestureHandler';\nimport {\n ForceTouchGestureHandler,\n forceTouchHandlerName,\n} from '../handlers/ForceTouchGestureHandler';\nimport {\n BaseGestureHandlerProps,\n GestureEvent,\n HandlerStateChangeEvent,\n} from '../handlers/gestureHandlerCommon';\nimport { FlingGesture } from '../handlers/gestures/flingGesture';\nimport { ForceTouchGesture } from '../handlers/gestures/forceTouchGesture';\nimport { BaseGesture, GestureType } from '../handlers/gestures/gesture';\nimport { LongPressGesture } from '../handlers/gestures/longPressGesture';\nimport { NativeGesture } from '../handlers/gestures/nativeGesture';\nimport { PanGesture } from '../handlers/gestures/panGesture';\nimport { PinchGesture } from '../handlers/gestures/pinchGesture';\nimport { RotationGesture } from '../handlers/gestures/rotationGesture';\nimport { TapGesture } from '../handlers/gestures/tapGesture';\nimport { findHandlerByTestID } from '../handlers/handlersRegistry';\nimport {\n LongPressGestureHandler,\n longPressHandlerName,\n} from '../handlers/LongPressGestureHandler';\nimport type {\n FlingGestureHandlerEventPayload,\n ForceTouchGestureHandlerEventPayload,\n LongPressGestureHandlerEventPayload,\n NativeViewGestureHandlerPayload,\n PanGestureHandlerEventPayload,\n PinchGestureHandlerEventPayload,\n RotationGestureHandlerEventPayload,\n TapGestureHandlerEventPayload,\n} from '../handlers/GestureHandlerEventPayload';\nimport {\n NativeViewGestureHandler,\n nativeViewHandlerName,\n} from '../handlers/NativeViewGestureHandler';\nimport {\n PanGestureHandler,\n panHandlerName,\n} from '../handlers/PanGestureHandler';\nimport {\n PinchGestureHandler,\n pinchHandlerName,\n} from '../handlers/PinchGestureHandler';\nimport {\n RotationGestureHandler,\n rotationHandlerName,\n} from '../handlers/RotationGestureHandler';\nimport {\n TapGestureHandler,\n tapHandlerName,\n} from '../handlers/TapGestureHandler';\nimport { State } from '../State';\nimport { hasProperty, withPrevAndCurrent } from '../utils';\n\n// Load fireEvent conditionally, so RNGH may be used in setups without testing-library\nlet fireEvent = (\n _element: ReactTestInstance,\n _name: string,\n ..._data: any[]\n) => {\n // NOOP\n};\n\ntry {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n fireEvent = require('@testing-library/react-native').fireEvent;\n} catch (_e) {\n // Do nothing if not available\n}\n\ntype GestureHandlerTestEvent<\n TEventPayload extends Record<string, unknown> = Record<string, unknown>\n> = (\n | GestureEvent<TEventPayload>\n | HandlerStateChangeEvent<TEventPayload>\n)['nativeEvent'];\n\ntype HandlerNames = keyof DefaultEventsMapping;\n\ntype WithNumberOfPointers<T> = {\n [P in keyof T]: T[P] & { numberOfPointers: number };\n};\ntype DefaultEventsMapping = WithNumberOfPointers<{\n [flingHandlerName]: FlingGestureHandlerEventPayload;\n [forceTouchHandlerName]: ForceTouchGestureHandlerEventPayload;\n [longPressHandlerName]: LongPressGestureHandlerEventPayload;\n [nativeViewHandlerName]: NativeViewGestureHandlerPayload;\n [panHandlerName]: PanGestureHandlerEventPayload;\n [pinchHandlerName]: PinchGestureHandlerEventPayload;\n [rotationHandlerName]: RotationGestureHandlerEventPayload;\n [tapHandlerName]: TapGestureHandlerEventPayload;\n}>;\n\nconst handlersDefaultEvents: DefaultEventsMapping = {\n [flingHandlerName]: {\n x: 0,\n y: 0,\n absoluteX: 0,\n absoluteY: 0,\n numberOfPointers: 1,\n },\n [forceTouchHandlerName]: {\n x: 0,\n y: 0,\n absoluteX: 0,\n absoluteY: 0,\n force: 1,\n numberOfPointers: 1,\n },\n [longPressHandlerName]: {\n x: 0,\n y: 0,\n absoluteX: 0,\n absoluteY: 0,\n duration: 100,\n numberOfPointers: 1,\n },\n [nativeViewHandlerName]: {\n pointerInside: true,\n numberOfPointers: 1,\n },\n [panHandlerName]: {\n x: 0,\n y: 0,\n absoluteX: 0,\n absoluteY: 0,\n translationX: 100,\n translationY: 0,\n velocityX: 3,\n velocityY: 0,\n numberOfPointers: 1,\n stylusData: undefined,\n },\n [pinchHandlerName]: {\n focalX: 0,\n focalY: 0,\n scale: 2,\n velocity: 1,\n numberOfPointers: 2,\n },\n [rotationHandlerName]: {\n anchorX: 0,\n anchorY: 0,\n rotation: 3.14,\n velocity: 2,\n numberOfPointers: 2,\n },\n [tapHandlerName]: {\n x: 0,\n y: 0,\n absoluteX: 0,\n absoluteY: 0,\n numberOfPointers: 1,\n },\n};\n\nfunction isGesture(\n componentOrGesture: ReactTestInstance | GestureType\n): componentOrGesture is GestureType {\n return componentOrGesture instanceof BaseGesture;\n}\n\ninterface WrappedGestureHandlerTestEvent {\n nativeEvent: GestureHandlerTestEvent;\n}\nfunction wrapWithNativeEvent(\n event: GestureHandlerTestEvent\n): WrappedGestureHandlerTestEvent {\n return { nativeEvent: event };\n}\n\nfunction fillOldStateChanges(\n previousEvent: GestureHandlerTestEvent | null,\n currentEvent: Omit<GestureHandlerTestEvent, 'oldState'>\n): GestureHandlerTestEvent {\n const isFirstEvent = previousEvent === null;\n if (isFirstEvent) {\n return {\n oldState: State.UNDETERMINED,\n ...currentEvent,\n } as GestureHandlerTestEvent;\n }\n\n const isGestureStateEvent = previousEvent.state !== currentEvent.state;\n if (isGestureStateEvent) {\n return {\n oldState: previousEvent?.state,\n ...currentEvent,\n } as GestureHandlerTestEvent;\n } else {\n return currentEvent as GestureHandlerTestEvent;\n }\n}\n\ntype EventWithStates = Partial<\n Pick<GestureHandlerTestEvent, 'oldState' | 'state'>\n>;\nfunction validateStateTransitions(\n previousEvent: EventWithStates | null,\n currentEvent: EventWithStates\n) {\n function stringify(event: Record<string, unknown> | null) {\n return JSON.stringify(event, null, 2);\n }\n function errorMsgWithBothEvents(description: string) {\n return `${description}, invalid event: ${stringify(\n currentEvent\n )}, previous event: ${stringify(previousEvent)}`;\n }\n\n function errorMsgWithCurrentEvent(description: string) {\n return `${description}, invalid event: ${stringify(currentEvent)}`;\n }\n\n invariant(\n hasProperty(currentEvent, 'state'),\n errorMsgWithCurrentEvent('every event must have state')\n );\n\n const isFirstEvent = previousEvent === null;\n if (isFirstEvent) {\n invariant(\n currentEvent.state === State.BEGAN,\n errorMsgWithCurrentEvent('first event must have BEGAN state')\n );\n }\n\n if (previousEvent !== null) {\n if (previousEvent.state !== currentEvent.state) {\n invariant(\n hasProperty(currentEvent, 'oldState'),\n errorMsgWithCurrentEvent(\n 'when state changes, oldState field should be present'\n )\n );\n invariant(\n currentEvent.oldState === previousEvent.state,\n errorMsgWithBothEvents(\n \"when state changes, oldState should be the same as previous event' state\"\n )\n );\n }\n }\n\n return currentEvent;\n}\n\ntype EventWithoutStates = Omit<GestureHandlerTestEvent, 'oldState' | 'state'>;\ninterface HandlerInfo {\n handlerType: HandlerNames;\n handlerTag: number;\n}\nfunction fillMissingDefaultsFor({\n handlerType,\n handlerTag,\n}: HandlerInfo): (\n event: Partial<GestureHandlerTestEvent>\n) => EventWithoutStates {\n return (event) => {\n return {\n ...handlersDefaultEvents[handlerType],\n ...event,\n handlerTag,\n };\n };\n}\n\nfunction isDiscreteHandler(handlerType: HandlerNames) {\n return (\n handlerType === 'TapGestureHandler' ||\n handlerType === 'LongPressGestureHandler'\n );\n}\n\nfunction fillMissingStatesTransitions(\n events: EventWithoutStates[],\n isDiscreteHandler: boolean\n): EventWithoutStates[] {\n type Event = EventWithoutStates | null;\n const _events = [...events];\n const lastEvent = _events[_events.length - 1] ?? null;\n const firstEvent = _events[0] ?? null;\n\n const shouldDuplicateFirstEvent =\n !isDiscreteHandler && !hasState(State.BEGAN)(firstEvent);\n if (shouldDuplicateFirstEvent) {\n const duplicated = { ...firstEvent, state: State.BEGAN };\n // @ts-ignore badly typed, property may exist and we don't want to copy it\n delete duplicated.oldState;\n _events.unshift(duplicated);\n }\n\n const shouldDuplicateLastEvent =\n !hasState(State.END)(lastEvent) ||\n !hasState(State.FAILED)(lastEvent) ||\n !hasState(State.CANCELLED)(lastEvent);\n\n if (shouldDuplicateLastEvent) {\n const duplicated = { ...lastEvent, state: State.END };\n // @ts-ignore badly typed, property may exist and we don't want to copy it\n delete duplicated.oldState;\n _events.push(duplicated);\n }\n\n function isWithoutState(event: Event) {\n return event !== null && !hasProperty(event, 'state');\n }\n function hasState(state: State) {\n return (event: Event) => event !== null && event.state === state;\n }\n function noEventsLeft(event: Event) {\n return event === null;\n }\n\n function trueFn() {\n return true;\n }\n interface Args {\n shouldConsumeEvent?: (event: Event) => boolean;\n shouldTransitionToNextState?: (nextEvent: Event) => boolean;\n }\n function fillEventsForCurrentState({\n shouldConsumeEvent = trueFn,\n shouldTransitionToNextState = trueFn,\n }: Args) {\n function peekCurrentEvent(): Event {\n return _events[0] ?? null;\n }\n function peekNextEvent(): Event {\n return _events[1] ?? null;\n }\n function consumeCurrentEvent() {\n _events.shift();\n }\n const currentEvent = peekCurrentEvent();\n const nextEvent = peekNextEvent();\n const currentRequiredState = REQUIRED_EVENTS[currentStateIdx];\n\n let eventData = {};\n const shouldUseEvent = shouldConsumeEvent(currentEvent);\n if (shouldUseEvent) {\n eventData = currentEvent!;\n consumeCurrentEvent();\n }\n transformedEvents.push({ state: currentRequiredState, ...eventData });\n if (shouldTransitionToNextState(nextEvent)) {\n currentStateIdx++;\n }\n }\n\n const REQUIRED_EVENTS = [State.BEGAN, State.ACTIVE, State.END];\n\n let currentStateIdx = 0;\n const transformedEvents: EventWithoutStates[] = [];\n let hasAllStates;\n let iterations = 0;\n do {\n const nextRequiredState = REQUIRED_EVENTS[currentStateIdx];\n if (nextRequiredState === State.BEGAN) {\n fillEventsForCurrentState({\n shouldConsumeEvent: (e: Event) =>\n isWithoutState(e) || hasState(State.BEGAN)(e),\n });\n } else if (nextRequiredState === State.ACTIVE) {\n const shouldConsumeEvent = (e: Event) =>\n isWithoutState(e) || hasState(State.ACTIVE)(e);\n const shouldTransitionToNextState = (nextEvent: Event) =>\n noEventsLeft(nextEvent) ||\n hasState(State.END)(nextEvent) ||\n hasState(State.FAILED)(nextEvent) ||\n hasState(State.CANCELLED)(nextEvent);\n\n fillEventsForCurrentState({\n shouldConsumeEvent,\n shouldTransitionToNextState,\n });\n } else if (nextRequiredState === State.END) {\n fillEventsForCurrentState({});\n }\n hasAllStates = currentStateIdx === REQUIRED_EVENTS.length;\n\n invariant(\n iterations++ <= 500,\n 'exceeded max number of iterations, please report a bug in RNGH repository with your test case'\n );\n } while (!hasAllStates);\n\n return transformedEvents;\n}\n\ntype EventEmitter = (\n eventName: string,\n args: { nativeEvent: GestureHandlerTestEvent }\n) => void;\ninterface HandlerData {\n emitEvent: EventEmitter;\n handlerType: HandlerNames;\n handlerTag: number;\n enabled: boolean | undefined;\n}\nfunction getHandlerData(\n componentOrGesture: ReactTestInstance | GestureType\n): HandlerData {\n if (isGesture(componentOrGesture)) {\n const gesture = componentOrGesture;\n return {\n emitEvent: (eventName, args) => {\n DeviceEventEmitter.emit(eventName, args.nativeEvent);\n },\n handlerType: gesture.handlerName as HandlerNames,\n handlerTag: gesture.handlerTag,\n enabled: gesture.config.enabled,\n };\n }\n const gestureHandlerComponent = componentOrGesture;\n return {\n emitEvent: (eventName, args) => {\n fireEvent(gestureHandlerComponent, eventName, args);\n },\n handlerType: gestureHandlerComponent.props.handlerType as HandlerNames,\n handlerTag: gestureHandlerComponent.props.handlerTag as number,\n enabled: gestureHandlerComponent.props.enabled,\n };\n}\ntype AllGestures =\n | TapGesture\n | PanGesture\n | LongPressGesture\n | RotationGesture\n | PinchGesture\n | FlingGesture\n | ForceTouchGesture\n | NativeGesture;\n\ntype AllHandlers =\n | TapGestureHandler\n | PanGestureHandler\n | LongPressGestureHandler\n | RotationGestureHandler\n | PinchGestureHandler\n | FlingGestureHandler\n | ForceTouchGestureHandler\n | NativeViewGestureHandler;\n\n// prettier-ignore\ntype ClassComponentConstructor<P> = new (props: P) => React.Component<P, any, any>;\n\ntype ExtractPayloadFromProps<T> = T extends BaseGestureHandlerProps<\n infer TPayload\n>\n ? TPayload\n : never;\n\ntype ExtractConfig<T> = T extends BaseGesture<infer TGesturePayload>\n ? TGesturePayload\n : T extends ClassComponentConstructor<infer THandlerProps>\n ? ExtractPayloadFromProps<THandlerProps>\n : Record<string, unknown>;\n\nexport function fireGestureHandler<THandler extends AllGestures | AllHandlers>(\n componentOrGesture: ReactTestInstance | GestureType,\n eventList: Partial<GestureHandlerTestEvent<ExtractConfig<THandler>>>[] = []\n): void {\n const { emitEvent, handlerType, handlerTag, enabled } =\n getHandlerData(componentOrGesture);\n\n if (enabled === false) {\n return;\n }\n\n let _ = fillMissingStatesTransitions(\n eventList,\n isDiscreteHandler(handlerType)\n );\n _ = _.map(fillMissingDefaultsFor({ handlerTag, handlerType }));\n _ = withPrevAndCurrent(_, fillOldStateChanges);\n _ = withPrevAndCurrent(_, validateStateTransitions);\n // @ts-ignore TODO\n _ = _.map(wrapWithNativeEvent);\n\n const events = _ as unknown as WrappedGestureHandlerTestEvent[];\n\n const firstEvent = events.shift()!;\n\n emitEvent('onGestureHandlerStateChange', firstEvent);\n let lastSentEvent = firstEvent;\n for (const event of events) {\n const hasChangedState =\n lastSentEvent.nativeEvent.state !== event.nativeEvent.state;\n\n if (hasChangedState) {\n emitEvent('onGestureHandlerStateChange', event);\n } else {\n emitEvent('onGestureHandlerEvent', event);\n }\n lastSentEvent = event;\n }\n}\n\nexport function getByGestureTestId(testID: string) {\n const handler = findHandlerByTestID(testID);\n if (handler === null) {\n throw new Error(`Handler with id: '${testID}' cannot be found`);\n }\n return handler;\n}\n"]}
@@ -1,3 +1,6 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import React from 'react';
1
4
  import { TouchableHighlight, TouchableNativeFeedback, TouchableOpacity, TouchableWithoutFeedback, ScrollView, FlatList, Switch, TextInput, DrawerLayoutAndroid, View } from 'react-native';
2
5
  import { State } from './State';
3
6
  import { Directions } from './Directions';
@@ -19,9 +22,16 @@ const LongPressGestureHandler = View;
19
22
  const PinchGestureHandler = View;
20
23
  const RotationGestureHandler = View;
21
24
  const FlingGestureHandler = View;
22
- const RawButton = TouchableNativeFeedback;
23
- const BaseButton = TouchableNativeFeedback;
24
- const RectButton = TouchableNativeFeedback;
25
+
26
+ const RawButton = ({
27
+ enabled,
28
+ ...rest
29
+ }) => /*#__PURE__*/React.createElement(TouchableNativeFeedback, _extends({
30
+ disabled: !enabled
31
+ }, rest), /*#__PURE__*/React.createElement(View, null));
32
+
33
+ const BaseButton = RawButton;
34
+ const RectButton = RawButton;
25
35
  const BorderlessButton = TouchableNativeFeedback;
26
36
  export default {
27
37
  TouchableHighlight,
@@ -1 +1 @@
1
- {"version":3,"sources":["mocks.ts"],"names":["TouchableHighlight","TouchableNativeFeedback","TouchableOpacity","TouchableWithoutFeedback","ScrollView","FlatList","Switch","TextInput","DrawerLayoutAndroid","View","State","Directions","NOOP","PanGestureHandler","attachGestureHandler","createGestureHandler","dropGestureHandler","updateGestureHandler","flushOperations","install","NativeViewGestureHandler","TapGestureHandler","ForceTouchGestureHandler","LongPressGestureHandler","PinchGestureHandler","RotationGestureHandler","FlingGestureHandler","RawButton","BaseButton","RectButton","BorderlessButton"],"mappings":"AAAA,SACEA,kBADF,EAEEC,uBAFF,EAGEC,gBAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,QANF,EAOEC,MAPF,EAQEC,SARF,EASEC,mBATF,EAUEC,IAVF,QAWO,cAXP;AAYA,SAASC,KAAT,QAAsB,SAAtB;AACA,SAASC,UAAT,QAA2B,cAA3B;;AAEA,MAAMC,IAAI,GAAG,MAAM,CACjB;AACD,CAFD;;AAGA,MAAMC,iBAAiB,GAAGJ,IAA1B;AACA,MAAMK,oBAAoB,GAAGF,IAA7B;AACA,MAAMG,oBAAoB,GAAGH,IAA7B;AACA,MAAMI,kBAAkB,GAAGJ,IAA3B;AACA,MAAMK,oBAAoB,GAAGL,IAA7B;AACA,MAAMM,eAAe,GAAGN,IAAxB;AACA,MAAMO,OAAO,GAAGP,IAAhB;AACA,MAAMQ,wBAAwB,GAAGX,IAAjC;AACA,MAAMY,iBAAiB,GAAGZ,IAA1B;AACA,MAAMa,wBAAwB,GAAGb,IAAjC;AACA,MAAMc,uBAAuB,GAAGd,IAAhC;AACA,MAAMe,mBAAmB,GAAGf,IAA5B;AACA,MAAMgB,sBAAsB,GAAGhB,IAA/B;AACA,MAAMiB,mBAAmB,GAAGjB,IAA5B;AACA,MAAMkB,SAAS,GAAG1B,uBAAlB;AACA,MAAM2B,UAAU,GAAG3B,uBAAnB;AACA,MAAM4B,UAAU,GAAG5B,uBAAnB;AACA,MAAM6B,gBAAgB,GAAG7B,uBAAzB;AAEA,eAAe;AACbD,EAAAA,kBADa;AAEbC,EAAAA,uBAFa;AAGbC,EAAAA,gBAHa;AAIbC,EAAAA,wBAJa;AAKbC,EAAAA,UALa;AAMbC,EAAAA,QANa;AAObC,EAAAA,MAPa;AAQbC,EAAAA,SARa;AASbC,EAAAA,mBATa;AAUbY,EAAAA,wBAVa;AAWbC,EAAAA,iBAXa;AAYbC,EAAAA,wBAZa;AAabC,EAAAA,uBAba;AAcbC,EAAAA,mBAda;AAebC,EAAAA,sBAfa;AAgBbC,EAAAA,mBAhBa;AAiBbC,EAAAA,SAjBa;AAkBbC,EAAAA,UAlBa;AAmBbC,EAAAA,UAnBa;AAoBbC,EAAAA,gBApBa;AAqBbjB,EAAAA,iBArBa;AAsBbC,EAAAA,oBAtBa;AAuBbC,EAAAA,oBAvBa;AAwBbC,EAAAA,kBAxBa;AAyBbC,EAAAA,oBAzBa;AA0BbC,EAAAA,eA1Ba;AA2BbC,EAAAA,OA3Ba;AA4Bb;AACAR,EAAAA,UA7Ba;AA8BbD,EAAAA;AA9Ba,CAAf","sourcesContent":["import {\n TouchableHighlight,\n TouchableNativeFeedback,\n TouchableOpacity,\n TouchableWithoutFeedback,\n ScrollView,\n FlatList,\n Switch,\n TextInput,\n DrawerLayoutAndroid,\n View,\n} from 'react-native';\nimport { State } from './State';\nimport { Directions } from './Directions';\n\nconst NOOP = () => {\n // Do nothing\n};\nconst PanGestureHandler = View;\nconst attachGestureHandler = NOOP;\nconst createGestureHandler = NOOP;\nconst dropGestureHandler = NOOP;\nconst updateGestureHandler = NOOP;\nconst flushOperations = NOOP;\nconst install = NOOP;\nconst NativeViewGestureHandler = View;\nconst TapGestureHandler = View;\nconst ForceTouchGestureHandler = View;\nconst LongPressGestureHandler = View;\nconst PinchGestureHandler = View;\nconst RotationGestureHandler = View;\nconst FlingGestureHandler = View;\nconst RawButton = TouchableNativeFeedback;\nconst BaseButton = TouchableNativeFeedback;\nconst RectButton = TouchableNativeFeedback;\nconst BorderlessButton = TouchableNativeFeedback;\n\nexport default {\n TouchableHighlight,\n TouchableNativeFeedback,\n TouchableOpacity,\n TouchableWithoutFeedback,\n ScrollView,\n FlatList,\n Switch,\n TextInput,\n DrawerLayoutAndroid,\n NativeViewGestureHandler,\n TapGestureHandler,\n ForceTouchGestureHandler,\n LongPressGestureHandler,\n PinchGestureHandler,\n RotationGestureHandler,\n FlingGestureHandler,\n RawButton,\n BaseButton,\n RectButton,\n BorderlessButton,\n PanGestureHandler,\n attachGestureHandler,\n createGestureHandler,\n dropGestureHandler,\n updateGestureHandler,\n flushOperations,\n install,\n // Probably can be removed\n Directions,\n State,\n} as const;\n"]}
1
+ {"version":3,"sources":["mocks.tsx"],"names":["React","TouchableHighlight","TouchableNativeFeedback","TouchableOpacity","TouchableWithoutFeedback","ScrollView","FlatList","Switch","TextInput","DrawerLayoutAndroid","View","State","Directions","NOOP","PanGestureHandler","attachGestureHandler","createGestureHandler","dropGestureHandler","updateGestureHandler","flushOperations","install","NativeViewGestureHandler","TapGestureHandler","ForceTouchGestureHandler","LongPressGestureHandler","PinchGestureHandler","RotationGestureHandler","FlingGestureHandler","RawButton","enabled","rest","BaseButton","RectButton","BorderlessButton"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SACEC,kBADF,EAEEC,uBAFF,EAGEC,gBAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,QANF,EAOEC,MAPF,EAQEC,SARF,EASEC,mBATF,EAUEC,IAVF,QAWO,cAXP;AAYA,SAASC,KAAT,QAAsB,SAAtB;AACA,SAASC,UAAT,QAA2B,cAA3B;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAC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AAqBbnB,EAAAA,iBArBa;AAsBbC,EAAAA,oBAtBa;AAuBbC,EAAAA,oBAvBa;AAwBbC,EAAAA,kBAxBa;AAyBbC,EAAAA,oBAzBa;AA0BbC,EAAAA,eA1Ba;AA2BbC,EAAAA,OA3Ba;AA4Bb;AACAR,EAAAA,UA7Ba;AA8BbD,EAAAA;AA9Ba,CAAf","sourcesContent":["import React from 'react';\nimport {\n TouchableHighlight,\n TouchableNativeFeedback,\n TouchableOpacity,\n TouchableWithoutFeedback,\n ScrollView,\n FlatList,\n Switch,\n TextInput,\n DrawerLayoutAndroid,\n View,\n} from 'react-native';\nimport { State } from './State';\nimport { Directions } from './Directions';\n\nconst NOOP = () => {\n // Do nothing\n};\nconst PanGestureHandler = View;\nconst attachGestureHandler = NOOP;\nconst createGestureHandler = NOOP;\nconst dropGestureHandler = NOOP;\nconst updateGestureHandler = NOOP;\nconst flushOperations = NOOP;\nconst install = NOOP;\nconst NativeViewGestureHandler = View;\nconst TapGestureHandler = View;\nconst ForceTouchGestureHandler = View;\nconst LongPressGestureHandler = View;\nconst PinchGestureHandler = View;\nconst RotationGestureHandler = View;\nconst FlingGestureHandler = View;\nconst RawButton = ({ enabled, ...rest }: any) => (\n <TouchableNativeFeedback disabled={!enabled} {...rest}>\n <View />\n </TouchableNativeFeedback>\n);\nconst BaseButton = RawButton;\nconst RectButton = RawButton;\nconst BorderlessButton = TouchableNativeFeedback;\n\nexport default {\n TouchableHighlight,\n TouchableNativeFeedback,\n TouchableOpacity,\n TouchableWithoutFeedback,\n ScrollView,\n FlatList,\n Switch,\n TextInput,\n DrawerLayoutAndroid,\n NativeViewGestureHandler,\n TapGestureHandler,\n ForceTouchGestureHandler,\n LongPressGestureHandler,\n PinchGestureHandler,\n RotationGestureHandler,\n FlingGestureHandler,\n RawButton,\n BaseButton,\n RectButton,\n BorderlessButton,\n PanGestureHandler,\n attachGestureHandler,\n createGestureHandler,\n dropGestureHandler,\n updateGestureHandler,\n flushOperations,\n install,\n // Probably can be removed\n Directions,\n State,\n} as const;\n"]}
@@ -79,4 +79,5 @@ export function deepEqual(obj1, obj2) {
79
79
 
80
80
  return true;
81
81
  }
82
+ export const INT32_MAX = 2 ** 31 - 1;
82
83
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["utils.ts"],"names":["toArray","object","Array","isArray","withPrevAndCurrent","array","mapFn","previousArr","currentArr","transformedArr","forEach","current","i","previous","transformed","push","hasProperty","key","Object","prototype","hasOwnProperty","call","isJestEnv","global","process","env","JEST_WORKER_ID","tagMessage","msg","isFabric","nativeFabricUIManager","isRemoteDebuggingEnabled","localGlobal","nativeCallSyncHook","__REMOTEDEV__","RN$Bridgeless","deepEqual","obj1","obj2","keys1","keys","keys2","length","includes"],"mappings":"AAAA,OAAO,SAASA,OAAT,CAAoBC,MAApB,EAA0C;AAC/C,MAAI,CAACC,KAAK,CAACC,OAAN,CAAcF,MAAd,CAAL,EAA4B;AAC1B,WAAO,CAACA,MAAD,CAAP;AACD;;AAED,SAAOA,MAAP;AACD;AAMD,OAAO,SAASG,kBAAT,CACLC,KADK,EAELC,KAFK,EAGU;AACf,QAAMC,WAAmC,GAAG,CAAC,IAAD,CAA5C;AACA,QAAMC,UAAU,GAAG,CAAC,GAAGH,KAAJ,CAAnB;AACA,QAAMI,cAA6B,GAAG,EAAtC;AACAD,EAAAA,UAAU,CAACE,OAAX,CAAmB,CAACC,OAAD,EAAUC,CAAV,KAAgB;AACjC;AACA;AACA;AACA,UAAMC,QAAQ,GAAGN,WAAW,CAACK,CAAD,CAA5B;AACA,UAAME,WAAW,GAAGR,KAAK,CAACO,QAAD,EAAWF,OAAX,CAAzB;AACAJ,IAAAA,WAAW,CAACQ,IAAZ,CAAiBD,WAAjB;AACAL,IAAAA,cAAc,CAACM,IAAf,CAAoBD,WAApB;AACD,GARD;AASA,SAAOL,cAAP;AACD,C,CAED;;AACA,OAAO,SAASO,WAAT,CAAqBf,MAArB,EAAqCgB,GAArC,EAAkD;A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AAI,CAACE,KAAK,CAACE,QAAN,CAAe1B,GAAf,CAAD,IAAwB,CAACmB,SAAS,CAACC,IAAI,CAACpB,GAAD,CAAL,EAAYqB,IAAI,CAACrB,GAAD,CAAhB,CAAtC,EAA8D;AAC5D,aAAO,KAAP;AACD;AACF;;AAED,SAAO,IAAP;AACD","sourcesContent":["export function toArray<T>(object: T | T[]): T[] {\n if (!Array.isArray(object)) {\n return [object];\n }\n\n return object;\n}\n\nexport type withPrevAndCurrentMapFn<T, Transformed> = (\n previous: Transformed | null,\n current: T\n) => Transformed;\nexport function withPrevAndCurrent<T, Transformed>(\n array: T[],\n mapFn: withPrevAndCurrentMapFn<T, Transformed>\n): Transformed[] {\n const previousArr: (null | Transformed)[] = [null];\n const currentArr = [...array];\n const transformedArr: Transformed[] = [];\n currentArr.forEach((current, i) => {\n // This type cast is fine and solves problem mentioned in https://github.com/software-mansion/react-native-gesture-handler/pull/2867 (namely that `previous` can be undefined).\n // Unfortunately, linter on our CI does not allow this type of casting as it is unnecessary. To bypass that we use eslint-disable.\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const previous = previousArr[i] as Transformed | null;\n const transformed = mapFn(previous, current);\n previousArr.push(transformed);\n transformedArr.push(transformed);\n });\n return transformedArr;\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function hasProperty(object: object, key: string) {\n return Object.prototype.hasOwnProperty.call(object, key);\n}\n\nexport function isJestEnv(): boolean {\n // @ts-ignore Do not use `@types/node` because it will prioritise Node types over RN types which breaks the types (ex. setTimeout) in React Native projects.\n return hasProperty(global, 'process') && !!process.env.JEST_WORKER_ID;\n}\n\nexport function tagMessage(msg: string) {\n return `[react-native-gesture-handler] ${msg}`;\n}\n\n// Helper method to check whether Fabric is enabled, however global.nativeFabricUIManager\n// may not be initialized before the first render\nexport function isFabric(): boolean {\n // @ts-expect-error nativeFabricUIManager is not yet included in the RN types\n return !!global?.nativeFabricUIManager;\n}\n\nexport function isRemoteDebuggingEnabled(): boolean {\n // react-native-reanimated checks if in remote debugging in the same way\n // @ts-ignore global is available but node types are not included\n const localGlobal = global as any;\n return (\n (!localGlobal.nativeCallSyncHook || !!localGlobal.__REMOTEDEV__) &&\n !localGlobal.RN$Bridgeless\n );\n}\n\n/**\n * Recursively compares two objects for deep equality.\n *\n * **Note:** This function does not support cyclic references.\n *\n * @param obj1 - The first object to compare.\n * @param obj2 - The second object to compare.\n * @returns `true` if the objects are deeply equal, `false` otherwise.\n */\nexport function deepEqual(obj1: any, obj2: any) {\n if (obj1 === obj2) {\n return true;\n }\n\n if (\n typeof obj1 !== 'object' ||\n typeof obj2 !== 'object' ||\n obj1 === null ||\n obj2 === null\n ) {\n return false;\n }\n\n const keys1 = Object.keys(obj1);\n const keys2 = Object.keys(obj2);\n\n if (keys1.length !== keys2.length) {\n return false;\n }\n\n for (const key of keys1) {\n if (!keys2.includes(key) || !deepEqual(obj1[key], obj2[key])) {\n return false;\n }\n }\n\n return true;\n}\n"]}
1
+ {"version":3,"sources":["utils.ts"],"names":["toArray","object","Array","isArray","withPrevAndCurrent","array","mapFn","previousArr","currentArr","transformedArr","forEach","current","i","previous","transformed","push","hasProperty","key","Object","prototype","hasOwnProperty","call","isJestEnv","global","process","env","JEST_WORKER_ID","tagMessage","msg","isFabric","nativeFabricUIManager","isRemoteDebuggingEnabled","localGlobal","nativeCallSyncHook","__REMOTEDEV__","RN$Bridgeless","deepEqual","obj1","obj2","keys1","keys","keys2","length","includes","INT32_MAX"],"mappings":"AAAA,OAAO,SAASA,OAAT,CAAoBC,MAApB,EAA0C;AAC/C,MAAI,CAACC,KAAK,CAACC,OAAN,CAAcF,MAAd,CAAL,EAA4B;AAC1B,WAAO,CAACA,MAAD,CAAP;AACD;;AAED,SAAOA,MAAP;AACD;AAMD,OAAO,SAASG,kBAAT,CACLC,KADK,EAELC,KAFK,EAGU;AACf,QAAMC,WAAmC,GAAG,CAAC,IAAD,CAA5C;AACA,QAAMC,UAAU,GAAG,CAAC,GAAGH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,WAAO,IAAP;AACD;;AAED,MACE,OAAOD,IAAP,KAAgB,QAAhB,IACA,OAAOC,IAAP,KAAgB,QADhB,IAEAD,IAAI,KAAK,IAFT,IAGAC,IAAI,KAAK,IAJX,EAKE;AACA,WAAO,KAAP;AACD;;AAED,QAAMC,KAAK,GAAGrB,MAAM,CAACsB,IAAP,CAAYH,IAAZ,CAAd;AACA,QAAMI,KAAK,GAAGvB,MAAM,CAACsB,IAAP,CAAYF,IAAZ,CAAd;;AAEA,MAAIC,KAAK,CAACG,MAAN,KAAiBD,KAAK,CAACC,MAA3B,EAAmC;AACjC,WAAO,KAAP;AACD;;AAED,OAAK,MAAMzB,GAAX,IAAkBsB,KAAlB,EAAyB;AACvB,QAAI,CAACE,KAAK,CAACE,QAAN,CAAe1B,GAAf,CAAD,IAAwB,CAACmB,SAAS,CAACC,IAAI,CAACpB,GAAD,CAAL,EAAYqB,IAAI,CAACrB,GAAD,CAAhB,CAAtC,EAA8D;AAC5D,aAAO,KAAP;AACD;AACF;;AAED,SAAO,IAAP;AACD;AAED,OAAO,MAAM2B,SAAS,GAAG,KAAK,EAAL,GAAU,CAA5B","sourcesContent":["export function toArray<T>(object: T | T[]): T[] {\n if (!Array.isArray(object)) {\n return [object];\n }\n\n return object;\n}\n\nexport type withPrevAndCurrentMapFn<T, Transformed> = (\n previous: Transformed | null,\n current: T\n) => Transformed;\nexport function withPrevAndCurrent<T, Transformed>(\n array: T[],\n mapFn: withPrevAndCurrentMapFn<T, Transformed>\n): Transformed[] {\n const previousArr: (null | Transformed)[] = [null];\n const currentArr = [...array];\n const transformedArr: Transformed[] = [];\n currentArr.forEach((current, i) => {\n // This type cast is fine and solves problem mentioned in https://github.com/software-mansion/react-native-gesture-handler/pull/2867 (namely that `previous` can be undefined).\n // Unfortunately, linter on our CI does not allow this type of casting as it is unnecessary. To bypass that we use eslint-disable.\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const previous = previousArr[i] as Transformed | null;\n const transformed = mapFn(previous, current);\n previousArr.push(transformed);\n transformedArr.push(transformed);\n });\n return transformedArr;\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function hasProperty(object: object, key: string) {\n return Object.prototype.hasOwnProperty.call(object, key);\n}\n\nexport function isJestEnv(): boolean {\n // @ts-ignore Do not use `@types/node` because it will prioritise Node types over RN types which breaks the types (ex. setTimeout) in React Native projects.\n return hasProperty(global, 'process') && !!process.env.JEST_WORKER_ID;\n}\n\nexport function tagMessage(msg: string) {\n return `[react-native-gesture-handler] ${msg}`;\n}\n\n// Helper method to check whether Fabric is enabled, however global.nativeFabricUIManager\n// may not be initialized before the first render\nexport function isFabric(): boolean {\n // @ts-expect-error nativeFabricUIManager is not yet included in the RN types\n return !!global?.nativeFabricUIManager;\n}\n\nexport function isRemoteDebuggingEnabled(): boolean {\n // react-native-reanimated checks if in remote debugging in the same way\n // @ts-ignore global is available but node types are not included\n const localGlobal = global as any;\n return (\n (!localGlobal.nativeCallSyncHook || !!localGlobal.__REMOTEDEV__) &&\n !localGlobal.RN$Bridgeless\n );\n}\n\n/**\n * Recursively compares two objects for deep equality.\n *\n * **Note:** This function does not support cyclic references.\n *\n * @param obj1 - The first object to compare.\n * @param obj2 - The second object to compare.\n * @returns `true` if the objects are deeply equal, `false` otherwise.\n */\nexport function deepEqual(obj1: any, obj2: any) {\n if (obj1 === obj2) {\n return true;\n }\n\n if (\n typeof obj1 !== 'object' ||\n typeof obj2 !== 'object' ||\n obj1 === null ||\n obj2 === null\n ) {\n return false;\n }\n\n const keys1 = Object.keys(obj1);\n const keys2 = Object.keys(obj2);\n\n if (keys1.length !== keys2.length) {\n return false;\n }\n\n for (const key of keys1) {\n if (!keys2.includes(key) || !deepEqual(obj1[key], obj2[key])) {\n return false;\n }\n }\n\n return true;\n}\n\nexport const INT32_MAX = 2 ** 31 - 1;\n"]}
@@ -1,3 +1,3 @@
1
1
  export const DEFAULT_TOUCH_SLOP = 15;
2
- export const MINIMAL_FLING_VELOCITY = 0.1;
2
+ export const MINIMAL_RECOGNIZABLE_MAGNITUDE = 0.1;
3
3
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["constants.ts"],"names":["DEFAULT_TOUCH_SLOP","MINIMAL_FLING_VELOCITY"],"mappings":"AAAA,OAAO,MAAMA,kBAAkB,GAAG,EAA3B;AACP,OAAO,MAAMC,sBAAsB,GAAG,GAA/B","sourcesContent":["export const DEFAULT_TOUCH_SLOP = 15;\nexport const MINIMAL_FLING_VELOCITY = 0.1;\n"]}
1
+ {"version":3,"sources":["constants.ts"],"names":["DEFAULT_TOUCH_SLOP","MINIMAL_RECOGNIZABLE_MAGNITUDE"],"mappings":"AAAA,OAAO,MAAMA,kBAAkB,GAAG,EAA3B;AACP,OAAO,MAAMC,8BAA8B,GAAG,GAAvC","sourcesContent":["export const DEFAULT_TOUCH_SLOP = 15;\nexport const MINIMAL_RECOGNIZABLE_MAGNITUDE = 0.1;\n"]}
@@ -380,8 +380,6 @@ export default class GestureHandler {
380
380
  }
381
381
 
382
382
  transformTouchEvent(event) {
383
- var _event$touchEventType;
384
-
385
383
  const rect = this.delegate.measureView();
386
384
  const all = [];
387
385
  const changed = [];
@@ -462,7 +460,7 @@ export default class GestureHandler {
462
460
  nativeEvent: {
463
461
  handlerTag: this.handlerTag,
464
462
  state: this.currentState,
465
- eventType: (_event$touchEventType = event.touchEventType) !== null && _event$touchEventType !== void 0 ? _event$touchEventType : eventType,
463
+ eventType: eventType,
466
464
  changedTouches: changed,
467
465
  allTouches: all,
468
466
  numberOfTouches: numberOfTouches,
@@ -541,6 +539,7 @@ export default class GestureHandler {
541
539
  ...props
542
540
  };
543
541
  this.enabled = enabled;
542
+ this.delegate.onEnabledChange(enabled);
544
543
 
545
544
  if (this.config.shouldCancelWhenOutside !== undefined) {
546
545
  this.setShouldCancelWhenOutside(this.config.shouldCancelWhenOutside);