@depup/reduxjs__toolkit 2.12.0-depup.28 → 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 +4 -4
- package/changes.json +3 -3
- 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 +17 -33
- 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,55 +1,34 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _reduxjs_toolkit = require("@reduxjs/toolkit");
|
|
3
|
+
let react_redux = require("react-redux");
|
|
4
|
+
//#region src/dynamicMiddleware/react/index.ts
|
|
5
|
+
const createDynamicMiddleware = () => {
|
|
6
|
+
const instance = (0, _reduxjs_toolkit.createDynamicMiddleware)();
|
|
7
|
+
const createDispatchWithMiddlewareHookFactory = (context = react_redux.ReactReduxContext) => {
|
|
8
|
+
const useDispatch = context === react_redux.ReactReduxContext ? react_redux.useDispatch : (0, react_redux.createDispatchHook)(context);
|
|
9
|
+
function createDispatchWithMiddlewareHook(...middlewares) {
|
|
10
|
+
instance.addMiddleware(...middlewares);
|
|
11
|
+
return useDispatch;
|
|
12
|
+
}
|
|
13
|
+
createDispatchWithMiddlewareHook.withTypes = () => createDispatchWithMiddlewareHook;
|
|
14
|
+
return createDispatchWithMiddlewareHook;
|
|
15
|
+
};
|
|
16
|
+
const createDispatchWithMiddlewareHook = createDispatchWithMiddlewareHookFactory();
|
|
17
|
+
return {
|
|
18
|
+
...instance,
|
|
19
|
+
createDispatchWithMiddlewareHookFactory,
|
|
20
|
+
createDispatchWithMiddlewareHook
|
|
21
|
+
};
|
|
9
22
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/react/index.ts
|
|
22
|
-
var react_exports = {};
|
|
23
|
-
__export(react_exports, {
|
|
24
|
-
createDynamicMiddleware: () => createDynamicMiddleware
|
|
23
|
+
//#endregion
|
|
24
|
+
exports.createDynamicMiddleware = createDynamicMiddleware;
|
|
25
|
+
Object.keys(_reduxjs_toolkit).forEach(function(k) {
|
|
26
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function() {
|
|
29
|
+
return _reduxjs_toolkit[k];
|
|
30
|
+
}
|
|
31
|
+
});
|
|
25
32
|
});
|
|
26
|
-
module.exports = __toCommonJS(react_exports);
|
|
27
|
-
__reExport(react_exports, require("@reduxjs/toolkit"), module.exports);
|
|
28
33
|
|
|
29
|
-
// src/dynamicMiddleware/react/index.ts
|
|
30
|
-
var import_toolkit = require("@reduxjs/toolkit");
|
|
31
|
-
var import_react_redux = require("react-redux");
|
|
32
|
-
var createDynamicMiddleware = () => {
|
|
33
|
-
const instance = (0, import_toolkit.createDynamicMiddleware)();
|
|
34
|
-
const createDispatchWithMiddlewareHookFactory = (context = import_react_redux.ReactReduxContext) => {
|
|
35
|
-
const useDispatch = context === import_react_redux.ReactReduxContext ? import_react_redux.useDispatch : (0, import_react_redux.createDispatchHook)(context);
|
|
36
|
-
function createDispatchWithMiddlewareHook2(...middlewares) {
|
|
37
|
-
instance.addMiddleware(...middlewares);
|
|
38
|
-
return useDispatch;
|
|
39
|
-
}
|
|
40
|
-
createDispatchWithMiddlewareHook2.withTypes = () => createDispatchWithMiddlewareHook2;
|
|
41
|
-
return createDispatchWithMiddlewareHook2;
|
|
42
|
-
};
|
|
43
|
-
const createDispatchWithMiddlewareHook = createDispatchWithMiddlewareHookFactory();
|
|
44
|
-
return {
|
|
45
|
-
...instance,
|
|
46
|
-
createDispatchWithMiddlewareHookFactory,
|
|
47
|
-
createDispatchWithMiddlewareHook
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
-
0 && (module.exports = {
|
|
52
|
-
createDynamicMiddleware,
|
|
53
|
-
...require("@reduxjs/toolkit")
|
|
54
|
-
});
|
|
55
34
|
//# sourceMappingURL=redux-toolkit-react.development.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["DynamicMiddlewareInstance","GetDispatch","GetState","MiddlewareApiConfig","TSHelpersExtractDispatchExtensions","createDynamicMiddleware","cDM","Context","ReactReduxContextValue","createDispatchHook","ReactReduxContext","useDispatch","useDefaultDispatch","Action","Dispatch","Middleware","UnknownAction","UseDispatchWithMiddlewareHook","State","DispatchType","Middlewares","CreateDispatchWithMiddlewareHook","middlewares","withTypes","MiddlewareConfig","ActionFromDispatch","ReactDynamicMiddlewareInstance","createDispatchWithMiddlewareHookFactory","context","createDispatchWithMiddlewareHook","instance","addMiddleware"],"sources":["../../../src/dynamicMiddleware/react/index.ts"],"sourcesContent":["import type {\n DynamicMiddlewareInstance,\n GetDispatch,\n GetState,\n MiddlewareApiConfig,\n TSHelpersExtractDispatchExtensions,\n} from '@reduxjs/toolkit'\nimport { createDynamicMiddleware as cDM } from '@reduxjs/toolkit'\nimport type { Context } from 'react'\nimport type { ReactReduxContextValue } from 'react-redux'\nimport {\n createDispatchHook,\n ReactReduxContext,\n useDispatch as useDefaultDispatch,\n} from 'react-redux'\nimport type { Action, Dispatch, Middleware, UnknownAction } from 'redux'\n\nexport type UseDispatchWithMiddlewareHook<\n Middlewares extends Middleware<any, State, DispatchType>[] = [],\n State = any,\n DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>,\n> = () => TSHelpersExtractDispatchExtensions<Middlewares> & DispatchType\n\nexport type CreateDispatchWithMiddlewareHook<\n State = any,\n DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>,\n> = {\n <\n Middlewares extends [\n Middleware<any, State, DispatchType>,\n ...Middleware<any, State, DispatchType>[],\n ],\n >(\n ...middlewares: Middlewares\n ): UseDispatchWithMiddlewareHook<Middlewares, State, DispatchType>\n withTypes<\n MiddlewareConfig extends MiddlewareApiConfig,\n >(): CreateDispatchWithMiddlewareHook<\n GetState<MiddlewareConfig>,\n GetDispatch<MiddlewareConfig>\n >\n}\n\ntype ActionFromDispatch<DispatchType extends Dispatch<Action>> =\n DispatchType extends Dispatch<infer Action> ? Action : never\n\ntype ReactDynamicMiddlewareInstance<\n State = any,\n DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>,\n> = DynamicMiddlewareInstance<State, DispatchType> & {\n createDispatchWithMiddlewareHookFactory: (\n context?: Context<ReactReduxContextValue<\n State,\n ActionFromDispatch<DispatchType>\n > | null>,\n ) => CreateDispatchWithMiddlewareHook<State, DispatchType>\n createDispatchWithMiddlewareHook: CreateDispatchWithMiddlewareHook<\n State,\n DispatchType\n >\n}\n\nexport const createDynamicMiddleware = <\n State = any,\n DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>,\n>(): ReactDynamicMiddlewareInstance<State, DispatchType> => {\n const instance = cDM<State, DispatchType>()\n const createDispatchWithMiddlewareHookFactory = (\n // @ts-ignore\n context: Context<ReactReduxContextValue<\n State,\n ActionFromDispatch<DispatchType>\n > | null> = ReactReduxContext,\n ) => {\n const useDispatch =\n context === ReactReduxContext\n ? useDefaultDispatch\n : createDispatchHook(context)\n function createDispatchWithMiddlewareHook<\n Middlewares extends Middleware<any, State, DispatchType>[],\n >(...middlewares: Middlewares) {\n instance.addMiddleware(...middlewares)\n return useDispatch\n }\n createDispatchWithMiddlewareHook.withTypes = () =>\n createDispatchWithMiddlewareHook\n return createDispatchWithMiddlewareHook as CreateDispatchWithMiddlewareHook<\n State,\n DispatchType\n >\n }\n\n const createDispatchWithMiddlewareHook =\n createDispatchWithMiddlewareHookFactory()\n\n return {\n ...instance,\n createDispatchWithMiddlewareHookFactory,\n createDispatchWithMiddlewareHook,\n }\n}\n"],"mappings":";;;;AA8DA,MAAaK,gCAG+C;CAC1D,MAAMyB,YAAAA,GAAWxB,iBAAAA,wBAAAA,CAAyB;CAC1C,MAAMqB,2CAEJC,UAGYlB,YAAAA,sBACT;EACH,MAAMC,cACJiB,YAAYlB,YAAAA,oBACRE,YAAAA,eAAAA,GACAH,YAAAA,mBAAAA,CAAmBmB,OAAO;EAChC,SAASC,iCAEP,GAAGP,aAA0B;GAC7BQ,SAASC,cAAc,GAAGT,WAAW;GACrC,OAAOX;EACT;EACAkB,iCAAiCN,kBAC/BM;EACF,OAAOA;CAIT;CAEA,MAAMA,mCACJF,wCAAwC;CAE1C,OAAO;EACL,GAAGG;EACHH;EACAE;CACF;AACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@reduxjs/toolkit"),t=require("react-redux");const n=()=>{let n=(0,e.createDynamicMiddleware)(),r=(e=t.ReactReduxContext)=>{let r=e===t.ReactReduxContext?t.useDispatch:(0,t.createDispatchHook)(e);function i(...e){return n.addMiddleware(...e),r}return i.withTypes=()=>i,i},i=r();return{...n,createDispatchWithMiddlewareHookFactory:r,createDispatchWithMiddlewareHook:i}};exports.createDynamicMiddleware=n,Object.keys(e).forEach(function(t){t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
|
|
2
2
|
//# sourceMappingURL=redux-toolkit-react.production.min.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["DynamicMiddlewareInstance","GetDispatch","GetState","MiddlewareApiConfig","TSHelpersExtractDispatchExtensions","createDynamicMiddleware","cDM","Context","ReactReduxContextValue","createDispatchHook","ReactReduxContext","useDispatch","useDefaultDispatch","Action","Dispatch","Middleware","UnknownAction","UseDispatchWithMiddlewareHook","State","DispatchType","Middlewares","CreateDispatchWithMiddlewareHook","middlewares","withTypes","MiddlewareConfig","ActionFromDispatch","ReactDynamicMiddlewareInstance","createDispatchWithMiddlewareHookFactory","context","createDispatchWithMiddlewareHook","instance","addMiddleware"],"sources":["../../../src/dynamicMiddleware/react/index.ts"],"sourcesContent":["import type {\n DynamicMiddlewareInstance,\n GetDispatch,\n GetState,\n MiddlewareApiConfig,\n TSHelpersExtractDispatchExtensions,\n} from '@reduxjs/toolkit'\nimport { createDynamicMiddleware as cDM } from '@reduxjs/toolkit'\nimport type { Context } from 'react'\nimport type { ReactReduxContextValue } from 'react-redux'\nimport {\n createDispatchHook,\n ReactReduxContext,\n useDispatch as useDefaultDispatch,\n} from 'react-redux'\nimport type { Action, Dispatch, Middleware, UnknownAction } from 'redux'\n\nexport type UseDispatchWithMiddlewareHook<\n Middlewares extends Middleware<any, State, DispatchType>[] = [],\n State = any,\n DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>,\n> = () => TSHelpersExtractDispatchExtensions<Middlewares> & DispatchType\n\nexport type CreateDispatchWithMiddlewareHook<\n State = any,\n DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>,\n> = {\n <\n Middlewares extends [\n Middleware<any, State, DispatchType>,\n ...Middleware<any, State, DispatchType>[],\n ],\n >(\n ...middlewares: Middlewares\n ): UseDispatchWithMiddlewareHook<Middlewares, State, DispatchType>\n withTypes<\n MiddlewareConfig extends MiddlewareApiConfig,\n >(): CreateDispatchWithMiddlewareHook<\n GetState<MiddlewareConfig>,\n GetDispatch<MiddlewareConfig>\n >\n}\n\ntype ActionFromDispatch<DispatchType extends Dispatch<Action>> =\n DispatchType extends Dispatch<infer Action> ? Action : never\n\ntype ReactDynamicMiddlewareInstance<\n State = any,\n DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>,\n> = DynamicMiddlewareInstance<State, DispatchType> & {\n createDispatchWithMiddlewareHookFactory: (\n context?: Context<ReactReduxContextValue<\n State,\n ActionFromDispatch<DispatchType>\n > | null>,\n ) => CreateDispatchWithMiddlewareHook<State, DispatchType>\n createDispatchWithMiddlewareHook: CreateDispatchWithMiddlewareHook<\n State,\n DispatchType\n >\n}\n\nexport const createDynamicMiddleware = <\n State = any,\n DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>,\n>(): ReactDynamicMiddlewareInstance<State, DispatchType> => {\n const instance = cDM<State, DispatchType>()\n const createDispatchWithMiddlewareHookFactory = (\n // @ts-ignore\n context: Context<ReactReduxContextValue<\n State,\n ActionFromDispatch<DispatchType>\n > | null> = ReactReduxContext,\n ) => {\n const useDispatch =\n context === ReactReduxContext\n ? useDefaultDispatch\n : createDispatchHook(context)\n function createDispatchWithMiddlewareHook<\n Middlewares extends Middleware<any, State, DispatchType>[],\n >(...middlewares: Middlewares) {\n instance.addMiddleware(...middlewares)\n return useDispatch\n }\n createDispatchWithMiddlewareHook.withTypes = () =>\n createDispatchWithMiddlewareHook\n return createDispatchWithMiddlewareHook as CreateDispatchWithMiddlewareHook<\n State,\n DispatchType\n >\n }\n\n const createDispatchWithMiddlewareHook =\n createDispatchWithMiddlewareHookFactory()\n\n return {\n ...instance,\n createDispatchWithMiddlewareHookFactory,\n createDispatchWithMiddlewareHook,\n }\n}\n"],"mappings":"8HA8DA,MAAaK,MAG+C,CAC1D,IAAMyB,GAAAA,EAAWxB,EAAAA,wBAAAA,CAAyB,EACpCqB,GAEJC,EAGYlB,EAAAA,oBACT,CACH,IAAMC,EACJiB,IAAYlB,EAAAA,kBACRE,EAAAA,aAAAA,EACAH,EAAAA,mBAAAA,CAAmBmB,CAAO,EAChC,SAASC,EAEP,GAAGP,EAA0B,CAE7B,OADAQ,EAASC,cAAc,GAAGT,CAAW,EAC9BX,CACT,CAGA,MAFAkB,GAAiCN,cAC/BM,EACKA,CAIT,EAEMA,EACJF,EAAwC,EAE1C,MAAO,CACL,GAAGG,EACHH,0CACAE,kCACF,CACF"}
|
package/dist/react/index.d.mts
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { DynamicMiddlewareInstance, GetDispatch, GetState, MiddlewareApiConfig, TSHelpersExtractDispatchExtensions } from "@reduxjs/toolkit";
|
|
2
|
+
import { Context } from "react";
|
|
3
|
+
import { ReactReduxContextValue } from "react-redux";
|
|
4
|
+
import { Action, Dispatch, Middleware, UnknownAction } from "redux";
|
|
5
|
+
export * from "@reduxjs/toolkit";
|
|
6
|
+
//#region src/dynamicMiddleware/react/index.d.ts
|
|
7
7
|
type UseDispatchWithMiddlewareHook<Middlewares extends Middleware<any, State, DispatchType>[] = [], State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = () => TSHelpersExtractDispatchExtensions<Middlewares> & DispatchType;
|
|
8
8
|
type CreateDispatchWithMiddlewareHook<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
...Middleware<any, State, DispatchType>[]
|
|
12
|
-
]>(...middlewares: Middlewares): UseDispatchWithMiddlewareHook<Middlewares, State, DispatchType>;
|
|
13
|
-
withTypes<MiddlewareConfig extends MiddlewareApiConfig>(): CreateDispatchWithMiddlewareHook<GetState<MiddlewareConfig>, GetDispatch<MiddlewareConfig>>;
|
|
9
|
+
<Middlewares extends [Middleware<any, State, DispatchType>, ...Middleware<any, State, DispatchType>[]]>(...middlewares: Middlewares): UseDispatchWithMiddlewareHook<Middlewares, State, DispatchType>;
|
|
10
|
+
withTypes<MiddlewareConfig extends MiddlewareApiConfig>(): CreateDispatchWithMiddlewareHook<GetState<MiddlewareConfig>, GetDispatch<MiddlewareConfig>>;
|
|
14
11
|
};
|
|
15
12
|
type ActionFromDispatch<DispatchType extends Dispatch<Action>> = DispatchType extends Dispatch<infer Action> ? Action : never;
|
|
16
13
|
type ReactDynamicMiddlewareInstance<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = DynamicMiddlewareInstance<State, DispatchType> & {
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
createDispatchWithMiddlewareHookFactory: (context?: Context<ReactReduxContextValue<State, ActionFromDispatch<DispatchType>> | null>) => CreateDispatchWithMiddlewareHook<State, DispatchType>;
|
|
15
|
+
createDispatchWithMiddlewareHook: CreateDispatchWithMiddlewareHook<State, DispatchType>;
|
|
19
16
|
};
|
|
20
17
|
declare const createDynamicMiddleware: <State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>>() => ReactDynamicMiddlewareInstance<State, DispatchType>;
|
|
21
|
-
|
|
22
|
-
export { type CreateDispatchWithMiddlewareHook, createDynamicMiddleware };
|
|
18
|
+
//#endregion
|
|
19
|
+
export { type CreateDispatchWithMiddlewareHook, createDynamicMiddleware };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { DynamicMiddlewareInstance, GetDispatch, GetState, MiddlewareApiConfig, TSHelpersExtractDispatchExtensions } from "@reduxjs/toolkit";
|
|
2
|
+
import { Context } from "react";
|
|
3
|
+
import { ReactReduxContextValue } from "react-redux";
|
|
4
|
+
import { Action, Dispatch, Middleware, UnknownAction } from "redux";
|
|
5
|
+
export * from "@reduxjs/toolkit";
|
|
6
|
+
//#region src/dynamicMiddleware/react/index.d.ts
|
|
7
7
|
type UseDispatchWithMiddlewareHook<Middlewares extends Middleware<any, State, DispatchType>[] = [], State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = () => TSHelpersExtractDispatchExtensions<Middlewares> & DispatchType;
|
|
8
8
|
type CreateDispatchWithMiddlewareHook<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
...Middleware<any, State, DispatchType>[]
|
|
12
|
-
]>(...middlewares: Middlewares): UseDispatchWithMiddlewareHook<Middlewares, State, DispatchType>;
|
|
13
|
-
withTypes<MiddlewareConfig extends MiddlewareApiConfig>(): CreateDispatchWithMiddlewareHook<GetState<MiddlewareConfig>, GetDispatch<MiddlewareConfig>>;
|
|
9
|
+
<Middlewares extends [Middleware<any, State, DispatchType>, ...Middleware<any, State, DispatchType>[]]>(...middlewares: Middlewares): UseDispatchWithMiddlewareHook<Middlewares, State, DispatchType>;
|
|
10
|
+
withTypes<MiddlewareConfig extends MiddlewareApiConfig>(): CreateDispatchWithMiddlewareHook<GetState<MiddlewareConfig>, GetDispatch<MiddlewareConfig>>;
|
|
14
11
|
};
|
|
15
12
|
type ActionFromDispatch<DispatchType extends Dispatch<Action>> = DispatchType extends Dispatch<infer Action> ? Action : never;
|
|
16
13
|
type ReactDynamicMiddlewareInstance<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = DynamicMiddlewareInstance<State, DispatchType> & {
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
createDispatchWithMiddlewareHookFactory: (context?: Context<ReactReduxContextValue<State, ActionFromDispatch<DispatchType>> | null>) => CreateDispatchWithMiddlewareHook<State, DispatchType>;
|
|
15
|
+
createDispatchWithMiddlewareHook: CreateDispatchWithMiddlewareHook<State, DispatchType>;
|
|
19
16
|
};
|
|
20
17
|
declare const createDynamicMiddleware: <State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>>() => ReactDynamicMiddlewareInstance<State, DispatchType>;
|
|
21
|
-
|
|
22
|
-
export { type CreateDispatchWithMiddlewareHook, createDynamicMiddleware };
|
|
18
|
+
//#endregion
|
|
19
|
+
export { type CreateDispatchWithMiddlewareHook, createDynamicMiddleware };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{createDynamicMiddleware as e}from"@reduxjs/toolkit";import{ReactReduxContext as t,createDispatchHook as n,useDispatch as r}from"react-redux";export*from"@reduxjs/toolkit";const i=()=>{let i=e(),a=(e=t)=>{let a=e===t?r:n(e);function o(...e){return i.addMiddleware(...e),a}return o.withTypes=()=>o,o},o=a();return{...i,createDispatchWithMiddlewareHookFactory:a,createDispatchWithMiddlewareHook:o}};export{i as createDynamicMiddleware};
|
|
2
2
|
//# sourceMappingURL=redux-toolkit-react.browser.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["DynamicMiddlewareInstance","GetDispatch","GetState","MiddlewareApiConfig","TSHelpersExtractDispatchExtensions","createDynamicMiddleware","cDM","Context","ReactReduxContextValue","createDispatchHook","ReactReduxContext","useDispatch","useDefaultDispatch","Action","Dispatch","Middleware","UnknownAction","UseDispatchWithMiddlewareHook","State","DispatchType","Middlewares","CreateDispatchWithMiddlewareHook","middlewares","withTypes","MiddlewareConfig","ActionFromDispatch","ReactDynamicMiddlewareInstance","createDispatchWithMiddlewareHookFactory","context","createDispatchWithMiddlewareHook","instance","addMiddleware"],"sources":["../../src/dynamicMiddleware/react/index.ts"],"sourcesContent":["import type {\n DynamicMiddlewareInstance,\n GetDispatch,\n GetState,\n MiddlewareApiConfig,\n TSHelpersExtractDispatchExtensions,\n} from '@reduxjs/toolkit'\nimport { createDynamicMiddleware as cDM } from '@reduxjs/toolkit'\nimport type { Context } from 'react'\nimport type { ReactReduxContextValue } from 'react-redux'\nimport {\n createDispatchHook,\n ReactReduxContext,\n useDispatch as useDefaultDispatch,\n} from 'react-redux'\nimport type { Action, Dispatch, Middleware, UnknownAction } from 'redux'\n\nexport type UseDispatchWithMiddlewareHook<\n Middlewares extends Middleware<any, State, DispatchType>[] = [],\n State = any,\n DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>,\n> = () => TSHelpersExtractDispatchExtensions<Middlewares> & DispatchType\n\nexport type CreateDispatchWithMiddlewareHook<\n State = any,\n DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>,\n> = {\n <\n Middlewares extends [\n Middleware<any, State, DispatchType>,\n ...Middleware<any, State, DispatchType>[],\n ],\n >(\n ...middlewares: Middlewares\n ): UseDispatchWithMiddlewareHook<Middlewares, State, DispatchType>\n withTypes<\n MiddlewareConfig extends MiddlewareApiConfig,\n >(): CreateDispatchWithMiddlewareHook<\n GetState<MiddlewareConfig>,\n GetDispatch<MiddlewareConfig>\n >\n}\n\ntype ActionFromDispatch<DispatchType extends Dispatch<Action>> =\n DispatchType extends Dispatch<infer Action> ? Action : never\n\ntype ReactDynamicMiddlewareInstance<\n State = any,\n DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>,\n> = DynamicMiddlewareInstance<State, DispatchType> & {\n createDispatchWithMiddlewareHookFactory: (\n context?: Context<ReactReduxContextValue<\n State,\n ActionFromDispatch<DispatchType>\n > | null>,\n ) => CreateDispatchWithMiddlewareHook<State, DispatchType>\n createDispatchWithMiddlewareHook: CreateDispatchWithMiddlewareHook<\n State,\n DispatchType\n >\n}\n\nexport const createDynamicMiddleware = <\n State = any,\n DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>,\n>(): ReactDynamicMiddlewareInstance<State, DispatchType> => {\n const instance = cDM<State, DispatchType>()\n const createDispatchWithMiddlewareHookFactory = (\n // @ts-ignore\n context: Context<ReactReduxContextValue<\n State,\n ActionFromDispatch<DispatchType>\n > | null> = ReactReduxContext,\n ) => {\n const useDispatch =\n context === ReactReduxContext\n ? useDefaultDispatch\n : createDispatchHook(context)\n function createDispatchWithMiddlewareHook<\n Middlewares extends Middleware<any, State, DispatchType>[],\n >(...middlewares: Middlewares) {\n instance.addMiddleware(...middlewares)\n return useDispatch\n }\n createDispatchWithMiddlewareHook.withTypes = () =>\n createDispatchWithMiddlewareHook\n return createDispatchWithMiddlewareHook as CreateDispatchWithMiddlewareHook<\n State,\n DispatchType\n >\n }\n\n const createDispatchWithMiddlewareHook =\n createDispatchWithMiddlewareHookFactory()\n\n return {\n ...instance,\n createDispatchWithMiddlewareHookFactory,\n createDispatchWithMiddlewareHook,\n }\n}\n"],"mappings":"kLA8DA,MAAaK,MAG+C,CAC1D,IAAMyB,EAAWxB,EAAyB,EACpCqB,GAEJC,EAGYlB,IACT,CACH,IAAMC,EACJiB,IAAYlB,EACRE,EACAH,EAAmBmB,CAAO,EAChC,SAASC,EAEP,GAAGP,EAA0B,CAE7B,OADAQ,EAASC,cAAc,GAAGT,CAAW,EAC9BX,CACT,CAGA,MAFAkB,GAAiCN,cAC/BM,EACKA,CAIT,EAEMA,EACJF,EAAwC,EAE1C,MAAO,CACL,GAAGG,EACHH,0CACAE,kCACF,CACF"}
|
|
@@ -1,47 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
|
|
21
|
-
// src/react/index.ts
|
|
1
|
+
import { createDynamicMiddleware as createDynamicMiddleware$1 } from "@reduxjs/toolkit";
|
|
2
|
+
import { ReactReduxContext, createDispatchHook, useDispatch } from "react-redux";
|
|
22
3
|
export * from "@reduxjs/toolkit";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
4
|
+
//#region \0@oxc-project+runtime@0.144.0/helpers/esm/typeof.js
|
|
5
|
+
function _typeof(o) {
|
|
6
|
+
"@babel/helpers - typeof";
|
|
7
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
8
|
+
return typeof o;
|
|
9
|
+
} : function(o) {
|
|
10
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
11
|
+
}, _typeof(o);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region \0@oxc-project+runtime@0.144.0/helpers/esm/toPrimitive.js
|
|
15
|
+
function toPrimitive(t, r) {
|
|
16
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
17
|
+
var e = t[Symbol.toPrimitive];
|
|
18
|
+
if (void 0 !== e) {
|
|
19
|
+
var i = e.call(t, r || "default");
|
|
20
|
+
if ("object" != _typeof(i)) return i;
|
|
21
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
22
|
+
}
|
|
23
|
+
return ("string" === r ? String : Number)(t);
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region \0@oxc-project+runtime@0.144.0/helpers/esm/toPropertyKey.js
|
|
27
|
+
function toPropertyKey(t) {
|
|
28
|
+
var i = toPrimitive(t, "string");
|
|
29
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region \0@oxc-project+runtime@0.144.0/helpers/esm/defineProperty.js
|
|
33
|
+
function _defineProperty(e, r, t) {
|
|
34
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
35
|
+
value: t,
|
|
36
|
+
enumerable: !0,
|
|
37
|
+
configurable: !0,
|
|
38
|
+
writable: !0
|
|
39
|
+
}) : e[r] = t, e;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region \0@oxc-project+runtime@0.144.0/helpers/esm/objectSpread2.js
|
|
43
|
+
function ownKeys(e, r) {
|
|
44
|
+
var t = Object.keys(e);
|
|
45
|
+
if (Object.getOwnPropertySymbols) {
|
|
46
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
47
|
+
r && (o = o.filter(function(r) {
|
|
48
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
49
|
+
})), t.push.apply(t, o);
|
|
50
|
+
}
|
|
51
|
+
return t;
|
|
52
|
+
}
|
|
53
|
+
function _objectSpread2(e) {
|
|
54
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
55
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
56
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
57
|
+
_defineProperty(e, r, t[r]);
|
|
58
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
59
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return e;
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/dynamicMiddleware/react/index.ts
|
|
66
|
+
const createDynamicMiddleware = () => {
|
|
67
|
+
const instance = createDynamicMiddleware$1();
|
|
68
|
+
const createDispatchWithMiddlewareHookFactory = (context = ReactReduxContext) => {
|
|
69
|
+
const useDispatch$1 = context === ReactReduxContext ? useDispatch : createDispatchHook(context);
|
|
70
|
+
function createDispatchWithMiddlewareHook(...middlewares) {
|
|
71
|
+
instance.addMiddleware(...middlewares);
|
|
72
|
+
return useDispatch$1;
|
|
73
|
+
}
|
|
74
|
+
createDispatchWithMiddlewareHook.withTypes = () => createDispatchWithMiddlewareHook;
|
|
75
|
+
return createDispatchWithMiddlewareHook;
|
|
76
|
+
};
|
|
77
|
+
const createDispatchWithMiddlewareHook = createDispatchWithMiddlewareHookFactory();
|
|
78
|
+
return _objectSpread2(_objectSpread2({}, instance), {}, {
|
|
79
|
+
createDispatchWithMiddlewareHookFactory,
|
|
80
|
+
createDispatchWithMiddlewareHook
|
|
81
|
+
});
|
|
46
82
|
};
|
|
83
|
+
//#endregion
|
|
84
|
+
export { createDynamicMiddleware };
|
|
85
|
+
|
|
47
86
|
//# sourceMappingURL=redux-toolkit-react.legacy-esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["DynamicMiddlewareInstance","GetDispatch","GetState","MiddlewareApiConfig","TSHelpersExtractDispatchExtensions","createDynamicMiddleware","cDM","Context","ReactReduxContextValue","createDispatchHook","ReactReduxContext","useDispatch","useDefaultDispatch","Action","Dispatch","Middleware","UnknownAction","UseDispatchWithMiddlewareHook","State","DispatchType","Middlewares","CreateDispatchWithMiddlewareHook","middlewares","withTypes","MiddlewareConfig","ActionFromDispatch","ReactDynamicMiddlewareInstance","createDispatchWithMiddlewareHookFactory","context","createDispatchWithMiddlewareHook","instance","addMiddleware"],"sources":["../../src/dynamicMiddleware/react/index.ts"],"sourcesContent":["import type {\n DynamicMiddlewareInstance,\n GetDispatch,\n GetState,\n MiddlewareApiConfig,\n TSHelpersExtractDispatchExtensions,\n} from '@reduxjs/toolkit'\nimport { createDynamicMiddleware as cDM } from '@reduxjs/toolkit'\nimport type { Context } from 'react'\nimport type { ReactReduxContextValue } from 'react-redux'\nimport {\n createDispatchHook,\n ReactReduxContext,\n useDispatch as useDefaultDispatch,\n} from 'react-redux'\nimport type { Action, Dispatch, Middleware, UnknownAction } from 'redux'\n\nexport type UseDispatchWithMiddlewareHook<\n Middlewares extends Middleware<any, State, DispatchType>[] = [],\n State = any,\n DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>,\n> = () => TSHelpersExtractDispatchExtensions<Middlewares> & DispatchType\n\nexport type CreateDispatchWithMiddlewareHook<\n State = any,\n DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>,\n> = {\n <\n Middlewares extends [\n Middleware<any, State, DispatchType>,\n ...Middleware<any, State, DispatchType>[],\n ],\n >(\n ...middlewares: Middlewares\n ): UseDispatchWithMiddlewareHook<Middlewares, State, DispatchType>\n withTypes<\n MiddlewareConfig extends MiddlewareApiConfig,\n >(): CreateDispatchWithMiddlewareHook<\n GetState<MiddlewareConfig>,\n GetDispatch<MiddlewareConfig>\n >\n}\n\ntype ActionFromDispatch<DispatchType extends Dispatch<Action>> =\n DispatchType extends Dispatch<infer Action> ? Action : never\n\ntype ReactDynamicMiddlewareInstance<\n State = any,\n DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>,\n> = DynamicMiddlewareInstance<State, DispatchType> & {\n createDispatchWithMiddlewareHookFactory: (\n context?: Context<ReactReduxContextValue<\n State,\n ActionFromDispatch<DispatchType>\n > | null>,\n ) => CreateDispatchWithMiddlewareHook<State, DispatchType>\n createDispatchWithMiddlewareHook: CreateDispatchWithMiddlewareHook<\n State,\n DispatchType\n >\n}\n\nexport const createDynamicMiddleware = <\n State = any,\n DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>,\n>(): ReactDynamicMiddlewareInstance<State, DispatchType> => {\n const instance = cDM<State, DispatchType>()\n const createDispatchWithMiddlewareHookFactory = (\n // @ts-ignore\n context: Context<ReactReduxContextValue<\n State,\n ActionFromDispatch<DispatchType>\n > | null> = ReactReduxContext,\n ) => {\n const useDispatch =\n context === ReactReduxContext\n ? useDefaultDispatch\n : createDispatchHook(context)\n function createDispatchWithMiddlewareHook<\n Middlewares extends Middleware<any, State, DispatchType>[],\n >(...middlewares: Middlewares) {\n instance.addMiddleware(...middlewares)\n return useDispatch\n }\n createDispatchWithMiddlewareHook.withTypes = () =>\n createDispatchWithMiddlewareHook\n return createDispatchWithMiddlewareHook as CreateDispatchWithMiddlewareHook<\n State,\n DispatchType\n >\n }\n\n const createDispatchWithMiddlewareHook =\n createDispatchWithMiddlewareHookFactory()\n\n return {\n ...instance,\n createDispatchWithMiddlewareHookFactory,\n createDispatchWithMiddlewareHook,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,MAAaK,gCAG+C;CAC1D,MAAMyB,WAAWxB,0BAAyB;CAC1C,MAAMqB,2CAEJC,UAGYlB,sBACT;EACH,MAAMC,gBACJiB,YAAYlB,oBACRE,cACAH,mBAAmBmB,OAAO;EAChC,SAASC,iCAEP,GAAGP,aAA0B;GAC7BQ,SAASC,cAAc,GAAGT,WAAW;GACrC,OAAOX;EACT;EACAkB,iCAAiCN,kBAC/BM;EACF,OAAOA;CAIT;CAEA,MAAMA,mCACJF,wCAAwC;CAE1C,OAAA,eAAA,eAAA,CAAA,GACKG,QAAAA,GAAAA,CAAAA,GAAAA;EACHH;EACAE;CACF,CAAA;AACF"}
|
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
import { createDynamicMiddleware as createDynamicMiddleware$1 } from "@reduxjs/toolkit";
|
|
2
|
+
import { ReactReduxContext, createDispatchHook, useDispatch } from "react-redux";
|
|
2
3
|
export * from "@reduxjs/toolkit";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
createDispatchWithMiddlewareHookFactory,
|
|
22
|
-
createDispatchWithMiddlewareHook
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
export {
|
|
26
|
-
createDynamicMiddleware
|
|
4
|
+
//#region src/dynamicMiddleware/react/index.ts
|
|
5
|
+
const createDynamicMiddleware = () => {
|
|
6
|
+
const instance = createDynamicMiddleware$1();
|
|
7
|
+
const createDispatchWithMiddlewareHookFactory = (context = ReactReduxContext) => {
|
|
8
|
+
const useDispatch$1 = context === ReactReduxContext ? useDispatch : createDispatchHook(context);
|
|
9
|
+
function createDispatchWithMiddlewareHook(...middlewares) {
|
|
10
|
+
instance.addMiddleware(...middlewares);
|
|
11
|
+
return useDispatch$1;
|
|
12
|
+
}
|
|
13
|
+
createDispatchWithMiddlewareHook.withTypes = () => createDispatchWithMiddlewareHook;
|
|
14
|
+
return createDispatchWithMiddlewareHook;
|
|
15
|
+
};
|
|
16
|
+
const createDispatchWithMiddlewareHook = createDispatchWithMiddlewareHookFactory();
|
|
17
|
+
return {
|
|
18
|
+
...instance,
|
|
19
|
+
createDispatchWithMiddlewareHookFactory,
|
|
20
|
+
createDispatchWithMiddlewareHook
|
|
21
|
+
};
|
|
27
22
|
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { createDynamicMiddleware };
|
|
25
|
+
|
|
28
26
|
//# sourceMappingURL=redux-toolkit-react.modern.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["DynamicMiddlewareInstance","GetDispatch","GetState","MiddlewareApiConfig","TSHelpersExtractDispatchExtensions","createDynamicMiddleware","cDM","Context","ReactReduxContextValue","createDispatchHook","ReactReduxContext","useDispatch","useDefaultDispatch","Action","Dispatch","Middleware","UnknownAction","UseDispatchWithMiddlewareHook","State","DispatchType","Middlewares","CreateDispatchWithMiddlewareHook","middlewares","withTypes","MiddlewareConfig","ActionFromDispatch","ReactDynamicMiddlewareInstance","createDispatchWithMiddlewareHookFactory","context","createDispatchWithMiddlewareHook","instance","addMiddleware"],"sources":["../../src/dynamicMiddleware/react/index.ts"],"sourcesContent":["import type {\n DynamicMiddlewareInstance,\n GetDispatch,\n GetState,\n MiddlewareApiConfig,\n TSHelpersExtractDispatchExtensions,\n} from '@reduxjs/toolkit'\nimport { createDynamicMiddleware as cDM } from '@reduxjs/toolkit'\nimport type { Context } from 'react'\nimport type { ReactReduxContextValue } from 'react-redux'\nimport {\n createDispatchHook,\n ReactReduxContext,\n useDispatch as useDefaultDispatch,\n} from 'react-redux'\nimport type { Action, Dispatch, Middleware, UnknownAction } from 'redux'\n\nexport type UseDispatchWithMiddlewareHook<\n Middlewares extends Middleware<any, State, DispatchType>[] = [],\n State = any,\n DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>,\n> = () => TSHelpersExtractDispatchExtensions<Middlewares> & DispatchType\n\nexport type CreateDispatchWithMiddlewareHook<\n State = any,\n DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>,\n> = {\n <\n Middlewares extends [\n Middleware<any, State, DispatchType>,\n ...Middleware<any, State, DispatchType>[],\n ],\n >(\n ...middlewares: Middlewares\n ): UseDispatchWithMiddlewareHook<Middlewares, State, DispatchType>\n withTypes<\n MiddlewareConfig extends MiddlewareApiConfig,\n >(): CreateDispatchWithMiddlewareHook<\n GetState<MiddlewareConfig>,\n GetDispatch<MiddlewareConfig>\n >\n}\n\ntype ActionFromDispatch<DispatchType extends Dispatch<Action>> =\n DispatchType extends Dispatch<infer Action> ? Action : never\n\ntype ReactDynamicMiddlewareInstance<\n State = any,\n DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>,\n> = DynamicMiddlewareInstance<State, DispatchType> & {\n createDispatchWithMiddlewareHookFactory: (\n context?: Context<ReactReduxContextValue<\n State,\n ActionFromDispatch<DispatchType>\n > | null>,\n ) => CreateDispatchWithMiddlewareHook<State, DispatchType>\n createDispatchWithMiddlewareHook: CreateDispatchWithMiddlewareHook<\n State,\n DispatchType\n >\n}\n\nexport const createDynamicMiddleware = <\n State = any,\n DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>,\n>(): ReactDynamicMiddlewareInstance<State, DispatchType> => {\n const instance = cDM<State, DispatchType>()\n const createDispatchWithMiddlewareHookFactory = (\n // @ts-ignore\n context: Context<ReactReduxContextValue<\n State,\n ActionFromDispatch<DispatchType>\n > | null> = ReactReduxContext,\n ) => {\n const useDispatch =\n context === ReactReduxContext\n ? useDefaultDispatch\n : createDispatchHook(context)\n function createDispatchWithMiddlewareHook<\n Middlewares extends Middleware<any, State, DispatchType>[],\n >(...middlewares: Middlewares) {\n instance.addMiddleware(...middlewares)\n return useDispatch\n }\n createDispatchWithMiddlewareHook.withTypes = () =>\n createDispatchWithMiddlewareHook\n return createDispatchWithMiddlewareHook as CreateDispatchWithMiddlewareHook<\n State,\n DispatchType\n >\n }\n\n const createDispatchWithMiddlewareHook =\n createDispatchWithMiddlewareHookFactory()\n\n return {\n ...instance,\n createDispatchWithMiddlewareHookFactory,\n createDispatchWithMiddlewareHook,\n }\n}\n"],"mappings":";;;;AA8DA,MAAaK,gCAG+C;CAC1D,MAAMyB,WAAWxB,0BAAyB;CAC1C,MAAMqB,2CAEJC,UAGYlB,sBACT;EACH,MAAMC,gBACJiB,YAAYlB,oBACRE,cACAH,mBAAmBmB,OAAO;EAChC,SAASC,iCAEP,GAAGP,aAA0B;GAC7BQ,SAASC,cAAc,GAAGT,WAAW;GACrC,OAAOX;EACT;EACAkB,iCAAiCN,kBAC/BM;EACF,OAAOA;CAIT;CAEA,MAAMA,mCACJF,wCAAwC;CAE1C,OAAO;EACL,GAAGG;EACHH;EACAE;CACF;AACF"}
|