@loaders.gl/xml 4.0.0-beta.2 → 4.0.0-beta.4

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 (51) hide show
  1. package/dist/{dist.min.js → dist.dev.js} +2077 -2057
  2. package/dist/{esm/html-loader.js → html-loader.js} +1 -1
  3. package/dist/html-loader.js.map +1 -0
  4. package/dist/index.cjs +1530 -0
  5. package/dist/index.js +6 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/{esm/lib → lib}/parsers/parse-xml.js +2 -2
  8. package/dist/lib/parsers/parse-xml.js.map +1 -0
  9. package/dist/{esm/lib → lib}/parsers/streaming-xml-parser.js +6 -7
  10. package/dist/lib/parsers/streaming-xml-parser.js.map +1 -0
  11. package/dist/lib/xml-utils/uncapitalize.js.map +1 -0
  12. package/dist/lib/xml-utils/xml-utils.js.map +1 -0
  13. package/dist/{esm/sax-ts → sax-ts}/sax.js +75 -76
  14. package/dist/sax-ts/sax.js.map +1 -0
  15. package/dist/{esm/xml-loader.js → xml-loader.js} +2 -2
  16. package/dist/xml-loader.js.map +1 -0
  17. package/package.json +16 -8
  18. package/dist/bundle.d.ts +0 -2
  19. package/dist/bundle.d.ts.map +0 -1
  20. package/dist/es5/bundle.js +0 -6
  21. package/dist/es5/bundle.js.map +0 -1
  22. package/dist/es5/html-loader.js +0 -58
  23. package/dist/es5/html-loader.js.map +0 -1
  24. package/dist/es5/index.js +0 -53
  25. package/dist/es5/index.js.map +0 -1
  26. package/dist/es5/lib/parsers/parse-xml.js +0 -53
  27. package/dist/es5/lib/parsers/parse-xml.js.map +0 -1
  28. package/dist/es5/lib/parsers/streaming-xml-parser.js +0 -134
  29. package/dist/es5/lib/parsers/streaming-xml-parser.js.map +0 -1
  30. package/dist/es5/lib/xml-utils/uncapitalize.js +0 -32
  31. package/dist/es5/lib/xml-utils/uncapitalize.js.map +0 -1
  32. package/dist/es5/lib/xml-utils/xml-utils.js +0 -23
  33. package/dist/es5/lib/xml-utils/xml-utils.js.map +0 -1
  34. package/dist/es5/sax-ts/sax.js +0 -1372
  35. package/dist/es5/sax-ts/sax.js.map +0 -1
  36. package/dist/es5/xml-loader.js +0 -58
  37. package/dist/es5/xml-loader.js.map +0 -1
  38. package/dist/esm/bundle.js +0 -4
  39. package/dist/esm/bundle.js.map +0 -1
  40. package/dist/esm/html-loader.js.map +0 -1
  41. package/dist/esm/index.js +0 -6
  42. package/dist/esm/index.js.map +0 -1
  43. package/dist/esm/lib/parsers/parse-xml.js.map +0 -1
  44. package/dist/esm/lib/parsers/streaming-xml-parser.js.map +0 -1
  45. package/dist/esm/lib/xml-utils/uncapitalize.js.map +0 -1
  46. package/dist/esm/lib/xml-utils/xml-utils.js.map +0 -1
  47. package/dist/esm/sax-ts/sax.js.map +0 -1
  48. package/dist/esm/xml-loader.js.map +0 -1
  49. package/src/bundle.ts +0 -4
  50. /package/dist/{esm/lib → lib}/xml-utils/uncapitalize.js +0 -0
  51. /package/dist/{esm/lib → lib}/xml-utils/xml-utils.js +0 -0
