feat: replace the epub reader with foliate-js
Drops epub.js's 1600-location pre-pass and its localStorage cache: foliate hands back a CFI and an overall fraction on every relocate, so first open no longer freezes. Also fixes resuming (pre-resolves the stored CFI, falling back to the stored percentage rather than silently resetting to page one), progress saving (missing Content-Type, and no flush on the way out), and arrow keys inside the book iframe.
This commit is contained in:
@@ -16,9 +16,11 @@ export interface ReaderPalette {
|
||||
* <style id="chitai-theme"> with the full palette into every page, so the tokens
|
||||
* are resolved on documentElement before first paint.
|
||||
*
|
||||
* Call this after the dark class has landed, not in the same tick as a mode flip.
|
||||
* `dark` is passed in rather than read off the class list, because mode-watcher's
|
||||
* store is the authority and the class trails it by a frame. Call this after that
|
||||
* frame, though — the token values themselves do come from the class.
|
||||
*/
|
||||
export function readReaderPalette(): ReaderPalette {
|
||||
export function readReaderPalette(dark: boolean): ReaderPalette {
|
||||
const styles = getComputedStyle(document.documentElement);
|
||||
const token = (name: string, fallback: string) =>
|
||||
styles.getPropertyValue(name).trim() || fallback;
|
||||
@@ -29,7 +31,7 @@ export function readReaderPalette(): ReaderPalette {
|
||||
fg: token('--foreground', '#000000'),
|
||||
muted: token('--muted-foreground', '#666666'),
|
||||
link: token('--primary', '#0066cc'),
|
||||
dark: document.documentElement.classList.contains('dark')
|
||||
dark
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user