This commit is contained in:
Nathan Bierema 2020-12-21 15:39:38 -05:00
parent a46b43209d
commit 67fdffc775
65 changed files with 165 additions and 67 deletions

View File

@ -1,41 +0,0 @@
import 'devui/lib/presets';
import React, { Component } from 'react';
import { Provider } from 'react-redux';
import { Store } from 'redux';
import configureStore from './store/configureStore';
import { CONNECT_REQUEST } from './constants/socketActionTypes';
import App from './containers/App';
import { StoreState } from './reducers';
import { ConnectionOptions, StoreAction } from './actions';
interface Props {
socketOptions?: ConnectionOptions;
}
class Root extends Component<Props> {
store?: Store<StoreState, StoreAction>;
UNSAFE_componentWillMount() {
configureStore((store, preloadedState) => {
this.store = store;
store.dispatch({
type: CONNECT_REQUEST,
options: (preloadedState!.connection ||
this.props.socketOptions) as ConnectionOptions,
});
this.forceUpdate();
});
}
render() {
if (!this.store) return null;
const AppAsAny = App as any;
return (
<Provider store={this.store}>
<AppAsAny {...this.props} />
</Provider>
);
}
}
export default Root;

View File

@ -1,22 +1,41 @@
import React from 'react'; import 'devui/lib/presets';
import { render } from 'react-dom'; import React, { Component } from 'react';
import App from './app'; import { Provider } from 'react-redux';
import { Store } from 'redux';
import configureStore from './store/configureStore';
import { CONNECT_REQUEST } from './constants/socketActionTypes';
import App from './containers/App';
import { StoreState } from './reducers';
import { ConnectionOptions, StoreAction } from './actions';
render(<App />, document.getElementById('root')); interface Props {
socketOptions?: ConnectionOptions;
if (module.hot) {
// https://github.com/webpack/webpack/issues/418#issuecomment-53398056
module.hot.accept((err) => {
if (err) console.error(err.message); // eslint-disable-line no-console
});
/*
module.hot.accept('./app', () => {
const NextApp = require('./app').default;
render(
<NextApp />,
document.getElementById('root')
);
});
*/
} }
class Root extends Component<Props> {
store?: Store<StoreState, StoreAction>;
UNSAFE_componentWillMount() {
configureStore((store, preloadedState) => {
this.store = store;
store.dispatch({
type: CONNECT_REQUEST,
options: (preloadedState!.connection ||
this.props.socketOptions) as ConnectionOptions,
});
this.forceUpdate();
});
}
render() {
if (!this.store) return null;
const AppAsAny = App as any;
return (
<Provider store={this.store}>
<AppAsAny {...this.props} />
</Provider>
);
}
}
export default Root;

View File

@ -3,12 +3,12 @@ import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux'; import { createStore, applyMiddleware } from 'redux';
import { mount, ReactWrapper } from 'enzyme'; import { mount, ReactWrapper } from 'enzyme';
// import { mountToJson } from 'enzyme-to-json'; // import { mountToJson } from 'enzyme-to-json';
import App from '../src/app/containers/App'; import App from '../src/containers/App';
import api from '../src/app/middlewares/api'; import api from '../src/middlewares/api';
import exportState from '../src/app/middlewares/exportState'; import exportState from '../src/middlewares/exportState';
import rootReducer from '../src/app/reducers'; import rootReducer from '../src/reducers';
import { DATA_TYPE_KEY } from '../src/app/constants/dataTypes'; import { DATA_TYPE_KEY } from '../src/constants/dataTypes';
import stringifyJSON from '../src/app/utils/stringifyJSON'; import stringifyJSON from '../src/utils/stringifyJSON';
let wrapper: ReactWrapper<unknown, unknown, Component>; let wrapper: ReactWrapper<unknown, unknown, Component>;

View File

@ -0,0 +1,8 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-react",
"@babel/preset-typescript"
],
"plugins": ["@babel/plugin-proposal-class-properties"]
}

View File

@ -0,0 +1 @@
lib

View File

@ -0,0 +1,29 @@
module.exports = {
extends: '../../.eslintrc',
overrides: [
{
files: ['*.ts', '*.tsx'],
extends: '../../eslintrc.ts.react.base.json',
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
},
{
files: ['test/*.ts', 'test/*.tsx'],
extends: '../../eslintrc.ts.react.jest.base.json',
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./test/tsconfig.json'],
},
},
{
files: ['webpack.config.ts', 'webpack.config.umd.ts'],
extends: '../../eslintrc.ts.base.json',
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.webpack.json'],
},
},
],
};

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Mihail Diordiev
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,54 @@
{
"name": "redux-devtools-core",
"version": "1.0.0-4",
"description": "Reusable functions of Redux DevTools",
"homepage": "https://github.com/reduxjs/redux-devtools/tree/master/packages/redux-devtools-core",
"bugs": {
"url": "https://github.com/reduxjs/redux-devtools/issues"
},
"license": "MIT",
"author": "Mihail Diordiev <zalmoxisus@gmail.com> (https://github.com/zalmoxisus)",
"files": [
"src",
"lib",
"umd"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/reduxjs/redux-devtools.git"
},
"scripts": {
"start": "webpack-dev-server --hot --inline --env.development --env.platform=web --progress",
"build": "npm run build:types && npm run build:js && npm run build:web && npm run build:umd && npm run build:umd:min",
"build:types": "tsc --emitDeclarationOnly",
"build:js": "babel src --out-dir lib --extensions \".ts,.tsx\" --source-maps inline",
"build:web": "rimraf ./build/web && webpack -p --env.platform=web --progress",
"build:umd": "rimraf ./umd && webpack --progress --config webpack.config.umd.ts",
"build:umd:min": "webpack --env.production --progress --config webpack.config.umd.ts",
"clean": "rimraf lib",
"test": "jest",
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "eslint . --ext .ts,.tsx --fix",
"type-check": "tsc --noEmit",
"type-check:watch": "npm run type-check -- --watch",
"preversion": "npm run type-check && npm run lint && npm run test",
"prepublishOnly": "npm run clean && npm run build"
},
"dependencies": {
"@redux-devtools/core": "^3.7.0",
"@redux-devtools/serialize": "^0.2.0",
"get-params": "^0.1.2",
"immutable": "^4.0.0-rc.12",
"jsan": "^3.1.13",
"lodash": "^4.17.19",
"nanoid": "^3.1.12",
"redux": "^4.0.5"
},
"peerDependencies": {
"@redux-devtools/core": "^3.7.0",
"immutable": "^4.0.0-rc.12",
"redux": "^4.0.5"
}
}

View File

@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.react.base.json",
"compilerOptions": {
"outDir": "lib"
},
"include": ["src"]
}