@tbela99/css-parser 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
  /**
@@ -257,7 +266,7 @@
257
266
  const k = Math.pow(29, 3) / Math.pow(3, 3);
258
267
  const e = Math.pow(6, 3) / Math.pow(29, 3);
259
268
  // color module v4
260
- const systemColors = new Set(['ActiveText', 'ButtonBorder', 'ButtonFace', 'ButtonText', 'Canvas', 'CanvasText', 'Field', 'FieldText', 'GrayText', 'Highlight', 'HighlightText', 'LinkText', 'Mark', 'MarkText', 'VisitedText'].map(m => m.toLowerCase()));
269
+ const systemColors = new Set(['ActiveText', 'ButtonBorder', 'ButtonFace', 'ButtonText', 'Canvas', 'CanvasText', 'Field', 'FieldText', 'GrayText', 'Highlight', 'HighlightText', 'LinkText', 'Mark', 'MarkText', 'VisitedText', '-webkit-focus-ring-color'].map(m => m.toLowerCase()));
261
270
  // deprecated
262
271
  const deprecatedSystemColors = new Set(['ActiveBorder', 'ActiveCaption', 'AppWorkspace', 'Background', 'ButtonFace', 'ButtonHighlight', 'ButtonShadow', 'ButtonText', 'CaptionText', 'GrayText', 'Highlight', 'HighlightText', 'InactiveBorder', 'InactiveCaption', 'InactiveCaptionText', 'InfoBackground', 'InfoText', 'Menu', 'MenuText', 'Scrollbar', 'ThreeDDarkShadow', 'ThreeDFace', 'ThreeDHighlight', 'ThreeDLightShadow', 'ThreeDShadow', 'Window', 'WindowFrame', 'WindowText'].map(t => t.toLowerCase()));
263
272
  // name to color
@@ -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) {
@@ -13547,7 +13556,8 @@
13547
13556
  }
13548
13557
  context.update(result.context);
13549
13558
  }
13550
- return {
13559
+ // @ts-ignore
13560
+ return result ?? {
13551
13561
  valid: SyntaxValidationResult.Valid,
13552
13562
  node: null,
13553
13563
  syntax: syntaxes[i - 1],
@@ -13689,7 +13699,7 @@
13689
13699
  }
13690
13700
  return {
13691
13701
  valid: SyntaxValidationResult.Drop,
13692
- node: context.next(),
13702
+ node: context.current(),
13693
13703
  syntax,
13694
13704
  error: `expected '${ValidationTokenEnum[syntax.typ].toLowerCase()}', got '${context.done() ? null : renderToken(context.peek())}'`,
13695
13705
  context
@@ -13724,7 +13734,7 @@
13724
13734
  }
13725
13735
  switch (syntax.typ) {
13726
13736
  case ValidationTokenEnum.Keyword:
13727
- success = (token.typ == exports.EnumToken.IdenTokenType || token.typ == exports.EnumToken.DashedIdenTokenType) &&
13737
+ success = (token.typ == exports.EnumToken.IdenTokenType || token.typ == exports.EnumToken.DashedIdenTokenType || isIdentColor(token)) &&
13728
13738
  (token.val == syntax.val ||
13729
13739
  syntax.val.localeCompare(token.val, undefined, { sensitivity: 'base' }) == 0 ||
13730
13740
  // config.declarations.all
@@ -13753,19 +13763,11 @@
13753
13763
  context
13754
13764
  };
13755
13765
  }
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
- }
13766
+ result = match(getParsedSyntax("syntaxes" /* ValidationSyntaxGroupEnum.Syntaxes */, syntax.val + '()')?.[0], context, options);
13767
+ if (result.valid == SyntaxValidationResult.Valid) {
13768
+ context.next();
13769
+ result.context = context;
13770
+ return result;
13769
13771
  }
13770
13772
  break;
13771
13773
  case ValidationTokenEnum.DeclarationType:
@@ -13863,6 +13865,7 @@
13863
13865
  }
