@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.
Files changed (61) hide show
  1. package/dist/chunk-532L4D5D.js +21 -0
  2. package/dist/chunk-532L4D5D.js.map +1 -0
  3. package/dist/chunk-67KIJHV2.js +21 -0
  4. package/dist/chunk-67KIJHV2.js.map +1 -0
  5. package/dist/chunk-KAK4V57E.js +387 -0
  6. package/dist/chunk-KAK4V57E.js.map +1 -0
  7. package/dist/chunk-MQHCXI56.js +1035 -0
  8. package/dist/chunk-MQHCXI56.js.map +1 -0
  9. package/dist/chunk-TBPD5PCU.js +1136 -0
  10. package/dist/chunk-TBPD5PCU.js.map +1 -0
  11. package/dist/chunk-ULLIPBEJ.js +271 -0
  12. package/dist/chunk-ULLIPBEJ.js.map +1 -0
  13. package/dist/docx/index.d.ts +108 -0
  14. package/dist/docx/index.js +14 -0
  15. package/dist/docx/index.js.map +1 -0
  16. package/dist/html/index.d.ts +166 -0
  17. package/dist/html/index.js +17 -0
  18. package/dist/html/index.js.map +1 -0
  19. package/dist/index.d.ts +7 -0
  20. package/dist/index.js +54 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/ooxml/index.d.ts +351 -0
  23. package/dist/ooxml/index.js +99 -0
  24. package/dist/ooxml/index.js.map +1 -0
  25. package/dist/pdf/index.d.ts +130 -0
  26. package/dist/pdf/index.js +15 -0
  27. package/dist/pdf/index.js.map +1 -0
  28. package/dist/pptx/index.d.ts +58 -0
  29. package/dist/pptx/index.js +13 -0
  30. package/dist/pptx/index.js.map +1 -0
  31. package/dist/xlsx/index.d.ts +58 -0
  32. package/dist/xlsx/index.js +13 -0
  33. package/dist/xlsx/index.js.map +1 -0
  34. package/package.json +85 -0
  35. package/src/__tests__/docxExport.test.ts +457 -0
  36. package/src/__tests__/docxImport.test.ts +410 -0
  37. package/src/__tests__/html.test.ts +295 -0
  38. package/src/__tests__/ooxml.test.ts +197 -0
  39. package/src/__tests__/pdfExport.test.ts +322 -0
  40. package/src/__tests__/pdfImport.test.ts +290 -0
  41. package/src/__tests__/roundTrip.test.ts +201 -0
  42. package/src/docx/export.ts +978 -0
  43. package/src/docx/import.ts +909 -0
  44. package/src/docx/index.ts +26 -0
  45. package/src/docx/styles.ts +145 -0
  46. package/src/html/htmlTemplate.ts +307 -0
  47. package/src/html/imageUtils.ts +66 -0
  48. package/src/html/index.ts +168 -0
  49. package/src/index.ts +51 -0
  50. package/src/ooxml/index.ts +87 -0
  51. package/src/ooxml/namespaces.ts +160 -0
  52. package/src/ooxml/reader.ts +218 -0
  53. package/src/ooxml/types.ts +104 -0
  54. package/src/ooxml/writer.ts +321 -0
  55. package/src/ooxml/xmlUtils.ts +123 -0
  56. package/src/pdf/export.ts +1029 -0
  57. package/src/pdf/import.ts +835 -0
  58. package/src/pdf/index.ts +29 -0
  59. package/src/pdf/styles.ts +180 -0
  60. package/src/pptx/index.ts +78 -0
  61. package/src/xlsx/index.ts +78 -0
