@loaders.gl/xml 3.4.0-alpha.1 → 3.4.0-alpha.3

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 (73) hide show
  1. package/dist/dist.min.js +419 -196
  2. package/dist/es5/html-loader.js +57 -0
  3. package/dist/es5/html-loader.js.map +1 -0
  4. package/dist/es5/index.js +33 -0
  5. package/dist/es5/index.js.map +1 -1
  6. package/dist/es5/lib/{parse-xml.js → parsers/parse-xml.js} +7 -7
  7. package/dist/es5/lib/parsers/parse-xml.js.map +1 -0
  8. package/dist/es5/lib/{parser/xml-parser.js → parsers/streaming-xml-parser.js} +10 -15
  9. package/dist/es5/lib/parsers/streaming-xml-parser.js.map +1 -0
  10. package/dist/es5/lib/xml-utils/uncapitalize.js +32 -0
  11. package/dist/es5/lib/xml-utils/uncapitalize.js.map +1 -0
  12. package/dist/es5/lib/xml-utils/xml-utils.js +23 -0
  13. package/dist/es5/lib/xml-utils/xml-utils.js.map +1 -0
  14. package/dist/es5/sax-ts/sax.js +1 -18
  15. package/dist/es5/sax-ts/sax.js.map +1 -1
  16. package/dist/es5/xml-loader.js +44 -12
  17. package/dist/es5/xml-loader.js.map +1 -1
  18. package/dist/esm/bundle.js +0 -1
  19. package/dist/esm/bundle.js.map +1 -1
  20. package/dist/esm/html-loader.js +27 -0
  21. package/dist/esm/html-loader.js.map +1 -0
  22. package/dist/esm/index.js +3 -3
  23. package/dist/esm/index.js.map +1 -1
  24. package/dist/esm/lib/parsers/parse-xml.js +22 -0
  25. package/dist/esm/lib/parsers/parse-xml.js.map +1 -0
  26. package/dist/esm/lib/{parser/xml-parser.js → parsers/streaming-xml-parser.js} +3 -8
  27. package/dist/esm/lib/parsers/streaming-xml-parser.js.map +1 -0
  28. package/dist/esm/lib/xml-utils/uncapitalize.js +17 -0
  29. package/dist/esm/lib/xml-utils/uncapitalize.js.map +1 -0
  30. package/dist/esm/lib/xml-utils/xml-utils.js +14 -0
  31. package/dist/esm/lib/xml-utils/xml-utils.js.map +1 -0
  32. package/dist/esm/sax-ts/sax.js +1 -19
  33. package/dist/esm/sax-ts/sax.js.map +1 -1
  34. package/dist/esm/xml-loader.js +38 -6
  35. package/dist/esm/xml-loader.js.map +1 -1
  36. package/dist/html-loader.d.ts +11 -0
  37. package/dist/html-loader.d.ts.map +1 -0
  38. package/dist/html-loader.js +40 -0
  39. package/dist/index.d.ts +4 -0
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +11 -1
  42. package/dist/lib/parsers/parse-xml.d.ts +12 -0
  43. package/dist/lib/parsers/parse-xml.d.ts.map +1 -0
  44. package/dist/lib/{parse-xml.js → parsers/parse-xml.js} +7 -8
  45. package/dist/lib/{parser/xml-parser.d.ts → parsers/streaming-xml-parser.d.ts} +6 -2
  46. package/dist/lib/parsers/streaming-xml-parser.d.ts.map +1 -0
  47. package/dist/lib/{parser/xml-parser.js → parsers/streaming-xml-parser.js} +6 -6
  48. package/dist/lib/xml-utils/uncapitalize.d.ts +13 -0
  49. package/dist/lib/xml-utils/uncapitalize.d.ts.map +1 -0
  50. package/dist/lib/xml-utils/uncapitalize.js +32 -0
  51. package/dist/lib/xml-utils/xml-utils.d.ts +11 -0
  52. package/dist/lib/xml-utils/xml-utils.d.ts.map +1 -0
  53. package/dist/lib/xml-utils/xml-utils.js +30 -0
  54. package/dist/sax-ts/sax.js +1 -1
  55. package/dist/xml-loader.d.ts +21 -3
  56. package/dist/xml-loader.d.ts.map +1 -1
  57. package/dist/xml-loader.js +41 -5
  58. package/package.json +5 -5
  59. package/src/html-loader.ts +46 -0
  60. package/src/index.ts +16 -0
  61. package/src/lib/{parse-xml.ts → parsers/parse-xml.ts} +9 -6
  62. package/src/lib/{parser/xml-parser.ts → parsers/streaming-xml-parser.ts} +5 -3
  63. package/src/lib/xml-utils/uncapitalize.ts +31 -0
  64. package/src/lib/xml-utils/xml-utils.ts +27 -0
  65. package/src/xml-loader.ts +63 -6
  66. package/dist/es5/lib/parse-xml.js.map +0 -1
  67. package/dist/es5/lib/parser/xml-parser.js.map +0 -1
  68. package/dist/esm/lib/parse-xml.js +0 -24
  69. package/dist/esm/lib/parse-xml.js.map +0 -1
  70. package/dist/esm/lib/parser/xml-parser.js.map +0 -1
  71. package/dist/lib/parse-xml.d.ts +0 -9
  72. package/dist/lib/parse-xml.d.ts.map +0 -1
  73. package/dist/lib/parser/xml-parser.d.ts.map +0 -1
package/dist/dist.min.js CHANGED
@@ -1740,13 +1740,14 @@ Actual: ${this.attribValue}`);
1740
1740
  cdataPropName: false,
1741
1741
  numberParseOptions: {
1742
1742
  hex: true,
1743
- leadingZeros: true
1743
+ leadingZeros: true,
1744
+ eNotation: true
1744
1745
  },
1745
- tagValueProcessor: function(tagName, val) {
1746
- return val;
1746
+ tagValueProcessor: function(tagName, val2) {
1747
+ return val2;
1747
1748
  },
1748
- attributeValueProcessor: function(attrName, val) {
1749
- return val;
1749
+ attributeValueProcessor: function(attrName, val2) {
1750
+ return val2;
1750
1751
  },
1751
1752
  stopNodes: [],
1752
1753
  alwaysCreateTextNode: false,
@@ -1757,7 +1758,11 @@ Actual: ${this.attribValue}`);
1757
1758
  htmlEntities: false,
1758
1759
  ignoreDeclaration: false,
1759
1760
  ignorePiTags: false,
1760
- transformTagName: false
1761
+ transformTagName: false,
1762
+ transformAttributeName: false,
1763
+ updateTag: function(tagName, jPath, attrs) {
1764
+ return tagName;
1765
+ }
1761
1766
  };
