UNPKG

@ng1005/chrome-extension-common

Version:

chrome扩展通用库--消息与storage

39 lines (38 loc) 1.17 kB
import MessageEventBus from "./MessageEventBus"; import { SendMessage } from "../utils/ResponseUtils"; import IMessageInterface from '../interface/IMessageInterface'; export declare class PortEventBus extends MessageEventBus implements IMessageInterface { script: string; port: chrome.runtime.Port | undefined; portTab: chrome.runtime.Port | undefined; popupListener: boolean; constructor(script?: string); /** * 链接(监听) */ connect(): this; /** * contentScript监听 */ popListener(): this; /** * 需要监听用来接收消息 */ listener(): this; /** * 检查链接 */ checkConnect(): this; /** * 消息处理 * @param {*} request */ handler(request: SendMessage): Promise<this | undefined>; $emitContent(type: string, ...args: any): Promise<any>; $emitBackground(type: string, ...args: any): Promise<any>; $emitPopup(type: string, ...args: any): Promise<any>; $emitWindow(type: string, ...args: any): Promise<any>; $emitAllTabs(type: string, ...args: any): Promise<any>; } declare const $bus: PortEventBus; export default $bus;