@office-open/xml 0.10.9 → 0.10.11

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 CHANGED
@@ -109,31 +109,31 @@ Performance comparison against original `xml` (1.0.1) and `xml-js` (1.6.11) pack
109
109
 
110
110
  | Scenario | @office-open/xml | xml | Speedup |
111
111
  | ----------------------- | ---------------: | ---------: | --------: |
112
- | Simple element | 5,069,751 hz | 724,533 hz | **7.00x** |
113
- | Nested element | 1,122,376 hz | 279,423 hz | **4.02x** |
114
- | Nested with declaration | 1,050,046 hz | 248,678 hz | **4.22x** |
112
+ | Simple element | 5,440,771 hz | 805,545 hz | **6.75x** |
113
+ | Nested element | 1,050,272 hz | 315,184 hz | **3.33x** |
114
+ | Nested with declaration | 967,945 hz | 275,684 hz | **3.51x** |
115
115
 
116
116
  ### Parsing (xml2js)
117
117
 
118
- | Scenario | @office-open/xml | xml-js | Speedup |
119
- | ------------------ | ---------------: | --------: | ---------: |
120
- | Simple XML | 1,000,869 hz | 90,488 hz | **11.06x** |
121
- | Complex OOXML | 310,266 hz | 42,938 hz | **7.23x** |
122
- | With captureSpaces | 313,183 hz | 41,814 hz | **7.49x** |
118
+ | Scenario | @office-open/xml | xml-js | Speedup |
119
+ | ------------------ | ---------------: | ---------: | --------: |
120
+ | Simple XML | 869,965 hz | 100,507 hz | **8.66x** |
121
+ | Complex OOXML | 346,440 hz | 53,621 hz | **6.46x** |
122
+ | With captureSpaces | 344,586 hz | 52,414 hz | **6.57x** |
123
123
 
124
124
  ### Stringifying (js2xml)
125
125
 
126
126
  | Scenario | @office-open/xml | xml-js | Speedup |
127
127
  | -------------- | ---------------: | ---------: | --------: |
128
- | Simple element | 975,878 hz | 198,953 hz | **4.90x** |
129
- | Complex OOXML | 492,220 hz | 107,815 hz | **4.57x** |
128
+ | Simple element | 793,710 hz | 207,730 hz | **3.82x** |
129
+ | Complex OOXML | 366,515 hz | 135,815 hz | **2.70x** |
130
130
 
131
131
  ### Direct Conversion (toElement vs bridge)
132
132
 
133
133
  | Scenario | toElement() | xml() + xml2js() bridge | Speedup |
134
134
  | -------- | ------------: | ----------------------: | ---------: |
135
- | Simple | 13,199,415 hz | 805,104 hz | **16.40x** |
136
- | Nested | 4,207,319 hz | 458,333 hz | **9.18x** |
135
+ | Simple | 15,471,913 hz | 1,073,016 hz | **14.42x** |
136
+ | Nested | 4,278,499 hz | 441,468 hz | **9.69x** |
137
137
 
138
138
  ## Bundle Size
139
139
 
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as Xml2JsOptions, D as XmlDescArray, E as XmlDesc, O as XmlObject, S as Js2XmlOptions, T as XmlAttrs, _ as DeclarationAttributes, a as attrNum, b as ElementObject, c as children, d as findChild, f as findDeep, g as Attributes, h as textOf, i as attrMeasure, k as XmlOption, l as collectText, m as hasChild, n as attr, o as childCount, p as findFirst, r as attrBool, s as childText, t as allChildren, u as colorAttr, v as Element, w as XmlAtom, x as IgnoreOptions, y as ElementCompact } from "./utils-CDLayhwk.mjs";
1
+ import { C as Xml2JsOptions, D as XmlDescArray, E as XmlDesc, O as XmlObject, S as Js2XmlOptions, T as XmlAttrs, _ as DeclarationAttributes, a as attrNum, b as ElementObject, c as children, d as findChild, f as findDeep, g as Attributes, h as textOf, i as attrMeasure, k as XmlOption, l as collectText, m as hasChild, n as attr, o as childCount, p as findFirst, r as attrBool, s as childText, t as allChildren, u as colorAttr, v as Element, w as XmlAtom, x as IgnoreOptions, y as ElementCompact } from "./utils-t-_-N57p.mjs";
2
2
 
3
3
  //#region src/serialize.d.ts
4
4
  /**
@@ -164,11 +164,11 @@ declare function attrNum(element: Element | undefined, name: string): number | u
164
164
  * UniversalMeasure ("5mm") and Percentage ("50%") stay verbatim so they
165
165
  * round-trip with the stringify-side value helpers in @office-open/core.
166
166
  *
167
- * Pass the sibling @type for CT_TblWidth with type="pct" its fiftieths token
168
- * ("5000") must stay a string, since converting it to 5000 would make a later
169
- * stringify re-emit "5000%", changing the value.
167
+ * For CT_TblWidth with type="pct", the fiftieths token ("5000" = 100%) is a
168
+ * plain numeric token and is returned as the number 5000; the stringify side
169
+ * emits it verbatim (never "5000%", which is a different XSD branch).
170
170
  */
171
- declare function attrMeasure(element: Element | undefined, name: string, type?: string): number | string | undefined;
171
+ declare function attrMeasure(element: Element | undefined, name: string): number | string | undefined;
172
172
  /**
173
173
  * Get an attribute value as a boolean.
174
174
  */
package/dist/utils.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as attrNum, c as children, d as findChild, f as findDeep, h as textOf, i as attrMeasure, l as collectText, m as hasChild, n as attr, o as childCount, p as findFirst, r as attrBool, s as childText, t as allChildren, u as colorAttr } from "./utils-CDLayhwk.mjs";
1
+ import { a as attrNum, c as children, d as findChild, f as findDeep, h as textOf, i as attrMeasure, l as collectText, m as hasChild, n as attr, o as childCount, p as findFirst, r as attrBool, s as childText, t as allChildren, u as colorAttr } from "./utils-t-_-N57p.mjs";
2
2
  export { allChildren, attr, attrBool, attrMeasure, attrNum, childCount, childText, children, collectText, colorAttr, findChild, findDeep, findFirst, hasChild, textOf };
package/dist/utils.mjs CHANGED
@@ -72,15 +72,14 @@ function attrNum(element, name) {
72
72
  * UniversalMeasure ("5mm") and Percentage ("50%") stay verbatim so they
73
73
  * round-trip with the stringify-side value helpers in @office-open/core.
74
74
  *
75
- * Pass the sibling @type for CT_TblWidth with type="pct" its fiftieths token
76
- * ("5000") must stay a string, since converting it to 5000 would make a later
77
- * stringify re-emit "5000%", changing the value.
75
+ * For CT_TblWidth with type="pct", the fiftieths token ("5000" = 100%) is a
76
+ * plain numeric token and is returned as the number 5000; the stringify side
77
+ * emits it verbatim (never "5000%", which is a different XSD branch).
78
78
  */
79
- function attrMeasure(element, name, type) {
79
+ function attrMeasure(element, name) {
80
80
  const v = element?.attributes?.[name];
81
81
  if (v === void 0) return void 0;
82
82
  const raw = String(v);
83
- if (type === "pct") return raw;
84
83
  const n = Number(raw);
85
84
  return Number.isNaN(n) ? raw : n;
86
85
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@office-open/xml",
3
- "version": "0.10.9",
3
+ "version": "0.10.11",
4
4
  "description": "XML parsing and serialization for Office Open XML. Zero dependencies, drop-in replacement for xml + xml-js.",
5
5
  "keywords": [
6
6
  "office-open",