import * as messages from "../../shared/messages"; export default interface FindClient { findNext(tabId: number, frameId: number, keyword: string): Promise; findPrev(tabId: number, frameId: number, keyword: string): Promise; clearSelection(tabId: number, frameId: number): Promise; } export class FindClientImpl implements FindClient { async findNext( tabId: number, frameId: number, keyword: string ): Promise { const found = (await browser.tabs.sendMessage( tabId, { type: messages.FIND_NEXT, keyword }, { frameId } )) as boolean; return found; } async findPrev( tabId: number, frameId: number, keyword: string ): Promise { const found = (await browser.tabs.sendMessage( tabId, { type: messages.FIND_PREV, keyword }, { frameId } )) as boolean; return found; } clearSelection(tabId: number, frameId: number): Promise { return browser.tabs.sendMessage( tabId, { type: messages.FIND_CLEAR_SELECTION }, { frameId } ); } }