/** * `Client` makes it easy to send message to background * and enable to handle response with Promise. * @constructor * @param {object} module is expected to be like [chrome.runtime], which has `sendMessage` method. * @param {bool} strict specifies the response to be with `status: 200`, otherwise rejection of Promise would be thrown. * @param {string} method is a method name which should be invoked, belonging to `module`. */ export declare class Client { /** * @static for * This is just a shorthand of `(new Client(chrome.tabs)).tab(123) // == TargetedClient` * This is kind of insignificant and useless method. * Just want to chain constructor and `tab`, * like this `Client.for(chrome.tabs, 123).message()` */ static for(module: any, id: any, strict?: boolean, method?: string): TargettedClient; /** * `connect` provides a client for long-lived connected port client. * @see https://developer.chrome.com/extensions/runtime#method-connect * @see https://developer.chrome.com/extensions/tabs#method-connect * @param {object} module is either `chrome.runtime` or `chrome.tabs` * @param {string} id might be either `extensionId` or `tabId` * @param {object} info might be `connectInfo` */ static connect(module: any, id?: any, info?: {}): Client; private module; private method; private strict; constructor(module: any, strict?: boolean, method?: string); /** * `message` is a shorthand to send message to (for example) background. * @param {string} name might be routing name to match (or to be resolved). * @param {object} params might be parameters to pass to controller. * @return {Promise} Result Promise */ message(action: string | object, param?: object, callback?: (response: any) => any): Promise; /** * tab */ tab(tabId: any, strict?: boolean, method?: string): TargettedClient; /** * `_expandArgumentsForChromeMethod` expands given arguments to `message` method, * so that the original method of (for example) `chrome.runtime.sendMessage` * can handle that arguments. * @param {array} args arguments give to `message` method. * @param {function} resolve to resolve Response Promise. * @param {function} reject to reject Response Promise. */ protected _expandArgumentsForChromeMethod(args: any, resolve: any, reject: any): any; /** * `_isStrictMode` * @private * @param {array} givenArgs * @return {bool} */ private _isStrictMode; /** * `_finally` just dispatch resolve / reject conditions. */ private _finally; } /** * TargetedClient converts given arguments to arguments for chrome.tabs.sendMessage * because it requires `tabId` for the first argument. */ export declare class TargettedClient extends Client { tabId: any; constructor(tabId: any, module: any, strict?: boolean, method?: string); /** * @override */ protected _expandArgumentsForChromeMethod(args: any, resolve: any, reject: any): any; }