diff options
Diffstat (limited to 'src/background/controllers')
-rw-r--r-- | src/background/controllers/AddonEnabledController.ts | 4 | ||||
-rw-r--r-- | src/background/controllers/CommandController.ts | 14 | ||||
-rw-r--r-- | src/background/controllers/FindController.ts | 6 | ||||
-rw-r--r-- | src/background/controllers/LinkController.ts | 12 | ||||
-rw-r--r-- | src/background/controllers/MarkController.ts | 10 | ||||
-rw-r--r-- | src/background/controllers/OperationController.ts | 13 | ||||
-rw-r--r-- | src/background/controllers/SettingController.ts | 8 | ||||
-rw-r--r-- | src/background/controllers/VersionController.ts | 6 | ||||
-rw-r--r-- | src/background/controllers/version.ts | 13 |
9 files changed, 52 insertions, 34 deletions
diff --git a/src/background/controllers/AddonEnabledController.ts b/src/background/controllers/AddonEnabledController.ts index 9a3a521..251af25 100644 --- a/src/background/controllers/AddonEnabledController.ts +++ b/src/background/controllers/AddonEnabledController.ts @@ -1,11 +1,13 @@ import AddonEnabledUseCase from '../usecases/AddonEnabledUseCase'; export default class AddonEnabledController { + private addonEnabledUseCase: AddonEnabledUseCase; + constructor() { this.addonEnabledUseCase = new AddonEnabledUseCase(); } - indicate(enabled) { + indicate(enabled: boolean): Promise<any> { return this.addonEnabledUseCase.indicate(enabled); } } diff --git a/src/background/controllers/CommandController.ts b/src/background/controllers/CommandController.ts index b113709..f3a6b7f 100644 --- a/src/background/controllers/CommandController.ts +++ b/src/background/controllers/CommandController.ts @@ -1,19 +1,23 @@ import CompletionsUseCase from '../usecases/CompletionsUseCase'; import CommandUseCase from '../usecases/CommandUseCase'; -import Completions from '../domains/Completions'; +import CompletionGroup from '../domains/CompletionGroup'; -const trimStart = (str) => { +const trimStart = (str: string): string => { // NOTE String.trimStart is available on Firefox 61 return str.replace(/^\s+/, ''); }; export default class CommandController { + private completionsUseCase: CompletionsUseCase; + + private commandIndicator: CommandUseCase; + constructor() { this.completionsUseCase = new CompletionsUseCase(); this.commandIndicator = new CommandUseCase(); } - getCompletions(line) { + getCompletions(line: string): Promise<CompletionGroup[]> { let trimmed = trimStart(line); let words = trimmed.split(/ +/); let name = words[0]; @@ -45,11 +49,11 @@ export default class CommandController { case 'set': return this.completionsUseCase.querySet(name, keywords); } - return Promise.resolve(Completions.empty()); + return Promise.resolve([]); } // eslint-disable-next-line complexity - exec(line) { + exec(line: string): Promise<any> { let trimmed = trimStart(line); let words = trimmed.split(/ +/); let name = words[0]; diff --git a/src/background/controllers/FindController.ts b/src/background/controllers/FindController.ts index caeff98..28959e2 100644 --- a/src/background/controllers/FindController.ts +++ b/src/background/controllers/FindController.ts @@ -1,15 +1,17 @@ import FindUseCase from '../usecases/FindUseCase'; export default class FindController { + private findUseCase: FindUseCase; + constructor() { this.findUseCase = new FindUseCase(); } - getKeyword() { + getKeyword(): Promise<string> { return this.findUseCase.getKeyword(); } - setKeyword(keyword) { + setKeyword(keyword: string): Promise<any> { return this.findUseCase.setKeyword(keyword); } } diff --git a/src/background/controllers/LinkController.ts b/src/background/controllers/LinkController.ts index 7e395b1..707b28a 100644 --- a/src/background/controllers/LinkController.ts +++ b/src/background/controllers/LinkController.ts @@ -1,15 +1,19 @@ import LinkUseCase from '../usecases/LinkUseCase'; export default class LinkController { + private linkUseCase: LinkUseCase; + constructor() { this.linkUseCase = new LinkUseCase(); } - openToTab(url, tabId) { - this.linkUseCase.openToTab(url, tabId); + openToTab(url: string, tabId: number): Promise<void> { + return this.linkUseCase.openToTab(url, tabId); } - openNewTab(url, openerId, background) { - this.linkUseCase.openNewTab(url, openerId, background); + openNewTab( + url: string, openerId: number, background: boolean, + ): Promise<void> { + return this.linkUseCase.openNewTab(url, openerId, background); } } diff --git a/src/background/controllers/MarkController.ts b/src/background/controllers/MarkController.ts index 0478369..419a08b 100644 --- a/src/background/controllers/MarkController.ts +++ b/src/background/controllers/MarkController.ts @@ -1,15 +1,17 @@ import MarkUseCase from '../usecases/MarkUseCase'; export default class MarkController { + private markUseCase: MarkUseCase; + constructor() { this.markUseCase = new MarkUseCase(); } - setGlobal(key, x, y) { - this.markUseCase.setGlobal(key, x, y); + setGlobal(key: string, x: number, y: number): Promise<any> { + return this.markUseCase.setGlobal(key, x, y); } - jumpGlobal(key) { - this.markUseCase.jumpGlobal(key); + jumpGlobal(key: string): Promise<any> { + return this.markUseCase.jumpGlobal(key); } } diff --git a/src/background/controllers/OperationController.ts b/src/background/controllers/OperationController.ts index 416aa9c..4e9c106 100644 --- a/src/background/controllers/OperationController.ts +++ b/src/background/controllers/OperationController.ts @@ -6,6 +6,16 @@ import TabSelectUseCase from '../usecases/TabSelectUseCase'; import ZoomUseCase from '../usecases/ZoomUseCase'; export default class OperationController { + private findUseCase: FindUseCase; + + private consoleUseCase: ConsoleUseCase; + + private tabUseCase: TabUseCase; + + private tabSelectUseCase: TabSelectUseCase; + + private zoomUseCase: ZoomUseCase; + constructor() { this.findUseCase = new FindUseCase(); this.consoleUseCase = new ConsoleUseCase(); @@ -15,7 +25,7 @@ export default class OperationController { } // eslint-disable-next-line complexity, max-lines-per-function - exec(operation) { + exec(operation: any): Promise<any> { switch (operation.type) { case operations.TAB_CLOSE: return this.tabUseCase.close(false); @@ -72,6 +82,7 @@ export default class OperationController { case operations.CANCEL: return this.consoleUseCase.hideConsole(); } + throw new Error('unknown operation: ' + operation.type); } } diff --git a/src/background/controllers/SettingController.ts b/src/background/controllers/SettingController.ts index e895d72..f8b7302 100644 --- a/src/background/controllers/SettingController.ts +++ b/src/background/controllers/SettingController.ts @@ -2,16 +2,20 @@ import SettingUseCase from '../usecases/SettingUseCase'; import ContentMessageClient from '../infrastructures/ContentMessageClient'; export default class SettingController { + private settingUseCase: SettingUseCase; + + private contentMessageClient: ContentMessageClient; + constructor() { this.settingUseCase = new SettingUseCase(); this.contentMessageClient = new ContentMessageClient(); } - getSetting() { + getSetting(): any { return this.settingUseCase.get(); } - async reload() { + async reload(): Promise<any> { await this.settingUseCase.reload(); this.contentMessageClient.broadcastSettingsChanged(); } diff --git a/src/background/controllers/VersionController.ts b/src/background/controllers/VersionController.ts index c596f9b..f402ed0 100644 --- a/src/background/controllers/VersionController.ts +++ b/src/background/controllers/VersionController.ts @@ -1,11 +1,13 @@ import VersionUseCase from '../usecases/VersionUseCase'; export default class VersionController { + private versionUseCase: VersionUseCase; + constructor() { this.versionUseCase = new VersionUseCase(); } - notify() { - this.versionUseCase.notify(); + notify(): void { + return this.versionUseCase.notify(); } } diff --git a/src/background/controllers/version.ts b/src/background/controllers/version.ts deleted file mode 100644 index ec0f634..0000000 --- a/src/background/controllers/version.ts +++ /dev/null @@ -1,13 +0,0 @@ -import VersionInteractor from '../usecases/version'; - -export default class VersionController { - constructor() { - this.versionInteractor = new VersionInteractor(); - } - - notifyIfUpdated() { - browser.runtime.onInstalled.addListener(() => { - return this.versionInteractor.notify(); - }); - } -} |