Make ReactDevTools Opt-in
This commit is contained in:
parent
516f8c488a
commit
86eacea74d
@ -3,9 +3,10 @@ import IpcEvents from "../utils/IpcEvents";
|
|||||||
import { React } from "../webpack/common";
|
import { React } from "../webpack/common";
|
||||||
import { mergeDefaults } from "../utils/misc";
|
import { mergeDefaults } from "../utils/misc";
|
||||||
|
|
||||||
interface Settings {
|
export interface Settings {
|
||||||
notifyAboutUpdates: boolean;
|
notifyAboutUpdates: boolean;
|
||||||
useQuickCss: boolean;
|
useQuickCss: boolean;
|
||||||
|
enableReactDevtools: boolean;
|
||||||
plugins: {
|
plugins: {
|
||||||
[plugin: string]: {
|
[plugin: string]: {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
@ -17,6 +18,7 @@ interface Settings {
|
|||||||
const DefaultSettings: Settings = {
|
const DefaultSettings: Settings = {
|
||||||
notifyAboutUpdates: true,
|
notifyAboutUpdates: true,
|
||||||
useQuickCss: true,
|
useQuickCss: true,
|
||||||
|
enableReactDevtools: false,
|
||||||
plugins: {}
|
plugins: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -100,10 +100,17 @@ export default ErrorBoundary.wrap(function Settings() {
|
|||||||
<Switch
|
<Switch
|
||||||
value={settings.useQuickCss}
|
value={settings.useQuickCss}
|
||||||
onChange={(v: boolean) => settings.useQuickCss = v}
|
onChange={(v: boolean) => settings.useQuickCss = v}
|
||||||
note="Enable QuickCSS"
|
note="Loads styles from your QuickCss file"
|
||||||
>
|
>
|
||||||
Use QuickCss
|
Use QuickCss
|
||||||
</Switch>
|
</Switch>
|
||||||
|
{!IS_WEB && <Switch
|
||||||
|
value={settings.enableReactDevtools}
|
||||||
|
onChange={(v: boolean) => settings.enableReactDevtools = v}
|
||||||
|
note="Requires a full restart"
|
||||||
|
>
|
||||||
|
Enable React Developer Tools
|
||||||
|
</Switch>}
|
||||||
{!IS_WEB && <Switch
|
{!IS_WEB && <Switch
|
||||||
value={settings.notifyAboutUpdates}
|
value={settings.notifyAboutUpdates}
|
||||||
onChange={(v: boolean) => settings.notifyAboutUpdates = v}
|
onChange={(v: boolean) => settings.notifyAboutUpdates = v}
|
||||||
|
@ -24,7 +24,7 @@ function readCss() {
|
|||||||
return readFile(QUICKCSS_PATH, "utf-8").catch(() => "");
|
return readFile(QUICKCSS_PATH, "utf-8").catch(() => "");
|
||||||
}
|
}
|
||||||
|
|
||||||
function readSettings() {
|
export function readSettings() {
|
||||||
try {
|
try {
|
||||||
return readFileSync(SETTINGS_FILE, "utf-8");
|
return readFileSync(SETTINGS_FILE, "utf-8");
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import electron, { app, BrowserWindowConstructorOptions } from "electron";
|
import electron, { app, BrowserWindowConstructorOptions } from "electron";
|
||||||
import installExt, { REACT_DEVELOPER_TOOLS } from "electron-devtools-installer";
|
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import { initIpc } from "./ipcMain";
|
import { initIpc } from "./ipcMain";
|
||||||
|
import { readSettings } from "./ipcMain/index";
|
||||||
|
|
||||||
console.log("[Vencord] Starting up...");
|
console.log("[Vencord] Starting up...");
|
||||||
|
|
||||||
@ -47,9 +47,17 @@ Object.defineProperty(global, "appSettings", {
|
|||||||
process.env.DATA_DIR = join(app.getPath("userData"), "..", "Vencord");
|
process.env.DATA_DIR = join(app.getPath("userData"), "..", "Vencord");
|
||||||
|
|
||||||
electron.app.whenReady().then(() => {
|
electron.app.whenReady().then(() => {
|
||||||
installExt(REACT_DEVELOPER_TOOLS)
|
try {
|
||||||
.then(() => console.info("Installed React DevTools"))
|
const settings = JSON.parse(readSettings());
|
||||||
.catch(err => console.error("Failed to install React DevTools", err));
|
if (settings.enableReactDevtools)
|
||||||
|
import("electron-devtools-installer")
|
||||||
|
.then(({ default: inst, REACT_DEVELOPER_TOOLS }) =>
|
||||||
|
// @ts-ignore: cursed fake esm turns it into exports.default.default
|
||||||
|
(inst.default ?? inst)(REACT_DEVELOPER_TOOLS)
|
||||||
|
)
|
||||||
|
.then(() => console.info("[Vencord] Installed React Developer Tools"))
|
||||||
|
.catch(err => console.error("[Vencord] Failed to install React Developer Tools", err));
|
||||||
|
} catch { }
|
||||||
|
|
||||||
// Remove CSP
|
// Remove CSP
|
||||||
electron.session.defaultSession.webRequest.onHeadersReceived(({ responseHeaders, url }, cb) => {
|
electron.session.defaultSession.webRequest.onHeadersReceived(({ responseHeaders, url }, cb) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user