redux.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949
  1. /**
  2. * Redux v.3.6.0
  3. */
  4. (function webpackUniversalModuleDefinition(root, factory) {
  5. if(typeof exports === 'object' && typeof module === 'object')
  6. module.exports = factory();
  7. else if(typeof define === 'function' && define.amd)
  8. define([], factory);
  9. else if(typeof exports === 'object')
  10. exports["Redux"] = factory();
  11. else
  12. root["Redux"] = factory();
  13. })(this, function() {
  14. return /******/ (function(modules) { // webpackBootstrap
  15. /******/ // The module cache
  16. /******/ var installedModules = {};
  17. /******/ // The require function
  18. /******/ function __webpack_require__(moduleId) {
  19. /******/ // Check if module is in cache
  20. /******/ if(installedModules[moduleId])
  21. /******/ return installedModules[moduleId].exports;
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ exports: {},
  25. /******/ id: moduleId,
  26. /******/ loaded: false
  27. /******/ };
  28. /******/ // Execute the module function
  29. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  30. /******/ // Flag the module as loaded
  31. /******/ module.loaded = true;
  32. /******/ // Return the exports of the module
  33. /******/ return module.exports;
  34. /******/ }
  35. /******/ // expose the modules object (__webpack_modules__)
  36. /******/ __webpack_require__.m = modules;
  37. /******/ // expose the module cache
  38. /******/ __webpack_require__.c = installedModules;
  39. /******/ // __webpack_public_path__
  40. /******/ __webpack_require__.p = "";
  41. /******/ // Load entry module and return exports
  42. /******/ return __webpack_require__(0);
  43. /******/ })
  44. /************************************************************************/
  45. /******/ ([
  46. /* 0 */
  47. /***/ function(module, exports, __webpack_require__) {
  48. 'use strict';
  49. exports.__esModule = true;
  50. exports.compose = exports.applyMiddleware = exports.bindActionCreators = exports.combineReducers = exports.createStore = undefined;
  51. var _createStore = __webpack_require__(2);
  52. var _createStore2 = _interopRequireDefault(_createStore);
  53. var _combineReducers = __webpack_require__(7);
  54. var _combineReducers2 = _interopRequireDefault(_combineReducers);
  55. var _bindActionCreators = __webpack_require__(6);
  56. var _bindActionCreators2 = _interopRequireDefault(_bindActionCreators);
  57. var _applyMiddleware = __webpack_require__(5);
  58. var _applyMiddleware2 = _interopRequireDefault(_applyMiddleware);
  59. var _compose = __webpack_require__(1);
  60. var _compose2 = _interopRequireDefault(_compose);
  61. var _warning = __webpack_require__(3);
  62. var _warning2 = _interopRequireDefault(_warning);
  63. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  64. /*
  65. * This is a dummy function to check if the function name has been altered by minification.
  66. * If the function has been minified and NODE_ENV !== 'production', warn the user.
  67. */
  68. function isCrushed() {}
  69. if (("development") !== 'production' && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') {
  70. (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.');
  71. }
  72. exports.createStore = _createStore2['default'];
  73. exports.combineReducers = _combineReducers2['default'];
  74. exports.bindActionCreators = _bindActionCreators2['default'];
  75. exports.applyMiddleware = _applyMiddleware2['default'];
  76. exports.compose = _compose2['default'];
  77. /***/ },
  78. /* 1 */
  79. /***/ function(module, exports) {
  80. "use strict";
  81. exports.__esModule = true;
  82. exports["default"] = compose;
  83. /**
  84. * Composes single-argument functions from right to left. The rightmost
  85. * function can take multiple arguments as it provides the signature for
  86. * the resulting composite function.
  87. *
  88. * @param {...Function} funcs The functions to compose.
  89. * @returns {Function} A function obtained by composing the argument functions
  90. * from right to left. For example, compose(f, g, h) is identical to doing
  91. * (...args) => f(g(h(...args))).
  92. */
  93. function compose() {
  94. for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) {
  95. funcs[_key] = arguments[_key];
  96. }
  97. if (funcs.length === 0) {
  98. return function (arg) {
  99. return arg;
  100. };
  101. }
  102. if (funcs.length === 1) {
  103. return funcs[0];
  104. }
  105. var last = funcs[funcs.length - 1];
  106. var rest = funcs.slice(0, -1);
  107. return function () {
  108. return rest.reduceRight(function (composed, f) {
  109. return f(composed);
  110. }, last.apply(undefined, arguments));
  111. };
  112. }
  113. /***/ },
  114. /* 2 */
  115. /***/ function(module, exports, __webpack_require__) {
  116. 'use strict';
  117. exports.__esModule = true;
  118. exports.ActionTypes = undefined;
  119. exports['default'] = createStore;
  120. var _isPlainObject = __webpack_require__(4);
  121. var _isPlainObject2 = _interopRequireDefault(_isPlainObject);
  122. var _symbolObservable = __webpack_require__(12);
  123. var _symbolObservable2 = _interopRequireDefault(_symbolObservable);
  124. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  125. /**
  126. * These are private action types reserved by Redux.
  127. * For any unknown actions, you must return the current state.
  128. * If the current state is undefined, you must return the initial state.
  129. * Do not reference these action types directly in your code.
  130. */
  131. var ActionTypes = exports.ActionTypes = {
  132. INIT: '@@redux/INIT'
  133. };
  134. /**
  135. * Creates a Redux store that holds the state tree.
  136. * The only way to change the data in the store is to call `dispatch()` on it.
  137. *
  138. * There should only be a single store in your app. To specify how different
  139. * parts of the state tree respond to actions, you may combine several reducers
  140. * into a single reducer function by using `combineReducers`.
  141. *
  142. * @param {Function} reducer A function that returns the next state tree, given
  143. * the current state tree and the action to handle.
  144. *
  145. * @param {any} [preloadedState] The initial state. You may optionally specify it
  146. * to hydrate the state from the server in universal apps, or to restore a
  147. * previously serialized user session.
  148. * If you use `combineReducers` to produce the root reducer function, this must be
  149. * an object with the same shape as `combineReducers` keys.
  150. *
  151. * @param {Function} enhancer The store enhancer. You may optionally specify it
  152. * to enhance the store with third-party capabilities such as middleware,
  153. * time travel, persistence, etc. The only store enhancer that ships with Redux
  154. * is `applyMiddleware()`.
  155. *
  156. * @returns {Store} A Redux store that lets you read the state, dispatch actions
  157. * and subscribe to changes.
  158. */
  159. function createStore(reducer, preloadedState, enhancer) {
  160. var _ref2;
  161. if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
  162. enhancer = preloadedState;
  163. preloadedState = undefined;
  164. }
  165. if (typeof enhancer !== 'undefined') {
  166. if (typeof enhancer !== 'function') {
  167. throw new Error('Expected the enhancer to be a function.');
  168. }
  169. return enhancer(createStore)(reducer, preloadedState);
  170. }
  171. if (typeof reducer !== 'function') {
  172. throw new Error('Expected the reducer to be a function.');
  173. }
  174. var currentReducer = reducer;
  175. var currentState = preloadedState;
  176. var currentListeners = [];
  177. var nextListeners = currentListeners;
  178. var isDispatching = false;
  179. function ensureCanMutateNextListeners() {
  180. if (nextListeners === currentListeners) {
  181. nextListeners = currentListeners.slice();
  182. }
  183. }
  184. /**
  185. * Reads the state tree managed by the store.
  186. *
  187. * @returns {any} The current state tree of your application.
  188. */
  189. function getState() {
  190. return currentState;
  191. }
  192. /**
  193. * Adds a change listener. It will be called any time an action is dispatched,
  194. * and some part of the state tree may potentially have changed. You may then
  195. * call `getState()` to read the current state tree inside the callback.
  196. *
  197. * You may call `dispatch()` from a change listener, with the following
  198. * caveats:
  199. *
  200. * 1. The subscriptions are snapshotted just before every `dispatch()` call.
  201. * If you subscribe or unsubscribe while the listeners are being invoked, this
  202. * will not have any effect on the `dispatch()` that is currently in progress.
  203. * However, the next `dispatch()` call, whether nested or not, will use a more
  204. * recent snapshot of the subscription list.
  205. *
  206. * 2. The listener should not expect to see all state changes, as the state
  207. * might have been updated multiple times during a nested `dispatch()` before
  208. * the listener is called. It is, however, guaranteed that all subscribers
  209. * registered before the `dispatch()` started will be called with the latest
  210. * state by the time it exits.
  211. *
  212. * @param {Function} listener A callback to be invoked on every dispatch.
  213. * @returns {Function} A function to remove this change listener.
  214. */
  215. function subscribe(listener) {
  216. if (typeof listener !== 'function') {
  217. throw new Error('Expected listener to be a function.');
  218. }
  219. var isSubscribed = true;
  220. ensureCanMutateNextListeners();
  221. nextListeners.push(listener);
  222. return function unsubscribe() {
  223. if (!isSubscribed) {
  224. return;
  225. }
  226. isSubscribed = false;
  227. ensureCanMutateNextListeners();
  228. var index = nextListeners.indexOf(listener);
  229. nextListeners.splice(index, 1);
  230. };
  231. }
  232. /**
  233. * Dispatches an action. It is the only way to trigger a state change.
  234. *
  235. * The `reducer` function, used to create the store, will be called with the
  236. * current state tree and the given `action`. Its return value will
  237. * be considered the **next** state of the tree, and the change listeners
  238. * will be notified.
  239. *
  240. * The base implementation only supports plain object actions. If you want to
  241. * dispatch a Promise, an Observable, a thunk, or something else, you need to
  242. * wrap your store creating function into the corresponding middleware. For
  243. * example, see the documentation for the `redux-thunk` package. Even the
  244. * middleware will eventually dispatch plain object actions using this method.
  245. *
  246. * @param {Object} action A plain object representing “what changed”. It is
  247. * a good idea to keep actions serializable so you can record and replay user
  248. * sessions, or use the time travelling `redux-devtools`. An action must have
  249. * a `type` property which may not be `undefined`. It is a good idea to use
  250. * string constants for action types.
  251. *
  252. * @returns {Object} For convenience, the same action object you dispatched.
  253. *
  254. * Note that, if you use a custom middleware, it may wrap `dispatch()` to
  255. * return something else (for example, a Promise you can await).
  256. */
  257. function dispatch(action) {
  258. if (!(0, _isPlainObject2['default'])(action)) {
  259. throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.');
  260. }
  261. if (typeof action.type === 'undefined') {
  262. throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?');
  263. }
  264. if (isDispatching) {
  265. throw new Error('Reducers may not dispatch actions.');
  266. }
  267. try {
  268. isDispatching = true;
  269. currentState = currentReducer(currentState, action);
  270. } finally {
  271. isDispatching = false;
  272. }
  273. var listeners = currentListeners = nextListeners;
  274. for (var i = 0; i < listeners.length; i++) {
  275. listeners[i]();
  276. }
  277. return action;
  278. }
  279. /**
  280. * Replaces the reducer currently used by the store to calculate the state.
  281. *
  282. * You might need this if your app implements code splitting and you want to
  283. * load some of the reducers dynamically. You might also need this if you
  284. * implement a hot reloading mechanism for Redux.
  285. *
  286. * @param {Function} nextReducer The reducer for the store to use instead.
  287. * @returns {void}
  288. */
  289. function replaceReducer(nextReducer) {
  290. if (typeof nextReducer !== 'function') {
  291. throw new Error('Expected the nextReducer to be a function.');
  292. }
  293. currentReducer = nextReducer;
  294. dispatch({ type: ActionTypes.INIT });
  295. }
  296. /**
  297. * Interoperability point for observable/reactive libraries.
  298. * @returns {observable} A minimal observable of state changes.
  299. * For more information, see the observable proposal:
  300. * https://github.com/zenparsing/es-observable
  301. */
  302. function observable() {
  303. var _ref;
  304. var outerSubscribe = subscribe;
  305. return _ref = {
  306. /**
  307. * The minimal observable subscription method.
  308. * @param {Object} observer Any object that can be used as an observer.
  309. * The observer object should have a `next` method.
  310. * @returns {subscription} An object with an `unsubscribe` method that can
  311. * be used to unsubscribe the observable from the store, and prevent further
  312. * emission of values from the observable.
  313. */
  314. subscribe: function subscribe(observer) {
  315. if (typeof observer !== 'object') {
  316. throw new TypeError('Expected the observer to be an object.');
  317. }
  318. function observeState() {
  319. if (observer.next) {
  320. observer.next(getState());
  321. }
  322. }
  323. observeState();
  324. var unsubscribe = outerSubscribe(observeState);
  325. return { unsubscribe: unsubscribe };
  326. }
  327. }, _ref[_symbolObservable2['default']] = function () {
  328. return this;
  329. }, _ref;
  330. }
  331. // When a store is created, an "INIT" action is dispatched so that every
  332. // reducer returns their initial state. This effectively populates
  333. // the initial state tree.
  334. dispatch({ type: ActionTypes.INIT });
  335. return _ref2 = {
  336. dispatch: dispatch,
  337. subscribe: subscribe,
  338. getState: getState,
  339. replaceReducer: replaceReducer
  340. }, _ref2[_symbolObservable2['default']] = observable, _ref2;
  341. }
  342. /***/ },
  343. /* 3 */
  344. /***/ function(module, exports) {
  345. 'use strict';
  346. exports.__esModule = true;
  347. exports['default'] = warning;
  348. /**
  349. * Prints a warning in the console if it exists.
  350. *
  351. * @param {String} message The warning message.
  352. * @returns {void}
  353. */
  354. function warning(message) {
  355. /* eslint-disable no-console */
  356. if (typeof console !== 'undefined' && typeof console.error === 'function') {
  357. console.error(message);
  358. }
  359. /* eslint-enable no-console */
  360. try {
  361. // This error was thrown as a convenience so that if you enable
  362. // "break on all exceptions" in your console,
  363. // it would pause the execution at this line.
  364. throw new Error(message);
  365. /* eslint-disable no-empty */
  366. } catch (e) {}
  367. /* eslint-enable no-empty */
  368. }
  369. /***/ },
  370. /* 4 */
  371. /***/ function(module, exports, __webpack_require__) {
  372. var getPrototype = __webpack_require__(8),
  373. isHostObject = __webpack_require__(9),
  374. isObjectLike = __webpack_require__(11);
  375. /** `Object#toString` result references. */
  376. var objectTag = '[object Object]';
  377. /** Used for built-in method references. */
  378. var funcProto = Function.prototype,
  379. objectProto = Object.prototype;
  380. /** Used to resolve the decompiled source of functions. */
  381. var funcToString = funcProto.toString;
  382. /** Used to check objects for own properties. */
  383. var hasOwnProperty = objectProto.hasOwnProperty;
  384. /** Used to infer the `Object` constructor. */
  385. var objectCtorString = funcToString.call(Object);
  386. /**
  387. * Used to resolve the
  388. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  389. * of values.
  390. */
  391. var objectToString = objectProto.toString;
  392. /**
  393. * Checks if `value` is a plain object, that is, an object created by the
  394. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  395. *
  396. * @static
  397. * @memberOf _
  398. * @since 0.8.0
  399. * @category Lang
  400. * @param {*} value The value to check.
  401. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  402. * @example
  403. *
  404. * function Foo() {
  405. * this.a = 1;
  406. * }
  407. *
  408. * _.isPlainObject(new Foo);
  409. * // => false
  410. *
  411. * _.isPlainObject([1, 2, 3]);
  412. * // => false
  413. *
  414. * _.isPlainObject({ 'x': 0, 'y': 0 });
  415. * // => true
  416. *
  417. * _.isPlainObject(Object.create(null));
  418. * // => true
  419. */
  420. function isPlainObject(value) {
  421. if (!isObjectLike(value) ||
  422. objectToString.call(value) != objectTag || isHostObject(value)) {
  423. return false;
  424. }
  425. var proto = getPrototype(value);
  426. if (proto === null) {
  427. return true;
  428. }
  429. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  430. return (typeof Ctor == 'function' &&
  431. Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString);
  432. }
  433. module.exports = isPlainObject;
  434. /***/ },
  435. /* 5 */
  436. /***/ function(module, exports, __webpack_require__) {
  437. 'use strict';
  438. exports.__esModule = true;
  439. 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; };
  440. exports['default'] = applyMiddleware;
  441. var _compose = __webpack_require__(1);
  442. var _compose2 = _interopRequireDefault(_compose);
  443. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  444. /**
  445. * Creates a store enhancer that applies middleware to the dispatch method
  446. * of the Redux store. This is handy for a variety of tasks, such as expressing
  447. * asynchronous actions in a concise manner, or logging every action payload.
  448. *
  449. * See `redux-thunk` package as an example of the Redux middleware.
  450. *
  451. * Because middleware is potentially asynchronous, this should be the first
  452. * store enhancer in the composition chain.
  453. *
  454. * Note that each middleware will be given the `dispatch` and `getState` functions
  455. * as named arguments.
  456. *
  457. * @param {...Function} middlewares The middleware chain to be applied.
  458. * @returns {Function} A store enhancer applying the middleware.
  459. */
  460. function applyMiddleware() {
  461. for (var _len = arguments.length, middlewares = Array(_len), _key = 0; _key < _len; _key++) {
  462. middlewares[_key] = arguments[_key];
  463. }
  464. return function (createStore) {
  465. return function (reducer, preloadedState, enhancer) {
  466. var store = createStore(reducer, preloadedState, enhancer);
  467. var _dispatch = store.dispatch;
  468. var chain = [];
  469. var middlewareAPI = {
  470. getState: store.getState,
  471. dispatch: function dispatch(action) {
  472. return _dispatch(action);
  473. }
  474. };
  475. chain = middlewares.map(function (middleware) {
  476. return middleware(middlewareAPI);
  477. });
  478. _dispatch = _compose2['default'].apply(undefined, chain)(store.dispatch);
  479. return _extends({}, store, {
  480. dispatch: _dispatch
  481. });
  482. };
  483. };
  484. }
  485. /***/ },
  486. /* 6 */
  487. /***/ function(module, exports) {
  488. 'use strict';
  489. exports.__esModule = true;
  490. exports['default'] = bindActionCreators;
  491. function bindActionCreator(actionCreator, dispatch) {
  492. return function () {
  493. return dispatch(actionCreator.apply(undefined, arguments));
  494. };
  495. }
  496. /**
  497. * Turns an object whose values are action creators, into an object with the
  498. * same keys, but with every function wrapped into a `dispatch` call so they
  499. * may be invoked directly. This is just a convenience method, as you can call
  500. * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
  501. *
  502. * For convenience, you can also pass a single function as the first argument,
  503. * and get a function in return.
  504. *
  505. * @param {Function|Object} actionCreators An object whose values are action
  506. * creator functions. One handy way to obtain it is to use ES6 `import * as`
  507. * syntax. You may also pass a single function.
  508. *
  509. * @param {Function} dispatch The `dispatch` function available on your Redux
  510. * store.
  511. *
  512. * @returns {Function|Object} The object mimicking the original object, but with
  513. * every action creator wrapped into the `dispatch` call. If you passed a
  514. * function as `actionCreators`, the return value will also be a single
  515. * function.
  516. */
  517. function bindActionCreators(actionCreators, dispatch) {
  518. if (typeof actionCreators === 'function') {
  519. return bindActionCreator(actionCreators, dispatch);
  520. }
  521. if (typeof actionCreators !== 'object' || actionCreators === null) {
  522. 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"?');
  523. }
  524. var keys = Object.keys(actionCreators);
  525. var boundActionCreators = {};
  526. for (var i = 0; i < keys.length; i++) {
  527. var key = keys[i];
  528. var actionCreator = actionCreators[key];
  529. if (typeof actionCreator === 'function') {
  530. boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
  531. }
  532. }
  533. return boundActionCreators;
  534. }
  535. /***/ },
  536. /* 7 */
  537. /***/ function(module, exports, __webpack_require__) {
  538. 'use strict';
  539. exports.__esModule = true;
  540. exports['default'] = combineReducers;
  541. var _createStore = __webpack_require__(2);
  542. var _isPlainObject = __webpack_require__(4);
  543. var _isPlainObject2 = _interopRequireDefault(_isPlainObject);
  544. var _warning = __webpack_require__(3);
  545. var _warning2 = _interopRequireDefault(_warning);
  546. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  547. function getUndefinedStateErrorMessage(key, action) {
  548. var actionType = action && action.type;
  549. var actionName = actionType && '"' + actionType.toString() + '"' || 'an action';
  550. return 'Given action ' + actionName + ', reducer "' + key + '" returned undefined. ' + 'To ignore an action, you must explicitly return the previous state.';
  551. }
  552. function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
  553. var reducerKeys = Object.keys(reducers);
  554. var argumentName = action && action.type === _createStore.ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
  555. if (reducerKeys.length === 0) {
  556. return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
  557. }
  558. if (!(0, _isPlainObject2['default'])(inputState)) {
  559. 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('", "') + '"');
  560. }
  561. var unexpectedKeys = Object.keys(inputState).filter(function (key) {
  562. return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
  563. });
  564. unexpectedKeys.forEach(function (key) {
  565. unexpectedKeyCache[key] = true;
  566. });
  567. if (unexpectedKeys.length > 0) {
  568. 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.');
  569. }
  570. }
  571. function assertReducerSanity(reducers) {
  572. Object.keys(reducers).forEach(function (key) {
  573. var reducer = reducers[key];
  574. var initialState = reducer(undefined, { type: _createStore.ActionTypes.INIT });
  575. if (typeof initialState === 'undefined') {
  576. 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.');
  577. }
  578. var type = '@@redux/PROBE_UNKNOWN_ACTION_' + Math.random().toString(36).substring(7).split('').join('.');
  579. if (typeof reducer(undefined, { type: type }) === 'undefined') {
  580. 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.');
  581. }
  582. });
  583. }
  584. /**
  585. * Turns an object whose values are different reducer functions, into a single
  586. * reducer function. It will call every child reducer, and gather their results
  587. * into a single state object, whose keys correspond to the keys of the passed
  588. * reducer functions.
  589. *
  590. * @param {Object} reducers An object whose values correspond to different
  591. * reducer functions that need to be combined into one. One handy way to obtain
  592. * it is to use ES6 `import * as reducers` syntax. The reducers may never return
  593. * undefined for any action. Instead, they should return their initial state
  594. * if the state passed to them was undefined, and the current state for any
  595. * unrecognized action.
  596. *
  597. * @returns {Function} A reducer function that invokes every reducer inside the
  598. * passed object, and builds a state object with the same shape.
  599. */
  600. function combineReducers(reducers) {
  601. var reducerKeys = Object.keys(reducers);
  602. var finalReducers = {};
  603. for (var i = 0; i < reducerKeys.length; i++) {
  604. var key = reducerKeys[i];
  605. if (true) {
  606. if (typeof reducers[key] === 'undefined') {
  607. (0, _warning2['default'])('No reducer provided for key "' + key + '"');
  608. }
  609. }
  610. if (typeof reducers[key] === 'function') {
  611. finalReducers[key] = reducers[key];
  612. }
  613. }
  614. var finalReducerKeys = Object.keys(finalReducers);
  615. if (true) {
  616. var unexpectedKeyCache = {};
  617. }
  618. var sanityError;
  619. try {
  620. assertReducerSanity(finalReducers);
  621. } catch (e) {
  622. sanityError = e;
  623. }
  624. return function combination() {
  625. var state = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
  626. var action = arguments[1];
  627. if (sanityError) {
  628. throw sanityError;
  629. }
  630. if (true) {
  631. var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
  632. if (warningMessage) {
  633. (0, _warning2['default'])(warningMessage);
  634. }
  635. }
  636. var hasChanged = false;
  637. var nextState = {};
  638. for (var i = 0; i < finalReducerKeys.length; i++) {
  639. var key = finalReducerKeys[i];
  640. var reducer = finalReducers[key];
  641. var previousStateForKey = state[key];
  642. var nextStateForKey = reducer(previousStateForKey, action);
  643. if (typeof nextStateForKey === 'undefined') {
  644. var errorMessage = getUndefinedStateErrorMessage(key, action);
  645. throw new Error(errorMessage);
  646. }
  647. nextState[key] = nextStateForKey;
  648. hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
  649. }
  650. return hasChanged ? nextState : state;
  651. };
  652. }
  653. /***/ },
  654. /* 8 */
  655. /***/ function(module, exports, __webpack_require__) {
  656. var overArg = __webpack_require__(10);
  657. /** Built-in value references. */
  658. var getPrototype = overArg(Object.getPrototypeOf, Object);
  659. module.exports = getPrototype;
  660. /***/ },
  661. /* 9 */
  662. /***/ function(module, exports) {
  663. /**
  664. * Checks if `value` is a host object in IE < 9.
  665. *
  666. * @private
  667. * @param {*} value The value to check.
  668. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  669. */
  670. function isHostObject(value) {
  671. // Many host objects are `Object` objects that can coerce to strings
  672. // despite having improperly defined `toString` methods.
  673. var result = false;
  674. if (value != null && typeof value.toString != 'function') {
  675. try {
  676. result = !!(value + '');
  677. } catch (e) {}
  678. }
  679. return result;
  680. }
  681. module.exports = isHostObject;
  682. /***/ },
  683. /* 10 */
  684. /***/ function(module, exports) {
  685. /**
  686. * Creates a unary function that invokes `func` with its argument transformed.
  687. *
  688. * @private
  689. * @param {Function} func The function to wrap.
  690. * @param {Function} transform The argument transform.
  691. * @returns {Function} Returns the new function.
  692. */
  693. function overArg(func, transform) {
  694. return function(arg) {
  695. return func(transform(arg));
  696. };
  697. }
  698. module.exports = overArg;
  699. /***/ },
  700. /* 11 */
  701. /***/ function(module, exports) {
  702. /**
  703. * Checks if `value` is object-like. A value is object-like if it's not `null`
  704. * and has a `typeof` result of "object".
  705. *
  706. * @static
  707. * @memberOf _
  708. * @since 4.0.0
  709. * @category Lang
  710. * @param {*} value The value to check.
  711. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  712. * @example
  713. *
  714. * _.isObjectLike({});
  715. * // => true
  716. *
  717. * _.isObjectLike([1, 2, 3]);
  718. * // => true
  719. *
  720. * _.isObjectLike(_.noop);
  721. * // => false
  722. *
  723. * _.isObjectLike(null);
  724. * // => false
  725. */
  726. function isObjectLike(value) {
  727. return !!value && typeof value == 'object';
  728. }
  729. module.exports = isObjectLike;
  730. /***/ },
  731. /* 12 */
  732. /***/ function(module, exports, __webpack_require__) {
  733. module.exports = __webpack_require__(13);
  734. /***/ },
  735. /* 13 */
  736. /***/ function(module, exports, __webpack_require__) {
  737. /* WEBPACK VAR INJECTION */(function(global) {'use strict';
  738. Object.defineProperty(exports, "__esModule", {
  739. value: true
  740. });
  741. var _ponyfill = __webpack_require__(14);
  742. var _ponyfill2 = _interopRequireDefault(_ponyfill);
  743. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  744. var root = undefined; /* global window */
  745. if (typeof global !== 'undefined') {
  746. root = global;
  747. } else if (typeof window !== 'undefined') {
  748. root = window;
  749. }
  750. var result = (0, _ponyfill2['default'])(root);
  751. exports['default'] = result;
  752. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  753. /***/ },
  754. /* 14 */
  755. /***/ function(module, exports) {
  756. 'use strict';
  757. Object.defineProperty(exports, "__esModule", {
  758. value: true
  759. });
  760. exports['default'] = symbolObservablePonyfill;
  761. function symbolObservablePonyfill(root) {
  762. var result;
  763. var _Symbol = root.Symbol;
  764. if (typeof _Symbol === 'function') {
  765. if (_Symbol.observable) {
  766. result = _Symbol.observable;
  767. } else {
  768. result = _Symbol('observable');
  769. _Symbol.observable = result;
  770. }
  771. } else {
  772. result = '@@observable';
  773. }
  774. return result;
  775. };
  776. /***/ }
  777. /******/ ])
  778. });
  779. ;