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) --- types/other/web-set-timeout.d.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 types/other/web-set-timeout.d.ts (limited to 'types/other') diff --git a/types/other/web-set-timeout.d.ts b/types/other/web-set-timeout.d.ts new file mode 100644 index 00000000..98e40dab --- /dev/null +++ b/types/other/web-set-timeout.d.ts @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2023 Yomitan Authors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +declare module 'web-set-timeout' { + global { + // These types are used to ensure that setTimeout returns a number + function setTimeout(callback: (...args: TArgs) => void, ms?: number, ...args: TArgs): number; + function setTimeout(callback: (args: void) => void, ms?: number): number; + } +} -- cgit v1.2.3 From 14d12f6ba20b837a04c638b935773f3120e194ff Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 27 Nov 2023 19:33:01 -0500 Subject: Update timer types and such --- dev/jsconfig.json | 2 +- ext/js/app/frontend.js | 11 +++++++++-- ext/js/background/backend.js | 4 ++-- ext/js/background/offscreen.js | 4 +++- ext/js/comm/api.js | 2 +- ext/js/comm/clipboard-monitor.js | 2 +- ext/js/comm/cross-frame-api.js | 21 +++++++++++++-------- ext/js/comm/frame-ancestry-handler.js | 2 +- ext/js/comm/frame-client.js | 2 +- ext/js/comm/mecab.js | 2 +- ext/js/core.js | 2 +- ext/js/display/display-audio.js | 2 +- ext/js/display/display-notification.js | 2 +- ext/js/display/display.js | 2 +- ext/js/display/element-overflow-controller.js | 8 ++++---- ext/js/display/option-toggle-hotkey-handler.js | 2 +- ext/js/display/search-display-controller.js | 2 +- ext/js/dom/document-util.js | 2 +- ext/js/dom/panel-element.js | 2 +- ext/js/language/text-scanner.js | 6 +++--- ext/js/media/audio-downloader.js | 2 +- ext/js/pages/settings/popup-preview-frame.js | 2 +- test/jsconfig.json | 2 +- types/ext/core.d.ts | 2 ++ types/ext/cross-frame-api.d.ts | 2 +- types/ext/offscreen.d.ts | 2 +- types/other/globals.d.ts | 22 ++++++++++++++++++++++ types/other/web-set-timeout.d.ts | 24 ------------------------ 28 files changed, 77 insertions(+), 63 deletions(-) create mode 100644 types/other/globals.d.ts delete mode 100644 types/other/web-set-timeout.d.ts (limited to 'types/other') diff --git a/dev/jsconfig.json b/dev/jsconfig.json index 518f97ad..d4efe694 100644 --- a/dev/jsconfig.json +++ b/dev/jsconfig.json @@ -71,7 +71,7 @@ "../ext/js/language/translator.js", "../ext/js/media/media-util.js", "../types/dev/**/*.ts", - "../types/other/web-set-timeout.d.ts" + "../types/other/globals.d.ts" ], "exclude": [ "../node_modules" diff --git a/ext/js/app/frontend.js b/ext/js/app/frontend.js index 628c504e..e1f8d8c9 100644 --- a/ext/js/app/frontend.js +++ b/ext/js/app/frontend.js @@ -99,7 +99,7 @@ export class Frontend { this._popupEventListeners = new EventListenerCollection(); /** @type {?import('core').TokenObject} */ this._updatePopupToken = null; - /** @type {?number} */ + /** @type {?import('core').Timeout} */ this._clearSelectionTimer = null; /** @type {boolean} */ this._isPointerOverPopup = false; @@ -840,7 +840,7 @@ export class Frontend { */ async _waitForFrontendReady(frameId, timeout) { return new Promise((resolve, reject) => { - /** @type {?number} */ + /** @type {?import('core').Timeout} */ let timeoutId = null; const cleanup = () => { @@ -973,6 +973,13 @@ export class Frontend { await yomitan.api.loadExtensionScripts([ '/js/accessibility/google-docs-util.js' ]); + this._prepareGoogleDocs2(); + } + + /** + * @returns {Promise} + */ + async _prepareGoogleDocs2() { if (typeof GoogleDocsUtil === 'undefined') { return; } DocumentUtil.registerGetRangeFromPointHandler(GoogleDocsUtil.getRangeFromPoint.bind(GoogleDocsUtil)); } diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index 44f5a42d..f1a47e7f 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -138,7 +138,7 @@ export class Backend { /** @type {?string} */ this._defaultBrowserActionTitle = null; - /** @type {?number} */ + /** @type {?import('core').Timeout} */ this._badgePrepareDelayTimer = null; /** @type {?import('log').LogLevel} */ this._logErrorLevel = null; @@ -1981,7 +1981,7 @@ export class Backend { */ _waitUntilTabFrameIsReady(tabId, frameId, timeout=null) { return new Promise((resolve, reject) => { - /** @type {?number} */ + /** @type {?import('core').Timeout} */ let timer = null; /** @type {?import('extension').ChromeRuntimeOnMessageCallback} */ let onMessage = (message, sender) => { diff --git a/ext/js/background/offscreen.js b/ext/js/background/offscreen.js index 45345c01..8da661ad 100644 --- a/ext/js/background/offscreen.js +++ b/ext/js/background/offscreen.js @@ -51,7 +51,7 @@ export class Offscreen { }); /** @type {import('offscreen').MessageHandlerMap} */ - this._messageHandlers = new Map([ + const messageHandlers = new Map([ ['clipboardGetTextOffscreen', {async: true, handler: this._getTextHandler.bind(this)}], ['clipboardGetImageOffscreen', {async: true, handler: this._getImageHandler.bind(this)}], ['clipboardSetBrowserOffscreen', {async: false, handler: this._setClipboardBrowser.bind(this)}], @@ -65,6 +65,8 @@ export class Offscreen { ['getTermFrequenciesOffscreen', {async: true, handler: this._getTermFrequenciesHandler.bind(this)}], ['clearDatabaseCachesOffscreen', {async: false, handler: this._clearDatabaseCachesHandler.bind(this)}] ]); + /** @type {import('offscreen').MessageHandlerMap} */ + this._messageHandlers = messageHandlers; const onMessage = this._onMessage.bind(this); chrome.runtime.onMessage.addListener(onMessage); 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>} */ + /** @type {Map>} */ this._commPorts = new Map(); /** @type {import('core').MessageHandlerMap} */ this._messageHandlers = new Map(); @@ -339,7 +339,12 @@ export class CrossFrameAPI { * @returns {Promise} */ 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} */ @@ -420,7 +425,7 @@ export class CrossFrameAPI { return await this._createCommPort(otherTabId, otherFrameId); } /** - * @param {?number} otherTabId + * @param {number} otherTabId * @param {number} otherFrameId * @returns {Promise} */ @@ -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} */ (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 void, reject: (reason?: unknown) => void, timer: number}>} */ + /** @type {Map void, reject: (reason?: unknown) => void, timer: import('core').Timeout}>} */ this._invocations = new Map(); /** @type {EventListenerCollection} */ this._eventListeners = new EventListenerCollection(); diff --git a/ext/js/core.js b/ext/js/core.js index cdac2020..a53d5572 100644 --- a/ext/js/core.js +++ b/ext/js/core.js @@ -307,7 +307,7 @@ export function promiseAnimationFrame(timeout) { return; } - /** @type {?number} */ + /** @type {?import('core').Timeout} */ let timer = null; /** @type {?number} */ let frameRequest = null; diff --git a/ext/js/display/display-audio.js b/ext/js/display/display-audio.js index 3fbfc3c8..3576decb 100644 --- a/ext/js/display/display-audio.js +++ b/ext/js/display/display-audio.js @@ -36,7 +36,7 @@ export class DisplayAudio { this._playbackVolume = 1.0; /** @type {boolean} */ this._autoPlay = false; - /** @type {?number} */ + /** @type {?import('core').Timeout} */ this._autoPlayAudioTimer = null; /** @type {number} */ this._autoPlayAudioDelay = 400; diff --git a/ext/js/display/display-notification.js b/ext/js/display/display-notification.js index b3f20700..d1cfa537 100644 --- a/ext/js/display/display-notification.js +++ b/ext/js/display/display-notification.js @@ -34,7 +34,7 @@ export class DisplayNotification { this._closeButton = /** @type {HTMLElement} */ (node.querySelector('.footer-notification-close-button')); /** @type {EventListenerCollection} */ this._eventListeners = new EventListenerCollection(); - /** @type {?number} */ + /** @type {?import('core').Timeout} */ this._closeTimer = null; } diff --git a/ext/js/display/display.js b/ext/js/display/display.js index f14291d1..6e1450c3 100644 --- a/ext/js/display/display.js +++ b/ext/js/display/display.js @@ -117,7 +117,7 @@ export class Display extends EventDispatcher { this._queryOffset = 0; /** @type {HTMLElement} */ this._progressIndicator = /** @type {HTMLElement} */ (document.querySelector('#progress-indicator')); - /** @type {?number} */ + /** @type {?import('core').Timeout} */ this._progressIndicatorTimer = null; /** @type {DynamicProperty} */ this._progressIndicatorVisible = new DynamicProperty(false); diff --git a/ext/js/display/element-overflow-controller.js b/ext/js/display/element-overflow-controller.js index 1d2c808f..35277fa5 100644 --- a/ext/js/display/element-overflow-controller.js +++ b/ext/js/display/element-overflow-controller.js @@ -22,7 +22,7 @@ export class ElementOverflowController { constructor() { /** @type {Element[]} */ this._elements = []; - /** @type {?number} */ + /** @type {?(number|import('core').Timeout)} */ this._checkTimer = null; /** @type {EventListenerCollection} */ this._eventListeners = new EventListenerCollection(); @@ -154,7 +154,7 @@ export class ElementOverflowController { /** * @param {() => void} callback * @param {number} timeout - * @returns {number} + * @returns {number|import('core').Timeout} */ _requestIdleCallback(callback, timeout) { if (typeof requestIdleCallback === 'function') { @@ -165,11 +165,11 @@ export class ElementOverflowController { } /** - * @param {number} handle + * @param {number|import('core').Timeout} handle */ _cancelIdleCallback(handle) { if (typeof cancelIdleCallback === 'function') { - cancelIdleCallback(handle); + cancelIdleCallback(/** @type {number} */ (handle)); } else { clearTimeout(handle); } diff --git a/ext/js/display/option-toggle-hotkey-handler.js b/ext/js/display/option-toggle-hotkey-handler.js index 531e208d..edd7de5b 100644 --- a/ext/js/display/option-toggle-hotkey-handler.js +++ b/ext/js/display/option-toggle-hotkey-handler.js @@ -29,7 +29,7 @@ export class OptionToggleHotkeyHandler { this._display = display; /** @type {?import('./display-notification.js').DisplayNotification} */ this._notification = null; - /** @type {?number} */ + /** @type {?import('core').Timeout} */ this._notificationHideTimer = null; /** @type {number} */ this._notificationHideTimeout = 5000; diff --git a/ext/js/display/search-display-controller.js b/ext/js/display/search-display-controller.js index b93757c2..98a4666b 100644 --- a/ext/js/display/search-display-controller.js +++ b/ext/js/display/search-display-controller.js @@ -63,7 +63,7 @@ export class SearchDisplayController { this._wanakanaBound = false; /** @type {boolean} */ this._introVisible = true; - /** @type {?number} */ + /** @type {?import('core').Timeout} */ this._introAnimationTimer = null; /** @type {boolean} */ this._clipboardMonitorEnabled = false; diff --git a/ext/js/dom/document-util.js b/ext/js/dom/document-util.js index cf58d39f..549a8195 100644 --- a/ext/js/dom/document-util.js +++ b/ext/js/dom/document-util.js @@ -360,7 +360,7 @@ export class DocumentUtil { /** * Adds a fullscreen change event listener. This function handles all of the browser-specific variants. * @param {EventListener} onFullscreenChanged The event callback. - * @param {?EventListenerCollection} eventListenerCollection An optional `EventListenerCollection` to add the registration to. + * @param {?import('../core.js').EventListenerCollection} eventListenerCollection An optional `EventListenerCollection` to add the registration to. */ static addFullscreenChangeEventListener(onFullscreenChanged, eventListenerCollection=null) { const target = document; diff --git a/ext/js/dom/panel-element.js b/ext/js/dom/panel-element.js index 314eb2fd..748c3a36 100644 --- a/ext/js/dom/panel-element.js +++ b/ext/js/dom/panel-element.js @@ -37,7 +37,7 @@ export class PanelElement extends EventDispatcher { this._mutationObserver = null; /** @type {boolean} */ this._visible = false; - /** @type {?number} */ + /** @type {?import('core').Timeout} */ this._closeTimer = null; } diff --git a/ext/js/language/text-scanner.js b/ext/js/language/text-scanner.js index f6bcde8d..d1b033e6 100644 --- a/ext/js/language/text-scanner.js +++ b/ext/js/language/text-scanner.js @@ -120,7 +120,7 @@ export class TextScanner extends EventDispatcher { /** @type {boolean} */ this._preventNextClickScan = false; - /** @type {?number} */ + /** @type {?import('core').Timeout} */ this._preventNextClickScanTimer = null; /** @type {number} */ this._preventNextClickScanTimerDuration = 50; @@ -145,7 +145,7 @@ export class TextScanner extends EventDispatcher { /** @type {boolean} */ this._canClearSelection = true; - /** @type {?number} */ + /** @type {?import('core').Timeout} */ this._textSelectionTimer = null; /** @type {boolean} */ this._yomitanIsChangingTextSelectionNow = false; @@ -995,7 +995,7 @@ export class TextScanner extends EventDispatcher { async _scanTimerWait() { const delay = this._delay; const promise = /** @type {Promise} */ (new Promise((resolve) => { - /** @type {?number} */ + /** @type {?import('core').Timeout} */ let timeout = setTimeout(() => { timeout = null; resolve(true); diff --git a/ext/js/media/audio-downloader.js b/ext/js/media/audio-downloader.js index 0847d479..e041cc67 100644 --- a/ext/js/media/audio-downloader.js +++ b/ext/js/media/audio-downloader.js @@ -316,7 +316,7 @@ export class AudioDownloader { let signal; /** @type {?import('request-builder.js').ProgressCallback} */ let onProgress = null; - /** @type {?number} */ + /** @type {?import('core').Timeout} */ let idleTimer = null; if (typeof idleTimeout === 'number') { const abortController = new AbortController(); diff --git a/ext/js/pages/settings/popup-preview-frame.js b/ext/js/pages/settings/popup-preview-frame.js index bb00829f..dab21f4d 100644 --- a/ext/js/pages/settings/popup-preview-frame.js +++ b/ext/js/pages/settings/popup-preview-frame.js @@ -43,7 +43,7 @@ export class PopupPreviewFrame { this._apiOptionsGetOld = null; /** @type {boolean} */ this._popupShown = false; - /** @type {?number} */ + /** @type {?import('core').Timeout} */ this._themeChangeTimeout = null; /** @type {?import('text-source').TextSource} */ this._textSource = null; diff --git a/test/jsconfig.json b/test/jsconfig.json index 261ec345..934aab81 100644 --- a/test/jsconfig.json +++ b/test/jsconfig.json @@ -31,7 +31,7 @@ "../ext/**/*.js", "../types/ext/**/*.ts", "../types/dev/**/*.ts", - "../types/other/web-set-timeout.d.ts" + "../types/other/globals.d.ts" ], "exclude": [ "../node_modules", diff --git a/types/ext/core.d.ts b/types/ext/core.d.ts index ce3a09f0..b83e6a74 100644 --- a/types/ext/core.d.ts +++ b/types/ext/core.d.ts @@ -100,3 +100,5 @@ export type MessageHandlerDetails = { export type MessageHandlerMap = Map; export type MessageHandlerArray = [key: string, handlerDetails: MessageHandlerDetails][]; + +export type Timeout = number | NodeJS.Timeout; diff --git a/types/ext/cross-frame-api.d.ts b/types/ext/cross-frame-api.d.ts index 5cedbec9..88ce59a7 100644 --- a/types/ext/cross-frame-api.d.ts +++ b/types/ext/cross-frame-api.d.ts @@ -50,5 +50,5 @@ export type Invocation = { responseTimeout: number; action: string; ack: boolean; - timer: number | null; + timer: Core.Timeout | null; }; diff --git a/types/ext/offscreen.d.ts b/types/ext/offscreen.d.ts index 7dd64d1e..ddf7eadc 100644 --- a/types/ext/offscreen.d.ts +++ b/types/ext/offscreen.d.ts @@ -112,4 +112,4 @@ export type MessageHandler< details: MessageDetailsMap[TMessage], ) => (TIsAsync extends true ? Promise> : MessageReturn); -export type MessageHandlerMap = Map; +export type MessageHandlerMap = Map; diff --git a/types/other/globals.d.ts b/types/other/globals.d.ts new file mode 100644 index 00000000..330f16c2 --- /dev/null +++ b/types/other/globals.d.ts @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2023 Yomitan Authors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +declare global { + function clearTimeout(timeoutId: NodeJS.Timeout | string | number | undefined): void; +} + +export {}; diff --git a/types/other/web-set-timeout.d.ts b/types/other/web-set-timeout.d.ts deleted file mode 100644 index 98e40dab..00000000 --- a/types/other/web-set-timeout.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2023 Yomitan Authors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -declare module 'web-set-timeout' { - global { - // These types are used to ensure that setTimeout returns a number - function setTimeout(callback: (...args: TArgs) => void, ms?: number, ...args: TArgs): number; - function setTimeout(callback: (args: void) => void, ms?: number): number; - } -} -- cgit v1.2.3 From bfcc9d3fba4a3ff85be167eb771a4c0f26f9cc49 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 29 Nov 2023 21:52:53 -0500 Subject: Fix rollup type issue --- dev/jsconfig.json | 5 +++-- test/jsconfig.json | 5 +++-- types/other/rollup-parse-ast.d.ts | 25 +++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 types/other/rollup-parse-ast.d.ts (limited to 'types/other') diff --git a/dev/jsconfig.json b/dev/jsconfig.json index e0074980..a52153a8 100644 --- a/dev/jsconfig.json +++ b/dev/jsconfig.json @@ -3,7 +3,7 @@ "module": "ES2022", "target": "ES2022", "checkJs": true, - "moduleResolution": "bundler", + "moduleResolution": "node", "strict": true, "strictNullChecks": true, "noImplicitAny": true, @@ -36,7 +36,8 @@ "translator": ["../types/ext/translator"], "translation": ["../types/ext/translation"], "translation-internal": ["../types/ext/translation-internal"], - "dev/*": ["../types/dev/*"] + "dev/*": ["../types/dev/*"], + "rollup/parseAst": ["../types/other/rollup-parse-ast"] }, "types": [ "node", diff --git a/test/jsconfig.json b/test/jsconfig.json index 7dbf3950..c587abe6 100644 --- a/test/jsconfig.json +++ b/test/jsconfig.json @@ -3,7 +3,7 @@ "module": "ES2022", "target": "ES2022", "checkJs": true, - "moduleResolution": "bundler", + "moduleResolution": "node", "strict": true, "strictNullChecks": true, "noImplicitAny": true, @@ -14,7 +14,8 @@ "paths": { "*": ["../types/ext/*"], "dev/*": ["../types/dev/*"], - "test/*": ["../types/test/*"] + "test/*": ["../types/test/*"], + "rollup/parseAst": ["../types/other/rollup-parse-ast"] }, "types": [ "chrome", diff --git a/types/other/rollup-parse-ast.d.ts b/types/other/rollup-parse-ast.d.ts new file mode 100644 index 00000000..52a5ec98 --- /dev/null +++ b/types/other/rollup-parse-ast.d.ts @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2023 Yomitan Authors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +// Patch for type definitions that aren't exported for rollup/parseAst +// https://github.com/vitest-dev/vitest/issues/4567 +// https://github.com/rollup/rollup/issues/5199 + +import type {ParseAst, ParseAstAsync} from 'rollup'; + +export const parseAst: ParseAst; +export const parseAstAsync: ParseAstAsync; -- cgit v1.2.3 From 4f24982112e7d4ad7b3f35c21926eafd6f0c8ff3 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 3 Dec 2023 11:17:57 -0500 Subject: Update imports --- types/ext/dictionary-importer.d.ts | 2 +- types/ext/dictionary-worker.d.ts | 2 +- types/ext/display-audio.d.ts | 4 ++-- types/ext/display.d.ts | 8 ++++---- types/ext/event-listener-collection.d.ts | 2 +- types/ext/generic-setting-controller.d.ts | 2 +- types/ext/popup.d.ts | 6 +++--- types/ext/settings-controller.d.ts | 6 +++--- types/ext/simple-dom-parser.d.ts | 5 ++--- types/ext/text-scanner.d.ts | 2 +- types/ext/translation-internal.d.ts | 2 +- types/ext/translator.d.ts | 4 ++-- types/other/globals.d.ts | 2 +- 13 files changed, 23 insertions(+), 24 deletions(-) (limited to 'types/other') diff --git a/types/ext/dictionary-importer.d.ts b/types/ext/dictionary-importer.d.ts index de85d04a..5ae20dd1 100644 --- a/types/ext/dictionary-importer.d.ts +++ b/types/ext/dictionary-importer.d.ts @@ -15,8 +15,8 @@ * along with this program. If not, see . */ -import type * as Ajv from 'ajv'; import type * as ZipJS from '@zip.js/zip.js'; +import type * as Ajv from 'ajv'; import type * as DictionaryData from './dictionary-data'; import type * as DictionaryDatabase from './dictionary-database'; import type * as StructuredContent from './structured-content'; diff --git a/types/ext/dictionary-worker.d.ts b/types/ext/dictionary-worker.d.ts index 570d37cd..17030691 100644 --- a/types/ext/dictionary-worker.d.ts +++ b/types/ext/dictionary-worker.d.ts @@ -16,8 +16,8 @@ */ import type * as Core from './core'; -import type * as DictionaryImporter from './dictionary-importer'; import type * as DictionaryDatabase from './dictionary-database'; +import type * as DictionaryImporter from './dictionary-importer'; export type InvokeDetails = { complete: boolean; diff --git a/types/ext/display-audio.d.ts b/types/ext/display-audio.d.ts index 759e5ee6..c9590cf2 100644 --- a/types/ext/display-audio.d.ts +++ b/types/ext/display-audio.d.ts @@ -15,10 +15,10 @@ * along with this program. If not, see . */ +import type {TextToSpeechAudio} from '../../ext/js/media/text-to-speech-audio'; import type * as Audio from './audio'; -import type * as Settings from './settings'; import type * as AudioDownloader from './audio-downloader'; -import type {TextToSpeechAudio} from '../../ext/js/media/text-to-speech-audio'; +import type * as Settings from './settings'; export type CacheItem = { sourceMap: Map; diff --git a/types/ext/display.d.ts b/types/ext/display.d.ts index 533fc441..aa0f0353 100644 --- a/types/ext/display.d.ts +++ b/types/ext/display.d.ts @@ -15,16 +15,16 @@ * along with this program. If not, see . */ +import type {DisplayContentManager} from '../../ext/js/display/display-content-manager'; +import type {HotkeyHelpController} from '../../ext/js/input/hotkey-help-controller'; +import type {JapaneseUtil} from '../../ext/js/language/sandbox/japanese-util'; +import type {TextScanner} from '../../ext/js/language/text-scanner'; import type * as Core from './core'; import type * as Dictionary from './dictionary'; import type * as Extension from './extension'; import type * as Settings from './settings'; import type * as TextScannerTypes from './text-scanner'; import type * as TextSource from './text-source'; -import type {DisplayContentManager} from '../../ext/js/display/display-content-manager'; -import type {HotkeyHelpController} from '../../ext/js/input/hotkey-help-controller'; -import type {JapaneseUtil} from '../../ext/js/language/sandbox/japanese-util'; -import type {TextScanner} from '../../ext/js/language/text-scanner'; export type HistoryMode = 'clear' | 'overwrite' | 'new'; diff --git a/types/ext/event-listener-collection.d.ts b/types/ext/event-listener-collection.d.ts index eee05658..988baa76 100644 --- a/types/ext/event-listener-collection.d.ts +++ b/types/ext/event-listener-collection.d.ts @@ -15,8 +15,8 @@ * along with this program. If not, see . */ -import type * as Core from './core'; import type {EventDispatcher} from '../../ext/js/core'; +import type * as Core from './core'; export type EventListenerFunction = (...args: Core.SafeAny[]) => unknown; diff --git a/types/ext/generic-setting-controller.d.ts b/types/ext/generic-setting-controller.d.ts index 5e3435c5..f7a2be5f 100644 --- a/types/ext/generic-setting-controller.d.ts +++ b/types/ext/generic-setting-controller.d.ts @@ -15,8 +15,8 @@ * along with this program. If not, see . */ -import type * as SettingsModifications from './settings-modifications'; import type * as DocumentUtil from './document-util'; +import type * as SettingsModifications from './settings-modifications'; export type TransformType = TransformData['type']; diff --git a/types/ext/popup.d.ts b/types/ext/popup.d.ts index aaeb676a..65725f96 100644 --- a/types/ext/popup.d.ts +++ b/types/ext/popup.d.ts @@ -15,12 +15,12 @@ * along with this program. If not, see . */ -import type * as DocumentUtil from './document-util'; -import type * as Settings from './settings'; -import type {FrameOffsetForwarder} from '../../ext/js/comm/frame-offset-forwarder'; import type {Popup} from '../../ext/js/app/popup'; import type {PopupProxy} from '../../ext/js/app/popup-proxy'; import type {PopupWindow} from '../../ext/js/app/popup-window'; +import type {FrameOffsetForwarder} from '../../ext/js/comm/frame-offset-forwarder'; +import type * as DocumentUtil from './document-util'; +import type * as Settings from './settings'; export type PopupAny = Popup | PopupWindow | PopupProxy; diff --git a/types/ext/settings-controller.d.ts b/types/ext/settings-controller.d.ts index 37399bc3..697de878 100644 --- a/types/ext/settings-controller.d.ts +++ b/types/ext/settings-controller.d.ts @@ -15,12 +15,12 @@ * along with this program. If not, see . */ -import type * as Core from './core'; -import type * as Settings from './settings'; -import type * as SettingsModifications from './settings-modifications'; import type {DictionaryController} from '../../ext/js/pages/settings/dictionary-controller'; import type {ScanInputsController} from '../../ext/js/pages/settings/scan-inputs-controller'; import type {ScanInputsSimpleController} from '../../ext/js/pages/settings/scan-inputs-simple-controller'; +import type * as Core from './core'; +import type * as Settings from './settings'; +import type * as SettingsModifications from './settings-modifications'; export type PageExitPrevention = { end: () => void; diff --git a/types/ext/simple-dom-parser.d.ts b/types/ext/simple-dom-parser.d.ts index 5fefe69d..d9ae3898 100644 --- a/types/ext/simple-dom-parser.d.ts +++ b/types/ext/simple-dom-parser.d.ts @@ -16,9 +16,8 @@ */ export type { - Document as Parse5Document, - Element as Parse5Element, - ChildNode as Parse5ChildNode, + ChildNode as Parse5ChildNode, Document as Parse5Document, + Element as Parse5Element } from 'parse5/dist/tree-adapters/default'; /** diff --git a/types/ext/text-scanner.d.ts b/types/ext/text-scanner.d.ts index 5ff62819..4ec7f204 100644 --- a/types/ext/text-scanner.d.ts +++ b/types/ext/text-scanner.d.ts @@ -15,12 +15,12 @@ * along with this program. If not, see . */ +import type {TextScanner} from '../../ext/js/language/text-scanner'; import type * as Dictionary from './dictionary'; import type * as Display from './display'; import type * as Input from './input'; import type * as Settings from './settings'; import type * as TextSource from './text-source'; -import type {TextScanner} from '../../ext/js/language/text-scanner'; export type SearchResultDetail = { documentTitle: string; diff --git a/types/ext/translation-internal.d.ts b/types/ext/translation-internal.d.ts index 00f51b05..784a5979 100644 --- a/types/ext/translation-internal.d.ts +++ b/types/ext/translation-internal.d.ts @@ -15,8 +15,8 @@ * along with this program. If not, see . */ -import type * as Translation from './translation'; import type * as DictionaryDatabase from './dictionary-database'; +import type * as Translation from './translation'; export type TextDeinflectionOptions = [ textReplacements: Translation.FindTermsTextReplacement[] | null, diff --git a/types/ext/translator.d.ts b/types/ext/translator.d.ts index 838ae171..39d4be81 100644 --- a/types/ext/translator.d.ts +++ b/types/ext/translator.d.ts @@ -15,10 +15,10 @@ * along with this program. If not, see . */ -import type * as Dictionary from './dictionary'; -import type * as DictionaryDatabaseTypes from './dictionary-database'; import type {DictionaryDatabase} from '../../ext/js/language/dictionary-database'; import type {JapaneseUtil} from '../../ext/js/language/sandbox/japanese-util'; +import type * as Dictionary from './dictionary'; +import type * as DictionaryDatabaseTypes from './dictionary-database'; export type ConstructorDetails = { /** An instance of JapaneseUtil. */ diff --git a/types/other/globals.d.ts b/types/other/globals.d.ts index 330f16c2..4f6db6c9 100644 --- a/types/other/globals.d.ts +++ b/types/other/globals.d.ts @@ -19,4 +19,4 @@ declare global { function clearTimeout(timeoutId: NodeJS.Timeout | string | number | undefined): void; } -export {}; +export { }; -- cgit v1.2.3