1762
1767
  var buildOptions = function(options) {
1763
1768
  return Object.assign({}, defaultOptions, options);
@@ -1777,10 +1782,14 @@ Actual: ${this.attribValue}`);
1777
1782
  this.child = [];
1778
1783
  this[":@"] = {};
1779
1784
  }
1780
- add(key, val) {
1781
- this.child.push({ [key]: val });
1785
+ add(key, val2) {
1786
+ if (key === "__proto__")
1787
+ key = "#__proto__";
1788
+ this.child.push({ [key]: val2 });
1782
1789
  }
1783
1790
  addChild(node) {
1791
+ if (node.tagname === "__proto__")
1792
+ node.tagname = "#__proto__";
1784
1793
  if (node[":@"] && Object.keys(node[":@"]).length > 0) {
1785
1794
  this.child.push({ [node.tagname]: node.child, [":@"]: node[":@"] });
1786
1795
  } else {
@@ -1800,38 +1809,39 @@ Actual: ${this.attribValue}`);
1800
1809
  if (xmlData[i + 3] === "O" && xmlData[i + 4] === "C" && xmlData[i + 5] === "T" && xmlData[i + 6] === "Y" && xmlData[i + 7] === "P" && xmlData[i + 8] === "E") {
1801
1810
  i = i + 9;
1802
1811
  let angleBracketsCount = 1;
1803
- let hasBody = false, entity = false, comment = false;
1812
+ let hasBody = false, comment = false;
1804
1813
  let exp = "";
1805
1814
  for (; i < xmlData.length; i++) {
1806
- if (xmlData[i] === "<") {
1807
- if (hasBody && xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "N" && xmlData[i + 4] === "T" && xmlData[i + 5] === "I" && xmlData[i + 6] === "T" && xmlData[i + 7] === "Y") {
1815
+ if (xmlData[i] === "<" && !comment) {
1816
+ if (hasBody && isEntity(xmlData, i)) {
1808
1817
  i += 7;
1809
- entity = true;
1810
- } else if (hasBody && xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "L" && xmlData[i + 4] === "E" && xmlData[i + 5] === "M" && xmlData[i + 6] === "E" && xmlData[i + 7] === "N" && xmlData[i + 8] === "T") {
1818
+ [entityName, val, i] = readEntityExp(xmlData, i + 1);
1819
+ if (val.indexOf("&") === -1)
1820
+ entities[entityName] = {
1821
+ regx: RegExp(`&${entityName};`, "g"),
1822
+ val
1823
+ };
1824
+ } else if (hasBody && isElement(xmlData, i))
1811
1825
  i += 8;
1812
- } else if (hasBody && xmlData[i + 1] === "!" && xmlData[i + 2] === "A" && xmlData[i + 3] === "T" && xmlData[i + 4] === "T" && xmlData[i + 5] === "L" && xmlData[i + 6] === "I" && xmlData[i + 7] === "S" && xmlData[i + 8] === "T") {
1826
+ else if (hasBody && isAttlist(xmlData, i))
1813
1827
  i += 8;
1814
- } else if (hasBody && xmlData[i + 1] === "!" && xmlData[i + 2] === "N" && xmlData[i + 3] === "O" && xmlData[i + 4] === "T" && xmlData[i + 5] === "A" && xmlData[i + 6] === "T" && xmlData[i + 7] === "I" && xmlData[i + 8] === "O" && xmlData[i + 9] === "N") {
1828
+ else if (hasBody && isNotation(xmlData, i))
1815
1829
  i += 9;
1816
- } else if (xmlData[i + 1] === "!" && xmlData[i + 2] === "-" && xmlData[i + 3] === "-") {
1830
+ else if (isComment)
1817
1831
  comment = true;
1818
- } else {
1832
+ else
1819
1833
  throw new Error("Invalid DOCTYPE");
1820
- }
1821
1834
  angleBracketsCount++;
1822
1835
  exp = "";
1823
1836
  } else if (xmlData[i] === ">") {
1824
1837
  if (comment) {
1825
1838
  if (xmlData[i - 1] === "-" && xmlData[i - 2] === "-") {
1826
1839
  comment = false;
1827
- } else {
1828
- throw new Error(`Invalid XML comment in DOCTYPE`);
1840
+ angleBracketsCount--;
1829
1841
  }
1830
- } else if (entity) {
1831
- parseEntityExp(exp, entities);
1832
- entity = false;
1842
+ } else {
1843
+ angleBracketsCount--;
1833
1844
  }
1834
- angleBracketsCount--;
1835
1845
  if (angleBracketsCount === 0) {
1836
1846
  break;
1837
1847
  }
@@ -1849,15 +1859,45 @@ Actual: ${this.attribValue}`);
1849
1859
  }
1850
1860
  return { entities, i };
1851
1861
  }
1852
- var entityRegex = RegExp(`^\\s([a-zA-z0-0]+)[ ](['"])([^&]+)\\2`);
1853
- function parseEntityExp(exp, entities) {
1854
- const match = entityRegex.exec(exp);
1855
- if (match) {
1856
- entities[match[1]] = {
1857
- regx: RegExp(`&${match[1]};`, "g"),
1858
- val: match[3]
1859
- };
1860
- }
1862
+ function readEntityExp(xmlData, i) {
1863
+ let entityName2 = "";
1864
+ for (; i < xmlData.length && (xmlData[i] !== "'" && xmlData[i] !== '"'); i++) {
1865
+ entityName2 += xmlData[i];
1866
+ }
1867
+ entityName2 = entityName2.trim();
1868
+ if (entityName2.indexOf(" ") !== -1)
1869
+ throw new Error("External entites are not supported");
1870
+ const startChar = xmlData[i++];
1871
+ let val2 = "";
1872
+ for (; i < xmlData.length && xmlData[i] !== startChar; i++) {
1873
+ val2 += xmlData[i];
1874
+ }
1875
+ return [entityName2, val2, i];
1876
+ }
1877
+ function isComment(xmlData, i) {
1878
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "-" && xmlData[i + 3] === "-")
1879
+ return true;
1880
+ return false;
1881
+ }
1882
+ function isEntity(xmlData, i) {
1883
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "N" && xmlData[i + 4] === "T" && xmlData[i + 5] === "I" && xmlData[i + 6] === "T" && xmlData[i + 7] === "Y")
1884
+ return true;
1885
+ return false;
1886
+ }
1887
+ function isElement(xmlData, i) {
1888
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "L" && xmlData[i + 4] === "E" && xmlData[i + 5] === "M" && xmlData[i + 6] === "E" && xmlData[i + 7] === "N" && xmlData[i + 8] === "T")
1889
+ return true;
1890
+ return false;
1891
+ }
1892
+ function isAttlist(xmlData, i) {
1893
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "A" && xmlData[i + 3] === "T" && xmlData[i + 4] === "T" && xmlData[i + 5] === "L" && xmlData[i + 6] === "I" && xmlData[i + 7] === "S" && xmlData[i + 8] === "T")
1894
+ return true;
1895
+ return false;
1896
+ }
1897
+ function isNotation(xmlData, i) {
1898
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "N" && xmlData[i + 3] === "O" && xmlData[i + 4] === "T" && xmlData[i + 5] === "A" && xmlData[i + 6] === "T" && xmlData[i + 7] === "I" && xmlData[i + 8] === "O" && xmlData[i + 9] === "N")
1899
+ return true;
1900
+ return false;
1861
1901
  }
1862
1902
  module.exports = readDocType;
1863
1903
  }
@@ -2000,6 +2040,7 @@ Actual: ${this.attribValue}`);
2000
2040
  this.replaceEntitiesValue = replaceEntitiesValue;
2001
2041
  this.readStopNodeData = readStopNodeData;
2002
2042
  this.saveTextToParentTag = saveTextToParentTag;
2043
+ this.addChild = addChild;
2003
2044
  }
2004
2045
  };
2005
2046
  function addExternalEntities(externalEntities) {
@@ -2012,27 +2053,27 @@ Actual: ${this.attribValue}`);
2012
2053
  };
