@depup/reduxjs__toolkit 2.12.0-depup.29 → 2.13.0-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/changes.json +1 -1
- package/dist/cjs/redux-toolkit.development.cjs +1755 -2247
- package/dist/cjs/redux-toolkit.development.cjs.map +1 -1
- package/dist/cjs/redux-toolkit.production.min.cjs +1 -2
- package/dist/cjs/redux-toolkit.production.min.cjs.map +1 -1
- package/dist/index.d.mts +1496 -1525
- package/dist/index.d.ts +1496 -1525
- package/dist/query/cjs/rtk-query.development.cjs +2059 -2990
- package/dist/query/cjs/rtk-query.development.cjs.map +1 -1
- package/dist/query/cjs/rtk-query.production.min.cjs +1 -1
- package/dist/query/cjs/rtk-query.production.min.cjs.map +1 -1
- package/dist/query/index.d.mts +2300 -2308
- package/dist/query/index.d.ts +2300 -2308
- package/dist/query/react/cjs/rtk-query-react.development.cjs +609 -714
- package/dist/query/react/cjs/rtk-query-react.development.cjs.map +1 -1
- package/dist/query/react/cjs/rtk-query-react.production.min.cjs +1 -1
- package/dist/query/react/cjs/rtk-query-react.production.min.cjs.map +1 -1
- package/dist/query/react/index.d.mts +516 -523
- package/dist/query/react/index.d.ts +516 -523
- package/dist/query/react/rtk-query-react.browser.mjs +1 -1
- package/dist/query/react/rtk-query-react.browser.mjs.map +1 -1
- package/dist/query/react/rtk-query-react.legacy-esm.js +672 -714
- package/dist/query/react/rtk-query-react.legacy-esm.js.map +1 -1
- package/dist/query/react/rtk-query-react.modern.mjs +586 -679
- package/dist/query/react/rtk-query-react.modern.mjs.map +1 -1
- package/dist/query/rtk-query.browser.mjs +1 -1
- package/dist/query/rtk-query.browser.mjs.map +1 -1
- package/dist/query/rtk-query.legacy-esm.js +2175 -3014
- package/dist/query/rtk-query.legacy-esm.js.map +1 -1
- package/dist/query/rtk-query.modern.mjs +2052 -2949
- package/dist/query/rtk-query.modern.mjs.map +1 -1
- package/dist/react/cjs/redux-toolkit-react.development.cjs +30 -51
- package/dist/react/cjs/redux-toolkit-react.development.cjs.map +1 -1
- package/dist/react/cjs/redux-toolkit-react.production.min.cjs +1 -1
- package/dist/react/cjs/redux-toolkit-react.production.min.cjs.map +1 -1
- package/dist/react/index.d.mts +12 -15
- package/dist/react/index.d.ts +12 -15
- package/dist/react/redux-toolkit-react.browser.mjs +1 -1
- package/dist/react/redux-toolkit-react.browser.mjs.map +1 -1
- package/dist/react/redux-toolkit-react.legacy-esm.js +83 -44
- package/dist/react/redux-toolkit-react.legacy-esm.js.map +1 -1
- package/dist/react/redux-toolkit-react.modern.mjs +23 -25
- package/dist/react/redux-toolkit-react.modern.mjs.map +1 -1
- package/dist/redux-toolkit.browser.mjs +1 -2
- package/dist/redux-toolkit.browser.mjs.map +1 -1
- package/dist/redux-toolkit.legacy-esm.js +1748 -2201
- package/dist/redux-toolkit.legacy-esm.js.map +1 -1
- package/dist/redux-toolkit.modern.mjs +1670 -2171
- package/dist/redux-toolkit.modern.mjs.map +1 -1
- package/package.json +13 -29
- package/skills/build-modern-redux-apps/modern-redux/SKILL.md +23 -14
- package/skills/build-modern-redux-apps/modern-redux/references/store-lifetime.md +6 -6
- package/skills/build-modern-redux-apps/redux-dataflow/SKILL.md +13 -10
- package/skills/evolve-and-diagnose-redux-apps/debug-redux-toolkit-apps/SKILL.md +6 -6
- package/skills/evolve-and-diagnose-redux-apps/migrate-to-modern-redux/SKILL.md +7 -8
- package/skills/manage-server-data/adopt-rtk-query/SKILL.md +13 -11
- package/skills/model-redux-state/build-slices-and-selectors/SKILL.md +26 -14
- package/skills/model-redux-state/design-state-ownership/SKILL.md +11 -12
- package/skills/model-redux-state/design-state-ownership/references/state-ownership.md +6 -6
- package/skills/orchestrate-side-effects/handle-side-effects/SKILL.md +27 -23
- package/skills/orchestrate-side-effects/handle-side-effects/references/listener-workflows.md +4 -4
- package/src/autoBatchEnhancer.ts +5 -3
- package/src/combineSlices.ts +5 -5
- package/src/createAction.ts +11 -6
- package/src/createAsyncThunk.ts +14 -2
- package/src/createReducer.ts +1 -1
- package/src/createSlice.ts +9 -4
- package/src/dynamicMiddleware/index.ts +21 -5
- package/src/entities/models.ts +2 -1
- package/src/entities/sorted_state_adapter.ts +35 -24
- package/src/entities/unsorted_state_adapter.ts +1 -1
- package/src/immutableStateInvariantMiddleware.ts +34 -5
- package/src/listenerMiddleware/types.ts +10 -10
- package/src/mapBuilders.ts +2 -5
- package/src/matchers.ts +7 -1
- package/src/query/core/apiState.ts +1 -1
- package/src/query/core/buildInitiate.ts +19 -15
- package/src/query/core/buildMiddleware/cacheLifecycle.ts +3 -1
- package/src/query/core/buildMiddleware/index.ts +1 -1
- package/src/query/core/buildMiddleware/invalidationByTags.ts +4 -1
- package/src/query/core/buildMiddleware/polling.ts +12 -3
- package/src/query/core/buildMiddleware/types.ts +5 -2
- package/src/query/core/buildSlice.ts +2 -2
- package/src/query/core/buildThunks.ts +19 -0
- package/src/query/core/module.ts +9 -3
- package/src/query/createApi.ts +4 -1
- package/src/query/endpointDefinitions.ts +15 -9
- package/src/query/fetchBaseQuery.ts +1 -1
- package/src/query/react/buildHooks.ts +54 -51
- package/src/query/react/namedHooks.ts +28 -24
- package/src/query/utils/isAbsoluteUrl.ts +8 -3
- package/src/serializableStateInvariantMiddleware.ts +1 -1
|
@@ -1,2406 +1,1914 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let redux = require("redux");
|
|
3
|
+
let immer = require("immer");
|
|
4
|
+
let reselect = require("reselect");
|
|
5
|
+
let redux_thunk = require("redux-thunk");
|
|
6
|
+
//#region src/createDraftSafeSelector.ts
|
|
7
|
+
const createDraftSafeSelectorCreator = (...args) => {
|
|
8
|
+
const createSelector = (0, reselect.createSelectorCreator)(...args);
|
|
9
|
+
const createDraftSafeSelector = Object.assign((...args) => {
|
|
10
|
+
const selector = createSelector(...args);
|
|
11
|
+
const wrappedSelector = (value, ...rest) => selector((0, immer.isDraft)(value) ? (0, immer.current)(value) : value, ...rest);
|
|
12
|
+
Object.assign(wrappedSelector, selector);
|
|
13
|
+
return wrappedSelector;
|
|
14
|
+
}, { withTypes: () => createDraftSafeSelector });
|
|
15
|
+
return createDraftSafeSelector;
|
|
9
16
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
const createDraftSafeSelector = /* @__PURE__ */ createDraftSafeSelectorCreator(reselect.weakMapMemoize);
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/devtoolsExtension.ts
|
|
20
|
+
const composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function() {
|
|
21
|
+
if (arguments.length === 0) return void 0;
|
|
22
|
+
if (typeof arguments[0] === "object") return redux.compose;
|
|
23
|
+
return redux.compose.apply(null, arguments);
|
|
17
24
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
__export(src_exports, {
|
|
24
|
-
ReducerType: () => ReducerType,
|
|
25
|
-
SHOULD_AUTOBATCH: () => SHOULD_AUTOBATCH,
|
|
26
|
-
TaskAbortError: () => TaskAbortError,
|
|
27
|
-
Tuple: () => Tuple,
|
|
28
|
-
addListener: () => addListener,
|
|
29
|
-
asyncThunkCreator: () => asyncThunkCreator,
|
|
30
|
-
autoBatchEnhancer: () => autoBatchEnhancer,
|
|
31
|
-
buildCreateSlice: () => buildCreateSlice,
|
|
32
|
-
clearAllListeners: () => clearAllListeners,
|
|
33
|
-
combineSlices: () => combineSlices,
|
|
34
|
-
configureStore: () => configureStore,
|
|
35
|
-
createAction: () => createAction,
|
|
36
|
-
createActionCreatorInvariantMiddleware: () => createActionCreatorInvariantMiddleware,
|
|
37
|
-
createAsyncThunk: () => createAsyncThunk,
|
|
38
|
-
createDraftSafeSelector: () => createDraftSafeSelector,
|
|
39
|
-
createDraftSafeSelectorCreator: () => createDraftSafeSelectorCreator,
|
|
40
|
-
createDynamicMiddleware: () => createDynamicMiddleware,
|
|
41
|
-
createEntityAdapter: () => createEntityAdapter,
|
|
42
|
-
createImmutableStateInvariantMiddleware: () => createImmutableStateInvariantMiddleware,
|
|
43
|
-
createListenerMiddleware: () => createListenerMiddleware,
|
|
44
|
-
createNextState: () => import_immer.produce,
|
|
45
|
-
createReducer: () => createReducer,
|
|
46
|
-
createSelector: () => import_reselect2.createSelector,
|
|
47
|
-
createSelectorCreator: () => import_reselect.createSelectorCreator,
|
|
48
|
-
createSerializableStateInvariantMiddleware: () => createSerializableStateInvariantMiddleware,
|
|
49
|
-
createSlice: () => createSlice,
|
|
50
|
-
current: () => import_immer.current,
|
|
51
|
-
findNonSerializableValue: () => findNonSerializableValue,
|
|
52
|
-
formatProdErrorMessage: () => formatProdErrorMessage,
|
|
53
|
-
freeze: () => import_immer2.freeze,
|
|
54
|
-
isActionCreator: () => isActionCreator,
|
|
55
|
-
isAllOf: () => isAllOf,
|
|
56
|
-
isAnyOf: () => isAnyOf,
|
|
57
|
-
isAsyncThunkAction: () => isAsyncThunkAction,
|
|
58
|
-
isDraft: () => import_immer.isDraft,
|
|
59
|
-
isFluxStandardAction: () => isFSA,
|
|
60
|
-
isFulfilled: () => isFulfilled,
|
|
61
|
-
isImmutableDefault: () => isImmutableDefault,
|
|
62
|
-
isPending: () => isPending,
|
|
63
|
-
isPlain: () => isPlain,
|
|
64
|
-
isRejected: () => isRejected,
|
|
65
|
-
isRejectedWithValue: () => isRejectedWithValue,
|
|
66
|
-
lruMemoize: () => import_reselect2.lruMemoize,
|
|
67
|
-
miniSerializeError: () => miniSerializeError,
|
|
68
|
-
nanoid: () => nanoid,
|
|
69
|
-
original: () => import_immer2.original,
|
|
70
|
-
prepareAutoBatched: () => prepareAutoBatched,
|
|
71
|
-
removeListener: () => removeListener,
|
|
72
|
-
unwrapResult: () => unwrapResult,
|
|
73
|
-
weakMapMemoize: () => import_reselect.weakMapMemoize
|
|
74
|
-
});
|
|
75
|
-
module.exports = __toCommonJS(src_exports);
|
|
76
|
-
__reExport(src_exports, require("redux"), module.exports);
|
|
77
|
-
var import_immer2 = require("immer");
|
|
78
|
-
|
|
79
|
-
// src/immerImports.ts
|
|
80
|
-
var import_immer = require("immer");
|
|
81
|
-
|
|
82
|
-
// src/index.ts
|
|
83
|
-
var import_reselect2 = require("reselect");
|
|
84
|
-
|
|
85
|
-
// src/reselectImports.ts
|
|
86
|
-
var import_reselect = require("reselect");
|
|
87
|
-
|
|
88
|
-
// src/createDraftSafeSelector.ts
|
|
89
|
-
var createDraftSafeSelectorCreator = (...args) => {
|
|
90
|
-
const createSelector2 = (0, import_reselect.createSelectorCreator)(...args);
|
|
91
|
-
const createDraftSafeSelector2 = Object.assign((...args2) => {
|
|
92
|
-
const selector = createSelector2(...args2);
|
|
93
|
-
const wrappedSelector = (value, ...rest) => selector((0, import_immer.isDraft)(value) ? (0, import_immer.current)(value) : value, ...rest);
|
|
94
|
-
Object.assign(wrappedSelector, selector);
|
|
95
|
-
return wrappedSelector;
|
|
96
|
-
}, {
|
|
97
|
-
withTypes: () => createDraftSafeSelector2
|
|
98
|
-
});
|
|
99
|
-
return createDraftSafeSelector2;
|
|
25
|
+
typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__;
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/tsHelpers.ts
|
|
28
|
+
const hasMatchFunction = (v) => {
|
|
29
|
+
return v && typeof v.match === "function";
|
|
100
30
|
};
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
// src/reduxImports.ts
|
|
104
|
-
var import_redux = require("redux");
|
|
105
|
-
|
|
106
|
-
// src/devtoolsExtension.ts
|
|
107
|
-
var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function() {
|
|
108
|
-
if (arguments.length === 0) return void 0;
|
|
109
|
-
if (typeof arguments[0] === "object") return import_redux.compose;
|
|
110
|
-
return import_redux.compose.apply(null, arguments);
|
|
111
|
-
};
|
|
112
|
-
var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function() {
|
|
113
|
-
return function(noop3) {
|
|
114
|
-
return noop3;
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
// src/getDefaultMiddleware.ts
|
|
119
|
-
var import_redux_thunk = require("redux-thunk");
|
|
120
|
-
|
|
121
|
-
// src/tsHelpers.ts
|
|
122
|
-
var hasMatchFunction = (v) => {
|
|
123
|
-
return v && typeof v.match === "function";
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
// src/createAction.ts
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/createAction.ts
|
|
127
33
|
function createAction(type, prepareAction) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
actionCreator.toString = () => `${type}`;
|
|
151
|
-
actionCreator.type = type;
|
|
152
|
-
actionCreator.match = (action) => (0, import_redux.isAction)(action) && action.type === type;
|
|
153
|
-
return actionCreator;
|
|
34
|
+
function actionCreator(...args) {
|
|
35
|
+
if (prepareAction) {
|
|
36
|
+
let prepared = prepareAction(...args);
|
|
37
|
+
if (!prepared) throw new Error("prepareAction did not return an object");
|
|
38
|
+
return {
|
|
39
|
+
type,
|
|
40
|
+
payload: prepared.payload,
|
|
41
|
+
..."meta" in prepared && { meta: prepared.meta },
|
|
42
|
+
..."error" in prepared && { error: prepared.error }
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
type,
|
|
47
|
+
payload: args[0]
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
actionCreator.toString = () => `${type}`;
|
|
51
|
+
actionCreator.type = type;
|
|
52
|
+
actionCreator.match = (action) => (0, redux.isAction)(action) && action.type === type;
|
|
53
|
+
return actionCreator;
|
|
154
54
|
}
|
|
155
55
|
function isActionCreator(action) {
|
|
156
|
-
|
|
157
|
-
hasMatchFunction(action);
|
|
56
|
+
return typeof action === "function" && "type" in action && hasMatchFunction(action);
|
|
158
57
|
}
|
|
159
58
|
function isFSA(action) {
|
|
160
|
-
|
|
59
|
+
return (0, redux.isAction)(action) && Object.keys(action).every(isValidKey);
|
|
161
60
|
}
|
|
162
61
|
function isValidKey(key) {
|
|
163
|
-
|
|
62
|
+
return [
|
|
63
|
+
"type",
|
|
64
|
+
"payload",
|
|
65
|
+
"error",
|
|
66
|
+
"meta"
|
|
67
|
+
].indexOf(key) > -1;
|
|
164
68
|
}
|
|
165
|
-
|
|
166
|
-
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/actionCreatorInvariantMiddleware.ts
|
|
167
71
|
function getMessage(type) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
72
|
+
const splitType = type ? `${type}`.split("/") : [];
|
|
73
|
+
const actionName = splitType[splitType.length - 1] || "actionCreator";
|
|
74
|
+
return `Detected an action creator with type "${type || "unknown"}" being dispatched.
|
|
171
75
|
Make sure you're calling the action creator before dispatching, i.e. \`dispatch(${actionName}())\` instead of \`dispatch(${actionName})\`. This is necessary even if the action has no payload.`;
|
|
172
76
|
}
|
|
173
77
|
function createActionCreatorInvariantMiddleware(options = {}) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
} = options;
|
|
180
|
-
return () => (next) => (action) => {
|
|
181
|
-
if (isActionCreator2(action)) {
|
|
182
|
-
console.warn(getMessage(action.type));
|
|
183
|
-
}
|
|
184
|
-
return next(action);
|
|
185
|
-
};
|
|
78
|
+
const { isActionCreator: isActionCreator$1 = isActionCreator } = options;
|
|
79
|
+
return () => (next) => (action) => {
|
|
80
|
+
if (isActionCreator$1(action)) console.warn(getMessage(action.type));
|
|
81
|
+
return next(action);
|
|
82
|
+
};
|
|
186
83
|
}
|
|
187
|
-
|
|
188
|
-
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/utils.ts
|
|
189
86
|
function getTimeMeasureUtils(maxDelay, fnName) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (elapsed > maxDelay) {
|
|
203
|
-
console.warn(`${fnName} took ${elapsed}ms, which is more than the warning threshold of ${maxDelay}ms.
|
|
87
|
+
let elapsed = 0;
|
|
88
|
+
return {
|
|
89
|
+
measureTime(fn) {
|
|
90
|
+
const started = Date.now();
|
|
91
|
+
try {
|
|
92
|
+
return fn();
|
|
93
|
+
} finally {
|
|
94
|
+
elapsed += Date.now() - started;
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
warnIfExceeded() {
|
|
98
|
+
if (elapsed > maxDelay) console.warn(`${fnName} took ${elapsed}ms, which is more than the warning threshold of ${maxDelay}ms.
|
|
204
99
|
If your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.
|
|
205
100
|
It is disabled in production builds, so you don't need to worry about that.`);
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
};
|
|
101
|
+
}
|
|
102
|
+
};
|
|
209
103
|
}
|
|
210
|
-
var Tuple = class
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
return new _Tuple(...arr.concat(this));
|
|
226
|
-
}
|
|
104
|
+
var Tuple = class Tuple extends Array {
|
|
105
|
+
constructor(...items) {
|
|
106
|
+
super(...items);
|
|
107
|
+
Object.setPrototypeOf(this, Tuple.prototype);
|
|
108
|
+
}
|
|
109
|
+
static get [Symbol.species]() {
|
|
110
|
+
return Tuple;
|
|
111
|
+
}
|
|
112
|
+
concat(...arr) {
|
|
113
|
+
return super.concat.apply(this, arr);
|
|
114
|
+
}
|
|
115
|
+
prepend(...arr) {
|
|
116
|
+
if (arr.length === 1 && Array.isArray(arr[0])) return new Tuple(...arr[0].concat(this));
|
|
117
|
+
return new Tuple(...arr.concat(this));
|
|
118
|
+
}
|
|
227
119
|
};
|
|
228
120
|
function freezeDraftable(val) {
|
|
229
|
-
|
|
230
|
-
}) : val;
|
|
121
|
+
return (0, immer.isDraftable)(val) ? (0, immer.produce)(val, () => {}) : val;
|
|
231
122
|
}
|
|
232
123
|
function getOrInsertComputed(map, key, compute) {
|
|
233
|
-
|
|
234
|
-
|
|
124
|
+
if (map.has(key)) return map.get(key);
|
|
125
|
+
return map.set(key, compute(key)).get(key);
|
|
235
126
|
}
|
|
236
|
-
|
|
237
|
-
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/immutableStateInvariantMiddleware.ts
|
|
238
129
|
function isImmutableDefault(value) {
|
|
239
|
-
|
|
130
|
+
return typeof value !== "object" || value == null || Object.isFrozen(value);
|
|
240
131
|
}
|
|
241
132
|
function trackForMutations(isImmutable, ignoredPaths, obj) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
};
|
|
133
|
+
const trackedProperties = trackProperties(isImmutable, ignoredPaths, obj);
|
|
134
|
+
return { detectMutations() {
|
|
135
|
+
return detectMutations(isImmutable, ignoredPaths, trackedProperties, obj);
|
|
136
|
+
} };
|
|
248
137
|
}
|
|
249
|
-
function trackProperties(isImmutable, ignoredPaths = [], obj, path = "",
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
tracked.children[key] = trackProperties(isImmutable, ignoredPaths, obj[key], nestedPath);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return tracked;
|
|
138
|
+
function trackProperties(isImmutable, ignoredPaths = [], obj, path = "", inProgress = /* @__PURE__ */ new Map()) {
|
|
139
|
+
const tracked = { value: obj };
|
|
140
|
+
if (!isImmutable(obj)) {
|
|
141
|
+
const alreadyInProgress = inProgress.get(obj);
|
|
142
|
+
if (alreadyInProgress) return alreadyInProgress;
|
|
143
|
+
tracked.children = {};
|
|
144
|
+
inProgress.set(obj, tracked);
|
|
145
|
+
const hasIgnoredPaths = ignoredPaths.length > 0;
|
|
146
|
+
for (const key in obj) {
|
|
147
|
+
const nestedPath = path ? path + "." + key : key;
|
|
148
|
+
if (hasIgnoredPaths) {
|
|
149
|
+
if (ignoredPaths.some((ignored) => {
|
|
150
|
+
if (ignored instanceof RegExp) return ignored.test(nestedPath);
|
|
151
|
+
return nestedPath === ignored;
|
|
152
|
+
})) continue;
|
|
153
|
+
}
|
|
154
|
+
tracked.children[key] = trackProperties(isImmutable, ignoredPaths, obj[key], nestedPath, inProgress);
|
|
155
|
+
}
|
|
156
|
+
inProgress.delete(obj);
|
|
157
|
+
}
|
|
158
|
+
return tracked;
|
|
274
159
|
}
|
|
275
|
-
function detectMutations(isImmutable, ignoredPaths = [], trackedProperty, obj, sameParentRef = false, path = "") {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
});
|
|
306
|
-
if (hasMatches) {
|
|
307
|
-
continue;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
const result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);
|
|
311
|
-
if (result.wasMutated) {
|
|
312
|
-
return result;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
return {
|
|
316
|
-
wasMutated: false
|
|
317
|
-
};
|
|
160
|
+
function detectMutations(isImmutable, ignoredPaths = [], trackedProperty, obj, sameParentRef = false, path = "", seen = /* @__PURE__ */ new Map()) {
|
|
161
|
+
const prevObj = trackedProperty ? trackedProperty.value : void 0;
|
|
162
|
+
const sameRef = prevObj === obj;
|
|
163
|
+
if (sameParentRef && !sameRef && !Number.isNaN(obj)) return {
|
|
164
|
+
wasMutated: true,
|
|
165
|
+
path
|
|
166
|
+
};
|
|
167
|
+
if (isImmutable(prevObj) || isImmutable(obj)) return { wasMutated: false };
|
|
168
|
+
let seenValues = seen.get(trackedProperty);
|
|
169
|
+
if (!seenValues) {
|
|
170
|
+
seenValues = /* @__PURE__ */ new Set();
|
|
171
|
+
seen.set(trackedProperty, seenValues);
|
|
172
|
+
} else if (seenValues.has(obj)) return { wasMutated: false };
|
|
173
|
+
seenValues.add(obj);
|
|
174
|
+
const keysToDetect = {};
|
|
175
|
+
for (let key in trackedProperty.children) keysToDetect[key] = true;
|
|
176
|
+
for (let key in obj) keysToDetect[key] = true;
|
|
177
|
+
const hasIgnoredPaths = ignoredPaths.length > 0;
|
|
178
|
+
for (let key in keysToDetect) {
|
|
179
|
+
const nestedPath = path ? path + "." + key : key;
|
|
180
|
+
if (hasIgnoredPaths) {
|
|
181
|
+
if (ignoredPaths.some((ignored) => {
|
|
182
|
+
if (ignored instanceof RegExp) return ignored.test(nestedPath);
|
|
183
|
+
return nestedPath === ignored;
|
|
184
|
+
})) continue;
|
|
185
|
+
}
|
|
186
|
+
const result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath, seen);
|
|
187
|
+
if (result.wasMutated) return result;
|
|
188
|
+
}
|
|
189
|
+
return { wasMutated: false };
|
|
318
190
|
}
|
|
319
191
|
function createImmutableStateInvariantMiddleware(options = {}) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
measureUtils.warnIfExceeded();
|
|
374
|
-
return dispatchedAction;
|
|
375
|
-
};
|
|
376
|
-
};
|
|
377
|
-
}
|
|
192
|
+
{
|
|
193
|
+
function stringify(obj, serializer, indent, decycler) {
|
|
194
|
+
return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
|
|
195
|
+
}
|
|
196
|
+
function getSerialize(serializer, decycler) {
|
|
197
|
+
let stack = [], keys = [];
|
|
198
|
+
if (!decycler) decycler = function(_, value) {
|
|
199
|
+
if (stack[0] === value) return "[Circular ~]";
|
|
200
|
+
return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
|
|
201
|
+
};
|
|
202
|
+
return function(key, value) {
|
|
203
|
+
if (stack.length > 0) {
|
|
204
|
+
var thisPos = stack.indexOf(this);
|
|
205
|
+
if (~thisPos) {
|
|
206
|
+
stack.splice(thisPos + 1);
|
|
207
|
+
keys.splice(thisPos, Infinity, key);
|
|
208
|
+
} else {
|
|
209
|
+
stack.push(this);
|
|
210
|
+
keys.push(key);
|
|
211
|
+
}
|
|
212
|
+
if (~stack.indexOf(value)) value = decycler.call(this, key, value);
|
|
213
|
+
} else stack.push(value);
|
|
214
|
+
return serializer == null ? value : serializer.call(this, key, value);
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
let { isImmutable = isImmutableDefault, ignoredPaths, warnAfter = 32 } = options;
|
|
218
|
+
const track = trackForMutations.bind(null, isImmutable, ignoredPaths);
|
|
219
|
+
return ({ getState }) => {
|
|
220
|
+
let state = getState();
|
|
221
|
+
let tracker = track(state);
|
|
222
|
+
let result;
|
|
223
|
+
return (next) => (action) => {
|
|
224
|
+
const measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
|
|
225
|
+
measureUtils.measureTime(() => {
|
|
226
|
+
state = getState();
|
|
227
|
+
result = tracker.detectMutations();
|
|
228
|
+
tracker = track(state);
|
|
229
|
+
if (result.wasMutated) throw new Error(`A state mutation was detected between dispatches, in the path '${result.path || ""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`);
|
|
230
|
+
});
|
|
231
|
+
const dispatchedAction = next(action);
|
|
232
|
+
measureUtils.measureTime(() => {
|
|
233
|
+
state = getState();
|
|
234
|
+
result = tracker.detectMutations();
|
|
235
|
+
tracker = track(state);
|
|
236
|
+
if (result.wasMutated) throw new Error(`A state mutation was detected inside a dispatch, in the path: ${result.path || ""}. Take a look at the reducer(s) handling the action ${stringify(action)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`);
|
|
237
|
+
});
|
|
238
|
+
measureUtils.warnIfExceeded();
|
|
239
|
+
return dispatchedAction;
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
}
|
|
378
243
|
}
|
|
379
|
-
|
|
380
|
-
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region src/serializableStateInvariantMiddleware.ts
|
|
381
246
|
function isPlain(val) {
|
|
382
|
-
|
|
383
|
-
|
|
247
|
+
const type = typeof val;
|
|
248
|
+
return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || (0, redux.isPlainObject)(val);
|
|
384
249
|
}
|
|
385
250
|
function findNonSerializableValue(value, path = "", isSerializable = isPlain, getEntries, ignoredPaths = [], cache) {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
keyPath: nestedPath,
|
|
415
|
-
value: nestedValue
|
|
416
|
-
};
|
|
417
|
-
}
|
|
418
|
-
if (typeof nestedValue === "object") {
|
|
419
|
-
foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
|
|
420
|
-
if (foundNestedSerializable) {
|
|
421
|
-
return foundNestedSerializable;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
if (cache && isNestedFrozen(value)) cache.add(value);
|
|
426
|
-
return false;
|
|
251
|
+
let foundNestedSerializable;
|
|
252
|
+
if (!isSerializable(value)) return {
|
|
253
|
+
keyPath: path || "<root>",
|
|
254
|
+
value
|
|
255
|
+
};
|
|
256
|
+
if (typeof value !== "object" || value === null) return false;
|
|
257
|
+
if (cache?.has(value)) return false;
|
|
258
|
+
const entries = getEntries != null ? getEntries(value) : Object.entries(value);
|
|
259
|
+
const hasIgnoredPaths = ignoredPaths.length > 0;
|
|
260
|
+
for (const [key, nestedValue] of entries) {
|
|
261
|
+
const nestedPath = path ? path + "." + key : key;
|
|
262
|
+
if (hasIgnoredPaths) {
|
|
263
|
+
if (ignoredPaths.some((ignored) => {
|
|
264
|
+
if (ignored instanceof RegExp) return ignored.test(nestedPath);
|
|
265
|
+
return nestedPath === ignored;
|
|
266
|
+
})) continue;
|
|
267
|
+
}
|
|
268
|
+
if (!isSerializable(nestedValue)) return {
|
|
269
|
+
keyPath: nestedPath,
|
|
270
|
+
value: nestedValue
|
|
271
|
+
};
|
|
272
|
+
if (typeof nestedValue === "object") {
|
|
273
|
+
foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
|
|
274
|
+
if (foundNestedSerializable) return foundNestedSerializable;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
if (cache && isNestedFrozen(value)) cache.add(value);
|
|
278
|
+
return false;
|
|
427
279
|
}
|
|
428
280
|
function isNestedFrozen(value) {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
281
|
+
if (!Object.isFrozen(value)) return false;
|
|
282
|
+
for (const nestedValue of Object.values(value)) {
|
|
283
|
+
if (typeof nestedValue !== "object" || nestedValue === null) continue;
|
|
284
|
+
if (!isNestedFrozen(nestedValue)) return false;
|
|
285
|
+
}
|
|
286
|
+
return true;
|
|
435
287
|
}
|
|
436
288
|
function createSerializableStateInvariantMiddleware(options = {}) {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
const measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
|
|
458
|
-
if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
|
|
459
|
-
measureUtils.measureTime(() => {
|
|
460
|
-
const foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
|
|
461
|
-
if (foundActionNonSerializableValue) {
|
|
462
|
-
const {
|
|
463
|
-
keyPath,
|
|
464
|
-
value
|
|
465
|
-
} = foundActionNonSerializableValue;
|
|
466
|
-
console.error(`A non-serializable value was detected in an action, in the path: \`${keyPath}\`. Value:`, value, "\nTake a look at the logic that dispatched this action: ", action, "\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)", "\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)");
|
|
467
|
-
}
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
if (!ignoreState) {
|
|
471
|
-
measureUtils.measureTime(() => {
|
|
472
|
-
const state = storeAPI.getState();
|
|
473
|
-
const foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
|
|
474
|
-
if (foundStateNonSerializableValue) {
|
|
475
|
-
const {
|
|
476
|
-
keyPath,
|
|
477
|
-
value
|
|
478
|
-
} = foundStateNonSerializableValue;
|
|
479
|
-
console.error(`A non-serializable value was detected in the state, in the path: \`${keyPath}\`. Value:`, value, `
|
|
289
|
+
{
|
|
290
|
+
const { isSerializable = isPlain, getEntries, ignoredActions = [], ignoredActionPaths = ["meta.arg", "meta.baseQueryMeta"], ignoredPaths = [], warnAfter = 32, ignoreState = false, ignoreActions = false, disableCache = false } = options;
|
|
291
|
+
const cache = !disableCache && WeakSet ? /* @__PURE__ */ new WeakSet() : void 0;
|
|
292
|
+
return (storeAPI) => (next) => (action) => {
|
|
293
|
+
if (!(0, redux.isAction)(action)) return next(action);
|
|
294
|
+
const result = next(action);
|
|
295
|
+
const measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
|
|
296
|
+
if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) measureUtils.measureTime(() => {
|
|
297
|
+
const foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
|
|
298
|
+
if (foundActionNonSerializableValue) {
|
|
299
|
+
const { keyPath, value } = foundActionNonSerializableValue;
|
|
300
|
+
console.error(`A non-serializable value was detected in an action, in the path: \`${keyPath}\`. Value:`, value, "\nTake a look at the logic that dispatched this action: ", action, "\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-why-should-my-action-types-be-constants)", "\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)");
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
if (!ignoreState) {
|
|
304
|
+
measureUtils.measureTime(() => {
|
|
305
|
+
const foundStateNonSerializableValue = findNonSerializableValue(storeAPI.getState(), "", isSerializable, getEntries, ignoredPaths, cache);
|
|
306
|
+
if (foundStateNonSerializableValue) {
|
|
307
|
+
const { keyPath, value } = foundStateNonSerializableValue;
|
|
308
|
+
console.error(`A non-serializable value was detected in the state, in the path: \`${keyPath}\`. Value:`, value, `
|
|
480
309
|
Take a look at the reducer(s) handling this action type: ${action.type}.
|
|
481
310
|
(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`);
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
measureUtils.warnIfExceeded();
|
|
314
|
+
}
|
|
315
|
+
return result;
|
|
316
|
+
};
|
|
317
|
+
}
|
|
489
318
|
}
|
|
490
|
-
|
|
491
|
-
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region src/getDefaultMiddleware.ts
|
|
492
321
|
function isBoolean(x) {
|
|
493
|
-
|
|
322
|
+
return typeof x === "boolean";
|
|
494
323
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
if (serializableCheck) {
|
|
519
|
-
let serializableOptions = {};
|
|
520
|
-
if (!isBoolean(serializableCheck)) {
|
|
521
|
-
serializableOptions = serializableCheck;
|
|
522
|
-
}
|
|
523
|
-
middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
|
|
524
|
-
}
|
|
525
|
-
if (actionCreatorCheck) {
|
|
526
|
-
let actionCreatorOptions = {};
|
|
527
|
-
if (!isBoolean(actionCreatorCheck)) {
|
|
528
|
-
actionCreatorOptions = actionCreatorCheck;
|
|
529
|
-
}
|
|
530
|
-
middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
return middlewareArray;
|
|
324
|
+
const buildGetDefaultMiddleware = () => function getDefaultMiddleware(options) {
|
|
325
|
+
const { thunk = true, immutableCheck = true, serializableCheck = true, actionCreatorCheck = true } = options ?? {};
|
|
326
|
+
let middlewareArray = new Tuple();
|
|
327
|
+
if (thunk) {
|
|
328
|
+
if (isBoolean(thunk)) middlewareArray.push(redux_thunk.thunk);
|
|
329
|
+
else middlewareArray.push((0, redux_thunk.withExtraArgument)(thunk.extraArgument));
|
|
330
|
+
}
|
|
331
|
+
if (immutableCheck) {
|
|
332
|
+
let immutableOptions = {};
|
|
333
|
+
if (!isBoolean(immutableCheck)) immutableOptions = immutableCheck;
|
|
334
|
+
middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
|
|
335
|
+
}
|
|
336
|
+
if (serializableCheck) {
|
|
337
|
+
let serializableOptions = {};
|
|
338
|
+
if (!isBoolean(serializableCheck)) serializableOptions = serializableCheck;
|
|
339
|
+
middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
|
|
340
|
+
}
|
|
341
|
+
if (actionCreatorCheck) {
|
|
342
|
+
let actionCreatorOptions = {};
|
|
343
|
+
if (!isBoolean(actionCreatorCheck)) actionCreatorOptions = actionCreatorCheck;
|
|
344
|
+
middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
|
|
345
|
+
}
|
|
346
|
+
return middlewareArray;
|
|
534
347
|
};
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
[SHOULD_AUTOBATCH]: true
|
|
542
|
-
}
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region src/autoBatchEnhancer.ts
|
|
350
|
+
const SHOULD_AUTOBATCH = "RTK_autoBatch";
|
|
351
|
+
const prepareAutoBatched = () => (payload) => ({
|
|
352
|
+
payload,
|
|
353
|
+
meta: { [SHOULD_AUTOBATCH]: true }
|
|
543
354
|
});
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
355
|
+
const createQueueWithTimer = (timeout) => {
|
|
356
|
+
return (notify) => {
|
|
357
|
+
setTimeout(notify, timeout);
|
|
358
|
+
};
|
|
548
359
|
};
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
360
|
+
const createRafWithFallbackTimer = (raf, timeout) => {
|
|
361
|
+
return (notify) => {
|
|
362
|
+
let called = false;
|
|
363
|
+
let rafId;
|
|
364
|
+
let timerId;
|
|
365
|
+
const callback = () => {
|
|
366
|
+
if (called) return;
|
|
367
|
+
called = true;
|
|
368
|
+
cancelAnimationFrame(rafId);
|
|
369
|
+
clearTimeout(timerId);
|
|
370
|
+
notify();
|
|
371
|
+
};
|
|
372
|
+
rafId = raf(callback);
|
|
373
|
+
timerId = setTimeout(callback, timeout);
|
|
374
|
+
};
|
|
562
375
|
};
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
queueCallback(notifyListeners);
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
return store.dispatch(action);
|
|
607
|
-
} finally {
|
|
608
|
-
notifying = true;
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
});
|
|
376
|
+
const autoBatchEnhancer = (options = { type: "raf" }) => (next) => (...args) => {
|
|
377
|
+
const store = next(...args);
|
|
378
|
+
let notifying = true;
|
|
379
|
+
let shouldNotifyAtEndOfTick = false;
|
|
380
|
+
let notificationQueued = false;
|
|
381
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
382
|
+
const queueCallback = options.type === "tick" ? queueMicrotask : options.type === "raf" ? typeof window !== "undefined" && window.requestAnimationFrame ? createRafWithFallbackTimer(window.requestAnimationFrame, 100) : createQueueWithTimer(10) : options.type === "callback" ? options.queueNotification : createQueueWithTimer(options.timeout);
|
|
383
|
+
const notifyListeners = () => {
|
|
384
|
+
notificationQueued = false;
|
|
385
|
+
if (shouldNotifyAtEndOfTick) {
|
|
386
|
+
shouldNotifyAtEndOfTick = false;
|
|
387
|
+
listeners.forEach((l) => l());
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
return Object.assign({}, store, {
|
|
391
|
+
subscribe(listener) {
|
|
392
|
+
const wrappedListener = () => notifying && listener();
|
|
393
|
+
const unsubscribe = store.subscribe(wrappedListener);
|
|
394
|
+
listeners.add(listener);
|
|
395
|
+
return () => {
|
|
396
|
+
unsubscribe();
|
|
397
|
+
listeners.delete(listener);
|
|
398
|
+
};
|
|
399
|
+
},
|
|
400
|
+
dispatch(action) {
|
|
401
|
+
try {
|
|
402
|
+
notifying = !action?.meta?.[SHOULD_AUTOBATCH];
|
|
403
|
+
shouldNotifyAtEndOfTick = !notifying;
|
|
404
|
+
if (shouldNotifyAtEndOfTick) {
|
|
405
|
+
if (!notificationQueued) {
|
|
406
|
+
notificationQueued = true;
|
|
407
|
+
queueCallback(notifyListeners);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return store.dispatch(action);
|
|
411
|
+
} finally {
|
|
412
|
+
notifying = true;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
});
|
|
612
416
|
};
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
if (autoBatch) {
|
|
621
|
-
enhancerArray.push(autoBatchEnhancer(typeof autoBatch === "object" ? autoBatch : void 0));
|
|
622
|
-
}
|
|
623
|
-
return enhancerArray;
|
|
417
|
+
//#endregion
|
|
418
|
+
//#region src/getDefaultEnhancers.ts
|
|
419
|
+
const buildGetDefaultEnhancers = (middlewareEnhancer) => function getDefaultEnhancers(options) {
|
|
420
|
+
const { autoBatch = true } = options ?? {};
|
|
421
|
+
let enhancerArray = new Tuple(middlewareEnhancer);
|
|
422
|
+
if (autoBatch) enhancerArray.push(autoBatchEnhancer(typeof autoBatch === "object" ? autoBatch : void 0));
|
|
423
|
+
return enhancerArray;
|
|
624
424
|
};
|
|
625
|
-
|
|
626
|
-
|
|
425
|
+
//#endregion
|
|
426
|
+
//#region src/configureStore.ts
|
|
627
427
|
function configureStore(options) {
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
finalMiddleware.forEach((middleware2) => {
|
|
663
|
-
if (middlewareReferences.has(middleware2)) {
|
|
664
|
-
throw new Error(false ? _formatProdErrorMessage5(42) : "Duplicate middleware references found when creating the store. Ensure that each middleware is only included once.");
|
|
665
|
-
}
|
|
666
|
-
middlewareReferences.add(middleware2);
|
|
667
|
-
});
|
|
668
|
-
}
|
|
669
|
-
let finalCompose = import_redux.compose;
|
|
670
|
-
if (devTools) {
|
|
671
|
-
finalCompose = composeWithDevTools({
|
|
672
|
-
// Enable capture of stack traces for dispatched Redux actions
|
|
673
|
-
trace: true,
|
|
674
|
-
...typeof devTools === "object" && devTools
|
|
675
|
-
});
|
|
676
|
-
}
|
|
677
|
-
const middlewareEnhancer = (0, import_redux.applyMiddleware)(...finalMiddleware);
|
|
678
|
-
const getDefaultEnhancers = buildGetDefaultEnhancers(middlewareEnhancer);
|
|
679
|
-
if (enhancers && typeof enhancers !== "function") {
|
|
680
|
-
throw new Error(false ? _formatProdErrorMessage6(5) : "`enhancers` field must be a callback");
|
|
681
|
-
}
|
|
682
|
-
let storeEnhancers = typeof enhancers === "function" ? enhancers(getDefaultEnhancers) : getDefaultEnhancers();
|
|
683
|
-
if (!Array.isArray(storeEnhancers)) {
|
|
684
|
-
throw new Error(false ? _formatProdErrorMessage7(6) : "`enhancers` callback must return an array");
|
|
685
|
-
}
|
|
686
|
-
if (storeEnhancers.some((item) => typeof item !== "function")) {
|
|
687
|
-
throw new Error(false ? _formatProdErrorMessage8(7) : "each enhancer provided to configureStore must be a function");
|
|
688
|
-
}
|
|
689
|
-
if (finalMiddleware.length && !storeEnhancers.includes(middlewareEnhancer)) {
|
|
690
|
-
console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");
|
|
691
|
-
}
|
|
692
|
-
const composedEnhancer = finalCompose(...storeEnhancers);
|
|
693
|
-
return (0, import_redux.createStore)(rootReducer, preloadedState, composedEnhancer);
|
|
428
|
+
const getDefaultMiddleware = buildGetDefaultMiddleware();
|
|
429
|
+
const { reducer = void 0, middleware, devTools = true, duplicateMiddlewareCheck = true, preloadedState = void 0, enhancers = void 0 } = options || {};
|
|
430
|
+
let rootReducer;
|
|
431
|
+
if (typeof reducer === "function") rootReducer = reducer;
|
|
432
|
+
else if ((0, redux.isPlainObject)(reducer)) rootReducer = (0, redux.combineReducers)(reducer);
|
|
433
|
+
else throw new Error("`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");
|
|
434
|
+
if (middleware && typeof middleware !== "function") throw new Error("`middleware` field must be a callback");
|
|
435
|
+
let finalMiddleware;
|
|
436
|
+
if (typeof middleware === "function") {
|
|
437
|
+
finalMiddleware = middleware(getDefaultMiddleware);
|
|
438
|
+
if (!Array.isArray(finalMiddleware)) throw new Error("when using a middleware builder function, an array of middleware must be returned");
|
|
439
|
+
} else finalMiddleware = getDefaultMiddleware();
|
|
440
|
+
if (finalMiddleware.some((item) => typeof item !== "function")) throw new Error("each middleware provided to configureStore must be a function");
|
|
441
|
+
if (duplicateMiddlewareCheck) {
|
|
442
|
+
let middlewareReferences = /* @__PURE__ */ new Set();
|
|
443
|
+
finalMiddleware.forEach((middleware) => {
|
|
444
|
+
if (middlewareReferences.has(middleware)) throw new Error("Duplicate middleware references found when creating the store. Ensure that each middleware is only included once.");
|
|
445
|
+
middlewareReferences.add(middleware);
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
let finalCompose = redux.compose;
|
|
449
|
+
if (devTools) finalCompose = composeWithDevTools({
|
|
450
|
+
trace: true,
|
|
451
|
+
...typeof devTools === "object" && devTools
|
|
452
|
+
});
|
|
453
|
+
const middlewareEnhancer = (0, redux.applyMiddleware)(...finalMiddleware);
|
|
454
|
+
const getDefaultEnhancers = buildGetDefaultEnhancers(middlewareEnhancer);
|
|
455
|
+
if (enhancers && typeof enhancers !== "function") throw new Error("`enhancers` field must be a callback");
|
|
456
|
+
let storeEnhancers = typeof enhancers === "function" ? enhancers(getDefaultEnhancers) : getDefaultEnhancers();
|
|
457
|
+
if (!Array.isArray(storeEnhancers)) throw new Error("`enhancers` callback must return an array");
|
|
458
|
+
if (storeEnhancers.some((item) => typeof item !== "function")) throw new Error("each enhancer provided to configureStore must be a function");
|
|
459
|
+
if (finalMiddleware.length && !storeEnhancers.includes(middlewareEnhancer)) console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");
|
|
460
|
+
const composedEnhancer = finalCompose(...storeEnhancers);
|
|
461
|
+
return (0, redux.createStore)(rootReducer, preloadedState, composedEnhancer);
|
|
694
462
|
}
|
|
695
|
-
|
|
696
|
-
|
|
463
|
+
//#endregion
|
|
464
|
+
//#region src/mapBuilders.ts
|
|
697
465
|
function executeReducerBuilderCallback(builderCallback) {
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
actionMatchers.push({
|
|
743
|
-
matcher,
|
|
744
|
-
reducer
|
|
745
|
-
});
|
|
746
|
-
return builder;
|
|
747
|
-
},
|
|
748
|
-
addDefaultCase(reducer) {
|
|
749
|
-
if (true) {
|
|
750
|
-
if (defaultCaseReducer) {
|
|
751
|
-
throw new Error(false ? _formatProdErrorMessage7(31) : "`builder.addDefaultCase` can only be called once");
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
defaultCaseReducer = reducer;
|
|
755
|
-
return builder;
|
|
756
|
-
}
|
|
757
|
-
};
|
|
758
|
-
builderCallback(builder);
|
|
759
|
-
return [actionsMap, actionMatchers, defaultCaseReducer];
|
|
466
|
+
const actionsMap = {};
|
|
467
|
+
const actionMatchers = [];
|
|
468
|
+
let defaultCaseReducer;
|
|
469
|
+
const builder = {
|
|
470
|
+
addCase(typeOrActionCreator, reducer) {
|
|
471
|
+
if (actionMatchers.length > 0) throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");
|
|
472
|
+
if (defaultCaseReducer) throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");
|
|
473
|
+
const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
|
|
474
|
+
if (!type) throw new Error("`builder.addCase` cannot be called with an empty action type");
|
|
475
|
+
if (type in actionsMap) throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${type}'`);
|
|
476
|
+
actionsMap[type] = reducer;
|
|
477
|
+
return builder;
|
|
478
|
+
},
|
|
479
|
+
addAsyncThunk(asyncThunk, reducers) {
|
|
480
|
+
if (defaultCaseReducer) throw new Error("`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`");
|
|
481
|
+
if (reducers.pending) actionsMap[asyncThunk.pending.type] = reducers.pending;
|
|
482
|
+
if (reducers.rejected) actionsMap[asyncThunk.rejected.type] = reducers.rejected;
|
|
483
|
+
if (reducers.fulfilled) actionsMap[asyncThunk.fulfilled.type] = reducers.fulfilled;
|
|
484
|
+
if (reducers.settled) actionMatchers.push({
|
|
485
|
+
matcher: asyncThunk.settled,
|
|
486
|
+
reducer: reducers.settled
|
|
487
|
+
});
|
|
488
|
+
return builder;
|
|
489
|
+
},
|
|
490
|
+
addMatcher(matcher, reducer) {
|
|
491
|
+
if (defaultCaseReducer) throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
|
|
492
|
+
actionMatchers.push({
|
|
493
|
+
matcher,
|
|
494
|
+
reducer
|
|
495
|
+
});
|
|
496
|
+
return builder;
|
|
497
|
+
},
|
|
498
|
+
addDefaultCase(reducer) {
|
|
499
|
+
if (defaultCaseReducer) throw new Error("`builder.addDefaultCase` can only be called once");
|
|
500
|
+
defaultCaseReducer = reducer;
|
|
501
|
+
return builder;
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
builderCallback(builder);
|
|
505
|
+
return [
|
|
506
|
+
actionsMap,
|
|
507
|
+
actionMatchers,
|
|
508
|
+
defaultCaseReducer
|
|
509
|
+
];
|
|
760
510
|
}
|
|
761
|
-
|
|
762
|
-
|
|
511
|
+
//#endregion
|
|
512
|
+
//#region src/createReducer.ts
|
|
763
513
|
function isStateFunction(x) {
|
|
764
|
-
|
|
514
|
+
return typeof x === "function";
|
|
765
515
|
}
|
|
766
516
|
function createReducer(initialState, mapOrBuilderCallback) {
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
if (result === void 0) {
|
|
801
|
-
if (previousState === null) {
|
|
802
|
-
return previousState;
|
|
803
|
-
}
|
|
804
|
-
throw Error("A case reducer on a non-draftable value must not return undefined");
|
|
805
|
-
}
|
|
806
|
-
return result;
|
|
807
|
-
} else {
|
|
808
|
-
return (0, import_immer.produce)(previousState, (draft) => {
|
|
809
|
-
return caseReducer(draft, action);
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
return previousState;
|
|
814
|
-
}, state);
|
|
815
|
-
}
|
|
816
|
-
reducer.getInitialState = getInitialState;
|
|
817
|
-
return reducer;
|
|
517
|
+
if (typeof mapOrBuilderCallback === "object") throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");
|
|
518
|
+
let [actionsMap, finalActionMatchers, finalDefaultCaseReducer] = executeReducerBuilderCallback(mapOrBuilderCallback);
|
|
519
|
+
let getInitialState;
|
|
520
|
+
if (isStateFunction(initialState)) getInitialState = () => freezeDraftable(initialState());
|
|
521
|
+
else {
|
|
522
|
+
const frozenInitialState = freezeDraftable(initialState);
|
|
523
|
+
getInitialState = () => frozenInitialState;
|
|
524
|
+
}
|
|
525
|
+
function reducer(state = getInitialState(), action) {
|
|
526
|
+
let caseReducers = [actionsMap[action.type], ...finalActionMatchers.filter(({ matcher }) => matcher(action)).map(({ reducer }) => reducer)];
|
|
527
|
+
if (caseReducers.filter((cr) => !!cr).length === 0) caseReducers = [finalDefaultCaseReducer];
|
|
528
|
+
return caseReducers.reduce((previousState, caseReducer) => {
|
|
529
|
+
if (caseReducer) {
|
|
530
|
+
if ((0, immer.isDraft)(previousState)) {
|
|
531
|
+
const result = caseReducer(previousState, action);
|
|
532
|
+
if (result === void 0) return previousState;
|
|
533
|
+
return result;
|
|
534
|
+
} else if (!(0, immer.isDraftable)(previousState)) {
|
|
535
|
+
const result = caseReducer(previousState, action);
|
|
536
|
+
if (result === void 0) {
|
|
537
|
+
if (previousState === null) return previousState;
|
|
538
|
+
throw new Error("A case reducer on a non-draftable value must not return undefined");
|
|
539
|
+
}
|
|
540
|
+
return result;
|
|
541
|
+
} else return (0, immer.produce)(previousState, (draft) => {
|
|
542
|
+
return caseReducer(draft, action);
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
return previousState;
|
|
546
|
+
}, state);
|
|
547
|
+
}
|
|
548
|
+
reducer.getInitialState = getInitialState;
|
|
549
|
+
return reducer;
|
|
818
550
|
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
} else {
|
|
825
|
-
return matcher(action);
|
|
826
|
-
}
|
|
551
|
+
//#endregion
|
|
552
|
+
//#region src/matchers.ts
|
|
553
|
+
const matches = (matcher, action) => {
|
|
554
|
+
if (hasMatchFunction(matcher)) return matcher.match(action);
|
|
555
|
+
else return matcher(action);
|
|
827
556
|
};
|
|
828
557
|
function isAnyOf(...matchers) {
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
558
|
+
return (action) => {
|
|
559
|
+
return matchers.some((matcher) => matches(matcher, action));
|
|
560
|
+
};
|
|
832
561
|
}
|
|
833
562
|
function isAllOf(...matchers) {
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
563
|
+
return (action) => {
|
|
564
|
+
return matchers.every((matcher) => matches(matcher, action));
|
|
565
|
+
};
|
|
837
566
|
}
|
|
838
567
|
function hasExpectedRequestMetadata(action, validStatus) {
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
568
|
+
if (!action || !action.meta) return false;
|
|
569
|
+
const hasValidRequestId = typeof action.meta.requestId === "string";
|
|
570
|
+
const hasValidRequestStatus = validStatus.indexOf(action.meta.requestStatus) > -1;
|
|
571
|
+
return hasValidRequestId && hasValidRequestStatus;
|
|
843
572
|
}
|
|
844
573
|
function isAsyncThunkArray(a) {
|
|
845
|
-
|
|
574
|
+
return typeof a[0] === "function" && "pending" in a[0] && "fulfilled" in a[0] && "rejected" in a[0];
|
|
846
575
|
}
|
|
847
576
|
function isPending(...asyncThunks) {
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
if (!isAsyncThunkArray(asyncThunks)) {
|
|
852
|
-
return isPending()(asyncThunks[0]);
|
|
853
|
-
}
|
|
854
|
-
return isAnyOf(...asyncThunks.map((asyncThunk) => asyncThunk.pending));
|
|
577
|
+
if (asyncThunks.length === 0) return (action) => hasExpectedRequestMetadata(action, ["pending"]);
|
|
578
|
+
if (!isAsyncThunkArray(asyncThunks)) return isPending()(asyncThunks[0]);
|
|
579
|
+
return isAnyOf(...asyncThunks.map((asyncThunk) => asyncThunk.pending));
|
|
855
580
|
}
|
|
856
581
|
function isRejected(...asyncThunks) {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
if (!isAsyncThunkArray(asyncThunks)) {
|
|
861
|
-
return isRejected()(asyncThunks[0]);
|
|
862
|
-
}
|
|
863
|
-
return isAnyOf(...asyncThunks.map((asyncThunk) => asyncThunk.rejected));
|
|
582
|
+
if (asyncThunks.length === 0) return (action) => hasExpectedRequestMetadata(action, ["rejected"]);
|
|
583
|
+
if (!isAsyncThunkArray(asyncThunks)) return isRejected()(asyncThunks[0]);
|
|
584
|
+
return isAnyOf(...asyncThunks.map((asyncThunk) => asyncThunk.rejected));
|
|
864
585
|
}
|
|
865
586
|
function isRejectedWithValue(...asyncThunks) {
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
if (!isAsyncThunkArray(asyncThunks)) {
|
|
873
|
-
return isRejectedWithValue()(asyncThunks[0]);
|
|
874
|
-
}
|
|
875
|
-
return isAllOf(isRejected(...asyncThunks), hasFlag);
|
|
587
|
+
const hasFlag = (action) => {
|
|
588
|
+
return action && action.meta && action.meta.rejectedWithValue;
|
|
589
|
+
};
|
|
590
|
+
if (asyncThunks.length === 0) return isAllOf(isRejected(...asyncThunks), hasFlag);
|
|
591
|
+
if (!isAsyncThunkArray(asyncThunks)) return isRejectedWithValue()(asyncThunks[0]);
|
|
592
|
+
return isAllOf(isRejected(...asyncThunks), hasFlag);
|
|
876
593
|
}
|
|
877
594
|
function isFulfilled(...asyncThunks) {
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
if (!isAsyncThunkArray(asyncThunks)) {
|
|
882
|
-
return isFulfilled()(asyncThunks[0]);
|
|
883
|
-
}
|
|
884
|
-
return isAnyOf(...asyncThunks.map((asyncThunk) => asyncThunk.fulfilled));
|
|
595
|
+
if (asyncThunks.length === 0) return (action) => hasExpectedRequestMetadata(action, ["fulfilled"]);
|
|
596
|
+
if (!isAsyncThunkArray(asyncThunks)) return isFulfilled()(asyncThunks[0]);
|
|
597
|
+
return isAnyOf(...asyncThunks.map((asyncThunk) => asyncThunk.fulfilled));
|
|
885
598
|
}
|
|
886
599
|
function isAsyncThunkAction(...asyncThunks) {
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
600
|
+
if (asyncThunks.length === 0) return (action) => hasExpectedRequestMetadata(action, [
|
|
601
|
+
"pending",
|
|
602
|
+
"fulfilled",
|
|
603
|
+
"rejected"
|
|
604
|
+
]);
|
|
605
|
+
if (!isAsyncThunkArray(asyncThunks)) return isAsyncThunkAction()(asyncThunks[0]);
|
|
606
|
+
return isAnyOf(...asyncThunks.flatMap((asyncThunk) => [
|
|
607
|
+
asyncThunk.pending,
|
|
608
|
+
asyncThunk.rejected,
|
|
609
|
+
asyncThunk.fulfilled
|
|
610
|
+
]));
|
|
894
611
|
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
}
|
|
904
|
-
return id;
|
|
612
|
+
//#endregion
|
|
613
|
+
//#region src/nanoid.ts
|
|
614
|
+
let urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
|
|
615
|
+
let nanoid = (size = 21) => {
|
|
616
|
+
let id = "";
|
|
617
|
+
let i = size;
|
|
618
|
+
while (i--) id += urlAlphabet[Math.random() * 64 | 0];
|
|
619
|
+
return id;
|
|
905
620
|
};
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
621
|
+
//#endregion
|
|
622
|
+
//#region src/createAsyncThunk.ts
|
|
623
|
+
const commonProperties = [
|
|
624
|
+
"name",
|
|
625
|
+
"message",
|
|
626
|
+
"stack",
|
|
627
|
+
"code"
|
|
628
|
+
];
|
|
909
629
|
var RejectWithValue = class {
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
type-only property to distinguish between RejectWithValue and FulfillWithMeta
|
|
918
|
-
does not exist at runtime
|
|
919
|
-
*/
|
|
920
|
-
_type;
|
|
630
|
+
payload;
|
|
631
|
+
meta;
|
|
632
|
+
_type;
|
|
633
|
+
constructor(payload, meta) {
|
|
634
|
+
this.payload = payload;
|
|
635
|
+
this.meta = meta;
|
|
636
|
+
}
|
|
921
637
|
};
|
|
922
638
|
var FulfillWithMeta = class {
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
type-only property to distinguish between RejectWithValue and FulfillWithMeta
|
|
931
|
-
does not exist at runtime
|
|
932
|
-
*/
|
|
933
|
-
_type;
|
|
639
|
+
payload;
|
|
640
|
+
meta;
|
|
641
|
+
_type;
|
|
642
|
+
constructor(payload, meta) {
|
|
643
|
+
this.payload = payload;
|
|
644
|
+
this.meta = meta;
|
|
645
|
+
}
|
|
934
646
|
};
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
}
|
|
943
|
-
return simpleError;
|
|
944
|
-
}
|
|
945
|
-
return {
|
|
946
|
-
message: String(value)
|
|
947
|
-
};
|
|
647
|
+
const miniSerializeError = (value) => {
|
|
648
|
+
if (typeof value === "object" && value !== null) {
|
|
649
|
+
const simpleError = {};
|
|
650
|
+
for (const property of commonProperties) if (typeof value[property] === "string") simpleError[property] = value[property];
|
|
651
|
+
return simpleError;
|
|
652
|
+
}
|
|
653
|
+
return { message: String(value) };
|
|
948
654
|
};
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
requestId,
|
|
1076
|
-
arg,
|
|
1077
|
-
unwrap() {
|
|
1078
|
-
return promise.then(unwrapResult);
|
|
1079
|
-
}
|
|
1080
|
-
});
|
|
1081
|
-
};
|
|
1082
|
-
}
|
|
1083
|
-
return Object.assign(actionCreator, {
|
|
1084
|
-
pending,
|
|
1085
|
-
rejected,
|
|
1086
|
-
fulfilled,
|
|
1087
|
-
settled: isAnyOf(rejected, fulfilled),
|
|
1088
|
-
typePrefix
|
|
1089
|
-
});
|
|
1090
|
-
}
|
|
1091
|
-
createAsyncThunk2.withTypes = () => createAsyncThunk2;
|
|
1092
|
-
return createAsyncThunk2;
|
|
655
|
+
const externalAbortMessage = "External signal was aborted";
|
|
656
|
+
const createAsyncThunk = /* @__PURE__ */ (() => {
|
|
657
|
+
function createAsyncThunk(typePrefix, payloadCreator, options) {
|
|
658
|
+
const fulfilled = createAction(typePrefix + "/fulfilled", (payload, requestId, arg, meta) => ({
|
|
659
|
+
payload,
|
|
660
|
+
meta: {
|
|
661
|
+
...meta || {},
|
|
662
|
+
arg,
|
|
663
|
+
requestId,
|
|
664
|
+
requestStatus: "fulfilled"
|
|
665
|
+
}
|
|
666
|
+
}));
|
|
667
|
+
const pending = createAction(typePrefix + "/pending", (requestId, arg, meta) => ({
|
|
668
|
+
payload: void 0,
|
|
669
|
+
meta: {
|
|
670
|
+
...meta || {},
|
|
671
|
+
arg,
|
|
672
|
+
requestId,
|
|
673
|
+
requestStatus: "pending"
|
|
674
|
+
}
|
|
675
|
+
}));
|
|
676
|
+
const rejected = createAction(typePrefix + "/rejected", (error, requestId, arg, payload, meta) => ({
|
|
677
|
+
payload,
|
|
678
|
+
error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
|
|
679
|
+
meta: {
|
|
680
|
+
...meta || {},
|
|
681
|
+
arg,
|
|
682
|
+
requestId,
|
|
683
|
+
rejectedWithValue: payload !== void 0,
|
|
684
|
+
requestStatus: "rejected",
|
|
685
|
+
aborted: error?.name === "AbortError",
|
|
686
|
+
condition: error?.name === "ConditionError"
|
|
687
|
+
}
|
|
688
|
+
}));
|
|
689
|
+
function actionCreator(arg, { signal } = {}) {
|
|
690
|
+
return (dispatch, getState, extra) => {
|
|
691
|
+
const requestId = options?.idGenerator ? options.idGenerator(arg) : nanoid();
|
|
692
|
+
const abortController = new AbortController();
|
|
693
|
+
let abortHandler;
|
|
694
|
+
let abortReason;
|
|
695
|
+
function abort(reason) {
|
|
696
|
+
abortReason = reason;
|
|
697
|
+
abortController.abort();
|
|
698
|
+
}
|
|
699
|
+
if (signal) {
|
|
700
|
+
if (signal.aborted) abort(externalAbortMessage);
|
|
701
|
+
else signal.addEventListener("abort", () => abort(externalAbortMessage), { once: true });
|
|
702
|
+
}
|
|
703
|
+
const promise = async function() {
|
|
704
|
+
let finalAction;
|
|
705
|
+
try {
|
|
706
|
+
let conditionResult = options?.condition?.(arg, {
|
|
707
|
+
getState,
|
|
708
|
+
extra
|
|
709
|
+
});
|
|
710
|
+
if (isThenable(conditionResult)) conditionResult = await conditionResult;
|
|
711
|
+
if (conditionResult === false) throw {
|
|
712
|
+
name: "ConditionError",
|
|
713
|
+
message: "Aborted due to condition callback returning false."
|
|
714
|
+
};
|
|
715
|
+
if (abortController.signal.aborted) throw {
|
|
716
|
+
name: "AbortError",
|
|
717
|
+
message: abortReason || "Aborted"
|
|
718
|
+
};
|
|
719
|
+
const abortedPromise = new Promise((_, reject) => {
|
|
720
|
+
abortHandler = () => {
|
|
721
|
+
reject({
|
|
722
|
+
name: "AbortError",
|
|
723
|
+
message: abortReason || "Aborted"
|
|
724
|
+
});
|
|
725
|
+
};
|
|
726
|
+
abortController.signal.addEventListener("abort", abortHandler, { once: true });
|
|
727
|
+
});
|
|
728
|
+
dispatch(pending(requestId, arg, options?.getPendingMeta?.({
|
|
729
|
+
requestId,
|
|
730
|
+
arg
|
|
731
|
+
}, {
|
|
732
|
+
getState,
|
|
733
|
+
extra
|
|
734
|
+
})));
|
|
735
|
+
finalAction = await Promise.race([abortedPromise, Promise.resolve(payloadCreator(arg, {
|
|
736
|
+
dispatch,
|
|
737
|
+
getState,
|
|
738
|
+
extra,
|
|
739
|
+
requestId,
|
|
740
|
+
signal: abortController.signal,
|
|
741
|
+
abort,
|
|
742
|
+
rejectWithValue: ((value, meta) => {
|
|
743
|
+
return new RejectWithValue(value, meta);
|
|
744
|
+
}),
|
|
745
|
+
fulfillWithValue: ((value, meta) => {
|
|
746
|
+
return new FulfillWithMeta(value, meta);
|
|
747
|
+
})
|
|
748
|
+
})).then((result) => {
|
|
749
|
+
if (result instanceof RejectWithValue) throw result;
|
|
750
|
+
if (result instanceof FulfillWithMeta) return fulfilled(result.payload, requestId, arg, result.meta);
|
|
751
|
+
return fulfilled(result, requestId, arg);
|
|
752
|
+
})]);
|
|
753
|
+
} catch (err) {
|
|
754
|
+
finalAction = err instanceof RejectWithValue ? rejected(null, requestId, arg, err.payload, err.meta) : rejected(err, requestId, arg);
|
|
755
|
+
} finally {
|
|
756
|
+
if (abortHandler) abortController.signal.removeEventListener("abort", abortHandler);
|
|
757
|
+
}
|
|
758
|
+
if (!(options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition)) dispatch(finalAction);
|
|
759
|
+
return finalAction;
|
|
760
|
+
}();
|
|
761
|
+
return Object.assign(promise, {
|
|
762
|
+
abort,
|
|
763
|
+
requestId,
|
|
764
|
+
arg,
|
|
765
|
+
unwrap() {
|
|
766
|
+
return promise.then(unwrapResult);
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
return Object.assign(actionCreator, {
|
|
772
|
+
pending,
|
|
773
|
+
rejected,
|
|
774
|
+
fulfilled,
|
|
775
|
+
settled: isAnyOf(rejected, fulfilled),
|
|
776
|
+
typePrefix
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
createAsyncThunk.withTypes = () => createAsyncThunk;
|
|
780
|
+
return createAsyncThunk;
|
|
1093
781
|
})();
|
|
1094
782
|
function unwrapResult(action) {
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
if (action.error) {
|
|
1099
|
-
throw action.error;
|
|
1100
|
-
}
|
|
1101
|
-
return action.payload;
|
|
783
|
+
if (action.meta && action.meta.rejectedWithValue) throw action.payload;
|
|
784
|
+
if (action.error) throw action.error;
|
|
785
|
+
return action.payload;
|
|
1102
786
|
}
|
|
1103
787
|
function isThenable(value) {
|
|
1104
|
-
|
|
788
|
+
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
1105
789
|
}
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
return ReducerType2;
|
|
1117
|
-
})(ReducerType || {});
|
|
790
|
+
//#endregion
|
|
791
|
+
//#region src/createSlice.ts
|
|
792
|
+
const asyncThunkSymbol = /* @__PURE__ */ Symbol.for("rtk-slice-createasyncthunk");
|
|
793
|
+
const asyncThunkCreator = { [asyncThunkSymbol]: createAsyncThunk };
|
|
794
|
+
let ReducerType = /* @__PURE__ */ function(ReducerType) {
|
|
795
|
+
ReducerType["reducer"] = "reducer";
|
|
796
|
+
ReducerType["reducerWithPrepare"] = "reducerWithPrepare";
|
|
797
|
+
ReducerType["asyncThunk"] = "asyncThunk";
|
|
798
|
+
return ReducerType;
|
|
799
|
+
}({});
|
|
1118
800
|
function getType(slice, actionKey) {
|
|
1119
|
-
|
|
801
|
+
return `${slice}/${actionKey}`;
|
|
1120
802
|
}
|
|
1121
|
-
function buildCreateSlice({
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
}
|
|
1244
|
-
return map;
|
|
1245
|
-
});
|
|
1246
|
-
}
|
|
1247
|
-
return {
|
|
1248
|
-
reducerPath: reducerPath2,
|
|
1249
|
-
getSelectors,
|
|
1250
|
-
get selectors() {
|
|
1251
|
-
return getSelectors(selectSlice);
|
|
1252
|
-
},
|
|
1253
|
-
selectSlice
|
|
1254
|
-
};
|
|
1255
|
-
}
|
|
1256
|
-
const slice = {
|
|
1257
|
-
name,
|
|
1258
|
-
reducer,
|
|
1259
|
-
actions: context.actionCreators,
|
|
1260
|
-
caseReducers: context.sliceCaseReducersByName,
|
|
1261
|
-
getInitialState,
|
|
1262
|
-
...makeSelectorProps(reducerPath),
|
|
1263
|
-
injectInto(injectable, {
|
|
1264
|
-
reducerPath: pathOpt,
|
|
1265
|
-
...config
|
|
1266
|
-
} = {}) {
|
|
1267
|
-
const newReducerPath = pathOpt ?? reducerPath;
|
|
1268
|
-
injectable.inject({
|
|
1269
|
-
reducerPath: newReducerPath,
|
|
1270
|
-
reducer
|
|
1271
|
-
}, config);
|
|
1272
|
-
return {
|
|
1273
|
-
...slice,
|
|
1274
|
-
...makeSelectorProps(newReducerPath, true)
|
|
1275
|
-
};
|
|
1276
|
-
}
|
|
1277
|
-
};
|
|
1278
|
-
return slice;
|
|
1279
|
-
};
|
|
803
|
+
function buildCreateSlice({ creators } = {}) {
|
|
804
|
+
const cAT = creators?.asyncThunk?.[asyncThunkSymbol];
|
|
805
|
+
return function createSlice(options) {
|
|
806
|
+
const { name, reducerPath = name } = options;
|
|
807
|
+
if (!name) throw new Error("`name` is a required option for createSlice");
|
|
808
|
+
if (typeof process !== "undefined" && true) {
|
|
809
|
+
if (options.initialState === void 0) console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
|
|
810
|
+
}
|
|
811
|
+
const reducers = (typeof options.reducers === "function" ? options.reducers(buildReducerCreators()) : options.reducers) || {};
|
|
812
|
+
const reducerNames = Object.keys(reducers);
|
|
813
|
+
const context = {
|
|
814
|
+
sliceCaseReducersByName: {},
|
|
815
|
+
sliceCaseReducersByType: {},
|
|
816
|
+
actionCreators: {},
|
|
817
|
+
sliceMatchers: []
|
|
818
|
+
};
|
|
819
|
+
const contextMethods = {
|
|
820
|
+
addCase(typeOrActionCreator, reducer) {
|
|
821
|
+
const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
|
|
822
|
+
if (!type) throw new Error("`context.addCase` cannot be called with an empty action type");
|
|
823
|
+
if (type in context.sliceCaseReducersByType) throw new Error("`context.addCase` cannot be called with two reducers for the same action type: " + type);
|
|
824
|
+
context.sliceCaseReducersByType[type] = reducer;
|
|
825
|
+
return contextMethods;
|
|
826
|
+
},
|
|
827
|
+
addMatcher(matcher, reducer) {
|
|
828
|
+
context.sliceMatchers.push({
|
|
829
|
+
matcher,
|
|
830
|
+
reducer
|
|
831
|
+
});
|
|
832
|
+
return contextMethods;
|
|
833
|
+
},
|
|
834
|
+
exposeAction(name, actionCreator) {
|
|
835
|
+
context.actionCreators[name] = actionCreator;
|
|
836
|
+
return contextMethods;
|
|
837
|
+
},
|
|
838
|
+
exposeCaseReducer(name, reducer) {
|
|
839
|
+
context.sliceCaseReducersByName[name] = reducer;
|
|
840
|
+
return contextMethods;
|
|
841
|
+
}
|
|
842
|
+
};
|
|
843
|
+
reducerNames.forEach((reducerName) => {
|
|
844
|
+
const reducerDefinition = reducers[reducerName];
|
|
845
|
+
const reducerDetails = {
|
|
846
|
+
reducerName,
|
|
847
|
+
type: getType(name, reducerName),
|
|
848
|
+
createNotation: typeof options.reducers === "function"
|
|
849
|
+
};
|
|
850
|
+
if (isAsyncThunkSliceReducerDefinition(reducerDefinition)) handleThunkCaseReducerDefinition(reducerDetails, reducerDefinition, contextMethods, cAT);
|
|
851
|
+
else handleNormalReducerDefinition(reducerDetails, reducerDefinition, contextMethods);
|
|
852
|
+
});
|
|
853
|
+
function buildReducer() {
|
|
854
|
+
if (typeof options.extraReducers === "object") throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");
|
|
855
|
+
const [extraReducers = {}, actionMatchers = [], defaultCaseReducer = void 0] = typeof options.extraReducers === "function" ? executeReducerBuilderCallback(options.extraReducers) : [options.extraReducers];
|
|
856
|
+
const finalCaseReducers = {
|
|
857
|
+
...extraReducers,
|
|
858
|
+
...context.sliceCaseReducersByType
|
|
859
|
+
};
|
|
860
|
+
return createReducer(options.initialState, (builder) => {
|
|
861
|
+
for (let key in finalCaseReducers) builder.addCase(key, finalCaseReducers[key]);
|
|
862
|
+
for (let sM of context.sliceMatchers) builder.addMatcher(sM.matcher, sM.reducer);
|
|
863
|
+
for (let m of actionMatchers) builder.addMatcher(m.matcher, m.reducer);
|
|
864
|
+
if (defaultCaseReducer) builder.addDefaultCase(defaultCaseReducer);
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
const selectSelf = (state) => state;
|
|
868
|
+
const injectedSelectorCache = /* @__PURE__ */ new Map();
|
|
869
|
+
const injectedStateCache = /* @__PURE__ */ new WeakMap();
|
|
870
|
+
let _reducer;
|
|
871
|
+
function reducer(state, action) {
|
|
872
|
+
if (!_reducer) _reducer = buildReducer();
|
|
873
|
+
return _reducer(state, action);
|
|
874
|
+
}
|
|
875
|
+
function getInitialState() {
|
|
876
|
+
if (!_reducer) _reducer = buildReducer();
|
|
877
|
+
return _reducer.getInitialState();
|
|
878
|
+
}
|
|
879
|
+
function makeSelectorProps(reducerPath, injected = false) {
|
|
880
|
+
function selectSlice(state) {
|
|
881
|
+
let sliceState = state[reducerPath];
|
|
882
|
+
if (typeof sliceState === "undefined") {
|
|
883
|
+
if (injected) sliceState = getOrInsertComputed(injectedStateCache, selectSlice, getInitialState);
|
|
884
|
+
else throw new Error("selectSlice returned undefined for an uninjected slice reducer");
|
|
885
|
+
}
|
|
886
|
+
return sliceState;
|
|
887
|
+
}
|
|
888
|
+
function getSelectors(selectState = selectSelf) {
|
|
889
|
+
return getOrInsertComputed(getOrInsertComputed(injectedSelectorCache, injected, () => /* @__PURE__ */ new WeakMap()), selectState, () => {
|
|
890
|
+
const map = {};
|
|
891
|
+
for (const [name, selector] of Object.entries(options.selectors ?? {})) map[name] = wrapSelector(selector, selectState, () => getOrInsertComputed(injectedStateCache, selectState, getInitialState), injected);
|
|
892
|
+
return map;
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
return {
|
|
896
|
+
reducerPath,
|
|
897
|
+
getSelectors,
|
|
898
|
+
get selectors() {
|
|
899
|
+
return getSelectors(selectSlice);
|
|
900
|
+
},
|
|
901
|
+
selectSlice
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
const slice = {
|
|
905
|
+
name,
|
|
906
|
+
reducer,
|
|
907
|
+
actions: context.actionCreators,
|
|
908
|
+
caseReducers: context.sliceCaseReducersByName,
|
|
909
|
+
getInitialState,
|
|
910
|
+
...makeSelectorProps(reducerPath),
|
|
911
|
+
injectInto(injectable, { reducerPath: pathOpt, ...config } = {}) {
|
|
912
|
+
const newReducerPath = pathOpt ?? reducerPath;
|
|
913
|
+
injectable.inject({
|
|
914
|
+
reducerPath: newReducerPath,
|
|
915
|
+
reducer
|
|
916
|
+
}, config);
|
|
917
|
+
return {
|
|
918
|
+
...slice,
|
|
919
|
+
...makeSelectorProps(newReducerPath, true)
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
return slice;
|
|
924
|
+
};
|
|
1280
925
|
}
|
|
1281
926
|
function wrapSelector(selector, selectState, getInitialState, injected) {
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
}
|
|
1293
|
-
wrapper.unwrapped = selector;
|
|
1294
|
-
return wrapper;
|
|
927
|
+
function wrapper(rootState, ...args) {
|
|
928
|
+
let sliceState = selectState(rootState);
|
|
929
|
+
if (typeof sliceState === "undefined") {
|
|
930
|
+
if (injected) sliceState = getInitialState();
|
|
931
|
+
else throw new Error("selectState returned undefined for an uninjected slice reducer");
|
|
932
|
+
}
|
|
933
|
+
return selector(sliceState, ...args);
|
|
934
|
+
}
|
|
935
|
+
wrapper.unwrapped = selector;
|
|
936
|
+
return wrapper;
|
|
1295
937
|
}
|
|
1296
|
-
|
|
938
|
+
const createSlice = /* @__PURE__ */ buildCreateSlice();
|
|
1297
939
|
function buildReducerCreators() {
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
prepare,
|
|
1322
|
-
reducer
|
|
1323
|
-
};
|
|
1324
|
-
},
|
|
1325
|
-
asyncThunk
|
|
1326
|
-
};
|
|
940
|
+
function asyncThunk(payloadCreator, config) {
|
|
941
|
+
return {
|
|
942
|
+
_reducerDefinitionType: "asyncThunk",
|
|
943
|
+
payloadCreator,
|
|
944
|
+
...config
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
asyncThunk.withTypes = () => asyncThunk;
|
|
948
|
+
return {
|
|
949
|
+
reducer(caseReducer) {
|
|
950
|
+
return Object.assign({ [caseReducer.name](...args) {
|
|
951
|
+
return caseReducer(...args);
|
|
952
|
+
} }[caseReducer.name], { _reducerDefinitionType: "reducer" });
|
|
953
|
+
},
|
|
954
|
+
preparedReducer(prepare, reducer) {
|
|
955
|
+
return {
|
|
956
|
+
_reducerDefinitionType: "reducerWithPrepare",
|
|
957
|
+
prepare,
|
|
958
|
+
reducer
|
|
959
|
+
};
|
|
960
|
+
},
|
|
961
|
+
asyncThunk
|
|
962
|
+
};
|
|
1327
963
|
}
|
|
1328
|
-
function handleNormalReducerDefinition({
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
throw new Error(false ? _formatProdErrorMessage7(17) : "Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");
|
|
1338
|
-
}
|
|
1339
|
-
caseReducer = maybeReducerWithPrepare.reducer;
|
|
1340
|
-
prepareCallback = maybeReducerWithPrepare.prepare;
|
|
1341
|
-
} else {
|
|
1342
|
-
caseReducer = maybeReducerWithPrepare;
|
|
1343
|
-
}
|
|
1344
|
-
context.addCase(type, caseReducer).exposeCaseReducer(reducerName, caseReducer).exposeAction(reducerName, prepareCallback ? createAction(type, prepareCallback) : createAction(type));
|
|
964
|
+
function handleNormalReducerDefinition({ type, reducerName, createNotation }, maybeReducerWithPrepare, context) {
|
|
965
|
+
let caseReducer;
|
|
966
|
+
let prepareCallback;
|
|
967
|
+
if ("reducer" in maybeReducerWithPrepare) {
|
|
968
|
+
if (createNotation && !isCaseReducerWithPrepareDefinition(maybeReducerWithPrepare)) throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");
|
|
969
|
+
caseReducer = maybeReducerWithPrepare.reducer;
|
|
970
|
+
prepareCallback = maybeReducerWithPrepare.prepare;
|
|
971
|
+
} else caseReducer = maybeReducerWithPrepare;
|
|
972
|
+
context.addCase(type, caseReducer).exposeCaseReducer(reducerName, caseReducer).exposeAction(reducerName, prepareCallback ? createAction(type, prepareCallback) : createAction(type));
|
|
1345
973
|
}
|
|
1346
974
|
function isAsyncThunkSliceReducerDefinition(reducerDefinition) {
|
|
1347
|
-
|
|
975
|
+
return reducerDefinition._reducerDefinitionType === "asyncThunk";
|
|
1348
976
|
}
|
|
1349
977
|
function isCaseReducerWithPrepareDefinition(reducerDefinition) {
|
|
1350
|
-
|
|
978
|
+
return reducerDefinition._reducerDefinitionType === "reducerWithPrepare";
|
|
1351
979
|
}
|
|
1352
|
-
function handleThunkCaseReducerDefinition({
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
const thunk = cAT(type, payloadCreator, options);
|
|
1368
|
-
context.exposeAction(reducerName, thunk);
|
|
1369
|
-
if (fulfilled) {
|
|
1370
|
-
context.addCase(thunk.fulfilled, fulfilled);
|
|
1371
|
-
}
|
|
1372
|
-
if (pending) {
|
|
1373
|
-
context.addCase(thunk.pending, pending);
|
|
1374
|
-
}
|
|
1375
|
-
if (rejected) {
|
|
1376
|
-
context.addCase(thunk.rejected, rejected);
|
|
1377
|
-
}
|
|
1378
|
-
if (settled) {
|
|
1379
|
-
context.addMatcher(thunk.settled, settled);
|
|
1380
|
-
}
|
|
1381
|
-
context.exposeCaseReducer(reducerName, {
|
|
1382
|
-
fulfilled: fulfilled || noop,
|
|
1383
|
-
pending: pending || noop,
|
|
1384
|
-
rejected: rejected || noop,
|
|
1385
|
-
settled: settled || noop
|
|
1386
|
-
});
|
|
980
|
+
function handleThunkCaseReducerDefinition({ type, reducerName }, reducerDefinition, context, cAT) {
|
|
981
|
+
if (!cAT) throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");
|
|
982
|
+
const { payloadCreator, fulfilled, pending, rejected, settled, options } = reducerDefinition;
|
|
983
|
+
const thunk = cAT(type, payloadCreator, options);
|
|
984
|
+
context.exposeAction(reducerName, thunk);
|
|
985
|
+
if (fulfilled) context.addCase(thunk.fulfilled, fulfilled);
|
|
986
|
+
if (pending) context.addCase(thunk.pending, pending);
|
|
987
|
+
if (rejected) context.addCase(thunk.rejected, rejected);
|
|
988
|
+
if (settled) context.addMatcher(thunk.settled, settled);
|
|
989
|
+
context.exposeCaseReducer(reducerName, {
|
|
990
|
+
fulfilled: fulfilled || noop$1,
|
|
991
|
+
pending: pending || noop$1,
|
|
992
|
+
rejected: rejected || noop$1,
|
|
993
|
+
settled: settled || noop$1
|
|
994
|
+
});
|
|
1387
995
|
}
|
|
1388
|
-
function noop() {
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
// src/entities/entity_state.ts
|
|
996
|
+
function noop$1() {}
|
|
997
|
+
//#endregion
|
|
998
|
+
//#region src/entities/entity_state.ts
|
|
1392
999
|
function getInitialEntityState() {
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1000
|
+
return {
|
|
1001
|
+
ids: [],
|
|
1002
|
+
entities: {}
|
|
1003
|
+
};
|
|
1397
1004
|
}
|
|
1398
1005
|
function createInitialStateFactory(stateAdapter) {
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
getInitialState
|
|
1405
|
-
};
|
|
1006
|
+
function getInitialState(additionalState = {}, entities) {
|
|
1007
|
+
const state = Object.assign(getInitialEntityState(), additionalState);
|
|
1008
|
+
return entities ? stateAdapter.setAll(state, entities) : state;
|
|
1009
|
+
}
|
|
1010
|
+
return { getInitialState };
|
|
1406
1011
|
}
|
|
1407
|
-
|
|
1408
|
-
|
|
1012
|
+
//#endregion
|
|
1013
|
+
//#region src/entities/state_selectors.ts
|
|
1409
1014
|
function createSelectorsFactory() {
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
selectById: createSelector2(selectGlobalizedEntities, selectId, selectById)
|
|
1436
|
-
};
|
|
1437
|
-
}
|
|
1438
|
-
return {
|
|
1439
|
-
getSelectors
|
|
1440
|
-
};
|
|
1015
|
+
function getSelectors(selectState, options = {}) {
|
|
1016
|
+
const { createSelector = createDraftSafeSelector } = options;
|
|
1017
|
+
const selectIds = (state) => state.ids;
|
|
1018
|
+
const selectEntities = (state) => state.entities;
|
|
1019
|
+
const selectAll = createSelector(selectIds, selectEntities, (ids, entities) => ids.map((id) => entities[id]));
|
|
1020
|
+
const selectId = (_, id) => id;
|
|
1021
|
+
const selectById = (entities, id) => entities[id];
|
|
1022
|
+
const selectTotal = createSelector(selectIds, (ids) => ids.length);
|
|
1023
|
+
if (!selectState) return {
|
|
1024
|
+
selectIds,
|
|
1025
|
+
selectEntities,
|
|
1026
|
+
selectAll,
|
|
1027
|
+
selectTotal,
|
|
1028
|
+
selectById: createSelector(selectEntities, selectId, selectById)
|
|
1029
|
+
};
|
|
1030
|
+
const selectGlobalizedEntities = createSelector(selectState, selectEntities);
|
|
1031
|
+
return {
|
|
1032
|
+
selectIds: createSelector(selectState, selectIds),
|
|
1033
|
+
selectEntities: selectGlobalizedEntities,
|
|
1034
|
+
selectAll: createSelector(selectState, selectAll),
|
|
1035
|
+
selectTotal: createSelector(selectState, selectTotal),
|
|
1036
|
+
selectById: createSelector(selectGlobalizedEntities, selectId, selectById)
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
return { getSelectors };
|
|
1441
1040
|
}
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1041
|
+
//#endregion
|
|
1042
|
+
//#region src/entities/state_adapter.ts
|
|
1043
|
+
const isDraftTyped = immer.isDraft;
|
|
1445
1044
|
function createSingleArgumentStateOperator(mutator) {
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1045
|
+
const operator = createStateOperator((_, state) => mutator(state));
|
|
1046
|
+
return function operation(state) {
|
|
1047
|
+
return operator(state, void 0);
|
|
1048
|
+
};
|
|
1450
1049
|
}
|
|
1451
1050
|
function createStateOperator(mutator) {
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
}
|
|
1467
|
-
return (0, import_immer.produce)(state, runMutator);
|
|
1468
|
-
};
|
|
1051
|
+
return function operation(state, arg) {
|
|
1052
|
+
function isPayloadActionArgument(arg) {
|
|
1053
|
+
return isFSA(arg);
|
|
1054
|
+
}
|
|
1055
|
+
const runMutator = (draft) => {
|
|
1056
|
+
if (isPayloadActionArgument(arg)) mutator(arg.payload, draft);
|
|
1057
|
+
else mutator(arg, draft);
|
|
1058
|
+
};
|
|
1059
|
+
if (isDraftTyped(state)) {
|
|
1060
|
+
runMutator(state);
|
|
1061
|
+
return state;
|
|
1062
|
+
}
|
|
1063
|
+
return (0, immer.produce)(state, runMutator);
|
|
1064
|
+
};
|
|
1469
1065
|
}
|
|
1470
|
-
|
|
1471
|
-
|
|
1066
|
+
//#endregion
|
|
1067
|
+
//#region src/entities/utils.ts
|
|
1472
1068
|
function selectIdValue(entity, selectId) {
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
}
|
|
1477
|
-
return key;
|
|
1069
|
+
const key = selectId(entity);
|
|
1070
|
+
if (key === void 0) console.warn("The entity passed to the `selectId` implementation returned undefined.", "You should probably provide your own `selectId` implementation.", "The entity that was passed:", entity, "The `selectId` implementation:", selectId.toString());
|
|
1071
|
+
return key;
|
|
1478
1072
|
}
|
|
1479
1073
|
function ensureEntitiesArray(entities) {
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
}
|
|
1483
|
-
return entities;
|
|
1074
|
+
if (!Array.isArray(entities)) entities = Object.values(entities);
|
|
1075
|
+
return entities;
|
|
1484
1076
|
}
|
|
1485
1077
|
function getCurrent(value) {
|
|
1486
|
-
|
|
1078
|
+
return (0, immer.isDraft)(value) ? (0, immer.current)(value) : value;
|
|
1487
1079
|
}
|
|
1488
1080
|
function splitAddedUpdatedEntities(newEntities, selectId, state) {
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1081
|
+
newEntities = ensureEntitiesArray(newEntities);
|
|
1082
|
+
const existingIdsArray = getCurrent(state.ids);
|
|
1083
|
+
const existingIds = new Set(existingIdsArray);
|
|
1084
|
+
const added = [];
|
|
1085
|
+
const addedIds = /* @__PURE__ */ new Set([]);
|
|
1086
|
+
const updated = [];
|
|
1087
|
+
for (const entity of newEntities) {
|
|
1088
|
+
const id = selectIdValue(entity, selectId);
|
|
1089
|
+
if (existingIds.has(id) || addedIds.has(id)) updated.push({
|
|
1090
|
+
id,
|
|
1091
|
+
changes: entity
|
|
1092
|
+
});
|
|
1093
|
+
else {
|
|
1094
|
+
addedIds.add(id);
|
|
1095
|
+
added.push(entity);
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
return [
|
|
1099
|
+
added,
|
|
1100
|
+
updated,
|
|
1101
|
+
existingIdsArray
|
|
1102
|
+
];
|
|
1508
1103
|
}
|
|
1509
|
-
|
|
1510
|
-
|
|
1104
|
+
//#endregion
|
|
1105
|
+
//#region src/entities/unsorted_state_adapter.ts
|
|
1511
1106
|
function createUnsortedStateAdapter(selectId) {
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
function upsertOneMutably(entity, state) {
|
|
1612
|
-
return upsertManyMutably([entity], state);
|
|
1613
|
-
}
|
|
1614
|
-
function upsertManyMutably(newEntities, state) {
|
|
1615
|
-
const [added, updated] = splitAddedUpdatedEntities(newEntities, selectId, state);
|
|
1616
|
-
addManyMutably(added, state);
|
|
1617
|
-
updateManyMutably(updated, state);
|
|
1618
|
-
}
|
|
1619
|
-
return {
|
|
1620
|
-
removeAll: createSingleArgumentStateOperator(removeAllMutably),
|
|
1621
|
-
addOne: createStateOperator(addOneMutably),
|
|
1622
|
-
addMany: createStateOperator(addManyMutably),
|
|
1623
|
-
setOne: createStateOperator(setOneMutably),
|
|
1624
|
-
setMany: createStateOperator(setManyMutably),
|
|
1625
|
-
setAll: createStateOperator(setAllMutably),
|
|
1626
|
-
updateOne: createStateOperator(updateOneMutably),
|
|
1627
|
-
updateMany: createStateOperator(updateManyMutably),
|
|
1628
|
-
upsertOne: createStateOperator(upsertOneMutably),
|
|
1629
|
-
upsertMany: createStateOperator(upsertManyMutably),
|
|
1630
|
-
removeOne: createStateOperator(removeOneMutably),
|
|
1631
|
-
removeMany: createStateOperator(removeManyMutably)
|
|
1632
|
-
};
|
|
1107
|
+
function addOneMutably(entity, state) {
|
|
1108
|
+
const key = selectIdValue(entity, selectId);
|
|
1109
|
+
if (key in state.entities) return;
|
|
1110
|
+
state.ids.push(key);
|
|
1111
|
+
state.entities[key] = entity;
|
|
1112
|
+
}
|
|
1113
|
+
function addManyMutably(newEntities, state) {
|
|
1114
|
+
newEntities = ensureEntitiesArray(newEntities);
|
|
1115
|
+
for (const entity of newEntities) addOneMutably(entity, state);
|
|
1116
|
+
}
|
|
1117
|
+
function setOneMutably(entity, state) {
|
|
1118
|
+
const key = selectIdValue(entity, selectId);
|
|
1119
|
+
if (!(key in state.entities)) state.ids.push(key);
|
|
1120
|
+
state.entities[key] = entity;
|
|
1121
|
+
}
|
|
1122
|
+
function setManyMutably(newEntities, state) {
|
|
1123
|
+
newEntities = ensureEntitiesArray(newEntities);
|
|
1124
|
+
for (const entity of newEntities) setOneMutably(entity, state);
|
|
1125
|
+
}
|
|
1126
|
+
function setAllMutably(newEntities, state) {
|
|
1127
|
+
newEntities = ensureEntitiesArray(newEntities);
|
|
1128
|
+
state.ids = [];
|
|
1129
|
+
state.entities = {};
|
|
1130
|
+
setManyMutably(newEntities, state);
|
|
1131
|
+
}
|
|
1132
|
+
function removeOneMutably(key, state) {
|
|
1133
|
+
return removeManyMutably([key], state);
|
|
1134
|
+
}
|
|
1135
|
+
function removeManyMutably(keys, state) {
|
|
1136
|
+
let didMutate = false;
|
|
1137
|
+
keys.forEach((key) => {
|
|
1138
|
+
if (key in state.entities) {
|
|
1139
|
+
delete state.entities[key];
|
|
1140
|
+
didMutate = true;
|
|
1141
|
+
}
|
|
1142
|
+
});
|
|
1143
|
+
if (didMutate) state.ids = state.ids.filter((id) => id in state.entities);
|
|
1144
|
+
}
|
|
1145
|
+
function removeAllMutably(state) {
|
|
1146
|
+
Object.assign(state, {
|
|
1147
|
+
ids: [],
|
|
1148
|
+
entities: {}
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
function takeNewKey(keys, update, state) {
|
|
1152
|
+
const original = state.entities[update.id];
|
|
1153
|
+
if (original === void 0) return false;
|
|
1154
|
+
const updated = Object.assign({}, original, update.changes);
|
|
1155
|
+
const newKey = selectIdValue(updated, selectId);
|
|
1156
|
+
const hasNewKey = newKey !== update.id;
|
|
1157
|
+
if (hasNewKey) {
|
|
1158
|
+
keys[update.id] = newKey;
|
|
1159
|
+
delete state.entities[update.id];
|
|
1160
|
+
}
|
|
1161
|
+
state.entities[newKey] = updated;
|
|
1162
|
+
return hasNewKey;
|
|
1163
|
+
}
|
|
1164
|
+
function updateOneMutably(update, state) {
|
|
1165
|
+
return updateManyMutably([update], state);
|
|
1166
|
+
}
|
|
1167
|
+
function updateManyMutably(updates, state) {
|
|
1168
|
+
const newKeys = {};
|
|
1169
|
+
const updatesPerEntity = {};
|
|
1170
|
+
updates.forEach((update) => {
|
|
1171
|
+
if (update.id in state.entities) updatesPerEntity[update.id] = {
|
|
1172
|
+
id: update.id,
|
|
1173
|
+
changes: {
|
|
1174
|
+
...updatesPerEntity[update.id]?.changes,
|
|
1175
|
+
...update.changes
|
|
1176
|
+
}
|
|
1177
|
+
};
|
|
1178
|
+
});
|
|
1179
|
+
updates = Object.values(updatesPerEntity);
|
|
1180
|
+
if (updates.length > 0) {
|
|
1181
|
+
if (updates.filter((update) => takeNewKey(newKeys, update, state)).length > 0) state.ids = Object.values(state.entities).map((e) => selectIdValue(e, selectId));
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
function upsertOneMutably(entity, state) {
|
|
1185
|
+
return upsertManyMutably([entity], state);
|
|
1186
|
+
}
|
|
1187
|
+
function upsertManyMutably(newEntities, state) {
|
|
1188
|
+
const [added, updated] = splitAddedUpdatedEntities(newEntities, selectId, state);
|
|
1189
|
+
addManyMutably(added, state);
|
|
1190
|
+
updateManyMutably(updated, state);
|
|
1191
|
+
}
|
|
1192
|
+
return {
|
|
1193
|
+
removeAll: createSingleArgumentStateOperator(removeAllMutably),
|
|
1194
|
+
addOne: createStateOperator(addOneMutably),
|
|
1195
|
+
addMany: createStateOperator(addManyMutably),
|
|
1196
|
+
setOne: createStateOperator(setOneMutably),
|
|
1197
|
+
setMany: createStateOperator(setManyMutably),
|
|
1198
|
+
setAll: createStateOperator(setAllMutably),
|
|
1199
|
+
updateOne: createStateOperator(updateOneMutably),
|
|
1200
|
+
updateMany: createStateOperator(updateManyMutably),
|
|
1201
|
+
upsertOne: createStateOperator(upsertOneMutably),
|
|
1202
|
+
upsertMany: createStateOperator(upsertManyMutably),
|
|
1203
|
+
removeOne: createStateOperator(removeOneMutably),
|
|
1204
|
+
removeMany: createStateOperator(removeManyMutably)
|
|
1205
|
+
};
|
|
1633
1206
|
}
|
|
1634
|
-
|
|
1635
|
-
|
|
1207
|
+
//#endregion
|
|
1208
|
+
//#region src/entities/sorted_state_adapter.ts
|
|
1636
1209
|
function findInsertIndex(sortedItems, item, comparisonFunction) {
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
highIndex = middleIndex;
|
|
1647
|
-
}
|
|
1648
|
-
}
|
|
1649
|
-
return lowIndex;
|
|
1210
|
+
let lowIndex = 0;
|
|
1211
|
+
let highIndex = sortedItems.length;
|
|
1212
|
+
while (lowIndex < highIndex) {
|
|
1213
|
+
let middleIndex = lowIndex + highIndex >>> 1;
|
|
1214
|
+
const currentItem = sortedItems[middleIndex];
|
|
1215
|
+
if (comparisonFunction(item, currentItem) >= 0) lowIndex = middleIndex + 1;
|
|
1216
|
+
else highIndex = middleIndex;
|
|
1217
|
+
}
|
|
1218
|
+
return lowIndex;
|
|
1650
1219
|
}
|
|
1651
1220
|
function insert(sortedItems, item, comparisonFunction) {
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1221
|
+
const insertAtIndex = findInsertIndex(sortedItems, item, comparisonFunction);
|
|
1222
|
+
sortedItems.splice(insertAtIndex, 0, item);
|
|
1223
|
+
return sortedItems;
|
|
1655
1224
|
}
|
|
1656
1225
|
function createSortedStateAdapter(selectId, comparer) {
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
sortedEntities.sort(comparer);
|
|
1777
|
-
}
|
|
1778
|
-
const newSortedIds = sortedEntities.map(selectId);
|
|
1779
|
-
if (!areArraysEqual(currentIds, newSortedIds)) {
|
|
1780
|
-
state.ids = newSortedIds;
|
|
1781
|
-
}
|
|
1782
|
-
};
|
|
1783
|
-
return {
|
|
1784
|
-
removeOne,
|
|
1785
|
-
removeMany,
|
|
1786
|
-
removeAll,
|
|
1787
|
-
addOne: createStateOperator(addOneMutably),
|
|
1788
|
-
updateOne: createStateOperator(updateOneMutably),
|
|
1789
|
-
upsertOne: createStateOperator(upsertOneMutably),
|
|
1790
|
-
setOne: createStateOperator(setOneMutably),
|
|
1791
|
-
setMany: createStateOperator(setManyMutably),
|
|
1792
|
-
setAll: createStateOperator(setAllMutably),
|
|
1793
|
-
addMany: createStateOperator(addManyMutably),
|
|
1794
|
-
updateMany: createStateOperator(updateManyMutably),
|
|
1795
|
-
upsertMany: createStateOperator(upsertManyMutably)
|
|
1796
|
-
};
|
|
1226
|
+
const { removeOne, removeMany, removeAll } = createUnsortedStateAdapter(selectId);
|
|
1227
|
+
function addOneMutably(entity, state) {
|
|
1228
|
+
return addManyMutably([entity], state);
|
|
1229
|
+
}
|
|
1230
|
+
function addManyMutably(newEntities, state, existingIds) {
|
|
1231
|
+
newEntities = ensureEntitiesArray(newEntities);
|
|
1232
|
+
const existingKeys = new Set(existingIds ?? getCurrent(state.ids));
|
|
1233
|
+
const addedKeys = /* @__PURE__ */ new Set();
|
|
1234
|
+
const models = newEntities.filter((model) => {
|
|
1235
|
+
const modelId = selectIdValue(model, selectId);
|
|
1236
|
+
const notAdded = !addedKeys.has(modelId);
|
|
1237
|
+
if (notAdded) addedKeys.add(modelId);
|
|
1238
|
+
return !existingKeys.has(modelId) && notAdded;
|
|
1239
|
+
});
|
|
1240
|
+
if (models.length !== 0) mergeFunction(state, models);
|
|
1241
|
+
}
|
|
1242
|
+
function setOneMutably(entity, state) {
|
|
1243
|
+
return setManyMutably([entity], state);
|
|
1244
|
+
}
|
|
1245
|
+
function setManyMutably(newEntities, state) {
|
|
1246
|
+
let deduplicatedEntities = {};
|
|
1247
|
+
newEntities = ensureEntitiesArray(newEntities);
|
|
1248
|
+
if (newEntities.length !== 0) {
|
|
1249
|
+
for (const item of newEntities) {
|
|
1250
|
+
const entityId = selectId(item);
|
|
1251
|
+
deduplicatedEntities[entityId] = item;
|
|
1252
|
+
delete state.entities[entityId];
|
|
1253
|
+
}
|
|
1254
|
+
newEntities = ensureEntitiesArray(deduplicatedEntities);
|
|
1255
|
+
mergeFunction(state, newEntities);
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
function setAllMutably(newEntities, state) {
|
|
1259
|
+
newEntities = ensureEntitiesArray(newEntities);
|
|
1260
|
+
state.entities = {};
|
|
1261
|
+
state.ids = [];
|
|
1262
|
+
setManyMutably(newEntities, state);
|
|
1263
|
+
}
|
|
1264
|
+
function updateOneMutably(update, state) {
|
|
1265
|
+
return updateManyMutably([update], state);
|
|
1266
|
+
}
|
|
1267
|
+
function updateManyMutably(updates, state) {
|
|
1268
|
+
let appliedUpdates = false;
|
|
1269
|
+
let replacedIds = false;
|
|
1270
|
+
const updatesPerEntity = {};
|
|
1271
|
+
for (const update of updates) if (update.id in state.entities) updatesPerEntity[update.id] = {
|
|
1272
|
+
id: update.id,
|
|
1273
|
+
changes: {
|
|
1274
|
+
...updatesPerEntity[update.id]?.changes,
|
|
1275
|
+
...update.changes
|
|
1276
|
+
}
|
|
1277
|
+
};
|
|
1278
|
+
for (const update of Object.values(updatesPerEntity)) {
|
|
1279
|
+
const entity = state.entities[update.id];
|
|
1280
|
+
if (!entity) continue;
|
|
1281
|
+
appliedUpdates = true;
|
|
1282
|
+
Object.assign(entity, update.changes);
|
|
1283
|
+
const newId = selectId(entity);
|
|
1284
|
+
if (update.id !== newId) {
|
|
1285
|
+
replacedIds = true;
|
|
1286
|
+
delete state.entities[update.id];
|
|
1287
|
+
const oldIndex = state.ids.indexOf(update.id);
|
|
1288
|
+
state.ids[oldIndex] = newId;
|
|
1289
|
+
state.entities[newId] = entity;
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
if (appliedUpdates) mergeFunction(state, [], appliedUpdates, replacedIds);
|
|
1293
|
+
}
|
|
1294
|
+
function upsertOneMutably(entity, state) {
|
|
1295
|
+
return upsertManyMutably([entity], state);
|
|
1296
|
+
}
|
|
1297
|
+
function upsertManyMutably(newEntities, state) {
|
|
1298
|
+
const [added, updated, existingIdsArray] = splitAddedUpdatedEntities(newEntities, selectId, state);
|
|
1299
|
+
if (added.length) addManyMutably(added, state, existingIdsArray);
|
|
1300
|
+
if (updated.length) updateManyMutably(updated, state);
|
|
1301
|
+
}
|
|
1302
|
+
function areArraysEqual(a, b) {
|
|
1303
|
+
if (a.length !== b.length) return false;
|
|
1304
|
+
for (let i = 0; i < a.length; i++) {
|
|
1305
|
+
if (a[i] === b[i]) continue;
|
|
1306
|
+
return false;
|
|
1307
|
+
}
|
|
1308
|
+
return true;
|
|
1309
|
+
}
|
|
1310
|
+
function mergeFunction(state, addedItems, appliedUpdates, replacedIds) {
|
|
1311
|
+
const currentEntities = getCurrent(state.entities);
|
|
1312
|
+
const currentIds = getCurrent(state.ids);
|
|
1313
|
+
const stateEntities = state.entities;
|
|
1314
|
+
let ids = currentIds;
|
|
1315
|
+
if (replacedIds) ids = new Set(currentIds);
|
|
1316
|
+
let sortedEntities = [];
|
|
1317
|
+
for (const id of ids) {
|
|
1318
|
+
const entity = currentEntities[id];
|
|
1319
|
+
if (entity) sortedEntities.push(entity);
|
|
1320
|
+
}
|
|
1321
|
+
const wasPreviouslyEmpty = sortedEntities.length === 0;
|
|
1322
|
+
for (const item of addedItems) {
|
|
1323
|
+
stateEntities[selectId(item)] = item;
|
|
1324
|
+
if (!wasPreviouslyEmpty) insert(sortedEntities, item, comparer);
|
|
1325
|
+
}
|
|
1326
|
+
if (wasPreviouslyEmpty) sortedEntities = addedItems.slice().sort(comparer);
|
|
1327
|
+
else if (appliedUpdates) sortedEntities.sort(comparer);
|
|
1328
|
+
const newSortedIds = sortedEntities.map(selectId);
|
|
1329
|
+
if (!areArraysEqual(currentIds, newSortedIds)) state.ids = newSortedIds;
|
|
1330
|
+
}
|
|
1331
|
+
return {
|
|
1332
|
+
removeOne,
|
|
1333
|
+
removeMany,
|
|
1334
|
+
removeAll,
|
|
1335
|
+
addOne: createStateOperator(addOneMutably),
|
|
1336
|
+
updateOne: createStateOperator(updateOneMutably),
|
|
1337
|
+
upsertOne: createStateOperator(upsertOneMutably),
|
|
1338
|
+
setOne: createStateOperator(setOneMutably),
|
|
1339
|
+
setMany: createStateOperator(setManyMutably),
|
|
1340
|
+
setAll: createStateOperator(setAllMutably),
|
|
1341
|
+
addMany: createStateOperator(addManyMutably),
|
|
1342
|
+
updateMany: createStateOperator(updateManyMutably),
|
|
1343
|
+
upsertMany: createStateOperator(upsertManyMutably)
|
|
1344
|
+
};
|
|
1797
1345
|
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1346
|
+
//#endregion
|
|
1347
|
+
//#region src/entities/create_adapter.ts
|
|
1800
1348
|
function createEntityAdapter(options = {}) {
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
...selectorsFactory,
|
|
1817
|
-
...stateAdapter
|
|
1818
|
-
};
|
|
1349
|
+
const { selectId, sortComparer } = {
|
|
1350
|
+
sortComparer: false,
|
|
1351
|
+
selectId: (instance) => instance.id,
|
|
1352
|
+
...options
|
|
1353
|
+
};
|
|
1354
|
+
const stateAdapter = sortComparer ? createSortedStateAdapter(selectId, sortComparer) : createUnsortedStateAdapter(selectId);
|
|
1355
|
+
const stateFactory = createInitialStateFactory(stateAdapter);
|
|
1356
|
+
const selectorsFactory = createSelectorsFactory();
|
|
1357
|
+
return {
|
|
1358
|
+
selectId,
|
|
1359
|
+
sortComparer,
|
|
1360
|
+
...stateFactory,
|
|
1361
|
+
...selectorsFactory,
|
|
1362
|
+
...stateAdapter
|
|
1363
|
+
};
|
|
1819
1364
|
}
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1365
|
+
//#endregion
|
|
1366
|
+
//#region src/listenerMiddleware/exceptions.ts
|
|
1367
|
+
const task = "task";
|
|
1368
|
+
const listener = "listener";
|
|
1369
|
+
const completed = "completed";
|
|
1370
|
+
const cancelled = "cancelled";
|
|
1371
|
+
const taskCancelled = `task-${cancelled}`;
|
|
1372
|
+
const taskCompleted = `task-${completed}`;
|
|
1373
|
+
const listenerCancelled = `${listener}-${cancelled}`;
|
|
1374
|
+
const listenerCompleted = `${listener}-${completed}`;
|
|
1830
1375
|
var TaskAbortError = class {
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
};
|
|
1839
|
-
|
|
1840
|
-
// src/listenerMiddleware/utils.ts
|
|
1841
|
-
var assertFunction = (func, expected) => {
|
|
1842
|
-
if (typeof func !== "function") {
|
|
1843
|
-
throw new TypeError(false ? _formatProdErrorMessage(32) : `${expected} is not a function`);
|
|
1844
|
-
}
|
|
1376
|
+
code;
|
|
1377
|
+
name = "TaskAbortError";
|
|
1378
|
+
message;
|
|
1379
|
+
constructor(code) {
|
|
1380
|
+
this.code = code;
|
|
1381
|
+
this.message = `${task} ${cancelled} (reason: ${code})`;
|
|
1382
|
+
}
|
|
1845
1383
|
};
|
|
1846
|
-
|
|
1384
|
+
//#endregion
|
|
1385
|
+
//#region src/listenerMiddleware/utils.ts
|
|
1386
|
+
const assertFunction = (func, expected) => {
|
|
1387
|
+
if (typeof func !== "function") throw new TypeError(`${expected} is not a function`);
|
|
1847
1388
|
};
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1389
|
+
const noop = () => {};
|
|
1390
|
+
const catchRejection = (promise, onError = noop) => {
|
|
1391
|
+
promise.catch(onError);
|
|
1392
|
+
return promise;
|
|
1851
1393
|
};
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
});
|
|
1856
|
-
return () => abortSignal.removeEventListener("abort", callback);
|
|
1394
|
+
const addAbortSignalListener = (abortSignal, callback) => {
|
|
1395
|
+
abortSignal.addEventListener("abort", callback, { once: true });
|
|
1396
|
+
return () => abortSignal.removeEventListener("abort", callback);
|
|
1857
1397
|
};
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
throw new TaskAbortError(signal.reason);
|
|
1863
|
-
}
|
|
1398
|
+
//#endregion
|
|
1399
|
+
//#region src/listenerMiddleware/task.ts
|
|
1400
|
+
const validateActive = (signal) => {
|
|
1401
|
+
if (signal.aborted) throw new TaskAbortError(signal.reason);
|
|
1864
1402
|
};
|
|
1865
1403
|
function raceWithSignal(signal, promise) {
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1404
|
+
let cleanup = noop;
|
|
1405
|
+
return new Promise((resolve, reject) => {
|
|
1406
|
+
const notifyRejection = () => reject(new TaskAbortError(signal.reason));
|
|
1407
|
+
if (signal.aborted) {
|
|
1408
|
+
notifyRejection();
|
|
1409
|
+
return;
|
|
1410
|
+
}
|
|
1411
|
+
cleanup = addAbortSignalListener(signal, notifyRejection);
|
|
1412
|
+
promise.finally(() => cleanup()).then(resolve, reject);
|
|
1413
|
+
}).finally(() => {
|
|
1414
|
+
cleanup = noop;
|
|
1415
|
+
});
|
|
1878
1416
|
}
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
}
|
|
1417
|
+
const runTask = async (task, cleanUp) => {
|
|
1418
|
+
try {
|
|
1419
|
+
await Promise.resolve();
|
|
1420
|
+
return {
|
|
1421
|
+
status: "ok",
|
|
1422
|
+
value: await task()
|
|
1423
|
+
};
|
|
1424
|
+
} catch (error) {
|
|
1425
|
+
return {
|
|
1426
|
+
status: error instanceof TaskAbortError ? "cancelled" : "rejected",
|
|
1427
|
+
error
|
|
1428
|
+
};
|
|
1429
|
+
} finally {
|
|
1430
|
+
cleanUp?.();
|
|
1431
|
+
}
|
|
1895
1432
|
};
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1433
|
+
const createPause = (signal) => {
|
|
1434
|
+
return (promise) => {
|
|
1435
|
+
return catchRejection(raceWithSignal(signal, promise).then((output) => {
|
|
1436
|
+
validateActive(signal);
|
|
1437
|
+
return output;
|
|
1438
|
+
}));
|
|
1439
|
+
};
|
|
1903
1440
|
};
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1441
|
+
const createDelay = (signal) => {
|
|
1442
|
+
const pause = createPause(signal);
|
|
1443
|
+
return (timeoutMs) => {
|
|
1444
|
+
return pause(new Promise((resolve) => setTimeout(resolve, timeoutMs)));
|
|
1445
|
+
};
|
|
1909
1446
|
};
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
childAbortController.abort(taskCancelled);
|
|
1941
|
-
}
|
|
1942
|
-
};
|
|
1943
|
-
};
|
|
1447
|
+
//#endregion
|
|
1448
|
+
//#region src/listenerMiddleware/index.ts
|
|
1449
|
+
const { assign } = Object;
|
|
1450
|
+
const INTERNAL_NIL_TOKEN = {};
|
|
1451
|
+
const alm = "listenerMiddleware";
|
|
1452
|
+
const createFork = (parentAbortSignal, parentBlockingPromises) => {
|
|
1453
|
+
const linkControllers = (controller) => addAbortSignalListener(parentAbortSignal, () => controller.abort(parentAbortSignal.reason));
|
|
1454
|
+
return (taskExecutor, opts) => {
|
|
1455
|
+
assertFunction(taskExecutor, "taskExecutor");
|
|
1456
|
+
const childAbortController = new AbortController();
|
|
1457
|
+
linkControllers(childAbortController);
|
|
1458
|
+
const result = runTask(async () => {
|
|
1459
|
+
validateActive(parentAbortSignal);
|
|
1460
|
+
validateActive(childAbortController.signal);
|
|
1461
|
+
const result = await taskExecutor({
|
|
1462
|
+
pause: createPause(childAbortController.signal),
|
|
1463
|
+
delay: createDelay(childAbortController.signal),
|
|
1464
|
+
signal: childAbortController.signal
|
|
1465
|
+
});
|
|
1466
|
+
validateActive(childAbortController.signal);
|
|
1467
|
+
return result;
|
|
1468
|
+
}, () => childAbortController.abort(taskCompleted));
|
|
1469
|
+
if (opts?.autoJoin) parentBlockingPromises.push(result.catch(noop));
|
|
1470
|
+
return {
|
|
1471
|
+
result: createPause(parentAbortSignal)(result),
|
|
1472
|
+
cancel() {
|
|
1473
|
+
childAbortController.abort(taskCancelled);
|
|
1474
|
+
}
|
|
1475
|
+
};
|
|
1476
|
+
};
|
|
1944
1477
|
};
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1478
|
+
const createTakePattern = (startListening, signal) => {
|
|
1479
|
+
const take = async (predicate, timeout) => {
|
|
1480
|
+
validateActive(signal);
|
|
1481
|
+
let unsubscribe = () => {};
|
|
1482
|
+
const promises = [new Promise((resolve, reject) => {
|
|
1483
|
+
let stopListening = startListening({
|
|
1484
|
+
predicate,
|
|
1485
|
+
effect: (action, listenerApi) => {
|
|
1486
|
+
listenerApi.unsubscribe();
|
|
1487
|
+
resolve([
|
|
1488
|
+
action,
|
|
1489
|
+
listenerApi.getState(),
|
|
1490
|
+
listenerApi.getOriginalState()
|
|
1491
|
+
]);
|
|
1492
|
+
}
|
|
1493
|
+
});
|
|
1494
|
+
unsubscribe = () => {
|
|
1495
|
+
stopListening();
|
|
1496
|
+
reject();
|
|
1497
|
+
};
|
|
1498
|
+
})];
|
|
1499
|
+
if (timeout != null) promises.push(new Promise((resolve) => setTimeout(resolve, timeout, null)));
|
|
1500
|
+
try {
|
|
1501
|
+
const output = await raceWithSignal(signal, Promise.race(promises));
|
|
1502
|
+
validateActive(signal);
|
|
1503
|
+
return output;
|
|
1504
|
+
} finally {
|
|
1505
|
+
unsubscribe();
|
|
1506
|
+
}
|
|
1507
|
+
};
|
|
1508
|
+
return ((predicate, timeout) => catchRejection(take(predicate, timeout)));
|
|
1976
1509
|
};
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
predicate = matcher;
|
|
1992
|
-
} else if (predicate) {
|
|
1993
|
-
} else {
|
|
1994
|
-
throw new Error(false ? _formatProdErrorMessage(21) : "Creating or removing a listener requires one of the known fields for matching an action");
|
|
1995
|
-
}
|
|
1996
|
-
assertFunction(effect, "options.listener");
|
|
1997
|
-
return {
|
|
1998
|
-
predicate,
|
|
1999
|
-
type,
|
|
2000
|
-
effect
|
|
2001
|
-
};
|
|
1510
|
+
const getListenerEntryPropsFrom = (options) => {
|
|
1511
|
+
let { type, actionCreator, matcher, predicate, effect } = options;
|
|
1512
|
+
if (type) predicate = createAction(type).match;
|
|
1513
|
+
else if (actionCreator) {
|
|
1514
|
+
type = actionCreator.type;
|
|
1515
|
+
predicate = actionCreator.match;
|
|
1516
|
+
} else if (matcher) predicate = matcher;
|
|
1517
|
+
else if (predicate) {} else throw new Error("Creating or removing a listener requires one of the known fields for matching an action");
|
|
1518
|
+
assertFunction(effect, "options.listener");
|
|
1519
|
+
return {
|
|
1520
|
+
predicate,
|
|
1521
|
+
type,
|
|
1522
|
+
effect
|
|
1523
|
+
};
|
|
2002
1524
|
};
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
}
|
|
2021
|
-
withTypes: () => createListenerEntry
|
|
2022
|
-
});
|
|
2023
|
-
var findListenerEntry = (listenerMap, options) => {
|
|
2024
|
-
const {
|
|
2025
|
-
type,
|
|
2026
|
-
effect,
|
|
2027
|
-
predicate
|
|
2028
|
-
} = getListenerEntryPropsFrom(options);
|
|
2029
|
-
return Array.from(listenerMap.values()).find((entry) => {
|
|
2030
|
-
const matchPredicateOrType = typeof type === "string" ? entry.type === type : entry.predicate === predicate;
|
|
2031
|
-
return matchPredicateOrType && entry.effect === effect;
|
|
2032
|
-
});
|
|
1525
|
+
const createListenerEntry = /* @__PURE__ */ assign((options) => {
|
|
1526
|
+
const { type, predicate, effect } = getListenerEntryPropsFrom(options);
|
|
1527
|
+
return {
|
|
1528
|
+
id: nanoid(),
|
|
1529
|
+
effect,
|
|
1530
|
+
type,
|
|
1531
|
+
predicate,
|
|
1532
|
+
pending: /* @__PURE__ */ new Set(),
|
|
1533
|
+
unsubscribe: () => {
|
|
1534
|
+
throw new Error("Unsubscribe not initialized");
|
|
1535
|
+
}
|
|
1536
|
+
};
|
|
1537
|
+
}, { withTypes: () => createListenerEntry });
|
|
1538
|
+
const findListenerEntry = (listenerMap, options) => {
|
|
1539
|
+
const { type, effect, predicate } = getListenerEntryPropsFrom(options);
|
|
1540
|
+
return Array.from(listenerMap.values()).find((entry) => {
|
|
1541
|
+
return (typeof type === "string" ? entry.type === type : entry.predicate === predicate) && entry.effect === effect;
|
|
1542
|
+
});
|
|
2033
1543
|
};
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
1544
|
+
const cancelActiveListeners = (entry) => {
|
|
1545
|
+
entry.pending.forEach((controller) => {
|
|
1546
|
+
controller.abort(listenerCancelled);
|
|
1547
|
+
});
|
|
2038
1548
|
};
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
listenerMap.clear();
|
|
2045
|
-
};
|
|
1549
|
+
const createClearListenerMiddleware = (listenerMap, executingListeners) => {
|
|
1550
|
+
return () => {
|
|
1551
|
+
for (const listener of executingListeners.keys()) cancelActiveListeners(listener);
|
|
1552
|
+
listenerMap.clear();
|
|
1553
|
+
};
|
|
2046
1554
|
};
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
1555
|
+
const safelyNotifyError = (errorHandler, errorToNotify, errorInfo) => {
|
|
1556
|
+
try {
|
|
1557
|
+
errorHandler(errorToNotify, errorInfo);
|
|
1558
|
+
} catch (errorHandlerError) {
|
|
1559
|
+
setTimeout(() => {
|
|
1560
|
+
throw errorHandlerError;
|
|
1561
|
+
}, 0);
|
|
1562
|
+
}
|
|
2055
1563
|
};
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
});
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
withTypes: () => removeListener
|
|
2062
|
-
});
|
|
2063
|
-
var defaultErrorHandler = (...args) => {
|
|
2064
|
-
console.error(`${alm}/error`, ...args);
|
|
1564
|
+
const addListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/add`), { withTypes: () => addListener });
|
|
1565
|
+
const clearAllListeners = /* @__PURE__ */ createAction(`${alm}/removeAll`);
|
|
1566
|
+
const removeListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/remove`), { withTypes: () => removeListener });
|
|
1567
|
+
const defaultErrorHandler = (...args) => {
|
|
1568
|
+
console.error(`${alm}/error`, ...args);
|
|
2065
1569
|
};
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
};
|
|
2191
|
-
let result;
|
|
2192
|
-
try {
|
|
2193
|
-
result = next(action);
|
|
2194
|
-
if (listenerMap.size > 0) {
|
|
2195
|
-
const currentState = api.getState();
|
|
2196
|
-
const listenerEntries = Array.from(listenerMap.values());
|
|
2197
|
-
for (const entry of listenerEntries) {
|
|
2198
|
-
let runListener = false;
|
|
2199
|
-
try {
|
|
2200
|
-
runListener = entry.predicate(action, currentState, originalState);
|
|
2201
|
-
} catch (predicateError) {
|
|
2202
|
-
runListener = false;
|
|
2203
|
-
safelyNotifyError(onError, predicateError, {
|
|
2204
|
-
raisedBy: "predicate"
|
|
2205
|
-
});
|
|
2206
|
-
}
|
|
2207
|
-
if (!runListener) {
|
|
2208
|
-
continue;
|
|
2209
|
-
}
|
|
2210
|
-
notifyListener(entry, action, api, getOriginalState);
|
|
2211
|
-
}
|
|
2212
|
-
}
|
|
2213
|
-
} finally {
|
|
2214
|
-
originalState = INTERNAL_NIL_TOKEN;
|
|
2215
|
-
}
|
|
2216
|
-
return result;
|
|
2217
|
-
};
|
|
2218
|
-
return {
|
|
2219
|
-
middleware,
|
|
2220
|
-
startListening,
|
|
2221
|
-
stopListening,
|
|
2222
|
-
clearListeners: clearListenerMiddleware
|
|
2223
|
-
};
|
|
1570
|
+
const createListenerMiddleware = (middlewareOptions = {}) => {
|
|
1571
|
+
const listenerMap = /* @__PURE__ */ new Map();
|
|
1572
|
+
const executingListeners = /* @__PURE__ */ new Map();
|
|
1573
|
+
const trackExecutingListener = (entry) => {
|
|
1574
|
+
const count = executingListeners.get(entry) ?? 0;
|
|
1575
|
+
executingListeners.set(entry, count + 1);
|
|
1576
|
+
};
|
|
1577
|
+
const untrackExecutingListener = (entry) => {
|
|
1578
|
+
const count = executingListeners.get(entry) ?? 1;
|
|
1579
|
+
if (count === 1) executingListeners.delete(entry);
|
|
1580
|
+
else executingListeners.set(entry, count - 1);
|
|
1581
|
+
};
|
|
1582
|
+
const { extra, onError = defaultErrorHandler } = middlewareOptions;
|
|
1583
|
+
assertFunction(onError, "onError");
|
|
1584
|
+
const insertEntry = (entry) => {
|
|
1585
|
+
entry.unsubscribe = () => listenerMap.delete(entry.id);
|
|
1586
|
+
listenerMap.set(entry.id, entry);
|
|
1587
|
+
return (cancelOptions) => {
|
|
1588
|
+
entry.unsubscribe();
|
|
1589
|
+
if (cancelOptions?.cancelActive) cancelActiveListeners(entry);
|
|
1590
|
+
};
|
|
1591
|
+
};
|
|
1592
|
+
const startListening = ((options) => {
|
|
1593
|
+
const entry = findListenerEntry(listenerMap, options) ?? createListenerEntry(options);
|
|
1594
|
+
return insertEntry(entry);
|
|
1595
|
+
});
|
|
1596
|
+
assign(startListening, { withTypes: () => startListening });
|
|
1597
|
+
const stopListening = (options) => {
|
|
1598
|
+
const entry = findListenerEntry(listenerMap, options);
|
|
1599
|
+
if (entry) {
|
|
1600
|
+
entry.unsubscribe();
|
|
1601
|
+
if (options.cancelActive) cancelActiveListeners(entry);
|
|
1602
|
+
}
|
|
1603
|
+
return !!entry;
|
|
1604
|
+
};
|
|
1605
|
+
assign(stopListening, { withTypes: () => stopListening });
|
|
1606
|
+
const notifyListener = async (entry, action, api, getOriginalState) => {
|
|
1607
|
+
const internalTaskController = new AbortController();
|
|
1608
|
+
const take = createTakePattern(startListening, internalTaskController.signal);
|
|
1609
|
+
const autoJoinPromises = [];
|
|
1610
|
+
try {
|
|
1611
|
+
entry.pending.add(internalTaskController);
|
|
1612
|
+
trackExecutingListener(entry);
|
|
1613
|
+
await Promise.resolve(entry.effect(action, assign({}, api, {
|
|
1614
|
+
getOriginalState,
|
|
1615
|
+
condition: (predicate, timeout) => take(predicate, timeout).then(Boolean),
|
|
1616
|
+
take,
|
|
1617
|
+
delay: createDelay(internalTaskController.signal),
|
|
1618
|
+
pause: createPause(internalTaskController.signal),
|
|
1619
|
+
extra,
|
|
1620
|
+
signal: internalTaskController.signal,
|
|
1621
|
+
fork: createFork(internalTaskController.signal, autoJoinPromises),
|
|
1622
|
+
unsubscribe: entry.unsubscribe,
|
|
1623
|
+
subscribe: () => {
|
|
1624
|
+
listenerMap.set(entry.id, entry);
|
|
1625
|
+
},
|
|
1626
|
+
cancelActiveListeners: () => {
|
|
1627
|
+
entry.pending.forEach((controller, _, set) => {
|
|
1628
|
+
if (controller !== internalTaskController) {
|
|
1629
|
+
controller.abort(listenerCancelled);
|
|
1630
|
+
set.delete(controller);
|
|
1631
|
+
}
|
|
1632
|
+
});
|
|
1633
|
+
},
|
|
1634
|
+
cancel: () => {
|
|
1635
|
+
internalTaskController.abort(listenerCancelled);
|
|
1636
|
+
entry.pending.delete(internalTaskController);
|
|
1637
|
+
},
|
|
1638
|
+
throwIfCancelled: () => {
|
|
1639
|
+
validateActive(internalTaskController.signal);
|
|
1640
|
+
}
|
|
1641
|
+
})));
|
|
1642
|
+
} catch (listenerError) {
|
|
1643
|
+
if (!(listenerError instanceof TaskAbortError)) safelyNotifyError(onError, listenerError, { raisedBy: "effect" });
|
|
1644
|
+
} finally {
|
|
1645
|
+
await Promise.all(autoJoinPromises);
|
|
1646
|
+
internalTaskController.abort(listenerCompleted);
|
|
1647
|
+
untrackExecutingListener(entry);
|
|
1648
|
+
entry.pending.delete(internalTaskController);
|
|
1649
|
+
}
|
|
1650
|
+
};
|
|
1651
|
+
const clearListenerMiddleware = createClearListenerMiddleware(listenerMap, executingListeners);
|
|
1652
|
+
const middleware = (api) => (next) => (action) => {
|
|
1653
|
+
if (!(0, redux.isAction)(action)) return next(action);
|
|
1654
|
+
if (addListener.match(action)) return startListening(action.payload);
|
|
1655
|
+
if (clearAllListeners.match(action)) {
|
|
1656
|
+
clearListenerMiddleware();
|
|
1657
|
+
return;
|
|
1658
|
+
}
|
|
1659
|
+
if (removeListener.match(action)) return stopListening(action.payload);
|
|
1660
|
+
let originalState = api.getState();
|
|
1661
|
+
const getOriginalState = () => {
|
|
1662
|
+
if (originalState === INTERNAL_NIL_TOKEN) throw new Error(`${alm}: getOriginalState can only be called synchronously`);
|
|
1663
|
+
return originalState;
|
|
1664
|
+
};
|
|
1665
|
+
let result;
|
|
1666
|
+
try {
|
|
1667
|
+
result = next(action);
|
|
1668
|
+
if (listenerMap.size > 0) {
|
|
1669
|
+
const currentState = api.getState();
|
|
1670
|
+
const listenerEntries = Array.from(listenerMap.values());
|
|
1671
|
+
for (const entry of listenerEntries) {
|
|
1672
|
+
let runListener = false;
|
|
1673
|
+
try {
|
|
1674
|
+
runListener = entry.predicate(action, currentState, originalState);
|
|
1675
|
+
} catch (predicateError) {
|
|
1676
|
+
runListener = false;
|
|
1677
|
+
safelyNotifyError(onError, predicateError, { raisedBy: "predicate" });
|
|
1678
|
+
}
|
|
1679
|
+
if (!runListener) continue;
|
|
1680
|
+
notifyListener(entry, action, api, getOriginalState);
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
} finally {
|
|
1684
|
+
originalState = INTERNAL_NIL_TOKEN;
|
|
1685
|
+
}
|
|
1686
|
+
return result;
|
|
1687
|
+
};
|
|
1688
|
+
return {
|
|
1689
|
+
middleware,
|
|
1690
|
+
startListening,
|
|
1691
|
+
stopListening,
|
|
1692
|
+
clearListeners: clearListenerMiddleware
|
|
1693
|
+
};
|
|
2224
1694
|
};
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
1695
|
+
//#endregion
|
|
1696
|
+
//#region src/dynamicMiddleware/index.ts
|
|
1697
|
+
const createMiddlewareEntry = (middleware) => ({
|
|
1698
|
+
middleware,
|
|
1699
|
+
applied: /* @__PURE__ */ new Map()
|
|
2230
1700
|
});
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
1701
|
+
const matchInstance = (instanceId) => (action) => action?.meta?.instanceId === instanceId;
|
|
1702
|
+
const createDynamicMiddleware = () => {
|
|
1703
|
+
const instanceId = nanoid();
|
|
1704
|
+
const middlewareMap = /* @__PURE__ */ new Map();
|
|
1705
|
+
let middlewareVersion = 0;
|
|
1706
|
+
const withMiddleware = Object.assign(createAction("dynamicMiddleware/add", (...middlewares) => ({
|
|
1707
|
+
payload: middlewares,
|
|
1708
|
+
meta: { instanceId }
|
|
1709
|
+
})), { withTypes: () => withMiddleware });
|
|
1710
|
+
const addMiddleware = Object.assign(function addMiddleware(...middlewares) {
|
|
1711
|
+
const previousSize = middlewareMap.size;
|
|
1712
|
+
middlewares.forEach((middleware) => {
|
|
1713
|
+
getOrInsertComputed(middlewareMap, middleware, createMiddlewareEntry);
|
|
1714
|
+
});
|
|
1715
|
+
if (middlewareMap.size !== previousSize) middlewareVersion++;
|
|
1716
|
+
}, { withTypes: () => addMiddleware });
|
|
1717
|
+
const getFinalMiddleware = (api) => {
|
|
1718
|
+
const appliedMiddleware = Array.from(middlewareMap.values()).map((entry) => getOrInsertComputed(entry.applied, api, entry.middleware));
|
|
1719
|
+
return (0, redux.compose)(...appliedMiddleware);
|
|
1720
|
+
};
|
|
1721
|
+
const isWithMiddleware = isAllOf(withMiddleware, matchInstance(instanceId));
|
|
1722
|
+
const middleware = (api) => (next) => {
|
|
1723
|
+
let appliedVersion = -1;
|
|
1724
|
+
let dispatch = next;
|
|
1725
|
+
return (action) => {
|
|
1726
|
+
if (isWithMiddleware(action)) {
|
|
1727
|
+
addMiddleware(...action.payload);
|
|
1728
|
+
return api.dispatch;
|
|
1729
|
+
}
|
|
1730
|
+
if (appliedVersion !== middlewareVersion) {
|
|
1731
|
+
dispatch = getFinalMiddleware(api)(next);
|
|
1732
|
+
appliedVersion = middlewareVersion;
|
|
1733
|
+
}
|
|
1734
|
+
return dispatch(action);
|
|
1735
|
+
};
|
|
1736
|
+
};
|
|
1737
|
+
return {
|
|
1738
|
+
middleware,
|
|
1739
|
+
addMiddleware,
|
|
1740
|
+
withMiddleware,
|
|
1741
|
+
instanceId
|
|
1742
|
+
};
|
|
2268
1743
|
};
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
}
|
|
2295
|
-
}
|
|
2296
|
-
return result;
|
|
2297
|
-
}
|
|
2298
|
-
}));
|
|
2299
|
-
var original = (state) => {
|
|
2300
|
-
if (!isStateProxy(state)) {
|
|
2301
|
-
throw new Error(false ? _formatProdErrorMessage2(25) : "original must be used on state Proxy");
|
|
2302
|
-
}
|
|
2303
|
-
return state[ORIGINAL_STATE];
|
|
1744
|
+
//#endregion
|
|
1745
|
+
//#region src/combineSlices.ts
|
|
1746
|
+
const isSliceLike = (maybeSliceLike) => "reducerPath" in maybeSliceLike && typeof maybeSliceLike.reducerPath === "string";
|
|
1747
|
+
const getReducers = (slices) => slices.flatMap((sliceOrMap) => isSliceLike(sliceOrMap) ? [[sliceOrMap.reducerPath, sliceOrMap.reducer]] : Object.entries(sliceOrMap));
|
|
1748
|
+
const ORIGINAL_STATE = Symbol.for("rtk-state-proxy-original");
|
|
1749
|
+
const isStateProxy = (value) => !!value && !!value[ORIGINAL_STATE];
|
|
1750
|
+
const createStateProxy = (stateProxyMap, state, reducerMap, initialStateCache) => getOrInsertComputed(stateProxyMap, state, () => new Proxy(state, { get: (target, prop, receiver) => {
|
|
1751
|
+
if (prop === ORIGINAL_STATE) return target;
|
|
1752
|
+
const result = Reflect.get(target, prop, receiver);
|
|
1753
|
+
if (typeof result === "undefined") {
|
|
1754
|
+
const cached = initialStateCache[prop];
|
|
1755
|
+
if (typeof cached !== "undefined") return cached;
|
|
1756
|
+
const reducer = reducerMap[prop];
|
|
1757
|
+
if (reducer) {
|
|
1758
|
+
const reducerResult = reducer(void 0, { type: nanoid() });
|
|
1759
|
+
if (typeof reducerResult === "undefined") throw new Error(`The slice reducer for key "${prop.toString()}" returned undefined when called for selector(). 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.`);
|
|
1760
|
+
initialStateCache[prop] = reducerResult;
|
|
1761
|
+
return reducerResult;
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
return result;
|
|
1765
|
+
} }));
|
|
1766
|
+
const original$1 = (state) => {
|
|
1767
|
+
if (!isStateProxy(state)) throw new Error("original must be used on state Proxy");
|
|
1768
|
+
return state[ORIGINAL_STATE];
|
|
2304
1769
|
};
|
|
2305
|
-
|
|
2306
|
-
|
|
1770
|
+
const emptyObject = {};
|
|
1771
|
+
const noopReducer = (state = emptyObject) => state;
|
|
2307
1772
|
function combineSlices(...slices) {
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
};
|
|
2339
|
-
}, {
|
|
2340
|
-
original
|
|
2341
|
-
});
|
|
2342
|
-
return Object.assign(combinedReducer, {
|
|
2343
|
-
inject,
|
|
2344
|
-
selector
|
|
2345
|
-
});
|
|
1773
|
+
const stateProxyMap = /* @__PURE__ */ new WeakMap();
|
|
1774
|
+
const reducerMap = Object.fromEntries(getReducers(slices));
|
|
1775
|
+
const getReducer = () => Object.keys(reducerMap).length ? (0, redux.combineReducers)(reducerMap) : noopReducer;
|
|
1776
|
+
let reducer = getReducer();
|
|
1777
|
+
function combinedReducer(state, action) {
|
|
1778
|
+
return reducer(state, action);
|
|
1779
|
+
}
|
|
1780
|
+
combinedReducer.withLazyLoadedSlices = () => combinedReducer;
|
|
1781
|
+
const initialStateCache = {};
|
|
1782
|
+
const inject = (slice, config = {}) => {
|
|
1783
|
+
const { reducerPath, reducer: reducerToInject } = slice;
|
|
1784
|
+
const currentReducer = reducerMap[reducerPath];
|
|
1785
|
+
if (!config.overrideExisting && currentReducer && currentReducer !== reducerToInject) {
|
|
1786
|
+
if (typeof process !== "undefined" && true) console.error(`called \`inject\` to override already-existing reducer ${reducerPath} without specifying \`overrideExisting: true\``);
|
|
1787
|
+
return combinedReducer;
|
|
1788
|
+
}
|
|
1789
|
+
if (config.overrideExisting && currentReducer !== reducerToInject) delete initialStateCache[reducerPath];
|
|
1790
|
+
reducerMap[reducerPath] = reducerToInject;
|
|
1791
|
+
reducer = getReducer();
|
|
1792
|
+
return combinedReducer;
|
|
1793
|
+
};
|
|
1794
|
+
const selector = Object.assign(function makeSelector(selectorFn, selectState) {
|
|
1795
|
+
return function selector(state, ...args) {
|
|
1796
|
+
return selectorFn(createStateProxy(stateProxyMap, selectState ? selectState(state, ...args) : state, reducerMap, initialStateCache), ...args);
|
|
1797
|
+
};
|
|
1798
|
+
}, { original: original$1 });
|
|
1799
|
+
return Object.assign(combinedReducer, {
|
|
1800
|
+
inject,
|
|
1801
|
+
selector
|
|
1802
|
+
});
|
|
2346
1803
|
}
|
|
2347
|
-
|
|
2348
|
-
|
|
1804
|
+
//#endregion
|
|
1805
|
+
//#region src/formatProdErrorMessage.ts
|
|
2349
1806
|
function formatProdErrorMessage(code) {
|
|
2350
|
-
|
|
1807
|
+
return `Minified Redux Toolkit error #${code}; visit https://redux-toolkit.js.org/Errors?code=${code} for the full message or use the non-minified dev environment for full errors. `;
|
|
2351
1808
|
}
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
original,
|
|
2400
|
-
prepareAutoBatched,
|
|
2401
|
-
removeListener,
|
|
2402
|
-
unwrapResult,
|
|
2403
|
-
weakMapMemoize,
|
|
2404
|
-
...require("redux")
|
|
1809
|
+
//#endregion
|
|
1810
|
+
exports.ReducerType = ReducerType;
|
|
1811
|
+
exports.SHOULD_AUTOBATCH = SHOULD_AUTOBATCH;
|
|
1812
|
+
exports.TaskAbortError = TaskAbortError;
|
|
1813
|
+
exports.Tuple = Tuple;
|
|
1814
|
+
exports.addListener = addListener;
|
|
1815
|
+
exports.asyncThunkCreator = asyncThunkCreator;
|
|
1816
|
+
exports.autoBatchEnhancer = autoBatchEnhancer;
|
|
1817
|
+
exports.buildCreateSlice = buildCreateSlice;
|
|
1818
|
+
exports.clearAllListeners = clearAllListeners;
|
|
1819
|
+
exports.combineSlices = combineSlices;
|
|
1820
|
+
exports.configureStore = configureStore;
|
|
1821
|
+
exports.createAction = createAction;
|
|
1822
|
+
exports.createActionCreatorInvariantMiddleware = createActionCreatorInvariantMiddleware;
|
|
1823
|
+
exports.createAsyncThunk = createAsyncThunk;
|
|
1824
|
+
exports.createDraftSafeSelector = createDraftSafeSelector;
|
|
1825
|
+
exports.createDraftSafeSelectorCreator = createDraftSafeSelectorCreator;
|
|
1826
|
+
exports.createDynamicMiddleware = createDynamicMiddleware;
|
|
1827
|
+
exports.createEntityAdapter = createEntityAdapter;
|
|
1828
|
+
exports.createImmutableStateInvariantMiddleware = createImmutableStateInvariantMiddleware;
|
|
1829
|
+
exports.createListenerMiddleware = createListenerMiddleware;
|
|
1830
|
+
Object.defineProperty(exports, "createNextState", {
|
|
1831
|
+
enumerable: true,
|
|
1832
|
+
get: function() {
|
|
1833
|
+
return immer.produce;
|
|
1834
|
+
}
|
|
1835
|
+
});
|
|
1836
|
+
exports.createReducer = createReducer;
|
|
1837
|
+
Object.defineProperty(exports, "createSelector", {
|
|
1838
|
+
enumerable: true,
|
|
1839
|
+
get: function() {
|
|
1840
|
+
return reselect.createSelector;
|
|
1841
|
+
}
|
|
1842
|
+
});
|
|
1843
|
+
Object.defineProperty(exports, "createSelectorCreator", {
|
|
1844
|
+
enumerable: true,
|
|
1845
|
+
get: function() {
|
|
1846
|
+
return reselect.createSelectorCreator;
|
|
1847
|
+
}
|
|
1848
|
+
});
|
|
1849
|
+
exports.createSerializableStateInvariantMiddleware = createSerializableStateInvariantMiddleware;
|
|
1850
|
+
exports.createSlice = createSlice;
|
|
1851
|
+
Object.defineProperty(exports, "current", {
|
|
1852
|
+
enumerable: true,
|
|
1853
|
+
get: function() {
|
|
1854
|
+
return immer.current;
|
|
1855
|
+
}
|
|
2405
1856
|
});
|
|
1857
|
+
exports.findNonSerializableValue = findNonSerializableValue;
|
|
1858
|
+
exports.formatProdErrorMessage = formatProdErrorMessage;
|
|
1859
|
+
Object.defineProperty(exports, "freeze", {
|
|
1860
|
+
enumerable: true,
|
|
1861
|
+
get: function() {
|
|
1862
|
+
return immer.freeze;
|
|
1863
|
+
}
|
|
1864
|
+
});
|
|
1865
|
+
exports.isActionCreator = isActionCreator;
|
|
1866
|
+
exports.isAllOf = isAllOf;
|
|
1867
|
+
exports.isAnyOf = isAnyOf;
|
|
1868
|
+
exports.isAsyncThunkAction = isAsyncThunkAction;
|
|
1869
|
+
Object.defineProperty(exports, "isDraft", {
|
|
1870
|
+
enumerable: true,
|
|
1871
|
+
get: function() {
|
|
1872
|
+
return immer.isDraft;
|
|
1873
|
+
}
|
|
1874
|
+
});
|
|
1875
|
+
exports.isFluxStandardAction = isFSA;
|
|
1876
|
+
exports.isFulfilled = isFulfilled;
|
|
1877
|
+
exports.isImmutableDefault = isImmutableDefault;
|
|
1878
|
+
exports.isPending = isPending;
|
|
1879
|
+
exports.isPlain = isPlain;
|
|
1880
|
+
exports.isRejected = isRejected;
|
|
1881
|
+
exports.isRejectedWithValue = isRejectedWithValue;
|
|
1882
|
+
Object.defineProperty(exports, "lruMemoize", {
|
|
1883
|
+
enumerable: true,
|
|
1884
|
+
get: function() {
|
|
1885
|
+
return reselect.lruMemoize;
|
|
1886
|
+
}
|
|
1887
|
+
});
|
|
1888
|
+
exports.miniSerializeError = miniSerializeError;
|
|
1889
|
+
exports.nanoid = nanoid;
|
|
1890
|
+
Object.defineProperty(exports, "original", {
|
|
1891
|
+
enumerable: true,
|
|
1892
|
+
get: function() {
|
|
1893
|
+
return immer.original;
|
|
1894
|
+
}
|
|
1895
|
+
});
|
|
1896
|
+
exports.prepareAutoBatched = prepareAutoBatched;
|
|
1897
|
+
exports.removeListener = removeListener;
|
|
1898
|
+
exports.unwrapResult = unwrapResult;
|
|
1899
|
+
Object.defineProperty(exports, "weakMapMemoize", {
|
|
1900
|
+
enumerable: true,
|
|
1901
|
+
get: function() {
|
|
1902
|
+
return reselect.weakMapMemoize;
|
|
1903
|
+
}
|
|
1904
|
+
});
|
|
1905
|
+
Object.keys(redux).forEach(function(k) {
|
|
1906
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
1907
|
+
enumerable: true,
|
|
1908
|
+
get: function() {
|
|
1909
|
+
return redux[k];
|
|
1910
|
+
}
|
|
1911
|
+
});
|
|
1912
|
+
});
|
|
1913
|
+
|
|
2406
1914
|
//# sourceMappingURL=redux-toolkit.development.cjs.map
|