You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
47 KiB

{"ast":null,"code":"import _toConsumableArray from \"@babel/runtime/helpers/toConsumableArray\";\nimport _classCallCheck from \"@babel/runtime/helpers/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/createClass\";\nimport _assertThisInitialized from \"@babel/runtime/helpers/assertThisInitialized\";\nimport _inherits from \"@babel/runtime/helpers/inherits\";\nimport _possibleConstructorReturn from \"@babel/runtime/helpers/possibleConstructorReturn\";\nimport _getPrototypeOf from \"@babel/runtime/helpers/getPrototypeOf\";\nimport _defineProperty2 from \"@babel/runtime/helpers/defineProperty\";\nvar _stateToPropMappings;\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty2(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nvar _UIManagerAny$getView, _UIManagerAny$getView2, _UIManagerAny$getCons;\nfunction _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n}\nimport * as React from 'react';\nimport Platform from \"react-native-web/dist/exports/Platform\";\nimport UIManager from \"react-native-web/dist/exports/UIManager\";\nimport DeviceEventEmitter from \"react-native-web/dist/exports/DeviceEventEmitter\";\nimport deepEqual from 'lodash/isEqual';\nimport RNGestureHandlerModule from \"../RNGestureHandlerModule\";\nimport { State } from \"../State\";\nimport { handlerIDToTag, getNextHandlerTag, registerOldGestureHandler } from \"./handlersRegistry\";\nimport { filterConfig, findNodeHandle, scheduleFlushOperations } from \"./gestureHandlerCommon\";\nimport { isFabric, isJestEnv, tagMessage } from \"../utils\";\nimport { ActionType } from \"../ActionType\";\nimport { PressabilityDebugView } from \"./PressabilityDebugView\";\nvar UIManagerAny = UIManager;\nvar customGHEventsConfigFabricAndroid = {\n topOnGestureHandlerEvent: {\n registrationName: 'onGestureHandlerEvent'\n },\n topOnGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange'\n }\n};\nvar customGHEventsConfig = _objectSpread({\n onGestureHandlerEvent: {\n registrationName: 'onGestureHandlerEvent'\n },\n onGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange'\n }\n}, isFabric() && Platform.OS === 'android' && customGHEventsConfigFabricAndroid);\nUIManagerAny.genericDirectEventTypes = _objectSpread(_objectSpread({}, UIManagerAny.genericDirectEventTypes), customGHEventsConfig);\nvar UIManagerConstants = (_UIManagerAny$getView = (_UIManagerAny$getView2 = UIManagerAny.getViewManagerConfig) === null || _UIManagerAny$getView2 === void 0 ? void 0 : _UIManagerAny$getView2.call(UIManagerAny, 'getConstants')) !== null && _UIManagerAny$getView !== void 0 ? _UIManagerAny$getView : (_UIManagerAny$getCons = UIManagerAny.getConstants) === null || _UIManagerAny$getCons === void 0 ? void 0 : _UIManagerAny$getCons.call(UIManagerAny);\nif (UIManagerConstants) {\n UIManagerConstants.genericDirectEventTypes = _objectSpread(_objectSpread({}, UIManagerConstants.genericDirectEventTypes), customGHEventsConfig);\n}\nvar _UIManagerAny$setJSRe = UIManagerAny.setJSResponder,\n oldSetJSResponder = _UIManagerAny$setJSRe === void 0 ? function () {} : _UIManagerAny$setJSRe,\n _UIManagerAny$clearJS = UIManagerAny.clearJSResponder,\n oldClearJSResponder = _UIManagerAny$clearJS === void 0 ? function () {} : _UIManagerAny$clearJS;\nUIManagerAny.setJSResponder = function (tag, blockNativeResponder) {\n RNGestureHandlerModule.handleSetJSResponder(tag, blockNativeResponder);\n oldSetJSResponder(tag, blockNativeResponder);\n};\nUIManagerAny.clearJSResponder = function () {\n RNGestureHandlerModule.handleClearJSResponder();\n oldClearJSResponder();\n};\nvar allowTouches = true;\nvar DEV_ON_ANDROID = __DEV__ && Platform.OS === 'android';\nif (DEV_ON_ANDROID) {\n DeviceEventEmitter.addListener('toggleElementInspector', function () {\n allowTouches = !allowTouches;\n });\n}\nfunction hasUnresolvedRefs(props) {\n var extract = function extract(refs) {\n if (!Array.isArray(refs)) {\n return refs && refs.current === null;\n }\n return refs.some(function (r) {\n return r && r.current === null;\n });\n };\n return extract(props['simultaneousHandlers']) || extract(props['waitFor']);\n}\nvar stateToPropMappings = (_stateToPropMappings = {}, _defineProperty2(_stateToPropMappings, State.UNDETERMINED, undefined), _defineProperty2(_stateToPropMappings, State.BEGAN, 'onBegan'), _defineProperty2(_stateToPropMappings, State.FAILED, 'onFailed'), _defineProperty2(_stateToPropMappings, State.CANCELLED, 'onCancelled'), _defineProperty2(_stateToPropMappings, State.ACTIVE, 'onActivated'), _defineProperty2(_stateToPropMappings, State.END, 'onEnded'), _stateToPropMappings);\nvar UNRESOLVED_REFS_RETRY_LIMIT = 1;\nexport default function createHandler(_ref) {\n var name = _ref.name,\n _ref$allowedProps = _ref.allowedProps,\n allowedProps = _ref$allowedProps === void 0 ? [] : _ref$allowedProps,\n _ref$config = _ref.config,\n config = _ref$config === void 0 ? {} : _ref$config,\n transformProps = _ref.transformProps,\n _ref$customNativeProp = _ref.customNativeProps,\n customNativeProps = _ref$customNativeProp === void 0 ? [] : _ref$customNativeProp;\n var Handler = function (_React$Component) {\n _inherits(Handler, _React$Component);\n var _super = _createSuper(Handler);\n function Handler(props) {\n var _this;\n _classCallCheck(this, Handler);\n _this = _super.call(this, props);\n _defineProperty(_assertThisInitialized(_this), \"handlerTag\", void 0);\n _defineProperty(_assertThisInitialized(_this), \"config\", void 0);\n _defineProperty(_assertThisInitialized(_this), \"propsRef\", void 0);\n _defineProperty(_assertThisInitialized(_this), \"viewNode\", void 0);\n _defineProperty(_assertThisInitialized(_this), \"viewTag\", void 0);\n _defineProperty(_assertThisInitialized(_this), \"updateEnqueued\", null);\n _defineProperty(_assertThisInitialized(_this), \"inspectorToggleListener\", void 0);\n _defineProperty(_assertThisInitialized(_this), \"onGestureHandlerEvent\", function (event) {\n if (event.nativeEvent.handlerTag === _this.handlerTag) {\n if (typeof _this.props.onGestureEvent === 'function') {\n var _this$props$onGesture, _this$props;\n (_this$props$onGesture = (_this$props = _this.props).onGestureEvent) === null || _this$props$onGesture === void 0 ? void 0 : _this$props$onGesture.call(_this$props, event);\n }\n } else {\n var _this$props$onGesture2, _this$props2;\n (_this$props$onGesture2 = (_this$props2 = _this.props).onGestureHandlerEvent) === null || _this$props$onGesture2 === void 0 ? void 0 : _this$props$onGesture2.call(_this$props2, event);\n }\n });\n _defineProperty(_assertThisInitialized(_this), \"onGestureHandlerStateChange\", function (event) {\n if (event.nativeEvent.handlerTag === _this.handlerTag) {\n if (typeof _this.props.onHandlerStateChange === 'function') {\n var _this$props$onHandler, _this$props3;\n (_this$props$onHandler = (_this$props3 = _this.props).onHandlerStateChange) === null || _this$props$onHandler === void 0 ? void 0 : _this$props$onHandler.call(_this$props3, event);\n }\n var state = event.nativeEvent.state;\n var stateEventName = stateToPropMappings[state];\n var eventHandler = stateEventName && _this.props[stateEventName];\n if (eventHandler && typeof eventHandler === 'function') {\n eventHandler(event);\n }\n } else {\n var _this$props$onGesture3, _this$props4;\n (_this$props$onGesture3 = (_this$props4 = _this.props).onGestureHandlerStateChange) === null || _this$props$onGesture3 === void 0 ? void 0 : _this$props$onGesture3.call(_this$props4, event);\n }\n });\n _defineProperty(_assertThisInitialized(_this), \"refHandler\", function (node) {\n _this.viewNode = node;\n var child = React.Children.only(_this.props.children);\n var ref = child.ref;\n if (ref !== null) {\n if (typeof ref === 'function') {\n ref(node);\n } else {\n ref.current = node;\n }\n }\n });\n _defineProperty(_assertThisInitialized(_this), \"createGestureHandler\", function (newConfig) {\n _this.config = newConfig;\n RNGestureHandlerModule.createGestureHandler(name, _this.handlerTag, newConfig);\n });\n _defineProperty(_assertThisInitialized(_this), \"attachGestureHandler\", function (newViewTag) {\n _this.viewTag = newViewTag;\n if (Platform.OS === 'web') {\n RNGestureHandlerModule.attachGestureHandler(_this.handlerTag, newViewTag, ActionType.JS_FUNCTION_OLD_API, _this.propsRef);\n } else {\n registerOldGestureHandler(_this.handlerTag, {\n onGestureEvent: _this.onGestureHandlerEvent,\n onGestureStateChange: _this.onGestureHandlerStateChange\n });\n var actionType = function () {\n var _this$props5, _this$props6;\n if ((_this$props5 = _this.props) !== null && _this$props5 !== void 0 && _this$props5.onGestureEvent && 'current' in _this.props.onGestureEvent) {\n return ActionType.REANIMATED_WORKLET;\n } else if ((_this$props6 = _this.props) !== null && _this$props6 !== void 0 && _this$props6.onGestureEvent && '__isNative' in _this.props.onGestureEvent) {\n return ActionType.NATIVE_ANIMATED_EVENT;\n } else {\n return ActionType.JS_FUNCTION_OLD_API;\n }\n }();\n RNGestureHandlerModule.attachGestureHandler(_this.handlerTag, newViewTag, actionType);\n }\n scheduleFlushOperations();\n });\n _defineProperty(_assertThisInitialized(_this), \"updateGestureHandler\", function (newConfig) {\n _this.config = newConfig;\n RNGestureHandlerModule.updateGestureHandler(_this.handlerTag, newConfig);\n scheduleFlushOperations();\n });\n _this.handlerTag = getNextHandlerTag();\n _this.config = {};\n _this.propsRef = React.createRef();\n _this.state = {\n allowTouches: allowTouches\n };\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 return _this;\n }\n _createClass(Handler, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n var _this2 = this;\n var props = this.props;\n if (DEV_ON_ANDROID) {\n this.inspectorToggleListener = DeviceEventEmitter.addListener('toggleElementInspector', function () {\n _this2.setState(function (_) {\n return {\n allowTouches: allowTouches\n };\n });\n _this2.update(UNRESOLVED_REFS_RETRY_LIMIT);\n });\n }\n if (hasUnresolvedRefs(props)) {\n this.updateEnqueued = setImmediate(function () {\n _this2.updateEnqueued = null;\n _this2.update(UNRESOLVED_REFS_RETRY_LIMIT);\n });\n }\n this.createGestureHandler(filterConfig(transformProps ? transformProps(this.props) : this.props, [].concat(_toConsumableArray(allowedProps), _toConsumableArray(customNativeProps)), config));\n this.attachGestureHandler(findNodeHandle(this.viewNode));\n }\n }, {\n key: \"componentDidUpdate\",\n value: function componentDidUpdate() {\n var viewTag = findNodeHandle(this.viewNode);\n if (this.viewTag !== viewTag) {\n this.attachGestureHandler(viewTag);\n }\n this.update(UNRESOLVED_REFS_RETRY_LIMIT);\n }\n }, {\n key: \"componentWillUnmount\",\n value: function componentWillUnmount() {\n var _this$inspectorToggle;\n (_this$inspectorToggle = this.inspectorToggleListener) === null || _this$inspectorToggle === void 0 ? void 0 : _this$inspectorToggle.remove();\n RNGestureHandlerModule.dropGestureHandler(this.handlerTag);\n scheduleFlushOperations();\n if (this.updateEnqueued) {\n clearImmediate(this.updateEnqueued);\n }\n var handlerID = this.props.id;\n if (handlerID) {\n delete handlerIDToTag[handlerID];\n }\n }\n }, {\n key: \"update\",\n value: function update(remainingTries) {\n var _this3 = this;\n var props = this.props;\n if (hasUnresolvedRefs(props) && remainingTries > 0) {\n this.updateEnqueued = setImmediate(function () {\n _this3.updateEnqueued = null;\n _this3.update(remainingTries - 1);\n });\n } else {\n var newConfig = filterConfig(transformProps ? transformProps(this.props) : this.props, [].concat(_toConsumableArray(allowedProps), _toConsumableArray(customNativeProps)), config);\n if (!deepEqual(this.config, newConfig)) {\n this.updateGestureHandler(newConfig);\n }\n }\n }\n }, {\n key: \"setNativeProps\",\n value: function setNativeProps(updates) {\n var mergedProps = _objectSpread(_objectSpread({}, this.props), updates);\n var newConfig = filterConfig(transformProps ? transformProps(mergedProps) : mergedProps, [].concat(_toConsumableArray(allowedProps), _toConsumableArray(customNativeProps)), config);\n this.updateGestureHandler(newConfig);\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this$props$testID;\n var gestureEventHandler = this.onGestureHandlerEvent;\n var _this$props7 = this.props,\n onGestureEvent = _this$props7.onGestureEvent,\n onGestureHandlerEvent = _this$props7.onGestureHandlerEvent;\n if (onGestureEvent && typeof onGestureEvent !== 'function') {\n if (onGestureHandlerEvent) {\n throw new Error('Nesting touch handlers with native animated driver is not supported yet');\n }\n gestureEventHandler = onGestureEvent;\n } else {\n if (onGestureHandlerEvent && typeof onGestureHandlerEvent !== 'function') {\n throw new Error('Nesting touch handlers with native animated driver is not supported yet');\n }\n }\n var gestureStateEventHandler = this.onGestureHandlerStateChange;\n var _this$props8 = this.props,\n onHandlerStateChange = _this$props8.onHandlerStateChange,\n onGestureHandlerStateChange = _this$props8.onGestureHandlerStateChange;\n if (onHandlerStateChange && typeof onHandlerStateChange !== 'function') {\n if (onGestureHandlerStateChange) {\n throw new Error('Nesting touch handlers with native animated driver is not supported yet');\n }\n gestureStateEventHandler = onHandlerStateChange;\n } else {\n if (onGestureHandlerStateChange && typeof onGestureHandlerStateChange !== 'function') {\n throw new Error('Nesting touch handlers with native animated driver is not supported yet');\n }\n }\n var events = {\n onGestureHandlerEvent: this.state.allowTouches ? gestureEventHandler : undefined,\n onGestureHandlerStateChange: this.state.allowTouches ? gestureStateEventHandler : undefined\n };\n this.propsRef.current = events;\n var child = null;\n try {\n child = React.Children.only(this.props.children);\n } catch (e) {\n throw new Error(tagMessage(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 var grandChildren = child.props.children;\n if (__DEV__ && child.type && (child.type === 'RNGestureHandlerButton' || child.type.name === 'View' || child.type.displayName === 'View')) {\n grandChildren = React.Children.toArray(grandChildren);\n grandChildren.push(React.createElement(PressabilityDebugView, {\n key: \"pressabilityDebugView\",\n color: \"mediumspringgreen\",\n hitSlop: child.props.hitSlop\n }));\n }\n return React.cloneElement(child, _objectSpread(_objectSpread({\n ref: this.refHandler,\n collapsable: false\n }, isJestEnv() ? {\n handlerType: name,\n handlerTag: this.handlerTag\n } : {}), {}, {\n testID: (_this$props$testID = this.props.testID) !== null && _this$props$testID !== void 0 ? _this$props$testID : child.props.testID\n }, events), grandChildren);\n }\n }]);\n return Handler;\n }(React.Component);\n _defineProperty(Handler, \"displayName\", name);\n return Handler;\n}","map":{"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAAA;AAAA;AAAA;AAQA,OAAOC,SAAP,MAAsB,gBAAtB;AACA,OAAOC,sBAAP;AAEA,SAASC,KAAT;AACA,SACEC,cADF,EAEEC,iBAFF,EAGEC,yBAHF;AAMA,SAEEC,YAFF,EAKEC,cALF,EAMEC,uBANF;AASA,SAASC,QAAT,EAAmBC,SAAnB,EAA8BC,UAA9B;AACA,SAASC,UAAT;AACA,SAASC,qBAAT;AAEA,IAAMC,YAAY,GAAGC,SAArB;AAEA,IAAMC,iCAAiC,GAAG;EACxCC,wBAAwB,EAAE;IAAEC,gBAAgB,EAAE;EAApB,CADc;EAExCC,8BAA8B,EAAE;IAC9BD,gBAAgB,EAAE;EADY;AAFQ,CAA1C;AAOA,IAAME,o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VmB5H,KAAK,CAACyI,SAA5B;EAJ0ElE,gBAIpEF,OAJoE,iBAQnDL,IARmD;EAoW1E,OAAOK,OAAP;AACD","names":["React","deepEqual","RNGestureHandlerModule","State","handlerIDToTag","getNextHandlerTag","registerOldGestureHandler","filterConfig","findNodeHandle","scheduleFlushOperations","isFabric","isJestEnv","tagMessage","ActionType","PressabilityDebugView","UIManagerAny","UIManager","customGHEventsConfigFabricAndroid","topOnGestureHandlerEvent","registrationName","topOnGestureHandlerStateChange","customGHEventsConfig","onGestureHandlerEvent","onGestureHandlerStateChange","Platform","OS","genericDirectEventTypes","UIManagerConstants","getViewManagerConfig","_UIManagerAny$getView2","getConstants","_UIManagerAny$getCons","setJSResponder","oldSetJSResponder","clearJSResponder","oldClearJSResponder","tag","blockNativeResponder","handleSetJSResponder","handleClearJSResponder","allowTouches","DEV_ON_ANDROID","__DEV__","DeviceEventEmitter","addListener","hasUnresolvedRefs","props","extract","refs","Array","isArray","current","some","r","stateToPropMappings","UNDETERMINED","undefined","BEGAN","FAILED","CANCELLED","ACTIVE","END","UNRESOLVED_REFS_RETRY_LIMIT","createHandler","name","allowedProps","config","transformProps","customNativeProps","Handler","constructor","_defineProperty","event","nativeEvent","handlerTag","onGestureEvent","onHandlerStateChange","state","stateEventName","eventHandler","node","viewNode","child","Children","only","children","ref","newConfig","createGestureHandler","newViewTag","viewTag","attachGestureHandler","JS_FUNCTION_OLD_API","propsRef","onGestureStateChange","actionType","REANIMATED_WORKLET","NATIVE_ANIMATED_EVENT","updateGestureHandler","createRef","id","Error","componentDidMount","inspectorToggleListener","setState","_","update","updateEnqueued","setImmediate","componentDidUpdate","componentWillUnmount","remove","dropGestureHandler","clearImmediate","handlerID","remainingTries","setNativeProps","updates","mergedProps","render","gestureEventHandler","gestureStateEventHandler","events","e","grandChildren","type","displayName","toArray","push","key","color","hitSlop","cloneElement","refHandler","collapsable","handlerType","testID","Component"],"sources":["/Users/mathildejean/Documents/BUT/LaSuperMeteo/LaSuperMeteo/iut-expo-starter/node_modules/react-native-gesture-handler/lib/module/handlers/createHandler.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n Platform,\n UIManager,\n DeviceEventEmitter,\n EmitterSubscription,\n} from 'react-native';\n// @ts-ignore - it isn't typed by TS & don't have definitelyTyped types\nimport deepEqual from 'lodash/isEqual';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\nimport type RNGestureHandlerModuleWeb from '../RNGestureHandlerModule.web';\nimport { State } from '../State';\nimport {\n handlerIDToTag,\n getNextHandlerTag,\n registerOldGestureHandler,\n} from './handlersRegistry';\n\nimport {\n BaseGestureHandlerProps,\n filterConfig,\n GestureEvent,\n HandlerStateChangeEvent,\n findNodeHandle,\n scheduleFlushOperations,\n} from './gestureHandlerCommon';\nimport { ValueOf } from '../typeUtils';\nimport { isFabric, isJestEnv, tagMessage } from '../utils';\nimport { ActionType } from '../ActionType';\nimport { PressabilityDebugView } from './PressabilityDebugView';\n\nconst UIManagerAny = UIManager as any;\n\nconst customGHEventsConfigFabricAndroid = {\n topOnGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n topOnGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n};\n\nconst customGHEventsConfig = {\n onGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n onGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n\n // When using React Native Gesture Handler for Animated.event with useNativeDriver: true\n // on Android with Fabric enabled, the native part still sends the native events to JS\n // but prefixed with \"top\". We cannot simply rename the events above so they are prefixed\n // with \"top\" instead of \"on\" because in such case Animated.events would not be registered.\n // That's why we need to register another pair of event names.\n // The incoming events will be queued but never handled.\n // Without this piece of code below, you'll get the following JS error:\n // Unsupported top level event type \"topOnGestureHandlerEvent\" dispatched\n ...(isFabric() &&\n Platform.OS === 'android' &&\n customGHEventsConfigFabricAndroid),\n};\n\n// Add gesture specific events to genericDirectEventTypes object exported from UIManager\n// native module.\n// Once new event types are registered with react it is possible to dispatch these\n// events to all kind of native views.\nUIManagerAny.genericDirectEventTypes = {\n ...UIManagerAny.genericDirectEventTypes,\n ...customGHEventsConfig,\n};\n// In newer versions of RN the `genericDirectEventTypes` is located in the object\n// returned by UIManager.getViewManagerConfig('getConstants') or in older RN UIManager.getConstants(), we need to add it there as well to make\n// it compatible with RN 61+\nconst UIManagerConstants =\n UIManagerAny.getViewManagerConfig?.('getConstants') ??\n UIManagerAny.getConstants?.();\n\nif (UIManagerConstants) {\n UIManagerConstants.genericDirectEventTypes = {\n ...UIManagerConstants.genericDirectEventTypes,\n ...customGHEventsConfig,\n };\n}\n\n// Wrap JS responder calls and notify gesture handler manager\nconst {\n setJSResponder: oldSetJSResponder = () => {\n //no operation\n },\n clearJSResponder: oldClearJSResponder = () => {\n //no operation\n },\n} = UIManagerAny;\nUIManagerAny.setJSResponder = (tag: number, blockNativeResponder: boolean) => {\n RNGestureHandlerModule.handleSetJSResponder(tag, blockNativeResponder);\n oldSetJSResponder(tag, blockNativeResponder);\n};\nUIManagerAny.clearJSResponder = () => {\n RNGestureHandlerModule.handleClearJSResponder();\n oldClearJSResponder();\n};\n\nlet allowTouches = true;\nconst DEV_ON_ANDROID = __DEV__ && Platform.OS === 'android';\n// Toggled inspector blocks touch events in order to allow inspecting on Android\n// This needs to be a global variable in order to set initial state for `allowTouches` property in Handler component\nif (DEV_ON_ANDROID) {\n DeviceEventEmitter.addListener('toggleElementInspector', () => {\n allowTouches = !allowTouches;\n });\n}\n\ntype HandlerProps<T extends Record<string, unknown>> = Readonly<\n React.PropsWithChildren<BaseGestureHandlerProps<T>>\n>;\nfunction hasUnresolvedRefs<T extends Record<string, unknown>>(\n props: HandlerProps<T>\n) {\n // TODO(TS) - add type for extract arg\n const extract = (refs: any | any[]) => {\n if (!Array.isArray(refs)) {\n return refs && refs.current === null;\n }\n return refs.some((r) => r && r.current === null);\n };\n return extract(props['simultaneousHandlers']) || extract(props['waitFor']);\n}\n\nconst stateToPropMappings = {\n [State.UNDETERMINED]: undefined,\n [State.BEGAN]: 'onBegan',\n [State.FAILED]: 'onFailed',\n [State.CANCELLED]: 'onCancelled',\n [State.ACTIVE]: 'onActivated',\n [State.END]: 'onEnded',\n} as const;\n\ntype CreateHandlerArgs<HandlerPropsT extends Record<string, unknown>> =\n Readonly<{\n name: string;\n allowedProps: Readonly<Extract<keyof HandlerPropsT, string>[]>;\n config: Readonly<Record<string, unknown>>;\n transformProps?: (props: HandlerPropsT) => HandlerPropsT;\n customNativeProps?: Readonly<string[]>;\n }>;\n\n// TODO(TS) fix event types\ntype InternalEventHandlers = {\n onGestureHandlerEvent?: (event: any) => void;\n onGestureHandlerStateChange?: (event: any) => void;\n};\n\nconst UNRESOLVED_REFS_RETRY_LIMIT = 1;\n\n// TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.\nexport default function createHandler<\n T extends BaseGestureHandlerProps<U>,\n U extends Record<string, unknown>\n>({\n name,\n allowedProps = [],\n config = {},\n transformProps,\n customNativeProps = [],\n}: CreateHandlerArgs<T>): React.ComponentType<T & React.RefAttributes<any>> {\n interface HandlerState {\n allowTouches: boolean;\n }\n class Handler extends React.Component<\n T & InternalEventHandlers,\n HandlerState\n > {\n static displayName = name;\n\n private handlerTag: number;\n private config: Record<string, unknown>;\n private propsRef: React.MutableRefObject<unknown>;\n private viewNode: any;\n private viewTag?: number;\n private updateEnqueued: ReturnType<typeof setImmediate> | null = null;\n private inspectorToggleListener?: EmitterSubscription;\n\n constructor(props: T & InternalEventHandlers) {\n super(props);\n this.handlerTag = getNextHandlerTag();\n this.config = {};\n this.propsRef = React.createRef();\n this.state = { allowTouches };\n if (props.id) {\n if (handlerIDToTag[props.id] !== undefined) {\n throw new Error(`Handler with ID \"${props.id}\" already registered`);\n }\n handlerIDToTag[props.id] = this.handlerTag;\n }\n }\n\n componentDidMount() {\n const props: HandlerProps<U> = this.props;\n\n if (DEV_ON_ANDROID) {\n this.inspectorToggleListener = DeviceEventEmitter.addListener(\n 'toggleElementInspector',\n () => {\n this.setState((_) => ({ allowTouches }));\n this.update(UNRESOLVED_REFS_RETRY_LIMIT);\n }\n );\n }\n if (hasUnresolvedRefs(props)) {\n // If there are unresolved refs (e.g. \".current\" has not yet been set)\n // passed as `simultaneousHandlers` or `waitFor`, we enqueue a call to\n // _update method that will try to update native handler props using\n // setImmediate. This makes it so update() function gets called after all\n // react components are mounted and we expect the missing ref object to\n // be resolved by then.\n this.updateEnqueued = setImmediate(() => {\n this.updateEnqueued = null;\n this.update(UNRESOLVED_REFS_RETRY_LIMIT);\n });\n }\n\n this.createGestureHandler(\n filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n )\n );\n\n this.attachGestureHandler(findNodeHandle(this.viewNode) as number); // TODO(TS) - check if this can be null\n }\n\n componentDidUpdate() {\n const viewTag = findNodeHandle(this.viewNode);\n if (this.viewTag !== viewTag) {\n this.attachGestureHandler(viewTag as number); // TODO(TS) - check interaction between _viewTag & findNodeHandle\n }\n this.update(UNRESOLVED_REFS_RETRY_LIMIT);\n }\n\n componentWillUnmount() {\n this.inspectorToggleListener?.remove();\n RNGestureHandlerModule.dropGestureHandler(this.handlerTag);\n scheduleFlushOperations();\n if (this.updateEnqueued) {\n clearImmediate(this.updateEnqueued);\n }\n // We can't use this.props.id directly due to TS generic type narrowing bug, see https://github.com/microsoft/TypeScript/issues/13995 for more context\n const handlerID: string | undefined = this.props.id;\n if (handlerID) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete handlerIDToTag[handlerID];\n }\n }\n\n private onGestureHandlerEvent = (event: GestureEvent<U>) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n if (typeof this.props.onGestureEvent === 'function') {\n this.props.onGestureEvent?.(event);\n }\n } else {\n this.props.onGestureHandlerEvent?.(event);\n }\n };\n\n // TODO(TS) - make sure this is right type for event\n private onGestureHandlerStateChange = (\n event: HandlerStateChangeEvent<U>\n ) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n if (typeof this.props.onHandlerStateChange === 'function') {\n this.props.onHandlerStateChange?.(event);\n }\n\n const state: ValueOf<typeof State> = event.nativeEvent.state;\n const stateEventName = stateToPropMappings[state];\n const eventHandler = stateEventName && this.props[stateEventName];\n if (eventHandler && typeof eventHandler === 'function') {\n eventHandler(event);\n }\n } else {\n this.props.onGestureHandlerStateChange?.(event);\n }\n };\n\n private refHandler = (node: any) => {\n this.viewNode = node;\n\n const child = React.Children.only(this.props.children);\n // TODO(TS) fix ref type\n const { ref }: any = child;\n if (ref !== null) {\n if (typeof ref === 'function') {\n ref(node);\n } else {\n ref.current = node;\n }\n }\n };\n\n private createGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.createGestureHandler(\n name,\n this.handlerTag,\n newConfig\n );\n };\n\n private attachGestureHandler = (newViewTag: number) => {\n this.viewTag = newViewTag;\n\n if (Platform.OS === 'web') {\n // typecast due to dynamic resolution, attachGestureHandler should have web version signature in this branch\n (\n RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler\n )(\n this.handlerTag,\n newViewTag,\n ActionType.JS_FUNCTION_OLD_API, // ignored on web\n this.propsRef\n );\n } else {\n registerOldGestureHandler(this.handlerTag, {\n onGestureEvent: this.onGestureHandlerEvent,\n onGestureStateChange: this.onGestureHandlerStateChange,\n });\n\n const actionType = (() => {\n if (\n this.props?.onGestureEvent &&\n 'current' in this.props.onGestureEvent\n ) {\n // Reanimated worklet\n return ActionType.REANIMATED_WORKLET;\n } else if (\n this.props?.onGestureEvent &&\n '__isNative' in this.props.onGestureEvent\n ) {\n // Animated.event with useNativeDriver: true\n return ActionType.NATIVE_ANIMATED_EVENT;\n } else {\n // JS callback or Animated.event with useNativeDriver: false\n return ActionType.JS_FUNCTION_OLD_API;\n }\n })();\n\n RNGestureHandlerModule.attachGestureHandler(\n this.handlerTag,\n newViewTag,\n actionType\n );\n }\n\n scheduleFlushOperations();\n };\n\n private updateGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.updateGestureHandler(this.handlerTag, newConfig);\n scheduleFlushOperations();\n };\n\n private update(remainingTries: number) {\n const props: HandlerProps<U> = this.props;\n\n // When ref is set via a function i.e. `ref={(r) => refObject.current = r}` instead of\n // `ref={refObject}` it's possible that it won't be resolved in time. Seems like trying\n // again is easy enough fix.\n if (hasUnresolvedRefs(props) && remainingTries > 0) {\n this.updateEnqueued = setImmediate(() => {\n this.updateEnqueued = null;\n this.update(remainingTries - 1);\n });\n } else {\n const newConfig = filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n );\n if (!deepEqual(this.config, newConfig)) {\n this.updateGestureHandler(newConfig);\n }\n }\n }\n\n setNativeProps(updates: any) {\n const mergedProps = { ...this.props, ...updates };\n const newConfig = filterConfig(\n transformProps ? transformProps(mergedProps) : mergedProps,\n [...allowedProps, ...customNativeProps],\n config\n );\n this.updateGestureHandler(newConfig);\n }\n\n render() {\n let gestureEventHandler = this.onGestureHandlerEvent;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureEventHandlers = {\n onGestureEvent?: BaseGestureHandlerProps<U>['onGestureEvent'];\n onGestureHandlerEvent?: InternalEventHandlers['onGestureHandlerEvent'];\n };\n const { onGestureEvent, onGestureHandlerEvent }: OnGestureEventHandlers =\n this.props;\n if (onGestureEvent && typeof onGestureEvent !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerEvent) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureEventHandler = onGestureEvent;\n } else {\n if (\n onGestureHandlerEvent &&\n typeof onGestureHandlerEvent !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n\n let gestureStateEventHandler = this.onGestureHandlerStateChange;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureStateChangeHandlers = {\n onHandlerStateChange?: BaseGestureHandlerProps<U>['onHandlerStateChange'];\n onGestureHandlerStateChange?: InternalEventHandlers['onGestureHandlerStateChange'];\n };\n const {\n onHandlerStateChange,\n onGestureHandlerStateChange,\n }: OnGestureStateChangeHandlers = this.props;\n if (onHandlerStateChange && typeof onHandlerStateChange !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerStateChange) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureStateEventHandler = onHandlerStateChange;\n } else {\n if (\n onGestureHandlerStateChange &&\n typeof onGestureHandlerStateChange !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n const events = {\n onGestureHandlerEvent: this.state.allowTouches\n ? gestureEventHandler\n : undefined,\n onGestureHandlerStateChange: this.state.allowTouches\n ? gestureStateEventHandler\n : undefined,\n };\n\n this.propsRef.current = events;\n\n let child: any = null;\n try {\n child = React.Children.only(this.props.children);\n } catch (e) {\n throw new Error(\n tagMessage(\n `${name} got more than one view as a child. If you want the gesture to work on multiple views, wrap them with a common parent and attach the gesture to that view.`\n )\n );\n }\n\n let grandChildren = child.props.children;\n if (\n __DEV__ &&\n child.type &&\n (child.type === 'RNGestureHandlerButton' ||\n child.type.name === 'View' ||\n child.type.displayName === 'View')\n ) {\n grandChildren = React.Children.toArray(grandChildren);\n grandChildren.push(\n <PressabilityDebugView\n key=\"pressabilityDebugView\"\n color=\"mediumspringgreen\"\n hitSlop={child.props.hitSlop}\n />\n );\n }\n\n return React.cloneElement(\n child,\n {\n ref: this.refHandler,\n collapsable: false,\n ...(isJestEnv()\n ? {\n handlerType: name,\n handlerTag: this.handlerTag,\n }\n : {}),\n testID: this.props.testID ?? child.props.testID,\n ...events,\n },\n grandChildren\n );\n }\n }\n return Handler;\n}\n"]},"metadata":{},"sourceType":"module","externalDependencies":[]}