import { injectable } from "tsyringe"; import * as messages from "../../shared/messages"; export default interface ConsoleClient { showCommand(tabId: number, command: string): Promise; showFind(tabId: number): Promise; showInfo(tabId: number, message: string): Promise; showError(tabId: number, message: string): Promise; hide(tabId: number): Promise; } @injectable() export class ConsoleClientImpl implements ConsoleClient { showCommand(tabId: number, command: string): Promise { return browser.tabs.sendMessage(tabId, { type: messages.CONSOLE_SHOW_COMMAND, command, }); } showFind(tabId: number): Promise { return browser.tabs.sendMessage(tabId, { type: messages.CONSOLE_SHOW_FIND, }); } showInfo(tabId: number, message: string): Promise { return browser.tabs.sendMessage(tabId, { type: messages.CONSOLE_SHOW_INFO, text: message, }); } showError(tabId: number, message: string): Promise { return browser.tabs.sendMessage(tabId, { type: messages.CONSOLE_SHOW_ERROR, text: message, }); } hide(tabId: number): Promise { return browser.tabs.sendMessage(tabId, { type: messages.CONSOLE_HIDE, }); } }