This commit is contained in:
126
node_modules/react-redux/es/utils/Subscription.js
generated
vendored
Normal file
126
node_modules/react-redux/es/utils/Subscription.js
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
import { getBatch } from './batch'; // encapsulates the subscription logic for connecting a component to the redux store, as
|
||||
// well as nesting subscriptions of descendant components, so that we can ensure the
|
||||
// ancestor components re-render before descendants
|
||||
|
||||
function createListenerCollection() {
|
||||
var batch = getBatch();
|
||||
var first = null;
|
||||
var last = null;
|
||||
return {
|
||||
clear: function clear() {
|
||||
first = null;
|
||||
last = null;
|
||||
},
|
||||
notify: function notify() {
|
||||
batch(function () {
|
||||
var listener = first;
|
||||
|
||||
while (listener) {
|
||||
listener.callback();
|
||||
listener = listener.next;
|
||||
}
|
||||
});
|
||||
},
|
||||
get: function get() {
|
||||
var listeners = [];
|
||||
var listener = first;
|
||||
|
||||
while (listener) {
|
||||
listeners.push(listener);
|
||||
listener = listener.next;
|
||||
}
|
||||
|
||||
return listeners;
|
||||
},
|
||||
subscribe: function subscribe(callback) {
|
||||
var isSubscribed = true;
|
||||
var listener = last = {
|
||||
callback: callback,
|
||||
next: null,
|
||||
prev: last
|
||||
};
|
||||
|
||||
if (listener.prev) {
|
||||
listener.prev.next = listener;
|
||||
} else {
|
||||
first = listener;
|
||||
}
|
||||
|
||||
return function unsubscribe() {
|
||||
if (!isSubscribed || first === null) return;
|
||||
isSubscribed = false;
|
||||
|
||||
if (listener.next) {
|
||||
listener.next.prev = listener.prev;
|
||||
} else {
|
||||
last = listener.prev;
|
||||
}
|
||||
|
||||
if (listener.prev) {
|
||||
listener.prev.next = listener.next;
|
||||
} else {
|
||||
first = listener.next;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var nullListeners = {
|
||||
notify: function notify() {},
|
||||
get: function get() {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
export function createSubscription(store, parentSub) {
|
||||
var unsubscribe;
|
||||
var listeners = nullListeners;
|
||||
|
||||
function addNestedSub(listener) {
|
||||
trySubscribe();
|
||||
return listeners.subscribe(listener);
|
||||
}
|
||||
|
||||
function notifyNestedSubs() {
|
||||
listeners.notify();
|
||||
}
|
||||
|
||||
function handleChangeWrapper() {
|
||||
if (subscription.onStateChange) {
|
||||
subscription.onStateChange();
|
||||
}
|
||||
}
|
||||
|
||||
function isSubscribed() {
|
||||
return Boolean(unsubscribe);
|
||||
}
|
||||
|
||||
function trySubscribe() {
|
||||
if (!unsubscribe) {
|
||||
unsubscribe = parentSub ? parentSub.addNestedSub(handleChangeWrapper) : store.subscribe(handleChangeWrapper);
|
||||
listeners = createListenerCollection();
|
||||
}
|
||||
}
|
||||
|
||||
function tryUnsubscribe() {
|
||||
if (unsubscribe) {
|
||||
unsubscribe();
|
||||
unsubscribe = undefined;
|
||||
listeners.clear();
|
||||
listeners = nullListeners;
|
||||
}
|
||||
}
|
||||
|
||||
var subscription = {
|
||||
addNestedSub: addNestedSub,
|
||||
notifyNestedSubs: notifyNestedSubs,
|
||||
handleChangeWrapper: handleChangeWrapper,
|
||||
isSubscribed: isSubscribed,
|
||||
trySubscribe: trySubscribe,
|
||||
tryUnsubscribe: tryUnsubscribe,
|
||||
getListeners: function getListeners() {
|
||||
return listeners;
|
||||
}
|
||||
};
|
||||
return subscription;
|
||||
}
|
||||
14
node_modules/react-redux/es/utils/batch.js
generated
vendored
Normal file
14
node_modules/react-redux/es/utils/batch.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
// Default to a dummy "batch" implementation that just runs the callback
|
||||
function defaultNoopBatch(callback) {
|
||||
callback();
|
||||
}
|
||||
|
||||
var batch = defaultNoopBatch; // Allow injecting another batching function later
|
||||
|
||||
export var setBatch = function setBatch(newBatch) {
|
||||
return batch = newBatch;
|
||||
}; // Supply a getter just to skip dealing with ESM bindings
|
||||
|
||||
export var getBatch = function getBatch() {
|
||||
return batch;
|
||||
};
|
||||
19
node_modules/react-redux/es/utils/bindActionCreators.js
generated
vendored
Normal file
19
node_modules/react-redux/es/utils/bindActionCreators.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
export default function bindActionCreators(actionCreators, dispatch) {
|
||||
var boundActionCreators = {};
|
||||
|
||||
var _loop = function _loop(key) {
|
||||
var actionCreator = actionCreators[key];
|
||||
|
||||
if (typeof actionCreator === 'function') {
|
||||
boundActionCreators[key] = function () {
|
||||
return dispatch(actionCreator.apply(void 0, arguments));
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
for (var key in actionCreators) {
|
||||
_loop(key);
|
||||
}
|
||||
|
||||
return boundActionCreators;
|
||||
}
|
||||
16
node_modules/react-redux/es/utils/isPlainObject.js
generated
vendored
Normal file
16
node_modules/react-redux/es/utils/isPlainObject.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @param {any} obj The object to inspect.
|
||||
* @returns {boolean} True if the argument appears to be a plain object.
|
||||
*/
|
||||
export default function isPlainObject(obj) {
|
||||
if (typeof obj !== 'object' || obj === null) return false;
|
||||
var proto = Object.getPrototypeOf(obj);
|
||||
if (proto === null) return true;
|
||||
var baseProto = proto;
|
||||
|
||||
while (Object.getPrototypeOf(baseProto) !== null) {
|
||||
baseProto = Object.getPrototypeOf(baseProto);
|
||||
}
|
||||
|
||||
return proto === baseProto;
|
||||
}
|
||||
2
node_modules/react-redux/es/utils/reactBatchedUpdates.js
generated
vendored
Normal file
2
node_modules/react-redux/es/utils/reactBatchedUpdates.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/* eslint-disable import/no-unresolved */
|
||||
export { unstable_batchedUpdates } from 'react-dom';
|
||||
3
node_modules/react-redux/es/utils/reactBatchedUpdates.native.js
generated
vendored
Normal file
3
node_modules/react-redux/es/utils/reactBatchedUpdates.native.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/* eslint-disable import/named */
|
||||
import { unstable_batchedUpdates } from 'react-native';
|
||||
export { unstable_batchedUpdates };
|
||||
27
node_modules/react-redux/es/utils/shallowEqual.js
generated
vendored
Normal file
27
node_modules/react-redux/es/utils/shallowEqual.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
function is(x, y) {
|
||||
if (x === y) {
|
||||
return x !== 0 || y !== 0 || 1 / x === 1 / y;
|
||||
} else {
|
||||
return x !== x && y !== y;
|
||||
}
|
||||
}
|
||||
|
||||
export default function shallowEqual(objA, objB) {
|
||||
if (is(objA, objB)) return true;
|
||||
|
||||
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var keysA = Object.keys(objA);
|
||||
var keysB = Object.keys(objB);
|
||||
if (keysA.length !== keysB.length) return false;
|
||||
|
||||
for (var i = 0; i < keysA.length; i++) {
|
||||
if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
10
node_modules/react-redux/es/utils/useIsomorphicLayoutEffect.js
generated
vendored
Normal file
10
node_modules/react-redux/es/utils/useIsomorphicLayoutEffect.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { useEffect, useLayoutEffect } from 'react'; // React currently throws a warning when using useLayoutEffect on the server.
|
||||
// To get around it, we can conditionally useEffect on the server (no-op) and
|
||||
// useLayoutEffect in the browser. We need useLayoutEffect to ensure the store
|
||||
// subscription callback always has the selector from the latest render commit
|
||||
// available, otherwise a store update may happen between render and the effect,
|
||||
// which may cause missed updates; we also must ensure the store subscription
|
||||
// is created synchronously, otherwise a store update may occur before the
|
||||
// subscription is created and an inconsistent state may be observed
|
||||
|
||||
export var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? useLayoutEffect : useEffect;
|
||||
3
node_modules/react-redux/es/utils/useIsomorphicLayoutEffect.native.js
generated
vendored
Normal file
3
node_modules/react-redux/es/utils/useIsomorphicLayoutEffect.native.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { useLayoutEffect } from 'react'; // Under React Native, we know that we always want to use useLayoutEffect
|
||||
|
||||
export var useIsomorphicLayoutEffect = useLayoutEffect;
|
||||
7
node_modules/react-redux/es/utils/verifyPlainObject.js
generated
vendored
Normal file
7
node_modules/react-redux/es/utils/verifyPlainObject.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import isPlainObject from './isPlainObject';
|
||||
import warning from './warning';
|
||||
export default function verifyPlainObject(value, displayName, methodName) {
|
||||
if (!isPlainObject(value)) {
|
||||
warning(methodName + "() in " + displayName + " must return a plain object. Instead received " + value + ".");
|
||||
}
|
||||
}
|
||||
24
node_modules/react-redux/es/utils/warning.js
generated
vendored
Normal file
24
node_modules/react-redux/es/utils/warning.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Prints a warning in the console if it exists.
|
||||
*
|
||||
* @param {String} message The warning message.
|
||||
* @returns {void}
|
||||
*/
|
||||
export default function warning(message) {
|
||||
/* eslint-disable no-console */
|
||||
if (typeof console !== 'undefined' && typeof console.error === 'function') {
|
||||
console.error(message);
|
||||
}
|
||||
/* eslint-enable no-console */
|
||||
|
||||
|
||||
try {
|
||||
// This error was thrown as a convenience so that if you enable
|
||||
// "break on all exceptions" in your console,
|
||||
// it would pause the execution at this line.
|
||||
throw new Error(message);
|
||||
/* eslint-disable no-empty */
|
||||
} catch (e) {}
|
||||
/* eslint-enable no-empty */
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user