@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,57 @@
1
+ /**
2
+ * Header and footer part emitters.
3
+ *
4
+ * Each declared header/footer slot (default / first / even) becomes its own
5
+ * part — word/headerN.xml or word/footerN.xml — registered with a
6
+ * content-type override and a relationship from the main document part. The
7
+ * block content reuses the same paragraph/run emitters as the body, so a
8
+ * footer's "Page X of Y" field compiles through exactly the same five-part
9
+ * field machinery.
10
+ *
11
+ * @conformance ECMA-376 edition 5, Part 1 § 17.10.4
12
+ */
13
+ import { OOXML } from '../../primitives/namespaces.js';
14
+ import { parseXml, serializeXml, XML_DECL } from '../../primitives/xml.js';
15
+ import { buildBlock } from './table.js';
16
+ const HEADER_CONTENT_TYPE = 'application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml';
17
+ const FOOTER_CONTENT_TYPE = 'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml';
18
+ const HEADER_REL_TYPE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/header';
19
+ const FOOTER_REL_TYPE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer';
20
+ const SLOT_ORDER = ['first', 'default', 'even'];
21
+ /**
22
+ * Allocate and emit every header/footer part, returning per-section
23
+ * reference maps for the sectPr emitter. Runs before the document part so
24
+ * relationship ids exist when sections bind their references.
25
+ */
26
+ export function emitHeaderFooterParts(spec, ctx, blockCtx) {
27
+ return spec.sections.map((section) => emitForSection(section, ctx, blockCtx));
28
+ }
29
+ function emitForSection(section, ctx, blockCtx) {
30
+ const refs = { headers: {}, footers: {} };
31
+ for (const slot of SLOT_ORDER) {
32
+ const header = section.headers?.[slot];
33
+ if (header) {
34
+ refs.headers[slot] = emitPart(header, ctx, 'header', blockCtx);
35
+ }
36
+ const footer = section.footers?.[slot];
37
+ if (footer) {
38
+ refs.footers[slot] = emitPart(footer, ctx, 'footer', blockCtx);
39
+ }
40
+ }
41
+ return refs;
42
+ }
43
+ /** @conformance ECMA-376 edition 5, Part 1 § 17.10.3 */
44
+ function emitPart(content, ctx, kind, blockCtx) {
45
+ const isHeader = kind === 'header';
46
+ const partName = isHeader ? ctx.allocateHeaderPartName() : ctx.allocateFooterPartName();
47
+ const part = ctx.registerPart(partName, isHeader ? HEADER_CONTENT_TYPE : FOOTER_CONTENT_TYPE, isHeader ? HEADER_REL_TYPE : FOOTER_REL_TYPE);
48
+ const rootTag = isHeader ? 'w:hdr' : 'w:ftr';
49
+ const doc = parseXml(`<${rootTag} xmlns:w="${OOXML.W_NS}" xmlns:r="${OOXML.R_NS}"/>`);
50
+ const root = doc.documentElement;
51
+ for (const block of content.blocks) {
52
+ root.appendChild(buildBlock(doc, block, blockCtx));
53
+ }
54
+ ctx.setFileContent(partName, XML_DECL + serializeXml(doc));
55
+ return part.documentRel.rId;
56
+ }
57
+ //# sourceMappingURL=header-footer-part.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"header-footer-part.js","sourceRoot":"","sources":["../../../src/generation/emit/header-footer-part.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAI3E,OAAO,EAAE,UAAU,EAAE,MAAM,YA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,EAAE,IAAyB,EAAE,QAA2B;IACtH,MAAM,QAAQ,GAAG,IAAI,KAAK,QAAQ,CAAC;IACnC,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,sBAAsB,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,sBAAsB,EAAE,CAAC;IACxF,MAAM,IAAI,GAAG,GAAG,CAAC,YAAY,CAC3B,QAAQ,EACR,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,mBAAmB,EACpD,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe,CAC7C,CAAC;IAEF,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IAC7C,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,OAAO,aAAa,KAAK,CAAC,IAAI,cAAc,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC;IACtF,MAAM,IAAI,GAAG,GAAG,CAAC,eAAgB,CAAC;IAClC,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,GAAG,CAAC,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3D,OAAO,IAAI,CAAC,WAAY,CAAC,GAAG,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * word/numbering.xml emitter.
3
+ *
4
+ * Each NumberingSpec compiles to one abstract definition plus one instance:
5
+ * the spec's string handle (`numId`) maps to sequential numeric ids assigned
6
+ * in declaration order, so identical specs always produce identical ids. The
7
+ * returned map is what lets paragraph `w:numPr` references bind to the
8
+ * numeric `w:numId` deterministically.
9
+ *
10
+ * Level children follow the CT_Lvl sequence (start, numFmt, suff, lvlText,
11
+ * lvlJc, pPr, rPr); level run properties reuse the shared rPr builder so a
12
+ * bullet glyph's font serializes exactly like body formatting would.
13
+ *
14
+ * @conformance ECMA-376 edition 5, Part 1 § 17.9.16
15
+ * @conformance ECMA-376 edition 5, Part 1 § 17.9.1
16
+ * @conformance ECMA-376 edition 5, Part 1 § 17.9.15
17
+ * @conformance ECMA-376 edition 5, Part 1 § 17.9.2
18
+ */
19
+ import type { CompileContext } from '../context.js';
20
+ import type { DocumentSpec } from '../types.js';
21
+ import type { NumberingIdMap } from './emit-context.js';
22
+ export declare const NUMBERING_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml";
23
+ export declare const NUMBERING_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering";
24
+ /**
25
+ * Emit word/numbering.xml when the spec declares numbering definitions.
26
+ * Returns the handle → numeric id map (empty when no part is emitted).
27
+ */
28
+ export declare function emitNumberingPartIfNeeded(spec: DocumentSpec, ctx: CompileContext): NumberingIdMap;
29
+ //# sourceMappingURL=numbering-part.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"numbering-part.d.ts","sourceRoot":"","sources":["../../../src/generation/emit/numbering-part.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGxD,eAAO,MAAM,sBAAsB,iFAC6C,CAAC;AACjF,eAAO,MAAM,kBAAkB,kFACkD,CAAC;AAIlF;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,cAAc,GAAG,cAAc,CAyBjG"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * word/numbering.xml emitter.
3
+ *
4
+ * Each NumberingSpec compiles to one abstract definition plus one instance:
5
+ * the spec's string handle (`numId`) maps to sequential numeric ids assigned
6
+ * in declaration order, so identical specs always produce identical ids. The
7
+ * returned map is what lets paragraph `w:numPr` references bind to the
8
+ * numeric `w:numId` deterministically.
9
+ *
10
+ * Level children follow the CT_Lvl sequence (start, numFmt, suff, lvlText,
11
+ * lvlJc, pPr, rPr); level run properties reuse the shared rPr builder so a
12
+ * bullet glyph's font serializes exactly like body formatting would.
13
+ *
14
+ * @conformance ECMA-376 edition 5, Part 1 § 17.9.16
15
+ * @conformance ECMA-376 edition 5, Part 1 § 17.9.1
16
+ * @conformance ECMA-376 edition 5, Part 1 § 17.9.15
17
+ * @conformance ECMA-376 edition 5, Part 1 § 17.9.2
18
+ */
19
+ import { createWmlElement } from '../../primitives/dom-helpers.js';
20
+ import { OOXML, W } from '../../primitives/namespaces.js';
21
+ import { parseXml, serializeXml, XML_DECL } from '../../primitives/xml.js';
22
+ import { buildRunPropsElement } from './properties.js';
23
+ export const NUMBERING_CONTENT_TYPE = 'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml';
24
+ export const NUMBERING_REL_TYPE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering';
25
+ const NUMBERING_SKELETON = `<w:numbering xmlns:w="${OOXML.W_NS}"/>`;
26
+ /**
27
+ * Emit word/numbering.xml when the spec declares numbering definitions.
28
+ * Returns the handle → numeric id map (empty when no part is emitted).
29
+ */
30
+ export function emitNumberingPartIfNeeded(spec, ctx) {
31
+ const ids = new Map();
32
+ const definitions = spec.numbering ?? [];
33
+ if (definitions.length === 0)
34
+ return ids;
35
+ ctx.registerPart('word/numbering.xml', NUMBERING_CONTENT_TYPE, NUMBERING_REL_TYPE);
36
+ const doc = parseXml(NUMBERING_SKELETON);
37
+ const root = doc.documentElement;
38
+ definitions.forEach((definition, index) => {
39
+ ids.set(definition.numId, index + 1);
40
+ });
41
+ // CT_Numbering sequence: every abstractNum precedes every num.
42
+ definitions.forEach((definition, index) => {
43
+ root.appendChild(buildAbstractNum(doc, definition, index));
44
+ });
45
+ definitions.forEach((_definition, index) => {
46
+ const num = createWmlElement(doc, W.num, { 'w:numId': String(index + 1) });
47
+ num.appendChild(createWmlElement(doc, W.abstractNumId, { 'w:val': String(index) }));
48
+ root.appendChild(num);
49
+ });
50
+ ctx.setFileContent('word/numbering.xml', XML_DECL + serializeXml(doc));
51
+ return ids;
52
+ }
53
+ /**
54
+ * @conformance ECMA-376 edition 5, Part 1 § 17.9.12
55
+ * @conformance ECMA-376 edition 5, Part 1 § 17.9.6
56
+ */
57
+ function buildAbstractNum(doc, definition, abstractId) {
58
+ const abstractNum = createWmlElement(doc, W.abstractNum, { 'w:abstractNumId': String(abstractId) });
59
+ abstractNum.appendChild(createWmlElement(doc, W.multiLevelType, {
60
+ 'w:val': definition.levels.length > 1 ? 'multilevel' : 'singleLevel',
61
+ }));
62
+ for (const level of definition.levels) {
63
+ abstractNum.appendChild(buildLevel(doc, level));
64
+ }
65
+ return abstractNum;
66
+ }
67
+ /**
68
+ * @conformance ECMA-376 edition 5, Part 1 § 17.9.25
69
+ * @conformance ECMA-376 edition 5, Part 1 § 17.9.17
70
+ * @conformance ECMA-376 edition 5, Part 1 § 17.9.28
71
+ * @conformance ECMA-376 edition 5, Part 1 § 17.9.11
72
+ * @conformance ECMA-376 edition 5, Part 1 § 17.9.7
73
+ */
74
+ function buildLevel(doc, level) {
75
+ const lvl = createWmlElement(doc, W.lvl, { 'w:ilvl': String(level.ilvl) });
76
+ lvl.appendChild(createWmlElement(doc, W.start, { 'w:val': String(level.start ?? 1) }));
77
+ lvl.appendChild(createWmlElement(doc, W.numFmt, { 'w:val': level.numFmt }));
78
+ if (level.suff !== undefined) {
79
+ lvl.appendChild(createWmlElement(doc, W.suff, { 'w:val': level.suff }));
80
+ }
81
+ lvl.appendChild(createWmlElement(doc, W.lvlText, { 'w:val': level.lvlText }));
82
+ lvl.appendChild(createWmlElement(doc, W.lvlJc, { 'w:val': 'left' }));
83
+ if (level.indentTwips !== undefined) {
84
+ const pPr = createWmlElement(doc, W.pPr);
85
+ const attrs = {};
86
+ if (level.indentTwips.left !== undefined)
87
+ attrs['w:left'] = String(level.indentTwips.left);
88
+ if (level.indentTwips.hanging !== undefined)
89
+ attrs['w:hanging'] = String(level.indentTwips.hanging);
90
+ pPr.appendChild(createWmlElement(doc, W.ind, attrs));
91
+ lvl.appendChild(pPr);
92
+ }
93
+ if (level.runProps !== undefined) {
94
+ const rPr = buildRunPropsElement(doc, level.runProps);
95
+ if (rPr)
96
+ lvl.appendChild(rPr);
97
+ }
98
+ return lvl;
99
+ }
100
+ //# sourceMappingURL=numbering-part.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"numbering-part.js","sourceRoot":"","sources":["../../../src/generation/emit/numbering-part.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAI3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,CAAC,MAAM,sBAAsB,GACjC,8EAA8E,CAAC;AACjF,MAAM,CAAC,MAAM,kBAAkB,GAC7B,+EAA+E,CAAC;AAElF,MAAM,kBAAkB,GAAG,yBAAyB,KAAK,CAAC,IAAI,KAAK,CAAC;AAEpE;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,IAAkB,EAAE,GAAmB;IAC/E,MAAM,GAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;IACtC,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;IACzC,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IAEzC,GAA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AAW,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAC9E,GAAG,CAAC,WAAW,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IACrE,IAAI,KAAK,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QACpC,MAAM,GAAG,GAAG,gBAAgB,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;QACzC,MAAM,KAAK,GAA2B,EAAE,CAAC;QACzC,IAAI,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,SAAS;YAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAC3F,IAAI,KAAK,CAAC,WAAW,CAAC,OAAO,KAAK,SAAS;YAAE,KAAK,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACpG,GAAG,CAAC,WAAW,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;QACrD,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IACD,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QACjC,MAAM,GAAG,GAAG,oBAAoB,CAAC,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;QACtD,IAAI,GAAG;YAAE,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * OPC package plumbing: [Content_Types].xml, package/part relationships, and
3
+ * document properties. Built with the same skeleton-parse + namespace-aware
4
+ * DOM approach as the WML parts — no string concatenation of dynamic values.
5
+ *
6
+ * docProps/core.xml dates come exclusively from the spec (meta.createdIso);
7
+ * generation never reads the clock, keeping output byte-deterministic.
8
+ */
9
+ import type { CompileContext } from '../context.js';
10
+ import type { DocumentSpec } from '../types.js';
11
+ export declare const CONTENT_TYPES: {
12
+ readonly document: "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml";
13
+ readonly coreProps: "application/vnd.openxmlformats-package.core-properties+xml";
14
+ readonly extendedProps: "application/vnd.openxmlformats-officedocument.extended-properties+xml";
15
+ readonly relationships: "application/vnd.openxmlformats-package.relationships+xml";
16
+ };
17
+ export declare const REL_TYPES: {
18
+ readonly officeDocument: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument";
19
+ readonly coreProps: "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
20
+ readonly extendedProps: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties";
21
+ };
22
+ /** Emit every package-plumbing part into the context's file map. */
23
+ export declare function emitPackageParts(spec: DocumentSpec, ctx: CompileContext): void;
24
+ //# sourceMappingURL=package-parts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-parts.d.ts","sourceRoot":"","sources":["../../../src/generation/emit/package-parts.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,aAAa;;;;;CAKhB,CAAC;AAEX,eAAO,MAAM,SAAS;;;;CAIZ,CAAC;AAWX,oEAAoE;AACpE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI,CAM9E"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * OPC package plumbing: [Content_Types].xml, package/part relationships, and
3
+ * document properties. Built with the same skeleton-parse + namespace-aware
4
+ * DOM approach as the WML parts — no string concatenation of dynamic values.
5
+ *
6
+ * docProps/core.xml dates come exclusively from the spec (meta.createdIso);
7
+ * generation never reads the clock, keeping output byte-deterministic.
8
+ */
9
+ import { OOXML } from '../../primitives/namespaces.js';
10
+ import { parseXml, serializeXml, XML_DECL } from '../../primitives/xml.js';
11
+ export const CONTENT_TYPES = {
12
+ document: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml',
13
+ coreProps: 'application/vnd.openxmlformats-package.core-properties+xml',
14
+ extendedProps: 'application/vnd.openxmlformats-officedocument.extended-properties+xml',
15
+ relationships: 'application/vnd.openxmlformats-package.relationships+xml',
16
+ };
17
+ export const REL_TYPES = {
18
+ officeDocument: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument',
19
+ coreProps: 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
20
+ extendedProps: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties',
21
+ };
22
+ const CORE_PROPS_NS = {
23
+ cp: 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties',
24
+ dc: 'http://purl.org/dc/elements/1.1/',
25
+ dcterms: 'http://purl.org/dc/terms/',
26
+ xsi: 'http://www.w3.org/2001/XMLSchema-instance',
27
+ };
28
+ const EXTENDED_PROPS_NS = 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties';
29
+ /** Emit every package-plumbing part into the context's file map. */
30
+ export function emitPackageParts(spec, ctx) {
31
+ ctx.setFileContent('docProps/core.xml', emitCoreProps(spec));
32
+ ctx.setFileContent('docProps/app.xml', emitAppProps());
33
+ ctx.setFileContent('_rels/.rels', emitPackageRels());
34
+ ctx.setFileContent('word/_rels/document.xml.rels', emitDocumentRels(ctx));
35
+ ctx.setFileContent('[Content_Types].xml', emitContentTypes(ctx));
36
+ }
37
+ function emitContentTypes(ctx) {
38
+ const doc = parseXml(`<Types xmlns="${OOXML.CT_NS}"/>`);
39
+ const root = doc.documentElement;
40
+ const addDefault = (extension, contentType) => {
41
+ const el = doc.createElementNS(OOXML.CT_NS, 'Default');
42
+ el.setAttribute('Extension', extension);
43
+ el.setAttribute('ContentType', contentType);
44
+ root.appendChild(el);
45
+ };
46
+ const addOverride = (partName, contentType) => {
47
+ const el = doc.createElementNS(OOXML.CT_NS, 'Override');
48
+ el.setAttribute('PartName', partName);
49
+ el.setAttribute('ContentType', contentType);
50
+ root.appendChild(el);
51
+ };
52
+ addDefault('rels', CONTENT_TYPES.relationships);
53
+ addDefault('xml', 'application/xml');
54
+ addOverride('/word/document.xml', CONTENT_TYPES.document);
55
+ addOverride('/docProps/core.xml', CONTENT_TYPES.coreProps);
56
+ addOverride('/docProps/app.xml', CONTENT_TYPES.extendedProps);
57
+ for (const part of ctx.registeredParts()) {
58
+ addOverride(`/${part.name}`, part.contentType);
59
+ }
60
+ return XML_DECL + serializeXml(doc);
61
+ }
62
+ function emitPackageRels() {
63
+ const doc = parseXml(`<Relationships xmlns="${OOXML.REL_NS}"/>`);
64
+ const root = doc.documentElement;
65
+ const add = (id, type, target) => {
66
+ const el = doc.createElementNS(OOXML.REL_NS, 'Relationship');
67
+ el.setAttribute('Id', id);
68
+ el.setAttribute('Type', type);
69
+ el.setAttribute('Target', target);
70
+ root.appendChild(el);
71
+ };
72
+ add('rId1', REL_TYPES.officeDocument, 'word/document.xml');
73
+ add('rId2', REL_TYPES.coreProps, 'docProps/core.xml');
74
+ add('rId3', REL_TYPES.extendedProps, 'docProps/app.xml');
75
+ return XML_DECL + serializeXml(doc);
76
+ }
77
+ function emitDocumentRels(ctx) {
78
+ const doc = parseXml(`<Relationships xmlns="${OOXML.REL_NS}"/>`);
79
+ const root = doc.documentElement;
80
+ for (const part of ctx.documentRelParts()) {
81
+ const el = doc.createElementNS(OOXML.REL_NS, 'Relationship');
82
+ el.setAttribute('Id', part.documentRel.rId);
83
+ el.setAttribute('Type', part.documentRel.type);
84
+ // Targets are resolved relative to word/, the directory owning document.xml.
85
+ el.setAttribute('Target', part.name.replace(/^word\//, ''));
86
+ root.appendChild(el);
87
+ }
88
+ return XML_DECL + serializeXml(doc);
89
+ }
90
+ function emitCoreProps(spec) {
91
+ const doc = parseXml(`<cp:coreProperties xmlns:cp="${CORE_PROPS_NS.cp}" xmlns:dc="${CORE_PROPS_NS.dc}"` +
92
+ ` xmlns:dcterms="${CORE_PROPS_NS.dcterms}" xmlns:xsi="${CORE_PROPS_NS.xsi}"/>`);
93
+ const root = doc.documentElement;
94
+ const meta = spec.meta;
95
+ const addText = (ns, qname, text, attrs) => {
96
+ const el = doc.createElementNS(ns, qname);
97
+ if (attrs)
98
+ for (const [k, v] of Object.entries(attrs))
99
+ el.setAttribute(k, v);
100
+ el.appendChild(doc.createTextNode(text));
101
+ root.appendChild(el);
102
+ };
103
+ if (meta?.title)
104
+ addText(CORE_PROPS_NS.dc, 'dc:title', meta.title);
105
+ if (meta?.author)
106
+ addText(CORE_PROPS_NS.dc, 'dc:creator', meta.author);
107
+ if (meta?.createdIso) {
108
+ addText(CORE_PROPS_NS.dcterms, 'dcterms:created', meta.createdIso, { 'xsi:type': 'dcterms:W3CDTF' });
109
+ addText(CORE_PROPS_NS.dcterms, 'dcterms:modified', meta.createdIso, { 'xsi:type': 'dcterms:W3CDTF' });
110
+ }
111
+ return XML_DECL + serializeXml(doc);
112
+ }
113
+ function emitAppProps() {
114
+ const doc = parseXml(`<Properties xmlns="${EXTENDED_PROPS_NS}"/>`);
115
+ const root = doc.documentElement;
116
+ const app = doc.createElementNS(EXTENDED_PROPS_NS, 'Application');
117
+ app.appendChild(doc.createTextNode('safe-docx'));
118
+ root.appendChild(app);
119
+ return XML_DECL + serializeXml(doc);
120
+ }
121
+ //# sourceMappingURL=package-parts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-parts.js","sourceRoot":"","sources":["../../../src/generation/emit/package-parts.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACv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AO,CAAC,aAAa,CAAC,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACvE,IAAI,IAAI,EAAE,UAAU,EAAE,CAAC;QACrB,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,iBAAiB,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC,CAAC;QACrG,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,kBAAkB,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC,CAAC;IACxG,CAAC;IAED,OAAO,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;AACtC,CAAC;AAED,SAAS,YAAY;IACnB,MAAM,GAAG,GAAG,QAAQ,CAAC,sBAAsB,iBAAiB,KAAK,CAAC,CAAC;IACnE,MAAM,IAAI,GAAG,GAAG,CAAC,eAAgB,CAAC;IAClC,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;IAClE,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC;IACjD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACtB,OAAO,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;AACtC,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Paragraph emitter.
3
+ *
4
+ * Shipped: paragraphs with style references and direct formatting
5
+ * (alignment, spacing, indentation, tabs, keepNext, pageBreakBefore), all
6
+ * routed through the shared pPr builder and PPR_ORDER. The section-break
7
+ * injection hook (a pPr-only sectPr) arrives with the multi-section phase.
8
+ */
9
+ import type { ParagraphSpec } from '../types.js';
10
+ import type { BlockEmitContext } from './emit-context.js';
11
+ /**
12
+ * List paragraphs reference their numbering definition through w:numPr
13
+ * (w:ilvl then w:numId, per CT_NumPr); the numeric id comes from the
14
+ * numbering part's deterministic handle map.
15
+ *
16
+ * @conformance ECMA-376 edition 5, Part 1 § 17.3.1.19
17
+ * @conformance ECMA-376 edition 5, Part 1 § 17.9.3
18
+ * @conformance ECMA-376 edition 5, Part 1 § 17.9.18
19
+ * @conformance ECMA-376 edition 5, Part 1 § 17.13.4.4
20
+ * @conformance ECMA-376 edition 5, Part 1 § 17.13.4.3
21
+ * @conformance ECMA-376 edition 5, Part 1 § 17.13.4.5
22
+ */
23
+ export declare function buildParagraph(doc: Document, paragraph: ParagraphSpec, ctx?: BlockEmitContext): Element;
24
+ //# sourceMappingURL=paragraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paragraph.d.ts","sourceRoot":"","sources":["../../../src/generation/emit/paragraph.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAI1D;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAsCvG"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Paragraph emitter.
3
+ *
4
+ * Shipped: paragraphs with style references and direct formatting
5
+ * (alignment, spacing, indentation, tabs, keepNext, pageBreakBefore), all
6
+ * routed through the shared pPr builder and PPR_ORDER. The section-break
7
+ * injection hook (a pPr-only sectPr) arrives with the multi-section phase.
8
+ */
9
+ import { createWmlElement } from '../../primitives/dom-helpers.js';
10
+ import { W } from '../../primitives/namespaces.js';
11
+ import { GenerationInternalError } from '../errors.js';
12
+ import { buildParagraphPropsElement } from './properties.js';
13
+ import { buildInlineRuns } from './run.js';
14
+ /**
15
+ * List paragraphs reference their numbering definition through w:numPr
16
+ * (w:ilvl then w:numId, per CT_NumPr); the numeric id comes from the
17
+ * numbering part's deterministic handle map.
18
+ *
19
+ * @conformance ECMA-376 edition 5, Part 1 § 17.3.1.19
20
+ * @conformance ECMA-376 edition 5, Part 1 § 17.9.3
21
+ * @conformance ECMA-376 edition 5, Part 1 § 17.9.18
22
+ * @conformance ECMA-376 edition 5, Part 1 § 17.13.4.4
23
+ * @conformance ECMA-376 edition 5, Part 1 § 17.13.4.3
24
+ * @conformance ECMA-376 edition 5, Part 1 § 17.13.4.5
25
+ */
26
+ export function buildParagraph(doc, paragraph, ctx) {
27
+ const p = createWmlElement(doc, W.p);
28
+ let extras;
29
+ if (paragraph.list !== undefined) {
30
+ const numericId = ctx?.numberingIds?.get(paragraph.list.numId);
31
+ if (numericId === undefined) {
32
+ throw new GenerationInternalError(`List paragraph references numbering handle '${paragraph.list.numId}' with no allocated numeric id`);
33
+ }
34
+ const numPr = createWmlElement(doc, W.numPr);
35
+ numPr.appendChild(createWmlElement(doc, W.ilvl, { 'w:val': String(paragraph.list.ilvl) }));
36
+ numPr.appendChild(createWmlElement(doc, W.numId, { 'w:val': String(numericId) }));
37
+ extras = new Map([[W.numPr, numPr]]);
38
+ }
39
+ const pPr = buildParagraphPropsElement(doc, paragraph, extras);
40
+ if (pPr)
41
+ p.appendChild(pPr);
42
+ // Drafting-note anchors: range markers bracket the paragraph's content and
43
+ // the reference run trails it (§ 17.13.4.4 / .3 / .5). Absent a collector
44
+ // (notes disabled, or a story that cannot carry them) the paragraph
45
+ // serializes without any trace of the note.
46
+ const noteId = paragraph.note !== undefined && ctx?.notes ? ctx.notes.allocate(paragraph.note) : undefined;
47
+ if (noteId !== undefined) {
48
+ p.appendChild(createWmlElement(doc, W.commentRangeStart, { 'w:id': String(noteId) }));
49
+ }
50
+ for (const inline of paragraph.runs) {
51
+ for (const run of buildInlineRuns(doc, inline)) {
52
+ p.appendChild(run);
53
+ }
54
+ }
55
+ if (noteId !== undefined) {
56
+ p.appendChild(createWmlElement(doc, W.commentRangeEnd, { 'w:id': String(noteId) }));
57
+ const referenceRun = createWmlElement(doc, W.r);
58
+ referenceRun.appendChild(createWmlElement(doc, W.commentReference, { 'w:id': String(noteId) }));
59
+ p.appendChild(referenceRun);
60
+ }
61
+ return p;
62
+ }
63
+ //# sourceMappingURL=paragraph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paragraph.js","sourceRoot":"","sources":["../../../src/generation/emit/paragraph.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,CAAC,EAAE,MAAM,gCAAgC,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAGvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,GAAa,EAAE,SAAwB,EAAE,GAAsB;IAC5F,MAAM,CAAC,GAAG,gBAAgB,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC,IAAI,MAAwC,CAAC;IAC7C,IAAI,SAAS,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACjC,MAAM,SAAS,GAAG,GAAG,EAAE,YAAY,EAAE,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/D,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,uBAAuB,CAC/B,+CAA+C,SAAS,CAAC,IAAI,CAAC,KAAK,gCAAgC,CACpG,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,GAAG,gBAAgB,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;QAC7C,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,C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AM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QACpF,MAAM,YAAY,GAAG,gBAAgB,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAChD,YAAY,CAAC,WAAW,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC,CAAC,gBAAgB,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QAChG,CAAC,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Shared property builders: RunProps → w:rPr and paragraph formatting → w:pPr
3
+ * child maps, used by both the body emitters (run.ts / paragraph.ts) and the
4
+ * styles-part emitter so direct formatting and style definitions can never
5
+ * drift apart. All children are routed through the ordering tables.
6
+ */
7
+ import type { ParagraphSpec, RunProps, StyleSpec } from '../types.js';
8
+ /** Paragraph-formatting subset shared by ParagraphSpec and StyleSpec.paragraph. */
9
+ export type ParagraphProps = Pick<ParagraphSpec, 'alignment' | 'spacing' | 'indent' | 'tabs' | 'pageBreakBefore' | 'keepNext'> & {
10
+ styleId?: string;
11
+ };
12
+ /**
13
+ * Build the ordered rPr children for a RunProps value. Returns null when no
14
+ * property is set so callers can omit the rPr container entirely.
15
+ *
16
+ * Complex-script twins (bCs/iCs/szCs) and the full rFonts script coverage
17
+ * (ascii + hAnsi + cs) are always emitted alongside their base properties so
18
+ * all script ranges agree.
19
+ *
20
+ * @conformance ECMA-376 edition 5, Part 1 § 17.3.2.28
21
+ */
22
+ export declare function buildRunPropsElement(doc: Document, props: RunProps): Element | null;
23
+ /**
24
+ * Build the ordered pPr children for a paragraph-formatting subset. Returns
25
+ * null when nothing is set. The optional extras hook lets phase-specific
26
+ * callers add already-built children (e.g. a section break sectPr) that
27
+ * still go through the same ordering discipline.
28
+ *
29
+ * @conformance ECMA-376 edition 5, Part 1 § 17.3.1.26
30
+ */
31
+ export declare function buildParagraphPropsElement(doc: Document, props: ParagraphProps, extras?: ReadonlyMap<string, Element | Element[]>): Element | null;
32
+ /** Paragraph-formatting subset of a StyleSpec, normalized for the builder. */
33
+ export declare function styleParagraphProps(style: StyleSpec): ParagraphProps;
34
+ //# sourceMappingURL=properties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"properties.d.ts","sourceRoot":"","sources":["../../../src/generation/emit/properties.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEtE,mFAAmF;AACnF,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,aAAa,EACb,WAAW,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,iBAAiB,GAAG,UAAU,CAC7E,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AASzB;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI,CAwCnF;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,cAAc,EACrB,MAAM,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,EAAE,CAAC,GAChD,OAAO,GAAG,IAAI,CAkDhB;AAED,8EAA8E;AAC9E,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,GAAG,cAAc,CAEpE"}