mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-10 18:06:22 +00:00
fix serialization and race cond
This commit is contained in:
parent
d188a93a6c
commit
c365c86a49
3 changed files with 18 additions and 27 deletions
|
@ -7,6 +7,7 @@
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import * as Webpack from "@webpack";
|
import * as Webpack from "@webpack";
|
||||||
import { patches } from "plugins";
|
import { patches } from "plugins";
|
||||||
|
import { initWs } from "plugins/devCompanion.dev/initWs";
|
||||||
|
|
||||||
import { loadLazyChunks } from "./loadLazyChunks";
|
import { loadLazyChunks } from "./loadLazyChunks";
|
||||||
import { reporterData } from "./reporterData";
|
import { reporterData } from "./reporterData";
|
||||||
|
@ -78,11 +79,13 @@ async function runReporter() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if we are running the reporter with companion integration, send the list to vscode as soon as we can
|
||||||
|
if(IS_COMPANION_TEST)
|
||||||
|
initWs();
|
||||||
ReporterLogger.log("Finished test");
|
ReporterLogger.log("Finished test");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ReporterLogger.log("A fatal error occurred:", e);
|
ReporterLogger.log("A fatal error occurred:", e);
|
||||||
}
|
}
|
||||||
console.log(reporterData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// imported in webpack for reporterData, wrap to avoid running reporter
|
// imported in webpack for reporterData, wrap to avoid running reporter
|
||||||
|
|
|
@ -20,7 +20,6 @@ import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import definePlugin, { OptionType, ReporterTestable } from "@utils/types";
|
import definePlugin, { OptionType, ReporterTestable } from "@utils/types";
|
||||||
import { reporterData } from "debug/reporterData";
|
|
||||||
|
|
||||||
import { initWs, socket, stopWs } from "./initWs";
|
import { initWs, socket, stopWs } from "./initWs";
|
||||||
console.log("imported");
|
console.log("imported");
|
||||||
|
@ -58,8 +57,8 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
console.log(123);
|
// if were running the reporter, we need to initws in the reporter file to avoid a race condition
|
||||||
console.log(reporterData);
|
if (!IS_COMPANION_TEST)
|
||||||
initWs();
|
initWs();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
import { showNotification } from "@api/Notifications";
|
import { showNotification } from "@api/Notifications";
|
||||||
import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches";
|
import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches";
|
||||||
import { Patch } from "@utils/types";
|
|
||||||
import { filters, findAll, search, wreq } from "@webpack";
|
import { filters, findAll, search, wreq } from "@webpack";
|
||||||
import { reporterData } from "debug/reporterData";
|
import { reporterData } from "debug/reporterData";
|
||||||
|
|
||||||
|
@ -40,29 +39,19 @@ export function initWs(isManual = false) {
|
||||||
data: Object.keys(wreq.m),
|
data: Object.keys(wreq.m),
|
||||||
ok: true,
|
ok: true,
|
||||||
});
|
});
|
||||||
// if we are running the reporter with companion integration, send the list to vscode as soon as we can
|
|
||||||
if (IS_COMPANION_TEST) {
|
if (IS_COMPANION_TEST) {
|
||||||
const toSend = reporterData;
|
const toSend = JSON.stringify(reporterData, (_k, v) => {
|
||||||
for (const i in toSend.failedPatches) {
|
if (v instanceof RegExp)
|
||||||
for (const j in toSend.failedPatches[i]) {
|
return String(v);
|
||||||
const patch: Patch = toSend.failedPatches[i][j];
|
return v;
|
||||||
if (patch.find instanceof RegExp)
|
|
||||||
patch.find = String(patch.find);
|
|
||||||
if (!Array.isArray(patch.replacement))
|
|
||||||
patch.replacement = [patch.replacement];
|
|
||||||
patch.replacement = patch.replacement.map(v => {
|
|
||||||
return {
|
|
||||||
match: String(v.match),
|
|
||||||
replace: String(v.replace)
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
socket?.send(JSON.stringify({
|
||||||
replyData({
|
|
||||||
type: "report",
|
type: "report",
|
||||||
data: toSend,
|
data: JSON.parse(toSend),
|
||||||
ok: true
|
ok: true
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue