Fix NPE when opening DevTools
This commit is contained in:
parent
876e622f4f
commit
1709ab61ef
4 changed files with 17 additions and 7 deletions
12
build.mjs
12
build.mjs
|
@ -4,16 +4,19 @@ import { readdirSync } from "fs";
|
||||||
import { performance } from "perf_hooks";
|
import { performance } from "perf_hooks";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {esbuild.WatchMode}
|
* @type {esbuild.WatchMode|false}
|
||||||
*/
|
*/
|
||||||
const watch = {
|
const watch = process.argv.includes("--watch") ? {
|
||||||
onRebuild: (err) => {
|
onRebuild: (err) => {
|
||||||
if (err) console.error("Build Error", err.message);
|
if (err) console.error("Build Error", err.message);
|
||||||
else console.log("Rebuilt!");
|
else console.log("Rebuilt!");
|
||||||
}
|
}
|
||||||
};
|
} : false;
|
||||||
|
|
||||||
// https://github.com/evanw/esbuild/issues/619#issuecomment-751995294
|
// https://github.com/evanw/esbuild/issues/619#issuecomment-751995294
|
||||||
|
/**
|
||||||
|
* @type {esbuild.Plugin}
|
||||||
|
*/
|
||||||
const makeAllPackagesExternalPlugin = {
|
const makeAllPackagesExternalPlugin = {
|
||||||
name: 'make-all-packages-external',
|
name: 'make-all-packages-external',
|
||||||
setup(build) {
|
setup(build) {
|
||||||
|
@ -22,6 +25,9 @@ const makeAllPackagesExternalPlugin = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {esbuild.Plugin}
|
||||||
|
*/
|
||||||
const globPlugins = {
|
const globPlugins = {
|
||||||
name: "glob-plugins",
|
name: "glob-plugins",
|
||||||
setup: build => {
|
setup: build => {
|
||||||
|
|
|
@ -7,5 +7,5 @@ export default {
|
||||||
cb(css);
|
cb(css);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getQuickCss: () => ipcRenderer.invoke(IPC_GET_QUICK_CSS)
|
getQuickCss: () => ipcRenderer.invoke(IPC_GET_QUICK_CSS) as Promise<string>
|
||||||
};
|
};
|
6
src/globals.d.ts
vendored
6
src/globals.d.ts
vendored
|
@ -1,7 +1,5 @@
|
||||||
import TVencordNative from "./VencordNative";
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
export var VencordNative: typeof TVencordNative;
|
export var VencordNative: typeof import("./VencordNative").default;
|
||||||
export var appSettings: {
|
export var appSettings: {
|
||||||
set(setting: string, v: any): void;
|
set(setting: string, v: any): void;
|
||||||
};
|
};
|
||||||
|
@ -12,3 +10,5 @@ declare global {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export { };
|
|
@ -20,6 +20,10 @@ class BrowserWindow extends electron.BrowserWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Object.assign(BrowserWindow, electron.BrowserWindow);
|
Object.assign(BrowserWindow, electron.BrowserWindow);
|
||||||
|
// esbuild may rename our BrowserWindow, which leads to it being excluded
|
||||||
|
// from getFocusedWindow(), so this is necessary
|
||||||
|
// https://github.com/discord/electron/blob/13-x-y/lib/browser/api/browser-window.ts#L60-L62
|
||||||
|
Object.defineProperty(BrowserWindow, "name", { value: "BrowserWindow", configurable: true });
|
||||||
|
|
||||||
// Replace electrons exports with our custom BrowserWindow
|
// Replace electrons exports with our custom BrowserWindow
|
||||||
const electronPath = require.resolve("electron");
|
const electronPath = require.resolve("electron");
|
||||||
|
|
Loading…
Reference in a new issue