@tbela99/css-parser 1.1.0 → 1.1.1-alpha4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -14,8 +14,17 @@ var SyntaxValidationResult;
14
14
  */
15
15
  exports.ValidationLevel = void 0;
16
16
  (function (ValidationLevel) {
17
+ /**
18
+ * disable validation
19
+ */
17
20
  ValidationLevel[ValidationLevel["None"] = 0] = "None";
21
+ /**
22
+ * validate selectors and at-rules
23
+ */
18
24
  ValidationLevel[ValidationLevel["Default"] = 1] = "Default";
25
+ /**
26
+ * validate selectors, at-rules and declarations
27
+ */
19
28
  ValidationLevel[ValidationLevel["All"] = 2] = "All"; // selectors + at-rules + declarations
20
29
  })(exports.ValidationLevel || (exports.ValidationLevel = {}));
21
30
  /**
@@ -4285,6 +4294,8 @@ const pseudoElements = [':before', ':after', ':first-line', ':first-letter'];
4285
4294
  // https://developer.mozilla.org/en-US/docs/Web/CSS/WebKit_Extensions
4286
4295
  // https://developer.mozilla.org/en-US/docs/Web/CSS/Mozilla_Extensions
4287
4296
  const pseudoAliasMap = {
4297
+ '-moz-center': 'center',
4298
+ '-webkit-center': 'center',
4288
4299
  '-ms-grid-columns': 'grid-template-columns',
4289
4300
  '-ms-grid-rows': 'grid-template-rows',
4290
4301
  '-ms-grid-row': 'grid-row-start',
@@ -4297,6 +4308,7 @@ const pseudoAliasMap = {
4297
4308
  '::-ms-input-placeholder': '::placeholder',
4298
4309
  ':-moz-any()': ':is',
4299
4310
  '-moz-user-modify': 'user-modify',
4311
+ '-webkit-match-parent': 'match-parent',
4300
4312
  '-moz-background-clip': 'background-clip',
4301
4313
  '-moz-background-origin': 'background-origin',
4302
4314
  '-ms-input-placeholder': 'placeholder',
@@ -4453,6 +4465,7 @@ const webkitExtensions = new Set([
4453
4465
  '-webkit-min-logical-height',
4454
4466
  '-webkit-min-logical-width',
4455
4467
  '-webkit-nbsp-mode',
4468
+ '-webkit-match-parent',
4456
4469
  '-webkit-perspective-origin-x',
4457
4470
  '-webkit-perspective-origin-y',
4458
4471
  '-webkit-rtl-ordering',
@@ -7454,7 +7467,7 @@ var declarations = {
7454
7467
  syntax: "auto | after"
7455
7468
  },
7456
7469
  "-ms-overflow-style": {
7457
- syntax: "auto | none | scrollbar | -ms-autohiding-scrollbar"
7470
+ syntax: "auto | none | scrollbar | -ms-autohiding-scrollbar auto | none | scrollbar | -ms-autohiding-scrollbar"
7458
7471
  },
7459
7472
  "-ms-scroll-chaining": {
7460
7473
  syntax: "chained | none"
@@ -7564,9 +7577,6 @@ var declarations = {
7564
7577
  "-moz-force-broken-image-icon": {
7565
7578
  syntax: "0 | 1"
7566
7579
  },
7567
- "-moz-image-region": {
7568
- syntax: "<shape> | auto"
7569
- },
7570
7580
  "-moz-orient": {
7571
7581
  syntax: "inline | block | horizontal | vertical"
7572
7582
  },
@@ -7607,7 +7617,7 @@ var declarations = {
7607
7617
  syntax: "default | menu | tooltip | sheet | none"
7608
7618
  },
7609
7619
  "-webkit-appearance": {
7610
- syntax: "none | button | button-bevel | caret | checkbox | default-button | inner-spin-button | listbox | listitem | media-controls-background | media-controls-fullscreen-background | media-current-time-display | media-enter-fullscreen-button | media-exit-fullscreen-button | media-fullscreen-button | media-mute-button | media-overlay-play-button | media-play-button | media-seek-back-button | media-seek-forward-button | media-slider | media-sliderthumb | media-time-remaining-display | media-toggle-closed-captions-button | media-volume-slider | media-volume-slider-container | media-volume-sliderthumb | menulist | menulist-button | menulist-text | menulist-textfield | meter | progress-bar | progress-bar-value | push-button | radio | searchfield | searchfield-cancel-button | searchfield-decoration | searchfield-results-button | searchfield-results-decoration | slider-horizontal | slider-vertical | sliderthumb-horizontal | sliderthumb-vertical | square-button | textarea | textfield | -apple-pay-button"
7620
+ syntax: "none | button | button-bevel | caret | checkbox | default-button | inner-spin-button | listbox | listitem | media-controls-background | media-controls-fullscreen-background | media-current-time-display | media-enter-fullscreen-button | media-exit-fullscreen-button | media-fullscreen-button | media-mute-button | media-overlay-play-button | media-play-button | media-seek-back-button | media-seek-forward-button | media-slider | media-sliderthumb | media-time-remaining-display | media-toggle-closed-captions-button | media-volume-slider | media-volume-slider-container | media-volume-sliderthumb | menulist | menulist-button | menulist-text | menulist-textfield | meter | progress-bar | progress-bar-value | push-button | radio | searchfield | searchfield-cancel-button | searchfield-decoration | searchfield-results-button | searchfield-results-decoration | slider-horizontal | slider-vertical | sliderthumb-horizontal | sliderthumb-vertical | square-button | textarea | textfield | -apple-pay-button none | button | button-bevel | caps-lock-indicator | caret | checkbox | default-button | inner-spin-button | listbox | listitem | media-controls-background | media-controls-fullscreen-background | media-current-time-display | media-enter-fullscreen-button | media-exit-fullscreen-button | media-fullscreen-button | media-mute-button | media-overlay-play-button | media-play-button | media-seek-back-button | media-seek-forward-button | media-slider | media-sliderthumb | media-time-remaining-display | media-toggle-closed-captions-button | media-volume-slider | media-volume-slider-container | media-volume-sliderthumb | menulist | menulist-button | menulist-text | menulist-textfield | meter | progress-bar | progress-bar-value | push-button | radio | scrollbarbutton-down | scrollbarbutton-left | scrollbarbutton-right | scrollbarbutton-up | scrollbargripper-horizontal | scrollbargripper-vertical | scrollbarthumb-horizontal | scrollbarthumb-vertical | scrollbartrack-horizontal | scrollbartrack-vertical | searchfield | searchfield-cancel-button | searchfield-decoration | searchfield-results-button | searchfield-results-decoration | slider-horizontal | slider-vertical | sliderthumb-horizontal | sliderthumb-vertical | square-button | textarea | textfield | -apple-pay-button"
7611
7621
  },
7612
7622
  "-webkit-border-before": {
7613
7623
  syntax: "<'border-width'> || <'border-style'> || <color>"
@@ -7691,7 +7701,7 @@ var declarations = {
7691
7701
  syntax: "read-only | read-write | read-write-plaintext-only"
7692
7702
  },
7693
7703
  "-webkit-user-select": {
7694
- syntax: "auto | text | none | all"
7704
+ syntax: "auto | text | none | all auto | none | text | all"
7695
7705
  },
7696
7706
  "accent-color": {
7697
7707
  syntax: "auto | <color>"
@@ -7709,7 +7719,7 @@ var declarations = {
7709
7719
  syntax: "[ normal | <baseline-position> | <content-distribution> | <overflow-position>? <content-position> ]#"
7710
7720
  },
7711
7721
  "alignment-baseline": {
7712
- syntax: "baseline | alphabetic | ideographic | middle | central | mathematical | text-before-edge | text-after-edge"
7722
+ syntax: "baseline | alphabetic | ideographic | middle | central | mathematical | text-before-edge | text-after-edge auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical"
7713
7723
  },
7714
7724
  all: {
7715
7725
  syntax: "initial | inherit | unset | revert | revert-layer"
@@ -7733,7 +7743,7 @@ var declarations = {
7733
7743
  syntax: "<single-animation-direction>#"
7734
7744
  },
7735
7745
  "animation-duration": {
7736
- syntax: "<time>#"
7746
+ syntax: "[ auto | <time [0s,∞]> ]#"
7737
7747
  },
7738
7748
  "animation-fill-mode": {
7739
7749
  syntax: "<single-animation-fill-mode>#"
@@ -7811,7 +7821,7 @@ var declarations = {
7811
7821
  syntax: "<bg-size>#"
7812
7822
  },
7813
7823
  "baseline-shift": {
7814
- syntax: "<length-percentage> | sub | super | baseline"
7824
+ syntax: "<length-percentage> | sub | super | baseline baseline | sub | super | <svg-length>"
7815
7825
  },
7816
7826
  "block-size": {
7817
7827
  syntax: "<'width'>"
@@ -8150,7 +8160,7 @@ var declarations = {
8150
8160
  syntax: "[ <counter-name> <integer>? ]+ | none"
8151
8161
  },
8152
8162
  cursor: {
8153
- syntax: "[ [ <url> [ <x> <y> ]? , ]* [ auto | default | none | context-menu | help | pointer | progress | wait | cell | crosshair | text | vertical-text | alias | copy | move | no-drop | not-allowed | e-resize | n-resize | ne-resize | nw-resize | s-resize | se-resize | sw-resize | w-resize | ew-resize | ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | all-scroll | zoom-in | zoom-out | grab | grabbing ] ]"
8163
+ syntax: "[ [ <url> [ <x> <y> ]? , ]* [ auto | default | none | context-menu | help | pointer | progress | wait | cell | crosshair | text | vertical-text | alias | copy | move | no-drop | not-allowed | e-resize | n-resize | ne-resize | nw-resize | s-resize | se-resize | sw-resize | w-resize | ew-resize | ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | all-scroll | zoom-in | zoom-out | grab | grabbing ] ] [ [ <url> [ <x> <y> ]? , ]* [ auto | default | none | context-menu | help | pointer | progress | wait | cell | crosshair | text | vertical-text | alias | copy | move | no-drop | not-allowed | e-resize | n-resize | ne-resize | nw-resize | s-resize | se-resize | sw-resize | w-resize | ew-resize | ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | all-scroll | zoom-in | zoom-out | grab | grabbing | hand | -webkit-grab | -webkit-grabbing | -webkit-zoom-in | -webkit-zoom-out | -moz-grab | -moz-grabbing | -moz-zoom-in | -moz-zoom-out ] ]"
8154
8164
  },
8155
8165
  cx: {
8156
8166
  syntax: "<length> | <percentage>"
@@ -8165,10 +8175,10 @@ var declarations = {
8165
8175
  syntax: "ltr | rtl"
8166
8176
  },
8167
8177
  display: {
8168
- syntax: "[ <display-outside> || <display-inside> ] | <display-listitem> | <display-internal> | <display-box> | <display-legacy>| <-non-standard-display>"
8178
+ syntax: "[ <display-outside> || <display-inside> ] | <display-listitem> | <display-internal> | <display-box> | <display-legacy> | <-non-standard-display>"
8169
8179
  },
8170
8180
  "dominant-baseline": {
8171
- syntax: "auto | text-bottom | alphabetic | ideographic | middle | central | mathematical | hanging | text-top"
8181
+ syntax: "auto | text-bottom | alphabetic | ideographic | middle | central | mathematical | hanging | text-top auto | use-script | no-change | reset-size | ideographic | alphabetic | hanging | mathematical | central | middle | text-after-edge | text-before-edge"
8172
8182
  },
8173
8183
  "empty-cells": {
8174
8184
  syntax: "show | hide"
@@ -8180,13 +8190,13 @@ var declarations = {
8180
8190
  syntax: "<paint>"
8181
8191
  },
8182
8192
  "fill-opacity": {
8183
- syntax: "<'opacity'>"
8193
+ syntax: "<'opacity'> <number-zero-one>"
8184
8194
  },
8185
8195
  "fill-rule": {
8186
8196
  syntax: "nonzero | evenodd"
8187
8197
  },
8188
8198
  filter: {
8189
- syntax: "none | <filter-value-list>"
8199
+ syntax: "none | <filter-value-list> | <-ms-filter-function-list>"
8190
8200
  },
8191
8201
  flex: {
8192
8202
  syntax: "none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ]"
@@ -8219,7 +8229,7 @@ var declarations = {
8219
8229
  syntax: "<'opacity'>"
8220
8230
  },
8221
8231
  font: {
8222
- syntax: "[ [ <'font-style'> || <font-variant-css2> || <'font-weight'> || <font-width-css3> ]? <'font-size'> [ / <'line-height'> ]? <'font-family'># ] | <system-family-name>"
8232
+ syntax: "[ [ <'font-style'> || <font-variant-css2> || <'font-weight'> || <font-width-css3> ]? <'font-size'> [ / <'line-height'> ]? <'font-family'># ] | <system-family-name> [ [ <'font-style'> || <font-variant-css2> || <'font-weight'> || <font-width-css3> ]? <'font-size'> [ / <'line-height'> ]? <'font-family'># ] | <system-family-name> | <-non-standard-font>"
8223
8233
  },
8224
8234
  "font-family": {
8225
8235
  syntax: "[ <family-name> | <generic-family> ]#"
@@ -8366,7 +8376,7 @@ var declarations = {
8366
8376
  syntax: "none | [ first || [ force-end | allow-end ] || last ]"
8367
8377
  },
8368
8378
  height: {
8369
- syntax: "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()>"
8379
+ syntax: "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()> | stretch | <-non-standard-size>"
8370
8380
  },
8371
8381
  "hyphenate-character": {
8372
8382
  syntax: "auto | <string>"
@@ -8381,7 +8391,7 @@ var declarations = {
8381
8391
  syntax: "from-image | <angle> | [ <angle>? flip ]"
8382
8392
  },
8383
8393
  "image-rendering": {
8384
- syntax: "auto | crisp-edges | pixelated | smooth| optimizeSpeed | optimizeQuality | <-non-standard-image-rendering>"
8394
+ syntax: "auto | crisp-edges | pixelated | smooth | optimizeSpeed | optimizeQuality | <-non-standard-image-rendering>"
8385
8395
  },
8386
8396
  "image-resolution": {
8387
8397
  syntax: "[ from-image || <resolution> ] && snap?"
@@ -8441,7 +8451,7 @@ var declarations = {
8441
8451
  syntax: "<length> | <percentage> | auto"
8442
8452
  },
8443
8453
  "letter-spacing": {
8444
- syntax: "normal | <length>"
8454
+ syntax: "normal | <length> normal | <length-percentage>"
8445
8455
  },
8446
8456
  "lighting-color": {
8447
8457
  syntax: "<color>"
@@ -8585,7 +8595,7 @@ var declarations = {
8585
8595
  syntax: "<'max-width'>"
8586
8596
  },
8587
8597
  "max-height": {
8588
- syntax: "none | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()>"
8598
+ syntax: "none | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()> | stretch | <-non-standard-size>"
8589
8599
  },
8590
8600
  "max-inline-size": {
8591
8601
  syntax: "<'max-width'>"
@@ -8594,19 +8604,19 @@ var declarations = {
8594
8604
  syntax: "none | <integer>"
8595
8605
  },
8596
8606
  "max-width": {
8597
- syntax: "none | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()>"
8607
+ syntax: "none | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()> | stretch | <-non-standard-size>"
8598
8608
  },
8599
8609
  "min-block-size": {
8600
8610
  syntax: "<'min-width'>"
8601
8611
  },
8602
8612
  "min-height": {
8603
- syntax: "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()>"
8613
+ syntax: "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()> | stretch | <-non-standard-size>"
8604
8614
  },
8605
8615
  "min-inline-size": {
8606
8616
  syntax: "<'min-width'>"
8607
8617
  },
8608
8618
  "min-width": {
8609
- syntax: "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()>"
8619
+ syntax: "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()> | stretch | <-non-standard-size>"
8610
8620
  },
8611
8621
  "mix-blend-mode": {
8612
8622
  syntax: "<blend-mode> | plus-lighter"
@@ -8663,7 +8673,7 @@ var declarations = {
8663
8673
  syntax: "<line-width>"
8664
8674
  },
8665
8675
  overflow: {
8666
- syntax: "[ visible | hidden | clip | scroll | auto ]{1,2}"
8676
+ syntax: "[ visible | hidden | clip | scroll | auto ]{1,2} | <-non-standard-overflow>"
8667
8677
  },
8668
8678
  "overflow-anchor": {
8669
8679
  syntax: "auto | none"
@@ -8684,10 +8694,10 @@ var declarations = {
8684
8694
  syntax: "normal | break-word | anywhere"
8685
8695
  },
8686
8696
  "overflow-x": {
8687
- syntax: "visible | hidden | clip | scroll | auto"
8697
+ syntax: "visible | hidden | clip | scroll | auto | <-non-standard-overflow>"
8688
8698
  },
8689
8699
  "overflow-y": {
8690
- syntax: "visible | hidden | clip | scroll | auto"
8700
+ syntax: "visible | hidden | clip | scroll | auto | <-non-standard-overflow>"
8691
8701
  },
8692
8702
  overlay: {
8693
8703
  syntax: "none | auto"
@@ -8774,7 +8784,7 @@ var declarations = {
8774
8784
  syntax: "auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all | inherit"
8775
8785
  },
8776
8786
  position: {
8777
- syntax: "static | relative | absolute | sticky | fixed| -webkit-sticky"
8787
+ syntax: "static | relative | absolute | sticky | fixed | -webkit-sticky"
8778
8788
  },
8779
8789
  "position-anchor": {
8780
8790
  syntax: "auto | <anchor-name>"
@@ -8981,25 +8991,25 @@ var declarations = {
8981
8991
  syntax: "<color>"
8982
8992
  },
8983
8993
  "stroke-dasharray": {
8984
- syntax: "none | <dasharray>"
8994
+ syntax: "none | <dasharray> none | [ <svg-length>+ ]#"
8985
8995
  },
8986
8996
  "stroke-dashoffset": {
8987
- syntax: "<length-percentage> | <number>"
8997
+ syntax: "<length-percentage> | <number> <svg-length>"
8988
8998
  },
8989
8999
  "stroke-linecap": {
8990
9000
  syntax: "butt | round | square"
8991
9001
  },
8992
9002
  "stroke-linejoin": {
8993
- syntax: "miter | miter-clip | round | bevel | arcs"
9003
+ syntax: "miter | miter-clip | round | bevel | arcs miter | round | bevel"
8994
9004
  },
8995
9005
  "stroke-miterlimit": {
8996
- syntax: "<number>"
9006
+ syntax: "<number> <number-one-or-greater>"
8997
9007
  },
8998
9008
  "stroke-opacity": {
8999
9009
  syntax: "<'opacity'>"
9000
9010
  },
9001
9011
  "stroke-width": {
9002
- syntax: "<length-percentage> | <number>"
9012
+ syntax: "<length-percentage> | <number> <svg-length>"
9003
9013
  },
9004
9014
  "tab-size": {
9005
9015
  syntax: "<integer> | <length>"
@@ -9008,7 +9018,7 @@ var declarations = {
9008
9018
  syntax: "auto | fixed"
9009
9019
  },
9010
9020
  "text-align": {
9011
- syntax: "start | end | left | right | center | justify | match-parent"
9021
+ syntax: "start | end | left | right | center | justify | match-parent | <-non-standard-text-align>"
9012
9022
  },
9013
9023
  "text-align-last": {
9014
9024
  syntax: "auto | start | end | left | right | center | justify"
@@ -9146,7 +9156,7 @@ var declarations = {
9146
9156
  syntax: "none | <length-percentage> [ <length-percentage> <length>? ]?"
9147
9157
  },
9148
9158
  "unicode-bidi": {
9149
- syntax: "normal | embed | isolate | bidi-override | isolate-override | plaintext"
9159
+ syntax: "normal | embed | isolate | bidi-override | isolate-override | plaintext | -moz-isolate | -moz-isolate-override | -moz-plaintext | -webkit-isolate | -webkit-isolate-override | -webkit-plaintext"
9150
9160
  },
9151
9161
  "user-select": {
9152
9162
  syntax: "auto | text | none | all"
@@ -9188,7 +9198,7 @@ var declarations = {
9188
9198
  syntax: "<integer>"
9189
9199
  },
9190
9200
  width: {
9191
- syntax: "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()>"
9201
+ syntax: "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()> | stretch | <-non-standard-size>"
9192
9202
  },
9193
9203
  "will-change": {
9194
9204
  syntax: "auto | <animateable-feature>#"
@@ -9203,7 +9213,7 @@ var declarations = {
9203
9213
  syntax: "normal | break-word"
9204
9214
  },
9205
9215
  "writing-mode": {
9206
- syntax: "horizontal-tb | vertical-rl | vertical-lr | sideways-rl | sideways-lr"
9216
+ syntax: "horizontal-tb | vertical-rl | vertical-lr | sideways-rl | sideways-lr | <svg-writing-mode>"
9207
9217
  },
9208
9218
  x: {
9209
9219
  syntax: "<length> | <percentage>"
@@ -9239,7 +9249,7 @@ var declarations = {
9239
9249
  syntax: "auto | grayscale"
9240
9250
  },
9241
9251
  "-moz-user-select": {
9242
- syntax: "none | text | all | -moz-none"
9252
+ syntax: "none | text | all | -moz-none | auto"
9243
9253
  },
9244
9254
  "-ms-flex-align": {
9245
9255
  syntax: "start | end | center | baseline | stretch"
@@ -9846,10 +9856,10 @@ var syntaxes = {
9846
9856
  syntax: "<url>"
9847
9857
  },
9848
9858
  color: {
9849
- syntax: "<color-base> | currentColor | <system-color> | <light-dark()> | <deprecated-system-color>"
9859
+ syntax: "<color-base> | currentColor | <system-color> | <device-cmyk()> | <light-dark()> | <-non-standard-color>"
9850
9860
  },
9851
9861
  "color()": {
9852
- syntax: "color( [ from <color> ]? <colorspace-params> [ / [ <alpha-value> | none ] ]? )"
9862
+ syntax: "color( <colorspace-params> [ / [ <alpha-value> | none ] ]? )"
9853
9863
  },
9854
9864
  "color-base": {
9855
9865
  syntax: "<hex-color> | <color-function> | <named-color> | <color-mix()> | transparent"
@@ -9861,7 +9871,7 @@ var syntaxes = {
9861
9871
  syntax: "in [ <rectangular-color-space> | <polar-color-space> <hue-interpolation-method>? | <custom-color-space> ]"
9862
9872
  },
9863
9873
  "color-mix()": {
9864
- syntax: "color-mix( <color-interpolation-method> , [ <color> && <percentage [0,100]>? ]#{2})"
9874
+ syntax: "color-mix( <color-interpolation-method> , [ <color> && <percentage [0,100]>? ]#{2} )"
9865
9875
  },
9866
9876
  "color-stop": {
9867
9877
  syntax: "<color-stop-length> | <color-stop-angle>"
@@ -9876,10 +9886,10 @@ var syntaxes = {
9876
9886
  syntax: "<linear-color-stop> , [ <linear-color-hint>? , <linear-color-stop> ]#?"
9877
9887
  },
9878
9888
  "colorspace-params": {
9879
- syntax: "[<custom-params> | <predefined-rgb-params> | <xyz-params>]"
9889
+ syntax: "[ <predefined-rgb-params> | <xyz-params>]"
9880
9890
  },
9881
9891
  combinator: {
9882
- syntax: "'>' | '+' | '~' | [ '||' ]"
9892
+ syntax: "'>' | '+' | '~' | [ '|' '|' ]"
9883
9893
  },
9884
9894
  "common-lig-values": {
9885
9895
  syntax: "[ common-ligatures | no-common-ligatures ]"
@@ -9888,7 +9898,7 @@ var syntaxes = {
9888
9898
  syntax: "searchfield | textarea | push-button | slider-horizontal | checkbox | radio | square-button | menulist | listbox | meter | progress-bar | button"
9889
9899
  },
9890
9900
  "complex-selector": {
9891
- syntax: "<compound-selector> [ <combinator>? <compound-selector> ]*"
9901
+ syntax: "<complex-selector-unit> [ <combinator>? <complex-selector-unit> ]*"
9892
9902
  },
9893
9903
  "complex-selector-list": {
9894
9904
  syntax: "<complex-selector>#"
@@ -9900,7 +9910,7 @@ var syntaxes = {
9900
9910
  syntax: "add | subtract | intersect | exclude"
9901
9911
  },
9902
9912
  "compound-selector": {
9903
- syntax: "[ <type-selector>? <subclass-selector>* [ <pseudo-element-selector> <pseudo-class-selector>* ]* ]!"
9913
+ syntax: "[ <type-selector>? <subclass-selector>* ]!"
9904
9914
  },
9905
9915
  "compound-selector-list": {
9906
9916
  syntax: "<compound-selector>#"
@@ -9912,7 +9922,7 @@ var syntaxes = {
9912
9922
  syntax: "[ [ [ from [ <angle> | <zero> ] ]? [ at <position> ]? ] || <color-interpolation-method> ]? , <angular-color-stop-list>"
9913
9923
  },
9914
9924
  "container-condition": {
9915
- syntax: "[ <container-name>? <container-query>? ]!"
9925
+ syntax: "not <query-in-parens> | <query-in-parens> [ [ and <query-in-parens> ]* | [ or <query-in-parens> ]* ]"
9916
9926
  },
9917
9927
  "container-name": {
9918
9928
  syntax: "<custom-ident>"
@@ -9924,7 +9934,7 @@ var syntaxes = {
9924
9934
  syntax: "space-between | space-around | space-evenly | stretch"
9925
9935
  },
9926
9936
  "content-list": {
9927
- syntax: "[ <string> | contents | <image> | <counter> | <quote> | <target> | <leader()> ]+"
9937
+ syntax: "[ <string> | contents | <image> | <counter> | <quote> | <target> | <leader()> | <attr()> ]+"
9928
9938
  },
9929
9939
  "content-position": {
9930
9940
  syntax: "center | start | end | flex-start | flex-end"
@@ -9939,7 +9949,7 @@ var syntaxes = {
9939
9949
  syntax: "contrast( [ <number> | <percentage> ]? )"
9940
9950
  },
9941
9951
  "coord-box": {
9942
- syntax: "<paint-box> | view-box"
9952
+ syntax: "content-box | padding-box | border-box | fill-box | stroke-box | view-box"
9943
9953
  },
9944
9954
  "cos()": {
9945
9955
  syntax: "cos( <calc-sum> )"
@@ -9969,7 +9979,7 @@ var syntaxes = {
9969
9979
  syntax: "cubic-bezier( [ <number [0,1]>, <number> ]#{2} )"
9970
9980
  },
9971
9981
  "cubic-bezier-easing-function": {
9972
- syntax: "ease | ease-in | ease-out | ease-in-out | <cubic-bezier()>"
9982
+ syntax: "ease | ease-in | ease-out | ease-in-out | cubic-bezier( <number [0,1]> , <number> , <number [0,1]> , <number> )"
9973
9983
  },
9974
9984
  "custom-color-space": {
9975
9985
  syntax: "<dashed-ident>"
@@ -10020,7 +10030,7 @@ var syntaxes = {
10020
10030
  syntax: "[ full-width | proportional-width ]"
10021
10031
  },
10022
10032
  "element()": {
10023
- syntax: "element( <id-selector> )"
10033
+ syntax: "element( <custom-ident> , [ first | start | last | first-except ]? ) | element( <id-selector> )"
10024
10034
  },
10025
10035
  "ellipse()": {
10026
10036
  syntax: "ellipse( <radial-size>? [ at <position> ]? )"
@@ -10101,10 +10111,10 @@ var syntaxes = {
10101
10111
  syntax: "serif | sans-serif | system-ui | cursive | fantasy | math | monospace"
10102
10112
  },
10103
10113
  "general-enclosed": {
10104
- syntax: "[ <function-token> <any-value> ) ] | ( <ident> <any-value> )"
10114
+ syntax: "[ <function-token> <any-value>? ) ] | [ ( <any-value>? ) ]"
10105
10115
  },
10106
10116
  "generic-family": {
10107
- syntax: "<generic-complete> | <generic-incomplete> | emoji | fangsong"
10117
+ syntax: "<generic-script-specific>| <generic-complete> | <generic-incomplete> | <-non-standard-generic-family>"
10108
10118
  },
10109
10119
  "generic-incomplete": {
10110
10120
  syntax: "ui-serif | ui-sans-serif | ui-monospace | ui-rounded"
@@ -10113,7 +10123,7 @@ var syntaxes = {
10113
10123
  syntax: "<shape-box> | fill-box | stroke-box | view-box"
10114
10124
  },
10115
10125
  gradient: {
10116
- syntax: "<linear-gradient()> | <repeating-linear-gradient()> | <radial-gradient()> | <repeating-radial-gradient()> | <conic-gradient()> | <repeating-conic-gradient()>"
10126
+ syntax: "| <-legacy-gradient>"
10117
10127
  },
10118
10128
  "grayscale()": {
10119
10129
  syntax: "grayscale( [ <number> | <percentage> ]? )"
@@ -10401,7 +10411,7 @@ var syntaxes = {
10401
10411
  syntax: "A5 | A4 | A3 | B5 | B4 | JIS-B5 | JIS-B4 | letter | legal | ledger"
10402
10412
  },
10403
10413
  paint: {
10404
- syntax: "none | <color> | <url> [none | <color>]? | context-fill | context-stroke"
10414
+ syntax: "none | <color> | <url> [ none | <color> ]? | context-fill | context-stroke"
10405
10415
  },
10406
10416
  "paint()": {
10407
10417
  syntax: "paint( <ident>, <declaration-value>? )"
@@ -10431,7 +10441,7 @@ var syntaxes = {
10431
10441
  syntax: "[ [ left | center | right ] || [ top | center | bottom ] | [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ]? | [ [ left | right ] <length-percentage> ] && [ [ top | bottom ] <length-percentage> ] ]"
10432
10442
  },
10433
10443
  "position-area": {
10434
- syntax: "[ left | center | right | span-left | span-right | x-start | x-end | span-x-start | span-x-end | x-self-start | x-self-end | span-x-self-start | span-x-self-end | span-all ] || [ top | center | bottom | span-top | span-bottom | y-start | y-end | span-y-start | span-y-end | y-self-start | y-self-end | span-y-self-start | span-y-self-end | span-all ] | [ block-start | center | block-end | span-block-start | span-block-end | span-all ] || [ inline-start | center | inline-end | span-inline-start | span-inline-end | span-all ] | [ self-block-start | center | self-block-end | span-self-block-start | span-self-block-end | span-all ] || [ self-inline-start | center | self-inline-end | span-self-inline-start | span-self-inline-end | span-all ] | [ start | center | end | span-start | span-end | span-all ]{1,2} | [ self-start | center | self-end | span-self-start | span-self-end | span-all ]{1,2}"
10444
+ syntax: "[ [ left | center | right | span-left | span-right | x-start | x-end | span-x-start | span-x-end | x-self-start | x-self-end | span-x-self-start | span-x-self-end | span-all ] || [ top | center | bottom | span-top | span-bottom | y-start | y-end | span-y-start | span-y-end | y-self-start | y-self-end | span-y-self-start | span-y-self-end | span-all ] | [ block-start | center | block-end | span-block-start | span-block-end | span-all ] || [ inline-start | center | inline-end | span-inline-start | span-inline-end | span-all ] | [ self-block-start | center | self-block-end | span-self-block-start | span-self-block-end | span-all ] || [ self-inline-start | center | self-inline-end | span-self-inline-start | span-self-inline-end | span-all ] | [ start | center | end | span-start | span-end | span-all ]{1,2} | [ self-start | center | self-end | span-self-start | span-self-end | span-all ]{1,2} ]"
10435
10445
  },
10436
10446
  "pow()": {
10437
10447
  syntax: "pow( <calc-sum>, <calc-sum> )"
@@ -10446,13 +10456,13 @@ var syntaxes = {
10446
10456
  syntax: "':' <ident-token> | ':' <function-token> <any-value> ')'"
10447
10457
  },
10448
10458
  "pseudo-element-selector": {
10449
- syntax: "':' <pseudo-class-selector>"
10459
+ syntax: "':' <pseudo-class-selector> | <legacy-pseudo-element-selector>"
10450
10460
  },
10451
10461
  "pseudo-page": {
10452
10462
  syntax: ": [ left | right | first | blank ]"
10453
10463
  },
10454
10464
  "query-in-parens": {
10455
- syntax: "( <container-query> ) | ( <size-feature> ) | style( <style-query> ) | scroll-state( <scroll-state-query> ) | <general-enclosed>"
10465
+ syntax: "( <container-condition> ) | ( <size-feature> ) | style( <style-query> ) | <general-enclosed>"
10456
10466
  },
10457
10467
  quote: {
10458
10468
  syntax: "open-quote | close-quote | no-open-quote | no-close-quote"
@@ -10560,10 +10570,10 @@ var syntaxes = {
10560
10570
  syntax: "scaleZ( [ <number> | <percentage> ] )"
10561
10571
  },
10562
10572
  "scope-end": {
10563
- syntax: "<selector-list>"
10573
+ syntax: "<forgiving-selector-list>"
10564
10574
  },
10565
10575
  "scope-start": {
10566
- syntax: "<selector-list>"
10576
+ syntax: "<forgiving-selector-list>"
10567
10577
  },
10568
10578
  "scroll()": {
10569
10579
  syntax: "scroll( [ <scroller> || <axis> ]? )"
@@ -10596,7 +10606,7 @@ var syntaxes = {
10596
10606
  syntax: "[ <length>{2,3} && <color>? ]"
10597
10607
  },
10598
10608
  shape: {
10599
- syntax: "rect(<top>, <right>, <bottom>, <left>)"
10609
+ syntax: "rect( <top>, <right>, <bottom>, <left> ) | rect( <top> <right> <bottom> <left> )"
10600
10610
  },
10601
10611
  "shape-box": {
10602
10612
  syntax: "<visual-box> | margin-box"
@@ -10647,7 +10657,7 @@ var syntaxes = {
10647
10657
  syntax: "closest-side | farthest-side | closest-corner | farthest-corner | <length> | <length-percentage>{2}"
10648
10658
  },
10649
10659
  "size-feature": {
10650
- syntax: "<media-query-list>"
10660
+ syntax: "<mf-plain> | <mf-boolean> | <mf-range>"
10651
10661
  },
10652
10662
  "skew()": {
10653
10663
  syntax: "skew( [ <angle> | <zero> ] , [ <angle> | <zero> ]? )"
@@ -10674,10 +10684,10 @@ var syntaxes = {
10674
10684
  syntax: "<declaration>"
10675
10685
  },
10676
10686
  "style-in-parens": {
10677
- syntax: "( <style-query> ) | ( <style-feature> ) | <general-enclosed>"
10687
+ syntax: "( <style-condition> ) | ( <style-feature> ) | <general-enclosed>"
10678
10688
  },
10679
10689
  "style-query": {
10680
- syntax: "not <style-in-parens> | <style-in-parens> [ [ and <style-in-parens> ]* | [ or <style-in-parens> ]* ] | <style-feature> "
10690
+ syntax: "<style-condition> | <style-feature>"
10681
10691
  },
10682
10692
  "subclass-selector": {
10683
10693
  syntax: "<id-selector> | <class-selector> | <attribute-selector> | <pseudo-class-selector>"
@@ -10806,7 +10816,7 @@ var syntaxes = {
10806
10816
  syntax: "xyz | xyz-d50 | xyz-d65"
10807
10817
  },
10808
10818
  "xyz-params": {
10809
- syntax: "<xyz> [ <number> | <percentage> | none ]{3}"
10819
+ syntax: "<xyz-space> [ <number> | <percentage> | none ]{3}"
10810
10820
  },
10811
10821
  "-legacy-gradient": {
10812
10822
  syntax: "<-webkit-gradient()> | <-legacy-linear-gradient> | <-legacy-repeating-linear-gradient> | <-legacy-radial-gradient> | <-legacy-repeating-radial-gradient>"
@@ -11001,10 +11011,13 @@ var syntaxes = {
11001
11011
  syntax: "not <style-in-parens> | <style-in-parens> [ [ and <style-in-parens> ]* | [ or <style-in-parens> ]* ]"
11002
11012
  },
11003
11013
  "-non-standard-display": {
11004
- syntax: "-ms-inline-flexbox | -ms-grid | -ms-inline-grid | -webkit-flex | -webkit-inline-flex | -webkit-box | -webkit-inline-box | -moz-inline-stack | -moz-box | -moz-inline-box"
11014
+ syntax: "-ms-inline-flexbox | -ms-grid | -ms-inline-grid | -webkit-flex | -webkit-inline-flex | -webkit-box | -webkit-inline-box | -moz-inline-stack | -moz-box | -moz-inline-box | -ms-flexbox"
11005
11015
  },
11006
11016
  "inset-area": {
11007
11017
  syntax: "[ [ left | center | right | span-left | span-right | x-start | x-end | span-x-start | span-x-end | x-self-start | x-self-end | span-x-self-start | span-x-self-end | span-all ] || [ top | center | bottom | span-top | span-bottom | y-start | y-end | span-y-start | span-y-end | y-self-start | y-self-end | span-y-self-start | span-y-self-end | span-all ] | [ block-start | center | block-end | span-block-start | span-block-end | span-all ] || [ inline-start | center | inline-end | span-inline-start | span-inline-end | span-all ] | [ self-block-start | self-block-end | span-self-block-start | span-self-block-end | span-all ] || [ self-inline-start | self-inline-end | span-self-inline-start | span-self-inline-end | span-all ] | [ start | center | end | span-start | span-end | span-all ]{1,2} | [ self-start | center | self-end | span-self-start | span-self-end | span-all ]{1,2} ]"
11018
+ },
11019
+ "-non-standard-text-align": {
11020
+ syntax: "| -moz-center | -webkit-center | -webkit-match-parent"
11008
11021
  }
11009
11022
  };
11010
11023
  var selectors = {
@@ -11653,20 +11666,6 @@ var ValidationSyntaxGroupEnum;
11653
11666
  ValidationSyntaxGroupEnum["AtRules"] = "atRules";
11654
11667
  })(ValidationSyntaxGroupEnum || (ValidationSyntaxGroupEnum = {}));
11655
11668
 
11656
- var WalkValidationTokenEnum;
11657
- (function (WalkValidationTokenEnum) {
11658
- WalkValidationTokenEnum[WalkValidationTokenEnum["IgnoreChildren"] = 0] = "IgnoreChildren";
11659
- WalkValidationTokenEnum[WalkValidationTokenEnum["IgnoreNode"] = 1] = "IgnoreNode";
11660
- WalkValidationTokenEnum[WalkValidationTokenEnum["IgnoreAll"] = 2] = "IgnoreAll";
11661
- })(WalkValidationTokenEnum || (WalkValidationTokenEnum = {}));
11662
- var WalkValidationTokenKeyTypeEnum;
11663
- (function (WalkValidationTokenKeyTypeEnum) {
11664
- WalkValidationTokenKeyTypeEnum["Array"] = "array";
11665
- WalkValidationTokenKeyTypeEnum["Children"] = "chi";
11666
- WalkValidationTokenKeyTypeEnum["Left"] = "l";
11667
- WalkValidationTokenKeyTypeEnum["Right"] = "r";
11668
- WalkValidationTokenKeyTypeEnum["Prelude"] = "prelude";
11669
- })(WalkValidationTokenKeyTypeEnum || (WalkValidationTokenKeyTypeEnum = {}));
11670
11669
  const skipped = [
11671
11670
  ValidationTokenEnum.Star,
11672
11671
  ValidationTokenEnum.HashMark,
@@ -11680,18 +11679,6 @@ const objectProperties = {
11680
11679
  writable: true,
11681
11680
  configurable: true
11682
11681
  };
11683
- // syntaxes: keyword | <'property'> | <function>
11684
- // "none | [ [<dashed-ident> || <try-tactic>] | inset-area( <'inset-area'> ) ]#"
11685
- // ""
11686
- // : "<outline-radius>{1,4} [ / <outline-radius>{1,4} ]?
11687
- // ""
11688
- // false | true
11689
- // [ <mask-reference> || <position> [ / <bg-size> ]? || <repeat-style> || [ <box> | border | padding | content | text ] || [ <box> | border | padding | content ] ]#
11690
- // false | true | green | pipe
11691
- // keyword | <'property'> | <function>
11692
- // [<dashed-ident> || <try-tactic>]
11693
- // [ <mask-reference> || <position> [ / <bg-size> ]? || <repeat-style> || [ <box> | border | padding | content | text ] || [ <box> | border | padding | content ] ]#
11694
- // none | [ [<dashed-ident> || <try-tactic>] | inset-area( <'inset-area'> ) ]
11695
11682
  function* tokenize(syntax, position = { ind: 0, lin: 1, col: 0 }, currentPosition = {
11696
11683
  ind: -1,
11697
11684
  lin: 1,
@@ -11854,7 +11841,6 @@ function matchParens(syntax, iterator) {
11854
11841
  let items = [];
11855
11842
  let match = 0;
11856
11843
  while ((item = iterator.next()) && !item.done) {
11857
- // console.error(JSON.stringify({match, val: item.value,func}, null, 1));
11858
11844
  switch (item.value.typ) {
11859
11845
  case ValidationTokenEnum.OpenParenthesis:
11860
11846
  if (match > 0) {
@@ -12530,7 +12516,7 @@ function getTokenType$1(token, position, currentPosition) {
12530
12516
  if (token.startsWith('<')) {
12531
12517
  // <number [1,1000]>
12532
12518
  // <length [0,∞]>
12533
- let match = token.match(/<([a-z0-9-]+)(\s+\[([0-9]+),(([0-9]+)|∞)\])?>/);
12519
+ let match = token.match(/<([a-z0-9-]+)(\s+\[([0-9]+[a-zA-Z]*),(([0-9]+[a-zA-Z]*)|∞)\])?>/);
12534
12520
  if (match == null) {
12535
12521
  let match = token.match(/<([a-zA-Z0-9-]+)\(\)>/);
12536
12522
  if (match != null) {
@@ -12542,10 +12528,12 @@ function getTokenType$1(token, position, currentPosition) {
12542
12528
  throw new Error('invalid token at position: ' + position.lin + ':' + position.col + ' ' + token);
12543
12529
  }
12544
12530
  if (match[2] != null) {
12531
+ const type = getTokenType(match[3]);
12545
12532
  return Object.defineProperty({
12546
12533
  typ: ValidationTokenEnum.PropertyType,
12547
12534
  val: match[1],
12548
- range: [+match[3], match[4] == '\u221e' ? Infinity : +match[4]]
12535
+ unit: exports.EnumToken[type.typ],
12536
+ range: [+type.val, match[4] == '\u221e' ? null : +match[4]]
12549
12537
  }, 'pos', { ...objectProperties, value: pos });
12550
12538
  }
12551
12539
  return Object.defineProperty({
@@ -12616,7 +12604,7 @@ function renderSyntax(token, parent) {
12616
12604
  case ValidationTokenEnum.Bracket:
12617
12605
  return '[' + token.chi.reduce((acc, curr) => acc + renderSyntax(curr), '') + ']' + renderAttributes(token);
12618
12606
  case ValidationTokenEnum.PropertyType:
12619
- return '<' + token.val + '>' + renderAttributes(token);
12607
+ return '<' + token.val + (Array.isArray(token.range) ? `[${token?.range?.[0]}, ${token?.range?.[1] ?? '\u221e'}]` : '') + '>' + renderAttributes(token);
12620
12608
  case ValidationTokenEnum.DeclarationType:
12621
12609
  return "<'" + token.val + "'>" + renderAttributes(token);
12622
12610
  case ValidationTokenEnum.Number:
@@ -13484,12 +13472,25 @@ function createContext(input) {
13484
13472
  update(context) {
13485
13473
  // @ts-ignore
13486
13474
  const newIndex = result.indexOf(context.current());
13487
- if (newIndex != -1) {
13488
- // console.error({newIndex, v: result[newIndex]});
13489
- // console.error(new Error('update'))
13475
+ if (newIndex > this.index) {
13490
13476
  this.index = newIndex;
13491
13477
  }
13492
13478
  },
13479
+ consume(token, howMany) {
13480
+ let newIndex = result.indexOf(token, this.index + 1);
13481
+ if (newIndex == -1 || newIndex < this.index) {
13482
+ return false;
13483
+ }
13484
+ howMany ??= 0;
13485
+ let splice = 1;
13486
+ if (result[newIndex - 1]?.typ == exports.EnumToken.WhitespaceTokenType) {
13487
+ splice++;
13488
+ newIndex--;
13489
+ }
13490
+ result.splice(this.index + 1, 0, ...result.splice(newIndex, splice + howMany));
13491
+ this.index += howMany + splice;
13492
+ return true;
13493
+ },
13493
13494
  done() {
13494
13495
  return this.index + 1 >= result.length;
13495
13496
  },
@@ -13514,13 +13515,21 @@ function createContext(input) {
13514
13515
  return result.slice(this.index + 1);
13515
13516
  },
13516
13517
  clone() {
13517
- const context = createContext(input.slice());
13518
+ const context = createContext(result.slice());
13518
13519
  context.index = this.index;
13519
13520
  return context;
13521
+ },
13522
+ // @ts-ignore
13523
+ toJSON() {
13524
+ return {
13525
+ index: this.index,
13526
+ slice: this.slice(),
13527
+ tokens: this.tokens()
13528
+ };
13520
13529
  }
13521
13530
  };
13522
13531
  }
13523
- function evaluateSyntax(node, options, parent) {
13532
+ function evaluateSyntax(node, options) {
13524
13533
  let ast;
13525
13534
  let result;
13526
13535
  switch (node.typ) {
@@ -13529,6 +13538,7 @@ function evaluateSyntax(node, options, parent) {
13529
13538
  break;
13530
13539
  }
13531
13540
  ast = getParsedSyntax("declarations" /* ValidationSyntaxGroupEnum.Declarations */, node.nam);
