react-native-gesture-handler 2.9.0 → 2.10.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -0
- package/RNGestureHandler.podspec +1 -1
- package/android/build.gradle +69 -29
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +2 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt +39 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +8 -2
- package/ios/Handlers/RNNativeViewHandler.mm +4 -4
- package/ios/RNGestureHandlerButtonComponentView.h +2 -2
- package/ios/RNGestureHandlerButtonComponentView.mm +2 -2
- package/ios/RNGestureHandlerManager.mm +9 -9
- package/ios/RNGestureHandlerModule.mm +16 -16
- package/ios/RNGestureHandlerRootViewComponentView.mm +2 -2
- package/ios/RNRootViewGestureRecognizer.m +3 -3
- package/lib/commonjs/EnableNewWebImplementation.js +35 -0
- package/lib/commonjs/EnableNewWebImplementation.js.map +1 -0
- package/lib/commonjs/GestureHandlerRootViewContext.js +15 -0
- package/lib/commonjs/GestureHandlerRootViewContext.js.map +1 -0
- package/lib/commonjs/RNGestureHandlerModule.macos.js +6 -6
- package/lib/commonjs/RNGestureHandlerModule.macos.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.web.js +6 -6
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.windows.js +6 -6
- package/lib/commonjs/RNGestureHandlerModule.windows.js.map +1 -1
- package/lib/commonjs/components/GestureComponents.web.js +6 -5
- package/lib/commonjs/components/GestureComponents.web.js.map +1 -1
- package/lib/commonjs/components/GestureHandlerButton.js +3 -5
- package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
- package/lib/commonjs/{GestureHandlerRootView.android.js → components/GestureHandlerRootView.android.js} +8 -7
- package/lib/commonjs/components/GestureHandlerRootView.android.js.map +1 -0
- package/lib/commonjs/{GestureHandlerRootView.js → components/GestureHandlerRootView.js} +8 -2
- package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -0
- package/lib/commonjs/{GestureHandlerRootView.web.js → components/GestureHandlerRootView.web.js} +7 -1
- package/lib/commonjs/components/GestureHandlerRootView.web.js.map +1 -0
- package/lib/commonjs/components/Swipeable.js +17 -3
- package/lib/commonjs/components/Swipeable.js.map +1 -1
- package/lib/commonjs/{gestureHandlerRootHOC.js.map → components/gestureHandlerRootHOC.js.map} +1 -1
- package/lib/commonjs/handlers/createHandler.js +21 -13
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js +5 -4
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector.js +19 -9
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/commonjs/handlers/gestures/reanimatedWrapper.js +22 -19
- package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -1
- package/lib/commonjs/index.js +16 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils.js +0 -6
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/handlers/FlingGestureHandler.js +0 -5
- package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js +3 -0
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/ManualGestureHandler.js +0 -5
- package/lib/commonjs/web/handlers/ManualGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +0 -6
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js +2 -12
- package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PinchGestureHandler.js +0 -5
- package/lib/commonjs/web/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/RotationGestureHandler.js +0 -6
- package/lib/commonjs/web/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/TapGestureHandler.js +0 -6
- package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/commonjs/web/tools/CircularBuffer.js +59 -0
- package/lib/commonjs/web/tools/CircularBuffer.js.map +1 -0
- package/lib/commonjs/web/tools/LeastSquareSolver.js +204 -0
- package/lib/commonjs/web/tools/LeastSquareSolver.js.map +1 -0
- package/lib/commonjs/web/tools/PointerEventManager.js +27 -0
- package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/PointerTracker.js +11 -7
- package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
- package/lib/commonjs/web/tools/VelocityTracker.js +111 -0
- package/lib/commonjs/web/tools/VelocityTracker.js.map +1 -0
- package/lib/commonjs/web_hammer/GestureHandler.js +1 -1
- package/lib/commonjs/web_hammer/GestureHandler.js.map +1 -1
- package/lib/module/EnableNewWebImplementation.js +22 -0
- package/lib/module/EnableNewWebImplementation.js.map +1 -0
- package/lib/module/GestureHandlerRootViewContext.js +3 -0
- package/lib/module/GestureHandlerRootViewContext.js.map +1 -0
- package/lib/module/RNGestureHandlerModule.macos.js +6 -6
- package/lib/module/RNGestureHandlerModule.macos.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.web.js +6 -6
- package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.windows.js +6 -6
- package/lib/module/RNGestureHandlerModule.windows.js.map +1 -1
- package/lib/module/components/GestureComponents.web.js +5 -6
- package/lib/module/components/GestureComponents.web.js.map +1 -1
- package/lib/module/components/GestureHandlerButton.js +1 -4
- package/lib/module/components/GestureHandlerButton.js.map +1 -1
- package/lib/module/components/GestureHandlerRootView.android.js +14 -0
- package/lib/module/components/GestureHandlerRootView.android.js.map +1 -0
- package/lib/module/{GestureHandlerRootView.js → components/GestureHandlerRootView.js} +5 -2
- package/lib/module/components/GestureHandlerRootView.js.map +1 -0
- package/lib/module/components/GestureHandlerRootView.web.js +9 -0
- package/lib/module/components/GestureHandlerRootView.web.js.map +1 -0
- package/lib/module/components/Swipeable.js +17 -3
- package/lib/module/components/Swipeable.js.map +1 -1
- package/lib/module/{gestureHandlerRootHOC.js.map → components/gestureHandlerRootHOC.js.map} +1 -1
- package/lib/module/handlers/createHandler.js +20 -13
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js +5 -4
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector.js +18 -10
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/module/handlers/gestures/reanimatedWrapper.js +19 -16
- package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -1
- package/lib/module/index.js +4 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils.js +0 -4
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/handlers/FlingGestureHandler.js +0 -5
- package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js +3 -0
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/ManualGestureHandler.js +0 -5
- package/lib/module/web/handlers/ManualGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/NativeViewGestureHandler.js +0 -6
- package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +2 -9
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PinchGestureHandler.js +0 -5
- package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/RotationGestureHandler.js +0 -6
- package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/TapGestureHandler.js +0 -6
- package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/module/web/tools/CircularBuffer.js +50 -0
- package/lib/module/web/tools/CircularBuffer.js.map +1 -0
- package/lib/module/web/tools/LeastSquareSolver.js +195 -0
- package/lib/module/web/tools/LeastSquareSolver.js.map +1 -0
- package/lib/module/web/tools/PointerEventManager.js +27 -0
- package/lib/module/web/tools/PointerEventManager.js.map +1 -1
- package/lib/module/web/tools/PointerTracker.js +8 -7
- package/lib/module/web/tools/PointerTracker.js.map +1 -1
- package/lib/module/web/tools/VelocityTracker.js +98 -0
- package/lib/module/web/tools/VelocityTracker.js.map +1 -0
- package/lib/module/web_hammer/GestureHandler.js +1 -1
- package/lib/module/web_hammer/GestureHandler.js.map +1 -1
- package/lib/typescript/EnableNewWebImplementation.d.ts +3 -0
- package/lib/typescript/GestureHandlerRootViewContext.d.ts +3 -0
- package/lib/typescript/components/GestureComponents.web.d.ts +1 -1
- package/lib/typescript/components/Swipeable.d.ts +12 -1
- package/lib/typescript/{gestureHandlerRootHOC.d.ts → components/gestureHandlerRootHOC.d.ts} +1 -1
- package/lib/typescript/index.d.ts +4 -4
- package/lib/typescript/utils.d.ts +0 -1
- package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/PanGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/TapGestureHandler.d.ts +0 -1
- package/lib/typescript/web/tools/CircularBuffer.d.ts +11 -0
- package/lib/typescript/web/tools/LeastSquareSolver.d.ts +12 -0
- package/lib/typescript/web/tools/PointerEventManager.d.ts +2 -0
- package/lib/typescript/web/tools/PointerTracker.d.ts +1 -0
- package/lib/typescript/web/tools/VelocityTracker.d.ts +13 -0
- package/package.json +3 -3
- package/src/EnableNewWebImplementation.ts +35 -0
- package/src/GestureHandlerRootViewContext.ts +3 -0
- package/src/RNGestureHandlerModule.macos.ts +6 -6
- package/src/RNGestureHandlerModule.web.ts +6 -6
- package/src/RNGestureHandlerModule.windows.ts +6 -6
- package/src/components/GestureComponents.web.tsx +5 -6
- package/src/components/GestureHandlerButton.tsx +2 -7
- package/src/components/GestureHandlerRootView.android.tsx +24 -0
- package/src/{GestureHandlerRootView.tsx → components/GestureHandlerRootView.tsx} +7 -2
- package/src/{GestureHandlerRootView.web.tsx → components/GestureHandlerRootView.web.tsx} +6 -1
- package/src/components/Swipeable.tsx +30 -4
- package/src/{gestureHandlerRootHOC.tsx → components/gestureHandlerRootHOC.tsx} +1 -1
- package/src/handlers/createHandler.tsx +20 -9
- package/src/handlers/gestureHandlerCommon.ts +5 -6
- package/src/handlers/gestures/GestureDetector.tsx +19 -9
- package/src/handlers/gestures/reanimatedWrapper.ts +21 -20
- package/src/index.ts +7 -3
- package/src/utils.ts +0 -5
- package/src/web/handlers/FlingGestureHandler.ts +0 -5
- package/src/web/handlers/GestureHandler.ts +3 -0
- package/src/web/handlers/ManualGestureHandler.ts +0 -5
- package/src/web/handlers/NativeViewGestureHandler.ts +0 -6
- package/src/web/handlers/PanGestureHandler.ts +2 -9
- package/src/web/handlers/PinchGestureHandler.ts +0 -5
- package/src/web/handlers/RotationGestureHandler.ts +0 -7
- package/src/web/handlers/TapGestureHandler.ts +0 -6
- package/src/web/tools/CircularBuffer.ts +42 -0
- package/src/web/tools/LeastSquareSolver.ts +182 -0
- package/src/web/tools/PointerEventManager.ts +29 -0
- package/src/web/tools/PointerTracker.ts +7 -7
- package/src/web/tools/VelocityTracker.ts +98 -0
- package/src/web_hammer/GestureHandler.ts +1 -1
- package/lib/commonjs/EnableExperimentalWebImplementation.js +0 -31
- package/lib/commonjs/EnableExperimentalWebImplementation.js.map +0 -1
- package/lib/commonjs/GestureHandlerRootView.android.js.map +0 -1
- package/lib/commonjs/GestureHandlerRootView.js.map +0 -1
- package/lib/commonjs/GestureHandlerRootView.web.js.map +0 -1
- package/lib/module/EnableExperimentalWebImplementation.js +0 -20
- package/lib/module/EnableExperimentalWebImplementation.js.map +0 -1
- package/lib/module/GestureHandlerRootView.android.js +0 -14
- package/lib/module/GestureHandlerRootView.android.js.map +0 -1
- package/lib/module/GestureHandlerRootView.js.map +0 -1
- package/lib/module/GestureHandlerRootView.web.js +0 -6
- package/lib/module/GestureHandlerRootView.web.js.map +0 -1
- package/lib/typescript/EnableExperimentalWebImplementation.d.ts +0 -2
- package/src/EnableExperimentalWebImplementation.ts +0 -27
- package/src/GestureHandlerRootView.android.tsx +0 -24
- /package/lib/commonjs/{gestureHandlerRootHOC.js → components/gestureHandlerRootHOC.js} +0 -0
- /package/lib/commonjs/{fabric → specs}/RNGestureHandlerButtonNativeComponent.js +0 -0
- /package/lib/commonjs/{fabric → specs}/RNGestureHandlerButtonNativeComponent.js.map +0 -0
- /package/lib/commonjs/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.js +0 -0
- /package/lib/commonjs/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.js.map +0 -0
- /package/lib/module/{gestureHandlerRootHOC.js → components/gestureHandlerRootHOC.js} +0 -0
- /package/lib/module/{fabric → specs}/RNGestureHandlerButtonNativeComponent.js +0 -0
- /package/lib/module/{fabric → specs}/RNGestureHandlerButtonNativeComponent.js.map +0 -0
- /package/lib/module/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.js +0 -0
- /package/lib/module/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.js.map +0 -0
- /package/lib/typescript/{GestureHandlerRootView.android.d.ts → components/GestureHandlerRootView.android.d.ts} +0 -0
- /package/lib/typescript/{GestureHandlerRootView.d.ts → components/GestureHandlerRootView.d.ts} +0 -0
- /package/lib/typescript/{GestureHandlerRootView.web.d.ts → components/GestureHandlerRootView.web.d.ts} +0 -0
- /package/lib/typescript/{fabric → specs}/RNGestureHandlerButtonNativeComponent.d.ts +0 -0
- /package/lib/typescript/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.d.ts +0 -0
- /package/src/{fabric → specs}/RNGestureHandlerButtonNativeComponent.ts +0 -0
- /package/src/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.ts +0 -0
package/lib/commonjs/{gestureHandlerRootHOC.js.map → components/gestureHandlerRootHOC.js.map}
RENAMED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["gestureHandlerRootHOC.tsx"],"names":["gestureHandlerRootHOC","Component","containerStyles","Wrapper","props","styles","container","displayName","name","StyleSheet","create","flex"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;AAEe,SAASA,qBAAT,CAGbC,SAHa,EAIbC,eAJa,EAKW;AACxB,WAASC,OAAT,CAAiBC,KAAjB,EAA2B;AACzB,wBACE,oBAAC,+BAAD;AAAwB,MAAA,KAAK,EAAE,CAACC,MAAM,CAACC,SAAR,EAAmBJ,eAAnB;AAA/B,oBACE,oBAAC,SAAD,EAAeE,KAAf,CADF,CADF;AAKD;;AAEDD,EAAAA,OAAO,CAACI,WAAR,GAAuB,yBACrBN,SAAS,CAACM,WAAV,IAAyBN,SAAS,CAACO,IACpC,GAFD,CATwB,CAaxB;;AACA,qCAAqBL,OAArB,EAA8BF,SAA9B;AAEA,SAAOE,OAAP;AACD;;AAED,MAAME,MAAM,GAAGI,wBAAWC,MAAX,CAAkB;AAC/BJ,EAAAA,SAAS,EAAE;AAAEK,IAAAA,IAAI,EAAE;AAAR;AADoB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport { StyleSheet, StyleProp, ViewStyle } from 'react-native';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport GestureHandlerRootView from './GestureHandlerRootView';\n\nexport default function gestureHandlerRootHOC<\n P extends
|
1
|
+
{"version":3,"sources":["gestureHandlerRootHOC.tsx"],"names":["gestureHandlerRootHOC","Component","containerStyles","Wrapper","props","styles","container","displayName","name","StyleSheet","create","flex"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;AAEe,SAASA,qBAAT,CAGbC,SAHa,EAIbC,eAJa,EAKW;AACxB,WAASC,OAAT,CAAiBC,KAAjB,EAA2B;AACzB,wBACE,oBAAC,+BAAD;AAAwB,MAAA,KAAK,EAAE,CAACC,MAAM,CAACC,SAAR,EAAmBJ,eAAnB;AAA/B,oBACE,oBAAC,SAAD,EAAeE,KAAf,CADF,CADF;AAKD;;AAEDD,EAAAA,OAAO,CAACI,WAAR,GAAuB,yBACrBN,SAAS,CAACM,WAAV,IAAyBN,SAAS,CAACO,IACpC,GAFD,CATwB,CAaxB;;AACA,qCAAqBL,OAArB,EAA8BF,SAA9B;AAEA,SAAOE,OAAP;AACD;;AAED,MAAME,MAAM,GAAGI,wBAAWC,MAAX,CAAkB;AAC/BJ,EAAAA,SAAS,EAAE;AAAEK,IAAAA,IAAI,EAAE;AAAR;AADoB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport { StyleSheet, StyleProp, ViewStyle } from 'react-native';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport GestureHandlerRootView from './GestureHandlerRootView';\n\nexport default function gestureHandlerRootHOC<\n P extends Record<string, unknown>\n>(\n Component: React.ComponentType<P>,\n containerStyles?: StyleProp<ViewStyle>\n): React.ComponentType<P> {\n function Wrapper(props: P) {\n return (\n <GestureHandlerRootView style={[styles.container, containerStyles]}>\n <Component {...props} />\n </GestureHandlerRootView>\n );\n }\n\n Wrapper.displayName = `gestureHandlerRootHOC(${\n Component.displayName || Component.name\n })`;\n\n // @ts-ignore - hoistNonReactStatics uses old version of @types/react\n hoistNonReactStatics(Wrapper, Component);\n\n return Wrapper;\n}\n\nconst styles = StyleSheet.create({\n container: { flex: 1 },\n});\n"]}
|
@@ -25,6 +25,8 @@ var _ActionType = require("../ActionType");
|
|
25
25
|
|
26
26
|
var _PressabilityDebugView = require("./PressabilityDebugView");
|
27
27
|
|
28
|
+
var _GestureHandlerRootViewContext = _interopRequireDefault(require("../GestureHandlerRootViewContext"));
|
29
|
+
|
28
30
|
var _UIManagerAny$getView, _UIManagerAny$getView2, _UIManagerAny$getCons;
|
29
31
|
|
30
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -149,12 +151,12 @@ function createHandler({
|
|
149
151
|
|
150
152
|
_defineProperty(this, "propsRef", void 0);
|
151
153
|
|
154
|
+
_defineProperty(this, "isMountedRef", void 0);
|
155
|
+
|
152
156
|
_defineProperty(this, "viewNode", void 0);
|
153
157
|
|
154
158
|
_defineProperty(this, "viewTag", void 0);
|
155
159
|
|
156
|
-
_defineProperty(this, "updateEnqueued", null);
|
157
|
-
|
158
160
|
_defineProperty(this, "inspectorToggleListener", void 0);
|
159
161
|
|
160
162
|
_defineProperty(this, "onGestureHandlerEvent", event => {
|
@@ -261,6 +263,7 @@ function createHandler({
|
|
261
263
|
this.handlerTag = (0, _handlersRegistry.getNextHandlerTag)();
|
262
264
|
this.config = {};
|
263
265
|
this.propsRef = /*#__PURE__*/React.createRef();
|
266
|
+
this.isMountedRef = /*#__PURE__*/React.createRef();
|
264
267
|
this.state = {
|
265
268
|
allowTouches
|
266
269
|
};
|
@@ -276,6 +279,7 @@ function createHandler({
|
|
276
279
|
|
277
280
|
componentDidMount() {
|
278
281
|
const props = this.props;
|
282
|
+
this.isMountedRef.current = true;
|
279
283
|
|
280
284
|
if (DEV_ON_ANDROID) {
|
281
285
|
this.inspectorToggleListener = _reactNative.DeviceEventEmitter.addListener('toggleElementInspector', () => {
|
@@ -290,11 +294,10 @@ function createHandler({
|
|
290
294
|
// If there are unresolved refs (e.g. ".current" has not yet been set)
|
291
295
|
// passed as `simultaneousHandlers` or `waitFor`, we enqueue a call to
|
292
296
|
// _update method that will try to update native handler props using
|
293
|
-
//
|
297
|
+
// queueMicrotask. This makes it so update() function gets called after all
|
294
298
|
// react components are mounted and we expect the missing ref object to
|
295
299
|
// be resolved by then.
|
296
|
-
|
297
|
-
this.updateEnqueued = null;
|
300
|
+
queueMicrotask(() => {
|
298
301
|
this.update(UNRESOLVED_REFS_RETRY_LIMIT);
|
299
302
|
});
|
300
303
|
}
|
@@ -317,15 +320,11 @@ function createHandler({
|
|
317
320
|
var _this$inspectorToggle;
|
318
321
|
|
319
322
|
(_this$inspectorToggle = this.inspectorToggleListener) === null || _this$inspectorToggle === void 0 ? void 0 : _this$inspectorToggle.remove();
|
323
|
+
this.isMountedRef.current = false;
|
320
324
|
|
321
325
|
_RNGestureHandlerModule.default.dropGestureHandler(this.handlerTag);
|
322
326
|
|
323
|
-
(0, _gestureHandlerCommon.scheduleFlushOperations)();
|
324
|
-
|
325
|
-
if (this.updateEnqueued) {
|
326
|
-
clearImmediate(this.updateEnqueued);
|
327
|
-
} // 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
|
328
|
-
|
327
|
+
(0, _gestureHandlerCommon.scheduleFlushOperations)(); // 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
|
329
328
|
|
330
329
|
const handlerID = this.props.id;
|
331
330
|
|
@@ -336,13 +335,16 @@ function createHandler({
|
|
336
335
|
}
|
337
336
|
|
338
337
|
update(remainingTries) {
|
338
|
+
if (!this.isMountedRef.current) {
|
339
|
+
return;
|
340
|
+
}
|
341
|
+
|
339
342
|
const props = this.props; // When ref is set via a function i.e. `ref={(r) => refObject.current = r}` instead of
|
340
343
|
// `ref={refObject}` it's possible that it won't be resolved in time. Seems like trying
|
341
344
|
// again is easy enough fix.
|
342
345
|
|
343
346
|
if (hasUnresolvedRefs(props) && remainingTries > 0) {
|
344
|
-
|
345
|
-
this.updateEnqueued = null;
|
347
|
+
queueMicrotask(() => {
|
346
348
|
this.update(remainingTries - 1);
|
347
349
|
});
|
348
350
|
} else {
|
@@ -365,6 +367,10 @@ function createHandler({
|
|
365
367
|
render() {
|
366
368
|
var _this$props$testID;
|
367
369
|
|
370
|
+
if (__DEV__ && !this.context) {
|
371
|
+
throw new Error(name + ' must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.');
|
372
|
+
}
|
373
|
+
|
368
374
|
let gestureEventHandler = this.onGestureHandlerEvent; // Another instance of https://github.com/microsoft/TypeScript/issues/13995
|
369
375
|
|
370
376
|
const {
|
@@ -449,6 +455,8 @@ function createHandler({
|
|
449
455
|
|
450
456
|
_defineProperty(Handler, "displayName", name);
|
451
457
|
|
458
|
+
_defineProperty(Handler, "contextType", _GestureHandlerRootViewContext.default);
|
459
|
+
|
452
460
|
return Handler;
|
453
461
|
}
|
454
462
|
//# sourceMappingURL=createHandler.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["createHandler.tsx"],"names":["UIManagerAny","UIManager","customGHEventsConfigFabricAndroid","topOnGestureHandlerEvent","registrationName","topOnGestureHandlerStateChange","customGHEventsConfig","onGestureHandlerEvent","onGestureHandlerStateChange","Platform","OS","genericDirectEventTypes","UIManagerConstants","getViewManagerConfig","getConstants","setJSResponder","oldSetJSResponder","clearJSResponder","oldClearJSResponder","tag","blockNativeResponder","RNGestureHandlerModule","handleSetJSResponder","handleClearJSResponder","allowTouches","DEV_ON_ANDROID","__DEV__","DeviceEventEmitter","addListener","hasUnresolvedRefs","props","extract","refs","Array","isArray","current","some","r","stateToPropMappings","State","UNDETERMINED","undefined","BEGAN","FAILED","CANCELLED","ACTIVE","END","UNRESOLVED_REFS_RETRY_LIMIT","createHandler","name","allowedProps","config","transformProps","customNativeProps","Handler","React","Component","constructor","event","nativeEvent","handlerTag","onGestureEvent","onHandlerStateChange","state","stateEventName","eventHandler","node","viewNode","child","Children","only","children","ref","newConfig","createGestureHandler","newViewTag","viewTag","attachGestureHandler","ActionType","JS_FUNCTION_OLD_API","propsRef","onGestureStateChange","actionType","REANIMATED_WORKLET","NATIVE_ANIMATED_EVENT","updateGestureHandler","createRef","id","handlerIDToTag","Error","componentDidMount","inspectorToggleListener","setState","_","update","updateEnqueued","setImmediate","componentDidUpdate","componentWillUnmount","remove","dropGestureHandler","clearImmediate","handlerID","remainingTries","setNativeProps","updates","mergedProps","render","gestureEventHandler","gestureStateEventHandler","events","e","grandChildren","type","displayName","toArray","push","hitSlop","cloneElement","refHandler","collapsable","handlerType","testID"],"mappings":";;;;;;;AAAA;;AACA;;AAOA;;AACA;;AAEA;;AACA;;AAMA;;AASA;;AACA;;AACA;;;;;;;;;;;;AAEA,MAAMA,YAAY,GAAGC,sBAArB;AAEA,MAAMC,iCAAiC,GAAG;AACxCC,EAAAA,wBAAwB,EAAE;AAAEC,IAAAA,gBAAgB,EAAE;AAApB,GADc;AAExCC,EAAAA,8BAA8B,EAAE;AAC9BD,IAAAA,gBAAgB,EAAE;AADY;AAFQ,CAA1C;AAOA,MAAME,oBAAoB,GAAG;AAC3BC,EAAAA,qBAAqB,EAAE;AAAEH,IAAAA,gBAAgB,EAAE;AAApB,GADI;AAE3BI,EAAAA,2BAA2B,EAAE;AAC3BJ,IAAAA,gBAAgB,EAAE;AADS,GAFF;AAM3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAI,0BACFK,sBAASC,EAAT,KAAgB,SADd,IAEFR,iCAFF;AAd2B,CAA7B,C,CAmBA;AACA;AACA;AACA;;AACAF,YAAY,CAACW,uBAAb,GAAuC,EACrC,GAAGX,YAAY,CAACW,uBADqB;AAErC,KAAGL;AAFkC,CAAvC,C,CAIA;AACA;AACA;;AACA,MAAMM,kBAAkB,sDACtBZ,YAAY,CAACa,oBADS,2DACtB,4BAAAb,YAAY,EAAwB,cAAxB,CADU,kGAEtBA,YAAY,CAACc,YAFS,0DAEtB,2BAAAd,YAAY,CAFd;;AAIA,IAAIY,kBAAJ,EAAwB;AACtBA,EAAAA,kBAAkB,CAACD,uBAAnB,GAA6C,EAC3C,GAAGC,kBAAkB,CAACD,uBADqB;AAE3C,OAAGL;AAFwC,GAA7C;AAID,C,CAED;;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,IAAItB,KAAJ,CACJ,uBACG,GAAExC,IAAK,4JADV,CADI,CAAN;AAKD;;AAED,UAAI+D,aAAa,GAAG5C,KAAK,CAACtC,KAAN,CAAYyC,QAAhC;;AACA,UACE7C,OAAO,IACP0C,KAAK,CAAC6C,IADN,KAEC7C,KAAK,CAAC6C,IAAN,KAAe,wBAAf,IACC7C,KAAK,CAAC6C,IAAN,CAAWhE,IAAX,KAAoB,MADrB,IAECmB,KAAK,CAAC6C,IAAN,CAAWC,WAAX,KAA2B,MAJ7B,CADF,EAME;AACAF,QAAAA,aAAa,GAAGzD,KAAK,CAACc,QAAN,CAAe8C,OAAf,CAAuBH,aAAvB,CAAhB;AACAA,QAAAA,aAAa,CAACI,IAAd,eACE,oBAAC,4CAAD;AACE,UAAA,GAAG,EAAC,uBADN;AAEE,UAAA,KAAK,EAAC,mBAFR;AAGE,UAAA,OAAO,EAAEhD,KAAK,CAACtC,KAAN,CAAYuF;AAHvB,UADF;AAOD;;AAED,0BAAO9D,KAAK,CAAC+D,YAAN,CACLlD,KADK,EAEL;AACEI,QAAAA,GAAG,EAAE,KAAK+C,UADZ;AAEEC,QAAAA,WAAW,EAAE,KAFf;AAGE,YAAI,0BACA;AACEC,UAAAA,WAAW,EAAExE,IADf;AAEEW,UAAAA,UAAU,EAAE,KAAKA;AAFnB,SADA,GAKA,EALJ,CAHF;AASE8D,QAAAA,MAAM,wBAAE,KAAK5F,KAAL,CAAW4F,MAAb,mEAAuBtD,KAAK,CAACtC,KAAN,CAAY4F,MAT3C;AAUE,WAAGZ;AAVL,OAFK,EAcLE,aAdK,CAAP;AAgBD;;AA3VD;;AAPwE,kBAIpE1D,OAJoE,iBAQnDL,IARmD;;AAoW1E,SAAOK,OAAP;AACD","sourcesContent":["import * as React from 'react';\nimport {\n Platform,\n UIManager,\n DeviceEventEmitter,\n EmitterSubscription,\n} from 'react-native';\n// @ts-ignore - it isn't typed by TS & don't have definitelyTyped types\nimport deepEqual from 'lodash/isEqual';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\nimport type RNGestureHandlerModuleWeb from '../RNGestureHandlerModule.web';\nimport { State } from '../State';\nimport {\n handlerIDToTag,\n getNextHandlerTag,\n registerOldGestureHandler,\n} from './handlersRegistry';\n\nimport {\n BaseGestureHandlerProps,\n filterConfig,\n GestureEvent,\n HandlerStateChangeEvent,\n findNodeHandle,\n scheduleFlushOperations,\n} from './gestureHandlerCommon';\nimport { ValueOf } from '../typeUtils';\nimport { isFabric, isJestEnv, tagMessage } from '../utils';\nimport { ActionType } from '../ActionType';\nimport { PressabilityDebugView } from './PressabilityDebugView';\n\nconst UIManagerAny = UIManager as any;\n\nconst customGHEventsConfigFabricAndroid = {\n topOnGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n topOnGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n};\n\nconst customGHEventsConfig = {\n onGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n onGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n\n // When using React Native Gesture Handler for Animated.event with useNativeDriver: true\n // on Android with Fabric enabled, the native part still sends the native events to JS\n // but prefixed with \"top\". We cannot simply rename the events above so they are prefixed\n // with \"top\" instead of \"on\" because in such case Animated.events would not be registered.\n // That's why we need to register another pair of event names.\n // The incoming events will be queued but never handled.\n // Without this piece of code below, you'll get the following JS error:\n // Unsupported top level event type \"topOnGestureHandlerEvent\" dispatched\n ...(isFabric() &&\n Platform.OS === 'android' &&\n customGHEventsConfigFabricAndroid),\n};\n\n// Add gesture specific events to genericDirectEventTypes object exported from UIManager\n// native module.\n// Once new event types are registered with react it is possible to dispatch these\n// events to all kind of native views.\nUIManagerAny.genericDirectEventTypes = {\n ...UIManagerAny.genericDirectEventTypes,\n ...customGHEventsConfig,\n};\n// In newer versions of RN the `genericDirectEventTypes` is located in the object\n// returned by UIManager.getViewManagerConfig('getConstants') or in older RN UIManager.getConstants(), we need to add it there as well to make\n// it compatible with RN 61+\nconst UIManagerConstants =\n UIManagerAny.getViewManagerConfig?.('getConstants') ??\n UIManagerAny.getConstants?.();\n\nif (UIManagerConstants) {\n UIManagerConstants.genericDirectEventTypes = {\n ...UIManagerConstants.genericDirectEventTypes,\n ...customGHEventsConfig,\n };\n}\n\n// Wrap JS responder calls and notify gesture handler manager\nconst {\n setJSResponder: oldSetJSResponder = () => {\n //no operation\n },\n clearJSResponder: oldClearJSResponder = () => {\n //no operation\n },\n} = UIManagerAny;\nUIManagerAny.setJSResponder = (tag: number, blockNativeResponder: boolean) => {\n RNGestureHandlerModule.handleSetJSResponder(tag, blockNativeResponder);\n oldSetJSResponder(tag, blockNativeResponder);\n};\nUIManagerAny.clearJSResponder = () => {\n RNGestureHandlerModule.handleClearJSResponder();\n oldClearJSResponder();\n};\n\nlet allowTouches = true;\nconst DEV_ON_ANDROID = __DEV__ && Platform.OS === 'android';\n// Toggled inspector blocks touch events in order to allow inspecting on Android\n// This needs to be a global variable in order to set initial state for `allowTouches` property in Handler component\nif (DEV_ON_ANDROID) {\n DeviceEventEmitter.addListener('toggleElementInspector', () => {\n allowTouches = !allowTouches;\n });\n}\n\ntype HandlerProps<T extends Record<string, unknown>> = Readonly<\n React.PropsWithChildren<BaseGestureHandlerProps<T>>\n>;\nfunction hasUnresolvedRefs<T extends Record<string, unknown>>(\n props: HandlerProps<T>\n) {\n // TODO(TS) - add type for extract arg\n const extract = (refs: any | any[]) => {\n if (!Array.isArray(refs)) {\n return refs && refs.current === null;\n }\n return refs.some((r) => r && r.current === null);\n };\n return extract(props['simultaneousHandlers']) || extract(props['waitFor']);\n}\n\nconst stateToPropMappings = {\n [State.UNDETERMINED]: undefined,\n [State.BEGAN]: 'onBegan',\n [State.FAILED]: 'onFailed',\n [State.CANCELLED]: 'onCancelled',\n [State.ACTIVE]: 'onActivated',\n [State.END]: 'onEnded',\n} as const;\n\ntype CreateHandlerArgs<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 (\n RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler\n )(\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 { onGestureEvent, onGestureHandlerEvent }: OnGestureEventHandlers =\n 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 let child: any = null;\n try {\n child = React.Children.only(this.props.children);\n } catch (e) {\n throw new Error(\n tagMessage(\n `${name} got more than one view as a child. If you want the gesture to work on multiple views, wrap them with a common parent and attach the gesture to that view.`\n )\n );\n }\n\n let grandChildren = child.props.children;\n if (\n __DEV__ &&\n child.type &&\n (child.type === 'RNGestureHandlerButton' ||\n child.type.name === 'View' ||\n child.type.displayName === 'View')\n ) {\n grandChildren = React.Children.toArray(grandChildren);\n grandChildren.push(\n <PressabilityDebugView\n key=\"pressabilityDebugView\"\n color=\"mediumspringgreen\"\n hitSlop={child.props.hitSlop}\n />\n );\n }\n\n return React.cloneElement(\n child,\n {\n ref: this.refHandler,\n collapsable: false,\n ...(isJestEnv()\n ? {\n handlerType: name,\n handlerTag: this.handlerTag,\n }\n : {}),\n testID: this.props.testID ?? child.props.testID,\n ...events,\n },\n grandChildren\n );\n }\n }\n return Handler;\n}\n"]}
|
1
|
+
{"version":3,"sources":["createHandler.tsx"],"names":["UIManagerAny","UIManager","customGHEventsConfigFabricAndroid","topOnGestureHandlerEvent","registrationName","topOnGestureHandlerStateChange","customGHEventsConfig","onGestureHandlerEvent","onGestureHandlerStateChange","Platform","OS","genericDirectEventTypes","UIManagerConstants","getViewManagerConfig","getConstants","setJSResponder","oldSetJSResponder","clearJSResponder","oldClearJSResponder","tag","blockNativeResponder","RNGestureHandlerModule","handleSetJSResponder","handleClearJSResponder","allowTouches","DEV_ON_ANDROID","__DEV__","DeviceEventEmitter","addListener","hasUnresolvedRefs","props","extract","refs","Array","isArray","current","some","r","stateToPropMappings","State","UNDETERMINED","undefined","BEGAN","FAILED","CANCELLED","ACTIVE","END","UNRESOLVED_REFS_RETRY_LIMIT","createHandler","name","allowedProps","config","transformProps","customNativeProps","Handler","React","Component","constructor","event","nativeEvent","handlerTag","onGestureEvent","onHandlerStateChange","state","stateEventName","eventHandler","node","viewNode","child","Children","only","children","ref","newConfig","createGestureHandler","newViewTag","viewTag","attachGestureHandler","ActionType","JS_FUNCTION_OLD_API","propsRef","onGestureStateChange","actionType","REANIMATED_WORKLET","NATIVE_ANIMATED_EVENT","updateGestureHandler","createRef","isMountedRef","id","handlerIDToTag","Error","componentDidMount","inspectorToggleListener","setState","_","update","queueMicrotask","componentDidUpdate","componentWillUnmount","remove","dropGestureHandler","handlerID","remainingTries","setNativeProps","updates","mergedProps","render","context","gestureEventHandler","gestureStateEventHandler","events","e","grandChildren","type","displayName","toArray","push","hitSlop","cloneElement","refHandler","collapsable","handlerType","testID","GestureHandlerRootViewContext"],"mappings":";;;;;;;AAAA;;AACA;;AAOA;;AACA;;AAEA;;AACA;;AAMA;;AASA;;AACA;;AACA;;AACA;;;;;;;;;;;;AAEA,MAAMA,YAAY,GAAGC,sBAArB;AAEA,MAAMC,iCAAiC,GAAG;AACxCC,EAAAA,wBAAwB,EAAE;AAAEC,IAAAA,gBAAgB,EAAE;AAApB,GADc;AAExCC,EAAAA,8BAA8B,EAAE;AAC9BD,IAAAA,gBAAgB,EAAE;AADY;AAFQ,CAA1C;AAOA,MAAME,oBAAoB,GAAG;AAC3BC,EAAAA,qBAAqB,EAAE;AAAEH,IAAAA,gBAAgB,EAAE;AAApB,GADI;AAE3BI,EAAAA,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E,UAAA,GAAG,EAAC,uBADN;AAEE,UAAA,KAAK,EAAC,mBAFR;AAGE,UAAA,OAAO,EAAEhD,KAAK,CAACtC,KAAN,CAAYuF;AAHvB,UADF;AAOD;;AAED,0BAAO9D,KAAK,CAAC+D,YAAN,CACLlD,KADK,EAEL;AACEI,QAAAA,GAAG,EAAE,KAAK+C,UADZ;AAEEC,QAAAA,WAAW,EAAE,KAFf;AAGE,YAAI,0BACA;AACEC,UAAAA,WAAW,EAAExE,IADf;AAEEW,UAAAA,UAAU,EAAE,KAAKA;AAFnB,SADA,GAKA,EALJ,CAHF;AASE8D,QAAAA,MAAM,wBAAE,KAAK5F,KAAL,CAAW4F,MAAb,mEAAuBtD,KAAK,CAACtC,KAAN,CAAY4F,MAT3C;AAUE,WAAGZ;AAVL,OAFK,EAcLE,aAdK,CAAP;AAgBD;;AArWD;;AAPwE,kBAIpE1D,OAJoE,iBAQnDL,IARmD;;AAAA,kBAIpEK,OAJoE,iBASnDqE,sCATmD;;AA8W1E,SAAOrE,OAAP;AACD","sourcesContent":["import * as React from 'react';\nimport {\n Platform,\n UIManager,\n DeviceEventEmitter,\n EmitterSubscription,\n} from 'react-native';\n// @ts-ignore - it isn't typed by TS & don't have definitelyTyped types\nimport deepEqual from 'lodash/isEqual';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\nimport type RNGestureHandlerModuleWeb from '../RNGestureHandlerModule.web';\nimport { State } from '../State';\nimport {\n handlerIDToTag,\n getNextHandlerTag,\n registerOldGestureHandler,\n} from './handlersRegistry';\n\nimport {\n BaseGestureHandlerProps,\n filterConfig,\n GestureEvent,\n HandlerStateChangeEvent,\n findNodeHandle,\n scheduleFlushOperations,\n} from './gestureHandlerCommon';\nimport { ValueOf } from '../typeUtils';\nimport { isFabric, isJestEnv, tagMessage } from '../utils';\nimport { ActionType } from '../ActionType';\nimport { PressabilityDebugView } from './PressabilityDebugView';\nimport GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';\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<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 static contextType = GestureHandlerRootViewContext;\n\n private handlerTag: number;\n private config: Record<string, unknown>;\n private propsRef: React.MutableRefObject<unknown>;\n private isMountedRef: React.MutableRefObject<boolean | null>;\n private viewNode: any;\n private viewTag?: number;\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.isMountedRef = 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 this.isMountedRef.current = true;\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 // queueMicrotask. 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 queueMicrotask(() => {\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 this.isMountedRef.current = false;\n RNGestureHandlerModule.dropGestureHandler(this.handlerTag);\n scheduleFlushOperations();\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 (\n RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler\n )(\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 if (!this.isMountedRef.current) {\n return;\n }\n\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 queueMicrotask(() => {\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 if (__DEV__ && !this.context) {\n throw new Error(\n name +\n ' must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.'\n );\n }\n\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 { onGestureEvent, onGestureHandlerEvent }: OnGestureEventHandlers =\n 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 let child: any = null;\n try {\n child = React.Children.only(this.props.children);\n } catch (e) {\n throw new Error(\n tagMessage(\n `${name} got more than one view as a child. If you want the gesture to work on multiple views, wrap them with a common parent and attach the gesture to that view.`\n )\n );\n }\n\n let grandChildren = child.props.children;\n if (\n __DEV__ &&\n child.type &&\n (child.type === 'RNGestureHandlerButton' ||\n child.type.name === 'View' ||\n child.type.displayName === 'View')\n ) {\n grandChildren = React.Children.toArray(grandChildren);\n grandChildren.push(\n <PressabilityDebugView\n key=\"pressabilityDebugView\"\n color=\"mediumspringgreen\"\n hitSlop={child.props.hitSlop}\n />\n );\n }\n\n return React.cloneElement(\n child,\n {\n ref: this.refHandler,\n collapsable: false,\n ...(isJestEnv()\n ? {\n handlerType: name,\n handlerTag: this.handlerTag,\n }\n : {}),\n testID: this.props.testID ?? child.props.testID,\n ...events,\n },\n grandChildren\n );\n }\n }\n return Handler;\n}\n"]}
|
@@ -86,14 +86,15 @@ function findNodeHandle(node) {
|
|
86
86
|
return (0, _reactNative.findNodeHandle)(node);
|
87
87
|
}
|
88
88
|
|
89
|
-
let
|
89
|
+
let flushOperationsScheduled = false;
|
90
90
|
|
91
91
|
function scheduleFlushOperations() {
|
92
|
-
if (
|
93
|
-
|
92
|
+
if (!flushOperationsScheduled) {
|
93
|
+
flushOperationsScheduled = true;
|
94
|
+
queueMicrotask(() => {
|
94
95
|
_RNGestureHandlerModule.default.flushOperations();
|
95
96
|
|
96
|
-
|
97
|
+
flushOperationsScheduled = false;
|
97
98
|
});
|
98
99
|
}
|
99
100
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["gestureHandlerCommon.ts"],"names":["commonProps","componentInteractionProps","baseGestureHandlerProps","baseGestureHandlerWithMonitorProps","isConfigParam","param","name","undefined","Object","filterConfig","props","validProps","defaults","filteredConfig","key","value","transformIntoHandlerTags","top","left","bottom","right","handlerIDs","Platform","OS","map","current","filter","handle","handlerID","handlerIDToTag","handlerTag","findNodeHandle","node","
|
1
|
+
{"version":3,"sources":["gestureHandlerCommon.ts"],"names":["commonProps","componentInteractionProps","baseGestureHandlerProps","baseGestureHandlerWithMonitorProps","isConfigParam","param","name","undefined","Object","filterConfig","props","validProps","defaults","filteredConfig","key","value","transformIntoHandlerTags","top","left","bottom","right","handlerIDs","Platform","OS","map","current","filter","handle","handlerID","handlerIDToTag","handlerTag","findNodeHandle","node","flushOperationsScheduled","scheduleFlushOperations","queueMicrotask","RNGestureHandlerModule","flushOperations"],"mappings":";;;;;;;;;;AAKA;;AAKA;;AACA;;AACA;;;;AAZA;AACA;AACA;AACA;AAWA,MAAMA,WAAW,GAAG,CAClB,IADkB,EAElB,SAFkB,EAGlB,yBAHkB,EAIlB,SAJkB,EAKlB,sBALkB,EAMlB,YANkB,CAApB;AASA,MAAMC,yBAAyB,GAAG,CAAC,SAAD,EAAY,sBAAZ,CAAlC;AAEO,MAAMC,uBAAuB,GAAG,CACrC,GAAGF,WADkC,EAErC,GAAGC,yBAFkC,EAGrC,SAHqC,EAIrC,UAJqC,EAKrC,aALqC,EAMrC,aANqC,EAOrC,SAPqC,EAQrC,gBARqC,EASrC,sBATqC,CAAhC;;AAYA,MAAME,kCAAkC,GAAG,CAChD,GAAGH,WAD6C,EAEhD,kBAFgD,EAGhD,kBAHgD,CAA3C;;;AAkGP,SAASI,aAAT,CAAuBC,KAAvB,EAAuCC,IAAvC,EAAqD;AACnD;AACA;AACA,SACED,KAAK,KAAKE,SAAV,KACCF,KAAK,KAAKG,MAAM,CAACH,KAAD,CAAhB,IACC,EAAE,gBAAiBA,KAAnB,CAFF,KAGAC,IAAI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,UAAhD,KAA8D,CAAC,CADjE;AAAA,GAFG,EAKJJ,MALI,CAKII,UAAD,IAAwBA,UAAU,GAAG,CALxC,CAAP;AAMD;;AAEM,SAASC,cAAT,CACLC,IADK,EAEkE;AACvE,MAAIV,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzB,WAAOS,IAAP;AACD;;AACD,SAAO,iCAAiBA,IAAjB,CAAP;AACD;;AAED,IAAIC,wBAAwB,GAAG,KAA/B;;AAEO,SAASC,uBAAT,GAAmC;AACxC,MAAI,CAACD,wBAAL,EAA+B;AAC7BA,IAAAA,wBAAwB,GAAG,IAA3B;AACAE,IAAAA,cAAc,CAAC,MAAM;AACnBC,sCAAuBC,eAAvB;;AAEAJ,MAAAA,wBAAwB,GAAG,KAA3B;AACD,KAJa,CAAd;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 'userSelect',\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\nexport type UserSelect = 'none' | 'auto' | 'text';\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<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 userSelect?: UserSelect;\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') {\n return node;\n }\n return findNodeHandleRN(node);\n}\n\nlet flushOperationsScheduled = false;\n\nexport function scheduleFlushOperations() {\n if (!flushOperationsScheduled) {\n flushOperationsScheduled = true;\n queueMicrotask(() => {\n RNGestureHandlerModule.flushOperations();\n\n flushOperationsScheduled = false;\n });\n }\n}\n"]}
|
@@ -45,7 +45,11 @@ var _eventReceiver = require("./eventReceiver");
|
|
45
45
|
|
46
46
|
var _RNRenderer = require("../../RNRenderer");
|
47
47
|
|
48
|
-
var
|
48
|
+
var _EnableNewWebImplementation = require("../../EnableNewWebImplementation");
|
49
|
+
|
50
|
+
var _NativeViewGestureHandler = require("../NativeViewGestureHandler");
|
51
|
+
|
52
|
+
var _GestureHandlerRootViewContext = _interopRequireDefault(require("../../GestureHandlerRootViewContext"));
|
49
53
|
|
50
54
|
var _Reanimated$default$c, _Reanimated$default;
|
51
55
|
|
@@ -55,7 +59,7 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
|
|
55
59
|
|
56
60
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
57
61
|
|
58
|
-
const ALLOWED_PROPS = [..._gestureHandlerCommon.baseGestureHandlerWithMonitorProps, ..._TapGestureHandler.tapGestureHandlerProps, ..._PanGestureHandler.panGestureHandlerProps, ..._PanGestureHandler.panGestureHandlerCustomNativeProps, ..._LongPressGestureHandler.longPressGestureHandlerProps, ..._ForceTouchGestureHandler.forceTouchGestureHandlerProps, ..._FlingGestureHandler.flingGestureHandlerProps];
|
62
|
+
const ALLOWED_PROPS = [..._gestureHandlerCommon.baseGestureHandlerWithMonitorProps, ..._TapGestureHandler.tapGestureHandlerProps, ..._PanGestureHandler.panGestureHandlerProps, ..._PanGestureHandler.panGestureHandlerCustomNativeProps, ..._LongPressGestureHandler.longPressGestureHandlerProps, ..._ForceTouchGestureHandler.forceTouchGestureHandlerProps, ..._FlingGestureHandler.flingGestureHandlerProps, ..._NativeViewGestureHandler.nativeViewGestureHandlerProps];
|
59
63
|
|
60
64
|
function convertToHandlerTag(ref) {
|
61
65
|
if (typeof ref === 'number') {
|
@@ -115,11 +119,11 @@ function attachHandlers({
|
|
115
119
|
gestureConfig.initialize();
|
116
120
|
} else {
|
117
121
|
preparedGesture.firstExecution = false;
|
118
|
-
} // use
|
122
|
+
} // use queueMicrotask to extract handlerTags, because all refs should be initialized
|
119
123
|
// when it's ran
|
120
124
|
|
121
125
|
|
122
|
-
|
126
|
+
queueMicrotask(() => {
|
123
127
|
if (!mountedRef.current) {
|
124
128
|
return;
|
125
129
|
}
|
@@ -133,11 +137,11 @@ function attachHandlers({
|
|
133
137
|
_RNGestureHandlerModule.default.createGestureHandler(handler.handlerName, handler.handlerTag, (0, _gestureHandlerCommon.filterConfig)(handler.config, ALLOWED_PROPS));
|
134
138
|
|
135
139
|
(0, _handlersRegistry.registerHandler)(handler.handlerTag, handler, handler.config.testId);
|
136
|
-
} // use
|
140
|
+
} // use queueMicrotask to extract handlerTags, because all refs should be initialized
|
137
141
|
// when it's ran
|
138
142
|
|
139
143
|
|
140
|
-
|
144
|
+
queueMicrotask(() => {
|
141
145
|
if (!mountedRef.current) {
|
142
146
|
return;
|
143
147
|
}
|
@@ -195,12 +199,12 @@ function updateHandlers(preparedGesture, gestureConfig, gesture, mountedRef) {
|
|
195
199
|
gesture[i].handlerTag = handler.handlerTag;
|
196
200
|
gesture[i].handlers.handlerTag = handler.handlerTag;
|
197
201
|
}
|
198
|
-
} // use
|
202
|
+
} // use queueMicrotask to extract handlerTags, because when it's ran, all refs should be updated
|
199
203
|
// and handlerTags in BaseGesture references should be updated in the loop above (we need to wait
|
200
204
|
// in case of external relations)
|
201
205
|
|
202
206
|
|
203
|
-
|
207
|
+
queueMicrotask(() => {
|
204
208
|
if (!mountedRef.current) {
|
205
209
|
return;
|
206
210
|
}
|
@@ -473,6 +477,12 @@ const applyUserSelectProp = (userSelect, gesture) => {
|
|
473
477
|
};
|
474
478
|
|
475
479
|
const GestureDetector = props => {
|
480
|
+
const rootViewContext = (0, _react.useContext)(_GestureHandlerRootViewContext.default);
|
481
|
+
|
482
|
+
if (__DEV__ && !rootViewContext) {
|
483
|
+
throw new Error('GestureDetector must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.');
|
484
|
+
}
|
485
|
+
|
476
486
|
const gestureConfig = props.gesture;
|
477
487
|
|
478
488
|
if (props.userSelect) {
|
@@ -493,7 +503,7 @@ const GestureDetector = props => {
|
|
493
503
|
onGestureHandlerEvent: e => {
|
494
504
|
(0, _eventReceiver.onGestureHandlerEvent)(e.nativeEvent);
|
495
505
|
},
|
496
|
-
onGestureHandlerStateChange: (0,
|
506
|
+
onGestureHandlerStateChange: (0, _EnableNewWebImplementation.isNewWebImplementationEnabled)() ? e => {
|
497
507
|
(0, _eventReceiver.onGestureHandlerEvent)(e.nativeEvent);
|
498
508
|
} : undefined
|
499
509
|
});
|