@office-open/docx 0.9.0 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/{context-Ca7nmKV2.mjs → context-CERMOUn0.mjs} +2231 -1714
- package/dist/context-CERMOUn0.mjs.map +1 -0
- package/dist/{core-properties-B3ztqzLD.d.mts → core-properties-Bh8_D5Kh.d.mts} +906 -871
- package/dist/core-properties-Bh8_D5Kh.d.mts.map +1 -0
- package/dist/{document-CWr8C_OX.mjs → document-CeM-U6J3.mjs} +68 -8
- package/dist/document-CeM-U6J3.mjs.map +1 -0
- package/dist/{generate-m1Cw7CHL.mjs → generate-DiDgl0bc.mjs} +3 -3
- package/dist/{generate-m1Cw7CHL.mjs.map → generate-DiDgl0bc.mjs.map} +1 -1
- package/dist/generate.d.mts +1 -1
- package/dist/generate.mjs +1 -1
- package/dist/index.d.mts +6 -37
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/dist/{parse-D9ujyKBr.mjs → parse-BIJM6_8Y.mjs} +42 -61
- package/dist/parse-BIJM6_8Y.mjs.map +1 -0
- package/dist/parse.d.mts +1 -1
- package/dist/parse.mjs +1 -1
- package/dist/patch/index.d.mts +4 -4
- package/dist/patch/index.d.mts.map +1 -1
- package/dist/patch/index.mjs +2 -2
- package/dist/patch/index.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/context-Ca7nmKV2.mjs.map +0 -1
- package/dist/core-properties-B3ztqzLD.d.mts.map +0 -1
- package/dist/document-CWr8C_OX.mjs.map +0 -1
- package/dist/parse-D9ujyKBr.mjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { E as tableDesc, T as setTableParseChild, t as parseSectionPropertiesEl } from "./document-
|
|
3
|
-
import { parseArchive,
|
|
4
|
-
import { attr,
|
|
1
|
+
import { A as footnotesDesc, B as settingsDesc, C as fontTableDesc, H as buildNumberingCache, I as parseToc, K as parseNumberingDefinitions, M as parseParagraphProperties, O as parseSdtBlock, S as bibliographyDesc, U as buildStyleCache, W as parseStyleDefinitions, _ as commentsDesc, c as corePropertiesDesc, f as setBodyParseChild, g as contentTypesDesc, j as parseParagraph, k as endnotesDesc, o as webSettingsDesc, s as customPropertiesDesc, t as DocxReadContext, x as glossaryDesc } from "./context-CERMOUn0.mjs";
|
|
2
|
+
import { E as tableDesc, T as setTableParseChild, t as parseSectionPropertiesEl } from "./document-CeM-U6J3.mjs";
|
|
3
|
+
import { parseArchive, toUint8Array } from "@office-open/core";
|
|
4
|
+
import { attr, findChild, stringify } from "@office-open/xml";
|
|
5
5
|
//#region src/parts/alt-chunk/alt-chunk-parse.ts
|
|
6
6
|
/**
|
|
7
7
|
* AltChunk parser for DOCX documents.
|
|
@@ -179,7 +179,7 @@ function findDeep$1(parent, name) {
|
|
|
179
179
|
* @module
|
|
180
180
|
*/
|
|
181
181
|
/**
|
|
182
|
-
* Parse w:sectPr element into
|
|
182
|
+
* Parse w:sectPr element into SectionPropertiesOptions.
|
|
183
183
|
* Delegates to the section properties descriptor's parse method.
|
|
184
184
|
*/
|
|
185
185
|
function parseSectionProperties(el, ctx) {
|
|
@@ -269,6 +269,7 @@ function findDeepElement(parent, name) {
|
|
|
269
269
|
* Previous w:sectPr elements appear inside w:pPr elements.
|
|
270
270
|
*/
|
|
271
271
|
function parseBody(body, ctx) {
|
|
272
|
+
setBodyParseChild(parseSectionChild);
|
|
272
273
|
const bodyChildren = [];
|
|
273
274
|
const boundaries = [];
|
|
274
275
|
for (const child of body.elements ?? []) if (child.name === "w:sectPr") boundaries.push({
|
|
@@ -357,6 +358,8 @@ function parseDocPartRefs(doc) {
|
|
|
357
358
|
else if (type.includes("/image") || type.includes("/media")) refs.media.set(id, path);
|
|
358
359
|
else if (type.includes("/aFChunk")) refs.afChunks.set(id, path);
|
|
359
360
|
else if (type.includes("/subDocument")) refs.subDocs.set(id, path);
|
|
361
|
+
else if (type.includes("/bibliography")) refs.bibliography = path;
|
|
362
|
+
else if (type.includes("/glossaryDocument")) refs.glossary = path;
|
|
360
363
|
else if (type.includes("/hyperlink")) refs.hyperlinks.set(id, target);
|
|
361
364
|
}
|
|
362
365
|
return refs;
|
|
@@ -397,6 +400,7 @@ function parseDocument(data) {
|
|
|
397
400
|
const docx = parseDocx(data);
|
|
398
401
|
const ctx = new DocxReadContext(docx, buildStyleCache(docx.styles), buildNumberingCache(docx.numbering));
|
|
399
402
|
setTableParseChild(parseSectionChild);
|
|
403
|
+
setBodyParseChild(parseSectionChild);
|
|
400
404
|
const opts = { sections: parseBody(docx.body, ctx) };
|
|
401
405
|
if (docx.background) {
|
|
402
406
|
const bg = {};
|
|
@@ -407,14 +411,14 @@ function parseDocument(data) {
|
|
|
407
411
|
if (docx.coreProps) {
|
|
408
412
|
const corePropsEl = docx.doc.get(docx.coreProps);
|
|
409
413
|
if (corePropsEl) {
|
|
410
|
-
const cp =
|
|
414
|
+
const cp = corePropertiesDesc.parse(corePropsEl, ctx);
|
|
411
415
|
if (cp.title) opts.title = cp.title;
|
|
412
416
|
if (cp.subject) opts.subject = cp.subject;
|
|
413
417
|
if (cp.creator) opts.creator = cp.creator;
|
|
414
418
|
if (cp.keywords) opts.keywords = cp.keywords;
|
|
415
419
|
if (cp.description) opts.description = cp.description;
|
|
416
420
|
if (cp.lastModifiedBy) opts.lastModifiedBy = cp.lastModifiedBy;
|
|
417
|
-
if (cp.revision) opts.revision =
|
|
421
|
+
if (cp.revision) opts.revision = cp.revision;
|
|
418
422
|
}
|
|
419
423
|
}
|
|
420
424
|
if (docx.settings) Object.assign(opts, settingsDesc.parse(docx.settings, ctx));
|
|
@@ -432,25 +436,25 @@ function parseDocument(data) {
|
|
|
432
436
|
if (docx.partRefs.comments) {
|
|
433
437
|
const commentsEl = docx.doc.get(docx.partRefs.comments);
|
|
434
438
|
if (commentsEl) {
|
|
435
|
-
const
|
|
436
|
-
if (
|
|
439
|
+
const children = commentsDesc.parse(commentsEl, ctx).children;
|
|
440
|
+
if (children && children.length > 0) opts.comments = { children };
|
|
437
441
|
}
|
|
438
442
|
}
|
|
439
443
|
if (docx.partRefs.footnotes) {
|
|
440
444
|
const footnotesEl = docx.doc.get(docx.partRefs.footnotes);
|
|
441
445
|
if (footnotesEl) {
|
|
442
|
-
const
|
|
446
|
+
const fnResult = footnotesDesc.parse(footnotesEl, ctx);
|
|
443
447
|
const footnotesMap = {};
|
|
444
|
-
for (const
|
|
448
|
+
for (const [id, paragraphs] of fnResult.notes) footnotesMap[String(id)] = { children: paragraphs };
|
|
445
449
|
if (Object.keys(footnotesMap).length > 0) opts.footnotes = footnotesMap;
|
|
446
450
|
}
|
|
447
451
|
}
|
|
448
452
|
if (docx.partRefs.endnotes) {
|
|
449
453
|
const endnotesEl = docx.doc.get(docx.partRefs.endnotes);
|
|
450
454
|
if (endnotesEl) {
|
|
451
|
-
const
|
|
455
|
+
const enResult = endnotesDesc.parse(endnotesEl, ctx);
|
|
452
456
|
const endnotesMap = {};
|
|
453
|
-
for (const
|
|
457
|
+
for (const [id, paragraphs] of enResult.notes) endnotesMap[String(id)] = { children: paragraphs };
|
|
454
458
|
if (Object.keys(endnotesMap).length > 0) opts.endnotes = endnotesMap;
|
|
455
459
|
}
|
|
456
460
|
}
|
|
@@ -462,6 +466,28 @@ function parseDocument(data) {
|
|
|
462
466
|
const numOpts = parseNumberingDefinitions(docx.numbering);
|
|
463
467
|
if (numOpts) opts.numbering = numOpts;
|
|
464
468
|
}
|
|
469
|
+
if (docx.fontTable) {
|
|
470
|
+
const ftResult = fontTableDesc.parse(docx.fontTable, ctx);
|
|
471
|
+
if (ftResult.fonts && ftResult.fonts.length > 0) opts.fonts = ftResult.fonts;
|
|
472
|
+
}
|
|
473
|
+
if (docx.partRefs.bibliography) {
|
|
474
|
+
const bibEl = docx.doc.get(docx.partRefs.bibliography);
|
|
475
|
+
if (bibEl) {
|
|
476
|
+
const bibResult = bibliographyDesc.parse(bibEl, ctx);
|
|
477
|
+
if (bibResult.sources && bibResult.sources.length > 0) opts.bibliography = bibResult;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
if (docx.partRefs.glossary) {
|
|
481
|
+
const glossaryEl = docx.doc.get(docx.partRefs.glossary);
|
|
482
|
+
if (glossaryEl) {
|
|
483
|
+
const glossaryResult = glossaryDesc.parse(glossaryEl, ctx);
|
|
484
|
+
if (glossaryResult.parts && glossaryResult.parts.length > 0) opts.glossary = glossaryResult;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
if (docx.contentTypes) {
|
|
488
|
+
const ctResult = contentTypesDesc.parse(docx.contentTypes, ctx);
|
|
489
|
+
if (ctResult) opts.contentTypes = ctResult;
|
|
490
|
+
}
|
|
465
491
|
return opts;
|
|
466
492
|
}
|
|
467
493
|
function parseDocx(data) {
|
|
@@ -490,56 +516,11 @@ function parseDocx(data) {
|
|
|
490
516
|
partRefs,
|
|
491
517
|
coreProps,
|
|
492
518
|
appProps,
|
|
493
|
-
customProps
|
|
519
|
+
customProps,
|
|
520
|
+
contentTypes: doc.get("[Content_Types].xml")
|
|
494
521
|
};
|
|
495
522
|
}
|
|
496
|
-
/**
|
|
497
|
-
* Parse w:comments element into CommentOptions array.
|
|
498
|
-
*/
|
|
499
|
-
function parseComments(el, ctx) {
|
|
500
|
-
const comments = [];
|
|
501
|
-
for (const child of el.elements ?? []) {
|
|
502
|
-
if (child.name !== "w:comment") continue;
|
|
503
|
-
const id = attrNum(child, "w:id");
|
|
504
|
-
if (id === void 0) continue;
|
|
505
|
-
const author = attr(child, "w:author");
|
|
506
|
-
const initials = attr(child, "w:initials");
|
|
507
|
-
const date = attr(child, "w:date");
|
|
508
|
-
const children = [];
|
|
509
|
-
for (const sub of child.elements ?? []) if (sub.name === "w:p") children.push(parseParagraph(sub, ctx));
|
|
510
|
-
comments.push({
|
|
511
|
-
id,
|
|
512
|
-
author: author || void 0,
|
|
513
|
-
initials: initials || void 0,
|
|
514
|
-
date: date || void 0,
|
|
515
|
-
children
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
return comments;
|
|
519
|
-
}
|
|
520
|
-
/**
|
|
521
|
-
* Parse footnotes or endnotes content into {id, children} array.
|
|
522
|
-
* Skips system notes (id=-1 for separator, id=0 for continuation separator).
|
|
523
|
-
*/
|
|
524
|
-
function parseNotesContent(el, tagName, ctx) {
|
|
525
|
-
const notes = [];
|
|
526
|
-
for (const child of el.elements ?? []) {
|
|
527
|
-
if (child.name !== tagName) continue;
|
|
528
|
-
const id = attrNum(child, "w:id");
|
|
529
|
-
if (id === void 0) continue;
|
|
530
|
-
if (id < 1) continue;
|
|
531
|
-
const type = attr(child, "w:type");
|
|
532
|
-
const children = [];
|
|
533
|
-
for (const sub of child.elements ?? []) if (sub.name === "w:p") children.push(parseParagraph(sub, ctx));
|
|
534
|
-
notes.push({
|
|
535
|
-
id,
|
|
536
|
-
type: type || void 0,
|
|
537
|
-
children
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
return notes;
|
|
541
|
-
}
|
|
542
523
|
//#endregion
|
|
543
524
|
export { parseDocument as n, parseDocx as r, parseArchive as t };
|
|
544
525
|
|
|
545
|
-
//# sourceMappingURL=parse-
|
|
526
|
+
//# sourceMappingURL=parse-BIJM6_8Y.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-BIJM6_8Y.mjs","names":["findDeep"],"sources":["../src/parts/alt-chunk/alt-chunk-parse.ts","../src/parts/custom-xml/custom-xml-parse.ts","../src/parts/sub-doc/sub-doc-parse.ts","../src/parts/textbox/textbox-parse.ts","../src/parse/body.ts","../src/parse.ts"],"sourcesContent":["/**\n * AltChunk parser for DOCX documents.\n *\n * Parses w:altChunk elements and extracts embedded content from the ZIP.\n *\n * @module\n */\nimport { attr } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { AltChunkOptions } from \"@parts/alt-chunk/alt-chunk\";\n\nimport type { DocxReadContext } from \"../../context\";\n\n/**\n * Parse a w:altChunk element into AltChunkOptions.\n * Reads the referenced data from the ZIP package.\n */\nexport function parseAltChunk(el: Element, ctx: DocxReadContext): AltChunkOptions {\n const rId = attr(el, \"r:id\");\n if (!rId) {\n throw new Error(\"w:altChunk missing r:id attribute\");\n }\n\n // Look up the path from relationships\n const path = ctx.docx.partRefs.afChunks.get(rId);\n if (!path) {\n throw new Error(`AltChunk relationship ${rId} not found`);\n }\n\n // Read raw data from ZIP\n const data = ctx.docx.doc.getRaw(path);\n if (!data) {\n throw new Error(`AltChunk data not found at ${path}`);\n }\n\n // Determine content type from extension\n const ext = path.split(\".\").pop() ?? \"txt\";\n let contentType: \"text/html\" | \"application/rtf\" | \"text/plain\";\n let extension: \"html\" | \"rtf\" | \"txt\";\n\n switch (ext) {\n case \"html\":\n contentType = \"text/html\";\n extension = \"html\";\n break;\n case \"rtf\":\n contentType = \"application/rtf\";\n extension = \"rtf\";\n break;\n default:\n contentType = \"text/plain\";\n extension = \"txt\";\n break;\n }\n\n return {\n data,\n contentType,\n extension,\n };\n}\n","/**\n * Parser for custom XML block elements (w:customXml).\n *\n * @module\n */\nimport { attr, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { SectionChild } from \"@shared/section\";\n\nimport type { DocxReadContext } from \"../../context\";\nimport type { CustomXmlBlockOptions, CustomXmlPrOptions } from \"./custom-xml\";\n\n/**\n * Parse w:customXml element into CustomXmlBlockOptions.\n *\n * Uses a callback for child parsing to avoid circular dependencies\n * (same pattern as parseTable).\n */\nexport function parseCustomXmlBlock(\n el: Element,\n ctx: DocxReadContext,\n parseChild: (el: Element, ctx: DocxReadContext) => SectionChild,\n): CustomXmlBlockOptions {\n const opts: Record<string, unknown> = {};\n\n // Required attribute\n const element = attr(el, \"w:element\");\n if (element) opts.element = element;\n\n // Optional URI\n const uri = attr(el, \"w:uri\");\n if (uri) opts.uri = uri;\n\n // Parse w:customXmlPr\n const xmlPr = findChild(el, \"w:customXmlPr\");\n if (xmlPr) {\n opts.customXmlPr = parseCustomXmlPr(xmlPr);\n }\n\n // Parse block-level children\n const children: SectionChild[] = [];\n for (const child of el.elements ?? []) {\n if (child.name === \"w:customXmlPr\") continue;\n const parsed = parseChild(child, ctx);\n children.push(parsed);\n }\n if (children.length > 0) opts.children = children;\n\n return opts as unknown as CustomXmlBlockOptions;\n}\n\nfunction parseCustomXmlPr(el: Element): CustomXmlPrOptions {\n const opts: Record<string, unknown> = {};\n\n const placeholder = findChild(el, \"w:placeholder\");\n if (placeholder) {\n const val = attr(placeholder, \"w:val\");\n if (val) opts.placeholder = val;\n }\n\n const attributes: { name: string; val: string; uri?: string }[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:attr\") continue;\n const name = attr(child, \"w:name\");\n const val = attr(child, \"w:val\");\n if (name && val) {\n const attrOpts: { name: string; val: string; uri?: string } = { name, val };\n const uriVal = attr(child, \"w:uri\");\n if (uriVal) attrOpts.uri = uriVal;\n attributes.push(attrOpts);\n }\n }\n if (attributes.length > 0) opts.attributes = attributes;\n\n return opts as unknown as CustomXmlPrOptions;\n}\n","/**\n * SubDoc parser for DOCX documents.\n *\n * Parses w:subDoc elements and extracts embedded document data.\n *\n * @module\n */\nimport { attr } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { SubDocOptions } from \"@parts/sub-doc/sub-doc\";\n\nimport type { DocxReadContext } from \"../../context\";\n\n/**\n * Parse a w:subDoc element into SubDocOptions.\n * Reads the referenced document data from the ZIP package.\n */\nexport function parseSubDoc(el: Element, ctx: DocxReadContext): SubDocOptions {\n const rId = attr(el, \"r:id\");\n if (!rId) {\n throw new Error(\"w:subDoc missing r:id attribute\");\n }\n\n const path = ctx.docx.partRefs.subDocs.get(rId);\n if (!path) {\n throw new Error(`SubDoc relationship ${rId} not found`);\n }\n\n const data = ctx.docx.doc.getRaw(path);\n if (!data) {\n throw new Error(`SubDoc data not found at ${path}`);\n }\n\n return { data };\n}\n","/**\n * Textbox parser for DOCX documents.\n *\n * Parses w:pict → v:shape → v:textbox → w:txbxContent elements.\n *\n * @module\n */\nimport { attr, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\nimport type { DocxReadContext } from \"../../context\";\n\n/**\n * Parse VML shape style string into VmlShapeStyle-like object.\n */\nfunction parseVmlStyle(styleStr: string): Record<string, string> {\n const style: Record<string, string> = {};\n for (const part of styleStr.split(\";\")) {\n const [key, val] = part.split(\":\").map((s) => s.trim());\n if (key && val) style[key] = val;\n }\n return style;\n}\n\n/**\n * Parse a w:pict element that contains a textbox.\n * Returns an object suitable for the { textbox: ... } SectionChild variant.\n */\nexport function parseTextbox(\n el: Element,\n ctx: DocxReadContext,\n parseChildren: (elements: Element[], ctx: DocxReadContext) => unknown[],\n): {\n style?: Record<string, string>;\n children?: unknown[];\n} {\n const shape = findDeep(el, \"v:shape\")[0];\n if (!shape) return {};\n\n const opts: Record<string, unknown> = {};\n\n // Parse VML style\n const styleAttr = attr(shape, \"style\");\n if (styleAttr) {\n opts.style = parseVmlStyle(styleAttr);\n }\n\n // Parse textbox content\n const textbox = findDeep(shape, \"v:textbox\")[0];\n if (textbox) {\n const txbxContent = findChild(textbox, \"w:txbxContent\");\n if (txbxContent) {\n const childList = parseChildren(txbxContent.elements ?? [], ctx);\n if (childList.length > 0) opts.children = childList;\n }\n }\n\n return opts as { style?: Record<string, string>; children?: unknown[] };\n}\n\n// Simple deep finder\nfunction findDeep(parent: Element, name: string): Element[] {\n const result: Element[] = [];\n for (const child of parent.elements ?? []) {\n if (child.name === name) result.push(child);\n result.push(...findDeep(child, name));\n }\n return result;\n}\n","/**\n * Body parser for DOCX documents.\n *\n * Parses w:body → SectionOptions[] by splitting at w:sectPr boundaries.\n *\n * @module\n */\nimport { attr, findChild, stringify } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { parseAltChunk } from \"@parts/alt-chunk/alt-chunk-parse\";\nimport { parseCustomXmlBlock } from \"@parts/custom-xml/custom-xml-parse\";\nimport { parseSectionPropertiesEl } from \"@parts/document/body/section-properties/descriptor\";\nimport type { SectionPropertiesOptions } from \"@parts/document/body/section-properties/section-properties\";\nimport { parseSdtBlock } from \"@parts/sdt/sdt-parse\";\nimport { parseSubDoc } from \"@parts/sub-doc/sub-doc-parse\";\nimport { parseToc } from \"@parts/table-of-contents/toc-parse\";\nimport { tableDesc } from \"@parts/table/descriptor\";\nimport type { TableOptions } from \"@parts/table/table\";\nimport { parseTextbox } from \"@parts/textbox/textbox-parse\";\nimport type { SectionOptions } from \"@shared/section\";\nimport type { SectionChild } from \"@shared/section\";\n\nimport { parseParagraph } from \"../body\";\nimport { DocxReadContext } from \"../context\";\nimport { setBodyParseChild } from \"../parts\";\n\n// ── Section properties parser ────────────────────────────────────────────────\n\n/**\n * Parse w:sectPr element into SectionPropertiesOptions.\n * Delegates to the section properties descriptor's parse method.\n */\nfunction parseSectionProperties(el: Element, ctx: DocxReadContext): SectionPropertiesOptions {\n const opts = parseSectionPropertiesEl(el) as Record<string, unknown>;\n\n // Headers/footers - parse from references and store in a separate field\n const headerRefs: Record<string, unknown> = {};\n const footerRefs: Record<string, unknown> = {};\n\n for (const child of el.elements ?? []) {\n if (child.name === \"w:headerReference\") {\n const rId = attr(child, \"r:id\");\n const type = attr(child, \"w:type\");\n if (rId && type) {\n const headerChildren = parseHeaderFooterRef(rId, ctx);\n if (headerChildren) headerRefs[type] = headerChildren;\n }\n }\n if (child.name === \"w:footerReference\") {\n const rId = attr(child, \"r:id\");\n const type = attr(child, \"w:type\");\n if (rId && type) {\n const footerChildren = parseHeaderFooterRef(rId, ctx);\n if (footerChildren) footerRefs[type] = footerChildren;\n }\n }\n }\n\n if (Object.keys(headerRefs).length > 0) {\n opts.parsedHeaders = headerRefs;\n }\n if (Object.keys(footerRefs).length > 0) {\n opts.parsedFooters = footerRefs;\n }\n\n return opts as SectionPropertiesOptions;\n}\n\n/**\n * Parse a header/footer reference by following the relationship to its XML part.\n */\nfunction parseHeaderFooterRef(rId: string, ctx: DocxReadContext): SectionChild[] | undefined {\n const path = ctx.docx.partRefs.headers.get(rId) ?? ctx.docx.partRefs.footers.get(rId);\n if (!path) return undefined;\n\n const partEl = ctx.docx.doc.get(path);\n if (!partEl) return undefined;\n\n // The header/footer XML root element contains w:p, w:tbl, etc.\n const children: SectionChild[] = [];\n for (const child of partEl.elements ?? []) {\n const sectionChild = parseSectionChild(child, ctx);\n if (sectionChild !== undefined) {\n children.push(sectionChild);\n }\n }\n\n return children.length > 0 ? children : undefined;\n}\n\n// ── Section child dispatch ───────────────────────────────────────────────────\n\n/**\n * Parse a single body child element into a SectionChild.\n */\nexport function parseSectionChild(el: Element, ctx: DocxReadContext): SectionChild {\n switch (el.name) {\n case \"w:p\": {\n // Check for textbox (w:pict containing v:textbox)\n const pict = findChild(el, \"w:pict\");\n if (pict) {\n const textbox = findDeepElement(pict, \"v:textbox\");\n if (textbox) {\n const textboxOpts = parseTextbox(pict, ctx, parseSectionChildrenElements);\n return { textbox: textboxOpts as SectionChild extends { textbox: infer T } ? T : never };\n }\n }\n\n return { paragraph: parseParagraph(el, ctx) };\n }\n case \"w:tbl\":\n return { table: tableDesc.parse(el, ctx) as TableOptions };\n case \"w:sdt\": {\n // Try TOC first\n const tocResult = parseToc(el, ctx);\n if (tocResult) {\n return { toc: tocResult };\n }\n // Otherwise parse as generic SDT block\n const sdtResult = parseSdtBlock(el, ctx, parseSectionChildrenElements);\n return {\n sdt: {\n properties: sdtResult.properties,\n children: sdtResult.children as SectionChild[] | undefined,\n },\n };\n }\n case \"w:altChunk\":\n return { altChunk: parseAltChunk(el, ctx) };\n case \"w:subDoc\":\n return { subDoc: parseSubDoc(el, ctx) };\n case \"w:customXml\":\n return { customXml: parseCustomXmlBlock(el, ctx, parseSectionChild) };\n default:\n return { rawXml: stringify(el) };\n }\n}\n\n/**\n * Find a deep descendant element by name.\n */\nfunction findDeepElement(parent: Element, name: string): Element | undefined {\n for (const child of parent.elements ?? []) {\n if (child.name === name) return child;\n const found = findDeepElement(child, name);\n if (found) return found;\n }\n return undefined;\n}\n\n// ── Body parsing with section splitting ───────────────────────────────────────\n\n/**\n * Parse w:body element into SectionOptions[].\n *\n * Splits body content at w:sectPr boundaries to create sections.\n * The last w:sectPr (child of w:body directly) defines the last section.\n * Previous w:sectPr elements appear inside w:pPr elements.\n */\nexport function parseBody(body: Element, ctx: DocxReadContext): SectionOptions[] {\n // Register the body child parser for descriptor parse callbacks\n setBodyParseChild(parseSectionChild);\n\n // Collect body children and detect section breaks\n interface SectionBoundary {\n index: number;\n sectPr: Element;\n }\n\n const bodyChildren: Element[] = [];\n const boundaries: SectionBoundary[] = [];\n\n for (const child of body.elements ?? []) {\n if (child.name === \"w:sectPr\") {\n // Final section properties (last section)\n boundaries.push({ index: bodyChildren.length, sectPr: child });\n } else {\n bodyChildren.push(child);\n\n // Check for inline sectPr in paragraph properties\n if (child.name === \"w:p\") {\n const pPr = findChild(child, \"w:pPr\");\n if (pPr) {\n const sectPr = findChild(pPr, \"w:sectPr\");\n if (sectPr) {\n boundaries.push({ index: bodyChildren.length, sectPr });\n }\n }\n }\n }\n }\n\n // If no boundaries, the whole body is one section\n if (boundaries.length === 0) {\n return [\n {\n children: bodyChildren.map((el) => parseSectionChild(el, ctx)),\n },\n ];\n }\n\n // Split into sections\n const sections: SectionOptions[] = [];\n let start = 0;\n\n for (let i = 0; i < boundaries.length; i++) {\n const boundary = boundaries[i];\n // For inline sectPr (inside w:pPr), the containing paragraph was pushed to\n // bodyChildren. Exclude it — it's a section break marker, not content.\n // The last boundary uses a body-level sectPr, so no paragraph to exclude.\n const isInlineSectPr = i < boundaries.length - 1;\n const endIdx = isInlineSectPr ? Math.max(start, boundary.index - 1) : boundary.index;\n const sectionElements = bodyChildren.slice(start, endIdx);\n const parsedProps = parseSectionProperties(boundary.sectPr, ctx);\n const rawProps = parsedProps as Record<string, unknown>;\n\n // Extract headers/footers that were stored as parsedHeaders/parsedFooters\n const parsedHeaders = rawProps.parsedHeaders as Record<string, SectionChild[]> | undefined;\n const parsedFooters = rawProps.parsedFooters as Record<string, SectionChild[]> | undefined;\n\n // Build clean properties without internal fields\n const cleanProps = { ...parsedProps };\n delete (cleanProps as Record<string, unknown>).parsedHeaders;\n delete (cleanProps as Record<string, unknown>).parsedFooters;\n\n const section = {\n children: sectionElements.map((el) => parseSectionChild(el, ctx)),\n properties: cleanProps,\n ...(parsedHeaders ? { headers: parsedHeaders } : {}),\n ...(parsedFooters ? { footers: parsedFooters } : {}),\n } as SectionOptions;\n\n sections.push(section);\n start = boundary.index;\n }\n\n // If there are elements after the last boundary, they form the last section\n // with the body-level w:sectPr (already captured)\n // Actually the body-level sectPr IS the last boundary\n\n return sections;\n}\n\n/**\n * Parse a list of elements into SectionChild[].\n * Used by SDT and textbox parsers for their content.\n */\nfunction parseSectionChildrenElements(elements: Element[], ctx: DocxReadContext): SectionChild[] {\n return elements.map((el) => parseSectionChild(el, ctx));\n}\n","import type { ParsedArchive } from \"@office-open/core\";\nimport { parseArchive } from \"@office-open/core\";\nimport type { DataType } from \"@office-open/core\";\nimport { toUint8Array } from \"@office-open/core\";\nimport { attr } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { bibliographyDesc } from \"@parts/bibliography\";\nimport { setBodyParseChild } from \"@parts/bodychildren\";\nimport { commentsDesc } from \"@parts/comments\";\nimport { contentTypesDesc } from \"@parts/contenttypes\";\nimport { corePropertiesDesc } from \"@parts/core-properties\";\nimport type { DocumentOptions } from \"@parts/core-properties\";\nimport { customPropertiesDesc } from \"@parts/custom-properties\";\nimport { endnotesDesc } from \"@parts/endnotes/descriptor\";\nimport { fontTableDesc } from \"@parts/fonts/descriptor\";\nimport { footnotesDesc } from \"@parts/footnotes/descriptor\";\nimport { glossaryDesc } from \"@parts/glossary-document\";\nimport { parseNumberingDefinitions } from \"@parts/numbering/numbering\";\nimport { settingsDesc } from \"@parts/settings/descriptor\";\nimport { buildStyleCache, buildNumberingCache, parseStyleDefinitions } from \"@parts/styles/styles\";\nimport { setTableParseChild } from \"@parts/table/descriptor\";\nimport { webSettingsDesc } from \"@parts/web-settings\";\n\nimport { parseParagraphProperties } from \"./body\";\nimport { DocxReadContext } from \"./context\";\nimport { parseBody, parseSectionChild } from \"./parse/body\";\n\nexport { parseArchive };\n\n/**\n * All part paths extracted from the DOCX package.\n * Field names correspond directly to the OOXML directory structure.\n */\nexport interface DocxPartRefs {\n /** word/headerN.xml keyed by rId */\n headers: Map<string, string>;\n /** word/footerN.xml keyed by rId */\n footers: Map<string, string>;\n /** word/footnotes.xml */\n footnotes?: string;\n /** word/endnotes.xml */\n endnotes?: string;\n /** word/comments.xml */\n comments?: string;\n /** Hyperlink targets keyed by rId (external URLs) */\n hyperlinks: Map<string, string>;\n /** word/charts/chartN.xml keyed by rId */\n charts: Map<string, string>;\n /** word/diagrams/dataN.xml keyed by rId */\n diagramData: Map<string, string>;\n /** word/media/* keyed by rId */\n media: Map<string, string>;\n /** Alternative format chunks (word/afchunkN.*) keyed by rId */\n afChunks: Map<string, string>;\n /** Sub-documents (word/subdocs/subdocN.docx) keyed by rId */\n subDocs: Map<string, string>;\n /** word/bibliography.xml */\n bibliography?: string;\n /** word/glossary/document.xml */\n glossary?: string;\n}\n\nexport interface DocxDocument {\n doc: ParsedArchive;\n /** word/document.xml → w:body element */\n body: Element;\n /** word/document.xml → w:background element */\n background?: Element;\n /** word/styles.xml */\n styles?: Element;\n /** word/numbering.xml */\n numbering?: Element;\n /** word/settings.xml */\n settings?: Element;\n /** word/fontTable.xml */\n fontTable?: Element;\n /** word/webSettings.xml */\n webSettings?: Element;\n partRefs: DocxPartRefs;\n /** docProps/core.xml */\n coreProps?: string;\n /** docProps/app.xml */\n appProps?: string;\n /** docProps/custom.xml */\n customProps?: string;\n /** [Content_Types].xml */\n contentTypes?: Element;\n}\n\nfunction resolveRelsPath(target: string): string {\n if (target.startsWith(\"/\")) return target.slice(1);\n if (target.startsWith(\"../\")) return target.replace(\"../\", \"\");\n return `word/${target}`;\n}\n\nfunction parseDocPartRefs(doc: ParsedArchive): DocxPartRefs {\n const refs: DocxPartRefs = {\n headers: new Map(),\n footers: new Map(),\n hyperlinks: new Map(),\n charts: new Map(),\n diagramData: new Map(),\n media: new Map(),\n afChunks: new Map(),\n subDocs: new Map(),\n };\n\n const relsEl = doc.get(\"word/_rels/document.xml.rels\");\n if (!relsEl) return refs;\n\n for (const child of relsEl.elements ?? []) {\n if (child.name !== \"Relationship\") continue;\n const type = attr(child, \"Type\") ?? \"\";\n const target = attr(child, \"Target\") ?? \"\";\n const id = attr(child, \"Id\") ?? \"\";\n if (!target) continue;\n\n const path = resolveRelsPath(target);\n\n if (type.includes(\"/header\")) {\n refs.headers.set(id, path);\n } else if (type.includes(\"/footer\")) {\n refs.footers.set(id, path);\n } else if (type.includes(\"/footnotes\")) {\n refs.footnotes = path;\n } else if (type.includes(\"/endnotes\")) {\n refs.endnotes = path;\n } else if (type.includes(\"/comments\")) {\n refs.comments = path;\n } else if (type.includes(\"/chart\")) {\n refs.charts.set(id, path);\n } else if (type.includes(\"/diagramData\")) {\n refs.diagramData.set(id, path);\n } else if (type.includes(\"/image\") || type.includes(\"/media\")) {\n refs.media.set(id, path);\n } else if (type.includes(\"/aFChunk\")) {\n refs.afChunks.set(id, path);\n } else if (type.includes(\"/subDocument\")) {\n refs.subDocs.set(id, path);\n } else if (type.includes(\"/bibliography\")) {\n refs.bibliography = path;\n } else if (type.includes(\"/glossaryDocument\")) {\n refs.glossary = path;\n } else if (type.includes(\"/hyperlink\")) {\n refs.hyperlinks.set(id, target);\n }\n }\n\n return refs;\n}\n\nfunction parseRootRels(doc: ParsedArchive): {\n coreProps?: string;\n appProps?: string;\n customProps?: string;\n} {\n const relsEl = doc.get(\"_rels/.rels\");\n if (!relsEl) return {};\n\n let coreProps: string | undefined;\n let appProps: string | undefined;\n let customProps: string | undefined;\n\n for (const child of relsEl.elements ?? []) {\n if (child.name !== \"Relationship\") continue;\n const type = attr(child, \"Type\") ?? \"\";\n const target = attr(child, \"Target\") ?? \"\";\n if (!target) continue;\n\n const path = target.startsWith(\"/\") ? target.slice(1) : target;\n\n if (type.includes(\"/core-properties\")) {\n coreProps = path;\n } else if (type.includes(\"/extended-properties\")) {\n appProps = path;\n } else if (type.includes(\"/custom-properties\")) {\n customProps = path;\n }\n }\n\n return { coreProps, appProps, customProps };\n}\n\n/**\n * Parse a .docx file and convert it into DocumentOptions.\n *\n * This is the main public API for parsing DOCX files.\n * The returned options can be passed directly to `new Document(parsed)`\n * to recreate the document.\n *\n * @param data - Raw bytes of a .docx file\n * @returns Document options including sections and metadata\n */\nexport function parseDocument(data: DataType): DocumentOptions {\n const docx = parseDocx(data);\n const ctx = new DocxReadContext(\n docx,\n buildStyleCache(docx.styles),\n buildNumberingCache(docx.numbering),\n );\n\n // Register the child parser for table and body child descriptors\n setTableParseChild(parseSectionChild);\n setBodyParseChild(parseSectionChild);\n\n const sections = parseBody(docx.body, ctx);\n\n const opts: Record<string, unknown> = { sections };\n\n // Background (w:background in document.xml)\n if (docx.background) {\n const bg: Record<string, unknown> = {};\n const color = attr(docx.background, \"w:color\");\n if (color) bg.color = color;\n if (Object.keys(bg).length > 0) opts.background = bg;\n }\n\n // Core properties\n if (docx.coreProps) {\n const corePropsEl = docx.doc.get(docx.coreProps);\n if (corePropsEl) {\n const cp = corePropertiesDesc.parse(corePropsEl, ctx);\n if (cp.title) opts.title = cp.title;\n if (cp.subject) opts.subject = cp.subject;\n if (cp.creator) opts.creator = cp.creator;\n if (cp.keywords) opts.keywords = cp.keywords;\n if (cp.description) opts.description = cp.description;\n if (cp.lastModifiedBy) opts.lastModifiedBy = cp.lastModifiedBy;\n if (cp.revision) opts.revision = cp.revision;\n }\n }\n\n // Settings\n if (docx.settings) {\n Object.assign(opts, settingsDesc.parse(docx.settings, ctx));\n }\n\n // Web settings\n if (docx.webSettings) {\n const wsOpts = webSettingsDesc.parse(docx.webSettings, ctx);\n if (Object.keys(wsOpts).length > 0) opts.webSettings = wsOpts;\n }\n\n // Custom properties\n if (docx.customProps) {\n const customPropsEl = docx.doc.get(docx.customProps);\n if (customPropsEl) {\n const cpResult = customPropertiesDesc.parse(customPropsEl, ctx);\n if (cpResult.properties && cpResult.properties.length > 0) {\n opts.customProperties = cpResult.properties;\n }\n }\n }\n\n // Comments content\n if (docx.partRefs.comments) {\n const commentsEl = docx.doc.get(docx.partRefs.comments);\n if (commentsEl) {\n const commentsResult = commentsDesc.parse(commentsEl, ctx);\n const children = commentsResult.children;\n if (children && children.length > 0) {\n opts.comments = { children } as unknown as DocumentOptions[\"comments\"];\n }\n }\n }\n\n // Footnotes content\n if (docx.partRefs.footnotes) {\n const footnotesEl = docx.doc.get(docx.partRefs.footnotes);\n if (footnotesEl) {\n const fnResult = footnotesDesc.parse(footnotesEl, ctx);\n const footnotesMap: Record<string, { children: unknown[] }> = {};\n for (const [id, paragraphs] of fnResult.notes) {\n footnotesMap[String(id)] = { children: paragraphs };\n }\n if (Object.keys(footnotesMap).length > 0) opts.footnotes = footnotesMap;\n }\n }\n\n // Endnotes content\n if (docx.partRefs.endnotes) {\n const endnotesEl = docx.doc.get(docx.partRefs.endnotes);\n if (endnotesEl) {\n const enResult = endnotesDesc.parse(endnotesEl, ctx);\n const endnotesMap: Record<string, { children: unknown[] }> = {};\n for (const [id, paragraphs] of enResult.notes) {\n endnotesMap[String(id)] = { children: paragraphs };\n }\n if (Object.keys(endnotesMap).length > 0) opts.endnotes = endnotesMap;\n }\n }\n\n // Styles definitions\n if (docx.styles) {\n const styleOpts = parseStyleDefinitions(docx.styles, parseParagraphProperties, ctx);\n if (styleOpts) opts.styles = styleOpts;\n }\n\n // Numbering definitions\n if (docx.numbering) {\n const numOpts = parseNumberingDefinitions(docx.numbering);\n if (numOpts) opts.numbering = numOpts;\n }\n\n // Font table\n if (docx.fontTable) {\n const ftResult = fontTableDesc.parse(docx.fontTable, ctx);\n if (ftResult.fonts && ftResult.fonts.length > 0) opts.fonts = ftResult.fonts;\n }\n\n // Bibliography\n if (docx.partRefs.bibliography) {\n const bibEl = docx.doc.get(docx.partRefs.bibliography);\n if (bibEl) {\n const bibResult = bibliographyDesc.parse(bibEl, ctx);\n if (bibResult.sources && bibResult.sources.length > 0) opts.bibliography = bibResult;\n }\n }\n\n // Glossary document\n if (docx.partRefs.glossary) {\n const glossaryEl = docx.doc.get(docx.partRefs.glossary);\n if (glossaryEl) {\n const glossaryResult = glossaryDesc.parse(glossaryEl, ctx);\n if (glossaryResult.parts && glossaryResult.parts.length > 0) opts.glossary = glossaryResult;\n }\n }\n\n // Content types\n if (docx.contentTypes) {\n const ctResult = contentTypesDesc.parse(docx.contentTypes, ctx);\n if (ctResult) opts.contentTypes = ctResult;\n }\n\n return opts as unknown as DocumentOptions;\n}\n\nexport function parseDocx(data: DataType): DocxDocument {\n const uint8 = toUint8Array(data);\n const doc = parseArchive(uint8);\n\n const documentEl = doc.get(\"word/document.xml\");\n if (!documentEl) throw new Error(\"word/document.xml not found\");\n const body = documentEl.elements?.find((e) => e.name === \"w:body\");\n if (!body) throw new Error(\"w:body not found in word/document.xml\");\n const background = documentEl.elements?.find((e) => e.name === \"w:background\");\n\n const styles = doc.get(\"word/styles.xml\");\n const numbering = doc.get(\"word/numbering.xml\");\n const settings = doc.get(\"word/settings.xml\");\n const fontTable = doc.get(\"word/fontTable.xml\");\n const webSettings = doc.get(\"word/webSettings.xml\");\n\n const partRefs = parseDocPartRefs(doc);\n const { coreProps, appProps, customProps } = parseRootRels(doc);\n\n const contentTypes = doc.get(\"[Content_Types].xml\");\n\n return {\n doc,\n body,\n background,\n styles,\n numbering,\n settings,\n fontTable,\n webSettings,\n partRefs,\n coreProps,\n appProps,\n customProps,\n contentTypes,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAgB,cAAc,IAAa,KAAuC;CAChF,MAAM,MAAM,KAAK,IAAI,MAAM;CAC3B,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,mCAAmC;CAIrD,MAA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YAAY,IAAI,IAAI,oBAAoB;CAC9C,MAAM,WAAW,IAAI,IAAI,mBAAmB;CAC5C,MAAM,YAAY,IAAI,IAAI,oBAAoB;CAC9C,MAAM,cAAc,IAAI,IAAI,sBAAsB;CAElD,MAAM,WAAW,iBAAiB,GAAG;CACrC,MAAM,EAAE,WAAW,UAAU,gBAAgB,cAAc,GAAG;CAI9D,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,cAfmB,IAAI,IAAI,qBAehB;CACb;AACF"}
|
package/dist/parse.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as parseDocument, g as parseArchive, h as DocxPartRefs, m as DocxDocument, v as parseDocx } from "./core-properties-
|
|
1
|
+
import { _ as parseDocument, g as parseArchive, h as DocxPartRefs, m as DocxDocument, v as parseDocx } from "./core-properties-Bh8_D5Kh.mjs";
|
|
2
2
|
export { DocxDocument, DocxPartRefs, parseArchive, parseDocument, parseDocx };
|
package/dist/parse.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as parseDocument, r as parseDocx, t as parseArchive } from "./parse-
|
|
1
|
+
import { n as parseDocument, r as parseDocx, t as parseArchive } from "./parse-BIJM6_8Y.mjs";
|
|
2
2
|
export { parseArchive, parseDocument, parseDocx };
|
package/dist/patch/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { wt as SectionChild } from "../core-properties-
|
|
1
|
+
import { wt as SectionChild } from "../core-properties-Bh8_D5Kh.mjs";
|
|
2
2
|
import { OutputByType, OutputType } from "@office-open/core";
|
|
3
3
|
import { Buffer } from "\u0000polyfill-node.buffer";
|
|
4
4
|
|
|
@@ -16,12 +16,12 @@ interface FilePatch {
|
|
|
16
16
|
type: typeof PatchType.DOCUMENT;
|
|
17
17
|
children: SectionChild[];
|
|
18
18
|
}
|
|
19
|
-
type
|
|
19
|
+
type Patch = ParagraphPatch | FilePatch;
|
|
20
20
|
type PatchDocumentOutputType = OutputType;
|
|
21
21
|
interface PatchDocumentOptions<T extends PatchDocumentOutputType = PatchDocumentOutputType> {
|
|
22
22
|
outputType: T;
|
|
23
23
|
data: InputDataType;
|
|
24
|
-
patches: Readonly<Record<string,
|
|
24
|
+
patches: Readonly<Record<string, Patch>>;
|
|
25
25
|
keepOriginalStyles?: boolean;
|
|
26
26
|
placeholderDelimiters?: Readonly<{
|
|
27
27
|
start: string;
|
|
@@ -46,5 +46,5 @@ declare const patchDetector: ({
|
|
|
46
46
|
data
|
|
47
47
|
}: PatchDetectorOptions) => Promise<string[]>;
|
|
48
48
|
//#endregion
|
|
49
|
-
export {
|
|
49
|
+
export { InputDataType, Patch, PatchDocumentOptions, PatchDocumentOutputType, PatchType, patchDetector, patchDocument };
|
|
50
50
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/patch/from-docx.ts","../../src/patch/patch-detector.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/patch/from-docx.ts","../../src/patch/patch-detector.ts"],"mappings":";;;;;KAoHY,aAAA,GAAgB,MAAA,uBAA6B,UAAA,GAAa,WAAA,GAAc,IAAA;AAAA,cAOvE,SAAA;EAAA,SAGH,QAAA;EAAA,SAAA,SAAA;AAAA;AAAA,UAEA,cAAA;EACR,IAAA,SAAa,SAAA,CAAU,SAAS;EAChC,QAAA;AAAA;AAAA,UAGQ,SAAA;EACR,IAAA,SAAa,SAAA,CAAU,QAAA;EACvB,QAAA,EAAU,YAAY;AAAA;AAAA,KAaZ,KAAA,GAAQ,cAAA,GAAiB,SAAS;AAAA,KAElC,uBAAA,GAA0B,UAAU;AAAA,UAE/B,oBAAA,WAA+B,uBAAA,GAA0B,uBAAA;EACxE,UAAA,EAAY,CAAA;EACZ,IAAA,EAAM,aAAA;EACN,OAAA,EAAS,QAAA,CAAS,MAAA,SAAe,KAAA;EACjC,kBAAA;EACA,qBAAA,GAAwB,QAAA;IACtB,KAAA;IACA,GAAA;EAAA;EAEF,SAAA;AAAA;AAAA,cAuBW,aAAA,aAAiC,uBAAA,GAA0B,uBAAA;EAAyB,UAAA;EAAA,IAAA;EAAA,OAAA;EAAA,kBAAA;EAAA,qBAAA;EAAA;AAAA,GAO9F,oBAAA,CAAqB,CAAA,MAAK,OAAA,CAAQ,YAAA,CAAa,CAAA;;;UChLxC,oBAAA;EACR,IAAA,EAAM,aAAa;AAAA;AAAA,cA4BR,aAAA;EAAuB;AAAA,GAAU,oBAAA,KAAuB,OAAA"}
|
package/dist/patch/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as
|
|
1
|
+
import { D as stringifyChildDispatch, E as tableDesc, O as stringifyParagraphInline, at as Media, k as stringifyRunInline, w as DocumentAttributeNamespaces } from "../document-CeM-U6J3.mjs";
|
|
2
2
|
import { DOCX_NS, OoxmlMimeType, TargetModeType, appendContentType, appendRelationship, createReplacer, createTraverser, getNextRelationshipIndex, getReferencedMedia, replaceImagePlaceholders, strFromU8, toJson, toUint8Array, unzipSync, zipAndConvert } from "@office-open/core";
|
|
3
3
|
import { escapeXml, js2xml, xml2js } from "@office-open/xml";
|
|
4
4
|
//#region src/patch/from-docx.ts
|
|
@@ -44,7 +44,7 @@ const docxReplacer = createReplacer({
|
|
|
44
44
|
if ("paragraph" in obj) xmlStr = stringifyParagraphInline(obj.paragraph, currentPatchCtx);
|
|
45
45
|
else if ("table" in obj) xmlStr = tableDesc.stringify(obj.table, currentPatchCtx) ?? "";
|
|
46
46
|
else {
|
|
47
|
-
const jr =
|
|
47
|
+
const jr = stringifyChildDispatch(child, currentPatchCtx);
|
|
48
48
|
if (jr !== void 0) xmlStr = Array.isArray(jr) ? jr.join("") : jr;
|
|
49
49
|
else xmlStr = stringifyRunInline(child, currentPatchCtx);
|
|
50
50
|
}
|
package/dist/patch/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/patch/from-docx.ts","../../src/patch/patch-detector.ts"],"sourcesContent":["import { TargetModeType } from \"@office-open/core\";\nimport {\n DOCX_NS,\n OoxmlMimeType,\n appendContentType,\n appendRelationship,\n createReplacer,\n getNextRelationshipIndex,\n getReferencedMedia,\n replaceImagePlaceholders,\n strFromU8,\n toJson,\n unzipSync,\n zipAndConvert,\n} from \"@office-open/core\";\nimport type { OutputByType, OutputType } from \"@office-open/core\";\nimport { toUint8Array } from \"@office-open/core\";\nimport { escapeXml, js2xml, xml2js } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { DocumentAttributeNamespaces } from \"@parts/document\";\nimport { stringifyJsonChild, stringifyParagraphInline, stringifyRunInline } from \"@parts/inline\";\nimport type { ParagraphChild } from \"@parts/inline\";\nimport type { ParagraphOptions } from \"@parts/paragraph/paragraph\";\nimport type { RunOptions } from \"@parts/paragraph/run/run\";\nimport { tableDesc } from \"@parts/table/descriptor\";\nimport type { TableOptions } from \"@parts/table/table\";\nimport { Media } from \"@shared/media\";\nimport type { SectionChild } from \"@shared/section\";\n\nimport type { BodyContext } from \"../context\";\nimport type { ViewWrapper } from \"../context\";\n\n/** Reusable TextEncoder (stateless, safe to share). */\nconst encoder = new TextEncoder();\n\n/**\n * Document patching module for modifying existing .docx files.\n *\n * Uses compile-path stringifiers (zero class instantiation) to serialize\n * patch content — no Formatter, no XmlComponent instances.\n *\n * @module\n */\n\n// ── Patch content stringification ──\n\n/**\n * Lightweight BodyContext adapter for patch serialization.\n * Captures hyperlink and image relationships for post-processing.\n */\nfunction createPatchContext(\n file: { media: Media },\n hyperlinkSink: Array<{ id: string; link: string }>,\n): BodyContext {\n return {\n fileData: file as unknown as BodyContext[\"fileData\"],\n file: file as unknown as BodyContext[\"file\"],\n viewWrapper: {\n relationships: {\n addRelationship: (linkId: string, _type: string, target: string, _mode?: string) => {\n hyperlinkSink.push({ id: linkId, link: target });\n },\n relationshipCount: 0,\n },\n } as unknown as BodyContext[\"viewWrapper\"],\n stringifyChild: () => \"\",\n addRelationship: () => \"\",\n addMedia: () => \"\",\n };\n}\n\nconst docxReplacer = createReplacer({\n ns: DOCX_NS,\n formatChild: (child: unknown): Element[] => {\n let xmlStr: string;\n\n if (typeof child === \"string\") {\n // Plain string → simple run\n xmlStr = `<w:r><w:t xml:space=\"preserve\">${escapeXml(child)}</w:t></w:r>`;\n } else if (typeof child === \"object\" && child !== null) {\n const obj = child as Record<string, unknown>;\n // SectionChild level (paragraph / table) — for DOCUMENT patches\n if (\"paragraph\" in obj) {\n xmlStr = stringifyParagraphInline(obj.paragraph as ParagraphOptions, currentPatchCtx);\n } else if (\"table\" in obj) {\n xmlStr = tableDesc.stringify(obj.table as TableOptions, currentPatchCtx) ?? \"\";\n } else {\n // ParagraphChild level — for PARAGRAPH patches\n // Try compile-path JSON child dispatch first\n const jr = stringifyJsonChild(child as ParagraphChild, currentPatchCtx);\n if (jr !== undefined) {\n xmlStr = Array.isArray(jr) ? jr.join(\"\") : jr;\n } else {\n // RunOptions (plain objects with text/children/bold/etc.)\n xmlStr = stringifyRunInline(child as RunOptions, currentPatchCtx);\n }\n }\n } else {\n xmlStr = \"<w:r/>\";\n }\n\n const jsonObj = xml2js(xmlStr, { captureSpacesBetweenElements: true });\n return [jsonObj.elements![0]];\n },\n});\n\n/** Current patch context — set per file in the main loop. */\nlet currentPatchCtx: BodyContext;\n\n/**\n * Supported input data types for document patching.\n */\nexport type InputDataType = Buffer | string | number[] | Uint8Array | ArrayBuffer | Blob;\n\n/**\n * Patch type enumeration.\n *\n * @publicApi\n */\nexport const PatchType = {\n DOCUMENT: \"file\",\n PARAGRAPH: \"paragraph\",\n} as const;\n\ninterface ParagraphPatch {\n type: typeof PatchType.PARAGRAPH;\n children: unknown[];\n}\n\ninterface FilePatch {\n type: typeof PatchType.DOCUMENT;\n children: SectionChild[];\n}\n\ninterface ImageRelationshipAddition {\n key: string;\n mediaDatas: { fileName: string }[];\n}\n\ninterface HyperlinkRelationshipAddition {\n key: string;\n hyperlink: { id: string; link: string };\n}\n\nexport type IPatch = ParagraphPatch | FilePatch;\n\nexport type PatchDocumentOutputType = OutputType;\n\nexport interface PatchDocumentOptions<T extends PatchDocumentOutputType = PatchDocumentOutputType> {\n outputType: T;\n data: InputDataType;\n patches: Readonly<Record<string, IPatch>>;\n keepOriginalStyles?: boolean;\n placeholderDelimiters?: Readonly<{\n start: string;\n end: string;\n }>;\n recursive?: boolean;\n}\n\nconst UTF16LE = new Uint8Array([0xff, 0xfe]);\nconst UTF16BE = new Uint8Array([0xfe, 0xff]);\n\nconst compareByteArrays = (a: Uint8Array, b: Uint8Array): boolean => {\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n};\n\n/**\n * Patches an existing .docx document by replacing placeholders with new content.\n *\n * @publicApi\n */\nexport const patchDocument = async <T extends PatchDocumentOutputType = PatchDocumentOutputType>({\n outputType,\n data,\n patches,\n keepOriginalStyles = true,\n placeholderDelimiters = { end: \"}}\", start: \"{{\" } as const,\n recursive = true,\n}: PatchDocumentOptions<T>): Promise<OutputByType[T]> => {\n const zipContent = unzipSync(toUint8Array(data));\n const contexts = new Map<string, BodyContext>();\n const media = new Media();\n const file = { media } as BodyContext[\"file\"];\n\n const map = new Map<string, Element>();\n\n const imageRelationshipAdditions: ImageRelationshipAddition[] = [];\n const hyperlinkRelationshipAdditions: HyperlinkRelationshipAddition[] = [];\n let hasMedia = false;\n\n const binaryContentMap = new Map<string, Uint8Array>();\n\n for (const [key, value] of Object.entries(zipContent)) {\n const startBytes = value.slice(0, 2);\n if (compareByteArrays(startBytes, UTF16LE) || compareByteArrays(startBytes, UTF16BE)) {\n binaryContentMap.set(key, value);\n continue;\n }\n\n if (!key.endsWith(\".xml\") && !key.endsWith(\".rels\")) {\n binaryContentMap.set(key, value);\n continue;\n }\n\n const json = toJson(strFromU8(value));\n\n if (key === \"word/document.xml\") {\n const document = json.elements?.find((i) => i.name === \"w:document\");\n if (document && document.attributes) {\n for (const ns of [\"mc\", \"wp\", \"r\", \"w15\", \"m\"] as const) {\n document.attributes[`xmlns:${ns}`] = DocumentAttributeNamespaces[ns];\n }\n document.attributes[\"mc:Ignorable\"] =\n `${document.attributes[\"mc:Ignorable\"] || \"\"} w15`.trim();\n }\n }\n\n if (key.startsWith(\"word/\") && !key.endsWith(\".xml.rels\")) {\n const hyperlinkSink: Array<{ id: string; link: string }> = [];\n\n const context: BodyContext = {\n fileData: file,\n file,\n viewWrapper: {\n relationships: {\n addRelationship: (\n linkId: string,\n _: string,\n target: string,\n __: (typeof TargetModeType)[keyof typeof TargetModeType],\n ) => {\n hyperlinkRelationshipAdditions.push({\n hyperlink: {\n id: linkId,\n link: target,\n },\n key,\n });\n },\n },\n } as unknown as ViewWrapper,\n stringifyChild: () => \"\",\n addRelationship: () => \"\",\n addMedia: () => \"\",\n };\n contexts.set(key, context);\n\n if (!placeholderDelimiters?.start.trim() || !placeholderDelimiters?.end.trim()) {\n throw new Error(\"Both start and end delimiters must be non-empty strings.\");\n }\n\n const { start, end } = placeholderDelimiters;\n\n // Create compile-path context for stringifying patch children\n const patchCtx = createPatchContext(file, hyperlinkSink);\n currentPatchCtx = patchCtx;\n\n for (const [patchKey, patchValue] of Object.entries(patches)) {\n const patchText = `${start}${patchKey}${end}`;\n while (true) {\n const { didFindOccurrence } = docxReplacer({\n context,\n json,\n keepOriginalStyles,\n patch: patchValue,\n patchText,\n });\n if (!recursive || !didFindOccurrence) {\n break;\n }\n }\n }\n\n // Flush hyperlink relationships captured by the compile-path context\n for (const hl of hyperlinkSink) {\n hyperlinkRelationshipAdditions.push({\n hyperlink: { id: hl.id, link: hl.link },\n key,\n });\n }\n\n const mediaDatas = getReferencedMedia(JSON.stringify(json), media.array);\n if (mediaDatas.length > 0) {\n hasMedia = true;\n imageRelationshipAdditions.push({\n key,\n mediaDatas,\n });\n }\n }\n\n map.set(key, json);\n }\n\n for (const { key, mediaDatas } of imageRelationshipAdditions) {\n const relationshipKey = `word/_rels/${key.split(\"/\").pop()}.rels`;\n const relationshipsJson = map.get(relationshipKey) ?? createRelationshipFile();\n map.set(relationshipKey, relationshipsJson);\n\n const index = getNextRelationshipIndex(relationshipsJson);\n const newJson = replaceImagePlaceholders(\n JSON.stringify(map.get(key)),\n mediaDatas,\n index,\n \"plain\",\n );\n map.set(key, JSON.parse(newJson) as Element);\n\n for (let i = 0; i < mediaDatas.length; i++) {\n const { fileName } = mediaDatas[i];\n appendRelationship(\n relationshipsJson,\n index + i,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image\",\n `media/${fileName}`,\n );\n }\n }\n\n for (const { key, hyperlink } of hyperlinkRelationshipAdditions) {\n const relationshipKey = `word/_rels/${key.split(\"/\").pop()}.rels`;\n\n const relationshipsJson = map.get(relationshipKey) ?? createRelationshipFile();\n map.set(relationshipKey, relationshipsJson);\n\n appendRelationship(\n relationshipsJson,\n hyperlink.id,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\",\n hyperlink.link,\n TargetModeType.EXTERNAL,\n );\n }\n\n if (hasMedia) {\n const contentTypesJson = map.get(\"[Content_Types].xml\");\n\n if (!contentTypesJson) {\n throw new Error(\"Could not find content types file\");\n }\n\n appendContentType(contentTypesJson, \"image/png\", \"png\");\n appendContentType(contentTypesJson, \"image/jpeg\", \"jpeg\");\n appendContentType(contentTypesJson, \"image/jpeg\", \"jpg\");\n appendContentType(contentTypesJson, \"image/bmp\", \"bmp\");\n appendContentType(contentTypesJson, \"image/gif\", \"gif\");\n appendContentType(contentTypesJson, \"image/svg+xml\", \"svg\");\n }\n\n const files: Record<string, Uint8Array> = {};\n\n for (const [key, value] of map) {\n files[key] = encoder.encode(js2xml(value));\n }\n\n for (const [key, value] of binaryContentMap) {\n files[key] = value;\n }\n\n for (const { data: mediaData, fileName } of media.array) {\n files[`word/media/${fileName}`] =\n mediaData instanceof Uint8Array ? mediaData : new Uint8Array(mediaData);\n }\n\n return await zipAndConvert(files, outputType, OoxmlMimeType.DOCX);\n};\n\nconst createRelationshipFile = (): Element => ({\n declaration: {\n attributes: {\n encoding: \"UTF-8\",\n standalone: \"yes\",\n version: \"1.0\",\n },\n },\n elements: [\n {\n attributes: {\n xmlns: \"http://schemas.openxmlformats.org/package/2006/relationships\",\n },\n elements: [],\n name: \"Relationships\",\n type: \"element\",\n },\n ],\n});\n","/**\n * Patch detector for discovering placeholders in document templates.\n *\n * @module\n */\nimport { DOCX_NS, createTraverser, strFromU8, toJson, unzipSync } from \"@office-open/core\";\nimport { toUint8Array } from \"@office-open/core\";\n\nimport type { InputDataType } from \"./from-docx\";\n\n/**\n * Options for patch detection.\n *\n * @property data - The document template to scan for placeholders\n */\ninterface PatchDetectorOptions {\n data: InputDataType;\n}\n\n/**\n * Detects all placeholders present in a document template.\n *\n * Scans through all XML content in a .docx file to find placeholder text\n * enclosed in delimiters (default: {{placeholder}}). This is useful for\n * discovering what patches a template expects before performing replacement.\n *\n * @param options - Patch detector configuration\n * @returns Array of placeholder keys found in the document\n *\n * @example\n * ```typescript\n * const placeholders = await patchDetector({ data: templateBuffer });\n * // Returns: [\"name\", \"date\", \"address\"] if template contains {{name}}, {{date}}, {{address}}\n *\n * // Use detected placeholders to create patches\n * const patches = {};\n * for (const key of placeholders) {\n * patches[key] = {\n * type: PatchType.PARAGRAPH,\n * children: [new TextRun(getUserData(key))],\n * };\n * });\n * ```\n */\nexport const patchDetector = async ({ data }: PatchDetectorOptions): Promise<string[]> => {\n const zipContent = unzipSync(toUint8Array(data));\n const patches = new Set<string>();\n\n for (const [key, value] of Object.entries(zipContent)) {\n if (!key.endsWith(\".xml\") && !key.endsWith(\".rels\")) {\n continue;\n }\n if (key.startsWith(\"word/\") && !key.endsWith(\".xml.rels\")) {\n const json = toJson(strFromU8(value));\n const { traverse } = createTraverser(DOCX_NS);\n for (const p of traverse(json)) {\n for (const patch of findPatchKeys(p.text)) {\n patches.add(patch);\n }\n }\n }\n }\n return [...patches];\n};\n\n/**\n * Extracts placeholder keys from text using regex pattern.\n *\n * @param text - Text to search for placeholders\n * @returns Array of placeholder keys (without delimiters)\n */\nconst findPatchKeys = (text: string): string[] => {\n const pattern = /(?<=\\{\\{).+?(?=\\}\\})/gs;\n return text.match(pattern) ?? [];\n};\n"],"mappings":";;;;;AAiCA,MAAM,UAAU,IAAI,YAAY;;;;;;;;;;;;;AAiBhC,SAAS,mBACP,MACA,eACa;CACb,OAAO;EACL,UAAU;EACJ;EACN,aAAa,EACX,eAAe;GACb,kBAAkB,QAAgB,OAAe,QAAgB,UAAmB;IAClF,cAAc,KAAK;KAAE,IAAI;KAAQ,MAAM;IAAO,CAAC;GACjD;GACA,mBAAmB;EACrB,EACF;EACA,sBAAsB;EACtB,uBAAuB;EACvB,gBAAgB;CAClB;AACF;AAEA,MAAM,eAAe,eAAe;CAClC,IAAI;CACJ,cAAc,UAA8B;EAC1C,IAAI;EAEJ,IAAI,OAAO,UAAU,UAEnB,SAAS,kCAAkC,UAAU,KAAK,EAAE;OACvD,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM;GACtD,MAAM,MAAM;GAEZ,IAAI,eAAe,KACjB,SAAS,yBAAyB,IAAI,WAA+B,eAAe;QAC/E,IAAI,WAAW,KACpB,SAAS,UAAU,UAAU,IAAI,OAAuB,eAAe,KAAK;QACvE;IAGL,MAAM,KAAK,mBAAmB,OAAyB,eAAe;IACtE,IAAI,OAAO,KAAA,GACT,SAAS,MAAM,QAAQ,EAAE,IAAI,GAAG,KAAK,EAAE,IAAI;SAG3C,SAAS,mBAAmB,OAAqB,eAAe;GAEpE;EACF,OACE,SAAS;EAIX,OAAO,CADS,OAAO,QAAQ,EAAE,8BAA8B,KAAK,CACtD,EAAE,SAAU,EAAE;CAC9B;AACF,CAAC;;AAGD,IAAI;;;;;;AAYJ,MAAa,YAAY;CACvB,UAAU;CACV,WAAW;AACb;AAsCA,MAAM,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,OAAO;CAGf,KAAK,MAAM,EAAE,MAAM,WAAW,cAAc,MAAM,OAChD,MAAM,cAAc,cAClB,qBAAqB,aAAa,YAAY,IAAI,WAAW,SAAS;CAG1E,OAAO,MAAM,cAAc,OAAO,YAAY,cAAc,IAAI;AAClE;AAEA,MAAM,gCAAyC;CAC7C,aAAa,EACX,YAAY;EACV,UAAU;EACV,YAAY;EACZ,SAAS;CACX,EACF;CACA,UAAU,CACR;EACE,YAAY,EACV,OAAO,+DACT;EACA,UAAU,CAAC;EACX,MAAM;EACN,MAAM;CACR,CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC9VA,MAAa,gBAAgB,OAAO,EAAE,WAAoD;CACxF,MAAM,aAAa,UAAU,aAAa,IAAI,CAAC;CAC/C,MAAM,0BAAU,IAAI,IAAY;CAEhC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,UAAU,GAAG;EACrD,IAAI,CAAC,IAAI,SAAS,MAAM,KAAK,CAAC,IAAI,SAAS,OAAO,GAChD;EAEF,IAAI,IAAI,WAAW,OAAO,KAAK,CAAC,IAAI,SAAS,WAAW,GAAG;GACzD,MAAM,OAAO,OAAO,UAAU,KAAK,CAAC;GACpC,MAAM,EAAE,aAAa,gBAAgB,OAAO;GAC5C,KAAK,MAAM,KAAK,SAAS,IAAI,GAC3B,KAAK,MAAM,SAAS,cAAc,EAAE,IAAI,GACtC,QAAQ,IAAI,KAAK;EAGvB;CACF;CACA,OAAO,CAAC,GAAG,OAAO;AACpB;;;;;;;AAQA,MAAM,iBAAiB,SAA2B;CAEhD,OAAO,KAAK,MAAM,wBAAO,KAAK,CAAC;AACjC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/patch/from-docx.ts","../../src/patch/patch-detector.ts"],"sourcesContent":["import { TargetModeType } from \"@office-open/core\";\nimport {\n DOCX_NS,\n OoxmlMimeType,\n appendContentType,\n appendRelationship,\n createReplacer,\n getNextRelationshipIndex,\n getReferencedMedia,\n replaceImagePlaceholders,\n strFromU8,\n toJson,\n unzipSync,\n zipAndConvert,\n} from \"@office-open/core\";\nimport type { OutputByType, OutputType } from \"@office-open/core\";\nimport { toUint8Array } from \"@office-open/core\";\nimport { escapeXml, js2xml, xml2js } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { DocumentAttributeNamespaces } from \"@parts/document\";\nimport {\n stringifyChildDispatch,\n stringifyParagraphInline,\n stringifyRunInline,\n} from \"@parts/inline\";\nimport type { ParagraphChild } from \"@parts/paragraph/paragraph\";\nimport type { ParagraphOptions } from \"@parts/paragraph/paragraph\";\nimport type { RunOptions } from \"@parts/paragraph/run/run\";\nimport { tableDesc } from \"@parts/table/descriptor\";\nimport type { TableOptions } from \"@parts/table/table\";\nimport { Media } from \"@shared/media\";\nimport type { SectionChild } from \"@shared/section\";\n\nimport type { BodyContext } from \"../context\";\nimport type { ViewWrapper } from \"../context\";\n\n/** Reusable TextEncoder (stateless, safe to share). */\nconst encoder = new TextEncoder();\n\n/**\n * Document patching module for modifying existing .docx files.\n *\n * Uses compile-path stringifiers (zero class instantiation) to serialize\n * patch content — no Formatter, no XmlComponent instances.\n *\n * @module\n */\n\n// ── Patch content stringification ──\n\n/**\n * Lightweight BodyContext adapter for patch serialization.\n * Captures hyperlink and image relationships for post-processing.\n */\nfunction createPatchContext(\n file: { media: Media },\n hyperlinkSink: Array<{ id: string; link: string }>,\n): BodyContext {\n return {\n fileData: file as unknown as BodyContext[\"fileData\"],\n file: file as unknown as BodyContext[\"file\"],\n viewWrapper: {\n relationships: {\n addRelationship: (linkId: string, _type: string, target: string, _mode?: string) => {\n hyperlinkSink.push({ id: linkId, link: target });\n },\n relationshipCount: 0,\n },\n } as unknown as BodyContext[\"viewWrapper\"],\n stringifyChild: () => \"\",\n addRelationship: () => \"\",\n addMedia: () => \"\",\n };\n}\n\nconst docxReplacer = createReplacer({\n ns: DOCX_NS,\n formatChild: (child: unknown): Element[] => {\n let xmlStr: string;\n\n if (typeof child === \"string\") {\n // Plain string → simple run\n xmlStr = `<w:r><w:t xml:space=\"preserve\">${escapeXml(child)}</w:t></w:r>`;\n } else if (typeof child === \"object\" && child !== null) {\n const obj = child as Record<string, unknown>;\n // SectionChild level (paragraph / table) — for DOCUMENT patches\n if (\"paragraph\" in obj) {\n xmlStr = stringifyParagraphInline(obj.paragraph as ParagraphOptions, currentPatchCtx);\n } else if (\"table\" in obj) {\n xmlStr = tableDesc.stringify(obj.table as TableOptions, currentPatchCtx) ?? \"\";\n } else {\n // ParagraphChild level — for PARAGRAPH patches\n // Try compile-path JSON child dispatch first\n const jr = stringifyChildDispatch(child as ParagraphChild, currentPatchCtx);\n if (jr !== undefined) {\n xmlStr = Array.isArray(jr) ? jr.join(\"\") : jr;\n } else {\n // RunOptions (plain objects with text/children/bold/etc.)\n xmlStr = stringifyRunInline(child as RunOptions, currentPatchCtx);\n }\n }\n } else {\n xmlStr = \"<w:r/>\";\n }\n\n const jsonObj = xml2js(xmlStr, { captureSpacesBetweenElements: true });\n return [jsonObj.elements![0]];\n },\n});\n\n/** Current patch context — set per file in the main loop. */\nlet currentPatchCtx: BodyContext;\n\n/**\n * Supported input data types for document patching.\n */\nexport type InputDataType = Buffer | string | number[] | Uint8Array | ArrayBuffer | Blob;\n\n/**\n * Patch type enumeration.\n *\n * @publicApi\n */\nexport const PatchType = {\n DOCUMENT: \"file\",\n PARAGRAPH: \"paragraph\",\n} as const;\n\ninterface ParagraphPatch {\n type: typeof PatchType.PARAGRAPH;\n children: unknown[];\n}\n\ninterface FilePatch {\n type: typeof PatchType.DOCUMENT;\n children: SectionChild[];\n}\n\ninterface ImageRelationshipAddition {\n key: string;\n mediaDatas: { fileName: string }[];\n}\n\ninterface HyperlinkRelationshipAddition {\n key: string;\n hyperlink: { id: string; link: string };\n}\n\nexport type Patch = ParagraphPatch | FilePatch;\n\nexport type PatchDocumentOutputType = OutputType;\n\nexport interface PatchDocumentOptions<T extends PatchDocumentOutputType = PatchDocumentOutputType> {\n outputType: T;\n data: InputDataType;\n patches: Readonly<Record<string, Patch>>;\n keepOriginalStyles?: boolean;\n placeholderDelimiters?: Readonly<{\n start: string;\n end: string;\n }>;\n recursive?: boolean;\n}\n\nconst UTF16LE = new Uint8Array([0xff, 0xfe]);\nconst UTF16BE = new Uint8Array([0xfe, 0xff]);\n\nconst compareByteArrays = (a: Uint8Array, b: Uint8Array): boolean => {\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n};\n\n/**\n * Patches an existing .docx document by replacing placeholders with new content.\n *\n * @publicApi\n */\nexport const patchDocument = async <T extends PatchDocumentOutputType = PatchDocumentOutputType>({\n outputType,\n data,\n patches,\n keepOriginalStyles = true,\n placeholderDelimiters = { end: \"}}\", start: \"{{\" } as const,\n recursive = true,\n}: PatchDocumentOptions<T>): Promise<OutputByType[T]> => {\n const zipContent = unzipSync(toUint8Array(data));\n const contexts = new Map<string, BodyContext>();\n const media = new Media();\n const file = { media } as BodyContext[\"file\"];\n\n const map = new Map<string, Element>();\n\n const imageRelationshipAdditions: ImageRelationshipAddition[] = [];\n const hyperlinkRelationshipAdditions: HyperlinkRelationshipAddition[] = [];\n let hasMedia = false;\n\n const binaryContentMap = new Map<string, Uint8Array>();\n\n for (const [key, value] of Object.entries(zipContent)) {\n const startBytes = value.slice(0, 2);\n if (compareByteArrays(startBytes, UTF16LE) || compareByteArrays(startBytes, UTF16BE)) {\n binaryContentMap.set(key, value);\n continue;\n }\n\n if (!key.endsWith(\".xml\") && !key.endsWith(\".rels\")) {\n binaryContentMap.set(key, value);\n continue;\n }\n\n const json = toJson(strFromU8(value));\n\n if (key === \"word/document.xml\") {\n const document = json.elements?.find((i) => i.name === \"w:document\");\n if (document && document.attributes) {\n for (const ns of [\"mc\", \"wp\", \"r\", \"w15\", \"m\"] as const) {\n document.attributes[`xmlns:${ns}`] = DocumentAttributeNamespaces[ns];\n }\n document.attributes[\"mc:Ignorable\"] =\n `${document.attributes[\"mc:Ignorable\"] || \"\"} w15`.trim();\n }\n }\n\n if (key.startsWith(\"word/\") && !key.endsWith(\".xml.rels\")) {\n const hyperlinkSink: Array<{ id: string; link: string }> = [];\n\n const context: BodyContext = {\n fileData: file,\n file,\n viewWrapper: {\n relationships: {\n addRelationship: (\n linkId: string,\n _: string,\n target: string,\n __: (typeof TargetModeType)[keyof typeof TargetModeType],\n ) => {\n hyperlinkRelationshipAdditions.push({\n hyperlink: {\n id: linkId,\n link: target,\n },\n key,\n });\n },\n },\n } as unknown as ViewWrapper,\n stringifyChild: () => \"\",\n addRelationship: () => \"\",\n addMedia: () => \"\",\n };\n contexts.set(key, context);\n\n if (!placeholderDelimiters?.start.trim() || !placeholderDelimiters?.end.trim()) {\n throw new Error(\"Both start and end delimiters must be non-empty strings.\");\n }\n\n const { start, end } = placeholderDelimiters;\n\n // Create compile-path context for stringifying patch children\n const patchCtx = createPatchContext(file, hyperlinkSink);\n currentPatchCtx = patchCtx;\n\n for (const [patchKey, patchValue] of Object.entries(patches)) {\n const patchText = `${start}${patchKey}${end}`;\n while (true) {\n const { didFindOccurrence } = docxReplacer({\n context,\n json,\n keepOriginalStyles,\n patch: patchValue,\n patchText,\n });\n if (!recursive || !didFindOccurrence) {\n break;\n }\n }\n }\n\n // Flush hyperlink relationships captured by the compile-path context\n for (const hl of hyperlinkSink) {\n hyperlinkRelationshipAdditions.push({\n hyperlink: { id: hl.id, link: hl.link },\n key,\n });\n }\n\n const mediaDatas = getReferencedMedia(JSON.stringify(json), media.array);\n if (mediaDatas.length > 0) {\n hasMedia = true;\n imageRelationshipAdditions.push({\n key,\n mediaDatas,\n });\n }\n }\n\n map.set(key, json);\n }\n\n for (const { key, mediaDatas } of imageRelationshipAdditions) {\n const relationshipKey = `word/_rels/${key.split(\"/\").pop()}.rels`;\n const relationshipsJson = map.get(relationshipKey) ?? createRelationshipFile();\n map.set(relationshipKey, relationshipsJson);\n\n const index = getNextRelationshipIndex(relationshipsJson);\n const newJson = replaceImagePlaceholders(\n JSON.stringify(map.get(key)),\n mediaDatas,\n index,\n \"plain\",\n );\n map.set(key, JSON.parse(newJson) as Element);\n\n for (let i = 0; i < mediaDatas.length; i++) {\n const { fileName } = mediaDatas[i];\n appendRelationship(\n relationshipsJson,\n index + i,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image\",\n `media/${fileName}`,\n );\n }\n }\n\n for (const { key, hyperlink } of hyperlinkRelationshipAdditions) {\n const relationshipKey = `word/_rels/${key.split(\"/\").pop()}.rels`;\n\n const relationshipsJson = map.get(relationshipKey) ?? createRelationshipFile();\n map.set(relationshipKey, relationshipsJson);\n\n appendRelationship(\n relationshipsJson,\n hyperlink.id,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\",\n hyperlink.link,\n TargetModeType.EXTERNAL,\n );\n }\n\n if (hasMedia) {\n const contentTypesJson = map.get(\"[Content_Types].xml\");\n\n if (!contentTypesJson) {\n throw new Error(\"Could not find content types file\");\n }\n\n appendContentType(contentTypesJson, \"image/png\", \"png\");\n appendContentType(contentTypesJson, \"image/jpeg\", \"jpeg\");\n appendContentType(contentTypesJson, \"image/jpeg\", \"jpg\");\n appendContentType(contentTypesJson, \"image/bmp\", \"bmp\");\n appendContentType(contentTypesJson, \"image/gif\", \"gif\");\n appendContentType(contentTypesJson, \"image/svg+xml\", \"svg\");\n }\n\n const files: Record<string, Uint8Array> = {};\n\n for (const [key, value] of map) {\n files[key] = encoder.encode(js2xml(value));\n }\n\n for (const [key, value] of binaryContentMap) {\n files[key] = value;\n }\n\n for (const { data: mediaData, fileName } of media.array) {\n files[`word/media/${fileName}`] =\n mediaData instanceof Uint8Array ? mediaData : new Uint8Array(mediaData);\n }\n\n return await zipAndConvert(files, outputType, OoxmlMimeType.DOCX);\n};\n\nconst createRelationshipFile = (): Element => ({\n declaration: {\n attributes: {\n encoding: \"UTF-8\",\n standalone: \"yes\",\n version: \"1.0\",\n },\n },\n elements: [\n {\n attributes: {\n xmlns: \"http://schemas.openxmlformats.org/package/2006/relationships\",\n },\n elements: [],\n name: \"Relationships\",\n type: \"element\",\n },\n ],\n});\n","/**\n * Patch detector for discovering placeholders in document templates.\n *\n * @module\n */\nimport { DOCX_NS, createTraverser, strFromU8, toJson, unzipSync } from \"@office-open/core\";\nimport { toUint8Array } from \"@office-open/core\";\n\nimport type { InputDataType } from \"./from-docx\";\n\n/**\n * Options for patch detection.\n *\n * @property data - The document template to scan for placeholders\n */\ninterface PatchDetectorOptions {\n data: InputDataType;\n}\n\n/**\n * Detects all placeholders present in a document template.\n *\n * Scans through all XML content in a .docx file to find placeholder text\n * enclosed in delimiters (default: {{placeholder}}). This is useful for\n * discovering what patches a template expects before performing replacement.\n *\n * @param options - Patch detector configuration\n * @returns Array of placeholder keys found in the document\n *\n * @example\n * ```typescript\n * const placeholders = await patchDetector({ data: templateBuffer });\n * // Returns: [\"name\", \"date\", \"address\"] if template contains {{name}}, {{date}}, {{address}}\n *\n * // Use detected placeholders to create patches\n * const patches = {};\n * for (const key of placeholders) {\n * patches[key] = {\n * type: PatchType.PARAGRAPH,\n * children: [new TextRun(getUserData(key))],\n * };\n * });\n * ```\n */\nexport const patchDetector = async ({ data }: PatchDetectorOptions): Promise<string[]> => {\n const zipContent = unzipSync(toUint8Array(data));\n const patches = new Set<string>();\n\n for (const [key, value] of Object.entries(zipContent)) {\n if (!key.endsWith(\".xml\") && !key.endsWith(\".rels\")) {\n continue;\n }\n if (key.startsWith(\"word/\") && !key.endsWith(\".xml.rels\")) {\n const json = toJson(strFromU8(value));\n const { traverse } = createTraverser(DOCX_NS);\n for (const p of traverse(json)) {\n for (const patch of findPatchKeys(p.text)) {\n patches.add(patch);\n }\n }\n }\n }\n return [...patches];\n};\n\n/**\n * Extracts placeholder keys from text using regex pattern.\n *\n * @param text - Text to search for placeholders\n * @returns Array of placeholder keys (without delimiters)\n */\nconst findPatchKeys = (text: string): string[] => {\n const pattern = /(?<=\\{\\{).+?(?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;CAC7C,aAAa,EACX,YAAY;EACV,UAAU;EACV,YAAY;EACZ,SAAS;CACX,EACF;CACA,UAAU,CACR;EACE,YAAY,EACV,OAAO,+DACT;EACA,UAAU,CAAC;EACX,MAAM;EACN,MAAM;CACR,CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AClWA,MAAa,gBAAgB,OAAO,EAAE,WAAoD;CACxF,MAAM,aAAa,UAAU,aAAa,IAAI,CAAC;CAC/C,MAAM,0BAAU,IAAI,IAAY;CAEhC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,UAAU,GAAG;EACrD,IAAI,CAAC,IAAI,SAAS,MAAM,KAAK,CAAC,IAAI,SAAS,OAAO,GAChD;EAEF,IAAI,IAAI,WAAW,OAAO,KAAK,CAAC,IAAI,SAAS,WAAW,GAAG;GACzD,MAAM,OAAO,OAAO,UAAU,KAAK,CAAC;GACpC,MAAM,EAAE,aAAa,gBAAgB,OAAO;GAC5C,KAAK,MAAM,KAAK,SAAS,IAAI,GAC3B,KAAK,MAAM,SAAS,cAAc,EAAE,IAAI,GACtC,QAAQ,IAAI,KAAK;EAGvB;CACF;CACA,OAAO,CAAC,GAAG,OAAO;AACpB;;;;;;;AAQA,MAAM,iBAAiB,SAA2B;CAEhD,OAAO,KAAK,MAAM,wBAAO,KAAK,CAAC;AACjC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@office-open/docx",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Generate, parse, and patch .docx documents with a declarative TypeScript API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"clippy",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@office-open/core": "0.9.
|
|
57
|
-
"@office-open/xml": "0.9.
|
|
56
|
+
"@office-open/core": "0.9.2",
|
|
57
|
+
"@office-open/xml": "0.9.2"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"dev": "basis build --stub",
|