Update DevComp to PR

This commit is contained in:
thororen1234 2025-01-09 10:37:02 -05:00
parent 218dadbe04
commit 93ec8dbe7a
10 changed files with 58 additions and 16 deletions

3
.gitignore vendored
View file

@ -26,3 +26,6 @@ ExtensionCache/
settings/
src/equicordplugins/usrpe
# vencord companion module cache
.modules

View file

@ -18,5 +18,6 @@
"domain": "codeberg.org",
"type": "Gitea"
}
]
],
"equicord-companion.showSidebar": true,
}

19
.vscode/tasks.json vendored
View file

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

View file

@ -18,7 +18,7 @@
import { waitFor } from "@webpack";
let NoticesModule: any;
export let NoticesModule: any;
waitFor(m => m.show && m.dismiss && !m.suppressAll, m => NoticesModule = m);
export const noticesQueue = [] as any[];

View file

@ -17,7 +17,7 @@ interface ErroredPatch extends EvaledPatch {
oldModule: string,
newModule: string;
}
interface ReporterData {
export interface ReporterData {
failedPatches: {
foundNoModule: Patch[];
hadNoEffect: EvaledPatch[];

View file

@ -22,7 +22,9 @@ import { Logger } from "@utils/Logger";
import definePlugin, { OptionType, ReporterTestable } from "@utils/types";
import { initWs, socket, stopWs } from "./initWs";
console.log("imported");
export const PORT = 8485;
const NAV_ID = "dev-companion-reconnect";
export const logger = new Logger("DevCompanion");
@ -59,6 +61,8 @@ export default definePlugin({
},
start() {
// if we're running the reporter, we need to initws in the reporter file to avoid a race condition
if (!IS_COMPANION_TEST)
initWs();
},

View file

@ -10,11 +10,11 @@ import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches";
import { filters, findAll, search, wreq } from "@webpack";
import { React, Toasts, useState } from "@webpack/common";
import { loadLazyChunks } from "debug/loadLazyChunks";
import { reporterData } from "debug/reporterData";
import { Settings } from "Vencord";
import { logger, PORT, settings } from ".";
import { Recieve } from "./types";
import { FullOutgoingMessage, OutgoingMessage } from "./types/send";
import { Recieve, Send } from "./types";
import { extractModule, extractOrThrow, findModuleId, mkRegexFind, parseNode, toggleEnabled, } from "./util";
export function stopWs() {
@ -29,7 +29,7 @@ export function initWs(isManual = false) {
let hasErrored = false;
const ws = socket = new WebSocket(`ws://localhost:${PORT}`);
function replyData(data: OutgoingMessage) {
function replyData(data: Send.OutgoingMessage) {
ws.send(JSON.stringify(data));
}
@ -47,6 +47,21 @@ export function initWs(isManual = false) {
ok: true
});
if (IS_COMPANION_TEST) {
const toSend = JSON.stringify(reporterData, (_k, v) => {
if (v instanceof RegExp)
return String(v);
return v;
});
socket?.send(JSON.stringify({
type: "report",
data: JSON.parse(toSend),
ok: true
}));
}
try {
if (settings.store.notifyOnAutoConnect || isManual) {
Toasts.show({
@ -112,8 +127,8 @@ export function initWs(isManual = false) {
ws.send(JSON.stringify(data));
}
function replyData(data: OutgoingMessage) {
const toSend: FullOutgoingMessage = {
function replyData(data: Send.OutgoingMessage) {
const toSend: Send.FullOutgoingMessage = {
...data,
nonce: d.nonce
};
@ -290,7 +305,6 @@ export function initWs(isManual = false) {
case "testPatch": {
const m = d.data;
let candidates;
console.log(m.find.toString());
if (d.data.findType === "string")
candidates = search(m.find.toString());

View file

@ -5,3 +5,4 @@
*/
export * as Recieve from "./recieve";
export * as Send from "./send";

View file

@ -5,8 +5,8 @@
*/
// should be the same types as src/server/types/recieve.ts in the companion
import { reporterData } from "debug/reporterData";
export type ReporterData = typeof reporterData;
import { ReporterData as IReporterData } from "debug/reporterData";
export type ReporterData = IReporterData;
export type OutgoingMessage = (Report | DiffModule | ExtractModule | ModuleList | RawId) & Base;
export type FullOutgoingMessage = OutgoingMessage & Nonce;

View file

@ -11,7 +11,7 @@ import { CodeFilter, stringMatches, wreq } from "@webpack";
import { Toasts } from "@webpack/common";
import { settings as companionSettings } from ".";
import { FindNode } from "./types/recieve";
import { Recieve } from "./types";
/**
* extracts the patched module, if there is no patched module, throws an error
@ -37,7 +37,7 @@ export function extractModule(id: number, patched = companionSettings.store.useP
throw new Error("No module found for module id:" + id);
return patched ? module.$$vencordPatchedSource ?? module.original.toString() : module.original.toString();
}
export function parseNode(node: FindNode): any {
export function parseNode(node: Recieve.FindNode): any {
switch (node.type) {
case "string":
return node.value;