2023-01-16 16:15:34 +03:00
|
|
|
import { compose } from 'redux';
|
|
|
|
import type { StoreEnhancer } from 'redux';
|
|
|
|
import type {
|
|
|
|
Config,
|
|
|
|
EnhancerOptions,
|
|
|
|
InferComposedStoreExt,
|
|
|
|
ReduxDevtoolsExtensionCompose,
|
|
|
|
} from './index';
|
2021-11-06 17:38:27 +03:00
|
|
|
|
|
|
|
declare const process: {
|
|
|
|
env: {
|
|
|
|
NODE_ENV: string;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
function extensionComposeStub(
|
|
|
|
config: Config
|
2023-01-16 16:15:34 +03:00
|
|
|
): <StoreEnhancers extends readonly StoreEnhancer<unknown>[]>(
|
|
|
|
...funcs: StoreEnhancers
|
|
|
|
) => StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
|
|
|
function extensionComposeStub<
|
|
|
|
StoreEnhancers extends readonly StoreEnhancer<unknown>[]
|
|
|
|
>(
|
|
|
|
...funcs: StoreEnhancers
|
|
|
|
): StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
|
|
|
function extensionComposeStub(...funcs: [Config] | StoreEnhancer<unknown>[]) {
|
2021-11-06 17:38:27 +03:00
|
|
|
if (funcs.length === 0) return undefined;
|
|
|
|
if (typeof funcs[0] === 'object') return compose;
|
2023-01-16 16:15:34 +03:00
|
|
|
return compose(...(funcs as StoreEnhancer<unknown>[]));
|
2021-11-06 17:38:27 +03:00
|
|
|
}
|
|
|
|
|
2023-01-16 16:15:34 +03:00
|
|
|
export const composeWithDevTools: ReduxDevtoolsExtensionCompose =
|
2021-11-06 17:38:27 +03:00
|
|
|
process.env.NODE_ENV !== 'production' &&
|
|
|
|
typeof window !== 'undefined' &&
|
|
|
|
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
|
|
|
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
|
|
|
: extensionComposeStub;
|
|
|
|
|
|
|
|
export const devToolsEnhancer: (options?: EnhancerOptions) => StoreEnhancer =
|
|
|
|
process.env.NODE_ENV !== 'production' &&
|
|
|
|
typeof window !== 'undefined' &&
|
|
|
|
window.__REDUX_DEVTOOLS_EXTENSION__
|
|
|
|
? window.__REDUX_DEVTOOLS_EXTENSION__
|
|
|
|
: function () {
|
|
|
|
return function (noop) {
|
|
|
|
return noop;
|
|
|
|
};
|
|
|
|
};
|