react-native-gesture-handler 2.21.2 → 2.22.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -3
- package/android/build.gradle +10 -0
- package/android/package77/src/main/java/com/swmansion/gesturehandler/RNGestureHandlerPackage.kt +85 -0
- package/android/{src → packageDeprecated/src}/main/java/com/swmansion/gesturehandler/RNGestureHandlerPackage.kt +2 -3
- package/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +3 -2
- package/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerRootViewManagerDelegate.java +3 -2
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +16 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt +45 -8
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +18 -0
- package/apple/Handlers/RNFlingHandler.m +0 -1
- package/apple/Handlers/RNForceTouchHandler.m +0 -1
- package/apple/Handlers/RNLongPressHandler.m +0 -1
- package/apple/Handlers/RNManualHandler.m +0 -1
- package/apple/Handlers/RNPanHandler.m +0 -3
- package/apple/Handlers/RNPinchHandler.m +0 -1
- package/apple/Handlers/RNRotationHandler.m +0 -1
- package/apple/Handlers/RNTapHandler.m +0 -1
- package/apple/RNGestureHandlerButton.h +1 -0
- package/apple/RNGestureHandlerButton.mm +51 -0
- package/apple/RNGestureHandlerManager.mm +6 -1
- package/apple/RNManualActivationRecognizer.m +1 -0
- package/lib/commonjs/ActionType.js.map +1 -1
- package/lib/commonjs/Directions.js.map +1 -1
- package/lib/commonjs/EnableNewWebImplementation.js +14 -1
- package/lib/commonjs/EnableNewWebImplementation.js.map +1 -1
- package/lib/commonjs/State.js.map +1 -1
- package/lib/commonjs/TouchEventType.js.map +1 -1
- package/lib/commonjs/components/Pressable/Pressable.js +1 -1
- package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
- package/lib/commonjs/components/ReanimatedSwipeable.js.map +1 -1
- package/lib/commonjs/components/Swipeable.js.map +1 -1
- package/lib/commonjs/components/Text.js +61 -0
- package/lib/commonjs/components/Text.js.map +1 -0
- package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/commonjs/getShadowNodeFromRef.js +10 -2
- package/lib/commonjs/getShadowNodeFromRef.js.map +1 -1
- package/lib/commonjs/ghQueueMicrotask.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js +12 -0
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/attachHandlers.js +4 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/attachHandlers.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/dropHandlers.js +4 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/dropHandlers.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js +3 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/useMountReactions.js +48 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/useMountReactions.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
- package/lib/commonjs/handlers/utils.js +1 -0
- package/lib/commonjs/handlers/utils.js.map +1 -1
- package/lib/commonjs/index.js +8 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/jestUtils/jestUtils.js.map +1 -1
- package/lib/commonjs/mountRegistry.js +49 -0
- package/lib/commonjs/mountRegistry.js.map +1 -0
- package/lib/commonjs/web/detectors/ScaleGestureDetector.js.map +1 -1
- package/lib/commonjs/web/handlers/FlingGestureHandler.js +0 -4
- package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/HoverGestureHandler.js +0 -14
- package/lib/commonjs/web/handlers/HoverGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/LongPressGestureHandler.js +6 -0
- package/lib/commonjs/web/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/ManualGestureHandler.js +0 -14
- package/lib/commonjs/web/handlers/ManualGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +3 -5
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js +0 -4
- package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PinchGestureHandler.js +0 -10
- package/lib/commonjs/web/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/RotationGestureHandler.js +0 -14
- package/lib/commonjs/web/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/TapGestureHandler.js +0 -4
- package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/commonjs/web_hammer/GestureHandler.js.map +1 -1
- package/lib/commonjs/web_hammer/PressGestureHandler.js.map +1 -1
- package/lib/module/ActionType.js.map +1 -1
- package/lib/module/Directions.js.map +1 -1
- package/lib/module/EnableNewWebImplementation.js +14 -1
- package/lib/module/EnableNewWebImplementation.js.map +1 -1
- package/lib/module/State.js.map +1 -1
- package/lib/module/TouchEventType.js.map +1 -1
- package/lib/module/components/Pressable/Pressable.js +1 -1
- package/lib/module/components/Pressable/Pressable.js.map +1 -1
- package/lib/module/components/ReanimatedSwipeable.js.map +1 -1
- package/lib/module/components/Swipeable.js.map +1 -1
- package/lib/module/components/Text.js +44 -0
- package/lib/module/components/Text.js.map +1 -0
- package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/module/getShadowNodeFromRef.js +10 -2
- package/lib/module/getShadowNodeFromRef.js.map +1 -1
- package/lib/module/ghQueueMicrotask.js.map +1 -1
- package/lib/module/handlers/createHandler.js +11 -0
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/attachHandlers.js +3 -0
- package/lib/module/handlers/gestures/GestureDetector/attachHandlers.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/dropHandlers.js +2 -0
- package/lib/module/handlers/gestures/GestureDetector/dropHandlers.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/index.js +2 -0
- package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/useMountReactions.js +39 -0
- package/lib/module/handlers/gestures/GestureDetector/useMountReactions.js.map +1 -0
- package/lib/module/handlers/gestures/gesture.js.map +1 -1
- package/lib/module/handlers/utils.js +1 -3
- package/lib/module/handlers/utils.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/jestUtils/jestUtils.js.map +1 -1
- package/lib/module/mountRegistry.js +40 -0
- package/lib/module/mountRegistry.js.map +1 -0
- package/lib/module/web/detectors/ScaleGestureDetector.js.map +1 -1
- package/lib/module/web/handlers/FlingGestureHandler.js +0 -4
- package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/HoverGestureHandler.js +0 -14
- package/lib/module/web/handlers/HoverGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/LongPressGestureHandler.js +6 -0
- package/lib/module/web/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/ManualGestureHandler.js +0 -14
- package/lib/module/web/handlers/ManualGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/NativeViewGestureHandler.js +3 -5
- package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +0 -4
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PinchGestureHandler.js +0 -10
- package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/RotationGestureHandler.js +0 -14
- package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/TapGestureHandler.js +0 -4
- package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/module/web_hammer/GestureHandler.js.map +1 -1
- package/lib/module/web_hammer/PressGestureHandler.js.map +1 -1
- package/lib/typescript/ActionType.d.ts +1 -1
- package/lib/typescript/Directions.d.ts +2 -2
- package/lib/typescript/EnableNewWebImplementation.d.ts +6 -0
- package/lib/typescript/State.d.ts +1 -1
- package/lib/typescript/TouchEventType.d.ts +1 -1
- package/lib/typescript/components/GestureButtonsProps.d.ts +2 -2
- package/lib/typescript/components/Text.d.ts +4 -0
- package/lib/typescript/components/touchables/GenericTouchable.d.ts +1 -1
- package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts +2 -2
- package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.d.ts +2 -0
- package/lib/typescript/handlers/gestures/gesture.d.ts +1 -1
- package/lib/typescript/handlers/utils.d.ts +1 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/mocks.d.ts +3 -3
- package/lib/typescript/mountRegistry.d.ts +17 -0
- package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +0 -2
- package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +1 -4
- package/lib/typescript/web/handlers/LongPressGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +1 -4
- package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/PanGestureHandler.d.ts +0 -2
- package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +1 -2
- package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +1 -3
- package/lib/typescript/web/handlers/TapGestureHandler.d.ts +0 -2
- package/package.json +18 -17
- package/src/ActionType.ts +1 -1
- package/src/Directions.ts +2 -2
- package/src/EnableNewWebImplementation.ts +18 -0
- package/src/State.ts +1 -1
- package/src/TouchEventType.ts +2 -1
- package/src/components/GestureButtonsProps.ts +4 -2
- package/src/components/Pressable/Pressable.tsx +3 -3
- package/src/components/ReanimatedSwipeable.tsx +8 -8
- package/src/components/Swipeable.tsx +4 -4
- package/src/components/Text.tsx +60 -0
- package/src/components/touchables/GenericTouchable.tsx +1 -1
- package/src/getShadowNodeFromRef.ts +8 -2
- package/src/ghQueueMicrotask.ts +2 -2
- package/src/handlers/GestureHandlerEventPayload.ts +2 -2
- package/src/handlers/createHandler.tsx +14 -1
- package/src/handlers/gestureHandlerCommon.ts +3 -3
- package/src/handlers/gestures/GestureDetector/attachHandlers.ts +3 -0
- package/src/handlers/gestures/GestureDetector/dropHandlers.ts +3 -0
- package/src/handlers/gestures/GestureDetector/index.tsx +3 -0
- package/src/handlers/gestures/GestureDetector/useMountReactions.ts +51 -0
- package/src/handlers/gestures/gesture.ts +3 -3
- package/src/handlers/utils.ts +2 -1
- package/src/index.ts +1 -0
- package/src/jestUtils/jestUtils.ts +10 -12
- package/src/mountRegistry.ts +51 -0
- package/src/web/detectors/ScaleGestureDetector.ts +1 -1
- package/src/web/handlers/FlingGestureHandler.ts +0 -4
- package/src/web/handlers/GestureHandler.ts +1 -3
- package/src/web/handlers/HoverGestureHandler.ts +1 -9
- package/src/web/handlers/LongPressGestureHandler.ts +6 -0
- package/src/web/handlers/ManualGestureHandler.ts +1 -9
- package/src/web/handlers/NativeViewGestureHandler.ts +5 -5
- package/src/web/handlers/PanGestureHandler.ts +0 -4
- package/src/web/handlers/PinchGestureHandler.ts +1 -5
- package/src/web/handlers/RotationGestureHandler.ts +1 -9
- package/src/web/handlers/TapGestureHandler.ts +0 -4
- package/src/web/tools/GestureHandlerWebDelegate.ts +4 -4
- package/src/web_hammer/GestureHandler.ts +1 -1
- package/src/web_hammer/PressGestureHandler.ts +7 -4
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["GenericTouchable.tsx"],"names":["TOUCHABLE_STATE","UNDETERMINED","BEGAN","MOVED_OUTSIDE","GenericTouchable","Component","nativeEvent","pointerInside","onMoveIn","onMoveOut","state","State","CANCELLED","FAILED","moveToState","Platform","OS","ACTIVE","STATE","handlePressIn","END","shouldCallOnPress","longPressDetected","pressOutTimeout","handleGoToUndetermined","props","onPress","onLongPress","delayPressIn","pressInTimeout","setTimeout","time","delayLongPress","longPressTimeout","onLongPressDetected","handleMoveOutside","delayPressOut","clearTimeout","componentDidMount","reset","newState","onPressIn","onPressOut","onStateChange","componentWillUnmount","render","hitSlop","top","left","bottom","right","undefined","coreProps","accessible","accessibilityLabel","accessibilityHint","accessibilityRole","accessibilityState","accessibilityActions","onAccessibilityAction","nativeID","onLayout","containerStyle","disabled","onHandlerStateChange","onGestureEvent","userSelect","shouldActivateOnStart","disallowInterruption","testID","touchSoundDisabled","extraButtonProps","style","children","rippleColor","exclusive"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;AACA;;;;;;;;;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,eAAe,GAAG;AAC7BC,EAAAA,YAAY,EAAE,CADe;AAE7BC,EAAAA,KAAK,EAAE,CAFsB;AAG7BC,EAAAA,aAAa,EAAE;AAHc,CAAxB;;;AAiBP;AACA;AACA;AACA;AAEe,MAAMC,gBAAN,SAA+BC,eAA/B,CAEb;AAAA;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,+CAeoB,KAfpB;;AAAA,2CAiBgB,IAjBhB;;AAAA,mCAoBwBL,eAAe,CAACC,YApBxC;;AAAA,4CAkHiB,CAAC;AAChBK,MAAAA,WAAW,EAAE;AAAEC,QAAAA;AAAF;AADG,KAAD,KAEoC;AACnD,UAAI,KAAKA,aAAL,KAAuBA,aAA3B,EAA0C;AACxC,YAAIA,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BC,MAAAA,qBAAqB,EAAE,KAAKlC,KAAL,CAAWkC,qBATlB;AAUhBC,MAAAA,QAAQ,EAAE,KAAKnC,KAAL,CAAWmC,QAVL;AAWhBC,MAAAA,QAAQ,EAAE,KAAKpC,KAAL,CAAWoC;AAXL,KAAlB;AAcA,wBACE,oBAAC,0BAAD;AACE,MAAA,KAAK,EAAE,KAAKpC,KAAL,CAAWqC,cADpB;AAEE,MAAA,oBAAoB,EAClB;AACA,WAAKrC,KAAL,CAAWsC,QAAX,GAAsBZ,SAAtB,GAAkC,KAAKa,oBAJ3C;AAME,MAAA,cAAc,EAAE,KAAKC,cANvB;AAOE,MAAA,OAAO,EAAEnB,OAPX;AAQE,MAAA,UAAU,EAAE,KAAKrB,KAAL,CAAWyC,UARzB;AASE,MAAA,qBAAqB,EAAE,KAAKzC,KAAL,CAAW0C,qBATpC;AAUE,MAAA,oBAAoB,EAAE,KAAK1C,KAAL,CAAW2C,oBAVnC;AAWE,MAAA,MAAM,EAAE,KAAK3C,KAAL,CAAW4C,MAXrB;AAYE,MAAA,kBAAkB,2BAAE,KAAK5C,KAAL,CAAW6C,kBAAb,yEAAmC,KAZvD;AAaE,MAAA,OAAO,EAAE,CAAC,KAAK7C,KAAL,CAAWsC;AAbvB,OAcM,KAAKtC,KAAL,CAAW8C,gBAdjB,gBAeE,oBAAC,qBAAD,CAAU,IAAV,eAAmBnB,SAAnB;AAA8B,MAAA,KAAK,EAAE,KAAK3B,KAAL,CAAW+C;AAAhD,QACG,KAAK/C,KAAL,CAAWgD,QADd,CAfF,CADF;AAqBD;;AArOD;;;;gBAFmBrE,gB,kBAGG;AACpB4B,EAAAA,cAAc,EAAE,GADI;AAEpBuC,EAAAA,gBAAgB,EAAE;AAChBG,IAAAA,WAAW,EAAE,aADG;AAEhBC,IAAAA,SAAS,EAAE;AAFK;AAFE,C","sourcesContent":["import * as React from 'react';\nimport { Component } from 'react';\nimport { Animated, Platform } from 'react-native';\n\nimport { State } from '../../State';\nimport { BaseButton } from '../GestureButtons';\n\nimport {\n GestureEvent,\n HandlerStateChangeEvent,\n} from '../../handlers/gestureHandlerCommon';\nimport type { NativeViewGestureHandlerPayload } from '../../handlers/GestureHandlerEventPayload';\nimport type { TouchableNativeFeedbackExtraProps } from './TouchableNativeFeedbackProps';\nimport type { GenericTouchableProps } from './GenericTouchableProps';\n\n/**\n * Each touchable is a states' machine which preforms transitions.\n * On very beginning (and on the very end or recognition) touchable is\n * UNDETERMINED. Then it moves to BEGAN. If touchable recognizes that finger\n * travel outside it transits to special MOVED_OUTSIDE state. Gesture recognition\n * finishes in UNDETERMINED state.\n */\nexport const TOUCHABLE_STATE = {\n UNDETERMINED: 0,\n BEGAN: 1,\n MOVED_OUTSIDE: 2,\n} as const;\n\ntype TouchableState = typeof TOUCHABLE_STATE[keyof typeof TOUCHABLE_STATE];\n\ninterface InternalProps {\n extraButtonProps: TouchableNativeFeedbackExtraProps;\n onStateChange?: (oldState: TouchableState, newState: TouchableState) => void;\n}\n\n// TODO: maybe can be better\n// TODO: all clearTimeout have ! added, maybe they shouldn't ?\ntype Timeout = ReturnType<typeof setTimeout> | null | undefined;\n\n/**\n * GenericTouchable is not intented to be used as it is.\n * Should be treated as a source for the rest of touchables\n */\n\nexport default class GenericTouchable extends Component<\n GenericTouchableProps & InternalProps\n> {\n static defaultProps = {\n delayLongPress: 600,\n extraButtonProps: {\n rippleColor: 'transparent',\n exclusive: true,\n },\n };\n\n // Timeout handlers\n pressInTimeout: Timeout;\n pressOutTimeout: Timeout;\n longPressTimeout: Timeout;\n\n // This flag is required since recognition of longPress implies not-invoking onPress\n longPressDetected = false;\n\n pointerInside = true;\n\n // State of touchable\n STATE: TouchableState = TOUCHABLE_STATE.UNDETERMINED;\n\n // handlePressIn in called on first touch on traveling inside component.\n // Handles state transition with delay.\n handlePressIn() {\n if (this.props.delayPressIn) {\n this.pressInTimeout = setTimeout(() => {\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n this.pressInTimeout = null;\n }, this.props.delayPressIn);\n } else {\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n }\n if (this.props.onLongPress) {\n const time =\n (this.props.delayPressIn || 0) + (this.props.delayLongPress || 0);\n this.longPressTimeout = setTimeout(this.onLongPressDetected, time);\n }\n }\n // handleMoveOutside in called on traveling outside component.\n // Handles state transition with delay.\n handleMoveOutside() {\n if (this.props.delayPressOut) {\n this.pressOutTimeout =\n this.pressOutTimeout ||\n setTimeout(() => {\n this.moveToState(TOUCHABLE_STATE.MOVED_OUTSIDE);\n this.pressOutTimeout = null;\n }, this.props.delayPressOut);\n } else {\n this.moveToState(TOUCHABLE_STATE.MOVED_OUTSIDE);\n }\n }\n\n // handleGoToUndetermined transits to UNDETERMINED state with proper delay\n handleGoToUndetermined() {\n clearTimeout(this.pressOutTimeout!); // TODO: maybe it can be undefined\n if (this.props.delayPressOut) {\n this.pressOutTimeout = setTimeout(() => {\n if (this.STATE === TOUCHABLE_STATE.UNDETERMINED) {\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n }\n this.moveToState(TOUCHABLE_STATE.UNDETERMINED);\n this.pressOutTimeout = null;\n }, this.props.delayPressOut);\n } else {\n if (this.STATE === TOUCHABLE_STATE.UNDETERMINED) {\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n }\n this.moveToState(TOUCHABLE_STATE.UNDETERMINED);\n }\n }\n\n componentDidMount() {\n this.reset();\n }\n // Reset timeout to prevent memory leaks.\n reset() {\n this.longPressDetected = false;\n this.pointerInside = true;\n clearTimeout(this.pressInTimeout!);\n clearTimeout(this.pressOutTimeout!);\n clearTimeout(this.longPressTimeout!);\n this.pressOutTimeout = null;\n this.longPressTimeout = null;\n this.pressInTimeout = null;\n }\n\n // All states' transitions are defined here.\n moveToState(newState: TouchableState) {\n if (newState === this.STATE) {\n // Ignore dummy transitions\n return;\n }\n if (newState === TOUCHABLE_STATE.BEGAN) {\n // First touch and moving inside\n this.props.onPressIn?.();\n } else if (newState === TOUCHABLE_STATE.MOVED_OUTSIDE) {\n // Moving outside\n this.props.onPressOut?.();\n } else if (newState === TOUCHABLE_STATE.UNDETERMINED) {\n // Need to reset each time on transition to UNDETERMINED\n this.reset();\n if (this.STATE === TOUCHABLE_STATE.BEGAN) {\n // ... and if it happens inside button.\n this.props.onPressOut?.();\n }\n }\n // Finally call lister (used by subclasses)\n this.props.onStateChange?.(this.STATE, newState);\n // ... and make transition.\n this.STATE = newState;\n }\n\n onGestureEvent = ({\n nativeEvent: { pointerInside },\n }: GestureEvent<NativeViewGestureHandlerPayload>) => {\n if (this.pointerInside !== pointerInside) {\n if (pointerInside) {\n this.onMoveIn();\n } else {\n this.onMoveOut();\n }\n }\n this.pointerInside = pointerInside;\n };\n\n onHandlerStateChange = ({\n nativeEvent,\n }: HandlerStateChangeEvent<NativeViewGestureHandlerPayload>) => {\n const { state } = nativeEvent;\n if (state === State.CANCELLED || state === State.FAILED) {\n // Need to handle case with external cancellation (e.g. by ScrollView)\n this.moveToState(TOUCHABLE_STATE.UNDETERMINED);\n } else if (\n // This platform check is an implication of slightly different behavior of handlers on different platform.\n // And Android \"Active\" state is achieving on first move of a finger, not on press in.\n // On iOS event on \"Began\" is not delivered.\n state === (Platform.OS !== 'android' ? State.ACTIVE : State.BEGAN) &&\n this.STATE === TOUCHABLE_STATE.UNDETERMINED\n ) {\n // Moving inside requires\n this.handlePressIn();\n } else if (state === State.END) {\n const shouldCallOnPress =\n !this.longPressDetected &&\n this.STATE !== TOUCHABLE_STATE.MOVED_OUTSIDE &&\n this.pressOutTimeout === null;\n this.handleGoToUndetermined();\n if (shouldCallOnPress) {\n // Calls only inside component whether no long press was called previously\n this.props.onPress?.();\n }\n }\n };\n\n onLongPressDetected = () => {\n this.longPressDetected = true;\n // Checked for in the caller of `onLongPressDetected`, but better to check twice\n this.props.onLongPress?.();\n };\n\n componentWillUnmount() {\n // To prevent memory leaks\n this.reset();\n }\n\n onMoveIn() {\n if (this.STATE === TOUCHABLE_STATE.MOVED_OUTSIDE) {\n // This call is not throttled with delays (like in RN's implementation).\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n }\n }\n\n onMoveOut() {\n // Long press should no longer be detected\n clearTimeout(this.longPressTimeout!);\n this.longPressTimeout = null;\n if (this.STATE === TOUCHABLE_STATE.BEGAN) {\n this.handleMoveOutside();\n }\n }\n\n render() {\n const hitSlop =\n (typeof this.props.hitSlop === 'number'\n ? {\n top: this.props.hitSlop,\n left: this.props.hitSlop,\n bottom: this.props.hitSlop,\n right: this.props.hitSlop,\n }\n : this.props.hitSlop) ?? undefined;\n\n const coreProps = {\n accessible: this.props.accessible !== false,\n accessibilityLabel: this.props.accessibilityLabel,\n accessibilityHint: this.props.accessibilityHint,\n accessibilityRole: this.props.accessibilityRole,\n // TODO: check if changed to no 's' correctly, also removed 2 props that are no longer available: `accessibilityComponentType` and `accessibilityTraits`,\n // would be good to check if it is ok for sure, see: https://github.com/facebook/react-native/issues/24016\n accessibilityState: this.props.accessibilityState,\n accessibilityActions: this.props.accessibilityActions,\n onAccessibilityAction: this.props.onAccessibilityAction,\n nativeID: this.props.nativeID,\n onLayout: this.props.onLayout,\n };\n\n return (\n <BaseButton\n style={this.props.containerStyle}\n onHandlerStateChange={\n // TODO: not sure if it can be undefined instead of null\n this.props.disabled ? undefined : this.onHandlerStateChange\n }\n onGestureEvent={this.onGestureEvent}\n hitSlop={hitSlop}\n userSelect={this.props.userSelect}\n shouldActivateOnStart={this.props.shouldActivateOnStart}\n disallowInterruption={this.props.disallowInterruption}\n testID={this.props.testID}\n touchSoundDisabled={this.props.touchSoundDisabled ?? false}\n enabled={!this.props.disabled}\n {...this.props.extraButtonProps}>\n <Animated.View {...coreProps} style={this.props.style}>\n {this.props.children}\n </Animated.View>\n </BaseButton>\n );\n }\n}\n"]}
|
1
|
+
{"version":3,"sources":["GenericTouchable.tsx"],"names":["TOUCHABLE_STATE","UNDETERMINED","BEGAN","MOVED_OUTSIDE","GenericTouchable","Component","nativeEvent","pointerInside","onMoveIn","onMoveOut","state","State","CANCELLED","FAILED","moveToState","Platform","OS","ACTIVE","STATE","handlePressIn","END","shouldCallOnPress","longPressDetected","pressOutTimeout","handleGoToUndetermined","props","onPress","onLongPress","delayPressIn","pressInTimeout","setTimeout","time","delayLongPress","longPressTimeout","onLongPressDetected","handleMoveOutside","delayPressOut","clearTimeout","componentDidMount","reset","newState","onPressIn","onPressOut","onStateChange","componentWillUnmount","render","hitSlop","top","left","bottom","right","undefined","coreProps","accessible","accessibilityLabel","accessibilityHint","accessibilityRole","accessibilityState","accessibilityActions","onAccessibilityAction","nativeID","onLayout","containerStyle","disabled","onHandlerStateChange","onGestureEvent","userSelect","shouldActivateOnStart","disallowInterruption","testID","touchSoundDisabled","extraButtonProps","style","children","rippleColor","exclusive"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;AACA;;;;;;;;;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,eAAe,GAAG;AAC7BC,EAAAA,YAAY,EAAE,CADe;AAE7BC,EAAAA,KAAK,EAAE,CAFsB;AAG7BC,EAAAA,aAAa,EAAE;AAHc,CAAxB;;;AAiBP;AACA;AACA;AACA;AAEe,MAAMC,gBAAN,SAA+BC,eAA/B,CAEb;AAAA;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,+CAeoB,KAfpB;;AAAA,2CAiBgB,IAjBhB;;AAAA,mCAoBwBL,eAAe,CAACC,YApBxC;;AAAA,4CAkHiB,CAAC;AAChBK,MAAAA,WAAW,EAAE;AAAEC,QAAAA;AAAF;AADG,KAAD,KAEoC;AACnD,UAAI,KAAKA,aAAL,KAAuBA,aAA3B,EAA0C;AACxC,YAAIA,aAAJ,EAAmB;AACjB,eAAKC,QAAL;AACD,SAFD,MAEO;AACL,eAAKC,SAAL;AACD;AACF;;AACD,WAAKF,aAAL,GAAqBA,aAArB;AACD,KA7HD;;AAAA,kDA+HuB,CAAC;AACtBD,MAAAA;AADsB,KAAD,KAEyC;AAC9D,YAAM;AAAEI,QAAAA;AAAF,UAAYJ,W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AE,KAAKpC,KAAL,CAAWqC,cADpB;AAEE,MAAA,oBAAoB,EAClB;AACA,WAAKrC,KAAL,CAAWsC,QAAX,GAAsBZ,SAAtB,GAAkC,KAAKa,oBAJ3C;AAME,MAAA,cAAc,EAAE,KAAKC,cANvB;AAOE,MAAA,OAAO,EAAEnB,OAPX;AAQE,MAAA,UAAU,EAAE,KAAKrB,KAAL,CAAWyC,UARzB;AASE,MAAA,qBAAqB,EAAE,KAAKzC,KAAL,CAAW0C,qBATpC;AAUE,MAAA,oBAAoB,EAAE,KAAK1C,KAAL,CAAW2C,oBAVnC;AAWE,MAAA,MAAM,EAAE,KAAK3C,KAAL,CAAW4C,MAXrB;AAYE,MAAA,kBAAkB,2BAAE,KAAK5C,KAAL,CAAW6C,kBAAb,yEAAmC,KAZvD;AAaE,MAAA,OAAO,EAAE,CAAC,KAAK7C,KAAL,CAAWsC;AAbvB,OAcM,KAAKtC,KAAL,CAAW8C,gBAdjB,gBAeE,oBAAC,qBAAD,CAAU,IAAV,eAAmBnB,SAAnB;AAA8B,MAAA,KAAK,EAAE,KAAK3B,KAAL,CAAW+C;AAAhD,QACG,KAAK/C,KAAL,CAAWgD,QADd,CAfF,CADF;AAqBD;;AArOD;;;;gBAFmBrE,gB,kBAGG;AACpB4B,EAAAA,cAAc,EAAE,GADI;AAEpBuC,EAAAA,gBAAgB,EAAE;AAChBG,IAAAA,WAAW,EAAE,aADG;AAEhBC,IAAAA,SAAS,EAAE;AAFK;AAFE,C","sourcesContent":["import * as React from 'react';\nimport { Component } from 'react';\nimport { Animated, Platform } from 'react-native';\n\nimport { State } from '../../State';\nimport { BaseButton } from '../GestureButtons';\n\nimport {\n GestureEvent,\n HandlerStateChangeEvent,\n} from '../../handlers/gestureHandlerCommon';\nimport type { NativeViewGestureHandlerPayload } from '../../handlers/GestureHandlerEventPayload';\nimport type { TouchableNativeFeedbackExtraProps } from './TouchableNativeFeedbackProps';\nimport type { GenericTouchableProps } from './GenericTouchableProps';\n\n/**\n * Each touchable is a states' machine which preforms transitions.\n * On very beginning (and on the very end or recognition) touchable is\n * UNDETERMINED. Then it moves to BEGAN. If touchable recognizes that finger\n * travel outside it transits to special MOVED_OUTSIDE state. Gesture recognition\n * finishes in UNDETERMINED state.\n */\nexport const TOUCHABLE_STATE = {\n UNDETERMINED: 0,\n BEGAN: 1,\n MOVED_OUTSIDE: 2,\n} as const;\n\ntype TouchableState = (typeof TOUCHABLE_STATE)[keyof typeof TOUCHABLE_STATE];\n\ninterface InternalProps {\n extraButtonProps: TouchableNativeFeedbackExtraProps;\n onStateChange?: (oldState: TouchableState, newState: TouchableState) => void;\n}\n\n// TODO: maybe can be better\n// TODO: all clearTimeout have ! added, maybe they shouldn't ?\ntype Timeout = ReturnType<typeof setTimeout> | null | undefined;\n\n/**\n * GenericTouchable is not intented to be used as it is.\n * Should be treated as a source for the rest of touchables\n */\n\nexport default class GenericTouchable extends Component<\n GenericTouchableProps & InternalProps\n> {\n static defaultProps = {\n delayLongPress: 600,\n extraButtonProps: {\n rippleColor: 'transparent',\n exclusive: true,\n },\n };\n\n // Timeout handlers\n pressInTimeout: Timeout;\n pressOutTimeout: Timeout;\n longPressTimeout: Timeout;\n\n // This flag is required since recognition of longPress implies not-invoking onPress\n longPressDetected = false;\n\n pointerInside = true;\n\n // State of touchable\n STATE: TouchableState = TOUCHABLE_STATE.UNDETERMINED;\n\n // handlePressIn in called on first touch on traveling inside component.\n // Handles state transition with delay.\n handlePressIn() {\n if (this.props.delayPressIn) {\n this.pressInTimeout = setTimeout(() => {\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n this.pressInTimeout = null;\n }, this.props.delayPressIn);\n } else {\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n }\n if (this.props.onLongPress) {\n const time =\n (this.props.delayPressIn || 0) + (this.props.delayLongPress || 0);\n this.longPressTimeout = setTimeout(this.onLongPressDetected, time);\n }\n }\n // handleMoveOutside in called on traveling outside component.\n // Handles state transition with delay.\n handleMoveOutside() {\n if (this.props.delayPressOut) {\n this.pressOutTimeout =\n this.pressOutTimeout ||\n setTimeout(() => {\n this.moveToState(TOUCHABLE_STATE.MOVED_OUTSIDE);\n this.pressOutTimeout = null;\n }, this.props.delayPressOut);\n } else {\n this.moveToState(TOUCHABLE_STATE.MOVED_OUTSIDE);\n }\n }\n\n // handleGoToUndetermined transits to UNDETERMINED state with proper delay\n handleGoToUndetermined() {\n clearTimeout(this.pressOutTimeout!); // TODO: maybe it can be undefined\n if (this.props.delayPressOut) {\n this.pressOutTimeout = setTimeout(() => {\n if (this.STATE === TOUCHABLE_STATE.UNDETERMINED) {\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n }\n this.moveToState(TOUCHABLE_STATE.UNDETERMINED);\n this.pressOutTimeout = null;\n }, this.props.delayPressOut);\n } else {\n if (this.STATE === TOUCHABLE_STATE.UNDETERMINED) {\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n }\n this.moveToState(TOUCHABLE_STATE.UNDETERMINED);\n }\n }\n\n componentDidMount() {\n this.reset();\n }\n // Reset timeout to prevent memory leaks.\n reset() {\n this.longPressDetected = false;\n this.pointerInside = true;\n clearTimeout(this.pressInTimeout!);\n clearTimeout(this.pressOutTimeout!);\n clearTimeout(this.longPressTimeout!);\n this.pressOutTimeout = null;\n this.longPressTimeout = null;\n this.pressInTimeout = null;\n }\n\n // All states' transitions are defined here.\n moveToState(newState: TouchableState) {\n if (newState === this.STATE) {\n // Ignore dummy transitions\n return;\n }\n if (newState === TOUCHABLE_STATE.BEGAN) {\n // First touch and moving inside\n this.props.onPressIn?.();\n } else if (newState === TOUCHABLE_STATE.MOVED_OUTSIDE) {\n // Moving outside\n this.props.onPressOut?.();\n } else if (newState === TOUCHABLE_STATE.UNDETERMINED) {\n // Need to reset each time on transition to UNDETERMINED\n this.reset();\n if (this.STATE === TOUCHABLE_STATE.BEGAN) {\n // ... and if it happens inside button.\n this.props.onPressOut?.();\n }\n }\n // Finally call lister (used by subclasses)\n this.props.onStateChange?.(this.STATE, newState);\n // ... and make transition.\n this.STATE = newState;\n }\n\n onGestureEvent = ({\n nativeEvent: { pointerInside },\n }: GestureEvent<NativeViewGestureHandlerPayload>) => {\n if (this.pointerInside !== pointerInside) {\n if (pointerInside) {\n this.onMoveIn();\n } else {\n this.onMoveOut();\n }\n }\n this.pointerInside = pointerInside;\n };\n\n onHandlerStateChange = ({\n nativeEvent,\n }: HandlerStateChangeEvent<NativeViewGestureHandlerPayload>) => {\n const { state } = nativeEvent;\n if (state === State.CANCELLED || state === State.FAILED) {\n // Need to handle case with external cancellation (e.g. by ScrollView)\n this.moveToState(TOUCHABLE_STATE.UNDETERMINED);\n } else if (\n // This platform check is an implication of slightly different behavior of handlers on different platform.\n // And Android \"Active\" state is achieving on first move of a finger, not on press in.\n // On iOS event on \"Began\" is not delivered.\n state === (Platform.OS !== 'android' ? State.ACTIVE : State.BEGAN) &&\n this.STATE === TOUCHABLE_STATE.UNDETERMINED\n ) {\n // Moving inside requires\n this.handlePressIn();\n } else if (state === State.END) {\n const shouldCallOnPress =\n !this.longPressDetected &&\n this.STATE !== TOUCHABLE_STATE.MOVED_OUTSIDE &&\n this.pressOutTimeout === null;\n this.handleGoToUndetermined();\n if (shouldCallOnPress) {\n // Calls only inside component whether no long press was called previously\n this.props.onPress?.();\n }\n }\n };\n\n onLongPressDetected = () => {\n this.longPressDetected = true;\n // Checked for in the caller of `onLongPressDetected`, but better to check twice\n this.props.onLongPress?.();\n };\n\n componentWillUnmount() {\n // To prevent memory leaks\n this.reset();\n }\n\n onMoveIn() {\n if (this.STATE === TOUCHABLE_STATE.MOVED_OUTSIDE) {\n // This call is not throttled with delays (like in RN's implementation).\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n }\n }\n\n onMoveOut() {\n // Long press should no longer be detected\n clearTimeout(this.longPressTimeout!);\n this.longPressTimeout = null;\n if (this.STATE === TOUCHABLE_STATE.BEGAN) {\n this.handleMoveOutside();\n }\n }\n\n render() {\n const hitSlop =\n (typeof this.props.hitSlop === 'number'\n ? {\n top: this.props.hitSlop,\n left: this.props.hitSlop,\n bottom: this.props.hitSlop,\n right: this.props.hitSlop,\n }\n : this.props.hitSlop) ?? undefined;\n\n const coreProps = {\n accessible: this.props.accessible !== false,\n accessibilityLabel: this.props.accessibilityLabel,\n accessibilityHint: this.props.accessibilityHint,\n accessibilityRole: this.props.accessibilityRole,\n // TODO: check if changed to no 's' correctly, also removed 2 props that are no longer available: `accessibilityComponentType` and `accessibilityTraits`,\n // would be good to check if it is ok for sure, see: https://github.com/facebook/react-native/issues/24016\n accessibilityState: this.props.accessibilityState,\n accessibilityActions: this.props.accessibilityActions,\n onAccessibilityAction: this.props.onAccessibilityAction,\n nativeID: this.props.nativeID,\n onLayout: this.props.onLayout,\n };\n\n return (\n <BaseButton\n style={this.props.containerStyle}\n onHandlerStateChange={\n // TODO: not sure if it can be undefined instead of null\n this.props.disabled ? undefined : this.onHandlerStateChange\n }\n onGestureEvent={this.onGestureEvent}\n hitSlop={hitSlop}\n userSelect={this.props.userSelect}\n shouldActivateOnStart={this.props.shouldActivateOnStart}\n disallowInterruption={this.props.disallowInterruption}\n testID={this.props.testID}\n touchSoundDisabled={this.props.touchSoundDisabled ?? false}\n enabled={!this.props.disabled}\n {...this.props.extraButtonProps}>\n <Animated.View {...coreProps} style={this.props.style}>\n {this.props.children}\n </Animated.View>\n </BaseButton>\n );\n }\n}\n"]}
|
@@ -15,9 +15,17 @@ function getShadowNodeFromRef(ref) {
|
|
15
15
|
// Load findHostInstance_DEPRECATED lazily because it may not be available before render
|
16
16
|
if (findHostInstance_DEPRECATED === undefined) {
|
17
17
|
try {
|
18
|
+
var _ReactFabric$default;
|
19
|
+
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment
|
21
|
+
const ReactFabric = require('react-native/Libraries/Renderer/shims/ReactFabric'); // Since RN 0.77 ReactFabric exports findHostInstance_DEPRECATED in default object so we're trying to
|
22
|
+
// access it first, then fallback on named export
|
18
23
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
19
|
-
|
20
|
-
|
24
|
+
|
25
|
+
|
26
|
+
findHostInstance_DEPRECATED = // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
27
|
+
(ReactFabric === null || ReactFabric === void 0 ? void 0 : (_ReactFabric$default = ReactFabric.default) === null || _ReactFabric$default === void 0 ? void 0 : _ReactFabric$default.findHostInstance_DEPRECATED) || ( // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
28
|
+
ReactFabric === null || ReactFabric === void 0 ? void 0 : ReactFabric.findHostInstance_DEPRECATED);
|
21
29
|
} catch (e) {
|
22
30
|
findHostInstance_DEPRECATED = _ref => null;
|
23
31
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["getShadowNodeFromRef.ts"],"names":["findHostInstance_DEPRECATED","getInternalInstanceHandleFromPublicInstance","getShadowNodeFromRef","ref","undefined","require","e","_ref","_internalInstanceHandle","stateNode","node"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA,IAAIA,2BAAJ;AACA,IAAIC,2CAAJ;;AAIO,SAASC,oBAAT,CAA8BC,GAA9B,EAA4C;AACjD;AACA,MAAIH,2BAA2B,KAAKI,SAApC,EAA+C;AAC7C,QAAI;AACF;
|
1
|
+
{"version":3,"sources":["getShadowNodeFromRef.ts"],"names":["findHostInstance_DEPRECATED","getInternalInstanceHandleFromPublicInstance","getShadowNodeFromRef","ref","undefined","ReactFabric","require","default","e","_ref","_internalInstanceHandle","stateNode","node"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA,IAAIA,2BAAJ;AACA,IAAIC,2CAAJ;;AAIO,SAASC,oBAAT,CAA8BC,GAA9B,EAA4C;AACjD;AACA,MAAIH,2BAA2B,KAAKI,SAApC,EAA+C;AAC7C,QAAI;AAAA;;AACF;AACA,YAAMC,WAAW,GAAGC,OAAO,CAAC,mDAAD,CAA3B,CAFE,CAGF;AACA;AACA;;;AACAN,MAAAA,2BAA2B,GACzB;AACA,OAAAK,WAAW,SAAX,IAAAA,WAAW,WAAX,oCAAAA,WAAW,CAAEE,OAAb,8EAAsBP,2BAAtB,OACA;AACAK,MAAAA,WAFA,aAEAA,WAFA,uBAEAA,WAAW,CAAEL,2BAFb,CAFF;AAKD,KAXD,CAWE,OAAOQ,CAAP,EAAU;AACVR,MAAAA,2BAA2B,GAAIS,IAAD,IAAmB,IAAjD;AACD;AACF,GAjBgD,CAmBjD;;;AACA,MAAIR,2CAA2C,KAAKG,SAApD,EAA+D;AAC7D,QAAI;AAAA;;AACF;AACAH,MAAAA,2CAA2C,GACzC;AADyC,+BAEzCK,OAAO,CAAC,wFAAD,CAAP,CACGL,2CAHsC,yEAIzC;AACEE,MAAAA,GAAD,IAAcA,GAAG,CAACO,uBALrB;AAMD,KARD,CAQE,OAAOF,CAAP,EAAU;AACVP,MAAAA,2CAA2C,GAAIE,GAAD,IAC5C;AACAA,MAAAA,GAAG,CAACO,uBAFN;AAGD;AACF,GAlCgD,CAoCjD;;;AACA,SAAOT,2CAA2C,CAChDD,2BAA2B,CAACG,GAAD,CADqB,CAA3C,CAELQ,SAFK,CAEKC,IAFZ;AAGD","sourcesContent":["// Used by GestureDetector (unsupported on web at the moment) to check whether the\n// attached view may get flattened on Fabric. This implementation causes errors\n// on web due to the static resolution of `require` statements by webpack breaking\n// the conditional importing. Solved by making .web file.\nlet findHostInstance_DEPRECATED: (ref: unknown) => void;\nlet getInternalInstanceHandleFromPublicInstance: (ref: unknown) => {\n stateNode: { node: unknown };\n};\n\nexport function getShadowNodeFromRef(ref: unknown) {\n // Load findHostInstance_DEPRECATED lazily because it may not be available before render\n if (findHostInstance_DEPRECATED === undefined) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment\n const ReactFabric = require('react-native/Libraries/Renderer/shims/ReactFabric');\n // Since RN 0.77 ReactFabric exports findHostInstance_DEPRECATED in default object so we're trying to\n // access it first, then fallback on named export\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n findHostInstance_DEPRECATED =\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ReactFabric?.default?.findHostInstance_DEPRECATED ||\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ReactFabric?.findHostInstance_DEPRECATED;\n } catch (e) {\n findHostInstance_DEPRECATED = (_ref: unknown) => null;\n }\n }\n\n // Load findHostInstance_DEPRECATED lazily because it may not be available before render\n if (getInternalInstanceHandleFromPublicInstance === undefined) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n getInternalInstanceHandleFromPublicInstance =\n // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access\n require('react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance')\n .getInternalInstanceHandleFromPublicInstance ??\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return\n ((ref: any) => ref._internalInstanceHandle);\n } catch (e) {\n getInternalInstanceHandleFromPublicInstance = (ref: any) =>\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return\n ref._internalInstanceHandle;\n }\n }\n\n // @ts-ignore Fabric\n return getInternalInstanceHandleFromPublicInstance(\n findHostInstance_DEPRECATED(ref)\n ).stateNode.node;\n}\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["ghQueueMicrotask.ts"],"names":["ghQueueMicrotask","setImmediate","bind","requestAnimationFrame","queueMicrotask"],"mappings":";;;;;;AAAA;AACA;AACO,MAAMA,gBAAgB,GAC3B,OAAOC,YAAP,KAAwB,UAAxB,GACIA,YAAY,CAACC,IAAb,CAAkB,IAAlB,CADJ,GAEI,OAAOC,qBAAP,KAAiC,UAAjC,
|
1
|
+
{"version":3,"sources":["ghQueueMicrotask.ts"],"names":["ghQueueMicrotask","setImmediate","bind","requestAnimationFrame","queueMicrotask"],"mappings":";;;;;;AAAA;AACA;AACO,MAAMA,gBAAgB,GAC3B,OAAOC,YAAP,KAAwB,UAAxB,GACIA,YAAY,CAACC,IAAb,CAAkB,IAAlB,CADJ,GAEI,OAAOC,qBAAP,KAAiC,UAAjC,GACEA,qBAAqB,CAACD,IAAtB,CAA2B,IAA3B,CADF,GAEEE,cAAc,CAACF,IAAf,CAAoB,IAApB,CALD","sourcesContent":["// We check for typeof requestAnimationFrame because of SSR\n// Functions are bound to null to avoid issues with scope when using Metro inline requires.\nexport const ghQueueMicrotask =\n typeof setImmediate === 'function'\n ? setImmediate.bind(null)\n : typeof requestAnimationFrame === 'function'\n ? requestAnimationFrame.bind(null)\n : queueMicrotask.bind(null);\n"]}
|
@@ -33,6 +33,8 @@ var _GestureHandlerRootViewContext = _interopRequireDefault(require("../GestureH
|
|
33
33
|
|
34
34
|
var _ghQueueMicrotask = require("../ghQueueMicrotask");
|
35
35
|
|
36
|
+
var _mountRegistry = require("../mountRegistry");
|
37
|
+
|
36
38
|
var _UIManagerAny$getView, _UIManagerAny$getView2, _UIManagerAny$getCons;
|
37
39
|
|
38
40
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -265,6 +267,9 @@ function createHandler({
|
|
265
267
|
}
|
266
268
|
|
267
269
|
(0, _utils.scheduleFlushOperations)();
|
270
|
+
(0, _ghQueueMicrotask.ghQueueMicrotask)(() => {
|
271
|
+
_mountRegistry.MountRegistry.gestureHandlerWillMount(this);
|
272
|
+
});
|
268
273
|
});
|
269
274
|
|
270
275
|
_defineProperty(this, "updateGestureHandler", newConfig => {
|
@@ -318,6 +323,11 @@ function createHandler({
|
|
318
323
|
}
|
319
324
|
|
320
325
|
this.createGestureHandler((0, _utils.filterConfig)(transformProps ? transformProps(this.props) : this.props, [...allowedProps, ...customNativeProps], config));
|
326
|
+
|
327
|
+
if (!this.viewNode) {
|
328
|
+
throw new Error(`[Gesture Handler] Failed to obtain view for ${Handler.displayName}. Note that old API doesn't support functional components.`);
|
329
|
+
}
|
330
|
+
|
321
331
|
this.attachGestureHandler((0, _findNodeHandle.default)(this.viewNode)); // TODO(TS) - check if this can be null
|
322
332
|
}
|
323
333
|
|
@@ -347,6 +357,8 @@ function createHandler({
|
|
347
357
|
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
348
358
|
delete _handlersRegistry.handlerIDToTag[handlerID];
|
349
359
|
}
|
360
|
+
|
361
|
+
_mountRegistry.MountRegistry.gestureHandlerWillUnmount(this);
|
350
362
|
}
|
351
363
|
|
352
364
|
update(remainingTries) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["createHandler.tsx"],"names":["UIManagerAny","UIManager","customDirectEventTypes","topGestureHandlerEvent","registrationName","customGHEventsConfigFabricAndroid","topOnGestureHandlerEvent","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","isGestureHandlerWorklet","isStateChangeHandlerWorklet","isReanimatedHandler","REANIMATED_WORKLET","NATIVE_ANIMATED_EVENT","updateGestureHandler","createRef","isMountedRef","id","handlerIDToTag","Error","componentDidMount","inspectorToggleListener","setState","_","update","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","enabled","testID","GestureHandlerRootViewContext"],"mappings":";;;;;;;AAAA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAOA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;AAEA,MAAMA,YAAY,GAAGC,sBAArB;AAEAC,+CAAuBC,sBAAvB,GAAgD;AAC9CC,EAAAA,gBAAgB,EAAE;AAD4B,CAAhD;AAIA,MAAMC,iCAAiC,GAAG;AACxCC,EAAAA,wBAAwB,EAAE;AAAEF,IAAAA,gBAAgB,EAAE;AAApB,GADc;AAExCG,EAAAA,8BAA8B,EAAE;AAC9BH,IAAAA,gBAAgB,EAAE;AADY;AAFQ,CAA1C;AAOA,MAAMI,oBAAoB,GAAG;AAC3BC,EAAAA,qBAAqB,EAAE;AAAEL,IAAAA,gBAAgB,EAAE;AAApB,GADI;AAE3BM,EAAAA,2BAA2B,EAAE;AAC3BN,IAAAA,gBAAgB,EAAE;AADS,GAFF;AAM3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAI,2BACFO,sBAASC,EAAT,KAAgB,SADd,IAEFP,iCAFF;AAd2B,CAA7B,C,CAmBA;AACA;AACA;AACA;;AACAL,YAAY,CAACa,uBAAb,GAAuC,EACrC,GAAGb,YAAY,CAACa,uBADqB;AAErC,KAAGL;AAFkC,CAAvC,C,CAIA;AACA;AACA;;AACA,MAAMM,kBAAkB,sDACtBd,YAAY,CAACe,oBADS,2DACtB,4BAAAf,YAAY,EAAwB,cAAxB,CADU,kGAEtBA,YAAY,CAACgB,YAFS,0DAEtB,2BAAAhB,YAAY,CAFd;;AAIA,IAAIc,kBAAJ,EAAwB;AACtBA,EAAAA,kBAAkB,CAACD,uBAAnB,GAA6C,EAC3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AW,EAAE,KAFf;AAGE,YAAI,2BACA;AACEC,UAAAA,WAAW,EAAE1E,IADf;AAEEW,UAAAA,UAAU,EAAE,KAAKA,UAFnB;AAGEgE,UAAAA,OAAO,EAAE,KAAK9F,KAAL,CAAW8F;AAHtB,SADA,GAMA,EANJ,CAHF;AAUEC,QAAAA,MAAM,wBAAE,KAAK/F,KAAL,CAAW+F,MAAb,mEAAuBzD,KAAK,CAACtC,KAAN,CAAY+F,MAV3C;AAWE,WAAGb;AAXL,OAFK,EAeLE,aAfK,CAAP;AAiBD;;AA5WD;;AAPwE,kBAIpE5D,OAJoE,iBAQnDL,IARmD;;AAAA,kBAIpEK,OAJoE,iBASnDwE,sCATmD;;AAqX1E,SAAOxE,OAAP;AACD","sourcesContent":["import * as React from 'react';\nimport {\n Platform,\n UIManager,\n DeviceEventEmitter,\n EmitterSubscription,\n} from 'react-native';\nimport { customDirectEventTypes } from './customDirectEventTypes';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\nimport { State } from '../State';\nimport { handlerIDToTag, registerOldGestureHandler } from './handlersRegistry';\nimport { getNextHandlerTag } from './getNextHandlerTag';\n\nimport {\n BaseGestureHandlerProps,\n GestureEvent,\n HandlerStateChangeEvent,\n} from './gestureHandlerCommon';\nimport { filterConfig, scheduleFlushOperations } from './utils';\nimport findNodeHandle from '../findNodeHandle';\nimport { ValueOf } from '../typeUtils';\nimport { deepEqual, isFabric, isJestEnv, tagMessage } from '../utils';\nimport { ActionType } from '../ActionType';\nimport { PressabilityDebugView } from './PressabilityDebugView';\nimport GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';\nimport { ghQueueMicrotask } from '../ghQueueMicrotask';\n\nconst UIManagerAny = UIManager as any;\n\ncustomDirectEventTypes.topGestureHandlerEvent = {\n registrationName: 'onGestureHandlerEvent',\n};\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-op\n },\n clearJSResponder: oldClearJSResponder = () => {\n // no-op\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\ntype AttachGestureHandlerWeb = (\n handlerTag: number,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n newView: any,\n _actionType: ActionType,\n propsRef: React.RefObject<unknown>\n) => void;\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 ghQueueMicrotask(() => {\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 AttachGestureHandlerWeb\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 const onGestureEvent = this.props?.onGestureEvent;\n const isGestureHandlerWorklet =\n onGestureEvent &&\n ('current' in onGestureEvent ||\n 'workletEventHandler' in onGestureEvent);\n const onHandlerStateChange = this.props?.onHandlerStateChange;\n const isStateChangeHandlerWorklet =\n onHandlerStateChange &&\n ('current' in onHandlerStateChange ||\n 'workletEventHandler' in onHandlerStateChange);\n const isReanimatedHandler =\n isGestureHandlerWorklet || isStateChangeHandlerWorklet;\n if (isReanimatedHandler) {\n // Reanimated worklet\n return ActionType.REANIMATED_WORKLET;\n } else if (onGestureEvent && '__isNative' in onGestureEvent) {\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 ghQueueMicrotask(() => {\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 && !isJestEnv() && Platform.OS !== 'web') {\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 enabled: this.props.enabled,\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","customDirectEventTypes","topGestureHandlerEvent","registrationName","customGHEventsConfigFabricAndroid","topOnGestureHandlerEvent","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","isGestureHandlerWorklet","isStateChangeHandlerWorklet","isReanimatedHandler","REANIMATED_WORKLET","NATIVE_ANIMATED_EVENT","MountRegistry","gestureHandlerWillMount","updateGestureHandler","createRef","isMountedRef","id","handlerIDToTag","Error","componentDidMount","inspectorToggleListener","setState","_","update","displayName","componentDidUpdate","componentWillUnmount","remove","dropGestureHandler","handlerID","gestureHandlerWillUnmount","remainingTries","setNativeProps","updates","mergedProps","render","context","gestureEventHandler","gestureStateEventHandler","events","e","grandChildren","type","toArray","push","hitSlop","cloneElement","refHandler","collapsable","handlerType","enabled","testID","GestureHandlerRootViewContext"],"mappings":";;;;;;;AAAA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAOA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;AAEA,MAAMA,YAAY,GAAGC,sBAArB;AAEAC,+CAAuBC,sBAAvB,GAAgD;AAC9CC,EAAAA,gBAAgB,EAAE;AAD4B,CAAhD;AAIA,MAAMC,iCAAiC,GAAG;AACxCC,EAAAA,wBAAwB,EAAE;AAA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AWkG,MAAb,mEAAuB5D,KAAK,CAACtC,KAAN,CAAYkG,MAV3C;AAWE,WAAGZ;AAXL,OAFK,EAeLE,aAfK,CAAP;AAiBD;;AAxXD;;AAPwE,kBAIpEhE,OAJoE,iBAQnDL,IARmD;;AAAA,kBAIpEK,OAJoE,iBASnD2E,sCATmD;;AAiY1E,SAAO3E,OAAP;AACD","sourcesContent":["import * as React from 'react';\nimport {\n Platform,\n UIManager,\n DeviceEventEmitter,\n EmitterSubscription,\n} from 'react-native';\nimport { customDirectEventTypes } from './customDirectEventTypes';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\nimport { State } from '../State';\nimport { handlerIDToTag, registerOldGestureHandler } from './handlersRegistry';\nimport { getNextHandlerTag } from './getNextHandlerTag';\n\nimport {\n BaseGestureHandlerProps,\n GestureEvent,\n HandlerStateChangeEvent,\n} from './gestureHandlerCommon';\nimport { filterConfig, scheduleFlushOperations } from './utils';\nimport findNodeHandle from '../findNodeHandle';\nimport { ValueOf } from '../typeUtils';\nimport { deepEqual, isFabric, isJestEnv, tagMessage } from '../utils';\nimport { ActionType } from '../ActionType';\nimport { PressabilityDebugView } from './PressabilityDebugView';\nimport GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';\nimport { ghQueueMicrotask } from '../ghQueueMicrotask';\nimport { MountRegistry } from '../mountRegistry';\n\nconst UIManagerAny = UIManager as any;\n\ncustomDirectEventTypes.topGestureHandlerEvent = {\n registrationName: 'onGestureHandlerEvent',\n};\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-op\n },\n clearJSResponder: oldClearJSResponder = () => {\n // no-op\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\ntype AttachGestureHandlerWeb = (\n handlerTag: number,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n newView: any,\n _actionType: ActionType,\n propsRef: React.RefObject<unknown>\n) => void;\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 ghQueueMicrotask(() => {\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 if (!this.viewNode) {\n throw new Error(\n `[Gesture Handler] Failed to obtain view for ${Handler.displayName}. Note that old API doesn't support functional components.`\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 MountRegistry.gestureHandlerWillUnmount(this);\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 AttachGestureHandlerWeb\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 const onGestureEvent = this.props?.onGestureEvent;\n const isGestureHandlerWorklet =\n onGestureEvent &&\n ('current' in onGestureEvent ||\n 'workletEventHandler' in onGestureEvent);\n const onHandlerStateChange = this.props?.onHandlerStateChange;\n const isStateChangeHandlerWorklet =\n onHandlerStateChange &&\n ('current' in onHandlerStateChange ||\n 'workletEventHandler' in onHandlerStateChange);\n const isReanimatedHandler =\n isGestureHandlerWorklet || isStateChangeHandlerWorklet;\n if (isReanimatedHandler) {\n // Reanimated worklet\n return ActionType.REANIMATED_WORKLET;\n } else if (onGestureEvent && '__isNative' in onGestureEvent) {\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 ghQueueMicrotask(() => {\n MountRegistry.gestureHandlerWillMount(this);\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 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 ghQueueMicrotask(() => {\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 && !isJestEnv() && Platform.OS !== 'web') {\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 enabled: this.props.enabled,\n }\n : {}),\n testID: this.props.testID ?? child.props.testID,\n ...events,\n },\n grandChildren\n );\n }\n }\n return Handler;\n}\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["gestureHandlerCommon.ts"],"names":["commonProps","componentInteractionProps","baseGestureHandlerProps","baseGestureHandlerWithDetectorProps","MouseButton"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAQA,MAAMA,WAAW,GAAG,CAClB,IADkB,EAElB,SAFkB,EAGlB,yBAHkB,EAIlB,SAJkB,EAKlB,sBALkB,EAMlB,YANkB,EAOlB,cAPkB,EAQlB,aARkB,EASlB,mBATkB,EAUlB,aAVkB,CAApB;AAaA,MAAMC,yBAAyB,GAAG,CAChC,SADgC,EAEhC,sBAFgC,EAGhC,gBAHgC,CAAlC;AAMO,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,mCAAmC,GAAG,CACjD,GAAGH,WAD8C,EAEjD,kBAFiD,EAGjD,kBAHiD,CAA5C;;IAsEKI,W;;;WAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;GAAAA,W,2BAAAA,W","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';\n\nimport { State } from '../State';\nimport { TouchEventType } from '../TouchEventType';\nimport { ValueOf } from '../typeUtils';\nimport { PointerType } from '../PointerType';\n\nconst commonProps = [\n 'id',\n 'enabled',\n 'shouldCancelWhenOutside',\n 'hitSlop',\n 'cancelsTouchesInView',\n 'userSelect',\n 'activeCursor',\n 'mouseButton',\n 'enableContextMenu',\n 'touchAction',\n] as const;\n\nconst componentInteractionProps = [\n 'waitFor',\n 'simultaneousHandlers',\n 'blocksHandlers',\n] 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 baseGestureHandlerWithDetectorProps = [\n ...commonProps,\n 'needsPointerData',\n 'manualActivation',\n];\n\nexport interface GestureEventPayload {\n handlerTag: number;\n numberOfPointers: number;\n state: ValueOf<typeof State>;\n pointerType: PointerType;\n}\nexport interface HandlerStateChangeEventPayload extends GestureEventPayload {\n oldState: ValueOf<typeof State>;\n}\n\nexport type HitSlop =\n | number\n | null\n | undefined\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';\nexport type ActiveCursor =\n | 'auto'\n | 'default'\n | 'none'\n | 'context-menu'\n | 'help'\n | 'pointer'\n | 'progress'\n | 'wait'\n | 'cell'\n | 'crosshair'\n | 'text'\n | 'vertical-text'\n | 'alias'\n | 'copy'\n | 'move'\n | 'no-drop'\n | 'not-allowed'\n | 'grab'\n | 'grabbing'\n | 'e-resize'\n | 'n-resize'\n | 'ne-resize'\n | 'nw-resize'\n | 's-resize'\n | 'se-resize'\n | 'sw-resize'\n | 'w-resize'\n | 'ew-resize'\n | 'ns-resize'\n | 'nesw-resize'\n | 'nwse-resize'\n | 'col-resize'\n | 'row-resize'\n | 'all-scroll'\n | 'zoom-in'\n | 'zoom-out';\n\nexport enum MouseButton {\n LEFT = 1,\n RIGHT = 2,\n MIDDLE = 4,\n BUTTON_4 = 8,\n BUTTON_5 = 16,\n ALL = 31,\n}\n\nexport type TouchAction =\n | 'auto'\n | 'none'\n | 'pan-x'\n | 'pan-left'\n | 'pan-right'\n | 'pan-y'\n | 'pan-up'\n | 'pan-down'\n | 'pinch-zoom'\n | 'manipulation'\n | 'inherit'\n | 'initial'\n | 'revert'\n | 'revert-layer'\n | 'unset';\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
|
1
|
+
{"version":3,"sources":["gestureHandlerCommon.ts"],"names":["commonProps","componentInteractionProps","baseGestureHandlerProps","baseGestureHandlerWithDetectorProps","MouseButton"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAQA,MAAMA,WAAW,GAAG,CAClB,IADkB,EAElB,SAFkB,EAGlB,yBAHkB,EAIlB,SAJkB,EAKlB,sBALkB,EAMlB,YANkB,EAOlB,cAPkB,EAQlB,aARkB,EASlB,mBATkB,EAUlB,aAVkB,CAApB;AAaA,MAAMC,yBAAyB,GAAG,CAChC,SADgC,EAEhC,sBAFgC,EAGhC,gBAHgC,CAAlC;AAMO,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,mCAAmC,GAAG,CACjD,GAAGH,WAD8C,EAEjD,kBAFiD,EAGjD,kBAHiD,CAA5C;;IAsEKI,W;;;WAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;GAAAA,W,2BAAAA,W","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';\n\nimport { State } from '../State';\nimport { TouchEventType } from '../TouchEventType';\nimport { ValueOf } from '../typeUtils';\nimport { PointerType } from '../PointerType';\n\nconst commonProps = [\n 'id',\n 'enabled',\n 'shouldCancelWhenOutside',\n 'hitSlop',\n 'cancelsTouchesInView',\n 'userSelect',\n 'activeCursor',\n 'mouseButton',\n 'enableContextMenu',\n 'touchAction',\n] as const;\n\nconst componentInteractionProps = [\n 'waitFor',\n 'simultaneousHandlers',\n 'blocksHandlers',\n] 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 baseGestureHandlerWithDetectorProps = [\n ...commonProps,\n 'needsPointerData',\n 'manualActivation',\n];\n\nexport interface GestureEventPayload {\n handlerTag: number;\n numberOfPointers: number;\n state: ValueOf<typeof State>;\n pointerType: PointerType;\n}\nexport interface HandlerStateChangeEventPayload extends GestureEventPayload {\n oldState: ValueOf<typeof State>;\n}\n\nexport type HitSlop =\n | number\n | null\n | undefined\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';\nexport type ActiveCursor =\n | 'auto'\n | 'default'\n | 'none'\n | 'context-menu'\n | 'help'\n | 'pointer'\n | 'progress'\n | 'wait'\n | 'cell'\n | 'crosshair'\n | 'text'\n | 'vertical-text'\n | 'alias'\n | 'copy'\n | 'move'\n | 'no-drop'\n | 'not-allowed'\n | 'grab'\n | 'grabbing'\n | 'e-resize'\n | 'n-resize'\n | 'ne-resize'\n | 'nw-resize'\n | 's-resize'\n | 'se-resize'\n | 'sw-resize'\n | 'w-resize'\n | 'ew-resize'\n | 'ns-resize'\n | 'nesw-resize'\n | 'nwse-resize'\n | 'col-resize'\n | 'row-resize'\n | 'all-scroll'\n | 'zoom-in'\n | 'zoom-out';\n\nexport enum MouseButton {\n LEFT = 1,\n RIGHT = 2,\n MIDDLE = 4,\n BUTTON_4 = 8,\n BUTTON_5 = 16,\n ALL = 31,\n}\n\nexport type TouchAction =\n | 'auto'\n | 'none'\n | 'pan-x'\n | 'pan-left'\n | 'pan-right'\n | 'pan-y'\n | 'pan-up'\n | 'pan-down'\n | 'pinch-zoom'\n | 'manipulation'\n | 'inherit'\n | 'initial'\n | 'revert'\n | 'revert-layer'\n | 'unset';\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 pointerType: PointerType;\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 activeCursor?: ActiveCursor;\n mouseButton?: MouseButton;\n enableContextMenu?: boolean;\n touchAction?: TouchAction;\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 blocksHandlers?: 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"]}
|
@@ -19,6 +19,8 @@ var _ghQueueMicrotask = require("../../../ghQueueMicrotask");
|
|
19
19
|
|
20
20
|
var _utils2 = require("./utils");
|
21
21
|
|
22
|
+
var _mountRegistry = require("../../../mountRegistry");
|
23
|
+
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23
25
|
|
24
26
|
function attachHandlers({
|
@@ -70,6 +72,8 @@ function attachHandlers({
|
|
70
72
|
} else {
|
71
73
|
_RNGestureHandlerModule.default.attachGestureHandler(gesture.handlerTag, viewTag, actionType);
|
72
74
|
}
|
75
|
+
|
76
|
+
_mountRegistry.MountRegistry.gestureWillMount(gesture);
|
73
77
|
}
|
74
78
|
|
75
79
|
preparedGesture.attachedGestures = gesturesToAttach;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["attachHandlers.ts"],"names":["attachHandlers","preparedGesture","gestureConfig","gesturesToAttach","viewTag","webEventHandlersRef","initialize","isMounted","prepare","handler","RNGestureHandlerModule","createGestureHandler","handlerName","handlerTag","config","ALLOWED_PROPS","testId","updateGestureHandler","gesture","actionType","shouldUseReanimated","ActionType","REANIMATED_WORKLET","JS_FUNCTION_NEW_API","Platform","OS","attachGestureHandler","JS_FUNCTION_OLD_API","attachedGestures","animatedHandlers","isAnimatedGesture","g","value","filter","map","handlers"],"mappings":";;;;;;;AAEA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AAEA;;;;
|
1
|
+
{"version":3,"sources":["attachHandlers.ts"],"names":["attachHandlers","preparedGesture","gestureConfig","gesturesToAttach","viewTag","webEventHandlersRef","initialize","isMounted","prepare","handler","RNGestureHandlerModule","createGestureHandler","handlerName","handlerTag","config","ALLOWED_PROPS","testId","updateGestureHandler","gesture","actionType","shouldUseReanimated","ActionType","REANIMATED_WORKLET","JS_FUNCTION_NEW_API","Platform","OS","attachGestureHandler","JS_FUNCTION_OLD_API","MountRegistry","gestureWillMount","attachedGestures","animatedHandlers","isAnimatedGesture","g","value","filter","map","handlers"],"mappings":";;;;;;;AAEA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AAEA;;AAKA;;;;AAUO,SAASA,cAAT,CAAwB;AAC7BC,EAAAA,eAD6B;AAE7BC,EAAAA,aAF6B;AAG7BC,EAAAA,gBAH6B;AAI7BC,EAAAA,OAJ6B;AAK7BC,EAAAA;AAL6B,CAAxB,EAMkB;AACvBH,EAAAA,aAAa,CAACI,UAAd,GADuB,CAGvB;AACA;;AACA,0CAAiB,MAAM;AACrB,QAAI,CAACL,eAAe,CAACM,SAArB,EAAgC;AAC9B;AACD;;AACDL,IAAAA,aAAa,CAACM,OAAd;AACD,GALD;;AAOA,OAAK,MAAMC,OAAX,IAAsBN,gBAAtB,EAAwC;AACtC,kDAAiCM,OAAjC;;AACAC,oCAAuBC,oBAAvB,CACEF,OAAO,CAACG,WADV,EAEEH,OAAO,CAACI,UAFV,EAGE,yBAAaJ,OAAO,CAACK,MAArB,EAA6BC,qBAA7B,CAHF;;AAMA,2CAAgBN,OAAO,CAACI,UAAxB,EAAoCJ,OAApC,EAA6CA,OAAO,CAACK,MAAR,CAAeE,MAA5D;AACD,GArBsB,CAuBvB;AACA;;;AACA,0CAAiB,MAAM;AACrB,QAAI,CAACf,eAAe,CAACM,SAArB,EAAgC;AAC9B;AACD;;AACD,SAAK,MAAME,OAAX,IAAsBN,gBAAtB,EAAwC;AACtCO,sCAAuBO,oBAAvB,CACER,OAAO,CAACI,UADV,EAEE,yBACEJ,OAAO,CAACK,MADV,EAEEC,qBAFF,EAGE,qCAAwBN,OAAxB,CAHF,CAFF;AAQD;;AAED;AACD,GAhBD;;AAkBA,OAAK,MAAMS,OAAX,IAAsBf,gBAAtB,EAAwC;AACtC,UAAMgB,UAAU,GAAGD,OAAO,CAACE,mBAAR,GACfC,uBAAWC,kBADI,GAEfD,uBAAWE,mBAFf;;AAIA,QAAIC,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AAEvBf,sCAAuBgB,oBADzB,CAGER,OAAO,CAACL,UAHV,EAIET,OAJF,EAKEiB,uBAAWM,mBALb,EAKkC;AAChCtB,MAAAA,mBANF;AAQD,KATD,MASO;AACLK,sCAAuBgB,oBAAvB,CACER,OAAO,CAACL,UADV,EAEET,OAFF,EAGEe,UAHF;AAKD;;AAEDS,iCAAcC,gBAAd,CAA+BX,OAA/B;AACD;;AAEDjB,EAAAA,eAAe,CAAC6B,gBAAhB,GAAmC3B,gBAAnC;;AAEA,MAAIF,eAAe,CAAC8B,gBAApB,EAAsC;AACpC,UAAMC,iBAAiB,GAAIC,CAAD,IAAoBA,CAAC,CAACb,mBAAhD;;AAEAnB,IAAAA,eAAe,CAAC8B,gBAAhB,CAAiCG,KAAjC,GAAyC/B,gBAAgB,CACtDgC,MADsC,CAC/BH,iBAD+B,EAEtCI,GAFsC,CAEjCH,CAAD,IAAOA,CAAC,CAACI,QAFyB,CAAzC;AAKD;AACF","sourcesContent":["import React from 'react';\nimport { GestureType, HandlerCallbacks } from '../gesture';\nimport { registerHandler } from '../../handlersRegistry';\nimport RNGestureHandlerModule from '../../../RNGestureHandlerModule';\nimport { filterConfig, scheduleFlushOperations } from '../../utils';\nimport { ComposedGesture } from '../gestureComposition';\nimport { ActionType } from '../../../ActionType';\nimport { Platform } from 'react-native';\nimport type RNGestureHandlerModuleWeb from '../../../RNGestureHandlerModule.web';\nimport { ghQueueMicrotask } from '../../../ghQueueMicrotask';\nimport { AttachedGestureState, WebEventHandler } from './types';\nimport {\n extractGestureRelations,\n checkGestureCallbacksForWorklets,\n ALLOWED_PROPS,\n} from './utils';\nimport { MountRegistry } from '../../../mountRegistry';\n\ninterface AttachHandlersConfig {\n preparedGesture: AttachedGestureState;\n gestureConfig: ComposedGesture | GestureType;\n gesturesToAttach: GestureType[];\n viewTag: number;\n webEventHandlersRef: React.RefObject<WebEventHandler>;\n}\n\nexport function attachHandlers({\n preparedGesture,\n gestureConfig,\n gesturesToAttach,\n viewTag,\n webEventHandlersRef,\n}: AttachHandlersConfig) {\n gestureConfig.initialize();\n\n // Use queueMicrotask to extract handlerTags, because all refs should be initialized\n // when it's ran\n ghQueueMicrotask(() => {\n if (!preparedGesture.isMounted) {\n return;\n }\n gestureConfig.prepare();\n });\n\n for (const handler of gesturesToAttach) {\n checkGestureCallbacksForWorklets(handler);\n RNGestureHandlerModule.createGestureHandler(\n handler.handlerName,\n handler.handlerTag,\n filterConfig(handler.config, ALLOWED_PROPS)\n );\n\n registerHandler(handler.handlerTag, handler, handler.config.testId);\n }\n\n // Use queueMicrotask to extract handlerTags, because all refs should be initialized\n // when it's ran\n ghQueueMicrotask(() => {\n if (!preparedGesture.isMounted) {\n return;\n }\n for (const handler of gesturesToAttach) {\n RNGestureHandlerModule.updateGestureHandler(\n handler.handlerTag,\n filterConfig(\n handler.config,\n ALLOWED_PROPS,\n extractGestureRelations(handler)\n )\n );\n }\n\n scheduleFlushOperations();\n });\n\n for (const gesture of gesturesToAttach) {\n const actionType = gesture.shouldUseReanimated\n ? ActionType.REANIMATED_WORKLET\n : ActionType.JS_FUNCTION_NEW_API;\n\n if (Platform.OS === 'web') {\n (\n RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler\n )(\n gesture.handlerTag,\n viewTag,\n ActionType.JS_FUNCTION_OLD_API, // Ignored on web\n webEventHandlersRef\n );\n } else {\n RNGestureHandlerModule.attachGestureHandler(\n gesture.handlerTag,\n viewTag,\n actionType\n );\n }\n\n MountRegistry.gestureWillMount(gesture);\n }\n\n preparedGesture.attachedGestures = gesturesToAttach;\n\n if (preparedGesture.animatedHandlers) {\n const isAnimatedGesture = (g: GestureType) => g.shouldUseReanimated;\n\n preparedGesture.animatedHandlers.value = gesturesToAttach\n .filter(isAnimatedGesture)\n .map((g) => g.handlers) as unknown as HandlerCallbacks<\n Record<string, unknown>\n >[];\n }\n}\n"]}
|
@@ -11,6 +11,8 @@ var _RNGestureHandlerModule = _interopRequireDefault(require("../../../RNGesture
|
|
11
11
|
|
12
12
|
var _utils = require("../../utils");
|
13
13
|
|
14
|
+
var _mountRegistry = require("../../../mountRegistry");
|
15
|
+
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
17
|
|
16
18
|
function dropHandlers(preparedGesture) {
|
@@ -18,6 +20,8 @@ function dropHandlers(preparedGesture) {
|
|
18
20
|
_RNGestureHandlerModule.default.dropGestureHandler(handler.handlerTag);
|
19
21
|
|
20
22
|
(0, _handlersRegistry.unregisterHandler)(handler.handlerTag, handler.config.testId);
|
23
|
+
|
24
|
+
_mountRegistry.MountRegistry.gestureWillUnmount(handler);
|
21
25
|
}
|
22
26
|
|
23
27
|
(0, _utils.scheduleFlushOperations)();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["dropHandlers.ts"],"names":["dropHandlers","preparedGesture","handler","attachedGestures","RNGestureHandlerModule","dropGestureHandler","handlerTag","config","testId"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;
|
1
|
+
{"version":3,"sources":["dropHandlers.ts"],"names":["dropHandlers","preparedGesture","handler","attachedGestures","RNGestureHandlerModule","dropGestureHandler","handlerTag","config","testId","MountRegistry","gestureWillUnmount"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;;;AAEO,SAASA,YAAT,CAAsBC,eAAtB,EAA6D;AAClE,OAAK,MAAMC,OAAX,IAAsBD,eAAe,CAACE,gBAAtC,EAAwD;AACtDC,oCAAuBC,kBAAvB,CAA0CH,OAAO,CAACI,UAAlD;;AAEA,6CAAkBJ,OAAO,CAACI,UAA1B,EAAsCJ,OAAO,CAACK,MAAR,CAAeC,MAArD;;AAEAC,iCAAcC,kBAAd,CAAiCR,OAAjC;AACD;;AAED;AACD","sourcesContent":["import { unregisterHandler } from '../../handlersRegistry';\nimport RNGestureHandlerModule from '../../../RNGestureHandlerModule';\nimport { scheduleFlushOperations } from '../../utils';\nimport { AttachedGestureState } from './types';\nimport { MountRegistry } from '../../../mountRegistry';\n\nexport function dropHandlers(preparedGesture: AttachedGestureState) {\n for (const handler of preparedGesture.attachedGestures) {\n RNGestureHandlerModule.dropGestureHandler(handler.handlerTag);\n\n unregisterHandler(handler.handlerTag, handler.config.testId);\n\n MountRegistry.gestureWillUnmount(handler);\n }\n\n scheduleFlushOperations();\n}\n"]}
|
@@ -31,6 +31,8 @@ var _useDetectorUpdater = require("./useDetectorUpdater");
|
|
31
31
|
|
32
32
|
var _useViewRefHandler = require("./useViewRefHandler");
|
33
33
|
|
34
|
+
var _useMountReactions = require("./useMountReactions");
|
35
|
+
|
34
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
35
37
|
|
36
38
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
@@ -128,6 +130,7 @@ const GestureDetector = props => {
|
|
128
130
|
updateAttachedGestures();
|
129
131
|
}
|
130
132
|
}, [props]);
|
133
|
+
(0, _useMountReactions.useMountReactions)(updateAttachedGestures, preparedGesture);
|
131
134
|
|
132
135
|
if (shouldUseReanimated) {
|
133
136
|
return /*#__PURE__*/_react.default.createElement(_Wrap.AnimatedWrap, {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["propagateDetectorConfig","props","gesture","keysToPropagate","key","value","undefined","g","toGestureArray","config","GestureDetector","rootViewContext","GestureHandlerRootViewContext","__DEV__","Platform","OS","Error","gestureConfig","gesturesToAttach","shouldUseReanimated","some","webEventHandlersRef","state","firstRender","viewRef","previousViewTag","forceRebuildReanimatedEvent","current","preparedGesture","React","useRef","attachedGestures","animatedEventHandler","animatedHandlers","isMounted","updateAttachedGestures","refHandler","needsToRebuildReanimatedEvent","viewTag","children"],"mappings":";;;;;;;AACA;;AAOA;;AACA;;AAIA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["propagateDetectorConfig","props","gesture","keysToPropagate","key","value","undefined","g","toGestureArray","config","GestureDetector","rootViewContext","GestureHandlerRootViewContext","__DEV__","Platform","OS","Error","gestureConfig","gesturesToAttach","shouldUseReanimated","some","webEventHandlersRef","state","firstRender","viewRef","previousViewTag","forceRebuildReanimatedEvent","current","preparedGesture","React","useRef","attachedGestures","animatedEventHandler","animatedHandlers","isMounted","updateAttachedGestures","refHandler","needsToRebuildReanimatedEvent","viewTag","children"],"mappings":";;;;;;;AACA;;AAOA;;AACA;;AAIA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAzBA;AA2BA,SAASA,uBAAT,CACEC,KADF,EAEEC,OAFF,EAGE;AACA,QAAMC,eAA+C,GAAG,CACtD,YADsD,EAEtD,mBAFsD,EAGtD,aAHsD,CAAxD;;AAMA,OAAK,MAAMC,GAAX,IAAkBD,eAAlB,EAAmC;AACjC,UAAME,KAAK,GAAGJ,KAAK,C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UADP;AAEE,MAAA,qBAAqB,EAAER,eAAe,CAACI;AAFzC,OAGG/B,KAAK,CAACsC,QAHT,CADF;AAOD,GARD,MAQO;AACL,wBAAO,6BAAC,UAAD;AAAM,MAAA,GAAG,EAAEH;AAAX,OAAwBnC,KAAK,CAACsC,QAA9B,CAAP;AACD;AACF,CAhGM","sourcesContent":["/* eslint-disable react/no-unused-prop-types */\nimport React, {\n useContext,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n} from 'react';\nimport { Platform } from 'react-native';\nimport findNodeHandle from '../../../findNodeHandle';\nimport { GestureType } from '../gesture';\nimport { UserSelect, TouchAction } from '../../gestureHandlerCommon';\nimport { ComposedGesture } from '../gestureComposition';\nimport { isJestEnv } from '../../../utils';\n\nimport GestureHandlerRootViewContext from '../../../GestureHandlerRootViewContext';\nimport { AttachedGestureState, GestureDetectorState } from './types';\nimport { useAnimatedGesture } from './useAnimatedGesture';\nimport { attachHandlers } from './attachHandlers';\nimport { needsToReattach } from './needsToReattach';\nimport { dropHandlers } from './dropHandlers';\nimport { useWebEventHandlers } from './utils';\nimport { Wrap, AnimatedWrap } from './Wrap';\nimport { useDetectorUpdater } from './useDetectorUpdater';\nimport { useViewRefHandler } from './useViewRefHandler';\nimport { useMountReactions } from './useMountReactions';\n\nfunction propagateDetectorConfig(\n props: GestureDetectorProps,\n gesture: ComposedGesture | GestureType\n) {\n const keysToPropagate: (keyof GestureDetectorProps)[] = [\n 'userSelect',\n 'enableContextMenu',\n 'touchAction',\n ];\n\n for (const key of keysToPropagate) {\n const value = props[key];\n if (value === undefined) {\n continue;\n }\n\n for (const g of gesture.toGestureArray()) {\n const config = g.config as { [key: string]: unknown };\n config[key] = value;\n }\n }\n}\n\ninterface GestureDetectorProps {\n children?: React.ReactNode;\n /**\n * A gesture object containing the configuration and callbacks.\n * Can be any of:\n * - base gestures (`Tap`, `Pan`, ...)\n * - `ComposedGesture` (`Race`, `Simultaneous`, `Exclusive`)\n */\n gesture: ComposedGesture | GestureType;\n /**\n * #### Web only\n * This parameter allows to specify which `userSelect` property should be applied to underlying view.\n * Possible values are `\"none\" | \"auto\" | \"text\"`. Default value is set to `\"none\"`.\n */\n userSelect?: UserSelect;\n /**\n * #### Web only\n * Specifies whether context menu should be enabled after clicking on underlying view with right mouse button.\n * Default value is set to `false`.\n */\n enableContextMenu?: boolean;\n /**\n * #### Web only\n * This parameter allows to specify which `touchAction` property should be applied to underlying view.\n * Supports all CSS touch-action values (e.g. `\"none\"`, `\"pan-y\"`). Default value is set to `\"none\"`.\n */\n touchAction?: TouchAction;\n}\n\n/**\n * `GestureDetector` is responsible for creating and updating native gesture handlers based on the config of provided gesture.\n *\n * ### Props\n * - `gesture`\n * - `userSelect` (**Web only**)\n * - `enableContextMenu` (**Web only**)\n * - `touchAction` (**Web only**)\n *\n * ### Remarks\n * - Gesture Detector will use first native view in its subtree to recognize gestures, however if this view is used only to group its children it may get automatically collapsed.\n * - Using the same instance of a gesture across multiple Gesture Detectors is not possible.\n *\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/gesture-detector\n */\nexport const GestureDetector = (props: GestureDetectorProps) => {\n const rootViewContext = useContext(GestureHandlerRootViewContext);\n if (__DEV__ && !rootViewContext && !isJestEnv() && Platform.OS !== 'web') {\n throw new Error(\n '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.'\n );\n }\n\n // Gesture config should be wrapped with useMemo to prevent unnecessary re-renders\n const gestureConfig = props.gesture;\n propagateDetectorConfig(props, gestureConfig);\n\n const gesturesToAttach = useMemo(\n () => gestureConfig.toGestureArray(),\n [gestureConfig]\n );\n const shouldUseReanimated = gesturesToAttach.some(\n (g) => g.shouldUseReanimated\n );\n\n const webEventHandlersRef = useWebEventHandlers();\n // Store state in ref to prevent unnecessary renders\n const state = useRef<GestureDetectorState>({\n firstRender: true,\n viewRef: null,\n previousViewTag: -1,\n forceRebuildReanimatedEvent: false,\n }).current;\n\n const preparedGesture = React.useRef<AttachedGestureState>({\n attachedGestures: [],\n animatedEventHandler: null,\n animatedHandlers: null,\n shouldUseReanimated: shouldUseReanimated,\n isMounted: false,\n }).current;\n\n const updateAttachedGestures = useDetectorUpdater(\n state,\n preparedGesture,\n gesturesToAttach,\n gestureConfig,\n webEventHandlersRef\n );\n\n const refHandler = useViewRefHandler(state, updateAttachedGestures);\n\n // Reanimated event should be rebuilt only when gestures are reattached, otherwise\n // config update will be enough as all necessary items are stored in shared values anyway\n const needsToRebuildReanimatedEvent =\n state.firstRender ||\n state.forceRebuildReanimatedEvent ||\n needsToReattach(preparedGesture, gesturesToAttach);\n state.forceRebuildReanimatedEvent = false;\n\n useAnimatedGesture(preparedGesture, needsToRebuildReanimatedEvent);\n\n useLayoutEffect(() => {\n const viewTag = findNodeHandle(state.viewRef) as number;\n preparedGesture.isMounted = true;\n\n attachHandlers({\n preparedGesture,\n gestureConfig,\n gesturesToAttach,\n webEventHandlersRef,\n viewTag,\n });\n\n return () => {\n preparedGesture.isMounted = false;\n dropHandlers(preparedGesture);\n };\n }, []);\n\n useEffect(() => {\n if (state.firstRender) {\n state.firstRender = false;\n } else {\n updateAttachedGestures();\n }\n }, [props]);\n\n useMountReactions(updateAttachedGestures, preparedGesture);\n\n if (shouldUseReanimated) {\n return (\n <AnimatedWrap\n ref={refHandler}\n onGestureHandlerEvent={preparedGesture.animatedEventHandler}>\n {props.children}\n </AnimatedWrap>\n );\n } else {\n return <Wrap ref={refHandler}>{props.children}</Wrap>;\n }\n};\n"]}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.useMountReactions = useMountReactions;
|
7
|
+
|
8
|
+
var _utils = require("../../utils");
|
9
|
+
|
10
|
+
var _mountRegistry = require("../../../mountRegistry");
|
11
|
+
|
12
|
+
var _react = require("react");
|
13
|
+
|
14
|
+
function shouldUpdateDetector(relation, gesture) {
|
15
|
+
if (relation === undefined) {
|
16
|
+
return false;
|
17
|
+
}
|
18
|
+
|
19
|
+
for (const tag of (0, _utils.transformIntoHandlerTags)(relation)) {
|
20
|
+
if (tag === gesture.handlerTag) {
|
21
|
+
return true;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
return false;
|
26
|
+
}
|
27
|
+
|
28
|
+
function useMountReactions(updateDetector, state) {
|
29
|
+
(0, _react.useEffect)(() => {
|
30
|
+
return _mountRegistry.MountRegistry.addMountListener(gesture => {
|
31
|
+
// At this point the ref in the gesture config should be updated, so we can check if one of the gestures
|
32
|
+
// set in a relation with the gesture got mounted. If so, we need to update the detector to propagate
|
33
|
+
// the changes to the native side.
|
34
|
+
for (const attachedGesture of state.attachedGestures) {
|
35
|
+
const blocksHandlers = attachedGesture.config.blocksHandlers;
|
36
|
+
const requireToFail = attachedGesture.config.requireToFail;
|
37
|
+
const simultaneousWith = attachedGesture.config.simultaneousWith;
|
38
|
+
|
39
|
+
if (shouldUpdateDetector(blocksHandlers, gesture) || shouldUpdateDetector(requireToFail, gesture) || shouldUpdateDetector(simultaneousWith, gesture)) {
|
40
|
+
updateDetector(); // We can safely return here, if any other gestures should be updated, they will be by the above call
|
41
|
+
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
});
|
46
|
+
}, [updateDetector, state]);
|
47
|
+
}
|
48
|
+
//# sourceMappingURL=useMountReactions.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["useMountReactions.ts"],"names":["shouldUpdateDetector","relation","gesture","undefined","tag","handlerTag","useMountReactions","updateDetector","state","MountRegistry","addMountListener","attachedGesture","attachedGestures","blocksHandlers","config","requireToFail","simultaneousWith"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AAGA,SAASA,oBAAT,CACEC,QADF,EAEEC,OAFF,EAGE;AACA,MAAID,QAAQ,KAAKE,SAAjB,EAA4B;AAC1B,WAAO,KAAP;AACD;;AAED,OAAK,MAAMC,GAAX,IAAkB,qCAAyBH,QAAzB,CAAlB,EAAsD;AACpD,QAAIG,GAAG,KAAKF,OAAO,CAACG,UAApB,EAAgC;AAC9B,aAAO,IAAP;AACD;AACF;;AAED,SAAO,KAAP;AACD;;AAEM,SAASC,iBAAT,CACLC,cADK,EAELC,KAFK,EAGL;AACA,wBAAU,MAAM;AACd,WAAOC,6BAAcC,gBAAd,CAAgCR,OAAD,IAAa;AACjD;AACA;AACA;AACA,WAAK,MAAMS,eAAX,IAA8BH,KAAK,CAACI,gBAApC,EAAsD;AACpD,cAAMC,cAAc,GAAGF,eAAe,CAACG,MAAhB,CAAuBD,cAA9C;AACA,cAAME,aAAa,GAAGJ,eAAe,CAACG,MAAhB,CAAuBC,aAA7C;AACA,cAAMC,gBAAgB,GAAGL,eAAe,CAACG,MAAhB,CAAuBE,gBAAhD;;AAEA,YACEhB,oBAAoB,CAACa,cAAD,EAAiBX,OAAjB,CAApB,IACAF,oBAAoB,CAACe,aAAD,EAAgBb,OAAhB,CADpB,IAEAF,oBAAoB,CAACgB,gBAAD,EAAmBd,OAAnB,CAHtB,EAIE;AACAK,UAAAA,cAAc,GADd,CAGA;;AACA;AACD;AACF;AACF,KApBM,CAAP;AAqBD,GAtBD,EAsBG,CAACA,cAAD,EAAiBC,KAAjB,CAtBH;AAuBD","sourcesContent":["import { transformIntoHandlerTags } from '../../utils';\nimport { MountRegistry } from '../../../mountRegistry';\nimport { AttachedGestureState } from './types';\nimport { useEffect } from 'react';\nimport { GestureRef } from '../gesture';\n\nfunction shouldUpdateDetector(\n relation: GestureRef[] | undefined,\n gesture: { handlerTag: number }\n) {\n if (relation === undefined) {\n return false;\n }\n\n for (const tag of transformIntoHandlerTags(relation)) {\n if (tag === gesture.handlerTag) {\n return true;\n }\n }\n\n return false;\n}\n\nexport function useMountReactions(\n updateDetector: () => void,\n state: AttachedGestureState\n) {\n useEffect(() => {\n return MountRegistry.addMountListener((gesture) => {\n // At this point the ref in the gesture config should be updated, so we can check if one of the gestures\n // set in a relation with the gesture got mounted. If so, we need to update the detector to propagate\n // the changes to the native side.\n for (const attachedGesture of state.attachedGestures) {\n const blocksHandlers = attachedGesture.config.blocksHandlers;\n const requireToFail = attachedGesture.config.requireToFail;\n const simultaneousWith = attachedGesture.config.simultaneousWith;\n\n if (\n shouldUpdateDetector(blocksHandlers, gesture) ||\n shouldUpdateDetector(requireToFail, gesture) ||\n shouldUpdateDetector(simultaneousWith, gesture)\n ) {\n updateDetector();\n\n // We can safely return here, if any other gestures should be updated, they will be by the above call\n return;\n }\n }\n });\n }, [updateDetector, state]);\n}\n"]}
|