diff --git a/src/debug/runReporter.ts b/src/debug/runReporter.ts index ddd5e5f18..2cce25bd1 100644 --- a/src/debug/runReporter.ts +++ b/src/debug/runReporter.ts @@ -11,7 +11,36 @@ import { patches } from "plugins"; import { loadLazyChunks } from "./loadLazyChunks"; const ReporterLogger = new Logger("Reporter"); - +interface ReporterData { + failedPatches: { + /** + * pluginName > array of failed modules + */ + foundNoModule: Record; + }; + failedWebpack: Record; +} +const reporterData: ReporterData = { + failedPatches: { + foundNoModule: {} + }, + failedWebpack: { + find: [[]], + findByProps: [[]], + findByCode: [[]], + findStore: [[]], + findComponent: [[]], + findComponentByCode: [[]], + findExportedComponent: [[]], + waitFor: [[]], + waitForComponent: [[]], + waitForStore: [[]], + proxyLazyWebpack: [[]], + LazyComponentWebpack: [[]], + extractAndLoadChunks: [[]], + mapMangledModule: [[]] + } +}; async function runReporter() { try { ReporterLogger.log("Starting test..."); @@ -70,7 +99,7 @@ async function runReporter() { logMessage += `("${args[0]}", {\n${failedMappings.map(mapping => `\t${mapping}: ${args[1][mapping].toString().slice(0, 147)}...`).join(",\n")}\n})`; } else logMessage += `(${args.map(arg => `"${arg}"`).join(", ")})`; - + reporterData.failedWebpack[method].push(args.map(a => String(a))); ReporterLogger.log("Webpack Find Fail:", logMessage); } } @@ -82,3 +111,4 @@ async function runReporter() { } runReporter(); +console.log(reporterData); diff --git a/src/plugins/devCompanion.dev/index.tsx b/src/plugins/devCompanion.dev/index.tsx index edfb0fec5..4a479ce54 100644 --- a/src/plugins/devCompanion.dev/index.tsx +++ b/src/plugins/devCompanion.dev/index.tsx @@ -131,35 +131,42 @@ function initWs(isManual = false) { switch (type) { case "diff": { - const { extractType, idOrSearch } = data; - switch (extractType) { - case "id": { - if (typeof idOrSearch !== "number") - throw new Error("Id is not a number, got :" + typeof idOrSearch); - replyData({ - type: "diff", - ok: true, - data: { - patched: extractOrThrow(idOrSearch), - source: extractModule(idOrSearch, false) - }, - moduleNumber: idOrSearch - }); - break; - } - case "search": { - const moduleId = +findModuleId([idOrSearch.toString()]); - replyData({ - type: "diff", - ok: true, - data: { - patched: extractOrThrow(moduleId), - source: extractModule(moduleId, false) - }, - moduleNumber: moduleId - }); - break; + try { + const { extractType, idOrSearch } = data; + switch (extractType) { + case "id": { + if (typeof idOrSearch !== "number") + throw new Error("Id is not a number, got :" + typeof idOrSearch); + replyData({ + type: "diff", + ok: true, + data: { + patched: extractOrThrow(idOrSearch), + source: extractModule(idOrSearch, false) + }, + moduleNumber: idOrSearch + }); + break; + } + case "search": { + const moduleId = +findModuleId([idOrSearch.toString()]); + const p = extractOrThrow(moduleId); + const p2 = extractModule(moduleId, false); + console.log(p, p2, "done"); + replyData({ + type: "diff", + ok: true, + data: { + patched: p, + source: p2 + }, + moduleNumber: moduleId + }); + break; + } } + } catch (error) { + reply(String(error)); } break; } diff --git a/src/plugins/devCompanion.dev/util.tsx b/src/plugins/devCompanion.dev/util.tsx index 6240e49c4..a681c6eb2 100644 --- a/src/plugins/devCompanion.dev/util.tsx +++ b/src/plugins/devCompanion.dev/util.tsx @@ -63,7 +63,7 @@ export function extractModule(id: number, patched = settings.store.usePatchedMod const module = wreq.m[id]; if (!module) throw new Error("No module found for module id:" + id); - return patched ? module.$$vencordPatchedSource ?? module.original : module.original; + return patched ? module.$$vencordPatchedSource ?? module.original.toString() : module.original.toString(); } export function parseNode(node: Node) { switch (node.type) { case "string": diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts index 19519d647..bbc60de4c 100644 --- a/src/webpack/webpack.ts +++ b/src/webpack/webpack.ts @@ -287,7 +287,9 @@ export function findModuleFactory(...code: CodeFilter) { return wreq.m[id]; } -export const lazyWebpackSearchHistory = [] as Array<["find" | "findByProps" | "findByCode" | "findStore" | "findComponent" | "findComponentByCode" | "findExportedComponent" | "waitFor" | "waitForComponent" | "waitForStore" | "proxyLazyWebpack" | "LazyComponentWebpack" | "extractAndLoadChunks" | "mapMangledModule", any[]]>; +// FIXME: give this a better name +export type TypeWebpackSearchHistory = "find" | "findByProps" | "findByCode" | "findStore" | "findComponent" | "findComponentByCode" | "findExportedComponent" | "waitFor" | "waitForComponent" | "waitForStore" | "proxyLazyWebpack" | "LazyComponentWebpack" | "extractAndLoadChunks" | "mapMangledModule"; +export const lazyWebpackSearchHistory = [] as Array<[TypeWebpackSearchHistory, any[]]>; /** * This is just a wrapper around {@link proxyLazy} to make our reporter test for your webpack finds.