reamkit 1.15.0 → 1.15.2

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 +9 -0
  12. package/dist/esm/core/bytes.js +9 -0
  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 +50 -4
  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 +46 -0
  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 +281 -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 +26 -0
  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 +56 -0
  148. package/dist/esm/excel/print-model.js +43 -0
  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 +19 -0
  156. package/dist/esm/excel/sheet-to-flow.js +10 -0
  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 +9 -0
  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 +26 -0
  178. package/dist/esm/excel/xlsx-reader.js +26 -0
  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 +117 -2
  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 +51 -2
  236. package/dist/esm/pdf-reader/flow-build.js +67 -2
  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 +17 -2
  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 +15 -2
  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 +37 -1
  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 +26 -4
  281. package/dist/esm/word/doc/doc-text.d.ts +81 -0
  282. package/dist/esm/word/doc/doc-text.js +38 -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 +16 -0
  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 +1 -1
@@ -1,5 +1,6 @@
1
1
  import { tokenize } from "./lexer.js";
2
2
  //#region src/excel/formula/parser.ts
3
+ /** Thrown when the token stream is not a well-formed formula. */
3
4
  var ParseError = class extends Error {};
4
5
  var PREC = {
5
6
  "=": 1,
@@ -21,27 +22,49 @@ var MAX_ARGS = 255;
21
22
  var CELL_RE = /^(\$?)([A-Za-z]{1,3})(\$?)([0-9]{1,7})$/;
22
23
  var MAX_COL = 16383;
23
24
  var MAX_ROW = 1048575;
25
+ /**
26
+ * Parse a formula string into an {@link Ast}. Callers (the CF compiler) catch
27
+ * the throw and treat a parse failure as "rule does not apply" — a formula using
28
+ * a construct we do not model never misrenders, it just no-ops.
29
+ *
30
+ * @param src The formula source.
31
+ * @returns The parsed syntax tree.
32
+ * @throws ParseError on a malformed formula (or {@link LexError} from tokenizing).
33
+ */
24
34
  function parse(src) {
25
35
  const parser = new Parser(tokenize(src));
26
36
  const ast = parser.parseExpr(0);
27
37
  parser.expectEof();
28
38
  return ast;
29
39
  }
40
+ /** A precedence-climbing (Pratt) parser over a {@link tokenize} token stream. */
30
41
  var Parser = class {
31
42
  pos = 0;
32
43
  depth = 0;
44
+ /** @param toks The token stream to parse (must end with an `eof` token). */
33
45
  constructor(toks) {
34
46
  this.toks = toks;
35
47
  }
48
+ /** The current token without consuming it. */
36
49
  peek() {
37
50
  return this.toks[this.pos];
38
51
  }
52
+ /** Consume and return the current token. */
39
53
  next() {
40
54
  return this.toks[this.pos++];
41
55
  }
56
+ /** Assert the stream is fully consumed; throws `ParseError` on trailing tokens. */
42
57
  expectEof() {
43
58
  if (this.peek().kind !== "eof") throw new ParseError(`trailing tokens at ${this.pos}`);
44
59
  }
60
+ /**
61
+ * Parse an expression whose operators bind at least as tightly as `minBp`
62
+ * (the precedence-climbing entry point).
63
+ *
64
+ * @param minBp The minimum binding power; operators below it stop the climb.
65
+ * @returns The parsed sub-tree.
66
+ * @throws ParseError when the expression nests past the depth cap or is malformed.
67
+ */
45
68
  parseExpr(minBp) {
46
69
  if (++this.depth > MAX_DEPTH) throw new ParseError("expression too deep");
47
70
  let left = this.parseUnary();
@@ -63,6 +86,11 @@ var Parser = class {
63
86
  this.depth--;
64
87
  return left;
65
88
  }
89
+ /**
90
+ * Parse a (possibly signed) operand. Unary `+`/`-` bind tighter than `^`
91
+ * (Excel: `-2^2` = 4), so they live above the binary loop; postfix `%` binds
92
+ * tighter still.
93
+ */
66
94
  parseUnary() {
67
95
  const t = this.peek();
68
96
  if (t.kind === "op" && (t.text === "-" || t.text === "+")) {
@@ -75,6 +103,7 @@ var Parser = class {
75
103
  }
76
104
  return this.parsePostfix();
77
105
  }
106
+ /** Parse a primary then fold any trailing postfix `%` percent operators. */
78
107
  parsePostfix() {
79
108
  let x = this.parsePrimary();
80
109
  while (this.peek().kind === "op" && this.peek().text === "%") {
@@ -86,6 +115,11 @@ var Parser = class {
86
115
  }
87
116
  return x;
88
117
  }
118
+ /**
119
+ * Parse a primary expression: a literal, a parenthesised sub-expression, an
120
+ * inline array constant, or a word (classified by `parseWord` /
121
+ * sheet-qualifier handling).
122
+ */
89
123
  parsePrimary() {
90
124
  const t = this.next();
91
125
  switch (t.kind) {
@@ -125,6 +159,12 @@ var Parser = class {
125
159
  case "eof": throw new ParseError("unexpected end of formula");
126
160
  }
127
161
  }
162
+ /**
163
+ * Classify a `word` token: a `(` directly after it makes it a function call,
164
+ * regardless of shape (so `LOG10( … )` is the function, bare `LOG10` is the
165
+ * cell reference); else an A1-shaped word is a cell ref (extended to a range on
166
+ * a trailing `:`), `TRUE`/`FALSE` a logical, anything else a defined name.
167
+ */
128
168
  parseWord(word) {
129
169
  if (this.peek().kind === "op" && this.peek().text === "(") {
130
170
  this.next();
@@ -174,6 +214,11 @@ var Parser = class {
174
214
  name: upper
175
215
  };
176
216
  }
217
+ /**
218
+ * Parse a sheet-qualified cell or range — the `!` is already consumed; `sheet`
219
+ * is the (unquoted) sheet name. `Sheet2!A1` or `Sheet2!A1:B3`. The evaluator
220
+ * resolves the name against the workbook; an unknown sheet becomes `#REF!`.
221
+ */
177
222
  parseSheetCell(sheet) {
178
223
  const t = this.next();
179
224
  if (t.kind !== "word") throw new ParseError("expected a cell after !");
@@ -198,6 +243,12 @@ var Parser = class {
198
243
  sheet
199
244
  };
200
245
  }
246
+ /**
247
+ * Parse an inline array constant `{1,2,3}` / `{1,2;3,4}`: rows separated by
248
+ * `;`, elements by `,`. The opening `{` is already consumed. Elements are
249
+ * parsed as expressions (so a signed literal like `-1` works) and reduced to
250
+ * scalars at eval; the element count is capped against a crafted huge array.
251
+ */
201
252
  parseArray() {
202
253
  const rows = [];
203
254
  let row = [];
@@ -225,6 +276,7 @@ var Parser = class {
225
276
  rows
226
277
  };
227
278
  }
279
+ /** Parse a comma-separated function argument list (the `(` already consumed). */
228
280
  parseArgs() {
229
281
  const args = [];
230
282
  if (this.peek().kind === "op" && this.peek().text === ")") return args;
@@ -240,6 +292,7 @@ var Parser = class {
240
292
  }
241
293
  return args;
242
294
  }
295
+ /** Consume the next token, asserting it is the operator `op`. */
243
296
  expect(op) {
244
297
  const t = this.next();
245
298
  if (t.kind !== "op" || t.text !== op) throw new ParseError(`expected ${op}`);
@@ -1,11 +1,21 @@
1
1
  import { EvalContext } from './context.js';
2
+ /**
3
+ * §18.17.2 — the seven error values a formula can carry. Stored as their literal
4
+ * display text so they round-trip and read naturally in diagnostics.
5
+ */
2
6
  export type FErr = '#NULL!' | '#DIV/0!' | '#VALUE!' | '#REF!' | '#NAME?' | '#NUM!' | '#N/A';
7
+ /**
8
+ * A rectangle of cells (absolute, 0-indexed, inclusive) — the value an `A1:B3`
9
+ * reference evaluates to. A single cell is a 1×1 rect. Aggregate functions iterate
10
+ * it; scalar contexts dereference it (1×1 → its value, else `#VALUE!`).
11
+ */
3
12
  export interface Rect {
4
13
  readonly r0: number;
5
14
  readonly c0: number;
6
15
  readonly r1: number;
7
16
  readonly c1: number;
8
17
  }
18
+ /** One of the five scalar value kinds a formula evaluates to. */
9
19
  export type Scalar = {
10
20
  readonly t: 'num';
11
21
  readonly v: number;
@@ -21,6 +31,19 @@ export type Scalar = {
21
31
  } | {
22
32
  readonly t: 'blank';
23
33
  };
34
+ /**
35
+ * Any value a formula evaluates to: a {@link Scalar}, a `ref` (a {@link Rect},
36
+ * optionally cross-sheet), or an `arr` (an inline array constant).
37
+ *
38
+ * `sheet` (a workbook sheet index) is set only for a cross-sheet qualifier
39
+ * (`Sheet2!A1`) or a defined name that targets another sheet; when undefined the
40
+ * reference is on the rule's own sheet (the common case).
41
+ *
42
+ * An `arr` value is an inline array constant (`{1,2;3,4}`) — rows of scalars. It
43
+ * flattens into aggregates, broadcasts element-wise against a scalar in the
44
+ * operators, and collapses to its top-left element in a scalar context (Excel's
45
+ * implicit intersection of a constant array).
46
+ */
24
47
  export type FValue = Scalar | {
25
48
  readonly t: 'ref';
26
49
  readonly rect: Rect;
@@ -29,24 +52,54 @@ export type FValue = Scalar | {
29
52
  readonly t: 'arr';
30
53
  readonly rows: ReadonlyArray<ReadonlyArray<Scalar>>;
31
54
  };
55
+ /** The blank scalar (an empty / absent cell). */
32
56
  export declare const BLANK: Scalar;
57
+ /** The logical TRUE scalar. */
33
58
  export declare const TRUE: Scalar;
59
+ /** The logical FALSE scalar. */
34
60
  export declare const FALSE: Scalar;
61
+ /** Wrap a number as a scalar; a non-finite result (overflow, 0/0) becomes `#NUM!`. */
35
62
  export declare function num(v: number): Scalar;
63
+ /** Wrap a string as a text scalar. */
36
64
  export declare function str(v: string): Scalar;
65
+ /** The {@link TRUE} / {@link FALSE} scalar for a boolean. */
37
66
  export declare function bool(v: boolean): Scalar;
67
+ /** Wrap an error code as an error scalar. */
38
68
  export declare function err(v: FErr): Scalar;
69
+ /** Type guard: is the value an error scalar? */
39
70
  export declare function isErr(v: FValue): v is {
40
71
  t: 'err';
41
72
  v: FErr;
42
73
  };
74
+ /**
75
+ * Collapse a reference to a scalar: a 1×1 rect yields the cell's value (a blank cell
76
+ * → blank); any larger rect in a scalar context is `#VALUE!` (we do not implement
77
+ * implicit intersection). An array constant collapses to its top-left element;
78
+ * non-refs pass through unchanged.
79
+ */
43
80
  export declare function deref(v: FValue, ctx: EvalContext): Scalar;
81
+ /** Visit every scalar element of an array constant, row by row. */
44
82
  export declare function arrEach(rows: ReadonlyArray<ReadonlyArray<Scalar>>, visit: (value: Scalar) => void): void;
83
+ /**
84
+ * Iterate the populated cells of a reference, honouring a cross-sheet qualifier (an
85
+ * absent `eachCellOn` ⇒ no cross-sheet support ⇒ the foreign range is empty).
86
+ */
45
87
  export declare function refEach(v: {
46
88
  readonly rect: Rect;
47
89
  readonly sheet?: number;
48
90
  }, ctx: EvalContext, visit: (row: number, col: number, value: Scalar) => void): void;
91
+ /** Read one absolute cell on a reference's sheet (the current sheet when `sheet` is unset). */
49
92
  export declare function refGet(sheet: number | undefined, ctx: EvalContext, row: number, col: number): Scalar;
93
+ /**
94
+ * §18.17.3 — number coercion. blank → 0, logical → 1/0, a numeric string → its
95
+ * number (Excel parses `"5"` and `" 5 "` leniently); non-numeric text → `#VALUE!`.
96
+ * An error propagates (returned as the {@link FErr}); references are dereferenced first.
97
+ */
50
98
  export declare function toNumber(v: FValue, ctx: EvalContext): number | FErr;
99
+ /**
100
+ * §18.17.3 — text coercion. A number formats with the shortest round-trip
101
+ * representation, a logical as `TRUE`/`FALSE`, blank as the empty string. Errors
102
+ * propagate (returned as the {@link FErr}).
103
+ */
51
104
  export declare function toText(v: FValue, ctx: EvalContext): string | FErr;
52
105
  export declare function toBool(v: FValue, ctx: EvalContext): boolean | FErr;
@@ -1,13 +1,17 @@
1
1
  //#region src/excel/formula/value.ts
2
+ /** The blank scalar (an empty / absent cell). */
2
3
  var BLANK = { t: "blank" };
4
+ /** The logical TRUE scalar. */
3
5
  var TRUE = {
4
6
  t: "bool",
5
7
  v: true
6
8
  };
9
+ /** The logical FALSE scalar. */
7
10
  var FALSE = {
8
11
  t: "bool",
9
12
  v: false
10
13
  };
14
+ /** Wrap a number as a scalar; a non-finite result (overflow, 0/0) becomes `#NUM!`. */
11
15
  function num(v) {
12
16
  return Number.isFinite(v) ? {
13
17
  t: "num",
@@ -17,24 +21,34 @@ function num(v) {
17
21
  v: "#NUM!"
18
22
  };
19
23
  }
24
+ /** Wrap a string as a text scalar. */
20
25
  function str(v) {
21
26
  return {
22
27
  t: "str",
23
28
  v
24
29
  };
25
30
  }
31
+ /** The {@link TRUE} / {@link FALSE} scalar for a boolean. */
26
32
  function bool(v) {
27
33
  return v ? TRUE : FALSE;
28
34
  }
35
+ /** Wrap an error code as an error scalar. */
29
36
  function err(v) {
30
37
  return {
31
38
  t: "err",
32
39
  v
33
40
  };
34
41
  }
42
+ /** Type guard: is the value an error scalar? */
35
43
  function isErr(v) {
36
44
  return v.t === "err";
37
45
  }
46
+ /**
47
+ * Collapse a reference to a scalar: a 1×1 rect yields the cell's value (a blank cell
48
+ * → blank); any larger rect in a scalar context is `#VALUE!` (we do not implement
49
+ * implicit intersection). An array constant collapses to its top-left element;
50
+ * non-refs pass through unchanged.
51
+ */
38
52
  function deref(v, ctx) {
39
53
  if (v.t === "arr") return v.rows[0]?.[0] ?? BLANK;
40
54
  if (v.t !== "ref") return v;
@@ -42,16 +56,27 @@ function deref(v, ctx) {
42
56
  if (r0 === r1 && c0 === c1) return refGet(v.sheet, ctx, r0, c0);
43
57
  return err("#VALUE!");
44
58
  }
59
+ /** Visit every scalar element of an array constant, row by row. */
45
60
  function arrEach(rows, visit) {
46
61
  for (const row of rows) for (const s of row) visit(s);
47
62
  }
63
+ /**
64
+ * Iterate the populated cells of a reference, honouring a cross-sheet qualifier (an
65
+ * absent `eachCellOn` ⇒ no cross-sheet support ⇒ the foreign range is empty).
66
+ */
48
67
  function refEach(v, ctx, visit) {
49
68
  if (v.sheet !== void 0) ctx.eachCellOn?.(v.sheet, v.rect, visit);
50
69
  else ctx.eachCell(v.rect, visit);
51
70
  }
71
+ /** Read one absolute cell on a reference's sheet (the current sheet when `sheet` is unset). */
52
72
  function refGet(sheet, ctx, row, col) {
53
73
  return sheet !== void 0 ? ctx.getCellOn?.(sheet, row, col) ?? BLANK : ctx.getCell(row, col);
54
74
  }
75
+ /**
76
+ * §18.17.3 — number coercion. blank → 0, logical → 1/0, a numeric string → its
77
+ * number (Excel parses `"5"` and `" 5 "` leniently); non-numeric text → `#VALUE!`.
78
+ * An error propagates (returned as the {@link FErr}); references are dereferenced first.
79
+ */
55
80
  function toNumber(v, ctx) {
56
81
  const s = deref(v, ctx);
57
82
  switch (s.t) {
@@ -67,6 +92,11 @@ function toNumber(v, ctx) {
67
92
  }
68
93
  }
69
94
  }
95
+ /**
96
+ * §18.17.3 — text coercion. A number formats with the shortest round-trip
97
+ * representation, a logical as `TRUE`/`FALSE`, blank as the empty string. Errors
98
+ * propagate (returned as the {@link FErr}).
99
+ */
70
100
  function toText(v, ctx) {
71
101
  const s = deref(v, ctx);
72
102
  switch (s.t) {
@@ -1,2 +1,11 @@
1
1
  import { BodyElement } from '../core/document-model/index.js';
2
+ /**
3
+ * Expand a print header/footer `&`-code string (E-SHEET W4) into header/footer band
4
+ * content — one aligned paragraph per non-empty left/centre/right region — or `[]`
5
+ * when every region is empty. `&P`/`&N` become dynamic PAGE/NUMPAGES field runs the
6
+ * renderer resolves per page; non-deterministic or unsupported codes are dropped.
7
+ *
8
+ * @param formatString The raw `&`-code format string.
9
+ * @param sheetName The worksheet tab name, substituted for `&A`.
10
+ */
2
11
  export declare function buildHeaderFooterContent(formatString: string, sheetName: string): Array<BodyElement>;
@@ -1,4 +1,13 @@
1
1
  //#region src/excel/header-footer.ts
2
+ /**
3
+ * Expand a print header/footer `&`-code string (E-SHEET W4) into header/footer band
4
+ * content — one aligned paragraph per non-empty left/centre/right region — or `[]`
5
+ * when every region is empty. `&P`/`&N` become dynamic PAGE/NUMPAGES field runs the
6
+ * renderer resolves per page; non-deterministic or unsupported codes are dropped.
7
+ *
8
+ * @param formatString The raw `&`-code format string.
9
+ * @param sheetName The worksheet tab name, substituted for `&A`.
10
+ */
2
11
  function buildHeaderFooterContent(formatString, sheetName) {
3
12
  const regions = parseHeaderFooterString(formatString, sheetName);
4
13
  const out = [];
@@ -1,3 +1,37 @@
1
+ /**
2
+ * Render a cell's raw stored value through its number format (§18.8.30 built-ins
3
+ * and §18.8.31 custom codes). Handles `General`, text (`@`), the built-in date /
4
+ * time formats, custom date codes, and the numeric placeholder grammar (`0` `#`
5
+ * `,` `.` `%`, scientific notation, quoted literals, `;`-separated sections). An
6
+ * unknown id, or a value that does not parse as a number, falls back to a plain
7
+ * render of `rawValue`.
8
+ *
9
+ * @param rawValue The cell's raw stored value (a serial for dates).
10
+ * @param numFmtId The number-format id from the cell's `cellXf`.
11
+ * @param customFormats Custom format codes by id (from `<numFmts>`).
12
+ * @param date1904 The workbook date epoch (1904 vs the 1900 default).
13
+ * @returns The formatted display string.
14
+ */
1
15
  export declare function applyNumberFormat(rawValue: string, numFmtId: number, customFormats: ReadonlyMap<number, string>, date1904?: boolean): string;
16
+ /**
17
+ * Excel serial date → JS `Date`. The default 1900 epoch uses 1899-12-30 as day 0
18
+ * (so serial 1 is 1900-01-01) and inherits the Lotus 1-2-3 leap-year bug: serial 60
19
+ * is considered "1900-02-29" which never existed. For serial ≥ 61 the simple
20
+ * formula is exact; values < 60 are vanishingly rare in business sheets (and our
21
+ * render is approximate anyway).
22
+ *
23
+ * The 1904 epoch (legacy Mac Excel) uses 1904-01-01 as day 0 and has no leap bug.
24
+ * Files saved with `<workbookPr date1904="1"/>` store dates offset by exactly 1462
25
+ * days from the 1900-epoch interpretation.
26
+ */
2
27
  export declare function excelSerialToDate(serial: number, date1904: boolean): Date;
28
+ /**
29
+ * The inverse over a UTC calendar date: `(year, month0, day)` → the integer Excel
30
+ * serial day, using the same epoch. Round-trips {@link excelSerialToDate} exactly
31
+ * for an integer serial (the time-of-day is zero), so a serial → parts → serial
32
+ * loop is stable. Used by the formula engine's date functions and the `timePeriod`
33
+ * windows (E-SHEET W9) to map an injected reference date into serial space.
34
+ *
35
+ * @param month0 The 0-indexed month (0 = January).
36
+ */
3
37
  export declare function excelSerialFromUtcParts(year: number, month0: number, day: number, date1904: boolean): number;
@@ -28,6 +28,20 @@ var BUILTIN_DATE_FORMATS = new Map([
28
28
  [46, "[h]:mm:ss"],
29
29
  [47, "mm:ss.0"]
30
30
  ]);
31
+ /**
32
+ * Render a cell's raw stored value through its number format (§18.8.30 built-ins
33
+ * and §18.8.31 custom codes). Handles `General`, text (`@`), the built-in date /
34
+ * time formats, custom date codes, and the numeric placeholder grammar (`0` `#`
35
+ * `,` `.` `%`, scientific notation, quoted literals, `;`-separated sections). An
36
+ * unknown id, or a value that does not parse as a number, falls back to a plain
37
+ * render of `rawValue`.
38
+ *
39
+ * @param rawValue The cell's raw stored value (a serial for dates).
40
+ * @param numFmtId The number-format id from the cell's `cellXf`.
41
+ * @param customFormats Custom format codes by id (from `<numFmts>`).
42
+ * @param date1904 The workbook date epoch (1904 vs the 1900 default).
43
+ * @returns The formatted display string.
44
+ */
31
45
  function applyNumberFormat(rawValue, numFmtId, customFormats, date1904 = false) {
32
46
  if (rawValue.length === 0) return "";
33
47
  if (numFmtId === 0) return defaultNumberRender(rawValue);
@@ -41,11 +55,31 @@ function applyNumberFormat(rawValue, numFmtId, customFormats, date1904 = false)
41
55
  if (format === "General") return defaultNumberRender(rawValue);
42
56
  return applyFormatString(rawValue, format);
43
57
  }
58
+ /**
59
+ * Excel serial date → JS `Date`. The default 1900 epoch uses 1899-12-30 as day 0
60
+ * (so serial 1 is 1900-01-01) and inherits the Lotus 1-2-3 leap-year bug: serial 60
61
+ * is considered "1900-02-29" which never existed. For serial ≥ 61 the simple
62
+ * formula is exact; values < 60 are vanishingly rare in business sheets (and our
63
+ * render is approximate anyway).
64
+ *
65
+ * The 1904 epoch (legacy Mac Excel) uses 1904-01-01 as day 0 and has no leap bug.
66
+ * Files saved with `<workbookPr date1904="1"/>` store dates offset by exactly 1462
67
+ * days from the 1900-epoch interpretation.
68
+ */
44
69
  function excelSerialToDate(serial, date1904) {
45
70
  const ms = serial * 86400 * 1e3;
46
71
  if (date1904) return new Date(Date.UTC(1904, 0, 1) + ms);
47
72
  return new Date(Date.UTC(1899, 11, 30) + ms);
48
73
  }
74
+ /**
75
+ * The inverse over a UTC calendar date: `(year, month0, day)` → the integer Excel
76
+ * serial day, using the same epoch. Round-trips {@link excelSerialToDate} exactly
77
+ * for an integer serial (the time-of-day is zero), so a serial → parts → serial
78
+ * loop is stable. Used by the formula engine's date functions and the `timePeriod`
79
+ * windows (E-SHEET W9) to map an injected reference date into serial space.
80
+ *
81
+ * @param month0 The 0-indexed month (0 = January).
82
+ */
49
83
  function excelSerialFromUtcParts(year, month0, day, date1904) {
50
84
  const epoch = date1904 ? Date.UTC(1904, 0, 1) : Date.UTC(1899, 11, 30);
51
85
  return Math.round((Date.UTC(year, month0, day) - epoch) / 864e5);
@@ -1,2 +1,10 @@
1
1
  import { PivotTable } from '../core/spreadsheet-model/index.js';
2
+ /**
3
+ * Parse `xl/pivotTables/pivotTableN.xml` (§18.10.1.73) into a {@link PivotTable}:
4
+ * the output `<location>` (range + header/data offsets), the banded-style flags,
5
+ * and the row/column total markers derived from `<rowItems>`/`<colItems>` (so the
6
+ * reader can band the region in the pivot palette — E-PIVOT). The output cells are
7
+ * already cached in the worksheet, so they render as a normal grid. Returns
8
+ * undefined when the root or its `ref` is missing.
9
+ */
2
10
  export declare function parsePivotTablePart(data: Uint8Array): PivotTable | undefined;
@@ -9,6 +9,14 @@ var parser = new XMLParser({
9
9
  parseTagValue: false,
10
10
  removeNSPrefix: true
11
11
  });
12
+ /**
13
+ * Parse `xl/pivotTables/pivotTableN.xml` (§18.10.1.73) into a {@link PivotTable}:
14
+ * the output `<location>` (range + header/data offsets), the banded-style flags,
15
+ * and the row/column total markers derived from `<rowItems>`/`<colItems>` (so the
16
+ * reader can band the region in the pivot palette — E-PIVOT). The output cells are
17
+ * already cached in the worksheet, so they render as a normal grid. Returns
18
+ * undefined when the root or its `ref` is missing.
19
+ */
12
20
  function parsePivotTablePart(data) {
13
21
  const def = asObj(parser.parse(decoder.decode(data))["pivotTableDefinition"]);
14
22
  if (!def) return void 0;
@@ -1,11 +1,34 @@
1
1
  import { BodyElement, SectionProperties, Table } from '../core/document-model/index.js';
2
2
  import { CellRange, DefinedName, ParsedWorksheet, SheetRichRun, WorksheetCell, XlsxStyles } from './index.js';
3
3
  import { SheetHyperlink, SheetSlicer } from '../core/ir/sheet.js';
4
+ /**
5
+ * Excel "character width" → twips. Calibri 11pt default Maximum Digit Width is
6
+ * ~7 px ≈ 5.25 pt ≈ 105 twips. This is a coarse approximation but the auto-fit
7
+ * pass refines column widths against the actual cell text anyway.
8
+ */
4
9
  export declare const TWIPS_PER_EXCEL_CHAR = 105;
10
+ /**
11
+ * Excel's default column width is 8.43 "characters" ≈ 64px ≈ 960 twips. Used for
12
+ * columns without an explicit `<col width="..">`.
13
+ */
5
14
  export declare const DEFAULT_COL_TWIPS = 960;
15
+ /**
16
+ * Excel's default row height is ~15pt = 300 twips. Used (for the `fitToHeight`
17
+ * estimate) for rows without an explicit `<row ht="..">`.
18
+ */
6
19
  export declare const DEFAULT_ROW_TWIPS = 300;
20
+ /**
21
+ * Build the page section (paper size + margins) from a worksheet's `<pageSetup>`
22
+ * / `<pageMargins>`. Returns `undefined` when neither is set, so the renderer
23
+ * applies its A4 default.
24
+ */
7
25
  export declare function sectionFromWorksheet(worksheet: ParsedWorksheet): SectionProperties | undefined;
26
+ /**
27
+ * ECMA-376 §18.2.5 — resolve the sheet-scoped `_xlnm.Print_Area` defined name
28
+ * (`localSheetId` = the sheet's 0-based index) into a clipping range.
29
+ */
8
30
  export declare function resolvePrintArea(definedNames: ReadonlyArray<DefinedName>, sheetIdx: number): CellRange | undefined;
31
+ /** ECMA-376 §18.2.5 — `_xlnm.Print_Titles` → the repeated row range (0-indexed). */
9
32
  export declare function resolvePrintTitleRows(definedNames: ReadonlyArray<DefinedName>, sheetIdx: number): {
10
33
  readonly startRow: number;
11
34
  readonly endRow: number;
@@ -24,7 +47,40 @@ interface PrintModelOptions {
24
47
  readonly sharedStringRuns?: ReadonlyArray<ReadonlyArray<SheetRichRun> | undefined>;
25
48
  readonly now?: Date;
26
49
  }
50
+ /**
51
+ * Project one worksheet's grid into Flow body elements — a single {@link Table}
52
+ * (or, when the sheet is wider than the page, several column-banded tables). The
53
+ * full print model lives here: the used-range/print-area window, merge handling,
54
+ * the style cascade (fonts/fills/borders/alignment), print scaling, conditional
55
+ * formatting, sparklines, table/pivot banding, overflow and rotation. Memory- and
56
+ * text-budget-bounded against untrusted input.
57
+ *
58
+ * @param worksheet The parsed grid + per-sheet geometry.
59
+ * @param sharedStrings The workbook shared-string table (`t="s"` cells index it).
60
+ * @param styles The workbook style table (cellXfs + fonts/fills/borders).
61
+ * @param date1904 The 1904 date system flag (serial-to-date epoch).
62
+ * @param print The print-model knobs (print area, gridlines, title rows, …).
63
+ * @returns The body elements (one table block, or banded tables); empty for a
64
+ * blank or empty-print-area sheet.
65
+ */
27
66
  export declare function worksheetToBody(worksheet: ParsedWorksheet, sharedStrings: ReadonlyArray<string>, styles: XlsxStyles, date1904: boolean, print: PrintModelOptions): Array<BodyElement>;
67
+ /**
68
+ * Resolve a cell's displayed text from its RAW stored value: shared-string and
69
+ * inline-string lookup, boolean → `TRUE`/`FALSE`, and the number-format pass
70
+ * (§18.8) for numeric cells. Error/string/date cells pass through verbatim.
71
+ *
72
+ * @param cell The parsed cell.
73
+ * @param sharedStrings The shared-string table for `t="s"` cells.
74
+ * @param styles The style table (for the cell's number format).
75
+ * @param date1904 The 1904 date system flag.
76
+ * @returns The resolved display string.
77
+ */
28
78
  export declare function resolveCellText(cell: WorksheetCell, sharedStrings: ReadonlyArray<string>, styles: XlsxStyles, date1904: boolean): string;
79
+ /**
80
+ * Project a slicer panel (E-SHEET SV2) into a styled mini-{@link Table} emitted
81
+ * after the grid: a caption header spanning the button columns, then one button
82
+ * cell per item — the slicer accent fill + white text when selected, a light
83
+ * band when not; the last row padded so every row keeps the column count.
84
+ */
29
85
  export declare function slicerTable(slicer: SheetSlicer): Table;
30
86
  export {};
@@ -16,6 +16,11 @@ var PAPER_SIZES_TWIPS = new Map([
16
16
  [70, [5953, 8392]]
17
17
  ]);
18
18
  var DEFAULT_PAPER_TWIPS = [11906, 16838];
19
+ /**
20
+ * Build the page section (paper size + margins) from a worksheet's `<pageSetup>`
21
+ * / `<pageMargins>`. Returns `undefined` when neither is set, so the renderer
22
+ * applies its A4 default.
23
+ */
19
24
  function sectionFromWorksheet(worksheet) {
20
25
  const pageSize = pageSizeFromSetup(worksheet.pageSetup);
21
26
  const margins = marginsFromXlsx(worksheet.pageMargins);
@@ -52,9 +57,14 @@ function marginsFromXlsx(margins) {
52
57
  }
53
58
  var PRINT_AREA_NAME = "_xlnm.Print_Area";
54
59
  var PRINT_TITLES_NAME = "_xlnm.Print_Titles";
60
+ /**
61
+ * ECMA-376 §18.2.5 — resolve the sheet-scoped `_xlnm.Print_Area` defined name
62
+ * (`localSheetId` = the sheet's 0-based index) into a clipping range.
63
+ */
55
64
  function resolvePrintArea(definedNames, sheetIdx) {
56
65
  for (const dn of definedNames) if (dn.name === PRINT_AREA_NAME && dn.localSheetId === sheetIdx) return parseAreaRef(dn.value);
57
66
  }
67
+ /** ECMA-376 §18.2.5 — `_xlnm.Print_Titles` → the repeated row range (0-indexed). */
58
68
  function resolvePrintTitleRows(definedNames, sheetIdx) {
59
69
  for (const dn of definedNames) if (dn.name === PRINT_TITLES_NAME && dn.localSheetId === sheetIdx) return parseTitleRowRange(dn.value);
60
70
  }
@@ -97,6 +107,22 @@ function scaleRunFont(props, scale) {
97
107
  };
98
108
  }
99
109
  var MAX_SHEET_TEXT_CHARS = 1e6;
110
+ /**
111
+ * Project one worksheet's grid into Flow body elements — a single {@link Table}
112
+ * (or, when the sheet is wider than the page, several column-banded tables). The
113
+ * full print model lives here: the used-range/print-area window, merge handling,
114
+ * the style cascade (fonts/fills/borders/alignment), print scaling, conditional
115
+ * formatting, sparklines, table/pivot banding, overflow and rotation. Memory- and
116
+ * text-budget-bounded against untrusted input.
117
+ *
118
+ * @param worksheet The parsed grid + per-sheet geometry.
119
+ * @param sharedStrings The workbook shared-string table (`t="s"` cells index it).
120
+ * @param styles The workbook style table (cellXfs + fonts/fills/borders).
121
+ * @param date1904 The 1904 date system flag (serial-to-date epoch).
122
+ * @param print The print-model knobs (print area, gridlines, title rows, …).
123
+ * @returns The body elements (one table block, or banded tables); empty for a
124
+ * blank or empty-print-area sheet.
125
+ */
100
126
  function worksheetToBody(worksheet, sharedStrings, styles, date1904, print) {
101
127
  if (worksheet.maxRow < 0 || worksheet.maxColumn < 0) return [];
102
128
  let usedRow = -1;
@@ -384,6 +410,17 @@ function makeVerticalContinuation(merge, colWindowEnd, absR, rowWindowEnd) {
384
410
  }]
385
411
  };
386
412
  }
413
+ /**
414
+ * Resolve a cell's displayed text from its RAW stored value: shared-string and
415
+ * inline-string lookup, boolean → `TRUE`/`FALSE`, and the number-format pass
416
+ * (§18.8) for numeric cells. Error/string/date cells pass through verbatim.
417
+ *
418
+ * @param cell The parsed cell.
419
+ * @param sharedStrings The shared-string table for `t="s"` cells.
420
+ * @param styles The style table (for the cell's number format).
421
+ * @param date1904 The 1904 date system flag.
422
+ * @returns The resolved display string.
423
+ */
387
424
  function resolveCellText(cell, sharedStrings, styles, date1904) {
388
425
  if (cell.type === "inlineStr") return cell.inlineText ?? "";
389
426
  if (cell.type === "s") {
@@ -698,6 +735,12 @@ function cellHasContent(cell) {
698
735
  var SLICER_WIDTH_PT = 108;
699
736
  var SLICER_ROW_PT = 16;
700
737
  var SLICER_UNSELECTED_HEX = "F2F2F2";
738
+ /**
739
+ * Project a slicer panel (E-SHEET SV2) into a styled mini-{@link Table} emitted
740
+ * after the grid: a caption header spanning the button columns, then one button
741
+ * cell per item — the slicer accent fill + white text when selected, a light
742
+ * band when not; the last row padded so every row keeps the column count.
743
+ */
701
744
  function slicerTable(slicer) {
702
745
  const cols = Math.max(1, slicer.columnCount);
703
746
  const colWidthPt = SLICER_WIDTH_PT / cols;
@@ -1,6 +1,19 @@
1
1
  import { SheetRichRun } from '../core/spreadsheet-model/index.js';
2
+ /**
3
+ * The flattened text of every shared string (a cell with `t="s"` indexes into it),
4
+ * plus — for the strings that carry per-run formatting — the parsed rich runs
5
+ * (E-SHEET W6). `runs[i]` is undefined unless si `i` has ≥ 2 runs OR a single run
6
+ * that actually sets formatting, so the common plain-text case stays cheap.
7
+ */
2
8
  export interface SharedStrings {
9
+ /** The flattened text of each shared string, parallel to the `<si>` order. */
3
10
  readonly texts: ReadonlyArray<string>;
11
+ /** Per-index rich runs, parallel to {@link SharedStrings.texts}; `undefined` for plain strings. */
4
12
  readonly runs: ReadonlyArray<ReadonlyArray<SheetRichRun> | undefined>;
5
13
  }
14
+ /**
15
+ * Parse `xl/sharedStrings.xml` (§18.4.8) into the deduplicated string table plus,
16
+ * for rich strings, their per-run formatting. Each string is capped to the Excel
17
+ * cell limit (32 767 chars).
18
+ */
6
19
  export declare function parseSharedStrings(data: Uint8Array): SharedStrings;
@@ -14,6 +14,11 @@ var MAX_CELL_CHARS = 32767;
14
14
  function capLen(s) {
15
15
  return s.length > MAX_CELL_CHARS ? s.slice(0, MAX_CELL_CHARS) : s;
16
16
  }
17
+ /**
18
+ * Parse `xl/sharedStrings.xml` (§18.4.8) into the deduplicated string table plus,
19
+ * for rich strings, their per-run formatting. Each string is capped to the Excel
20
+ * cell limit (32 767 chars).
21
+ */
17
22
  function parseSharedStrings(data) {
18
23
  const xml = decoder.decode(data);
19
24
  const sst = parser.parse(xml)["sst"];