@usejunior/docx-core 0.10.0 → 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 (232) 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 +13 -7
  6. package/dist/atomizer.d.ts.map +1 -1
  7. package/dist/atomizer.js +59 -24
  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 +120 -27
  15. package/dist/baselines/atomizer/documentReconstructor.js.map +1 -1
  16. package/dist/baselines/atomizer/inPlaceModifier-wrappers.d.ts +9 -0
  17. package/dist/baselines/atomizer/inPlaceModifier-wrappers.d.ts.map +1 -1
  18. package/dist/baselines/atomizer/inPlaceModifier-wrappers.js +52 -4
  19. package/dist/baselines/atomizer/inPlaceModifier-wrappers.js.map +1 -1
  20. package/dist/baselines/atomizer/pipeline.d.ts +12 -53
  21. package/dist/baselines/atomizer/pipeline.d.ts.map +1 -1
  22. package/dist/baselines/atomizer/pipeline.js +126 -231
  23. package/dist/baselines/atomizer/pipeline.js.map +1 -1
  24. package/dist/baselines/atomizer/trackChangesAcceptorAst.d.ts.map +1 -1
  25. package/dist/baselines/atomizer/trackChangesAcceptorAst.js +153 -23
  26. package/dist/baselines/atomizer/trackChangesAcceptorAst.js.map +1 -1
  27. package/dist/baselines/wmlcomparer/DotnetCli.d.ts.map +1 -1
  28. package/dist/baselines/wmlcomparer/DotnetCli.js +7 -0
  29. package/dist/baselines/wmlcomparer/DotnetCli.js.map +1 -1
  30. package/dist/cli/compare-two.d.ts.map +1 -1
  31. package/dist/cli/compare-two.js +3 -1
  32. package/dist/cli/compare-two.js.map +1 -1
  33. package/dist/cli/conformance-adapter.d.ts +3 -0
  34. package/dist/cli/conformance-adapter.d.ts.map +1 -0
  35. package/dist/cli/conformance-adapter.js +93 -0
  36. package/dist/cli/conformance-adapter.js.map +1 -0
  37. package/dist/cli/index.d.ts.map +1 -1
  38. package/dist/cli/index.js +5 -1
  39. package/dist/cli/index.js.map +1 -1
  40. package/dist/compare-types.d.ts +46 -0
  41. package/dist/compare-types.d.ts.map +1 -1
  42. package/dist/generation/compile.d.ts +21 -0
  43. package/dist/generation/compile.d.ts.map +1 -0
  44. package/dist/generation/compile.js +46 -0
  45. package/dist/generation/compile.js.map +1 -0
  46. package/dist/generation/context.d.ts +42 -0
  47. package/dist/generation/context.d.ts.map +1 -0
  48. package/dist/generation/context.js +65 -0
  49. package/dist/generation/context.js.map +1 -0
  50. package/dist/generation/emit/comments-part.d.ts +36 -0
  51. package/dist/generation/emit/comments-part.d.ts.map +1 -0
  52. package/dist/generation/emit/comments-part.js +116 -0
  53. package/dist/generation/emit/comments-part.js.map +1 -0
  54. package/dist/generation/emit/document-part.d.ts +24 -0
  55. package/dist/generation/emit/document-part.d.ts.map +1 -0
  56. package/dist/generation/emit/document-part.js +60 -0
  57. package/dist/generation/emit/document-part.js.map +1 -0
  58. package/dist/generation/emit/emit-context.d.ts +26 -0
  59. package/dist/generation/emit/emit-context.d.ts.map +1 -0
  60. package/dist/generation/emit/emit-context.js +19 -0
  61. package/dist/generation/emit/emit-context.js.map +1 -0
  62. package/dist/generation/emit/header-footer-part.d.ts +23 -0
  63. package/dist/generation/emit/header-footer-part.d.ts.map +1 -0
  64. package/dist/generation/emit/header-footer-part.js +57 -0
  65. package/dist/generation/emit/header-footer-part.js.map +1 -0
  66. package/dist/generation/emit/numbering-part.d.ts +29 -0
  67. package/dist/generation/emit/numbering-part.d.ts.map +1 -0
  68. package/dist/generation/emit/numbering-part.js +100 -0
  69. package/dist/generation/emit/numbering-part.js.map +1 -0
  70. package/dist/generation/emit/package-parts.d.ts +24 -0
  71. package/dist/generation/emit/package-parts.d.ts.map +1 -0
  72. package/dist/generation/emit/package-parts.js +121 -0
  73. package/dist/generation/emit/package-parts.js.map +1 -0
  74. package/dist/generation/emit/paragraph.d.ts +24 -0
  75. package/dist/generation/emit/paragraph.d.ts.map +1 -0
  76. package/dist/generation/emit/paragraph.js +63 -0
  77. package/dist/generation/emit/paragraph.js.map +1 -0
  78. package/dist/generation/emit/properties.d.ts +34 -0
  79. package/dist/generation/emit/properties.d.ts.map +1 -0
  80. package/dist/generation/emit/properties.js +138 -0
  81. package/dist/generation/emit/properties.js.map +1 -0
  82. package/dist/generation/emit/run.d.ts +15 -0
  83. package/dist/generation/emit/run.d.ts.map +1 -0
  84. package/dist/generation/emit/run.js +71 -0
  85. package/dist/generation/emit/run.js.map +1 -0
  86. package/dist/generation/emit/section.d.ts +29 -0
  87. package/dist/generation/emit/section.d.ts.map +1 -0
  88. package/dist/generation/emit/section.js +117 -0
  89. package/dist/generation/emit/section.js.map +1 -0
  90. package/dist/generation/emit/settings-part.d.ts +13 -0
  91. package/dist/generation/emit/settings-part.d.ts.map +1 -0
  92. package/dist/generation/emit/settings-part.js +24 -0
  93. package/dist/generation/emit/settings-part.js.map +1 -0
  94. package/dist/generation/emit/styles-part.d.ts +16 -0
  95. package/dist/generation/emit/styles-part.d.ts.map +1 -0
  96. package/dist/generation/emit/styles-part.js +80 -0
  97. package/dist/generation/emit/styles-part.js.map +1 -0
  98. package/dist/generation/emit/table.d.ts +26 -0
  99. package/dist/generation/emit/table.d.ts.map +1 -0
  100. package/dist/generation/emit/table.js +196 -0
  101. package/dist/generation/emit/table.js.map +1 -0
  102. package/dist/generation/errors.d.ts +22 -0
  103. package/dist/generation/errors.d.ts.map +1 -0
  104. package/dist/generation/errors.js +29 -0
  105. package/dist/generation/errors.js.map +1 -0
  106. package/dist/generation/index.d.ts +13 -0
  107. package/dist/generation/index.d.ts.map +1 -0
  108. package/dist/generation/index.js +12 -0
  109. package/dist/generation/index.js.map +1 -0
  110. package/dist/generation/ordering.d.ts +46 -0
  111. package/dist/generation/ordering.d.ts.map +1 -0
  112. package/dist/generation/ordering.js +119 -0
  113. package/dist/generation/ordering.js.map +1 -0
  114. package/dist/generation/recipes.d.ts +47 -0
  115. package/dist/generation/recipes.d.ts.map +1 -0
  116. package/dist/generation/recipes.js +84 -0
  117. package/dist/generation/recipes.js.map +1 -0
  118. package/dist/generation/structural-checks.d.ts +24 -0
  119. package/dist/generation/structural-checks.d.ts.map +1 -0
  120. package/dist/generation/structural-checks.js +318 -0
  121. package/dist/generation/structural-checks.js.map +1 -0
  122. package/dist/generation/types.d.ts +217 -0
  123. package/dist/generation/types.d.ts.map +1 -0
  124. package/dist/generation/types.js +16 -0
  125. package/dist/generation/types.js.map +1 -0
  126. package/dist/generation/validate-spec.d.ts +27 -0
  127. package/dist/generation/validate-spec.d.ts.map +1 -0
  128. package/dist/generation/validate-spec.js +307 -0
  129. package/dist/generation/validate-spec.js.map +1 -0
  130. package/dist/index.d.ts +3 -0
  131. package/dist/index.d.ts.map +1 -1
  132. package/dist/index.js +8 -0
  133. package/dist/index.js.map +1 -1
  134. package/dist/integration/generation-probes.d.ts +15 -0
  135. package/dist/integration/generation-probes.d.ts.map +1 -0
  136. package/dist/integration/generation-probes.js +84 -0
  137. package/dist/integration/generation-probes.js.map +1 -0
  138. package/dist/integration/libreoffice-oracle.d.ts +8 -0
  139. package/dist/integration/libreoffice-oracle.d.ts.map +1 -1
  140. package/dist/integration/libreoffice-oracle.js +14 -6
  141. package/dist/integration/libreoffice-oracle.js.map +1 -1
  142. package/dist/integration/synthetic-docx-fixture.d.ts +72 -0
  143. package/dist/integration/synthetic-docx-fixture.d.ts.map +1 -1
  144. package/dist/integration/synthetic-docx-fixture.js +131 -4
  145. package/dist/integration/synthetic-docx-fixture.js.map +1 -1
  146. package/dist/primitives/accept_changes.d.ts +2 -1
  147. package/dist/primitives/accept_changes.d.ts.map +1 -1
  148. package/dist/primitives/accept_changes.js +153 -12
  149. package/dist/primitives/accept_changes.js.map +1 -1
  150. package/dist/primitives/document.d.ts +38 -0
  151. package/dist/primitives/document.d.ts.map +1 -1
  152. package/dist/primitives/document.js +75 -9
  153. package/dist/primitives/document.js.map +1 -1
  154. package/dist/primitives/document_view-comments.d.ts.map +1 -1
  155. package/dist/primitives/document_view-comments.js +4 -3
  156. package/dist/primitives/document_view-comments.js.map +1 -1
  157. package/dist/primitives/document_view-types.d.ts +15 -0
  158. package/dist/primitives/document_view-types.d.ts.map +1 -1
  159. package/dist/primitives/document_view.d.ts.map +1 -1
  160. package/dist/primitives/document_view.js +21 -13
  161. package/dist/primitives/document_view.js.map +1 -1
  162. package/dist/primitives/formatting_tags.d.ts +1 -0
  163. package/dist/primitives/formatting_tags.d.ts.map +1 -1
  164. package/dist/primitives/formatting_tags.js +16 -10
  165. package/dist/primitives/formatting_tags.js.map +1 -1
  166. package/dist/primitives/index.d.ts +4 -0
  167. package/dist/primitives/index.d.ts.map +1 -1
  168. package/dist/primitives/index.js +4 -0
  169. package/dist/primitives/index.js.map +1 -1
  170. package/dist/primitives/layout.d.ts.map +1 -1
  171. package/dist/primitives/layout.js +13 -0
  172. package/dist/primitives/layout.js.map +1 -1
  173. package/dist/primitives/minimal_save.d.ts +38 -0
  174. package/dist/primitives/minimal_save.d.ts.map +1 -0
  175. package/dist/primitives/minimal_save.js +323 -0
  176. package/dist/primitives/minimal_save.js.map +1 -0
  177. package/dist/primitives/namespaces.d.ts +41 -0
  178. package/dist/primitives/namespaces.d.ts.map +1 -1
  179. package/dist/primitives/namespaces.js +43 -0
  180. package/dist/primitives/namespaces.js.map +1 -1
  181. package/dist/primitives/reject_changes.d.ts +4 -2
  182. package/dist/primitives/reject_changes.d.ts.map +1 -1
  183. package/dist/primitives/reject_changes.js +177 -24
  184. package/dist/primitives/reject_changes.js.map +1 -1
  185. package/dist/primitives/revision-parts.d.ts +7 -0
  186. package/dist/primitives/revision-parts.d.ts.map +1 -0
  187. package/dist/primitives/revision-parts.js +27 -0
  188. package/dist/primitives/revision-parts.js.map +1 -0
  189. package/dist/primitives/revision-vocabulary.d.ts +7 -0
  190. package/dist/primitives/revision-vocabulary.d.ts.map +1 -0
  191. package/dist/primitives/revision-vocabulary.js +39 -0
  192. package/dist/primitives/revision-vocabulary.js.map +1 -0
  193. package/dist/primitives/schema-corpus-capture.d.ts +19 -0
  194. package/dist/primitives/schema-corpus-capture.d.ts.map +1 -0
  195. package/dist/primitives/schema-corpus-capture.js +29 -0
  196. package/dist/primitives/schema-corpus-capture.js.map +1 -0
  197. package/dist/primitives/sectPrAudit.d.ts +19 -0
  198. package/dist/primitives/sectPrAudit.d.ts.map +1 -0
  199. package/dist/primitives/sectPrAudit.js +165 -0
  200. package/dist/primitives/sectPrAudit.js.map +1 -0
  201. package/dist/primitives/semantic_tags.d.ts.map +1 -1
  202. package/dist/primitives/semantic_tags.js +2 -1
  203. package/dist/primitives/semantic_tags.js.map +1 -1
  204. package/dist/primitives/serialize_html.d.ts +1 -0
  205. package/dist/primitives/serialize_html.d.ts.map +1 -1
  206. package/dist/primitives/serialize_html.js +4 -2
  207. package/dist/primitives/serialize_html.js.map +1 -1
  208. package/dist/primitives/styles.d.ts +15 -0
  209. package/dist/primitives/styles.d.ts.map +1 -1
  210. package/dist/primitives/styles.js +11 -0
  211. package/dist/primitives/styles.js.map +1 -1
  212. package/dist/primitives/track-changes-emitter.d.ts +9 -0
  213. package/dist/primitives/track-changes-emitter.d.ts.map +1 -1
  214. package/dist/primitives/track-changes-emitter.js +54 -4
  215. package/dist/primitives/track-changes-emitter.js.map +1 -1
  216. package/dist/primitives/validate_ai_revisions.d.ts +35 -0
  217. package/dist/primitives/validate_ai_revisions.d.ts.map +1 -0
  218. package/dist/primitives/validate_ai_revisions.js +323 -0
  219. package/dist/primitives/validate_ai_revisions.js.map +1 -0
  220. package/dist/primitives/xml.d.ts +5 -0
  221. package/dist/primitives/xml.d.ts.map +1 -1
  222. package/dist/primitives/xml.js +5 -0
  223. package/dist/primitives/xml.js.map +1 -1
  224. package/dist/primitives/zip.d.ts +1 -0
  225. package/dist/primitives/zip.d.ts.map +1 -1
  226. package/dist/primitives/zip.js +21 -3
  227. package/dist/primitives/zip.js.map +1 -1
  228. package/dist/shared/field-structure.d.ts +14 -0
  229. package/dist/shared/field-structure.d.ts.map +1 -0
  230. package/dist/shared/field-structure.js +166 -0
  231. package/dist/shared/field-structure.js.map +1 -0
  232. package/package.json +7 -4
