1
0
Fork 1
mirror of https://github.com/Vendicated/Vencord.git synced 2025-01-26 09:16:24 +00:00

fix imports causing a crash and add missing if statment

This commit is contained in:
sadan 2024-08-20 20:58:47 -04:00
parent 982b52d6e9
commit 4f92052d49
No known key found for this signature in database
5 changed files with 73 additions and 51 deletions

13
.vscode/tasks.json vendored
View file

@ -14,12 +14,19 @@
}, },
{ {
// for use with the vencord companion extension // for use with the vencord companion extension
"label": "BuildCompanionReporter", "label": "Build Companion Reporter",
"type": "shell", "type": "shell",
"command": "pnpm build --dev --reporter --companion-test" "command": "pnpm build --dev --reporter --companion-test",
"presentation": {
"echo": true,
"reveal": "silent",
"panel": "shared",
"showReuseMessage": true,
"clear": true
}
}, },
{ {
"label": "BuildDev", "label": "Build Dev",
"type": "shell", "type": "shell",
"command": "pnpm build --dev", "command": "pnpm build --dev",
"group": "build" "group": "build"

48
src/debug/reporterData.ts Normal file
View file

@ -0,0 +1,48 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
/**
* this file is needed to avoid an import of plugins in ./runReporter.ts
*/
import { Patch } from "@utils/types";
import { TypeWebpackSearchHistory } from "@webpack";
interface EvaledPatch extends Patch {
id: number | string;
}
interface ReporterData {
failedPatches: {
foundNoModule: Patch[];
hadNoEffect: EvaledPatch[];
undoingPatchGroup: EvaledPatch[];
erroredPatch: EvaledPatch[];
};
failedWebpack: Record<TypeWebpackSearchHistory, string[][]>;
}
export const reporterData: ReporterData = {
failedPatches: {
foundNoModule: [],
hadNoEffect: [],
undoingPatchGroup: [],
erroredPatch: []
},
failedWebpack: {
find: [],
findByProps: [],
findByCode: [],
findStore: [],
findComponent: [],
findComponentByCode: [],
findExportedComponent: [],
waitFor: [],
waitForComponent: [],
waitForStore: [],
proxyLazyWebpack: [],
LazyComponentWebpack: [],
extractAndLoadChunks: [],
mapMangledModule: []
}
};

View file

@ -5,49 +5,13 @@
*/ */
import { Logger } from "@utils/Logger"; import { Logger } from "@utils/Logger";
import { Patch } from "@utils/types";
import * as Webpack from "@webpack"; import * as Webpack from "@webpack";
import { patches } from "plugins"; import { patches } from "plugins";
import { loadLazyChunks } from "./loadLazyChunks"; import { loadLazyChunks } from "./loadLazyChunks";
import { reporterData } from "./reporterData";
const ReporterLogger = new Logger("Reporter"); const ReporterLogger = new Logger("Reporter");
interface EvaledPatch extends Patch {
id: number | string;
}
interface ReporterData {
failedPatches: {
foundNoModule: Patch[];
hadNoEffect: EvaledPatch[];
undoingPatchGroup: EvaledPatch[];
erroredPatch: EvaledPatch[];
};
failedWebpack: Record<Webpack.TypeWebpackSearchHistory, string[][]>;
}
export const reporterData: ReporterData = {
failedPatches: {
foundNoModule: [],
hadNoEffect: [],
undoingPatchGroup: [],
erroredPatch: []
},
failedWebpack: {
find: [],
findByProps: [],
findByCode: [],
findStore: [],
findComponent: [],
findComponentByCode: [],
findExportedComponent: [],
waitFor: [],
waitForComponent: [],
waitForStore: [],
proxyLazyWebpack: [],
LazyComponentWebpack: [],
extractAndLoadChunks: [],
mapMangledModule: []
}
};
async function runReporter() { async function runReporter() {
try { try {
ReporterLogger.log("Starting test..."); ReporterLogger.log("Starting test...");

View file

@ -23,7 +23,7 @@ import { Logger } from "@utils/Logger";
import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches"; import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches";
import definePlugin, { OptionType, ReporterTestable } from "@utils/types"; import definePlugin, { OptionType, ReporterTestable } from "@utils/types";
import { filters, findAll, search, wreq } from "@webpack"; import { filters, findAll, search, wreq } from "@webpack";
import { reporterData } from "debug/runReporter"; import { reporterData } from "debug/reporterData";
import { extractModule, extractOrThrow, FindData, findModuleId, FindType, mkRegexFind, parseNode, PatchData, SendData } from "./util"; import { extractModule, extractOrThrow, FindData, findModuleId, FindType, mkRegexFind, parseNode, PatchData, SendData } from "./util";
@ -69,11 +69,13 @@ function initWs(isManual = false) {
ok: true, ok: true,
}); });
// if we are running the reporter with companion integration, send the list to vscode as soon as we can // if we are running the reporter with companion integration, send the list to vscode as soon as we can
replyData({ if (IS_COMPANION_TEST) {
type: "report", replyData({
data: reporterData, type: "report",
ok: true data: reporterData,
}); ok: true
});
}
(settings.store.notifyOnAutoConnect || isManual) && showNotification({ (settings.store.notifyOnAutoConnect || isManual) && showNotification({
title: "Dev Companion Connected", title: "Dev Companion Connected",

View file

@ -20,7 +20,7 @@ import { WEBPACK_CHUNK } from "@utils/constants";
import { Logger } from "@utils/Logger"; import { Logger } from "@utils/Logger";
import { canonicalizeReplacement } from "@utils/patches"; import { canonicalizeReplacement } from "@utils/patches";
import { PatchReplacement } from "@utils/types"; import { PatchReplacement } from "@utils/types";
import { reporterData } from "debug/runReporter"; import { reporterData } from "debug/reporterData";
import { WebpackInstance } from "discord-types/other"; import { WebpackInstance } from "discord-types/other";
import { traceFunction } from "../debug/Tracer"; import { traceFunction } from "../debug/Tracer";
@ -357,10 +357,11 @@ function patchFactories(factories: Record<string, (module: any, exports: any, re
if (patch.group) { if (patch.group) {
logger.warn(`Undoing patch group ${patch.find} by ${patch.plugin} because replacement ${replacement.match} errored`); logger.warn(`Undoing patch group ${patch.find} by ${patch.plugin} because replacement ${replacement.match} errored`);
reporterData.failedPatches.undoingPatchGroup.push({ if (IS_COMPANION_TEST)
...patch, reporterData.failedPatches.undoingPatchGroup.push({
id ...patch,
}); id
});
mod = previousMod; mod = previousMod;
code = previousCode; code = previousCode;
break; break;