1 line
4.0 KiB
Plaintext
1 line
4.0 KiB
Plaintext
|
|
{"version":3,"sources":["../../src/react/index.ts","../../src/dynamicMiddleware/react/index.ts"],"sourcesContent":["// This must remain here so that the `mangleErrors.cjs` build script\n// does not have to import this into each source file it rewrites.\nimport { formatProdErrorMessage } from '@reduxjs/toolkit';\nexport * from '@reduxjs/toolkit';\nexport { createDynamicMiddleware } from '../dynamicMiddleware/react';","import type { Action as ReduxAction, UnknownAction, Dispatch as ReduxDispatch, Middleware } from 'redux';\nimport type { TSHelpersExtractDispatchExtensions } from '@reduxjs/toolkit';\nimport { createDynamicMiddleware as cDM } from '@reduxjs/toolkit';\nimport type { ReactReduxContextValue } from 'react-redux';\nimport { ReactReduxContext, useDispatch as useDefaultDispatch, createDispatchHook } from 'react-redux';\nimport type { Context } from 'react';\nimport type { DynamicMiddlewareInstance, GetDispatch, GetState, MiddlewareApiConfig } from '@reduxjs/toolkit';\nexport type UseDispatchWithMiddlewareHook<Middlewares extends Middleware<any, State, Dispatch>[] = [], State = any, Dispatch extends ReduxDispatch<UnknownAction> = ReduxDispatch<UnknownAction>> = () => TSHelpersExtractDispatchExtensions<Middlewares> & Dispatch;\nexport type CreateDispatchWithMiddlewareHook<State = any, Dispatch extends ReduxDispatch<UnknownAction> = ReduxDispatch<UnknownAction>> = {\n <Middlewares extends [Middleware<any, State, Dispatch>, ...Middleware<any, State, Dispatch>[]]>(...middlewares: Middlewares): UseDispatchWithMiddlewareHook<Middlewares, State, Dispatch>;\n withTypes<MiddlewareConfig extends MiddlewareApiConfig>(): CreateDispatchWithMiddlewareHook<GetState<MiddlewareConfig>, GetDispatch<MiddlewareConfig>>;\n};\ntype ActionFromDispatch<Dispatch extends ReduxDispatch<ReduxAction>> = Dispatch extends ReduxDispatch<infer Action> ? Action : never;\ninterface ReactDynamicMiddlewareInstance<State = any, Dispatch extends ReduxDispatch<UnknownAction> = ReduxDispatch<UnknownAction>> extends DynamicMiddlewareInstance<State, Dispatch> {\n createDispatchWithMiddlewareHookFactory: (context?: Context<ReactReduxContextValue<State, ActionFromDispatch<Dispatch>> | null>) => CreateDispatchWithMiddlewareHook<State, Dispatch>;\n createDispatchWithMiddlewareHook: CreateDispatchWithMiddlewareHook<State, Dispatch>;\n}\nexport const createDynamicMiddleware = <State = any, Dispatch extends ReduxDispatch<UnknownAction> = ReduxDispatch<UnknownAction>>(): ReactDynamicMiddlewareInstance<State, Dispatch> => {\n const instance = cDM<State, Dispatch>();\n\n const createDispatchWithMiddlewareHookFactory = ( // @ts-ignore\n context: Context<ReactReduxContextValue<State, ActionFromDispatch<Dispatch>> | null> = ReactReduxContext) => {\n const useDispatch = context === ReactReduxContext ? useDefaultDispatch : createDispatchHook(context);\n\n function createDispatchWithMiddlewareHook<Middlewares extends Middleware<any, State, Dispatch>[]>(...middlewares: Middlewares) {\n instance.addMiddleware(...middlewares);\n return useDispatch;\n }\n\n createDispatchWithMiddlewareHook.withTypes = () => createDispatchWithMiddlewareHook;\n\n return (createDispatchWithMiddlewareHook as CreateDispatchWithMiddlewareHook<State, Dispatch>);\n };\n\n const createDispatchWithMiddlewareHook = createDispatchWithMiddlewareHookFactory();\n return { ...instance,\n createDispatchWithMiddlewareHookFactory,\n createDispatchWithMiddlewareHook\n };\n};"],"mappings":"AAGA,WAAc,mBCDd,OAAS,2BAA2BA,MAAW,mBAE/C,OAAS,qBAAAC,EAAmB,eAAeC,EAAoB,sBAAAC,MAA0B,cAalF,IAAMC,EAA0B,IAAkJ,CACvL,IAAMC,EAAWL,EAAqB,EAEhCM,EAA0C,CAChDC,EAAuFN,IAAsB,CAC3G,IAAMO,EAAcD,IAAYN,EAAoBC,EAAqBC,EAAmBI,CAAO,EAEnG,SAASE,KAA4FC,EAA0B,CAC7H,OAAAL,EAAS,cAAc,GAAGK,CAAW,EAC9BF,CACT,CAEA,OAAAC,EAAiC,UAAY,IAAMA,EAE3CA,CACV,EAEMA,EAAmCH,EAAwC,EACjF,MAAO,CAAE,GAAGD,EACV,wCAAAC,EACA,iCAAAG,CACF,CACF","names":["cDM","ReactReduxContext","useDefaultDispatch","createDispatchHook","createDynamicMiddleware","instance","createDispatchWithMiddlewareHookFactory","context","useDispatch","createDispat
|