aboutsummaryrefslogtreecommitdiff
path: root/src/content
diff options
context:
space:
mode:
Diffstat (limited to 'src/content')
-rw-r--r--src/content/Application.ts8
-rw-r--r--src/content/client/FindClient.ts23
-rw-r--r--src/content/client/FindMasterClient.ts27
-rw-r--r--src/content/controllers/FindController.ts20
-rw-r--r--src/content/di.ts8
-rw-r--r--src/content/operators/impls/FindNextOperator.ts15
-rw-r--r--src/content/operators/impls/FindOperatorFactoryChain.ts25
-rw-r--r--src/content/operators/impls/FindPrevOperator.ts15
-rw-r--r--src/content/operators/impls/OperatorFactoryImpl.ts3
-rw-r--r--src/content/presenters/FindPresenter.ts29
-rw-r--r--src/content/repositories/FindRepository.ts17
-rw-r--r--src/content/usecases/FindUseCase.ts67
12 files changed, 0 insertions, 257 deletions
diff --git a/src/content/Application.ts b/src/content/Application.ts
index b09edfa..4c89fa0 100644
--- a/src/content/Application.ts
+++ b/src/content/Application.ts
@@ -1,6 +1,5 @@
import { injectable } from "tsyringe";
import MessageListener from "./MessageListener";
-import FindController from "./controllers/FindController";
import MarkController from "./controllers/MarkController";
import FollowMasterController from "./controllers/FollowMasterController";
import FollowSlaveController from "./controllers/FollowSlaveController";
@@ -22,7 +21,6 @@ export default class Application {
// eslint-disable-next-line max-params
constructor(
private messageListener: MessageListener,
- private findController: FindController,
private markController: MarkController,
private followMasterController: FollowMasterController,
private followSlaveController: FollowSlaveController,
@@ -47,12 +45,6 @@ export default class Application {
private routeMasterComponents() {
this.messageListener.onWebMessage((msg: Message, sender: Window) => {
switch (msg.type) {
- case messages.CONSOLE_ENTER_FIND:
- return this.findController.start(msg);
- case messages.FIND_NEXT:
- return this.findController.next(msg);
- case messages.FIND_PREV:
- return this.findController.prev(msg);
case messages.CONSOLE_UNFOCUS:
return this.consoleFrameController.unfocus(msg);
case messages.FOLLOW_START:
diff --git a/src/content/client/FindClient.ts b/src/content/client/FindClient.ts
deleted file mode 100644
index 7da5069..0000000
--- a/src/content/client/FindClient.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import * as messages from "../../shared/messages";
-
-export default interface FindClient {
- getGlobalLastKeyword(): Promise<string | null>;
-
- setGlobalLastKeyword(keyword: string): Promise<void>;
-}
-
-export class FindClientImpl implements FindClient {
- async getGlobalLastKeyword(): Promise<string | null> {
- const keyword = await browser.runtime.sendMessage({
- type: messages.FIND_GET_KEYWORD,
- });
- return keyword as string;
- }
-
- async setGlobalLastKeyword(keyword: string): Promise<void> {
- await browser.runtime.sendMessage({
- type: messages.FIND_SET_KEYWORD,
- keyword: keyword,
- });
- }
-}
diff --git a/src/content/client/FindMasterClient.ts b/src/content/client/FindMasterClient.ts
deleted file mode 100644
index 9c3f812..0000000
--- a/src/content/client/FindMasterClient.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import * as messages from "../../shared/messages";
-
-export default interface FindMasterClient {
- findNext(): void;
-
- findPrev(): void;
-}
-
-export class FindMasterClientImpl implements FindMasterClient {
- findNext(): void {
- window.top.postMessage(
- JSON.stringify({
- type: messages.FIND_NEXT,
- }),
- "*"
- );
- }
-
- findPrev(): void {
- window.top.postMessage(
- JSON.stringify({
- type: messages.FIND_PREV,
- }),
- "*"
- );
- }
-}
diff --git a/src/content/controllers/FindController.ts b/src/content/controllers/FindController.ts
deleted file mode 100644
index 3087d5d..0000000
--- a/src/content/controllers/FindController.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { injectable } from "tsyringe";
-import * as messages from "../../shared/messages";
-import FindUseCase from "../usecases/FindUseCase";
-
-@injectable()
-export default class FindController {
- constructor(private findUseCase: FindUseCase) {}
-
- async start(m: messages.ConsoleEnterFindMessage): Promise<void> {
- await this.findUseCase.startFind(m.text);
- }
-
- async next(_: messages.FindNextMessage): Promise<void> {
- await this.findUseCase.findNext();
- }
-
- async prev(_: messages.FindPrevMessage): Promise<void> {
- await this.findUseCase.findPrev();
- }
-}
diff --git a/src/content/di.ts b/src/content/di.ts
index e74d7ac..7a7fb08 100644
--- a/src/content/di.ts
+++ b/src/content/di.ts
@@ -6,10 +6,6 @@ import { AddressRepositoryImpl } from "./repositories/AddressRepository";
import { ClipboardRepositoryImpl } from "./repositories/ClipboardRepository";
import { ConsoleClientImpl } from "./client/ConsoleClient";
import { ConsoleFramePresenterImpl } from "./presenters/ConsoleFramePresenter";
-import { FindClientImpl } from "./client/FindClient";
-import { FindMasterClientImpl } from "./client/FindMasterClient";
-import { FindPresenterImpl } from "./presenters/FindPresenter";
-import { FindRepositoryImpl } from "./repositories/FindRepository";
import { FocusPresenterImpl } from "./presenters/FocusPresenter";
import { FollowKeyRepositoryImpl } from "./repositories/FollowKeyRepository";
import { FollowMasterClientImpl } from "./client/FollowMasterClient";
@@ -49,10 +45,6 @@ container.register("ConsoleClient", { useClass: ConsoleClientImpl });
container.register("ConsoleFramePresenter", {
useClass: ConsoleFramePresenterImpl,
});
-container.register("FindClient", { useClass: FindClientImpl });
-container.register("FindMasterClient", { useClass: FindMasterClientImpl });
-container.register("FindPresenter", { useClass: FindPresenterImpl });
-container.register("FindRepository", { useClass: FindRepositoryImpl });
container.register("FocusPresenter", { useClass: FocusPresenterImpl });
container.register("FollowKeyRepository", {
useClass: FollowKeyRepositoryImpl,
diff --git a/src/content/operators/impls/FindNextOperator.ts b/src/content/operators/impls/FindNextOperator.ts
deleted file mode 100644
index c67f6d9..0000000
--- a/src/content/operators/impls/FindNextOperator.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import Operator from "../Operator";
-import FindMasterClient from "../../client/FindMasterClient";
-
-export default class FindNextOperator implements Operator {
- constructor(
- private readonly findMasterClient: FindMasterClient,
- private readonly repeat: number
- ) {}
-
- async run(): Promise<void> {
- for (let i = 0; i < this.repeat; ++i) {
- this.findMasterClient.findNext();
- }
- }
-}
diff --git a/src/content/operators/impls/FindOperatorFactoryChain.ts b/src/content/operators/impls/FindOperatorFactoryChain.ts
deleted file mode 100644
index b3524c1..0000000
--- a/src/content/operators/impls/FindOperatorFactoryChain.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { inject, injectable } from "tsyringe";
-import Operator from "../Operator";
-import OperatorFactoryChain from "../OperatorFactoryChain";
-import FindNextOperator from "./FindNextOperator";
-import FindPrevOperator from "./FindPrevOperator";
-import FindMasterClient from "../../client/FindMasterClient";
-import * as operations from "../../../shared/operations";
-
-@injectable()
-export default class FindOperatorFactoryChain implements OperatorFactoryChain {
- constructor(
- @inject("FindMasterClient")
- private readonly findMasterClient: FindMasterClient
- ) {}
-
- create(op: operations.Operation, repeat: number): Operator | null {
- switch (op.type) {
- case operations.FIND_NEXT:
- return new FindNextOperator(this.findMasterClient, repeat);
- case operations.FIND_PREV:
- return new FindPrevOperator(this.findMasterClient, repeat);
- }
- return null;
- }
-}
diff --git a/src/content/operators/impls/FindPrevOperator.ts b/src/content/operators/impls/FindPrevOperator.ts
deleted file mode 100644
index f73e605..0000000
--- a/src/content/operators/impls/FindPrevOperator.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import Operator from "../Operator";
-import FindMasterClient from "../../client/FindMasterClient";
-
-export default class FindPrevOperator implements Operator {
- constructor(
- private readonly findMasterClient: FindMasterClient,
- private readonly repeat: number
- ) {}
-
- async run(): Promise<void> {
- for (let i = 0; i < this.repeat; ++i) {
- this.findMasterClient.findPrev();
- }
- }
-}
diff --git a/src/content/operators/impls/OperatorFactoryImpl.ts b/src/content/operators/impls/OperatorFactoryImpl.ts
index 22b35c8..bc9bbee 100644
--- a/src/content/operators/impls/OperatorFactoryImpl.ts
+++ b/src/content/operators/impls/OperatorFactoryImpl.ts
@@ -7,7 +7,6 @@ import { Operation } from "../../../shared/operations";
import OperationClient from "../../client/OperationClient";
import AddonOperatorFactoryChain from "./AddonOperatorFactoryChain";
import ClipboardOperatorFactoryChain from "./ClipboardOperatorFactoryChain";
-import FindOperatorFactoryChain from "./FindOperatorFactoryChain";
import FocusOperatorFactoryChain from "./FocusOperatorFactoryChain";
import FollowOperatorFactoryChain from "./FollowOperatorFactoryChain";
import MarkOperatorFactoryChain from "./MarkOperatorFactoryChain";
@@ -20,7 +19,6 @@ export default class OperatorFactoryImpl implements OperatorFactory {
constructor(
addonOperatorFactoryChain: AddonOperatorFactoryChain,
clipboardOperatorFactoryChain: ClipboardOperatorFactoryChain,
- findOperatorFactoryChain: FindOperatorFactoryChain,
focusOperatorFactoryChain: FocusOperatorFactoryChain,
followOperatorFactoryChain: FollowOperatorFactoryChain,
markOperatorFactoryChain: MarkOperatorFactoryChain,
@@ -31,7 +29,6 @@ export default class OperatorFactoryImpl implements OperatorFactory {
this.factoryChains = [
addonOperatorFactoryChain,
clipboardOperatorFactoryChain,
- findOperatorFactoryChain,
focusOperatorFactoryChain,
followOperatorFactoryChain,
markOperatorFactoryChain,
diff --git a/src/content/presenters/FindPresenter.ts b/src/content/presenters/FindPresenter.ts
deleted file mode 100644
index b25190c..0000000
--- a/src/content/presenters/FindPresenter.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-export default interface FindPresenter {
- find(keyword: string, backwards: boolean): boolean;
-
- clearSelection(): void;
-}
-
-export class FindPresenterImpl implements FindPresenter {
- find(keyword: string, backwards: boolean): boolean {
- const caseSensitive = false;
- const wrapScan = true;
-
- // NOTE: aWholeWord dows not implemented, and aSearchInFrames does not work
- // because of same origin policy
- const found = window.find(keyword, caseSensitive, backwards, wrapScan);
- if (found) {
- return found;
- }
- this.clearSelection();
-
- return window.find(keyword, caseSensitive, backwards, wrapScan);
- }
-
- clearSelection(): void {
- const sel = window.getSelection();
- if (sel) {
- sel.removeAllRanges();
- }
- }
-}
diff --git a/src/content/repositories/FindRepository.ts b/src/content/repositories/FindRepository.ts
deleted file mode 100644
index aeb200f..0000000
--- a/src/content/repositories/FindRepository.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-export default interface FindRepository {
- getLastKeyword(): string | null;
-
- setLastKeyword(keyword: string): void;
-}
-
-let current: string | null = null;
-
-export class FindRepositoryImpl implements FindRepository {
- getLastKeyword(): string | null {
- return current;
- }
-
- setLastKeyword(keyword: string): void {
- current = keyword;
- }
-}
diff --git a/src/content/usecases/FindUseCase.ts b/src/content/usecases/FindUseCase.ts
deleted file mode 100644
index bff0eee..0000000
--- a/src/content/usecases/FindUseCase.ts
+++ /dev/null
@@ -1,67 +0,0 @@
-import { injectable, inject } from "tsyringe";
-import FindPresenter from "../presenters/FindPresenter";
-import FindRepository from "../repositories/FindRepository";
-import FindClient from "../client/FindClient";
-import ConsoleClient from "../client/ConsoleClient";
-
-@injectable()
-export default class FindUseCase {
- constructor(
- @inject("FindPresenter") private presenter: FindPresenter,
- @inject("FindRepository") private repository: FindRepository,
- @inject("FindClient") private client: FindClient,
- @inject("ConsoleClient") private consoleClient: ConsoleClient
- ) {}
-
- async startFind(keyword?: string): Promise<void> {
- this.presenter.clearSelection();
- if (keyword) {
- this.saveKeyword(keyword);
- } else {
- const lastKeyword = await this.getKeyword();
- if (!lastKeyword) {
- return this.showNoLastKeywordError();
- }
- this.saveKeyword(lastKeyword);
- }
- return this.findNext();
- }
-
- findNext(): Promise<void> {
- return this.findNextPrev(false);
- }
-
- findPrev(): Promise<void> {
- return this.findNextPrev(true);
- }
-
- private async findNextPrev(backwards: boolean): Promise<void> {
- const keyword = await this.getKeyword();
- if (!keyword) {
- return this.showNoLastKeywordError();
- }
- const found = this.presenter.find(keyword, backwards);
- if (found) {
- this.consoleClient.info("Pattern found: " + keyword);
- } else {
- this.consoleClient.error("Pattern not found: " + keyword);
- }
- }
-
- private async getKeyword(): Promise<string | null> {
- let keyword = this.repository.getLastKeyword();
- if (!keyword) {
- keyword = await this.client.getGlobalLastKeyword();
- }
- return keyword;
- }
-
- private async saveKeyword(keyword: string): Promise<void> {
- this.repository.setLastKeyword(keyword);
- await this.client.setGlobalLastKeyword(keyword);
- }
-
- private async showNoLastKeywordError(): Promise<void> {
- await this.consoleClient.error("No previous search keywords");
- }
-}