aksos-react-native-epub-reader 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +351 -2
  3. package/lib/EpubReader.d.ts +76 -0
  4. package/lib/EpubReader.js +284 -0
  5. package/lib/EpubReaderView.d.ts +31 -0
  6. package/lib/EpubReaderView.js +599 -0
  7. package/lib/assets/page-turn-1.wav +0 -0
  8. package/lib/assets/page-turn-2.wav +0 -0
  9. package/lib/assets/page-turn-3.wav +0 -0
  10. package/lib/assets/page-turn-4.wav +0 -0
  11. package/lib/engine/html.d.ts +1 -0
  12. package/lib/engine/html.js +5 -0
  13. package/lib/index.d.ts +9 -0
  14. package/lib/index.js +34 -0
  15. package/lib/sound.d.ts +1 -0
  16. package/lib/sound.js +71 -0
  17. package/lib/strings.d.ts +94 -0
  18. package/lib/strings.js +96 -0
  19. package/lib/themes.d.ts +60 -0
  20. package/lib/themes.js +166 -0
  21. package/lib/types.d.ts +149 -0
  22. package/lib/types.js +2 -0
  23. package/lib/ui/AppearanceSheet.d.ts +15 -0
  24. package/lib/ui/AppearanceSheet.js +134 -0
  25. package/lib/ui/ContentsSheet.d.ts +27 -0
  26. package/lib/ui/ContentsSheet.js +89 -0
  27. package/lib/ui/CustomizeSheet.d.ts +16 -0
  28. package/lib/ui/CustomizeSheet.js +141 -0
  29. package/lib/ui/Glass.d.ts +15 -0
  30. package/lib/ui/Glass.js +27 -0
  31. package/lib/ui/HighlightMenu.d.ts +25 -0
  32. package/lib/ui/HighlightMenu.js +45 -0
  33. package/lib/ui/Icons.d.ts +17 -0
  34. package/lib/ui/Icons.js +193 -0
  35. package/lib/ui/LineGuide.d.ts +21 -0
  36. package/lib/ui/LineGuide.js +92 -0
  37. package/lib/ui/NoteEditor.d.ts +12 -0
  38. package/lib/ui/NoteEditor.js +63 -0
  39. package/lib/ui/Scrubber.d.ts +15 -0
  40. package/lib/ui/Scrubber.js +86 -0
  41. package/lib/ui/SearchSheet.d.ts +14 -0
  42. package/lib/ui/SearchSheet.js +79 -0
  43. package/lib/ui/Sheet.d.ts +19 -0
  44. package/lib/ui/Sheet.js +40 -0
  45. package/lib/ui/Slider.d.ts +14 -0
  46. package/lib/ui/Slider.js +53 -0
  47. package/package.json +76 -6
  48. package/src/EpubReader.tsx +356 -0
  49. package/src/EpubReaderView.tsx +865 -0
  50. package/src/assets/page-turn-1.wav +0 -0
  51. package/src/assets/page-turn-2.wav +0 -0
  52. package/src/assets/page-turn-3.wav +0 -0
  53. package/src/assets/page-turn-4.wav +0 -0
  54. package/src/engine/html.ts +2 -0
  55. package/src/engine/reader.js +2047 -0
  56. package/src/index.ts +9 -0
  57. package/src/sound.ts +66 -0
  58. package/src/strings.ts +187 -0
  59. package/src/themes.ts +188 -0
  60. package/src/types.ts +154 -0
  61. package/src/ui/AppearanceSheet.tsx +176 -0
  62. package/src/ui/ContentsSheet.tsx +146 -0
  63. package/src/ui/CustomizeSheet.tsx +191 -0
  64. package/src/ui/Glass.tsx +37 -0
  65. package/src/ui/HighlightMenu.tsx +66 -0
  66. package/src/ui/Icons.tsx +246 -0
  67. package/src/ui/LineGuide.tsx +87 -0
  68. package/src/ui/NoteEditor.tsx +57 -0
  69. package/src/ui/Scrubber.tsx +78 -0
  70. package/src/ui/SearchSheet.tsx +95 -0
  71. package/src/ui/Sheet.tsx +71 -0
  72. package/src/ui/Slider.tsx +30 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aksos
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,352 @@
1
- # Temporary Holding Version
1
+ # aksos-react-native-epub-reader
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A complete EPUB reader for **React Native and Expo**, with the feel of a modern book app: real page curl, slide, fade and
4
+ continuous scroll, themes with light and dark variants, highlights, notes, bookmarks, whole-book search, a line guide, and
5
+ first-class **right-to-left** support (Pashto, Dari, Persian, Arabic, Urdu, Hebrew).
6
+
7
+ It is one component with a full reading UI (`EpubReaderView`), plus a headless engine (`EpubReader`) if you want to build your own.
8
+
9
+ - Works in **Expo Go**, Expo development builds and bare React Native (iOS and Android).
10
+ - No native code of its own: it uses `react-native-webview` and `react-native-svg`.
11
+ - You own the storage. The reader gives you the reading position, highlights, bookmarks and settings through callbacks.
12
+
13
+ ---
14
+
15
+ ## Contents
16
+
17
+ 1. [Install](#install)
18
+ 2. [Quick start](#quick-start)
19
+ 3. [Saving and restoring](#saving-and-restoring)
20
+ 4. [`EpubReaderView` props](#epubreaderview-props)
21
+ 5. [Headless `EpubReader`](#headless-epubreader)
22
+ 6. [Data types](#data-types)
23
+ 7. [Settings reference](#settings-reference)
24
+ 8. [Right-to-left books](#right-to-left-books)
25
+ 9. [What the user can do](#what-the-user-can-do)
26
+ 10. [Troubleshooting](#troubleshooting)
27
+ 11. [Limitations](#limitations)
28
+ 12. [Credits and license](#credits-and-license)
29
+
30
+ ---
31
+
32
+ ## Install
33
+
34
+ ### Expo
35
+
36
+ ```bash
37
+ npx expo install react-native-webview react-native-svg
38
+ npm install aksos-react-native-epub-reader
39
+ ```
40
+
41
+ Optional, each one adds a feature and the reader simply works without it:
42
+
43
+ ```bash
44
+ npx expo install expo-blur expo-audio expo-screen-orientation
45
+ ```
46
+
47
+ | Package | Adds |
48
+ |---|---|
49
+ | `expo-blur` | frosted-glass controls and sheets (without it they are plain translucent) |
50
+ | `expo-audio` | the page-turn sound |
51
+ | `expo-screen-orientation` | the rotation-lock button |
52
+
53
+ > After installing a new package, restart Metro with a cleared cache: `npx expo start --clear`.
54
+
55
+ ### Bare React Native
56
+
57
+ ```bash
58
+ npm install aksos-react-native-epub-reader react-native-webview react-native-svg
59
+ cd ios && pod install
60
+ ```
61
+
62
+ Add the optional packages above if you want those features.
63
+
64
+ ### Opening files from the device
65
+
66
+ The reader takes a file URI or a base64 string. To let users pick a book, add a document picker:
67
+
68
+ ```bash
69
+ npx expo install expo-document-picker expo-file-system
70
+ ```
71
+
72
+ ---
73
+
74
+ ## Quick start
75
+
76
+ ```tsx
77
+ import React from 'react';
78
+ import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context';
79
+ import { EpubReaderView } from 'aksos-react-native-epub-reader';
80
+
81
+ function Reader({ uri, onClose }: { uri: string; onClose: () => void }) {
82
+ const insets = useSafeAreaInsets();
83
+ return (
84
+ <EpubReaderView
85
+ source={{ uri }} // file:// or http(s):// (or { base64: '...' })
86
+ safeInsets={{ top: insets.top, bottom: insets.bottom }}
87
+ onClose={onClose}
88
+ />
89
+ );
90
+ }
91
+
92
+ export default function App() {
93
+ return (
94
+ <SafeAreaProvider>
95
+ <Reader uri="file:///path/to/book.epub" onClose={() => {}} />
96
+ </SafeAreaProvider>
97
+ );
98
+ }
99
+ ```
100
+
101
+ That is a complete reader: tap the middle of the page to show the controls, long-press a word to highlight.
102
+
103
+ ### Pick a book from the device (Expo)
104
+
105
+ ```tsx
106
+ import * as DocumentPicker from 'expo-document-picker';
107
+ import * as FileSystem from 'expo-file-system/legacy';
108
+
109
+ async function importBook() {
110
+ const res = await DocumentPicker.getDocumentAsync({ type: ['application/epub+zip', '*/*'], copyToCacheDirectory: true });
111
+ if (res.canceled) return null;
112
+ const dest = `${FileSystem.documentDirectory}${Date.now()}.epub`;
113
+ await FileSystem.copyAsync({ from: res.assets[0].uri, to: dest });
114
+ return dest; // pass as source={{ uri: dest }}
115
+ }
116
+ ```
117
+
118
+ A complete example app (library, import, saving) is in [`example/`](example/).
119
+
120
+ ---
121
+
122
+ ## Saving and restoring
123
+
124
+ The reader never stores anything itself. Save what the callbacks give you, and pass it back next time:
125
+
126
+ ```tsx
127
+ import AsyncStorage from '@react-native-async-storage/async-storage';
128
+
129
+ const key = (id: string) => `book:${id}`;
130
+
131
+ <EpubReaderView
132
+ source={{ uri }}
133
+ initialLocation={saved.location} // { spine, offset }
134
+ initialHighlights={saved.highlights}
135
+ initialBookmarks={saved.bookmarks}
136
+ initialSettings={saved.settings} // partial ReaderSettings
137
+
138
+ onLocationChange={(e) => save({ location: { spine: e.spine, offset: e.offset, progress: e.progress } })}
139
+ onHighlightsChange={(list) => save({ highlights: list })}
140
+ onBookmarksChange={(list) => save({ bookmarks: list })}
141
+ onSettingsChange={(s) => save({ settings: s })}
142
+ />
143
+ ```
144
+
145
+ Locations are `{ spine, offset }`: the chapter number and a character offset inside it. They stay valid when the user
146
+ changes font size, theme or rotates the device.
147
+
148
+ `onLocationChange` fires on every page, so debounce the write (about 400 ms is plenty). The example app does this in
149
+ [`example/App.tsx`](example/App.tsx).
150
+
151
+ ---
152
+
153
+ ## `EpubReaderView` props
154
+
155
+ | Prop | Type | Description |
156
+ |---|---|---|
157
+ | `source` | `{ uri; headers?; key? } \| { base64; key? }` | **Required.** The EPUB: a `file://`, `content://` (Android) or `https://` uri, or base64 data. `key` identifies the book; a different source starts a fresh reader (highlights, bookmarks and position of one book never reach another). |
158
+ | `title` | `string` | Shown in Contents until the book's own title is read. |
159
+ | `safeInsets` | `{ top; bottom; left?; right? }` | Status-bar, home-indicator and (landscape) notch space. Use `useSafeAreaInsets()` from `react-native-safe-area-context`. Without it a guess from the screen size is used. |
160
+ | `labels` | `Partial<ReaderLabels>` | Every text of the interface, for translation (Pashto, Dari, Arabic ...). `formatNumber` lets you show Arabic-Indic digits. See `DEFAULT_LABELS`. |
161
+ | `maxFileSize` | `number` | Largest EPUB in bytes (default 150 MB, `0` = no limit). Bigger files raise an error instead of crashing low-memory phones. |
162
+ | `initialLocation` | `{ spine: number; offset: number }` | Where to open. Defaults to the start. |
163
+ | `initialSettings` | `Partial<ReaderSettings>` | Theme, font, size, spacing ... |
164
+ | `initialHighlights` | `Highlight[]` | |
165
+ | `initialBookmarks` | `Bookmark[]` | |
166
+ | `onClose` | `() => void` | The X button. |
167
+ | `onLocationChange` | `(e: RelocateEvent) => void` | Every page turn. Has `spine`, `offset`, `progress` (0..1), `page`, `pageCount`, `chapter`. |
168
+ | `onHighlightsChange` | `(list: Highlight[]) => void` | After any create / edit / delete. |
169
+ | `onBookmarksChange` | `(list: Bookmark[]) => void` | |
170
+ | `onSettingsChange` | `(s: ReaderSettings) => void` | |
171
+ | `onMetadata` | `(m: BookMetadata) => void` | `title`, `author`, `language`, `publisher`. |
172
+ | `onCover` | `(dataUri: string) => void` | The cover image, if the book has one. |
173
+ | `onError` | `(message: string) => void` | Unreadable file, DRM, ... The reader itself shows an error screen with **Try again** and **Close**, so the user is never stuck. |
174
+
175
+ ---
176
+
177
+ ## Headless `EpubReader`
178
+
179
+ `EpubReader` is only the page engine, with no buttons and no sheets. Use it to build your own interface.
180
+
181
+ ```tsx
182
+ import { EpubReader, DEFAULT_SETTINGS } from 'aksos-react-native-epub-reader';
183
+ import type { EpubReaderHandle } from 'aksos-react-native-epub-reader';
184
+
185
+ const ref = useRef<EpubReaderHandle>(null);
186
+
187
+ <EpubReader
188
+ ref={ref}
189
+ source={{ uri }}
190
+ settings={{ ...DEFAULT_SETTINGS, themeId: 'calm', fontSize: 21 }}
191
+ systemDark={useColorScheme() === 'dark'}
192
+ safeInsets={{ top: 50, bottom: 30 }}
193
+ highlights={highlights}
194
+ onRelocate={(e) => console.log(e.chapter, e.progress)}
195
+ onSelection={(sel) => sel && console.log(sel.text)} // sel.start / sel.end / sel.rect
196
+ onTap={() => toggleMyControls()}
197
+ onToc={(items) => setToc(items)}
198
+ />
199
+
200
+ ref.current?.next();
201
+ ref.current?.prev();
202
+ ref.current?.goTo({ spine: 3 });
203
+ ref.current?.goTo({ spine: 3, fragment: 'section-2' });
204
+ ref.current?.goTo({ progress: 0.5 }); // 0..1 across the whole book
205
+ ref.current?.search('word', 1); // results arrive in onSearchResults(1, results, done)
206
+ ref.current?.showSearchResult(result);
207
+ ref.current?.clearSelection();
208
+ ref.current?.setLabels('Chapter 3', '42 of 300'); // running header / footer drawn on the page
209
+ ```
210
+
211
+ Extra callbacks: `onReady`, `onCover`, `onIndexed`, `onHighlightTap`, `onLink`, `onSearchResults`, `onEndReached`, `onPageTurn`, `onError`.
212
+
213
+ ---
214
+
215
+ ## Data types
216
+
217
+ ```ts
218
+ interface Highlight {
219
+ id: string; spine: number; start: number; end: number; // character offsets in that chapter
220
+ text: string; color: 'yellow' | 'green' | 'blue' | 'pink' | 'purple';
221
+ style?: 'highlight' | 'underline'; note?: string; chapter?: string; createdAt: number;
222
+ }
223
+
224
+ interface Bookmark {
225
+ id: string; spine: number; offset: number; chapter: string; excerpt: string; progress: number; createdAt: number;
226
+ }
227
+
228
+ interface RelocateEvent {
229
+ spine: number; offset: number; end: number; page: number; pageCount: number; spineCount: number;
230
+ textLength: number; progress: number; chapter: string; excerpt: string; indexed: boolean;
231
+ }
232
+ ```
233
+
234
+ All types are exported: `import type { Highlight, Bookmark, ReaderSettings, TocItem, ... } from 'aksos-react-native-epub-reader'`.
235
+
236
+ ---
237
+
238
+ ## Settings reference
239
+
240
+ `ReaderSettings` (all optional in `initialSettings`; defaults are in `DEFAULT_SETTINGS`):
241
+
242
+ | Field | Values | Default |
243
+ |---|---|---|
244
+ | `themeId` | `original` `quiet` `paper` `bold` `calm` `focus` | `original` |
245
+ | `appearance` | `light` `dark` `device` | `device` |
246
+ | `fontId` | `original` (the book's own) `system` `newyork` `athelas` `charter` `georgia` `iowan` `palatino` `seravek` `times` `naskh` | `original` |
247
+ | `fontSize` | 12 - 40 | `19` |
248
+ | `bold` | `boolean` | `false` |
249
+ | `customize` | turns on the spacing values below | `false` |
250
+ | `lineHeight` | 1.1 - 2.2 | `1.5` |
251
+ | `letterSpacing` / `wordSpacing` | -50 .. 100 (percent) | `0` |
252
+ | `margins` | -50 .. 100 (percent) | `0` |
253
+ | `columns` | `auto` `1` `2` | `auto` |
254
+ | `justify` | `boolean` | `false` |
255
+ | `pageTurn` | `slide` `curl` `fade` `scroll` | `slide` |
256
+ | `pageSound` | paper sound on page turns | `true` |
257
+ | `brightness` | 0.3 - 1 | `1` |
258
+ | `direction` | `auto` `ltr` `rtl` | `auto` |
259
+
260
+ Exported helpers: `THEMES`, `FONTS`, `HIGHLIGHT_COLORS`, `DEFAULT_SETTINGS`, `getTheme(id)`, `getFont(id)`, `chromeColors(...)`.
261
+
262
+ > The fonts are CSS stacks, so what you see depends on the device. `original` always uses the fonts inside the book.
263
+ > For Pashto / Arabic text, `naskh` asks for Noto Naskh, Geeza Pro or Scheherazade.
264
+
265
+ ---
266
+
267
+ ## Right-to-left books
268
+
269
+ Direction is detected automatically, in this order:
270
+
271
+ 1. `page-progression-direction` in the book,
272
+ 2. the book's language (`ps`, `fa`, `ar`, `ur`, `he`, ...),
273
+ 3. **the text itself**: if the first chapters are mostly Arabic script, the book is treated as right-to-left, even when
274
+ the metadata says English. (Many Pashto and Dari EPUBs have wrong or missing language tags.)
275
+
276
+ In a right-to-left book pages turn from left to right, taps and swipes are mirrored, the progress bar fills from the right,
277
+ and the page curl folds the other way. Set `settings.direction` to `ltr` or `rtl` to override the detection.
278
+
279
+ ---
280
+
281
+ ## What the user can do
282
+
283
+ - **Turn pages** with a tap on the left or right edge, or a swipe. Choose Slide, Curl (a real corner fold, following the finger),
284
+ Fast Fade or Scroll (continuous, chapter after chapter).
285
+ - **Tap the middle** to show the controls: close, Contents (chapters, bookmarks, highlights with page numbers), Search Book,
286
+ Themes & Settings, Customize, share, rotation lock, Line Guide, bookmark.
287
+ - **Long-press a word** and drag to select, then choose **Highlight** or **Note**. Tap a highlight to change its colour,
288
+ underline it, edit the note or delete it.
289
+ - **Line Guide** dims everything except one line that can be dragged.
290
+ - **Links** inside the book work; external links open in the browser.
291
+
292
+ ---
293
+
294
+ ## Troubleshooting
295
+
296
+ **"Unable to resolve module" right after installing a package.** Metro has a stale cache: `npx expo start --clear`.
297
+
298
+ **No page-turn sound.** Install `expo-audio`, turn up the media volume, and check the iPhone silent switch.
299
+ The sound can be disabled by the user in Themes & Settings, Customize.
300
+
301
+ **Controls are not blurred on Android.** `expo-blur` blur is limited on Android; the controls fall back to translucent colour.
302
+
303
+ **A book will not open.** `onError` receives the reason and the reader shows it with Try again / Close. DRM-protected files (Adobe, Apple FairPlay, Readium LCP) cannot be opened and are reported as such.
304
+
305
+ **The reader goes blank after the app was in the background.** If the system kills the web view process (low memory), the reader restarts by itself at the last position.
306
+
307
+ **Opening is slow for a very large book.** The file is sent to the page engine as base64 in pieces. Typical novels take well under
308
+ a second; a 50 MB illustrated book will be slow, and files above `maxFileSize` are refused.
309
+
310
+ ---
311
+
312
+ ## Limitations
313
+
314
+ - Reflowable EPUBs only. Fixed-layout EPUBs and media overlays are not supported.
315
+ - Themes and fonts are chosen from the built-in lists (no custom theme prop yet).
316
+ - Vertical writing modes (Japanese `writing-mode: vertical-rl`) are laid out horizontally.
317
+ - Character spacing is ignored in right-to-left books: it would break the joins of Arabic-script letters.
318
+ - Audio and video elements in a book are removed.
319
+ - Text selection and highlights work in the chapter that is on screen; in Scroll mode a neighbouring chapter becomes
320
+ selectable once it scrolls into the middle of the screen.
321
+ - Search ignores case, diacritics (tashkeel), tatweel and ZWNJ, unifies Arabic / Persian letter variants (for example ي and ی) and all digit systems.
322
+ - The page curl is a geometric corner fold, not a physical simulation of paper.
323
+
324
+ ---
325
+
326
+ ## Credits and license
327
+
328
+ MIT, see [LICENSE](LICENSE).
329
+
330
+ The page-turn sounds (`src/assets/page-turn-*.wav`) are trimmed and softened recordings from
331
+ "10 Book Page Flips" by StarNinjas (https://opengameart.org/content/10-book-page-flips), released under CC0.
332
+
333
+ EPUB parsing uses [JSZip](https://stuk.github.io/jszip/).
334
+
335
+ ### Security
336
+
337
+ Books are untrusted input. Chapter HTML is sanitized (scripts, event handlers, `javascript:` URLs, forms, `<base>`, remote images and
338
+ styles are removed), chapters render in frames under a Content-Security-Policy that blocks script and network, and only
339
+ `http(s)` and `mailto` links can leave the book, after a confirmation. Publisher font obfuscation (IDPF and Adobe) is decoded, so
340
+ embedded fonts work; real DRM is detected and refused.
341
+
342
+ ### Developing
343
+
344
+ ```bash
345
+ npm install
346
+ npm run build:engine # rebuilds src/engine/html.ts from src/engine/reader.js
347
+ npm run build:lib # compiles src/ to lib/
348
+ npm run typecheck
349
+ ```
350
+
351
+ The reading engine is plain JavaScript in `src/engine/reader.js`, bundled with JSZip into a single HTML page for the WebView.
352
+ `test/serve.js` serves that page in a browser together with sample books (`node test/make-epub.js` creates them).
@@ -0,0 +1,76 @@
1
+ import React from 'react';
2
+ import type { BookLocation, BookMetadata, EpubSource, Highlight, ReaderSettings, RelocateEvent, SafeInsets, SearchResult, SelectionEvent, TocItem } from './types';
3
+ export interface ReaderErrorInfo {
4
+ /** true when the book cannot be shown (failed to open, reader engine stopped); false for a problem on one page */
5
+ fatal: boolean;
6
+ }
7
+ export interface EpubReaderProps {
8
+ source: EpubSource;
9
+ settings: ReaderSettings;
10
+ /** system colour scheme, used when settings.appearance is 'device' */
11
+ systemDark?: boolean;
12
+ /** Space reserved for status bar / home indicator (and the notch in landscape). The engine adds room for the running header and footer. */
13
+ safeInsets?: SafeInsets;
14
+ initialLocation?: BookLocation | {
15
+ progress: number;
16
+ };
17
+ highlights?: Highlight[];
18
+ /**
19
+ * Largest EPUB (bytes) that will be loaded. The whole book is held in memory while it is opened, so very large
20
+ * files can crash low-memory phones. Default 150 MB, 0 disables the check.
21
+ */
22
+ maxFileSize?: number;
23
+ /** Items added to the native text-selection menu. `onMenuAction` fires with the item key. */
24
+ menuItems?: {
25
+ label: string;
26
+ key: string;
27
+ }[];
28
+ onMenuAction?: (key: string, selection: SelectionEvent | null) => void;
29
+ onReady?: (info: {
30
+ metadata: BookMetadata;
31
+ rtl: boolean;
32
+ }) => void;
33
+ onToc?: (items: TocItem[]) => void;
34
+ onCover?: (dataUri: string) => void;
35
+ onRelocate?: (e: RelocateEvent) => void;
36
+ /** fired once the whole book has been indexed: cumulative character offset of every spine item */
37
+ onIndexed?: (info: {
38
+ totalLength: number;
39
+ cum: number[];
40
+ }) => void;
41
+ onSelection?: (e: SelectionEvent | null) => void;
42
+ onHighlightTap?: (id: string, rect: SelectionEvent['rect']) => void;
43
+ onTap?: () => void;
44
+ /** a page turn animation is starting (use it to play a sound) */
45
+ onPageTurn?: () => void;
46
+ /** a web or mail link was tapped (other schemes are never forwarded). Open it yourself, ideally after asking. */
47
+ onLink?: (href: string) => void;
48
+ /** an internal link (footnote, cross reference) is about to jump; `from` is where the reader was, so you can offer a way back */
49
+ onLinkJump?: (from: BookLocation) => void;
50
+ /** the reading direction changed (the user overrode it in the settings) */
51
+ onDirectionChange?: (rtl: boolean) => void;
52
+ onSearchResults?: (searchId: number, results: SearchResult[], done: boolean) => void;
53
+ onEndReached?: (edge: 'start' | 'end') => void;
54
+ onError?: (message: string, info: ReaderErrorInfo) => void;
55
+ }
56
+ export interface EpubReaderHandle {
57
+ next(): void;
58
+ prev(): void;
59
+ goTo(location: {
60
+ spine: number;
61
+ offset?: number;
62
+ fragment?: string;
63
+ } | {
64
+ progress: number;
65
+ }): void;
66
+ search(query: string, searchId: number): void;
67
+ cancelSearch(searchId?: number): void;
68
+ /** Jump to a search result and flash the match. */
69
+ showSearchResult(r: SearchResult): void;
70
+ clearSelection(): void;
71
+ /** Replace the running header / footer text drawn on the page. */
72
+ setLabels(header: string, footer: string): void;
73
+ }
74
+ /** Identity of a source: the explicit `key`, the uri, or a fingerprint sampled across the base64 data. */
75
+ export declare function sourceKeyOf(source: EpubSource): string;
76
+ export declare const EpubReader: React.ForwardRefExoticComponent<EpubReaderProps & React.RefAttributes<EpubReaderHandle>>;