isomorfeus-redux 4.0.23 → 4.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +27 -0
- data/lib/isomorfeus/core_ext/kernel.rb +1 -1
- data/lib/isomorfeus/execution_environment.rb +17 -10
- data/lib/isomorfeus/{redux_config.rb → redux/config.rb} +0 -0
- data/lib/isomorfeus/redux/imports.rb +17 -0
- data/lib/isomorfeus-redux.rb +7 -4
- data/lib/redux/version.rb +1 -1
- data/node_modules/.package-lock.json +31 -0
- data/node_modules/@babel/runtime/LICENSE +22 -0
- data/node_modules/@babel/runtime/README.md +19 -0
- data/node_modules/@babel/runtime/helpers/AsyncGenerator.js +99 -0
- data/node_modules/@babel/runtime/helpers/AwaitValue.js +6 -0
- data/node_modules/@babel/runtime/helpers/applyDecoratedDescriptor.js +31 -0
- data/node_modules/@babel/runtime/helpers/arrayLikeToArray.js +12 -0
- data/node_modules/@babel/runtime/helpers/arrayWithHoles.js +6 -0
- data/node_modules/@babel/runtime/helpers/arrayWithoutHoles.js +8 -0
- data/node_modules/@babel/runtime/helpers/assertThisInitialized.js +10 -0
- data/node_modules/@babel/runtime/helpers/asyncGeneratorDelegate.js +57 -0
- data/node_modules/@babel/runtime/helpers/asyncIterator.js +16 -0
- data/node_modules/@babel/runtime/helpers/asyncToGenerator.js +38 -0
- data/node_modules/@babel/runtime/helpers/awaitAsyncGenerator.js +8 -0
- data/node_modules/@babel/runtime/helpers/checkPrivateRedeclaration.js +8 -0
- data/node_modules/@babel/runtime/helpers/classApplyDescriptorDestructureSet.js +23 -0
- data/node_modules/@babel/runtime/helpers/classApplyDescriptorGet.js +10 -0
- data/node_modules/@babel/runtime/helpers/classApplyDescriptorSet.js +14 -0
- data/node_modules/@babel/runtime/helpers/classCallCheck.js +8 -0
- data/node_modules/@babel/runtime/helpers/classCheckPrivateStaticAccess.js +8 -0
- data/node_modules/@babel/runtime/helpers/classCheckPrivateStaticFieldDescriptor.js +8 -0
- data/node_modules/@babel/runtime/helpers/classExtractFieldDescriptor.js +10 -0
- data/node_modules/@babel/runtime/helpers/classNameTDZError.js +6 -0
- data/node_modules/@babel/runtime/helpers/classPrivateFieldDestructureSet.js +11 -0
- data/node_modules/@babel/runtime/helpers/classPrivateFieldGet.js +11 -0
- data/node_modules/@babel/runtime/helpers/classPrivateFieldInitSpec.js +9 -0
- data/node_modules/@babel/runtime/helpers/classPrivateFieldLooseBase.js +10 -0
- data/node_modules/@babel/runtime/helpers/classPrivateFieldLooseKey.js +8 -0
- data/node_modules/@babel/runtime/helpers/classPrivateFieldSet.js +12 -0
- data/node_modules/@babel/runtime/helpers/classPrivateMethodGet.js +10 -0
- data/node_modules/@babel/runtime/helpers/classPrivateMethodInitSpec.js +9 -0
- data/node_modules/@babel/runtime/helpers/classPrivateMethodSet.js +6 -0
- data/node_modules/@babel/runtime/helpers/classStaticPrivateFieldDestructureSet.js +14 -0
- data/node_modules/@babel/runtime/helpers/classStaticPrivateFieldSpecGet.js +14 -0
- data/node_modules/@babel/runtime/helpers/classStaticPrivateFieldSpecSet.js +15 -0
- data/node_modules/@babel/runtime/helpers/classStaticPrivateMethodGet.js +9 -0
- data/node_modules/@babel/runtime/helpers/classStaticPrivateMethodSet.js +6 -0
- data/node_modules/@babel/runtime/helpers/construct.js +26 -0
- data/node_modules/@babel/runtime/helpers/createClass.js +18 -0
- data/node_modules/@babel/runtime/helpers/createForOfIteratorHelper.js +61 -0
- data/node_modules/@babel/runtime/helpers/createForOfIteratorHelperLoose.js +25 -0
- data/node_modules/@babel/runtime/helpers/createSuper.js +25 -0
- data/node_modules/@babel/runtime/helpers/decorate.js +401 -0
- data/node_modules/@babel/runtime/helpers/defaults.js +17 -0
- data/node_modules/@babel/runtime/helpers/defineEnumerableProperties.js +25 -0
- data/node_modules/@babel/runtime/helpers/defineProperty.js +17 -0
- data/node_modules/@babel/runtime/helpers/esm/AsyncGenerator.js +95 -0
- data/node_modules/@babel/runtime/helpers/esm/AwaitValue.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/applyDecoratedDescriptor.js +28 -0
- data/node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js +9 -0
- data/node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js +4 -0
- data/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/asyncGeneratorDelegate.js +54 -0
- data/node_modules/@babel/runtime/helpers/esm/asyncIterator.js +13 -0
- data/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js +35 -0
- data/node_modules/@babel/runtime/helpers/esm/awaitAsyncGenerator.js +4 -0
- data/node_modules/@babel/runtime/helpers/esm/checkPrivateRedeclaration.js +5 -0
- data/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorDestructureSet.js +20 -0
- data/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorGet.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorSet.js +11 -0
- data/node_modules/@babel/runtime/helpers/esm/classCallCheck.js +5 -0
- data/node_modules/@babel/runtime/helpers/esm/classCheckPrivateStaticAccess.js +5 -0
- data/node_modules/@babel/runtime/helpers/esm/classCheckPrivateStaticFieldDescriptor.js +5 -0
- data/node_modules/@babel/runtime/helpers/esm/classExtractFieldDescriptor.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/classNameTDZError.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/classPrivateFieldDestructureSet.js +6 -0
- data/node_modules/@babel/runtime/helpers/esm/classPrivateFieldGet.js +6 -0
- data/node_modules/@babel/runtime/helpers/esm/classPrivateFieldInitSpec.js +5 -0
- data/node_modules/@babel/runtime/helpers/esm/classPrivateFieldLooseBase.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/classPrivateFieldLooseKey.js +4 -0
- data/node_modules/@babel/runtime/helpers/esm/classPrivateFieldSet.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/classPrivateMethodGet.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/classPrivateMethodInitSpec.js +5 -0
- data/node_modules/@babel/runtime/helpers/esm/classPrivateMethodSet.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldDestructureSet.js +8 -0
- data/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldSpecGet.js +8 -0
- data/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldSpecSet.js +9 -0
- data/node_modules/@babel/runtime/helpers/esm/classStaticPrivateMethodGet.js +5 -0
- data/node_modules/@babel/runtime/helpers/esm/classStaticPrivateMethodSet.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/construct.js +18 -0
- data/node_modules/@babel/runtime/helpers/esm/createClass.js +15 -0
- data/node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelper.js +57 -0
- data/node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelperLoose.js +21 -0
- data/node_modules/@babel/runtime/helpers/esm/createSuper.js +19 -0
- data/node_modules/@babel/runtime/helpers/esm/decorate.js +396 -0
- data/node_modules/@babel/runtime/helpers/esm/defaults.js +14 -0
- data/node_modules/@babel/runtime/helpers/esm/defineEnumerableProperties.js +22 -0
- data/node_modules/@babel/runtime/helpers/esm/defineProperty.js +14 -0
- data/node_modules/@babel/runtime/helpers/esm/extends.js +17 -0
- data/node_modules/@babel/runtime/helpers/esm/get.js +20 -0
- data/node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js +6 -0
- data/node_modules/@babel/runtime/helpers/esm/inherits.js +15 -0
- data/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js +6 -0
- data/node_modules/@babel/runtime/helpers/esm/initializerDefineProperty.js +9 -0
- data/node_modules/@babel/runtime/helpers/esm/initializerWarningHelper.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/instanceof.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/interopRequireDefault.js +5 -0
- data/node_modules/@babel/runtime/helpers/esm/interopRequireWildcard.js +51 -0
- data/node_modules/@babel/runtime/helpers/esm/isNativeFunction.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/isNativeReflectConstruct.js +12 -0
- data/node_modules/@babel/runtime/helpers/esm/iterableToArray.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js +29 -0
- data/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimitLoose.js +14 -0
- data/node_modules/@babel/runtime/helpers/esm/jsx.js +46 -0
- data/node_modules/@babel/runtime/helpers/esm/maybeArrayLike.js +9 -0
- data/node_modules/@babel/runtime/helpers/esm/newArrowCheck.js +5 -0
- data/node_modules/@babel/runtime/helpers/esm/nonIterableRest.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/objectDestructuringEmpty.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/objectSpread.js +19 -0
- data/node_modules/@babel/runtime/helpers/esm/objectSpread2.js +39 -0
- data/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js +19 -0
- data/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +14 -0
- data/node_modules/@babel/runtime/helpers/esm/package.json +3 -0
- data/node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js +11 -0
- data/node_modules/@babel/runtime/helpers/esm/readOnlyError.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/set.js +51 -0
- data/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js +8 -0
- data/node_modules/@babel/runtime/helpers/esm/skipFirstGeneratorNext.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/slicedToArray.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/slicedToArrayLoose.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/superPropBase.js +9 -0
- data/node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteral.js +11 -0
- data/node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteralLoose.js +8 -0
- data/node_modules/@babel/runtime/helpers/esm/tdz.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/temporalRef.js +5 -0
- data/node_modules/@babel/runtime/helpers/esm/temporalUndefined.js +1 -0
- data/node_modules/@babel/runtime/helpers/esm/toArray.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +13 -0
- data/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js +6 -0
- data/node_modules/@babel/runtime/helpers/esm/typeof.js +15 -0
- data/node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js +9 -0
- data/node_modules/@babel/runtime/helpers/esm/wrapAsyncGenerator.js +6 -0
- data/node_modules/@babel/runtime/helpers/esm/wrapNativeSuper.js +37 -0
- data/node_modules/@babel/runtime/helpers/esm/wrapRegExp.js +65 -0
- data/node_modules/@babel/runtime/helpers/esm/writeOnlyError.js +3 -0
- data/node_modules/@babel/runtime/helpers/extends.js +21 -0
- data/node_modules/@babel/runtime/helpers/get.js +27 -0
- data/node_modules/@babel/runtime/helpers/getPrototypeOf.js +10 -0
- data/node_modules/@babel/runtime/helpers/inherits.js +19 -0
- data/node_modules/@babel/runtime/helpers/inheritsLoose.js +10 -0
- data/node_modules/@babel/runtime/helpers/initializerDefineProperty.js +12 -0
- data/node_modules/@babel/runtime/helpers/initializerWarningHelper.js +6 -0
- data/node_modules/@babel/runtime/helpers/instanceof.js +10 -0
- data/node_modules/@babel/runtime/helpers/interopRequireDefault.js +8 -0
- data/node_modules/@babel/runtime/helpers/interopRequireWildcard.js +54 -0
- data/node_modules/@babel/runtime/helpers/isNativeFunction.js +6 -0
- data/node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js +15 -0
- data/node_modules/@babel/runtime/helpers/iterableToArray.js +6 -0
- data/node_modules/@babel/runtime/helpers/iterableToArrayLimit.js +32 -0
- data/node_modules/@babel/runtime/helpers/iterableToArrayLimitLoose.js +17 -0
- data/node_modules/@babel/runtime/helpers/jsx.js +50 -0
- data/node_modules/@babel/runtime/helpers/maybeArrayLike.js +13 -0
- data/node_modules/@babel/runtime/helpers/newArrowCheck.js +8 -0
- data/node_modules/@babel/runtime/helpers/nonIterableRest.js +6 -0
- data/node_modules/@babel/runtime/helpers/nonIterableSpread.js +6 -0
- data/node_modules/@babel/runtime/helpers/objectDestructuringEmpty.js +6 -0
- data/node_modules/@babel/runtime/helpers/objectSpread.js +23 -0
- data/node_modules/@babel/runtime/helpers/objectSpread2.js +42 -0
- data/node_modules/@babel/runtime/helpers/objectWithoutProperties.js +23 -0
- data/node_modules/@babel/runtime/helpers/objectWithoutPropertiesLoose.js +17 -0
- data/node_modules/@babel/runtime/helpers/possibleConstructorReturn.js +16 -0
- data/node_modules/@babel/runtime/helpers/readOnlyError.js +6 -0
- data/node_modules/@babel/runtime/helpers/set.js +55 -0
- data/node_modules/@babel/runtime/helpers/setPrototypeOf.js +12 -0
- data/node_modules/@babel/runtime/helpers/skipFirstGeneratorNext.js +10 -0
- data/node_modules/@babel/runtime/helpers/slicedToArray.js +14 -0
- data/node_modules/@babel/runtime/helpers/slicedToArrayLoose.js +14 -0
- data/node_modules/@babel/runtime/helpers/superPropBase.js +13 -0
- data/node_modules/@babel/runtime/helpers/taggedTemplateLiteral.js +14 -0
- data/node_modules/@babel/runtime/helpers/taggedTemplateLiteralLoose.js +11 -0
- data/node_modules/@babel/runtime/helpers/tdz.js +6 -0
- data/node_modules/@babel/runtime/helpers/temporalRef.js +10 -0
- data/node_modules/@babel/runtime/helpers/temporalUndefined.js +4 -0
- data/node_modules/@babel/runtime/helpers/toArray.js +14 -0
- data/node_modules/@babel/runtime/helpers/toConsumableArray.js +14 -0
- data/node_modules/@babel/runtime/helpers/toPrimitive.js +17 -0
- data/node_modules/@babel/runtime/helpers/toPropertyKey.js +11 -0
- data/node_modules/@babel/runtime/helpers/typeof.js +22 -0
- data/node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js +13 -0
- data/node_modules/@babel/runtime/helpers/wrapAsyncGenerator.js +10 -0
- data/node_modules/@babel/runtime/helpers/wrapNativeSuper.js +45 -0
- data/node_modules/@babel/runtime/helpers/wrapRegExp.js +72 -0
- data/node_modules/@babel/runtime/helpers/writeOnlyError.js +6 -0
- data/node_modules/@babel/runtime/package.json +848 -0
- data/node_modules/@babel/runtime/regenerator/index.js +1 -0
- data/node_modules/redux/LICENSE.md +21 -0
- data/node_modules/redux/README.md +322 -0
- data/node_modules/redux/dist/redux.js +735 -0
- data/node_modules/redux/dist/redux.min.js +1 -0
- data/node_modules/redux/es/redux.js +684 -0
- data/node_modules/redux/es/redux.mjs +1 -0
- data/node_modules/redux/index.d.ts +676 -0
- data/node_modules/redux/lib/redux.js +697 -0
- data/node_modules/redux/package.json +108 -0
- data/node_modules/redux/src/applyMiddleware.js +41 -0
- data/node_modules/redux/src/bindActionCreators.js +52 -0
- data/node_modules/redux/src/combineReducers.js +175 -0
- data/node_modules/redux/src/compose.js +22 -0
- data/node_modules/redux/src/createStore.js +315 -0
- data/node_modules/redux/src/index.js +36 -0
- data/node_modules/redux/src/utils/actionTypes.js +17 -0
- data/node_modules/redux/src/utils/formatProdErrorMessage.js +15 -0
- data/node_modules/redux/src/utils/isPlainObject.js +14 -0
- data/node_modules/redux/src/utils/kindOf.js +70 -0
- data/node_modules/redux/src/utils/symbol-observable.js +3 -0
- data/node_modules/redux/src/utils/warning.js +19 -0
- data/node_modules/regenerator-runtime/LICENSE +21 -0
- data/node_modules/regenerator-runtime/README.md +31 -0
- data/node_modules/regenerator-runtime/package.json +19 -0
- data/node_modules/regenerator-runtime/path.js +11 -0
- data/node_modules/regenerator-runtime/runtime.js +754 -0
- data/package.json +6 -0
- metadata +240 -10
- data/README.md +0 -223
@@ -0,0 +1,697 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
+
|
5
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
6
|
+
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
8
|
+
|
9
|
+
var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
|
13
|
+
*
|
14
|
+
* Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
|
15
|
+
* during build.
|
16
|
+
* @param {number} code
|
17
|
+
*/
|
18
|
+
function formatProdErrorMessage(code) {
|
19
|
+
return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or " + 'use the non-minified dev environment for full errors. ';
|
20
|
+
}
|
21
|
+
|
22
|
+
// Inlined version of the `symbol-observable` polyfill
|
23
|
+
var $$observable = (function () {
|
24
|
+
return typeof Symbol === 'function' && Symbol.observable || '@@observable';
|
25
|
+
})();
|
26
|
+
|
27
|
+
/**
|
28
|
+
* These are private action types reserved by Redux.
|
29
|
+
* For any unknown actions, you must return the current state.
|
30
|
+
* If the current state is undefined, you must return the initial state.
|
31
|
+
* Do not reference these action types directly in your code.
|
32
|
+
*/
|
33
|
+
var randomString = function randomString() {
|
34
|
+
return Math.random().toString(36).substring(7).split('').join('.');
|
35
|
+
};
|
36
|
+
|
37
|
+
var ActionTypes = {
|
38
|
+
INIT: "@@redux/INIT" + randomString(),
|
39
|
+
REPLACE: "@@redux/REPLACE" + randomString(),
|
40
|
+
PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
|
41
|
+
return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
|
42
|
+
}
|
43
|
+
};
|
44
|
+
|
45
|
+
/**
|
46
|
+
* @param {any} obj The object to inspect.
|
47
|
+
* @returns {boolean} True if the argument appears to be a plain object.
|
48
|
+
*/
|
49
|
+
function isPlainObject(obj) {
|
50
|
+
if (typeof obj !== 'object' || obj === null) return false;
|
51
|
+
var proto = obj;
|
52
|
+
|
53
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
54
|
+
proto = Object.getPrototypeOf(proto);
|
55
|
+
}
|
56
|
+
|
57
|
+
return Object.getPrototypeOf(obj) === proto;
|
58
|
+
}
|
59
|
+
|
60
|
+
// Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
|
61
|
+
function miniKindOf(val) {
|
62
|
+
if (val === void 0) return 'undefined';
|
63
|
+
if (val === null) return 'null';
|
64
|
+
var type = typeof val;
|
65
|
+
|
66
|
+
switch (type) {
|
67
|
+
case 'boolean':
|
68
|
+
case 'string':
|
69
|
+
case 'number':
|
70
|
+
case 'symbol':
|
71
|
+
case 'function':
|
72
|
+
{
|
73
|
+
return type;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
if (Array.isArray(val)) return 'array';
|
78
|
+
if (isDate(val)) return 'date';
|
79
|
+
if (isError(val)) return 'error';
|
80
|
+
var constructorName = ctorName(val);
|
81
|
+
|
82
|
+
switch (constructorName) {
|
83
|
+
case 'Symbol':
|
84
|
+
case 'Promise':
|
85
|
+
case 'WeakMap':
|
86
|
+
case 'WeakSet':
|
87
|
+
case 'Map':
|
88
|
+
case 'Set':
|
89
|
+
return constructorName;
|
90
|
+
} // other
|
91
|
+
|
92
|
+
|
93
|
+
return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
|
94
|
+
}
|
95
|
+
|
96
|
+
function ctorName(val) {
|
97
|
+
return typeof val.constructor === 'function' ? val.constructor.name : null;
|
98
|
+
}
|
99
|
+
|
100
|
+
function isError(val) {
|
101
|
+
return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
|
102
|
+
}
|
103
|
+
|
104
|
+
function isDate(val) {
|
105
|
+
if (val instanceof Date) return true;
|
106
|
+
return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
|
107
|
+
}
|
108
|
+
|
109
|
+
function kindOf(val) {
|
110
|
+
var typeOfVal = typeof val;
|
111
|
+
|
112
|
+
if (process.env.NODE_ENV !== 'production') {
|
113
|
+
typeOfVal = miniKindOf(val);
|
114
|
+
}
|
115
|
+
|
116
|
+
return typeOfVal;
|
117
|
+
}
|
118
|
+
|
119
|
+
/**
|
120
|
+
* Creates a Redux store that holds the state tree.
|
121
|
+
* The only way to change the data in the store is to call `dispatch()` on it.
|
122
|
+
*
|
123
|
+
* There should only be a single store in your app. To specify how different
|
124
|
+
* parts of the state tree respond to actions, you may combine several reducers
|
125
|
+
* into a single reducer function by using `combineReducers`.
|
126
|
+
*
|
127
|
+
* @param {Function} reducer A function that returns the next state tree, given
|
128
|
+
* the current state tree and the action to handle.
|
129
|
+
*
|
130
|
+
* @param {any} [preloadedState] The initial state. You may optionally specify it
|
131
|
+
* to hydrate the state from the server in universal apps, or to restore a
|
132
|
+
* previously serialized user session.
|
133
|
+
* If you use `combineReducers` to produce the root reducer function, this must be
|
134
|
+
* an object with the same shape as `combineReducers` keys.
|
135
|
+
*
|
136
|
+
* @param {Function} [enhancer] The store enhancer. You may optionally specify it
|
137
|
+
* to enhance the store with third-party capabilities such as middleware,
|
138
|
+
* time travel, persistence, etc. The only store enhancer that ships with Redux
|
139
|
+
* is `applyMiddleware()`.
|
140
|
+
*
|
141
|
+
* @returns {Store} A Redux store that lets you read the state, dispatch actions
|
142
|
+
* and subscribe to changes.
|
143
|
+
*/
|
144
|
+
|
145
|
+
function createStore(reducer, preloadedState, enhancer) {
|
146
|
+
var _ref2;
|
147
|
+
|
148
|
+
if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
|
149
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(0) : 'It looks like you are passing several store enhancers to ' + 'createStore(). This is not supported. Instead, compose them ' + 'together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.');
|
150
|
+
}
|
151
|
+
|
152
|
+
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
|
153
|
+
enhancer = preloadedState;
|
154
|
+
preloadedState = undefined;
|
155
|
+
}
|
156
|
+
|
157
|
+
if (typeof enhancer !== 'undefined') {
|
158
|
+
if (typeof enhancer !== 'function') {
|
159
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(1) : "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
|
160
|
+
}
|
161
|
+
|
162
|
+
return enhancer(createStore)(reducer, preloadedState);
|
163
|
+
}
|
164
|
+
|
165
|
+
if (typeof reducer !== 'function') {
|
166
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(2) : "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
|
167
|
+
}
|
168
|
+
|
169
|
+
var currentReducer = reducer;
|
170
|
+
var currentState = preloadedState;
|
171
|
+
var currentListeners = [];
|
172
|
+
var nextListeners = currentListeners;
|
173
|
+
var isDispatching = false;
|
174
|
+
/**
|
175
|
+
* This makes a shallow copy of currentListeners so we can use
|
176
|
+
* nextListeners as a temporary list while dispatching.
|
177
|
+
*
|
178
|
+
* This prevents any bugs around consumers calling
|
179
|
+
* subscribe/unsubscribe in the middle of a dispatch.
|
180
|
+
*/
|
181
|
+
|
182
|
+
function ensureCanMutateNextListeners() {
|
183
|
+
if (nextListeners === currentListeners) {
|
184
|
+
nextListeners = currentListeners.slice();
|
185
|
+
}
|
186
|
+
}
|
187
|
+
/**
|
188
|
+
* Reads the state tree managed by the store.
|
189
|
+
*
|
190
|
+
* @returns {any} The current state tree of your application.
|
191
|
+
*/
|
192
|
+
|
193
|
+
|
194
|
+
function getState() {
|
195
|
+
if (isDispatching) {
|
196
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(3) : 'You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.');
|
197
|
+
}
|
198
|
+
|
199
|
+
return currentState;
|
200
|
+
}
|
201
|
+
/**
|
202
|
+
* Adds a change listener. It will be called any time an action is dispatched,
|
203
|
+
* and some part of the state tree may potentially have changed. You may then
|
204
|
+
* call `getState()` to read the current state tree inside the callback.
|
205
|
+
*
|
206
|
+
* You may call `dispatch()` from a change listener, with the following
|
207
|
+
* caveats:
|
208
|
+
*
|
209
|
+
* 1. The subscriptions are snapshotted just before every `dispatch()` call.
|
210
|
+
* If you subscribe or unsubscribe while the listeners are being invoked, this
|
211
|
+
* will not have any effect on the `dispatch()` that is currently in progress.
|
212
|
+
* However, the next `dispatch()` call, whether nested or not, will use a more
|
213
|
+
* recent snapshot of the subscription list.
|
214
|
+
*
|
215
|
+
* 2. The listener should not expect to see all state changes, as the state
|
216
|
+
* might have been updated multiple times during a nested `dispatch()` before
|
217
|
+
* the listener is called. It is, however, guaranteed that all subscribers
|
218
|
+
* registered before the `dispatch()` started will be called with the latest
|
219
|
+
* state by the time it exits.
|
220
|
+
*
|
221
|
+
* @param {Function} listener A callback to be invoked on every dispatch.
|
222
|
+
* @returns {Function} A function to remove this change listener.
|
223
|
+
*/
|
224
|
+
|
225
|
+
|
226
|
+
function subscribe(listener) {
|
227
|
+
if (typeof listener !== 'function') {
|
228
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(4) : "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
|
229
|
+
}
|
230
|
+
|
231
|
+
if (isDispatching) {
|
232
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(5) : 'You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
|
233
|
+
}
|
234
|
+
|
235
|
+
var isSubscribed = true;
|
236
|
+
ensureCanMutateNextListeners();
|
237
|
+
nextListeners.push(listener);
|
238
|
+
return function unsubscribe() {
|
239
|
+
if (!isSubscribed) {
|
240
|
+
return;
|
241
|
+
}
|
242
|
+
|
243
|
+
if (isDispatching) {
|
244
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(6) : 'You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
|
245
|
+
}
|
246
|
+
|
247
|
+
isSubscribed = false;
|
248
|
+
ensureCanMutateNextListeners();
|
249
|
+
var index = nextListeners.indexOf(listener);
|
250
|
+
nextListeners.splice(index, 1);
|
251
|
+
currentListeners = null;
|
252
|
+
};
|
253
|
+
}
|
254
|
+
/**
|
255
|
+
* Dispatches an action. It is the only way to trigger a state change.
|
256
|
+
*
|
257
|
+
* The `reducer` function, used to create the store, will be called with the
|
258
|
+
* current state tree and the given `action`. Its return value will
|
259
|
+
* be considered the **next** state of the tree, and the change listeners
|
260
|
+
* will be notified.
|
261
|
+
*
|
262
|
+
* The base implementation only supports plain object actions. If you want to
|
263
|
+
* dispatch a Promise, an Observable, a thunk, or something else, you need to
|
264
|
+
* wrap your store creating function into the corresponding middleware. For
|
265
|
+
* example, see the documentation for the `redux-thunk` package. Even the
|
266
|
+
* middleware will eventually dispatch plain object actions using this method.
|
267
|
+
*
|
268
|
+
* @param {Object} action A plain object representing “what changed”. It is
|
269
|
+
* a good idea to keep actions serializable so you can record and replay user
|
270
|
+
* sessions, or use the time travelling `redux-devtools`. An action must have
|
271
|
+
* a `type` property which may not be `undefined`. It is a good idea to use
|
272
|
+
* string constants for action types.
|
273
|
+
*
|
274
|
+
* @returns {Object} For convenience, the same action object you dispatched.
|
275
|
+
*
|
276
|
+
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
|
277
|
+
* return something else (for example, a Promise you can await).
|
278
|
+
*/
|
279
|
+
|
280
|
+
|
281
|
+
function dispatch(action) {
|
282
|
+
if (!isPlainObject(action)) {
|
283
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(7) : "Actions must be plain objects. Instead, the actual type was: '" + kindOf(action) + "'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.");
|
284
|
+
}
|
285
|
+
|
286
|
+
if (typeof action.type === 'undefined') {
|
287
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(8) : 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
|
288
|
+
}
|
289
|
+
|
290
|
+
if (isDispatching) {
|
291
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(9) : 'Reducers may not dispatch actions.');
|
292
|
+
}
|
293
|
+
|
294
|
+
try {
|
295
|
+
isDispatching = true;
|
296
|
+
currentState = currentReducer(currentState, action);
|
297
|
+
} finally {
|
298
|
+
isDispatching = false;
|
299
|
+
}
|
300
|
+
|
301
|
+
var listeners = currentListeners = nextListeners;
|
302
|
+
|
303
|
+
for (var i = 0; i < listeners.length; i++) {
|
304
|
+
var listener = listeners[i];
|
305
|
+
listener();
|
306
|
+
}
|
307
|
+
|
308
|
+
return action;
|
309
|
+
}
|
310
|
+
/**
|
311
|
+
* Replaces the reducer currently used by the store to calculate the state.
|
312
|
+
*
|
313
|
+
* You might need this if your app implements code splitting and you want to
|
314
|
+
* load some of the reducers dynamically. You might also need this if you
|
315
|
+
* implement a hot reloading mechanism for Redux.
|
316
|
+
*
|
317
|
+
* @param {Function} nextReducer The reducer for the store to use instead.
|
318
|
+
* @returns {void}
|
319
|
+
*/
|
320
|
+
|
321
|
+
|
322
|
+
function replaceReducer(nextReducer) {
|
323
|
+
if (typeof nextReducer !== 'function') {
|
324
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(10) : "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
|
325
|
+
}
|
326
|
+
|
327
|
+
currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
|
328
|
+
// Any reducers that existed in both the new and old rootReducer
|
329
|
+
// will receive the previous state. This effectively populates
|
330
|
+
// the new state tree with any relevant data from the old one.
|
331
|
+
|
332
|
+
dispatch({
|
333
|
+
type: ActionTypes.REPLACE
|
334
|
+
});
|
335
|
+
}
|
336
|
+
/**
|
337
|
+
* Interoperability point for observable/reactive libraries.
|
338
|
+
* @returns {observable} A minimal observable of state changes.
|
339
|
+
* For more information, see the observable proposal:
|
340
|
+
* https://github.com/tc39/proposal-observable
|
341
|
+
*/
|
342
|
+
|
343
|
+
|
344
|
+
function observable() {
|
345
|
+
var _ref;
|
346
|
+
|
347
|
+
var outerSubscribe = subscribe;
|
348
|
+
return _ref = {
|
349
|
+
/**
|
350
|
+
* The minimal observable subscription method.
|
351
|
+
* @param {Object} observer Any object that can be used as an observer.
|
352
|
+
* The observer object should have a `next` method.
|
353
|
+
* @returns {subscription} An object with an `unsubscribe` method that can
|
354
|
+
* be used to unsubscribe the observable from the store, and prevent further
|
355
|
+
* emission of values from the observable.
|
356
|
+
*/
|
357
|
+
subscribe: function subscribe(observer) {
|
358
|
+
if (typeof observer !== 'object' || observer === null) {
|
359
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(11) : "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
|
360
|
+
}
|
361
|
+
|
362
|
+
function observeState() {
|
363
|
+
if (observer.next) {
|
364
|
+
observer.next(getState());
|
365
|
+
}
|
366
|
+
}
|
367
|
+
|
368
|
+
observeState();
|
369
|
+
var unsubscribe = outerSubscribe(observeState);
|
370
|
+
return {
|
371
|
+
unsubscribe: unsubscribe
|
372
|
+
};
|
373
|
+
}
|
374
|
+
}, _ref[$$observable] = function () {
|
375
|
+
return this;
|
376
|
+
}, _ref;
|
377
|
+
} // When a store is created, an "INIT" action is dispatched so that every
|
378
|
+
// reducer returns their initial state. This effectively populates
|
379
|
+
// the initial state tree.
|
380
|
+
|
381
|
+
|
382
|
+
dispatch({
|
383
|
+
type: ActionTypes.INIT
|
384
|
+
});
|
385
|
+
return _ref2 = {
|
386
|
+
dispatch: dispatch,
|
387
|
+
subscribe: subscribe,
|
388
|
+
getState: getState,
|
389
|
+
replaceReducer: replaceReducer
|
390
|
+
}, _ref2[$$observable] = observable, _ref2;
|
391
|
+
}
|
392
|
+
|
393
|
+
/**
|
394
|
+
* Prints a warning in the console if it exists.
|
395
|
+
*
|
396
|
+
* @param {String} message The warning message.
|
397
|
+
* @returns {void}
|
398
|
+
*/
|
399
|
+
function warning(message) {
|
400
|
+
/* eslint-disable no-console */
|
401
|
+
if (typeof console !== 'undefined' && typeof console.error === 'function') {
|
402
|
+
console.error(message);
|
403
|
+
}
|
404
|
+
/* eslint-enable no-console */
|
405
|
+
|
406
|
+
|
407
|
+
try {
|
408
|
+
// This error was thrown as a convenience so that if you enable
|
409
|
+
// "break on all exceptions" in your console,
|
410
|
+
// it would pause the execution at this line.
|
411
|
+
throw new Error(message);
|
412
|
+
} catch (e) {} // eslint-disable-line no-empty
|
413
|
+
|
414
|
+
}
|
415
|
+
|
416
|
+
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
|
417
|
+
var reducerKeys = Object.keys(reducers);
|
418
|
+
var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
|
419
|
+
|
420
|
+
if (reducerKeys.length === 0) {
|
421
|
+
return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
|
422
|
+
}
|
423
|
+
|
424
|
+
if (!isPlainObject(inputState)) {
|
425
|
+
return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
|
426
|
+
}
|
427
|
+
|
428
|
+
var unexpectedKeys = Object.keys(inputState).filter(function (key) {
|
429
|
+
return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
|
430
|
+
});
|
431
|
+
unexpectedKeys.forEach(function (key) {
|
432
|
+
unexpectedKeyCache[key] = true;
|
433
|
+
});
|
434
|
+
if (action && action.type === ActionTypes.REPLACE) return;
|
435
|
+
|
436
|
+
if (unexpectedKeys.length > 0) {
|
437
|
+
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.");
|
438
|
+
}
|
439
|
+
}
|
440
|
+
|
441
|
+
function assertReducerShape(reducers) {
|
442
|
+
Object.keys(reducers).forEach(function (key) {
|
443
|
+
var reducer = reducers[key];
|
444
|
+
var initialState = reducer(undefined, {
|
445
|
+
type: ActionTypes.INIT
|
446
|
+
});
|
447
|
+
|
448
|
+
if (typeof initialState === 'undefined') {
|
449
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : "The slice reducer for key \"" + 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.");
|
450
|
+
}
|
451
|
+
|
452
|
+
if (typeof reducer(undefined, {
|
453
|
+
type: ActionTypes.PROBE_UNKNOWN_ACTION()
|
454
|
+
}) === 'undefined') {
|
455
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : "The slice reducer for key \"" + 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.");
|
456
|
+
}
|
457
|
+
});
|
458
|
+
}
|
459
|
+
/**
|
460
|
+
* Turns an object whose values are different reducer functions, into a single
|
461
|
+
* reducer function. It will call every child reducer, and gather their results
|
462
|
+
* into a single state object, whose keys correspond to the keys of the passed
|
463
|
+
* reducer functions.
|
464
|
+
*
|
465
|
+
* @param {Object} reducers An object whose values correspond to different
|
466
|
+
* reducer functions that need to be combined into one. One handy way to obtain
|
467
|
+
* it is to use ES6 `import * as reducers` syntax. The reducers may never return
|
468
|
+
* undefined for any action. Instead, they should return their initial state
|
469
|
+
* if the state passed to them was undefined, and the current state for any
|
470
|
+
* unrecognized action.
|
471
|
+
*
|
472
|
+
* @returns {Function} A reducer function that invokes every reducer inside the
|
473
|
+
* passed object, and builds a state object with the same shape.
|
474
|
+
*/
|
475
|
+
|
476
|
+
|
477
|
+
function combineReducers(reducers) {
|
478
|
+
var reducerKeys = Object.keys(reducers);
|
479
|
+
var finalReducers = {};
|
480
|
+
|
481
|
+
for (var i = 0; i < reducerKeys.length; i++) {
|
482
|
+
var key = reducerKeys[i];
|
483
|
+
|
484
|
+
if (process.env.NODE_ENV !== 'production') {
|
485
|
+
if (typeof reducers[key] === 'undefined') {
|
486
|
+
warning("No reducer provided for key \"" + key + "\"");
|
487
|
+
}
|
488
|
+
}
|
489
|
+
|
490
|
+
if (typeof reducers[key] === 'function') {
|
491
|
+
finalReducers[key] = reducers[key];
|
492
|
+
}
|
493
|
+
}
|
494
|
+
|
495
|
+
var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
|
496
|
+
// keys multiple times.
|
497
|
+
|
498
|
+
var unexpectedKeyCache;
|
499
|
+
|
500
|
+
if (process.env.NODE_ENV !== 'production') {
|
501
|
+
unexpectedKeyCache = {};
|
502
|
+
}
|
503
|
+
|
504
|
+
var shapeAssertionError;
|
505
|
+
|
506
|
+
try {
|
507
|
+
assertReducerShape(finalReducers);
|
508
|
+
} catch (e) {
|
509
|
+
shapeAssertionError = e;
|
510
|
+
}
|
511
|
+
|
512
|
+
return function combination(state, action) {
|
513
|
+
if (state === void 0) {
|
514
|
+
state = {};
|
515
|
+
}
|
516
|
+
|
517
|
+
if (shapeAssertionError) {
|
518
|
+
throw shapeAssertionError;
|
519
|
+
}
|
520
|
+
|
521
|
+
if (process.env.NODE_ENV !== 'production') {
|
522
|
+
var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
|
523
|
+
|
524
|
+
if (warningMessage) {
|
525
|
+
warning(warningMessage);
|
526
|
+
}
|
527
|
+
}
|
528
|
+
|
529
|
+
var hasChanged = false;
|
530
|
+
var nextState = {};
|
531
|
+
|
532
|
+
for (var _i = 0; _i < finalReducerKeys.length; _i++) {
|
533
|
+
var _key = finalReducerKeys[_i];
|
534
|
+
var reducer = finalReducers[_key];
|
535
|
+
var previousStateForKey = state[_key];
|
536
|
+
var nextStateForKey = reducer(previousStateForKey, action);
|
537
|
+
|
538
|
+
if (typeof nextStateForKey === 'undefined') {
|
539
|
+
var actionType = action && action.type;
|
540
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : "When called with an action of type " + (actionType ? "\"" + String(actionType) + "\"" : '(unknown type)') + ", the slice reducer for key \"" + _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.");
|
541
|
+
}
|
542
|
+
|
543
|
+
nextState[_key] = nextStateForKey;
|
544
|
+
hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
|
545
|
+
}
|
546
|
+
|
547
|
+
hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
|
548
|
+
return hasChanged ? nextState : state;
|
549
|
+
};
|
550
|
+
}
|
551
|
+
|
552
|
+
function bindActionCreator(actionCreator, dispatch) {
|
553
|
+
return function () {
|
554
|
+
return dispatch(actionCreator.apply(this, arguments));
|
555
|
+
};
|
556
|
+
}
|
557
|
+
/**
|
558
|
+
* Turns an object whose values are action creators, into an object with the
|
559
|
+
* same keys, but with every function wrapped into a `dispatch` call so they
|
560
|
+
* may be invoked directly. This is just a convenience method, as you can call
|
561
|
+
* `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
|
562
|
+
*
|
563
|
+
* For convenience, you can also pass an action creator as the first argument,
|
564
|
+
* and get a dispatch wrapped function in return.
|
565
|
+
*
|
566
|
+
* @param {Function|Object} actionCreators An object whose values are action
|
567
|
+
* creator functions. One handy way to obtain it is to use ES6 `import * as`
|
568
|
+
* syntax. You may also pass a single function.
|
569
|
+
*
|
570
|
+
* @param {Function} dispatch The `dispatch` function available on your Redux
|
571
|
+
* store.
|
572
|
+
*
|
573
|
+
* @returns {Function|Object} The object mimicking the original object, but with
|
574
|
+
* every action creator wrapped into the `dispatch` call. If you passed a
|
575
|
+
* function as `actionCreators`, the return value will also be a single
|
576
|
+
* function.
|
577
|
+
*/
|
578
|
+
|
579
|
+
|
580
|
+
function bindActionCreators(actionCreators, dispatch) {
|
581
|
+
if (typeof actionCreators === 'function') {
|
582
|
+
return bindActionCreator(actionCreators, dispatch);
|
583
|
+
}
|
584
|
+
|
585
|
+
if (typeof actionCreators !== 'object' || actionCreators === null) {
|
586
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(16) : "bindActionCreators expected an object or a function, but instead received: '" + kindOf(actionCreators) + "'. " + "Did you write \"import ActionCreators from\" instead of \"import * as ActionCreators from\"?");
|
587
|
+
}
|
588
|
+
|
589
|
+
var boundActionCreators = {};
|
590
|
+
|
591
|
+
for (var key in actionCreators) {
|
592
|
+
var actionCreator = actionCreators[key];
|
593
|
+
|
594
|
+
if (typeof actionCreator === 'function') {
|
595
|
+
boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
|
596
|
+
}
|
597
|
+
}
|
598
|
+
|
599
|
+
return boundActionCreators;
|
600
|
+
}
|
601
|
+
|
602
|
+
/**
|
603
|
+
* Composes single-argument functions from right to left. The rightmost
|
604
|
+
* function can take multiple arguments as it provides the signature for
|
605
|
+
* the resulting composite function.
|
606
|
+
*
|
607
|
+
* @param {...Function} funcs The functions to compose.
|
608
|
+
* @returns {Function} A function obtained by composing the argument functions
|
609
|
+
* from right to left. For example, compose(f, g, h) is identical to doing
|
610
|
+
* (...args) => f(g(h(...args))).
|
611
|
+
*/
|
612
|
+
function compose() {
|
613
|
+
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
|
614
|
+
funcs[_key] = arguments[_key];
|
615
|
+
}
|
616
|
+
|
617
|
+
if (funcs.length === 0) {
|
618
|
+
return function (arg) {
|
619
|
+
return arg;
|
620
|
+
};
|
621
|
+
}
|
622
|
+
|
623
|
+
if (funcs.length === 1) {
|
624
|
+
return funcs[0];
|
625
|
+
}
|
626
|
+
|
627
|
+
return funcs.reduce(function (a, b) {
|
628
|
+
return function () {
|
629
|
+
return a(b.apply(void 0, arguments));
|
630
|
+
};
|
631
|
+
});
|
632
|
+
}
|
633
|
+
|
634
|
+
/**
|
635
|
+
* Creates a store enhancer that applies middleware to the dispatch method
|
636
|
+
* of the Redux store. This is handy for a variety of tasks, such as expressing
|
637
|
+
* asynchronous actions in a concise manner, or logging every action payload.
|
638
|
+
*
|
639
|
+
* See `redux-thunk` package as an example of the Redux middleware.
|
640
|
+
*
|
641
|
+
* Because middleware is potentially asynchronous, this should be the first
|
642
|
+
* store enhancer in the composition chain.
|
643
|
+
*
|
644
|
+
* Note that each middleware will be given the `dispatch` and `getState` functions
|
645
|
+
* as named arguments.
|
646
|
+
*
|
647
|
+
* @param {...Function} middlewares The middleware chain to be applied.
|
648
|
+
* @returns {Function} A store enhancer applying the middleware.
|
649
|
+
*/
|
650
|
+
|
651
|
+
function applyMiddleware() {
|
652
|
+
for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
|
653
|
+
middlewares[_key] = arguments[_key];
|
654
|
+
}
|
655
|
+
|
656
|
+
return function (createStore) {
|
657
|
+
return function () {
|
658
|
+
var store = createStore.apply(void 0, arguments);
|
659
|
+
|
660
|
+
var _dispatch = function dispatch() {
|
661
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(15) : 'Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
|
662
|
+
};
|
663
|
+
|
664
|
+
var middlewareAPI = {
|
665
|
+
getState: store.getState,
|
666
|
+
dispatch: function dispatch() {
|
667
|
+
return _dispatch.apply(void 0, arguments);
|
668
|
+
}
|
669
|
+
};
|
670
|
+
var chain = middlewares.map(function (middleware) {
|
671
|
+
return middleware(middlewareAPI);
|
672
|
+
});
|
673
|
+
_dispatch = compose.apply(void 0, chain)(store.dispatch);
|
674
|
+
return _objectSpread__default['default'](_objectSpread__default['default']({}, store), {}, {
|
675
|
+
dispatch: _dispatch
|
676
|
+
});
|
677
|
+
};
|
678
|
+
};
|
679
|
+
}
|
680
|
+
|
681
|
+
/*
|
682
|
+
* This is a dummy function to check if the function name has been altered by minification.
|
683
|
+
* If the function has been minified and NODE_ENV !== 'production', warn the user.
|
684
|
+
*/
|
685
|
+
|
686
|
+
function isCrushed() {}
|
687
|
+
|
688
|
+
if (process.env.NODE_ENV !== 'production' && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') {
|
689
|
+
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 setting mode to production in webpack (https://webpack.js.org/concepts/mode/) ' + 'to ensure you have the correct code for your production build.');
|
690
|
+
}
|
691
|
+
|
692
|
+
exports.__DO_NOT_USE__ActionTypes = ActionTypes;
|
693
|
+
exports.applyMiddleware = applyMiddleware;
|
694
|
+
exports.bindActionCreators = bindActionCreators;
|
695
|
+
exports.combineReducers = combineReducers;
|
696
|
+
exports.compose = compose;
|
697
|
+
exports.createStore = createStore;
|