2013
2054
  }
2014
2055
  }
2015
- function parseTextData(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
2016
- if (val !== void 0) {
2056
+ function parseTextData(val2, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
2057
+ if (val2 !== void 0) {
2017
2058
  if (this.options.trimValues && !dontTrim) {
2018
- val = val.trim();
2059
+ val2 = val2.trim();
2019
2060
  }
2020
- if (val.length > 0) {
2061
+ if (val2.length > 0) {
2021
2062
  if (!escapeEntities)
2022
- val = this.replaceEntitiesValue(val);
2023
- const newval = this.options.tagValueProcessor(tagName, val, jPath, hasAttributes, isLeafNode);
2063
+ val2 = this.replaceEntitiesValue(val2);
2064
+ const newval = this.options.tagValueProcessor(tagName, val2, jPath, hasAttributes, isLeafNode);
2024
2065
  if (newval === null || newval === void 0) {
2025
- return val;
2026
- } else if (typeof newval !== typeof val || newval !== val) {
2066
+ return val2;
2067
+ } else if (typeof newval !== typeof val2 || newval !== val2) {
2027
2068
  return newval;
2028
2069
  } else if (this.options.trimValues) {
2029
- return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions);
2070
+ return parseValue(val2, this.options.parseTagValue, this.options.numberParseOptions);
2030
2071
  } else {
2031
- const trimmedVal = val.trim();
2032
- if (trimmedVal === val) {
2033
- return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions);
2072
+ const trimmedVal = val2.trim();
2073
+ if (trimmedVal === val2) {
2074
+ return parseValue(val2, this.options.parseTagValue, this.options.numberParseOptions);
2034
2075
  } else {
2035
- return val;
2076
+ return val2;
2036
2077
  }
2037
2078
  }
2038
2079
  }
@@ -2052,7 +2093,7 @@ Actual: ${this.attribValue}`);
2052
2093
  return tagname;
2053
2094
  }
2054
2095
  var attrsRegx = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
2055
- function buildAttributesMap(attrStr, jPath) {
2096
+ function buildAttributesMap(attrStr, jPath, tagName) {
2056
2097
  if (!this.options.ignoreAttributes && typeof attrStr === "string") {
2057
2098
  const matches = util.getAllMatches(attrStr, attrsRegx);
2058
2099
  const len = matches.length;
@@ -2060,8 +2101,13 @@ Actual: ${this.attribValue}`);
2060
2101
  for (let i = 0; i < len; i++) {
2061
2102
  const attrName = this.resolveNameSpace(matches[i][1]);
2062
2103
  let oldVal = matches[i][4];
2063
- const aName = this.options.attributeNamePrefix + attrName;
2104
+ let aName = this.options.attributeNamePrefix + attrName;
2064
2105
  if (attrName.length) {
2106
+ if (this.options.transformAttributeName) {
2107
+ aName = this.options.transformAttributeName(aName);
2108
+ }
2109
+ if (aName === "__proto__")
2110
+ aName = "#__proto__";
2065
2111
  if (oldVal !== void 0) {
2066
2112
  if (this.options.trimValues) {
2067
2113
  oldVal = oldVal.trim();
@@ -2115,7 +2161,18 @@ Actual: ${this.attribValue}`);
2115
2161
  if (currentNode) {
2116
2162
  textData = this.saveTextToParentTag(textData, currentNode, jPath);
2117
2163
  }
2118
- jPath = jPath.substr(0, jPath.lastIndexOf("."));
2164
+ const lastTagName = jPath.substring(jPath.lastIndexOf(".") + 1);
2165
+ if (tagName && this.options.unpairedTags.indexOf(tagName) !== -1) {
2166
+ throw new Error(`Unpaired tag can not be used as closing tag: </${tagName}>`);
2167
+ }
2168
+ let propIndex = 0;
2169
+ if (lastTagName && this.options.unpairedTags.indexOf(lastTagName) !== -1) {
2170
+ propIndex = jPath.lastIndexOf(".", jPath.lastIndexOf(".") - 1);
2171
+ this.tagsNodeStack.pop();
2172
+ } else {
2173
+ propIndex = jPath.lastIndexOf(".");
2174
+ }
2175
+ jPath = jPath.substring(0, propIndex);
2119
2176
  currentNode = this.tagsNodeStack.pop();
2120
2177
  textData = "";
2121
2178
  i = closeIndex;
@@ -2129,9 +2186,9 @@ Actual: ${this.attribValue}`);
2129
2186
  const childNode = new xmlNode(tagData.tagName);
2130
2187
  childNode.add(this.options.textNodeName, "");
2131
2188
  if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent) {
2132
- childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath);
2189
+ childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath, tagData.tagName);
2133
2190
  }
2134
- currentNode.addChild(childNode);
2191
+ this.addChild(currentNode, childNode, jPath);
2135
2192
  }
2136
2193
  i = tagData.closeIndex + 1;
2137
2194
  } else if (xmlData.substr(i + 1, 3) === "!--") {
@@ -2153,10 +2210,10 @@ Actual: ${this.attribValue}`);
2153
2210
  if (this.options.cdataPropName) {
2154
2211
  currentNode.add(this.options.cdataPropName, [{ [this.options.textNodeName]: tagExp }]);
2155
2212
  } else {
2156
- let val = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true);
2157
- if (val == void 0)
2158
- val = "";
2159
- currentNode.add(this.options.textNodeName, val);
2213
+ let val2 = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true);
2214
+ if (val2 == void 0)
2215
+ val2 = "";
2216
+ currentNode.add(this.options.textNodeName, val2);
2160
2217
  }
2161
2218
  i = closeIndex + 2;
2162
2219
  } else {
@@ -2173,12 +2230,13 @@ Actual: ${this.attribValue}`);
2173
2230
  textData = this.saveTextToParentTag(textData, currentNode, jPath, false);
2174
2231
  }
2175
2232
  }
