@nextcloud/files 3.10.0 → 3.10.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 (41) hide show
  1. package/dist/chunks/{dav-DxfiR0wZ.mjs → dav-Co9y-hkg.mjs} +15 -9
  2. package/dist/chunks/dav-Co9y-hkg.mjs.map +1 -0
  3. package/dist/chunks/{dav-BBwoJ8WE.cjs → dav-CtqjqS4O.cjs} +15 -9
  4. package/dist/chunks/dav-CtqjqS4O.cjs.map +1 -0
  5. package/dist/dav/dav.d.ts +55 -0
  6. package/dist/dav/davPermissions.d.ts +6 -0
  7. package/dist/dav/davProperties.d.ts +57 -0
  8. package/dist/dav/index.d.ts +13 -0
  9. package/dist/dav.cjs +1 -1
  10. package/dist/dav.mjs +1 -1
  11. package/dist/fileAction.d.ts +83 -0
  12. package/dist/fileListAction.d.ts +41 -0
  13. package/dist/fileListFilters.d.ts +100 -0
  14. package/dist/fileListHeaders.d.ts +26 -0
  15. package/dist/files/file.d.ts +13 -0
  16. package/dist/files/fileType.d.ts +8 -0
  17. package/dist/files/folder.d.ts +17 -0
  18. package/dist/files/node.d.ts +177 -0
  19. package/dist/files/nodeData.d.ts +53 -0
  20. package/dist/index.cjs +1956 -1805
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.ts +118 -1099
  23. package/dist/index.mjs +1957 -1806
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/navigation/column.d.ts +27 -0
  26. package/dist/navigation/index.d.ts +7 -0
  27. package/dist/navigation/navigation.d.ts +73 -0
  28. package/dist/navigation/view.d.ts +91 -0
  29. package/dist/newFileMenu.d.ts +65 -0
  30. package/dist/permissions.d.ts +16 -0
  31. package/dist/utils/fileSize.d.ts +25 -0
  32. package/dist/utils/fileSorting.d.ts +34 -0
  33. package/dist/utils/filename-validation.d.ts +51 -0
  34. package/dist/utils/filename.d.ts +24 -0
  35. package/dist/utils/logger.d.ts +2 -0
  36. package/dist/utils/sorting.d.ts +12 -0
  37. package/dist/vendor.LICENSE.txt +1 -1
  38. package/package.json +14 -14
  39. package/dist/chunks/dav-BBwoJ8WE.cjs.map +0 -1
  40. package/dist/chunks/dav-DxfiR0wZ.mjs.map +0 -1
  41. package/dist/dav.d.ts +0 -370
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const dav = require("./chunks/dav-BBwoJ8WE.cjs");
3
+ const dav = require("./chunks/dav-CtqjqS4O.cjs");
4
4
  const capabilities = require("@nextcloud/capabilities");
5
5
  const path = require("path");
6
6
  const l10n = require("@nextcloud/l10n");
