aboutsummaryrefslogtreecommitdiff
path: root/src/background
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-05-02 14:08:51 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2019-05-05 23:59:59 +0900
commitd01db82c0dca352de2d7644c383d388fc3ec0366 (patch)
treeff09ebc545ce00192dff9e1119b0c9e2cf92fdef /src/background
parent992b3ac65d7fe86ac7bc3b560960c8bcf86bec69 (diff)
Types src/content
Diffstat (limited to 'src/background')
-rw-r--r--src/background/controllers/OperationController.ts4
-rw-r--r--src/background/controllers/VersionController.ts2
-rw-r--r--src/background/domains/Setting.ts20
-rw-r--r--src/background/infrastructures/ConsoleClient.ts2
-rw-r--r--src/background/infrastructures/ContentMessageClient.ts2
-rw-r--r--src/background/infrastructures/ContentMessageListener.ts6
-rw-r--r--src/background/presenters/NotifyPresenter.ts6
-rw-r--r--src/background/usecases/VersionUseCase.ts2
8 files changed, 27 insertions, 17 deletions
diff --git a/src/background/controllers/OperationController.ts b/src/background/controllers/OperationController.ts
index 4e9c106..fa09512 100644
--- a/src/background/controllers/OperationController.ts
+++ b/src/background/controllers/OperationController.ts
@@ -1,4 +1,4 @@
-import operations from '../../shared/operations';
+import * as operations from '../../shared/operations';
import FindUseCase from '../usecases/FindUseCase';
import ConsoleUseCase from '../usecases/ConsoleUseCase';
import TabUseCase from '../usecases/TabUseCase';
@@ -25,7 +25,7 @@ export default class OperationController {
}
// eslint-disable-next-line complexity, max-lines-per-function
- exec(operation: any): Promise<any> {
+ exec(operation: operations.Operation): Promise<any> {
switch (operation.type) {
case operations.TAB_CLOSE:
return this.tabUseCase.close(false);
diff --git a/src/background/controllers/VersionController.ts b/src/background/controllers/VersionController.ts
index f402ed0..2e2a197 100644
--- a/src/background/controllers/VersionController.ts
+++ b/src/background/controllers/VersionController.ts
@@ -7,7 +7,7 @@ export default class VersionController {
this.versionUseCase = new VersionUseCase();
}
- notify(): void {
+ notify(): Promise<void> {
return this.versionUseCase.notify();
}
}
diff --git a/src/background/domains/Setting.ts b/src/background/domains/Setting.ts
index 106ec0f..b2b1ff2 100644
--- a/src/background/domains/Setting.ts
+++ b/src/background/domains/Setting.ts
@@ -1,22 +1,30 @@
import DefaultSettings from '../../shared/settings/default';
import * as settingsValues from '../../shared/settings/values';
+type SettingValue = {
+ source: string,
+ json: string,
+ form: any
+}
+
export default class Setting {
- constructor({ source, json, form }) {
+ private obj: SettingValue;
+
+ constructor({ source, json, form }: SettingValue) {
this.obj = {
source, json, form
};
}
- get source() {
+ get source(): string {
return this.obj.source;
}
- get json() {
+ get json(): string {
return this.obj.json;
}
- get form() {
+ get form(): any {
return this.obj.form;
}
@@ -33,11 +41,11 @@ export default class Setting {
return { ...settingsValues.valueFromJson(DefaultSettings.json), ...value };
}
- serialize() {
+ serialize(): SettingValue {
return this.obj;
}
- static deserialize(obj) {
+ static deserialize(obj: SettingValue): Setting {
return new Setting({ source: obj.source, json: obj.json, form: obj.form });
}
diff --git a/src/background/infrastructures/ConsoleClient.ts b/src/background/infrastructures/ConsoleClient.ts
index 7ad5d24..c162634 100644
--- a/src/background/infrastructures/ConsoleClient.ts
+++ b/src/background/infrastructures/ConsoleClient.ts
@@ -1,4 +1,4 @@
-import messages from '../../shared/messages';
+import * as messages from '../../shared/messages';
export default class ConsoleClient {
showCommand(tabId: number, command: string): Promise<any> {
diff --git a/src/background/infrastructures/ContentMessageClient.ts b/src/background/infrastructures/ContentMessageClient.ts
index 20057c7..d4bc476 100644
--- a/src/background/infrastructures/ContentMessageClient.ts
+++ b/src/background/infrastructures/ContentMessageClient.ts
@@ -1,4 +1,4 @@
-import messages from '../../shared/messages';
+import * as messages from '../../shared/messages';
export default class ContentMessageClient {
async broadcastSettingsChanged(): Promise<void> {
diff --git a/src/background/infrastructures/ContentMessageListener.ts b/src/background/infrastructures/ContentMessageListener.ts
index 81d3232..1cc2696 100644
--- a/src/background/infrastructures/ContentMessageListener.ts
+++ b/src/background/infrastructures/ContentMessageListener.ts
@@ -1,4 +1,4 @@
-import messages from '../../shared/messages';
+import * as messages from '../../shared/messages';
import CompletionGroup from '../domains/CompletionGroup';
import CommandController from '../controllers/CommandController';
import SettingController from '../controllers/SettingController';
@@ -68,7 +68,9 @@ export default class ContentMessageListener {
browser.runtime.onConnect.addListener(this.onConnected.bind(this));
}
- onMessage(message: any, senderTab: browser.tabs.Tab): Promise<any> | any {
+ onMessage(
+ message: messages.Message, senderTab: browser.tabs.Tab,
+ ): Promise<any> | any {
switch (message.type) {
case messages.CONSOLE_QUERY_COMPLETIONS:
return this.onConsoleQueryCompletions(message.text);
diff --git a/src/background/presenters/NotifyPresenter.ts b/src/background/presenters/NotifyPresenter.ts
index c83c205..23932f7 100644
--- a/src/background/presenters/NotifyPresenter.ts
+++ b/src/background/presenters/NotifyPresenter.ts
@@ -1,11 +1,11 @@
const NOTIFICATION_ID = 'vimvixen-update';
export default class NotifyPresenter {
- notify(
+ async notify(
title: string,
message: string,
onclick: () => void,
- ): Promise<string> {
+ ): Promise<void> {
const listener = (id: string) => {
if (id !== NOTIFICATION_ID) {
return;
@@ -17,7 +17,7 @@ export default class NotifyPresenter {
};
browser.notifications.onClicked.addListener(listener);
- return browser.notifications.create(NOTIFICATION_ID, {
+ await browser.notifications.create(NOTIFICATION_ID, {
'type': 'basic',
'iconUrl': browser.extension.getURL('resources/icon_48x48.png'),
title,
diff --git a/src/background/usecases/VersionUseCase.ts b/src/background/usecases/VersionUseCase.ts
index 207f9e2..3a3cc2e 100644
--- a/src/background/usecases/VersionUseCase.ts
+++ b/src/background/usecases/VersionUseCase.ts
@@ -12,7 +12,7 @@ export default class VersionUseCase {
this.notifyPresenter = new NotifyPresenter();
}
- notify(): Promise<string> {
+ notify(): Promise<void> {
let title = `Vim Vixen ${manifest.version} has been installed`;
let message = 'Click here to see release notes';
let url = this.releaseNoteUrl(manifest.version);