Capitalize background scripts
This commit is contained in:
parent
21788740c1
commit
a26d8a8a1b
50 changed files with 247 additions and 245 deletions
11
src/background/controllers/AddonEnabledController.js
Normal file
11
src/background/controllers/AddonEnabledController.js
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import AddonEnabledUseCase from '../usecases/AddonEnabledUseCase';
|
||||||
|
|
||||||
|
export default class AddonEnabledController {
|
||||||
|
constructor() {
|
||||||
|
this.addonEnabledUseCase = new AddonEnabledUseCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
indicate(enabled) {
|
||||||
|
return this.addonEnabledUseCase.indicate(enabled);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
import CompletionsInteractor from '../usecases/completions';
|
import CompletionsUseCase from '../usecases/CompletionsUseCase';
|
||||||
import CommandInteractor from '../usecases/command';
|
import CommandUseCase from '../usecases/CommandUseCase';
|
||||||
import Completions from '../domains/completions';
|
import Completions from '../domains/Completions';
|
||||||
|
|
||||||
const trimStart = (str) => {
|
const trimStart = (str) => {
|
||||||
// NOTE String.trimStart is available on Firefox 61
|
// NOTE String.trimStart is available on Firefox 61
|
||||||
|
@ -9,8 +9,8 @@ const trimStart = (str) => {
|
||||||
|
|
||||||
export default class CommandController {
|
export default class CommandController {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.completionsInteractor = new CompletionsInteractor();
|
this.completionsUseCase = new CompletionsUseCase();
|
||||||
this.commandIndicator = new CommandInteractor();
|
this.commandIndicator = new CommandUseCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
getCompletions(line) {
|
getCompletions(line) {
|
||||||
|
@ -18,7 +18,7 @@ export default class CommandController {
|
||||||
let words = trimmed.split(/ +/);
|
let words = trimmed.split(/ +/);
|
||||||
let name = words[0];
|
let name = words[0];
|
||||||
if (words.length === 1) {
|
if (words.length === 1) {
|
||||||
return this.completionsInteractor.queryConsoleCommand(name);
|
return this.completionsUseCase.queryConsoleCommand(name);
|
||||||
}
|
}
|
||||||
let keywords = trimStart(trimmed.slice(name.length));
|
let keywords = trimStart(trimmed.slice(name.length));
|
||||||
switch (words[0]) {
|
switch (words[0]) {
|
||||||
|
@ -28,22 +28,22 @@ export default class CommandController {
|
||||||
case 'tabopen':
|
case 'tabopen':
|
||||||
case 'w':
|
case 'w':
|
||||||
case 'winopen':
|
case 'winopen':
|
||||||
return this.completionsInteractor.queryOpen(name, keywords);
|
return this.completionsUseCase.queryOpen(name, keywords);
|
||||||
case 'b':
|
case 'b':
|
||||||
case 'buffer':
|
case 'buffer':
|
||||||
return this.completionsInteractor.queryBuffer(name, keywords);
|
return this.completionsUseCase.queryBuffer(name, keywords);
|
||||||
case 'bd':
|
case 'bd':
|
||||||
case 'bdel':
|
case 'bdel':
|
||||||
case 'bdelete':
|
case 'bdelete':
|
||||||
case 'bdeletes':
|
case 'bdeletes':
|
||||||
return this.completionsInteractor.queryBdelete(name, keywords);
|
return this.completionsUseCase.queryBdelete(name, keywords);
|
||||||
case 'bd!':
|
case 'bd!':
|
||||||
case 'bdel!':
|
case 'bdel!':
|
||||||
case 'bdelete!':
|
case 'bdelete!':
|
||||||
case 'bdeletes!':
|
case 'bdeletes!':
|
||||||
return this.completionsInteractor.queryBdeleteForce(name, keywords);
|
return this.completionsUseCase.queryBdeleteForce(name, keywords);
|
||||||
case 'set':
|
case 'set':
|
||||||
return this.completionsInteractor.querySet(name, keywords);
|
return this.completionsUseCase.querySet(name, keywords);
|
||||||
}
|
}
|
||||||
return Promise.resolve(Completions.empty());
|
return Promise.resolve(Completions.empty());
|
||||||
}
|
}
|
15
src/background/controllers/FindController.js
Normal file
15
src/background/controllers/FindController.js
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import FindUseCase from '../usecases/FindUseCase';
|
||||||
|
|
||||||
|
export default class FindController {
|
||||||
|
constructor() {
|
||||||
|
this.findUseCase = new FindUseCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
getKeyword() {
|
||||||
|
return this.findUseCase.getKeyword();
|
||||||
|
}
|
||||||
|
|
||||||
|
setKeyword(keyword) {
|
||||||
|
return this.findUseCase.setKeyword(keyword);
|
||||||
|
}
|
||||||
|
}
|
15
src/background/controllers/LinkController.js
Normal file
15
src/background/controllers/LinkController.js
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import LinkUseCase from '../usecases/LinkUseCase';
|
||||||
|
|
||||||
|
export default class LinkController {
|
||||||
|
constructor() {
|
||||||
|
this.linkUseCase = new LinkUseCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
openToTab(url, tabId) {
|
||||||
|
this.linkUseCase.openToTab(url, tabId);
|
||||||
|
}
|
||||||
|
|
||||||
|
openNewTab(url, openerId, background) {
|
||||||
|
this.linkUseCase.openNewTab(url, openerId, background);
|
||||||
|
}
|
||||||
|
}
|
15
src/background/controllers/MarkController.js
Normal file
15
src/background/controllers/MarkController.js
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import MarkUseCase from '../usecases/MarkUseCase';
|
||||||
|
|
||||||
|
export default class MarkController {
|
||||||
|
constructor() {
|
||||||
|
this.markUseCase = new MarkUseCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
setGlobal(key, x, y) {
|
||||||
|
this.markUseCase.setGlobal(key, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
jumpGlobal(key) {
|
||||||
|
this.markUseCase.jumpGlobal(key);
|
||||||
|
}
|
||||||
|
}
|
69
src/background/controllers/OperationController.js
Normal file
69
src/background/controllers/OperationController.js
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
import operations from '../../shared/operations';
|
||||||
|
import OperationUseCase from '../usecases/OperationUseCase';
|
||||||
|
|
||||||
|
export default class OperationController {
|
||||||
|
constructor() {
|
||||||
|
this.operationUseCase = new OperationUseCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line complexity, max-lines-per-function
|
||||||
|
exec(operation) {
|
||||||
|
switch (operation.type) {
|
||||||
|
case operations.TAB_CLOSE:
|
||||||
|
return this.operationUseCase.close(false);
|
||||||
|
case operations.TAB_CLOSE_RIGHT:
|
||||||
|
return this.operationUseCase.closeRight();
|
||||||
|
case operations.TAB_CLOSE_FORCE:
|
||||||
|
return this.operationUseCase.close(true);
|
||||||
|
case operations.TAB_REOPEN:
|
||||||
|
return this.operationUseCase.reopen();
|
||||||
|
case operations.TAB_PREV:
|
||||||
|
return this.operationUseCase.selectPrev(1);
|
||||||
|
case operations.TAB_NEXT:
|
||||||
|
return this.operationUseCase.selectNext(1);
|
||||||
|
case operations.TAB_FIRST:
|
||||||
|
return this.operationUseCase.selectFirst();
|
||||||
|
case operations.TAB_LAST:
|
||||||
|
return this.operationUseCase.selectLast();
|
||||||
|
case operations.TAB_PREV_SEL:
|
||||||
|
return this.operationUseCase.selectPrevSelected();
|
||||||
|
case operations.TAB_RELOAD:
|
||||||
|
return this.operationUseCase.reload(operation.cache);
|
||||||
|
case operations.TAB_PIN:
|
||||||
|
return this.operationUseCase.setPinned(true);
|
||||||
|
case operations.TAB_UNPIN:
|
||||||
|
return this.operationUseCase.setPinned(false);
|
||||||
|
case operations.TAB_TOGGLE_PINNED:
|
||||||
|
return this.operationUseCase.togglePinned();
|
||||||
|
case operations.TAB_DUPLICATE:
|
||||||
|
return this.operationUseCase.duplicate();
|
||||||
|
case operations.PAGE_SOURCE:
|
||||||
|
return this.operationUseCase.openPageSource();
|
||||||
|
case operations.PAGE_HOME:
|
||||||
|
return this.operationUseCase.openHome(operation.newTab);
|
||||||
|
case operations.ZOOM_IN:
|
||||||
|
return this.operationUseCase.zoomIn();
|
||||||
|
case operations.ZOOM_OUT:
|
||||||
|
return this.operationUseCase.zoomOut();
|
||||||
|
case operations.ZOOM_NEUTRAL:
|
||||||
|
return this.operationUseCase.zoomNutoral();
|
||||||
|
case operations.COMMAND_SHOW:
|
||||||
|
return this.operationUseCase.showCommand();
|
||||||
|
case operations.COMMAND_SHOW_OPEN:
|
||||||
|
return this.operationUseCase.showOpenCommand(operation.alter);
|
||||||
|
case operations.COMMAND_SHOW_TABOPEN:
|
||||||
|
return this.operationUseCase.showTabopenCommand(operation.alter);
|
||||||
|
case operations.COMMAND_SHOW_WINOPEN:
|
||||||
|
return this.operationUseCase.showWinopenCommand(operation.alter);
|
||||||
|
case operations.COMMAND_SHOW_BUFFER:
|
||||||
|
return this.operationUseCase.showBufferCommand();
|
||||||
|
case operations.COMMAND_SHOW_ADDBOOKMARK:
|
||||||
|
return this.operationUseCase.showAddbookmarkCommand(operation.alter);
|
||||||
|
case operations.FIND_START:
|
||||||
|
return this.operationUseCase.findStart();
|
||||||
|
case operations.CANCEL:
|
||||||
|
return this.operationUseCase.hideConsole();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
18
src/background/controllers/SettingController.js
Normal file
18
src/background/controllers/SettingController.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
import SettingUseCase from '../usecases/SettingUseCase';
|
||||||
|
import ContentMessageClient from '../infrastructures/ContentMessageClient';
|
||||||
|
|
||||||
|
export default class SettingController {
|
||||||
|
constructor() {
|
||||||
|
this.settingUseCase = new SettingUseCase();
|
||||||
|
this.contentMessageClient = new ContentMessageClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
getSetting() {
|
||||||
|
return this.settingUseCase.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
async reload() {
|
||||||
|
await this.settingUseCase.reload();
|
||||||
|
this.contentMessageClient.broadcastSettingsChanged();
|
||||||
|
}
|
||||||
|
}
|
11
src/background/controllers/VersionController.js
Normal file
11
src/background/controllers/VersionController.js
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import VersionUseCase from '../usecases/VersionUseCase';
|
||||||
|
|
||||||
|
export default class VersionController {
|
||||||
|
constructor() {
|
||||||
|
this.versionUseCase = new VersionUseCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
notifyIfUpdated() {
|
||||||
|
this.versionUseCase.notifyIfUpdated();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,11 +0,0 @@
|
||||||
import AddonEnabledInteractor from '../usecases/addon-enabled';
|
|
||||||
|
|
||||||
export default class AddonEnabledController {
|
|
||||||
constructor() {
|
|
||||||
this.addonEnabledInteractor = new AddonEnabledInteractor();
|
|
||||||
}
|
|
||||||
|
|
||||||
indicate(enabled) {
|
|
||||||
return this.addonEnabledInteractor.indicate(enabled);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
import FindInteractor from '../usecases/find';
|
|
||||||
|
|
||||||
export default class FindController {
|
|
||||||
constructor() {
|
|
||||||
this.findInteractor = new FindInteractor();
|
|
||||||
}
|
|
||||||
|
|
||||||
getKeyword() {
|
|
||||||
return this.findInteractor.getKeyword();
|
|
||||||
}
|
|
||||||
|
|
||||||
setKeyword(keyword) {
|
|
||||||
return this.findInteractor.setKeyword(keyword);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
import LinkInteractor from '../usecases/link';
|
|
||||||
|
|
||||||
export default class LinkController {
|
|
||||||
constructor() {
|
|
||||||
this.linkInteractor = new LinkInteractor();
|
|
||||||
}
|
|
||||||
|
|
||||||
openToTab(url, tabId) {
|
|
||||||
this.linkInteractor.openToTab(url, tabId);
|
|
||||||
}
|
|
||||||
|
|
||||||
openNewTab(url, openerId, background) {
|
|
||||||
this.linkInteractor.openNewTab(url, openerId, background);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
import MarkInteractor from '../usecases/mark';
|
|
||||||
|
|
||||||
export default class MarkController {
|
|
||||||
constructor() {
|
|
||||||
this.markInteractor = new MarkInteractor();
|
|
||||||
}
|
|
||||||
|
|
||||||
setGlobal(key, x, y) {
|
|
||||||
this.markInteractor.setGlobal(key, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
jumpGlobal(key) {
|
|
||||||
this.markInteractor.jumpGlobal(key);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,69 +0,0 @@
|
||||||
import operations from '../../shared/operations';
|
|
||||||
import OperationInteractor from '../usecases/operation';
|
|
||||||
|
|
||||||
export default class OperationController {
|
|
||||||
constructor() {
|
|
||||||
this.operationInteractor = new OperationInteractor();
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line complexity, max-lines-per-function
|
|
||||||
exec(operation) {
|
|
||||||
switch (operation.type) {
|
|
||||||
case operations.TAB_CLOSE:
|
|
||||||
return this.operationInteractor.close(false);
|
|
||||||
case operations.TAB_CLOSE_RIGHT:
|
|
||||||
return this.operationInteractor.closeRight();
|
|
||||||
case operations.TAB_CLOSE_FORCE:
|
|
||||||
return this.operationInteractor.close(true);
|
|
||||||
case operations.TAB_REOPEN:
|
|
||||||
return this.operationInteractor.reopen();
|
|
||||||
case operations.TAB_PREV:
|
|
||||||
return this.operationInteractor.selectPrev(1);
|
|
||||||
case operations.TAB_NEXT:
|
|
||||||
return this.operationInteractor.selectNext(1);
|
|
||||||
case operations.TAB_FIRST:
|
|
||||||
return this.operationInteractor.selectFirst();
|
|
||||||
case operations.TAB_LAST:
|
|
||||||
return this.operationInteractor.selectLast();
|
|
||||||
case operations.TAB_PREV_SEL:
|
|
||||||
return this.operationInteractor.selectPrevSelected();
|
|
||||||
case operations.TAB_RELOAD:
|
|
||||||
return this.operationInteractor.reload(operation.cache);
|
|
||||||
case operations.TAB_PIN:
|
|
||||||
return this.operationInteractor.setPinned(true);
|
|
||||||
case operations.TAB_UNPIN:
|
|
||||||
return this.operationInteractor.setPinned(false);
|
|
||||||
case operations.TAB_TOGGLE_PINNED:
|
|
||||||
return this.operationInteractor.togglePinned();
|
|
||||||
case operations.TAB_DUPLICATE:
|
|
||||||
return this.operationInteractor.duplicate();
|
|
||||||
case operations.PAGE_SOURCE:
|
|
||||||
return this.operationInteractor.openPageSource();
|
|
||||||
case operations.PAGE_HOME:
|
|
||||||
return this.operationInteractor.openHome(operation.newTab);
|
|
||||||
case operations.ZOOM_IN:
|
|
||||||
return this.operationInteractor.zoomIn();
|
|
||||||
case operations.ZOOM_OUT:
|
|
||||||
return this.operationInteractor.zoomOut();
|
|
||||||
case operations.ZOOM_NEUTRAL:
|
|
||||||
return this.operationInteractor.zoomNutoral();
|
|
||||||
case operations.COMMAND_SHOW:
|
|
||||||
return this.operationInteractor.showCommand();
|
|
||||||
case operations.COMMAND_SHOW_OPEN:
|
|
||||||
return this.operationInteractor.showOpenCommand(operation.alter);
|
|
||||||
case operations.COMMAND_SHOW_TABOPEN:
|
|
||||||
return this.operationInteractor.showTabopenCommand(operation.alter);
|
|
||||||
case operations.COMMAND_SHOW_WINOPEN:
|
|
||||||
return this.operationInteractor.showWinopenCommand(operation.alter);
|
|
||||||
case operations.COMMAND_SHOW_BUFFER:
|
|
||||||
return this.operationInteractor.showBufferCommand();
|
|
||||||
case operations.COMMAND_SHOW_ADDBOOKMARK:
|
|
||||||
return this.operationInteractor.showAddbookmarkCommand(operation.alter);
|
|
||||||
case operations.FIND_START:
|
|
||||||
return this.operationInteractor.findStart();
|
|
||||||
case operations.CANCEL:
|
|
||||||
return this.operationInteractor.hideConsole();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
import SettingInteractor from '../usecases/setting';
|
|
||||||
import ContentMessageClient from '../infrastructures/content-message-client';
|
|
||||||
|
|
||||||
export default class SettingController {
|
|
||||||
constructor() {
|
|
||||||
this.settingInteractor = new SettingInteractor();
|
|
||||||
this.contentMessageClient = new ContentMessageClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
getSetting() {
|
|
||||||
return this.settingInteractor.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
async reload() {
|
|
||||||
await this.settingInteractor.reload();
|
|
||||||
this.contentMessageClient.broadcastSettingsChanged();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
import VersionInteractor from '../usecases/version';
|
|
||||||
|
|
||||||
export default class VersionController {
|
|
||||||
constructor() {
|
|
||||||
this.versionInteractor = new VersionInteractor();
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyIfUpdated() {
|
|
||||||
this.versionInteractor.notifyIfUpdated();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,6 @@
|
||||||
import ContentMessageListener from './infrastructures/content-message-listener';
|
import ContentMessageListener from './infrastructures/ContentMessageListener';
|
||||||
import SettingController from './controllers/setting';
|
import SettingController from './controllers/SettingController';
|
||||||
import VersionController from './controllers/version';
|
import VersionController from './controllers/VersionController';
|
||||||
|
|
||||||
new SettingController().reload();
|
new SettingController().reload();
|
||||||
new VersionController().notifyIfUpdated();
|
new VersionController().notifyIfUpdated();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import messages from '../../shared/messages';
|
import messages from '../../shared/messages';
|
||||||
|
|
||||||
export default class ConsolePresenter {
|
export default class ConsoleClient {
|
||||||
showCommand(tabId, command) {
|
showCommand(tabId, command) {
|
||||||
return browser.tabs.sendMessage(tabId, {
|
return browser.tabs.sendMessage(tabId, {
|
||||||
type: messages.CONSOLE_SHOW_COMMAND,
|
type: messages.CONSOLE_SHOW_COMMAND,
|
||||||
|
@ -34,3 +34,4 @@ export default class ConsolePresenter {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import messages from '../../shared/messages';
|
import messages from '../../shared/messages';
|
||||||
import CommandController from '../controllers/command';
|
import CommandController from '../controllers/CommandController';
|
||||||
import SettingController from '../controllers/setting';
|
import SettingController from '../controllers/SettingController';
|
||||||
import FindController from '../controllers/find';
|
import FindController from '../controllers/FindController';
|
||||||
import AddonEnabledController from '../controllers/addon-enabled';
|
import AddonEnabledController from '../controllers/AddonEnabledController';
|
||||||
import LinkController from '../controllers/link';
|
import LinkController from '../controllers/LinkController';
|
||||||
import OperationController from '../controllers/operation';
|
import OperationController from '../controllers/OperationController';
|
||||||
import MarkController from '../controllers/mark';
|
import MarkController from '../controllers/MarkController';
|
||||||
|
|
||||||
export default class ContentMessageListener {
|
export default class ContentMessageListener {
|
||||||
constructor() {
|
constructor() {
|
|
@ -1,4 +1,4 @@
|
||||||
import MemoryStorage from '../infrastructures/memory-storage';
|
import MemoryStorage from '../infrastructures/MemoryStorage';
|
||||||
|
|
||||||
const CURRENT_SELECTED_KEY = 'tabs.current.selected';
|
const CURRENT_SELECTED_KEY = 'tabs.current.selected';
|
||||||
const LAST_SELECTED_KEY = 'tabs.last.selected';
|
const LAST_SELECTED_KEY = 'tabs.last.selected';
|
|
@ -1,4 +1,4 @@
|
||||||
import MemoryStorage from '../infrastructures/memory-storage';
|
import MemoryStorage from '../infrastructures/MemoryStorage';
|
||||||
|
|
||||||
const FIND_KEYWORD_KEY = 'find-keyword';
|
const FIND_KEYWORD_KEY = 'find-keyword';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import MemoryStorage from '../infrastructures/memory-storage';
|
import MemoryStorage from '../infrastructures/MemoryStorage';
|
||||||
import GlobalMark from 'background/domains/global-mark';
|
import GlobalMark from '../domains/GlobalMark';
|
||||||
|
|
||||||
const MARK_KEY = 'mark';
|
const MARK_KEY = 'mark';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import Setting from '../domains/setting';
|
import Setting from '../domains/Setting';
|
||||||
|
|
||||||
export default class SettingRepository {
|
export default class SettingRepository {
|
||||||
save(settings) {
|
save(settings) {
|
|
@ -1,4 +1,4 @@
|
||||||
import MemoryStorage from '../infrastructures/memory-storage';
|
import MemoryStorage from '../infrastructures/MemoryStorage';
|
||||||
|
|
||||||
const CACHED_SETTING_KEY = 'setting';
|
const CACHED_SETTING_KEY = 'setting';
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import IndicatorPresenter from '../presenters/indicator';
|
import IndicatorPresenter from '../presenters/IndicatorPresenter';
|
||||||
import TabPresenter from '../presenters/tab';
|
import TabPresenter from '../presenters/TabPresenter';
|
||||||
import ContentMessageClient from '../infrastructures/content-message-client';
|
import ContentMessageClient from '../infrastructures/ContentMessageClient';
|
||||||
|
|
||||||
export default class AddonEnabledInteractor {
|
export default class AddonEnabledUseCase {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.indicatorPresentor = new IndicatorPresenter();
|
this.indicatorPresentor = new IndicatorPresenter();
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import * as parsers from './parsers';
|
import * as parsers from './parsers';
|
||||||
import * as urls from '../../shared/urls';
|
import * as urls from '../../shared/urls';
|
||||||
import TabPresenter from '../presenters/tab';
|
import TabPresenter from '../presenters/TabPresenter';
|
||||||
import WindowPresenter from '../presenters/window';
|
import WindowPresenter from '../presenters/WindowPresenter';
|
||||||
import SettingRepository from '../repositories/setting';
|
import SettingRepository from '../repositories/SettingRepository';
|
||||||
import BookmarkRepository from '../repositories/bookmark';
|
import BookmarkRepository from '../repositories/BookmarkRepository';
|
||||||
import ConsolePresenter from '../presenters/console';
|
import ConsoleClient from '../infrastructures/ConsoleClient';
|
||||||
import ContentMessageClient from '../infrastructures/content-message-client';
|
import ContentMessageClient from '../infrastructures/ContentMessageClient';
|
||||||
import * as properties from 'shared/settings/properties';
|
import * as properties from 'shared/settings/properties';
|
||||||
|
|
||||||
export default class CommandIndicator {
|
export default class CommandIndicator {
|
||||||
|
@ -14,7 +14,7 @@ export default class CommandIndicator {
|
||||||
this.windowPresenter = new WindowPresenter();
|
this.windowPresenter = new WindowPresenter();
|
||||||
this.settingRepository = new SettingRepository();
|
this.settingRepository = new SettingRepository();
|
||||||
this.bookmarkRepository = new BookmarkRepository();
|
this.bookmarkRepository = new BookmarkRepository();
|
||||||
this.consolePresenter = new ConsolePresenter();
|
this.consoleClient = new ConsoleClient();
|
||||||
|
|
||||||
this.contentMessageClient = new ContentMessageClient();
|
this.contentMessageClient = new ContentMessageClient();
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ export default class CommandIndicator {
|
||||||
let tab = await this.tabPresenter.getCurrent();
|
let tab = await this.tabPresenter.getCurrent();
|
||||||
let item = await this.bookmarkRepository.create(title, tab.url);
|
let item = await this.bookmarkRepository.create(title, tab.url);
|
||||||
let message = 'Saved current page: ' + item.url;
|
let message = 'Saved current page: ' + item.url;
|
||||||
return this.consolePresenter.showInfo(tab.id, message);
|
return this.consoleClient.showInfo(tab.id, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
async set(keywords) {
|
async set(keywords) {
|
|
@ -1,19 +1,19 @@
|
||||||
import CompletionItem from '../domains/completion-item';
|
import CompletionItem from '../domains/CompletionItem';
|
||||||
import CompletionGroup from '../domains/completion-group';
|
import CompletionGroup from '../domains/CompletionGroup';
|
||||||
import Completions from '../domains/completions';
|
import Completions from '../domains/Completions';
|
||||||
import CommandDocs from '../domains/command-docs';
|
import CommandDocs from '../domains/CommandDocs';
|
||||||
import CompletionRepository from '../repositories/completions';
|
import CompletionsRepository from '../repositories/CompletionsRepository';
|
||||||
import * as filters from './filters';
|
import * as filters from './filters';
|
||||||
import SettingRepository from '../repositories/setting';
|
import SettingRepository from '../repositories/SettingRepository';
|
||||||
import TabPresenter from '../presenters/tab';
|
import TabPresenter from '../presenters/TabPresenter';
|
||||||
import * as properties from '../../shared/settings/properties';
|
import * as properties from '../../shared/settings/properties';
|
||||||
|
|
||||||
const COMPLETION_ITEM_LIMIT = 10;
|
const COMPLETION_ITEM_LIMIT = 10;
|
||||||
|
|
||||||
export default class CompletionsInteractor {
|
export default class CompletionsUseCase {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.tabPresenter = new TabPresenter();
|
this.tabPresenter = new TabPresenter();
|
||||||
this.completionRepository = new CompletionRepository();
|
this.completionsRepository = new CompletionsRepository();
|
||||||
this.settingRepository = new SettingRepository();
|
this.settingRepository = new SettingRepository();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ export default class CompletionsInteractor {
|
||||||
tabs = [tab];
|
tabs = [tab];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tabs = await this.completionRepository.queryTabs(keywords, false);
|
tabs = await this.completionsRepository.queryTabs(keywords, false);
|
||||||
}
|
}
|
||||||
const flag = (tab) => {
|
const flag = (tab) => {
|
||||||
if (tab.active) {
|
if (tab.active) {
|
||||||
|
@ -153,7 +153,7 @@ export default class CompletionsInteractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
async queryTabs(name, excludePinned, args) {
|
async queryTabs(name, excludePinned, args) {
|
||||||
let tabs = await this.completionRepository.queryTabs(args, excludePinned);
|
let tabs = await this.completionsRepository.queryTabs(args, excludePinned);
|
||||||
let items = tabs.map(tab => new CompletionItem({
|
let items = tabs.map(tab => new CompletionItem({
|
||||||
caption: tab.title,
|
caption: tab.title,
|
||||||
content: name + ' ' + tab.title,
|
content: name + ' ' + tab.title,
|
||||||
|
@ -177,7 +177,7 @@ export default class CompletionsInteractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
async queryHistoryItems(name, keywords) {
|
async queryHistoryItems(name, keywords) {
|
||||||
let histories = await this.completionRepository.queryHistories(keywords);
|
let histories = await this.completionsRepository.queryHistories(keywords);
|
||||||
histories = [histories]
|
histories = [histories]
|
||||||
.map(filters.filterBlankTitle)
|
.map(filters.filterBlankTitle)
|
||||||
.map(filters.filterHttp)
|
.map(filters.filterHttp)
|
||||||
|
@ -194,7 +194,7 @@ export default class CompletionsInteractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
async queryBookmarkItems(name, keywords) {
|
async queryBookmarkItems(name, keywords) {
|
||||||
let bookmarks = await this.completionRepository.queryBookmarks(keywords);
|
let bookmarks = await this.completionsRepository.queryBookmarks(keywords);
|
||||||
return bookmarks.slice(0, COMPLETION_ITEM_LIMIT)
|
return bookmarks.slice(0, COMPLETION_ITEM_LIMIT)
|
||||||
.map(page => new CompletionItem({
|
.map(page => new CompletionItem({
|
||||||
caption: page.title,
|
caption: page.title,
|
|
@ -1,6 +1,6 @@
|
||||||
import FindRepository from '../repositories/find';
|
import FindRepository from '../repositories/FindRepository';
|
||||||
|
|
||||||
export default class FindInteractor {
|
export default class FindUseCase {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.findRepository = new FindRepository();
|
this.findRepository = new FindRepository();
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
import SettingRepository from '../repositories/setting';
|
import SettingRepository from '../repositories/SettingRepository';
|
||||||
import TabPresenter from '../presenters/tab';
|
import TabPresenter from '../presenters/TabPresenter';
|
||||||
|
|
||||||
export default class LinkInteractor {
|
export default class LinkUseCase {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.settingRepository = new SettingRepository();
|
this.settingRepository = new SettingRepository();
|
||||||
this.tabPresenter = new TabPresenter();
|
this.tabPresenter = new TabPresenter();
|
|
@ -1,14 +1,14 @@
|
||||||
import GlobalMark from '../domains/global-mark';
|
import GlobalMark from '../domains/GlobalMark';
|
||||||
import TabPresenter from '../presenters/tab';
|
import TabPresenter from '../presenters/TabPresenter';
|
||||||
import MarkRepository from '../repositories/mark';
|
import MarkRepository from '../repositories/MarkRepository';
|
||||||
import ConsolePresenter from '../presenters/console';
|
import ConsoleClient from '../infrastructures/ConsoleClient';
|
||||||
import ContentMessageClient from '../infrastructures/content-message-client';
|
import ContentMessageClient from '../infrastructures/ContentMessageClient';
|
||||||
|
|
||||||
export default class MarkInteractor {
|
export default class MarkUseCase {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.tabPresenter = new TabPresenter();
|
this.tabPresenter = new TabPresenter();
|
||||||
this.markRepository = new MarkRepository();
|
this.markRepository = new MarkRepository();
|
||||||
this.consolePresenter = new ConsolePresenter();
|
this.consoleClient = new ConsoleClient();
|
||||||
this.contentMessageClient = new ContentMessageClient();
|
this.contentMessageClient = new ContentMessageClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ export default class MarkInteractor {
|
||||||
|
|
||||||
let mark = await this.markRepository.getMark(key);
|
let mark = await this.markRepository.getMark(key);
|
||||||
if (!mark) {
|
if (!mark) {
|
||||||
return this.consolePresenter.showError(current.id, 'Mark is not set');
|
return this.consoleClient.showError(current.id, 'Mark is not set');
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.contentMessageClient.scrollTo(
|
return this.contentMessageClient.scrollTo(
|
|
@ -1,5 +1,5 @@
|
||||||
import TabPresenter from '../presenters/tab';
|
import TabPresenter from '../presenters/TabPresenter';
|
||||||
import ConsolePresenter from '../presenters/console';
|
import ConsoleClient from '../infrastructures/ConsoleClient';
|
||||||
import * as urls from '../../shared/urls';
|
import * as urls from '../../shared/urls';
|
||||||
|
|
||||||
const ZOOM_SETTINGS = [
|
const ZOOM_SETTINGS = [
|
||||||
|
@ -7,10 +7,10 @@ const ZOOM_SETTINGS = [
|
||||||
1.10, 1.25, 1.50, 1.75, 2.00, 2.50, 3.00
|
1.10, 1.25, 1.50, 1.75, 2.00, 2.50, 3.00
|
||||||
];
|
];
|
||||||
|
|
||||||
export default class OperationInteractor {
|
export default class OperationUseCase {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.tabPresenter = new TabPresenter();
|
this.tabPresenter = new TabPresenter();
|
||||||
this.consolePresenter = new ConsolePresenter();
|
this.consoleClient = new ConsoleClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
async close(force) {
|
async close(force) {
|
||||||
|
@ -134,7 +134,7 @@ export default class OperationInteractor {
|
||||||
|
|
||||||
async showCommand() {
|
async showCommand() {
|
||||||
let tab = await this.tabPresenter.getCurrent();
|
let tab = await this.tabPresenter.getCurrent();
|
||||||
return this.consolePresenter.showCommand(tab.id, '');
|
return this.consoleClient.showCommand(tab.id, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
async showOpenCommand(alter) {
|
async showOpenCommand(alter) {
|
||||||
|
@ -143,7 +143,7 @@ export default class OperationInteractor {
|
||||||
if (alter) {
|
if (alter) {
|
||||||
command += tab.url;
|
command += tab.url;
|
||||||
}
|
}
|
||||||
return this.consolePresenter.showCommand(tab.id, command);
|
return this.consoleClient.showCommand(tab.id, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
async showTabopenCommand(alter) {
|
async showTabopenCommand(alter) {
|
||||||
|
@ -152,7 +152,7 @@ export default class OperationInteractor {
|
||||||
if (alter) {
|
if (alter) {
|
||||||
command += tab.url;
|
command += tab.url;
|
||||||
}
|
}
|
||||||
return this.consolePresenter.showCommand(tab.id, command);
|
return this.consoleClient.showCommand(tab.id, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
async showWinopenCommand(alter) {
|
async showWinopenCommand(alter) {
|
||||||
|
@ -161,13 +161,13 @@ export default class OperationInteractor {
|
||||||
if (alter) {
|
if (alter) {
|
||||||
command += tab.url;
|
command += tab.url;
|
||||||
}
|
}
|
||||||
return this.consolePresenter.showCommand(tab.id, command);
|
return this.consoleClient.showCommand(tab.id, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
async showBufferCommand() {
|
async showBufferCommand() {
|
||||||
let tab = await this.tabPresenter.getCurrent();
|
let tab = await this.tabPresenter.getCurrent();
|
||||||
let command = 'buffer ';
|
let command = 'buffer ';
|
||||||
return this.consolePresenter.showCommand(tab.id, command);
|
return this.consoleClient.showCommand(tab.id, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
async showAddbookmarkCommand(alter) {
|
async showAddbookmarkCommand(alter) {
|
||||||
|
@ -176,17 +176,17 @@ export default class OperationInteractor {
|
||||||
if (alter) {
|
if (alter) {
|
||||||
command += tab.title;
|
command += tab.title;
|
||||||
}
|
}
|
||||||
return this.consolePresenter.showCommand(tab.id, command);
|
return this.consoleClient.showCommand(tab.id, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
async findStart() {
|
async findStart() {
|
||||||
let tab = await this.tabPresenter.getCurrent();
|
let tab = await this.tabPresenter.getCurrent();
|
||||||
return this.consolePresenter.showFind(tab.id);
|
return this.consoleClient.showFind(tab.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
async hideConsole() {
|
async hideConsole() {
|
||||||
let tab = await this.tabPresenter.getCurrent();
|
let tab = await this.tabPresenter.getCurrent();
|
||||||
return this.consolePresenter.hide(tab.id);
|
return this.consoleClient.hide(tab.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
async openHome(newTab) {
|
async openHome(newTab) {
|
|
@ -1,8 +1,9 @@
|
||||||
import Setting from '../domains/setting';
|
import Setting from '../domains/Setting';
|
||||||
import PersistentSettingRepository from '../repositories/persistent-setting';
|
// eslint-disable-next-line max-len
|
||||||
import SettingRepository from '../repositories/setting';
|
import PersistentSettingRepository from '../repositories/PersistentSettingRepository';
|
||||||
|
import SettingRepository from '../repositories/SettingRepository';
|
||||||
|
|
||||||
export default class SettingInteractor {
|
export default class SettingUseCase {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.persistentSettingRepository = new PersistentSettingRepository();
|
this.persistentSettingRepository = new PersistentSettingRepository();
|
||||||
this.settingRepository = new SettingRepository();
|
this.settingRepository = new SettingRepository();
|
|
@ -1,9 +1,9 @@
|
||||||
import manifest from '../../../manifest.json';
|
import manifest from '../../../manifest.json';
|
||||||
import VersionRepository from '../repositories/version';
|
import VersionRepository from '../repositories/VersionRepository';
|
||||||
import TabPresenter from '../presenters/tab';
|
import TabPresenter from '../presenters/TabPresenter';
|
||||||
import Notifier from '../infrastructures/notifier';
|
import Notifier from '../infrastructures/Notifier';
|
||||||
|
|
||||||
export default class VersionInteractor {
|
export default class VersionUseCase {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.versionRepository = new VersionRepository();
|
this.versionRepository = new VersionRepository();
|
||||||
this.tabPresenter = new TabPresenter();
|
this.tabPresenter = new TabPresenter();
|
|
@ -1,4 +1,4 @@
|
||||||
import GlobalMark from 'background/domains/global-mark';
|
import GlobalMark from 'background/domains/GlobalMark';
|
||||||
|
|
||||||
describe('background/domains/global-mark', () => {
|
describe('background/domains/global-mark', () => {
|
||||||
describe('constructor and getter', () => {
|
describe('constructor and getter', () => {
|
|
@ -1,4 +1,4 @@
|
||||||
import MemoryStorage from 'background/infrastructures/memory-storage';
|
import MemoryStorage from 'background/infrastructures/MemoryStorage';
|
||||||
|
|
||||||
describe("background/infrastructures/memory-storage", () => {
|
describe("background/infrastructures/memory-storage", () => {
|
||||||
it('stores values', () => {
|
it('stores values', () => {
|
|
@ -1,5 +1,5 @@
|
||||||
import MarkRepository from 'background/repositories/mark';
|
import MarkRepository from 'background/repositories/MarkRepository';
|
||||||
import GlobalMark from 'background/domains/global-mark';
|
import GlobalMark from 'background/domains/GlobalMark';
|
||||||
|
|
||||||
describe('background/repositories/mark', () => {
|
describe('background/repositories/mark', () => {
|
||||||
let repository;
|
let repository;
|
|
@ -1,4 +1,4 @@
|
||||||
import VersionRepository from 'background/repositories/version';
|
import VersionRepository from 'background/repositories/Version';
|
||||||
|
|
||||||
describe("background/repositories/version", () => {
|
describe("background/repositories/version", () => {
|
||||||
let versionRepository;
|
let versionRepository;
|
Reference in a new issue