@@ -0,0 +1,14 @@
1
+ import {
2
+ docToDocx,
3
+ docxToDoc,
4
+ docxToMarkdownDoc,
5
+ markdownDocToDocx
6
+ } from "../chunk-MQHCXI56.js";
7
+ import "../chunk-KAK4V57E.js";
8
+ export {
9
+ docToDocx,
10
+ docxToDoc,
11
+ docxToMarkdownDoc,
12
+ markdownDocToDocx
13
+ };
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,166 @@
1
+ import { Doc } from '@bendyline/squisq/schemas';
2
+
3
+ /**
4
+ * HTML Template Generation for SquisqPlayer Exports
5
+ *
6
+ * Generates complete, self-contained HTML documents that load the SquisqPlayer
7
+ * IIFE bundle and render a Doc as either an interactive slideshow or a static
8
+ * scrollable document.
9
+ *
10
+ * Two variants:
11
+ * 1. **Inline** — All JS, CSS, and images are embedded in the HTML (single file).
12
+ * 2. **External** — JS is referenced via `<script src>`, images via relative paths.
13
+ */
14
+
15
+ interface HtmlExportOptions {
16
+ /** The IIFE player bundle source code (from @bendyline/squisq-react/standalone-source) */
17
+ playerScript: string;
18
+ /**
19
+ * Map of relative image paths (as they appear in the Doc) to binary image data.
20
+ * For inline HTML export, these are converted to base64 data URIs.
21
+ * For ZIP export, these are written as separate files.
22
+ */
23
+ images?: Map<string, ArrayBuffer>;
24
+ /**
25
+ * Map of audio segment identifiers to binary audio data.
26
+ * Keys should match the audio segment `name` or `url` fields in the Doc.
27
+ * Only used in ZIP exports — single HTML uses timer-based playback.
28
+ */
29
+ audio?: Map<string, ArrayBuffer>;
30
+ /** Rendering mode: 'slideshow' (interactive, default) or 'static' (scrollable) */
31
+ mode?: 'slideshow' | 'static';
32
+ /** HTML page title (default: 'Squisq Document') */
33
+ title?: string;
34
+ /** Auto-play slideshow on load (default: false) */
35
+ autoPlay?: boolean;
36
+ }
37
+ /**
38
+ * Collect all relative image paths referenced in a Doc's layers and template blocks.
39
+ * Returns a Set of unique relative paths that need to be resolved.
40
+ */
41
+ declare function collectImagePaths(doc: Doc): Set<string>;
42
+
43
+ /**
44
+ * Image Utilities for HTML Export
45
+ *
46
+ * Browser-compatible helpers for converting image data to base64 data URIs
47
+ * and inferring MIME types from filenames.
48
+ */
49
+ /**
50
+ * Infer a MIME type from a filename's extension.
51
+ * Returns 'application/octet-stream' for unknown types.
52
+ */
53
+ declare function inferMimeType(filename: string): string;
54
+ /**
55
+ * Convert an ArrayBuffer to a base64-encoded data URI string.
56
+ *
57
+ * @param buffer - The binary image data
58
+ * @param mimeType - MIME type (e.g., 'image/jpeg'). If not provided, defaults to
59
+ * 'application/octet-stream'.
60
+ * @returns A `data:` URI string
61
+ */
62
+ declare function arrayBufferToBase64DataUrl(buffer: ArrayBuffer, mimeType: string): string;
63
+ /**
64
+ * Extract the filename from a path or URL (strips directory and query).
65
+ *
66
+ * @example
67
+ * extractFilename('images/hero.jpg') // 'hero.jpg'
68
+ * extractFilename('https://example.com/photo.png?v=2') // 'photo.png'
69
+ */
70
+ declare function extractFilename(path: string): string;
71
+
72
+ /**
73
+ * HTML Export Module — @bendyline/squisq-formats/html
74
+ *
75
+ * Exports squisq documents as self-contained HTML files or ZIP archives.
76
+ *
77
+ * Two export modes:
78
+ *
79
+ * 1. **Single HTML** (`docToHtml`) — Everything embedded in one file:
80
+ * - SquisqPlayer IIFE bundle inlined in `<script>`
81
+ * - Images base64-encoded as data URIs
82
+ * - Timer-based playback (no audio — too large for inline)
83
+ *
84
+ * 2. **ZIP Archive** (`docToHtmlZip`) — Multi-file package:
85
+ * - `index.html` referencing external `squisq-player.js`
86
+ * - `squisq-player.js` — the IIFE bundle
87
+ * - `images/` — extracted image files
88
+ * - `audio/` — optional audio segment files (enables full playback)
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * import { PLAYER_BUNDLE } from '@bendyline/squisq-react/standalone-source';
93
+ * import { docToHtml, docToHtmlZip } from '@bendyline/squisq-formats/html';
94
+ *
95
+ * // Single HTML file
96
+ * const html = docToHtml(doc, { playerScript: PLAYER_BUNDLE, images });
97
+ *
98
+ * // ZIP archive
99
+ * const zipBlob = await docToHtmlZip(doc, { playerScript: PLAYER_BUNDLE, images, audio });
100
+ * ```
101
+ */
102
+
103
+ interface HtmlZipExportOptions extends HtmlExportOptions {
104
+ /**
105
+ * Map of audio segment identifiers to binary audio data.
106
+ * Keys should match the audio segment `name` or `url` fields in the Doc.
107
+ * When provided, audio files are included in the ZIP and full playback is enabled.
108
+ */
109
+ audio?: Map<string, ArrayBuffer>;
110
+ }
111
+ /**
112
+ * Export a Doc as a single, self-contained HTML file.
113
+ *
114
+ * The player JS is embedded inline, images are base64-encoded as data URIs,
115
+ * and playback uses a timer (no audio) for compact file size.
116
+ *
117
+ * @param doc - The Doc to export
118
+ * @param options - Export options (must include `playerScript`)
119
+ * @returns Complete HTML document as a string
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * const html = docToHtml(myDoc, {
124
+ * playerScript: PLAYER_BUNDLE,
125
+ * images: imageMap,
126
+ * title: 'My Document',
127
+ * mode: 'slideshow',
128
+ * });
129
+ * const blob = new Blob([html], { type: 'text/html' });
130
+ * ```
131
+ */
132
+ declare function docToHtml(doc: Doc, options: HtmlExportOptions): string;
133
+ /**
134
+ * Export a Doc as a ZIP archive containing HTML, JS, images, and optionally audio.
135
+ *
136
+ * The archive structure:
137
+ * ```
138
+ * document.zip
139
+ * ├── index.html # HTML page referencing squisq-player.js
140
+ * ├── squisq-player.js # Standalone IIFE bundle
141
+ * ├── images/ # Extracted image files
142
+ * │ ├── hero.jpg
143
+ * │ └── ...
144
+ * └── audio/ # Optional audio segment files
145
+ * ├── intro.mp3
146
+ * └── ...
147
+ * ```
148
+ *
149
+ * @param doc - The Doc to export
150
+ * @param options - Export options (must include `playerScript`)
151
+ * @returns A Promise resolving to a ZIP Blob
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * const blob = await docToHtmlZip(myDoc, {
156
+ * playerScript: PLAYER_BUNDLE,
157
+ * images: imageMap,
158
+ * audio: audioMap,
159
+ * });
160
+ * // Trigger browser download
161
+ * const url = URL.createObjectURL(blob);
162
+ * ```
163
+ */
164
+ declare function docToHtmlZip(doc: Doc, options: HtmlZipExportOptions): Promise<Blob>;
165
+
166
+ export { type HtmlExportOptions, type HtmlZipExportOptions, arrayBufferToBase64DataUrl, collectImagePaths, docToHtml, docToHtmlZip, extractFilename, inferMimeType };
@@ -0,0 +1,17 @@
1
+ import {
2
+ arrayBufferToBase64DataUrl,
3
+ collectImagePaths,
4
+ docToHtml,
5
+ docToHtmlZip,
6
+ extractFilename,
7
+ inferMimeType
8
+ } from "../chunk-ULLIPBEJ.js";
9
+ export {
10
+ arrayBufferToBase64DataUrl,
11
+ collectImagePaths,
12
+ docToHtml,
13
+ docToHtmlZip,
14
+ extractFilename,
15
+ inferMimeType
16
+ };
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,7 @@
1
+ export { DocxExportOptions, DocxImportOptions, docToDocx, docxToDoc, docxToMarkdownDoc, markdownDocToDocx } from './docx/index.js';
2
+ export { PptxExportOptions, PptxImportOptions, docToPptx, markdownDocToPptx, pptxToDoc, pptxToMarkdownDoc } from './pptx/index.js';
3
+ export { XlsxExportOptions, XlsxImportOptions, docToXlsx, markdownDocToXlsx, xlsxToDoc, xlsxToMarkdownDoc } from './xlsx/index.js';
4
+ export { PdfExportOptions, PdfImportOptions, configurePdfWorker, docToPdf, markdownDocToPdf, pdfToDoc, pdfToMarkdownDoc } from './pdf/index.js';
5
+ export { HtmlExportOptions, HtmlZipExportOptions, collectImagePaths, docToHtml, docToHtmlZip } from './html/index.js';
6
+ import '@bendyline/squisq/schemas';
7
+ import '@bendyline/squisq/markdown';
package/dist/index.js ADDED
@@ -0,0 +1,54 @@
1
+ import {
2
+ docToDocx,
3
+ docxToDoc,
4
+ docxToMarkdownDoc,
5
+ markdownDocToDocx
6
+ } from "./chunk-MQHCXI56.js";
7
+ import {
8
+ docToPptx,
9
+ markdownDocToPptx,
10
+ pptxToDoc,
11
+ pptxToMarkdownDoc
12
+ } from "./chunk-532L4D5D.js";
13
+ import {
14
+ docToXlsx,
15
+ markdownDocToXlsx,
16
+ xlsxToDoc,
17
+ xlsxToMarkdownDoc
18
+ } from "./chunk-67KIJHV2.js";
19
+ import "./chunk-KAK4V57E.js";
20
+ import {
21
+ configurePdfWorker,
22
+ docToPdf,
23
+ markdownDocToPdf,
24
+ pdfToDoc,
25
+ pdfToMarkdownDoc
26
+ } from "./chunk-TBPD5PCU.js";
27
+ import {
28
+ collectImagePaths,
29
+ docToHtml,
30
+ docToHtmlZip
31
+ } from "./chunk-ULLIPBEJ.js";
32
+ export {
33
+ collectImagePaths,
34
+ configurePdfWorker,
35
+ docToDocx,
36
+ docToHtml,
37
+ docToHtmlZip,
38
+ docToPdf,
39
+ docToPptx,
40
+ docToXlsx,
41
+ docxToDoc,
42
+ docxToMarkdownDoc,
43
+ markdownDocToDocx,
44
+ markdownDocToPdf,
45
+ markdownDocToPptx,
46
+ markdownDocToXlsx,
47
+ pdfToDoc,
48
+ pdfToMarkdownDoc,
49
+ pptxToDoc,
50
+ pptxToMarkdownDoc,
51
+ xlsxToDoc,
52
+ xlsxToMarkdownDoc
53
+ };
54
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,351 @@
1
+ import JSZip from 'jszip';
2
+
3
+ /**
4
+ * OOXML Types
5
+ *
6
+ * Shared type definitions for all Office Open XML formats (DOCX, PPTX, XLSX).
7
+ * These model the common structural elements of the OOXML package format:
8
+ * ZIP archive, relationships, content types, and core properties.
9
+ */
10
+
11
+ /**
12
+ * An opened OOXML package — wraps the JSZip archive plus parsed
13
+ * structural metadata (content types, root relationships).
14
+ */
15
+ interface OoxmlPackage {
16
+ /** The underlying JSZip archive */
17
+ zip: JSZip;
18
+ /** Parsed [Content_Types].xml entries */
19
+ contentTypes: ContentTypeMap;
20
+ /** Root-level relationships (_rels/.rels) */
21
+ rootRelationships: Relationship[];
22
+ }
23
+ /**
24
+ * Content type map built from [Content_Types].xml.
25
+ * Maps part paths → content type strings plus extension defaults.
26
+ */
27
+ interface ContentTypeMap {
28
+ /** Explicit overrides: partName → contentType */
29
+ overrides: Map<string, string>;
30
+ /** Default extensions: extension → contentType */
31
+ defaults: Map<string, string>;
32
+ }
33
+ /**
34
+ * An OOXML relationship entry (from any _rels/*.rels file).
35
+ */
36
+ interface Relationship {
37
+ /** Relationship ID (e.g., "rId1") */
38
+ id: string;
39
+ /** Relationship type URI (e.g., "http://...officedocument/...") */
40
+ type: string;
41
+ /** Target path or URL */
42
+ target: string;
43
+ /** "Internal" (default) or "External" for hyperlinks */
44
+ targetMode?: 'Internal' | 'External';
45
+ }
46
+ /**
47
+ * Document core properties from docProps/core.xml (Dublin Core metadata).
48
+ */
49
+ interface CoreProperties {
50
+ title?: string;
51
+ subject?: string;
52
+ creator?: string;
53
+ keywords?: string;
54
+ description?: string;
55
+ lastModifiedBy?: string;
56
+ revision?: string;
57
+ created?: string;
58
+ modified?: string;
59
+ }
60
+ /**
61
+ * A part (file) that will be written into an OOXML package.
62
+ */
63
+ interface PackagePart {
64
+ /** Path within the ZIP (e.g., "word/document.xml") */
65
+ path: string;
66
+ /** XML or text content (mutually exclusive with binaryContent) */
67
+ content?: string;
68
+ /** Binary content (mutually exclusive with content) */
69
+ binaryContent?: ArrayBuffer | Uint8Array;
70
+ /** MIME content type for [Content_Types].xml */
71
+ contentType: string;
72
+ }
73
+ /**
74
+ * A relationship to be written into a _rels/*.rels file.
75
+ * `sourcePart` identifies which part the relationship belongs to.
76
+ * Use "" (empty string) for root-level relationships (_rels/.rels).
77
+ */
78
+ interface PendingRelationship {
79
+ /** The part this relationship belongs to ("" for root) */
80
+ sourcePart: string;
81
+ /** The relationship entry */
82
+ relationship: Relationship;
83
+ }
84
+
85
+ /**
86
+ * OOXML Package Reader
87
+ *
88
+ * Opens OOXML archives (.docx, .pptx, .xlsx) and parses their
89
+ * structural metadata: [Content_Types].xml, relationships, and
90
+ * core properties.
91
+ *
92
+ * Uses JSZip to unzip and the browser's DOMParser to parse XML.
93
+ */
94
+
95
+ /**
96
+ * Open an OOXML package from raw data.
97
+ *
98
+ * Parses the ZIP archive, [Content_Types].xml, and root relationships.
99
+ *
100
+ * @param data - The raw .docx/.pptx/.xlsx file as ArrayBuffer or Blob
101
+ * @returns A parsed OoxmlPackage
102
+ */
103
+ declare function openPackage(data: ArrayBuffer | Blob): Promise<OoxmlPackage>;
104
+ /**
105
+ * Parse relationships for a specific part.
106
+ *
107
+ * @param pkg - The OOXML package (or the zip directly)
108
+ * @param partPath - The part path (e.g., "word/document.xml").
109
+ * Use "" for root-level relationships (_rels/.rels).
110
+ * @returns Array of relationship entries
111
+ */
112
+ declare function getPartRelationships(pkg: OoxmlPackage, partPath: string): Promise<Relationship[]>;
113
+ /**
114
+ * Extract an XML part from the package and parse it as a DOM Document.
115
+ *
116
+ * @param pkg - The OOXML package
117
+ * @param partPath - Path within the archive (e.g., "word/document.xml")
118
+ * @returns Parsed XML Document, or null if the part doesn't exist
119
+ */
120
+ declare function getPartXml(pkg: OoxmlPackage, partPath: string): Promise<Document | null>;
121
+ /**
122
+ * Extract a binary part from the package (e.g., an image from word/media/).
123
+ *
124
+ * @param pkg - The OOXML package
125
+ * @param partPath - Path within the archive
126
+ * @returns The binary content, or null if the part doesn't exist
127
+ */
128
+ declare function getPartBinary(pkg: OoxmlPackage, partPath: string): Promise<ArrayBuffer | null>;
129
+ /**
130
+ * Parse core document properties from docProps/core.xml.
131
+ *
132
+ * @param pkg - The OOXML package
133
+ * @returns Parsed core properties (all fields optional)
134
+ */
135
+ declare function getCoreProperties(pkg: OoxmlPackage): Promise<CoreProperties>;
136
+
137
+ /**
138
+ * OOXML Package Writer
139
+ *
140
+ * Builds OOXML archives (.docx, .pptx, .xlsx) from parts.
141
+ * Handles automatic generation of [Content_Types].xml and
142
+ * _rels/*.rels files from the registered parts and relationships.
143
+ */
144
+
145
+ /**
146
+ * Mutable builder for constructing an OOXML package.
147
+ *
148
+ * Add parts, relationships, and core properties, then call `toBlob()`
149
+ * or `toArrayBuffer()` to produce the final ZIP archive.
150
+ *
151
+ * @example
152
+ * ```ts
153
+ * const builder = createPackage();
154
+ * builder.addPart('word/document.xml', documentXml, CONTENT_TYPE_DOCX_DOCUMENT);
155
+ * builder.addRelationship('', {
156
+ * id: 'rId1',
157
+ * type: REL_OFFICE_DOCUMENT,
158
+ * target: 'word/document.xml',
159
+ * });
160
+ * const blob = await builder.toBlob();
161
+ * ```
162
+ */
163
+ interface OoxmlPackageBuilder {
164
+ /**
165
+ * Add an XML or text part to the package.
166
+ *
167
+ * @param path - Path within the archive (e.g., "word/document.xml")
168
+ * @param content - XML string content
169
+ * @param contentType - MIME content type for [Content_Types].xml
170
+ */
171
+ addPart(path: string, content: string, contentType: string): void;
172
+ /**
173
+ * Add a binary part to the package (e.g., an image).
174
+ *
175
+ * @param path - Path within the archive (e.g., "word/media/image1.png")
176
+ * @param data - Binary content
177
+ * @param contentType - MIME content type (e.g., "image/png")
178
+ */
179
+ addBinaryPart(path: string, data: ArrayBuffer | Uint8Array, contentType: string): void;
180
+ /**
181
+ * Register a relationship.
182
+ *
183
+ * @param sourcePart - The part this relationship belongs to (e.g., "word/document.xml").
184
+ * Use "" (empty string) for root-level relationships (_rels/.rels).
185
+ * @param rel - The relationship entry
186
+ */
187
+ addRelationship(sourcePart: string, rel: Relationship): void;
188
+ /**
189
+ * Set core document properties (docProps/core.xml).
190
+ * Calling this multiple times overwrites previous values.
191
+ */
192
+ setCoreProperties(props: CoreProperties): void;
193
+ /**
194
+ * Assemble the final OOXML package as a Blob.
195
+ * Generates [Content_Types].xml and all _rels/*.rels files automatically.
196
+ */
197
+ toBlob(): Promise<Blob>;
198
+ /**
199
+ * Assemble the final OOXML package as an ArrayBuffer.
200
+ */
201
+ toArrayBuffer(): Promise<ArrayBuffer>;
202
+ }
203
+ /**
204
+ * Create a new OOXML package builder.
205
+ */
206
+ declare function createPackage(): OoxmlPackageBuilder;
207
+
208
+ /**
209
+ * XML Utility Functions
210
+ *
211
+ * Lightweight helpers for generating well-formed XML strings.
212
+ * Used by all OOXML writers (DOCX, PPTX, XLSX) to construct
213
+ * part content without a heavy DOM library.
214
+ */
215
+ /**
216
+ * XML declaration for the start of every OOXML part.
217
+ */
218
+ declare function xmlDeclaration(): string;
219
+ /**
220
+ * Escape a string for safe inclusion in XML text content or attribute values.
221
+ *
222
+ * Handles the five predefined XML entities:
223
+ * - & → &amp;
224
+ * - < → &lt;
225
+ * - > → &gt;
226
+ * - " → &quot;
227
+ * - ' → &apos;
228
+ */
229
+ declare function escapeXml(text: string): string;
230
+ /**
231
+ * Build an XML attribute string from a key-value record.
232
+ * Only includes entries where the value is defined and non-empty.
233
+ *
234
+ * @example
235
+ * ```ts
236
+ * attrString({ 'w:val': 'Heading1', 'w:eastAsia': undefined })
237
+ * // ' w:val="Heading1"'
238
+ * ```
239
+ */
240
+ declare function attrString(attrs?: Record<string, string | undefined>): string;
241
+ /**
242
+ * Build a self-closing XML element: `<tag attr="val"/>`.
243
+ *
244
+ * @example
245
+ * ```ts
246
+ * selfClosingElement('w:b')
247
+ * // '<w:b/>'
248
+ *
249
+ * selfClosingElement('w:pStyle', { 'w:val': 'Heading1' })
250
+ * // '<w:pStyle w:val="Heading1"/>'
251
+ * ```
252
+ */
253
+ declare function selfClosingElement(tag: string, attrs?: Record<string, string | undefined>): string;
254
+ /**
255
+ * Build an XML element with children: `<tag attr="val">...children...</tag>`.
256
+ * Children are concatenated directly (no extra whitespace).
257
+ *
258
+ * @example
259
+ * ```ts
260
+ * xmlElement('w:p', {},
261
+ * xmlElement('w:r', {},
262
+ * xmlElement('w:t', {}, 'Hello')
263
+ * )
264
+ * )
265
+ * // '<w:p><w:r><w:t>Hello</w:t></w:r></w:p>'
266
+ * ```
267
+ */
268
+ declare function xmlElement(tag: string, attrs?: Record<string, string | undefined>, ...children: string[]): string;
269
+ /**
270
+ * Build an XML text element: `<tag attr="val">escaped text</tag>`.
271
+ * The text value is XML-escaped automatically.
272
+ *
273
+ * This is a convenience for the common pattern of wrapping text in an element,
274
+ * where you want automatic escaping (unlike `xmlElement` which takes raw children).
275
+ *
276
+ * @example
277
+ * ```ts
278
+ * textElement('w:t', { 'xml:space': 'preserve' }, 'Hello & world')
279
+ * // '<w:t xml:space="preserve">Hello &amp; world</w:t>'
280
+ * ```
281
+ */
282
+ declare function textElement(tag: string, attrs?: Record<string, string | undefined>, text?: string): string;
283
+
284
+ /**
285
+ * OOXML Namespace Constants
286
+ *
287
+ * All Office Open XML namespace URIs used across DOCX, PPTX, and XLSX.
288
+ * Organized by category for easy reference.
289
+ */
290
+ /** Relationships namespace (used in _rels/*.rels files) */
291
+ declare const NS_RELATIONSHIPS = "http://schemas.openxmlformats.org/package/2006/relationships";
292
+ /** Content Types namespace ([Content_Types].xml) */
293
+ declare const NS_CONTENT_TYPES = "http://schemas.openxmlformats.org/package/2006/content-types";
294
+ /** Relationship type: Office document (main part) */
295
+ declare const REL_OFFICE_DOCUMENT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument";
296
+ /** Relationship type: Core properties */
297
+ declare const REL_CORE_PROPERTIES = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
298
+ /** Relationship type: Extended properties (app.xml) */
299
+ declare const REL_EXTENDED_PROPERTIES = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties";
300
+ /** Relationship type: Styles */
301
+ declare const REL_STYLES = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles";
302
+ /** Relationship type: Numbering */
303
+ declare const REL_NUMBERING = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering";
304
+ /** Relationship type: Font table */
305
+ declare const REL_FONT_TABLE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable";
306
+ /** Relationship type: Settings */
307
+ declare const REL_SETTINGS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings";
308
+ /** Relationship type: Hyperlink */
309
+ declare const REL_HYPERLINK = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
310
+ /** Relationship type: Image */
311
+ declare const REL_IMAGE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
312
+ /** Relationship type: Footnotes */
313
+ declare const REL_FOOTNOTES = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes";
314
+ /** Relationship type: Theme */
315
+ declare const REL_THEME = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
316
+ /** WordprocessingML main namespace (w:) */
317
+ declare const NS_WML = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
318
+ /** PresentationML main namespace (p:) */
319
+ declare const NS_PML = "http://schemas.openxmlformats.org/presentationml/2006/main";
320
+ /** SpreadsheetML main namespace */
321
+ declare const NS_SML = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
322
+ /** DrawingML main namespace (a:) */
323
+ declare const NS_DRAWINGML = "http://schemas.openxmlformats.org/drawingml/2006/main";
324
+ /** DrawingML WordprocessingML drawing namespace (wp:) */
325
+ declare const NS_WP_DRAWING = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing";
326
+ /** DrawingML picture namespace (pic:) */
327
+ declare const NS_PICTURE = "http://schemas.openxmlformats.org/drawingml/2006/picture";
328
+ /** Dublin Core elements namespace */
329
+ declare const NS_DC = "http://purl.org/dc/elements/1.1/";
330
+ /** Dublin Core terms namespace */
331
+ declare const NS_DCTERMS = "http://purl.org/dc/terms/";
332
+ /** Core properties namespace */
333
+ declare const NS_CORE_PROPERTIES = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties";
334
+ /** XML Schema Instance namespace */
335
+ declare const NS_XSI = "http://www.w3.org/2001/XMLSchema-instance";
336
+ /** Markup Compatibility namespace (mc:) */
337
+ declare const NS_MC = "http://schemas.openxmlformats.org/markup-compatibility/2006";
338
+ /** Office relationships namespace (r:) */
339
+ declare const NS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
340
+ declare const CONTENT_TYPE_RELATIONSHIPS = "application/vnd.openxmlformats-package.relationships+xml";
341
+ declare const CONTENT_TYPE_CORE_PROPERTIES = "application/vnd.openxmlformats-package.core-properties+xml";
342
+ declare const CONTENT_TYPE_DOCX_DOCUMENT = "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml";
343
+ declare const CONTENT_TYPE_DOCX_STYLES = "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";
344
+ declare const CONTENT_TYPE_DOCX_NUMBERING = "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml";
345
+ declare const CONTENT_TYPE_DOCX_SETTINGS = "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml";
346
+ declare const CONTENT_TYPE_DOCX_FONT_TABLE = "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml";
347
+ declare const CONTENT_TYPE_DOCX_FOOTNOTES = "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml";
348
+ declare const CONTENT_TYPE_PPTX_PRESENTATION = "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml";
349
+ declare const CONTENT_TYPE_XLSX_WORKBOOK = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml";
350
+
351
+ export { CONTENT_TYPE_CORE_PROPERTIES, CONTENT_TYPE_DOCX_DOCUMENT, CONTENT_TYPE_DOCX_FONT_TABLE, CONTENT_TYPE_DOCX_FOOTNOTES, CONTENT_TYPE_DOCX_NUMBERING, CONTENT_TYPE_DOCX_SETTINGS, CONTENT_TYPE_DOCX_STYLES, CONTENT_TYPE_PPTX_PRESENTATION, CONTENT_TYPE_RELATIONSHIPS, CONTENT_TYPE_XLSX_WORKBOOK, type ContentTypeMap, type CoreProperties, NS_CONTENT_TYPES, NS_CORE_PROPERTIES, NS_DC, NS_DCTERMS, NS_DRAWINGML, NS_MC, NS_PICTURE, NS_PML, NS_R, NS_RELATIONSHIPS, NS_SML, NS_WML, NS_WP_DRAWING, NS_XSI, type OoxmlPackage, type OoxmlPackageBuilder, type PackagePart, type PendingRelationship, REL_CORE_PROPERTIES, REL_EXTENDED_PROPERTIES, REL_FONT_TABLE, REL_FOOTNOTES, REL_HYPERLINK, REL_IMAGE, REL_NUMBERING, REL_OFFICE_DOCUMENT, REL_SETTINGS, REL_STYLES, REL_THEME, type Relationship, attrString, createPackage, escapeXml, getCoreProperties, getPartBinary, getPartRelationships, getPartXml, openPackage, selfClosingElement, textElement, xmlDeclaration, xmlElement };