UNPKG

@ng1005/chrome-extension-common

Version:

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

57 lines (56 loc) 1.66 kB
import { EventBusDemo } from "../message/EventBusDemo"; import IStorageInterface from "../interface/IStorageInterface"; import { RuntimeEventBus } from "../message/RuntimeEventBus"; import { KeyValue } from "../types/KeyValue"; declare class StorageDefaultService extends EventBusDemo implements IStorageInterface { script: string; _keys: KeyValue; keys: KeyValue; type: string; $runtimeBus: RuntimeEventBus; chromeVars: KeyValue; watchKeys: Array<string>; _events: Map<string, Function | Array<Function>>; chromeVar: any; constructor(type?: string, script?: string); /** * 重写方法 * @param name * @param callback * @returns */ $on(name: string, callback: Function): this; /** * 重写提交事件 * @param type 消息类型 * @param args 参数 * @returns */ $emit(type: string, ...args: any): Promise<any>; listenerWatch(): void; /** * 消息处理 * @param {*} request:any * @param {*} sender:chrome.runtime.MessageSender * @param {*} sendResponse:any */ handler(data: any, sender: chrome.runtime.MessageSender, sendResponse: any): Promise<void>; listener(): void; /** * 根据key获取数据 * @param {*} name */ get(name: string | Array<string>): Promise<any>; /** * 设置数据 * @param {*} name * @param {*} value */ set(name: string | Object, value?: any): Promise<any>; /** * 检查本次更新是否有需要监听的字短 * @param data */ checkWatch(data: KeyValue): Promise<void>; } export default StorageDefaultService;