13864
13866
  function matchPropertyType(syntax, context, options) {
13865
13867
  if (![
13868
+ 'bg-position',
13866
13869
  'length-percentage', 'flex', 'calc-sum', 'color', 'color-base', 'system-color', 'deprecated-system-color',
13867
13870
  'pseudo-class-selector', 'pseudo-element-selector'
13868
13871
  ].includes(syntax.val)) {
@@ -13892,6 +13895,96 @@
13892
13895
  return { ...result, context };
13893
13896
  }
13894
13897
  switch (syntax.val) {
13898
+ case 'bg-position': {
13899
+ let val;
13900
+ let keyworkMatchCount = 0;
13901
+ let lengthMatchCount = 0;
13902
+ let functionMatchCount = 0;
13903
+ let isBGX = false;
13904
+ let isBGY = false;
13905
+ while (token != null && keyworkMatchCount + lengthMatchCount + functionMatchCount < 3) {
13906
+ // match one value: keyword or length
13907
+ success = (token.typ == exports.EnumToken.FunctionTokenType && wildCardFuncs.includes(token.val));
13908
+ if (success) {
13909
+ functionMatchCount++;
13910
+ context.next();
13911
+ token = context.peek();
13912
+ continue;
13913
+ }
13914
+ if (token.typ == exports.EnumToken.WhitespaceTokenType) {
13915
+ context.next();
13916
+ token = context.peek();
13917
+ continue;
13918
+ }
13919
+ if (token.typ == exports.EnumToken.IdenTokenType) {
13920
+ val = token.val.toLowerCase();
13921
+ success = ['left', 'center', 'right', 'top', 'center', 'bottom'].includes(val);
13922
+ if (!success) {
13923
+ break;
13924
+ }
13925
+ keyworkMatchCount++;
13926
+ if (keyworkMatchCount > 2) {
13927
+ return {
13928
+ valid: SyntaxValidationResult.Drop,
13929
+ node: token,
13930
+ syntax,
13931
+ error: `expected <length-percentage>`,
13932
+ context
13933
+ };
13934
+ }
13935
+ if (val == 'left' || val == 'right') {
13936
+ if (isBGX) {
13937
+ return {
13938
+ valid: SyntaxValidationResult.Drop,
13939
+ node: token,
13940
+ syntax,
13941
+ error: `top | bottom | <length-percentage>`,
13942
+ context
13943
+ };
13944
+ }
13945
+ isBGX = true;
13946
+ }
13947
+ if (val == 'top' || val == 'bottom') {
13948
+ if (isBGY) {
13949
+ return {
13950
+ valid: SyntaxValidationResult.Drop,
13951
+ node: token,
13952
+ syntax,
13953
+ error: `expected left | right | <length-percentage>`,
13954
+ context
13955
+ };
13956
+ }
13957
+ isBGY = true;
13958
+ }
13959
+ context.next();
13960
+ token = context.peek();
13961
+ continue;
13962
+ }
13963
+ success = token.typ == exports.EnumToken.LengthTokenType || token.typ == exports.EnumToken.PercentageTokenType || (token.typ == exports.EnumToken.NumberTokenType && token.val == '0');
13964
+ if (!success) {
13965
+ break;
13966
+ }
13967
+ lengthMatchCount++;
13968
+ context.next();
13969
+ token = context.peek();
13970
+ }
13971
+ if (keyworkMatchCount + lengthMatchCount + functionMatchCount == 0) {
13972
+ return {
13973
+ valid: SyntaxValidationResult.Drop,
13974
+ node: token,
13975
+ syntax,
13976
+ error: `expected <bg-position>`,
13977
+ context
13978
+ };
13979
+ }
13980
+ return {
13981
+ valid: SyntaxValidationResult.Valid,
13982
+ node: token,
13983
+ syntax,
13984
+ error: '',
13985
+ context
13986
+ };
13987
+ }
13895
13988
  case 'calc-sum':
13896
13989
  success = (token.typ == exports.EnumToken.FunctionTokenType && mathFuncs.includes(token.val)) ||
13897
13990
  // @ts-ignore
@@ -13960,8 +14053,8 @@
13960
14053
  case 'number':
13961
14054
  case 'number-token':
13962
14055
  success = token.typ == exports.EnumToken.NumberTokenType;
13963
- if ('range' in syntax) {
13964
- success = success && +token.val >= +syntax.range[0] && +token.val <= +syntax.range[1];
14056
+ if (success && 'range' in syntax) {
14057
+ success = +token.val >= +syntax.range[0] && (syntax.range[1] == null || +token.val <= +syntax.range[1]);
13965
14058
  }
13966
14059
  break;
13967
14060
  case 'angle':
@@ -14018,7 +14111,6 @@
14018
14111
  ['length-percentage', 'length', 'number', 'number-token', 'angle', 'percentage', 'dimension'].includes(syntax.val)) {
14019
14112
  if (!success) {
14020
14113
  success = mathFuncs.includes(token.val.toLowerCase()) &&
14021
- // (token as FunctionToken).val + '()' in config[ValidationSyntaxGroupEnum.Syntaxes] &&
14022
14114
  doEvaluateSyntax(getParsedSyntax("syntaxes" /* ValidationSyntaxGroupEnum.Syntaxes */, token.val + '()')?.[0]?.chi ?? [], createContext(token.chi), {
14023
14115
  ...options,
14024
14116
  isRepeatable: null,
@@ -14099,24 +14191,28 @@
14099
14191
  function allOf(syntax, context, options) {
14100
14192
  let result;
14101
14193
  let i;
14102
- // sort tokens -> wildCard -> last
14103
- // 1px var(...) 2px => 1px 2px var(...)
14104
- const slice = context.slice();
14194
+ let slice = context.slice();
14105
14195
  const vars = [];
14106
14196
  const tokens = [];
14197
+ const repeatable = [];
14198
+ // match optional syntax first
14199
+ // <length>{2,3}&&<color>? => <color>?&&<length>{2,3}
14200
+ for (i = 0; i < syntax.length; i++) {
14201
+ if (syntax[i].length == 1 && syntax[i][0].occurence != null) {
14202
+ repeatable.push(syntax[i]);
14203
+ syntax.splice(i--, 1);
14204
+ }
14205
+ }
14206
+ if (repeatable.length > 0) {
14207
+ syntax.push(...repeatable);
14208
+ }
14209
+ // sort tokens -> wildCard -> last
14210
+ // 1px var(...) 2px => 1px 2px var(...)
14107
14211
  for (i = 0; i < slice.length; i++) {
14108
14212
  if (slice[i].typ == exports.EnumToken.FunctionTokenType && wildCardFuncs.includes(slice[i].val.toLowerCase())) {
14109
14213
  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--;
14214
+ if (slice[i + 1]?.typ == exports.EnumToken.WhitespaceTokenType) {
14215
+ vars.push(slice[++i]);
14120
14216
  }
14121
14217
  continue;
14122
14218
  }
@@ -14130,7 +14226,44 @@
14130
14226
  tokens.push(...vars);
14131
14227
  }
14132
14228
  const con = createContext(tokens);
14229
+ let cp;
14230
+ let j;
14133
14231
  for (i = 0; i < syntax.length; i++) {
14232
+ if (syntax[i].length == 1 && syntax[i][0].isOptional) {
14233
+ syntax[i][0].isOptional = false;
14234
+ j = 0;
14235
+ cp = con.clone();
14236
+ slice = cp.slice();
14237
+ if (cp.done()) {
14238
+ syntax[i][0].isOptional = true;
14239
+ syntax.splice(i, 1);
14240
+ i = -1;
14241
+ continue;
14242
+ }
14243
+ while (!cp.done()) {
14244
+ result = doEvaluateSyntax(syntax[i], cp.clone(), options);
14245
+ if (result.valid == SyntaxValidationResult.Valid) {
14246
+ let end = slice.indexOf(cp.current());
14247
+ if (end == -1) {
14248
+ end = 0;
14249
+ }
14250
+ else {
14251
+ end -= j - 1;
14252
+ }
14253
+ con.consume(slice[j], end < 0 ? 0 : end);
14254
+ break;
14255
+ }
14256
+ cp.next();
14257
+ j++;
14258
+ }
14259
+ syntax[i][0].isOptional = true;
14260
+ // @ts-ignore
14261
+ if (result?.valid == SyntaxValidationResult.Valid) {
14262
+ syntax.splice(i, 1);
14263
+ i = -1;
14264
+ }
14265
+ continue;
14266
+ }
14134
14267
  result = doEvaluateSyntax(syntax[i], con.clone(), options);
14135
14268
  if (result.valid == SyntaxValidationResult.Valid) {
14136
14269
  con.update(result.context);
@@ -16075,11 +16208,13 @@
16075
16208
  const src = options.src;
16076
16209
  const stack = [];
16077
16210
  const stats = {
16211
+ src: options.src ?? '',
16078
16212
  bytesIn: 0,
16079
16213
  importedBytesIn: 0,
16080
16214
  parse: `0ms`,
16081
16215
  minify: `0ms`,
16082
- total: `0ms`
16216
+ total: `0ms`,
16217
+ imports: []
16083
16218
  };
16084
16219
  let ast = {
16085
16220
  typ: exports.EnumToken.StyleSheetNodeType,
@@ -16125,7 +16260,7 @@
16125
16260
  ast.loc.end = item.end;
16126
16261
  }
16127
16262
  if (item.token == ';' || item.token == '{') {
16128
- node = parseNode(tokens, context, stats, options, errors, src, map, rawTokens);
16263
+ node = parseNode(tokens, context, options, errors, src, map, rawTokens);
16129
16264
  rawTokens.length = 0;
16130
16265
  if (node != null) {
16131
16266
  if ('chi' in node) {
@@ -16164,7 +16299,7 @@
16164
16299
  map = new Map;
16165
16300
  }
16166
16301
  else if (item.token == '}') {
16167
- parseNode(tokens, context, stats, options, errors, src, map, rawTokens);
16302
+ parseNode(tokens, context, options, errors, src, map, rawTokens);
16168
16303
  rawTokens.length = 0;
16169
16304
  if (context.loc != null) {
16170
16305
  context.loc.end = item.end;
@@ -16185,7 +16320,7 @@
16185
16320
  }
16186
16321
  }
16187
16322
  if (tokens.length > 0) {
16188
- node = parseNode(tokens, context, stats, options, errors, src, map, rawTokens);
16323
+ node = parseNode(tokens, context, options, errors, src, map, rawTokens);
16189
16324
  rawTokens.length = 0;
16190
16325
  if (node != null) {
16191
16326
  if (node.typ == exports.EnumToken.AtRuleNodeType && node.nam == 'import') {
@@ -16210,7 +16345,6 @@
16210
16345
  const url = token.typ == exports.EnumToken.StringTokenType ? token.val.slice(1, -1) : token.val;
16211
16346
  try {
16212
16347
  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
16348
  return doParse(src, Object.assign({}, options, {
16215
16349
  minify: false,
16216
16350
  setParent: false,
@@ -16218,6 +16352,7 @@
16218
16352
  }));
16219
16353
  });
16220
16354
  stats.importedBytesIn += root.stats.bytesIn;
16355
+ stats.imports.push(root.stats);
16221
16356
  node.parent.chi.splice(node.parent.chi.indexOf(node), 1, ...root.ast.chi);
16222
16357
  if (root.errors.length > 0) {
16223
16358
  errors.push(...root.errors);
@@ -16309,7 +16444,7 @@
16309
16444
  }
16310
16445
  return null;
16311
16446
  }
16312
- function parseNode(results, context, stats, options, errors, src, map, rawTokens) {
16447
+ function parseNode(results, context, options, errors, src, map, rawTokens) {
16313
16448
  let tokens = [];
16314
16449
  for (const t of results) {
16315
16450
  const node = getTokenType(t.token, t.hint);
@@ -16537,9 +16672,11 @@
16537
16672
  removeComments: true
16538
16673
  }), '');
16539
16674
  }
16540
- // }
16541
16675
  context.chi.push(node);
16542
- Object.defineProperties(node, { parent: { ...definedPropertySettings, value: context }, validSyntax: { ...definedPropertySettings, value: valid.valid == SyntaxValidationResult.Valid } });
16676
+ Object.defineProperties(node, {
16677
+ parent: { ...definedPropertySettings, value: context },
16678
+ validSyntax: { ...definedPropertySettings, value: valid.valid == SyntaxValidationResult.Valid }
16679
+ });
16543
16680
  return node;
16544
16681
  }
16545
16682
  else {
@@ -16577,11 +16714,9 @@
16577
16714
  let t = renderToken(curr, { minify: false });
16578
16715
  if (t == ',') {
16579
16716
  acc.push([]);
16580
- // uniqTokens.push([]);
16581
16717
  }
16582
16718
  else {
16583
16719
  acc[acc.length - 1].push(t);
16584
- // uniqTokens[uniqTokens.length - 1].push(curr);
16585
16720
  }
16586
16721
  return acc;
16587
16722
  }, [[]]).reduce((acc, curr) => {
@@ -16613,7 +16748,6 @@
16613
16748
  // @ts-ignore
16614
16749
  context.chi.push(node);
16615
16750
  Object.defineProperty(node, 'parent', { ...definedPropertySettings, value: context });
16616
- // if (options.validation) {
16617
16751
  // @ts-ignore
16618
16752
  const valid = options.validation == exports.ValidationLevel.None ? {
16619
16753
  valid: SyntaxValidationResult.Valid,
@@ -16630,24 +16764,10 @@
16630
16764
  location
16631
16765
  });
16632
16766
  }
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 });
16767
+ Object.defineProperty(node, 'validSyntax', {
16768
+ ...definedPropertySettings,
16769
+ value: valid.valid == SyntaxValidationResult.Valid
16770
+ });
16651
16771
  return node;
16652
16772
  }
16653
16773
  else {
@@ -16697,9 +16817,7 @@
16697
16817
  parseColor(tokens[i]);
16698
16818
  }
16699
16819
  }
16700
- tokens.splice(i, 0, { typ: exports.EnumToken.ColonTokenType });
16701
- // i++;
16702
- i--;
16820
+ tokens.splice(i--, 0, { typ: exports.EnumToken.ColonTokenType });
16703
16821
  continue;
16704
16822
  }
16705
16823
  if ('chi' in tokens[i]) {
@@ -16784,11 +16902,15 @@
16784
16902
  const result = parseDeclarationNode(node, errors, location);
16785
16903
  Object.defineProperty(result, 'parent', { ...definedPropertySettings, value: context });
16786
16904
  if (result != null) {
16787
- // console.error(doRender(result), result.val, location);
16788
16905
  if (options.validation == exports.ValidationLevel.All) {
16789
16906
  const valid = evaluateSyntax(result, options);
16790
- Object.defineProperty(result, 'validSyntax', { ...definedPropertySettings, value: valid.valid == SyntaxValidationResult.Valid });
16907
+ Object.defineProperty(result, 'validSyntax', {
16908
+ ...definedPropertySettings,
16909
+ value: valid.valid == SyntaxValidationResult.Valid
16910
+ });
16791
16911
  if (valid.valid == SyntaxValidationResult.Drop) {
16912
+ // console.error({result, valid});
16913
+ // console.error(JSON.stringify({result, options, valid}, null, 1));
16792
16914
  errors.push({
16793
16915
  action: 'drop',
16794
16916
  message: valid.error,
@@ -17582,12 +17704,6 @@
17582
17704
  if (t.chi[0].val.slice(1, 5) != 'data:' && urlTokenMatcher.test(value)) {
17583
17705
  // @ts-ignore
17584
17706
  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
17707
  // @ts-ignore
17592
17708
  t.chi[0].val = options.src !== '' && options.resolveUrls ? options.resolve(value, options.src).absolute : value;
17593
17709
  }
@@ -20923,8 +21039,7 @@
20923
21039
  }
20924
21040
  let rule = selector.map(s => {
20925
21041
  if (s[0] == '&') {
20926
- // @ts-ignore
20927
- s[0] = node.optimized.optimized[0];
21042
+ s.splice(0, 1, ...node.optimized.optimized);
20928
21043
  }
20929
21044
  return s.join('');
20930
21045
  }).join(',');