mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-07 21:53:04 -04:00
update companion (#243)
This commit is contained in:
parent
a7f1d87f08
commit
fe3777b1b0
6 changed files with 36 additions and 8 deletions
|
@ -61,9 +61,10 @@ 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();
|
||||
if (!IS_DEV) throw new Error("This plugin requires dev mode to run, please build with pnpm build --dev");
|
||||
initWs();
|
||||
},
|
||||
|
||||
stop: stopWs,
|
||||
});
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
import { popNotice, showNotice } from "@api/Notices";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { getIntlMessageFromHash } from "@utils/discord";
|
||||
import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches";
|
||||
import { filters, findAll, search, wreq } from "@webpack";
|
||||
import { React, Toasts, useState } from "@webpack/common";
|
||||
|
@ -125,7 +126,7 @@ export function initWs(isManual = false) {
|
|||
function reply(error?: string) {
|
||||
const toSend = { nonce: d.nonce, ok: !error } as Record<string, unknown>;
|
||||
if (error) toSend.error = error;
|
||||
logger.debug("Replying with:", toSend);
|
||||
logger.debug(`Replying with:`, toSend);
|
||||
ws.send(JSON.stringify(toSend));
|
||||
}
|
||||
function replyData(data: OutgoingMessage) {
|
||||
|
@ -437,8 +438,20 @@ export function initWs(isManual = false) {
|
|||
});
|
||||
break;
|
||||
}
|
||||
case "i18n": {
|
||||
const { hashedKey } = d.data;
|
||||
replyData({
|
||||
type: "i18n",
|
||||
ok: true,
|
||||
data: {
|
||||
value: getIntlMessageFromHash(hashedKey)
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
default:
|
||||
reply("Unknown Type " + (d as any).type);
|
||||
// @ts-expect-error should be never
|
||||
reply("Unknown Type " + d?.type);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -5,4 +5,3 @@
|
|||
*/
|
||||
|
||||
export * as Recieve from "./recieve";
|
||||
export * as Send from "./send";
|
||||
|
|
|
@ -62,7 +62,7 @@ export type FindData = {
|
|||
args: FindNode[];
|
||||
};
|
||||
|
||||
export type IncomingMessage = DisablePlugin | RawId | DiffPatch | Reload | ExtractModule | TestPatch | TestFind | AllModules;
|
||||
export type IncomingMessage = DisablePlugin | RawId | DiffPatch | Reload | ExtractModule | TestPatch | TestFind | AllModules | I18nLookup;
|
||||
export type FullIncomingMessage = IncomingMessage & { nonce: number; };
|
||||
|
||||
export type DisablePlugin = {
|
||||
|
@ -73,6 +73,13 @@ export type DisablePlugin = {
|
|||
};
|
||||
};
|
||||
|
||||
export type I18nLookup = {
|
||||
type: "i18n";
|
||||
data: {
|
||||
hashedKey: string;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated use {@link ExtractModule} instead
|
||||
*/
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import { ReporterData as IReporterData } from "debug/reporterData";
|
||||
export type ReporterData = IReporterData;
|
||||
|
||||
export type OutgoingMessage = (Report | DiffModule | ExtractModule | ModuleList | RawId) & Base;
|
||||
export type OutgoingMessage = (Report | DiffModule | ExtractModule | ModuleList | RawId | I18nValue) & Base;
|
||||
export type FullOutgoingMessage = OutgoingMessage & Nonce;
|
||||
|
||||
export type Base = {
|
||||
|
@ -34,6 +34,13 @@ export type ModuleResult = {
|
|||
};
|
||||
|
||||
// #region valid payloads
|
||||
export type I18nValue = {
|
||||
type: "i18n";
|
||||
data: {
|
||||
value: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type Report = {
|
||||
type: "report";
|
||||
data: ReporterData;
|
||||
|
|
|
@ -9,11 +9,12 @@ import { Settings } from "@api/Settings";
|
|||
import { canonicalizeMatch } from "@utils/patches";
|
||||
import { CodeFilter, stringMatches, wreq } from "@webpack";
|
||||
import { Toasts } from "@webpack/common";
|
||||
import { WebpackPatcher } from "Vencord";
|
||||
|
||||
import { logger, settings as companionSettings } from ".";
|
||||
import { FindNode } from "./types/recieve";
|
||||
|
||||
const { WebpackPatcher: { getFactoryPatchedBy, getFactoryPatchedSource } } = require("Vencord") as typeof import("Vencord");
|
||||
const { getFactoryPatchedBy, getFactoryPatchedSource } = WebpackPatcher;
|
||||
|
||||
/**
|
||||
* extracts the patched module, if there is no patched module, throws an error
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue