feat(reader): open DjVu documents in the web reader

Scanned books are commonly distributed as DjVu, which the scanner only stored as a supplement.
Decode pages on the server with DjVuLibre so DjVu imports with a cover and page count, opens in
the image reader with its embedded OCR text, and can be the preferred format of an ordinary email
recipient. Migration 0113 widens the recipient format check to allow it.

Decoding runs on validated private snapshots behind a bounded, reader-first queue, and
revalidation and cached pages are answered without a decoder. Released iOS builds cannot open
DjVu, so series continuation offers it only to callers sending includeDjvu=true, and the
dashboard and notebook read file never name it. The first full scan after upgrading promotes
stored .djvu supplements to content.
This commit is contained in:
neon
2026-10-14 21:37:41 +00:00
parent 2cbd76bc7f
commit 97cd03325f
96 changed files with 26351 additions and 146 deletions
+3
View File
@@ -0,0 +1,3 @@
export interface DjvuPageTextResponse {
text: string;
}
+1
View File
@@ -88,4 +88,5 @@ export * from "./tts";
export * from "./watch-download";
export * from "./podcast";
export * from "./delivery";
export * from "./djvu";
export * from "./email";
+1
View File
@@ -20,6 +20,7 @@ export const DEFAULT_FORMAT_PRIORITY = [
"azw3",
"azw",
"fb2",
"djvu",
"m4b",
"mp3",
"m4a",
+12
View File
@@ -29,6 +29,7 @@ export const READER_OPENABLE_FORMATS = new Set([
"cbz",
"cbr",
"cb7",
"djvu",
// audio reader
"m4b",
"mp3",
@@ -50,6 +51,7 @@ export const FORMAT_TO_GROUP: Record<string, ReaderFormatGroup> = {
cbz: "cbx",
cbr: "cbx",
cb7: "cbx",
djvu: "cbx",
m4b: "audio",
mp3: "audio",
m4a: "audio",
@@ -62,6 +64,16 @@ export function getFormatGroup(format: string): ReaderFormatGroup {
return FORMAT_TO_GROUP[format.toLowerCase()] ?? "epub";
}
/**
* Openable formats that released native clients cannot open. An answer that picks a file for a
* client offers one of these only to a caller that says it can open it.
*/
export const OPT_IN_READER_FORMATS: ReadonlySet<string> = new Set(["djvu"]);
export function isOptInReaderFormat(format: string | null | undefined): boolean {
return OPT_IN_READER_FORMATS.has((format ?? "").toLowerCase());
}
/** Formats a given reader can open, so a caller can ask for "another file this same reader handles". */
export function getOpenableFormatsForGroup(group: ReaderFormatGroup): string[] {
return Object.entries(FORMAT_TO_GROUP)
+1
View File
@@ -4,6 +4,7 @@ export const UPLOAD_SUPPORTED_FORMATS = [
"epub",
"kepub",
"pdf",
"djvu",
"mobi",
"azw",
"azw3",