2176
- if (tagName !== xmlObj.tagname) {
2177
- jPath += jPath ? "." + tagName : tagName;
2178
- }
2179
2233
  const lastTag = currentNode;
2180
2234
  if (lastTag && this.options.unpairedTags.indexOf(lastTag.tagname) !== -1) {
2181
2235
  currentNode = this.tagsNodeStack.pop();
2236
+ jPath = jPath.substring(0, jPath.lastIndexOf("."));
2237
+ }
2238
+ if (tagName !== xmlObj.tagname) {
2239
+ jPath += jPath ? "." + tagName : tagName;
2182
2240
  }
2183
2241
  if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) {
2184
2242
  let tagContent = "";
@@ -2195,14 +2253,14 @@ Actual: ${this.attribValue}`);
2195
2253
  }
2196
2254
  const childNode = new xmlNode(tagName);
2197
2255
  if (tagName !== tagExp && attrExpPresent) {
2198
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath);
2256
+ childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
2199
2257
  }
2200
2258
  if (tagContent) {
2201
2259
  tagContent = this.parseTextData(tagContent, tagName, jPath, true, attrExpPresent, true, true);
2202
2260
  }
2203
2261
  jPath = jPath.substr(0, jPath.lastIndexOf("."));
2204
2262
  childNode.add(this.options.textNodeName, tagContent);
2205
- currentNode.addChild(childNode);
2263
+ this.addChild(currentNode, childNode, jPath);
2206
2264
  } else {
2207
2265
  if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
2208
2266
  if (tagName[tagName.length - 1] === "/") {
@@ -2216,17 +2274,17 @@ Actual: ${this.attribValue}`);
2216
2274
  }
2217
2275
  const childNode = new xmlNode(tagName);
2218
2276
  if (tagName !== tagExp && attrExpPresent) {
2219
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath);
2277
+ childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
2220
2278
  }
2279
+ this.addChild(currentNode, childNode, jPath);
2221
2280
  jPath = jPath.substr(0, jPath.lastIndexOf("."));
2222
- currentNode.addChild(childNode);
2223
2281
  } else {
2224
2282
  const childNode = new xmlNode(tagName);
2225
2283
  this.tagsNodeStack.push(currentNode);
2226
2284
  if (tagName !== tagExp && attrExpPresent) {
2227
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath);
2285
+ childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
2228
2286
  }
2229
- currentNode.addChild(childNode);
2287
+ this.addChild(currentNode, childNode, jPath);
2230
2288
  currentNode = childNode;
2231
2289
  }
2232
2290
  textData = "";
@@ -2239,25 +2297,35 @@ Actual: ${this.attribValue}`);
2239
2297
  }
2240
2298
  return xmlObj.child;
2241
2299
  };
2242
- var replaceEntitiesValue = function(val) {
2300
+ function addChild(currentNode, childNode, jPath) {
2301
+ const result = this.options.updateTag(childNode.tagname, jPath, childNode[":@"]);
2302
+ if (result === false) {
2303
+ } else if (typeof result === "string") {
2304
+ childNode.tagname = result;
2305
+ currentNode.addChild(childNode);
2306
+ } else {
2307
+ currentNode.addChild(childNode);
2308
+ }
2309
+ }
2310
+ var replaceEntitiesValue = function(val2) {
2243
2311
  if (this.options.processEntities) {
2244
- for (let entityName in this.docTypeEntities) {
2245
- const entity = this.docTypeEntities[entityName];
2246
- val = val.replace(entity.regx, entity.val);
2312
+ for (let entityName2 in this.docTypeEntities) {
2313
+ const entity = this.docTypeEntities[entityName2];
2314
+ val2 = val2.replace(entity.regx, entity.val);
2247
2315
  }
2248
- for (let entityName in this.lastEntities) {
2249
- const entity = this.lastEntities[entityName];
2250
- val = val.replace(entity.regex, entity.val);
2316
+ for (let entityName2 in this.lastEntities) {
2317
+ const entity = this.lastEntities[entityName2];
2318
+ val2 = val2.replace(entity.regex, entity.val);
2251
2319
  }
2252
2320
  if (this.options.htmlEntities) {
2253
- for (let entityName in this.htmlEntities) {
2254
- const entity = this.htmlEntities[entityName];
2255
- val = val.replace(entity.regex, entity.val);
2321
+ for (let entityName2 in this.htmlEntities) {
2322
+ const entity = this.htmlEntities[entityName2];
2323
+ val2 = val2.replace(entity.regex, entity.val);
2256
2324
  }
2257
2325
  }
2258
- val = val.replace(this.ampEntity.regex, this.ampEntity.val);
2326
+ val2 = val2.replace(this.ampEntity.regex, this.ampEntity.val);
2259
2327
  }
2260
- return val;
2328
+ return val2;
2261
2329
  };
2262
2330
  function saveTextToParentTag(textData, currentNode, jPath, isLeafNode) {
2263
2331
  if (textData) {
@@ -2384,18 +2452,18 @@ Actual: ${this.attribValue}`);
2384
2452
  }
2385
2453
  }
2386
2454
  }
