aboutsummaryrefslogtreecommitdiff
path: root/ext/js/comm
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/comm')
-rw-r--r--ext/js/comm/api.js2
-rw-r--r--ext/js/comm/clipboard-monitor.js2
-rw-r--r--ext/js/comm/cross-frame-api.js21
-rw-r--r--ext/js/comm/frame-ancestry-handler.js2
-rw-r--r--ext/js/comm/frame-client.js2
-rw-r--r--ext/js/comm/mecab.js2
6 files changed, 18 insertions, 13 deletions
diff --git a/ext/js/comm/api.js b/ext/js/comm/api.js
index 0cfdba59..26218595 100644
--- a/ext/js/comm/api.js
+++ b/ext/js/comm/api.js
@@ -431,7 +431,7 @@ export class API {
*/
_createActionPort(timeout) {
return new Promise((resolve, reject) => {
- /** @type {?number} */
+ /** @type {?import('core').Timeout} */
let timer = null;
const portDetails = deferPromise();
diff --git a/ext/js/comm/clipboard-monitor.js b/ext/js/comm/clipboard-monitor.js
index 06e95438..3b3a56a9 100644
--- a/ext/js/comm/clipboard-monitor.js
+++ b/ext/js/comm/clipboard-monitor.js
@@ -31,7 +31,7 @@ export class ClipboardMonitor extends EventDispatcher {
this._japaneseUtil = japaneseUtil;
/** @type {import('clipboard-monitor').ClipboardReaderLike} */
this._clipboardReader = clipboardReader;
- /** @type {?number} */
+ /** @type {?import('core').Timeout} */
this._timerId = null;
/** @type {?import('core').TokenObject} */
this._timerToken = null;
diff --git a/ext/js/comm/cross-frame-api.js b/ext/js/comm/cross-frame-api.js
index 34f3f36a..3ac38cf2 100644
--- a/ext/js/comm/cross-frame-api.js
+++ b/ext/js/comm/cross-frame-api.js
@@ -25,14 +25,14 @@ import {yomitan} from '../yomitan.js';
*/
class CrossFrameAPIPort extends EventDispatcher {
/**
- * @param {?number} otherTabId
+ * @param {number} otherTabId
* @param {number} otherFrameId
* @param {chrome.runtime.Port} port
* @param {import('core').MessageHandlerMap} messageHandlers
*/
constructor(otherTabId, otherFrameId, port, messageHandlers) {
super();
- /** @type {?number} */
+ /** @type {number} */
this._otherTabId = otherTabId;
/** @type {number} */
this._otherFrameId = otherFrameId;
@@ -48,7 +48,7 @@ class CrossFrameAPIPort extends EventDispatcher {
this._eventListeners = new EventListenerCollection();
}
- /** @type {?number} */
+ /** @type {number} */
get otherTabId() {
return this._otherTabId;
}
@@ -299,7 +299,7 @@ export class CrossFrameAPI {
this._ackTimeout = 3000; // 3 seconds
/** @type {number} */
this._responseTimeout = 10000; // 10 seconds
- /** @type {Map<?number, Map<number, CrossFrameAPIPort>>} */
+ /** @type {Map<number, Map<number, CrossFrameAPIPort>>} */
this._commPorts = new Map();
/** @type {import('core').MessageHandlerMap} */
this._messageHandlers = new Map();
@@ -339,7 +339,12 @@ export class CrossFrameAPI {
* @returns {Promise<TReturn>}
*/
async invokeTab(targetTabId, targetFrameId, action, params) {
- if (typeof targetTabId !== 'number') { targetTabId = this._tabId; }
+ if (typeof targetTabId !== 'number') {
+ targetTabId = this._tabId;
+ if (typeof targetTabId !== 'number') {
+ throw new Error('Unknown target tab id for invocation');
+ }
+ }
const commPort = await this._getOrCreateCommPort(targetTabId, targetFrameId);
return await commPort.invoke(action, params, this._ackTimeout, this._responseTimeout);
}
@@ -405,7 +410,7 @@ export class CrossFrameAPI {
}
/**
- * @param {?number} otherTabId
+ * @param {number} otherTabId
* @param {number} otherFrameId
* @returns {Promise<CrossFrameAPIPort>}
*/
@@ -420,7 +425,7 @@ export class CrossFrameAPI {
return await this._createCommPort(otherTabId, otherFrameId);
}
/**
- * @param {?number} otherTabId
+ * @param {number} otherTabId
* @param {number} otherFrameId
* @returns {Promise<CrossFrameAPIPort>}
*/
@@ -438,7 +443,7 @@ export class CrossFrameAPI {
}
/**
- * @param {?number} otherTabId
+ * @param {number} otherTabId
* @param {number} otherFrameId
* @param {chrome.runtime.Port} port
* @returns {CrossFrameAPIPort}
diff --git a/ext/js/comm/frame-ancestry-handler.js b/ext/js/comm/frame-ancestry-handler.js
index 49c96c22..687ec368 100644
--- a/ext/js/comm/frame-ancestry-handler.js
+++ b/ext/js/comm/frame-ancestry-handler.js
@@ -122,7 +122,7 @@ export class FrameAncestryHandler {
const responseMessageId = `${this._responseMessageIdBase}${uniqueId}`;
/** @type {number[]} */
const results = [];
- /** @type {?number} */
+ /** @type {?import('core').Timeout} */
let timer = null;
const cleanup = () => {
diff --git a/ext/js/comm/frame-client.js b/ext/js/comm/frame-client.js
index 1519cf7f..8aa8c6d6 100644
--- a/ext/js/comm/frame-client.js
+++ b/ext/js/comm/frame-client.js
@@ -83,7 +83,7 @@ export class FrameClient {
_connectInternal(frame, targetOrigin, hostFrameId, setupFrame, timeout) {
return new Promise((resolve, reject) => {
const tokenMap = new Map();
- /** @type {?number} */
+ /** @type {?import('core').Timeout} */
let timer = null;
const deferPromiseDetails = /** @type {import('core').DeferredPromiseDetails<void>} */ (deferPromise());
const frameLoadedPromise = deferPromiseDetails.promise;
diff --git a/ext/js/comm/mecab.js b/ext/js/comm/mecab.js
index 072b42f3..0a87463b 100644
--- a/ext/js/comm/mecab.js
+++ b/ext/js/comm/mecab.js
@@ -31,7 +31,7 @@ export class Mecab {
this._port = null;
/** @type {number} */
this._sequence = 0;
- /** @type {Map<number, {resolve: (value: unknown) => void, reject: (reason?: unknown) => void, timer: number}>} */
+ /** @type {Map<number, {resolve: (value: unknown) => void, reject: (reason?: unknown) => void, timer: import('core').Timeout}>} */
this._invocations = new Map();
/** @type {EventListenerCollection} */
this._eventListeners = new EventListenerCollection();