From 4da4827bcbcdd1ef163f635d9b29416ff272b0bb Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 27 Nov 2023 12:48:14 -0500 Subject: Add JSDoc type annotations to project (rebased) --- .../schemas/dictionary-term-bank-v3-schema.json | 4 + ext/data/schemas/options-schema.json | 3 + ext/js/accessibility/accessibility-controller.js | 14 +- ext/js/accessibility/google-docs-util.js | 46 +- ext/js/accessibility/google-docs.js | 14 +- ext/js/app/content-script-main.js | 2 + ext/js/app/frontend.js | 308 ++++- ext/js/app/popup-factory.js | 182 ++- ext/js/app/popup-proxy.js | 102 +- ext/js/app/popup-window.js | 67 +- ext/js/app/popup.js | 333 +++-- ext/js/app/theme-controller.js | 28 +- ext/js/background/backend.js | 1001 +++++++++++--- ext/js/background/profile-conditions-util.js | 155 ++- ext/js/background/request-builder.js | 50 + ext/js/background/script-manager.js | 186 ++- ext/js/comm/anki-connect.js | 310 ++++- ext/js/comm/api.js | 356 ++++- ext/js/comm/clipboard-monitor.js | 24 +- ext/js/comm/clipboard-reader.js | 54 +- ext/js/comm/cross-frame-api.js | 156 ++- ext/js/comm/frame-ancestry-handler.js | 87 +- ext/js/comm/frame-client.js | 68 +- ext/js/comm/frame-endpoint.js | 49 +- ext/js/comm/frame-offset-forwarder.js | 16 + ext/js/comm/mecab.js | 84 +- ext/js/core.js | 343 ++--- ext/js/core/extension-error.js | 85 ++ ext/js/data/anki-note-builder.js | 143 +- ext/js/data/anki-util.js | 2 +- ext/js/data/database.js | 206 ++- ext/js/data/json-schema.js | 927 +++++++++---- ext/js/data/options-util.js | 185 ++- ext/js/data/permissions-util.js | 22 + ext/js/data/sandbox/anki-note-data-creator.js | 243 +++- ext/js/debug/timer.js | 31 +- ext/js/display/display-anki.js | 328 ++++- ext/js/display/display-audio.js | 320 ++++- ext/js/display/display-content-manager.js | 101 +- ext/js/display/display-generator.js | 429 ++++-- ext/js/display/display-history.js | 73 +- ext/js/display/display-notification.js | 32 +- ext/js/display/display-profile-selection.js | 50 +- ext/js/display/display-resizer.js | 58 +- ext/js/display/display.js | 678 +++++++--- ext/js/display/element-overflow-controller.js | 39 +- ext/js/display/option-toggle-hotkey-handler.js | 62 +- ext/js/display/query-parser.js | 127 +- ext/js/display/sandbox/pronunciation-generator.js | 56 +- .../sandbox/structured-content-generator.js | 101 +- ext/js/display/search-action-popup-controller.js | 5 + ext/js/display/search-display-controller.js | 171 ++- ext/js/display/search-main.js | 4 +- .../display/search-persistent-state-controller.js | 27 +- ext/js/dom/document-focus-controller.js | 22 +- ext/js/dom/document-util.js | 290 +++-- ext/js/dom/dom-data-binder.js | 144 +- ext/js/dom/dom-text-scanner.js | 55 +- ext/js/dom/html-template-collection.js | 39 +- ext/js/dom/native-simple-dom-parser.js | 74 +- ext/js/dom/panel-element.js | 34 + ext/js/dom/popup-menu.js | 71 +- ext/js/dom/sandbox/css-style-applier.js | 43 +- ext/js/dom/scroll-element.js | 50 + ext/js/dom/selector-observer.js | 113 +- ext/js/dom/simple-dom-parser.js | 122 +- ext/js/dom/text-source-element.js | 41 +- ext/js/dom/text-source-range.js | 33 +- ext/js/extension/environment.js | 24 + ext/js/general/cache-map.js | 45 +- ext/js/general/object-property-accessor.js | 29 +- ext/js/general/regex-util.js | 8 +- ext/js/general/task-accumulator.js | 46 +- ext/js/general/text-source-map.js | 34 + ext/js/input/hotkey-handler.js | 102 +- ext/js/input/hotkey-help-controller.js | 92 +- ext/js/input/hotkey-util.js | 64 +- ext/js/language/deinflector.js | 39 +- ext/js/language/dictionary-database.js | 255 +++- .../language/dictionary-importer-media-loader.js | 10 +- ext/js/language/dictionary-importer.js | 338 ++++- ext/js/language/dictionary-worker-handler.js | 38 +- ext/js/language/dictionary-worker-media-loader.js | 16 +- ext/js/language/dictionary-worker.js | 110 +- ext/js/language/sandbox/dictionary-data-util.js | 161 ++- ext/js/language/sandbox/japanese-util.js | 1371 +++++++++++--------- ext/js/language/text-scanner.js | 534 +++++++- ext/js/language/translator.js | 788 ++++++++--- ext/js/media/audio-downloader.js | 125 +- ext/js/media/audio-system.js | 41 +- ext/js/media/media-util.js | 2 +- ext/js/media/text-to-speech-audio.js | 16 + ext/js/pages/action-popup-main.js | 103 +- .../pages/common/extension-content-controller.js | 32 +- ext/js/pages/info-main.js | 34 +- ext/js/pages/permissions-main.js | 41 +- ext/js/pages/settings/anki-controller.js | 426 ++++-- ext/js/pages/settings/anki-templates-controller.js | 161 ++- ext/js/pages/settings/audio-controller.js | 181 ++- ext/js/pages/settings/backup-controller.js | 180 ++- .../settings/collapsible-dictionary-controller.js | 86 +- ext/js/pages/settings/dictionary-controller.js | 327 ++++- .../pages/settings/dictionary-import-controller.js | 150 ++- .../extension-keyboard-shortcuts-controller.js | 135 +- .../pages/settings/generic-setting-controller.js | 180 ++- .../pages/settings/keyboard-mouse-input-field.js | 92 +- .../settings/keyboard-shortcuts-controller.js | 268 +++- ext/js/pages/settings/mecab-controller.js | 37 +- ext/js/pages/settings/modal-controller.js | 12 +- ext/js/pages/settings/modal.js | 28 +- ext/js/pages/settings/nested-popups-controller.js | 47 +- .../settings/permissions-origin-controller.js | 73 +- .../settings/permissions-toggle-controller.js | 45 +- .../settings/persistent-storage-controller.js | 29 +- ext/js/pages/settings/popup-preview-controller.js | 32 +- ext/js/pages/settings/popup-preview-frame-main.js | 6 + ext/js/pages/settings/popup-preview-frame.js | 102 +- ext/js/pages/settings/popup-window-controller.js | 7 +- ext/js/pages/settings/profile-conditions-ui.js | 395 +++++- ext/js/pages/settings/profile-controller.js | 287 +++- ext/js/pages/settings/scan-inputs-controller.js | 175 ++- .../settings/scan-inputs-simple-controller.js | 90 +- .../secondary-search-dictionary-controller.js | 40 +- .../sentence-termination-characters-controller.js | 127 +- ext/js/pages/settings/settings-controller.js | 172 ++- .../pages/settings/settings-display-controller.js | 152 ++- ext/js/pages/settings/settings-main.js | 8 +- .../sort-frequency-dictionary-controller.js | 93 +- ext/js/pages/settings/status-footer.js | 34 +- ext/js/pages/settings/storage-controller.js | 67 +- .../translation-text-replacements-controller.js | 107 +- ext/js/pages/welcome-main.js | 6 +- ext/js/script/dynamic-loader-sentinel.js | 3 +- ext/js/script/dynamic-loader.js | 43 +- .../anki-template-renderer-content-manager.js | 23 +- ext/js/templates/sandbox/anki-template-renderer.js | 347 +++-- .../sandbox/template-renderer-frame-api.js | 86 +- .../sandbox/template-renderer-media-provider.js | 67 +- ext/js/templates/sandbox/template-renderer.js | 100 +- ext/js/templates/template-patcher.js | 18 + ext/js/templates/template-renderer-proxy.js | 84 +- ext/js/yomitan.js | 76 +- 142 files changed, 15187 insertions(+), 4193 deletions(-) create mode 100644 ext/js/core/extension-error.js (limited to 'ext') diff --git a/ext/data/schemas/dictionary-term-bank-v3-schema.json b/ext/data/schemas/dictionary-term-bank-v3-schema.json index 7d0b4868..1df99135 100644 --- a/ext/data/schemas/dictionary-term-bank-v3-schema.json +++ b/ext/data/schemas/dictionary-term-bank-v3-schema.json @@ -155,6 +155,10 @@ "type": "string", "description": "Hover text for the image." }, + "description": { + "type": "string", + "description": "Description of the image." + }, "pixelated": { "type": "boolean", "description": "Whether or not the image should appear pixelated at sizes larger than the image's native resolution.", diff --git a/ext/data/schemas/options-schema.json b/ext/data/schemas/options-schema.json index 8ccbfa94..7c131ecc 100644 --- a/ext/data/schemas/options-schema.json +++ b/ext/data/schemas/options-schema.json @@ -541,9 +541,12 @@ "searchKanji", "scanOnTouchMove", "scanOnTouchPress", + "scanOnTouchRelease", "scanOnPenMove", "scanOnPenHover", "scanOnPenReleaseHover", + "scanOnPenPress", + "scanOnPenRelease", "preventTouchScrolling", "preventPenScrolling" ], diff --git a/ext/js/accessibility/accessibility-controller.js b/ext/js/accessibility/accessibility-controller.js index e9a24880..a4239947 100644 --- a/ext/js/accessibility/accessibility-controller.js +++ b/ext/js/accessibility/accessibility-controller.js @@ -28,15 +28,19 @@ export class AccessibilityController { * @param {ScriptManager} scriptManager An instance of the `ScriptManager` class. */ constructor(scriptManager) { + /** @type {ScriptManager} */ this._scriptManager = scriptManager; + /** @type {?import('core').TokenObject} */ this._updateGoogleDocsAccessibilityToken = null; + /** @type {?Promise} */ this._updateGoogleDocsAccessibilityPromise = null; + /** @type {boolean} */ this._forceGoogleDocsHtmlRenderingAny = false; } /** * Updates the accessibility handlers. - * @param {object} fullOptions The full options object from the `Backend` instance. + * @param {import('settings').Options} fullOptions The full options object from the `Backend` instance. * The value is treated as read-only and is not modified. */ async update(fullOptions) { @@ -53,8 +57,12 @@ export class AccessibilityController { // Private + /** + * @param {boolean} forceGoogleDocsHtmlRenderingAny + */ async _updateGoogleDocsAccessibility(forceGoogleDocsHtmlRenderingAny) { // Reentrant token + /** @type {?import('core').TokenObject} */ const token = {}; this._updateGoogleDocsAccessibilityToken = token; @@ -72,6 +80,9 @@ export class AccessibilityController { this._updateGoogleDocsAccessibilityPromise = null; } + /** + * @param {boolean} forceGoogleDocsHtmlRenderingAny + */ async _updateGoogleDocsAccessibilityInner(forceGoogleDocsHtmlRenderingAny) { if (this._forceGoogleDocsHtmlRenderingAny === forceGoogleDocsHtmlRenderingAny) { return; } @@ -81,6 +92,7 @@ export class AccessibilityController { try { if (forceGoogleDocsHtmlRenderingAny) { if (await this._scriptManager.isContentScriptRegistered(id)) { return; } + /** @type {import('script-manager').RegistrationDetails} */ const details = { allFrames: true, matchAboutBlank: true, diff --git a/ext/js/accessibility/google-docs-util.js b/ext/js/accessibility/google-docs-util.js index e170f334..9db45cc1 100644 --- a/ext/js/accessibility/google-docs-util.js +++ b/ext/js/accessibility/google-docs-util.js @@ -29,8 +29,8 @@ export class GoogleDocsUtil { * Coordinates are provided in [client space](https://developer.mozilla.org/en-US/docs/Web/CSS/CSSOM_View/Coordinate_systems). * @param {number} x The x coordinate to search at. * @param {number} y The y coordinate to search at. - * @param {GetRangeFromPointOptions} options Options to configure how element detection is performed. - * @returns {?TextSourceRange|TextSourceElement} A range for the hovered text or element, or `null` if no applicable content was found. + * @param {import('document-util').GetRangeFromPointOptions} options Options to configure how element detection is performed. + * @returns {?TextSourceRange} A range for the hovered text or element, or `null` if no applicable content was found. */ static getRangeFromPoint(x, y, {normalizeCssZoom}) { const styleNode = this._getStyleNode(); @@ -46,10 +46,13 @@ export class GoogleDocsUtil { return null; } + /** + * @returns {HTMLStyleElement} + */ static _getStyleNode() { // This