mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-02-17 20:10:51 +03:00
* Use rollup for d3tooltip * Use rollup for map2tree * Set moduleResolution * Use rollup for d3-state-visualizer * Use rollup for react-base16-styling * Use rollup for react-dock * Use rollup for react-json-tree * Use rollup for redux-devtools * Use rollup for redux-devtools-intrument * Use rollup for redux-devtools-chart-monitor * Update export * Use rollup for redux-devtools-dock-monitor * Use rollup for redux-devtools-inspector-monitor * Fix inspector demo * Fix invalid eslint config * Use rollup for inspector-monitor-test-tab * Use rollup for inspector-monitor-trace-tab * Use rollup for redux-devtools-log-monitor * Use rollup for redux-devtools-remote * Use rollup in redux-devtools-rtk-query-monitor * Use rollup for redux-devtools-serialize * Fix redux-devtools examples * Use rollup for redux-devtools-slider-monitor * Fix slider examples * Use rollup for redux-devtools-ui * Use rollup for redux-devtools-utils * Use rollup for redux-devtools-extension * Use rollup for redux-devtools-app * Fix Webpack app build * Fix extension build * Turn on minimization * Update CLI
76 lines
1.7 KiB
TypeScript
76 lines
1.7 KiB
TypeScript
import jsan from 'jsan';
|
|
import { immutableSerialize } from '@redux-devtools/serialize';
|
|
import { Action } from 'redux';
|
|
import Immutable from 'immutable';
|
|
import { PerformAction } from '@redux-devtools/core';
|
|
|
|
interface State {
|
|
actionsById: { [actionId: number]: PerformAction<Action<unknown>> };
|
|
computedStates: { state: unknown; error?: string }[];
|
|
committedState?: unknown;
|
|
}
|
|
|
|
export function importState(
|
|
state: string,
|
|
{
|
|
serialize,
|
|
}: {
|
|
serialize?: {
|
|
immutable?: typeof Immutable;
|
|
refs?: (new (data: any) => unknown)[] | null;
|
|
reviver?: (key: string, value: unknown) => unknown;
|
|
};
|
|
}
|
|
) {
|
|
if (!state) return undefined;
|
|
let parse = jsan.parse;
|
|
if (serialize) {
|
|
if (serialize.immutable) {
|
|
parse = (v) =>
|
|
jsan.parse(
|
|
v,
|
|
immutableSerialize(serialize.immutable!, serialize.refs).reviver
|
|
);
|
|
} else if (serialize.reviver) {
|
|
parse = (v) => jsan.parse(v, serialize.reviver);
|
|
}
|
|
}
|
|
|
|
let preloadedState: State | undefined;
|
|
let nextLiftedState: State = parse(state) as State;
|
|
if (
|
|
(
|
|
nextLiftedState as unknown as {
|
|
payload?: string;
|
|
preloadedState?: string;
|
|
}
|
|
).payload
|
|
) {
|
|
if (
|
|
(
|
|
nextLiftedState as unknown as {
|
|
payload: string;
|
|
preloadedState?: string;
|
|
}
|
|
).preloadedState
|
|
)
|
|
preloadedState = parse(
|
|
(
|
|
nextLiftedState as unknown as {
|
|
payload: string;
|
|
preloadedState: string;
|
|
}
|
|
).preloadedState
|
|
) as State;
|
|
nextLiftedState = parse(
|
|
(
|
|
nextLiftedState as unknown as {
|
|
payload: string;
|
|
}
|
|
).payload
|
|
) as State;
|
|
}
|
|
|
|
return { nextLiftedState, preloadedState };
|
|
}
|