From fe875bbd99980b175fc366a2bfd4395be9cbad72 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 20 Feb 2024 10:13:57 -0500 Subject: Constructor simplification (#713) * Update AudioDownloader * Update Translator * Update ClipboardMonitor * Update ClipboardReader * Update PanelElement * Update QueryParser * Update DisplayGenerator * Update DisplayHistory * Update DOMDataBinder * Remove unnecessary cast * Update Popup types * One declaration per line * Remove optionals from Frontend constructor * Fix Translator constructor --- ext/js/background/backend.js | 22 ++++++++-------------- ext/js/background/offscreen.js | 14 ++++++-------- 2 files changed, 14 insertions(+), 22 deletions(-) (limited to 'ext/js/background') diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index 8b0853d2..03c0b5fe 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -68,16 +68,14 @@ export class Backend { /** @type {DictionaryDatabase|DictionaryDatabaseProxy} */ this._dictionaryDatabase = new DictionaryDatabase(); /** @type {Translator|TranslatorProxy} */ - this._translator = new Translator({ - database: this._dictionaryDatabase - }); + this._translator = new Translator(this._dictionaryDatabase); /** @type {ClipboardReader|ClipboardReaderProxy} */ - this._clipboardReader = new ClipboardReader({ + this._clipboardReader = new ClipboardReader( // eslint-disable-next-line no-undef - document: (typeof document === 'object' && document !== null ? document : null), - pasteTargetSelector: '#clipboard-paste-target', - richContentPasteTargetSelector: '#clipboard-rich-content-paste-target' - }); + (typeof document === 'object' && document !== null ? document : null), + '#clipboard-paste-target', + '#clipboard-rich-content-paste-target' + ); } else { /** @type {?OffscreenProxy} */ this._offscreen = new OffscreenProxy(webExtension); @@ -90,9 +88,7 @@ export class Backend { } /** @type {ClipboardMonitor} */ - this._clipboardMonitor = new ClipboardMonitor({ - clipboardReader: this._clipboardReader - }); + this._clipboardMonitor = new ClipboardMonitor(this._clipboardReader); /** @type {?import('settings').Options} */ this._options = null; /** @type {import('../data/json-schema.js').JsonSchema[]} */ @@ -102,9 +98,7 @@ export class Backend { /** @type {RequestBuilder} */ this._requestBuilder = new RequestBuilder(); /** @type {AudioDownloader} */ - this._audioDownloader = new AudioDownloader({ - requestBuilder: this._requestBuilder - }); + this._audioDownloader = new AudioDownloader(this._requestBuilder); /** @type {OptionsUtil} */ this._optionsUtil = new OptionsUtil(); /** @type {AccessibilityController} */ diff --git a/ext/js/background/offscreen.js b/ext/js/background/offscreen.js index dbdb9773..3b8b6a3e 100644 --- a/ext/js/background/offscreen.js +++ b/ext/js/background/offscreen.js @@ -34,15 +34,13 @@ export class Offscreen { /** @type {DictionaryDatabase} */ this._dictionaryDatabase = new DictionaryDatabase(); /** @type {Translator} */ - this._translator = new Translator({ - database: this._dictionaryDatabase - }); + this._translator = new Translator(this._dictionaryDatabase); /** @type {ClipboardReader} */ - this._clipboardReader = new ClipboardReader({ - document: (typeof document === 'object' && document !== null ? document : null), - pasteTargetSelector: '#clipboard-paste-target', - richContentPasteTargetSelector: '#clipboard-rich-content-paste-target' - }); + this._clipboardReader = new ClipboardReader( + (typeof document === 'object' && document !== null ? document : null), + '#clipboard-paste-target', + '#clipboard-rich-content-paste-target' + ); /* eslint-disable @stylistic/no-multi-spaces */ -- cgit v1.2.3