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 @@
1
+ {"version":3,"file":"frame.js","sourceRoot":"","sources":["../../src/view/frame.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,CAAC,MAAM,eAAe,GAAG,sBAAsB,CAAC;AAEtD,iFAAiF;AACjF,MAAM,CAAC,MAAM,WAAW,GAAG,oBAAoB,CAAC;AAChD,kFAAkF;AAClF,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AACnD,kEAAkE;AAClE,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAC/C,oDAAoD;AACpD,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAEnD,0FAA0F;AAC1F,MAAM,CAAC,MAAM,gBAAgB,GAAG,yBAAyB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,SAAS,GAAG;IAChB,6BAA6B;IAC7B,0CAA0C;IAC1C,gBAAgB;IAChB,qCAAqC;IACrC,kFAAkF;IAClF,qFAAqF;IACrF,sFAAsF;IACtF,iFAAiF;IACjF,IAAI,gBAAgB,gGAAgG;CACrH,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAEX;;;;;;;;;;;;;;GAcG;AACH,SAAS,qBAAqB,CAAC,KAAa;IAC1C,OAAO;QACL,oBAAoB;QACpB,qBAAqB,KAAK,GAAG;QAC7B,iCAAiC;QACjC,eAAe;QACf,gBAAgB;QAChB,oBAAoB;QACpB,oBAAoB;QACpB,iBAAiB;KAClB,CAAC,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,cAAc,KAAK,GAAG,KAAK,KAAK,CAAC,IAAI,QAAQ,CAClF,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACxB,CAAC;AAwBD,MAAM,UAAU,qBAAqB,CAAC,KAAyB;IAC7D,8EAA8E;IAC9E,4EAA4E;IAC5E,8DAA8D;IAC9D,EAAE;IACF,8EAA8E;IAC9E,8EAA8E;IAC9E,gFAAgF;IAChF,+BAA+B;IAC/B,OAAO;QACL,iBAAiB;QACjB,QAAQ;QACR,QAAQ;QACR,uDAAuD,kBAAkB,CAAC,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI;QACjH,wBAAwB;QACxB,kBAAkB,KAAK,CAAC,KAAK,KAAK,kBAAkB,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,WAAW,KAAK,KAAK,CAAC,WAAW;QAC9G,UAAU,SAAS,UAAU;QAC7B,GAAG,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,IAAI,KAAK,CAAC,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,KAAK,CAAC,QAAQ,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACtG,KAAK,CAAC,QAAQ;QACd,SAAS;QACT,QAAQ;QACR,YAAY,eAAe,IAAI;QAC/B,KAAK,CAAC,QAAQ;QACd,QAAQ;QACR,SAAS;QACT,SAAS;KACV,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,160 @@
1
+ import type { Section } from '../core/index.ts';
2
+ import { type Measurement, type PaginateOptions, type PaginationState } from './protocol.ts';
3
+ import { type ResourceSummary } from './resources.ts';
4
+ import { type SanitizationSummary } from './sanitize.ts';
5
+ /** Something went wrong hosting content; never a book decoding failure. */
6
+ export declare class ContentHostError extends Error {
7
+ constructor(message: string, options?: ErrorOptions);
8
+ }
9
+ export interface ViolationReport {
10
+ readonly directive: string;
11
+ readonly blockedUri: string;
12
+ }
13
+ export interface ContentHostOptions {
14
+ readonly onViolation?: (report: ViolationReport) => void;
15
+ readonly onError?: (message: string) => void;
16
+ /** An internal link was clicked in the frame; carries the raw authored href. */
17
+ readonly onLinkClick?: (href: string) => void;
18
+ /**
19
+ * A navigation-relevant keydown fired in the frame; carries the
20
+ * `KeyboardEvent.key`, except Space, which arrives as the normalized tokens
21
+ * `'Space'` / `'Shift+Space'` (the key is `' '` for both and the wire carries
22
+ * no modifier field).
23
+ */
24
+ readonly onKey?: (key: string) => void;
25
+ /** A completed horizontal swipe in the frame; carries the net delta in CSS px. */
26
+ readonly onSwipe?: (dx: number, dy: number) => void;
27
+ /** A tap in the frame that was not on a link; carries tap coords + frame viewport size. */
28
+ readonly onTap?: (tap: {
29
+ x: number;
30
+ y: number;
31
+ width: number;
32
+ height: number;
33
+ }) => void;
34
+ /**
35
+ * A tap on a book image in the frame (not a link, not a page-turn). Carries the
36
+ * image's already-substituted `data:` URL and its `alt`, so a host can open a
37
+ * zoom overlay over the same full-resolution bytes. Never a `blob:` URL.
38
+ */
39
+ readonly onImageTap?: (image: {
40
+ src: string;
41
+ alt: string;
42
+ }) => void;
43
+ /**
44
+ * A completed text selection in the frame; carries the selected text and its
45
+ * UTF-16 offset range over the section text (`sectionText`). Empty and collapsed
46
+ * selections are dropped in the frame and never reach here.
47
+ */
48
+ readonly onSelection?: (selection: {
49
+ start: number;
50
+ end: number;
51
+ text: string;
52
+ }) => void;
53
+ /**
54
+ * The appearance theme stylesheet injected at document assembly (see
55
+ * {@link themeStyleSheet}). Applied to every render; update it live with
56
+ * {@link ContentHost.setThemeCss} and re-render. Omit for an unthemed frame.
57
+ */
58
+ readonly themeCss?: string;
59
+ /**
60
+ * Whether the consumer acts on the nav keydowns the frame forwards (`onKey`).
61
+ * Baked into the coordination script at document assembly — not a wire
62
+ * message, so no protocol change. When `false` the frame still forwards nav
63
+ * keys (the wire is unconditional) but stops `preventDefault`ing them, so a
64
+ * key the host will ignore keeps its default action. Defaults to `true`.
65
+ */
66
+ readonly keyboardNav?: boolean;
67
+ /** How long the frame has to answer, in milliseconds. Defaults to 10000. */
68
+ readonly timeoutMs?: number;
69
+ }
70
+ export interface RenderReport {
71
+ readonly sectionId: string;
72
+ /**
73
+ * The section's own `scripted` declaration. Diagnostic only: it is an author
74
+ * declaration, not a detection, so nothing in the pipeline depends on it.
75
+ */
76
+ readonly declaredScripted: boolean;
77
+ readonly sanitization: SanitizationSummary;
78
+ readonly resources: ResourceSummary;
79
+ }
80
+ /**
81
+ * Renders decoded sections as live markup inside a hardened sandboxed frame.
82
+ *
83
+ * Three independent defences, none of them redundant. The sandbox denies reach:
84
+ * without `allow-same-origin` the document has an opaque origin and cannot see
85
+ * the host page, its cookies or its storage. Sanitization denies execution:
86
+ * `allow-scripts` is granted to the document, not to a party, so book script
87
+ * would run under the same grant as the coordination script — and could then
88
+ * impersonate it on this very message channel, which no sandbox can prevent.
89
+ * CSP denies egress: nothing may be fetched at all except the `data:` resources
90
+ * this host minted, which reach nothing.
91
+ */
92
+ export declare class ContentHost {
93
+ #private;
94
+ readonly frame: HTMLIFrameElement;
95
+ constructor(container: HTMLElement, options?: ContentHostOptions);
96
+ render(section: Section): Promise<RenderReport>;
97
+ /**
98
+ * Sets the theme stylesheet injected at the next document assembly. Does not
99
+ * re-render on its own — the caller re-renders (or re-paginates) to apply it.
100
+ * The theme lands in the srcdoc, not over the wire, so this changes no protocol.
101
+ */
102
+ setThemeCss(themeCss: string | undefined): void;
103
+ /** The theme stylesheet currently applied to renders, or `undefined`. */
104
+ get themeCss(): string | undefined;
105
+ /**
106
+ * Renders a section chunked for pagination: each top-level chunk becomes its
107
+ * own container element carrying the character range it covers, so the frame
108
+ * can build a per-chunk multi-column context and map pages to offsets. The
109
+ * sanitize + resources pipeline is identical to {@link render}; only the body
110
+ * assembly differs. Call {@link paginate} afterward to lay it out.
111
+ */
112
+ renderChunked(section: Section, chunkChars?: number): Promise<RenderReport>;
113
+ /**
114
+ * Lays the currently-rendered chunked section out under `options` and returns
115
+ * the resulting pagination state. In paginated mode each chunk becomes an
116
+ * absolutely-positioned multi-column context and the page count is the sum of
117
+ * per-chunk page counts; in scrolled mode chunks stack with no paging. Requires
118
+ * a prior {@link renderChunked}.
119
+ */
120
+ paginate(section: Section, options: PaginateOptions): Promise<PaginationState>;
121
+ /** Re-measures the current layout (e.g. after a viewport or typography change). */
122
+ relayout(): Promise<PaginationState>;
123
+ /** Scrolls to a page (0-based). Returns the page actually shown after clamping. */
124
+ goToPage(page: number): Promise<number>;
125
+ /** Character offset of the first glyph painted on a page, or -1 if none. */
126
+ offsetOfPage(page: number): Promise<number>;
127
+ /**
128
+ * Character offset of the element carrying `elementId` into the section text,
129
+ * or -1 if no element carries the id. The seam behind fragment anchoring.
130
+ */
131
+ offsetOfElementId(elementId: string): Promise<number>;
132
+ /** The page (0-based) painting the glyph at a section-text character offset. */
133
+ pageOfOffset(offset: number): Promise<number>;
134
+ /** The section's concatenated chunk text, as the frame measures it. */
135
+ sectionText(): Promise<string>;
136
+ /** Frame-side counts for eviction/memory checks. */
137
+ diagnostics(): Promise<{
138
+ domNodes: number;
139
+ realizedChunks: number;
140
+ totalChunks: number;
141
+ }>;
142
+ /**
143
+ * Draws a decoration over the section-text UTF-16 offset range `[start, end)`:
144
+ * the frame maps the range to client rects and paints pointer-transparent,
145
+ * layout-neutral overlay boxes carrying `className`. Re-issuing the same
146
+ * `decorationId` replaces that overlay. Returns the number of boxes painted — 0
147
+ * on a soft-miss (the range is not in the realized section text, or its rects are
148
+ * empty); a soft-miss draws nothing and is not an error.
149
+ */
150
+ decorate(decorationId: string, start: number, end: number, className: string): Promise<number>;
151
+ /** Removes the decoration painted for `decorationId`, leaving nothing behind. */
152
+ undecorate(decorationId: string): Promise<void>;
153
+ /** Content size as the frame measures it. */
154
+ measure(): Promise<Measurement>;
155
+ /** Round-trips the protocol; the cheapest proof the channel is live. */
156
+ ping(): Promise<void>;
157
+ /** Releases this render's resources and removes the frame. */
158
+ destroy(): void;
159
+ }
160
+ //# sourceMappingURL=host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/view/host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGhD,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACxF,OAAO,EAAmB,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAG1E,2EAA2E;AAC3E,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,EAGlD;CACF;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IACzD,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,gFAAgF;IAChF,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,kFAAkF;IAClF,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,2FAA2F;IAC3F,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE;QAAE,CAAC,EA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AAwE;IAClE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAE1B;IAED,8DAA8D;IAC9D,OAAO,IAAI,IAAI,CAcd;CA0DF"}
@@ -0,0 +1,385 @@
1
+ import { chunkElement } from '../layout/chunk.js';
2
+ import { assembleChunkedBody, assembleFrameDocument, createNonce } from './frame.js';
3
+ import { asFrameMessage, PROTOCOL_VERSION, } from './protocol.js';
4
+ import { applyResources, ResourceRegistry } from './resources.js';
5
+ import { sanitizeSection } from './sanitize.js';
6
+ import { decodeText } from '../core/text.js';
7
+ /** Something went wrong hosting content; never a book decoding failure. */
8
+ export class ContentHostError extends Error {
9
+ constructor(message, options) {
10
+ super(message, options);
11
+ this.name = 'ContentHostError';
12
+ }
13
+ }
14
+ const DEFAULT_TIMEOUT_MS = 10_000;
15
+ /**
16
+ * Renders decoded sections as live markup inside a hardened sandboxed frame.
17
+ *
18
+ * Three independent defences, none of them redundant. The sandbox denies reach:
19
+ * without `allow-same-origin` the document has an opaque origin and cannot see
20
+ * the host page, its cookies or its storage. Sanitization denies execution:
21
+ * `allow-scripts` is granted to the document, not to a party, so book script
22
+ * would run under the same grant as the coordination script — and could then
23
+ * impersonate it on this very message channel, which no sandbox can prevent.
24
+ * CSP denies egress: nothing may be fetched at all except the `data:` resources
25
+ * this host minted, which reach nothing.
26
+ */
27
+ export class ContentHost {
28
+ frame;
29
+ #window;
30
+ #options;
31
+ #pending = new Map();
32
+ #cache = null;
33
+ #ready = null;
34
+ #nextId = 1;
35
+ #generation = 0;
36
+ #destroyed = false;
37
+ /** The theme stylesheet injected at document assembly; updated live by the facade. */
38
+ #themeCss;
39
+ #receive = (event) => {
40
+ // The frame's origin is 'null' under an opaque origin, so origin checking
41
+ // authenticates nothing. Identity comes from the source window; meaning
42
+ // comes from validation. Anything else is ignored, never dispatched.
43
+ if (event.source === null || event.source !== this.frame.contentWindow)
44
+ return;
45
+ const message = asFrameMessage(event.data);
46
+ if (message === null)
47
+ return;
48
+ switch (message.type) {
49
+ case 'ready':
50
+ this.#ready?.();
51
+ return;
52
+ case 'violation':
53
+ this.#options.onViolation?.({ directive: message.directive, blockedUri: message.blockedUri });
54
+ return;
55
+ case 'error':
56
+ this.#options.onError?.(message.message);
57
+ return;
58
+ case 'linkclick':
59
+ this.#options.onLinkClick?.(message.href);
60
+ return;
61
+ case 'key':
62
+ this.#options.onKey?.(message.key);
63
+ return;
64
+ case 'swipe':
65
+ this.#options.onSwipe?.(message.dx, message.dy);
66
+ return;
67
+ case 'tap':
68
+ this.#options.onTap?.({ x: message.x, y: message.y, width: message.width, height: message.height });
69
+ return;
70
+ case 'imagetap':
71
+ this.#options.onImageTap?.({ src: message.src, alt: message.alt });
72
+ return;
73
+ case 'selection':
74
+ this.#options.onSelection?.({ start: message.start, end: message.end, text: message.text });
75
+ return;
76
+ case 'pong':
77
+ case 'measured':
78
+ case 'paginated':
79
+ case 'movedToPage':
80
+ case 'offset':
81
+ case 'page':
82
+ case 'text':
83
+ case 'decorated':
84
+ case 'diagnosticsReport': {
85
+ const pending = this.#pending.get(message.id);
86
+ if (pending === undefined)
87
+ return;
88
+ this.#pending.delete(message.id);
89
+ clearTimeout(pending.timer);
90
+ pending.settle(message);
91
+ return;
92
+ }
93
+ }
94
+ };
95
+ constructor(container, options = {}) {
96
+ this.#options = options;
97
+ this.#themeCss = options.themeCss;
98
+ const view = container.ownerDocument.defaultView;
99
+ if (view === null)
100
+ throw new ContentHostError('the container is not in a rendered document');
101
+ this.#window = view;
102
+ const frame = container.ownerDocument.createElement('iframe');
103
+ // Set before insertion. A frame that reaches the document without its
104
+ // sandbox attribute has already had one unsandboxed document.
105
+ frame.setAttribute('sandbox', 'allow-scripts');
106
+ frame.setAttribute('referrerpolicy', 'no-referrer');
107
+ frame.setAttribute('title', 'book content');
108
+ frame.style.display = 'block';
109
+ frame.style.border = '0';
110
+ frame.style.width = '100%';
111
+ frame.style.height = '100%';
112
+ container.append(frame);
113
+ this.frame = frame;
114
+ view.addEventListener('message', this.#receive);
115
+ }
116
+ async render(section) {
117
+ return this.#renderSection(section, 'plain', (document) => document.body.innerHTML);
118
+ }
119
+ /**
120
+ * Sets the theme stylesheet injected at the next document assembly. Does not
121
+ * re-render on its own — the caller re-renders (or re-paginates) to apply it.
122
+ * The theme lands in the srcdoc, not over the wire, so this changes no protocol.
123
+ */
124
+ setThemeCss(themeCss) {
125
+ this.#themeCss = themeCss;
126
+ }
127
+ /** The theme stylesheet currently applied to renders, or `undefined`. */
128
+ get themeCss() {
129
+ return this.#themeCss;
130
+ }
131
+ /**
132
+ * Renders a section chunked for pagination: each top-level chunk becomes its
133
+ * own container element carrying the character range it covers, so the frame
134
+ * can build a per-chunk multi-column context and map pages to offsets. The
135
+ * sanitize + resources pipeline is identical to {@link render}; only the body
136
+ * assembly differs. Call {@link paginate} afterward to lay it out.
137
+ */
138
+ async renderChunked(section, chunkChars) {
139
+ return this.#renderSection(section, `chunked@${chunkChars ?? 'default'}`, (document) => {
140
+ const { chunks } = chunkElement(document.body, chunkChars);
141
+ return assembleChunkedBody(chunks.map((chunk) => ({ html: chunk.html, chars: chunk.chars })));
142
+ });
143
+ }
144
+ /**
145
+ * The shared render path: bump the generation, obtain the section-invariant
146
+ * render inputs (from the cache when the same section renders again — a
147
+ * reflow — or by running the sanitize + resources pipeline), then hand the
148
+ * sanitized document's body to `buildBody` to produce the frame body markup.
149
+ * `render` passes it through verbatim; `renderChunked` re-wraps it in chunk
150
+ * containers; both memoize their output under `bodyKey`. The CSP nonce is
151
+ * minted fresh for every assembly regardless of cache hits.
152
+ */
153
+ async #renderSection(section, bodyKey, buildBody) {
154
+ if (this.#destroyed)
155
+ throw new ContentHostError('the host has been destroyed');
156
+ const generation = (this.#generation += 1);
157
+ let cache = this.#cache;
158
+ if (cache === null || cache.section !== section) {
159
+ // A different section: the outgoing section's inputs are invalidated and
160
+ // its registry released before anything new is built.
161
+ this.#cache?.registry.release();
162
+ this.#cache = null;
163
+ const source = decodeText(await section.load());
164
+ this.#checkGeneration(generation);
165
+ // Sanitization is unconditional. Section.scripted is an author declaration
166
+ // that a hostile book simply omits, so gating on it would skip exactly the
167
+ // files that need it most.
168
+ const sanitized = sanitizeSection(source, section.mediaType);
169
+ const registry = new ResourceRegistry(section.resolve?.bind(section));
170
+ let resources;
171
+ try {
172
+ resources = await applyResources(sanitized.document, registry);
173
+ // Checked before the cache is written, so a superseded render can never
174
+ // clobber the cache a later render installed.
175
+ this.#checkGeneration(generation);
176
+ }
177
+ catch (error) {
178
+ registry.release();
179
+ throw error;
180
+ }
181
+ cache = {
182
+ section,
183
+ document: sanitized.document,
184
+ headHtml: sanitized.document.head.innerHTML,
185
+ sanitization: sanitized.summary,
186
+ resources,
187
+ registry,
188
+ bodyHtml: new Map(),
189
+ };
190
+ this.#cache = cache;
191
+ }
192
+ let bodyHtml = cache.bodyHtml.get(bodyKey);
193
+ if (bodyHtml === undefined) {
194
+ bodyHtml = buildBody(cache.document);
195
+ cache.bodyHtml.set(bodyKey, bodyHtml);
196
+ }
197
+ await this.#load(assembleFrameDocument({
198
+ headHtml: cache.headHtml,
199
+ bodyHtml,
200
+ nonce: createNonce(),
201
+ hostOrigin: this.#targetOrigin(),
202
+ ...(this.#themeCss !== undefined ? { themeCss: this.#themeCss } : {}),
203
+ ...(this.#options.keyboardNav !== undefined ? { keyboardNav: this.#options.keyboardNav } : {}),
204
+ }));
205
+ this.#checkGeneration(generation);
206
+ return {
207
+ sectionId: section.id,
208
+ declaredScripted: section.scripted === true,
209
+ sanitization: cache.sanitization,
210
+ resources: cache.resources,
211
+ };
212
+ }
213
+ /**
214
+ * Lays the currently-rendered chunked section out under `options` and returns
215
+ * the resulting pagination state. In paginated mode each chunk becomes an
216
+ * absolutely-positioned multi-column context and the page count is the sum of
217
+ * per-chunk page counts; in scrolled mode chunks stack with no paging. Requires
218
+ * a prior {@link renderChunked}.
219
+ */
220
+ async paginate(section, options) {
221
+ await this.renderChunked(section, options.chunkChars);
222
+ const reply = await this.#request('paginate', { options });
223
+ if (reply.type !== 'paginated') {
224
+ throw new ContentHostError('the frame answered paginate with the wrong message');
225
+ }
226
+ return reply.state;
227
+ }
228
+ /** Re-measures the current layout (e.g. after a viewport or typography change). */
229
+ async relayout() {
230
+ const reply = await this.#request('relayout');
231
+ if (reply.type !== 'paginated') {
232
+ throw new ContentHostError('the frame answered relayout with the wrong message');
233
+ }
234
+ return reply.state;
235
+ }
236
+ /** Scrolls to a page (0-based). Returns the page actually shown after clamping. */
237
+ async goToPage(page) {
238
+ const reply = await this.#request('goToPage', { page });
239
+ if (reply.type !== 'movedToPage') {
240
+ throw new ContentHostError('the frame answered goToPage with the wrong message');
241
+ }
242
+ return reply.page;
243
+ }
244
+ /** Character offset of the first glyph painted on a page, or -1 if none. */
245
+ async offsetOfPage(page) {
246
+ const reply = await this.#request('offsetOfPage', { page });
247
+ if (reply.type !== 'offset') {
248
+ throw new ContentHostError('the frame answered offsetOfPage with the wrong message');
249
+ }
250
+ return reply.offset;
251
+ }
252
+ /**
253
+ * Character offset of the element carrying `elementId` into the section text,
254
+ * or -1 if no element carries the id. The seam behind fragment anchoring.
255
+ */
256
+ async offsetOfElementId(elementId) {
257
+ const reply = await this.#request('offsetOfElementId', { elementId });
258
+ if (reply.type !== 'offset') {
259
+ throw new ContentHostError('the frame answered offsetOfElementId with the wrong message');
260
+ }
261
+ return reply.offset;
262
+ }
263
+ /** The page (0-based) painting the glyph at a section-text character offset. */
264
+ async pageOfOffset(offset) {
265
+ const reply = await this.#request('pageOfOffset', { offset });
266
+ if (reply.type !== 'page') {
267
+ throw new ContentHostError('the frame answered pageOfOffset with the wrong message');
268
+ }
269
+ return reply.page;
270
+ }
271
+ /** The section's concatenated chunk text, as the frame measures it. */
272
+ async sectionText() {
273
+ const reply = await this.#request('sectionText');
274
+ if (reply.type !== 'text') {
275
+ throw new ContentHostError('the frame answered sectionText with the wrong message');
276
+ }
277
+ return reply.text;
278
+ }
279
+ /** Frame-side counts for eviction/memory checks. */
280
+ async diagnostics() {
281
+ const reply = await this.#request('diagnostics');
282
+ if (reply.type !== 'diagnosticsReport') {
283
+ throw new ContentHostError('the frame answered diagnostics with the wrong message');
284
+ }
285
+ return {
286
+ domNodes: reply.domNodes,
287
+ realizedChunks: reply.realizedChunks,
288
+ totalChunks: reply.totalChunks,
289
+ };
290
+ }
291
+ /**
292
+ * Draws a decoration over the section-text UTF-16 offset range `[start, end)`:
293
+ * the frame maps the range to client rects and paints pointer-transparent,
294
+ * layout-neutral overlay boxes carrying `className`. Re-issuing the same
295
+ * `decorationId` replaces that overlay. Returns the number of boxes painted — 0
296
+ * on a soft-miss (the range is not in the realized section text, or its rects are
297
+ * empty); a soft-miss draws nothing and is not an error.
298
+ */
299
+ async decorate(decorationId, start, end, className) {
300
+ const reply = await this.#request('decorate', { decorationId, start, end, className });
301
+ if (reply.type !== 'decorated') {
302
+ throw new ContentHostError('the frame answered decorate with the wrong message');
303
+ }
304
+ return reply.boxes;
305
+ }
306
+ /** Removes the decoration painted for `decorationId`, leaving nothing behind. */
307
+ async undecorate(decorationId) {
308
+ const reply = await this.#request('undecorate', { decorationId });
309
+ if (reply.type !== 'decorated') {
310
+ throw new ContentHostError('the frame answered undecorate with the wrong message');
311
+ }
312
+ }
313
+ /** Content size as the frame measures it. */
314
+ async measure() {
315
+ const reply = await this.#request('measure');
316
+ if (reply.type !== 'measured')
317
+ throw new ContentHostError('the frame answered measure with the wrong message');
318
+ return { width: reply.width, height: reply.height };
319
+ }
320
+ /** Round-trips the protocol; the cheapest proof the channel is live. */
321
+ async ping() {
322
+ await this.#request('ping');
323
+ }
324
+ /** Releases this render's resources and removes the frame. */
325
+ destroy() {
326
+ if (this.#destroyed)
327
+ return;
328
+ this.#destroyed = true;
329
+ this.#generation += 1;
330
+ this.#window.removeEventListener('message', this.#receive);
331
+ for (const [id, pending] of [...this.#pending]) {
332
+ clearTimeout(pending.timer);
333
+ this.#pending.delete(id);
334
+ pending.fail(new ContentHostError('the host has been destroyed'));
335
+ }
336
+ this.#ready = null;
337
+ this.#cache?.registry.release();
338
+ this.#cache = null;
339
+ this.frame.remove();
340
+ }
341
+ #timeout() {
342
+ return this.#options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
343
+ }
344
+ #targetOrigin() {
345
+ const origin = this.#window.origin;
346
+ return origin === '' || origin === 'null' ? '*' : origin;
347
+ }
348
+ #checkGeneration(generation) {
349
+ if (generation !== this.#generation)
350
+ throw new ContentHostError('the render was superseded by a later one');
351
+ }
352
+ #load(html) {
353
+ return new Promise((resolve, reject) => {
354
+ const timer = setTimeout(() => {
355
+ this.#ready = null;
356
+ reject(new ContentHostError('the frame did not report ready'));
357
+ }, this.#timeout());
358
+ this.#ready = () => {
359
+ clearTimeout(timer);
360
+ this.#ready = null;
361
+ resolve();
362
+ };
363
+ this.frame.srcdoc = html;
364
+ });
365
+ }
366
+ #request(type, extras = {}) {
367
+ if (this.#destroyed)
368
+ return Promise.reject(new ContentHostError('the host has been destroyed'));
369
+ const target = this.frame.contentWindow;
370
+ if (target === null)
371
+ return Promise.reject(new ContentHostError('the frame has no document yet'));
372
+ const id = (this.#nextId += 1);
373
+ return new Promise((settle, fail) => {
374
+ const timer = setTimeout(() => {
375
+ this.#pending.delete(id);
376
+ fail(new ContentHostError(`the frame did not answer ${type}`));
377
+ }, this.#timeout());
378
+ this.#pending.set(id, { settle, fail, timer });
379
+ // The frame's origin is opaque, so '*' is the only targetOrigin that can
380
+ // reach it. The payload carries nothing confidential for that reason.
381
+ target.postMessage({ v: PROTOCOL_VERSION, type, id, ...extras }, '*');
382
+ });
383
+ }
384
+ }
385
+ //# sourceMappingURL=host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/view/host.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACrF,OAAO,EACL,cAAc,EACd,gBAAgB,GA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,EAAE,CAAC,CAAC;YACpB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;YAC/C,yEAAyE;YACzE,sEAAsE;YACtE,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,gBAAgB,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,CAAC,CAAC;QACxE,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ export { CONTENT_ROOT_ID } from './frame.ts';
2
+ export { ContentHost, ContentHostError } from './host.ts';
3
+ export type { ContentHostOptions, RenderReport, ViolationReport } from './host.ts';
4
+ export { asFrameMessage, asHostMessage, PROTOCOL_VERSION } from './protocol.ts';
5
+ export type { FrameMessage, HostMessage, Measurement } from './protocol.ts';
6
+ export { applyResources, ResourceRegistry, UNRESOLVABLE_URL } from './resources.ts';
7
+ export type { ReferenceResolver, ResourceSummary } from './resources.ts';
8
+ export { sanitizeSection } from './sanitize.ts';
9
+ export type { RemovalCount, SanitizationSummary, SanitizedSection } from './sanitize.ts';
10
+ export { isReflowingUpdate, mergeAppearance, resolveThemeProperties, resolveTypographyProperties, THEMES, themeStyleSheet, } from './appearance.ts';
11
+ export type { Appearance, TextAlign, ThemeName, ThemeVariables, TypographyVariables, } from './appearance.ts';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/view/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC1D,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAChF,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACpF,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACzF,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,2BAA2B,EAC3B,MAAM,EACN,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,cAAc,EACd,mBAAmB,GACpB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { CONTENT_ROOT_ID } from './frame.js';
2
+ export { ContentHost, ContentHostError } from './host.js';
3
+ export { asFrameMessage, asHostMessage, PROTOCOL_VERSION } from './protocol.js';
4
+ export { applyResources, ResourceRegistry, UNRESOLVABLE_URL } from './resources.js';
5
+ export { sanitizeSection } from './sanitize.js';
6
+ export { isReflowingUpdate, mergeAppearance, resolveThemeProperties, resolveTypographyProperties, THEMES, themeStyleSheet, } from './appearance.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/view/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEhF,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEpF,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,2BAA2B,EAC3B,MAAM,EACN,eAAe,GAChB,MAAM,iBAAiB,CAAC"}