wolfy-reader 0.1.0

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 (233) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +277 -0
  3. package/dist/core/book.d.ts +75 -0
  4. package/dist/core/book.d.ts.map +1 -0
  5. package/dist/core/book.js +2 -0
  6. package/dist/core/book.js.map +1 -0
  7. package/dist/core/errors.d.ts +17 -0
  8. package/dist/core/errors.d.ts.map +1 -0
  9. package/dist/core/errors.js +29 -0
  10. package/dist/core/errors.js.map +1 -0
  11. package/dist/core/format.d.ts +13 -0
  12. package/dist/core/format.d.ts.map +1 -0
  13. package/dist/core/format.js +2 -0
  14. package/dist/core/format.js.map +1 -0
  15. package/dist/core/graphemes.d.ts +36 -0
  16. package/dist/core/graphemes.d.ts.map +1 -0
  17. package/dist/core/graphemes.js +62 -0
  18. package/dist/core/graphemes.js.map +1 -0
  19. package/dist/core/index.d.ts +11 -0
  20. package/dist/core/index.d.ts.map +1 -0
  21. package/dist/core/index.js +6 -0
  22. package/dist/core/index.js.map +1 -0
  23. package/dist/core/lookup.d.ts +10 -0
  24. package/dist/core/lookup.d.ts.map +1 -0
  25. package/dist/core/lookup.js +16 -0
  26. package/dist/core/lookup.js.map +1 -0
  27. package/dist/core/open.d.ts +12 -0
  28. package/dist/core/open.d.ts.map +1 -0
  29. package/dist/core/open.js +23 -0
  30. package/dist/core/open.js.map +1 -0
  31. package/dist/core/position.d.ts +121 -0
  32. package/dist/core/position.d.ts.map +1 -0
  33. package/dist/core/position.js +327 -0
  34. package/dist/core/position.js.map +1 -0
  35. package/dist/core/reading-text.d.ts +77 -0
  36. package/dist/core/reading-text.d.ts.map +1 -0
  37. package/dist/core/reading-text.js +144 -0
  38. package/dist/core/reading-text.js.map +1 -0
  39. package/dist/core/source.d.ts +17 -0
  40. package/dist/core/source.d.ts.map +1 -0
  41. package/dist/core/source.js +39 -0
  42. package/dist/core/source.js.map +1 -0
  43. package/dist/core/storage.d.ts +7 -0
  44. package/dist/core/storage.d.ts.map +1 -0
  45. package/dist/core/storage.js +2 -0
  46. package/dist/core/storage.js.map +1 -0
  47. package/dist/core/text.d.ts +18 -0
  48. package/dist/core/text.d.ts.map +1 -0
  49. package/dist/core/text.js +32 -0
  50. package/dist/core/text.js.map +1 -0
  51. package/dist/formats/epub/href.d.ts +14 -0
  52. package/dist/formats/epub/href.d.ts.map +1 -0
  53. package/dist/formats/epub/href.js +52 -0
  54. package/dist/formats/epub/href.js.map +1 -0
  55. package/dist/formats/epub/index.d.ts +3 -0
  56. package/dist/formats/epub/index.d.ts.map +1 -0
  57. package/dist/formats/epub/index.js +223 -0
  58. package/dist/formats/epub/index.js.map +1 -0
  59. package/dist/formats/epub/opf.d.ts +27 -0
  60. package/dist/formats/epub/opf.d.ts.map +1 -0
  61. package/dist/formats/epub/opf.js +110 -0
  62. package/dist/formats/epub/opf.js.map +1 -0
  63. package/dist/formats/epub/toc.d.ts +6 -0
  64. package/dist/formats/epub/toc.d.ts.map +1 -0
  65. package/dist/formats/epub/toc.js +88 -0
  66. package/dist/formats/epub/toc.js.map +1 -0
  67. package/dist/formats/fb2/index.d.ts +13 -0
  68. package/dist/formats/fb2/index.d.ts.map +1 -0
  69. package/dist/formats/fb2/index.js +317 -0
  70. package/dist/formats/fb2/index.js.map +1 -0
  71. package/dist/formats/index.d.ts +4 -0
  72. package/dist/formats/index.d.ts.map +1 -0
  73. package/dist/formats/index.js +4 -0
  74. package/dist/formats/index.js.map +1 -0
  75. package/dist/formats/text/index.d.ts +11 -0
  76. package/dist/formats/text/index.d.ts.map +1 -0
  77. package/dist/formats/text/index.js +201 -0
  78. package/dist/formats/text/index.js.map +1 -0
  79. package/dist/formats/xml.d.ts +33 -0
  80. package/dist/formats/xml.d.ts.map +1 -0
  81. package/dist/formats/xml.js +321 -0
  82. package/dist/formats/xml.js.map +1 -0
  83. package/dist/index.d.ts +27 -0
  84. package/dist/index.d.ts.map +1 -0
  85. package/dist/index.js +28 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/layout/chunk.d.ts +51 -0
  88. package/dist/layout/chunk.d.ts.map +1 -0
  89. package/dist/layout/chunk.js +131 -0
  90. package/dist/layout/chunk.js.map +1 -0
  91. package/dist/layout/index.d.ts +238 -0
  92. package/dist/layout/index.d.ts.map +1 -0
  93. package/dist/layout/index.js +476 -0
  94. package/dist/layout/index.js.map +1 -0
  95. package/dist/reader/index.d.ts +231 -0
  96. package/dist/reader/index.d.ts.map +1 -0
  97. package/dist/reader/index.js +958 -0
  98. package/dist/reader/index.js.map +1 -0
  99. package/dist/reader/input.d.ts +69 -0
  100. package/dist/reader/input.d.ts.map +1 -0
  101. package/dist/reader/input.js +75 -0
  102. package/dist/reader/input.js.map +1 -0
  103. package/dist/search/extract.d.ts +51 -0
  104. package/dist/search/extract.d.ts.map +1 -0
  105. package/dist/search/extract.js +401 -0
  106. package/dist/search/extract.js.map +1 -0
  107. package/dist/search/index.d.ts +11 -0
  108. package/dist/search/index.d.ts.map +1 -0
  109. package/dist/search/index.js +11 -0
  110. package/dist/search/index.js.map +1 -0
  111. package/dist/search/matcher.d.ts +56 -0
  112. package/dist/search/matcher.d.ts.map +1 -0
  113. package/dist/search/matcher.js +128 -0
  114. package/dist/search/matcher.js.map +1 -0
  115. package/dist/search/normalize.d.ts +48 -0
  116. package/dist/search/normalize.d.ts.map +1 -0
  117. package/dist/search/normalize.js +103 -0
  118. package/dist/search/normalize.js.map +1 -0
  119. package/dist/view/allowlist.d.ts +59 -0
  120. package/dist/view/allowlist.d.ts.map +1 -0
  121. package/dist/view/allowlist.js +198 -0
  122. package/dist/view/allowlist.js.map +1 -0
  123. package/dist/view/appearance.d.ts +137 -0
  124. package/dist/view/appearance.d.ts.map +1 -0
  125. package/dist/view/appearance.js +274 -0
  126. package/dist/view/appearance.js.map +1 -0
  127. package/dist/view/css.d.ts +24 -0
  128. package/dist/view/css.d.ts.map +1 -0
  129. package/dist/view/css.js +153 -0
  130. package/dist/view/css.js.map +1 -0
  131. package/dist/view/frame.d.ts +54 -0
  132. package/dist/view/frame.d.ts.map +1 -0
  133. package/dist/view/frame.js +980 -0
  134. package/dist/view/frame.js.map +1 -0
  135. package/dist/view/host.d.ts +160 -0
  136. package/dist/view/host.d.ts.map +1 -0
  137. package/dist/view/host.js +385 -0
  138. package/dist/view/host.js.map +1 -0
  139. package/dist/view/index.d.ts +12 -0
  140. package/dist/view/index.d.ts.map +1 -0
  141. package/dist/view/index.js +7 -0
  142. package/dist/view/index.js.map +1 -0
  143. package/dist/view/protocol.d.ts +220 -0
  144. package/dist/view/protocol.d.ts.map +1 -0
  145. package/dist/view/protocol.js +246 -0
  146. package/dist/view/protocol.js.map +1 -0
  147. package/dist/view/reference.d.ts +18 -0
  148. package/dist/view/reference.d.ts.map +1 -0
  149. package/dist/view/reference.js +25 -0
  150. package/dist/view/reference.js.map +1 -0
  151. package/dist/view/resources.d.ts +51 -0
  152. package/dist/view/resources.d.ts.map +1 -0
  153. package/dist/view/resources.js +242 -0
  154. package/dist/view/resources.js.map +1 -0
  155. package/dist/view/sanitize.d.ts +32 -0
  156. package/dist/view/sanitize.d.ts.map +1 -0
  157. package/dist/view/sanitize.js +226 -0
  158. package/dist/view/sanitize.js.map +1 -0
  159. package/dist/zip/central.d.ts +12 -0
  160. package/dist/zip/central.d.ts.map +1 -0
  161. package/dist/zip/central.js +72 -0
  162. package/dist/zip/central.js.map +1 -0
  163. package/dist/zip/crc32.d.ts +3 -0
  164. package/dist/zip/crc32.d.ts.map +1 -0
  165. package/dist/zip/crc32.js +28 -0
  166. package/dist/zip/crc32.js.map +1 -0
  167. package/dist/zip/eocd.d.ts +9 -0
  168. package/dist/zip/eocd.d.ts.map +1 -0
  169. package/dist/zip/eocd.js +84 -0
  170. package/dist/zip/eocd.js.map +1 -0
  171. package/dist/zip/errors.d.ts +19 -0
  172. package/dist/zip/errors.d.ts.map +1 -0
  173. package/dist/zip/errors.js +37 -0
  174. package/dist/zip/errors.js.map +1 -0
  175. package/dist/zip/index.d.ts +18 -0
  176. package/dist/zip/index.d.ts.map +1 -0
  177. package/dist/zip/index.js +78 -0
  178. package/dist/zip/index.js.map +1 -0
  179. package/dist/zip/inflate.d.ts +2 -0
  180. package/dist/zip/inflate.d.ts.map +1 -0
  181. package/dist/zip/inflate.js +43 -0
  182. package/dist/zip/inflate.js.map +1 -0
  183. package/dist/zip/source.d.ts +15 -0
  184. package/dist/zip/source.d.ts.map +1 -0
  185. package/dist/zip/source.js +34 -0
  186. package/dist/zip/source.js.map +1 -0
  187. package/package.json +75 -0
  188. package/src/core/book.ts +80 -0
  189. package/src/core/errors.ts +31 -0
  190. package/src/core/format.ts +14 -0
  191. package/src/core/graphemes.ts +73 -0
  192. package/src/core/index.ts +27 -0
  193. package/src/core/lookup.ts +16 -0
  194. package/src/core/open.ts +31 -0
  195. package/src/core/position.ts +485 -0
  196. package/src/core/reading-text.ts +200 -0
  197. package/src/core/source.ts +61 -0
  198. package/src/core/storage.ts +6 -0
  199. package/src/core/text.ts +35 -0
  200. package/src/formats/epub/href.ts +54 -0
  201. package/src/formats/epub/index.ts +235 -0
  202. package/src/formats/epub/opf.ts +143 -0
  203. package/src/formats/epub/toc.ts +120 -0
  204. package/src/formats/fb2/index.ts +348 -0
  205. package/src/formats/index.ts +3 -0
  206. package/src/formats/text/index.ts +208 -0
  207. package/src/formats/xml.ts +326 -0
  208. package/src/index.ts +26 -0
  209. package/src/layout/chunk.ts +169 -0
  210. package/src/layout/index.ts +573 -0
  211. package/src/reader/index.ts +1206 -0
  212. package/src/reader/input.ts +122 -0
  213. package/src/search/extract.ts +403 -0
  214. package/src/search/index.ts +10 -0
  215. package/src/search/matcher.ts +187 -0
  216. package/src/search/normalize.ts +122 -0
  217. package/src/view/allowlist.ts +273 -0
  218. package/src/view/appearance.ts +380 -0
  219. package/src/view/css.ts +172 -0
  220. package/src/view/frame.ts +1018 -0
  221. package/src/view/host.ts +527 -0
  222. package/src/view/index.ts +24 -0
  223. package/src/view/protocol.ts +412 -0
  224. package/src/view/reference.ts +30 -0
  225. package/src/view/resources.ts +265 -0
  226. package/src/view/sanitize.ts +266 -0
  227. package/src/zip/central.ts +85 -0
  228. package/src/zip/crc32.ts +30 -0
  229. package/src/zip/eocd.ts +97 -0
  230. package/src/zip/errors.ts +41 -0
  231. package/src/zip/index.ts +114 -0
  232. package/src/zip/inflate.ts +41 -0
  233. package/src/zip/source.ts +51 -0
