aboutsummaryrefslogtreecommitdiff
path: root/ext/js/background/offscreen.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-12-27 01:40:25 -0500
committerGitHub <noreply@github.com>2023-12-27 06:40:25 +0000
commit0094ff7babab6839ccef4c82fa46b8aa4f14198f (patch)
tree3beeb558b41a04948ff82cc1c34f5e44df65825e /ext/js/background/offscreen.js
parent7cc20964b5ae69967945a802c4137be9052ea93b (diff)
API map updates (#458)
* Rename * Fix incorrect union types * Update type names * Fix types
Diffstat (limited to 'ext/js/background/offscreen.js')
-rw-r--r--ext/js/background/offscreen.js28
1 files changed, 14 insertions, 14 deletions
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);
}