e9a378e9087997bc942f5aed8ea14cfa.json
15.3 KB
{"ast":null,"code":"'use strict';var _interopRequireDefault=require(\"@babel/runtime/helpers/interopRequireDefault\");Object.defineProperty(exports,\"__esModule\",{value:true});exports.attachNativeEvent=attachNativeEvent;exports.default=exports.AnimatedEvent=void 0;var _AnimatedValue=_interopRequireDefault(require(\"./nodes/AnimatedValue\"));var _NativeAnimatedHelper=_interopRequireDefault(require(\"./NativeAnimatedHelper\"));var _findNodeHandle=_interopRequireDefault(require(\"../../../exports/findNodeHandle\"));var _invariant=_interopRequireDefault(require(\"fbjs/lib/invariant\"));var shouldUseNativeDriver=_NativeAnimatedHelper.default.shouldUseNativeDriver;function attachNativeEvent(viewRef,eventName,argMapping){var eventMappings=[];var traverse=function traverse(value,path){if(value instanceof _AnimatedValue.default){value.__makeNative();eventMappings.push({nativeEventPath:path,animatedValueTag:value.__getNativeTag()});}else if(typeof value==='object'){for(var _key in value){traverse(value[_key],path.concat(_key));}}};(0,_invariant.default)(argMapping[0]&&argMapping[0].nativeEvent,'Native driven events only support animated values contained inside `nativeEvent`.');traverse(argMapping[0].nativeEvent,[]);var viewTag=(0,_findNodeHandle.default)(viewRef);eventMappings.forEach(function(mapping){_NativeAnimatedHelper.default.API.addAnimatedEventToView(viewTag,eventName,mapping);});return{detach:function detach(){eventMappings.forEach(function(mapping){_NativeAnimatedHelper.default.API.removeAnimatedEventFromView(viewTag,eventName,mapping.animatedValueTag);});}};}var AnimatedEvent=function(){function AnimatedEvent(argMapping,config){if(config===void 0){config={};}this._listeners=[];this._argMapping=argMapping;if(config.listener){this.__addListener(config.listener);}this._callListeners=this._callListeners.bind(this);this._attachedEvent=null;this.__isNative=shouldUseNativeDriver(config);if(process.env.NODE_ENV!=='production'){this._validateMapping();}}var _proto=AnimatedEvent.prototype;_proto.__addListener=function __addListener(callback){this._listeners.push(callback);};_proto.__removeListener=function __removeListener(callback){this._listeners=this._listeners.filter(function(listener){return listener!==callback;});};_proto.__attach=function __attach(viewRef,eventName){(0,_invariant.default)(this.__isNative,'Only native driven events need to be attached.');this._attachedEvent=attachNativeEvent(viewRef,eventName,this._argMapping);};_proto.__detach=function __detach(viewTag,eventName){(0,_invariant.default)(this.__isNative,'Only native driven events need to be detached.');this._attachedEvent&&this._attachedEvent.detach();};_proto.__getHandler=function __getHandler(){var _this=this;if(this.__isNative){return this._callListeners;}return function(){for(var _len=arguments.length,args=new Array(_len),_key2=0;_key2<_len;_key2++){args[_key2]=arguments[_key2];}var traverse=function traverse(recMapping,recEvt,key){if(typeof recEvt==='number'&&recMapping instanceof _AnimatedValue.default){recMapping.setValue(recEvt);}else if(typeof recMapping==='object'){for(var mappingKey in recMapping){traverse(recMapping[mappingKey],recEvt[mappingKey],mappingKey);}}};if(!_this.__isNative){_this._argMapping.forEach(function(mapping,idx){traverse(mapping,args[idx],'arg'+idx);});}_this._callListeners.apply(_this,args);};};_proto._callListeners=function _callListeners(){for(var _len2=arguments.length,args=new Array(_len2),_key3=0;_key3<_len2;_key3++){args[_key3]=arguments[_key3];}this._listeners.forEach(function(listener){return listener.apply(void 0,args);});};_proto._validateMapping=function _validateMapping(){var traverse=function traverse(recMapping,recEvt,key){if(typeof recEvt==='number'){(0,_invariant.default)(recMapping instanceof _AnimatedValue.default,'Bad mapping of type '+typeof recMapping+' for key '+key+', event value must map to AnimatedValue');return;}(0,_invariant.default)(typeof recMapping==='object','Bad mapping of type '+typeof recMapping+' for key '+key);(0,_invariant.default)(typeof recEvt==='object','Bad event of type '+typeof recEvt+' for key '+key);for(var mappingKey in recMapping){traverse(recMapping[mappingKey],recEvt[mappingKey],mappingKey);}};};return AnimatedEvent;}();exports.AnimatedEvent=AnimatedEvent;var _default={AnimatedEvent:AnimatedEvent,attachNativeEvent:attachNativeEvent};exports.default=_default;","map":{"version":3,"sources":["C:/Users/bluej/Desktop/2_2/searchGuide/searchGuide/node_modules/react-native-web/dist/vendor/react-native/Animated/AnimatedEvent.js"],"names":["shouldUseNativeDriver","NativeAnimatedHelper","attachNativeEvent","viewRef","eventName","argMapping","eventMappings","traverse","value","path","AnimatedValue","__makeNative","push","nativeEventPath","animatedValueTag","__getNativeTag","_key","concat","nativeEvent","viewTag","forEach","mapping","API","addAnimatedEventToView","detach","removeAnimatedEventFromView","AnimatedEvent","config","_listeners","_argMapping","listener","__addListener","_callListeners","bind","_attachedEvent","__isNative","process","env","NODE_ENV","_validateMapping","_proto","prototype","callback","__removeListener","filter","__attach","__detach","__getHandler","_this","_len","arguments","length","args","Array","_key2","recMapping","recEvt","key","setValue","mappingKey","idx","apply","_len2","_key3"],"mappings":"AASA,a,qOAEA,4EACA,oFACA,uFACA,qEACA,GAAIA,CAAAA,qBAAqB,CAAGC,8BAAqBD,qBAAjD,CAEA,QAASE,CAAAA,iBAAT,CAA2BC,OAA3B,CAAoCC,SAApC,CAA+CC,UAA/C,CAA2D,CAGzD,GAAIC,CAAAA,aAAa,CAAG,EAApB,CAEA,GAAIC,CAAAA,QAAQ,CAAG,QAASA,CAAAA,QAAT,CAAkBC,KAAlB,CAAyBC,IAAzB,CAA+B,CAC5C,GAAID,KAAK,WAAYE,uBAArB,CAAoC,CAClCF,KAAK,CAACG,YAAN,GAEAL,aAAa,CAACM,IAAd,CAAmB,CACjBC,eAAe,CAAEJ,IADA,CAEjBK,gBAAgB,CAAEN,KAAK,CAACO,cAAN,EAFD,CAAnB,EAID,CAPD,IAOO,IAAI,MAAOP,CAAAA,KAAP,GAAiB,QAArB,CAA+B,CACpC,IAAK,GAAIQ,CAAAA,IAAT,GAAiBR,CAAAA,KAAjB,CAAwB,CACtBD,QAAQ,CAACC,KAAK,CAACQ,IAAD,CAAN,CAAcP,IAAI,CAACQ,MAAL,CAAYD,IAAZ,CAAd,CAAR,CACD,CACF,CACF,CAbD,CAeA,uBAAUX,UAAU,CAAC,CAAD,CAAV,EAAiBA,UAAU,CAAC,CAAD,CAAV,CAAca,WAAzC,CAAsD,mFAAtD,EAEAX,QAAQ,CAACF,UAAU,CAAC,CAAD,CAAV,CAAca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AAuBT,IAAvB,CAAP,CACD,CAFD,EAGD,CARD,CAUAZ,MAAM,CAACD,gBAAP,CAA0B,QAASA,CAAAA,gBAAT,EAA4B,CACpD,GAAIhC,CAAAA,QAAQ,CAAG,QAASA,CAAAA,QAAT,CAAkBgD,UAAlB,CAA8BC,MAA9B,CAAsCC,GAAtC,CAA2C,CACxD,GAAI,MAAOD,CAAAA,MAAP,GAAkB,QAAtB,CAAgC,CAC9B,uBAAUD,UAAU,WAAY7C,uBAAhC,CAA+C,uBAAyB,MAAO6C,CAAAA,UAAhC,CAA6C,WAA7C,CAA2DE,GAA3D,CAAiE,yCAAhH,EACA,OACD,CAED,uBAAU,MAAOF,CAAAA,UAAP,GAAsB,QAAhC,CAA0C,uBAAyB,MAAOA,CAAAA,UAAhC,CAA6C,WAA7C,CAA2DE,GAArG,EACA,uBAAU,MAAOD,CAAAA,MAAP,GAAkB,QAA5B,CAAsC,qBAAuB,MAAOA,CAAAA,MAA9B,CAAuC,WAAvC,CAAqDC,GAA3F,EAEA,IAAK,GAAIE,CAAAA,UAAT,GAAuBJ,CAAAA,UAAvB,CAAmC,CACjChD,QAAQ,CAACgD,UAAU,CAACI,UAAD,CAAX,CAAyBH,MAAM,CAACG,UAAD,CAA/B,CAA6CA,UAA7C,CAAR,CACD,CACF,CAZD,CAaD,CAdD,CAgBA,MAAOjC,CAAAA,aAAP,CACD,CA1GD,EAFA,C,iDA+Ge,CACbA,aAAa,CAAEA,aADF,CAEbxB,iBAAiB,CAAEA,iBAFN,C","sourcesContent":["/**\n * Copyright (c) 2015-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * \n * @format\n */\n'use strict';\n\nimport AnimatedValue from './nodes/AnimatedValue';\nimport NativeAnimatedHelper from './NativeAnimatedHelper';\nimport findNodeHandle from '../../../exports/findNodeHandle';\nimport invariant from 'fbjs/lib/invariant';\nvar shouldUseNativeDriver = NativeAnimatedHelper.shouldUseNativeDriver;\n\nfunction attachNativeEvent(viewRef, eventName, argMapping) {\n // Find animated values in `argMapping` and create an array representing their\n // key path inside the `nativeEvent` object. Ex.: ['contentOffset', 'x'].\n var eventMappings = [];\n\n var traverse = function traverse(value, path) {\n if (value instanceof AnimatedValue) {\n value.__makeNative();\n\n eventMappings.push({\n nativeEventPath: path,\n animatedValueTag: value.__getNativeTag()\n });\n } else if (typeof value === 'object') {\n for (var _key in value) {\n traverse(value[_key], path.concat(_key));\n }\n }\n };\n\n invariant(argMapping[0] && argMapping[0].nativeEvent, 'Native driven events only support animated values contained inside `nativeEvent`.'); // Assume that the event containing `nativeEvent` is always the first argument.\n\n traverse(argMapping[0].nativeEvent, []);\n var viewTag = findNodeHandle(viewRef);\n eventMappings.forEach(function (mapping) {\n NativeAnimatedHelper.API.addAnimatedEventToView(viewTag, eventName, mapping);\n });\n return {\n detach: function detach() {\n eventMappings.forEach(function (mapping) {\n NativeAnimatedHelper.API.removeAnimatedEventFromView(viewTag, eventName, mapping.animatedValueTag);\n });\n }\n };\n}\n\nvar AnimatedEvent =\n/*#__PURE__*/\nfunction () {\n function AnimatedEvent(argMapping, config) {\n if (config === void 0) {\n config = {};\n }\n\n this._listeners = [];\n this._argMapping = argMapping;\n\n if (config.listener) {\n this.__addListener(config.listener);\n }\n\n this._callListeners = this._callListeners.bind(this);\n this._attachedEvent = null;\n this.__isNative = shouldUseNativeDriver(config);\n\n if (process.env.NODE_ENV !== 'production') {\n this._validateMapping();\n }\n }\n\n var _proto = AnimatedEvent.prototype;\n\n _proto.__addListener = function __addListener(callback) {\n this._listeners.push(callback);\n };\n\n _proto.__removeListener = function __removeListener(callback) {\n this._listeners = this._listeners.filter(function (listener) {\n return listener !== callback;\n });\n };\n\n _proto.__attach = function __attach(viewRef, eventName) {\n invariant(this.__isNative, 'Only native driven events need to be attached.');\n this._attachedEvent = attachNativeEvent(viewRef, eventName, this._argMapping);\n };\n\n _proto.__detach = function __detach(viewTag, eventName) {\n invariant(this.__isNative, 'Only native driven events need to be detached.');\n this._attachedEvent && this._attachedEvent.detach();\n };\n\n _proto.__getHandler = function __getHandler() {\n var _this = this;\n\n if (this.__isNative) {\n return this._callListeners;\n }\n\n return function () {\n for (var _len = arguments.length, args = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {\n args[_key2] = arguments[_key2];\n }\n\n var traverse = function traverse(recMapping, recEvt, key) {\n if (typeof recEvt === 'number' && recMapping instanceof AnimatedValue) {\n recMapping.setValue(recEvt);\n } else if (typeof recMapping === 'object') {\n for (var mappingKey in recMapping) {\n /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This\n * comment suppresses an error when upgrading Flow's support for\n * React. To see the error delete this comment and run Flow. */\n traverse(recMapping[mappingKey], recEvt[mappingKey], mappingKey);\n }\n }\n };\n\n if (!_this.__isNative) {\n _this._argMapping.forEach(function (mapping, idx) {\n traverse(mapping, args[idx], 'arg' + idx);\n });\n }\n\n _this._callListeners.apply(_this, args);\n };\n };\n\n _proto._callListeners = function _callListeners() {\n for (var _len2 = arguments.length, args = new Array(_len2), _key3 = 0; _key3 < _len2; _key3++) {\n args[_key3] = arguments[_key3];\n }\n\n this._listeners.forEach(function (listener) {\n return listener.apply(void 0, args);\n });\n };\n\n _proto._validateMapping = function _validateMapping() {\n var traverse = function traverse(recMapping, recEvt, key) {\n if (typeof recEvt === 'number') {\n invariant(recMapping instanceof AnimatedValue, 'Bad mapping of type ' + typeof recMapping + ' for key ' + key + ', event value must map to AnimatedValue');\n return;\n }\n\n invariant(typeof recMapping === 'object', 'Bad mapping of type ' + typeof recMapping + ' for key ' + key);\n invariant(typeof recEvt === 'object', 'Bad event of type ' + typeof recEvt + ' for key ' + key);\n\n for (var mappingKey in recMapping) {\n traverse(recMapping[mappingKey], recEvt[mappingKey], mappingKey);\n }\n };\n };\n\n return AnimatedEvent;\n}();\n\nexport { AnimatedEvent, attachNativeEvent };\nexport default {\n AnimatedEvent: AnimatedEvent,\n attachNativeEvent: attachNativeEvent\n};"]},"metadata":{},"sourceType":"script"}