diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/app.ts | 54 | ||||
| -rw-r--r-- | src/reader.ts | 150 | ||||
| -rw-r--r-- | src/tsconfig.json | 103 | ||||
| -rw-r--r-- | src/worker.ts | 1 |
4 files changed, 2 insertions, 306 deletions
diff --git a/src/app.ts b/src/app.ts index e56db0b..6bef2c2 100644 --- a/src/app.ts +++ b/src/app.ts @@ -137,7 +137,6 @@ class AppCommon { applyNightMode(is_night: any) { console.log("night mode changed to", is_night); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#theme_css").attr("href", "lib/bootstrap/v3/css/" + (is_night ? "theme-dark.min.css" : "bootstrap-theme.min.css")); } @@ -165,7 +164,6 @@ class AppCommon { '`': '`' }; - // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message return p.replace(/[&<>"'`/]/g, function(m) { return map[m]; }); } } @@ -206,26 +204,19 @@ class AppClass extends AppCommon { // Update navbar active states if (this.index_mode === "favorites") { - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".index_favorites").addClass("active"); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".download_all_link").show(); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".logout_link").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 $(".index_all").addClass("active"); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".download_all_link").hide(); } - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".search_query").val(this.index_query); // Auth check: call backend with a minimal request; 401 means unauthorized try { const checkParams = new URLSearchParams({op: "list", limit: "1"}); - // @ts-expect-error TS(2554): Expected 2 arguments, but got 1. await Http.get("backend.php?" + checkParams.toString()); // If we get here without error, we're authenticated } catch (e) { @@ -243,13 +234,9 @@ class AppClass extends AppCommon { Http.setCsrfToken(this.csrf_token); 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 $(".navbar").hide(); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".epube-app-filler").show(); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".separate-search").show(); - // @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("is-epube-app"); if (this.index_mode == "favorites") @@ -267,7 +254,6 @@ class AppClass extends AppCommon { this.showCovers(); this.updateOfflinePrompts(); } else { - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".container-main") .addClass("alert alert-danger") .html("Service worker support missing in browser (are you using plain HTTP?)."); @@ -275,29 +261,24 @@ class AppClass extends AppCommon { } initCommonEventHandlers() { - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".remove_all_downloads").on('click', () => { this.removeAll(); }); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".logout_link").on('click', () => { this.logout(); }); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".download_all_link").on('click', (e: any) => { e.preventDefault(); this.getAll(); }); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".update_link").on('click', (e: any) => { e.preventDefault(); window.location.reload(); }); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".cosmetic_version").attr('title', this.cosmeticVersion); } @@ -330,24 +311,18 @@ class AppClass extends AppCommon { const comment = data.comment ? data.comment : 'No description available'; - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#summary-modal .modal-title").text(data.title); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#summary-modal .book-summary").html(comment); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#summary-modal").modal(); } else { const data = await localforage.getItem("epube-book." + bookId); const comment = data.comment ? data.comment : 'No description available'; - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#summary-modal .modal-title").text(data.title); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#summary-modal .book-summary").html(comment); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#summary-modal").modal(); } @@ -355,13 +330,10 @@ class AppClass extends AppCommon { } showCovers() { - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("img[data-book-id]").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 e = $(elem); if (e.attr('data-cover-link')) { - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const img = $("<img>") .on("load", () => { e.css("background-image", "url(" + e.attr('data-cover-link') + ")") @@ -379,7 +351,6 @@ class AppClass extends AppCommon { * @param {boolean} is_fav */ updateFavoritePrompt(elem: any, is_fav: any) { - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(elem) .text(is_fav ? "Remove from favorites" : "Add to favorites") .attr('data-is-fav', is_fav ? 1 : 0); @@ -402,7 +373,6 @@ class AppClass extends AppCommon { this.updateFavoritePrompt(elem, resp.data.status == "1"); if (this.index_mode == "favorites" && resp.data.status == 0) { - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#cell-" + bookId).remove(); } } @@ -415,10 +385,8 @@ class AppClass extends AppCommon { } updateOfflinePrompts() { - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const elems = $(".offline_dropitem"); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $.each(elems, (i: any, elem: any) => { this.updateOfflinePrompt(elem); }); @@ -464,11 +432,8 @@ class AppClass extends AppCommon { console.log('cache version, current:', this.cacheVersion, 'worker:', await this.getActiveCacheVersion()); 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 $(".navbar").hide(); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".epube-app-filler").show(); - // @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("is-epube-app"); EpubeApp.setPage("PAGE_OFFLINE"); @@ -477,7 +442,6 @@ class AppClass extends AppCommon { this.initNightMode(); this.initCommonEventHandlers(); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".search_query").val(this.urlParam("query")); this.populateOfflineList(); @@ -504,26 +468,22 @@ class AppClass extends AppCommon { const promises = []; - // @ts-expect-error TS(2554): Expected 2 arguments, but got 1. promises.push(Http.blob('backend.php?op=download&id=' + data.epub_id).then((resp) => { console.log(cacheId + ' got book'); return localforage.setItem(cacheId + '.book', resp.blob); }).catch((e) => console.warn('failed to download book', e))); - // @ts-expect-error TS(2554): Expected 2 arguments, but got 1. promises.push(Http.text("backend.php?op=getpagination&id=" + data.epub_id).then((resp) => { console.log(cacheId + ' got pagination'); return localforage.setItem(cacheId + '.locations', JSON.parse(resp.text)); }).catch((e) => console.warn('failed to download pagination', e))); - // @ts-expect-error TS(2554): Expected 2 arguments, but got 1. promises.push(Http.text("backend.php?op=getlastread&id=" + data.epub_id).then((resp) => { console.log(cacheId + ' got lastread'); return localforage.setItem(cacheId + '.lastread', JSON.parse(resp.text)); }).catch((e) => console.warn('failed to download lastread', e))); if (data.has_cover) { - // @ts-expect-error TS(2554): Expected 2 arguments, but got 1. promises.push(Http.blob("backend.php?op=cover&id=" + bookId).then((resp) => { console.log(cacheId + ' got cover'); return localforage.setItem(cacheId + '.cover', resp.blob); @@ -535,7 +495,6 @@ class AppClass extends AppCommon { callback(); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".dl-progress") .show() .html("Finished downloading <b>" + this.escapeHtml(data.title) + "</b>"); @@ -543,7 +502,6 @@ class AppClass extends AppCommon { window.clearTimeout(this._dl_progress_timeout); this._dl_progress_timeout = window.setTimeout(() => { - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".dl-progress").fadeOut(); }, 5*1000); } @@ -552,11 +510,8 @@ class AppClass extends AppCommon { getAll() { if (confirm("Download all books on this page?")) { - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".row > div").each((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 bookId = ($(row).attr("id") ?? "").replace("cell-", ""); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const dropitem = $(row).find(".offline_dropitem")[0] ?? null; if (bookId) { @@ -581,7 +536,6 @@ class AppClass extends AppCommon { const bookId = elem.getAttribute("data-book-id"); this.remove(bookId, () => { - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#cell-" + bookId).remove(); }); } @@ -623,7 +577,6 @@ class AppClass extends AppCommon { /** @type {HttpResponse} */ let resp; try { - // @ts-expect-error TS(2554): Expected 2 arguments, but got 1. resp = await Http.get("backend.php?" + params.toString()); } catch (e) { const err = /** @type {HttpError} */(e); @@ -635,7 +588,6 @@ class AppClass extends AppCommon { /** @type{BookList} */ const data = resp.data; - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const books = $("#books_container"); books.html(""); @@ -679,11 +631,8 @@ class AppClass extends AppCommon { * @param {BookList} data */ updateIndexPagination(data: 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 prevLi = $(".pager .previous"); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const nextLi = $(".pager .next"); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const pagerInfo = $(".pager .pager-info"); const prevParams = new URLSearchParams({ @@ -756,7 +705,6 @@ class AppClass extends AppCommon { ${this.escapeHtml(book.series_name) + " [" + book.series_index + "]"} </a></div>` : ''; - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const cell = $(`<div class="col-xxs-6 col-xs-3 col-sm-3 col-md-2" id="cell-${book.id}"> ${isOpenable ? `<a class="thumbnail ${cellThumbClass}" href="${readUrl}">` : @@ -798,7 +746,6 @@ class AppClass extends AppCommon { } 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_query").val(); await localforage.setItem("epube.search-query", query); @@ -829,7 +776,6 @@ class AppClass extends AppCommon { let query = this.urlParam("query"); if (query) query = String(query).toLowerCase(); - // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const books = $("#books_container"); books.html(""); 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} — ${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; diff --git a/src/tsconfig.json b/src/tsconfig.json deleted file mode 100644 index 75dcaea..0000000 --- a/src/tsconfig.json +++ /dev/null @@ -1,103 +0,0 @@ -{ - "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - - /* Projects */ - // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - - /* Language and Environment */ - "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ - // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ - - /* Modules */ - "module": "commonjs", /* Specify what module code is generated. */ - // "rootDir": "./", /* Specify the root folder within your source files. */ - // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "resolveJsonModule": true, /* Enable importing .json files. */ - // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */ - - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ - - /* Emit */ - // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - // "outDir": "./", /* Specify an output folder for all emitted files. */ - // "removeComments": true, /* Disable emitting comments. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ - - /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ - - /* Type Checking */ - "strict": true, /* Enable all strict type-checking options. */ - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ - // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ - } -} diff --git a/src/worker.ts b/src/worker.ts index 7afde1b..c362f3c 100644 --- a/src/worker.ts +++ b/src/worker.ts @@ -70,7 +70,6 @@ sw.addEventListener('activate', (event) => { await caches.delete(key); } } - // @ts-expect-error TS(2551): Property 'clients' does not exist on type 'Window ... Remove this comment to see the full error message await sw.clients.claim(); }; // Hand the executed promise directly to the event |
