@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.
Files changed (52) hide show
  1. package/README.md +46 -31
  2. package/dist/browser.js +692 -300
  3. package/dist/browser.js.map +4 -4
  4. package/dist/global.min.js +9 -8
  5. package/dist/global.min.js.map +4 -4
  6. package/dist/index.d.ts +3 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +8 -2
  9. package/dist/index.js.map +1 -1
  10. package/dist/lib/Parser.d.ts +53 -6
  11. package/dist/lib/Parser.d.ts.map +1 -1
  12. package/dist/lib/Parser.js +166 -126
  13. package/dist/lib/Parser.js.map +1 -1
  14. package/dist/lib/StringScanner.d.ts +15 -21
  15. package/dist/lib/StringScanner.d.ts.map +1 -1
  16. package/dist/lib/StringScanner.js +63 -86
  17. package/dist/lib/StringScanner.js.map +1 -1
  18. package/dist/lib/XmlDeclaration.d.ts +30 -0
  19. package/dist/lib/XmlDeclaration.d.ts.map +1 -0
  20. package/dist/lib/XmlDeclaration.js +36 -0
  21. package/dist/lib/XmlDeclaration.js.map +1 -0
  22. package/dist/lib/XmlDocument.d.ts +4 -2
  23. package/dist/lib/XmlDocument.d.ts.map +1 -1
  24. package/dist/lib/XmlDocument.js.map +1 -1
  25. package/dist/lib/XmlDocumentType.d.ts +37 -0
  26. package/dist/lib/XmlDocumentType.d.ts.map +1 -0
  27. package/dist/lib/XmlDocumentType.js +39 -0
  28. package/dist/lib/XmlDocumentType.js.map +1 -0
  29. package/dist/lib/XmlElement.js.map +1 -1
  30. package/dist/lib/XmlError.d.ts +24 -0
  31. package/dist/lib/XmlError.d.ts.map +1 -0
  32. package/dist/lib/XmlError.js +52 -0
  33. package/dist/lib/XmlError.js.map +1 -0
  34. package/dist/lib/XmlNode.d.ts +20 -1
  35. package/dist/lib/XmlNode.d.ts.map +1 -1
  36. package/dist/lib/XmlNode.js +28 -3
  37. package/dist/lib/XmlNode.js.map +1 -1
  38. package/dist/lib/syntax.d.ts.map +1 -1
  39. package/dist/lib/syntax.js +18 -23
  40. package/dist/lib/syntax.js.map +1 -1
  41. package/dist/lib/types.d.ts +2 -2
  42. package/dist/lib/types.d.ts.map +1 -1
  43. package/package.json +20 -23
  44. package/src/index.ts +3 -0
  45. package/src/lib/Parser.ts +228 -141
  46. package/src/lib/StringScanner.ts +66 -103
  47. package/src/lib/XmlDeclaration.ts +58 -0
  48. package/src/lib/XmlDocument.ts +4 -2
  49. package/src/lib/XmlDocumentType.ts +67 -0
  50. package/src/lib/XmlError.ts +80 -0
  51. package/src/lib/XmlNode.ts +33 -3
  52. package/src/lib/syntax.ts +12 -18
