xml-model 1.3.3 → 2.0.0-beta.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.
Files changed (84) hide show
  1. package/README.md +39 -35
  2. package/dist/_virtual/_rolldown/runtime.js +8 -0
  3. package/dist/index.d.ts +3 -7
  4. package/dist/index.js +7 -20
  5. package/dist/model.d.ts +53 -0
  6. package/dist/model.js +75 -0
  7. package/dist/node_modules/sax/lib/sax.js +1249 -0
  8. package/dist/node_modules/xml-js/lib/array-helper.js +13 -0
  9. package/dist/node_modules/xml-js/lib/index.js +19 -0
  10. package/dist/node_modules/xml-js/lib/js2xml.js +258 -0
  11. package/dist/node_modules/xml-js/lib/json2xml.js +22 -0
  12. package/dist/node_modules/xml-js/lib/options-helper.js +33 -0
  13. package/dist/node_modules/xml-js/lib/xml2js.js +246 -0
  14. package/dist/node_modules/xml-js/lib/xml2json.js +26 -0
  15. package/dist/util/kebab-case.js +24 -13
  16. package/dist/util/zod.d.ts +4 -0
  17. package/dist/util/zod.js +21 -0
  18. package/dist/xml/codec.d.ts +87 -0
  19. package/dist/xml/codec.js +339 -0
  20. package/dist/xml/examples.d.ts +188 -0
  21. package/dist/xml/index.d.ts +5 -79
  22. package/dist/xml/index.js +4 -57
  23. package/dist/xml/model.d.ts +18 -0
  24. package/dist/xml/model.js +33 -0
  25. package/dist/xml/schema-meta.d.ts +57 -0
  26. package/dist/xml/schema-meta.js +88 -0
  27. package/dist/xml/xml-js.d.ts +280 -3
  28. package/dist/xml/xml-js.js +121 -8
  29. package/package.json +27 -42
  30. package/dist/_virtual/Reflect.js +0 -8
  31. package/dist/_virtual/Reflect2.js +0 -5
  32. package/dist/_virtual/_commonjsHelpers.js +0 -47
  33. package/dist/defaults.d.ts +0 -28
  34. package/dist/defaults.js +0 -165
  35. package/dist/errors.d.ts +0 -40
  36. package/dist/errors.js +0 -45
  37. package/dist/middleware.d.ts +0 -10
  38. package/dist/middleware.js +0 -25
  39. package/dist/model/built-ins.d.ts +0 -3
  40. package/dist/model/built-ins.js +0 -43
  41. package/dist/model/index.d.ts +0 -69
  42. package/dist/model/index.js +0 -264
  43. package/dist/model/property.d.ts +0 -18
  44. package/dist/model/property.js +0 -67
  45. package/dist/model/registry.d.ts +0 -9
  46. package/dist/model/registry.js +0 -19
  47. package/dist/model/types.d.ts +0 -109
  48. package/dist/node_modules/reflect-metadata/Reflect.js +0 -806
  49. package/dist/types.d.ts +0 -25
  50. package/dist/util/is-regexp.d.ts +0 -12
  51. package/dist/util/is-regexp.js +0 -8
  52. package/dist/util/merge-maps.d.ts +0 -2
  53. package/dist/util/merge-maps.js +0 -23
  54. package/dist/vite/index.d.ts +0 -80
  55. package/dist/vite/index.js +0 -71
  56. package/dist/vite/node_modules/typescript-rtti/dist.esm/common/format.js +0 -105
  57. package/dist/vite/node_modules/typescript-rtti/dist.esm/common/index.js +0 -55
  58. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/api-call-transformer.js +0 -152
  59. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/common/class-analyzer.js +0 -83
  60. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/common/compile-error.js +0 -8
  61. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/common/import-analyzer.js +0 -89
  62. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/common/interface-analyzer.js +0 -58
  63. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/common/visitor-base.js +0 -93
  64. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/declarations-emitter.js +0 -31
  65. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/encode-parameter.js +0 -64
  66. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/find-relative-path.js +0 -41
  67. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/flags.js +0 -43
  68. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/forward-ref.js +0 -20
  69. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/get-exports-for-symbol.js +0 -64
  70. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/index.js +0 -130
  71. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/legacy-decorator.js +0 -10
  72. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/legacy-type-encoder.js +0 -82
  73. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/literal-node.js +0 -9
  74. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/metadata-collector.js +0 -56
  75. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/metadata-decorator.js +0 -80
  76. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/metadata-emitter.js +0 -425
  77. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/metadata-encoder.js +0 -212
  78. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/rt-helper.js +0 -96
  79. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/rtti-visitor-base.js +0 -28
  80. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/serialize.js +0 -31
  81. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/type-encoder.js +0 -76
  82. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/type-literal.js +0 -499
  83. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/utils.js +0 -906
  84. package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/workarounds.js +0 -7
