@extend-ai/react-docx 0.7.0-alpha.3 → 0.7.0-alpha.5

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.
@@ -0,0 +1,422 @@
1
+ import {
2
+ mapsToWasmPackage,
3
+ wasmBuildDocModelFromPackage
4
+ } from "./chunk-2SXGXGWO.js";
5
+
6
+ // ../doc-model/src/normalize.ts
7
+ function normalizeUint8Array(value) {
8
+ if (value instanceof Uint8Array) {
9
+ return value;
10
+ }
11
+ if (Array.isArray(value)) {
12
+ return Uint8Array.from(value);
13
+ }
14
+ return void 0;
15
+ }
16
+ function normalizeParagraphChild(child) {
17
+ if (child.type !== "image") {
18
+ return child;
19
+ }
20
+ const image = child;
21
+ const data = normalizeUint8Array(image.data);
22
+ if (data === image.data) {
23
+ return child;
24
+ }
25
+ return {
26
+ ...image,
27
+ data
28
+ };
29
+ }
30
+ function normalizeTableCellContent(node) {
31
+ if (node.type === "table") {
32
+ return normalizeDocNode(node);
33
+ }
34
+ return {
35
+ ...node,
36
+ children: node.children.map(normalizeParagraphChild)
37
+ };
38
+ }
39
+ function normalizeDocNode(node) {
40
+ if (node.type === "paragraph") {
41
+ return {
42
+ ...node,
43
+ children: node.children.map(normalizeParagraphChild)
44
+ };
45
+ }
46
+ return {
47
+ ...node,
48
+ rows: node.rows.map((row) => ({
49
+ ...row,
50
+ cells: row.cells.map((cell) => ({
51
+ ...cell,
52
+ nodes: cell.nodes.map(normalizeTableCellContent)
53
+ }))
54
+ }))
55
+ };
56
+ }
57
+ function normalizeDocModel(model) {
58
+ return {
59
+ ...model,
60
+ nodes: model.nodes.map(normalizeDocNode),
61
+ metadata: {
62
+ ...model.metadata,
63
+ headerSections: model.metadata.headerSections.map((section) => ({
64
+ ...section,
65
+ nodes: section.nodes.map(normalizeDocNode)
66
+ })),
67
+ footerSections: model.metadata.footerSections.map((section) => ({
68
+ ...section,
69
+ nodes: section.nodes.map(normalizeDocNode)
70
+ })),
71
+ sections: model.metadata.sections?.map((section) => ({
72
+ ...section,
73
+ headerSections: section.headerSections.map((header) => ({
74
+ ...header,
75
+ nodes: header.nodes.map(normalizeDocNode)
76
+ })),
77
+ footerSections: section.footerSections.map((footer) => ({
78
+ ...footer,
79
+ nodes: footer.nodes.map(normalizeDocNode)
80
+ }))
81
+ })),
82
+ footnotes: model.metadata.footnotes?.map((note) => ({
83
+ ...note,
84
+ nodes: note.nodes?.map(normalizeDocNode)
85
+ })),
86
+ endnotes: model.metadata.endnotes?.map((note) => ({
87
+ ...note,
88
+ nodes: note.nodes?.map(normalizeDocNode)
89
+ }))
90
+ }
91
+ };
92
+ }
93
+
94
+ // ../doc-model/src/clone.ts
95
+ function isParagraphCellContent(node) {
96
+ return node.type === "paragraph";
97
+ }
98
+ function isTableCellContentTable(node) {
99
+ return node.type === "table";
100
+ }
101
+ function cloneTableCellContent(nodes) {
102
+ return nodes.map((node) => {
103
+ if (isParagraphCellContent(node)) {
104
+ return cloneParagraph(node);
105
+ }
106
+ if (isTableCellContentTable(node)) {
107
+ return cloneTable(node);
108
+ }
109
+ return node;
110
+ });
111
+ }
112
+ function cloneParagraphNumbering(numbering) {
113
+ return numbering ? { ...numbering } : void 0;
114
+ }
115
+ function cloneParagraphSpacing(spacing) {
116
+ return spacing ? { ...spacing } : void 0;
117
+ }
118
+ function cloneParagraphIndent(indent) {
119
+ return indent ? { ...indent } : void 0;
120
+ }
121
+ function cloneParagraphBorderStyle(border) {
122
+ return border ? { ...border } : void 0;
123
+ }
124
+ function cloneParagraphBorderSet(borders) {
125
+ if (!borders) {
126
+ return void 0;
127
+ }
128
+ return {
129
+ top: cloneParagraphBorderStyle(borders.top),
130
+ right: cloneParagraphBorderStyle(borders.right),
131
+ bottom: cloneParagraphBorderStyle(borders.bottom),
132
+ left: cloneParagraphBorderStyle(borders.left),
133
+ between: cloneParagraphBorderStyle(borders.between),
134
+ bar: cloneParagraphBorderStyle(borders.bar)
135
+ };
136
+ }
137
+ function cloneParagraphStyle(style) {
138
+ if (!style) {
139
+ return void 0;
140
+ }
141
+ return {
142
+ ...style,
143
+ numbering: cloneParagraphNumbering(style.numbering),
144
+ spacing: cloneParagraphSpacing(style.spacing),
145
+ indent: cloneParagraphIndent(style.indent),
146
+ borders: cloneParagraphBorderSet(style.borders),
147
+ dropCap: style.dropCap ? {
148
+ ...style.dropCap
149
+ } : void 0
150
+ };
151
+ }
152
+ function cloneParagraph(paragraph) {
153
+ return {
154
+ type: "paragraph",
155
+ style: cloneParagraphStyle(paragraph.style),
156
+ paragraphMarkDeleted: paragraph.paragraphMarkDeleted,
157
+ sourceXml: paragraph.sourceXml,
158
+ children: paragraph.children.map((child) => {
159
+ if (child.type === "text") {
160
+ return {
161
+ type: "text",
162
+ text: child.text,
163
+ style: child.style ? { ...child.style } : void 0,
164
+ link: child.link
165
+ };
166
+ }
167
+ if (child.type === "form-field") {
168
+ return {
169
+ type: "form-field",
170
+ fieldType: child.fieldType,
171
+ sourceKind: child.sourceKind,
172
+ id: child.id,
173
+ tag: child.tag,
174
+ title: child.title,
175
+ placeholder: child.placeholder,
176
+ checked: child.checked,
177
+ value: child.value,
178
+ options: child.options?.map((option) => ({
179
+ displayText: option.displayText,
180
+ value: option.value
181
+ })),
182
+ widget: child.widget ? {
183
+ name: child.widget.name,
184
+ enabled: child.widget.enabled,
185
+ calcOnExit: child.widget.calcOnExit,
186
+ text: child.widget.text ? {
187
+ inputType: child.widget.text.inputType,
188
+ defaultText: child.widget.text.defaultText,
189
+ maxLength: child.widget.text.maxLength,
190
+ textFormat: child.widget.text.textFormat
191
+ } : void 0,
192
+ checkbox: child.widget.checkbox ? {
193
+ defaultChecked: child.widget.checkbox.defaultChecked,
194
+ sizeMode: child.widget.checkbox.sizeMode,
195
+ sizePt: child.widget.checkbox.sizePt
196
+ } : void 0,
197
+ dropdown: child.widget.dropdown ? {
198
+ defaultValue: child.widget.dropdown.defaultValue
199
+ } : void 0
200
+ } : void 0,
201
+ checkedSymbol: child.checkedSymbol,
202
+ uncheckedSymbol: child.uncheckedSymbol,
203
+ style: child.style ? { ...child.style } : void 0,
204
+ link: child.link,
205
+ sourceXml: child.sourceXml
206
+ };
207
+ }
208
+ return {
209
+ type: "image",
210
+ src: child.src,
211
+ alt: child.alt,
212
+ widthPx: child.widthPx,
213
+ heightPx: child.heightPx,
214
+ partName: child.partName,
215
+ contentType: child.contentType,
216
+ data: child.data ? new Uint8Array(child.data) : void 0,
217
+ sourceXml: child.sourceXml,
218
+ crop: child.crop ? { ...child.crop } : void 0,
219
+ cssFilter: child.cssFilter,
220
+ cssOpacity: child.cssOpacity,
221
+ floating: child.floating ? { ...child.floating } : void 0,
222
+ syntheticTextBox: child.syntheticTextBox,
223
+ textBoxText: child.textBoxText
224
+ };
225
+ })
226
+ };
227
+ }
228
+ function cloneTableBoxSpacing(spacing) {
229
+ if (!spacing) {
230
+ return void 0;
231
+ }
232
+ return {
233
+ topTwips: spacing.topTwips,
234
+ rightTwips: spacing.rightTwips,
235
+ bottomTwips: spacing.bottomTwips,
236
+ leftTwips: spacing.leftTwips
237
+ };
238
+ }
239
+ function cloneTableBorderStyle(border) {
240
+ if (!border) {
241
+ return void 0;
242
+ }
243
+ return {
244
+ type: border.type,
245
+ color: border.color,
246
+ sizeEighthPt: border.sizeEighthPt
247
+ };
248
+ }
249
+ function cloneTableBorderSet(borders) {
250
+ if (!borders) {
251
+ return void 0;
252
+ }
253
+ return {
254
+ top: cloneTableBorderStyle(borders.top),
255
+ right: cloneTableBorderStyle(borders.right),
256
+ bottom: cloneTableBorderStyle(borders.bottom),
257
+ left: cloneTableBorderStyle(borders.left),
258
+ insideH: cloneTableBorderStyle(borders.insideH),
259
+ insideV: cloneTableBorderStyle(borders.insideV),
260
+ tl2br: cloneTableBorderStyle(borders.tl2br),
261
+ tr2bl: cloneTableBorderStyle(borders.tr2bl)
262
+ };
263
+ }
264
+ function cloneTableFloatingStyle(floating) {
265
+ if (!floating) {
266
+ return void 0;
267
+ }
268
+ return {
269
+ xTwips: floating.xTwips,
270
+ yTwips: floating.yTwips,
271
+ leftFromTextTwips: floating.leftFromTextTwips,
272
+ rightFromTextTwips: floating.rightFromTextTwips,
273
+ topFromTextTwips: floating.topFromTextTwips,
274
+ bottomFromTextTwips: floating.bottomFromTextTwips,
275
+ horizontalAnchor: floating.horizontalAnchor,
276
+ verticalAnchor: floating.verticalAnchor,
277
+ horizontalAlign: floating.horizontalAlign,
278
+ verticalAlign: floating.verticalAlign
279
+ };
280
+ }
281
+ function cloneTable(table) {
282
+ return {
283
+ type: "table",
284
+ sourceXml: table.sourceXml,
285
+ style: table.style ? {
286
+ widthTwips: table.style.widthTwips,
287
+ indentTwips: table.style.indentTwips,
288
+ layout: table.style.layout,
289
+ cellSpacingTwips: table.style.cellSpacingTwips,
290
+ floating: cloneTableFloatingStyle(table.style.floating),
291
+ cellMarginTwips: cloneTableBoxSpacing(table.style.cellMarginTwips),
292
+ columnWidthsTwips: table.style.columnWidthsTwips ? [...table.style.columnWidthsTwips] : void 0,
293
+ borders: cloneTableBorderSet(table.style.borders)
294
+ } : void 0,
295
+ rows: table.rows.map((row) => ({
296
+ type: "table-row",
297
+ style: row.style ? { ...row.style } : void 0,
298
+ cells: row.cells.map((cell) => ({
299
+ type: "table-cell",
300
+ style: cell.style ? {
301
+ ...cell.style,
302
+ marginTwips: cloneTableBoxSpacing(cell.style.marginTwips),
303
+ borders: cloneTableBorderSet(cell.style.borders)
304
+ } : void 0,
305
+ nodes: cloneTableCellContent(cell.nodes)
306
+ }))
307
+ }))
308
+ };
309
+ }
310
+ function cloneDocNode(node) {
311
+ return node.type === "paragraph" ? cloneParagraph(node) : cloneTable(node);
312
+ }
313
+ function cloneNumberingDefinitions(numberingDefinitions) {
314
+ if (!numberingDefinitions) {
315
+ return void 0;
316
+ }
317
+ return {
318
+ abstracts: numberingDefinitions.abstracts.map((abstractDefinition) => ({
319
+ abstractNumId: abstractDefinition.abstractNumId,
320
+ levels: abstractDefinition.levels.map((level) => ({
321
+ ...level,
322
+ runStyle: level.runStyle ? { ...level.runStyle } : void 0,
323
+ pictureBullet: level.pictureBullet ? { ...level.pictureBullet } : void 0
324
+ }))
325
+ })),
326
+ instances: numberingDefinitions.instances.map((instanceDefinition) => ({
327
+ numId: instanceDefinition.numId,
328
+ abstractNumId: instanceDefinition.abstractNumId,
329
+ levelStartOverrides: instanceDefinition.levelStartOverrides ? { ...instanceDefinition.levelStartOverrides } : void 0,
330
+ levelOverrides: instanceDefinition.levelOverrides ? instanceDefinition.levelOverrides.map((level) => ({
331
+ ...level,
332
+ runStyle: level.runStyle ? { ...level.runStyle } : void 0,
333
+ pictureBullet: level.pictureBullet ? { ...level.pictureBullet } : void 0
334
+ })) : void 0
335
+ }))
336
+ };
337
+ }
338
+ function cloneDocModel(model) {
339
+ return {
340
+ nodes: model.nodes.map(cloneDocNode),
341
+ metadata: {
342
+ sourceParts: model.metadata.sourceParts,
343
+ warnings: [...model.metadata.warnings],
344
+ documentPageCount: model.metadata.documentPageCount,
345
+ documentOpenTag: model.metadata.documentOpenTag,
346
+ documentBackgroundColor: model.metadata.documentBackgroundColor,
347
+ sectionPropertiesXml: model.metadata.sectionPropertiesXml,
348
+ sections: model.metadata.sections?.map((section) => ({
349
+ startNodeIndex: section.startNodeIndex,
350
+ sectionPropertiesXml: section.sectionPropertiesXml,
351
+ headerSections: (section.headerSections ?? []).map((headerSection) => ({
352
+ partName: headerSection.partName,
353
+ referenceType: headerSection.referenceType,
354
+ nodes: headerSection.nodes.map(cloneDocNode)
355
+ })),
356
+ footerSections: (section.footerSections ?? []).map((footerSection) => ({
357
+ partName: footerSection.partName,
358
+ referenceType: footerSection.referenceType,
359
+ nodes: footerSection.nodes.map(cloneDocNode)
360
+ }))
361
+ })),
362
+ headerSections: (model.metadata.headerSections ?? []).map((section) => ({
363
+ partName: section.partName,
364
+ referenceType: section.referenceType,
365
+ nodes: section.nodes.map(cloneDocNode)
366
+ })),
367
+ footerSections: (model.metadata.footerSections ?? []).map((section) => ({
368
+ partName: section.partName,
369
+ referenceType: section.referenceType,
370
+ nodes: section.nodes.map(cloneDocNode)
371
+ })),
372
+ paragraphStyles: (model.metadata.paragraphStyles ?? []).map((style) => ({
373
+ ...style,
374
+ runStyle: style.runStyle ? { ...style.runStyle } : void 0,
375
+ numbering: cloneParagraphNumbering(style.numbering),
376
+ spacing: cloneParagraphSpacing(style.spacing),
377
+ indent: cloneParagraphIndent(style.indent),
378
+ borders: cloneParagraphBorderSet(style.borders)
379
+ })),
380
+ defaultParagraphStyleId: model.metadata.defaultParagraphStyleId,
381
+ numberingDefinitions: cloneNumberingDefinitions(
382
+ model.metadata.numberingDefinitions
383
+ ),
384
+ compatibility: model.metadata.compatibility ? { ...model.metadata.compatibility } : void 0,
385
+ footnotes: model.metadata.footnotes?.map((note) => ({
386
+ ...note,
387
+ nodes: note.nodes?.map(cloneDocNode)
388
+ })),
389
+ endnotes: model.metadata.endnotes?.map((note) => ({
390
+ ...note,
391
+ nodes: note.nodes?.map(cloneDocNode)
392
+ })),
393
+ comments: model.metadata.comments?.map((comment) => ({ ...comment }))
394
+ }
395
+ };
396
+ }
397
+
398
+ // ../doc-model/src/index.ts
399
+ async function buildDocModel(pkg) {
400
+ const wasmPackage = mapsToWasmPackage({
401
+ parts: pkg.parts,
402
+ binaryAssets: pkg.binaryAssets
403
+ });
404
+ const model = await wasmBuildDocModelFromPackage(wasmPackage);
405
+ return normalizeDocModel(model);
406
+ }
407
+ async function buildDocModelFromBytes(bytes) {
408
+ const { parseDocx } = await import("./src-PJYTN6DB.js");
409
+ const payload = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
410
+ const buffer = payload.buffer.slice(payload.byteOffset, payload.byteOffset + payload.byteLength);
411
+ const pkg = await parseDocx(buffer);
412
+ const model = await buildDocModel(pkg);
413
+ return { package: pkg, model };
414
+ }
415
+
416
+ export {
417
+ normalizeDocModel,
418
+ cloneDocModel,
419
+ buildDocModel,
420
+ buildDocModelFromBytes
421
+ };
422
+ //# sourceMappingURL=chunk-P3B3Q7Y6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../doc-model/src/normalize.ts","../../doc-model/src/clone.ts","../../doc-model/src/index.ts"],"sourcesContent":["import type {\n DocModel,\n DocNode,\n ImageRunNode,\n ParagraphChildNode,\n TableCellContentNode\n} from \"./types\";\n\nfunction normalizeUint8Array(value: unknown): Uint8Array | undefined {\n if (value instanceof Uint8Array) {\n return value;\n }\n if (Array.isArray(value)) {\n return Uint8Array.from(value as number[]);\n }\n return undefined;\n}\n\nfunction normalizeParagraphChild(child: ParagraphChildNode): ParagraphChildNode {\n if (child.type !== \"image\") {\n return child;\n }\n\n const image = child as ImageRunNode;\n const data = normalizeUint8Array(image.data);\n if (data === image.data) {\n return child;\n }\n\n return {\n ...image,\n data\n };\n}\n\nfunction normalizeTableCellContent(node: TableCellContentNode): TableCellContentNode {\n if (node.type === \"table\") {\n return normalizeDocNode(node) as TableCellContentNode;\n }\n\n return {\n ...node,\n children: node.children.map(normalizeParagraphChild)\n };\n}\n\nfunction normalizeDocNode(node: DocNode): DocNode {\n if (node.type === \"paragraph\") {\n return {\n ...node,\n children: node.children.map(normalizeParagraphChild)\n };\n }\n\n return {\n ...node,\n rows: node.rows.map((row) => ({\n ...row,\n cells: row.cells.map((cell) => ({\n ...cell,\n nodes: cell.nodes.map(normalizeTableCellContent)\n }))\n }))\n };\n}\n\nexport function normalizeDocModel(model: DocModel): DocModel {\n return {\n ...model,\n nodes: model.nodes.map(normalizeDocNode),\n metadata: {\n ...model.metadata,\n headerSections: model.metadata.headerSections.map((section) => ({\n ...section,\n nodes: section.nodes.map(normalizeDocNode)\n })),\n footerSections: model.metadata.footerSections.map((section) => ({\n ...section,\n nodes: section.nodes.map(normalizeDocNode)\n })),\n sections: model.metadata.sections?.map((section) => ({\n ...section,\n headerSections: section.headerSections.map((header) => ({\n ...header,\n nodes: header.nodes.map(normalizeDocNode)\n })),\n footerSections: section.footerSections.map((footer) => ({\n ...footer,\n nodes: footer.nodes.map(normalizeDocNode)\n }))\n })),\n footnotes: model.metadata.footnotes?.map((note) => ({\n ...note,\n nodes: note.nodes?.map(normalizeDocNode)\n })),\n endnotes: model.metadata.endnotes?.map((note) => ({\n ...note,\n nodes: note.nodes?.map(normalizeDocNode)\n }))\n }\n };\n}\n","import type {\n DocModel,\n DocNode,\n FooterSection,\n HeaderSection,\n NumberingDefinitionSet,\n ParagraphBorderSet,\n ParagraphBorderStyle,\n ParagraphIndent,\n ParagraphNode,\n ParagraphNumbering,\n ParagraphSpacing,\n ParagraphStyle,\n ParagraphStyleDefinition,\n TableBorderSet,\n TableBorderStyle,\n TableBoxSpacing,\n TableCellContentNode,\n TableNode,\n TableStyle,\n} from \"./types\";\n\nfunction isParagraphCellContent(\n node: TableCellContentNode\n): node is ParagraphNode {\n return node.type === \"paragraph\";\n}\n\nfunction isTableCellContentTable(\n node: TableCellContentNode\n): node is TableNode {\n return node.type === \"table\";\n}\n\nfunction cloneTableCellContent(\n nodes: TableCellContentNode[]\n): TableCellContentNode[] {\n return nodes.map((node) => {\n if (isParagraphCellContent(node)) {\n return cloneParagraph(node);\n }\n\n if (isTableCellContentTable(node)) {\n return cloneTable(node);\n }\n\n return node;\n });\n}\n\nfunction cloneParagraphNumbering(\n numbering?: ParagraphNumbering\n): ParagraphNumbering | undefined {\n return numbering ? { ...numbering } : undefined;\n}\n\nfunction cloneParagraphSpacing(\n spacing?: ParagraphSpacing\n): ParagraphSpacing | undefined {\n return spacing ? { ...spacing } : undefined;\n}\n\nfunction cloneParagraphIndent(\n indent?: ParagraphIndent\n): ParagraphIndent | undefined {\n return indent ? { ...indent } : undefined;\n}\n\nfunction cloneParagraphBorderStyle(\n border?: ParagraphBorderStyle\n): ParagraphBorderStyle | undefined {\n return border ? { ...border } : undefined;\n}\n\nfunction cloneParagraphBorderSet(\n borders?: ParagraphBorderSet\n): ParagraphBorderSet | undefined {\n if (!borders) {\n return undefined;\n }\n\n return {\n top: cloneParagraphBorderStyle(borders.top),\n right: cloneParagraphBorderStyle(borders.right),\n bottom: cloneParagraphBorderStyle(borders.bottom),\n left: cloneParagraphBorderStyle(borders.left),\n between: cloneParagraphBorderStyle(borders.between),\n bar: cloneParagraphBorderStyle(borders.bar),\n };\n}\n\nfunction cloneParagraphStyle(\n style?: ParagraphStyle\n): ParagraphStyle | undefined {\n if (!style) {\n return undefined;\n }\n\n return {\n ...style,\n numbering: cloneParagraphNumbering(style.numbering),\n spacing: cloneParagraphSpacing(style.spacing),\n indent: cloneParagraphIndent(style.indent),\n borders: cloneParagraphBorderSet(style.borders),\n dropCap: style.dropCap\n ? {\n ...style.dropCap,\n }\n : undefined,\n };\n}\n\nfunction cloneParagraph(paragraph: ParagraphNode): ParagraphNode {\n return {\n type: \"paragraph\",\n style: cloneParagraphStyle(paragraph.style),\n paragraphMarkDeleted: paragraph.paragraphMarkDeleted,\n sourceXml: paragraph.sourceXml,\n children: paragraph.children.map((child) => {\n if (child.type === \"text\") {\n return {\n type: \"text\" as const,\n text: child.text,\n style: child.style ? { ...child.style } : undefined,\n link: child.link,\n };\n }\n\n if (child.type === \"form-field\") {\n return {\n type: \"form-field\" as const,\n fieldType: child.fieldType,\n sourceKind: child.sourceKind,\n id: child.id,\n tag: child.tag,\n title: child.title,\n placeholder: child.placeholder,\n checked: child.checked,\n value: child.value,\n options: child.options?.map((option) => ({\n displayText: option.displayText,\n value: option.value,\n })),\n widget: child.widget\n ? {\n name: child.widget.name,\n enabled: child.widget.enabled,\n calcOnExit: child.widget.calcOnExit,\n text: child.widget.text\n ? {\n inputType: child.widget.text.inputType,\n defaultText: child.widget.text.defaultText,\n maxLength: child.widget.text.maxLength,\n textFormat: child.widget.text.textFormat,\n }\n : undefined,\n checkbox: child.widget.checkbox\n ? {\n defaultChecked: child.widget.checkbox.defaultChecked,\n sizeMode: child.widget.checkbox.sizeMode,\n sizePt: child.widget.checkbox.sizePt,\n }\n : undefined,\n dropdown: child.widget.dropdown\n ? {\n defaultValue: child.widget.dropdown.defaultValue,\n }\n : undefined,\n }\n : undefined,\n checkedSymbol: child.checkedSymbol,\n uncheckedSymbol: child.uncheckedSymbol,\n style: child.style ? { ...child.style } : undefined,\n link: child.link,\n sourceXml: child.sourceXml,\n };\n }\n\n return {\n type: \"image\" as const,\n src: child.src,\n alt: child.alt,\n widthPx: child.widthPx,\n heightPx: child.heightPx,\n partName: child.partName,\n contentType: child.contentType,\n data: child.data ? new Uint8Array(child.data) : undefined,\n sourceXml: child.sourceXml,\n crop: child.crop ? { ...child.crop } : undefined,\n cssFilter: child.cssFilter,\n cssOpacity: child.cssOpacity,\n floating: child.floating ? { ...child.floating } : undefined,\n syntheticTextBox: child.syntheticTextBox,\n textBoxText: child.textBoxText,\n };\n }),\n };\n}\n\nfunction cloneTableBoxSpacing(\n spacing?: TableBoxSpacing\n): TableBoxSpacing | undefined {\n if (!spacing) {\n return undefined;\n }\n\n return {\n topTwips: spacing.topTwips,\n rightTwips: spacing.rightTwips,\n bottomTwips: spacing.bottomTwips,\n leftTwips: spacing.leftTwips,\n };\n}\n\nfunction cloneTableBorderStyle(\n border?: TableBorderStyle\n): TableBorderStyle | undefined {\n if (!border) {\n return undefined;\n }\n\n return {\n type: border.type,\n color: border.color,\n sizeEighthPt: border.sizeEighthPt,\n };\n}\n\nfunction cloneTableBorderSet(\n borders?: TableBorderSet\n): TableBorderSet | undefined {\n if (!borders) {\n return undefined;\n }\n\n return {\n top: cloneTableBorderStyle(borders.top),\n right: cloneTableBorderStyle(borders.right),\n bottom: cloneTableBorderStyle(borders.bottom),\n left: cloneTableBorderStyle(borders.left),\n insideH: cloneTableBorderStyle(borders.insideH),\n insideV: cloneTableBorderStyle(borders.insideV),\n tl2br: cloneTableBorderStyle(borders.tl2br),\n tr2bl: cloneTableBorderStyle(borders.tr2bl),\n };\n}\n\nfunction cloneTableFloatingStyle(\n floating?: NonNullable<TableStyle[\"floating\"]>\n): NonNullable<TableStyle[\"floating\"]> | undefined {\n if (!floating) {\n return undefined;\n }\n\n return {\n xTwips: floating.xTwips,\n yTwips: floating.yTwips,\n leftFromTextTwips: floating.leftFromTextTwips,\n rightFromTextTwips: floating.rightFromTextTwips,\n topFromTextTwips: floating.topFromTextTwips,\n bottomFromTextTwips: floating.bottomFromTextTwips,\n horizontalAnchor: floating.horizontalAnchor,\n verticalAnchor: floating.verticalAnchor,\n horizontalAlign: floating.horizontalAlign,\n verticalAlign: floating.verticalAlign,\n };\n}\n\nfunction cloneTable(table: TableNode): TableNode {\n return {\n type: \"table\",\n sourceXml: table.sourceXml,\n style: table.style\n ? {\n widthTwips: table.style.widthTwips,\n indentTwips: table.style.indentTwips,\n layout: table.style.layout,\n cellSpacingTwips: table.style.cellSpacingTwips,\n floating: cloneTableFloatingStyle(table.style.floating),\n cellMarginTwips: cloneTableBoxSpacing(table.style.cellMarginTwips),\n columnWidthsTwips: table.style.columnWidthsTwips\n ? [...table.style.columnWidthsTwips]\n : undefined,\n borders: cloneTableBorderSet(table.style.borders),\n }\n : undefined,\n rows: table.rows.map((row) => ({\n type: \"table-row\",\n style: row.style ? { ...row.style } : undefined,\n cells: row.cells.map((cell) => ({\n type: \"table-cell\",\n style: cell.style\n ? {\n ...cell.style,\n marginTwips: cloneTableBoxSpacing(cell.style.marginTwips),\n borders: cloneTableBorderSet(cell.style.borders),\n }\n : undefined,\n nodes: cloneTableCellContent(cell.nodes),\n })),\n })),\n };\n}\n\nfunction cloneDocNode(node: DocNode): DocNode {\n return node.type === \"paragraph\" ? cloneParagraph(node) : cloneTable(node);\n}\n\nfunction cloneNumberingDefinitions(\n numberingDefinitions?: NumberingDefinitionSet\n): NumberingDefinitionSet | undefined {\n if (!numberingDefinitions) {\n return undefined;\n }\n\n return {\n abstracts: numberingDefinitions.abstracts.map((abstractDefinition) => ({\n abstractNumId: abstractDefinition.abstractNumId,\n levels: abstractDefinition.levels.map((level) => ({\n ...level,\n runStyle: level.runStyle ? { ...level.runStyle } : undefined,\n pictureBullet: level.pictureBullet\n ? { ...level.pictureBullet }\n : undefined,\n })),\n })),\n instances: numberingDefinitions.instances.map((instanceDefinition) => ({\n numId: instanceDefinition.numId,\n abstractNumId: instanceDefinition.abstractNumId,\n levelStartOverrides: instanceDefinition.levelStartOverrides\n ? { ...instanceDefinition.levelStartOverrides }\n : undefined,\n levelOverrides: instanceDefinition.levelOverrides\n ? instanceDefinition.levelOverrides.map((level) => ({\n ...level,\n runStyle: level.runStyle ? { ...level.runStyle } : undefined,\n pictureBullet: level.pictureBullet\n ? { ...level.pictureBullet }\n : undefined,\n }))\n : undefined,\n })),\n };\n}\n\nexport function cloneDocModel(model: DocModel): DocModel {\n return {\n nodes: model.nodes.map(cloneDocNode),\n metadata: {\n sourceParts: model.metadata.sourceParts,\n warnings: [...model.metadata.warnings],\n documentPageCount: model.metadata.documentPageCount,\n documentOpenTag: model.metadata.documentOpenTag,\n documentBackgroundColor: model.metadata.documentBackgroundColor,\n sectionPropertiesXml: model.metadata.sectionPropertiesXml,\n sections: model.metadata.sections?.map((section) => ({\n startNodeIndex: section.startNodeIndex,\n sectionPropertiesXml: section.sectionPropertiesXml,\n headerSections: (section.headerSections ?? []).map((headerSection) => ({\n partName: headerSection.partName,\n referenceType: headerSection.referenceType,\n nodes: headerSection.nodes.map(cloneDocNode),\n })),\n footerSections: (section.footerSections ?? []).map((footerSection) => ({\n partName: footerSection.partName,\n referenceType: footerSection.referenceType,\n nodes: footerSection.nodes.map(cloneDocNode),\n })),\n })),\n headerSections: (model.metadata.headerSections ?? []).map((section) => ({\n partName: section.partName,\n referenceType: section.referenceType,\n nodes: section.nodes.map(cloneDocNode),\n })),\n footerSections: (model.metadata.footerSections ?? []).map((section) => ({\n partName: section.partName,\n referenceType: section.referenceType,\n nodes: section.nodes.map(cloneDocNode),\n })),\n paragraphStyles: (model.metadata.paragraphStyles ?? []).map((style) => ({\n ...style,\n runStyle: style.runStyle ? { ...style.runStyle } : undefined,\n numbering: cloneParagraphNumbering(style.numbering),\n spacing: cloneParagraphSpacing(style.spacing),\n indent: cloneParagraphIndent(style.indent),\n borders: cloneParagraphBorderSet(style.borders),\n })),\n defaultParagraphStyleId: model.metadata.defaultParagraphStyleId,\n numberingDefinitions: cloneNumberingDefinitions(\n model.metadata.numberingDefinitions\n ),\n compatibility: model.metadata.compatibility\n ? { ...model.metadata.compatibility }\n : undefined,\n footnotes: model.metadata.footnotes?.map((note) => ({\n ...note,\n nodes: note.nodes?.map(cloneDocNode),\n })),\n endnotes: model.metadata.endnotes?.map((note) => ({\n ...note,\n nodes: note.nodes?.map(cloneDocNode),\n })),\n comments: model.metadata.comments?.map((comment) => ({ ...comment })),\n },\n };\n}\n","import type { OoxmlPackage } from \"@extend-ai/react-docx-ooxml-core\";\nimport {\n mapsToWasmPackage,\n wasmBuildDocModelFromPackage,\n wasmPackageToMaps\n} from \"@extend-ai/react-docx-wasm\";\n\nimport { normalizeDocModel } from \"./normalize\";\nimport type { DocModel } from \"./types\";\n\nexport * from \"./types\";\nexport { cloneDocModel } from \"./clone\";\nexport { normalizeDocModel } from \"./normalize\";\n\nexport async function buildDocModel(pkg: OoxmlPackage): Promise<DocModel> {\n const wasmPackage = mapsToWasmPackage({\n parts: pkg.parts,\n binaryAssets: pkg.binaryAssets\n });\n const model = (await wasmBuildDocModelFromPackage(wasmPackage)) as DocModel;\n return normalizeDocModel(model);\n}\n\nexport async function buildDocModelFromBytes(bytes: ArrayBuffer | Uint8Array): Promise<{\n package: OoxmlPackage;\n model: DocModel;\n}> {\n const { parseDocx } = await import(\"@extend-ai/react-docx-ooxml-core\");\n const payload = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);\n const buffer =\n payload.buffer.slice(payload.byteOffset, payload.byteOffset + payload.byteLength) as ArrayBuffer;\n const pkg = await parseDocx(buffer);\n const model = await buildDocModel(pkg);\n return { package: pkg, model };\n}\n"],"mappings":";;;;;;AAQA,SAAS,oBAAoB,OAAwC;AACnE,MAAI,iBAAiB,YAAY;AAC/B,WAAO;AAAA,EACT;AACA,MAAI,MAAM,QAAQ,KAAK,GAAG;AAC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AAM,SAAS;AAAA,MACjB;AAAA,MACA,eAAe,MAAM,SAAS,gBAC1B,EAAE,GAAG,MAAM,SAAS,cAAc,IAClC;AAAA,MACJ,WAAW,MAAM,SAAS,WAAW,IAAI,CAAC,UAAU;AAAA,QAClD,GAAG;AAAA,QACH,OAAO,KAAK,OAAO,IAAI,YAAY;AAAA,MACrC,EAAE;AAAA,MACF,UAAU,MAAM,SAAS,UAAU,IAAI,CAAC,UAAU;AAAA,QAChD,GAAG;AAAA,QACH,OAAO,KAAK,OAAO,IAAI,YAAY;AAAA,MACrC,EAAE;AAAA,MACF,UAAU,MAAM,SAAS,UAAU,IAAI,CAAC,aAAa,EAAE,GAAG,QAAQ,EAAE;AAAA,IACtE;AAAA,EACF;AACF;;;ACvYA,eAAsB,cAAc,KAAsC;AACxE,QAAM,cAAc,kBAAkB;AAAA,IACpC,OAAO,IAAI;AAAA,IACX,cAAc,IAAI;AAAA,EACpB,CAAC;AACD,QAAM,QAAS,MAAM,6BAA6B,WAAW;AAC7D,SAAO,kBAAkB,KAAK;AAChC;AAEA,eAAsB,uBAAuB,OAG1C;AACD,QAAM,EAAE,UAAU,IAAI,MAAM,OAAO,mBAAkC;AACrE,QAAM,UAAU,iBAAiB,aAAa,QAAQ,IAAI,WAAW,KAAK;AAC1E,QAAM,SACJ,QAAQ,OAAO,MAAM,QAAQ,YAAY,QAAQ,aAAa,QAAQ,UAAU;AAClF,QAAM,MAAM,MAAM,UAAU,MAAM;AAClC,QAAM,QAAQ,MAAM,cAAc,GAAG;AACrC,SAAO,EAAE,SAAS,KAAK,MAAM;AAC/B;","names":[]}
@@ -0,0 +1,73 @@
1
+ import {
2
+ mapsToWasmPackage,
3
+ wasmPackageToArrayBuffer,
4
+ wasmPackageToMaps,
5
+ wasmParseDocx
6
+ } from "./chunk-2SXGXGWO.js";
7
+
8
+ // ../ooxml-core/src/index.ts
9
+ async function parseDocx(input) {
10
+ const wasmPackage = await wasmParseDocx(input);
11
+ const { parts, binaryAssets } = wasmPackageToMaps(wasmPackage);
12
+ return { parts, binaryAssets };
13
+ }
14
+ async function packageToArrayBuffer(pkg) {
15
+ return wasmPackageToArrayBuffer(mapsToWasmPackage(pkg));
16
+ }
17
+ function createMinimalDocxPackage(documentXml = DEFAULT_DOCUMENT_XML) {
18
+ return {
19
+ parts: /* @__PURE__ */ new Map([
20
+ ["[Content_Types].xml", { name: "[Content_Types].xml", content: DEFAULT_CONTENT_TYPES_XML }],
21
+ ["_rels/.rels", { name: "_rels/.rels", content: DEFAULT_ROOT_RELS_XML }],
22
+ ["word/document.xml", { name: "word/document.xml", content: documentXml }],
23
+ [
24
+ "word/_rels/document.xml.rels",
25
+ { name: "word/_rels/document.xml.rels", content: DEFAULT_DOCUMENT_RELS_XML }
26
+ ]
27
+ ]),
28
+ binaryAssets: /* @__PURE__ */ new Map()
29
+ };
30
+ }
31
+ function getPart(pkg, partName) {
32
+ return pkg.parts.get(partName);
33
+ }
34
+ function withPart(pkg, part) {
35
+ const parts = new Map(pkg.parts);
36
+ parts.set(part.name, part);
37
+ return {
38
+ parts,
39
+ binaryAssets: new Map(pkg.binaryAssets)
40
+ };
41
+ }
42
+ var WORD_MAIN_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
43
+ var DEFAULT_DOCUMENT_XML = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
44
+ <w:document xmlns:w="${WORD_MAIN_NS}">
45
+ <w:body>
46
+ <w:p><w:r><w:t/></w:r></w:p>
47
+ <w:sectPr>
48
+ <w:pgSz w:w="12240" w:h="15840"/>
49
+ <w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="708" w:footer="708" w:gutter="0"/>
50
+ </w:sectPr>
51
+ </w:body>
52
+ </w:document>`;
53
+ var DEFAULT_CONTENT_TYPES_XML = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
54
+ <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
55
+ <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
56
+ <Default Extension="xml" ContentType="application/xml"/>
57
+ <Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>
58
+ </Types>`;
59
+ var DEFAULT_ROOT_RELS_XML = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
60
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
61
+ <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/>
62
+ </Relationships>`;
63
+ var DEFAULT_DOCUMENT_RELS_XML = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
64
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"/>`;
65
+
66
+ export {
67
+ parseDocx,
68
+ packageToArrayBuffer,
69
+ createMinimalDocxPackage,
70
+ getPart,
71
+ withPart
72
+ };
73
+ //# sourceMappingURL=chunk-QOXSE6WY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../ooxml-core/src/index.ts"],"sourcesContent":["import {\n mapsToWasmPackage,\n wasmPackageToArrayBuffer,\n wasmPackageToMaps,\n wasmParseDocx,\n type LegacyWasmOoxmlPackage,\n type WasmOoxmlPackage\n} from \"@extend-ai/react-docx-wasm\";\n\nexport interface OoxmlPart {\n name: string;\n content: string;\n}\n\nexport interface OoxmlPackage {\n parts: Map<string, OoxmlPart>;\n binaryAssets: Map<string, Uint8Array>;\n}\n\nexport async function parseDocx(input: ArrayBuffer): Promise<OoxmlPackage> {\n const wasmPackage = await wasmParseDocx(input);\n const { parts, binaryAssets } = wasmPackageToMaps(wasmPackage);\n return { parts, binaryAssets };\n}\n\nexport async function packageToArrayBuffer(pkg: OoxmlPackage): Promise<ArrayBuffer> {\n return wasmPackageToArrayBuffer(mapsToWasmPackage(pkg));\n}\n\nexport function createMinimalDocxPackage(\n documentXml = DEFAULT_DOCUMENT_XML\n): OoxmlPackage {\n return {\n parts: new Map([\n [\"[Content_Types].xml\", { name: \"[Content_Types].xml\", content: DEFAULT_CONTENT_TYPES_XML }],\n [\"_rels/.rels\", { name: \"_rels/.rels\", content: DEFAULT_ROOT_RELS_XML }],\n [\"word/document.xml\", { name: \"word/document.xml\", content: documentXml }],\n [\n \"word/_rels/document.xml.rels\",\n { name: \"word/_rels/document.xml.rels\", content: DEFAULT_DOCUMENT_RELS_XML }\n ]\n ]),\n binaryAssets: new Map()\n };\n}\n\nexport function getPart(pkg: OoxmlPackage, partName: string): OoxmlPart | undefined {\n return pkg.parts.get(partName);\n}\n\nexport function withPart(pkg: OoxmlPackage, part: OoxmlPart): OoxmlPackage {\n const parts = new Map(pkg.parts);\n parts.set(part.name, part);\n return {\n parts,\n binaryAssets: new Map(pkg.binaryAssets)\n };\n}\n\nconst WORD_MAIN_NS = \"http://schemas.openxmlformats.org/wordprocessingml/2006/main\";\n\nconst DEFAULT_DOCUMENT_XML = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<w:document xmlns:w=\"${WORD_MAIN_NS}\">\n <w:body>\n <w:p><w:r><w:t/></w:r></w:p>\n <w:sectPr>\n <w:pgSz w:w=\"12240\" w:h=\"15840\"/>\n <w:pgMar w:top=\"1440\" w:right=\"1440\" w:bottom=\"1440\" w:left=\"1440\" w:header=\"708\" w:footer=\"708\" w:gutter=\"0\"/>\n </w:sectPr>\n </w:body>\n</w:document>`;\n\nconst DEFAULT_CONTENT_TYPES_XML = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">\n <Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/>\n <Default Extension=\"xml\" ContentType=\"application/xml\"/>\n <Override PartName=\"/word/document.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\"/>\n</Types>`;\n\nconst DEFAULT_ROOT_RELS_XML = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\n <Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument\" Target=\"word/document.xml\"/>\n</Relationships>`;\n\nconst DEFAULT_DOCUMENT_RELS_XML = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\"/>`;\n\nexport type { LegacyWasmOoxmlPackage, WasmOoxmlPackage };\n"],"mappings":";;;;;;;;AAmBA,eAAsB,UAAU,OAA2C;AACzE,QAAM,cAAc,MAAM,cAAc,KAAK;AAC7C,QAAM,EAAE,OAAO,aAAa,IAAI,kBAAkB,WAAW;AAC7D,SAAO,EAAE,OAAO,aAAa;AAC/B;AAEA,eAAsB,qBAAqB,KAAyC;AAClF,SAAO,yBAAyB,kBAAkB,GAAG,CAAC;AACxD;AAEO,SAAS,yBACd,cAAc,sBACA;AACd,SAAO;AAAA,IACL,OAAO,oBAAI,IAAI;AAAA,MACb,CAAC,uBAAuB,EAAE,MAAM,uBAAuB,SAAS,0BAA0B,CAAC;AAAA,MAC3F,CAAC,eAAe,EAAE,MAAM,eAAe,SAAS,sBAAsB,CAAC;AAAA,MACvE,CAAC,qBAAqB,EAAE,MAAM,qBAAqB,SAAS,YAAY,CAAC;AAAA,MACzE;AAAA,QACE;AAAA,QACA,EAAE,MAAM,gCAAgC,SAAS,0BAA0B;AAAA,MAC7E;AAAA,IACF,CAAC;AAAA,IACD,cAAc,oBAAI,IAAI;AAAA,EACxB;AACF;AAEO,SAAS,QAAQ,KAAmB,UAAyC;AAClF,SAAO,IAAI,MAAM,IAAI,QAAQ;AAC/B;AAEO,SAAS,SAAS,KAAmB,MAA+B;AACzE,QAAM,QAAQ,IAAI,IAAI,IAAI,KAAK;AAC/B,QAAM,IAAI,KAAK,MAAM,IAAI;AACzB,SAAO;AAAA,IACL;AAAA,IACA,cAAc,IAA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