@rgrove/parse-xml 4.0.1 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -31
- package/dist/browser.js +692 -300
- package/dist/browser.js.map +4 -4
- package/dist/global.min.js +9 -8
- package/dist/global.min.js.map +4 -4
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/Parser.d.ts +53 -6
- package/dist/lib/Parser.d.ts.map +1 -1
- package/dist/lib/Parser.js +166 -126
- package/dist/lib/Parser.js.map +1 -1
- package/dist/lib/StringScanner.d.ts +15 -21
- package/dist/lib/StringScanner.d.ts.map +1 -1
- package/dist/lib/StringScanner.js +63 -86
- package/dist/lib/StringScanner.js.map +1 -1
- package/dist/lib/XmlDeclaration.d.ts +30 -0
- package/dist/lib/XmlDeclaration.d.ts.map +1 -0
- package/dist/lib/XmlDeclaration.js +36 -0
- package/dist/lib/XmlDeclaration.js.map +1 -0
- package/dist/lib/XmlDocument.d.ts +4 -2
- package/dist/lib/XmlDocument.d.ts.map +1 -1
- package/dist/lib/XmlDocument.js.map +1 -1
- package/dist/lib/XmlDocumentType.d.ts +37 -0
- package/dist/lib/XmlDocumentType.d.ts.map +1 -0
- package/dist/lib/XmlDocumentType.js +39 -0
- package/dist/lib/XmlDocumentType.js.map +1 -0
- package/dist/lib/XmlElement.js.map +1 -1
- package/dist/lib/XmlError.d.ts +24 -0
- package/dist/lib/XmlError.d.ts.map +1 -0
- package/dist/lib/XmlError.js +52 -0
- package/dist/lib/XmlError.js.map +1 -0
- package/dist/lib/XmlNode.d.ts +20 -1
- package/dist/lib/XmlNode.d.ts.map +1 -1
- package/dist/lib/XmlNode.js +28 -3
- package/dist/lib/XmlNode.js.map +1 -1
- package/dist/lib/syntax.d.ts.map +1 -1
- package/dist/lib/syntax.js +18 -23
- package/dist/lib/syntax.js.map +1 -1
- package/dist/lib/types.d.ts +2 -2
- package/dist/lib/types.d.ts.map +1 -1
- package/package.json +20 -23
- package/src/index.ts +3 -0
- package/src/lib/Parser.ts +228 -141
- package/src/lib/StringScanner.ts +66 -103
- package/src/lib/XmlDeclaration.ts +58 -0
- package/src/lib/XmlDocument.ts +4 -2
- package/src/lib/XmlDocumentType.ts +67 -0
- package/src/lib/XmlError.ts +80 -0
- package/src/lib/XmlNode.ts +33 -3
- package/src/lib/syntax.ts +12 -18
package/dist/lib/XmlNode.d.ts
CHANGED
|
@@ -17,6 +17,10 @@ export declare class XmlNode {
|
|
|
17
17
|
* Type value for an `XmlDocument` node.
|
|
18
18
|
*/
|
|
19
19
|
static readonly TYPE_DOCUMENT = "document";
|
|
20
|
+
/**
|
|
21
|
+
* Type value for an `XmlDocumentType` node.
|
|
22
|
+
*/
|
|
23
|
+
static readonly TYPE_DOCUMENT_TYPE = "doctype";
|
|
20
24
|
/**
|
|
21
25
|
* Type value for an `XmlElement` node.
|
|
22
26
|
*/
|
|
@@ -29,17 +33,32 @@ export declare class XmlNode {
|
|
|
29
33
|
* Type value for an `XmlText` node.
|
|
30
34
|
*/
|
|
31
35
|
static readonly TYPE_TEXT = "text";
|
|
36
|
+
/**
|
|
37
|
+
* Type value for an `XmlDeclaration` node.
|
|
38
|
+
*/
|
|
39
|
+
static readonly TYPE_XML_DECLARATION = "xmldecl";
|
|
32
40
|
/**
|
|
33
41
|
* Parent node of this node, or `null` if this node has no parent.
|
|
34
42
|
*/
|
|
35
43
|
parent: XmlDocument | XmlElement | null;
|
|
44
|
+
/**
|
|
45
|
+
* Starting byte offset of this node in the original XML string, or `-1` if
|
|
46
|
+
* the offset is unknown.
|
|
47
|
+
*/
|
|
48
|
+
start: number;
|
|
49
|
+
/**
|
|
50
|
+
* Ending byte offset of this node in the original XML string, or `-1` if the
|
|
51
|
+
* offset is unknown.
|
|
52
|
+
*/
|
|
53
|
+
end: number;
|
|
36
54
|
/**
|
|
37
55
|
* Document that contains this node, or `null` if this node is not associated
|
|
38
56
|
* with a document.
|
|
39
57
|
*/
|
|
40
58
|
get document(): XmlDocument | null;
|
|
41
59
|
/**
|
|
42
|
-
* Whether this node is the root node of the document
|
|
60
|
+
* Whether this node is the root node of the document (also known as the
|
|
61
|
+
* document element).
|
|
43
62
|
*/
|
|
44
63
|
get isRootNode(): boolean;
|
|
45
64
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XmlNode.d.ts","sourceRoot":"","sources":["../../src/lib/XmlNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;GAEG;AACH,qBAAa,OAAO;IAClB;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,UAAU,WAAW;IAErC;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,YAAY,aAAa;IAEzC;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,aAAa,cAAc;IAE3C;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,YAAY,aAAa;IAEzC;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,2BAA2B,QAAQ;IAEnD;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,SAAS,UAAU;IAEnC;;OAEG;IACH,MAAM,EAAE,WAAW,GAAG,UAAU,GAAG,IAAI,CAAQ;IAE/C;;;OAGG;IACH,IAAI,QAAQ,IAAI,WAAW,GAAG,IAAI,CAEjC;IAED
|
|
1
|
+
{"version":3,"file":"XmlNode.d.ts","sourceRoot":"","sources":["../../src/lib/XmlNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;GAEG;AACH,qBAAa,OAAO;IAClB;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,UAAU,WAAW;IAErC;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,YAAY,aAAa;IAEzC;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,aAAa,cAAc;IAE3C;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,kBAAkB,aAAa;IAE/C;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,YAAY,aAAa;IAEzC;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,2BAA2B,QAAQ;IAEnD;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,SAAS,UAAU;IAEnC;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,oBAAoB,aAAa;IAEjD;;OAEG;IACH,MAAM,EAAE,WAAW,GAAG,UAAU,GAAG,IAAI,CAAQ;IAE/C;;;OAGG;IACH,KAAK,SAAM;IAEX;;;OAGG;IACH,GAAG,SAAM;IAET;;;OAGG;IACH,IAAI,QAAQ,IAAI,WAAW,GAAG,IAAI,CAEjC;IAED;;;OAGG;IACH,IAAI,UAAU,IAAI,OAAO,CAIxB;IAED;;;;;;;;;;OAUG;IACH,IAAI,kBAAkB,IAAI,OAAO,CAEhC;IAED;;;;;;;;;OASG;IACH,IAAI,IAAI,WAEP;IAED;;;OAGG;IACH,MAAM,IAAI,UAAU;CAoBrB"}
|
package/dist/lib/XmlNode.js
CHANGED
|
@@ -10,6 +10,16 @@ class XmlNode {
|
|
|
10
10
|
* Parent node of this node, or `null` if this node has no parent.
|
|
11
11
|
*/
|
|
12
12
|
this.parent = null;
|
|
13
|
+
/**
|
|
14
|
+
* Starting byte offset of this node in the original XML string, or `-1` if
|
|
15
|
+
* the offset is unknown.
|
|
16
|
+
*/
|
|
17
|
+
this.start = -1;
|
|
18
|
+
/**
|
|
19
|
+
* Ending byte offset of this node in the original XML string, or `-1` if the
|
|
20
|
+
* offset is unknown.
|
|
21
|
+
*/
|
|
22
|
+
this.end = -1;
|
|
13
23
|
}
|
|
14
24
|
/**
|
|
15
25
|
* Document that contains this node, or `null` if this node is not associated
|
|
@@ -19,10 +29,13 @@ class XmlNode {
|
|
|
19
29
|
return this.parent?.document ?? null;
|
|
20
30
|
}
|
|
21
31
|
/**
|
|
22
|
-
* Whether this node is the root node of the document
|
|
32
|
+
* Whether this node is the root node of the document (also known as the
|
|
33
|
+
* document element).
|
|
23
34
|
*/
|
|
24
35
|
get isRootNode() {
|
|
25
|
-
return this.parent !== null
|
|
36
|
+
return this.parent !== null
|
|
37
|
+
&& this.parent === this.document
|
|
38
|
+
&& this.type === XmlNode.TYPE_ELEMENT;
|
|
26
39
|
}
|
|
27
40
|
/**
|
|
28
41
|
* Whether whitespace should be preserved in the content of this element and
|
|
@@ -36,7 +49,7 @@ class XmlNode {
|
|
|
36
49
|
* @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-white-space
|
|
37
50
|
*/
|
|
38
51
|
get preserveWhitespace() {
|
|
39
|
-
return
|
|
52
|
+
return !!this.parent?.preserveWhitespace;
|
|
40
53
|
}
|
|
41
54
|
/**
|
|
42
55
|
* Type of this node.
|
|
@@ -65,6 +78,10 @@ class XmlNode {
|
|
|
65
78
|
if (this.preserveWhitespace) {
|
|
66
79
|
json.preserveWhitespace = true;
|
|
67
80
|
}
|
|
81
|
+
if (this.start !== -1) {
|
|
82
|
+
json.start = this.start;
|
|
83
|
+
json.end = this.end;
|
|
84
|
+
}
|
|
68
85
|
return json;
|
|
69
86
|
}
|
|
70
87
|
}
|
|
@@ -81,6 +98,10 @@ XmlNode.TYPE_COMMENT = 'comment';
|
|
|
81
98
|
* Type value for an `XmlDocument` node.
|
|
82
99
|
*/
|
|
83
100
|
XmlNode.TYPE_DOCUMENT = 'document';
|
|
101
|
+
/**
|
|
102
|
+
* Type value for an `XmlDocumentType` node.
|
|
103
|
+
*/
|
|
104
|
+
XmlNode.TYPE_DOCUMENT_TYPE = 'doctype';
|
|
84
105
|
/**
|
|
85
106
|
* Type value for an `XmlElement` node.
|
|
86
107
|
*/
|
|
@@ -93,4 +114,8 @@ XmlNode.TYPE_PROCESSING_INSTRUCTION = 'pi';
|
|
|
93
114
|
* Type value for an `XmlText` node.
|
|
94
115
|
*/
|
|
95
116
|
XmlNode.TYPE_TEXT = 'text';
|
|
117
|
+
/**
|
|
118
|
+
* Type value for an `XmlDeclaration` node.
|
|
119
|
+
*/
|
|
120
|
+
XmlNode.TYPE_XML_DECLARATION = 'xmldecl';
|
|
96
121
|
//# sourceMappingURL=XmlNode.js.map
|
package/dist/lib/XmlNode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XmlNode.js","sourceRoot":"","sources":["../../src/lib/XmlNode.ts"],"names":[],"mappings":";;;AAIA;;GAEG;AACH,MAAa,OAAO;IAApB;
|
|
1
|
+
{"version":3,"file":"XmlNode.js","sourceRoot":"","sources":["../../src/lib/XmlNode.ts"],"names":[],"mappings":";;;AAIA;;GAEG;AACH,MAAa,OAAO;IAApB;QAyCE;;WAEG;QACH,WAAM,GAAoC,IAAI,CAAC;QAE/C;;;WAGG;QACH,UAAK,GAAG,CAAC,CAAC,CAAC;QAEX;;;WAGG;QACH,QAAG,GAAG,CAAC,CAAC,CAAC;IAyEX,CAAC;IAvEC;;;OAGG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,EAAE,QAAQ,IAAI,IAAI,CAAC;IACvC,CAAC;IAED;;;OAGG;IACH,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,MAAM,KAAK,IAAI;eACtB,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,QAAQ;eAC7B,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,YAAY,CAAC;IAC1C,CAAC;IAED;;;;;;;;;;OAUG;IACH,IAAI,kBAAkB;QACpB,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,kB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file":"syntax.d.ts","sourceRoot":"","sources":["../../src/lib/syntax.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,QAAU,CAAC;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,QAAU,CAAC;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,QAAmB,CAAC;AAE7D;;;;;GAKG;AACH,eAAO,MAAM,WAAW,QAAY,CAAC;AAErC;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC;IAAC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CAAC,CAMhE,CAAC;AAEJ;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAehD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAA0B,MAAM,GAAG,OAAO,CAkBzF;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOlD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAOlD"}
|
package/dist/lib/syntax.js
CHANGED
|
@@ -1,27 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.predefinedEntities = exports.endCharData = exports.attValueNormalizedWhitespace = exports.attValueCharSingleQuote = exports.attValueCharDoubleQuote = void 0;
|
|
4
|
+
exports.isNameChar = isNameChar;
|
|
5
|
+
exports.isNameStartChar = isNameStartChar;
|
|
6
|
+
exports.isReferenceChar = isReferenceChar;
|
|
7
|
+
exports.isWhitespace = isWhitespace;
|
|
8
|
+
exports.isXmlCodePoint = isXmlCodePoint;
|
|
4
9
|
/**
|
|
5
10
|
* Regular expression that matches one or more `AttValue` characters in a
|
|
6
11
|
* double-quoted attribute value.
|
|
7
12
|
*
|
|
8
13
|
* @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-AttValue
|
|
9
14
|
*/
|
|
10
|
-
exports.attValueCharDoubleQuote = /[
|
|
15
|
+
exports.attValueCharDoubleQuote = /["&<]/;
|
|
11
16
|
/**
|
|
12
17
|
* Regular expression that matches one or more `AttValue` characters in a
|
|
13
18
|
* single-quoted attribute value.
|
|
14
19
|
*
|
|
15
20
|
* @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-AttValue
|
|
16
21
|
*/
|
|
17
|
-
exports.attValueCharSingleQuote = /[
|
|
22
|
+
exports.attValueCharSingleQuote = /['&<]/;
|
|
18
23
|
/**
|
|
19
24
|
* Regular expression that matches a whitespace character that should be
|
|
20
25
|
* normalized to a space character in an attribute value.
|
|
21
26
|
*
|
|
22
27
|
* @see https://www.w3.org/TR/2008/REC-xml-20081126/#AVNormalize
|
|
23
28
|
*/
|
|
24
|
-
exports.attValueNormalizedWhitespace =
|
|
29
|
+
exports.attValueNormalizedWhitespace = /\r\n|[\n\r\t]/g;
|
|
25
30
|
/**
|
|
26
31
|
* Regular expression that matches one or more characters that signal the end of
|
|
27
32
|
* XML `CharData` content.
|
|
@@ -47,7 +52,7 @@ exports.predefinedEntities = Object.freeze(Object.assign(Object.create(null), {
|
|
|
47
52
|
* @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-NameChar
|
|
48
53
|
*/
|
|
49
54
|
function isNameChar(char) {
|
|
50
|
-
let cp =
|
|
55
|
+
let cp = char.codePointAt(0);
|
|
51
56
|
// Including the most common NameStartChars here improves performance
|
|
52
57
|
// slightly.
|
|
53
58
|
return (cp >= 0x61 && cp <= 0x7A) // a-z
|
|
@@ -57,16 +62,16 @@ function isNameChar(char) {
|
|
|
57
62
|
|| cp === 0x2E // .
|
|
58
63
|
|| cp === 0xB7
|
|
59
64
|
|| (cp >= 0x300 && cp <= 0x36F)
|
|
60
|
-
||
|
|
65
|
+
|| cp === 0x203F
|
|
66
|
+
|| cp === 0x2040
|
|
61
67
|
|| isNameStartChar(char, cp);
|
|
62
68
|
}
|
|
63
|
-
exports.isNameChar = isNameChar;
|
|
64
69
|
/**
|
|
65
70
|
* Returns `true` if _char_ is an XML `NameStartChar`, `false` if it isn't.
|
|
66
71
|
*
|
|
67
72
|
* @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-NameStartChar
|
|
68
73
|
*/
|
|
69
|
-
function isNameStartChar(char, cp =
|
|
74
|
+
function isNameStartChar(char, cp = char.codePointAt(0)) {
|
|
70
75
|
return (cp >= 0x61 && cp <= 0x7A) // a-z
|
|
71
76
|
|| (cp >= 0x41 && cp <= 0x5A) // A-Z
|
|
72
77
|
|| cp === 0x3A // :
|
|
@@ -76,7 +81,8 @@ function isNameStartChar(char, cp = getCodePoint(char)) {
|
|
|
76
81
|
|| (cp >= 0xF8 && cp <= 0x2FF)
|
|
77
82
|
|| (cp >= 0x370 && cp <= 0x37D)
|
|
78
83
|
|| (cp >= 0x37F && cp <= 0x1FFF)
|
|
79
|
-
||
|
|
84
|
+
|| cp === 0x200C
|
|
85
|
+
|| cp === 0x200D
|
|
80
86
|
|| (cp >= 0x2070 && cp <= 0x218F)
|
|
81
87
|
|| (cp >= 0x2C00 && cp <= 0x2FEF)
|
|
82
88
|
|| (cp >= 0x3001 && cp <= 0xD7FF)
|
|
@@ -84,7 +90,6 @@ function isNameStartChar(char, cp = getCodePoint(char)) {
|
|
|
84
90
|
|| (cp >= 0xFDF0 && cp <= 0xFFFD)
|
|
85
91
|
|| (cp >= 0x10000 && cp <= 0xEFFFF);
|
|
86
92
|
}
|
|
87
|
-
exports.isNameStartChar = isNameStartChar;
|
|
88
93
|
/**
|
|
89
94
|
* Returns `true` if _char_ is a valid reference character (which may appear
|
|
90
95
|
* between `&` and `;` in a reference), `false` otherwise.
|
|
@@ -94,20 +99,18 @@ exports.isNameStartChar = isNameStartChar;
|
|
|
94
99
|
function isReferenceChar(char) {
|
|
95
100
|
return char === '#' || isNameChar(char);
|
|
96
101
|
}
|
|
97
|
-
exports.isReferenceChar = isReferenceChar;
|
|
98
102
|
/**
|
|
99
103
|
* Returns `true` if _char_ is an XML whitespace character, `false` otherwise.
|
|
100
104
|
*
|
|
101
105
|
* @see https://www.w3.org/TR/2008/REC-xml-20081126/#white
|
|
102
106
|
*/
|
|
103
107
|
function isWhitespace(char) {
|
|
104
|
-
let cp =
|
|
108
|
+
let cp = char.codePointAt(0);
|
|
105
109
|
return cp === 0x20
|
|
106
110
|
|| cp === 0x9
|
|
107
111
|
|| cp === 0xA
|
|
108
112
|
|| cp === 0xD;
|
|
109
113
|
}
|
|
110
|
-
exports.isWhitespace = isWhitespace;
|
|
111
114
|
/**
|
|
112
115
|
* Returns `true` if _codepoint_ is a valid XML `Char` code point, `false`
|
|
113
116
|
* otherwise.
|
|
@@ -115,19 +118,11 @@ exports.isWhitespace = isWhitespace;
|
|
|
115
118
|
* @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-Char
|
|
116
119
|
*/
|
|
117
120
|
function isXmlCodePoint(cp) {
|
|
118
|
-
return cp
|
|
121
|
+
return (cp >= 0x20 && cp <= 0xD7FF)
|
|
119
122
|
|| cp === 0xA
|
|
123
|
+
|| cp === 0x9
|
|
120
124
|
|| cp === 0xD
|
|
121
|
-
|| (cp >= 0x20 && cp <= 0xD7FF)
|
|
122
125
|
|| (cp >= 0xE000 && cp <= 0xFFFD)
|
|
123
126
|
|| (cp >= 0x10000 && cp <= 0x10FFFF);
|
|
124
127
|
}
|
|
125
|
-
exports.isXmlCodePoint = isXmlCodePoint;
|
|
126
|
-
/**
|
|
127
|
-
* Returns the Unicode code point value of the given character, or `-1` if
|
|
128
|
-
* _char_ is empty.
|
|
129
|
-
*/
|
|
130
|
-
function getCodePoint(char) {
|
|
131
|
-
return char.codePointAt(0) || -1;
|
|
132
|
-
}
|
|
133
128
|
//# sourceMappingURL=syntax.js.map
|
package/dist/lib/syntax.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syntax.js","sourceRoot":"","sources":["../../src/lib/syntax.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"syntax.js","sourceRoot":"","sources":["../../src/lib/syntax.ts"],"names":[],"mappings":";;;AAkDA,gCAeC;AAOD,0CAkBC;AAQD,0CAEC;AAOD,oCAOC;AAQD,wCAOC;AAjID;;;;;GAKG;AACU,QAAA,uBAAuB,GAAG,OAAO,CAAC;AAE/C;;;;;GAKG;AACU,QAAA,uBAAuB,GAAG,OAAO,CAAC;AAE/C;;;;;GAKG;AACU,QAAA,4BAA4B,GAAG,gBAAgB,CAAC;AAE7D;;;;;GAKG;AACU,QAAA,WAAW,GAAG,SAAS,CAAC;AAErC;;;;GAIG;AACU,QAAA,kBAAkB,GAAwC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;IACtH,GAAG,EAAE,GAAG;IACR,IAAI,EAAE,GAAG;IACT,EAAE,EAAE,GAAG;IACP,EAAE,EAAE,GAAG;IACP,IAAI,EAAE,GAAG;CACV,CAAC,CAAC,CAAC;AAEJ;;;;GAIG;AACH,SAAgB,UAAU,CAAC,IAAY;IACrC,IAAI,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAW,CAAC;IAEvC,qEAAqE;IACrE,YAAY;IACZ,OAAO,CAAC,EAAE,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI,CAAC,CAAC,MAAM;WACnC,CAAC,EAAE,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI,CAAC,CAAC,MAAM;WACjC,CAAC,EAAE,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI,CAAC,CAAC,MAAM;WACjC,EAAE,KAAK,IAAI,CAAC,IAAI;WAChB,EAAE,KAAK,IAAI,CAAC,IAAI;WAChB,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CAAC;AAED;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,IAAY;IAC1C,OAAO,IAAI,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;AAC1C,CAAC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,IAAY;IACvC,IAAI,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAE7B,OAAO,EAAE,KAAK,IAAI;WACb,EAAE,KAAK,GAAG;WACV,EAAE,KAAK,GAAG;WACV,EAAE,KAAK,GAAG,CAAC;AAClB,CAAC;AAED;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,EAAU;IACvC,OAAO,CAAC,EAAE,IAAI,IAAI,IAAI,EAAE,IAAI,MAAM,CAAC;WAC9B,EAAE,KAAK,GAAG;WACV,EAAE,KAAK,GAAG;WACV,EAAE,KAAK,GAAG;WACV,CAAC,EAAE,IAAI,MAAM,IAAI,EAAE,IAAI,MAAM,CAAC;WAC9B,CAAC,EAAE,IAAI,OAAO,IAAI,EAAE,IAAI,QAAQ,CAAC,CAAC;AACzC,CAAC"}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type JsonObject = {
|
|
2
2
|
[key in string]?: JsonValue;
|
|
3
3
|
};
|
|
4
|
-
export
|
|
4
|
+
export type JsonValue = string | number | boolean | JsonObject | JsonValue[] | null;
|
|
5
5
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;KAAE,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,SAAS;CAAC,CAAC;AACvD,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,EAAE,GAAG,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rgrove/parse-xml",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "A fast, safe, compliant XML parser for Node.js and browsers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xml",
|
|
@@ -31,35 +31,32 @@
|
|
|
31
31
|
"main": "./dist/index.js",
|
|
32
32
|
"browser": "./dist/browser.js",
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@rgrove/eslint-config": "^5.
|
|
35
|
-
"@types/node": "^
|
|
36
|
-
"assert": "^2.
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"mocha": "^10.
|
|
42
|
-
"nyc": "^
|
|
34
|
+
"@rgrove/eslint-config": "^5.1.0",
|
|
35
|
+
"@types/node": "^22.7.9",
|
|
36
|
+
"assert": "^2.1.0",
|
|
37
|
+
"concurrently": "^9.0.1",
|
|
38
|
+
"esbuild": "^0.24.0",
|
|
39
|
+
"eslint": "^8.57.1",
|
|
40
|
+
"expect-type": "^1.1.0",
|
|
41
|
+
"mocha": "^10.7.3",
|
|
42
|
+
"nyc": "^17.1.0",
|
|
43
43
|
"path-browserify": "^1.0.1",
|
|
44
44
|
"process": "^0.11.10",
|
|
45
|
-
"typedoc": "^0.
|
|
46
|
-
"typescript": "
|
|
47
|
-
"webpack": "^5.65.0",
|
|
48
|
-
"webpack-cli": "^4.9.1",
|
|
49
|
-
"webpack-dev-server": "^4.11.1"
|
|
45
|
+
"typedoc": "^0.26.10",
|
|
46
|
+
"typescript": "5.6.3"
|
|
50
47
|
},
|
|
51
48
|
"scripts": {
|
|
52
|
-
"build": "
|
|
49
|
+
"build": "pnpm run build:js && pnpm run build:bundle && pnpm run build:docs",
|
|
53
50
|
"build:bundle": "./scripts/esbuild.js",
|
|
54
51
|
"build:docs": "typedoc src/index.ts",
|
|
55
52
|
"build:js": "tsc",
|
|
56
|
-
"clean": "rm -rf .nyc_output coverage dist",
|
|
57
|
-
"coverage": "nyc --reporter html --report-dir coverage
|
|
58
|
-
"lint": "
|
|
53
|
+
"clean": "rm -rf .nyc_output coverage dist docs tests/.build",
|
|
54
|
+
"coverage": "nyc --reporter html --report-dir coverage pnpm test && open coverage/index.html",
|
|
55
|
+
"lint": "pnpm run build:js && pnpm run lint:js",
|
|
59
56
|
"lint:js": "eslint .",
|
|
60
|
-
"
|
|
61
|
-
"test": "
|
|
62
|
-
"test:
|
|
63
|
-
"test:
|
|
57
|
+
"test": "pnpm run build:js && nyc --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 mocha && pnpm run test:types",
|
|
58
|
+
"test:browser": "pnpm run build:js && pnpm run build:bundle && scripts/test/browser.js",
|
|
59
|
+
"test:types": "pnpm run build:js && tsc --noEmit tests/types.expect.ts",
|
|
60
|
+
"test:watch": "pnpm run build:js && concurrently --kill-others-on-fail --names build,mocha 'pnpm run build:js --watch' 'mocha --watch'"
|
|
64
61
|
}
|
|
65
62
|
}
|
package/src/index.ts
CHANGED
|
@@ -5,8 +5,11 @@ import type { ParserOptions } from './lib/Parser.js';
|
|
|
5
5
|
export * from './lib/types.js';
|
|
6
6
|
export { XmlCdata } from './lib/XmlCdata.js';
|
|
7
7
|
export { XmlComment } from './lib/XmlComment.js';
|
|
8
|
+
export { XmlDeclaration } from './lib/XmlDeclaration.js';
|
|
8
9
|
export { XmlDocument } from './lib/XmlDocument.js';
|
|
10
|
+
export { XmlDocumentType } from './lib/XmlDocumentType.js';
|
|
9
11
|
export { XmlElement } from './lib/XmlElement.js';
|
|
12
|
+
export { XmlError } from './lib/XmlError.js';
|
|
10
13
|
export { XmlNode } from './lib/XmlNode.js';
|
|
11
14
|
export { XmlProcessingInstruction } from './lib/XmlProcessingInstruction.js';
|
|
12
15
|
export { XmlText } from './lib/XmlText.js';
|