forked from akai/readest
Import pdf-js from our public vendor and fix build
This commit is contained in:
@@ -25,7 +25,7 @@ const LibraryPage = () => {
|
||||
setLibrary(await appService.loadLibraryBooks());
|
||||
setLoading(false);
|
||||
});
|
||||
}, [envConfig, libraryBooks, setLibrary]);
|
||||
}, [envConfig, libraryBooks, setLibrary, getAppService]);
|
||||
|
||||
const importBooks = async (files: [string | File]) => {
|
||||
setLoading(true);
|
||||
|
||||
@@ -37,5 +37,5 @@ export const useFoliateEvents = (
|
||||
view.removeEventListener('load', onLoad);
|
||||
view.removeEventListener('relocate', onRelocate);
|
||||
};
|
||||
}, [view, handlers]);
|
||||
}, [view, onLoad, onRelocate, handlers]);
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ const ReaderPage = () => {
|
||||
};
|
||||
|
||||
fetchLibrary();
|
||||
}, [setLibrary]);
|
||||
}, [envConfig, setLibrary]);
|
||||
|
||||
return (
|
||||
<div className='min-h-screen bg-gray-100'>
|
||||
|
||||
@@ -189,6 +189,7 @@ export abstract class BaseAppService implements AppService {
|
||||
}
|
||||
|
||||
async saveLibraryBooks(books: Book[]): Promise<void> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const libraryBooks = books.map(({ coverImageUrl, ...rest }) => rest);
|
||||
await this.fs.writeFile(getLibraryFilename(), 'Books', JSON.stringify(libraryBooks));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { create } from 'zustand';
|
||||
|
||||
import { BookNote, BookContent, Book, BookConfig } from '@/types/book';
|
||||
import { BookNote, BookContent, Book, BookConfig, PageInfo } from '@/types/book';
|
||||
import { AppService } from '@/types/system';
|
||||
|
||||
interface BookState {
|
||||
@@ -18,7 +18,7 @@ interface ReaderStore {
|
||||
|
||||
setLibrary: (books: Book[]) => void;
|
||||
fetchBook: (appService: AppService, id: string) => Promise<Book | null>;
|
||||
setProgress: (id: string, progress: number, location: string, pageinfo: {}) => void;
|
||||
setProgress: (id: string, progress: number, location: string, pageinfo: PageInfo) => void;
|
||||
addBookmark: (id: string, bookmark: BookNote) => void;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ export const useReaderStore = create<ReaderStore>((set) => ({
|
||||
}
|
||||
},
|
||||
|
||||
setProgress: (id: string, progress: number, location: string, pageinfo: {}) =>
|
||||
setProgress: (id: string, progress: number, location: string, pageinfo: PageInfo) =>
|
||||
set((state) => {
|
||||
const book = state.books[id];
|
||||
if (!book) return state;
|
||||
|
||||
@@ -12,6 +12,12 @@ export interface Book {
|
||||
coverImageUrl?: string | null;
|
||||
}
|
||||
|
||||
export interface PageInfo {
|
||||
current: number;
|
||||
next: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface BookNote {
|
||||
cfi: string;
|
||||
start: string;
|
||||
@@ -27,7 +33,7 @@ export interface BookConfig {
|
||||
lastUpdated: number;
|
||||
progress?: number;
|
||||
location?: string;
|
||||
pageinfo?: Record<string, number>;
|
||||
pageinfo?: PageInfo;
|
||||
bookmarks?: BookNote[];
|
||||
annotations?: BookNote[];
|
||||
removedNotesTimestamps?: Record<string, number>;
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
{
|
||||
"extends": "@sindresorhus/tsconfig",
|
||||
"compilerOptions": {
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
@@ -19,9 +23,21 @@
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
"@/*": [
|
||||
"./src/*"
|
||||
],
|
||||
"@pdfjs/*": [
|
||||
"./public/vendor/pdfjs/*"
|
||||
]
|
||||
}
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
".next/types/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
+1
-1
Submodule packages/foliate-js updated: 2af74079c1...337988cffc
Reference in New Issue
Block a user