@bendyline/squisq-formats 0.1.0 → 1.0.1

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 (110) hide show
  1. package/README.md +105 -0
  2. package/dist/__tests__/docxExport.test.d.ts +8 -0
  3. package/dist/__tests__/docxExport.test.d.ts.map +1 -0
  4. package/dist/__tests__/docxExport.test.js +383 -0
  5. package/dist/__tests__/docxExport.test.js.map +1 -0
  6. package/dist/__tests__/docxImport.test.d.ts +8 -0
  7. package/dist/__tests__/docxImport.test.d.ts.map +1 -0
  8. package/dist/__tests__/docxImport.test.js +309 -0
  9. package/dist/__tests__/docxImport.test.js.map +1 -0
  10. package/dist/__tests__/html.test.d.ts +8 -0
  11. package/dist/__tests__/html.test.d.ts.map +1 -0
  12. package/dist/__tests__/html.test.js +243 -0
  13. package/dist/__tests__/html.test.js.map +1 -0
  14. package/dist/__tests__/ooxml.test.d.ts +5 -0
  15. package/dist/__tests__/ooxml.test.d.ts.map +1 -0
  16. package/dist/__tests__/ooxml.test.js +152 -0
  17. package/dist/__tests__/ooxml.test.js.map +1 -0
  18. package/dist/__tests__/pdfExport.test.d.ts +8 -0
  19. package/dist/__tests__/pdfExport.test.d.ts.map +1 -0
  20. package/dist/__tests__/pdfExport.test.js +275 -0
  21. package/dist/__tests__/pdfExport.test.js.map +1 -0
  22. package/dist/__tests__/pdfImport.test.d.ts +11 -0
  23. package/dist/__tests__/pdfImport.test.d.ts.map +1 -0
  24. package/dist/__tests__/pdfImport.test.js +254 -0
  25. package/dist/__tests__/pdfImport.test.js.map +1 -0
  26. package/dist/__tests__/roundTrip.test.d.ts +7 -0
  27. package/dist/__tests__/roundTrip.test.d.ts.map +1 -0
  28. package/dist/__tests__/roundTrip.test.js +173 -0
  29. package/dist/__tests__/roundTrip.test.js.map +1 -0
  30. package/dist/docx/export.d.ts +54 -0
  31. package/dist/docx/export.d.ts.map +1 -0
  32. package/dist/docx/export.js +729 -0
  33. package/dist/docx/export.js.map +1 -0
  34. package/dist/docx/import.d.ts +52 -0
  35. package/dist/docx/import.d.ts.map +1 -0
  36. package/dist/docx/import.js +687 -0
  37. package/dist/docx/import.js.map +1 -0
  38. package/dist/docx/index.d.ts +15 -100
  39. package/dist/docx/index.d.ts.map +1 -0
  40. package/dist/docx/index.js +22 -13
  41. package/dist/docx/index.js.map +1 -1
  42. package/dist/docx/styles.d.ts +68 -0
  43. package/dist/docx/styles.d.ts.map +1 -0
  44. package/dist/docx/styles.js +125 -0
  45. package/dist/docx/styles.js.map +1 -0
  46. package/dist/html/htmlTemplate.d.ts +64 -0
  47. package/dist/html/htmlTemplate.d.ts.map +1 -0
  48. package/dist/html/htmlTemplate.js +235 -0
  49. package/dist/html/htmlTemplate.js.map +1 -0
  50. package/dist/html/imageUtils.d.ts +29 -0
  51. package/dist/html/imageUtils.d.ts.map +1 -0
  52. package/dist/html/imageUtils.js +63 -0
  53. package/dist/html/imageUtils.js.map +1 -0
  54. package/dist/html/index.d.ts +9 -77
  55. package/dist/html/index.d.ts.map +1 -0
  56. package/dist/html/index.js +137 -16
  57. package/dist/html/index.js.map +1 -1
  58. package/dist/index.d.ts +36 -7
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +35 -53
  61. package/dist/index.js.map +1 -1
  62. package/dist/ooxml/index.d.ts +14 -343
  63. package/dist/ooxml/index.d.ts.map +1 -0
  64. package/dist/ooxml/index.js +22 -98
  65. package/dist/ooxml/index.js.map +1 -1
  66. package/dist/ooxml/namespaces.d.ts +67 -0
  67. package/dist/ooxml/namespaces.d.ts.map +1 -0
  68. package/dist/ooxml/namespaces.js +94 -0
  69. package/dist/ooxml/namespaces.js.map +1 -0
  70. package/dist/ooxml/reader.d.ts +52 -0
  71. package/dist/ooxml/reader.d.ts.map +1 -0
  72. package/dist/ooxml/reader.js +190 -0
  73. package/dist/ooxml/reader.js.map +1 -0
  74. package/dist/ooxml/types.d.ts +82 -0
  75. package/dist/ooxml/types.d.ts.map +1 -0
  76. package/dist/ooxml/types.js +9 -0
  77. package/dist/ooxml/types.js.map +1 -0
  78. package/dist/ooxml/writer.d.ts +71 -0
  79. package/dist/ooxml/writer.d.ts.map +1 -0
  80. package/dist/ooxml/writer.js +200 -0
  81. package/dist/ooxml/writer.js.map +1 -0
  82. package/dist/ooxml/xmlUtils.d.ts +76 -0
  83. package/dist/ooxml/xmlUtils.d.ts.map +1 -0
  84. package/dist/ooxml/xmlUtils.js +108 -0
  85. package/dist/ooxml/xmlUtils.js.map +1 -0
  86. package/dist/pdf/export.d.ts +50 -0
  87. package/dist/pdf/export.d.ts.map +1 -0
  88. package/dist/pdf/export.js +740 -0
  89. package/dist/pdf/export.js.map +1 -0
  90. package/dist/pdf/import.d.ts +78 -0
  91. package/dist/pdf/import.d.ts.map +1 -0
  92. package/dist/pdf/import.js +619 -0
  93. package/dist/pdf/import.js.map +1 -0
  94. package/dist/pdf/index.d.ts +17 -121
  95. package/dist/pdf/index.d.ts.map +1 -0
  96. package/dist/pdf/index.js +25 -14
  97. package/dist/pdf/index.js.map +1 -1
  98. package/dist/pdf/styles.d.ts +142 -0
  99. package/dist/pdf/styles.d.ts.map +1 -0
  100. package/dist/pdf/styles.js +145 -0
  101. package/dist/pdf/styles.js.map +1 -0
  102. package/dist/pptx/index.d.ts +9 -12
  103. package/dist/pptx/index.d.ts.map +1 -0
  104. package/dist/pptx/index.js +44 -12
  105. package/dist/pptx/index.js.map +1 -1
  106. package/dist/xlsx/index.d.ts +9 -12
  107. package/dist/xlsx/index.d.ts.map +1 -0
  108. package/dist/xlsx/index.js +44 -12
  109. package/dist/xlsx/index.js.map +1 -1
  110. package/package.json +5 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC7F,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAG5E,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC7F,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAG5E,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC7F,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAG5E,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,gBAAgB,EAChB,QAAQ,EACR,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGzE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC7E,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -1,54 +1,36 @@
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
- };
1
+ /**
2
+ * @bendyline/squisq-formats
3
+ *
4
+ * Format converters for squisq documents. Converts between squisq's
5
+ * MarkdownDocument / Doc and various file formats via Office Open XML.
6
+ *
7
+ * Supported formats:
8
+ * - **DOCX** — Microsoft Word (import + export) ✅
9
+ * - **PDF** — Portable Document Format (import + export) ✅
10
+ * - **PPTX** — Microsoft PowerPoint (planned)
11
+ * - **XLSX** — Microsoft Excel (planned)
12
+ *
13
+ * All converters run in the browser — no server or native binaries required.
14
+ * The shared `ooxml/` subpath export provides reusable OOXML infrastructure.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * // Import from root
19
+ * import { markdownDocToDocx, docxToMarkdownDoc } from '@bendyline/squisq-formats';
20
+ *
21
+ * // Or import from subpath
22
+ * import { markdownDocToDocx } from '@bendyline/squisq-formats/docx';
23
+ * import { createPackage } from '@bendyline/squisq-formats/ooxml';
24
+ * ```
25
+ */
26
+ // DOCX (fully implemented)
27
+ export { markdownDocToDocx, docToDocx, docxToMarkdownDoc, docxToDoc } from './docx/index.js';
28
+ // PPTX (stub)
29
+ export { markdownDocToPptx, docToPptx, pptxToMarkdownDoc, pptxToDoc } from './pptx/index.js';
30
+ // XLSX (stub)
31
+ export { markdownDocToXlsx, docToXlsx, xlsxToMarkdownDoc, xlsxToDoc } from './xlsx/index.js';
32
+ // PDF (fully implemented)
33
+ export { markdownDocToPdf, docToPdf, pdfToMarkdownDoc, pdfToDoc, configurePdfWorker, } from './pdf/index.js';
34
+ // HTML (fully implemented)
35
+ export { docToHtml, docToHtmlZip, collectImagePaths } from './html/index.js';
54
36
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,2BAA2B;AAC3B,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG7F,cAAc;AACd,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG7F,cAAc;AACd,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG7F,0BAA0B;AAC1B,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,gBAAgB,EAChB,QAAQ,EACR,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAGxB,2BAA2B;AAC3B,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,351 +1,22 @@
1
- import JSZip from 'jszip';
2
-
3
1
  /**
4
- * OOXML Types
2
+ * @bendyline/squisq-formats OOXML Module
5
3
  *
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.
4
+ * Shared infrastructure for reading and writing Office Open XML packages
5
+ * (DOCX, PPTX, XLSX). Provides ZIP archive handling, relationship management,
6
+ * content type assembly, XML utilities, and core property parsing.
150
7
  *
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).
8
+ * This module is consumed by the format-specific modules (docx/, pptx/, xlsx/)
9
+ * and can also be imported directly by advanced consumers.
257
10
  *
258
11
  * @example
259
12
  * ```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>'
13
+ * import { createPackage, openPackage } from '@bendyline/squisq-formats/ooxml';
266
14
  * ```
267
15
  */
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 };
16
+ export type { OoxmlPackage, ContentTypeMap, Relationship, CoreProperties, PackagePart, PendingRelationship, } from './types.js';
17
+ export { openPackage, getPartRelationships, getPartXml, getPartBinary, getCoreProperties, } from './reader.js';
18
+ export type { OoxmlPackageBuilder } from './writer.js';
19
+ export { createPackage } from './writer.js';
20
+ export { xmlDeclaration, escapeXml, attrString, selfClosingElement, xmlElement, textElement, } from './xmlUtils.js';
21
+ export { NS_RELATIONSHIPS, NS_CONTENT_TYPES, REL_OFFICE_DOCUMENT, REL_CORE_PROPERTIES, REL_EXTENDED_PROPERTIES, REL_STYLES, REL_NUMBERING, REL_FONT_TABLE, REL_SETTINGS, REL_HYPERLINK, REL_IMAGE, REL_FOOTNOTES, REL_THEME, NS_WML, NS_PML, NS_SML, NS_DRAWINGML, NS_WP_DRAWING, NS_PICTURE, NS_DC, NS_DCTERMS, NS_CORE_PROPERTIES, NS_XSI, NS_MC, NS_R, CONTENT_TYPE_RELATIONSHIPS, CONTENT_TYPE_CORE_PROPERTIES, CONTENT_TYPE_DOCX_DOCUMENT, CONTENT_TYPE_DOCX_STYLES, CONTENT_TYPE_DOCX_NUMBERING, CONTENT_TYPE_DOCX_SETTINGS, CONTENT_TYPE_DOCX_FONT_TABLE, CONTENT_TYPE_DOCX_FOOTNOTES, CONTENT_TYPE_PPTX_PRESENTATION, CONTENT_TYPE_XLSX_WORKBOOK, } from './namespaces.js';
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ooxml/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,YAAY,EACV,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,cAAc,EACd,WAAW,EACX,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,UAAU,EACV,aAAa,EACb,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAGrB,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,EACL,cAAc,EACd,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,UAAU,EACV,WAAW,GACZ,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,UAAU,EACV,aAAa,EACb,cAAc,EACd,YAAY,EACZ,aAAa,EACb,SAAS,EACT,aAAa,EACb,SAAS,EACT,MAAM,EACN,MAAM,EACN,MAAM,EACN,YAAY,EACZ,aAAa,EACb,UAAU,EACV,KAAK,EACL,UAAU,EACV,kBAAkB,EAClB,MAAM,EACN,KAAK,EACL,IAAI,EACJ,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,wBAAwB,EACxB,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,EAC3B,8BAA8B,EAC9B,0BAA0B,GAC3B,MAAM,iBAAiB,CAAC"}
@@ -1,99 +1,23 @@
1
- import {
2
- CONTENT_TYPE_CORE_PROPERTIES,
3
- CONTENT_TYPE_DOCX_DOCUMENT,
4
- CONTENT_TYPE_DOCX_FONT_TABLE,
5
- CONTENT_TYPE_DOCX_FOOTNOTES,
6
- CONTENT_TYPE_DOCX_NUMBERING,
7
- CONTENT_TYPE_DOCX_SETTINGS,
8
- CONTENT_TYPE_DOCX_STYLES,
9
- CONTENT_TYPE_PPTX_PRESENTATION,
10
- CONTENT_TYPE_RELATIONSHIPS,
11
- CONTENT_TYPE_XLSX_WORKBOOK,
12
- NS_CONTENT_TYPES,
13
- NS_CORE_PROPERTIES,
14
- NS_DC,
15
- NS_DCTERMS,
16
- NS_DRAWINGML,
17
- NS_MC,
18
- NS_PICTURE,
19
- NS_PML,
20
- NS_R,
21
- NS_RELATIONSHIPS,
22
- NS_SML,
23
- NS_WML,
24
- NS_WP_DRAWING,
25
- NS_XSI,
26
- REL_CORE_PROPERTIES,
27
- REL_EXTENDED_PROPERTIES,
28
- REL_FONT_TABLE,
29
- REL_FOOTNOTES,
30
- REL_HYPERLINK,
31
- REL_IMAGE,
32
- REL_NUMBERING,
33
- REL_OFFICE_DOCUMENT,
34
- REL_SETTINGS,
35
- REL_STYLES,
36
- REL_THEME,
37
- attrString,
38
- createPackage,
39
- escapeXml,
40
- getCoreProperties,
41
- getPartBinary,
42
- getPartRelationships,
43
- getPartXml,
44
- openPackage,
45
- selfClosingElement,
46
- textElement,
47
- xmlDeclaration,
48
- xmlElement
49
- } from "../chunk-KAK4V57E.js";
50
- export {
51
- CONTENT_TYPE_CORE_PROPERTIES,
52
- CONTENT_TYPE_DOCX_DOCUMENT,
53
- CONTENT_TYPE_DOCX_FONT_TABLE,
54
- CONTENT_TYPE_DOCX_FOOTNOTES,
55
- CONTENT_TYPE_DOCX_NUMBERING,
56
- CONTENT_TYPE_DOCX_SETTINGS,
57
- CONTENT_TYPE_DOCX_STYLES,
58
- CONTENT_TYPE_PPTX_PRESENTATION,
59
- CONTENT_TYPE_RELATIONSHIPS,
60
- CONTENT_TYPE_XLSX_WORKBOOK,
61
- NS_CONTENT_TYPES,
62
- NS_CORE_PROPERTIES,
63
- NS_DC,
64
- NS_DCTERMS,
65
- NS_DRAWINGML,
66
- NS_MC,
67
- NS_PICTURE,
68
- NS_PML,
69
- NS_R,
70
- NS_RELATIONSHIPS,
71
- NS_SML,
72
- NS_WML,
73
- NS_WP_DRAWING,
74
- NS_XSI,
75
- REL_CORE_PROPERTIES,
76
- REL_EXTENDED_PROPERTIES,
77
- REL_FONT_TABLE,
78
- REL_FOOTNOTES,
79
- REL_HYPERLINK,
80
- REL_IMAGE,
81
- REL_NUMBERING,
82
- REL_OFFICE_DOCUMENT,
83
- REL_SETTINGS,
84
- REL_STYLES,
85
- REL_THEME,
86
- attrString,
87
- createPackage,
88
- escapeXml,
89
- getCoreProperties,
90
- getPartBinary,
91
- getPartRelationships,
92
- getPartXml,
93
- openPackage,
94
- selfClosingElement,
95
- textElement,
96
- xmlDeclaration,
97
- xmlElement
98
- };
1
+ /**
2
+ * @bendyline/squisq-formats OOXML Module
3
+ *
4
+ * Shared infrastructure for reading and writing Office Open XML packages
5
+ * (DOCX, PPTX, XLSX). Provides ZIP archive handling, relationship management,
6
+ * content type assembly, XML utilities, and core property parsing.
7
+ *
8
+ * This module is consumed by the format-specific modules (docx/, pptx/, xlsx/)
9
+ * and can also be imported directly by advanced consumers.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { createPackage, openPackage } from '@bendyline/squisq-formats/ooxml';
14
+ * ```
15
+ */
16
+ // Reader
17
+ export { openPackage, getPartRelationships, getPartXml, getPartBinary, getCoreProperties, } from './reader.js';
18
+ export { createPackage } from './writer.js';
19
+ // XML Utilities
20
+ export { xmlDeclaration, escapeXml, attrString, selfClosingElement, xmlElement, textElement, } from './xmlUtils.js';
21
+ // Namespace constants
22
+ export { NS_RELATIONSHIPS, NS_CONTENT_TYPES, REL_OFFICE_DOCUMENT, REL_CORE_PROPERTIES, REL_EXTENDED_PROPERTIES, REL_STYLES, REL_NUMBERING, REL_FONT_TABLE, REL_SETTINGS, REL_HYPERLINK, REL_IMAGE, REL_FOOTNOTES, REL_THEME, NS_WML, NS_PML, NS_SML, NS_DRAWINGML, NS_WP_DRAWING, NS_PICTURE, NS_DC, NS_DCTERMS, NS_CORE_PROPERTIES, NS_XSI, NS_MC, NS_R, CONTENT_TYPE_RELATIONSHIPS, CONTENT_TYPE_CORE_PROPERTIES, CONTENT_TYPE_DOCX_DOCUMENT, CONTENT_TYPE_DOCX_STYLES, CONTENT_TYPE_DOCX_NUMBERING, CONTENT_TYPE_DOCX_SETTINGS, CONTENT_TYPE_DOCX_FONT_TABLE, CONTENT_TYPE_DOCX_FOOTNOTES, CONTENT_TYPE_PPTX_PRESENTATION, CONTENT_TYPE_XLSX_WORKBOOK, } from './namespaces.js';
99
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ooxml/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAYH,SAAS;AACT,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,UAAU,EACV,aAAa,EACb,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,gBAAgB;AAChB,OAAO,EACL,cAAc,EACd,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,UAAU,EACV,WAAW,GACZ,MAAM,eAAe,CAAC;AAEvB,sBAAsB;AACtB,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,UAAU,EACV,aAAa,EACb,cAAc,EACd,YAAY,EACZ,aAAa,EACb,SAAS,EACT,aAAa,EACb,SAAS,EACT,MAAM,EACN,MAAM,EACN,MAAM,EACN,YAAY,EACZ,aAAa,EACb,UAAU,EACV,KAAK,EACL,UAAU,EACV,kBAAkB,EAClB,MAAM,EACN,KAAK,EACL,IAAI,EACJ,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,wBAAwB,EACxB,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,EAC3B,8BAA8B,EAC9B,0BAA0B,GAC3B,MAAM,iBAAiB,CAAC"}