summaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-04-23 18:26:34 -0400
committerGitHub <noreply@github.com>2020-04-23 18:26:34 -0400
commit9216d1862fa8d0f51fe1dba603c2643aa8ef4215 (patch)
tree74f99b338dae8ecf6737eb3c9a234c26abed419a /ext/bg/js
parent6a39b0cd7a5f3145300fe48942b55122734ae0a5 (diff)
parentd8276a9d5d119edf1747593608d3e135947019f0 (diff)
Merge pull request #463 from toasted-nutbread/explicit-entry-point
Explicit entry points
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/backend.js3
-rw-r--r--ext/bg/js/background-main.js25
-rw-r--r--ext/bg/js/context-main.js (renamed from ext/bg/js/context.js)8
-rw-r--r--ext/bg/js/search-main.js (renamed from ext/bg/js/search-frontend.js)12
-rw-r--r--ext/bg/js/search.js8
-rw-r--r--ext/bg/js/settings/popup-preview-frame-main.js25
-rw-r--r--ext/bg/js/settings/popup-preview-frame.js11
7 files changed, 63 insertions, 29 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index 6b696f2c..693a9ad6 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -1059,6 +1059,3 @@ class Backend {
}
}
}
-
-window.yomichanBackend = new Backend();
-window.yomichanBackend.prepare();
diff --git a/ext/bg/js/background-main.js b/ext/bg/js/background-main.js
new file mode 100644
index 00000000..24117f4e
--- /dev/null
+++ b/ext/bg/js/background-main.js
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2020 Yomichan Authors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+/* global
+ * Backend
+ */
+
+(async () => {
+ window.yomichanBackend = new Backend();
+ await window.yomichanBackend.prepare();
+})();
diff --git a/ext/bg/js/context.js b/ext/bg/js/context-main.js
index e3d4ad4a..e2086a96 100644
--- a/ext/bg/js/context.js
+++ b/ext/bg/js/context-main.js
@@ -51,7 +51,7 @@ function setupButtonEvents(selector, command, url) {
}
}
-window.addEventListener('DOMContentLoaded', async () => {
+async function mainInner() {
await yomichan.prepare();
showExtensionInfo();
@@ -86,4 +86,8 @@ window.addEventListener('DOMContentLoaded', async () => {
}
}, 10);
});
-});
+}
+
+(async () => {
+ window.addEventListener('DOMContentLoaded', mainInner, false);
+})();
diff --git a/ext/bg/js/search-frontend.js b/ext/bg/js/search-main.js
index e534e771..38b6d99a 100644
--- a/ext/bg/js/search-frontend.js
+++ b/ext/bg/js/search-main.js
@@ -16,6 +16,7 @@
*/
/* global
+ * DisplaySearch
* apiOptionsGet
*/
@@ -27,7 +28,7 @@ function injectSearchFrontend() {
'/fg/js/popup.js',
'/fg/js/popup-proxy-host.js',
'/fg/js/frontend.js',
- '/fg/js/frontend-initialize.js'
+ '/fg/js/content-script-main.js'
];
for (const src of scriptSrcs) {
const node = document.querySelector(`script[src='${src}']`);
@@ -51,9 +52,12 @@ function injectSearchFrontend() {
}
}
-async function main() {
+(async () => {
await yomichan.prepare();
+ const displaySearch = new DisplaySearch();
+ await displaySearch.prepare();
+
let optionsApplied = false;
const applyOptions = async () => {
@@ -74,6 +78,4 @@ async function main() {
yomichan.on('optionsUpdated', applyOptions);
await applyOptions();
-}
-
-main();
+})();
diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js
index 006536c0..684ea6d3 100644
--- a/ext/bg/js/search.js
+++ b/ext/bg/js/search.js
@@ -73,12 +73,6 @@ class DisplaySearch extends Display {
]);
}
- static create() {
- const instance = new DisplaySearch();
- instance.prepare();
- return instance;
- }
-
async prepare() {
try {
await super.prepare();
@@ -377,5 +371,3 @@ class DisplaySearch extends Display {
}
}
}
-
-DisplaySearch.instance = DisplaySearch.create();
diff --git a/ext/bg/js/settings/popup-preview-frame-main.js b/ext/bg/js/settings/popup-preview-frame-main.js
new file mode 100644
index 00000000..86c2814c
--- /dev/null
+++ b/ext/bg/js/settings/popup-preview-frame-main.js
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2019-2020 Yomichan Authors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+/* global
+ * SettingsPopupPreview
+ */
+
+(async () => {
+ const instance = new SettingsPopupPreview();
+ await instance.prepare();
+})();
diff --git a/ext/bg/js/settings/popup-preview-frame.js b/ext/bg/js/settings/popup-preview-frame.js
index fba114e2..420a7c5a 100644
--- a/ext/bg/js/settings/popup-preview-frame.js
+++ b/ext/bg/js/settings/popup-preview-frame.js
@@ -41,12 +41,6 @@ class SettingsPopupPreview {
]);
}
- static create() {
- const instance = new SettingsPopupPreview();
- instance.prepare();
- return instance;
- }
-
async prepare() {
// Setup events
window.addEventListener('message', this.onMessage.bind(this), false);
@@ -178,8 +172,3 @@ class SettingsPopupPreview {
this.setInfoVisible(!this.popupShown);
}
}
-
-SettingsPopupPreview.instance = SettingsPopupPreview.create();
-
-
-