@usejunior/docx-core 0.9.1 → 0.11.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 (335) hide show
  1. package/LICENSE +202 -21
  2. package/NOTICE +2 -0
  3. package/README.md +2 -2
  4. package/dist/.tsbuildinfo +1 -1
  5. package/dist/atomizer.d.ts +28 -8
  6. package/dist/atomizer.d.ts.map +1 -1
  7. package/dist/atomizer.js +96 -25
  8. package/dist/atomizer.js.map +1 -1
  9. package/dist/baselines/atomizer/auxiliaryIdCollision.d.ts +99 -0
  10. package/dist/baselines/atomizer/auxiliaryIdCollision.d.ts.map +1 -0
  11. package/dist/baselines/atomizer/auxiliaryIdCollision.js +415 -0
  12. package/dist/baselines/atomizer/auxiliaryIdCollision.js.map +1 -0
  13. package/dist/baselines/atomizer/documentReconstructor.d.ts.map +1 -1
  14. package/dist/baselines/atomizer/documentReconstructor.js +333 -112
  15. package/dist/baselines/atomizer/documentReconstructor.js.map +1 -1
  16. package/dist/baselines/atomizer/formattingFidelity.d.ts +99 -0
  17. package/dist/baselines/atomizer/formattingFidelity.d.ts.map +1 -0
  18. package/dist/baselines/atomizer/formattingFidelity.js +449 -0
  19. package/dist/baselines/atomizer/formattingFidelity.js.map +1 -0
  20. package/dist/baselines/atomizer/inPlaceModifier-bookmarks.d.ts +37 -0
  21. package/dist/baselines/atomizer/inPlaceModifier-bookmarks.d.ts.map +1 -0
  22. package/dist/baselines/atomizer/inPlaceModifier-bookmarks.js +189 -0
  23. package/dist/baselines/atomizer/inPlaceModifier-bookmarks.js.map +1 -0
  24. package/dist/baselines/atomizer/inPlaceModifier-containers.d.ts +74 -0
  25. package/dist/baselines/atomizer/inPlaceModifier-containers.d.ts.map +1 -0
  26. package/dist/baselines/atomizer/inPlaceModifier-containers.js +171 -0
  27. package/dist/baselines/atomizer/inPlaceModifier-containers.js.map +1 -0
  28. package/dist/baselines/atomizer/inPlaceModifier-deletion.d.ts +88 -0
  29. package/dist/baselines/atomizer/inPlaceModifier-deletion.d.ts.map +1 -0
  30. package/dist/baselines/atomizer/inPlaceModifier-deletion.js +326 -0
  31. package/dist/baselines/atomizer/inPlaceModifier-deletion.js.map +1 -0
  32. package/dist/baselines/atomizer/inPlaceModifier-postprocess.d.ts +85 -0
  33. package/dist/baselines/atomizer/inPlaceModifier-postprocess.d.ts.map +1 -0
  34. package/dist/baselines/atomizer/inPlaceModifier-postprocess.js +402 -0
  35. package/dist/baselines/atomizer/inPlaceModifier-postprocess.js.map +1 -0
  36. package/dist/baselines/atomizer/inPlaceModifier-presplit.d.ts +39 -0
  37. package/dist/baselines/atomizer/inPlaceModifier-presplit.d.ts.map +1 -0
  38. package/dist/baselines/atomizer/inPlaceModifier-presplit.js +265 -0
  39. package/dist/baselines/atomizer/inPlaceModifier-presplit.js.map +1 -0
  40. package/dist/baselines/atomizer/inPlaceModifier-shared.d.ts +62 -0
  41. package/dist/baselines/atomizer/inPlaceModifier-shared.d.ts.map +1 -0
  42. package/dist/baselines/atomizer/inPlaceModifier-shared.js +139 -0
  43. package/dist/baselines/atomizer/inPlaceModifier-shared.js.map +1 -0
  44. package/dist/baselines/atomizer/inPlaceModifier-wrappers.d.ts +198 -0
  45. package/dist/baselines/atomizer/inPlaceModifier-wrappers.d.ts.map +1 -0
  46. package/dist/baselines/atomizer/inPlaceModifier-wrappers.js +475 -0
  47. package/dist/baselines/atomizer/inPlaceModifier-wrappers.js.map +1 -0
  48. package/dist/baselines/atomizer/inPlaceModifier.d.ts +6 -290
  49. package/dist/baselines/atomizer/inPlaceModifier.d.ts.map +1 -1
  50. package/dist/baselines/atomizer/inPlaceModifier.js +23 -1828
  51. package/dist/baselines/atomizer/inPlaceModifier.js.map +1 -1
  52. package/dist/baselines/atomizer/pipeline.d.ts +36 -2
  53. package/dist/baselines/atomizer/pipeline.d.ts.map +1 -1
  54. package/dist/baselines/atomizer/pipeline.js +216 -144
  55. package/dist/baselines/atomizer/pipeline.js.map +1 -1
  56. package/dist/baselines/atomizer/trackChangesAcceptorAst.d.ts.map +1 -1
  57. package/dist/baselines/atomizer/trackChangesAcceptorAst.js +199 -173
  58. package/dist/baselines/atomizer/trackChangesAcceptorAst.js.map +1 -1
  59. package/dist/baselines/wmlcomparer/DotnetCli.d.ts.map +1 -1
  60. package/dist/baselines/wmlcomparer/DotnetCli.js +7 -0
  61. package/dist/baselines/wmlcomparer/DotnetCli.js.map +1 -1
  62. package/dist/cli/compare-two.d.ts.map +1 -1
  63. package/dist/cli/compare-two.js +3 -1
  64. package/dist/cli/compare-two.js.map +1 -1
  65. package/dist/cli/conformance-adapter.d.ts +3 -0
  66. package/dist/cli/conformance-adapter.d.ts.map +1 -0
  67. package/dist/cli/conformance-adapter.js +93 -0
  68. package/dist/cli/conformance-adapter.js.map +1 -0
  69. package/dist/cli/index.d.ts.map +1 -1
  70. package/dist/cli/index.js +5 -1
  71. package/dist/cli/index.js.map +1 -1
  72. package/dist/compare-types.d.ts +197 -0
  73. package/dist/compare-types.d.ts.map +1 -0
  74. package/dist/compare-types.js +2 -0
  75. package/dist/compare-types.js.map +1 -0
  76. package/dist/core-types.d.ts +5 -1
  77. package/dist/core-types.d.ts.map +1 -1
  78. package/dist/core-types.js +5 -1
  79. package/dist/core-types.js.map +1 -1
  80. package/dist/footnotes.d.ts +8 -3
  81. package/dist/footnotes.d.ts.map +1 -1
  82. package/dist/footnotes.js +8 -3
  83. package/dist/footnotes.js.map +1 -1
  84. package/dist/generation/compile.d.ts +21 -0
  85. package/dist/generation/compile.d.ts.map +1 -0
  86. package/dist/generation/compile.js +46 -0
  87. package/dist/generation/compile.js.map +1 -0
  88. package/dist/generation/context.d.ts +42 -0
  89. package/dist/generation/context.d.ts.map +1 -0
  90. package/dist/generation/context.js +65 -0
  91. package/dist/generation/context.js.map +1 -0
  92. package/dist/generation/emit/comments-part.d.ts +36 -0
  93. package/dist/generation/emit/comments-part.d.ts.map +1 -0
  94. package/dist/generation/emit/comments-part.js +116 -0
  95. package/dist/generation/emit/comments-part.js.map +1 -0
  96. package/dist/generation/emit/document-part.d.ts +24 -0
  97. package/dist/generation/emit/document-part.d.ts.map +1 -0
  98. package/dist/generation/emit/document-part.js +60 -0
  99. package/dist/generation/emit/document-part.js.map +1 -0
  100. package/dist/generation/emit/emit-context.d.ts +26 -0
  101. package/dist/generation/emit/emit-context.d.ts.map +1 -0
  102. package/dist/generation/emit/emit-context.js +19 -0
  103. package/dist/generation/emit/emit-context.js.map +1 -0
  104. package/dist/generation/emit/header-footer-part.d.ts +23 -0
  105. package/dist/generation/emit/header-footer-part.d.ts.map +1 -0
  106. package/dist/generation/emit/header-footer-part.js +57 -0
  107. package/dist/generation/emit/header-footer-part.js.map +1 -0
  108. package/dist/generation/emit/numbering-part.d.ts +29 -0
  109. package/dist/generation/emit/numbering-part.d.ts.map +1 -0
  110. package/dist/generation/emit/numbering-part.js +100 -0
  111. package/dist/generation/emit/numbering-part.js.map +1 -0
  112. package/dist/generation/emit/package-parts.d.ts +24 -0
  113. package/dist/generation/emit/package-parts.d.ts.map +1 -0
  114. package/dist/generation/emit/package-parts.js +121 -0
  115. package/dist/generation/emit/package-parts.js.map +1 -0
  116. package/dist/generation/emit/paragraph.d.ts +24 -0
  117. package/dist/generation/emit/paragraph.d.ts.map +1 -0
  118. package/dist/generation/emit/paragraph.js +63 -0
  119. package/dist/generation/emit/paragraph.js.map +1 -0
  120. package/dist/generation/emit/properties.d.ts +34 -0
  121. package/dist/generation/emit/properties.d.ts.map +1 -0
  122. package/dist/generation/emit/properties.js +138 -0
  123. package/dist/generation/emit/properties.js.map +1 -0
  124. package/dist/generation/emit/run.d.ts +15 -0
  125. package/dist/generation/emit/run.d.ts.map +1 -0
  126. package/dist/generation/emit/run.js +71 -0
  127. package/dist/generation/emit/run.js.map +1 -0
  128. package/dist/generation/emit/section.d.ts +29 -0
  129. package/dist/generation/emit/section.d.ts.map +1 -0
  130. package/dist/generation/emit/section.js +117 -0
  131. package/dist/generation/emit/section.js.map +1 -0
  132. package/dist/generation/emit/settings-part.d.ts +13 -0
  133. package/dist/generation/emit/settings-part.d.ts.map +1 -0
  134. package/dist/generation/emit/settings-part.js +24 -0
  135. package/dist/generation/emit/settings-part.js.map +1 -0
  136. package/dist/generation/emit/styles-part.d.ts +16 -0
  137. package/dist/generation/emit/styles-part.d.ts.map +1 -0
  138. package/dist/generation/emit/styles-part.js +80 -0
  139. package/dist/generation/emit/styles-part.js.map +1 -0
  140. package/dist/generation/emit/table.d.ts +26 -0
  141. package/dist/generation/emit/table.d.ts.map +1 -0
  142. package/dist/generation/emit/table.js +196 -0
  143. package/dist/generation/emit/table.js.map +1 -0
  144. package/dist/generation/errors.d.ts +22 -0
  145. package/dist/generation/errors.d.ts.map +1 -0
  146. package/dist/generation/errors.js +29 -0
  147. package/dist/generation/errors.js.map +1 -0
  148. package/dist/generation/index.d.ts +13 -0
  149. package/dist/generation/index.d.ts.map +1 -0
  150. package/dist/generation/index.js +12 -0
  151. package/dist/generation/index.js.map +1 -0
  152. package/dist/generation/ordering.d.ts +46 -0
  153. package/dist/generation/ordering.d.ts.map +1 -0
  154. package/dist/generation/ordering.js +119 -0
  155. package/dist/generation/ordering.js.map +1 -0
  156. package/dist/generation/recipes.d.ts +47 -0
  157. package/dist/generation/recipes.d.ts.map +1 -0
  158. package/dist/generation/recipes.js +84 -0
  159. package/dist/generation/recipes.js.map +1 -0
  160. package/dist/generation/structural-checks.d.ts +24 -0
  161. package/dist/generation/structural-checks.d.ts.map +1 -0
  162. package/dist/generation/structural-checks.js +318 -0
  163. package/dist/generation/structural-checks.js.map +1 -0
  164. package/dist/generation/types.d.ts +217 -0
  165. package/dist/generation/types.d.ts.map +1 -0
  166. package/dist/generation/types.js +16 -0
  167. package/dist/generation/types.js.map +1 -0
  168. package/dist/generation/validate-spec.d.ts +27 -0
  169. package/dist/generation/validate-spec.d.ts.map +1 -0
  170. package/dist/generation/validate-spec.js +307 -0
  171. package/dist/generation/validate-spec.js.map +1 -0
  172. package/dist/index.d.ts +9 -150
  173. package/dist/index.d.ts.map +1 -1
  174. package/dist/index.js +14 -0
  175. package/dist/index.js.map +1 -1
  176. package/dist/integration/generation-probes.d.ts +15 -0
  177. package/dist/integration/generation-probes.d.ts.map +1 -0
  178. package/dist/integration/generation-probes.js +84 -0
  179. package/dist/integration/generation-probes.js.map +1 -0
  180. package/dist/integration/libreoffice-oracle.d.ts +49 -0
  181. package/dist/integration/libreoffice-oracle.d.ts.map +1 -0
  182. package/dist/integration/libreoffice-oracle.js +290 -0
  183. package/dist/integration/libreoffice-oracle.js.map +1 -0
  184. package/dist/integration/synthetic-docx-fixture.d.ts +72 -0
  185. package/dist/integration/synthetic-docx-fixture.d.ts.map +1 -1
  186. package/dist/integration/synthetic-docx-fixture.js +131 -4
  187. package/dist/integration/synthetic-docx-fixture.js.map +1 -1
  188. package/dist/primitives/accept_changes.d.ts +4 -3
  189. package/dist/primitives/accept_changes.d.ts.map +1 -1
  190. package/dist/primitives/accept_changes.js +163 -77
  191. package/dist/primitives/accept_changes.js.map +1 -1
  192. package/dist/primitives/comments.d.ts +12 -3
  193. package/dist/primitives/comments.d.ts.map +1 -1
  194. package/dist/primitives/comments.js +374 -97
  195. package/dist/primitives/comments.js.map +1 -1
  196. package/dist/primitives/content_fingerprint.d.ts +29 -0
  197. package/dist/primitives/content_fingerprint.d.ts.map +1 -0
  198. package/dist/primitives/content_fingerprint.js +63 -0
  199. package/dist/primitives/content_fingerprint.js.map +1 -0
  200. package/dist/primitives/document.d.ts +94 -15
  201. package/dist/primitives/document.d.ts.map +1 -1
  202. package/dist/primitives/document.js +373 -36
  203. package/dist/primitives/document.js.map +1 -1
  204. package/dist/primitives/document_view-comments.d.ts +18 -0
  205. package/dist/primitives/document_view-comments.d.ts.map +1 -0
  206. package/dist/primitives/document_view-comments.js +160 -0
  207. package/dist/primitives/document_view-comments.js.map +1 -0
  208. package/dist/primitives/document_view-headings.d.ts +45 -0
  209. package/dist/primitives/document_view-headings.d.ts.map +1 -0
  210. package/dist/primitives/document_view-headings.js +247 -0
  211. package/dist/primitives/document_view-headings.js.map +1 -0
  212. package/dist/primitives/document_view-styles.d.ts +11 -0
  213. package/dist/primitives/document_view-styles.d.ts.map +1 -0
  214. package/dist/primitives/document_view-styles.js +104 -0
  215. package/dist/primitives/document_view-styles.js.map +1 -0
  216. package/dist/primitives/document_view-toon.d.ts +37 -0
  217. package/dist/primitives/document_view-toon.d.ts.map +1 -0
  218. package/dist/primitives/document_view-toon.js +199 -0
  219. package/dist/primitives/document_view-toon.js.map +1 -0
  220. package/dist/primitives/document_view-types.d.ts +152 -0
  221. package/dist/primitives/document_view-types.d.ts.map +1 -0
  222. package/dist/primitives/document_view-types.js +2 -0
  223. package/dist/primitives/document_view-types.js.map +1 -0
  224. package/dist/primitives/document_view.d.ts +8 -106
  225. package/dist/primitives/document_view.d.ts.map +1 -1
  226. package/dist/primitives/document_view.js +153 -312
  227. package/dist/primitives/document_view.js.map +1 -1
  228. package/dist/primitives/dom-helpers.d.ts +9 -0
  229. package/dist/primitives/dom-helpers.d.ts.map +1 -1
  230. package/dist/primitives/dom-helpers.js +10 -1
  231. package/dist/primitives/dom-helpers.js.map +1 -1
  232. package/dist/primitives/footnotes.d.ts +4 -3
  233. package/dist/primitives/footnotes.d.ts.map +1 -1
  234. package/dist/primitives/footnotes.js +232 -44
  235. package/dist/primitives/footnotes.js.map +1 -1
  236. package/dist/primitives/formatting_tags.d.ts +7 -0
  237. package/dist/primitives/formatting_tags.d.ts.map +1 -1
  238. package/dist/primitives/formatting_tags.js +22 -11
  239. package/dist/primitives/formatting_tags.js.map +1 -1
  240. package/dist/primitives/index.d.ts +10 -0
  241. package/dist/primitives/index.d.ts.map +1 -1
  242. package/dist/primitives/index.js +9 -0
  243. package/dist/primitives/index.js.map +1 -1
  244. package/dist/primitives/layout.d.ts +4 -3
  245. package/dist/primitives/layout.d.ts.map +1 -1
  246. package/dist/primitives/layout.js +45 -3
  247. package/dist/primitives/layout.js.map +1 -1
  248. package/dist/primitives/merge_runs.d.ts +21 -3
  249. package/dist/primitives/merge_runs.d.ts.map +1 -1
  250. package/dist/primitives/merge_runs.js +32 -10
  251. package/dist/primitives/merge_runs.js.map +1 -1
  252. package/dist/primitives/minimal_save.d.ts +38 -0
  253. package/dist/primitives/minimal_save.d.ts.map +1 -0
  254. package/dist/primitives/minimal_save.js +323 -0
  255. package/dist/primitives/minimal_save.js.map +1 -0
  256. package/dist/primitives/namespaces.d.ts +47 -0
  257. package/dist/primitives/namespaces.d.ts.map +1 -1
  258. package/dist/primitives/namespaces.js +52 -0
  259. package/dist/primitives/namespaces.js.map +1 -1
  260. package/dist/primitives/reject_changes.d.ts +6 -4
  261. package/dist/primitives/reject_changes.d.ts.map +1 -1
  262. package/dist/primitives/reject_changes.js +187 -91
  263. package/dist/primitives/reject_changes.js.map +1 -1
  264. package/dist/primitives/revision-parts.d.ts +7 -0
  265. package/dist/primitives/revision-parts.d.ts.map +1 -0
  266. package/dist/primitives/revision-parts.js +27 -0
  267. package/dist/primitives/revision-parts.js.map +1 -0
  268. package/dist/primitives/revision-vocabulary.d.ts +7 -0
  269. package/dist/primitives/revision-vocabulary.d.ts.map +1 -0
  270. package/dist/primitives/revision-vocabulary.js +39 -0
  271. package/dist/primitives/revision-vocabulary.js.map +1 -0
  272. package/dist/primitives/schema-corpus-capture.d.ts +19 -0
  273. package/dist/primitives/schema-corpus-capture.d.ts.map +1 -0
  274. package/dist/primitives/schema-corpus-capture.js +29 -0
  275. package/dist/primitives/schema-corpus-capture.js.map +1 -0
  276. package/dist/primitives/sectPrAudit.d.ts +19 -0
  277. package/dist/primitives/sectPrAudit.d.ts.map +1 -0
  278. package/dist/primitives/sectPrAudit.js +165 -0
  279. package/dist/primitives/sectPrAudit.js.map +1 -0
  280. package/dist/primitives/semantic_tags.d.ts +7 -0
  281. package/dist/primitives/semantic_tags.d.ts.map +1 -1
  282. package/dist/primitives/semantic_tags.js +23 -4
  283. package/dist/primitives/semantic_tags.js.map +1 -1
  284. package/dist/primitives/serialize_html.d.ts +37 -0
  285. package/dist/primitives/serialize_html.d.ts.map +1 -0
  286. package/dist/primitives/serialize_html.js +395 -0
  287. package/dist/primitives/serialize_html.js.map +1 -0
  288. package/dist/primitives/serialize_markdown.d.ts +16 -0
  289. package/dist/primitives/serialize_markdown.d.ts.map +1 -0
  290. package/dist/primitives/serialize_markdown.js +300 -0
  291. package/dist/primitives/serialize_markdown.js.map +1 -0
  292. package/dist/primitives/serialize_plaintext.d.ts +15 -0
  293. package/dist/primitives/serialize_plaintext.d.ts.map +1 -0
  294. package/dist/primitives/serialize_plaintext.js +154 -0
  295. package/dist/primitives/serialize_plaintext.js.map +1 -0
  296. package/dist/primitives/styles.d.ts +15 -0
  297. package/dist/primitives/styles.d.ts.map +1 -1
  298. package/dist/primitives/styles.js +33 -22
  299. package/dist/primitives/styles.js.map +1 -1
  300. package/dist/primitives/tables.d.ts.map +1 -1
  301. package/dist/primitives/tables.js +13 -3
  302. package/dist/primitives/tables.js.map +1 -1
  303. package/dist/primitives/text.d.ts +2 -1
  304. package/dist/primitives/text.d.ts.map +1 -1
  305. package/dist/primitives/text.js +116 -12
  306. package/dist/primitives/text.js.map +1 -1
  307. package/dist/primitives/track-changes-emitter.d.ts +148 -0
  308. package/dist/primitives/track-changes-emitter.d.ts.map +1 -0
  309. package/dist/primitives/track-changes-emitter.js +291 -0
  310. package/dist/primitives/track-changes-emitter.js.map +1 -0
  311. package/dist/primitives/validate_ai_revisions.d.ts +35 -0
  312. package/dist/primitives/validate_ai_revisions.d.ts.map +1 -0
  313. package/dist/primitives/validate_ai_revisions.js +323 -0
  314. package/dist/primitives/validate_ai_revisions.js.map +1 -0
  315. package/dist/primitives/xml-helpers.d.ts +29 -0
  316. package/dist/primitives/xml-helpers.d.ts.map +1 -0
  317. package/dist/primitives/xml-helpers.js +35 -0
  318. package/dist/primitives/xml-helpers.js.map +1 -0
  319. package/dist/primitives/xml.d.ts +5 -0
  320. package/dist/primitives/xml.d.ts.map +1 -1
  321. package/dist/primitives/xml.js +5 -0
  322. package/dist/primitives/xml.js.map +1 -1
  323. package/dist/primitives/zip.d.ts +1 -0
  324. package/dist/primitives/zip.d.ts.map +1 -1
  325. package/dist/primitives/zip.js +21 -3
  326. package/dist/primitives/zip.js.map +1 -1
  327. package/dist/shared/field-structure.d.ts +14 -0
  328. package/dist/shared/field-structure.d.ts.map +1 -0
  329. package/dist/shared/field-structure.js +166 -0
  330. package/dist/shared/field-structure.js.map +1 -0
  331. package/dist/shared/ooxml/namespaces.d.ts +4 -1
  332. package/dist/shared/ooxml/namespaces.d.ts.map +1 -1
  333. package/dist/shared/ooxml/namespaces.js +4 -1
  334. package/dist/shared/ooxml/namespaces.js.map +1 -1
  335. package/package.json +13 -9
