@tbela99/css-parser 0.9.0 → 0.9.1

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.
@@ -372,7 +372,7 @@ var declarations = {
372
372
  syntax: "auto || <ratio>"
373
373
  },
374
374
  "backdrop-filter": {
375
- syntax: "none | <filter-function-list>"
375
+ syntax: "none | <filter-value-list>"
376
376
  },
377
377
  "backface-visibility": {
378
378
  syntax: "visible | hidden"
@@ -786,7 +786,7 @@ var declarations = {
786
786
  syntax: "nonzero | evenodd"
787
787
  },
788
788
  filter: {
789
- syntax: "none | <filter-function-list>"
789
+ syntax: "none | <filter-value-list>"
790
790
  },
791
791
  flex: {
792
792
  syntax: "none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ]"
@@ -1242,7 +1242,7 @@ var declarations = {
1242
1242
  syntax: "<integer>"
1243
1243
  },
1244
1244
  outline: {
1245
- syntax: "[ <'outline-width'> || <'outline-style'> || <'outline-color'> ]"
1245
+ syntax: "<'outline-width'> || <'outline-style'> || <'outline-color'>"
1246
1246
  },
1247
1247
  "outline-color": {
1248
1248
  syntax: "auto | <color>"
@@ -1671,7 +1671,7 @@ var declarations = {
1671
1671
  syntax: "space-all | normal | space-first | trim-start"
1672
1672
  },
1673
1673
  "text-transform": {
1674
- syntax: "none | capitalize | uppercase | lowercase | full-width | full-size-kana"
1674
+ syntax: "none | [ capitalize | uppercase | lowercase ] || full-width || full-size-kana | math-auto"
1675
1675
  },
1676
1676
  "text-underline-offset": {
1677
1677
  syntax: "auto | <length> | <percentage> "
@@ -1761,7 +1761,7 @@ var declarations = {
1761
1761
  syntax: "visible | hidden | collapse"
1762
1762
  },
1763
1763
  "white-space": {
1764
- syntax: "normal | pre | nowrap | pre-wrap | pre-line | break-spaces | [ <'white-space-collapse'> || <'text-wrap'> ]"
1764
+ syntax: "normal | pre | pre-wrap | pre-line | <'white-space-collapse'> || <'text-wrap-mode'>"
1765
1765
  },
1766
1766
  "white-space-collapse": {
1767
1767
  syntax: "collapse | preserve | preserve-breaks | preserve-spaces | break-spaces"
@@ -1797,7 +1797,7 @@ var declarations = {
1797
1797
  syntax: "auto | <integer>"
1798
1798
  },
1799
1799
  zoom: {
1800
- syntax: "normal | reset | <number> | <percentage>"
1800
+ syntax: "normal | reset | <number [0,∞]> || <percentage [0,∞]>"
1801
1801
  }
1802
1802
  };
1803
1803
  var functions = {
@@ -1838,7 +1838,7 @@ var functions = {
1838
1838
  syntax: "calc-size( <calc-size-basis>, <calc-sum> )"
1839
1839
  },
1840
1840
  circle: {
1841
- syntax: "circle( [ <shape-radius> ]? [ at <position> ]? )"
1841
+ syntax: "circle( <radial-size>? [ at <position> ]? )"
1842
1842
  },
1843
1843
  clamp: {
1844
1844
  syntax: "clamp( <calc-sum>#{3} )"
@@ -1874,7 +1874,7 @@ var functions = {
1874
1874
  syntax: "element( <id-selector> )"
1875
1875
  },
1876
1876
  ellipse: {
1877
- syntax: "ellipse( [ <shape-radius>{2} ]? [ at <position> ]? )"
1877
+ syntax: "ellipse( <radial-size>? [ at <position> ]? )"
1878
1878
  },
1879
1879
  env: {
1880
1880
  syntax: "env( <custom-ident> , <declaration-value>? )"
@@ -1889,16 +1889,16 @@ var functions = {
1889
1889
  syntax: "grayscale( [ <number> | <percentage> ]? )"
1890
1890
  },
1891
1891
  hsl: {
1892
- syntax: "hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )"
1892
+ syntax: "hsl( <hue>, <percentage>, <percentage>, <alpha-value>? ) | hsl( [ <hue> | none ] [ <percentage> | <number> | none ] [ <percentage> | <number> | none ] [ / [ <alpha-value> | none ] ]? )"
1893
1893
  },
1894
1894
  hsla: {
1895
- syntax: "hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? )"
1895
+ syntax: "hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ) | hsla( [ <hue> | none ] [ <percentage> | <number> | none ] [ <percentage> | <number> | none ] [ / [ <alpha-value> | none ] ]? )"
1896
1896
  },
1897
1897
  "hue-rotate": {
1898
1898
  syntax: "hue-rotate( [ <angle> | <zero> ]? )"
1899
1899
  },
1900
1900
  hwb: {
1901
- syntax: "hwb( [<hue> | none] [<percentage> | none] [<percentage> | none] [ / [<alpha-value> | none] ]? )"
1901
+ syntax: "hwb( [ <hue> | none ] [ <percentage> | <number> | none ] [ <percentage> | <number> | none ] [ / [ <alpha-value> | none ] ]? )"
1902
1902
  },
1903
1903
  hypot: {
1904
1904
  syntax: "hypot( <calc-sum># )"
@@ -1987,6 +1987,9 @@ var functions = {
1987
1987
  ray: {
1988
1988
  syntax: "ray( <angle> && <ray-size>? && contain? && [at <position>]? )"
1989
1989
  },
1990
+ rect: {
1991
+ syntax: "rect( [ <length-percentage> | auto ]{4} [ round <'border-radius'> ]? )"
1992
+ },
1990
1993
  rem: {
1991
1994
  syntax: "rem( <calc-sum>, <calc-sum> )"
1992
1995
  },
@@ -2000,10 +2003,10 @@ var functions = {
2000
2003
  syntax: "repeating-radial-gradient( [ <ending-shape> || <size> ]? [ at <position> ]? , <color-stop-list> )"
2001
2004
  },
2002
2005
  rgb: {
2003
- syntax: "rgb( <percentage>{3} [ / <alpha-value> ]? ) | rgb( <number>{3} [ / <alpha-value> ]? ) | rgb( <percentage>#{3} , <alpha-value>? ) | rgb( <number>#{3} , <alpha-value>? )"
2006
+ syntax: "rgb( <percentage>#{3} , <alpha-value>? ) | rgb( <number>#{3} , <alpha-value>? ) | rgb( [ <number> | <percentage> | none ]{3} [ / [ <alpha-value> | none ] ]? )"
2004
2007
  },
2005
2008
  rgba: {
2006
- syntax: "rgba( <percentage>{3} [ / <alpha-value> ]? ) | rgba( <number>{3} [ / <alpha-value> ]? ) | rgba( <percentage>#{3} , <alpha-value>? ) | rgba( <number>#{3} , <alpha-value>? )"
2009
+ syntax: "rgba( <percentage>#{3} , <alpha-value>? ) | rgba( <number>#{3} , <alpha-value>? ) | rgba( [ <number> | <percentage> | none ]{3} [ / [ <alpha-value> | none ] ]? )"
2007
2010
  },
2008
2011
  rotate: {
2009
2012
  syntax: "rotate( [ <angle> | <zero> ] )"
@@ -2065,6 +2068,9 @@ var functions = {
2065
2068
  sqrt: {
2066
2069
  syntax: "sqrt( <calc-sum> )"
2067
2070
  },
2071
+ symbols: {
2072
+ syntax: "symbols( <symbols-type>? [ <string> | <image> ]+ )"
2073
+ },
2068
2074
  tan: {
2069
2075
  syntax: "tan( <calc-sum> )"
2070
2076
  },
@@ -2097,6 +2103,9 @@ var functions = {
2097
2103
  },
2098
2104
  view: {
2099
2105
  syntax: "view([<axis> || <'view-timeline-inset'>]?)"
2106
+ },
2107
+ xywh: {
2108
+ syntax: "xywh( <length-percentage>{2} <length-percentage [0,∞]>{2} [ round <'border-radius'> ]? )"
2100
2109
  }
2101
2110
  };
2102
2111
  var syntaxes = {
@@ -2112,6 +2121,9 @@ var syntaxes = {
2112
2121
  "alpha-value": {
2113
2122
  syntax: "<number> | <percentage>"
2114
2123
  },
2124
+ "an+b": {
2125
+ syntax: "odd | even | <integer> | <n-dimension> | '+'?† n | -n | <ndashdigit-dimension> | '+'?† <ndashdigit-ident> | <dashndashdigit-ident> | <n-dimension> <signed-integer> | '+'?† n <signed-integer> | -n <signed-integer> | <ndash-dimension> <signless-integer> | '+'?† n- <signless-integer> | -n- <signless-integer> | <n-dimension> ['+' | '-'] <signless-integer> | '+'?† n ['+' | '-'] <signless-integer> | -n ['+' | '-'] <signless-integer>"
2126
+ },
2115
2127
  "anchor()": {
2116
2128
  syntax: "anchor( <anchor-name>? && <anchor-side>, <length-percentage>? )"
2117
2129
  },
@@ -2233,7 +2245,7 @@ var syntaxes = {
2233
2245
  syntax: "<percentage>? && <image>"
2234
2246
  },
2235
2247
  "circle()": {
2236
- syntax: "circle( [ <shape-radius> ]? [ at <position> ]? )"
2248
+ syntax: "circle( <radial-size>? [ at <position> ]? )"
2237
2249
  },
2238
2250
  "clamp()": {
2239
2251
  syntax: "clamp( <calc-sum>#{3} )"
@@ -2247,15 +2259,15 @@ var syntaxes = {
2247
2259
  color: {
2248
2260
  syntax: "<color-base> | currentColor | <system-color> | <light-dark()> | <deprecated-system-color>"
2249
2261
  },
2262
+ "color()": {
2263
+ syntax: "color( [ from <color> ]? <colorspace-params> [ / [ <alpha-value> | none ] ]? )"
2264
+ },
2250
2265
  "color-base": {
2251
2266
  syntax: "<hex-color> | <color-function> | <named-color> | <color-mix()> | transparent"
2252
2267
  },
2253
2268
  "color-function": {
2254
2269
  syntax: "<rgb()> | <rgba()> | <hsl()> | <hsla()> | <hwb()> | <lab()> | <lch()> | <oklab()> | <oklch()> | <color()>"
2255
2270
  },
2256
- "color()": {
2257
- syntax: "color( [from <color>]? <colorspace-params> [ / [ <alpha-value> | none ] ]? )"
2258
- },
2259
2271
  "color-interpolation-method": {
2260
2272
  syntax: "in [ <rectangular-color-space> | <polar-color-space> <hue-interpolation-method>? | <custom-color-space> ]"
2261
2273
  },
@@ -2364,6 +2376,9 @@ var syntaxes = {
2364
2376
  dasharray: {
2365
2377
  syntax: "[ [ <length-percentage> | <number> ]+ ]#"
2366
2378
  },
2379
+ "dashndashdigit-ident": {
2380
+ syntax: "<ident-token>"
2381
+ },
2367
2382
  "deprecated-system-color": {
2368
2383
  syntax: "ActiveBorder | ActiveCaption | AppWorkspace | Background | ButtonHighlight | ButtonShadow | CaptionText | InactiveBorder | InactiveCaption | InactiveCaptionText | InfoBackground | InfoText | Menu | MenuText | Scrollbar | ThreeDDarkShadow | ThreeDFace | ThreeDHighlight | ThreeDLightShadow | ThreeDShadow | Window | WindowFrame | WindowText"
2369
2384
  },
@@ -2404,7 +2419,7 @@ var syntaxes = {
2404
2419
  syntax: "element( <id-selector> )"
2405
2420
  },
2406
2421
  "ellipse()": {
2407
- syntax: "ellipse( [ <shape-radius>{2} ]? [ at <position> ]? )"
2422
+ syntax: "ellipse( <radial-size>? [ at <position> ]? )"
2408
2423
  },
2409
2424
  "ending-shape": {
2410
2425
  syntax: "circle | ellipse"
@@ -2445,7 +2460,7 @@ var syntaxes = {
2445
2460
  "filter-function": {
2446
2461
  syntax: "<blur()> | <brightness()> | <contrast()> | <drop-shadow()> | <grayscale()> | <hue-rotate()> | <invert()> | <opacity()> | <saturate()> | <sepia()>"
2447
2462
  },
2448
- "filter-function-list": {
2463
+ "filter-value-list": {
2449
2464
  syntax: "[ <filter-function> | <url> ]+"
2450
2465
  },
2451
2466
  "final-bg-layer": {
@@ -2500,10 +2515,10 @@ var syntaxes = {
2500
2515
  syntax: "[ historical-ligatures | no-historical-ligatures ]"
2501
2516
  },
2502
2517
  "hsl()": {
2503
- syntax: "hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )"
2518
+ syntax: "hsl( <hue>, <percentage>, <percentage>, <alpha-value>? ) | hsl( [ <hue> | none ] [ <percentage> | <number> | none ] [ <percentage> | <number> | none ] [ / [ <alpha-value> | none ] ]? )"
2504
2519
  },
2505
2520
  "hsla()": {
2506
- syntax: "hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? )"
2521
+ syntax: "hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ) | hsla( [ <hue> | none ] [ <percentage> | <number> | none ] [ <percentage> | <number> | none ] [ / [ <alpha-value> | none ] ]? )"
2507
2522
  },
2508
2523
  hue: {
2509
2524
  syntax: "<number> | <angle>"
@@ -2515,7 +2530,7 @@ var syntaxes = {
2515
2530
  syntax: "hue-rotate( [ <angle> | <zero> ]? )"
2516
2531
  },
2517
2532
  "hwb()": {
2518
- syntax: "hwb( [<hue> | none] [<percentage> | none] [<percentage> | none] [ / [<alpha-value> | none] ]? )"
2533
+ syntax: "hwb( [ <hue> | none ] [ <percentage> | <number> | none ] [ <percentage> | <number> | none ] [ / [ <alpha-value> | none ] ]? )"
2519
2534
  },
2520
2535
  "hypot()": {
2521
2536
  syntax: "hypot( <calc-sum># )"
@@ -2523,6 +2538,9 @@ var syntaxes = {
2523
2538
  "id-selector": {
2524
2539
  syntax: "<hash-token>"
2525
2540
  },
2541
+ integer: {
2542
+ syntax: "<number-token>"
2543
+ },
2526
2544
  image: {
2527
2545
  syntax: "<url> | <image()> | <image-set()> | <element()> | <paint()> | <cross-fade()> | <gradient>"
2528
2546
  },
@@ -2688,6 +2706,18 @@ var syntaxes = {
2688
2706
  "mod()": {
2689
2707
  syntax: "mod( <calc-sum>, <calc-sum> )"
2690
2708
  },
2709
+ "n-dimension": {
2710
+ syntax: "<dimension-token>"
2711
+ },
2712
+ "ndash-dimension": {
2713
+ syntax: "<dimension-token>"
2714
+ },
2715
+ "ndashdigit-dimension": {
2716
+ syntax: "<dimension-token>"
2717
+ },
2718
+ "ndashdigit-ident": {
2719
+ syntax: "<ident-token>"
2720
+ },
2691
2721
  "name-repeat": {
2692
2722
  syntax: "repeat( [ <integer [1,∞]> | auto-fill ], <line-names>+ )"
2693
2723
  },
@@ -2700,9 +2730,6 @@ var syntaxes = {
2700
2730
  "ns-prefix": {
2701
2731
  syntax: "[ <ident-token> | '*' ]? '|'"
2702
2732
  },
2703
- nth: {
2704
- syntax: "<an-plus-b> | even | odd"
2705
- },
2706
2733
  "number-percentage": {
2707
2734
  syntax: "<number> | <percentage>"
2708
2735
  },
@@ -2811,9 +2838,15 @@ var syntaxes = {
2811
2838
  quote: {
2812
2839
  syntax: "open-quote | close-quote | no-open-quote | no-close-quote"
2813
2840
  },
2841
+ "radial-extent": {
2842
+ syntax: "closest-corner | closest-side | farthest-corner | farthest-side"
2843
+ },
2814
2844
  "radial-gradient()": {
2815
2845
  syntax: "radial-gradient( [ <ending-shape> || <size> ]? [ at <position> ]? , <color-stop-list> )"
2816
2846
  },
2847
+ "radial-size": {
2848
+ syntax: "<radial-extent> | <length [0,∞]> | <length-percentage [0,∞]>{2}"
2849
+ },
2817
2850
  ratio: {
2818
2851
  syntax: "<number [0,∞]> [ / <number [0,∞]> ]?"
2819
2852
  },
@@ -2835,6 +2868,9 @@ var syntaxes = {
2835
2868
  "relative-size": {
2836
2869
  syntax: "larger | smaller"
2837
2870
  },
2871
+ "rect()": {
2872
+ syntax: "rect( [ <length-percentage> | auto ]{4} [ round <'border-radius'> ]? )"
2873
+ },
2838
2874
  "rem()": {
2839
2875
  syntax: "rem( <calc-sum>, <calc-sum> )"
2840
2876
  },
@@ -2854,10 +2890,10 @@ var syntaxes = {
2854
2890
  syntax: "reversed( <counter-name> )"
2855
2891
  },
2856
2892
  "rgb()": {
2857
- syntax: "rgb( <percentage>{3} [ / <alpha-value> ]? ) | rgb( <number>{3} [ / <alpha-value> ]? ) | rgb( <percentage>#{3} , <alpha-value>? ) | rgb( <number>#{3} , <alpha-value>? )"
2893
+ syntax: "rgb( <percentage>#{3} , <alpha-value>? ) | rgb( <number>#{3} , <alpha-value>? ) | rgb( [ <number> | <percentage> | none ]{3} [ / [ <alpha-value> | none ] ]? )"
2858
2894
  },
2859
2895
  "rgba()": {
2860
- syntax: "rgba( <percentage>{3} [ / <alpha-value> ]? ) | rgba( <number>{3} [ / <alpha-value> ]? ) | rgba( <percentage>#{3} , <alpha-value>? ) | rgba( <number>#{3} , <alpha-value>? )"
2896
+ syntax: "rgba( <percentage>#{3} , <alpha-value>? ) | rgba( <number>#{3} , <alpha-value>? ) | rgba( [ <number> | <percentage> | none ]{3} [ / [ <alpha-value> | none ] ]? )"
2861
2897
  },
2862
2898
  "rotate()": {
2863
2899
  syntax: "rotate( [ <angle> | <zero> ] )"
@@ -2931,15 +2967,18 @@ var syntaxes = {
2931
2967
  "shape-box": {
2932
2968
  syntax: "<visual-box> | margin-box"
2933
2969
  },
2934
- "shape-radius": {
2935
- syntax: "<length-percentage> | closest-side | farthest-side"
2936
- },
2937
2970
  "side-or-corner": {
2938
2971
  syntax: "[ left | right ] || [ top | bottom ]"
2939
2972
  },
2940
2973
  "sign()": {
2941
2974
  syntax: "sign( <calc-sum> )"
2942
2975
  },
2976
+ "signed-integer": {
2977
+ syntax: "<number-token>"
2978
+ },
2979
+ "signless-integer": {
2980
+ syntax: "<number-token>"
2981
+ },
2943
2982
  "sin()": {
2944
2983
  syntax: "sin( <calc-sum> )"
2945
2984
  },
@@ -3012,6 +3051,12 @@ var syntaxes = {
3012
3051
  symbol: {
3013
3052
  syntax: "<string> | <image> | <custom-ident>"
3014
3053
  },
3054
+ "symbols()": {
3055
+ syntax: "symbols( <symbols-type>? [ <string> | <image> ]+ )"
3056
+ },
3057
+ "symbols-type": {
3058
+ syntax: "cyclic | numeric | alphabetic | symbolic | fixed"
3059
+ },
3015
3060
  "system-color": {
3016
3061
  syntax: "AccentColor | AccentColorText | ActiveText | ButtonBorder | ButtonFace | ButtonText | Canvas | CanvasText | Field | FieldText | GrayText | Highlight | HighlightText | LinkText | Mark | MarkText | SelectedItem | SelectedItemText | VisitedText"
3017
3062
  },
@@ -3102,6 +3147,9 @@ var syntaxes = {
3102
3147
  "wq-name": {
3103
3148
  syntax: "<ns-prefix>? <ident-token>"
3104
3149
  },
3150
+ "xywh()": {
3151
+ syntax: "xywh( <length-percentage>{2} <length-percentage [0,∞]>{2} [ round <'border-radius'> ]? )"
3152
+ },
3105
3153
  xyz: {
3106
3154
  syntax: "xyz | xyz-d50 | xyz-d65"
3107
3155
  },
@@ -3237,16 +3285,16 @@ var selectors = {
3237
3285
  syntax: ":not( <complex-selector-list> )"
3238
3286
  },
3239
3287
  ":nth-child()": {
3240
- syntax: ":nth-child( <nth> [ of <complex-selector-list> ]? )"
3288
+ syntax: ":nth-child( <an+b> [ of <complex-selector-list> ]? )"
3241
3289
  },
3242
3290
  ":nth-last-child()": {
3243
- syntax: ":nth-last-child( <nth> [ of <complex-selector-list> ]? )"
3291
+ syntax: ":nth-last-child( <an+b> [ of <complex-selector-list> ]? )"
3244
3292
  },
3245
3293
  ":nth-last-of-type()": {
3246
- syntax: ":nth-last-of-type( <nth> )"
3294
+ syntax: ":nth-last-of-type( <an+b> )"
3247
3295
  },
3248
3296
  ":nth-of-type()": {
3249
- syntax: ":nth-of-type( <nth> )"
3297
+ syntax: ":nth-of-type( <an+b> )"
3250
3298
  },
3251
3299
  ":only-child": {
3252
3300
  syntax: ":only-child"
@@ -3529,7 +3577,7 @@ var atRules = {
3529
3577
  syntax: "normal | <percentage>"
3530
3578
  },
3531
3579
  "font-display": {
3532
- syntax: "[ auto | block | swap | fallback | optional ]"
3580
+ syntax: "auto | block | swap | fallback | optional"
3533
3581
  },
3534
3582
  "font-family": {
3535
3583
  syntax: "<family-name>"
@@ -5,7 +5,7 @@ import '../parser/parse.js';
5
5
  import '../renderer/color/utils/constants.js';
6
6
  import '../renderer/sourcemap/lib/encode.js';
7
7
  import '../parser/utils/config.js';
8
- import { getParsedSyntax, getSyntaxConfig } from './config.js';
8
+ import { getSyntaxConfig, getParsedSyntax } from './config.js';
9
9
  import { validateSyntax } from './syntax.js';
10
10
 
11
11
  function validateDeclaration(declaration, options, root) {
@@ -23,7 +23,6 @@ function validateDeclaration(declaration, options, root) {
23
23
  if (root?.typ == EnumToken.AtRuleNodeType) {
24
24
  //
25
25
  const syntax = getParsedSyntax("atRules" /* ValidationSyntaxGroupEnum.AtRules */, '@' + root.nam)?.[0];
26
- // console.error({syntax});
27
26
  if (syntax != null) {
28
27
  if (!('chi' in syntax)) {
29
28
  return {
@@ -52,7 +51,7 @@ function validateDeclaration(declaration, options, root) {
52
51
  valid: ValidationLevel.Drop,
53
52
  node: declaration,
54
53
  syntax: `<${declaration.nam}>`,
55
- error: ` declaration <${declaration.nam}> is not allowed in <@${root.nam}>`
54
+ error: `declaration <${declaration.nam}> is not allowed in <@${root.nam}>`
56
55
  };
57
56
  }
58
57
  const syntax = getParsedSyntax("atRules" /* ValidationSyntaxGroupEnum.AtRules */, ['@' + root.nam, 'descriptors', name]);
@@ -89,13 +88,6 @@ function validateDeclaration(declaration, options, root) {
89
88
  error: `unknown declaration "${declaration.nam}"`
90
89
  };
91
90
  }
92
- // return {
93
- //
94
- // valid: ValidationLevel.Valid,
95
- // node: declaration,
96
- // syntax: null,
97
- // error: ''
98
- // }
99
91
  return validateSyntax(getParsedSyntax("declarations" /* ValidationSyntaxGroupEnum.Declarations */, name), declaration.val);
100
92
  }
101
93
 
@@ -949,100 +949,6 @@ function move(position, chr) {
949
949
  }
950
950
  return position;
951
951
  }
952
- function renderSyntax(token, parent) {
953
- let glue;
954
- switch (token.typ) {
955
- case ValidationTokenEnum.Root:
956
- return token.chi.reduce((acc, curr) => acc + renderSyntax(curr), '');
957
- case ValidationTokenEnum.Whitespace:
958
- return ' ';
959
- case ValidationTokenEnum.ValidationFunctionDefinition:
960
- return '<' + token.val + '()>';
961
- case ValidationTokenEnum.HashMark:
962
- return '#';
963
- case ValidationTokenEnum.Pipe:
964
- return '|';
965
- case ValidationTokenEnum.Column:
966
- return '||';
967
- case ValidationTokenEnum.PipeToken:
968
- return token.chi.reduce((acc, curr) => acc + (acc.trim().length > 0 ? '|' : '') + curr.reduce((acc, curr) => acc + renderSyntax(curr), ''), '');
969
- case ValidationTokenEnum.ColumnToken:
970
- case ValidationTokenEnum.AmpersandToken:
971
- glue = token.typ == ValidationTokenEnum.ColumnToken ? '||' : '&&';
972
- return token.l.reduce((acc, curr) => acc + renderSyntax(curr), '') +
973
- glue +
974
- token.r.reduce((acc, curr) => acc + renderSyntax(curr), '');
975
- case ValidationTokenEnum.Function:
976
- case ValidationTokenEnum.PseudoClassFunctionToken:
977
- case ValidationTokenEnum.Parens:
978
- return token.val + '(' + token.chi.reduce((acc, curr) => acc + renderSyntax(curr), '') + ')' + renderAttributes(token);
979
- case ValidationTokenEnum.Comma:
980
- return ',';
981
- case ValidationTokenEnum.Keyword:
982
- return token.val + renderAttributes(token);
983
- case ValidationTokenEnum.OpenBracket:
984
- return '[';
985
- case ValidationTokenEnum.Ampersand:
986
- return '&&';
987
- case ValidationTokenEnum.QuestionMark:
988
- return '?';
989
- case ValidationTokenEnum.Separator:
990
- return '/';
991
- case ValidationTokenEnum.Bracket:
992
- return '[' + token.chi.reduce((acc, curr) => acc + renderSyntax(curr), '') + ']' + renderAttributes(token);
993
- case ValidationTokenEnum.PropertyType:
994
- return '<' + token.val + '>' + renderAttributes(token);
995
- case ValidationTokenEnum.DeclarationType:
996
- return "<'" + token.val + "'>" + renderAttributes(token);
997
- case ValidationTokenEnum.Number:
998
- case ValidationTokenEnum.PseudoClassToken:
999
- case ValidationTokenEnum.StringToken:
1000
- return token.val + '';
1001
- case ValidationTokenEnum.SemiColon:
1002
- return ';';
1003
- case ValidationTokenEnum.AtRule:
1004
- return '@' + token.val;
1005
- case ValidationTokenEnum.AtRuleDefinition:
1006
- return '@' + token.val +
1007
- (token.prelude == null ? '' : ' ' + token.prelude.reduce((acc, curr) => acc + renderSyntax(curr), '')) +
1008
- (token.chi == null ? '' : ' {\n' + token.chi.reduce((acc, curr) => acc + renderSyntax(curr), '')).slice(1, -1) + '\n}';
1009
- case ValidationTokenEnum.Block:
1010
- return '{' + token.chi.reduce((acc, t) => acc + renderSyntax(t), '') + '}';
1011
- case ValidationTokenEnum.DeclarationDefinitionToken:
1012
- return token.nam + ': ' + renderSyntax(token.val);
1013
- case ValidationTokenEnum.ColumnArrayToken:
1014
- return token.chi.reduce((acc, curr) => acc + (acc.trim().length > 0 ? '||' : '') + renderSyntax(curr), '');
1015
- default:
1016
- throw new Error('Unhandled token: ' + JSON.stringify({ token }));
1017
- }
1018
- }
1019
- function renderAttributes(token) {
1020
- let result = '';
1021
- if (token.isList) {
1022
- result += '#';
1023
- }
1024
- if (token.isOptional) {
1025
- result += '?';
1026
- }
1027
- if (token.isRepeatableGroup) {
1028
- result += '!';
1029
- }
1030
- if (token.isRepeatable) {
1031
- result += '*';
1032
- }
1033
- if (token.atLeastOnce) {
1034
- result += '+';
1035
- }
1036
- if (token.occurence != null) {
1037
- if (token.occurence.max == 0 || token.occurence.max == token.occurence.min || Number.isNaN(token.occurence.max)) {
1038
- result += '{' + token.occurence.min + '}';
1039
- }
1040
- else {
1041
- result += '{' + token.occurence.min + ',' + token.occurence.max + '}';
1042
- }
1043
- }
1044
- return result;
1045
- }
1046
952
  function minify(ast) {
1047
953
  if (Array.isArray(ast)) {
1048
954
  // @ts-ignore
@@ -1143,4 +1049,4 @@ function* walkValidationToken(token, parent, callback, key) {
1143
1049
  }
1144
1050
  }
1145
1051
 
1146
- export { WalkValidationTokenEnum, WalkValidationTokenKeyTypeEnum, parseSyntax, renderSyntax, walkValidationToken };
1052
+ export { WalkValidationTokenEnum, WalkValidationTokenKeyTypeEnum, parseSyntax, walkValidationToken };
@@ -1,4 +1,3 @@
1
- const specialValues = ['inherit', 'initial', 'unset', 'revert', 'revert-layer'];
2
1
  var ValidationTokenEnum;
3
2
  (function (ValidationTokenEnum) {
4
3
  ValidationTokenEnum[ValidationTokenEnum["Root"] = 0] = "Root";
@@ -52,4 +51,4 @@ var ValidationSyntaxGroupEnum;
52
51
  ValidationSyntaxGroupEnum["AtRules"] = "atRules";
53
52
  })(ValidationSyntaxGroupEnum || (ValidationSyntaxGroupEnum = {}));
54
53
 
55
- export { ValidationSyntaxGroupEnum, ValidationTokenEnum, specialValues };
54
+ export { ValidationSyntaxGroupEnum, ValidationTokenEnum };
@@ -6,8 +6,7 @@ import '../ast/walk.js';
6
6
  import '../parser/parse.js';
7
7
  import { isLength } from '../syntax/syntax.js';
8
8
  import '../parser/utils/config.js';
9
- import '../renderer/color/utils/constants.js';
10
- import '../renderer/sourcemap/lib/encode.js';
9
+ import { renderToken } from '../renderer/render.js';
11
10
  import { getSyntaxConfig, getParsedSyntax } from './config.js';
12
11
  import { validateSelector } from './selector.js';
13
12
  import './syntaxes/complex-selector.js';
@@ -33,9 +32,9 @@ function splice(tokens, matches) {
33
32
  }
34
33
  function validateSyntax(syntaxes, tokens, root, options, context = { level: 0 }) {
35
34
  console.error(JSON.stringify({
36
- syntax: syntaxes.reduce((acc, curr) => acc + renderSyntax(curr), ''),
37
- syntaxes,
38
- tokens,
35
+ syntax: syntaxes?.reduce?.((acc, curr) => acc + renderSyntax(curr), ''),
36
+ // syntaxes,
37
+ tokens: tokens.reduce((acc, curr) => acc + renderToken(curr), ''),
39
38
  s: new Error('bar').stack
40
39
  }, null, 1));
41
40
  if (syntaxes == null) {
@@ -1391,6 +1390,41 @@ function doValidateSyntax(syntax, token, tokens, root, options, context) {
1391
1390
  tokens
1392
1391
  };
1393
1392
  break;
1393
+ case ValidationTokenEnum.ColumnArrayToken:
1394
+ {
1395
+ matches = [];
1396
+ queue = [];
1397
+ const children = syntax.chi;
1398
+ let child;
1399
+ while (child = children.shift()) {
1400
+ result = validateSyntax([child], tokens, root, options, context);
1401
+ if (result.valid == ValidationLevel.Valid) {
1402
+ matches.push(child);
1403
+ consumeToken(tokens);
1404
+ token = tokens[0];
1405
+ if (queue.length > 0) {
1406
+ children.unshift(...queue);
1407
+ queue = [];
1408
+ }
1409
+ if (token == null) {
1410
+ break;
1411
+ }
1412
+ }
1413
+ else {
1414
+ queue.push(child);
1415
+ }
1416
+ }
1417
+ valid = matches.length > 0;
1418
+ result = {
1419
+ valid: valid ? ValidationLevel.Valid : ValidationLevel.Drop,
1420
+ matches: valid ? [token] : [],
1421
+ node: valid ? null : token,
1422
+ syntax,
1423
+ error: valid ? '' : 'expecting token',
1424
+ tokens
1425
+ };
1426
+ }
1427
+ break;
1394
1428
  case ValidationTokenEnum.ColumnToken:
1395
1429
  children = [...syntax.l.slice(), ...syntax.r.slice()];
1396
1430
  matches = [];
@@ -80,8 +80,8 @@ function validateCompoundSelector(tokens, root, options) {
80
80
  tokens.shift();
81
81
  consumeWhitespace(tokens);
82
82
  }
83
- while (tokens.length > 0 && tokens[0].typ == EnumToken.PseudoClassTokenType) {
84
- const isPseudoElement = tokens[0].val.startsWith('::');
83
+ while (tokens.length > 0 && (tokens[0].typ == EnumToken.PseudoElementTokenType || tokens[0].typ == EnumToken.PseudoClassTokenType)) {
84
+ const isPseudoElement = tokens[0].typ == EnumToken.PseudoElementTokenType;
85
85
  if (
86
86
  // https://developer.mozilla.org/en-US/docs/Web/CSS/WebKit_Extensions#pseudo-elements
87
87
  !(isPseudoElement && tokens[0].val.startsWith('::-webkit-')) &&
@@ -15,7 +15,7 @@ function validateLayerName(tokens) {
15
15
  acc[acc.length - 1].push(curr);
16
16
  }
17
17
  return acc;
18
- }, [[]]).slice(1);
18
+ }, [[]]);
19
19
  for (let i = 0; i < slice.length; i++) {
20
20
  if (slice[i].length == 0) {
21
21
  // @ts-ignore
@@ -28,26 +28,15 @@ function validateLayerName(tokens) {
28
28
  tokens
29
29
  };
30
30
  }
31
- if (slice[i][0].typ != EnumToken.IdenTokenType) {
32
- // @ts-ignore
33
- return {
34
- valid: ValidationLevel.Drop,
35
- matches: tokens,
36
- node: slice[i][0],
37
- syntax: 'ident',
38
- error: 'expecting ident',
39
- tokens
40
- };
41
- }
42
- for (let j = 1; j < slice[i].length; j++) {
43
- if (slice[i][j].typ != EnumToken.ClassSelectorTokenType) {
31
+ for (let j = 0; j < slice[i].length; j++) {
32
+ if (slice[i][j].typ != EnumToken.IdenTokenType && slice[i][j].typ != EnumToken.ClassSelectorTokenType) {
44
33
  // @ts-ignore
45
34
  return {
46
35
  valid: ValidationLevel.Drop,
47
36
  matches: tokens,
48
37
  node: slice[i][j],
49
- syntax: 'layer-name',
50
- error: 'expecting class selector',
38
+ syntax: '<layer-name>',
39
+ error: 'expecting ident or class selector',
51
40
  tokens
52
41
  };
53
42
  }