build: automatically glob all patch files
This commit is contained in:
@@ -8,6 +8,7 @@ import { BuildContext, BuildOptions, context } from "esbuild";
|
|||||||
import { copyFile } from "fs/promises";
|
import { copyFile } from "fs/promises";
|
||||||
|
|
||||||
import vencordDep from "./vencordDep.mjs";
|
import vencordDep from "./vencordDep.mjs";
|
||||||
|
import { includeDirPlugin } from "./includeDirPlugin.mts";
|
||||||
|
|
||||||
const isDev = process.argv.includes("--dev");
|
const isDev = process.argv.includes("--dev");
|
||||||
|
|
||||||
@@ -78,7 +79,7 @@ await Promise.all([
|
|||||||
jsxFactory: "VencordCreateElement",
|
jsxFactory: "VencordCreateElement",
|
||||||
jsxFragment: "VencordFragment",
|
jsxFragment: "VencordFragment",
|
||||||
external: ["@vencord/types/*"],
|
external: ["@vencord/types/*"],
|
||||||
plugins: [vencordDep],
|
plugins: [vencordDep, includeDirPlugin("patches", "src/renderer/patches")],
|
||||||
footer: { js: "//# sourceURL=VCDRenderer" }
|
footer: { js: "//# sourceURL=VCDRenderer" }
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|||||||
25
scripts/build/includeDirPlugin.mts
Normal file
25
scripts/build/includeDirPlugin.mts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { Plugin } from "esbuild";
|
||||||
|
import { readdir } from "fs/promises";
|
||||||
|
|
||||||
|
const makeImportAllCode = (files: string[]) =>
|
||||||
|
files.map(f => `require("./${f.replace(/\.[cm]?[tj]sx?$/, "")}")`).join("\n");
|
||||||
|
|
||||||
|
const makeImportDirRecursiveCode = (dir: string) => readdir(dir).then(files => makeImportAllCode(files));
|
||||||
|
|
||||||
|
export function includeDirPlugin(namespace: string, path: string): Plugin {
|
||||||
|
return {
|
||||||
|
name: `include-dir-plugin:${namespace}`,
|
||||||
|
setup(build) {
|
||||||
|
const filter = new RegExp(`^__${namespace}__$`);
|
||||||
|
|
||||||
|
build.onResolve({ filter }, args => ({ path: args.path, namespace }));
|
||||||
|
|
||||||
|
build.onLoad({ filter, namespace }, async args => {
|
||||||
|
return {
|
||||||
|
contents: await makeImportDirRecursiveCode(path),
|
||||||
|
resolveDir: path
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
10
src/module.d.ts
vendored
Normal file
10
src/module.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* Vesktop, a desktop app aiming to give you a snappier Discord Experience
|
||||||
|
* Copyright (c) 2025 Vendicated and Vesktop contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare module "__patches__" {
|
||||||
|
const never: never;
|
||||||
|
export default never;
|
||||||
|
}
|
||||||
@@ -7,9 +7,9 @@
|
|||||||
import "./themedSplash";
|
import "./themedSplash";
|
||||||
import "./ipcCommands";
|
import "./ipcCommands";
|
||||||
import "./appBadge";
|
import "./appBadge";
|
||||||
import "./patches";
|
|
||||||
import "./fixes";
|
import "./fixes";
|
||||||
import "./arrpc";
|
import "./arrpc";
|
||||||
|
import "__patches__"; // auto generated by the build script
|
||||||
|
|
||||||
export * as Components from "./components";
|
export * as Components from "./components";
|
||||||
|
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ addPatch({
|
|||||||
replacement: {
|
replacement: {
|
||||||
// eslint-disable-next-line no-useless-escape
|
// eslint-disable-next-line no-useless-escape
|
||||||
match: /(\i)\.\i\.getState\(\).neverShowModal/,
|
match: /(\i)\.\i\.getState\(\).neverShowModal/,
|
||||||
replace: "$& || $self.shouldIgnore($1)"
|
replace: "$& || $self.shouldIgnoreDevice($1)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
shouldIgnore(state: any) {
|
shouldIgnoreDevice(state: any) {
|
||||||
return Object.keys(state?.default?.lastDeviceConnected ?? {})?.[0] === "vencord-screen-share";
|
return Object.keys(state?.default?.lastDeviceConnected ?? {})?.[0] === "vencord-screen-share";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* Vesktop, a desktop app aiming to give you a snappier Discord Experience
|
|
||||||
* Copyright (c) 2023 Vendicated and Vencord contributors
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
// TODO: Possibly auto generate glob if we have more patches in the future
|
|
||||||
import "./enableNotificationsByDefault";
|
|
||||||
import "./platformClass";
|
|
||||||
import "./allowDevToolsKeybind";
|
|
||||||
import "./hideSwitchDevice";
|
|
||||||
import "./hideVenmicInput";
|
|
||||||
import "./screenShareFixes";
|
|
||||||
import "./spellCheck";
|
|
||||||
import "./windowsTitleBar";
|
|
||||||
import "./streamerMode";
|
|
||||||
import "./windowMethods";
|
|
||||||
import "./hideDownloadAppsButton";
|
|
||||||
import "./fixAutoGainToggle";
|
|
||||||
Reference in New Issue
Block a user