about summary refs log tree commit diff stats
path: root/src/reader.ts
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2026-06-26 23:47:31 +0300
committerAndrew Dolgov <fox@fakecake.org>2026-06-26 23:47:31 +0300
commit6e5eca4961d293c01ea4f01ff5323dc137daad8f (patch)
tree305a06b0c81c3b86e682f6db20d77d6a9a2bae0a /src/reader.ts
parent38cf35c2c24d2fb3bcc0ffc5e2ff6551d72e6eb8 (diff)
downloadthe-epube-6e5eca4961d293c01ea4f01ff5323dc137daad8f.tar.gz
the-epube-6e5eca4961d293c01ea4f01ff5323dc137daad8f.tar.xz
more ts migration stuff
Diffstat (limited to 'src/reader.ts')
-rw-r--r--src/reader.ts150
1 files changed, 2 insertions, 148 deletions
diff --git a/src/reader.ts b/src/reader.ts
index 8b7cdb3..705aab0 100644
--- a/src/reader.ts
+++ b/src/reader.ts
@@ -43,7 +43,7 @@ class ReaderClass extends AppCommon {
         startX: 0,
         startY: 0,
         startTime: 0,
-        direction: null,
+        direction: "",
     };
 
     /** @type {SwipeConfig} */
@@ -56,7 +56,6 @@ class ReaderClass extends AppCommon {
     constructor() {
         super();
 
-        // @ts-expect-error TS(2304): Cannot find name 'ePub'.
         this.book = new ePub.Book();
         this.loader = new ReaderLoader();
     }
@@ -69,7 +68,6 @@ class ReaderClass extends AppCommon {
             startX: touch.clientX,
             startY: touch.clientY,
             startTime: Date.now(),
-            // @ts-expect-error TS(2322): Type 'string' is not assignable to type 'null'.
             direction: evt.target.id == "right" ? 'left' : 'right',
         };
     }
@@ -120,47 +118,38 @@ class ReaderClass extends AppCommon {
 
         Http.setCsrfToken(this.csrf_token);
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $(document).on("keyup", (e: any) => {
             this.hotkeyHandler(e);
         });
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $(".close_book").on("click", () => {
             this.close();
         });
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $("#left").on("mouseup", () => {
             this.prevPage();
         });
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $(".search_input").on("change", () => {
             this.search();
         });
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $(".prev_location_btn").on("click", (evt: any) => {
             this.openPrevious(evt.target);
         });
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $("#right").on("mouseup", () => {
             this.nextPage();
         });
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $("#left, #right").on("touchstart", (evt: any) => {
             this.onTouchStart(evt);
         });
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $("#left, #right").on("touchmove", (evt: any) => {
             this.onTouchMove(evt);
         });
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $("#left, #right").on("touchend", (evt: any) => {
             this.onTouchEnd(evt);
         });
@@ -174,7 +163,6 @@ class ReaderClass extends AppCommon {
         } else {
             this.applyTheme();
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".loading-message").text('Resource loader failed to initialize.');
         }
     }
