mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-25 15:40:06 +03:00
More changes
This commit is contained in:
parent
386d7ee786
commit
c80473329e
|
@ -37,6 +37,7 @@
|
|||
"@redux-devtools/serialize": "^0.3.0",
|
||||
"@redux-devtools/slider-monitor": "^2.0.0-8",
|
||||
"@redux-devtools/utils": "^1.0.0-6",
|
||||
"@types/jsan": "^3.1.2",
|
||||
"jsan": "^3.1.13",
|
||||
"lodash": "^4.17.21",
|
||||
"react": "^16.14.0",
|
||||
|
|
|
@ -6,6 +6,8 @@ import {
|
|||
SerializeWithImmutable,
|
||||
} from '../../browser/extension/inject/pageScript';
|
||||
import Immutable from 'immutable';
|
||||
import { LiftedState } from '@redux-devtools/instrument';
|
||||
import { Action } from 'redux';
|
||||
|
||||
function deprecate(param: string) {
|
||||
// eslint-disable-next-line no-console
|
||||
|
@ -34,7 +36,12 @@ function isSerializeWithReviver(
|
|||
return !!(serialize as SerializeWithImmutable).immutable;
|
||||
}
|
||||
|
||||
export default function importState(
|
||||
interface ParsedSerializedLiftedState {
|
||||
readonly payload: string;
|
||||
readonly preloadedState?: string;
|
||||
}
|
||||
|
||||
export default function importState<S, A extends Action<unknown>>(
|
||||
state: string | undefined,
|
||||
{ deserializeState, deserializeAction, serialize }: Config
|
||||
) {
|
||||
|
@ -57,14 +64,24 @@ export default function importState(
|
|||
}
|
||||
}
|
||||
|
||||
let preloadedState;
|
||||
let nextLiftedState = parse(state);
|
||||
if (nextLiftedState.payload) {
|
||||
if (nextLiftedState.preloadedState) {
|
||||
preloadedState = parse(nextLiftedState.preloadedState);
|
||||
}
|
||||
nextLiftedState = parse(nextLiftedState.payload);
|
||||
}
|
||||
const parsedSerializedLiftedState:
|
||||
| ParsedSerializedLiftedState
|
||||
| LiftedState<S, A, unknown> = parse(state) as
|
||||
| ParsedSerializedLiftedState
|
||||
| LiftedState<S, A, unknown>;
|
||||
let preloadedState =
|
||||
'payload' in parsedSerializedLiftedState &&
|
||||
parsedSerializedLiftedState.preloadedState
|
||||
? (parse(parsedSerializedLiftedState.preloadedState) as S)
|
||||
: undefined;
|
||||
const nextLiftedState =
|
||||
'payload' in parsedSerializedLiftedState
|
||||
? (parse(parsedSerializedLiftedState.payload) as LiftedState<
|
||||
S,
|
||||
A,
|
||||
unknown
|
||||
>)
|
||||
: parsedSerializedLiftedState;
|
||||
if (deserializeState) {
|
||||
deprecate('deserializeState');
|
||||
if (typeof nextLiftedState.computedStates !== 'undefined') {
|
||||
|
|
|
@ -275,7 +275,11 @@ function getStackTrace(
|
|||
}
|
||||
|
||||
function amendActionType<A extends Action<unknown>>(
|
||||
action: A | StructuralPerformAction<A> | string,
|
||||
action:
|
||||
| A
|
||||
| StructuralPerformAction<A>
|
||||
| StructuralPerformAction<A>[]
|
||||
| string,
|
||||
config: Config,
|
||||
toExcludeFromTrace: Function | undefined
|
||||
): StructuralPerformAction<A> {
|
||||
|
@ -494,7 +498,7 @@ const liftListener =
|
|||
type: 'DISPATCH',
|
||||
payload: {
|
||||
type: 'IMPORT_STATE',
|
||||
...importState(message.state, config),
|
||||
...importState<S, A>(message.state, config)!,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
|
@ -614,7 +618,7 @@ export function connect(preConfig: Config) {
|
|||
) => {
|
||||
const message: InitMessage<S, A> = {
|
||||
type: 'INIT',
|
||||
payload: stringify(state, config.serialize),
|
||||
payload: stringify(state, config.serialize as Serialize | undefined),
|
||||
instanceId: id,
|
||||
source,
|
||||
};
|
||||
|
|
|
@ -120,7 +120,7 @@ export interface ConfigWithExpandedMaxAge {
|
|||
readonly features?: Features;
|
||||
readonly type?: string;
|
||||
readonly getActionType?: <A extends Action<unknown>>(action: A) => A;
|
||||
readonly actionCreators: {
|
||||
readonly actionCreators?: {
|
||||
readonly [key: string]: ActionCreator<Action<unknown>>;
|
||||
};
|
||||
}
|
||||
|
@ -362,10 +362,10 @@ function __REDUX_DEVTOOLS_EXTENSION__<S, A extends Action<unknown>>(
|
|||
}
|
||||
}
|
||||
|
||||
function importPayloadFrom(state) {
|
||||
if (config.features && !config.features.import) return;
|
||||
function importPayloadFrom(state: string | undefined) {
|
||||
if (config!.features && !config!.features.import) return;
|
||||
try {
|
||||
const nextLiftedState = importState(state, config);
|
||||
const nextLiftedState = importState<S, A>(state, config!);
|
||||
if (!nextLiftedState) return;
|
||||
store.liftedStore.dispatch({ type: 'IMPORT_STATE', ...nextLiftedState });
|
||||
} catch (e) {
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
"@redux-devtools/inspector-monitor": "^1.0.0",
|
||||
"@types/es6template": "^1.0.0",
|
||||
"@types/history": "^4.7.8",
|
||||
"@types/jsan": "^3.1.0",
|
||||
"@types/jsan": "^3.1.2",
|
||||
"@types/lodash.shuffle": "^4.2.6",
|
||||
"@types/object-path": "^0.11.0",
|
||||
"@types/react": "^16.14.8",
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
"jsan": "^3.1.13"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jsan": "^3.1.0",
|
||||
"@types/jsan": "^3.1.2",
|
||||
"immutable": "^4.0.0-rc.12"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
|
13
yarn.lock
13
yarn.lock
|
@ -3520,7 +3520,7 @@ __metadata:
|
|||
"@redux-devtools/inspector-monitor": ^1.0.0
|
||||
"@types/es6template": ^1.0.0
|
||||
"@types/history": ^4.7.8
|
||||
"@types/jsan": ^3.1.0
|
||||
"@types/jsan": ^3.1.2
|
||||
"@types/lodash.shuffle": ^4.2.6
|
||||
"@types/object-path": ^0.11.0
|
||||
"@types/prop-types": ^15.7.3
|
||||
|
@ -3682,7 +3682,7 @@ __metadata:
|
|||
version: 0.0.0-use.local
|
||||
resolution: "@redux-devtools/serialize@workspace:packages/redux-devtools-serialize"
|
||||
dependencies:
|
||||
"@types/jsan": ^3.1.0
|
||||
"@types/jsan": ^3.1.2
|
||||
immutable: ^4.0.0-rc.12
|
||||
jsan: ^3.1.13
|
||||
peerDependencies:
|
||||
|
@ -5246,10 +5246,10 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/jsan@npm:^3.1.0":
|
||||
version: 3.1.0
|
||||
resolution: "@types/jsan@npm:3.1.0"
|
||||
checksum: a0670d90e4bee7110504be73eefff9196b46235faf490062865136b1cbad4d3bac2adb9303e308c523f07716c026bb8e72a12ae7d47a948424d4ca4d7883587d
|
||||
"@types/jsan@npm:^3.1.2":
|
||||
version: 3.1.2
|
||||
resolution: "@types/jsan@npm:3.1.2"
|
||||
checksum: 2ff652807d6067bbc650aaefcda4e3c07b54ddfd7d72283d7c1f1892ad1e18e907b1bbdbee7d0a163efa9e8aed9af5fa9f4ed8e2f27243c46383d31e1181fc11
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
@ -23231,6 +23231,7 @@ fsevents@^1.2.7:
|
|||
"@redux-devtools/serialize": ^0.3.0
|
||||
"@redux-devtools/slider-monitor": ^2.0.0-8
|
||||
"@redux-devtools/utils": ^1.0.0-6
|
||||
"@types/jsan": ^3.1.2
|
||||
bestzip: ^2.2.0
|
||||
chromedriver: ^91.0.1
|
||||
electron: ^13.1.2
|
||||
|
|
Loading…
Reference in New Issue
Block a user