mirror of
https://github.com/Vencord/Vesktop.git
synced 2025-02-22 21:35:08 +00:00
use Vencord's addPatch instead of manually adding patches
This commit is contained in:
parent
3b76c30db2
commit
68930a1f50
2 changed files with 7 additions and 11 deletions
2
src/globals.d.ts
vendored
2
src/globals.d.ts
vendored
|
@ -7,7 +7,7 @@
|
||||||
declare global {
|
declare global {
|
||||||
export var VesktopNative: typeof import("preload/VesktopNative").VesktopNative;
|
export var VesktopNative: typeof import("preload/VesktopNative").VesktopNative;
|
||||||
export var Vesktop: typeof import("renderer/index");
|
export var Vesktop: typeof import("renderer/index");
|
||||||
export var VCDP: any;
|
export var VesktopPatchGlobals: any;
|
||||||
|
|
||||||
export var IS_DEV: boolean;
|
export var IS_DEV: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
import { Patch } from "@vencord/types/utils/types";
|
import { Patch } from "@vencord/types/utils/types";
|
||||||
|
|
||||||
window.VCDP = {};
|
window.VesktopPatchGlobals = {};
|
||||||
|
|
||||||
interface PatchData {
|
interface PatchData {
|
||||||
patches: Omit<Patch, "plugin">[];
|
patches: Omit<Patch, "plugin">[];
|
||||||
|
@ -16,15 +16,11 @@ interface PatchData {
|
||||||
export function addPatch<P extends PatchData>(p: P) {
|
export function addPatch<P extends PatchData>(p: P) {
|
||||||
const { patches, ...globals } = p;
|
const { patches, ...globals } = p;
|
||||||
|
|
||||||
for (const patch of patches as Patch[]) {
|
for (const patch of patches) {
|
||||||
if (!Array.isArray(patch.replacement)) patch.replacement = [patch.replacement];
|
// @ts-expect-error outdated types don't have addPatch yet
|
||||||
for (const r of patch.replacement) {
|
// TODO: Update types
|
||||||
if (typeof r.replace === "string") r.replace = r.replace.replaceAll("$self", "VCDP");
|
Vencord.Plugins.addPatch(patch, "Vesktop", "VesktopPatchGlobals");
|
||||||
}
|
|
||||||
|
|
||||||
patch.plugin = "Vesktop";
|
|
||||||
Vencord.Plugins.patches.push(patch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.assign(VCDP, globals);
|
Object.assign(VesktopPatchGlobals, globals);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue