MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / sendMessage

Function sendMessage

packages/message/client.ts:5–20  ·  view source on GitHub ↗
(msgSender: MessageSend, action: string, data?: any)

Source from the content-addressed store, hash-verified

3import Logger from "@App/app/logger/logger";
4
5export async function sendMessage<T = any>(msgSender: MessageSend, action: string, data?: any): Promise<T | undefined> {
6 const res = await msgSender.sendMessage<TMessageCommCode<T> | TMessageCommAction<T>>({ action, data });
7 const logger = LoggerCore.getInstance().logger().with({ action, data, response: res });
8 logger.trace("sendMessage");
9 if (res?.code) {
10 console.error(res);
11 throw res.message;
12 } else {
13 try {
14 return res.data;
15 } catch (e) {
16 logger.trace("Invalid response data", Logger.E(e));
17 return undefined;
18 }
19 }
20}
21
22export function connect(msgSender: MessageSend, action: string, data?: any): Promise<MessageConnect> {
23 return msgSender.connect({ action, data });

Callers 15

handlerFunction · 0.90
setSandboxLanguageFunction · 0.90
enableScriptFunction · 0.90
disableScriptFunction · 0.90
runScriptFunction · 0.90
stopScriptFunction · 0.90
pushValueUpdateMethod · 0.90
emitEventToTabMethod · 0.90
GM_openInTabMethod · 0.90
GM_setClipboardMethod · 0.90
preparationSandboxFunction · 0.90

Calls 6

withMethod · 0.80
getInstanceMethod · 0.80
traceMethod · 0.80
errorMethod · 0.80
EMethod · 0.80
loggerMethod · 0.45

Tested by

no test coverage detected