Comparing version 3.6.0 to 3.7.0
1527
dist/redux.js
@@ -1,945 +0,786 @@ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(); | ||
else if(typeof define === 'function' && define.amd) | ||
define([], factory); | ||
else if(typeof exports === 'object') | ||
exports["Redux"] = factory(); | ||
else | ||
root["Redux"] = factory(); | ||
})(this, function() { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
(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'; | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/** Detect free variable `global` from Node.js. */ | ||
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/** Detect free variable `self`. */ | ||
var freeSelf = typeof self == 'object' && self && self.Object === Object && self; | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ }; | ||
/** Used as a reference to the global object. */ | ||
var root = freeGlobal || freeSelf || Function('return this')(); | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/** Built-in value references. */ | ||
var Symbol = root.Symbol; | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/** Used for built-in method references. */ | ||
var objectProto$1 = Object.prototype; | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/** 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; | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/** Built-in value references. */ | ||
var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined; | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/** | ||
* 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]; | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
try { | ||
value[symToStringTag$1] = undefined; | ||
var unmasked = true; | ||
} catch (e) {} | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var result = nativeObjectToString.call(value); | ||
if (unmasked) { | ||
if (isOwn) { | ||
value[symToStringTag$1] = tag; | ||
} else { | ||
delete value[symToStringTag$1]; | ||
} | ||
} | ||
return result; | ||
} | ||
'use strict'; | ||
/** Used for built-in method references. */ | ||
var objectProto$2 = Object.prototype; | ||
exports.__esModule = true; | ||
exports.compose = exports.applyMiddleware = exports.bindActionCreators = exports.combineReducers = exports.createStore = undefined; | ||
/** | ||
* 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; | ||
var _createStore = __webpack_require__(2); | ||
/** | ||
* 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); | ||
} | ||
var _createStore2 = _interopRequireDefault(_createStore); | ||
/** `Object#toString` result references. */ | ||
var nullTag = '[object Null]'; | ||
var undefinedTag = '[object Undefined]'; | ||
var _combineReducers = __webpack_require__(7); | ||
/** Built-in value references. */ | ||
var symToStringTag = Symbol ? Symbol.toStringTag : undefined; | ||
var _combineReducers2 = _interopRequireDefault(_combineReducers); | ||
/** | ||
* 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); | ||
} | ||
var _bindActionCreators = __webpack_require__(6); | ||
/** | ||
* 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)); | ||
}; | ||
} | ||
var _bindActionCreators2 = _interopRequireDefault(_bindActionCreators); | ||
/** Built-in value references. */ | ||
var getPrototype = overArg(Object.getPrototypeOf, Object); | ||
var _applyMiddleware = __webpack_require__(5); | ||
/** | ||
* 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'; | ||
} | ||
var _applyMiddleware2 = _interopRequireDefault(_applyMiddleware); | ||
/** `Object#toString` result references. */ | ||
var objectTag = '[object Object]'; | ||
var _compose = __webpack_require__(1); | ||
/** Used for built-in method references. */ | ||
var funcProto = Function.prototype; | ||
var objectProto = Object.prototype; | ||
var _compose2 = _interopRequireDefault(_compose); | ||
/** Used to resolve the decompiled source of functions. */ | ||
var funcToString = funcProto.toString; | ||
var _warning = __webpack_require__(3); | ||
/** Used to check objects for own properties. */ | ||
var hasOwnProperty = objectProto.hasOwnProperty; | ||
var _warning2 = _interopRequireDefault(_warning); | ||
/** Used to infer the `Object` constructor. */ | ||
var objectCtorString = funcToString.call(Object); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
/** | ||
* 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; | ||
} | ||
/* | ||
* 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() {} | ||
function symbolObservablePonyfill(root) { | ||
var result; | ||
var Symbol = root.Symbol; | ||
if (("development") !== '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.'); | ||
if (typeof Symbol === 'function') { | ||
if (Symbol.observable) { | ||
result = Symbol.observable; | ||
} else { | ||
result = Symbol('observable'); | ||
Symbol.observable = result; | ||
} | ||
} else { | ||
result = '@@observable'; | ||
} | ||
exports.createStore = _createStore2['default']; | ||
exports.combineReducers = _combineReducers2['default']; | ||
exports.bindActionCreators = _bindActionCreators2['default']; | ||
exports.applyMiddleware = _applyMiddleware2['default']; | ||
exports.compose = _compose2['default']; | ||
return result; | ||
} | ||
/***/ }, | ||
/* 1 */ | ||
/***/ function(module, exports) { | ||
/* global window */ | ||
var root$2; | ||
"use strict"; | ||
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')(); | ||
} | ||
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))). | ||
*/ | ||
var result = symbolObservablePonyfill(root$2); | ||
function compose() { | ||
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) { | ||
funcs[_key] = arguments[_key]; | ||
} | ||
/** | ||
* 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' | ||
if (funcs.length === 0) { | ||
return function (arg) { | ||
return arg; | ||
}; | ||
} | ||
/** | ||
* 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 (funcs.length === 1) { | ||
return funcs[0]; | ||
} | ||
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') { | ||
enhancer = preloadedState; | ||
preloadedState = undefined; | ||
} | ||
var last = funcs[funcs.length - 1]; | ||
var rest = funcs.slice(0, -1); | ||
return function () { | ||
return rest.reduceRight(function (composed, f) { | ||
return f(composed); | ||
}, last.apply(undefined, arguments)); | ||
}; | ||
} | ||
if (typeof enhancer !== 'undefined') { | ||
if (typeof enhancer !== 'function') { | ||
throw new Error('Expected the enhancer to be a function.'); | ||
} | ||
/***/ }, | ||
/* 2 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
return enhancer(createStore)(reducer, preloadedState); | ||
} | ||
'use strict'; | ||
if (typeof reducer !== 'function') { | ||
throw new Error('Expected the reducer to be a function.'); | ||
} | ||
exports.__esModule = true; | ||
exports.ActionTypes = undefined; | ||
exports['default'] = createStore; | ||
var currentReducer = reducer; | ||
var currentState = preloadedState; | ||
var currentListeners = []; | ||
var nextListeners = currentListeners; | ||
var isDispatching = false; | ||
var _isPlainObject = __webpack_require__(4); | ||
function ensureCanMutateNextListeners() { | ||
if (nextListeners === currentListeners) { | ||
nextListeners = currentListeners.slice(); | ||
} | ||
} | ||
var _isPlainObject2 = _interopRequireDefault(_isPlainObject); | ||
/** | ||
* Reads the state tree managed by the store. | ||
* | ||
* @returns {any} The current state tree of your application. | ||
*/ | ||
function getState() { | ||
return currentState; | ||
} | ||
var _symbolObservable = __webpack_require__(12); | ||
/** | ||
* 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 _symbolObservable2 = _interopRequireDefault(_symbolObservable); | ||
var isSubscribed = true; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
ensureCanMutateNextListeners(); | ||
nextListeners.push(listener); | ||
/** | ||
* 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' | ||
}; | ||
return function unsubscribe() { | ||
if (!isSubscribed) { | ||
return; | ||
} | ||
/** | ||
* 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; | ||
isSubscribed = false; | ||
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') { | ||
enhancer = preloadedState; | ||
preloadedState = undefined; | ||
} | ||
ensureCanMutateNextListeners(); | ||
var index = nextListeners.indexOf(listener); | ||
nextListeners.splice(index, 1); | ||
}; | ||
} | ||
if (typeof enhancer !== 'undefined') { | ||
if (typeof enhancer !== 'function') { | ||
throw new Error('Expected the enhancer to be a function.'); | ||
} | ||
/** | ||
* 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.'); | ||
} | ||
return enhancer(createStore)(reducer, preloadedState); | ||
} | ||
if (typeof action.type === 'undefined') { | ||
throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?'); | ||
} | ||
if (typeof reducer !== 'function') { | ||
throw new Error('Expected the reducer to be a function.'); | ||
} | ||
if (isDispatching) { | ||
throw new Error('Reducers may not dispatch actions.'); | ||
} | ||
var currentReducer = reducer; | ||
var currentState = preloadedState; | ||
var currentListeners = []; | ||
var nextListeners = currentListeners; | ||
var isDispatching = false; | ||
try { | ||
isDispatching = true; | ||
currentState = currentReducer(currentState, action); | ||
} finally { | ||
isDispatching = false; | ||
} | ||
function ensureCanMutateNextListeners() { | ||
if (nextListeners === currentListeners) { | ||
nextListeners = currentListeners.slice(); | ||
} | ||
} | ||
var listeners = currentListeners = nextListeners; | ||
for (var i = 0; i < listeners.length; i++) { | ||
var listener = listeners[i]; | ||
listener(); | ||
} | ||
/** | ||
* Reads the state tree managed by the store. | ||
* | ||
* @returns {any} The current state tree of your application. | ||
*/ | ||
function getState() { | ||
return currentState; | ||
} | ||
return action; | ||
} | ||
/** | ||
* 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.'); | ||
} | ||
/** | ||
* 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.'); | ||
} | ||
var isSubscribed = true; | ||
currentReducer = nextReducer; | ||
dispatch({ type: ActionTypes.INIT }); | ||
} | ||
ensureCanMutateNextListeners(); | ||
nextListeners.push(listener); | ||
/** | ||
* 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; | ||
return function unsubscribe() { | ||
if (!isSubscribed) { | ||
return; | ||
} | ||
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.'); | ||
} | ||
isSubscribed = false; | ||
function observeState() { | ||
if (observer.next) { | ||
observer.next(getState()); | ||
} | ||
} | ||
ensureCanMutateNextListeners(); | ||
var index = nextListeners.indexOf(listener); | ||
nextListeners.splice(index, 1); | ||
}; | ||
} | ||
observeState(); | ||
var unsubscribe = outerSubscribe(observeState); | ||
return { unsubscribe: unsubscribe }; | ||
} | ||
}, _ref[result] = function () { | ||
return this; | ||
}, _ref; | ||
} | ||
/** | ||
* 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.'); | ||
} | ||
// 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 }); | ||
if (typeof action.type === 'undefined') { | ||
throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?'); | ||
} | ||
return _ref2 = { | ||
dispatch: dispatch, | ||
subscribe: subscribe, | ||
getState: getState, | ||
replaceReducer: replaceReducer | ||
}, _ref2[result] = observable, _ref2; | ||
} | ||
if (isDispatching) { | ||
throw new Error('Reducers may not dispatch actions.'); | ||
} | ||
/** | ||
* 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 */ | ||
} | ||
try { | ||
isDispatching = true; | ||
currentState = currentReducer(currentState, action); | ||
} finally { | ||
isDispatching = false; | ||
} | ||
function getUndefinedStateErrorMessage(key, action) { | ||
var actionType = action && action.type; | ||
var actionName = actionType && '"' + actionType.toString() + '"' || 'an action'; | ||
var listeners = currentListeners = nextListeners; | ||
for (var i = 0; i < listeners.length; i++) { | ||
listeners[i](); | ||
} | ||
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.'; | ||
} | ||
return action; | ||
} | ||
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'; | ||
/** | ||
* 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.'); | ||
} | ||
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.'; | ||
} | ||
currentReducer = nextReducer; | ||
dispatch({ type: ActionTypes.INIT }); | ||
} | ||
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('", "') + '"'); | ||
} | ||
/** | ||
* Interoperability point for observable/reactive libraries. | ||
* @returns {observable} A minimal observable of state changes. | ||
* For more information, see the observable proposal: | ||
* https://github.com/zenparsing/es-observable | ||
*/ | ||
function observable() { | ||
var _ref; | ||
var unexpectedKeys = Object.keys(inputState).filter(function (key) { | ||
return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]; | ||
}); | ||
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.'); | ||
} | ||
unexpectedKeys.forEach(function (key) { | ||
unexpectedKeyCache[key] = true; | ||
}); | ||
function observeState() { | ||
if (observer.next) { | ||
observer.next(getState()); | ||
} | ||
} | ||
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.'); | ||
} | ||
} | ||
observeState(); | ||
var unsubscribe = outerSubscribe(observeState); | ||
return { unsubscribe: unsubscribe }; | ||
} | ||
}, _ref[_symbolObservable2['default']] = function () { | ||
return this; | ||
}, _ref; | ||
} | ||
function assertReducerShape(reducers) { | ||
Object.keys(reducers).forEach(function (key) { | ||
var reducer = reducers[key]; | ||
var initialState = reducer(undefined, { type: ActionTypes.INIT }); | ||
// 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 }); | ||
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.'); | ||
} | ||
return _ref2 = { | ||
dispatch: dispatch, | ||
subscribe: subscribe, | ||
getState: getState, | ||
replaceReducer: replaceReducer | ||
}, _ref2[_symbolObservable2['default']] = observable, _ref2; | ||
} | ||
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.'); | ||
} | ||
}); | ||
} | ||
/***/ }, | ||
/* 3 */ | ||
/***/ function(module, exports) { | ||
/** | ||
* 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]; | ||
'use strict'; | ||
{ | ||
if (typeof reducers[key] === 'undefined') { | ||
warning('No reducer provided for key "' + key + '"'); | ||
} | ||
} | ||
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 */ | ||
} | ||
if (typeof reducers[key] === 'function') { | ||
finalReducers[key] = reducers[key]; | ||
} | ||
} | ||
var finalReducerKeys = Object.keys(finalReducers); | ||
/***/ }, | ||
/* 4 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var unexpectedKeyCache = void 0; | ||
{ | ||
unexpectedKeyCache = {}; | ||
} | ||
var getPrototype = __webpack_require__(8), | ||
isHostObject = __webpack_require__(9), | ||
isObjectLike = __webpack_require__(11); | ||
var shapeAssertionError = void 0; | ||
try { | ||
assertReducerShape(finalReducers); | ||
} catch (e) { | ||
shapeAssertionError = e; | ||
} | ||
/** `Object#toString` result references. */ | ||
var objectTag = '[object Object]'; | ||
return function combination() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var action = arguments[1]; | ||
/** Used for built-in method references. */ | ||
var funcProto = Function.prototype, | ||
objectProto = Object.prototype; | ||
if (shapeAssertionError) { | ||
throw shapeAssertionError; | ||
} | ||
/** Used to resolve the decompiled source of functions. */ | ||
var funcToString = funcProto.toString; | ||
{ | ||
var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache); | ||
if (warningMessage) { | ||
warning(warningMessage); | ||
} | ||
} | ||
/** Used to check objects for own properties. */ | ||
var hasOwnProperty = objectProto.hasOwnProperty; | ||
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; | ||
}; | ||
} | ||
/** Used to infer the `Object` constructor. */ | ||
var objectCtorString = funcToString.call(Object); | ||
function bindActionCreator(actionCreator, dispatch) { | ||
return function () { | ||
return dispatch(actionCreator.apply(undefined, arguments)); | ||
}; | ||
} | ||
/** | ||
* Used to resolve the | ||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) | ||
* of values. | ||
*/ | ||
var objectToString = objectProto.toString; | ||
/** | ||
* 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); | ||
} | ||
/** | ||
* 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) || | ||
objectToString.call(value) != objectTag || isHostObject(value)) { | ||
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); | ||
} | ||
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"?'); | ||
} | ||
module.exports = isPlainObject; | ||
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); | ||
} else { | ||
warning('bindActionCreators expected a function actionCreator for key \'' + key + '\', instead received type \'' + typeof actionCreator + '\'.'); | ||
} | ||
} | ||
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))). | ||
*/ | ||
/***/ }, | ||
/* 5 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
function compose() { | ||
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) { | ||
funcs[_key] = arguments[_key]; | ||
} | ||
'use strict'; | ||
if (funcs.length === 0) { | ||
return function (arg) { | ||
return arg; | ||
}; | ||
} | ||
exports.__esModule = true; | ||
if (funcs.length === 1) { | ||
return funcs[0]; | ||
} | ||
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; }; | ||
return funcs.reduce(function (a, b) { | ||
return function () { | ||
return a(b.apply(undefined, arguments)); | ||
}; | ||
}); | ||
} | ||
exports['default'] = applyMiddleware; | ||
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; }; | ||
var _compose = __webpack_require__(1); | ||
/** | ||
* 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]; | ||
} | ||
var _compose2 = _interopRequireDefault(_compose); | ||
return function (createStore) { | ||
return function (reducer, preloadedState, enhancer) { | ||
var store = createStore(reducer, preloadedState, enhancer); | ||
var _dispatch = store.dispatch; | ||
var chain = []; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
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); | ||
/** | ||
* 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 _extends({}, store, { | ||
dispatch: _dispatch | ||
}); | ||
}; | ||
}; | ||
} | ||
return function (createStore) { | ||
return function (reducer, preloadedState, enhancer) { | ||
var store = createStore(reducer, preloadedState, enhancer); | ||
var _dispatch = store.dispatch; | ||
var chain = []; | ||
/* | ||
* 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() {} | ||
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); | ||
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.'); | ||
} | ||
return _extends({}, store, { | ||
dispatch: _dispatch | ||
}); | ||
}; | ||
}; | ||
} | ||
exports.createStore = createStore; | ||
exports.combineReducers = combineReducers; | ||
exports.bindActionCreators = bindActionCreators; | ||
exports.applyMiddleware = applyMiddleware; | ||
exports.compose = compose; | ||
/***/ }, | ||
/* 6 */ | ||
/***/ function(module, exports) { | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
'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; | ||
} | ||
/***/ }, | ||
/* 7 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
exports.__esModule = true; | ||
exports['default'] = combineReducers; | ||
var _createStore = __webpack_require__(2); | ||
var _isPlainObject = __webpack_require__(4); | ||
var _isPlainObject2 = _interopRequireDefault(_isPlainObject); | ||
var _warning = __webpack_require__(3); | ||
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.'; | ||
} | ||
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 assertReducerSanity(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.'); | ||
} | ||
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.'); | ||
} | ||
}); | ||
} | ||
/** | ||
* 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 (true) { | ||
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); | ||
if (true) { | ||
var unexpectedKeyCache = {}; | ||
} | ||
var sanityError; | ||
try { | ||
assertReducerSanity(finalReducers); | ||
} catch (e) { | ||
sanityError = e; | ||
} | ||
return function combination() { | ||
var state = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var action = arguments[1]; | ||
if (sanityError) { | ||
throw sanityError; | ||
} | ||
if (true) { | ||
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; | ||
}; | ||
} | ||
/***/ }, | ||
/* 8 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var overArg = __webpack_require__(10); | ||
/** Built-in value references. */ | ||
var getPrototype = overArg(Object.getPrototypeOf, Object); | ||
module.exports = getPrototype; | ||
/***/ }, | ||
/* 9 */ | ||
/***/ function(module, exports) { | ||
/** | ||
* Checks if `value` is a host object in IE < 9. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a host object, else `false`. | ||
*/ | ||
function isHostObject(value) { | ||
// Many host objects are `Object` objects that can coerce to strings | ||
// despite having improperly defined `toString` methods. | ||
var result = false; | ||
if (value != null && typeof value.toString != 'function') { | ||
try { | ||
result = !!(value + ''); | ||
} catch (e) {} | ||
} | ||
return result; | ||
} | ||
module.exports = isHostObject; | ||
/***/ }, | ||
/* 10 */ | ||
/***/ function(module, exports) { | ||
/** | ||
* 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)); | ||
}; | ||
} | ||
module.exports = overArg; | ||
/***/ }, | ||
/* 11 */ | ||
/***/ function(module, exports) { | ||
/** | ||
* 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 && typeof value == 'object'; | ||
} | ||
module.exports = isObjectLike; | ||
/***/ }, | ||
/* 12 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
module.exports = __webpack_require__(13); | ||
/***/ }, | ||
/* 13 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/* WEBPACK VAR INJECTION */(function(global) {'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _ponyfill = __webpack_require__(14); | ||
var _ponyfill2 = _interopRequireDefault(_ponyfill); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var root = undefined; /* global window */ | ||
if (typeof global !== 'undefined') { | ||
root = global; | ||
} else if (typeof window !== 'undefined') { | ||
root = window; | ||
} | ||
var result = (0, _ponyfill2['default'])(root); | ||
exports['default'] = result; | ||
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) | ||
/***/ }, | ||
/* 14 */ | ||
/***/ function(module, exports) { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports['default'] = symbolObservablePonyfill; | ||
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; | ||
}; | ||
/***/ } | ||
/******/ ]) | ||
}); | ||
; | ||
}))); |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Redux=e():t.Redux=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}e.__esModule=!0,e.compose=e.applyMiddleware=e.bindActionCreators=e.combineReducers=e.createStore=void 0;var o=n(2),u=r(o),i=n(7),c=r(i),a=n(6),f=r(a),s=n(5),d=r(s),l=n(1),p=r(l),y=n(3);r(y);e.createStore=u["default"],e.combineReducers=c["default"],e.bindActionCreators=f["default"],e.applyMiddleware=d["default"],e.compose=p["default"]},function(t,e){"use strict";function n(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(0===e.length)return function(t){return t};if(1===e.length)return e[0];var r=e[e.length-1],o=e.slice(0,-1);return function(){return o.reduceRight(function(t,e){return e(t)},r.apply(void 0,arguments))}}e.__esModule=!0,e["default"]=n},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e,n){function r(){b===h&&(b=h.slice())}function u(){return v}function c(t){if("function"!=typeof t)throw Error("Expected listener to be a function.");var e=!0;return r(),b.push(t),function(){if(e){e=!1,r();var n=b.indexOf(t);b.splice(n,1)}}}function s(t){if(!(0,i["default"])(t))throw Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===t.type)throw Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(m)throw Error("Reducers may not dispatch actions.");try{m=!0,v=y(v,t)}finally{m=!1}for(var e=h=b,n=0;e.length>n;n++)e[n]();return t}function d(t){if("function"!=typeof t)throw Error("Expected the nextReducer to be a function.");y=t,s({type:f.INIT})}function l(){var t,e=c;return t={subscribe:function(t){function n(){t.next&&t.next(u())}if("object"!=typeof t)throw new TypeError("Expected the observer to be an object.");n();var r=e(n);return{unsubscribe:r}}},t[a["default"]]=function(){return this},t}var p;if("function"==typeof e&&void 0===n&&(n=e,e=void 0),void 0!==n){if("function"!=typeof n)throw Error("Expected the enhancer to be a function.");return n(o)(t,e)}if("function"!=typeof t)throw Error("Expected the reducer to be a function.");var y=t,v=e,h=[],b=h,m=!1;return s({type:f.INIT}),p={dispatch:s,subscribe:c,getState:u,replaceReducer:d},p[a["default"]]=l,p}e.__esModule=!0,e.ActionTypes=void 0,e["default"]=o;var u=n(4),i=r(u),c=n(12),a=r(c),f=e.ActionTypes={INIT:"@@redux/INIT"}},function(t,e){"use strict";function n(t){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(t);try{throw Error(t)}catch(e){}}e.__esModule=!0,e["default"]=n},function(t,e,n){function r(t){if(!i(t)||p.call(t)!=c||u(t))return!1;var e=o(t);if(null===e)return!0;var n=d.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&s.call(n)==l}var o=n(8),u=n(9),i=n(11),c="[object Object]",a=Function.prototype,f=Object.prototype,s=a.toString,d=f.hasOwnProperty,l=s.call(Object),p=f.toString;t.exports=r},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return function(t){return function(n,r,o){var i=t(n,r,o),a=i.dispatch,f=[],s={getState:i.getState,dispatch:function(t){return a(t)}};return f=e.map(function(t){return t(s)}),a=c["default"].apply(void 0,f)(i.dispatch),u({},i,{dispatch:a})}}}e.__esModule=!0;var u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};e["default"]=o;var i=n(1),c=r(i)},function(t,e){"use strict";function n(t,e){return function(){return e(t.apply(void 0,arguments))}}function r(t,e){if("function"==typeof t)return n(t,e);if("object"!=typeof t||null===t)throw Error("bindActionCreators expected an object or a function, instead received "+(null===t?"null":typeof t)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');for(var r=Object.keys(t),o={},u=0;r.length>u;u++){var i=r[u],c=t[i];"function"==typeof c&&(o[i]=n(c,e))}return o}e.__esModule=!0,e["default"]=r},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){var n=e&&e.type,r=n&&'"'+n+'"'||"an action";return"Given action "+r+', reducer "'+t+'" returned undefined. To ignore an action, you must explicitly return the previous state.'}function u(t){Object.keys(t).forEach(function(e){var n=t[e],r=n(void 0,{type:c.ActionTypes.INIT});if(void 0===r)throw Error('Reducer "'+e+'" 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.');var o="@@redux/PROBE_UNKNOWN_ACTION_"+Math.random().toString(36).substring(7).split("").join(".");if(void 0===n(void 0,{type:o}))throw Error('Reducer "'+e+'" returned undefined when probed with a random type. '+("Don't try to handle "+c.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.")})}function i(t){for(var e=Object.keys(t),n={},r=0;e.length>r;r++){var i=e[r];"function"==typeof t[i]&&(n[i]=t[i])}var c,a=Object.keys(n);try{u(n)}catch(f){c=f}return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments[1];if(c)throw c;for(var r=!1,u={},i=0;a.length>i;i++){var f=a[i],s=n[f],d=t[f],l=s(d,e);if(void 0===l){var p=o(f,e);throw Error(p)}u[f]=l,r=r||l!==d}return r?u:t}}e.__esModule=!0,e["default"]=i;var c=n(2),a=n(4),f=(r(a),n(3));r(f)},function(t,e,n){var r=n(10),o=r(Object.getPrototypeOf,Object);t.exports=o},function(t,e){function n(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(n){}return e}t.exports=n},function(t,e){function n(t,e){return function(n){return t(e(n))}}t.exports=n},function(t,e){function n(t){return!!t&&"object"==typeof t}t.exports=n},function(t,e,n){t.exports=n(13)},function(t,e,n){(function(t){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var o=n(14),u=r(o),i=void 0;void 0!==t?i=t:"undefined"!=typeof window&&(i=window);var c=(0,u["default"])(i);e["default"]=c}).call(e,function(){return this}())},function(t,e){"use strict";function n(t){var e,n=t.Symbol;return"function"==typeof n?n.observable?e=n.observable:(e=n("observable"),n.observable=e):e="@@observable",e}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=n}])}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Redux=t.Redux||{})}(this,function(t){"use strict";function e(t){var e=v.call(t,j),n=t[j];try{t[j]=void 0;var r=!0}catch(t){}var o=g.call(t);return r&&(e?t[j]=n:delete t[j]),o}function n(t){return w.call(t)}function r(t){return null==t?void 0===t?O:m:x&&x in Object(t)?e(t):n(t)}function o(t){return null!=t&&"object"==typeof t}function i(t){if(!o(t)||r(t)!=I)return!1;var e=E(t);if(null===e)return!0;var n=A.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&N.call(n)==R}function u(t,e,n){function r(){p===l&&(p=l.slice())}function o(){return s}function c(t){if("function"!=typeof t)throw Error("Expected listener to be a function.");var e=!0;return r(),p.push(t),function(){if(e){e=!1,r();var n=p.indexOf(t);p.splice(n,1)}}}function a(t){if(!i(t))throw Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===t.type)throw Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(y)throw Error("Reducers may not dispatch actions.");try{y=!0,s=d(s,t)}finally{y=!1}for(var e=l=p,n=0;e.length>n;n++)(0,e[n])();return t}var f;if("function"==typeof e&&void 0===n&&(n=e,e=void 0),void 0!==n){if("function"!=typeof n)throw Error("Expected the enhancer to be a function.");return n(u)(t,e)}if("function"!=typeof t)throw Error("Expected the reducer to be a function.");var d=t,s=e,l=[],p=l,y=!1;return a({type:k.INIT}),f={dispatch:a,subscribe:c,getState:o,replaceReducer:function(t){if("function"!=typeof t)throw Error("Expected the nextReducer to be a function.");d=t,a({type:k.INIT})}},f[C]=function(){var t,e=c;return t={subscribe:function(t){function n(){t.next&&t.next(o())}if("object"!=typeof t)throw new TypeError("Expected the observer to be an object.");return n(),{unsubscribe:e(n)}}},t[C]=function(){return this},t},f}function c(t){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(t);try{throw Error(t)}catch(t){}}function a(t,e){var n=e&&e.type;return"Given action "+(n&&'"'+n+'"'||"an action")+', reducer "'+t+'" 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 f(t){Object.keys(t).forEach(function(e){var n=t[e];if(void 0===n(void 0,{type:k.INIT}))throw Error('Reducer "'+e+"\" 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.");if(void 0===n(void 0,{type:"@@redux/PROBE_UNKNOWN_ACTION_"+Math.random().toString(36).substring(7).split("").join(".")}))throw Error('Reducer "'+e+"\" returned undefined when probed with a random type. Don't try to handle "+k.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.')})}function d(t,e){return function(){return e(t.apply(void 0,arguments))}}function s(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return 0===e.length?function(t){return t}:1===e.length?e[0]:e.reduce(function(t,e){return function(){return t(e.apply(void 0,arguments))}})}var l,p="object"==typeof global&&global&&global.Object===Object&&global,y="object"==typeof self&&self&&self.Object===Object&&self,b=(p||y||Function("return this")()).Symbol,h=Object.prototype,v=h.hasOwnProperty,g=h.toString,j=b?b.toStringTag:void 0,w=Object.prototype.toString,m="[object Null]",O="[object Undefined]",x=b?b.toStringTag:void 0,E=function(t,e){return function(n){return t(e(n))}}(Object.getPrototypeOf,Object),I="[object Object]",T=Function.prototype,S=Object.prototype,N=T.toString,A=S.hasOwnProperty,R=N.call(Object),C=function(t){var e,n=t.Symbol;return"function"==typeof n?n.observable?e=n.observable:(e=n("observable"),n.observable=e):e="@@observable",e}(l="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")()),k={INIT:"@@redux/INIT"},P=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};t.createStore=u,t.combineReducers=function(t){for(var e=Object.keys(t),n={},r=0;e.length>r;r++){var o=e[r];"function"==typeof t[o]&&(n[o]=t[o])}var i=Object.keys(n),u=void 0;try{f(n)}catch(t){u=t}return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments[1];if(u)throw u;for(var r=!1,o={},c=0;i.length>c;c++){var f=i[c],d=n[f],s=t[f],l=d(s,e);if(void 0===l){var p=a(f,e);throw Error(p)}o[f]=l,r=r||l!==s}return r?o:t}},t.bindActionCreators=function(t,e){if("function"==typeof t)return d(t,e);if("object"!=typeof t||null===t)throw Error("bindActionCreators expected an object or a function, instead received "+(null===t?"null":typeof t)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');for(var n=Object.keys(t),r={},o=0;n.length>o;o++){var i=n[o],u=t[i];"function"==typeof u?r[i]=d(u,e):c("bindActionCreators expected a function actionCreator for key '"+i+"', instead received type '"+typeof u+"'.")}return r},t.applyMiddleware=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return function(t){return function(n,r,o){var i=t(n,r,o),u=i.dispatch,c=[],a={getState:i.getState,dispatch:function(t){return u(t)}};return c=e.map(function(t){return t(a)}),u=s.apply(void 0,c)(i.dispatch),P({},i,{dispatch:u})}}},t.compose=s,Object.defineProperty(t,"__esModule",{value:!0})}); |
@@ -0,1 +1,3 @@ | ||
import warning from './utils/warning'; | ||
function bindActionCreator(actionCreator, dispatch) { | ||
@@ -44,2 +46,4 @@ return function () { | ||
boundActionCreators[key] = bindActionCreator(actionCreator, dispatch); | ||
} else { | ||
warning('bindActionCreators expected a function actionCreator for key \'' + key + '\', instead received type \'' + typeof actionCreator + '\'.'); | ||
} | ||
@@ -46,0 +50,0 @@ } |
@@ -9,3 +9,3 @@ import { ActionTypes } from './createStore'; | ||
return 'Given action ' + actionName + ', reducer "' + key + '" returned undefined. ' + 'To ignore an action, you must explicitly return the previous state.'; | ||
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.'; | ||
} | ||
@@ -38,3 +38,3 @@ | ||
function assertReducerSanity(reducers) { | ||
function assertReducerShape(reducers) { | ||
Object.keys(reducers).forEach(function (key) { | ||
@@ -45,3 +45,3 @@ var reducer = reducers[key]; | ||
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.'); | ||
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.'); | ||
} | ||
@@ -51,3 +51,3 @@ | ||
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.'); | ||
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.'); | ||
} | ||
@@ -91,19 +91,20 @@ }); | ||
var unexpectedKeyCache = void 0; | ||
if (process.env.NODE_ENV !== 'production') { | ||
var unexpectedKeyCache = {}; | ||
unexpectedKeyCache = {}; | ||
} | ||
var sanityError; | ||
var shapeAssertionError = void 0; | ||
try { | ||
assertReducerSanity(finalReducers); | ||
assertReducerShape(finalReducers); | ||
} catch (e) { | ||
sanityError = e; | ||
shapeAssertionError = e; | ||
} | ||
return function combination() { | ||
var state = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var action = arguments[1]; | ||
if (sanityError) { | ||
throw sanityError; | ||
if (shapeAssertionError) { | ||
throw shapeAssertionError; | ||
} | ||
@@ -120,12 +121,12 @@ | ||
var nextState = {}; | ||
for (var i = 0; i < finalReducerKeys.length; i++) { | ||
var key = finalReducerKeys[i]; | ||
var reducer = finalReducers[key]; | ||
var previousStateForKey = state[key]; | ||
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); | ||
var errorMessage = getUndefinedStateErrorMessage(_key, action); | ||
throw new Error(errorMessage); | ||
} | ||
nextState[key] = nextStateForKey; | ||
nextState[_key] = nextStateForKey; | ||
hasChanged = hasChanged || nextStateForKey !== previousStateForKey; | ||
@@ -132,0 +133,0 @@ } |
@@ -27,9 +27,7 @@ /** | ||
var last = funcs[funcs.length - 1]; | ||
var rest = funcs.slice(0, -1); | ||
return function () { | ||
return rest.reduceRight(function (composed, f) { | ||
return f(composed); | ||
}, last.apply(undefined, arguments)); | ||
}; | ||
return funcs.reduce(function (a, b) { | ||
return function () { | ||
return a(b.apply(undefined, arguments)); | ||
}; | ||
}); | ||
} |
@@ -12,30 +12,29 @@ import isPlainObject from 'lodash-es/isPlainObject'; | ||
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) { | ||
/** | ||
* 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; | ||
@@ -174,3 +173,4 @@ | ||
for (var i = 0; i < listeners.length; i++) { | ||
listeners[i](); | ||
var listener = listeners[i]; | ||
listener(); | ||
} | ||
@@ -204,3 +204,3 @@ | ||
* For more information, see the observable proposal: | ||
* https://github.com/zenparsing/es-observable | ||
* https://github.com/tc39/proposal-observable | ||
*/ | ||
@@ -207,0 +207,0 @@ function observable() { |
@@ -422,5 +422,6 @@ /** | ||
/* rest */ | ||
export function compose<A, B, C, R>( | ||
f1: (b: C) => R, f2: (a: B) => C, f3: (a: A) => B, | ||
...funcs: Function[] | ||
export function compose<R>( | ||
f1: (b: any) => R, ...funcs: Function[] | ||
): (...args: any[]) => R; | ||
export function compose<R>(...funcs: Function[]): (...args: any[]) => R; |
@@ -5,2 +5,9 @@ 'use strict'; | ||
exports['default'] = bindActionCreators; | ||
var _warning = require('./utils/warning'); | ||
var _warning2 = _interopRequireDefault(_warning); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
function bindActionCreator(actionCreator, dispatch) { | ||
@@ -49,2 +56,4 @@ return function () { | ||
boundActionCreators[key] = bindActionCreator(actionCreator, dispatch); | ||
} else { | ||
(0, _warning2['default'])('bindActionCreators expected a function actionCreator for key \'' + key + '\', instead received type \'' + typeof actionCreator + '\'.'); | ||
} | ||
@@ -51,0 +60,0 @@ } |
@@ -22,3 +22,3 @@ 'use strict'; | ||
return 'Given action ' + actionName + ', reducer "' + key + '" returned undefined. ' + 'To ignore an action, you must explicitly return the previous state.'; | ||
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.'; | ||
} | ||
@@ -51,3 +51,3 @@ | ||
function assertReducerSanity(reducers) { | ||
function assertReducerShape(reducers) { | ||
Object.keys(reducers).forEach(function (key) { | ||
@@ -58,3 +58,3 @@ var reducer = reducers[key]; | ||
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.'); | ||
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.'); | ||
} | ||
@@ -64,3 +64,3 @@ | ||
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.'); | ||
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.'); | ||
} | ||
@@ -104,19 +104,20 @@ }); | ||
var unexpectedKeyCache = void 0; | ||
if (process.env.NODE_ENV !== 'production') { | ||
var unexpectedKeyCache = {}; | ||
unexpectedKeyCache = {}; | ||
} | ||
var sanityError; | ||
var shapeAssertionError = void 0; | ||
try { | ||
assertReducerSanity(finalReducers); | ||
assertReducerShape(finalReducers); | ||
} catch (e) { | ||
sanityError = e; | ||
shapeAssertionError = e; | ||
} | ||
return function combination() { | ||
var state = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var action = arguments[1]; | ||
if (sanityError) { | ||
throw sanityError; | ||
if (shapeAssertionError) { | ||
throw shapeAssertionError; | ||
} | ||
@@ -133,12 +134,12 @@ | ||
var nextState = {}; | ||
for (var i = 0; i < finalReducerKeys.length; i++) { | ||
var key = finalReducerKeys[i]; | ||
var reducer = finalReducers[key]; | ||
var previousStateForKey = state[key]; | ||
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); | ||
var errorMessage = getUndefinedStateErrorMessage(_key, action); | ||
throw new Error(errorMessage); | ||
} | ||
nextState[key] = nextStateForKey; | ||
nextState[_key] = nextStateForKey; | ||
hasChanged = hasChanged || nextStateForKey !== previousStateForKey; | ||
@@ -145,0 +146,0 @@ } |
@@ -31,9 +31,7 @@ "use strict"; | ||
var last = funcs[funcs.length - 1]; | ||
var rest = funcs.slice(0, -1); | ||
return function () { | ||
return rest.reduceRight(function (composed, f) { | ||
return f(composed); | ||
}, last.apply(undefined, arguments)); | ||
}; | ||
return funcs.reduce(function (a, b) { | ||
return function () { | ||
return a(b.apply(undefined, arguments)); | ||
}; | ||
}); | ||
} |
@@ -25,30 +25,29 @@ 'use strict'; | ||
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) { | ||
/** | ||
* 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; | ||
@@ -187,3 +186,4 @@ | ||
for (var i = 0; i < listeners.length; i++) { | ||
listeners[i](); | ||
var listener = listeners[i]; | ||
listener(); | ||
} | ||
@@ -217,3 +217,3 @@ | ||
* For more information, see the observable proposal: | ||
* https://github.com/zenparsing/es-observable | ||
* https://github.com/tc39/proposal-observable | ||
*/ | ||
@@ -220,0 +220,0 @@ function observable() { |
{ | ||
"name": "redux", | ||
"version": "3.6.0", | ||
"version": "3.7.0", | ||
"description": "Predictable state container for JavaScript apps", | ||
@@ -18,23 +18,19 @@ "main": "lib/index.js", | ||
"clean": "rimraf lib dist es coverage", | ||
"lint": "npm run lint:src && npm run lint:examples", | ||
"lint:src": "eslint src test build", | ||
"lint:examples": "eslint examples", | ||
"test": "cross-env BABEL_ENV=commonjs mocha --compilers js:babel-register --recursive", | ||
"test:watch": "npm test -- --watch", | ||
"test:cov": "cross-env BABEL_ENV=commonjs babel-node $(npm bin)/isparta cover $(npm bin)/_mocha -- --recursive", | ||
"test:examples": "cross-env BABEL_ENV=commonjs babel-node examples/testAll.js", | ||
"check:src": "npm run lint:src && npm run test", | ||
"check:examples": "npm run build:examples && npm run lint:examples && npm run test:examples", | ||
"lint": "eslint src test build", | ||
"test": "cross-env BABEL_ENV=commonjs jest", | ||
"test:watch": "yarn test -- --watch", | ||
"test:cov": "yarn test -- --coverage", | ||
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --out-dir lib", | ||
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es", | ||
"build:umd": "cross-env BABEL_ENV=commonjs NODE_ENV=development webpack src/index.js dist/redux.js", | ||
"build:umd:min": "cross-env BABEL_ENV=commonjs NODE_ENV=production webpack src/index.js dist/redux.min.js", | ||
"build:examples": "cross-env BABEL_ENV=commonjs babel-node examples/buildAll.js", | ||
"build": "npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:umd:min", | ||
"prepublish": "npm run clean && npm run check:src && npm run build && check-es3-syntax lib/ dist/ --kill --print", | ||
"build:umd": "cross-env BABEL_ENV=es NODE_ENV=development rollup -c -i src/index.js -o dist/redux.js", | ||
"build:umd:min": "cross-env BABEL_ENV=es NODE_ENV=production rollup -c -i src/index.js -o dist/redux.min.js", | ||
"build": "yarn run build:commonjs && yarn run build:es && yarn run build:umd && yarn run build:umd:min", | ||
"prepublish": "yarn run clean && yarn run lint && yarn test && yarn run build", | ||
"examples:lint": "eslint examples", | ||
"examples:test": "cross-env CI=true babel-node examples/testAll.js", | ||
"docs:clean": "rimraf _book", | ||
"docs:prepare": "gitbook install", | ||
"docs:build": "npm run docs:prepare && gitbook build -g reactjs/redux && cp logo/apple-touch-icon.png _book/gitbook/images/apple-touch-icon-precomposed-152.png && cp logo/favicon.ico _book/gitbook/images", | ||
"docs:watch": "npm run docs:prepare && gitbook serve", | ||
"docs:publish": "npm run docs:clean && npm run docs:build && cp CNAME _book && cd _book && git init && git commit --allow-empty -m 'update book' && git checkout -b gh-pages && touch .nojekyll && git add . && git commit -am 'update book' && git push git@github.com:reactjs/redux gh-pages --force" | ||
"docs:build": "yarn run docs:prepare && gitbook build -g reactjs/redux && cp logo/apple-touch-icon.png _book/gitbook/images/apple-touch-icon-precomposed-152.png && cp logo/favicon.ico _book/gitbook/images", | ||
"docs:watch": "yarn run docs:prepare && gitbook serve", | ||
"docs:publish": "yarn run docs:clean && yarn run docs:build && cp CNAME _book && cd _book && git init && git commit --allow-empty -m 'update book' && git checkout -b gh-pages && touch .nojekyll && git add . && git commit -am 'update book' && git push git@github.com:reactjs/redux gh-pages --force" | ||
}, | ||
@@ -71,3 +67,3 @@ "repository": { | ||
"loose-envify": "^1.1.0", | ||
"symbol-observable": "^1.0.2" | ||
"symbol-observable": "^1.0.3" | ||
}, | ||
@@ -77,4 +73,4 @@ "devDependencies": { | ||
"babel-core": "^6.3.15", | ||
"babel-eslint": "^4.1.6", | ||
"babel-loader": "^6.2.0", | ||
"babel-eslint": "^7.0.0", | ||
"babel-jest": "^20.0.3", | ||
"babel-plugin-check-es2015-constants": "^6.3.13", | ||
@@ -102,17 +98,21 @@ "babel-plugin-transform-es2015-arrow-functions": "^6.3.13", | ||
"babel-register": "^6.3.13", | ||
"check-es3-syntax-cli": "^0.1.1", | ||
"cross-env": "^1.0.7", | ||
"eslint": "^1.10.3", | ||
"eslint-config-rackt": "^1.1.1", | ||
"eslint-plugin-react": "^3.16.1", | ||
"expect": "^1.8.0", | ||
"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": "^6.0.4", | ||
"isparta": "^4.0.0", | ||
"mocha": "^2.2.5", | ||
"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", | ||
"webpack": "^1.9.6" | ||
"typescript-definition-tester": "0.0.4" | ||
}, | ||
@@ -132,3 +132,6 @@ "npmName": "redux", | ||
] | ||
}, | ||
"jest": { | ||
"testRegex": "(/test/.*\\.spec.js)$" | ||
} | ||
} |
@@ -18,4 +18,5 @@ # <a href='http://redux.js.org'><img src='https://camo.githubusercontent.com/f28b5bc7822f1b7bb28a96d8d09e7d79169248fc/687474703a2f2f692e696d6775722e636f6d2f4a65567164514d2e706e67' height='60'></a> | ||
>**New! Learn Redux from its creator: | ||
>[Getting Started with Redux](https://egghead.io/series/getting-started-with-redux) (30 free videos)** | ||
>**Learn Redux from its creator:** | ||
>**[Part 1: Getting Started with Redux](https://egghead.io/series/getting-started-with-redux) (30 free videos)**<br> | ||
>**[Part 2: Building React Applications with Idiomatic Redux](https://egghead.io/courses/building-react-applications-with-idiomatic-redux) (27 free videos)** | ||
@@ -33,2 +34,7 @@ ### Testimonials | ||
### Before Proceeding Further | ||
>**Also read:** | ||
>**[You Might Not Need Redux](https://medium.com/@dan_abramov/you-might-not-need-redux-be46360cf367)** | ||
### Developer Experience | ||
@@ -52,6 +58,7 @@ | ||
This assumes you are using [npm](https://www.npmjs.com/) as your package manager. | ||
If you don't, you can [access these files on unpkg](https://unpkg.com/redux/), download them, or point your package manager to them. | ||
Most commonly people consume Redux as a collection of [CommonJS](http://webpack.github.io/docs/commonjs.html) modules. These modules are what you get when you import `redux` in a [Webpack](http://webpack.github.io), [Browserify](http://browserify.org/), or a Node environment. If you like to live on the edge and use [Rollup](http://rollupjs.org), we support that as well. | ||
If you're not, you can [access these files on unpkg](https://unpkg.com/redux/), download them, or point your package manager to them. | ||
Most commonly people consume Redux as a collection of [CommonJS](http://webpack.github.io/docs/commonjs.html) modules. These modules are what you get when you import `redux` in a [Webpack](https://webpack.js.org/), [Browserify](http://browserify.org/), or a Node environment. If you like to live on the edge and use [Rollup](http://rollupjs.org), we support that as well. | ||
If you don't use a module bundler, it's also fine. The `redux` npm package includes precompiled production and development [UMD](https://github.com/umdjs/umd) builds in the [`dist` folder](https://unpkg.com/redux/dist/). They can be used directly without a bundler and are thus compatible with many popular JavaScript module loaders and environments. For example, you can drop a UMD build as a [`<script>` tag](https://unpkg.com/redux/dist/redux.js) on the page, or [tell Bower to install it](https://github.com/reactjs/redux/pull/1181#issuecomment-167361975). The UMD builds make Redux available as a `window.Redux` global variable. | ||
@@ -70,3 +77,3 @@ | ||
Note that unlike Redux itself, many packages in the Redux ecosystem don't provide UMD builds, so we recommend using CommonJS module bundlers like [Webpack](http://webpack.github.io) and [Browserify](http://browserify.org/) for the most comfortable development experience. | ||
Note that unlike Redux itself, many packages in the Redux ecosystem don't provide UMD builds, so we recommend using CommonJS module bundlers like [Webpack](https://webpack.js.org/) and [Browserify](http://browserify.org/) for the most comfortable development experience. | ||
@@ -131,3 +138,3 @@ ### The Gist | ||
If you're coming from Flux, there is a single important difference you need to understand. Redux doesn't have a Dispatcher or support many stores. Instead, there is just a single store with a single root reducing function. As your app grows, instead of adding stores, you split the root reducer into smaller reducers independently operating on the different parts of the state tree. This is exactly like there is just one root component in a React app, but it is composed out of many small components. | ||
If you're coming from Flux, there is a single important difference you need to understand. Redux doesn't have a Dispatcher or support many stores. Instead, there is just a single store with a single root reducing function. As your app grows, instead of adding stores, you split the root reducer into smaller reducers independently operating on the different parts of the state tree. This is exactly like how there is just one root component in a React app, but it is composed out of many small components. | ||
@@ -167,2 +174,3 @@ This architecture might seem like an overkill for a counter app, but the beauty of this pattern is how well it scales to large and complex apps. It also enables very powerful developer tools, because it is possible to trace every mutation to the action that caused it. You can record user sessions and reproduce them just by replaying every action. | ||
* [Recipes](http://redux.js.org/docs/recipes/index.html) | ||
* [FAQ](http://redux.js.org/docs/FAQ.html) | ||
* [Troubleshooting](http://redux.js.org/docs/Troubleshooting.html) | ||
@@ -174,2 +182,4 @@ * [Glossary](http://redux.js.org/docs/Glossary.html) | ||
For Offline docs, please see: [devdocs](http://devdocs.io/redux/) | ||
### Examples | ||
@@ -199,3 +209,3 @@ | ||
* [Developing ClojureScript with Figwheel](https://www.youtube.com/watch?v=j-kj2qwJa_E) for convincing me that re-evaluation should “just work”; | ||
* [Webpack](https://github.com/webpack/docs/wiki/hot-module-replacement-with-webpack) for Hot Module Replacement; | ||
* [Webpack](https://webpack.js.org/concepts/hot-module-replacement/) for Hot Module Replacement; | ||
* [Flummox](https://github.com/acdlite/flummox) for teaching me to approach Flux without boilerplate or singletons; | ||
@@ -227,3 +237,3 @@ * [disto](https://github.com/threepointone/disto) for a proof of concept of hot reloadable Stores; | ||
[See the full list of Redux patrons.](PATRONS.md) | ||
[See the full list of Redux patrons.](PATRONS.md), as well as the always-growing list of [people and companies that use Redux](https://github.com/reactjs/redux/issues/310). | ||
@@ -230,0 +240,0 @@ ### License |
@@ -21,7 +21,7 @@ import compose from './compose' | ||
return (createStore) => (reducer, preloadedState, enhancer) => { | ||
var store = createStore(reducer, preloadedState, enhancer) | ||
var dispatch = store.dispatch | ||
var chain = [] | ||
const store = createStore(reducer, preloadedState, enhancer) | ||
let dispatch = store.dispatch | ||
let chain = [] | ||
var middlewareAPI = { | ||
const middlewareAPI = { | ||
getState: store.getState, | ||
@@ -28,0 +28,0 @@ dispatch: (action) => dispatch(action) |
@@ -0,1 +1,3 @@ | ||
import warning from './utils/warning' | ||
function bindActionCreator(actionCreator, dispatch) { | ||
@@ -38,9 +40,11 @@ return (...args) => dispatch(actionCreator(...args)) | ||
var keys = Object.keys(actionCreators) | ||
var boundActionCreators = {} | ||
for (var i = 0; i < keys.length; i++) { | ||
var key = keys[i] | ||
var actionCreator = actionCreators[key] | ||
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) | ||
} else { | ||
warning(`bindActionCreators expected a function actionCreator for key '${key}', instead received type '${typeof actionCreator}'.`) | ||
} | ||
@@ -47,0 +51,0 @@ } |
@@ -6,8 +6,9 @@ import { ActionTypes } from './createStore' | ||
function getUndefinedStateErrorMessage(key, action) { | ||
var actionType = action && action.type | ||
var actionName = actionType && `"${actionType.toString()}"` || 'an 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.` | ||
`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.` | ||
) | ||
@@ -17,4 +18,4 @@ } | ||
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) { | ||
var reducerKeys = Object.keys(reducers) | ||
var argumentName = action && action.type === ActionTypes.INIT ? | ||
const reducerKeys = Object.keys(reducers) | ||
const argumentName = action && action.type === ActionTypes.INIT ? | ||
'preloadedState argument passed to createStore' : | ||
@@ -39,3 +40,3 @@ 'previous state received by the reducer' | ||
var unexpectedKeys = Object.keys(inputState).filter(key => | ||
const unexpectedKeys = Object.keys(inputState).filter(key => | ||
!reducers.hasOwnProperty(key) && | ||
@@ -59,6 +60,6 @@ !unexpectedKeyCache[key] | ||
function assertReducerSanity(reducers) { | ||
function assertReducerShape(reducers) { | ||
Object.keys(reducers).forEach(key => { | ||
var reducer = reducers[key] | ||
var initialState = reducer(undefined, { type: ActionTypes.INIT }) | ||
const reducer = reducers[key] | ||
const initialState = reducer(undefined, { type: ActionTypes.INIT }) | ||
@@ -70,7 +71,8 @@ if (typeof initialState === 'undefined') { | ||
`explicitly return the initial state. The initial state may ` + | ||
`not be undefined.` | ||
`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('.') | ||
const type = '@@redux/PROBE_UNKNOWN_ACTION_' + Math.random().toString(36).substring(7).split('').join('.') | ||
if (typeof reducer(undefined, { type }) === 'undefined') { | ||
@@ -83,3 +85,3 @@ throw new Error( | ||
`in which case you must return the initial state, regardless of the ` + | ||
`action type. The initial state may not be undefined.` | ||
`action type. The initial state may not be undefined, but can be null.` | ||
) | ||
@@ -107,6 +109,6 @@ } | ||
export default function combineReducers(reducers) { | ||
var reducerKeys = Object.keys(reducers) | ||
var finalReducers = {} | ||
for (var i = 0; i < reducerKeys.length; i++) { | ||
var key = reducerKeys[i] | ||
const reducerKeys = Object.keys(reducers) | ||
const finalReducers = {} | ||
for (let i = 0; i < reducerKeys.length; i++) { | ||
const key = reducerKeys[i] | ||
@@ -123,22 +125,23 @@ if (process.env.NODE_ENV !== 'production') { | ||
} | ||
var finalReducerKeys = Object.keys(finalReducers) | ||
const finalReducerKeys = Object.keys(finalReducers) | ||
let unexpectedKeyCache | ||
if (process.env.NODE_ENV !== 'production') { | ||
var unexpectedKeyCache = {} | ||
unexpectedKeyCache = {} | ||
} | ||
var sanityError | ||
let shapeAssertionError | ||
try { | ||
assertReducerSanity(finalReducers) | ||
assertReducerShape(finalReducers) | ||
} catch (e) { | ||
sanityError = e | ||
shapeAssertionError = e | ||
} | ||
return function combination(state = {}, action) { | ||
if (sanityError) { | ||
throw sanityError | ||
if (shapeAssertionError) { | ||
throw shapeAssertionError | ||
} | ||
if (process.env.NODE_ENV !== 'production') { | ||
var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache) | ||
const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache) | ||
if (warningMessage) { | ||
@@ -149,11 +152,11 @@ 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) | ||
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') { | ||
var errorMessage = getUndefinedStateErrorMessage(key, action) | ||
const errorMessage = getUndefinedStateErrorMessage(key, action) | ||
throw new Error(errorMessage) | ||
@@ -160,0 +163,0 @@ } |
@@ -21,5 +21,3 @@ /** | ||
const last = funcs[funcs.length - 1] | ||
const rest = funcs.slice(0, -1) | ||
return (...args) => rest.reduceRight((composed, f) => f(composed), last(...args)) | ||
return funcs.reduce((a, b) => (...args) => a(b(...args))) | ||
} |
@@ -10,3 +10,3 @@ import isPlainObject from 'lodash/isPlainObject' | ||
*/ | ||
export var ActionTypes = { | ||
export const ActionTypes = { | ||
INIT: '@@redux/INIT' | ||
@@ -32,3 +32,3 @@ } | ||
* | ||
* @param {Function} enhancer The store enhancer. You may optionally specify it | ||
* @param {Function} [enhancer] The store enhancer. You may optionally specify it | ||
* to enhance the store with third-party capabilities such as middleware, | ||
@@ -59,7 +59,7 @@ * time travel, persistence, etc. The only store enhancer that ships with Redux | ||
var currentReducer = reducer | ||
var currentState = preloadedState | ||
var currentListeners = [] | ||
var nextListeners = currentListeners | ||
var isDispatching = false | ||
let currentReducer = reducer | ||
let currentState = preloadedState | ||
let currentListeners = [] | ||
let nextListeners = currentListeners | ||
let isDispatching = false | ||
@@ -109,3 +109,3 @@ function ensureCanMutateNextListeners() { | ||
var isSubscribed = true | ||
let isSubscribed = true | ||
@@ -123,3 +123,3 @@ ensureCanMutateNextListeners() | ||
ensureCanMutateNextListeners() | ||
var index = nextListeners.indexOf(listener) | ||
const index = nextListeners.indexOf(listener) | ||
nextListeners.splice(index, 1) | ||
@@ -180,5 +180,6 @@ } | ||
var listeners = currentListeners = nextListeners | ||
for (var i = 0; i < listeners.length; i++) { | ||
listeners[i]() | ||
const listeners = currentListeners = nextListeners | ||
for (let i = 0; i < listeners.length; i++) { | ||
const listener = listeners[i] | ||
listener() | ||
} | ||
@@ -212,6 +213,6 @@ | ||
* For more information, see the observable proposal: | ||
* https://github.com/zenparsing/es-observable | ||
* https://github.com/tc39/proposal-observable | ||
*/ | ||
function observable() { | ||
var outerSubscribe = subscribe | ||
const outerSubscribe = subscribe | ||
return { | ||
@@ -238,3 +239,3 @@ /** | ||
observeState() | ||
var unsubscribe = outerSubscribe(observeState) | ||
const unsubscribe = outerSubscribe(observeState) | ||
return { unsubscribe } | ||
@@ -241,0 +242,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
234
0
136058
45
2618
Updatedsymbol-observable@^1.0.3