reamkit 1.15.1 → 1.15.3

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 (316) hide show
  1. package/dist/esm/core/arc-to-bezier.d.ts +23 -0
  2. package/dist/esm/core/arc-to-bezier.js +23 -0
  3. package/dist/esm/core/bidi/algorithm.d.ts +26 -0
  4. package/dist/esm/core/bidi/algorithm.js +21 -0
  5. package/dist/esm/core/bidi/char-types.d.ts +17 -0
  6. package/dist/esm/core/bidi/char-types.js +10 -0
  7. package/dist/esm/core/bidi/index.d.ts +42 -0
  8. package/dist/esm/core/bidi/index.js +27 -0
  9. package/dist/esm/core/bidi/segments.d.ts +22 -0
  10. package/dist/esm/core/bidi/segments.js +14 -0
  11. package/dist/esm/core/bytes.d.ts +20 -0
  12. package/dist/esm/core/bytes.js +24 -1
  13. package/dist/esm/core/converter/facade.d.ts +38 -1
  14. package/dist/esm/core/converter/facade.js +25 -0
  15. package/dist/esm/core/converter/project.d.ts +12 -0
  16. package/dist/esm/core/converter/project.js +11 -0
  17. package/dist/esm/core/converter/ream.d.ts +107 -0
  18. package/dist/esm/core/converter/ream.js +76 -0
  19. package/dist/esm/core/crypto/asn1.d.ts +77 -0
  20. package/dist/esm/core/crypto/asn1.js +65 -0
  21. package/dist/esm/core/crypto/cms.d.ts +25 -0
  22. package/dist/esm/core/crypto/cms.js +8 -0
  23. package/dist/esm/core/document-model/index.d.ts +7 -0
  24. package/dist/esm/core/document-model/types.d.ts +328 -0
  25. package/dist/esm/core/drawingml/chart-geometry.d.ts +125 -0
  26. package/dist/esm/core/drawingml/chart-geometry.js +96 -0
  27. package/dist/esm/core/drawingml/chart-parser.d.ts +34 -0
  28. package/dist/esm/core/drawingml/chart-parser.js +34 -0
  29. package/dist/esm/core/drawingml/chart-serializer.d.ts +12 -0
  30. package/dist/esm/core/drawingml/chart-serializer.js +12 -0
  31. package/dist/esm/core/drawingml/colors.d.ts +53 -0
  32. package/dist/esm/core/drawingml/colors.js +41 -0
  33. package/dist/esm/core/drawingml/preset-geometry.d.ts +30 -0
  34. package/dist/esm/core/drawingml/preset-geometry.js +30 -0
  35. package/dist/esm/core/drawingml/shape-render.d.ts +54 -0
  36. package/dist/esm/core/drawingml/shape-render.js +54 -0
  37. package/dist/esm/core/drawingml/sparkline-geometry.d.ts +15 -0
  38. package/dist/esm/core/drawingml/sparkline-geometry.js +13 -0
  39. package/dist/esm/core/drawingml/theme-parser.d.ts +11 -0
  40. package/dist/esm/core/drawingml/theme-parser.js +11 -0
  41. package/dist/esm/core/font/arabic-joining.d.ts +21 -0
  42. package/dist/esm/core/font/arabic-joining.js +16 -0
  43. package/dist/esm/core/font/binary-reader.d.ts +17 -0
  44. package/dist/esm/core/font/binary-reader.js +17 -0
  45. package/dist/esm/core/font/font-registry.d.ts +37 -0
  46. package/dist/esm/core/font/font-registry.js +31 -0
  47. package/dist/esm/core/font/measure.d.ts +20 -0
  48. package/dist/esm/core/font/measure.js +11 -0
  49. package/dist/esm/core/font/opentype-layout.d.ts +49 -0
  50. package/dist/esm/core/font/opentype-layout.js +37 -0
  51. package/dist/esm/core/font/ttf-parser.d.ts +32 -0
  52. package/dist/esm/core/font/ttf-parser.js +7 -0
  53. package/dist/esm/core/font/ttf-subset.d.ts +21 -0
  54. package/dist/esm/core/font/ttf-subset.js +21 -0
  55. package/dist/esm/core/fonts/provider.d.ts +8 -1
  56. package/dist/esm/core/fonts/provider.js +1 -0
  57. package/dist/esm/core/fonts/remote-fonts.d.ts +22 -0
  58. package/dist/esm/core/fonts/remote-fonts.js +16 -0
  59. package/dist/esm/core/hyphenation/index.d.ts +25 -0
  60. package/dist/esm/core/hyphenation/index.js +17 -0
  61. package/dist/esm/core/hyphenation/liang.d.ts +27 -0
  62. package/dist/esm/core/hyphenation/liang.js +14 -0
  63. package/dist/esm/core/images.d.ts +32 -0
  64. package/dist/esm/core/images.js +12 -0
  65. package/dist/esm/core/ir/adapters.d.ts +23 -0
  66. package/dist/esm/core/ir/features.d.ts +8 -0
  67. package/dist/esm/core/ir/features.js +1 -0
  68. package/dist/esm/core/ir/flow.d.ts +20 -0
  69. package/dist/esm/core/ir/index.d.ts +7 -0
  70. package/dist/esm/core/ir/loss.d.ts +12 -0
  71. package/dist/esm/core/ir/loss.js +8 -0
  72. package/dist/esm/core/ir/resources.d.ts +12 -0
  73. package/dist/esm/core/ir/resources.js +11 -0
  74. package/dist/esm/core/ir/sheet.d.ts +81 -0
  75. package/dist/esm/core/ir/units.d.ts +9 -0
  76. package/dist/esm/core/ir/units.js +2 -0
  77. package/dist/esm/core/line-breaker/cjk.d.ts +26 -0
  78. package/dist/esm/core/line-breaker/cjk.js +60 -0
  79. package/dist/esm/core/line-breaker/greedy.d.ts +14 -0
  80. package/dist/esm/core/line-breaker/greedy.js +14 -0
  81. package/dist/esm/core/line-breaker/index.d.ts +1 -0
  82. package/dist/esm/core/line-breaker/index.js +3 -0
  83. package/dist/esm/core/line-breaker/knuth-plass.d.ts +29 -5
  84. package/dist/esm/core/line-breaker/knuth-plass.js +10 -5
  85. package/dist/esm/core/numbering/apply.d.ts +19 -0
  86. package/dist/esm/core/numbering/apply.js +19 -0
  87. package/dist/esm/core/numbering/state.d.ts +15 -0
  88. package/dist/esm/core/numbering/state.js +15 -0
  89. package/dist/esm/core/ole/cfb.d.ts +19 -0
  90. package/dist/esm/core/ole/cfb.js +16 -0
  91. package/dist/esm/core/opc/core-properties.d.ts +12 -0
  92. package/dist/esm/core/opc/core-properties.js +5 -0
  93. package/dist/esm/core/opc/opc-writer.d.ts +24 -4
  94. package/dist/esm/core/opc/opc-writer.js +12 -0
  95. package/dist/esm/core/opc/package.d.ts +55 -0
  96. package/dist/esm/core/opc/package.js +49 -1
  97. package/dist/esm/core/opc/relationship-types.d.ts +8 -0
  98. package/dist/esm/core/opc/relationship-types.js +5 -0
  99. package/dist/esm/core/opc/relationships.d.ts +12 -0
  100. package/dist/esm/core/opc/relationships.js +7 -0
  101. package/dist/esm/core/po-helpers.d.ts +38 -0
  102. package/dist/esm/core/po-helpers.js +33 -0
  103. package/dist/esm/core/spreadsheet-model/types.d.ts +302 -0
  104. package/dist/esm/core/style-cascade/resolver.d.ts +31 -0
  105. package/dist/esm/core/style-cascade/resolver.js +31 -0
  106. package/dist/esm/core/style-cascade/table.d.ts +7 -0
  107. package/dist/esm/core/style-cascade/table.js +7 -0
  108. package/dist/esm/core/style-cascade/types.d.ts +27 -0
  109. package/dist/esm/core/style-cascade/types.js +2 -0
  110. package/dist/esm/core/vector.d.ts +67 -0
  111. package/dist/esm/core/vector.js +23 -0
  112. package/dist/esm/excel/activex-parser.d.ts +31 -0
  113. package/dist/esm/excel/activex-parser.js +24 -0
  114. package/dist/esm/excel/cell-reference.d.ts +14 -0
  115. package/dist/esm/excel/cell-reference.js +9 -0
  116. package/dist/esm/excel/column-bands.d.ts +29 -0
  117. package/dist/esm/excel/column-bands.js +27 -7
  118. package/dist/esm/excel/comments-parser.d.ts +19 -0
  119. package/dist/esm/excel/comments-parser.js +19 -0
  120. package/dist/esm/excel/conditional-format.d.ts +38 -0
  121. package/dist/esm/excel/conditional-format.js +25 -0
  122. package/dist/esm/excel/defined-name-ref.d.ts +21 -0
  123. package/dist/esm/excel/defined-name-ref.js +20 -0
  124. package/dist/esm/excel/form-control-parser.d.ts +13 -0
  125. package/dist/esm/excel/form-control-parser.js +5 -0
  126. package/dist/esm/excel/formula/context.d.ts +37 -0
  127. package/dist/esm/excel/formula/dates.d.ts +23 -0
  128. package/dist/esm/excel/formula/dates.js +20 -0
  129. package/dist/esm/excel/formula/eval.d.ts +21 -0
  130. package/dist/esm/excel/formula/eval.js +11 -0
  131. package/dist/esm/excel/formula/functions.d.ts +12 -0
  132. package/dist/esm/excel/formula/functions.js +12 -0
  133. package/dist/esm/excel/formula/index.d.ts +21 -0
  134. package/dist/esm/excel/formula/index.js +16 -0
  135. package/dist/esm/excel/formula/lexer.d.ts +12 -0
  136. package/dist/esm/excel/formula/lexer.js +10 -0
  137. package/dist/esm/excel/formula/parser.d.ts +20 -0
  138. package/dist/esm/excel/formula/parser.js +53 -0
  139. package/dist/esm/excel/formula/value.d.ts +53 -0
  140. package/dist/esm/excel/formula/value.js +30 -0
  141. package/dist/esm/excel/header-footer.d.ts +9 -0
  142. package/dist/esm/excel/header-footer.js +9 -0
  143. package/dist/esm/excel/number-format.d.ts +34 -0
  144. package/dist/esm/excel/number-format.js +34 -0
  145. package/dist/esm/excel/pivot-table-parser.d.ts +8 -0
  146. package/dist/esm/excel/pivot-table-parser.js +8 -0
  147. package/dist/esm/excel/print-model.d.ts +77 -1
  148. package/dist/esm/excel/print-model.js +230 -26
  149. package/dist/esm/excel/shared-strings-parser.d.ts +13 -0
  150. package/dist/esm/excel/shared-strings-parser.js +5 -0
  151. package/dist/esm/excel/sheet-drawing.d.ts +34 -0
  152. package/dist/esm/excel/sheet-drawing.js +21 -0
  153. package/dist/esm/excel/sheet-shape-parser.d.ts +12 -0
  154. package/dist/esm/excel/sheet-shape-parser.js +12 -0
  155. package/dist/esm/excel/sheet-to-flow.d.ts +29 -0
  156. package/dist/esm/excel/sheet-to-flow.js +24 -7
  157. package/dist/esm/excel/slicer-parser.d.ts +23 -0
  158. package/dist/esm/excel/slicer-parser.js +10 -0
  159. package/dist/esm/excel/styles-parser.d.ts +8 -0
  160. package/dist/esm/excel/styles-parser.js +8 -0
  161. package/dist/esm/excel/table-parser.d.ts +24 -0
  162. package/dist/esm/excel/table-parser.js +5 -0
  163. package/dist/esm/excel/workbook-parser.d.ts +17 -0
  164. package/dist/esm/excel/workbook-parser.js +5 -0
  165. package/dist/esm/excel/worksheet-parser.d.ts +9 -0
  166. package/dist/esm/excel/worksheet-parser.js +39 -6
  167. package/dist/esm/excel/xls/biff-chart.d.ts +10 -0
  168. package/dist/esm/excel/xls/biff-chart.js +10 -0
  169. package/dist/esm/excel/xls/biff-reader.d.ts +27 -0
  170. package/dist/esm/excel/xls/biff-reader.js +44 -0
  171. package/dist/esm/excel/xls/biff-styles.d.ts +20 -0
  172. package/dist/esm/excel/xls/biff-styles.js +20 -0
  173. package/dist/esm/excel/xls/escher.d.ts +27 -0
  174. package/dist/esm/excel/xls/escher.js +18 -0
  175. package/dist/esm/excel/xls/xls-reader.d.ts +6 -0
  176. package/dist/esm/excel/xls/xls-reader.js +6 -0
  177. package/dist/esm/excel/xlsx-reader.d.ts +30 -0
  178. package/dist/esm/excel/xlsx-reader.js +38 -4
  179. package/dist/esm/excel/xlsx-to-pdf.d.ts +27 -0
  180. package/dist/esm/excel/xlsx-writer.d.ts +14 -0
  181. package/dist/esm/excel/xlsx-writer.js +13 -0
  182. package/dist/esm/html/html-writer.d.ts +18 -0
  183. package/dist/esm/html/html-writer.js +18 -0
  184. package/dist/esm/index.d.ts +23 -0
  185. package/dist/esm/layout/math-layout.d.ts +39 -0
  186. package/dist/esm/layout/math-layout.js +18 -0
  187. package/dist/esm/layout/page-doc.d.ts +91 -0
  188. package/dist/esm/layout/styled-layout.d.ts +175 -0
  189. package/dist/esm/layout/styled-layout.js +136 -4
  190. package/dist/esm/pdf/builtin-fonts.d.ts +5 -0
  191. package/dist/esm/pdf/cid-font.d.ts +22 -0
  192. package/dist/esm/pdf/cid-font.js +10 -0
  193. package/dist/esm/pdf/embedded-file.d.ts +16 -0
  194. package/dist/esm/pdf/embedded-file.js +9 -0
  195. package/dist/esm/pdf/encryption.d.ts +59 -0
  196. package/dist/esm/pdf/encryption.js +37 -0
  197. package/dist/esm/pdf/icc-profile.d.ts +8 -0
  198. package/dist/esm/pdf/icc-profile.js +8 -0
  199. package/dist/esm/pdf/image-xobject.d.ts +19 -0
  200. package/dist/esm/pdf/image-xobject.js +9 -0
  201. package/dist/esm/pdf/objects.d.ts +40 -0
  202. package/dist/esm/pdf/objects.js +36 -0
  203. package/dist/esm/pdf/serialize.d.ts +18 -0
  204. package/dist/esm/pdf/serialize.js +18 -0
  205. package/dist/esm/pdf/shading.d.ts +16 -0
  206. package/dist/esm/pdf/shading.js +16 -0
  207. package/dist/esm/pdf/signature.d.ts +36 -0
  208. package/dist/esm/pdf/signature.js +22 -0
  209. package/dist/esm/pdf/struct-tree.d.ts +64 -0
  210. package/dist/esm/pdf/struct-tree.js +60 -0
  211. package/dist/esm/pdf/styled-page-emitter.d.ts +33 -0
  212. package/dist/esm/pdf/styled-page-emitter.js +21 -0
  213. package/dist/esm/pdf/styled-page-renderer.d.ts +18 -0
  214. package/dist/esm/pdf/styled-page-renderer.js +18 -0
  215. package/dist/esm/pdf/text-encoding.d.ts +16 -0
  216. package/dist/esm/pdf/text-page-renderer.d.ts +11 -0
  217. package/dist/esm/pdf/vector-graphics.d.ts +12 -0
  218. package/dist/esm/pdf/vector-graphics.js +12 -0
  219. package/dist/esm/pdf/writer.d.ts +39 -0
  220. package/dist/esm/pdf/writer.js +27 -0
  221. package/dist/esm/pdf/xmp.d.ts +16 -0
  222. package/dist/esm/pdf/xmp.js +9 -0
  223. package/dist/esm/pdf-reader/ccitt.d.ts +25 -0
  224. package/dist/esm/pdf-reader/ccitt.js +15 -0
  225. package/dist/esm/pdf-reader/cmap.d.ts +12 -0
  226. package/dist/esm/pdf-reader/cmap.js +9 -0
  227. package/dist/esm/pdf-reader/content.d.ts +69 -0
  228. package/dist/esm/pdf-reader/content.js +16 -0
  229. package/dist/esm/pdf-reader/crypto.d.ts +5 -0
  230. package/dist/esm/pdf-reader/crypto.js +5 -0
  231. package/dist/esm/pdf-reader/decrypt.d.ts +17 -0
  232. package/dist/esm/pdf-reader/decrypt.js +12 -0
  233. package/dist/esm/pdf-reader/document.d.ts +53 -0
  234. package/dist/esm/pdf-reader/document.js +50 -0
  235. package/dist/esm/pdf-reader/flow-build.d.ts +47 -0
  236. package/dist/esm/pdf-reader/flow-build.js +42 -0
  237. package/dist/esm/pdf-reader/font.d.ts +12 -0
  238. package/dist/esm/pdf-reader/font.js +12 -0
  239. package/dist/esm/pdf-reader/image-decode.d.ts +21 -0
  240. package/dist/esm/pdf-reader/image-decode.js +14 -0
  241. package/dist/esm/pdf-reader/images.d.ts +19 -0
  242. package/dist/esm/pdf-reader/images.js +9 -0
  243. package/dist/esm/pdf-reader/layout.d.ts +15 -0
  244. package/dist/esm/pdf-reader/layout.js +15 -0
  245. package/dist/esm/pdf-reader/lexer.d.ts +43 -0
  246. package/dist/esm/pdf-reader/lexer.js +38 -0
  247. package/dist/esm/pdf-reader/parser.d.ts +15 -0
  248. package/dist/esm/pdf-reader/parser.js +8 -0
  249. package/dist/esm/pdf-reader/png-encode.d.ts +9 -0
  250. package/dist/esm/pdf-reader/png-encode.js +8 -0
  251. package/dist/esm/pdf-reader/predictor.d.ts +9 -0
  252. package/dist/esm/pdf-reader/predictor.js +8 -0
  253. package/dist/esm/pdf-reader/reader.d.ts +16 -0
  254. package/dist/esm/pdf-reader/reader.js +16 -0
  255. package/dist/esm/pdf-reader/shading.d.ts +10 -0
  256. package/dist/esm/pdf-reader/shading.js +10 -0
  257. package/dist/esm/pdf-reader/struct-tree.d.ts +24 -0
  258. package/dist/esm/pdf-reader/struct-tree.js +12 -0
  259. package/dist/esm/pdf-reader/tagged.d.ts +13 -0
  260. package/dist/esm/pdf-reader/tagged.js +13 -0
  261. package/dist/esm/pdf-reader/text.d.ts +11 -0
  262. package/dist/esm/pdf-reader/text.js +11 -0
  263. package/dist/esm/pdf-reader/vector.d.ts +19 -0
  264. package/dist/esm/pdf-reader/vector.js +9 -0
  265. package/dist/esm/pptx/placeholder-cascade.d.ts +21 -0
  266. package/dist/esm/pptx/placeholder-cascade.js +10 -0
  267. package/dist/esm/pptx/ppt/ppt-reader.d.ts +16 -0
  268. package/dist/esm/pptx/ppt/ppt-reader.js +16 -0
  269. package/dist/esm/pptx/ppt/ppt-text.d.ts +55 -0
  270. package/dist/esm/pptx/ppt/ppt-text.js +14 -0
  271. package/dist/esm/pptx/pptx-reader.d.ts +21 -0
  272. package/dist/esm/pptx/pptx-reader.js +23 -2
  273. package/dist/esm/pptx/slide-parser.d.ts +102 -0
  274. package/dist/esm/pptx/slide-parser.js +78 -0
  275. package/dist/esm/pptx/sp-helpers.d.ts +28 -0
  276. package/dist/esm/pptx/sp-helpers.js +22 -0
  277. package/dist/esm/svg/svg-writer.d.ts +17 -0
  278. package/dist/esm/svg/svg-writer.js +16 -0
  279. package/dist/esm/word/doc/doc-reader.d.ts +16 -0
  280. package/dist/esm/word/doc/doc-reader.js +16 -0
  281. package/dist/esm/word/doc/doc-text.d.ts +77 -0
  282. package/dist/esm/word/doc/doc-text.js +13 -0
  283. package/dist/esm/word/document-parser.d.ts +134 -0
  284. package/dist/esm/word/document-parser.js +86 -0
  285. package/dist/esm/word/docx-reader.d.ts +16 -0
  286. package/dist/esm/word/docx-reader.js +18 -2
  287. package/dist/esm/word/docx-to-pdf.d.ts +52 -0
  288. package/dist/esm/word/docx-to-pdf.js +21 -0
  289. package/dist/esm/word/docx-writer.d.ts +17 -0
  290. package/dist/esm/word/docx-writer.js +17 -0
  291. package/dist/esm/word/drawing-parser.d.ts +88 -0
  292. package/dist/esm/word/drawing-parser.js +68 -0
  293. package/dist/esm/word/font-table.d.ts +24 -0
  294. package/dist/esm/word/font-table.js +24 -0
  295. package/dist/esm/word/numbering-parser.d.ts +11 -0
  296. package/dist/esm/word/numbering-parser.js +11 -0
  297. package/dist/esm/word/omml-parser.d.ts +15 -0
  298. package/dist/esm/word/omml-parser.js +15 -0
  299. package/dist/esm/word/omml-serializer.d.ts +9 -0
  300. package/dist/esm/word/omml-serializer.js +9 -0
  301. package/dist/esm/word/paragraph-properties.d.ts +10 -0
  302. package/dist/esm/word/paragraph-properties.js +10 -0
  303. package/dist/esm/word/po-to-flat.d.ts +11 -0
  304. package/dist/esm/word/po-to-flat.js +11 -0
  305. package/dist/esm/word/run-properties.d.ts +10 -0
  306. package/dist/esm/word/run-properties.js +10 -0
  307. package/dist/esm/word/settings-parser.d.ts +13 -0
  308. package/dist/esm/word/settings-parser.js +8 -0
  309. package/dist/esm/word/styles-parser.d.ts +10 -0
  310. package/dist/esm/word/styles-parser.js +10 -0
  311. package/dist/esm/word/table-parser.d.ts +11 -0
  312. package/dist/esm/word/table-parser.js +11 -0
  313. package/dist/esm/word/text-extractor.d.ts +9 -0
  314. package/dist/esm/word/xml-helpers.d.ts +44 -0
  315. package/dist/esm/word/xml-helpers.js +38 -0
  316. package/package.json +5 -2
