@recode-js/next-toolkit 0.0.1
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 +27 -0
- package/dist/NextToolkitProvider.d.ts +8 -0
- package/dist/NextToolkitProvider.d.ts.map +1 -0
- package/dist/NextToolkitProvider.js +12 -0
- package/dist/NextToolkitProvider.js.map +1 -0
- package/dist/_virtual/_commonjsHelpers.js +6 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/browser.js +4 -0
- package/dist/_virtual/browser.js.map +1 -0
- package/dist/_virtual/index.js +4 -0
- package/dist/_virtual/index.js.map +1 -0
- package/dist/_virtual/index2.js +4 -0
- package/dist/_virtual/index2.js.map +1 -0
- package/dist/_virtual/index3.js +4 -0
- package/dist/_virtual/index3.js.map +1 -0
- package/dist/_virtual/node.js +4 -0
- package/dist/_virtual/node.js.map +1 -0
- package/dist/_virtual/use-sync-external-store-with-selector.development.js +4 -0
- package/dist/_virtual/use-sync-external-store-with-selector.development.js.map +1 -0
- package/dist/_virtual/use-sync-external-store-with-selector.production.js +4 -0
- package/dist/_virtual/use-sync-external-store-with-selector.production.js.map +1 -0
- package/dist/_virtual/with-selector.js +4 -0
- package/dist/_virtual/with-selector.js.map +1 -0
- package/dist/axios/api.d.ts +16 -0
- package/dist/axios/api.d.ts.map +1 -0
- package/dist/axios/api.js +11 -0
- package/dist/axios/api.js.map +1 -0
- package/dist/components/auth/Form.d.ts +10 -0
- package/dist/components/auth/Form.d.ts.map +1 -0
- package/dist/components/auth/Form.js +49 -0
- package/dist/components/auth/Form.js.map +1 -0
- package/dist/components/auth/auth.d.ts +8 -0
- package/dist/components/auth/auth.d.ts.map +1 -0
- package/dist/components/auth/auth.js +18 -0
- package/dist/components/auth/auth.js.map +1 -0
- package/dist/components/auth/formActions.d.ts +17 -0
- package/dist/components/auth/formActions.d.ts.map +1 -0
- package/dist/components/auth/formActions.js +58 -0
- package/dist/components/auth/formActions.js.map +1 -0
- package/dist/components/auth/login/LoginPage.d.ts +7 -0
- package/dist/components/auth/login/LoginPage.d.ts.map +1 -0
- package/dist/components/auth/login/LoginPage.js +18 -0
- package/dist/components/auth/login/LoginPage.js.map +1 -0
- package/dist/components/auth/login/login.d.ts +1 -0
- package/dist/components/auth/login/login.d.ts.map +1 -0
- package/dist/components/auth/register/RegisterPage.d.ts +7 -0
- package/dist/components/auth/register/RegisterPage.d.ts.map +1 -0
- package/dist/components/auth/register/RegisterPage.js +18 -0
- package/dist/components/auth/register/RegisterPage.js.map +1 -0
- package/dist/components/auth/register/register.d.ts +1 -0
- package/dist/components/auth/register/register.d.ts.map +1 -0
- package/dist/components/auth/styles/form.module.css.js +4 -0
- package/dist/components/auth/styles/form.module.css.js.map +1 -0
- package/dist/components/common/Button.d.ts +25 -0
- package/dist/components/common/Button.d.ts.map +1 -0
- package/dist/components/common/Button.js +25 -0
- package/dist/components/common/Button.js.map +1 -0
- package/dist/components/common/styles/button.module.css.js +4 -0
- package/dist/components/common/styles/button.module.css.js.map +1 -0
- package/dist/components/navigation/NavigatorProvider.d.ts +10 -0
- package/dist/components/navigation/NavigatorProvider.d.ts.map +1 -0
- package/dist/components/navigation/NavigatorProvider.js +15 -0
- package/dist/components/navigation/NavigatorProvider.js.map +1 -0
- package/dist/components/navigation/bottom-tab/BottomTab.d.ts +12 -0
- package/dist/components/navigation/bottom-tab/BottomTab.d.ts.map +1 -0
- package/dist/components/navigation/bottom-tab/BottomTab.js +45 -0
- package/dist/components/navigation/bottom-tab/BottomTab.js.map +1 -0
- package/dist/components/navigation/bottom-tab/bottom-tab.module.css.js +4 -0
- package/dist/components/navigation/bottom-tab/bottom-tab.module.css.js.map +1 -0
- package/dist/components/navigation/drawer/Drawer.d.ts +21 -0
- package/dist/components/navigation/drawer/Drawer.d.ts.map +1 -0
- package/dist/components/navigation/drawer/Drawer.js +91 -0
- package/dist/components/navigation/drawer/Drawer.js.map +1 -0
- package/dist/components/navigation/drawer/drawer.module.css.js +4 -0
- package/dist/components/navigation/drawer/drawer.module.css.js.map +1 -0
- package/dist/components/navigation/header/Header.d.ts +7 -0
- package/dist/components/navigation/header/Header.d.ts.map +1 -0
- package/dist/components/navigation/header/Header.js +32 -0
- package/dist/components/navigation/header/Header.js.map +1 -0
- package/dist/components/navigation/header/header.module.css.js +4 -0
- package/dist/components/navigation/header/header.module.css.js.map +1 -0
- package/dist/components/navigation/navigatior-provider.module.css.js +4 -0
- package/dist/components/navigation/navigatior-provider.module.css.js.map +1 -0
- package/dist/components/toast/Toast.d.ts +9 -0
- package/dist/components/toast/Toast.d.ts.map +1 -0
- package/dist/components/toast/Toast.js +92 -0
- package/dist/components/toast/Toast.js.map +1 -0
- package/dist/components/toast/ToastExamples.d.ts +2 -0
- package/dist/components/toast/ToastExamples.d.ts.map +1 -0
- package/dist/components/toast/ToastExamples.js +74 -0
- package/dist/components/toast/ToastExamples.js.map +1 -0
- package/dist/components/toast/toast.module.css.js +4 -0
- package/dist/components/toast/toast.module.css.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/node_modules/@reduxjs/toolkit/dist/redux-toolkit.modern.js +969 -0
- package/dist/node_modules/@reduxjs/toolkit/dist/redux-toolkit.modern.js.map +1 -0
- package/dist/node_modules/axios/index.js +26 -0
- package/dist/node_modules/axios/index.js.map +1 -0
- package/dist/node_modules/axios/lib/adapters/adapters.js +129 -0
- package/dist/node_modules/axios/lib/adapters/adapters.js.map +1 -0
- package/dist/node_modules/axios/lib/adapters/fetch.js +289 -0
- package/dist/node_modules/axios/lib/adapters/fetch.js.map +1 -0
- package/dist/node_modules/axios/lib/adapters/http.js +895 -0
- package/dist/node_modules/axios/lib/adapters/http.js.map +1 -0
- package/dist/node_modules/axios/lib/adapters/xhr.js +203 -0
- package/dist/node_modules/axios/lib/adapters/xhr.js.map +1 -0
- package/dist/node_modules/axios/lib/axios.js +88 -0
- package/dist/node_modules/axios/lib/axios.js.map +1 -0
- package/dist/node_modules/axios/lib/cancel/CancelToken.js +135 -0
- package/dist/node_modules/axios/lib/cancel/CancelToken.js.map +1 -0
- package/dist/node_modules/axios/lib/cancel/CanceledError.js +25 -0
- package/dist/node_modules/axios/lib/cancel/CanceledError.js.map +1 -0
- package/dist/node_modules/axios/lib/cancel/isCancel.js +7 -0
- package/dist/node_modules/axios/lib/cancel/isCancel.js.map +1 -0
- package/dist/node_modules/axios/lib/core/Axios.js +238 -0
- package/dist/node_modules/axios/lib/core/Axios.js.map +1 -0
- package/dist/node_modules/axios/lib/core/AxiosError.js +110 -0
- package/dist/node_modules/axios/lib/core/AxiosError.js.map +1 -0
- package/dist/node_modules/axios/lib/core/AxiosHeaders.js +314 -0
- package/dist/node_modules/axios/lib/core/AxiosHeaders.js.map +1 -0
- package/dist/node_modules/axios/lib/core/InterceptorManager.js +71 -0
- package/dist/node_modules/axios/lib/core/InterceptorManager.js.map +1 -0
- package/dist/node_modules/axios/lib/core/buildFullPath.js +24 -0
- package/dist/node_modules/axios/lib/core/buildFullPath.js.map +1 -0
- package/dist/node_modules/axios/lib/core/dispatchRequest.js +83 -0
- package/dist/node_modules/axios/lib/core/dispatchRequest.js.map +1 -0
- package/dist/node_modules/axios/lib/core/mergeConfig.js +108 -0
- package/dist/node_modules/axios/lib/core/mergeConfig.js.map +1 -0
- package/dist/node_modules/axios/lib/core/settle.js +29 -0
- package/dist/node_modules/axios/lib/core/settle.js.map +1 -0
- package/dist/node_modules/axios/lib/core/transformData.js +30 -0
- package/dist/node_modules/axios/lib/core/transformData.js.map +1 -0
- package/dist/node_modules/axios/lib/defaults/index.js +161 -0
- package/dist/node_modules/axios/lib/defaults/index.js.map +1 -0
- package/dist/node_modules/axios/lib/defaults/transitional.js +9 -0
- package/dist/node_modules/axios/lib/defaults/transitional.js.map +1 -0
- package/dist/node_modules/axios/lib/env/data.js +4 -0
- package/dist/node_modules/axios/lib/env/data.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/AxiosTransformStream.js +143 -0
- package/dist/node_modules/axios/lib/helpers/AxiosTransformStream.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +58 -0
- package/dist/node_modules/axios/lib/helpers/AxiosURLSearchParams.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/HttpStatusCode.js +78 -0
- package/dist/node_modules/axios/lib/helpers/HttpStatusCode.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js +28 -0
- package/dist/node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/bind.js +16 -0
- package/dist/node_modules/axios/lib/helpers/bind.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/buildURL.js +69 -0
- package/dist/node_modules/axios/lib/helpers/buildURL.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/callbackify.js +17 -0
- package/dist/node_modules/axios/lib/helpers/callbackify.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/combineURLs.js +17 -0
- package/dist/node_modules/axios/lib/helpers/combineURLs.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/composeSignals.js +49 -0
- package/dist/node_modules/axios/lib/helpers/composeSignals.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/cookies.js +55 -0
- package/dist/node_modules/axios/lib/helpers/cookies.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +76 -0
- package/dist/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/formDataToJSON.js +95 -0
- package/dist/node_modules/axios/lib/helpers/formDataToJSON.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/formDataToStream.js +113 -0
- package/dist/node_modules/axios/lib/helpers/formDataToStream.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/fromDataURI.js +55 -0
- package/dist/node_modules/axios/lib/helpers/fromDataURI.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/isAbsoluteURL.js +17 -0
- package/dist/node_modules/axios/lib/helpers/isAbsoluteURL.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/isAxiosError.js +16 -0
- package/dist/node_modules/axios/lib/helpers/isAxiosError.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/isURLSameOrigin.js +17 -0
- package/dist/node_modules/axios/lib/helpers/isURLSameOrigin.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/parseHeaders.js +57 -0
- package/dist/node_modules/axios/lib/helpers/parseHeaders.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/parseProtocol.js +8 -0
- package/dist/node_modules/axios/lib/helpers/parseProtocol.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/progressEventReducer.js +47 -0
- package/dist/node_modules/axios/lib/helpers/progressEventReducer.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/readBlob.js +16 -0
- package/dist/node_modules/axios/lib/helpers/readBlob.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/resolveConfig.js +63 -0
- package/dist/node_modules/axios/lib/helpers/resolveConfig.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/speedometer.js +55 -0
- package/dist/node_modules/axios/lib/helpers/speedometer.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/spread.js +30 -0
- package/dist/node_modules/axios/lib/helpers/spread.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/throttle.js +45 -0
- package/dist/node_modules/axios/lib/helpers/throttle.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/toFormData.js +222 -0
- package/dist/node_modules/axios/lib/helpers/toFormData.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/toURLEncodedForm.js +21 -0
- package/dist/node_modules/axios/lib/helpers/toURLEncodedForm.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/trackStream.js +89 -0
- package/dist/node_modules/axios/lib/helpers/trackStream.js.map +1 -0
- package/dist/node_modules/axios/lib/helpers/validator.js +101 -0
- package/dist/node_modules/axios/lib/helpers/validator.js.map +1 -0
- package/dist/node_modules/axios/lib/platform/common/utils.js +46 -0
- package/dist/node_modules/axios/lib/platform/common/utils.js.map +1 -0
- package/dist/node_modules/axios/lib/platform/index.js +10 -0
- package/dist/node_modules/axios/lib/platform/index.js.map +1 -0
- package/dist/node_modules/axios/lib/platform/node/classes/FormData.js +3 -0
- package/dist/node_modules/axios/lib/platform/node/classes/FormData.js.map +1 -0
- package/dist/node_modules/axios/lib/platform/node/classes/URLSearchParams.js +7 -0
- package/dist/node_modules/axios/lib/platform/node/classes/URLSearchParams.js.map +1 -0
- package/dist/node_modules/axios/lib/platform/node/index.js +41 -0
- package/dist/node_modules/axios/lib/platform/node/index.js.map +1 -0
- package/dist/node_modules/axios/lib/utils.js +784 -0
- package/dist/node_modules/axios/lib/utils.js.map +1 -0
- package/dist/node_modules/debug/src/browser.js +287 -0
- package/dist/node_modules/debug/src/browser.js.map +1 -0
- package/dist/node_modules/debug/src/common.js +304 -0
- package/dist/node_modules/debug/src/common.js.map +1 -0
- package/dist/node_modules/debug/src/index.js +24 -0
- package/dist/node_modules/debug/src/index.js.map +1 -0
- package/dist/node_modules/debug/src/node.js +280 -0
- package/dist/node_modules/debug/src/node.js.map +1 -0
- package/dist/node_modules/follow-redirects/debug.js +20 -0
- package/dist/node_modules/follow-redirects/debug.js.map +1 -0
- package/dist/node_modules/follow-redirects/index.js +701 -0
- package/dist/node_modules/follow-redirects/index.js.map +1 -0
- package/dist/node_modules/immer/dist/immer.js +860 -0
- package/dist/node_modules/immer/dist/immer.js.map +1 -0
- package/dist/node_modules/proxy-from-env/index.js +112 -0
- package/dist/node_modules/proxy-from-env/index.js.map +1 -0
- package/dist/node_modules/react-redux/dist/react-redux.js +348 -0
- package/dist/node_modules/react-redux/dist/react-redux.js.map +1 -0
- package/dist/node_modules/redux/dist/redux.js +362 -0
- package/dist/node_modules/redux/dist/redux.js.map +1 -0
- package/dist/node_modules/redux-thunk/dist/redux-thunk.js +15 -0
- package/dist/node_modules/redux-thunk/dist/redux-thunk.js.map +1 -0
- package/dist/node_modules/reselect/dist/reselect.js +322 -0
- package/dist/node_modules/reselect/dist/reselect.js.map +1 -0
- package/dist/node_modules/server-only/index.js +5 -0
- package/dist/node_modules/server-only/index.js.map +1 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.development.js +108 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.development.js.map +1 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.production.js +96 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.production.js.map +1 -0
- package/dist/node_modules/use-sync-external-store/with-selector.js +14 -0
- package/dist/node_modules/use-sync-external-store/with-selector.js.map +1 -0
- package/dist/store/StoreProvider.d.ts +7 -0
- package/dist/store/StoreProvider.d.ts.map +1 -0
- package/dist/store/StoreProvider.js +11 -0
- package/dist/store/StoreProvider.js.map +1 -0
- package/dist/store/features/drawer/drawer.slice.d.ts +12 -0
- package/dist/store/features/drawer/drawer.slice.d.ts.map +1 -0
- package/dist/store/features/drawer/drawer.slice.js +26 -0
- package/dist/store/features/drawer/drawer.slice.js.map +1 -0
- package/dist/store/features/toast/toastSlice.d.ts +16 -0
- package/dist/store/features/toast/toastSlice.d.ts.map +1 -0
- package/dist/store/features/toast/toastSlice.js +26 -0
- package/dist/store/features/toast/toastSlice.js.map +1 -0
- package/dist/store/hooks.d.ts +10 -0
- package/dist/store/hooks.d.ts.map +1 -0
- package/dist/store/hooks.js +8 -0
- package/dist/store/hooks.js.map +1 -0
- package/dist/store/store.d.ts +16 -0
- package/dist/store/store.d.ts.map +1 -0
- package/dist/store/store.js +13 -0
- package/dist/store/store.js.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/styles.css.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,969 @@
|
|
|
1
|
+
import { isAction, isPlainObject, combineReducers, applyMiddleware, compose, createStore } from '../../../redux/dist/redux.js';
|
|
2
|
+
export { __DO_NOT_USE__ActionTypes } from '../../../redux/dist/redux.js';
|
|
3
|
+
import { produce, isDraftable, isDraft } from '../../../immer/dist/immer.js';
|
|
4
|
+
export { current, freeze } from '../../../immer/dist/immer.js';
|
|
5
|
+
import { thunk, withExtraArgument } from '../../../redux-thunk/dist/redux-thunk.js';
|
|
6
|
+
|
|
7
|
+
// src/index.ts
|
|
8
|
+
|
|
9
|
+
// src/devtoolsExtension.ts
|
|
10
|
+
var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function() {
|
|
11
|
+
if (arguments.length === 0) return void 0;
|
|
12
|
+
if (typeof arguments[0] === "object") return compose;
|
|
13
|
+
return compose.apply(null, arguments);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// src/tsHelpers.ts
|
|
17
|
+
var hasMatchFunction = (v) => {
|
|
18
|
+
return v && typeof v.match === "function";
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// src/createAction.ts
|
|
22
|
+
function createAction(type, prepareAction) {
|
|
23
|
+
function actionCreator(...args) {
|
|
24
|
+
if (prepareAction) {
|
|
25
|
+
let prepared = prepareAction(...args);
|
|
26
|
+
if (!prepared) {
|
|
27
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(0) : "prepareAction did not return an object");
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
type,
|
|
31
|
+
payload: prepared.payload,
|
|
32
|
+
..."meta" in prepared && {
|
|
33
|
+
meta: prepared.meta
|
|
34
|
+
},
|
|
35
|
+
..."error" in prepared && {
|
|
36
|
+
error: prepared.error
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
type,
|
|
42
|
+
payload: args[0]
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
actionCreator.toString = () => `${type}`;
|
|
46
|
+
actionCreator.type = type;
|
|
47
|
+
actionCreator.match = (action) => isAction(action) && action.type === type;
|
|
48
|
+
return actionCreator;
|
|
49
|
+
}
|
|
50
|
+
function isActionCreator(action) {
|
|
51
|
+
return typeof action === "function" && "type" in action && // hasMatchFunction only wants Matchers but I don't see the point in rewriting it
|
|
52
|
+
hasMatchFunction(action);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/actionCreatorInvariantMiddleware.ts
|
|
56
|
+
function getMessage(type) {
|
|
57
|
+
const splitType = type ? `${type}`.split("/") : [];
|
|
58
|
+
const actionName = splitType[splitType.length - 1] || "actionCreator";
|
|
59
|
+
return `Detected an action creator with type "${type || "unknown"}" being dispatched.
|
|
60
|
+
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.`;
|
|
61
|
+
}
|
|
62
|
+
function createActionCreatorInvariantMiddleware(options = {}) {
|
|
63
|
+
if (process.env.NODE_ENV === "production") {
|
|
64
|
+
return () => (next) => (action) => next(action);
|
|
65
|
+
}
|
|
66
|
+
const {
|
|
67
|
+
isActionCreator: isActionCreator2 = isActionCreator
|
|
68
|
+
} = options;
|
|
69
|
+
return () => (next) => (action) => {
|
|
70
|
+
if (isActionCreator2(action)) {
|
|
71
|
+
console.warn(getMessage(action.type));
|
|
72
|
+
}
|
|
73
|
+
return next(action);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// src/utils.ts
|
|
78
|
+
function getTimeMeasureUtils(maxDelay, fnName) {
|
|
79
|
+
let elapsed = 0;
|
|
80
|
+
return {
|
|
81
|
+
measureTime(fn) {
|
|
82
|
+
const started = Date.now();
|
|
83
|
+
try {
|
|
84
|
+
return fn();
|
|
85
|
+
} finally {
|
|
86
|
+
const finished = Date.now();
|
|
87
|
+
elapsed += finished - started;
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
warnIfExceeded() {
|
|
91
|
+
if (elapsed > maxDelay) {
|
|
92
|
+
console.warn(`${fnName} took ${elapsed}ms, which is more than the warning threshold of ${maxDelay}ms.
|
|
93
|
+
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.
|
|
94
|
+
It is disabled in production builds, so you don't need to worry about that.`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
var Tuple = class _Tuple extends Array {
|
|
100
|
+
constructor(...items) {
|
|
101
|
+
super(...items);
|
|
102
|
+
Object.setPrototypeOf(this, _Tuple.prototype);
|
|
103
|
+
}
|
|
104
|
+
static get [Symbol.species]() {
|
|
105
|
+
return _Tuple;
|
|
106
|
+
}
|
|
107
|
+
concat(...arr) {
|
|
108
|
+
return super.concat.apply(this, arr);
|
|
109
|
+
}
|
|
110
|
+
prepend(...arr) {
|
|
111
|
+
if (arr.length === 1 && Array.isArray(arr[0])) {
|
|
112
|
+
return new _Tuple(...arr[0].concat(this));
|
|
113
|
+
}
|
|
114
|
+
return new _Tuple(...arr.concat(this));
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
function freezeDraftable(val) {
|
|
118
|
+
return isDraftable(val) ? produce(val, () => {
|
|
119
|
+
}) : val;
|
|
120
|
+
}
|
|
121
|
+
function getOrInsertComputed(map, key, compute) {
|
|
122
|
+
if (map.has(key)) return map.get(key);
|
|
123
|
+
return map.set(key, compute(key)).get(key);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// src/immutableStateInvariantMiddleware.ts
|
|
127
|
+
function isImmutableDefault(value) {
|
|
128
|
+
return typeof value !== "object" || value == null || Object.isFrozen(value);
|
|
129
|
+
}
|
|
130
|
+
function trackForMutations(isImmutable, ignoredPaths, obj) {
|
|
131
|
+
const trackedProperties = trackProperties(isImmutable, ignoredPaths, obj);
|
|
132
|
+
return {
|
|
133
|
+
detectMutations() {
|
|
134
|
+
return detectMutations(isImmutable, ignoredPaths, trackedProperties, obj);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function trackProperties(isImmutable, ignoredPaths = [], obj, path = "", checkedObjects = /* @__PURE__ */ new Set()) {
|
|
139
|
+
const tracked = {
|
|
140
|
+
value: obj
|
|
141
|
+
};
|
|
142
|
+
if (!isImmutable(obj) && !checkedObjects.has(obj)) {
|
|
143
|
+
checkedObjects.add(obj);
|
|
144
|
+
tracked.children = {};
|
|
145
|
+
const hasIgnoredPaths = ignoredPaths.length > 0;
|
|
146
|
+
for (const key in obj) {
|
|
147
|
+
const nestedPath = path ? path + "." + key : key;
|
|
148
|
+
if (hasIgnoredPaths) {
|
|
149
|
+
const hasMatches = ignoredPaths.some((ignored) => {
|
|
150
|
+
if (ignored instanceof RegExp) {
|
|
151
|
+
return ignored.test(nestedPath);
|
|
152
|
+
}
|
|
153
|
+
return nestedPath === ignored;
|
|
154
|
+
});
|
|
155
|
+
if (hasMatches) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
tracked.children[key] = trackProperties(isImmutable, ignoredPaths, obj[key], nestedPath);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return tracked;
|
|
163
|
+
}
|
|
164
|
+
function detectMutations(isImmutable, ignoredPaths = [], trackedProperty, obj, sameParentRef = false, path = "") {
|
|
165
|
+
const prevObj = trackedProperty ? trackedProperty.value : void 0;
|
|
166
|
+
const sameRef = prevObj === obj;
|
|
167
|
+
if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
|
|
168
|
+
return {
|
|
169
|
+
wasMutated: true,
|
|
170
|
+
path
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
if (isImmutable(prevObj) || isImmutable(obj)) {
|
|
174
|
+
return {
|
|
175
|
+
wasMutated: false
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
const keysToDetect = {};
|
|
179
|
+
for (let key in trackedProperty.children) {
|
|
180
|
+
keysToDetect[key] = true;
|
|
181
|
+
}
|
|
182
|
+
for (let key in obj) {
|
|
183
|
+
keysToDetect[key] = true;
|
|
184
|
+
}
|
|
185
|
+
const hasIgnoredPaths = ignoredPaths.length > 0;
|
|
186
|
+
for (let key in keysToDetect) {
|
|
187
|
+
const nestedPath = path ? path + "." + key : key;
|
|
188
|
+
if (hasIgnoredPaths) {
|
|
189
|
+
const hasMatches = ignoredPaths.some((ignored) => {
|
|
190
|
+
if (ignored instanceof RegExp) {
|
|
191
|
+
return ignored.test(nestedPath);
|
|
192
|
+
}
|
|
193
|
+
return nestedPath === ignored;
|
|
194
|
+
});
|
|
195
|
+
if (hasMatches) {
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);
|
|
200
|
+
if (result.wasMutated) {
|
|
201
|
+
return result;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
wasMutated: false
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function createImmutableStateInvariantMiddleware(options = {}) {
|
|
209
|
+
if (process.env.NODE_ENV === "production") {
|
|
210
|
+
return () => (next) => (action) => next(action);
|
|
211
|
+
} else {
|
|
212
|
+
let stringify2 = function(obj, serializer, indent, decycler) {
|
|
213
|
+
return JSON.stringify(obj, getSerialize2(serializer, decycler), indent);
|
|
214
|
+
}, getSerialize2 = function(serializer, decycler) {
|
|
215
|
+
let stack = [], keys = [];
|
|
216
|
+
if (!decycler) decycler = function(_, value) {
|
|
217
|
+
if (stack[0] === value) return "[Circular ~]";
|
|
218
|
+
return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
|
|
219
|
+
};
|
|
220
|
+
return function(key, value) {
|
|
221
|
+
if (stack.length > 0) {
|
|
222
|
+
var thisPos = stack.indexOf(this);
|
|
223
|
+
~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
|
|
224
|
+
~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
|
|
225
|
+
if (~stack.indexOf(value)) value = decycler.call(this, key, value);
|
|
226
|
+
} else stack.push(value);
|
|
227
|
+
return serializer == null ? value : serializer.call(this, key, value);
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
let {
|
|
231
|
+
isImmutable = isImmutableDefault,
|
|
232
|
+
ignoredPaths,
|
|
233
|
+
warnAfter = 32
|
|
234
|
+
} = options;
|
|
235
|
+
const track = trackForMutations.bind(null, isImmutable, ignoredPaths);
|
|
236
|
+
return ({
|
|
237
|
+
getState
|
|
238
|
+
}) => {
|
|
239
|
+
let state = getState();
|
|
240
|
+
let tracker = track(state);
|
|
241
|
+
let result;
|
|
242
|
+
return (next) => (action) => {
|
|
243
|
+
const measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
|
|
244
|
+
measureUtils.measureTime(() => {
|
|
245
|
+
state = getState();
|
|
246
|
+
result = tracker.detectMutations();
|
|
247
|
+
tracker = track(state);
|
|
248
|
+
if (result.wasMutated) {
|
|
249
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(19) : `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)`);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
const dispatchedAction = next(action);
|
|
253
|
+
measureUtils.measureTime(() => {
|
|
254
|
+
state = getState();
|
|
255
|
+
result = tracker.detectMutations();
|
|
256
|
+
tracker = track(state);
|
|
257
|
+
if (result.wasMutated) {
|
|
258
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(20) : `A state mutation was detected inside a dispatch, in the path: ${result.path || ""}. Take a look at the reducer(s) handling the action ${stringify2(action)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`);
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
measureUtils.warnIfExceeded();
|
|
262
|
+
return dispatchedAction;
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// src/serializableStateInvariantMiddleware.ts
|
|
269
|
+
function isPlain(val) {
|
|
270
|
+
const type = typeof val;
|
|
271
|
+
return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
|
|
272
|
+
}
|
|
273
|
+
function findNonSerializableValue(value, path = "", isSerializable = isPlain, getEntries, ignoredPaths = [], cache) {
|
|
274
|
+
let foundNestedSerializable;
|
|
275
|
+
if (!isSerializable(value)) {
|
|
276
|
+
return {
|
|
277
|
+
keyPath: path || "<root>",
|
|
278
|
+
value
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
if (typeof value !== "object" || value === null) {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
if (cache?.has(value)) return false;
|
|
285
|
+
const entries = getEntries != null ? getEntries(value) : Object.entries(value);
|
|
286
|
+
const hasIgnoredPaths = ignoredPaths.length > 0;
|
|
287
|
+
for (const [key, nestedValue] of entries) {
|
|
288
|
+
const nestedPath = path ? path + "." + key : key;
|
|
289
|
+
if (hasIgnoredPaths) {
|
|
290
|
+
const hasMatches = ignoredPaths.some((ignored) => {
|
|
291
|
+
if (ignored instanceof RegExp) {
|
|
292
|
+
return ignored.test(nestedPath);
|
|
293
|
+
}
|
|
294
|
+
return nestedPath === ignored;
|
|
295
|
+
});
|
|
296
|
+
if (hasMatches) {
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
if (!isSerializable(nestedValue)) {
|
|
301
|
+
return {
|
|
302
|
+
keyPath: nestedPath,
|
|
303
|
+
value: nestedValue
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
if (typeof nestedValue === "object") {
|
|
307
|
+
foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
|
|
308
|
+
if (foundNestedSerializable) {
|
|
309
|
+
return foundNestedSerializable;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (cache && isNestedFrozen(value)) cache.add(value);
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
function isNestedFrozen(value) {
|
|
317
|
+
if (!Object.isFrozen(value)) return false;
|
|
318
|
+
for (const nestedValue of Object.values(value)) {
|
|
319
|
+
if (typeof nestedValue !== "object" || nestedValue === null) continue;
|
|
320
|
+
if (!isNestedFrozen(nestedValue)) return false;
|
|
321
|
+
}
|
|
322
|
+
return true;
|
|
323
|
+
}
|
|
324
|
+
function createSerializableStateInvariantMiddleware(options = {}) {
|
|
325
|
+
if (process.env.NODE_ENV === "production") {
|
|
326
|
+
return () => (next) => (action) => next(action);
|
|
327
|
+
} else {
|
|
328
|
+
const {
|
|
329
|
+
isSerializable = isPlain,
|
|
330
|
+
getEntries,
|
|
331
|
+
ignoredActions = [],
|
|
332
|
+
ignoredActionPaths = ["meta.arg", "meta.baseQueryMeta"],
|
|
333
|
+
ignoredPaths = [],
|
|
334
|
+
warnAfter = 32,
|
|
335
|
+
ignoreState = false,
|
|
336
|
+
ignoreActions = false,
|
|
337
|
+
disableCache = false
|
|
338
|
+
} = options;
|
|
339
|
+
const cache = !disableCache && WeakSet ? /* @__PURE__ */ new WeakSet() : void 0;
|
|
340
|
+
return (storeAPI) => (next) => (action) => {
|
|
341
|
+
if (!isAction(action)) {
|
|
342
|
+
return next(action);
|
|
343
|
+
}
|
|
344
|
+
const result = next(action);
|
|
345
|
+
const measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
|
|
346
|
+
if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
|
|
347
|
+
measureUtils.measureTime(() => {
|
|
348
|
+
const foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
|
|
349
|
+
if (foundActionNonSerializableValue) {
|
|
350
|
+
const {
|
|
351
|
+
keyPath,
|
|
352
|
+
value
|
|
353
|
+
} = foundActionNonSerializableValue;
|
|
354
|
+
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)");
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
if (!ignoreState) {
|
|
359
|
+
measureUtils.measureTime(() => {
|
|
360
|
+
const state = storeAPI.getState();
|
|
361
|
+
const foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
|
|
362
|
+
if (foundStateNonSerializableValue) {
|
|
363
|
+
const {
|
|
364
|
+
keyPath,
|
|
365
|
+
value
|
|
366
|
+
} = foundStateNonSerializableValue;
|
|
367
|
+
console.error(`A non-serializable value was detected in the state, in the path: \`${keyPath}\`. Value:`, value, `
|
|
368
|
+
Take a look at the reducer(s) handling this action type: ${action.type}.
|
|
369
|
+
(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`);
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
measureUtils.warnIfExceeded();
|
|
373
|
+
}
|
|
374
|
+
return result;
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// src/getDefaultMiddleware.ts
|
|
380
|
+
function isBoolean(x) {
|
|
381
|
+
return typeof x === "boolean";
|
|
382
|
+
}
|
|
383
|
+
var buildGetDefaultMiddleware = () => function getDefaultMiddleware(options) {
|
|
384
|
+
const {
|
|
385
|
+
thunk: thunk$1 = true,
|
|
386
|
+
immutableCheck = true,
|
|
387
|
+
serializableCheck = true,
|
|
388
|
+
actionCreatorCheck = true
|
|
389
|
+
} = options ?? {};
|
|
390
|
+
let middlewareArray = new Tuple();
|
|
391
|
+
if (thunk$1) {
|
|
392
|
+
if (isBoolean(thunk$1)) {
|
|
393
|
+
middlewareArray.push(thunk);
|
|
394
|
+
} else {
|
|
395
|
+
middlewareArray.push(withExtraArgument(thunk$1.extraArgument));
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
if (process.env.NODE_ENV !== "production") {
|
|
399
|
+
if (immutableCheck) {
|
|
400
|
+
let immutableOptions = {};
|
|
401
|
+
if (!isBoolean(immutableCheck)) {
|
|
402
|
+
immutableOptions = immutableCheck;
|
|
403
|
+
}
|
|
404
|
+
middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
|
|
405
|
+
}
|
|
406
|
+
if (serializableCheck) {
|
|
407
|
+
let serializableOptions = {};
|
|
408
|
+
if (!isBoolean(serializableCheck)) {
|
|
409
|
+
serializableOptions = serializableCheck;
|
|
410
|
+
}
|
|
411
|
+
middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
|
|
412
|
+
}
|
|
413
|
+
if (actionCreatorCheck) {
|
|
414
|
+
let actionCreatorOptions = {};
|
|
415
|
+
if (!isBoolean(actionCreatorCheck)) {
|
|
416
|
+
actionCreatorOptions = actionCreatorCheck;
|
|
417
|
+
}
|
|
418
|
+
middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return middlewareArray;
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
// src/autoBatchEnhancer.ts
|
|
425
|
+
var SHOULD_AUTOBATCH = "RTK_autoBatch";
|
|
426
|
+
var createQueueWithTimer = (timeout) => {
|
|
427
|
+
return (notify) => {
|
|
428
|
+
setTimeout(notify, timeout);
|
|
429
|
+
};
|
|
430
|
+
};
|
|
431
|
+
var autoBatchEnhancer = (options = {
|
|
432
|
+
type: "raf"
|
|
433
|
+
}) => (next) => (...args) => {
|
|
434
|
+
const store = next(...args);
|
|
435
|
+
let notifying = true;
|
|
436
|
+
let shouldNotifyAtEndOfTick = false;
|
|
437
|
+
let notificationQueued = false;
|
|
438
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
439
|
+
const queueCallback = options.type === "tick" ? queueMicrotask : options.type === "raf" ? (
|
|
440
|
+
// requestAnimationFrame won't exist in SSR environments. Fall back to a vague approximation just to keep from erroring.
|
|
441
|
+
typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame : createQueueWithTimer(10)
|
|
442
|
+
) : options.type === "callback" ? options.queueNotification : createQueueWithTimer(options.timeout);
|
|
443
|
+
const notifyListeners = () => {
|
|
444
|
+
notificationQueued = false;
|
|
445
|
+
if (shouldNotifyAtEndOfTick) {
|
|
446
|
+
shouldNotifyAtEndOfTick = false;
|
|
447
|
+
listeners.forEach((l) => l());
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
return Object.assign({}, store, {
|
|
451
|
+
// Override the base `store.subscribe` method to keep original listeners
|
|
452
|
+
// from running if we're delaying notifications
|
|
453
|
+
subscribe(listener2) {
|
|
454
|
+
const wrappedListener = () => notifying && listener2();
|
|
455
|
+
const unsubscribe = store.subscribe(wrappedListener);
|
|
456
|
+
listeners.add(listener2);
|
|
457
|
+
return () => {
|
|
458
|
+
unsubscribe();
|
|
459
|
+
listeners.delete(listener2);
|
|
460
|
+
};
|
|
461
|
+
},
|
|
462
|
+
// Override the base `store.dispatch` method so that we can check actions
|
|
463
|
+
// for the `shouldAutoBatch` flag and determine if batching is active
|
|
464
|
+
dispatch(action) {
|
|
465
|
+
try {
|
|
466
|
+
notifying = !action?.meta?.[SHOULD_AUTOBATCH];
|
|
467
|
+
shouldNotifyAtEndOfTick = !notifying;
|
|
468
|
+
if (shouldNotifyAtEndOfTick) {
|
|
469
|
+
if (!notificationQueued) {
|
|
470
|
+
notificationQueued = true;
|
|
471
|
+
queueCallback(notifyListeners);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
return store.dispatch(action);
|
|
475
|
+
} finally {
|
|
476
|
+
notifying = true;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
// src/getDefaultEnhancers.ts
|
|
483
|
+
var buildGetDefaultEnhancers = (middlewareEnhancer) => function getDefaultEnhancers(options) {
|
|
484
|
+
const {
|
|
485
|
+
autoBatch = true
|
|
486
|
+
} = options ?? {};
|
|
487
|
+
let enhancerArray = new Tuple(middlewareEnhancer);
|
|
488
|
+
if (autoBatch) {
|
|
489
|
+
enhancerArray.push(autoBatchEnhancer(typeof autoBatch === "object" ? autoBatch : void 0));
|
|
490
|
+
}
|
|
491
|
+
return enhancerArray;
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
// src/configureStore.ts
|
|
495
|
+
function configureStore(options) {
|
|
496
|
+
const getDefaultMiddleware = buildGetDefaultMiddleware();
|
|
497
|
+
const {
|
|
498
|
+
reducer = void 0,
|
|
499
|
+
middleware,
|
|
500
|
+
devTools = true,
|
|
501
|
+
duplicateMiddlewareCheck = true,
|
|
502
|
+
preloadedState = void 0,
|
|
503
|
+
enhancers = void 0
|
|
504
|
+
} = options || {};
|
|
505
|
+
let rootReducer;
|
|
506
|
+
if (typeof reducer === "function") {
|
|
507
|
+
rootReducer = reducer;
|
|
508
|
+
} else if (isPlainObject(reducer)) {
|
|
509
|
+
rootReducer = combineReducers(reducer);
|
|
510
|
+
} else {
|
|
511
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(1) : "`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");
|
|
512
|
+
}
|
|
513
|
+
if (process.env.NODE_ENV !== "production" && middleware && typeof middleware !== "function") {
|
|
514
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(2) : "`middleware` field must be a callback");
|
|
515
|
+
}
|
|
516
|
+
let finalMiddleware;
|
|
517
|
+
if (typeof middleware === "function") {
|
|
518
|
+
finalMiddleware = middleware(getDefaultMiddleware);
|
|
519
|
+
if (process.env.NODE_ENV !== "production" && !Array.isArray(finalMiddleware)) {
|
|
520
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(3) : "when using a middleware builder function, an array of middleware must be returned");
|
|
521
|
+
}
|
|
522
|
+
} else {
|
|
523
|
+
finalMiddleware = getDefaultMiddleware();
|
|
524
|
+
}
|
|
525
|
+
if (process.env.NODE_ENV !== "production" && finalMiddleware.some((item) => typeof item !== "function")) {
|
|
526
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(4) : "each middleware provided to configureStore must be a function");
|
|
527
|
+
}
|
|
528
|
+
if (process.env.NODE_ENV !== "production" && duplicateMiddlewareCheck) {
|
|
529
|
+
let middlewareReferences = /* @__PURE__ */ new Set();
|
|
530
|
+
finalMiddleware.forEach((middleware2) => {
|
|
531
|
+
if (middlewareReferences.has(middleware2)) {
|
|
532
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(42) : "Duplicate middleware references found when creating the store. Ensure that each middleware is only included once.");
|
|
533
|
+
}
|
|
534
|
+
middlewareReferences.add(middleware2);
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
let finalCompose = compose;
|
|
538
|
+
if (devTools) {
|
|
539
|
+
finalCompose = composeWithDevTools({
|
|
540
|
+
// Enable capture of stack traces for dispatched Redux actions
|
|
541
|
+
trace: process.env.NODE_ENV !== "production",
|
|
542
|
+
...typeof devTools === "object" && devTools
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
const middlewareEnhancer = applyMiddleware(...finalMiddleware);
|
|
546
|
+
const getDefaultEnhancers = buildGetDefaultEnhancers(middlewareEnhancer);
|
|
547
|
+
if (process.env.NODE_ENV !== "production" && enhancers && typeof enhancers !== "function") {
|
|
548
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(5) : "`enhancers` field must be a callback");
|
|
549
|
+
}
|
|
550
|
+
let storeEnhancers = typeof enhancers === "function" ? enhancers(getDefaultEnhancers) : getDefaultEnhancers();
|
|
551
|
+
if (process.env.NODE_ENV !== "production" && !Array.isArray(storeEnhancers)) {
|
|
552
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(6) : "`enhancers` callback must return an array");
|
|
553
|
+
}
|
|
554
|
+
if (process.env.NODE_ENV !== "production" && storeEnhancers.some((item) => typeof item !== "function")) {
|
|
555
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(7) : "each enhancer provided to configureStore must be a function");
|
|
556
|
+
}
|
|
557
|
+
if (process.env.NODE_ENV !== "production" && finalMiddleware.length && !storeEnhancers.includes(middlewareEnhancer)) {
|
|
558
|
+
console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");
|
|
559
|
+
}
|
|
560
|
+
const composedEnhancer = finalCompose(...storeEnhancers);
|
|
561
|
+
return createStore(rootReducer, preloadedState, composedEnhancer);
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// src/mapBuilders.ts
|
|
565
|
+
function executeReducerBuilderCallback(builderCallback) {
|
|
566
|
+
const actionsMap = {};
|
|
567
|
+
const actionMatchers = [];
|
|
568
|
+
let defaultCaseReducer;
|
|
569
|
+
const builder = {
|
|
570
|
+
addCase(typeOrActionCreator, reducer) {
|
|
571
|
+
if (process.env.NODE_ENV !== "production") {
|
|
572
|
+
if (actionMatchers.length > 0) {
|
|
573
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(26) : "`builder.addCase` should only be called before calling `builder.addMatcher`");
|
|
574
|
+
}
|
|
575
|
+
if (defaultCaseReducer) {
|
|
576
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(27) : "`builder.addCase` should only be called before calling `builder.addDefaultCase`");
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
|
|
580
|
+
if (!type) {
|
|
581
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(28) : "`builder.addCase` cannot be called with an empty action type");
|
|
582
|
+
}
|
|
583
|
+
if (type in actionsMap) {
|
|
584
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(29) : `\`builder.addCase\` cannot be called with two reducers for the same action type '${type}'`);
|
|
585
|
+
}
|
|
586
|
+
actionsMap[type] = reducer;
|
|
587
|
+
return builder;
|
|
588
|
+
},
|
|
589
|
+
addAsyncThunk(asyncThunk, reducers) {
|
|
590
|
+
if (process.env.NODE_ENV !== "production") {
|
|
591
|
+
if (defaultCaseReducer) {
|
|
592
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(43) : "`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`");
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
if (reducers.pending) actionsMap[asyncThunk.pending.type] = reducers.pending;
|
|
596
|
+
if (reducers.rejected) actionsMap[asyncThunk.rejected.type] = reducers.rejected;
|
|
597
|
+
if (reducers.fulfilled) actionsMap[asyncThunk.fulfilled.type] = reducers.fulfilled;
|
|
598
|
+
if (reducers.settled) actionMatchers.push({
|
|
599
|
+
matcher: asyncThunk.settled,
|
|
600
|
+
reducer: reducers.settled
|
|
601
|
+
});
|
|
602
|
+
return builder;
|
|
603
|
+
},
|
|
604
|
+
addMatcher(matcher, reducer) {
|
|
605
|
+
if (process.env.NODE_ENV !== "production") {
|
|
606
|
+
if (defaultCaseReducer) {
|
|
607
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(30) : "`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
actionMatchers.push({
|
|
611
|
+
matcher,
|
|
612
|
+
reducer
|
|
613
|
+
});
|
|
614
|
+
return builder;
|
|
615
|
+
},
|
|
616
|
+
addDefaultCase(reducer) {
|
|
617
|
+
if (process.env.NODE_ENV !== "production") {
|
|
618
|
+
if (defaultCaseReducer) {
|
|
619
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(31) : "`builder.addDefaultCase` can only be called once");
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
defaultCaseReducer = reducer;
|
|
623
|
+
return builder;
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
builderCallback(builder);
|
|
627
|
+
return [actionsMap, actionMatchers, defaultCaseReducer];
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
// src/createReducer.ts
|
|
631
|
+
function isStateFunction(x) {
|
|
632
|
+
return typeof x === "function";
|
|
633
|
+
}
|
|
634
|
+
function createReducer(initialState, mapOrBuilderCallback) {
|
|
635
|
+
if (process.env.NODE_ENV !== "production") {
|
|
636
|
+
if (typeof mapOrBuilderCallback === "object") {
|
|
637
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(8) : "The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
let [actionsMap, finalActionMatchers, finalDefaultCaseReducer] = executeReducerBuilderCallback(mapOrBuilderCallback);
|
|
641
|
+
let getInitialState;
|
|
642
|
+
if (isStateFunction(initialState)) {
|
|
643
|
+
getInitialState = () => freezeDraftable(initialState());
|
|
644
|
+
} else {
|
|
645
|
+
const frozenInitialState = freezeDraftable(initialState);
|
|
646
|
+
getInitialState = () => frozenInitialState;
|
|
647
|
+
}
|
|
648
|
+
function reducer(state = getInitialState(), action) {
|
|
649
|
+
let caseReducers = [actionsMap[action.type], ...finalActionMatchers.filter(({
|
|
650
|
+
matcher
|
|
651
|
+
}) => matcher(action)).map(({
|
|
652
|
+
reducer: reducer2
|
|
653
|
+
}) => reducer2)];
|
|
654
|
+
if (caseReducers.filter((cr) => !!cr).length === 0) {
|
|
655
|
+
caseReducers = [finalDefaultCaseReducer];
|
|
656
|
+
}
|
|
657
|
+
return caseReducers.reduce((previousState, caseReducer) => {
|
|
658
|
+
if (caseReducer) {
|
|
659
|
+
if (isDraft(previousState)) {
|
|
660
|
+
const draft = previousState;
|
|
661
|
+
const result = caseReducer(draft, action);
|
|
662
|
+
if (result === void 0) {
|
|
663
|
+
return previousState;
|
|
664
|
+
}
|
|
665
|
+
return result;
|
|
666
|
+
} else if (!isDraftable(previousState)) {
|
|
667
|
+
const result = caseReducer(previousState, action);
|
|
668
|
+
if (result === void 0) {
|
|
669
|
+
if (previousState === null) {
|
|
670
|
+
return previousState;
|
|
671
|
+
}
|
|
672
|
+
throw Error("A case reducer on a non-draftable value must not return undefined");
|
|
673
|
+
}
|
|
674
|
+
return result;
|
|
675
|
+
} else {
|
|
676
|
+
return produce(previousState, (draft) => {
|
|
677
|
+
return caseReducer(draft, action);
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
return previousState;
|
|
682
|
+
}, state);
|
|
683
|
+
}
|
|
684
|
+
reducer.getInitialState = getInitialState;
|
|
685
|
+
return reducer;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
// src/createSlice.ts
|
|
689
|
+
var asyncThunkSymbol = /* @__PURE__ */ Symbol.for("rtk-slice-createasyncthunk");
|
|
690
|
+
function getType(slice, actionKey) {
|
|
691
|
+
return `${slice}/${actionKey}`;
|
|
692
|
+
}
|
|
693
|
+
function buildCreateSlice({
|
|
694
|
+
creators
|
|
695
|
+
} = {}) {
|
|
696
|
+
const cAT = creators?.asyncThunk?.[asyncThunkSymbol];
|
|
697
|
+
return function createSlice2(options) {
|
|
698
|
+
const {
|
|
699
|
+
name,
|
|
700
|
+
reducerPath = name
|
|
701
|
+
} = options;
|
|
702
|
+
if (!name) {
|
|
703
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(11) : "`name` is a required option for createSlice");
|
|
704
|
+
}
|
|
705
|
+
if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
|
|
706
|
+
if (options.initialState === void 0) {
|
|
707
|
+
console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
const reducers = (typeof options.reducers === "function" ? options.reducers(buildReducerCreators()) : options.reducers) || {};
|
|
711
|
+
const reducerNames = Object.keys(reducers);
|
|
712
|
+
const context = {
|
|
713
|
+
sliceCaseReducersByName: {},
|
|
714
|
+
sliceCaseReducersByType: {},
|
|
715
|
+
actionCreators: {},
|
|
716
|
+
sliceMatchers: []
|
|
717
|
+
};
|
|
718
|
+
const contextMethods = {
|
|
719
|
+
addCase(typeOrActionCreator, reducer2) {
|
|
720
|
+
const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
|
|
721
|
+
if (!type) {
|
|
722
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : "`context.addCase` cannot be called with an empty action type");
|
|
723
|
+
}
|
|
724
|
+
if (type in context.sliceCaseReducersByType) {
|
|
725
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : "`context.addCase` cannot be called with two reducers for the same action type: " + type);
|
|
726
|
+
}
|
|
727
|
+
context.sliceCaseReducersByType[type] = reducer2;
|
|
728
|
+
return contextMethods;
|
|
729
|
+
},
|
|
730
|
+
addMatcher(matcher, reducer2) {
|
|
731
|
+
context.sliceMatchers.push({
|
|
732
|
+
matcher,
|
|
733
|
+
reducer: reducer2
|
|
734
|
+
});
|
|
735
|
+
return contextMethods;
|
|
736
|
+
},
|
|
737
|
+
exposeAction(name2, actionCreator) {
|
|
738
|
+
context.actionCreators[name2] = actionCreator;
|
|
739
|
+
return contextMethods;
|
|
740
|
+
},
|
|
741
|
+
exposeCaseReducer(name2, reducer2) {
|
|
742
|
+
context.sliceCaseReducersByName[name2] = reducer2;
|
|
743
|
+
return contextMethods;
|
|
744
|
+
}
|
|
745
|
+
};
|
|
746
|
+
reducerNames.forEach((reducerName) => {
|
|
747
|
+
const reducerDefinition = reducers[reducerName];
|
|
748
|
+
const reducerDetails = {
|
|
749
|
+
reducerName,
|
|
750
|
+
type: getType(name, reducerName),
|
|
751
|
+
createNotation: typeof options.reducers === "function"
|
|
752
|
+
};
|
|
753
|
+
if (isAsyncThunkSliceReducerDefinition(reducerDefinition)) {
|
|
754
|
+
handleThunkCaseReducerDefinition(reducerDetails, reducerDefinition, contextMethods, cAT);
|
|
755
|
+
} else {
|
|
756
|
+
handleNormalReducerDefinition(reducerDetails, reducerDefinition, contextMethods);
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
function buildReducer() {
|
|
760
|
+
if (process.env.NODE_ENV !== "production") {
|
|
761
|
+
if (typeof options.extraReducers === "object") {
|
|
762
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : "The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
const [extraReducers = {}, actionMatchers = [], defaultCaseReducer = void 0] = typeof options.extraReducers === "function" ? executeReducerBuilderCallback(options.extraReducers) : [options.extraReducers];
|
|
766
|
+
const finalCaseReducers = {
|
|
767
|
+
...extraReducers,
|
|
768
|
+
...context.sliceCaseReducersByType
|
|
769
|
+
};
|
|
770
|
+
return createReducer(options.initialState, (builder) => {
|
|
771
|
+
for (let key in finalCaseReducers) {
|
|
772
|
+
builder.addCase(key, finalCaseReducers[key]);
|
|
773
|
+
}
|
|
774
|
+
for (let sM of context.sliceMatchers) {
|
|
775
|
+
builder.addMatcher(sM.matcher, sM.reducer);
|
|
776
|
+
}
|
|
777
|
+
for (let m of actionMatchers) {
|
|
778
|
+
builder.addMatcher(m.matcher, m.reducer);
|
|
779
|
+
}
|
|
780
|
+
if (defaultCaseReducer) {
|
|
781
|
+
builder.addDefaultCase(defaultCaseReducer);
|
|
782
|
+
}
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
const selectSelf = (state) => state;
|
|
786
|
+
const injectedSelectorCache = /* @__PURE__ */ new Map();
|
|
787
|
+
const injectedStateCache = /* @__PURE__ */ new WeakMap();
|
|
788
|
+
let _reducer;
|
|
789
|
+
function reducer(state, action) {
|
|
790
|
+
if (!_reducer) _reducer = buildReducer();
|
|
791
|
+
return _reducer(state, action);
|
|
792
|
+
}
|
|
793
|
+
function getInitialState() {
|
|
794
|
+
if (!_reducer) _reducer = buildReducer();
|
|
795
|
+
return _reducer.getInitialState();
|
|
796
|
+
}
|
|
797
|
+
function makeSelectorProps(reducerPath2, injected = false) {
|
|
798
|
+
function selectSlice(state) {
|
|
799
|
+
let sliceState = state[reducerPath2];
|
|
800
|
+
if (typeof sliceState === "undefined") {
|
|
801
|
+
if (injected) {
|
|
802
|
+
sliceState = getOrInsertComputed(injectedStateCache, selectSlice, getInitialState);
|
|
803
|
+
} else if (process.env.NODE_ENV !== "production") {
|
|
804
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(15) : "selectSlice returned undefined for an uninjected slice reducer");
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
return sliceState;
|
|
808
|
+
}
|
|
809
|
+
function getSelectors(selectState = selectSelf) {
|
|
810
|
+
const selectorCache = getOrInsertComputed(injectedSelectorCache, injected, () => /* @__PURE__ */ new WeakMap());
|
|
811
|
+
return getOrInsertComputed(selectorCache, selectState, () => {
|
|
812
|
+
const map = {};
|
|
813
|
+
for (const [name2, selector] of Object.entries(options.selectors ?? {})) {
|
|
814
|
+
map[name2] = wrapSelector(selector, selectState, () => getOrInsertComputed(injectedStateCache, selectState, getInitialState), injected);
|
|
815
|
+
}
|
|
816
|
+
return map;
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
return {
|
|
820
|
+
reducerPath: reducerPath2,
|
|
821
|
+
getSelectors,
|
|
822
|
+
get selectors() {
|
|
823
|
+
return getSelectors(selectSlice);
|
|
824
|
+
},
|
|
825
|
+
selectSlice
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
const slice = {
|
|
829
|
+
name,
|
|
830
|
+
reducer,
|
|
831
|
+
actions: context.actionCreators,
|
|
832
|
+
caseReducers: context.sliceCaseReducersByName,
|
|
833
|
+
getInitialState,
|
|
834
|
+
...makeSelectorProps(reducerPath),
|
|
835
|
+
injectInto(injectable, {
|
|
836
|
+
reducerPath: pathOpt,
|
|
837
|
+
...config
|
|
838
|
+
} = {}) {
|
|
839
|
+
const newReducerPath = pathOpt ?? reducerPath;
|
|
840
|
+
injectable.inject({
|
|
841
|
+
reducerPath: newReducerPath,
|
|
842
|
+
reducer
|
|
843
|
+
}, config);
|
|
844
|
+
return {
|
|
845
|
+
...slice,
|
|
846
|
+
...makeSelectorProps(newReducerPath, true)
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
};
|
|
850
|
+
return slice;
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
function wrapSelector(selector, selectState, getInitialState, injected) {
|
|
854
|
+
function wrapper(rootState, ...args) {
|
|
855
|
+
let sliceState = selectState(rootState);
|
|
856
|
+
if (typeof sliceState === "undefined") {
|
|
857
|
+
if (injected) {
|
|
858
|
+
sliceState = getInitialState();
|
|
859
|
+
} else if (process.env.NODE_ENV !== "production") {
|
|
860
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(16) : "selectState returned undefined for an uninjected slice reducer");
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
return selector(sliceState, ...args);
|
|
864
|
+
}
|
|
865
|
+
wrapper.unwrapped = selector;
|
|
866
|
+
return wrapper;
|
|
867
|
+
}
|
|
868
|
+
var createSlice = /* @__PURE__ */ buildCreateSlice();
|
|
869
|
+
function buildReducerCreators() {
|
|
870
|
+
function asyncThunk(payloadCreator, config) {
|
|
871
|
+
return {
|
|
872
|
+
_reducerDefinitionType: "asyncThunk" /* asyncThunk */,
|
|
873
|
+
payloadCreator,
|
|
874
|
+
...config
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
asyncThunk.withTypes = () => asyncThunk;
|
|
878
|
+
return {
|
|
879
|
+
reducer(caseReducer) {
|
|
880
|
+
return Object.assign({
|
|
881
|
+
// hack so the wrapping function has the same name as the original
|
|
882
|
+
// we need to create a wrapper so the `reducerDefinitionType` is not assigned to the original
|
|
883
|
+
[caseReducer.name](...args) {
|
|
884
|
+
return caseReducer(...args);
|
|
885
|
+
}
|
|
886
|
+
}[caseReducer.name], {
|
|
887
|
+
_reducerDefinitionType: "reducer" /* reducer */
|
|
888
|
+
});
|
|
889
|
+
},
|
|
890
|
+
preparedReducer(prepare, reducer) {
|
|
891
|
+
return {
|
|
892
|
+
_reducerDefinitionType: "reducerWithPrepare" /* reducerWithPrepare */,
|
|
893
|
+
prepare,
|
|
894
|
+
reducer
|
|
895
|
+
};
|
|
896
|
+
},
|
|
897
|
+
asyncThunk
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
function handleNormalReducerDefinition({
|
|
901
|
+
type,
|
|
902
|
+
reducerName,
|
|
903
|
+
createNotation
|
|
904
|
+
}, maybeReducerWithPrepare, context) {
|
|
905
|
+
let caseReducer;
|
|
906
|
+
let prepareCallback;
|
|
907
|
+
if ("reducer" in maybeReducerWithPrepare) {
|
|
908
|
+
if (createNotation && !isCaseReducerWithPrepareDefinition(maybeReducerWithPrepare)) {
|
|
909
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(17) : "Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");
|
|
910
|
+
}
|
|
911
|
+
caseReducer = maybeReducerWithPrepare.reducer;
|
|
912
|
+
prepareCallback = maybeReducerWithPrepare.prepare;
|
|
913
|
+
} else {
|
|
914
|
+
caseReducer = maybeReducerWithPrepare;
|
|
915
|
+
}
|
|
916
|
+
context.addCase(type, caseReducer).exposeCaseReducer(reducerName, caseReducer).exposeAction(reducerName, prepareCallback ? createAction(type, prepareCallback) : createAction(type));
|
|
917
|
+
}
|
|
918
|
+
function isAsyncThunkSliceReducerDefinition(reducerDefinition) {
|
|
919
|
+
return reducerDefinition._reducerDefinitionType === "asyncThunk" /* asyncThunk */;
|
|
920
|
+
}
|
|
921
|
+
function isCaseReducerWithPrepareDefinition(reducerDefinition) {
|
|
922
|
+
return reducerDefinition._reducerDefinitionType === "reducerWithPrepare" /* reducerWithPrepare */;
|
|
923
|
+
}
|
|
924
|
+
function handleThunkCaseReducerDefinition({
|
|
925
|
+
type,
|
|
926
|
+
reducerName
|
|
927
|
+
}, reducerDefinition, context, cAT) {
|
|
928
|
+
if (!cAT) {
|
|
929
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(18) : "Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");
|
|
930
|
+
}
|
|
931
|
+
const {
|
|
932
|
+
payloadCreator,
|
|
933
|
+
fulfilled,
|
|
934
|
+
pending,
|
|
935
|
+
rejected,
|
|
936
|
+
settled,
|
|
937
|
+
options
|
|
938
|
+
} = reducerDefinition;
|
|
939
|
+
const thunk = cAT(type, payloadCreator, options);
|
|
940
|
+
context.exposeAction(reducerName, thunk);
|
|
941
|
+
if (fulfilled) {
|
|
942
|
+
context.addCase(thunk.fulfilled, fulfilled);
|
|
943
|
+
}
|
|
944
|
+
if (pending) {
|
|
945
|
+
context.addCase(thunk.pending, pending);
|
|
946
|
+
}
|
|
947
|
+
if (rejected) {
|
|
948
|
+
context.addCase(thunk.rejected, rejected);
|
|
949
|
+
}
|
|
950
|
+
if (settled) {
|
|
951
|
+
context.addMatcher(thunk.settled, settled);
|
|
952
|
+
}
|
|
953
|
+
context.exposeCaseReducer(reducerName, {
|
|
954
|
+
fulfilled: fulfilled || noop,
|
|
955
|
+
pending: pending || noop,
|
|
956
|
+
rejected: rejected || noop,
|
|
957
|
+
settled: settled || noop
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
function noop() {
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
// src/formatProdErrorMessage.ts
|
|
964
|
+
function formatProdErrorMessage(code) {
|
|
965
|
+
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. `;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
export { SHOULD_AUTOBATCH, Tuple, applyMiddleware, autoBatchEnhancer, buildCreateSlice, combineReducers, compose, configureStore, createAction, createActionCreatorInvariantMiddleware, createImmutableStateInvariantMiddleware, produce as createNextState, createReducer, createSerializableStateInvariantMiddleware, createSlice, createStore, findNonSerializableValue, formatProdErrorMessage, isAction, isActionCreator, isDraft, isImmutableDefault, isPlain, isPlainObject };
|
|
969
|
+
//# sourceMappingURL=redux-toolkit.modern.js.map
|