@@ -0,0 +1,231 @@
1
+ /**
2
+ * The public reader facade: opens a decoded {@link Book} into a container element
3
+ * and returns a {@link Reader} that turns pages and sections, navigates to any
4
+ * target, follows internal links with a back-stack, reports position, emits
5
+ * events, and switches paginated↔scrolled without losing the reader's place.
6
+ *
7
+ * This module lives *outside* `src/core` on purpose. Core is headless by rule —
8
+ * nothing reachable from `src/core/index.ts` may import `src/view` or `src/layout`
9
+ * (`npm run check:core`). The PLAN §4 sketch shows `book.render(...)`; that method
10
+ * cannot exist on the core `Book`, so the shape is relocated here as a free
11
+ * function `render(book, element, options)` keeping the sketched object surface
12
+ * (`next/prev`, `nextSection/prevSection`, `goTo`, `back`, `position`, `on`,
13
+ * `setMode`, `destroy`).
14
+ *
15
+ * The facade owns no format vocabulary and never fetches or persists: bytes came
16
+ * in as a `Book`, page geometry comes from the {@link Paginator}, and reading
17
+ * positions are the headless `Position` model from core. It drives the paginator
18
+ * and reads the book; it never reaches past the paginator into frame geometry.
19
+ */
20
+ import type { Book, Position, SentenceRange, TocItem } from '../core/index.ts';
21
+ import { parsePosition } from '../core/index.ts';
22
+ import { type LayoutMode } from '../layout/index.ts';
23
+ import { type SearchHit, type SearchOptions } from '../search/index.ts';
24
+ import { type Appearance, type TextAlign, type ThemeName } from '../view/appearance.ts';
25
+ import { type InputConfig } from './input.ts';
26
+ export type { InputConfig, TapZones } from './input.ts';
27
+ export type { Appearance, TextAlign, ThemeName } from '../view/appearance.ts';
28
+ export type { SearchHit, SearchOptions } from '../search/index.ts';
29
+ /**
30
+ * Appearance and layout options for {@link render}. All optional. `mode` selects
31
+ * paginated (default) or scrolled layout. The theme and typography fields drive
32
+ * the appearance system and are applied at the first render; change any of them
33
+ * live afterward with {@link Reader.setAppearance}.
34
+ */
35
+ export interface ReaderOptions {
36
+ /** 'paginated' (default) or 'scrolled'. */
37
+ readonly mode?: LayoutMode;
38
+ /**
39
+ * The theme applied to content: `'light' | 'dark' | 'sepia' | 'custom'`. Omit
40
+ * to follow the OS (`prefers-color-scheme`); a named theme overrides it. Change
41
+ * it live with {@link Reader.setAppearance}.
42
+ */
43
+ readonly theme?: ThemeName;
44
+ /**
45
+ * Bespoke `--wr-*` CSS custom properties, merged over the resolved theme. The
46
+ * escape hatch for a custom theme; keys may omit the leading `--`.
47
+ */
48
+ readonly customProperties?: Readonly<Record<string, string>>;
49
+ /** Body font size in CSS px. Applied at the first render; change it live with {@link Reader.setAppearance}. */
50
+ readonly fontSize?: number;
51
+ /** Body font family. Applied at the first render. */
52
+ readonly fontFamily?: string;
53
+ /** Body line height (unitless multiplier). Applied at the first render. */
54
+ readonly lineHeight?: number;
55
+ /** Page-edge margin in CSS px (also the inter-column gutter), threaded to the paginator as `columnGap`. */
56
+ readonly margin?: number;
57
+ /** Body text alignment: `'start'` (publisher default) or `'justify'`. */
58
+ readonly textAlign?: TextAlign;
59
+ /** Shorthand for `textAlign: 'justify'`. */
60
+ readonly justify?: boolean;
61
+ /** Whether the content root hyphenates. */
62
+ readonly hyphenate?: boolean;
63
+ /** Text columns per page: 1 (default) or 2. Applied at the first render. */
64
+ readonly columns?: 1 | 2;
65
+ /** Where to open. Any {@link GoToTarget}; defaults to the book's start. */
66
+ readonly start?: GoToTarget;
67
+ /**
68
+ * Human-input configuration: keyboard, swipe, tap zones. Additive and optional
69
+ * — omitting it enables all three with defaults. See {@link InputConfig}. Input
70
+ * is direction-aware: `Book.direction === 'rtl'` flips the horizontal axis.
71
+ */
72
+ readonly input?: InputConfig;
73
+ }
74
+ /**
75
+ * A navigation target for {@link Reader.goTo}. Six forms:
76
+ * - {@link TocItem} — its `sectionId` (+ optional `fragment`)
77
+ * - internal `href` string — resolved to a section (+ fragment), best-effort
78
+ * - {@link Position} — restored by content anchor
79
+ * - a number in `0..1` — a fraction through the whole book
80
+ * - `'start'` — the first section, first page
81
+ * - `'end'` — the last section, last page
82
+ */
83
+ export type GoToTarget = TocItem | Position | string | number | 'start' | 'end';
84
+ /** The reader's place in the book, assembled from the paginator and the book. */
85
+ export interface ReaderPosition {
86
+ /** 0-based index of the active section in reading order. */
87
+ readonly section: number;
88
+ /** Fraction through the whole book, 0..1 — approximate across unlaid sections. */
89
+ readonly progress: number;
90
+ /** Fraction through the current chapter, 0..1. */
91
+ readonly chapterProgress: number;
92
+ /** 0-based current page within the section. */
93
+ readonly page: number;
94
+ /** Total pages in the section — an estimate until the layout is firm. */
95
+ readonly totalPages: number;
96
+ }
97
+ /** The events a {@link Reader} emits, with their payload types. */
98
+ export interface ReaderEventMap {
99
+ /** Fires once, after the first section paints. Payload: the initial position. */
100
+ readonly ready: ReaderPosition;
101
+ /** Fires after any navigation settles. Payload: the settled position. */
102
+ readonly positionchange: ReaderPosition;
103
+ /** Fires when the active section changes. Payload: the new section index + id. */
104
+ readonly sectionchange: SectionChange;
105
+ /** Fires when an in-frame link is clicked, before it is followed. Payload: the raw href. */
106
+ readonly linkclick: LinkClick;
107
+ /** Fires when the user selects text in the frame. Payload: the text + a resolvable Position. */
108
+ readonly selection: SelectionEvent;
109
+ /** Fires when a navigation or render fails. Payload: the error. */
110
+ readonly error: Error;
111
+ }
112
+ export interface SectionChange {
113
+ /** 0-based index of the now-active section. */
114
+ readonly index: number;
115
+ /** The now-active section's id. */
116
+ readonly sectionId: string;
117
+ }
118
+ export interface LinkClick {
119
+ /** The raw authored href from the frame, exactly as reported. */
120
+ readonly href: string;
121
+ }
122
+ export interface SelectionEvent {
123
+ /** The selected text, exactly as the frame read it. */
124
+ readonly text: string;
125
+ /**
126
+ * A `Position` anchored at the selection's start. Resolves back against the
127
+ * section via {@link Reader.goTo}/`resolvePosition`, so a host can persist it
128
+ * (a bookmark or highlight anchor) and navigate to it later.
129
+ */
130
+ readonly position: Position;
131
+ }
132
+ export type ReaderEvent = keyof ReaderEventMap;
133
+ export type ReaderEventHandler<E extends ReaderEvent> = (payload: ReaderEventMap[E]) => void;
134
+ /** Removes a previously-registered handler. Idempotent. */
135
+ export type Unsubscribe = () => void;
136
+ /**
137
+ * A live reader over one book. Navigation methods are async and settle once the
138
+ * paginator has moved and the corresponding events have fired. Reads of
139
+ * {@link position} are synchronous snapshots of the last settled state.
140
+ */
141
+ export interface Reader {
142
+ /** Turn one page forward, rolling to the next section's first page at the end. */
143
+ next(): Promise<void>;
144
+ /** Turn one page back, rolling to the previous section's last page at the start. */
145
+ prev(): Promise<void>;
146
+ /** Jump to the next section's first page. No-op at the last section. */
147
+ nextSection(): Promise<void>;
148
+ /** Jump to the previous section's first page. No-op at the first section. */
149
+ prevSection(): Promise<void>;
150
+ /** Navigate to any of the six {@link GoToTarget} forms. Soft-misses degrade quietly. */
151
+ goTo(target: GoToTarget): Promise<void>;
152
+ /** Pop the internal-link back-stack and restore the pushed position. No-op when empty. */
153
+ back(): Promise<void>;
154
+ /** Switch paginated↔scrolled without reload, preserving the reading position. */
155
+ setMode(mode: LayoutMode): Promise<void>;
156
+ /**
157
+ * Update the live appearance without losing the reading place. Covers the theme
158
+ * half (colours / background) and the typography half (font family/size, line
159
+ * height, margin, text alignment, justification, hyphenation, 1-or-2 columns).
160
+ * Partial: only the fields present in `appearance` change; `customProperties`
161
+ * shallow-merges over the current set. A colour-only change repaints the current
162
+ * page in place with no reflow; a reflowing typography knob (font, size, line
163
+ * height, columns) re-lays out and restores the reading place by content anchor,
164
+ * so the place survives even though the page number may shift.
165
+ */
166
+ setAppearance(appearance: Appearance): Promise<void>;
167
+ /**
168
+ * Full-text search over the whole book. Returns a **lazy async iterator** of
169
+ * {@link SearchHit}s, streaming each as its section is scanned — the book is never
170
+ * buffered whole, and stopping early (`break`) halts the scan (no later section is
171
+ * loaded). Each hit's `position` is jumpable: `await reader.goTo(hit.position)`
172
+ * lands on its page. Matching is normalized literal substring (case-insensitive,
173
+ * NFC, smart-punctuation- and whitespace-folded); it does not route through the
174
+ * frame — sections are decoded and scanned headlessly, independent of what is
175
+ * painted.
176
+ */
177
+ search(query: string, options?: SearchOptions): AsyncIterableIterator<SearchHit>;
178
+ /**
179
+ * Draws a decoration — a styled overlay — over the range `position` resolves to,
180
+ * keyed by `id`. Re-issuing the same `id` replaces that overlay; the `className`
181
+ * on `opts` is applied to every overlay box so a host stylesheet can colour it.
182
+ *
183
+ * **Draw-only, never stored.** The reader holds the decoration *intent* (id →
184
+ * position + class) in memory only, so it can re-anchor the overlay across a
185
+ * re-layout (font-size, mode, appearance) — it never persists, serializes, or
186
+ * fetches annotation data. A host owns all annotation storage: to make a highlight
187
+ * durable, persist the `position` (or its serialized string) yourself and re-call
188
+ * `decorate` on the next open. The overlay is pointer-transparent and layout-
189
+ * neutral: it never eats a selection or a click and never changes page geometry.
190
+ *
191
+ * A soft-miss — the anchor no longer resolves, or it belongs to a section other
192
+ * than the one on screen — draws nothing and throws nothing; the intent is kept, so
193
+ * navigating to that section (or re-laying out) redraws it.
194
+ */
195
+ decorate(id: string, position: Position, opts: {
196
+ className: string;
197
+ }): Promise<void>;
198
+ /** Removes the decoration drawn for `id` and drops its intent. No-op for an unknown id. */
199
+ undecorate(id: string): Promise<void>;
200
+ /**
201
+ * Sentence ranges for the current section, each with a `Position` anchored over
202
+ * the whole sentence. The **TTS enabler**: pair a sentence's `position` with
203
+ * {@link goTo} to jump and {@link decorate} to highlight it, and a host can step
204
+ * a speech engine sentence-by-sentence over the reading view. The library speaks
205
+ * nothing and stores nothing — it exposes ranges only. Returns `[]` before the
206
+ * first paint or for an empty section.
207
+ */
208
+ sentences(): Promise<readonly SentenceRange[]>;
209
+ /** A synchronous snapshot of the current place in the book. */
210
+ readonly position: ReaderPosition;
211
+ /** The layout mode currently in effect. */
212
+ readonly mode: LayoutMode;
213
+ /** Subscribe to an event; returns an unsubscribe function. */
214
+ on<E extends ReaderEvent>(event: E, handler: ReaderEventHandler<E>): Unsubscribe;
215
+ /** Tear everything down: paginator, frame, data: URLs, listeners, back-stack. Idempotent. */
216
+ destroy(): void;
217
+ }
218
+ /** Something went wrong driving the reader; never a book decoding failure. */
219
+ export declare class ReaderError extends Error {
220
+ constructor(message: string, options?: ErrorOptions);
221
+ }
222
+ /**
223
+ * Renders `book` into `element` and returns a live {@link Reader}. The reader is
224
+ * usable immediately; the first section paints asynchronously and a `ready` event
225
+ * fires once it does. Options are applied where they map today and otherwise
226
+ * retained for M3. Pass `options.start` to open somewhere other than the book's
227
+ * beginning.
228
+ */
229
+ export declare function render(book: Book, element: HTMLElement, options?: ReaderOptions): Reader;
230
+ export { parsePosition };
231
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reader/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAA6B,aAAa,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC1G,OAAO,EAAE,aAAa,EAAoB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACnF,OAAO,EAAc,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACpF,OAAO,EAIL,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAIL,KAAK,WAAW,EAGjB,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACxD,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC9E,YAAY,EAAE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