mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-11-10 19:56:54 +03:00
Remove deprecated serialization parameters (#942)
This commit is contained in:
parent
a3d70a7e04
commit
39be59eebe
|
@ -1,4 +1,3 @@
|
|||
import mapValues from 'lodash/mapValues';
|
||||
import jsan from 'jsan';
|
||||
import seralizeImmutable from '@redux-devtools/serialize/lib/immutable/serialize';
|
||||
import {
|
||||
|
@ -9,13 +8,6 @@ import Immutable from 'immutable';
|
|||
import { LiftedState } from '@redux-devtools/instrument';
|
||||
import { Action } from 'redux';
|
||||
|
||||
function deprecate(param: string) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
`\`${param}\` parameter for Redux DevTools Extension is deprecated. Use \`serialize\` parameter instead: https://github.com/zalmoxisus/redux-devtools-extension/releases/tag/v2.12.1`
|
||||
);
|
||||
}
|
||||
|
||||
interface SerializeWithRequiredImmutable extends SerializeWithImmutable {
|
||||
readonly immutable: typeof Immutable;
|
||||
}
|
||||
|
@ -43,7 +35,7 @@ interface ParsedSerializedLiftedState {
|
|||
|
||||
export default function importState<S, A extends Action<unknown>>(
|
||||
state: string | undefined,
|
||||
{ deserializeState, deserializeAction, serialize }: Config
|
||||
{ serialize }: Config
|
||||
) {
|
||||
if (!state) return undefined;
|
||||
let parse = jsan.parse;
|
||||
|
@ -82,35 +74,6 @@ export default function importState<S, A extends Action<unknown>>(
|
|||
unknown
|
||||
>)
|
||||
: parsedSerializedLiftedState;
|
||||
if (deserializeState) {
|
||||
deprecate('deserializeState');
|
||||
if (typeof nextLiftedState.computedStates !== 'undefined') {
|
||||
nextLiftedState.computedStates = nextLiftedState.computedStates.map(
|
||||
(computedState) => ({
|
||||
...computedState,
|
||||
state: deserializeState(computedState.state),
|
||||
})
|
||||
);
|
||||
}
|
||||
if (typeof nextLiftedState.committedState !== 'undefined') {
|
||||
nextLiftedState.committedState = deserializeState(
|
||||
nextLiftedState.committedState
|
||||
);
|
||||
}
|
||||
if (typeof preloadedState !== 'undefined') {
|
||||
preloadedState = deserializeState(preloadedState);
|
||||
}
|
||||
}
|
||||
if (deserializeAction) {
|
||||
deprecate('deserializeAction');
|
||||
nextLiftedState.actionsById = mapValues(
|
||||
nextLiftedState.actionsById,
|
||||
(liftedAction) => ({
|
||||
...liftedAction,
|
||||
action: deserializeAction(liftedAction.action),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return { nextLiftedState, preloadedState };
|
||||
}
|
||||
|
|
|
@ -76,10 +76,7 @@ export interface Serialize {
|
|||
readonly options?: Options | boolean;
|
||||
}
|
||||
|
||||
export function getSerializeParameter(
|
||||
config: Config,
|
||||
param?: 'serializeState' | 'serializeAction'
|
||||
) {
|
||||
export function getSerializeParameter(config: Config) {
|
||||
const serialize = config.serialize;
|
||||
if (serialize) {
|
||||
if (serialize === true) return { options: true };
|
||||
|
@ -109,16 +106,7 @@ export function getSerializeParameter(
|
|||
};
|
||||
}
|
||||
|
||||
const value = config[param!];
|
||||
if (typeof value === 'undefined') return undefined;
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
`\`${param}\` parameter for Redux DevTools Extension is deprecated. Use \`serialize\` parameter instead: https://github.com/zalmoxisus/redux-devtools-extension/releases/tag/v2.12.1`
|
||||
);
|
||||
|
||||
if (typeof value === 'boolean') return { options: value };
|
||||
if (typeof value === 'function') return { replacer: value };
|
||||
return value;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
interface InitInstancePageScriptToContentScriptMessage {
|
||||
|
|
|
@ -37,10 +37,6 @@ export default function configureStore<
|
|||
shouldStartLocked: config.shouldStartLocked,
|
||||
pauseActionType: config.pauseActionType || '@@PAUSED',
|
||||
}),
|
||||
persistState(
|
||||
getUrlParam('debug_session'),
|
||||
config.deserializeState,
|
||||
config.deserializeAction
|
||||
)
|
||||
persistState(getUrlParam('debug_session'))
|
||||
)(next);
|
||||
}
|
||||
|
|
|
@ -95,14 +95,6 @@ export interface ConfigWithExpandedMaxAge {
|
|||
readonly actionsDenylist?: string | readonly string[];
|
||||
readonly actionsAllowlist?: string | readonly string[];
|
||||
serialize?: boolean | SerializeWithImmutable;
|
||||
readonly serializeState?:
|
||||
| boolean
|
||||
| ((key: string, value: unknown) => unknown)
|
||||
| Serialize;
|
||||
readonly serializeAction?:
|
||||
| boolean
|
||||
| ((key: string, value: unknown) => unknown)
|
||||
| Serialize;
|
||||
readonly statesFilter?: <S>(state: S, index?: number) => S;
|
||||
readonly actionsFilter?: <A extends Action<unknown>>(
|
||||
action: A,
|
||||
|
@ -134,8 +126,6 @@ export interface ConfigWithExpandedMaxAge {
|
|||
readonly shouldRecordChanges?: boolean;
|
||||
readonly shouldStartLocked?: boolean;
|
||||
readonly pauseActionType?: unknown;
|
||||
readonly deserializeState?: <S>(state: S) => S;
|
||||
readonly deserializeAction?: <A extends Action<unknown>>(action: A) => A;
|
||||
name?: string;
|
||||
readonly autoPause?: boolean;
|
||||
readonly features?: Features;
|
||||
|
@ -210,8 +200,8 @@ function __REDUX_DEVTOOLS_EXTENSION__<S, A extends Action<unknown>>(
|
|||
let sendingActionId = 1;
|
||||
const instanceId = generateId(config.instanceId);
|
||||
const localFilter = getLocalFilter(config);
|
||||
const serializeState = getSerializeParameter(config, 'serializeState');
|
||||
const serializeAction = getSerializeParameter(config, 'serializeAction');
|
||||
const serializeState = getSerializeParameter(config);
|
||||
const serializeAction = getSerializeParameter(config);
|
||||
let {
|
||||
statesFilter,
|
||||
actionsFilter,
|
||||
|
|
|
@ -183,7 +183,6 @@ describe('Redux enhancer', () => {
|
|||
window.__REDUX_DEVTOOLS_EXTENSION__({
|
||||
actionsDenylist: ['SOME_ACTION'],
|
||||
statesFilter: (state) => state,
|
||||
serializeState: (key, value) => value,
|
||||
})
|
||||
);
|
||||
expect(typeof window.store).toBe('object');
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import mapValues from 'lodash/mapValues';
|
||||
import jsan from 'jsan';
|
||||
import { immutableSerialize } from '@redux-devtools/serialize';
|
||||
import { Action } from 'redux';
|
||||
|
@ -11,23 +10,11 @@ interface State {
|
|||
committedState?: unknown;
|
||||
}
|
||||
|
||||
function deprecate(param: string) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
`\`${param}\` parameter for Redux DevTools Extension is deprecated. Use \`serialize\` parameter instead:` +
|
||||
' https://github.com/zalmoxisus/redux-devtools-extension/releases/tag/v2.12.1'
|
||||
);
|
||||
}
|
||||
|
||||
export default function importState(
|
||||
state: string,
|
||||
{
|
||||
deserializeState,
|
||||
deserializeAction,
|
||||
serialize,
|
||||
}: {
|
||||
deserializeState?: (state: string) => unknown;
|
||||
deserializeAction?: (action: string) => Action<unknown>;
|
||||
serialize?: {
|
||||
immutable?: typeof Immutable;
|
||||
refs?: (new (data: any) => unknown)[] | null;
|
||||
|
@ -83,37 +70,6 @@ export default function importState(
|
|||
).payload
|
||||
) as State;
|
||||
}
|
||||
if (deserializeState) {
|
||||
deprecate('deserializeState');
|
||||
if (typeof nextLiftedState.computedStates !== 'undefined') {
|
||||
nextLiftedState.computedStates = nextLiftedState.computedStates.map(
|
||||
(computedState) => ({
|
||||
...computedState,
|
||||
state: deserializeState(computedState.state as string),
|
||||
})
|
||||
);
|
||||
}
|
||||
if (typeof nextLiftedState.committedState !== 'undefined') {
|
||||
nextLiftedState.committedState = deserializeState(
|
||||
nextLiftedState.committedState as string
|
||||
);
|
||||
}
|
||||
if (typeof preloadedState !== 'undefined') {
|
||||
preloadedState = deserializeState(
|
||||
preloadedState as unknown as string
|
||||
) as State;
|
||||
}
|
||||
}
|
||||
if (deserializeAction) {
|
||||
deprecate('deserializeAction');
|
||||
nextLiftedState.actionsById = mapValues(
|
||||
nextLiftedState.actionsById,
|
||||
(liftedAction) => ({
|
||||
...liftedAction,
|
||||
action: deserializeAction(liftedAction.action as unknown as string),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return { nextLiftedState, preloadedState };
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user