2387
- function parseValue(val, shouldParse, options) {
2388
- if (shouldParse && typeof val === "string") {
2389
- const newval = val.trim();
2455
+ function parseValue(val2, shouldParse, options) {
2456
+ if (shouldParse && typeof val2 === "string") {
2457
+ const newval = val2.trim();
2390
2458
  if (newval === "true")
2391
2459
  return true;
2392
2460
  else if (newval === "false")
2393
2461
  return false;
2394
2462
  else
2395
- return toNumber(val, options);
2463
+ return toNumber(val2, options);
2396
2464
  } else {
2397
- if (util.isExist(val)) {
2398
- return val;
2465
+ if (util.isExist(val2)) {
2466
+ return val2;
2399
2467
  } else {
2400
2468
  return "";
2401
2469
  }
@@ -2431,28 +2499,28 @@ Actual: ${this.attribValue}`);
2431
2499
  } else if (property === void 0) {
2432
2500
  continue;
2433
2501
  } else if (tagObj[property]) {
2434
- let val = compress(tagObj[property], options, newJpath);
2435
- const isLeaf = isLeafTag(val, options);
2502
+ let val2 = compress(tagObj[property], options, newJpath);
2503
+ const isLeaf = isLeafTag(val2, options);
2436
2504
  if (tagObj[":@"]) {
2437
- assignAttributes(val, tagObj[":@"], newJpath, options);
2438
- } else if (Object.keys(val).length === 1 && val[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
2439
- val = val[options.textNodeName];
2440
- } else if (Object.keys(val).length === 0) {
2505
+ assignAttributes(val2, tagObj[":@"], newJpath, options);
2506
+ } else if (Object.keys(val2).length === 1 && val2[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
2507
+ val2 = val2[options.textNodeName];
2508
+ } else if (Object.keys(val2).length === 0) {
2441
2509
  if (options.alwaysCreateTextNode)
2442
- val[options.textNodeName] = "";
2510
+ val2[options.textNodeName] = "";
2443
2511
  else
2444
- val = "";
2512
+ val2 = "";
2445
2513
  }
2446
2514
  if (compressedObj[property] !== void 0 && compressedObj.hasOwnProperty(property)) {
2447
2515
  if (!Array.isArray(compressedObj[property])) {
2448
2516
  compressedObj[property] = [compressedObj[property]];
2449
2517
  }
2450
- compressedObj[property].push(val);
2518
+ compressedObj[property].push(val2);
2451
2519
  } else {
2452
2520
  if (options.isArray(property, newJpath, isLeaf)) {
2453
- compressedObj[property] = [val];
2521
+ compressedObj[property] = [val2];
2454
2522
  } else {
2455
- compressedObj[property] = val;
2523
+ compressedObj[property] = val2;
2456
2524
  }
2457
2525
  }
2458
2526
  }
@@ -2487,9 +2555,14 @@ Actual: ${this.attribValue}`);
2487
2555
  }
2488
2556
  }
2489
2557
  function isLeafTag(obj, options) {
2558
+ const { textNodeName } = options;
2490
2559
  const propCount = Object.keys(obj).length;
2491
- if (propCount === 0 || propCount === 1 && obj[options.textNodeName])
2560
+ if (propCount === 0) {
2561
+ return true;
2562
+ }
2563
+ if (propCount === 1 && (obj[textNodeName] || typeof obj[textNodeName] === "boolean" || obj[textNodeName] === 0)) {
2492
2564
  return true;
2565
+ }
2493
2566
  return false;
2494
2567
  }
2495
2568
  exports.prettify = prettify;
@@ -2552,14 +2625,15 @@ Actual: ${this.attribValue}`);
2552
2625
  "node_modules/fast-xml-parser/src/xmlbuilder/orderedJs2Xml.js"(exports, module) {
2553
2626
  var EOL = "\n";
2554
2627
  function toXml(jArray, options) {
2555
- return arrToStr(jArray, options, "", 0);
2556
- }
2557
- function arrToStr(arr, options, jPath, level) {
2558
- let xmlStr = "";
2559
2628
  let indentation = "";
2560
2629
  if (options.format && options.indentBy.length > 0) {
2561
- indentation = EOL + "" + options.indentBy.repeat(level);
2630
+ indentation = EOL;
2562
2631
  }
2632
+ return arrToStr(jArray, options, "", indentation);
2633
+ }
2634
+ function arrToStr(arr, options, jPath, indentation) {
2635
+ let xmlStr = "";
2636
+ let isPreviousElementTag = false;
2563
2637
  for (let i = 0; i < arr.length; i++) {
2564
2638
  const tagObj = arr[i];
2565
2639
  const tagName = propName(tagObj);
@@ -2574,13 +2648,22 @@ Actual: ${this.attribValue}`);
2574
2648
  tagText = options.tagValueProcessor(tagName, tagText);
2575
2649
  tagText = replaceEntitiesValue(tagText, options);
2576
2650
  }
2577
- xmlStr += indentation + tagText;
2651
+ if (isPreviousElementTag) {
2652
+ xmlStr += indentation;
2653
+ }
2654
+ xmlStr += tagText;
2655
+ isPreviousElementTag = false;
2578
2656
  continue;
2579
2657
  } else if (tagName === options.cdataPropName) {
2580
- xmlStr += indentation + `<![CDATA[${tagObj[tagName][0][options.textNodeName]}]]>`;
2658
+ if (isPreviousElementTag) {
2659
+ xmlStr += indentation;
2660
+ }
2661
+ xmlStr += `<![CDATA[${tagObj[tagName][0][options.textNodeName]}]]>`;
2662
+ isPreviousElementTag = false;
2581
2663
  continue;
2582
2664
  } else if (tagName === options.commentPropName) {
2583
2665
  xmlStr += indentation + `<!--${tagObj[tagName][0][options.textNodeName]}-->`;
2666
+ isPreviousElementTag = true;
2584
2667
  continue;
2585
2668
  } else if (tagName[0] === "?") {
2586
2669
  const attStr2 = attr_to_str(tagObj[":@"], options);
@@ -2588,11 +2671,16 @@ Actual: ${this.attribValue}`);
2588
2671
  let piTextNodeName = tagObj[tagName][0][options.textNodeName];
2589
2672
  piTextNodeName = piTextNodeName.length !== 0 ? " " + piTextNodeName : "";
2590
2673
  xmlStr += tempInd + `<${tagName}${piTextNodeName}${attStr2}?>`;
2674
+ isPreviousElementTag = true;
2591
2675
  continue;
2592
2676
  }
2677
+ let newIdentation = indentation;
2678
+ if (newIdentation !== "") {
2679
+ newIdentation += options.indentBy;
2680
+ }
2593
2681
  const attStr = attr_to_str(tagObj[":@"], options);
2594
- let tagStart = indentation + `<${tagName}${attStr}`;
2595
- let tagValue = arrToStr(tagObj[tagName], options, newJPath, level + 1);
2682
+ const tagStart = indentation + `<${tagName}${attStr}`;
2683
+ const tagValue = arrToStr(tagObj[tagName], options, newJPath, newIdentation);
2596
2684
  if (options.unpairedTags.indexOf(tagName) !== -1) {
2597
2685
  if (options.suppressUnpairedNode)
2598
2686
  xmlStr += tagStart + ">";
@@ -2600,9 +2688,18 @@ Actual: ${this.attribValue}`);
2600
2688
  xmlStr += tagStart + "/>";
2601
2689
  } else if ((!tagValue || tagValue.length === 0) && options.suppressEmptyNode) {
2602
2690
  xmlStr += tagStart + "/>";
2603
- } else {
2691
+ } else if (tagValue && tagValue.endsWith(">")) {
2604
2692
  xmlStr += tagStart + `>${tagValue}${indentation}</${tagName}>`;
2693
+ } else {
2694
+ xmlStr += tagStart + ">";
2695
+ if (tagValue && indentation !== "" && (tagValue.includes("/>") || tagValue.includes("</"))) {
2696
+ xmlStr += indentation + options.indentBy + tagValue + indentation;
2697
+ } else {
2698
+ xmlStr += tagValue;
2699
+ }
2700
+ xmlStr += `</${tagName}>`;
2605
2701
  }
2702
+ isPreviousElementTag = true;
2606
2703
  }
2607
2704
  return xmlStr;
2608
2705
  }
@@ -2685,7 +2782,7 @@ Actual: ${this.attribValue}`);
2685
2782
  ],
2686
2783
  processEntities: true,
2687
2784
  stopNodes: [],
2688
- transformTagName: false
2785
+ oneListGroup: false
2689
2786
  };
2690
2787
  function Builder(options) {
2691
2788
  this.options = Object.assign({}, defaultOptions, options);
@@ -2709,17 +2806,6 @@ Actual: ${this.attribValue}`);
2709
2806
  this.tagEndChar = ">";