@@ -212,7 +212,7 @@ class FileListAction {
212
212
  if (!action.displayName || typeof action.displayName !== "function") {
213
213
  throw new Error("Invalid displayName function");
214
214
  }
215
- if (!action.iconSvgInline || typeof action.iconSvgInline !== "function") {
215
+ if ("iconSvgInline" in action && typeof action.iconSvgInline !== "function") {
216
216
  throw new Error("Invalid iconSvgInline function");
217
217
  }
218
218
  if ("order" in action && typeof action.order !== "number") {
@@ -604,1604 +604,1688 @@ const isValidColumn = function(column) {
604
604
  function getDefaultExportFromCjs(x) {
605
605
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
606
606
  }
607
- var validator$2 = {};
608
- var util$3 = {};
609
- (function(exports2) {
610
- const nameStartChar = ":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";
611
- const nameChar = nameStartChar + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
612
- const nameRegexp = "[" + nameStartChar + "][" + nameChar + "]*";
613
- const regexName = new RegExp("^" + nameRegexp + "$");
614
- const getAllMatches = function(string, regex) {
615
- const matches = [];
616
- let match = regex.exec(string);
617
- while (match) {
618
- const allmatches = [];
619
- allmatches.startIndex = regex.lastIndex - match[0].length;
620
- const len = match.length;
621
- for (let index = 0; index < len; index++) {
622
- allmatches.push(match[index]);
623
- }
624
- matches.push(allmatches);
625
- match = regex.exec(string);
626
- }
627
- return matches;
628
- };
629
- const isName = function(string) {
630
- const match = regexName.exec(string);
631
- return !(match === null || typeof match === "undefined");
632
- };
633
- exports2.isExist = function(v) {
634
- return typeof v !== "undefined";
635
- };
636
- exports2.isEmptyObject = function(obj) {
637
- return Object.keys(obj).length === 0;
638
- };
639
- exports2.merge = function(target, a, arrayMode) {
640
- if (a) {
641
- const keys = Object.keys(a);
642
- const len = keys.length;
643
- for (let i = 0; i < len; i++) {
644
- if (arrayMode === "strict") {
645
- target[keys[i]] = [a[keys[i]]];
646
- } else {
647
- target[keys[i]] = a[keys[i]];
607
+ var validator = {};
608
+ var util = {};
609
+ var hasRequiredUtil;
610
+ function requireUtil() {
611
+ if (hasRequiredUtil) return util;
612
+ hasRequiredUtil = 1;
613
+ (function(exports2) {
614
+ const nameStartChar = ":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";
615
+ const nameChar = nameStartChar + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
616
+ const nameRegexp = "[" + nameStartChar + "][" + nameChar + "]*";
617
+ const regexName = new RegExp("^" + nameRegexp + "$");
618
+ const getAllMatches = function(string, regex) {
619
+ const matches = [];
620
+ let match = regex.exec(string);
621
+ while (match) {
622
+ const allmatches = [];
623
+ allmatches.startIndex = regex.lastIndex - match[0].length;
624
+ const len = match.length;
625
+ for (let index = 0; index < len; index++) {
626
+ allmatches.push(match[index]);
648
627
  }
628
+ matches.push(allmatches);
629
+ match = regex.exec(string);
649
630
  }
650
- }
651
- };
652
- exports2.getValue = function(v) {
653
- if (exports2.isExist(v)) {
654
- return v;
655
- } else {
656
- return "";
657
- }
658
- };
659
- exports2.isName = isName;
660
- exports2.getAllMatches = getAllMatches;
661
- exports2.nameRegexp = nameRegexp;
662
- })(util$3);
663
- const util$2 = util$3;
664
- const defaultOptions$2 = {
665
- allowBooleanAttributes: false,
666
- //A tag can have attributes without any value
667
- unpairedTags: []
668
- };
669
- validator$2.validate = function(xmlData, options) {
670
- options = Object.assign({}, defaultOptions$2, options);
671
- const tags = [];
672
- let tagFound = false;
673
- let reachedRoot = false;
674
- if (xmlData[0] === "\uFEFF") {
675
- xmlData = xmlData.substr(1);
676
- }
677
- for (let i = 0; i < xmlData.length; i++) {
678
- if (xmlData[i] === "<" && xmlData[i + 1] === "?") {
679
- i += 2;
680
- i = readPI(xmlData, i);
681
- if (i.err) return i;
682
- } else if (xmlData[i] === "<") {
683
- let tagStartPos = i;
684
- i++;
685
- if (xmlData[i] === "!") {
686
- i = readCommentAndCDATA(xmlData, i);
687
- continue;
688
- } else {
689
- let closingTag = false;
690
- if (xmlData[i] === "/") {
691
- closingTag = true;
692
- i++;
693
- }
694
- let tagName = "";
695
- for (; i < xmlData.length && xmlData[i] !== ">" && xmlData[i] !== " " && xmlData[i] !== " " && xmlData[i] !== "\n" && xmlData[i] !== "\r"; i++) {
696
- tagName += xmlData[i];
697
- }
698
- tagName = tagName.trim();
699
- if (tagName[tagName.length - 1] === "/") {
700
- tagName = tagName.substring(0, tagName.length - 1);
701
- i--;
702
- }
703
- if (!validateTagName(tagName)) {
704
- let msg;
705
- if (tagName.trim().length === 0) {
706
- msg = "Invalid space after '<'.";
631
+ return matches;
632
+ };
633
+ const isName = function(string) {
634
+ const match = regexName.exec(string);
635
+ return !(match === null || typeof match === "undefined");
636
+ };
637
+ exports2.isExist = function(v) {
638
+ return typeof v !== "undefined";
639
+ };
640
+ exports2.isEmptyObject = function(obj) {
641
+ return Object.keys(obj).length === 0;
642
+ };
643
+ exports2.merge = function(target, a, arrayMode) {
644
+ if (a) {
645
+ const keys = Object.keys(a);
646
+ const len = keys.length;
647
+ for (let i = 0; i < len; i++) {
648
+ if (arrayMode === "strict") {
649
+ target[keys[i]] = [a[keys[i]]];
707
650
  } else {
708
- msg = "Tag '" + tagName + "' is an invalid name.";
651
+ target[keys[i]] = a[keys[i]];
709
652
  }
710
- return getErrorObject("InvalidTag", msg, getLineNumberForPosition(xmlData, i));
711
- }
712
- const result = readAttributeStr(xmlData, i);
713
- if (result === false) {
714
- return getErrorObject("InvalidAttr", "Attributes for '" + tagName + "' have open quote.", getLineNumberForPosition(xmlData, i));
715
653
  }
716
- let attrStr = result.value;
717
- i = result.index;
718
- if (attrStr[attrStr.length - 1] === "/") {
719
- const attrStrStart = i - attrStr.length;
720
- attrStr = attrStr.substring(0, attrStr.length - 1);
721
- const isValid = validateAttributeString(attrStr, options);
722
- if (isValid === true) {
723
- tagFound = true;
724
- } else {
725
- return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid.err.line));
654
+ }
655
+ };
656
+ exports2.getValue = function(v) {
657
+ if (exports2.isExist(v)) {
658
+ return v;
659
+ } else {
660
+ return "";
661
+ }
662
+ };
663
+ exports2.isName = isName;
664
+ exports2.getAllMatches = getAllMatches;
665
+ exports2.nameRegexp = nameRegexp;
666
+ })(util);
667
+ return util;
668
+ }
669
+ var hasRequiredValidator;
670
+ function requireValidator() {
671
+ if (hasRequiredValidator) return validator;
672
+ hasRequiredValidator = 1;
673
+ const util2 = requireUtil();
674
+ const defaultOptions = {
675
+ allowBooleanAttributes: false,
676
+ //A tag can have attributes without any value
677
+ unpairedTags: []
678
+ };
679
+ validator.validate = function(xmlData, options) {
680
+ options = Object.assign({}, defaultOptions, options);
681
+ const tags = [];
682
+ let tagFound = false;
683
+ let reachedRoot = false;
684
+ if (xmlData[0] === "\uFEFF") {
685
+ xmlData = xmlData.substr(1);
686
+ }
687
+ for (let i = 0; i < xmlData.length; i++) {
688
+ if (xmlData[i] === "<" && xmlData[i + 1] === "?") {
689
+ i += 2;
690
+ i = readPI(xmlData, i);
691
+ if (i.err) return i;
692
+ } else if (xmlData[i] === "<") {
693
+ let tagStartPos = i;
694
+ i++;
695
+ if (xmlData[i] === "!") {
696
+ i = readCommentAndCDATA(xmlData, i);
697
+ continue;
698
+ } else {
699
+ let closingTag = false;
700
+ if (xmlData[i] === "/") {
701
+ closingTag = true;
702
+ i++;
726
703
  }
727
- } else if (closingTag) {
728
- if (!result.tagClosed) {
729
- return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' doesn't have proper closing.", getLineNumberForPosition(xmlData, i));
730
- } else if (attrStr.trim().length > 0) {
731
- return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' can't have attributes or invalid starting.", getLineNumberForPosition(xmlData, tagStartPos));
732
- } else if (tags.length === 0) {
733
- return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' has not been opened.", getLineNumberForPosition(xmlData, tagStartPos));
734
- } else {
735
- const otg = tags.pop();
736
- if (tagName !== otg.tagName) {
737
- let openPos = getLineNumberForPosition(xmlData, otg.tagStartPos);
738
- return getErrorObject(
739
- "InvalidTag",
740
- "Expected closing tag '" + otg.tagName + "' (opened in line " + openPos.line + ", col " + openPos.col + ") instead of closing tag '" + tagName + "'.",
741
- getLineNumberForPosition(xmlData, tagStartPos)
742
- );
743
- }
744
- if (tags.length == 0) {
745
- reachedRoot = true;
746
- }
704
+ let tagName = "";
705
+ for (; i < xmlData.length && xmlData[i] !== ">" && xmlData[i] !== " " && xmlData[i] !== " " && xmlData[i] !== "\n" && xmlData[i] !== "\r"; i++) {
706
+ tagName += xmlData[i];
747
707
  }
748
- } else {
749
- const isValid = validateAttributeString(attrStr, options);
750
- if (isValid !== true) {
751
- return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, i - attrStr.length + isValid.err.line));
708
+ tagName = tagName.trim();
709
+ if (tagName[tagName.length - 1] === "/") {
710
+ tagName = tagName.substring(0, tagName.length - 1);
711
+ i--;
752
712
  }
753
- if (reachedRoot === true) {
754
- return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(xmlData, i));
755
- } else if (options.unpairedTags.indexOf(tagName) !== -1) ;
756
- else {
757
- tags.push({ tagName, tagStartPos });
713
+ if (!validateTagName(tagName)) {
714
+ let msg;
715
+ if (tagName.trim().length === 0) {
716
+ msg = "Invalid space after '<'.";
717
+ } else {
718
+ msg = "Tag '" + tagName + "' is an invalid name.";
719
+ }
720
+ return getErrorObject("InvalidTag", msg, getLineNumberForPosition(xmlData, i));
758
721
  }
759
- tagFound = true;
760
- }
761
- for (i++; i < xmlData.length; i++) {
762
- if (xmlData[i] === "<") {
763
- if (xmlData[i + 1] === "!") {
764
- i++;
765
- i = readCommentAndCDATA(xmlData, i);
766
- continue;
767
- } else if (xmlData[i + 1] === "?") {
768
- i = readPI(xmlData, ++i);
769
- if (i.err) return i;
722
+ const result = readAttributeStr(xmlData, i);
723
+ if (result === false) {
724
+ return getErrorObject("InvalidAttr", "Attributes for '" + tagName + "' have open quote.", getLineNumberForPosition(xmlData, i));
725
+ }
726
+ let attrStr = result.value;
727
+ i = result.index;
728
+ if (attrStr[attrStr.length - 1] === "/") {
729
+ const attrStrStart = i - attrStr.length;
730
+ attrStr = attrStr.substring(0, attrStr.length - 1);
731
+ const isValid = validateAttributeString(attrStr, options);
732
+ if (isValid === true) {
733
+ tagFound = true;
770
734
  } else {
771
- break;
735
+ return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid.err.line));
736
+ }
737
+ } else if (closingTag) {
738
+ if (!result.tagClosed) {
739
+ return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' doesn't have proper closing.", getLineNumberForPosition(xmlData, i));
740
+ } else if (attrStr.trim().length > 0) {
741
+ return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' can't have attributes or invalid starting.", getLineNumberForPosition(xmlData, tagStartPos));
742
+ } else if (tags.length === 0) {
743
+ return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' has not been opened.", getLineNumberForPosition(xmlData, tagStartPos));
744
+ } else {
745
+ const otg = tags.pop();
746
+ if (tagName !== otg.tagName) {
747
+ let openPos = getLineNumberForPosition(xmlData, otg.tagStartPos);
748
+ return getErrorObject(
749
+ "InvalidTag",
750
+ "Expected closing tag '" + otg.tagName + "' (opened in line " + openPos.line + ", col " + openPos.col + ") instead of closing tag '" + tagName + "'.",
751
+ getLineNumberForPosition(xmlData, tagStartPos)
752
+ );
753
+ }
754
+ if (tags.length == 0) {
755
+ reachedRoot = true;
756
+ }
772
757
  }
773
- } else if (xmlData[i] === "&") {
774
- const afterAmp = validateAmpersand(xmlData, i);
775
- if (afterAmp == -1)
776
- return getErrorObject("InvalidChar", "char '&' is not expected.", getLineNumberForPosition(xmlData, i));
777
- i = afterAmp;
778
758
  } else {
779
- if (reachedRoot === true && !isWhiteSpace(xmlData[i])) {
780
- return getErrorObject("InvalidXml", "Extra text at the end", getLineNumberForPosition(xmlData, i));
759
+ const isValid = validateAttributeString(attrStr, options);
760
+ if (isValid !== true) {
761
+ return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, i - attrStr.length + isValid.err.line));
762
+ }
763
+ if (reachedRoot === true) {
764
+ return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(xmlData, i));
765
+ } else if (options.unpairedTags.indexOf(tagName) !== -1) ;
766
+ else {
767
+ tags.push({ tagName, tagStartPos });
768
+ }
769
+ tagFound = true;
770
+ }
771
+ for (i++; i < xmlData.length; i++) {
772
+ if (xmlData[i] === "<") {
773
+ if (xmlData[i + 1] === "!") {
774
+ i++;
775
+ i = readCommentAndCDATA(xmlData, i);
776
+ continue;
777
+ } else if (xmlData[i + 1] === "?") {
778
+ i = readPI(xmlData, ++i);
779
+ if (i.err) return i;
780
+ } else {
781
+ break;
782
+ }
783
+ } else if (xmlData[i] === "&") {
784
+ const afterAmp = validateAmpersand(xmlData, i);
785
+ if (afterAmp == -1)
786
+ return getErrorObject("InvalidChar", "char '&' is not expected.", getLineNumberForPosition(xmlData, i));
787
+ i = afterAmp;
788
+ } else {
789
+ if (reachedRoot === true && !isWhiteSpace(xmlData[i])) {
790
+ return getErrorObject("InvalidXml", "Extra text at the end", getLineNumberForPosition(xmlData, i));
791
+ }
781
792
  }
782
793
  }
794
+ if (xmlData[i] === "<") {
795
+ i--;
796
+ }
783
797
  }
784
- if (xmlData[i] === "<") {
785
- i--;
798
+ } else {
799
+ if (isWhiteSpace(xmlData[i])) {
800
+ continue;
786
801
  }
802
+ return getErrorObject("InvalidChar", "char '" + xmlData[i] + "' is not expected.", getLineNumberForPosition(xmlData, i));
787
803
  }
788
- } else {
789
- if (isWhiteSpace(xmlData[i])) {
790
- continue;
791
- }
792
- return getErrorObject("InvalidChar", "char '" + xmlData[i] + "' is not expected.", getLineNumberForPosition(xmlData, i));
793
804
  }
805
+ if (!tagFound) {
806
+ return getErrorObject("InvalidXml", "Start tag expected.", 1);
807
+ } else if (tags.length == 1) {
808
+ return getErrorObject("InvalidTag", "Unclosed tag '" + tags[0].tagName + "'.", getLineNumberForPosition(xmlData, tags[0].tagStartPos));
809
+ } else if (tags.length > 0) {
810
+ return getErrorObject("InvalidXml", "Invalid '" + JSON.stringify(tags.map((t) => t.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
811
+ }
812
+ return true;
813
+ };
814
+ function isWhiteSpace(char) {
815
+ return char === " " || char === " " || char === "\n" || char === "\r";
794
816
  }
795
- if (!tagFound) {
796
- return getErrorObject("InvalidXml", "Start tag expected.", 1);
797
- } else if (tags.length == 1) {
798
- return getErrorObject("InvalidTag", "Unclosed tag '" + tags[0].tagName + "'.", getLineNumberForPosition(xmlData, tags[0].tagStartPos));
799
- } else if (tags.length > 0) {
800
- return getErrorObject("InvalidXml", "Invalid '" + JSON.stringify(tags.map((t2) => t2.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
801
- }
802
- return true;
803
- };
804
- function isWhiteSpace(char) {
805
- return char === " " || char === " " || char === "\n" || char === "\r";
806
- }
807
- function readPI(xmlData, i) {
808
- const start = i;
809
- for (; i < xmlData.length; i++) {
810
- if (xmlData[i] == "?" || xmlData[i] == " ") {
811
- const tagname = xmlData.substr(start, i - start);
812
- if (i > 5 && tagname === "xml") {
813
- return getErrorObject("InvalidXml", "XML declaration allowed only at the start of the document.", getLineNumberForPosition(xmlData, i));
814
- } else if (xmlData[i] == "?" && xmlData[i + 1] == ">") {
815
- i++;
816
- break;
817
- } else {
818
- continue;
817
+ function readPI(xmlData, i) {
818
+ const start = i;
819
+ for (; i < xmlData.length; i++) {
820
+ if (xmlData[i] == "?" || xmlData[i] == " ") {
821
+ const tagname = xmlData.substr(start, i - start);
822
+ if (i > 5 && tagname === "xml") {
823
+ return getErrorObject("InvalidXml", "XML declaration allowed only at the start of the document.", getLineNumberForPosition(xmlData, i));
824
+ } else if (xmlData[i] == "?" && xmlData[i + 1] == ">") {
825
+ i++;
826
+ break;
827
+ } else {
828
+ continue;
829
+ }
819
830
  }
820
831
  }
832
+ return i;
821
833
  }
822
- return i;
823
- }
824
- function readCommentAndCDATA(xmlData, i) {
825
- if (xmlData.length > i + 5 && xmlData[i + 1] === "-" && xmlData[i + 2] === "-") {
826
- for (i += 3; i < xmlData.length; i++) {
827
- if (xmlData[i] === "-" && xmlData[i + 1] === "-" && xmlData[i + 2] === ">") {
828
- i += 2;
829
- break;
834
+ function readCommentAndCDATA(xmlData, i) {
835
+ if (xmlData.length > i + 5 && xmlData[i + 1] === "-" && xmlData[i + 2] === "-") {
836
+ for (i += 3; i < xmlData.length; i++) {
837
+ if (xmlData[i] === "-" && xmlData[i + 1] === "-" && xmlData[i + 2] === ">") {
838
+ i += 2;
839
+ break;
840
+ }
841
+ }
842
+ } else if (xmlData.length > i + 8 && xmlData[i + 1] === "D" && xmlData[i + 2] === "O" && xmlData[i + 3] === "C" && xmlData[i + 4] === "T" && xmlData[i + 5] === "Y" && xmlData[i + 6] === "P" && xmlData[i + 7] === "E") {
843
+ let angleBracketsCount = 1;
844
+ for (i += 8; i < xmlData.length; i++) {
845
+ if (xmlData[i] === "<") {
846
+ angleBracketsCount++;
847
+ } else if (xmlData[i] === ">") {
848
+ angleBracketsCount--;
849
+ if (angleBracketsCount === 0) {
850
+ break;
851
+ }
852
+ }
853
+ }
854
+ } else if (xmlData.length > i + 9 && xmlData[i + 1] === "[" && xmlData[i + 2] === "C" && xmlData[i + 3] === "D" && xmlData[i + 4] === "A" && xmlData[i + 5] === "T" && xmlData[i + 6] === "A" && xmlData[i + 7] === "[") {
855
+ for (i += 8; i < xmlData.length; i++) {
856
+ if (xmlData[i] === "]" && xmlData[i + 1] === "]" && xmlData[i + 2] === ">") {
857
+ i += 2;
858
+ break;
859
+ }
830
860
  }
831
861
  }
832
- } else if (xmlData.length > i + 8 && xmlData[i + 1] === "D" && xmlData[i + 2] === "O" && xmlData[i + 3] === "C" && xmlData[i + 4] === "T" && xmlData[i + 5] === "Y" && xmlData[i + 6] === "P" && xmlData[i + 7] === "E") {
833
- let angleBracketsCount = 1;
834
- for (i += 8; i < xmlData.length; i++) {
835
- if (xmlData[i] === "<") {
836
- angleBracketsCount++;
862
+ return i;
863
+ }
864
+ const doubleQuote = '"';
865
+ const singleQuote = "'";
866
+ function readAttributeStr(xmlData, i) {
867
+ let attrStr = "";
868
+ let startChar = "";
869
+ let tagClosed = false;
870
+ for (; i < xmlData.length; i++) {
871
+ if (xmlData[i] === doubleQuote || xmlData[i] === singleQuote) {
872
+ if (startChar === "") {
873
+ startChar = xmlData[i];
874
+ } else if (startChar !== xmlData[i]) ;
875
+ else {
876
+ startChar = "";
877
+ }
837
878
  } else if (xmlData[i] === ">") {
838
- angleBracketsCount--;
839
- if (angleBracketsCount === 0) {
879
+ if (startChar === "") {
880
+ tagClosed = true;
840
881
  break;
841
882
  }
842
883
  }
884
+ attrStr += xmlData[i];
843
885
  }
844
- } else if (xmlData.length > i + 9 && xmlData[i + 1] === "[" && xmlData[i + 2] === "C" && xmlData[i + 3] === "D" && xmlData[i + 4] === "A" && xmlData[i + 5] === "T" && xmlData[i + 6] === "A" && xmlData[i + 7] === "[") {
845
- for (i += 8; i < xmlData.length; i++) {
846
- if (xmlData[i] === "]" && xmlData[i + 1] === "]" && xmlData[i + 2] === ">") {
847
- i += 2;
848
- break;
849
- }
886
+ if (startChar !== "") {
887
+ return false;
850
888
  }
889
+ return {
890
+ value: attrStr,
891
+ index: i,
892
+ tagClosed
893
+ };
851
894
  }
852
- return i;
853
- }
854
- const doubleQuote = '"';
855
- const singleQuote = "'";
856
- function readAttributeStr(xmlData, i) {
857
- let attrStr = "";
858
- let startChar = "";
859
- let tagClosed = false;
860
- for (; i < xmlData.length; i++) {
861
- if (xmlData[i] === doubleQuote || xmlData[i] === singleQuote) {
862
- if (startChar === "") {
863
- startChar = xmlData[i];
864
- } else if (startChar !== xmlData[i]) ;
865
- else {
866
- startChar = "";
895
+ const validAttrStrRegxp = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
896
+ function validateAttributeString(attrStr, options) {
897
+ const matches = util2.getAllMatches(attrStr, validAttrStrRegxp);
898
+ const attrNames = {};
899
+ for (let i = 0; i < matches.length; i++) {
900
+ if (matches[i][1].length === 0) {
901
+ return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' has no space in starting.", getPositionFromMatch(matches[i]));
902
+ } else if (matches[i][3] !== void 0 && matches[i][4] === void 0) {
903
+ return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' is without value.", getPositionFromMatch(matches[i]));
904
+ } else if (matches[i][3] === void 0 && !options.allowBooleanAttributes) {
905
+ return getErrorObject("InvalidAttr", "boolean attribute '" + matches[i][2] + "' is not allowed.", getPositionFromMatch(matches[i]));
867
906
  }
868
- } else if (xmlData[i] === ">") {
869
- if (startChar === "") {
870
- tagClosed = true;
871
- break;
907
+ const attrName = matches[i][2];
908
+ if (!validateAttrName(attrName)) {
909
+ return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is an invalid name.", getPositionFromMatch(matches[i]));
910
+ }
911
+ if (!attrNames.hasOwnProperty(attrName)) {
912
+ attrNames[attrName] = 1;
913
+ } else {
914
+ return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is repeated.", getPositionFromMatch(matches[i]));
872
915
  }
873
916
  }
874
- attrStr += xmlData[i];
875
- }
876
- if (startChar !== "") {
877
- return false;
917
+ return true;
878
918
  }
879
- return {
880
- value: attrStr,
881
- index: i,
882
- tagClosed
883
- };
884
- }
885
- const validAttrStrRegxp = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
886
- function validateAttributeString(attrStr, options) {
887
- const matches = util$2.getAllMatches(attrStr, validAttrStrRegxp);
888
- const attrNames = {};
889
- for (let i = 0; i < matches.length; i++) {
890
- if (matches[i][1].length === 0) {
891
- return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' has no space in starting.", getPositionFromMatch(matches[i]));
892
- } else if (matches[i][3] !== void 0 && matches[i][4] === void 0) {
893
- return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' is without value.", getPositionFromMatch(matches[i]));
894
- } else if (matches[i][3] === void 0 && !options.allowBooleanAttributes) {
895
- return getErrorObject("InvalidAttr", "boolean attribute '" + matches[i][2] + "' is not allowed.", getPositionFromMatch(matches[i]));
896
- }
897
- const attrName = matches[i][2];
898
- if (!validateAttrName(attrName)) {
899
- return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is an invalid name.", getPositionFromMatch(matches[i]));
900
- }
901
- if (!attrNames.hasOwnProperty(attrName)) {
902
- attrNames[attrName] = 1;
903
- } else {
904
- return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is repeated.", getPositionFromMatch(matches[i]));
919
+ function validateNumberAmpersand(xmlData, i) {
920
+ let re2 = /\d/;
921
+ if (xmlData[i] === "x") {
922
+ i++;
923
+ re2 = /[\da-fA-F]/;
924
+ }
925
+ for (; i < xmlData.length; i++) {
926
+ if (xmlData[i] === ";")
927
+ return i;
928
+ if (!xmlData[i].match(re2))
929
+ break;
905
930
  }
931
+ return -1;
906
932
  }
907
- return true;
908
- }
909
- function validateNumberAmpersand(xmlData, i) {
910
- let re2 = /\d/;
911
- if (xmlData[i] === "x") {
933
+ function validateAmpersand(xmlData, i) {
912
934
  i++;
913
- re2 = /[\da-fA-F]/;
914
- }
915
- for (; i < xmlData.length; i++) {
916
935
  if (xmlData[i] === ";")
917
- return i;
918
- if (!xmlData[i].match(re2))
919
- break;
936
+ return -1;
937
+ if (xmlData[i] === "#") {
938
+ i++;
939
+ return validateNumberAmpersand(xmlData, i);
940
+ }
941
+ let count = 0;
942
+ for (; i < xmlData.length; i++, count++) {
943
+ if (xmlData[i].match(/\w/) && count < 20)
944
+ continue;
945
+ if (xmlData[i] === ";")
946
+ break;
947
+ return -1;
948
+ }
949
+ return i;
920
950
  }
921
- return -1;
922
- }
923
- function validateAmpersand(xmlData, i) {
924
- i++;
925
- if (xmlData[i] === ";")
926
- return -1;
927
- if (xmlData[i] === "#") {
928
- i++;
929
- return validateNumberAmpersand(xmlData, i);
951
+ function getErrorObject(code, message, lineNumber) {
952
+ return {
953
+ err: {
954
+ code,
955
+ msg: message,
956
+ line: lineNumber.line || lineNumber,
957
+ col: lineNumber.col
958
+ }
959
+ };
930
960
  }
931
- let count = 0;
932
- for (; i < xmlData.length; i++, count++) {
933
- if (xmlData[i].match(/\w/) && count < 20)
934
- continue;
935
- if (xmlData[i] === ";")
936
- break;
937
- return -1;
961
+ function validateAttrName(attrName) {
962
+ return util2.isName(attrName);
963
+ }
964
+ function validateTagName(tagname) {
965
+ return util2.isName(tagname);
966
+ }
967
+ function getLineNumberForPosition(xmlData, index) {
968
+ const lines = xmlData.substring(0, index).split(/\r?\n/);
969
+ return {
970
+ line: lines.length,
971
+ // column number is last line's length + 1, because column numbering starts at 1:
972
+ col: lines[lines.length - 1].length + 1
973
+ };
974
+ }
975
+ function getPositionFromMatch(match) {
976
+ return match.startIndex + match[1].length;
938
977
  }
939
- return i;
978
+ return validator;
940
979
  }
941
- function getErrorObject(code, message, lineNumber) {
942
- return {
943
- err: {
944
- code,
945
- msg: message,
946
- line: lineNumber.line || lineNumber,
947
- col: lineNumber.col
948
- }
980
+ var OptionsBuilder = {};
981
+ var hasRequiredOptionsBuilder;
982
+ function requireOptionsBuilder() {
983
+ if (hasRequiredOptionsBuilder) return OptionsBuilder;
984
+ hasRequiredOptionsBuilder = 1;
985
+ const defaultOptions = {
986
+ preserveOrder: false,
987
+ attributeNamePrefix: "@_",
988
+ attributesGroupName: false,
989
+ textNodeName: "#text",
990
+ ignoreAttributes: true,
991
+ removeNSPrefix: false,
992
+ // remove NS from tag name or attribute name if true
993
+ allowBooleanAttributes: false,
994
+ //a tag can have attributes without any value
995
+ //ignoreRootElement : false,
996
+ parseTagValue: true,
997
+ parseAttributeValue: false,
998
+ trimValues: true,
999
+ //Trim string values of tag and attributes
1000
+ cdataPropName: false,
1001
+ numberParseOptions: {
1002
+ hex: true,
1003
+ leadingZeros: true,
1004
+ eNotation: true
1005
+ },
1006
+ tagValueProcessor: function(tagName, val) {
1007
+ return val;
1008
+ },
1009
+ attributeValueProcessor: function(attrName, val) {
1010
+ return val;
1011
+ },
1012
+ stopNodes: [],
1013
+ //nested tags will not be parsed even for errors
1014
+ alwaysCreateTextNode: false,
1015
+ isArray: () => false,
1016
+ commentPropName: false,
1017
+ unpairedTags: [],
1018
+ processEntities: true,
1019
+ htmlEntities: false,
1020
+ ignoreDeclaration: false,
1021
+ ignorePiTags: false,
1022
+ transformTagName: false,
1023
+ transformAttributeName: false,
1024
+ updateTag: function(tagName, jPath, attrs) {
1025
+ return tagName;
1026
+ }
1027
+ // skipEmptyListItem: false
949
1028
  };
950
- }
951
- function validateAttrName(attrName) {
952
- return util$2.isName(attrName);
953
- }
954
- function validateTagName(tagname) {
955
- return util$2.isName(tagname);
956
- }
957
- function getLineNumberForPosition(xmlData, index) {
958
- const lines = xmlData.substring(0, index).split(/\r?\n/);
959
- return {
960
- line: lines.length,
961
- // column number is last line's length + 1, because column numbering starts at 1:
962
- col: lines[lines.length - 1].length + 1
1029
+ const buildOptions = function(options) {
1030
+ return Object.assign({}, defaultOptions, options);
963
1031
  };
964
- }
965
- function getPositionFromMatch(match) {
966
- return match.startIndex + match[1].length;
967
- }
968
- var OptionsBuilder = {};
969
- const defaultOptions$1 = {
970
- preserveOrder: false,
971
- attributeNamePrefix: "@_",
972
- attributesGroupName: false,
973
- textNodeName: "#text",
974
- ignoreAttributes: true,
975
- removeNSPrefix: false,
976
- // remove NS from tag name or attribute name if true
977
- allowBooleanAttributes: false,
978
- //a tag can have attributes without any value
979
- //ignoreRootElement : false,
980
- parseTagValue: true,
981
- parseAttributeValue: false,
982
- trimValues: true,
983
- //Trim string values of tag and attributes
984
- cdataPropName: false,
985
- numberParseOptions: {
986
- hex: true,
987
- leadingZeros: true,
988
- eNotation: true
989
- },
990
- tagValueProcessor: function(tagName, val2) {
991
- return val2;
992
- },
993
- attributeValueProcessor: function(attrName, val2) {
994
- return val2;
995
- },
996
- stopNodes: [],
997
- //nested tags will not be parsed even for errors
998
- alwaysCreateTextNode: false,
999
- isArray: () => false,
1000
- commentPropName: false,
1001
- unpairedTags: [],
1002
- processEntities: true,
1003
- htmlEntities: false,
1004
- ignoreDeclaration: false,
1005
- ignorePiTags: false,
1006
- transformTagName: false,
1007
- transformAttributeName: false,
1008
- updateTag: function(tagName, jPath, attrs) {
1009
- return tagName;
1010
- }
1011
- // skipEmptyListItem: false
1012
- };
1013
- const buildOptions$1 = function(options) {
1014
- return Object.assign({}, defaultOptions$1, options);
1015
- };
1016
- OptionsBuilder.buildOptions = buildOptions$1;
1017
- OptionsBuilder.defaultOptions = defaultOptions$1;
1018
- class XmlNode {
1019
- constructor(tagname) {
1020
- this.tagname = tagname;
1021
- this.child = [];
1022
- this[":@"] = {};
1023
- }
1024
- add(key, val2) {
1025
- if (key === "__proto__") key = "#__proto__";
1026
- this.child.push({ [key]: val2 });
1027
- }
1028
- addChild(node) {
1029
- if (node.tagname === "__proto__") node.tagname = "#__proto__";
1030
- if (node[":@"] && Object.keys(node[":@"]).length > 0) {
1031
- this.child.push({ [node.tagname]: node.child, [":@"]: node[":@"] });
1032
- } else {
1033
- this.child.push({ [node.tagname]: node.child });
1032
+ OptionsBuilder.buildOptions = buildOptions;
1033
+ OptionsBuilder.defaultOptions = defaultOptions;
1034
+ return OptionsBuilder;
1035
+ }
1036
+ var xmlNode;
1037
+ var hasRequiredXmlNode;
1038
+ function requireXmlNode() {
1039
+ if (hasRequiredXmlNode) return xmlNode;
1040
+ hasRequiredXmlNode = 1;
1041
+ class XmlNode {
1042
+ constructor(tagname) {
1043
+ this.tagname = tagname;
1044
+ this.child = [];
1045
+ this[":@"] = {};
1046
+ }
1047
+ add(key, val) {
1048
+ if (key === "__proto__") key = "#__proto__";
1049
+ this.child.push({ [key]: val });
1050
+ }
1051
+ addChild(node) {
1052
+ if (node.tagname === "__proto__") node.tagname = "#__proto__";
1053
+ if (node[":@"] && Object.keys(node[":@"]).length > 0) {
1054
+ this.child.push({ [node.tagname]: node.child, [":@"]: node[":@"] });
1055
+ } else {
1056
+ this.child.push({ [node.tagname]: node.child });
1057
+ }
1034
1058
  }
1035
1059
  }
1036
- }
1037
- var xmlNode$1 = XmlNode;
1038
- const util$1 = util$3;
1039
- function readDocType$1(xmlData, i) {
1040
- const entities = {};
1041
- 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") {
1042
- i = i + 9;
1043
- let angleBracketsCount = 1;
1044
- let hasBody = false, comment = false;
1045
- let exp = "";
1046
- for (; i < xmlData.length; i++) {
1047
- if (xmlData[i] === "<" && !comment) {
1048
- if (hasBody && isEntity(xmlData, i)) {
1049
- i += 7;
1050
- [entityName, val, i] = readEntityExp(xmlData, i + 1);
1051
- if (val.indexOf("&") === -1)
1052
- entities[validateEntityName(entityName)] = {
1053
- regx: RegExp(`&${entityName};`, "g"),
1054
- val
1055
- };
1056
- } else if (hasBody && isElement(xmlData, i)) i += 8;
1057
- else if (hasBody && isAttlist(xmlData, i)) i += 8;
1058
- else if (hasBody && isNotation(xmlData, i)) i += 9;
1059
- else if (isComment) comment = true;
1060
- else throw new Error("Invalid DOCTYPE");
1061
- angleBracketsCount++;
1062
- exp = "";
1063
- } else if (xmlData[i] === ">") {
1064
- if (comment) {
1065
- if (xmlData[i - 1] === "-" && xmlData[i - 2] === "-") {
1066
- comment = false;
1060
+ xmlNode = XmlNode;
1061
+ return xmlNode;
1062
+ }
1063
+ var DocTypeReader;
1064
+ var hasRequiredDocTypeReader;
1065
+ function requireDocTypeReader() {
1066
+ if (hasRequiredDocTypeReader) return DocTypeReader;
1067
+ hasRequiredDocTypeReader = 1;
1068
+ const util2 = requireUtil();
1069
+ function readDocType(xmlData, i) {
1070
+ const entities = {};
1071
+ 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") {
1072
+ i = i + 9;
1073
+ let angleBracketsCount = 1;
1074
+ let hasBody = false, comment = false;
1075
+ let exp = "";
1076
+ for (; i < xmlData.length; i++) {
1077
+ if (xmlData[i] === "<" && !comment) {
1078
+ if (hasBody && isEntity(xmlData, i)) {
1079
+ i += 7;
1080
+ let entityName, val;
1081
+ [entityName, val, i] = readEntityExp(xmlData, i + 1);
1082
+ if (val.indexOf("&") === -1)
1083
+ entities[validateEntityName(entityName)] = {
1084
+ regx: RegExp(`&${entityName};`, "g"),
1085
+ val
1086
+ };
1087
+ } else if (hasBody && isElement(xmlData, i)) i += 8;
1088
+ else if (hasBody && isAttlist(xmlData, i)) i += 8;
1089
+ else if (hasBody && isNotation(xmlData, i)) i += 9;
1090
+ else comment = true;
1091
+ angleBracketsCount++;
1092
+ exp = "";
1093
+ } else if (xmlData[i] === ">") {
1094
+ if (comment) {
1095
+ if (xmlData[i - 1] === "-" && xmlData[i - 2] === "-") {
1096
+ comment = false;
1097
+ angleBracketsCount--;
1098
+ }
1099
+ } else {
1067
1100
  angleBracketsCount--;
1068
1101
  }
1102
+ if (angleBracketsCount === 0) {
1103
+ break;
1104
+ }
1105
+ } else if (xmlData[i] === "[") {
1106
+ hasBody = true;
1069
1107
  } else {
1070
- angleBracketsCount--;
1071
- }
1072
- if (angleBracketsCount === 0) {
1073
- break;
1108
+ exp += xmlData[i];
1074
1109
  }
1075
- } else if (xmlData[i] === "[") {
1076
- hasBody = true;
1077
- } else {
1078
- exp += xmlData[i];
1079
1110
  }
1080
- }
1081
- if (angleBracketsCount !== 0) {
1082
- throw new Error(`Unclosed DOCTYPE`);
1083
- }
1084
- } else {
1085
- throw new Error(`Invalid Tag instead of DOCTYPE`);
1086
- }
1087
- return { entities, i };
1088
- }
1089
- function readEntityExp(xmlData, i) {
1090
- let entityName2 = "";
1091
- for (; i < xmlData.length && (xmlData[i] !== "'" && xmlData[i] !== '"'); i++) {
1092
- entityName2 += xmlData[i];
1093
- }
1094
- entityName2 = entityName2.trim();
1095
- if (entityName2.indexOf(" ") !== -1) throw new Error("External entites are not supported");
1096
- const startChar = xmlData[i++];
1097
- let val2 = "";
1098
- for (; i < xmlData.length && xmlData[i] !== startChar; i++) {
1099
- val2 += xmlData[i];
1100
- }
1101
- return [entityName2, val2, i];
1102
- }
1103
- function isComment(xmlData, i) {
1104
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "-" && xmlData[i + 3] === "-") return true;
1105
- return false;
1106
- }
1107
- function isEntity(xmlData, i) {
1108
- 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") return true;
1109
- return false;
1110
- }
1111
- function isElement(xmlData, i) {
1112
- 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") return true;
1113
- return false;
1114
- }
1115
- function isAttlist(xmlData, i) {
1116
- 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") return true;
1117
- return false;
1118
- }
1119
- function isNotation(xmlData, i) {
1120
- 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") return true;
1121
- return false;
1122
- }
1123
- function validateEntityName(name) {
1124
- if (util$1.isName(name))
1125
- return name;
1126
- else
1127
- throw new Error(`Invalid entity name ${name}`);
1128
- }
1129
- var DocTypeReader = readDocType$1;
1130
- const hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;
1131
- const numRegex = /^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/;
1132
- if (!Number.parseInt && window.parseInt) {
1133
- Number.parseInt = window.parseInt;
1134
- }
1135
- if (!Number.parseFloat && window.parseFloat) {
1136
- Number.parseFloat = window.parseFloat;
1137
- }
1138
- const consider = {
1139
- hex: true,
1140
- leadingZeros: true,
1141
- decimalPoint: ".",
1142
- eNotation: true
1143
- //skipLike: /regex/
1144
- };
1145
- function toNumber$1(str, options = {}) {
1146
- options = Object.assign({}, consider, options);
1147
- if (!str || typeof str !== "string") return str;
1148
- let trimmedStr = str.trim();
1149
- if (options.skipLike !== void 0 && options.skipLike.test(trimmedStr)) return str;
1150
- else if (options.hex && hexRegex.test(trimmedStr)) {
1151
- return Number.parseInt(trimmedStr, 16);
1152
- } else {
1153
- const match = numRegex.exec(trimmedStr);
1154
- if (match) {
1155
- const sign = match[1];
1156
- const leadingZeros = match[2];
1157
- let numTrimmedByZeros = trimZeros(match[3]);
1158
- const eNotation = match[4] || match[6];
1159
- if (!options.leadingZeros && leadingZeros.length > 0 && sign && trimmedStr[2] !== ".") return str;
1160
- else if (!options.leadingZeros && leadingZeros.length > 0 && !sign && trimmedStr[1] !== ".") return str;
1161
- else {
1162
- const num = Number(trimmedStr);
1163
- const numStr = "" + num;
1164
- if (numStr.search(/[eE]/) !== -1) {
1165
- if (options.eNotation) return num;
1166
- else return str;
1167
- } else if (eNotation) {
1168
- if (options.eNotation) return num;
1169
- else return str;
1170
- } else if (trimmedStr.indexOf(".") !== -1) {
1171
- if (numStr === "0" && numTrimmedByZeros === "") return num;
1172
- else if (numStr === numTrimmedByZeros) return num;
1173
- else if (sign && numStr === "-" + numTrimmedByZeros) return num;
1174
- else return str;
1175
- }
1176
- if (leadingZeros) {
1177
- if (numTrimmedByZeros === numStr) return num;
1178
- else if (sign + numTrimmedByZeros === numStr) return num;
1179
- else return str;
1180
- }
1181
- if (trimmedStr === numStr) return num;
1182
- else if (trimmedStr === sign + numStr) return num;
1183
- return str;
1111
+ if (angleBracketsCount !== 0) {
1112
+ throw new Error(`Unclosed DOCTYPE`);
1184
1113
  }
1185
1114
  } else {
1186
- return str;
1115
+ throw new Error(`Invalid Tag instead of DOCTYPE`);
1187
1116
  }
1117
+ return { entities, i };
1188
1118
  }
1189
- }
1190
- function trimZeros(numStr) {
1191
- if (numStr && numStr.indexOf(".") !== -1) {
1192
- numStr = numStr.replace(/0+$/, "");
1193
- if (numStr === ".") numStr = "0";
1194
- else if (numStr[0] === ".") numStr = "0" + numStr;
1195
- else if (numStr[numStr.length - 1] === ".") numStr = numStr.substr(0, numStr.length - 1);
1196
- return numStr;
1119
+ function readEntityExp(xmlData, i) {
1120
+ let entityName = "";
1121
+ for (; i < xmlData.length && (xmlData[i] !== "'" && xmlData[i] !== '"'); i++) {
1122
+ entityName += xmlData[i];
1123
+ }
1124
+ entityName = entityName.trim();
1125
+ if (entityName.indexOf(" ") !== -1) throw new Error("External entites are not supported");
1126
+ const startChar = xmlData[i++];
1127
+ let val = "";
1128
+ for (; i < xmlData.length && xmlData[i] !== startChar; i++) {
1129
+ val += xmlData[i];
1130
+ }
1131
+ return [entityName, val, i];
1197
1132
  }
1198
- return numStr;
1199
- }
1200
- var strnum = toNumber$1;
1201
- function getIgnoreAttributesFn$2(ignoreAttributes2) {
1202
- if (typeof ignoreAttributes2 === "function") {
1203
- return ignoreAttributes2;
1204
- }
1205
- if (Array.isArray(ignoreAttributes2)) {
1206
- return (attrName) => {
1207
- for (const pattern of ignoreAttributes2) {
1208
- if (typeof pattern === "string" && attrName === pattern) {
1209
- return true;
1210
- }
1211
- if (pattern instanceof RegExp && pattern.test(attrName)) {
1212
- return true;
1213
- }
1214
- }
1215
- };
1133
+ function isEntity(xmlData, i) {
1134
+ 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") return true;
1135
+ return false;
1216
1136
  }
1217
- return () => false;
1218
- }
1219
- var ignoreAttributes = getIgnoreAttributesFn$2;
1220
- const util = util$3;
1221
- const xmlNode = xmlNode$1;
1222
- const readDocType = DocTypeReader;
1223
- const toNumber = strnum;
1224
- const getIgnoreAttributesFn$1 = ignoreAttributes;
1225
- let OrderedObjParser$1 = class OrderedObjParser {
1226
- constructor(options) {
1227
- this.options = options;
1228
- this.currentNode = null;
1229
- this.tagsNodeStack = [];
1230
- this.docTypeEntities = {};
1231
- this.lastEntities = {
1232
- "apos": { regex: /&(apos|#39|#x27);/g, val: "'" },
1233
- "gt": { regex: /&(gt|#62|#x3E);/g, val: ">" },
1234
- "lt": { regex: /&(lt|#60|#x3C);/g, val: "<" },
1235
- "quot": { regex: /&(quot|#34|#x22);/g, val: '"' }
1236
- };
1237
- this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" };
1238
- this.htmlEntities = {
1239
- "space": { regex: /&(nbsp|#160);/g, val: " " },
1240
- // "lt" : { regex: /&(lt|#60);/g, val: "<" },
1241
- // "gt" : { regex: /&(gt|#62);/g, val: ">" },
1242
- // "amp" : { regex: /&(amp|#38);/g, val: "&" },
1243
- // "quot" : { regex: /&(quot|#34);/g, val: "\"" },
1244
- // "apos" : { regex: /&(apos|#39);/g, val: "'" },
1245
- "cent": { regex: /&(cent|#162);/g, val: "¢" },
1246
- "pound": { regex: /&(pound|#163);/g, val: "£" },
1247
- "yen": { regex: /&(yen|#165);/g, val: "¥" },
1248
- "euro": { regex: /&(euro|#8364);/g, val: "€" },
1249
- "copyright": { regex: /&(copy|#169);/g, val: "©" },
1250
- "reg": { regex: /&(reg|#174);/g, val: "®" },
1251
- "inr": { regex: /&(inr|#8377);/g, val: "₹" },
1252
- "num_dec": { regex: /&#([0-9]{1,7});/g, val: (_, str) => String.fromCharCode(Number.parseInt(str, 10)) },
1253
- "num_hex": { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (_, str) => String.fromCharCode(Number.parseInt(str, 16)) }
1254
- };
1255
- this.addExternalEntities = addExternalEntities;
1256
- this.parseXml = parseXml;
1257
- this.parseTextData = parseTextData;
1258
- this.resolveNameSpace = resolveNameSpace;
1259
- this.buildAttributesMap = buildAttributesMap;
1260
- this.isItStopNode = isItStopNode;
1261
- this.replaceEntitiesValue = replaceEntitiesValue$1;
1262
- this.readStopNodeData = readStopNodeData;
1263
- this.saveTextToParentTag = saveTextToParentTag;
1264
- this.addChild = addChild;
1265
- this.ignoreAttributesFn = getIgnoreAttributesFn$1(this.options.ignoreAttributes);
1137
+ function isElement(xmlData, i) {
1138
+ 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") return true;
1139
+ return false;
1266
1140
  }
1267
- };
1268
- function addExternalEntities(externalEntities) {
1269
- const entKeys = Object.keys(externalEntities);
1270
- for (let i = 0; i < entKeys.length; i++) {
1271
- const ent = entKeys[i];
1272
- this.lastEntities[ent] = {
1273
- regex: new RegExp("&" + ent + ";", "g"),
1274
- val: externalEntities[ent]
1275
- };
1141
+ function isAttlist(xmlData, i) {
1142
+ 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") return true;
1143
+ return false;
1276
1144
  }
1277
- }
1278
- function parseTextData(val2, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
1279
- if (val2 !== void 0) {
1280
- if (this.options.trimValues && !dontTrim) {
1281
- val2 = val2.trim();
1282
- }
1283
- if (val2.length > 0) {
1284
- if (!escapeEntities) val2 = this.replaceEntitiesValue(val2);
1285
- const newval = this.options.tagValueProcessor(tagName, val2, jPath, hasAttributes, isLeafNode);
1286
- if (newval === null || newval === void 0) {
1287
- return val2;
1288
- } else if (typeof newval !== typeof val2 || newval !== val2) {
1289
- return newval;
1290
- } else if (this.options.trimValues) {
1291
- return parseValue(val2, this.options.parseTagValue, this.options.numberParseOptions);
1292
- } else {
1293
- const trimmedVal = val2.trim();
1294
- if (trimmedVal === val2) {
1295
- return parseValue(val2, this.options.parseTagValue, this.options.numberParseOptions);
1296
- } else {
1297
- return val2;
1145
+ function isNotation(xmlData, i) {
1146
+ 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") return true;
1147
+ return false;
1148
+ }
1149
+ function validateEntityName(name) {
1150
+ if (util2.isName(name))
1151
+ return name;
1152
+ else
1153
+ throw new Error(`Invalid entity name ${name}`);
1154
+ }
1155
+ DocTypeReader = readDocType;
1156
+ return DocTypeReader;
1157
+ }
1158
+ var strnum;
1159
+ var hasRequiredStrnum;
1160
+ function requireStrnum() {
1161
+ if (hasRequiredStrnum) return strnum;
1162
+ hasRequiredStrnum = 1;
1163
+ const hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;
1164
+ const numRegex = /^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/;
1165
+ if (!Number.parseInt && window.parseInt) {
1166
+ Number.parseInt = window.parseInt;
1167
+ }
1168
+ if (!Number.parseFloat && window.parseFloat) {
1169
+ Number.parseFloat = window.parseFloat;
1170
+ }
1171
+ const consider = {
1172
+ hex: true,
1173
+ leadingZeros: true,
1174
+ decimalPoint: ".",
1175
+ eNotation: true
1176
+ //skipLike: /regex/
1177
+ };
1178
+ function toNumber(str, options = {}) {
1179
+ options = Object.assign({}, consider, options);
1180
+ if (!str || typeof str !== "string") return str;
1181
+ let trimmedStr = str.trim();
1182
+ if (options.skipLike !== void 0 && options.skipLike.test(trimmedStr)) return str;
1183
+ else if (options.hex && hexRegex.test(trimmedStr)) {
1184
+ return Number.parseInt(trimmedStr, 16);
1185
+ } else {
1186
+ const match = numRegex.exec(trimmedStr);
1187
+ if (match) {
1188
+ const sign = match[1];
1189
+ const leadingZeros = match[2];
1190
+ let numTrimmedByZeros = trimZeros(match[3]);
1191
+ const eNotation = match[4] || match[6];
1192
+ if (!options.leadingZeros && leadingZeros.length > 0 && sign && trimmedStr[2] !== ".") return str;
1193
+ else if (!options.leadingZeros && leadingZeros.length > 0 && !sign && trimmedStr[1] !== ".") return str;
1194
+ else {
1195
+ const num = Number(trimmedStr);
1196
+ const numStr = "" + num;
1197
+ if (numStr.search(/[eE]/) !== -1) {
1198
+ if (options.eNotation) return num;
1199
+ else return str;
1200
+ } else if (eNotation) {
1201
+ if (options.eNotation) return num;
1202
+ else return str;
1203
+ } else if (trimmedStr.indexOf(".") !== -1) {
1204
+ if (numStr === "0" && numTrimmedByZeros === "") return num;
1205
+ else if (numStr === numTrimmedByZeros) return num;
1206
+ else if (sign && numStr === "-" + numTrimmedByZeros) return num;
1207
+ else return str;
1208
+ }
1209
+ if (leadingZeros) {
1210
+ if (numTrimmedByZeros === numStr) return num;
1211
+ else if (sign + numTrimmedByZeros === numStr) return num;
1212
+ else return str;
1213
+ }
1214
+ if (trimmedStr === numStr) return num;
1215
+ else if (trimmedStr === sign + numStr) return num;
1216
+ return str;
1298
1217
  }
1218
+ } else {
1219
+ return str;
1299
1220
  }
1300
1221
  }
1301
1222
  }
1302
- }
1303
- function resolveNameSpace(tagname) {
1304
- if (this.options.removeNSPrefix) {
1305
- const tags = tagname.split(":");
1306
- const prefix = tagname.charAt(0) === "/" ? "/" : "";
1307
- if (tags[0] === "xmlns") {
1308
- return "";
1223
+ function trimZeros(numStr) {
1224
+ if (numStr && numStr.indexOf(".") !== -1) {
1225
+ numStr = numStr.replace(/0+$/, "");
1226
+ if (numStr === ".") numStr = "0";
1227
+ else if (numStr[0] === ".") numStr = "0" + numStr;
1228
+ else if (numStr[numStr.length - 1] === ".") numStr = numStr.substr(0, numStr.length - 1);
1229
+ return numStr;
1230
+ }
1231
+ return numStr;
1232
+ }
1233
+ strnum = toNumber;
1234
+ return strnum;
1235
+ }
1236
+ var ignoreAttributes;
1237
+ var hasRequiredIgnoreAttributes;
1238
+ function requireIgnoreAttributes() {
1239
+ if (hasRequiredIgnoreAttributes) return ignoreAttributes;
1240
+ hasRequiredIgnoreAttributes = 1;
1241
+ function getIgnoreAttributesFn(ignoreAttributes2) {
1242
+ if (typeof ignoreAttributes2 === "function") {
1243
+ return ignoreAttributes2;
1244
+ }
1245
+ if (Array.isArray(ignoreAttributes2)) {
1246
+ return (attrName) => {
1247
+ for (const pattern of ignoreAttributes2) {
1248
+ if (typeof pattern === "string" && attrName === pattern) {
1249
+ return true;
1250
+ }
1251
+ if (pattern instanceof RegExp && pattern.test(attrName)) {
1252
+ return true;
1253
+ }
1254
+ }
1255
+ };
1309
1256
  }
1310
- if (tags.length === 2) {
1311
- tagname = prefix + tags[1];
1257
+ return () => false;
1258
+ }
1259
+ ignoreAttributes = getIgnoreAttributesFn;
1260
+ return ignoreAttributes;
1261
+ }
1262
+ var OrderedObjParser_1;
1263
+ var hasRequiredOrderedObjParser;
1264
+ function requireOrderedObjParser() {
1265
+ if (hasRequiredOrderedObjParser) return OrderedObjParser_1;
1266
+ hasRequiredOrderedObjParser = 1;
1267
+ const util2 = requireUtil();
1268
+ const xmlNode2 = requireXmlNode();
1269
+ const readDocType = requireDocTypeReader();
1270
+ const toNumber = requireStrnum();
1271
+ const getIgnoreAttributesFn = requireIgnoreAttributes();
1272
+ class OrderedObjParser {
1273
+ constructor(options) {
1274
+ this.options = options;
1275
+ this.currentNode = null;
1276
+ this.tagsNodeStack = [];
1277
+ this.docTypeEntities = {};
1278
+ this.lastEntities = {
1279
+ "apos": { regex: /&(apos|#39|#x27);/g, val: "'" },
1280
+ "gt": { regex: /&(gt|#62|#x3E);/g, val: ">" },
1281
+ "lt": { regex: /&(lt|#60|#x3C);/g, val: "<" },
1282
+ "quot": { regex: /&(quot|#34|#x22);/g, val: '"' }
1283
+ };
1284
+ this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" };
1285
+ this.htmlEntities = {
1286
+ "space": { regex: /&(nbsp|#160);/g, val: " " },
1287
+ // "lt" : { regex: /&(lt|#60);/g, val: "<" },
1288
+ // "gt" : { regex: /&(gt|#62);/g, val: ">" },
1289
+ // "amp" : { regex: /&(amp|#38);/g, val: "&" },
1290
+ // "quot" : { regex: /&(quot|#34);/g, val: "\"" },
1291
+ // "apos" : { regex: /&(apos|#39);/g, val: "'" },
1292
+ "cent": { regex: /&(cent|#162);/g, val: "¢" },
1293
+ "pound": { regex: /&(pound|#163);/g, val: "£" },
1294
+ "yen": { regex: /&(yen|#165);/g, val: "¥" },
1295
+ "euro": { regex: /&(euro|#8364);/g, val: "€" },
1296
+ "copyright": { regex: /&(copy|#169);/g, val: "©" },
1297
+ "reg": { regex: /&(reg|#174);/g, val: "®" },
1298
+ "inr": { regex: /&(inr|#8377);/g, val: "₹" },
1299
+ "num_dec": { regex: /&#([0-9]{1,7});/g, val: (_, str) => String.fromCharCode(Number.parseInt(str, 10)) },
1300
+ "num_hex": { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (_, str) => String.fromCharCode(Number.parseInt(str, 16)) }
1301
+ };
1302
+ this.addExternalEntities = addExternalEntities;
1303
+ this.parseXml = parseXml;
1304
+ this.parseTextData = parseTextData;
1305
+ this.resolveNameSpace = resolveNameSpace;
1306
+ this.buildAttributesMap = buildAttributesMap;
1307
+ this.isItStopNode = isItStopNode;
1308
+ this.replaceEntitiesValue = replaceEntitiesValue;
1309
+ this.readStopNodeData = readStopNodeData;
1310
+ this.saveTextToParentTag = saveTextToParentTag;
1311
+ this.addChild = addChild;
1312
+ this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes);
1313
+ }
1314
+ }
1315
+ function addExternalEntities(externalEntities) {
1316
+ const entKeys = Object.keys(externalEntities);
1317
+ for (let i = 0; i < entKeys.length; i++) {
1318
+ const ent = entKeys[i];
1319
+ this.lastEntities[ent] = {
1320
+ regex: new RegExp("&" + ent + ";", "g"),
1321
+ val: externalEntities[ent]
1322
+ };
1312
1323
  }
1313
1324
  }
1314
- return tagname;
1315
- }
1316
- const attrsRegx = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
1317
- function buildAttributesMap(attrStr, jPath, tagName) {
1318
- if (this.options.ignoreAttributes !== true && typeof attrStr === "string") {
1319
- const matches = util.getAllMatches(attrStr, attrsRegx);
1320
- const len = matches.length;
1321
- const attrs = {};
1322
- for (let i = 0; i < len; i++) {
1323
- const attrName = this.resolveNameSpace(matches[i][1]);
1324
- if (this.ignoreAttributesFn(attrName, jPath)) {
1325
- continue;
1325
+ function parseTextData(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
1326
+ if (val !== void 0) {
1327
+ if (this.options.trimValues && !dontTrim) {
1328
+ val = val.trim();
1326
1329
  }
1327
- let oldVal = matches[i][4];
1328
- let aName = this.options.attributeNamePrefix + attrName;
1329
- if (attrName.length) {
1330
- if (this.options.transformAttributeName) {
1331
- aName = this.options.transformAttributeName(aName);
1332
- }
1333
- if (aName === "__proto__") aName = "#__proto__";
1334
- if (oldVal !== void 0) {
1335
- if (this.options.trimValues) {
1336
- oldVal = oldVal.trim();
1337
- }
1338
- oldVal = this.replaceEntitiesValue(oldVal);
1339
- const newVal = this.options.attributeValueProcessor(attrName, oldVal, jPath);
1340
- if (newVal === null || newVal === void 0) {
1341
- attrs[aName] = oldVal;
1342
- } else if (typeof newVal !== typeof oldVal || newVal !== oldVal) {
1343
- attrs[aName] = newVal;
1330
+ if (val.length > 0) {
1331
+ if (!escapeEntities) val = this.replaceEntitiesValue(val);
1332
+ const newval = this.options.tagValueProcessor(tagName, val, jPath, hasAttributes, isLeafNode);
1333
+ if (newval === null || newval === void 0) {
1334
+ return val;
1335
+ } else if (typeof newval !== typeof val || newval !== val) {
1336
+ return newval;
1337
+ } else if (this.options.trimValues) {
1338
+ return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions);
1339
+ } else {
1340
+ const trimmedVal = val.trim();
1341
+ if (trimmedVal === val) {
1342
+ return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions);
1344
1343
  } else {
1345
- attrs[aName] = parseValue(
1346
- oldVal,
1347
- this.options.parseAttributeValue,
1348
- this.options.numberParseOptions
1349
- );
1344
+ return val;
1350
1345
  }
1351
- } else if (this.options.allowBooleanAttributes) {
1352
- attrs[aName] = true;
1353
1346
  }
1354
1347
  }
1355
1348
  }
1356
- if (!Object.keys(attrs).length) {
1357
- return;
1358
- }
1359
- if (this.options.attributesGroupName) {
1360
- const attrCollection = {};
1361
- attrCollection[this.options.attributesGroupName] = attrs;
1362
- return attrCollection;
1349
+ }
1350
+ function resolveNameSpace(tagname) {
1351
+ if (this.options.removeNSPrefix) {
1352
+ const tags = tagname.split(":");
1353
+ const prefix = tagname.charAt(0) === "/" ? "/" : "";
1354
+ if (tags[0] === "xmlns") {
1355
+ return "";
1356
+ }
1357
+ if (tags.length === 2) {
1358
+ tagname = prefix + tags[1];
1359
+ }
1363
1360
  }
1364
- return attrs;
1361
+ return tagname;
1365
1362
  }
1366
- }
1367
- const parseXml = function(xmlData) {
1368
- xmlData = xmlData.replace(/\r\n?/g, "\n");
1369
- const xmlObj = new xmlNode("!xml");
1370
- let currentNode = xmlObj;
1371
- let textData = "";
1372
- let jPath = "";
1373
- for (let i = 0; i < xmlData.length; i++) {
1374
- const ch = xmlData[i];
1375
- if (ch === "<") {
1376
- if (xmlData[i + 1] === "/") {
1377
- const closeIndex = findClosingIndex(xmlData, ">", i, "Closing Tag is not closed.");
1378
- let tagName = xmlData.substring(i + 2, closeIndex).trim();
1379
- if (this.options.removeNSPrefix) {
1380
- const colonIndex = tagName.indexOf(":");
1381
- if (colonIndex !== -1) {
1382
- tagName = tagName.substr(colonIndex + 1);
1383
- }
1384
- }
1385
- if (this.options.transformTagName) {
1386
- tagName = this.options.transformTagName(tagName);
1387
- }
1388
- if (currentNode) {
1389
- textData = this.saveTextToParentTag(textData, currentNode, jPath);
1390
- }
1391
- const lastTagName = jPath.substring(jPath.lastIndexOf(".") + 1);
1392
- if (tagName && this.options.unpairedTags.indexOf(tagName) !== -1) {
1393
- throw new Error(`Unpaired tag can not be used as closing tag: </${tagName}>`);
1394
- }
1395
- let propIndex = 0;
1396
- if (lastTagName && this.options.unpairedTags.indexOf(lastTagName) !== -1) {
1397
- propIndex = jPath.lastIndexOf(".", jPath.lastIndexOf(".") - 1);
1398
- this.tagsNodeStack.pop();
1399
- } else {
1400
- propIndex = jPath.lastIndexOf(".");
1363
+ const attrsRegx = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
1364
+ function buildAttributesMap(attrStr, jPath, tagName) {
1365
+ if (this.options.ignoreAttributes !== true && typeof attrStr === "string") {
1366
+ const matches = util2.getAllMatches(attrStr, attrsRegx);
1367
+ const len = matches.length;
1368
+ const attrs = {};
1369
+ for (let i = 0; i < len; i++) {
1370
+ const attrName = this.resolveNameSpace(matches[i][1]);
1371
+ if (this.ignoreAttributesFn(attrName, jPath)) {
1372
+ continue;
1401
1373
  }
1402
- jPath = jPath.substring(0, propIndex);
1403
- currentNode = this.tagsNodeStack.pop();
1404
- textData = "";
1405
- i = closeIndex;
1406
- } else if (xmlData[i + 1] === "?") {
1407
- let tagData = readTagExp(xmlData, i, false, "?>");
1408
- if (!tagData) throw new Error("Pi Tag is not closed.");
1409
- textData = this.saveTextToParentTag(textData, currentNode, jPath);
1410
- if (this.options.ignoreDeclaration && tagData.tagName === "?xml" || this.options.ignorePiTags) ;
1411
- else {
1412
- const childNode = new xmlNode(tagData.tagName);
1413
- childNode.add(this.options.textNodeName, "");
1414
- if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent) {
1415
- childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath, tagData.tagName);
1374
+ let oldVal = matches[i][4];
1375
+ let aName = this.options.attributeNamePrefix + attrName;
1376
+ if (attrName.length) {
1377
+ if (this.options.transformAttributeName) {
1378
+ aName = this.options.transformAttributeName(aName);
1379
+ }
1380
+ if (aName === "__proto__") aName = "#__proto__";
1381
+ if (oldVal !== void 0) {
1382
+ if (this.options.trimValues) {
1383
+ oldVal = oldVal.trim();
1384
+ }
1385
+ oldVal = this.replaceEntitiesValue(oldVal);
1386
+ const newVal = this.options.attributeValueProcessor(attrName, oldVal, jPath);
1387
+ if (newVal === null || newVal === void 0) {
1388
+ attrs[aName] = oldVal;
1389
+ } else if (typeof newVal !== typeof oldVal || newVal !== oldVal) {
1390
+ attrs[aName] = newVal;
1391
+ } else {
1392
+ attrs[aName] = parseValue(
1393
+ oldVal,
1394
+ this.options.parseAttributeValue,
1395
+ this.options.numberParseOptions
1396
+ );
1397
+ }
1398
+ } else if (this.options.allowBooleanAttributes) {
1399
+ attrs[aName] = true;
1416
1400
  }
1417
- this.addChild(currentNode, childNode, jPath);
1418
- }
1419
- i = tagData.closeIndex + 1;
1420
- } else if (xmlData.substr(i + 1, 3) === "!--") {
1421
- const endIndex = findClosingIndex(xmlData, "-->", i + 4, "Comment is not closed.");
1422
- if (this.options.commentPropName) {
1423
- const comment = xmlData.substring(i + 4, endIndex - 2);
1424
- textData = this.saveTextToParentTag(textData, currentNode, jPath);
1425
- currentNode.add(this.options.commentPropName, [{ [this.options.textNodeName]: comment }]);
1426
1401
  }
1427
- i = endIndex;
1428
- } else if (xmlData.substr(i + 1, 2) === "!D") {
1429
- const result = readDocType(xmlData, i);
1430
- this.docTypeEntities = result.entities;
1431
- i = result.i;
1432
- } else if (xmlData.substr(i + 1, 2) === "![") {
1433
- const closeIndex = findClosingIndex(xmlData, "]]>", i, "CDATA is not closed.") - 2;
1434
- const tagExp = xmlData.substring(i + 9, closeIndex);
1435
- textData = this.saveTextToParentTag(textData, currentNode, jPath);
1436
- let val2 = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true, true);
1437
- if (val2 == void 0) val2 = "";
1438
- if (this.options.cdataPropName) {
1439
- currentNode.add(this.options.cdataPropName, [{ [this.options.textNodeName]: tagExp }]);
1440
- } else {
1441
- currentNode.add(this.options.textNodeName, val2);
1442
- }
1443
- i = closeIndex + 2;
1444
- } else {
1445
- let result = readTagExp(xmlData, i, this.options.removeNSPrefix);
1446
- let tagName = result.tagName;
1447
- const rawTagName = result.rawTagName;
1448
- let tagExp = result.tagExp;
1449
- let attrExpPresent = result.attrExpPresent;
1450
- let closeIndex = result.closeIndex;
1451
- if (this.options.transformTagName) {
1452
- tagName = this.options.transformTagName(tagName);
1453
- }
1454
- if (currentNode && textData) {
1455
- if (currentNode.tagname !== "!xml") {
1456
- textData = this.saveTextToParentTag(textData, currentNode, jPath, false);
1402
+ }
1403
+ if (!Object.keys(attrs).length) {
1404
+ return;
1405
+ }
1406
+ if (this.options.attributesGroupName) {
1407
+ const attrCollection = {};
1408
+ attrCollection[this.options.attributesGroupName] = attrs;
1409
+ return attrCollection;
1410
+ }
1411
+ return attrs;
1412
+ }
1413
+ }
1414
+ const parseXml = function(xmlData) {
1415
+ xmlData = xmlData.replace(/\r\n?/g, "\n");
1416
+ const xmlObj = new xmlNode2("!xml");
1417
+ let currentNode = xmlObj;
1418
+ let textData = "";
1419
+ let jPath = "";
1420
+ for (let i = 0; i < xmlData.length; i++) {
1421
+ const ch = xmlData[i];
1422
+ if (ch === "<") {
1423
+ if (xmlData[i + 1] === "/") {
1424
+ const closeIndex = findClosingIndex(xmlData, ">", i, "Closing Tag is not closed.");
1425
+ let tagName = xmlData.substring(i + 2, closeIndex).trim();
1426
+ if (this.options.removeNSPrefix) {
1427
+ const colonIndex = tagName.indexOf(":");
1428
+ if (colonIndex !== -1) {
1429
+ tagName = tagName.substr(colonIndex + 1);
1430
+ }
1457
1431
  }
1458
- }
1459
- const lastTag = currentNode;
1460
- if (lastTag && this.options.unpairedTags.indexOf(lastTag.tagname) !== -1) {
1432
+ if (this.options.transformTagName) {
1433
+ tagName = this.options.transformTagName(tagName);
1434
+ }
1435
+ if (currentNode) {
1436
+ textData = this.saveTextToParentTag(textData, currentNode, jPath);
1437
+ }
1438
+ const lastTagName = jPath.substring(jPath.lastIndexOf(".") + 1);
1439
+ if (tagName && this.options.unpairedTags.indexOf(tagName) !== -1) {
1440
+ throw new Error(`Unpaired tag can not be used as closing tag: </${tagName}>`);
1441
+ }
1442
+ let propIndex = 0;
1443
+ if (lastTagName && this.options.unpairedTags.indexOf(lastTagName) !== -1) {
1444
+ propIndex = jPath.lastIndexOf(".", jPath.lastIndexOf(".") - 1);
1445
+ this.tagsNodeStack.pop();
1446
+ } else {
1447
+ propIndex = jPath.lastIndexOf(".");
1448
+ }
1449
+ jPath = jPath.substring(0, propIndex);
1461
1450
  currentNode = this.tagsNodeStack.pop();
1462
- jPath = jPath.substring(0, jPath.lastIndexOf("."));
1463
- }
1464
- if (tagName !== xmlObj.tagname) {
1465
- jPath += jPath ? "." + tagName : tagName;
1466
- }
1467
- if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) {
1468
- let tagContent = "";
1469
- if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
1470
- if (tagName[tagName.length - 1] === "/") {
1471
- tagName = tagName.substr(0, tagName.length - 1);
1472
- jPath = jPath.substr(0, jPath.length - 1);
1473
- tagExp = tagName;
1474
- } else {
1475
- tagExp = tagExp.substr(0, tagExp.length - 1);
1451
+ textData = "";
1452
+ i = closeIndex;
1453
+ } else if (xmlData[i + 1] === "?") {
1454
+ let tagData = readTagExp(xmlData, i, false, "?>");
1455
+ if (!tagData) throw new Error("Pi Tag is not closed.");
1456
+ textData = this.saveTextToParentTag(textData, currentNode, jPath);
1457
+ if (this.options.ignoreDeclaration && tagData.tagName === "?xml" || this.options.ignorePiTags) ;
1458
+ else {
1459
+ const childNode = new xmlNode2(tagData.tagName);
1460
+ childNode.add(this.options.textNodeName, "");
1461
+ if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent) {
1462
+ childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath, tagData.tagName);
1476
1463
  }
1477
- i = result.closeIndex;
1478
- } else if (this.options.unpairedTags.indexOf(tagName) !== -1) {
1479
- i = result.closeIndex;
1480
- } else {
1481
- const result2 = this.readStopNodeData(xmlData, rawTagName, closeIndex + 1);
1482
- if (!result2) throw new Error(`Unexpected end of ${rawTagName}`);
1483
- i = result2.i;
1484
- tagContent = result2.tagContent;
1464
+ this.addChild(currentNode, childNode, jPath);
1485
1465
  }
1486
- const childNode = new xmlNode(tagName);
1487
- if (tagName !== tagExp && attrExpPresent) {
1488
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
1466
+ i = tagData.closeIndex + 1;
1467
+ } else if (xmlData.substr(i + 1, 3) === "!--") {
1468
+ const endIndex = findClosingIndex(xmlData, "-->", i + 4, "Comment is not closed.");
1469
+ if (this.options.commentPropName) {
1470
+ const comment = xmlData.substring(i + 4, endIndex - 2);
1471
+ textData = this.saveTextToParentTag(textData, currentNode, jPath);
1472
+ currentNode.add(this.options.commentPropName, [{ [this.options.textNodeName]: comment }]);
1489
1473
  }
1490
- if (tagContent) {
1491
- tagContent = this.parseTextData(tagContent, tagName, jPath, true, attrExpPresent, true, true);
1474
+ i = endIndex;
1475
+ } else if (xmlData.substr(i + 1, 2) === "!D") {
1476
+ const result = readDocType(xmlData, i);
1477
+ this.docTypeEntities = result.entities;
1478
+ i = result.i;
1479
+ } else if (xmlData.substr(i + 1, 2) === "![") {
1480
+ const closeIndex = findClosingIndex(xmlData, "]]>", i, "CDATA is not closed.") - 2;
1481
+ const tagExp = xmlData.substring(i + 9, closeIndex);
1482
+ textData = this.saveTextToParentTag(textData, currentNode, jPath);
1483
+ let val = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true, true);
1484
+ if (val == void 0) val = "";
1485
+ if (this.options.cdataPropName) {
1486
+ currentNode.add(this.options.cdataPropName, [{ [this.options.textNodeName]: tagExp }]);
1487
+ } else {
1488
+ currentNode.add(this.options.textNodeName, val);
1492
1489
  }
1493
- jPath = jPath.substr(0, jPath.lastIndexOf("."));
1494
- childNode.add(this.options.textNodeName, tagContent);
1495
- this.addChild(currentNode, childNode, jPath);
1490
+ i = closeIndex + 2;
1496
1491
  } else {
1497
- if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
1498
- if (tagName[tagName.length - 1] === "/") {
1499
- tagName = tagName.substr(0, tagName.length - 1);
1500
- jPath = jPath.substr(0, jPath.length - 1);
1501
- tagExp = tagName;
1502
- } else {
1503
- tagExp = tagExp.substr(0, tagExp.length - 1);
1492
+ let result = readTagExp(xmlData, i, this.options.removeNSPrefix);
1493
+ let tagName = result.tagName;
1494
+ const rawTagName = result.rawTagName;
1495
+ let tagExp = result.tagExp;
1496
+ let attrExpPresent = result.attrExpPresent;
1497
+ let closeIndex = result.closeIndex;
1498
+ if (this.options.transformTagName) {
1499
+ tagName = this.options.transformTagName(tagName);
1500
+ }
1501
+ if (currentNode && textData) {
1502
+ if (currentNode.tagname !== "!xml") {
1503
+ textData = this.saveTextToParentTag(textData, currentNode, jPath, false);
1504
1504
  }
1505
- if (this.options.transformTagName) {
1506
- tagName = this.options.transformTagName(tagName);
1505
+ }
1506
+ const lastTag = currentNode;
1507
+ if (lastTag && this.options.unpairedTags.indexOf(lastTag.tagname) !== -1) {
1508
+ currentNode = this.tagsNodeStack.pop();
1509
+ jPath = jPath.substring(0, jPath.lastIndexOf("."));
1510
+ }
1511
+ if (tagName !== xmlObj.tagname) {
1512
+ jPath += jPath ? "." + tagName : tagName;
1513
+ }
1514
+ if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) {
1515
+ let tagContent = "";
1516
+ if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
1517
+ if (tagName[tagName.length - 1] === "/") {
1518
+ tagName = tagName.substr(0, tagName.length - 1);
1519
+ jPath = jPath.substr(0, jPath.length - 1);
1520
+ tagExp = tagName;
1521
+ } else {
1522
+ tagExp = tagExp.substr(0, tagExp.length - 1);
1523
+ }
1524
+ i = result.closeIndex;
1525
+ } else if (this.options.unpairedTags.indexOf(tagName) !== -1) {
1526
+ i = result.closeIndex;
1527
+ } else {
1528
+ const result2 = this.readStopNodeData(xmlData, rawTagName, closeIndex + 1);
1529
+ if (!result2) throw new Error(`Unexpected end of ${rawTagName}`);
1530
+ i = result2.i;
1531
+ tagContent = result2.tagContent;
1507
1532
  }
1508
- const childNode = new xmlNode(tagName);
1533
+ const childNode = new xmlNode2(tagName);
1509
1534
  if (tagName !== tagExp && attrExpPresent) {
1510
1535
  childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
1511
1536
  }
1512
- this.addChild(currentNode, childNode, jPath);
1537
+ if (tagContent) {
1538
+ tagContent = this.parseTextData(tagContent, tagName, jPath, true, attrExpPresent, true, true);
1539
+ }
1513
1540
  jPath = jPath.substr(0, jPath.lastIndexOf("."));
1541
+ childNode.add(this.options.textNodeName, tagContent);
1542
+ this.addChild(currentNode, childNode, jPath);
1514
1543
  } else {
1515
- const childNode = new xmlNode(tagName);
1516
- this.tagsNodeStack.push(currentNode);
1517
- if (tagName !== tagExp && attrExpPresent) {
1518
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
1544
+ if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
1545
+ if (tagName[tagName.length - 1] === "/") {
1546
+ tagName = tagName.substr(0, tagName.length - 1);
1547
+ jPath = jPath.substr(0, jPath.length - 1);
1548
+ tagExp = tagName;
1549
+ } else {
1550
+ tagExp = tagExp.substr(0, tagExp.length - 1);
1551
+ }
1552
+ if (this.options.transformTagName) {
1553
+ tagName = this.options.transformTagName(tagName);
1554
+ }
1555
+ const childNode = new xmlNode2(tagName);
1556
+ if (tagName !== tagExp && attrExpPresent) {
1557
+ childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
1558
+ }
1559
+ this.addChild(currentNode, childNode, jPath);
1560
+ jPath = jPath.substr(0, jPath.lastIndexOf("."));
1561
+ } else {
1562
+ const childNode = new xmlNode2(tagName);
1563
+ this.tagsNodeStack.push(currentNode);
1564
+ if (tagName !== tagExp && attrExpPresent) {
1565
+ childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
1566
+ }
1567
+ this.addChild(currentNode, childNode, jPath);
1568
+ currentNode = childNode;
1519
1569
  }
1520
- this.addChild(currentNode, childNode, jPath);
1521
- currentNode = childNode;
1570
+ textData = "";
1571
+ i = closeIndex;
1522
1572
  }
1523
- textData = "";
1524
- i = closeIndex;
1525
1573
  }
1574
+ } else {
1575
+ textData += xmlData[i];
1526
1576
  }
1577
+ }
1578
+ return xmlObj.child;
1579
+ };
1580
+ function addChild(currentNode, childNode, jPath) {
1581
+ const result = this.options.updateTag(childNode.tagname, jPath, childNode[":@"]);
1582
+ if (result === false) ;
1583
+ else if (typeof result === "string") {
1584
+ childNode.tagname = result;
1585
+ currentNode.addChild(childNode);
1527
1586
  } else {
1528
- textData += xmlData[i];
1587
+ currentNode.addChild(childNode);
1529
1588
  }
1530
1589
  }
1531
- return xmlObj.child;
1532
- };
1533
- function addChild(currentNode, childNode, jPath) {
1534
- const result = this.options.updateTag(childNode.tagname, jPath, childNode[":@"]);
1535
- if (result === false) ;
1536
- else if (typeof result === "string") {
1537
- childNode.tagname = result;
1538
- currentNode.addChild(childNode);
1539
- } else {
1540
- currentNode.addChild(childNode);
1541
- }
1542
- }
1543
- const replaceEntitiesValue$1 = function(val2) {
1544
- if (this.options.processEntities) {
1545
- for (let entityName2 in this.docTypeEntities) {
1546
- const entity = this.docTypeEntities[entityName2];
1547
- val2 = val2.replace(entity.regx, entity.val);
1548
- }
1549
- for (let entityName2 in this.lastEntities) {
1550
- const entity = this.lastEntities[entityName2];
1551
- val2 = val2.replace(entity.regex, entity.val);
1552
- }
1553
- if (this.options.htmlEntities) {
1554
- for (let entityName2 in this.htmlEntities) {
1555
- const entity = this.htmlEntities[entityName2];
1556
- val2 = val2.replace(entity.regex, entity.val);
1590
+ const replaceEntitiesValue = function(val) {
1591
+ if (this.options.processEntities) {
1592
+ for (let entityName in this.docTypeEntities) {
1593
+ const entity = this.docTypeEntities[entityName];
1594
+ val = val.replace(entity.regx, entity.val);
1595
+ }
1596
+ for (let entityName in this.lastEntities) {
1597
+ const entity = this.lastEntities[entityName];
1598
+ val = val.replace(entity.regex, entity.val);
1557
1599
  }
1600
+ if (this.options.htmlEntities) {
1601
+ for (let entityName in this.htmlEntities) {
1602
+ const entity = this.htmlEntities[entityName];
1603
+ val = val.replace(entity.regex, entity.val);
1604
+ }
1605
+ }
1606
+ val = val.replace(this.ampEntity.regex, this.ampEntity.val);
1558
1607
  }
1559
- val2 = val2.replace(this.ampEntity.regex, this.ampEntity.val);
1560
- }
1561
- return val2;
1562
- };
1563
- function saveTextToParentTag(textData, currentNode, jPath, isLeafNode) {
1564
- if (textData) {
1565
- if (isLeafNode === void 0) isLeafNode = Object.keys(currentNode.child).length === 0;
1566
- textData = this.parseTextData(
1567
- textData,
1568
- currentNode.tagname,
1569
- jPath,
1570
- false,
1571
- currentNode[":@"] ? Object.keys(currentNode[":@"]).length !== 0 : false,
1572
- isLeafNode
1573
- );
1574
- if (textData !== void 0 && textData !== "")
1575
- currentNode.add(this.options.textNodeName, textData);
1576
- textData = "";
1608
+ return val;
1609
+ };
1610
+ function saveTextToParentTag(textData, currentNode, jPath, isLeafNode) {
1611
+ if (textData) {
1612
+ if (isLeafNode === void 0) isLeafNode = Object.keys(currentNode.child).length === 0;
1613
+ textData = this.parseTextData(
1614
+ textData,
1615
+ currentNode.tagname,
1616
+ jPath,
1617
+ false,
1618
+ currentNode[":@"] ? Object.keys(currentNode[":@"]).length !== 0 : false,
1619
+ isLeafNode
1620
+ );
1621
+ if (textData !== void 0 && textData !== "")
1622
+ currentNode.add(this.options.textNodeName, textData);
1623
+ textData = "";
1624
+ }
1625
+ return textData;
1577
1626
  }
1578
- return textData;
1579
- }
1580
- function isItStopNode(stopNodes, jPath, currentTagName) {
1581
- const allNodesExp = "*." + currentTagName;
1582
- for (const stopNodePath in stopNodes) {
1583
- const stopNodeExp = stopNodes[stopNodePath];
1584
- if (allNodesExp === stopNodeExp || jPath === stopNodeExp) return true;
1627
+ function isItStopNode(stopNodes, jPath, currentTagName) {
1628
+ const allNodesExp = "*." + currentTagName;
1629
+ for (const stopNodePath in stopNodes) {
1630
+ const stopNodeExp = stopNodes[stopNodePath];
1631
+ if (allNodesExp === stopNodeExp || jPath === stopNodeExp) return true;
1632
+ }
1633
+ return false;
1585
1634
  }
1586
- return false;
1587
- }
1588
- function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
1589
- let attrBoundary;
1590
- let tagExp = "";
1591
- for (let index = i; index < xmlData.length; index++) {
1592
- let ch = xmlData[index];
1593
- if (attrBoundary) {
1594
- if (ch === attrBoundary) attrBoundary = "";
1595
- } else if (ch === '"' || ch === "'") {
1596
- attrBoundary = ch;
1597
- } else if (ch === closingChar[0]) {
1598
- if (closingChar[1]) {
1599
- if (xmlData[index + 1] === closingChar[1]) {
1635
+ function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
1636
+ let attrBoundary;
1637
+ let tagExp = "";
1638
+ for (let index = i; index < xmlData.length; index++) {
1639
+ let ch = xmlData[index];
1640
+ if (attrBoundary) {
1641
+ if (ch === attrBoundary) attrBoundary = "";
1642
+ } else if (ch === '"' || ch === "'") {
1643
+ attrBoundary = ch;
1644
+ } else if (ch === closingChar[0]) {
1645
+ if (closingChar[1]) {
1646
+ if (xmlData[index + 1] === closingChar[1]) {
1647
+ return {
1648
+ data: tagExp,
1649
+ index
1650
+ };
1651
+ }
1652
+ } else {
1600
1653
  return {
1601
1654
  data: tagExp,
1602
1655
  index
1603
1656
  };
1604
1657
  }
1605
- } else {
1606
- return {
1607
- data: tagExp,
1608
- index
1609
- };
1658
+ } else if (ch === " ") {
1659
+ ch = " ";
1610
1660
  }
1611
- } else if (ch === " ") {
1612
- ch = " ";
1661
+ tagExp += ch;
1613
1662
  }
1614
- tagExp += ch;
1615
1663
  }
1616
- }
1617
- function findClosingIndex(xmlData, str, i, errMsg) {
1618
- const closingIndex = xmlData.indexOf(str, i);
1619
- if (closingIndex === -1) {
1620
- throw new Error(errMsg);
1621
- } else {
1622
- return closingIndex + str.length - 1;
1664
+ function findClosingIndex(xmlData, str, i, errMsg) {
1665
+ const closingIndex = xmlData.indexOf(str, i);
1666
+ if (closingIndex === -1) {
1667
+ throw new Error(errMsg);
1668
+ } else {
1669
+ return closingIndex + str.length - 1;
1670
+ }
1671
+ }
1672
+ function readTagExp(xmlData, i, removeNSPrefix, closingChar = ">") {
1673
+ const result = tagExpWithClosingIndex(xmlData, i + 1, closingChar);
1674
+ if (!result) return;
1675
+ let tagExp = result.data;
1676
+ const closeIndex = result.index;
1677
+ const separatorIndex = tagExp.search(/\s/);
1678
+ let tagName = tagExp;
1679
+ let attrExpPresent = true;
1680
+ if (separatorIndex !== -1) {
1681
+ tagName = tagExp.substring(0, separatorIndex);
1682
+ tagExp = tagExp.substring(separatorIndex + 1).trimStart();
1683
+ }
1684
+ const rawTagName = tagName;
1685
+ if (removeNSPrefix) {
1686
+ const colonIndex = tagName.indexOf(":");
1687
+ if (colonIndex !== -1) {
1688
+ tagName = tagName.substr(colonIndex + 1);
1689
+ attrExpPresent = tagName !== result.data.substr(colonIndex + 1);
1690
+ }
1691
+ }
1692
+ return {
1693
+ tagName,
1694
+ tagExp,
1695
+ closeIndex,
1696
+ attrExpPresent,
1697
+ rawTagName
1698
+ };
1623
1699
  }
1624
- }
1625
- function readTagExp(xmlData, i, removeNSPrefix, closingChar = ">") {
1626
- const result = tagExpWithClosingIndex(xmlData, i + 1, closingChar);
1627
- if (!result) return;
1628
- let tagExp = result.data;
1629
- const closeIndex = result.index;
1630
- const separatorIndex = tagExp.search(/\s/);
1631
- let tagName = tagExp;
1632
- let attrExpPresent = true;
1633
- if (separatorIndex !== -1) {
1634
- tagName = tagExp.substring(0, separatorIndex);
1635
- tagExp = tagExp.substring(separatorIndex + 1).trimStart();
1636
- }
1637
- const rawTagName = tagName;
1638
- if (removeNSPrefix) {
1639
- const colonIndex = tagName.indexOf(":");
1640
- if (colonIndex !== -1) {
1641
- tagName = tagName.substr(colonIndex + 1);
1642
- attrExpPresent = tagName !== result.data.substr(colonIndex + 1);
1643
- }
1644
- }
1645
- return {
1646
- tagName,
1647
- tagExp,
1648
- closeIndex,
1649
- attrExpPresent,
1650
- rawTagName
1651
- };
1652
- }
1653
- function readStopNodeData(xmlData, tagName, i) {
1654
- const startIndex = i;
1655
- let openTagCount = 1;
1656
- for (; i < xmlData.length; i++) {
1657
- if (xmlData[i] === "<") {
1658
- if (xmlData[i + 1] === "/") {
1659
- const closeIndex = findClosingIndex(xmlData, ">", i, `${tagName} is not closed`);
1660
- let closeTagName = xmlData.substring(i + 2, closeIndex).trim();
1661
- if (closeTagName === tagName) {
1662
- openTagCount--;
1663
- if (openTagCount === 0) {
1664
- return {
1665
- tagContent: xmlData.substring(startIndex, i),
1666
- i: closeIndex
1667
- };
1700
+ function readStopNodeData(xmlData, tagName, i) {
1701
+ const startIndex = i;
1702
+ let openTagCount = 1;
1703
+ for (; i < xmlData.length; i++) {
1704
+ if (xmlData[i] === "<") {
1705
+ if (xmlData[i + 1] === "/") {
1706
+ const closeIndex = findClosingIndex(xmlData, ">", i, `${tagName} is not closed`);
1707
+ let closeTagName = xmlData.substring(i + 2, closeIndex).trim();
1708
+ if (closeTagName === tagName) {
1709
+ openTagCount--;
1710
+ if (openTagCount === 0) {
1711
+ return {
1712
+ tagContent: xmlData.substring(startIndex, i),
1713
+ i: closeIndex
1714
+ };
1715
+ }
1668
1716
  }
1669
- }
1670
- i = closeIndex;
1671
- } else if (xmlData[i + 1] === "?") {
1672
- const closeIndex = findClosingIndex(xmlData, "?>", i + 1, "StopNode is not closed.");
1673
- i = closeIndex;
1674
- } else if (xmlData.substr(i + 1, 3) === "!--") {
1675
- const closeIndex = findClosingIndex(xmlData, "-->", i + 3, "StopNode is not closed.");
1676
- i = closeIndex;
1677
- } else if (xmlData.substr(i + 1, 2) === "![") {
1678
- const closeIndex = findClosingIndex(xmlData, "]]>", i, "StopNode is not closed.") - 2;
1679
- i = closeIndex;
1680
- } else {
1681
- const tagData = readTagExp(xmlData, i, ">");
1682
- if (tagData) {
1683
- const openTagName = tagData && tagData.tagName;
1684
- if (openTagName === tagName && tagData.tagExp[tagData.tagExp.length - 1] !== "/") {
1685
- openTagCount++;
1717
+ i = closeIndex;
1718
+ } else if (xmlData[i + 1] === "?") {
1719
+ const closeIndex = findClosingIndex(xmlData, "?>", i + 1, "StopNode is not closed.");
1720
+ i = closeIndex;
1721
+ } else if (xmlData.substr(i + 1, 3) === "!--") {
1722
+ const closeIndex = findClosingIndex(xmlData, "-->", i + 3, "StopNode is not closed.");
1723
+ i = closeIndex;
1724
+ } else if (xmlData.substr(i + 1, 2) === "![") {
1725
+ const closeIndex = findClosingIndex(xmlData, "]]>", i, "StopNode is not closed.") - 2;
1726
+ i = closeIndex;
1727
+ } else {
1728
+ const tagData = readTagExp(xmlData, i, ">");
1729
+ if (tagData) {
1730
+ const openTagName = tagData && tagData.tagName;
1731
+ if (openTagName === tagName && tagData.tagExp[tagData.tagExp.length - 1] !== "/") {
1732
+ openTagCount++;
1733
+ }
1734
+ i = tagData.closeIndex;
1686
1735
  }
1687
- i = tagData.closeIndex;
1688
1736
  }
1689
1737
  }
1690
1738
  }
1691
1739
  }
1692
- }
1693
- function parseValue(val2, shouldParse, options) {
1694
- if (shouldParse && typeof val2 === "string") {
1695
- const newval = val2.trim();
1696
- if (newval === "true") return true;
1697
- else if (newval === "false") return false;
1698
- else return toNumber(val2, options);
1699
- } else {
1700
- if (util.isExist(val2)) {
1701
- return val2;
1740
+ function parseValue(val, shouldParse, options) {
1741
+ if (shouldParse && typeof val === "string") {
1742
+ const newval = val.trim();
1743
+ if (newval === "true") return true;
1744
+ else if (newval === "false") return false;
1745
+ else return toNumber(val, options);
1702
1746
  } else {
1703
- return "";
1747
+ if (util2.isExist(val)) {
1748
+ return val;
1749
+ } else {
1750
+ return "";
1751
+ }
1704
1752
  }
1705
1753
  }
1754
+ OrderedObjParser_1 = OrderedObjParser;
1755
+ return OrderedObjParser_1;
1706
1756
  }
1707
- var OrderedObjParser_1 = OrderedObjParser$1;
1708
1757
  var node2json = {};
1709
- function prettify$1(node, options) {
1710
- return compress(node, options);
1711
- }
1712
- function compress(arr, options, jPath) {
1713
- let text;
1714
- const compressedObj = {};
1715
- for (let i = 0; i < arr.length; i++) {
1716
- const tagObj = arr[i];
1717
- const property = propName$1(tagObj);
1718
- let newJpath = "";
1719
- if (jPath === void 0) newJpath = property;
1720
- else newJpath = jPath + "." + property;
1721
- if (property === options.textNodeName) {
1722
- if (text === void 0) text = tagObj[property];
1723
- else text += "" + tagObj[property];
1724
- } else if (property === void 0) {
1725
- continue;
1726
- } else if (tagObj[property]) {
1727
- let val2 = compress(tagObj[property], options, newJpath);
1728
- const isLeaf = isLeafTag(val2, options);
1729
- if (tagObj[":@"]) {
1730
- assignAttributes(val2, tagObj[":@"], newJpath, options);
1731
- } else if (Object.keys(val2).length === 1 && val2[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
1732
- val2 = val2[options.textNodeName];
1733
- } else if (Object.keys(val2).length === 0) {
1734
- if (options.alwaysCreateTextNode) val2[options.textNodeName] = "";
1735
- else val2 = "";
1736
- }
1737
- if (compressedObj[property] !== void 0 && compressedObj.hasOwnProperty(property)) {
1738
- if (!Array.isArray(compressedObj[property])) {
1739
- compressedObj[property] = [compressedObj[property]];
1758
+ var hasRequiredNode2json;
1759
+ function requireNode2json() {
1760
+ if (hasRequiredNode2json) return node2json;
1761
+ hasRequiredNode2json = 1;
1762
+ function prettify(node, options) {
1763
+ return compress(node, options);
1764
+ }
1765
+ function compress(arr, options, jPath) {
1766
+ let text;
1767
+ const compressedObj = {};
1768
+ for (let i = 0; i < arr.length; i++) {
1769
+ const tagObj = arr[i];
1770
+ const property = propName(tagObj);
1771
+ let newJpath = "";
1772
+ if (jPath === void 0) newJpath = property;
1773
+ else newJpath = jPath + "." + property;
1774
+ if (property === options.textNodeName) {
1775
+ if (text === void 0) text = tagObj[property];
1776
+ else text += "" + tagObj[property];
1777
+ } else if (property === void 0) {
1778
+ continue;
1779
+ } else if (tagObj[property]) {
1780
+ let val = compress(tagObj[property], options, newJpath);
1781
+ const isLeaf = isLeafTag(val, options);
1782
+ if (tagObj[":@"]) {
1783
+ assignAttributes(val, tagObj[":@"], newJpath, options);
1784
+ } else if (Object.keys(val).length === 1 && val[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
1785
+ val = val[options.textNodeName];
1786
+ } else if (Object.keys(val).length === 0) {
1787
+ if (options.alwaysCreateTextNode) val[options.textNodeName] = "";
1788
+ else val = "";
1740
1789
  }
1741
- compressedObj[property].push(val2);
1742
- } else {
1743
- if (options.isArray(property, newJpath, isLeaf)) {
1744
- compressedObj[property] = [val2];
1790
+ if (compressedObj[property] !== void 0 && compressedObj.hasOwnProperty(property)) {
1791
+ if (!Array.isArray(compressedObj[property])) {
1792
+ compressedObj[property] = [compressedObj[property]];
1793
+ }
1794
+ compressedObj[property].push(val);
1745
1795
  } else {
1746
- compressedObj[property] = val2;
1796
+ if (options.isArray(property, newJpath, isLeaf)) {
1797
+ compressedObj[property] = [val];
1798
+ } else {
1799
+ compressedObj[property] = val;
1800
+ }
1747
1801
  }
1748
1802
  }
1749
1803
  }
1804
+ if (typeof text === "string") {
1805
+ if (text.length > 0) compressedObj[options.textNodeName] = text;
1806
+ } else if (text !== void 0) compressedObj[options.textNodeName] = text;
1807
+ return compressedObj;
1750
1808
  }
1751
- if (typeof text === "string") {
1752
- if (text.length > 0) compressedObj[options.textNodeName] = text;
1753
- } else if (text !== void 0) compressedObj[options.textNodeName] = text;
1754
- return compressedObj;
1755
- }
1756
- function propName$1(obj) {
1757
- const keys = Object.keys(obj);
1758
- for (let i = 0; i < keys.length; i++) {
1759
- const key = keys[i];
1760
- if (key !== ":@") return key;
1761
- }
1762
- }
1763
- function assignAttributes(obj, attrMap, jpath, options) {
1764
- if (attrMap) {
1765
- const keys = Object.keys(attrMap);
1766
- const len = keys.length;
1767
- for (let i = 0; i < len; i++) {
1768
- const atrrName = keys[i];
1769
- if (options.isArray(atrrName, jpath + "." + atrrName, true, true)) {
1770
- obj[atrrName] = [attrMap[atrrName]];
1771
- } else {
1772
- obj[atrrName] = attrMap[atrrName];
1773
- }
1809
+ function propName(obj) {
1810
+ const keys = Object.keys(obj);
1811
+ for (let i = 0; i < keys.length; i++) {
1812
+ const key = keys[i];
1813
+ if (key !== ":@") return key;
1774
1814
  }
1775
1815
  }
1776
- }
1777
- function isLeafTag(obj, options) {
1778
- const { textNodeName } = options;
1779
- const propCount = Object.keys(obj).length;
1780
- if (propCount === 0) {
1781
- return true;
1782
- }
1783
- if (propCount === 1 && (obj[textNodeName] || typeof obj[textNodeName] === "boolean" || obj[textNodeName] === 0)) {
1784
- return true;
1785
- }
1786
- return false;
1787
- }
1788
- node2json.prettify = prettify$1;
1789
- const { buildOptions } = OptionsBuilder;
1790
- const OrderedObjParser2 = OrderedObjParser_1;
1791
- const { prettify } = node2json;
1792
- const validator$1 = validator$2;
1793
- let XMLParser$1 = class XMLParser {
1794
- constructor(options) {
1795
- this.externalEntities = {};
1796
- this.options = buildOptions(options);
1797
- }
1798
- /**
1799
- * Parse XML dats to JS object
1800
- * @param {string|Buffer} xmlData
1801
- * @param {boolean|Object} validationOption
1802
- */
1803
- parse(xmlData, validationOption) {
1804
- if (typeof xmlData === "string") ;
1805
- else if (xmlData.toString) {
1806
- xmlData = xmlData.toString();
1807
- } else {
1808
- throw new Error("XML data is accepted in String or Bytes[] form.");
1809
- }
1810
- if (validationOption) {
1811
- if (validationOption === true) validationOption = {};
1812
- const result = validator$1.validate(xmlData, validationOption);
1813
- if (result !== true) {
1814
- throw Error(`${result.err.msg}:${result.err.line}:${result.err.col}`);
1816
+ function assignAttributes(obj, attrMap, jpath, options) {
1817
+ if (attrMap) {
1818
+ const keys = Object.keys(attrMap);
1819
+ const len = keys.length;
1820
+ for (let i = 0; i < len; i++) {
1821
+ const atrrName = keys[i];
1822
+ if (options.isArray(atrrName, jpath + "." + atrrName, true, true)) {
1823
+ obj[atrrName] = [attrMap[atrrName]];
1824
+ } else {
1825
+ obj[atrrName] = attrMap[atrrName];
1826
+ }
1815
1827
  }
1816
1828
  }
1817
- const orderedObjParser = new OrderedObjParser2(this.options);
1818
- orderedObjParser.addExternalEntities(this.externalEntities);
1819
- const orderedResult = orderedObjParser.parseXml(xmlData);
1820
- if (this.options.preserveOrder || orderedResult === void 0) return orderedResult;
1821
- else return prettify(orderedResult, this.options);
1822
1829
  }
1823
- /**
1824
- * Add Entity which is not by default supported by this library
1825
- * @param {string} key
1826
- * @param {string} value
1827
- */
1828
- addEntity(key, value) {
1829
- if (value.indexOf("&") !== -1) {
1830
- throw new Error("Entity value can't have '&'");
1831
- } else if (key.indexOf("&") !== -1 || key.indexOf(";") !== -1) {
1832
- throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");
1833
- } else if (value === "&") {
1834
- throw new Error("An entity with value '&' is not permitted");
1835
- } else {
1836
- this.externalEntities[key] = value;
1830
+ function isLeafTag(obj, options) {
1831
+ const { textNodeName } = options;
1832
+ const propCount = Object.keys(obj).length;
1833
+ if (propCount === 0) {
1834
+ return true;
1835
+ }
1836
+ if (propCount === 1 && (obj[textNodeName] || typeof obj[textNodeName] === "boolean" || obj[textNodeName] === 0)) {
1837
+ return true;
1837
1838
  }
1839
+ return false;
1838
1840
  }
1839
- };
1840
- var XMLParser_1 = XMLParser$1;
1841
- const EOL = "\n";
1842
- function toXml(jArray, options) {
1843
- let indentation = "";
1844
- if (options.format && options.indentBy.length > 0) {
1845
- indentation = EOL;
1846
- }
1847
- return arrToStr(jArray, options, "", indentation);
1848
- }
1849
- function arrToStr(arr, options, jPath, indentation) {
1850
- let xmlStr = "";
1851
- let isPreviousElementTag = false;
1852
- for (let i = 0; i < arr.length; i++) {
1853
- const tagObj = arr[i];
1854
- const tagName = propName(tagObj);
1855
- if (tagName === void 0) continue;
1856
- let newJPath = "";
1857
- if (jPath.length === 0) newJPath = tagName;
1858
- else newJPath = `${jPath}.${tagName}`;
1859
- if (tagName === options.textNodeName) {
1860
- let tagText = tagObj[tagName];
1861
- if (!isStopNode(newJPath, options)) {
1862
- tagText = options.tagValueProcessor(tagName, tagText);
1863
- tagText = replaceEntitiesValue(tagText, options);
1864
- }
1865
- if (isPreviousElementTag) {
1866
- xmlStr += indentation;
1867
- }
1868
- xmlStr += tagText;
1869
- isPreviousElementTag = false;
1870
- continue;
1871
- } else if (tagName === options.cdataPropName) {
1872
- if (isPreviousElementTag) {
1873
- xmlStr += indentation;
1874
- }
1875
- xmlStr += `<![CDATA[${tagObj[tagName][0][options.textNodeName]}]]>`;
1876
- isPreviousElementTag = false;
1877
- continue;
1878
- } else if (tagName === options.commentPropName) {
1879
- xmlStr += indentation + `<!--${tagObj[tagName][0][options.textNodeName]}-->`;
1880
- isPreviousElementTag = true;
1881
- continue;
1882
- } else if (tagName[0] === "?") {
1883
- const attStr2 = attr_to_str(tagObj[":@"], options);
1884
- const tempInd = tagName === "?xml" ? "" : indentation;
1885
- let piTextNodeName = tagObj[tagName][0][options.textNodeName];
1886
- piTextNodeName = piTextNodeName.length !== 0 ? " " + piTextNodeName : "";
1887
- xmlStr += tempInd + `<${tagName}${piTextNodeName}${attStr2}?>`;
1888
- isPreviousElementTag = true;
1889
- continue;
1890
- }
1891
- let newIdentation = indentation;
1892
- if (newIdentation !== "") {
1893
- newIdentation += options.indentBy;
1894
- }
1895
- const attStr = attr_to_str(tagObj[":@"], options);
1896
- const tagStart = indentation + `<${tagName}${attStr}`;
1897
- const tagValue = arrToStr(tagObj[tagName], options, newJPath, newIdentation);
1898
- if (options.unpairedTags.indexOf(tagName) !== -1) {
1899
- if (options.suppressUnpairedNode) xmlStr += tagStart + ">";
1900
- else xmlStr += tagStart + "/>";
1901
- } else if ((!tagValue || tagValue.length === 0) && options.suppressEmptyNode) {
1902
- xmlStr += tagStart + "/>";
1903
- } else if (tagValue && tagValue.endsWith(">")) {
1904
- xmlStr += tagStart + `>${tagValue}${indentation}</${tagName}>`;
1905
- } else {
1906
- xmlStr += tagStart + ">";
1907
- if (tagValue && indentation !== "" && (tagValue.includes("/>") || tagValue.includes("</"))) {
1908
- xmlStr += indentation + options.indentBy + tagValue + indentation;
1841
+ node2json.prettify = prettify;
1842
+ return node2json;
1843
+ }
1844
+ var XMLParser_1;
1845
+ var hasRequiredXMLParser;
1846
+ function requireXMLParser() {
1847
+ if (hasRequiredXMLParser) return XMLParser_1;
1848
+ hasRequiredXMLParser = 1;
1849
+ const { buildOptions } = requireOptionsBuilder();
1850
+ const OrderedObjParser = requireOrderedObjParser();
1851
+ const { prettify } = requireNode2json();
1852
+ const validator2 = requireValidator();
1853
+ class XMLParser {
1854
+ constructor(options) {
1855
+ this.externalEntities = {};
1856
+ this.options = buildOptions(options);
1857
+ }
1858
+ /**
1859
+ * Parse XML dats to JS object
1860
+ * @param {string|Buffer} xmlData
1861
+ * @param {boolean|Object} validationOption
1862
+ */
1863
+ parse(xmlData, validationOption) {
1864
+ if (typeof xmlData === "string") ;
1865
+ else if (xmlData.toString) {
1866
+ xmlData = xmlData.toString();
1909
1867
  } else {
1910
- xmlStr += tagValue;
1868
+ throw new Error("XML data is accepted in String or Bytes[] form.");
1869
+ }
1870
+ if (validationOption) {
1871
+ if (validationOption === true) validationOption = {};
1872
+ const result = validator2.validate(xmlData, validationOption);
1873
+ if (result !== true) {
1874
+ throw Error(`${result.err.msg}:${result.err.line}:${result.err.col}`);
1875
+ }
1876
+ }
1877
+ const orderedObjParser = new OrderedObjParser(this.options);
1878
+ orderedObjParser.addExternalEntities(this.externalEntities);
1879
+ const orderedResult = orderedObjParser.parseXml(xmlData);
1880
+ if (this.options.preserveOrder || orderedResult === void 0) return orderedResult;
1881
+ else return prettify(orderedResult, this.options);
1882
+ }
1883
+ /**
1884
+ * Add Entity which is not by default supported by this library
1885
+ * @param {string} key
1886
+ * @param {string} value
1887
+ */
1888
+ addEntity(key, value) {
1889
+ if (value.indexOf("&") !== -1) {
1890
+ throw new Error("Entity value can't have '&'");
1891
+ } else if (key.indexOf("&") !== -1 || key.indexOf(";") !== -1) {
1892
+ throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");
1893
+ } else if (value === "&") {
1894
+ throw new Error("An entity with value '&' is not permitted");
1895
+ } else {
1896
+ this.externalEntities[key] = value;
1911
1897
  }
1912
- xmlStr += `</${tagName}>`;
1913
1898
  }
1914
- isPreviousElementTag = true;
1915
- }
1916
- return xmlStr;
1917
- }
1918
- function propName(obj) {
1919
- const keys = Object.keys(obj);
1920
- for (let i = 0; i < keys.length; i++) {
1921
- const key = keys[i];
1922
- if (!obj.hasOwnProperty(key)) continue;
1923
- if (key !== ":@") return key;
1924
1899
  }
1925
- }
1926
- function attr_to_str(attrMap, options) {
1927
- let attrStr = "";
1928
- if (attrMap && !options.ignoreAttributes) {
1929
- for (let attr in attrMap) {
1930
- if (!attrMap.hasOwnProperty(attr)) continue;
1931
- let attrVal = options.attributeValueProcessor(attr, attrMap[attr]);
1932
- attrVal = replaceEntitiesValue(attrVal, options);
1933
- if (attrVal === true && options.suppressBooleanAttributes) {
1934
- attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}`;
1900
+ XMLParser_1 = XMLParser;
1901
+ return XMLParser_1;
1902
+ }
1903
+ var orderedJs2Xml;
1904
+ var hasRequiredOrderedJs2Xml;
1905
+ function requireOrderedJs2Xml() {
1906
+ if (hasRequiredOrderedJs2Xml) return orderedJs2Xml;
1907
+ hasRequiredOrderedJs2Xml = 1;
1908
+ const EOL = "\n";
1909
+ function toXml(jArray, options) {
1910
+ let indentation = "";
1911
+ if (options.format && options.indentBy.length > 0) {
1912
+ indentation = EOL;
1913
+ }
1914
+ return arrToStr(jArray, options, "", indentation);
1915
+ }
1916
+ function arrToStr(arr, options, jPath, indentation) {
1917
+ let xmlStr = "";
1918
+ let isPreviousElementTag = false;
1919
+ for (let i = 0; i < arr.length; i++) {
1920
+ const tagObj = arr[i];
1921
+ const tagName = propName(tagObj);
1922
+ if (tagName === void 0) continue;
1923
+ let newJPath = "";
1924
+ if (jPath.length === 0) newJPath = tagName;
1925
+ else newJPath = `${jPath}.${tagName}`;
1926
+ if (tagName === options.textNodeName) {
1927
+ let tagText = tagObj[tagName];
1928
+ if (!isStopNode(newJPath, options)) {
1929
+ tagText = options.tagValueProcessor(tagName, tagText);
1930
+ tagText = replaceEntitiesValue(tagText, options);
1931
+ }
1932
+ if (isPreviousElementTag) {
1933
+ xmlStr += indentation;
1934
+ }
1935
+ xmlStr += tagText;
1936
+ isPreviousElementTag = false;
1937
+ continue;
1938
+ } else if (tagName === options.cdataPropName) {
1939
+ if (isPreviousElementTag) {
1940
+ xmlStr += indentation;
1941
+ }
1942
+ xmlStr += `<![CDATA[${tagObj[tagName][0][options.textNodeName]}]]>`;
1943
+ isPreviousElementTag = false;
1944
+ continue;
1945
+ } else if (tagName === options.commentPropName) {
1946
+ xmlStr += indentation + `<!--${tagObj[tagName][0][options.textNodeName]}-->`;
1947
+ isPreviousElementTag = true;
1948
+ continue;
1949
+ } else if (tagName[0] === "?") {
1950
+ const attStr2 = attr_to_str(tagObj[":@"], options);
1951
+ const tempInd = tagName === "?xml" ? "" : indentation;
1952
+ let piTextNodeName = tagObj[tagName][0][options.textNodeName];
1953
+ piTextNodeName = piTextNodeName.length !== 0 ? " " + piTextNodeName : "";
1954
+ xmlStr += tempInd + `<${tagName}${piTextNodeName}${attStr2}?>`;
1955
+ isPreviousElementTag = true;
1956
+ continue;
1957
+ }
1958
+ let newIdentation = indentation;
1959
+ if (newIdentation !== "") {
1960
+ newIdentation += options.indentBy;
1961
+ }
1962
+ const attStr = attr_to_str(tagObj[":@"], options);
1963
+ const tagStart = indentation + `<${tagName}${attStr}`;
1964
+ const tagValue = arrToStr(tagObj[tagName], options, newJPath, newIdentation);
1965
+ if (options.unpairedTags.indexOf(tagName) !== -1) {
1966
+ if (options.suppressUnpairedNode) xmlStr += tagStart + ">";
1967
+ else xmlStr += tagStart + "/>";
1968
+ } else if ((!tagValue || tagValue.length === 0) && options.suppressEmptyNode) {
1969
+ xmlStr += tagStart + "/>";
1970
+ } else if (tagValue && tagValue.endsWith(">")) {
1971
+ xmlStr += tagStart + `>${tagValue}${indentation}</${tagName}>`;
1935
1972
  } else {
1936
- attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}="${attrVal}"`;
1973
+ xmlStr += tagStart + ">";
1974
+ if (tagValue && indentation !== "" && (tagValue.includes("/>") || tagValue.includes("</"))) {
1975
+ xmlStr += indentation + options.indentBy + tagValue + indentation;
1976
+ } else {
1977
+ xmlStr += tagValue;
1978
+ }
1979
+ xmlStr += `</${tagName}>`;
1937
1980
  }
1981
+ isPreviousElementTag = true;
1938
1982
  }
1939
- }
1940
- return attrStr;
1941
- }
1942
- function isStopNode(jPath, options) {
1943
- jPath = jPath.substr(0, jPath.length - options.textNodeName.length - 1);
1944
- let tagName = jPath.substr(jPath.lastIndexOf(".") + 1);
1945
- for (let index in options.stopNodes) {
1946
- if (options.stopNodes[index] === jPath || options.stopNodes[index] === "*." + tagName) return true;
1947
- }
1948
- return false;
1949
- }
1950
- function replaceEntitiesValue(textValue, options) {
1951
- if (textValue && textValue.length > 0 && options.processEntities) {
1952
- for (let i = 0; i < options.entities.length; i++) {
1953
- const entity = options.entities[i];
1954
- textValue = textValue.replace(entity.regex, entity.val);
1983
+ return xmlStr;
1984
+ }
1985
+ function propName(obj) {
1986
+ const keys = Object.keys(obj);
1987
+ for (let i = 0; i < keys.length; i++) {
1988
+ const key = keys[i];
1989
+ if (!obj.hasOwnProperty(key)) continue;
1990
+ if (key !== ":@") return key;
1991
+ }
1992
+ }
1993
+ function attr_to_str(attrMap, options) {
1994
+ let attrStr = "";
1995
+ if (attrMap && !options.ignoreAttributes) {
1996
+ for (let attr in attrMap) {
1997
+ if (!attrMap.hasOwnProperty(attr)) continue;
1998
+ let attrVal = options.attributeValueProcessor(attr, attrMap[attr]);
1999
+ attrVal = replaceEntitiesValue(attrVal, options);
2000
+ if (attrVal === true && options.suppressBooleanAttributes) {
2001
+ attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}`;
2002
+ } else {
2003
+ attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}="${attrVal}"`;
2004
+ }
2005
+ }
1955
2006
  }
2007
+ return attrStr;
1956
2008
  }
1957
- return textValue;
1958
- }
1959
- var orderedJs2Xml = toXml;
1960
- const buildFromOrderedJs = orderedJs2Xml;
1961
- const getIgnoreAttributesFn = ignoreAttributes;
1962
- const defaultOptions = {
1963
- attributeNamePrefix: "@_",
1964
- attributesGroupName: false,
1965
- textNodeName: "#text",
1966
- ignoreAttributes: true,
1967
- cdataPropName: false,
1968
- format: false,
1969
- indentBy: " ",
1970
- suppressEmptyNode: false,
1971
- suppressUnpairedNode: true,
1972
- suppressBooleanAttributes: true,
1973
- tagValueProcessor: function(key, a) {
1974
- return a;
1975
- },
1976
- attributeValueProcessor: function(attrName, a) {
1977
- return a;
1978
- },
1979
- preserveOrder: false,
1980
- commentPropName: false,
1981
- unpairedTags: [],
1982
- entities: [
1983
- { regex: new RegExp("&", "g"), val: "&amp;" },
1984
- //it must be on top
1985
- { regex: new RegExp(">", "g"), val: "&gt;" },
1986
- { regex: new RegExp("<", "g"), val: "&lt;" },
1987
- { regex: new RegExp("'", "g"), val: "&apos;" },
1988
- { regex: new RegExp('"', "g"), val: "&quot;" }
1989
- ],
1990
- processEntities: true,
1991
- stopNodes: [],
1992
- // transformTagName: false,
1993
- // transformAttributeName: false,
1994
- oneListGroup: false
1995
- };
1996
- function Builder(options) {
1997
- this.options = Object.assign({}, defaultOptions, options);
1998
- if (this.options.ignoreAttributes === true || this.options.attributesGroupName) {
1999
- this.isAttribute = function() {
2000
- return false;
2001
- };
2002
- } else {
2003
- this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes);
2004
- this.attrPrefixLen = this.options.attributeNamePrefix.length;
2005
- this.isAttribute = isAttribute;
2006
- }
2007
- this.processTextOrObjNode = processTextOrObjNode;
2008
- if (this.options.format) {
2009
- this.indentate = indentate;
2010
- this.tagEndChar = ">\n";
2011
- this.newLine = "\n";
2012
- } else {
2013
- this.indentate = function() {
2014
- return "";
2015
- };
2016
- this.tagEndChar = ">";
2017
- this.newLine = "";
2009
+ function isStopNode(jPath, options) {
2010
+ jPath = jPath.substr(0, jPath.length - options.textNodeName.length - 1);
2011
+ let tagName = jPath.substr(jPath.lastIndexOf(".") + 1);
2012
+ for (let index in options.stopNodes) {
2013
+ if (options.stopNodes[index] === jPath || options.stopNodes[index] === "*." + tagName) return true;
2014
+ }
2015
+ return false;
2018
2016
  }
2019
- }
2020
- Builder.prototype.build = function(jObj) {
2021
- if (this.options.preserveOrder) {
2022
- return buildFromOrderedJs(jObj, this.options);
2023
- } else {
2024
- if (Array.isArray(jObj) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1) {
2025
- jObj = {
2026
- [this.options.arrayNodeName]: jObj
2017
+ function replaceEntitiesValue(textValue, options) {
2018
+ if (textValue && textValue.length > 0 && options.processEntities) {
2019
+ for (let i = 0; i < options.entities.length; i++) {
2020
+ const entity = options.entities[i];
2021
+ textValue = textValue.replace(entity.regex, entity.val);
2022
+ }
2023
+ }
2024
+ return textValue;
2025
+ }
2026
+ orderedJs2Xml = toXml;
2027
+ return orderedJs2Xml;
2028
+ }
2029
+ var json2xml;
2030
+ var hasRequiredJson2xml;
2031
+ function requireJson2xml() {
2032
+ if (hasRequiredJson2xml) return json2xml;
2033
+ hasRequiredJson2xml = 1;
2034
+ const buildFromOrderedJs = requireOrderedJs2Xml();
2035
+ const getIgnoreAttributesFn = requireIgnoreAttributes();
2036
+ const defaultOptions = {
2037
+ attributeNamePrefix: "@_",
2038
+ attributesGroupName: false,
2039
+ textNodeName: "#text",
2040
+ ignoreAttributes: true,
2041
+ cdataPropName: false,
2042
+ format: false,
2043
+ indentBy: " ",
2044
+ suppressEmptyNode: false,
2045
+ suppressUnpairedNode: true,
2046
+ suppressBooleanAttributes: true,
2047
+ tagValueProcessor: function(key, a) {
2048
+ return a;
2049
+ },
2050
+ attributeValueProcessor: function(attrName, a) {
2051
+ return a;
2052
+ },
2053
+ preserveOrder: false,
2054
+ commentPropName: false,
2055
+ unpairedTags: [],
2056
+ entities: [
2057
+ { regex: new RegExp("&", "g"), val: "&amp;" },
2058
+ //it must be on top
2059
+ { regex: new RegExp(">", "g"), val: "&gt;" },
2060
+ { regex: new RegExp("<", "g"), val: "&lt;" },
2061
+ { regex: new RegExp("'", "g"), val: "&apos;" },
2062
+ { regex: new RegExp('"', "g"), val: "&quot;" }
2063
+ ],
2064
+ processEntities: true,
2065
+ stopNodes: [],
2066
+ // transformTagName: false,
2067
+ // transformAttributeName: false,
2068
+ oneListGroup: false
2069
+ };
2070
+ function Builder(options) {
2071
+ this.options = Object.assign({}, defaultOptions, options);
2072
+ if (this.options.ignoreAttributes === true || this.options.attributesGroupName) {
2073
+ this.isAttribute = function() {
2074
+ return false;
2075
+ };
2076
+ } else {
2077
+ this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes);
2078
+ this.attrPrefixLen = this.options.attributeNamePrefix.length;
2079
+ this.isAttribute = isAttribute;
2080
+ }
2081
+ this.processTextOrObjNode = processTextOrObjNode;
2082
+ if (this.options.format) {
2083
+ this.indentate = indentate;
2084
+ this.tagEndChar = ">\n";
2085
+ this.newLine = "\n";
2086
+ } else {
2087
+ this.indentate = function() {
2088
+ return "";
2027
2089
  };
2090
+ this.tagEndChar = ">";
2091
+ this.newLine = "";
2028
2092
  }
2029
- return this.j2x(jObj, 0, []).val;
2030
2093
  }
2031
- };
2032
- Builder.prototype.j2x = function(jObj, level, ajPath) {
2033
- let attrStr = "";
2034
- let val2 = "";
2035
- const jPath = ajPath.join(".");
2036
- for (let key in jObj) {
2037
- if (!Object.prototype.hasOwnProperty.call(jObj, key)) continue;
2038
- if (typeof jObj[key] === "undefined") {
2039
- if (this.isAttribute(key)) {
2040
- val2 += "";
2041
- }
2042
- } else if (jObj[key] === null) {
2043
- if (this.isAttribute(key)) {
2044
- val2 += "";
2045
- } else if (key[0] === "?") {
2046
- val2 += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
2047
- } else {
2048
- val2 += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
2049
- }
2050
- } else if (jObj[key] instanceof Date) {
2051
- val2 += this.buildTextValNode(jObj[key], key, "", level);
2052
- } else if (typeof jObj[key] !== "object") {
2053
- const attr = this.isAttribute(key);
2054
- if (attr && !this.ignoreAttributesFn(attr, jPath)) {
2055
- attrStr += this.buildAttrPairStr(attr, "" + jObj[key]);
2056
- } else if (!attr) {
2057
- if (key === this.options.textNodeName) {
2058
- let newval = this.options.tagValueProcessor(key, "" + jObj[key]);
2059
- val2 += this.replaceEntitiesValue(newval);
2094
+ Builder.prototype.build = function(jObj) {
2095
+ if (this.options.preserveOrder) {
2096
+ return buildFromOrderedJs(jObj, this.options);
2097
+ } else {
2098
+ if (Array.isArray(jObj) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1) {
2099
+ jObj = {
2100
+ [this.options.arrayNodeName]: jObj
2101
+ };
2102
+ }
2103
+ return this.j2x(jObj, 0, []).val;
2104
+ }
2105
+ };
2106
+ Builder.prototype.j2x = function(jObj, level, ajPath) {
2107
+ let attrStr = "";
2108
+ let val = "";
2109
+ const jPath = ajPath.join(".");
2110
+ for (let key in jObj) {
2111
+ if (!Object.prototype.hasOwnProperty.call(jObj, key)) continue;
2112
+ if (typeof jObj[key] === "undefined") {
2113
+ if (this.isAttribute(key)) {
2114
+ val += "";
2115
+ }
2116
+ } else if (jObj[key] === null) {
2117
+ if (this.isAttribute(key)) {
2118
+ val += "";
2119
+ } else if (key[0] === "?") {
2120
+ val += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
2060
2121
  } else {
2061
- val2 += this.buildTextValNode(jObj[key], key, "", level);
2122
+ val += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
2062
2123
  }
2063
- }
2064
- } else if (Array.isArray(jObj[key])) {
2065
- const arrLen = jObj[key].length;
2066
- let listTagVal = "";
2067
- let listTagAttr = "";
2068
- for (let j = 0; j < arrLen; j++) {
2069
- const item = jObj[key][j];
2070
- if (typeof item === "undefined") ;
2071
- else if (item === null) {
2072
- if (key[0] === "?") val2 += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
2073
- else val2 += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
2074
- } else if (typeof item === "object") {
2075
- if (this.options.oneListGroup) {
2076
- const result = this.j2x(item, level + 1, ajPath.concat(key));
2077
- listTagVal += result.val;
2078
- if (this.options.attributesGroupName && item.hasOwnProperty(this.options.attributesGroupName)) {
2079
- listTagAttr += result.attrStr;
2080
- }
2124
+ } else if (jObj[key] instanceof Date) {
2125
+ val += this.buildTextValNode(jObj[key], key, "", level);
2126
+ } else if (typeof jObj[key] !== "object") {
2127
+ const attr = this.isAttribute(key);
2128
+ if (attr && !this.ignoreAttributesFn(attr, jPath)) {
2129
+ attrStr += this.buildAttrPairStr(attr, "" + jObj[key]);
2130
+ } else if (!attr) {
2131
+ if (key === this.options.textNodeName) {
2132
+ let newval = this.options.tagValueProcessor(key, "" + jObj[key]);
2133
+ val += this.replaceEntitiesValue(newval);
2081
2134
  } else {
2082
- listTagVal += this.processTextOrObjNode(item, key, level, ajPath);
2135
+ val += this.buildTextValNode(jObj[key], key, "", level);
2083
2136
  }
2084
- } else {
2085
- if (this.options.oneListGroup) {
2086
- let textValue = this.options.tagValueProcessor(key, item);
2087
- textValue = this.replaceEntitiesValue(textValue);
2088
- listTagVal += textValue;
2137
+ }
2138
+ } else if (Array.isArray(jObj[key])) {
2139
+ const arrLen = jObj[key].length;
2140
+ let listTagVal = "";
2141
+ let listTagAttr = "";
2142
+ for (let j = 0; j < arrLen; j++) {
2143
+ const item = jObj[key][j];
2144
+ if (typeof item === "undefined") ;
2145
+ else if (item === null) {
2146
+ if (key[0] === "?") val += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
2147
+ else val += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
2148
+ } else if (typeof item === "object") {
2149
+ if (this.options.oneListGroup) {
2150
+ const result = this.j2x(item, level + 1, ajPath.concat(key));
2151
+ listTagVal += result.val;
2152
+ if (this.options.attributesGroupName && item.hasOwnProperty(this.options.attributesGroupName)) {
2153
+ listTagAttr += result.attrStr;
2154
+ }
2155
+ } else {
2156
+ listTagVal += this.processTextOrObjNode(item, key, level, ajPath);
2157
+ }
2089
2158
  } else {
2090
- listTagVal += this.buildTextValNode(item, key, "", level);
2159
+ if (this.options.oneListGroup) {
2160
+ let textValue = this.options.tagValueProcessor(key, item);
2161
+ textValue = this.replaceEntitiesValue(textValue);
2162
+ listTagVal += textValue;
2163
+ } else {
2164
+ listTagVal += this.buildTextValNode(item, key, "", level);
2165
+ }
2091
2166
  }
2092
2167
  }
2093
- }
2094
- if (this.options.oneListGroup) {
2095
- listTagVal = this.buildObjectNode(listTagVal, key, listTagAttr, level);
2096
- }
2097
- val2 += listTagVal;
2098
- } else {
2099
- if (this.options.attributesGroupName && key === this.options.attributesGroupName) {
2100
- const Ks = Object.keys(jObj[key]);
2101
- const L = Ks.length;
2102
- for (let j = 0; j < L; j++) {
2103
- attrStr += this.buildAttrPairStr(Ks[j], "" + jObj[key][Ks[j]]);
2168
+ if (this.options.oneListGroup) {
2169
+ listTagVal = this.buildObjectNode(listTagVal, key, listTagAttr, level);
2104
2170
  }
2171
+ val += listTagVal;
2105
2172
  } else {
2106
- val2 += this.processTextOrObjNode(jObj[key], key, level, ajPath);
2173
+ if (this.options.attributesGroupName && key === this.options.attributesGroupName) {
2174
+ const Ks = Object.keys(jObj[key]);
2175
+ const L = Ks.length;
2176
+ for (let j = 0; j < L; j++) {
2177
+ attrStr += this.buildAttrPairStr(Ks[j], "" + jObj[key][Ks[j]]);
2178
+ }
2179
+ } else {
2180
+ val += this.processTextOrObjNode(jObj[key], key, level, ajPath);
2181
+ }
2107
2182
  }
2108
2183
  }
2184
+ return { attrStr, val };
2185
+ };
2186
+ Builder.prototype.buildAttrPairStr = function(attrName, val) {
2187
+ val = this.options.attributeValueProcessor(attrName, "" + val);
2188
+ val = this.replaceEntitiesValue(val);
2189
+ if (this.options.suppressBooleanAttributes && val === "true") {
2190
+ return " " + attrName;
2191
+ } else return " " + attrName + '="' + val + '"';
2192
+ };
2193
+ function processTextOrObjNode(object, key, level, ajPath) {
2194
+ const result = this.j2x(object, level + 1, ajPath.concat(key));
2195
+ if (object[this.options.textNodeName] !== void 0 && Object.keys(object).length === 1) {
2196
+ return this.buildTextValNode(object[this.options.textNodeName], key, result.attrStr, level);
2197
+ } else {
2198
+ return this.buildObjectNode(result.val, key, result.attrStr, level);
2199
+ }
2109
2200
  }
2110
- return { attrStr, val: val2 };
2111
- };
2112
- Builder.prototype.buildAttrPairStr = function(attrName, val2) {
2113
- val2 = this.options.attributeValueProcessor(attrName, "" + val2);
2114
- val2 = this.replaceEntitiesValue(val2);
2115
- if (this.options.suppressBooleanAttributes && val2 === "true") {
2116
- return " " + attrName;
2117
- } else return " " + attrName + '="' + val2 + '"';
2118
- };
2119
- function processTextOrObjNode(object, key, level, ajPath) {
2120
- const result = this.j2x(object, level + 1, ajPath.concat(key));
2121
- if (object[this.options.textNodeName] !== void 0 && Object.keys(object).length === 1) {
2122
- return this.buildTextValNode(object[this.options.textNodeName], key, result.attrStr, level);
2123
- } else {
2124
- return this.buildObjectNode(result.val, key, result.attrStr, level);
2125
- }
2126
- }
2127
- Builder.prototype.buildObjectNode = function(val2, key, attrStr, level) {
2128
- if (val2 === "") {
2129
- if (key[0] === "?") return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
2130
- else {
2131
- return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
2201
+ Builder.prototype.buildObjectNode = function(val, key, attrStr, level) {
2202
+ if (val === "") {
2203
+ if (key[0] === "?") return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
2204
+ else {
2205
+ return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
2206
+ }
2207
+ } else {
2208
+ let tagEndExp = "</" + key + this.tagEndChar;
2209
+ let piClosingChar = "";
2210
+ if (key[0] === "?") {
2211
+ piClosingChar = "?";
2212
+ tagEndExp = "";
2213
+ }
2214
+ if ((attrStr || attrStr === "") && val.indexOf("<") === -1) {
2215
+ return this.indentate(level) + "<" + key + attrStr + piClosingChar + ">" + val + tagEndExp;
2216
+ } else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {
2217
+ return this.indentate(level) + `<!--${val}-->` + this.newLine;
2218
+ } else {
2219
+ return this.indentate(level) + "<" + key + attrStr + piClosingChar + this.tagEndChar + val + this.indentate(level) + tagEndExp;
2220
+ }
2132
2221
  }
2133
- } else {
2134
- let tagEndExp = "</" + key + this.tagEndChar;
2135
- let piClosingChar = "";
2136
- if (key[0] === "?") {
2137
- piClosingChar = "?";
2138
- tagEndExp = "";
2139
- }
2140
- if ((attrStr || attrStr === "") && val2.indexOf("<") === -1) {
2141
- return this.indentate(level) + "<" + key + attrStr + piClosingChar + ">" + val2 + tagEndExp;
2142
- } else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {
2143
- return this.indentate(level) + `<!--${val2}-->` + this.newLine;
2222
+ };
2223
+ Builder.prototype.closeTag = function(key) {
2224
+ let closeTag = "";
2225
+ if (this.options.unpairedTags.indexOf(key) !== -1) {
2226
+ if (!this.options.suppressUnpairedNode) closeTag = "/";
2227
+ } else if (this.options.suppressEmptyNode) {
2228
+ closeTag = "/";
2144
2229
  } else {
2145
- return this.indentate(level) + "<" + key + attrStr + piClosingChar + this.tagEndChar + val2 + this.indentate(level) + tagEndExp;
2230
+ closeTag = `></${key}`;
2146
2231
  }
2147
- }
2148
- };
2149
- Builder.prototype.closeTag = function(key) {
2150
- let closeTag = "";
2151
- if (this.options.unpairedTags.indexOf(key) !== -1) {
2152
- if (!this.options.suppressUnpairedNode) closeTag = "/";
2153
- } else if (this.options.suppressEmptyNode) {
2154
- closeTag = "/";
2155
- } else {
2156
- closeTag = `></${key}`;
2157
- }
2158
- return closeTag;
2159
- };
2160
- Builder.prototype.buildTextValNode = function(val2, key, attrStr, level) {
2161
- if (this.options.cdataPropName !== false && key === this.options.cdataPropName) {
2162
- return this.indentate(level) + `<![CDATA[${val2}]]>` + this.newLine;
2163
- } else if (this.options.commentPropName !== false && key === this.options.commentPropName) {
2164
- return this.indentate(level) + `<!--${val2}-->` + this.newLine;
2165
- } else if (key[0] === "?") {
2166
- return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
2167
- } else {
2168
- let textValue = this.options.tagValueProcessor(key, val2);
2169
- textValue = this.replaceEntitiesValue(textValue);
2170
- if (textValue === "") {
2171
- return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
2232
+ return closeTag;
2233
+ };
2234
+ Builder.prototype.buildTextValNode = function(val, key, attrStr, level) {
2235
+ if (this.options.cdataPropName !== false && key === this.options.cdataPropName) {
2236
+ return this.indentate(level) + `<![CDATA[${val}]]>` + this.newLine;
2237
+ } else if (this.options.commentPropName !== false && key === this.options.commentPropName) {
2238
+ return this.indentate(level) + `<!--${val}-->` + this.newLine;
2239
+ } else if (key[0] === "?") {
2240
+ return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
2172
2241
  } else {
2173
- return this.indentate(level) + "<" + key + attrStr + ">" + textValue + "</" + key + this.tagEndChar;
2242
+ let textValue = this.options.tagValueProcessor(key, val);
2243
+ textValue = this.replaceEntitiesValue(textValue);
2244
+ if (textValue === "") {
2245
+ return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
2246
+ } else {
2247
+ return this.indentate(level) + "<" + key + attrStr + ">" + textValue + "</" + key + this.tagEndChar;
2248
+ }
2174
2249
  }
2175
- }
2176
- };
2177
- Builder.prototype.replaceEntitiesValue = function(textValue) {
2178
- if (textValue && textValue.length > 0 && this.options.processEntities) {
2179
- for (let i = 0; i < this.options.entities.length; i++) {
2180
- const entity = this.options.entities[i];
2181
- textValue = textValue.replace(entity.regex, entity.val);
2250
+ };
2251
+ Builder.prototype.replaceEntitiesValue = function(textValue) {
2252
+ if (textValue && textValue.length > 0 && this.options.processEntities) {
2253
+ for (let i = 0; i < this.options.entities.length; i++) {
2254
+ const entity = this.options.entities[i];
2255
+ textValue = textValue.replace(entity.regex, entity.val);
2256
+ }
2182
2257
  }
2258
+ return textValue;
2259
+ };
2260
+ function indentate(level) {
2261
+ return this.options.indentBy.repeat(level);
2183
2262
  }
2184
- return textValue;
2185
- };
2186
- function indentate(level) {
2187
- return this.options.indentBy.repeat(level);
2188
- }
2189
- function isAttribute(name) {
2190
- if (name.startsWith(this.options.attributeNamePrefix) && name !== this.options.textNodeName) {
2191
- return name.substr(this.attrPrefixLen);
2192
- } else {
2193
- return false;
2263
+ function isAttribute(name) {
2264
+ if (name.startsWith(this.options.attributeNamePrefix) && name !== this.options.textNodeName) {
2265
+ return name.substr(this.attrPrefixLen);
2266
+ } else {
2267
+ return false;
2268
+ }
2194
2269
  }
2270
+ json2xml = Builder;
2271
+ return json2xml;
2272
+ }
2273
+ var fxp;
2274
+ var hasRequiredFxp;
2275
+ function requireFxp() {
2276
+ if (hasRequiredFxp) return fxp;
2277
+ hasRequiredFxp = 1;
2278
+ const validator2 = requireValidator();
2279
+ const XMLParser = requireXMLParser();
2280
+ const XMLBuilder = requireJson2xml();
2281
+ fxp = {
2282
+ XMLParser,
2283
+ XMLValidator: validator2,
2284
+ XMLBuilder
2285
+ };
2286
+ return fxp;
2195
2287
  }
2196
- var json2xml = Builder;
2197
- const validator = validator$2;
2198
- const XMLParser2 = XMLParser_1;
2199
- const XMLBuilder = json2xml;
2200
- var fxp = {
2201
- XMLParser: XMLParser2,
2202
- XMLValidator: validator,
2203
- XMLBuilder
2204
- };
2288
+ var fxpExports = requireFxp();
2205
2289
  function isSvg(string) {
2206
2290
  if (typeof string !== "string") {
2207
2291
  throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
@@ -2210,11 +2294,11 @@ function isSvg(string) {
2210
2294
  if (string.length === 0) {
2211
2295
  return false;
2212
2296
  }
2213
- if (fxp.XMLValidator.validate(string) !== true) {
2297
+ if (fxpExports.XMLValidator.validate(string) !== true) {
2214
2298
  return false;
2215
2299
  }
2216
2300
  let jsonObject;
2217
- const parser = new fxp.XMLParser();
2301
+ const parser = new fxpExports.XMLParser();
2218
2302
  try {
2219
2303
  jsonObject = parser.parse(string);
2220
2304
  } catch {
@@ -2341,412 +2425,479 @@ const isValidView = function(view) {
2341
2425
  }
2342
2426
  return true;
2343
2427
  };
2344
- const debug$1 = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
2345
- };
2346
- var debug_1 = debug$1;
2347
- const SEMVER_SPEC_VERSION = "2.0.0";
2348
- const MAX_LENGTH$1 = 256;
2349
- const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
2350
- 9007199254740991;
2351
- const MAX_SAFE_COMPONENT_LENGTH = 16;
2352
- const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH$1 - 6;
2353
- const RELEASE_TYPES = [
2354
- "major",
2355
- "premajor",
2356
- "minor",
2357
- "preminor",
2358
- "patch",
2359
- "prepatch",
2360
- "prerelease"
2361
- ];
2362
- var constants = {
2363
- MAX_LENGTH: MAX_LENGTH$1,
2364
- MAX_SAFE_COMPONENT_LENGTH,
2365
- MAX_SAFE_BUILD_LENGTH,
2366
- MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
2367
- RELEASE_TYPES,
2368
- SEMVER_SPEC_VERSION,
2369
- FLAG_INCLUDE_PRERELEASE: 1,
2370
- FLAG_LOOSE: 2
2371
- };
2372
- var re$1 = { exports: {} };
2373
- (function(module2, exports2) {
2374
- const {
2375
- MAX_SAFE_COMPONENT_LENGTH: MAX_SAFE_COMPONENT_LENGTH2,
2376
- MAX_SAFE_BUILD_LENGTH: MAX_SAFE_BUILD_LENGTH2,
2377
- MAX_LENGTH: MAX_LENGTH2
2378
- } = constants;
2379
- const debug2 = debug_1;
2380
- exports2 = module2.exports = {};
2381
- const re2 = exports2.re = [];
2382
- const safeRe = exports2.safeRe = [];
2383
- const src = exports2.src = [];
2384
- const t2 = exports2.t = {};
2385
- let R = 0;
2386
- const LETTERDASHNUMBER = "[a-zA-Z0-9-]";
2387
- const safeRegexReplacements = [
2388
- ["\\s", 1],
2389
- ["\\d", MAX_LENGTH2],
2390
- [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH2]
2428
+ var debug_1;
2429
+ var hasRequiredDebug;
2430
+ function requireDebug() {
2431
+ if (hasRequiredDebug) return debug_1;
2432
+ hasRequiredDebug = 1;
2433
+ const debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
2434
+ };
2435
+ debug_1 = debug;
2436
+ return debug_1;
2437
+ }
2438
+ var constants;
2439
+ var hasRequiredConstants;
2440
+ function requireConstants() {
2441
+ if (hasRequiredConstants) return constants;
2442
+ hasRequiredConstants = 1;
2443
+ const SEMVER_SPEC_VERSION = "2.0.0";
2444
+ const MAX_LENGTH = 256;
2445
+ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
2446
+ 9007199254740991;
2447
+ const MAX_SAFE_COMPONENT_LENGTH = 16;
2448
+ const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
2449
+ const RELEASE_TYPES = [
2450
+ "major",
2451
+ "premajor",
2452
+ "minor",
2453
+ "preminor",
2454
+ "patch",
2455
+ "prepatch",
2456
+ "prerelease"
2391
2457
  ];
2392
- const makeSafeRegex = (value) => {
2393
- for (const [token, max] of safeRegexReplacements) {
2394
- value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
2395
- }
2396
- return value;
2458
+ constants = {
2459
+ MAX_LENGTH,
2460
+ MAX_SAFE_COMPONENT_LENGTH,
2461
+ MAX_SAFE_BUILD_LENGTH,
2462
+ MAX_SAFE_INTEGER,
2463
+ RELEASE_TYPES,
2464
+ SEMVER_SPEC_VERSION,
2465
+ FLAG_INCLUDE_PRERELEASE: 1,
2466
+ FLAG_LOOSE: 2
2397
2467
  };
2398
- const createToken = (name, value, isGlobal) => {
2399
- const safe = makeSafeRegex(value);
2400
- const index = R++;
2401
- debug2(name, index, value);
2402
- t2[name] = index;
2403
- src[index] = value;
2404
- re2[index] = new RegExp(value, isGlobal ? "g" : void 0);
2405
- safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
2468
+ return constants;
2469
+ }
2470
+ var re = { exports: {} };
2471
+ var hasRequiredRe;
2472
+ function requireRe() {
2473
+ if (hasRequiredRe) return re.exports;
2474
+ hasRequiredRe = 1;
2475
+ (function(module2, exports2) {
2476
+ const {
2477
+ MAX_SAFE_COMPONENT_LENGTH,
2478
+ MAX_SAFE_BUILD_LENGTH,
2479
+ MAX_LENGTH
2480
+ } = requireConstants();
2481
+ const debug = requireDebug();
2482
+ exports2 = module2.exports = {};
2483
+ const re2 = exports2.re = [];
2484
+ const safeRe = exports2.safeRe = [];
2485
+ const src = exports2.src = [];
2486
+ const t = exports2.t = {};
2487
+ let R = 0;
2488
+ const LETTERDASHNUMBER = "[a-zA-Z0-9-]";
2489
+ const safeRegexReplacements = [
2490
+ ["\\s", 1],
2491
+ ["\\d", MAX_LENGTH],
2492
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
2493
+ ];
2494
+ const makeSafeRegex = (value) => {
2495
+ for (const [token, max] of safeRegexReplacements) {
2496
+ value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
2497
+ }
2498
+ return value;
2499
+ };
2500
+ const createToken = (name, value, isGlobal) => {
2501
+ const safe = makeSafeRegex(value);
2502
+ const index = R++;
2503
+ debug(name, index, value);
2504
+ t[name] = index;
2505
+ src[index] = value;
2506
+ re2[index] = new RegExp(value, isGlobal ? "g" : void 0);
2507
+ safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
2508
+ };
2509
+ createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
2510
+ createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
2511
+ createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
2512
+ createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
2513
+ createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
2514
+ createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NUMERICIDENTIFIER]}|${src[t.NONNUMERICIDENTIFIER]})`);
2515
+ createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NUMERICIDENTIFIERLOOSE]}|${src[t.NONNUMERICIDENTIFIER]})`);
2516
+ createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
2517
+ createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
2518
+ createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
2519
+ createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
2520
+ createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
2521
+ createToken("FULL", `^${src[t.FULLPLAIN]}$`);
2522
+ createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
2523
+ createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
2524
+ createToken("GTLT", "((?:<|>)?=?)");
2525
+ createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
2526
+ createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
2527
+ createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
2528
+ createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
2529
+ createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
2530
+ createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
2531
+ createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
2532
+ createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
2533
+ createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
2534
+ createToken("COERCERTL", src[t.COERCE], true);
2535
+ createToken("COERCERTLFULL", src[t.COERCEFULL], true);
2536
+ createToken("LONETILDE", "(?:~>?)");
2537
+ createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
2538
+ exports2.tildeTrimReplace = "$1~";
2539
+ createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
2540
+ createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
2541
+ createToken("LONECARET", "(?:\\^)");
2542
+ createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
2543
+ exports2.caretTrimReplace = "$1^";
2544
+ createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
2545
+ createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
2546
+ createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
2547
+ createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
2548
+ createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
2549
+ exports2.comparatorTrimReplace = "$1$2$3";
2550
+ createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
2551
+ createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
2552
+ createToken("STAR", "(<|>)?=?\\s*\\*");
2553
+ createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
2554
+ createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
2555
+ })(re, re.exports);
2556
+ return re.exports;
2557
+ }
2558
+ var parseOptions_1;
2559
+ var hasRequiredParseOptions;
2560
+ function requireParseOptions() {
2561
+ if (hasRequiredParseOptions) return parseOptions_1;
2562
+ hasRequiredParseOptions = 1;
2563
+ const looseOption = Object.freeze({ loose: true });
2564
+ const emptyOpts = Object.freeze({});
2565
+ const parseOptions = (options) => {
2566
+ if (!options) {
2567
+ return emptyOpts;
2568
+ }
2569
+ if (typeof options !== "object") {
2570
+ return looseOption;
2571
+ }
2572
+ return options;
2406
2573
  };
2407
- createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
2408
- createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
2409
- createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
2410
- createToken("MAINVERSION", `(${src[t2.NUMERICIDENTIFIER]})\\.(${src[t2.NUMERICIDENTIFIER]})\\.(${src[t2.NUMERICIDENTIFIER]})`);
2411
- createToken("MAINVERSIONLOOSE", `(${src[t2.NUMERICIDENTIFIERLOOSE]})\\.(${src[t2.NUMERICIDENTIFIERLOOSE]})\\.(${src[t2.NUMERICIDENTIFIERLOOSE]})`);
2412
- createToken("PRERELEASEIDENTIFIER", `(?:${src[t2.NUMERICIDENTIFIER]}|${src[t2.NONNUMERICIDENTIFIER]})`);
2413
- createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t2.NUMERICIDENTIFIERLOOSE]}|${src[t2.NONNUMERICIDENTIFIER]})`);
2414
- createToken("PRERELEASE", `(?:-(${src[t2.PRERELEASEIDENTIFIER]}(?:\\.${src[t2.PRERELEASEIDENTIFIER]})*))`);
2415
- createToken("PRERELEASELOOSE", `(?:-?(${src[t2.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t2.PRERELEASEIDENTIFIERLOOSE]})*))`);
2416
- createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
2417
- createToken("BUILD", `(?:\\+(${src[t2.BUILDIDENTIFIER]}(?:\\.${src[t2.BUILDIDENTIFIER]})*))`);
2418
- createToken("FULLPLAIN", `v?${src[t2.MAINVERSION]}${src[t2.PRERELEASE]}?${src[t2.BUILD]}?`);
2419
- createToken("FULL", `^${src[t2.FULLPLAIN]}$`);
2420
- createToken("LOOSEPLAIN", `[v=\\s]*${src[t2.MAINVERSIONLOOSE]}${src[t2.PRERELEASELOOSE]}?${src[t2.BUILD]}?`);
2421
- createToken("LOOSE", `^${src[t2.LOOSEPLAIN]}$`);
2422
- createToken("GTLT", "((?:<|>)?=?)");
2423
- createToken("XRANGEIDENTIFIERLOOSE", `${src[t2.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
2424
- createToken("XRANGEIDENTIFIER", `${src[t2.NUMERICIDENTIFIER]}|x|X|\\*`);
2425
- createToken("XRANGEPLAIN", `[v=\\s]*(${src[t2.XRANGEIDENTIFIER]})(?:\\.(${src[t2.XRANGEIDENTIFIER]})(?:\\.(${src[t2.XRANGEIDENTIFIER]})(?:${src[t2.PRERELEASE]})?${src[t2.BUILD]}?)?)?`);
2426
- createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t2.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t2.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t2.XRANGEIDENTIFIERLOOSE]})(?:${src[t2.PRERELEASELOOSE]})?${src[t2.BUILD]}?)?)?`);
2427
- createToken("XRANGE", `^${src[t2.GTLT]}\\s*${src[t2.XRANGEPLAIN]}$`);
2428
- createToken("XRANGELOOSE", `^${src[t2.GTLT]}\\s*${src[t2.XRANGEPLAINLOOSE]}$`);
2429
- createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH2}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH2}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH2}}))?`);
2430
- createToken("COERCE", `${src[t2.COERCEPLAIN]}(?:$|[^\\d])`);
2431
- createToken("COERCEFULL", src[t2.COERCEPLAIN] + `(?:${src[t2.PRERELEASE]})?(?:${src[t2.BUILD]})?(?:$|[^\\d])`);
2432
- createToken("COERCERTL", src[t2.COERCE], true);
2433
- createToken("COERCERTLFULL", src[t2.COERCEFULL], true);
2434
- createToken("LONETILDE", "(?:~>?)");
2435
- createToken("TILDETRIM", `(\\s*)${src[t2.LONETILDE]}\\s+`, true);
2436
- exports2.tildeTrimReplace = "$1~";
2437
- createToken("TILDE", `^${src[t2.LONETILDE]}${src[t2.XRANGEPLAIN]}$`);
2438
- createToken("TILDELOOSE", `^${src[t2.LONETILDE]}${src[t2.XRANGEPLAINLOOSE]}$`);
2439
- createToken("LONECARET", "(?:\\^)");
2440
- createToken("CARETTRIM", `(\\s*)${src[t2.LONECARET]}\\s+`, true);
2441
- exports2.caretTrimReplace = "$1^";
2442
- createToken("CARET", `^${src[t2.LONECARET]}${src[t2.XRANGEPLAIN]}$`);
2443
- createToken("CARETLOOSE", `^${src[t2.LONECARET]}${src[t2.XRANGEPLAINLOOSE]}$`);
2444
- createToken("COMPARATORLOOSE", `^${src[t2.GTLT]}\\s*(${src[t2.LOOSEPLAIN]})$|^$`);
2445
- createToken("COMPARATOR", `^${src[t2.GTLT]}\\s*(${src[t2.FULLPLAIN]})$|^$`);
2446
- createToken("COMPARATORTRIM", `(\\s*)${src[t2.GTLT]}\\s*(${src[t2.LOOSEPLAIN]}|${src[t2.XRANGEPLAIN]})`, true);
2447
- exports2.comparatorTrimReplace = "$1$2$3";
2448
- createToken("HYPHENRANGE", `^\\s*(${src[t2.XRANGEPLAIN]})\\s+-\\s+(${src[t2.XRANGEPLAIN]})\\s*$`);
2449
- createToken("HYPHENRANGELOOSE", `^\\s*(${src[t2.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t2.XRANGEPLAINLOOSE]})\\s*$`);
2450
- createToken("STAR", "(<|>)?=?\\s*\\*");
2451
- createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
2452
- createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
2453
- })(re$1, re$1.exports);
2454
- var reExports = re$1.exports;
2455
- const looseOption = Object.freeze({ loose: true });
2456
- const emptyOpts = Object.freeze({});
2457
- const parseOptions$1 = (options) => {
2458
- if (!options) {
2459
- return emptyOpts;
2460
- }
2461
- if (typeof options !== "object") {
2462
- return looseOption;
2463
- }
2464
- return options;
2465
- };
2466
- var parseOptions_1 = parseOptions$1;
2467
- const numeric = /^[0-9]+$/;
2468
- const compareIdentifiers$1 = (a, b) => {
2469
- const anum = numeric.test(a);
2470
- const bnum = numeric.test(b);
2471
- if (anum && bnum) {
2472
- a = +a;
2473
- b = +b;
2474
- }
2475
- return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
2476
- };
2477
- const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
2478
- var identifiers = {
2479
- compareIdentifiers: compareIdentifiers$1,
2480
- rcompareIdentifiers
2481
- };
2482
- const debug = debug_1;
2483
- const { MAX_LENGTH, MAX_SAFE_INTEGER } = constants;
2484
- const { safeRe: re, t } = reExports;
2485
- const parseOptions = parseOptions_1;
2486
- const { compareIdentifiers } = identifiers;
2487
- let SemVer$2 = class SemVer {
2488
- constructor(version, options) {
2489
- options = parseOptions(options);
2490
- if (version instanceof SemVer) {
2491
- if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
2492
- return version;
2574
+ parseOptions_1 = parseOptions;
2575
+ return parseOptions_1;
2576
+ }
2577
+ var identifiers;
2578
+ var hasRequiredIdentifiers;
2579
+ function requireIdentifiers() {
2580
+ if (hasRequiredIdentifiers) return identifiers;
2581
+ hasRequiredIdentifiers = 1;
2582
+ const numeric = /^[0-9]+$/;
2583
+ const compareIdentifiers = (a, b) => {
2584
+ const anum = numeric.test(a);
2585
+ const bnum = numeric.test(b);
2586
+ if (anum && bnum) {
2587
+ a = +a;
2588
+ b = +b;
2589
+ }
2590
+ return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
2591
+ };
2592
+ const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
2593
+ identifiers = {
2594
+ compareIdentifiers,
2595
+ rcompareIdentifiers
2596
+ };
2597
+ return identifiers;
2598
+ }
2599
+ var semver;
2600
+ var hasRequiredSemver;
2601
+ function requireSemver() {
2602
+ if (hasRequiredSemver) return semver;
2603
+ hasRequiredSemver = 1;
2604
+ const debug = requireDebug();
2605
+ const { MAX_LENGTH, MAX_SAFE_INTEGER } = requireConstants();
2606
+ const { safeRe: re2, t } = requireRe();
2607
+ const parseOptions = requireParseOptions();
2608
+ const { compareIdentifiers } = requireIdentifiers();
2609
+ class SemVer {
2610
+ constructor(version, options) {
2611
+ options = parseOptions(options);
2612
+ if (version instanceof SemVer) {
2613
+ if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
2614
+ return version;
2615
+ } else {
2616
+ version = version.version;
2617
+ }
2618
+ } else if (typeof version !== "string") {
2619
+ throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
2620
+ }
2621
+ if (version.length > MAX_LENGTH) {
2622
+ throw new TypeError(
2623
+ `version is longer than ${MAX_LENGTH} characters`
2624
+ );
2625
+ }
2626
+ debug("SemVer", version, options);
2627
+ this.options = options;
2628
+ this.loose = !!options.loose;
2629
+ this.includePrerelease = !!options.includePrerelease;
2630
+ const m = version.trim().match(options.loose ? re2[t.LOOSE] : re2[t.FULL]);
2631
+ if (!m) {
2632
+ throw new TypeError(`Invalid Version: ${version}`);
2633
+ }
2634
+ this.raw = version;
2635
+ this.major = +m[1];
2636
+ this.minor = +m[2];
2637
+ this.patch = +m[3];
2638
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
2639
+ throw new TypeError("Invalid major version");
2640
+ }
2641
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
2642
+ throw new TypeError("Invalid minor version");
2643
+ }
2644
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
2645
+ throw new TypeError("Invalid patch version");
2646
+ }
2647
+ if (!m[4]) {
2648
+ this.prerelease = [];
2493
2649
  } else {
2494
- version = version.version;
2650
+ this.prerelease = m[4].split(".").map((id) => {
2651
+ if (/^[0-9]+$/.test(id)) {
2652
+ const num = +id;
2653
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
2654
+ return num;
2655
+ }
2656
+ }
2657
+ return id;
2658
+ });
2495
2659
  }
2496
- } else if (typeof version !== "string") {
2497
- throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
2660
+ this.build = m[5] ? m[5].split(".") : [];
2661
+ this.format();
2498
2662
  }
2499
- if (version.length > MAX_LENGTH) {
2500
- throw new TypeError(
2501
- `version is longer than ${MAX_LENGTH} characters`
2502
- );
2663
+ format() {
2664
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
2665
+ if (this.prerelease.length) {
2666
+ this.version += `-${this.prerelease.join(".")}`;
2667
+ }
2668
+ return this.version;
2503
2669
  }
2504
- debug("SemVer", version, options);
2505
- this.options = options;
2506
- this.loose = !!options.loose;
2507
- this.includePrerelease = !!options.includePrerelease;
2508
- const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
2509
- if (!m) {
2510
- throw new TypeError(`Invalid Version: ${version}`);
2511
- }
2512
- this.raw = version;
2513
- this.major = +m[1];
2514
- this.minor = +m[2];
2515
- this.patch = +m[3];
2516
- if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
2517
- throw new TypeError("Invalid major version");
2518
- }
2519
- if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
2520
- throw new TypeError("Invalid minor version");
2521
- }
2522
- if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
2523
- throw new TypeError("Invalid patch version");
2524
- }
2525
- if (!m[4]) {
2526
- this.prerelease = [];
2527
- } else {
2528
- this.prerelease = m[4].split(".").map((id) => {
2529
- if (/^[0-9]+$/.test(id)) {
2530
- const num = +id;
2531
- if (num >= 0 && num < MAX_SAFE_INTEGER) {
2532
- return num;
2533
- }
2534
- }
2535
- return id;
2536
- });
2670
+ toString() {
2671
+ return this.version;
2537
2672
  }
2538
- this.build = m[5] ? m[5].split(".") : [];
2539
- this.format();
2540
- }
2541
- format() {
2542
- this.version = `${this.major}.${this.minor}.${this.patch}`;
2543
- if (this.prerelease.length) {
2544
- this.version += `-${this.prerelease.join(".")}`;
2545
- }
2546
- return this.version;
2547
- }
2548
- toString() {
2549
- return this.version;
2550
- }
2551
- compare(other) {
2552
- debug("SemVer.compare", this.version, this.options, other);
2553
- if (!(other instanceof SemVer)) {
2554
- if (typeof other === "string" && other === this.version) {
2673
+ compare(other) {
2674
+ debug("SemVer.compare", this.version, this.options, other);
2675
+ if (!(other instanceof SemVer)) {
2676
+ if (typeof other === "string" && other === this.version) {
2677
+ return 0;
2678
+ }
2679
+ other = new SemVer(other, this.options);
2680
+ }
2681
+ if (other.version === this.version) {
2555
2682
  return 0;
2556
2683
  }
2557
- other = new SemVer(other, this.options);
2684
+ return this.compareMain(other) || this.comparePre(other);
2558
2685
  }
2559
- if (other.version === this.version) {
2560
- return 0;
2561
- }
2562
- return this.compareMain(other) || this.comparePre(other);
2563
- }
2564
- compareMain(other) {
2565
- if (!(other instanceof SemVer)) {
2566
- other = new SemVer(other, this.options);
2567
- }
2568
- return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
2569
- }
2570
- comparePre(other) {
2571
- if (!(other instanceof SemVer)) {
2572
- other = new SemVer(other, this.options);
2686
+ compareMain(other) {
2687
+ if (!(other instanceof SemVer)) {
2688
+ other = new SemVer(other, this.options);
2689
+ }
2690
+ return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
2573
2691
  }
2574
- if (this.prerelease.length && !other.prerelease.length) {
2575
- return -1;
2576
- } else if (!this.prerelease.length && other.prerelease.length) {
2577
- return 1;
2578
- } else if (!this.prerelease.length && !other.prerelease.length) {
2579
- return 0;
2580
- }
2581
- let i = 0;
2582
- do {
2583
- const a = this.prerelease[i];
2584
- const b = other.prerelease[i];
2585
- debug("prerelease compare", i, a, b);
2586
- if (a === void 0 && b === void 0) {
2587
- return 0;
2588
- } else if (b === void 0) {
2589
- return 1;
2590
- } else if (a === void 0) {
2692
+ comparePre(other) {
2693
+ if (!(other instanceof SemVer)) {
2694
+ other = new SemVer(other, this.options);
2695
+ }
2696
+ if (this.prerelease.length && !other.prerelease.length) {
2591
2697
  return -1;
2592
- } else if (a === b) {
2593
- continue;
2594
- } else {
2595
- return compareIdentifiers(a, b);
2698
+ } else if (!this.prerelease.length && other.prerelease.length) {
2699
+ return 1;
2700
+ } else if (!this.prerelease.length && !other.prerelease.length) {
2701
+ return 0;
2596
2702
  }
2597
- } while (++i);
2598
- }
2599
- compareBuild(other) {
2600
- if (!(other instanceof SemVer)) {
2601
- other = new SemVer(other, this.options);
2703
+ let i = 0;
2704
+ do {
2705
+ const a = this.prerelease[i];
2706
+ const b = other.prerelease[i];
2707
+ debug("prerelease compare", i, a, b);
2708
+ if (a === void 0 && b === void 0) {
2709
+ return 0;
2710
+ } else if (b === void 0) {
2711
+ return 1;
2712
+ } else if (a === void 0) {
2713
+ return -1;
2714
+ } else if (a === b) {
2715
+ continue;
2716
+ } else {
2717
+ return compareIdentifiers(a, b);
2718
+ }
2719
+ } while (++i);
2602
2720
  }
2603
- let i = 0;
2604
- do {
2605
- const a = this.build[i];
2606
- const b = other.build[i];
2607
- debug("build compare", i, a, b);
2608
- if (a === void 0 && b === void 0) {
2609
- return 0;
2610
- } else if (b === void 0) {
2611
- return 1;
2612
- } else if (a === void 0) {
2613
- return -1;
2614
- } else if (a === b) {
2615
- continue;
2616
- } else {
2617
- return compareIdentifiers(a, b);
2618
- }
2619
- } while (++i);
2620
- }
2621
- // preminor will bump the version up to the next minor release, and immediately
2622
- // down to pre-release. premajor and prepatch work the same way.
2623
- inc(release, identifier, identifierBase) {
2624
- switch (release) {
2625
- case "premajor":
2626
- this.prerelease.length = 0;
2627
- this.patch = 0;
2628
- this.minor = 0;
2629
- this.major++;
2630
- this.inc("pre", identifier, identifierBase);
2631
- break;
2632
- case "preminor":
2633
- this.prerelease.length = 0;
2634
- this.patch = 0;
2635
- this.minor++;
2636
- this.inc("pre", identifier, identifierBase);
2637
- break;
2638
- case "prepatch":
2639
- this.prerelease.length = 0;
2640
- this.inc("patch", identifier, identifierBase);
2641
- this.inc("pre", identifier, identifierBase);
2642
- break;
2643
- case "prerelease":
2644
- if (this.prerelease.length === 0) {
2645
- this.inc("patch", identifier, identifierBase);
2721
+ compareBuild(other) {
2722
+ if (!(other instanceof SemVer)) {
2723
+ other = new SemVer(other, this.options);
2724
+ }
2725
+ let i = 0;
2726
+ do {
2727
+ const a = this.build[i];
2728
+ const b = other.build[i];
2729
+ debug("build compare", i, a, b);
2730
+ if (a === void 0 && b === void 0) {
2731
+ return 0;
2732
+ } else if (b === void 0) {
2733
+ return 1;
2734
+ } else if (a === void 0) {
2735
+ return -1;
2736
+ } else if (a === b) {
2737
+ continue;
2738
+ } else {
2739
+ return compareIdentifiers(a, b);
2646
2740
  }
2647
- this.inc("pre", identifier, identifierBase);
2648
- break;
2649
- case "major":
2650
- if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
2741
+ } while (++i);
2742
+ }
2743
+ // preminor will bump the version up to the next minor release, and immediately
2744
+ // down to pre-release. premajor and prepatch work the same way.
2745
+ inc(release, identifier, identifierBase) {
2746
+ switch (release) {
2747
+ case "premajor":
2748
+ this.prerelease.length = 0;
2749
+ this.patch = 0;
2750
+ this.minor = 0;
2651
2751
  this.major++;
2652
- }
2653
- this.minor = 0;
2654
- this.patch = 0;
2655
- this.prerelease = [];
2656
- break;
2657
- case "minor":
2658
- if (this.patch !== 0 || this.prerelease.length === 0) {
2752
+ this.inc("pre", identifier, identifierBase);
2753
+ break;
2754
+ case "preminor":
2755
+ this.prerelease.length = 0;
2756
+ this.patch = 0;
2659
2757
  this.minor++;
2660
- }
2661
- this.patch = 0;
2662
- this.prerelease = [];
2663
- break;
2664
- case "patch":
2665
- if (this.prerelease.length === 0) {
2666
- this.patch++;
2667
- }
2668
- this.prerelease = [];
2669
- break;
2670
- case "pre": {
2671
- const base = Number(identifierBase) ? 1 : 0;
2672
- if (!identifier && identifierBase === false) {
2673
- throw new Error("invalid increment argument: identifier is empty");
2674
- }
2675
- if (this.prerelease.length === 0) {
2676
- this.prerelease = [base];
2677
- } else {
2678
- let i = this.prerelease.length;
2679
- while (--i >= 0) {
2680
- if (typeof this.prerelease[i] === "number") {
2681
- this.prerelease[i]++;
2682
- i = -2;
2683
- }
2758
+ this.inc("pre", identifier, identifierBase);
2759
+ break;
2760
+ case "prepatch":
2761
+ this.prerelease.length = 0;
2762
+ this.inc("patch", identifier, identifierBase);
2763
+ this.inc("pre", identifier, identifierBase);
2764
+ break;
2765
+ // If the input is a non-prerelease version, this acts the same as
2766
+ // prepatch.
2767
+ case "prerelease":
2768
+ if (this.prerelease.length === 0) {
2769
+ this.inc("patch", identifier, identifierBase);
2684
2770
  }
2685
- if (i === -1) {
2686
- if (identifier === this.prerelease.join(".") && identifierBase === false) {
2687
- throw new Error("invalid increment argument: identifier already exists");
2688
- }
2689
- this.prerelease.push(base);
2771
+ this.inc("pre", identifier, identifierBase);
2772
+ break;
2773
+ case "major":
2774
+ if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
2775
+ this.major++;
2690
2776
  }
2691
- }
2692
- if (identifier) {
2693
- let prerelease = [identifier, base];
2694
- if (identifierBase === false) {
2695
- prerelease = [identifier];
2777
+ this.minor = 0;
2778
+ this.patch = 0;
2779
+ this.prerelease = [];
2780
+ break;
2781
+ case "minor":
2782
+ if (this.patch !== 0 || this.prerelease.length === 0) {
2783
+ this.minor++;
2696
2784
  }
2697
- if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
2698
- if (isNaN(this.prerelease[1])) {
2785
+ this.patch = 0;
2786
+ this.prerelease = [];
2787
+ break;
2788
+ case "patch":
2789
+ if (this.prerelease.length === 0) {
2790
+ this.patch++;
2791
+ }
2792
+ this.prerelease = [];
2793
+ break;
2794
+ // This probably shouldn't be used publicly.
2795
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
2796
+ case "pre": {
2797
+ const base = Number(identifierBase) ? 1 : 0;
2798
+ if (!identifier && identifierBase === false) {
2799
+ throw new Error("invalid increment argument: identifier is empty");
2800
+ }
2801
+ if (this.prerelease.length === 0) {
2802
+ this.prerelease = [base];
2803
+ } else {
2804
+ let i = this.prerelease.length;
2805
+ while (--i >= 0) {
2806
+ if (typeof this.prerelease[i] === "number") {
2807
+ this.prerelease[i]++;
2808
+ i = -2;
2809
+ }
2810
+ }
2811
+ if (i === -1) {
2812
+ if (identifier === this.prerelease.join(".") && identifierBase === false) {
2813
+ throw new Error("invalid increment argument: identifier already exists");
2814
+ }
2815
+ this.prerelease.push(base);
2816
+ }
2817
+ }
2818
+ if (identifier) {
2819
+ let prerelease = [identifier, base];
2820
+ if (identifierBase === false) {
2821
+ prerelease = [identifier];
2822
+ }
2823
+ if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
2824
+ if (isNaN(this.prerelease[1])) {
2825
+ this.prerelease = prerelease;
2826
+ }
2827
+ } else {
2699
2828
  this.prerelease = prerelease;
2700
2829
  }
2701
- } else {
2702
- this.prerelease = prerelease;
2703
2830
  }
2831
+ break;
2704
2832
  }
2705
- break;
2833
+ default:
2834
+ throw new Error(`invalid increment argument: ${release}`);
2706
2835
  }
2707
- default:
2708
- throw new Error(`invalid increment argument: ${release}`);
2709
- }
2710
- this.raw = this.format();
2711
- if (this.build.length) {
2712
- this.raw += `+${this.build.join(".")}`;
2836
+ this.raw = this.format();
2837
+ if (this.build.length) {
2838
+ this.raw += `+${this.build.join(".")}`;
2839
+ }
2840
+ return this;
2713
2841
  }
2714
- return this;
2715
- }
2716
- };
2717
- var semver = SemVer$2;
2718
- const SemVer$1 = semver;
2719
- const parse$1 = (version, options, throwErrors = false) => {
2720
- if (version instanceof SemVer$1) {
2721
- return version;
2722
2842
  }
2723
- try {
2724
- return new SemVer$1(version, options);
2725
- } catch (er) {
2726
- if (!throwErrors) {
2727
- return null;
2843
+ semver = SemVer;
2844
+ return semver;
2845
+ }
2846
+ var parse_1;
2847
+ var hasRequiredParse;
2848
+ function requireParse() {
2849
+ if (hasRequiredParse) return parse_1;
2850
+ hasRequiredParse = 1;
2851
+ const SemVer = requireSemver();
2852
+ const parse = (version, options, throwErrors = false) => {
2853
+ if (version instanceof SemVer) {
2854
+ return version;
2728
2855
  }
2729
- throw er;
2730
- }
2731
- };
2732
- var parse_1 = parse$1;
2733
- const parse = parse_1;
2734
- const valid = (version, options) => {
2735
- const v = parse(version, options);
2736
- return v ? v.version : null;
2737
- };
2738
- var valid_1 = valid;
2739
- const valid$1 = /* @__PURE__ */ getDefaultExportFromCjs(valid_1);
2740
- const SemVer2 = semver;
2741
- const major = (a, loose) => new SemVer2(a, loose).major;
2742
- var major_1 = major;
2743
- const major$1 = /* @__PURE__ */ getDefaultExportFromCjs(major_1);
2856
+ try {
2857
+ return new SemVer(version, options);
2858
+ } catch (er) {
2859
+ if (!throwErrors) {
2860
+ return null;
2861
+ }
2862
+ throw er;
2863
+ }
2864
+ };
2865
+ parse_1 = parse;
2866
+ return parse_1;
2867
+ }
2868
+ var valid_1;
2869
+ var hasRequiredValid;
2870
+ function requireValid() {
2871
+ if (hasRequiredValid) return valid_1;
2872
+ hasRequiredValid = 1;
2873
+ const parse = requireParse();
2874
+ const valid2 = (version, options) => {
2875
+ const v = parse(version, options);
2876
+ return v ? v.version : null;
2877
+ };
2878
+ valid_1 = valid2;
2879
+ return valid_1;
2880
+ }
2881
+ var validExports = requireValid();
2882
+ const valid = /* @__PURE__ */ getDefaultExportFromCjs(validExports);
2883
+ var major_1;
2884
+ var hasRequiredMajor;
2885
+ function requireMajor() {
2886
+ if (hasRequiredMajor) return major_1;
2887
+ hasRequiredMajor = 1;
2888
+ const SemVer = requireSemver();
2889
+ const major2 = (a, loose) => new SemVer(a, loose).major;
2890
+ major_1 = major2;
2891
+ return major_1;
2892
+ }
2893
+ var majorExports = requireMajor();
2894
+ const major = /* @__PURE__ */ getDefaultExportFromCjs(majorExports);
2744
2895
  class ProxyBus {
2745
2896
  bus;
2746
2897
  constructor(bus2) {
2747
- if (typeof bus2.getVersion !== "function" || !valid$1(bus2.getVersion())) {
2898
+ if (typeof bus2.getVersion !== "function" || !valid(bus2.getVersion())) {
2748
2899
  console.warn("Proxying an event bus with an unknown or invalid version");
2749
- } else if (major$1(bus2.getVersion()) !== major$1(this.getVersion())) {
2900
+ } else if (major(bus2.getVersion()) !== major(this.getVersion())) {
2750
2901
  console.warn(
2751
2902
  "Proxying an event bus of version " + bus2.getVersion() + " with " + this.getVersion()
2752
2903
  );