@office-open/xml 0.6.7 → 0.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +12 -12
- package/dist/utils.d.mts +1 -1
- package/package.json +1 -1
- /package/dist/{utils-DTU54qj_.d.mts → utils-CSaXdiWb.d.mts} +0 -0
package/README.md
CHANGED
|
@@ -103,31 +103,31 @@ Performance comparison against original `xml` (1.0.1) and `xml-js` (1.6.11) pack
|
|
|
103
103
|
|
|
104
104
|
| Scenario | @office-open/xml | xml | Speedup |
|
|
105
105
|
| ----------------------- | ---------------: | ---------: | --------: |
|
|
106
|
-
| Simple element | 5,
|
|
107
|
-
| Nested element |
|
|
108
|
-
| Nested with declaration |
|
|
106
|
+
| Simple element | 5,069,751 hz | 724,533 hz | **7.00x** |
|
|
107
|
+
| Nested element | 1,122,376 hz | 279,423 hz | **4.02x** |
|
|
108
|
+
| Nested with declaration | 1,050,046 hz | 248,678 hz | **4.22x** |
|
|
109
109
|
|
|
110
110
|
### Parsing (xml2js)
|
|
111
111
|
|
|
112
112
|
| Scenario | @office-open/xml | xml-js | Speedup |
|
|
113
113
|
| ------------------ | ---------------: | --------: | ---------: |
|
|
114
|
-
| Simple XML | 1,
|
|
115
|
-
| Complex OOXML |
|
|
116
|
-
| With captureSpaces |
|
|
114
|
+
| Simple XML | 1,000,869 hz | 90,488 hz | **11.06x** |
|
|
115
|
+
| Complex OOXML | 310,266 hz | 42,938 hz | **7.23x** |
|
|
116
|
+
| With captureSpaces | 313,183 hz | 41,814 hz | **7.49x** |
|
|
117
117
|
|
|
118
118
|
### Stringifying (js2xml)
|
|
119
119
|
|
|
120
120
|
| Scenario | @office-open/xml | xml-js | Speedup |
|
|
121
121
|
| -------------- | ---------------: | ---------: | --------: |
|
|
122
|
-
| Simple element |
|
|
123
|
-
| Complex OOXML |
|
|
122
|
+
| Simple element | 975,878 hz | 198,953 hz | **4.90x** |
|
|
123
|
+
| Complex OOXML | 492,220 hz | 107,815 hz | **4.57x** |
|
|
124
124
|
|
|
125
125
|
### Direct Conversion (toElement vs bridge)
|
|
126
126
|
|
|
127
127
|
| Scenario | toElement() | xml() + xml2js() bridge | Speedup |
|
|
128
128
|
| -------- | ------------: | ----------------------: | ---------: |
|
|
129
|
-
| Simple | 13,
|
|
130
|
-
| Nested |
|
|
129
|
+
| Simple | 13,199,415 hz | 805,104 hz | **16.40x** |
|
|
130
|
+
| Nested | 4,207,319 hz | 458,333 hz | **9.18x** |
|
|
131
131
|
|
|
132
132
|
## Bundle Size
|
|
133
133
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as XmlAttrs, D as XmlOption, E as XmlObject, S as XmlAtom, T as XmlDescArray, _ as ElementCompact, a as childCount, b as Js2XmlOptions, c as collectText, d as findDeep, f as hasChild, g as Element, h as DeclarationAttributes, i as attrNum, l as colorAttr, m as Attributes, n as attr, o as childText, p as textOf, r as attrBool, s as children, t as allChildren, u as findChild, v as ElementObject, w as XmlDesc, x as Xml2JsOptions, y as IgnoreOptions } from "./utils-
|
|
1
|
+
import { C as XmlAttrs, D as XmlOption, E as XmlObject, S as XmlAtom, T as XmlDescArray, _ as ElementCompact, a as childCount, b as Js2XmlOptions, c as collectText, d as findDeep, f as hasChild, g as Element, h as DeclarationAttributes, i as attrNum, l as colorAttr, m as Attributes, n as attr, o as childText, p as textOf, r as attrBool, s as children, t as allChildren, u as findChild, v as ElementObject, w as XmlDesc, x as Xml2JsOptions, y as IgnoreOptions } from "./utils-CSaXdiWb.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/serialize.d.ts
|
|
4
4
|
declare function xml(input: Record<string, any> | Record<string, any>[], options?: boolean | string | {
|
|
@@ -50,4 +50,4 @@ declare function selfCloseElement(tag: string, attrStr?: string): string;
|
|
|
50
50
|
/** Convert XML string to JSON string — xml-js compatible export */
|
|
51
51
|
declare function xml2json(xml: string, options?: Xml2JsOptions): string;
|
|
52
52
|
//#endregion
|
|
53
|
-
export { Attributes, DeclarationAttributes, Element, ElementCompact, ElementObject, IgnoreOptions, Js2XmlOptions, Xml2JsOptions, XmlAtom, XmlAttrs, XmlDesc, XmlDescArray, XmlObject, XmlOption, allChildren, attr, attrBool, attrNum, attrs, childCount, childText, children, collectText, colorAttr, escapeXml, findChild, findDeep, hasChild, js2xml, json2xml, nativeTypeValue, parseAttributes, selfCloseElement, textOf, toElement, unescapeXml, xml, xml2js, xml2json };
|
|
53
|
+
export { type Attributes, type DeclarationAttributes, type Element, type ElementCompact, type ElementObject, type IgnoreOptions, type Js2XmlOptions, type Xml2JsOptions, type XmlAtom, type XmlAttrs, type XmlDesc, type XmlDescArray, type XmlObject, type XmlOption, allChildren, attr, attrBool, attrNum, attrs, childCount, childText, children, collectText, colorAttr, escapeXml, findChild, findDeep, hasChild, js2xml, json2xml, nativeTypeValue, parseAttributes, selfCloseElement, textOf, toElement, unescapeXml, xml, xml2js, xml2json };
|
package/dist/index.mjs
CHANGED
|
@@ -418,39 +418,39 @@ function writeElement(element, opts, depth) {
|
|
|
418
418
|
return parts.join("");
|
|
419
419
|
}
|
|
420
420
|
function writeElements(elements, opts, depth, firstLine) {
|
|
421
|
-
|
|
421
|
+
const parts = [];
|
|
422
422
|
for (let i = 0; i < elements.length; i++) {
|
|
423
423
|
const element = elements[i];
|
|
424
424
|
const isFirst = firstLine && i === 0;
|
|
425
425
|
switch (element.type) {
|
|
426
426
|
case "element":
|
|
427
|
-
|
|
428
|
-
|
|
427
|
+
parts.push(writeIndentation(opts.spaces, depth, isFirst));
|
|
428
|
+
parts.push(writeElement(element, opts, depth));
|
|
429
429
|
break;
|
|
430
430
|
case "text":
|
|
431
431
|
if (opts.ignoreText) continue;
|
|
432
|
-
if (opts.indentText)
|
|
433
|
-
|
|
432
|
+
if (opts.indentText) parts.push(writeIndentation(opts.spaces, depth, isFirst));
|
|
433
|
+
parts.push(writeText(element.text));
|
|
434
434
|
break;
|
|
435
435
|
case "cdata":
|
|
436
436
|
if (opts.ignoreCdata) continue;
|
|
437
|
-
if (opts.indentCdata)
|
|
438
|
-
|
|
437
|
+
if (opts.indentCdata) parts.push(writeIndentation(opts.spaces, depth, isFirst));
|
|
438
|
+
parts.push(writeCdata(element.cdata));
|
|
439
439
|
break;
|
|
440
440
|
case "comment":
|
|
441
441
|
if (opts.ignoreComment) continue;
|
|
442
|
-
|
|
443
|
-
|
|
442
|
+
parts.push(writeIndentation(opts.spaces, depth, isFirst));
|
|
443
|
+
parts.push(writeComment(element.comment));
|
|
444
444
|
break;
|
|
445
445
|
case "doctype":
|
|
446
446
|
if (opts.ignoreDoctype) continue;
|
|
447
|
-
|
|
448
|
-
|
|
447
|
+
parts.push(writeIndentation(opts.spaces, depth, isFirst));
|
|
448
|
+
parts.push(writeDoctype(element.doctype));
|
|
449
449
|
break;
|
|
450
450
|
default: break;
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
|
-
return
|
|
453
|
+
return parts.join("");
|
|
454
454
|
}
|
|
455
455
|
function writeText(text) {
|
|
456
456
|
if (text == null) return "";
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as childCount, c as collectText, d as findDeep, f as hasChild, i as attrNum, l as colorAttr, n as attr, o as childText, p as textOf, r as attrBool, s as children, t as allChildren, u as findChild } from "./utils-
|
|
1
|
+
import { a as childCount, c as collectText, d as findDeep, f as hasChild, i as attrNum, l as colorAttr, n as attr, o as childText, p as textOf, r as attrBool, s as children, t as allChildren, u as findChild } from "./utils-CSaXdiWb.mjs";
|
|
2
2
|
export { allChildren, attr, attrBool, attrNum, childCount, childText, children, collectText, colorAttr, findChild, findDeep, hasChild, textOf };
|
package/package.json
CHANGED
|
File without changes
|