2710
2807
  this.newLine = "";
2711
2808
  }
2712
- if (this.options.suppressEmptyNode) {
2713
- this.buildTextNode = buildEmptyTextNode;
2714
- this.buildObjNode = buildEmptyObjNode;
2715
- } else {
2716
- this.buildTextNode = buildTextValNode;
2717
- this.buildObjNode = buildObjectNode;
2718
- }
2719
- this.buildTextValNode = buildTextValNode;
2720
- this.buildObjectNode = buildObjectNode;
2721
- this.replaceEntitiesValue = replaceEntitiesValue;
2722
- this.buildAttrPairStr = buildAttrPairStr;
2723
2809
  }
2724
2810
  Builder.prototype.build = function(jObj) {
2725
2811
  if (this.options.preserveOrder) {
@@ -2735,16 +2821,16 @@ Actual: ${this.attribValue}`);
2735
2821
  };
2736
2822
  Builder.prototype.j2x = function(jObj, level) {
2737
2823
  let attrStr = "";
2738
- let val = "";
2824
+ let val2 = "";
2739
2825
  for (let key in jObj) {
2740
2826
  if (typeof jObj[key] === "undefined") {
2741
2827
  } else if (jObj[key] === null) {
2742
2828
  if (key[0] === "?")
2743
- val += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
2829
+ val2 += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
2744
2830
  else
2745
- val += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
2831
+ val2 += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
2746
2832
  } else if (jObj[key] instanceof Date) {
2747
- val += this.buildTextNode(jObj[key], key, "", level);
2833
+ val2 += this.buildTextValNode(jObj[key], key, "", level);
2748
2834
  } else if (typeof jObj[key] !== "object") {
2749
2835
  const attr = this.isAttribute(key);
2750
2836
  if (attr) {
@@ -2752,27 +2838,36 @@ Actual: ${this.attribValue}`);
2752
2838
  } else {
2753
2839
  if (key === this.options.textNodeName) {
2754
2840
  let newval = this.options.tagValueProcessor(key, "" + jObj[key]);
2755
- val += this.replaceEntitiesValue(newval);
2841
+ val2 += this.replaceEntitiesValue(newval);
2756
2842
  } else {
2757
- val += this.buildTextNode(jObj[key], key, "", level);
2843
+ val2 += this.buildTextValNode(jObj[key], key, "", level);
2758
2844
  }
2759
2845
  }
2760
2846
  } else if (Array.isArray(jObj[key])) {
2761
2847
  const arrLen = jObj[key].length;
2848
+ let listTagVal = "";
2762
2849
  for (let j = 0; j < arrLen; j++) {
2763
2850
  const item = jObj[key][j];
2764
2851
  if (typeof item === "undefined") {
2765
2852
  } else if (item === null) {
2766
2853
  if (key[0] === "?")
2767
- val += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
2854
+ val2 += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
2768
2855
  else
2769
- val += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
2856
+ val2 += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
2770
2857
  } else if (typeof item === "object") {
2771
- val += this.processTextOrObjNode(item, key, level);
2858
+ if (this.options.oneListGroup) {
2859
+ listTagVal += this.j2x(item, level + 1).val;
2860
+ } else {
2861
+ listTagVal += this.processTextOrObjNode(item, key, level);
2862
+ }
2772
2863
  } else {
2773
- val += this.buildTextNode(item, key, "", level);
2864
+ listTagVal += this.buildTextValNode(item, key, "", level);
2774
2865
  }
2775
2866
  }
2867
+ if (this.options.oneListGroup) {
2868
+ listTagVal = this.buildObjectNode(listTagVal, key, "", level);
2869
+ }
2870
+ val2 += listTagVal;
2776
2871
  } else {
2777
2872
  if (this.options.attributesGroupName && key === this.options.attributesGroupName) {
2778
2873
  const Ks = Object.keys(jObj[key]);
@@ -2781,73 +2876,81 @@ Actual: ${this.attribValue}`);
2781
2876
  attrStr += this.buildAttrPairStr(Ks[j], "" + jObj[key][Ks[j]]);
2782
2877
  }
2783
2878
  } else {
2784
- val += this.processTextOrObjNode(jObj[key], key, level);
2879
+ val2 += this.processTextOrObjNode(jObj[key], key, level);
2785
2880
  }
2786
2881
  }
2787
2882
  }
2788
- return { attrStr, val };
2883
+ return { attrStr, val: val2 };
2789
2884
  };
2790
- function buildAttrPairStr(attrName, val) {
2791
- val = this.options.attributeValueProcessor(attrName, "" + val);
2792
- val = this.replaceEntitiesValue(val);
2793
- if (this.options.suppressBooleanAttributes && val === "true") {
2885
+ Builder.prototype.buildAttrPairStr = function(attrName, val2) {
2886
+ val2 = this.options.attributeValueProcessor(attrName, "" + val2);
2887
+ val2 = this.replaceEntitiesValue(val2);
2888
+ if (this.options.suppressBooleanAttributes && val2 === "true") {
2794
2889
  return " " + attrName;
2795
2890
  } else
2796
- return " " + attrName + '="' + val + '"';
2797
- }
2891
+ return " " + attrName + '="' + val2 + '"';
2892
+ };
2798
2893
  function processTextOrObjNode(object, key, level) {
2799
2894
  const result = this.j2x(object, level + 1);
2800
2895
  if (object[this.options.textNodeName] !== void 0 && Object.keys(object).length === 1) {
2801
- return this.buildTextNode(object[this.options.textNodeName], key, result.attrStr, level);
2896
+ return this.buildTextValNode(object[this.options.textNodeName], key, result.attrStr, level);
2802
2897
  } else {
2803
- return this.buildObjNode(result.val, key, result.attrStr, level);
2898
+ return this.buildObjectNode(result.val, key, result.attrStr, level);
2804
2899
  }
2805
2900
  }
2806
- function buildObjectNode(val, key, attrStr, level) {
2807
- let tagEndExp = "</" + key + this.tagEndChar;
2808
- let piClosingChar = "";
2809
- if (key[0] === "?") {
2810
- piClosingChar = "?";
2811
- tagEndExp = "";
2812
- }
2813
- if (attrStr && val.indexOf("<") === -1) {
2814
- return this.indentate(level) + "<" + key + attrStr + piClosingChar + ">" + val + tagEndExp;
2815
- } else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {
2816
- return this.indentate(level) + `<!--${val}-->` + this.newLine;
2901
+ Builder.prototype.buildObjectNode = function(val2, key, attrStr, level) {
2902
+ if (val2 === "") {
2903
+ if (key[0] === "?")
2904
+ return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
2905
+ else {
2906
+ return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
2907
+ }
2817
2908
  } else {
2818
- return this.indentate(level) + "<" + key + attrStr + piClosingChar + this.tagEndChar + val + this.indentate(level) + tagEndExp;
2909
+ let tagEndExp = "</" + key + this.tagEndChar;
2910
+ let piClosingChar = "";
2911
+ if (key[0] === "?") {
2912
+ piClosingChar = "?";
2913
+ tagEndExp = "";
2914
+ }
2915
+ if (attrStr && val2.indexOf("<") === -1) {
2916
+ return this.indentate(level) + "<" + key + attrStr + piClosingChar + ">" + val2 + tagEndExp;
2917
+ } else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {
2918
+ return this.indentate(level) + `<!--${val2}-->` + this.newLine;
2919
+ } else {
2920
+ return this.indentate(level) + "<" + key + attrStr + piClosingChar + this.tagEndChar + val2 + this.indentate(level) + tagEndExp;
2921
+ }
2819
2922
  }
2820
- }
2821
- function buildEmptyObjNode(val, key, attrStr, level) {
2822
- if (val !== "") {
2823
- return this.buildObjectNode(val, key, attrStr, level);
2923
+ };
2924
+ Builder.prototype.closeTag = function(key) {
2925
+ let closeTag = "";
2926
+ if (this.options.unpairedTags.indexOf(key) !== -1) {
2927
+ if (!this.options.suppressUnpairedNode)
2928
+ closeTag = "/";
2929
+ } else if (this.options.suppressEmptyNode) {
2930
+ closeTag = "/";
2824
2931
  } else {
2825
- if (key[0] === "?")
2826
- return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
2827
- else
2828
- return this.indentate(level) + "<" + key + attrStr + "/" + this.tagEndChar;
2932
+ closeTag = `></${key}`;
2829
2933
  }
2830
- }
2831
- function buildTextValNode(val, key, attrStr, level) {
2934
+ return closeTag;
2935
+ };
2936
+ Builder.prototype.buildTextValNode = function(val2, key, attrStr, level) {
2832
2937
  if (this.options.cdataPropName !== false && key === this.options.cdataPropName) {
2833
- return this.indentate(level) + `<![CDATA[${val}]]>` + this.newLine;
2938
+ return this.indentate(level) + `<![CDATA[${val2}]]>` + this.newLine;
2834
2939
  } else if (this.options.commentPropName !== false && key === this.options.commentPropName) {
2835
- return this.indentate(level) + `<!--${val}-->` + this.newLine;
2940
+ return this.indentate(level) + `<!--${val2}-->` + this.newLine;
2941
+ } else if (key[0] === "?") {
2942
+ return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
2836
2943
  } else {
2837
- let textValue = this.options.tagValueProcessor(key, val);
2944
+ let textValue = this.options.tagValueProcessor(key, val2);
2838
2945
  textValue = this.replaceEntitiesValue(textValue);
2839
- if (textValue === "" && this.options.unpairedTags.indexOf(key) !== -1) {
2840
- if (this.options.suppressUnpairedNode) {
2841
- return this.indentate(level) + "<" + key + this.tagEndChar;
2842
- } else {
2843
- return this.indentate(level) + "<" + key + "/" + this.tagEndChar;
2844
- }
2946
+ if (textValue === "") {
2947
+ return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
2845
2948
  } else {
2846
2949
  return this.indentate(level) + "<" + key + attrStr + ">" + textValue + "</" + key + this.tagEndChar;
2847
2950
  }
2848
2951
  }
2849
- }
2850
- function replaceEntitiesValue(textValue) {
2952
+ };
2953
+ Builder.prototype.replaceEntitiesValue = function(textValue) {
2851
2954
  if (textValue && textValue.length > 0 && this.options.processEntities) {
2852
2955
  for (let i = 0; i < this.options.entities.length; i++) {
2853
2956
  const entity = this.options.entities[i];
@@ -2855,23 +2958,7 @@ Actual: ${this.attribValue}`);
2855
2958
  }
