postext 1.68.0 → 1.70.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (599) hide show
  1. package/README.md +2 -1
  2. package/dist/__tests__/exports.test.js +3 -0
  3. package/dist/__tests__/exports.test.js.map +1 -1
  4. package/dist/composed/sourceMap/text.d.ts.map +1 -1
  5. package/dist/composed/sourceMap/text.js +1 -15
  6. package/dist/composed/sourceMap/text.js.map +1 -1
  7. package/dist/index.d.ts +4 -4
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +2 -0
  10. package/dist/index.js.map +1 -1
  11. package/dist/paint/displayList/blocks.d.ts +29 -0
  12. package/dist/paint/displayList/blocks.d.ts.map +1 -0
  13. package/dist/paint/displayList/blocks.js +257 -0
  14. package/dist/paint/displayList/blocks.js.map +1 -0
  15. package/dist/paint/displayList/comic.d.ts +8 -0
  16. package/dist/paint/displayList/comic.d.ts.map +1 -0
  17. package/dist/paint/displayList/comic.js +142 -0
  18. package/dist/paint/displayList/comic.js.map +1 -0
  19. package/dist/paint/displayList/design.d.ts +27 -0
  20. package/dist/paint/displayList/design.d.ts.map +1 -0
  21. package/dist/paint/displayList/design.js +190 -0
  22. package/dist/paint/displayList/design.js.map +1 -0
  23. package/dist/paint/displayList/displayList.test.d.ts +2 -0
  24. package/dist/paint/displayList/displayList.test.d.ts.map +1 -0
  25. package/dist/paint/displayList/displayList.test.js +256 -0
  26. package/dist/paint/displayList/displayList.test.js.map +1 -0
  27. package/dist/paint/displayList/eastAsian.test.d.ts +2 -0
  28. package/dist/paint/displayList/eastAsian.test.d.ts.map +1 -0
  29. package/dist/paint/displayList/eastAsian.test.js +112 -0
  30. package/dist/paint/displayList/eastAsian.test.js.map +1 -0
  31. package/dist/paint/displayList/frame.d.ts +49 -0
  32. package/dist/paint/displayList/frame.d.ts.map +1 -0
  33. package/dist/paint/displayList/frame.js +230 -0
  34. package/dist/paint/displayList/frame.js.map +1 -0
  35. package/dist/paint/displayList/frames.test.d.ts +2 -0
  36. package/dist/paint/displayList/frames.test.d.ts.map +1 -0
  37. package/dist/paint/displayList/frames.test.js +129 -0
  38. package/dist/paint/displayList/frames.test.js.map +1 -0
  39. package/dist/paint/displayList/index.d.ts +4 -0
  40. package/dist/paint/displayList/index.d.ts.map +1 -0
  41. package/dist/paint/displayList/index.js +5 -0
  42. package/dist/paint/displayList/index.js.map +1 -0
  43. package/dist/paint/displayList/inline.d.ts +19 -0
  44. package/dist/paint/displayList/inline.d.ts.map +1 -0
  45. package/dist/paint/displayList/inline.js +84 -0
  46. package/dist/paint/displayList/inline.js.map +1 -0
  47. package/dist/paint/displayList/lines.d.ts +60 -0
  48. package/dist/paint/displayList/lines.d.ts.map +1 -0
  49. package/dist/paint/displayList/lines.js +267 -0
  50. package/dist/paint/displayList/lines.js.map +1 -0
  51. package/dist/paint/displayList/overlays.d.ts +23 -0
  52. package/dist/paint/displayList/overlays.d.ts.map +1 -0
  53. package/dist/paint/displayList/overlays.js +99 -0
  54. package/dist/paint/displayList/overlays.js.map +1 -0
  55. package/dist/paint/displayList/overlays.test.d.ts +2 -0
  56. package/dist/paint/displayList/overlays.test.d.ts.map +1 -0
  57. package/dist/paint/displayList/overlays.test.js +241 -0
  58. package/dist/paint/displayList/overlays.test.js.map +1 -0
  59. package/dist/paint/displayList/page.d.ts +8 -0
  60. package/dist/paint/displayList/page.d.ts.map +1 -0
  61. package/dist/paint/displayList/page.js +157 -0
  62. package/dist/paint/displayList/page.js.map +1 -0
  63. package/dist/paint/displayList/resource.d.ts +6 -0
  64. package/dist/paint/displayList/resource.d.ts.map +1 -0
  65. package/dist/paint/displayList/resource.js +195 -0
  66. package/dist/paint/displayList/resource.js.map +1 -0
  67. package/dist/paint/displayList/review.test.d.ts +2 -0
  68. package/dist/paint/displayList/review.test.d.ts.map +1 -0
  69. package/dist/paint/displayList/review.test.js +185 -0
  70. package/dist/paint/displayList/review.test.js.map +1 -0
  71. package/dist/paint/displayList/source.d.ts +57 -0
  72. package/dist/paint/displayList/source.d.ts.map +1 -0
  73. package/dist/paint/displayList/source.js +263 -0
  74. package/dist/paint/displayList/source.js.map +1 -0
  75. package/dist/paint/displayList/source.test.d.ts +2 -0
  76. package/dist/paint/displayList/source.test.d.ts.map +1 -0
  77. package/dist/paint/displayList/source.test.js +37 -0
  78. package/dist/paint/displayList/source.test.js.map +1 -0
  79. package/dist/paint/displayList/types.d.ts +309 -0
  80. package/dist/paint/displayList/types.d.ts.map +1 -0
  81. package/dist/paint/displayList/types.js +7 -0
  82. package/dist/paint/displayList/types.js.map +1 -0
  83. package/dist/paint/segmentPlainLength.d.ts +9 -0
  84. package/dist/paint/segmentPlainLength.d.ts.map +1 -0
  85. package/dist/paint/segmentPlainLength.js +19 -0
  86. package/dist/paint/segmentPlainLength.js.map +1 -0
  87. package/dist/parse/sourceMapping.d.ts.map +1 -1
  88. package/dist/parse/sourceMapping.js +10 -4
  89. package/dist/parse/sourceMapping.js.map +1 -1
  90. package/dist/word/anchors/anchors.test.d.ts +2 -0
  91. package/dist/word/anchors/anchors.test.d.ts.map +1 -0
  92. package/dist/word/anchors/anchors.test.js +88 -0
  93. package/dist/word/anchors/anchors.test.js.map +1 -0
  94. package/dist/word/anchors/base64.d.ts +3 -0
  95. package/dist/word/anchors/base64.d.ts.map +1 -0
  96. package/dist/word/anchors/base64.js +47 -0
  97. package/dist/word/anchors/base64.js.map +1 -0
  98. package/dist/word/anchors/bookmarks.d.ts +11 -0
  99. package/dist/word/anchors/bookmarks.d.ts.map +1 -0
  100. package/dist/word/anchors/bookmarks.js +34 -0
  101. package/dist/word/anchors/bookmarks.js.map +1 -0
  102. package/dist/word/anchors/exportMap.d.ts +25 -0
  103. package/dist/word/anchors/exportMap.d.ts.map +1 -0
  104. package/dist/word/anchors/exportMap.js +131 -0
  105. package/dist/word/anchors/exportMap.js.map +1 -0
  106. package/dist/word/anchors/hash.d.ts +7 -0
  107. package/dist/word/anchors/hash.d.ts.map +1 -0
  108. package/dist/word/anchors/hash.js +39 -0
  109. package/dist/word/anchors/hash.js.map +1 -0
  110. package/dist/word/anchors/index.d.ts +7 -0
  111. package/dist/word/anchors/index.d.ts.map +1 -0
  112. package/dist/word/anchors/index.js +9 -0
  113. package/dist/word/anchors/index.js.map +1 -0
  114. package/dist/word/anchors/ommlHash.d.ts +8 -0
  115. package/dist/word/anchors/ommlHash.d.ts.map +1 -0
  116. package/dist/word/anchors/ommlHash.js +71 -0
  117. package/dist/word/anchors/ommlHash.js.map +1 -0
  118. package/dist/word/anchors/types.d.ts +87 -0
  119. package/dist/word/anchors/types.d.ts.map +1 -0
  120. package/dist/word/anchors/types.js +8 -0
  121. package/dist/word/anchors/types.js.map +1 -0
  122. package/dist/word/fonts/cmap.d.ts +13 -0
  123. package/dist/word/fonts/cmap.d.ts.map +1 -0
  124. package/dist/word/fonts/cmap.js +235 -0
  125. package/dist/word/fonts/cmap.js.map +1 -0
  126. package/dist/word/fonts/fonts.test.d.ts +2 -0
  127. package/dist/word/fonts/fonts.test.d.ts.map +1 -0
  128. package/dist/word/fonts/fonts.test.js +459 -0
  129. package/dist/word/fonts/fonts.test.js.map +1 -0
  130. package/dist/word/fonts/glyf.d.ts +21 -0
  131. package/dist/word/fonts/glyf.d.ts.map +1 -0
  132. package/dist/word/fonts/glyf.js +139 -0
  133. package/dist/word/fonts/glyf.js.map +1 -0
  134. package/dist/word/fonts/gsub.d.ts +8 -0
  135. package/dist/word/fonts/gsub.d.ts.map +1 -0
  136. package/dist/word/fonts/gsub.js +145 -0
  137. package/dist/word/fonts/gsub.js.map +1 -0
  138. package/dist/word/fonts/gsub.test.d.ts +2 -0
  139. package/dist/word/fonts/gsub.test.d.ts.map +1 -0
  140. package/dist/word/fonts/gsub.test.js +98 -0
  141. package/dist/word/fonts/gsub.test.js.map +1 -0
  142. package/dist/word/fonts/index.d.ts +6 -0
  143. package/dist/word/fonts/index.d.ts.map +1 -0
  144. package/dist/word/fonts/index.js +5 -0
  145. package/dist/word/fonts/index.js.map +1 -0
  146. package/dist/word/fonts/merge.d.ts +7 -0
  147. package/dist/word/fonts/merge.d.ts.map +1 -0
  148. package/dist/word/fonts/merge.js +222 -0
  149. package/dist/word/fonts/merge.js.map +1 -0
  150. package/dist/word/fonts/meta.d.ts +33 -0
  151. package/dist/word/fonts/meta.d.ts.map +1 -0
  152. package/dist/word/fonts/meta.js +206 -0
  153. package/dist/word/fonts/meta.js.map +1 -0
  154. package/dist/word/fonts/plan.d.ts +31 -0
  155. package/dist/word/fonts/plan.d.ts.map +1 -0
  156. package/dist/word/fonts/plan.js +275 -0
  157. package/dist/word/fonts/plan.js.map +1 -0
  158. package/dist/word/fonts/sfnt.d.ts +47 -0
  159. package/dist/word/fonts/sfnt.d.ts.map +1 -0
  160. package/dist/word/fonts/sfnt.js +202 -0
  161. package/dist/word/fonts/sfnt.js.map +1 -0
  162. package/dist/word/fonts/types.d.ts +54 -0
  163. package/dist/word/fonts/types.d.ts.map +1 -0
  164. package/dist/word/fonts/types.js +5 -0
  165. package/dist/word/fonts/types.js.map +1 -0
  166. package/dist/word/formatted/displayRoundTrip.test.d.ts +2 -0
  167. package/dist/word/formatted/displayRoundTrip.test.d.ts.map +1 -0
  168. package/dist/word/formatted/displayRoundTrip.test.js +99 -0
  169. package/dist/word/formatted/displayRoundTrip.test.js.map +1 -0
  170. package/dist/word/formatted/drawing.d.ts +61 -0
  171. package/dist/word/formatted/drawing.d.ts.map +1 -0
  172. package/dist/word/formatted/drawing.js +85 -0
  173. package/dist/word/formatted/drawing.js.map +1 -0
  174. package/dist/word/formatted/dump.test.d.ts +2 -0
  175. package/dist/word/formatted/dump.test.d.ts.map +1 -0
  176. package/dist/word/formatted/dump.test.js +31 -0
  177. package/dist/word/formatted/dump.test.js.map +1 -0
  178. package/dist/word/formatted/eastAsian.d.ts +68 -0
  179. package/dist/word/formatted/eastAsian.d.ts.map +1 -0
  180. package/dist/word/formatted/eastAsian.js +144 -0
  181. package/dist/word/formatted/eastAsian.js.map +1 -0
  182. package/dist/word/formatted/formatted.test-helper.d.ts +34 -0
  183. package/dist/word/formatted/formatted.test-helper.d.ts.map +1 -0
  184. package/dist/word/formatted/formatted.test-helper.js +138 -0
  185. package/dist/word/formatted/formatted.test-helper.js.map +1 -0
  186. package/dist/word/formatted/formatted.test.d.ts +2 -0
  187. package/dist/word/formatted/formatted.test.d.ts.map +1 -0
  188. package/dist/word/formatted/formatted.test.js +285 -0
  189. package/dist/word/formatted/formatted.test.js.map +1 -0
  190. package/dist/word/formatted/fragments.d.ts +30 -0
  191. package/dist/word/formatted/fragments.d.ts.map +1 -0
  192. package/dist/word/formatted/fragments.js +98 -0
  193. package/dist/word/formatted/fragments.js.map +1 -0
  194. package/dist/word/formatted/graphics.test.d.ts +2 -0
  195. package/dist/word/formatted/graphics.test.d.ts.map +1 -0
  196. package/dist/word/formatted/graphics.test.js +204 -0
  197. package/dist/word/formatted/graphics.test.js.map +1 -0
  198. package/dist/word/formatted/index.d.ts +8 -0
  199. package/dist/word/formatted/index.d.ts.map +1 -0
  200. package/dist/word/formatted/index.js +103 -0
  201. package/dist/word/formatted/index.js.map +1 -0
  202. package/dist/word/formatted/inline.test.d.ts +2 -0
  203. package/dist/word/formatted/inline.test.d.ts.map +1 -0
  204. package/dist/word/formatted/inline.test.js +154 -0
  205. package/dist/word/formatted/inline.test.js.map +1 -0
  206. package/dist/word/formatted/inlineShapes.d.ts +13 -0
  207. package/dist/word/formatted/inlineShapes.d.ts.map +1 -0
  208. package/dist/word/formatted/inlineShapes.js +79 -0
  209. package/dist/word/formatted/inlineShapes.js.map +1 -0
  210. package/dist/word/formatted/metrics.d.ts +54 -0
  211. package/dist/word/formatted/metrics.d.ts.map +1 -0
  212. package/dist/word/formatted/metrics.js +165 -0
  213. package/dist/word/formatted/metrics.js.map +1 -0
  214. package/dist/word/formatted/page.d.ts +16 -0
  215. package/dist/word/formatted/page.d.ts.map +1 -0
  216. package/dist/word/formatted/page.js +82 -0
  217. package/dist/word/formatted/page.js.map +1 -0
  218. package/dist/word/formatted/paragraphs.d.ts +98 -0
  219. package/dist/word/formatted/paragraphs.d.ts.map +1 -0
  220. package/dist/word/formatted/paragraphs.js +364 -0
  221. package/dist/word/formatted/paragraphs.js.map +1 -0
  222. package/dist/word/formatted/pictures.d.ts +27 -0
  223. package/dist/word/formatted/pictures.d.ts.map +1 -0
  224. package/dist/word/formatted/pictures.js +239 -0
  225. package/dist/word/formatted/pictures.js.map +1 -0
  226. package/dist/word/formatted/review.test.d.ts +2 -0
  227. package/dist/word/formatted/review.test.d.ts.map +1 -0
  228. package/dist/word/formatted/review.test.js +141 -0
  229. package/dist/word/formatted/review.test.js.map +1 -0
  230. package/dist/word/formatted/runs.d.ts +135 -0
  231. package/dist/word/formatted/runs.d.ts.map +1 -0
  232. package/dist/word/formatted/runs.js +433 -0
  233. package/dist/word/formatted/runs.js.map +1 -0
  234. package/dist/word/formatted/scripts.test.d.ts +2 -0
  235. package/dist/word/formatted/scripts.test.d.ts.map +1 -0
  236. package/dist/word/formatted/scripts.test.js +201 -0
  237. package/dist/word/formatted/scripts.test.js.map +1 -0
  238. package/dist/word/formatted/shapes.d.ts +29 -0
  239. package/dist/word/formatted/shapes.d.ts.map +1 -0
  240. package/dist/word/formatted/shapes.js +101 -0
  241. package/dist/word/formatted/shapes.js.map +1 -0
  242. package/dist/word/formatted/styles.d.ts +17 -0
  243. package/dist/word/formatted/styles.d.ts.map +1 -0
  244. package/dist/word/formatted/styles.js +91 -0
  245. package/dist/word/formatted/styles.js.map +1 -0
  246. package/dist/word/formatted/tables.d.ts +13 -0
  247. package/dist/word/formatted/tables.d.ts.map +1 -0
  248. package/dist/word/formatted/tables.js +159 -0
  249. package/dist/word/formatted/tables.js.map +1 -0
  250. package/dist/word/formatted/text.d.ts +32 -0
  251. package/dist/word/formatted/text.d.ts.map +1 -0
  252. package/dist/word/formatted/text.js +115 -0
  253. package/dist/word/formatted/text.js.map +1 -0
  254. package/dist/word/formatted/types.d.ts +68 -0
  255. package/dist/word/formatted/types.d.ts.map +1 -0
  256. package/dist/word/formatted/types.js +4 -0
  257. package/dist/word/formatted/types.js.map +1 -0
  258. package/dist/word/formatted/units.d.ts +23 -0
  259. package/dist/word/formatted/units.d.ts.map +1 -0
  260. package/dist/word/formatted/units.js +51 -0
  261. package/dist/word/formatted/units.js.map +1 -0
  262. package/dist/word/formatted/widths.test.d.ts +2 -0
  263. package/dist/word/formatted/widths.test.d.ts.map +1 -0
  264. package/dist/word/formatted/widths.test.js +327 -0
  265. package/dist/word/formatted/widths.test.js.map +1 -0
  266. package/dist/word/index.d.ts +13 -2
  267. package/dist/word/index.d.ts.map +1 -1
  268. package/dist/word/index.js +14 -5
  269. package/dist/word/index.js.map +1 -1
  270. package/dist/word/integration/corpus.known.test.d.ts +2 -0
  271. package/dist/word/integration/corpus.known.test.d.ts.map +1 -0
  272. package/dist/word/integration/corpus.known.test.js +42 -0
  273. package/dist/word/integration/corpus.known.test.js.map +1 -0
  274. package/dist/word/integration/corpus.test.d.ts +2 -0
  275. package/dist/word/integration/corpus.test.d.ts.map +1 -0
  276. package/dist/word/integration/corpus.test.js +352 -0
  277. package/dist/word/integration/corpus.test.js.map +1 -0
  278. package/dist/word/integration/formatted.test.d.ts +2 -0
  279. package/dist/word/integration/formatted.test.d.ts.map +1 -0
  280. package/dist/word/integration/formatted.test.js +125 -0
  281. package/dist/word/integration/formatted.test.js.map +1 -0
  282. package/dist/word/integration/integration.test-helper.d.ts +16 -0
  283. package/dist/word/integration/integration.test-helper.d.ts.map +1 -0
  284. package/dist/word/integration/integration.test-helper.js +48 -0
  285. package/dist/word/integration/integration.test-helper.js.map +1 -0
  286. package/dist/word/integration/sample.test-helper.d.ts +5 -0
  287. package/dist/word/integration/sample.test-helper.d.ts.map +1 -0
  288. package/dist/word/integration/sample.test-helper.js +48 -0
  289. package/dist/word/integration/sample.test-helper.js.map +1 -0
  290. package/dist/word/integration/semantic.test.d.ts +2 -0
  291. package/dist/word/integration/semantic.test.d.ts.map +1 -0
  292. package/dist/word/integration/semantic.test.js +111 -0
  293. package/dist/word/integration/semantic.test.js.map +1 -0
  294. package/dist/word/integration/wordEdit.test-helper.d.ts +14 -0
  295. package/dist/word/integration/wordEdit.test-helper.d.ts.map +1 -0
  296. package/dist/word/integration/wordEdit.test-helper.js +150 -0
  297. package/dist/word/integration/wordEdit.test-helper.js.map +1 -0
  298. package/dist/word/omml.d.ts.map +1 -1
  299. package/dist/word/omml.js +17 -5
  300. package/dist/word/omml.js.map +1 -1
  301. package/dist/word/omml.test.d.ts +2 -0
  302. package/dist/word/omml.test.d.ts.map +1 -0
  303. package/dist/word/omml.test.js +46 -0
  304. package/dist/word/omml.test.js.map +1 -0
  305. package/dist/word/ommlWrite/convert.d.ts +20 -0
  306. package/dist/word/ommlWrite/convert.d.ts.map +1 -0
  307. package/dist/word/ommlWrite/convert.js +311 -0
  308. package/dist/word/ommlWrite/convert.js.map +1 -0
  309. package/dist/word/ommlWrite/index.d.ts +25 -0
  310. package/dist/word/ommlWrite/index.d.ts.map +1 -0
  311. package/dist/word/ommlWrite/index.js +80 -0
  312. package/dist/word/ommlWrite/index.js.map +1 -0
  313. package/dist/word/ommlWrite/mml.d.ts +49 -0
  314. package/dist/word/ommlWrite/mml.d.ts.map +1 -0
  315. package/dist/word/ommlWrite/mml.js +73 -0
  316. package/dist/word/ommlWrite/mml.js.map +1 -0
  317. package/dist/word/ommlWrite/ommlWrite.test.d.ts +2 -0
  318. package/dist/word/ommlWrite/ommlWrite.test.d.ts.map +1 -0
  319. package/dist/word/ommlWrite/ommlWrite.test.js +230 -0
  320. package/dist/word/ommlWrite/ommlWrite.test.js.map +1 -0
  321. package/dist/word/ommlWrite/rows.d.ts +6 -0
  322. package/dist/word/ommlWrite/rows.d.ts.map +1 -0
  323. package/dist/word/ommlWrite/rows.js +216 -0
  324. package/dist/word/ommlWrite/rows.js.map +1 -0
  325. package/dist/word/ommlWrite/runs.d.ts +30 -0
  326. package/dist/word/ommlWrite/runs.d.ts.map +1 -0
  327. package/dist/word/ommlWrite/runs.js +122 -0
  328. package/dist/word/ommlWrite/runs.js.map +1 -0
  329. package/dist/word/ommlWrite/tables.d.ts +4 -0
  330. package/dist/word/ommlWrite/tables.d.ts.map +1 -0
  331. package/dist/word/ommlWrite/tables.js +50 -0
  332. package/dist/word/ommlWrite/tables.js.map +1 -0
  333. package/dist/word/ooxml/constants.d.ts +54 -0
  334. package/dist/word/ooxml/constants.d.ts.map +1 -0
  335. package/dist/word/ooxml/constants.js +85 -0
  336. package/dist/word/ooxml/constants.js.map +1 -0
  337. package/dist/word/ooxml/fonts.d.ts +16 -0
  338. package/dist/word/ooxml/fonts.d.ts.map +1 -0
  339. package/dist/word/ooxml/fonts.js +71 -0
  340. package/dist/word/ooxml/fonts.js.map +1 -0
  341. package/dist/word/ooxml/index.d.ts +7 -0
  342. package/dist/word/ooxml/index.d.ts.map +1 -0
  343. package/dist/word/ooxml/index.js +7 -0
  344. package/dist/word/ooxml/index.js.map +1 -0
  345. package/dist/word/ooxml/package.d.ts +21 -0
  346. package/dist/word/ooxml/package.d.ts.map +1 -0
  347. package/dist/word/ooxml/package.js +202 -0
  348. package/dist/word/ooxml/package.js.map +1 -0
  349. package/dist/word/ooxml/package.test.d.ts +2 -0
  350. package/dist/word/ooxml/package.test.d.ts.map +1 -0
  351. package/dist/word/ooxml/package.test.js +176 -0
  352. package/dist/word/ooxml/package.test.js.map +1 -0
  353. package/dist/word/ooxml/parts.d.ts +28 -0
  354. package/dist/word/ooxml/parts.d.ts.map +1 -0
  355. package/dist/word/ooxml/parts.js +172 -0
  356. package/dist/word/ooxml/parts.js.map +1 -0
  357. package/dist/word/ooxml/review.test.d.ts +2 -0
  358. package/dist/word/ooxml/review.test.d.ts.map +1 -0
  359. package/dist/word/ooxml/review.test.js +104 -0
  360. package/dist/word/ooxml/review.test.js.map +1 -0
  361. package/dist/word/ooxml/types.d.ts +85 -0
  362. package/dist/word/ooxml/types.d.ts.map +1 -0
  363. package/dist/word/ooxml/types.js +6 -0
  364. package/dist/word/ooxml/types.js.map +1 -0
  365. package/dist/word/ooxml/validate.d.ts +3 -0
  366. package/dist/word/ooxml/validate.d.ts.map +1 -0
  367. package/dist/word/ooxml/validate.js +122 -0
  368. package/dist/word/ooxml/validate.js.map +1 -0
  369. package/dist/word/ooxml/wellFormed.d.ts +3 -0
  370. package/dist/word/ooxml/wellFormed.d.ts.map +1 -0
  371. package/dist/word/ooxml/wellFormed.js +79 -0
  372. package/dist/word/ooxml/wellFormed.js.map +1 -0
  373. package/dist/word/roundtrip/added.d.ts +31 -0
  374. package/dist/word/roundtrip/added.d.ts.map +1 -0
  375. package/dist/word/roundtrip/added.js +199 -0
  376. package/dist/word/roundtrip/added.js.map +1 -0
  377. package/dist/word/roundtrip/added.test.d.ts +2 -0
  378. package/dist/word/roundtrip/added.test.d.ts.map +1 -0
  379. package/dist/word/roundtrip/added.test.js +59 -0
  380. package/dist/word/roundtrip/added.test.js.map +1 -0
  381. package/dist/word/roundtrip/apply.d.ts +11 -0
  382. package/dist/word/roundtrip/apply.d.ts.map +1 -0
  383. package/dist/word/roundtrip/apply.js +260 -0
  384. package/dist/word/roundtrip/apply.js.map +1 -0
  385. package/dist/word/roundtrip/blocks.d.ts +56 -0
  386. package/dist/word/roundtrip/blocks.d.ts.map +1 -0
  387. package/dist/word/roundtrip/blocks.js +145 -0
  388. package/dist/word/roundtrip/blocks.js.map +1 -0
  389. package/dist/word/roundtrip/corpus.test.d.ts +2 -0
  390. package/dist/word/roundtrip/corpus.test.d.ts.map +1 -0
  391. package/dist/word/roundtrip/corpus.test.js +54 -0
  392. package/dist/word/roundtrip/corpus.test.js.map +1 -0
  393. package/dist/word/roundtrip/diff.d.ts +15 -0
  394. package/dist/word/roundtrip/diff.d.ts.map +1 -0
  395. package/dist/word/roundtrip/diff.js +160 -0
  396. package/dist/word/roundtrip/diff.js.map +1 -0
  397. package/dist/word/roundtrip/diff.test.d.ts +2 -0
  398. package/dist/word/roundtrip/diff.test.d.ts.map +1 -0
  399. package/dist/word/roundtrip/diff.test.js +79 -0
  400. package/dist/word/roundtrip/diff.test.js.map +1 -0
  401. package/dist/word/roundtrip/edits.d.ts +34 -0
  402. package/dist/word/roundtrip/edits.d.ts.map +1 -0
  403. package/dist/word/roundtrip/edits.js +467 -0
  404. package/dist/word/roundtrip/edits.js.map +1 -0
  405. package/dist/word/roundtrip/fixture.test-helper.d.ts +62 -0
  406. package/dist/word/roundtrip/fixture.test-helper.d.ts.map +1 -0
  407. package/dist/word/roundtrip/fixture.test-helper.js +258 -0
  408. package/dist/word/roundtrip/fixture.test-helper.js.map +1 -0
  409. package/dist/word/roundtrip/formats.d.ts +6 -0
  410. package/dist/word/roundtrip/formats.d.ts.map +1 -0
  411. package/dist/word/roundtrip/formats.js +102 -0
  412. package/dist/word/roundtrip/formats.js.map +1 -0
  413. package/dist/word/roundtrip/formatted.test.d.ts +2 -0
  414. package/dist/word/roundtrip/formatted.test.d.ts.map +1 -0
  415. package/dist/word/roundtrip/formatted.test.js +93 -0
  416. package/dist/word/roundtrip/formatted.test.js.map +1 -0
  417. package/dist/word/roundtrip/holders.test.d.ts +2 -0
  418. package/dist/word/roundtrip/holders.test.d.ts.map +1 -0
  419. package/dist/word/roundtrip/holders.test.js +109 -0
  420. package/dist/word/roundtrip/holders.test.js.map +1 -0
  421. package/dist/word/roundtrip/index.d.ts +6 -0
  422. package/dist/word/roundtrip/index.d.ts.map +1 -0
  423. package/dist/word/roundtrip/index.js +9 -0
  424. package/dist/word/roundtrip/index.js.map +1 -0
  425. package/dist/word/roundtrip/markup.d.ts +35 -0
  426. package/dist/word/roundtrip/markup.d.ts.map +1 -0
  427. package/dist/word/roundtrip/markup.js +168 -0
  428. package/dist/word/roundtrip/markup.js.map +1 -0
  429. package/dist/word/roundtrip/math.d.ts +12 -0
  430. package/dist/word/roundtrip/math.d.ts.map +1 -0
  431. package/dist/word/roundtrip/math.js +47 -0
  432. package/dist/word/roundtrip/math.js.map +1 -0
  433. package/dist/word/roundtrip/math.test.d.ts +2 -0
  434. package/dist/word/roundtrip/math.test.d.ts.map +1 -0
  435. package/dist/word/roundtrip/math.test.js +63 -0
  436. package/dist/word/roundtrip/math.test.js.map +1 -0
  437. package/dist/word/roundtrip/merge.d.ts +21 -0
  438. package/dist/word/roundtrip/merge.d.ts.map +1 -0
  439. package/dist/word/roundtrip/merge.js +81 -0
  440. package/dist/word/roundtrip/merge.js.map +1 -0
  441. package/dist/word/roundtrip/paragraphs.test.d.ts +2 -0
  442. package/dist/word/roundtrip/paragraphs.test.d.ts.map +1 -0
  443. package/dist/word/roundtrip/paragraphs.test.js +44 -0
  444. package/dist/word/roundtrip/paragraphs.test.js.map +1 -0
  445. package/dist/word/roundtrip/read.d.ts +60 -0
  446. package/dist/word/roundtrip/read.d.ts.map +1 -0
  447. package/dist/word/roundtrip/read.js +247 -0
  448. package/dist/word/roundtrip/read.js.map +1 -0
  449. package/dist/word/roundtrip/review.test.d.ts +2 -0
  450. package/dist/word/roundtrip/review.test.d.ts.map +1 -0
  451. package/dist/word/roundtrip/review.test.js +76 -0
  452. package/dist/word/roundtrip/review.test.js.map +1 -0
  453. package/dist/word/roundtrip/semantic.test.d.ts +2 -0
  454. package/dist/word/roundtrip/semantic.test.d.ts.map +1 -0
  455. package/dist/word/roundtrip/semantic.test.js +121 -0
  456. package/dist/word/roundtrip/semantic.test.js.map +1 -0
  457. package/dist/word/roundtrip/targets.d.ts +26 -0
  458. package/dist/word/roundtrip/targets.d.ts.map +1 -0
  459. package/dist/word/roundtrip/targets.js +58 -0
  460. package/dist/word/roundtrip/targets.js.map +1 -0
  461. package/dist/word/roundtrip/types.d.ts +46 -0
  462. package/dist/word/roundtrip/types.d.ts.map +1 -0
  463. package/dist/word/roundtrip/types.js +4 -0
  464. package/dist/word/roundtrip/types.js.map +1 -0
  465. package/dist/word/roundtrip/walk.d.ts +66 -0
  466. package/dist/word/roundtrip/walk.d.ts.map +1 -0
  467. package/dist/word/roundtrip/walk.js +328 -0
  468. package/dist/word/roundtrip/walk.js.map +1 -0
  469. package/dist/word/roundtrip/writers.test.d.ts +2 -0
  470. package/dist/word/roundtrip/writers.test.d.ts.map +1 -0
  471. package/dist/word/roundtrip/writers.test.js +51 -0
  472. package/dist/word/roundtrip/writers.test.js.map +1 -0
  473. package/dist/word/semantic/atoms.d.ts +14 -0
  474. package/dist/word/semantic/atoms.d.ts.map +1 -0
  475. package/dist/word/semantic/atoms.js +85 -0
  476. package/dist/word/semantic/atoms.js.map +1 -0
  477. package/dist/word/semantic/blocks.d.ts +39 -0
  478. package/dist/word/semantic/blocks.d.ts.map +1 -0
  479. package/dist/word/semantic/blocks.js +260 -0
  480. package/dist/word/semantic/blocks.js.map +1 -0
  481. package/dist/word/semantic/chapter.d.ts +17 -0
  482. package/dist/word/semantic/chapter.d.ts.map +1 -0
  483. package/dist/word/semantic/chapter.js +56 -0
  484. package/dist/word/semantic/chapter.js.map +1 -0
  485. package/dist/word/semantic/constructs.test.d.ts +2 -0
  486. package/dist/word/semantic/constructs.test.d.ts.map +1 -0
  487. package/dist/word/semantic/constructs.test.js +267 -0
  488. package/dist/word/semantic/constructs.test.js.map +1 -0
  489. package/dist/word/semantic/containers.d.ts +8 -0
  490. package/dist/word/semantic/containers.d.ts.map +1 -0
  491. package/dist/word/semantic/containers.js +141 -0
  492. package/dist/word/semantic/containers.js.map +1 -0
  493. package/dist/word/semantic/context.d.ts +83 -0
  494. package/dist/word/semantic/context.d.ts.map +1 -0
  495. package/dist/word/semantic/context.js +9 -0
  496. package/dist/word/semantic/context.js.map +1 -0
  497. package/dist/word/semantic/corpus.test.d.ts +2 -0
  498. package/dist/word/semantic/corpus.test.d.ts.map +1 -0
  499. package/dist/word/semantic/corpus.test.js +80 -0
  500. package/dist/word/semantic/corpus.test.js.map +1 -0
  501. package/dist/word/semantic/engineNumbers.d.ts +31 -0
  502. package/dist/word/semantic/engineNumbers.d.ts.map +1 -0
  503. package/dist/word/semantic/engineNumbers.js +66 -0
  504. package/dist/word/semantic/engineNumbers.js.map +1 -0
  505. package/dist/word/semantic/figures.d.ts +8 -0
  506. package/dist/word/semantic/figures.d.ts.map +1 -0
  507. package/dist/word/semantic/figures.js +175 -0
  508. package/dist/word/semantic/figures.js.map +1 -0
  509. package/dist/word/semantic/fixtures/harness.d.ts +20 -0
  510. package/dist/word/semantic/fixtures/harness.d.ts.map +1 -0
  511. package/dist/word/semantic/fixtures/harness.js +89 -0
  512. package/dist/word/semantic/fixtures/harness.js.map +1 -0
  513. package/dist/word/semantic/fragments.d.ts +48 -0
  514. package/dist/word/semantic/fragments.d.ts.map +1 -0
  515. package/dist/word/semantic/fragments.js +109 -0
  516. package/dist/word/semantic/fragments.js.map +1 -0
  517. package/dist/word/semantic/index.d.ts +25 -0
  518. package/dist/word/semantic/index.d.ts.map +1 -0
  519. package/dist/word/semantic/index.js +141 -0
  520. package/dist/word/semantic/index.js.map +1 -0
  521. package/dist/word/semantic/inline.d.ts +34 -0
  522. package/dist/word/semantic/inline.d.ts.map +1 -0
  523. package/dist/word/semantic/inline.js +210 -0
  524. package/dist/word/semantic/inline.js.map +1 -0
  525. package/dist/word/semantic/inspect.d.ts +6 -0
  526. package/dist/word/semantic/inspect.d.ts.map +1 -0
  527. package/dist/word/semantic/inspect.js +102 -0
  528. package/dist/word/semantic/inspect.js.map +1 -0
  529. package/dist/word/semantic/marks.d.ts +30 -0
  530. package/dist/word/semantic/marks.d.ts.map +1 -0
  531. package/dist/word/semantic/marks.js +87 -0
  532. package/dist/word/semantic/marks.js.map +1 -0
  533. package/dist/word/semantic/numbering.d.ts +18 -0
  534. package/dist/word/semantic/numbering.d.ts.map +1 -0
  535. package/dist/word/semantic/numbering.js +93 -0
  536. package/dist/word/semantic/numbering.js.map +1 -0
  537. package/dist/word/semantic/numbers.test.d.ts +2 -0
  538. package/dist/word/semantic/numbers.test.d.ts.map +1 -0
  539. package/dist/word/semantic/numbers.test.js +53 -0
  540. package/dist/word/semantic/numbers.test.js.map +1 -0
  541. package/dist/word/semantic/raw.d.ts +8 -0
  542. package/dist/word/semantic/raw.d.ts.map +1 -0
  543. package/dist/word/semantic/raw.js +42 -0
  544. package/dist/word/semantic/raw.js.map +1 -0
  545. package/dist/word/semantic/review.test.d.ts +2 -0
  546. package/dist/word/semantic/review.test.d.ts.map +1 -0
  547. package/dist/word/semantic/review.test.js +88 -0
  548. package/dist/word/semantic/review.test.js.map +1 -0
  549. package/dist/word/semantic/sections.d.ts +25 -0
  550. package/dist/word/semantic/sections.d.ts.map +1 -0
  551. package/dist/word/semantic/sections.js +83 -0
  552. package/dist/word/semantic/sections.js.map +1 -0
  553. package/dist/word/semantic/snippet.d.ts +10 -0
  554. package/dist/word/semantic/snippet.d.ts.map +1 -0
  555. package/dist/word/semantic/snippet.js +34 -0
  556. package/dist/word/semantic/snippet.js.map +1 -0
  557. package/dist/word/semantic/styles.d.ts +66 -0
  558. package/dist/word/semantic/styles.d.ts.map +1 -0
  559. package/dist/word/semantic/styles.js +354 -0
  560. package/dist/word/semantic/styles.js.map +1 -0
  561. package/dist/word/semantic/tables.d.ts +4 -0
  562. package/dist/word/semantic/tables.d.ts.map +1 -0
  563. package/dist/word/semantic/tables.js +114 -0
  564. package/dist/word/semantic/tables.js.map +1 -0
  565. package/dist/word/semantic/types.d.ts +9 -0
  566. package/dist/word/semantic/types.d.ts.map +1 -0
  567. package/dist/word/semantic/types.js +3 -0
  568. package/dist/word/semantic/types.js.map +1 -0
  569. package/dist/word/semantic/wml.d.ts +104 -0
  570. package/dist/word/semantic/wml.d.ts.map +1 -0
  571. package/dist/word/semantic/wml.js +192 -0
  572. package/dist/word/semantic/wml.js.map +1 -0
  573. package/dist/word/word.test.js +31 -53
  574. package/dist/word/word.test.js.map +1 -1
  575. package/dist/word/xml.d.ts +16 -0
  576. package/dist/word/xml.d.ts.map +1 -1
  577. package/dist/word/xml.js +61 -15
  578. package/dist/word/xml.js.map +1 -1
  579. package/dist/word/xml.test.d.ts +2 -0
  580. package/dist/word/xml.test.d.ts.map +1 -0
  581. package/dist/word/xml.test.js +46 -0
  582. package/dist/word/xml.test.js.map +1 -0
  583. package/package.json +1 -1
  584. package/dist/word/toDocx/parse.d.ts +0 -46
  585. package/dist/word/toDocx/parse.d.ts.map +0 -1
  586. package/dist/word/toDocx/parse.js +0 -313
  587. package/dist/word/toDocx/parse.js.map +0 -1
  588. package/dist/word/toDocx/styles.d.ts +0 -63
  589. package/dist/word/toDocx/styles.d.ts.map +0 -1
  590. package/dist/word/toDocx/styles.js +0 -239
  591. package/dist/word/toDocx/styles.js.map +0 -1
  592. package/dist/word/toDocx/wordml.d.ts +0 -24
  593. package/dist/word/toDocx/wordml.d.ts.map +0 -1
  594. package/dist/word/toDocx/wordml.js +0 -114
  595. package/dist/word/toDocx/wordml.js.map +0 -1
  596. package/dist/word/toDocx.d.ts +0 -6
  597. package/dist/word/toDocx.d.ts.map +0 -1
  598. package/dist/word/toDocx.js +0 -157
  599. package/dist/word/toDocx.js.map +0 -1