@@ -214,12 +202,10 @@ class ReaderClass extends AppCommon {
         if (typeof EpubeApp != "undefined") {
             EpubeApp.setPage("PAGE_READER");
         } else {
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(window).on('online', () => {
                 this.onOfflineModeChanged(false);
             });
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(window).on('offline', () => {
                 this.onOfflineModeChanged(true);
             });
@@ -227,7 +213,6 @@ class ReaderClass extends AppCommon {
 
         this.applyTheme();
 
-        // @ts-expect-error TS(2554): Expected 1 arguments, but got 0.
         const bookinfo = await localforage.getItem(this.cacheId());
 
         if (!bookinfo) {
@@ -249,7 +234,6 @@ class ReaderClass extends AppCommon {
                     await localforage.setItem(this.cacheId('cover'), cover.blob);
                 }
 
-                // @ts-expect-error TS(2554): Expected 1 arguments, but got 0.
                 await localforage.setItem(this.cacheId(), info);
 
                 console.log('bookinfo saved');
@@ -260,7 +244,6 @@ class ReaderClass extends AppCommon {
 
                 console.error(err);
 
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 $(".loading-message").html(`Unable to load book info.<br/><small>${this.escapeHtml((String)((err as any).responseText))}</small>`);
                 return;
             }
@@ -273,7 +256,6 @@ class ReaderClass extends AppCommon {
         if (!book_data) {
             console.log("local data not found, loading from network...");
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".loading-message").html("Downloading book…");
 
             /** @type {HttpBlobResponse} */
@@ -286,7 +268,6 @@ class ReaderClass extends AppCommon {
                 console.log('saved local data for book');
 
             } else {
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 $(".loading-message").html(`Unable to download book: ${book_resp.status}`);
                 return;
             }
@@ -300,14 +281,12 @@ class ReaderClass extends AppCommon {
                 _reader.openBookData(this.result);
             } catch (e) {
                 console.error(e);
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 $(".loading-message").html("Unable to load book blob: " + e);
             }
         };
 
         fileReader.onerror = (e) => {
             console.log('filereader error', e);
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".loading-message").html("Unable to open book.<br/><small>" + this.escapeHtml(String(e)) + "</small>");
         };
 
@@ -321,7 +300,6 @@ class ReaderClass extends AppCommon {
             await this.book.open(book_data);
         } catch (e) {
             console.error(e);
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".loading-message").html(`Unable to open book.<br/><small>${this.escapeHtml(e instanceof Error ? e.message : String(e))}</small>`);
             return;
         }
@@ -340,7 +318,6 @@ class ReaderClass extends AppCommon {
             minSpreadWidth: 961
         });
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $(".location").on('click', async () => {
             const current = Math.floor(rendition.currentLocation().start.location / LOCATION_DIVISOR);
             const total = Math.floor(this.book.locations.length() / LOCATION_DIVISOR);
@@ -355,9 +332,7 @@ class ReaderClass extends AppCommon {
 
         if (enable_hyphens) {
             /* global hyphenationPatternsEnUs, hyphenationPatternsRu, createHyphenator */
-// @ts-expect-error TS(2304): Cannot find name 'createHyphenator'.
 (this.hyphenate as any).en = createHyphenator(hyphenationPatternsEnUs, { html: true });
-            // @ts-expect-error TS(2304): Cannot find name 'createHyphenator'.
             (this.hyphenate as any).ru = createHyphenator(hyphenationPatternsRu, { html: true });
         }
 
@@ -377,7 +352,6 @@ class ReaderClass extends AppCommon {
      * @param {ePub.Book} book
      */
     async showBookInfo(book: any) {
-        // @ts-expect-error TS(2554): Expected 1 arguments, but got 0.
         const bookinfo = await localforage.getItem(this.cacheId());
 
         let title;
@@ -395,7 +369,6 @@ class ReaderClass extends AppCommon {
 
         document.title = title + " – " + author + " – The Epube";
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $(".title")
             .text(title)
             .attr("title", title + " – " + author);
@@ -426,7 +399,6 @@ class ReaderClass extends AppCommon {
         if (this.isOnline()) {
             console.log("downloading locations...");
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".loading-message").html("Downloading locations…");
 
             try {
@@ -459,7 +431,6 @@ class ReaderClass extends AppCommon {
             }
         }
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $(".loading-message").html("Preparing locations…");
 
         let generate_queue_max = 0;
@@ -472,7 +443,6 @@ class ReaderClass extends AppCommon {
             if (generate_queue_max > 0) {
                 const queue_pct = Math.round((1 - queue.length() / generate_queue_max) * 100); // TODO un-wtf
 
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 $(".loading-message").html(`Preparing locations (${queue_pct}%)…`);
             }
         });
@@ -506,7 +476,6 @@ class ReaderClass extends AppCommon {
                 this.blockLastReadUpdate();
 
                 if (href.indexOf("://") == -1) {
-                    // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                     $(".prev_location_btn")
                         .attr("data-location-cfi", rendition.currentLocation().start.cfi)
                         .show();
@@ -526,7 +495,6 @@ class ReaderClass extends AppCommon {
                     console.log('selected', cfiRange, selection);
 
                     if (selection.match(/^[\w­]+$/)) {
-                        // @ts-expect-error TS(2554): Expected 3 arguments, but got 2.
                         this.lookupWord(selection, () => {
                             if (typeof EpubeApp != "undefined")
                                 EpubeApp.showActionBar(false);
@@ -544,31 +512,24 @@ class ReaderClass extends AppCommon {
             const match = window.location.href.match(/^.*\//);
             const base_url = match ? match[0] : window.location.href;
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(contents.document.head)
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 .append($("<style type='text/css'>")
                     .text(this.generateFontsCss(base_url)));
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(contents.document.head)
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 .append($("<style type='text/css'>")
                     .text(this.loader._res_data[base_url + 'dist/reader_iframe.min.css']));
 
             const theme = (await localforage.getItem("epube.theme")) || 'default';
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(contents.document).find("body")
                 .attr("class", typeof EpubeApp != "undefined" ? "is-epube-app" : "")
                 .addClass("theme-" + theme);
 
             console.log('contents', contents);
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(contents.window).on("click tap", (evt: any) => {
                 if (evt.button == 0) {
-                    // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                     if ($(".modal").is(":visible"))
                         return;
 
@@ -579,7 +540,6 @@ class ReaderClass extends AppCommon {
                 }
             });
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(contents.window).on("wheel", async (evt: any) => {
                 if (await localforage.getItem("epube.enable-wheel")) {
                     if ((evt.originalEvent?.deltaY ?? 0) > 0) {
@@ -611,7 +571,6 @@ class ReaderClass extends AppCommon {
         if (location.start) {
             const cur_href = book.canonical(location.start.href);
             let toc_entry = {};
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $.each(this.flattenToc(book), function (i: any, r: any) {
                 if (book.spine.get(r.href).canonical == cur_href) {
                     toc_entry = r;
@@ -619,7 +578,6 @@ class ReaderClass extends AppCommon {
                 }
             });
             if (toc_entry && (toc_entry as any).label)
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 $(".chapter_title").text(this.escapeHtml((toc_entry as any).label.trim()) + " | ");
             this.generateTocBar(book, this.flattenToc(book));
         }
@@ -642,40 +600,34 @@ class ReaderClass extends AppCommon {
     }
 
     initModals() {
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $('#settings-modal').on('shown.bs.modal', async () => {
 
             const last_read = await localforage.getItem(this.cacheId("lastread"));
 
             if (last_read && last_read.cfi) {
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 $(".lastread_input")
                     .val(last_read.page + '%')
                     .attr('title', `[local] ${last_read.cfi}`);
             }
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".clear_last_read")
                 .off("click")
                 .on("click", () => {
                     this.clearLastRead();
                 });
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".open_last_read")
                 .off("click")
                 .on("click", () => {
                     this.openLastRead();
                 });
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".mark_as_read")
                 .off("click")
                 .on("click", () => {
                     this.markAsRead();
                 });
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".reset_locations")
                 .off("click")
                 .on("click", () => {
@@ -686,7 +638,6 @@ class ReaderClass extends AppCommon {
                 try {
                     /** @type {HttpResponse} */
                     const lrResp = await Http.get("backend.php", { op: "getlastread", id: this.urlParam("id") });
-                    // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                     $(".lastread_input")
                         .val(lrResp.data.page + '%')
                         .attr('title', `[remote] ${lrResp.data.cfi}`);
@@ -695,35 +646,30 @@ class ReaderClass extends AppCommon {
                 }
             }
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".font_family")
                 .off("change")
                 .on("change", (evt: any) => {
                     this.onFontChanged(evt.target);
                 });
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".font_size")
                 .off("change")
                 .on("change", (evt: any) => {
                     this.onTextSizeChanged(evt.target);
                 });
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".line_height")
                 .off("change")
                 .on("change", (evt: any) => {
                     this.onLineHeightChanged(evt.target);
                 });
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".theme_name")
                 .off("change")
                 .on("change", (evt: any) => {
                     this.onThemeChanged(evt.target);
                 });
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".enable_hyphens_checkbox")
                 .attr("checked", await localforage.getItem("epube.enable-hyphens"))
                 .off("click")
@@ -735,7 +681,6 @@ class ReaderClass extends AppCommon {
                     }
                 });
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".enable_wheel_checkbox")
                 .attr("checked", await localforage.getItem("epube.enable-wheel"))
                 .off("click")
@@ -744,10 +689,8 @@ class ReaderClass extends AppCommon {
                 });
 
             if (typeof EpubeApp != "undefined") {
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 $(".keep_ui_checkbox").parent().parent().hide();
             } else {
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 $(".keep_ui_checkbox")
                 .attr("checked", await localforage.getItem("epube.keep-ui-visible"))
                 .off("click")
@@ -756,32 +699,25 @@ class ReaderClass extends AppCommon {
                 });
             }
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".last-mod-timestamp").html(`${this.cosmeticVersion} &mdash; ${this.cacheVersion}
                 (${this.isOnline() ? `<span class='text-success'>Online</span>` : `<span class='text-danger'>Offline</span>`})
                 `);
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".font_family").val((await localforage.getItem("epube.fontFamily")) || DEFAULT_FONT_FAMILY);
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".theme_name").val((await localforage.getItem("epube.theme")) || 'default');
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             const zoom = $(".font_size").html("");
 
             for (let i = 10; i <= 32; i++) {
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 const opt = $("<option>").val(i).html(i + " px");
                 zoom.append(opt);
             }
 
             zoom.val((await localforage.getItem("epube.fontSize")) || DEFAULT_FONT_SIZE);
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             const line_height = $(".line_height").html("");
 
             for (let i = 100; i <= 220; i += 10) {
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 const opt = $("<option>").val(i).html(i + "%");
                 line_height.append(opt);
             }
@@ -790,9 +726,7 @@ class ReaderClass extends AppCommon {
 
         });
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $('#dict-modal').on('shown.bs.modal', () => {
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".dict_query")
                 .off("keyup")
                 .on("keyup", (evt: any) => {
@@ -802,16 +736,12 @@ class ReaderClass extends AppCommon {
                     }
                 });
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".dict_result").scrollTop(0);
         });
 
         // TODO: make configurable
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $(".dict_search_btn").on("click", function() {
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $("#dict-modal").modal('hide');
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             window.open("https://duckduckgo.com/?q=" + $(".dict_query").val());
         });
 
@@ -852,13 +782,10 @@ class ReaderClass extends AppCommon {
 
             if (row.subitems) {
 
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 const sublist = $("<ul class='toc_sublist list-unstyled'>");
 
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 $.each(row.subitems, function(i: any, row: any) {
 
-                    // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                     const a = $("<a>")
                         .attr('href', '#')
                         .html("<b class='pull-right'>" + toc_loc_msg(row.href) + "</b>" + _reader.escapeHtml(row.label))
@@ -867,7 +794,6 @@ class ReaderClass extends AppCommon {
                             book.rendition.display(a.attr('data-href'));
                         });
 
-                    // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                     sublist.append($("<li>").append(a));
 
                     process_toc_sublist(row, sublist, nest + 1);
@@ -878,21 +804,17 @@ class ReaderClass extends AppCommon {
             }
         }
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $('#toc-modal').on('shown.bs.modal', function() {
 
             const toc = book.navigation.toc;
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             const list = $(".toc_list");
             list.html("");
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $.each(toc, function(i: any, row: any) {
 
                 // if anything fails here the toc entry is likely useless anyway (i.e. no cfi)
                 try {
-                    // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                     const a = $("<a>")
                         .attr('href', '#')
                         .html("<b class='pull-right'>" + toc_loc_msg(row.href) + "</b>" + _reader.escapeHtml(row.label))
@@ -901,7 +823,6 @@ class ReaderClass extends AppCommon {
                             book.rendition.display(a.attr('data-href'));
                         });
 
-                    // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                     list.append($("<li>").append(a));
 
                     process_toc_sublist(row, list, 0);
@@ -916,10 +837,8 @@ class ReaderClass extends AppCommon {
 
                 list.html("");
 
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 $.each(book.spine.items, function (i: any, row: any) {
 
-                    // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                     const a = $("<a>")
                         .attr('href', '#')
                         .attr('title', row.url)
@@ -929,7 +848,6 @@ class ReaderClass extends AppCommon {
                             book.rendition.display(a.attr('data-href'));
                         });
 
-                    // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                     list.append($("<li>").append(a));
 
                 });
@@ -943,21 +861,16 @@ class ReaderClass extends AppCommon {
      * @param {Document} doc
      */
     cleanupEmbeddedStyles(doc: any) {
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $(doc).find("p")
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 .filter((i: any, e: any) => (($(e).text().length >= MIN_LENGTH_TO_JUSTIFY) ? e : null))
                     .css("text-align", "justify");
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $(doc).find("html")
                 .attr("class", "");
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $(doc).find("pre")
                 .css("white-space", "pre-wrap");
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $(doc).find("a, p, span, em, i, strong, b, body, header, section, div, big, small, table, tr, td, th, ul, ol, li")
                 .attr("class", "")
                 .css("font-family", "inherit")
@@ -971,7 +884,6 @@ class ReaderClass extends AppCommon {
                 .attr("height", "");
 
         // same as above except for allowed font-size
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $(doc).find("h1, h2, h3, h4, h5")
             .attr("class", "")
             .css("font-family", "inherit")
@@ -981,9 +893,7 @@ class ReaderClass extends AppCommon {
             .css("background-color", "");
 
         if (typeof (this.hyphenate as any).en != "undefined") {
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(doc).find('p, div').each((i: any, elem: any) => {
-    // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
     const p = $(elem);
     p.html((this.hyphenate as any).en(p.html()));
     p.html((this.hyphenate as any).ru(p.html()));
@@ -1178,7 +1088,6 @@ class ReaderClass extends AppCommon {
         if (nest == 3) return false;
 
         if (entry.subitems) {
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $.each(entry.subitems, (i: any, r: any) => {
                 r._nest = nest;
 
@@ -1201,7 +1110,6 @@ class ReaderClass extends AppCommon {
         } else {
             let rv: any = [];
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $.each(book.navigation.toc, (i: any, r: any) => {
                 r._nest = 0;
 
@@ -1220,11 +1128,9 @@ class ReaderClass extends AppCommon {
      * @param { any[] } toc
      */
     generateTocBar(book: any, toc: any) {
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $(".spacer")
             .html("");
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $.each(toc, function(i: any, te: any) {
             try {
                 const cfiBase = book.spine.get(te.href).cfiBase;
@@ -1235,9 +1141,7 @@ class ReaderClass extends AppCommon {
                 if (loc) {
                     const pct = Math.round(book.locations.percentageFromCfi(loc) * 100);
 
-                    // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                     $(".spacer").append(
-                        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                         $("<div class='toc-bar-entry'>")
                             .attr('data-nest-level', te._nest)
                             .css('left', pct + '%')
@@ -1252,7 +1156,6 @@ class ReaderClass extends AppCommon {
             }
         });
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $(".spacer").append($("<div class='toc-bar-entry current-position'>"));
 
         this.updateTocBarPosition(book, book.rendition.currentLocation())
@@ -1265,7 +1168,6 @@ class ReaderClass extends AppCommon {
     updateTocBarPosition(book: any, location: any) {
         const cur_pct = Math.round(location.start.location / book.locations.length() * 100);
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $(".toc-bar-entry.current-position")
                 .css('left', cur_pct + '%');
     }
@@ -1303,7 +1205,6 @@ class ReaderClass extends AppCommon {
 
         console.log('setting main UI theme', theme);
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $("body")
             .attr("class", typeof EpubeApp != "undefined" ? "is-epube-app" : "")
             .addClass("epube-reader theme-" + theme)
@@ -1347,7 +1248,6 @@ class ReaderClass extends AppCommon {
                 rendition.css("line-height", lineHeight);
                 rendition.css("text-align", 'justify');
 
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 $(rendition.document).find("body")
                     .attr("class", typeof EpubeApp != "undefined" ? "is-epube-app" : "")
                     .addClass("theme-" + theme);
@@ -1361,7 +1261,6 @@ class ReaderClass extends AppCommon {
         try {
             //console.log('K3:' + e.which, e);
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             if ($(".modal").is(":visible"))
                 return;
 
@@ -1388,7 +1287,6 @@ class ReaderClass extends AppCommon {
     }
 
     resizeSideColumns() {
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         let width = $("#reader").position().left;
 
         if (this.book && this.book.rendition)
@@ -1401,13 +1299,11 @@ class ReaderClass extends AppCommon {
 
         console.log(`resizing side columns to ${width} px`);
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $("#left, #right").width(width);
     }
 
     async markAsRead() {
         if (confirm("Mark book as read?")) {
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $("#settings-modal").modal('hide');
 
             const total = 100;
@@ -1417,7 +1313,6 @@ class ReaderClass extends AppCommon {
             if (this.isOnline()) {
                 /** @type {HttpResponse} */
                 const data = await Http.post("backend.php", { op: "storelastread", page: String(total), cfi: lastCfi, id: this.urlParam("id"), timestamp: String(lastread_timestamp) });
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 $(".lastread_input").val(data.data.page + '%');
             }
 
@@ -1453,7 +1348,7 @@ class ReaderClass extends AppCommon {
     }
 
     /** @param {string} [suffix] */
-    cacheId(suffix: any) {
+    cacheId(suffix: string = "") {
         return "epube-book." + this.urlParam("b") + (suffix ? "." + suffix : "");
     }
 
@@ -1462,36 +1357,28 @@ class ReaderClass extends AppCommon {
      */
     showUI(show: any) {
         if (show)
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".header,.footer").fadeIn();
         else
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".header,.footer").fadeOut();
     }
 
     toggleUI() {
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         if ($(".header").is(":visible"))
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".header,.footer").fadeOut();
         else
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".header,.footer").fadeIn();
     }
 
     async lookupWord(word: any, callback: any, elem: any) {
         if (elem)
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             word = $(elem).val();
 
         word = word.replace(/­/g, "");
 
         console.log('lookupWord', word);
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $(".dict_result").html('Loading, please wait...');
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $("#dict-modal").modal('show');
 
         try {
@@ -1500,9 +1387,7 @@ class ReaderClass extends AppCommon {
 
             if (data.data) {
 
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 $(".dict_result").html(data.data.result.map((r: any) => this.escapeHtml(String(r))).join("<br/>"));
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 $(".dict_query").val(word);
 
                 if (callback) callback();
@@ -1513,7 +1398,6 @@ class ReaderClass extends AppCommon {
 
             console.error(err);
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".dict_result").html(`Network error while looking up word: ${this.escapeHtml((String)((err as any).responseText))}.`);
         }
     }
@@ -1522,9 +1406,7 @@ class ReaderClass extends AppCommon {
      * @returns {Promise<void>}
      */
     async search() {
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         const query = $(".search_input").val();
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         const list = $(".search_results");
 
         list.html("");
@@ -1551,17 +1433,14 @@ class ReaderClass extends AppCommon {
             searchResults.flat().forEach((row: any) => {
                 console.log('sr', row);
 
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 const a = $("<a>")
                     .attr('href', '#')
                     .html(`<b class='pull-right'>${this.book.locations.locationFromCfi(row.cfi)}</b>${this.escapeHtml(row.excerpt)}`)
                     .attr('data-cfi', row.cfi)
                     .on('click', () => {
-                        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                         this.book.rendition.display($(a).attr('data-cfi'));
                     });
 
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 list.append($("<li>").append(a));
             });
         } catch (e) {
@@ -1595,13 +1474,11 @@ class ReaderClass extends AppCommon {
      * @param {HTMLElement} elem
      */
     async openPrevious(elem: any) {
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         const cfi = $(elem).attr("data-location-cfi");
 
         if (cfi)
             await this.book.rendition.display(cfi);
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $(elem).fadeOut();
     }
 
@@ -1632,11 +1509,8 @@ class ReaderClass extends AppCommon {
         const currentCfi = location.start.cfi;
         const currentPct = Math.round(book.locations.percentageFromCfi(currentCfi) * 100);
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $("#cur_page").text(Math.floor(location.start.location / LOCATION_DIVISOR));
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $("#total_pages").text(Math.floor(book.locations.length() / LOCATION_DIVISOR));
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $("#page_pct").text(Math.round(book.locations.percentageFromCfi(currentCfi)*100) + '%');
 
         this.updateTocBarPosition(book, location);
@@ -1644,13 +1518,10 @@ class ReaderClass extends AppCommon {
         const displayed = location.start.displayed;
 
         if (displayed) {
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $("#chapter_cur_page").text(displayed.page);
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $("#chapter_total_pages").text(displayed.total);
 
             if (displayed.total > 0)
-                // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
                 $("#chapter_pct").text(Math.round(displayed.page / displayed.total * 100) + '%')
         }
 
@@ -1676,7 +1547,6 @@ class ReaderClass extends AppCommon {
 
     async clearLastRead() {
         if (confirm("Reset reading progress for this book?")) {
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $("#settings-modal").modal('hide');
 
             const total = this.book.locations.length();
@@ -1690,14 +1560,12 @@ class ReaderClass extends AppCommon {
 
             await this.book.rendition.display(this.book.locations.cfiFromPercentage(0));
 
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $(".lastread_input").val('0%');
         }
     }
 
     async resetLocations() {
         if (confirm("Reset stored pagination data? This will also reset reading progress.")) {
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $("#settings-modal").modal('hide');
 
             await localforage.removeItem(this.cacheId("lastread"));
@@ -1714,12 +1582,9 @@ class ReaderClass extends AppCommon {
     }
 
     async openLastRead() {
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $(".loading").show();
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $(".loading-message").html("Opening last read page…");
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $("#settings-modal").modal('hide');
 
         const rendition = this.book.rendition;
@@ -1770,7 +1635,6 @@ class ReaderClass extends AppCommon {
             }
         }
 
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         $(".loading").fadeOut();
     }
 
@@ -1782,9 +1646,7 @@ class ReaderClass extends AppCommon {
         if (!a || !b)
             return -1;
 
-        // @ts-expect-error TS(2304): Cannot find name 'ePub'.
         const acfi = new ePub.CFI(a);
-        // @ts-expect-error TS(2304): Cannot find name 'ePub'.
         const bcfi = new ePub.CFI(b);
 
         console.log('calculateCfiDelta', acfi, bcfi);
@@ -1854,7 +1716,6 @@ class ReaderClass extends AppCommon {
      * @param {HTMLElement} elem
      */
     async onThemeChanged(elem: any) {
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         const theme = $(elem).val();
 
         await localforage.setItem("epube.theme", theme);
@@ -1865,7 +1726,6 @@ class ReaderClass extends AppCommon {
      * @param {HTMLElement} elem
      */
     async onLineHeightChanged(elem: any) {
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         const height = $(elem).val();
 
         await localforage.setItem("epube.lineHeight", height);
@@ -1876,7 +1736,6 @@ class ReaderClass extends AppCommon {
      * @param {HTMLElement} elem
      */
     async onTextSizeChanged(elem: any) {
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         const size = $(elem).val();
 
         await localforage.setItem("epube.fontSize", size);
@@ -1887,7 +1746,6 @@ class ReaderClass extends AppCommon {
      * @param {HTMLElement} elem
      */
     async onFontChanged(elem: any) {
-        // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
         const font = $(elem).val();
 
         await localforage.setItem("epube.fontFamily", font);
@@ -1907,7 +1765,6 @@ class ReaderLoader {
         console.log('loader init for cache:', cacheName);
 
         if (typeof EpubeApp != "undefined") {
-            // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message
             $("body").addClass("epube-app");
         }
 
@@ -1938,12 +1795,10 @@ class ReaderLoader {
             let promise;
             if (req.url.match(/\.(ttf|otf)$/)) {
                 promise = response.blob().then((blob) => {
-                    // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
                     this._res_data[key] = URL.createObjectURL(blob);
                 });
             } else {
                 promise = response.text().then((text) => {
-                    // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
                     this._res_data[key] = text;
                 });
             }
@@ -1954,7 +1809,6 @@ class ReaderLoader {
             }));
         }
 
-        // @ts-expect-error TS(2550): Property 'allSettled' does not exist on type 'Prom... Remove this comment to see the full error message
         await Promise.allSettled(promises);
 
         if (Object.keys(this._res_data).length === 0) loadFailed = true;