mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-05-05 07:33:45 +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
79 lines
2.1 KiB
TypeScript
79 lines
2.1 KiB
TypeScript
import {
|
|
createStore,
|
|
compose,
|
|
applyMiddleware,
|
|
Store,
|
|
StoreEnhancer,
|
|
Reducer,
|
|
} from 'redux';
|
|
import localForage from 'localforage';
|
|
import { persistReducer, persistStore } from 'redux-persist';
|
|
import {
|
|
api,
|
|
CONNECT_REQUEST,
|
|
exportStateMiddleware,
|
|
InstancesState,
|
|
StoreActionWithoutUpdateState,
|
|
StoreState,
|
|
UpdateStateAction,
|
|
} from '@redux-devtools/app';
|
|
import syncStores from '../middlewares/windowSync';
|
|
import instanceSelector from '../middlewares/instanceSelector';
|
|
import rootReducer from '../reducers/window';
|
|
import { BackgroundState } from '../reducers/background';
|
|
import { BackgroundAction } from './backgroundStore';
|
|
import { EmptyUpdateStateAction, NAAction } from '../middlewares/api';
|
|
|
|
export interface ExpandedUpdateStateAction extends UpdateStateAction {
|
|
readonly instances: InstancesState;
|
|
}
|
|
|
|
export type WindowStoreAction =
|
|
| StoreActionWithoutUpdateState
|
|
| ExpandedUpdateStateAction
|
|
| NAAction
|
|
| EmptyUpdateStateAction;
|
|
|
|
const persistConfig = {
|
|
key: 'redux-devtools',
|
|
blacklist: ['instances', 'socket'],
|
|
storage: localForage,
|
|
};
|
|
|
|
const persistedReducer: Reducer<StoreState, WindowStoreAction> = persistReducer(
|
|
persistConfig,
|
|
rootReducer
|
|
) as any;
|
|
|
|
export default function configureStore(
|
|
baseStore: Store<BackgroundState, BackgroundAction>,
|
|
position: string
|
|
) {
|
|
let enhancer: StoreEnhancer;
|
|
const middlewares = [exportStateMiddleware, api, syncStores(baseStore)];
|
|
if (!position || position === '#popup') {
|
|
// select current tab instance for devPanel and pageAction
|
|
middlewares.push(instanceSelector);
|
|
}
|
|
if (process.env.NODE_ENV === 'production') {
|
|
enhancer = applyMiddleware(...middlewares);
|
|
} else {
|
|
enhancer = compose(
|
|
applyMiddleware(...middlewares),
|
|
window.__REDUX_DEVTOOLS_EXTENSION__
|
|
? window.__REDUX_DEVTOOLS_EXTENSION__()
|
|
: (noop: unknown) => noop
|
|
);
|
|
}
|
|
const store = createStore(persistedReducer, enhancer);
|
|
const persistor = persistStore(store, null, () => {
|
|
if (store.getState().connection.type !== 'disabled') {
|
|
store.dispatch({
|
|
type: CONNECT_REQUEST,
|
|
});
|
|
}
|
|
});
|
|
|
|
return { store, persistor };
|
|
}
|