This commit is contained in:
Yamozha
2021-04-02 02:24:13 +03:00
parent c23950b545
commit 7256d79e2c
31493 changed files with 3036630 additions and 0 deletions

View File

@ -0,0 +1,83 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
'use strict';
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
import EventEmitter from '../emitter/EventEmitter';
import EventSubscriptionVendor from '../emitter/EventSubscriptionVendor';
var __DEV__ = process.env.NODE_ENV !== 'production';
function checkNativeEventModule(eventType) {
if (eventType) {
if (eventType.lastIndexOf('statusBar', 0) === 0) {
throw new Error('`' + eventType + '` event should be registered via the StatusBarIOS module');
}
if (eventType.lastIndexOf('keyboard', 0) === 0) {
throw new Error('`' + eventType + '` event should be registered via the Keyboard module');
}
if (eventType === 'appStateDidChange' || eventType === 'memoryWarning') {
throw new Error('`' + eventType + '` event should be registered via the AppState module');
}
}
}
/**
* Deprecated - subclass NativeEventEmitter to create granular event modules instead of
* adding all event listeners directly to RCTDeviceEventEmitter.
*/
var RCTDeviceEventEmitter =
/*#__PURE__*/
function (_EventEmitter) {
_inheritsLoose(RCTDeviceEventEmitter, _EventEmitter);
function RCTDeviceEventEmitter() {
var _this;
var sharedSubscriber = new EventSubscriptionVendor();
_this = _EventEmitter.call(this, sharedSubscriber) || this;
_this.sharedSubscriber = sharedSubscriber;
return _this;
}
var _proto = RCTDeviceEventEmitter.prototype;
_proto.addListener = function addListener(eventType, listener, context) {
if (__DEV__) {
checkNativeEventModule(eventType);
}
return _EventEmitter.prototype.addListener.call(this, eventType, listener, context);
};
_proto.removeAllListeners = function removeAllListeners(eventType) {
if (__DEV__) {
checkNativeEventModule(eventType);
}
_EventEmitter.prototype.removeAllListeners.call(this, eventType);
};
_proto.removeSubscription = function removeSubscription(subscription) {
if (subscription.emitter !== this) {
subscription.emitter.removeSubscription(subscription);
} else {
_EventEmitter.prototype.removeSubscription.call(this, subscription);
}
};
return RCTDeviceEventEmitter;
}(EventEmitter);
export default new RCTDeviceEventEmitter();

View File

@ -0,0 +1,63 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
*/
'use strict';
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
import EventEmitter from '../emitter/EventEmitter';
import RCTDeviceEventEmitter from './RCTDeviceEventEmitter';
import invariant from 'fbjs/lib/invariant';
/**
* Abstract base class for implementing event-emitting modules. This implements
* a subset of the standard EventEmitter node module API.
*/
var NativeEventEmitter =
/*#__PURE__*/
function (_EventEmitter) {
_inheritsLoose(NativeEventEmitter, _EventEmitter);
function NativeEventEmitter(nativeModule) {
return _EventEmitter.call(this, RCTDeviceEventEmitter.sharedSubscriber) || this;
}
var _proto = NativeEventEmitter.prototype;
_proto.addListener = function addListener(eventType, listener, context) {
if (this._nativeModule != null) {
this._nativeModule.addListener(eventType);
}
return _EventEmitter.prototype.addListener.call(this, eventType, listener, context);
};
_proto.removeAllListeners = function removeAllListeners(eventType) {
invariant(eventType, 'eventType argument is required.');
var count = this.listeners(eventType).length;
if (this._nativeModule != null) {
this._nativeModule.removeListeners(count);
}
_EventEmitter.prototype.removeAllListeners.call(this, eventType);
};
_proto.removeSubscription = function removeSubscription(subscription) {
if (this._nativeModule != null) {
this._nativeModule.removeListeners(1);
}
_EventEmitter.prototype.removeSubscription.call(this, subscription);
};
return NativeEventEmitter;
}(EventEmitter);
export default NativeEventEmitter;