@bendyline/squisq-formats 0.1.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.
- package/dist/chunk-532L4D5D.js +21 -0
- package/dist/chunk-532L4D5D.js.map +1 -0
- package/dist/chunk-67KIJHV2.js +21 -0
- package/dist/chunk-67KIJHV2.js.map +1 -0
- package/dist/chunk-KAK4V57E.js +387 -0
- package/dist/chunk-KAK4V57E.js.map +1 -0
- package/dist/chunk-MQHCXI56.js +1035 -0
- package/dist/chunk-MQHCXI56.js.map +1 -0
- package/dist/chunk-TBPD5PCU.js +1136 -0
- package/dist/chunk-TBPD5PCU.js.map +1 -0
- package/dist/chunk-ULLIPBEJ.js +271 -0
- package/dist/chunk-ULLIPBEJ.js.map +1 -0
- package/dist/docx/index.d.ts +108 -0
- package/dist/docx/index.js +14 -0
- package/dist/docx/index.js.map +1 -0
- package/dist/html/index.d.ts +166 -0
- package/dist/html/index.js +17 -0
- package/dist/html/index.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/ooxml/index.d.ts +351 -0
- package/dist/ooxml/index.js +99 -0
- package/dist/ooxml/index.js.map +1 -0
- package/dist/pdf/index.d.ts +130 -0
- package/dist/pdf/index.js +15 -0
- package/dist/pdf/index.js.map +1 -0
- package/dist/pptx/index.d.ts +58 -0
- package/dist/pptx/index.js +13 -0
- package/dist/pptx/index.js.map +1 -0
- package/dist/xlsx/index.d.ts +58 -0
- package/dist/xlsx/index.js +13 -0
- package/dist/xlsx/index.js.map +1 -0
- package/package.json +85 -0
- package/src/__tests__/docxExport.test.ts +457 -0
- package/src/__tests__/docxImport.test.ts +410 -0
- package/src/__tests__/html.test.ts +295 -0
- package/src/__tests__/ooxml.test.ts +197 -0
- package/src/__tests__/pdfExport.test.ts +322 -0
- package/src/__tests__/pdfImport.test.ts +290 -0
- package/src/__tests__/roundTrip.test.ts +201 -0
- package/src/docx/export.ts +978 -0
- package/src/docx/import.ts +909 -0
- package/src/docx/index.ts +26 -0
- package/src/docx/styles.ts +145 -0
- package/src/html/htmlTemplate.ts +307 -0
- package/src/html/imageUtils.ts +66 -0
- package/src/html/index.ts +168 -0
- package/src/index.ts +51 -0
- package/src/ooxml/index.ts +87 -0
- package/src/ooxml/namespaces.ts +160 -0
- package/src/ooxml/reader.ts +218 -0
- package/src/ooxml/types.ts +104 -0
- package/src/ooxml/writer.ts +321 -0
- package/src/ooxml/xmlUtils.ts +123 -0
- package/src/pdf/export.ts +1029 -0
- package/src/pdf/import.ts +835 -0
- package/src/pdf/index.ts +29 -0
- package/src/pdf/styles.ts +180 -0
- package/src/pptx/index.ts +78 -0
- package/src/xlsx/index.ts +78 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/pptx/index.ts
|
|
2
|
+
async function markdownDocToPptx(_doc, _options) {
|
|
3
|
+
throw new Error("PPTX export is not yet implemented");
|
|
4
|
+
}
|
|
5
|
+
async function docToPptx(_doc, _options) {
|
|
6
|
+
throw new Error("PPTX export is not yet implemented");
|
|
7
|
+
}
|
|
8
|
+
async function pptxToMarkdownDoc(_data, _options) {
|
|
9
|
+
throw new Error("PPTX import is not yet implemented");
|
|
10
|
+
}
|
|
11
|
+
async function pptxToDoc(_data, _options) {
|
|
12
|
+
throw new Error("PPTX import is not yet implemented");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
markdownDocToPptx,
|
|
17
|
+
docToPptx,
|
|
18
|
+
pptxToMarkdownDoc,
|
|
19
|
+
pptxToDoc
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=chunk-532L4D5D.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/pptx/index.ts"],"sourcesContent":["/**\n * @bendyline/squisq-formats PPTX Module (Stub)\n *\n * Placeholder for PowerPoint .pptx import/export support.\n * Will use PresentationML (`<p:presentation>`, `<p:sld>`) via the\n * shared ooxml/ infrastructure.\n *\n * @example\n * ```ts\n * import { markdownDocToPptx } from '@bendyline/squisq-formats/pptx';\n * ```\n */\n\nimport type { MarkdownDocument } from '@bendyline/squisq/markdown';\nimport type { Doc } from '@bendyline/squisq/schemas';\n\n/**\n * Options for PPTX export (placeholder).\n */\nexport interface PptxExportOptions {\n /** Presentation title */\n title?: string;\n /** Presentation author */\n author?: string;\n}\n\n/**\n * Options for PPTX import (placeholder).\n */\nexport interface PptxImportOptions {\n /** Whether to extract embedded images as data URIs */\n extractImages?: boolean;\n}\n\n/**\n * Convert a MarkdownDocument to a .pptx Blob.\n *\n * @throws Error — PPTX support is not yet implemented\n */\nexport async function markdownDocToPptx(\n _doc: MarkdownDocument,\n _options?: PptxExportOptions,\n): Promise<Blob> {\n throw new Error('PPTX export is not yet implemented');\n}\n\n/**\n * Convert a squisq Doc to a .pptx Blob.\n *\n * @throws Error — PPTX support is not yet implemented\n */\nexport async function docToPptx(_doc: Doc, _options?: PptxExportOptions): Promise<Blob> {\n throw new Error('PPTX export is not yet implemented');\n}\n\n/**\n * Convert a .pptx file to a MarkdownDocument.\n *\n * @throws Error — PPTX support is not yet implemented\n */\nexport async function pptxToMarkdownDoc(\n _data: ArrayBuffer | Blob,\n _options?: PptxImportOptions,\n): Promise<MarkdownDocument> {\n throw new Error('PPTX import is not yet implemented');\n}\n\n/**\n * Convert a .pptx file to a squisq Doc.\n *\n * @throws Error — PPTX support is not yet implemented\n */\nexport async function pptxToDoc(\n _data: ArrayBuffer | Blob,\n _options?: PptxImportOptions,\n): Promise<Doc> {\n throw new Error('PPTX import is not yet implemented');\n}\n"],"mappings":";AAuCA,eAAsB,kBACpB,MACA,UACe;AACf,QAAM,IAAI,MAAM,oCAAoC;AACtD;AAOA,eAAsB,UAAU,MAAW,UAA6C;AACtF,QAAM,IAAI,MAAM,oCAAoC;AACtD;AAOA,eAAsB,kBACpB,OACA,UAC2B;AAC3B,QAAM,IAAI,MAAM,oCAAoC;AACtD;AAOA,eAAsB,UACpB,OACA,UACc;AACd,QAAM,IAAI,MAAM,oCAAoC;AACtD;","names":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/xlsx/index.ts
|
|
2
|
+
async function markdownDocToXlsx(_doc, _options) {
|
|
3
|
+
throw new Error("XLSX export is not yet implemented");
|
|
4
|
+
}
|
|
5
|
+
async function docToXlsx(_doc, _options) {
|
|
6
|
+
throw new Error("XLSX export is not yet implemented");
|
|
7
|
+
}
|
|
8
|
+
async function xlsxToMarkdownDoc(_data, _options) {
|
|
9
|
+
throw new Error("XLSX import is not yet implemented");
|
|
10
|
+
}
|
|
11
|
+
async function xlsxToDoc(_data, _options) {
|
|
12
|
+
throw new Error("XLSX import is not yet implemented");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
markdownDocToXlsx,
|
|
17
|
+
docToXlsx,
|
|
18
|
+
xlsxToMarkdownDoc,
|
|
19
|
+
xlsxToDoc
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=chunk-67KIJHV2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/xlsx/index.ts"],"sourcesContent":["/**\n * @bendyline/squisq-formats XLSX Module (Stub)\n *\n * Placeholder for Excel .xlsx import/export support.\n * Will use SpreadsheetML (`<spreadsheet>`, `<worksheet>`, `<sheetData>`)\n * via the shared ooxml/ infrastructure.\n *\n * @example\n * ```ts\n * import { markdownDocToXlsx } from '@bendyline/squisq-formats/xlsx';\n * ```\n */\n\nimport type { MarkdownDocument } from '@bendyline/squisq/markdown';\nimport type { Doc } from '@bendyline/squisq/schemas';\n\n/**\n * Options for XLSX export (placeholder).\n */\nexport interface XlsxExportOptions {\n /** Workbook title */\n title?: string;\n /** Workbook author */\n author?: string;\n}\n\n/**\n * Options for XLSX import (placeholder).\n */\nexport interface XlsxImportOptions {\n /** Which sheet to import (0-based index or name). Default: 0 */\n sheet?: number | string;\n}\n\n/**\n * Convert a MarkdownDocument to a .xlsx Blob.\n *\n * @throws Error — XLSX support is not yet implemented\n */\nexport async function markdownDocToXlsx(\n _doc: MarkdownDocument,\n _options?: XlsxExportOptions,\n): Promise<Blob> {\n throw new Error('XLSX export is not yet implemented');\n}\n\n/**\n * Convert a squisq Doc to a .xlsx Blob.\n *\n * @throws Error — XLSX support is not yet implemented\n */\nexport async function docToXlsx(_doc: Doc, _options?: XlsxExportOptions): Promise<Blob> {\n throw new Error('XLSX export is not yet implemented');\n}\n\n/**\n * Convert a .xlsx file to a MarkdownDocument.\n *\n * @throws Error — XLSX support is not yet implemented\n */\nexport async function xlsxToMarkdownDoc(\n _data: ArrayBuffer | Blob,\n _options?: XlsxImportOptions,\n): Promise<MarkdownDocument> {\n throw new Error('XLSX import is not yet implemented');\n}\n\n/**\n * Convert a .xlsx file to a squisq Doc.\n *\n * @throws Error — XLSX support is not yet implemented\n */\nexport async function xlsxToDoc(\n _data: ArrayBuffer | Blob,\n _options?: XlsxImportOptions,\n): Promise<Doc> {\n throw new Error('XLSX import is not yet implemented');\n}\n"],"mappings":";AAuCA,eAAsB,kBACpB,MACA,UACe;AACf,QAAM,IAAI,MAAM,oCAAoC;AACtD;AAOA,eAAsB,UAAU,MAAW,UAA6C;AACtF,QAAM,IAAI,MAAM,oCAAoC;AACtD;AAOA,eAAsB,kBACpB,OACA,UAC2B;AAC3B,QAAM,IAAI,MAAM,oCAAoC;AACtD;AAOA,eAAsB,UACpB,OACA,UACc;AACd,QAAM,IAAI,MAAM,oCAAoC;AACtD;","names":[]}
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
// src/ooxml/namespaces.ts
|
|
2
|
+
var NS_RELATIONSHIPS = "http://schemas.openxmlformats.org/package/2006/relationships";
|
|
3
|
+
var NS_CONTENT_TYPES = "http://schemas.openxmlformats.org/package/2006/content-types";
|
|
4
|
+
var REL_OFFICE_DOCUMENT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument";
|
|
5
|
+
var REL_CORE_PROPERTIES = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
|
|
6
|
+
var REL_EXTENDED_PROPERTIES = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties";
|
|
7
|
+
var REL_STYLES = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles";
|
|
8
|
+
var REL_NUMBERING = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering";
|
|
9
|
+
var REL_FONT_TABLE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable";
|
|
10
|
+
var REL_SETTINGS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings";
|
|
11
|
+
var REL_HYPERLINK = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
|
|
12
|
+
var REL_IMAGE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
|
|
13
|
+
var REL_FOOTNOTES = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes";
|
|
14
|
+
var REL_THEME = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
|
|
15
|
+
var NS_WML = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
|
|
16
|
+
var NS_PML = "http://schemas.openxmlformats.org/presentationml/2006/main";
|
|
17
|
+
var NS_SML = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
|
|
18
|
+
var NS_DRAWINGML = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
19
|
+
var NS_WP_DRAWING = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing";
|
|
20
|
+
var NS_PICTURE = "http://schemas.openxmlformats.org/drawingml/2006/picture";
|
|
21
|
+
var NS_DC = "http://purl.org/dc/elements/1.1/";
|
|
22
|
+
var NS_DCTERMS = "http://purl.org/dc/terms/";
|
|
23
|
+
var NS_CORE_PROPERTIES = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties";
|
|
24
|
+
var NS_XSI = "http://www.w3.org/2001/XMLSchema-instance";
|
|
25
|
+
var NS_MC = "http://schemas.openxmlformats.org/markup-compatibility/2006";
|
|
26
|
+
var NS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
27
|
+
var CONTENT_TYPE_RELATIONSHIPS = "application/vnd.openxmlformats-package.relationships+xml";
|
|
28
|
+
var CONTENT_TYPE_CORE_PROPERTIES = "application/vnd.openxmlformats-package.core-properties+xml";
|
|
29
|
+
var CONTENT_TYPE_DOCX_DOCUMENT = "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml";
|
|
30
|
+
var CONTENT_TYPE_DOCX_STYLES = "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";
|
|
31
|
+
var CONTENT_TYPE_DOCX_NUMBERING = "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml";
|
|
32
|
+
var CONTENT_TYPE_DOCX_SETTINGS = "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml";
|
|
33
|
+
var CONTENT_TYPE_DOCX_FONT_TABLE = "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml";
|
|
34
|
+
var CONTENT_TYPE_DOCX_FOOTNOTES = "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml";
|
|
35
|
+
var CONTENT_TYPE_PPTX_PRESENTATION = "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml";
|
|
36
|
+
var CONTENT_TYPE_XLSX_WORKBOOK = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml";
|
|
37
|
+
|
|
38
|
+
// src/ooxml/xmlUtils.ts
|
|
39
|
+
function xmlDeclaration() {
|
|
40
|
+
return '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
|
|
41
|
+
}
|
|
42
|
+
function escapeXml(text) {
|
|
43
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
44
|
+
}
|
|
45
|
+
function attrString(attrs) {
|
|
46
|
+
if (!attrs) return "";
|
|
47
|
+
const parts = [];
|
|
48
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
49
|
+
if (value !== void 0 && value !== "") {
|
|
50
|
+
parts.push(` ${key}="${escapeXml(value)}"`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return parts.join("");
|
|
54
|
+
}
|
|
55
|
+
function selfClosingElement(tag, attrs) {
|
|
56
|
+
return `<${tag}${attrString(attrs)}/>`;
|
|
57
|
+
}
|
|
58
|
+
function xmlElement(tag, attrs, ...children) {
|
|
59
|
+
const content = children.join("");
|
|
60
|
+
if (content === "") {
|
|
61
|
+
return selfClosingElement(tag, attrs);
|
|
62
|
+
}
|
|
63
|
+
return `<${tag}${attrString(attrs)}>${content}</${tag}>`;
|
|
64
|
+
}
|
|
65
|
+
function textElement(tag, attrs, text) {
|
|
66
|
+
if (text === void 0 || text === "") {
|
|
67
|
+
return selfClosingElement(tag, attrs);
|
|
68
|
+
}
|
|
69
|
+
return `<${tag}${attrString(attrs)}>${escapeXml(text)}</${tag}>`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/ooxml/writer.ts
|
|
73
|
+
import JSZip from "jszip";
|
|
74
|
+
function createPackage() {
|
|
75
|
+
const parts = [];
|
|
76
|
+
const relationships = [];
|
|
77
|
+
let coreProps;
|
|
78
|
+
return {
|
|
79
|
+
addPart(path, content, contentType) {
|
|
80
|
+
parts.push({ path, content, contentType });
|
|
81
|
+
},
|
|
82
|
+
addBinaryPart(path, data, contentType) {
|
|
83
|
+
parts.push({ path, binaryContent: data, contentType });
|
|
84
|
+
},
|
|
85
|
+
addRelationship(sourcePart, rel) {
|
|
86
|
+
relationships.push({ sourcePart, relationship: rel });
|
|
87
|
+
},
|
|
88
|
+
setCoreProperties(props) {
|
|
89
|
+
coreProps = props;
|
|
90
|
+
},
|
|
91
|
+
async toBlob() {
|
|
92
|
+
const zip = assemble(parts, relationships, coreProps);
|
|
93
|
+
return zip.generateAsync({ type: "blob" });
|
|
94
|
+
},
|
|
95
|
+
async toArrayBuffer() {
|
|
96
|
+
const zip = assemble(parts, relationships, coreProps);
|
|
97
|
+
return zip.generateAsync({ type: "arraybuffer" });
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function assemble(parts, relationships, coreProps) {
|
|
102
|
+
const zip = new JSZip();
|
|
103
|
+
for (const part of parts) {
|
|
104
|
+
if (part.content !== void 0) {
|
|
105
|
+
zip.file(part.path, part.content);
|
|
106
|
+
} else if (part.binaryContent !== void 0) {
|
|
107
|
+
zip.file(part.path, part.binaryContent);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (coreProps) {
|
|
111
|
+
const coreXml = buildCorePropertiesXml(coreProps);
|
|
112
|
+
zip.file("docProps/core.xml", coreXml);
|
|
113
|
+
relationships.push({
|
|
114
|
+
sourcePart: "",
|
|
115
|
+
relationship: {
|
|
116
|
+
id: `rId${relationships.length + 100}`,
|
|
117
|
+
type: REL_CORE_PROPERTIES,
|
|
118
|
+
target: "docProps/core.xml"
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
zip.file("[Content_Types].xml", buildContentTypesXml(parts, coreProps));
|
|
123
|
+
const relsBySource = groupRelationshipsBySource(relationships);
|
|
124
|
+
for (const [sourcePart, rels] of relsBySource) {
|
|
125
|
+
const relsPath = sourcePart === "" ? "_rels/.rels" : buildRelsPath(sourcePart);
|
|
126
|
+
zip.file(relsPath, buildRelationshipsXml(rels));
|
|
127
|
+
}
|
|
128
|
+
return zip;
|
|
129
|
+
}
|
|
130
|
+
function buildContentTypesXml(parts, coreProps) {
|
|
131
|
+
const lines = [xmlDeclaration()];
|
|
132
|
+
lines.push(`<Types xmlns="${NS_CONTENT_TYPES}">`);
|
|
133
|
+
const extensionTypes = /* @__PURE__ */ new Map();
|
|
134
|
+
extensionTypes.set("rels", CONTENT_TYPE_RELATIONSHIPS);
|
|
135
|
+
extensionTypes.set("xml", "application/xml");
|
|
136
|
+
for (const part of parts) {
|
|
137
|
+
if (part.binaryContent !== void 0) {
|
|
138
|
+
const ext = getExtension(part.path);
|
|
139
|
+
if (ext && !extensionTypes.has(ext)) {
|
|
140
|
+
extensionTypes.set(ext, part.contentType);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
for (const [ext, ct] of extensionTypes) {
|
|
145
|
+
lines.push(` <Default Extension="${escapeXml(ext)}" ContentType="${escapeXml(ct)}"/>`);
|
|
146
|
+
}
|
|
147
|
+
for (const part of parts) {
|
|
148
|
+
if (part.content !== void 0) {
|
|
149
|
+
lines.push(
|
|
150
|
+
` <Override PartName="/${escapeXml(part.path)}" ContentType="${escapeXml(part.contentType)}"/>`
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (coreProps) {
|
|
155
|
+
lines.push(
|
|
156
|
+
` <Override PartName="/docProps/core.xml" ContentType="${CONTENT_TYPE_CORE_PROPERTIES}"/>`
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
lines.push("</Types>");
|
|
160
|
+
return lines.join("\n");
|
|
161
|
+
}
|
|
162
|
+
function buildRelationshipsXml(rels) {
|
|
163
|
+
const lines = [xmlDeclaration()];
|
|
164
|
+
lines.push(`<Relationships xmlns="${NS_RELATIONSHIPS}">`);
|
|
165
|
+
for (const rel of rels) {
|
|
166
|
+
const attrs = [
|
|
167
|
+
`Id="${escapeXml(rel.id)}"`,
|
|
168
|
+
`Type="${escapeXml(rel.type)}"`,
|
|
169
|
+
`Target="${escapeXml(rel.target)}"`
|
|
170
|
+
];
|
|
171
|
+
if (rel.targetMode) {
|
|
172
|
+
attrs.push(`TargetMode="${escapeXml(rel.targetMode)}"`);
|
|
173
|
+
}
|
|
174
|
+
lines.push(` <Relationship ${attrs.join(" ")}/>`);
|
|
175
|
+
}
|
|
176
|
+
lines.push("</Relationships>");
|
|
177
|
+
return lines.join("\n");
|
|
178
|
+
}
|
|
179
|
+
function buildCorePropertiesXml(props) {
|
|
180
|
+
const lines = [xmlDeclaration()];
|
|
181
|
+
lines.push(
|
|
182
|
+
`<cp:coreProperties xmlns:cp="${NS_CORE_PROPERTIES}" xmlns:dc="${NS_DC}" xmlns:dcterms="${NS_DCTERMS}" xmlns:xsi="${NS_XSI}">`
|
|
183
|
+
);
|
|
184
|
+
if (props.title) lines.push(` <dc:title>${escapeXml(props.title)}</dc:title>`);
|
|
185
|
+
if (props.subject) lines.push(` <dc:subject>${escapeXml(props.subject)}</dc:subject>`);
|
|
186
|
+
if (props.creator) lines.push(` <dc:creator>${escapeXml(props.creator)}</dc:creator>`);
|
|
187
|
+
if (props.description)
|
|
188
|
+
lines.push(` <dc:description>${escapeXml(props.description)}</dc:description>`);
|
|
189
|
+
if (props.keywords) lines.push(` <cp:keywords>${escapeXml(props.keywords)}</cp:keywords>`);
|
|
190
|
+
if (props.lastModifiedBy)
|
|
191
|
+
lines.push(` <cp:lastModifiedBy>${escapeXml(props.lastModifiedBy)}</cp:lastModifiedBy>`);
|
|
192
|
+
if (props.revision) lines.push(` <cp:revision>${escapeXml(props.revision)}</cp:revision>`);
|
|
193
|
+
if (props.created) {
|
|
194
|
+
lines.push(
|
|
195
|
+
` <dcterms:created xsi:type="dcterms:W3CDTF">${escapeXml(props.created)}</dcterms:created>`
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
if (props.modified) {
|
|
199
|
+
lines.push(
|
|
200
|
+
` <dcterms:modified xsi:type="dcterms:W3CDTF">${escapeXml(props.modified)}</dcterms:modified>`
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
lines.push("</cp:coreProperties>");
|
|
204
|
+
return lines.join("\n");
|
|
205
|
+
}
|
|
206
|
+
function getExtension(path) {
|
|
207
|
+
const dot = path.lastIndexOf(".");
|
|
208
|
+
if (dot === -1) return void 0;
|
|
209
|
+
return path.substring(dot + 1).toLowerCase();
|
|
210
|
+
}
|
|
211
|
+
function buildRelsPath(partPath) {
|
|
212
|
+
const lastSlash = partPath.lastIndexOf("/");
|
|
213
|
+
if (lastSlash === -1) {
|
|
214
|
+
return `_rels/${partPath}.rels`;
|
|
215
|
+
}
|
|
216
|
+
const dir = partPath.substring(0, lastSlash);
|
|
217
|
+
const file = partPath.substring(lastSlash + 1);
|
|
218
|
+
return `${dir}/_rels/${file}.rels`;
|
|
219
|
+
}
|
|
220
|
+
function groupRelationshipsBySource(pending) {
|
|
221
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
222
|
+
for (const { sourcePart, relationship } of pending) {
|
|
223
|
+
let list = grouped.get(sourcePart);
|
|
224
|
+
if (!list) {
|
|
225
|
+
list = [];
|
|
226
|
+
grouped.set(sourcePart, list);
|
|
227
|
+
}
|
|
228
|
+
list.push(relationship);
|
|
229
|
+
}
|
|
230
|
+
return grouped;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// src/ooxml/reader.ts
|
|
234
|
+
import JSZip2 from "jszip";
|
|
235
|
+
async function openPackage(data) {
|
|
236
|
+
const zip = await JSZip2.loadAsync(data);
|
|
237
|
+
const contentTypes = await parseContentTypes(zip);
|
|
238
|
+
const rootRelationships = await parseRelationships(zip, "");
|
|
239
|
+
return { zip, contentTypes, rootRelationships };
|
|
240
|
+
}
|
|
241
|
+
async function parseContentTypes(zip) {
|
|
242
|
+
const overrides = /* @__PURE__ */ new Map();
|
|
243
|
+
const defaults = /* @__PURE__ */ new Map();
|
|
244
|
+
const file = zip.file("[Content_Types].xml");
|
|
245
|
+
if (!file) return { overrides, defaults };
|
|
246
|
+
const text = await file.async("text");
|
|
247
|
+
const doc = new DOMParser().parseFromString(text, "application/xml");
|
|
248
|
+
const defaultEls = doc.getElementsByTagName("Default");
|
|
249
|
+
for (let i = 0; i < defaultEls.length; i++) {
|
|
250
|
+
const el = defaultEls[i];
|
|
251
|
+
const ext = el.getAttribute("Extension");
|
|
252
|
+
const ct = el.getAttribute("ContentType");
|
|
253
|
+
if (ext && ct) defaults.set(ext, ct);
|
|
254
|
+
}
|
|
255
|
+
const overrideEls = doc.getElementsByTagName("Override");
|
|
256
|
+
for (let i = 0; i < overrideEls.length; i++) {
|
|
257
|
+
const el = overrideEls[i];
|
|
258
|
+
const partName = el.getAttribute("PartName");
|
|
259
|
+
const ct = el.getAttribute("ContentType");
|
|
260
|
+
if (partName && ct) {
|
|
261
|
+
overrides.set(partName.replace(/^\//, ""), ct);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return { overrides, defaults };
|
|
265
|
+
}
|
|
266
|
+
async function getPartRelationships(pkg, partPath) {
|
|
267
|
+
return parseRelationships(pkg.zip, partPath);
|
|
268
|
+
}
|
|
269
|
+
async function parseRelationships(zip, partPath) {
|
|
270
|
+
const relsPath = partPath === "" ? "_rels/.rels" : buildRelsPath2(partPath);
|
|
271
|
+
const file = zip.file(relsPath);
|
|
272
|
+
if (!file) return [];
|
|
273
|
+
const text = await file.async("text");
|
|
274
|
+
const doc = new DOMParser().parseFromString(text, "application/xml");
|
|
275
|
+
const result = [];
|
|
276
|
+
const els = doc.getElementsByTagNameNS(NS_RELATIONSHIPS, "Relationship");
|
|
277
|
+
const fallbackEls = els.length > 0 ? els : doc.getElementsByTagName("Relationship");
|
|
278
|
+
for (let i = 0; i < fallbackEls.length; i++) {
|
|
279
|
+
const el = fallbackEls[i];
|
|
280
|
+
const id = el.getAttribute("Id");
|
|
281
|
+
const type = el.getAttribute("Type");
|
|
282
|
+
const target = el.getAttribute("Target");
|
|
283
|
+
if (id && type && target) {
|
|
284
|
+
const targetMode = el.getAttribute("TargetMode");
|
|
285
|
+
result.push({
|
|
286
|
+
id,
|
|
287
|
+
type,
|
|
288
|
+
target,
|
|
289
|
+
...targetMode ? { targetMode } : {}
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return result;
|
|
294
|
+
}
|
|
295
|
+
function buildRelsPath2(partPath) {
|
|
296
|
+
const lastSlash = partPath.lastIndexOf("/");
|
|
297
|
+
if (lastSlash === -1) {
|
|
298
|
+
return `_rels/${partPath}.rels`;
|
|
299
|
+
}
|
|
300
|
+
const dir = partPath.substring(0, lastSlash);
|
|
301
|
+
const file = partPath.substring(lastSlash + 1);
|
|
302
|
+
return `${dir}/_rels/${file}.rels`;
|
|
303
|
+
}
|
|
304
|
+
async function getPartXml(pkg, partPath) {
|
|
305
|
+
const file = pkg.zip.file(partPath);
|
|
306
|
+
if (!file) return null;
|
|
307
|
+
const text = await file.async("text");
|
|
308
|
+
return new DOMParser().parseFromString(text, "application/xml");
|
|
309
|
+
}
|
|
310
|
+
async function getPartBinary(pkg, partPath) {
|
|
311
|
+
const file = pkg.zip.file(partPath);
|
|
312
|
+
if (!file) return null;
|
|
313
|
+
return file.async("arraybuffer");
|
|
314
|
+
}
|
|
315
|
+
async function getCoreProperties(pkg) {
|
|
316
|
+
const doc = await getPartXml(pkg, "docProps/core.xml");
|
|
317
|
+
if (!doc) return {};
|
|
318
|
+
function getText(ns, localName) {
|
|
319
|
+
const els = doc.getElementsByTagNameNS(ns, localName);
|
|
320
|
+
if (els.length > 0 && els[0].textContent) {
|
|
321
|
+
return els[0].textContent;
|
|
322
|
+
}
|
|
323
|
+
return void 0;
|
|
324
|
+
}
|
|
325
|
+
return {
|
|
326
|
+
title: getText(NS_DC, "title"),
|
|
327
|
+
subject: getText(NS_DC, "subject"),
|
|
328
|
+
creator: getText(NS_DC, "creator"),
|
|
329
|
+
description: getText(NS_DC, "description"),
|
|
330
|
+
keywords: getText(NS_CORE_PROPERTIES, "keywords"),
|
|
331
|
+
lastModifiedBy: getText(NS_CORE_PROPERTIES, "lastModifiedBy"),
|
|
332
|
+
revision: getText(NS_CORE_PROPERTIES, "revision"),
|
|
333
|
+
created: getText(NS_DCTERMS, "created"),
|
|
334
|
+
modified: getText(NS_DCTERMS, "modified")
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export {
|
|
339
|
+
NS_RELATIONSHIPS,
|
|
340
|
+
NS_CONTENT_TYPES,
|
|
341
|
+
REL_OFFICE_DOCUMENT,
|
|
342
|
+
REL_CORE_PROPERTIES,
|
|
343
|
+
REL_EXTENDED_PROPERTIES,
|
|
344
|
+
REL_STYLES,
|
|
345
|
+
REL_NUMBERING,
|
|
346
|
+
REL_FONT_TABLE,
|
|
347
|
+
REL_SETTINGS,
|
|
348
|
+
REL_HYPERLINK,
|
|
349
|
+
REL_IMAGE,
|
|
350
|
+
REL_FOOTNOTES,
|
|
351
|
+
REL_THEME,
|
|
352
|
+
NS_WML,
|
|
353
|
+
NS_PML,
|
|
354
|
+
NS_SML,
|
|
355
|
+
NS_DRAWINGML,
|
|
356
|
+
NS_WP_DRAWING,
|
|
357
|
+
NS_PICTURE,
|
|
358
|
+
NS_DC,
|
|
359
|
+
NS_DCTERMS,
|
|
360
|
+
NS_CORE_PROPERTIES,
|
|
361
|
+
NS_XSI,
|
|
362
|
+
NS_MC,
|
|
363
|
+
NS_R,
|
|
364
|
+
CONTENT_TYPE_RELATIONSHIPS,
|
|
365
|
+
CONTENT_TYPE_CORE_PROPERTIES,
|
|
366
|
+
CONTENT_TYPE_DOCX_DOCUMENT,
|
|
367
|
+
CONTENT_TYPE_DOCX_STYLES,
|
|
368
|
+
CONTENT_TYPE_DOCX_NUMBERING,
|
|
369
|
+
CONTENT_TYPE_DOCX_SETTINGS,
|
|
370
|
+
CONTENT_TYPE_DOCX_FONT_TABLE,
|
|
371
|
+
CONTENT_TYPE_DOCX_FOOTNOTES,
|
|
372
|
+
CONTENT_TYPE_PPTX_PRESENTATION,
|
|
373
|
+
CONTENT_TYPE_XLSX_WORKBOOK,
|
|
374
|
+
xmlDeclaration,
|
|
375
|
+
escapeXml,
|
|
376
|
+
attrString,
|
|
377
|
+
selfClosingElement,
|
|
378
|
+
xmlElement,
|
|
379
|
+
textElement,
|
|
380
|
+
createPackage,
|
|
381
|
+
openPackage,
|
|
382
|
+
getPartRelationships,
|
|
383
|
+
getPartXml,
|
|
384
|
+
getPartBinary,
|
|
385
|
+
getCoreProperties
|
|
386
|
+
};
|
|
387
|
+
//# sourceMappingURL=chunk-KAK4V57E.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ooxml/namespaces.ts","../src/ooxml/xmlUtils.ts","../src/ooxml/writer.ts","../src/ooxml/reader.ts"],"sourcesContent":["/**\n * OOXML Namespace Constants\n *\n * All Office Open XML namespace URIs used across DOCX, PPTX, and XLSX.\n * Organized by category for easy reference.\n */\n\n// ============================================\n// Package-level namespaces (shared by all formats)\n// ============================================\n\n/** Relationships namespace (used in _rels/*.rels files) */\nexport const NS_RELATIONSHIPS = 'http://schemas.openxmlformats.org/package/2006/relationships';\n\n/** Content Types namespace ([Content_Types].xml) */\nexport const NS_CONTENT_TYPES = 'http://schemas.openxmlformats.org/package/2006/content-types';\n\n// ============================================\n// Relationship type URIs\n// ============================================\n\n/** Relationship type: Office document (main part) */\nexport const REL_OFFICE_DOCUMENT =\n 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument';\n\n/** Relationship type: Core properties */\nexport const REL_CORE_PROPERTIES =\n 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties';\n\n/** Relationship type: Extended properties (app.xml) */\nexport const REL_EXTENDED_PROPERTIES =\n 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties';\n\n/** Relationship type: Styles */\nexport const REL_STYLES =\n 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles';\n\n/** Relationship type: Numbering */\nexport const REL_NUMBERING =\n 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering';\n\n/** Relationship type: Font table */\nexport const REL_FONT_TABLE =\n 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable';\n\n/** Relationship type: Settings */\nexport const REL_SETTINGS =\n 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings';\n\n/** Relationship type: Hyperlink */\nexport const REL_HYPERLINK =\n 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink';\n\n/** Relationship type: Image */\nexport const REL_IMAGE =\n 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image';\n\n/** Relationship type: Footnotes */\nexport const REL_FOOTNOTES =\n 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes';\n\n/** Relationship type: Theme */\nexport const REL_THEME =\n 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme';\n\n// ============================================\n// WordprocessingML (DOCX)\n// ============================================\n\n/** WordprocessingML main namespace (w:) */\nexport const NS_WML = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';\n\n// ============================================\n// PresentationML (PPTX)\n// ============================================\n\n/** PresentationML main namespace (p:) */\nexport const NS_PML = 'http://schemas.openxmlformats.org/presentationml/2006/main';\n\n// ============================================\n// SpreadsheetML (XLSX)\n// ============================================\n\n/** SpreadsheetML main namespace */\nexport const NS_SML = 'http://schemas.openxmlformats.org/spreadsheetml/2006/main';\n\n// ============================================\n// DrawingML (shared across formats)\n// ============================================\n\n/** DrawingML main namespace (a:) */\nexport const NS_DRAWINGML = 'http://schemas.openxmlformats.org/drawingml/2006/main';\n\n/** DrawingML WordprocessingML drawing namespace (wp:) */\nexport const NS_WP_DRAWING =\n 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing';\n\n/** DrawingML picture namespace (pic:) */\nexport const NS_PICTURE = 'http://schemas.openxmlformats.org/drawingml/2006/picture';\n\n// ============================================\n// Dublin Core / Core Properties\n// ============================================\n\n/** Dublin Core elements namespace */\nexport const NS_DC = 'http://purl.org/dc/elements/1.1/';\n\n/** Dublin Core terms namespace */\nexport const NS_DCTERMS = 'http://purl.org/dc/terms/';\n\n/** Core properties namespace */\nexport const NS_CORE_PROPERTIES =\n 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties';\n\n/** XML Schema Instance namespace */\nexport const NS_XSI = 'http://www.w3.org/2001/XMLSchema-instance';\n\n// ============================================\n// Markup Compatibility\n// ============================================\n\n/** Markup Compatibility namespace (mc:) */\nexport const NS_MC = 'http://schemas.openxmlformats.org/markup-compatibility/2006';\n\n/** Office relationships namespace (r:) */\nexport const NS_R = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships';\n\n// ============================================\n// Content type strings\n// ============================================\n\nexport const CONTENT_TYPE_RELATIONSHIPS =\n 'application/vnd.openxmlformats-package.relationships+xml';\n\nexport const CONTENT_TYPE_CORE_PROPERTIES =\n 'application/vnd.openxmlformats-package.core-properties+xml';\n\nexport const CONTENT_TYPE_DOCX_DOCUMENT =\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml';\n\nexport const CONTENT_TYPE_DOCX_STYLES =\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml';\n\nexport const CONTENT_TYPE_DOCX_NUMBERING =\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml';\n\nexport const CONTENT_TYPE_DOCX_SETTINGS =\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml';\n\nexport const CONTENT_TYPE_DOCX_FONT_TABLE =\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml';\n\nexport const CONTENT_TYPE_DOCX_FOOTNOTES =\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml';\n\nexport const CONTENT_TYPE_PPTX_PRESENTATION =\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml';\n\nexport const CONTENT_TYPE_XLSX_WORKBOOK =\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml';\n","/**\n * XML Utility Functions\n *\n * Lightweight helpers for generating well-formed XML strings.\n * Used by all OOXML writers (DOCX, PPTX, XLSX) to construct\n * part content without a heavy DOM library.\n */\n\n/**\n * XML declaration for the start of every OOXML part.\n */\nexport function xmlDeclaration(): string {\n return '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>';\n}\n\n/**\n * Escape a string for safe inclusion in XML text content or attribute values.\n *\n * Handles the five predefined XML entities:\n * - & → &\n * - < → <\n * - > → >\n * - \" → "\n * - ' → '\n */\nexport function escapeXml(text: string): string {\n return text\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''');\n}\n\n/**\n * Build an XML attribute string from a key-value record.\n * Only includes entries where the value is defined and non-empty.\n *\n * @example\n * ```ts\n * attrString({ 'w:val': 'Heading1', 'w:eastAsia': undefined })\n * // ' w:val=\"Heading1\"'\n * ```\n */\nexport function attrString(attrs?: Record<string, string | undefined>): string {\n if (!attrs) return '';\n const parts: string[] = [];\n for (const [key, value] of Object.entries(attrs)) {\n if (value !== undefined && value !== '') {\n parts.push(` ${key}=\"${escapeXml(value)}\"`);\n }\n }\n return parts.join('');\n}\n\n/**\n * Build a self-closing XML element: `<tag attr=\"val\"/>`.\n *\n * @example\n * ```ts\n * selfClosingElement('w:b')\n * // '<w:b/>'\n *\n * selfClosingElement('w:pStyle', { 'w:val': 'Heading1' })\n * // '<w:pStyle w:val=\"Heading1\"/>'\n * ```\n */\nexport function selfClosingElement(\n tag: string,\n attrs?: Record<string, string | undefined>,\n): string {\n return `<${tag}${attrString(attrs)}/>`;\n}\n\n/**\n * Build an XML element with children: `<tag attr=\"val\">...children...</tag>`.\n * Children are concatenated directly (no extra whitespace).\n *\n * @example\n * ```ts\n * xmlElement('w:p', {},\n * xmlElement('w:r', {},\n * xmlElement('w:t', {}, 'Hello')\n * )\n * )\n * // '<w:p><w:r><w:t>Hello</w:t></w:r></w:p>'\n * ```\n */\nexport function xmlElement(\n tag: string,\n attrs?: Record<string, string | undefined>,\n ...children: string[]\n): string {\n const content = children.join('');\n if (content === '') {\n return selfClosingElement(tag, attrs);\n }\n return `<${tag}${attrString(attrs)}>${content}</${tag}>`;\n}\n\n/**\n * Build an XML text element: `<tag attr=\"val\">escaped text</tag>`.\n * The text value is XML-escaped automatically.\n *\n * This is a convenience for the common pattern of wrapping text in an element,\n * where you want automatic escaping (unlike `xmlElement` which takes raw children).\n *\n * @example\n * ```ts\n * textElement('w:t', { 'xml:space': 'preserve' }, 'Hello & world')\n * // '<w:t xml:space=\"preserve\">Hello & world</w:t>'\n * ```\n */\nexport function textElement(\n tag: string,\n attrs?: Record<string, string | undefined>,\n text?: string,\n): string {\n if (text === undefined || text === '') {\n return selfClosingElement(tag, attrs);\n }\n return `<${tag}${attrString(attrs)}>${escapeXml(text)}</${tag}>`;\n}\n","/**\n * OOXML Package Writer\n *\n * Builds OOXML archives (.docx, .pptx, .xlsx) from parts.\n * Handles automatic generation of [Content_Types].xml and\n * _rels/*.rels files from the registered parts and relationships.\n */\n\nimport JSZip from 'jszip';\nimport type { CoreProperties, PackagePart, PendingRelationship, Relationship } from './types.js';\nimport {\n NS_CONTENT_TYPES,\n NS_RELATIONSHIPS,\n NS_CORE_PROPERTIES,\n NS_DC,\n NS_DCTERMS,\n NS_XSI,\n CONTENT_TYPE_RELATIONSHIPS,\n CONTENT_TYPE_CORE_PROPERTIES,\n REL_CORE_PROPERTIES,\n} from './namespaces.js';\nimport { xmlDeclaration, escapeXml } from './xmlUtils.js';\n\n// ============================================\n// Package Builder\n// ============================================\n\n/**\n * Mutable builder for constructing an OOXML package.\n *\n * Add parts, relationships, and core properties, then call `toBlob()`\n * or `toArrayBuffer()` to produce the final ZIP archive.\n *\n * @example\n * ```ts\n * const builder = createPackage();\n * builder.addPart('word/document.xml', documentXml, CONTENT_TYPE_DOCX_DOCUMENT);\n * builder.addRelationship('', {\n * id: 'rId1',\n * type: REL_OFFICE_DOCUMENT,\n * target: 'word/document.xml',\n * });\n * const blob = await builder.toBlob();\n * ```\n */\nexport interface OoxmlPackageBuilder {\n /**\n * Add an XML or text part to the package.\n *\n * @param path - Path within the archive (e.g., \"word/document.xml\")\n * @param content - XML string content\n * @param contentType - MIME content type for [Content_Types].xml\n */\n addPart(path: string, content: string, contentType: string): void;\n\n /**\n * Add a binary part to the package (e.g., an image).\n *\n * @param path - Path within the archive (e.g., \"word/media/image1.png\")\n * @param data - Binary content\n * @param contentType - MIME content type (e.g., \"image/png\")\n */\n addBinaryPart(path: string, data: ArrayBuffer | Uint8Array, contentType: string): void;\n\n /**\n * Register a relationship.\n *\n * @param sourcePart - The part this relationship belongs to (e.g., \"word/document.xml\").\n * Use \"\" (empty string) for root-level relationships (_rels/.rels).\n * @param rel - The relationship entry\n */\n addRelationship(sourcePart: string, rel: Relationship): void;\n\n /**\n * Set core document properties (docProps/core.xml).\n * Calling this multiple times overwrites previous values.\n */\n setCoreProperties(props: CoreProperties): void;\n\n /**\n * Assemble the final OOXML package as a Blob.\n * Generates [Content_Types].xml and all _rels/*.rels files automatically.\n */\n toBlob(): Promise<Blob>;\n\n /**\n * Assemble the final OOXML package as an ArrayBuffer.\n */\n toArrayBuffer(): Promise<ArrayBuffer>;\n}\n\n/**\n * Create a new OOXML package builder.\n */\nexport function createPackage(): OoxmlPackageBuilder {\n const parts: PackagePart[] = [];\n const relationships: PendingRelationship[] = [];\n let coreProps: CoreProperties | undefined;\n\n return {\n addPart(path, content, contentType) {\n parts.push({ path, content, contentType });\n },\n\n addBinaryPart(path, data, contentType) {\n parts.push({ path, binaryContent: data, contentType });\n },\n\n addRelationship(sourcePart, rel) {\n relationships.push({ sourcePart, relationship: rel });\n },\n\n setCoreProperties(props) {\n coreProps = props;\n },\n\n async toBlob() {\n const zip = assemble(parts, relationships, coreProps);\n return zip.generateAsync({ type: 'blob' });\n },\n\n async toArrayBuffer() {\n const zip = assemble(parts, relationships, coreProps);\n return zip.generateAsync({ type: 'arraybuffer' });\n },\n };\n}\n\n// ============================================\n// Assembly\n// ============================================\n\n/**\n * Assemble a JSZip archive from parts, relationships, and core properties.\n */\nfunction assemble(\n parts: PackagePart[],\n relationships: PendingRelationship[],\n coreProps?: CoreProperties,\n): JSZip {\n const zip = new JSZip();\n\n // Write content parts\n for (const part of parts) {\n if (part.content !== undefined) {\n zip.file(part.path, part.content);\n } else if (part.binaryContent !== undefined) {\n zip.file(part.path, part.binaryContent);\n }\n }\n\n // Add core properties if set\n if (coreProps) {\n const coreXml = buildCorePropertiesXml(coreProps);\n zip.file('docProps/core.xml', coreXml);\n\n // Add relationship to core properties\n relationships.push({\n sourcePart: '',\n relationship: {\n id: `rId${relationships.length + 100}`,\n type: REL_CORE_PROPERTIES,\n target: 'docProps/core.xml',\n },\n });\n }\n\n // Build and write [Content_Types].xml\n zip.file('[Content_Types].xml', buildContentTypesXml(parts, coreProps));\n\n // Build and write _rels/*.rels files\n const relsBySource = groupRelationshipsBySource(relationships);\n for (const [sourcePart, rels] of relsBySource) {\n const relsPath = sourcePart === '' ? '_rels/.rels' : buildRelsPath(sourcePart);\n zip.file(relsPath, buildRelationshipsXml(rels));\n }\n\n return zip;\n}\n\n// ============================================\n// [Content_Types].xml\n// ============================================\n\nfunction buildContentTypesXml(parts: PackagePart[], coreProps?: CoreProperties): string {\n const lines: string[] = [xmlDeclaration()];\n lines.push(`<Types xmlns=\"${NS_CONTENT_TYPES}\">`);\n\n // Default extension types\n const extensionTypes = new Map<string, string>();\n extensionTypes.set('rels', CONTENT_TYPE_RELATIONSHIPS);\n extensionTypes.set('xml', 'application/xml');\n\n // Collect extensions from binary parts (e.g., png, jpeg)\n for (const part of parts) {\n if (part.binaryContent !== undefined) {\n const ext = getExtension(part.path);\n if (ext && !extensionTypes.has(ext)) {\n extensionTypes.set(ext, part.contentType);\n }\n }\n }\n\n for (const [ext, ct] of extensionTypes) {\n lines.push(` <Default Extension=\"${escapeXml(ext)}\" ContentType=\"${escapeXml(ct)}\"/>`);\n }\n\n // Override entries for each XML part\n for (const part of parts) {\n if (part.content !== undefined) {\n lines.push(\n ` <Override PartName=\"/${escapeXml(part.path)}\" ContentType=\"${escapeXml(part.contentType)}\"/>`,\n );\n }\n }\n\n // Core properties override\n if (coreProps) {\n lines.push(\n ` <Override PartName=\"/docProps/core.xml\" ContentType=\"${CONTENT_TYPE_CORE_PROPERTIES}\"/>`,\n );\n }\n\n lines.push('</Types>');\n return lines.join('\\n');\n}\n\n// ============================================\n// Relationships XML\n// ============================================\n\nfunction buildRelationshipsXml(rels: Relationship[]): string {\n const lines: string[] = [xmlDeclaration()];\n lines.push(`<Relationships xmlns=\"${NS_RELATIONSHIPS}\">`);\n\n for (const rel of rels) {\n const attrs: string[] = [\n `Id=\"${escapeXml(rel.id)}\"`,\n `Type=\"${escapeXml(rel.type)}\"`,\n `Target=\"${escapeXml(rel.target)}\"`,\n ];\n if (rel.targetMode) {\n attrs.push(`TargetMode=\"${escapeXml(rel.targetMode)}\"`);\n }\n lines.push(` <Relationship ${attrs.join(' ')}/>`);\n }\n\n lines.push('</Relationships>');\n return lines.join('\\n');\n}\n\n// ============================================\n// Core Properties XML\n// ============================================\n\nfunction buildCorePropertiesXml(props: CoreProperties): string {\n const lines: string[] = [xmlDeclaration()];\n lines.push(\n `<cp:coreProperties` +\n ` xmlns:cp=\"${NS_CORE_PROPERTIES}\"` +\n ` xmlns:dc=\"${NS_DC}\"` +\n ` xmlns:dcterms=\"${NS_DCTERMS}\"` +\n ` xmlns:xsi=\"${NS_XSI}\">`,\n );\n\n if (props.title) lines.push(` <dc:title>${escapeXml(props.title)}</dc:title>`);\n if (props.subject) lines.push(` <dc:subject>${escapeXml(props.subject)}</dc:subject>`);\n if (props.creator) lines.push(` <dc:creator>${escapeXml(props.creator)}</dc:creator>`);\n if (props.description)\n lines.push(` <dc:description>${escapeXml(props.description)}</dc:description>`);\n if (props.keywords) lines.push(` <cp:keywords>${escapeXml(props.keywords)}</cp:keywords>`);\n if (props.lastModifiedBy)\n lines.push(` <cp:lastModifiedBy>${escapeXml(props.lastModifiedBy)}</cp:lastModifiedBy>`);\n if (props.revision) lines.push(` <cp:revision>${escapeXml(props.revision)}</cp:revision>`);\n if (props.created) {\n lines.push(\n ` <dcterms:created xsi:type=\"dcterms:W3CDTF\">${escapeXml(props.created)}</dcterms:created>`,\n );\n }\n if (props.modified) {\n lines.push(\n ` <dcterms:modified xsi:type=\"dcterms:W3CDTF\">${escapeXml(props.modified)}</dcterms:modified>`,\n );\n }\n\n lines.push('</cp:coreProperties>');\n return lines.join('\\n');\n}\n\n// ============================================\n// Helpers\n// ============================================\n\nfunction getExtension(path: string): string | undefined {\n const dot = path.lastIndexOf('.');\n if (dot === -1) return undefined;\n return path.substring(dot + 1).toLowerCase();\n}\n\nfunction buildRelsPath(partPath: string): string {\n const lastSlash = partPath.lastIndexOf('/');\n if (lastSlash === -1) {\n return `_rels/${partPath}.rels`;\n }\n const dir = partPath.substring(0, lastSlash);\n const file = partPath.substring(lastSlash + 1);\n return `${dir}/_rels/${file}.rels`;\n}\n\nfunction groupRelationshipsBySource(pending: PendingRelationship[]): Map<string, Relationship[]> {\n const grouped = new Map<string, Relationship[]>();\n for (const { sourcePart, relationship } of pending) {\n let list = grouped.get(sourcePart);\n if (!list) {\n list = [];\n grouped.set(sourcePart, list);\n }\n list.push(relationship);\n }\n return grouped;\n}\n","/**\n * OOXML Package Reader\n *\n * Opens OOXML archives (.docx, .pptx, .xlsx) and parses their\n * structural metadata: [Content_Types].xml, relationships, and\n * core properties.\n *\n * Uses JSZip to unzip and the browser's DOMParser to parse XML.\n */\n\nimport JSZip from 'jszip';\nimport type { OoxmlPackage, ContentTypeMap, Relationship, CoreProperties } from './types.js';\nimport { NS_RELATIONSHIPS, NS_DC, NS_DCTERMS, NS_CORE_PROPERTIES } from './namespaces.js';\n\n// ============================================\n// Package Opening\n// ============================================\n\n/**\n * Open an OOXML package from raw data.\n *\n * Parses the ZIP archive, [Content_Types].xml, and root relationships.\n *\n * @param data - The raw .docx/.pptx/.xlsx file as ArrayBuffer or Blob\n * @returns A parsed OoxmlPackage\n */\nexport async function openPackage(data: ArrayBuffer | Blob): Promise<OoxmlPackage> {\n const zip = await JSZip.loadAsync(data);\n const contentTypes = await parseContentTypes(zip);\n const rootRelationships = await parseRelationships(zip, '');\n\n return { zip, contentTypes, rootRelationships };\n}\n\n// ============================================\n// Content Types\n// ============================================\n\n/**\n * Parse [Content_Types].xml from the archive.\n */\nasync function parseContentTypes(zip: JSZip): Promise<ContentTypeMap> {\n const overrides = new Map<string, string>();\n const defaults = new Map<string, string>();\n\n const file = zip.file('[Content_Types].xml');\n if (!file) return { overrides, defaults };\n\n const text = await file.async('text');\n const doc = new DOMParser().parseFromString(text, 'application/xml');\n\n // Parse <Default Extension=\"rels\" ContentType=\"...\" />\n const defaultEls = doc.getElementsByTagName('Default');\n for (let i = 0; i < defaultEls.length; i++) {\n const el = defaultEls[i];\n const ext = el.getAttribute('Extension');\n const ct = el.getAttribute('ContentType');\n if (ext && ct) defaults.set(ext, ct);\n }\n\n // Parse <Override PartName=\"/word/document.xml\" ContentType=\"...\" />\n const overrideEls = doc.getElementsByTagName('Override');\n for (let i = 0; i < overrideEls.length; i++) {\n const el = overrideEls[i];\n const partName = el.getAttribute('PartName');\n const ct = el.getAttribute('ContentType');\n if (partName && ct) {\n // Normalize: strip leading slash\n overrides.set(partName.replace(/^\\//, ''), ct);\n }\n }\n\n return { overrides, defaults };\n}\n\n// ============================================\n// Relationships\n// ============================================\n\n/**\n * Parse relationships for a specific part.\n *\n * @param pkg - The OOXML package (or the zip directly)\n * @param partPath - The part path (e.g., \"word/document.xml\").\n * Use \"\" for root-level relationships (_rels/.rels).\n * @returns Array of relationship entries\n */\nexport async function getPartRelationships(\n pkg: OoxmlPackage,\n partPath: string,\n): Promise<Relationship[]> {\n return parseRelationships(pkg.zip, partPath);\n}\n\n/**\n * Parse a _rels/*.rels file from the ZIP.\n *\n * For root relationships, relsPath = \"_rels/.rels\".\n * For part relationships, relsPath = \"<dir>/_rels/<filename>.rels\".\n */\nasync function parseRelationships(zip: JSZip, partPath: string): Promise<Relationship[]> {\n const relsPath = partPath === '' ? '_rels/.rels' : buildRelsPath(partPath);\n\n const file = zip.file(relsPath);\n if (!file) return [];\n\n const text = await file.async('text');\n const doc = new DOMParser().parseFromString(text, 'application/xml');\n const result: Relationship[] = [];\n\n const els = doc.getElementsByTagNameNS(NS_RELATIONSHIPS, 'Relationship');\n // Fallback in case namespace isn't used (some generators omit it)\n const fallbackEls = els.length > 0 ? els : doc.getElementsByTagName('Relationship');\n\n for (let i = 0; i < fallbackEls.length; i++) {\n const el = fallbackEls[i];\n const id = el.getAttribute('Id');\n const type = el.getAttribute('Type');\n const target = el.getAttribute('Target');\n if (id && type && target) {\n const targetMode = el.getAttribute('TargetMode') as 'Internal' | 'External' | null;\n result.push({\n id,\n type,\n target,\n ...(targetMode ? { targetMode } : {}),\n });\n }\n }\n\n return result;\n}\n\n/**\n * Build the _rels path for a given part path.\n *\n * \"word/document.xml\" → \"word/_rels/document.xml.rels\"\n * \"xl/workbook.xml\" → \"xl/_rels/workbook.xml.rels\"\n */\nfunction buildRelsPath(partPath: string): string {\n const lastSlash = partPath.lastIndexOf('/');\n if (lastSlash === -1) {\n return `_rels/${partPath}.rels`;\n }\n const dir = partPath.substring(0, lastSlash);\n const file = partPath.substring(lastSlash + 1);\n return `${dir}/_rels/${file}.rels`;\n}\n\n// ============================================\n// Part Access\n// ============================================\n\n/**\n * Extract an XML part from the package and parse it as a DOM Document.\n *\n * @param pkg - The OOXML package\n * @param partPath - Path within the archive (e.g., \"word/document.xml\")\n * @returns Parsed XML Document, or null if the part doesn't exist\n */\nexport async function getPartXml(pkg: OoxmlPackage, partPath: string): Promise<Document | null> {\n const file = pkg.zip.file(partPath);\n if (!file) return null;\n\n const text = await file.async('text');\n return new DOMParser().parseFromString(text, 'application/xml');\n}\n\n/**\n * Extract a binary part from the package (e.g., an image from word/media/).\n *\n * @param pkg - The OOXML package\n * @param partPath - Path within the archive\n * @returns The binary content, or null if the part doesn't exist\n */\nexport async function getPartBinary(\n pkg: OoxmlPackage,\n partPath: string,\n): Promise<ArrayBuffer | null> {\n const file = pkg.zip.file(partPath);\n if (!file) return null;\n return file.async('arraybuffer');\n}\n\n// ============================================\n// Core Properties\n// ============================================\n\n/**\n * Parse core document properties from docProps/core.xml.\n *\n * @param pkg - The OOXML package\n * @returns Parsed core properties (all fields optional)\n */\nexport async function getCoreProperties(pkg: OoxmlPackage): Promise<CoreProperties> {\n const doc = await getPartXml(pkg, 'docProps/core.xml');\n if (!doc) return {};\n\n function getText(ns: string, localName: string): string | undefined {\n const els = doc!.getElementsByTagNameNS(ns, localName);\n if (els.length > 0 && els[0].textContent) {\n return els[0].textContent;\n }\n return undefined;\n }\n\n return {\n title: getText(NS_DC, 'title'),\n subject: getText(NS_DC, 'subject'),\n creator: getText(NS_DC, 'creator'),\n description: getText(NS_DC, 'description'),\n keywords: getText(NS_CORE_PROPERTIES, 'keywords'),\n lastModifiedBy: getText(NS_CORE_PROPERTIES, 'lastModifiedBy'),\n revision: getText(NS_CORE_PROPERTIES, 'revision'),\n created: getText(NS_DCTERMS, 'created'),\n modified: getText(NS_DCTERMS, 'modified'),\n };\n}\n"],"mappings":";AAYO,IAAM,mBAAmB;AAGzB,IAAM,mBAAmB;AAOzB,IAAM,sBACX;AAGK,IAAM,sBACX;AAGK,IAAM,0BACX;AAGK,IAAM,aACX;AAGK,IAAM,gBACX;AAGK,IAAM,iBACX;AAGK,IAAM,eACX;AAGK,IAAM,gBACX;AAGK,IAAM,YACX;AAGK,IAAM,gBACX;AAGK,IAAM,YACX;AAOK,IAAM,SAAS;AAOf,IAAM,SAAS;AAOf,IAAM,SAAS;AAOf,IAAM,eAAe;AAGrB,IAAM,gBACX;AAGK,IAAM,aAAa;AAOnB,IAAM,QAAQ;AAGd,IAAM,aAAa;AAGnB,IAAM,qBACX;AAGK,IAAM,SAAS;AAOf,IAAM,QAAQ;AAGd,IAAM,OAAO;AAMb,IAAM,6BACX;AAEK,IAAM,+BACX;AAEK,IAAM,6BACX;AAEK,IAAM,2BACX;AAEK,IAAM,8BACX;AAEK,IAAM,6BACX;AAEK,IAAM,+BACX;AAEK,IAAM,8BACX;AAEK,IAAM,iCACX;AAEK,IAAM,6BACX;;;ACpJK,SAAS,iBAAyB;AACvC,SAAO;AACT;AAYO,SAAS,UAAU,MAAsB;AAC9C,SAAO,KACJ,QAAQ,MAAM,OAAO,EACrB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAA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