2856
2959
  }
2857
2960
  return textValue;
2858
- }
2859
- function buildEmptyTextNode(val, key, attrStr, level) {
2860
- if (val === "" && this.options.unpairedTags.indexOf(key) !== -1) {
2861
- if (this.options.suppressUnpairedNode) {
2862
- return this.indentate(level) + "<" + key + this.tagEndChar;
2863
- } else {
2864
- return this.indentate(level) + "<" + key + "/" + this.tagEndChar;
2865
- }
2866
- } else if (val !== "") {
2867
- return this.buildTextValNode(val, key, attrStr, level);
2868
- } else {
2869
- if (key[0] === "?")
2870
- return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
2871
- else
2872
- return this.indentate(level) + "<" + key + attrStr + "/" + this.tagEndChar;
2873
- }
2874
- }
2961
+ };
2875
2962
  function indentate(level) {
2876
2963
  return this.options.indentBy.repeat(level);
2877
2964
  }
@@ -2901,31 +2988,75 @@ Actual: ${this.attribValue}`);
2901
2988
  }
2902
2989
  });
2903
2990
 
2904
- // src/lib/parse-xml.ts
2905
- function parseXML(text, options) {
2991
+ // src/lib/parsers/parse-xml.ts
2992
+ function fastParseXML(text, options) {
2906
2993
  const parser = new import_fast_xml_parser.XMLParser({
2907
2994
  ignoreAttributes: false,
2908
2995
  attributeNamePrefix: "",
2909
- ...options?.xml
2996
+ ...options
2910
2997
  });
2911
2998
  const parsedXML = parser.parse(text);
2912
2999
  return parsedXML;
2913
3000
  }
2914
3001
  var import_fast_xml_parser;
2915
3002
  var init_parse_xml = __esm({
2916
- "src/lib/parse-xml.ts"() {
3003
+ "src/lib/parsers/parse-xml.ts"() {
2917
3004
  import_fast_xml_parser = __toModule(require_fxp());
2918
3005
  }
2919
3006
  });
2920
3007
 
3008
+ // src/lib/xml-utils/uncapitalize.ts
3009
+ function uncapitalize(str) {
3010
+ return typeof str === "string" ? str.charAt(0).toLowerCase() + str.slice(1) : str;
3011
+ }
3012
+ function uncapitalizeKeys(object) {
3013
+ if (Array.isArray(object)) {
3014
+ return object.map((element) => uncapitalizeKeys(element));
3015
+ }
3016
+ if (object && typeof object === "object") {
3017
+ const newObject = {};
3018
+ for (const [key, value] of Object.entries(object)) {
3019
+ newObject[uncapitalize(key)] = uncapitalizeKeys(value);
3020
+ }
3021
+ return newObject;
3022
+ }
3023
+ return object;
3024
+ }
3025
+ var init_uncapitalize = __esm({
3026
+ "src/lib/xml-utils/uncapitalize.ts"() {
3027
+ }
3028
+ });
3029
+
2921
3030
  // src/xml-loader.ts
2922
3031
  function testXMLFile(text) {
2923
3032
  return text.startsWith("<?xml");
2924
3033
  }
3034
+ function parseTextSync(text, options) {
3035
+ const xmlOptions = { ...XMLLoader.options.xml, ...options?.xml };
3036
+ switch (xmlOptions.parser) {
3037
+ case "fast-xml-parser":
3038
+ const fastXMLOptions = {
3039
+ allowBooleanAttributes: true,
3040
+ ignoreDeclaration: true,
3041
+ removeNSPrefix: xmlOptions.removeNSPrefix,
3042
+ textNodeName: xmlOptions.textNodeName,
3043
+ isArray: (name, jpath, isLeafNode, isAttribute) => {
3044
+ const array = Boolean(xmlOptions?.arrayPaths?.some((path) => jpath === path));
3045
+ return array;
3046
+ },
3047
+ ...options?._fastXML
3048
+ };
3049
+ const xml = fastParseXML(text, fastXMLOptions);
3050
+ return xmlOptions.uncapitalizeKeys ? uncapitalizeKeys(xml) : xml;
3051
+ default:
3052
+ throw new Error(options?.xml?.parser);
3053
+ }
3054
+ }
2925
3055
  var VERSION, XMLLoader;
2926
3056
  var init_xml_loader = __esm({
2927
3057
  "src/xml-loader.ts"() {
2928
3058
  init_parse_xml();
3059
+ init_uncapitalize();
2929
3060
  VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
2930
3061
  XMLLoader = {
2931
3062
  name: "XML",
@@ -2937,31 +3068,123 @@ Actual: ${this.attribValue}`);
2937
3068
  mimeTypes: ["application/xml", "text/xml"],
