mirror of
https://github.com/Equicord/Equicord.git
synced 2025-02-24 00:59:09 -05:00
Fix Dev Companion Mostly
This commit is contained in:
parent
691b5cd2ed
commit
2aaf97518c
3 changed files with 18 additions and 4 deletions
|
@ -24,7 +24,6 @@ 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");
|
||||
|
||||
|
|
|
@ -9,20 +9,29 @@ import { Settings } from "@api/Settings";
|
|||
import { canonicalizeMatch } from "@utils/patches";
|
||||
import { CodeFilter, stringMatches, wreq } from "@webpack";
|
||||
import { Toasts } from "@webpack/common";
|
||||
import { AnyWebpackRequire } from "webpack";
|
||||
|
||||
import { settings as companionSettings } from ".";
|
||||
import { Recieve } from "./types";
|
||||
|
||||
const SYM_PATCHED_SOURCE = Symbol("WebpackPatcher.patchedSource");
|
||||
|
||||
function getFactoryPatchedSource(id: PropertyKey, webpackRequire = wreq as AnyWebpackRequire) {
|
||||
return webpackRequire.m[id]?.[SYM_PATCHED_SOURCE];
|
||||
}
|
||||
|
||||
/**
|
||||
* extracts the patched module, if there is no patched module, throws an error
|
||||
* @param id module id
|
||||
*/
|
||||
export function extractOrThrow(id: number): string {
|
||||
const module = wreq.m[id];
|
||||
if (!module?.$$vencordPatchedSource)
|
||||
const patchedSource = getFactoryPatchedSource(id);
|
||||
if (!patchedSource)
|
||||
throw new Error("No patched module found for module id " + id);
|
||||
return module.$$vencordPatchedSource;
|
||||
return patchedSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* attempts to extract the module, throws if not found
|
||||
*
|
||||
|
@ -35,8 +44,11 @@ export function extractModule(id: number, patched = companionSettings.store.useP
|
|||
const module = wreq.m[id];
|
||||
if (!module)
|
||||
throw new Error("No module found for module id:" + id);
|
||||
return patched ? module.$$vencordPatchedSource ?? module.original.toString() : module.original.toString();
|
||||
const original = module.toString();
|
||||
const patchedSource = getFactoryPatchedSource(id);
|
||||
return patched ? patchedSource ?? original : original;
|
||||
}
|
||||
|
||||
export function parseNode(node: Recieve.FindNode): any {
|
||||
switch (node.type) {
|
||||
case "string":
|
||||
|
|
|
@ -45,6 +45,9 @@
|
|||
"@webpack": [
|
||||
"./webpack/webpack"
|
||||
],
|
||||
"@webpack/patch": [
|
||||
"./webpack/patchWebpack"
|
||||
],
|
||||
"@plugins": [
|
||||
"./plugins"
|
||||
],
|
||||
|
|
Loading…
Add table
Reference in a new issue