summaryrefslogtreecommitdiff
path: root/ext/js/comm/cross-frame-api.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2024-02-01 10:00:59 -0500
committerGitHub <noreply@github.com>2024-02-01 15:00:59 +0000
commitdfd42bad0b46845ad88d1fdc5fa82b4f03bab0f3 (patch)
tree04686b943b84b33b8927238be17e4bc0dda7eb62 /ext/js/comm/cross-frame-api.js
parent2356223942a21d1683ac38eed8e7b9485f453d87 (diff)
Application refactor (#591)
* Rename Yomitan class to Application, change initialization style * Rename file * Update init * Update config * Remove dead code
Diffstat (limited to 'ext/js/comm/cross-frame-api.js')
-rw-r--r--ext/js/comm/cross-frame-api.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/ext/js/comm/cross-frame-api.js b/ext/js/comm/cross-frame-api.js
index fca7c84d..eb9bed38 100644
--- a/ext/js/comm/cross-frame-api.js
+++ b/ext/js/comm/cross-frame-api.js
@@ -22,7 +22,6 @@ import {EventListenerCollection} from '../core/event-listener-collection.js';
import {ExtensionError} from '../core/extension-error.js';
import {parseJson} from '../core/json.js';
import {log} from '../core/logger.js';
-import {yomitan} from '../yomitan.js';
/**
* @augments EventDispatcher<import('cross-frame-api').CrossFrameAPIPortEvents>
@@ -290,7 +289,12 @@ export class CrossFrameAPIPort extends EventDispatcher {
}
export class CrossFrameAPI {
- constructor() {
+ /**
+ * @param {import('../comm/api.js').API} api
+ */
+ constructor(api) {
+ /** @type {import('../comm/api.js').API} */
+ this._api = api;
/** @type {number} */
this._ackTimeout = 3000; // 3 seconds
/** @type {number} */
@@ -310,7 +314,7 @@ export class CrossFrameAPI {
/** */
async prepare() {
chrome.runtime.onConnect.addListener(this._onConnect.bind(this));
- ({tabId: this._tabId = null, frameId: this._frameId = null} = await yomitan.api.frameInformationGet());
+ ({tabId: this._tabId = null, frameId: this._frameId = null} = await this._api.frameInformationGet());
}
/**
@@ -411,7 +415,7 @@ export class CrossFrameAPI {
* @returns {Promise<CrossFrameAPIPort>}
*/
async _createCommPort(otherTabId, otherFrameId) {
- await yomitan.api.openCrossFramePort(otherTabId, otherFrameId);
+ await this._api.openCrossFramePort(otherTabId, otherFrameId);
const tabPorts = this._commPorts.get(otherTabId);
if (typeof tabPorts !== 'undefined') {