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
13 KiB
1 line
13 KiB
{"ast":null,"code":"import _defineProperty2 from \"@babel/runtime/helpers/defineProperty\";\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 _toConsumableArray from \"@babel/runtime/helpers/toConsumableArray\";\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; }\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 _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 { BaseGesture, Gesture } from \"./gesture\";\nfunction extendRelation(currentRelation, extendWith) {\n if (currentRelation === undefined) {\n return _toConsumableArray(extendWith);\n } else {\n return [].concat(_toConsumableArray(currentRelation), _toConsumableArray(extendWith));\n }\n}\nexport var ComposedGesture = function (_Gesture) {\n _inherits(ComposedGesture, _Gesture);\n var _super = _createSuper(ComposedGesture);\n function ComposedGesture() {\n var _this;\n _classCallCheck(this, ComposedGesture);\n _this = _super.call(this);\n _defineProperty(_assertThisInitialized(_this), \"gestures\", []);\n _defineProperty(_assertThisInitialized(_this), \"simultaneousGestures\", []);\n _defineProperty(_assertThisInitialized(_this), \"requireGesturesToFail\", []);\n for (var _len = arguments.length, gestures = new Array(_len), _key = 0; _key < _len; _key++) {\n gestures[_key] = arguments[_key];\n }\n _this.gestures = gestures;\n return _this;\n }\n _createClass(ComposedGesture, [{\n key: \"prepareSingleGesture\",\n value: function prepareSingleGesture(gesture, simultaneousGestures, requireGesturesToFail) {\n if (gesture instanceof BaseGesture) {\n var newConfig = _objectSpread({}, gesture.config);\n newConfig.simultaneousWith = extendRelation(newConfig.simultaneousWith, simultaneousGestures);\n newConfig.requireToFail = extendRelation(newConfig.requireToFail, requireGesturesToFail);\n gesture.config = newConfig;\n } else if (gesture instanceof ComposedGesture) {\n gesture.simultaneousGestures = simultaneousGestures;\n gesture.requireGesturesToFail = requireGesturesToFail;\n gesture.prepare();\n }\n }\n }, {\n key: \"prepare\",\n value: function prepare() {\n for (var gesture of this.gestures) {\n this.prepareSingleGesture(gesture, this.simultaneousGestures, this.requireGesturesToFail);\n }\n }\n }, {\n key: \"initialize\",\n value: function initialize() {\n for (var gesture of this.gestures) {\n gesture.initialize();\n }\n }\n }, {\n key: \"toGestureArray\",\n value: function toGestureArray() {\n return this.gestures.flatMap(function (gesture) {\n return gesture.toGestureArray();\n });\n }\n }]);\n return ComposedGesture;\n}(Gesture);\nexport var SimultaneousGesture = function (_ComposedGesture) {\n _inherits(SimultaneousGesture, _ComposedGesture);\n var _super2 = _createSuper(SimultaneousGesture);\n function SimultaneousGesture() {\n _classCallCheck(this, SimultaneousGesture);\n return _super2.apply(this, arguments);\n }\n _createClass(SimultaneousGesture, [{\n key: \"prepare\",\n value: function prepare() {\n var _this2 = this;\n var simultaneousArrays = this.gestures.map(function (gesture) {\n return _this2.gestures.filter(function (x) {\n return x !== gesture;\n }).flatMap(function (x) {\n return x.toGestureArray();\n });\n });\n for (var i = 0; i < this.gestures.length; i++) {\n this.prepareSingleGesture(this.gestures[i], simultaneousArrays[i], this.requireGesturesToFail);\n }\n }\n }]);\n return SimultaneousGesture;\n}(ComposedGesture);\nexport var ExclusiveGesture = function (_ComposedGesture2) {\n _inherits(ExclusiveGesture, _ComposedGesture2);\n var _super3 = _createSuper(ExclusiveGesture);\n function ExclusiveGesture() {\n _classCallCheck(this, ExclusiveGesture);\n return _super3.apply(this, arguments);\n }\n _createClass(ExclusiveGesture, [{\n key: \"prepare\",\n value: function prepare() {\n var gestureArrays = this.gestures.map(function (gesture) {\n return gesture.toGestureArray();\n });\n var requireToFail = [];\n for (var i = 0; i < this.gestures.length; i++) {\n this.prepareSingleGesture(this.gestures[i], this.simultaneousGestures, this.requireGesturesToFail.concat(requireToFail));\n requireToFail = requireToFail.concat(gestureArrays[i]);\n }\n }\n }]);\n return ExclusiveGesture;\n}(ComposedGesture);","map":{"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,WAAT,EAAsBC,OAAtB;AAEA,SAASC,cAAT,CACEC,eADF,EAEEC,UAFF,EAGE;EACA,IAAID,eAAe,KAAKE,SAAxB,EAAmC;IACjC,0BAAWD,UAAJ;EACR,CAFD,MAEO;IACL,oCAAWD,eAAJ,sBAAwBC,UAAxB;EACR;AACF;AAED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;EAAA;AAAA,EApBmCrB,eAA/B","names":["BaseGesture","Gesture","extendRelation","currentRelation","extendWith","undefined","ComposedGesture","constructor","_defineProperty","gestures","prepareSingleGesture","gesture","simultaneousGestures","requireGesturesToFail","newConfig","config","simultaneousWith","requireToFail","prepare","initialize","toGestureArray","flatMap","SimultaneousGesture","simultaneousArrays","map","filter","x","i","length","ExclusiveGesture","gestureArrays","concat"],"sources":["/Users/mathildejean/Documents/BUT/LaSuperMeteo/LaSuperMeteo/iut-expo-starter/node_modules/react-native-gesture-handler/lib/module/handlers/gestures/gestureComposition.ts"],"sourcesContent":["import { BaseGesture, Gesture, GestureRef, GestureType } from './gesture';\n\nfunction extendRelation(\n currentRelation: GestureRef[] | undefined,\n extendWith: GestureType[]\n) {\n if (currentRelation === undefined) {\n return [...extendWith];\n } else {\n return [...currentRelation, ...extendWith];\n }\n}\n\nexport class ComposedGesture extends Gesture {\n protected gestures: Gesture[] = [];\n protected simultaneousGestures: GestureType[] = [];\n protected requireGesturesToFail: GestureType[] = [];\n\n constructor(...gestures: Gesture[]) {\n super();\n this.gestures = gestures;\n }\n\n protected prepareSingleGesture(\n gesture: Gesture,\n simultaneousGestures: GestureType[],\n requireGesturesToFail: GestureType[]\n ) {\n if (gesture instanceof BaseGesture) {\n const newConfig = { ...gesture.config };\n\n newConfig.simultaneousWith = extendRelation(\n newConfig.simultaneousWith,\n simultaneousGestures\n );\n newConfig.requireToFail = extendRelation(\n newConfig.requireToFail,\n requireGesturesToFail\n );\n\n gesture.config = newConfig;\n } else if (gesture instanceof ComposedGesture) {\n gesture.simultaneousGestures = simultaneousGestures;\n gesture.requireGesturesToFail = requireGesturesToFail;\n gesture.prepare();\n }\n }\n\n prepare() {\n for (const gesture of this.gestures) {\n this.prepareSingleGesture(\n gesture,\n this.simultaneousGestures,\n this.requireGesturesToFail\n );\n }\n }\n\n initialize() {\n for (const gesture of this.gestures) {\n gesture.initialize();\n }\n }\n\n toGestureArray(): GestureType[] {\n return this.gestures.flatMap((gesture) => gesture.toGestureArray());\n }\n}\n\nexport class SimultaneousGesture extends ComposedGesture {\n prepare() {\n // this piece of magic works something like this:\n // for every gesture in the array\n const simultaneousArrays = this.gestures.map((gesture) =>\n // we take the array it's in\n this.gestures\n // and make a copy without it\n .filter((x) => x !== gesture)\n // then we flatmap the result to get list of raw (not composed) gestures\n // this way we don't make the gestures simultaneous with themselves, which is\n // important when the gesture is `ExclusiveGesture` - we don't want to make\n // exclusive gestures simultaneous\n .flatMap((x) => x.toGestureArray())\n );\n\n for (let i = 0; i < this.gestures.length; i++) {\n this.prepareSingleGesture(\n this.gestures[i],\n simultaneousArrays[i],\n this.requireGesturesToFail\n );\n }\n }\n}\n\nexport class ExclusiveGesture extends ComposedGesture {\n prepare() {\n // transforms the array of gestures into array of grouped raw (not composed) gestures\n // i.e. [gesture1, gesture2, ComposedGesture(gesture3, gesture4)] -> [[gesture1], [gesture2], [gesture3, gesture4]]\n const gestureArrays = this.gestures.map((gesture) =>\n gesture.toGestureArray()\n );\n\n let requireToFail: GestureType[] = [];\n\n for (let i = 0; i < this.gestures.length; i++) {\n this.prepareSingleGesture(\n this.gestures[i],\n this.simultaneousGestures,\n this.requireGesturesToFail.concat(requireToFail)\n );\n\n // every group gets to wait for all groups before it\n requireToFail = requireToFail.concat(gestureArrays[i]);\n }\n }\n}\n\nexport type ComposedGestureType = InstanceType<typeof ComposedGesture>;\nexport type RaceGestureType = ComposedGestureType;\nexport type SimultaneousGestureType = InstanceType<typeof SimultaneousGesture>;\nexport type ExclusiveGestureType = InstanceType<typeof ExclusiveGesture>;\n"]},"metadata":{},"sourceType":"module","externalDependencies":[]} |