2020-08-08 22:46:01 +03:00
|
|
|
import '@babel/polyfill';
|
|
|
|
import 'devui/lib/presets';
|
|
|
|
import React from 'react';
|
|
|
|
import { render } from 'react-dom';
|
|
|
|
import { Container } from 'devui';
|
|
|
|
import DemoApp from './DemoApp';
|
|
|
|
import { Provider } from 'react-redux';
|
2020-08-10 03:41:59 +03:00
|
|
|
import createRootReducer from './reducers';
|
|
|
|
import { createStore, applyMiddleware, compose } from 'redux';
|
2020-08-09 01:04:46 +03:00
|
|
|
import logger from 'redux-logger';
|
2020-08-10 03:41:59 +03:00
|
|
|
import { Route } from 'react-router';
|
|
|
|
import { createBrowserHistory } from 'history';
|
|
|
|
import { ConnectedRouter, routerMiddleware } from 'connected-react-router';
|
|
|
|
import { persistState } from 'redux-devtools';
|
2020-08-08 22:46:01 +03:00
|
|
|
import getOptions from './getOptions';
|
2020-08-10 03:41:59 +03:00
|
|
|
import { ConnectedDevTools, getDevTools } from './DevTools';
|
2020-08-08 22:46:01 +03:00
|
|
|
|
|
|
|
function getDebugSessionKey() {
|
|
|
|
const matches = window.location.href.match(/[?&]debug_session=([^&#]+)\b/);
|
|
|
|
return matches && matches.length > 0 ? matches[1] : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const ROOT =
|
2020-08-10 03:41:59 +03:00
|
|
|
process.env.NODE_ENV === 'production'
|
|
|
|
? '/redux-devtools-test-generator/'
|
|
|
|
: '/';
|
|
|
|
|
|
|
|
const DevTools = getDevTools(window.location);
|
2020-08-08 22:46:01 +03:00
|
|
|
|
2020-08-10 03:41:59 +03:00
|
|
|
const history = createBrowserHistory();
|
2020-08-08 22:46:01 +03:00
|
|
|
|
2020-08-10 03:41:59 +03:00
|
|
|
const useDevtoolsExtension =
|
|
|
|
!!window.__REDUX_DEVTOOLS_EXTENSION__ &&
|
|
|
|
getOptions(window.location).useExtension;
|
2020-08-08 22:46:01 +03:00
|
|
|
|
|
|
|
const enhancer = compose(
|
2020-08-10 03:41:59 +03:00
|
|
|
applyMiddleware(logger, routerMiddleware(history)),
|
2020-08-08 22:46:01 +03:00
|
|
|
(...args) => {
|
|
|
|
const instrument = useDevtoolsExtension
|
|
|
|
? window.__REDUX_DEVTOOLS_EXTENSION__()
|
|
|
|
: DevTools.instrument();
|
|
|
|
return instrument(...args);
|
|
|
|
},
|
|
|
|
persistState(getDebugSessionKey())
|
|
|
|
);
|
|
|
|
|
2020-08-10 03:41:59 +03:00
|
|
|
const store = createStore(createRootReducer(history), {}, enhancer);
|
2020-08-08 22:46:01 +03:00
|
|
|
|
2020-08-10 03:41:59 +03:00
|
|
|
render(
|
|
|
|
<Provider store={store}>
|
|
|
|
<ConnectedRouter history={history}>
|
2020-08-08 22:46:01 +03:00
|
|
|
<Container
|
|
|
|
themeData={{ theme: 'default', scheme: 'default', light: true }}
|
|
|
|
>
|
2020-08-10 03:41:59 +03:00
|
|
|
<Route path={ROOT}>
|
|
|
|
<DemoApp />
|
|
|
|
</Route>
|
|
|
|
{!useDevtoolsExtension && <ConnectedDevTools />}
|
2020-08-08 22:46:01 +03:00
|
|
|
</Container>
|
2020-08-10 03:41:59 +03:00
|
|
|
</ConnectedRouter>
|
|
|
|
</Provider>,
|
|
|
|
document.getElementById('root')
|
|
|
|
);
|