@tbela99/css-parser 1.4.11 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +11 -4
  3. package/dist/index-umd-web.js +2116 -1699
  4. package/dist/index.cjs +2128 -1694
  5. package/dist/index.d.ts +781 -269
  6. package/dist/lib/ast/clone.js +13 -8
  7. package/dist/lib/ast/expand.js +45 -9
  8. package/dist/lib/ast/features/calc.js +2 -1
  9. package/dist/lib/ast/features/if.js +24 -4
  10. package/dist/lib/ast/features/prefix.js +13 -31
  11. package/dist/lib/ast/features/shorthand.js +1 -1
  12. package/dist/lib/ast/features/transform.js +5 -2
  13. package/dist/lib/ast/find.js +7 -5
  14. package/dist/lib/ast/minify.js +80 -35
  15. package/dist/lib/ast/node.js +50 -0
  16. package/dist/lib/ast/types.js +1 -1
  17. package/dist/lib/ast/walk.js +27 -7
  18. package/dist/lib/fs/resolve.js +60 -28
  19. package/dist/lib/parser/declaration/map.js +14 -5
  20. package/dist/lib/parser/linesmap.js +5 -13
  21. package/dist/lib/parser/parse.js +489 -719
  22. package/dist/lib/parser/source.js +16 -2
  23. package/dist/lib/parser/tokenize.js +382 -278
  24. package/dist/lib/parser/utils/at-rule-container.js +2 -1
  25. package/dist/lib/parser/utils/selector.js +88 -10
  26. package/dist/lib/renderer/render.js +174 -99
  27. package/dist/lib/renderer/sourcemap/lib/codec.js +78 -0
  28. package/dist/lib/renderer/sourcemap/sourcemap.js +190 -34
  29. package/dist/lib/syntax/syntax.js +14 -151
  30. package/dist/lib/validation/match.js +81 -1
  31. package/dist/node.js +41 -26
  32. package/dist/utils/sync.d.ts +16 -0
  33. package/dist/utils/sync.js +52 -0
  34. package/dist/web.js +26 -28
  35. package/llms.txt +12 -5
  36. package/package.json +1 -1
  37. package/dist/lib/renderer/sourcemap/lib/encode.js +0 -37
@@ -1,10 +1,14 @@
1
- import { encode } from './lib/encode.js';
1
+ import { decode, encode } from './lib/codec.js';
2
2
 
3
3
  /**
4
- * Source map class
5
- * @internal
4
+ * Generate and parse source map
6
5
  */
