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

Method sendMessage

packages/message/extension_message.ts:19–31  ·  view source on GitHub ↗
(data: TMessage)

Source from the content-addressed store, hash-verified

17
18 // 发送消息 注意不进行回调的内存泄漏
19 sendMessage<T = any>(data: TMessage): Promise<T> {
20 return new Promise((resolve: ((value: T) => void) | null) => {
21 chrome.runtime.sendMessage(data, (resp: T) => {
22 const lastError = chrome.runtime.lastError;
23 if (lastError) {
24 console.error("chrome.runtime.lastError in chrome.runtime.sendMessage:", lastError);
25 // 通信API出错不回继续对话
26 }
27 resolve!(resp);
28 resolve = null;
29 });
30 });
31 }
32
33 tryEnableUserScriptConnectionListener = (..._args: any) => {
34 // empty function

Callers

nothing calls this directly

Calls 2

errorMethod · 0.80
sendMessageMethod · 0.65

Tested by

no test coverage detected