From b2a37b8fc3e273dd71e1e3558c58be8002aa3789 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Thu, 26 Mar 2020 22:17:00 +0900 Subject: Query completions on open command by a completion source --- src/console/clients/CompletionClient.ts | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/console/clients/CompletionClient.ts (limited to 'src/console/clients') diff --git a/src/console/clients/CompletionClient.ts b/src/console/clients/CompletionClient.ts new file mode 100644 index 0000000..d5f9b01 --- /dev/null +++ b/src/console/clients/CompletionClient.ts @@ -0,0 +1,54 @@ +import * as messages from "../../shared/messages"; +import { + ConsoleGetCompletionTypesResponse, + ConsoleRequestBookmarksResponse, + ConsoleRequestHistoryResponse, ConsoleRequestSearchEnginesResponse +} from "../../shared/messages"; +import CompletionType from "../../shared/CompletionType"; + +export type SearchEngines = { + title: string +} + +export type BookmarkItem = { + title: string + url: string +} + +export type HistoryItem = { + title: string + url: string +} + +export default class CompletionClient { + async getCompletionTypes(): Promise { + const resp = await browser.runtime.sendMessage({ + type: messages.CONSOLE_GET_COMPLETION_TYPES, + }) as ConsoleGetCompletionTypesResponse; + return resp; + } + + async requestSearchEngines(query: string): Promise { + const resp = await browser.runtime.sendMessage({ + type: messages.CONSOLE_REQUEST_SEARCH_ENGINES_MESSAGE, + query, + }) as ConsoleRequestSearchEnginesResponse; + return resp; + } + + async requestBookmarks(query: string): Promise { + const resp = await browser.runtime.sendMessage({ + type: messages.CONSOLE_REQUEST_BOOKMARKS, + query, + }) as ConsoleRequestBookmarksResponse; + return resp; + } + + async requestHistory(query: string): Promise { + const resp = await browser.runtime.sendMessage({ + type: messages.CONSOLE_REQUEST_HISTORY, + query, + }) as ConsoleRequestHistoryResponse; + return resp; + } +} -- cgit v1.2.3