@@ -0,0 +1,196 @@
1
+ /**
2
+ * Table emitter.
3
+ *
4
+ * Compiles TableSpec nodes into w:tbl structures: table-level properties and
5
+ * the column grid, then rows and cells. Cell content reuses the paragraph
6
+ * emitter, and nested tables recurse through buildTable. Two invariants are
7
+ * enforced by construction rather than checked after the fact:
8
+ *
9
+ * - every cell ends with a w:p (readers treat a cell whose last block is a
10
+ * table as corrupt), and
11
+ * - cell widths always come from somewhere deterministic — an explicit
12
+ * widthTwips, or the sum of the grid columns the cell spans.
13
+ */
14
+ import { createWmlElement } from '../../primitives/dom-helpers.js';
15
+ import { W } from '../../primitives/namespaces.js';
16
+ import { appendInOrder, TBLPR_ORDER, TCPR_ORDER, TRPR_ORDER } from '../ordering.js';
17
+ import { buildParagraph } from './paragraph.js';
18
+ /**
19
+ * Build the w:tbl element for a table block.
20
+ *
21
+ * @conformance ECMA-376 edition 5, Part 1 § 17.4.37
22
+ * @conformance ECMA-376 edition 5, Part 1 § 17.4.59
23
+ * @conformance ECMA-376 edition 5, Part 1 § 17.4.48
24
+ */
25
+ export function buildTable(doc, table, ctx) {
26
+ const tbl = createWmlElement(doc, W.tbl);
27
+ tbl.appendChild(buildTblPr(doc, table));
28
+ tbl.appendChild(buildTblGrid(doc, table));
29
+ for (const row of table.rows) {
30
+ tbl.appendChild(buildRow(doc, table, row, ctx));
31
+ }
32
+ return tbl;
33
+ }
34
+ /**
35
+ * Table-level properties. w:tblW always carries the dxa sum of the declared
36
+ * grid so the preferred width and the grid agree, and w:tblLayout is always
37
+ * emitted explicitly (fixed by default) because autofit is the reader-side
38
+ * default and silently reflows fixed designs.
39
+ *
40
+ * @conformance ECMA-376 edition 5, Part 1 § 17.4.63
41
+ * @conformance ECMA-376 edition 5, Part 1 § 17.4.52
42
+ * @conformance ECMA-376 edition 5, Part 1 § 17.4.38
43
+ */
44
+ function buildTblPr(doc, table) {
45
+ const tblPr = createWmlElement(doc, W.tblPr);
46
+ const props = new Map();
47
+ const widthSum = table.columnWidthsTwips.reduce((sum, w) => sum + w, 0);
48
+ props.set(W.tblW, createWmlElement(doc, W.tblW, { 'w:w': String(widthSum), 'w:type': 'dxa' }));
49
+ if (table.borders) {
50
+ props.set(W.tblBorders, buildBordersElement(doc, W.tblBorders, table.borders));
51
+ }
52
+ props.set(W.tblLayout, createWmlElement(doc, W.tblLayout, { 'w:type': table.layout ?? 'fixed' }));
53
+ appendInOrder(tblPr, props, TBLPR_ORDER);
54
+ return tblPr;
55
+ }
56
+ /**
57
+ * @conformance ECMA-376 edition 5, Part 1 § 17.4.16
58
+ */
59
+ function buildTblGrid(doc, table) {
60
+ const tblGrid = createWmlElement(doc, W.tblGrid);
61
+ for (const width of table.columnWidthsTwips) {
62
+ tblGrid.appendChild(createWmlElement(doc, W.gridCol, { 'w:w': String(width) }));
63
+ }
64
+ return tblGrid;
65
+ }
66
+ /**
67
+ * @conformance ECMA-376 edition 5, Part 1 § 17.4.78
68
+ * @conformance ECMA-376 edition 5, Part 1 § 17.4.80
69
+ * @conformance ECMA-376 edition 5, Part 1 § 17.4.49
70
+ */
71
+ function buildRow(doc, table, row, ctx) {
72
+ const tr = createWmlElement(doc, W.tr);
73
+ const props = new Map();
74
+ if (row.heightTwips !== undefined) {
75
+ props.set(W.trHeight, createWmlElement(doc, W.trHeight, {
76
+ 'w:val': String(row.heightTwips),
77
+ 'w:hRule': row.heightRule ?? 'atLeast',
78
+ }));
79
+ }
80
+ if (row.header) {
81
+ props.set(W.tblHeader, createWmlElement(doc, W.tblHeader));
82
+ }
83
+ if (props.size > 0) {
84
+ const trPr = createWmlElement(doc, W.trPr);
85
+ appendInOrder(trPr, props, TRPR_ORDER);
86
+ tr.appendChild(trPr);
87
+ }
88
+ let gridOffset = 0;
89
+ for (const cell of row.cells) {
90
+ const span = cell.gridSpan ?? 1;
91
+ tr.appendChild(buildCell(doc, table, cell, gridOffset, ctx));
92
+ gridOffset += span;
93
+ }
94
+ return tr;
95
+ }
96
+ /**
97
+ * Cell properties in TCPR_ORDER, then cell content. An unspecified width
98
+ * falls back to the sum of the spanned grid columns; a vertical-merge
99
+ * continuation is the bare element form Word itself writes.
100
+ *
101
+ * @conformance ECMA-376 edition 5, Part 1 § 17.4.65
102
+ * @conformance ECMA-376 edition 5, Part 1 § 17.4.69
103
+ * @conformance ECMA-376 edition 5, Part 1 § 17.4.71
104
+ * @conformance ECMA-376 edition 5, Part 1 § 17.4.17
105
+ * @conformance ECMA-376 edition 5, Part 1 § 17.4.84
106
+ * @conformance ECMA-376 edition 5, Part 1 § 17.4.32
107
+ * @conformance ECMA-376 edition 5, Part 1 § 17.4.83
108
+ * @conformance ECMA-376 edition 5, Part 1 § 17.4.68
109
+ */
110
+ function buildCell(doc, table, cell, gridOffset, ctx) {
111
+ const tc = createWmlElement(doc, W.tc);
112
+ const tcPr = createWmlElement(doc, W.tcPr);
113
+ const props = new Map();
114
+ const span = cell.gridSpan ?? 1;
115
+ const width = cell.widthTwips ?? table.columnWidthsTwips.slice(gridOffset, gridOffset + span).reduce((sum, w) => sum + w, 0);
116
+ props.set(W.tcW, createWmlElement(doc, W.tcW, { 'w:w': String(width), 'w:type': 'dxa' }));
117
+ if (cell.gridSpan !== undefined && cell.gridSpan > 1) {
118
+ props.set(W.gridSpan, createWmlElement(doc, W.gridSpan, { 'w:val': String(cell.gridSpan) }));
119
+ }
120
+ if (cell.vMerge !== undefined) {
121
+ props.set(W.vMerge, cell.vMerge === 'restart' ? createWmlElement(doc, W.vMerge, { 'w:val': 'restart' }) : createWmlElement(doc, W.vMerge));
122
+ }
123
+ if (cell.borders) {
124
+ props.set(W.tcBorders, buildBordersElement(doc, W.tcBorders, cell.borders));
125
+ }
126
+ if (cell.shadingHex !== undefined) {
127
+ props.set(W.shd, createWmlElement(doc, W.shd, { 'w:val': 'clear', 'w:color': 'auto', 'w:fill': cell.shadingHex }));
128
+ }
129
+ if (cell.marginsTwips) {
130
+ props.set(W.tcMar, buildCellMargins(doc, cell.marginsTwips));
131
+ }
132
+ if (cell.vAlign !== undefined) {
133
+ props.set(W.vAlign, createWmlElement(doc, W.vAlign, { 'w:val': cell.vAlign }));
134
+ }
135
+ appendInOrder(tcPr, props, TCPR_ORDER);
136
+ tc.appendChild(tcPr);
137
+ for (const block of cell.blocks) {
138
+ tc.appendChild(buildBlock(doc, block, ctx));
139
+ }
140
+ // A cell must end with a paragraph: readers reject a cell that is empty or
141
+ // whose last block is a table.
142
+ const last = cell.blocks[cell.blocks.length - 1];
143
+ if (!last || last.kind === 'table') {
144
+ tc.appendChild(createWmlElement(doc, W.p));
145
+ }
146
+ return tc;
147
+ }
148
+ /** Dispatch a block-level spec node to its emitter (cells hold both kinds). */
149
+ export function buildBlock(doc, block, ctx) {
150
+ return block.kind === 'table' ? buildTable(doc, block, ctx) : buildParagraph(doc, block, ctx);
151
+ }
152
+ /**
153
+ * Border collection in CT_TblBorders / CT_TcBorders schema order. Every edge
154
+ * present in the spec is emitted with explicit size/space/color so readers
155
+ * don't fall back to divergent defaults.
156
+ *
157
+ * @conformance ECMA-376 edition 5, Part 1 § 17.4.66
158
+ */
159
+ function buildBordersElement(doc, localName, borders) {
160
+ const container = createWmlElement(doc, localName);
161
+ const edges = [
162
+ [W.top, borders.top],
163
+ [W.left, borders.left],
164
+ [W.bottom, borders.bottom],
165
+ [W.right, borders.right],
166
+ [W.insideH, borders.insideH],
167
+ [W.insideV, borders.insideV],
168
+ ];
169
+ for (const [edge, spec] of edges) {
170
+ if (!spec)
171
+ continue;
172
+ container.appendChild(createWmlElement(doc, edge, {
173
+ 'w:val': spec.style,
174
+ 'w:sz': String(spec.style === 'none' ? 0 : (spec.sizeEighthPt ?? 4)),
175
+ 'w:space': '0',
176
+ 'w:color': spec.colorHex ?? 'auto',
177
+ }));
178
+ }
179
+ return container;
180
+ }
181
+ function buildCellMargins(doc, margins) {
182
+ const tcMar = createWmlElement(doc, W.tcMar);
183
+ const edges = [
184
+ [W.top, margins.top],
185
+ [W.left, margins.left],
186
+ [W.bottom, margins.bottom],
187
+ [W.right, margins.right],
188
+ ];
189
+ for (const [edge, value] of edges) {
190
+ if (value === undefined)
191
+ continue;
192
+ tcMar.appendChild(createWmlElement(doc, edge, { 'w:w': String(value), 'w:type': 'dxa' }));
193
+ }
194
+ return tcMar;
195
+ }
196
+ //# sourceMappingURL=table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.js","sourceRoot":"","sources":["../../../src/generation/emit/table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,CAAC,EAAE,MAAM,gCAAgC,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGpF,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,GAAa,EAAE,KAAgB,EAAE,GAAsB;IAChF,MAAM,GAAG,GAAG,gBAAgB,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;IACzC,GAAG,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IACxC,GAAG,C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O,CAAC,GAAG,CAAC;QACpB,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC;QACtB,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC;QAC1B,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC;KACzB,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC;QAClC,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Typed errors for the generation compiler.
3
+ *
4
+ * GenerationSpecError reports problems in the caller's DocumentSpec (dangling
5
+ * references, unimplemented features, shape violations) with a JSON-pointer-ish
6
+ * path into the spec so callers can surface the exact offending node.
7
+ *
8
+ * GenerationInternalError flags compiler bugs (e.g. an emitter producing a
9
+ * property name missing from its ordering table); it should never be reachable
10
+ * from user input that passed spec validation.
11
+ */
12
+ export type GenerationSpecErrorCode = 'empty_sections' | 'unsupported_feature' | 'dangling_style_reference' | 'dangling_numbering_reference' | 'invalid_value' | 'grid_mismatch';
13
+ export declare class GenerationSpecError extends Error {
14
+ readonly code: GenerationSpecErrorCode;
15
+ /** Path into the spec, e.g. '/sections/0/blocks/2/runs/1'. */
16
+ readonly path: string;
17
+ constructor(code: GenerationSpecErrorCode, path: string, message: string);
18
+ }
19
+ export declare class GenerationInternalError extends Error {
20
+ constructor(message: string);
21
+ }
22
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/generation/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,MAAM,uBAAuB,GAC/B,gBAAgB,GAChB,qBAAqB,GACrB,0BAA0B,GAC1B,8BAA8B,GAC9B,eAAe,GACf,eAAe,CAAC;AAEpB,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,IAAI,EAAE,uBAAuB,CAAC;IACvC,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAMzE;AAED,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,OAAO,EAAE,MAAM;CAI5B"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Typed errors for the generation compiler.
3
+ *
4
+ * GenerationSpecError reports problems in the caller's DocumentSpec (dangling
5
+ * references, unimplemented features, shape violations) with a JSON-pointer-ish
6
+ * path into the spec so callers can surface the exact offending node.
7
+ *
8
+ * GenerationInternalError flags compiler bugs (e.g. an emitter producing a
9
+ * property name missing from its ordering table); it should never be reachable
10
+ * from user input that passed spec validation.
11
+ */
12
+ export class GenerationSpecError extends Error {
13
+ code;
14
+ /** Path into the spec, e.g. '/sections/0/blocks/2/runs/1'. */
15
+ path;
16
+ constructor(code, path, message) {
17
+ super(`${message} (at ${path})`);
18
+ this.name = 'GenerationSpecError';
19
+ this.code = code;
20
+ this.path = path;
21
+ }
22
+ }
23
+ export class GenerationInternalError extends Error {
24
+ constructor(message) {
25
+ super(message);
26
+ this.name = 'GenerationInternalError';
27
+ }
28
+ }
29
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/generation/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAUH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,IAAI,CAA0B;IACvC,8DAA8D;IACrD,IAAI,CAAS;IAEtB,YAAY,IAA6B,EAAE,IAAY,EAAE,OAAe;QACtE,KAAK,CAAC,GAAG,OAAO,QAAQ,IAAI,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * From-scratch DOCX generation (OpenSpec capability: docx-generation).
3
+ *
4
+ * Re-exported from the package root since the final phase of the
5
+ * add-docx-generation change, with the cross-reader compatibility matrix
6
+ * recorded in docs/generation-manual-compat-checklist.md.
7
+ */
8
+ export { generateDocx, type GenerateDocxOptions } from './compile.js';
9
+ export { GenerationSpecError, GenerationInternalError, type GenerationSpecErrorCode } from './errors.js';
10
+ export { checkGeneratedPackage, type StructuralCheckResult, type StructuralIssue } from './structural-checks.js';
11
+ export { coverTermsTable, signatureBlock, type CoverTermsOptions, type SignatureBlockOptions } from './recipes.js';
12
+ export type { BlockSpec, BorderSpec, BreakSpec, DocumentMetaSpec, DocumentSpec, DraftingNoteSpec, FieldSpec, HeaderFooterSet, HeaderFooterSpec, InlineSpec, NumberingSpec, ParagraphSpec, RunProps, RunSpec, SectionSpec, StyleSpec, TableBorders, TableCellSpec, TableRowSpec, TableSpec, TabSpec, } from './types.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generation/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,KAAK,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACzG,OAAO,EAAE,qBAAqB,EAAE,KAAK,qBAAqB,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACjH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,KAAK,iBAAiB,EAAE,KAAK,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACnH,YAAY,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,aAAa,EACb,QAAQ,EACR,OAAO,EACP,WAAW,EACX,SAAS,EACT,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,SAAS,EACT,OAAO,GACR,MAAM,YAAY,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * From-scratch DOCX generation (OpenSpec capability: docx-generation).
3
+ *
4
+ * Re-exported from the package root since the final phase of the
5
+ * add-docx-generation change, with the cross-reader compatibility matrix
6
+ * recorded in docs/generation-manual-compat-checklist.md.
7
+ */
8
+ export { generateDocx } from './compile.js';
9
+ export { GenerationSpecError, GenerationInternalError } from './errors.js';
10
+ export { checkGeneratedPackage } from './structural-checks.js';
11
+ export { coverTermsTable, signatureBlock } from './recipes.js';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generation/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAA4B,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAgC,MAAM,aAAa,CAAC;AACzG,OAAO,EAAE,qBAAqB,EAAoD,MAAM,wBAAwB,CAAC;AACjH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAsD,MAAM,cAAc,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Property-order discipline for emitted OOXML property containers.
3
+ *
4
+ * Each table lists the subset of child local names the generation emitters
5
+ * produce, in the relative order the WML schema sequence declares. Emitters
6
+ * never appendChild properties directly — they collect them into a map and
7
+ * call appendInOrder, which throws on any name missing from its table so
8
+ * adding a new property forces a conscious ordering decision.
9
+ */
10
+ /**
11
+ * Child order for w:pPr (CT_PPr). Subset actually emitted, in schema-relative
12
+ * order; w:rPr (paragraph-mark run properties) precedes w:sectPr at the end.
13
+ *
14
+ * @conformance ECMA-376 edition 5, Part 1 § 17.3.1.26
15
+ */
16
+ export declare const PPR_ORDER: readonly ["pStyle", "keepNext", "keepLines", "pageBreakBefore", "widowControl", "numPr", "pBdr", "shd", "tabs", "spacing", "ind", "contextualSpacing", "jc", "rPr", "sectPr"];
17
+ /**
18
+ * Child order for w:rPr (CT_RPr / EG_RPrBase). Subset actually emitted.
19
+ *
20
+ * @conformance ECMA-376 edition 5, Part 1 § 17.3.2.28
21
+ */
22
+ export declare const RPR_ORDER: readonly ["rStyle", "rFonts", "b", "bCs", "i", "iCs", "caps", "smallCaps", "strike", "vanish", "color", "sz", "szCs", "highlight", "u", "vertAlign"];
23
+ /** Child order for w:sectPr (CT_SectPr). Header/footer references lead. */
24
+ export declare const SECTPR_ORDER: readonly ["headerReference", "footerReference", "type", "pgSz", "pgMar", "pgNumType", "titlePg", "docGrid"];
25
+ /** Child order for w:tblPr (CT_TblPr). */
26
+ export declare const TBLPR_ORDER: readonly ["tblStyle", "tblW", "jc", "tblBorders", "tblLayout", "tblCellMar", "tblLook"];
27
+ /**
28
+ * Child order for w:trPr (CT_TrPrBase). Subset actually emitted.
29
+ *
30
+ * @conformance ECMA-376 edition 5, Part 1 § 17.4.81
31
+ */
32
+ export declare const TRPR_ORDER: readonly ["trHeight", "tblHeader"];
33
+ /** Child order for w:tcPr (CT_TcPr). */
34
+ export declare const TCPR_ORDER: readonly ["tcW", "gridSpan", "vMerge", "tcBorders", "shd", "tcMar", "vAlign"];
35
+ export type PropMap = ReadonlyMap<string, Element | Element[]>;
36
+ /**
37
+ * Append collected property elements to a container in the order declared by
38
+ * the table. Repeatable properties (e.g. w:headerReference) are passed as
39
+ * arrays and appended in collection order at their slot.
40
+ *
41
+ * Throws GenerationInternalError when the map contains a local name absent
42
+ * from the order table — ordering bugs fail loudly at build time instead of
43
+ * producing schema-invalid output.
44
+ */
45
+ export declare function appendInOrder(container: Element, props: PropMap, order: readonly string[]): void;
46
+ //# sourceMappingURL=ordering.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ordering.d.ts","sourceRoot":"","sources":["../../src/generation/ordering.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;;;GAKG;AACH,eAAO,MAAM,SAAS,+KAgBZ,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,SAAS,sJAiBZ,CAAC;AAEX,2EAA2E;AAC3E,eAAO,MAAM,YAAY,6GASf,CAAC;AAEX,0CAA0C;AAC1C,eAAO,MAAM,WAAW,yFAQd,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,UAAU,oCAAqC,CAAC;AAE7D,wCAAwC;AACxC,eAAO,MAAM,UAAU,+EAQb,CAAC;AAEX,MAAM,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,EAAE,CAAC,CAAC;AAE/D;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAehG"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Property-order discipline for emitted OOXML property containers.
3
+ *
4
+ * Each table lists the subset of child local names the generation emitters
5
+ * produce, in the relative order the WML schema sequence declares. Emitters
6
+ * never appendChild properties directly — they collect them into a map and
7
+ * call appendInOrder, which throws on any name missing from its table so
8
+ * adding a new property forces a conscious ordering decision.
9
+ */
10
+ import { GenerationInternalError } from './errors.js';
11
+ /**
12
+ * Child order for w:pPr (CT_PPr). Subset actually emitted, in schema-relative
13
+ * order; w:rPr (paragraph-mark run properties) precedes w:sectPr at the end.
14
+ *
15
+ * @conformance ECMA-376 edition 5, Part 1 § 17.3.1.26
16
+ */
17
+ export const PPR_ORDER = [
18
+ 'pStyle',
19
+ 'keepNext',
20
+ 'keepLines',
21
+ 'pageBreakBefore',
22
+ 'widowControl',
23
+ 'numPr',
24
+ 'pBdr',
25
+ 'shd',
26
+ 'tabs',
27
+ 'spacing',
28
+ 'ind',
29
+ 'contextualSpacing',
30
+ 'jc',
31
+ 'rPr',
32
+ 'sectPr',
33
+ ];
34
+ /**
35
+ * Child order for w:rPr (CT_RPr / EG_RPrBase). Subset actually emitted.
36
+ *
37
+ * @conformance ECMA-376 edition 5, Part 1 § 17.3.2.28
38
+ */
39
+ export const RPR_ORDER = [
40
+ 'rStyle',
41
+ 'rFonts',
42
+ 'b',
43
+ 'bCs',
44
+ 'i',
45
+ 'iCs',
46
+ 'caps',
47
+ 'smallCaps',
48
+ 'strike',
49
+ 'vanish',
50
+ 'color',
51
+ 'sz',
52
+ 'szCs',
53
+ 'highlight',
54
+ 'u',
55
+ 'vertAlign',
56
+ ];
57
+ /** Child order for w:sectPr (CT_SectPr). Header/footer references lead. */
58
+ export const SECTPR_ORDER = [
59
+ 'headerReference',
60
+ 'footerReference',
61
+ 'type',
62
+ 'pgSz',
63
+ 'pgMar',
64
+ 'pgNumType',
65
+ 'titlePg',
66
+ 'docGrid',
67
+ ];
68
+ /** Child order for w:tblPr (CT_TblPr). */
69
+ export const TBLPR_ORDER = [
70
+ 'tblStyle',
71
+ 'tblW',
72
+ 'jc',
73
+ 'tblBorders',
74
+ 'tblLayout',
75
+ 'tblCellMar',
76
+ 'tblLook',
77
+ ];
78
+ /**
79
+ * Child order for w:trPr (CT_TrPrBase). Subset actually emitted.
80
+ *
81
+ * @conformance ECMA-376 edition 5, Part 1 § 17.4.81
82
+ */
83
+ export const TRPR_ORDER = ['trHeight', 'tblHeader'];
84
+ /** Child order for w:tcPr (CT_TcPr). */
85
+ export const TCPR_ORDER = [
86
+ 'tcW',
87
+ 'gridSpan',
88
+ 'vMerge',
89
+ 'tcBorders',
90
+ 'shd',
91
+ 'tcMar',
92
+ 'vAlign',
93
+ ];
94
+ /**
95
+ * Append collected property elements to a container in the order declared by
96
+ * the table. Repeatable properties (e.g. w:headerReference) are passed as
97
+ * arrays and appended in collection order at their slot.
98
+ *
99
+ * Throws GenerationInternalError when the map contains a local name absent
100
+ * from the order table — ordering bugs fail loudly at build time instead of
101
+ * producing schema-invalid output.
102
+ */
103
+ export function appendInOrder(container, props, order) {
104
+ for (const name of props.keys()) {
105
+ if (!order.includes(name)) {
106
+ throw new GenerationInternalError(`Property '${name}' is not declared in the ordering table for <${container.tagName}>; ` +
107
+ 'add it to the table in schema order before emitting it');
108
+ }
109
+ }
110
+ for (const name of order) {
111
+ const value = props.get(name);
112
+ if (!value)
113
+ continue;
114
+ const elements = Array.isArray(value) ? value : [value];
115
+ for (const el of elements)
116
+ container.appendChild(el);
117
+ }
118
+ }
119
+ //# sourceMappingURL=ordering.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ordering.js","sourceRoot":"","sources":["../../src/generation/ordering.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,QAAQ;IACR,UAAU;IACV,WAAW;IACX,iBAAiB;IACjB,cAAc;IACd,OAAO;IACP,MAAM;IACN,KAAK;IACL,MAAM;IACN,SAAS;IACT,KAAK;IACL,mBAAmB;IACnB,IAAI;IACJ,KAAK;IACL,QAAQ;CACA,CAAC;AAEX;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,QAAQ;IACR,QAAQ;IACR,GAAG;IACH,KAAK;IACL,GAAG;IACH,KAAK;IACL,MAAM;IACN,WAAW;IACX,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,KAAK,CAAC,CAAC;QACxD,KAAK,MAAM,EAAE,IAAI,QAAQ;YAAE,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IACvD,CAAC;AACH,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Legal-document recipes.
3
+ *
4
+ * Pure functions producing spec nodes from options — no own OOXML
5
+ * representation, no compiler hooks. Everything a recipe returns is built
6
+ * from the paragraph/table grammar, so its output is inlineable anywhere a
7
+ * BlockSpec is accepted and serializes through exactly the emitters the
8
+ * rest of the document uses. Signature lines are bottom-bordered cells, not
9
+ * VML shapes: Pages and Google Docs mangle VML, borders survive everywhere.
10
+ */
11
+ import type { BlockSpec, TableSpec } from './types.js';
12
+ export type CoverTermsOptions = {
13
+ /** Label/value pairs, rendered one row each in declaration order. */
14
+ terms: Array<{
15
+ label: string;
16
+ value: string;
17
+ }>;
18
+ /** Two-column widths in twips; defaults to a 2880/6480 split of a 6.5" body. */
19
+ columnWidthsTwips?: [number, number];
20
+ /** Heading text for a shaded full-width header row; omitted when absent. */
21
+ title?: string;
22
+ };
23
+ /**
24
+ * A fixed-layout two-column label/value table for cover-terms blocks
25
+ * (scenario SDX-GEN-070).
26
+ */
27
+ export declare function coverTermsTable(options: CoverTermsOptions): TableSpec;
28
+ export type SignatureBlockOptions = {
29
+ parties: Array<{
30
+ /** Party heading above the signature line, e.g. the company name. */
31
+ party: string;
32
+ /** Signatory name printed under the line. */
33
+ name: string;
34
+ title?: string;
35
+ /** Label for the date row; defaults to 'Date:'. */
36
+ dateLabel?: string;
37
+ }>;
38
+ /** Signature-line column width in twips; defaults to 4320 (3"). */
39
+ lineWidthTwips?: number;
40
+ };
41
+ /**
42
+ * Signature blocks rendered as borderless single-column tables whose first
43
+ * content cell carries only a bottom border — the signature line — followed
44
+ * by name, title, and date rows (scenario SDX-GEN-071). No VML, no images.
45
+ */
46
+ export declare function signatureBlock(options: SignatureBlockOptions): BlockSpec[];
47
+ //# sourceMappingURL=recipes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipes.d.ts","sourceRoot":"","sources":["../../src/generation/recipes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAA6B,SAAS,EAAE,MAAM,YAAY,CAAC;AAIlF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,qEAAqE;IACrE,KAAK,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,gFAAgF;IAChF,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,SAAS,CA+BrE;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,KAAK,CAAC;QACb,qEAAqE;QACrE,KAAK,EAAE,MAAM,CAAC;QACd,6CAA6C;QAC7C,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,mDAAmD;QACnD,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;IACH,mEAAmE;IACnE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,SAAS,EAAE,CAsB1E"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Legal-document recipes.
3
+ *
4
+ * Pure functions producing spec nodes from options — no own OOXML
5
+ * representation, no compiler hooks. Everything a recipe returns is built
6
+ * from the paragraph/table grammar, so its output is inlineable anywhere a
7
+ * BlockSpec is accepted and serializes through exactly the emitters the
8
+ * rest of the document uses. Signature lines are bottom-bordered cells, not
9
+ * VML shapes: Pages and Google Docs mangle VML, borders survive everywhere.
10
+ */
11
+ const SINGLE = { style: 'single' };
12
+ /**
13
+ * A fixed-layout two-column label/value table for cover-terms blocks
14
+ * (scenario SDX-GEN-070).
15
+ */
16
+ export function coverTermsTable(options) {
17
+ const [labelWidth, valueWidth] = options.columnWidthsTwips ?? [2880, 6480];
18
+ const rows = [];
19
+ if (options.title !== undefined) {
20
+ rows.push({
21
+ header: true,
22
+ cells: [
23
+ {
24
+ gridSpan: 2,
25
+ shadingHex: 'D9D9D9',
26
+ vAlign: 'center',
27
+ blocks: [paragraph(options.title, { bold: true, alignment: 'center' })],
28
+ },
29
+ ],
30
+ });
31
+ }
32
+ for (const term of options.terms) {
33
+ rows.push({
34
+ cells: [
35
+ { blocks: [paragraph(term.label, { bold: true })] },
36
+ { blocks: [paragraph(term.value)] },
37
+ ],
38
+ });
39
+ }
40
+ return {
41
+ kind: 'table',
42
+ layout: 'fixed',
43
+ columnWidthsTwips: [labelWidth, valueWidth],
44
+ borders: { top: SINGLE, bottom: SINGLE, left: SINGLE, right: SINGLE, insideH: SINGLE, insideV: SINGLE },
45
+ rows,
46
+ };
47
+ }
48
+ /**
49
+ * Signature blocks rendered as borderless single-column tables whose first
50
+ * content cell carries only a bottom border — the signature line — followed
51
+ * by name, title, and date rows (scenario SDX-GEN-071). No VML, no images.
52
+ */
53
+ export function signatureBlock(options) {
54
+ const width = options.lineWidthTwips ?? 4320;
55
+ const blocks = [];
56
+ options.parties.forEach((party, index) => {
57
+ if (index > 0)
58
+ blocks.push(paragraph(''));
59
+ blocks.push(paragraph(party.party, { bold: true }));
60
+ const rows = [
61
+ { cells: [{ borders: { bottom: SINGLE }, blocks: [paragraph('')] }] },
62
+ { cells: [{ blocks: [paragraph(`Name: ${party.name}`)] }] },
63
+ ];
64
+ if (party.title !== undefined) {
65
+ rows.push({ cells: [{ blocks: [paragraph(`Title: ${party.title}`)] }] });
66
+ }
67
+ rows.push({ cells: [{ blocks: [paragraph(party.dateLabel ?? 'Date:')] }] });
68
+ blocks.push({
69
+ kind: 'table',
70
+ layout: 'fixed',
71
+ columnWidthsTwips: [width],
72
+ rows,
73
+ });
74
+ });
75
+ return blocks;
76
+ }
77
+ function paragraph(text, opts) {
78
+ return {
79
+ kind: 'paragraph',
80
+ ...(opts?.alignment !== undefined ? { alignment: opts.alignment } : {}),
81
+ runs: [{ kind: 'text', text, ...(opts?.bold ? { bold: true } : {}) }],
82
+ };
83
+ }
84
+ //# sourceMappingURL=recipes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipes.js","sourceRoot":"","sources":["../../src/generation/recipes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,MAAM,MAAM,GAAe,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AAW/C;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,OAA0B;IACxD,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,OAAO,CAAC,iBAAiB,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC3E,MAAM,IAAI,GAAsB,EAAE,CAAC;IACnC,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAChC,IAAI,CAAC,IAAI,CAAC;YACR,MAAM,EAAE,IAAI;YACZ,KAAK,EAAE;gBACL;oBACE,QAAQ,EAAE,CAAC;oBACX,UAAU,EAAE,QAAQ;oBACpB,MAAM,EAAE,QAAQ;oBAChB,MAAM,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC;iBACxE;aACF;SACF,CAAC,CAAC;IACL,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC,IAAI,CAAC;YACR,KAAK,EAAE;gBACL,EAAE,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CA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K,SAAS,EAAE,CAAC;YAC9B,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,SAAS,CAAC,UAAU,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAC3E,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAC5E,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,OAAO;YACf,iBAAiB,EAAE,CAAC,KAAK,CAAC;YAC1B,IAAI;SACL,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,SAAS,CAChB,IAAY,EACZ,IAAiE;IAEjE,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,GAAG,CAAC,IAAI,EAAE,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;KACtE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Post-build structural validation of a generated package — the
3
+ * "no recovery dialog" gate. Each check targets a concrete repair trigger in
4
+ * reading applications: missing content types, dangling relationship targets,
5
+ * unresolvable r:id references, malformed section properties, and unbalanced
6
+ * field characters.
7
+ *
8
+ * `auditSectPr` is reused as one component: it flags duplicated or misplaced
9
+ * body-level sectPr and dangling header/footer references, but tolerates the
10
+ * zero-sectPr case (legal for parsed third-party documents), so the
11
+ * required-final-sectPr check lives here.
12
+ */
13
+ export type StructuralIssue = {
14
+ check: 'xml_declaration' | 'content_type_coverage' | 'relationship_target' | 'rid_resolution' | 'sectpr' | 'field_pairing' | 'table';
15
+ part: string;
16
+ message: string;
17
+ };
18
+ export type StructuralCheckResult = {
19
+ ok: boolean;
20
+ issues: StructuralIssue[];
21
+ };
22
+ /** Run every structural check against a generated package buffer. */
23
+ export declare function checkGeneratedPackage(buffer: Buffer): Promise<StructuralCheckResult>;
24
+ //# sourceMappingURL=structural-checks.d.ts.map