about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--build.js12
-rw-r--r--lib/epub.js/types/epubcfi.d.ts7
-rw-r--r--lib/epub.js/types/index.d.ts1
-rw-r--r--lib/epub.js/types/tsconfig.json1
-rw-r--r--src/index.d.ts4
-rw-r--r--src/reader.ts4
-rw-r--r--tsconfig.json26
7 files changed, 28 insertions, 27 deletions
diff --git a/build.js b/build.js
index a2eb419..54488cf 100644
--- a/build.js
+++ b/build.js
@@ -42,9 +42,9 @@ const LESS_FILES = [
 ]
 
 const JS_FILES = [
-	'src/http.js',
-	'src/app.js',
-	'src/reader.js'
+	'src/http.ts',
+	'src/app.ts',
+	'src/reader.ts'
 ];
 
 // Files that should be precached by the service worker
@@ -86,7 +86,7 @@ async function buildApp() {
 	console.log(`build version: ${BUILD_VERSION}`);
 
 	await esbuild.build({
-		stdin: { contents: content, resolveDir: process.cwd(), loader: 'js' },
+		stdin: { contents: content, resolveDir: process.cwd(), loader: 'ts' },
 		bundle: false,
 		minify: true,
 		outfile: 'dist/app.min.js',
@@ -113,7 +113,7 @@ async function buildApp() {
 
 	console.log('building service worker...');
 
-	const workerContent = readFileSync("src/worker.js");
+	const workerContent = readFileSync("src/worker.ts");
 
 	// Use suffixed JS filenames in manifest (stripped by worker for cache keys)
 	// worker.js itself is the service worker — not versioned, replaced atomically by deploy
@@ -129,7 +129,7 @@ async function buildApp() {
 	MANIFEST_ASSETS = [...new Set(MANIFEST_ASSETS)];
 
 	await esbuild.build({
-		stdin: { contents: workerContent, resolveDir: process.cwd(), loader: 'js' },
+		stdin: { contents: workerContent, resolveDir: process.cwd(), loader: 'ts' },
 		bundle: false,
 		minify: true,
 		outfile: 'worker.js',
diff --git a/lib/epub.js/types/epubcfi.d.ts b/lib/epub.js/types/epubcfi.d.ts
index f9748bb..f45faf8 100644
--- a/lib/epub.js/types/epubcfi.d.ts
+++ b/lib/epub.js/types/epubcfi.d.ts
@@ -9,7 +9,7 @@ interface EpubCFISegment {
 interface EpubCFIStep {
 	id: string,
 	tagName: string,
-	type: number,
+	type: number|string,
 	index: number
 }
 
@@ -25,8 +25,9 @@ export default class EpubCFI {
     constructor(cfiFrom?: string | Range | Node, base?: string | object, ignoreClass?: string);
 
     base: EpubCFIComponent;
-		spinePos: number;
-		range: boolean;
+    spinePos: number;
+    range: boolean;
+    path: EpubCFIComponent;
 
     isCfiString(str: string): boolean;
 
diff --git a/lib/epub.js/types/index.d.ts b/lib/epub.js/types/index.d.ts
index 6a8ec9b..7cf87a1 100644
--- a/lib/epub.js/types/index.d.ts
+++ b/lib/epub.js/types/index.d.ts
@@ -10,6 +10,7 @@ export default Epub;
 
 export { default as Book } from './book';
 export { default as EpubCFI } from './epubcfi';
+export { default as CFI } from './epubcfi';
 export { default as Rendition, Location } from './rendition';
 export { default as Contents } from './contents';
 export { default as Layout } from './layout';
diff --git a/lib/epub.js/types/tsconfig.json b/lib/epub.js/types/tsconfig.json
index 546c5a3..22ea59d 100644
--- a/lib/epub.js/types/tsconfig.json
+++ b/lib/epub.js/types/tsconfig.json
@@ -9,6 +9,7 @@
         "noImplicitThis": true,
         "strictNullChecks": true,
         "strictFunctionTypes": true,
+        "ignoreDeprecations": "6.0",
         "baseUrl": "../",
         "typeRoots": [
             "../"
diff --git a/src/index.d.ts b/src/index.d.ts
index c83ae9b..78706ea 100644
--- a/src/index.d.ts
+++ b/src/index.d.ts
@@ -51,3 +51,7 @@ declare const BUILD_CACHE_VERSION: string;
 declare const BUILD_MANIFEST_ASSETS: [];
 
 declare const BUILD_VERSION: string;
+
+declare var hyphenationPatternsEnUs;
+declare var hyphenationPatternsRu;
+declare var createHyphenator;
diff --git a/src/reader.ts b/src/reader.ts
index ac8c316..dbd505b 100644
--- a/src/reader.ts
+++ b/src/reader.ts
@@ -1369,7 +1369,7 @@ class ReaderClass extends AppCommon {
             $(".header,.footer").fadeIn();
     }
 
-    async lookupWord(word: any, callback: any, elem: any) {
+    async lookupWord(word: any, callback: any, elem: any = null) {
         if (elem)
             word = $(elem).val();
 
@@ -1774,7 +1774,7 @@ class ReaderLoader {
         const cache = await caches.open(cacheName);
         const cacheKeys = await cache.keys();
 
-        const promises = [];
+        const promises: Promise<void>[] = [];
         let loadFailed = false;
 
         for (const req of cacheKeys) {
diff --git a/tsconfig.json b/tsconfig.json
index 1d3266d..d6473a3 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,22 +1,16 @@
 {
   "compilerOptions": {
-    "ignoreDeprecations": "6.0",
+    "allowJs": true,
+    "checkJs": true,
+    "noImplicitAny": false,
     "noEmit": true,
     "skipLibCheck": true,
-    "noImplicitAny": false,
-    "moduleResolution": "node",
+    "types": ["bootstrap", "localforage", "node", "epub.js/types", "localforage"],
     "typeRoots": [
-      "./node_modules/@types",
-      "./lib"
-    ],
-    "types": [
-      "jquery",
-      "bootstrap",
-      "node",
-    ],
-    "paths": {
-      "localforage": ["./node_modules/localforage/typings/localforage.d.ts"],
-      "epubjs": ["./node_modules/epub.js/types/index.d.ts"]
-    }
-  }
+      "node_modules/@types",
+      "lib",
+      "node_modules"
+    ]
+  },
+  "include": ["src/**/*"]
 }