@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.
@@ -15,8 +15,17 @@
15
15
  */
16
16
  exports.ValidationLevel = void 0;
17
17
  (function (ValidationLevel) {
18
+ /**
19
+ * disable validation
20
+ */
18
21
  ValidationLevel[ValidationLevel["None"] = 0] = "None";
22
+ /**
23
+ * validate selectors and at-rules
24
+ */
19
25
  ValidationLevel[ValidationLevel["Default"] = 1] = "Default";
26
+ /**
27
+ * validate selectors, at-rules and declarations
28
+ */
20
29
  ValidationLevel[ValidationLevel["All"] = 2] = "All"; // selectors + at-rules + declarations
21
30
  })(exports.ValidationLevel || (exports.ValidationLevel = {}));
22
31
  /**
@@ -4286,6 +4295,8 @@
4286
4295
  // https://developer.mozilla.org/en-US/docs/Web/CSS/WebKit_Extensions
4287
4296
  // https://developer.mozilla.org/en-US/docs/Web/CSS/Mozilla_Extensions
4288
4297
  const pseudoAliasMap = {
4298
+ '-moz-center': 'center',
4299
+ '-webkit-center': 'center',
4289
4300
  '-ms-grid-columns': 'grid-template-columns',
4290
4301
  '-ms-grid-rows': 'grid-template-rows',
4291
4302
  '-ms-grid-row': 'grid-row-start',
@@ -4298,6 +4309,7 @@
4298
4309
  '::-ms-input-placeholder': '::placeholder',
4299
4310
  ':-moz-any()': ':is',
4300
4311
  '-moz-user-modify': 'user-modify',
4312
+ '-webkit-match-parent': 'match-parent',
4301
4313
  '-moz-background-clip': 'background-clip',
4302
4314
  '-moz-background-origin': 'background-origin',
4303
4315
  '-ms-input-placeholder': 'placeholder',
@@ -4454,6 +4466,7 @@
4454
4466
  '-webkit-min-logical-height',
4455
4467
  '-webkit-min-logical-width',
4456
4468
  '-webkit-nbsp-mode',
4469
+ '-webkit-match-parent',
4457
4470
  '-webkit-perspective-origin-x',
4458
4471
  '-webkit-perspective-origin-y',
4459
4472
  '-webkit-rtl-ordering',
@@ -7455,7 +7468,7 @@
7455
7468
  syntax: "auto | after"
7456
7469
  },
7457
7470
  "-ms-overflow-style": {
7458
- syntax: "auto | none | scrollbar | -ms-autohiding-scrollbar"
7471
+ syntax: "auto | none | scrollbar | -ms-autohiding-scrollbar auto | none | scrollbar | -ms-autohiding-scrollbar"
7459
7472
  },
7460
7473
  "-ms-scroll-chaining": {
7461
7474
  syntax: "chained | none"
@@ -7565,9 +7578,6 @@
7565
7578
  "-moz-force-broken-image-icon": {
7566
7579
  syntax: "0 | 1"
7567
7580
  },
7568
- "-moz-image-region": {
7569
- syntax: "<shape> | auto"
7570
- },
7571
7581
  "-moz-orient": {
7572
7582
  syntax: "inline | block | horizontal | vertical"
7573
7583
  },
@@ -7608,7 +7618,7 @@
7608
7618
  syntax: "default | menu | tooltip | sheet | none"
7609
7619
  },
7610
7620
  "-webkit-appearance": {
7611
- 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"
7621
+ 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"
7612
7622
  },
7613
7623
  "-webkit-border-before": {
7614
7624
  syntax: "<'border-width'> || <'border-style'> || <color>"
@@ -7692,7 +7702,7 @@
7692
7702
  syntax: "read-only | read-write | read-write-plaintext-only"
7693
7703
  },
7694
7704
  "-webkit-user-select": {
7695
- syntax: "auto | text | none | all"
7705
+ syntax: "auto | text | none | all auto | none | text | all"
7696
7706
  },
7697
7707
  "accent-color": {
7698
7708
  syntax: "auto | <color>"
@@ -7710,7 +7720,7 @@
7710
7720
  syntax: "[ normal | <baseline-position> | <content-distribution> | <overflow-position>? <content-position> ]#"
7711
7721
  },
7712
7722
  "alignment-baseline": {
7713
- syntax: "baseline | alphabetic | ideographic | middle | central | mathematical | text-before-edge | text-after-edge"
7723
+ 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"
7714
7724
  },
7715
7725
  all: {
7716
7726
  syntax: "initial | inherit | unset | revert | revert-layer"
@@ -7734,7 +7744,7 @@
7734
7744
  syntax: "<single-animation-direction>#"
7735
7745
  },
7736
7746
  "animation-duration": {
7737
- syntax: "<time>#"
7747
+ syntax: "[ auto | <time [0s,∞]> ]#"
7738
7748
  },
7739
7749
  "animation-fill-mode": {
7740
7750
  syntax: "<single-animation-fill-mode>#"
@@ -7812,7 +7822,7 @@
7812
7822
  syntax: "<bg-size>#"
7813
7823
  },
7814
7824
  "baseline-shift": {
7815
- syntax: "<length-percentage> | sub | super | baseline"
7825
+ syntax: "<length-percentage> | sub | super | baseline baseline | sub | super | <svg-length>"
7816
7826
  },
7817
7827
  "block-size": {
7818
7828
  syntax: "<'width'>"
@@ -8151,7 +8161,7 @@
8151
8161
  syntax: "[ <counter-name> <integer>? ]+ | none"
8152
8162
  },
8153
8163
  cursor: {
8154
- 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 ] ]"
8164
+ 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 ] ]"
8155
8165
  },
8156
8166
  cx: {
8157
8167
  syntax: "<length> | <percentage>"
@@ -8166,10 +8176,10 @@
8166
8176
  syntax: "ltr | rtl"
8167
8177
  },
8168
8178
  display: {
8169
- syntax: "[ <display-outside> || <display-inside> ] | <display-listitem> | <display-internal> | <display-box> | <display-legacy>| <-non-standard-display>"
8179
+ syntax: "[ <display-outside> || <display-inside> ] | <display-listitem> | <display-internal> | <display-box> | <display-legacy> | <-non-standard-display>"
8170
8180
  },
8171
8181
  "dominant-baseline": {
8172
- syntax: "auto | text-bottom | alphabetic | ideographic | middle | central | mathematical | hanging | text-top"
8182
+ 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"
8173
8183
  },
8174
8184
  "empty-cells": {
8175
8185
  syntax: "show | hide"
@@ -8181,13 +8191,13 @@
8181
8191
  syntax: "<paint>"
8182
8192
  },
8183
8193
  "fill-opacity": {
8184
- syntax: "<'opacity'>"
8194
+ syntax: "<'opacity'> <number-zero-one>"
8185
8195
  },
8186
8196
  "fill-rule": {
8187
8197
  syntax: "nonzero | evenodd"
8188
8198
  },
8189
8199
  filter: {
8190
- syntax: "none | <filter-value-list>"
8200
+ syntax: "none | <filter-value-list> | <-ms-filter-function-list>"
8191
8201
  },
8192
8202
  flex: {
8193
8203
  syntax: "none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ]"
@@ -8220,7 +8230,7 @@
8220
8230
  syntax: "<'opacity'>"
8221
8231
  },
8222
8232
  font: {
8223
- syntax: "[ [ <'font-style'> || <font-variant-css2> || <'font-weight'> || <font-width-css3> ]? <'font-size'> [ / <'line-height'> ]? <'font-family'># ] | <system-family-name>"
8233
+ 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>"
8224
8234
  },
8225
8235
  "font-family": {
8226
8236
  syntax: "[ <family-name> | <generic-family> ]#"
@@ -8367,7 +8377,7 @@
8367
8377
  syntax: "none | [ first || [ force-end | allow-end ] || last ]"
8368
8378
  },
8369
8379
  height: {
8370
- syntax: "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()>"
8380
+ syntax: "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()> | stretch | <-non-standard-size>"
8371
8381
  },
8372
8382
  "hyphenate-character": {
8373
8383
  syntax: "auto | <string>"
@@ -8382,7 +8392,7 @@
8382
8392
  syntax: "from-image | <angle> | [ <angle>? flip ]"
8383
8393
  },
8384
8394
  "image-rendering": {
8385
- syntax: "auto | crisp-edges | pixelated | smooth| optimizeSpeed | optimizeQuality | <-non-standard-image-rendering>"
8395
+ syntax: "auto | crisp-edges | pixelated | smooth | optimizeSpeed | optimizeQuality | <-non-standard-image-rendering>"
8386
8396
  },
8387
8397
  "image-resolution": {
8388
8398
  syntax: "[ from-image || <resolution> ] && snap?"
@@ -8442,7 +8452,7 @@
8442
8452
  syntax: "<length> | <percentage> | auto"
8443
8453
  },
8444
8454
  "letter-spacing": {
8445
- syntax: "normal | <length>"
8455
+ syntax: "normal | <length> normal | <length-percentage>"
8446
8456
  },
8447
8457
  "lighting-color": {
8448
8458
  syntax: "<color>"
@@ -8586,7 +8596,7 @@
8586
8596
  syntax: "<'max-width'>"
8587
8597
  },
8588
8598
  "max-height": {
8589
- syntax: "none | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()>"
8599
+ syntax: "none | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()> | stretch | <-non-standard-size>"
8590
8600
  },
8591
8601
  "max-inline-size": {
8592
8602
  syntax: "<'max-width'>"
@@ -8595,19 +8605,19 @@
8595
8605
  syntax: "none | <integer>"
8596
8606
  },
8597
8607
  "max-width": {
8598
- syntax: "none | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()>"
8608
+ syntax: "none | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()> | stretch | <-non-standard-size>"
8599
8609
  },
8600
8610
  "min-block-size": {
8601
8611
  syntax: "<'min-width'>"
8602
8612
  },
8603
8613
  "min-height": {
8604
- syntax: "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()>"
8614
+ syntax: "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()> | stretch | <-non-standard-size>"
8605
8615
  },
8606
8616
  "min-inline-size": {
8607
8617
  syntax: "<'min-width'>"
8608
8618
  },
8609
8619
  "min-width": {
8610
- syntax: "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()>"
8620
+ syntax: "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()> | stretch | <-non-standard-size>"
8611
8621
  },
8612
8622
  "mix-blend-mode": {
8613
8623
  syntax: "<blend-mode> | plus-lighter"
@@ -8664,7 +8674,7 @@
8664
8674
  syntax: "<line-width>"
8665
8675
  },
8666
8676
  overflow: {
8667
- syntax: "[ visible | hidden | clip | scroll | auto ]{1,2}"
8677
+ syntax: "[ visible | hidden | clip | scroll | auto ]{1,2} | <-non-standard-overflow>"
8668
8678
  },
8669
8679
  "overflow-anchor": {
8670
8680
  syntax: "auto | none"
@@ -8685,10 +8695,10 @@
8685
8695
  syntax: "normal | break-word | anywhere"
8686
8696
  },
8687
8697
  "overflow-x": {
8688
- syntax: "visible | hidden | clip | scroll | auto"
8698
+ syntax: "visible | hidden | clip | scroll | auto | <-non-standard-overflow>"
8689
8699
  },
8690
8700
  "overflow-y": {
8691
- syntax: "visible | hidden | clip | scroll | auto"
8701
+ syntax: "visible | hidden | clip | scroll | auto | <-non-standard-overflow>"
8692
8702
  },
8693
8703
  overlay: {
8694
8704
  syntax: "none | auto"
@@ -8775,7 +8785,7 @@
8775
8785
  syntax: "auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all | inherit"
8776
8786
  },
8777
8787
  position: {
8778
- syntax: "static | relative | absolute | sticky | fixed| -webkit-sticky"
8788
+ syntax: "static | relative | absolute | sticky | fixed | -webkit-sticky"
8779
8789
  },
8780
8790
  "position-anchor": {
8781
8791
  syntax: "auto | <anchor-name>"
@@ -8982,25 +8992,25 @@
8982
8992
  syntax: "<color>"
8983
8993
  },
8984
8994
  "stroke-dasharray": {
8985
- syntax: "none | <dasharray>"
8995
+ syntax: "none | <dasharray> none | [ <svg-length>+ ]#"
8986
8996
  },
8987
8997
  "stroke-dashoffset": {
8988
- syntax: "<length-percentage> | <number>"
8998
+ syntax: "<length-percentage> | <number> <svg-length>"
8989
8999
  },
8990
9000
  "stroke-linecap": {
8991
9001
  syntax: "butt | round | square"
8992
9002
  },
8993
9003
  "stroke-linejoin": {
8994
- syntax: "miter | miter-clip | round | bevel | arcs"
9004
+ syntax: "miter | miter-clip | round | bevel | arcs miter | round | bevel"
8995
9005
  },
8996
9006
  "stroke-miterlimit": {
8997
- syntax: "<number>"
9007
+ syntax: "<number> <number-one-or-greater>"
8998
9008
  },
8999
9009
  "stroke-opacity": {
9000
9010
  syntax: "<'opacity'>"
9001
9011
  },
9002
9012
  "stroke-width": {
9003
- syntax: "<length-percentage> | <number>"
9013
+ syntax: "<length-percentage> | <number> <svg-length>"
9004
9014
  },
9005
9015
  "tab-size": {
9006
9016
  syntax: "<integer> | <length>"
@@ -9009,7 +9019,7 @@
9009
9019
  syntax: "auto | fixed"
9010
9020
  },
9011
9021
  "text-align": {
9012
- syntax: "start | end | left | right | center | justify | match-parent"
9022
+ syntax: "start | end | left | right | center | justify | match-parent | <-non-standard-text-align>"
9013
9023
  },
9014
9024
  "text-align-last": {
9015
9025
  syntax: "auto | start | end | left | right | center | justify"
@@ -9147,7 +9157,7 @@
9147
9157
  syntax: "none | <length-percentage> [ <length-percentage> <length>? ]?"
9148
9158
  },
9149
9159
  "unicode-bidi": {
9150
- syntax: "normal | embed | isolate | bidi-override | isolate-override | plaintext"
9160
+ syntax: "normal | embed | isolate | bidi-override | isolate-override | plaintext | -moz-isolate | -moz-isolate-override | -moz-plaintext | -webkit-isolate | -webkit-isolate-override | -webkit-plaintext"
9151
9161
  },
9152
9162
  "user-select": {
9153
9163
  syntax: "auto | text | none | all"
@@ -9189,7 +9199,7 @@
9189
9199
  syntax: "<integer>"
9190
9200
  },
9191
9201
  width: {
9192
- syntax: "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()>"
9202
+ syntax: "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()> | stretch | <-non-standard-size>"
9193
9203
  },
9194
9204
  "will-change": {
9195
9205
  syntax: "auto | <animateable-feature>#"
@@ -9204,7 +9214,7 @@
9204
9214
  syntax: "normal | break-word"
9205
9215
  },
9206
9216
  "writing-mode": {
9207
- syntax: "horizontal-tb | vertical-rl | vertical-lr | sideways-rl | sideways-lr"
9217
+ syntax: "horizontal-tb | vertical-rl | vertical-lr | sideways-rl | sideways-lr | <svg-writing-mode>"
9208
9218
  },
9209
9219
  x: {
9210
9220
  syntax: "<length> | <percentage>"
@@ -9240,7 +9250,7 @@
9240
9250
  syntax: "auto | grayscale"
9241
9251
  },
9242
9252
  "-moz-user-select": {
9243
- syntax: "none | text | all | -moz-none"
9253
+ syntax: "none | text | all | -moz-none | auto"
9244
9254
  },
9245
9255
  "-ms-flex-align": {
9246
9256
  syntax: "start | end | center | baseline | stretch"
@@ -9847,10 +9857,10 @@
9847
9857
  syntax: "<url>"
9848
9858
  },
9849
9859
  color: {
9850
- syntax: "<color-base> | currentColor | <system-color> | <light-dark()> | <deprecated-system-color>"
9860
+ syntax: "<color-base> | currentColor | <system-color> | <device-cmyk()> | <light-dark()> | <-non-standard-color>"
9851
9861
  },
9852
9862
  "color()": {
9853
- syntax: "color( [ from <color> ]? <colorspace-params> [ / [ <alpha-value> | none ] ]? )"
9863
+ syntax: "color( <colorspace-params> [ / [ <alpha-value> | none ] ]? )"
9854
9864
  },
9855
9865
  "color-base": {
9856
9866
  syntax: "<hex-color> | <color-function> | <named-color> | <color-mix()> | transparent"
@@ -9862,7 +9872,7 @@
9862
9872
  syntax: "in [ <rectangular-color-space> | <polar-color-space> <hue-interpolation-method>? | <custom-color-space> ]"
9863
9873
  },
9864
9874
  "color-mix()": {
9865
- syntax: "color-mix( <color-interpolation-method> , [ <color> && <percentage [0,100]>? ]#{2})"
9875
+ syntax: "color-mix( <color-interpolation-method> , [ <color> && <percentage [0,100]>? ]#{2} )"
9866
9876
  },
9867
9877
  "color-stop": {
9868
9878
  syntax: "<color-stop-length> | <color-stop-angle>"
@@ -9877,10 +9887,10 @@
9877
9887
  syntax: "<linear-color-stop> , [ <linear-color-hint>? , <linear-color-stop> ]#?"
9878
9888
  },
9879
9889
  "colorspace-params": {
9880
- syntax: "[<custom-params> | <predefined-rgb-params> | <xyz-params>]"
9890
+ syntax: "[ <predefined-rgb-params> | <xyz-params>]"
9881
9891
  },
9882
9892
  combinator: {
9883
- syntax: "'>' | '+' | '~' | [ '||' ]"
9893
+ syntax: "'>' | '+' | '~' | [ '|' '|' ]"
9884
9894
  },
9885
9895
  "common-lig-values": {
9886
9896
  syntax: "[ common-ligatures | no-common-ligatures ]"
@@ -9889,7 +9899,7 @@
9889
9899
  syntax: "searchfield | textarea | push-button | slider-horizontal | checkbox | radio | square-button | menulist | listbox | meter | progress-bar | button"
9890
9900
  },
9891
9901
  "complex-selector": {
9892
- syntax: "<compound-selector> [ <combinator>? <compound-selector> ]*"
9902
+ syntax: "<complex-selector-unit> [ <combinator>? <complex-selector-unit> ]*"
9893
9903
  },
9894
9904
  "complex-selector-list": {
9895
9905
  syntax: "<complex-selector>#"
@@ -9901,7 +9911,7 @@
9901
9911
  syntax: "add | subtract | intersect | exclude"
9902
9912
  },
9903
9913
  "compound-selector": {
9904
- syntax: "[ <type-selector>? <subclass-selector>* [ <pseudo-element-selector> <pseudo-class-selector>* ]* ]!"
9914
+ syntax: "[ <type-selector>? <subclass-selector>* ]!"
9905
9915
  },
9906
9916
  "compound-selector-list": {
9907
9917
  syntax: "<compound-selector>#"
@@ -9913,7 +9923,7 @@
9913
9923
  syntax: "[ [ [ from [ <angle> | <zero> ] ]? [ at <position> ]? ] || <color-interpolation-method> ]? , <angular-color-stop-list>"
9914
9924
  },
9915
9925
  "container-condition": {
9916
- syntax: "[ <container-name>? <container-query>? ]!"
9926
+ syntax: "not <query-in-parens> | <query-in-parens> [ [ and <query-in-parens> ]* | [ or <query-in-parens> ]* ]"
9917
9927
  },
9918
9928
  "container-name": {
9919
9929
  syntax: "<custom-ident>"
@@ -9925,7 +9935,7 @@
9925
9935
  syntax: "space-between | space-around | space-evenly | stretch"
9926
9936
  },
9927
9937
  "content-list": {
9928
- syntax: "[ <string> | contents | <image> | <counter> | <quote> | <target> | <leader()> ]+"
9938
+ syntax: "[ <string> | contents | <image> | <counter> | <quote> | <target> | <leader()> | <attr()> ]+"
9929
9939
  },
9930
9940
  "content-position": {
9931
9941
  syntax: "center | start | end | flex-start | flex-end"
@@ -9940,7 +9950,7 @@
9940
9950
  syntax: "contrast( [ <number> | <percentage> ]? )"
9941
9951
  },
9942
9952
  "coord-box": {
9943
- syntax: "<paint-box> | view-box"
9953
+ syntax: "content-box | padding-box | border-box | fill-box | stroke-box | view-box"
9944
9954
  },
9945
9955
  "cos()": {
9946
9956
  syntax: "cos( <calc-sum> )"
@@ -9970,7 +9980,7 @@
9970
9980
  syntax: "cubic-bezier( [ <number [0,1]>, <number> ]#{2} )"
9971
9981
  },
9972
9982
  "cubic-bezier-easing-function": {
9973
- syntax: "ease | ease-in | ease-out | ease-in-out | <cubic-bezier()>"
9983
+ syntax: "ease | ease-in | ease-out | ease-in-out | cubic-bezier( <number [0,1]> , <number> , <number [0,1]> , <number> )"
9974
9984
  },
9975
9985
  "custom-color-space": {
9976
9986
  syntax: "<dashed-ident>"
@@ -10021,7 +10031,7 @@
10021
10031
  syntax: "[ full-width | proportional-width ]"
10022
10032
  },
10023
10033
  "element()": {
10024
- syntax: "element( <id-selector> )"
10034
+ syntax: "element( <custom-ident> , [ first | start | last | first-except ]? ) | element( <id-selector> )"
10025
10035
  },
10026
10036
  "ellipse()": {
10027
10037
  syntax: "ellipse( <radial-size>? [ at <position> ]? )"
@@ -10102,10 +10112,10 @@
10102
10112
  syntax: "serif | sans-serif | system-ui | cursive | fantasy | math | monospace"
10103
10113
  },
10104
10114
  "general-enclosed": {
10105
- syntax: "[ <function-token> <any-value> ) ] | ( <ident> <any-value> )"
10115
+ syntax: "[ <function-token> <any-value>? ) ] | [ ( <any-value>? ) ]"
10106
10116
  },
10107
10117
  "generic-family": {
10108
- syntax: "<generic-complete> | <generic-incomplete> | emoji | fangsong"
10118
+ syntax: "<generic-script-specific>| <generic-complete> | <generic-incomplete> | <-non-standard-generic-family>"
10109
10119
  },
10110
10120
  "generic-incomplete": {
10111
10121
  syntax: "ui-serif | ui-sans-serif | ui-monospace | ui-rounded"
@@ -10114,7 +10124,7 @@
10114
10124
  syntax: "<shape-box> | fill-box | stroke-box | view-box"
10115
10125
  },
10116
10126
  gradient: {
10117
- syntax: "<linear-gradient()> | <repeating-linear-gradient()> | <radial-gradient()> | <repeating-radial-gradient()> | <conic-gradient()> | <repeating-conic-gradient()>"
10127
+ syntax: "| <-legacy-gradient>"
10118
10128
  },
10119
10129
  "grayscale()": {
10120
10130
  syntax: "grayscale( [ <number> | <percentage> ]? )"
@@ -10402,7 +10412,7 @@
10402
10412
  syntax: "A5 | A4 | A3 | B5 | B4 | JIS-B5 | JIS-B4 | letter | legal | ledger"
10403
10413
  },
10404
10414
  paint: {
10405
- syntax: "none | <color> | <url> [none | <color>]? | context-fill | context-stroke"
10415
+ syntax: "none | <color> | <url> [ none | <color> ]? | context-fill | context-stroke"
10406
10416
  },
10407
10417
  "paint()": {
10408
10418
  syntax: "paint( <ident>, <declaration-value>? )"
@@ -10432,7 +10442,7 @@
10432
10442
  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> ] ]"
10433
10443
  },
10434
10444
  "position-area": {
10435
- 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}"
10445
+ 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} ]"
10436
10446
  },
10437
10447
  "pow()": {
10438
10448
  syntax: "pow( <calc-sum>, <calc-sum> )"
@@ -10447,13 +10457,13 @@
10447
10457
  syntax: "':' <ident-token> | ':' <function-token> <any-value> ')'"
10448
10458
  },
10449
10459
  "pseudo-element-selector": {
10450
- syntax: "':' <pseudo-class-selector>"
10460
+ syntax: "':' <pseudo-class-selector> | <legacy-pseudo-element-selector>"
10451
10461
  },
10452
10462
  "pseudo-page": {
10453
10463
  syntax: ": [ left | right | first | blank ]"
10454
10464
  },
10455
10465
  "query-in-parens": {
10456
- syntax: "( <container-query> ) | ( <size-feature> ) | style( <style-query> ) | scroll-state( <scroll-state-query> ) | <general-enclosed>"
10466
+ syntax: "( <container-condition> ) | ( <size-feature> ) | style( <style-query> ) | <general-enclosed>"
10457
10467
  },
10458
10468
  quote: {
10459
10469
  syntax: "open-quote | close-quote | no-open-quote | no-close-quote"
@@ -10561,10 +10571,10 @@
10561
10571
  syntax: "scaleZ( [ <number> | <percentage> ] )"
10562
10572
  },
10563
10573
  "scope-end": {
10564
- syntax: "<selector-list>"
10574
+ syntax: "<forgiving-selector-list>"
10565
10575
  },
10566
10576
  "scope-start": {
10567
- syntax: "<selector-list>"
10577
+ syntax: "<forgiving-selector-list>"
10568
10578
  },
10569
10579
  "scroll()": {
10570
10580
  syntax: "scroll( [ <scroller> || <axis> ]? )"
@@ -10597,7 +10607,7 @@
10597
10607
  syntax: "[ <length>{2,3} && <color>? ]"
10598
10608
  },
10599
10609
  shape: {
10600
- syntax: "rect(<top>, <right>, <bottom>, <left>)"
10610
+ syntax: "rect( <top>, <right>, <bottom>, <left> ) | rect( <top> <right> <bottom> <left> )"
10601
10611
  },
10602
10612
  "shape-box": {
10603
10613
  syntax: "<visual-box> | margin-box"
@@ -10648,7 +10658,7 @@
10648
10658
  syntax: "closest-side | farthest-side | closest-corner | farthest-corner | <length> | <length-percentage>{2}"
10649
10659
  },
10650
10660
  "size-feature": {
10651
- syntax: "<media-query-list>"
10661
+ syntax: "<mf-plain> | <mf-boolean> | <mf-range>"
10652
10662
  },
10653
10663
  "skew()": {
10654
10664
  syntax: "skew( [ <angle> | <zero> ] , [ <angle> | <zero> ]? )"
@@ -10675,10 +10685,10 @@
10675
10685
  syntax: "<declaration>"
10676
10686
  },
10677
10687
  "style-in-parens": {
10678
- syntax: "( <style-query> ) | ( <style-feature> ) | <general-enclosed>"
10688
+ syntax: "( <style-condition> ) | ( <style-feature> ) | <general-enclosed>"
10679
10689
  },
10680
10690
  "style-query": {
10681
- syntax: "not <style-in-parens> | <style-in-parens> [ [ and <style-in-parens> ]* | [ or <style-in-parens> ]* ] | <style-feature> "
10691
+ syntax: "<style-condition> | <style-feature>"
10682
10692
  },
10683
10693
  "subclass-selector": {
10684
10694
  syntax: "<id-selector> | <class-selector> | <attribute-selector> | <pseudo-class-selector>"
@@ -10807,7 +10817,7 @@
10807
10817
  syntax: "xyz | xyz-d50 | xyz-d65"
10808
10818
  },
10809
10819
  "xyz-params": {
10810
- syntax: "<xyz> [ <number> | <percentage> | none ]{3}"
10820
+ syntax: "<xyz-space> [ <number> | <percentage> | none ]{3}"
10811
10821
  },
10812
10822
  "-legacy-gradient": {
10813
10823
  syntax: "<-webkit-gradient()> | <-legacy-linear-gradient> | <-legacy-repeating-linear-gradient> | <-legacy-radial-gradient> | <-legacy-repeating-radial-gradient>"
@@ -11002,10 +11012,13 @@
11002
11012
  syntax: "not <style-in-parens> | <style-in-parens> [ [ and <style-in-parens> ]* | [ or <style-in-parens> ]* ]"
11003
11013
  },
11004
11014
  "-non-standard-display": {
11005
- 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"
11015
+ 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"
11006
11016
  },
11007
11017
  "inset-area": {
11008
11018
  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} ]"
11019
+ },
11020
+ "-non-standard-text-align": {
11021
+ syntax: "| -moz-center | -webkit-center | -webkit-match-parent"
11009
11022
  }
11010
11023
  };
11011
11024
  var selectors = {
@@ -11654,20 +11667,6 @@
11654
11667
  ValidationSyntaxGroupEnum["AtRules"] = "atRules";
11655
11668
  })(ValidationSyntaxGroupEnum || (ValidationSyntaxGroupEnum = {}));
11656
11669
 
11657
- var WalkValidationTokenEnum;
11658
- (function (WalkValidationTokenEnum) {
11659
- WalkValidationTokenEnum[WalkValidationTokenEnum["IgnoreChildren"] = 0] = "IgnoreChildren";
11660
- WalkValidationTokenEnum[WalkValidationTokenEnum["IgnoreNode"] = 1] = "IgnoreNode";
11661
- WalkValidationTokenEnum[WalkValidationTokenEnum["IgnoreAll"] = 2] = "IgnoreAll";
11662
- })(WalkValidationTokenEnum || (WalkValidationTokenEnum = {}));
11663
- var WalkValidationTokenKeyTypeEnum;
11664
- (function (WalkValidationTokenKeyTypeEnum) {
11665
- WalkValidationTokenKeyTypeEnum["Array"] = "array";
11666
- WalkValidationTokenKeyTypeEnum["Children"] = "chi";
11667
- WalkValidationTokenKeyTypeEnum["Left"] = "l";
11668
- WalkValidationTokenKeyTypeEnum["Right"] = "r";
11669
- WalkValidationTokenKeyTypeEnum["Prelude"] = "prelude";
11670
- })(WalkValidationTokenKeyTypeEnum || (WalkValidationTokenKeyTypeEnum = {}));
11671
11670
  const skipped = [
11672
11671
  ValidationTokenEnum.Star,
11673
11672
  ValidationTokenEnum.HashMark,
@@ -11681,18 +11680,6 @@
11681
11680
  writable: true,
11682
11681
  configurable: true
11683
11682
  };
11684
- // syntaxes: keyword | <'property'> | <function>
11685
- // "none | [ [<dashed-ident> || <try-tactic>] | inset-area( <'inset-area'> ) ]#"
11686
- // ""
11687
- // : "<outline-radius>{1,4} [ / <outline-radius>{1,4} ]?
11688
- // ""
11689
- // false | true
11690
- // [ <mask-reference> || <position> [ / <bg-size> ]? || <repeat-style> || [ <box> | border | padding | content | text ] || [ <box> | border | padding | content ] ]#
11691
- // false | true | green | pipe
11692
- // keyword | <'property'> | <function>
11693
- // [<dashed-ident> || <try-tactic>]
11694
- // [ <mask-reference> || <position> [ / <bg-size> ]? || <repeat-style> || [ <box> | border | padding | content | text ] || [ <box> | border | padding | content ] ]#
11695
- // none | [ [<dashed-ident> || <try-tactic>] | inset-area( <'inset-area'> ) ]
11696
11683
  function* tokenize(syntax, position = { ind: 0, lin: 1, col: 0 }, currentPosition = {
11697
11684
  ind: -1,
11698
11685
  lin: 1,
@@ -11855,7 +11842,6 @@
11855
11842
  let items = [];
11856
11843
  let match = 0;
11857
11844
  while ((item = iterator.next()) && !item.done) {
11858
- // console.error(JSON.stringify({match, val: item.value,func}, null, 1));
11859
11845
  switch (item.value.typ) {
11860
11846
  case ValidationTokenEnum.OpenParenthesis:
11861
11847
  if (match > 0) {
@@ -12531,7 +12517,7 @@
12531
12517
  if (token.startsWith('<')) {
12532
12518
  // <number [1,1000]>
12533
12519
  // <length [0,∞]>
12534
- let match = token.match(/<([a-z0-9-]+)(\s+\[([0-9]+),(([0-9]+)|∞)\])?>/);
12520
+ let match = token.match(/<([a-z0-9-]+)(\s+\[([0-9]+[a-zA-Z]*),(([0-9]+[a-zA-Z]*)|∞)\])?>/);
12535
12521
  if (match == null) {
12536
12522
  let match = token.match(/<([a-zA-Z0-9-]+)\(\)>/);
12537
12523
  if (match != null) {
@@ -12543,10 +12529,12 @@
12543
12529
  throw new Error('invalid token at position: ' + position.lin + ':' + position.col + ' ' + token);
12544
12530
  }
12545
12531
  if (match[2] != null) {
12532
+ const type = getTokenType(match[3]);
12546
12533
  return Object.defineProperty({
12547
12534
  typ: ValidationTokenEnum.PropertyType,
12548
12535
  val: match[1],
12549
- range: [+match[3], match[4] == '\u221e' ? Infinity : +match[4]]
12536
+ unit: exports.EnumToken[type.typ],
12537
+ range: [+type.val, match[4] == '\u221e' ? null : +match[4]]
12550
12538
  }, 'pos', { ...objectProperties, value: pos });
12551
12539
  }
12552
12540
  return Object.defineProperty({
@@ -12617,7 +12605,7 @@
12617
12605
  case ValidationTokenEnum.Bracket:
12618
12606
  return '[' + token.chi.reduce((acc, curr) => acc + renderSyntax(curr), '') + ']' + renderAttributes(token);
12619
12607
  case ValidationTokenEnum.PropertyType:
12620
- return '<' + token.val + '>' + renderAttributes(token);
12608
+ return '<' + token.val + (Array.isArray(token.range) ? `[${token?.range?.[0]}, ${token?.range?.[1] ?? '\u221e'}]` : '') + '>' + renderAttributes(token);
12621
12609
  case ValidationTokenEnum.DeclarationType:
12622
12610
  return "<'" + token.val + "'>" + renderAttributes(token);
12623
12611
  case ValidationTokenEnum.Number:
@@ -13375,12 +13363,25 @@
13375
13363
  update(context) {
13376
13364
  // @ts-ignore
13377
13365
  const newIndex = result.indexOf(context.current());
13378
- if (newIndex != -1) {
13379
- // console.error({newIndex, v: result[newIndex]});
13380
- // console.error(new Error('update'))
13366
+ if (newIndex > this.index) {
13381
13367
  this.index = newIndex;
13382
13368
  }
13383
13369
  },
13370
+ consume(token, howMany) {
13371
+ let newIndex = result.indexOf(token, this.index + 1);
13372
+ if (newIndex == -1 || newIndex < this.index) {
13373
+ return false;
13374
+ }
13375
+ howMany ??= 0;
13376
+ let splice = 1;
13377
+ if (result[newIndex - 1]?.typ == exports.EnumToken.WhitespaceTokenType) {
13378
+ splice++;
13379
+ newIndex--;
13380
+ }
13381
+ result.splice(this.index + 1, 0, ...result.splice(newIndex, splice + howMany));
13382
+ this.index += howMany + splice;
13383
+ return true;
13384
+ },
13384
13385
  done() {
13385
13386
  return this.index + 1 >= result.length;
13386
13387
  },
@@ -13405,13 +13406,21 @@
13405
13406
  return result.slice(this.index + 1);
13406
13407
  },
13407
13408
  clone() {
13408
- const context = createContext(input.slice());
13409
+ const context = createContext(result.slice());
13409
13410
  context.index = this.index;
13410
13411
  return context;
13412
+ },
13413
+ // @ts-ignore
13414
+ toJSON() {
13415
+ return {
13416
+ index: this.index,
13417
+ slice: this.slice(),
13418
+ tokens: this.tokens()
13419
+ };
13411
13420
  }
13412
13421
  };
13413
13422
  }
13414
- function evaluateSyntax(node, options, parent) {
13423
+ function evaluateSyntax(node, options) {
13415
13424
  let ast;
13416
13425
  let result;
13417
13426
  switch (node.typ) {
@@ -13420,6 +13429,7 @@
13420
13429
  break;
13421
13430
  }
13422
13431
  ast = getParsedSyntax("declarations" /* ValidationSyntaxGroupEnum.Declarations */, node.nam);
