Merge pull request #463 from toasted-nutbread/explicit-entry-point
Explicit entry points
This commit is contained in:
commit
9216d1862f
@ -24,6 +24,7 @@
|
||||
|
||||
<script src="/bg/js/anki.js"></script>
|
||||
<script src="/bg/js/anki-note-builder.js"></script>
|
||||
<script src="/bg/js/backend.js"></script>
|
||||
<script src="/bg/js/mecab.js"></script>
|
||||
<script src="/bg/js/audio-uri-builder.js"></script>
|
||||
<script src="/bg/js/backend-api-forwarder.js"></script>
|
||||
@ -45,6 +46,6 @@
|
||||
<script src="/bg/js/util.js"></script>
|
||||
<script src="/mixed/js/audio-system.js"></script>
|
||||
|
||||
<script src="/bg/js/backend.js"></script>
|
||||
<script src="/bg/js/background-main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -185,6 +185,6 @@
|
||||
<script src="/bg/js/options.js"></script>
|
||||
<script src="/bg/js/util.js"></script>
|
||||
|
||||
<script src="/bg/js/context.js"></script>
|
||||
<script src="/bg/js/context-main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1059,6 +1059,3 @@ class Backend {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.yomichanBackend = new Backend();
|
||||
window.yomichanBackend.prepare();
|
||||
|
25
ext/bg/js/background-main.js
Normal file
25
ext/bg/js/background-main.js
Normal file
@ -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();
|
||||
})();
|
@ -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);
|
||||
})();
|
@ -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();
|
||||
})();
|
@ -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();
|
||||
|
25
ext/bg/js/settings/popup-preview-frame-main.js
Normal file
25
ext/bg/js/settings/popup-preview-frame-main.js
Normal file
@ -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();
|
||||
})();
|
@ -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();
|
||||
|
||||
|
||||
|
||||
|
@ -94,6 +94,7 @@
|
||||
<script src="/bg/js/search-query-parser.js"></script>
|
||||
<script src="/bg/js/clipboard-monitor.js"></script>
|
||||
<script src="/bg/js/search.js"></script>
|
||||
<script src="/bg/js/search-frontend.js"></script>
|
||||
|
||||
<script src="/bg/js/search-main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -129,5 +129,7 @@
|
||||
<script src="/fg/js/popup-proxy-host.js"></script>
|
||||
<script src="/fg/js/frontend.js"></script>
|
||||
<script src="/bg/js/settings/popup-preview-frame.js"></script>
|
||||
|
||||
<script src="/bg/js/settings/popup-preview-frame-main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -57,6 +57,6 @@
|
||||
|
||||
<script src="/fg/js/float.js"></script>
|
||||
|
||||
<script src="/fg/js/popup-nested.js"></script>
|
||||
<script src="/fg/js/float-main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -61,7 +61,7 @@ async function createPopupProxy(depth, id, parentFrameId, url) {
|
||||
return popup;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
(async () => {
|
||||
await yomichan.prepare();
|
||||
|
||||
const data = window.frontendInitializationData || {};
|
||||
@ -128,6 +128,4 @@ async function main() {
|
||||
window.addEventListener('fullscreenchange', applyOptions, false);
|
||||
|
||||
await applyOptions();
|
||||
}
|
||||
|
||||
main();
|
||||
})();
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2020 Yomichan Authors
|
||||
* 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
|
||||
@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
/* global
|
||||
* DisplayFloat
|
||||
* apiOptionsGet
|
||||
*/
|
||||
|
||||
@ -26,7 +27,7 @@ function injectPopupNested() {
|
||||
'/fg/js/popup.js',
|
||||
'/fg/js/popup-proxy.js',
|
||||
'/fg/js/frontend.js',
|
||||
'/fg/js/frontend-initialize.js'
|
||||
'/fg/js/content-script-main.js'
|
||||
];
|
||||
for (const src of scriptSrcs) {
|
||||
const script = document.createElement('script');
|
||||
@ -65,3 +66,7 @@ async function popupNestedInitialize(id, depth, parentFrameId, url) {
|
||||
|
||||
await applyOptions();
|
||||
}
|
||||
|
||||
(async () => {
|
||||
new DisplayFloat();
|
||||
})();
|
@ -189,5 +189,3 @@ class DisplayFloat extends Display {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DisplayFloat.instance = new DisplayFloat();
|
||||
|
@ -31,7 +31,7 @@
|
||||
"fg/js/popup-proxy.js",
|
||||
"fg/js/popup-proxy-host.js",
|
||||
"fg/js/frontend.js",
|
||||
"fg/js/frontend-initialize.js"
|
||||
"fg/js/content-script-main.js"
|
||||
],
|
||||
"match_about_blank": true,
|
||||
"all_frames": true
|
||||
|
Loading…
Reference in New Issue
Block a user