svg-eslint-parser 0.0.7 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -14
- package/dist/chunk-pbuEa-1d.js +13 -0
- package/dist/index.d.ts +31 -23
- package/dist/index.js +434 -506
- package/package.json +31 -29
- package/dist/chunk-CzXV76rE.js +0 -18
package/dist/index.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import { t as __exportAll } from "./chunk-
|
|
1
|
+
import { t as __exportAll } from "./chunk-pbuEa-1d.js";
|
|
2
2
|
import { unionWith } from "eslint-visitor-keys";
|
|
3
|
-
|
|
4
|
-
//#region package.json
|
|
5
|
-
var name$1 = "svg-eslint-parser";
|
|
6
|
-
var version = "0.0.7";
|
|
7
|
-
|
|
8
3
|
//#endregion
|
|
9
4
|
//#region src/meta.ts
|
|
10
5
|
const meta = {
|
|
11
|
-
name:
|
|
12
|
-
version
|
|
6
|
+
name: "svg-eslint-parser",
|
|
7
|
+
version: "0.1.0"
|
|
13
8
|
};
|
|
14
|
-
|
|
15
9
|
//#endregion
|
|
16
10
|
//#region src/parser/error.ts
|
|
17
11
|
/**
|
|
@@ -29,7 +23,6 @@ var ParseError = class extends SyntaxError {
|
|
|
29
23
|
this.column = column;
|
|
30
24
|
}
|
|
31
25
|
};
|
|
32
|
-
|
|
33
26
|
//#endregion
|
|
34
27
|
//#region src/constants/parse.ts
|
|
35
28
|
/**
|
|
@@ -52,23 +45,22 @@ const XML_DECLARATION_END = "?>";
|
|
|
52
45
|
* regexp for open tag start
|
|
53
46
|
* @regex101 https://regex101.com/?regex=%5E%3C%5Cw&flavor=javascript
|
|
54
47
|
*/
|
|
55
|
-
const RE_OPEN_TAG_START = /^<\w
|
|
48
|
+
const RE_OPEN_TAG_START = /^<\w/u;
|
|
56
49
|
/**
|
|
57
50
|
* regexp for open tag name
|
|
58
51
|
* @regex101 https://regex101.com/?regex=%5E%3C%28%5CS%2B%29&flavor=javascript
|
|
59
52
|
*/
|
|
60
|
-
const RE_OPEN_TAG_NAME = /^<(\S+)
|
|
53
|
+
const RE_OPEN_TAG_NAME = /^<(\S+)/u;
|
|
61
54
|
/**
|
|
62
55
|
* regexp for close tag name
|
|
63
56
|
* @regex101 https://regex101.com/?regex=%5E%3C%5C%2F%28%28%3F%3A.%7C%5Cr%3F%5Cn%29*%29%3E%24&flavor=javascript
|
|
64
57
|
*/
|
|
65
|
-
const RE_CLOSE_TAG_NAME = /^<\/((?:.|\r?\n)*)
|
|
58
|
+
const RE_CLOSE_TAG_NAME = /^<\/((?:.|\r?\n)*)>$/u;
|
|
66
59
|
/**
|
|
67
60
|
* regexp for incomplete closing tag
|
|
68
61
|
* @regex101 https://regex101.com/?regex=%3C%5C%2F%5B%5E%3E%5D%2B%24&flavor=javascript
|
|
69
62
|
*/
|
|
70
|
-
const RE_INCOMPLETE_CLOSING_TAG = /<\/[^>]
|
|
71
|
-
|
|
63
|
+
const RE_INCOMPLETE_CLOSING_TAG = /<\/[^>]+$/u;
|
|
72
64
|
//#endregion
|
|
73
65
|
//#region src/constants/nodeTypes.ts
|
|
74
66
|
let NodeTypes = /* @__PURE__ */ function(NodeTypes) {
|
|
@@ -80,9 +72,11 @@ let NodeTypes = /* @__PURE__ */ function(NodeTypes) {
|
|
|
80
72
|
NodeTypes["DoctypeAttribute"] = "DoctypeAttribute";
|
|
81
73
|
NodeTypes["DoctypeAttributeValue"] = "DoctypeAttributeValue";
|
|
82
74
|
NodeTypes["Document"] = "Document";
|
|
75
|
+
NodeTypes["Element"] = "Element";
|
|
83
76
|
NodeTypes["Error"] = "Error";
|
|
84
77
|
NodeTypes["Program"] = "Program";
|
|
85
|
-
|
|
78
|
+
/** @deprecated Use Element instead. */
|
|
79
|
+
NodeTypes["Tag"] = "Element";
|
|
86
80
|
NodeTypes["Text"] = "Text";
|
|
87
81
|
NodeTypes["XMLDeclaration"] = "XMLDeclaration";
|
|
88
82
|
NodeTypes["XMLDeclarationAttribute"] = "XMLDeclarationAttribute";
|
|
@@ -90,7 +84,6 @@ let NodeTypes = /* @__PURE__ */ function(NodeTypes) {
|
|
|
90
84
|
NodeTypes["XMLDeclarationAttributeValue"] = "XMLDeclarationAttributeValue";
|
|
91
85
|
return NodeTypes;
|
|
92
86
|
}({});
|
|
93
|
-
|
|
94
87
|
//#endregion
|
|
95
88
|
//#region src/constants/tokenTypes.ts
|
|
96
89
|
let TokenTypes = /* @__PURE__ */ function(TokenTypes) {
|
|
@@ -138,7 +131,6 @@ let TokenTypes = /* @__PURE__ */ function(TokenTypes) {
|
|
|
138
131
|
TokenTypes["XMLDeclarationOpen"] = "XMLDeclarationOpen";
|
|
139
132
|
return TokenTypes;
|
|
140
133
|
}({});
|
|
141
|
-
|
|
142
134
|
//#endregion
|
|
143
135
|
//#region src/constants/specialChar.ts
|
|
144
136
|
const SPECIAL_CHAR = {
|
|
@@ -158,7 +150,6 @@ const SPECIAL_CHAR = {
|
|
|
158
150
|
space: ` `,
|
|
159
151
|
tab: `\t`
|
|
160
152
|
};
|
|
161
|
-
|
|
162
153
|
//#endregion
|
|
163
154
|
//#region src/constants/svgElements.ts
|
|
164
155
|
/**
|
|
@@ -292,7 +283,6 @@ const SELF_CLOSING_ELEMENTS = new Set([
|
|
|
292
283
|
"use",
|
|
293
284
|
"view"
|
|
294
285
|
]);
|
|
295
|
-
|
|
296
286
|
//#endregion
|
|
297
287
|
//#region src/constants/tokenizerContextTypes.ts
|
|
298
288
|
let TokenizerContextTypes = /* @__PURE__ */ function(TokenizerContextTypes) {
|
|
@@ -321,7 +311,6 @@ let TokenizerContextTypes = /* @__PURE__ */ function(TokenizerContextTypes) {
|
|
|
321
311
|
TokenizerContextTypes["XMLDeclarationOpen"] = "XMLDeclarationOpen";
|
|
322
312
|
return TokenizerContextTypes;
|
|
323
313
|
}({});
|
|
324
|
-
|
|
325
314
|
//#endregion
|
|
326
315
|
//#region src/constants/constructTreeContextTypes.ts
|
|
327
316
|
let ConstructTreeContextTypes = /* @__PURE__ */ function(ConstructTreeContextTypes) {
|
|
@@ -341,7 +330,6 @@ let ConstructTreeContextTypes = /* @__PURE__ */ function(ConstructTreeContextTyp
|
|
|
341
330
|
ConstructTreeContextTypes["XMLDeclarationAttributeValue"] = "XMLDeclarationAttributeValue";
|
|
342
331
|
return ConstructTreeContextTypes;
|
|
343
332
|
}({});
|
|
344
|
-
|
|
345
333
|
//#endregion
|
|
346
334
|
//#region src/utils/cloneNode.ts
|
|
347
335
|
/**
|
|
@@ -354,7 +342,7 @@ function cloneNode(node) {
|
|
|
354
342
|
if (Array.isArray(node)) return node.map((item) => cloneNode(item));
|
|
355
343
|
const cloned = {};
|
|
356
344
|
for (const key in node) {
|
|
357
|
-
if (!Object.
|
|
345
|
+
if (!Object.hasOwn(node, key)) continue;
|
|
358
346
|
if (key === "parentRef" || key === "parent") continue;
|
|
359
347
|
const value = node[key];
|
|
360
348
|
if (value && typeof value === "object") if (Array.isArray(value)) cloned[key] = value.map((item) => cloneNode(item));
|
|
@@ -374,7 +362,7 @@ function cloneNodeWithParent(node, parent) {
|
|
|
374
362
|
if (Array.isArray(node)) return node.map((item) => cloneNodeWithParent(item));
|
|
375
363
|
const cloned = {};
|
|
376
364
|
for (const key in node) {
|
|
377
|
-
if (!Object.
|
|
365
|
+
if (!Object.hasOwn(node, key)) continue;
|
|
378
366
|
if (key === "parentRef" || key === "parent") continue;
|
|
379
367
|
const value = node[key];
|
|
380
368
|
if (value && typeof value === "object") if (Array.isArray(value)) cloned[key] = value.map((item) => cloneNodeWithParent(item, cloned));
|
|
@@ -384,7 +372,6 @@ function cloneNodeWithParent(node, parent) {
|
|
|
384
372
|
if (parent) cloned.parentRef = parent;
|
|
385
373
|
return cloned;
|
|
386
374
|
}
|
|
387
|
-
|
|
388
375
|
//#endregion
|
|
389
376
|
//#region src/utils/firstLast.ts
|
|
390
377
|
/**
|
|
@@ -403,7 +390,6 @@ function first(items) {
|
|
|
403
390
|
function last(items) {
|
|
404
391
|
return items[items.length - 1];
|
|
405
392
|
}
|
|
406
|
-
|
|
407
393
|
//#endregion
|
|
408
394
|
//#region src/utils/cloneRange.ts
|
|
409
395
|
/**
|
|
@@ -414,7 +400,6 @@ function last(items) {
|
|
|
414
400
|
function cloneRange(range) {
|
|
415
401
|
return [range[0], range[1]];
|
|
416
402
|
}
|
|
417
|
-
|
|
418
403
|
//#endregion
|
|
419
404
|
//#region src/utils/initIfNone.ts
|
|
420
405
|
/**
|
|
@@ -433,7 +418,6 @@ function initChildrenIfNone(node) {
|
|
|
433
418
|
function initAttributesIfNone(node) {
|
|
434
419
|
if (!node.attributes) node.attributes = [];
|
|
435
420
|
}
|
|
436
|
-
|
|
437
421
|
//#endregion
|
|
438
422
|
//#region src/utils/clearParent.ts
|
|
439
423
|
/**
|
|
@@ -444,12 +428,9 @@ function initAttributesIfNone(node) {
|
|
|
444
428
|
function clearParent(ast) {
|
|
445
429
|
const cleanAst = ast;
|
|
446
430
|
delete cleanAst.parentRef;
|
|
447
|
-
if (Array.isArray(ast.children)) cleanAst.children = ast.children.map((node) =>
|
|
448
|
-
return clearParent(node);
|
|
449
|
-
});
|
|
431
|
+
if (Array.isArray(ast.children)) cleanAst.children = ast.children.map((node) => clearParent(node));
|
|
450
432
|
return cleanAst;
|
|
451
433
|
}
|
|
452
|
-
|
|
453
434
|
//#endregion
|
|
454
435
|
//#region src/utils/getLineInfo.ts
|
|
455
436
|
/**
|
|
@@ -492,7 +473,6 @@ function getLineInfo(input, offset) {
|
|
|
492
473
|
cur = nextBreak;
|
|
493
474
|
}
|
|
494
475
|
}
|
|
495
|
-
|
|
496
476
|
//#endregion
|
|
497
477
|
//#region src/utils/nodeHelpers.ts
|
|
498
478
|
/**
|
|
@@ -503,12 +483,12 @@ function getLineInfo(input, offset) {
|
|
|
503
483
|
*/
|
|
504
484
|
function filterNodes(node, predicate) {
|
|
505
485
|
const results = [];
|
|
506
|
-
function traverse
|
|
486
|
+
function traverse(currentNode) {
|
|
507
487
|
if (predicate(currentNode)) results.push(currentNode);
|
|
508
|
-
if ("children" in currentNode && Array.isArray(currentNode.children)) for (const child of currentNode.children) traverse
|
|
509
|
-
if ("attributes" in currentNode && Array.isArray(currentNode.attributes)) for (const attr of currentNode.attributes) traverse
|
|
488
|
+
if ("children" in currentNode && Array.isArray(currentNode.children)) for (const child of currentNode.children) traverse(child);
|
|
489
|
+
if ("attributes" in currentNode && Array.isArray(currentNode.attributes)) for (const attr of currentNode.attributes) traverse(attr);
|
|
510
490
|
}
|
|
511
|
-
traverse
|
|
491
|
+
traverse(node);
|
|
512
492
|
return results;
|
|
513
493
|
}
|
|
514
494
|
/**
|
|
@@ -562,7 +542,6 @@ function countNodes(node) {
|
|
|
562
542
|
if ("attributes" in node && Array.isArray(node.attributes)) for (const attr of node.attributes) count += countNodes(attr);
|
|
563
543
|
return count;
|
|
564
544
|
}
|
|
565
|
-
|
|
566
545
|
//#endregion
|
|
567
546
|
//#region src/utils/traverseAST.ts
|
|
568
547
|
/**
|
|
@@ -590,7 +569,6 @@ function traverseAST(node, visitor, parent = null) {
|
|
|
590
569
|
function walkAST(node, callback) {
|
|
591
570
|
traverseAST(node, { enter: callback });
|
|
592
571
|
}
|
|
593
|
-
|
|
594
572
|
//#endregion
|
|
595
573
|
//#region src/utils/isWhitespace.ts
|
|
596
574
|
/**
|
|
@@ -601,30 +579,9 @@ function walkAST(node, callback) {
|
|
|
601
579
|
function isWhitespace(char) {
|
|
602
580
|
return char === SPECIAL_CHAR.space || char === SPECIAL_CHAR.newline || char === SPECIAL_CHAR.return || char === SPECIAL_CHAR.tab;
|
|
603
581
|
}
|
|
604
|
-
|
|
605
582
|
//#endregion
|
|
606
583
|
//#region src/utils/validateNode.ts
|
|
607
|
-
|
|
608
|
-
* Validate if a node matches its expected structure
|
|
609
|
-
* @param node - Node to validate
|
|
610
|
-
* @returns True if node is valid
|
|
611
|
-
*/
|
|
612
|
-
function validateNode(node) {
|
|
613
|
-
if (!node || typeof node !== "object") return false;
|
|
614
|
-
if (!("type" in node) || !("range" in node) || !("loc" in node)) return false;
|
|
615
|
-
if (!Array.isArray(node.range) || node.range.length !== 2 || typeof node.range[0] !== "number" || typeof node.range[1] !== "number") return false;
|
|
616
|
-
if (!node.loc || !node.loc.start || !node.loc.end || typeof node.loc.start.line !== "number" || typeof node.loc.start.column !== "number" || typeof node.loc.end.line !== "number" || typeof node.loc.end.column !== "number") return false;
|
|
617
|
-
switch (node.type) {
|
|
618
|
-
case NodeTypes.Tag: return validateTagNode(node);
|
|
619
|
-
case NodeTypes.Attribute: return validateAttributeNode(node);
|
|
620
|
-
case NodeTypes.Text: return validateTextNode(node);
|
|
621
|
-
case NodeTypes.Comment: return validateCommentNode(node);
|
|
622
|
-
case NodeTypes.Document: return validateDocumentNode(node);
|
|
623
|
-
case NodeTypes.Doctype: return validateDoctypeNode(node);
|
|
624
|
-
default: return true;
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
function validateTagNode(node) {
|
|
584
|
+
function validateElementNode(node) {
|
|
628
585
|
if (!("name" in node) || typeof node.name !== "string") return false;
|
|
629
586
|
if ("children" in node && !Array.isArray(node.children)) return false;
|
|
630
587
|
if ("attributes" in node && !Array.isArray(node.attributes)) return false;
|
|
@@ -649,6 +606,27 @@ function validateDoctypeNode(node) {
|
|
|
649
606
|
return true;
|
|
650
607
|
}
|
|
651
608
|
/**
|
|
609
|
+
* Validate if a node matches its expected structure
|
|
610
|
+
* @param node - Node to validate
|
|
611
|
+
* @returns True if node is valid
|
|
612
|
+
*/
|
|
613
|
+
function validateNode(node) {
|
|
614
|
+
if (!node || typeof node !== "object") return false;
|
|
615
|
+
if (!("type" in node) || !("range" in node) || !("loc" in node)) return false;
|
|
616
|
+
if (!Array.isArray(node.range) || node.range.length !== 2 || typeof node.range[0] !== "number" || typeof node.range[1] !== "number") return false;
|
|
617
|
+
if (!node.loc || !node.loc.start || !node.loc.end || typeof node.loc.start.line !== "number" || typeof node.loc.start.column !== "number" || typeof node.loc.end.line !== "number" || typeof node.loc.end.column !== "number") return false;
|
|
618
|
+
switch (node.type) {
|
|
619
|
+
case "Element":
|
|
620
|
+
case "Element": return validateElementNode(node);
|
|
621
|
+
case "Attribute": return validateAttributeNode(node);
|
|
622
|
+
case "Text": return validateTextNode(node);
|
|
623
|
+
case "Comment": return validateCommentNode(node);
|
|
624
|
+
case "Document": return validateDocumentNode(node);
|
|
625
|
+
case "Doctype": return validateDoctypeNode(node);
|
|
626
|
+
default: return true;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
652
630
|
* Check if a node is of a specific type with type guard
|
|
653
631
|
* @param node - Node to check
|
|
654
632
|
* @param type - Expected node type
|
|
@@ -657,7 +635,6 @@ function validateDoctypeNode(node) {
|
|
|
657
635
|
function isNodeType(node, type) {
|
|
658
636
|
return node.type === type;
|
|
659
637
|
}
|
|
660
|
-
|
|
661
638
|
//#endregion
|
|
662
639
|
//#region src/utils/cloneLocation.ts
|
|
663
640
|
/**
|
|
@@ -677,7 +654,6 @@ function cloneLocation(loc) {
|
|
|
677
654
|
}
|
|
678
655
|
};
|
|
679
656
|
}
|
|
680
|
-
|
|
681
657
|
//#endregion
|
|
682
658
|
//#region src/utils/updateNodeEnd.ts
|
|
683
659
|
/**
|
|
@@ -689,7 +665,6 @@ function updateNodeEnd(node, token) {
|
|
|
689
665
|
node.range[1] = token.range[1];
|
|
690
666
|
node.loc.end = { ...token.loc.end };
|
|
691
667
|
}
|
|
692
|
-
|
|
693
668
|
//#endregion
|
|
694
669
|
//#region src/utils/createNodeFrom.ts
|
|
695
670
|
/**
|
|
@@ -707,7 +682,6 @@ function createNodeFrom(token) {
|
|
|
707
682
|
range
|
|
708
683
|
};
|
|
709
684
|
}
|
|
710
|
-
|
|
711
685
|
//#endregion
|
|
712
686
|
//#region src/utils/findNodeByType.ts
|
|
713
687
|
/**
|
|
@@ -718,12 +692,12 @@ function createNodeFrom(token) {
|
|
|
718
692
|
*/
|
|
719
693
|
function findNodeByType(node, type) {
|
|
720
694
|
const results = [];
|
|
721
|
-
function traverse
|
|
695
|
+
function traverse(currentNode) {
|
|
722
696
|
if (currentNode.type === type) results.push(currentNode);
|
|
723
|
-
if ("children" in currentNode && Array.isArray(currentNode.children)) for (const child of currentNode.children) traverse
|
|
724
|
-
if ("attributes" in currentNode && Array.isArray(currentNode.attributes)) for (const attr of currentNode.attributes) traverse
|
|
697
|
+
if ("children" in currentNode && Array.isArray(currentNode.children)) for (const child of currentNode.children) traverse(child);
|
|
698
|
+
if ("attributes" in currentNode && Array.isArray(currentNode.attributes)) for (const attr of currentNode.attributes) traverse(attr);
|
|
725
699
|
}
|
|
726
|
-
traverse
|
|
700
|
+
traverse(node);
|
|
727
701
|
return results;
|
|
728
702
|
}
|
|
729
703
|
/**
|
|
@@ -733,27 +707,25 @@ function findNodeByType(node, type) {
|
|
|
733
707
|
* @returns First matching node or undefined
|
|
734
708
|
*/
|
|
735
709
|
function findFirstNodeByType(node, type) {
|
|
736
|
-
function traverse
|
|
710
|
+
function traverse(currentNode) {
|
|
737
711
|
if (currentNode.type === type) return currentNode;
|
|
738
712
|
if ("children" in currentNode && Array.isArray(currentNode.children)) for (const child of currentNode.children) {
|
|
739
|
-
const result = traverse
|
|
713
|
+
const result = traverse(child);
|
|
740
714
|
if (result) return result;
|
|
741
715
|
}
|
|
742
716
|
if ("attributes" in currentNode && Array.isArray(currentNode.attributes)) for (const attr of currentNode.attributes) {
|
|
743
|
-
const result = traverse
|
|
717
|
+
const result = traverse(attr);
|
|
744
718
|
if (result) return result;
|
|
745
719
|
}
|
|
746
720
|
}
|
|
747
|
-
return traverse
|
|
721
|
+
return traverse(node);
|
|
748
722
|
}
|
|
749
|
-
|
|
750
723
|
//#endregion
|
|
751
724
|
//#region src/utils/getLastAttribute.ts
|
|
752
725
|
function getLastAttribute(state) {
|
|
753
726
|
const attributes = state.currentNode.attributes;
|
|
754
727
|
return last(attributes);
|
|
755
728
|
}
|
|
756
|
-
|
|
757
729
|
//#endregion
|
|
758
730
|
//#region src/utils/parseOpenTagName.ts
|
|
759
731
|
/**
|
|
@@ -767,7 +739,6 @@ function parseOpenTagName(openTagStartTokenContent) {
|
|
|
767
739
|
if (match === null) throw new Error(`Unable to parse open tag name.\n${openTagStartTokenContent} does not match pattern of opening tag.`);
|
|
768
740
|
return match[1].toLowerCase();
|
|
769
741
|
}
|
|
770
|
-
|
|
771
742
|
//#endregion
|
|
772
743
|
//#region src/utils/parseCloseTagName.ts
|
|
773
744
|
/**
|
|
@@ -781,7 +752,6 @@ function parseCloseTagName(closeTagTokenContent) {
|
|
|
781
752
|
if (match === null) throw new Error(`Unable to parse close tag name.\n${closeTagTokenContent} does not match pattern of closing tag.`);
|
|
782
753
|
return match[1].trim().toLowerCase();
|
|
783
754
|
}
|
|
784
|
-
|
|
785
755
|
//#endregion
|
|
786
756
|
//#region src/utils/calculateTokenLocation.ts
|
|
787
757
|
/**
|
|
@@ -796,7 +766,6 @@ function calculateTokenLocation(source, range) {
|
|
|
796
766
|
end: getLineInfo(source, range[1])
|
|
797
767
|
};
|
|
798
768
|
}
|
|
799
|
-
|
|
800
769
|
//#endregion
|
|
801
770
|
//#region src/utils/calculateTokenCharactersRange.ts
|
|
802
771
|
/**
|
|
@@ -808,12 +777,11 @@ function calculateTokenLocation(source, range) {
|
|
|
808
777
|
*/
|
|
809
778
|
function calculateTokenCharactersRange(state, options) {
|
|
810
779
|
const startPosition = state.sourceCode.index() - (state.accumulatedContent.length() - 1) - state.decisionBuffer.length();
|
|
811
|
-
let endPosition;
|
|
780
|
+
let endPosition = 0;
|
|
812
781
|
if (options.keepBuffer) endPosition = state.sourceCode.index();
|
|
813
782
|
else endPosition = state.sourceCode.index() - state.decisionBuffer.length();
|
|
814
783
|
return [startPosition, endPosition + 1];
|
|
815
784
|
}
|
|
816
|
-
|
|
817
785
|
//#endregion
|
|
818
786
|
//#region src/utils/calculateTokenPosition.ts
|
|
819
787
|
/**
|
|
@@ -830,7 +798,6 @@ function calculateTokenPosition(state, options) {
|
|
|
830
798
|
loc: calculateTokenLocation(state.sourceCode.source, range)
|
|
831
799
|
};
|
|
832
800
|
}
|
|
833
|
-
|
|
834
801
|
//#endregion
|
|
835
802
|
//#region src/constructor/handlerFactory.ts
|
|
836
803
|
/**
|
|
@@ -846,35 +813,33 @@ function createTokenDispatcher(handlers, defaultHandler) {
|
|
|
846
813
|
return state;
|
|
847
814
|
};
|
|
848
815
|
}
|
|
849
|
-
|
|
850
816
|
//#endregion
|
|
851
817
|
//#region src/constructor/handlers/tag.ts
|
|
852
818
|
var tag_exports = /* @__PURE__ */ __exportAll({ construct: () => construct$13 });
|
|
853
|
-
const ATTRIBUTE_START_TOKENS$3 = new Set([TokenTypes.AttributeKey, TokenTypes.AttributeAssignment]);
|
|
854
819
|
const dispatch$13 = createTokenDispatcher([
|
|
855
820
|
{
|
|
856
|
-
tokenType:
|
|
821
|
+
tokenType: "OpenTagStart",
|
|
857
822
|
handler(token, state) {
|
|
858
823
|
state.currentNode.openStart = createNodeFrom(token);
|
|
859
824
|
state.currentContext = {
|
|
860
825
|
parentRef: state.currentContext,
|
|
861
|
-
type:
|
|
826
|
+
type: "TagName"
|
|
862
827
|
};
|
|
863
828
|
return state;
|
|
864
829
|
}
|
|
865
830
|
},
|
|
866
831
|
{
|
|
867
|
-
tokenType:
|
|
832
|
+
tokenType: new Set(["AttributeKey", "AttributeAssignment"]),
|
|
868
833
|
handler(_, state) {
|
|
869
834
|
state.currentContext = {
|
|
870
835
|
parentRef: state.currentContext,
|
|
871
|
-
type:
|
|
836
|
+
type: "Attributes"
|
|
872
837
|
};
|
|
873
838
|
return state;
|
|
874
839
|
}
|
|
875
840
|
},
|
|
876
841
|
{
|
|
877
|
-
tokenType:
|
|
842
|
+
tokenType: "OpenTagEnd",
|
|
878
843
|
handler(token, state) {
|
|
879
844
|
const tagName = state.currentNode.name;
|
|
880
845
|
state.currentNode.openEnd = createNodeFrom(token);
|
|
@@ -889,14 +854,14 @@ const dispatch$13 = createTokenDispatcher([
|
|
|
889
854
|
state.currentNode.selfClosing = false;
|
|
890
855
|
state.currentContext = {
|
|
891
856
|
parentRef: state.currentContext,
|
|
892
|
-
type:
|
|
857
|
+
type: "TagContent"
|
|
893
858
|
};
|
|
894
859
|
state.caretPosition++;
|
|
895
860
|
return state;
|
|
896
861
|
}
|
|
897
862
|
},
|
|
898
863
|
{
|
|
899
|
-
tokenType:
|
|
864
|
+
tokenType: "CloseTag",
|
|
900
865
|
handler(token, state) {
|
|
901
866
|
state.currentNode.close = createNodeFrom(token);
|
|
902
867
|
updateNodeEnd(state.currentNode, token);
|
|
@@ -913,20 +878,19 @@ const dispatch$13 = createTokenDispatcher([
|
|
|
913
878
|
function construct$13(token, state) {
|
|
914
879
|
return dispatch$13(token, state);
|
|
915
880
|
}
|
|
916
|
-
|
|
917
881
|
//#endregion
|
|
918
882
|
//#region src/constructor/handlers/comment.ts
|
|
919
883
|
var comment_exports = /* @__PURE__ */ __exportAll({ construct: () => construct$12 });
|
|
920
884
|
const dispatch$12 = createTokenDispatcher([
|
|
921
885
|
{
|
|
922
|
-
tokenType:
|
|
886
|
+
tokenType: "CommentOpen",
|
|
923
887
|
handler(_, state) {
|
|
924
888
|
state.caretPosition++;
|
|
925
889
|
return state;
|
|
926
890
|
}
|
|
927
891
|
},
|
|
928
892
|
{
|
|
929
|
-
tokenType:
|
|
893
|
+
tokenType: "CommentContent",
|
|
930
894
|
handler(token, state) {
|
|
931
895
|
state.currentNode.content = token.value;
|
|
932
896
|
state.caretPosition++;
|
|
@@ -934,7 +898,7 @@ const dispatch$12 = createTokenDispatcher([
|
|
|
934
898
|
}
|
|
935
899
|
},
|
|
936
900
|
{
|
|
937
|
-
tokenType:
|
|
901
|
+
tokenType: "CommentClose",
|
|
938
902
|
handler(token, state) {
|
|
939
903
|
updateNodeEnd(state.currentNode, token);
|
|
940
904
|
state.currentNode = state.currentNode.parentRef;
|
|
@@ -947,14 +911,12 @@ const dispatch$12 = createTokenDispatcher([
|
|
|
947
911
|
function construct$12(token, state) {
|
|
948
912
|
return dispatch$12(token, state);
|
|
949
913
|
}
|
|
950
|
-
|
|
951
914
|
//#endregion
|
|
952
915
|
//#region src/constructor/handlers/doctype.ts
|
|
953
916
|
var doctype_exports = /* @__PURE__ */ __exportAll({ construct: () => construct$11 });
|
|
954
|
-
const ATTRIBUTES_START_TOKENS = new Set([TokenTypes.DoctypeAttributeWrapperStart, TokenTypes.DoctypeAttributeValue]);
|
|
955
917
|
const dispatch$11 = createTokenDispatcher([
|
|
956
918
|
{
|
|
957
|
-
tokenType:
|
|
919
|
+
tokenType: "DoctypeOpen",
|
|
958
920
|
handler(token, state) {
|
|
959
921
|
state.currentNode.open = createNodeFrom(token);
|
|
960
922
|
state.caretPosition++;
|
|
@@ -962,7 +924,7 @@ const dispatch$11 = createTokenDispatcher([
|
|
|
962
924
|
}
|
|
963
925
|
},
|
|
964
926
|
{
|
|
965
|
-
tokenType:
|
|
927
|
+
tokenType: "DoctypeClose",
|
|
966
928
|
handler(token, state) {
|
|
967
929
|
state.currentNode.close = createNodeFrom(token);
|
|
968
930
|
updateNodeEnd(state.currentNode, token);
|
|
@@ -973,11 +935,11 @@ const dispatch$11 = createTokenDispatcher([
|
|
|
973
935
|
}
|
|
974
936
|
},
|
|
975
937
|
{
|
|
976
|
-
tokenType:
|
|
938
|
+
tokenType: new Set(["DoctypeAttributeWrapperStart", "DoctypeAttributeValue"]),
|
|
977
939
|
handler(_, state) {
|
|
978
940
|
state.currentContext = {
|
|
979
941
|
parentRef: state.currentContext,
|
|
980
|
-
type:
|
|
942
|
+
type: "DoctypeAttributes"
|
|
981
943
|
};
|
|
982
944
|
return state;
|
|
983
945
|
}
|
|
@@ -989,12 +951,11 @@ const dispatch$11 = createTokenDispatcher([
|
|
|
989
951
|
function construct$11(token, state) {
|
|
990
952
|
return dispatch$11(token, state);
|
|
991
953
|
}
|
|
992
|
-
|
|
993
954
|
//#endregion
|
|
994
955
|
//#region src/constructor/handlers/tagName.ts
|
|
995
956
|
var tagName_exports = /* @__PURE__ */ __exportAll({ construct: () => construct$10 });
|
|
996
957
|
const dispatch$10 = createTokenDispatcher([{
|
|
997
|
-
tokenType:
|
|
958
|
+
tokenType: "OpenTagStart",
|
|
998
959
|
handler(token, state) {
|
|
999
960
|
state.currentNode.name = parseOpenTagName(token.value);
|
|
1000
961
|
state.currentContext = state.currentContext.parentRef;
|
|
@@ -1008,20 +969,19 @@ const dispatch$10 = createTokenDispatcher([{
|
|
|
1008
969
|
function construct$10(token, state) {
|
|
1009
970
|
return dispatch$10(token, state);
|
|
1010
971
|
}
|
|
1011
|
-
|
|
1012
972
|
//#endregion
|
|
1013
973
|
//#region src/constructor/handlers/attribute.ts
|
|
1014
974
|
var attribute_exports = /* @__PURE__ */ __exportAll({ construct: () => construct$9 });
|
|
1015
975
|
const dispatch$9 = createTokenDispatcher([
|
|
1016
976
|
{
|
|
1017
|
-
tokenType: new Set([
|
|
977
|
+
tokenType: new Set(["OpenTagEnd"]),
|
|
1018
978
|
handler(_, state) {
|
|
1019
979
|
state.currentContext = state.currentContext.parentRef;
|
|
1020
980
|
return state;
|
|
1021
981
|
}
|
|
1022
982
|
},
|
|
1023
983
|
{
|
|
1024
|
-
tokenType:
|
|
984
|
+
tokenType: "AttributeKey",
|
|
1025
985
|
handler(token, state) {
|
|
1026
986
|
const attribute = getLastAttribute(state);
|
|
1027
987
|
if (attribute.key !== void 0 || attribute.value !== void 0) {
|
|
@@ -1034,7 +994,7 @@ const dispatch$9 = createTokenDispatcher([
|
|
|
1034
994
|
}
|
|
1035
995
|
},
|
|
1036
996
|
{
|
|
1037
|
-
tokenType:
|
|
997
|
+
tokenType: "AttributeAssignment",
|
|
1038
998
|
handler(_, state) {
|
|
1039
999
|
if (getLastAttribute(state).value !== void 0) {
|
|
1040
1000
|
state.currentContext = state.currentContext.parentRef;
|
|
@@ -1042,7 +1002,7 @@ const dispatch$9 = createTokenDispatcher([
|
|
|
1042
1002
|
}
|
|
1043
1003
|
state.currentContext = {
|
|
1044
1004
|
parentRef: state.currentContext,
|
|
1045
|
-
type:
|
|
1005
|
+
type: "AttributeValue"
|
|
1046
1006
|
};
|
|
1047
1007
|
state.caretPosition++;
|
|
1048
1008
|
return state;
|
|
@@ -1055,29 +1015,26 @@ const dispatch$9 = createTokenDispatcher([
|
|
|
1055
1015
|
function construct$9(token, state) {
|
|
1056
1016
|
return dispatch$9(token, state);
|
|
1057
1017
|
}
|
|
1058
|
-
|
|
1059
1018
|
//#endregion
|
|
1060
1019
|
//#region src/constructor/handlers/attributes.ts
|
|
1061
1020
|
var attributes_exports$1 = /* @__PURE__ */ __exportAll({ construct: () => construct$8 });
|
|
1062
|
-
const ATTRIBUTE_START_TOKENS$2 = new Set([TokenTypes.AttributeKey, TokenTypes.AttributeAssignment]);
|
|
1063
|
-
const ATTRIBUTE_END_TOKENS = new Set([TokenTypes.OpenTagEnd]);
|
|
1064
1021
|
const dispatch$8 = createTokenDispatcher([{
|
|
1065
|
-
tokenType:
|
|
1022
|
+
tokenType: new Set(["AttributeKey", "AttributeAssignment"]),
|
|
1066
1023
|
handler(token, state) {
|
|
1067
1024
|
initAttributesIfNone(state.currentNode);
|
|
1068
1025
|
state.currentNode.attributes.push({
|
|
1069
|
-
type:
|
|
1026
|
+
type: "Attribute",
|
|
1070
1027
|
range: cloneRange(token.range),
|
|
1071
1028
|
loc: cloneLocation(token.loc)
|
|
1072
1029
|
});
|
|
1073
1030
|
state.currentContext = {
|
|
1074
1031
|
parentRef: state.currentContext,
|
|
1075
|
-
type:
|
|
1032
|
+
type: "Attribute"
|
|
1076
1033
|
};
|
|
1077
1034
|
return state;
|
|
1078
1035
|
}
|
|
1079
1036
|
}, {
|
|
1080
|
-
tokenType:
|
|
1037
|
+
tokenType: new Set(["OpenTagEnd"]),
|
|
1081
1038
|
handler(_, state) {
|
|
1082
1039
|
state.currentContext = state.currentContext.parentRef;
|
|
1083
1040
|
return state;
|
|
@@ -1089,17 +1046,16 @@ const dispatch$8 = createTokenDispatcher([{
|
|
|
1089
1046
|
function construct$8(token, state) {
|
|
1090
1047
|
return dispatch$8(token, state);
|
|
1091
1048
|
}
|
|
1092
|
-
|
|
1093
1049
|
//#endregion
|
|
1094
1050
|
//#region src/constructor/handlers/tagContent.ts
|
|
1095
1051
|
var tagContent_exports = /* @__PURE__ */ __exportAll({ construct: () => construct$7 });
|
|
1096
1052
|
const dispatch$7 = createTokenDispatcher([
|
|
1097
1053
|
{
|
|
1098
|
-
tokenType:
|
|
1054
|
+
tokenType: "OpenTagStart",
|
|
1099
1055
|
handler(token, state) {
|
|
1100
1056
|
initChildrenIfNone(state.currentNode);
|
|
1101
1057
|
const tagNode = {
|
|
1102
|
-
type:
|
|
1058
|
+
type: "Element",
|
|
1103
1059
|
parentRef: state.currentNode,
|
|
1104
1060
|
range: cloneRange(token.range),
|
|
1105
1061
|
loc: cloneLocation(token.loc),
|
|
@@ -1110,13 +1066,37 @@ const dispatch$7 = createTokenDispatcher([
|
|
|
1110
1066
|
state.currentNode = tagNode;
|
|
1111
1067
|
state.currentContext = {
|
|
1112
1068
|
parentRef: state.currentContext,
|
|
1113
|
-
type:
|
|
1069
|
+
type: "Tag"
|
|
1114
1070
|
};
|
|
1115
1071
|
return state;
|
|
1116
1072
|
}
|
|
1117
1073
|
},
|
|
1118
1074
|
{
|
|
1119
|
-
tokenType:
|
|
1075
|
+
tokenType: "DoctypeOpen",
|
|
1076
|
+
handler(token, state) {
|
|
1077
|
+
if (state.currentNode.type !== "Document") {
|
|
1078
|
+
state.caretPosition++;
|
|
1079
|
+
return state;
|
|
1080
|
+
}
|
|
1081
|
+
initChildrenIfNone(state.currentNode);
|
|
1082
|
+
const doctypeNode = {
|
|
1083
|
+
type: "Doctype",
|
|
1084
|
+
parentRef: state.currentNode,
|
|
1085
|
+
range: cloneRange(token.range),
|
|
1086
|
+
loc: cloneLocation(token.loc),
|
|
1087
|
+
attributes: []
|
|
1088
|
+
};
|
|
1089
|
+
state.currentNode.children.push(doctypeNode);
|
|
1090
|
+
state.currentNode = doctypeNode;
|
|
1091
|
+
state.currentContext = {
|
|
1092
|
+
parentRef: state.currentContext,
|
|
1093
|
+
type: "Doctype"
|
|
1094
|
+
};
|
|
1095
|
+
return state;
|
|
1096
|
+
}
|
|
1097
|
+
},
|
|
1098
|
+
{
|
|
1099
|
+
tokenType: "Text",
|
|
1120
1100
|
handler(token, state) {
|
|
1121
1101
|
initChildrenIfNone(state.currentNode);
|
|
1122
1102
|
const textNode = createNodeFrom(token);
|
|
@@ -1126,7 +1106,7 @@ const dispatch$7 = createTokenDispatcher([
|
|
|
1126
1106
|
}
|
|
1127
1107
|
},
|
|
1128
1108
|
{
|
|
1129
|
-
tokenType:
|
|
1109
|
+
tokenType: "CloseTag",
|
|
1130
1110
|
handler(token, state) {
|
|
1131
1111
|
if (parseCloseTagName(token.value) !== state.currentNode.name) {
|
|
1132
1112
|
state.caretPosition++;
|
|
@@ -1137,11 +1117,11 @@ const dispatch$7 = createTokenDispatcher([
|
|
|
1137
1117
|
}
|
|
1138
1118
|
},
|
|
1139
1119
|
{
|
|
1140
|
-
tokenType:
|
|
1120
|
+
tokenType: "CommentOpen",
|
|
1141
1121
|
handler(token, state) {
|
|
1142
1122
|
initChildrenIfNone(state.currentNode);
|
|
1143
1123
|
const commentNode = {
|
|
1144
|
-
type:
|
|
1124
|
+
type: "Comment",
|
|
1145
1125
|
parentRef: state.currentNode,
|
|
1146
1126
|
range: cloneRange(token.range),
|
|
1147
1127
|
loc: cloneLocation(token.loc)
|
|
@@ -1150,27 +1130,7 @@ const dispatch$7 = createTokenDispatcher([
|
|
|
1150
1130
|
state.currentNode = commentNode;
|
|
1151
1131
|
state.currentContext = {
|
|
1152
1132
|
parentRef: state.currentContext,
|
|
1153
|
-
type:
|
|
1154
|
-
};
|
|
1155
|
-
return state;
|
|
1156
|
-
}
|
|
1157
|
-
},
|
|
1158
|
-
{
|
|
1159
|
-
tokenType: TokenTypes.DoctypeOpen,
|
|
1160
|
-
handler(token, state) {
|
|
1161
|
-
initChildrenIfNone(state.currentNode);
|
|
1162
|
-
const doctypeNode = {
|
|
1163
|
-
type: NodeTypes.Doctype,
|
|
1164
|
-
parentRef: state.currentNode,
|
|
1165
|
-
range: cloneRange(token.range),
|
|
1166
|
-
loc: cloneLocation(token.loc),
|
|
1167
|
-
attributes: []
|
|
1168
|
-
};
|
|
1169
|
-
state.currentNode.children.push(doctypeNode);
|
|
1170
|
-
state.currentNode = doctypeNode;
|
|
1171
|
-
state.currentContext = {
|
|
1172
|
-
parentRef: state.currentContext,
|
|
1173
|
-
type: ConstructTreeContextTypes.Doctype
|
|
1133
|
+
type: "Comment"
|
|
1174
1134
|
};
|
|
1175
1135
|
return state;
|
|
1176
1136
|
}
|
|
@@ -1182,16 +1142,15 @@ const dispatch$7 = createTokenDispatcher([
|
|
|
1182
1142
|
function construct$7(token, state) {
|
|
1183
1143
|
return dispatch$7(token, state);
|
|
1184
1144
|
}
|
|
1185
|
-
|
|
1186
1145
|
//#endregion
|
|
1187
1146
|
//#region src/constructor/handlers/attributeValue.ts
|
|
1188
1147
|
var attributeValue_exports$1 = /* @__PURE__ */ __exportAll({ construct: () => construct$6 });
|
|
1189
1148
|
const dispatch$6 = createTokenDispatcher([
|
|
1190
1149
|
{
|
|
1191
1150
|
tokenType: new Set([
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1151
|
+
"OpenTagEnd",
|
|
1152
|
+
"AttributeKey",
|
|
1153
|
+
"AttributeAssignment"
|
|
1195
1154
|
]),
|
|
1196
1155
|
handler(_, state) {
|
|
1197
1156
|
state.currentContext = state.currentContext.parentRef;
|
|
@@ -1199,7 +1158,7 @@ const dispatch$6 = createTokenDispatcher([
|
|
|
1199
1158
|
}
|
|
1200
1159
|
},
|
|
1201
1160
|
{
|
|
1202
|
-
tokenType:
|
|
1161
|
+
tokenType: "AttributeValue",
|
|
1203
1162
|
handler(token, state) {
|
|
1204
1163
|
const attribute = getLastAttribute(state);
|
|
1205
1164
|
attribute.value = createNodeFrom(token);
|
|
@@ -1209,7 +1168,7 @@ const dispatch$6 = createTokenDispatcher([
|
|
|
1209
1168
|
}
|
|
1210
1169
|
},
|
|
1211
1170
|
{
|
|
1212
|
-
tokenType:
|
|
1171
|
+
tokenType: "AttributeValueWrapperStart",
|
|
1213
1172
|
handler(token, state) {
|
|
1214
1173
|
const attribute = getLastAttribute(state);
|
|
1215
1174
|
attribute.quoteChar = token.value;
|
|
@@ -1222,7 +1181,7 @@ const dispatch$6 = createTokenDispatcher([
|
|
|
1222
1181
|
}
|
|
1223
1182
|
},
|
|
1224
1183
|
{
|
|
1225
|
-
tokenType:
|
|
1184
|
+
tokenType: "AttributeValueWrapperEnd",
|
|
1226
1185
|
handler(token, state) {
|
|
1227
1186
|
updateNodeEnd(getLastAttribute(state), token);
|
|
1228
1187
|
state.caretPosition++;
|
|
@@ -1236,12 +1195,11 @@ const dispatch$6 = createTokenDispatcher([
|
|
|
1236
1195
|
function construct$6(token, state) {
|
|
1237
1196
|
return dispatch$6(token, state);
|
|
1238
1197
|
}
|
|
1239
|
-
|
|
1240
1198
|
//#endregion
|
|
1241
1199
|
//#region src/constructor/handlers/xmlDeclaration.ts
|
|
1242
1200
|
var xmlDeclaration_exports = /* @__PURE__ */ __exportAll({ construct: () => construct$5 });
|
|
1243
1201
|
const dispatch$5 = createTokenDispatcher([{
|
|
1244
|
-
tokenType:
|
|
1202
|
+
tokenType: "OpenTagStart",
|
|
1245
1203
|
handler(token, state) {
|
|
1246
1204
|
state.currentNode.name = parseOpenTagName(token.value);
|
|
1247
1205
|
state.currentContext = state.currentContext.parentRef;
|
|
@@ -1255,20 +1213,19 @@ const dispatch$5 = createTokenDispatcher([{
|
|
|
1255
1213
|
function construct$5(token, state) {
|
|
1256
1214
|
return dispatch$5(token, state);
|
|
1257
1215
|
}
|
|
1258
|
-
|
|
1259
1216
|
//#endregion
|
|
1260
1217
|
//#region src/constructor/handlers/doctypeAttribute.ts
|
|
1261
1218
|
var doctypeAttribute_exports = /* @__PURE__ */ __exportAll({ construct: () => construct$4 });
|
|
1262
1219
|
const dispatch$4 = createTokenDispatcher([
|
|
1263
1220
|
{
|
|
1264
|
-
tokenType:
|
|
1221
|
+
tokenType: "DoctypeClose",
|
|
1265
1222
|
handler(_, state) {
|
|
1266
1223
|
state.currentContext = state.currentContext.parentRef;
|
|
1267
1224
|
return state;
|
|
1268
1225
|
}
|
|
1269
1226
|
},
|
|
1270
1227
|
{
|
|
1271
|
-
tokenType:
|
|
1228
|
+
tokenType: "DoctypeAttributeWrapperStart",
|
|
1272
1229
|
handler(token, state) {
|
|
1273
1230
|
const attribute = getLastAttribute(state);
|
|
1274
1231
|
if (attribute.value !== void 0) {
|
|
@@ -1282,7 +1239,7 @@ const dispatch$4 = createTokenDispatcher([
|
|
|
1282
1239
|
}
|
|
1283
1240
|
},
|
|
1284
1241
|
{
|
|
1285
|
-
tokenType:
|
|
1242
|
+
tokenType: "DoctypeAttributeWrapperEnd",
|
|
1286
1243
|
handler(token, state) {
|
|
1287
1244
|
updateNodeEnd(getLastAttribute(state), token);
|
|
1288
1245
|
state.currentContext = state.currentContext.parentRef;
|
|
@@ -1291,7 +1248,7 @@ const dispatch$4 = createTokenDispatcher([
|
|
|
1291
1248
|
}
|
|
1292
1249
|
},
|
|
1293
1250
|
{
|
|
1294
|
-
tokenType:
|
|
1251
|
+
tokenType: "DoctypeAttributeValue",
|
|
1295
1252
|
handler(token, state) {
|
|
1296
1253
|
const attribute = getLastAttribute(state);
|
|
1297
1254
|
if (attribute.value !== void 0) {
|
|
@@ -1311,28 +1268,26 @@ const dispatch$4 = createTokenDispatcher([
|
|
|
1311
1268
|
function construct$4(token, state) {
|
|
1312
1269
|
return dispatch$4(token, state);
|
|
1313
1270
|
}
|
|
1314
|
-
|
|
1315
1271
|
//#endregion
|
|
1316
1272
|
//#region src/constructor/handlers/doctypeAttributes.ts
|
|
1317
1273
|
var doctypeAttributes_exports$1 = /* @__PURE__ */ __exportAll({ construct: () => construct$3 });
|
|
1318
|
-
const ATTRIBUTE_START_TOKENS$1 = new Set([TokenTypes.DoctypeAttributeWrapperStart, TokenTypes.DoctypeAttributeValue]);
|
|
1319
1274
|
const dispatch$3 = createTokenDispatcher([{
|
|
1320
|
-
tokenType:
|
|
1275
|
+
tokenType: "DoctypeClose",
|
|
1321
1276
|
handler(_, state) {
|
|
1322
1277
|
state.currentContext = state.currentContext.parentRef;
|
|
1323
1278
|
return state;
|
|
1324
1279
|
}
|
|
1325
1280
|
}, {
|
|
1326
|
-
tokenType:
|
|
1281
|
+
tokenType: new Set(["DoctypeAttributeWrapperStart", "DoctypeAttributeValue"]),
|
|
1327
1282
|
handler(token, state) {
|
|
1328
1283
|
initAttributesIfNone(state.currentNode);
|
|
1329
1284
|
state.currentNode.attributes.push({
|
|
1330
|
-
type:
|
|
1285
|
+
type: "DoctypeAttribute",
|
|
1331
1286
|
range: cloneRange(token.range),
|
|
1332
1287
|
loc: cloneLocation(token.loc)
|
|
1333
1288
|
});
|
|
1334
1289
|
state.currentContext = {
|
|
1335
|
-
type:
|
|
1290
|
+
type: "DoctypeAttribute",
|
|
1336
1291
|
parentRef: state.currentContext
|
|
1337
1292
|
};
|
|
1338
1293
|
return state;
|
|
@@ -1344,16 +1299,15 @@ const dispatch$3 = createTokenDispatcher([{
|
|
|
1344
1299
|
function construct$3(token, state) {
|
|
1345
1300
|
return dispatch$3(token, state);
|
|
1346
1301
|
}
|
|
1347
|
-
|
|
1348
1302
|
//#endregion
|
|
1349
1303
|
//#region src/constructor/handlers/xmlDeclarationAttribute.ts
|
|
1350
1304
|
var xmlDeclarationAttribute_exports = /* @__PURE__ */ __exportAll({ construct: () => construct$2 });
|
|
1351
1305
|
const dispatch$2 = createTokenDispatcher([
|
|
1352
1306
|
{
|
|
1353
1307
|
tokenType: new Set([
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1308
|
+
"OpenTagEnd",
|
|
1309
|
+
"AttributeKey",
|
|
1310
|
+
"AttributeAssignment"
|
|
1357
1311
|
]),
|
|
1358
1312
|
handler(_, state) {
|
|
1359
1313
|
state.currentContext = state.currentContext.parentRef;
|
|
@@ -1361,7 +1315,7 @@ const dispatch$2 = createTokenDispatcher([
|
|
|
1361
1315
|
}
|
|
1362
1316
|
},
|
|
1363
1317
|
{
|
|
1364
|
-
tokenType:
|
|
1318
|
+
tokenType: "AttributeValue",
|
|
1365
1319
|
handler(token, state) {
|
|
1366
1320
|
const attribute = getLastAttribute(state);
|
|
1367
1321
|
attribute.value = createNodeFrom(token);
|
|
@@ -1371,7 +1325,7 @@ const dispatch$2 = createTokenDispatcher([
|
|
|
1371
1325
|
}
|
|
1372
1326
|
},
|
|
1373
1327
|
{
|
|
1374
|
-
tokenType:
|
|
1328
|
+
tokenType: "AttributeValueWrapperStart",
|
|
1375
1329
|
handler(token, state) {
|
|
1376
1330
|
const attribute = getLastAttribute(state);
|
|
1377
1331
|
attribute.quoteChar = token.value;
|
|
@@ -1381,7 +1335,7 @@ const dispatch$2 = createTokenDispatcher([
|
|
|
1381
1335
|
}
|
|
1382
1336
|
},
|
|
1383
1337
|
{
|
|
1384
|
-
tokenType:
|
|
1338
|
+
tokenType: "AttributeValueWrapperEnd",
|
|
1385
1339
|
handler(token, state) {
|
|
1386
1340
|
updateNodeEnd(getLastAttribute(state), token);
|
|
1387
1341
|
state.caretPosition++;
|
|
@@ -1395,28 +1349,26 @@ const dispatch$2 = createTokenDispatcher([
|
|
|
1395
1349
|
function construct$2(token, state) {
|
|
1396
1350
|
return dispatch$2(token, state);
|
|
1397
1351
|
}
|
|
1398
|
-
|
|
1399
1352
|
//#endregion
|
|
1400
1353
|
//#region src/constructor/handlers/xmlDeclarationAttributes.ts
|
|
1401
1354
|
var xmlDeclarationAttributes_exports$1 = /* @__PURE__ */ __exportAll({ construct: () => construct$1 });
|
|
1402
|
-
const ATTRIBUTE_START_TOKENS = new Set([TokenTypes.AttributeKey, TokenTypes.AttributeAssignment]);
|
|
1403
1355
|
const dispatch$1 = createTokenDispatcher([{
|
|
1404
|
-
tokenType:
|
|
1356
|
+
tokenType: "OpenTagEnd",
|
|
1405
1357
|
handler(_, state) {
|
|
1406
1358
|
state.currentContext = state.currentContext.parentRef;
|
|
1407
1359
|
return state;
|
|
1408
1360
|
}
|
|
1409
1361
|
}, {
|
|
1410
|
-
tokenType:
|
|
1362
|
+
tokenType: new Set(["AttributeKey", "AttributeAssignment"]),
|
|
1411
1363
|
handler(token, state) {
|
|
1412
1364
|
initAttributesIfNone(state.currentNode);
|
|
1413
1365
|
state.currentNode.attributes.push({
|
|
1414
|
-
type:
|
|
1366
|
+
type: "Attribute",
|
|
1415
1367
|
range: cloneRange(token.range),
|
|
1416
1368
|
loc: cloneLocation(token.loc)
|
|
1417
1369
|
});
|
|
1418
1370
|
state.currentContext = {
|
|
1419
|
-
type:
|
|
1371
|
+
type: "XMLDeclarationAttribute",
|
|
1420
1372
|
parentRef: state.currentContext
|
|
1421
1373
|
};
|
|
1422
1374
|
return state;
|
|
@@ -1428,20 +1380,19 @@ const dispatch$1 = createTokenDispatcher([{
|
|
|
1428
1380
|
function construct$1(token, state) {
|
|
1429
1381
|
return dispatch$1(token, state);
|
|
1430
1382
|
}
|
|
1431
|
-
|
|
1432
1383
|
//#endregion
|
|
1433
1384
|
//#region src/constructor/handlers/xmlDeclarationAttributeValue.ts
|
|
1434
1385
|
var xmlDeclarationAttributeValue_exports$1 = /* @__PURE__ */ __exportAll({ construct: () => construct });
|
|
1435
1386
|
const dispatch = createTokenDispatcher([
|
|
1436
1387
|
{
|
|
1437
|
-
tokenType:
|
|
1388
|
+
tokenType: "OpenTagEnd",
|
|
1438
1389
|
handler(_, state) {
|
|
1439
1390
|
state.currentContext = state.currentContext.parentRef;
|
|
1440
1391
|
return state;
|
|
1441
1392
|
}
|
|
1442
1393
|
},
|
|
1443
1394
|
{
|
|
1444
|
-
tokenType:
|
|
1395
|
+
tokenType: "AttributeValue",
|
|
1445
1396
|
handler(token, state) {
|
|
1446
1397
|
const attribute = getLastAttribute(state);
|
|
1447
1398
|
if (attribute.value !== void 0) {
|
|
@@ -1455,7 +1406,7 @@ const dispatch = createTokenDispatcher([
|
|
|
1455
1406
|
}
|
|
1456
1407
|
},
|
|
1457
1408
|
{
|
|
1458
|
-
tokenType:
|
|
1409
|
+
tokenType: "AttributeValueWrapperStart",
|
|
1459
1410
|
handler(token, state) {
|
|
1460
1411
|
const attribute = getLastAttribute(state);
|
|
1461
1412
|
if (attribute.value !== void 0) {
|
|
@@ -1469,7 +1420,7 @@ const dispatch = createTokenDispatcher([
|
|
|
1469
1420
|
}
|
|
1470
1421
|
},
|
|
1471
1422
|
{
|
|
1472
|
-
tokenType:
|
|
1423
|
+
tokenType: "AttributeValueWrapperEnd",
|
|
1473
1424
|
handler(token, state) {
|
|
1474
1425
|
updateNodeEnd(getLastAttribute(state), token);
|
|
1475
1426
|
state.currentContext = state.currentContext.parentRef;
|
|
@@ -1484,7 +1435,6 @@ const dispatch = createTokenDispatcher([
|
|
|
1484
1435
|
function construct(token, state) {
|
|
1485
1436
|
return dispatch(token, state);
|
|
1486
1437
|
}
|
|
1487
|
-
|
|
1488
1438
|
//#endregion
|
|
1489
1439
|
//#region src/constructor/constructTree.ts
|
|
1490
1440
|
const EMPTY_RANGE = [0, 0];
|
|
@@ -1499,24 +1449,34 @@ const EMPTY_LOC = {
|
|
|
1499
1449
|
}
|
|
1500
1450
|
};
|
|
1501
1451
|
const contextHandlers$1 = {
|
|
1502
|
-
[
|
|
1503
|
-
[
|
|
1504
|
-
[
|
|
1505
|
-
[
|
|
1506
|
-
[
|
|
1507
|
-
[
|
|
1508
|
-
[
|
|
1509
|
-
[
|
|
1510
|
-
[
|
|
1511
|
-
[
|
|
1512
|
-
[
|
|
1513
|
-
[
|
|
1514
|
-
[
|
|
1515
|
-
[
|
|
1452
|
+
["Tag"]: tag_exports,
|
|
1453
|
+
["TagName"]: tagName_exports,
|
|
1454
|
+
["TagContent"]: tagContent_exports,
|
|
1455
|
+
["Attributes"]: attributes_exports$1,
|
|
1456
|
+
["Attribute"]: attribute_exports,
|
|
1457
|
+
["AttributeValue"]: attributeValue_exports$1,
|
|
1458
|
+
["Doctype"]: doctype_exports,
|
|
1459
|
+
["DoctypeAttribute"]: doctypeAttribute_exports,
|
|
1460
|
+
["DoctypeAttributes"]: doctypeAttributes_exports$1,
|
|
1461
|
+
["Comment"]: comment_exports,
|
|
1462
|
+
["XMLDeclaration"]: xmlDeclaration_exports,
|
|
1463
|
+
["XMLDeclarationAttribute"]: xmlDeclarationAttribute_exports,
|
|
1464
|
+
["XMLDeclarationAttributes"]: xmlDeclarationAttributes_exports$1,
|
|
1465
|
+
["XMLDeclarationAttributeValue"]: xmlDeclarationAttributeValue_exports$1
|
|
1516
1466
|
};
|
|
1467
|
+
function processTokens(tokens, state, positionOffset) {
|
|
1468
|
+
let tokenIndex = state.caretPosition - positionOffset;
|
|
1469
|
+
while (tokenIndex < tokens.length) {
|
|
1470
|
+
const token = tokens[tokenIndex];
|
|
1471
|
+
const handler = contextHandlers$1[state.currentContext.type].construct;
|
|
1472
|
+
state = handler(token, state);
|
|
1473
|
+
tokenIndex = state.caretPosition - positionOffset;
|
|
1474
|
+
}
|
|
1475
|
+
return state;
|
|
1476
|
+
}
|
|
1517
1477
|
function constructTree(tokens) {
|
|
1518
1478
|
const rootContext = {
|
|
1519
|
-
type:
|
|
1479
|
+
type: "TagContent",
|
|
1520
1480
|
parentRef: void 0,
|
|
1521
1481
|
content: []
|
|
1522
1482
|
};
|
|
@@ -1529,7 +1489,7 @@ function constructTree(tokens) {
|
|
|
1529
1489
|
} : EMPTY_LOC;
|
|
1530
1490
|
loc.start.line = 1;
|
|
1531
1491
|
const rootNode = {
|
|
1532
|
-
type:
|
|
1492
|
+
type: "Document",
|
|
1533
1493
|
range,
|
|
1534
1494
|
children: [],
|
|
1535
1495
|
loc
|
|
@@ -1547,24 +1507,13 @@ function constructTree(tokens) {
|
|
|
1547
1507
|
ast: state.rootNode
|
|
1548
1508
|
};
|
|
1549
1509
|
}
|
|
1550
|
-
function processTokens(tokens, state, positionOffset) {
|
|
1551
|
-
let tokenIndex = state.caretPosition - positionOffset;
|
|
1552
|
-
while (tokenIndex < tokens.length) {
|
|
1553
|
-
const token = tokens[tokenIndex];
|
|
1554
|
-
const handler = contextHandlers$1[state.currentContext.type].construct;
|
|
1555
|
-
state = handler(token, state);
|
|
1556
|
-
tokenIndex = state.caretPosition - positionOffset;
|
|
1557
|
-
}
|
|
1558
|
-
return state;
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
1510
|
//#endregion
|
|
1562
1511
|
//#region src/tokenizer/charsBuffer.ts
|
|
1563
1512
|
var CharsBuffer = class {
|
|
1564
1513
|
charsBuffer = [];
|
|
1565
1514
|
concat(chars) {
|
|
1566
|
-
const
|
|
1567
|
-
if (
|
|
1515
|
+
const theLast = this.last();
|
|
1516
|
+
if (theLast) theLast.concat(chars);
|
|
1568
1517
|
else this.charsBuffer.push(chars);
|
|
1569
1518
|
}
|
|
1570
1519
|
concatBuffer(buffer) {
|
|
@@ -1595,7 +1544,6 @@ var CharsBuffer = class {
|
|
|
1595
1544
|
this.charsBuffer = [...other.charsBuffer];
|
|
1596
1545
|
}
|
|
1597
1546
|
};
|
|
1598
|
-
|
|
1599
1547
|
//#endregion
|
|
1600
1548
|
//#region src/tokenizer/handlers/data.ts
|
|
1601
1549
|
var data_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -1611,35 +1559,10 @@ const INCOMPLETE_DOCTYPE_CHARS = new Set([
|
|
|
1611
1559
|
"<!DOCTY",
|
|
1612
1560
|
"<!DOCTYP"
|
|
1613
1561
|
]);
|
|
1614
|
-
function parse$22(chars, state) {
|
|
1615
|
-
const value = chars.value();
|
|
1616
|
-
if (value === XML_DECLARATION_START) return parseXMLDeclarationOpen(state);
|
|
1617
|
-
if (RE_OPEN_TAG_START.test(value)) return parseOpeningCornerBraceWithText(state);
|
|
1618
|
-
if (value === "</") return parseOpeningCornerBraceWithSlash(state);
|
|
1619
|
-
if (value === SPECIAL_CHAR.openingCorner || value === "<!" || value === "<!-") return state.sourceCode.next();
|
|
1620
|
-
if (value === COMMENT_START) return parseCommentOpen(state);
|
|
1621
|
-
if (isIncompleteDoctype(value)) return state.sourceCode.next();
|
|
1622
|
-
if (value.toUpperCase() === "<!DOCTYPE") return parseDoctypeOpen(state);
|
|
1623
|
-
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
1624
|
-
state.decisionBuffer.clear();
|
|
1625
|
-
state.sourceCode.next();
|
|
1626
|
-
}
|
|
1627
|
-
function handleContentEnd(state) {
|
|
1628
|
-
const textContent = state.accumulatedContent.value() + state.decisionBuffer.value();
|
|
1629
|
-
if (textContent.length !== 0) {
|
|
1630
|
-
const position = calculateTokenPosition(state, { keepBuffer: false });
|
|
1631
|
-
state.tokens.push({
|
|
1632
|
-
type: TokenTypes.Text,
|
|
1633
|
-
value: textContent,
|
|
1634
|
-
range: position.range,
|
|
1635
|
-
loc: position.loc
|
|
1636
|
-
});
|
|
1637
|
-
}
|
|
1638
|
-
}
|
|
1639
1562
|
function generateTextToken(state) {
|
|
1640
1563
|
const position = calculateTokenPosition(state, { keepBuffer: false });
|
|
1641
1564
|
return {
|
|
1642
|
-
type:
|
|
1565
|
+
type: "Text",
|
|
1643
1566
|
value: state.accumulatedContent.value(),
|
|
1644
1567
|
range: position.range,
|
|
1645
1568
|
loc: position.loc
|
|
@@ -1652,145 +1575,159 @@ function parseOpeningCornerBraceWithText(state) {
|
|
|
1652
1575
|
if (state.accumulatedContent.length() !== 0) state.tokens.push(generateTextToken(state));
|
|
1653
1576
|
state.accumulatedContent.replace(state.decisionBuffer);
|
|
1654
1577
|
state.decisionBuffer.clear();
|
|
1655
|
-
state.currentContext =
|
|
1578
|
+
state.currentContext = "OpenTagStart";
|
|
1656
1579
|
state.sourceCode.next();
|
|
1657
1580
|
}
|
|
1658
1581
|
function parseOpeningCornerBraceWithSlash(state) {
|
|
1659
1582
|
if (state.accumulatedContent.length() !== 0) state.tokens.push(generateTextToken(state));
|
|
1660
1583
|
state.accumulatedContent.replace(state.decisionBuffer);
|
|
1661
1584
|
state.decisionBuffer.clear();
|
|
1662
|
-
state.currentContext =
|
|
1585
|
+
state.currentContext = "CloseTag";
|
|
1663
1586
|
state.sourceCode.next();
|
|
1664
1587
|
}
|
|
1665
1588
|
function parseCommentOpen(state) {
|
|
1666
1589
|
if (state.accumulatedContent.length() !== 0) state.tokens.push(generateTextToken(state));
|
|
1667
|
-
const range = [state.sourceCode.index() -
|
|
1590
|
+
const range = [state.sourceCode.index() - 3, state.sourceCode.index() + 1];
|
|
1668
1591
|
state.tokens.push({
|
|
1669
|
-
type:
|
|
1592
|
+
type: "CommentOpen",
|
|
1670
1593
|
value: state.decisionBuffer.value(),
|
|
1671
1594
|
range,
|
|
1672
1595
|
loc: state.sourceCode.getLocationOf(range)
|
|
1673
1596
|
});
|
|
1674
1597
|
state.accumulatedContent.clear();
|
|
1675
1598
|
state.decisionBuffer.clear();
|
|
1676
|
-
state.currentContext =
|
|
1599
|
+
state.currentContext = "CommentContent";
|
|
1677
1600
|
state.sourceCode.next();
|
|
1678
1601
|
}
|
|
1679
1602
|
function parseDoctypeOpen(state) {
|
|
1680
1603
|
if (state.accumulatedContent.length() !== 0) state.tokens.push(generateTextToken(state));
|
|
1681
1604
|
state.accumulatedContent.replace(state.decisionBuffer);
|
|
1682
1605
|
state.decisionBuffer.clear();
|
|
1683
|
-
state.currentContext =
|
|
1606
|
+
state.currentContext = "DoctypeOpen";
|
|
1684
1607
|
state.sourceCode.next();
|
|
1685
1608
|
}
|
|
1686
1609
|
function parseXMLDeclarationOpen(state) {
|
|
1687
1610
|
if (state.accumulatedContent.length() !== 0) state.tokens.push(generateTextToken(state));
|
|
1688
1611
|
state.accumulatedContent.clear();
|
|
1689
1612
|
state.decisionBuffer.clear();
|
|
1690
|
-
state.currentContext =
|
|
1613
|
+
state.currentContext = "XMLDeclarationAttributes";
|
|
1691
1614
|
state.sourceCode.next();
|
|
1692
1615
|
}
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
if (
|
|
1616
|
+
function parse$22(chars, state) {
|
|
1617
|
+
const value = chars.value();
|
|
1618
|
+
if (value === "<?xml") return parseXMLDeclarationOpen(state);
|
|
1619
|
+
if (RE_OPEN_TAG_START.test(value)) return parseOpeningCornerBraceWithText(state);
|
|
1620
|
+
if (value === "</") return parseOpeningCornerBraceWithSlash(state);
|
|
1621
|
+
if (value === SPECIAL_CHAR.openingCorner || value === "<!" || value === "<!-") return state.sourceCode.next();
|
|
1622
|
+
if (value === "<!--") return parseCommentOpen(state);
|
|
1623
|
+
if (isIncompleteDoctype(value)) return state.sourceCode.next();
|
|
1624
|
+
if (value.toUpperCase() === "<!DOCTYPE") return parseDoctypeOpen(state);
|
|
1699
1625
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
1700
1626
|
state.decisionBuffer.clear();
|
|
1701
1627
|
state.sourceCode.next();
|
|
1702
1628
|
}
|
|
1629
|
+
function handleContentEnd(state) {
|
|
1630
|
+
const textContent = state.accumulatedContent.value() + state.decisionBuffer.value();
|
|
1631
|
+
if (textContent.length !== 0) {
|
|
1632
|
+
const position = calculateTokenPosition(state, { keepBuffer: false });
|
|
1633
|
+
state.tokens.push({
|
|
1634
|
+
type: "Text",
|
|
1635
|
+
value: textContent,
|
|
1636
|
+
range: position.range,
|
|
1637
|
+
loc: position.loc
|
|
1638
|
+
});
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
//#endregion
|
|
1642
|
+
//#region src/tokenizer/handlers/closeTag.ts
|
|
1643
|
+
var closeTag_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$21 });
|
|
1703
1644
|
function parseClosingCornerBrace$5(state) {
|
|
1704
1645
|
const position = calculateTokenPosition(state, { keepBuffer: true });
|
|
1705
1646
|
state.tokens.push({
|
|
1706
|
-
type:
|
|
1647
|
+
type: "CloseTag",
|
|
1707
1648
|
value: state.accumulatedContent.value() + state.decisionBuffer.value(),
|
|
1708
1649
|
range: position.range,
|
|
1709
1650
|
loc: position.loc
|
|
1710
1651
|
});
|
|
1711
1652
|
state.accumulatedContent.clear();
|
|
1712
1653
|
state.decisionBuffer.clear();
|
|
1713
|
-
state.currentContext =
|
|
1654
|
+
state.currentContext = "Data";
|
|
1714
1655
|
state.sourceCode.next();
|
|
1715
1656
|
}
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
var attributes_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$20 });
|
|
1720
|
-
function parse$20(chars, state) {
|
|
1721
|
-
const value = chars.value();
|
|
1722
|
-
if (value === SPECIAL_CHAR.closingCorner || value === SPECIAL_CHAR.slash) return parseTagEnd$3(state);
|
|
1723
|
-
if (value === SPECIAL_CHAR.equal) return parseEqual(state);
|
|
1724
|
-
if (!isWhitespace(value)) return parseNoneWhitespace(chars, state);
|
|
1657
|
+
function parse$21(chars, state) {
|
|
1658
|
+
if (chars.value() === SPECIAL_CHAR.closingCorner) return parseClosingCornerBrace$5(state);
|
|
1659
|
+
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
1725
1660
|
state.decisionBuffer.clear();
|
|
1726
1661
|
state.sourceCode.next();
|
|
1727
1662
|
}
|
|
1663
|
+
//#endregion
|
|
1664
|
+
//#region src/tokenizer/handlers/attributes.ts
|
|
1665
|
+
var attributes_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$20 });
|
|
1728
1666
|
function parseTagEnd$3(state) {
|
|
1729
|
-
const tagName = state.contextParams[
|
|
1667
|
+
const tagName = state.contextParams["Attributes"]?.tagName;
|
|
1730
1668
|
state.accumulatedContent.clear();
|
|
1731
1669
|
state.decisionBuffer.clear();
|
|
1732
|
-
state.currentContext =
|
|
1733
|
-
state.contextParams[
|
|
1734
|
-
state.contextParams[
|
|
1670
|
+
state.currentContext = "OpenTagEnd";
|
|
1671
|
+
state.contextParams["OpenTagEnd"] = { tagName };
|
|
1672
|
+
state.contextParams["Attributes"] = void 0;
|
|
1735
1673
|
}
|
|
1736
1674
|
function parseEqual(state) {
|
|
1737
1675
|
const position = calculateTokenPosition(state, { keepBuffer: true });
|
|
1738
1676
|
state.tokens.push({
|
|
1739
|
-
type:
|
|
1677
|
+
type: "AttributeAssignment",
|
|
1740
1678
|
value: state.decisionBuffer.value(),
|
|
1741
1679
|
range: position.range,
|
|
1742
1680
|
loc: position.loc
|
|
1743
1681
|
});
|
|
1744
1682
|
state.accumulatedContent.clear();
|
|
1745
1683
|
state.decisionBuffer.clear();
|
|
1746
|
-
state.currentContext =
|
|
1684
|
+
state.currentContext = "AttributeValue";
|
|
1747
1685
|
state.sourceCode.next();
|
|
1748
1686
|
}
|
|
1749
1687
|
function parseNoneWhitespace(chars, state) {
|
|
1750
1688
|
state.accumulatedContent.replace(state.decisionBuffer);
|
|
1751
|
-
state.currentContext =
|
|
1689
|
+
state.currentContext = "AttributeKey";
|
|
1752
1690
|
state.decisionBuffer.clear();
|
|
1753
1691
|
state.sourceCode.next();
|
|
1754
1692
|
}
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
if (chars.value() === SPECIAL_CHAR.closingCorner) return parseClosingCornerBrace$4(state);
|
|
1761
|
-
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
1693
|
+
function parse$20(chars, state) {
|
|
1694
|
+
const value = chars.value();
|
|
1695
|
+
if (value === SPECIAL_CHAR.closingCorner || value === SPECIAL_CHAR.slash) return parseTagEnd$3(state);
|
|
1696
|
+
if (value === SPECIAL_CHAR.equal) return parseEqual(state);
|
|
1697
|
+
if (!isWhitespace(value)) return parseNoneWhitespace(chars, state);
|
|
1762
1698
|
state.decisionBuffer.clear();
|
|
1763
1699
|
state.sourceCode.next();
|
|
1764
1700
|
}
|
|
1701
|
+
//#endregion
|
|
1702
|
+
//#region src/tokenizer/handlers/openTagEnd.ts
|
|
1703
|
+
var openTagEnd_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$19 });
|
|
1765
1704
|
function parseClosingCornerBrace$4(state) {
|
|
1766
1705
|
const position = calculateTokenPosition(state, { keepBuffer: true });
|
|
1767
1706
|
state.tokens.push({
|
|
1768
|
-
type:
|
|
1707
|
+
type: "OpenTagEnd",
|
|
1769
1708
|
value: state.accumulatedContent.value() + state.decisionBuffer.value(),
|
|
1770
1709
|
range: position.range,
|
|
1771
1710
|
loc: position.loc
|
|
1772
1711
|
});
|
|
1773
1712
|
state.accumulatedContent.clear();
|
|
1774
1713
|
state.decisionBuffer.clear();
|
|
1775
|
-
state.currentContext =
|
|
1714
|
+
state.currentContext = "Data";
|
|
1776
1715
|
state.sourceCode.next();
|
|
1777
|
-
state.contextParams[
|
|
1716
|
+
state.contextParams["OpenTagEnd"] = void 0;
|
|
1778
1717
|
}
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
var doctypeOpen_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$18 });
|
|
1783
|
-
function parse$18(chars, state) {
|
|
1784
|
-
const value = chars.value();
|
|
1785
|
-
if (isWhitespace(value)) return parseWhitespace$1(state);
|
|
1786
|
-
if (value === SPECIAL_CHAR.closingCorner) return parseClosingCornerBrace$3(state);
|
|
1718
|
+
function parse$19(chars, state) {
|
|
1719
|
+
if (chars.value() === SPECIAL_CHAR.closingCorner) return parseClosingCornerBrace$4(state);
|
|
1720
|
+
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
1787
1721
|
state.decisionBuffer.clear();
|
|
1788
1722
|
state.sourceCode.next();
|
|
1789
1723
|
}
|
|
1724
|
+
//#endregion
|
|
1725
|
+
//#region src/tokenizer/handlers/doctypeOpen.ts
|
|
1726
|
+
var doctypeOpen_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$18 });
|
|
1790
1727
|
function generateDoctypeOpenToken(state) {
|
|
1791
1728
|
const position = calculateTokenPosition(state, { keepBuffer: false });
|
|
1792
1729
|
return {
|
|
1793
|
-
type:
|
|
1730
|
+
type: "DoctypeOpen",
|
|
1794
1731
|
value: state.accumulatedContent.value(),
|
|
1795
1732
|
range: position.range,
|
|
1796
1733
|
loc: position.loc
|
|
@@ -1800,24 +1737,24 @@ function parseWhitespace$1(state) {
|
|
|
1800
1737
|
state.tokens.push(generateDoctypeOpenToken(state));
|
|
1801
1738
|
state.accumulatedContent.clear();
|
|
1802
1739
|
state.decisionBuffer.clear();
|
|
1803
|
-
state.currentContext =
|
|
1740
|
+
state.currentContext = "DoctypeAttributes";
|
|
1804
1741
|
}
|
|
1805
1742
|
function parseClosingCornerBrace$3(state) {
|
|
1806
1743
|
state.tokens.push(generateDoctypeOpenToken(state));
|
|
1807
1744
|
state.accumulatedContent.clear();
|
|
1808
1745
|
state.decisionBuffer.clear();
|
|
1809
|
-
state.currentContext =
|
|
1746
|
+
state.currentContext = "DoctypeClose";
|
|
1810
1747
|
}
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
function parse$17(chars, state) {
|
|
1816
|
-
if (isKeyBreak$1(chars)) return parseKeyEnd$1(state);
|
|
1817
|
-
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
1748
|
+
function parse$18(chars, state) {
|
|
1749
|
+
const value = chars.value();
|
|
1750
|
+
if (isWhitespace(value)) return parseWhitespace$1(state);
|
|
1751
|
+
if (value === SPECIAL_CHAR.closingCorner) return parseClosingCornerBrace$3(state);
|
|
1818
1752
|
state.decisionBuffer.clear();
|
|
1819
1753
|
state.sourceCode.next();
|
|
1820
1754
|
}
|
|
1755
|
+
//#endregion
|
|
1756
|
+
//#region src/tokenizer/handlers/attributeKey.ts
|
|
1757
|
+
var attributeKey_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$17 });
|
|
1821
1758
|
function isKeyBreak$1(chars) {
|
|
1822
1759
|
const value = chars.value();
|
|
1823
1760
|
return value === SPECIAL_CHAR.equal || value === SPECIAL_CHAR.slash || value === SPECIAL_CHAR.closingCorner || isWhitespace(value);
|
|
@@ -1825,376 +1762,363 @@ function isKeyBreak$1(chars) {
|
|
|
1825
1762
|
function parseKeyEnd$1(state) {
|
|
1826
1763
|
const position = calculateTokenPosition(state, { keepBuffer: false });
|
|
1827
1764
|
state.tokens.push({
|
|
1828
|
-
type:
|
|
1765
|
+
type: "AttributeKey",
|
|
1829
1766
|
value: state.accumulatedContent.value(),
|
|
1830
1767
|
range: position.range,
|
|
1831
1768
|
loc: position.loc
|
|
1832
1769
|
});
|
|
1833
1770
|
state.accumulatedContent.clear();
|
|
1834
1771
|
state.decisionBuffer.clear();
|
|
1835
|
-
state.currentContext =
|
|
1772
|
+
state.currentContext = "Attributes";
|
|
1773
|
+
}
|
|
1774
|
+
function parse$17(chars, state) {
|
|
1775
|
+
if (isKeyBreak$1(chars)) return parseKeyEnd$1(state);
|
|
1776
|
+
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
1777
|
+
state.decisionBuffer.clear();
|
|
1778
|
+
state.sourceCode.next();
|
|
1836
1779
|
}
|
|
1837
|
-
|
|
1838
1780
|
//#endregion
|
|
1839
1781
|
//#region src/tokenizer/handlers/doctypeClose.ts
|
|
1840
1782
|
var doctypeClose_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$16 });
|
|
1841
1783
|
function parse$16(chars, state) {
|
|
1842
1784
|
const position = calculateTokenPosition(state, { keepBuffer: true });
|
|
1843
1785
|
state.tokens.push({
|
|
1844
|
-
type:
|
|
1786
|
+
type: "DoctypeClose",
|
|
1845
1787
|
value: state.decisionBuffer.value(),
|
|
1846
1788
|
range: position.range,
|
|
1847
1789
|
loc: position.loc
|
|
1848
1790
|
});
|
|
1849
1791
|
state.accumulatedContent.clear();
|
|
1850
1792
|
state.decisionBuffer.clear();
|
|
1851
|
-
state.currentContext =
|
|
1793
|
+
state.currentContext = "Data";
|
|
1852
1794
|
state.sourceCode.next();
|
|
1853
1795
|
}
|
|
1854
|
-
|
|
1855
1796
|
//#endregion
|
|
1856
1797
|
//#region src/tokenizer/handlers/openTagStart.ts
|
|
1857
1798
|
var openTagStart_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$15 });
|
|
1858
|
-
function parse$15(chars, state) {
|
|
1859
|
-
const value = chars.value();
|
|
1860
|
-
if (value === SPECIAL_CHAR.closingCorner || value === SPECIAL_CHAR.slash) return parseTagEnd$2(state);
|
|
1861
|
-
if (isWhitespace(value)) return parseWhitespace(state);
|
|
1862
|
-
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
1863
|
-
state.decisionBuffer.clear();
|
|
1864
|
-
state.sourceCode.next();
|
|
1865
|
-
}
|
|
1866
1799
|
function parseTagEnd$2(state) {
|
|
1867
1800
|
const tagName = parseOpenTagName(state.accumulatedContent.value());
|
|
1868
1801
|
const position = calculateTokenPosition(state, { keepBuffer: false });
|
|
1869
1802
|
state.tokens.push({
|
|
1870
|
-
type:
|
|
1803
|
+
type: "OpenTagStart",
|
|
1871
1804
|
value: state.accumulatedContent.value(),
|
|
1872
1805
|
range: position.range,
|
|
1873
1806
|
loc: position.loc
|
|
1874
1807
|
});
|
|
1875
1808
|
state.accumulatedContent.clear();
|
|
1876
1809
|
state.decisionBuffer.clear();
|
|
1877
|
-
state.currentContext =
|
|
1878
|
-
state.contextParams[
|
|
1810
|
+
state.currentContext = "OpenTagEnd";
|
|
1811
|
+
state.contextParams["OpenTagEnd"] = { tagName };
|
|
1879
1812
|
}
|
|
1880
1813
|
function parseWhitespace(state) {
|
|
1881
1814
|
const tagName = parseOpenTagName(state.accumulatedContent.value());
|
|
1882
1815
|
const position = calculateTokenPosition(state, { keepBuffer: false });
|
|
1883
1816
|
state.tokens.push({
|
|
1884
|
-
type:
|
|
1817
|
+
type: "OpenTagStart",
|
|
1885
1818
|
value: state.accumulatedContent.value(),
|
|
1886
1819
|
range: position.range,
|
|
1887
1820
|
loc: position.loc
|
|
1888
1821
|
});
|
|
1889
1822
|
state.accumulatedContent.clear();
|
|
1890
1823
|
state.decisionBuffer.clear();
|
|
1891
|
-
state.currentContext =
|
|
1892
|
-
state.contextParams[
|
|
1824
|
+
state.currentContext = "Attributes";
|
|
1825
|
+
state.contextParams["Attributes"] = { tagName };
|
|
1893
1826
|
state.sourceCode.next();
|
|
1894
1827
|
}
|
|
1895
|
-
|
|
1896
|
-
//#endregion
|
|
1897
|
-
//#region src/tokenizer/handlers/attributeValue.ts
|
|
1898
|
-
var attributeValue_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$14 });
|
|
1899
|
-
function parse$14(chars, state) {
|
|
1828
|
+
function parse$15(chars, state) {
|
|
1900
1829
|
const value = chars.value();
|
|
1901
|
-
if (value === SPECIAL_CHAR.
|
|
1902
|
-
if (value
|
|
1903
|
-
|
|
1830
|
+
if (value === SPECIAL_CHAR.closingCorner || value === SPECIAL_CHAR.slash) return parseTagEnd$2(state);
|
|
1831
|
+
if (isWhitespace(value)) return parseWhitespace(state);
|
|
1832
|
+
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
1904
1833
|
state.decisionBuffer.clear();
|
|
1905
1834
|
state.sourceCode.next();
|
|
1906
1835
|
}
|
|
1836
|
+
//#endregion
|
|
1837
|
+
//#region src/tokenizer/handlers/attributeValue.ts
|
|
1838
|
+
var attributeValue_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$14 });
|
|
1907
1839
|
function parseWrapper$5(state) {
|
|
1908
1840
|
const wrapper = state.decisionBuffer.value();
|
|
1909
1841
|
const range = [state.sourceCode.index(), state.sourceCode.index() + 1];
|
|
1910
1842
|
state.tokens.push({
|
|
1911
|
-
type:
|
|
1843
|
+
type: "AttributeValueWrapperStart",
|
|
1912
1844
|
value: wrapper,
|
|
1913
1845
|
range,
|
|
1914
1846
|
loc: state.sourceCode.getLocationOf(range)
|
|
1915
1847
|
});
|
|
1916
1848
|
state.accumulatedContent.clear();
|
|
1917
1849
|
state.decisionBuffer.clear();
|
|
1918
|
-
state.currentContext =
|
|
1919
|
-
state.contextParams[
|
|
1850
|
+
state.currentContext = "AttributeValueWrapped";
|
|
1851
|
+
state.contextParams["AttributeValueWrapped"] = { wrapper };
|
|
1920
1852
|
state.sourceCode.next();
|
|
1921
1853
|
}
|
|
1922
1854
|
function parseTagEnd$1(state) {
|
|
1923
1855
|
state.accumulatedContent.clear();
|
|
1924
1856
|
state.decisionBuffer.clear();
|
|
1925
|
-
state.currentContext =
|
|
1857
|
+
state.currentContext = "Attributes";
|
|
1926
1858
|
}
|
|
1927
1859
|
function parseBare$2(state) {
|
|
1928
1860
|
state.accumulatedContent.replace(state.decisionBuffer);
|
|
1929
1861
|
state.decisionBuffer.clear();
|
|
1930
|
-
state.currentContext =
|
|
1862
|
+
state.currentContext = "AttributeValueBare";
|
|
1931
1863
|
state.sourceCode.next();
|
|
1932
1864
|
}
|
|
1933
|
-
|
|
1934
|
-
//#endregion
|
|
1935
|
-
//#region src/tokenizer/handlers/commentContent.ts
|
|
1936
|
-
var commentContent_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$13 });
|
|
1937
|
-
function parse$13(chars, state) {
|
|
1865
|
+
function parse$14(chars, state) {
|
|
1938
1866
|
const value = chars.value();
|
|
1939
|
-
if (value === SPECIAL_CHAR.
|
|
1940
|
-
if (value ===
|
|
1941
|
-
|
|
1867
|
+
if (value === SPECIAL_CHAR.doubleQuote || value === SPECIAL_CHAR.singleQuote) return parseWrapper$5(state);
|
|
1868
|
+
if (value === SPECIAL_CHAR.closingCorner || value === SPECIAL_CHAR.slash) return parseTagEnd$1(state);
|
|
1869
|
+
if (!isWhitespace(value)) return parseBare$2(state);
|
|
1942
1870
|
state.decisionBuffer.clear();
|
|
1943
1871
|
state.sourceCode.next();
|
|
1944
1872
|
}
|
|
1873
|
+
//#endregion
|
|
1874
|
+
//#region src/tokenizer/handlers/commentContent.ts
|
|
1875
|
+
var commentContent_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$13 });
|
|
1945
1876
|
function parseCommentClose(state) {
|
|
1946
1877
|
const position = calculateTokenPosition(state, { keepBuffer: false });
|
|
1947
|
-
const endRange = [position.range[1], position.range[1] +
|
|
1878
|
+
const endRange = [position.range[1], position.range[1] + 3];
|
|
1948
1879
|
state.tokens.push({
|
|
1949
|
-
type:
|
|
1880
|
+
type: "CommentContent",
|
|
1950
1881
|
value: state.accumulatedContent.value(),
|
|
1951
1882
|
range: position.range,
|
|
1952
1883
|
loc: position.loc
|
|
1953
1884
|
});
|
|
1954
1885
|
state.tokens.push({
|
|
1955
|
-
type:
|
|
1886
|
+
type: "CommentClose",
|
|
1956
1887
|
value: state.decisionBuffer.value(),
|
|
1957
1888
|
range: endRange,
|
|
1958
1889
|
loc: state.sourceCode.getLocationOf(endRange)
|
|
1959
1890
|
});
|
|
1960
1891
|
state.accumulatedContent.clear();
|
|
1961
1892
|
state.decisionBuffer.clear();
|
|
1962
|
-
state.currentContext =
|
|
1893
|
+
state.currentContext = "Data";
|
|
1963
1894
|
state.sourceCode.next();
|
|
1964
1895
|
}
|
|
1965
|
-
|
|
1966
|
-
//#endregion
|
|
1967
|
-
//#region src/tokenizer/handlers/doctypeAttributes.ts
|
|
1968
|
-
var doctypeAttributes_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$12 });
|
|
1969
|
-
function parse$12(chars, state) {
|
|
1896
|
+
function parse$13(chars, state) {
|
|
1970
1897
|
const value = chars.value();
|
|
1971
|
-
if (value === SPECIAL_CHAR.
|
|
1972
|
-
if (value ===
|
|
1973
|
-
|
|
1898
|
+
if (value === SPECIAL_CHAR.hyphen || value === "--") return state.sourceCode.next();
|
|
1899
|
+
if (value === "-->") return parseCommentClose(state);
|
|
1900
|
+
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
1974
1901
|
state.decisionBuffer.clear();
|
|
1975
1902
|
state.sourceCode.next();
|
|
1976
1903
|
}
|
|
1904
|
+
//#endregion
|
|
1905
|
+
//#region src/tokenizer/handlers/doctypeAttributes.ts
|
|
1906
|
+
var doctypeAttributes_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$12 });
|
|
1977
1907
|
function parseWrapper$4(state) {
|
|
1978
1908
|
const wrapper = state.decisionBuffer.value();
|
|
1979
1909
|
const range = [state.sourceCode.index(), state.sourceCode.index() + wrapper.length];
|
|
1980
1910
|
state.tokens.push({
|
|
1981
|
-
type:
|
|
1911
|
+
type: "DoctypeAttributeWrapperStart",
|
|
1982
1912
|
value: wrapper,
|
|
1983
1913
|
range,
|
|
1984
1914
|
loc: state.sourceCode.getLocationOf(range)
|
|
1985
1915
|
});
|
|
1986
1916
|
state.accumulatedContent.clear();
|
|
1987
1917
|
state.decisionBuffer.clear();
|
|
1988
|
-
state.currentContext =
|
|
1989
|
-
state.contextParams[
|
|
1918
|
+
state.currentContext = "DoctypeAttributeWrapped";
|
|
1919
|
+
state.contextParams["DoctypeAttributeWrapped"] = { wrapper };
|
|
1990
1920
|
state.sourceCode.next();
|
|
1991
1921
|
}
|
|
1992
1922
|
function parseClosingCornerBrace$2(state) {
|
|
1993
1923
|
state.accumulatedContent.clear();
|
|
1994
1924
|
state.decisionBuffer.clear();
|
|
1995
|
-
state.currentContext =
|
|
1925
|
+
state.currentContext = "DoctypeClose";
|
|
1996
1926
|
}
|
|
1997
1927
|
function parseBare$1(state) {
|
|
1998
1928
|
state.accumulatedContent.replace(state.decisionBuffer);
|
|
1999
1929
|
state.decisionBuffer.clear();
|
|
2000
|
-
state.currentContext =
|
|
1930
|
+
state.currentContext = "DoctypeAttributeBare";
|
|
2001
1931
|
state.sourceCode.next();
|
|
2002
1932
|
}
|
|
2003
|
-
|
|
2004
|
-
//#endregion
|
|
2005
|
-
//#region src/tokenizer/handlers/attributeValueBare.ts
|
|
2006
|
-
var attributeValueBare_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$11 });
|
|
2007
|
-
function parse$11(chars, state) {
|
|
1933
|
+
function parse$12(chars, state) {
|
|
2008
1934
|
const value = chars.value();
|
|
2009
|
-
if (
|
|
2010
|
-
|
|
1935
|
+
if (value === SPECIAL_CHAR.doubleQuote || value === SPECIAL_CHAR.singleQuote) return parseWrapper$4(state);
|
|
1936
|
+
if (value === SPECIAL_CHAR.closingCorner) return parseClosingCornerBrace$2(state);
|
|
1937
|
+
if (!isWhitespace(value)) return parseBare$1(state);
|
|
2011
1938
|
state.decisionBuffer.clear();
|
|
2012
1939
|
state.sourceCode.next();
|
|
2013
1940
|
}
|
|
1941
|
+
//#endregion
|
|
1942
|
+
//#region src/tokenizer/handlers/attributeValueBare.ts
|
|
1943
|
+
var attributeValueBare_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$11 });
|
|
2014
1944
|
function parseValueEnd(state) {
|
|
2015
1945
|
const position = calculateTokenPosition(state, { keepBuffer: false });
|
|
2016
1946
|
state.tokens.push({
|
|
2017
|
-
type:
|
|
1947
|
+
type: "AttributeValue",
|
|
2018
1948
|
value: state.accumulatedContent.value(),
|
|
2019
1949
|
range: position.range,
|
|
2020
1950
|
loc: position.loc
|
|
2021
1951
|
});
|
|
2022
1952
|
state.accumulatedContent.clear();
|
|
2023
1953
|
state.decisionBuffer.clear();
|
|
2024
|
-
state.currentContext =
|
|
1954
|
+
state.currentContext = "Attributes";
|
|
2025
1955
|
}
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
var xmlDeclarationOpen_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$10 });
|
|
2030
|
-
function parse$10(chars, state) {
|
|
2031
|
-
if (chars.value() === SPECIAL_CHAR.closingCorner) return parseClosingCornerBrace$1(state);
|
|
1956
|
+
function parse$11(chars, state) {
|
|
1957
|
+
const value = chars.value();
|
|
1958
|
+
if (isWhitespace(value) || value === SPECIAL_CHAR.closingCorner || value === SPECIAL_CHAR.slash) return parseValueEnd(state);
|
|
2032
1959
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
2033
1960
|
state.decisionBuffer.clear();
|
|
2034
1961
|
state.sourceCode.next();
|
|
2035
1962
|
}
|
|
1963
|
+
//#endregion
|
|
1964
|
+
//#region src/tokenizer/handlers/xmlDeclarationOpen.ts
|
|
1965
|
+
var xmlDeclarationOpen_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$10 });
|
|
2036
1966
|
function parseClosingCornerBrace$1(state) {
|
|
2037
1967
|
const position = calculateTokenPosition(state, { keepBuffer: true });
|
|
2038
1968
|
state.tokens.push({
|
|
2039
|
-
type:
|
|
1969
|
+
type: "OpenTagEnd",
|
|
2040
1970
|
value: state.accumulatedContent.value() + state.decisionBuffer.value(),
|
|
2041
1971
|
range: position.range,
|
|
2042
1972
|
loc: position.loc
|
|
2043
1973
|
});
|
|
2044
1974
|
state.accumulatedContent.clear();
|
|
2045
1975
|
state.decisionBuffer.clear();
|
|
2046
|
-
state.currentContext =
|
|
1976
|
+
state.currentContext = "Data";
|
|
2047
1977
|
state.sourceCode.next();
|
|
2048
|
-
state.contextParams[
|
|
1978
|
+
state.contextParams["OpenTagEnd"] = void 0;
|
|
2049
1979
|
}
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
//#region src/tokenizer/handlers/xmlDeclarationClose.ts
|
|
2053
|
-
var xmlDeclarationClose_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$9 });
|
|
2054
|
-
function parse$9(chars, state) {
|
|
2055
|
-
if (chars.value() === SPECIAL_CHAR.closingCorner) return parseClosingCornerBrace(state);
|
|
1980
|
+
function parse$10(chars, state) {
|
|
1981
|
+
if (chars.value() === SPECIAL_CHAR.closingCorner) return parseClosingCornerBrace$1(state);
|
|
2056
1982
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
2057
1983
|
state.decisionBuffer.clear();
|
|
2058
1984
|
state.sourceCode.next();
|
|
2059
1985
|
}
|
|
1986
|
+
//#endregion
|
|
1987
|
+
//#region src/tokenizer/handlers/xmlDeclarationClose.ts
|
|
1988
|
+
var xmlDeclarationClose_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$9 });
|
|
2060
1989
|
function parseClosingCornerBrace(state) {
|
|
2061
1990
|
const position = calculateTokenPosition(state, { keepBuffer: true });
|
|
2062
1991
|
state.tokens.push({
|
|
2063
|
-
type:
|
|
1992
|
+
type: "OpenTagEnd",
|
|
2064
1993
|
value: state.accumulatedContent.value() + state.decisionBuffer.value(),
|
|
2065
1994
|
range: position.range,
|
|
2066
1995
|
loc: position.loc
|
|
2067
1996
|
});
|
|
2068
1997
|
state.accumulatedContent.clear();
|
|
2069
1998
|
state.decisionBuffer.clear();
|
|
2070
|
-
state.currentContext =
|
|
1999
|
+
state.currentContext = "Data";
|
|
2071
2000
|
state.sourceCode.next();
|
|
2072
|
-
state.contextParams[
|
|
2001
|
+
state.contextParams["OpenTagEnd"] = void 0;
|
|
2073
2002
|
}
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
//#region src/tokenizer/handlers/doctypeAttributeBare.ts
|
|
2077
|
-
var doctypeAttributeBare_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$8 });
|
|
2078
|
-
function parse$8(chars, state) {
|
|
2079
|
-
const value = chars.value();
|
|
2080
|
-
if (isWhitespace(value) || value === SPECIAL_CHAR.closingCorner) return parseAttributeEnd(state);
|
|
2003
|
+
function parse$9(chars, state) {
|
|
2004
|
+
if (chars.value() === SPECIAL_CHAR.closingCorner) return parseClosingCornerBrace(state);
|
|
2081
2005
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
2082
2006
|
state.decisionBuffer.clear();
|
|
2083
2007
|
state.sourceCode.next();
|
|
2084
2008
|
}
|
|
2009
|
+
//#endregion
|
|
2010
|
+
//#region src/tokenizer/handlers/doctypeAttributeBare.ts
|
|
2011
|
+
var doctypeAttributeBare_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$8 });
|
|
2085
2012
|
function parseAttributeEnd(state) {
|
|
2086
2013
|
const position = calculateTokenPosition(state, { keepBuffer: false });
|
|
2087
2014
|
state.tokens.push({
|
|
2088
|
-
type:
|
|
2015
|
+
type: "DoctypeAttributeValue",
|
|
2089
2016
|
value: state.accumulatedContent.value(),
|
|
2090
2017
|
range: position.range,
|
|
2091
2018
|
loc: position.loc
|
|
2092
2019
|
});
|
|
2093
2020
|
state.accumulatedContent.clear();
|
|
2094
2021
|
state.decisionBuffer.clear();
|
|
2095
|
-
state.currentContext =
|
|
2022
|
+
state.currentContext = "DoctypeAttributes";
|
|
2096
2023
|
}
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
var attributeValueWrapped_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$7 });
|
|
2101
|
-
function parse$7(chars, state) {
|
|
2102
|
-
const wrapperChar = state.contextParams[TokenizerContextTypes.AttributeValueWrapped]?.wrapper;
|
|
2103
|
-
if (chars.value() === wrapperChar) return parseWrapper$3(state);
|
|
2024
|
+
function parse$8(chars, state) {
|
|
2025
|
+
const value = chars.value();
|
|
2026
|
+
if (isWhitespace(value) || value === SPECIAL_CHAR.closingCorner) return parseAttributeEnd(state);
|
|
2104
2027
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
2105
2028
|
state.decisionBuffer.clear();
|
|
2106
2029
|
state.sourceCode.next();
|
|
2107
2030
|
}
|
|
2031
|
+
//#endregion
|
|
2032
|
+
//#region src/tokenizer/handlers/attributeValueWrapped.ts
|
|
2033
|
+
var attributeValueWrapped_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$7 });
|
|
2108
2034
|
function parseWrapper$3(state) {
|
|
2109
2035
|
const position = calculateTokenPosition(state, { keepBuffer: false });
|
|
2110
2036
|
const endWrapperPosition = position.range[1];
|
|
2111
2037
|
state.tokens.push({
|
|
2112
|
-
type:
|
|
2038
|
+
type: "AttributeValue",
|
|
2113
2039
|
value: state.accumulatedContent.value(),
|
|
2114
2040
|
range: position.range,
|
|
2115
2041
|
loc: position.loc
|
|
2116
2042
|
});
|
|
2117
2043
|
const range = [endWrapperPosition, endWrapperPosition + 1];
|
|
2118
2044
|
state.tokens.push({
|
|
2119
|
-
type:
|
|
2045
|
+
type: "AttributeValueWrapperEnd",
|
|
2120
2046
|
value: state.decisionBuffer.value(),
|
|
2121
2047
|
range,
|
|
2122
2048
|
loc: state.sourceCode.getLocationOf(range)
|
|
2123
2049
|
});
|
|
2124
2050
|
state.accumulatedContent.clear();
|
|
2125
2051
|
state.decisionBuffer.clear();
|
|
2126
|
-
state.currentContext =
|
|
2052
|
+
state.currentContext = "Attributes";
|
|
2127
2053
|
state.sourceCode.next();
|
|
2128
|
-
state.contextParams[
|
|
2054
|
+
state.contextParams["AttributeValueWrapped"] = void 0;
|
|
2129
2055
|
}
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
var doctypeAttributeWrapped_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$6 });
|
|
2134
|
-
function parse$6(chars, state) {
|
|
2135
|
-
if (chars.value() === state.contextParams[TokenizerContextTypes.DoctypeAttributeWrapped]?.wrapper) return parseWrapper$2(state);
|
|
2056
|
+
function parse$7(chars, state) {
|
|
2057
|
+
const wrapperChar = state.contextParams["AttributeValueWrapped"]?.wrapper;
|
|
2058
|
+
if (chars.value() === wrapperChar) return parseWrapper$3(state);
|
|
2136
2059
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
2137
2060
|
state.decisionBuffer.clear();
|
|
2138
2061
|
state.sourceCode.next();
|
|
2139
2062
|
}
|
|
2063
|
+
//#endregion
|
|
2064
|
+
//#region src/tokenizer/handlers/doctypeAttributeWrapped.ts
|
|
2065
|
+
var doctypeAttributeWrapped_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$6 });
|
|
2140
2066
|
function parseWrapper$2(state) {
|
|
2141
2067
|
const position = calculateTokenPosition(state, { keepBuffer: false });
|
|
2142
2068
|
const endWrapperPosition = position.range[1];
|
|
2143
2069
|
state.tokens.push({
|
|
2144
|
-
type:
|
|
2070
|
+
type: "DoctypeAttributeValue",
|
|
2145
2071
|
value: state.accumulatedContent.value(),
|
|
2146
2072
|
range: position.range,
|
|
2147
2073
|
loc: position.loc
|
|
2148
2074
|
});
|
|
2149
2075
|
const range = [endWrapperPosition, endWrapperPosition + 1];
|
|
2150
2076
|
state.tokens.push({
|
|
2151
|
-
type:
|
|
2077
|
+
type: "DoctypeAttributeWrapperEnd",
|
|
2152
2078
|
value: state.decisionBuffer.value(),
|
|
2153
2079
|
range,
|
|
2154
2080
|
loc: state.sourceCode.getLocationOf(range)
|
|
2155
2081
|
});
|
|
2156
2082
|
state.accumulatedContent.clear();
|
|
2157
2083
|
state.decisionBuffer.clear();
|
|
2158
|
-
state.currentContext =
|
|
2084
|
+
state.currentContext = "DoctypeAttributes";
|
|
2159
2085
|
state.sourceCode.next();
|
|
2160
|
-
state.contextParams[
|
|
2086
|
+
state.contextParams["DoctypeAttributeWrapped"] = void 0;
|
|
2161
2087
|
}
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
//#region src/tokenizer/handlers/xmlDeclarationAttributes.ts
|
|
2165
|
-
var xmlDeclarationAttributes_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$5 });
|
|
2166
|
-
function parse$5(chars, state) {
|
|
2167
|
-
const value = chars.value();
|
|
2168
|
-
if (value === SPECIAL_CHAR.question || value === SPECIAL_CHAR.closingCorner) return parseXMLDeclarationClose(state);
|
|
2169
|
-
if (value === XML_DECLARATION_END) return parseXMLDeclarationClose(state);
|
|
2088
|
+
function parse$6(chars, state) {
|
|
2089
|
+
if (chars.value() === state.contextParams["DoctypeAttributeWrapped"]?.wrapper) return parseWrapper$2(state);
|
|
2170
2090
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
2171
2091
|
state.decisionBuffer.clear();
|
|
2172
2092
|
state.sourceCode.next();
|
|
2173
2093
|
}
|
|
2094
|
+
//#endregion
|
|
2095
|
+
//#region src/tokenizer/handlers/xmlDeclarationAttributes.ts
|
|
2096
|
+
var xmlDeclarationAttributes_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$5 });
|
|
2174
2097
|
function parseXMLDeclarationClose(state) {
|
|
2175
2098
|
const position = calculateTokenPosition(state, { keepBuffer: false });
|
|
2176
|
-
const endRange = [position.range[1], position.range[1] +
|
|
2099
|
+
const endRange = [position.range[1], position.range[1] + 2];
|
|
2177
2100
|
state.tokens.push({
|
|
2178
|
-
type:
|
|
2101
|
+
type: "XMLDeclarationClose",
|
|
2179
2102
|
value: state.decisionBuffer.value(),
|
|
2180
2103
|
range: endRange,
|
|
2181
2104
|
loc: state.sourceCode.getLocationOf(endRange)
|
|
2182
2105
|
});
|
|
2183
2106
|
state.accumulatedContent.clear();
|
|
2184
2107
|
state.decisionBuffer.clear();
|
|
2185
|
-
state.currentContext =
|
|
2108
|
+
state.currentContext = "Data";
|
|
2186
2109
|
state.sourceCode.next();
|
|
2187
2110
|
}
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
function parse$4(chars, state) {
|
|
2193
|
-
if (isKeyBreak(chars)) return parseKeyEnd(state);
|
|
2111
|
+
function parse$5(chars, state) {
|
|
2112
|
+
const value = chars.value();
|
|
2113
|
+
if (value === SPECIAL_CHAR.question || value === SPECIAL_CHAR.closingCorner) return parseXMLDeclarationClose(state);
|
|
2114
|
+
if (value === "?>") return parseXMLDeclarationClose(state);
|
|
2194
2115
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
2195
2116
|
state.decisionBuffer.clear();
|
|
2196
2117
|
state.sourceCode.next();
|
|
2197
2118
|
}
|
|
2119
|
+
//#endregion
|
|
2120
|
+
//#region src/tokenizer/handlers/xmlDeclarationAttributeKey.ts
|
|
2121
|
+
var xmlDeclarationAttributeKey_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$4 });
|
|
2198
2122
|
function isKeyBreak(chars) {
|
|
2199
2123
|
const value = chars.value();
|
|
2200
2124
|
return value === SPECIAL_CHAR.equal || value === SPECIAL_CHAR.slash || value === SPECIAL_CHAR.closingCorner || isWhitespace(value);
|
|
@@ -2202,94 +2126,98 @@ function isKeyBreak(chars) {
|
|
|
2202
2126
|
function parseKeyEnd(state) {
|
|
2203
2127
|
const position = calculateTokenPosition(state, { keepBuffer: false });
|
|
2204
2128
|
state.tokens.push({
|
|
2205
|
-
type:
|
|
2129
|
+
type: "XMLDeclarationAttributeKey",
|
|
2206
2130
|
value: state.accumulatedContent.value(),
|
|
2207
2131
|
range: position.range,
|
|
2208
2132
|
loc: position.loc
|
|
2209
2133
|
});
|
|
2210
2134
|
state.accumulatedContent.clear();
|
|
2211
2135
|
state.decisionBuffer.clear();
|
|
2212
|
-
state.currentContext =
|
|
2136
|
+
state.currentContext = "XMLDeclarationAttributes";
|
|
2213
2137
|
}
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
var xmlDeclarationAttributeValue_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$3 });
|
|
2218
|
-
function parse$3(chars, state) {
|
|
2219
|
-
const value = chars.value();
|
|
2220
|
-
if (value === SPECIAL_CHAR.doubleQuote || value === SPECIAL_CHAR.singleQuote) return parseWrapper$1(state);
|
|
2221
|
-
if (value === SPECIAL_CHAR.closingCorner || value === SPECIAL_CHAR.slash) return parseTagEnd(state);
|
|
2222
|
-
if (!isWhitespace(value)) return parseBare(state);
|
|
2138
|
+
function parse$4(chars, state) {
|
|
2139
|
+
if (isKeyBreak(chars)) return parseKeyEnd(state);
|
|
2140
|
+
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
2223
2141
|
state.decisionBuffer.clear();
|
|
2224
2142
|
state.sourceCode.next();
|
|
2225
2143
|
}
|
|
2144
|
+
//#endregion
|
|
2145
|
+
//#region src/tokenizer/handlers/xmlDeclarationAttributeValue.ts
|
|
2146
|
+
var xmlDeclarationAttributeValue_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$3 });
|
|
2226
2147
|
function parseWrapper$1(state) {
|
|
2227
2148
|
const wrapper = state.decisionBuffer.value();
|
|
2228
2149
|
const range = [state.sourceCode.index(), state.sourceCode.index() + 1];
|
|
2229
2150
|
state.tokens.push({
|
|
2230
|
-
type:
|
|
2151
|
+
type: "AttributeValueWrapperStart",
|
|
2231
2152
|
value: wrapper,
|
|
2232
2153
|
range,
|
|
2233
2154
|
loc: state.sourceCode.getLocationOf(range)
|
|
2234
2155
|
});
|
|
2235
2156
|
state.accumulatedContent.clear();
|
|
2236
2157
|
state.decisionBuffer.clear();
|
|
2237
|
-
state.currentContext =
|
|
2238
|
-
state.contextParams[
|
|
2158
|
+
state.currentContext = "AttributeValueWrapped";
|
|
2159
|
+
state.contextParams["AttributeValueWrapped"] = { wrapper };
|
|
2239
2160
|
state.sourceCode.next();
|
|
2240
2161
|
}
|
|
2241
2162
|
function parseTagEnd(state) {
|
|
2242
2163
|
state.accumulatedContent.clear();
|
|
2243
2164
|
state.decisionBuffer.clear();
|
|
2244
|
-
state.currentContext =
|
|
2165
|
+
state.currentContext = "Attributes";
|
|
2245
2166
|
}
|
|
2246
2167
|
function parseBare(state) {
|
|
2247
2168
|
state.accumulatedContent.replace(state.decisionBuffer);
|
|
2248
2169
|
state.decisionBuffer.clear();
|
|
2249
|
-
state.currentContext =
|
|
2170
|
+
state.currentContext = "AttributeValueBare";
|
|
2250
2171
|
state.sourceCode.next();
|
|
2251
2172
|
}
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
const wrapperChar = state.contextParams[TokenizerContextTypes.AttributeValueWrapped]?.wrapper;
|
|
2258
|
-
if (chars.value() === wrapperChar) return parseWrapper(state);
|
|
2259
|
-
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
2173
|
+
function parse$3(chars, state) {
|
|
2174
|
+
const value = chars.value();
|
|
2175
|
+
if (value === SPECIAL_CHAR.doubleQuote || value === SPECIAL_CHAR.singleQuote) return parseWrapper$1(state);
|
|
2176
|
+
if (value === SPECIAL_CHAR.closingCorner || value === SPECIAL_CHAR.slash) return parseTagEnd(state);
|
|
2177
|
+
if (!isWhitespace(value)) return parseBare(state);
|
|
2260
2178
|
state.decisionBuffer.clear();
|
|
2261
2179
|
state.sourceCode.next();
|
|
2262
2180
|
}
|
|
2181
|
+
//#endregion
|
|
2182
|
+
//#region src/tokenizer/handlers/xmlDeclarationAttributeValueWrapped.ts
|
|
2183
|
+
var xmlDeclarationAttributeValueWrapped_exports = /* @__PURE__ */ __exportAll({ parse: () => parse$2 });
|
|
2263
2184
|
function parseWrapper(state) {
|
|
2264
2185
|
const position = calculateTokenPosition(state, { keepBuffer: false });
|
|
2265
2186
|
const endWrapperPosition = position.range[1];
|
|
2266
2187
|
state.tokens.push({
|
|
2267
|
-
type:
|
|
2188
|
+
type: "AttributeValue",
|
|
2268
2189
|
value: state.accumulatedContent.value(),
|
|
2269
2190
|
range: position.range,
|
|
2270
2191
|
loc: position.loc
|
|
2271
2192
|
});
|
|
2272
2193
|
const range = [endWrapperPosition, endWrapperPosition + 1];
|
|
2273
2194
|
state.tokens.push({
|
|
2274
|
-
type:
|
|
2195
|
+
type: "AttributeValueWrapperEnd",
|
|
2275
2196
|
value: state.decisionBuffer.value(),
|
|
2276
2197
|
range,
|
|
2277
2198
|
loc: state.sourceCode.getLocationOf(range)
|
|
2278
2199
|
});
|
|
2279
2200
|
state.accumulatedContent.clear();
|
|
2280
2201
|
state.decisionBuffer.clear();
|
|
2281
|
-
state.currentContext =
|
|
2202
|
+
state.currentContext = "Attributes";
|
|
2203
|
+
state.sourceCode.next();
|
|
2204
|
+
state.contextParams["AttributeValueWrapped"] = void 0;
|
|
2205
|
+
}
|
|
2206
|
+
function parse$2(chars, state) {
|
|
2207
|
+
const wrapperChar = state.contextParams["AttributeValueWrapped"]?.wrapper;
|
|
2208
|
+
if (chars.value() === wrapperChar) return parseWrapper(state);
|
|
2209
|
+
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
2210
|
+
state.decisionBuffer.clear();
|
|
2282
2211
|
state.sourceCode.next();
|
|
2283
|
-
state.contextParams[TokenizerContextTypes.AttributeValueWrapped] = void 0;
|
|
2284
2212
|
}
|
|
2285
|
-
|
|
2286
2213
|
//#endregion
|
|
2287
2214
|
//#region src/tokenizer/handlers/index.ts
|
|
2288
2215
|
const noop = { parse: () => {} };
|
|
2289
|
-
|
|
2290
2216
|
//#endregion
|
|
2291
2217
|
//#region src/tokenizer/chars.ts
|
|
2292
2218
|
var Chars = class {
|
|
2219
|
+
value;
|
|
2220
|
+
range;
|
|
2293
2221
|
constructor(value, range) {
|
|
2294
2222
|
this.value = value;
|
|
2295
2223
|
this.range = range;
|
|
@@ -2305,10 +2233,10 @@ var Chars = class {
|
|
|
2305
2233
|
return this.value.length;
|
|
2306
2234
|
}
|
|
2307
2235
|
};
|
|
2308
|
-
|
|
2309
2236
|
//#endregion
|
|
2310
2237
|
//#region src/tokenizer/sourceCode.ts
|
|
2311
2238
|
var SourceCode = class {
|
|
2239
|
+
source;
|
|
2312
2240
|
charsList;
|
|
2313
2241
|
charsIndex = 0;
|
|
2314
2242
|
constructor(source) {
|
|
@@ -2346,39 +2274,38 @@ var SourceCode = class {
|
|
|
2346
2274
|
return charsList;
|
|
2347
2275
|
}
|
|
2348
2276
|
};
|
|
2349
|
-
|
|
2350
2277
|
//#endregion
|
|
2351
2278
|
//#region src/tokenizer/tokenize.ts
|
|
2352
2279
|
const contextHandlers = {
|
|
2353
|
-
[
|
|
2354
|
-
[
|
|
2355
|
-
[
|
|
2356
|
-
[
|
|
2357
|
-
[
|
|
2358
|
-
[
|
|
2359
|
-
[
|
|
2360
|
-
[
|
|
2361
|
-
[
|
|
2362
|
-
[
|
|
2363
|
-
[
|
|
2364
|
-
[
|
|
2365
|
-
[
|
|
2366
|
-
[
|
|
2367
|
-
[
|
|
2368
|
-
[
|
|
2369
|
-
[
|
|
2370
|
-
[
|
|
2371
|
-
[
|
|
2372
|
-
[
|
|
2373
|
-
[
|
|
2374
|
-
[
|
|
2375
|
-
[
|
|
2280
|
+
["Data"]: data_exports,
|
|
2281
|
+
["XMLDeclarationOpen"]: xmlDeclarationOpen_exports,
|
|
2282
|
+
["XMLDeclarationClose"]: xmlDeclarationClose_exports,
|
|
2283
|
+
["XMLDeclarationAttributes"]: xmlDeclarationAttributes_exports,
|
|
2284
|
+
["XMLDeclarationAttributeKey"]: xmlDeclarationAttributeKey_exports,
|
|
2285
|
+
["XMLDeclarationAttributeValue"]: xmlDeclarationAttributeValue_exports,
|
|
2286
|
+
["XMLDeclarationAttributeValueWrapped"]: xmlDeclarationAttributeValueWrapped_exports,
|
|
2287
|
+
["Attributes"]: attributes_exports,
|
|
2288
|
+
["AttributeKey"]: attributeKey_exports,
|
|
2289
|
+
["AttributeValue"]: attributeValue_exports,
|
|
2290
|
+
["AttributeValueBare"]: attributeValueBare_exports,
|
|
2291
|
+
["AttributeValueWrapped"]: attributeValueWrapped_exports,
|
|
2292
|
+
["OpenTagStart"]: openTagStart_exports,
|
|
2293
|
+
["OpenTagEnd"]: openTagEnd_exports,
|
|
2294
|
+
["CloseTag"]: closeTag_exports,
|
|
2295
|
+
["DoctypeOpen"]: doctypeOpen_exports,
|
|
2296
|
+
["DoctypeClose"]: doctypeClose_exports,
|
|
2297
|
+
["DoctypeAttributes"]: doctypeAttributes_exports,
|
|
2298
|
+
["DoctypeAttributeBare"]: doctypeAttributeBare_exports,
|
|
2299
|
+
["DoctypeAttributeWrapped"]: doctypeAttributeWrapped_exports,
|
|
2300
|
+
["CommentContent"]: commentContent_exports,
|
|
2301
|
+
["CommentOpen"]: noop,
|
|
2302
|
+
["CommentClose"]: noop
|
|
2376
2303
|
};
|
|
2377
2304
|
function tokenizeChars(state) {
|
|
2378
2305
|
while (!state.sourceCode.isEof()) {
|
|
2379
|
-
const handler
|
|
2306
|
+
const handler = contextHandlers[state.currentContext];
|
|
2380
2307
|
state.decisionBuffer.concat(state.sourceCode.current());
|
|
2381
|
-
handler
|
|
2308
|
+
handler.parse(state.decisionBuffer, state);
|
|
2382
2309
|
}
|
|
2383
2310
|
const handler = contextHandlers[state.currentContext];
|
|
2384
2311
|
state.sourceCode.prev();
|
|
@@ -2388,7 +2315,7 @@ function tokenize(source) {
|
|
|
2388
2315
|
const tokens = [];
|
|
2389
2316
|
const state = {
|
|
2390
2317
|
contextParams: {},
|
|
2391
|
-
currentContext:
|
|
2318
|
+
currentContext: "Data",
|
|
2392
2319
|
sourceCode: new SourceCode(source),
|
|
2393
2320
|
decisionBuffer: new CharsBuffer(),
|
|
2394
2321
|
accumulatedContent: new CharsBuffer(),
|
|
@@ -2402,7 +2329,6 @@ function tokenize(source) {
|
|
|
2402
2329
|
tokens
|
|
2403
2330
|
};
|
|
2404
2331
|
}
|
|
2405
|
-
|
|
2406
2332
|
//#endregion
|
|
2407
2333
|
//#region src/parser/parse.ts
|
|
2408
2334
|
function parse$1(source, _options = {}) {
|
|
@@ -2413,11 +2339,10 @@ function parse$1(source, _options = {}) {
|
|
|
2413
2339
|
tokens
|
|
2414
2340
|
};
|
|
2415
2341
|
}
|
|
2416
|
-
|
|
2417
2342
|
//#endregion
|
|
2418
2343
|
//#region src/visitorKeys.ts
|
|
2419
2344
|
const keys = {
|
|
2420
|
-
Program: ["
|
|
2345
|
+
Program: ["document"],
|
|
2421
2346
|
Document: ["children"],
|
|
2422
2347
|
XMLDeclaration: ["attributes"],
|
|
2423
2348
|
XMLDeclarationAttribute: ["key", "value"],
|
|
@@ -2429,47 +2354,52 @@ const keys = {
|
|
|
2429
2354
|
Attribute: ["key", "value"],
|
|
2430
2355
|
AttributeKey: [],
|
|
2431
2356
|
AttributeValue: [],
|
|
2432
|
-
|
|
2357
|
+
Element: ["attributes", "children"],
|
|
2433
2358
|
Comment: [],
|
|
2434
2359
|
Text: [],
|
|
2435
2360
|
Error: []
|
|
2436
2361
|
};
|
|
2437
2362
|
let vistorKeysCache = null;
|
|
2438
2363
|
function getVisitorKeys() {
|
|
2439
|
-
if (!vistorKeysCache)
|
|
2364
|
+
if (!vistorKeysCache) {
|
|
2365
|
+
const merged = unionWith(keys);
|
|
2366
|
+
vistorKeysCache = {
|
|
2367
|
+
...merged,
|
|
2368
|
+
Tag: merged.Element
|
|
2369
|
+
};
|
|
2370
|
+
}
|
|
2440
2371
|
return vistorKeysCache;
|
|
2441
2372
|
}
|
|
2442
2373
|
const visitorKeys = getVisitorKeys();
|
|
2443
|
-
|
|
2444
2374
|
//#endregion
|
|
2445
2375
|
//#region src/parser/traverse.ts
|
|
2446
2376
|
function traverse(node, visitor) {
|
|
2447
2377
|
if (!node) return;
|
|
2448
2378
|
visitor(node);
|
|
2449
|
-
const keys
|
|
2450
|
-
if (!keys
|
|
2451
|
-
keys
|
|
2379
|
+
const keys = visitorKeys[node.type];
|
|
2380
|
+
if (!keys || keys.length <= 0) return;
|
|
2381
|
+
keys.forEach((key) => {
|
|
2452
2382
|
const value = node[key];
|
|
2453
|
-
if (value) if (Array.isArray(value)) value.forEach((
|
|
2383
|
+
if (value) if (Array.isArray(value)) value.forEach((v) => traverse(v, visitor));
|
|
2454
2384
|
else traverse(value, visitor);
|
|
2455
2385
|
});
|
|
2456
2386
|
}
|
|
2457
|
-
|
|
2458
2387
|
//#endregion
|
|
2459
2388
|
//#region src/parser/parseForESLint.ts
|
|
2460
2389
|
function parseForESLint(source, options = {}) {
|
|
2461
2390
|
const { ast, tokens } = parse$1(source, options);
|
|
2462
2391
|
const programNode = {
|
|
2463
|
-
type:
|
|
2464
|
-
body: [
|
|
2392
|
+
type: "Program",
|
|
2393
|
+
body: [],
|
|
2465
2394
|
comments: [],
|
|
2466
|
-
|
|
2395
|
+
document: ast,
|
|
2396
|
+
tokens: tokens.filter((token) => token.type !== "CommentOpen" && token.type !== "CommentClose" && token.type !== "CommentContent"),
|
|
2467
2397
|
range: ast.range,
|
|
2468
2398
|
loc: ast.loc
|
|
2469
2399
|
};
|
|
2470
2400
|
const comments = [];
|
|
2471
2401
|
traverse(programNode, (node) => {
|
|
2472
|
-
if (node.type ===
|
|
2402
|
+
if (node.type === "Comment") comments.push({
|
|
2473
2403
|
type: "Block",
|
|
2474
2404
|
value: node.content,
|
|
2475
2405
|
range: node.range,
|
|
@@ -2484,14 +2414,12 @@ function parseForESLint(source, options = {}) {
|
|
|
2484
2414
|
services: { isSVG: true }
|
|
2485
2415
|
};
|
|
2486
2416
|
}
|
|
2487
|
-
|
|
2488
2417
|
//#endregion
|
|
2489
2418
|
//#region src/index.ts
|
|
2490
2419
|
const name = meta.name;
|
|
2491
2420
|
const VisitorKeys = visitorKeys;
|
|
2492
2421
|
function parse(code, options = {}) {
|
|
2493
|
-
return parseForESLint(code, options).ast;
|
|
2422
|
+
return parseForESLint(code, options).ast.document;
|
|
2494
2423
|
}
|
|
2495
|
-
|
|
2496
2424
|
//#endregion
|
|
2497
|
-
export { COMMENT_END, COMMENT_START, ConstructTreeContextTypes, DEPRECATED_SVG_ELEMENTS, NodeTypes, ParseError, RE_CLOSE_TAG_NAME, RE_INCOMPLETE_CLOSING_TAG, RE_OPEN_TAG_NAME, RE_OPEN_TAG_START, SELF_CLOSING_ELEMENTS, SPECIAL_CHAR, SVG_ELEMENTS, TokenTypes, TokenizerContextTypes, VisitorKeys, XML_DECLARATION_END, XML_DECLARATION_START, cloneNode, cloneNodeWithParent, countNodes, filterNodes, findFirstNodeByType, findNodeByType, getNodeDepth, getParentChain, isNodeType, mapNodes, meta, name, parse, parseForESLint, traverseAST, validateNode, walkAST };
|
|
2425
|
+
export { COMMENT_END, COMMENT_START, ConstructTreeContextTypes, DEPRECATED_SVG_ELEMENTS, NodeTypes, ParseError, RE_CLOSE_TAG_NAME, RE_INCOMPLETE_CLOSING_TAG, RE_OPEN_TAG_NAME, RE_OPEN_TAG_START, SELF_CLOSING_ELEMENTS, SPECIAL_CHAR, SVG_ELEMENTS, TokenTypes, TokenizerContextTypes, VisitorKeys, XML_DECLARATION_END, XML_DECLARATION_START, cloneNode, cloneNodeWithParent, countNodes, filterNodes, findFirstNodeByType, findNodeByType, getNodeDepth, getParentChain, isNodeType, mapNodes, meta, name, parse, parseForESLint, traverseAST, validateNode, walkAST };
|