2938
3069
  testText: testXMLFile,
2939
3070
  options: {
2940
- xml: {}
3071
+ xml: {
3072
+ parser: "fast-xml-parser",
3073
+ uncapitalizeKeys: false,
3074
+ removeNSPrefix: false,
3075
+ textNodeName: "value",
3076
+ arrayPaths: []
3077
+ }
2941
3078
  },
2942
- parse: async (arrayBuffer, options) => parseXML(new TextDecoder().decode(arrayBuffer), options),
2943
- parseTextSync: (text, options) => parseXML(text, options)
3079
+ parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
3080
+ parseTextSync: (text, options) => parseTextSync(text, options)
2944
3081
  };
2945
3082
  }
2946
3083
  });
2947
3084
 
3085
+ // ../loader-utils/src/lib/option-utils/merge-loader-options.ts
3086
+ function mergeLoaderOptions(baseOptions, newOptions) {
3087
+ const options = { ...baseOptions };
3088
+ for (const [key, newValue] of Object.entries(newOptions)) {
3089
+ if (newValue && typeof newValue === "object") {
3090
+ options[key] = options[key] || {};
3091
+ Object.assign(options[key], newOptions[key]);
3092
+ } else {
3093
+ options[key] = newOptions[key];
3094
+ }
3095
+ }
3096
+ return options;
3097
+ }
3098
+ var init_merge_loader_options = __esm({
3099
+ "../loader-utils/src/lib/option-utils/merge-loader-options.ts"() {
3100
+ }
3101
+ });
3102
+
3103
+ // ../loader-utils/src/index.ts
3104
+ var init_src = __esm({
3105
+ "../loader-utils/src/index.ts"() {
3106
+ init_merge_loader_options();
3107
+ }
3108
+ });
3109
+
3110
+ // src/html-loader.ts
3111
+ function testHTMLFile(text) {
3112
+ return text.startsWith("<html");
3113
+ }
3114
+ function parseTextSync2(text, options) {
3115
+ options = mergeLoaderOptions(options, {
3116
+ xml: {
3117
+ parser: "fast-xml-parser"
3118
+ },
3119
+ _fastXML: {
3120
+ htmlEntities: true
3121
+ }
3122
+ });
3123
+ return XMLLoader.parseTextSync(text, options);
3124
+ }
3125
+ var HTMLLoader;
3126
+ var init_html_loader = __esm({
3127
+ "src/html-loader.ts"() {
3128
+ init_src();
3129
+ init_xml_loader();
3130
+ HTMLLoader = {
3131
+ ...XMLLoader,
3132
+ name: "HTML",
3133
+ id: "html",
3134
+ extensions: ["html", "htm"],
3135
+ mimeTypes: ["text/html"],
3136
+ testText: testHTMLFile,
3137
+ parse: async (arrayBuffer, options) => parseTextSync2(new TextDecoder().decode(arrayBuffer), options),
3138
+ parseTextSync: (text, options) => parseTextSync2(text, options)
3139
+ };
3140
+ }
3141
+ });
3142
+
3143
+ // src/lib/xml-utils/xml-utils.ts
3144
+ function convertXMLValueToArray(xmlValue) {
3145
+ if (Array.isArray(xmlValue)) {
3146
+ return xmlValue;
3147
+ }
3148
+ if (xmlValue && typeof xmlValue === "object" && xmlValue["0"]) {
3149
+ }
3150
+ if (xmlValue) {
3151
+ return [xmlValue];
3152
+ }
3153
+ return [];
3154
+ }
3155
+ function convertXMLFieldToArrayInPlace(xml, key) {
3156
+ xml[key] = convertXMLValueToArray(xml[key]);
3157
+ }
3158
+ var init_xml_utils = __esm({
3159
+ "src/lib/xml-utils/xml-utils.ts"() {
3160
+ }
3161
+ });
3162
+
2948
3163
  // src/index.ts
2949
3164
  var src_exports = {};
2950
3165
  __export(src_exports, {
3166
+ HTMLLoader: () => HTMLLoader,
2951
3167
  SAXParser: () => SAXParser,
2952
- XMLLoader: () => XMLLoader
3168
+ XMLLoader: () => XMLLoader,
3169
+ _uncapitalize: () => uncapitalize,
3170
+ _uncapitalizeKeys: () => uncapitalizeKeys,
3171
+ convertXMLFieldToArrayInPlace: () => convertXMLFieldToArrayInPlace,
3172
+ convertXMLValueToArray: () => convertXMLValueToArray
2953
3173
  });
2954
- var init_src = __esm({
3174
+ var init_src2 = __esm({
2955
3175
  "src/index.ts"() {
2956
3176
  init_xml_loader();
3177
+ init_html_loader();
2957
3178
  init_sax();
3179
+ init_xml_utils();
3180
+ init_uncapitalize();
2958
3181
  }
2959
3182
  });
2960
3183
 
2961
3184
  // src/bundle.ts
2962
3185
  var require_bundle = __commonJS({
2963
3186
  "src/bundle.ts"(exports, module) {
2964
- var moduleExports = (init_src(), src_exports);
3187
+ var moduleExports = (init_src2(), src_exports);
2965
3188
  globalThis.loaders = globalThis.loaders || {};
2966
3189
  module.exports = Object.assign(globalThis.loaders, moduleExports);
2967
3190
  }