From dfd42bad0b46845ad88d1fdc5fa82b4f03bab0f3 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Thu, 1 Feb 2024 10:00:59 -0500 Subject: Application refactor (#591) * Rename Yomitan class to Application, change initialization style * Rename file * Update init * Update config * Remove dead code --- ext/js/input/hotkey-handler.js | 6 +++--- ext/js/input/hotkey-help-controller.js | 9 ++++----- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'ext/js/input') diff --git a/ext/js/input/hotkey-handler.js b/ext/js/input/hotkey-handler.js index 3b40a86d..9caedcc2 100644 --- a/ext/js/input/hotkey-handler.js +++ b/ext/js/input/hotkey-handler.js @@ -19,7 +19,6 @@ import {EventDispatcher} from '../core/event-dispatcher.js'; import {EventListenerCollection} from '../core/event-listener-collection.js'; import {DocumentUtil} from '../dom/document-util.js'; -import {yomitan} from '../yomitan.js'; /** * Class which handles hotkey events and actions. @@ -47,11 +46,12 @@ export class HotkeyHandler extends EventDispatcher { /** * Begins listening to key press events in order to detect hotkeys. + * @param {import('../comm/cross-frame-api.js').CrossFrameAPI} crossFrameApi */ - prepare() { + prepare(crossFrameApi) { this._isPrepared = true; this._updateEventHandlers(); - yomitan.crossFrame.registerHandlers([ + crossFrameApi.registerHandlers([ ['hotkeyHandlerForwardHotkey', this._onMessageForwardHotkey.bind(this)] ]); } diff --git a/ext/js/input/hotkey-help-controller.js b/ext/js/input/hotkey-help-controller.js index 4c4f56d5..a75ab9db 100644 --- a/ext/js/input/hotkey-help-controller.js +++ b/ext/js/input/hotkey-help-controller.js @@ -16,9 +16,8 @@ * along with this program. If not, see . */ -import {isObject} from '../core/utilities.js'; import {parseJson} from '../core/json.js'; -import {yomitan} from '../yomitan.js'; +import {isObject} from '../core/utilities.js'; import {HotkeyUtil} from './hotkey-util.js'; export class HotkeyHelpController { @@ -34,10 +33,10 @@ export class HotkeyHelpController { } /** - * @returns {Promise} + * @param {import('../comm/api.js').API} api */ - async prepare() { - const {platform: {os}} = await yomitan.api.getEnvironmentInfo(); + async prepare(api) { + const {platform: {os}} = await api.getEnvironmentInfo(); this._hotkeyUtil.os = os; await this._setupGlobalCommands(this._globalActionHotkeys); } -- cgit v1.2.3