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) --- ext/js/templates/sandbox/template-renderer.js | 100 +++++++++++++++++++++----- 1 file changed, 82 insertions(+), 18 deletions(-) (limited to 'ext/js/templates/sandbox/template-renderer.js') diff --git a/ext/js/templates/sandbox/template-renderer.js b/ext/js/templates/sandbox/template-renderer.js index 8d8a2765..c7613533 100644 --- a/ext/js/templates/sandbox/template-renderer.js +++ b/ext/js/templates/sandbox/template-renderer.js @@ -20,47 +20,74 @@ import {Handlebars} from '../../../lib/handlebars.js'; export class TemplateRenderer { constructor() { + /** @type {Map>} */ this._cache = new Map(); + /** @type {number} */ this._cacheMaxSize = 5; + /** @type {Map} */ this._dataTypes = new Map(); + /** @type {?((noteData: import('anki-templates').NoteData) => import('template-renderer').SetupCallbackResult)} */ this._renderSetup = null; + /** @type {?((noteData: import('anki-templates').NoteData) => import('template-renderer').CleanupCallbackResult)} */ this._renderCleanup = null; } + /** + * @param {import('template-renderer').HelperFunctionsDescriptor} helpers + */ registerHelpers(helpers) { for (const [name, helper] of helpers) { this._registerHelper(name, helper); } } - registerDataType(name, {modifier=null, composeData=null}) { + /** + * @param {import('anki-templates').RenderMode} name + * @param {import('template-renderer').DataType} details + */ + registerDataType(name, {modifier, composeData}) { this._dataTypes.set(name, {modifier, composeData}); } + /** + * @param {?((noteData: import('anki-templates').NoteData) => import('template-renderer').SetupCallbackResult)} setup + * @param {?((noteData: import('anki-templates').NoteData) => import('template-renderer').CleanupCallbackResult)} cleanup + */ setRenderCallbacks(setup, cleanup) { this._renderSetup = setup; this._renderCleanup = cleanup; } + /** + * @param {string} template + * @param {import('template-renderer').PartialOrCompositeRenderData} data + * @param {import('anki-templates').RenderMode} type + * @returns {import('template-renderer').RenderResult} + */ render(template, data, type) { const instance = this._getTemplateInstance(template); - data = this._getModifiedData(data, void 0, type); - return this._renderTemplate(instance, data); + const modifiedData = this._getModifiedData(data, void 0, type); + return this._renderTemplate(instance, modifiedData); } + /** + * @param {import('template-renderer').RenderMultiItem[]} items + * @returns {import('core').Response[]} + */ renderMulti(items) { + /** @type {import('core').Response[]} */ const results = []; for (const {template, templateItems} of items) { const instance = this._getTemplateInstance(template); for (const {type, commonData, datas} of templateItems) { - for (let data of datas) { + for (const data of datas) { let result; try { - data = this._getModifiedData(data, commonData, type); - result = this._renderTemplate(instance, data); - result = {result}; + const data2 = this._getModifiedData(data, commonData, type); + const renderResult = this._renderTemplate(instance, data2); + result = {result: renderResult}; } catch (error) { - result = {error}; + result = {error: ExtensionError.serialize(error)}; } results.push(result); } @@ -69,29 +96,46 @@ export class TemplateRenderer { return results; } + /** + * @param {import('template-renderer').CompositeRenderData} data + * @param {import('anki-templates').RenderMode} type + * @returns {import('anki-templates').NoteData} + */ getModifiedData(data, type) { return this._getModifiedData(data, void 0, type); } // Private + /** + * @param {string} template + * @returns {HandlebarsTemplateDelegate} + */ _getTemplateInstance(template) { const cache = this._cache; let instance = cache.get(template); if (typeof instance === 'undefined') { this._updateCacheSize(this._cacheMaxSize - 1); - instance = Handlebars.compileAST(template); + instance = /** @type {HandlebarsTemplateDelegate} */ (Handlebars.compileAST(template)); cache.set(template, instance); } return instance; } + /** + * @param {HandlebarsTemplateDelegate} instance + * @param {import('anki-templates').NoteData} data + * @returns {import('template-renderer').RenderResult} + */ _renderTemplate(instance, data) { const renderSetup = this._renderSetup; const renderCleanup = this._renderCleanup; + /** @type {string} */ let result; + /** @type {?import('template-renderer').SetupCallbackResult} */ let additions1; + /** @type {?import('template-renderer').CleanupCallbackResult} */ let additions2; try { additions1 = (typeof renderSetup === 'function' ? renderSetup(data) : null); @@ -99,28 +143,36 @@ export class TemplateRenderer { } finally { additions2 = (typeof renderCleanup === 'function' ? renderCleanup(data) : null); } - return Object.assign({result}, additions1, additions2); + return /** @type {import('template-renderer').RenderResult} */ (Object.assign({result}, additions1, additions2)); } + /** + * @param {import('template-renderer').PartialOrCompositeRenderData} data + * @param {import('anki-note-builder').CommonData|undefined} commonData + * @param {import('anki-templates').RenderMode} type + * @returns {import('anki-templates').NoteData} + * @throws {Error} + */ _getModifiedData(data, commonData, type) { if (typeof type === 'string') { const typeInfo = this._dataTypes.get(type); if (typeof typeInfo !== 'undefined') { if (typeof commonData !== 'undefined') { const {composeData} = typeInfo; - if (typeof composeData === 'function') { - data = composeData(data, commonData); - } + data = composeData(data, commonData); + } else if (typeof data.commonData === 'undefined') { + throw new Error('Incomplete data'); } const {modifier} = typeInfo; - if (typeof modifier === 'function') { - data = modifier(data); - } + return modifier(/** @type {import('template-renderer').CompositeRenderData} */ (data)); } } - return data; + throw new Error(`Invalid type: ${type}`); } + /** + * @param {number} maxSize + */ _updateCacheSize(maxSize) { const cache = this._cache; let removeCount = cache.size - maxSize; @@ -132,9 +184,21 @@ export class TemplateRenderer { } } + /** + * @param {string} name + * @param {import('template-renderer').HelperFunction} helper + */ _registerHelper(name, helper) { + /** + * @this {unknown} + * @param {unknown[]} args + * @returns {unknown} + */ function wrapper(...args) { - return helper(this, ...args); + const argCountM1 = Math.max(0, args.length - 1); + const options = /** @type {Handlebars.HelperOptions} */ (args[argCountM1]); + args.length = argCountM1; + return helper(args, this, options); } Handlebars.registerHelper(name, wrapper); } -- cgit v1.2.3 From 6a3dae04de68ab633da15bbc8ec6b350e38e6d2f Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 27 Nov 2023 13:54:43 -0500 Subject: Add extension error imports --- ext/js/app/popup.js | 1 + ext/js/comm/anki-connect.js | 1 + ext/js/data/anki-note-builder.js | 1 + ext/js/display/display-generator.js | 1 + ext/js/display/option-toggle-hotkey-handler.js | 1 + ext/js/language/dictionary-worker-handler.js | 1 + ext/js/language/dictionary-worker-media-loader.js | 1 + ext/js/language/dictionary-worker.js | 1 + ext/js/media/audio-downloader.js | 1 + ext/js/pages/settings/anki-controller.js | 1 + ext/js/pages/settings/anki-templates-controller.js | 1 + ext/js/pages/settings/dictionary-import-controller.js | 1 + ext/js/pages/settings/generic-setting-controller.js | 1 + ext/js/templates/sandbox/template-renderer-frame-api.js | 2 ++ ext/js/templates/sandbox/template-renderer.js | 1 + ext/js/templates/template-renderer-proxy.js | 1 + 16 files changed, 17 insertions(+) (limited to 'ext/js/templates/sandbox/template-renderer.js') diff --git a/ext/js/app/popup.js b/ext/js/app/popup.js index 31b18f01..4f201fc3 100644 --- a/ext/js/app/popup.js +++ b/ext/js/app/popup.js @@ -18,6 +18,7 @@ import {FrameClient} from '../comm/frame-client.js'; import {DynamicProperty, EventDispatcher, EventListenerCollection, deepEqual} from '../core.js'; +import {ExtensionError} from '../core/extension-error.js'; import {DocumentUtil} from '../dom/document-util.js'; import {dynamicLoader} from '../script/dynamic-loader.js'; import {yomitan} from '../yomitan.js'; diff --git a/ext/js/comm/anki-connect.js b/ext/js/comm/anki-connect.js index b876703f..7ff8d0e1 100644 --- a/ext/js/comm/anki-connect.js +++ b/ext/js/comm/anki-connect.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +import {ExtensionError} from '../core/extension-error.js'; import {AnkiUtil} from '../data/anki-util.js'; /** diff --git a/ext/js/data/anki-note-builder.js b/ext/js/data/anki-note-builder.js index f8296ee0..28809e1f 100644 --- a/ext/js/data/anki-note-builder.js +++ b/ext/js/data/anki-note-builder.js @@ -17,6 +17,7 @@ */ import {deferPromise} from '../core.js'; +import {ExtensionError} from '../core/extension-error.js'; import {TemplateRendererProxy} from '../templates/template-renderer-proxy.js'; import {yomitan} from '../yomitan.js'; import {AnkiUtil} from './anki-util.js'; diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index 9fc700f3..e8be79d9 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -17,6 +17,7 @@ */ import {isObject} from '../core.js'; +import {ExtensionError} from '../core/extension-error.js'; import {HtmlTemplateCollection} from '../dom/html-template-collection.js'; import {DictionaryDataUtil} from '../language/sandbox/dictionary-data-util.js'; import {yomitan} from '../yomitan.js'; diff --git a/ext/js/display/option-toggle-hotkey-handler.js b/ext/js/display/option-toggle-hotkey-handler.js index e73fcf04..9677e86b 100644 --- a/ext/js/display/option-toggle-hotkey-handler.js +++ b/ext/js/display/option-toggle-hotkey-handler.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +import {ExtensionError} from '../core/extension-error.js'; import {yomitan} from '../yomitan.js'; export class OptionToggleHotkeyHandler { diff --git a/ext/js/language/dictionary-worker-handler.js b/ext/js/language/dictionary-worker-handler.js index 3a85cb71..9a724386 100644 --- a/ext/js/language/dictionary-worker-handler.js +++ b/ext/js/language/dictionary-worker-handler.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +import {ExtensionError} from '../core/extension-error.js'; import {DictionaryDatabase} from './dictionary-database.js'; import {DictionaryImporter} from './dictionary-importer.js'; import {DictionaryWorkerMediaLoader} from './dictionary-worker-media-loader.js'; diff --git a/ext/js/language/dictionary-worker-media-loader.js b/ext/js/language/dictionary-worker-media-loader.js index 2701389e..e19a13d3 100644 --- a/ext/js/language/dictionary-worker-media-loader.js +++ b/ext/js/language/dictionary-worker-media-loader.js @@ -17,6 +17,7 @@ */ import {generateId} from '../core.js'; +import {ExtensionError} from '../core/extension-error.js'; /** * Class used for loading and validating media from a worker thread diff --git a/ext/js/language/dictionary-worker.js b/ext/js/language/dictionary-worker.js index b9d0236c..3e78a6ff 100644 --- a/ext/js/language/dictionary-worker.js +++ b/ext/js/language/dictionary-worker.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +import {ExtensionError} from '../core/extension-error.js'; import {DictionaryImporterMediaLoader} from './dictionary-importer-media-loader.js'; export class DictionaryWorker { diff --git a/ext/js/media/audio-downloader.js b/ext/js/media/audio-downloader.js index 8bd04b2b..7b236790 100644 --- a/ext/js/media/audio-downloader.js +++ b/ext/js/media/audio-downloader.js @@ -17,6 +17,7 @@ */ import {RequestBuilder} from '../background/request-builder.js'; +import {ExtensionError} from '../core/extension-error.js'; import {JsonSchema} from '../data/json-schema.js'; import {ArrayBufferUtil} from '../data/sandbox/array-buffer-util.js'; import {NativeSimpleDOMParser} from '../dom/native-simple-dom-parser.js'; diff --git a/ext/js/pages/settings/anki-controller.js b/ext/js/pages/settings/anki-controller.js index 0ccd018d..722459df 100644 --- a/ext/js/pages/settings/anki-controller.js +++ b/ext/js/pages/settings/anki-controller.js @@ -18,6 +18,7 @@ import {AnkiConnect} from '../../comm/anki-connect.js'; import {EventListenerCollection, log} from '../../core.js'; +import {ExtensionError} from '../../core/extension-error.js'; import {AnkiUtil} from '../../data/anki-util.js'; import {SelectorObserver} from '../../dom/selector-observer.js'; import {ObjectPropertyAccessor} from '../../general/object-property-accessor.js'; diff --git a/ext/js/pages/settings/anki-templates-controller.js b/ext/js/pages/settings/anki-templates-controller.js index d2814880..a0ff96b2 100644 --- a/ext/js/pages/settings/anki-templates-controller.js +++ b/ext/js/pages/settings/anki-templates-controller.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +import {ExtensionError} from '../../core/extension-error.js'; import {AnkiNoteBuilder} from '../../data/anki-note-builder.js'; import {JapaneseUtil} from '../../language/sandbox/japanese-util.js'; import {yomitan} from '../../yomitan.js'; diff --git a/ext/js/pages/settings/dictionary-import-controller.js b/ext/js/pages/settings/dictionary-import-controller.js index 106ecbca..af8c2fcd 100644 --- a/ext/js/pages/settings/dictionary-import-controller.js +++ b/ext/js/pages/settings/dictionary-import-controller.js @@ -17,6 +17,7 @@ */ import {log} from '../../core.js'; +import {ExtensionError} from '../../core/extension-error.js'; import {DictionaryWorker} from '../../language/dictionary-worker.js'; import {yomitan} from '../../yomitan.js'; import {DictionaryController} from './dictionary-controller.js'; diff --git a/ext/js/pages/settings/generic-setting-controller.js b/ext/js/pages/settings/generic-setting-controller.js index 3c6104a9..47c0d6fe 100644 --- a/ext/js/pages/settings/generic-setting-controller.js +++ b/ext/js/pages/settings/generic-setting-controller.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +import {ExtensionError} from '../../core/extension-error.js'; import {DocumentUtil} from '../../dom/document-util.js'; import {DOMDataBinder} from '../../dom/dom-data-binder.js'; diff --git a/ext/js/templates/sandbox/template-renderer-frame-api.js b/ext/js/templates/sandbox/template-renderer-frame-api.js index 31ba4500..91400ab8 100644 --- a/ext/js/templates/sandbox/template-renderer-frame-api.js +++ b/ext/js/templates/sandbox/template-renderer-frame-api.js @@ -16,6 +16,8 @@ * along with this program. If not, see . */ +import {ExtensionError} from '../../core/extension-error.js'; + export class TemplateRendererFrameApi { /** * @param {TemplateRenderer} templateRenderer diff --git a/ext/js/templates/sandbox/template-renderer.js b/ext/js/templates/sandbox/template-renderer.js index c7613533..716e3ccc 100644 --- a/ext/js/templates/sandbox/template-renderer.js +++ b/ext/js/templates/sandbox/template-renderer.js @@ -17,6 +17,7 @@ */ import {Handlebars} from '../../../lib/handlebars.js'; +import {ExtensionError} from '../../core/extension-error.js'; export class TemplateRenderer { constructor() { diff --git a/ext/js/templates/template-renderer-proxy.js b/ext/js/templates/template-renderer-proxy.js index e67b715a..642eea8b 100644 --- a/ext/js/templates/template-renderer-proxy.js +++ b/ext/js/templates/template-renderer-proxy.js @@ -17,6 +17,7 @@ */ import {generateId} from '../core.js'; +import {ExtensionError} from '../core/extension-error.js'; export class TemplateRendererProxy { constructor() { -- cgit v1.2.3 From c8ac0d45bfb94deabd933117ba55d365f43fb1c5 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 27 Nov 2023 14:08:39 -0500 Subject: Updates --- .vscode/settings.json | 2 +- .../templates/__mocks__/template-renderer-proxy.js | 53 ++++++++-------------- .../anki-template-renderer-content-manager.js | 6 +-- ext/js/templates/sandbox/anki-template-renderer.js | 8 ++-- .../sandbox/template-renderer-frame-api.js | 4 +- ext/js/templates/sandbox/template-renderer.js | 8 ++-- 6 files changed, 32 insertions(+), 49 deletions(-) (limited to 'ext/js/templates/sandbox/template-renderer.js') diff --git a/.vscode/settings.json b/.vscode/settings.json index ecfe13c5..81cd7b9c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,7 +3,7 @@ "editor.codeActionsOnSave": { "source.addMissingImports": false, "source.organizeImports": true, - "source.fixAll.eslint": true, + "source.fixAll.eslint": false }, "eslint.format.enable": true, "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false, diff --git a/ext/js/templates/__mocks__/template-renderer-proxy.js b/ext/js/templates/__mocks__/template-renderer-proxy.js index bcacf13b..8823e8f3 100644 --- a/ext/js/templates/__mocks__/template-renderer-proxy.js +++ b/ext/js/templates/__mocks__/template-renderer-proxy.js @@ -20,20 +20,35 @@ import {AnkiTemplateRenderer} from '../sandbox/anki-template-renderer.js'; export class TemplateRendererProxy { constructor() { + /** @type {?Promise} */ this._preparePromise = null; + /** @type {AnkiTemplateRenderer} */ this._ankiTemplateRenderer = new AnkiTemplateRenderer(); } + /** + * @param {string} template + * @param {import('template-renderer').PartialOrCompositeRenderData} data + * @param {import('anki-templates').RenderMode} type + * @returns {Promise} + */ async render(template, data, type) { await this._prepare(); - return await this._ankiTemplateRenderer.templateRenderer.render(template, data, type); + return this._ankiTemplateRenderer.templateRenderer.render(template, data, type); } + /** + * @param {import('template-renderer').RenderMultiItem[]} items + * @returns {Promise[]>} + */ async renderMulti(items) { await this._prepare(); - return await this._serializeMulti(this._ankiTemplateRenderer.templateRenderer.renderMulti(items)); + return this._ankiTemplateRenderer.templateRenderer.renderMulti(items); } + /** + * @returns {Promise} + */ _prepare() { if (this._preparePromise === null) { this._preparePromise = this._prepareInternal(); @@ -41,40 +56,8 @@ export class TemplateRendererProxy { return this._preparePromise; } + /** */ async _prepareInternal() { await this._ankiTemplateRenderer.prepare(); } - - _serializeError(error) { - try { - if (typeof error === 'object' && error !== null) { - const result = { - name: error.name, - message: error.message, - stack: error.stack - }; - if (Object.prototype.hasOwnProperty.call(error, 'data')) { - result.data = error.data; - } - return result; - } - } catch (e) { - // NOP - } - return { - value: error, - hasValue: true - }; - } - - _serializeMulti(array) { - for (let i = 0, ii = array.length; i < ii; ++i) { - const value = array[i]; - const {error} = value; - if (typeof error !== 'undefined') { - value.error = this._serializeError(error); - } - } - return array; - } } diff --git a/ext/js/templates/sandbox/anki-template-renderer-content-manager.js b/ext/js/templates/sandbox/anki-template-renderer-content-manager.js index be80c211..4989ced3 100644 --- a/ext/js/templates/sandbox/anki-template-renderer-content-manager.js +++ b/ext/js/templates/sandbox/anki-template-renderer-content-manager.js @@ -22,12 +22,12 @@ export class AnkiTemplateRendererContentManager { /** * Creates a new instance of the class. - * @param {TemplateRendererMediaProvider} mediaProvider The media provider for the object. + * @param {import('./template-renderer-media-provider.js').TemplateRendererMediaProvider} mediaProvider The media provider for the object. * @param {import('anki-templates').NoteData} data The data object passed to the Handlebars template renderer. - * See {@link AnkiNoteDataCreator.create}'s return value for structure information. + * See AnkiNoteDataCreator.create's return value for structure information. */ constructor(mediaProvider, data) { - /** @type {TemplateRendererMediaProvider} */ + /** @type {import('./template-renderer-media-provider.js').TemplateRendererMediaProvider} */ this._mediaProvider = mediaProvider; /** @type {import('anki-templates').NoteData} */ this._data = data; diff --git a/ext/js/templates/sandbox/anki-template-renderer.js b/ext/js/templates/sandbox/anki-template-renderer.js index ce8e3200..9f4bf6ff 100644 --- a/ext/js/templates/sandbox/anki-template-renderer.js +++ b/ext/js/templates/sandbox/anki-template-renderer.js @@ -151,8 +151,8 @@ export class AnkiTemplateRenderer { } /** - * - * @param text + * @param {string} text + * @returns {string} */ _safeString(text) { return new Handlebars.SafeString(text); @@ -221,8 +221,8 @@ export class AnkiTemplateRenderer { } /** - * - * @param string + * @param {string} string + * @returns {string} */ _stringToMultiLineHtml(string) { return string.split('\n').join('
'); diff --git a/ext/js/templates/sandbox/template-renderer-frame-api.js b/ext/js/templates/sandbox/template-renderer-frame-api.js index 91400ab8..94ebf7fe 100644 --- a/ext/js/templates/sandbox/template-renderer-frame-api.js +++ b/ext/js/templates/sandbox/template-renderer-frame-api.js @@ -20,10 +20,10 @@ import {ExtensionError} from '../../core/extension-error.js'; export class TemplateRendererFrameApi { /** - * @param {TemplateRenderer} templateRenderer + * @param {import('./template-renderer.js').TemplateRenderer} templateRenderer */ constructor(templateRenderer) { - /** @type {TemplateRenderer} */ + /** @type {import('./template-renderer.js').TemplateRenderer} */ this._templateRenderer = templateRenderer; /** @type {import('core').MessageHandlerMap} */ this._windowMessageHandlers = new Map(/** @type {import('core').MessageHandlerArray} */ ([ diff --git a/ext/js/templates/sandbox/template-renderer.js b/ext/js/templates/sandbox/template-renderer.js index 716e3ccc..fe240b5f 100644 --- a/ext/js/templates/sandbox/template-renderer.js +++ b/ext/js/templates/sandbox/template-renderer.js @@ -21,7 +21,7 @@ import {ExtensionError} from '../../core/extension-error.js'; export class TemplateRenderer { constructor() { - /** @type {Map>} */ + /** @type {Map>} */ this._cache = new Map(); /** @type {number} */ this._cacheMaxSize = 5; @@ -110,14 +110,14 @@ export class TemplateRenderer { /** * @param {string} template - * @returns {HandlebarsTemplateDelegate} + * @returns {import('handlebars').TemplateDelegate} */ _getTemplateInstance(template) { const cache = this._cache; let instance = cache.get(template); if (typeof instance === 'undefined') { this._updateCacheSize(this._cacheMaxSize - 1); - instance = /** @type {HandlebarsTemplateDelegate} */ (Handlebars.compileAST(template)); + instance = /** @type {import('handlebars').TemplateDelegate} */ (Handlebars.compileAST(template)); cache.set(template, instance); } @@ -125,7 +125,7 @@ export class TemplateRenderer { } /** - * @param {HandlebarsTemplateDelegate} instance + * @param {import('handlebars').TemplateDelegate} instance * @param {import('anki-templates').NoteData} data * @returns {import('template-renderer').RenderResult} */ -- cgit v1.2.3 From d5b1217df3fe7480fc5f58fe194f5bbf73281094 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 27 Nov 2023 19:23:17 -0500 Subject: Use import map --- dev/jsconfig.json | 1 + ext/action-popup.html | 8 ++++++++ ext/background.html | 8 ++++++++ ext/info.html | 8 ++++++++ ext/issues.html | 8 ++++++++ ext/js/background/backend.js | 2 +- ext/js/background/offscreen.js | 2 +- ext/js/display/search-display-controller.js | 2 +- ext/js/display/search-main.js | 2 +- ext/js/dom/simple-dom-parser.js | 2 +- ext/js/language/dictionary-importer.js | 4 ++-- ext/js/pages/settings/backup-controller.js | 2 +- ext/js/pages/settings/popup-preview-frame.js | 2 +- ext/js/templates/sandbox/anki-template-renderer.js | 2 +- ext/js/templates/sandbox/template-renderer-media-provider.js | 2 +- ext/js/templates/sandbox/template-renderer.js | 2 +- ext/legal.html | 8 ++++++++ ext/offscreen.html | 8 ++++++++ ext/permissions.html | 8 ++++++++ ext/popup-preview.html | 8 ++++++++ ext/popup.html | 8 ++++++++ ext/search.html | 8 ++++++++ ext/settings.html | 8 ++++++++ ext/template-renderer.html | 8 ++++++++ ext/welcome.html | 8 ++++++++ jsconfig.json | 3 ++- test/japanese-util.test.js | 2 +- test/jsconfig.json | 1 + 28 files changed, 121 insertions(+), 14 deletions(-) (limited to 'ext/js/templates/sandbox/template-renderer.js') diff --git a/dev/jsconfig.json b/dev/jsconfig.json index a012f32f..518f97ad 100644 --- a/dev/jsconfig.json +++ b/dev/jsconfig.json @@ -12,6 +12,7 @@ "skipLibCheck": false, "baseUrl": ".", "paths": { + "zip.js": ["@zip.js/zip.js"], "anki-templates": ["../types/ext/anki-templates"], "anki-templates-internal": ["../types/ext/anki-templates-internal"], "cache-map": ["../types/ext/cache-map"], diff --git a/ext/action-popup.html b/ext/action-popup.html index b60e7055..5c6bfce4 100644 --- a/ext/action-popup.html +++ b/ext/action-popup.html @@ -12,6 +12,14 @@ + diff --git a/ext/background.html b/ext/background.html index dc88f397..6f9ee5f6 100644 --- a/ext/background.html +++ b/ext/background.html @@ -12,6 +12,14 @@ + diff --git a/ext/info.html b/ext/info.html index cb80053d..9e71ffd4 100644 --- a/ext/info.html +++ b/ext/info.html @@ -13,6 +13,14 @@ + diff --git a/ext/issues.html b/ext/issues.html index 904fbf16..c75683dd 100644 --- a/ext/issues.html +++ b/ext/issues.html @@ -13,6 +13,14 @@ + diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index be68ecf4..44f5a42d 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import * as wanakana from '../../lib/wanakana.js'; +import * as wanakana from 'wanakana'; import {AccessibilityController} from '../accessibility/accessibility-controller.js'; import {AnkiConnect} from '../comm/anki-connect.js'; import {ClipboardMonitor} from '../comm/clipboard-monitor.js'; diff --git a/ext/js/background/offscreen.js b/ext/js/background/offscreen.js index 1b68887b..45345c01 100644 --- a/ext/js/background/offscreen.js +++ b/ext/js/background/offscreen.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import * as wanakana from '../../lib/wanakana.js'; +import * as wanakana from 'wanakana'; import {ClipboardReader} from '../comm/clipboard-reader.js'; import {invokeMessageHandler} from '../core.js'; import {ArrayBufferUtil} from '../data/sandbox/array-buffer-util.js'; diff --git a/ext/js/display/search-display-controller.js b/ext/js/display/search-display-controller.js index a9bf2217..b93757c2 100644 --- a/ext/js/display/search-display-controller.js +++ b/ext/js/display/search-display-controller.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import * as wanakana from '../../lib/wanakana.js'; +import * as wanakana from 'wanakana'; import {ClipboardMonitor} from '../comm/clipboard-monitor.js'; import {EventListenerCollection, invokeMessageHandler} from '../core.js'; import {yomitan} from '../yomitan.js'; diff --git a/ext/js/display/search-main.js b/ext/js/display/search-main.js index c20cc135..c1445e37 100644 --- a/ext/js/display/search-main.js +++ b/ext/js/display/search-main.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import * as wanakana from '../../lib/wanakana.js'; +import * as wanakana from 'wanakana'; import {log} from '../core.js'; import {DocumentFocusController} from '../dom/document-focus-controller.js'; import {HotkeyHandler} from '../input/hotkey-handler.js'; diff --git a/ext/js/dom/simple-dom-parser.js b/ext/js/dom/simple-dom-parser.js index a1f63890..7ee28d51 100644 --- a/ext/js/dom/simple-dom-parser.js +++ b/ext/js/dom/simple-dom-parser.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import * as parse5 from '../../lib/parse5.js'; +import * as parse5 from 'parse5'; /** * @augments import('simple-dom-parser').ISimpleDomParser diff --git a/ext/js/language/dictionary-importer.js b/ext/js/language/dictionary-importer.js index 115e0726..5a4d7257 100644 --- a/ext/js/language/dictionary-importer.js +++ b/ext/js/language/dictionary-importer.js @@ -16,14 +16,14 @@ * along with this program. If not, see . */ -import * as ajvSchemas0 from '../../lib/validate-schemas.js'; +import * as ajvSchemas0 from 'validate-schemas'; import { BlobWriter as BlobWriter0, TextWriter as TextWriter0, Uint8ArrayReader as Uint8ArrayReader0, ZipReader as ZipReader0, configure -} from '../../lib/zip.js'; +} from 'zip.js'; import {stringReverse} from '../core.js'; import {MediaUtil} from '../media/media-util.js'; import {ExtensionError} from '../core/extension-error.js'; diff --git a/ext/js/pages/settings/backup-controller.js b/ext/js/pages/settings/backup-controller.js index 52c5f418..aeff2a97 100644 --- a/ext/js/pages/settings/backup-controller.js +++ b/ext/js/pages/settings/backup-controller.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import {Dexie} from '../../../lib/dexie.js'; +import {Dexie} from 'dexie'; import {isObject, log} from '../../core.js'; import {OptionsUtil} from '../../data/options-util.js'; import {ArrayBufferUtil} from '../../data/sandbox/array-buffer-util.js'; diff --git a/ext/js/pages/settings/popup-preview-frame.js b/ext/js/pages/settings/popup-preview-frame.js index c1a0d706..bb00829f 100644 --- a/ext/js/pages/settings/popup-preview-frame.js +++ b/ext/js/pages/settings/popup-preview-frame.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import * as wanakana from '../../../lib/wanakana.js'; +import * as wanakana from 'wanakana'; import {Frontend} from '../../app/frontend.js'; import {TextSourceRange} from '../../dom/text-source-range.js'; import {yomitan} from '../../yomitan.js'; diff --git a/ext/js/templates/sandbox/anki-template-renderer.js b/ext/js/templates/sandbox/anki-template-renderer.js index 9f4bf6ff..b0dc8223 100644 --- a/ext/js/templates/sandbox/anki-template-renderer.js +++ b/ext/js/templates/sandbox/anki-template-renderer.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import {Handlebars} from '../../../lib/handlebars.js'; +import {Handlebars} from 'handlebars'; import {AnkiNoteDataCreator} from '../../data/sandbox/anki-note-data-creator.js'; import {PronunciationGenerator} from '../../display/sandbox/pronunciation-generator.js'; import {StructuredContentGenerator} from '../../display/sandbox/structured-content-generator.js'; diff --git a/ext/js/templates/sandbox/template-renderer-media-provider.js b/ext/js/templates/sandbox/template-renderer-media-provider.js index d8a0a16d..23f334e1 100644 --- a/ext/js/templates/sandbox/template-renderer-media-provider.js +++ b/ext/js/templates/sandbox/template-renderer-media-provider.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import {Handlebars} from '../../../lib/handlebars.js'; +import {Handlebars} from 'handlebars'; export class TemplateRendererMediaProvider { constructor() { diff --git a/ext/js/templates/sandbox/template-renderer.js b/ext/js/templates/sandbox/template-renderer.js index fe240b5f..d4aebd64 100644 --- a/ext/js/templates/sandbox/template-renderer.js +++ b/ext/js/templates/sandbox/template-renderer.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import {Handlebars} from '../../../lib/handlebars.js'; +import {Handlebars} from 'handlebars'; import {ExtensionError} from '../../core/extension-error.js'; export class TemplateRenderer { diff --git a/ext/legal.html b/ext/legal.html index 94912c7e..b853f3e8 100644 --- a/ext/legal.html +++ b/ext/legal.html @@ -14,6 +14,14 @@ + diff --git a/ext/offscreen.html b/ext/offscreen.html index afb7eb44..cfab53ee 100644 --- a/ext/offscreen.html +++ b/ext/offscreen.html @@ -12,6 +12,14 @@ + diff --git a/ext/permissions.html b/ext/permissions.html index 61b0d363..7baff14e 100644 --- a/ext/permissions.html +++ b/ext/permissions.html @@ -14,6 +14,14 @@ + diff --git a/ext/popup-preview.html b/ext/popup-preview.html index 15810242..7bd54470 100644 --- a/ext/popup-preview.html +++ b/ext/popup-preview.html @@ -13,6 +13,14 @@ + diff --git a/ext/popup.html b/ext/popup.html index 30e8a8c0..6bc8d690 100644 --- a/ext/popup.html +++ b/ext/popup.html @@ -15,6 +15,14 @@ + diff --git a/ext/search.html b/ext/search.html index 8c595cc4..377a966a 100644 --- a/ext/search.html +++ b/ext/search.html @@ -16,6 +16,14 @@ + diff --git a/ext/settings.html b/ext/settings.html index 346cc1d7..276a7222 100644 --- a/ext/settings.html +++ b/ext/settings.html @@ -14,6 +14,14 @@ + diff --git a/ext/template-renderer.html b/ext/template-renderer.html index 116f1a0c..d1747e99 100644 --- a/ext/template-renderer.html +++ b/ext/template-renderer.html @@ -11,6 +11,14 @@ + diff --git a/ext/welcome.html b/ext/welcome.html index 40639881..355bbc5f 100644 --- a/ext/welcome.html +++ b/ext/welcome.html @@ -13,6 +13,14 @@ + diff --git a/jsconfig.json b/jsconfig.json index ace0c2aa..4f316174 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -12,6 +12,7 @@ "skipLibCheck": false, "baseUrl": ".", "paths": { + "zip.js": ["@zip.js/zip.js"], "*": ["./types/ext/*"] }, "types": [ @@ -29,7 +30,7 @@ "include": [ "ext/**/*.js", "types/ext/**/*.ts", - "types/other/web-set-timeout.d.ts" + "types/other/globals.d.ts" ], "exclude": [ "node_modules", diff --git a/test/japanese-util.test.js b/test/japanese-util.test.js index 47da4ccb..ae5b1a16 100644 --- a/test/japanese-util.test.js +++ b/test/japanese-util.test.js @@ -16,10 +16,10 @@ * along with this program. If not, see . */ +import * as wanakana from 'wanakana'; import {expect, test} from 'vitest'; import {TextSourceMap} from '../ext/js/general/text-source-map.js'; import {JapaneseUtil} from '../ext/js/language/sandbox/japanese-util.js'; -import * as wanakana from '../ext/lib/wanakana.js'; const jp = new JapaneseUtil(wanakana); diff --git a/test/jsconfig.json b/test/jsconfig.json index b025918c..261ec345 100644 --- a/test/jsconfig.json +++ b/test/jsconfig.json @@ -12,6 +12,7 @@ "skipLibCheck": false, "baseUrl": ".", "paths": { + "zip.js": ["@zip.js/zip.js"], "*": ["../types/ext/*"], "dev/*": ["../types/dev/*"], "test/*": ["../types/test/*"] -- cgit v1.2.3 From 58ae2ab871591eea82895b1ab2a18753521eab1f Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 27 Nov 2023 22:07:28 -0500 Subject: Revert "Use import map" --- dev/jsconfig.json | 1 - ext/action-popup.html | 8 -------- ext/background.html | 8 -------- ext/info.html | 8 -------- ext/issues.html | 8 -------- ext/js/background/backend.js | 2 +- ext/js/background/offscreen.js | 2 +- ext/js/display/search-display-controller.js | 2 +- ext/js/display/search-main.js | 2 +- ext/js/dom/simple-dom-parser.js | 2 +- ext/js/language/dictionary-importer.js | 4 ++-- ext/js/pages/settings/backup-controller.js | 2 +- ext/js/pages/settings/popup-preview-frame.js | 2 +- ext/js/templates/sandbox/anki-template-renderer.js | 2 +- ext/js/templates/sandbox/template-renderer-media-provider.js | 2 +- ext/js/templates/sandbox/template-renderer.js | 2 +- ext/legal.html | 8 -------- ext/offscreen.html | 8 -------- ext/permissions.html | 8 -------- ext/popup-preview.html | 8 -------- ext/popup.html | 8 -------- ext/search.html | 8 -------- ext/settings.html | 8 -------- ext/template-renderer.html | 8 -------- ext/welcome.html | 8 -------- jsconfig.json | 1 - test/japanese-util.test.js | 2 +- test/jsconfig.json | 1 - 28 files changed, 13 insertions(+), 120 deletions(-) (limited to 'ext/js/templates/sandbox/template-renderer.js') diff --git a/dev/jsconfig.json b/dev/jsconfig.json index d4efe694..5b1c450c 100644 --- a/dev/jsconfig.json +++ b/dev/jsconfig.json @@ -12,7 +12,6 @@ "skipLibCheck": false, "baseUrl": ".", "paths": { - "zip.js": ["@zip.js/zip.js"], "anki-templates": ["../types/ext/anki-templates"], "anki-templates-internal": ["../types/ext/anki-templates-internal"], "cache-map": ["../types/ext/cache-map"], diff --git a/ext/action-popup.html b/ext/action-popup.html index 5c6bfce4..b60e7055 100644 --- a/ext/action-popup.html +++ b/ext/action-popup.html @@ -12,14 +12,6 @@ - diff --git a/ext/background.html b/ext/background.html index 6f9ee5f6..dc88f397 100644 --- a/ext/background.html +++ b/ext/background.html @@ -12,14 +12,6 @@ - diff --git a/ext/info.html b/ext/info.html index 9e71ffd4..cb80053d 100644 --- a/ext/info.html +++ b/ext/info.html @@ -13,14 +13,6 @@ - diff --git a/ext/issues.html b/ext/issues.html index c75683dd..904fbf16 100644 --- a/ext/issues.html +++ b/ext/issues.html @@ -13,14 +13,6 @@ - diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index f1a47e7f..3eefed53 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import * as wanakana from 'wanakana'; +import * as wanakana from '../../lib/wanakana.js'; import {AccessibilityController} from '../accessibility/accessibility-controller.js'; import {AnkiConnect} from '../comm/anki-connect.js'; import {ClipboardMonitor} from '../comm/clipboard-monitor.js'; diff --git a/ext/js/background/offscreen.js b/ext/js/background/offscreen.js index 8da661ad..4b57514d 100644 --- a/ext/js/background/offscreen.js +++ b/ext/js/background/offscreen.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import * as wanakana from 'wanakana'; +import * as wanakana from '../../lib/wanakana.js'; import {ClipboardReader} from '../comm/clipboard-reader.js'; import {invokeMessageHandler} from '../core.js'; import {ArrayBufferUtil} from '../data/sandbox/array-buffer-util.js'; diff --git a/ext/js/display/search-display-controller.js b/ext/js/display/search-display-controller.js index 98a4666b..2778c4cd 100644 --- a/ext/js/display/search-display-controller.js +++ b/ext/js/display/search-display-controller.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import * as wanakana from 'wanakana'; +import * as wanakana from '../../lib/wanakana.js'; import {ClipboardMonitor} from '../comm/clipboard-monitor.js'; import {EventListenerCollection, invokeMessageHandler} from '../core.js'; import {yomitan} from '../yomitan.js'; diff --git a/ext/js/display/search-main.js b/ext/js/display/search-main.js index c1445e37..c20cc135 100644 --- a/ext/js/display/search-main.js +++ b/ext/js/display/search-main.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import * as wanakana from 'wanakana'; +import * as wanakana from '../../lib/wanakana.js'; import {log} from '../core.js'; import {DocumentFocusController} from '../dom/document-focus-controller.js'; import {HotkeyHandler} from '../input/hotkey-handler.js'; diff --git a/ext/js/dom/simple-dom-parser.js b/ext/js/dom/simple-dom-parser.js index 7ee28d51..a1f63890 100644 --- a/ext/js/dom/simple-dom-parser.js +++ b/ext/js/dom/simple-dom-parser.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import * as parse5 from 'parse5'; +import * as parse5 from '../../lib/parse5.js'; /** * @augments import('simple-dom-parser').ISimpleDomParser diff --git a/ext/js/language/dictionary-importer.js b/ext/js/language/dictionary-importer.js index 5a4d7257..115e0726 100644 --- a/ext/js/language/dictionary-importer.js +++ b/ext/js/language/dictionary-importer.js @@ -16,14 +16,14 @@ * along with this program. If not, see . */ -import * as ajvSchemas0 from 'validate-schemas'; +import * as ajvSchemas0 from '../../lib/validate-schemas.js'; import { BlobWriter as BlobWriter0, TextWriter as TextWriter0, Uint8ArrayReader as Uint8ArrayReader0, ZipReader as ZipReader0, configure -} from 'zip.js'; +} from '../../lib/zip.js'; import {stringReverse} from '../core.js'; import {MediaUtil} from '../media/media-util.js'; import {ExtensionError} from '../core/extension-error.js'; diff --git a/ext/js/pages/settings/backup-controller.js b/ext/js/pages/settings/backup-controller.js index aeff2a97..52c5f418 100644 --- a/ext/js/pages/settings/backup-controller.js +++ b/ext/js/pages/settings/backup-controller.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import {Dexie} from 'dexie'; +import {Dexie} from '../../../lib/dexie.js'; import {isObject, log} from '../../core.js'; import {OptionsUtil} from '../../data/options-util.js'; import {ArrayBufferUtil} from '../../data/sandbox/array-buffer-util.js'; diff --git a/ext/js/pages/settings/popup-preview-frame.js b/ext/js/pages/settings/popup-preview-frame.js index dab21f4d..60d264fa 100644 --- a/ext/js/pages/settings/popup-preview-frame.js +++ b/ext/js/pages/settings/popup-preview-frame.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import * as wanakana from 'wanakana'; +import * as wanakana from '../../../lib/wanakana.js'; import {Frontend} from '../../app/frontend.js'; import {TextSourceRange} from '../../dom/text-source-range.js'; import {yomitan} from '../../yomitan.js'; diff --git a/ext/js/templates/sandbox/anki-template-renderer.js b/ext/js/templates/sandbox/anki-template-renderer.js index b0dc8223..9f4bf6ff 100644 --- a/ext/js/templates/sandbox/anki-template-renderer.js +++ b/ext/js/templates/sandbox/anki-template-renderer.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import {Handlebars} from 'handlebars'; +import {Handlebars} from '../../../lib/handlebars.js'; import {AnkiNoteDataCreator} from '../../data/sandbox/anki-note-data-creator.js'; import {PronunciationGenerator} from '../../display/sandbox/pronunciation-generator.js'; import {StructuredContentGenerator} from '../../display/sandbox/structured-content-generator.js'; diff --git a/ext/js/templates/sandbox/template-renderer-media-provider.js b/ext/js/templates/sandbox/template-renderer-media-provider.js index 23f334e1..d8a0a16d 100644 --- a/ext/js/templates/sandbox/template-renderer-media-provider.js +++ b/ext/js/templates/sandbox/template-renderer-media-provider.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import {Handlebars} from 'handlebars'; +import {Handlebars} from '../../../lib/handlebars.js'; export class TemplateRendererMediaProvider { constructor() { diff --git a/ext/js/templates/sandbox/template-renderer.js b/ext/js/templates/sandbox/template-renderer.js index d4aebd64..fe240b5f 100644 --- a/ext/js/templates/sandbox/template-renderer.js +++ b/ext/js/templates/sandbox/template-renderer.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import {Handlebars} from 'handlebars'; +import {Handlebars} from '../../../lib/handlebars.js'; import {ExtensionError} from '../../core/extension-error.js'; export class TemplateRenderer { diff --git a/ext/legal.html b/ext/legal.html index b853f3e8..94912c7e 100644 --- a/ext/legal.html +++ b/ext/legal.html @@ -14,14 +14,6 @@ - diff --git a/ext/offscreen.html b/ext/offscreen.html index cfab53ee..afb7eb44 100644 --- a/ext/offscreen.html +++ b/ext/offscreen.html @@ -12,14 +12,6 @@ - diff --git a/ext/permissions.html b/ext/permissions.html index 7baff14e..61b0d363 100644 --- a/ext/permissions.html +++ b/ext/permissions.html @@ -14,14 +14,6 @@ - diff --git a/ext/popup-preview.html b/ext/popup-preview.html index 7bd54470..15810242 100644 --- a/ext/popup-preview.html +++ b/ext/popup-preview.html @@ -13,14 +13,6 @@ - diff --git a/ext/popup.html b/ext/popup.html index 6bc8d690..30e8a8c0 100644 --- a/ext/popup.html +++ b/ext/popup.html @@ -15,14 +15,6 @@ - diff --git a/ext/search.html b/ext/search.html index 377a966a..8c595cc4 100644 --- a/ext/search.html +++ b/ext/search.html @@ -16,14 +16,6 @@ - diff --git a/ext/settings.html b/ext/settings.html index 276a7222..346cc1d7 100644 --- a/ext/settings.html +++ b/ext/settings.html @@ -14,14 +14,6 @@ - diff --git a/ext/template-renderer.html b/ext/template-renderer.html index d1747e99..116f1a0c 100644 --- a/ext/template-renderer.html +++ b/ext/template-renderer.html @@ -11,14 +11,6 @@ - diff --git a/ext/welcome.html b/ext/welcome.html index 355bbc5f..40639881 100644 --- a/ext/welcome.html +++ b/ext/welcome.html @@ -13,14 +13,6 @@ - diff --git a/jsconfig.json b/jsconfig.json index 4f316174..0f780ead 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -12,7 +12,6 @@ "skipLibCheck": false, "baseUrl": ".", "paths": { - "zip.js": ["@zip.js/zip.js"], "*": ["./types/ext/*"] }, "types": [ diff --git a/test/japanese-util.test.js b/test/japanese-util.test.js index ae5b1a16..47da4ccb 100644 --- a/test/japanese-util.test.js +++ b/test/japanese-util.test.js @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -import * as wanakana from 'wanakana'; import {expect, test} from 'vitest'; import {TextSourceMap} from '../ext/js/general/text-source-map.js'; import {JapaneseUtil} from '../ext/js/language/sandbox/japanese-util.js'; +import * as wanakana from '../ext/lib/wanakana.js'; const jp = new JapaneseUtil(wanakana); diff --git a/test/jsconfig.json b/test/jsconfig.json index 934aab81..2461fda9 100644 --- a/test/jsconfig.json +++ b/test/jsconfig.json @@ -12,7 +12,6 @@ "skipLibCheck": false, "baseUrl": ".", "paths": { - "zip.js": ["@zip.js/zip.js"], "*": ["../types/ext/*"], "dev/*": ["../types/dev/*"], "test/*": ["../types/test/*"] -- cgit v1.2.3 From ec67de5c0c4abc11232d3f3a8a8e9bb2fe045daa Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 27 Nov 2023 23:05:37 -0500 Subject: Update library types --- ext/js/display/search-main.js | 4 +--- ext/js/language/sandbox/japanese-util.js | 4 ++-- ext/js/templates/sandbox/template-renderer.js | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) (limited to 'ext/js/templates/sandbox/template-renderer.js') diff --git a/ext/js/display/search-main.js b/ext/js/display/search-main.js index c20cc135..5eee08d1 100644 --- a/ext/js/display/search-main.js +++ b/ext/js/display/search-main.js @@ -44,9 +44,7 @@ import {SearchPersistentStateController} from './search-persistent-state-control const {tabId, frameId} = await yomitan.api.frameInformationGet(); - /** @type {import('wanakana')} */ - const wanakanaLib = wanakana; - const japaneseUtil = new JapaneseUtil(wanakanaLib); + const japaneseUtil = new JapaneseUtil(wanakana); const hotkeyHandler = new HotkeyHandler(); hotkeyHandler.prepare(); diff --git a/ext/js/language/sandbox/japanese-util.js b/ext/js/language/sandbox/japanese-util.js index 4c9c46bd..6f4fc8e0 100644 --- a/ext/js/language/sandbox/japanese-util.js +++ b/ext/js/language/sandbox/japanese-util.js @@ -233,11 +233,11 @@ function getProlongedHiragana(previousCharacter) { export class JapaneseUtil { /** - * @param {?import('wanakana')} wanakana + * @param {?import('wanakana')|import('../../../lib/wanakana.js')} wanakana */ constructor(wanakana=null) { /** @type {?import('wanakana')} */ - this._wanakana = wanakana; + this._wanakana = /** @type {import('wanakana')} */ (wanakana); } // Character code testing functions diff --git a/ext/js/templates/sandbox/template-renderer.js b/ext/js/templates/sandbox/template-renderer.js index fe240b5f..239240b6 100644 --- a/ext/js/templates/sandbox/template-renderer.js +++ b/ext/js/templates/sandbox/template-renderer.js @@ -197,7 +197,7 @@ export class TemplateRenderer { */ function wrapper(...args) { const argCountM1 = Math.max(0, args.length - 1); - const options = /** @type {Handlebars.HelperOptions} */ (args[argCountM1]); + const options = /** @type {import('handlebars').HelperOptions} */ (args[argCountM1]); args.length = argCountM1; return helper(args, this, options); } -- cgit v1.2.3