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
"label": "BuildCompanionReporter",
"label": "Build Companion Reporter",
"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",
"command": "pnpm build --dev",
"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 { Patch } from "@utils/types";
import * as Webpack from "@webpack";
import { patches } from "plugins";
import { loadLazyChunks } from "./loadLazyChunks";
import { reporterData } from "./reporterData";
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() {
try {
ReporterLogger.log("Starting test...");

View file

@ -23,7 +23,7 @@ import { Logger } from "@utils/Logger";
import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches";
import definePlugin, { OptionType, ReporterTestable } from "@utils/types";
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";
@ -69,11 +69,13 @@ function initWs(isManual = false) {
ok: true,
});
// if we are running the reporter with companion integration, send the list to vscode as soon as we can
if (IS_COMPANION_TEST) {
replyData({
type: "report",
data: reporterData,
ok: true
});
}
(settings.store.notifyOnAutoConnect || isManual) && showNotification({
title: "Dev Companion Connected",

View file

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