@@ -11,11 +11,6 @@ export declare class StringScanner {
11
11
  * Whether the current character index is at the end of the input string.
12
12
  */
13
13
  get isEnd(): boolean;
14
- /**
15
- * Returns the byte index of the given character index in the string. The two
16
- * may differ in strings that contain multibyte characters.
17
- */
18
- protected charIndexToByteIndex(charIndex?: number): number;
19
14
  /**
20
15
  * Returns the number of characters in the given string, which may differ from
21
16
  * the byte length if the string contains multibyte characters.
@@ -26,27 +21,32 @@ export declare class StringScanner {
26
21
  * of the string is reached.
27
22
  */
28
23
  advance(count?: number): void;
24
+ /**
25
+ * Returns the byte index of the given character index in the string. The two
26
+ * may differ in strings that contain multibyte characters.
27
+ */
28
+ charIndexToByteIndex(charIndex?: number): number;
29
29
  /**
30
30
  * Consumes and returns the given number of characters if possible, advancing
31
31
  * the scanner and stopping if the end of the string is reached.
32
32
  *
33
33
  * If no characters could be consumed, an empty string will be returned.
34
34
  */
35
- consume(count?: number): string;
35
+ consume(charCount?: number): string;
36
36
  /**
37
- * Consumes a match for the given sticky regex, advances the scanner, updates
38
- * the `lastIndex` property of the regex, and returns the matching string.
37
+ * Consumes and returns the given number of bytes if possible, advancing the
38
+ * scanner and stopping if the end of the string is reached.
39
39
  *
40
- * The regex must have a sticky flag ("y") so that its `lastIndex` prop can be
41
- * used to anchor the match at the current scanner position.
40
+ * It's up to the caller to ensure that the given byte count doesn't split a
41
+ * multibyte character.
42
42
  *
43
- * Returns the consumed string, or an empty string if nothing was consumed.
43
+ * If no bytes could be consumed, an empty string will be returned.
44
44
  */
45
- consumeMatch(regex: RegExp): string;
45
+ consumeBytes(byteCount: number): string;
46
46
  /**
47
- * Consumes and returns all characters for which the given function returns a
48
- * truthy value, stopping on the first falsy return value or if the end of the
49
- * input is reached.
47
+ * Consumes and returns all characters for which the given function returns
48
+ * `true`, stopping when `false` is returned or the end of the input is
49
+ * reached.
50
50
  */
51
51
  consumeMatchFn(fn: (char: string) => boolean): string;
52
52
  /**
@@ -57,12 +57,6 @@ export declare class StringScanner {
57
57
  * string will be returned and the scanner will not be advanced.
58
58
  */
59
59
  consumeString(stringToConsume: string): string;
60
- /**
61
- * Does the same thing as `consumeString()`, but doesn't support consuming
62
- * multibyte characters. This can be faster if you only need to match single
63
- * byte characters.
64
- */
65
- consumeStringFast(stringToConsume: string): string;
66
60
  /**
67
61
  * Consumes characters until the given global regex is matched, advancing the
68
62
  * scanner up to (but not beyond) the beginning of the match. If the regex
@@ -1 +1 @@
1
- {"version":3,"file":"StringScanner.d.ts","sourceRoot":"","sources":["../../src/lib/StringScanner.ts"],"names":[],"mappings":"AAGA,eAAe;AACf,qBAAa,aAAa;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAuB;IACpD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAU;gBAE5B,MAAM,EAAE,MAAM;IAsB1B;;OAEG;IACH,IAAI,KAAK,YAER;IAID;;;OAGG;IACH,SAAS,CAAC,oBAAoB,CAAC,SAAS,GAAE,MAAuB,GAAG,MAAM;IAM1E;;;OAGG;IACH,SAAS,CAAC,UAAU,C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GG;IACH,OAAO,CAAC,KAAK,SAAI;IAIjB;;;OAGG;IACH,oBAAoB,CAAC,SAAS,GAAE,MAAuB,GAAG,MAAM;IAMhE;;;;;OAKG;IACH,OAAO,CAAC,SAAS,SAAI,GAAG,MAAM;IAM9B;;;;;;;;OAQG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAOvC;;;;OAIG;IACH,cAAc,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM;IA6BrD;;;;;;OAMG;IACH,aAAa,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM;IAY9C;;;;;;OAMG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAUxC;;;;;;OAMG;IACH,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAShD;;;;OAIG;IACH,IAAI,CAAC,KAAK,SAAI,GAAG,MAAM;IAQvB;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,SAAI;CAKhB"}
@@ -30,15 +30,6 @@ class StringScanner {
30
30
  return this.charIndex >= this.charCount;
31
31
  }
32
32
  // -- Protected Methods ------------------------------------------------------
33
- /**
34
- * Returns the byte index of the given character index in the string. The two
35
- * may differ in strings that contain multibyte characters.
36
- */
37
- charIndexToByteIndex(charIndex = this.charIndex) {
38
- return this.multiByteMode
39
- ? this.charsToBytes[charIndex] ?? Infinity
40
- : charIndex;
41
- }
42
33
  /**
43
34
  * Returns the number of characters in the given string, which may differ from
44
35
  * the byte length if the string contains multibyte characters.
@@ -59,52 +50,69 @@ class StringScanner {
59
50
  advance(count = 1) {
60
51
  this.charIndex = Math.min(this.charCount, this.charIndex + count);
61
52
  }
53
+ /**
54
+ * Returns the byte index of the given character index in the string. The two
55
+ * may differ in strings that contain multibyte characters.
56
+ */
57
+ charIndexToByteIndex(charIndex = this.charIndex) {
58
+ return this.multiByteMode
59
+ ? this.charsToBytes[charIndex] ?? Infinity
60
+ : charIndex;
61
+ }
62
62
  /**
63
63
  * Consumes and returns the given number of characters if possible, advancing
64
64
  * the scanner and stopping if the end of the string is reached.
65
65
  *
66
66
  * If no characters could be consumed, an empty string will be returned.
67
67
  */
68
- consume(count = 1) {
69
- let chars = this.peek(count);
70
- this.advance(count);
68
+ consume(charCount = 1) {
69
+ let chars = this.peek(charCount);
70
+ this.advance(charCount);
71
71
  return chars;
72
72
  }
73
73
  /**
74
- * Consumes a match for the given sticky regex, advances the scanner, updates
75
- * the `lastIndex` property of the regex, and returns the matching string.
74
+ * Consumes and returns the given number of bytes if possible, advancing the
75
+ * scanner and stopping if the end of the string is reached.
76
76
  *
77
- * The regex must have a sticky flag ("y") so that its `lastIndex` prop can be
78
- * used to anchor the match at the current scanner position.
77
+ * It's up to the caller to ensure that the given byte count doesn't split a
78
+ * multibyte character.
79
79
  *
80
- * Returns the consumed string, or an empty string if nothing was consumed.
80
+ * If no bytes could be consumed, an empty string will be returned.
81
81
  */
82
- consumeMatch(regex) {
83
- if (!regex.sticky) {
84
- throw new Error('`regex` must have a sticky flag ("y")');
85
- }
86
- regex.lastIndex = this.charIndexToByteIndex();
87
- let result = regex.exec(this.string);
88
- if (result === null || result.length === 0) {
89
- return emptyString;
90
- }
91
- let match = result[0];
92
- this.advance(this.charLength(match));
93
- return match;
82
+ consumeBytes(byteCount) {
83
+ let byteIndex = this.charIndexToByteIndex();
84
+ let result = this.string.slice(byteIndex, byteIndex + byteCount);
85
+ this.advance(this.charLength(result));
86
+ return result;
94
87
  }
95
88
  /**
96
- * Consumes and returns all characters for which the given function returns a
97
- * truthy value, stopping on the first falsy return value or if the end of the
98
- * input is reached.
89
+ * Consumes and returns all characters for which the given function returns
90
+ * `true`, stopping when `false` is returned or the end of the input is
91
+ * reached.
99
92
  */
100
93
  consumeMatchFn(fn) {
101
- let char;
102
- let match = emptyString;
103
- while ((char = this.peek()) && fn(char)) {
104
- match += char;
105
- this.advance();
94
+ let { length, multiByteMode, string } = this;
95
+ let startByteIndex = this.charIndexToByteIndex();
96
+ let endByteIndex = startByteIndex;
97
+ if (multiByteMode) {
98
+ while (endByteIndex < length) {
99
+ let char = string[endByteIndex];
100
+ let isSurrogatePair = char >= '\uD800' && char <= '\uDBFF';
101
+ if (isSurrogatePair) {
102
+ char += string[endByteIndex + 1];
103
+ }
104
+ if (!fn(char)) {
105
+ break;
106
+ }
107
+ endByteIndex += isSurrogatePair ? 2 : 1;
108
+ }
109
+ }
110
+ else {
111
+ while (endByteIndex < length && fn(string[endByteIndex])) {
112
+ ++endByteIndex;
113
+ }
106
114
  }
107
- return match;
115
+ return this.consumeBytes(endByteIndex - startByteIndex);
108
116
  }
109
117
  /**
110
118
  * Consumes the given string if it exists at the current character index, and
@@ -114,29 +122,10 @@ class StringScanner {
114
122
  * string will be returned and the scanner will not be advanced.
115
123
  */
116
124
  consumeString(stringToConsume) {
117
- if (this.consumeStringFast(stringToConsume)) {
118
- return stringToConsume;
119
- }
120
- if (this.multiByteMode) {
121
- let { length } = stringToConsume;
122
- let charLengthToMatch = this.charLength(stringToConsume);
123
- if (charLengthToMatch !== length
124
- && stringToConsume === this.peek(charLengthToMatch)) {
125
- this.advance(charLengthToMatch);
126
- return stringToConsume;
127
- }
128
- }
129
- return emptyString;
130
- }
131
- /**
132
- * Does the same thing as `consumeString()`, but doesn't support consuming
133
- * multibyte characters. This can be faster if you only need to match single
134
- * byte characters.
135
- */
136
- consumeStringFast(stringToConsume) {
137
125
  let { length } = stringToConsume;
138
- if (this.peek(length) === stringToConsume) {
139
- this.advance(length);
126
+ let byteIndex = this.charIndexToByteIndex();
127
+ if (stringToConsume === this.string.slice(byteIndex, byteIndex + length)) {
128
+ this.advance(length === 1 ? 1 : this.charLength(stringToConsume));
140
129
  return stringToConsume;
141
130
  }
142
131
  return emptyString;
@@ -149,14 +138,12 @@ class StringScanner {
149
138
  * Returns the consumed string, or an empty string if nothing was consumed.
150
139
  */
151
140
  consumeUntilMatch(regex) {
152
- let restOfString = this.string.slice(this.charIndexToByteIndex());
153
- let matchByteIndex = restOfString.search(regex);
154
- if (matchByteIndex <= 0) {
155
- return emptyString;
156
- }
157
- let result = restOfString.slice(0, matchByteIndex);
158
- this.advance(this.charLength(result));
159
- return result;
141
+ let matchByteIndex = this.string
142
+ .slice(this.charIndexToByteIndex())
143
+ .search(regex);
144
+ return matchByteIndex > 0
145
+ ? this.consumeBytes(matchByteIndex)
146
+ : emptyString;
160
147
  }
161
148
  /**
162
149
  * Consumes characters until the given string is found, advancing the scanner
@@ -166,15 +153,11 @@ class StringScanner {
166
153
  * Returns the consumed string, or an empty string if nothing was consumed.
167
154
  */
168
155
  consumeUntilString(searchString) {
169
- let { string } = this;
170
156
  let byteIndex = this.charIndexToByteIndex();
171
- let matchByteIndex = string.indexOf(searchString, byteIndex);
172
- if (matchByteIndex <= 0) {
173
- return emptyString;
174
- }
175
- let result = string.slice(byteIndex, matchByteIndex);
176
- this.advance(this.charLength(result));
177
- return result;
157
+ let matchByteIndex = this.string.indexOf(searchString, byteIndex);
158
+ return matchByteIndex > 0
159
+ ? this.consumeBytes(matchByteIndex - byteIndex)
160
+ : emptyString;
178
161
  }
179
162
  /**
180
163
  * Returns the given number of characters starting at the current character
@@ -182,16 +165,10 @@ class StringScanner {
182
165
  * input string.
183
166
  */
184
167
  peek(count = 1) {
185
- let { charIndex, multiByteMode, string } = this;
186
- if (multiByteMode) {
187
- // Inlining this comparison instead of checking `this.isEnd` improves perf
188
- // slightly since `peek()` is called so frequently.
189
- if (charIndex >= this.charCount) {
190
- return emptyString;
191
- }
192
- return string.slice(this.charIndexToByteIndex(charIndex), this.charIndexToByteIndex(charIndex + count));
193
- }
194
- return string.slice(charIndex, charIndex + count);
168
+ let { charIndex, string } = this;
169
+ return this.multiByteMode
170
+ ? string.slice(this.charIndexToByteIndex(charIndex), this.charIndexToByteIndex(charIndex + count))
171
+ : string.slice(charIndex, charIndex + count);
195
172
  }
196
173
  /**
197
174
  * Resets the scanner position to the given character _index_, or to the start
@@ -1 +1 @@
1
- {"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AAC,SAAS,CAAC,EAAE,IAAI,CAAC,oBAAoB,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC;YAClG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,SAAS,GAAG,KAAK,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,GAAG,CAAC;QACb,IAAI,CAAC,SAAS,GAAG,KAAK,IAAI,CAAC;YACzB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC;YACjC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC;IAC1C,CAAC;CACF;AApND,sCAoNC"}
@@ -0,0 +1,30 @@
1
+ import { XmlNode } from './XmlNode.js';
2
+ /**
3
+ * An XML declaration within an XML document.
4
+ *
5
+ * @example
6
+ *
7
+ * ```xml
8
+ * <?xml version="1.0" encoding="UTF-8"?>
9
+ * ```
10
+ */
11
+ export declare class XmlDeclaration extends XmlNode {
12
+ /**
13
+ * Value of the encoding declaration in this XML declaration, or `null` if no
14
+ * encoding declaration was present.
15
+ */
16
+ encoding: string | null;
17
+ /**
18
+ * Value of the standalone declaration in this XML declaration, or `null` if
19
+ * no standalone declaration was present.
20
+ */
21
+ standalone: 'yes' | 'no' | null;
22
+ /**
23
+ * Value of the version declaration in this XML declaration.
24
+ */
25
+ version: string;
26
+ constructor(version: string, encoding?: string, standalone?: typeof XmlDeclaration.prototype.standalone);
27
+ get type(): string;
28
+ toJSON(): import("./types.js").JsonObject;
29
+ }
30
+ //# sourceMappingURL=XmlDeclaration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XmlDeclaration.d.ts","sourceRoot":"","sources":["../../src/lib/XmlDeclaration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;;;;;;;GAQG;AACH,qBAAa,cAAe,SAAQ,OAAO;IACzC;;;OAGG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAExB;;;OAGG;IACH,UAAU,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC;IAEhC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;gBAGd,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,OAAO,cAAc,CAAC,SAAS,CAAC,UAAU;IASzD,IAAa,IAAI,WAEhB;IAEQ,MAAM;CAYhB"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XmlDeclaration = void 0;
4
+ const XmlNode_js_1 = require("./XmlNode.js");
5
+ /**
6
+ * An XML declaration within an XML document.
7
+ *
8
+ * @example
9
+ *
10
+ * ```xml
11
+ * <?xml version="1.0" encoding="UTF-8"?>
12
+ * ```
13
+ */
14
+ class XmlDeclaration extends XmlNode_js_1.XmlNode {
15
+ constructor(version, encoding, standalone) {
16
+ super();
17
+ this.version = version;
18
+ this.encoding = encoding ?? null;
19
+ this.standalone = standalone ?? null;
20
+ }
21
+ get type() {
22
+ return XmlNode_js_1.XmlNode.TYPE_XML_DECLARATION;
23
+ }
24
+ toJSON() {
25
+ let json = XmlNode_js_1.XmlNode.prototype.toJSON.call(this);
26
+ json.version = this.version;
27
+ for (let key of ['encoding', 'standalone']) {
28
+ if (this[key] !== null) {
29
+ json[key] = this[key];
30
+ }
31
+ }
32
+ return json;
33
+ }
34
+ }
35
+ exports.XmlDeclaration = XmlDeclaration;
36
+ //# sourceMappingURL=XmlDeclaration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XmlDeclaration.js","sourceRoot":"","sources":["../../src/lib/XmlDeclaration.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AAEvC;;;;;;;;GAQG;AACH,MAAa,cAAe,SAAQ,oBAAO;IAkBzC,YACE,OAAe,EACf,QAAiB,EACjB,UAAuD;QAEvD,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,IAAI,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,UAAU,IAAI,IAAI,CAAC;IACvC,CAAC;IAED,IAAa,IAAI;QACf,OAAO,oBAAO,CAAC,oBAAoB,CAAC;IACtC,CAAC;IAEQ,MAAM;QACb,IAAI,IAAI,GAAG,oBAAO,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAE5B,KAAK,IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,YAAY,CAAU,EAAE,CAAC;YACpD,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;gBACvB,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA9CD,wCA8CC"}
@@ -1,6 +1,8 @@
1
1
  import { XmlElement } from './XmlElement.js';
2
2
  import { XmlNode } from './XmlNode.js';
3
3
  import type { XmlComment } from './XmlComment.js';
4
+ import type { XmlDeclaration } from './XmlDeclaration.js';
5
+ import type { XmlDocumentType } from './XmlDocumentType.js';
4
6
  import type { XmlProcessingInstruction } from './XmlProcessingInstruction.js';
5
7
  /**
6
8
  * Represents an XML document. All elements within the document are descendants
@@ -10,8 +12,8 @@ export declare class XmlDocument extends XmlNode {
10
12
  /**
11
13
  * Child nodes of this document.
12
14
  */
13
- readonly children: Array<XmlComment | XmlProcessingInstruction | XmlElement>;
14
- constructor(children?: Array<XmlComment | XmlElement | XmlProcessingInstruction>);
15
+ readonly children: Array<XmlComment | XmlDeclaration | XmlDocumentType | XmlProcessingInstruction | XmlElement>;
16
+ constructor(children?: Array<XmlComment | XmlDeclaration | XmlDocumentType | XmlElement | XmlProcessingInstruction>);
15
17
  get document(): this;
16
18
  /**
17
19
  * Root element of this document, or `null` if this document is empty.
@@ -1 +1 @@
1
- {"version":3,"file":"XmlDocument.d.ts","sourceRoot":"","sources":["../../src/lib/XmlDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAE9E;;;GAGG;AACH,qBAAa,WAAY,SAAQ,OAAO;IACtC;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,UAAU,GAAG,wBAAwB,GAAG,UAAU,CAAC,CAAC;gBAEjE,QAAQ,GAAE,KAAK,CAAC,UAAU,GAAG,UAAU,GAAG,wBAAwB,CAAM;IAKpF,IAAa,QAAQ,SAEpB;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,UAAU,GAAG,IAAI,CAQ5B;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAIjB;IAED,IAAa,IAAI,WAEhB;IAEQ,MAAM;;;CAKhB"}
1
+ {"version":3,"file":"XmlDocument.d.ts","sourceRoot":"","sources":["../../src/lib/XmlDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+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C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACxD,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;SACrD,CAAC,CAAC;IACL,CAAC;CACF;AA9CD,kCA8CC"}
@@ -0,0 +1,37 @@
1
+ import { XmlNode } from './XmlNode.js';
2
+ /**
3
+ * A document type declaration within an XML document.
4
+ *
5
+ * @example
6
+ *
7
+ * ```xml
8
+ * <!DOCTYPE kittens [
9
+ * <!ELEMENT kittens (#PCDATA)>
10
+ * ]>
11
+ * ```
12
+ */
13
+ export declare class XmlDocumentType extends XmlNode {
14
+ /**
15
+ * Name of the root element described by this document type declaration.
16
+ */
17
+ name: string;
18
+ /**
19
+ * Public identifier of the external subset of this document type declaration,
20
+ * or `null` if no public identifier was present.
21
+ */
22
+ publicId: string | null;
23
+ /**
24
+ * System identifier of the external subset of this document type declaration,
25
+ * or `null` if no system identifier was present.
26
+ */
27
+ systemId: string | null;
28
+ /**
29
+ * Internal subset of this document type declaration, or `null` if no internal
30
+ * subset was present.
31
+ */
32
+ internalSubset: string | null;
33
+ constructor(name: string, publicId?: string, systemId?: string, internalSubset?: string);
34
+ get type(): string;
35
+ toJSON(): import("./types.js").JsonObject;
36
+ }
37
+ //# sourceMappingURL=XmlDocumentType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XmlDocumentType.d.ts","sourceRoot":"","sources":["../../src/lib/XmlDocumentType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;;;;;;;;;GAUG;AACH,qBAAa,eAAgB,SAAQ,OAAO;IAC1C;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAExB;;;OAGG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAExB;;;OAGG;IACH,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;gBAG5B,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,MAAM,EACjB,cAAc,CAAC,EAAE,MAAM;IASzB,IAAa,IAAI,WAEhB;IAEQ,MAAM;CAYhB"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XmlDocumentType = void 0;
4
+ const XmlNode_js_1 = require("./XmlNode.js");
5
+ /**
6
+ * A document type declaration within an XML document.
7
+ *
8
+ * @example
9
+ *
10
+ * ```xml
11
+ * <!DOCTYPE kittens [
12
+ * <!ELEMENT kittens (#PCDATA)>
13
+ * ]>
14
+ * ```
15
+ */
16
+ class XmlDocumentType extends XmlNode_js_1.XmlNode {
17
+ constructor(name, publicId, systemId, internalSubset) {
18
+ super();
19
+ this.name = name;
20
+ this.publicId = publicId ?? null;
21
+ this.systemId = systemId ?? null;
22
+ this.internalSubset = internalSubset ?? null;
23
+ }
24
+ get type() {
25
+ return XmlNode_js_1.XmlNode.TYPE_DOCUMENT_TYPE;
26
+ }
27
+ toJSON() {
28
+ let json = XmlNode_js_1.XmlNode.prototype.toJSON.call(this);
29
+ json.name = this.name;
30
+ for (let key of ['publicId', 'systemId', 'internalSubset']) {
31
+ if (this[key] !== null) {
32
+ json[key] = this[key];
33
+ }
34
+ }
35
+ return json;
36
+ }
37
+ }
38
+ exports.XmlDocumentType = XmlDocumentType;
39
+ //# sourceMappingURL=XmlDocumentType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XmlDocumentType.js","sourceRoot":"","sources":["../../src/lib/XmlDocumentType.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AAEvC;;;;;;;;;;GAUG;AACH,MAAa,eAAgB,SAAQ,oBAAO;IAwB1C,YACE,IAAY,EACZ,QAAiB,EACjB,QAAiB,EACjB,cAAuB;QAEvB,KAAK,EAAE,CAAC;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1,24 @@
1
+ /**
2
+ * An error that occurred while parsing XML.
3
+ */
4
+ export declare class XmlError extends Error {
5
+ /**
6
+ * Character column at which this error occurred (1-based).
7
+ */
8
+ readonly column: number;
9
+ /**
10
+ * Short excerpt from the input string that contains the problem.
11
+ */
12
+ readonly excerpt: string;
13
+ /**
14
+ * Line number at which this error occurred (1-based).
15
+ */
16
+ readonly line: number;
17
+ /**
18
+ * Character position at which this error occurred relative to the beginning
19
+ * of the input (0-based).
20
+ */
21
+ readonly pos: number;
22
+ constructor(message: string, charIndex: number, xml: string);
23
+ }
24
+ //# sourceMappingURL=XmlError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XmlError.d.ts","sourceRoot":"","sources":["../../src/lib/XmlError.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;gBAGnB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM;CAmDd"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XmlError = void 0;
4
+ /**
5
+ * An error that occurred while parsing XML.
6
+ */
7
+ class XmlError extends Error {
8
+ constructor(message, charIndex, xml) {
9
+ let column = 1;
10
+ let excerpt = '';
11
+ let line = 1;
12
+ // Find the line and column where the error occurred.
13
+ for (let i = 0; i < charIndex; ++i) {
14
+ let char = xml[i];
15
+ if (char === '\n') {
16
+ column = 1;
17
+ excerpt = '';
18
+ line += 1;
19
+ }
20
+ else {
21
+ column += 1;
22
+ excerpt += char;
23
+ }
24
+ }
25
+ let eol = xml.indexOf('\n', charIndex);
26
+ excerpt += eol === -1
27
+ ? xml.slice(charIndex)
28
+ : xml.slice(charIndex, eol);
29
+ let excerptStart = 0;
30
+ // Keep the excerpt below 50 chars, but always keep the error position in
31
+ // view.
32
+ if (excerpt.length > 50) {
33
+ if (column < 40) {
34
+ excerpt = excerpt.slice(0, 50);
35
+ }
36
+ else {
37
+ excerptStart = column - 20;
38
+ excerpt = excerpt.slice(excerptStart, column + 30);
39
+ }
40
+ }
41
+ super(`${message} (line ${line}, column ${column})\n`
42
+ + ` ${excerpt}\n`
43
+ + ' '.repeat(column - excerptStart + 1) + '^\n');
44
+ this.column = column;
45
+ this.excerpt = excerpt;
46
+ this.line = line;
47
+ this.name = 'XmlError';
48
+ this.pos = charIndex;
49
+ }
50
+ }
51
+ exports.XmlError = XmlError;
52
+ //# sourceMappingURL=XmlError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XmlError.js","sourceRoot":"","sources":["../../src/lib/XmlError.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,QAAS,SAAQ,KAAK;IAsBjC,YACE,OAAe,EACf,SAAiB,EACjB,GAAW;QAEX,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,IAAI,IAAI,GAAG,CAAC,CAAC;QAEb,qDAAqD;QACrD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC;YACnC,IAAI,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;YAElB,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;gBAClB,MAAM,GAAG,CAAC,CAAC;gBACX,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,IAAI,CAAC,CAAC;YACZ,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,CAAC,CAAC;gBACZ,OAAO,IAAI,IAAI,CAAC;YAClB,CAAC;QACH,CAAC;QAED,IAAI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