about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2026-06-27 00:23:31 +0300
committerAndrew Dolgov <fox@fakecake.org>2026-06-27 00:23:31 +0300
commit6dbcfb7a317dc9642710f5479fa39c8c7881d280 (patch)
tree9239acad9402430a3642436b1f263fd56df423f8 /src
parent67d8785083c159aaaf3a4757e3bd6d8a5e07602e (diff)
downloadthe-epube-6dbcfb7a317dc9642710f5479fa39c8c7881d280.tar.gz
the-epube-6dbcfb7a317dc9642710f5479fa39c8c7881d280.tar.xz
last tsc fixes
Diffstat (limited to 'src')
-rw-r--r--src/app.ts11
-rw-r--r--src/http.ts6
-rw-r--r--src/index.d.ts1
-rw-r--r--src/worker.ts3
4 files changed, 10 insertions, 11 deletions
diff --git a/src/app.ts b/src/app.ts
index 6bef2c2..1d40637 100644
--- a/src/app.ts
+++ b/src/app.ts
@@ -317,7 +317,7 @@ class AppClass extends AppCommon {
             $("#summary-modal").modal();
 
         } else {
-            const data = await localforage.getItem("epube-book." + bookId);
+            const data = await localforage.getItem("epube-book." + bookId) as BookInfo;
             const comment = data.comment ? data.comment : 'No description available';
 
             $("#summary-modal .modal-title").text(data.title);
@@ -466,7 +466,7 @@ class AppClass extends AppCommon {
             await localforage.setItem(cacheId, data);
             console.log(cacheId + ' got data');
 
-            const promises = [];
+            const promises: Promise<any>[] = [];
 
             promises.push(Http.blob('backend.php?op=download&id=' + data.epub_id).then((resp) => {
                 console.log(cacheId + ' got book');
@@ -791,8 +791,7 @@ class AppClass extends AppCommon {
 
                     if (results[0] && results[3]) {
 
-                        /** @type BookInfo */
-                        const info = results[0];
+                        const info = results[0] as BookInfo;
 
                         if (query) {
                             const match =
@@ -805,10 +804,10 @@ class AppClass extends AppCommon {
 
                         let cover = "";
                         if (results[1]) {
-                            cover = URL.createObjectURL(results[1]);
+                            cover = URL.createObjectURL(results[1] as Blob);
                         }
 
-                        const lastread = results[2];
+                        const lastread = results[2] as LastRead;
                         info.in_progress = lastread ? lastread.page > 0 : false;
                         info.is_read = lastread ? (lastread.total > 0 && lastread.total - lastread.page < 5) : false;
 
diff --git a/src/http.ts b/src/http.ts
index 2474eb5..9c8b71a 100644
--- a/src/http.ts
+++ b/src/http.ts
@@ -65,7 +65,7 @@ resp.text().then((t: any) => { (err as any).responseText = t; }).catch(() => {
      * @param {Record<string, string> | null} [params] - optional query parameters
      * @returns {Promise<HttpResponse>}
      */
-    static async get(url: any, params: any) {
+    static async get(url: any, params: any = null) {
         const urlWithParams = Http._appendParams(url, params);
         const resp = await fetch(urlWithParams, {
             method: 'GET',
@@ -112,7 +112,7 @@ resp.text().then((t: any) => { (err as any).responseText = t; }).catch(() => {
      * @param {Record<string, string> | null} [params] - optional query parameters
      * @returns {Promise<HttpBlobResponse>}
      */
-    static async blob(url: any, params: any) {
+    static async blob(url: any, params: any = null) {
         const urlWithParams = Http._appendParams(url, params);
         const resp = await fetch(urlWithParams, {
             method: 'GET',
@@ -133,7 +133,7 @@ resp.text().then((t: any) => { (err as any).responseText = t; }).catch(() => {
      * @param {Record<string, string> | null} [params] - optional query parameters
      * @returns {Promise<HttpTextResponse>}
      */
-    static async text(url: any, params: any) {
+    static async text(url: any, params: any = null) {
         const urlWithParams = Http._appendParams(url, params);
         const resp = await fetch(urlWithParams, {
             method: 'GET',
diff --git a/src/index.d.ts b/src/index.d.ts
index 78706ea..1e6a886 100644
--- a/src/index.d.ts
+++ b/src/index.d.ts
@@ -41,6 +41,7 @@ declare interface BookList {
 declare interface LastRead {
     cfi: string;
     page: number;
+    total: number;
 }
 
 declare var EpubeApp: EpubeApp;
diff --git a/src/worker.ts b/src/worker.ts
index c362f3c..e7133e4 100644
--- a/src/worker.ts
+++ b/src/worker.ts
@@ -1,7 +1,6 @@
 /// <reference lib="webworker" />
 
-/** @type {ServiceWorkerGlobalScope} */
-const sw = (/** @type {any} */ (self));
+const sw = (self as typeof globalThis) as unknown as ServiceWorkerGlobalScope;
 
 const CACHE_PREFIX = 'epube';