aboutsummaryrefslogtreecommitdiff
path: root/src/content/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/controllers')
-rw-r--r--src/content/controllers/AddonEnabledController.ts11
-rw-r--r--src/content/controllers/ConsoleFrameController.ts11
-rw-r--r--src/content/controllers/FindController.ts11
-rw-r--r--src/content/controllers/FollowKeyController.ts11
-rw-r--r--src/content/controllers/FollowMasterController.ts11
-rw-r--r--src/content/controllers/FollowSlaveController.ts11
-rw-r--r--src/content/controllers/KeymapController.ts59
-rw-r--r--src/content/controllers/MarkController.ts11
-rw-r--r--src/content/controllers/MarkKeyController.ts16
-rw-r--r--src/content/controllers/SettingController.ts15
10 files changed, 63 insertions, 104 deletions
diff --git a/src/content/controllers/AddonEnabledController.ts b/src/content/controllers/AddonEnabledController.ts
index 4e19b6a..bae95bf 100644
--- a/src/content/controllers/AddonEnabledController.ts
+++ b/src/content/controllers/AddonEnabledController.ts
@@ -1,13 +1,12 @@
+import { injectable } from 'tsyringe';
import * as messages from '../../shared/messages';
import AddonEnabledUseCase from '../usecases/AddonEnabledUseCase';
+@injectable()
export default class AddonEnabledController {
- private addonEnabledUseCase: AddonEnabledUseCase;
-
- constructor({
- addonEnabledUseCase = new AddonEnabledUseCase(),
- } = {}) {
- this.addonEnabledUseCase = addonEnabledUseCase;
+ constructor(
+ private addonEnabledUseCase: AddonEnabledUseCase,
+ ) {
}
getAddonEnabled(
diff --git a/src/content/controllers/ConsoleFrameController.ts b/src/content/controllers/ConsoleFrameController.ts
index fafadf4..ae26b7c 100644
--- a/src/content/controllers/ConsoleFrameController.ts
+++ b/src/content/controllers/ConsoleFrameController.ts
@@ -1,13 +1,12 @@
+import { injectable } from 'tsyringe';
import ConsoleFrameUseCase from '../usecases/ConsoleFrameUseCase';
import * as messages from '../../shared/messages';
+@injectable()
export default class ConsoleFrameController {
- private consoleFrameUseCase: ConsoleFrameUseCase;
-
- constructor({
- consoleFrameUseCase = new ConsoleFrameUseCase(),
- } = {}) {
- this.consoleFrameUseCase = consoleFrameUseCase;
+ constructor(
+ private consoleFrameUseCase: ConsoleFrameUseCase,
+ ) {
}
unfocus(_message: messages.Message) {
diff --git a/src/content/controllers/FindController.ts b/src/content/controllers/FindController.ts
index cf27a8d..7735176 100644
--- a/src/content/controllers/FindController.ts
+++ b/src/content/controllers/FindController.ts
@@ -1,13 +1,12 @@
+import { injectable } from 'tsyringe';
import * as messages from '../../shared/messages';
import FindUseCase from '../usecases/FindUseCase';
+@injectable()
export default class FindController {
- private findUseCase: FindUseCase;
-
- constructor({
- findUseCase = new FindUseCase(),
- } = {}) {
- this.findUseCase = findUseCase;
+ constructor(
+ private findUseCase: FindUseCase,
+ ) {
}
async start(m: messages.ConsoleEnterFindMessage): Promise<void> {
diff --git a/src/content/controllers/FollowKeyController.ts b/src/content/controllers/FollowKeyController.ts
index eb45e01..59d2271 100644
--- a/src/content/controllers/FollowKeyController.ts
+++ b/src/content/controllers/FollowKeyController.ts
@@ -1,13 +1,12 @@
+import { injectable } from 'tsyringe';
import FollowSlaveUseCase from '../usecases/FollowSlaveUseCase';
import Key from '../domains/Key';
+@injectable()
export default class FollowKeyController {
- private followSlaveUseCase: FollowSlaveUseCase;
-
- constructor({
- followSlaveUseCase = new FollowSlaveUseCase(),
- } = {}) {
- this.followSlaveUseCase = followSlaveUseCase;
+ constructor(
+ private followSlaveUseCase: FollowSlaveUseCase,
+ ) {
}
press(key: Key): boolean {
diff --git a/src/content/controllers/FollowMasterController.ts b/src/content/controllers/FollowMasterController.ts
index 89294ff..fa99820 100644
--- a/src/content/controllers/FollowMasterController.ts
+++ b/src/content/controllers/FollowMasterController.ts
@@ -1,13 +1,12 @@
+import { injectable } from 'tsyringe';
import FollowMasterUseCase from '../usecases/FollowMasterUseCase';
import * as messages from '../../shared/messages';
+@injectable()
export default class FollowMasterController {
- private followMasterUseCase: FollowMasterUseCase;
-
- constructor({
- followMasterUseCase = new FollowMasterUseCase(),
- } = {}) {
- this.followMasterUseCase = followMasterUseCase;
+ constructor(
+ private followMasterUseCase: FollowMasterUseCase,
+ ) {
}
followStart(m: messages.FollowStartMessage): void {
diff --git a/src/content/controllers/FollowSlaveController.ts b/src/content/controllers/FollowSlaveController.ts
index 88dccf3..65ce477 100644
--- a/src/content/controllers/FollowSlaveController.ts
+++ b/src/content/controllers/FollowSlaveController.ts
@@ -1,13 +1,12 @@
+import { injectable } from 'tsyringe';
import * as messages from '../../shared/messages';
import FollowSlaveUseCase from '../usecases/FollowSlaveUseCase';
+@injectable()
export default class FollowSlaveController {
- private usecase: FollowSlaveUseCase;
-
- constructor({
- usecase = new FollowSlaveUseCase(),
- } = {}) {
- this.usecase = usecase;
+ constructor(
+ private usecase: FollowSlaveUseCase,
+ ) {
}
countTargets(m: messages.FollowRequestCountTargetsMessage): void {
diff --git a/src/content/controllers/KeymapController.ts b/src/content/controllers/KeymapController.ts
index 20c24c0..1835546 100644
--- a/src/content/controllers/KeymapController.ts
+++ b/src/content/controllers/KeymapController.ts
@@ -1,3 +1,4 @@
+import { injectable, inject } from 'tsyringe';
import * as operations from '../../shared/operations';
import KeymapUseCase from '../usecases/KeymapUseCase';
import AddonEnabledUseCase from '../usecases/AddonEnabledUseCase';
@@ -8,53 +9,25 @@ import FocusUseCase from '../usecases/FocusUseCase';
import ClipboardUseCase from '../usecases/ClipboardUseCase';
import BackgroundClient from '../client/BackgroundClient';
import MarkKeyyUseCase from '../usecases/MarkKeyUseCase';
-import FollowMasterClient, { FollowMasterClientImpl }
- from '../client/FollowMasterClient';
+import FollowMasterClient from '../client/FollowMasterClient';
import Key from '../domains/Key';
+@injectable()
export default class KeymapController {
- private keymapUseCase: KeymapUseCase;
+ constructor(
+ private keymapUseCase: KeymapUseCase,
+ private addonEnabledUseCase: AddonEnabledUseCase,
+ private findSlaveUseCase: FindSlaveUseCase,
+ private scrollUseCase: ScrollUseCase,
+ private navigateUseCase: NavigateUseCase,
+ private focusUseCase: FocusUseCase,
+ private clipbaordUseCase: ClipboardUseCase,
+ private backgroundClient: BackgroundClient,
+ private markKeyUseCase: MarkKeyyUseCase,
- private addonEnabledUseCase: AddonEnabledUseCase;
-
- private findSlaveUseCase: FindSlaveUseCase;
-
- private scrollUseCase: ScrollUseCase;
-
- private navigateUseCase: NavigateUseCase;
-
- private focusUseCase: FocusUseCase;
-
- private clipbaordUseCase: ClipboardUseCase;
-
- private backgroundClient: BackgroundClient;
-
- private markKeyUseCase: MarkKeyyUseCase;
-
- private followMasterClient: FollowMasterClient;
-
- constructor({
- keymapUseCase = new KeymapUseCase(),
- addonEnabledUseCase = new AddonEnabledUseCase(),
- findSlaveUseCase = new FindSlaveUseCase(),
- scrollUseCase = new ScrollUseCase(),
- navigateUseCase = new NavigateUseCase(),
- focusUseCase = new FocusUseCase(),
- clipbaordUseCase = new ClipboardUseCase(),
- backgroundClient = new BackgroundClient(),
- markKeyUseCase = new MarkKeyyUseCase(),
- followMasterClient = new FollowMasterClientImpl(window.top),
- } = {}) {
- this.keymapUseCase = keymapUseCase;
- this.addonEnabledUseCase = addonEnabledUseCase;
- this.findSlaveUseCase = findSlaveUseCase;
- this.scrollUseCase = scrollUseCase;
- this.navigateUseCase = navigateUseCase;
- this.focusUseCase = focusUseCase;
- this.clipbaordUseCase = clipbaordUseCase;
- this.backgroundClient = backgroundClient;
- this.markKeyUseCase = markKeyUseCase;
- this.followMasterClient = followMasterClient;
+ @inject('FollowMasterClient')
+ private followMasterClient: FollowMasterClient,
+ ) {
}
// eslint-disable-next-line complexity, max-lines-per-function
diff --git a/src/content/controllers/MarkController.ts b/src/content/controllers/MarkController.ts
index 365794c..5eb898a 100644
--- a/src/content/controllers/MarkController.ts
+++ b/src/content/controllers/MarkController.ts
@@ -1,13 +1,12 @@
+import { injectable } from 'tsyringe';
import * as messages from '../../shared/messages';
import MarkUseCase from '../usecases/MarkUseCase';
+@injectable()
export default class MarkController {
- private markUseCase: MarkUseCase;
-
- constructor({
- markUseCase = new MarkUseCase(),
- } = {}) {
- this.markUseCase = markUseCase;
+ constructor(
+ private markUseCase: MarkUseCase,
+ ) {
}
scrollTo(message: messages.TabScrollToMessage) {
diff --git a/src/content/controllers/MarkKeyController.ts b/src/content/controllers/MarkKeyController.ts
index 395dee3..886e5ff 100644
--- a/src/content/controllers/MarkKeyController.ts
+++ b/src/content/controllers/MarkKeyController.ts
@@ -1,18 +1,14 @@
+import { injectable } from 'tsyringe';
import MarkUseCase from '../usecases/MarkUseCase';
import MarkKeyyUseCase from '../usecases/MarkKeyUseCase';
import Key from '../domains/Key';
+@injectable()
export default class MarkKeyController {
- private markUseCase: MarkUseCase;
-
- private markKeyUseCase: MarkKeyyUseCase;
-
- constructor({
- markUseCase = new MarkUseCase(),
- markKeyUseCase = new MarkKeyyUseCase(),
- } = {}) {
- this.markUseCase = markUseCase;
- this.markKeyUseCase = markKeyUseCase;
+ constructor(
+ private markUseCase: MarkUseCase,
+ private markKeyUseCase: MarkKeyyUseCase,
+ ) {
}
press(key: Key): boolean {
diff --git a/src/content/controllers/SettingController.ts b/src/content/controllers/SettingController.ts
index f0e770b..7fb045b 100644
--- a/src/content/controllers/SettingController.ts
+++ b/src/content/controllers/SettingController.ts
@@ -1,20 +1,17 @@
+import { injectable } from 'tsyringe';
import AddonEnabledUseCase from '../usecases/AddonEnabledUseCase';
import SettingUseCase from '../usecases/SettingUseCase';
import * as blacklists from '../../shared/blacklists';
import * as messages from '../../shared/messages';
+@injectable()
export default class SettingController {
- private addonEnabledUseCase: AddonEnabledUseCase;
- private settingUseCase: SettingUseCase;
-
- constructor({
- addonEnabledUseCase = new AddonEnabledUseCase(),
- settingUseCase = new SettingUseCase(),
- } = {}) {
- this.addonEnabledUseCase = addonEnabledUseCase;
- this.settingUseCase = settingUseCase;
+ constructor(
+ private addonEnabledUseCase: AddonEnabledUseCase,
+ private settingUseCase: SettingUseCase,
+ ) {
}
async initSettings(): Promise<void> {