diff options
Diffstat (limited to 'src/background/controllers')
-rw-r--r-- | src/background/controllers/AddonEnabledController.ts | 2 | ||||
-rw-r--r-- | src/background/controllers/CommandController.ts | 2 | ||||
-rw-r--r-- | src/background/controllers/ConsoleController.ts | 11 | ||||
-rw-r--r-- | src/background/controllers/ConsoleFrameClient.ts | 15 | ||||
-rw-r--r-- | src/background/controllers/ConsoleUseCase.ts | 21 | ||||
-rw-r--r-- | src/background/controllers/FindController.ts | 2 | ||||
-rw-r--r-- | src/background/controllers/MarkController.ts | 4 | ||||
-rw-r--r-- | src/background/controllers/OperationController.ts | 4 | ||||
-rw-r--r-- | src/background/controllers/SettingController.ts | 2 |
9 files changed, 55 insertions, 8 deletions
diff --git a/src/background/controllers/AddonEnabledController.ts b/src/background/controllers/AddonEnabledController.ts index 170abdf..fd69a69 100644 --- a/src/background/controllers/AddonEnabledController.ts +++ b/src/background/controllers/AddonEnabledController.ts @@ -5,7 +5,7 @@ import AddonEnabledUseCase from "../usecases/AddonEnabledUseCase"; export default class AddonEnabledController { constructor(private addonEnabledUseCase: AddonEnabledUseCase) {} - indicate(enabled: boolean): Promise<any> { + indicate(enabled: boolean): Promise<void> { return this.addonEnabledUseCase.indicate(enabled); } } diff --git a/src/background/controllers/CommandController.ts b/src/background/controllers/CommandController.ts index f19303f..bde401a 100644 --- a/src/background/controllers/CommandController.ts +++ b/src/background/controllers/CommandController.ts @@ -11,7 +11,7 @@ export default class CommandController { constructor(private commandIndicator: CommandUseCase) {} // eslint-disable-next-line complexity - exec(line: string): Promise<any> { + exec(line: string): Promise<unknown> { const trimmed = trimStart(line); const words = trimmed.split(/ +/); const name = words[0]; diff --git a/src/background/controllers/ConsoleController.ts b/src/background/controllers/ConsoleController.ts new file mode 100644 index 0000000..11ee09d --- /dev/null +++ b/src/background/controllers/ConsoleController.ts @@ -0,0 +1,11 @@ +import { injectable } from "tsyringe"; +import ConsoleUseCase from "./ConsoleUseCase"; + +@injectable() +export default class ConsoleController { + constructor(private readonly consoleUseCase: ConsoleUseCase) {} + + resize(width: number, height: number) { + return this.consoleUseCase.resize(width, height); + } +} diff --git a/src/background/controllers/ConsoleFrameClient.ts b/src/background/controllers/ConsoleFrameClient.ts new file mode 100644 index 0000000..170566d --- /dev/null +++ b/src/background/controllers/ConsoleFrameClient.ts @@ -0,0 +1,15 @@ +import * as messages from "../../shared/messages"; + +export default interface ConsoleFrameClient { + resize(tabId: number, width: number, height: number): Promise<void>; +} + +export class ConsoleFrameClientImpl implements ConsoleFrameClient { + async resize(tabId: number, width: number, height: number): Promise<void> { + await browser.tabs.sendMessage(tabId, { + type: messages.CONSOLE_RESIZE, + width, + height, + }); + } +} diff --git a/src/background/controllers/ConsoleUseCase.ts b/src/background/controllers/ConsoleUseCase.ts new file mode 100644 index 0000000..556aaf8 --- /dev/null +++ b/src/background/controllers/ConsoleUseCase.ts @@ -0,0 +1,21 @@ +import { inject, injectable } from "tsyringe"; +import ConsoleFrameClient from "./ConsoleFrameClient"; +import TabPresenter from "../presenters/TabPresenter"; + +@injectable() +export default class ConsoleUseCase { + constructor( + @inject("TabPresenter") + private readonly tabPresenter: TabPresenter, + @inject("ConsoleFrameClient") + private readonly consoleFrameClient: ConsoleFrameClient + ) {} + + async resize(width: number, height: number): Promise<void> { + const tabId = (await this.tabPresenter.getCurrent()).id; + if (typeof tabId === "undefined") { + return; + } + return this.consoleFrameClient.resize(tabId, width, height); + } +} diff --git a/src/background/controllers/FindController.ts b/src/background/controllers/FindController.ts index 92dfeb0..f3ea93f 100644 --- a/src/background/controllers/FindController.ts +++ b/src/background/controllers/FindController.ts @@ -9,7 +9,7 @@ export default class FindController { return this.findUseCase.getKeyword(); } - setKeyword(keyword: string): Promise<any> { + setKeyword(keyword: string): Promise<void> { return this.findUseCase.setKeyword(keyword); } } diff --git a/src/background/controllers/MarkController.ts b/src/background/controllers/MarkController.ts index 0d468f2..cfe425f 100644 --- a/src/background/controllers/MarkController.ts +++ b/src/background/controllers/MarkController.ts @@ -5,11 +5,11 @@ import MarkUseCase from "../usecases/MarkUseCase"; export default class MarkController { constructor(private markUseCase: MarkUseCase) {} - setGlobal(key: string, x: number, y: number): Promise<any> { + setGlobal(key: string, x: number, y: number): Promise<void> { return this.markUseCase.setGlobal(key, x, y); } - jumpGlobal(key: string): Promise<any> { + jumpGlobal(key: string): Promise<void> { return this.markUseCase.jumpGlobal(key); } } diff --git a/src/background/controllers/OperationController.ts b/src/background/controllers/OperationController.ts index d606ac0..7e43153 100644 --- a/src/background/controllers/OperationController.ts +++ b/src/background/controllers/OperationController.ts @@ -11,7 +11,7 @@ export default class OperationController { private readonly operatorFactory: OperatorFactory ) {} - async exec(repeat: number, op: operations.Operation): Promise<any> { + async exec(repeat: number, op: operations.Operation): Promise<void> { await this.doOperation(repeat, op); if (this.repeatUseCase.isRepeatable(op)) { this.repeatUseCase.storeLastOperation(op); @@ -21,7 +21,7 @@ export default class OperationController { private async doOperation( repeat: number, operation: operations.Operation - ): Promise<any> { + ): Promise<void> { const operator = this.operatorFactory.create(operation); for (let i = 0; i < repeat; ++i) { // eslint-disable-next-line no-await-in-loop diff --git a/src/background/controllers/SettingController.ts b/src/background/controllers/SettingController.ts index 4248746..cc0b89f 100644 --- a/src/background/controllers/SettingController.ts +++ b/src/background/controllers/SettingController.ts @@ -14,7 +14,7 @@ export default class SettingController { return this.settingUseCase.getCached(); } - async reload(): Promise<any> { + async reload(): Promise<void> { await this.settingUseCase.reload(); this.contentMessageClient.broadcastSettingsChanged(); } |