@@ -0,0 +1,13 @@
1
+ import { __commonJSMin } from "../../../_virtual/_rolldown/runtime.js";
2
+ //#region node_modules/xml-js/lib/array-helper.js
3
+ var require_array_helper = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4
+ module.exports = { isArray: function(value) {
5
+ if (Array.isArray) return Array.isArray(value);
6
+ return Object.prototype.toString.call(value) === "[object Array]";
7
+ } };
8
+ }));
9
+ //#endregion
10
+ export default require_array_helper();
11
+ export { require_array_helper };
12
+
13
+ //# sourceMappingURL=array-helper.js.map
@@ -0,0 +1,19 @@
1
+ import { __commonJSMin } from "../../../_virtual/_rolldown/runtime.js";
2
+ import { require_xml2js } from "./xml2js.js";
3
+ import { require_xml2json } from "./xml2json.js";
4
+ import { require_js2xml } from "./js2xml.js";
5
+ import { require_json2xml } from "./json2xml.js";
6
+ //#region node_modules/xml-js/lib/index.js
7
+ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8
+ module.exports = {
9
+ xml2js: require_xml2js(),
10
+ xml2json: require_xml2json(),
11
+ js2xml: require_js2xml(),
12
+ json2xml: require_json2xml()
13
+ };
14
+ }));
15
+ //#endregion
16
+ export default require_lib();
17
+ export { require_lib };
18
+
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,258 @@
1
+ import { __commonJSMin } from "../../../_virtual/_rolldown/runtime.js";
2
+ import { require_array_helper } from "./array-helper.js";
3
+ import { require_options_helper } from "./options-helper.js";
4
+ //#region node_modules/xml-js/lib/js2xml.js
5
+ var require_js2xml = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6
+ var helper = require_options_helper();
7
+ var isArray = require_array_helper().isArray;
8
+ var currentElement, currentElementName;
9
+ function validateOptions(userOptions) {
10
+ var options = helper.copyOptions(userOptions);
11
+ helper.ensureFlagExists("ignoreDeclaration", options);
12
+ helper.ensureFlagExists("ignoreInstruction", options);
13
+ helper.ensureFlagExists("ignoreAttributes", options);
14
+ helper.ensureFlagExists("ignoreText", options);
15
+ helper.ensureFlagExists("ignoreComment", options);
16
+ helper.ensureFlagExists("ignoreCdata", options);
17
+ helper.ensureFlagExists("ignoreDoctype", options);
18
+ helper.ensureFlagExists("compact", options);
19
+ helper.ensureFlagExists("indentText", options);
20
+ helper.ensureFlagExists("indentCdata", options);
21
+ helper.ensureFlagExists("indentAttributes", options);
22
+ helper.ensureFlagExists("indentInstruction", options);
23
+ helper.ensureFlagExists("fullTagEmptyElement", options);
24
+ helper.ensureFlagExists("noQuotesForNativeAttributes", options);
25
+ helper.ensureSpacesExists(options);
26
+ if (typeof options.spaces === "number") options.spaces = Array(options.spaces + 1).join(" ");
27
+ helper.ensureKeyExists("declaration", options);
28
+ helper.ensureKeyExists("instruction", options);
29
+ helper.ensureKeyExists("attributes", options);
30
+ helper.ensureKeyExists("text", options);
31
+ helper.ensureKeyExists("comment", options);
32
+ helper.ensureKeyExists("cdata", options);
33
+ helper.ensureKeyExists("doctype", options);
34
+ helper.ensureKeyExists("type", options);
35
+ helper.ensureKeyExists("name", options);
36
+ helper.ensureKeyExists("elements", options);
37
+ helper.checkFnExists("doctype", options);
38
+ helper.checkFnExists("instruction", options);
39
+ helper.checkFnExists("cdata", options);
40
+ helper.checkFnExists("comment", options);
41
+ helper.checkFnExists("text", options);
42
+ helper.checkFnExists("instructionName", options);
43
+ helper.checkFnExists("elementName", options);
44
+ helper.checkFnExists("attributeName", options);
45
+ helper.checkFnExists("attributeValue", options);
46
+ helper.checkFnExists("attributes", options);
47
+ helper.checkFnExists("fullTagEmptyElement", options);
48
+ return options;
49
+ }
50
+ function writeIndentation(options, depth, firstLine) {
51
+ return (!firstLine && options.spaces ? "\n" : "") + Array(depth + 1).join(options.spaces);
52
+ }
53
+ function writeAttributes(attributes, options, depth) {
54
+ if (options.ignoreAttributes) return "";
55
+ if ("attributesFn" in options) attributes = options.attributesFn(attributes, currentElementName, currentElement);
56
+ var key, attr, attrName, quote, result = [];
57
+ for (key in attributes) if (attributes.hasOwnProperty(key) && attributes[key] !== null && attributes[key] !== void 0) {
58
+ quote = options.noQuotesForNativeAttributes && typeof attributes[key] !== "string" ? "" : "\"";
59
+ attr = "" + attributes[key];
60
+ attr = attr.replace(/"/g, """);
61
+ attrName = "attributeNameFn" in options ? options.attributeNameFn(key, attr, currentElementName, currentElement) : key;
62
+ result.push(options.spaces && options.indentAttributes ? writeIndentation(options, depth + 1, false) : " ");
63
+ result.push(attrName + "=" + quote + ("attributeValueFn" in options ? options.attributeValueFn(attr, key, currentElementName, currentElement) : attr) + quote);
64
+ }
65
+ if (attributes && Object.keys(attributes).length && options.spaces && options.indentAttributes) result.push(writeIndentation(options, depth, false));
66
+ return result.join("");
67
+ }
68
+ function writeDeclaration(declaration, options, depth) {
69
+ currentElement = declaration;
70
+ currentElementName = "xml";
71
+ return options.ignoreDeclaration ? "" : "<?xml" + writeAttributes(declaration[options.attributesKey], options, depth) + "?>";
72
+ }
73
+ function writeInstruction(instruction, options, depth) {
74
+ if (options.ignoreInstruction) return "";
75
+ var key;
76
+ for (key in instruction) if (instruction.hasOwnProperty(key)) break;
77
+ var instructionName = "instructionNameFn" in options ? options.instructionNameFn(key, instruction[key], currentElementName, currentElement) : key;
78
+ if (typeof instruction[key] === "object") {
79
+ currentElement = instruction;
80
+ currentElementName = instructionName;
81
+ return "<?" + instructionName + writeAttributes(instruction[key][options.attributesKey], options, depth) + "?>";
82
+ } else {
83
+ var instructionValue = instruction[key] ? instruction[key] : "";
84
+ if ("instructionFn" in options) instructionValue = options.instructionFn(instructionValue, key, currentElementName, currentElement);
85
+ return "<?" + instructionName + (instructionValue ? " " + instructionValue : "") + "?>";
86
+ }
87
+ }
88
+ function writeComment(comment, options) {
89
+ return options.ignoreComment ? "" : "<!--" + ("commentFn" in options ? options.commentFn(comment, currentElementName, currentElement) : comment) + "-->";
90
+ }
91
+ function writeCdata(cdata, options) {
92
+ return options.ignoreCdata ? "" : "<![CDATA[" + ("cdataFn" in options ? options.cdataFn(cdata, currentElementName, currentElement) : cdata.replace("]]>", "]]]]><![CDATA[>")) + "]]>";
93
+ }
94
+ function writeDoctype(doctype, options) {
95
+ return options.ignoreDoctype ? "" : "<!DOCTYPE " + ("doctypeFn" in options ? options.doctypeFn(doctype, currentElementName, currentElement) : doctype) + ">";
96
+ }
97
+ function writeText(text, options) {
98
+ if (options.ignoreText) return "";
99
+ text = "" + text;
100
+ text = text.replace(/&amp;/g, "&");
101
+ text = text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
102
+ return "textFn" in options ? options.textFn(text, currentElementName, currentElement) : text;
103
+ }
104
+ function hasContent(element, options) {
105
+ var i;
106
+ if (element.elements && element.elements.length) for (i = 0; i < element.elements.length; ++i) switch (element.elements[i][options.typeKey]) {
107
+ case "text":
108
+ if (options.indentText) return true;
109
+ break;
110
+ case "cdata":
111
+ if (options.indentCdata) return true;
112
+ break;
113
+ case "instruction":
114
+ if (options.indentInstruction) return true;
115
+ break;
116
+ case "doctype":
117
+ case "comment":
118
+ case "element": return true;
119
+ default: return true;
120
+ }
121
+ return false;
122
+ }
123
+ function writeElement(element, options, depth) {
124
+ currentElement = element;
125
+ currentElementName = element.name;
126
+ var xml = [], elementName = "elementNameFn" in options ? options.elementNameFn(element.name, element) : element.name;
127
+ xml.push("<" + elementName);
128
+ if (element[options.attributesKey]) xml.push(writeAttributes(element[options.attributesKey], options, depth));
129
+ var withClosingTag = element[options.elementsKey] && element[options.elementsKey].length || element[options.attributesKey] && element[options.attributesKey]["xml:space"] === "preserve";
130
+ if (!withClosingTag) if ("fullTagEmptyElementFn" in options) withClosingTag = options.fullTagEmptyElementFn(element.name, element);
131
+ else withClosingTag = options.fullTagEmptyElement;
132
+ if (withClosingTag) {
133
+ xml.push(">");
134
+ if (element[options.elementsKey] && element[options.elementsKey].length) {
135
+ xml.push(writeElements(element[options.elementsKey], options, depth + 1));
136
+ currentElement = element;
137
+ currentElementName = element.name;
138
+ }
139
+ xml.push(options.spaces && hasContent(element, options) ? "\n" + Array(depth + 1).join(options.spaces) : "");
140
+ xml.push("</" + elementName + ">");
141
+ } else xml.push("/>");
142
+ return xml.join("");
143
+ }
144
+ function writeElements(elements, options, depth, firstLine) {
145
+ return elements.reduce(function(xml, element) {
146
+ var indent = writeIndentation(options, depth, firstLine && !xml);
147
+ switch (element.type) {
148
+ case "element": return xml + indent + writeElement(element, options, depth);
149
+ case "comment": return xml + indent + writeComment(element[options.commentKey], options);
150
+ case "doctype": return xml + indent + writeDoctype(element[options.doctypeKey], options);
151
+ case "cdata": return xml + (options.indentCdata ? indent : "") + writeCdata(element[options.cdataKey], options);
152
+ case "text": return xml + (options.indentText ? indent : "") + writeText(element[options.textKey], options);
153
+ case "instruction":
154
+ var instruction = {};
155
+ instruction[element[options.nameKey]] = element[options.attributesKey] ? element : element[options.instructionKey];
156
+ return xml + (options.indentInstruction ? indent : "") + writeInstruction(instruction, options, depth);
157
+ }
158
+ }, "");
159
+ }
160
+ function hasContentCompact(element, options, anyContent) {
161
+ var key;
162
+ for (key in element) if (element.hasOwnProperty(key)) switch (key) {
163
+ case options.parentKey:
164
+ case options.attributesKey: break;
165
+ case options.textKey:
166
+ if (options.indentText || anyContent) return true;
167
+ break;
168
+ case options.cdataKey:
169
+ if (options.indentCdata || anyContent) return true;
170
+ break;
171
+ case options.instructionKey:
172
+ if (options.indentInstruction || anyContent) return true;
173
+ break;
174
+ case options.doctypeKey:
175
+ case options.commentKey: return true;
176
+ default: return true;
177
+ }
178
+ return false;
179
+ }
180
+ function writeElementCompact(element, name, options, depth, indent) {
181
+ currentElement = element;
182
+ currentElementName = name;
183
+ var elementName = "elementNameFn" in options ? options.elementNameFn(name, element) : name;
184
+ if (typeof element === "undefined" || element === null || element === "") return "fullTagEmptyElementFn" in options && options.fullTagEmptyElementFn(name, element) || options.fullTagEmptyElement ? "<" + elementName + "></" + elementName + ">" : "<" + elementName + "/>";
185
+ var xml = [];
186
+ if (name) {
187
+ xml.push("<" + elementName);
188
+ if (typeof element !== "object") {
189
+ xml.push(">" + writeText(element, options) + "</" + elementName + ">");
190
+ return xml.join("");
191
+ }
192
+ if (element[options.attributesKey]) xml.push(writeAttributes(element[options.attributesKey], options, depth));
193
+ var withClosingTag = hasContentCompact(element, options, true) || element[options.attributesKey] && element[options.attributesKey]["xml:space"] === "preserve";
194
+ if (!withClosingTag) if ("fullTagEmptyElementFn" in options) withClosingTag = options.fullTagEmptyElementFn(name, element);
195
+ else withClosingTag = options.fullTagEmptyElement;
196
+ if (withClosingTag) xml.push(">");
197
+ else {
198
+ xml.push("/>");
199
+ return xml.join("");
200
+ }
201
+ }
202
+ xml.push(writeElementsCompact(element, options, depth + 1, false));
203
+ currentElement = element;
204
+ currentElementName = name;
205
+ if (name) xml.push((indent ? writeIndentation(options, depth, false) : "") + "</" + elementName + ">");
206
+ return xml.join("");
207
+ }
208
+ function writeElementsCompact(element, options, depth, firstLine) {
209
+ var i, key, nodes, xml = [];
210
+ for (key in element) if (element.hasOwnProperty(key)) {
211
+ nodes = isArray(element[key]) ? element[key] : [element[key]];
212
+ for (i = 0; i < nodes.length; ++i) {
213
+ switch (key) {
214
+ case options.declarationKey:
215
+ xml.push(writeDeclaration(nodes[i], options, depth));
216
+ break;
217
+ case options.instructionKey:
218
+ xml.push((options.indentInstruction ? writeIndentation(options, depth, firstLine) : "") + writeInstruction(nodes[i], options, depth));
219
+ break;
220
+ case options.attributesKey:
221
+ case options.parentKey: break;
222
+ case options.textKey:
223
+ xml.push((options.indentText ? writeIndentation(options, depth, firstLine) : "") + writeText(nodes[i], options));
224
+ break;
225
+ case options.cdataKey:
226
+ xml.push((options.indentCdata ? writeIndentation(options, depth, firstLine) : "") + writeCdata(nodes[i], options));
227
+ break;
228
+ case options.doctypeKey:
229
+ xml.push(writeIndentation(options, depth, firstLine) + writeDoctype(nodes[i], options));
230
+ break;
231
+ case options.commentKey:
232
+ xml.push(writeIndentation(options, depth, firstLine) + writeComment(nodes[i], options));
233
+ break;
234
+ default: xml.push(writeIndentation(options, depth, firstLine) + writeElementCompact(nodes[i], key, options, depth, hasContentCompact(nodes[i], options)));
235
+ }
236
+ firstLine = firstLine && !xml.length;
237
+ }
238
+ }
239
+ return xml.join("");
240
+ }
241
+ module.exports = function(js, options) {
242
+ options = validateOptions(options);
243
+ var xml = [];
244
+ currentElement = js;
245
+ currentElementName = "_root_";
246
+ if (options.compact) xml.push(writeElementsCompact(js, options, 0, true));
247
+ else {
248
+ if (js[options.declarationKey]) xml.push(writeDeclaration(js[options.declarationKey], options, 0));
249
+ if (js[options.elementsKey] && js[options.elementsKey].length) xml.push(writeElements(js[options.elementsKey], options, 0, !xml.length));
250
+ }
251
+ return xml.join("");
252
+ };
253
+ }));
254
+ //#endregion
255
+ export default require_js2xml();
256
+ export { require_js2xml };
257
+
258
+ //# sourceMappingURL=js2xml.js.map
@@ -0,0 +1,22 @@
1
+ import { __commonJSMin } from "../../../_virtual/_rolldown/runtime.js";
2
+ import { require_js2xml } from "./js2xml.js";
3
+ //#region node_modules/xml-js/lib/json2xml.js
4
+ var require_json2xml = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5
+ var js2xml = require_js2xml();
6
+ module.exports = function(json, options) {
7
+ if (json instanceof Buffer) json = json.toString();
8
+ var js = null;
9
+ if (typeof json === "string") try {
10
+ js = JSON.parse(json);
11
+ } catch (e) {
12
+ throw new Error("The JSON structure is invalid");
13
+ }
14
+ else js = json;
15
+ return js2xml(js, options);
16
+ };
17
+ }));
18
+ //#endregion
19
+ export default require_json2xml();
20
+ export { require_json2xml };
21
+
22
+ //# sourceMappingURL=json2xml.js.map
@@ -0,0 +1,33 @@
1
+ import { __commonJSMin } from "../../../_virtual/_rolldown/runtime.js";
2
+ import { require_array_helper } from "./array-helper.js";
3
+ //#region node_modules/xml-js/lib/options-helper.js
4
+ var require_options_helper = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5
+ var isArray = require_array_helper().isArray;
6
+ module.exports = {
7
+ copyOptions: function(options) {
8
+ var key, copy = {};
9
+ for (key in options) if (options.hasOwnProperty(key)) copy[key] = options[key];
10
+ return copy;
11
+ },
12
+ ensureFlagExists: function(item, options) {
13
+ if (!(item in options) || typeof options[item] !== "boolean") options[item] = false;
14
+ },
15
+ ensureSpacesExists: function(options) {
16
+ if (!("spaces" in options) || typeof options.spaces !== "number" && typeof options.spaces !== "string") options.spaces = 0;
17
+ },
18
+ ensureAlwaysArrayExists: function(options) {
19
+ if (!("alwaysArray" in options) || typeof options.alwaysArray !== "boolean" && !isArray(options.alwaysArray)) options.alwaysArray = false;
20
+ },
21
+ ensureKeyExists: function(key, options) {
22
+ if (!(key + "Key" in options) || typeof options[key + "Key"] !== "string") options[key + "Key"] = options.compact ? "_" + key : key;
23
+ },
24
+ checkFnExists: function(key, options) {
25
+ return key + "Fn" in options;
26
+ }
27
+ };
28
+ }));
29
+ //#endregion
30
+ export default require_options_helper();
31
+ export { require_options_helper };
32
+
33
+ //# sourceMappingURL=options-helper.js.map
@@ -0,0 +1,246 @@
1
+ import { __commonJSMin } from "../../../_virtual/_rolldown/runtime.js";
2
+ import { require_sax } from "../../sax/lib/sax.js";
3
+ import { require_array_helper } from "./array-helper.js";
4
+ import { require_options_helper } from "./options-helper.js";
5
+ //#region node_modules/xml-js/lib/xml2js.js
6
+ var require_xml2js = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7
+ var sax = require_sax();
8
+ var expat = {
9
+ on: function() {},
10
+ parse: function() {}
11
+ };
12
+ var helper = require_options_helper();
13
+ var isArray = require_array_helper().isArray;
14
+ var options;
15
+ var pureJsParser = true;
16
+ var currentElement;
17
+ function validateOptions(userOptions) {
18
+ options = helper.copyOptions(userOptions);
19
+ helper.ensureFlagExists("ignoreDeclaration", options);
20
+ helper.ensureFlagExists("ignoreInstruction", options);
21
+ helper.ensureFlagExists("ignoreAttributes", options);
22
+ helper.ensureFlagExists("ignoreText", options);
23
+ helper.ensureFlagExists("ignoreComment", options);
24
+ helper.ensureFlagExists("ignoreCdata", options);
25
+ helper.ensureFlagExists("ignoreDoctype", options);
26
+ helper.ensureFlagExists("compact", options);
27
+ helper.ensureFlagExists("alwaysChildren", options);
28
+ helper.ensureFlagExists("addParent", options);
29
+ helper.ensureFlagExists("trim", options);
30
+ helper.ensureFlagExists("nativeType", options);
31
+ helper.ensureFlagExists("nativeTypeAttributes", options);
32
+ helper.ensureFlagExists("sanitize", options);
33
+ helper.ensureFlagExists("instructionHasAttributes", options);
34
+ helper.ensureFlagExists("captureSpacesBetweenElements", options);
35
+ helper.ensureAlwaysArrayExists(options);
36
+ helper.ensureKeyExists("declaration", options);
37
+ helper.ensureKeyExists("instruction", options);
38
+ helper.ensureKeyExists("attributes", options);
39
+ helper.ensureKeyExists("text", options);
40
+ helper.ensureKeyExists("comment", options);
41
+ helper.ensureKeyExists("cdata", options);
42
+ helper.ensureKeyExists("doctype", options);
43
+ helper.ensureKeyExists("type", options);
44
+ helper.ensureKeyExists("name", options);
45
+ helper.ensureKeyExists("elements", options);
46
+ helper.ensureKeyExists("parent", options);
47
+ helper.checkFnExists("doctype", options);
48
+ helper.checkFnExists("instruction", options);
49
+ helper.checkFnExists("cdata", options);
50
+ helper.checkFnExists("comment", options);
51
+ helper.checkFnExists("text", options);
52
+ helper.checkFnExists("instructionName", options);
53
+ helper.checkFnExists("elementName", options);
54
+ helper.checkFnExists("attributeName", options);
55
+ helper.checkFnExists("attributeValue", options);
56
+ helper.checkFnExists("attributes", options);
57
+ return options;
58
+ }
59
+ function nativeType(value) {
60
+ var nValue = Number(value);
61
+ if (!isNaN(nValue)) return nValue;
62
+ var bValue = value.toLowerCase();
63
+ if (bValue === "true") return true;
64
+ else if (bValue === "false") return false;
65
+ return value;
66
+ }
67
+ function addField(type, value) {
68
+ var key;
69
+ if (options.compact) {
70
+ if (!currentElement[options[type + "Key"]] && (isArray(options.alwaysArray) ? options.alwaysArray.indexOf(options[type + "Key"]) !== -1 : options.alwaysArray)) currentElement[options[type + "Key"]] = [];
71
+ if (currentElement[options[type + "Key"]] && !isArray(currentElement[options[type + "Key"]])) currentElement[options[type + "Key"]] = [currentElement[options[type + "Key"]]];
72
+ if (type + "Fn" in options && typeof value === "string") value = options[type + "Fn"](value, currentElement);
73
+ if (type === "instruction" && ("instructionFn" in options || "instructionNameFn" in options)) {
74
+ for (key in value) if (value.hasOwnProperty(key)) if ("instructionFn" in options) value[key] = options.instructionFn(value[key], key, currentElement);
75
+ else {
76
+ var temp = value[key];
77
+ delete value[key];
78
+ value[options.instructionNameFn(key, temp, currentElement)] = temp;
79
+ }
80
+ }
81
+ if (isArray(currentElement[options[type + "Key"]])) currentElement[options[type + "Key"]].push(value);
82
+ else currentElement[options[type + "Key"]] = value;
83
+ } else {
84
+ if (!currentElement[options.elementsKey]) currentElement[options.elementsKey] = [];
85
+ var element = {};
86
+ element[options.typeKey] = type;
87
+ if (type === "instruction") {
88
+ for (key in value) if (value.hasOwnProperty(key)) break;
89
+ element[options.nameKey] = "instructionNameFn" in options ? options.instructionNameFn(key, value, currentElement) : key;
90
+ if (options.instructionHasAttributes) {
91
+ element[options.attributesKey] = value[key][options.attributesKey];
92
+ if ("instructionFn" in options) element[options.attributesKey] = options.instructionFn(element[options.attributesKey], key, currentElement);
93
+ } else {
94
+ if ("instructionFn" in options) value[key] = options.instructionFn(value[key], key, currentElement);
95
+ element[options.instructionKey] = value[key];
96
+ }
97
+ } else {
98
+ if (type + "Fn" in options) value = options[type + "Fn"](value, currentElement);
99
+ element[options[type + "Key"]] = value;
100
+ }
101
+ if (options.addParent) element[options.parentKey] = currentElement;
102
+ currentElement[options.elementsKey].push(element);
103
+ }
104
+ }
105
+ function manipulateAttributes(attributes) {
106
+ if ("attributesFn" in options && attributes) attributes = options.attributesFn(attributes, currentElement);
107
+ if ((options.trim || "attributeValueFn" in options || "attributeNameFn" in options || options.nativeTypeAttributes) && attributes) {
108
+ var key;
109
+ for (key in attributes) if (attributes.hasOwnProperty(key)) {
110
+ if (options.trim) attributes[key] = attributes[key].trim();
111
+ if (options.nativeTypeAttributes) attributes[key] = nativeType(attributes[key]);
112
+ if ("attributeValueFn" in options) attributes[key] = options.attributeValueFn(attributes[key], key, currentElement);
113
+ if ("attributeNameFn" in options) {
114
+ var temp = attributes[key];
115
+ delete attributes[key];
116
+ attributes[options.attributeNameFn(key, attributes[key], currentElement)] = temp;
117
+ }
118
+ }
119
+ }
120
+ return attributes;
121
+ }
122
+ function onInstruction(instruction) {
123
+ var attributes = {};
124
+ if (instruction.body && (instruction.name.toLowerCase() === "xml" || options.instructionHasAttributes)) {
125
+ var attrsRegExp = /([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g;
126
+ var match;
127
+ while ((match = attrsRegExp.exec(instruction.body)) !== null) attributes[match[1]] = match[2] || match[3] || match[4];
128
+ attributes = manipulateAttributes(attributes);
129
+ }
130
+ if (instruction.name.toLowerCase() === "xml") {
131
+ if (options.ignoreDeclaration) return;
132
+ currentElement[options.declarationKey] = {};
133
+ if (Object.keys(attributes).length) currentElement[options.declarationKey][options.attributesKey] = attributes;
134
+ if (options.addParent) currentElement[options.declarationKey][options.parentKey] = currentElement;
135
+ } else {
136
+ if (options.ignoreInstruction) return;
137
+ if (options.trim) instruction.body = instruction.body.trim();
138
+ var value = {};
139
+ if (options.instructionHasAttributes && Object.keys(attributes).length) {
140
+ value[instruction.name] = {};
141
+ value[instruction.name][options.attributesKey] = attributes;
142
+ } else value[instruction.name] = instruction.body;
143
+ addField("instruction", value);
144
+ }
145
+ }
146
+ function onStartElement(name, attributes) {
147
+ var element;
148
+ if (typeof name === "object") {
149
+ attributes = name.attributes;
150
+ name = name.name;
151
+ }
152
+ attributes = manipulateAttributes(attributes);
153
+ if ("elementNameFn" in options) name = options.elementNameFn(name, currentElement);
154
+ if (options.compact) {
155
+ element = {};
156
+ if (!options.ignoreAttributes && attributes && Object.keys(attributes).length) {
157
+ element[options.attributesKey] = {};
158
+ var key;
159
+ for (key in attributes) if (attributes.hasOwnProperty(key)) element[options.attributesKey][key] = attributes[key];
160
+ }
161
+ if (!(name in currentElement) && (isArray(options.alwaysArray) ? options.alwaysArray.indexOf(name) !== -1 : options.alwaysArray)) currentElement[name] = [];
162
+ if (currentElement[name] && !isArray(currentElement[name])) currentElement[name] = [currentElement[name]];
163
+ if (isArray(currentElement[name])) currentElement[name].push(element);
164
+ else currentElement[name] = element;
165
+ } else {
166
+ if (!currentElement[options.elementsKey]) currentElement[options.elementsKey] = [];
167
+ element = {};
168
+ element[options.typeKey] = "element";
169
+ element[options.nameKey] = name;
170
+ if (!options.ignoreAttributes && attributes && Object.keys(attributes).length) element[options.attributesKey] = attributes;
171
+ if (options.alwaysChildren) element[options.elementsKey] = [];
172
+ currentElement[options.elementsKey].push(element);
173
+ }
174
+ element[options.parentKey] = currentElement;
175
+ currentElement = element;
176
+ }
177
+ function onText(text) {
178
+ if (options.ignoreText) return;
179
+ if (!text.trim() && !options.captureSpacesBetweenElements) return;
180
+ if (options.trim) text = text.trim();
181
+ if (options.nativeType) text = nativeType(text);
182
+ if (options.sanitize) text = text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
183
+ addField("text", text);
184
+ }
185
+ function onComment(comment) {
186
+ if (options.ignoreComment) return;
187
+ if (options.trim) comment = comment.trim();
188
+ addField("comment", comment);
189
+ }
190
+ function onEndElement(name) {
191
+ var parentElement = currentElement[options.parentKey];
192
+ if (!options.addParent) delete currentElement[options.parentKey];
193
+ currentElement = parentElement;
194
+ }
195
+ function onCdata(cdata) {
196
+ if (options.ignoreCdata) return;
197
+ if (options.trim) cdata = cdata.trim();
198
+ addField("cdata", cdata);
199
+ }
200
+ function onDoctype(doctype) {
201
+ if (options.ignoreDoctype) return;
202
+ doctype = doctype.replace(/^ /, "");
203
+ if (options.trim) doctype = doctype.trim();
204
+ addField("doctype", doctype);
205
+ }
206
+ function onError(error) {
207
+ error.note = error;
208
+ }
209
+ module.exports = function(xml, userOptions) {
210
+ var parser = pureJsParser ? sax.parser(true, {}) : parser = new expat.Parser("UTF-8");
211
+ var result = {};
212
+ currentElement = result;
213
+ options = validateOptions(userOptions);
214
+ if (pureJsParser) {
215
+ parser.opt = { strictEntities: true };
216
+ parser.onopentag = onStartElement;
217
+ parser.ontext = onText;
218
+ parser.oncomment = onComment;
219
+ parser.onclosetag = onEndElement;
220
+ parser.onerror = onError;
221
+ parser.oncdata = onCdata;
222
+ parser.ondoctype = onDoctype;
223
+ parser.onprocessinginstruction = onInstruction;
224
+ } else {
225
+ parser.on("startElement", onStartElement);
226
+ parser.on("text", onText);
227
+ parser.on("comment", onComment);
228
+ parser.on("endElement", onEndElement);
229
+ parser.on("error", onError);
230
+ }
231
+ if (pureJsParser) parser.write(xml).close();
232
+ else if (!parser.parse(xml)) throw new Error("XML parsing error: " + parser.getError());
233
+ if (result[options.elementsKey]) {
234
+ var temp = result[options.elementsKey];
235
+ delete result[options.elementsKey];
236
+ result[options.elementsKey] = temp;
237
+ delete result.text;
238
+ }
239
+ return result;
240
+ };
241
+ }));
242
+ //#endregion
243
+ export default require_xml2js();
244
+ export { require_xml2js };
245
+
246
+ //# sourceMappingURL=xml2js.js.map
@@ -0,0 +1,26 @@
1
+ import { __commonJSMin } from "../../../_virtual/_rolldown/runtime.js";
2
+ import { require_options_helper } from "./options-helper.js";
3
+ import { require_xml2js } from "./xml2js.js";
4
+ //#region node_modules/xml-js/lib/xml2json.js
5
+ var require_xml2json = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6
+ var helper = require_options_helper();
7
+ var xml2js = require_xml2js();
8
+ function validateOptions(userOptions) {
9
+ var options = helper.copyOptions(userOptions);
10
+ helper.ensureSpacesExists(options);
11
+ return options;
12
+ }
13
+ module.exports = function(xml, userOptions) {
14
+ var options = validateOptions(userOptions), js = xml2js(xml, options), json, parentKey = "compact" in options && options.compact ? "_parent" : "parent";
15
+ if ("addParent" in options && options.addParent) json = JSON.stringify(js, function(k, v) {
16
+ return k === parentKey ? "_" : v;
17
+ }, options.spaces);
18
+ else json = JSON.stringify(js, null, options.spaces);
19
+ return json.replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
20
+ };
21
+ }));
22
+ //#endregion
23
+ export default require_xml2json();
24
+ export { require_xml2json };
25
+
26
+ //# sourceMappingURL=xml2json.js.map
@@ -1,15 +1,26 @@
1
- const KEBAB_REGEX = new RegExp("\\p{Lu}", "gu");
1
+ //#region src/util/kebab-case.ts
2
+ var KEBAB_REGEX = /\p{Lu}/gu;
3
+ /**
4
+ * Transforms a string into kebab-case.
5
+ *
6
+ * stolen from https://github.com/joakimbeng/kebab-case/blob/master/index.js
7
+ *
8
+ * @example
9
+ * kebabCase("helloWorld"); // "hello-world"
10
+ * kebabCase("HelloWorld"); // "-hello-world"
11
+ * kebabCase("HelloWorld", false); // "hello-world"
12
+ *
13
+ * @param str The string to transform
14
+ * @param keepLeadingDash Whether to keep the leading dash in case the string starts with an uppercase letter (default: true)
15
+ * @returns The kebab-cased string
16
+ */
2
17
  function kebabCase(str, keepLeadingDash = false) {
3
- const result = str.replace(KEBAB_REGEX, (match) => `-${match.toLowerCase()}`);
4
- if (keepLeadingDash) {
5
- return result;
6
- }
7
- if (result.startsWith("-")) {
8
- return result.slice(1);
9
- }
10
- return result;
18
+ const result = str.replace(KEBAB_REGEX, (match) => `-${match.toLowerCase()}`);
19
+ if (keepLeadingDash) return result;
20
+ if (result.startsWith("-")) return result.slice(1);
21
+ return result;
11
22
  }
12
- export {
13
- kebabCase
14
- };
15
- //# sourceMappingURL=kebab-case.js.map
23
+ //#endregion
24
+ export { kebabCase };
25
+
26
+ //# sourceMappingURL=kebab-case.js.map
@@ -0,0 +1,4 @@
1
+ import { z } from 'zod';
2
+ export declare function isZodType(object: any): object is z.ZodType;
3
+ export declare function getParentSchema(schema: z.ZodType): z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
4
+ //# sourceMappingURL=zod.d.ts.map