summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/js/background/backend.js4
-rw-r--r--ext/js/background/offscreen-proxy.js6
-rw-r--r--ext/js/background/offscreen.js28
-rw-r--r--ext/js/comm/api.js2
4 files changed, 20 insertions, 20 deletions
diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js
index 765d17d9..5ef3c3be 100644
--- a/ext/js/background/backend.js
+++ b/ext/js/background/backend.js
@@ -370,7 +370,7 @@ export class Backend {
});
}
- /** @type {import('extension').ChromeRuntimeOnMessageCallback<import('api').MessageAny>} */
+ /** @type {import('extension').ChromeRuntimeOnMessageCallback<import('api').ApiMessageAny>} */
_onMessageWrapper(message, sender, sendResponse) {
if (this._isPrepared) {
return this._onMessage(message, sender, sendResponse);
@@ -393,7 +393,7 @@ export class Backend {
}
/**
- * @param {import('api').MessageAny} message
+ * @param {import('api').ApiMessageAny} message
* @param {chrome.runtime.MessageSender} sender
* @param {(response?: unknown) => void} callback
* @returns {boolean}
diff --git a/ext/js/background/offscreen-proxy.js b/ext/js/background/offscreen-proxy.js
index 99dc0741..2335b673 100644
--- a/ext/js/background/offscreen-proxy.js
+++ b/ext/js/background/offscreen-proxy.js
@@ -72,9 +72,9 @@ export class OffscreenProxy {
}
/**
- * @template {import('offscreen').MessageType} TMessageType
- * @param {import('offscreen').Message<TMessageType>} message
- * @returns {Promise<import('offscreen').OffscreenApiReturn<TMessageType>>}
+ * @template {import('offscreen').ApiNames} TMessageType
+ * @param {import('offscreen').ApiMessage<TMessageType>} message
+ * @returns {Promise<import('offscreen').ApiReturn<TMessageType>>}
*/
sendMessagePromise(message) {
return new Promise((resolve, reject) => {
diff --git a/ext/js/background/offscreen.js b/ext/js/background/offscreen.js
index 05c655df..2320471c 100644
--- a/ext/js/background/offscreen.js
+++ b/ext/js/background/offscreen.js
@@ -52,7 +52,7 @@ export class Offscreen {
/* eslint-disable no-multi-spaces */
- /** @type {import('offscreen').OffscreenApiMap} */
+ /** @type {import('offscreen').ApiMap} */
this._apiMap = createApiMap([
['clipboardGetTextOffscreen', this._getTextHandler.bind(this)],
['clipboardGetImageOffscreen', this._getImageHandler.bind(this)],
@@ -78,22 +78,22 @@ export class Offscreen {
chrome.runtime.onMessage.addListener(this._onMessage.bind(this));
}
- /** @type {import('offscreen').OffscreenApiHandler<'clipboardGetTextOffscreen'>} */
+ /** @type {import('offscreen').ApiHandler<'clipboardGetTextOffscreen'>} */
async _getTextHandler({useRichText}) {
return await this._clipboardReader.getText(useRichText);
}
- /** @type {import('offscreen').OffscreenApiHandler<'clipboardGetImageOffscreen'>} */
+ /** @type {import('offscreen').ApiHandler<'clipboardGetImageOffscreen'>} */
async _getImageHandler() {
return await this._clipboardReader.getImage();
}
- /** @type {import('offscreen').OffscreenApiHandler<'clipboardSetBrowserOffscreen'>} */
+ /** @type {import('offscreen').ApiHandler<'clipboardSetBrowserOffscreen'>} */
_setClipboardBrowser({value}) {
this._clipboardReader.browser = value;
}
- /** @type {import('offscreen').OffscreenApiHandler<'databasePrepareOffscreen'>} */
+ /** @type {import('offscreen').ApiHandler<'databasePrepareOffscreen'>} */
_prepareDatabaseHandler() {
if (this._prepareDatabasePromise !== null) {
return this._prepareDatabasePromise;
@@ -102,29 +102,29 @@ export class Offscreen {
return this._prepareDatabasePromise;
}
- /** @type {import('offscreen').OffscreenApiHandler<'getDictionaryInfoOffscreen'>} */
+ /** @type {import('offscreen').ApiHandler<'getDictionaryInfoOffscreen'>} */
async _getDictionaryInfoHandler() {
return await this._dictionaryDatabase.getDictionaryInfo();
}
- /** @type {import('offscreen').OffscreenApiHandler<'databasePurgeOffscreen'>} */
+ /** @type {import('offscreen').ApiHandler<'databasePurgeOffscreen'>} */
async _purgeDatabaseHandler() {
return await this._dictionaryDatabase.purge();
}
- /** @type {import('offscreen').OffscreenApiHandler<'databaseGetMediaOffscreen'>} */
+ /** @type {import('offscreen').ApiHandler<'databaseGetMediaOffscreen'>} */
async _getMediaHandler({targets}) {
const media = await this._dictionaryDatabase.getMedia(targets);
const serializedMedia = media.map((m) => ({...m, content: ArrayBufferUtil.arrayBufferToBase64(m.content)}));
return serializedMedia;
}
- /** @type {import('offscreen').OffscreenApiHandler<'translatorPrepareOffscreen'>} */
+ /** @type {import('offscreen').ApiHandler<'translatorPrepareOffscreen'>} */
_prepareTranslatorHandler({deinflectionReasons}) {
this._translator.prepare(deinflectionReasons);
}
- /** @type {import('offscreen').OffscreenApiHandler<'findKanjiOffscreen'>} */
+ /** @type {import('offscreen').ApiHandler<'findKanjiOffscreen'>} */
async _findKanjiHandler({text, options}) {
/** @type {import('translation').FindKanjiOptions} */
const modifiedOptions = {
@@ -134,7 +134,7 @@ export class Offscreen {
return await this._translator.findKanji(text, modifiedOptions);
}
- /** @type {import('offscreen').OffscreenApiHandler<'findTermsOffscreen'>} */
+ /** @type {import('offscreen').ApiHandler<'findTermsOffscreen'>} */
async _findTermsHandler({mode, text, options}) {
const enabledDictionaryMap = new Map(options.enabledDictionaryMap);
const excludeDictionaryDefinitions = (
@@ -161,17 +161,17 @@ export class Offscreen {
return this._translator.findTerms(mode, text, modifiedOptions);
}
- /** @type {import('offscreen').OffscreenApiHandler<'getTermFrequenciesOffscreen'>} */
+ /** @type {import('offscreen').ApiHandler<'getTermFrequenciesOffscreen'>} */
_getTermFrequenciesHandler({termReadingList, dictionaries}) {
return this._translator.getTermFrequencies(termReadingList, dictionaries);
}
- /** @type {import('offscreen').OffscreenApiHandler<'clearDatabaseCachesOffscreen'>} */
+ /** @type {import('offscreen').ApiHandler<'clearDatabaseCachesOffscreen'>} */
_clearDatabaseCachesHandler() {
this._translator.clearDatabaseCaches();
}
- /** @type {import('extension').ChromeRuntimeOnMessageCallback<import('offscreen').MessageAny>} */
+ /** @type {import('extension').ChromeRuntimeOnMessageCallback<import('offscreen').ApiMessageAny>} */
_onMessage({action, params}, _sender, callback) {
return invokeApiMapHandler(this._apiMap, action, params, [], callback);
}
diff --git a/ext/js/comm/api.js b/ext/js/comm/api.js
index c0cfae16..c2351538 100644
--- a/ext/js/comm/api.js
+++ b/ext/js/comm/api.js
@@ -373,7 +373,7 @@ export class API {
* @returns {Promise<import('api').ApiReturn<TAction>>}
*/
_invoke(action, params) {
- /** @type {import('api').MessageAny} */
+ /** @type {import('api').ApiMessage<TAction>} */
const data = {action, params};
return new Promise((resolve, reject) => {
try {