@office-open/xml 0.6.9 → 0.7.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.
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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-DJSm61Ws.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/serialize.d.ts
|
|
4
|
-
declare function xml(input: Record<string,
|
|
4
|
+
declare function xml(input: Record<string, unknown> | Record<string, unknown>[], options?: boolean | string | {
|
|
5
5
|
indent?: boolean | string;
|
|
6
6
|
declaration?: boolean | {
|
|
7
7
|
encoding?: string;
|
package/dist/index.mjs
CHANGED
|
@@ -103,17 +103,28 @@ function formatElement(name, values, indent, depth) {
|
|
|
103
103
|
return `${indent ? indent.repeat(depth) : ""}<${name}${attrStr}/>`;
|
|
104
104
|
}
|
|
105
105
|
if (typeof values === "object") {
|
|
106
|
-
|
|
107
|
-
if (
|
|
108
|
-
|
|
109
|
-
const
|
|
106
|
+
const obj = values;
|
|
107
|
+
if (obj._attr) {
|
|
108
|
+
const attr = obj._attr;
|
|
109
|
+
for (const key of Object.keys(attr)) attrParts.push(`${key}="${escapeXml(String(attr[key]))}"`);
|
|
110
|
+
}
|
|
111
|
+
if (obj._attributes) {
|
|
112
|
+
const attr = obj._attributes;
|
|
113
|
+
for (const key of Object.keys(attr)) attrParts.push(`${key}="${escapeXml(String(attr[key]))}"`);
|
|
114
|
+
}
|
|
115
|
+
if (obj._cdata) {
|
|
116
|
+
const escaped = String(obj._cdata).replace(/\]\]>/g, "]]]]><![CDATA[>");
|
|
110
117
|
textParts.push(`<![CDATA[${escaped}]]>`);
|
|
111
118
|
}
|
|
112
119
|
if (Array.isArray(values)) {
|
|
113
120
|
if (values.length === 0) emptyArray = true;
|
|
114
|
-
else for (const value of values) if (value && typeof value === "object" && "_attr" in value)
|
|
115
|
-
|
|
116
|
-
|
|
121
|
+
else for (const value of values) if (value && typeof value === "object" && "_attr" in value) {
|
|
122
|
+
const attr = value._attr;
|
|
123
|
+
for (const key of Object.keys(attr)) attrParts.push(`${key}="${escapeXml(String(attr[key]))}"`);
|
|
124
|
+
} else if (value && typeof value === "object" && "_attributes" in value) {
|
|
125
|
+
const attr = value._attributes;
|
|
126
|
+
for (const key of Object.keys(attr)) attrParts.push(`${key}="${escapeXml(String(attr[key]))}"`);
|
|
127
|
+
} else if (value && typeof value === "object") {
|
|
117
128
|
const childKeys = Object.keys(value);
|
|
118
129
|
elemParts.push(formatElement(childKeys[0], value[childKeys[0]], indent, depth + 1));
|
|
119
130
|
} else if (value != null) textParts.push(escapeXml(String(value)));
|
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-DJSm61Ws.mjs";
|
|
2
2
|
export { allChildren, attr, attrBool, attrNum, childCount, childText, children, collectText, colorAttr, findChild, findDeep, hasChild, textOf };
|