Initial commit
This commit is contained in:
784
node_modules/redux/dist/redux.js
generated
vendored
Normal file
784
node_modules/redux/dist/redux.js
generated
vendored
Normal file
@@ -0,0 +1,784 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(factory((global.Redux = global.Redux || {})));
|
||||
}(this, (function (exports) { 'use strict';
|
||||
|
||||
/** Detect free variable `global` from Node.js. */
|
||||
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
||||
|
||||
/** Detect free variable `self`. */
|
||||
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
||||
|
||||
/** Used as a reference to the global object. */
|
||||
var root = freeGlobal || freeSelf || Function('return this')();
|
||||
|
||||
/** Built-in value references. */
|
||||
var Symbol = root.Symbol;
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto$1 = Object.prototype;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* Used to resolve the
|
||||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var nativeObjectToString = objectProto$1.toString;
|
||||
|
||||
/** Built-in value references. */
|
||||
var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined;
|
||||
|
||||
/**
|
||||
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to query.
|
||||
* @returns {string} Returns the raw `toStringTag`.
|
||||
*/
|
||||
function getRawTag(value) {
|
||||
var isOwn = hasOwnProperty$1.call(value, symToStringTag$1),
|
||||
tag = value[symToStringTag$1];
|
||||
|
||||
try {
|
||||
value[symToStringTag$1] = undefined;
|
||||
var unmasked = true;
|
||||
} catch (e) {}
|
||||
|
||||
var result = nativeObjectToString.call(value);
|
||||
if (unmasked) {
|
||||
if (isOwn) {
|
||||
value[symToStringTag$1] = tag;
|
||||
} else {
|
||||
delete value[symToStringTag$1];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto$2 = Object.prototype;
|
||||
|
||||
/**
|
||||
* Used to resolve the
|
||||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var nativeObjectToString$1 = objectProto$2.toString;
|
||||
|
||||
/**
|
||||
* Converts `value` to a string using `Object.prototype.toString`.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to convert.
|
||||
* @returns {string} Returns the converted string.
|
||||
*/
|
||||
function objectToString(value) {
|
||||
return nativeObjectToString$1.call(value);
|
||||
}
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var nullTag = '[object Null]';
|
||||
var undefinedTag = '[object Undefined]';
|
||||
|
||||
/** Built-in value references. */
|
||||
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
||||
|
||||
/**
|
||||
* The base implementation of `getTag` without fallbacks for buggy environments.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to query.
|
||||
* @returns {string} Returns the `toStringTag`.
|
||||
*/
|
||||
function baseGetTag(value) {
|
||||
if (value == null) {
|
||||
return value === undefined ? undefinedTag : nullTag;
|
||||
}
|
||||
return (symToStringTag && symToStringTag in Object(value))
|
||||
? getRawTag(value)
|
||||
: objectToString(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a unary function that invokes `func` with its argument transformed.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} func The function to wrap.
|
||||
* @param {Function} transform The argument transform.
|
||||
* @returns {Function} Returns the new function.
|
||||
*/
|
||||
function overArg(func, transform) {
|
||||
return function(arg) {
|
||||
return func(transform(arg));
|
||||
};
|
||||
}
|
||||
|
||||
/** Built-in value references. */
|
||||
var getPrototype = overArg(Object.getPrototypeOf, Object);
|
||||
|
||||
/**
|
||||
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
||||
* and has a `typeof` result of "object".
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isObjectLike({});
|
||||
* // => true
|
||||
*
|
||||
* _.isObjectLike([1, 2, 3]);
|
||||
* // => true
|
||||
*
|
||||
* _.isObjectLike(_.noop);
|
||||
* // => false
|
||||
*
|
||||
* _.isObjectLike(null);
|
||||
* // => false
|
||||
*/
|
||||
function isObjectLike(value) {
|
||||
return value != null && typeof value == 'object';
|
||||
}
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var objectTag = '[object Object]';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var funcProto = Function.prototype;
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/** Used to resolve the decompiled source of functions. */
|
||||
var funcToString = funcProto.toString;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/** Used to infer the `Object` constructor. */
|
||||
var objectCtorString = funcToString.call(Object);
|
||||
|
||||
/**
|
||||
* Checks if `value` is a plain object, that is, an object created by the
|
||||
* `Object` constructor or one with a `[[Prototype]]` of `null`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.8.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
|
||||
* @example
|
||||
*
|
||||
* function Foo() {
|
||||
* this.a = 1;
|
||||
* }
|
||||
*
|
||||
* _.isPlainObject(new Foo);
|
||||
* // => false
|
||||
*
|
||||
* _.isPlainObject([1, 2, 3]);
|
||||
* // => false
|
||||
*
|
||||
* _.isPlainObject({ 'x': 0, 'y': 0 });
|
||||
* // => true
|
||||
*
|
||||
* _.isPlainObject(Object.create(null));
|
||||
* // => true
|
||||
*/
|
||||
function isPlainObject(value) {
|
||||
if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
|
||||
return false;
|
||||
}
|
||||
var proto = getPrototype(value);
|
||||
if (proto === null) {
|
||||
return true;
|
||||
}
|
||||
var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
|
||||
return typeof Ctor == 'function' && Ctor instanceof Ctor &&
|
||||
funcToString.call(Ctor) == objectCtorString;
|
||||
}
|
||||
|
||||
function symbolObservablePonyfill(root) {
|
||||
var result;
|
||||
var Symbol = root.Symbol;
|
||||
|
||||
if (typeof Symbol === 'function') {
|
||||
if (Symbol.observable) {
|
||||
result = Symbol.observable;
|
||||
} else {
|
||||
result = Symbol('observable');
|
||||
Symbol.observable = result;
|
||||
}
|
||||
} else {
|
||||
result = '@@observable';
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* global window */
|
||||
var root$2;
|
||||
|
||||
if (typeof self !== 'undefined') {
|
||||
root$2 = self;
|
||||
} else if (typeof window !== 'undefined') {
|
||||
root$2 = window;
|
||||
} else if (typeof global !== 'undefined') {
|
||||
root$2 = global;
|
||||
} else if (typeof module !== 'undefined') {
|
||||
root$2 = module;
|
||||
} else {
|
||||
root$2 = Function('return this')();
|
||||
}
|
||||
|
||||
var result = symbolObservablePonyfill(root$2);
|
||||
|
||||
/**
|
||||
* These are private action types reserved by Redux.
|
||||
* For any unknown actions, you must return the current state.
|
||||
* If the current state is undefined, you must return the initial state.
|
||||
* Do not reference these action types directly in your code.
|
||||
*/
|
||||
var ActionTypes = {
|
||||
INIT: '@@redux/INIT'
|
||||
|
||||
/**
|
||||
* Creates a Redux store that holds the state tree.
|
||||
* The only way to change the data in the store is to call `dispatch()` on it.
|
||||
*
|
||||
* There should only be a single store in your app. To specify how different
|
||||
* parts of the state tree respond to actions, you may combine several reducers
|
||||
* into a single reducer function by using `combineReducers`.
|
||||
*
|
||||
* @param {Function} reducer A function that returns the next state tree, given
|
||||
* the current state tree and the action to handle.
|
||||
*
|
||||
* @param {any} [preloadedState] The initial state. You may optionally specify it
|
||||
* to hydrate the state from the server in universal apps, or to restore a
|
||||
* previously serialized user session.
|
||||
* If you use `combineReducers` to produce the root reducer function, this must be
|
||||
* an object with the same shape as `combineReducers` keys.
|
||||
*
|
||||
* @param {Function} [enhancer] The store enhancer. You may optionally specify it
|
||||
* to enhance the store with third-party capabilities such as middleware,
|
||||
* time travel, persistence, etc. The only store enhancer that ships with Redux
|
||||
* is `applyMiddleware()`.
|
||||
*
|
||||
* @returns {Store} A Redux store that lets you read the state, dispatch actions
|
||||
* and subscribe to changes.
|
||||
*/
|
||||
};function createStore(reducer, preloadedState, enhancer) {
|
||||
var _ref2;
|
||||
|
||||
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
|
||||
enhancer = preloadedState;
|
||||
preloadedState = undefined;
|
||||
}
|
||||
|
||||
if (typeof enhancer !== 'undefined') {
|
||||
if (typeof enhancer !== 'function') {
|
||||
throw new Error('Expected the enhancer to be a function.');
|
||||
}
|
||||
|
||||
return enhancer(createStore)(reducer, preloadedState);
|
||||
}
|
||||
|
||||
if (typeof reducer !== 'function') {
|
||||
throw new Error('Expected the reducer to be a function.');
|
||||
}
|
||||
|
||||
var currentReducer = reducer;
|
||||
var currentState = preloadedState;
|
||||
var currentListeners = [];
|
||||
var nextListeners = currentListeners;
|
||||
var isDispatching = false;
|
||||
|
||||
function ensureCanMutateNextListeners() {
|
||||
if (nextListeners === currentListeners) {
|
||||
nextListeners = currentListeners.slice();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the state tree managed by the store.
|
||||
*
|
||||
* @returns {any} The current state tree of your application.
|
||||
*/
|
||||
function getState() {
|
||||
return currentState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a change listener. It will be called any time an action is dispatched,
|
||||
* and some part of the state tree may potentially have changed. You may then
|
||||
* call `getState()` to read the current state tree inside the callback.
|
||||
*
|
||||
* You may call `dispatch()` from a change listener, with the following
|
||||
* caveats:
|
||||
*
|
||||
* 1. The subscriptions are snapshotted just before every `dispatch()` call.
|
||||
* If you subscribe or unsubscribe while the listeners are being invoked, this
|
||||
* will not have any effect on the `dispatch()` that is currently in progress.
|
||||
* However, the next `dispatch()` call, whether nested or not, will use a more
|
||||
* recent snapshot of the subscription list.
|
||||
*
|
||||
* 2. The listener should not expect to see all state changes, as the state
|
||||
* might have been updated multiple times during a nested `dispatch()` before
|
||||
* the listener is called. It is, however, guaranteed that all subscribers
|
||||
* registered before the `dispatch()` started will be called with the latest
|
||||
* state by the time it exits.
|
||||
*
|
||||
* @param {Function} listener A callback to be invoked on every dispatch.
|
||||
* @returns {Function} A function to remove this change listener.
|
||||
*/
|
||||
function subscribe(listener) {
|
||||
if (typeof listener !== 'function') {
|
||||
throw new Error('Expected listener to be a function.');
|
||||
}
|
||||
|
||||
var isSubscribed = true;
|
||||
|
||||
ensureCanMutateNextListeners();
|
||||
nextListeners.push(listener);
|
||||
|
||||
return function unsubscribe() {
|
||||
if (!isSubscribed) {
|
||||
return;
|
||||
}
|
||||
|
||||
isSubscribed = false;
|
||||
|
||||
ensureCanMutateNextListeners();
|
||||
var index = nextListeners.indexOf(listener);
|
||||
nextListeners.splice(index, 1);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches an action. It is the only way to trigger a state change.
|
||||
*
|
||||
* The `reducer` function, used to create the store, will be called with the
|
||||
* current state tree and the given `action`. Its return value will
|
||||
* be considered the **next** state of the tree, and the change listeners
|
||||
* will be notified.
|
||||
*
|
||||
* The base implementation only supports plain object actions. If you want to
|
||||
* dispatch a Promise, an Observable, a thunk, or something else, you need to
|
||||
* wrap your store creating function into the corresponding middleware. For
|
||||
* example, see the documentation for the `redux-thunk` package. Even the
|
||||
* middleware will eventually dispatch plain object actions using this method.
|
||||
*
|
||||
* @param {Object} action A plain object representing “what changed”. It is
|
||||
* a good idea to keep actions serializable so you can record and replay user
|
||||
* sessions, or use the time travelling `redux-devtools`. An action must have
|
||||
* a `type` property which may not be `undefined`. It is a good idea to use
|
||||
* string constants for action types.
|
||||
*
|
||||
* @returns {Object} For convenience, the same action object you dispatched.
|
||||
*
|
||||
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
|
||||
* return something else (for example, a Promise you can await).
|
||||
*/
|
||||
function dispatch(action) {
|
||||
if (!isPlainObject(action)) {
|
||||
throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.');
|
||||
}
|
||||
|
||||
if (typeof action.type === 'undefined') {
|
||||
throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?');
|
||||
}
|
||||
|
||||
if (isDispatching) {
|
||||
throw new Error('Reducers may not dispatch actions.');
|
||||
}
|
||||
|
||||
try {
|
||||
isDispatching = true;
|
||||
currentState = currentReducer(currentState, action);
|
||||
} finally {
|
||||
isDispatching = false;
|
||||
}
|
||||
|
||||
var listeners = currentListeners = nextListeners;
|
||||
for (var i = 0; i < listeners.length; i++) {
|
||||
var listener = listeners[i];
|
||||
listener();
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the reducer currently used by the store to calculate the state.
|
||||
*
|
||||
* You might need this if your app implements code splitting and you want to
|
||||
* load some of the reducers dynamically. You might also need this if you
|
||||
* implement a hot reloading mechanism for Redux.
|
||||
*
|
||||
* @param {Function} nextReducer The reducer for the store to use instead.
|
||||
* @returns {void}
|
||||
*/
|
||||
function replaceReducer(nextReducer) {
|
||||
if (typeof nextReducer !== 'function') {
|
||||
throw new Error('Expected the nextReducer to be a function.');
|
||||
}
|
||||
|
||||
currentReducer = nextReducer;
|
||||
dispatch({ type: ActionTypes.INIT });
|
||||
}
|
||||
|
||||
/**
|
||||
* Interoperability point for observable/reactive libraries.
|
||||
* @returns {observable} A minimal observable of state changes.
|
||||
* For more information, see the observable proposal:
|
||||
* https://github.com/tc39/proposal-observable
|
||||
*/
|
||||
function observable() {
|
||||
var _ref;
|
||||
|
||||
var outerSubscribe = subscribe;
|
||||
return _ref = {
|
||||
/**
|
||||
* The minimal observable subscription method.
|
||||
* @param {Object} observer Any object that can be used as an observer.
|
||||
* The observer object should have a `next` method.
|
||||
* @returns {subscription} An object with an `unsubscribe` method that can
|
||||
* be used to unsubscribe the observable from the store, and prevent further
|
||||
* emission of values from the observable.
|
||||
*/
|
||||
subscribe: function subscribe(observer) {
|
||||
if (typeof observer !== 'object') {
|
||||
throw new TypeError('Expected the observer to be an object.');
|
||||
}
|
||||
|
||||
function observeState() {
|
||||
if (observer.next) {
|
||||
observer.next(getState());
|
||||
}
|
||||
}
|
||||
|
||||
observeState();
|
||||
var unsubscribe = outerSubscribe(observeState);
|
||||
return { unsubscribe: unsubscribe };
|
||||
}
|
||||
}, _ref[result] = function () {
|
||||
return this;
|
||||
}, _ref;
|
||||
}
|
||||
|
||||
// When a store is created, an "INIT" action is dispatched so that every
|
||||
// reducer returns their initial state. This effectively populates
|
||||
// the initial state tree.
|
||||
dispatch({ type: ActionTypes.INIT });
|
||||
|
||||
return _ref2 = {
|
||||
dispatch: dispatch,
|
||||
subscribe: subscribe,
|
||||
getState: getState,
|
||||
replaceReducer: replaceReducer
|
||||
}, _ref2[result] = observable, _ref2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a warning in the console if it exists.
|
||||
*
|
||||
* @param {String} message The warning message.
|
||||
* @returns {void}
|
||||
*/
|
||||
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 */
|
||||
}
|
||||
|
||||
function getUndefinedStateErrorMessage(key, action) {
|
||||
var actionType = action && action.type;
|
||||
var actionName = actionType && '"' + actionType.toString() + '"' || 'an action';
|
||||
|
||||
return 'Given action ' + actionName + ', reducer "' + key + '" returned undefined. ' + 'To ignore an action, you must explicitly return the previous state. ' + 'If you want this reducer to hold no value, you can return null instead of undefined.';
|
||||
}
|
||||
|
||||
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
|
||||
var reducerKeys = Object.keys(reducers);
|
||||
var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
|
||||
|
||||
if (reducerKeys.length === 0) {
|
||||
return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
|
||||
}
|
||||
|
||||
if (!isPlainObject(inputState)) {
|
||||
return 'The ' + argumentName + ' has unexpected type of "' + {}.toString.call(inputState).match(/\s([a-z|A-Z]+)/)[1] + '". Expected argument to be an object with the following ' + ('keys: "' + reducerKeys.join('", "') + '"');
|
||||
}
|
||||
|
||||
var unexpectedKeys = Object.keys(inputState).filter(function (key) {
|
||||
return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
|
||||
});
|
||||
|
||||
unexpectedKeys.forEach(function (key) {
|
||||
unexpectedKeyCache[key] = true;
|
||||
});
|
||||
|
||||
if (unexpectedKeys.length > 0) {
|
||||
return 'Unexpected ' + (unexpectedKeys.length > 1 ? 'keys' : 'key') + ' ' + ('"' + unexpectedKeys.join('", "') + '" found in ' + argumentName + '. ') + 'Expected to find one of the known reducer keys instead: ' + ('"' + reducerKeys.join('", "') + '". Unexpected keys will be ignored.');
|
||||
}
|
||||
}
|
||||
|
||||
function assertReducerShape(reducers) {
|
||||
Object.keys(reducers).forEach(function (key) {
|
||||
var reducer = reducers[key];
|
||||
var initialState = reducer(undefined, { type: ActionTypes.INIT });
|
||||
|
||||
if (typeof initialState === 'undefined') {
|
||||
throw new Error('Reducer "' + key + '" returned undefined during initialization. ' + 'If the state passed to the reducer is undefined, you must ' + 'explicitly return the initial state. The initial state may ' + 'not be undefined. If you don\'t want to set a value for this reducer, ' + 'you can use null instead of undefined.');
|
||||
}
|
||||
|
||||
var type = '@@redux/PROBE_UNKNOWN_ACTION_' + Math.random().toString(36).substring(7).split('').join('.');
|
||||
if (typeof reducer(undefined, { type: type }) === 'undefined') {
|
||||
throw new Error('Reducer "' + key + '" returned undefined when probed with a random type. ' + ('Don\'t try to handle ' + ActionTypes.INIT + ' or other actions in "redux/*" ') + 'namespace. They are considered private. Instead, you must return the ' + 'current state for any unknown actions, unless it is undefined, ' + 'in which case you must return the initial state, regardless of the ' + 'action type. The initial state may not be undefined, but can be null.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns an object whose values are different reducer functions, into a single
|
||||
* reducer function. It will call every child reducer, and gather their results
|
||||
* into a single state object, whose keys correspond to the keys of the passed
|
||||
* reducer functions.
|
||||
*
|
||||
* @param {Object} reducers An object whose values correspond to different
|
||||
* reducer functions that need to be combined into one. One handy way to obtain
|
||||
* it is to use ES6 `import * as reducers` syntax. The reducers may never return
|
||||
* undefined for any action. Instead, they should return their initial state
|
||||
* if the state passed to them was undefined, and the current state for any
|
||||
* unrecognized action.
|
||||
*
|
||||
* @returns {Function} A reducer function that invokes every reducer inside the
|
||||
* passed object, and builds a state object with the same shape.
|
||||
*/
|
||||
function combineReducers(reducers) {
|
||||
var reducerKeys = Object.keys(reducers);
|
||||
var finalReducers = {};
|
||||
for (var i = 0; i < reducerKeys.length; i++) {
|
||||
var key = reducerKeys[i];
|
||||
|
||||
{
|
||||
if (typeof reducers[key] === 'undefined') {
|
||||
warning('No reducer provided for key "' + key + '"');
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof reducers[key] === 'function') {
|
||||
finalReducers[key] = reducers[key];
|
||||
}
|
||||
}
|
||||
var finalReducerKeys = Object.keys(finalReducers);
|
||||
|
||||
var unexpectedKeyCache = void 0;
|
||||
{
|
||||
unexpectedKeyCache = {};
|
||||
}
|
||||
|
||||
var shapeAssertionError = void 0;
|
||||
try {
|
||||
assertReducerShape(finalReducers);
|
||||
} catch (e) {
|
||||
shapeAssertionError = e;
|
||||
}
|
||||
|
||||
return function combination() {
|
||||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var action = arguments[1];
|
||||
|
||||
if (shapeAssertionError) {
|
||||
throw shapeAssertionError;
|
||||
}
|
||||
|
||||
{
|
||||
var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
|
||||
if (warningMessage) {
|
||||
warning(warningMessage);
|
||||
}
|
||||
}
|
||||
|
||||
var hasChanged = false;
|
||||
var nextState = {};
|
||||
for (var _i = 0; _i < finalReducerKeys.length; _i++) {
|
||||
var _key = finalReducerKeys[_i];
|
||||
var reducer = finalReducers[_key];
|
||||
var previousStateForKey = state[_key];
|
||||
var nextStateForKey = reducer(previousStateForKey, action);
|
||||
if (typeof nextStateForKey === 'undefined') {
|
||||
var errorMessage = getUndefinedStateErrorMessage(_key, action);
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
nextState[_key] = nextStateForKey;
|
||||
hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
|
||||
}
|
||||
return hasChanged ? nextState : state;
|
||||
};
|
||||
}
|
||||
|
||||
function bindActionCreator(actionCreator, dispatch) {
|
||||
return function () {
|
||||
return dispatch(actionCreator.apply(undefined, arguments));
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns an object whose values are action creators, into an object with the
|
||||
* same keys, but with every function wrapped into a `dispatch` call so they
|
||||
* may be invoked directly. This is just a convenience method, as you can call
|
||||
* `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
|
||||
*
|
||||
* For convenience, you can also pass a single function as the first argument,
|
||||
* and get a function in return.
|
||||
*
|
||||
* @param {Function|Object} actionCreators An object whose values are action
|
||||
* creator functions. One handy way to obtain it is to use ES6 `import * as`
|
||||
* syntax. You may also pass a single function.
|
||||
*
|
||||
* @param {Function} dispatch The `dispatch` function available on your Redux
|
||||
* store.
|
||||
*
|
||||
* @returns {Function|Object} The object mimicking the original object, but with
|
||||
* every action creator wrapped into the `dispatch` call. If you passed a
|
||||
* function as `actionCreators`, the return value will also be a single
|
||||
* function.
|
||||
*/
|
||||
function bindActionCreators(actionCreators, dispatch) {
|
||||
if (typeof actionCreators === 'function') {
|
||||
return bindActionCreator(actionCreators, dispatch);
|
||||
}
|
||||
|
||||
if (typeof actionCreators !== 'object' || actionCreators === null) {
|
||||
throw new Error('bindActionCreators expected an object or a function, instead received ' + (actionCreators === null ? 'null' : typeof actionCreators) + '. ' + 'Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');
|
||||
}
|
||||
|
||||
var keys = Object.keys(actionCreators);
|
||||
var boundActionCreators = {};
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
var actionCreator = actionCreators[key];
|
||||
if (typeof actionCreator === 'function') {
|
||||
boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
|
||||
}
|
||||
}
|
||||
return boundActionCreators;
|
||||
}
|
||||
|
||||
/**
|
||||
* Composes single-argument functions from right to left. The rightmost
|
||||
* function can take multiple arguments as it provides the signature for
|
||||
* the resulting composite function.
|
||||
*
|
||||
* @param {...Function} funcs The functions to compose.
|
||||
* @returns {Function} A function obtained by composing the argument functions
|
||||
* from right to left. For example, compose(f, g, h) is identical to doing
|
||||
* (...args) => f(g(h(...args))).
|
||||
*/
|
||||
|
||||
function compose() {
|
||||
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
funcs[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
if (funcs.length === 0) {
|
||||
return function (arg) {
|
||||
return arg;
|
||||
};
|
||||
}
|
||||
|
||||
if (funcs.length === 1) {
|
||||
return funcs[0];
|
||||
}
|
||||
|
||||
return funcs.reduce(function (a, b) {
|
||||
return function () {
|
||||
return a(b.apply(undefined, arguments));
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||
|
||||
/**
|
||||
* Creates a store enhancer that applies middleware to the dispatch method
|
||||
* of the Redux store. This is handy for a variety of tasks, such as expressing
|
||||
* asynchronous actions in a concise manner, or logging every action payload.
|
||||
*
|
||||
* See `redux-thunk` package as an example of the Redux middleware.
|
||||
*
|
||||
* Because middleware is potentially asynchronous, this should be the first
|
||||
* store enhancer in the composition chain.
|
||||
*
|
||||
* Note that each middleware will be given the `dispatch` and `getState` functions
|
||||
* as named arguments.
|
||||
*
|
||||
* @param {...Function} middlewares The middleware chain to be applied.
|
||||
* @returns {Function} A store enhancer applying the middleware.
|
||||
*/
|
||||
function applyMiddleware() {
|
||||
for (var _len = arguments.length, middlewares = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
middlewares[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return function (createStore) {
|
||||
return function (reducer, preloadedState, enhancer) {
|
||||
var store = createStore(reducer, preloadedState, enhancer);
|
||||
var _dispatch = store.dispatch;
|
||||
var chain = [];
|
||||
|
||||
var middlewareAPI = {
|
||||
getState: store.getState,
|
||||
dispatch: function dispatch(action) {
|
||||
return _dispatch(action);
|
||||
}
|
||||
};
|
||||
chain = middlewares.map(function (middleware) {
|
||||
return middleware(middlewareAPI);
|
||||
});
|
||||
_dispatch = compose.apply(undefined, chain)(store.dispatch);
|
||||
|
||||
return _extends({}, store, {
|
||||
dispatch: _dispatch
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* This is a dummy function to check if the function name has been altered by minification.
|
||||
* If the function has been minified and NODE_ENV !== 'production', warn the user.
|
||||
*/
|
||||
function isCrushed() {}
|
||||
|
||||
if ("development" !== 'production' && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') {
|
||||
warning('You are currently using minified code outside of NODE_ENV === \'production\'. ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) ' + 'to ensure you have the correct code for your production build.');
|
||||
}
|
||||
|
||||
exports.createStore = createStore;
|
||||
exports.combineReducers = combineReducers;
|
||||
exports.bindActionCreators = bindActionCreators;
|
||||
exports.applyMiddleware = applyMiddleware;
|
||||
exports.compose = compose;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
1
node_modules/redux/dist/redux.min.js
generated
vendored
Normal file
1
node_modules/redux/dist/redux.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
48
node_modules/redux/es/applyMiddleware.js
generated
vendored
Normal file
48
node_modules/redux/es/applyMiddleware.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||
|
||||
import compose from './compose';
|
||||
|
||||
/**
|
||||
* Creates a store enhancer that applies middleware to the dispatch method
|
||||
* of the Redux store. This is handy for a variety of tasks, such as expressing
|
||||
* asynchronous actions in a concise manner, or logging every action payload.
|
||||
*
|
||||
* See `redux-thunk` package as an example of the Redux middleware.
|
||||
*
|
||||
* Because middleware is potentially asynchronous, this should be the first
|
||||
* store enhancer in the composition chain.
|
||||
*
|
||||
* Note that each middleware will be given the `dispatch` and `getState` functions
|
||||
* as named arguments.
|
||||
*
|
||||
* @param {...Function} middlewares The middleware chain to be applied.
|
||||
* @returns {Function} A store enhancer applying the middleware.
|
||||
*/
|
||||
export default function applyMiddleware() {
|
||||
for (var _len = arguments.length, middlewares = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
middlewares[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return function (createStore) {
|
||||
return function (reducer, preloadedState, enhancer) {
|
||||
var store = createStore(reducer, preloadedState, enhancer);
|
||||
var _dispatch = store.dispatch;
|
||||
var chain = [];
|
||||
|
||||
var middlewareAPI = {
|
||||
getState: store.getState,
|
||||
dispatch: function dispatch(action) {
|
||||
return _dispatch(action);
|
||||
}
|
||||
};
|
||||
chain = middlewares.map(function (middleware) {
|
||||
return middleware(middlewareAPI);
|
||||
});
|
||||
_dispatch = compose.apply(undefined, chain)(store.dispatch);
|
||||
|
||||
return _extends({}, store, {
|
||||
dispatch: _dispatch
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
47
node_modules/redux/es/bindActionCreators.js
generated
vendored
Normal file
47
node_modules/redux/es/bindActionCreators.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
function bindActionCreator(actionCreator, dispatch) {
|
||||
return function () {
|
||||
return dispatch(actionCreator.apply(undefined, arguments));
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns an object whose values are action creators, into an object with the
|
||||
* same keys, but with every function wrapped into a `dispatch` call so they
|
||||
* may be invoked directly. This is just a convenience method, as you can call
|
||||
* `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
|
||||
*
|
||||
* For convenience, you can also pass a single function as the first argument,
|
||||
* and get a function in return.
|
||||
*
|
||||
* @param {Function|Object} actionCreators An object whose values are action
|
||||
* creator functions. One handy way to obtain it is to use ES6 `import * as`
|
||||
* syntax. You may also pass a single function.
|
||||
*
|
||||
* @param {Function} dispatch The `dispatch` function available on your Redux
|
||||
* store.
|
||||
*
|
||||
* @returns {Function|Object} The object mimicking the original object, but with
|
||||
* every action creator wrapped into the `dispatch` call. If you passed a
|
||||
* function as `actionCreators`, the return value will also be a single
|
||||
* function.
|
||||
*/
|
||||
export default function bindActionCreators(actionCreators, dispatch) {
|
||||
if (typeof actionCreators === 'function') {
|
||||
return bindActionCreator(actionCreators, dispatch);
|
||||
}
|
||||
|
||||
if (typeof actionCreators !== 'object' || actionCreators === null) {
|
||||
throw new Error('bindActionCreators expected an object or a function, instead received ' + (actionCreators === null ? 'null' : typeof actionCreators) + '. ' + 'Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');
|
||||
}
|
||||
|
||||
var keys = Object.keys(actionCreators);
|
||||
var boundActionCreators = {};
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
var actionCreator = actionCreators[key];
|
||||
if (typeof actionCreator === 'function') {
|
||||
boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
|
||||
}
|
||||
}
|
||||
return boundActionCreators;
|
||||
}
|
||||
130
node_modules/redux/es/combineReducers.js
generated
vendored
Normal file
130
node_modules/redux/es/combineReducers.js
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
import { ActionTypes } from './createStore';
|
||||
import isPlainObject from 'lodash-es/isPlainObject';
|
||||
import warning from './utils/warning';
|
||||
|
||||
function getUndefinedStateErrorMessage(key, action) {
|
||||
var actionType = action && action.type;
|
||||
var actionName = actionType && '"' + actionType.toString() + '"' || 'an action';
|
||||
|
||||
return 'Given action ' + actionName + ', reducer "' + key + '" returned undefined. ' + 'To ignore an action, you must explicitly return the previous state. ' + 'If you want this reducer to hold no value, you can return null instead of undefined.';
|
||||
}
|
||||
|
||||
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
|
||||
var reducerKeys = Object.keys(reducers);
|
||||
var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
|
||||
|
||||
if (reducerKeys.length === 0) {
|
||||
return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
|
||||
}
|
||||
|
||||
if (!isPlainObject(inputState)) {
|
||||
return 'The ' + argumentName + ' has unexpected type of "' + {}.toString.call(inputState).match(/\s([a-z|A-Z]+)/)[1] + '". Expected argument to be an object with the following ' + ('keys: "' + reducerKeys.join('", "') + '"');
|
||||
}
|
||||
|
||||
var unexpectedKeys = Object.keys(inputState).filter(function (key) {
|
||||
return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
|
||||
});
|
||||
|
||||
unexpectedKeys.forEach(function (key) {
|
||||
unexpectedKeyCache[key] = true;
|
||||
});
|
||||
|
||||
if (unexpectedKeys.length > 0) {
|
||||
return 'Unexpected ' + (unexpectedKeys.length > 1 ? 'keys' : 'key') + ' ' + ('"' + unexpectedKeys.join('", "') + '" found in ' + argumentName + '. ') + 'Expected to find one of the known reducer keys instead: ' + ('"' + reducerKeys.join('", "') + '". Unexpected keys will be ignored.');
|
||||
}
|
||||
}
|
||||
|
||||
function assertReducerShape(reducers) {
|
||||
Object.keys(reducers).forEach(function (key) {
|
||||
var reducer = reducers[key];
|
||||
var initialState = reducer(undefined, { type: ActionTypes.INIT });
|
||||
|
||||
if (typeof initialState === 'undefined') {
|
||||
throw new Error('Reducer "' + key + '" returned undefined during initialization. ' + 'If the state passed to the reducer is undefined, you must ' + 'explicitly return the initial state. The initial state may ' + 'not be undefined. If you don\'t want to set a value for this reducer, ' + 'you can use null instead of undefined.');
|
||||
}
|
||||
|
||||
var type = '@@redux/PROBE_UNKNOWN_ACTION_' + Math.random().toString(36).substring(7).split('').join('.');
|
||||
if (typeof reducer(undefined, { type: type }) === 'undefined') {
|
||||
throw new Error('Reducer "' + key + '" returned undefined when probed with a random type. ' + ('Don\'t try to handle ' + ActionTypes.INIT + ' or other actions in "redux/*" ') + 'namespace. They are considered private. Instead, you must return the ' + 'current state for any unknown actions, unless it is undefined, ' + 'in which case you must return the initial state, regardless of the ' + 'action type. The initial state may not be undefined, but can be null.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns an object whose values are different reducer functions, into a single
|
||||
* reducer function. It will call every child reducer, and gather their results
|
||||
* into a single state object, whose keys correspond to the keys of the passed
|
||||
* reducer functions.
|
||||
*
|
||||
* @param {Object} reducers An object whose values correspond to different
|
||||
* reducer functions that need to be combined into one. One handy way to obtain
|
||||
* it is to use ES6 `import * as reducers` syntax. The reducers may never return
|
||||
* undefined for any action. Instead, they should return their initial state
|
||||
* if the state passed to them was undefined, and the current state for any
|
||||
* unrecognized action.
|
||||
*
|
||||
* @returns {Function} A reducer function that invokes every reducer inside the
|
||||
* passed object, and builds a state object with the same shape.
|
||||
*/
|
||||
export default function combineReducers(reducers) {
|
||||
var reducerKeys = Object.keys(reducers);
|
||||
var finalReducers = {};
|
||||
for (var i = 0; i < reducerKeys.length; i++) {
|
||||
var key = reducerKeys[i];
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (typeof reducers[key] === 'undefined') {
|
||||
warning('No reducer provided for key "' + key + '"');
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof reducers[key] === 'function') {
|
||||
finalReducers[key] = reducers[key];
|
||||
}
|
||||
}
|
||||
var finalReducerKeys = Object.keys(finalReducers);
|
||||
|
||||
var unexpectedKeyCache = void 0;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
unexpectedKeyCache = {};
|
||||
}
|
||||
|
||||
var shapeAssertionError = void 0;
|
||||
try {
|
||||
assertReducerShape(finalReducers);
|
||||
} catch (e) {
|
||||
shapeAssertionError = e;
|
||||
}
|
||||
|
||||
return function combination() {
|
||||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var action = arguments[1];
|
||||
|
||||
if (shapeAssertionError) {
|
||||
throw shapeAssertionError;
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
|
||||
if (warningMessage) {
|
||||
warning(warningMessage);
|
||||
}
|
||||
}
|
||||
|
||||
var hasChanged = false;
|
||||
var nextState = {};
|
||||
for (var _i = 0; _i < finalReducerKeys.length; _i++) {
|
||||
var _key = finalReducerKeys[_i];
|
||||
var reducer = finalReducers[_key];
|
||||
var previousStateForKey = state[_key];
|
||||
var nextStateForKey = reducer(previousStateForKey, action);
|
||||
if (typeof nextStateForKey === 'undefined') {
|
||||
var errorMessage = getUndefinedStateErrorMessage(_key, action);
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
nextState[_key] = nextStateForKey;
|
||||
hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
|
||||
}
|
||||
return hasChanged ? nextState : state;
|
||||
};
|
||||
}
|
||||
32
node_modules/redux/es/compose.js
generated
vendored
Normal file
32
node_modules/redux/es/compose.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Composes single-argument functions from right to left. The rightmost
|
||||
* function can take multiple arguments as it provides the signature for
|
||||
* the resulting composite function.
|
||||
*
|
||||
* @param {...Function} funcs The functions to compose.
|
||||
* @returns {Function} A function obtained by composing the argument functions
|
||||
* from right to left. For example, compose(f, g, h) is identical to doing
|
||||
* (...args) => f(g(h(...args))).
|
||||
*/
|
||||
|
||||
export default function compose() {
|
||||
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
funcs[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
if (funcs.length === 0) {
|
||||
return function (arg) {
|
||||
return arg;
|
||||
};
|
||||
}
|
||||
|
||||
if (funcs.length === 1) {
|
||||
return funcs[0];
|
||||
}
|
||||
|
||||
return funcs.reduce(function (a, b) {
|
||||
return function () {
|
||||
return a(b.apply(undefined, arguments));
|
||||
};
|
||||
});
|
||||
}
|
||||
248
node_modules/redux/es/createStore.js
generated
vendored
Normal file
248
node_modules/redux/es/createStore.js
generated
vendored
Normal file
@@ -0,0 +1,248 @@
|
||||
import isPlainObject from 'lodash-es/isPlainObject';
|
||||
import $$observable from 'symbol-observable';
|
||||
|
||||
/**
|
||||
* These are private action types reserved by Redux.
|
||||
* For any unknown actions, you must return the current state.
|
||||
* If the current state is undefined, you must return the initial state.
|
||||
* Do not reference these action types directly in your code.
|
||||
*/
|
||||
export var ActionTypes = {
|
||||
INIT: '@@redux/INIT'
|
||||
|
||||
/**
|
||||
* Creates a Redux store that holds the state tree.
|
||||
* The only way to change the data in the store is to call `dispatch()` on it.
|
||||
*
|
||||
* There should only be a single store in your app. To specify how different
|
||||
* parts of the state tree respond to actions, you may combine several reducers
|
||||
* into a single reducer function by using `combineReducers`.
|
||||
*
|
||||
* @param {Function} reducer A function that returns the next state tree, given
|
||||
* the current state tree and the action to handle.
|
||||
*
|
||||
* @param {any} [preloadedState] The initial state. You may optionally specify it
|
||||
* to hydrate the state from the server in universal apps, or to restore a
|
||||
* previously serialized user session.
|
||||
* If you use `combineReducers` to produce the root reducer function, this must be
|
||||
* an object with the same shape as `combineReducers` keys.
|
||||
*
|
||||
* @param {Function} [enhancer] The store enhancer. You may optionally specify it
|
||||
* to enhance the store with third-party capabilities such as middleware,
|
||||
* time travel, persistence, etc. The only store enhancer that ships with Redux
|
||||
* is `applyMiddleware()`.
|
||||
*
|
||||
* @returns {Store} A Redux store that lets you read the state, dispatch actions
|
||||
* and subscribe to changes.
|
||||
*/
|
||||
};export default function createStore(reducer, preloadedState, enhancer) {
|
||||
var _ref2;
|
||||
|
||||
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
|
||||
enhancer = preloadedState;
|
||||
preloadedState = undefined;
|
||||
}
|
||||
|
||||
if (typeof enhancer !== 'undefined') {
|
||||
if (typeof enhancer !== 'function') {
|
||||
throw new Error('Expected the enhancer to be a function.');
|
||||
}
|
||||
|
||||
return enhancer(createStore)(reducer, preloadedState);
|
||||
}
|
||||
|
||||
if (typeof reducer !== 'function') {
|
||||
throw new Error('Expected the reducer to be a function.');
|
||||
}
|
||||
|
||||
var currentReducer = reducer;
|
||||
var currentState = preloadedState;
|
||||
var currentListeners = [];
|
||||
var nextListeners = currentListeners;
|
||||
var isDispatching = false;
|
||||
|
||||
function ensureCanMutateNextListeners() {
|
||||
if (nextListeners === currentListeners) {
|
||||
nextListeners = currentListeners.slice();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the state tree managed by the store.
|
||||
*
|
||||
* @returns {any} The current state tree of your application.
|
||||
*/
|
||||
function getState() {
|
||||
return currentState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a change listener. It will be called any time an action is dispatched,
|
||||
* and some part of the state tree may potentially have changed. You may then
|
||||
* call `getState()` to read the current state tree inside the callback.
|
||||
*
|
||||
* You may call `dispatch()` from a change listener, with the following
|
||||
* caveats:
|
||||
*
|
||||
* 1. The subscriptions are snapshotted just before every `dispatch()` call.
|
||||
* If you subscribe or unsubscribe while the listeners are being invoked, this
|
||||
* will not have any effect on the `dispatch()` that is currently in progress.
|
||||
* However, the next `dispatch()` call, whether nested or not, will use a more
|
||||
* recent snapshot of the subscription list.
|
||||
*
|
||||
* 2. The listener should not expect to see all state changes, as the state
|
||||
* might have been updated multiple times during a nested `dispatch()` before
|
||||
* the listener is called. It is, however, guaranteed that all subscribers
|
||||
* registered before the `dispatch()` started will be called with the latest
|
||||
* state by the time it exits.
|
||||
*
|
||||
* @param {Function} listener A callback to be invoked on every dispatch.
|
||||
* @returns {Function} A function to remove this change listener.
|
||||
*/
|
||||
function subscribe(listener) {
|
||||
if (typeof listener !== 'function') {
|
||||
throw new Error('Expected listener to be a function.');
|
||||
}
|
||||
|
||||
var isSubscribed = true;
|
||||
|
||||
ensureCanMutateNextListeners();
|
||||
nextListeners.push(listener);
|
||||
|
||||
return function unsubscribe() {
|
||||
if (!isSubscribed) {
|
||||
return;
|
||||
}
|
||||
|
||||
isSubscribed = false;
|
||||
|
||||
ensureCanMutateNextListeners();
|
||||
var index = nextListeners.indexOf(listener);
|
||||
nextListeners.splice(index, 1);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches an action. It is the only way to trigger a state change.
|
||||
*
|
||||
* The `reducer` function, used to create the store, will be called with the
|
||||
* current state tree and the given `action`. Its return value will
|
||||
* be considered the **next** state of the tree, and the change listeners
|
||||
* will be notified.
|
||||
*
|
||||
* The base implementation only supports plain object actions. If you want to
|
||||
* dispatch a Promise, an Observable, a thunk, or something else, you need to
|
||||
* wrap your store creating function into the corresponding middleware. For
|
||||
* example, see the documentation for the `redux-thunk` package. Even the
|
||||
* middleware will eventually dispatch plain object actions using this method.
|
||||
*
|
||||
* @param {Object} action A plain object representing “what changed”. It is
|
||||
* a good idea to keep actions serializable so you can record and replay user
|
||||
* sessions, or use the time travelling `redux-devtools`. An action must have
|
||||
* a `type` property which may not be `undefined`. It is a good idea to use
|
||||
* string constants for action types.
|
||||
*
|
||||
* @returns {Object} For convenience, the same action object you dispatched.
|
||||
*
|
||||
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
|
||||
* return something else (for example, a Promise you can await).
|
||||
*/
|
||||
function dispatch(action) {
|
||||
if (!isPlainObject(action)) {
|
||||
throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.');
|
||||
}
|
||||
|
||||
if (typeof action.type === 'undefined') {
|
||||
throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?');
|
||||
}
|
||||
|
||||
if (isDispatching) {
|
||||
throw new Error('Reducers may not dispatch actions.');
|
||||
}
|
||||
|
||||
try {
|
||||
isDispatching = true;
|
||||
currentState = currentReducer(currentState, action);
|
||||
} finally {
|
||||
isDispatching = false;
|
||||
}
|
||||
|
||||
var listeners = currentListeners = nextListeners;
|
||||
for (var i = 0; i < listeners.length; i++) {
|
||||
var listener = listeners[i];
|
||||
listener();
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the reducer currently used by the store to calculate the state.
|
||||
*
|
||||
* You might need this if your app implements code splitting and you want to
|
||||
* load some of the reducers dynamically. You might also need this if you
|
||||
* implement a hot reloading mechanism for Redux.
|
||||
*
|
||||
* @param {Function} nextReducer The reducer for the store to use instead.
|
||||
* @returns {void}
|
||||
*/
|
||||
function replaceReducer(nextReducer) {
|
||||
if (typeof nextReducer !== 'function') {
|
||||
throw new Error('Expected the nextReducer to be a function.');
|
||||
}
|
||||
|
||||
currentReducer = nextReducer;
|
||||
dispatch({ type: ActionTypes.INIT });
|
||||
}
|
||||
|
||||
/**
|
||||
* Interoperability point for observable/reactive libraries.
|
||||
* @returns {observable} A minimal observable of state changes.
|
||||
* For more information, see the observable proposal:
|
||||
* https://github.com/tc39/proposal-observable
|
||||
*/
|
||||
function observable() {
|
||||
var _ref;
|
||||
|
||||
var outerSubscribe = subscribe;
|
||||
return _ref = {
|
||||
/**
|
||||
* The minimal observable subscription method.
|
||||
* @param {Object} observer Any object that can be used as an observer.
|
||||
* The observer object should have a `next` method.
|
||||
* @returns {subscription} An object with an `unsubscribe` method that can
|
||||
* be used to unsubscribe the observable from the store, and prevent further
|
||||
* emission of values from the observable.
|
||||
*/
|
||||
subscribe: function subscribe(observer) {
|
||||
if (typeof observer !== 'object') {
|
||||
throw new TypeError('Expected the observer to be an object.');
|
||||
}
|
||||
|
||||
function observeState() {
|
||||
if (observer.next) {
|
||||
observer.next(getState());
|
||||
}
|
||||
}
|
||||
|
||||
observeState();
|
||||
var unsubscribe = outerSubscribe(observeState);
|
||||
return { unsubscribe: unsubscribe };
|
||||
}
|
||||
}, _ref[$$observable] = function () {
|
||||
return this;
|
||||
}, _ref;
|
||||
}
|
||||
|
||||
// When a store is created, an "INIT" action is dispatched so that every
|
||||
// reducer returns their initial state. This effectively populates
|
||||
// the initial state tree.
|
||||
dispatch({ type: ActionTypes.INIT });
|
||||
|
||||
return _ref2 = {
|
||||
dispatch: dispatch,
|
||||
subscribe: subscribe,
|
||||
getState: getState,
|
||||
replaceReducer: replaceReducer
|
||||
}, _ref2[$$observable] = observable, _ref2;
|
||||
}
|
||||
18
node_modules/redux/es/index.js
generated
vendored
Normal file
18
node_modules/redux/es/index.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import createStore from './createStore';
|
||||
import combineReducers from './combineReducers';
|
||||
import bindActionCreators from './bindActionCreators';
|
||||
import applyMiddleware from './applyMiddleware';
|
||||
import compose from './compose';
|
||||
import warning from './utils/warning';
|
||||
|
||||
/*
|
||||
* This is a dummy function to check if the function name has been altered by minification.
|
||||
* If the function has been minified and NODE_ENV !== 'production', warn the user.
|
||||
*/
|
||||
function isCrushed() {}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') {
|
||||
warning('You are currently using minified code outside of NODE_ENV === \'production\'. ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) ' + 'to ensure you have the correct code for your production build.');
|
||||
}
|
||||
|
||||
export { createStore, combineReducers, bindActionCreators, applyMiddleware, compose };
|
||||
21
node_modules/redux/es/utils/warning.js
generated
vendored
Normal file
21
node_modules/redux/es/utils/warning.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* 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 */
|
||||
}
|
||||
58
node_modules/redux/lib/applyMiddleware.js
generated
vendored
Normal file
58
node_modules/redux/lib/applyMiddleware.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||
|
||||
exports['default'] = applyMiddleware;
|
||||
|
||||
var _compose = require('./compose');
|
||||
|
||||
var _compose2 = _interopRequireDefault(_compose);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
/**
|
||||
* Creates a store enhancer that applies middleware to the dispatch method
|
||||
* of the Redux store. This is handy for a variety of tasks, such as expressing
|
||||
* asynchronous actions in a concise manner, or logging every action payload.
|
||||
*
|
||||
* See `redux-thunk` package as an example of the Redux middleware.
|
||||
*
|
||||
* Because middleware is potentially asynchronous, this should be the first
|
||||
* store enhancer in the composition chain.
|
||||
*
|
||||
* Note that each middleware will be given the `dispatch` and `getState` functions
|
||||
* as named arguments.
|
||||
*
|
||||
* @param {...Function} middlewares The middleware chain to be applied.
|
||||
* @returns {Function} A store enhancer applying the middleware.
|
||||
*/
|
||||
function applyMiddleware() {
|
||||
for (var _len = arguments.length, middlewares = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
middlewares[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return function (createStore) {
|
||||
return function (reducer, preloadedState, enhancer) {
|
||||
var store = createStore(reducer, preloadedState, enhancer);
|
||||
var _dispatch = store.dispatch;
|
||||
var chain = [];
|
||||
|
||||
var middlewareAPI = {
|
||||
getState: store.getState,
|
||||
dispatch: function dispatch(action) {
|
||||
return _dispatch(action);
|
||||
}
|
||||
};
|
||||
chain = middlewares.map(function (middleware) {
|
||||
return middleware(middlewareAPI);
|
||||
});
|
||||
_dispatch = _compose2['default'].apply(undefined, chain)(store.dispatch);
|
||||
|
||||
return _extends({}, store, {
|
||||
dispatch: _dispatch
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
51
node_modules/redux/lib/bindActionCreators.js
generated
vendored
Normal file
51
node_modules/redux/lib/bindActionCreators.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
exports['default'] = bindActionCreators;
|
||||
function bindActionCreator(actionCreator, dispatch) {
|
||||
return function () {
|
||||
return dispatch(actionCreator.apply(undefined, arguments));
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns an object whose values are action creators, into an object with the
|
||||
* same keys, but with every function wrapped into a `dispatch` call so they
|
||||
* may be invoked directly. This is just a convenience method, as you can call
|
||||
* `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
|
||||
*
|
||||
* For convenience, you can also pass a single function as the first argument,
|
||||
* and get a function in return.
|
||||
*
|
||||
* @param {Function|Object} actionCreators An object whose values are action
|
||||
* creator functions. One handy way to obtain it is to use ES6 `import * as`
|
||||
* syntax. You may also pass a single function.
|
||||
*
|
||||
* @param {Function} dispatch The `dispatch` function available on your Redux
|
||||
* store.
|
||||
*
|
||||
* @returns {Function|Object} The object mimicking the original object, but with
|
||||
* every action creator wrapped into the `dispatch` call. If you passed a
|
||||
* function as `actionCreators`, the return value will also be a single
|
||||
* function.
|
||||
*/
|
||||
function bindActionCreators(actionCreators, dispatch) {
|
||||
if (typeof actionCreators === 'function') {
|
||||
return bindActionCreator(actionCreators, dispatch);
|
||||
}
|
||||
|
||||
if (typeof actionCreators !== 'object' || actionCreators === null) {
|
||||
throw new Error('bindActionCreators expected an object or a function, instead received ' + (actionCreators === null ? 'null' : typeof actionCreators) + '. ' + 'Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');
|
||||
}
|
||||
|
||||
var keys = Object.keys(actionCreators);
|
||||
var boundActionCreators = {};
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
var actionCreator = actionCreators[key];
|
||||
if (typeof actionCreator === 'function') {
|
||||
boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
|
||||
}
|
||||
}
|
||||
return boundActionCreators;
|
||||
}
|
||||
143
node_modules/redux/lib/combineReducers.js
generated
vendored
Normal file
143
node_modules/redux/lib/combineReducers.js
generated
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
exports['default'] = combineReducers;
|
||||
|
||||
var _createStore = require('./createStore');
|
||||
|
||||
var _isPlainObject = require('lodash/isPlainObject');
|
||||
|
||||
var _isPlainObject2 = _interopRequireDefault(_isPlainObject);
|
||||
|
||||
var _warning = require('./utils/warning');
|
||||
|
||||
var _warning2 = _interopRequireDefault(_warning);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
function getUndefinedStateErrorMessage(key, action) {
|
||||
var actionType = action && action.type;
|
||||
var actionName = actionType && '"' + actionType.toString() + '"' || 'an action';
|
||||
|
||||
return 'Given action ' + actionName + ', reducer "' + key + '" returned undefined. ' + 'To ignore an action, you must explicitly return the previous state. ' + 'If you want this reducer to hold no value, you can return null instead of undefined.';
|
||||
}
|
||||
|
||||
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
|
||||
var reducerKeys = Object.keys(reducers);
|
||||
var argumentName = action && action.type === _createStore.ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
|
||||
|
||||
if (reducerKeys.length === 0) {
|
||||
return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
|
||||
}
|
||||
|
||||
if (!(0, _isPlainObject2['default'])(inputState)) {
|
||||
return 'The ' + argumentName + ' has unexpected type of "' + {}.toString.call(inputState).match(/\s([a-z|A-Z]+)/)[1] + '". Expected argument to be an object with the following ' + ('keys: "' + reducerKeys.join('", "') + '"');
|
||||
}
|
||||
|
||||
var unexpectedKeys = Object.keys(inputState).filter(function (key) {
|
||||
return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
|
||||
});
|
||||
|
||||
unexpectedKeys.forEach(function (key) {
|
||||
unexpectedKeyCache[key] = true;
|
||||
});
|
||||
|
||||
if (unexpectedKeys.length > 0) {
|
||||
return 'Unexpected ' + (unexpectedKeys.length > 1 ? 'keys' : 'key') + ' ' + ('"' + unexpectedKeys.join('", "') + '" found in ' + argumentName + '. ') + 'Expected to find one of the known reducer keys instead: ' + ('"' + reducerKeys.join('", "') + '". Unexpected keys will be ignored.');
|
||||
}
|
||||
}
|
||||
|
||||
function assertReducerShape(reducers) {
|
||||
Object.keys(reducers).forEach(function (key) {
|
||||
var reducer = reducers[key];
|
||||
var initialState = reducer(undefined, { type: _createStore.ActionTypes.INIT });
|
||||
|
||||
if (typeof initialState === 'undefined') {
|
||||
throw new Error('Reducer "' + key + '" returned undefined during initialization. ' + 'If the state passed to the reducer is undefined, you must ' + 'explicitly return the initial state. The initial state may ' + 'not be undefined. If you don\'t want to set a value for this reducer, ' + 'you can use null instead of undefined.');
|
||||
}
|
||||
|
||||
var type = '@@redux/PROBE_UNKNOWN_ACTION_' + Math.random().toString(36).substring(7).split('').join('.');
|
||||
if (typeof reducer(undefined, { type: type }) === 'undefined') {
|
||||
throw new Error('Reducer "' + key + '" returned undefined when probed with a random type. ' + ('Don\'t try to handle ' + _createStore.ActionTypes.INIT + ' or other actions in "redux/*" ') + 'namespace. They are considered private. Instead, you must return the ' + 'current state for any unknown actions, unless it is undefined, ' + 'in which case you must return the initial state, regardless of the ' + 'action type. The initial state may not be undefined, but can be null.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns an object whose values are different reducer functions, into a single
|
||||
* reducer function. It will call every child reducer, and gather their results
|
||||
* into a single state object, whose keys correspond to the keys of the passed
|
||||
* reducer functions.
|
||||
*
|
||||
* @param {Object} reducers An object whose values correspond to different
|
||||
* reducer functions that need to be combined into one. One handy way to obtain
|
||||
* it is to use ES6 `import * as reducers` syntax. The reducers may never return
|
||||
* undefined for any action. Instead, they should return their initial state
|
||||
* if the state passed to them was undefined, and the current state for any
|
||||
* unrecognized action.
|
||||
*
|
||||
* @returns {Function} A reducer function that invokes every reducer inside the
|
||||
* passed object, and builds a state object with the same shape.
|
||||
*/
|
||||
function combineReducers(reducers) {
|
||||
var reducerKeys = Object.keys(reducers);
|
||||
var finalReducers = {};
|
||||
for (var i = 0; i < reducerKeys.length; i++) {
|
||||
var key = reducerKeys[i];
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (typeof reducers[key] === 'undefined') {
|
||||
(0, _warning2['default'])('No reducer provided for key "' + key + '"');
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof reducers[key] === 'function') {
|
||||
finalReducers[key] = reducers[key];
|
||||
}
|
||||
}
|
||||
var finalReducerKeys = Object.keys(finalReducers);
|
||||
|
||||
var unexpectedKeyCache = void 0;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
unexpectedKeyCache = {};
|
||||
}
|
||||
|
||||
var shapeAssertionError = void 0;
|
||||
try {
|
||||
assertReducerShape(finalReducers);
|
||||
} catch (e) {
|
||||
shapeAssertionError = e;
|
||||
}
|
||||
|
||||
return function combination() {
|
||||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var action = arguments[1];
|
||||
|
||||
if (shapeAssertionError) {
|
||||
throw shapeAssertionError;
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
|
||||
if (warningMessage) {
|
||||
(0, _warning2['default'])(warningMessage);
|
||||
}
|
||||
}
|
||||
|
||||
var hasChanged = false;
|
||||
var nextState = {};
|
||||
for (var _i = 0; _i < finalReducerKeys.length; _i++) {
|
||||
var _key = finalReducerKeys[_i];
|
||||
var reducer = finalReducers[_key];
|
||||
var previousStateForKey = state[_key];
|
||||
var nextStateForKey = reducer(previousStateForKey, action);
|
||||
if (typeof nextStateForKey === 'undefined') {
|
||||
var errorMessage = getUndefinedStateErrorMessage(_key, action);
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
nextState[_key] = nextStateForKey;
|
||||
hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
|
||||
}
|
||||
return hasChanged ? nextState : state;
|
||||
};
|
||||
}
|
||||
36
node_modules/redux/lib/compose.js
generated
vendored
Normal file
36
node_modules/redux/lib/compose.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = compose;
|
||||
/**
|
||||
* Composes single-argument functions from right to left. The rightmost
|
||||
* function can take multiple arguments as it provides the signature for
|
||||
* the resulting composite function.
|
||||
*
|
||||
* @param {...Function} funcs The functions to compose.
|
||||
* @returns {Function} A function obtained by composing the argument functions
|
||||
* from right to left. For example, compose(f, g, h) is identical to doing
|
||||
* (...args) => f(g(h(...args))).
|
||||
*/
|
||||
|
||||
function compose() {
|
||||
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
funcs[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
if (funcs.length === 0) {
|
||||
return function (arg) {
|
||||
return arg;
|
||||
};
|
||||
}
|
||||
|
||||
if (funcs.length === 1) {
|
||||
return funcs[0];
|
||||
}
|
||||
|
||||
return funcs.reduce(function (a, b) {
|
||||
return function () {
|
||||
return a(b.apply(undefined, arguments));
|
||||
};
|
||||
});
|
||||
}
|
||||
261
node_modules/redux/lib/createStore.js
generated
vendored
Normal file
261
node_modules/redux/lib/createStore.js
generated
vendored
Normal file
@@ -0,0 +1,261 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.ActionTypes = undefined;
|
||||
exports['default'] = createStore;
|
||||
|
||||
var _isPlainObject = require('lodash/isPlainObject');
|
||||
|
||||
var _isPlainObject2 = _interopRequireDefault(_isPlainObject);
|
||||
|
||||
var _symbolObservable = require('symbol-observable');
|
||||
|
||||
var _symbolObservable2 = _interopRequireDefault(_symbolObservable);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
/**
|
||||
* These are private action types reserved by Redux.
|
||||
* For any unknown actions, you must return the current state.
|
||||
* If the current state is undefined, you must return the initial state.
|
||||
* Do not reference these action types directly in your code.
|
||||
*/
|
||||
var ActionTypes = exports.ActionTypes = {
|
||||
INIT: '@@redux/INIT'
|
||||
|
||||
/**
|
||||
* Creates a Redux store that holds the state tree.
|
||||
* The only way to change the data in the store is to call `dispatch()` on it.
|
||||
*
|
||||
* There should only be a single store in your app. To specify how different
|
||||
* parts of the state tree respond to actions, you may combine several reducers
|
||||
* into a single reducer function by using `combineReducers`.
|
||||
*
|
||||
* @param {Function} reducer A function that returns the next state tree, given
|
||||
* the current state tree and the action to handle.
|
||||
*
|
||||
* @param {any} [preloadedState] The initial state. You may optionally specify it
|
||||
* to hydrate the state from the server in universal apps, or to restore a
|
||||
* previously serialized user session.
|
||||
* If you use `combineReducers` to produce the root reducer function, this must be
|
||||
* an object with the same shape as `combineReducers` keys.
|
||||
*
|
||||
* @param {Function} [enhancer] The store enhancer. You may optionally specify it
|
||||
* to enhance the store with third-party capabilities such as middleware,
|
||||
* time travel, persistence, etc. The only store enhancer that ships with Redux
|
||||
* is `applyMiddleware()`.
|
||||
*
|
||||
* @returns {Store} A Redux store that lets you read the state, dispatch actions
|
||||
* and subscribe to changes.
|
||||
*/
|
||||
};function createStore(reducer, preloadedState, enhancer) {
|
||||
var _ref2;
|
||||
|
||||
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
|
||||
enhancer = preloadedState;
|
||||
preloadedState = undefined;
|
||||
}
|
||||
|
||||
if (typeof enhancer !== 'undefined') {
|
||||
if (typeof enhancer !== 'function') {
|
||||
throw new Error('Expected the enhancer to be a function.');
|
||||
}
|
||||
|
||||
return enhancer(createStore)(reducer, preloadedState);
|
||||
}
|
||||
|
||||
if (typeof reducer !== 'function') {
|
||||
throw new Error('Expected the reducer to be a function.');
|
||||
}
|
||||
|
||||
var currentReducer = reducer;
|
||||
var currentState = preloadedState;
|
||||
var currentListeners = [];
|
||||
var nextListeners = currentListeners;
|
||||
var isDispatching = false;
|
||||
|
||||
function ensureCanMutateNextListeners() {
|
||||
if (nextListeners === currentListeners) {
|
||||
nextListeners = currentListeners.slice();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the state tree managed by the store.
|
||||
*
|
||||
* @returns {any} The current state tree of your application.
|
||||
*/
|
||||
function getState() {
|
||||
return currentState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a change listener. It will be called any time an action is dispatched,
|
||||
* and some part of the state tree may potentially have changed. You may then
|
||||
* call `getState()` to read the current state tree inside the callback.
|
||||
*
|
||||
* You may call `dispatch()` from a change listener, with the following
|
||||
* caveats:
|
||||
*
|
||||
* 1. The subscriptions are snapshotted just before every `dispatch()` call.
|
||||
* If you subscribe or unsubscribe while the listeners are being invoked, this
|
||||
* will not have any effect on the `dispatch()` that is currently in progress.
|
||||
* However, the next `dispatch()` call, whether nested or not, will use a more
|
||||
* recent snapshot of the subscription list.
|
||||
*
|
||||
* 2. The listener should not expect to see all state changes, as the state
|
||||
* might have been updated multiple times during a nested `dispatch()` before
|
||||
* the listener is called. It is, however, guaranteed that all subscribers
|
||||
* registered before the `dispatch()` started will be called with the latest
|
||||
* state by the time it exits.
|
||||
*
|
||||
* @param {Function} listener A callback to be invoked on every dispatch.
|
||||
* @returns {Function} A function to remove this change listener.
|
||||
*/
|
||||
function subscribe(listener) {
|
||||
if (typeof listener !== 'function') {
|
||||
throw new Error('Expected listener to be a function.');
|
||||
}
|
||||
|
||||
var isSubscribed = true;
|
||||
|
||||
ensureCanMutateNextListeners();
|
||||
nextListeners.push(listener);
|
||||
|
||||
return function unsubscribe() {
|
||||
if (!isSubscribed) {
|
||||
return;
|
||||
}
|
||||
|
||||
isSubscribed = false;
|
||||
|
||||
ensureCanMutateNextListeners();
|
||||
var index = nextListeners.indexOf(listener);
|
||||
nextListeners.splice(index, 1);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches an action. It is the only way to trigger a state change.
|
||||
*
|
||||
* The `reducer` function, used to create the store, will be called with the
|
||||
* current state tree and the given `action`. Its return value will
|
||||
* be considered the **next** state of the tree, and the change listeners
|
||||
* will be notified.
|
||||
*
|
||||
* The base implementation only supports plain object actions. If you want to
|
||||
* dispatch a Promise, an Observable, a thunk, or something else, you need to
|
||||
* wrap your store creating function into the corresponding middleware. For
|
||||
* example, see the documentation for the `redux-thunk` package. Even the
|
||||
* middleware will eventually dispatch plain object actions using this method.
|
||||
*
|
||||
* @param {Object} action A plain object representing “what changed”. It is
|
||||
* a good idea to keep actions serializable so you can record and replay user
|
||||
* sessions, or use the time travelling `redux-devtools`. An action must have
|
||||
* a `type` property which may not be `undefined`. It is a good idea to use
|
||||
* string constants for action types.
|
||||
*
|
||||
* @returns {Object} For convenience, the same action object you dispatched.
|
||||
*
|
||||
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
|
||||
* return something else (for example, a Promise you can await).
|
||||
*/
|
||||
function dispatch(action) {
|
||||
if (!(0, _isPlainObject2['default'])(action)) {
|
||||
throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.');
|
||||
}
|
||||
|
||||
if (typeof action.type === 'undefined') {
|
||||
throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?');
|
||||
}
|
||||
|
||||
if (isDispatching) {
|
||||
throw new Error('Reducers may not dispatch actions.');
|
||||
}
|
||||
|
||||
try {
|
||||
isDispatching = true;
|
||||
currentState = currentReducer(currentState, action);
|
||||
} finally {
|
||||
isDispatching = false;
|
||||
}
|
||||
|
||||
var listeners = currentListeners = nextListeners;
|
||||
for (var i = 0; i < listeners.length; i++) {
|
||||
var listener = listeners[i];
|
||||
listener();
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the reducer currently used by the store to calculate the state.
|
||||
*
|
||||
* You might need this if your app implements code splitting and you want to
|
||||
* load some of the reducers dynamically. You might also need this if you
|
||||
* implement a hot reloading mechanism for Redux.
|
||||
*
|
||||
* @param {Function} nextReducer The reducer for the store to use instead.
|
||||
* @returns {void}
|
||||
*/
|
||||
function replaceReducer(nextReducer) {
|
||||
if (typeof nextReducer !== 'function') {
|
||||
throw new Error('Expected the nextReducer to be a function.');
|
||||
}
|
||||
|
||||
currentReducer = nextReducer;
|
||||
dispatch({ type: ActionTypes.INIT });
|
||||
}
|
||||
|
||||
/**
|
||||
* Interoperability point for observable/reactive libraries.
|
||||
* @returns {observable} A minimal observable of state changes.
|
||||
* For more information, see the observable proposal:
|
||||
* https://github.com/tc39/proposal-observable
|
||||
*/
|
||||
function observable() {
|
||||
var _ref;
|
||||
|
||||
var outerSubscribe = subscribe;
|
||||
return _ref = {
|
||||
/**
|
||||
* The minimal observable subscription method.
|
||||
* @param {Object} observer Any object that can be used as an observer.
|
||||
* The observer object should have a `next` method.
|
||||
* @returns {subscription} An object with an `unsubscribe` method that can
|
||||
* be used to unsubscribe the observable from the store, and prevent further
|
||||
* emission of values from the observable.
|
||||
*/
|
||||
subscribe: function subscribe(observer) {
|
||||
if (typeof observer !== 'object') {
|
||||
throw new TypeError('Expected the observer to be an object.');
|
||||
}
|
||||
|
||||
function observeState() {
|
||||
if (observer.next) {
|
||||
observer.next(getState());
|
||||
}
|
||||
}
|
||||
|
||||
observeState();
|
||||
var unsubscribe = outerSubscribe(observeState);
|
||||
return { unsubscribe: unsubscribe };
|
||||
}
|
||||
}, _ref[_symbolObservable2['default']] = function () {
|
||||
return this;
|
||||
}, _ref;
|
||||
}
|
||||
|
||||
// When a store is created, an "INIT" action is dispatched so that every
|
||||
// reducer returns their initial state. This effectively populates
|
||||
// the initial state tree.
|
||||
dispatch({ type: ActionTypes.INIT });
|
||||
|
||||
return _ref2 = {
|
||||
dispatch: dispatch,
|
||||
subscribe: subscribe,
|
||||
getState: getState,
|
||||
replaceReducer: replaceReducer
|
||||
}, _ref2[_symbolObservable2['default']] = observable, _ref2;
|
||||
}
|
||||
46
node_modules/redux/lib/index.js
generated
vendored
Normal file
46
node_modules/redux/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.compose = exports.applyMiddleware = exports.bindActionCreators = exports.combineReducers = exports.createStore = undefined;
|
||||
|
||||
var _createStore = require('./createStore');
|
||||
|
||||
var _createStore2 = _interopRequireDefault(_createStore);
|
||||
|
||||
var _combineReducers = require('./combineReducers');
|
||||
|
||||
var _combineReducers2 = _interopRequireDefault(_combineReducers);
|
||||
|
||||
var _bindActionCreators = require('./bindActionCreators');
|
||||
|
||||
var _bindActionCreators2 = _interopRequireDefault(_bindActionCreators);
|
||||
|
||||
var _applyMiddleware = require('./applyMiddleware');
|
||||
|
||||
var _applyMiddleware2 = _interopRequireDefault(_applyMiddleware);
|
||||
|
||||
var _compose = require('./compose');
|
||||
|
||||
var _compose2 = _interopRequireDefault(_compose);
|
||||
|
||||
var _warning = require('./utils/warning');
|
||||
|
||||
var _warning2 = _interopRequireDefault(_warning);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
/*
|
||||
* This is a dummy function to check if the function name has been altered by minification.
|
||||
* If the function has been minified and NODE_ENV !== 'production', warn the user.
|
||||
*/
|
||||
function isCrushed() {}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') {
|
||||
(0, _warning2['default'])('You are currently using minified code outside of NODE_ENV === \'production\'. ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) ' + 'to ensure you have the correct code for your production build.');
|
||||
}
|
||||
|
||||
exports.createStore = _createStore2['default'];
|
||||
exports.combineReducers = _combineReducers2['default'];
|
||||
exports.bindActionCreators = _bindActionCreators2['default'];
|
||||
exports.applyMiddleware = _applyMiddleware2['default'];
|
||||
exports.compose = _compose2['default'];
|
||||
25
node_modules/redux/lib/utils/warning.js
generated
vendored
Normal file
25
node_modules/redux/lib/utils/warning.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
exports['default'] = warning;
|
||||
/**
|
||||
* Prints a warning in the console if it exists.
|
||||
*
|
||||
* @param {String} message The warning message.
|
||||
* @returns {void}
|
||||
*/
|
||||
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 */
|
||||
}
|
||||
96
node_modules/redux/package.json
generated
vendored
Normal file
96
node_modules/redux/package.json
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
{
|
||||
"name": "redux",
|
||||
"version": "3.7.2",
|
||||
"description": "Predictable state container for JavaScript apps",
|
||||
"main": "lib/index.js",
|
||||
"module": "es/index.js",
|
||||
"jsnext:main": "es/index.js",
|
||||
"typings": "./index.d.ts",
|
||||
"files": [
|
||||
"dist",
|
||||
"lib",
|
||||
"es",
|
||||
"src",
|
||||
"index.d.ts"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/reactjs/redux.git"
|
||||
},
|
||||
"authors": [
|
||||
"Dan Abramov <dan.abramov@me.com> (https://github.com/gaearon)",
|
||||
"Andrew Clark <acdlite@me.com> (https://github.com/acdlite)"
|
||||
],
|
||||
"license": "MIT",
|
||||
"homepage": "http://redux.js.org",
|
||||
"dependencies": {
|
||||
"lodash": "^4.2.1",
|
||||
"lodash-es": "^4.2.1",
|
||||
"loose-envify": "^1.1.0",
|
||||
"symbol-observable": "^1.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.3.15",
|
||||
"babel-core": "^6.3.15",
|
||||
"babel-eslint": "^7.0.0",
|
||||
"babel-jest": "^20.0.3",
|
||||
"babel-plugin-check-es2015-constants": "^6.3.13",
|
||||
"babel-plugin-transform-es2015-arrow-functions": "^6.3.13",
|
||||
"babel-plugin-transform-es2015-block-scoped-functions": "^6.3.13",
|
||||
"babel-plugin-transform-es2015-block-scoping": "^6.3.13",
|
||||
"babel-plugin-transform-es2015-classes": "^6.3.13",
|
||||
"babel-plugin-transform-es2015-computed-properties": "^6.3.13",
|
||||
"babel-plugin-transform-es2015-destructuring": "^6.3.13",
|
||||
"babel-plugin-transform-es2015-for-of": "^6.3.13",
|
||||
"babel-plugin-transform-es2015-function-name": "^6.3.13",
|
||||
"babel-plugin-transform-es2015-literals": "^6.3.13",
|
||||
"babel-plugin-transform-es2015-modules-commonjs": "^6.3.13",
|
||||
"babel-plugin-transform-es2015-object-super": "^6.3.13",
|
||||
"babel-plugin-transform-es2015-parameters": "^6.3.13",
|
||||
"babel-plugin-transform-es2015-shorthand-properties": "^6.3.13",
|
||||
"babel-plugin-transform-es2015-spread": "^6.3.13",
|
||||
"babel-plugin-transform-es2015-sticky-regex": "^6.3.13",
|
||||
"babel-plugin-transform-es2015-template-literals": "^6.3.13",
|
||||
"babel-plugin-transform-es2015-unicode-regex": "^6.3.13",
|
||||
"babel-plugin-transform-es3-member-expression-literals": "^6.5.0",
|
||||
"babel-plugin-transform-es3-property-literals": "^6.5.0",
|
||||
"babel-plugin-transform-object-rest-spread": "^6.3.13",
|
||||
"babel-register": "^6.3.13",
|
||||
"cross-env": "^5.0.1",
|
||||
"eslint": "^4.0.0",
|
||||
"eslint-config-react-app": "^1.0.4",
|
||||
"eslint-plugin-flowtype": "^2.29.2",
|
||||
"eslint-plugin-import": "^2.2.0",
|
||||
"eslint-plugin-jsx-a11y": "^5.0.3",
|
||||
"eslint-plugin-react": "^7.1.0",
|
||||
"gitbook-cli": "^2.3.0",
|
||||
"glob": "^7.1.1",
|
||||
"jest": "^20.0.4",
|
||||
"rimraf": "^2.3.4",
|
||||
"rollup": "^0.43.0",
|
||||
"rollup-plugin-babel": "^2.7.1",
|
||||
"rollup-plugin-node-resolve": "^3.0.0",
|
||||
"rollup-plugin-replace": "^1.1.1",
|
||||
"rollup-plugin-uglify": "^2.0.1",
|
||||
"rxjs": "^5.0.0-beta.6",
|
||||
"typescript": "^1.8.0",
|
||||
"typescript-definition-tester": "0.0.4"
|
||||
},
|
||||
"npmName": "redux",
|
||||
"npmFileMap": [
|
||||
{
|
||||
"basePath": "/dist/",
|
||||
"files": [
|
||||
"*.js"
|
||||
]
|
||||
}
|
||||
],
|
||||
"browserify": {
|
||||
"transform": [
|
||||
"loose-envify"
|
||||
]
|
||||
},
|
||||
"jest": {
|
||||
"testRegex": "(/test/.*\\.spec.js)$"
|
||||
}
|
||||
}
|
||||
37
node_modules/redux/src/applyMiddleware.js
generated
vendored
Normal file
37
node_modules/redux/src/applyMiddleware.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import compose from './compose'
|
||||
|
||||
/**
|
||||
* Creates a store enhancer that applies middleware to the dispatch method
|
||||
* of the Redux store. This is handy for a variety of tasks, such as expressing
|
||||
* asynchronous actions in a concise manner, or logging every action payload.
|
||||
*
|
||||
* See `redux-thunk` package as an example of the Redux middleware.
|
||||
*
|
||||
* Because middleware is potentially asynchronous, this should be the first
|
||||
* store enhancer in the composition chain.
|
||||
*
|
||||
* Note that each middleware will be given the `dispatch` and `getState` functions
|
||||
* as named arguments.
|
||||
*
|
||||
* @param {...Function} middlewares The middleware chain to be applied.
|
||||
* @returns {Function} A store enhancer applying the middleware.
|
||||
*/
|
||||
export default function applyMiddleware(...middlewares) {
|
||||
return (createStore) => (reducer, preloadedState, enhancer) => {
|
||||
const store = createStore(reducer, preloadedState, enhancer)
|
||||
let dispatch = store.dispatch
|
||||
let chain = []
|
||||
|
||||
const middlewareAPI = {
|
||||
getState: store.getState,
|
||||
dispatch: (action) => dispatch(action)
|
||||
}
|
||||
chain = middlewares.map(middleware => middleware(middlewareAPI))
|
||||
dispatch = compose(...chain)(store.dispatch)
|
||||
|
||||
return {
|
||||
...store,
|
||||
dispatch
|
||||
}
|
||||
}
|
||||
}
|
||||
48
node_modules/redux/src/bindActionCreators.js
generated
vendored
Normal file
48
node_modules/redux/src/bindActionCreators.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
function bindActionCreator(actionCreator, dispatch) {
|
||||
return (...args) => dispatch(actionCreator(...args))
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns an object whose values are action creators, into an object with the
|
||||
* same keys, but with every function wrapped into a `dispatch` call so they
|
||||
* may be invoked directly. This is just a convenience method, as you can call
|
||||
* `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
|
||||
*
|
||||
* For convenience, you can also pass a single function as the first argument,
|
||||
* and get a function in return.
|
||||
*
|
||||
* @param {Function|Object} actionCreators An object whose values are action
|
||||
* creator functions. One handy way to obtain it is to use ES6 `import * as`
|
||||
* syntax. You may also pass a single function.
|
||||
*
|
||||
* @param {Function} dispatch The `dispatch` function available on your Redux
|
||||
* store.
|
||||
*
|
||||
* @returns {Function|Object} The object mimicking the original object, but with
|
||||
* every action creator wrapped into the `dispatch` call. If you passed a
|
||||
* function as `actionCreators`, the return value will also be a single
|
||||
* function.
|
||||
*/
|
||||
export default function bindActionCreators(actionCreators, dispatch) {
|
||||
if (typeof actionCreators === 'function') {
|
||||
return bindActionCreator(actionCreators, dispatch)
|
||||
}
|
||||
|
||||
if (typeof actionCreators !== 'object' || actionCreators === null) {
|
||||
throw new Error(
|
||||
`bindActionCreators expected an object or a function, instead received ${actionCreators === null ? 'null' : typeof actionCreators}. ` +
|
||||
`Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?`
|
||||
)
|
||||
}
|
||||
|
||||
const keys = Object.keys(actionCreators)
|
||||
const boundActionCreators = {}
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i]
|
||||
const actionCreator = actionCreators[key]
|
||||
if (typeof actionCreator === 'function') {
|
||||
boundActionCreators[key] = bindActionCreator(actionCreator, dispatch)
|
||||
}
|
||||
}
|
||||
return boundActionCreators
|
||||
}
|
||||
160
node_modules/redux/src/combineReducers.js
generated
vendored
Normal file
160
node_modules/redux/src/combineReducers.js
generated
vendored
Normal file
@@ -0,0 +1,160 @@
|
||||
import { ActionTypes } from './createStore'
|
||||
import isPlainObject from 'lodash/isPlainObject'
|
||||
import warning from './utils/warning'
|
||||
|
||||
function getUndefinedStateErrorMessage(key, action) {
|
||||
const actionType = action && action.type
|
||||
const actionName = (actionType && `"${actionType.toString()}"`) || 'an action'
|
||||
|
||||
return (
|
||||
`Given action ${actionName}, reducer "${key}" returned undefined. ` +
|
||||
`To ignore an action, you must explicitly return the previous state. ` +
|
||||
`If you want this reducer to hold no value, you can return null instead of undefined.`
|
||||
)
|
||||
}
|
||||
|
||||
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
|
||||
const reducerKeys = Object.keys(reducers)
|
||||
const argumentName = action && action.type === ActionTypes.INIT ?
|
||||
'preloadedState argument passed to createStore' :
|
||||
'previous state received by the reducer'
|
||||
|
||||
if (reducerKeys.length === 0) {
|
||||
return (
|
||||
'Store does not have a valid reducer. Make sure the argument passed ' +
|
||||
'to combineReducers is an object whose values are reducers.'
|
||||
)
|
||||
}
|
||||
|
||||
if (!isPlainObject(inputState)) {
|
||||
return (
|
||||
`The ${argumentName} has unexpected type of "` +
|
||||
({}).toString.call(inputState).match(/\s([a-z|A-Z]+)/)[1] +
|
||||
`". Expected argument to be an object with the following ` +
|
||||
`keys: "${reducerKeys.join('", "')}"`
|
||||
)
|
||||
}
|
||||
|
||||
const unexpectedKeys = Object.keys(inputState).filter(key =>
|
||||
!reducers.hasOwnProperty(key) &&
|
||||
!unexpectedKeyCache[key]
|
||||
)
|
||||
|
||||
unexpectedKeys.forEach(key => {
|
||||
unexpectedKeyCache[key] = true
|
||||
})
|
||||
|
||||
if (unexpectedKeys.length > 0) {
|
||||
return (
|
||||
`Unexpected ${unexpectedKeys.length > 1 ? 'keys' : 'key'} ` +
|
||||
`"${unexpectedKeys.join('", "')}" found in ${argumentName}. ` +
|
||||
`Expected to find one of the known reducer keys instead: ` +
|
||||
`"${reducerKeys.join('", "')}". Unexpected keys will be ignored.`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function assertReducerShape(reducers) {
|
||||
Object.keys(reducers).forEach(key => {
|
||||
const reducer = reducers[key]
|
||||
const initialState = reducer(undefined, { type: ActionTypes.INIT })
|
||||
|
||||
if (typeof initialState === 'undefined') {
|
||||
throw new Error(
|
||||
`Reducer "${key}" returned undefined during initialization. ` +
|
||||
`If the state passed to the reducer is undefined, you must ` +
|
||||
`explicitly return the initial state. The initial state may ` +
|
||||
`not be undefined. If you don't want to set a value for this reducer, ` +
|
||||
`you can use null instead of undefined.`
|
||||
)
|
||||
}
|
||||
|
||||
const type = '@@redux/PROBE_UNKNOWN_ACTION_' + Math.random().toString(36).substring(7).split('').join('.')
|
||||
if (typeof reducer(undefined, { type }) === 'undefined') {
|
||||
throw new Error(
|
||||
`Reducer "${key}" returned undefined when probed with a random type. ` +
|
||||
`Don't try to handle ${ActionTypes.INIT} or other actions in "redux/*" ` +
|
||||
`namespace. They are considered private. Instead, you must return the ` +
|
||||
`current state for any unknown actions, unless it is undefined, ` +
|
||||
`in which case you must return the initial state, regardless of the ` +
|
||||
`action type. The initial state may not be undefined, but can be null.`
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns an object whose values are different reducer functions, into a single
|
||||
* reducer function. It will call every child reducer, and gather their results
|
||||
* into a single state object, whose keys correspond to the keys of the passed
|
||||
* reducer functions.
|
||||
*
|
||||
* @param {Object} reducers An object whose values correspond to different
|
||||
* reducer functions that need to be combined into one. One handy way to obtain
|
||||
* it is to use ES6 `import * as reducers` syntax. The reducers may never return
|
||||
* undefined for any action. Instead, they should return their initial state
|
||||
* if the state passed to them was undefined, and the current state for any
|
||||
* unrecognized action.
|
||||
*
|
||||
* @returns {Function} A reducer function that invokes every reducer inside the
|
||||
* passed object, and builds a state object with the same shape.
|
||||
*/
|
||||
export default function combineReducers(reducers) {
|
||||
const reducerKeys = Object.keys(reducers)
|
||||
const finalReducers = {}
|
||||
for (let i = 0; i < reducerKeys.length; i++) {
|
||||
const key = reducerKeys[i]
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (typeof reducers[key] === 'undefined') {
|
||||
warning(`No reducer provided for key "${key}"`)
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof reducers[key] === 'function') {
|
||||
finalReducers[key] = reducers[key]
|
||||
}
|
||||
}
|
||||
const finalReducerKeys = Object.keys(finalReducers)
|
||||
|
||||
let unexpectedKeyCache
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
unexpectedKeyCache = {}
|
||||
}
|
||||
|
||||
let shapeAssertionError
|
||||
try {
|
||||
assertReducerShape(finalReducers)
|
||||
} catch (e) {
|
||||
shapeAssertionError = e
|
||||
}
|
||||
|
||||
return function combination(state = {}, action) {
|
||||
if (shapeAssertionError) {
|
||||
throw shapeAssertionError
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache)
|
||||
if (warningMessage) {
|
||||
warning(warningMessage)
|
||||
}
|
||||
}
|
||||
|
||||
let hasChanged = false
|
||||
const nextState = {}
|
||||
for (let i = 0; i < finalReducerKeys.length; i++) {
|
||||
const key = finalReducerKeys[i]
|
||||
const reducer = finalReducers[key]
|
||||
const previousStateForKey = state[key]
|
||||
const nextStateForKey = reducer(previousStateForKey, action)
|
||||
if (typeof nextStateForKey === 'undefined') {
|
||||
const errorMessage = getUndefinedStateErrorMessage(key, action)
|
||||
throw new Error(errorMessage)
|
||||
}
|
||||
nextState[key] = nextStateForKey
|
||||
hasChanged = hasChanged || nextStateForKey !== previousStateForKey
|
||||
}
|
||||
return hasChanged ? nextState : state
|
||||
}
|
||||
}
|
||||
22
node_modules/redux/src/compose.js
generated
vendored
Normal file
22
node_modules/redux/src/compose.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Composes single-argument functions from right to left. The rightmost
|
||||
* function can take multiple arguments as it provides the signature for
|
||||
* the resulting composite function.
|
||||
*
|
||||
* @param {...Function} funcs The functions to compose.
|
||||
* @returns {Function} A function obtained by composing the argument functions
|
||||
* from right to left. For example, compose(f, g, h) is identical to doing
|
||||
* (...args) => f(g(h(...args))).
|
||||
*/
|
||||
|
||||
export default function compose(...funcs) {
|
||||
if (funcs.length === 0) {
|
||||
return arg => arg
|
||||
}
|
||||
|
||||
if (funcs.length === 1) {
|
||||
return funcs[0]
|
||||
}
|
||||
|
||||
return funcs.reduce((a, b) => (...args) => a(b(...args)))
|
||||
}
|
||||
254
node_modules/redux/src/createStore.js
generated
vendored
Normal file
254
node_modules/redux/src/createStore.js
generated
vendored
Normal file
@@ -0,0 +1,254 @@
|
||||
import isPlainObject from 'lodash/isPlainObject'
|
||||
import $$observable from 'symbol-observable'
|
||||
|
||||
/**
|
||||
* These are private action types reserved by Redux.
|
||||
* For any unknown actions, you must return the current state.
|
||||
* If the current state is undefined, you must return the initial state.
|
||||
* Do not reference these action types directly in your code.
|
||||
*/
|
||||
export const ActionTypes = {
|
||||
INIT: '@@redux/INIT'
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Redux store that holds the state tree.
|
||||
* The only way to change the data in the store is to call `dispatch()` on it.
|
||||
*
|
||||
* There should only be a single store in your app. To specify how different
|
||||
* parts of the state tree respond to actions, you may combine several reducers
|
||||
* into a single reducer function by using `combineReducers`.
|
||||
*
|
||||
* @param {Function} reducer A function that returns the next state tree, given
|
||||
* the current state tree and the action to handle.
|
||||
*
|
||||
* @param {any} [preloadedState] The initial state. You may optionally specify it
|
||||
* to hydrate the state from the server in universal apps, or to restore a
|
||||
* previously serialized user session.
|
||||
* If you use `combineReducers` to produce the root reducer function, this must be
|
||||
* an object with the same shape as `combineReducers` keys.
|
||||
*
|
||||
* @param {Function} [enhancer] The store enhancer. You may optionally specify it
|
||||
* to enhance the store with third-party capabilities such as middleware,
|
||||
* time travel, persistence, etc. The only store enhancer that ships with Redux
|
||||
* is `applyMiddleware()`.
|
||||
*
|
||||
* @returns {Store} A Redux store that lets you read the state, dispatch actions
|
||||
* and subscribe to changes.
|
||||
*/
|
||||
export default function createStore(reducer, preloadedState, enhancer) {
|
||||
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
|
||||
enhancer = preloadedState
|
||||
preloadedState = undefined
|
||||
}
|
||||
|
||||
if (typeof enhancer !== 'undefined') {
|
||||
if (typeof enhancer !== 'function') {
|
||||
throw new Error('Expected the enhancer to be a function.')
|
||||
}
|
||||
|
||||
return enhancer(createStore)(reducer, preloadedState)
|
||||
}
|
||||
|
||||
if (typeof reducer !== 'function') {
|
||||
throw new Error('Expected the reducer to be a function.')
|
||||
}
|
||||
|
||||
let currentReducer = reducer
|
||||
let currentState = preloadedState
|
||||
let currentListeners = []
|
||||
let nextListeners = currentListeners
|
||||
let isDispatching = false
|
||||
|
||||
function ensureCanMutateNextListeners() {
|
||||
if (nextListeners === currentListeners) {
|
||||
nextListeners = currentListeners.slice()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the state tree managed by the store.
|
||||
*
|
||||
* @returns {any} The current state tree of your application.
|
||||
*/
|
||||
function getState() {
|
||||
return currentState
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a change listener. It will be called any time an action is dispatched,
|
||||
* and some part of the state tree may potentially have changed. You may then
|
||||
* call `getState()` to read the current state tree inside the callback.
|
||||
*
|
||||
* You may call `dispatch()` from a change listener, with the following
|
||||
* caveats:
|
||||
*
|
||||
* 1. The subscriptions are snapshotted just before every `dispatch()` call.
|
||||
* If you subscribe or unsubscribe while the listeners are being invoked, this
|
||||
* will not have any effect on the `dispatch()` that is currently in progress.
|
||||
* However, the next `dispatch()` call, whether nested or not, will use a more
|
||||
* recent snapshot of the subscription list.
|
||||
*
|
||||
* 2. The listener should not expect to see all state changes, as the state
|
||||
* might have been updated multiple times during a nested `dispatch()` before
|
||||
* the listener is called. It is, however, guaranteed that all subscribers
|
||||
* registered before the `dispatch()` started will be called with the latest
|
||||
* state by the time it exits.
|
||||
*
|
||||
* @param {Function} listener A callback to be invoked on every dispatch.
|
||||
* @returns {Function} A function to remove this change listener.
|
||||
*/
|
||||
function subscribe(listener) {
|
||||
if (typeof listener !== 'function') {
|
||||
throw new Error('Expected listener to be a function.')
|
||||
}
|
||||
|
||||
let isSubscribed = true
|
||||
|
||||
ensureCanMutateNextListeners()
|
||||
nextListeners.push(listener)
|
||||
|
||||
return function unsubscribe() {
|
||||
if (!isSubscribed) {
|
||||
return
|
||||
}
|
||||
|
||||
isSubscribed = false
|
||||
|
||||
ensureCanMutateNextListeners()
|
||||
const index = nextListeners.indexOf(listener)
|
||||
nextListeners.splice(index, 1)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches an action. It is the only way to trigger a state change.
|
||||
*
|
||||
* The `reducer` function, used to create the store, will be called with the
|
||||
* current state tree and the given `action`. Its return value will
|
||||
* be considered the **next** state of the tree, and the change listeners
|
||||
* will be notified.
|
||||
*
|
||||
* The base implementation only supports plain object actions. If you want to
|
||||
* dispatch a Promise, an Observable, a thunk, or something else, you need to
|
||||
* wrap your store creating function into the corresponding middleware. For
|
||||
* example, see the documentation for the `redux-thunk` package. Even the
|
||||
* middleware will eventually dispatch plain object actions using this method.
|
||||
*
|
||||
* @param {Object} action A plain object representing “what changed”. It is
|
||||
* a good idea to keep actions serializable so you can record and replay user
|
||||
* sessions, or use the time travelling `redux-devtools`. An action must have
|
||||
* a `type` property which may not be `undefined`. It is a good idea to use
|
||||
* string constants for action types.
|
||||
*
|
||||
* @returns {Object} For convenience, the same action object you dispatched.
|
||||
*
|
||||
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
|
||||
* return something else (for example, a Promise you can await).
|
||||
*/
|
||||
function dispatch(action) {
|
||||
if (!isPlainObject(action)) {
|
||||
throw new Error(
|
||||
'Actions must be plain objects. ' +
|
||||
'Use custom middleware for async actions.'
|
||||
)
|
||||
}
|
||||
|
||||
if (typeof action.type === 'undefined') {
|
||||
throw new Error(
|
||||
'Actions may not have an undefined "type" property. ' +
|
||||
'Have you misspelled a constant?'
|
||||
)
|
||||
}
|
||||
|
||||
if (isDispatching) {
|
||||
throw new Error('Reducers may not dispatch actions.')
|
||||
}
|
||||
|
||||
try {
|
||||
isDispatching = true
|
||||
currentState = currentReducer(currentState, action)
|
||||
} finally {
|
||||
isDispatching = false
|
||||
}
|
||||
|
||||
const listeners = currentListeners = nextListeners
|
||||
for (let i = 0; i < listeners.length; i++) {
|
||||
const listener = listeners[i]
|
||||
listener()
|
||||
}
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the reducer currently used by the store to calculate the state.
|
||||
*
|
||||
* You might need this if your app implements code splitting and you want to
|
||||
* load some of the reducers dynamically. You might also need this if you
|
||||
* implement a hot reloading mechanism for Redux.
|
||||
*
|
||||
* @param {Function} nextReducer The reducer for the store to use instead.
|
||||
* @returns {void}
|
||||
*/
|
||||
function replaceReducer(nextReducer) {
|
||||
if (typeof nextReducer !== 'function') {
|
||||
throw new Error('Expected the nextReducer to be a function.')
|
||||
}
|
||||
|
||||
currentReducer = nextReducer
|
||||
dispatch({ type: ActionTypes.INIT })
|
||||
}
|
||||
|
||||
/**
|
||||
* Interoperability point for observable/reactive libraries.
|
||||
* @returns {observable} A minimal observable of state changes.
|
||||
* For more information, see the observable proposal:
|
||||
* https://github.com/tc39/proposal-observable
|
||||
*/
|
||||
function observable() {
|
||||
const outerSubscribe = subscribe
|
||||
return {
|
||||
/**
|
||||
* The minimal observable subscription method.
|
||||
* @param {Object} observer Any object that can be used as an observer.
|
||||
* The observer object should have a `next` method.
|
||||
* @returns {subscription} An object with an `unsubscribe` method that can
|
||||
* be used to unsubscribe the observable from the store, and prevent further
|
||||
* emission of values from the observable.
|
||||
*/
|
||||
subscribe(observer) {
|
||||
if (typeof observer !== 'object') {
|
||||
throw new TypeError('Expected the observer to be an object.')
|
||||
}
|
||||
|
||||
function observeState() {
|
||||
if (observer.next) {
|
||||
observer.next(getState())
|
||||
}
|
||||
}
|
||||
|
||||
observeState()
|
||||
const unsubscribe = outerSubscribe(observeState)
|
||||
return { unsubscribe }
|
||||
},
|
||||
|
||||
[$$observable]() {
|
||||
return this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// When a store is created, an "INIT" action is dispatched so that every
|
||||
// reducer returns their initial state. This effectively populates
|
||||
// the initial state tree.
|
||||
dispatch({ type: ActionTypes.INIT })
|
||||
|
||||
return {
|
||||
dispatch,
|
||||
subscribe,
|
||||
getState,
|
||||
replaceReducer,
|
||||
[$$observable]: observable
|
||||
}
|
||||
}
|
||||
34
node_modules/redux/src/index.js
generated
vendored
Normal file
34
node_modules/redux/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import createStore from './createStore'
|
||||
import combineReducers from './combineReducers'
|
||||
import bindActionCreators from './bindActionCreators'
|
||||
import applyMiddleware from './applyMiddleware'
|
||||
import compose from './compose'
|
||||
import warning from './utils/warning'
|
||||
|
||||
/*
|
||||
* This is a dummy function to check if the function name has been altered by minification.
|
||||
* If the function has been minified and NODE_ENV !== 'production', warn the user.
|
||||
*/
|
||||
function isCrushed() {}
|
||||
|
||||
if (
|
||||
process.env.NODE_ENV !== 'production' &&
|
||||
typeof isCrushed.name === 'string' &&
|
||||
isCrushed.name !== 'isCrushed'
|
||||
) {
|
||||
warning(
|
||||
'You are currently using minified code outside of NODE_ENV === \'production\'. ' +
|
||||
'This means that you are running a slower development build of Redux. ' +
|
||||
'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' +
|
||||
'or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) ' +
|
||||
'to ensure you have the correct code for your production build.'
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
createStore,
|
||||
combineReducers,
|
||||
bindActionCreators,
|
||||
applyMiddleware,
|
||||
compose
|
||||
}
|
||||
21
node_modules/redux/src/utils/warning.js
generated
vendored
Normal file
21
node_modules/redux/src/utils/warning.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* 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