mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 08:21:39 -06:00
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:
@@ -0,0 +1,3 @@
|
||||
export interface DjvuPageTextResponse {
|
||||
text: string;
|
||||
}
|
||||
@@ -88,4 +88,5 @@ export * from "./tts";
|
||||
export * from "./watch-download";
|
||||
export * from "./podcast";
|
||||
export * from "./delivery";
|
||||
export * from "./djvu";
|
||||
export * from "./email";
|
||||
|
||||
@@ -20,6 +20,7 @@ export const DEFAULT_FORMAT_PRIORITY = [
|
||||
"azw3",
|
||||
"azw",
|
||||
"fb2",
|
||||
"djvu",
|
||||
"m4b",
|
||||
"mp3",
|
||||
"m4a",
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -4,6 +4,7 @@ export const UPLOAD_SUPPORTED_FORMATS = [
|
||||
"epub",
|
||||
"kepub",
|
||||
"pdf",
|
||||
"djvu",
|
||||
"mobi",
|
||||
"azw",
|
||||
"azw3",
|
||||
|
||||
Reference in New Issue
Block a user