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,4 +1,8 @@
1
1
  import { Chart, ChartSeries } from '../document-model/index.js';
2
+ /**
3
+ * An axis-aligned rectangle in the scene's local y-up frame: bars, scatter
4
+ * point markers, legend swatches. Position is the bottom-left corner.
5
+ */
2
6
  export interface ChartRect {
3
7
  readonly x: number;
4
8
  readonly y: number;
@@ -8,17 +12,24 @@ export interface ChartRect {
8
12
  readonly strokeHex?: string;
9
13
  readonly strokeWidthPt?: number;
10
14
  }
15
+ /** An open stroked polyline: line-chart series, gridlines and axis lines. */
11
16
  export interface ChartPolyline {
12
17
  readonly points: ReadonlyArray<readonly [number, number]>;
13
18
  readonly strokeHex: string;
14
19
  readonly widthPt: number;
15
20
  }
21
+ /** A closed, filled polygon (area-chart bands). Drawn before strokes/labels. */
16
22
  export interface ChartPolygon {
17
23
  readonly points: ReadonlyArray<readonly [number, number]>;
18
24
  readonly fillHex: string;
19
25
  readonly strokeHex?: string;
20
26
  readonly widthPt?: number;
21
27
  }
28
+ /**
29
+ * A circular sector (pie/doughnut slice), centred at `(cx, cy)` with radius `r`.
30
+ * `startRad`/`sweepRad` are radians in the y-up frame; sweeps are negative for
31
+ * Excel's clockwise winding. The doughnut hole is a white wedge drawn last.
32
+ */
22
33
  export interface ChartWedge {
23
34
  readonly cx: number;
24
35
  readonly cy: number;
@@ -28,15 +39,25 @@ export interface ChartWedge {
28
39
  readonly fillHex: string;
29
40
  readonly strokeHex?: string;
30
41
  }
42
+ /** How a {@link ChartLabel} sits horizontally relative to its anchor point. */
31
43
  export type LabelAlign = 'left' | 'center' | 'right';
44
+ /** A text label (title, axis tick, category, data value, legend entry). */
32
45
  export interface ChartLabel {
33
46
  readonly text: string;
47
+ /** Anchor point; `align` says how text sits relative to it. */
34
48
  readonly x: number;
49
+ /** Text baseline. */
35
50
  readonly y: number;
36
51
  readonly sizePt: number;
37
52
  readonly colorHex: string;
38
53
  readonly align: LabelAlign;
39
54
  }
55
+ /**
56
+ * The fully laid-out chart: rectangles, polylines, wedges and labels (plus
57
+ * optional filled polygons) in a local y-up frame, origin bottom-left. The
58
+ * renderer maps these to draw commands — rects/polylines/wedges/polygons via the
59
+ * vector layer, labels via the text pass.
60
+ */
40
61
  export interface ChartScene {
41
62
  readonly rects: ReadonlyArray<ChartRect>;
42
63
  readonly polylines: ReadonlyArray<ChartPolyline>;
@@ -44,21 +65,125 @@ export interface ChartScene {
44
65
  readonly labels: ReadonlyArray<ChartLabel>;
45
66
  readonly polygons?: ReadonlyArray<ChartPolygon>;
46
67
  }
68
+ /**
69
+ * Injected text-width measurer: the rendered advance width (points) of `text` at
70
+ * `sizePt`. Keeps this module free of any font/PDF dependency, so it is
71
+ * unit-testable in isolation.
72
+ */
47
73
  export type MeasureText = (text: string, sizePt: number) => number;
74
+ /** Font size (points) for axis ticks, category/data labels and legend text. */
48
75
  export declare const CHART_LABEL_PT = 9;
76
+ /** Font size (points) for the chart title. */
49
77
  export declare const CHART_TITLE_PT = 13;
78
+ /** The Office accent cycle (RRGGBB) for series without an explicit colour. */
50
79
  export declare const SERIES_COLORS: string[];
80
+ /**
81
+ * Resolve a series colour: the series' own `colorHex` if set, else cycling
82
+ * through `cycle` (the chart's theme accent cycle) or, failing that,
83
+ * {@link SERIES_COLORS} by index.
84
+ *
85
+ * @param s The series.
86
+ * @param i The series index, used to pick from the cycle.
87
+ * @param cycle Optional per-chart colour cycle; falls back to {@link SERIES_COLORS}.
88
+ * @returns An RRGGBB hex string.
89
+ */
51
90
  export declare const seriesColor: (s: ChartSeries, i: number, cycle?: ReadonlyArray<string>) => string;
91
+ /** A value-axis scale: the rounded `min`/`max` extent and the tick `step`. */
52
92
  export interface Scale {
53
93
  readonly min: number;
54
94
  readonly max: number;
55
95
  readonly step: number;
56
96
  }
97
+ /**
98
+ * Compute a human-friendly axis {@link Scale} for the data range using
99
+ * Heckbert's "nice numbers" algorithm: rounded endpoints and a 1/2/5·10ⁿ step
100
+ * that yields about `maxTicks` ticks. A degenerate range (`dataMin === dataMax`)
101
+ * is widened by 1 so the axis is non-empty.
102
+ *
103
+ * @param dataMin The smallest data value to cover.
104
+ * @param dataMax The largest data value to cover.
105
+ * @param maxTicks Target upper bound on tick count (default 6).
106
+ * @returns The rounded min/max and tick step.
107
+ */
57
108
  export declare function niceScale(dataMin: number, dataMax: number, maxTicks?: number): Scale;
109
+ /**
110
+ * Format an axis tick value, choosing decimal places from the tick `step` so
111
+ * `0.25`-spaced ticks read `0.25` while integer steps drop the fraction.
112
+ *
113
+ * @param v The tick value.
114
+ * @param step The tick spacing (from {@link niceScale}).
115
+ * @returns The label text.
116
+ */
58
117
  export declare function formatTick(v: number, step: number): string;
118
+ /**
119
+ * Lay out a bar/column {@link Chart} into a {@link ChartScene}. Honours
120
+ * `chart.grouping` (clustered / stacked / percentStacked) and `chart.barDir`
121
+ * (column vs horizontal bar), over the shared cartesian frame.
122
+ *
123
+ * @param chart The bar/column chart.
124
+ * @param wPt Frame width in points.
125
+ * @param hPt Frame height in points.
126
+ * @param measure Text measurer used to size labels and reserve axis gutters.
127
+ * @returns The positioned scene primitives.
128
+ */
59
129
  export declare function buildBarScene(chart: Chart, wPt: number, hPt: number, measure: MeasureText): ChartScene;
130
+ /**
131
+ * Lay out an area {@link Chart} into a {@link ChartScene}: each series becomes a
132
+ * filled polygon down to the value baseline (stacked when `chart.grouping` is
133
+ * stacked / percentStacked), over the shared cartesian frame.
134
+ *
135
+ * @param chart The area chart.
136
+ * @param wPt Frame width in points.
137
+ * @param hPt Frame height in points.
138
+ * @param measure Text measurer used to size labels and reserve axis gutters.
139
+ * @returns The positioned scene primitives.
140
+ */
60
141
  export declare function buildAreaScene(chart: Chart, wPt: number, hPt: number, measure: MeasureText): ChartScene;
142
+ /**
143
+ * Lay out a scatter {@link Chart} into a {@link ChartScene}: numeric X/Y series
144
+ * plotted as marker points over a frame with two value axes (X from each
145
+ * series' `xValues`, Y from its `values`).
146
+ *
147
+ * @param chart The scatter chart.
148
+ * @param wPt Frame width in points.
149
+ * @param hPt Frame height in points.
150
+ * @param measure Text measurer used to size labels and reserve axis gutters.
151
+ * @returns The positioned scene primitives.
152
+ */
61
153
  export declare function buildScatterScene(chart: Chart, wPt: number, hPt: number, measure: MeasureText): ChartScene;
154
+ /**
155
+ * Lay out a line {@link Chart} into a {@link ChartScene}: each series becomes a
156
+ * stroked polyline across the category slots, over the shared cartesian frame.
157
+ * Unlike bars/areas the value axis auto-mins (it need not include 0).
158
+ *
159
+ * @param chart The line chart.
160
+ * @param wPt Frame width in points.
161
+ * @param hPt Frame height in points.
162
+ * @param measure Text measurer used to size labels and reserve axis gutters.
163
+ * @returns The positioned scene primitives.
164
+ */
62
165
  export declare function buildLineScene(chart: Chart, wPt: number, hPt: number, measure: MeasureText): ChartScene;
166
+ /**
167
+ * Lay out a pie/doughnut {@link Chart} into a {@link ChartScene}: the first
168
+ * series' values become proportional wedges (a centre hole for doughnut),
169
+ * with a legend instead of axes.
170
+ *
171
+ * @param chart The pie/doughnut chart.
172
+ * @param wPt Frame width in points.
173
+ * @param hPt Frame height in points.
174
+ * @param measure Text measurer used to size labels and the legend.
175
+ * @returns The positioned scene primitives.
176
+ */
63
177
  export declare function buildPieScene(chart: Chart, wPt: number, hPt: number, measure: MeasureText): ChartScene;
178
+ /**
179
+ * Lay out any supported {@link Chart} into a {@link ChartScene}, dispatching by
180
+ * `chart.type` to the per-type builders.
181
+ *
182
+ * @param chart The chart to lay out.
183
+ * @param wPt Frame width in points.
184
+ * @param hPt Frame height in points.
185
+ * @param measure Text measurer used to size labels and reserve gutters.
186
+ * @returns The positioned scene, or `null` for an unrenderable type (the
187
+ * renderer then reserves the box with a light border).
188
+ */
64
189
  export declare function buildChartScene(chart: Chart, wPt: number, hPt: number, measure: MeasureText): ChartScene | null;
@@ -2,6 +2,7 @@ var AXIS_COLOR = "595959";
2
2
  var GRID_COLOR = "D9D9D9";
3
3
  var LABEL_COLOR = "595959";
4
4
  var TITLE_COLOR = "404040";
5
+ /** The Office accent cycle (RRGGBB) for series without an explicit colour. */
5
6
  var SERIES_COLORS = [
6
7
  "4472C4",
7
8
  "ED7D31",
@@ -10,6 +11,16 @@ var SERIES_COLORS = [
10
11
  "5B9BD5",
11
12
  "70AD47"
12
13
  ];
14
+ /**
15
+ * Resolve a series colour: the series' own `colorHex` if set, else cycling
16
+ * through `cycle` (the chart's theme accent cycle) or, failing that,
17
+ * {@link SERIES_COLORS} by index.
18
+ *
19
+ * @param s The series.
20
+ * @param i The series index, used to pick from the cycle.
21
+ * @param cycle Optional per-chart colour cycle; falls back to {@link SERIES_COLORS}.
22
+ * @returns An RRGGBB hex string.
23
+ */
13
24
  var seriesColor = (s, i, cycle) => s.colorHex ?? (cycle && cycle.length > 0 ? cycle[i % cycle.length] : SERIES_COLORS[i % SERIES_COLORS.length]);
14
25
  function niceNum(range, round) {
15
26
  const exp = Math.floor(Math.log10(range));
@@ -19,6 +30,17 @@ function niceNum(range, round) {
19
30
  else nf = f <= 1 ? 1 : f <= 2 ? 2 : f <= 5 ? 5 : 10;
20
31
  return nf * 10 ** exp;
21
32
  }
33
+ /**
34
+ * Compute a human-friendly axis {@link Scale} for the data range using
35
+ * Heckbert's "nice numbers" algorithm: rounded endpoints and a 1/2/5·10ⁿ step
36
+ * that yields about `maxTicks` ticks. A degenerate range (`dataMin === dataMax`)
37
+ * is widened by 1 so the axis is non-empty.
38
+ *
39
+ * @param dataMin The smallest data value to cover.
40
+ * @param dataMax The largest data value to cover.
41
+ * @param maxTicks Target upper bound on tick count (default 6).
42
+ * @returns The rounded min/max and tick step.
43
+ */
22
44
  function niceScale(dataMin, dataMax, maxTicks = 6) {
23
45
  const lo = Math.min(dataMin, dataMax);
24
46
  let hi = Math.max(dataMin, dataMax);
@@ -30,6 +52,14 @@ function niceScale(dataMin, dataMax, maxTicks = 6) {
30
52
  step
31
53
  };
32
54
  }
55
+ /**
56
+ * Format an axis tick value, choosing decimal places from the tick `step` so
57
+ * `0.25`-spaced ticks read `0.25` while integer steps drop the fraction.
58
+ *
59
+ * @param v The tick value.
60
+ * @param step The tick spacing (from {@link niceScale}).
61
+ * @returns The label text.
62
+ */
33
63
  function formatTick(v, step) {
34
64
  if (Number.isInteger(step) && Number.isInteger(v)) return String(v);
35
65
  const decimals = Math.max(0, -Math.floor(Math.log10(step)));
@@ -220,6 +250,17 @@ function groupingFrameOpts(chart, nCats) {
220
250
  }
221
251
  return {};
222
252
  }
253
+ /**
254
+ * Lay out a bar/column {@link Chart} into a {@link ChartScene}. Honours
255
+ * `chart.grouping` (clustered / stacked / percentStacked) and `chart.barDir`
256
+ * (column vs horizontal bar), over the shared cartesian frame.
257
+ *
258
+ * @param chart The bar/column chart.
259
+ * @param wPt Frame width in points.
260
+ * @param hPt Frame height in points.
261
+ * @param measure Text measurer used to size labels and reserve axis gutters.
262
+ * @returns The positioned scene primitives.
263
+ */
223
264
  function buildBarScene(chart, wPt, hPt, measure) {
224
265
  const g = chart.grouping ?? "clustered";
225
266
  const stacked = g === "stacked" || g === "percentStacked";
@@ -350,6 +391,17 @@ function areaBand(top, base, f, xAt, fillHex) {
350
391
  widthPt: 1
351
392
  };
352
393
  }
394
+ /**
395
+ * Lay out an area {@link Chart} into a {@link ChartScene}: each series becomes a
396
+ * filled polygon down to the value baseline (stacked when `chart.grouping` is
397
+ * stacked / percentStacked), over the shared cartesian frame.
398
+ *
399
+ * @param chart The area chart.
400
+ * @param wPt Frame width in points.
401
+ * @param hPt Frame height in points.
402
+ * @param measure Text measurer used to size labels and reserve axis gutters.
403
+ * @returns The positioned scene primitives.
404
+ */
353
405
  function buildAreaScene(chart, wPt, hPt, measure) {
354
406
  const g = chart.grouping ?? "standard";
355
407
  const stacked = g === "stacked" || g === "percentStacked";
@@ -386,6 +438,17 @@ function buildAreaScene(chart, wPt, hPt, measure) {
386
438
  polygons
387
439
  };
388
440
  }
441
+ /**
442
+ * Lay out a scatter {@link Chart} into a {@link ChartScene}: numeric X/Y series
443
+ * plotted as marker points over a frame with two value axes (X from each
444
+ * series' `xValues`, Y from its `values`).
445
+ *
446
+ * @param chart The scatter chart.
447
+ * @param wPt Frame width in points.
448
+ * @param hPt Frame height in points.
449
+ * @param measure Text measurer used to size labels and reserve axis gutters.
450
+ * @returns The positioned scene primitives.
451
+ */
389
452
  function buildScatterScene(chart, wPt, hPt, measure) {
390
453
  const rects = [];
391
454
  const polylines = [];
@@ -442,6 +505,17 @@ function buildScatterScene(chart, wPt, hPt, measure) {
442
505
  labels
443
506
  };
444
507
  }
508
+ /**
509
+ * Lay out a line {@link Chart} into a {@link ChartScene}: each series becomes a
510
+ * stroked polyline across the category slots, over the shared cartesian frame.
511
+ * Unlike bars/areas the value axis auto-mins (it need not include 0).
512
+ *
513
+ * @param chart The line chart.
514
+ * @param wPt Frame width in points.
515
+ * @param hPt Frame height in points.
516
+ * @param measure Text measurer used to size labels and reserve axis gutters.
517
+ * @returns The positioned scene primitives.
518
+ */
445
519
  function buildLineScene(chart, wPt, hPt, measure) {
446
520
  const allVals = chart.series.flatMap((s) => s.values);
447
521
  const f = buildFrame(chart, wPt, hPt, measure, false, { dataRange: allVals.length > 0 ? [Math.min(...allVals), Math.max(...allVals)] : [0, 1] });
@@ -479,6 +553,17 @@ function buildLineScene(chart, wPt, hPt, measure) {
479
553
  };
480
554
  }
481
555
  var sliceColor = (series, i) => pointColor(series, i) ?? SERIES_COLORS[i % SERIES_COLORS.length];
556
+ /**
557
+ * Lay out a pie/doughnut {@link Chart} into a {@link ChartScene}: the first
558
+ * series' values become proportional wedges (a centre hole for doughnut),
559
+ * with a legend instead of axes.
560
+ *
561
+ * @param chart The pie/doughnut chart.
562
+ * @param wPt Frame width in points.
563
+ * @param hPt Frame height in points.
564
+ * @param measure Text measurer used to size labels and the legend.
565
+ * @returns The positioned scene primitives.
566
+ */
482
567
  function buildPieScene(chart, wPt, hPt, measure) {
483
568
  const rects = [];
484
569
  const wedges = [];
@@ -624,6 +709,17 @@ function layoutLegend(entries, hasLegend, pos, wPt, hPt, measure) {
624
709
  }
625
710
  };
626
711
  }
712
+ /**
713
+ * Lay out any supported {@link Chart} into a {@link ChartScene}, dispatching by
714
+ * `chart.type` to the per-type builders.
715
+ *
716
+ * @param chart The chart to lay out.
717
+ * @param wPt Frame width in points.
718
+ * @param hPt Frame height in points.
719
+ * @param measure Text measurer used to size labels and reserve gutters.
720
+ * @returns The positioned scene, or `null` for an unrenderable type (the
721
+ * renderer then reserves the box with a light border).
722
+ */
627
723
  function buildChartScene(chart, wPt, hPt, measure) {
628
724
  if (chart.type === "bar") return buildBarScene(chart, wPt, hPt, measure);
629
725
  if (chart.type === "line") return buildLineScene(chart, wPt, hPt, measure);
@@ -1,6 +1,40 @@
1
1
  import { Chart } from '../document-model/index.js';
2
2
  import { OpcPackage } from '../opc/index.js';
3
3
  import { ColorResolver } from './colors.js';
4
+ /**
5
+ * Parse a DrawingML chart part (chart1.xml) into a {@link Chart}, reading the
6
+ * CACHED data (`c:numCache` / `c:strCache`) rather than the embedded spreadsheet
7
+ * — the cache holds the last-computed categories and values, exactly what Word
8
+ * renders. Supports bar/column, line, pie/doughnut, area and scatter; other
9
+ * chart types parse with `type: 'unknown'` (the renderer reserves the box but
10
+ * draws nothing). Categories are shared and taken from the first series carrying
11
+ * them.
12
+ *
13
+ * @param chartXml The raw chart1.xml part bytes.
14
+ * @param resolveColor Maps a DrawingML colour reference to a 6-hex string.
15
+ * @returns The parsed chart, or `null` when there is no `c:chart` / `c:plotArea`.
16
+ */
4
17
  export declare function parseChart(chartXml: Uint8Array, resolveColor: ColorResolver): Chart | null;
18
+ /**
19
+ * MS-ODRAWXML chartColorStyle (charts/colorsN.xml): the top-level colour list is
20
+ * the series cycle (`meth="cycle"` — the common case; variations are luminance
21
+ * tweaks for `>N` series and are ignored in v1).
22
+ *
23
+ * @param colorsXml The raw colorsN.xml part bytes.
24
+ * @param resolveColor Maps a DrawingML colour reference to a 6-hex string.
25
+ * @returns The resolved series-colour cycle, in order (empty if none resolve).
26
+ */
5
27
  export declare function parseChartColorStyle(colorsXml: Uint8Array, resolveColor: ColorResolver): Array<string>;
28
+ /**
29
+ * Augment a parsed {@link Chart} with its custom series-colour cycle when the
30
+ * chart part's own relationships carry a chartColorStyle (colorsN.xml). Returns
31
+ * the chart unchanged when no such relationship resolves to a non-empty cycle.
32
+ * Shared by the docx and xlsx readers.
33
+ *
34
+ * @param chart The parsed chart to augment.
35
+ * @param pkg The OPC package, for relationship lookup.
36
+ * @param chartPartPath The chart part path, used as the relationship source.
37
+ * @param resolveColor Maps a DrawingML colour reference to a 6-hex string.
38
+ * @returns The chart, with `seriesColorCycle` set when a cycle is found.
39
+ */
6
40
  export declare function withChartColorStyle(chart: Chart, pkg: OpcPackage, chartPartPath: string, resolveColor: ColorResolver): Chart;
@@ -23,6 +23,19 @@ var TYPE_OF_TAG = {
23
23
  "c:area3DChart": "area",
24
24
  "c:scatterChart": "scatter"
25
25
  };
26
+ /**
27
+ * Parse a DrawingML chart part (chart1.xml) into a {@link Chart}, reading the
28
+ * CACHED data (`c:numCache` / `c:strCache`) rather than the embedded spreadsheet
29
+ * — the cache holds the last-computed categories and values, exactly what Word
30
+ * renders. Supports bar/column, line, pie/doughnut, area and scatter; other
31
+ * chart types parse with `type: 'unknown'` (the renderer reserves the box but
32
+ * draws nothing). Categories are shared and taken from the first series carrying
33
+ * them.
34
+ *
35
+ * @param chartXml The raw chart1.xml part bytes.
36
+ * @param resolveColor Maps a DrawingML colour reference to a 6-hex string.
37
+ * @returns The parsed chart, or `null` when there is no `c:chart` / `c:plotArea`.
38
+ */
26
39
  function parseChart(chartXml, resolveColor) {
27
40
  const chart = poFindByPath(parser.parse(decoder.decode(chartXml)), ["c:chartSpace", "c:chart"]);
28
41
  if (!chart) return null;
@@ -191,6 +204,15 @@ function isLegendPos(v) {
191
204
  function isGrouping(v) {
192
205
  return v === "clustered" || v === "stacked" || v === "percentStacked" || v === "standard";
193
206
  }
207
+ /**
208
+ * MS-ODRAWXML chartColorStyle (charts/colorsN.xml): the top-level colour list is
209
+ * the series cycle (`meth="cycle"` — the common case; variations are luminance
210
+ * tweaks for `>N` series and are ignored in v1).
211
+ *
212
+ * @param colorsXml The raw colorsN.xml part bytes.
213
+ * @param resolveColor Maps a DrawingML colour reference to a 6-hex string.
214
+ * @returns The resolved series-colour cycle, in order (empty if none resolve).
215
+ */
194
216
  function parseChartColorStyle(colorsXml, resolveColor) {
195
217
  const root = parser.parse(new TextDecoder().decode(colorsXml)).find((n) => {
196
218
  const tag = Object.keys(n).find((k) => k !== ":@" && k !== "#text");
@@ -204,6 +226,18 @@ function parseChartColorStyle(colorsXml, resolveColor) {
204
226
  }
205
227
  return out;
206
228
  }
229
+ /**
230
+ * Augment a parsed {@link Chart} with its custom series-colour cycle when the
231
+ * chart part's own relationships carry a chartColorStyle (colorsN.xml). Returns
232
+ * the chart unchanged when no such relationship resolves to a non-empty cycle.
233
+ * Shared by the docx and xlsx readers.
234
+ *
235
+ * @param chart The parsed chart to augment.
236
+ * @param pkg The OPC package, for relationship lookup.
237
+ * @param chartPartPath The chart part path, used as the relationship source.
238
+ * @param resolveColor Maps a DrawingML colour reference to a 6-hex string.
239
+ * @returns The chart, with `seriesColorCycle` set when a cycle is found.
240
+ */
207
241
  function withChartColorStyle(chart, pkg, chartPartPath, resolveColor) {
208
242
  for (const rel of pkg.getPartRelationships(chartPartPath)) {
209
243
  if (rel.type !== REL_CHART_COLOR_STYLE) continue;
@@ -1,2 +1,14 @@
1
1
  import { Chart } from '../document-model/index.js';
2
+ /**
3
+ * Serialize a {@link Chart} to a DrawingML chart part (chart1.xml) — the inverse
4
+ * of `parseChart`. Emits exactly the cached data the parser reads
5
+ * (`c:numCache` / `c:strCache`), so a parse → serialize → parse round-trip
6
+ * preserves type, series, categories, colours, title, legend and axis titles.
7
+ * Pie/doughnut charts omit axes; scatter emits two value axes (`c:valAx`);
8
+ * everything else gets a category + value axis pair. Shared by the xlsx writer
9
+ * (embedded charts, WT1) and the docx writer (drawing charts, WT3).
10
+ *
11
+ * @param chart The chart to serialize.
12
+ * @returns The chart1.xml document as a string (with the XML declaration).
13
+ */
2
14
  export declare function chartSpaceXml(chart: Chart): string;
@@ -12,6 +12,18 @@ var GROUP_TAG = {
12
12
  };
13
13
  var CAT_AX_ID = 111111111;
14
14
  var VAL_AX_ID = 222222222;
15
+ /**
16
+ * Serialize a {@link Chart} to a DrawingML chart part (chart1.xml) — the inverse
17
+ * of `parseChart`. Emits exactly the cached data the parser reads
18
+ * (`c:numCache` / `c:strCache`), so a parse → serialize → parse round-trip
19
+ * preserves type, series, categories, colours, title, legend and axis titles.
20
+ * Pie/doughnut charts omit axes; scatter emits two value axes (`c:valAx`);
21
+ * everything else gets a category + value axis pair. Shared by the xlsx writer
22
+ * (embedded charts, WT1) and the docx writer (drawing charts, WT3).
23
+ *
24
+ * @param chart The chart to serialize.
25
+ * @returns The chart1.xml document as a string (with the XML declaration).
26
+ */
15
27
  function chartSpaceXml(chart) {
16
28
  const isScatter = chart.type === "scatter";
17
29
  const isPie = chart.type === "pie" || chart.doughnut === true;
@@ -1,8 +1,19 @@
1
1
  import { PoNode } from '../po-helpers.js';
2
+ /**
3
+ * A colour transform child (§20.1.2.3): `lumMod`/`lumOff` modulate luminance,
4
+ * `shade` darkens toward black, `tint` lightens toward white. `val` is normalised
5
+ * to 0..1 (the XML stores thousandths of a percent). `alpha` is parsed but ignored
6
+ * (solid fills emit no transparency).
7
+ */
2
8
  export interface ColorMod {
3
9
  readonly kind: 'lumMod' | 'lumOff' | 'shade' | 'tint' | 'alpha';
4
10
  readonly val: number;
5
11
  }
12
+ /**
13
+ * A theme-agnostic colour reference emitted by the shape parser: either a direct
14
+ * sRGB value or a theme scheme-name reference, each with optional colour
15
+ * transforms. A {@link ColorResolver} maps it to a concrete 6-hex string.
16
+ */
6
17
  export type RawColor = {
7
18
  readonly srgb: string;
8
19
  readonly mods?: ReadonlyArray<ColorMod>;
@@ -10,11 +21,53 @@ export type RawColor = {
10
21
  readonly scheme: string;
11
22
  readonly mods?: ReadonlyArray<ColorMod>;
12
23
  };
24
+ /** Maps a {@link RawColor} to a 6-hex string, or `undefined` when unresolvable. */
13
25
  export type ColorResolver = (raw: RawColor) => string | undefined;
26
+ /**
27
+ * Apply DrawingML colour transforms ({@link ColorMod}s) to a 6-hex value,
28
+ * returning a 6-hex value. `shade`/`tint` scale in RGB; `lumMod`/`lumOff` adjust
29
+ * luminance in HSL. An empty `mods` returns `hex` unchanged.
30
+ *
31
+ * @param hex The base colour, RRGGBB.
32
+ * @param mods The transforms to apply, in order.
33
+ * @returns The transformed colour, uppercase RRGGBB.
34
+ */
14
35
  export declare function applyColorMods(hex: string, mods: ReadonlyArray<ColorMod>): string;
36
+ /**
37
+ * Office 2013 default theme palette — the colours Word assigns to the standard
38
+ * scheme slots when a document carries no custom theme part.
39
+ */
15
40
  export declare const DEFAULT_THEME_PALETTE: ReadonlyMap<string, string>;
41
+ /**
42
+ * Resolve a `schemeClr` text/background alias (`tx1`/`bg1`/`tx2`/`bg2`,
43
+ * §20.1.2.3.29) to its underlying `dk`/`lt` slot name; other names pass through.
44
+ */
16
45
  export declare function resolveSchemeName(name: string): string;
46
+ /**
47
+ * Build a {@link ColorResolver} over a scheme-name → hex `palette`. sRGB
48
+ * references pass through verbatim (upper-cased); scheme references are aliased
49
+ * (via {@link resolveSchemeName}) then looked up; colour transforms are applied.
50
+ *
51
+ * @param palette The scheme-name → RRGGBB map (e.g. {@link DEFAULT_THEME_PALETTE}).
52
+ * @returns A resolver that maps a {@link RawColor} to a hex string or `undefined`.
53
+ */
17
54
  export declare function makeColorResolver(palette: ReadonlyMap<string, string>): ColorResolver;
55
+ /** A {@link ColorResolver} backed by the {@link DEFAULT_THEME_PALETTE}. */
18
56
  export declare const defaultColorResolver: ColorResolver;
57
+ /**
58
+ * Read the colour transform children ({@link ColorMod}s) under an `a:srgbClr` /
59
+ * `a:schemeClr` node, normalising each `val` from thousandths-of-a-percent to 0..1.
60
+ */
19
61
  export declare function readColorMods(colorNode: PoNode): Array<ColorMod>;
62
+ /**
63
+ * Resolve an `a:srgbClr` / `a:schemeClr` node to a hex string (with colour
64
+ * transforms applied). Returns `undefined` when the node is some other element,
65
+ * valueless, or the resolver does not know the colour. Container traversal policy
66
+ * (stop at the first colour node vs continue past unresolved ones) stays with the
67
+ * callers.
68
+ *
69
+ * @param c The candidate colour node.
70
+ * @param resolveColor The resolver mapping a {@link RawColor} to hex.
71
+ * @returns The resolved RRGGBB, or `undefined`.
72
+ */
20
73
  export declare function resolveColorNode(c: PoNode, resolveColor: ColorResolver): string | undefined;
@@ -69,6 +69,15 @@ function hslToRgb(h, s, l) {
69
69
  b + m
70
70
  ];
71
71
  }
72
+ /**
73
+ * Apply DrawingML colour transforms ({@link ColorMod}s) to a 6-hex value,
74
+ * returning a 6-hex value. `shade`/`tint` scale in RGB; `lumMod`/`lumOff` adjust
75
+ * luminance in HSL. An empty `mods` returns `hex` unchanged.
76
+ *
77
+ * @param hex The base colour, RRGGBB.
78
+ * @param mods The transforms to apply, in order.
79
+ * @returns The transformed colour, uppercase RRGGBB.
80
+ */
72
81
  function applyColorMods(hex, mods) {
73
82
  if (mods.length === 0) return hex;
74
83
  const n = parseInt(hex, 16);
@@ -91,6 +100,10 @@ function applyColorMods(hex, mods) {
91
100
  const toHex = (x) => Math.round(clamp01(x) * 255).toString(16).padStart(2, "0");
92
101
  return (toHex(r) + toHex(g) + toHex(b)).toUpperCase();
93
102
  }
103
+ /**
104
+ * Office 2013 default theme palette — the colours Word assigns to the standard
105
+ * scheme slots when a document carries no custom theme part.
106
+ */
94
107
  var DEFAULT_THEME_PALETTE = new Map([
95
108
  ["dk1", "000000"],
96
109
  ["lt1", "FFFFFF"],
@@ -111,9 +124,21 @@ var SCHEME_ALIAS = {
111
124
  tx2: "dk2",
112
125
  bg2: "lt2"
113
126
  };
127
+ /**
128
+ * Resolve a `schemeClr` text/background alias (`tx1`/`bg1`/`tx2`/`bg2`,
129
+ * §20.1.2.3.29) to its underlying `dk`/`lt` slot name; other names pass through.
130
+ */
114
131
  function resolveSchemeName(name) {
115
132
  return SCHEME_ALIAS[name] ?? name;
116
133
  }
134
+ /**
135
+ * Build a {@link ColorResolver} over a scheme-name → hex `palette`. sRGB
136
+ * references pass through verbatim (upper-cased); scheme references are aliased
137
+ * (via {@link resolveSchemeName}) then looked up; colour transforms are applied.
138
+ *
139
+ * @param palette The scheme-name → RRGGBB map (e.g. {@link DEFAULT_THEME_PALETTE}).
140
+ * @returns A resolver that maps a {@link RawColor} to a hex string or `undefined`.
141
+ */
117
142
  function makeColorResolver(palette) {
118
143
  return (raw) => {
119
144
  const base = "srgb" in raw ? raw.srgb.toUpperCase() : palette.get(resolveSchemeName(raw.scheme));
@@ -121,7 +146,12 @@ function makeColorResolver(palette) {
121
146
  return raw.mods && raw.mods.length > 0 ? applyColorMods(base, raw.mods) : base;
122
147
  };
123
148
  }
149
+ /** A {@link ColorResolver} backed by the {@link DEFAULT_THEME_PALETTE}. */
124
150
  var defaultColorResolver = makeColorResolver(DEFAULT_THEME_PALETTE);
151
+ /**
152
+ * Read the colour transform children ({@link ColorMod}s) under an `a:srgbClr` /
153
+ * `a:schemeClr` node, normalising each `val` from thousandths-of-a-percent to 0..1.
154
+ */
125
155
  function readColorMods(colorNode) {
126
156
  const mods = [];
127
157
  for (const c of poChildren(colorNode)) for (const kind of [
@@ -139,6 +169,17 @@ function readColorMods(colorNode) {
139
169
  }
140
170
  return mods;
141
171
  }
172
+ /**
173
+ * Resolve an `a:srgbClr` / `a:schemeClr` node to a hex string (with colour
174
+ * transforms applied). Returns `undefined` when the node is some other element,
175
+ * valueless, or the resolver does not know the colour. Container traversal policy
176
+ * (stop at the first colour node vs continue past unresolved ones) stays with the
177
+ * callers.
178
+ *
179
+ * @param c The candidate colour node.
180
+ * @param resolveColor The resolver mapping a {@link RawColor} to hex.
181
+ * @returns The resolved RRGGBB, or `undefined`.
182
+ */
142
183
  function resolveColorNode(c, resolveColor) {
143
184
  const isSrgb = poIs(c, "a:srgbClr");
144
185
  if (!isSrgb && !poIs(c, "a:schemeClr")) return void 0;
@@ -1,6 +1,36 @@
1
1
  import { CustomGeometry } from '../document-model/index.js';
2
2
  import { PathSegment, VectorPath } from '../vector.js';
3
+ /**
4
+ * The four closed segments of the `w`×`h` bounding rectangle, in the local y-up
5
+ * frame (origin bottom-left). The fallback geometry for unknown presets.
6
+ */
3
7
  export declare function rectSegments(w: number, h: number): ReadonlyArray<PathSegment>;
8
+ /** The `w`×`h` bounding rectangle as a {@link VectorPath}. */
4
9
  export declare function rectPath(w: number, h: number): VectorPath;
10
+ /**
11
+ * Map a preset shape name (§20.1.10.55) to its vector path(s) in the local y-up
12
+ * frame, sized `w`×`h` points and shaped by the `adjust` guides. Returns `null`
13
+ * for an unknown preset so the caller falls back to the bounding rectangle —
14
+ * graceful degradation that keeps even unimplemented presets visible (with the
15
+ * right fill/line) and never throws.
16
+ *
17
+ * @param preset The preset geometry name (e.g. `'roundRect'`, `'rightArrow'`).
18
+ * @param w Box width in points.
19
+ * @param h Box height in points.
20
+ * @param adjust Raw `a:gd` adjust guides by name (thousandths of a percent).
21
+ * @returns The path(s), or `null` for an unrecognised preset.
22
+ */
5
23
  export declare function presetPaths(preset: string, w: number, h: number, adjust: ReadonlyMap<string, number>): Array<VectorPath> | null;
24
+ /**
25
+ * Convert a custom geometry (§20.1.9) to a vector path. Path-space coordinates
26
+ * (y-down, origin top-left) are scaled to the shape box and flipped to the local
27
+ * y-up frame; quadratics are elevated to cubics; `arcTo` is decomposed via the
28
+ * shared arc helper. Angles are 1/60000° clockwise in y-down, which becomes
29
+ * negative (CCW) once y is flipped.
30
+ *
31
+ * @param geom The parsed custom geometry (path size + draw commands).
32
+ * @param wPt Box width in points.
33
+ * @param hPt Box height in points.
34
+ * @returns A single-element array holding the built path.
35
+ */
6
36
  export declare function customPaths(geom: CustomGeometry, wPt: number, hPt: number): Array<VectorPath>;