7
6
  class SourceMap {
7
+ /**
8
+ *
9
+ * @private
10
+ */
11
+ keys = new Set();
8
12
  /**
9
13
  * Last location
10
14
  */
@@ -19,6 +23,11 @@ class SourceMap {
19
23
  * @private
20
24
  */
21
25
  sourcesMap = [];
26
+ /**
27
+ * Sources content
28
+ * @private
29
+ */
30
+ sourcesContent = [];
22
31
  /**
23
32
  * Sources
24
33
  * @private
@@ -27,52 +36,198 @@ class SourceMap {
27
36
  /**
28
37
  * Map
29
38
  * @private
39
+ *
30
40
  */
31
41
  map = new Map();
42
+ /**
43
+ * Map
44
+ * @private
45
+ *
46
+ */
47
+ reverseMap = new Map();
32
48
  /**
33
49
  * Line
34
50
  * @private
35
51
  */
36
52
  line = -1;
37
53
  /**
38
- * Add a location
39
- * @param source
40
- * @param original
54
+ *
55
+ * @param sourcemaps
56
+ */
57
+ constructor(sourcemaps) {
58
+ if (typeof sourcemaps === "string") {
59
+ if (sourcemaps.startsWith("data:")) {
60
+ let encoding = "";
61
+ let offset = sourcemaps.indexOf(",") + 1;
62
+ if (offset == 0) {
63
+ offset = sourcemaps.lastIndexOf(";") + 1;
64
+ }
65
+ else {
66
+ encoding = sourcemaps.slice(sourcemaps.lastIndexOf(";") + 1, offset - 1);
67
+ }
68
+ if (encoding == "base64") {
69
+ sourcemaps = atob(sourcemaps.slice(offset));
70
+ }
71
+ else {
72
+ sourcemaps = decodeURIComponent(sourcemaps.slice(offset));
73
+ }
74
+ }
75
+ sourcemaps = JSON.parse(sourcemaps);
76
+ }
77
+ if (sourcemaps != null) {
78
+ this.sources = sourcemaps.sources?.slice() ?? [];
79
+ this.sourcesContent = sourcemaps.sourcesContent?.slice() ?? [];
80
+ const decodedMappings = sourcemaps.mappings
81
+ .split(";")
82
+ .map((mapping) => mapping.split(",").map((mapping) => decode(mapping)));
83
+ this.line = decodedMappings.length - 1;
84
+ for (let index = 0; index < decodedMappings.length; index++) {
85
+ if (decodedMappings[index].length == 0 ||
86
+ (decodedMappings[index].length == 1 && decodedMappings[index][0].length == 0)) {
87
+ continue;
88
+ }
89
+ this.map.set(index, decodedMappings[index]);
90
+ }
91
+ this.computePositions();
92
+ }
93
+ }
94
+ /**
95
+ * add source
96
+ * @param id
97
+ * @param fileName
98
+ * @param content
99
+ * @returns
100
+ */
101
+ addSourceContent(id, fileName, content) {
102
+ if (this.sourcesMap.includes(id)) {
103
+ return;
104
+ }
105
+ this.sourcesMap[this.sourcesMap.length] = id;
106
+ this.sources[this.sources.length] = fileName || null;
107
+ this.sourcesContent[this.sourcesContent.length] = content || null;
108
+ }
109
+ /**
110
+ * Add all location
111
+ * @param maps
112
+ * @throws
41
113
  */
42
- add(newLine, newColumn, srcId, ln, col, sourceFileName, sourceContent) {
43
- if (!this.sourcesMap.includes(srcId)) {
44
- if (sourceFileName == null && sourceContent != null) {
45
- sourceFileName = "data:text/css;charset=utf-8;base64," + btoa(sourceContent);
114
+ add(...maps) {
115
+ let srcIndex;
116
+ if (typeof maps[0] === "number") {
117
+ maps = [maps];
118
+ }
119
+ for (let [newLine, newColumn, srcId, ln, col] of maps) {
120
+ const key = `${srcId}:${ln}:${col}:${newLine}:${newColumn}`;
121
+ if (this.keys.has(key)) {
122
+ continue;
123
+ }
124
+ this.keys.add(key);
125
+ const line = newLine - 1;
126
+ let record;
127
+ if (line > this.line) {
128
+ this.line = line;
129
+ }
130
+ srcIndex = this.sourcesMap.indexOf(srcId);
131
+ if (srcIndex == -1) {
132
+ throw new Error(`Source file ${srcId} not added to sourcemap`);
46
133
  }
47
- this.sourcesMap.push(srcId);
48
- this.sources.push(sourceFileName || null);
134
+ if (!this.map.has(line)) {
135
+ record = [Math.max(0, newColumn - 1), srcIndex, ln - 1, col - 1];
136
+ this.map.set(line, [record]);
137
+ }
138
+ else {
139
+ const arr = this.map.get(line);
140
+ record = [Math.max(0, newColumn - 1) - arr[0][0], srcIndex - arr[0][1], ln - 1, col - 1];
141
+ arr.push(record);
142
+ }
143
+ if (this.lastLocation != null) {
144
+ record[2] -= this.lastLocation.ln - 1;
145
+ record[3] -= this.lastLocation.col - 1;
146
+ }
147
+ this.lastLocation ??= { ln, col };
148
+ this.lastLocation.ln = ln;
149
+ this.lastLocation.col = col;
49
150
  }
50
- const line = newLine - 1;
51
- let record;
52
- if (line > this.line) {
53
- this.line = line;
151
+ }
152
+ /**
153
+ * compute original positions
154
+ */
155
+ computePositions() {
156
+ this.reverseMap.clear();
157
+ let sourceFileIndex = 0; // second field
158
+ let sourceCodeLine = 0; // third field
159
+ let sourceCodeColumn = 0; // fourth field
160
+ // let nameIndex: number = 0; // fifth field
161
+ let generatedCodeColumn;
162
+ let result;
163
+ // mappings to original source
164
+ for (let [i, line] of this.map.entries()) {
165
+ if (line.length === 0 || (line.length === 1 && line[0].length === 0)) {
166
+ continue;
167
+ }
168
+ generatedCodeColumn = line[0][0]; // first field - reset each time
169
+ line = line
170
+ .map((segment, index, array) => {
171
+ if (segment.length === 0) {
172
+ return [];
173
+ }
174
+ generatedCodeColumn = index == 0 ? segment[0] : segment[0] + array[0][0];
175
+ result = [generatedCodeColumn];
176
+ if (segment.length <= 1) {
177
+ return result;
178
+ }
179
+ sourceFileIndex = index == 0 ? segment[1] : segment[1] + array[0][1];
180
+ sourceCodeLine += segment[2];
181
+ sourceCodeColumn += segment[3];
182
+ result.push(sourceFileIndex, sourceCodeLine, sourceCodeColumn);
183
+ // nameIndex not needed
184
+ // if (segment.length === 5) {
185
+ // nameIndex += segment[4];
186
+ // result.push(nameIndex);
187
+ // }
188
+ return result;
189
+ })
190
+ .sort((a, b) => {
191
+ if (a[1] !== b[1]) {
192
+ return a[1] - b[1];
193
+ }
194
+ return a[0] - b[0];
195
+ });
196
+ if (line.length == 0 || (line.length == 1 && line[0].length == 0)) {
197
+ continue;
198
+ }
199
+ this.reverseMap.set(i, line);
54
200
  }
55
- if (!this.map.has(line)) {
56
- record = [Math.max(0, newColumn - 1), this.sourcesMap.indexOf(srcId), ln - 1, col - 1];
57
- this.map.set(line, [record]);
201
+ }
202
+ /**
203
+ * retrieve original sources, lines and columns
204
+ * @param line generated line
205
+ * @param column generated column
206
+ */
207
+ find(line, column) {
208
+ if (this.reverseMap.size == 0) {
209
+ this.computePositions();
58
210
  }
59
- else {
60
- const arr = this.map.get(line);
61
- record = [
62
- Math.max(0, newColumn - 1 - arr[0][0]),
63
- this.sourcesMap.indexOf(srcId) - arr[0][1],
64
- ln - 1,
65
- col - 1,
66
- ];
67
- arr.push(record);
211
+ if (!this.reverseMap.has(--line)) {
212
+ return null;
68
213
  }
69
- if (this.lastLocation != null) {
70
- record[2] -= this.lastLocation.ln - 1;
71
- record[3] -= this.lastLocation.col - 1;
214
+ column--;
215
+ const result = [];
216
+ for (const record of this.reverseMap.get(line)) {
217
+ if (record.length == 0 || record[0] < column) {
218
+ continue;
219
+ }
220
+ if (record[0] > column) {
221
+ break;
222
+ }
223
+ result.push([
224
+ this.sources?.[record[1]] ?? null,
225
+ record[2] + 1,
226
+ record[3] + 1,
227
+ this.sourcesContent?.[record[1]] ?? null,
228
+ ]);
72
229
  }
73
- this.lastLocation ??= { ln, col };
74
- this.lastLocation.ln = ln;
75
- this.lastLocation.col = col;
230
+ return result.length == 0 ? null : result;
76
231
  }
77
232
  /**
78
233
  * Convert to URL encoded string
@@ -98,6 +253,7 @@ class SourceMap {
98
253
  return {
99
254
  version: this.version,
100
255
  sources: this.sources.slice(),
256
+ sourcesContent: this.sourcesContent?.slice(),
101
257
  mappings: mappings.join(";"),
102
258
  };
103
259
  }
@@ -591,7 +591,6 @@ function isColor(token, errors) {
591
591
  action: "drop",
592
592
  message: `Invalid color`,
593
593
  node: token,
594
- // location: options.source!.getSourLocation(token[LOC]!.sta),
595
594
  });
596
595
  return false;
597
596
  }
@@ -614,31 +613,6 @@ function isColor(token, errors) {
614
613
  if (children.length == 4 || (isRelative && children.length == 6)) {
615
614
  return true;
616
615
  }
617
- if (children.length == 8 || children.length == 6) {
618
- children.at(-2);
619
- children.at(-1);
620
- // @ts-ignore
621
- // if (
622
- // ((children.length > 6 || !isRelative) && sep.typ != EnumToken.LiteralTokenType) ||
623
- // (sep as LiteralToken).val != "/"
624
- // ) {
625
- // return false;
626
- // }
627
- // if (alpha.typ == EnumToken.IdenTokenType && (alpha as IdentToken).val != "none") {
628
- // return false;
629
- // } else {
630
- // // @ts-ignore
631
- // if (alpha.typ == EnumToken.PercentageTokenType) {
632
- // if (+(alpha as PercentageToken).val < 0 || +(alpha as PercentageToken).val > 100) {
633
- // return false;
634
- // }
635
- // } else if (alpha.typ == EnumToken.NumberTokenType) {
636
- // if (+(alpha as NumberToken).val < 0 || +(alpha as NumberToken).val > 1) {
637
- // return false;
638
- // }
639
- // }
640
- // }
641
- }
642
616
  return true;
643
617
  }
644
618
  // @ts-ignore
@@ -655,9 +629,6 @@ function isColor(token, errors) {
655
629
  }
656
630
  return acc;
657
631
  }, [[]]);
658
- // if (children.length === 0 || children[0].length === 0) {
659
- // return false;
660
- // }
661
632
  let j = 0;
662
633
  let k = 0;
663
634
  if (children[j][0].typ === EnumToken.IdenTokenType &&
@@ -691,50 +662,13 @@ function isColor(token, errors) {
691
662
  k++;
692
663
  }
693
664
  }
694
- // else {
695
- // return false;
696
- // }
697
665
  }
698
666
  else {
699
667
  k++;
700
668
  }
701
669
  }
702
- // else {
703
- // return false;
704
- // }
705
- // if (k != children[j].length) {
706
- // return false;
707
- // }
708
670
  j++;
709
671
  }
710
- // while (j < children.length) {
711
- // if (children[j].length > 2) {
712
- // return false;
713
- // }
714
- // if (
715
- // !isColor(children[j][0]) &&
716
- // !(
717
- // children[j][0].typ == EnumToken.WildCardFunctionTokenType &&
718
- // equalsIgnoreCase("calc", (children[j][0] as FunctionToken).val)
719
- // )
720
- // ) {
721
- // return false;
722
- // }
723
- // if (children[j][0].typ == EnumToken.WildCardFunctionTokenType) {
724
- // const result = matchAllSyntaxes(
725
- // getParsedSyntax(ValidationSyntaxGroupEnum.Syntaxes, "calc()") as ValidationFunctionToken[],
726
- // createValidationContext([children[j][0]]),
727
- // {},
728
- // );
729
- // if (!result.success) {
730
- // return false;
731
- // }
732
- // }
733
- // if (children[j].length > 1 && !isPercentageToken(children[j][1])) {
734
- // return false;
735
- // }
736
- // j++;
737
- // }
738
672
  return true;
739
673
  }
740
674
  else {
@@ -747,21 +681,6 @@ function isColor(token, errors) {
747
681
  // @ts-ignore
748
682
  for (const v of token.chi) {
749
683
  if (v.typ == EnumToken.IdenTokenType) {
750
- // if (isColor(v)) {
751
- // continue;
752
- // }
753
- // if (!(keywords.includes(v.val) || COLORS_NAMES[v.val.toLowerCase()] != null)) {
754
- // return false;
755
- // }
756
- // if (keywords.includes(v.val)) {
757
- // if (isLegacySyntax) {
758
- // return false;
759
- // }
760
- // // @ts-ignore
761
- // if (v.val == "from" && ["rgba", "hsla"].includes((token as ColorToken).val)) {
762
- // return false;
763
- // }
764
- // }
765
684
  continue;
766
685
  }
767
686
  if (v.typ === EnumToken.MathFunctionTokenType ||
@@ -769,20 +688,6 @@ function isColor(token, errors) {
769
688
  colorsFunc.includes(v.val)) {
770
689
  continue;
771
690
  }
772
- // if (
773
- // ![
774
- // EnumToken.ColorTokenType,
775
- // EnumToken.IdenTokenType,
776
- // EnumToken.NumberTokenType,
777
- // EnumToken.AngleTokenType,
778
- // EnumToken.PercentageTokenType,
779
- // EnumToken.CommaTokenType,
780
- // EnumToken.WhitespaceTokenType,
781
- // EnumToken.LiteralTokenType,
782
- // ].includes(v.typ)
783
- // ) {
784
- // return false;
785
- // }
786
691
  }
787
692
  }
788
693
  return true;
@@ -838,63 +743,12 @@ function parseColor(token) {
838
743
  }
839
744
  if (token.val == "color") {
840
745
  let index = token.chi.indexOf(tk);
841
- // if ((token as ColorToken).cal == "rel") {
842
- // for (let k = 0; k < (token as ColorToken).chi!.length; k++) {
843
- // if (EnumToken.DashedIdenTokenType == (token as ColorToken).chi![k].typ) {
844
- // index = k;
845
- // break;
846
- // }
847
- // }
848
- // }
849
746
  if (EnumToken.DashedIdenTokenType == token?.chi?.[index]?.typ) {
850
747
  token.kin = ColorType.CUSTOM_COLOR;
851
748
  }
852
749
  }
853
750
  }
854
- // return token;
855
751
  }
856
- // @ts-ignore
857
- // token.typ = EnumToken.ColorTokenType;
858
- // // @ts-ignore
859
- // (token as ColorToken).kin = ColorType[token.val.replaceAll("-", "_").toUpperCase()];
860
- // if (!("chi" in token)) {
861
- // const val: string = (token as ColorToken).val.toLowerCase();
862
- // if (val == "currentcolor" || val == "transparent" || val in COLORS_NAMES) {
863
- // (token as ColorToken).kin = ColorType.LIT;
864
- // } else if (isHexColor(val)) {
865
- // (token as ColorToken).kin = ColorType.HEX;
866
- // }
867
- // const tk = (token as ColorToken).chi?.find(
868
- // (t) => t.typ !== EnumToken.WhitespaceTokenType && t.typ !== EnumToken.CommentTokenType,
869
- // );
870
- // if (tk?.typ === EnumToken.IdenTokenType && (tk as IdentToken).val === "from") {
871
- // (token as ColorToken).cal = "rel";
872
- // } else if ((token as ColorToken).val == "color-mix" && (tk as IdentToken).val == "in") {
873
- // (token as ColorToken).cal = "mix";
874
- // } else if ((token as ColorToken).val == "color") {
875
- // (token as ColorToken).cal = "col";
876
- // }
877
- // return token;
878
- // }
879
- // // @ts-ignore
880
- // if (((token as ColorToken).chi as Token[])[0].typ == EnumToken.IdenTokenType) {
881
- // // @ts-ignore
882
- // if (((token as ColorToken).chi as Token[])[0].val == "from") {
883
- // // @ts-ignore
884
- // (token as ColorToken).cal = "rel";
885
- // }
886
- // // @ts-ignore
887
- // else if ((token as ColorToken).val == "color-mix" && ((token as ColorToken).chi as Token[])[0].val == "in") {
888
- // // @ts-ignore
889
- // (token as ColorToken).cal = "mix";
890
- // } else {
891
- // // @ts-ignore
892
- // if ((token as ColorToken).val == "color") {
893
- // // @ts-ignore
894
- // (token as ColorToken).cal = "col";
895
- // }
896
- // }
897
- // }
898
752
  return token;
899
753
  }
900
754
  function isLetter(codepoint) {
@@ -940,6 +794,9 @@ const isIdent = memoize(function (name) {
940
794
  return false;
941
795
  }
942
796
  if (codepoint == REVERSE_SOLIDUS) {
797
+ if (i + 1 > j) {
798
+ return false;
799
+ }
943
800
  codepoint = name.charCodeAt(i + 1);
944
801
  // if (!isIdentCodepoint(codepoint)) {
945
802
  // return false;
@@ -967,18 +824,24 @@ const isIdent = memoize(function (name) {
967
824
  }
968
825
  return true;
969
826
  });
827
+ function isNonPrintable(codepoint) {
828
+ // null -> backspace
829
+ return ((codepoint >= 0 && codepoint <= 0x8) ||
830
+ // tab
831
+ codepoint == 0xb ||
832
+ // delete
833
+ codepoint == 0x7f ||
834
+ (codepoint >= 0xe && codepoint <= 0x1f));
835
+ }
970
836
  function isPseudo(name) {
971
837
  return (name.charAt(0) == ":" &&
972
838
  ((name.endsWith("(") && isIdent(name.charAt(1) == ":" ? name.slice(2, -1) : name.slice(1, -1))) ||
973
839
  isIdent(name.charAt(1) == ":" ? name.slice(2) : name.slice(1))));
974
840
  }
975
841
  function isHash(name) {
976
- return name.charAt(0) == "#" && isIdent(name.charAt(1));
842
+ return name.charAt(0) == "#" && isIdentStart(name.charCodeAt(1));
977
843
  }
978
844
  const isNumber = memoize(function (name) {
979
- // if (name.length == 0) {
980
- // return false;
981
- // }
982
845
  let codepoint = name.charCodeAt(0);
983
846
  let i = 0;
984
847
  const j = name.length;
@@ -1225,4 +1088,4 @@ function toPrecisionAngle(angle, precision = colorPrecision, correctValue = true
1225
1088
  return angle;
1226
1089
  }
1227
1090
 
1228
- export { dimensionUnits, isAngle, isColor, isDigit, isFlex, isFrequency, isFunction, isHash, isHexColor, isIdent, isIdentCodepoint, isIdentColor, isIdentStart, isLength, isLetter, isNewLine, isNumber, isPercentage, isPolarColorspace, isPseudo, isRectangularOrthogonalColorspace, isResolution, isTime, isWhiteSpace, length2Px, minifyNumber, parseColor, parseDimension, pseudoAliasMap, reduceColorStops, reduceConicColorStops, reducegradientBackgroundPosition, renamedStandardProperties, toPrecisionAngle, toPrecisionValue };
1091
+ export { dimensionUnits, isAngle, isColor, isDigit, isFlex, isFrequency, isFunction, isHash, isHexColor, isIdent, isIdentCodepoint, isIdentColor, isIdentStart, isLength, isLetter, isNewLine, isNonPrintable, isNumber, isPercentage, isPolarColorspace, isPseudo, isRectangularOrthogonalColorspace, isResolution, isTime, isWhiteSpace, length2Px, minifyNumber, parseColor, parseDimension, pseudoAliasMap, reduceColorStops, reduceConicColorStops, reducegradientBackgroundPosition, renamedStandardProperties, toPrecisionAngle, toPrecisionValue };
@@ -10,11 +10,19 @@ import { parseTokens } from '../parser/parse.js';
10
10
  const config = getSyntaxConfig();
11
11
  // @ts-expect-error
12
12
  const allValues = config.declarations.all.syntax.split(/[\s|]+/g);
13
+ /**
14
+ * @type {Array.<EnumToken>}
15
+ */
13
16
  const funcTypes = [
14
17
  ...tokensfuncDefMap.values(),
15
18
  EnumToken.FunctionTokenType,
16
19
  EnumToken.PseudoClassFuncTokenType,
17
20
  ];
21
+ /**
22
+ * trim leading and trailing whitespace
23
+ * @param tokens
24
+ * @returns
25
+ */
18
26
  function trimArray(tokens) {
19
27
  while (tokens[0]?.typ === EnumToken.WhitespaceTokenType) {
20
28
  tokens.shift();
@@ -115,6 +123,11 @@ function isMFValue(featureName, tokens, isMFRange) {
115
123
  success: true,
116
124
  };
117
125
  }
126
+ /**
127
+ * create validation context
128
+ * @param tokens
129
+ * @returns
130
+ */
118
131
  function createValidationContext(tokens) {
119
132
  tokens = trimArray(tokens.filter((t) => t.typ !== EnumToken.CommentTokenType));
120
133
  if (tokens.at(-1)?.typ === EnumToken.ImportantTokenType) {
@@ -278,6 +291,14 @@ function createValidationContext(tokens) {
278
291
  };
279
292
  return token;
280
293
  }
294
+ /**
295
+ * match selector syntax
296
+ * @param stream
297
+ * @param errors
298
+ * @param options
299
+ * @param nested
300
+ * @returns
301
+ */
281
302
  function matchSelectorSyntax(stream, errors, options, nested = true) {
282
303
  const stack = [];
283
304
  const tokens = [];
@@ -716,6 +737,13 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
716
737
  stream.push(...tokens);
717
738
  return { success, errors };
718
739
  }
740
+ /**
741
+ * matches all syntaxes
742
+ * @param syntaxes
743
+ * @param context
744
+ * @param options
745
+ * @returns
746
+ */
719
747
  function matchAllSyntaxes(syntaxes, context, options) {
720
748
  const result = matchSyntax(syntaxes, context, {
721
749
  ...options,
@@ -754,6 +782,13 @@ function matchAllSyntaxes(syntaxes, context, options) {
754
782
  syntaxToken: !result.success ? result.syntaxToken : null,
755
783
  };
756
784
  }
785
+ /**
786
+ * matches a list of syntaxes
787
+ * @param syntax
788
+ * @param context
789
+ * @param options
790
+ * @returns
791
+ */
757
792
  function matchListSyntax(syntax, context, options) {
758
793
  const { isList, match, isOptional, ...rest } = syntax;
759
794
  let success = true;
@@ -798,6 +833,13 @@ function matchListSyntax(syntax, context, options) {
798
833
  token: context.peek(),
799
834
  };
800
835
  }
836
+ /**
837
+ * matches a list of syntaxes
838
+ * @param syntax
839
+ * @param context
840
+ * @param options
841
+ * @returns
842
+ */
801
843
  function matchOccurenceSyntax(syntax, context, options) {
802
844
  const { match, ...rest } = syntax;
803
845
  let result = null;
@@ -839,6 +881,13 @@ function matchOccurenceSyntax(syntax, context, options) {
839
881
  }
840
882
  return result;
841
883
  }
884
+ /**
885
+ * matches a list of syntaxes
886
+ * @param syntaxes
887
+ * @param context
888
+ * @param options
889
+ * @returns
890
+ */
842
891
  function matchSyntax(syntaxes, context, options) {
843
892
  if (syntaxes == null) {
844
893
  return {
@@ -941,6 +990,7 @@ function matchSyntax(syntaxes, context, options) {
941
990
  return result;
942
991
  }
943
992
  if (tokensfuncDefMap.has(token.typ) &&
993
+ // @ts-ignore
944
994
  token.typ === EnumToken.WildCardFunctionTokenDefType) {
945
995
  const range = trimArray(context.peekRange());
946
996
  result = matchSyntax(getParsedSyntax(ValidationSyntaxGroupEnum.Syntaxes, token.val + "()")?.[0]?.chi, createValidationContext(range.slice(1, -1)), options);
@@ -971,7 +1021,7 @@ function matchSyntax(syntaxes, context, options) {
971
1021
  if (syntaxes[i].isList) {
972
1022
  result = matchListSyntax(syntaxes[i], context.slice(), options);
973
1023
  if (result.success) {
974
- options.visited.get(token).delete(syntaxes[i]);
1024
+ options.visited.get(token)?.delete?.(syntaxes[i]);
975
1025
  if (result.context.done()) {
976
1026
  context.end();
977
1027
  return {
@@ -1479,6 +1529,13 @@ function matchSyntax(syntaxes, context, options) {
1479
1529
  errors: [],
1480
1530
  };
1481
1531
  }
1532
+ /**
1533
+ * matches a column of syntaxes
1534
+ * @param syntax
1535
+ * @param context
1536
+ * @param options
1537
+ * @returns
1538
+ */
1482
1539
  function matchColumnSyntax(syntax, context, options) {
1483
1540
  let syntaxes = syntax.chi.slice();
1484
1541
  let i = 0;
@@ -1515,6 +1572,13 @@ function matchColumnSyntax(syntax, context, options) {
1515
1572
  errors: [],
1516
1573
  };
1517
1574
  }
1575
+ /**
1576
+ * matches an ampersand of syntaxes
1577
+ * @param syntax
1578
+ * @param context
1579
+ * @param options
1580
+ * @returns
1581
+ */
1518
1582
  function matchAmpersandSyntax(syntax, context, options) {
1519
1583
  const syntaxes = [syntax.l, syntax.r];
1520
1584
  let result;
@@ -1533,6 +1597,13 @@ function matchAmpersandSyntax(syntax, context, options) {
1533
1597
  }
1534
1598
  return result;
1535
1599
  }
1600
+ /**
1601
+ * matches a property
1602
+ * @param property
1603
+ * @param context
1604
+ * @param options
1605
+ * @returns
1606
+ */
1536
1607
  function matchProperty(property, context, options) {
1537
1608
  let success = false;
1538
1609
  let t = context.peek()?.typ;
@@ -1920,7 +1991,9 @@ function matchProperty(property, context, options) {
1920
1991
  // )
1921
1992
  // ) {
1922
1993
  const newRange = range.map((t) => cloneNode(t, true));
1994
+ // @ts-ignore
1923
1995
  parseTokens(newRange, { parseColor: true }, errors);
1996
+ // @ts-ignore
1924
1997
  success = newRange.length == 1 && isColor(newRange[0], errors);
1925
1998
  if (success) {
1926
1999
  context.update(range.at(-1));
@@ -2265,6 +2338,13 @@ function matchProperty(property, context, options) {
2265
2338
  errors: [],
2266
2339
  };
2267
2340
  }
2341
+ /**
2342
+ * matches a repeatable syntax
2343
+ * @param syntax
2344
+ * @param context
2345
+ * @param options
2346
+ * @returns
2347
+ */
2268
2348
  function matchRepeatableSyntax(syntax, context, options) {
2269
2349
  const { isRepeatable, isOptional, isMandatatoryGroup, isRepeatableAtLeastOnce, ...rest } = syntax;
2270
2350
  let result = null;