xml-tokenizer 0.0.31 → 0.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/config.js +43 -1
- package/dist/cjs/config.js.map +1 -0
- package/dist/cjs/get-q-name.js +8 -1
- package/dist/cjs/get-q-name.js.map +1 -0
- package/dist/cjs/index.js +80 -1
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/selector/TokenSelectState.js +107 -1
- package/dist/cjs/selector/TokenSelectState.js.map +1 -0
- package/dist/cjs/selector/TokenSelectStateMachine.js +151 -1
- package/dist/cjs/selector/TokenSelectStateMachine.js.map +1 -0
- package/dist/cjs/selector/TokenSelector.js +140 -1
- package/dist/cjs/selector/TokenSelector.js.map +1 -0
- package/dist/cjs/selector/match-string.js +22 -1
- package/dist/cjs/selector/match-string.js.map +1 -0
- package/dist/cjs/selector/select.js +20 -1
- package/dist/cjs/selector/select.js.map +1 -0
- package/dist/cjs/token-to-xml.js +45 -1
- package/dist/cjs/token-to-xml.js.map +1 -0
- package/dist/cjs/tokenizer/XmlError.js +97 -1
- package/dist/cjs/tokenizer/XmlError.js.map +1 -0
- package/dist/cjs/tokenizer/XmlStream.js +479 -1
- package/dist/cjs/tokenizer/XmlStream.js.map +1 -0
- package/dist/cjs/tokenizer/ascii-constants.js +70 -1
- package/dist/cjs/tokenizer/ascii-constants.js.map +1 -0
- package/dist/cjs/tokenizer/tokenize.js +420 -1
- package/dist/cjs/tokenizer/tokenize.js.map +1 -0
- package/dist/cjs/tokenizer/utils.js +48 -1
- package/dist/cjs/tokenizer/utils.js.map +1 -0
- package/dist/cjs/tokens-to-xml.js +14 -1
- package/dist/cjs/tokens-to-xml.js.map +1 -0
- package/dist/cjs/xml-to-object.js +70 -1
- package/dist/cjs/xml-to-object.js.map +1 -0
- package/dist/cjs/xml-to-simplified-object.js +87 -1
- package/dist/cjs/xml-to-simplified-object.js.map +1 -0
- package/dist/esm/config.js +39 -1
- package/dist/esm/config.js.map +1 -0
- package/dist/esm/get-q-name.js +6 -1
- package/dist/esm/get-q-name.js.map +1 -0
- package/dist/esm/index.js +16 -1
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/selector/TokenSelectState.js +103 -1
- package/dist/esm/selector/TokenSelectState.js.map +1 -0
- package/dist/esm/selector/TokenSelectStateMachine.js +149 -1
- package/dist/esm/selector/TokenSelectStateMachine.js.map +1 -0
- package/dist/esm/selector/TokenSelector.js +138 -1
- package/dist/esm/selector/TokenSelector.js.map +1 -0
- package/dist/esm/selector/match-string.js +20 -1
- package/dist/esm/selector/match-string.js.map +1 -0
- package/dist/esm/selector/select.js +18 -1
- package/dist/esm/selector/select.js.map +1 -0
- package/dist/esm/token-to-xml.js +43 -1
- package/dist/esm/token-to-xml.js.map +1 -0
- package/dist/esm/tokenizer/XmlError.js +95 -1
- package/dist/esm/tokenizer/XmlError.js.map +1 -0
- package/dist/esm/tokenizer/XmlStream.js +477 -1
- package/dist/esm/tokenizer/XmlStream.js.map +1 -0
- package/dist/esm/tokenizer/ascii-constants.js +36 -1
- package/dist/esm/tokenizer/ascii-constants.js.map +1 -0
- package/dist/esm/tokenizer/tokenize.js +417 -1
- package/dist/esm/tokenizer/tokenize.js.map +1 -0
- package/dist/esm/tokenizer/utils.js +41 -1
- package/dist/esm/tokenizer/utils.js.map +1 -0
- package/dist/esm/tokens-to-xml.js +12 -1
- package/dist/esm/tokens-to-xml.js.map +1 -0
- package/dist/esm/xml-to-object.js +67 -1
- package/dist/esm/xml-to-object.js.map +1 -0
- package/dist/esm/xml-to-simplified-object.js +84 -1
- package/dist/esm/xml-to-simplified-object.js.map +1 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/get-q-name.d.ts +1 -0
- package/dist/types/get-q-name.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/selector/TokenSelectState.d.ts +1 -0
- package/dist/types/selector/TokenSelectState.d.ts.map +1 -0
- package/dist/types/selector/TokenSelectStateMachine.d.ts +1 -0
- package/dist/types/selector/TokenSelectStateMachine.d.ts.map +1 -0
- package/dist/types/selector/TokenSelector.d.ts +1 -0
- package/dist/types/selector/TokenSelector.d.ts.map +1 -0
- package/dist/types/selector/index.d.ts +1 -0
- package/dist/types/selector/index.d.ts.map +1 -0
- package/dist/types/selector/match-string.d.ts +1 -0
- package/dist/types/selector/match-string.d.ts.map +1 -0
- package/dist/types/selector/select.d.ts +1 -0
- package/dist/types/selector/select.d.ts.map +1 -0
- package/dist/types/selector/types.d.ts +1 -0
- package/dist/types/selector/types.d.ts.map +1 -0
- package/dist/types/token-to-xml.d.ts +1 -0
- package/dist/types/token-to-xml.d.ts.map +1 -0
- package/dist/types/tokenizer/XmlError.d.ts +1 -0
- package/dist/types/tokenizer/XmlError.d.ts.map +1 -0
- package/dist/types/tokenizer/XmlStream.d.ts +1 -0
- package/dist/types/tokenizer/XmlStream.d.ts.map +1 -0
- package/dist/types/tokenizer/ascii-constants.d.ts +1 -0
- package/dist/types/tokenizer/ascii-constants.d.ts.map +1 -0
- package/dist/types/tokenizer/index.d.ts +1 -0
- package/dist/types/tokenizer/index.d.ts.map +1 -0
- package/dist/types/tokenizer/tokenize.d.ts +1 -0
- package/dist/types/tokenizer/tokenize.d.ts.map +1 -0
- package/dist/types/tokenizer/types.d.ts +1 -0
- package/dist/types/tokenizer/types.d.ts.map +1 -0
- package/dist/types/tokenizer/utils.d.ts +1 -0
- package/dist/types/tokenizer/utils.d.ts.map +1 -0
- package/dist/types/tokens-to-xml.d.ts +1 -0
- package/dist/types/tokens-to-xml.d.ts.map +1 -0
- package/dist/types/xml-to-object.d.ts +1 -0
- package/dist/types/xml-to-object.d.ts.map +1 -0
- package/dist/types/xml-to-simplified-object.d.ts +1 -0
- package/dist/types/xml-to-simplified-object.d.ts.map +1 -0
- package/package.json +6 -5
|
@@ -1 +1,477 @@
|
|
|
1
|
-
import{AMPERSAND
|
|
1
|
+
import { AMPERSAND, HASH, LOWERCASE_X, ZERO, NINE, UPPERCASE_A, UPPERCASE_F, LOWERCASE_A, LOWERCASE_F, SEMICOLON, COLON, SINGLE_QUOTE, DOUBLE_QUOTE, LINE_FEED } from './ascii-constants.js';
|
|
2
|
+
import { isXmlChar, isXmlSpaceByte, isAsciiDigit, isXmlNameStart, isXmlName } from './utils.js';
|
|
3
|
+
import { XmlError } from './XmlError.js';
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
|
+
class XmlStream {
|
|
23
|
+
constructor(text, options = {}) {
|
|
24
|
+
__publicField(this, "_text");
|
|
25
|
+
__publicField(this, "_pos");
|
|
26
|
+
__publicField(this, "_end");
|
|
27
|
+
__publicField(this, "config");
|
|
28
|
+
const {
|
|
29
|
+
pos = 0,
|
|
30
|
+
strictDocument = true,
|
|
31
|
+
allowDtd = true,
|
|
32
|
+
rawTextElements = null,
|
|
33
|
+
implicitSelfClosingElements = null,
|
|
34
|
+
contextSliceSize = false
|
|
35
|
+
} = options;
|
|
36
|
+
this._text = text;
|
|
37
|
+
this._pos = pos;
|
|
38
|
+
this._end = this._text.length;
|
|
39
|
+
this.config = {
|
|
40
|
+
strictDocument,
|
|
41
|
+
allowDtd,
|
|
42
|
+
rawTextElements,
|
|
43
|
+
implicitSelfClosingElements,
|
|
44
|
+
contextSliceSize
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Creates a clone of the current stream.
|
|
49
|
+
*
|
|
50
|
+
* @returns A new instance of XmlStream with the same state.
|
|
51
|
+
*/
|
|
52
|
+
clone() {
|
|
53
|
+
return new XmlStream(this._text, __spreadValues({ pos: this._pos }, this.config));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Gets the current position in the stream.
|
|
57
|
+
*
|
|
58
|
+
* @returns The current position.
|
|
59
|
+
*/
|
|
60
|
+
getPos() {
|
|
61
|
+
return this._pos;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Checks if the stream is at the end.
|
|
65
|
+
*
|
|
66
|
+
* @returns True if at the end, false otherwise.
|
|
67
|
+
*/
|
|
68
|
+
atEnd() {
|
|
69
|
+
return this._pos >= this._end;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Gets the current code unit in the stream.
|
|
73
|
+
*
|
|
74
|
+
* @returns The current code unit.
|
|
75
|
+
* @throws XmlError if at the end of the stream.
|
|
76
|
+
*/
|
|
77
|
+
currCodeUnit() {
|
|
78
|
+
if (this._pos >= this._end) {
|
|
79
|
+
throw new XmlError({ type: "UnexpectedEndOfStream" });
|
|
80
|
+
}
|
|
81
|
+
return this._text.charCodeAt(this._pos);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Gets the current code unit without checking for the end.
|
|
85
|
+
*
|
|
86
|
+
* @returns The current code unit.
|
|
87
|
+
*/
|
|
88
|
+
currCodeUnitUnchecked() {
|
|
89
|
+
return this._text.charCodeAt(this._pos);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Gets the next code unit in the stream.
|
|
93
|
+
*
|
|
94
|
+
* @returns The next code unit.
|
|
95
|
+
* @throws XmlError if at the end of the stream.
|
|
96
|
+
*/
|
|
97
|
+
nextCodeUnit() {
|
|
98
|
+
if (this._pos + 1 >= this._end) {
|
|
99
|
+
throw new XmlError({ type: "UnexpectedEndOfStream" });
|
|
100
|
+
}
|
|
101
|
+
return this._text.charCodeAt(this._pos + 1);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Consumes a specific code unit (character) from the stream.
|
|
105
|
+
*
|
|
106
|
+
* @param codeUnit - The code unit to consume.
|
|
107
|
+
* @throws XmlError if the current code unit doesn't match or if at the end.
|
|
108
|
+
*/
|
|
109
|
+
consumeCodeUnit(codeUnit) {
|
|
110
|
+
const currCodeUnit = this.currCodeUnit();
|
|
111
|
+
if (currCodeUnit !== codeUnit) {
|
|
112
|
+
throw new XmlError(
|
|
113
|
+
{ type: "InvalidChar", expected: codeUnit, actual: currCodeUnit },
|
|
114
|
+
this.genTextPos()
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
this._pos += 1;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Tries to consume a specific code unit (character) from the stream.
|
|
121
|
+
* Unlike `consumeCodeUnit`, it will not throw any errors.
|
|
122
|
+
*
|
|
123
|
+
* @param codeUnit - The code unit to consume.
|
|
124
|
+
* @returns True if the code unit was consumed, false otherwise.
|
|
125
|
+
*/
|
|
126
|
+
tryConsumeCodeUnit(codeUnit) {
|
|
127
|
+
if (this.currCodeUnit() === codeUnit) {
|
|
128
|
+
this._pos += 1;
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Consumes code units that satisfy a predicate function.
|
|
135
|
+
*
|
|
136
|
+
* @param predicate - The function to test each code unit.
|
|
137
|
+
* @returns The consumed string.
|
|
138
|
+
*/
|
|
139
|
+
consumeCodeUnitsWhile(predicate) {
|
|
140
|
+
const start = this._pos;
|
|
141
|
+
this.skipCodeUnitsWhile(predicate);
|
|
142
|
+
return this.sliceBack(start);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Skips code units that satisfy a predicate function.
|
|
146
|
+
*
|
|
147
|
+
* @param predicate - The function to test each code unit.
|
|
148
|
+
*/
|
|
149
|
+
skipCodeUnitsWhile(predicate) {
|
|
150
|
+
while (this._pos < this._end && predicate(this.currCodeUnitUnchecked(), this)) {
|
|
151
|
+
if (!isXmlChar(this.currCodeUnitUnchecked())) {
|
|
152
|
+
throw new XmlError(
|
|
153
|
+
{
|
|
154
|
+
type: "NonXmlChar",
|
|
155
|
+
char: String.fromCodePoint(this.currCodeUnitUnchecked())
|
|
156
|
+
},
|
|
157
|
+
this.genTextPos()
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
this._pos += 1;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Advances the stream position by the specified number of characters.
|
|
165
|
+
*
|
|
166
|
+
* @param n - The number of characters to advance.
|
|
167
|
+
*/
|
|
168
|
+
advance(n) {
|
|
169
|
+
this._pos += n;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Go to a new position in the stream.
|
|
173
|
+
*
|
|
174
|
+
* @param pos - The new position.
|
|
175
|
+
*/
|
|
176
|
+
goTo(pos) {
|
|
177
|
+
this._pos = pos;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Go to the end of the stream.
|
|
181
|
+
*/
|
|
182
|
+
goToEnd() {
|
|
183
|
+
this._pos = this._end;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Checks if the stream starts with the given text.
|
|
187
|
+
*
|
|
188
|
+
* @param text - The text to check.
|
|
189
|
+
* @returns True if the stream starts with the text, false otherwise.
|
|
190
|
+
*/
|
|
191
|
+
startsWith(text) {
|
|
192
|
+
return this._text.startsWith(text, this._pos);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Skips a specific string in the stream.
|
|
196
|
+
*
|
|
197
|
+
* @param text - The string to skip.
|
|
198
|
+
* @throws XmlError if the stream doesn't start with the given string.
|
|
199
|
+
*/
|
|
200
|
+
skipString(text) {
|
|
201
|
+
if (!this.startsWith(text)) {
|
|
202
|
+
throw new XmlError({ type: "InvalidString", expected: text }, this.genTextPos());
|
|
203
|
+
}
|
|
204
|
+
this._pos += text.length;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Slices the text from the given position to the current position.
|
|
208
|
+
*
|
|
209
|
+
* @param pos - The start position.
|
|
210
|
+
* @returns The sliced string.
|
|
211
|
+
*/
|
|
212
|
+
sliceBack(pos) {
|
|
213
|
+
return this._text.slice(pos, this._pos);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Creates a range from the given start position to the current position.
|
|
217
|
+
*
|
|
218
|
+
* @param start - The start position.
|
|
219
|
+
* @returns The range object.
|
|
220
|
+
*/
|
|
221
|
+
rangeFrom(start) {
|
|
222
|
+
return { start, end: this._pos };
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Skips whitespace characters in the stream.
|
|
226
|
+
*/
|
|
227
|
+
skipSpaces() {
|
|
228
|
+
while (this.startsWithSpace()) {
|
|
229
|
+
this._pos += 1;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Checks if the stream starts with a whitespace character.
|
|
234
|
+
*
|
|
235
|
+
* @returns True if it starts with a whitespace, false otherwise.
|
|
236
|
+
*/
|
|
237
|
+
startsWithSpace() {
|
|
238
|
+
return this._pos < this._end && isXmlSpaceByte(this.currCodeUnitUnchecked());
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Consumes whitespace characters in the stream.
|
|
242
|
+
* Like `skipSpaces`, but checks that the first char is actually a space.
|
|
243
|
+
*
|
|
244
|
+
* @throws XmlError if the stream doesn't start with a whitespace or is at the end.
|
|
245
|
+
*/
|
|
246
|
+
consumeSpaces() {
|
|
247
|
+
if (this._pos >= this._end) {
|
|
248
|
+
throw new XmlError({ type: "UnexpectedEndOfStream" }, this.genTextPos());
|
|
249
|
+
}
|
|
250
|
+
if (!this.startsWithSpace()) {
|
|
251
|
+
throw new XmlError(
|
|
252
|
+
{ type: "InvalidChar", expected: "a whitespace", actual: this.currCodeUnitUnchecked() },
|
|
253
|
+
this.genTextPos()
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
this.skipSpaces();
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Tries to consume a reference (entity or character reference).
|
|
260
|
+
* Consumes according to: https://www.w3.org/TR/xml/#NT-Reference
|
|
261
|
+
*
|
|
262
|
+
* @returns The consumed reference or null if not a reference.
|
|
263
|
+
*/
|
|
264
|
+
tryConsumeReference() {
|
|
265
|
+
const start = this._pos;
|
|
266
|
+
const subStream = this.clone();
|
|
267
|
+
const result = subStream.consumeReference();
|
|
268
|
+
if (result != null) {
|
|
269
|
+
this._pos += subStream.getPos() - start;
|
|
270
|
+
return result;
|
|
271
|
+
}
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Consumes a reference (entity or character reference).
|
|
276
|
+
*
|
|
277
|
+
* @returns The consumed reference or null if not a reference.
|
|
278
|
+
*/
|
|
279
|
+
consumeReference() {
|
|
280
|
+
if (!this.tryConsumeCodeUnit(AMPERSAND)) {
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
let reference;
|
|
284
|
+
if (this.tryConsumeCodeUnit(HASH)) {
|
|
285
|
+
let value;
|
|
286
|
+
let radix;
|
|
287
|
+
if (this.tryConsumeCodeUnit(LOWERCASE_X)) {
|
|
288
|
+
value = this.consumeCodeUnitsWhile(
|
|
289
|
+
(codeUnit) => codeUnit >= ZERO && codeUnit <= NINE || codeUnit >= UPPERCASE_A && codeUnit <= UPPERCASE_F || codeUnit >= LOWERCASE_A && codeUnit <= LOWERCASE_F
|
|
290
|
+
);
|
|
291
|
+
radix = 16;
|
|
292
|
+
} else {
|
|
293
|
+
value = this.consumeCodeUnitsWhile((codeUnit) => isAsciiDigit(codeUnit));
|
|
294
|
+
radix = 10;
|
|
295
|
+
}
|
|
296
|
+
const codePoint = parseInt(value, radix);
|
|
297
|
+
if (isNaN(codePoint) || !isXmlChar(codePoint)) {
|
|
298
|
+
reference = null;
|
|
299
|
+
} else {
|
|
300
|
+
reference = { type: "Char", value: String.fromCodePoint(codePoint) };
|
|
301
|
+
}
|
|
302
|
+
} else {
|
|
303
|
+
const name = this.consumeName();
|
|
304
|
+
switch (name) {
|
|
305
|
+
case "quot":
|
|
306
|
+
reference = { type: "Char", value: '"' };
|
|
307
|
+
break;
|
|
308
|
+
case "amp":
|
|
309
|
+
reference = { type: "Char", value: "&" };
|
|
310
|
+
break;
|
|
311
|
+
case "apos":
|
|
312
|
+
reference = { type: "Char", value: "'" };
|
|
313
|
+
break;
|
|
314
|
+
case "lt":
|
|
315
|
+
reference = { type: "Char", value: "<" };
|
|
316
|
+
break;
|
|
317
|
+
case "gt":
|
|
318
|
+
reference = { type: "Char", value: ">" };
|
|
319
|
+
break;
|
|
320
|
+
default:
|
|
321
|
+
reference = { type: "Entity", value: name };
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
if (!this.tryConsumeCodeUnit(SEMICOLON)) {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
return reference;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Consumes a XML name.
|
|
331
|
+
* Consumes according to: https://www.w3.org/TR/xml/#NT-Name
|
|
332
|
+
*
|
|
333
|
+
* @returns The consumed name.
|
|
334
|
+
* @throws XmlError if an invalid name is encountered.
|
|
335
|
+
*/
|
|
336
|
+
consumeName() {
|
|
337
|
+
const start = this._pos;
|
|
338
|
+
this.skipName();
|
|
339
|
+
const name = this.sliceBack(start);
|
|
340
|
+
if (name.length === 0) {
|
|
341
|
+
throw new XmlError({ type: "InvalidName" }, this.genTextPosFrom(start));
|
|
342
|
+
}
|
|
343
|
+
return name;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Skips a XML name.
|
|
347
|
+
* The same as `consumeName`, but does not return the consumed name.
|
|
348
|
+
* @throws XmlError if an invalid name is encountered.
|
|
349
|
+
*/
|
|
350
|
+
skipName() {
|
|
351
|
+
const start = this._pos;
|
|
352
|
+
while (this._pos < this._end) {
|
|
353
|
+
const currCodeUnit = this.currCodeUnitUnchecked();
|
|
354
|
+
if (this._pos === start) {
|
|
355
|
+
if (!isXmlNameStart(currCodeUnit)) {
|
|
356
|
+
throw new XmlError({ type: "InvalidName" }, this.genTextPosFrom(start));
|
|
357
|
+
}
|
|
358
|
+
} else if (!isXmlName(currCodeUnit)) {
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
this._pos += 1;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Consumes a qualified XML name and returns it.
|
|
366
|
+
* Consumes according to: https://www.w3.org/TR/xml-names/#ns-qualnames
|
|
367
|
+
*
|
|
368
|
+
* @returns The prefix and local name as a tuple.
|
|
369
|
+
* @throws XmlError if an invalid qualified XML name is encountered.
|
|
370
|
+
*/
|
|
371
|
+
consumeQName() {
|
|
372
|
+
var _a, _b;
|
|
373
|
+
const start = this._pos;
|
|
374
|
+
let splitter = null;
|
|
375
|
+
while (this._pos < this._end) {
|
|
376
|
+
const currCodeUnit = this.currCodeUnitUnchecked();
|
|
377
|
+
if (currCodeUnit === COLON) {
|
|
378
|
+
if (splitter == null) {
|
|
379
|
+
splitter = this._pos;
|
|
380
|
+
this._pos += 1;
|
|
381
|
+
} else {
|
|
382
|
+
throw new XmlError({ type: "InvalidName" }, this.genTextPosFrom(start));
|
|
383
|
+
}
|
|
384
|
+
} else if (isXmlName(currCodeUnit)) {
|
|
385
|
+
this._pos += 1;
|
|
386
|
+
} else {
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
let prefix;
|
|
391
|
+
let local;
|
|
392
|
+
if (splitter != null) {
|
|
393
|
+
prefix = this._text.slice(start, splitter);
|
|
394
|
+
local = this.sliceBack(splitter + 1);
|
|
395
|
+
} else {
|
|
396
|
+
prefix = "";
|
|
397
|
+
local = this.sliceBack(start);
|
|
398
|
+
}
|
|
399
|
+
if (prefix.length > 0 && !isXmlNameStart((_a = prefix[0]) == null ? void 0 : _a.codePointAt(0))) {
|
|
400
|
+
throw new XmlError({ type: "InvalidName" }, this.genTextPosFrom(start));
|
|
401
|
+
}
|
|
402
|
+
if (local.length > 0) {
|
|
403
|
+
if (!isXmlNameStart((_b = local[0]) == null ? void 0 : _b.codePointAt(0))) {
|
|
404
|
+
throw new XmlError({ type: "InvalidName" }, this.genTextPosFrom(start));
|
|
405
|
+
}
|
|
406
|
+
} else {
|
|
407
|
+
throw new XmlError({ type: "InvalidName" }, this.genTextPosFrom(start));
|
|
408
|
+
}
|
|
409
|
+
return [prefix, local];
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Consumes a quote character.
|
|
413
|
+
*
|
|
414
|
+
* @returns The consumed quote character.
|
|
415
|
+
* @throws XmlError if an invalid quote character is encountered.
|
|
416
|
+
*/
|
|
417
|
+
consumeQuote() {
|
|
418
|
+
const currCodeUnit = this.currCodeUnit();
|
|
419
|
+
if (currCodeUnit === SINGLE_QUOTE || currCodeUnit === DOUBLE_QUOTE) {
|
|
420
|
+
this._pos += 1;
|
|
421
|
+
return currCodeUnit;
|
|
422
|
+
}
|
|
423
|
+
throw new XmlError(
|
|
424
|
+
{ type: "InvalidChar", expected: "a quote", actual: currCodeUnit },
|
|
425
|
+
this.genTextPos()
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Returns a slice of text centered around the specified position.
|
|
430
|
+
*
|
|
431
|
+
* @param pos - The center position for the slice.
|
|
432
|
+
* @param size - The total size of the slice (will extend size/2 in each direction).
|
|
433
|
+
* @returns A string containing the text around the position.
|
|
434
|
+
*/
|
|
435
|
+
getTextAround(pos, size) {
|
|
436
|
+
const halfSize = Math.floor(size / 2);
|
|
437
|
+
const start = Math.max(0, pos - halfSize);
|
|
438
|
+
const end = Math.min(this._end, pos + halfSize + size % 2);
|
|
439
|
+
return this._text.slice(start, end);
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Calculates the current absolute position.
|
|
443
|
+
* This operation is very expensive. Use only for errors.
|
|
444
|
+
*
|
|
445
|
+
* @returns The current text position.
|
|
446
|
+
*/
|
|
447
|
+
genTextPos() {
|
|
448
|
+
return this.genTextPosFrom(this._pos);
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Calculates an absolute position at the specified position.
|
|
452
|
+
* This operation is very expensive. Use only for errors.
|
|
453
|
+
*
|
|
454
|
+
* @param pos - The position to calculate from.
|
|
455
|
+
* @returns The calculated text position.
|
|
456
|
+
*/
|
|
457
|
+
genTextPosFrom(pos) {
|
|
458
|
+
const clampedPos = Math.min(pos, this._end);
|
|
459
|
+
let row = 1;
|
|
460
|
+
let col = 1;
|
|
461
|
+
for (let i = 0; i < clampedPos; i++) {
|
|
462
|
+
if (this._text.charCodeAt(i) === LINE_FEED) {
|
|
463
|
+
row++;
|
|
464
|
+
col = 1;
|
|
465
|
+
} else {
|
|
466
|
+
col++;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
return __spreadValues({
|
|
470
|
+
row,
|
|
471
|
+
col
|
|
472
|
+
}, this.config.contextSliceSize ? { contextSlice: this.getTextAround(pos, this.config.contextSliceSize) } : {});
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
export { XmlStream };
|
|
477
|
+
//# sourceMappingURL=XmlStream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XmlStream.js","sources":["../../../src/tokenizer/XmlStream.ts"],"sourcesContent":["import {\n\tAMPERSAND,\n\tCOLON,\n\tDOUBLE_QUOTE,\n\tHASH,\n\tLINE_FEED,\n\tLOWERCASE_A,\n\tLOWERCASE_F,\n\tLOWERCASE_X,\n\tNINE,\n\tSEMICOLON,\n\tSINGLE_QUOTE,\n\tUPPERCASE_A,\n\tUPPERCASE_F,\n\tZERO\n} from './ascii-constants';\nimport { type TRange, type TReference, type TTextPos } from './types';\nimport { isAsciiDigit, isXmlChar, isXmlName, isXmlNameStart, isXmlSpaceByte } from './utils';\nimport { XmlError } from './XmlError';\n\n/**\n * A stream of characters for parsing XML-like content.\n *\n * This implementation uses UTF-16 code units, whereas the Rust implementation is based on bytes (UTF-8).\n * This difference in encoding affects how characters are handled and parsed.\n * For more details, refer to the FAQ.\n */\nexport class XmlStream {\n\tprivate _text: string;\n\tprivate _pos: number;\n\tprivate _end: number;\n\n\tpublic readonly config: TXmlStreamConfig;\n\n\tpublic constructor(text: string, options: TXmlStreamOptions = {}) {\n\t\tconst {\n\t\t\tpos = 0,\n\t\t\tstrictDocument = true,\n\t\t\tallowDtd = true,\n\t\t\trawTextElements = null,\n\t\t\timplicitSelfClosingElements = null,\n\t\t\tcontextSliceSize = false\n\t\t} = options;\n\t\tthis._text = text;\n\t\tthis._pos = pos;\n\t\tthis._end = this._text.length;\n\t\tthis.config = {\n\t\t\tstrictDocument,\n\t\t\tallowDtd,\n\t\t\trawTextElements,\n\t\t\timplicitSelfClosingElements,\n\t\t\tcontextSliceSize\n\t\t};\n\t}\n\n\t/**\n\t * Creates a clone of the current stream.\n\t *\n\t * @returns A new instance of XmlStream with the same state.\n\t */\n\tpublic clone(): XmlStream {\n\t\treturn new XmlStream(this._text, { pos: this._pos, ...this.config });\n\t}\n\n\t/**\n\t * Gets the current position in the stream.\n\t *\n\t * @returns The current position.\n\t */\n\tpublic getPos(): number {\n\t\treturn this._pos;\n\t}\n\n\t/**\n\t * Checks if the stream is at the end.\n\t *\n\t * @returns True if at the end, false otherwise.\n\t */\n\tpublic atEnd(): boolean {\n\t\treturn this._pos >= this._end;\n\t}\n\n\t/**\n\t * Gets the current code unit in the stream.\n\t *\n\t * @returns The current code unit.\n\t * @throws XmlError if at the end of the stream.\n\t */\n\tpublic currCodeUnit(): number {\n\t\tif (this._pos >= this._end) {\n\t\t\tthrow new XmlError({ type: 'UnexpectedEndOfStream' });\n\t\t}\n\t\treturn this._text.charCodeAt(this._pos);\n\t}\n\n\t/**\n\t * Gets the current code unit without checking for the end.\n\t *\n\t * @returns The current code unit.\n\t */\n\tpublic currCodeUnitUnchecked(): number {\n\t\treturn this._text.charCodeAt(this._pos);\n\t}\n\n\t/**\n\t * Gets the next code unit in the stream.\n\t *\n\t * @returns The next code unit.\n\t * @throws XmlError if at the end of the stream.\n\t */\n\tpublic nextCodeUnit(): number {\n\t\tif (this._pos + 1 >= this._end) {\n\t\t\tthrow new XmlError({ type: 'UnexpectedEndOfStream' });\n\t\t}\n\t\treturn this._text.charCodeAt(this._pos + 1);\n\t}\n\n\t/**\n\t * Consumes a specific code unit (character) from the stream.\n\t *\n\t * @param codeUnit - The code unit to consume.\n\t * @throws XmlError if the current code unit doesn't match or if at the end.\n\t */\n\tpublic consumeCodeUnit(codeUnit: number): void {\n\t\tconst currCodeUnit = this.currCodeUnit();\n\t\tif (currCodeUnit !== codeUnit) {\n\t\t\tthrow new XmlError(\n\t\t\t\t{ type: 'InvalidChar', expected: codeUnit, actual: currCodeUnit },\n\t\t\t\tthis.genTextPos()\n\t\t\t);\n\t\t}\n\t\tthis._pos += 1;\n\t}\n\n\t/**\n\t * Tries to consume a specific code unit (character) from the stream.\n\t * Unlike `consumeCodeUnit`, it will not throw any errors.\n\t *\n\t * @param codeUnit - The code unit to consume.\n\t * @returns True if the code unit was consumed, false otherwise.\n\t */\n\tpublic tryConsumeCodeUnit(codeUnit: number): boolean {\n\t\tif (this.currCodeUnit() === codeUnit) {\n\t\t\tthis._pos += 1;\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Consumes code units that satisfy a predicate function.\n\t *\n\t * @param predicate - The function to test each code unit.\n\t * @returns The consumed string.\n\t */\n\tpublic consumeCodeUnitsWhile(\n\t\tpredicate: (codeUnit: number, stream: XmlStream) => boolean\n\t): string {\n\t\tconst start = this._pos;\n\t\tthis.skipCodeUnitsWhile(predicate);\n\t\treturn this.sliceBack(start);\n\t}\n\n\t/**\n\t * Skips code units that satisfy a predicate function.\n\t *\n\t * @param predicate - The function to test each code unit.\n\t */\n\tpublic skipCodeUnitsWhile(predicate: (codeUnit: number, stream: XmlStream) => boolean): void {\n\t\twhile (this._pos < this._end && predicate(this.currCodeUnitUnchecked(), this)) {\n\t\t\tif (!isXmlChar(this.currCodeUnitUnchecked())) {\n\t\t\t\tthrow new XmlError(\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'NonXmlChar',\n\t\t\t\t\t\tchar: String.fromCodePoint(this.currCodeUnitUnchecked())\n\t\t\t\t\t},\n\t\t\t\t\tthis.genTextPos()\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis._pos += 1;\n\t\t}\n\t}\n\n\t/**\n\t * Advances the stream position by the specified number of characters.\n\t *\n\t * @param n - The number of characters to advance.\n\t */\n\tpublic advance(n: number): void {\n\t\tthis._pos += n;\n\t}\n\n\t/**\n\t * Go to a new position in the stream.\n\t *\n\t * @param pos - The new position.\n\t */\n\tpublic goTo(pos: number): void {\n\t\tthis._pos = pos;\n\t}\n\n\t/**\n\t * Go to the end of the stream.\n\t */\n\tpublic goToEnd(): void {\n\t\tthis._pos = this._end;\n\t}\n\n\t/**\n\t * Checks if the stream starts with the given text.\n\t *\n\t * @param text - The text to check.\n\t * @returns True if the stream starts with the text, false otherwise.\n\t */\n\tpublic startsWith(text: string): boolean {\n\t\treturn this._text.startsWith(text, this._pos);\n\t}\n\n\t/**\n\t * Skips a specific string in the stream.\n\t *\n\t * @param text - The string to skip.\n\t * @throws XmlError if the stream doesn't start with the given string.\n\t */\n\tpublic skipString(text: string): void {\n\t\tif (!this.startsWith(text)) {\n\t\t\tthrow new XmlError({ type: 'InvalidString', expected: text }, this.genTextPos());\n\t\t}\n\t\tthis._pos += text.length;\n\t}\n\n\t/**\n\t * Slices the text from the given position to the current position.\n\t *\n\t * @param pos - The start position.\n\t * @returns The sliced string.\n\t */\n\tpublic sliceBack(pos: number): string {\n\t\treturn this._text.slice(pos, this._pos);\n\t}\n\n\t/**\n\t * Creates a range from the given start position to the current position.\n\t *\n\t * @param start - The start position.\n\t * @returns The range object.\n\t */\n\tpublic rangeFrom(start: number): TRange {\n\t\treturn { start, end: this._pos };\n\t}\n\n\t/**\n\t * Skips whitespace characters in the stream.\n\t */\n\tpublic skipSpaces(): void {\n\t\twhile (this.startsWithSpace()) {\n\t\t\tthis._pos += 1;\n\t\t}\n\t}\n\n\t/**\n\t * Checks if the stream starts with a whitespace character.\n\t *\n\t * @returns True if it starts with a whitespace, false otherwise.\n\t */\n\tpublic startsWithSpace(): boolean {\n\t\treturn this._pos < this._end && isXmlSpaceByte(this.currCodeUnitUnchecked());\n\t}\n\n\t/**\n\t * Consumes whitespace characters in the stream.\n\t * Like `skipSpaces`, but checks that the first char is actually a space.\n\t *\n\t * @throws XmlError if the stream doesn't start with a whitespace or is at the end.\n\t */\n\tpublic consumeSpaces(): void {\n\t\tif (this._pos >= this._end) {\n\t\t\tthrow new XmlError({ type: 'UnexpectedEndOfStream' }, this.genTextPos());\n\t\t}\n\n\t\tif (!this.startsWithSpace()) {\n\t\t\tthrow new XmlError(\n\t\t\t\t{ type: 'InvalidChar', expected: 'a whitespace', actual: this.currCodeUnitUnchecked() },\n\t\t\t\tthis.genTextPos()\n\t\t\t);\n\t\t}\n\n\t\tthis.skipSpaces();\n\t}\n\n\t/**\n\t * Tries to consume a reference (entity or character reference).\n\t * Consumes according to: https://www.w3.org/TR/xml/#NT-Reference\n\t *\n\t * @returns The consumed reference or null if not a reference.\n\t */\n\tpublic tryConsumeReference(): TReference | null {\n\t\tconst start = this._pos;\n\n\t\t// Consume reference on a substream\n\t\tconst subStream = this.clone();\n\t\tconst result = subStream.consumeReference();\n\n\t\t// If the current data is a reference than advance the current stream\n\t\t// by number of code units read by substream\n\t\tif (result != null) {\n\t\t\tthis._pos += subStream.getPos() - start;\n\t\t\treturn result;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Consumes a reference (entity or character reference).\n\t *\n\t * @returns The consumed reference or null if not a reference.\n\t */\n\tpublic consumeReference(): TReference | null {\n\t\tif (!this.tryConsumeCodeUnit(AMPERSAND)) {\n\t\t\treturn null;\n\t\t}\n\n\t\tlet reference: TReference | null;\n\n\t\tif (this.tryConsumeCodeUnit(HASH)) {\n\t\t\tlet value: string;\n\t\t\tlet radix: number;\n\n\t\t\tif (this.tryConsumeCodeUnit(LOWERCASE_X)) {\n\t\t\t\tvalue = this.consumeCodeUnitsWhile(\n\t\t\t\t\t(codeUnit) =>\n\t\t\t\t\t\t(codeUnit >= ZERO && codeUnit <= NINE) ||\n\t\t\t\t\t\t(codeUnit >= UPPERCASE_A && codeUnit <= UPPERCASE_F) ||\n\t\t\t\t\t\t(codeUnit >= LOWERCASE_A && codeUnit <= LOWERCASE_F)\n\t\t\t\t);\n\t\t\t\tradix = 16;\n\t\t\t} else {\n\t\t\t\tvalue = this.consumeCodeUnitsWhile((codeUnit) => isAsciiDigit(codeUnit));\n\t\t\t\tradix = 10;\n\t\t\t}\n\n\t\t\tconst codePoint = parseInt(value, radix);\n\t\t\tif (isNaN(codePoint) || !isXmlChar(codePoint)) {\n\t\t\t\treference = null;\n\t\t\t} else {\n\t\t\t\treference = { type: 'Char', value: String.fromCodePoint(codePoint) };\n\t\t\t}\n\t\t} else {\n\t\t\tconst name = this.consumeName();\n\t\t\tswitch (name) {\n\t\t\t\tcase 'quot':\n\t\t\t\t\treference = { type: 'Char', value: '\"' };\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'amp':\n\t\t\t\t\treference = { type: 'Char', value: '&' };\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'apos':\n\t\t\t\t\treference = { type: 'Char', value: \"'\" };\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'lt':\n\t\t\t\t\treference = { type: 'Char', value: '<' };\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'gt':\n\t\t\t\t\treference = { type: 'Char', value: '>' };\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\treference = { type: 'Entity', value: name };\n\t\t\t}\n\t\t}\n\n\t\tif (!this.tryConsumeCodeUnit(SEMICOLON)) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn reference;\n\t}\n\n\t/**\n\t * Consumes a XML name.\n\t * Consumes according to: https://www.w3.org/TR/xml/#NT-Name\n\t *\n\t * @returns The consumed name.\n\t * @throws XmlError if an invalid name is encountered.\n\t */\n\tpublic consumeName(): string {\n\t\tconst start = this._pos;\n\t\tthis.skipName();\n\n\t\tconst name = this.sliceBack(start);\n\t\tif (name.length === 0) {\n\t\t\tthrow new XmlError({ type: 'InvalidName' }, this.genTextPosFrom(start));\n\t\t}\n\n\t\treturn name;\n\t}\n\n\t/**\n\t * Skips a XML name.\n\t * The same as `consumeName`, but does not return the consumed name.\n\t * @throws XmlError if an invalid name is encountered.\n\t */\n\tpublic skipName(): void {\n\t\tconst start = this._pos;\n\n\t\twhile (this._pos < this._end) {\n\t\t\tconst currCodeUnit = this.currCodeUnitUnchecked();\n\t\t\tif (this._pos === start) {\n\t\t\t\tif (!isXmlNameStart(currCodeUnit)) {\n\t\t\t\t\tthrow new XmlError({ type: 'InvalidName' }, this.genTextPosFrom(start));\n\t\t\t\t}\n\t\t\t} else if (!isXmlName(currCodeUnit)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tthis._pos += 1;\n\t\t}\n\t}\n\n\t/**\n\t * Consumes a qualified XML name and returns it.\n\t * Consumes according to: https://www.w3.org/TR/xml-names/#ns-qualnames\n\t *\n\t * @returns The prefix and local name as a tuple.\n\t * @throws XmlError if an invalid qualified XML name is encountered.\n\t */\n\tpublic consumeQName(): [string, string] {\n\t\tconst start = this._pos;\n\t\tlet splitter: number | null = null;\n\n\t\twhile (this._pos < this._end) {\n\t\t\tconst currCodeUnit = this.currCodeUnitUnchecked();\n\t\t\tif (currCodeUnit === COLON) {\n\t\t\t\tif (splitter == null) {\n\t\t\t\t\tsplitter = this._pos;\n\t\t\t\t\tthis._pos += 1;\n\t\t\t\t} else {\n\t\t\t\t\t// Multiple `:` is an error\n\t\t\t\t\tthrow new XmlError({ type: 'InvalidName' }, this.genTextPosFrom(start));\n\t\t\t\t}\n\t\t\t} else if (isXmlName(currCodeUnit)) {\n\t\t\t\tthis._pos += 1;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tlet prefix;\n\t\tlet local;\n\t\tif (splitter != null) {\n\t\t\tprefix = this._text.slice(start, splitter);\n\t\t\tlocal = this.sliceBack(splitter + 1);\n\t\t} else {\n\t\t\t// Empty prefix. This way we can preserve attribute start position.\n\t\t\tprefix = '';\n\t\t\tlocal = this.sliceBack(start);\n\t\t}\n\n\t\t// Prefix must start with a `NameStartChar`\n\t\tif (prefix.length > 0 && !isXmlNameStart(prefix[0]?.codePointAt(0))) {\n\t\t\tthrow new XmlError({ type: 'InvalidName' }, this.genTextPosFrom(start));\n\t\t}\n\n\t\t// Local name must start with a `NameStartChar`\n\t\tif (local.length > 0) {\n\t\t\tif (!isXmlNameStart(local[0]?.codePointAt(0))) {\n\t\t\t\tthrow new XmlError({ type: 'InvalidName' }, this.genTextPosFrom(start));\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new XmlError({ type: 'InvalidName' }, this.genTextPosFrom(start));\n\t\t}\n\n\t\treturn [prefix, local];\n\t}\n\n\t/**\n\t * Consumes a quote character.\n\t *\n\t * @returns The consumed quote character.\n\t * @throws XmlError if an invalid quote character is encountered.\n\t */\n\tpublic consumeQuote(): number {\n\t\tconst currCodeUnit = this.currCodeUnit();\n\t\tif (currCodeUnit === SINGLE_QUOTE || currCodeUnit === DOUBLE_QUOTE) {\n\t\t\tthis._pos += 1;\n\t\t\treturn currCodeUnit;\n\t\t}\n\t\tthrow new XmlError(\n\t\t\t{ type: 'InvalidChar', expected: 'a quote', actual: currCodeUnit },\n\t\t\tthis.genTextPos()\n\t\t);\n\t}\n\n\t/**\n\t * Returns a slice of text centered around the specified position.\n\t *\n\t * @param pos - The center position for the slice.\n\t * @param size - The total size of the slice (will extend size/2 in each direction).\n\t * @returns A string containing the text around the position.\n\t */\n\tpublic getTextAround(pos: number, size: number): string {\n\t\tconst halfSize = Math.floor(size / 2);\n\n\t\t// Calculate start and end positions with bounds checking\n\t\tconst start = Math.max(0, pos - halfSize);\n\t\tconst end = Math.min(this._end, pos + halfSize + (size % 2));\n\n\t\treturn this._text.slice(start, end);\n\t}\n\n\t/**\n\t * Calculates the current absolute position.\n\t * This operation is very expensive. Use only for errors.\n\t *\n\t * @returns The current text position.\n\t */\n\tpublic genTextPos(): TTextPos {\n\t\treturn this.genTextPosFrom(this._pos);\n\t}\n\n\t/**\n\t * Calculates an absolute position at the specified position.\n\t * This operation is very expensive. Use only for errors.\n\t *\n\t * @param pos - The position to calculate from.\n\t * @returns The calculated text position.\n\t */\n\tpublic genTextPosFrom(pos: number): TTextPos {\n\t\tconst clampedPos = Math.min(pos, this._end);\n\t\tlet row = 1;\n\t\tlet col = 1;\n\t\tfor (let i = 0; i < clampedPos; i++) {\n\t\t\tif (this._text.charCodeAt(i) === LINE_FEED) {\n\t\t\t\trow++;\n\t\t\t\tcol = 1;\n\t\t\t} else {\n\t\t\t\tcol++;\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\trow,\n\t\t\tcol,\n\t\t\t...(this.config.contextSliceSize\n\t\t\t\t? { contextSlice: this.getTextAround(pos, this.config.contextSliceSize) }\n\t\t\t\t: {})\n\t\t};\n\t}\n}\n\nexport interface TXmlStreamConfig {\n\t/**\n\t * Whether to enforce strict XML document structure rules.\n\t * When true:\n\t * - Document must have exactly one root element\n\t * - No text nodes at document level (outside root element)\n\t * - Only comments and processing instructions allowed outside root element\n\t * - Attribute requires an explicit value and the value must be quoted\n\t * When false:\n\t * - Multiple root elements allowed\n\t * - Text nodes allowed at document level\n\t * - More HTML-like permissive parsing (unquoted attributes, boolean attributes)\n\t * @default true\n\t */\n\tstrictDocument: boolean;\n\n\t/**\n\t * List of element names that should be treated as raw text elements.\n\t * Their content will be parsed as text rather than XML.\n\t * Common examples are 'script' and 'style' for HTML-like documents.\n\t * @default null\n\t */\n\trawTextElements: string[] | null;\n\n\t/**\n\t * List of element names that should be treated as self-closing without requiring '/>' syntax.\n\t * Common examples are 'meta' and 'link' for HTML-like documents.\n\t * @default null\n\t */\n\timplicitSelfClosingElements: string[] | null;\n\n\t/**\n\t * Whether to allow DOCTYPE declarations.\n\t * @default true\n\t */\n\tallowDtd: boolean;\n\n\t/**\n\t * Controls the inclusion and size of context slices in error positions.\n\t * When set to a number, error positions will include a text slice of that size\n\t * centered around the error location for better debugging context.\n\t * When set to false, no context slices will be included in error positions.\n\t * @default 30\n\t */\n\tcontextSliceSize: number | false;\n}\n\nexport type TXmlStreamOptions = { pos?: number } & Partial<TXmlStreamConfig>;\n"],"names":[],"mappings":";;;;AACA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc;AACrC,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB;AACtD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc;AAClD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB;AACxD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAA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cAAc,CAAC,GAAG,EAAE;AACtB,IAAI,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC;AAC/C,IAAI,IAAI,GAAG,GAAG,CAAC;AACf,IAAI,IAAI,GAAG,GAAG,CAAC;AACf,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,EAAE;AACzC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE;AAClD,QAAQ,GAAG,EAAE;AACb,QAAQ,GAAG,GAAG,CAAC;AACf,OAAO,MAAM;AACb,QAAQ,GAAG,EAAE;AACb;AACA;AACA,IAAI,OAAO,cAAc,CAAC;AAC1B,MAAM,GAAG;AACT,MAAM;AACN,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,GAAG,EAAE,YAAY,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,GAAG,EAAE,CAAC;AACnH;AACA;;;;"}
|
|
@@ -1 +1,36 @@
|
|
|
1
|
-
const
|
|
1
|
+
const HORIZONTAL_TAB = 9;
|
|
2
|
+
const LINE_FEED = 10;
|
|
3
|
+
const CARRIAGE_RETURN = 13;
|
|
4
|
+
const SPACE = 32;
|
|
5
|
+
const EXCLAMATION_MARK = 33;
|
|
6
|
+
const DOUBLE_QUOTE = 34;
|
|
7
|
+
const HASH = 35;
|
|
8
|
+
const PERCENT = 37;
|
|
9
|
+
const AMPERSAND = 38;
|
|
10
|
+
const SINGLE_QUOTE = 39;
|
|
11
|
+
const HYPHEN = 45;
|
|
12
|
+
const PERIOD = 46;
|
|
13
|
+
const SLASH = 47;
|
|
14
|
+
const ZERO = 48;
|
|
15
|
+
const NINE = 57;
|
|
16
|
+
const COLON = 58;
|
|
17
|
+
const SEMICOLON = 59;
|
|
18
|
+
const LESS_THAN = 60;
|
|
19
|
+
const EQUALS = 61;
|
|
20
|
+
const GREATER_THAN = 62;
|
|
21
|
+
const QUESTION_MARK = 63;
|
|
22
|
+
const UPPERCASE_A = 65;
|
|
23
|
+
const UPPERCASE_F = 70;
|
|
24
|
+
const UPPERCASE_P = 80;
|
|
25
|
+
const UPPERCASE_S = 83;
|
|
26
|
+
const UPPERCASE_Z = 90;
|
|
27
|
+
const OPEN_SQUARE_BRACKET = 91;
|
|
28
|
+
const CLOSE_SQUARE_BRACKET = 93;
|
|
29
|
+
const UNDERSCORE = 95;
|
|
30
|
+
const LOWERCASE_A = 97;
|
|
31
|
+
const LOWERCASE_F = 102;
|
|
32
|
+
const LOWERCASE_X = 120;
|
|
33
|
+
const LOWERCASE_Z = 122;
|
|
34
|
+
|
|
35
|
+
export { AMPERSAND, CARRIAGE_RETURN, CLOSE_SQUARE_BRACKET, COLON, DOUBLE_QUOTE, EQUALS, EXCLAMATION_MARK, GREATER_THAN, HASH, HORIZONTAL_TAB, HYPHEN, LESS_THAN, LINE_FEED, LOWERCASE_A, LOWERCASE_F, LOWERCASE_X, LOWERCASE_Z, NINE, OPEN_SQUARE_BRACKET, PERCENT, PERIOD, QUESTION_MARK, SEMICOLON, SINGLE_QUOTE, SLASH, SPACE, UNDERSCORE, UPPERCASE_A, UPPERCASE_F, UPPERCASE_P, UPPERCASE_S, UPPERCASE_Z, ZERO };
|
|
36
|
+
//# sourceMappingURL=ascii-constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ascii-constants.js","sources":["../../../src/tokenizer/ascii-constants.ts"],"sourcesContent":["export const HORIZONTAL_TAB = 9; // \\t\nexport const LINE_FEED = 10; // \\n\nexport const CARRIAGE_RETURN = 13; // \\r\nexport const SPACE = 32; // ' '\nexport const EXCLAMATION_MARK = 33; // !\nexport const DOUBLE_QUOTE = 34; // \"\nexport const HASH = 35; // #\nexport const PERCENT = 37; // %\nexport const AMPERSAND = 38; // &\nexport const SINGLE_QUOTE = 39; // '\nexport const HYPHEN = 45; // -\nexport const PERIOD = 46; // .\nexport const SLASH = 47; // /\nexport const ZERO = 48; // 0\nexport const NINE = 57; // 9\nexport const COLON = 58; // :\nexport const SEMICOLON = 59; // ;\nexport const LESS_THAN = 60; // <\nexport const EQUALS = 61; // =\nexport const GREATER_THAN = 62; // >\nexport const QUESTION_MARK = 63; // ?\nexport const UPPERCASE_A = 65; // A\nexport const UPPERCASE_F = 70; // F\nexport const UPPERCASE_P = 80; // P\nexport const UPPERCASE_S = 83; // S\nexport const UPPERCASE_Z = 90; // Z\nexport const OPEN_SQUARE_BRACKET = 91; // [\nexport const CLOSE_SQUARE_BRACKET = 93; // ]\nexport const UNDERSCORE = 95; // _\nexport const LOWERCASE_A = 97; // a\nexport const LOWERCASE_F = 102; // f\nexport const LOWERCASE_X = 120; // x\nexport const LOWERCASE_Z = 122; // z\n// export const OPEN_CURLY_BRACKET = 123; // {\n// export const CLOSE_CURLY_BRACKET = 125; // }\n"],"names":[],"mappings":"AACY,MAAC,cAAc,GAAG;AAClB,MAAC,SAAS,GAAG;AACb,MAAC,eAAe,GAAG;AACnB,MAAC,KAAK,GAAG;AACT,MAAC,gBAAgB,GAAG;AACpB,MAAC,YAAY,GAAG;AAChB,MAAC,IAAI,GAAG;AACR,MAAC,OAAO,GAAG;AACX,MAAC,SAAS,GAAG;AACb,MAAC,YAAY,GAAG;AAChB,MAAC,MAAM,GAAG;AACV,MAAC,MAAM,GAAG;AACV,MAAC,KAAK,GAAG;AACT,MAAC,IAAI,GAAG;AACR,MAAC,IAAI,GAAG;AACR,MAAC,KAAK,GAAG;AACT,MAAC,SAAS,GAAG;AACb,MAAC,SAAS,GAAG;AACb,MAAC,MAAM,GAAG;AACV,MAAC,YAAY,GAAG;AAChB,MAAC,aAAa,GAAG;AACjB,MAAC,WAAW,GAAG;AACf,MAAC,WAAW,GAAG;AACf,MAAC,WAAW,GAAG;AACf,MAAC,WAAW,GAAG;AACf,MAAC,WAAW,GAAG;AACf,MAAC,mBAAmB,GAAG;AACvB,MAAC,oBAAoB,GAAG;AACxB,MAAC,UAAU,GAAG;AACd,MAAC,WAAW,GAAG;AACf,MAAC,WAAW,GAAG;AACf,MAAC,WAAW,GAAG;AACf,MAAC,WAAW,GAAG;;;;"}
|