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
11 KiB

{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _classCallCheck from \"@babel/runtime/helpers/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/createClass\";\nimport invariant from 'invariant';\nimport NativeEventEmitter from \"react-native-web/dist/exports/NativeEventEmitter\";\nimport NativeModules from \"react-native-web/dist/exports/NativeModules\";\nimport Platform from \"react-native-web/dist/exports/Platform\";\nvar nativeEmitterSubscriptionKey = '@@nativeEmitterSubscription@@';\nexport var EventEmitter = function () {\n function EventEmitter(nativeModule) {\n _classCallCheck(this, EventEmitter);\n this._listenerCount = 0;\n if (nativeModule.__expo_module_name__ && NativeModules.EXReactNativeEventEmitter) {\n nativeModule.addListener = function () {\n var _NativeModules$EXReac;\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n return (_NativeModules$EXReac = NativeModules.EXReactNativeEventEmitter).addProxiedListener.apply(_NativeModules$EXReac, [nativeModule.__expo_module_name__].concat(args));\n };\n nativeModule.removeListeners = function () {\n var _NativeModules$EXReac2;\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n return (_NativeModules$EXReac2 = NativeModules.EXReactNativeEventEmitter).removeProxiedListeners.apply(_NativeModules$EXReac2, [nativeModule.__expo_module_name__].concat(args));\n };\n }\n this._nativeModule = nativeModule;\n this._eventEmitter = new NativeEventEmitter(nativeModule);\n }\n _createClass(EventEmitter, [{\n key: \"addListener\",\n value: function addListener(eventName, listener) {\n var _this = this,\n _subscription;\n if (!this._listenerCount && Platform.OS !== 'ios' && this._nativeModule.startObserving) {\n this._nativeModule.startObserving();\n }\n this._listenerCount++;\n var nativeEmitterSubscription = this._eventEmitter.addListener(eventName, listener);\n var subscription = (_subscription = {}, _defineProperty(_subscription, nativeEmitterSubscriptionKey, nativeEmitterSubscription), _defineProperty(_subscription, \"remove\", function remove() {\n _this.removeSubscription(subscription);\n }), _subscription);\n return subscription;\n }\n }, {\n key: \"removeAllListeners\",\n value: function removeAllListeners(eventName) {\n var removedListenerCount = this._eventEmitter.listenerCount ? this._eventEmitter.listenerCount(eventName) : this._eventEmitter.listeners(eventName).length;\n this._eventEmitter.removeAllListeners(eventName);\n this._listenerCount -= removedListenerCount;\n invariant(this._listenerCount >= 0, \"EventEmitter must have a non-negative number of listeners\");\n if (!this._listenerCount && Platform.OS !== 'ios' && this._nativeModule.stopObserving) {\n this._nativeModule.stopObserving();\n }\n }\n }, {\n key: \"removeSubscription\",\n value: function removeSubscription(subscription) {\n var nativeEmitterSubscription = subscription[nativeEmitterSubscriptionKey];\n if (!nativeEmitterSubscription) {\n return;\n }\n if ('remove' in nativeEmitterSubscription) {\n nativeEmitterSubscription.remove();\n } else if ('removeSubscription' in this._eventEmitter) {\n this._eventEmitter.removeSubscription(nativeEmitterSubscription);\n }\n this._listenerCount--;\n delete subscription[nativeEmitterSubscriptionKey];\n subscription.remove = function () {};\n if (!this._listenerCount && Platform.OS !== 'ios' && this._nativeModule.stopObserving) {\n this._nativeModule.stopObserving();\n }\n }\n }, {\n key: \"emit\",\n value: function emit(eventName) {\n var _this$_eventEmitter;\n for (var _len3 = arguments.length, params = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {\n params[_key3 - 1] = arguments[_key3];\n }\n (_this$_eventEmitter = this._eventEmitter).emit.apply(_this$_eventEmitter, [eventName].concat(params));\n }\n }]);\n return EventEmitter;\n}();","map":{"version":3,"mappings":";;;AAAA,OAAOA,SAAS,MAAM,WAAW;AAAC;AAAA;AAAA;AAGlC,IAAMC,4BAA4B,GAAG,+BAA+B;AAkBpE,WAAaC,YAAY;EAKvB,sBAAYC,YAA0B;IAAA;IAAA,KAJtCC,cAAc,GAAG,CAAC;IAShB,IAAID,YAAY,CAACE,oBAAoB,IAAI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AAI,CAACb,aAAa,CAACc,kBAAkB,CAACZ,SAAS,CAAC;MAChD,IAAI,CAACZ,cAAc,IAAIoB,oBAAoB;MAC3CxB,SAAS,CACP,IAAI,CAACI,cAAc,IAAI,CAAC,8DAEzB;MAED,IAAI,CAAC,IAAI,CAACA,cAAc,IAAIc,QAAQ,CAACC,EAAE,KAAK,KAAK,IAAI,IAAI,CAACN,aAAa,CAACgB,aAAa,EAAE;QACrF,IAAI,CAAChB,aAAa,CAACgB,aAAa,EAAE;;IAEtC;EAAC;IAAA;IAAA,OAED,4BAAmBP,YAA0B;MAC3C,IAAMD,yBAAyB,GAAGC,YAAY,CAACrB,4BAA4B,CAAC;MAC5E,IAAI,CAACoB,yBAAyB,EAAE;QAC9B;;MAGF,IAAI,QAAQ,IAAIA,yBAAyB,EAAE;QAEzCA,yBAAyB,CAACS,MAAM,EAAE;OACnC,MAAM,IAAI,oBAAoB,IAAI,IAAI,CAAChB,aAAa,EAAE;QACrD,IAAI,CAACA,aAAa,CAACS,kBAAkB,CAACF,yBAA0B,CAAC;;MAEnE,IAAI,CAACjB,cAAc,EAAE;MAIrB,OAAOkB,YAAY,CAACrB,4BAA4B,CAAC;MAGjDqB,YAAY,CAACQ,MAAM,GAAG,YAAK,CAAE,CAAC;MAE9B,IAAI,CAAC,IAAI,CAAC1B,cAAc,IAAIc,QAAQ,CAACC,EAAE,KAAK,KAAK,IAAI,IAAI,CAACN,aAAa,CAACgB,aAAa,EAAE;QACrF,IAAI,CAAChB,aAAa,CAACgB,aAAa,EAAE;;IAEtC;EAAC;IAAA;IAAA,OAED,cAAKb,SAAiB,EAAkB;MAAA;MAAA,mCAAbe,MAAa;QAAbA,MAAa;MAAA;MACtC,2BAAI,CAACjB,aAAa,EAACkB,IAAI,6BAAChB,SAAS,SAAKe,MAAM,EAAC;IAC/C;EAAC;EAAA;AAAA","names":["invariant","nativeEmitterSubscriptionKey","EventEmitter","nativeModule","_listenerCount","__expo_module_name__","NativeModules","EXReactNativeEventEmitter","addListener","args","addProxiedListener","removeListeners","removeProxiedListeners","_nativeModule","_eventEmitter","NativeEventEmitter","eventName","listener","Platform","OS","startObserving","nativeEmitterSubscription","subscription","removeSubscription","removedListenerCount","listenerCount","listeners","length","removeAllListeners","stopObserving","remove","params","emit"],"sources":["/Users/mathildejean/Documents/BUT/LaSuperMeteo/LaSuperMeteo/iut-expo-starter/node_modules/expo-modules-core/src/EventEmitter.ts"],"sourcesContent":["import invariant from 'invariant';\nimport { NativeEventEmitter, NativeModules, Platform } from 'react-native';\n\nconst nativeEmitterSubscriptionKey = '@@nativeEmitterSubscription@@';\n\ntype NativeModule = {\n __expo_module_name__?: string;\n startObserving?: () => void;\n stopObserving?: () => void;\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n};\n\n// @needsAudit\nexport type Subscription = {\n /**\n * A method to unsubscribe the listener.\n */\n remove: () => void;\n};\n\nexport class EventEmitter {\n _listenerCount = 0;\n _nativeModule: NativeModule;\n _eventEmitter: NativeEventEmitter;\n\n constructor(nativeModule: NativeModule) {\n // Expo modules installed through the JSI don't have `addListener` and `removeListeners` set,\n // so if someone wants to use them with `EventEmitter`, make sure to provide these functions\n // as they are required by `NativeEventEmitter`. This is only temporary — in the future\n // JSI modules will have event emitter built in.\n if (nativeModule.__expo_module_name__ && NativeModules.EXReactNativeEventEmitter) {\n nativeModule.addListener = (...args) =>\n NativeModules.EXReactNativeEventEmitter.addProxiedListener(\n nativeModule.__expo_module_name__,\n ...args\n );\n nativeModule.removeListeners = (...args) =>\n NativeModules.EXReactNativeEventEmitter.removeProxiedListeners(\n nativeModule.__expo_module_name__,\n ...args\n );\n }\n this._nativeModule = nativeModule;\n this._eventEmitter = new NativeEventEmitter(nativeModule as any);\n }\n\n addListener<T>(eventName: string, listener: (event: T) => void): Subscription {\n if (!this._listenerCount && Platform.OS !== 'ios' && this._nativeModule.startObserving) {\n this._nativeModule.startObserving();\n }\n\n this._listenerCount++;\n const nativeEmitterSubscription = this._eventEmitter.addListener(eventName, listener);\n const subscription = {\n [nativeEmitterSubscriptionKey]: nativeEmitterSubscription,\n remove: () => {\n this.removeSubscription(subscription);\n },\n };\n return subscription;\n }\n\n removeAllListeners(eventName: string): void {\n // @ts-ignore: the EventEmitter interface has been changed in react-native@0.64.0\n const removedListenerCount = this._eventEmitter.listenerCount\n ? // @ts-ignore: this is available since 0.64\n this._eventEmitter.listenerCount(eventName)\n : // @ts-ignore: this is available in older versions\n this._eventEmitter.listeners(eventName).length;\n this._eventEmitter.removeAllListeners(eventName);\n this._listenerCount -= removedListenerCount;\n invariant(\n this._listenerCount >= 0,\n `EventEmitter must have a non-negative number of listeners`\n );\n\n if (!this._listenerCount && Platform.OS !== 'ios' && this._nativeModule.stopObserving) {\n this._nativeModule.stopObserving();\n }\n }\n\n removeSubscription(subscription: Subscription): void {\n const nativeEmitterSubscription = subscription[nativeEmitterSubscriptionKey];\n if (!nativeEmitterSubscription) {\n return;\n }\n\n if ('remove' in nativeEmitterSubscription) {\n // `react-native-web@0.17.1` doesn't support `removeSubscription`\n nativeEmitterSubscription.remove();\n } else if ('removeSubscription' in this._eventEmitter) {\n this._eventEmitter.removeSubscription(nativeEmitterSubscription!);\n }\n this._listenerCount--;\n\n // Ensure that the emitter's internal state remains correct even if `removeSubscription` is\n // called again with the same subscription\n delete subscription[nativeEmitterSubscriptionKey];\n\n // Release closed-over references to the emitter\n subscription.remove = () => {};\n\n if (!this._listenerCount && Platform.OS !== 'ios' && this._nativeModule.stopObserving) {\n this._nativeModule.stopObserving();\n }\n }\n\n emit(eventName: string, ...params: any[]): void {\n this._eventEmitter.emit(eventName, ...params);\n }\n}\n"]},"metadata":{},"sourceType":"module","externalDependencies":[]}