13541
+ // console.error({ast: ast.reduce((acc, curr) => acc + renderSyntax(curr), '')});
13532
13542
  if (ast != null) {
13533
13543
  let token = null;
13534
13544
  const values = node.val.slice();
@@ -13548,6 +13558,7 @@ function evaluateSyntax(node, options, parent) {
13548
13558
  }
13549
13559
  }
13550
13560
  result = doEvaluateSyntax(ast, createContext(values), { ...options, visited: new WeakMap() });
13561
+ // console.error(JSON.stringify({ast, values, result}, null, 1));
13551
13562
  if (result.valid == SyntaxValidationResult.Valid && !result.context.done()) {
13552
13563
  let token = null;
13553
13564
  while ((token = result.context.next()) != null) {
@@ -13606,6 +13617,7 @@ function doEvaluateSyntax(syntaxes, context, options) {
13606
13617
  let i = 0;
13607
13618
  let result;
13608
13619
  let token = null;
13620
+ // console.error(`>> doEvaluateSyntax: ${syntaxes.reduce((acc, curr) => acc + renderSyntax(curr), '')}\n>> ${JSON.stringify({syntaxes}, null, 1)}>> context: ${context.slice<Token>().reduce((acc, curr) => acc + renderToken(curr), '')}`);
13609
13621
  for (; i < syntaxes.length; i++) {
13610
13622
  syntax = syntaxes[i];
13611
13623
  if (context.done()) {
@@ -13635,6 +13647,7 @@ function doEvaluateSyntax(syntaxes, context, options) {
13635
13647
  }
13636
13648
  else {
13637
13649
  if (isVisited(token, syntax, 'doEvaluateSyntax', options)) {
13650
+ // console.error(`cyclic dependency: ${renderSyntax(syntax)}`);
13638
13651
  return {
13639
13652
  valid: SyntaxValidationResult.Drop,
13640
13653
  node: token,
@@ -13656,7 +13669,8 @@ function doEvaluateSyntax(syntaxes, context, options) {
13656
13669
  }
13657
13670
  context.update(result.context);
13658
13671
  }
13659
- return {
13672
+ // @ts-ignore
13673
+ return result ?? {
13660
13674
  valid: SyntaxValidationResult.Valid,
13661
13675
  node: null,
13662
13676
  syntax: syntaxes[i - 1],
@@ -13781,6 +13795,7 @@ function matchOccurence(syntax, context, options) {
13781
13795
  };
13782
13796
  }
13783
13797
  function match(syntax, context, options) {
13798
+ // console.error(`>> match(): ${renderSyntax(syntax)}\n>> ${JSON.stringify({syntax}, null, 1)}>> context: ${context.slice<Token>().reduce((acc, curr) => acc + renderToken(curr), '')}`);
13784
13799
  let success = false;
13785
13800
  let result;
13786
13801
  let token = context.peek();
@@ -13798,7 +13813,7 @@ function match(syntax, context, options) {
13798
13813
  }
13799
13814
  return {
13800
13815
  valid: SyntaxValidationResult.Drop,
13801
- node: context.next(),
13816
+ node: context.current(),
13802
13817
  syntax,
13803
13818
  error: `expected '${ValidationTokenEnum[syntax.typ].toLowerCase()}', got '${context.done() ? null : renderToken(context.peek())}'`,
13804
13819
  context
@@ -13833,7 +13848,7 @@ function match(syntax, context, options) {
13833
13848
  }
13834
13849
  switch (syntax.typ) {
13835
13850
  case ValidationTokenEnum.Keyword:
13836
- success = (token.typ == exports.EnumToken.IdenTokenType || token.typ == exports.EnumToken.DashedIdenTokenType) &&
13851
+ success = (token.typ == exports.EnumToken.IdenTokenType || token.typ == exports.EnumToken.DashedIdenTokenType || isIdentColor(token)) &&
13837
13852
  (token.val == syntax.val ||
13838
13853
  syntax.val.localeCompare(token.val, undefined, { sensitivity: 'base' }) == 0 ||
13839
13854
  // config.declarations.all
@@ -13862,20 +13877,17 @@ function match(syntax, context, options) {
13862
13877
  context
13863
13878
  };
13864
13879
  }
13865
- {
13866
- result = doEvaluateSyntax((getParsedSyntax("syntaxes" /* ValidationSyntaxGroupEnum.Syntaxes */, syntax.val + '()')?.[0]).chi, createContext(token.chi), {
13867
- ...options,
13868
- isRepeatable: null,
13869
- isList: null,
13870
- occurence: null,
13871
- atLeastOnce: null
13872
- });
13873
- if (result.valid == SyntaxValidationResult.Valid) {
13874
- context.next();
13875
- result.context = context;
13876
- return result;
13877
- }
13880
+ // {
13881
+ // console.error(JSON.stringify({funcDef: (getParsedSyntax(ValidationSyntaxGroupEnum.Syntaxes, (syntax as ValidationFunctionDefinitionToken).val + '()')?.[0] as ValidationFunctionToken).chi}, null, 1))
13882
+ //
13883
+ // const child = getParsedSyntax(ValidationSyntaxGroupEnum.Syntaxes, (syntax as ValidationFunctionDefinitionToken).val + '()')?.[0] as ValidationFunctionToken;
13884
+ result = match(getParsedSyntax("syntaxes" /* ValidationSyntaxGroupEnum.Syntaxes */, syntax.val + '()')?.[0], context, options);
13885
+ if (result.valid == SyntaxValidationResult.Valid) {
13886
+ context.next();
13887
+ result.context = context;
13888
+ return result;
13878
13889
  }
13890
+ // }
13879
13891
  break;
13880
13892
  case ValidationTokenEnum.DeclarationType:
13881
13893
  return doEvaluateSyntax(getParsedSyntax("declarations" /* ValidationSyntaxGroupEnum.Declarations */, syntax.val), context, {
@@ -13972,6 +13984,7 @@ function match(syntax, context, options) {
13972
13984
  }
13973
13985
  function matchPropertyType(syntax, context, options) {
13974
13986
  if (![
13987
+ 'bg-position',
13975
13988
  'length-percentage', 'flex', 'calc-sum', 'color', 'color-base', 'system-color', 'deprecated-system-color',
13976
13989
  'pseudo-class-selector', 'pseudo-element-selector'
13977
13990
  ].includes(syntax.val)) {
@@ -14001,6 +14014,96 @@ function matchPropertyType(syntax, context, options) {
14001
14014
  return { ...result, context };
14002
14015
  }
14003
14016
  switch (syntax.val) {
14017
+ case 'bg-position': {
14018
+ let val;
14019
+ let keyworkMatchCount = 0;
14020
+ let lengthMatchCount = 0;
14021
+ let functionMatchCount = 0;
14022
+ let isBGX = false;
14023
+ let isBGY = false;
14024
+ while (token != null && keyworkMatchCount + lengthMatchCount + functionMatchCount < 3) {
14025
+ // match one value: keyword or length
14026
+ success = (token.typ == exports.EnumToken.FunctionTokenType && wildCardFuncs.includes(token.val));
14027
+ if (success) {
14028
+ functionMatchCount++;
14029
+ context.next();
14030
+ token = context.peek();
14031
+ continue;
14032
+ }
14033
+ if (token.typ == exports.EnumToken.WhitespaceTokenType) {
14034
+ context.next();
14035
+ token = context.peek();
14036
+ continue;
14037
+ }
14038
+ if (token.typ == exports.EnumToken.IdenTokenType) {
14039
+ val = token.val.toLowerCase();
14040
+ success = ['left', 'center', 'right', 'top', 'center', 'bottom'].includes(val);
14041
+ if (!success) {
14042
+ break;
14043
+ }
14044
+ keyworkMatchCount++;
14045
+ if (keyworkMatchCount > 2) {
14046
+ return {
14047
+ valid: SyntaxValidationResult.Drop,
14048
+ node: token,
14049
+ syntax,
14050
+ error: `expected <length>`,
14051
+ context
14052
+ };
14053
+ }
14054
+ if (val == 'left' || val == 'right') {
14055
+ if (isBGX) {
14056
+ return {
14057
+ valid: SyntaxValidationResult.Drop,
14058
+ node: token,
14059
+ syntax,
14060
+ error: `top | bottom | <length-percentage>`,
14061
+ context
14062
+ };
14063
+ }
14064
+ isBGX = true;
14065
+ }
14066
+ if (val == 'top' || val == 'bottom') {
14067
+ if (isBGY) {
14068
+ return {
14069
+ valid: SyntaxValidationResult.Drop,
14070
+ node: token,
14071
+ syntax,
14072
+ error: `expected left | right | <length-percentage>`,
14073
+ context
14074
+ };
14075
+ }
14076
+ isBGY = true;
14077
+ }
14078
+ context.next();
14079
+ token = context.peek();
14080
+ continue;
14081
+ }
14082
+ success = token.typ == exports.EnumToken.LengthTokenType || token.typ == exports.EnumToken.PercentageTokenType || (token.typ == exports.EnumToken.NumberTokenType && token.val == '0');
14083
+ if (!success) {
14084
+ break;
14085
+ }
14086
+ lengthMatchCount++;
14087
+ context.next();
14088
+ token = context.peek();
14089
+ }
14090
+ if (keyworkMatchCount + lengthMatchCount + functionMatchCount == 0) {
14091
+ return {
14092
+ valid: SyntaxValidationResult.Drop,
14093
+ node: token,
14094
+ syntax,
14095
+ error: `expected <bg-position>`,
14096
+ context
14097
+ };
14098
+ }
14099
+ return {
14100
+ valid: SyntaxValidationResult.Valid,
14101
+ node: token,
14102
+ syntax,
14103
+ error: '',
14104
+ context
14105
+ };
14106
+ }
14004
14107
  case 'calc-sum':
14005
14108
  success = (token.typ == exports.EnumToken.FunctionTokenType && mathFuncs.includes(token.val)) ||
14006
14109
  // @ts-ignore
@@ -14069,8 +14172,8 @@ function matchPropertyType(syntax, context, options) {
14069
14172
  case 'number':
14070
14173
  case 'number-token':
14071
14174
  success = token.typ == exports.EnumToken.NumberTokenType;
14072
- if ('range' in syntax) {
14073
- success = success && +token.val >= +syntax.range[0] && +token.val <= +syntax.range[1];
14175
+ if (success && 'range' in syntax) {
14176
+ success = +token.val >= +syntax.range[0] && (syntax.range[1] == null || +token.val <= +syntax.range[1]);
14074
14177
  }
14075
14178
  break;
14076
14179
  case 'angle':
@@ -14208,24 +14311,28 @@ function anyOf(syntaxes, context, options) {
14208
14311
  function allOf(syntax, context, options) {
14209
14312
  let result;
14210
14313
  let i;
14211
- // sort tokens -> wildCard -> last
14212
- // 1px var(...) 2px => 1px 2px var(...)
14213
- const slice = context.slice();
14314
+ let slice = context.slice();
14214
14315
  const vars = [];
14215
14316
  const tokens = [];
14317
+ const repeatable = [];
14318
+ // match optional syntax first
14319
+ // <length>{2,3}&&<color>? => <color>?&&<length>{2,3}
14320
+ for (i = 0; i < syntax.length; i++) {
14321
+ if (syntax[i].length == 1 && syntax[i][0].occurence != null) {
14322
+ repeatable.push(syntax[i]);
14323
+ syntax.splice(i--, 1);
14324
+ }
14325
+ }
14326
+ if (repeatable.length > 0) {
14327
+ syntax.push(...repeatable);
14328
+ }
14329
+ // sort tokens -> wildCard -> last
14330
+ // 1px var(...) 2px => 1px 2px var(...)
14216
14331
  for (i = 0; i < slice.length; i++) {
14217
14332
  if (slice[i].typ == exports.EnumToken.FunctionTokenType && wildCardFuncs.includes(slice[i].val.toLowerCase())) {
14218
14333
  vars.push(slice[i]);
14219
- slice.splice(i, 1);
14220
- if (slice[i]?.typ == exports.EnumToken.WhitespaceTokenType) {
14221
- vars.push(slice[i]);
14222
- slice.splice(i, 1);
14223
- if (i > 0) {
14224
- i--;
14225
- }
14226
- }
14227
- if (i > 0) {
14228
- i--;
14334
+ if (slice[i + 1]?.typ == exports.EnumToken.WhitespaceTokenType) {
14335
+ vars.push(slice[++i]);
14229
14336
  }
14230
14337
  continue;
14231
14338
  }
@@ -14239,7 +14346,44 @@ function allOf(syntax, context, options) {
14239
14346
  tokens.push(...vars);
14240
14347
  }
14241
14348
  const con = createContext(tokens);
14349
+ let cp;
14350
+ let j;
14242
14351
  for (i = 0; i < syntax.length; i++) {
14352
+ if (syntax[i].length == 1 && syntax[i][0].isOptional) {
14353
+ syntax[i][0].isOptional = false;
14354
+ j = 0;
14355
+ cp = con.clone();
14356
+ slice = cp.slice();
14357
+ if (cp.done()) {
14358
+ syntax[i][0].isOptional = true;
14359
+ syntax.splice(i, 1);
14360
+ i = -1;
14361
+ continue;
14362
+ }
14363
+ while (!cp.done()) {
14364
+ result = doEvaluateSyntax(syntax[i], cp.clone(), options);
14365
+ if (result.valid == SyntaxValidationResult.Valid) {
14366
+ let end = slice.indexOf(cp.current());
14367
+ if (end == -1) {
14368
+ end = 0;
14369
+ }
14370
+ else {
14371
+ end -= j - 1;
14372
+ }
14373
+ con.consume(slice[j], end < 0 ? 0 : end);
14374
+ break;
14375
+ }
14376
+ cp.next();
14377
+ j++;
14378
+ }
14379
+ syntax[i][0].isOptional = true;
14380
+ // @ts-ignore
14381
+ if (result?.valid == SyntaxValidationResult.Valid) {
14382
+ syntax.splice(i, 1);
14383
+ i = -1;
14384
+ }
14385
+ continue;
14386
+ }
14243
14387
  result = doEvaluateSyntax(syntax[i], con.clone(), options);
14244
14388
  if (result.valid == SyntaxValidationResult.Valid) {
14245
14389
  con.update(result.context);
@@ -16184,11 +16328,13 @@ async function doParse(iterator, options = {}) {
16184
16328
  const src = options.src;
16185
16329
  const stack = [];
16186
16330
  const stats = {
16331
+ src: options.src ?? '',
16187
16332
  bytesIn: 0,
16188
16333
  importedBytesIn: 0,
16189
16334
  parse: `0ms`,
16190
16335
  minify: `0ms`,
16191
- total: `0ms`
16336
+ total: `0ms`,
16337
+ imports: []
16192
16338
  };
16193
16339
  let ast = {
16194
16340
  typ: exports.EnumToken.StyleSheetNodeType,
@@ -16234,7 +16380,7 @@ async function doParse(iterator, options = {}) {
16234
16380
  ast.loc.end = item.end;
16235
16381
  }
16236
16382
  if (item.token == ';' || item.token == '{') {
16237
- node = parseNode(tokens, context, stats, options, errors, src, map, rawTokens);
16383
+ node = parseNode(tokens, context, options, errors, src, map, rawTokens);
16238
16384
  rawTokens.length = 0;
16239
16385
  if (node != null) {
16240
16386
  if ('chi' in node) {
@@ -16273,7 +16419,7 @@ async function doParse(iterator, options = {}) {
16273
16419
  map = new Map;
16274
16420
  }
16275
16421
  else if (item.token == '}') {
16276
- parseNode(tokens, context, stats, options, errors, src, map, rawTokens);
16422
+ parseNode(tokens, context, options, errors, src, map, rawTokens);
16277
16423
  rawTokens.length = 0;
16278
16424
  if (context.loc != null) {
16279
16425
  context.loc.end = item.end;
@@ -16294,7 +16440,7 @@ async function doParse(iterator, options = {}) {
16294
16440
  }
16295
16441
  }
16296
16442
  if (tokens.length > 0) {
16297
- node = parseNode(tokens, context, stats, options, errors, src, map, rawTokens);
16443
+ node = parseNode(tokens, context, options, errors, src, map, rawTokens);
16298
16444
  rawTokens.length = 0;
16299
16445
  if (node != null) {
16300
16446
  if (node.typ == exports.EnumToken.AtRuleNodeType && node.nam == 'import') {
@@ -16319,7 +16465,6 @@ async function doParse(iterator, options = {}) {
16319
16465
  const url = token.typ == exports.EnumToken.StringTokenType ? token.val.slice(1, -1) : token.val;
16320
16466
  try {
16321
16467
  const root = await options.load(url, options.src).then((src) => {
16322
- // console.error({url, src: options.src, resolved: options.resolve!(url, options.src as string)})
16323
16468
  return doParse(src, Object.assign({}, options, {
16324
16469
  minify: false,
16325
16470
  setParent: false,
@@ -16327,6 +16472,7 @@ async function doParse(iterator, options = {}) {
16327
16472
  }));
16328
16473
  });
16329
16474
  stats.importedBytesIn += root.stats.bytesIn;
16475
+ stats.imports.push(root.stats);
16330
16476
  node.parent.chi.splice(node.parent.chi.indexOf(node), 1, ...root.ast.chi);
16331
16477
  if (root.errors.length > 0) {
16332
16478
  errors.push(...root.errors);
@@ -16418,7 +16564,7 @@ function getLastNode(context) {
16418
16564
  }
16419
16565
  return null;
16420
16566
  }
16421
- function parseNode(results, context, stats, options, errors, src, map, rawTokens) {
16567
+ function parseNode(results, context, options, errors, src, map, rawTokens) {
16422
16568
  let tokens = [];
16423
16569
  for (const t of results) {
16424
16570
  const node = getTokenType(t.token, t.hint);
@@ -16646,9 +16792,11 @@ function parseNode(results, context, stats, options, errors, src, map, rawTokens
16646
16792
  removeComments: true
16647
16793
  }), '');
16648
16794
  }
16649
- // }
16650
16795
  context.chi.push(node);
16651
- Object.defineProperties(node, { parent: { ...definedPropertySettings, value: context }, validSyntax: { ...definedPropertySettings, value: valid.valid == SyntaxValidationResult.Valid } });
16796
+ Object.defineProperties(node, {
16797
+ parent: { ...definedPropertySettings, value: context },
16798
+ validSyntax: { ...definedPropertySettings, value: valid.valid == SyntaxValidationResult.Valid }
16799
+ });
16652
16800
  return node;
16653
16801
  }
16654
16802
  else {
@@ -16686,11 +16834,9 @@ function parseNode(results, context, stats, options, errors, src, map, rawTokens
16686
16834
  let t = renderToken(curr, { minify: false });
16687
16835
  if (t == ',') {
16688
16836
  acc.push([]);
16689
- // uniqTokens.push([]);
16690
16837
  }
16691
16838
  else {
16692
16839
  acc[acc.length - 1].push(t);
16693
- // uniqTokens[uniqTokens.length - 1].push(curr);
16694
16840
  }
16695
16841
  return acc;
16696
16842
  }, [[]]).reduce((acc, curr) => {
@@ -16722,7 +16868,6 @@ function parseNode(results, context, stats, options, errors, src, map, rawTokens
16722
16868
  // @ts-ignore
16723
16869
  context.chi.push(node);
16724
16870
  Object.defineProperty(node, 'parent', { ...definedPropertySettings, value: context });
16725
- // if (options.validation) {
16726
16871
  // @ts-ignore
16727
16872
  const valid = options.validation == exports.ValidationLevel.None ? {
16728
16873
  valid: SyntaxValidationResult.Valid,
@@ -16739,24 +16884,10 @@ function parseNode(results, context, stats, options, errors, src, map, rawTokens
16739
16884
  location
16740
16885
  });
16741
16886
  }
16742
- // } else {
16743
- //
16744
- // Object.defineProperty(node, 'tokens', {
16745
- // ...definedPropertySettings,
16746
- // enumerable: false,
16747
- // value: tokens.slice()
16748
- // });
16749
- //
16750
- // let raw: string[][] = [...uniq.values()];
16751
- //
16752
- // Object.defineProperty(node, 'raw', {
16753
- // enumerable: false,
16754
- // configurable: true,
16755
- // writable: true,
16756
- // value: raw
16757
- // });
16758
- // }
16759
- Object.defineProperty(node, 'validSyntax', { ...definedPropertySettings, value: valid.valid == SyntaxValidationResult.Valid });
16887
+ Object.defineProperty(node, 'validSyntax', {
16888
+ ...definedPropertySettings,
16889
+ value: valid.valid == SyntaxValidationResult.Valid
16890
+ });
16760
16891
  return node;
16761
16892
  }
16762
16893
  else {
@@ -16806,9 +16937,7 @@ function parseNode(results, context, stats, options, errors, src, map, rawTokens
16806
16937
  parseColor(tokens[i]);
16807
16938
  }
16808
16939
  }
16809
- tokens.splice(i, 0, { typ: exports.EnumToken.ColonTokenType });
16810
- // i++;
16811
- i--;
16940
+ tokens.splice(i--, 0, { typ: exports.EnumToken.ColonTokenType });
16812
16941
  continue;
16813
16942
  }
16814
16943
  if ('chi' in tokens[i]) {
@@ -16893,11 +17022,15 @@ function parseNode(results, context, stats, options, errors, src, map, rawTokens
16893
17022
  const result = parseDeclarationNode(node, errors, location);
16894
17023
  Object.defineProperty(result, 'parent', { ...definedPropertySettings, value: context });
16895
17024
  if (result != null) {
16896
- // console.error(doRender(result), result.val, location);
16897
17025
  if (options.validation == exports.ValidationLevel.All) {
16898
17026
  const valid = evaluateSyntax(result, options);
16899
- Object.defineProperty(result, 'validSyntax', { ...definedPropertySettings, value: valid.valid == SyntaxValidationResult.Valid });
17027
+ Object.defineProperty(result, 'validSyntax', {
17028
+ ...definedPropertySettings,
17029
+ value: valid.valid == SyntaxValidationResult.Valid
17030
+ });
16900
17031
  if (valid.valid == SyntaxValidationResult.Drop) {
17032
+ // console.error({result, valid});
17033
+ // console.error(JSON.stringify({result, options, valid}, null, 1));
16901
17034
  errors.push({
16902
17035
  action: 'drop',
16903
17036
  message: valid.error,
@@ -17691,12 +17824,6 @@ function parseTokens(tokens, options = {}) {
17691
17824
  if (t.chi[0].val.slice(1, 5) != 'data:' && urlTokenMatcher.test(value)) {
17692
17825
  // @ts-ignore
17693
17826
  t.chi[0].typ = exports.EnumToken.UrlTokenTokenType;
17694
- // console.error({t, v: t.chi[0], value,
17695
- // src: options.src,
17696
- // resolved: options.src !== '' && options.resolveUrls ? options.resolve(value, options.src).absolute : null,
17697
- // val2: options.src !== '' && options.resolveUrls ? options.resolve(value, options.src).absolute : value});
17698
- //
17699
- // console.error(new Error('resolved'));
17700
17827
  // @ts-ignore
17701
17828
  t.chi[0].val = options.src !== '' && options.resolveUrls ? options.resolve(value, options.src).absolute : value;
17702
17829
  }