зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1246650 - upgrade redux to version 3.3.0; r=jsantell
--HG-- extra : rebase_source : 29e4f09e691a43d7a29293af3da5601dab338da3
This commit is contained in:
Родитель
a0db96a838
Коммит
ce45b02f5e
|
@ -0,0 +1,10 @@
|
|||
REDUX_UPGRADING
|
||||
|
||||
Current version of redux : 3.3.0
|
||||
|
||||
1 - grab the unminified version of redux on npm. For release 3.3.0 for instance,
|
||||
https://npmcdn.com/redux@3.3.0/dist/redux.js
|
||||
|
||||
2 - replace the content of devtools/client/shared/vendor
|
||||
|
||||
3 - update the current version in this file
|
|
@ -57,49 +57,99 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.compose = exports.applyMiddleware = exports.bindActionCreators = exports.combineReducers = exports.createStore = undefined;
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
var _createStore = __webpack_require__(1);
|
||||
var _createStore = __webpack_require__(2);
|
||||
|
||||
var _createStore2 = _interopRequireDefault(_createStore);
|
||||
|
||||
var _utilsCombineReducers = __webpack_require__(7);
|
||||
var _combineReducers = __webpack_require__(7);
|
||||
|
||||
var _utilsCombineReducers2 = _interopRequireDefault(_utilsCombineReducers);
|
||||
var _combineReducers2 = _interopRequireDefault(_combineReducers);
|
||||
|
||||
var _utilsBindActionCreators = __webpack_require__(6);
|
||||
var _bindActionCreators = __webpack_require__(6);
|
||||
|
||||
var _utilsBindActionCreators2 = _interopRequireDefault(_utilsBindActionCreators);
|
||||
var _bindActionCreators2 = _interopRequireDefault(_bindActionCreators);
|
||||
|
||||
var _utilsApplyMiddleware = __webpack_require__(5);
|
||||
var _applyMiddleware = __webpack_require__(5);
|
||||
|
||||
var _utilsApplyMiddleware2 = _interopRequireDefault(_utilsApplyMiddleware);
|
||||
var _applyMiddleware2 = _interopRequireDefault(_applyMiddleware);
|
||||
|
||||
var _utilsCompose = __webpack_require__(2);
|
||||
var _compose = __webpack_require__(1);
|
||||
|
||||
var _utilsCompose2 = _interopRequireDefault(_utilsCompose);
|
||||
var _compose2 = _interopRequireDefault(_compose);
|
||||
|
||||
exports.createStore = _createStore2['default'];
|
||||
exports.combineReducers = _utilsCombineReducers2['default'];
|
||||
exports.bindActionCreators = _utilsBindActionCreators2['default'];
|
||||
exports.applyMiddleware = _utilsApplyMiddleware2['default'];
|
||||
exports.compose = _utilsCompose2['default'];
|
||||
var _warning = __webpack_require__(3);
|
||||
|
||||
var _warning2 = _interopRequireDefault(_warning);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
||||
|
||||
/*
|
||||
* This is a dummy function to check if the function name has been altered by minification.
|
||||
* If the function has been minified and NODE_ENV !== 'production', warn the user.
|
||||
*/
|
||||
function isCrushed() {}
|
||||
|
||||
if (("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.');
|
||||
}
|
||||
|
||||
exports.createStore = _createStore2["default"];
|
||||
exports.combineReducers = _combineReducers2["default"];
|
||||
exports.bindActionCreators = _bindActionCreators2["default"];
|
||||
exports.applyMiddleware = _applyMiddleware2["default"];
|
||||
exports.compose = _compose2["default"];
|
||||
|
||||
/***/ },
|
||||
/* 1 */
|
||||
/***/ function(module, exports) {
|
||||
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = compose;
|
||||
/**
|
||||
* Composes single-argument functions from right to left.
|
||||
*
|
||||
* @param {...Function} funcs The functions to compose.
|
||||
* @returns {Function} A function obtained by composing functions from right to
|
||||
* left. For example, compose(f, g, h) is identical to arg => f(g(h(arg))).
|
||||
*/
|
||||
function compose() {
|
||||
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
funcs[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return function () {
|
||||
if (funcs.length === 0) {
|
||||
return arguments.length <= 0 ? undefined : arguments[0];
|
||||
}
|
||||
|
||||
var last = funcs[funcs.length - 1];
|
||||
var rest = funcs.slice(0, -1);
|
||||
|
||||
return rest.reduceRight(function (composed, f) {
|
||||
return f(composed);
|
||||
}, last.apply(undefined, arguments));
|
||||
};
|
||||
}
|
||||
|
||||
/***/ },
|
||||
/* 2 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
exports['default'] = createStore;
|
||||
exports.ActionTypes = undefined;
|
||||
exports["default"] = createStore;
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
var _isPlainObject = __webpack_require__(4);
|
||||
|
||||
var _utilsIsPlainObject = __webpack_require__(3);
|
||||
var _isPlainObject2 = _interopRequireDefault(_isPlainObject);
|
||||
|
||||
var _utilsIsPlainObject2 = _interopRequireDefault(_utilsIsPlainObject);
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
||||
|
||||
/**
|
||||
* These are private action types reserved by Redux.
|
||||
|
@ -107,11 +157,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
* If the current state is undefined, you must return the initial state.
|
||||
* Do not reference these action types directly in your code.
|
||||
*/
|
||||
var ActionTypes = {
|
||||
var ActionTypes = exports.ActionTypes = {
|
||||
INIT: '@@redux/INIT'
|
||||
};
|
||||
|
||||
exports.ActionTypes = ActionTypes;
|
||||
/**
|
||||
* 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.
|
||||
|
@ -129,20 +178,44 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
* 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, initialState, enhancer) {
|
||||
if (typeof initialState === 'function' && typeof enhancer === 'undefined') {
|
||||
enhancer = initialState;
|
||||
initialState = undefined;
|
||||
}
|
||||
|
||||
if (typeof enhancer !== 'undefined') {
|
||||
if (typeof enhancer !== 'function') {
|
||||
throw new Error('Expected the enhancer to be a function.');
|
||||
}
|
||||
|
||||
return enhancer(createStore)(reducer, initialState);
|
||||
}
|
||||
|
||||
function createStore(reducer, initialState) {
|
||||
if (typeof reducer !== 'function') {
|
||||
throw new Error('Expected the reducer to be a function.');
|
||||
}
|
||||
|
||||
var currentReducer = reducer;
|
||||
var currentState = initialState;
|
||||
var listeners = [];
|
||||
var currentListeners = [];
|
||||
var nextListeners = currentListeners;
|
||||
var isDispatching = false;
|
||||
|
||||
function ensureCanMutateNextListeners() {
|
||||
if (nextListeners === currentListeners) {
|
||||
nextListeners = currentListeners.slice();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the state tree managed by the store.
|
||||
*
|
||||
|
@ -157,15 +230,44 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
* 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 states 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) {
|
||||
listeners.push(listener);
|
||||
if (typeof listener !== 'function') {
|
||||
throw new Error('Expected listener to be a function.');
|
||||
}
|
||||
|
||||
var isSubscribed = true;
|
||||
|
||||
ensureCanMutateNextListeners();
|
||||
nextListeners.push(listener);
|
||||
|
||||
return function unsubscribe() {
|
||||
var index = listeners.indexOf(listener);
|
||||
listeners.splice(index, 1);
|
||||
if (!isSubscribed) {
|
||||
return;
|
||||
}
|
||||
|
||||
isSubscribed = false;
|
||||
|
||||
ensureCanMutateNextListeners();
|
||||
var index = nextListeners.indexOf(listener);
|
||||
nextListeners.splice(index, 1);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -185,7 +287,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
*
|
||||
* @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`.
|
||||
* 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.
|
||||
*
|
||||
|
@ -193,8 +297,12 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
* return something else (for example, a Promise you can await).
|
||||
*/
|
||||
function dispatch(action) {
|
||||
if (!_utilsIsPlainObject2['default'](action)) {
|
||||
throw new Error('Actions must be plain objects. Use custom middleware for async actions.');
|
||||
if (!(0, _isPlainObject2["default"])(action)) {
|
||||
throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.');
|
||||
}
|
||||
|
||||
if (typeof action.type === 'undefined') {
|
||||
throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?');
|
||||
}
|
||||
|
||||
if (isDispatching) {
|
||||
|
@ -208,9 +316,11 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
isDispatching = false;
|
||||
}
|
||||
|
||||
listeners.slice().forEach(function (listener) {
|
||||
return listener();
|
||||
});
|
||||
var listeners = currentListeners = nextListeners;
|
||||
for (var i = 0; i < listeners.length; i++) {
|
||||
listeners[i]();
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
|
@ -225,6 +335,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
* @returns {void}
|
||||
*/
|
||||
function replaceReducer(nextReducer) {
|
||||
if (typeof nextReducer !== 'function') {
|
||||
throw new Error('Expected the nextReducer to be a function.');
|
||||
}
|
||||
|
||||
currentReducer = nextReducer;
|
||||
dispatch({ type: ActionTypes.INIT });
|
||||
}
|
||||
|
@ -242,36 +356,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
};
|
||||
}
|
||||
|
||||
/***/ },
|
||||
/* 2 */
|
||||
/***/ function(module, exports) {
|
||||
|
||||
/**
|
||||
* Composes single-argument functions from right to left.
|
||||
*
|
||||
* @param {...Function} funcs The functions to compose.
|
||||
* @returns {Function} A function obtained by composing functions from right to
|
||||
* left. For example, compose(f, g, h) is identical to x => h(g(f(x))).
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = compose;
|
||||
|
||||
function compose() {
|
||||
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
funcs[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return function (arg) {
|
||||
return funcs.reduceRight(function (composed, f) {
|
||||
return f(composed);
|
||||
}, arg);
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = exports["default"];
|
||||
|
||||
/***/ },
|
||||
/* 3 */
|
||||
/***/ function(module, exports) {
|
||||
|
@ -279,58 +363,101 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
exports['default'] = isPlainObject;
|
||||
var fnToString = function fnToString(fn) {
|
||||
return Function.prototype.toString.call(fn);
|
||||
};
|
||||
|
||||
exports["default"] = warning;
|
||||
/**
|
||||
* @param {any} obj The object to inspect.
|
||||
* @returns {boolean} True if the argument appears to be a plain object.
|
||||
* Prints a warning in the console if it exists.
|
||||
*
|
||||
* @param {String} message The warning message.
|
||||
* @returns {void}
|
||||
*/
|
||||
|
||||
function isPlainObject(obj) {
|
||||
if (!obj || typeof obj !== 'object') {
|
||||
return false;
|
||||
function warning(message) {
|
||||
/* eslint-disable no-console */
|
||||
if (typeof console !== 'undefined' && typeof console.error === 'function') {
|
||||
console.error(message);
|
||||
}
|
||||
|
||||
var proto = typeof obj.constructor === 'function' ? Object.getPrototypeOf(obj) : Object.prototype;
|
||||
|
||||
if (proto === null) {
|
||||
return true;
|
||||
/* eslint-enable no-console */
|
||||
try {
|
||||
// This error was thrown as a convenience so that you can use this stack
|
||||
// to find the callsite that caused this warning to fire.
|
||||
throw new Error(message);
|
||||
/* eslint-disable no-empty */
|
||||
} catch (e) {}
|
||||
/* eslint-enable no-empty */
|
||||
}
|
||||
|
||||
var constructor = proto.constructor;
|
||||
|
||||
return typeof constructor === 'function' && constructor instanceof constructor && fnToString(constructor) === fnToString(Object);
|
||||
}
|
||||
|
||||
module.exports = exports['default'];
|
||||
|
||||
/***/ },
|
||||
/* 4 */
|
||||
/***/ function(module, exports) {
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
var isHostObject = __webpack_require__(8),
|
||||
isObjectLike = __webpack_require__(9);
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var objectTag = '[object Object]';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/** Used to resolve the decompiled source of functions. */
|
||||
var funcToString = Function.prototype.toString;
|
||||
|
||||
/** Used to infer the `Object` constructor. */
|
||||
var objectCtorString = funcToString.call(Object);
|
||||
|
||||
/**
|
||||
* Applies a function to every key-value pair inside an object.
|
||||
*
|
||||
* @param {Object} obj The source object.
|
||||
* @param {Function} fn The mapper function that receives the value and the key.
|
||||
* @returns {Object} A new object that contains the mapped values for the keys.
|
||||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
"use strict";
|
||||
var objectToString = objectProto.toString;
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = mapValues;
|
||||
/** Built-in value references. */
|
||||
var getPrototypeOf = Object.getPrototypeOf;
|
||||
|
||||
function mapValues(obj, fn) {
|
||||
return Object.keys(obj).reduce(function (result, key) {
|
||||
result[key] = fn(obj[key], key);
|
||||
return result;
|
||||
}, {});
|
||||
/**
|
||||
* 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 _
|
||||
* @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 = objectProto;
|
||||
if (typeof value.constructor == 'function') {
|
||||
proto = getPrototypeOf(value);
|
||||
}
|
||||
if (proto === null) {
|
||||
return true;
|
||||
}
|
||||
var Ctor = proto.constructor;
|
||||
return (typeof Ctor == 'function' &&
|
||||
Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString);
|
||||
}
|
||||
|
||||
module.exports = exports["default"];
|
||||
module.exports = isPlainObject;
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 5 */
|
||||
|
@ -338,18 +465,17 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||
|
||||
exports['default'] = applyMiddleware;
|
||||
exports.__esModule = true;
|
||||
exports["default"] = applyMiddleware;
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
var _compose = __webpack_require__(2);
|
||||
var _compose = __webpack_require__(1);
|
||||
|
||||
var _compose2 = _interopRequireDefault(_compose);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
||||
|
||||
/**
|
||||
* Creates a store enhancer that applies middleware to the dispatch method
|
||||
* of the Redux store. This is handy for a variety of tasks, such as expressing
|
||||
|
@ -366,15 +492,14 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
* @param {...Function} middlewares The middleware chain to be applied.
|
||||
* @returns {Function} A store enhancer applying the middleware.
|
||||
*/
|
||||
|
||||
function applyMiddleware() {
|
||||
for (var _len = arguments.length, middlewares = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
middlewares[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return function (next) {
|
||||
return function (reducer, initialState) {
|
||||
var store = next(reducer, initialState);
|
||||
return function (createStore) {
|
||||
return function (reducer, initialState, enhancer) {
|
||||
var store = createStore(reducer, initialState, enhancer);
|
||||
var _dispatch = store.dispatch;
|
||||
var chain = [];
|
||||
|
||||
|
@ -387,7 +512,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
chain = middlewares.map(function (middleware) {
|
||||
return middleware(middlewareAPI);
|
||||
});
|
||||
_dispatch = _compose2['default'].apply(undefined, chain)(store.dispatch);
|
||||
_dispatch = _compose2["default"].apply(undefined, chain)(store.dispatch);
|
||||
|
||||
return _extends({}, store, {
|
||||
dispatch: _dispatch
|
||||
|
@ -396,23 +521,14 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
};
|
||||
}
|
||||
|
||||
module.exports = exports['default'];
|
||||
|
||||
/***/ },
|
||||
/* 6 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
/***/ function(module, exports) {
|
||||
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
exports['default'] = bindActionCreators;
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
var _utilsMapValues = __webpack_require__(4);
|
||||
|
||||
var _utilsMapValues2 = _interopRequireDefault(_utilsMapValues);
|
||||
|
||||
exports["default"] = bindActionCreators;
|
||||
function bindActionCreator(actionCreator, dispatch) {
|
||||
return function () {
|
||||
return dispatch(actionCreator.apply(undefined, arguments));
|
||||
|
@ -440,23 +556,26 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
* 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) {
|
||||
// eslint-disable-line no-eq-null
|
||||
throw new Error('bindActionCreators expected an object or a function, instead received ' + typeof actionCreators + '. ' + 'Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');
|
||||
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"?');
|
||||
}
|
||||
|
||||
return _utilsMapValues2['default'](actionCreators, function (actionCreator) {
|
||||
return bindActionCreator(actionCreator, dispatch);
|
||||
});
|
||||
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;
|
||||
}
|
||||
|
||||
module.exports = exports['default'];
|
||||
|
||||
/***/ },
|
||||
/* 7 */
|
||||
|
@ -465,55 +584,64 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
exports['default'] = combineReducers;
|
||||
exports["default"] = combineReducers;
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
var _createStore = __webpack_require__(2);
|
||||
|
||||
var _createStore = __webpack_require__(1);
|
||||
var _isPlainObject = __webpack_require__(4);
|
||||
|
||||
var _utilsIsPlainObject = __webpack_require__(3);
|
||||
var _isPlainObject2 = _interopRequireDefault(_isPlainObject);
|
||||
|
||||
var _utilsIsPlainObject2 = _interopRequireDefault(_utilsIsPlainObject);
|
||||
var _warning = __webpack_require__(3);
|
||||
|
||||
var _utilsMapValues = __webpack_require__(4);
|
||||
var _warning2 = _interopRequireDefault(_warning);
|
||||
|
||||
var _utilsMapValues2 = _interopRequireDefault(_utilsMapValues);
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
||||
|
||||
var _utilsPick = __webpack_require__(8);
|
||||
|
||||
var _utilsPick2 = _interopRequireDefault(_utilsPick);
|
||||
|
||||
/* eslint-disable no-console */
|
||||
|
||||
function getErrorMessage(key, action) {
|
||||
function getUndefinedStateErrorMessage(key, action) {
|
||||
var actionType = action && action.type;
|
||||
var actionName = actionType && '"' + actionType.toString() + '"' || 'an action';
|
||||
|
||||
return 'Reducer "' + key + '" returned undefined handling ' + actionName + '. ' + 'To ignore an action, you must explicitly return the previous state.';
|
||||
}
|
||||
|
||||
function verifyStateShape(initialState, currentState) {
|
||||
var reducerKeys = Object.keys(currentState);
|
||||
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action) {
|
||||
var reducerKeys = Object.keys(reducers);
|
||||
var argumentName = action && action.type === _createStore.ActionTypes.INIT ? 'initialState argument passed to createStore' : 'previous state received by the reducer';
|
||||
|
||||
if (reducerKeys.length === 0) {
|
||||
console.error('Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.');
|
||||
return;
|
||||
return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
|
||||
}
|
||||
|
||||
if (!_utilsIsPlainObject2['default'](initialState)) {
|
||||
console.error('initialState has unexpected type of "' + ({}).toString.call(initialState).match(/\s([a-z|A-Z]+)/)[1] + '". Expected initialState to be an object with the following ' + ('keys: "' + reducerKeys.join('", "') + '"'));
|
||||
return;
|
||||
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(initialState).filter(function (key) {
|
||||
return reducerKeys.indexOf(key) < 0;
|
||||
var unexpectedKeys = Object.keys(inputState).filter(function (key) {
|
||||
return !reducers.hasOwnProperty(key);
|
||||
});
|
||||
|
||||
if (unexpectedKeys.length > 0) {
|
||||
console.error('Unexpected ' + (unexpectedKeys.length > 1 ? 'keys' : 'key') + ' ' + ('"' + unexpectedKeys.join('", "') + '" in initialState will be ignored. ') + ('Expected to find one of the known reducer keys instead: "' + reducerKeys.join('", "') + '"'));
|
||||
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
|
||||
|
@ -530,79 +658,116 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
* @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 finalReducers = _utilsPick2['default'](reducers, function (val) {
|
||||
return typeof val === 'function';
|
||||
});
|
||||
var reducerKeys = Object.keys(reducers);
|
||||
var finalReducers = {};
|
||||
for (var i = 0; i < reducerKeys.length; i++) {
|
||||
var key = reducerKeys[i];
|
||||
if (typeof reducers[key] === 'function') {
|
||||
finalReducers[key] = reducers[key];
|
||||
}
|
||||
}
|
||||
var finalReducerKeys = Object.keys(finalReducers);
|
||||
|
||||
Object.keys(finalReducers).forEach(function (key) {
|
||||
var reducer = finalReducers[key];
|
||||
if (typeof reducer(undefined, { type: _createStore.ActionTypes.INIT }) === '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 sanityError;
|
||||
try {
|
||||
assertReducerSanity(finalReducers);
|
||||
} catch (e) {
|
||||
sanityError = e;
|
||||
}
|
||||
|
||||
var type = 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.');
|
||||
return function combination() {
|
||||
var state = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
|
||||
var action = arguments[1];
|
||||
|
||||
if (sanityError) {
|
||||
throw sanityError;
|
||||
}
|
||||
});
|
||||
|
||||
var defaultState = _utilsMapValues2['default'](finalReducers, function () {
|
||||
return undefined;
|
||||
});
|
||||
var stateShapeVerified;
|
||||
|
||||
return function combination(state, action) {
|
||||
if (state === undefined) state = defaultState;
|
||||
|
||||
var finalState = _utilsMapValues2['default'](finalReducers, function (reducer, key) {
|
||||
var newState = reducer(state[key], action);
|
||||
if (typeof newState === 'undefined') {
|
||||
throw new Error(getErrorMessage(key, action));
|
||||
}
|
||||
return newState;
|
||||
});
|
||||
|
||||
if (true) {
|
||||
if (!stateShapeVerified) {
|
||||
verifyStateShape(state, finalState);
|
||||
stateShapeVerified = true;
|
||||
var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action);
|
||||
if (warningMessage) {
|
||||
(0, _warning2["default"])(warningMessage);
|
||||
}
|
||||
}
|
||||
|
||||
return finalState;
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = exports['default'];
|
||||
|
||||
/***/ },
|
||||
/* 8 */
|
||||
/***/ function(module, exports) {
|
||||
|
||||
/**
|
||||
* Picks key-value pairs from an object where values satisfy a predicate.
|
||||
* Checks if `value` is a host object in IE < 9.
|
||||
*
|
||||
* @param {Object} obj The object to pick from.
|
||||
* @param {Function} fn The predicate the values must satisfy to be copied.
|
||||
* @returns {Object} The object with the values that satisfied the predicate.
|
||||
* @private
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is a host object, else `false`.
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = pick;
|
||||
|
||||
function pick(obj, fn) {
|
||||
return Object.keys(obj).reduce(function (result, key) {
|
||||
if (fn(obj[key])) {
|
||||
result[key] = obj[key];
|
||||
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 = exports["default"];
|
||||
module.exports = isHostObject;
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 9 */
|
||||
/***/ 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 _
|
||||
* @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;
|
||||
|
||||
|
||||
/***/ }
|
||||
/******/ ])
|
||||
|
|
Загрузка…
Ссылка в новой задаче