mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-10 18:06:22 +00:00
add diffing and start work on reporter GUI
This commit is contained in:
parent
219c764680
commit
da01d52e50
4 changed files with 71 additions and 32 deletions
|
@ -11,7 +11,36 @@ import { patches } from "plugins";
|
||||||
import { loadLazyChunks } from "./loadLazyChunks";
|
import { loadLazyChunks } from "./loadLazyChunks";
|
||||||
|
|
||||||
const ReporterLogger = new Logger("Reporter");
|
const ReporterLogger = new Logger("Reporter");
|
||||||
|
interface ReporterData {
|
||||||
|
failedPatches: {
|
||||||
|
/**
|
||||||
|
* pluginName > array of failed modules
|
||||||
|
*/
|
||||||
|
foundNoModule: Record<string, string[]>;
|
||||||
|
};
|
||||||
|
failedWebpack: Record<Webpack.TypeWebpackSearchHistory, string[][]>;
|
||||||
|
}
|
||||||
|
const reporterData: ReporterData = {
|
||||||
|
failedPatches: {
|
||||||
|
foundNoModule: {}
|
||||||
|
},
|
||||||
|
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...");
|
||||||
|
@ -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})`;
|
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(", ")})`;
|
else logMessage += `(${args.map(arg => `"${arg}"`).join(", ")})`;
|
||||||
|
reporterData.failedWebpack[method].push(args.map(a => String(a)));
|
||||||
ReporterLogger.log("Webpack Find Fail:", logMessage);
|
ReporterLogger.log("Webpack Find Fail:", logMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,3 +111,4 @@ async function runReporter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
runReporter();
|
runReporter();
|
||||||
|
console.log(reporterData);
|
||||||
|
|
|
@ -131,6 +131,7 @@ function initWs(isManual = false) {
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "diff": {
|
case "diff": {
|
||||||
|
try {
|
||||||
const { extractType, idOrSearch } = data;
|
const { extractType, idOrSearch } = data;
|
||||||
switch (extractType) {
|
switch (extractType) {
|
||||||
case "id": {
|
case "id": {
|
||||||
|
@ -149,18 +150,24 @@ function initWs(isManual = false) {
|
||||||
}
|
}
|
||||||
case "search": {
|
case "search": {
|
||||||
const moduleId = +findModuleId([idOrSearch.toString()]);
|
const moduleId = +findModuleId([idOrSearch.toString()]);
|
||||||
|
const p = extractOrThrow(moduleId);
|
||||||
|
const p2 = extractModule(moduleId, false);
|
||||||
|
console.log(p, p2, "done");
|
||||||
replyData({
|
replyData({
|
||||||
type: "diff",
|
type: "diff",
|
||||||
ok: true,
|
ok: true,
|
||||||
data: {
|
data: {
|
||||||
patched: extractOrThrow(moduleId),
|
patched: p,
|
||||||
source: extractModule(moduleId, false)
|
source: p2
|
||||||
},
|
},
|
||||||
moduleNumber: moduleId
|
moduleNumber: moduleId
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
reply(String(error));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "extract": {
|
case "extract": {
|
||||||
|
|
|
@ -63,7 +63,7 @@ export function extractModule(id: number, patched = settings.store.usePatchedMod
|
||||||
const module = wreq.m[id];
|
const module = wreq.m[id];
|
||||||
if (!module)
|
if (!module)
|
||||||
throw new Error("No module found for module id:" + id);
|
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) {
|
} export function parseNode(node: Node) {
|
||||||
switch (node.type) {
|
switch (node.type) {
|
||||||
case "string":
|
case "string":
|
||||||
|
|
|
@ -287,7 +287,9 @@ export function findModuleFactory(...code: CodeFilter) {
|
||||||
return wreq.m[id];
|
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.
|
* This is just a wrapper around {@link proxyLazy} to make our reporter test for your webpack finds.
|
||||||
|
|
Loading…
Reference in a new issue