aboutsummaryrefslogtreecommitdiff
path: root/ext/js/app/content-script-main.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2024-02-07 02:55:48 -0500
committerGitHub <noreply@github.com>2024-02-07 07:55:48 +0000
commitdc22c0260e55121b2930f8bf8761271ba977503f (patch)
tree1c5cf6d59fb600dfc03e46f11d3fba3dfb30c8f1 /ext/js/app/content-script-main.js
parent376bac7195bf2114da8b234ffa64af9751b4466d (diff)
Update application init process (#634)
Diffstat (limited to 'ext/js/app/content-script-main.js')
-rw-r--r--ext/js/app/content-script-main.js67
1 files changed, 27 insertions, 40 deletions
diff --git a/ext/js/app/content-script-main.js b/ext/js/app/content-script-main.js
index d77f1fa0..23d36b48 100644
--- a/ext/js/app/content-script-main.js
+++ b/ext/js/app/content-script-main.js
@@ -17,49 +17,36 @@
*/
import {Application} from '../application.js';
-import {log} from '../core/logger.js';
import {HotkeyHandler} from '../input/hotkey-handler.js';
import {Frontend} from './frontend.js';
import {PopupFactory} from './popup-factory.js';
-/** Entry point. */
-async function main() {
- try {
- const application = new Application();
- await application.prepare();
-
- const {tabId, frameId} = await application.api.frameInformationGet();
- if (typeof frameId !== 'number') {
- throw new Error('Failed to get frameId');
- }
-
- const hotkeyHandler = new HotkeyHandler();
- hotkeyHandler.prepare(application.crossFrame);
-
- const popupFactory = new PopupFactory(application, frameId);
- popupFactory.prepare();
-
- const frontend = new Frontend({
- application,
- tabId,
- frameId,
- popupFactory,
- depth: 0,
- parentPopupId: null,
- parentFrameId: null,
- useProxyPopup: false,
- pageType: 'web',
- canUseWindowPopup: true,
- allowRootFramePopupProxy: true,
- childrenSupported: true,
- hotkeyHandler
- });
- await frontend.prepare();
-
- application.ready();
- } catch (e) {
- log.error(e);
+await Application.main(async (application) => {
+ const {tabId, frameId} = await application.api.frameInformationGet();
+ if (typeof frameId !== 'number') {
+ throw new Error('Failed to get frameId');
}
-}
-await main();
+ const hotkeyHandler = new HotkeyHandler();
+ hotkeyHandler.prepare(application.crossFrame);
+
+ const popupFactory = new PopupFactory(application, frameId);
+ popupFactory.prepare();
+
+ const frontend = new Frontend({
+ application,
+ tabId,
+ frameId,
+ popupFactory,
+ depth: 0,
+ parentPopupId: null,
+ parentFrameId: null,
+ useProxyPopup: false,
+ pageType: 'web',
+ canUseWindowPopup: true,
+ allowRootFramePopupProxy: true,
+ childrenSupported: true,
+ hotkeyHandler
+ });
+ await frontend.prepare();
+});