🔧 More fixes for the react-refresh plugin bugs
This commit is contained in:
@@ -5,11 +5,11 @@
|
|||||||
"main": "server/index.js",
|
"main": "server/index.js",
|
||||||
"typings": "server/index.js",
|
"typings": "server/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "NODE_ENV=production webpack --mode production",
|
"build": "webpack --mode production",
|
||||||
"start": "npm run build && npm run server",
|
"start": "npm run build && npm run server",
|
||||||
"client": "webpack serve --mode development --devtool inline-source-map --hot",
|
"client": "webpack serve --mode development --devtool inline-source-map --hot",
|
||||||
"server": "tsc -p tsconfig.server.json && node server/",
|
"server": "tsc -p tsconfig.server.json && node server/",
|
||||||
"dev": "NODE_ENV=development concurrently \"nodemon\" \"npm run client\"",
|
"dev": "concurrently \"nodemon\" \"npm run client\"",
|
||||||
"server-dev": "nodemon",
|
"server-dev": "nodemon",
|
||||||
"docs": "jsdoc -c jsdoc.json"
|
"docs": "jsdoc -c jsdoc.json"
|
||||||
},
|
},
|
||||||
@@ -151,7 +151,7 @@
|
|||||||
"nodemon": "^1.17.3",
|
"nodemon": "^1.17.3",
|
||||||
"npm": "^8.11.0",
|
"npm": "^8.11.0",
|
||||||
"prettier": "^2.2.1",
|
"prettier": "^2.2.1",
|
||||||
"react-refresh": "^0.13.0",
|
"react-refresh": "^0.14.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"sass-loader": "^11.0.1",
|
"sass-loader": "^11.0.1",
|
||||||
"source-map-loader": "^0.2.4",
|
"source-map-loader": "^0.2.4",
|
||||||
|
|||||||
@@ -7,21 +7,15 @@ import { saveSettings } from "../../actions/settings.actions";
|
|||||||
import { AirDCPPSocketContext } from "../../context/AirDCPPSocket";
|
import { AirDCPPSocketContext } from "../../context/AirDCPPSocket";
|
||||||
|
|
||||||
export const AirDCPPHubsForm = (airDCPPClientUserSettings): ReactElement => {
|
export const AirDCPPHubsForm = (airDCPPClientUserSettings): ReactElement => {
|
||||||
const { settings } = airDCPPClientUserSettings;
|
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [hubList, setHubList] = useState([]);
|
const [hubList, setHubList] = useState([]);
|
||||||
const { ADCPPSocket } = useContext(AirDCPPSocketContext);
|
const airDCPPConfiguration = useContext(AirDCPPSocketContext);
|
||||||
|
const { AirDCPPSocket, settings } = airDCPPConfiguration;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
if (!isEmpty(settings)) {
|
if (!isEmpty(settings)) {
|
||||||
console.log(ADCPPSocket);
|
const hubs = await AirDCPPSocket.get(`hubs`);
|
||||||
await ADCPPSocket.connect(
|
|
||||||
settings.directConnect.client.host.username,
|
|
||||||
settings.directConnect.client.host.password,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
const hubs = await ADCPPSocket.get(`hubs`);
|
|
||||||
const hubSelectionOptions = hubs.map(({ hub_url, identity }) => ({
|
const hubSelectionOptions = hubs.map(({ hub_url, identity }) => ({
|
||||||
value: hub_url,
|
value: hub_url,
|
||||||
label: identity.name,
|
label: identity.name,
|
||||||
|
|||||||
@@ -4,36 +4,20 @@ import { useDispatch } from "react-redux";
|
|||||||
import { saveSettings, deleteSettings } from "../../actions/settings.actions";
|
import { saveSettings, deleteSettings } from "../../actions/settings.actions";
|
||||||
import { AirDCPPSettingsConfirmation } from "./AirDCPPSettingsConfirmation";
|
import { AirDCPPSettingsConfirmation } from "./AirDCPPSettingsConfirmation";
|
||||||
import { AirDCPPSocketContext } from "../../context/AirDCPPSocket";
|
import { AirDCPPSocketContext } from "../../context/AirDCPPSocket";
|
||||||
import AirDCPPSocket from "../../services/DcppSearchService";
|
|
||||||
import { isUndefined, isEmpty, isNil } from "lodash";
|
import { isUndefined, isEmpty, isNil } from "lodash";
|
||||||
|
|
||||||
export const AirDCPPSettingsForm = (airDCPPClientSettings): ReactElement => {
|
export const AirDCPPSettingsForm = (): ReactElement => {
|
||||||
const { settings } = airDCPPClientSettings;
|
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { setADCPPSocket } = useContext(AirDCPPSocketContext);
|
const airDCPPConfiguration = useContext(AirDCPPSocketContext);
|
||||||
|
const { AirDCPPSocket, settings } = airDCPPConfiguration;
|
||||||
|
|
||||||
const onSubmit = async (values) => {
|
const onSubmit = async (values) => {
|
||||||
try {
|
try {
|
||||||
const socket = new AirDCPPSocket({
|
if (!isNil(AirDCPPSocket.session_id)) {
|
||||||
hostname: `${values.hostname}`,
|
|
||||||
protocol: `${values.protocol}`,
|
|
||||||
});
|
|
||||||
const socketConnectionResponse = await socket.connect(
|
|
||||||
values.username,
|
|
||||||
values.password,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
if (!isNil(socketConnectionResponse.session_id)) {
|
|
||||||
dispatch(
|
dispatch(
|
||||||
saveSettings({
|
saveSettings({
|
||||||
host: values,
|
host: values,
|
||||||
airDCPPUserSettings: socketConnectionResponse,
|
airDCPPUserSettings: settings,
|
||||||
}),
|
|
||||||
);
|
|
||||||
setADCPPSocket(
|
|
||||||
new AirDCPPSocket({
|
|
||||||
hostname: `${values.hostname}`,
|
|
||||||
protocol: `${values.protocol}`,
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -44,7 +28,6 @@ export const AirDCPPSettingsForm = (airDCPPClientSettings): ReactElement => {
|
|||||||
|
|
||||||
const removeSettings = useCallback(async () => {
|
const removeSettings = useCallback(async () => {
|
||||||
dispatch(deleteSettings());
|
dispatch(deleteSettings());
|
||||||
setADCPPSocket({});
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const validate = async () => {};
|
const validate = async () => {};
|
||||||
|
|||||||
@@ -4,52 +4,21 @@ import { AirDCPPHubsForm } from "./AirDCPPSettings/AirDCPPHubsForm";
|
|||||||
import { SystemSettingsForm } from "./SystemSettings/SystemSettingsForm";
|
import { SystemSettingsForm } from "./SystemSettings/SystemSettingsForm";
|
||||||
import settingsObject from "../constants/settings/settingsMenu.json";
|
import settingsObject from "../constants/settings/settingsMenu.json";
|
||||||
import { isEmpty, isUndefined, map } from "lodash";
|
import { isEmpty, isUndefined, map } from "lodash";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
|
||||||
import { getSettings } from "../actions/settings.actions";
|
|
||||||
import { AirDCPPSocketContext } from "../context/AirDCPPSocket";
|
|
||||||
import AirDCPPSocket from "../services/DcppSearchService";
|
|
||||||
|
|
||||||
interface ISettingsProps {}
|
interface ISettingsProps {}
|
||||||
|
|
||||||
export const Settings = (props: ISettingsProps): ReactElement => {
|
export const Settings = (props: ISettingsProps): ReactElement => {
|
||||||
// fetch saved AirDC++ settings, if any
|
|
||||||
const airDCPPClientSettings = useSelector(
|
|
||||||
(state: RootState) => state.settings.data,
|
|
||||||
);
|
|
||||||
const dispatch = useDispatch();
|
|
||||||
const { ADCPPSocket, setADCPPSocket } = useContext(AirDCPPSocketContext);
|
|
||||||
useEffect(() => {
|
|
||||||
dispatch(getSettings());
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!isEmpty(airDCPPClientSettings)) {
|
|
||||||
setADCPPSocket(
|
|
||||||
new AirDCPPSocket({
|
|
||||||
hostname: `${airDCPPClientSettings.directConnect.client.host.hostname}`,
|
|
||||||
protocol: `${airDCPPClientSettings.directConnect.client.host.protocol}`,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}, [airDCPPClientSettings]);
|
|
||||||
const [active, setActive] = useState("gen-db");
|
const [active, setActive] = useState("gen-db");
|
||||||
|
|
||||||
const settingsContent = [
|
const settingsContent = [
|
||||||
{
|
{
|
||||||
id: "adc-hubs",
|
id: "adc-hubs",
|
||||||
content: (
|
content: <>{<AirDCPPHubsForm />}</>,
|
||||||
<>
|
|
||||||
{!isEmpty(airDCPPClientSettings) ? (
|
|
||||||
<AirDCPPHubsForm settings={airDCPPClientSettings} />
|
|
||||||
) : null}
|
|
||||||
</>
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "adc-connection",
|
id: "adc-connection",
|
||||||
content: (
|
content: (
|
||||||
<>
|
<>
|
||||||
<AirDCPPSettingsForm settings={airDCPPClientSettings} />
|
<AirDCPPSettingsForm />
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@@ -57,7 +26,7 @@ export const Settings = (props: ISettingsProps): ReactElement => {
|
|||||||
id: "flushdb",
|
id: "flushdb",
|
||||||
content: (
|
content: (
|
||||||
<>
|
<>
|
||||||
<SystemSettingsForm settings={airDCPPClientSettings} />
|
<SystemSettingsForm />
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { flushDb } from "../../actions/settings.actions";
|
|||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
|
||||||
export const SystemSettingsForm = (settingsObject): ReactElement => {
|
export const SystemSettingsForm = (settingsObject): ReactElement => {
|
||||||
const { settings } = settingsObject;
|
|
||||||
|
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const isSettingsCallInProgress = useSelector(
|
const isSettingsCallInProgress = useSelector(
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import App from "./components/App";
|
|||||||
|
|
||||||
const rootEl = document.getElementById("root");
|
const rootEl = document.getElementById("root");
|
||||||
const root = createRoot(rootEl);
|
const root = createRoot(rootEl);
|
||||||
//In the entry of your indirect code path (e.g. some index.js), add the following two lines:
|
|
||||||
|
|
||||||
root.render(
|
root.render(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
|
|||||||
@@ -8,13 +8,9 @@ const BundleAnalyzerPlugin =
|
|||||||
const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin");
|
const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin");
|
||||||
const CopyPlugin = require("copy-webpack-plugin");
|
const CopyPlugin = require("copy-webpack-plugin");
|
||||||
|
|
||||||
const isDevelopment = process.env.NODE_ENV !== "production";
|
module.exports = (_, argv) => {
|
||||||
const HMRPlugin = () => (isDevelopment ? new ReactRefreshWebpackPlugin() : {});
|
const mode = argv.mode;
|
||||||
const reactRefreshBabelPlugin = isDevelopment
|
const isDevelopment = mode === "development";
|
||||||
? require.resolve("react-refresh/babel")
|
|
||||||
: {};
|
|
||||||
|
|
||||||
module.exports = () => {
|
|
||||||
return {
|
return {
|
||||||
entry: ["babel-polyfill", "./src/client/index.tsx"],
|
entry: ["babel-polyfill", "./src/client/index.tsx"],
|
||||||
output: {
|
output: {
|
||||||
@@ -47,7 +43,9 @@ module.exports = () => {
|
|||||||
{
|
{
|
||||||
loader: "babel-loader",
|
loader: "babel-loader",
|
||||||
options: {
|
options: {
|
||||||
plugins: [reactRefreshBabelPlugin],
|
plugins: [
|
||||||
|
isDevelopment && require("react-refresh/babel"),
|
||||||
|
].filter(Boolean),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -103,7 +101,6 @@ module.exports = () => {
|
|||||||
usedExports: false,
|
usedExports: false,
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
HMRPlugin,
|
|
||||||
// new BundleAnalyzerPlugin(),
|
// new BundleAnalyzerPlugin(),
|
||||||
new CopyPlugin({
|
new CopyPlugin({
|
||||||
patterns: [{ from: "./src/client/assets/img/", to: "img/" }],
|
patterns: [{ from: "./src/client/assets/img/", to: "img/" }],
|
||||||
@@ -111,6 +108,7 @@ module.exports = () => {
|
|||||||
concurrency: 100,
|
concurrency: 100,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
isDevelopment && new ReactRefreshWebpackPlugin(),
|
||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
template: "./public/index.html",
|
template: "./public/index.html",
|
||||||
favicon: "./public/favicon.ico",
|
favicon: "./public/favicon.ico",
|
||||||
@@ -125,6 +123,6 @@ module.exports = () => {
|
|||||||
filename: "./css/[name].css",
|
filename: "./css/[name].css",
|
||||||
chunkFilename: "./css/[id].css",
|
chunkFilename: "./css/[id].css",
|
||||||
}),
|
}),
|
||||||
],
|
].filter(Boolean),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12220,10 +12220,10 @@ react-redux@^7.2.6:
|
|||||||
prop-types "^15.7.2"
|
prop-types "^15.7.2"
|
||||||
react-is "^17.0.2"
|
react-is "^17.0.2"
|
||||||
|
|
||||||
react-refresh@^0.13.0:
|
react-refresh@^0.14.0:
|
||||||
version "0.13.0"
|
version "0.14.0"
|
||||||
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.13.0.tgz#cbd01a4482a177a5da8d44c9755ebb1f26d5a1c1"
|
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.14.0.tgz#4e02825378a5f227079554d4284889354e5f553e"
|
||||||
integrity sha512-XP8A9BT0CpRBD+NYLLeIhld/RqG9+gktUjW1FkE+Vm7OCinbG1SshcK5tb9ls4kzvjZr9mOQc7HYgBngEyPAXg==
|
integrity sha512-wViHqhAd8OHeLS/IRMJjTSDHF3U9eWi62F/MledQGPdJGDhodXJ9PBLNGr6WWL7qlH12Mt3TyTpbS+hGXMjCzQ==
|
||||||
|
|
||||||
react-refresh@^0.9.0:
|
react-refresh@^0.9.0:
|
||||||
version "0.9.0"
|
version "0.9.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user