@@ -24,6 +24,15 @@ function* records(d) {
24
24
  off = end;
25
25
  }
26
26
  }
27
+ /**
28
+ * Read the workbook-globals MSODrawingGroup's BLIP store: one entry per BSE (so a
29
+ * `pib` index lines up), holding the extracted image bytes — or `undefined` for
30
+ * an entry we cannot read (a metafile blip, an empty slot), which keeps the
31
+ * indices aligned.
32
+ *
33
+ * @param msoDrawingGroup The concatenated MSODrawingGroup record bytes.
34
+ * @returns The image pool, indexed so `pib − 1` selects an entry.
35
+ */
27
36
  function parseBlipStore(msoDrawingGroup) {
28
37
  const store = findContainer(msoDrawingGroup, FBT_BSTORE_CONTAINER, 0);
29
38
  if (!store) return [];
@@ -41,6 +50,10 @@ function findContainer(d, type, depth) {
41
50
  }
42
51
  }
43
52
  }
53
+ /**
54
+ * The picture shapes in a sheet's MSODrawing: every SpContainer that carries a
55
+ * `pib` (a picture-fill reference into the BLIP store) with its cell anchor.
56
+ */
44
57
  function parseSheetPictures(msoDrawing) {
45
58
  const out = [];
46
59
  collectPictures(msoDrawing, out, 0);
@@ -63,6 +76,11 @@ var FBT_SP = 61450;
63
76
  var FBT_CLIENT_TEXTBOX = 61453;
64
77
  var PROP_FILL_COLOR = 385;
65
78
  var PROP_LINE_COLOR = 448;
79
+ /**
80
+ * The non-picture shapes (autoshapes, text boxes) in a sheet's MSODrawing — every
81
+ * SpContainer that is NOT a picture (no `pib`). Pictures are handled separately
82
+ * by {@link parseSheetPictures}.
83
+ */
66
84
  function parseSheetShapes(msoDrawing) {
67
85
  const out = [];
68
86
  collectShapes(msoDrawing, out, 0);
@@ -1,3 +1,9 @@
1
1
  import { DocumentReader } from '../../core/ir/adapters.js';
2
2
  import { SheetDoc } from '../../core/ir/sheet.js';
3
+ /**
4
+ * The legacy `.xls` {@link DocumentReader} (XLS-3): sniffs a BIFF8 OLE2/CFB
5
+ * workbook and reads it into the same {@link SheetDoc} the OOXML xlsx reader
6
+ * produces, so the whole render pipeline works on a 1997–2003 `.xls`. Reports a
7
+ * single degraded {@link Loss} for the unread Excel-tables / autofilter feature.
8
+ */
3
9
  export declare const xlsReader: DocumentReader<SheetDoc>;
@@ -16,6 +16,12 @@ var XLS_LOSSES = [{
16
16
  feature: FEATURES.cellFormatting,
17
17
  detail: "legacy .xls Excel tables / autofilter are not read; the sheet’s cell data, styling, images, charts, drawing shapes, conditional formatting, comments, hyperlinks, data validation, defined names, the page-setup print model, frozen panes and custom row heights are"
18
18
  }];
19
+ /**
20
+ * The legacy `.xls` {@link DocumentReader} (XLS-3): sniffs a BIFF8 OLE2/CFB
21
+ * workbook and reads it into the same {@link SheetDoc} the OOXML xlsx reader
22
+ * produces, so the whole render pipeline works on a 1997–2003 `.xls`. Reports a
23
+ * single degraded {@link Loss} for the unread Excel-tables / autofilter feature.
24
+ */
19
25
  var xlsReader = {
20
26
  id: "xls",
21
27
  produces: "sheet",
@@ -2,6 +2,36 @@ import { DocumentReader, ReadResult } from '../core/ir/adapters.js';
2
2
  import { FlowDoc } from '../core/ir/flow.js';
3
3
  import { SheetDoc } from '../core/ir/sheet.js';
4
4
  import { ProjectSheetOptions } from './sheet-to-flow.js';
5
+ /**
6
+ * Read a `.xlsx` and project it to a {@link FlowDoc} in one step:
7
+ * {@link readXlsxToSheetDoc} then {@link projectSheetDoc}.
8
+ *
9
+ * Parsing itself is lossless — SpreadsheetML maps cleanly onto the sheet IR.
10
+ * The losses come from the projection: the print model's defence-in-depth caps
11
+ * (grid size, per-sheet text budget, sparkline range) clip pathological sheets,
12
+ * and each clip is reported rather than applied in silence.
13
+ *
14
+ * @param xlsx The `.xlsx` (OPC ZIP) bytes.
15
+ * @param options Projection knobs (the W9 reference date).
16
+ * @returns The flow document plus whatever the projection had to clip.
17
+ */
5
18
  export declare function readXlsx(xlsx: Uint8Array, options?: ProjectSheetOptions): ReadResult<FlowDoc>;
19
+ /**
20
+ * Read a `.xlsx` into the {@link SheetDoc} SpreadsheetML IR node. Everything that
21
+ * needs the OPC package — workbook/worksheet/styles/shared-string parsing, chart
22
+ * and drawing resolution, tables, pivots, slicers, hyperlinks, comments and
23
+ * controls — happens here; the SheetDoc → FlowDoc projection (sheet-to-flow) is
24
+ * then a pure transform.
25
+ *
26
+ * @param xlsx The `.xlsx` (OPC ZIP) bytes.
27
+ * @returns The parsed spreadsheet IR tree.
28
+ * @throws Error when `xl/workbook.xml` is missing or the workbook has no sheets.
29
+ */
6
30
  export declare function readXlsxToSheetDoc(xlsx: Uint8Array): SheetDoc;
31
+ /**
32
+ * The OOXML `.xlsx` {@link DocumentReader}: sniffs the OPC ZIP for
33
+ * `xl/workbook.xml` and reads it into a {@link SheetDoc}. The reader's native
34
+ * tree is the SheetDoc; the facade/Ream project it to a {@link FlowDoc} for
35
+ * rendering (E-SHEET SB1).
36
+ */
7
37
  export declare const xlsxReader: DocumentReader<SheetDoc>;
@@ -1,6 +1,6 @@
1
1
  import { ResourceStore } from "../core/ir/resources.js";
2
2
  import { FEATURES } from "../core/ir/features.js";
3
- import { bytesInclude } from "../core/bytes.js";
3
+ import { bytesInclude, bytesIncludePartName } from "../core/bytes.js";
4
4
  import { DEFAULT_THEME_PALETTE, makeColorResolver } from "../core/drawingml/colors.js";
5
5
  import { parseChart, withChartColorStyle } from "../core/drawingml/chart-parser.js";
6
6
  import { parseTheme } from "../core/drawingml/theme-parser.js";
@@ -34,12 +34,40 @@ var SLICER_CACHE_REL_TAIL = "/slicerCache";
34
34
  var THREADED_COMMENTS_REL_TAIL = "/threadedComment";
35
35
  var PERSON_REL_TAIL = "/person";
36
36
  var MAX_SLICER_ITEMS = 256;
37
+ /**
38
+ * Read a `.xlsx` and project it to a {@link FlowDoc} in one step:
39
+ * {@link readXlsxToSheetDoc} then {@link projectSheetDoc}.
40
+ *
41
+ * Parsing itself is lossless — SpreadsheetML maps cleanly onto the sheet IR.
42
+ * The losses come from the projection: the print model's defence-in-depth caps
43
+ * (grid size, per-sheet text budget, sparkline range) clip pathological sheets,
44
+ * and each clip is reported rather than applied in silence.
45
+ *
46
+ * @param xlsx The `.xlsx` (OPC ZIP) bytes.
47
+ * @param options Projection knobs (the W9 reference date).
48
+ * @returns The flow document plus whatever the projection had to clip.
49
+ */
37
50
  function readXlsx(xlsx, options = {}) {
51
+ const losses = [];
38
52
  return {
39
- doc: projectSheetDoc(readXlsxToSheetDoc(xlsx), options),
40
- losses: []
53
+ doc: projectSheetDoc(readXlsxToSheetDoc(xlsx), {
54
+ ...options,
55
+ losses
56
+ }),
57
+ losses
41
58
  };
42
59
  }
60
+ /**
61
+ * Read a `.xlsx` into the {@link SheetDoc} SpreadsheetML IR node. Everything that
62
+ * needs the OPC package — workbook/worksheet/styles/shared-string parsing, chart
63
+ * and drawing resolution, tables, pivots, slicers, hyperlinks, comments and
64
+ * controls — happens here; the SheetDoc → FlowDoc projection (sheet-to-flow) is
65
+ * then a pure transform.
66
+ *
67
+ * @param xlsx The `.xlsx` (OPC ZIP) bytes.
68
+ * @returns The parsed spreadsheet IR tree.
69
+ * @throws Error when `xl/workbook.xml` is missing or the workbook has no sheets.
70
+ */
43
71
  function readXlsxToSheetDoc(xlsx) {
44
72
  const pkg = OpcPackage.open(xlsx);
45
73
  const workbookData = pkg.getPart(WORKBOOK_PART);
@@ -384,11 +412,17 @@ function lighten(hex, amount) {
384
412
  const hx = (c) => c.toString(16).padStart(2, "0").toUpperCase();
385
413
  return `${hx(ch(16))}${hx(ch(8))}${hx(ch(0))}`;
386
414
  }
415
+ /**
416
+ * The OOXML `.xlsx` {@link DocumentReader}: sniffs the OPC ZIP for
417
+ * `xl/workbook.xml` and reads it into a {@link SheetDoc}. The reader's native
418
+ * tree is the SheetDoc; the facade/Ream project it to a {@link FlowDoc} for
419
+ * rendering (E-SHEET SB1).
420
+ */
387
421
  var xlsxReader = {
388
422
  id: "xlsx",
389
423
  produces: "sheet",
390
424
  supports: new Set([FEATURES.text, FEATURES.tables]),
391
- sniff: (bytes) => bytes[0] === 80 && bytes[1] === 75 && bytesInclude(bytes, "xl/workbook.xml"),
425
+ sniff: (bytes) => bytes[0] === 80 && bytes[1] === 75 && bytesIncludePartName(bytes, "xl/workbook.xml"),
392
426
  read: (bytes) => ({
393
427
  doc: readXlsxToSheetDoc(bytes),
394
428
  losses: []
@@ -1,13 +1,40 @@
1
1
  import { FontBytesByVariant } from '../core/font/index.js';
2
2
  import { FetchLike } from '../core/fonts/index.js';
3
3
  import { SignatureOptions, StyledRenderOptions } from '../pdf/index.js';
4
+ /**
5
+ * Options for the xlsx → PDF convenience converters. Extends the low-level
6
+ * {@link StyledRenderOptions} (minus the font `registry` and `styles`, which the
7
+ * converter builds itself) with font acquisition and source-touching conveniences.
8
+ */
4
9
  export interface ConvertXlsxOptions extends Omit<StyledRenderOptions, 'registry' | 'styles'> {
10
+ /** Shorthand for supplying a single regular-variant font as raw bytes. */
5
11
  readonly fontBytes?: Uint8Array;
12
+ /** Explicit font bytes per variant (regular/bold/italic/bold-italic). */
6
13
  readonly fonts?: FontBytesByVariant;
14
+ /**
15
+ * Force a substitute font family for the auto-download path. Ignored when
16
+ * `fonts`/`fontBytes` are supplied.
17
+ */
7
18
  readonly fontFamily?: string;
19
+ /** Injectable `fetch` for the auto-download path (defaults to the global `fetch`). */
8
20
  readonly fontFetch?: FetchLike;
21
+ /**
22
+ * For PDF/A-3 only: embed the input `.xlsx` as an associated source file
23
+ * (`/AFRelationship /Source`). Ignored for other profiles.
24
+ */
9
25
  readonly embedSource?: boolean;
26
+ /**
27
+ * E-SHEET W9 — the reference date for conditional-format `timePeriod` rules and
28
+ * `TODAY()`/`NOW()` in `expression` rules. An explicit input (never the wall
29
+ * clock), so output stays deterministic; omitted ⇒ those clock-relative rules
30
+ * no-op.
31
+ */
10
32
  readonly now?: Date;
33
+ /**
34
+ * Digitally sign the output (ISO 32000 §12.8). Requires the async
35
+ * {@link convertXlsxToPdf} (signing uses WebCrypto). Ignored by the sync
36
+ * converter.
37
+ */
11
38
  readonly signature?: SignatureOptions;
12
39
  }
13
40
  /**
@@ -1,4 +1,18 @@
1
1
  import { DocumentWriter, WriteResult } from '../core/ir/adapters.js';
2
2
  import { SheetDoc } from '../core/ir/sheet.js';
3
+ /**
4
+ * Serialize a {@link SheetDoc} back to a `.xlsx` (E-SHEET SD1). The first writer
5
+ * that consumes the SpreadsheetML IR node directly (not the FlowDoc projection),
6
+ * so the cells keep their RAW value + style index and the SheetDoc is a stable
7
+ * round-trip fixpoint (SD2). Re-emits the full grid surface — values, shared
8
+ * strings, styles, merges, column/row geometry, the page model, conditional
9
+ * formatting, sparklines, table parts and embedded charts — through the core OPC
10
+ * writer.
11
+ *
12
+ * @param sheet The spreadsheet IR tree to write.
13
+ * @returns The encoded `.xlsx` bytes and any write-time losses (e.g. a chart
14
+ * frame whose data could not be resolved).
15
+ */
3
16
  export declare function writeXlsx(sheet: SheetDoc): WriteResult;
17
+ /** The `.xlsx` {@link DocumentWriter}: a thin wrapper over {@link writeXlsx}. */
4
18
  export declare const xlsxWriter: DocumentWriter<SheetDoc>;
@@ -24,6 +24,19 @@ var CT_STYLES = "application/vnd.openxmlformats-officedocument.spreadsheetml.sty
24
24
  var CT_TABLE = "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml";
25
25
  var MAIN_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
26
26
  var R_NS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
27
+ /**
28
+ * Serialize a {@link SheetDoc} back to a `.xlsx` (E-SHEET SD1). The first writer
29
+ * that consumes the SpreadsheetML IR node directly (not the FlowDoc projection),
30
+ * so the cells keep their RAW value + style index and the SheetDoc is a stable
31
+ * round-trip fixpoint (SD2). Re-emits the full grid surface — values, shared
32
+ * strings, styles, merges, column/row geometry, the page model, conditional
33
+ * formatting, sparklines, table parts and embedded charts — through the core OPC
34
+ * writer.
35
+ *
36
+ * @param sheet The spreadsheet IR tree to write.
37
+ * @returns The encoded `.xlsx` bytes and any write-time losses (e.g. a chart
38
+ * frame whose data could not be resolved).
39
+ */
27
40
  function writeXlsx(sheet) {
28
41
  const losses = [];
29
42
  const worksheetParts = [];
@@ -1,4 +1,22 @@
1
1
  import { DocumentWriter, WriteResult } from '../core/ir/adapters.js';
2
2
  import { FlowDoc } from '../core/ir/flow.js';
3
+ /**
4
+ * Render a {@link FlowDoc} to a self-contained HTML document (ir-design §7).
5
+ *
6
+ * A flow medium: no pagination, no layout engine and no fonts to embed, so this
7
+ * is a pure, zero-I/O transform. `flow.body` already carries FINAL effective
8
+ * properties (the Stage-6 contract), so values map straight to CSS; every read
9
+ * still routes through the cascade resolver over the empty sheet, a memoized
10
+ * identity on reader output. Charts and shapes emit as inline SVG; deliberately
11
+ * out of scope (reported as losses): inline math and headers/footers (no fixed
12
+ * pages to band them onto). Page-break hints map to CSS `break-before`.
13
+ *
14
+ * @param flow The format-neutral interlayer document tree.
15
+ * @returns The encoded HTML bytes plus the recorded {@link Loss} list.
16
+ */
3
17
  export declare function writeHtml(flow: FlowDoc): WriteResult;
18
+ /**
19
+ * The flow-medium {@link DocumentWriter} adapter (id `'html'`), wrapping
20
+ * {@link writeHtml}, with the set of {@link FEATURES} it renders.
21
+ */
4
22
  export declare const htmlWriter: DocumentWriter<FlowDoc>;
@@ -10,6 +10,20 @@ import { buildShapePaths, buildShapeTransform, buildStroke, gradientSvgDef } fro
10
10
  import { sanitizeHref } from "../core/links.js";
11
11
  import { toBase64 } from "../core/bytes.js";
12
12
  //#region src/html/html-writer.ts
13
+ /**
14
+ * Render a {@link FlowDoc} to a self-contained HTML document (ir-design §7).
15
+ *
16
+ * A flow medium: no pagination, no layout engine and no fonts to embed, so this
17
+ * is a pure, zero-I/O transform. `flow.body` already carries FINAL effective
18
+ * properties (the Stage-6 contract), so values map straight to CSS; every read
19
+ * still routes through the cascade resolver over the empty sheet, a memoized
20
+ * identity on reader output. Charts and shapes emit as inline SVG; deliberately
21
+ * out of scope (reported as losses): inline math and headers/footers (no fixed
22
+ * pages to band them onto). Page-break hints map to CSS `break-before`.
23
+ *
24
+ * @param flow The format-neutral interlayer document tree.
25
+ * @returns The encoded HTML bytes plus the recorded {@link Loss} list.
26
+ */
13
27
  function writeHtml(flow) {
14
28
  const losses = [];
15
29
  const out = [];
@@ -50,6 +64,10 @@ function writeHtml(flow) {
50
64
  losses
51
65
  };
52
66
  }
67
+ /**
68
+ * The flow-medium {@link DocumentWriter} adapter (id `'html'`), wrapping
69
+ * {@link writeHtml}, with the set of {@link FEATURES} it renders.
70
+ */
53
71
  var htmlWriter = {
54
72
  id: "html",
55
73
  consumes: "flow",
@@ -1,3 +1,26 @@
1
+ /**
2
+ * The public API for Ream.
3
+ *
4
+ * The package reads Word, Excel, PowerPoint and PDF — including the legacy
5
+ * `.doc` / `.xls` / `.ppt` — and converts any of them to PDF, SVG, HTML, DOCX or
6
+ * XLSX, implemented from the ECMA-376 and ISO 32000 specifications without
7
+ * wrapping LibreOffice, headless Office, or any commercial SDK.
8
+ *
9
+ * Typical use:
10
+ *
11
+ * ```ts
12
+ * import { Ream } from 'reamkit';
13
+ * const doc = Ream.parse(bytes); // format sniffed
14
+ * const pdf = await doc.convert('pdf'); // one parse, any target
15
+ * ```
16
+ *
17
+ * Advanced consumers can build custom pipelines from the reader/writer
18
+ * interfaces, drive the layout engine directly via {@link renderStyledPdf},
19
+ * supply a hyphenator, or import the typed document model from the
20
+ * `reamkit/document-model` subpath.
21
+ *
22
+ * @packageDocumentation
23
+ */
1
24
  export { fetchFontSet, resolveFamilyKey } from './core/fonts/index.js';
2
25
  export type { FamilyKey, FetchFontSetOptions, FetchLike } from './core/fonts/index.js';
3
26
  export { renderStyledPdf } from './pdf/index.js';
@@ -1,14 +1,21 @@
1
1
  import { MathNode } from '../core/document-model/index.js';
2
2
  import { PathSegment } from '../core/vector.js';
3
+ /** Font variant a math glyph renders in (drives the auto-italic of letters). */
3
4
  export type MathVariant = 'regular' | 'italic' | 'bold' | 'boldItalic';
5
+ /**
6
+ * An ordinary symbol drawn from the font: a string positioned in the box's local
7
+ * frame (origin = box left, baseline at `y = 0`, y up).
8
+ */
4
9
  export interface MathGlyphItem {
5
10
  readonly kind: 'glyph';
6
11
  readonly x: number;
12
+ /** Baseline offset, up positive. */
7
13
  readonly y: number;
8
14
  readonly text: string;
9
15
  readonly variant: MathVariant;
10
16
  readonly sizePt: number;
11
17
  }
18
+ /** A filled rectangle (fraction bars, accent rules); `(x, y)` is its bottom-left edge. */
12
19
  export interface MathRuleItem {
13
20
  readonly kind: 'rule';
14
21
  readonly x: number;
@@ -16,29 +23,61 @@ export interface MathRuleItem {
16
23
  readonly w: number;
17
24
  readonly h: number;
18
25
  }
26
+ /**
27
+ * A vector path drawn instead of a math-font glyph (radicals, stretchy
28
+ * delimiters, big operators) — so no math font is needed.
29
+ */
19
30
  export interface MathPathItem {
20
31
  readonly kind: 'path';
21
32
  readonly segments: ReadonlyArray<PathSegment>;
33
+ /** Present ⇒ stroked at this width. */
22
34
  readonly strokeWidthPt?: number;
35
+ /** `true` ⇒ filled. */
23
36
  readonly fill?: boolean;
24
37
  }
38
+ /** A positioned draw item in a {@link MathBox}'s local frame. */
25
39
  export type MathDrawItem = MathGlyphItem | MathRuleItem | MathPathItem;
40
+ /**
41
+ * A laid-out math box: a width plus ascent (above the baseline) and descent
42
+ * (below), and a flat list of positioned {@link MathDrawItem}s in a LOCAL frame
43
+ * (origin = box left, baseline at `y = 0`, y up).
44
+ */
26
45
  export interface MathBox {
27
46
  readonly width: number;
28
47
  readonly ascent: number;
29
48
  readonly descent: number;
30
49
  readonly items: ReadonlyArray<MathDrawItem>;
31
50
  }
51
+ /** Injected text-measure: the advance width of `text` at `sizePt` in `variant`. */
32
52
  export type MeasureMath = (text: string, sizePt: number, variant: MathVariant) => number;
53
+ /** Layout context threaded through {@link layoutMath} — currently just the em size. */
33
54
  export interface MathCtx {
34
55
  readonly sizePt: number;
35
56
  }
57
+ /** Decompose a {@link MathVariant} into its independent bold / italic flags. */
36
58
  export declare function variantStyle(v: MathVariant): {
37
59
  bold: boolean;
38
60
  italic: boolean;
39
61
  };
62
+ /**
63
+ * Recursively lay out an ECMA-376 §22 OfficeMath node into a {@link MathBox}.
64
+ * Ordinary symbols become {@link MathGlyphItem}s (rendered from the font);
65
+ * structural elements (fraction rules, radicals, big operators, stretchy
66
+ * delimiters) become rule/path items drawn as vector graphics. Pure: text widths
67
+ * arrive through the injected `measure` fn.
68
+ *
69
+ * @param node The math tree node to lay out.
70
+ * @param ctx The layout context (em size).
71
+ * @param measure The injected advance-width measurer.
72
+ * @returns The positioned box; constructs added in later milestones render empty.
73
+ */
40
74
  export declare function layoutMath(node: MathNode, ctx: MathCtx, measure: MeasureMath): MathBox;
75
+ /** Translate every item in a box by `(dx, dy)`, returning shifted copies. */
41
76
  export declare function shiftItems(items: ReadonlyArray<MathDrawItem>, dx: number, dy: number): Array<MathDrawItem>;
77
+ /**
78
+ * Flatten a math tree into `(variant, text)` glyph segments — used to subset the
79
+ * right glyphs into the right font variant. Grows alongside {@link layoutMath}.
80
+ */
42
81
  export declare function mathGlyphSegments(node: MathNode): Array<{
43
82
  variant: MathVariant;
44
83
  text: string;
@@ -6,6 +6,7 @@ var BAR_THICK = .045;
6
6
  var FRAC_GAP = .15;
7
7
  var FRAC_PAD = .12;
8
8
  var SCRIPT_SIZE = .7;
9
+ /** Decompose a {@link MathVariant} into its independent bold / italic flags. */
9
10
  function variantStyle(v) {
10
11
  return {
11
12
  bold: v === "bold" || v === "boldItalic",
@@ -20,6 +21,18 @@ function runCharVariant(ch, run) {
20
21
  const bold = run.bold ?? false;
21
22
  return variantOf(run.nor ? false : run.italic ?? isAutoItalic(ch), bold);
22
23
  }
24
+ /**
25
+ * Recursively lay out an ECMA-376 §22 OfficeMath node into a {@link MathBox}.
26
+ * Ordinary symbols become {@link MathGlyphItem}s (rendered from the font);
27
+ * structural elements (fraction rules, radicals, big operators, stretchy
28
+ * delimiters) become rule/path items drawn as vector graphics. Pure: text widths
29
+ * arrive through the injected `measure` fn.
30
+ *
31
+ * @param node The math tree node to lay out.
32
+ * @param ctx The layout context (em size).
33
+ * @param measure The injected advance-width measurer.
34
+ * @returns The positioned box; constructs added in later milestones render empty.
35
+ */
23
36
  function layoutMath(node, ctx, measure) {
24
37
  switch (node.type) {
25
38
  case "run": return layoutRun(node, ctx, measure);
@@ -1016,6 +1029,7 @@ function layoutGroupChr(node, ctx, measure) {
1016
1029
  items
1017
1030
  };
1018
1031
  }
1032
+ /** Translate every item in a box by `(dx, dy)`, returning shifted copies. */
1019
1033
  function shiftItems(items, dx, dy) {
1020
1034
  return items.map((it) => {
1021
1035
  if (it.kind === "glyph") return {
@@ -1054,6 +1068,10 @@ function shiftSegment(s, dx, dy) {
1054
1068
  case "close": return s;
1055
1069
  }
1056
1070
  }
1071
+ /**
1072
+ * Flatten a math tree into `(variant, text)` glyph segments — used to subset the
1073
+ * right glyphs into the right font variant. Grows alongside {@link layoutMath}.
1074
+ */
1057
1075
  function mathGlyphSegments(node) {
1058
1076
  const out = [];
1059
1077
  const visit = (n) => {
@@ -3,35 +3,74 @@ import { FontMeasure, ParsedTtf } from '../core/font/index.js';
3
3
  import { ResolvedParagraphProperties, ResolvedRunProperties } from '../core/style-cascade/index.js';
4
4
  import { PathSegment, VectorShape } from '../core/vector.js';
5
5
  import { PreparedImage } from '../core/images.js';
6
+ /** A font bound into a {@link LaidOutDocument}: the parsed face plus what layout/emit need from it. */
6
7
  export interface FontResource {
7
8
  readonly resourceName: string;
8
9
  readonly parsed: ParsedTtf;
10
+ /**
11
+ * Pure measurement/encoding (no `PdfDocument`): layout measures with this and
12
+ * emit encodes with it; the PDF font objects are created in the emit phase.
13
+ */
9
14
  readonly measure: FontMeasure;
15
+ /** Glyphs collected by the usage walk — the emit phase subsets to these. */
10
16
  readonly gids: ReadonlySet<number>;
11
17
  }
18
+ /** A run of text on a {@link Line}: the string plus its resolved font, size, width and link/tagging state. */
12
19
  export interface TextToken {
13
20
  readonly kind: 'text';
14
21
  readonly text: string;
15
22
  readonly isSpace: boolean;
23
+ /**
24
+ * External hyperlink target inherited from the source run (rels-resolved).
25
+ * Writers MUST sanitize the scheme (`core/links`) before emitting anything
26
+ * clickable.
27
+ */
16
28
  readonly href?: string;
29
+ /**
30
+ * §17.11.14 — the token renders a footnote reference number; pagination
31
+ * reserves the note's block at the bottom of the page it lands on.
32
+ */
17
33
  readonly footnoteRef?: string;
34
+ /**
35
+ * §17.16.22 — internal link target: a bookmark name in this document (not a
36
+ * URL; resolves to a GoTo destination, never through the scheme list).
37
+ */
18
38
  readonly anchor?: string;
39
+ /**
40
+ * List-item marker glyphs (`"1."`, `"•"`) — tagged PDF brackets them in a Lbl
41
+ * element separate from the item body.
42
+ */
19
43
  readonly listMarker?: true;
44
+ /**
45
+ * The token falls inside a comment range (`commentRangeRefs`): the emitter
46
+ * fills a soft highlight behind it (E-COMMENTS CM2c).
47
+ */
20
48
  readonly highlight?: true;
21
49
  readonly resolvedRun: ResolvedRunProperties;
22
50
  readonly font: FontResource;
23
51
  readonly fontSizePt: number;
24
52
  readonly widthPt: number;
53
+ /**
54
+ * UAX #9 embedding level of this token's characters (0 for pure-LTR docs).
55
+ * Even = LTR, odd = RTL. Used for visual reordering at emit time.
56
+ */
25
57
  readonly bidiLevel: number;
26
58
  }
59
+ /** An inline image on a {@link Line}: its sized box plus the resource name binding to the page XObject. */
27
60
  export interface ImageToken {
28
61
  readonly kind: 'image';
29
62
  readonly imageResourceName: string;
30
63
  readonly widthPt: number;
31
64
  readonly heightPt: number;
65
+ /** Constants kept to satisfy {@link Token} consumers — they never read these for images. */
32
66
  readonly isSpace: false;
33
67
  readonly bidiLevel: number;
34
68
  }
69
+ /**
70
+ * A math draw item with its font already resolved (`math-layout` emits a
71
+ * variant; the tokenizer maps it to a {@link FontResource} so the emit phase
72
+ * needs no fonts).
73
+ */
35
74
  export type ResolvedMathItem = {
36
75
  readonly kind: 'glyph';
37
76
  readonly x: number;
@@ -51,6 +90,10 @@ export type ResolvedMathItem = {
51
90
  readonly strokeWidthPt?: number;
52
91
  readonly fill?: boolean;
53
92
  };
93
+ /**
94
+ * An inline OfficeMath object — an atomic box straddling the baseline (its own
95
+ * ascent/descent extend the line height).
96
+ */
54
97
  export interface MathToken {
55
98
  readonly kind: 'math';
56
99
  readonly items: ReadonlyArray<ResolvedMathItem>;
@@ -60,7 +103,9 @@ export interface MathToken {
60
103
  readonly isSpace: false;
61
104
  readonly bidiLevel: number;
62
105
  }
106
+ /** A positioned atom on a {@link Line}: a text run, an inline image, or an inline math box. */
63
107
  export type Token = TextToken | ImageToken | MathToken;
108
+ /** A laid-out line of a paragraph: its broken tokens plus the geometry pagination needs. */
64
109
  export interface Line {
65
110
  readonly tokens: ReadonlyArray<Token>;
66
111
  readonly contentWidthPt: number;
@@ -69,25 +114,61 @@ export interface Line {
69
114
  readonly firstLine: boolean;
70
115
  readonly resolved: ResolvedParagraphProperties;
71
116
  isLastInParagraph: boolean;
117
+ /**
118
+ * Max ascent/descent contributed by math tokens (0 when none) — they straddle
119
+ * the baseline, so the line height/descent must grow to fit them.
120
+ */
72
121
  readonly mathAscentPt?: number;
73
122
  readonly mathDescentPt?: number;
123
+ /**
124
+ * E-PARITY: metric-derived single-line height and descent (Pt), the max over
125
+ * the line's text-token fonts under a non-default `layoutProfile`. Absent under
126
+ * `'ream'`, where leading stays the flat 1.2×/0.2 model (byte-identical).
127
+ */
74
128
  readonly metricHeightPt?: number;
75
129
  readonly metricDescentPt?: number;
76
130
  }
131
+ /** An image bound into a {@link LaidOutDocument}: its resource name plus the decoded/validated bytes. */
77
132
  export interface ImageResource {
78
133
  readonly resourceName: string;
134
+ /**
135
+ * Decoded/validated at layout time (the probe); the emit phase replays it
136
+ * without touching the source bytes again.
137
+ */
79
138
  readonly prepared: PreparedImage;
80
139
  }
140
+ /**
141
+ * The fields every {@link PageItem} shares (ir-design §6, frozen at stage 6.4):
142
+ * the positioned, layout-output vocabulary a page is made of. Page-frame
143
+ * geometry is branded `Pt` (PostScript points) with a TOP-LEFT origin, y growing
144
+ * downward (like CSS/SVG); the PDF emitter converts into PDF's native y-up frame
145
+ * at emission. Offsets measured from a text baseline (math/inline-image boxes
146
+ * inside a {@link Line}) and styling magnitudes (font/stroke sizes) stay plain
147
+ * numbers — they are not page-frame coordinates.
148
+ */
81
149
  export interface PageItemBase {
150
+ /**
151
+ * Tagged PDF (§14.8): the logical structure node this item's content belongs
152
+ * to. Set only on body content in tagged mode; undefined text in the line pass
153
+ * is treated as an artifact. Ignored when not tagging.
154
+ */
82
155
  readonly structId?: number;
156
+ /**
157
+ * Tagged PDF: explicitly mark this item as a pagination artifact (running
158
+ * header/footer, §14.8.2.2.2). Distinguishes header/footer text from
159
+ * not-yet-tagged body content so it is typed `/Artifact /Pagination`, never a P.
160
+ */
83
161
  readonly artifact?: 'pagination';
84
162
  }
163
+ /** A laid-out line of text (tokens carry their fonts/sizes/positions). */
85
164
  export interface TextLineItem extends PageItemBase {
86
165
  readonly type: 'line';
87
166
  readonly line: Line;
88
167
  readonly originX: Pt;
168
+ /** Distance from the page TOP down to the text baseline. */
89
169
  readonly baselineY: Pt;
90
170
  }
171
+ /** One edge of a table-cell frame; `(x, y)` is the cell box's top-left corner. */
91
172
  export interface BorderItem extends PageItemBase {
92
173
  readonly type: 'border';
93
174
  readonly side: 'top' | 'right' | 'bottom' | 'left';
@@ -98,6 +179,7 @@ export interface BorderItem extends PageItemBase {
98
179
  readonly borderSizePt: number;
99
180
  readonly borderColorHex: string;
100
181
  }
182
+ /** A filled rectangle (cell shading); `(x, y)` is its top-left corner. */
101
183
  export interface FillItem extends PageItemBase {
102
184
  readonly type: 'fill';
103
185
  readonly x: Pt;
@@ -106,6 +188,10 @@ export interface FillItem extends PageItemBase {
106
188
  readonly height: Pt;
107
189
  readonly fillColorHex: string;
108
190
  }
191
+ /**
192
+ * A placed raster image (resource name binds to the page XObject dict); `(x, y)`
193
+ * is its top-left corner.
194
+ */
109
195
  export interface ImageItem extends PageItemBase {
110
196
  readonly type: 'image';
111
197
  readonly x: Pt;
@@ -114,10 +200,15 @@ export interface ImageItem extends PageItemBase {
114
200
  readonly height: Pt;
115
201
  readonly imageResourceName: string;
116
202
  }
203
+ /**
204
+ * DrawingML vector geometry. `shape.transform` maps the shape's local y-up frame
205
+ * into the top-left page frame (see `flipTransform`).
206
+ */
117
207
  export interface ShapeItem extends PageItemBase {
118
208
  readonly type: 'shape';
119
209
  readonly shape: VectorShape;
120
210
  }
211
+ /** A positioned item on a laid-out page: a text line, border, fill, image, or vector shape. */
121
212
  export type PageItem = TextLineItem | BorderItem | FillItem | ImageItem | ShapeItem;
122
213
  export interface PagePaintPlan {
123
214
  readonly fills: ReadonlyArray<FillItem>;