summaryrefslogtreecommitdiff
path: root/ext/js/display
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/display')
-rw-r--r--ext/js/display/display-anki.js15
-rw-r--r--ext/js/display/display-audio.js3
-rw-r--r--ext/js/display/display-content-manager.js3
-rw-r--r--ext/js/display/display-generator.js9
-rw-r--r--ext/js/display/display-profile-selection.js7
-rw-r--r--ext/js/display/display.js48
-rw-r--r--ext/js/display/option-toggle-hotkey-handler.js7
-rw-r--r--ext/js/display/popup-main.js13
-rw-r--r--ext/js/display/query-parser.js10
-rw-r--r--ext/js/display/search-display-controller.js9
-rw-r--r--ext/js/display/search-main.js14
11 files changed, 74 insertions, 64 deletions
diff --git a/ext/js/display/display-anki.js b/ext/js/display/display-anki.js
index 68d28d33..c19cfa22 100644
--- a/ext/js/display/display-anki.js
+++ b/ext/js/display/display-anki.js
@@ -24,7 +24,6 @@ import {isNoteDataValid} from '../data/anki-util.js';
import {PopupMenu} from '../dom/popup-menu.js';
import {querySelectorNotNull} from '../dom/query-selector.js';
import {TemplateRendererProxy} from '../templates/template-renderer-proxy.js';
-import {yomitan} from '../yomitan.js';
export class DisplayAnki {
/**
@@ -41,7 +40,7 @@ export class DisplayAnki {
/** @type {?string} */
this._ankiFieldTemplatesDefault = null;
/** @type {AnkiNoteBuilder} */
- this._ankiNoteBuilder = new AnkiNoteBuilder(new TemplateRendererProxy());
+ this._ankiNoteBuilder = new AnkiNoteBuilder(display.application.api, new TemplateRendererProxy());
/** @type {?import('./display-notification.js').DisplayNotification} */
this._errorNotification = null;
/** @type {?EventListenerCollection} */
@@ -487,7 +486,7 @@ export class DisplayAnki {
let noteId = null;
let addNoteOkay = false;
try {
- noteId = await yomitan.api.addAnkiNote(note);
+ noteId = await this._display.application.api.addAnkiNote(note);
addNoteOkay = true;
} catch (e) {
allErrors.length = 0;
@@ -500,7 +499,7 @@ export class DisplayAnki {
} else {
if (this._suspendNewCards) {
try {
- await yomitan.api.suspendAnkiCardsForNote(noteId);
+ await this._display.application.api.suspendAnkiCardsForNote(noteId);
} catch (e) {
allErrors.push(toError(e));
}
@@ -605,7 +604,7 @@ export class DisplayAnki {
templates = this._ankiFieldTemplatesDefault;
if (typeof templates === 'string') { return templates; }
- templates = await yomitan.api.getDefaultAnkiFieldTemplates();
+ templates = await this._display.application.api.getDefaultAnkiFieldTemplates();
this._ankiFieldTemplatesDefault = templates;
return templates;
}
@@ -639,12 +638,12 @@ export class DisplayAnki {
let ankiError = null;
try {
if (forceCanAddValue !== null) {
- if (!await yomitan.api.isAnkiConnected()) {
+ if (!await this._display.application.api.isAnkiConnected()) {
throw new Error('Anki not connected');
}
infos = this._getAnkiNoteInfoForceValue(notes, forceCanAddValue);
} else {
- infos = await yomitan.api.getAnkiNoteInfo(notes, fetchAdditionalInfo);
+ infos = await this._display.application.api.getAnkiNoteInfo(notes, fetchAdditionalInfo);
}
} catch (e) {
infos = this._getAnkiNoteInfoForceValue(notes, false);
@@ -853,7 +852,7 @@ export class DisplayAnki {
const noteIds = this._getNodeNoteIds(node);
if (noteIds.length === 0) { return; }
try {
- await yomitan.api.noteView(noteIds[0], this._noteGuiMode, false);
+ await this._display.application.api.noteView(noteIds[0], this._noteGuiMode, false);
} catch (e) {
const displayErrors = (
toError(e).message === 'Mode not supported' ?
diff --git a/ext/js/display/display-audio.js b/ext/js/display/display-audio.js
index 8cbfc83f..4acd6494 100644
--- a/ext/js/display/display-audio.js
+++ b/ext/js/display/display-audio.js
@@ -20,7 +20,6 @@ import {EventListenerCollection} from '../core/event-listener-collection.js';
import {PopupMenu} from '../dom/popup-menu.js';
import {querySelectorNotNull} from '../dom/query-selector.js';
import {AudioSystem} from '../media/audio-system.js';
-import {yomitan} from '../yomitan.js';
export class DisplayAudio {
/**
@@ -676,7 +675,7 @@ export class DisplayAudio {
*/
async _getTermAudioInfoList(source, term, reading) {
const sourceData = this._getSourceData(source);
- const infoList = await yomitan.api.getTermAudioInfoList(sourceData, term, reading);
+ const infoList = await this._display.application.api.getTermAudioInfoList(sourceData, term, reading);
return infoList.map((info) => ({info, audioPromise: null, audioResolved: false, audio: null}));
}
diff --git a/ext/js/display/display-content-manager.js b/ext/js/display/display-content-manager.js
index 4465ce3e..81742279 100644
--- a/ext/js/display/display-content-manager.js
+++ b/ext/js/display/display-content-manager.js
@@ -18,7 +18,6 @@
import {EventListenerCollection} from '../core/event-listener-collection.js';
import {base64ToArrayBuffer} from '../data/sandbox/array-buffer-util.js';
-import {yomitan} from '../yomitan.js';
/**
* The content manager which is used when generating HTML display content.
@@ -140,7 +139,7 @@ export class DisplayContentManager {
*/
async _getMediaData(path, dictionary) {
const token = this._token;
- const datas = await yomitan.api.getMedia([{path, dictionary}]);
+ const datas = await this._display.application.api.getMedia([{path, dictionary}]);
if (token === this._token && datas.length > 0) {
const data = datas[0];
const buffer = base64ToArrayBuffer(data.content);
diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js
index 01f6f38b..fdfe3d4a 100644
--- a/ext/js/display/display-generator.js
+++ b/ext/js/display/display-generator.js
@@ -21,7 +21,6 @@ import {isObject} from '../core/utilities.js';
import {getDisambiguations, getGroupedPronunciations, getTermFrequency, groupKanjiFrequencies, groupTermFrequencies, groupTermTags, isNonNounVerbOrAdjective} from '../dictionary/dictionary-data-util.js';
import {HtmlTemplateCollection} from '../dom/html-template-collection.js';
import {distributeFurigana, getKanaMorae, getPitchCategory, isCodePointKanji, isStringPartiallyJapanese} from '../language/japanese.js';
-import {yomitan} from '../yomitan.js';
import {createPronunciationDownstepPosition, createPronunciationGraph, createPronunciationText} from './sandbox/pronunciation-generator.js';
import {StructuredContentGenerator} from './sandbox/structured-content-generator.js';
@@ -40,9 +39,11 @@ export class DisplayGenerator {
this._structuredContentGenerator = new StructuredContentGenerator(this._contentManager, document);
}
- /** */
- async prepare() {
- const html = await yomitan.api.getDisplayTemplatesHtml();
+ /**
+ * @param {import('../comm/api.js').API} api
+ */
+ async prepare(api) {
+ const html = await api.getDisplayTemplatesHtml();
this._templates.load(html);
this.updateHotkeys();
}
diff --git a/ext/js/display/display-profile-selection.js b/ext/js/display/display-profile-selection.js
index b61b49d5..3df79b74 100644
--- a/ext/js/display/display-profile-selection.js
+++ b/ext/js/display/display-profile-selection.js
@@ -20,7 +20,6 @@ import {EventListenerCollection} from '../core/event-listener-collection.js';
import {generateId} from '../core/utilities.js';
import {PanelElement} from '../dom/panel-element.js';
import {querySelectorNotNull} from '../dom/query-selector.js';
-import {yomitan} from '../yomitan.js';
export class DisplayProfileSelection {
/**
@@ -50,7 +49,7 @@ export class DisplayProfileSelection {
/** */
async prepare() {
- yomitan.on('optionsUpdated', this._onOptionsUpdated.bind(this));
+ this._display.application.on('optionsUpdated', this._onOptionsUpdated.bind(this));
this._profileButton.addEventListener('click', this._onProfileButtonClick.bind(this), false);
this._profileListNeedsUpdate = true;
}
@@ -92,7 +91,7 @@ export class DisplayProfileSelection {
/** */
async _updateProfileList() {
this._profileListNeedsUpdate = false;
- const options = await yomitan.api.optionsGetFull();
+ const options = await this._display.application.api.optionsGetFull();
this._eventListeners.removeAllEventListeners();
const displayGenerator = this._display.displayGenerator;
@@ -138,7 +137,7 @@ export class DisplayProfileSelection {
scope: 'global',
optionsContext: null
};
- await yomitan.api.modifySettings([modification], this._source);
+ await this._display.application.api.modifySettings([modification], this._source);
this._setProfilePanelVisible(false);
}
}
diff --git a/ext/js/display/display.js b/ext/js/display/display.js
index c7a2775d..4114cc45 100644
--- a/ext/js/display/display.js
+++ b/ext/js/display/display.js
@@ -32,7 +32,6 @@ import {ScrollElement} from '../dom/scroll-element.js';
import {TextSourceGenerator} from '../dom/text-source-generator.js';
import {HotkeyHelpController} from '../input/hotkey-help-controller.js';
import {TextScanner} from '../language/text-scanner.js';
-import {yomitan} from '../yomitan.js';
import {DisplayContentManager} from './display-content-manager.js';
import {DisplayGenerator} from './display-generator.js';
import {DisplayHistory} from './display-history.js';
@@ -46,14 +45,17 @@ import {QueryParser} from './query-parser.js';
*/
export class Display extends EventDispatcher {
/**
+ * @param {import('../application.js').Application} application
* @param {number|undefined} tabId
* @param {number|undefined} frameId
* @param {import('display').DisplayPageType} pageType
* @param {import('../dom/document-focus-controller.js').DocumentFocusController} documentFocusController
* @param {import('../input/hotkey-handler.js').HotkeyHandler} hotkeyHandler
*/
- constructor(tabId, frameId, pageType, documentFocusController, hotkeyHandler) {
+ constructor(application, tabId, frameId, pageType, documentFocusController, hotkeyHandler) {
super();
+ /** @type {import('../application.js').Application} */
+ this._application = application;
/** @type {number|undefined} */
this._tabId = tabId;
/** @type {number|undefined} */
@@ -131,6 +133,7 @@ export class Display extends EventDispatcher {
this._textSourceGenerator = new TextSourceGenerator();
/** @type {QueryParser} */
this._queryParser = new QueryParser({
+ api: application.api,
getSearchContext: this._getSearchContext.bind(this),
textSourceGenerator: this._textSourceGenerator
});
@@ -163,7 +166,7 @@ export class Display extends EventDispatcher {
/** @type {boolean} */
this._childrenSupported = true;
/** @type {?FrameEndpoint} */
- this._frameEndpoint = (pageType === 'popup' ? new FrameEndpoint() : null);
+ this._frameEndpoint = (pageType === 'popup' ? new FrameEndpoint(this._application.api) : null);
/** @type {?import('environment').Browser} */
this._browser = null;
/** @type {?HTMLTextAreaElement} */
@@ -224,6 +227,11 @@ export class Display extends EventDispatcher {
/* eslint-enable no-multi-spaces */
}
+ /** @type {import('../application.js').Application} */
+ get application() {
+ return this._application;
+ }
+
/** @type {DisplayGenerator} */
get displayGenerator() {
return this._displayGenerator;
@@ -307,7 +315,7 @@ export class Display extends EventDispatcher {
// State setup
const {documentElement} = document;
- const {browser} = await yomitan.api.getEnvironmentInfo();
+ const {browser} = await this._application.api.getEnvironmentInfo();
this._browser = browser;
if (documentElement !== null) {
@@ -315,8 +323,8 @@ export class Display extends EventDispatcher {
}
// Prepare
- await this._hotkeyHelpController.prepare();
- await this._displayGenerator.prepare();
+ await this._hotkeyHelpController.prepare(this._application.api);
+ await this._displayGenerator.prepare(this._application.api);
this._queryParser.prepare();
this._history.prepare();
this._optionToggleHotkeyHandler.prepare();
@@ -325,8 +333,8 @@ export class Display extends EventDispatcher {
this._history.on('stateChanged', this._onStateChanged.bind(this));
this._queryParser.on('searched', this._onQueryParserSearch.bind(this));
this._progressIndicatorVisible.on('change', this._onProgressIndicatorVisibleChanged.bind(this));
- yomitan.on('extensionUnloaded', this._onExtensionUnloaded.bind(this));
- yomitan.crossFrame.registerHandlers([
+ this._application.on('extensionUnloaded', this._onExtensionUnloaded.bind(this));
+ this._application.crossFrame.registerHandlers([
['displayPopupMessage1', this._onDisplayPopupMessage1.bind(this)],
['displayPopupMessage2', this._onDisplayPopupMessage2.bind(this)]
]);
@@ -384,7 +392,7 @@ export class Display extends EventDispatcher {
* @param {Error} error
*/
onError(error) {
- if (yomitan.webExtension.unloaded) { return; }
+ if (this._application.webExtension.unloaded) { return; }
log.error(error);
}
@@ -412,7 +420,7 @@ export class Display extends EventDispatcher {
/** */
async updateOptions() {
- const options = await yomitan.api.optionsGet(this.getOptionsContext());
+ const options = await this._application.api.optionsGet(this.getOptionsContext());
const {scanning: scanningOptions, sentenceParsing: sentenceParsingOptions} = options;
this._options = options;
@@ -586,7 +594,7 @@ export class Display extends EventDispatcher {
if (typeof this._contentOriginTabId !== 'number' || typeof this._contentOriginFrameId !== 'number') {
throw new Error('No content origin is assigned');
}
- return await yomitan.crossFrame.invokeTab(this._contentOriginTabId, this._contentOriginFrameId, action, params);
+ return await this._application.crossFrame.invokeTab(this._contentOriginTabId, this._contentOriginFrameId, action, params);
}
/**
@@ -599,7 +607,7 @@ export class Display extends EventDispatcher {
if (this._parentFrameId === null || this._parentFrameId === this._frameId) {
throw new Error('Invalid parent frame');
}
- return await yomitan.crossFrame.invoke(this._parentFrameId, action, params);
+ return await this._application.crossFrame.invoke(this._parentFrameId, action, params);
}
/**
@@ -721,7 +729,7 @@ export class Display extends EventDispatcher {
/** @type {import('display').WindowApiHandler<'displayExtensionUnloaded'>} */
_onMessageExtensionUnloaded() {
- yomitan.webExtension.triggerUnloaded();
+ this._application.webExtension.triggerUnloaded();
}
// Private
@@ -900,7 +908,7 @@ export class Display extends EventDispatcher {
const element = /** @type {Element} */ (e.currentTarget);
let query = element.textContent;
if (query === null) { query = ''; }
- const dictionaryEntries = await yomitan.api.kanjiFind(query, optionsContext);
+ const dictionaryEntries = await this._application.api.kanjiFind(query, optionsContext);
/** @type {import('display').ContentDetails} */
const details = {
focus: false,
@@ -1136,7 +1144,7 @@ export class Display extends EventDispatcher {
*/
async _findDictionaryEntries(isKanji, source, wildcardsEnabled, optionsContext) {
if (isKanji) {
- const dictionaryEntries = await yomitan.api.kanjiFind(source, optionsContext);
+ const dictionaryEntries = await this._application.api.kanjiFind(source, optionsContext);
return dictionaryEntries;
} else {
/** @type {import('api').FindTermsDetails} */
@@ -1155,7 +1163,7 @@ export class Display extends EventDispatcher {
}
}
- const {dictionaryEntries} = await yomitan.api.termsFind(source, findDetails, optionsContext);
+ const {dictionaryEntries} = await this._application.api.termsFind(source, findDetails, optionsContext);
return dictionaryEntries;
}
}
@@ -1640,7 +1648,7 @@ export class Display extends EventDispatcher {
/** */
_closePopups() {
- yomitan.triggerClosePopups();
+ this._application.triggerClosePopups();
}
/**
@@ -1711,11 +1719,12 @@ export class Display extends EventDispatcher {
import('../app/frontend.js')
]);
- const popupFactory = new PopupFactory(this._frameId);
+ const popupFactory = new PopupFactory(this._application, this._frameId);
popupFactory.prepare();
/** @type {import('frontend').ConstructorDetails} */
const setupNestedPopupsOptions = {
+ application: this._application,
useProxyPopup,
parentPopupId,
parentFrameId,
@@ -1828,6 +1837,7 @@ export class Display extends EventDispatcher {
if (this._contentTextScanner === null) {
this._contentTextScanner = new TextScanner({
+ api: this._application.api,
node: window,
getSearchContext: this._getSearchContext.bind(this),
searchTerms: true,
@@ -1888,7 +1898,7 @@ export class Display extends EventDispatcher {
* @param {import('text-scanner').SearchedEventDetails} details
*/
_onContentTextScannerSearched({type, dictionaryEntries, sentence, textSource, optionsContext, error}) {
- if (error !== null && !yomitan.webExtension.unloaded) {
+ if (error !== null && !this._application.webExtension.unloaded) {
log.error(error);
}
diff --git a/ext/js/display/option-toggle-hotkey-handler.js b/ext/js/display/option-toggle-hotkey-handler.js
index d9065e7f..b2f48a3e 100644
--- a/ext/js/display/option-toggle-hotkey-handler.js
+++ b/ext/js/display/option-toggle-hotkey-handler.js
@@ -16,10 +16,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-import {generateId} from '../core/utilities.js';
import {ExtensionError} from '../core/extension-error.js';
import {toError} from '../core/to-error.js';
-import {yomitan} from '../yomitan.js';
+import {generateId} from '../core/utilities.js';
export class OptionToggleHotkeyHandler {
/**
@@ -72,7 +71,7 @@ export class OptionToggleHotkeyHandler {
try {
const optionsContext = this._display.getOptionsContext();
- const getSettingsResponse = (await yomitan.api.getSettings([{
+ const getSettingsResponse = (await this._display.application.api.getSettings([{
scope: 'profile',
path,
optionsContext
@@ -97,7 +96,7 @@ export class OptionToggleHotkeyHandler {
value,
optionsContext
};
- const modifySettingsResponse = (await yomitan.api.modifySettings([modification], this._source))[0];
+ const modifySettingsResponse = (await this._display.application.api.modifySettings([modification], this._source))[0];
const {error: modifySettingsError} = modifySettingsResponse;
if (typeof modifySettingsError !== 'undefined') {
throw ExtensionError.deserialize(modifySettingsError);
diff --git a/ext/js/display/popup-main.js b/ext/js/display/popup-main.js
index 870e039e..2ca2fcd3 100644
--- a/ext/js/display/popup-main.js
+++ b/ext/js/display/popup-main.js
@@ -16,10 +16,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+import {Application} from '../application.js';
import {log} from '../core/logger.js';
import {DocumentFocusController} from '../dom/document-focus-controller.js';
import {HotkeyHandler} from '../input/hotkey-handler.js';
-import {yomitan} from '../yomitan.js';
import {DisplayAnki} from './display-anki.js';
import {DisplayAudio} from './display-audio.js';
import {DisplayProfileSelection} from './display-profile-selection.js';
@@ -32,14 +32,15 @@ async function main() {
const documentFocusController = new DocumentFocusController();
documentFocusController.prepare();
- await yomitan.prepare();
+ const application = new Application();
+ await application.prepare();
- const {tabId, frameId} = await yomitan.api.frameInformationGet();
+ const {tabId, frameId} = await application.api.frameInformationGet();
const hotkeyHandler = new HotkeyHandler();
- hotkeyHandler.prepare();
+ hotkeyHandler.prepare(application.crossFrame);
- const display = new Display(tabId, frameId, 'popup', documentFocusController, hotkeyHandler);
+ const display = new Display(application, tabId, frameId, 'popup', documentFocusController, hotkeyHandler);
await display.prepare();
const displayAudio = new DisplayAudio(display);
@@ -58,7 +59,7 @@ async function main() {
document.documentElement.dataset.loaded = 'true';
- yomitan.ready();
+ application.ready();
} catch (e) {
log.error(e);
}
diff --git a/ext/js/display/query-parser.js b/ext/js/display/query-parser.js
index 178bb110..daa298d2 100644
--- a/ext/js/display/query-parser.js
+++ b/ext/js/display/query-parser.js
@@ -21,7 +21,6 @@ import {log} from '../core/logger.js';
import {querySelectorNotNull} from '../dom/query-selector.js';
import {convertHiraganaToKatakana, convertKatakanaToHiragana, isStringEntirelyKana} from '../language/japanese.js';
import {TextScanner} from '../language/text-scanner.js';
-import {yomitan} from '../yomitan.js';
/**
* @augments EventDispatcher<import('query-parser').Events>
@@ -30,8 +29,10 @@ export class QueryParser extends EventDispatcher {
/**
* @param {import('display').QueryParserConstructorDetails} details
*/
- constructor({getSearchContext, textSourceGenerator}) {
+ constructor({api, getSearchContext, textSourceGenerator}) {
super();
+ /** @type {import('../comm/api.js').API} */
+ this._api = api;
/** @type {import('display').GetSearchContextCallback} */
this._getSearchContext = getSearchContext;
/** @type {string} */
@@ -58,6 +59,7 @@ export class QueryParser extends EventDispatcher {
this._queryParserModeSelect = querySelectorNotNull(document, '#query-parser-mode-select');
/** @type {TextScanner} */
this._textScanner = new TextScanner({
+ api,
node: this._queryParser,
getSearchContext,
searchTerms: true,
@@ -128,7 +130,7 @@ export class QueryParser extends EventDispatcher {
/** @type {?import('core').TokenObject} */
const token = {};
this._setTextToken = token;
- this._parseResults = await yomitan.api.parseText(text, this._getOptionsContext(), this._scanLength, this._useInternalParser, this._useMecabParser);
+ this._parseResults = await this._api.parseText(text, this._getOptionsContext(), this._scanLength, this._useInternalParser, this._useMecabParser);
if (this._setTextToken !== token) { return; }
this._refreshSelectedParser();
@@ -214,7 +216,7 @@ export class QueryParser extends EventDispatcher {
scope: 'profile',
optionsContext
};
- yomitan.api.modifySettings([modification], 'search');
+ this._api.modifySettings([modification], 'search');
}
/**
diff --git a/ext/js/display/search-display-controller.js b/ext/js/display/search-display-controller.js
index ff4340c1..49c69520 100644
--- a/ext/js/display/search-display-controller.js
+++ b/ext/js/display/search-display-controller.js
@@ -21,7 +21,6 @@ import {ClipboardMonitor} from '../comm/clipboard-monitor.js';
import {createApiMap, invokeApiMapHandler} from '../core/api-map.js';
import {EventListenerCollection} from '../core/event-listener-collection.js';
import {querySelectorNotNull} from '../dom/query-selector.js';
-import {yomitan} from '../yomitan.js';
export class SearchDisplayController {
/**
@@ -71,7 +70,7 @@ export class SearchDisplayController {
/** @type {ClipboardMonitor} */
this._clipboardMonitor = new ClipboardMonitor({
clipboardReader: {
- getText: yomitan.api.clipboardGet.bind(yomitan.api)
+ getText: this._display.application.api.clipboardGet.bind(this._display.application.api)
}
});
/** @type {import('application').ApiMap} */
@@ -89,7 +88,7 @@ export class SearchDisplayController {
this._searchPersistentStateController.on('modeChange', this._onModeChange.bind(this));
chrome.runtime.onMessage.addListener(this._onMessage.bind(this));
- yomitan.on('optionsUpdated', this._onOptionsUpdated.bind(this));
+ this._display.application.on('optionsUpdated', this._onOptionsUpdated.bind(this));
this._display.on('optionsUpdated', this._onDisplayOptionsUpdated.bind(this));
this._display.on('contentUpdateStart', this._onContentUpdateStart.bind(this));
@@ -297,7 +296,7 @@ export class SearchDisplayController {
scope: 'profile',
optionsContext: this._display.getOptionsContext()
};
- yomitan.api.modifySettings([modification], 'search');
+ this._display.application.api.modifySettings([modification], 'search');
}
/**
@@ -430,7 +429,7 @@ export class SearchDisplayController {
scope: 'profile',
optionsContext: this._display.getOptionsContext()
};
- await yomitan.api.modifySettings([modification], 'search');
+ await this._display.application.api.modifySettings([modification], 'search');
}
/** */
diff --git a/ext/js/display/search-main.js b/ext/js/display/search-main.js
index dedad163..dc4f1b7e 100644
--- a/ext/js/display/search-main.js
+++ b/ext/js/display/search-main.js
@@ -16,10 +16,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+import {Application} from '../application.js';
import {log} from '../core/logger.js';
import {DocumentFocusController} from '../dom/document-focus-controller.js';
import {HotkeyHandler} from '../input/hotkey-handler.js';
-import {yomitan} from '../yomitan.js';
import {DisplayAnki} from './display-anki.js';
import {DisplayAudio} from './display-audio.js';
import {Display} from './display.js';
@@ -30,6 +30,8 @@ import {SearchPersistentStateController} from './search-persistent-state-control
/** Entry point. */
async function main() {
try {
+ const application = new Application();
+
const documentFocusController = new DocumentFocusController('#search-textbox');
documentFocusController.prepare();
@@ -39,14 +41,14 @@ async function main() {
const searchActionPopupController = new SearchActionPopupController(searchPersistentStateController);
searchActionPopupController.prepare();
- await yomitan.prepare();
+ await application.prepare();
- const {tabId, frameId} = await yomitan.api.frameInformationGet();
+ const {tabId, frameId} = await application.api.frameInformationGet();
const hotkeyHandler = new HotkeyHandler();
- hotkeyHandler.prepare();
+ hotkeyHandler.prepare(application.crossFrame);
- const display = new Display(tabId, frameId, 'search', documentFocusController, hotkeyHandler);
+ const display = new Display(application, tabId, frameId, 'search', documentFocusController, hotkeyHandler);
await display.prepare();
const displayAudio = new DisplayAudio(display);
@@ -62,7 +64,7 @@ async function main() {
document.documentElement.dataset.loaded = 'true';
- yomitan.ready();
+ application.ready();
} catch (e) {
log.error(e);
}