13432
+ // console.error({ast: ast.reduce((acc, curr) => acc + renderSyntax(curr), '')});
13423
13433
  if (ast != null) {
13424
13434
  let token = null;
13425
13435
  const values = node.val.slice();
@@ -13439,6 +13449,7 @@
13439
13449
  }
13440
13450
  }
13441
13451
  result = doEvaluateSyntax(ast, createContext(values), { ...options, visited: new WeakMap() });
13452
+ // console.error(JSON.stringify({ast, values, result}, null, 1));
13442
13453
  if (result.valid == SyntaxValidationResult.Valid && !result.context.done()) {
13443
13454
  let token = null;
13444
13455
  while ((token = result.context.next()) != null) {
@@ -13497,6 +13508,7 @@
13497
13508
  let i = 0;
13498
13509
  let result;
13499
13510
  let token = null;
13511
+ // 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), '')}`);
13500
13512
  for (; i < syntaxes.length; i++) {
13501
13513
  syntax = syntaxes[i];
13502
13514
  if (context.done()) {
@@ -13526,6 +13538,7 @@
13526
13538
  }
13527
13539
  else {
13528
13540
  if (isVisited(token, syntax, 'doEvaluateSyntax', options)) {
13541
+ // console.error(`cyclic dependency: ${renderSyntax(syntax)}`);
13529
13542
  return {
13530
13543
  valid: SyntaxValidationResult.Drop,
13531
13544
  node: token,
@@ -13547,7 +13560,8 @@
13547
13560
  }
13548
13561
  context.update(result.context);
13549
13562
  }
13550
- return {
13563
+ // @ts-ignore
13564
+ return result ?? {
13551
13565
  valid: SyntaxValidationResult.Valid,
13552
13566
  node: null,
13553
13567
  syntax: syntaxes[i - 1],
@@ -13672,6 +13686,7 @@
13672
13686
  };
13673
13687
  }
13674
13688
  function match(syntax, context, options) {
13689
+ // console.error(`>> match(): ${renderSyntax(syntax)}\n>> ${JSON.stringify({syntax}, null, 1)}>> context: ${context.slice<Token>().reduce((acc, curr) => acc + renderToken(curr), '')}`);
13675
13690
  let success = false;
13676
13691
  let result;
13677
13692
  let token = context.peek();
@@ -13689,7 +13704,7 @@
13689
13704
  }
13690
13705
  return {
13691
13706
  valid: SyntaxValidationResult.Drop,
13692
- node: context.next(),
13707
+ node: context.current(),
13693
13708
  syntax,
13694
13709
  error: `expected '${ValidationTokenEnum[syntax.typ].toLowerCase()}', got '${context.done() ? null : renderToken(context.peek())}'`,
13695
13710
  context
@@ -13724,7 +13739,7 @@
13724
13739
  }
13725
13740
  switch (syntax.typ) {
13726
13741
  case ValidationTokenEnum.Keyword:
13727
- success = (token.typ == exports.EnumToken.IdenTokenType || token.typ == exports.EnumToken.DashedIdenTokenType) &&
13742
+ success = (token.typ == exports.EnumToken.IdenTokenType || token.typ == exports.EnumToken.DashedIdenTokenType || isIdentColor(token)) &&
13728
13743
  (token.val == syntax.val ||
13729
13744
  syntax.val.localeCompare(token.val, undefined, { sensitivity: 'base' }) == 0 ||
13730
13745
  // config.declarations.all
@@ -13753,20 +13768,17 @@
13753
13768
  context
13754
13769
  };
13755
13770
  }
13756
- {
13757
- result = doEvaluateSyntax((getParsedSyntax("syntaxes" /* ValidationSyntaxGroupEnum.Syntaxes */, syntax.val + '()')?.[0]).chi, createContext(token.chi), {
13758
- ...options,
13759
- isRepeatable: null,
13760
- isList: null,
13761
- occurence: null,
13762
- atLeastOnce: null
13763
- });
13764
- if (result.valid == SyntaxValidationResult.Valid) {
13765
- context.next();
13766
- result.context = context;
13767
- return result;
13768
- }
13771
+ // {
13772
+ // console.error(JSON.stringify({funcDef: (getParsedSyntax(ValidationSyntaxGroupEnum.Syntaxes, (syntax as ValidationFunctionDefinitionToken).val + '()')?.[0] as ValidationFunctionToken).chi}, null, 1))
13773
+ //
13774
+ // const child = getParsedSyntax(ValidationSyntaxGroupEnum.Syntaxes, (syntax as ValidationFunctionDefinitionToken).val + '()')?.[0] as ValidationFunctionToken;
13775
+ result = match(getParsedSyntax("syntaxes" /* ValidationSyntaxGroupEnum.Syntaxes */, syntax.val + '()')?.[0], context, options);
13776
+ if (result.valid == SyntaxValidationResult.Valid) {
13777
+ context.next();
13778
+ result.context = context;
13779
+ return result;
13769
13780
  }
13781
+ // }
13770
13782
  break;
13771
13783
  case ValidationTokenEnum.DeclarationType:
13772
13784
  return doEvaluateSyntax(getParsedSyntax("declarations" /* ValidationSyntaxGroupEnum.Declarations */, syntax.val), context, {
@@ -13863,6 +13875,7 @@
13863
13875
  }
13864
13876
  function matchPropertyType(syntax, context, options) {
13865
13877
  if (![
13878
+ 'bg-position',
13866
13879
  'length-percentage', 'flex', 'calc-sum', 'color', 'color-base', 'system-color', 'deprecated-system-color',
13867
13880
  'pseudo-class-selector', 'pseudo-element-selector'
13868
13881
  ].includes(syntax.val)) {
@@ -13892,6 +13905,96 @@
13892
13905
  return { ...result, context };
13893
13906
  }
13894
13907
  switch (syntax.val) {
13908
+ case 'bg-position': {
13909
+ let val;
13910
+ let keyworkMatchCount = 0;
13911
+ let lengthMatchCount = 0;
13912
+ let functionMatchCount = 0;
13913
+ let isBGX = false;
13914
+ let isBGY = false;
13915
+ while (token != null && keyworkMatchCount + lengthMatchCount + functionMatchCount < 3) {
13916
+ // match one value: keyword or length
13917
+ success = (token.typ == exports.EnumToken.FunctionTokenType && wildCardFuncs.includes(token.val));
13918
+ if (success) {
13919
+ functionMatchCount++;
13920
+ context.next();
13921
+ token = context.peek();
13922
+ continue;
13923
+ }
13924
+ if (token.typ == exports.EnumToken.WhitespaceTokenType) {
13925
+ context.next();
13926
+ token = context.peek();
13927
+ continue;
13928
+ }
13929
+ if (token.typ == exports.EnumToken.IdenTokenType) {
13930
+ val = token.val.toLowerCase();
13931
+ success = ['left', 'center', 'right', 'top', 'center', 'bottom'].includes(val);
13932
+ if (!success) {
13933
+ break;
13934
+ }
13935
+ keyworkMatchCount++;
13936
+ if (keyworkMatchCount > 2) {
13937
+ return {
13938
+ valid: SyntaxValidationResult.Drop,
13939
+ node: token,
13940
+ syntax,
13941
+ error: `expected <length>`,
13942
+ context
13943
+ };
13944
+ }
13945
+ if (val == 'left' || val == 'right') {
13946
+ if (isBGX) {
13947
+ return {
13948
+ valid: SyntaxValidationResult.Drop,
13949
+ node: token,
13950
+ syntax,
13951
+ error: `top | bottom | <length-percentage>`,
13952
+ context
13953
+ };
13954
+ }
13955
+ isBGX = true;
13956
+ }
13957
+ if (val == 'top' || val == 'bottom') {
13958
+ if (isBGY) {
13959
+ return {
13960
+ valid: SyntaxValidationResult.Drop,
13961
+ node: token,
13962
+ syntax,
13963
+ error: `expected left | right | <length-percentage>`,
13964
+ context
13965
+ };
13966
+ }
13967
+ isBGY = true;
13968
+ }
13969
+ context.next();
13970
+ token = context.peek();
13971
+ continue;
13972
+ }
13973
+ success = token.typ == exports.EnumToken.LengthTokenType || token.typ == exports.EnumToken.PercentageTokenType || (token.typ == exports.EnumToken.NumberTokenType && token.val == '0');
13974
+ if (!success) {
13975
+ break;
13976
+ }
13977
+ lengthMatchCount++;
13978
+ context.next();
13979
+ token = context.peek();
13980
+ }
13981
+ if (keyworkMatchCount + lengthMatchCount + functionMatchCount == 0) {
13982
+ return {
13983
+ valid: SyntaxValidationResult.Drop,
13984
+ node: token,
13985
+ syntax,
13986
+ error: `expected <bg-position>`,
13987
+ context
13988
+ };
13989
+ }
13990
+ return {
13991
+ valid: SyntaxValidationResult.Valid,
13992
+ node: token,
13993
+ syntax,
13994
+ error: '',
13995
+ context
13996
+ };
13997
+ }
13895
13998
  case 'calc-sum':
13896
13999
  success = (token.typ == exports.EnumToken.FunctionTokenType && mathFuncs.includes(token.val)) ||
13897
14000
  // @ts-ignore
@@ -13960,8 +14063,8 @@
13960
14063
  case 'number':
13961
14064
  case 'number-token':
13962
14065
  success = token.typ == exports.EnumToken.NumberTokenType;
13963
- if ('range' in syntax) {
13964
- success = success && +token.val >= +syntax.range[0] && +token.val <= +syntax.range[1];
14066
+ if (success && 'range' in syntax) {
14067
+ success = +token.val >= +syntax.range[0] && (syntax.range[1] == null || +token.val <= +syntax.range[1]);
13965
14068
  }
13966
14069
  break;
13967
14070
  case 'angle':
@@ -14099,24 +14202,28 @@
14099
14202
  function allOf(syntax, context, options) {
14100
14203
  let result;
14101
14204
  let i;
14102
- // sort tokens -> wildCard -> last
14103
- // 1px var(...) 2px => 1px 2px var(...)
14104
- const slice = context.slice();
14205
+ let slice = context.slice();
14105
14206
  const vars = [];
14106
14207
  const tokens = [];
14208
+ const repeatable = [];
14209
+ // match optional syntax first
14210
+ // <length>{2,3}&&<color>? => <color>?&&<length>{2,3}
14211
+ for (i = 0; i < syntax.length; i++) {
14212
+ if (syntax[i].length == 1 && syntax[i][0].occurence != null) {
14213
+ repeatable.push(syntax[i]);
14214
+ syntax.splice(i--, 1);
14215
+ }
14216
+ }
14217
+ if (repeatable.length > 0) {
14218
+ syntax.push(...repeatable);
14219
+ }
14220
+ // sort tokens -> wildCard -> last
14221
+ // 1px var(...) 2px => 1px 2px var(...)
14107
14222
  for (i = 0; i < slice.length; i++) {
14108
14223
  if (slice[i].typ == exports.EnumToken.FunctionTokenType && wildCardFuncs.includes(slice[i].val.toLowerCase())) {
14109
14224
  vars.push(slice[i]);
14110
- slice.splice(i, 1);
14111
- if (slice[i]?.typ == exports.EnumToken.WhitespaceTokenType) {
14112
- vars.push(slice[i]);
14113
- slice.splice(i, 1);
14114
- if (i > 0) {
14115
- i--;
14116
- }
14117
- }
14118
- if (i > 0) {
14119
- i--;
14225
+ if (slice[i + 1]?.typ == exports.EnumToken.WhitespaceTokenType) {
14226
+ vars.push(slice[++i]);
14120
14227
  }
14121
14228
  continue;
14122
14229
  }
@@ -14130,7 +14237,44 @@
14130
14237
  tokens.push(...vars);
14131
14238
  }
14132
14239
  const con = createContext(tokens);
14240
+ let cp;
14241
+ let j;
14133
14242
  for (i = 0; i < syntax.length; i++) {
14243
+ if (syntax[i].length == 1 && syntax[i][0].isOptional) {
14244
+ syntax[i][0].isOptional = false;
14245
+ j = 0;
14246
+ cp = con.clone();
14247
+ slice = cp.slice();
14248
+ if (cp.done()) {
14249
+ syntax[i][0].isOptional = true;
14250
+ syntax.splice(i, 1);
14251
+ i = -1;
14252
+ continue;
14253
+ }
14254
+ while (!cp.done()) {
14255
+ result = doEvaluateSyntax(syntax[i], cp.clone(), options);
14256
+ if (result.valid == SyntaxValidationResult.Valid) {
14257
+ let end = slice.indexOf(cp.current());
14258
+ if (end == -1) {
14259
+ end = 0;
14260
+ }
14261
+ else {
14262
+ end -= j - 1;
14263
+ }
14264
+ con.consume(slice[j], end < 0 ? 0 : end);
14265
+ break;
14266
+ }
14267
+ cp.next();
14268
+ j++;
14269
+ }
14270
+ syntax[i][0].isOptional = true;
14271
+ // @ts-ignore
14272
+ if (result?.valid == SyntaxValidationResult.Valid) {
14273
+ syntax.splice(i, 1);
14274
+ i = -1;
14275
+ }
14276
+ continue;
14277
+ }
14134
14278
  result = doEvaluateSyntax(syntax[i], con.clone(), options);
14135
14279
  if (result.valid == SyntaxValidationResult.Valid) {
14136
14280
  con.update(result.context);
@@ -16075,11 +16219,13 @@
16075
16219
  const src = options.src;
16076
16220
  const stack = [];
16077
16221
  const stats = {
16222
+ src: options.src ?? '',
16078
16223
  bytesIn: 0,
16079
16224
  importedBytesIn: 0,
16080
16225
  parse: `0ms`,
16081
16226
  minify: `0ms`,
16082
- total: `0ms`
16227
+ total: `0ms`,
16228
+ imports: []
16083
16229
  };
16084
16230
  let ast = {
16085
16231
  typ: exports.EnumToken.StyleSheetNodeType,
@@ -16125,7 +16271,7 @@
16125
16271
  ast.loc.end = item.end;
16126
16272
  }
16127
16273
  if (item.token == ';' || item.token == '{') {
16128
- node = parseNode(tokens, context, stats, options, errors, src, map, rawTokens);
16274
+ node = parseNode(tokens, context, options, errors, src, map, rawTokens);
16129
16275
  rawTokens.length = 0;
16130
16276
  if (node != null) {
16131
16277
  if ('chi' in node) {
@@ -16164,7 +16310,7 @@
16164
16310
  map = new Map;
16165
16311
  }
16166
16312
  else if (item.token == '}') {
16167
- parseNode(tokens, context, stats, options, errors, src, map, rawTokens);
16313
+ parseNode(tokens, context, options, errors, src, map, rawTokens);
16168
16314
  rawTokens.length = 0;
16169
16315
  if (context.loc != null) {
16170
16316
  context.loc.end = item.end;
@@ -16185,7 +16331,7 @@
16185
16331
  }
16186
16332
  }
16187
16333
  if (tokens.length > 0) {
16188
- node = parseNode(tokens, context, stats, options, errors, src, map, rawTokens);
16334
+ node = parseNode(tokens, context, options, errors, src, map, rawTokens);
16189
16335
  rawTokens.length = 0;
16190
16336
  if (node != null) {
16191
16337
  if (node.typ == exports.EnumToken.AtRuleNodeType && node.nam == 'import') {
@@ -16210,7 +16356,6 @@
16210
16356
  const url = token.typ == exports.EnumToken.StringTokenType ? token.val.slice(1, -1) : token.val;
16211
16357
  try {
16212
16358
  const root = await options.load(url, options.src).then((src) => {
16213
- // console.error({url, src: options.src, resolved: options.resolve!(url, options.src as string)})
16214
16359
  return doParse(src, Object.assign({}, options, {
16215
16360
  minify: false,
16216
16361
  setParent: false,
@@ -16218,6 +16363,7 @@
16218
16363
  }));
16219
16364
  });
16220
16365
  stats.importedBytesIn += root.stats.bytesIn;
16366
+ stats.imports.push(root.stats);
16221
16367
  node.parent.chi.splice(node.parent.chi.indexOf(node), 1, ...root.ast.chi);
16222
16368
  if (root.errors.length > 0) {
16223
16369
  errors.push(...root.errors);
@@ -16309,7 +16455,7 @@
16309
16455
  }
16310
16456
  return null;
16311
16457
  }
16312
- function parseNode(results, context, stats, options, errors, src, map, rawTokens) {
16458
+ function parseNode(results, context, options, errors, src, map, rawTokens) {
16313
16459
  let tokens = [];
16314
16460
  for (const t of results) {
16315
16461
  const node = getTokenType(t.token, t.hint);
@@ -16537,9 +16683,11 @@
16537
16683
  removeComments: true
16538
16684
  }), '');
16539
16685
  }
16540
- // }
16541
16686
  context.chi.push(node);
16542
- Object.defineProperties(node, { parent: { ...definedPropertySettings, value: context }, validSyntax: { ...definedPropertySettings, value: valid.valid == SyntaxValidationResult.Valid } });
16687
+ Object.defineProperties(node, {
16688
+ parent: { ...definedPropertySettings, value: context },
16689
+ validSyntax: { ...definedPropertySettings, value: valid.valid == SyntaxValidationResult.Valid }
16690
+ });
16543
16691
  return node;
16544
16692
  }
16545
16693
  else {
@@ -16577,11 +16725,9 @@
16577
16725
  let t = renderToken(curr, { minify: false });
16578
16726
  if (t == ',') {
16579
16727
  acc.push([]);
16580
- // uniqTokens.push([]);
16581
16728
  }
16582
16729
  else {
16583
16730
  acc[acc.length - 1].push(t);
16584
- // uniqTokens[uniqTokens.length - 1].push(curr);
16585
16731
  }
16586
16732
  return acc;
16587
16733
  }, [[]]).reduce((acc, curr) => {
@@ -16613,7 +16759,6 @@
16613
16759
  // @ts-ignore
16614
16760
  context.chi.push(node);
16615
16761
  Object.defineProperty(node, 'parent', { ...definedPropertySettings, value: context });
16616
- // if (options.validation) {
16617
16762
  // @ts-ignore
16618
16763
  const valid = options.validation == exports.ValidationLevel.None ? {
16619
16764
  valid: SyntaxValidationResult.Valid,
@@ -16630,24 +16775,10 @@
16630
16775
  location
16631
16776
  });
16632
16777
  }
16633
- // } else {
16634
- //
16635
- // Object.defineProperty(node, 'tokens', {
16636
- // ...definedPropertySettings,
16637
- // enumerable: false,
16638
- // value: tokens.slice()
16639
- // });
16640
- //
16641
- // let raw: string[][] = [...uniq.values()];
16642
- //
16643
- // Object.defineProperty(node, 'raw', {
16644
- // enumerable: false,
16645
- // configurable: true,
16646
- // writable: true,
16647
- // value: raw
16648
- // });
16649
- // }
16650
- Object.defineProperty(node, 'validSyntax', { ...definedPropertySettings, value: valid.valid == SyntaxValidationResult.Valid });
16778
+ Object.defineProperty(node, 'validSyntax', {
16779
+ ...definedPropertySettings,
16780
+ value: valid.valid == SyntaxValidationResult.Valid
16781
+ });
16651
16782
  return node;
16652
16783
  }
16653
16784
  else {
@@ -16697,9 +16828,7 @@
16697
16828
  parseColor(tokens[i]);
16698
16829
  }
16699
16830
  }
16700
- tokens.splice(i, 0, { typ: exports.EnumToken.ColonTokenType });
16701
- // i++;
16702
- i--;
16831
+ tokens.splice(i--, 0, { typ: exports.EnumToken.ColonTokenType });
16703
16832
  continue;
16704
16833
  }
16705
16834
  if ('chi' in tokens[i]) {
@@ -16784,11 +16913,15 @@
16784
16913
  const result = parseDeclarationNode(node, errors, location);
16785
16914
  Object.defineProperty(result, 'parent', { ...definedPropertySettings, value: context });
16786
16915
  if (result != null) {
16787
- // console.error(doRender(result), result.val, location);
16788
16916
  if (options.validation == exports.ValidationLevel.All) {
16789
16917
  const valid = evaluateSyntax(result, options);
16790
- Object.defineProperty(result, 'validSyntax', { ...definedPropertySettings, value: valid.valid == SyntaxValidationResult.Valid });
16918
+ Object.defineProperty(result, 'validSyntax', {
16919
+ ...definedPropertySettings,
16920
+ value: valid.valid == SyntaxValidationResult.Valid
16921
+ });
16791
16922
  if (valid.valid == SyntaxValidationResult.Drop) {
16923
+ // console.error({result, valid});
16924
+ // console.error(JSON.stringify({result, options, valid}, null, 1));
16792
16925
  errors.push({
16793
16926
  action: 'drop',
16794
16927
  message: valid.error,
@@ -17582,12 +17715,6 @@
17582
17715
  if (t.chi[0].val.slice(1, 5) != 'data:' && urlTokenMatcher.test(value)) {
17583
17716
  // @ts-ignore
17584
17717
  t.chi[0].typ = exports.EnumToken.UrlTokenTokenType;
17585
- // console.error({t, v: t.chi[0], value,
17586
- // src: options.src,
17587
- // resolved: options.src !== '' && options.resolveUrls ? options.resolve(value, options.src).absolute : null,
17588
- // val2: options.src !== '' && options.resolveUrls ? options.resolve(value, options.src).absolute : value});
17589
- //
17590
- // console.error(new Error('resolved'));
17591
17718
  // @ts-ignore
17592
17719
  t.chi[0].val = options.src !== '' && options.resolveUrls ? options.resolve(value, options.src).absolute : value;
17593
17720
  }