mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-27 00:19:55 +03:00
Fix redux-devtools-extension build
This commit is contained in:
parent
1b29f90cf2
commit
e2c1178667
|
@ -15,18 +15,16 @@ declare const process: {
|
||||||
|
|
||||||
function extensionComposeStub(
|
function extensionComposeStub(
|
||||||
config: Config,
|
config: Config,
|
||||||
): <StoreEnhancers extends readonly StoreEnhancer<unknown>[]>(
|
): <StoreEnhancers extends readonly StoreEnhancer[]>(
|
||||||
...funcs: StoreEnhancers
|
...funcs: StoreEnhancers
|
||||||
) => StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
) => StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
||||||
function extensionComposeStub<
|
function extensionComposeStub<StoreEnhancers extends readonly StoreEnhancer[]>(
|
||||||
StoreEnhancers extends readonly StoreEnhancer<unknown>[],
|
|
||||||
>(
|
|
||||||
...funcs: StoreEnhancers
|
...funcs: StoreEnhancers
|
||||||
): StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
): StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
||||||
function extensionComposeStub(...funcs: [Config] | StoreEnhancer<unknown>[]) {
|
function extensionComposeStub(...funcs: [Config] | StoreEnhancer[]) {
|
||||||
if (funcs.length === 0) return undefined;
|
if (funcs.length === 0) return undefined;
|
||||||
if (typeof funcs[0] === 'object') return compose;
|
if (typeof funcs[0] === 'object') return compose;
|
||||||
return compose(...(funcs as StoreEnhancer<unknown>[]));
|
return compose(...(funcs as StoreEnhancer[]));
|
||||||
}
|
}
|
||||||
|
|
||||||
export const composeWithDevTools: ReduxDevtoolsExtensionCompose =
|
export const composeWithDevTools: ReduxDevtoolsExtensionCompose =
|
||||||
|
|
|
@ -235,15 +235,16 @@ export type InferComposedStoreExt<StoreEnhancers> = StoreEnhancers extends [
|
||||||
? HeadStoreEnhancer extends StoreEnhancer<infer StoreExt>
|
? HeadStoreEnhancer extends StoreEnhancer<infer StoreExt>
|
||||||
? StoreExt & InferComposedStoreExt<RestStoreEnhancers>
|
? StoreExt & InferComposedStoreExt<RestStoreEnhancers>
|
||||||
: never
|
: never
|
||||||
: unknown;
|
: // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
||||||
|
{};
|
||||||
|
|
||||||
export interface ReduxDevtoolsExtensionCompose {
|
export interface ReduxDevtoolsExtensionCompose {
|
||||||
(
|
(
|
||||||
config: Config,
|
config: Config,
|
||||||
): <StoreEnhancers extends readonly StoreEnhancer<unknown>[]>(
|
): <StoreEnhancers extends readonly StoreEnhancer[]>(
|
||||||
...funcs: StoreEnhancers
|
...funcs: StoreEnhancers
|
||||||
) => StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
) => StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
||||||
<StoreEnhancers extends readonly StoreEnhancer<unknown>[]>(
|
<StoreEnhancers extends readonly StoreEnhancer[]>(
|
||||||
...funcs: StoreEnhancers
|
...funcs: StoreEnhancers
|
||||||
): StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
): StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
||||||
}
|
}
|
||||||
|
@ -257,18 +258,16 @@ declare global {
|
||||||
|
|
||||||
function extensionComposeStub(
|
function extensionComposeStub(
|
||||||
config: Config,
|
config: Config,
|
||||||
): <StoreEnhancers extends readonly StoreEnhancer<unknown>[]>(
|
): <StoreEnhancers extends readonly StoreEnhancer[]>(
|
||||||
...funcs: StoreEnhancers
|
...funcs: StoreEnhancers
|
||||||
) => StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
) => StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
||||||
function extensionComposeStub<
|
function extensionComposeStub<StoreEnhancers extends readonly StoreEnhancer[]>(
|
||||||
StoreEnhancers extends readonly StoreEnhancer<unknown>[],
|
|
||||||
>(
|
|
||||||
...funcs: StoreEnhancers
|
...funcs: StoreEnhancers
|
||||||
): StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
): StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
||||||
function extensionComposeStub(...funcs: [Config] | StoreEnhancer<unknown>[]) {
|
function extensionComposeStub(...funcs: [Config] | StoreEnhancer[]) {
|
||||||
if (funcs.length === 0) return undefined;
|
if (funcs.length === 0) return undefined;
|
||||||
if (typeof funcs[0] === 'object') return compose;
|
if (typeof funcs[0] === 'object') return compose;
|
||||||
return compose(...(funcs as StoreEnhancer<unknown>[]));
|
return compose(...(funcs as StoreEnhancer[]));
|
||||||
}
|
}
|
||||||
|
|
||||||
export const composeWithDevTools: ReduxDevtoolsExtensionCompose =
|
export const composeWithDevTools: ReduxDevtoolsExtensionCompose =
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
import assign from './utils/assign';
|
|
||||||
import { compose } from 'redux';
|
import { compose } from 'redux';
|
||||||
import type {
|
import type { Action, Dispatch, Reducer, StoreEnhancer } from 'redux';
|
||||||
Action,
|
|
||||||
Dispatch,
|
|
||||||
PreloadedState,
|
|
||||||
Reducer,
|
|
||||||
StoreEnhancer,
|
|
||||||
} from 'redux';
|
|
||||||
import type { Config, EnhancerOptions, InferComposedStoreExt } from './index';
|
import type { Config, EnhancerOptions, InferComposedStoreExt } from './index';
|
||||||
|
|
||||||
function enhancer(options?: EnhancerOptions): StoreEnhancer {
|
function enhancer(options?: EnhancerOptions): StoreEnhancer {
|
||||||
|
@ -17,9 +10,9 @@ function enhancer(options?: EnhancerOptions): StoreEnhancer {
|
||||||
if (config.latency === undefined) config.latency = 500;
|
if (config.latency === undefined) config.latency = 500;
|
||||||
|
|
||||||
return function (createStore) {
|
return function (createStore) {
|
||||||
return function <S, A extends Action<string>>(
|
return function <S, A extends Action<string>, PreloadedState>(
|
||||||
reducer: Reducer<S, A>,
|
reducer: Reducer<S, A, PreloadedState>,
|
||||||
preloadedState: PreloadedState<S> | undefined,
|
preloadedState?: PreloadedState | undefined,
|
||||||
) {
|
) {
|
||||||
const store = createStore(reducer, preloadedState);
|
const store = createStore(reducer, preloadedState);
|
||||||
const origDispatch = store.dispatch;
|
const origDispatch = store.dispatch;
|
||||||
|
@ -33,35 +26,32 @@ function enhancer(options?: EnhancerOptions): StoreEnhancer {
|
||||||
return r;
|
return r;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Object.assign) return Object.assign(store, { dispatch: dispatch });
|
return Object.assign(store, { dispatch: dispatch });
|
||||||
return assign(store, 'dispatch', dispatch);
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function composeWithEnhancer(config?: EnhancerOptions) {
|
function composeWithEnhancer(config?: EnhancerOptions) {
|
||||||
return function (...funcs: StoreEnhancer<unknown>[]) {
|
return function (...funcs: StoreEnhancer[]) {
|
||||||
return compose(compose(...funcs), enhancer(config));
|
return compose(compose(...funcs), enhancer(config));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function composeWithDevTools(
|
export function composeWithDevTools(
|
||||||
config: Config,
|
config: Config,
|
||||||
): <StoreEnhancers extends readonly StoreEnhancer<unknown>[]>(
|
): <StoreEnhancers extends readonly StoreEnhancer[]>(
|
||||||
...funcs: StoreEnhancers
|
...funcs: StoreEnhancers
|
||||||
) => StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
) => StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
||||||
export function composeWithDevTools<
|
export function composeWithDevTools<
|
||||||
StoreEnhancers extends readonly StoreEnhancer<unknown>[],
|
StoreEnhancers extends readonly StoreEnhancer[],
|
||||||
>(
|
>(
|
||||||
...funcs: StoreEnhancers
|
...funcs: StoreEnhancers
|
||||||
): StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
): StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
||||||
export function composeWithDevTools(
|
export function composeWithDevTools(...funcs: [Config] | StoreEnhancer[]) {
|
||||||
...funcs: [Config] | StoreEnhancer<unknown>[]
|
|
||||||
) {
|
|
||||||
if (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__) {
|
if (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__) {
|
||||||
if (funcs.length === 0) return enhancer();
|
if (funcs.length === 0) return enhancer();
|
||||||
if (typeof funcs[0] === 'object') return composeWithEnhancer(funcs[0]);
|
if (typeof funcs[0] === 'object') return composeWithEnhancer(funcs[0]);
|
||||||
return composeWithEnhancer()(...(funcs as StoreEnhancer<unknown>[]));
|
return composeWithEnhancer()(...(funcs as StoreEnhancer[]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (funcs.length === 0) return undefined;
|
if (funcs.length === 0) return undefined;
|
||||||
|
|
|
@ -16,18 +16,16 @@ declare const process: {
|
||||||
|
|
||||||
function extensionComposeStub(
|
function extensionComposeStub(
|
||||||
config: Config,
|
config: Config,
|
||||||
): <StoreEnhancers extends readonly StoreEnhancer<unknown>[]>(
|
): <StoreEnhancers extends readonly StoreEnhancer[]>(
|
||||||
...funcs: StoreEnhancers
|
...funcs: StoreEnhancers
|
||||||
) => StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
) => StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
||||||
function extensionComposeStub<
|
function extensionComposeStub<StoreEnhancers extends readonly StoreEnhancer[]>(
|
||||||
StoreEnhancers extends readonly StoreEnhancer<unknown>[],
|
|
||||||
>(
|
|
||||||
...funcs: StoreEnhancers
|
...funcs: StoreEnhancers
|
||||||
): StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
): StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
||||||
function extensionComposeStub(...funcs: [Config] | StoreEnhancer<unknown>[]) {
|
function extensionComposeStub(...funcs: [Config] | StoreEnhancer[]) {
|
||||||
if (funcs.length === 0) return undefined;
|
if (funcs.length === 0) return undefined;
|
||||||
if (typeof funcs[0] === 'object') return compose;
|
if (typeof funcs[0] === 'object') return compose;
|
||||||
return compose(...(funcs as StoreEnhancer<unknown>[]));
|
return compose(...(funcs as StoreEnhancer[]));
|
||||||
}
|
}
|
||||||
|
|
||||||
export const composeWithDevTools: ReduxDevtoolsExtensionCompose =
|
export const composeWithDevTools: ReduxDevtoolsExtensionCompose =
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
const objectKeys =
|
|
||||||
Object.keys ||
|
|
||||||
function (obj) {
|
|
||||||
const keys = [];
|
|
||||||
for (const key in obj) {
|
|
||||||
if ({}.hasOwnProperty.call(obj, key)) keys.push(key);
|
|
||||||
}
|
|
||||||
return keys;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function assign<T extends object, K extends keyof T>(
|
|
||||||
obj: T,
|
|
||||||
newKey: K,
|
|
||||||
newValue: T[K],
|
|
||||||
): T {
|
|
||||||
const keys = objectKeys(obj);
|
|
||||||
const copy: T = {} as T;
|
|
||||||
|
|
||||||
for (let i = 0, l = keys.length; i < l; i++) {
|
|
||||||
const key = keys[i];
|
|
||||||
copy[key as keyof T] = obj[key as keyof T];
|
|
||||||
}
|
|
||||||
|
|
||||||
copy[newKey] = newValue;
|
|
||||||
return copy;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user