yeet
This commit is contained in:
60
node_modules/react-native-web/dist/vendor/react-native/emitter/EmitterSubscription.js
generated
vendored
Normal file
60
node_modules/react-native-web/dist/vendor/react-native/emitter/EmitterSubscription.js
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
/**
|
||||
* 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 EventSubscription from './EventSubscription';
|
||||
|
||||
/**
|
||||
* EmitterSubscription represents a subscription with listener and context data.
|
||||
*/
|
||||
var EmitterSubscription =
|
||||
/*#__PURE__*/
|
||||
function (_EventSubscription) {
|
||||
_inheritsLoose(EmitterSubscription, _EventSubscription);
|
||||
|
||||
/**
|
||||
* @param {EventEmitter} emitter - The event emitter that registered this
|
||||
* subscription
|
||||
* @param {EventSubscriptionVendor} subscriber - The subscriber that controls
|
||||
* this subscription
|
||||
* @param {function} listener - Function to invoke when the specified event is
|
||||
* emitted
|
||||
* @param {*} context - Optional context object to use when invoking the
|
||||
* listener
|
||||
*/
|
||||
function EmitterSubscription(emitter, subscriber, listener, context) {
|
||||
var _this;
|
||||
|
||||
_this = _EventSubscription.call(this, subscriber) || this;
|
||||
_this.emitter = emitter;
|
||||
_this.listener = listener;
|
||||
_this.context = context;
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* Removes this subscription from the emitter that registered it.
|
||||
* Note: we're overriding the `remove()` method of EventSubscription here
|
||||
* but deliberately not calling `super.remove()` as the responsibility
|
||||
* for removing the subscription lies with the EventEmitter.
|
||||
*/
|
||||
|
||||
|
||||
var _proto = EmitterSubscription.prototype;
|
||||
|
||||
_proto.remove = function remove() {
|
||||
this.emitter.removeSubscription(this);
|
||||
};
|
||||
|
||||
return EmitterSubscription;
|
||||
}(EventSubscription);
|
||||
|
||||
export default EmitterSubscription;
|
228
node_modules/react-native-web/dist/vendor/react-native/emitter/EventEmitter.js
generated
vendored
Normal file
228
node_modules/react-native-web/dist/vendor/react-native/emitter/EventEmitter.js
generated
vendored
Normal file
@ -0,0 +1,228 @@
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @typecheck
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
import EmitterSubscription from './EmitterSubscription';
|
||||
import EventSubscriptionVendor from './EventSubscriptionVendor';
|
||||
import invariant from 'fbjs/lib/invariant';
|
||||
|
||||
var sparseFilterPredicate = function sparseFilterPredicate() {
|
||||
return true;
|
||||
};
|
||||
/**
|
||||
* @class EventEmitter
|
||||
* @description
|
||||
* An EventEmitter is responsible for managing a set of listeners and publishing
|
||||
* events to them when it is told that such events happened. In addition to the
|
||||
* data for the given event it also sends a event control object which allows
|
||||
* the listeners/handlers to prevent the default behavior of the given event.
|
||||
*
|
||||
* The emitter is designed to be generic enough to support all the different
|
||||
* contexts in which one might want to emit events. It is a simple multicast
|
||||
* mechanism on top of which extra functionality can be composed. For example, a
|
||||
* more advanced emitter may use an EventHolder and EventFactory.
|
||||
*/
|
||||
|
||||
|
||||
var EventEmitter =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {EventSubscriptionVendor} subscriber - Optional subscriber instance
|
||||
* to use. If omitted, a new subscriber will be created for the emitter.
|
||||
*/
|
||||
function EventEmitter(subscriber) {
|
||||
this._subscriber = subscriber || new EventSubscriptionVendor();
|
||||
}
|
||||
/**
|
||||
* Adds a listener to be invoked when events of the specified type are
|
||||
* emitted. An optional calling context may be provided. The data arguments
|
||||
* emitted will be passed to the listener function.
|
||||
*
|
||||
* TODO: Annotate the listener arg's type. This is tricky because listeners
|
||||
* can be invoked with varargs.
|
||||
*
|
||||
* @param {string} eventType - Name of the event to listen to
|
||||
* @param {function} listener - Function to invoke when the specified event is
|
||||
* emitted
|
||||
* @param {*} context - Optional context object to use when invoking the
|
||||
* listener
|
||||
*/
|
||||
|
||||
|
||||
var _proto = EventEmitter.prototype;
|
||||
|
||||
_proto.addListener = function addListener(eventType, listener, context) {
|
||||
return this._subscriber.addSubscription(eventType, new EmitterSubscription(this, this._subscriber, listener, context));
|
||||
}
|
||||
/**
|
||||
* Similar to addListener, except that the listener is removed after it is
|
||||
* invoked once.
|
||||
*
|
||||
* @param {string} eventType - Name of the event to listen to
|
||||
* @param {function} listener - Function to invoke only once when the
|
||||
* specified event is emitted
|
||||
* @param {*} context - Optional context object to use when invoking the
|
||||
* listener
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.once = function once(eventType, listener, context) {
|
||||
var _this = this;
|
||||
|
||||
return this.addListener(eventType, function () {
|
||||
_this.removeCurrentListener();
|
||||
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
listener.apply(context, args);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Removes all of the registered listeners, including those registered as
|
||||
* listener maps.
|
||||
*
|
||||
* @param {?string} eventType - Optional name of the event whose registered
|
||||
* listeners to remove
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.removeAllListeners = function removeAllListeners(eventType) {
|
||||
this._subscriber.removeAllSubscriptions(eventType);
|
||||
}
|
||||
/**
|
||||
* Provides an API that can be called during an eventing cycle to remove the
|
||||
* last listener that was invoked. This allows a developer to provide an event
|
||||
* object that can remove the listener (or listener map) during the
|
||||
* invocation.
|
||||
*
|
||||
* If it is called when not inside of an emitting cycle it will throw.
|
||||
*
|
||||
* @throws {Error} When called not during an eventing cycle
|
||||
*
|
||||
* @example
|
||||
* var subscription = emitter.addListenerMap({
|
||||
* someEvent: function(data, event) {
|
||||
* console.log(data);
|
||||
* emitter.removeCurrentListener();
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* emitter.emit('someEvent', 'abc'); // logs 'abc'
|
||||
* emitter.emit('someEvent', 'def'); // does not log anything
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.removeCurrentListener = function removeCurrentListener() {
|
||||
invariant(!!this._currentSubscription, 'Not in an emitting cycle; there is no current subscription');
|
||||
this.removeSubscription(this._currentSubscription);
|
||||
}
|
||||
/**
|
||||
* Removes a specific subscription. Called by the `remove()` method of the
|
||||
* subscription itself to ensure any necessary cleanup is performed.
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.removeSubscription = function removeSubscription(subscription) {
|
||||
invariant(subscription.emitter === this, 'Subscription does not belong to this emitter.');
|
||||
|
||||
this._subscriber.removeSubscription(subscription);
|
||||
}
|
||||
/**
|
||||
* Returns an array of listeners that are currently registered for the given
|
||||
* event.
|
||||
*
|
||||
* @param {string} eventType - Name of the event to query
|
||||
* @returns {array}
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.listeners = function listeners(eventType) {
|
||||
var subscriptions = this._subscriber.getSubscriptionsForType(eventType);
|
||||
|
||||
return subscriptions ? subscriptions // We filter out missing entries because the array is sparse.
|
||||
// "callbackfn is called only for elements of the array which actually
|
||||
// exist; it is not called for missing elements of the array."
|
||||
// https://www.ecma-international.org/ecma-262/9.0/index.html#sec-array.prototype.filter
|
||||
.filter(sparseFilterPredicate).map(function (subscription) {
|
||||
return subscription.listener;
|
||||
}) : [];
|
||||
}
|
||||
/**
|
||||
* Emits an event of the given type with the given data. All handlers of that
|
||||
* particular type will be notified.
|
||||
*
|
||||
* @param {string} eventType - Name of the event to emit
|
||||
* @param {...*} Arbitrary arguments to be passed to each registered listener
|
||||
*
|
||||
* @example
|
||||
* emitter.addListener('someEvent', function(message) {
|
||||
* console.log(message);
|
||||
* });
|
||||
*
|
||||
* emitter.emit('someEvent', 'abc'); // logs 'abc'
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.emit = function emit(eventType) {
|
||||
var subscriptions = this._subscriber.getSubscriptionsForType(eventType);
|
||||
|
||||
if (subscriptions) {
|
||||
for (var i = 0, l = subscriptions.length; i < l; i++) {
|
||||
var subscription = subscriptions[i]; // The subscription may have been removed during this event loop.
|
||||
|
||||
if (subscription && subscription.listener) {
|
||||
this._currentSubscription = subscription;
|
||||
subscription.listener.apply(subscription.context, Array.prototype.slice.call(arguments, 1));
|
||||
}
|
||||
}
|
||||
|
||||
this._currentSubscription = null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Removes the given listener for event of specific type.
|
||||
*
|
||||
* @param {string} eventType - Name of the event to emit
|
||||
* @param {function} listener - Function to invoke when the specified event is
|
||||
* emitted
|
||||
*
|
||||
* @example
|
||||
* emitter.removeListener('someEvent', function(message) {
|
||||
* console.log(message);
|
||||
* }); // removes the listener if already registered
|
||||
*
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.removeListener = function removeListener(eventType, listener) {
|
||||
var subscriptions = this._subscriber.getSubscriptionsForType(eventType);
|
||||
|
||||
if (subscriptions) {
|
||||
for (var i = 0, l = subscriptions.length; i < l; i++) {
|
||||
var subscription = subscriptions[i]; // The subscription may have been removed during this event loop.
|
||||
// its listener matches the listener in method parameters
|
||||
|
||||
if (subscription && subscription.listener === listener) {
|
||||
subscription.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return EventEmitter;
|
||||
}();
|
||||
|
||||
export default EventEmitter;
|
185
node_modules/react-native-web/dist/vendor/react-native/emitter/EventEmitterWithHolding.js
generated
vendored
Normal file
185
node_modules/react-native-web/dist/vendor/react-native/emitter/EventEmitterWithHolding.js
generated
vendored
Normal file
@ -0,0 +1,185 @@
|
||||
/**
|
||||
* 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';
|
||||
|
||||
/**
|
||||
* @class EventEmitterWithHolding
|
||||
* @description
|
||||
* An EventEmitterWithHolding decorates an event emitter and enables one to
|
||||
* "hold" or cache events and then have a handler register later to actually
|
||||
* handle them.
|
||||
*
|
||||
* This is separated into its own decorator so that only those who want to use
|
||||
* the holding functionality have to and others can just use an emitter. Since
|
||||
* it implements the emitter interface it can also be combined with anything
|
||||
* that uses an emitter.
|
||||
*/
|
||||
var EventEmitterWithHolding =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
/**
|
||||
* @constructor
|
||||
* @param {object} emitter - The object responsible for emitting the actual
|
||||
* events.
|
||||
* @param {object} holder - The event holder that is responsible for holding
|
||||
* and then emitting held events.
|
||||
*/
|
||||
function EventEmitterWithHolding(emitter, holder) {
|
||||
this._emitter = emitter;
|
||||
this._eventHolder = holder;
|
||||
this._currentEventToken = null;
|
||||
this._emittingHeldEvents = false;
|
||||
}
|
||||
/**
|
||||
* @see EventEmitter#addListener
|
||||
*/
|
||||
|
||||
|
||||
var _proto = EventEmitterWithHolding.prototype;
|
||||
|
||||
_proto.addListener = function addListener(eventType, listener, context) {
|
||||
return this._emitter.addListener(eventType, listener, context);
|
||||
}
|
||||
/**
|
||||
* @see EventEmitter#once
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.once = function once(eventType, listener, context) {
|
||||
return this._emitter.once(eventType, listener, context);
|
||||
}
|
||||
/**
|
||||
* Adds a listener to be invoked when events of the specified type are
|
||||
* emitted. An optional calling context may be provided. The data arguments
|
||||
* emitted will be passed to the listener function. In addition to subscribing
|
||||
* to all subsequent events, this method will also handle any events that have
|
||||
* already been emitted, held, and not released.
|
||||
*
|
||||
* @param {string} eventType - Name of the event to listen to
|
||||
* @param {function} listener - Function to invoke when the specified event is
|
||||
* emitted
|
||||
* @param {*} context - Optional context object to use when invoking the
|
||||
* listener
|
||||
*
|
||||
* @example
|
||||
* emitter.emitAndHold('someEvent', 'abc');
|
||||
*
|
||||
* emitter.addRetroactiveListener('someEvent', function(message) {
|
||||
* console.log(message);
|
||||
* }); // logs 'abc'
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.addRetroactiveListener = function addRetroactiveListener(eventType, listener, context) {
|
||||
var subscription = this._emitter.addListener(eventType, listener, context);
|
||||
|
||||
this._emittingHeldEvents = true;
|
||||
|
||||
this._eventHolder.emitToListener(eventType, listener, context);
|
||||
|
||||
this._emittingHeldEvents = false;
|
||||
return subscription;
|
||||
}
|
||||
/**
|
||||
* @see EventEmitter#removeAllListeners
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.removeAllListeners = function removeAllListeners(eventType) {
|
||||
this._emitter.removeAllListeners(eventType);
|
||||
}
|
||||
/**
|
||||
* @see EventEmitter#removeCurrentListener
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.removeCurrentListener = function removeCurrentListener() {
|
||||
this._emitter.removeCurrentListener();
|
||||
}
|
||||
/**
|
||||
* @see EventEmitter#listeners
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.listeners = function listeners(eventType)
|
||||
/* TODO: Annotate return type here */
|
||||
{
|
||||
return this._emitter.listeners(eventType);
|
||||
}
|
||||
/**
|
||||
* @see EventEmitter#emit
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.emit = function emit(eventType) {
|
||||
var _this$_emitter;
|
||||
|
||||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
args[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
(_this$_emitter = this._emitter).emit.apply(_this$_emitter, [eventType].concat(args));
|
||||
}
|
||||
/**
|
||||
* Emits an event of the given type with the given data, and holds that event
|
||||
* in order to be able to dispatch it to a later subscriber when they say they
|
||||
* want to handle held events.
|
||||
*
|
||||
* @param {string} eventType - Name of the event to emit
|
||||
* @param {...*} Arbitrary arguments to be passed to each registered listener
|
||||
*
|
||||
* @example
|
||||
* emitter.emitAndHold('someEvent', 'abc');
|
||||
*
|
||||
* emitter.addRetroactiveListener('someEvent', function(message) {
|
||||
* console.log(message);
|
||||
* }); // logs 'abc'
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.emitAndHold = function emitAndHold(eventType) {
|
||||
var _this$_eventHolder, _this$_emitter2;
|
||||
|
||||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
||||
args[_key2 - 1] = arguments[_key2];
|
||||
}
|
||||
|
||||
this._currentEventToken = (_this$_eventHolder = this._eventHolder).holdEvent.apply(_this$_eventHolder, [eventType].concat(args));
|
||||
|
||||
(_this$_emitter2 = this._emitter).emit.apply(_this$_emitter2, [eventType].concat(args));
|
||||
|
||||
this._currentEventToken = null;
|
||||
}
|
||||
/**
|
||||
* @see EventHolder#releaseCurrentEvent
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.releaseCurrentEvent = function releaseCurrentEvent() {
|
||||
if (this._currentEventToken) {
|
||||
this._eventHolder.releaseEvent(this._currentEventToken);
|
||||
} else if (this._emittingHeldEvents) {
|
||||
this._eventHolder.releaseCurrentEvent();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see EventHolder#releaseEventType
|
||||
* @param {string} eventType
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.releaseHeldEventType = function releaseHeldEventType(eventType) {
|
||||
this._eventHolder.releaseEventType(eventType);
|
||||
};
|
||||
|
||||
return EventEmitterWithHolding;
|
||||
}();
|
||||
|
||||
export default EventEmitterWithHolding;
|
137
node_modules/react-native-web/dist/vendor/react-native/emitter/EventHolder.js
generated
vendored
Normal file
137
node_modules/react-native-web/dist/vendor/react-native/emitter/EventHolder.js
generated
vendored
Normal file
@ -0,0 +1,137 @@
|
||||
/**
|
||||
* 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';
|
||||
|
||||
import invariant from 'fbjs/lib/invariant';
|
||||
|
||||
var EventHolder =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function EventHolder() {
|
||||
this._heldEvents = {};
|
||||
this._currentEventKey = null;
|
||||
}
|
||||
/**
|
||||
* Holds a given event for processing later.
|
||||
*
|
||||
* TODO: Annotate return type better. The structural type of the return here
|
||||
* is pretty obvious.
|
||||
*
|
||||
* @param {string} eventType - Name of the event to hold and later emit
|
||||
* @param {...*} Arbitrary arguments to be passed to each registered listener
|
||||
* @return {object} Token that can be used to release the held event
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* holder.holdEvent({someEvent: 'abc'});
|
||||
*
|
||||
* holder.emitToHandler({
|
||||
* someEvent: function(data, event) {
|
||||
* console.log(data);
|
||||
* }
|
||||
* }); //logs 'abc'
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
var _proto = EventHolder.prototype;
|
||||
|
||||
_proto.holdEvent = function holdEvent(eventType) {
|
||||
this._heldEvents[eventType] = this._heldEvents[eventType] || [];
|
||||
var eventsOfType = this._heldEvents[eventType];
|
||||
var key = {
|
||||
eventType: eventType,
|
||||
index: eventsOfType.length
|
||||
};
|
||||
|
||||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
args[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
eventsOfType.push(args);
|
||||
return key;
|
||||
}
|
||||
/**
|
||||
* Emits the held events of the specified type to the given listener.
|
||||
*
|
||||
* @param {?string} eventType - Optional name of the events to replay
|
||||
* @param {function} listener - The listener to which to dispatch the event
|
||||
* @param {?object} context - Optional context object to use when invoking
|
||||
* the listener
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.emitToListener = function emitToListener(eventType, listener, context) {
|
||||
var _this = this;
|
||||
|
||||
var eventsOfType = this._heldEvents[eventType];
|
||||
|
||||
if (!eventsOfType) {
|
||||
return;
|
||||
}
|
||||
|
||||
var origEventKey = this._currentEventKey;
|
||||
eventsOfType.forEach(function (
|
||||
/*?array*/
|
||||
eventHeld,
|
||||
/*number*/
|
||||
index) {
|
||||
if (!eventHeld) {
|
||||
return;
|
||||
}
|
||||
|
||||
_this._currentEventKey = {
|
||||
eventType: eventType,
|
||||
index: index
|
||||
};
|
||||
listener.apply(context, eventHeld);
|
||||
});
|
||||
this._currentEventKey = origEventKey;
|
||||
}
|
||||
/**
|
||||
* Provides an API that can be called during an eventing cycle to release
|
||||
* the last event that was invoked, so that it is no longer "held".
|
||||
*
|
||||
* If it is called when not inside of an emitting cycle it will throw.
|
||||
*
|
||||
* @throws {Error} When called not during an eventing cycle
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.releaseCurrentEvent = function releaseCurrentEvent() {
|
||||
invariant(this._currentEventKey !== null, 'Not in an emitting cycle; there is no current event');
|
||||
this._currentEventKey && this.releaseEvent(this._currentEventKey);
|
||||
}
|
||||
/**
|
||||
* Releases the event corresponding to the handle that was returned when the
|
||||
* event was first held.
|
||||
*
|
||||
* @param {object} token - The token returned from holdEvent
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.releaseEvent = function releaseEvent(token) {
|
||||
delete this._heldEvents[token.eventType][token.index];
|
||||
}
|
||||
/**
|
||||
* Releases all events of a certain type.
|
||||
*
|
||||
* @param {string} type
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.releaseEventType = function releaseEventType(type) {
|
||||
this._heldEvents[type] = [];
|
||||
};
|
||||
|
||||
return EventHolder;
|
||||
}();
|
||||
|
||||
export default EventHolder;
|
40
node_modules/react-native-web/dist/vendor/react-native/emitter/EventSubscription.js
generated
vendored
Normal file
40
node_modules/react-native-web/dist/vendor/react-native/emitter/EventSubscription.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* 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';
|
||||
|
||||
/**
|
||||
* EventSubscription represents a subscription to a particular event. It can
|
||||
* remove its own subscription.
|
||||
*/
|
||||
var EventSubscription =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
/**
|
||||
* @param {EventSubscriptionVendor} subscriber the subscriber that controls
|
||||
* this subscription.
|
||||
*/
|
||||
function EventSubscription(subscriber) {
|
||||
this.subscriber = subscriber;
|
||||
}
|
||||
/**
|
||||
* Removes this subscription from the subscriber that controls it.
|
||||
*/
|
||||
|
||||
|
||||
var _proto = EventSubscription.prototype;
|
||||
|
||||
_proto.remove = function remove() {
|
||||
this.subscriber.removeSubscription(this);
|
||||
};
|
||||
|
||||
return EventSubscription;
|
||||
}();
|
||||
|
||||
export default EventSubscription;
|
103
node_modules/react-native-web/dist/vendor/react-native/emitter/EventSubscriptionVendor.js
generated
vendored
Normal file
103
node_modules/react-native-web/dist/vendor/react-native/emitter/EventSubscriptionVendor.js
generated
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
/**
|
||||
* 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';
|
||||
|
||||
import invariant from 'fbjs/lib/invariant';
|
||||
|
||||
/**
|
||||
* EventSubscriptionVendor stores a set of EventSubscriptions that are
|
||||
* subscribed to a particular event type.
|
||||
*/
|
||||
var EventSubscriptionVendor =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function EventSubscriptionVendor() {
|
||||
this._subscriptionsForType = {};
|
||||
this._currentSubscription = null;
|
||||
}
|
||||
/**
|
||||
* Adds a subscription keyed by an event type.
|
||||
*
|
||||
* @param {string} eventType
|
||||
* @param {EventSubscription} subscription
|
||||
*/
|
||||
|
||||
|
||||
var _proto = EventSubscriptionVendor.prototype;
|
||||
|
||||
_proto.addSubscription = function addSubscription(eventType, subscription) {
|
||||
invariant(subscription.subscriber === this, 'The subscriber of the subscription is incorrectly set.');
|
||||
|
||||
if (!this._subscriptionsForType[eventType]) {
|
||||
this._subscriptionsForType[eventType] = [];
|
||||
}
|
||||
|
||||
var key = this._subscriptionsForType[eventType].length;
|
||||
|
||||
this._subscriptionsForType[eventType].push(subscription);
|
||||
|
||||
subscription.eventType = eventType;
|
||||
subscription.key = key;
|
||||
return subscription;
|
||||
}
|
||||
/**
|
||||
* Removes a bulk set of the subscriptions.
|
||||
*
|
||||
* @param {?string} eventType - Optional name of the event type whose
|
||||
* registered supscriptions to remove, if null remove all subscriptions.
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.removeAllSubscriptions = function removeAllSubscriptions(eventType) {
|
||||
if (eventType === undefined) {
|
||||
this._subscriptionsForType = {};
|
||||
} else {
|
||||
delete this._subscriptionsForType[eventType];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Removes a specific subscription. Instead of calling this function, call
|
||||
* `subscription.remove()` directly.
|
||||
*
|
||||
* @param {object} subscription
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.removeSubscription = function removeSubscription(subscription) {
|
||||
var eventType = subscription.eventType;
|
||||
var key = subscription.key;
|
||||
var subscriptionsForType = this._subscriptionsForType[eventType];
|
||||
|
||||
if (subscriptionsForType) {
|
||||
delete subscriptionsForType[key];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns the array of subscriptions that are currently registered for the
|
||||
* given event type.
|
||||
*
|
||||
* Note: This array can be potentially sparse as subscriptions are deleted
|
||||
* from it when they are removed.
|
||||
*
|
||||
* TODO: This returns a nullable array. wat?
|
||||
*
|
||||
* @param {string} eventType
|
||||
* @returns {?array}
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.getSubscriptionsForType = function getSubscriptionsForType(eventType) {
|
||||
return this._subscriptionsForType[eventType];
|
||||
};
|
||||
|
||||
return EventSubscriptionVendor;
|
||||
}();
|
||||
|
||||
export default EventSubscriptionVendor;
|
130
node_modules/react-native-web/dist/vendor/react-native/emitter/EventValidator.js
generated
vendored
Normal file
130
node_modules/react-native-web/dist/vendor/react-native/emitter/EventValidator.js
generated
vendored
Normal file
@ -0,0 +1,130 @@
|
||||
/**
|
||||
* 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';
|
||||
|
||||
var __DEV__ = process.env.NODE_ENV !== 'production';
|
||||
/**
|
||||
* EventValidator is designed to validate event types to make it easier to catch
|
||||
* common mistakes. It accepts a map of all of the different types of events
|
||||
* that the emitter can emit. Then, if a user attempts to emit an event that is
|
||||
* not one of those specified types the emitter will throw an error. Also, it
|
||||
* provides a relatively simple matcher so that if it thinks that you likely
|
||||
* mistyped the event name it will suggest what you might have meant to type in
|
||||
* the error message.
|
||||
*/
|
||||
|
||||
|
||||
var EventValidator = {
|
||||
/**
|
||||
* @param {Object} emitter - The object responsible for emitting the actual
|
||||
* events
|
||||
* @param {Object} types - The collection of valid types that will be used to
|
||||
* check for errors
|
||||
* @return {Object} A new emitter with event type validation
|
||||
* @example
|
||||
* const types = {someEvent: true, anotherEvent: true};
|
||||
* const emitter = EventValidator.addValidation(emitter, types);
|
||||
*/
|
||||
addValidation: function addValidation(emitter, types) {
|
||||
var eventTypes = Object.keys(types);
|
||||
var emitterWithValidation = Object.create(emitter);
|
||||
Object.assign(emitterWithValidation, {
|
||||
emit: function emit(type, a, b, c, d, e, _) {
|
||||
assertAllowsEventType(type, eventTypes);
|
||||
return emitter.emit.call(this, type, a, b, c, d, e, _);
|
||||
}
|
||||
});
|
||||
return emitterWithValidation;
|
||||
}
|
||||
};
|
||||
|
||||
function assertAllowsEventType(type, allowedTypes) {
|
||||
if (allowedTypes.indexOf(type) === -1) {
|
||||
throw new TypeError(errorMessageFor(type, allowedTypes));
|
||||
}
|
||||
}
|
||||
|
||||
function errorMessageFor(type, allowedTypes) {
|
||||
var message = 'Unknown event type "' + type + '". ';
|
||||
|
||||
if (__DEV__) {
|
||||
message += recommendationFor(type, allowedTypes);
|
||||
}
|
||||
|
||||
message += 'Known event types: ' + allowedTypes.join(', ') + '.';
|
||||
return message;
|
||||
} // Allow for good error messages
|
||||
|
||||
|
||||
if (__DEV__) {
|
||||
var recommendationFor = function recommendationFor(type, allowedTypes) {
|
||||
var closestTypeRecommendation = closestTypeFor(type, allowedTypes);
|
||||
|
||||
if (isCloseEnough(closestTypeRecommendation, type)) {
|
||||
return 'Did you mean "' + closestTypeRecommendation.type + '"? ';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
var closestTypeFor = function closestTypeFor(type, allowedTypes) {
|
||||
var typeRecommendations = allowedTypes.map(typeRecommendationFor.bind(this, type));
|
||||
return typeRecommendations.sort(recommendationSort)[0];
|
||||
};
|
||||
|
||||
var typeRecommendationFor = function typeRecommendationFor(type, recommendedType) {
|
||||
return {
|
||||
type: recommendedType,
|
||||
distance: damerauLevenshteinDistance(type, recommendedType)
|
||||
};
|
||||
};
|
||||
|
||||
var recommendationSort = function recommendationSort(recommendationA, recommendationB) {
|
||||
if (recommendationA.distance < recommendationB.distance) {
|
||||
return -1;
|
||||
} else if (recommendationA.distance > recommendationB.distance) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
var isCloseEnough = function isCloseEnough(closestType, actualType) {
|
||||
return closestType.distance / actualType.length < 0.334;
|
||||
};
|
||||
|
||||
var damerauLevenshteinDistance = function damerauLevenshteinDistance(a, b) {
|
||||
var i, j;
|
||||
var d = [];
|
||||
|
||||
for (i = 0; i <= a.length; i++) {
|
||||
d[i] = [i];
|
||||
}
|
||||
|
||||
for (j = 1; j <= b.length; j++) {
|
||||
d[0][j] = j;
|
||||
}
|
||||
|
||||
for (i = 1; i <= a.length; i++) {
|
||||
for (j = 1; j <= b.length; j++) {
|
||||
var cost = a.charAt(i - 1) === b.charAt(j - 1) ? 0 : 1;
|
||||
d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
|
||||
|
||||
if (i > 1 && j > 1 && a.charAt(i - 1) === b.charAt(j - 2) && a.charAt(i - 2) === b.charAt(j - 1)) {
|
||||
d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + cost);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return d[a.length][b.length];
|
||||
};
|
||||
}
|
||||
|
||||
export default EventValidator;
|
118
node_modules/react-native-web/dist/vendor/react-native/emitter/mixInEventEmitter.js
generated
vendored
Normal file
118
node_modules/react-native-web/dist/vendor/react-native/emitter/mixInEventEmitter.js
generated
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
/**
|
||||
* 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';
|
||||
|
||||
import EventEmitter from './EventEmitter';
|
||||
import EventEmitterWithHolding from './EventEmitterWithHolding';
|
||||
import EventHolder from './EventHolder';
|
||||
import invariant from 'fbjs/lib/invariant';
|
||||
import keyOf from 'fbjs/lib/keyOf';
|
||||
|
||||
var __DEV__ = process.env.NODE_ENV !== 'production';
|
||||
|
||||
var TYPES_KEY = keyOf({
|
||||
__types: true
|
||||
});
|
||||
/**
|
||||
* API to setup an object or constructor to be able to emit data events.
|
||||
*
|
||||
* @example
|
||||
* function Dog() { ...dog stuff... }
|
||||
* mixInEventEmitter(Dog, {bark: true});
|
||||
*
|
||||
* var puppy = new Dog();
|
||||
* puppy.addListener('bark', function (volume) {
|
||||
* console.log('Puppy', this, 'barked at volume:', volume);
|
||||
* });
|
||||
* puppy.emit('bark', 'quiet');
|
||||
* // Puppy <puppy> barked at volume: quiet
|
||||
*
|
||||
*
|
||||
* // A "singleton" object may also be commissioned:
|
||||
*
|
||||
* var Singleton = {};
|
||||
* mixInEventEmitter(Singleton, {lonely: true});
|
||||
* Singleton.emit('lonely', true);
|
||||
*/
|
||||
|
||||
function mixInEventEmitter(cls, types) {
|
||||
invariant(types, 'Must supply set of valid event types'); // If this is a constructor, write to the prototype, otherwise write to the
|
||||
// singleton object.
|
||||
|
||||
var target = cls.prototype || cls;
|
||||
invariant(!target.__eventEmitter, 'An active emitter is already mixed in');
|
||||
var ctor = cls.constructor;
|
||||
|
||||
if (ctor) {
|
||||
invariant(ctor === Object || ctor === Function, 'Mix EventEmitter into a class, not an instance');
|
||||
} // Keep track of the provided types, union the types if they already exist,
|
||||
// which allows for prototype subclasses to provide more types.
|
||||
|
||||
|
||||
if (target.hasOwnProperty(TYPES_KEY)) {
|
||||
Object.assign(target.__types, types);
|
||||
} else if (target.__types) {
|
||||
target.__types = Object.assign({}, target.__types, types);
|
||||
} else {
|
||||
target.__types = types;
|
||||
}
|
||||
|
||||
Object.assign(target, EventEmitterMixin);
|
||||
}
|
||||
|
||||
var EventEmitterMixin = {
|
||||
emit: function emit(eventType, a, b, c, d, e, _) {
|
||||
return this.__getEventEmitter().emit(eventType, a, b, c, d, e, _);
|
||||
},
|
||||
emitAndHold: function emitAndHold(eventType, a, b, c, d, e, _) {
|
||||
return this.__getEventEmitter().emitAndHold(eventType, a, b, c, d, e, _);
|
||||
},
|
||||
addListener: function addListener(eventType, listener, context) {
|
||||
return this.__getEventEmitter().addListener(eventType, listener, context);
|
||||
},
|
||||
once: function once(eventType, listener, context) {
|
||||
return this.__getEventEmitter().once(eventType, listener, context);
|
||||
},
|
||||
addRetroactiveListener: function addRetroactiveListener(eventType, listener, context) {
|
||||
return this.__getEventEmitter().addRetroactiveListener(eventType, listener, context);
|
||||
},
|
||||
addListenerMap: function addListenerMap(listenerMap, context) {
|
||||
return this.__getEventEmitter().addListenerMap(listenerMap, context);
|
||||
},
|
||||
addRetroactiveListenerMap: function addRetroactiveListenerMap(listenerMap, context) {
|
||||
return this.__getEventEmitter().addListenerMap(listenerMap, context);
|
||||
},
|
||||
removeAllListeners: function removeAllListeners() {
|
||||
this.__getEventEmitter().removeAllListeners();
|
||||
},
|
||||
removeCurrentListener: function removeCurrentListener() {
|
||||
this.__getEventEmitter().removeCurrentListener();
|
||||
},
|
||||
releaseHeldEventType: function releaseHeldEventType(eventType) {
|
||||
this.__getEventEmitter().releaseHeldEventType(eventType);
|
||||
},
|
||||
__getEventEmitter: function __getEventEmitter() {
|
||||
if (!this.__eventEmitter) {
|
||||
var emitter = new EventEmitter();
|
||||
|
||||
if (__DEV__) {
|
||||
var EventValidator = require('./EventValidator').default;
|
||||
|
||||
emitter = EventValidator.addValidation(emitter, this.__types);
|
||||
}
|
||||
|
||||
var holder = new EventHolder();
|
||||
this.__eventEmitter = new EventEmitterWithHolding(emitter, holder);
|
||||
}
|
||||
|
||||
return this.__eventEmitter;
|
||||
}
|
||||
};
|
||||
export default mixInEventEmitter;
|
Reference in New Issue
Block a user