@@ -1,1934 +1,612 @@
1
- (() => {
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if (typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory();
4
+ else if (typeof define === 'function' && define.amd) define([], factory);
5
+ else if (typeof exports === 'object') exports['loader'] = factory();
6
+ else root['loader'] = factory();})(globalThis, function () {
7
+ "use strict";
8
+ var __exports__ = (() => {
2
9
  var __create = Object.create;
3
10
  var __defProp = Object.defineProperty;
4
11
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
12
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
13
  var __getProtoOf = Object.getPrototypeOf;
7
14
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
9
- var __esm = (fn, res) => function __init() {
10
- return fn && (res = (0, fn[Object.keys(fn)[0]])(fn = 0)), res;
11
- };
15
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
16
  var __commonJS = (cb, mod) => function __require() {
13
- return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
14
18
  };
15
19
  var __export = (target, all) => {
16
- __markAsModule(target);
17
20
  for (var name in all)
18
21
  __defProp(target, name, { get: all[name], enumerable: true });
19
22
  };
20
- var __reExport = (target, module, desc) => {
21
- if (module && typeof module === "object" || typeof module === "function") {
22
- for (let key of __getOwnPropNames(module))
23
- if (!__hasOwnProp.call(target, key) && key !== "default")
24
- __defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
23
+ var __copyProps = (to, from, except, desc) => {
24
+ if (from && typeof from === "object" || typeof from === "function") {
25
+ for (let key of __getOwnPropNames(from))
26
+ if (!__hasOwnProp.call(to, key) && key !== except)
27
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
28
  }
26
- return target;
29
+ return to;
27
30
  };
28
- var __toModule = (module) => {
29
- return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
31
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
32
+ // If the importer is in node compatibility mode or this is not an ESM
33
+ // file that has been converted to a CommonJS file using a Babel-
34
+ // compatible transform (i.e. "__esModule" has not been set), then set
35
+ // "default" to the CommonJS "module.exports" for node compatibility.
36
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
37
+ mod
38
+ ));
39
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
40
+ var __publicField = (obj, key, value) => {
41
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
42
+ return value;
30
43
  };
31
44
 
32
- // src/sax-ts/sax.ts
33
- var DEFAULT_SAX_EVENTS, DEFAULT_SAX_PARSER_OPTIONS, EVENTS, BUFFERS, nameStart, nameBody, entityStart, entityBody, ENTITIES, SAX, SAXParser;
34
- var init_sax = __esm({
35
- "src/sax-ts/sax.ts"() {
36
- DEFAULT_SAX_EVENTS = {
37
- ontext: () => {
38
- },
39
- onprocessinginstruction: () => {
40
- },
41
- onsgmldeclaration: () => {
42
- },
43
- ondoctype: () => {
44
- },
45
- oncomment: () => {
46
- },
47
- onopentagstart: () => {
48
- },
49
- onattribute: () => {
50
- },
51
- onopentag: () => {
52
- },
53
- onclosetag: () => {
54
- },
55
- onopencdata: () => {
56
- },
57
- oncdata: () => {
58
- },
59
- onclosecdata: () => {
60
- },
61
- onerror: () => {
62
- },
63
- onend: () => {
64
- },
65
- onready: () => {
66
- },
67
- onscript: () => {
68
- },
69
- onopennamespace: () => {
70
- },
71
- onclosenamespace: () => {
45
+ // ../../node_modules/fast-xml-parser/src/util.js
46
+ var require_util = __commonJS({
47
+ "../../node_modules/fast-xml-parser/src/util.js"(exports) {
48
+ "use strict";
49
+ var nameStartChar = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
50
+ var nameChar = nameStartChar + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
51
+ var nameRegexp = "[" + nameStartChar + "][" + nameChar + "]*";
52
+ var regexName = new RegExp("^" + nameRegexp + "$");
53
+ var getAllMatches = function(string, regex) {
54
+ const matches = [];
55
+ let match = regex.exec(string);
56
+ while (match) {
57
+ const allmatches = [];
58
+ allmatches.startIndex = regex.lastIndex - match[0].length;
59
+ const len = match.length;
60
+ for (let index = 0; index < len; index++) {
61
+ allmatches.push(match[index]);
62
+ }
63
+ matches.push(allmatches);
64
+ match = regex.exec(string);
72
65
  }
66
+ return matches;
73
67
  };
74
- DEFAULT_SAX_PARSER_OPTIONS = {
75
- ...DEFAULT_SAX_EVENTS,
76
- strict: false,
77
- MAX_BUFFER_LENGTH: 64 * 1024,
78
- lowercase: false,
79
- lowercasetags: false,
80
- noscript: false,
81
- strictEntities: false,
82
- xmlns: void 0,
83
- position: void 0,
84
- trim: void 0,
85
- normalize: void 0
68
+ var isName = function(string) {
69
+ const match = regexName.exec(string);
70
+ return !(match === null || typeof match === "undefined");
86
71
  };
87
- EVENTS = [
88
- "text",
89
- "processinginstruction",
90
- "sgmldeclaration",
91
- "doctype",
92
- "comment",
93
- "opentagstart",
94
- "attribute",
95
- "opentag",
96
- "closetag",
97
- "opencdata",
98
- "cdata",
99
- "closecdata",
100
- "error",
101
- "end",
102
- "ready",
103
- "script",
104
- "opennamespace",
105
- "closenamespace"
106
- ];
107
- BUFFERS = [
108
- "comment",
109
- "sgmlDecl",
110
- "textNode",
111
- "tagName",
112
- "doctype",
113
- "procInstName",
114
- "procInstBody",
115
- "entity",
116
- "attribName",
117
- "attribValue",
118
- "cdata",
119
- "script"
120
- ];
121
- nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
122
- nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
123
- entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
124
- entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
125
- ENTITIES = {
126
- amp: "&",
127
- gt: ">",
128
- lt: "<",
129
- quot: '"',
130
- apos: "'",
131
- AElig: 198,
132
- Aacute: 193,
133
- Acirc: 194,
134
- Agrave: 192,
135
- Aring: 197,
136
- Atilde: 195,
137
- Auml: 196,
138
- Ccedil: 199,
139
- ETH: 208,
140
- Eacute: 201,
141
- Ecirc: 202,
142
- Egrave: 200,
143
- Euml: 203,
144
- Iacute: 205,
145
- Icirc: 206,
146
- Igrave: 204,
147
- Iuml: 207,
148
- Ntilde: 209,
149
- Oacute: 211,
150
- Ocirc: 212,
151
- Ograve: 210,
152
- Oslash: 216,
153
- Otilde: 213,
154
- Ouml: 214,
155
- THORN: 222,
156
- Uacute: 218,
157
- Ucirc: 219,
158
- Ugrave: 217,
159
- Uuml: 220,
160
- Yacute: 221,
161
- aacute: 225,
162
- acirc: 226,
163
- aelig: 230,
164
- agrave: 224,
165
- aring: 229,
166
- atilde: 227,
167
- auml: 228,
168
- ccedil: 231,
169
- eacute: 233,
170
- ecirc: 234,
171
- egrave: 232,
172
- eth: 240,
173
- euml: 235,
174
- iacute: 237,
175
- icirc: 238,
176
- igrave: 236,
177
- iuml: 239,
178
- ntilde: 241,
179
- oacute: 243,
180
- ocirc: 244,
181
- ograve: 242,
182
- oslash: 248,
183
- otilde: 245,
184
- ouml: 246,
185
- szlig: 223,
186
- thorn: 254,
187
- uacute: 250,
188
- ucirc: 251,
189
- ugrave: 249,
190
- uuml: 252,
191
- yacute: 253,
192
- yuml: 255,
193
- copy: 169,
194
- reg: 174,
195
- nbsp: 160,
196
- iexcl: 161,
197
- cent: 162,
198
- pound: 163,
199
- curren: 164,
200
- yen: 165,
201
- brvbar: 166,
202
- sect: 167,
203
- uml: 168,
204
- ordf: 170,
205
- laquo: 171,
206
- not: 172,
207
- shy: 173,
208
- macr: 175,
209
- deg: 176,
210
- plusmn: 177,
211
- sup1: 185,
212
- sup2: 178,
213
- sup3: 179,
214
- acute: 180,
215
- micro: 181,
216
- para: 182,
217
- middot: 183,
218
- cedil: 184,
219
- ordm: 186,
220
- raquo: 187,
221
- frac14: 188,
222
- frac12: 189,
223
- frac34: 190,
224
- iquest: 191,
225
- times: 215,
226
- divide: 247,
227
- OElig: 338,
228
- oelig: 339,
229
- Scaron: 352,
230
- scaron: 353,
231
- Yuml: 376,
232
- fnof: 402,
233
- circ: 710,
234
- tilde: 732,
235
- Alpha: 913,
236
- Beta: 914,
237
- Gamma: 915,
238
- Delta: 916,
239
- Epsilon: 917,
240
- Zeta: 918,
241
- Eta: 919,
242
- Theta: 920,
243
- Iota: 921,
244
- Kappa: 922,
245
- Lambda: 923,
246
- Mu: 924,
247
- Nu: 925,
248
- Xi: 926,
249
- Omicron: 927,
250
- Pi: 928,
251
- Rho: 929,
252
- Sigma: 931,
253
- Tau: 932,
254
- Upsilon: 933,
255
- Phi: 934,
256
- Chi: 935,
257
- Psi: 936,
258
- Omega: 937,
259
- alpha: 945,
260
- beta: 946,
261
- gamma: 947,
262
- delta: 948,
263
- epsilon: 949,
264
- zeta: 950,
265
- eta: 951,
266
- theta: 952,
267
- iota: 953,
268
- kappa: 954,
269
- lambda: 955,
270
- mu: 956,
271
- nu: 957,
272
- xi: 958,
273
- omicron: 959,
274
- pi: 960,
275
- rho: 961,
276
- sigmaf: 962,
277
- sigma: 963,
278
- tau: 964,
279
- upsilon: 965,
280
- phi: 966,
281
- chi: 967,
282
- psi: 968,
283
- omega: 969,
284
- thetasym: 977,
285
- upsih: 978,
286
- piv: 982,
287
- ensp: 8194,
288
- emsp: 8195,
289
- thinsp: 8201,
290
- zwnj: 8204,
291
- zwj: 8205,
292
- lrm: 8206,
293
- rlm: 8207,
294
- ndash: 8211,
295
- mdash: 8212,
296
- lsquo: 8216,
297
- rsquo: 8217,
298
- sbquo: 8218,
299
- ldquo: 8220,
300
- rdquo: 8221,
301
- bdquo: 8222,
302
- dagger: 8224,
303
- Dagger: 8225,
304
- bull: 8226,
305
- hellip: 8230,
306
- permil: 8240,
307
- prime: 8242,
308
- Prime: 8243,
309
- lsaquo: 8249,
310
- rsaquo: 8250,
311
- oline: 8254,
312
- frasl: 8260,
313
- euro: 8364,
314
- image: 8465,
315
- weierp: 8472,
316
- real: 8476,
317
- trade: 8482,
318
- alefsym: 8501,
319
- larr: 8592,
320
- uarr: 8593,
321
- rarr: 8594,
322
- darr: 8595,
323
- harr: 8596,
324
- crarr: 8629,
325
- lArr: 8656,
326
- uArr: 8657,
327
- rArr: 8658,
328
- dArr: 8659,
329
- hArr: 8660,
330
- forall: 8704,
331
- part: 8706,
332
- exist: 8707,
333
- empty: 8709,
334
- nabla: 8711,
335
- isin: 8712,
336
- notin: 8713,
337
- ni: 8715,
338
- prod: 8719,
339
- sum: 8721,
340
- minus: 8722,
341
- lowast: 8727,
342
- radic: 8730,
343
- prop: 8733,
344
- infin: 8734,
345
- ang: 8736,
346
- and: 8743,
347
- or: 8744,
348
- cap: 8745,
349
- cup: 8746,
350
- int: 8747,
351
- there4: 8756,
352
- sim: 8764,
353
- cong: 8773,
354
- asymp: 8776,
355
- ne: 8800,
356
- equiv: 8801,
357
- le: 8804,
358
- ge: 8805,
359
- sub: 8834,
360
- sup: 8835,
361
- nsub: 8836,
362
- sube: 8838,
363
- supe: 8839,
364
- oplus: 8853,
365
- otimes: 8855,
366
- perp: 8869,
367
- sdot: 8901,
368
- lceil: 8968,
369
- rceil: 8969,
370
- lfloor: 8970,
371
- rfloor: 8971,
372
- lang: 9001,
373
- rang: 9002,
374
- loz: 9674,
375
- spades: 9824,
376
- clubs: 9827,
377
- hearts: 9829,
378
- diams: 9830
72
+ exports.isExist = function(v) {
73
+ return typeof v !== "undefined";
379
74
  };
380
- Object.keys(ENTITIES).forEach((key) => {
381
- const e = ENTITIES[key];
382
- ENTITIES[key] = typeof e === "number" ? String.fromCharCode(e) : e;
383
- });
384
- SAX = class {
385
- constructor() {
386
- this.EVENTS = EVENTS;
387
- this.ENTITIES = {
388
- ...ENTITIES
389
- };
390
- this.XML_ENTITIES = {
391
- amp: "&",
392
- gt: ">",
393
- lt: "<",
394
- quot: '"',
395
- apos: "'"
396
- };
397
- this.S = 0;
398
- this.trackPosition = false;
399
- this.column = 0;
400
- this.line = 0;
401
- this.c = "";
402
- this.q = "";
403
- this.closed = false;
404
- this.tags = [];
405
- this.looseCase = "";
406
- this.closedRoot = false;
407
- this.sawRoot = false;
408
- this.strict = false;
409
- this.noscript = false;
410
- this.attribList = [];
411
- this.position = 0;
412
- this.STATE = {
413
- BEGIN: this.S++,
414
- BEGIN_WHITESPACE: this.S++,
415
- TEXT: this.S++,
416
- TEXT_ENTITY: this.S++,
417
- OPEN_WAKA: this.S++,
418
- SGML_DECL: this.S++,
419
- SGML_DECL_QUOTED: this.S++,
420
- DOCTYPE: this.S++,
421
- DOCTYPE_QUOTED: this.S++,
422
- DOCTYPE_DTD: this.S++,
423
- DOCTYPE_DTD_QUOTED: this.S++,
424
- COMMENT_STARTING: this.S++,
425
- COMMENT: this.S++,
426
- COMMENT_ENDING: this.S++,
427
- COMMENT_ENDED: this.S++,
428
- CDATA: this.S++,
429
- CDATA_ENDING: this.S++,
430
- CDATA_ENDING_2: this.S++,
431
- PROC_INST: this.S++,
432
- PROC_INST_BODY: this.S++,
433
- PROC_INST_ENDING: this.S++,
434
- OPEN_TAG: this.S++,
435
- OPEN_TAG_SLASH: this.S++,
436
- ATTRIB: this.S++,
437
- ATTRIB_NAME: this.S++,
438
- ATTRIB_NAME_SAW_WHITE: this.S++,
439
- ATTRIB_VALUE: this.S++,
440
- ATTRIB_VALUE_QUOTED: this.S++,
441
- ATTRIB_VALUE_CLOSED: this.S++,
442
- ATTRIB_VALUE_UNQUOTED: this.S++,
443
- ATTRIB_VALUE_ENTITY_Q: this.S++,
444
- ATTRIB_VALUE_ENTITY_U: this.S++,
445
- CLOSE_TAG: this.S++,
446
- CLOSE_TAG_SAW_WHITE: this.S++,
447
- SCRIPT: this.S++,
448
- SCRIPT_ENDING: this.S++
449
- };
450
- this.BUFFERS = BUFFERS;
451
- this.CDATA = "[CDATA[";
452
- this.DOCTYPE = "DOCTYPE";
453
- this.XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
454
- this.XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/";
455
- this.rootNS = {
456
- xml: this.XML_NAMESPACE,
457
- xmlns: this.XMLNS_NAMESPACE
458
- };
459
- this.textNode = "";
460
- this.entity = "";
461
- this.cdata = "";
462
- this.script = "";
463
- this.startTagPosition = 0;
464
- this.S = 0;
465
- for (const s in this.STATE) {
466
- if (this.STATE.hasOwnProperty(s)) {
467
- this.STATE[this.STATE[s]] = s;
75
+ exports.isEmptyObject = function(obj) {
76
+ return Object.keys(obj).length === 0;
77
+ };
78
+ exports.merge = function(target, a, arrayMode) {
79
+ if (a) {
80
+ const keys = Object.keys(a);
81
+ const len = keys.length;
82
+ for (let i = 0; i < len; i++) {
83
+ if (arrayMode === "strict") {
84
+ target[keys[i]] = [a[keys[i]]];
85
+ } else {
86
+ target[keys[i]] = a[keys[i]];
468
87
  }
469
88
  }
470
- this.S = this.STATE;
471
- }
472
- static charAt(chunk, i) {
473
- let result = "";
474
- if (i < chunk.length) {
475
- result = chunk.charAt(i);
476
- }
477
- return result;
478
89
  }
479
- static isWhitespace(c) {
480
- return c === " " || c === "\n" || c === "\r" || c === " ";
481
- }
482
- static isQuote(c) {
483
- return c === '"' || c === "'";
484
- }
485
- static isAttribEnd(c) {
486
- return c === ">" || SAX.isWhitespace(c);
487
- }
488
- static isMatch(regex, c) {
489
- return regex.test(c);
490
- }
491
- static notMatch(regex, c) {
492
- return !SAX.isMatch(regex, c);
90
+ };
91
+ exports.getValue = function(v) {
92
+ if (exports.isExist(v)) {
93
+ return v;
94
+ } else {
95
+ return "";
493
96
  }
494
- static qname(name, attribute) {
495
- const i = name.indexOf(":");
496
- const qualName = i < 0 ? ["", name] : name.split(":");
497
- let prefix = qualName[0];
498
- let local = qualName[1];
499
- if (attribute && name === "xmlns") {
500
- prefix = "xmlns";
501
- local = "";
502
- }
503
- return { prefix, local };
97
+ };
98
+ exports.isName = isName;
99
+ exports.getAllMatches = getAllMatches;
100
+ exports.nameRegexp = nameRegexp;
101
+ }
102
+ });
103
+
104
+ // ../../node_modules/fast-xml-parser/src/validator.js
105
+ var require_validator = __commonJS({
106
+ "../../node_modules/fast-xml-parser/src/validator.js"(exports) {
107
+ "use strict";
108
+ var util = require_util();
109
+ var defaultOptions = {
110
+ allowBooleanAttributes: false,
111
+ unpairedTags: []
112
+ };
113
+ exports.validate = function(xmlData, options) {
114
+ options = Object.assign({}, defaultOptions, options);
115
+ const tags = [];
116
+ let tagFound = false;
117
+ let reachedRoot = false;
118
+ if (xmlData[0] === "\uFEFF") {
119
+ xmlData = xmlData.substr(1);
504
120
  }
505
- write(chunk) {
506
- if (this.error) {
507
- throw this.error;
508
- }
509
- if (this.closed) {
510
- return this.errorFunction("Cannot write after close. Assign an onready handler.");
511
- }
512
- if (chunk === null) {
513
- return this.end();
514
- }
515
- if (typeof chunk === "object") {
516
- chunk = chunk.toString();
517
- }
518
- let i = 0;
519
- let c;
520
- while (true) {
521
- c = SAX.charAt(chunk, i++);
522
- this.c = c;
523
- if (!c) {
524
- break;
525
- }
526
- if (this.trackPosition) {
527
- this.position++;
528
- if (c === "\n") {
529
- this.line++;
530
- this.column = 0;
531
- } else {
532
- this.column++;
121
+ for (let i = 0; i < xmlData.length; i++) {
122
+ if (xmlData[i] === "<" && xmlData[i + 1] === "?") {
123
+ i += 2;
124
+ i = readPI(xmlData, i);
125
+ if (i.err)
126
+ return i;
127
+ } else if (xmlData[i] === "<") {
128
+ let tagStartPos = i;
129
+ i++;
130
+ if (xmlData[i] === "!") {
131
+ i = readCommentAndCDATA(xmlData, i);
132
+ continue;
133
+ } else {
134
+ let closingTag = false;
135
+ if (xmlData[i] === "/") {
136
+ closingTag = true;
137
+ i++;
533
138
  }
534
- }
535
- switch (this.state) {
536
- case this.S.BEGIN:
537
- this.state = this.S.BEGIN_WHITESPACE;
538
- if (c === "\uFEFF") {
539
- continue;
540
- }
541
- this.beginWhiteSpace(c);
542
- continue;
543
- case this.S.BEGIN_WHITESPACE:
544
- this.beginWhiteSpace(c);
545
- continue;
546
- case this.S.TEXT:
547
- if (this.sawRoot && !this.closedRoot) {
548
- const starti = i - 1;
549
- while (c && c !== "<" && c !== "&") {
550
- c = SAX.charAt(chunk, i++);
551
- if (c && this.trackPosition) {
552
- this.position++;
553
- if (c === "\n") {
554
- this.line++;
555
- this.column = 0;
556
- } else {
557
- this.column++;
558
- }
559
- }
560
- }
561
- this.textNode += chunk.substring(starti, i - 1);
562
- }
563
- if (c === "<" && !(this.sawRoot && this.closedRoot && !this.strict)) {
564
- this.state = this.S.OPEN_WAKA;
565
- this.startTagPosition = this.position;
566
- } else {
567
- if (!SAX.isWhitespace(c) && (!this.sawRoot || this.closedRoot)) {
568
- this.strictFail("Text data outside of root node.");
569
- }
570
- if (c === "&") {
571
- this.state = this.S.TEXT_ENTITY;
572
- } else {
573
- this.textNode += c;
574
- }
575
- }
576
- continue;
577
- case this.S.SCRIPT:
578
- if (c === "<") {
579
- this.state = this.S.SCRIPT_ENDING;
580
- } else {
581
- this.script += c;
582
- }
583
- continue;
584
- case this.S.SCRIPT_ENDING:
585
- if (c === "/") {
586
- this.state = this.S.CLOSE_TAG;
587
- } else {
588
- this.script += `<${c}`;
589
- this.state = this.S.SCRIPT;
590
- }
591
- continue;
592
- case this.S.OPEN_WAKA:
593
- if (c === "!") {
594
- this.state = this.S.SGML_DECL;
595
- this.sgmlDecl = "";
596
- } else if (SAX.isWhitespace(c)) {
597
- } else if (SAX.isMatch(nameStart, c)) {
598
- this.state = this.S.OPEN_TAG;
599
- this.tagName = c;
600
- } else if (c === "/") {
601
- this.state = this.S.CLOSE_TAG;
602
- this.tagName = "";
603
- } else if (c === "?") {
604
- this.state = this.S.PROC_INST;
605
- this.procInstName = this.procInstBody = "";
606
- } else {
607
- this.strictFail("Unencoded <");
608
- if (this.startTagPosition + 1 < this.position) {
609
- const pad = this.position - this.startTagPosition;
610
- c = new Array(pad).join(" ") + c;
611
- }
612
- this.textNode += `<${c}`;
613
- this.state = this.S.TEXT;
614
- }
615
- continue;
616
- case this.S.SGML_DECL:
617
- if ((this.sgmlDecl + c).toUpperCase() === this.CDATA) {
618
- this.emitNode("onopencdata");
619
- this.state = this.S.CDATA;
620
- this.sgmlDecl = "";
621
- this.cdata = "";
622
- } else if (this.sgmlDecl + c === "--") {
623
- this.state = this.S.COMMENT;
624
- this.comment = "";
625
- this.sgmlDecl = "";
626
- } else if ((this.sgmlDecl + c).toUpperCase() === this.DOCTYPE) {
627
- this.state = this.S.DOCTYPE;
628
- if (this.doctype || this.sawRoot) {
629
- this.strictFail("Inappropriately located doctype declaration");
630
- }
631
- this.doctype = "";
632
- this.sgmlDecl = "";
633
- } else if (c === ">") {
634
- this.emitNode("onsgmldeclaration", this.sgmlDecl);
635
- this.sgmlDecl = "";
636
- this.state = this.S.TEXT;
637
- } else if (SAX.isQuote(c)) {
638
- this.state = this.S.SGML_DECL_QUOTED;
639
- this.sgmlDecl += c;
139
+ let tagName = "";
140
+ for (; i < xmlData.length && xmlData[i] !== ">" && xmlData[i] !== " " && xmlData[i] !== " " && xmlData[i] !== "\n" && xmlData[i] !== "\r"; i++) {
141
+ tagName += xmlData[i];
142
+ }
143
+ tagName = tagName.trim();
144
+ if (tagName[tagName.length - 1] === "/") {
145
+ tagName = tagName.substring(0, tagName.length - 1);
146
+ i--;
147
+ }
148
+ if (!validateTagName(tagName)) {
149
+ let msg;
150
+ if (tagName.trim().length === 0) {
151
+ msg = "Invalid space after '<'.";
640
152
  } else {
641
- this.sgmlDecl += c;
642
- }
643
- continue;
644
- case this.S.SGML_DECL_QUOTED:
645
- if (c === this.q) {
646
- this.state = this.S.SGML_DECL;
647
- this.q = "";
153
+ msg = "Tag '" + tagName + "' is an invalid name.";
648
154
  }
649
- this.sgmlDecl += c;
650
- continue;
651
- case this.S.DOCTYPE:
652
- if (c === ">") {
653
- this.state = this.S.TEXT;
654
- this.emitNode("ondoctype", this.doctype);
655
- this.doctype = true;
155
+ return getErrorObject("InvalidTag", msg, getLineNumberForPosition(xmlData, i));
156
+ }
157
+ const result = readAttributeStr(xmlData, i);
158
+ if (result === false) {
159
+ return getErrorObject("InvalidAttr", "Attributes for '" + tagName + "' have open quote.", getLineNumberForPosition(xmlData, i));
160
+ }
161
+ let attrStr = result.value;
162
+ i = result.index;
163
+ if (attrStr[attrStr.length - 1] === "/") {
164
+ const attrStrStart = i - attrStr.length;
165
+ attrStr = attrStr.substring(0, attrStr.length - 1);
166
+ const isValid = validateAttributeString(attrStr, options);
167
+ if (isValid === true) {
168
+ tagFound = true;
656
169
  } else {
657
- this.doctype += c;
658
- if (c === "[") {
659
- this.state = this.S.DOCTYPE_DTD;
660
- } else if (SAX.isQuote(c)) {
661
- this.state = this.S.DOCTYPE_QUOTED;
662
- this.q = c;
663
- }
664
- }
665
- continue;
666
- case this.S.DOCTYPE_QUOTED:
667
- this.doctype += c;
668
- if (c === this.q) {
669
- this.q = "";
670
- this.state = this.S.DOCTYPE;
671
- }
672
- continue;
673
- case this.S.DOCTYPE_DTD:
674
- this.doctype += c;
675
- if (c === "]") {
676
- this.state = this.S.DOCTYPE;
677
- } else if (SAX.isQuote(c)) {
678
- this.state = this.S.DOCTYPE_DTD_QUOTED;
679
- this.q = c;
680
- }
681
- continue;
682
- case this.S.DOCTYPE_DTD_QUOTED:
683
- this.doctype += c;
684
- if (c === this.q) {
685
- this.state = this.S.DOCTYPE_DTD;
686
- this.q = "";
170
+ return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid.err.line));
687
171
  }
688
- continue;
689
- case this.S.COMMENT:
690
- if (c === "-") {
691
- this.state = this.S.COMMENT_ENDING;
172
+ } else if (closingTag) {
173
+ if (!result.tagClosed) {
174
+ return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' doesn't have proper closing.", getLineNumberForPosition(xmlData, i));
175
+ } else if (attrStr.trim().length > 0) {
176
+ return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' can't have attributes or invalid starting.", getLineNumberForPosition(xmlData, tagStartPos));
692
177
  } else {
693
- this.comment += c;
694
- }
695
- continue;
696
- case this.S.COMMENT_ENDING:
697
- if (c === "-") {
698
- this.state = this.S.COMMENT_ENDED;
699
- this.comment = this.textApplyOptions(this.comment);
700
- if (this.comment) {
701
- this.emitNode("oncomment", this.comment);
178
+ const otg = tags.pop();
179
+ if (tagName !== otg.tagName) {
180
+ let openPos = getLineNumberForPosition(xmlData, otg.tagStartPos);
181
+ return getErrorObject("InvalidTag", "Expected closing tag '" + otg.tagName + "' (opened in line " + openPos.line + ", col " + openPos.col + ") instead of closing tag '" + tagName + "'.", getLineNumberForPosition(xmlData, tagStartPos));
702
182
  }
703
- this.comment = "";
704
- } else {
705
- this.comment += `-${c}`;
706
- this.state = this.S.COMMENT;
707
- }
708
- continue;
709
- case this.S.COMMENT_ENDED:
710
- if (c !== ">") {
711
- this.strictFail("Malformed comment");
712
- this.comment += `--${c}`;
713
- this.state = this.S.COMMENT;
714
- } else {
715
- this.state = this.S.TEXT;
716
- }
717
- continue;
718
- case this.S.CDATA:
719
- if (c === "]") {
720
- this.state = this.S.CDATA_ENDING;
721
- } else {
722
- this.cdata += c;
723
- }
724
- continue;
725
- case this.S.CDATA_ENDING:
726
- if (c === "]") {
727
- this.state = this.S.CDATA_ENDING_2;
728
- } else {
729
- this.cdata += `]${c}`;
730
- this.state = this.S.CDATA;
731
- }
732
- continue;
733
- case this.S.CDATA_ENDING_2:
734
- if (c === ">") {
735
- if (this.cdata) {
736
- this.emitNode("oncdata", this.cdata);
183
+ if (tags.length == 0) {
184
+ reachedRoot = true;
737
185
  }
738
- this.emitNode("onclosecdata");
739
- this.cdata = "";
740
- this.state = this.S.TEXT;
741
- } else if (c === "]") {
742
- this.cdata += "]";
743
- } else {
744
- this.cdata += `]]${c}`;
745
- this.state = this.S.CDATA;
746
186
  }
747
- continue;
748
- case this.S.PROC_INST:
749
- if (c === "?") {
750
- this.state = this.S.PROC_INST_ENDING;
751
- } else if (SAX.isWhitespace(c)) {
752
- this.state = this.S.PROC_INST_BODY;
753
- } else {
754
- this.procInstName += c;
187
+ } else {
188
+ const isValid = validateAttributeString(attrStr, options);
189
+ if (isValid !== true) {
190
+ return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, i - attrStr.length + isValid.err.line));
755
191
  }
756
- continue;
757
- case this.S.PROC_INST_BODY:
758
- if (!this.procInstBody && SAX.isWhitespace(c)) {
759
- continue;
760
- } else if (c === "?") {
761
- this.state = this.S.PROC_INST_ENDING;
192
+ if (reachedRoot === true) {
193
+ return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(xmlData, i));
194
+ } else if (options.unpairedTags.indexOf(tagName) !== -1) {
762
195
  } else {
763
- this.procInstBody += c;
764
- }
765
- continue;
766
- case this.S.PROC_INST_ENDING:
767
- if (c === ">") {
768
- this.emitNode("onprocessinginstruction", {
769
- name: this.procInstName,
770
- body: this.procInstBody
196
+ tags.push({
197
+ tagName,
198
+ tagStartPos
771
199
  });
772
- this.procInstName = this.procInstBody = "";
773
- this.state = this.S.TEXT;
774
- } else {
775
- this.procInstBody += `?${c}`;
776
- this.state = this.S.PROC_INST_BODY;
777
200
  }
778
- continue;
779
- case this.S.OPEN_TAG:
780
- if (SAX.isMatch(nameBody, c)) {
781
- this.tagName += c;
782
- } else {
783
- this.newTag();
784
- if (c === ">") {
785
- this.openTag();
786
- } else if (c === "/") {
787
- this.state = this.S.OPEN_TAG_SLASH;
201
+ tagFound = true;
202
+ }
203
+ for (i++; i < xmlData.length; i++) {
204
+ if (xmlData[i] === "<") {
205
+ if (xmlData[i + 1] === "!") {
206
+ i++;
207
+ i = readCommentAndCDATA(xmlData, i);
208
+ continue;
209
+ } else if (xmlData[i + 1] === "?") {
210
+ i = readPI(xmlData, ++i);
211
+ if (i.err)
212
+ return i;
788
213
  } else {
789
- if (!SAX.isWhitespace(c)) {
790
- this.strictFail("Invalid character in tag name");
791
- }
792
- this.state = this.S.ATTRIB;
214
+ break;
793
215
  }
794
- }
795
- continue;
796
- case this.S.OPEN_TAG_SLASH:
797
- if (c === ">") {
798
- this.openTag(true);
799
- this.closeTag();
800
- } else {
801
- this.strictFail("Forward-slash in opening tag not followed by >");
802
- this.state = this.S.ATTRIB;
803
- }
804
- continue;
805
- case this.S.ATTRIB:
806
- if (SAX.isWhitespace(c)) {
807
- continue;
808
- } else if (c === ">") {
809
- this.openTag();
810
- } else if (c === "/") {
811
- this.state = this.S.OPEN_TAG_SLASH;
812
- } else if (SAX.isMatch(nameStart, c)) {
813
- this.attribName = c;
814
- this.attribValue = "";
815
- this.state = this.S.ATTRIB_NAME;
216
+ } else if (xmlData[i] === "&") {
217
+ const afterAmp = validateAmpersand(xmlData, i);
218
+ if (afterAmp == -1)
219
+ return getErrorObject("InvalidChar", "char '&' is not expected.", getLineNumberForPosition(xmlData, i));
220
+ i = afterAmp;
816
221
  } else {
817
- this.strictFail("Invalid attribute name");
222
+ if (reachedRoot === true && !isWhiteSpace(xmlData[i])) {
223
+ return getErrorObject("InvalidXml", "Extra text at the end", getLineNumberForPosition(xmlData, i));
224
+ }
818
225
  }
819
- continue;
820
- case this.S.ATTRIB_NAME:
821
- if (c === "=") {
822
- this.state = this.S.ATTRIB_VALUE;
823
- } else if (c === ">") {
824
- this.strictFail("Attribute without value");
825
- this.attribValue = this.attribName;
826
- this.attrib();
827
- this.openTag();
828
- } else if (SAX.isWhitespace(c)) {
829
- this.state = this.S.ATTRIB_NAME_SAW_WHITE;
830
- } else if (SAX.isMatch(nameBody, c)) {
831
- this.attribName += c;
832
- } else {
833
- this.strictFail("Invalid attribute name");
834
- }
835
- continue;
836
- case this.S.ATTRIB_NAME_SAW_WHITE:
837
- if (c === "=") {
838
- this.state = this.S.ATTRIB_VALUE;
839
- } else if (SAX.isWhitespace(c)) {
840
- continue;
841
- } else {
842
- this.strictFail("Attribute without value");
843
- this.tag.attributes[this.attribName] = "";
844
- this.attribValue = "";
845
- this.emitNode("onattribute", {
846
- name: this.attribName,
847
- value: ""
848
- });
849
- this.attribName = "";
850
- if (c === ">") {
851
- this.openTag();
852
- } else if (SAX.isMatch(nameStart, c)) {
853
- this.attribName = c;
854
- this.state = this.S.ATTRIB_NAME;
855
- } else {
856
- this.strictFail("Invalid attribute name");
857
- this.state = this.S.ATTRIB;
858
- }
859
- }
860
- continue;
861
- case this.S.ATTRIB_VALUE:
862
- if (SAX.isWhitespace(c)) {
863
- continue;
864
- } else if (SAX.isQuote(c)) {
865
- this.q = c;
866
- this.state = this.S.ATTRIB_VALUE_QUOTED;
867
- } else {
868
- this.strictFail("Unquoted attribute value");
869
- this.state = this.S.ATTRIB_VALUE_UNQUOTED;
870
- this.attribValue = c;
871
- }
872
- continue;
873
- case this.S.ATTRIB_VALUE_QUOTED:
874
- if (c !== this.q) {
875
- if (c === "&") {
876
- this.state = this.S.ATTRIB_VALUE_ENTITY_Q;
877
- } else {
878
- this.attribValue += c;
879
- }
880
- continue;
881
- }
882
- this.attrib();
883
- this.q = "";
884
- this.state = this.S.ATTRIB_VALUE_CLOSED;
885
- continue;
886
- case this.S.ATTRIB_VALUE_CLOSED:
887
- if (SAX.isWhitespace(c)) {
888
- this.state = this.S.ATTRIB;
889
- } else if (c === ">") {
890
- this.openTag();
891
- } else if (c === "/") {
892
- this.state = this.S.OPEN_TAG_SLASH;
893
- } else if (SAX.isMatch(nameStart, c)) {
894
- this.strictFail("No whitespace between attributes");
895
- this.attribName = c;
896
- this.attribValue = "";
897
- this.state = this.S.ATTRIB_NAME;
898
- } else {
899
- this.strictFail("Invalid attribute name");
900
- }
901
- continue;
902
- case this.S.ATTRIB_VALUE_UNQUOTED:
903
- if (!SAX.isAttribEnd(c)) {
904
- if (c === "&") {
905
- this.state = this.S.ATTRIB_VALUE_ENTITY_U;
906
- } else {
907
- this.attribValue += c;
908
- }
909
- continue;
910
- }
911
- this.attrib();
912
- if (c === ">") {
913
- this.openTag();
914
- } else {
915
- this.state = this.S.ATTRIB;
916
- }
917
- continue;
918
- case this.S.CLOSE_TAG:
919
- if (!this.tagName) {
920
- if (SAX.isWhitespace(c)) {
921
- continue;
922
- } else if (SAX.notMatch(nameStart, c)) {
923
- if (this.script) {
924
- this.script += `</${c}`;
925
- this.state = this.S.SCRIPT;
926
- } else {
927
- this.strictFail("Invalid tagname in closing tag.");
928
- }
929
- } else {
930
- this.tagName = c;
931
- }
932
- } else if (c === ">") {
933
- this.closeTag();
934
- } else if (SAX.isMatch(nameBody, c)) {
935
- this.tagName += c;
936
- } else if (this.script) {
937
- this.script += `</${this.tagName}`;
938
- this.tagName = "";
939
- this.state = this.S.SCRIPT;
940
- } else {
941
- if (!SAX.isWhitespace(c)) {
942
- this.strictFail("Invalid tagname in closing tag");
943
- }
944
- this.state = this.S.CLOSE_TAG_SAW_WHITE;
945
- }
946
- continue;
947
- case this.S.CLOSE_TAG_SAW_WHITE:
948
- if (SAX.isWhitespace(c)) {
949
- continue;
950
- }
951
- if (c === ">") {
952
- this.closeTag();
953
- } else {
954
- this.strictFail("Invalid characters in closing tag");
955
- }
956
- continue;
957
- case this.S.TEXT_ENTITY:
958
- case this.S.ATTRIB_VALUE_ENTITY_Q:
959
- case this.S.ATTRIB_VALUE_ENTITY_U:
960
- let returnState;
961
- let buffer;
962
- switch (this.state) {
963
- case this.S.TEXT_ENTITY:
964
- returnState = this.S.TEXT;
965
- buffer = "textNode";
966
- break;
967
- case this.S.ATTRIB_VALUE_ENTITY_Q:
968
- returnState = this.S.ATTRIB_VALUE_QUOTED;
969
- buffer = "attribValue";
970
- break;
971
- case this.S.ATTRIB_VALUE_ENTITY_U:
972
- returnState = this.S.ATTRIB_VALUE_UNQUOTED;
973
- buffer = "attribValue";
974
- break;
975
- default:
976
- throw new Error(`Unknown state: ${this.state}`);
977
- }
978
- if (c === ";") {
979
- this[buffer] += this.parseEntity();
980
- this.entity = "";
981
- this.state = returnState;
982
- } else if (SAX.isMatch(this.entity.length ? entityBody : entityStart, c)) {
983
- this.entity += c;
984
- } else {
985
- this.strictFail("Invalid character in entity name");
986
- this[buffer] += `&${this.entity}${c}`;
987
- this.entity = "";
988
- this.state = returnState;
989
- }
990
- continue;
991
- default:
992
- throw new Error(`Unknown state: ${this.state}`);
993
- }
994
- }
995
- if (this.position >= this.bufferCheckPosition) {
996
- this.checkBufferLength();
997
- }
998
- return this;
999
- }
1000
- emit(event, data) {
1001
- if (this.events.hasOwnProperty(event)) {
1002
- const eventName = event.replace(/^on/, "");
1003
- this.events[event](data, eventName, this);
1004
- }
1005
- }
1006
- clearBuffers() {
1007
- for (let i = 0, l = this.BUFFERS.length; i < l; i++) {
1008
- this[this[i]] = "";
1009
- }
1010
- }
1011
- flushBuffers() {
1012
- this.closeText();
1013
- if (this.cdata !== "") {
1014
- this.emitNode("oncdata", this.cdata);
1015
- this.cdata = "";
1016
- }
1017
- if (this.script !== "") {
1018
- this.emitNode("onscript", this.script);
1019
- this.script = "";
1020
- }
1021
- }
1022
- end() {
1023
- if (this.sawRoot && !this.closedRoot)
1024
- this.strictFail("Unclosed root tag");
1025
- if (this.state !== this.S.BEGIN && this.state !== this.S.BEGIN_WHITESPACE && this.state !== this.S.TEXT) {
1026
- this.errorFunction("Unexpected end");
1027
- }
1028
- this.closeText();
1029
- this.c = "";
1030
- this.closed = true;
1031
- this.emit("onend");
1032
- return new SAXParser(this.opt);
1033
- }
1034
- errorFunction(er) {
1035
- this.closeText();
1036
- if (this.trackPosition) {
1037
- er += `
1038
- Line: ${this.line}
1039
- Column: ${this.column}
1040
- Char: ${this.c}`;
1041
- }
1042
- const error = new Error(er);
1043
- this.error = error;
1044
- this.emit("onerror", error);
1045
- return this;
1046
- }
1047
- attrib() {
1048
- if (!this.strict) {
1049
- this.attribName = this.attribName[this.looseCase]();
1050
- }
1051
- if (this.attribList.indexOf(this.attribName) !== -1 || this.tag.attributes.hasOwnProperty(this.attribName)) {
1052
- this.attribName = this.attribValue = "";
1053
- return;
1054
- }
1055
- if (this.opt.xmlns) {
1056
- const qn = SAX.qname(this.attribName, true);
1057
- const prefix = qn.prefix;
1058
- const local = qn.local;
1059
- if (prefix === "xmlns") {
1060
- if (local === "xml" && this.attribValue !== this.XML_NAMESPACE) {
1061
- this.strictFail(`xml: prefix must be bound to ${this.XML_NAMESPACE}
1062
- Actual: ${this.attribValue}`);
1063
- } else if (local === "xmlns" && this.attribValue !== this.XMLNS_NAMESPACE) {
1064
- this.strictFail(`xmlns: prefix must be bound to ${this.XMLNS_NAMESPACE}
1065
- Actual: ${this.attribValue}`);
1066
- } else {
1067
- const tag = this.tag;
1068
- const parent = this.tags[this.tags.length - 1] || this;
1069
- if (tag.ns === parent.ns) {
1070
- tag.ns = Object.create(parent.ns);
1071
- }
1072
- tag.ns[local] = this.attribValue;
226
+ }
227
+ if (xmlData[i] === "<") {
228
+ i--;
1073
229
  }
1074
230
  }
1075
- this.attribList.push([this.attribName, this.attribValue]);
1076
231
  } else {
1077
- this.tag.attributes[this.attribName] = this.attribValue;
1078
- this.emitNode("onattribute", {
1079
- name: this.attribName,
1080
- value: this.attribValue
1081
- });
1082
- }
1083
- this.attribName = this.attribValue = "";
1084
- }
1085
- newTag() {
1086
- if (!this.strict)
1087
- this.tagName = this.tagName[this.looseCase]();
1088
- const parent = this.tags[this.tags.length - 1] || this;
1089
- const tag = this.tag = { name: this.tagName, attributes: {} };
1090
- if (this.opt.xmlns) {
1091
- tag.ns = parent.ns;
1092
- }
1093
- this.attribList.length = 0;
1094
- this.emitNode("onopentagstart", tag);
1095
- }
1096
- parseEntity() {
1097
- let entity = this.entity;
1098
- const entityLC = entity.toLowerCase();
1099
- let num = NaN;
1100
- let numStr = "";
1101
- if (this.ENTITIES[entity]) {
1102
- return this.ENTITIES[entity];
1103
- }
1104
- if (this.ENTITIES[entityLC]) {
1105
- return this.ENTITIES[entityLC];
1106
- }
1107
- entity = entityLC;
1108
- if (entity.charAt(0) === "#") {
1109
- if (entity.charAt(1) === "x") {
1110
- entity = entity.slice(2);
1111
- num = parseInt(entity, 16);
1112
- numStr = num.toString(16);
1113
- } else {
1114
- entity = entity.slice(1);
1115
- num = parseInt(entity, 10);
1116
- numStr = num.toString(10);
232
+ if (isWhiteSpace(xmlData[i])) {
233
+ continue;
1117
234
  }
1118
- }
1119
- entity = entity.replace(/^0+/, "");
1120
- if (isNaN(num) || numStr.toLowerCase() !== entity) {
1121
- this.strictFail("Invalid character entity");
1122
- return `&${this.entity};`;
1123
- }
1124
- return String.fromCodePoint(num);
1125
- }
1126
- beginWhiteSpace(c) {
1127
- if (c === "<") {
1128
- this.state = this.S.OPEN_WAKA;
1129
- this.startTagPosition = this.position;
1130
- } else if (!SAX.isWhitespace(c)) {
1131
- this.strictFail("Non-whitespace before first tag.");
1132
- this.textNode = c;
1133
- this.state = this.S.TEXT;
1134
- } else {
235
+ return getErrorObject("InvalidChar", "char '" + xmlData[i] + "' is not expected.", getLineNumberForPosition(xmlData, i));
1135
236
  }
1136
237
  }
1137
- strictFail(message) {
1138
- if (typeof this !== "object" || !(this instanceof SAXParser)) {
1139
- throw new Error("bad call to strictFail");
1140
- }
1141
- if (this.strict) {
1142
- this.errorFunction(message);
1143
- }
238
+ if (!tagFound) {
239
+ return getErrorObject("InvalidXml", "Start tag expected.", 1);
240
+ } else if (tags.length == 1) {
241
+ return getErrorObject("InvalidTag", "Unclosed tag '" + tags[0].tagName + "'.", getLineNumberForPosition(xmlData, tags[0].tagStartPos));
242
+ } else if (tags.length > 0) {
243
+ return getErrorObject("InvalidXml", "Invalid '" + JSON.stringify(tags.map((t) => t.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", {
244
+ line: 1,
245
+ col: 1
246
+ });
1144
247
  }
1145
- textApplyOptions(text) {
1146
- if (this.opt.trim)
1147
- text = text.trim();
1148
- if (this.opt.normalize)
1149
- text = text.replace(/\s+/g, " ");
1150
- return text;
1151
- }
1152
- emitNode(nodeType, data) {
1153
- if (this.textNode)
1154
- this.closeText();
1155
- this.emit(nodeType, data);
1156
- }
1157
- closeText() {
1158
- this.textNode = this.textApplyOptions(this.textNode);
1159
- if (this.textNode !== void 0 && this.textNode !== "" && this.textNode !== "undefined") {
1160
- this.emit("ontext", this.textNode);
1161
- }
1162
- this.textNode = "";
1163
- }
1164
- checkBufferLength() {
1165
- const maxAllowed = Math.max(this.opt.MAX_BUFFER_LENGTH, 10);
1166
- let maxActual = 0;
1167
- for (let i = 0, l = this.BUFFERS.length; i < l; i++) {
1168
- const len = this[this.BUFFERS[i]]?.length || 0;
1169
- if (len > maxAllowed) {
1170
- switch (this.BUFFERS[i]) {
1171
- case "textNode":
1172
- this.closeText();
1173
- break;
1174
- case "cdata":
1175
- this.emitNode("oncdata", this.cdata);
1176
- this.cdata = "";
1177
- break;
1178
- case "script":
1179
- this.emitNode("onscript", this.script);
1180
- this.script = "";
1181
- break;
1182
- default:
1183
- this.errorFunction(`Max buffer length exceeded: ${this.BUFFERS[i]}`);
1184
- }
248
+ return true;
249
+ };
250
+ function isWhiteSpace(char) {
251
+ return char === " " || char === " " || char === "\n" || char === "\r";
252
+ }
253
+ function readPI(xmlData, i) {
254
+ const start = i;
255
+ for (; i < xmlData.length; i++) {
256
+ if (xmlData[i] == "?" || xmlData[i] == " ") {
257
+ const tagname = xmlData.substr(start, i - start);
258
+ if (i > 5 && tagname === "xml") {
259
+ return getErrorObject("InvalidXml", "XML declaration allowed only at the start of the document.", getLineNumberForPosition(xmlData, i));
260
+ } else if (xmlData[i] == "?" && xmlData[i + 1] == ">") {
261
+ i++;
262
+ break;
263
+ } else {
264
+ continue;
1185
265
  }
1186
- maxActual = Math.max(maxActual, len);
1187
266
  }
1188
- const m = this.opt.MAX_BUFFER_LENGTH - maxActual;
1189
- this.bufferCheckPosition = m + this.position;
1190
267
  }
1191
- openTag(selfClosing) {
1192
- if (this.opt.xmlns) {
1193
- const tag = this.tag;
1194
- const qn = SAX.qname(this.tagName);
1195
- tag.prefix = qn.prefix;
1196
- tag.local = qn.local;
1197
- tag.uri = tag.ns[qn.prefix] || "";
1198
- if (tag.prefix && !tag.uri) {
1199
- this.strictFail(`Unbound namespace prefix: ${JSON.stringify(this.tagName)}`);
1200
- tag.uri = qn.prefix;
1201
- }
1202
- const parent = this.tags[this.tags.length - 1] || this;
1203
- if (tag.ns && parent.ns !== tag.ns) {
1204
- const that = this;
1205
- Object.keys(tag.ns).forEach((p) => {
1206
- that.emitNode("onopennamespace", {
1207
- prefix: p,
1208
- uri: tag.ns[p]
1209
- });
1210
- });
1211
- }
1212
- for (let i = 0, l = this.attribList.length; i < l; i++) {
1213
- const nv = this.attribList[i];
1214
- const name = nv[0];
1215
- const value = nv[1];
1216
- const qualName = SAX.qname(name, true);
1217
- const prefix = qualName.prefix;
1218
- const local = qualName.local;
1219
- const uri = prefix === "" ? "" : tag.ns[prefix] || "";
1220
- const a = {
1221
- name,
1222
- value,
1223
- prefix,
1224
- local,
1225
- uri
1226
- };
1227
- if (prefix && prefix !== "xmlns" && !uri) {
1228
- this.strictFail(`Unbound namespace prefix: ${JSON.stringify(prefix)}`);
1229
- a.uri = prefix;
1230
- }
1231
- this.tag.attributes[name] = a;
1232
- this.emitNode("onattribute", a);
1233
- }
1234
- this.attribList.length = 0;
1235
- }
1236
- this.tag.isSelfClosing = Boolean(selfClosing);
1237
- this.sawRoot = true;
1238
- this.tags.push(this.tag);
1239
- this.emitNode("onopentag", this.tag);
1240
- if (!selfClosing) {
1241
- if (!this.noscript && this.tagName.toLowerCase() === "script") {
1242
- this.state = this.S.SCRIPT;
1243
- } else {
1244
- this.state = this.S.TEXT;
268
+ return i;
269
+ }
270
+ function readCommentAndCDATA(xmlData, i) {
271
+ if (xmlData.length > i + 5 && xmlData[i + 1] === "-" && xmlData[i + 2] === "-") {
272
+ for (i += 3; i < xmlData.length; i++) {
273
+ if (xmlData[i] === "-" && xmlData[i + 1] === "-" && xmlData[i + 2] === ">") {
274
+ i += 2;
275
+ break;
1245
276
  }
1246
- this.tag = null;
1247
- this.tagName = "";
1248
277
  }
1249
- this.attribName = this.attribValue = "";
1250
- this.attribList.length = 0;
1251
- }
1252
- closeTag() {
1253
- if (!this.tagName) {
1254
- this.strictFail("Weird empty close tag.");
1255
- this.textNode += "</>";
1256
- this.state = this.S.TEXT;
1257
- return;
1258
- }
1259
- if (this.script) {
1260
- if (this.tagName !== "script") {
1261
- this.script += `</${this.tagName}>`;
1262
- this.tagName = "";
1263
- this.state = this.S.SCRIPT;
1264
- return;
278
+ } else if (xmlData.length > i + 8 && xmlData[i + 1] === "D" && xmlData[i + 2] === "O" && xmlData[i + 3] === "C" && xmlData[i + 4] === "T" && xmlData[i + 5] === "Y" && xmlData[i + 6] === "P" && xmlData[i + 7] === "E") {
279
+ let angleBracketsCount = 1;
280
+ for (i += 8; i < xmlData.length; i++) {
281
+ if (xmlData[i] === "<") {
282
+ angleBracketsCount++;
283
+ } else if (xmlData[i] === ">") {
284
+ angleBracketsCount--;
285
+ if (angleBracketsCount === 0) {
286
+ break;
287
+ }
1265
288
  }
1266
- this.emitNode("onscript", this.script);
1267
- this.script = "";
1268
289
  }
1269
- let t = this.tags.length;
1270
- let tagName = this.tagName;
1271
- if (!this.strict) {
1272
- tagName = tagName[this.looseCase]();
1273
- }
1274
- while (t--) {
1275
- const close = this.tags[t];
1276
- if (close.name !== tagName) {
1277
- this.strictFail("Unexpected close tag");
1278
- } else {
290
+ } else if (xmlData.length > i + 9 && xmlData[i + 1] === "[" && xmlData[i + 2] === "C" && xmlData[i + 3] === "D" && xmlData[i + 4] === "A" && xmlData[i + 5] === "T" && xmlData[i + 6] === "A" && xmlData[i + 7] === "[") {
291
+ for (i += 8; i < xmlData.length; i++) {
292
+ if (xmlData[i] === "]" && xmlData[i + 1] === "]" && xmlData[i + 2] === ">") {
293
+ i += 2;
1279
294
  break;
1280
295
  }
1281
296
  }
1282
- if (t < 0) {
1283
- this.strictFail(`Unmatched closing tag: ${this.tagName}`);
1284
- this.textNode += `</${this.tagName}>`;
1285
- this.state = this.S.TEXT;
1286
- return;
1287
- }
1288
- this.tagName = tagName;
1289
- let s = this.tags.length;
1290
- while (s-- > t) {
1291
- const tag = this.tag = this.tags.pop();
1292
- this.tagName = this.tag.name;
1293
- this.emitNode("onclosetag", this.tagName);
1294
- const x = {};
1295
- for (const i in tag.ns) {
1296
- if (tag.ns.hasOwnProperty(i)) {
1297
- x[i] = tag.ns[i];
1298
- }
297
+ }
298
+ return i;
299
+ }
300
+ var doubleQuote = '"';
301
+ var singleQuote = "'";
302
+ function readAttributeStr(xmlData, i) {
303
+ let attrStr = "";
304
+ let startChar = "";
305
+ let tagClosed = false;
306
+ for (; i < xmlData.length; i++) {
307
+ if (xmlData[i] === doubleQuote || xmlData[i] === singleQuote) {
308
+ if (startChar === "") {
309
+ startChar = xmlData[i];
310
+ } else if (startChar !== xmlData[i]) {
311
+ } else {
312
+ startChar = "";
1299
313
  }
1300
- const parent = this.tags[this.tags.length - 1] || this;
1301
- if (this.opt.xmlns && tag.ns !== parent.ns) {
1302
- const that = this;
1303
- Object.keys(tag.ns).forEach((p) => {
1304
- const n = tag.ns[p];
1305
- that.emitNode("onclosenamespace", { prefix: p, uri: n });
1306
- });
314
+ } else if (xmlData[i] === ">") {
315
+ if (startChar === "") {
316
+ tagClosed = true;
317
+ break;
1307
318
  }
1308
319
  }
1309
- if (t === 0)
1310
- this.closedRoot = true;
1311
- this.tagName = this.attribValue = this.attribName = "";
1312
- this.attribList.length = 0;
1313
- this.state = this.S.TEXT;
320
+ attrStr += xmlData[i];
1314
321
  }
1315
- };
1316
- SAXParser = class extends SAX {
1317
- constructor(opt) {
1318
- super();
1319
- this.opt = DEFAULT_SAX_PARSER_OPTIONS;
1320
- this.events = DEFAULT_SAX_EVENTS;
1321
- this.clearBuffers();
1322
- this.opt = opt = { ...this.opt, ...opt };
1323
- this.events = { ...this.events, ...opt };
1324
- this.q = this.c = "";
1325
- this.opt.lowercase = this.opt.lowercase || this.opt.lowercasetags;
1326
- this.bufferCheckPosition = this.opt.MAX_BUFFER_LENGTH;
1327
- this.looseCase = this.opt.lowercase ? "toLowerCase" : "toUpperCase";
1328
- this.tags = [];
1329
- this.closed = this.closedRoot = this.sawRoot = false;
1330
- this.tag = this.error = null;
1331
- this.strict = Boolean(this.opt.strict);
1332
- this.noscript = Boolean(this.opt.strict || this.opt.noscript);
1333
- this.state = this.S.BEGIN;
1334
- this.strictEntities = this.opt.strictEntities;
1335
- this.ENTITIES = this.strictEntities ? Object.create(this.XML_ENTITIES) : Object.create(this.ENTITIES);
1336
- this.attribList = [];
1337
- if (this.opt.xmlns) {
1338
- this.ns = Object.create(this.rootNS);
322
+ if (startChar !== "") {
323
+ return false;
324
+ }
325
+ return {
326
+ value: attrStr,
327
+ index: i,
328
+ tagClosed
329
+ };
330
+ }
331
+ var validAttrStrRegxp = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
332
+ function validateAttributeString(attrStr, options) {
333
+ const matches = util.getAllMatches(attrStr, validAttrStrRegxp);
334
+ const attrNames = {};
335
+ for (let i = 0; i < matches.length; i++) {
336
+ if (matches[i][1].length === 0) {
337
+ return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' has no space in starting.", getPositionFromMatch(matches[i]));
338
+ } else if (matches[i][3] !== void 0 && matches[i][4] === void 0) {
339
+ return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' is without value.", getPositionFromMatch(matches[i]));
340
+ } else if (matches[i][3] === void 0 && !options.allowBooleanAttributes) {
341
+ return getErrorObject("InvalidAttr", "boolean attribute '" + matches[i][2] + "' is not allowed.", getPositionFromMatch(matches[i]));
1339
342
  }
1340
- this.trackPosition = this.opt.position !== false;
1341
- if (this.trackPosition) {
1342
- this.position = this.line = this.column = 0;
343
+ const attrName = matches[i][2];
344
+ if (!validateAttrName(attrName)) {
345
+ return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is an invalid name.", getPositionFromMatch(matches[i]));
346
+ }
347
+ if (!attrNames.hasOwnProperty(attrName)) {
348
+ attrNames[attrName] = 1;
349
+ } else {
350
+ return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is repeated.", getPositionFromMatch(matches[i]));
1343
351
  }
1344
- this.emit("onready");
1345
352
  }
1346
- resume() {
1347
- this.error = null;
1348
- return this;
353
+ return true;
354
+ }
355
+ function validateNumberAmpersand(xmlData, i) {
356
+ let re = /\d/;
357
+ if (xmlData[i] === "x") {
358
+ i++;
359
+ re = /[\da-fA-F]/;
360
+ }
361
+ for (; i < xmlData.length; i++) {
362
+ if (xmlData[i] === ";")
363
+ return i;
364
+ if (!xmlData[i].match(re))
365
+ break;
1349
366
  }
1350
- close() {
1351
- return this.write(null);
367
+ return -1;
368
+ }
369
+ function validateAmpersand(xmlData, i) {
370
+ i++;
371
+ if (xmlData[i] === ";")
372
+ return -1;
373
+ if (xmlData[i] === "#") {
374
+ i++;
375
+ return validateNumberAmpersand(xmlData, i);
1352
376
  }
1353
- flush() {
1354
- this.flushBuffers();
377
+ let count = 0;
378
+ for (; i < xmlData.length; i++, count++) {
379
+ if (xmlData[i].match(/\w/) && count < 20)
380
+ continue;
381
+ if (xmlData[i] === ";")
382
+ break;
383
+ return -1;
1355
384
  }
1356
- };
1357
- SAXParser.ENTITIES = ENTITIES;
1358
- }
1359
- });
1360
-
1361
- // src/lib/xml-utils/uncapitalize.ts
1362
- function uncapitalize(str) {
1363
- return typeof str === "string" ? str.charAt(0).toLowerCase() + str.slice(1) : str;
1364
- }
1365
- function uncapitalizeKeys(object) {
1366
- if (Array.isArray(object)) {
1367
- return object.map((element) => uncapitalizeKeys(element));
1368
- }
1369
- if (object && typeof object === "object") {
1370
- const newObject = {};
1371
- for (const [key, value] of Object.entries(object)) {
1372
- newObject[uncapitalize(key)] = uncapitalizeKeys(value);
385
+ return i;
386
+ }
387
+ function getErrorObject(code, message, lineNumber) {
388
+ return {
389
+ err: {
390
+ code,
391
+ msg: message,
392
+ line: lineNumber.line || lineNumber,
393
+ col: lineNumber.col
394
+ }
395
+ };
396
+ }
397
+ function validateAttrName(attrName) {
398
+ return util.isName(attrName);
399
+ }
400
+ function validateTagName(tagname) {
401
+ return util.isName(tagname);
402
+ }
403
+ function getLineNumberForPosition(xmlData, index) {
404
+ const lines = xmlData.substring(0, index).split(/\r?\n/);
405
+ return {
406
+ line: lines.length,
407
+ col: lines[lines.length - 1].length + 1
408
+ };
409
+ }
410
+ function getPositionFromMatch(match) {
411
+ return match.startIndex + match[1].length;
1373
412
  }
1374
- return newObject;
1375
- }
1376
- return object;
1377
- }
1378
- var init_uncapitalize = __esm({
1379
- "src/lib/xml-utils/uncapitalize.ts"() {
1380
413
  }
1381
414
  });
1382
415
 
1383
- // ../../node_modules/fast-xml-parser/src/util.js
1384
- var require_util = __commonJS({
1385
- "../../node_modules/fast-xml-parser/src/util.js"(exports) {
1386
- "use strict";
1387
- var nameStartChar = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
1388
- var nameChar = nameStartChar + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
1389
- var nameRegexp = "[" + nameStartChar + "][" + nameChar + "]*";
1390
- var regexName = new RegExp("^" + nameRegexp + "$");
1391
- var getAllMatches = function(string, regex) {
1392
- const matches = [];
1393
- let match = regex.exec(string);
1394
- while (match) {
1395
- const allmatches = [];
1396
- allmatches.startIndex = regex.lastIndex - match[0].length;
1397
- const len = match.length;
1398
- for (let index = 0; index < len; index++) {
1399
- allmatches.push(match[index]);
1400
- }
1401
- matches.push(allmatches);
1402
- match = regex.exec(string);
416
+ // ../../node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js
417
+ var require_OptionsBuilder = __commonJS({
418
+ "../../node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js"(exports) {
419
+ var defaultOptions = {
420
+ preserveOrder: false,
421
+ attributeNamePrefix: "@_",
422
+ attributesGroupName: false,
423
+ textNodeName: "#text",
424
+ ignoreAttributes: true,
425
+ removeNSPrefix: false,
426
+ allowBooleanAttributes: false,
427
+ parseTagValue: true,
428
+ parseAttributeValue: false,
429
+ trimValues: true,
430
+ cdataPropName: false,
431
+ numberParseOptions: {
432
+ hex: true,
433
+ leadingZeros: true,
434
+ eNotation: true
435
+ },
436
+ tagValueProcessor: function(tagName, val2) {
437
+ return val2;
438
+ },
439
+ attributeValueProcessor: function(attrName, val2) {
440
+ return val2;
441
+ },
442
+ stopNodes: [],
443
+ alwaysCreateTextNode: false,
444
+ isArray: () => false,
445
+ commentPropName: false,
446
+ unpairedTags: [],
447
+ processEntities: true,
448
+ htmlEntities: false,
449
+ ignoreDeclaration: false,
450
+ ignorePiTags: false,
451
+ transformTagName: false,
452
+ transformAttributeName: false,
453
+ updateTag: function(tagName, jPath, attrs) {
454
+ return tagName;
1403
455
  }
1404
- return matches;
1405
456
  };
1406
- var isName = function(string) {
1407
- const match = regexName.exec(string);
1408
- return !(match === null || typeof match === "undefined");
1409
- };
1410
- exports.isExist = function(v) {
1411
- return typeof v !== "undefined";
1412
- };
1413
- exports.isEmptyObject = function(obj) {
1414
- return Object.keys(obj).length === 0;
457
+ var buildOptions = function(options) {
458
+ return Object.assign({}, defaultOptions, options);
1415
459
  };
1416
- exports.merge = function(target, a, arrayMode) {
1417
- if (a) {
1418
- const keys = Object.keys(a);
1419
- const len = keys.length;
1420
- for (let i = 0; i < len; i++) {
1421
- if (arrayMode === "strict") {
1422
- target[keys[i]] = [a[keys[i]]];
1423
- } else {
1424
- target[keys[i]] = a[keys[i]];
1425
- }
1426
- }
460
+ exports.buildOptions = buildOptions;
461
+ exports.defaultOptions = defaultOptions;
462
+ }
463
+ });
464
+
465
+ // ../../node_modules/fast-xml-parser/src/xmlparser/xmlNode.js
466
+ var require_xmlNode = __commonJS({
467
+ "../../node_modules/fast-xml-parser/src/xmlparser/xmlNode.js"(exports, module) {
468
+ "use strict";
469
+ var XmlNode = class {
470
+ constructor(tagname) {
471
+ this.tagname = tagname;
472
+ this.child = [];
473
+ this[":@"] = {};
1427
474
  }
1428
- };
1429
- exports.getValue = function(v) {
1430
- if (exports.isExist(v)) {
1431
- return v;
1432
- } else {
1433
- return "";
475
+ add(key, val2) {
476
+ if (key === "__proto__")
477
+ key = "#__proto__";
478
+ this.child.push({
479
+ [key]: val2
480
+ });
481
+ }
482
+ addChild(node) {
483
+ if (node.tagname === "__proto__")
484
+ node.tagname = "#__proto__";
485
+ if (node[":@"] && Object.keys(node[":@"]).length > 0) {
486
+ this.child.push({
487
+ [node.tagname]: node.child,
488
+ [":@"]: node[":@"]
489
+ });
490
+ } else {
491
+ this.child.push({
492
+ [node.tagname]: node.child
493
+ });
494
+ }
1434
495
  }
1435
496
  };
1436
- exports.isName = isName;
1437
- exports.getAllMatches = getAllMatches;
1438
- exports.nameRegexp = nameRegexp;
497
+ module.exports = XmlNode;
1439
498
  }
1440
499
  });
1441
500
 
1442
- // ../../node_modules/fast-xml-parser/src/validator.js
1443
- var require_validator = __commonJS({
1444
- "../../node_modules/fast-xml-parser/src/validator.js"(exports) {
1445
- "use strict";
501
+ // ../../node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js
502
+ var require_DocTypeReader = __commonJS({
503
+ "../../node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js"(exports, module) {
1446
504
  var util = require_util();
1447
- var defaultOptions = {
1448
- allowBooleanAttributes: false,
1449
- unpairedTags: []
1450
- };
1451
- exports.validate = function(xmlData, options) {
1452
- options = Object.assign({}, defaultOptions, options);
1453
- const tags = [];
1454
- let tagFound = false;
1455
- let reachedRoot = false;
1456
- if (xmlData[0] === "\uFEFF") {
1457
- xmlData = xmlData.substr(1);
1458
- }
1459
- for (let i = 0; i < xmlData.length; i++) {
1460
- if (xmlData[i] === "<" && xmlData[i + 1] === "?") {
1461
- i += 2;
1462
- i = readPI(xmlData, i);
1463
- if (i.err)
1464
- return i;
1465
- } else if (xmlData[i] === "<") {
1466
- let tagStartPos = i;
1467
- i++;
1468
- if (xmlData[i] === "!") {
1469
- i = readCommentAndCDATA(xmlData, i);
1470
- continue;
1471
- } else {
1472
- let closingTag = false;
1473
- if (xmlData[i] === "/") {
1474
- closingTag = true;
1475
- i++;
1476
- }
1477
- let tagName = "";
1478
- for (; i < xmlData.length && xmlData[i] !== ">" && xmlData[i] !== " " && xmlData[i] !== " " && xmlData[i] !== "\n" && xmlData[i] !== "\r"; i++) {
1479
- tagName += xmlData[i];
1480
- }
1481
- tagName = tagName.trim();
1482
- if (tagName[tagName.length - 1] === "/") {
1483
- tagName = tagName.substring(0, tagName.length - 1);
1484
- i--;
1485
- }
1486
- if (!validateTagName(tagName)) {
1487
- let msg;
1488
- if (tagName.trim().length === 0) {
1489
- msg = "Invalid space after '<'.";
1490
- } else {
1491
- msg = "Tag '" + tagName + "' is an invalid name.";
505
+ function readDocType(xmlData, i) {
506
+ const entities = {};
507
+ if (xmlData[i + 3] === "O" && xmlData[i + 4] === "C" && xmlData[i + 5] === "T" && xmlData[i + 6] === "Y" && xmlData[i + 7] === "P" && xmlData[i + 8] === "E") {
508
+ i = i + 9;
509
+ let angleBracketsCount = 1;
510
+ let hasBody = false, comment = false;
511
+ let exp = "";
512
+ for (; i < xmlData.length; i++) {
513
+ if (xmlData[i] === "<" && !comment) {
514
+ if (hasBody && isEntity(xmlData, i)) {
515
+ i += 7;
516
+ [entityName, val, i] = readEntityExp(xmlData, i + 1);
517
+ if (val.indexOf("&") === -1)
518
+ entities[validateEntityName(entityName)] = {
519
+ regx: RegExp(`&${entityName};`, "g"),
520
+ val
521
+ };
522
+ } else if (hasBody && isElement(xmlData, i))
523
+ i += 8;
524
+ else if (hasBody && isAttlist(xmlData, i))
525
+ i += 8;
526
+ else if (hasBody && isNotation(xmlData, i))
527
+ i += 9;
528
+ else if (isComment)
529
+ comment = true;
530
+ else
531
+ throw new Error("Invalid DOCTYPE");
532
+ angleBracketsCount++;
533
+ exp = "";
534
+ } else if (xmlData[i] === ">") {
535
+ if (comment) {
536
+ if (xmlData[i - 1] === "-" && xmlData[i - 2] === "-") {
537
+ comment = false;
538
+ angleBracketsCount--;
1492
539
  }
1493
- return getErrorObject("InvalidTag", msg, getLineNumberForPosition(xmlData, i));
540
+ } else {
541
+ angleBracketsCount--;
1494
542
  }
1495
- const result = readAttributeStr(xmlData, i);
1496
- if (result === false) {
1497
- return getErrorObject("InvalidAttr", "Attributes for '" + tagName + "' have open quote.", getLineNumberForPosition(xmlData, i));
543
+ if (angleBracketsCount === 0) {
544
+ break;
1498
545
  }
1499
- let attrStr = result.value;
1500
- i = result.index;
1501
- if (attrStr[attrStr.length - 1] === "/") {
1502
- const attrStrStart = i - attrStr.length;
1503
- attrStr = attrStr.substring(0, attrStr.length - 1);
1504
- const isValid = validateAttributeString(attrStr, options);
1505
- if (isValid === true) {
1506
- tagFound = true;
1507
- } else {
1508
- return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid.err.line));
1509
- }
1510
- } else if (closingTag) {
1511
- if (!result.tagClosed) {
1512
- return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' doesn't have proper closing.", getLineNumberForPosition(xmlData, i));
1513
- } else if (attrStr.trim().length > 0) {
1514
- return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' can't have attributes or invalid starting.", getLineNumberForPosition(xmlData, tagStartPos));
1515
- } else {
1516
- const otg = tags.pop();
1517
- if (tagName !== otg.tagName) {
1518
- let openPos = getLineNumberForPosition(xmlData, otg.tagStartPos);
1519
- return getErrorObject("InvalidTag", "Expected closing tag '" + otg.tagName + "' (opened in line " + openPos.line + ", col " + openPos.col + ") instead of closing tag '" + tagName + "'.", getLineNumberForPosition(xmlData, tagStartPos));
1520
- }
1521
- if (tags.length == 0) {
1522
- reachedRoot = true;
1523
- }
1524
- }
1525
- } else {
1526
- const isValid = validateAttributeString(attrStr, options);
1527
- if (isValid !== true) {
1528
- return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, i - attrStr.length + isValid.err.line));
1529
- }
1530
- if (reachedRoot === true) {
1531
- return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(xmlData, i));
1532
- } else if (options.unpairedTags.indexOf(tagName) !== -1) {
1533
- } else {
1534
- tags.push({ tagName, tagStartPos });
1535
- }
1536
- tagFound = true;
1537
- }
1538
- for (i++; i < xmlData.length; i++) {
1539
- if (xmlData[i] === "<") {
1540
- if (xmlData[i + 1] === "!") {
1541
- i++;
1542
- i = readCommentAndCDATA(xmlData, i);
1543
- continue;
1544
- } else if (xmlData[i + 1] === "?") {
1545
- i = readPI(xmlData, ++i);
1546
- if (i.err)
1547
- return i;
1548
- } else {
1549
- break;
1550
- }
1551
- } else if (xmlData[i] === "&") {
1552
- const afterAmp = validateAmpersand(xmlData, i);
1553
- if (afterAmp == -1)
1554
- return getErrorObject("InvalidChar", "char '&' is not expected.", getLineNumberForPosition(xmlData, i));
1555
- i = afterAmp;
1556
- } else {
1557
- if (reachedRoot === true && !isWhiteSpace(xmlData[i])) {
1558
- return getErrorObject("InvalidXml", "Extra text at the end", getLineNumberForPosition(xmlData, i));
1559
- }
1560
- }
1561
- }
1562
- if (xmlData[i] === "<") {
1563
- i--;
1564
- }
1565
- }
1566
- } else {
1567
- if (isWhiteSpace(xmlData[i])) {
1568
- continue;
1569
- }
1570
- return getErrorObject("InvalidChar", "char '" + xmlData[i] + "' is not expected.", getLineNumberForPosition(xmlData, i));
1571
- }
1572
- }
1573
- if (!tagFound) {
1574
- return getErrorObject("InvalidXml", "Start tag expected.", 1);
1575
- } else if (tags.length == 1) {
1576
- return getErrorObject("InvalidTag", "Unclosed tag '" + tags[0].tagName + "'.", getLineNumberForPosition(xmlData, tags[0].tagStartPos));
1577
- } else if (tags.length > 0) {
1578
- return getErrorObject("InvalidXml", "Invalid '" + JSON.stringify(tags.map((t) => t.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
1579
- }
1580
- return true;
1581
- };
1582
- function isWhiteSpace(char) {
1583
- return char === " " || char === " " || char === "\n" || char === "\r";
1584
- }
1585
- function readPI(xmlData, i) {
1586
- const start = i;
1587
- for (; i < xmlData.length; i++) {
1588
- if (xmlData[i] == "?" || xmlData[i] == " ") {
1589
- const tagname = xmlData.substr(start, i - start);
1590
- if (i > 5 && tagname === "xml") {
1591
- return getErrorObject("InvalidXml", "XML declaration allowed only at the start of the document.", getLineNumberForPosition(xmlData, i));
1592
- } else if (xmlData[i] == "?" && xmlData[i + 1] == ">") {
1593
- i++;
1594
- break;
546
+ } else if (xmlData[i] === "[") {
547
+ hasBody = true;
1595
548
  } else {
1596
- continue;
1597
- }
1598
- }
1599
- }
1600
- return i;
1601
- }
1602
- function readCommentAndCDATA(xmlData, i) {
1603
- if (xmlData.length > i + 5 && xmlData[i + 1] === "-" && xmlData[i + 2] === "-") {
1604
- for (i += 3; i < xmlData.length; i++) {
1605
- if (xmlData[i] === "-" && xmlData[i + 1] === "-" && xmlData[i + 2] === ">") {
1606
- i += 2;
1607
- break;
1608
- }
1609
- }
1610
- } else if (xmlData.length > i + 8 && xmlData[i + 1] === "D" && xmlData[i + 2] === "O" && xmlData[i + 3] === "C" && xmlData[i + 4] === "T" && xmlData[i + 5] === "Y" && xmlData[i + 6] === "P" && xmlData[i + 7] === "E") {
1611
- let angleBracketsCount = 1;
1612
- for (i += 8; i < xmlData.length; i++) {
1613
- if (xmlData[i] === "<") {
1614
- angleBracketsCount++;
1615
- } else if (xmlData[i] === ">") {
1616
- angleBracketsCount--;
1617
- if (angleBracketsCount === 0) {
1618
- break;
1619
- }
1620
- }
1621
- }
1622
- } else if (xmlData.length > i + 9 && xmlData[i + 1] === "[" && xmlData[i + 2] === "C" && xmlData[i + 3] === "D" && xmlData[i + 4] === "A" && xmlData[i + 5] === "T" && xmlData[i + 6] === "A" && xmlData[i + 7] === "[") {
1623
- for (i += 8; i < xmlData.length; i++) {
1624
- if (xmlData[i] === "]" && xmlData[i + 1] === "]" && xmlData[i + 2] === ">") {
1625
- i += 2;
1626
- break;
549
+ exp += xmlData[i];
1627
550
  }
1628
551
  }
1629
- }
1630
- return i;
1631
- }
1632
- var doubleQuote = '"';
1633
- var singleQuote = "'";
1634
- function readAttributeStr(xmlData, i) {
1635
- let attrStr = "";
1636
- let startChar = "";
1637
- let tagClosed = false;
1638
- for (; i < xmlData.length; i++) {
1639
- if (xmlData[i] === doubleQuote || xmlData[i] === singleQuote) {
1640
- if (startChar === "") {
1641
- startChar = xmlData[i];
1642
- } else if (startChar !== xmlData[i]) {
1643
- } else {
1644
- startChar = "";
1645
- }
1646
- } else if (xmlData[i] === ">") {
1647
- if (startChar === "") {
1648
- tagClosed = true;
1649
- break;
1650
- }
552
+ if (angleBracketsCount !== 0) {
553
+ throw new Error(`Unclosed DOCTYPE`);
1651
554
  }
1652
- attrStr += xmlData[i];
1653
- }
1654
- if (startChar !== "") {
1655
- return false;
555
+ } else {
556
+ throw new Error(`Invalid Tag instead of DOCTYPE`);
1656
557
  }
1657
558
  return {
1658
- value: attrStr,
1659
- index: i,
1660
- tagClosed
559
+ entities,
560
+ i
1661
561
  };
1662
562
  }
1663
- var validAttrStrRegxp = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
1664
- function validateAttributeString(attrStr, options) {
1665
- const matches = util.getAllMatches(attrStr, validAttrStrRegxp);
1666
- const attrNames = {};
1667
- for (let i = 0; i < matches.length; i++) {
1668
- if (matches[i][1].length === 0) {
1669
- return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' has no space in starting.", getPositionFromMatch(matches[i]));
1670
- } else if (matches[i][3] !== void 0 && matches[i][4] === void 0) {
1671
- return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' is without value.", getPositionFromMatch(matches[i]));
1672
- } else if (matches[i][3] === void 0 && !options.allowBooleanAttributes) {
1673
- return getErrorObject("InvalidAttr", "boolean attribute '" + matches[i][2] + "' is not allowed.", getPositionFromMatch(matches[i]));
1674
- }
1675
- const attrName = matches[i][2];
1676
- if (!validateAttrName(attrName)) {
1677
- return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is an invalid name.", getPositionFromMatch(matches[i]));
1678
- }
1679
- if (!attrNames.hasOwnProperty(attrName)) {
1680
- attrNames[attrName] = 1;
1681
- } else {
1682
- return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is repeated.", getPositionFromMatch(matches[i]));
1683
- }
1684
- }
1685
- return true;
1686
- }
1687
- function validateNumberAmpersand(xmlData, i) {
1688
- let re = /\d/;
1689
- if (xmlData[i] === "x") {
1690
- i++;
1691
- re = /[\da-fA-F]/;
563
+ function readEntityExp(xmlData, i) {
564
+ let entityName2 = "";
565
+ for (; i < xmlData.length && xmlData[i] !== "'" && xmlData[i] !== '"'; i++) {
566
+ entityName2 += xmlData[i];
1692
567
  }
1693
- for (; i < xmlData.length; i++) {
1694
- if (xmlData[i] === ";")
1695
- return i;
1696
- if (!xmlData[i].match(re))
1697
- break;
568
+ entityName2 = entityName2.trim();
569
+ if (entityName2.indexOf(" ") !== -1)
570
+ throw new Error("External entites are not supported");
571
+ const startChar = xmlData[i++];
572
+ let val2 = "";
573
+ for (; i < xmlData.length && xmlData[i] !== startChar; i++) {
574
+ val2 += xmlData[i];
1698
575
  }
1699
- return -1;
576
+ return [entityName2, val2, i];
1700
577
  }
1701
- function validateAmpersand(xmlData, i) {
1702
- i++;
1703
- if (xmlData[i] === ";")
1704
- return -1;
1705
- if (xmlData[i] === "#") {
1706
- i++;
1707
- return validateNumberAmpersand(xmlData, i);
1708
- }
1709
- let count = 0;
1710
- for (; i < xmlData.length; i++, count++) {
1711
- if (xmlData[i].match(/\w/) && count < 20)
1712
- continue;
1713
- if (xmlData[i] === ";")
1714
- break;
1715
- return -1;
1716
- }
1717
- return i;
578
+ function isComment(xmlData, i) {
579
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "-" && xmlData[i + 3] === "-")
580
+ return true;
581
+ return false;
1718
582
  }
1719
- function getErrorObject(code, message, lineNumber) {
1720
- return {
1721
- err: {
1722
- code,
1723
- msg: message,
1724
- line: lineNumber.line || lineNumber,
1725
- col: lineNumber.col
1726
- }
1727
- };
583
+ function isEntity(xmlData, i) {
584
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "N" && xmlData[i + 4] === "T" && xmlData[i + 5] === "I" && xmlData[i + 6] === "T" && xmlData[i + 7] === "Y")
585
+ return true;
586
+ return false;
1728
587
  }
1729
- function validateAttrName(attrName) {
1730
- return util.isName(attrName);
588
+ function isElement(xmlData, i) {
589
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "L" && xmlData[i + 4] === "E" && xmlData[i + 5] === "M" && xmlData[i + 6] === "E" && xmlData[i + 7] === "N" && xmlData[i + 8] === "T")
590
+ return true;
591
+ return false;
1731
592
  }
1732
- function validateTagName(tagname) {
1733
- return util.isName(tagname);
593
+ function isAttlist(xmlData, i) {
594
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "A" && xmlData[i + 3] === "T" && xmlData[i + 4] === "T" && xmlData[i + 5] === "L" && xmlData[i + 6] === "I" && xmlData[i + 7] === "S" && xmlData[i + 8] === "T")
595
+ return true;
596
+ return false;
1734
597
  }
1735
- function getLineNumberForPosition(xmlData, index) {
1736
- const lines = xmlData.substring(0, index).split(/\r?\n/);
1737
- return {
1738
- line: lines.length,
1739
- col: lines[lines.length - 1].length + 1
1740
- };
598
+ function isNotation(xmlData, i) {
599
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "N" && xmlData[i + 3] === "O" && xmlData[i + 4] === "T" && xmlData[i + 5] === "A" && xmlData[i + 6] === "T" && xmlData[i + 7] === "I" && xmlData[i + 8] === "O" && xmlData[i + 9] === "N")
600
+ return true;
601
+ return false;
1741
602
  }
1742
- function getPositionFromMatch(match) {
1743
- return match.startIndex + match[1].length;
603
+ function validateEntityName(name) {
604
+ if (util.isName(name))
605
+ return name;
606
+ else
607
+ throw new Error(`Invalid entity name ${name}`);
1744
608
  }
1745
- }
1746
- });
1747
-
1748
- // ../../node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js
1749
- var require_OptionsBuilder = __commonJS({
1750
- "../../node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js"(exports) {
1751
- var defaultOptions = {
1752
- preserveOrder: false,
1753
- attributeNamePrefix: "@_",
1754
- attributesGroupName: false,
1755
- textNodeName: "#text",
1756
- ignoreAttributes: true,
1757
- removeNSPrefix: false,
1758
- allowBooleanAttributes: false,
1759
- parseTagValue: true,
1760
- parseAttributeValue: false,
1761
- trimValues: true,
1762
- cdataPropName: false,
1763
- numberParseOptions: {
1764
- hex: true,
1765
- leadingZeros: true,
1766
- eNotation: true
1767
- },
1768
- tagValueProcessor: function(tagName, val2) {
1769
- return val2;
1770
- },
1771
- attributeValueProcessor: function(attrName, val2) {
1772
- return val2;
1773
- },
1774
- stopNodes: [],
1775
- alwaysCreateTextNode: false,
1776
- isArray: () => false,
1777
- commentPropName: false,
1778
- unpairedTags: [],
1779
- processEntities: true,
1780
- htmlEntities: false,
1781
- ignoreDeclaration: false,
1782
- ignorePiTags: false,
1783
- transformTagName: false,
1784
- transformAttributeName: false,
1785
- updateTag: function(tagName, jPath, attrs) {
1786
- return tagName;
1787
- }
1788
- };
1789
- var buildOptions = function(options) {
1790
- return Object.assign({}, defaultOptions, options);
1791
- };
1792
- exports.buildOptions = buildOptions;
1793
- exports.defaultOptions = defaultOptions;
1794
- }
1795
- });
1796
-
1797
- // ../../node_modules/fast-xml-parser/src/xmlparser/xmlNode.js
1798
- var require_xmlNode = __commonJS({
1799
- "../../node_modules/fast-xml-parser/src/xmlparser/xmlNode.js"(exports, module) {
1800
- "use strict";
1801
- var XmlNode = class {
1802
- constructor(tagname) {
1803
- this.tagname = tagname;
1804
- this.child = [];
1805
- this[":@"] = {};
1806
- }
1807
- add(key, val2) {
1808
- if (key === "__proto__")
1809
- key = "#__proto__";
1810
- this.child.push({ [key]: val2 });
1811
- }
1812
- addChild(node) {
1813
- if (node.tagname === "__proto__")
1814
- node.tagname = "#__proto__";
1815
- if (node[":@"] && Object.keys(node[":@"]).length > 0) {
1816
- this.child.push({ [node.tagname]: node.child, [":@"]: node[":@"] });
1817
- } else {
1818
- this.child.push({ [node.tagname]: node.child });
1819
- }
1820
- }
1821
- };
1822
- module.exports = XmlNode;
1823
- }
1824
- });
1825
-
1826
- // ../../node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js
1827
- var require_DocTypeReader = __commonJS({
1828
- "../../node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js"(exports, module) {
1829
- var util = require_util();
1830
- function readDocType(xmlData, i) {
1831
- const entities = {};
1832
- if (xmlData[i + 3] === "O" && xmlData[i + 4] === "C" && xmlData[i + 5] === "T" && xmlData[i + 6] === "Y" && xmlData[i + 7] === "P" && xmlData[i + 8] === "E") {
1833
- i = i + 9;
1834
- let angleBracketsCount = 1;
1835
- let hasBody = false, comment = false;
1836
- let exp = "";
1837
- for (; i < xmlData.length; i++) {
1838
- if (xmlData[i] === "<" && !comment) {
1839
- if (hasBody && isEntity(xmlData, i)) {
1840
- i += 7;
1841
- [entityName, val, i] = readEntityExp(xmlData, i + 1);
1842
- if (val.indexOf("&") === -1)
1843
- entities[validateEntityName(entityName)] = {
1844
- regx: RegExp(`&${entityName};`, "g"),
1845
- val
1846
- };
1847
- } else if (hasBody && isElement(xmlData, i))
1848
- i += 8;
1849
- else if (hasBody && isAttlist(xmlData, i))
1850
- i += 8;
1851
- else if (hasBody && isNotation(xmlData, i))
1852
- i += 9;
1853
- else if (isComment)
1854
- comment = true;
1855
- else
1856
- throw new Error("Invalid DOCTYPE");
1857
- angleBracketsCount++;
1858
- exp = "";
1859
- } else if (xmlData[i] === ">") {
1860
- if (comment) {
1861
- if (xmlData[i - 1] === "-" && xmlData[i - 2] === "-") {
1862
- comment = false;
1863
- angleBracketsCount--;
1864
- }
1865
- } else {
1866
- angleBracketsCount--;
1867
- }
1868
- if (angleBracketsCount === 0) {
1869
- break;
1870
- }
1871
- } else if (xmlData[i] === "[") {
1872
- hasBody = true;
1873
- } else {
1874
- exp += xmlData[i];
1875
- }
1876
- }
1877
- if (angleBracketsCount !== 0) {
1878
- throw new Error(`Unclosed DOCTYPE`);
1879
- }
1880
- } else {
1881
- throw new Error(`Invalid Tag instead of DOCTYPE`);
1882
- }
1883
- return { entities, i };
1884
- }
1885
- function readEntityExp(xmlData, i) {
1886
- let entityName2 = "";
1887
- for (; i < xmlData.length && (xmlData[i] !== "'" && xmlData[i] !== '"'); i++) {
1888
- entityName2 += xmlData[i];
1889
- }
1890
- entityName2 = entityName2.trim();
1891
- if (entityName2.indexOf(" ") !== -1)
1892
- throw new Error("External entites are not supported");
1893
- const startChar = xmlData[i++];
1894
- let val2 = "";
1895
- for (; i < xmlData.length && xmlData[i] !== startChar; i++) {
1896
- val2 += xmlData[i];
1897
- }
1898
- return [entityName2, val2, i];
1899
- }
1900
- function isComment(xmlData, i) {
1901
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "-" && xmlData[i + 3] === "-")
1902
- return true;
1903
- return false;
1904
- }
1905
- function isEntity(xmlData, i) {
1906
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "N" && xmlData[i + 4] === "T" && xmlData[i + 5] === "I" && xmlData[i + 6] === "T" && xmlData[i + 7] === "Y")
1907
- return true;
1908
- return false;
1909
- }
1910
- function isElement(xmlData, i) {
1911
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "L" && xmlData[i + 4] === "E" && xmlData[i + 5] === "M" && xmlData[i + 6] === "E" && xmlData[i + 7] === "N" && xmlData[i + 8] === "T")
1912
- return true;
1913
- return false;
1914
- }
1915
- function isAttlist(xmlData, i) {
1916
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "A" && xmlData[i + 3] === "T" && xmlData[i + 4] === "T" && xmlData[i + 5] === "L" && xmlData[i + 6] === "I" && xmlData[i + 7] === "S" && xmlData[i + 8] === "T")
1917
- return true;
1918
- return false;
1919
- }
1920
- function isNotation(xmlData, i) {
1921
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "N" && xmlData[i + 3] === "O" && xmlData[i + 4] === "T" && xmlData[i + 5] === "A" && xmlData[i + 6] === "T" && xmlData[i + 7] === "I" && xmlData[i + 8] === "O" && xmlData[i + 9] === "N")
1922
- return true;
1923
- return false;
1924
- }
1925
- function validateEntityName(name) {
1926
- if (util.isName(name))
1927
- return name;
1928
- else
1929
- throw new Error(`Invalid entity name ${name}`);
1930
- }
1931
- module.exports = readDocType;
609
+ module.exports = readDocType;
1932
610
  }
1933
611
  });
1934
612
 
@@ -1948,6 +626,7 @@ Actual: ${this.attribValue}`);
1948
626
  leadingZeros: true,
1949
627
  decimalPoint: ".",
1950
628
  eNotation: true
629
+ //skipLike: /regex/
1951
630
  };
1952
631
  function toNumber(str, options = {}) {
1953
632
  options = Object.assign({}, consider, options);
@@ -2044,21 +723,60 @@ Actual: ${this.attribValue}`);
2044
723
  this.tagsNodeStack = [];
2045
724
  this.docTypeEntities = {};
2046
725
  this.lastEntities = {
2047
- "apos": { regex: /&(apos|#39|#x27);/g, val: "'" },
2048
- "gt": { regex: /&(gt|#62|#x3E);/g, val: ">" },
2049
- "lt": { regex: /&(lt|#60|#x3C);/g, val: "<" },
2050
- "quot": { regex: /&(quot|#34|#x22);/g, val: '"' }
726
+ "apos": {
727
+ regex: /&(apos|#39|#x27);/g,
728
+ val: "'"
729
+ },
730
+ "gt": {
731
+ regex: /&(gt|#62|#x3E);/g,
732
+ val: ">"
733
+ },
734
+ "lt": {
735
+ regex: /&(lt|#60|#x3C);/g,
736
+ val: "<"
737
+ },
738
+ "quot": {
739
+ regex: /&(quot|#34|#x22);/g,
740
+ val: '"'
741
+ }
742
+ };
743
+ this.ampEntity = {
744
+ regex: /&(amp|#38|#x26);/g,
745
+ val: "&"
2051
746
  };
2052
- this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" };
2053
747
  this.htmlEntities = {
2054
- "space": { regex: /&(nbsp|#160);/g, val: " " },
2055
- "cent": { regex: /&(cent|#162);/g, val: "\xA2" },
2056
- "pound": { regex: /&(pound|#163);/g, val: "\xA3" },
2057
- "yen": { regex: /&(yen|#165);/g, val: "\xA5" },
2058
- "euro": { regex: /&(euro|#8364);/g, val: "\u20AC" },
2059
- "copyright": { regex: /&(copy|#169);/g, val: "\xA9" },
2060
- "reg": { regex: /&(reg|#174);/g, val: "\xAE" },
2061
- "inr": { regex: /&(inr|#8377);/g, val: "\u20B9" }
748
+ "space": {
749
+ regex: /&(nbsp|#160);/g,
750
+ val: " "
751
+ },
752
+ "cent": {
753
+ regex: /&(cent|#162);/g,
754
+ val: "\xA2"
755
+ },
756
+ "pound": {
757
+ regex: /&(pound|#163);/g,
758
+ val: "\xA3"
759
+ },
760
+ "yen": {
761
+ regex: /&(yen|#165);/g,
762
+ val: "\xA5"
763
+ },
764
+ "euro": {
765
+ regex: /&(euro|#8364);/g,
766
+ val: "\u20AC"
767
+ },
768
+ "copyright": {
769
+ regex: /&(copy|#169);/g,
770
+ val: "\xA9"
771
+ },
772
+ "reg": {
773
+ regex: /&(reg|#174);/g,
774
+ val: "\xAE"
775
+ },
776
+ "inr": {
777
+ regex: /&(inr|#8377);/g,
778
+ val: "\u20B9"
779
+ }
2062
780
  };
2063
781
  this.addExternalEntities = addExternalEntities;
2064
782
  this.parseXml = parseXml;
@@ -2225,7 +943,9 @@ Actual: ${this.attribValue}`);
2225
943
  if (this.options.commentPropName) {
2226
944
  const comment = xmlData.substring(i + 4, endIndex - 2);
2227
945
  textData = this.saveTextToParentTag(textData, currentNode, jPath);
2228
- currentNode.add(this.options.commentPropName, [{ [this.options.textNodeName]: comment }]);
946
+ currentNode.add(this.options.commentPropName, [{
947
+ [this.options.textNodeName]: comment
948
+ }]);
2229
949
  }
2230
950
  i = endIndex;
2231
951
  } else if (xmlData.substr(i + 1, 2) === "!D") {
@@ -2237,7 +957,9 @@ Actual: ${this.attribValue}`);
2237
957
  const tagExp = xmlData.substring(i + 9, closeIndex);
2238
958
  textData = this.saveTextToParentTag(textData, currentNode, jPath);
2239
959
  if (this.options.cdataPropName) {
2240
- currentNode.add(this.options.cdataPropName, [{ [this.options.textNodeName]: tagExp }]);
960
+ currentNode.add(this.options.cdataPropName, [{
961
+ [this.options.textNodeName]: tagExp
962
+ }]);
2241
963
  } else {
2242
964
  let val2 = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true);
2243
965
  if (val2 == void 0)
@@ -2584,7 +1306,9 @@ Actual: ${this.attribValue}`);
2584
1306
  }
2585
1307
  }
2586
1308
  function isLeafTag(obj, options) {
2587
- const { textNodeName } = options;
1309
+ const {
1310
+ textNodeName
1311
+ } = options;
2588
1312
  const propCount = Object.keys(obj).length;
2589
1313
  if (propCount === 0) {
2590
1314
  return true;
@@ -2601,9 +1325,13 @@ Actual: ${this.attribValue}`);
2601
1325
  // ../../node_modules/fast-xml-parser/src/xmlparser/XMLParser.js
2602
1326
  var require_XMLParser = __commonJS({
2603
1327
  "../../node_modules/fast-xml-parser/src/xmlparser/XMLParser.js"(exports, module) {
2604
- var { buildOptions } = require_OptionsBuilder();
1328
+ var {
1329
+ buildOptions
1330
+ } = require_OptionsBuilder();
2605
1331
  var OrderedObjParser = require_OrderedObjParser();
2606
- var { prettify } = require_node2json();
1332
+ var {
1333
+ prettify
1334
+ } = require_node2json();
2607
1335
  var validator = require_validator();
2608
1336
  var XMLParser = class {
2609
1337
  constructor(options) {
@@ -2802,13 +1530,22 @@ Actual: ${this.attribValue}`);
2802
1530
  preserveOrder: false,
2803
1531
  commentPropName: false,
2804
1532
  unpairedTags: [],
2805
- entities: [
2806
- { regex: new RegExp("&", "g"), val: "&amp;" },
2807
- { regex: new RegExp(">", "g"), val: "&gt;" },
2808
- { regex: new RegExp("<", "g"), val: "&lt;" },
2809
- { regex: new RegExp("'", "g"), val: "&apos;" },
2810
- { regex: new RegExp('"', "g"), val: "&quot;" }
2811
- ],
1533
+ entities: [{
1534
+ regex: new RegExp("&", "g"),
1535
+ val: "&amp;"
1536
+ }, {
1537
+ regex: new RegExp(">", "g"),
1538
+ val: "&gt;"
1539
+ }, {
1540
+ regex: new RegExp("<", "g"),
1541
+ val: "&lt;"
1542
+ }, {
1543
+ regex: new RegExp("'", "g"),
1544
+ val: "&apos;"
1545
+ }, {
1546
+ regex: new RegExp('"', "g"),
1547
+ val: "&quot;"
1548
+ }],
2812
1549
  processEntities: true,
2813
1550
  stopNodes: [],
2814
1551
  oneListGroup: false
@@ -2887,137 +1624,1478 @@ Actual: ${this.attribValue}`);
2887
1624
  if (this.options.oneListGroup) {
2888
1625
  listTagVal += this.j2x(item, level + 1).val;
2889
1626
  } else {
2890
- listTagVal += this.processTextOrObjNode(item, key, level);
1627
+ listTagVal += this.processTextOrObjNode(item, key, level);
1628
+ }
1629
+ } else {
1630
+ listTagVal += this.buildTextValNode(item, key, "", level);
1631
+ }
1632
+ }
1633
+ if (this.options.oneListGroup) {
1634
+ listTagVal = this.buildObjectNode(listTagVal, key, "", level);
1635
+ }
1636
+ val2 += listTagVal;
1637
+ } else {
1638
+ if (this.options.attributesGroupName && key === this.options.attributesGroupName) {
1639
+ const Ks = Object.keys(jObj[key]);
1640
+ const L = Ks.length;
1641
+ for (let j = 0; j < L; j++) {
1642
+ attrStr += this.buildAttrPairStr(Ks[j], "" + jObj[key][Ks[j]]);
1643
+ }
1644
+ } else {
1645
+ val2 += this.processTextOrObjNode(jObj[key], key, level);
1646
+ }
1647
+ }
1648
+ }
1649
+ return {
1650
+ attrStr,
1651
+ val: val2
1652
+ };
1653
+ };
1654
+ Builder.prototype.buildAttrPairStr = function(attrName, val2) {
1655
+ val2 = this.options.attributeValueProcessor(attrName, "" + val2);
1656
+ val2 = this.replaceEntitiesValue(val2);
1657
+ if (this.options.suppressBooleanAttributes && val2 === "true") {
1658
+ return " " + attrName;
1659
+ } else
1660
+ return " " + attrName + '="' + val2 + '"';
1661
+ };
1662
+ function processTextOrObjNode(object, key, level) {
1663
+ const result = this.j2x(object, level + 1);
1664
+ if (object[this.options.textNodeName] !== void 0 && Object.keys(object).length === 1) {
1665
+ return this.buildTextValNode(object[this.options.textNodeName], key, result.attrStr, level);
1666
+ } else {
1667
+ return this.buildObjectNode(result.val, key, result.attrStr, level);
1668
+ }
1669
+ }
1670
+ Builder.prototype.buildObjectNode = function(val2, key, attrStr, level) {
1671
+ if (val2 === "") {
1672
+ if (key[0] === "?")
1673
+ return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
1674
+ else {
1675
+ return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
1676
+ }
1677
+ } else {
1678
+ let tagEndExp = "</" + key + this.tagEndChar;
1679
+ let piClosingChar = "";
1680
+ if (key[0] === "?") {
1681
+ piClosingChar = "?";
1682
+ tagEndExp = "";
1683
+ }
1684
+ if (attrStr && val2.indexOf("<") === -1) {
1685
+ return this.indentate(level) + "<" + key + attrStr + piClosingChar + ">" + val2 + tagEndExp;
1686
+ } else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {
1687
+ return this.indentate(level) + `<!--${val2}-->` + this.newLine;
1688
+ } else {
1689
+ return this.indentate(level) + "<" + key + attrStr + piClosingChar + this.tagEndChar + val2 + this.indentate(level) + tagEndExp;
1690
+ }
1691
+ }
1692
+ };
1693
+ Builder.prototype.closeTag = function(key) {
1694
+ let closeTag = "";
1695
+ if (this.options.unpairedTags.indexOf(key) !== -1) {
1696
+ if (!this.options.suppressUnpairedNode)
1697
+ closeTag = "/";
1698
+ } else if (this.options.suppressEmptyNode) {
1699
+ closeTag = "/";
1700
+ } else {
1701
+ closeTag = `></${key}`;
1702
+ }
1703
+ return closeTag;
1704
+ };
1705
+ Builder.prototype.buildTextValNode = function(val2, key, attrStr, level) {
1706
+ if (this.options.cdataPropName !== false && key === this.options.cdataPropName) {
1707
+ return this.indentate(level) + `<![CDATA[${val2}]]>` + this.newLine;
1708
+ } else if (this.options.commentPropName !== false && key === this.options.commentPropName) {
1709
+ return this.indentate(level) + `<!--${val2}-->` + this.newLine;
1710
+ } else if (key[0] === "?") {
1711
+ return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
1712
+ } else {
1713
+ let textValue = this.options.tagValueProcessor(key, val2);
1714
+ textValue = this.replaceEntitiesValue(textValue);
1715
+ if (textValue === "") {
1716
+ return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
1717
+ } else {
1718
+ return this.indentate(level) + "<" + key + attrStr + ">" + textValue + "</" + key + this.tagEndChar;
1719
+ }
1720
+ }
1721
+ };
1722
+ Builder.prototype.replaceEntitiesValue = function(textValue) {
1723
+ if (textValue && textValue.length > 0 && this.options.processEntities) {
1724
+ for (let i = 0; i < this.options.entities.length; i++) {
1725
+ const entity = this.options.entities[i];
1726
+ textValue = textValue.replace(entity.regex, entity.val);
1727
+ }
1728
+ }
1729
+ return textValue;
1730
+ };
1731
+ function indentate(level) {
1732
+ return this.options.indentBy.repeat(level);
1733
+ }
1734
+ function isAttribute(name) {
1735
+ if (name.startsWith(this.options.attributeNamePrefix)) {
1736
+ return name.substr(this.attrPrefixLen);
1737
+ } else {
1738
+ return false;
1739
+ }
1740
+ }
1741
+ module.exports = Builder;
1742
+ }
1743
+ });
1744
+
1745
+ // ../../node_modules/fast-xml-parser/src/fxp.js
1746
+ var require_fxp = __commonJS({
1747
+ "../../node_modules/fast-xml-parser/src/fxp.js"(exports, module) {
1748
+ "use strict";
1749
+ var validator = require_validator();
1750
+ var XMLParser = require_XMLParser();
1751
+ var XMLBuilder = require_json2xml();
1752
+ module.exports = {
1753
+ XMLParser,
1754
+ XMLValidator: validator,
1755
+ XMLBuilder
1756
+ };
1757
+ }
1758
+ });
1759
+
1760
+ // src/index.ts
1761
+ var src_exports = {};
1762
+ __export(src_exports, {
1763
+ HTMLLoader: () => HTMLLoader,
1764
+ SAXParser: () => SAXParser,
1765
+ XMLLoader: () => XMLLoader,
1766
+ _uncapitalize: () => uncapitalize,
1767
+ _uncapitalizeKeys: () => uncapitalizeKeys,
1768
+ convertXMLFieldToArrayInPlace: () => convertXMLFieldToArrayInPlace,
1769
+ convertXMLValueToArray: () => convertXMLValueToArray
1770
+ });
1771
+
1772
+ // src/sax-ts/sax.ts
1773
+ var DEFAULT_SAX_EVENTS = {
1774
+ ontext: () => {
1775
+ },
1776
+ onprocessinginstruction: () => {
1777
+ },
1778
+ onsgmldeclaration: () => {
1779
+ },
1780
+ ondoctype: () => {
1781
+ },
1782
+ oncomment: () => {
1783
+ },
1784
+ onopentagstart: () => {
1785
+ },
1786
+ onattribute: () => {
1787
+ },
1788
+ onopentag: () => {
1789
+ },
1790
+ onclosetag: () => {
1791
+ },
1792
+ onopencdata: () => {
1793
+ },
1794
+ oncdata: () => {
1795
+ },
1796
+ onclosecdata: () => {
1797
+ },
1798
+ onerror: () => {
1799
+ },
1800
+ onend: () => {
1801
+ },
1802
+ onready: () => {
1803
+ },
1804
+ onscript: () => {
1805
+ },
1806
+ onopennamespace: () => {
1807
+ },
1808
+ onclosenamespace: () => {
1809
+ }
1810
+ };
1811
+ var DEFAULT_SAX_PARSER_OPTIONS = {
1812
+ ...DEFAULT_SAX_EVENTS,
1813
+ strict: false,
1814
+ MAX_BUFFER_LENGTH: 64 * 1024,
1815
+ lowercase: false,
1816
+ lowercasetags: false,
1817
+ noscript: false,
1818
+ strictEntities: false,
1819
+ xmlns: void 0,
1820
+ position: void 0,
1821
+ trim: void 0,
1822
+ normalize: void 0
1823
+ };
1824
+ var EVENTS = ["text", "processinginstruction", "sgmldeclaration", "doctype", "comment", "opentagstart", "attribute", "opentag", "closetag", "opencdata", "cdata", "closecdata", "error", "end", "ready", "script", "opennamespace", "closenamespace"];
1825
+ var BUFFERS = ["comment", "sgmlDecl", "textNode", "tagName", "doctype", "procInstName", "procInstBody", "entity", "attribName", "attribValue", "cdata", "script"];
1826
+ var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
1827
+ var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
1828
+ var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
1829
+ var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
1830
+ var ENTITIES = {
1831
+ amp: "&",
1832
+ gt: ">",
1833
+ lt: "<",
1834
+ quot: '"',
1835
+ apos: "'",
1836
+ AElig: 198,
1837
+ Aacute: 193,
1838
+ Acirc: 194,
1839
+ Agrave: 192,
1840
+ Aring: 197,
1841
+ Atilde: 195,
1842
+ Auml: 196,
1843
+ Ccedil: 199,
1844
+ ETH: 208,
1845
+ Eacute: 201,
1846
+ Ecirc: 202,
1847
+ Egrave: 200,
1848
+ Euml: 203,
1849
+ Iacute: 205,
1850
+ Icirc: 206,
1851
+ Igrave: 204,
1852
+ Iuml: 207,
1853
+ Ntilde: 209,
1854
+ Oacute: 211,
1855
+ Ocirc: 212,
1856
+ Ograve: 210,
1857
+ Oslash: 216,
1858
+ Otilde: 213,
1859
+ Ouml: 214,
1860
+ THORN: 222,
1861
+ Uacute: 218,
1862
+ Ucirc: 219,
1863
+ Ugrave: 217,
1864
+ Uuml: 220,
1865
+ Yacute: 221,
1866
+ aacute: 225,
1867
+ acirc: 226,
1868
+ aelig: 230,
1869
+ agrave: 224,
1870
+ aring: 229,
1871
+ atilde: 227,
1872
+ auml: 228,
1873
+ ccedil: 231,
1874
+ eacute: 233,
1875
+ ecirc: 234,
1876
+ egrave: 232,
1877
+ eth: 240,
1878
+ euml: 235,
1879
+ iacute: 237,
1880
+ icirc: 238,
1881
+ igrave: 236,
1882
+ iuml: 239,
1883
+ ntilde: 241,
1884
+ oacute: 243,
1885
+ ocirc: 244,
1886
+ ograve: 242,
1887
+ oslash: 248,
1888
+ otilde: 245,
1889
+ ouml: 246,
1890
+ szlig: 223,
1891
+ thorn: 254,
1892
+ uacute: 250,
1893
+ ucirc: 251,
1894
+ ugrave: 249,
1895
+ uuml: 252,
1896
+ yacute: 253,
1897
+ yuml: 255,
1898
+ copy: 169,
1899
+ reg: 174,
1900
+ nbsp: 160,
1901
+ iexcl: 161,
1902
+ cent: 162,
1903
+ pound: 163,
1904
+ curren: 164,
1905
+ yen: 165,
1906
+ brvbar: 166,
1907
+ sect: 167,
1908
+ uml: 168,
1909
+ ordf: 170,
1910
+ laquo: 171,
1911
+ not: 172,
1912
+ shy: 173,
1913
+ macr: 175,
1914
+ deg: 176,
1915
+ plusmn: 177,
1916
+ sup1: 185,
1917
+ sup2: 178,
1918
+ sup3: 179,
1919
+ acute: 180,
1920
+ micro: 181,
1921
+ para: 182,
1922
+ middot: 183,
1923
+ cedil: 184,
1924
+ ordm: 186,
1925
+ raquo: 187,
1926
+ frac14: 188,
1927
+ frac12: 189,
1928
+ frac34: 190,
1929
+ iquest: 191,
1930
+ times: 215,
1931
+ divide: 247,
1932
+ OElig: 338,
1933
+ oelig: 339,
1934
+ Scaron: 352,
1935
+ scaron: 353,
1936
+ Yuml: 376,
1937
+ fnof: 402,
1938
+ circ: 710,
1939
+ tilde: 732,
1940
+ Alpha: 913,
1941
+ Beta: 914,
1942
+ Gamma: 915,
1943
+ Delta: 916,
1944
+ Epsilon: 917,
1945
+ Zeta: 918,
1946
+ Eta: 919,
1947
+ Theta: 920,
1948
+ Iota: 921,
1949
+ Kappa: 922,
1950
+ Lambda: 923,
1951
+ Mu: 924,
1952
+ Nu: 925,
1953
+ Xi: 926,
1954
+ Omicron: 927,
1955
+ Pi: 928,
1956
+ Rho: 929,
1957
+ Sigma: 931,
1958
+ Tau: 932,
1959
+ Upsilon: 933,
1960
+ Phi: 934,
1961
+ Chi: 935,
1962
+ Psi: 936,
1963
+ Omega: 937,
1964
+ alpha: 945,
1965
+ beta: 946,
1966
+ gamma: 947,
1967
+ delta: 948,
1968
+ epsilon: 949,
1969
+ zeta: 950,
1970
+ eta: 951,
1971
+ theta: 952,
1972
+ iota: 953,
1973
+ kappa: 954,
1974
+ lambda: 955,
1975
+ mu: 956,
1976
+ nu: 957,
1977
+ xi: 958,
1978
+ omicron: 959,
1979
+ pi: 960,
1980
+ rho: 961,
1981
+ sigmaf: 962,
1982
+ sigma: 963,
1983
+ tau: 964,
1984
+ upsilon: 965,
1985
+ phi: 966,
1986
+ chi: 967,
1987
+ psi: 968,
1988
+ omega: 969,
1989
+ thetasym: 977,
1990
+ upsih: 978,
1991
+ piv: 982,
1992
+ ensp: 8194,
1993
+ emsp: 8195,
1994
+ thinsp: 8201,
1995
+ zwnj: 8204,
1996
+ zwj: 8205,
1997
+ lrm: 8206,
1998
+ rlm: 8207,
1999
+ ndash: 8211,
2000
+ mdash: 8212,
2001
+ lsquo: 8216,
2002
+ rsquo: 8217,
2003
+ sbquo: 8218,
2004
+ ldquo: 8220,
2005
+ rdquo: 8221,
2006
+ bdquo: 8222,
2007
+ dagger: 8224,
2008
+ Dagger: 8225,
2009
+ bull: 8226,
2010
+ hellip: 8230,
2011
+ permil: 8240,
2012
+ prime: 8242,
2013
+ Prime: 8243,
2014
+ lsaquo: 8249,
2015
+ rsaquo: 8250,
2016
+ oline: 8254,
2017
+ frasl: 8260,
2018
+ euro: 8364,
2019
+ image: 8465,
2020
+ weierp: 8472,
2021
+ real: 8476,
2022
+ trade: 8482,
2023
+ alefsym: 8501,
2024
+ larr: 8592,
2025
+ uarr: 8593,
2026
+ rarr: 8594,
2027
+ darr: 8595,
2028
+ harr: 8596,
2029
+ crarr: 8629,
2030
+ lArr: 8656,
2031
+ uArr: 8657,
2032
+ rArr: 8658,
2033
+ dArr: 8659,
2034
+ hArr: 8660,
2035
+ forall: 8704,
2036
+ part: 8706,
2037
+ exist: 8707,
2038
+ empty: 8709,
2039
+ nabla: 8711,
2040
+ isin: 8712,
2041
+ notin: 8713,
2042
+ ni: 8715,
2043
+ prod: 8719,
2044
+ sum: 8721,
2045
+ minus: 8722,
2046
+ lowast: 8727,
2047
+ radic: 8730,
2048
+ prop: 8733,
2049
+ infin: 8734,
2050
+ ang: 8736,
2051
+ and: 8743,
2052
+ or: 8744,
2053
+ cap: 8745,
2054
+ cup: 8746,
2055
+ int: 8747,
2056
+ there4: 8756,
2057
+ sim: 8764,
2058
+ cong: 8773,
2059
+ asymp: 8776,
2060
+ ne: 8800,
2061
+ equiv: 8801,
2062
+ le: 8804,
2063
+ ge: 8805,
2064
+ sub: 8834,
2065
+ sup: 8835,
2066
+ nsub: 8836,
2067
+ sube: 8838,
2068
+ supe: 8839,
2069
+ oplus: 8853,
2070
+ otimes: 8855,
2071
+ perp: 8869,
2072
+ sdot: 8901,
2073
+ lceil: 8968,
2074
+ rceil: 8969,
2075
+ lfloor: 8970,
2076
+ rfloor: 8971,
2077
+ lang: 9001,
2078
+ rang: 9002,
2079
+ loz: 9674,
2080
+ spades: 9824,
2081
+ clubs: 9827,
2082
+ hearts: 9829,
2083
+ diams: 9830
2084
+ };
2085
+ Object.keys(ENTITIES).forEach((key) => {
2086
+ const e = ENTITIES[key];
2087
+ ENTITIES[key] = typeof e === "number" ? String.fromCharCode(e) : e;
2088
+ });
2089
+ var SAX = class {
2090
+ EVENTS = EVENTS;
2091
+ ENTITIES = {
2092
+ ...ENTITIES
2093
+ };
2094
+ XML_ENTITIES = {
2095
+ amp: "&",
2096
+ gt: ">",
2097
+ lt: "<",
2098
+ quot: '"',
2099
+ apos: "'"
2100
+ };
2101
+ S = 0;
2102
+ trackPosition = false;
2103
+ column = 0;
2104
+ line = 0;
2105
+ c = "";
2106
+ q = "";
2107
+ closed = false;
2108
+ tags = [];
2109
+ looseCase = "";
2110
+ closedRoot = false;
2111
+ sawRoot = false;
2112
+ strict = false;
2113
+ noscript = false;
2114
+ attribList = [];
2115
+ position = 0;
2116
+ STATE = {
2117
+ BEGIN: this.S++,
2118
+ BEGIN_WHITESPACE: this.S++,
2119
+ TEXT: this.S++,
2120
+ TEXT_ENTITY: this.S++,
2121
+ OPEN_WAKA: this.S++,
2122
+ SGML_DECL: this.S++,
2123
+ SGML_DECL_QUOTED: this.S++,
2124
+ DOCTYPE: this.S++,
2125
+ DOCTYPE_QUOTED: this.S++,
2126
+ DOCTYPE_DTD: this.S++,
2127
+ DOCTYPE_DTD_QUOTED: this.S++,
2128
+ COMMENT_STARTING: this.S++,
2129
+ COMMENT: this.S++,
2130
+ COMMENT_ENDING: this.S++,
2131
+ COMMENT_ENDED: this.S++,
2132
+ CDATA: this.S++,
2133
+ CDATA_ENDING: this.S++,
2134
+ CDATA_ENDING_2: this.S++,
2135
+ PROC_INST: this.S++,
2136
+ PROC_INST_BODY: this.S++,
2137
+ PROC_INST_ENDING: this.S++,
2138
+ OPEN_TAG: this.S++,
2139
+ OPEN_TAG_SLASH: this.S++,
2140
+ ATTRIB: this.S++,
2141
+ ATTRIB_NAME: this.S++,
2142
+ ATTRIB_NAME_SAW_WHITE: this.S++,
2143
+ ATTRIB_VALUE: this.S++,
2144
+ ATTRIB_VALUE_QUOTED: this.S++,
2145
+ ATTRIB_VALUE_CLOSED: this.S++,
2146
+ ATTRIB_VALUE_UNQUOTED: this.S++,
2147
+ ATTRIB_VALUE_ENTITY_Q: this.S++,
2148
+ ATTRIB_VALUE_ENTITY_U: this.S++,
2149
+ CLOSE_TAG: this.S++,
2150
+ CLOSE_TAG_SAW_WHITE: this.S++,
2151
+ SCRIPT: this.S++,
2152
+ SCRIPT_ENDING: this.S++
2153
+ };
2154
+ BUFFERS = BUFFERS;
2155
+ CDATA = "[CDATA[";
2156
+ DOCTYPE = "DOCTYPE";
2157
+ XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
2158
+ XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/";
2159
+ rootNS = {
2160
+ xml: this.XML_NAMESPACE,
2161
+ xmlns: this.XMLNS_NAMESPACE
2162
+ };
2163
+ textNode = "";
2164
+ entity = "";
2165
+ cdata = "";
2166
+ script = "";
2167
+ startTagPosition = 0;
2168
+ constructor() {
2169
+ this.S = 0;
2170
+ for (const s in this.STATE) {
2171
+ if (this.STATE.hasOwnProperty(s)) {
2172
+ this.STATE[this.STATE[s]] = s;
2173
+ }
2174
+ }
2175
+ this.S = this.STATE;
2176
+ }
2177
+ static charAt(chunk, i) {
2178
+ let result = "";
2179
+ if (i < chunk.length) {
2180
+ result = chunk.charAt(i);
2181
+ }
2182
+ return result;
2183
+ }
2184
+ static isWhitespace(c) {
2185
+ return c === " " || c === "\n" || c === "\r" || c === " ";
2186
+ }
2187
+ static isQuote(c) {
2188
+ return c === '"' || c === "'";
2189
+ }
2190
+ static isAttribEnd(c) {
2191
+ return c === ">" || SAX.isWhitespace(c);
2192
+ }
2193
+ static isMatch(regex, c) {
2194
+ return regex.test(c);
2195
+ }
2196
+ static notMatch(regex, c) {
2197
+ return !SAX.isMatch(regex, c);
2198
+ }
2199
+ static qname(name, attribute) {
2200
+ const i = name.indexOf(":");
2201
+ const qualName = i < 0 ? ["", name] : name.split(":");
2202
+ let prefix = qualName[0];
2203
+ let local = qualName[1];
2204
+ if (attribute && name === "xmlns") {
2205
+ prefix = "xmlns";
2206
+ local = "";
2207
+ }
2208
+ return {
2209
+ prefix,
2210
+ local
2211
+ };
2212
+ }
2213
+ write(chunk) {
2214
+ if (this.error) {
2215
+ throw this.error;
2216
+ }
2217
+ if (this.closed) {
2218
+ return this.errorFunction("Cannot write after close. Assign an onready handler.");
2219
+ }
2220
+ if (chunk === null) {
2221
+ return this.end();
2222
+ }
2223
+ if (typeof chunk === "object") {
2224
+ chunk = chunk.toString();
2225
+ }
2226
+ let i = 0;
2227
+ let c;
2228
+ while (true) {
2229
+ c = SAX.charAt(chunk, i++);
2230
+ this.c = c;
2231
+ if (!c) {
2232
+ break;
2233
+ }
2234
+ if (this.trackPosition) {
2235
+ this.position++;
2236
+ if (c === "\n") {
2237
+ this.line++;
2238
+ this.column = 0;
2239
+ } else {
2240
+ this.column++;
2241
+ }
2242
+ }
2243
+ switch (this.state) {
2244
+ case this.S.BEGIN:
2245
+ this.state = this.S.BEGIN_WHITESPACE;
2246
+ if (c === "\uFEFF") {
2247
+ continue;
2248
+ }
2249
+ this.beginWhiteSpace(c);
2250
+ continue;
2251
+ case this.S.BEGIN_WHITESPACE:
2252
+ this.beginWhiteSpace(c);
2253
+ continue;
2254
+ case this.S.TEXT:
2255
+ if (this.sawRoot && !this.closedRoot) {
2256
+ const starti = i - 1;
2257
+ while (c && c !== "<" && c !== "&") {
2258
+ c = SAX.charAt(chunk, i++);
2259
+ if (c && this.trackPosition) {
2260
+ this.position++;
2261
+ if (c === "\n") {
2262
+ this.line++;
2263
+ this.column = 0;
2264
+ } else {
2265
+ this.column++;
2266
+ }
2267
+ }
2268
+ }
2269
+ this.textNode += chunk.substring(starti, i - 1);
2270
+ }
2271
+ if (c === "<" && !(this.sawRoot && this.closedRoot && !this.strict)) {
2272
+ this.state = this.S.OPEN_WAKA;
2273
+ this.startTagPosition = this.position;
2274
+ } else {
2275
+ if (!SAX.isWhitespace(c) && (!this.sawRoot || this.closedRoot)) {
2276
+ this.strictFail("Text data outside of root node.");
2277
+ }
2278
+ if (c === "&") {
2279
+ this.state = this.S.TEXT_ENTITY;
2280
+ } else {
2281
+ this.textNode += c;
2282
+ }
2283
+ }
2284
+ continue;
2285
+ case this.S.SCRIPT:
2286
+ if (c === "<") {
2287
+ this.state = this.S.SCRIPT_ENDING;
2288
+ } else {
2289
+ this.script += c;
2290
+ }
2291
+ continue;
2292
+ case this.S.SCRIPT_ENDING:
2293
+ if (c === "/") {
2294
+ this.state = this.S.CLOSE_TAG;
2295
+ } else {
2296
+ this.script += `<${c}`;
2297
+ this.state = this.S.SCRIPT;
2298
+ }
2299
+ continue;
2300
+ case this.S.OPEN_WAKA:
2301
+ if (c === "!") {
2302
+ this.state = this.S.SGML_DECL;
2303
+ this.sgmlDecl = "";
2304
+ } else if (SAX.isWhitespace(c)) {
2305
+ } else if (SAX.isMatch(nameStart, c)) {
2306
+ this.state = this.S.OPEN_TAG;
2307
+ this.tagName = c;
2308
+ } else if (c === "/") {
2309
+ this.state = this.S.CLOSE_TAG;
2310
+ this.tagName = "";
2311
+ } else if (c === "?") {
2312
+ this.state = this.S.PROC_INST;
2313
+ this.procInstName = this.procInstBody = "";
2314
+ } else {
2315
+ this.strictFail("Unencoded <");
2316
+ if (this.startTagPosition + 1 < this.position) {
2317
+ const pad = this.position - this.startTagPosition;
2318
+ c = new Array(pad).join(" ") + c;
2319
+ }
2320
+ this.textNode += `<${c}`;
2321
+ this.state = this.S.TEXT;
2322
+ }
2323
+ continue;
2324
+ case this.S.SGML_DECL:
2325
+ if ((this.sgmlDecl + c).toUpperCase() === this.CDATA) {
2326
+ this.emitNode("onopencdata");
2327
+ this.state = this.S.CDATA;
2328
+ this.sgmlDecl = "";
2329
+ this.cdata = "";
2330
+ } else if (this.sgmlDecl + c === "--") {
2331
+ this.state = this.S.COMMENT;
2332
+ this.comment = "";
2333
+ this.sgmlDecl = "";
2334
+ } else if ((this.sgmlDecl + c).toUpperCase() === this.DOCTYPE) {
2335
+ this.state = this.S.DOCTYPE;
2336
+ if (this.doctype || this.sawRoot) {
2337
+ this.strictFail("Inappropriately located doctype declaration");
2338
+ }
2339
+ this.doctype = "";
2340
+ this.sgmlDecl = "";
2341
+ } else if (c === ">") {
2342
+ this.emitNode("onsgmldeclaration", this.sgmlDecl);
2343
+ this.sgmlDecl = "";
2344
+ this.state = this.S.TEXT;
2345
+ } else if (SAX.isQuote(c)) {
2346
+ this.state = this.S.SGML_DECL_QUOTED;
2347
+ this.sgmlDecl += c;
2348
+ } else {
2349
+ this.sgmlDecl += c;
2350
+ }
2351
+ continue;
2352
+ case this.S.SGML_DECL_QUOTED:
2353
+ if (c === this.q) {
2354
+ this.state = this.S.SGML_DECL;
2355
+ this.q = "";
2356
+ }
2357
+ this.sgmlDecl += c;
2358
+ continue;
2359
+ case this.S.DOCTYPE:
2360
+ if (c === ">") {
2361
+ this.state = this.S.TEXT;
2362
+ this.emitNode("ondoctype", this.doctype);
2363
+ this.doctype = true;
2364
+ } else {
2365
+ this.doctype += c;
2366
+ if (c === "[") {
2367
+ this.state = this.S.DOCTYPE_DTD;
2368
+ } else if (SAX.isQuote(c)) {
2369
+ this.state = this.S.DOCTYPE_QUOTED;
2370
+ this.q = c;
2371
+ }
2372
+ }
2373
+ continue;
2374
+ case this.S.DOCTYPE_QUOTED:
2375
+ this.doctype += c;
2376
+ if (c === this.q) {
2377
+ this.q = "";
2378
+ this.state = this.S.DOCTYPE;
2379
+ }
2380
+ continue;
2381
+ case this.S.DOCTYPE_DTD:
2382
+ this.doctype += c;
2383
+ if (c === "]") {
2384
+ this.state = this.S.DOCTYPE;
2385
+ } else if (SAX.isQuote(c)) {
2386
+ this.state = this.S.DOCTYPE_DTD_QUOTED;
2387
+ this.q = c;
2388
+ }
2389
+ continue;
2390
+ case this.S.DOCTYPE_DTD_QUOTED:
2391
+ this.doctype += c;
2392
+ if (c === this.q) {
2393
+ this.state = this.S.DOCTYPE_DTD;
2394
+ this.q = "";
2395
+ }
2396
+ continue;
2397
+ case this.S.COMMENT:
2398
+ if (c === "-") {
2399
+ this.state = this.S.COMMENT_ENDING;
2400
+ } else {
2401
+ this.comment += c;
2402
+ }
2403
+ continue;
2404
+ case this.S.COMMENT_ENDING:
2405
+ if (c === "-") {
2406
+ this.state = this.S.COMMENT_ENDED;
2407
+ this.comment = this.textApplyOptions(this.comment);
2408
+ if (this.comment) {
2409
+ this.emitNode("oncomment", this.comment);
2410
+ }
2411
+ this.comment = "";
2412
+ } else {
2413
+ this.comment += `-${c}`;
2414
+ this.state = this.S.COMMENT;
2415
+ }
2416
+ continue;
2417
+ case this.S.COMMENT_ENDED:
2418
+ if (c !== ">") {
2419
+ this.strictFail("Malformed comment");
2420
+ this.comment += `--${c}`;
2421
+ this.state = this.S.COMMENT;
2422
+ } else {
2423
+ this.state = this.S.TEXT;
2424
+ }
2425
+ continue;
2426
+ case this.S.CDATA:
2427
+ if (c === "]") {
2428
+ this.state = this.S.CDATA_ENDING;
2429
+ } else {
2430
+ this.cdata += c;
2431
+ }
2432
+ continue;
2433
+ case this.S.CDATA_ENDING:
2434
+ if (c === "]") {
2435
+ this.state = this.S.CDATA_ENDING_2;
2436
+ } else {
2437
+ this.cdata += `]${c}`;
2438
+ this.state = this.S.CDATA;
2439
+ }
2440
+ continue;
2441
+ case this.S.CDATA_ENDING_2:
2442
+ if (c === ">") {
2443
+ if (this.cdata) {
2444
+ this.emitNode("oncdata", this.cdata);
2445
+ }
2446
+ this.emitNode("onclosecdata");
2447
+ this.cdata = "";
2448
+ this.state = this.S.TEXT;
2449
+ } else if (c === "]") {
2450
+ this.cdata += "]";
2451
+ } else {
2452
+ this.cdata += `]]${c}`;
2453
+ this.state = this.S.CDATA;
2454
+ }
2455
+ continue;
2456
+ case this.S.PROC_INST:
2457
+ if (c === "?") {
2458
+ this.state = this.S.PROC_INST_ENDING;
2459
+ } else if (SAX.isWhitespace(c)) {
2460
+ this.state = this.S.PROC_INST_BODY;
2461
+ } else {
2462
+ this.procInstName += c;
2463
+ }
2464
+ continue;
2465
+ case this.S.PROC_INST_BODY:
2466
+ if (!this.procInstBody && SAX.isWhitespace(c)) {
2467
+ continue;
2468
+ } else if (c === "?") {
2469
+ this.state = this.S.PROC_INST_ENDING;
2470
+ } else {
2471
+ this.procInstBody += c;
2472
+ }
2473
+ continue;
2474
+ case this.S.PROC_INST_ENDING:
2475
+ if (c === ">") {
2476
+ this.emitNode("onprocessinginstruction", {
2477
+ name: this.procInstName,
2478
+ body: this.procInstBody
2479
+ });
2480
+ this.procInstName = this.procInstBody = "";
2481
+ this.state = this.S.TEXT;
2482
+ } else {
2483
+ this.procInstBody += `?${c}`;
2484
+ this.state = this.S.PROC_INST_BODY;
2485
+ }
2486
+ continue;
2487
+ case this.S.OPEN_TAG:
2488
+ if (SAX.isMatch(nameBody, c)) {
2489
+ this.tagName += c;
2490
+ } else {
2491
+ this.newTag();
2492
+ if (c === ">") {
2493
+ this.openTag();
2494
+ } else if (c === "/") {
2495
+ this.state = this.S.OPEN_TAG_SLASH;
2496
+ } else {
2497
+ if (!SAX.isWhitespace(c)) {
2498
+ this.strictFail("Invalid character in tag name");
2499
+ }
2500
+ this.state = this.S.ATTRIB;
2501
+ }
2502
+ }
2503
+ continue;
2504
+ case this.S.OPEN_TAG_SLASH:
2505
+ if (c === ">") {
2506
+ this.openTag(true);
2507
+ this.closeTag();
2508
+ } else {
2509
+ this.strictFail("Forward-slash in opening tag not followed by >");
2510
+ this.state = this.S.ATTRIB;
2511
+ }
2512
+ continue;
2513
+ case this.S.ATTRIB:
2514
+ if (SAX.isWhitespace(c)) {
2515
+ continue;
2516
+ } else if (c === ">") {
2517
+ this.openTag();
2518
+ } else if (c === "/") {
2519
+ this.state = this.S.OPEN_TAG_SLASH;
2520
+ } else if (SAX.isMatch(nameStart, c)) {
2521
+ this.attribName = c;
2522
+ this.attribValue = "";
2523
+ this.state = this.S.ATTRIB_NAME;
2524
+ } else {
2525
+ this.strictFail("Invalid attribute name");
2526
+ }
2527
+ continue;
2528
+ case this.S.ATTRIB_NAME:
2529
+ if (c === "=") {
2530
+ this.state = this.S.ATTRIB_VALUE;
2531
+ } else if (c === ">") {
2532
+ this.strictFail("Attribute without value");
2533
+ this.attribValue = this.attribName;
2534
+ this.attrib();
2535
+ this.openTag();
2536
+ } else if (SAX.isWhitespace(c)) {
2537
+ this.state = this.S.ATTRIB_NAME_SAW_WHITE;
2538
+ } else if (SAX.isMatch(nameBody, c)) {
2539
+ this.attribName += c;
2540
+ } else {
2541
+ this.strictFail("Invalid attribute name");
2542
+ }
2543
+ continue;
2544
+ case this.S.ATTRIB_NAME_SAW_WHITE:
2545
+ if (c === "=") {
2546
+ this.state = this.S.ATTRIB_VALUE;
2547
+ } else if (SAX.isWhitespace(c)) {
2548
+ continue;
2549
+ } else {
2550
+ this.strictFail("Attribute without value");
2551
+ this.tag.attributes[this.attribName] = "";
2552
+ this.attribValue = "";
2553
+ this.emitNode("onattribute", {
2554
+ name: this.attribName,
2555
+ value: ""
2556
+ });
2557
+ this.attribName = "";
2558
+ if (c === ">") {
2559
+ this.openTag();
2560
+ } else if (SAX.isMatch(nameStart, c)) {
2561
+ this.attribName = c;
2562
+ this.state = this.S.ATTRIB_NAME;
2563
+ } else {
2564
+ this.strictFail("Invalid attribute name");
2565
+ this.state = this.S.ATTRIB;
2566
+ }
2567
+ }
2568
+ continue;
2569
+ case this.S.ATTRIB_VALUE:
2570
+ if (SAX.isWhitespace(c)) {
2571
+ continue;
2572
+ } else if (SAX.isQuote(c)) {
2573
+ this.q = c;
2574
+ this.state = this.S.ATTRIB_VALUE_QUOTED;
2575
+ } else {
2576
+ this.strictFail("Unquoted attribute value");
2577
+ this.state = this.S.ATTRIB_VALUE_UNQUOTED;
2578
+ this.attribValue = c;
2579
+ }
2580
+ continue;
2581
+ case this.S.ATTRIB_VALUE_QUOTED:
2582
+ if (c !== this.q) {
2583
+ if (c === "&") {
2584
+ this.state = this.S.ATTRIB_VALUE_ENTITY_Q;
2585
+ } else {
2586
+ this.attribValue += c;
2587
+ }
2588
+ continue;
2589
+ }
2590
+ this.attrib();
2591
+ this.q = "";
2592
+ this.state = this.S.ATTRIB_VALUE_CLOSED;
2593
+ continue;
2594
+ case this.S.ATTRIB_VALUE_CLOSED:
2595
+ if (SAX.isWhitespace(c)) {
2596
+ this.state = this.S.ATTRIB;
2597
+ } else if (c === ">") {
2598
+ this.openTag();
2599
+ } else if (c === "/") {
2600
+ this.state = this.S.OPEN_TAG_SLASH;
2601
+ } else if (SAX.isMatch(nameStart, c)) {
2602
+ this.strictFail("No whitespace between attributes");
2603
+ this.attribName = c;
2604
+ this.attribValue = "";
2605
+ this.state = this.S.ATTRIB_NAME;
2606
+ } else {
2607
+ this.strictFail("Invalid attribute name");
2608
+ }
2609
+ continue;
2610
+ case this.S.ATTRIB_VALUE_UNQUOTED:
2611
+ if (!SAX.isAttribEnd(c)) {
2612
+ if (c === "&") {
2613
+ this.state = this.S.ATTRIB_VALUE_ENTITY_U;
2614
+ } else {
2615
+ this.attribValue += c;
2616
+ }
2617
+ continue;
2618
+ }
2619
+ this.attrib();
2620
+ if (c === ">") {
2621
+ this.openTag();
2622
+ } else {
2623
+ this.state = this.S.ATTRIB;
2624
+ }
2625
+ continue;
2626
+ case this.S.CLOSE_TAG:
2627
+ if (!this.tagName) {
2628
+ if (SAX.isWhitespace(c)) {
2629
+ continue;
2630
+ } else if (SAX.notMatch(nameStart, c)) {
2631
+ if (this.script) {
2632
+ this.script += `</${c}`;
2633
+ this.state = this.S.SCRIPT;
2634
+ } else {
2635
+ this.strictFail("Invalid tagname in closing tag.");
2891
2636
  }
2892
2637
  } else {
2893
- listTagVal += this.buildTextValNode(item, key, "", level);
2638
+ this.tagName = c;
2639
+ }
2640
+ } else if (c === ">") {
2641
+ this.closeTag();
2642
+ } else if (SAX.isMatch(nameBody, c)) {
2643
+ this.tagName += c;
2644
+ } else if (this.script) {
2645
+ this.script += `</${this.tagName}`;
2646
+ this.tagName = "";
2647
+ this.state = this.S.SCRIPT;
2648
+ } else {
2649
+ if (!SAX.isWhitespace(c)) {
2650
+ this.strictFail("Invalid tagname in closing tag");
2894
2651
  }
2652
+ this.state = this.S.CLOSE_TAG_SAW_WHITE;
2895
2653
  }
2896
- if (this.options.oneListGroup) {
2897
- listTagVal = this.buildObjectNode(listTagVal, key, "", level);
2654
+ continue;
2655
+ case this.S.CLOSE_TAG_SAW_WHITE:
2656
+ if (SAX.isWhitespace(c)) {
2657
+ continue;
2898
2658
  }
2899
- val2 += listTagVal;
2900
- } else {
2901
- if (this.options.attributesGroupName && key === this.options.attributesGroupName) {
2902
- const Ks = Object.keys(jObj[key]);
2903
- const L = Ks.length;
2904
- for (let j = 0; j < L; j++) {
2905
- attrStr += this.buildAttrPairStr(Ks[j], "" + jObj[key][Ks[j]]);
2906
- }
2659
+ if (c === ">") {
2660
+ this.closeTag();
2907
2661
  } else {
2908
- val2 += this.processTextOrObjNode(jObj[key], key, level);
2662
+ this.strictFail("Invalid characters in closing tag");
2663
+ }
2664
+ continue;
2665
+ case this.S.TEXT_ENTITY:
2666
+ case this.S.ATTRIB_VALUE_ENTITY_Q:
2667
+ case this.S.ATTRIB_VALUE_ENTITY_U:
2668
+ let returnState;
2669
+ let buffer;
2670
+ switch (this.state) {
2671
+ case this.S.TEXT_ENTITY:
2672
+ returnState = this.S.TEXT;
2673
+ buffer = "textNode";
2674
+ break;
2675
+ case this.S.ATTRIB_VALUE_ENTITY_Q:
2676
+ returnState = this.S.ATTRIB_VALUE_QUOTED;
2677
+ buffer = "attribValue";
2678
+ break;
2679
+ case this.S.ATTRIB_VALUE_ENTITY_U:
2680
+ returnState = this.S.ATTRIB_VALUE_UNQUOTED;
2681
+ buffer = "attribValue";
2682
+ break;
2683
+ default:
2684
+ throw new Error(`Unknown state: ${this.state}`);
2685
+ }
2686
+ if (c === ";") {
2687
+ this[buffer] += this.parseEntity();
2688
+ this.entity = "";
2689
+ this.state = returnState;
2690
+ } else if (SAX.isMatch(this.entity.length ? entityBody : entityStart, c)) {
2691
+ this.entity += c;
2692
+ } else {
2693
+ this.strictFail("Invalid character in entity name");
2694
+ this[buffer] += `&${this.entity}${c}`;
2695
+ this.entity = "";
2696
+ this.state = returnState;
2697
+ }
2698
+ continue;
2699
+ default:
2700
+ throw new Error(`Unknown state: ${this.state}`);
2701
+ }
2702
+ }
2703
+ if (this.position >= this.bufferCheckPosition) {
2704
+ this.checkBufferLength();
2705
+ }
2706
+ return this;
2707
+ }
2708
+ emit(event, data) {
2709
+ if (this.events.hasOwnProperty(event)) {
2710
+ const eventName = event.replace(/^on/, "");
2711
+ this.events[event](data, eventName, this);
2712
+ }
2713
+ }
2714
+ clearBuffers() {
2715
+ for (let i = 0, l = this.BUFFERS.length; i < l; i++) {
2716
+ this[this[i]] = "";
2717
+ }
2718
+ }
2719
+ flushBuffers() {
2720
+ this.closeText();
2721
+ if (this.cdata !== "") {
2722
+ this.emitNode("oncdata", this.cdata);
2723
+ this.cdata = "";
2724
+ }
2725
+ if (this.script !== "") {
2726
+ this.emitNode("onscript", this.script);
2727
+ this.script = "";
2728
+ }
2729
+ }
2730
+ end() {
2731
+ if (this.sawRoot && !this.closedRoot)
2732
+ this.strictFail("Unclosed root tag");
2733
+ if (this.state !== this.S.BEGIN && this.state !== this.S.BEGIN_WHITESPACE && this.state !== this.S.TEXT) {
2734
+ this.errorFunction("Unexpected end");
2735
+ }
2736
+ this.closeText();
2737
+ this.c = "";
2738
+ this.closed = true;
2739
+ this.emit("onend");
2740
+ return new SAXParser(this.opt);
2741
+ }
2742
+ errorFunction(er) {
2743
+ this.closeText();
2744
+ if (this.trackPosition) {
2745
+ er += `
2746
+ Line: ${this.line}
2747
+ Column: ${this.column}
2748
+ Char: ${this.c}`;
2749
+ }
2750
+ const error = new Error(er);
2751
+ this.error = error;
2752
+ this.emit("onerror", error);
2753
+ return this;
2754
+ }
2755
+ attrib() {
2756
+ if (!this.strict) {
2757
+ this.attribName = this.attribName[this.looseCase]();
2758
+ }
2759
+ if (this.attribList.indexOf(this.attribName) !== -1 || this.tag.attributes.hasOwnProperty(this.attribName)) {
2760
+ this.attribName = this.attribValue = "";
2761
+ return;
2762
+ }
2763
+ if (this.opt.xmlns) {
2764
+ const qn = SAX.qname(this.attribName, true);
2765
+ const prefix = qn.prefix;
2766
+ const local = qn.local;
2767
+ if (prefix === "xmlns") {
2768
+ if (local === "xml" && this.attribValue !== this.XML_NAMESPACE) {
2769
+ this.strictFail(`xml: prefix must be bound to ${this.XML_NAMESPACE}
2770
+ Actual: ${this.attribValue}`);
2771
+ } else if (local === "xmlns" && this.attribValue !== this.XMLNS_NAMESPACE) {
2772
+ this.strictFail(`xmlns: prefix must be bound to ${this.XMLNS_NAMESPACE}
2773
+ Actual: ${this.attribValue}`);
2774
+ } else {
2775
+ const tag = this.tag;
2776
+ const parent = this.tags[this.tags.length - 1] || this;
2777
+ if (tag.ns === parent.ns) {
2778
+ tag.ns = Object.create(parent.ns);
2909
2779
  }
2780
+ tag.ns[local] = this.attribValue;
2910
2781
  }
2911
2782
  }
2912
- return { attrStr, val: val2 };
2913
- };
2914
- Builder.prototype.buildAttrPairStr = function(attrName, val2) {
2915
- val2 = this.options.attributeValueProcessor(attrName, "" + val2);
2916
- val2 = this.replaceEntitiesValue(val2);
2917
- if (this.options.suppressBooleanAttributes && val2 === "true") {
2918
- return " " + attrName;
2919
- } else
2920
- return " " + attrName + '="' + val2 + '"';
2783
+ this.attribList.push([this.attribName, this.attribValue]);
2784
+ } else {
2785
+ this.tag.attributes[this.attribName] = this.attribValue;
2786
+ this.emitNode("onattribute", {
2787
+ name: this.attribName,
2788
+ value: this.attribValue
2789
+ });
2790
+ }
2791
+ this.attribName = this.attribValue = "";
2792
+ }
2793
+ newTag() {
2794
+ if (!this.strict)
2795
+ this.tagName = this.tagName[this.looseCase]();
2796
+ const parent = this.tags[this.tags.length - 1] || this;
2797
+ const tag = this.tag = {
2798
+ name: this.tagName,
2799
+ attributes: {}
2921
2800
  };
2922
- function processTextOrObjNode(object, key, level) {
2923
- const result = this.j2x(object, level + 1);
2924
- if (object[this.options.textNodeName] !== void 0 && Object.keys(object).length === 1) {
2925
- return this.buildTextValNode(object[this.options.textNodeName], key, result.attrStr, level);
2801
+ if (this.opt.xmlns) {
2802
+ tag.ns = parent.ns;
2803
+ }
2804
+ this.attribList.length = 0;
2805
+ this.emitNode("onopentagstart", tag);
2806
+ }
2807
+ parseEntity() {
2808
+ let entity = this.entity;
2809
+ const entityLC = entity.toLowerCase();
2810
+ let num = NaN;
2811
+ let numStr = "";
2812
+ if (this.ENTITIES[entity]) {
2813
+ return this.ENTITIES[entity];
2814
+ }
2815
+ if (this.ENTITIES[entityLC]) {
2816
+ return this.ENTITIES[entityLC];
2817
+ }
2818
+ entity = entityLC;
2819
+ if (entity.charAt(0) === "#") {
2820
+ if (entity.charAt(1) === "x") {
2821
+ entity = entity.slice(2);
2822
+ num = parseInt(entity, 16);
2823
+ numStr = num.toString(16);
2926
2824
  } else {
2927
- return this.buildObjectNode(result.val, key, result.attrStr, level);
2825
+ entity = entity.slice(1);
2826
+ num = parseInt(entity, 10);
2827
+ numStr = num.toString(10);
2928
2828
  }
2929
2829
  }
2930
- Builder.prototype.buildObjectNode = function(val2, key, attrStr, level) {
2931
- if (val2 === "") {
2932
- if (key[0] === "?")
2933
- return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
2934
- else {
2935
- return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
2936
- }
2937
- } else {
2938
- let tagEndExp = "</" + key + this.tagEndChar;
2939
- let piClosingChar = "";
2940
- if (key[0] === "?") {
2941
- piClosingChar = "?";
2942
- tagEndExp = "";
2830
+ entity = entity.replace(/^0+/, "");
2831
+ if (isNaN(num) || numStr.toLowerCase() !== entity) {
2832
+ this.strictFail("Invalid character entity");
2833
+ return `&${this.entity};`;
2834
+ }
2835
+ return String.fromCodePoint(num);
2836
+ }
2837
+ beginWhiteSpace(c) {
2838
+ if (c === "<") {
2839
+ this.state = this.S.OPEN_WAKA;
2840
+ this.startTagPosition = this.position;
2841
+ } else if (!SAX.isWhitespace(c)) {
2842
+ this.strictFail("Non-whitespace before first tag.");
2843
+ this.textNode = c;
2844
+ this.state = this.S.TEXT;
2845
+ } else {
2846
+ }
2847
+ }
2848
+ strictFail(message) {
2849
+ if (typeof this !== "object" || !(this instanceof SAXParser)) {
2850
+ throw new Error("bad call to strictFail");
2851
+ }
2852
+ if (this.strict) {
2853
+ this.errorFunction(message);
2854
+ }
2855
+ }
2856
+ textApplyOptions(text) {
2857
+ if (this.opt.trim)
2858
+ text = text.trim();
2859
+ if (this.opt.normalize)
2860
+ text = text.replace(/\s+/g, " ");
2861
+ return text;
2862
+ }
2863
+ emitNode(nodeType, data) {
2864
+ if (this.textNode)
2865
+ this.closeText();
2866
+ this.emit(nodeType, data);
2867
+ }
2868
+ closeText() {
2869
+ this.textNode = this.textApplyOptions(this.textNode);
2870
+ if (this.textNode !== void 0 && this.textNode !== "" && this.textNode !== "undefined") {
2871
+ this.emit("ontext", this.textNode);
2872
+ }
2873
+ this.textNode = "";
2874
+ }
2875
+ checkBufferLength() {
2876
+ const maxAllowed = Math.max(this.opt.MAX_BUFFER_LENGTH, 10);
2877
+ let maxActual = 0;
2878
+ for (let i = 0, l = this.BUFFERS.length; i < l; i++) {
2879
+ const len = this[this.BUFFERS[i]]?.length || 0;
2880
+ if (len > maxAllowed) {
2881
+ switch (this.BUFFERS[i]) {
2882
+ case "textNode":
2883
+ this.closeText();
2884
+ break;
2885
+ case "cdata":
2886
+ this.emitNode("oncdata", this.cdata);
2887
+ this.cdata = "";
2888
+ break;
2889
+ case "script":
2890
+ this.emitNode("onscript", this.script);
2891
+ this.script = "";
2892
+ break;
2893
+ default:
2894
+ this.errorFunction(`Max buffer length exceeded: ${this.BUFFERS[i]}`);
2943
2895
  }
2944
- if (attrStr && val2.indexOf("<") === -1) {
2945
- return this.indentate(level) + "<" + key + attrStr + piClosingChar + ">" + val2 + tagEndExp;
2946
- } else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {
2947
- return this.indentate(level) + `<!--${val2}-->` + this.newLine;
2948
- } else {
2949
- return this.indentate(level) + "<" + key + attrStr + piClosingChar + this.tagEndChar + val2 + this.indentate(level) + tagEndExp;
2896
+ }
2897
+ maxActual = Math.max(maxActual, len);
2898
+ }
2899
+ const m = this.opt.MAX_BUFFER_LENGTH - maxActual;
2900
+ this.bufferCheckPosition = m + this.position;
2901
+ }
2902
+ openTag(selfClosing) {
2903
+ if (this.opt.xmlns) {
2904
+ const tag = this.tag;
2905
+ const qn = SAX.qname(this.tagName);
2906
+ tag.prefix = qn.prefix;
2907
+ tag.local = qn.local;
2908
+ tag.uri = tag.ns[qn.prefix] || "";
2909
+ if (tag.prefix && !tag.uri) {
2910
+ this.strictFail(`Unbound namespace prefix: ${JSON.stringify(this.tagName)}`);
2911
+ tag.uri = qn.prefix;
2912
+ }
2913
+ const parent = this.tags[this.tags.length - 1] || this;
2914
+ if (tag.ns && parent.ns !== tag.ns) {
2915
+ const that = this;
2916
+ Object.keys(tag.ns).forEach((p) => {
2917
+ that.emitNode("onopennamespace", {
2918
+ prefix: p,
2919
+ uri: tag.ns[p]
2920
+ });
2921
+ });
2922
+ }
2923
+ for (let i = 0, l = this.attribList.length; i < l; i++) {
2924
+ const nv = this.attribList[i];
2925
+ const name = nv[0];
2926
+ const value = nv[1];
2927
+ const qualName = SAX.qname(name, true);
2928
+ const prefix = qualName.prefix;
2929
+ const local = qualName.local;
2930
+ const uri = prefix === "" ? "" : tag.ns[prefix] || "";
2931
+ const a = {
2932
+ name,
2933
+ value,
2934
+ prefix,
2935
+ local,
2936
+ uri
2937
+ };
2938
+ if (prefix && prefix !== "xmlns" && !uri) {
2939
+ this.strictFail(`Unbound namespace prefix: ${JSON.stringify(prefix)}`);
2940
+ a.uri = prefix;
2950
2941
  }
2942
+ this.tag.attributes[name] = a;
2943
+ this.emitNode("onattribute", a);
2951
2944
  }
2952
- };
2953
- Builder.prototype.closeTag = function(key) {
2954
- let closeTag = "";
2955
- if (this.options.unpairedTags.indexOf(key) !== -1) {
2956
- if (!this.options.suppressUnpairedNode)
2957
- closeTag = "/";
2958
- } else if (this.options.suppressEmptyNode) {
2959
- closeTag = "/";
2945
+ this.attribList.length = 0;
2946
+ }
2947
+ this.tag.isSelfClosing = Boolean(selfClosing);
2948
+ this.sawRoot = true;
2949
+ this.tags.push(this.tag);
2950
+ this.emitNode("onopentag", this.tag);
2951
+ if (!selfClosing) {
2952
+ if (!this.noscript && this.tagName.toLowerCase() === "script") {
2953
+ this.state = this.S.SCRIPT;
2960
2954
  } else {
2961
- closeTag = `></${key}`;
2955
+ this.state = this.S.TEXT;
2962
2956
  }
2963
- return closeTag;
2964
- };
2965
- Builder.prototype.buildTextValNode = function(val2, key, attrStr, level) {
2966
- if (this.options.cdataPropName !== false && key === this.options.cdataPropName) {
2967
- return this.indentate(level) + `<![CDATA[${val2}]]>` + this.newLine;
2968
- } else if (this.options.commentPropName !== false && key === this.options.commentPropName) {
2969
- return this.indentate(level) + `<!--${val2}-->` + this.newLine;
2970
- } else if (key[0] === "?") {
2971
- return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
2957
+ this.tag = null;
2958
+ this.tagName = "";
2959
+ }
2960
+ this.attribName = this.attribValue = "";
2961
+ this.attribList.length = 0;
2962
+ }
2963
+ closeTag() {
2964
+ if (!this.tagName) {
2965
+ this.strictFail("Weird empty close tag.");
2966
+ this.textNode += "</>";
2967
+ this.state = this.S.TEXT;
2968
+ return;
2969
+ }
2970
+ if (this.script) {
2971
+ if (this.tagName !== "script") {
2972
+ this.script += `</${this.tagName}>`;
2973
+ this.tagName = "";
2974
+ this.state = this.S.SCRIPT;
2975
+ return;
2976
+ }
2977
+ this.emitNode("onscript", this.script);
2978
+ this.script = "";
2979
+ }
2980
+ let t = this.tags.length;
2981
+ let tagName = this.tagName;
2982
+ if (!this.strict) {
2983
+ tagName = tagName[this.looseCase]();
2984
+ }
2985
+ while (t--) {
2986
+ const close = this.tags[t];
2987
+ if (close.name !== tagName) {
2988
+ this.strictFail("Unexpected close tag");
2972
2989
  } else {
2973
- let textValue = this.options.tagValueProcessor(key, val2);
2974
- textValue = this.replaceEntitiesValue(textValue);
2975
- if (textValue === "") {
2976
- return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
2977
- } else {
2978
- return this.indentate(level) + "<" + key + attrStr + ">" + textValue + "</" + key + this.tagEndChar;
2979
- }
2990
+ break;
2980
2991
  }
2981
- };
2982
- Builder.prototype.replaceEntitiesValue = function(textValue) {
2983
- if (textValue && textValue.length > 0 && this.options.processEntities) {
2984
- for (let i = 0; i < this.options.entities.length; i++) {
2985
- const entity = this.options.entities[i];
2986
- textValue = textValue.replace(entity.regex, entity.val);
2987
- }
2992
+ }
2993
+ if (t < 0) {
2994
+ this.strictFail(`Unmatched closing tag: ${this.tagName}`);
2995
+ this.textNode += `</${this.tagName}>`;
2996
+ this.state = this.S.TEXT;
2997
+ return;
2998
+ }
2999
+ this.tagName = tagName;
3000
+ let s = this.tags.length;
3001
+ while (s-- > t) {
3002
+ const tag = this.tag = this.tags.pop();
3003
+ this.tagName = this.tag.name;
3004
+ this.emitNode("onclosetag", this.tagName);
3005
+ const x = {};
3006
+ for (const i in tag.ns) {
3007
+ if (tag.ns.hasOwnProperty(i)) {
3008
+ x[i] = tag.ns[i];
3009
+ }
3010
+ }
3011
+ const parent = this.tags[this.tags.length - 1] || this;
3012
+ if (this.opt.xmlns && tag.ns !== parent.ns) {
3013
+ const that = this;
3014
+ Object.keys(tag.ns).forEach((p) => {
3015
+ const n = tag.ns[p];
3016
+ that.emitNode("onclosenamespace", {
3017
+ prefix: p,
3018
+ uri: n
3019
+ });
3020
+ });
2988
3021
  }
2989
- return textValue;
3022
+ }
3023
+ if (t === 0)
3024
+ this.closedRoot = true;
3025
+ this.tagName = this.attribValue = this.attribName = "";
3026
+ this.attribList.length = 0;
3027
+ this.state = this.S.TEXT;
3028
+ }
3029
+ };
3030
+ var SAXParser = class extends SAX {
3031
+ opt = DEFAULT_SAX_PARSER_OPTIONS;
3032
+ events = DEFAULT_SAX_EVENTS;
3033
+ constructor(opt) {
3034
+ super();
3035
+ this.clearBuffers();
3036
+ this.opt = opt = {
3037
+ ...this.opt,
3038
+ ...opt
2990
3039
  };
2991
- function indentate(level) {
2992
- return this.options.indentBy.repeat(level);
3040
+ this.events = {
3041
+ ...this.events,
3042
+ ...opt
3043
+ };
3044
+ this.q = this.c = "";
3045
+ this.opt.lowercase = this.opt.lowercase || this.opt.lowercasetags;
3046
+ this.bufferCheckPosition = this.opt.MAX_BUFFER_LENGTH;
3047
+ this.looseCase = this.opt.lowercase ? "toLowerCase" : "toUpperCase";
3048
+ this.tags = [];
3049
+ this.closed = this.closedRoot = this.sawRoot = false;
3050
+ this.tag = this.error = null;
3051
+ this.strict = Boolean(this.opt.strict);
3052
+ this.noscript = Boolean(this.opt.strict || this.opt.noscript);
3053
+ this.state = this.S.BEGIN;
3054
+ this.strictEntities = this.opt.strictEntities;
3055
+ this.ENTITIES = this.strictEntities ? Object.create(this.XML_ENTITIES) : Object.create(this.ENTITIES);
3056
+ this.attribList = [];
3057
+ if (this.opt.xmlns) {
3058
+ this.ns = Object.create(this.rootNS);
2993
3059
  }
2994
- function isAttribute(name) {
2995
- if (name.startsWith(this.options.attributeNamePrefix)) {
2996
- return name.substr(this.attrPrefixLen);
2997
- } else {
2998
- return false;
2999
- }
3060
+ this.trackPosition = this.opt.position !== false;
3061
+ if (this.trackPosition) {
3062
+ this.position = this.line = this.column = 0;
3000
3063
  }
3001
- module.exports = Builder;
3064
+ this.emit("onready");
3002
3065
  }
3003
- });
3066
+ resume() {
3067
+ this.error = null;
3068
+ return this;
3069
+ }
3070
+ close() {
3071
+ return this.write(null);
3072
+ }
3073
+ flush() {
3074
+ this.flushBuffers();
3075
+ }
3076
+ };
3077
+ __publicField(SAXParser, "ENTITIES", ENTITIES);
3004
3078
 
3005
- // ../../node_modules/fast-xml-parser/src/fxp.js
3006
- var require_fxp = __commonJS({
3007
- "../../node_modules/fast-xml-parser/src/fxp.js"(exports, module) {
3008
- "use strict";
3009
- var validator = require_validator();
3010
- var XMLParser = require_XMLParser();
3011
- var XMLBuilder = require_json2xml();
3012
- module.exports = {
3013
- XMLParser,
3014
- XMLValidator: validator,
3015
- XMLBuilder
3016
- };
3079
+ // src/lib/xml-utils/uncapitalize.ts
3080
+ function uncapitalize(str) {
3081
+ return typeof str === "string" ? str.charAt(0).toLowerCase() + str.slice(1) : str;
3082
+ }
3083
+ function uncapitalizeKeys(object) {
3084
+ if (Array.isArray(object)) {
3085
+ return object.map((element) => uncapitalizeKeys(element));
3017
3086
  }
3018
- });
3087
+ if (object && typeof object === "object") {
3088
+ const newObject = {};
3089
+ for (const [key, value] of Object.entries(object)) {
3090
+ newObject[uncapitalize(key)] = uncapitalizeKeys(value);
3091
+ }
3092
+ return newObject;
3093
+ }
3094
+ return object;
3095
+ }
3019
3096
 
3020
3097
  // src/lib/parsers/parse-xml.ts
3098
+ var import_fast_xml_parser = __toESM(require_fxp(), 1);
3021
3099
  function parseXMLSync(text, options) {
3022
3100
  if (options?._parser && options._parser !== "fast-xml-parser") {
3023
3101
  throw new Error(options?._parser);
@@ -3045,56 +3123,48 @@ Actual: ${this.attribValue}`);
3045
3123
  const parsedXML = parser.parse(text);
3046
3124
  return parsedXML;
3047
3125
  }
3048
- var import_fast_xml_parser;
3049
- var init_parse_xml = __esm({
3050
- "src/lib/parsers/parse-xml.ts"() {
3051
- init_uncapitalize();
3052
- import_fast_xml_parser = __toModule(require_fxp());
3053
- }
3054
- });
3055
3126
 
3056
3127
  // src/xml-loader.ts
3128
+ var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3129
+ var XMLLoader = {
3130
+ name: "XML",
3131
+ id: "xml",
3132
+ module: "xml",
3133
+ version: VERSION,
3134
+ worker: false,
3135
+ extensions: ["xml"],
3136
+ mimeTypes: ["application/xml", "text/xml"],
3137
+ testText: testXMLFile,
3138
+ options: {
3139
+ xml: {
3140
+ _parser: "fast-xml-parser",
3141
+ uncapitalizeKeys: false,
3142
+ removeNSPrefix: false,
3143
+ textNodeName: "value",
3144
+ arrayPaths: []
3145
+ }
3146
+ },
3147
+ parse: async (arrayBuffer, options) => parseXMLSync(new TextDecoder().decode(arrayBuffer), {
3148
+ ...XMLLoader.options.xml,
3149
+ ...options?.xml
3150
+ }),
3151
+ parseTextSync: (text, options) => parseXMLSync(text, {
3152
+ ...XMLLoader.options.xml,
3153
+ ...options?.xml
3154
+ })
3155
+ };
3057
3156
  function testXMLFile(text) {
3058
3157
  return text.startsWith("<?xml");
3059
3158
  }
3060
- var VERSION, XMLLoader;
3061
- var init_xml_loader = __esm({
3062
- "src/xml-loader.ts"() {
3063
- init_parse_xml();
3064
- VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3065
- XMLLoader = {
3066
- name: "XML",
3067
- id: "xml",
3068
- module: "xml",
3069
- version: VERSION,
3070
- worker: false,
3071
- extensions: ["xml"],
3072
- mimeTypes: ["application/xml", "text/xml"],
3073
- testText: testXMLFile,
3074
- options: {
3075
- xml: {
3076
- _parser: "fast-xml-parser",
3077
- uncapitalizeKeys: false,
3078
- removeNSPrefix: false,
3079
- textNodeName: "value",
3080
- arrayPaths: []
3081
- }
3082
- },
3083
- parse: async (arrayBuffer, options) => parseXMLSync(new TextDecoder().decode(arrayBuffer), {
3084
- ...XMLLoader.options.xml,
3085
- ...options?.xml
3086
- }),
3087
- parseTextSync: (text, options) => parseXMLSync(text, { ...XMLLoader.options.xml, ...options?.xml })
3088
- };
3089
- }
3090
- });
3091
3159
 
3092
3160
  // ../loader-utils/src/lib/option-utils/merge-loader-options.ts
3093
3161
  function mergeLoaderOptions(baseOptions, newOptions) {
3094
3162
  return mergeOptionsRecursively(baseOptions || {}, newOptions);
3095
3163
  }
3096
3164
  function mergeOptionsRecursively(baseOptions, newOptions) {
3097
- const options = { ...baseOptions };
3165
+ const options = {
3166
+ ...baseOptions
3167
+ };
3098
3168
  for (const [key, newValue] of Object.entries(newOptions)) {
3099
3169
  if (newValue && typeof newValue === "object" && !Array.isArray(newValue)) {
3100
3170
  options[key] = mergeOptionsRecursively(options[key] || {}, newOptions[key]);
@@ -3104,19 +3174,18 @@ Actual: ${this.attribValue}`);
3104
3174
  }
3105
3175
  return options;
3106
3176
  }
3107
- var init_merge_loader_options = __esm({
3108
- "../loader-utils/src/lib/option-utils/merge-loader-options.ts"() {
3109
- }
3110
- });
3111
-
3112
- // ../loader-utils/src/index.ts
3113
- var init_src = __esm({
3114
- "../loader-utils/src/index.ts"() {
3115
- init_merge_loader_options();
3116
- }
3117
- });
3118
3177
 
3119
3178
  // src/html-loader.ts
3179
+ var HTMLLoader = {
3180
+ ...XMLLoader,
3181
+ name: "HTML",
3182
+ id: "html",
3183
+ extensions: ["html", "htm"],
3184
+ mimeTypes: ["text/html"],
3185
+ testText: testHTMLFile,
3186
+ parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
3187
+ parseTextSync: (text, options) => parseTextSync(text, options)
3188
+ };
3120
3189
  function testHTMLFile(text) {
3121
3190
  return text.startsWith("<html");
3122
3191
  }
@@ -3131,23 +3200,6 @@ Actual: ${this.attribValue}`);
3131
3200
  });
3132
3201
  return XMLLoader.parseTextSync?.(text, options);
3133
3202
  }
3134
- var HTMLLoader;
3135
- var init_html_loader = __esm({
3136
- "src/html-loader.ts"() {
3137
- init_src();
3138
- init_xml_loader();
3139
- HTMLLoader = {
3140
- ...XMLLoader,
3141
- name: "HTML",
3142
- id: "html",
3143
- extensions: ["html", "htm"],
3144
- mimeTypes: ["text/html"],
3145
- testText: testHTMLFile,
3146
- parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
3147
- parseTextSync: (text, options) => parseTextSync(text, options)
3148
- };
3149
- }
3150
- });
3151
3203
 
3152
3204
  // src/lib/xml-utils/xml-utils.ts
3153
3205
  function convertXMLValueToArray(xmlValue) {
@@ -3164,39 +3216,7 @@ Actual: ${this.attribValue}`);
3164
3216
  function convertXMLFieldToArrayInPlace(xml, key) {
3165
3217
  xml[key] = convertXMLValueToArray(xml[key]);
3166
3218
  }
3167
- var init_xml_utils = __esm({
3168
- "src/lib/xml-utils/xml-utils.ts"() {
3169
- }
3170
- });
3171
-
3172
- // src/index.ts
3173
- var src_exports = {};
3174
- __export(src_exports, {
3175
- HTMLLoader: () => HTMLLoader,
3176
- SAXParser: () => SAXParser,
3177
- XMLLoader: () => XMLLoader,
3178
- _uncapitalize: () => uncapitalize,
3179
- _uncapitalizeKeys: () => uncapitalizeKeys,
3180
- convertXMLFieldToArrayInPlace: () => convertXMLFieldToArrayInPlace,
3181
- convertXMLValueToArray: () => convertXMLValueToArray
3182
- });
3183
- var init_src2 = __esm({
3184
- "src/index.ts"() {
3185
- init_xml_loader();
3186
- init_html_loader();
3187
- init_sax();
3188
- init_xml_utils();
3189
- init_uncapitalize();
3190
- }
3191
- });
3192
-
3193
- // src/bundle.ts
3194
- var require_bundle = __commonJS({
3195
- "src/bundle.ts"(exports, module) {
3196
- var moduleExports = (init_src2(), src_exports);
3197
- globalThis.loaders = globalThis.loaders || {};
3198
- module.exports = Object.assign(globalThis.loaders, moduleExports);
3199
- }
3200
- });
3201
- require_bundle();
3219
+ return __toCommonJS(src_exports);
3202
3220
  })();
3221
+ return __exports__;
3222
+ });