@@ -0,0 +1,79 @@
1
+ // Shapes inline in a line (#1406): a chip's box under its words and a
2
+ // colour swatch in the holder its run leaves, as the canvas and the PDF
3
+ // paint them (`canvas-backend/chip.ts`, `swatch.ts`): the fill, then the
4
+ // outline stroked inside the edge. Drawn from the item's lines, in its
5
+ // unturned frame, turned with the item.
6
+ import { swatchGeometry } from '../../paint/swatchShape.js';
7
+ import { turnedBox, turnPoint } from './drawing.js';
8
+ import { rectRuns, ruleRun } from './shapes.js';
9
+ /** A box filled and stroked inside its edge, radius `r` at its outer edge. */
10
+ function boxRuns(ctx, r, radius, fill, stroke, strokeW, centre, rotate) {
11
+ const half = stroke && strokeW > 0 ? strokeW / 2 : 0;
12
+ // A centred DrawingML stroke on the box inset by half its width covers
13
+ // the edge band; the fill under its inner half is hidden as on canvas.
14
+ const inner = { x: r.x + half, y: r.y + half, width: Math.max(0, r.width - 2 * half), height: Math.max(0, r.height - 2 * half) };
15
+ const rect = turnedBox(half ? inner : r, centre, rotate);
16
+ return rectRuns(ctx, {
17
+ kind: 'rect', rect,
18
+ ...(fill ? { fill } : {}),
19
+ ...(half ? { stroke, strokeWidthPx: strokeW } : {}),
20
+ ...(radius - half > 0 ? { radius: radius - half } : {}),
21
+ ...(rotate ? { rotate } : {}),
22
+ });
23
+ }
24
+ /** The shapes of a chip run (its box) on `line`. */
25
+ function chipRuns(ctx, run, line, centre, rotate) {
26
+ const b = run.inline?.box;
27
+ if (!b)
28
+ return [];
29
+ const baseline = line.baseline;
30
+ const r = { x: run.x + b.dx, y: baseline - b.ascent, width: b.width, height: b.ascent + b.descent };
31
+ if (b.underline) {
32
+ if (!b.stroke || !b.strokeWidthPx)
33
+ return b.fill ? boxRuns(ctx, r, b.radius ?? 0, b.fill, undefined, 0, centre, rotate) : [];
34
+ const y = r.y + r.height - b.strokeWidthPx / 2;
35
+ const p = turnPoint({ x: r.x, y }, centre, rotate ?? 0);
36
+ const q = turnPoint({ x: r.x + r.width, y }, centre, rotate ?? 0);
37
+ const dash = b.underline === 'dotted' ? [b.strokeWidthPx, b.strokeWidthPx * 2.2] : b.underline === 'dashed' ? [b.strokeWidthPx * 3, b.strokeWidthPx * 2] : undefined;
38
+ const out = b.fill ? boxRuns(ctx, r, b.radius ?? 0, b.fill, undefined, 0, centre, rotate) : [];
39
+ out.push(ruleRun(ctx, { kind: 'rule', x1: p.x, y1: p.y, x2: q.x, y2: q.y, color: b.stroke, widthPx: b.strokeWidthPx, ...(dash ? { dash } : {}) }));
40
+ return out;
41
+ }
42
+ if (!b.fill && !b.stroke)
43
+ return [];
44
+ return boxRuns(ctx, r, b.radius ?? 0, b.fill, b.stroke, b.strokeWidthPx ?? 0, centre, rotate);
45
+ }
46
+ /** The square of a swatch run on `line` (an inline symbol draws nothing). */
47
+ function swatchRuns(ctx, run, line, centre, rotate) {
48
+ const sw = run.inline?.swatch;
49
+ if (!sw || sw.icon)
50
+ return [];
51
+ const g = swatchGeometry({ ...(sw.side !== undefined ? { side: sw.side } : {}), ...(sw.borderWidth !== undefined ? { borderWidth: sw.borderWidth } : {}), ...(sw.radius !== undefined ? { radius: sw.radius } : {}) }, run.x, line.baseline - (run.baselineShift ?? 0), run.width, run.rtl === true);
52
+ return boxRuns(ctx, { x: g.x, y: g.y, width: g.side, height: g.side }, g.radius, sw.color, sw.ink, g.stroke, centre, rotate);
53
+ }
54
+ /** The chip boxes of `lines`, drawn before their text as empty text
55
+ * boxes (under it in Word and in LibreOffice). */
56
+ export function chipBoxRuns(ctx, lines, centre, rotate) {
57
+ const out = [];
58
+ for (const line of lines) {
59
+ if (line.vertical)
60
+ continue;
61
+ for (const run of line.runs)
62
+ if (run.inline?.kind === 'chip')
63
+ out.push(...chipRuns(ctx, run, line, centre, rotate));
64
+ }
65
+ return out;
66
+ }
67
+ /** The swatches of `lines` (drawn over the holders their runs leave). */
68
+ export function swatchShapeRuns(ctx, lines, centre, rotate) {
69
+ const out = [];
70
+ for (const line of lines) {
71
+ if (line.vertical)
72
+ continue;
73
+ for (const run of line.runs)
74
+ if (run.inline?.kind === 'swatch')
75
+ out.push(...swatchRuns(ctx, run, line, centre, rotate));
76
+ }
77
+ return out;
78
+ }
79
+ //# sourceMappingURL=inlineShapes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inlineShapes.js","sourceRoot":"","sources":["../../../src/word/formatted/inlineShapes.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,wEAAwE;AACxE,yEAAyE;AACzE,uEAAuE;AACvE,wCAAwC;AAGxC,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAKhD,8EAA8E;AAC9E,SAAS,OAAO,CAAC,GAAkB,EAAE,CAAc,EAAE,MAAc,EAAE,IAAwB,EAAE,MAA0B,EAAE,OAAe,EAAE,MAAc,EAAE,MAA0B;IACpL,MAAM,IAAI,GAAG,MAAM,IAAI,OA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IACvH,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,QAAQ;YAAE,SAAS;QAC5B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI;YAAE,IAAI,GAAG,CAAC,MAAM,EAAE,IAAI,KAAK,MAAM;gBAAE,GAAG,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACtH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,eAAe,CAAC,GAAkB,EAAE,KAA6B,EAAE,MAAc,EAAE,MAA0B;IAC3H,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,QAAQ;YAAE,SAAS;QAC5B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI;YAAE,IAAI,GAAG,CAAC,MAAM,EAAE,IAAI,KAAK,QAAQ;gBAAE,GAAG,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1H,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { type Sfnt } from '../fonts/sfnt.js';
2
+ import type { WordFontPlan } from '../fonts/types.js';
3
+ export interface FaceMetrics {
4
+ unitsPerEm: number;
5
+ /** Positive font units above the baseline. */
6
+ ascent: number;
7
+ /** Positive font units below the baseline. */
8
+ descent: number;
9
+ }
10
+ /** Descent of a font of unknown metrics, as a fraction of its size. */
11
+ export declare const FALLBACK_DESCENT = 0.2;
12
+ /** Windows vertical metrics of an sfnt (OS/2 win metrics, else hhea). */
13
+ export declare function faceMetricsOf(font: Sfnt): FaceMetrics | undefined;
14
+ export declare function readFaceMetrics(bytes: Uint8Array): FaceMetrics | undefined;
15
+ /** Horizontal advances of a face, by code point. */
16
+ export interface FaceAdvances {
17
+ unitsPerEm: number;
18
+ cmap: Map<number, number>;
19
+ advances: number[];
20
+ /** The face's GSUB table, for a feature family's figures. */
21
+ gsub?: Uint8Array;
22
+ }
23
+ /** cmap and hmtx of an sfnt, when it has both. */
24
+ export declare function faceAdvancesOf(font: Sfnt): FaceAdvances | undefined;
25
+ /** Advance in ems of the characters of `text` the face has, and how many
26
+ * it lacks (a renderer draws those from a fallback face). `features`
27
+ * (onum, tnum, …) swap figures as Word's numForm/numSpacing do. */
28
+ export declare function measureEms(face: FaceAdvances, text: string, features?: readonly string[]): {
29
+ ems: number;
30
+ missing: number;
31
+ };
32
+ /** Natural advance of `text` in ems; undefined when the face lacks a
33
+ * character (the renderer would fall back to another face). */
34
+ export declare function naturalEms(face: FaceAdvances, text: string, features?: readonly string[]): number | undefined;
35
+ /** The px size of a CSS font shorthand (0 when it has none). */
36
+ export declare function fontSizePx(fontString: string): number;
37
+ /** Where Word sets the baseline below the top of an exact line box. */
38
+ export declare function baselineOffset(pitchPx: number, descentPx: number): number;
39
+ /** Font descents and advances per font string, from the embedded faces of
40
+ * the plan (a feature family `Lora@onum` reads its base family's face). */
41
+ export declare class MetricsCache {
42
+ private readonly plan;
43
+ private readonly byFont;
44
+ private readonly byFace;
45
+ constructor(plan: WordFontPlan | undefined);
46
+ private face;
47
+ /** The face metrics a font string resolves to in the plan, if embedded. */
48
+ faceMetrics(fontString: string): FaceMetrics | undefined;
49
+ /** The advances of the face a font string resolves to, if embedded. */
50
+ faceAdvances(fontString: string): FaceAdvances | undefined;
51
+ /** Descent in px of a font string at its size. */
52
+ descentPx(fontString: string): number;
53
+ }
54
+ //# sourceMappingURL=metrics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../../src/word/formatted/metrics.ts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AAM,CAGrD;AAED,uEAAuE;AACvE,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAEzE;AAOD;4EAC4E;AAC5E,qBAAa,YAAY;IAIX,OAAO,CAAC,QAAQ,CAAC,IAAI;IAHjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6B;IACpD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6C;gBAEvC,IAAI,EAAE,YAAY,GAAG,SAAS;IAE3D,OAAO,CAAC,IAAI;IAaZ,2EAA2E;IAC3E,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAIxD,uEAAuE;IACvE,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAI1D,kDAAkD;IAClD,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;CAUtC"}
@@ -0,0 +1,165 @@
1
+ // Vertical font metrics and the baseline calibration of the formatted
2
+ // Word export (#1392). With exact line spacing Word gives every line a
3
+ // box of exactly the pitch and sets the baseline at
4
+ //
5
+ // baselineOffset = pitch − descent
6
+ //
7
+ // below the line box's top, `descent` being the line's largest font
8
+ // descent at its size (Windows metrics: OS/2 usWinDescent, else hhea
9
+ // descender, over head.unitsPerEm); the extra leading goes above the
10
+ // text. A text box is therefore placed with its top at
11
+ // `firstBaseline − baselineOffset`. This is the one place to recalibrate
12
+ // against a renderer (Word, LibreOffice) if a font lands off its line.
13
+ //
14
+ // The same faces give the natural advances of a run's characters (cmap →
15
+ // GSUB figure substitutions → hmtx, no kerning or shaping), so runs.ts can
16
+ // space every run out to the width the engine set it at (#1406).
17
+ import { readSfnt } from '../fonts/sfnt.js';
18
+ import { readCmap } from '../fonts/cmap.js';
19
+ import { readHmtx } from '../fonts/glyf.js';
20
+ import { gsubSingles } from '../fonts/gsub.js';
21
+ import { wordFontFor } from '../fonts/plan.js';
22
+ import { findPxSize } from '../../measure/fontString.js';
23
+ /** Descent of a font of unknown metrics, as a fraction of its size. */
24
+ export const FALLBACK_DESCENT = 0.2;
25
+ function u16(t, at) {
26
+ return (t[at] << 8) | t[at + 1];
27
+ }
28
+ function i16(t, at) {
29
+ const v = u16(t, at);
30
+ return v & 0x8000 ? v - 0x10000 : v;
31
+ }
32
+ /** Windows vertical metrics of an sfnt (OS/2 win metrics, else hhea). */
33
+ export function faceMetricsOf(font) {
34
+ const head = font.tables.get('head');
35
+ if (!head || head.length < 20)
36
+ return undefined;
37
+ const unitsPerEm = u16(head, 18);
38
+ if (!unitsPerEm)
39
+ return undefined;
40
+ const os2 = font.tables.get('OS/2');
41
+ if (os2 && os2.length >= 78) {
42
+ const ascent = u16(os2, 74);
43
+ const descent = u16(os2, 76);
44
+ if (ascent + descent > 0)
45
+ return { unitsPerEm, ascent, descent };
46
+ }
47
+ const hhea = font.tables.get('hhea');
48
+ if (hhea && hhea.length >= 8)
49
+ return { unitsPerEm, ascent: i16(hhea, 4), descent: Math.abs(i16(hhea, 6)) };
50
+ return undefined;
51
+ }
52
+ export function readFaceMetrics(bytes) {
53
+ const font = readSfnt(bytes);
54
+ return font ? faceMetricsOf(font) : undefined;
55
+ }
56
+ /** cmap and hmtx of an sfnt, when it has both. */
57
+ export function faceAdvancesOf(font) {
58
+ const head = font.tables.get('head');
59
+ const hhea = font.tables.get('hhea');
60
+ const maxp = font.tables.get('maxp');
61
+ const hmtx = font.tables.get('hmtx');
62
+ if (!head || head.length < 20 || !hhea || hhea.length < 36 || !maxp || maxp.length < 6 || !hmtx)
63
+ return undefined;
64
+ const unitsPerEm = u16(head, 18);
65
+ const cmap = readCmap(font.tables.get('cmap'));
66
+ if (!unitsPerEm || cmap.size === 0)
67
+ return undefined;
68
+ const advances = readHmtx(hmtx, u16(hhea, 34), u16(maxp, 4)).map((m) => m[0]);
69
+ const gsub = font.tables.get('GSUB');
70
+ return { unitsPerEm, cmap, advances, ...(gsub ? { gsub } : {}) };
71
+ }
72
+ const singlesCache = new WeakMap();
73
+ /** Glyph substitutions of `features` in a face, cached per face. */
74
+ function singlesOf(face, features) {
75
+ if (!face.gsub || features.length === 0)
76
+ return undefined;
77
+ let byKey = singlesCache.get(face);
78
+ if (!byKey)
79
+ singlesCache.set(face, (byKey = new Map()));
80
+ const key = features.join(',');
81
+ let map = byKey.get(key);
82
+ if (!map)
83
+ byKey.set(key, (map = gsubSingles(face.gsub, features)));
84
+ return map;
85
+ }
86
+ // Format characters (ZWSP, soft hyphen, word joiner, BOM, variation
87
+ // selectors…) that Word and LibreOffice draw zero-wide when the face lacks
88
+ // them: no fallback glyph, so they never count as missing.
89
+ const IGNORABLE = /\p{Default_Ignorable_Code_Point}/u;
90
+ /** Advance in ems of the characters of `text` the face has, and how many
91
+ * it lacks (a renderer draws those from a fallback face). `features`
92
+ * (onum, tnum, …) swap figures as Word's numForm/numSpacing do. */
93
+ export function measureEms(face, text, features = []) {
94
+ const subs = singlesOf(face, features);
95
+ let units = 0;
96
+ let missing = 0;
97
+ for (const ch of text) {
98
+ const g = face.cmap.get(ch.codePointAt(0));
99
+ if (g === undefined || g === 0) {
100
+ if (!IGNORABLE.test(ch))
101
+ missing++;
102
+ continue;
103
+ }
104
+ units += face.advances[subs?.get(g) ?? g] ?? 0;
105
+ }
106
+ return { ems: units / face.unitsPerEm, missing };
107
+ }
108
+ /** Natural advance of `text` in ems; undefined when the face lacks a
109
+ * character (the renderer would fall back to another face). */
110
+ export function naturalEms(face, text, features = []) {
111
+ const m = measureEms(face, text, features);
112
+ return m.missing ? undefined : m.ems;
113
+ }
114
+ /** The px size of a CSS font shorthand (0 when it has none). */
115
+ export function fontSizePx(fontString) {
116
+ const m = findPxSize(fontString);
117
+ return m ? Number(m.value) : 0;
118
+ }
119
+ /** Where Word sets the baseline below the top of an exact line box. */
120
+ export function baselineOffset(pitchPx, descentPx) {
121
+ return pitchPx - descentPx;
122
+ }
123
+ /** Font descents and advances per font string, from the embedded faces of
124
+ * the plan (a feature family `Lora@onum` reads its base family's face). */
125
+ export class MetricsCache {
126
+ plan;
127
+ byFont = new Map();
128
+ byFace = new Map();
129
+ constructor(plan) {
130
+ this.plan = plan;
131
+ }
132
+ face(fontString) {
133
+ if (!this.plan)
134
+ return undefined;
135
+ const ref = wordFontFor(this.plan, fontString);
136
+ const slot = ref.bold ? (ref.italic ? 'boldItalic' : 'bold') : ref.italic ? 'italic' : 'regular';
137
+ const key = `${ref.family}|${slot}`;
138
+ if (!this.byFace.has(key)) {
139
+ const face = this.plan.faces.find((f) => f.family === ref.family && f.slot === slot) ?? this.plan.faces.find((f) => f.family === ref.family);
140
+ const font = face ? readSfnt(face.bytes) : undefined;
141
+ this.byFace.set(key, font ? { metrics: faceMetricsOf(font), advances: faceAdvancesOf(font) } : undefined);
142
+ }
143
+ return this.byFace.get(key);
144
+ }
145
+ /** The face metrics a font string resolves to in the plan, if embedded. */
146
+ faceMetrics(fontString) {
147
+ return this.face(fontString)?.metrics;
148
+ }
149
+ /** The advances of the face a font string resolves to, if embedded. */
150
+ faceAdvances(fontString) {
151
+ return this.face(fontString)?.advances;
152
+ }
153
+ /** Descent in px of a font string at its size. */
154
+ descentPx(fontString) {
155
+ let d = this.byFont.get(fontString);
156
+ if (d === undefined) {
157
+ const size = fontSizePx(fontString);
158
+ const m = this.faceMetrics(fontString);
159
+ d = m ? (m.descent / m.unitsPerEm) * size : FALLBACK_DESCENT * size;
160
+ this.byFont.set(fontString, d);
161
+ }
162
+ return d;
163
+ }
164
+ }
165
+ //# sourceMappingURL=metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../src/word/formatted/metrics.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,uEAAuE;AACvE,oDAAoD;AACpD,EAAE;AACF,uCAAuC;AACvC,EAAE;AACF,oEAAoE;AACpE,qEAAqE;AACrE,qEAAqE;AACrE,uDAAuD;AACvD,yEAAyE;AACzE,uEAAuE;AACvE,EAAE;AACF,yEAAyE;AACzE,2EAA2E;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IAAI,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;YACpC,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;YACvC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,gBAAgB,GAAG,IAAI,CAAC;YACpE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;CACF"}
@@ -0,0 +1,16 @@
1
+ import type { DisplayPage } from '../../paint/displayList/types.js';
2
+ import type { WriterContext } from './types.js';
3
+ /** Word's largest page side (22 in), twips. */
4
+ export declare const MAX_PAGE_TWIPS = 31680;
5
+ /** `w:sectPr` of a page: its size in twips, every margin and distance 0.
6
+ * Never `w:bidi`, even on a right-to-left page: nothing flows in the
7
+ * section (each paragraph carries its own direction), and a
8
+ * right-to-left section lets a renderer measure page-relative drawing
9
+ * offsets from the right edge, which would mirror every box. */
10
+ export declare function sectPrXml(page: DisplayPage): string;
11
+ /** The drawings of a page, in paint order. */
12
+ export declare function pageRuns(ctx: WriterContext, page: DisplayPage): Promise<string[]>;
13
+ /** A page as body XML: its anchor paragraph, ending its section unless it
14
+ * is the document's last page (whose `sectPr` closes the body). */
15
+ export declare function pageXml(ctx: WriterContext, page: DisplayPage, last: boolean): Promise<string>;
16
+ //# sourceMappingURL=page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../src/word/formatted/page.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAOpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,+CAA+C;AAC/C,eAAO,MAAM,cAAc,QAAQ,CAAC;AAEpC;;;;iEAIiE;AACjE,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAWnD;AAQD,8CAA8C;AAC9C,wBAAsB,QAAQ,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAiCvF;AAED;oEACoE;AACpE,wBAAsB,OAAO,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAYnG"}
@@ -0,0 +1,82 @@
1
+ // One page of the formatted Word export (#1392): a section of its own
2
+ // (exact page size, no margins, no header or footer room) holding one
3
+ // tiny anchor paragraph that carries every drawing of the page in paint
4
+ // order: the page background behind the text, then text boxes, shapes,
5
+ // pictures and tables.
6
+ import { anchorRun, shapeGraphic, xfrm } from './drawing.js';
7
+ import { imageRun } from './pictures.js';
8
+ import { pathRun, rectRuns, ruleRun } from './shapes.js';
9
+ import { tableRuns } from './tables.js';
10
+ import { textItemRuns } from './text.js';
11
+ import { solidFill, twips, wordColor } from './units.js';
12
+ /** Word's largest page side (22 in), twips. */
13
+ export const MAX_PAGE_TWIPS = 31680;
14
+ /** `w:sectPr` of a page: its size in twips, every margin and distance 0.
15
+ * Never `w:bidi`, even on a right-to-left page: nothing flows in the
16
+ * section (each paragraph carries its own direction), and a
17
+ * right-to-left section lets a renderer measure page-relative drawing
18
+ * offsets from the right edge, which would mirror every box. */
19
+ export function sectPrXml(page) {
20
+ const w = twips(page.width, page.dpi);
21
+ const h = twips(page.height, page.dpi);
22
+ return ('<w:sectPr>' +
23
+ `<w:pgSz w:w="${w}" w:h="${h}"${w > h ? ' w:orient="landscape"' : ''}/>` +
24
+ '<w:pgMar w:top="0" w:right="0" w:bottom="0" w:left="0" w:header="0" w:footer="0" w:gutter="0"/>' +
25
+ '<w:cols w:space="0"/>' +
26
+ '<w:docGrid w:linePitch="20"/>' +
27
+ '</w:sectPr>');
28
+ }
29
+ /** Whether a page background needs painting (white paper is the default). */
30
+ function paintsBackground(css) {
31
+ const c = wordColor(css);
32
+ return c !== undefined && c.alpha > 0 && c.hex !== 'FFFFFF';
33
+ }
34
+ /** The drawings of a page, in paint order. */
35
+ export async function pageRuns(ctx, page) {
36
+ const runs = [];
37
+ if (paintsBackground(page.background)) {
38
+ const rect = { x: 0, y: 0, width: page.width, height: page.height };
39
+ runs.push(anchorRun(ctx, { rect, behind: true, name: 'ptx page' }, (_id, cx, cy) => shapeGraphic(`${xfrm(cx, cy)}<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>${solidFill(page.background)}<a:ln><a:noFill/></a:ln>`)));
40
+ }
41
+ for (const item of page.items) {
42
+ switch (item.kind) {
43
+ case 'text':
44
+ runs.push(...(await textItemRuns(ctx, item)));
45
+ break;
46
+ case 'rule':
47
+ runs.push(ruleRun(ctx, item));
48
+ break;
49
+ case 'rect':
50
+ runs.push(...rectRuns(ctx, item));
51
+ break;
52
+ case 'path':
53
+ runs.push(pathRun(ctx, item));
54
+ break;
55
+ case 'image': {
56
+ const r = await imageRun(ctx, item);
57
+ if (r)
58
+ runs.push(r);
59
+ break;
60
+ }
61
+ case 'table':
62
+ runs.push(...(await tableRuns(ctx, item)));
63
+ break;
64
+ }
65
+ }
66
+ return runs;
67
+ }
68
+ /** A page as body XML: its anchor paragraph, ending its section unless it
69
+ * is the document's last page (whose `sectPr` closes the body). */
70
+ export async function pageXml(ctx, page, last) {
71
+ const runs = await pageRuns(ctx, page);
72
+ const sect = sectPrXml(page);
73
+ if (Math.max(twips(page.width, page.dpi), twips(page.height, page.dpi)) > MAX_PAGE_TWIPS) {
74
+ ctx.warn('page-too-large', `a ${(page.width / page.dpi).toFixed(1)} × ${(page.height / page.dpi).toFixed(1)} in page is larger than Word's 22 in limit; Word shrinks the page and the drawings near its far edges fall off it`);
75
+ }
76
+ const pPr = '<w:pPr><w:pStyle w:val="PostextAnchor"/><w:spacing w:before="0" w:after="0" w:line="20" w:lineRule="exact"/>' +
77
+ '<w:rPr><w:sz w:val="2"/><w:szCs w:val="2"/></w:rPr>' +
78
+ (last ? '' : sect) +
79
+ '</w:pPr>';
80
+ return `<w:p>${pPr}${runs.join('')}</w:p>${last ? sect : ''}`;
81
+ }
82
+ //# sourceMappingURL=page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page.js","sourceRoot":"","sources":["../../../src/word/formatted/page.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,wEAAwE;AACxE,uEAAuE;AACvE,uBAAuB;AAGvB,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGzD,+CAA+C;AAC/C,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC;AAEpC;;;;iEAIiE;AACjE,MAAM,UAAU,SAAS,CAAC,IAAiB;IACzC,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACvC,OAAO,CACL,YAAY;QACZ,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,IAAI;QACxE,iGAAiG;QACjG,uBAAuB;QACvB,+BAA+B;QAC/B,aAAa,CACd,CAAC;AACJ,CAAC;AAED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AAC,CAAC,mHAAmH,CAAC,CAAC;IAClO,CAAC;IACD,MAAM,GAAG,GACP,8GAA8G;QAC9G,qDAAqD;QACrD,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAClB,UAAU,CAAC;IACb,OAAO,QAAQ,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAChE,CAAC"}
@@ -0,0 +1,98 @@
1
+ import type { DisplayItem, DisplayLine } from '../../paint/displayList/types.js';
2
+ import type { MapFormat, MapFragment } from '../anchors/types.js';
3
+ import { type EmittedRun, type InlineDrawing } from './runs.js';
4
+ import type { Annotation } from './eastAsian.js';
5
+ import type { WriterContext } from './types.js';
6
+ type TextItem = Extract<DisplayItem, {
7
+ kind: 'text';
8
+ }>;
9
+ /** Room on a box's free side so a ragged line Word sets a hair wider
10
+ * than the engine does not wrap (pt). */
11
+ export declare const SLACK_PT = 2;
12
+ /** Word's exact line spacing runs from 1 pt to 1584 pt (twips). */
13
+ export declare const MIN_PITCH = 20;
14
+ export declare const MAX_PITCH = 31680;
15
+ /** Room under a box's last line, at most this many twips (and never half
16
+ * a line, so the empty line a closing break opens still falls outside):
17
+ * renderers that round line heights on their own grid (LibreOffice's
18
+ * 1/100 mm) must not push the last line out of an exact-height box. */
19
+ export declare const BOTTOM_ROOM = 60;
20
+ type Jc = 'both' | 'left' | 'center' | 'right';
21
+ export interface LinePlan {
22
+ /** Exact line pitch, twips. */
23
+ h: number;
24
+ /** Descent of the line's largest face, px. */
25
+ d: number;
26
+ }
27
+ export interface Group {
28
+ jc: Jc;
29
+ from: number;
30
+ to: number;
31
+ pitch: number;
32
+ rtl: boolean;
33
+ firstL: number;
34
+ firstR: number;
35
+ restL: number;
36
+ restR: number;
37
+ /** The last line ends with `<w:br/>` (a justified line). */
38
+ endsWithBreak: boolean;
39
+ }
40
+ export interface Chunk {
41
+ from: number;
42
+ to: number;
43
+ groups: Group[];
44
+ }
45
+ /** Descent of a line: its largest face's (Word sizes the line by it),
46
+ * each run in the face it is written in (a space takes its word's). */
47
+ export declare function lineDescent(ctx: WriterContext, line: DisplayLine): number;
48
+ /** Room before the next run of the same direction, per run (px; runs
49
+ * set apart, a number flush right). Vertical runs go by x too, along
50
+ * the line in the item's unturned frame. */
51
+ export declare function runGaps(line: DisplayLine): number[];
52
+ /** Pitches and descents of an item's lines: line i's box is as tall as
53
+ * makes its baseline land `baselines[i] − baselines[i−1]` below the
54
+ * previous one (`h_i = Δ_i + d_i − d_{i−1}`). */
55
+ export declare function planLines(ctx: WriterContext, lines: readonly DisplayLine[]): LinePlan[];
56
+ /** Cut lines into paragraphs and boxes. `boxes` false (table cells): one
57
+ * chunk whatever the breaks. */
58
+ export declare function planChunks(lines: readonly DisplayLine[], plans: LinePlan[], boxes?: boolean): Chunk[];
59
+ /** The px box of a chunk: its lines' measures plus slack on the free side. */
60
+ export declare function chunkBox(ctx: WriterContext, lines: readonly DisplayLine[], chunk: Chunk, plans: LinePlan[]): {
61
+ x: number;
62
+ y: number;
63
+ width: number;
64
+ height: number;
65
+ };
66
+ /** What a run of paragraphs writes. */
67
+ export interface TextOut {
68
+ xml: string;
69
+ text: string;
70
+ map: number[];
71
+ formats: MapFormat[];
72
+ /** Item text offset → chunk text offset, per line start. */
73
+ lineStarts: {
74
+ item: number;
75
+ out: number;
76
+ length: number;
77
+ }[];
78
+ drawings: (InlineDrawing & {
79
+ baseline: number;
80
+ })[];
81
+ /** Marks beside runs (kanbun) and their rules, item's unturned frame. */
82
+ annotations: Annotation[];
83
+ rules: NonNullable<EmittedRun['rules']>;
84
+ /** Atoms the writer adds (forced breaks), at offsets of `text`. */
85
+ atoms: NonNullable<MapFragment['atoms']>;
86
+ }
87
+ export interface EmitOptions {
88
+ /** Spacing before the first paragraph, twips (table cells). */
89
+ spaceBefore?: number;
90
+ bookmarkStart?: string;
91
+ bookmarkEnd?: string;
92
+ /** Item text offset of each line. */
93
+ offsets: number[];
94
+ }
95
+ /** Paragraphs of `groups` (lines of `item`) inside the box [boxL, boxR]. */
96
+ export declare function emitGroups(ctx: WriterContext, item: TextItem, groups: Group[], boxL: number, boxR: number, opts: EmitOptions): TextOut;
97
+ export {};
98
+ //# sourceMappingURL=paragraphs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paragraphs.d.ts","sourceRoot":"","sources":["../../../src/word/formatted/paragraphs.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlE,OAAO,EAA6F,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAC3J,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,KAAK,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAMvD;0CAC0C;AAC1C,eAAO,MAAM,QAAQ,IAAI,CAAC;AAC1B,mEAAmE;AACnE,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,eAAO,MAAM,SAAS,QAAQ,CAAC;AAC/B;;;wEAGwE;AACxE,eAAO,MAAM,WAAW,KAAK,CAAC;AAE9B,KAAK,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE/C,MAAM,WAAW,QAAQ;IACvB,+BAA+B;IAC/B,CAAC,EAAE,MAAM,CAAC;IACV,8CAA8C;IAC9C,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,EAAE,CAAC;IACP,IAAI,EAAE,MAAM,CAAC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