Update Dev Companion
This commit is contained in:
parent
04a03bc851
commit
ed559e94e1
3 changed files with 15 additions and 2 deletions
|
|
@ -23,7 +23,7 @@ import definePlugin, { OptionType, ReporterTestable } from "@utils/types";
|
|||
|
||||
import { initWs, socket, stopWs } from "./initWs";
|
||||
export const PORT = 8485;
|
||||
export const CLIENT_VERSION: readonly [major: number, minor: number, patch: number] = [0, 1, 1];
|
||||
export const CLIENT_VERSION: readonly [major: number, minor: number, patch: number] = [0, 1, 2];
|
||||
|
||||
export const logger = new Logger("DevCompanion");
|
||||
|
||||
|
|
|
|||
|
|
@ -329,6 +329,8 @@ export function initWs(isManual = false) {
|
|||
|
||||
if (src.startsWith("function(")) {
|
||||
src = "0," + src;
|
||||
} else if (src.charCodeAt(0) >= 49 /* 1*/ && src.charCodeAt(0) <= 57 /* 9*/) {
|
||||
src = "0,function" + src.substring(src.indexOf("("));
|
||||
}
|
||||
|
||||
let i = 0;
|
||||
|
|
|
|||
|
|
@ -45,11 +45,22 @@ export function extractModule(id: PropertyKey, patched = companionSettings.store
|
|||
}
|
||||
return extractUnpatchedModule(id);
|
||||
}
|
||||
|
||||
// FIXME: maybe update companion to support new style later
|
||||
function getNormalizedModuleText(id_: PropertyKey): string {
|
||||
const id = String(id_);
|
||||
if (Number.isNaN(parseInt(String(id), 10))) {
|
||||
throw new Error("can't normalize module with non-numeric id");
|
||||
}
|
||||
const moduleText = wreq.m[id].toString();
|
||||
return "function" + moduleText.substring(moduleText.indexOf("("));
|
||||
}
|
||||
|
||||
function extractUnpatchedModule(id: PropertyKey): string {
|
||||
if (!wreq.m[id]) {
|
||||
throw new Error(`Module not found for id: ${String(id)}`);
|
||||
}
|
||||
return `// Webpack Module ${String(id)} - Patched by\n0,${wreq.m[id]}\n//# sourceURL=WebpackModule${String(id)}`;
|
||||
return `// Webpack Module ${String(id)} - Patched by\n0,${getNormalizedModuleText(id)}\n//# sourceURL=WebpackModule${String(id)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue