react-native-gesture-handler 2.3.2 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/RNGestureHandler.podspec +2 -1
  2. package/android/build.gradle +38 -6
  3. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +14 -2
  4. package/android/noreanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt +10 -0
  5. package/android/reanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt +17 -0
  6. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.kt +3 -41
  7. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +6 -0
  8. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +10 -54
  9. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +2 -0
  10. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt +6 -0
  11. package/ios/RNGHTouchEventType.h +9 -0
  12. package/ios/RNGestureHandler.h +2 -2
  13. package/ios/RNGestureHandler.m +21 -8
  14. package/ios/RNGestureHandlerButton.h +1 -0
  15. package/ios/RNGestureHandlerButton.m +9 -1
  16. package/ios/RNGestureHandlerButtonComponentView.mm +14 -1
  17. package/ios/RNGestureHandlerButtonManager.m +4 -1
  18. package/ios/RNGestureHandlerEvents.h +2 -2
  19. package/ios/RNGestureHandlerEvents.m +2 -2
  20. package/ios/RNGestureHandlerManager.h +2 -0
  21. package/ios/RNGestureHandlerManager.mm +30 -20
  22. package/ios/RNGestureHandlerModule.mm +18 -0
  23. package/ios/RNGestureHandlerPointerTracker.h +2 -2
  24. package/ios/RNGestureHandlerPointerTracker.m +9 -6
  25. package/ios/RNGestureHandlerRegistry.h +1 -0
  26. package/ios/RNGestureHandlerRegistry.m +10 -0
  27. package/lib/commonjs/GestureHandlerRootView.android.js +7 -1
  28. package/lib/commonjs/GestureHandlerRootView.android.js.map +1 -1
  29. package/lib/commonjs/GestureHandlerRootView.js +6 -0
  30. package/lib/commonjs/GestureHandlerRootView.js.map +1 -1
  31. package/lib/commonjs/GestureHandlerRootView.web.js +19 -0
  32. package/lib/commonjs/GestureHandlerRootView.web.js.map +1 -0
  33. package/lib/commonjs/RNGestureHandlerModule.js +5 -0
  34. package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
  35. package/lib/commonjs/RNGestureHandlerModule.web.js +4 -1
  36. package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
  37. package/lib/commonjs/{EventType.js → TouchEventType.js} +4 -4
  38. package/lib/commonjs/TouchEventType.js.map +1 -0
  39. package/lib/commonjs/components/DrawerLayout.js +38 -11
  40. package/lib/commonjs/components/DrawerLayout.js.map +1 -1
  41. package/lib/commonjs/components/GestureButtons.js.map +1 -1
  42. package/lib/commonjs/components/GestureHandlerButton.js +1 -1
  43. package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
  44. package/lib/commonjs/components/touchables/GenericTouchable.js +2 -0
  45. package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
  46. package/lib/commonjs/fabric/RNGestureHandlerButtonNativeComponent.js +4 -6
  47. package/lib/commonjs/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -1
  48. package/lib/commonjs/fabric/RNGestureHandlerRootViewNativeComponent.js +4 -6
  49. package/lib/commonjs/fabric/RNGestureHandlerRootViewNativeComponent.js.map +1 -1
  50. package/lib/commonjs/getShadowNodeFromRef.js +12 -9
  51. package/lib/commonjs/getShadowNodeFromRef.js.map +1 -1
  52. package/lib/commonjs/handlers/ForceTouchGestureHandler.js +2 -1
  53. package/lib/commonjs/handlers/ForceTouchGestureHandler.js.map +1 -1
  54. package/lib/commonjs/handlers/createHandler.js +25 -20
  55. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  56. package/lib/commonjs/handlers/gestureHandlerCommon.js +18 -1
  57. package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
  58. package/lib/commonjs/handlers/gestures/GestureDetector.js +120 -80
  59. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
  60. package/lib/commonjs/handlers/gestures/eventReceiver.js +6 -5
  61. package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -1
  62. package/lib/commonjs/handlers/gestures/gesture.js +24 -4
  63. package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
  64. package/lib/commonjs/init.js +10 -1
  65. package/lib/commonjs/init.js.map +1 -1
  66. package/lib/commonjs/mocks.js +2 -0
  67. package/lib/commonjs/mocks.js.map +1 -1
  68. package/lib/commonjs/utils.js +23 -1
  69. package/lib/commonjs/utils.js.map +1 -1
  70. package/lib/commonjs/web/GestureHandler.js +4 -1
  71. package/lib/commonjs/web/GestureHandler.js.map +1 -1
  72. package/lib/commonjs/web/utils.js.map +1 -1
  73. package/lib/module/GestureHandlerRootView.android.js +7 -2
  74. package/lib/module/GestureHandlerRootView.android.js.map +1 -1
  75. package/lib/module/GestureHandlerRootView.js +5 -0
  76. package/lib/module/GestureHandlerRootView.js.map +1 -1
  77. package/lib/module/GestureHandlerRootView.web.js +6 -0
  78. package/lib/module/GestureHandlerRootView.web.js.map +1 -0
  79. package/lib/module/RNGestureHandlerModule.js +5 -0
  80. package/lib/module/RNGestureHandlerModule.js.map +1 -1
  81. package/lib/module/RNGestureHandlerModule.web.js +4 -1
  82. package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
  83. package/lib/module/{EventType.js → TouchEventType.js} +2 -2
  84. package/lib/module/TouchEventType.js.map +1 -0
  85. package/lib/module/components/DrawerLayout.js +38 -11
  86. package/lib/module/components/DrawerLayout.js.map +1 -1
  87. package/lib/module/components/GestureButtons.js.map +1 -1
  88. package/lib/module/components/GestureHandlerButton.js +2 -2
  89. package/lib/module/components/GestureHandlerButton.js.map +1 -1
  90. package/lib/module/components/touchables/GenericTouchable.js +2 -0
  91. package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
  92. package/lib/module/fabric/RNGestureHandlerButtonNativeComponent.js +5 -7
  93. package/lib/module/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -1
  94. package/lib/module/fabric/RNGestureHandlerRootViewNativeComponent.js +5 -8
  95. package/lib/module/fabric/RNGestureHandlerRootViewNativeComponent.js.map +1 -1
  96. package/lib/module/getShadowNodeFromRef.js +11 -8
  97. package/lib/module/getShadowNodeFromRef.js.map +1 -1
  98. package/lib/module/handlers/ForceTouchGestureHandler.js +1 -1
  99. package/lib/module/handlers/ForceTouchGestureHandler.js.map +1 -1
  100. package/lib/module/handlers/createHandler.js +25 -22
  101. package/lib/module/handlers/createHandler.js.map +1 -1
  102. package/lib/module/handlers/gestureHandlerCommon.js +11 -1
  103. package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
  104. package/lib/module/handlers/gestures/GestureDetector.js +120 -81
  105. package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
  106. package/lib/module/handlers/gestures/eventReceiver.js +6 -7
  107. package/lib/module/handlers/gestures/eventReceiver.js.map +1 -1
  108. package/lib/module/handlers/gestures/gesture.js +23 -4
  109. package/lib/module/handlers/gestures/gesture.js.map +1 -1
  110. package/lib/module/init.js +6 -1
  111. package/lib/module/init.js.map +1 -1
  112. package/lib/module/mocks.js +2 -0
  113. package/lib/module/mocks.js.map +1 -1
  114. package/lib/module/utils.js +17 -1
  115. package/lib/module/utils.js.map +1 -1
  116. package/lib/module/web/GestureHandler.js +4 -1
  117. package/lib/module/web/GestureHandler.js.map +1 -1
  118. package/lib/module/web/utils.js.map +1 -1
  119. package/lib/typescript/GestureHandlerRootView.web.d.ts +5 -0
  120. package/lib/typescript/RNGestureHandlerModule.d.ts +1 -0
  121. package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -0
  122. package/lib/typescript/{EventType.d.ts → TouchEventType.d.ts} +2 -2
  123. package/lib/typescript/components/DrawerLayout.d.ts +3 -0
  124. package/lib/typescript/components/GestureButtons.d.ts +18 -6
  125. package/lib/typescript/fabric/RNGestureHandlerButtonNativeComponent.d.ts +13 -0
  126. package/lib/typescript/fabric/RNGestureHandlerRootViewNativeComponent.d.ts +5 -0
  127. package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +2 -2
  128. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -1
  129. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +6 -3
  130. package/lib/typescript/handlers/gestures/GestureDetector.d.ts +2 -4
  131. package/lib/typescript/handlers/gestures/eventReceiver.d.ts +2 -0
  132. package/lib/typescript/handlers/gestures/gesture.d.ts +5 -0
  133. package/lib/typescript/init.d.ts +1 -0
  134. package/lib/typescript/mocks.d.ts +1 -0
  135. package/lib/typescript/utils.d.ts +2 -0
  136. package/lib/typescript/web/GestureHandler.d.ts +1 -1
  137. package/package.json +4 -2
  138. package/src/GestureHandlerRootView.android.tsx +8 -2
  139. package/src/GestureHandlerRootView.tsx +6 -0
  140. package/src/GestureHandlerRootView.web.tsx +12 -0
  141. package/src/RNGestureHandlerModule.ts +7 -0
  142. package/src/RNGestureHandlerModule.web.ts +2 -0
  143. package/src/{EventType.ts → TouchEventType.ts} +2 -2
  144. package/src/components/DrawerLayout.tsx +34 -10
  145. package/src/components/GestureButtons.tsx +21 -7
  146. package/src/components/GestureHandlerButton.tsx +2 -2
  147. package/src/components/touchables/GenericTouchable.tsx +2 -0
  148. package/src/fabric/RNGestureHandlerButtonNativeComponent.ts +27 -0
  149. package/src/fabric/RNGestureHandlerRootViewNativeComponent.ts +12 -0
  150. package/src/getShadowNodeFromRef.ts +12 -9
  151. package/src/handlers/ForceTouchGestureHandler.ts +3 -2
  152. package/src/handlers/createHandler.ts +30 -26
  153. package/src/handlers/gestureHandlerCommon.ts +21 -2
  154. package/src/handlers/gestures/GestureDetector.tsx +164 -105
  155. package/src/handlers/gestures/eventReceiver.ts +6 -6
  156. package/src/handlers/gestures/gesture.ts +29 -2
  157. package/src/init.ts +8 -1
  158. package/src/mocks.ts +2 -0
  159. package/src/utils.ts +20 -0
  160. package/src/web/GestureHandler.ts +7 -1
  161. package/src/web/utils.ts +1 -1
  162. package/ios/RNTouchEventType.h +0 -9
  163. package/lib/commonjs/EventType.js.map +0 -1
  164. package/lib/module/EventType.js.map +0 -1
  165. package/src/fabric/RNGestureHandlerButtonNativeComponent.js +0 -27
  166. package/src/fabric/RNGestureHandlerRootViewNativeComponent.js +0 -19