@@ -0,0 +1,60 @@
1
+ /**
2
+ * word/document.xml emitter.
3
+ *
4
+ * Builds the main document part from a namespace-declaring skeleton: the
5
+ * skeleton string carries every namespace the part uses on the root element,
6
+ * and all children are created through the namespace-safe DOM helpers.
7
+ * xmldom's serializer omits the XML declaration, so it is prepended here;
8
+ * the structural validator asserts every part starts with one.
9
+ */
10
+ import { createWmlElement } from '../../primitives/dom-helpers.js';
11
+ import { OOXML, W } from '../../primitives/namespaces.js';
12
+ import { parseXml, serializeXml, XML_DECL } from '../../primitives/xml.js';
13
+ import { GenerationInternalError } from '../errors.js';
14
+ import { buildSectPr } from './section.js';
15
+ import { buildBlock } from './table.js';
16
+ const DOCUMENT_SKELETON = `<w:document xmlns:w="${OOXML.W_NS}" xmlns:r="${OOXML.R_NS}" xmlns:w14="${OOXML.W14_NS}">` +
17
+ `<w:body/></w:document>`;
18
+ /**
19
+ * Compile the body: each section's blocks in order. Every non-final section
20
+ * ends with a dedicated break paragraph whose pPr contains only that
21
+ * section's sectPr (what Word itself emits on Insert → Section Break; it
22
+ * also sidesteps the trailing-table case), and the final section's
23
+ * properties bind as the body's last child.
24
+ *
25
+ * @conformance ECMA-376 edition 5, Part 1 § 17.6.18
26
+ * @conformance ECMA-376 edition 5, Part 1 § 17.6.17
27
+ */
28
+ export function emitDocumentPart(spec, refs, ctx) {
29
+ const doc = parseXml(DOCUMENT_SKELETON);
30
+ const body = doc.getElementsByTagName('w:body').item(0);
31
+ if (!body)
32
+ throw new GenerationInternalError('document skeleton lost its w:body');
33
+ spec.sections.forEach((section, index) => {
34
+ for (const block of section.blocks) {
35
+ body.appendChild(buildBlock(doc, block, ctx));
36
+ }
37
+ const sectPr = buildSectPr(doc, section, refs?.[index]);
38
+ const isFinal = index === spec.sections.length - 1;
39
+ if (isFinal) {
40
+ // The body must not end with a table (readers treat it as truncated);
41
+ // a final trailing table gets a closing empty paragraph before the
42
+ // body-level sectPr binds. Non-final sections already end with their
43
+ // dedicated break paragraph.
44
+ const lastBlock = section.blocks[section.blocks.length - 1];
45
+ if (lastBlock && lastBlock.kind === 'table') {
46
+ body.appendChild(createWmlElement(doc, W.p));
47
+ }
48
+ body.appendChild(sectPr);
49
+ }
50
+ else {
51
+ const breakParagraph = createWmlElement(doc, W.p);
52
+ const pPr = createWmlElement(doc, W.pPr);
53
+ pPr.appendChild(sectPr);
54
+ breakParagraph.appendChild(pPr);
55
+ body.appendChild(breakParagraph);
56
+ }
57
+ });
58
+ return XML_DECL + serializeXml(doc);
59
+ }
60
+ //# sourceMappingURL=document-part.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-part.js","sourceRoot":"","sources":["../../../src/generation/emit/document-part.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;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;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAGvD,OAAO,EAAE,WAAW,EAAgC,MAAM,cAAc,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,iBAAiB,GACrB,wBAAwB,KAAK,CAAC,IAAI,cAAc,KAAK,C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C3B,CAAC;aAAM,CAAC;YACN,MAAM,cAAc,GAAG,gBAAgB,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAClD,MAAM,GAAG,GAAG,gBAAgB,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;YACzC,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YACxB,cAAc,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YAChC,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;AACtC,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Shared state the block emitters thread through paragraph/table recursion.
3
+ *
4
+ * Bundling it in one object keeps emitter signatures stable as features
5
+ * land: numbering binds spec handles to numeric ids, and the drafting-note
6
+ * collector allocates comment ids in document order (absent in stories that
7
+ * cannot carry notes, e.g. headers/footers, and when notes are disabled).
8
+ */
9
+ import type { DraftingNoteSpec } from '../types.js';
10
+ /** Spec-level numbering handle → numeric w:numId value. */
11
+ export type NumberingIdMap = ReadonlyMap<string, number>;
12
+ /** Allocates deterministic comment ids and records notes in document order. */
13
+ export declare class DraftingNoteCollector {
14
+ readonly collected: Array<{
15
+ id: number;
16
+ note: DraftingNoteSpec;
17
+ }>;
18
+ private nextId;
19
+ allocate(note: DraftingNoteSpec): number;
20
+ }
21
+ export type BlockEmitContext = {
22
+ numberingIds?: NumberingIdMap;
23
+ /** Present only where drafting notes may anchor (body story, notes enabled). */
24
+ notes?: DraftingNoteCollector;
25
+ };
26
+ //# sourceMappingURL=emit-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit-context.d.ts","sourceRoot":"","sources":["../../../src/generation/emit/emit-context.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,2DAA2D;AAC3D,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEzD,+EAA+E;AAC/E,qBAAa,qBAAqB;IAChC,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,gBAAgB,CAAA;KAAE,CAAC,CAAM;IACvE,OAAO,CAAC,MAAM,CAAK;IAEnB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM;CAKzC;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,YAAY,CAAC,EAAE,cAAc,CAAC;IAC9B,gFAAgF;IAChF,KAAK,CAAC,EAAE,qBAAqB,CAAC;CAC/B,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Shared state the block emitters thread through paragraph/table recursion.
3
+ *
4
+ * Bundling it in one object keeps emitter signatures stable as features
5
+ * land: numbering binds spec handles to numeric ids, and the drafting-note
6
+ * collector allocates comment ids in document order (absent in stories that
7
+ * cannot carry notes, e.g. headers/footers, and when notes are disabled).
8
+ */
9
+ /** Allocates deterministic comment ids and records notes in document order. */
10
+ export class DraftingNoteCollector {
11
+ collected = [];
12
+ nextId = 1;
13
+ allocate(note) {
14
+ const id = this.nextId++;
15
+ this.collected.push({ id, note });
16
+ return id;
17
+ }
18
+ }
19
+ //# sourceMappingURL=emit-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit-context.js","sourceRoot":"","sources":["../../../src/generation/emit/emit-context.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,+EAA+E;AAC/E,MAAM,OAAO,qBAAqB;IACvB,SAAS,GAAkD,EAAE,CAAC;IAC/D,MAAM,GAAG,CAAC,CAAC;IAEnB,QAAQ,CAAC,IAAsB;QAC7B,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QACzB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QAClC,OAAO,EAAE,CAAC;IACZ,CAAC;CACF"}
@@ -0,0 +1,23 @@
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 type { CompileContext } from '../context.js';
14
+ import type { DocumentSpec } from '../types.js';
15
+ import type { BlockEmitContext } from './emit-context.js';
16
+ import type { SectionHeaderFooterRefs } from './section.js';
17
+ /**
18
+ * Allocate and emit every header/footer part, returning per-section
19
+ * reference maps for the sectPr emitter. Runs before the document part so
20
+ * relationship ids exist when sections bind their references.
21
+ */
22
+ export declare function emitHeaderFooterParts(spec: DocumentSpec, ctx: CompileContext, blockCtx?: BlockEmitContext): SectionHeaderFooterRefs[];
23
+ //# sourceMappingURL=header-footer-part.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"header-footer-part.d.ts","sourceRoot":"","sources":["../../../src/generation/emit/header-footer-part.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAiC,MAAM,aAAa,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAS5D;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,gBAAgB,GAAG,uBAAuB,EAAE,CAErI"}
@@ -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,YAAY,CAAC;AAGxC,MAAM,mBAAmB,GAAG,2EAA2E,CAAC;AACxG,MAAM,mBAAmB,GAAG,2EAA2E,CAAC;AACxG,MAAM,eAAe,GAAG,4EAA4E,CAAC;AACrG,MAAM,eAAe,GAAG,4EAA4E,CAAC;AAErG,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAU,CAAC;AAEzD;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAkB,EAAE,GAAmB,EAAE,QAA2B;IACxG,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,CA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C,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":"num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AAI,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;AACvD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAI3E,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,QAAQ,EAAE,kFAAkF;IAC5F,SAAS,EAAE,4DAA4D;IACvE,aAAa,EAAE,uEAAuE;IACtF,aAAa,EAAE,0DAA0D;CACjE,CAAC;AAEX,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,cAAc,EAAE,oFAAoF;IACpG,SAAS,EAAE,uFAAuF;IAClG,aAAa,EAAE,yFAAyF;CAChG,CAAC;AAEX,MAAM,aAAa,GAAG;IACpB,EAAE,EAAE,yEAAyE;IAC7E,EAAE,EAAE,kCAAkC;IACtC,OAAO,EAAE,2BAA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Y;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;A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