mirror of
https://github.com/Equicord/Equicord.git
synced 2025-01-17 21:03:28 -05:00
Update DevComp to PR
This commit is contained in:
parent
218dadbe04
commit
93ec8dbe7a
10 changed files with 58 additions and 16 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -26,3 +26,6 @@ ExtensionCache/
|
|||
settings/
|
||||
|
||||
src/equicordplugins/usrpe
|
||||
|
||||
# vencord companion module cache
|
||||
.modules
|
||||
|
|
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
|
@ -18,5 +18,6 @@
|
|||
"domain": "codeberg.org",
|
||||
"type": "Gitea"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"equicord-companion.showSidebar": true,
|
||||
}
|
21
.vscode/tasks.json
vendored
21
.vscode/tasks.json
vendored
|
@ -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",
|
||||
|
@ -41,4 +60,4 @@
|
|||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -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[];
|
||||
|
|
|
@ -17,7 +17,7 @@ interface ErroredPatch extends EvaledPatch {
|
|||
oldModule: string,
|
||||
newModule: string;
|
||||
}
|
||||
interface ReporterData {
|
||||
export interface ReporterData {
|
||||
failedPatches: {
|
||||
foundNoModule: Patch[];
|
||||
hadNoEffect: EvaledPatch[];
|
||||
|
|
|
@ -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,7 +61,9 @@ export default definePlugin({
|
|||
},
|
||||
|
||||
start() {
|
||||
initWs();
|
||||
// if we're running the reporter, we need to initws in the reporter file to avoid a race condition
|
||||
if (!IS_COMPANION_TEST)
|
||||
initWs();
|
||||
},
|
||||
|
||||
stop: stopWs,
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -5,3 +5,4 @@
|
|||
*/
|
||||
|
||||
export * as Recieve from "./recieve";
|
||||
export * as Send from "./send";
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue