@ai-sdk-tool/rxml 0.1.2-canary.0 → 0.1.2
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.cjs +9 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -58,12 +58,16 @@ interface StringifyOptions {
|
|
|
58
58
|
/** Error handling callback */
|
|
59
59
|
onError?: OnErrorFn;
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* Whether to serialize boolean-like attributes (value === null)
|
|
62
62
|
* as name="name" to follow strict XML attribute rules.
|
|
63
63
|
* When false (default), serialize as a convenience flag without value
|
|
64
64
|
* (e.g., <item checked>), for compatibility with existing outputs.
|
|
65
65
|
*/
|
|
66
66
|
strictBooleanAttributes?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Whether to include the XML declaration
|
|
69
|
+
*/
|
|
70
|
+
declaration?: boolean;
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -58,12 +58,16 @@ interface StringifyOptions {
|
|
|
58
58
|
/** Error handling callback */
|
|
59
59
|
onError?: OnErrorFn;
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* Whether to serialize boolean-like attributes (value === null)
|
|
62
62
|
* as name="name" to follow strict XML attribute rules.
|
|
63
63
|
* When false (default), serialize as a convenience flag without value
|
|
64
64
|
* (e.g., <item checked>), for compatibility with existing outputs.
|
|
65
65
|
*/
|
|
66
66
|
strictBooleanAttributes?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Whether to include the XML declaration
|
|
69
|
+
*/
|
|
70
|
+
declaration?: boolean;
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
/**
|
package/dist/index.js
CHANGED
|
@@ -151,14 +151,15 @@ function unescapeXml(text) {
|
|
|
151
151
|
|
|
152
152
|
// src/builders/stringify.ts
|
|
153
153
|
function stringify(rootTag, obj, options = {}) {
|
|
154
|
-
var _a, _b, _c, _d;
|
|
154
|
+
var _a, _b, _c, _d, _e;
|
|
155
155
|
try {
|
|
156
156
|
const format = (_a = options.format) != null ? _a : true;
|
|
157
|
-
const
|
|
158
|
-
const
|
|
159
|
-
const
|
|
157
|
+
const declaration = (_b = options.declaration) != null ? _b : false;
|
|
158
|
+
const minimalEscaping = (_c = options.minimalEscaping) != null ? _c : false;
|
|
159
|
+
const suppressEmptyNode = (_d = options.suppressEmptyNode) != null ? _d : false;
|
|
160
|
+
const strictBooleanAttributes = (_e = options.strictBooleanAttributes) != null ? _e : false;
|
|
160
161
|
let result = "";
|
|
161
|
-
if (
|
|
162
|
+
if (declaration) {
|
|
162
163
|
result += '<?xml version="1.0" encoding="UTF-8"?>\n';
|
|
163
164
|
}
|
|
164
165
|
result += stringifyValue(rootTag, obj, {
|
|
@@ -168,6 +169,9 @@ function stringify(rootTag, obj, options = {}) {
|
|
|
168
169
|
minimalEscaping,
|
|
169
170
|
strictBooleanAttributes
|
|
170
171
|
});
|
|
172
|
+
if (result.endsWith("\n")) {
|
|
173
|
+
return result.slice(0, -1);
|
|
174
|
+
}
|
|
171
175
|
return result;
|
|
172
176
|
} catch (error) {
|
|
173
177
|
throw new RXMLStringifyError("Failed to stringify XML", error);
|