@loaders.gl/xml 4.2.0-alpha.4 → 4.2.0-alpha.6

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/dist.dev.js CHANGED
@@ -2,8 +2,8 @@
2
2
  if (typeof exports === 'object' && typeof module === 'object')
3
3
  module.exports = factory();
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
- else if (typeof exports === 'object') exports['loader'] = factory();
6
- else root['loader'] = factory();})(globalThis, function () {
5
+ else if (typeof exports === 'object') exports['loaders'] = factory();
6
+ else root['loaders'] = factory();})(globalThis, function () {
7
7
  "use strict";
8
8
  var __exports__ = (() => {
9
9
  var __create = Object.create;
@@ -28,6 +28,7 @@ var __exports__ = (() => {
28
28
  }
29
29
  return to;
30
30
  };
31
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
31
32
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
32
33
  // If the importer is in node compatibility mode or this is not an ESM
33
34
  // file that has been converted to a CommonJS file using a Babel-
@@ -42,6 +43,13 @@ var __exports__ = (() => {
42
43
  return value;
43
44
  };
44
45
 
46
+ // external-global-plugin:@loaders.gl/core
47
+ var require_core = __commonJS({
48
+ "external-global-plugin:@loaders.gl/core"(exports, module) {
49
+ module.exports = globalThis.loaders;
50
+ }
51
+ });
52
+
45
53
  // ../../node_modules/fast-xml-parser/src/util.js
46
54
  var require_util = __commonJS({
47
55
  "../../node_modules/fast-xml-parser/src/util.js"(exports) {
@@ -108,6 +116,7 @@ var __exports__ = (() => {
108
116
  var util = require_util();
109
117
  var defaultOptions = {
110
118
  allowBooleanAttributes: false,
119
+ //A tag can have attributes without any value
111
120
  unpairedTags: []
112
121
  };
113
122
  exports.validate = function(xmlData, options) {
@@ -178,7 +187,11 @@ var __exports__ = (() => {
178
187
  const otg = tags.pop();
179
188
  if (tagName !== otg.tagName) {
180
189
  let openPos = getLineNumberForPosition(xmlData, otg.tagStartPos);
181
- return getErrorObject("InvalidTag", "Expected closing tag '" + otg.tagName + "' (opened in line " + openPos.line + ", col " + openPos.col + ") instead of closing tag '" + tagName + "'.", getLineNumberForPosition(xmlData, tagStartPos));
190
+ return getErrorObject(
191
+ "InvalidTag",
192
+ "Expected closing tag '" + otg.tagName + "' (opened in line " + openPos.line + ", col " + openPos.col + ") instead of closing tag '" + tagName + "'.",
193
+ getLineNumberForPosition(xmlData, tagStartPos)
194
+ );
182
195
  }
183
196
  if (tags.length == 0) {
184
197
  reachedRoot = true;
@@ -193,10 +206,7 @@ var __exports__ = (() => {
193
206
  return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(xmlData, i));
194
207
  } else if (options.unpairedTags.indexOf(tagName) !== -1) {
195
208
  } else {
196
- tags.push({
197
- tagName,
198
- tagStartPos
199
- });
209
+ tags.push({ tagName, tagStartPos });
200
210
  }
201
211
  tagFound = true;
202
212
  }
@@ -240,10 +250,7 @@ var __exports__ = (() => {
240
250
  } else if (tags.length == 1) {
241
251
  return getErrorObject("InvalidTag", "Unclosed tag '" + tags[0].tagName + "'.", getLineNumberForPosition(xmlData, tags[0].tagStartPos));
242
252
  } else if (tags.length > 0) {
243
- return getErrorObject("InvalidXml", "Invalid '" + JSON.stringify(tags.map((t) => t.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", {
244
- line: 1,
245
- col: 1
246
- });
253
+ return getErrorObject("InvalidXml", "Invalid '" + JSON.stringify(tags.map((t) => t.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
247
254
  }
248
255
  return true;
249
256
  };
@@ -404,6 +411,7 @@ var __exports__ = (() => {
404
411
  const lines = xmlData.substring(0, index).split(/\r?\n/);
405
412
  return {
406
413
  line: lines.length,
414
+ // column number is last line's length + 1, because column numbering starts at 1:
407
415
  col: lines[lines.length - 1].length + 1
408
416
  };
409
417
  }
@@ -423,10 +431,14 @@ var __exports__ = (() => {
423
431
  textNodeName: "#text",
424
432
  ignoreAttributes: true,
425
433
  removeNSPrefix: false,
434
+ // remove NS from tag name or attribute name if true
426
435
  allowBooleanAttributes: false,
436
+ //a tag can have attributes without any value
437
+ //ignoreRootElement : false,
427
438
  parseTagValue: true,
428
439
  parseAttributeValue: false,
429
440
  trimValues: true,
441
+ //Trim string values of tag and attributes
430
442
  cdataPropName: false,
431
443
  numberParseOptions: {
432
444
  hex: true,
@@ -440,6 +452,7 @@ var __exports__ = (() => {
440
452
  return val2;
441
453
  },
442
454
  stopNodes: [],
455
+ //nested tags will not be parsed even for errors
443
456
  alwaysCreateTextNode: false,
444
457
  isArray: () => false,
445
458
  commentPropName: false,
@@ -453,6 +466,7 @@ var __exports__ = (() => {
453
466
  updateTag: function(tagName, jPath, attrs) {
454
467
  return tagName;
455
468
  }
469
+ // skipEmptyListItem: false
456
470
  };
457
471
  var buildOptions = function(options) {
458
472
  return Object.assign({}, defaultOptions, options);
@@ -475,22 +489,15 @@ var __exports__ = (() => {
475
489
  add(key, val2) {
476
490
  if (key === "__proto__")
477
491
  key = "#__proto__";
478
- this.child.push({
479
- [key]: val2
480
- });
492
+ this.child.push({ [key]: val2 });
481
493
  }
482
494
  addChild(node) {
483
495
  if (node.tagname === "__proto__")
484
496
  node.tagname = "#__proto__";
485
497
  if (node[":@"] && Object.keys(node[":@"]).length > 0) {
486
- this.child.push({
487
- [node.tagname]: node.child,
488
- [":@"]: node[":@"]
489
- });
498
+ this.child.push({ [node.tagname]: node.child, [":@"]: node[":@"] });
490
499
  } else {
491
- this.child.push({
492
- [node.tagname]: node.child
493
- });
500
+ this.child.push({ [node.tagname]: node.child });
494
501
  }
495
502
  }
496
503
  };
@@ -555,14 +562,11 @@ var __exports__ = (() => {
555
562
  } else {
556
563
  throw new Error(`Invalid Tag instead of DOCTYPE`);
557
564
  }
558
- return {
559
- entities,
560
- i
561
- };
565
+ return { entities, i };
562
566
  }
563
567
  function readEntityExp(xmlData, i) {
564
568
  let entityName2 = "";
565
- for (; i < xmlData.length && xmlData[i] !== "'" && xmlData[i] !== '"'; i++) {
569
+ for (; i < xmlData.length && (xmlData[i] !== "'" && xmlData[i] !== '"'); i++) {
566
570
  entityName2 += xmlData[i];
567
571
  }
568
572
  entityName2 = entityName2.trim();
@@ -723,60 +727,26 @@ var __exports__ = (() => {
723
727
  this.tagsNodeStack = [];
724
728
  this.docTypeEntities = {};
725
729
  this.lastEntities = {
726
- "apos": {
727
- regex: /&(apos|#39|#x27);/g,
728
- val: "'"
729
- },
730
- "gt": {
731
- regex: /&(gt|#62|#x3E);/g,
732
- val: ">"
733
- },
734
- "lt": {
735
- regex: /&(lt|#60|#x3C);/g,
736
- val: "<"
737
- },
738
- "quot": {
739
- regex: /&(quot|#34|#x22);/g,
740
- val: '"'
741
- }
742
- };
743
- this.ampEntity = {
744
- regex: /&(amp|#38|#x26);/g,
745
- val: "&"
730
+ "apos": { regex: /&(apos|#39|#x27);/g, val: "'" },
731
+ "gt": { regex: /&(gt|#62|#x3E);/g, val: ">" },
732
+ "lt": { regex: /&(lt|#60|#x3C);/g, val: "<" },
733
+ "quot": { regex: /&(quot|#34|#x22);/g, val: '"' }
746
734
  };
735
+ this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" };
747
736
  this.htmlEntities = {
748
- "space": {
749
- regex: /&(nbsp|#160);/g,
750
- val: " "
751
- },
752
- "cent": {
753
- regex: /&(cent|#162);/g,
754
- val: "\xA2"
755
- },
756
- "pound": {
757
- regex: /&(pound|#163);/g,
758
- val: "\xA3"
759
- },
760
- "yen": {
761
- regex: /&(yen|#165);/g,
762
- val: "\xA5"
763
- },
764
- "euro": {
765
- regex: /&(euro|#8364);/g,
766
- val: "\u20AC"
767
- },
768
- "copyright": {
769
- regex: /&(copy|#169);/g,
770
- val: "\xA9"
771
- },
772
- "reg": {
773
- regex: /&(reg|#174);/g,
774
- val: "\xAE"
775
- },
776
- "inr": {
777
- regex: /&(inr|#8377);/g,
778
- val: "\u20B9"
779
- }
737
+ "space": { regex: /&(nbsp|#160);/g, val: " " },
738
+ // "lt" : { regex: /&(lt|#60);/g, val: "<" },
739
+ // "gt" : { regex: /&(gt|#62);/g, val: ">" },
740
+ // "amp" : { regex: /&(amp|#38);/g, val: "&" },
741
+ // "quot" : { regex: /&(quot|#34);/g, val: "\"" },
742
+ // "apos" : { regex: /&(apos|#39);/g, val: "'" },
743
+ "cent": { regex: /&(cent|#162);/g, val: "\xA2" },
744
+ "pound": { regex: /&(pound|#163);/g, val: "\xA3" },
745
+ "yen": { regex: /&(yen|#165);/g, val: "\xA5" },
746
+ "euro": { regex: /&(euro|#8364);/g, val: "\u20AC" },
747
+ "copyright": { regex: /&(copy|#169);/g, val: "\xA9" },
748
+ "reg": { regex: /&(reg|#174);/g, val: "\xAE" },
749
+ "inr": { regex: /&(inr|#8377);/g, val: "\u20B9" }
780
750
  };
781
751
  this.addExternalEntities = addExternalEntities;
782
752
  this.parseXml = parseXml;
@@ -866,7 +836,11 @@ var __exports__ = (() => {
866
836
  } else if (typeof newVal !== typeof oldVal || newVal !== oldVal) {
867
837
  attrs[aName] = newVal;
868
838
  } else {
869
- attrs[aName] = parseValue(oldVal, this.options.parseAttributeValue, this.options.numberParseOptions);
839
+ attrs[aName] = parseValue(
840
+ oldVal,
841
+ this.options.parseAttributeValue,
842
+ this.options.numberParseOptions
843
+ );
870
844
  }
871
845
  } else if (this.options.allowBooleanAttributes) {
872
846
  attrs[aName] = true;
@@ -943,9 +917,7 @@ var __exports__ = (() => {
943
917
  if (this.options.commentPropName) {
944
918
  const comment = xmlData.substring(i + 4, endIndex - 2);
945
919
  textData = this.saveTextToParentTag(textData, currentNode, jPath);
946
- currentNode.add(this.options.commentPropName, [{
947
- [this.options.textNodeName]: comment
948
- }]);
920
+ currentNode.add(this.options.commentPropName, [{ [this.options.textNodeName]: comment }]);
949
921
  }
950
922
  i = endIndex;
951
923
  } else if (xmlData.substr(i + 1, 2) === "!D") {
@@ -957,9 +929,7 @@ var __exports__ = (() => {
957
929
  const tagExp = xmlData.substring(i + 9, closeIndex);
958
930
  textData = this.saveTextToParentTag(textData, currentNode, jPath);
959
931
  if (this.options.cdataPropName) {
960
- currentNode.add(this.options.cdataPropName, [{
961
- [this.options.textNodeName]: tagExp
962
- }]);
932
+ currentNode.add(this.options.cdataPropName, [{ [this.options.textNodeName]: tagExp }]);
963
933
  } else {
964
934
  let val2 = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true);
965
935
  if (val2 == void 0)
@@ -1082,7 +1052,14 @@ var __exports__ = (() => {
1082
1052
  if (textData) {
1083
1053
  if (isLeafNode === void 0)
1084
1054
  isLeafNode = Object.keys(currentNode.child).length === 0;
1085
- textData = this.parseTextData(textData, currentNode.tagname, jPath, false, currentNode[":@"] ? Object.keys(currentNode[":@"]).length !== 0 : false, isLeafNode);
1055
+ textData = this.parseTextData(
1056
+ textData,
1057
+ currentNode.tagname,
1058
+ jPath,
1059
+ false,
1060
+ currentNode[":@"] ? Object.keys(currentNode[":@"]).length !== 0 : false,
1061
+ isLeafNode
1062
+ );
1086
1063
  if (textData !== void 0 && textData !== "")
1087
1064
  currentNode.add(this.options.textNodeName, textData);
1088
1065
  textData = "";
@@ -1306,9 +1283,7 @@ var __exports__ = (() => {
1306
1283
  }
1307
1284
  }
1308
1285
  function isLeafTag(obj, options) {
1309
- const {
1310
- textNodeName
1311
- } = options;
1286
+ const { textNodeName } = options;
1312
1287
  const propCount = Object.keys(obj).length;
1313
1288
  if (propCount === 0) {
1314
1289
  return true;
@@ -1325,19 +1300,20 @@ var __exports__ = (() => {
1325
1300
  // ../../node_modules/fast-xml-parser/src/xmlparser/XMLParser.js
1326
1301
  var require_XMLParser = __commonJS({
1327
1302
  "../../node_modules/fast-xml-parser/src/xmlparser/XMLParser.js"(exports, module) {
1328
- var {
1329
- buildOptions
1330
- } = require_OptionsBuilder();
1303
+ var { buildOptions } = require_OptionsBuilder();
1331
1304
  var OrderedObjParser = require_OrderedObjParser();
1332
- var {
1333
- prettify
1334
- } = require_node2json();
1305
+ var { prettify } = require_node2json();
1335
1306
  var validator = require_validator();
1336
1307
  var XMLParser = class {
1337
1308
  constructor(options) {
1338
1309
  this.externalEntities = {};
1339
1310
  this.options = buildOptions(options);
1340
1311
  }
1312
+ /**
1313
+ * Parse XML dats to JS object
1314
+ * @param {string|Buffer} xmlData
1315
+ * @param {boolean|Object} validationOption
1316
+ */
1341
1317
  parse(xmlData, validationOption) {
1342
1318
  if (typeof xmlData === "string") {
1343
1319
  } else if (xmlData.toString) {
@@ -1361,6 +1337,11 @@ var __exports__ = (() => {
1361
1337
  else
1362
1338
  return prettify(orderedResult, this.options);
1363
1339
  }
1340
+ /**
1341
+ * Add Entity which is not by default supported by this library
1342
+ * @param {string} key
1343
+ * @param {string} value
1344
+ */
1364
1345
  addEntity(key, value) {
1365
1346
  if (value.indexOf("&") !== -1) {
1366
1347
  throw new Error("Entity value can't have '&'");
@@ -1530,24 +1511,18 @@ var __exports__ = (() => {
1530
1511
  preserveOrder: false,
1531
1512
  commentPropName: false,
1532
1513
  unpairedTags: [],
1533
- entities: [{
1534
- regex: new RegExp("&", "g"),
1535
- val: "&amp;"
1536
- }, {
1537
- regex: new RegExp(">", "g"),
1538
- val: "&gt;"
1539
- }, {
1540
- regex: new RegExp("<", "g"),
1541
- val: "&lt;"
1542
- }, {
1543
- regex: new RegExp("'", "g"),
1544
- val: "&apos;"
1545
- }, {
1546
- regex: new RegExp('"', "g"),
1547
- val: "&quot;"
1548
- }],
1514
+ entities: [
1515
+ { regex: new RegExp("&", "g"), val: "&amp;" },
1516
+ //it must be on top
1517
+ { regex: new RegExp(">", "g"), val: "&gt;" },
1518
+ { regex: new RegExp("<", "g"), val: "&lt;" },
1519
+ { regex: new RegExp("'", "g"), val: "&apos;" },
1520
+ { regex: new RegExp('"', "g"), val: "&quot;" }
1521
+ ],
1549
1522
  processEntities: true,
1550
1523
  stopNodes: [],
1524
+ // transformTagName: false,
1525
+ // transformAttributeName: false,
1551
1526
  oneListGroup: false
1552
1527
  };
1553
1528
  function Builder(options) {
@@ -1646,10 +1621,7 @@ var __exports__ = (() => {
1646
1621
  }
1647
1622
  }
1648
1623
  }
1649
- return {
1650
- attrStr,
1651
- val: val2
1652
- };
1624
+ return { attrStr, val: val2 };
1653
1625
  };
1654
1626
  Builder.prototype.buildAttrPairStr = function(attrName, val2) {
1655
1627
  val2 = this.options.attributeValueProcessor(attrName, "" + val2);
@@ -1757,9 +1729,9 @@ var __exports__ = (() => {
1757
1729
  }
1758
1730
  });
1759
1731
 
1760
- // src/index.ts
1761
- var src_exports = {};
1762
- __export(src_exports, {
1732
+ // bundle.ts
1733
+ var bundle_exports = {};
1734
+ __export(bundle_exports, {
1763
1735
  HTMLLoader: () => HTMLLoader,
1764
1736
  SAXParser: () => SAXParser,
1765
1737
  XMLLoader: () => XMLLoader,
@@ -1768,6 +1740,7 @@ var __exports__ = (() => {
1768
1740
  convertXMLFieldToArrayInPlace: () => convertXMLFieldToArrayInPlace,
1769
1741
  convertXMLValueToArray: () => convertXMLValueToArray
1770
1742
  });
1743
+ __reExport(bundle_exports, __toESM(require_core(), 1));
1771
1744
 
1772
1745
  // src/sax-ts/sax.ts
1773
1746
  var DEFAULT_SAX_EVENTS = {
@@ -1821,8 +1794,40 @@ var __exports__ = (() => {
1821
1794
  trim: void 0,
1822
1795
  normalize: void 0
1823
1796
  };
1824
- var EVENTS = ["text", "processinginstruction", "sgmldeclaration", "doctype", "comment", "opentagstart", "attribute", "opentag", "closetag", "opencdata", "cdata", "closecdata", "error", "end", "ready", "script", "opennamespace", "closenamespace"];
1825
- var BUFFERS = ["comment", "sgmlDecl", "textNode", "tagName", "doctype", "procInstName", "procInstBody", "entity", "attribName", "attribValue", "cdata", "script"];
1797
+ var EVENTS = [
1798
+ "text",
1799
+ "processinginstruction",
1800
+ "sgmldeclaration",
1801
+ "doctype",
1802
+ "comment",
1803
+ "opentagstart",
1804
+ "attribute",
1805
+ "opentag",
1806
+ "closetag",
1807
+ "opencdata",
1808
+ "cdata",
1809
+ "closecdata",
1810
+ "error",
1811
+ "end",
1812
+ "ready",
1813
+ "script",
1814
+ "opennamespace",
1815
+ "closenamespace"
1816
+ ];
1817
+ var BUFFERS = [
1818
+ "comment",
1819
+ "sgmlDecl",
1820
+ "textNode",
1821
+ "tagName",
1822
+ "doctype",
1823
+ "procInstName",
1824
+ "procInstBody",
1825
+ "entity",
1826
+ "attribName",
1827
+ "attribValue",
1828
+ "cdata",
1829
+ "script"
1830
+ ];
1826
1831
  var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
1827
1832
  var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
1828
1833
  var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
@@ -2089,6 +2094,9 @@ var __exports__ = (() => {
2089
2094
  var SAX = class {
2090
2095
  EVENTS = EVENTS;
2091
2096
  ENTITIES = {
2097
+ // TODO: make it readonly, needed for entity-mega test
2098
+ // amp, gt, lt, quot and apos are resolved to strings instead of numerical
2099
+ // codes, IDK why
2092
2100
  ...ENTITIES
2093
2101
  };
2094
2102
  XML_ENTITIES = {
@@ -2099,59 +2107,103 @@ var __exports__ = (() => {
2099
2107
  apos: "'"
2100
2108
  };
2101
2109
  S = 0;
2110
+ opt;
2102
2111
  trackPosition = false;
2103
2112
  column = 0;
2104
2113
  line = 0;
2105
2114
  c = "";
2115
+ error;
2106
2116
  q = "";
2117
+ bufferCheckPosition;
2107
2118
  closed = false;
2108
2119
  tags = [];
2109
2120
  looseCase = "";
2110
2121
  closedRoot = false;
2111
2122
  sawRoot = false;
2112
2123
  strict = false;
2124
+ tag;
2125
+ strictEntities;
2126
+ state;
2113
2127
  noscript = false;
2114
2128
  attribList = [];
2129
+ ns;
2115
2130
  position = 0;
2116
2131
  STATE = {
2117
2132
  BEGIN: this.S++,
2133
+ // leading byte order mark or whitespace
2118
2134
  BEGIN_WHITESPACE: this.S++,
2135
+ // leading whitespace
2119
2136
  TEXT: this.S++,
2137
+ // general stuff
2120
2138
  TEXT_ENTITY: this.S++,
2139
+ // &amp and such.
2121
2140
  OPEN_WAKA: this.S++,
2141
+ // <
2122
2142
  SGML_DECL: this.S++,
2143
+ // <!BLARG
2123
2144
  SGML_DECL_QUOTED: this.S++,
2145
+ // <!BLARG foo "bar
2124
2146
  DOCTYPE: this.S++,
2147
+ // <!DOCTYPE
2125
2148
  DOCTYPE_QUOTED: this.S++,
2149
+ // <!DOCTYPE "//blah
2126
2150
  DOCTYPE_DTD: this.S++,
2151
+ // <!DOCTYPE "//blah" [ ...
2127
2152
  DOCTYPE_DTD_QUOTED: this.S++,
2153
+ // <!DOCTYPE "//blah" [ "foo
2128
2154
  COMMENT_STARTING: this.S++,
2155
+ // <!-
2129
2156
  COMMENT: this.S++,
2157
+ // <!--
2130
2158
  COMMENT_ENDING: this.S++,
2159
+ // <!-- blah -
2131
2160
  COMMENT_ENDED: this.S++,
2161
+ // <!-- blah --
2132
2162
  CDATA: this.S++,
2163
+ // <![CDATA[ something
2133
2164
  CDATA_ENDING: this.S++,
2165
+ // ]
2134
2166
  CDATA_ENDING_2: this.S++,
2167
+ // ]]
2135
2168
  PROC_INST: this.S++,
2169
+ // <?hi
2136
2170
  PROC_INST_BODY: this.S++,
2171
+ // <?hi there
2137
2172
  PROC_INST_ENDING: this.S++,
2173
+ // <?hi "there" ?
2138
2174
  OPEN_TAG: this.S++,
2175
+ // <strong
2139
2176
  OPEN_TAG_SLASH: this.S++,
2177
+ // <strong /
2140
2178
  ATTRIB: this.S++,
2179
+ // <a
2141
2180
  ATTRIB_NAME: this.S++,
2181
+ // <a foo
2142
2182
  ATTRIB_NAME_SAW_WHITE: this.S++,
2183
+ // <a foo _
2143
2184
  ATTRIB_VALUE: this.S++,
2185
+ // <a foo=
2144
2186
  ATTRIB_VALUE_QUOTED: this.S++,
2187
+ // <a foo="bar
2145
2188
  ATTRIB_VALUE_CLOSED: this.S++,
2189
+ // <a foo="bar"
2146
2190
  ATTRIB_VALUE_UNQUOTED: this.S++,
2191
+ // <a foo=bar
2147
2192
  ATTRIB_VALUE_ENTITY_Q: this.S++,
2193
+ // <foo bar="&quot;"
2148
2194
  ATTRIB_VALUE_ENTITY_U: this.S++,
2195
+ // <foo bar=&quot
2149
2196
  CLOSE_TAG: this.S++,
2197
+ // </a
2150
2198
  CLOSE_TAG_SAW_WHITE: this.S++,
2199
+ // </a >
2151
2200
  SCRIPT: this.S++,
2201
+ // <script> ...
2152
2202
  SCRIPT_ENDING: this.S++
2203
+ // <script> ... <
2153
2204
  };
2154
2205
  BUFFERS = BUFFERS;
2206
+ // private parser: (strict: boolean, opt: any) => SAXParser;
2155
2207
  CDATA = "[CDATA[";
2156
2208
  DOCTYPE = "DOCTYPE";
2157
2209
  XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
@@ -2160,8 +2212,16 @@ var __exports__ = (() => {
2160
2212
  xml: this.XML_NAMESPACE,
2161
2213
  xmlns: this.XMLNS_NAMESPACE
2162
2214
  };
2215
+ comment;
2216
+ sgmlDecl;
2163
2217
  textNode = "";
2218
+ tagName;
2219
+ doctype;
2220
+ procInstName;
2221
+ procInstBody;
2164
2222
  entity = "";
2223
+ attribName;
2224
+ attribValue;
2165
2225
  cdata = "";
2166
2226
  script = "";
2167
2227
  startTagPosition = 0;
@@ -2205,10 +2265,7 @@ var __exports__ = (() => {
2205
2265
  prefix = "xmlns";
2206
2266
  local = "";
2207
2267
  }
2208
- return {
2209
- prefix,
2210
- local
2211
- };
2268
+ return { prefix, local };
2212
2269
  }
2213
2270
  write(chunk) {
2214
2271
  if (this.error) {
@@ -2766,11 +2823,15 @@ Char: ${this.c}`;
2766
2823
  const local = qn.local;
2767
2824
  if (prefix === "xmlns") {
2768
2825
  if (local === "xml" && this.attribValue !== this.XML_NAMESPACE) {
2769
- this.strictFail(`xml: prefix must be bound to ${this.XML_NAMESPACE}
2770
- Actual: ${this.attribValue}`);
2826
+ this.strictFail(
2827
+ `xml: prefix must be bound to ${this.XML_NAMESPACE}
2828
+ Actual: ${this.attribValue}`
2829
+ );
2771
2830
  } else if (local === "xmlns" && this.attribValue !== this.XMLNS_NAMESPACE) {
2772
- this.strictFail(`xmlns: prefix must be bound to ${this.XMLNS_NAMESPACE}
2773
- Actual: ${this.attribValue}`);
2831
+ this.strictFail(
2832
+ `xmlns: prefix must be bound to ${this.XMLNS_NAMESPACE}
2833
+ Actual: ${this.attribValue}`
2834
+ );
2774
2835
  } else {
2775
2836
  const tag = this.tag;
2776
2837
  const parent = this.tags[this.tags.length - 1] || this;
@@ -2794,10 +2855,7 @@ Actual: ${this.attribValue}`);
2794
2855
  if (!this.strict)
2795
2856
  this.tagName = this.tagName[this.looseCase]();
2796
2857
  const parent = this.tags[this.tags.length - 1] || this;
2797
- const tag = this.tag = {
2798
- name: this.tagName,
2799
- attributes: {}
2800
- };
2858
+ const tag = this.tag = { name: this.tagName, attributes: {} };
2801
2859
  if (this.opt.xmlns) {
2802
2860
  tag.ns = parent.ns;
2803
2861
  }
@@ -3013,10 +3071,7 @@ Actual: ${this.attribValue}`);
3013
3071
  const that = this;
3014
3072
  Object.keys(tag.ns).forEach((p) => {
3015
3073
  const n = tag.ns[p];
3016
- that.emitNode("onclosenamespace", {
3017
- prefix: p,
3018
- uri: n
3019
- });
3074
+ that.emitNode("onclosenamespace", { prefix: p, uri: n });
3020
3075
  });
3021
3076
  }
3022
3077
  }
@@ -3033,14 +3088,8 @@ Actual: ${this.attribValue}`);
3033
3088
  constructor(opt) {
3034
3089
  super();
3035
3090
  this.clearBuffers();
3036
- this.opt = opt = {
3037
- ...this.opt,
3038
- ...opt
3039
- };
3040
- this.events = {
3041
- ...this.events,
3042
- ...opt
3043
- };
3091
+ this.opt = opt = { ...this.opt, ...opt };
3092
+ this.events = { ...this.events, ...opt };
3044
3093
  this.q = this.c = "";
3045
3094
  this.opt.lowercase = this.opt.lowercase || this.opt.lowercasetags;
3046
3095
  this.bufferCheckPosition = this.opt.MAX_BUFFER_LENGTH;
@@ -3101,14 +3150,21 @@ Actual: ${this.attribValue}`);
3101
3150
  throw new Error(options?._parser);
3102
3151
  }
3103
3152
  const fastXMLOptions = {
3153
+ // Default FastXML options
3154
+ // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#allowbooleanattributes
3104
3155
  allowBooleanAttributes: true,
3156
+ // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#ignoredeclaration
3105
3157
  ignoreDeclaration: true,
3158
+ // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#removensprefix
3106
3159
  removeNSPrefix: options?.removeNSPrefix,
3160
+ // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#textnodename
3107
3161
  textNodeName: options?.textNodeName,
3162
+ // Let's application specify keys that are always arrays
3108
3163
  isArray: (name, jpath, isLeafNode, isAttribute) => {
3109
3164
  const array = Boolean(options?.arrayPaths?.some((path) => jpath === path));
3110
3165
  return array;
3111
3166
  },
3167
+ // Application overrides
3112
3168
  ...options?._fastXML
3113
3169
  };
3114
3170
  const xml = fastParseXML(text, fastXMLOptions);
@@ -3125,7 +3181,7 @@ Actual: ${this.attribValue}`);
3125
3181
  }
3126
3182
 
3127
3183
  // src/xml-loader.ts
3128
- var VERSION = true ? "4.2.0-alpha.4" : "latest";
3184
+ var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3129
3185
  var XMLLoader = {
3130
3186
  name: "XML",
3131
3187
  id: "xml",
@@ -3148,10 +3204,7 @@ Actual: ${this.attribValue}`);
3148
3204
  ...XMLLoader.options.xml,
3149
3205
  ...options?.xml
3150
3206
  }),
3151
- parseTextSync: (text, options) => parseXMLSync(text, {
3152
- ...XMLLoader.options.xml,
3153
- ...options?.xml
3154
- })
3207
+ parseTextSync: (text, options) => parseXMLSync(text, { ...XMLLoader.options.xml, ...options?.xml })
3155
3208
  };
3156
3209
  function testXMLFile(text) {
3157
3210
  return text.startsWith("<?xml");
@@ -3165,12 +3218,14 @@ Actual: ${this.attribValue}`);
3165
3218
  if (level > 3) {
3166
3219
  return newOptions;
3167
3220
  }
3168
- const options = {
3169
- ...baseOptions
3170
- };
3221
+ const options = { ...baseOptions };
3171
3222
  for (const [key, newValue] of Object.entries(newOptions)) {
3172
3223
  if (newValue && typeof newValue === "object" && !Array.isArray(newValue)) {
3173
- options[key] = mergeOptionsRecursively(options[key] || {}, newOptions[key], level + 1);
3224
+ options[key] = mergeOptionsRecursively(
3225
+ options[key] || {},
3226
+ newOptions[key],
3227
+ level + 1
3228
+ );
3174
3229
  } else {
3175
3230
  options[key] = newOptions[key];
3176
3231
  }
@@ -3219,7 +3274,7 @@ Actual: ${this.attribValue}`);
3219
3274
  function convertXMLFieldToArrayInPlace(xml, key) {
3220
3275
  xml[key] = convertXMLValueToArray(xml[key]);
3221
3276
  }
3222
- return __toCommonJS(src_exports);
3277
+ return __toCommonJS(bundle_exports);
3223
3278
  })();
3224
3279
  return __exports__;
3225
3280
  });