@@ -1 +1 @@
1
- {"version":3,"sources":["ForceTouchGestureHandler.ts"],"names":["React","tagMessage","PlatformConstants","createHandler","baseGestureHandlerProps","forceTouchGestureHandlerProps","ForceTouchFallback","Component","componentDidMount","console","warn","render","props","children","forceTouchHandlerName","ForceTouchGestureHandler","forceTouchAvailable","name","allowedProps","config"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,UAAT,QAA2B,UAA3B;AACA,OAAOC,iBAAP,MAA8B,sBAA9B;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,SAEEC,uBAFF,QAGO,wBAHP;AAKA,OAAO,MAAMC,6BAA6B,GAAG,CAC3C,UAD2C,EAE3C,UAF2C,EAG3C,sBAH2C,CAAtC;;AAMP,MAAMC,kBAAN,SAAiCN,KAAK,CAACO,SAAvC,CAAiD;AAE/CC,EAAAA,iBAAiB,GAAG;AAClBC,IAAAA,OAAO,CAACC,IAAR,CACET,UAAU,CACR,8NADQ,CADZ;AAKD;;AACDU,EAAAA,MAAM,GAAG;AACP,WAAO,KAAKC,KAAL,CAAWC,QAAlB;AACD;;AAX8C;;gBAA3CP,kB,yBACyB,K;;AAsD/B,OAAO,MAAMQ,qBAAqB,GAAG,0BAA9B,C,CAEP;;AACA,OAAO,MAAMC,wBAAwB,GAAGb,iBAAiB,SAAjB,IAAAA,iBAAiB,WAAjB,IAAAA,iBAAiB,CAAEc,mBAAnB,GACpCb,aAAa,CAGX;AACAc,EAAAA,IAAI,EAAEH,qBADN;AAEAI,EAAAA,YAAY,EAAE,CACZ,GAAGd,uBADS,EAEZ,GAAGC,6BAFS,CAFd;AAMAc,EAAAA,MAAM,EAAE;AANR,CAHW,CADuB,GAYpCb,kBAZG;AAcNS,wBAAD,CAAuDC,mBAAvD,GACE,CAAAd,iBAAiB,SAAjB,IAAAA,iBAAiB,WAAjB,YAAAA,iBAAiB,CAAEc,mBAAnB,KAA0C,KAD5C","sourcesContent":["import React from 'react';\nimport { tagMessage } from '../utils';\nimport PlatformConstants from '../PlatformConstants';\nimport createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const forceTouchGestureHandlerProps = [\n 'minForce',\n 'maxForce',\n 'feedbackOnActivation',\n] as const;\n\nclass ForceTouchFallback extends React.Component {\n static forceTouchAvailable = false;\n componentDidMount() {\n console.warn(\n tagMessage(\n 'ForceTouchGestureHandler is not available on this platform. Please use ForceTouchGestureHandler.forceTouchAvailable to conditionally render other components that would provide a fallback behavior specific to your usecase'\n )\n );\n }\n render() {\n return this.props.children;\n }\n}\n\nexport type ForceTouchGestureHandlerEventPayload = {\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n\n /**\n * The pressure of a touch.\n */\n force: number;\n};\n\nexport interface ForceTouchGestureConfig {\n /**\n *\n * A minimal pressure that is required before handler can activate. Should be a\n * value from range `[0.0, 1.0]`. Default is `0.2`.\n */\n minForce?: number;\n\n /**\n * A maximal pressure that could be applied for handler. If the pressure is\n * greater, handler fails. Should be a value from range `[0.0, 1.0]`.\n */\n maxForce?: number;\n\n /**\n * Boolean value defining if haptic feedback has to be performed on\n * activation.\n */\n feedbackOnActivation?: boolean;\n}\n\nexport interface ForceTouchGestureHandlerProps\n extends BaseGestureHandlerProps<ForceTouchGestureHandlerEventPayload>,\n ForceTouchGestureConfig {}\n\nexport type ForceTouchGestureHandler = typeof ForceTouchGestureHandler & {\n forceTouchAvailable: boolean;\n};\n\nexport const forceTouchHandlerName = 'ForceTouchGestureHandler';\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const ForceTouchGestureHandler = PlatformConstants?.forceTouchAvailable\n ? createHandler<\n ForceTouchGestureHandlerProps,\n ForceTouchGestureHandlerEventPayload\n >({\n name: forceTouchHandlerName,\n allowedProps: [\n ...baseGestureHandlerProps,\n ...forceTouchGestureHandlerProps,\n ] as const,\n config: {},\n })\n : ForceTouchFallback;\n\n(ForceTouchGestureHandler as ForceTouchGestureHandler).forceTouchAvailable =\n PlatformConstants?.forceTouchAvailable || false;\n"]}
1
+ {"version":3,"sources":["ForceTouchGestureHandler.ts"],"names":["React","tagMessage","PlatformConstants","createHandler","baseGestureHandlerProps","forceTouchGestureHandlerProps","ForceTouchFallback","Component","componentDidMount","console","warn","render","props","children","forceTouchHandlerName","ForceTouchGestureHandler","forceTouchAvailable","name","allowedProps","config"],"mappings":";;AAAA,OAAOA,KAAP,MAAyC,OAAzC;AACA,SAASC,UAAT,QAA2B,UAA3B;AACA,OAAOC,iBAAP,MAA8B,sBAA9B;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,SAEEC,uBAFF,QAGO,wBAHP;AAKA,OAAO,MAAMC,6BAA6B,GAAG,CAC3C,UAD2C,EAE3C,UAF2C,EAG3C,sBAH2C,CAAtC,C,CAMP;;AACA,MAAMC,kBAAN,SAAiCN,KAAK,CAACO,SAAvC,CAA6E;AAE3EC,EAAAA,iBAAiB,GAAG;AAClBC,IAAAA,OAAO,CAACC,IAAR,CACET,UAAU,CACR,8NADQ,CADZ;AAKD;;AACDU,EAAAA,MAAM,GAAG;AACP,WAAO,KAAKC,KAAL,CAAWC,QAAlB;AACD;;AAX0E;;gBAAvEP,kB,yBACyB,K;;AAsD/B,OAAO,MAAMQ,qBAAqB,GAAG,0BAA9B,C,CAEP;;AACA,OAAO,MAAMC,wBAAwB,GAAGb,iBAAiB,SAAjB,IAAAA,iBAAiB,WAAjB,IAAAA,iBAAiB,CAAEc,mBAAnB,GACpCb,aAAa,CAGX;AACAc,EAAAA,IAAI,EAAEH,qBADN;AAEAI,EAAAA,YAAY,EAAE,CACZ,GAAGd,uBADS,EAEZ,GAAGC,6BAFS,CAFd;AAMAc,EAAAA,MAAM,EAAE;AANR,CAHW,CADuB,GAYpCb,kBAZG;AAcNS,wBAAD,CAAuDC,mBAAvD,GACE,CAAAd,iBAAiB,SAAjB,IAAAA,iBAAiB,WAAjB,YAAAA,iBAAiB,CAAEc,mBAAnB,KAA0C,KAD5C","sourcesContent":["import React, { PropsWithChildren } from 'react';\nimport { tagMessage } from '../utils';\nimport PlatformConstants from '../PlatformConstants';\nimport createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const forceTouchGestureHandlerProps = [\n 'minForce',\n 'maxForce',\n 'feedbackOnActivation',\n] as const;\n\n// implicit `children` prop has been removed in @types/react^18.0.0\nclass ForceTouchFallback extends React.Component<PropsWithChildren<unknown>> {\n static forceTouchAvailable = false;\n componentDidMount() {\n console.warn(\n tagMessage(\n 'ForceTouchGestureHandler is not available on this platform. Please use ForceTouchGestureHandler.forceTouchAvailable to conditionally render other components that would provide a fallback behavior specific to your usecase'\n )\n );\n }\n render() {\n return this.props.children;\n }\n}\n\nexport type ForceTouchGestureHandlerEventPayload = {\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n\n /**\n * The pressure of a touch.\n */\n force: number;\n};\n\nexport interface ForceTouchGestureConfig {\n /**\n *\n * A minimal pressure that is required before handler can activate. Should be a\n * value from range `[0.0, 1.0]`. Default is `0.2`.\n */\n minForce?: number;\n\n /**\n * A maximal pressure that could be applied for handler. If the pressure is\n * greater, handler fails. Should be a value from range `[0.0, 1.0]`.\n */\n maxForce?: number;\n\n /**\n * Boolean value defining if haptic feedback has to be performed on\n * activation.\n */\n feedbackOnActivation?: boolean;\n}\n\nexport interface ForceTouchGestureHandlerProps\n extends BaseGestureHandlerProps<ForceTouchGestureHandlerEventPayload>,\n ForceTouchGestureConfig {}\n\nexport type ForceTouchGestureHandler = typeof ForceTouchGestureHandler & {\n forceTouchAvailable: boolean;\n};\n\nexport const forceTouchHandlerName = 'ForceTouchGestureHandler';\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const ForceTouchGestureHandler = PlatformConstants?.forceTouchAvailable\n ? createHandler<\n ForceTouchGestureHandlerProps,\n ForceTouchGestureHandlerEventPayload\n >({\n name: forceTouchHandlerName,\n allowedProps: [\n ...baseGestureHandlerProps,\n ...forceTouchGestureHandlerProps,\n ] as const,\n config: {},\n })\n : ForceTouchFallback;\n\n(ForceTouchGestureHandler as ForceTouchGestureHandler).forceTouchAvailable =\n PlatformConstants?.forceTouchAvailable || false;\n"]}
@@ -9,8 +9,8 @@ import deepEqual from 'lodash/isEqual';
9
9
  import RNGestureHandlerModule from '../RNGestureHandlerModule';
10
10
  import { State } from '../State';
11
11
  import { handlerIDToTag, getNextHandlerTag, registerOldGestureHandler } from './handlersRegistry';
12
- import { filterConfig, findNodeHandle } from './gestureHandlerCommon';
13
- import { isFabric, isJestEnv, tagMessage } from '../utils';
12
+ import { filterConfig, findNodeHandle, scheduleFlushOperations } from './gestureHandlerCommon';
13
+ import { isFabric, isJestEnv } from '../utils';
14
14
  import { ActionType } from '../ActionType';
15
15
  const UIManagerAny = UIManager;
16
16
  const customGHEventsConfigFabricAndroid = {
@@ -105,15 +105,7 @@ const stateToPropMappings = {
105
105
  [State.ACTIVE]: 'onActivated',
106
106
  [State.END]: 'onEnded'
107
107
  };
108
- let showedRngh2Notice = false;
109
-
110
- function showRngh2NoticeIfNeeded() {
111
- if (!showedRngh2Notice) {
112
- console.warn(tagMessage("Seems like you're using an old API with gesture components, check out new Gestures system!"));
113
- showedRngh2Notice = true;
114
- }
115
- } // TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.
116
-
108
+ const UNRESOLVED_REFS_RETRY_LIMIT = 1; // TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.
117
109
 
118
110
  export default function createHandler({
119
111
  name,
@@ -228,11 +220,14 @@ export default function createHandler({
228
220
 
229
221
  RNGestureHandlerModule.attachGestureHandler(this.handlerTag, newViewTag, actionType);
230
222
  }
223
+
224
+ scheduleFlushOperations();
231
225
  });
232
226
 
233
227
  _defineProperty(this, "updateGestureHandler", newConfig => {
234
228
  this.config = newConfig;
235
229
  RNGestureHandlerModule.updateGestureHandler(this.handlerTag, newConfig);
230
+ scheduleFlushOperations();
236
231
  });
237
232
 
238
233
  this.handlerTag = getNextHandlerTag();
@@ -249,10 +244,6 @@ export default function createHandler({
249
244
 
250
245
  handlerIDToTag[props.id] = this.handlerTag;
251
246
  }
252
-
253
- if (__DEV__ && !isJestEnv()) {
254
- showRngh2NoticeIfNeeded();
255
- }
256
247
  }
257
248
 
258
249
  componentDidMount() {
@@ -263,7 +254,7 @@ export default function createHandler({
263
254
  this.setState(_ => ({
264
255
  allowTouches
265
256
  }));
266
- this.update();
257
+ this.update(UNRESOLVED_REFS_RETRY_LIMIT);
267
258
  });
268
259
  }
269
260
 
@@ -276,7 +267,7 @@ export default function createHandler({
276
267
  // be resolved by then.
277
268
  this.updateEnqueued = setImmediate(() => {
278
269
  this.updateEnqueued = null;
279
- this.update();
270
+ this.update(UNRESOLVED_REFS_RETRY_LIMIT);
280
271
  });
281
272
  }
282
273
 
@@ -291,7 +282,7 @@ export default function createHandler({
291
282
  this.attachGestureHandler(viewTag); // TODO(TS) - check interaction between _viewTag & findNodeHandle
292
283
  }
293
284
 
294
- this.update();
285
+ this.update(UNRESOLVED_REFS_RETRY_LIMIT);
295
286
  }
296
287
 
297
288
  componentWillUnmount() {
@@ -299,6 +290,7 @@ export default function createHandler({
299
290
 
300
291
  (_this$inspectorToggle = this.inspectorToggleListener) === null || _this$inspectorToggle === void 0 ? void 0 : _this$inspectorToggle.remove();
301
292
  RNGestureHandlerModule.dropGestureHandler(this.handlerTag);
293
+ scheduleFlushOperations();
302
294
 
303
295
  if (this.updateEnqueued) {
304
296
  clearImmediate(this.updateEnqueued);
@@ -313,11 +305,22 @@ export default function createHandler({
313
305
  }
314
306
  }
315
307
 
316
- update() {
317
- const newConfig = filterConfig(transformProps ? transformProps(this.props) : this.props, [...allowedProps, ...customNativeProps], config);
308
+ update(remainingTries) {
309
+ const props = this.props; // When ref is set via a function i.e. `ref={(r) => refObject.current = r}` instead of
310
+ // `ref={refObject}` it's possible that it won't be resolved in time. Seems like trying
311
+ // again is easy enough fix.
318
312
 
319
- if (!deepEqual(this.config, newConfig)) {
320
- this.updateGestureHandler(newConfig);
313
+ if (hasUnresolvedRefs(props) && remainingTries > 0) {
314
+ this.updateEnqueued = setImmediate(() => {
315
+ this.updateEnqueued = null;
316
+ this.update(remainingTries - 1);
317
+ });
318
+ } else {
319
+ const newConfig = filterConfig(transformProps ? transformProps(this.props) : this.props, [...allowedProps, ...customNativeProps], config);
320
+
321
+ if (!deepEqual(this.config, newConfig)) {
322
+ this.updateGestureHandler(newConfig);
323
+ }
321
324
  }
322
325
  }
323
326
 
@@ -1 +1 @@
1
- {"version":3,"sources":["createHandler.ts"],"names":["React","Platform","Touchable","UIManager","DeviceEventEmitter","deepEqual","RNGestureHandlerModule","State","handlerIDToTag","getNextHandlerTag","registerOldGestureHandler","filterConfig","findNodeHandle","isFabric","isJestEnv","tagMessage","ActionType","UIManagerAny","customGHEventsConfigFabricAndroid","topOnGestureHandlerEvent","registrationName","topOnGestureHandlerStateChange","customGHEventsConfig","onGestureHandlerEvent","onGestureHandlerStateChange","OS","genericDirectEventTypes","UIManagerConstants","getViewManagerConfig","getConstants","setJSResponder","oldSetJSResponder","clearJSResponder","oldClearJSResponder","tag","blockNativeResponder","handleSetJSResponder","handleClearJSResponder","allowTouches","DEV_ON_ANDROID","__DEV__","addListener","hasUnresolvedRefs","props","extract","refs","Array","isArray","current","some","r","stateToPropMappings","UNDETERMINED","undefined","BEGAN","FAILED","CANCELLED","ACTIVE","END","showedRngh2Notice","showRngh2NoticeIfNeeded","console","warn","createHandler","name","allowedProps","config","transformProps","customNativeProps","Handler","Component","constructor","event","nativeEvent","handlerTag","onGestureEvent","onHandlerStateChange","state","stateEventName","eventHandler","node","viewNode","child","Children","only","children","ref","newConfig","createGestureHandler","newViewTag","viewTag","attachGestureHandler","JS_FUNCTION_OLD_API","propsRef","onGestureStateChange","actionType","REANIMATED_WORKLET","NATIVE_ANIMATED_EVENT","updateGestureHandler","createRef","id","Error","componentDidMount","inspectorToggleListener","setState","_","update","updateEnqueued","setImmediate","componentDidUpdate","componentWillUnmount","remove","dropGestureHandler","clearImmediate","handlerID","setNativeProps","updates","mergedProps","render","gestureEventHandler","gestureStateEventHandler","events","grandChildren","TOUCH_TARGET_DEBUG","type","displayName","toArray","push","renderDebugView","color","hitSlop","cloneElement","refHandler","collapsable","handlerType","testID"],"mappings":";;;;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,QADF,EAEEC,SAFF,EAGEC,SAHF,EAIEC,kBAJF,QAMO,cANP,C,CAOA;;AACA,OAAOC,SAAP,MAAsB,gBAAtB;AACA,OAAOC,sBAAP,MAAmC,2BAAnC;AAEA,SAASC,KAAT,QAAsB,UAAtB;AACA,SACEC,cADF,EAEEC,iBAFF,EAGEC,yBAHF,QAIO,oBAJP;AAMA,SAEEC,YAFF,EAKEC,cALF,QAMO,wBANP;AAQA,SAASC,QAAT,EAAmBC,SAAnB,EAA8BC,UAA9B,QAAgD,UAAhD;AACA,SAASC,UAAT,QAA2B,eAA3B;AAEA,MAAMC,YAAY,GAAGd,SAArB;AAEA,MAAMe,iCAAiC,GAAG;AACxCC,EAAAA,wBAAwB,EAAE;AAAEC,IAAAA,gBAAgB,EAAE;AAApB,GADc;AAExCC,EAAAA,8BAA8B,EAAE;AAC9BD,IAAAA,gBAAgB,EAAE;AADY;AAFQ,CAA1C;AAOA,MAAME,oBAA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7H,SAAS,CAAC8H,eAAV,CAA0B;AACxBC,UAAAA,KAAK,EAAE,mBADiB;AAExBC,UAAAA,OAAO,EAAEhD,KAAK,CAACvC,KAAN,CAAYuF;AAFG,SAA1B,CADF;AAMD;;AAED,0BAAOlI,KAAK,CAACmI,YAAN,CACLjD,KADK,EAEL;AACEI,QAAAA,GAAG,EAAE,KAAK8C,UADZ;AAEEC,QAAAA,WAAW,EAAE,KAFf;AAGE,YAAIvH,SAAS,KACT;AACEwH,UAAAA,WAAW,EAAEtE,IADf;AAEEU,UAAAA,UAAU,EAAE,KAAKA;AAFnB,SADS,GAKT,EALJ,CAHF;AASE6D,QAAAA,MAAM,wBAAE,KAAK5F,KAAL,CAAW4F,MAAb,mEAAuBrD,KAAK,CAACvC,KAAN,CAAY4F,MAT3C;AAUE,WAAGd;AAVL,OAFK,EAcLC,aAdK,CAAP;AAgBD;;AAnUD;;AAPwE,kBAIpErD,OAJoE,iBAQnDL,IARmD;;AA4U1E,SAAOK,OAAP;AACD","sourcesContent":["import * as React from 'react';\nimport {\n Platform,\n Touchable,\n UIManager,\n DeviceEventEmitter,\n EmitterSubscription,\n} from 'react-native';\n// @ts-ignore - it isn't typed by TS & don't have definitelyTyped types\nimport deepEqual from 'lodash/isEqual';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\nimport type RNGestureHandlerModuleWeb from '../RNGestureHandlerModule.web';\nimport { State } from '../State';\nimport {\n handlerIDToTag,\n getNextHandlerTag,\n registerOldGestureHandler,\n} from './handlersRegistry';\n\nimport {\n BaseGestureHandlerProps,\n filterConfig,\n GestureEvent,\n HandlerStateChangeEvent,\n findNodeHandle,\n} from './gestureHandlerCommon';\nimport { ValueOf } from '../typeUtils';\nimport { isFabric, isJestEnv, tagMessage } from '../utils';\nimport { ActionType } from '../ActionType';\n\nconst UIManagerAny = UIManager as any;\n\nconst customGHEventsConfigFabricAndroid = {\n topOnGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n topOnGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n};\n\nconst customGHEventsConfig = {\n onGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n onGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n\n // When using React Native Gesture Handler for Animated.event with useNativeDriver: true\n // on Android with Fabric enabled, the native part still sends the native events to JS\n // but prefixed with \"top\". We cannot simply rename the events above so they are prefixed\n // with \"top\" instead of \"on\" because in such case Animated.events would not be registered.\n // That's why we need to register another pair of event names.\n // The incoming events will be queued but never handled.\n // Without this piece of code below, you'll get the following JS error:\n // Unsupported top level event type \"topOnGestureHandlerEvent\" dispatched\n ...(isFabric() &&\n Platform.OS === 'android' &&\n customGHEventsConfigFabricAndroid),\n};\n\n// Add gesture specific events to genericDirectEventTypes object exported from UIManager\n// native module.\n// Once new event types are registered with react it is possible to dispatch these\n// events to all kind of native views.\nUIManagerAny.genericDirectEventTypes = {\n ...UIManagerAny.genericDirectEventTypes,\n ...customGHEventsConfig,\n};\n// In newer versions of RN the `genericDirectEventTypes` is located in the object\n// returned by UIManager.getViewManagerConfig('getConstants') or in older RN UIManager.getConstants(), we need to add it there as well to make\n// it compatible with RN 61+\nconst UIManagerConstants =\n UIManagerAny.getViewManagerConfig?.('getConstants') ??\n UIManagerAny.getConstants?.();\n\nif (UIManagerConstants) {\n UIManagerConstants.genericDirectEventTypes = {\n ...UIManagerConstants.genericDirectEventTypes,\n ...customGHEventsConfig,\n };\n}\n\n// Wrap JS responder calls and notify gesture handler manager\nconst {\n setJSResponder: oldSetJSResponder = () => {\n //no operation\n },\n clearJSResponder: oldClearJSResponder = () => {\n //no operation\n },\n} = UIManagerAny;\nUIManagerAny.setJSResponder = (tag: number, blockNativeResponder: boolean) => {\n RNGestureHandlerModule.handleSetJSResponder(tag, blockNativeResponder);\n oldSetJSResponder(tag, blockNativeResponder);\n};\nUIManagerAny.clearJSResponder = () => {\n RNGestureHandlerModule.handleClearJSResponder();\n oldClearJSResponder();\n};\n\nlet allowTouches = true;\nconst DEV_ON_ANDROID = __DEV__ && Platform.OS === 'android';\n// Toggled inspector blocks touch events in order to allow inspecting on Android\n// This needs to be a global variable in order to set initial state for `allowTouches` property in Handler component\nif (DEV_ON_ANDROID) {\n DeviceEventEmitter.addListener('toggleElementInspector', () => {\n allowTouches = !allowTouches;\n });\n}\n\ntype HandlerProps<T extends Record<string, unknown>> = Readonly<\n React.PropsWithChildren<BaseGestureHandlerProps<T>>\n>;\nfunction hasUnresolvedRefs<T extends Record<string, unknown>>(\n props: HandlerProps<T>\n) {\n // TODO(TS) - add type for extract arg\n const extract = (refs: any | any[]) => {\n if (!Array.isArray(refs)) {\n return refs && refs.current === null;\n }\n return refs.some((r) => r && r.current === null);\n };\n return extract(props['simultaneousHandlers']) || extract(props['waitFor']);\n}\n\nconst stateToPropMappings = {\n [State.UNDETERMINED]: undefined,\n [State.BEGAN]: 'onBegan',\n [State.FAILED]: 'onFailed',\n [State.CANCELLED]: 'onCancelled',\n [State.ACTIVE]: 'onActivated',\n [State.END]: 'onEnded',\n} as const;\n\ntype CreateHandlerArgs<\n HandlerPropsT extends Record<string, unknown>\n> = Readonly<{\n name: string;\n allowedProps: Readonly<Extract<keyof HandlerPropsT, string>[]>;\n config: Readonly<Record<string, unknown>>;\n transformProps?: (props: HandlerPropsT) => HandlerPropsT;\n customNativeProps?: Readonly<string[]>;\n}>;\n\n// TODO(TS) fix event types\ntype InternalEventHandlers = {\n onGestureHandlerEvent?: (event: any) => void;\n onGestureHandlerStateChange?: (event: any) => void;\n};\n\nlet showedRngh2Notice = false;\nfunction showRngh2NoticeIfNeeded() {\n if (!showedRngh2Notice) {\n console.warn(\n tagMessage(\n \"Seems like you're using an old API with gesture components, check out new Gestures system!\"\n )\n );\n showedRngh2Notice = true;\n }\n}\n\n// TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.\nexport default function createHandler<\n T extends BaseGestureHandlerProps<U>,\n U extends Record<string, unknown>\n>({\n name,\n allowedProps = [],\n config = {},\n transformProps,\n customNativeProps = [],\n}: CreateHandlerArgs<T>): React.ComponentType<T & React.RefAttributes<any>> {\n interface HandlerState {\n allowTouches: boolean;\n }\n class Handler extends React.Component<\n T & InternalEventHandlers,\n HandlerState\n > {\n static displayName = name;\n\n private handlerTag: number;\n private config: Record<string, unknown>;\n private propsRef: React.MutableRefObject<unknown>;\n private viewNode: any;\n private viewTag?: number;\n private updateEnqueued: ReturnType<typeof setImmediate> | null = null;\n private inspectorToggleListener?: EmitterSubscription;\n\n constructor(props: T & InternalEventHandlers) {\n super(props);\n this.handlerTag = getNextHandlerTag();\n this.config = {};\n this.propsRef = React.createRef();\n this.state = { allowTouches };\n if (props.id) {\n if (handlerIDToTag[props.id] !== undefined) {\n throw new Error(`Handler with ID \"${props.id}\" already registered`);\n }\n handlerIDToTag[props.id] = this.handlerTag;\n }\n if (__DEV__ && !isJestEnv()) {\n showRngh2NoticeIfNeeded();\n }\n }\n\n componentDidMount() {\n const props: HandlerProps<U> = this.props;\n\n if (DEV_ON_ANDROID) {\n this.inspectorToggleListener = DeviceEventEmitter.addListener(\n 'toggleElementInspector',\n () => {\n this.setState((_) => ({ allowTouches }));\n this.update();\n }\n );\n }\n if (hasUnresolvedRefs(props)) {\n // If there are unresolved refs (e.g. \".current\" has not yet been set)\n // passed as `simultaneousHandlers` or `waitFor`, we enqueue a call to\n // _update method that will try to update native handler props using\n // setImmediate. This makes it so update() function gets called after all\n // react components are mounted and we expect the missing ref object to\n // be resolved by then.\n this.updateEnqueued = setImmediate(() => {\n this.updateEnqueued = null;\n this.update();\n });\n }\n\n this.createGestureHandler(\n filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n )\n );\n\n this.attachGestureHandler(findNodeHandle(this.viewNode) as number); // TODO(TS) - check if this can be null\n }\n\n componentDidUpdate() {\n const viewTag = findNodeHandle(this.viewNode);\n if (this.viewTag !== viewTag) {\n this.attachGestureHandler(viewTag as number); // TODO(TS) - check interaction between _viewTag & findNodeHandle\n }\n this.update();\n }\n\n componentWillUnmount() {\n this.inspectorToggleListener?.remove();\n RNGestureHandlerModule.dropGestureHandler(this.handlerTag);\n if (this.updateEnqueued) {\n clearImmediate(this.updateEnqueued);\n }\n // We can't use this.props.id directly due to TS generic type narrowing bug, see https://github.com/microsoft/TypeScript/issues/13995 for more context\n const handlerID: string | undefined = this.props.id;\n if (handlerID) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete handlerIDToTag[handlerID];\n }\n }\n\n private onGestureHandlerEvent = (event: GestureEvent<U>) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n if (typeof this.props.onGestureEvent === 'function') {\n this.props.onGestureEvent?.(event);\n }\n } else {\n this.props.onGestureHandlerEvent?.(event);\n }\n };\n\n // TODO(TS) - make sure this is right type for event\n private onGestureHandlerStateChange = (\n event: HandlerStateChangeEvent<U>\n ) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n if (typeof this.props.onHandlerStateChange === 'function') {\n this.props.onHandlerStateChange?.(event);\n }\n\n const state: ValueOf<typeof State> = event.nativeEvent.state;\n const stateEventName = stateToPropMappings[state];\n const eventHandler = stateEventName && this.props[stateEventName];\n if (eventHandler && typeof eventHandler === 'function') {\n eventHandler(event);\n }\n } else {\n this.props.onGestureHandlerStateChange?.(event);\n }\n };\n\n private refHandler = (node: any) => {\n this.viewNode = node;\n\n const child = React.Children.only(this.props.children);\n // TODO(TS) fix ref type\n const { ref }: any = child;\n if (ref !== null) {\n if (typeof ref === 'function') {\n ref(node);\n } else {\n ref.current = node;\n }\n }\n };\n\n private createGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.createGestureHandler(\n name,\n this.handlerTag,\n newConfig\n );\n };\n\n private attachGestureHandler = (newViewTag: number) => {\n this.viewTag = newViewTag;\n\n if (Platform.OS === 'web') {\n // typecast due to dynamic resolution, attachGestureHandler should have web version signature in this branch\n (RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler)(\n this.handlerTag,\n newViewTag,\n ActionType.JS_FUNCTION_OLD_API, // ignored on web\n this.propsRef\n );\n } else {\n registerOldGestureHandler(this.handlerTag, {\n onGestureEvent: this.onGestureHandlerEvent,\n onGestureStateChange: this.onGestureHandlerStateChange,\n });\n\n const actionType = (() => {\n if (\n this.props?.onGestureEvent &&\n 'current' in this.props.onGestureEvent\n ) {\n // Reanimated worklet\n return ActionType.REANIMATED_WORKLET;\n } else if (\n this.props?.onGestureEvent &&\n '__isNative' in this.props.onGestureEvent\n ) {\n // Animated.event with useNativeDriver: true\n return ActionType.NATIVE_ANIMATED_EVENT;\n } else {\n // JS callback or Animated.event with useNativeDriver: false\n return ActionType.JS_FUNCTION_OLD_API;\n }\n })();\n\n RNGestureHandlerModule.attachGestureHandler(\n this.handlerTag,\n newViewTag,\n actionType\n );\n }\n };\n\n private updateGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.updateGestureHandler(this.handlerTag, newConfig);\n };\n\n private update() {\n const newConfig = filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n );\n if (!deepEqual(this.config, newConfig)) {\n this.updateGestureHandler(newConfig);\n }\n }\n\n setNativeProps(updates: any) {\n const mergedProps = { ...this.props, ...updates };\n const newConfig = filterConfig(\n transformProps ? transformProps(mergedProps) : mergedProps,\n [...allowedProps, ...customNativeProps],\n config\n );\n this.updateGestureHandler(newConfig);\n }\n\n render() {\n let gestureEventHandler = this.onGestureHandlerEvent;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureEventHandlers = {\n onGestureEvent?: BaseGestureHandlerProps<U>['onGestureEvent'];\n onGestureHandlerEvent?: InternalEventHandlers['onGestureHandlerEvent'];\n };\n const {\n onGestureEvent,\n onGestureHandlerEvent,\n }: OnGestureEventHandlers = this.props;\n if (onGestureEvent && typeof onGestureEvent !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerEvent) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureEventHandler = onGestureEvent;\n } else {\n if (\n onGestureHandlerEvent &&\n typeof onGestureHandlerEvent !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n\n let gestureStateEventHandler = this.onGestureHandlerStateChange;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureStateChangeHandlers = {\n onHandlerStateChange?: BaseGestureHandlerProps<U>['onHandlerStateChange'];\n onGestureHandlerStateChange?: InternalEventHandlers['onGestureHandlerStateChange'];\n };\n const {\n onHandlerStateChange,\n onGestureHandlerStateChange,\n }: OnGestureStateChangeHandlers = this.props;\n if (onHandlerStateChange && typeof onHandlerStateChange !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerStateChange) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureStateEventHandler = onHandlerStateChange;\n } else {\n if (\n onGestureHandlerStateChange &&\n typeof onGestureHandlerStateChange !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n const events = {\n onGestureHandlerEvent: this.state.allowTouches\n ? gestureEventHandler\n : undefined,\n onGestureHandlerStateChange: this.state.allowTouches\n ? gestureStateEventHandler\n : undefined,\n };\n\n this.propsRef.current = events;\n\n const child: any = React.Children.only(this.props.children);\n let grandChildren = child.props.children;\n if (\n Touchable.TOUCH_TARGET_DEBUG &&\n child.type &&\n (child.type === 'RNGestureHandlerButton' ||\n child.type.name === 'View' ||\n child.type.displayName === 'View')\n ) {\n grandChildren = React.Children.toArray(grandChildren);\n grandChildren.push(\n Touchable.renderDebugView({\n color: 'mediumspringgreen',\n hitSlop: child.props.hitSlop,\n })\n );\n }\n\n return React.cloneElement(\n child,\n {\n ref: this.refHandler,\n collapsable: false,\n ...(isJestEnv()\n ? {\n handlerType: name,\n handlerTag: this.handlerTag,\n }\n : {}),\n testID: this.props.testID ?? child.props.testID,\n ...events,\n },\n grandChildren\n );\n }\n }\n return Handler;\n}\n"]}
1
+ {"version":3,"sources":["createHandler.ts"],"names":["React","Platform","Touchable","UIManager","DeviceEventEmitter","deepEqual","RNGestureHandlerModule","State","handlerIDToTag","getNextHandlerTag","registerOldGestureHandler","filterConfig","findNodeHandle","scheduleFlushOperations","isFabric","isJestEnv","ActionType","UIManagerAny","customGHEventsConfigFabricAndroid","topOnGestureHandlerEvent","registrationName","topOnGestureHandlerStateChange","customGHEventsConfig","onGestureHandlerEvent","onGestureHandlerStateChange","OS","genericDirectEventTypes","UIManagerConstants","getViewManagerConfig","getConstants","setJSResponder","oldSetJSResponder","clearJSResponder","oldClearJSResponder","tag","blockNativeResponder","handleSetJSResponder","handleClearJSResponder","allowTouches","DEV_ON_ANDROID","__DEV__","addListener","hasUnresolvedRefs","props","extract","refs","Array","isArray","current","some","r","stateToPropMappings","UNDETERMINED","undefined","BEGAN","FAILED","CANCELLED","ACTIVE","END","UNRESOLVED_REFS_RETRY_LIMIT","createHandler","name","allowedProps","config","transformProps","customNativeProps","Handler","Component","constructor","event","nativeEvent","handlerTag","onGestureEvent","onHandlerStateChange","state","stateEventName","eventHandler","node","viewNode","child","Children","only","children","ref","newConfig","createGestureHandler","newViewTag","viewTag","attachGestureHandler","JS_FUNCTION_OLD_API","propsRef","onGestureStateChange","actionType","REANIMATED_WORKLET","NATIVE_ANIMATED_EVENT","updateGestureHandler","createRef","id","Error","componentDidMount","inspectorToggleListener","setState","_","update","updateEnqueued","setImmediate","componentDidUpdate","componentWillUnmount","remove","dropGestureHandler","clearImmediate","handlerID","remainingTries","setNativeProps","updates","mergedProps","render","gestureEventHandler","gestureStateEventHandler","events","grandChildren","TOUCH_TARGET_DEBUG","type","displayName","toArray","push","renderDebugView","color","hitSlop","cloneElement","refHandler","collapsable","handlerType","testID"],"mappings":";;;;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,QADF,EAEEC,SAFF,EAGEC,SAHF,EAIEC,kBAJF,QAMO,cANP,C,CAOA;;AACA,OAAOC,SAAP,MAAsB,gBAAtB;AACA,OAAOC,sBAAP,MAAmC,2BAAnC;AAEA,SAASC,KAAT,QAAsB,UAAtB;AACA,SACEC,cADF,EAEEC,iBAFF,EAGEC,yBAHF,QAIO,oBAJP;AAMA,SAEEC,YAFF,EAKEC,cALF,EAMEC,uBANF,QAOO,wBAPP;AASA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,UAApC;AACA,SAASC,UAAT,QAA2B,eAA3B;AAEA,MAAMC,YAAY,GAAGd,SAArB;AAEA,MAAMe,iCAAiC,GAAG;AACxCC,EAAAA,wBAAwB,EAAE;AAAEC,IAAAA,gBAAgB,EAAE;AAApB,GADc;AAExCC,EAAAA,8BAA8B,EAAE;AAC9BD,IAAAA,gBAAgB,EAAE;AADY;AAFQ,CAA1C;AAOA,MAAME,oBAAoB,GAAG;AAC3BC,EAAAA,qBAAqB,EAAE;AAAEH,IAAAA,gBAAgB,EAAE;AAApB,GADI;AAE3BI,EAAAA,2BAA2B,EAAE;AAC3BJ,IAAAA,gBAAgB,EAAE;AADS,GAFF;AAM3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAIN,QAAQ,MACVb,QAAQ,CAACwB,EAAT,KAAgB,SADd,IAEFP,iCAFF;AAd2B,CAA7B,C,CAmBA;AACA;AACA;AACA;;AACAD,YAAY,CAACS,uBAAb,GAAuC,EACrC,GAAGT,YAAY,CAACS,uBADqB;AAErC,KAAGJ;AAFkC,CAAvC,C,CAIA;AACA;AACA;;AACA,MAAMK,kBAAkB,sDACtBV,YAAY,CAACW,oBADS,2DACtB,4BAAAX,YAAY,EAAwB,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WAAW,EAAEvE,IADf;AAEEU,UAAAA,UAAU,EAAE,KAAKA;AAFnB,SADS,GAKT,EALJ,CAHF;AASE8D,QAAAA,MAAM,wBAAE,KAAK1F,KAAL,CAAW0F,MAAb,mEAAuBtD,KAAK,CAACpC,KAAN,CAAY0F,MAT3C;AAUE,WAAGd;AAVL,OAFK,EAcLC,aAdK,CAAP;AAgBD;;AAhVD;;AAPwE,kBAIpEtD,OAJoE,iBAQnDL,IARmD;;AAyV1E,SAAOK,OAAP;AACD","sourcesContent":["import * as React from 'react';\nimport {\n Platform,\n Touchable,\n UIManager,\n DeviceEventEmitter,\n EmitterSubscription,\n} from 'react-native';\n// @ts-ignore - it isn't typed by TS & don't have definitelyTyped types\nimport deepEqual from 'lodash/isEqual';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\nimport type RNGestureHandlerModuleWeb from '../RNGestureHandlerModule.web';\nimport { State } from '../State';\nimport {\n handlerIDToTag,\n getNextHandlerTag,\n registerOldGestureHandler,\n} from './handlersRegistry';\n\nimport {\n BaseGestureHandlerProps,\n filterConfig,\n GestureEvent,\n HandlerStateChangeEvent,\n findNodeHandle,\n scheduleFlushOperations,\n} from './gestureHandlerCommon';\nimport { ValueOf } from '../typeUtils';\nimport { isFabric, isJestEnv } from '../utils';\nimport { ActionType } from '../ActionType';\n\nconst UIManagerAny = UIManager as any;\n\nconst customGHEventsConfigFabricAndroid = {\n topOnGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n topOnGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n};\n\nconst customGHEventsConfig = {\n onGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n onGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n\n // When using React Native Gesture Handler for Animated.event with useNativeDriver: true\n // on Android with Fabric enabled, the native part still sends the native events to JS\n // but prefixed with \"top\". We cannot simply rename the events above so they are prefixed\n // with \"top\" instead of \"on\" because in such case Animated.events would not be registered.\n // That's why we need to register another pair of event names.\n // The incoming events will be queued but never handled.\n // Without this piece of code below, you'll get the following JS error:\n // Unsupported top level event type \"topOnGestureHandlerEvent\" dispatched\n ...(isFabric() &&\n Platform.OS === 'android' &&\n customGHEventsConfigFabricAndroid),\n};\n\n// Add gesture specific events to genericDirectEventTypes object exported from UIManager\n// native module.\n// Once new event types are registered with react it is possible to dispatch these\n// events to all kind of native views.\nUIManagerAny.genericDirectEventTypes = {\n ...UIManagerAny.genericDirectEventTypes,\n ...customGHEventsConfig,\n};\n// In newer versions of RN the `genericDirectEventTypes` is located in the object\n// returned by UIManager.getViewManagerConfig('getConstants') or in older RN UIManager.getConstants(), we need to add it there as well to make\n// it compatible with RN 61+\nconst UIManagerConstants =\n UIManagerAny.getViewManagerConfig?.('getConstants') ??\n UIManagerAny.getConstants?.();\n\nif (UIManagerConstants) {\n UIManagerConstants.genericDirectEventTypes = {\n ...UIManagerConstants.genericDirectEventTypes,\n ...customGHEventsConfig,\n };\n}\n\n// Wrap JS responder calls and notify gesture handler manager\nconst {\n setJSResponder: oldSetJSResponder = () => {\n //no operation\n },\n clearJSResponder: oldClearJSResponder = () => {\n //no operation\n },\n} = UIManagerAny;\nUIManagerAny.setJSResponder = (tag: number, blockNativeResponder: boolean) => {\n RNGestureHandlerModule.handleSetJSResponder(tag, blockNativeResponder);\n oldSetJSResponder(tag, blockNativeResponder);\n};\nUIManagerAny.clearJSResponder = () => {\n RNGestureHandlerModule.handleClearJSResponder();\n oldClearJSResponder();\n};\n\nlet allowTouches = true;\nconst DEV_ON_ANDROID = __DEV__ && Platform.OS === 'android';\n// Toggled inspector blocks touch events in order to allow inspecting on Android\n// This needs to be a global variable in order to set initial state for `allowTouches` property in Handler component\nif (DEV_ON_ANDROID) {\n DeviceEventEmitter.addListener('toggleElementInspector', () => {\n allowTouches = !allowTouches;\n });\n}\n\ntype HandlerProps<T extends Record<string, unknown>> = Readonly<\n React.PropsWithChildren<BaseGestureHandlerProps<T>>\n>;\nfunction hasUnresolvedRefs<T extends Record<string, unknown>>(\n props: HandlerProps<T>\n) {\n // TODO(TS) - add type for extract arg\n const extract = (refs: any | any[]) => {\n if (!Array.isArray(refs)) {\n return refs && refs.current === null;\n }\n return refs.some((r) => r && r.current === null);\n };\n return extract(props['simultaneousHandlers']) || extract(props['waitFor']);\n}\n\nconst stateToPropMappings = {\n [State.UNDETERMINED]: undefined,\n [State.BEGAN]: 'onBegan',\n [State.FAILED]: 'onFailed',\n [State.CANCELLED]: 'onCancelled',\n [State.ACTIVE]: 'onActivated',\n [State.END]: 'onEnded',\n} as const;\n\ntype CreateHandlerArgs<\n HandlerPropsT extends Record<string, unknown>\n> = Readonly<{\n name: string;\n allowedProps: Readonly<Extract<keyof HandlerPropsT, string>[]>;\n config: Readonly<Record<string, unknown>>;\n transformProps?: (props: HandlerPropsT) => HandlerPropsT;\n customNativeProps?: Readonly<string[]>;\n}>;\n\n// TODO(TS) fix event types\ntype InternalEventHandlers = {\n onGestureHandlerEvent?: (event: any) => void;\n onGestureHandlerStateChange?: (event: any) => void;\n};\n\nconst UNRESOLVED_REFS_RETRY_LIMIT = 1;\n\n// TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.\nexport default function createHandler<\n T extends BaseGestureHandlerProps<U>,\n U extends Record<string, unknown>\n>({\n name,\n allowedProps = [],\n config = {},\n transformProps,\n customNativeProps = [],\n}: CreateHandlerArgs<T>): React.ComponentType<T & React.RefAttributes<any>> {\n interface HandlerState {\n allowTouches: boolean;\n }\n class Handler extends React.Component<\n T & InternalEventHandlers,\n HandlerState\n > {\n static displayName = name;\n\n private handlerTag: number;\n private config: Record<string, unknown>;\n private propsRef: React.MutableRefObject<unknown>;\n private viewNode: any;\n private viewTag?: number;\n private updateEnqueued: ReturnType<typeof setImmediate> | null = null;\n private inspectorToggleListener?: EmitterSubscription;\n\n constructor(props: T & InternalEventHandlers) {\n super(props);\n this.handlerTag = getNextHandlerTag();\n this.config = {};\n this.propsRef = React.createRef();\n this.state = { allowTouches };\n if (props.id) {\n if (handlerIDToTag[props.id] !== undefined) {\n throw new Error(`Handler with ID \"${props.id}\" already registered`);\n }\n handlerIDToTag[props.id] = this.handlerTag;\n }\n }\n\n componentDidMount() {\n const props: HandlerProps<U> = this.props;\n\n if (DEV_ON_ANDROID) {\n this.inspectorToggleListener = DeviceEventEmitter.addListener(\n 'toggleElementInspector',\n () => {\n this.setState((_) => ({ allowTouches }));\n this.update(UNRESOLVED_REFS_RETRY_LIMIT);\n }\n );\n }\n if (hasUnresolvedRefs(props)) {\n // If there are unresolved refs (e.g. \".current\" has not yet been set)\n // passed as `simultaneousHandlers` or `waitFor`, we enqueue a call to\n // _update method that will try to update native handler props using\n // setImmediate. This makes it so update() function gets called after all\n // react components are mounted and we expect the missing ref object to\n // be resolved by then.\n this.updateEnqueued = setImmediate(() => {\n this.updateEnqueued = null;\n this.update(UNRESOLVED_REFS_RETRY_LIMIT);\n });\n }\n\n this.createGestureHandler(\n filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n )\n );\n\n this.attachGestureHandler(findNodeHandle(this.viewNode) as number); // TODO(TS) - check if this can be null\n }\n\n componentDidUpdate() {\n const viewTag = findNodeHandle(this.viewNode);\n if (this.viewTag !== viewTag) {\n this.attachGestureHandler(viewTag as number); // TODO(TS) - check interaction between _viewTag & findNodeHandle\n }\n this.update(UNRESOLVED_REFS_RETRY_LIMIT);\n }\n\n componentWillUnmount() {\n this.inspectorToggleListener?.remove();\n RNGestureHandlerModule.dropGestureHandler(this.handlerTag);\n scheduleFlushOperations();\n if (this.updateEnqueued) {\n clearImmediate(this.updateEnqueued);\n }\n // We can't use this.props.id directly due to TS generic type narrowing bug, see https://github.com/microsoft/TypeScript/issues/13995 for more context\n const handlerID: string | undefined = this.props.id;\n if (handlerID) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete handlerIDToTag[handlerID];\n }\n }\n\n private onGestureHandlerEvent = (event: GestureEvent<U>) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n if (typeof this.props.onGestureEvent === 'function') {\n this.props.onGestureEvent?.(event);\n }\n } else {\n this.props.onGestureHandlerEvent?.(event);\n }\n };\n\n // TODO(TS) - make sure this is right type for event\n private onGestureHandlerStateChange = (\n event: HandlerStateChangeEvent<U>\n ) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n if (typeof this.props.onHandlerStateChange === 'function') {\n this.props.onHandlerStateChange?.(event);\n }\n\n const state: ValueOf<typeof State> = event.nativeEvent.state;\n const stateEventName = stateToPropMappings[state];\n const eventHandler = stateEventName && this.props[stateEventName];\n if (eventHandler && typeof eventHandler === 'function') {\n eventHandler(event);\n }\n } else {\n this.props.onGestureHandlerStateChange?.(event);\n }\n };\n\n private refHandler = (node: any) => {\n this.viewNode = node;\n\n const child = React.Children.only(this.props.children);\n // TODO(TS) fix ref type\n const { ref }: any = child;\n if (ref !== null) {\n if (typeof ref === 'function') {\n ref(node);\n } else {\n ref.current = node;\n }\n }\n };\n\n private createGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.createGestureHandler(\n name,\n this.handlerTag,\n newConfig\n );\n };\n\n private attachGestureHandler = (newViewTag: number) => {\n this.viewTag = newViewTag;\n\n if (Platform.OS === 'web') {\n // typecast due to dynamic resolution, attachGestureHandler should have web version signature in this branch\n (RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler)(\n this.handlerTag,\n newViewTag,\n ActionType.JS_FUNCTION_OLD_API, // ignored on web\n this.propsRef\n );\n } else {\n registerOldGestureHandler(this.handlerTag, {\n onGestureEvent: this.onGestureHandlerEvent,\n onGestureStateChange: this.onGestureHandlerStateChange,\n });\n\n const actionType = (() => {\n if (\n this.props?.onGestureEvent &&\n 'current' in this.props.onGestureEvent\n ) {\n // Reanimated worklet\n return ActionType.REANIMATED_WORKLET;\n } else if (\n this.props?.onGestureEvent &&\n '__isNative' in this.props.onGestureEvent\n ) {\n // Animated.event with useNativeDriver: true\n return ActionType.NATIVE_ANIMATED_EVENT;\n } else {\n // JS callback or Animated.event with useNativeDriver: false\n return ActionType.JS_FUNCTION_OLD_API;\n }\n })();\n\n RNGestureHandlerModule.attachGestureHandler(\n this.handlerTag,\n newViewTag,\n actionType\n );\n }\n\n scheduleFlushOperations();\n };\n\n private updateGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.updateGestureHandler(this.handlerTag, newConfig);\n scheduleFlushOperations();\n };\n\n private update(remainingTries: number) {\n const props: HandlerProps<U> = this.props;\n\n // When ref is set via a function i.e. `ref={(r) => refObject.current = r}` instead of\n // `ref={refObject}` it's possible that it won't be resolved in time. Seems like trying\n // again is easy enough fix.\n if (hasUnresolvedRefs(props) && remainingTries > 0) {\n this.updateEnqueued = setImmediate(() => {\n this.updateEnqueued = null;\n this.update(remainingTries - 1);\n });\n } else {\n const newConfig = filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n );\n if (!deepEqual(this.config, newConfig)) {\n this.updateGestureHandler(newConfig);\n }\n }\n }\n\n setNativeProps(updates: any) {\n const mergedProps = { ...this.props, ...updates };\n const newConfig = filterConfig(\n transformProps ? transformProps(mergedProps) : mergedProps,\n [...allowedProps, ...customNativeProps],\n config\n );\n this.updateGestureHandler(newConfig);\n }\n\n render() {\n let gestureEventHandler = this.onGestureHandlerEvent;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureEventHandlers = {\n onGestureEvent?: BaseGestureHandlerProps<U>['onGestureEvent'];\n onGestureHandlerEvent?: InternalEventHandlers['onGestureHandlerEvent'];\n };\n const {\n onGestureEvent,\n onGestureHandlerEvent,\n }: OnGestureEventHandlers = this.props;\n if (onGestureEvent && typeof onGestureEvent !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerEvent) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureEventHandler = onGestureEvent;\n } else {\n if (\n onGestureHandlerEvent &&\n typeof onGestureHandlerEvent !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n\n let gestureStateEventHandler = this.onGestureHandlerStateChange;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureStateChangeHandlers = {\n onHandlerStateChange?: BaseGestureHandlerProps<U>['onHandlerStateChange'];\n onGestureHandlerStateChange?: InternalEventHandlers['onGestureHandlerStateChange'];\n };\n const {\n onHandlerStateChange,\n onGestureHandlerStateChange,\n }: OnGestureStateChangeHandlers = this.props;\n if (onHandlerStateChange && typeof onHandlerStateChange !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerStateChange) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureStateEventHandler = onHandlerStateChange;\n } else {\n if (\n onGestureHandlerStateChange &&\n typeof onGestureHandlerStateChange !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n const events = {\n onGestureHandlerEvent: this.state.allowTouches\n ? gestureEventHandler\n : undefined,\n onGestureHandlerStateChange: this.state.allowTouches\n ? gestureStateEventHandler\n : undefined,\n };\n\n this.propsRef.current = events;\n\n const child: any = React.Children.only(this.props.children);\n let grandChildren = child.props.children;\n if (\n Touchable.TOUCH_TARGET_DEBUG &&\n child.type &&\n (child.type === 'RNGestureHandlerButton' ||\n child.type.name === 'View' ||\n child.type.displayName === 'View')\n ) {\n grandChildren = React.Children.toArray(grandChildren);\n grandChildren.push(\n Touchable.renderDebugView({\n color: 'mediumspringgreen',\n hitSlop: child.props.hitSlop,\n })\n );\n }\n\n return React.cloneElement(\n child,\n {\n ref: this.refHandler,\n collapsable: false,\n ...(isJestEnv()\n ? {\n handlerType: name,\n handlerTag: this.handlerTag,\n }\n : {}),\n testID: this.props.testID ?? child.props.testID,\n ...events,\n },\n grandChildren\n );\n }\n }\n return Handler;\n}\n"]}
@@ -5,7 +5,8 @@
5
5
  import { Platform, findNodeHandle as findNodeHandleRN } from 'react-native';
6
6
  import { handlerIDToTag } from './handlersRegistry';
7
7
  import { toArray } from '../utils';
8
- const commonProps = ['id', 'enabled', 'shouldCancelWhenOutside', 'hitSlop'];
8
+ import RNGestureHandlerModule from '../RNGestureHandlerModule';
9
+ const commonProps = ['id', 'enabled', 'shouldCancelWhenOutside', 'hitSlop', 'cancelsTouchesInView'];
9
10
  const componentInteractionProps = ['waitFor', 'simultaneousHandlers'];
10
11
  export const baseGestureHandlerProps = [...commonProps, ...componentInteractionProps, 'onBegan', 'onFailed', 'onCancelled', 'onActivated', 'onEnded', 'onGestureEvent', 'onHandlerStateChange'];
11
12
  export const baseGestureHandlerWithMonitorProps = [...commonProps, 'needsPointerData', 'manualActivation'];
@@ -63,4 +64,13 @@ export function findNodeHandle(node) {
63
64
  if (Platform.OS === 'web') return node;
64
65
  return findNodeHandleRN(node);
65
66
  }
67
+ let scheduledFlushOperationsId = null;
68
+ export function scheduleFlushOperations() {
69
+ if (scheduledFlushOperationsId === null) {
70
+ scheduledFlushOperationsId = requestAnimationFrame(() => {
71
+ RNGestureHandlerModule.flushOperations();
72
+ scheduledFlushOperationsId = null;
73
+ });
74
+ }
75
+ }
66
76
  //# sourceMappingURL=gestureHandlerCommon.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["gestureHandlerCommon.ts"],"names":["Platform","findNodeHandle","findNodeHandleRN","handlerIDToTag","toArray","commonProps","componentInteractionProps","baseGestureHandlerProps","baseGestureHandlerWithMonitorProps","isConfigParam","param","name","undefined","Object","filterConfig","props","validProps","defaults","filteredConfig","key","value","transformIntoHandlerTags","top","left","bottom","right","handlerIDs","OS","map","current","filter","handle","handlerID","handlerT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AAN,CAAhC;AACD,OAFD,MAEO,IAAIA,GAAG,KAAK,SAAR,IAAqB,OAAOC,KAAP,KAAiB,QAA1C,EAAoD;AACzDA,QAAAA,KAAK,GAAG;AAAEE,UAAAA,GAAG,EAAEF,KAAP;AAAcG,UAAAA,IAAI,EAAEH,KAApB;AAA2BI,UAAAA,MAAM,EAAEJ,KAAnC;AAA0CK,UAAAA,KAAK,EAAEL;AAAjD,SAAR;AACD;;AACDF,MAAAA,cAAc,CAACC,GAAD,CAAd,GAAsBC,KAAtB;AACD;AACF;;AACD,SAAOF,cAAP;AACD;;AAED,SAASG,wBAAT,CAAkCK,UAAlC,EAAmD;AACjDA,EAAAA,UAAU,GAAGtB,OAAO,CAACsB,UAAD,CAApB;;AAEA,MAAI1B,QAAQ,CAAC2B,EAAT,KAAgB,KAApB,EAA2B;AACzB,WAAOD,UAAU,CACdE,GADI,CACA,CAAC;AAAEC,MAAAA;AAAF,KAAD,KAAmCA,OADnC,EAEJC,MAFI,CAEIC,MAAD,IAAiBA,MAFpB,CAAP;AAGD,GAPgD,CAQjD;;;AACA,SAAOL,UAAU,CACdE,GADI,CAEFI,SAAD;AAAA;;AAAA,WACE7B,cAAc,CAAC6B,SAAD,CAAd,2BAA6BA,SAAS,CAACH,OAAvC,uDAA6B,mBAAmBI,UAAhD,KAA8D,CAAC,CADjE;AAAA,GAFG,EAKJH,MALI,CAKIG,UAAD,IAAwBA,UAAU,GAAG,CALxC,CAAP;AAMD;;AAED,OAAO,SAAShC,cAAT,CACLiC,IADK,EAEkE;AACvE,MAAIlC,QAAQ,CAAC2B,EAAT,KAAgB,KAApB,EAA2B,OAAOO,IAAP;AAC3B,SAAOhC,gBAAgB,CAACgC,IAAD,CAAvB;AACD","sourcesContent":["// Previous types exported gesture handlers as classes which creates an interface and variable, both named the same as class.\n// Without those types, we'd introduce breaking change, forcing users to prefix every handler type specification with typeof\n// e.g. React.createRef<TapGestureHandler> -> React.createRef<typeof TapGestureHandler>.\n// See https://www.typescriptlang.org/docs/handbook/classes.html#constructor-functions for reference.\nimport * as React from 'react';\nimport { Platform, findNodeHandle as findNodeHandleRN } from 'react-native';\n\nimport { State } from '../State';\nimport { EventType } from '../EventType';\nimport { ValueOf } from '../typeUtils';\nimport { handlerIDToTag } from './handlersRegistry';\nimport { toArray } from '../utils';\n\nconst commonProps = [\n 'id',\n 'enabled',\n 'shouldCancelWhenOutside',\n 'hitSlop',\n] as const;\n\nconst componentInteractionProps = ['waitFor', 'simultaneousHandlers'] as const;\n\nexport const baseGestureHandlerProps = [\n ...commonProps,\n ...componentInteractionProps,\n 'onBegan',\n 'onFailed',\n 'onCancelled',\n 'onActivated',\n 'onEnded',\n 'onGestureEvent',\n 'onHandlerStateChange',\n] as const;\n\nexport const baseGestureHandlerWithMonitorProps = [\n ...commonProps,\n 'needsPointerData',\n 'manualActivation',\n];\n\nexport interface GestureEventPayload {\n handlerTag: number;\n numberOfPointers: number;\n state: ValueOf<typeof State>;\n}\nexport interface HandlerStateChangeEventPayload extends GestureEventPayload {\n oldState: ValueOf<typeof State>;\n}\n\nexport type HitSlop =\n | number\n | Partial<\n Record<\n 'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal',\n number\n >\n >\n | Record<'width' | 'left', number>\n | Record<'width' | 'right', number>\n | Record<'height' | 'top', number>\n | Record<'height' | 'bottom', number>;\n\n//TODO(TS) events in handlers\n\nexport interface GestureEvent<ExtraEventPayloadT = Record<string, unknown>> {\n nativeEvent: Readonly<GestureEventPayload & ExtraEventPayloadT>;\n}\nexport interface HandlerStateChangeEvent<\n ExtraEventPayloadT = Record<string, unknown>\n> {\n nativeEvent: Readonly<HandlerStateChangeEventPayload & ExtraEventPayloadT>;\n}\n\nexport type TouchData = {\n id: number;\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\n\nexport type GestureTouchEvent = {\n handlerTag: number;\n numberOfTouches: number;\n state: ValueOf<typeof State>;\n eventType: EventType;\n allTouches: TouchData[];\n changedTouches: TouchData[];\n};\n\nexport type GestureUpdateEvent<\n GestureEventPayloadT = Record<string, unknown>\n> = GestureEventPayload & GestureEventPayloadT;\n\nexport type GestureStateChangeEvent<\n GestureStateChangeEventPayloadT = Record<string, unknown>\n> = HandlerStateChangeEventPayload & GestureStateChangeEventPayloadT;\n\nexport type CommonGestureConfig = {\n enabled?: boolean;\n shouldCancelWhenOutside?: boolean;\n hitSlop?: HitSlop;\n};\n\n// Events payloads are types instead of interfaces due to TS limitation.\n// See https://github.com/microsoft/TypeScript/issues/15300 for more info.\nexport type BaseGestureHandlerProps<\n ExtraEventPayloadT extends Record<string, unknown> = Record<string, unknown>\n> = CommonGestureConfig & {\n id?: string;\n waitFor?: React.Ref<unknown> | React.Ref<unknown>[];\n simultaneousHandlers?: React.Ref<unknown> | React.Ref<unknown>[];\n testID?: string;\n // TODO(TS) - fix event types\n onBegan?: (event: HandlerStateChangeEvent) => void;\n onFailed?: (event: HandlerStateChangeEvent) => void;\n onCancelled?: (event: HandlerStateChangeEvent) => void;\n onActivated?: (event: HandlerStateChangeEvent) => void;\n onEnded?: (event: HandlerStateChangeEvent) => void;\n\n //TODO(TS) consider using NativeSyntheticEvent\n onGestureEvent?: (event: GestureEvent<ExtraEventPayloadT>) => void;\n onHandlerStateChange?: (\n event: HandlerStateChangeEvent<ExtraEventPayloadT>\n ) => void;\n};\n\nfunction isConfigParam(param: unknown, name: string) {\n // param !== Object(param) returns false if `param` is a function\n // or an object and returns true if `param` is null\n return (\n param !== undefined &&\n (param !== Object(param) ||\n !('__isNative' in (param as Record<string, unknown>))) &&\n name !== 'onHandlerStateChange' &&\n name !== 'onGestureEvent'\n );\n}\n\nexport function filterConfig(\n props: Record<string, unknown>,\n validProps: string[],\n defaults: Record<string, unknown> = {}\n) {\n const filteredConfig = { ...defaults };\n for (const key of validProps) {\n let value = props[key];\n if (isConfigParam(value, key)) {\n if (key === 'simultaneousHandlers' || key === 'waitFor') {\n value = transformIntoHandlerTags(props[key]);\n } else if (key === 'hitSlop' && typeof value !== 'object') {\n value = { top: value, left: value, bottom: value, right: value };\n }\n filteredConfig[key] = value;\n }\n }\n return filteredConfig;\n}\n\nfunction transformIntoHandlerTags(handlerIDs: any) {\n handlerIDs = toArray(handlerIDs);\n\n if (Platform.OS === 'web') {\n return handlerIDs\n .map(({ current }: { current: any }) => current)\n .filter((handle: any) => handle);\n }\n // converts handler string IDs into their numeric tags\n return handlerIDs\n .map(\n (handlerID: any) =>\n handlerIDToTag[handlerID] || handlerID.current?.handlerTag || -1\n )\n .filter((handlerTag: number) => handlerTag > 0);\n}\n\nexport function findNodeHandle(\n node: null | number | React.Component<any, any> | React.ComponentClass<any>\n): null | number | React.Component<any, any> | React.ComponentClass<any> {\n if (Platform.OS === 'web') return node;\n return findNodeHandleRN(node);\n}\n"]}
1
+ {"version":3,"sources":["gestureHandlerCommon.ts"],"names":["Platform","findNodeHandle","findNodeHandleRN","handlerIDToTag","toArray","RNGestureHandlerModule","commonProps","componentInteractionProps","baseGestureHandlerProps","baseGestureHandlerWithMonitorProps","isConfigParam","param","name","undefined","Object","filterConfig","props","validProps","defaults","filteredConfig","key","value","transformIntoHandlerTags","top","left","bottom","right","handlerIDs","OS","map","current","filter","handle","handlerID","handlerTag","node","scheduledFlushOperationsId","scheduleFlushOperations","requestAnimationFrame","flushOperations"],"mappings":"AAAA;AACA;AACA;AACA;AAEA,SAASA,QAAT,EAAmBC,cAAc,IAAIC,gBAArC,QAA6D,cAA7D;AAKA,SAASC,cAAT,QAA+B,oBAA/B;AACA,SAASC,OAAT,QAAwB,UAAxB;AACA,OAAOC,sBAAP,MAAmC,2BAAnC;AAEA,MAAMC,WAAW,GAAG,CAClB,IADkB,EAElB,SAFkB,EAGlB,yBAHkB,EAIlB,SAJkB,EAKlB,sBALkB,CAApB;AAQA,MAAMC,yBAAyB,GAAG,CAAC,SAAD,EAAY,sBAAZ,CAAlC;AAEA,OAAO,MAAMC,uBAAuB,GAAG,CACrC,GAAGF,WADkC,EAErC,GAAGC,yBAFkC,E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AkCK,UAAlC,EAAmD;AACjDA,EAAAA,UAAU,GAAGvB,OAAO,CAACuB,UAAD,CAApB;;AAEA,MAAI3B,QAAQ,CAAC4B,EAAT,KAAgB,KAApB,EAA2B;AACzB,WAAOD,UAAU,CACdE,GADI,CACA,CAAC;AAAEC,MAAAA;AAAF,KAAD,KAAmCA,OADnC,EAEJC,MAFI,CAEIC,MAAD,IAAiBA,MAFpB,CAAP;AAGD,GAPgD,CAQjD;;;AACA,SAAOL,UAAU,CACdE,GADI,CAEFI,SAAD;AAAA;;AAAA,WACE9B,cAAc,CAAC8B,SAAD,CAAd,2BAA6BA,SAAS,CAACH,OAAvC,uDAA6B,mBAAmBI,UAAhD,KAA8D,CAAC,CADjE;AAAA,GAFG,EAKJH,MALI,CAKIG,UAAD,IAAwBA,UAAU,GAAG,CALxC,CAAP;AAMD;;AAED,OAAO,SAASjC,cAAT,CACLkC,IADK,EAEkE;AACvE,MAAInC,QAAQ,CAAC4B,EAAT,KAAgB,KAApB,EAA2B,OAAOO,IAAP;AAC3B,SAAOjC,gBAAgB,CAACiC,IAAD,CAAvB;AACD;AAED,IAAIC,0BAEI,GAAG,IAFX;AAIA,OAAO,SAASC,uBAAT,GAAmC;AACxC,MAAID,0BAA0B,KAAK,IAAnC,EAAyC;AACvCA,IAAAA,0BAA0B,GAAGE,qBAAqB,CAAC,MAAM;AACvDjC,MAAAA,sBAAsB,CAACkC,eAAvB;AAEAH,MAAAA,0BAA0B,GAAG,IAA7B;AACD,KAJiD,CAAlD;AAKD;AACF","sourcesContent":["// Previous types exported gesture handlers as classes which creates an interface and variable, both named the same as class.\n// Without those types, we'd introduce breaking change, forcing users to prefix every handler type specification with typeof\n// e.g. React.createRef<TapGestureHandler> -> React.createRef<typeof TapGestureHandler>.\n// See https://www.typescriptlang.org/docs/handbook/classes.html#constructor-functions for reference.\nimport * as React from 'react';\nimport { Platform, findNodeHandle as findNodeHandleRN } from 'react-native';\n\nimport { State } from '../State';\nimport { TouchEventType } from '../TouchEventType';\nimport { ValueOf } from '../typeUtils';\nimport { handlerIDToTag } from './handlersRegistry';\nimport { toArray } from '../utils';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\n\nconst commonProps = [\n 'id',\n 'enabled',\n 'shouldCancelWhenOutside',\n 'hitSlop',\n 'cancelsTouchesInView',\n] as const;\n\nconst componentInteractionProps = ['waitFor', 'simultaneousHandlers'] as const;\n\nexport const baseGestureHandlerProps = [\n ...commonProps,\n ...componentInteractionProps,\n 'onBegan',\n 'onFailed',\n 'onCancelled',\n 'onActivated',\n 'onEnded',\n 'onGestureEvent',\n 'onHandlerStateChange',\n] as const;\n\nexport const baseGestureHandlerWithMonitorProps = [\n ...commonProps,\n 'needsPointerData',\n 'manualActivation',\n];\n\nexport interface GestureEventPayload {\n handlerTag: number;\n numberOfPointers: number;\n state: ValueOf<typeof State>;\n}\nexport interface HandlerStateChangeEventPayload extends GestureEventPayload {\n oldState: ValueOf<typeof State>;\n}\n\nexport type HitSlop =\n | number\n | Partial<\n Record<\n 'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal',\n number\n >\n >\n | Record<'width' | 'left', number>\n | Record<'width' | 'right', number>\n | Record<'height' | 'top', number>\n | Record<'height' | 'bottom', number>;\n\n//TODO(TS) events in handlers\n\nexport interface GestureEvent<ExtraEventPayloadT = Record<string, unknown>> {\n nativeEvent: Readonly<GestureEventPayload & ExtraEventPayloadT>;\n}\nexport interface HandlerStateChangeEvent<\n ExtraEventPayloadT = Record<string, unknown>\n> {\n nativeEvent: Readonly<HandlerStateChangeEventPayload & ExtraEventPayloadT>;\n}\n\nexport type TouchData = {\n id: number;\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\n\nexport type GestureTouchEvent = {\n handlerTag: number;\n numberOfTouches: number;\n state: ValueOf<typeof State>;\n eventType: TouchEventType;\n allTouches: TouchData[];\n changedTouches: TouchData[];\n};\n\nexport type GestureUpdateEvent<\n GestureEventPayloadT = Record<string, unknown>\n> = GestureEventPayload & GestureEventPayloadT;\n\nexport type GestureStateChangeEvent<\n GestureStateChangeEventPayloadT = Record<string, unknown>\n> = HandlerStateChangeEventPayload & GestureStateChangeEventPayloadT;\n\nexport type CommonGestureConfig = {\n enabled?: boolean;\n shouldCancelWhenOutside?: boolean;\n hitSlop?: HitSlop;\n};\n\n// Events payloads are types instead of interfaces due to TS limitation.\n// See https://github.com/microsoft/TypeScript/issues/15300 for more info.\nexport type BaseGestureHandlerProps<\n ExtraEventPayloadT extends Record<string, unknown> = Record<string, unknown>\n> = CommonGestureConfig & {\n id?: string;\n waitFor?: React.Ref<unknown> | React.Ref<unknown>[];\n simultaneousHandlers?: React.Ref<unknown> | React.Ref<unknown>[];\n testID?: string;\n cancelsTouchesInView?: boolean;\n // TODO(TS) - fix event types\n onBegan?: (event: HandlerStateChangeEvent) => void;\n onFailed?: (event: HandlerStateChangeEvent) => void;\n onCancelled?: (event: HandlerStateChangeEvent) => void;\n onActivated?: (event: HandlerStateChangeEvent) => void;\n onEnded?: (event: HandlerStateChangeEvent) => void;\n\n //TODO(TS) consider using NativeSyntheticEvent\n onGestureEvent?: (event: GestureEvent<ExtraEventPayloadT>) => void;\n onHandlerStateChange?: (\n event: HandlerStateChangeEvent<ExtraEventPayloadT>\n ) => void;\n // implicit `children` prop has been removed in @types/react^18.0.0\n children?: React.ReactNode;\n};\n\nfunction isConfigParam(param: unknown, name: string) {\n // param !== Object(param) returns false if `param` is a function\n // or an object and returns true if `param` is null\n return (\n param !== undefined &&\n (param !== Object(param) ||\n !('__isNative' in (param as Record<string, unknown>))) &&\n name !== 'onHandlerStateChange' &&\n name !== 'onGestureEvent'\n );\n}\n\nexport function filterConfig(\n props: Record<string, unknown>,\n validProps: string[],\n defaults: Record<string, unknown> = {}\n) {\n const filteredConfig = { ...defaults };\n for (const key of validProps) {\n let value = props[key];\n if (isConfigParam(value, key)) {\n if (key === 'simultaneousHandlers' || key === 'waitFor') {\n value = transformIntoHandlerTags(props[key]);\n } else if (key === 'hitSlop' && typeof value !== 'object') {\n value = { top: value, left: value, bottom: value, right: value };\n }\n filteredConfig[key] = value;\n }\n }\n return filteredConfig;\n}\n\nfunction transformIntoHandlerTags(handlerIDs: any) {\n handlerIDs = toArray(handlerIDs);\n\n if (Platform.OS === 'web') {\n return handlerIDs\n .map(({ current }: { current: any }) => current)\n .filter((handle: any) => handle);\n }\n // converts handler string IDs into their numeric tags\n return handlerIDs\n .map(\n (handlerID: any) =>\n handlerIDToTag[handlerID] || handlerID.current?.handlerTag || -1\n )\n .filter((handlerTag: number) => handlerTag > 0);\n}\n\nexport function findNodeHandle(\n node: null | number | React.Component<any, any> | React.ComponentClass<any>\n): null | number | React.Component<any, any> | React.ComponentClass<any> {\n if (Platform.OS === 'web') return node;\n return findNodeHandleRN(node);\n}\n\nlet scheduledFlushOperationsId: ReturnType<\n typeof requestAnimationFrame\n> | null = null;\n\nexport function scheduleFlushOperations() {\n if (scheduledFlushOperationsId === null) {\n scheduledFlushOperationsId = requestAnimationFrame(() => {\n RNGestureHandlerModule.flushOperations();\n\n scheduledFlushOperationsId = null;\n });\n }\n}\n"]}