@projectwallace/css-analyzer 7.5.0 → 7.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import $t from "css-tree/parser";
2
- import q from "css-tree/walker";
3
- import { calculateForAST as ei } from "@bramus/specificity/core";
1
+ import ei from "css-tree/parser";
2
+ import v from "css-tree/walker";
3
+ import { calculateForAST as ti } from "@bramus/specificity/core";
4
4
  function He(r, t) {
5
5
  return t >= 65 && t <= 90 && (t = t | 32), r === t;
6
6
  }
@@ -23,7 +23,7 @@ function O(r, t) {
23
23
  return !1;
24
24
  return !0;
25
25
  }
26
- function We(r, t) {
26
+ function Ke(r, t) {
27
27
  if (r === t) return !0;
28
28
  let s = r.length;
29
29
  if (t.length < s) return !1;
@@ -32,24 +32,24 @@ function We(r, t) {
32
32
  return !1;
33
33
  return !0;
34
34
  }
35
- const Te = "Atrule", ti = "MediaQuery", Me = "Rule", Ke = "Selector", Kt = "TypeSelector", G = "PseudoClassSelector", Nt = "AttributeSelector", jt = "PseudoElementSelector", Ve = "Declaration", ii = "Value", R = "Identifier", ri = "Nth", si = "Combinator", Bt = "Number", Ne = "Dimension", W = "Operator", li = "Hash", ni = "Url", je = "Function";
36
- function It(r, t, s) {
35
+ const Te = "Atrule", ii = "MediaQuery", Me = "Rule", We = "Selector", Nt = "TypeSelector", G = "PseudoClassSelector", jt = "AttributeSelector", Bt = "PseudoElementSelector", Ve = "Declaration", ri = "Value", R = "Identifier", si = "Nth", li = "Combinator", Yt = "Number", Ne = "Dimension", K = "Operator", ni = "Hash", ai = "Url", je = "Function";
36
+ function Ut(r, t, s) {
37
37
  let e = r.value.children.first;
38
38
  return S(t, r.property) && e.type === R && S(s, e.name);
39
39
  }
40
- function ai(r) {
40
+ function oi(r) {
41
41
  let t = !1;
42
- return q(r, function(s) {
43
- if (s.type === Ve && (It(s, "-webkit-appearance", "none") || It(s, "-moz-appearance", "meterbar")))
42
+ return v(r, function(s) {
43
+ if (s.type === Ve && (Ut(s, "-webkit-appearance", "none") || Ut(s, "-moz-appearance", "meterbar")))
44
44
  return t = !0, this.break;
45
45
  }), t;
46
46
  }
47
- function oi(r) {
47
+ function ui(r) {
48
48
  let t = !1;
49
- return q(r, function(s) {
49
+ return v(r, function(s) {
50
50
  let e = s.name, n = s.value;
51
- if (s.type === ti && s.mediaType !== null) {
52
- if (We("\\0", s.mediaType) || O("\\9 ", s.mediaType))
51
+ if (s.type === ii && s.mediaType !== null) {
52
+ if (Ke("\\0", s.mediaType) || O("\\9 ", s.mediaType))
53
53
  return t = !0, this.break;
54
54
  } else if (s.type === "Feature" && s.kind === "media") {
55
55
  if (n && n.unit && n.unit === "\\0")
@@ -63,12 +63,12 @@ function oi(r) {
63
63
  }
64
64
  }), t;
65
65
  }
66
- const Ut = 45;
67
- function F(r) {
68
- return r.charCodeAt(0) === Ut && r.charCodeAt(1) !== Ut && r.indexOf("-", 2) !== -1;
66
+ const Vt = 45;
67
+ function E(r) {
68
+ return r.charCodeAt(0) === Vt && r.charCodeAt(1) !== Vt && r.indexOf("-", 2) !== -1;
69
69
  }
70
70
  class A {
71
- /** @param {string[]} items */
71
+ /** @param {Lowercase<string>[]} items */
72
72
  constructor(t) {
73
73
  this.set = new Set(t);
74
74
  }
@@ -77,16 +77,16 @@ class A {
77
77
  return this.set.has(t.toLowerCase());
78
78
  }
79
79
  }
80
- function Yt(r, t) {
80
+ function Gt(r, t) {
81
81
  let s = [];
82
- return q(r, {
83
- visit: Ke,
82
+ return v(r, {
83
+ visit: We,
84
84
  enter: function(e) {
85
85
  s.push(t(e));
86
86
  }
87
87
  }), s;
88
88
  }
89
- const Gt = new A([
89
+ const Qt = new A([
90
90
  "nth-child",
91
91
  "where",
92
92
  "not",
@@ -97,15 +97,15 @@ const Gt = new A([
97
97
  "-webkit-any",
98
98
  "-moz-any"
99
99
  ]);
100
- function Qt(r) {
100
+ function Zt(r) {
101
101
  let t = !1;
102
- return q(r, function(s) {
103
- if (s.type === Nt) {
102
+ return v(r, function(s) {
103
+ if (s.type === jt) {
104
104
  let e = s.name.name;
105
- if (S("role", e) || We("aria-", e))
105
+ if (S("role", e) || Ke("aria-", e))
106
106
  return t = !0, this.break;
107
- } else if (s.type === G && Gt.has(s.name)) {
108
- let e = Yt(s, Qt);
107
+ } else if (s.type === G && Qt.has(s.name)) {
108
+ let e = Gt(s, Zt);
109
109
  for (let n of e)
110
110
  if (n === !0) {
111
111
  t = !0;
@@ -115,29 +115,29 @@ function Qt(r) {
115
115
  }
116
116
  }), t;
117
117
  }
118
- function ui(r) {
118
+ function ci(r) {
119
119
  let t = !1;
120
- return q(r, function(s) {
120
+ return v(r, function(s) {
121
121
  let e = s.type;
122
- if ((e === jt || e === Kt || e === G) && F(s.name))
122
+ if ((e === Bt || e === Nt || e === G) && E(s.name))
123
123
  return t = !0, this.break;
124
124
  }), t;
125
125
  }
126
- function ci(r) {
126
+ function fi(r) {
127
127
  let t = [];
128
- return q(r, function(s) {
128
+ return v(r, function(s) {
129
129
  s.type === G && t.push(s.name);
130
130
  }), t.length === 0 ? !1 : t;
131
131
  }
132
- function Zt(r) {
132
+ function Jt(r) {
133
133
  let t = 0;
134
- return q(r, function(s) {
134
+ return v(r, function(s) {
135
135
  let e = s.type;
136
- if (!(e === Ke || e === ri)) {
137
- if (t++, (e === jt || e === Kt || e === G) && F(s.name) && t++, e === Nt)
136
+ if (!(e === We || e === si)) {
137
+ if (t++, (e === Bt || e === Nt || e === G) && E(s.name) && t++, e === jt)
138
138
  return s.value && t++, this.skip;
139
- if (e === G && Gt.has(s.name)) {
140
- let n = Yt(s, Zt);
139
+ if (e === G && Qt.has(s.name)) {
140
+ let n = Gt(s, Jt);
141
141
  if (n.length === 0) return;
142
142
  for (let a of n)
143
143
  t += a;
@@ -146,12 +146,12 @@ function Zt(r) {
146
146
  }
147
147
  }), t;
148
148
  }
149
- function fi(r, t) {
150
- q(r, function(s, e) {
151
- if (s.type === si) {
149
+ function pi(r, t) {
150
+ v(r, function(s, e) {
151
+ if (s.type === li) {
152
152
  let n = s.loc, a = s.name;
153
153
  if (n === null) {
154
- let y = e.prev.data.loc.end, k = {
154
+ let y = e.prev.data.loc.end, b = {
155
155
  offset: y.offset,
156
156
  line: y.line,
157
157
  column: y.column
@@ -159,11 +159,11 @@ function fi(r, t) {
159
159
  t({
160
160
  name: a,
161
161
  loc: {
162
- start: k,
162
+ start: b,
163
163
  end: {
164
- offset: k.offset + 1,
165
- line: k.line,
166
- column: k.column + 1
164
+ offset: b.offset + 1,
165
+ line: b.line,
166
+ column: b.column + 1
167
167
  }
168
168
  }
169
169
  });
@@ -175,7 +175,7 @@ function fi(r, t) {
175
175
  }
176
176
  });
177
177
  }
178
- const pi = new A([
178
+ const hi = new A([
179
179
  // CSS Named Colors
180
180
  // Spec: https://drafts.csswg.org/css-color/#named-colors
181
181
  // Heuristic: popular names first for quick finding in set.has()
@@ -328,7 +328,7 @@ const pi = new A([
328
328
  "mediumorchid",
329
329
  "darksalmon",
330
330
  "mediumspringgreen"
331
- ]), hi = new A([
331
+ ]), mi = new A([
332
332
  // CSS System Colors
333
333
  // Spec: https://drafts.csswg.org/css-color/#css-system-colors
334
334
  "accentcolor",
@@ -350,7 +350,7 @@ const pi = new A([
350
350
  "selecteditem",
351
351
  "selecteditemtext",
352
352
  "visitedtext"
353
- ]), mi = new A([
353
+ ]), gi = new A([
354
354
  "rgba",
355
355
  "rgb",
356
356
  "hsla",
@@ -361,7 +361,7 @@ const pi = new A([
361
361
  "lch",
362
362
  "lab",
363
363
  "oklab"
364
- ]), gi = new A([
364
+ ]), di = new A([
365
365
  "transparent",
366
366
  "currentcolor"
367
367
  ]), ie = new A([
@@ -380,23 +380,23 @@ function te(r) {
380
380
  let e = t.first;
381
381
  return e.type === R && ie.has(e.name);
382
382
  }
383
- function Vt(r) {
383
+ function Ht(r) {
384
384
  return parseFloat(r) === 0;
385
385
  }
386
- function di(r) {
386
+ function yi(r) {
387
387
  for (let t of r.children.toArray())
388
- if (!(t.type === Bt && Vt(t.value)) && !(t.type === Ne && Vt(t.value)))
388
+ if (!(t.type === Yt && Ht(t.value)) && !(t.type === Ne && Ht(t.value)))
389
389
  return !1;
390
390
  return !0;
391
391
  }
392
- const yi = new A([
392
+ const wi = new A([
393
393
  "caption",
394
394
  "icon",
395
395
  "menu",
396
396
  "message-box",
397
397
  "small-caption",
398
398
  "status-bar"
399
- ]), wi = new A([
399
+ ]), ki = new A([
400
400
  /* <absolute-size> values */
401
401
  "xx-small",
402
402
  "x-small",
@@ -409,39 +409,41 @@ const yi = new A([
409
409
  /* <relative-size> values */
410
410
  "smaller",
411
411
  "larger"
412
- ]), bi = 44, Ht = 47;
412
+ ]), bi = 44, Kt = 47;
413
413
  function Ie(r) {
414
414
  let t = r.children.first;
415
- return t === null ? !1 : t.type === R && yi.has(t.name);
415
+ return t === null ? !1 : t.type === R && wi.has(t.name);
416
416
  }
417
- function ki(r, t, s) {
418
- var k;
419
- let e = Array.from({ length: 2 }), n, a;
417
+ function xi(r, t, s) {
418
+ var b;
419
+ let e = [,], n, a;
420
+ if (r.children.first.type === "Function" && r.children.first.name.toLowerCase() === "var")
421
+ return null;
420
422
  r.children.forEach(function(w, _) {
421
- let b = _.prev ? _.prev.data : void 0, P = _.next ? _.next.data : void 0;
423
+ let k = _.prev ? _.prev.data : void 0, P = _.next ? _.next.data : void 0;
422
424
  if (w.type === R && ie.has(w.name) && s({
423
425
  type: "keyword",
424
426
  value: w.name
425
- }), P && P.type === W && P.value.charCodeAt(0) === Ht) {
427
+ }), P && P.type === K && P.value.charCodeAt(0) === Kt) {
426
428
  n = t(w);
427
429
  return;
428
430
  }
429
- if (b && b.type === W && b.value.charCodeAt(0) === Ht) {
431
+ if (k && k.type === K && k.value.charCodeAt(0) === Kt) {
430
432
  a = t(w);
431
433
  return;
432
434
  }
433
- if (P && P.type === W && P.value.charCodeAt(0) === bi && !e[0]) {
434
- e[0] = w, !n && b && (n = t(b));
435
+ if (P && P.type === K && P.value.charCodeAt(0) === bi && !e[0]) {
436
+ e[0] = w, !n && k && (n = t(k));
435
437
  return;
436
438
  }
437
- if (w.type !== Bt) {
439
+ if (w.type !== Yt) {
438
440
  if (_.next === null) {
439
- e[1] = w, !n && !e[0] && b && (n = t(b));
441
+ e[1] = w, !n && !e[0] && k && (n = t(k));
440
442
  return;
441
443
  }
442
444
  if (w.type === R) {
443
445
  let D = w.name;
444
- if (wi.has(D)) {
446
+ if (ki.has(D)) {
445
447
  n = D;
446
448
  return;
447
449
  }
@@ -456,7 +458,7 @@ function ki(r, t, s) {
456
458
  end: {
457
459
  // Either the node we detected as the last node, or the end of the whole value
458
460
  // It's never 0 because the first node is always a font-size or font-style
459
- offset: ((k = e[1]) == null ? void 0 : k.loc.end.offset) || r.loc.end.offset
461
+ offset: ((b = e[1]) == null ? void 0 : b.loc.end.offset) || r.loc.end.offset
460
462
  }
461
463
  }
462
464
  }) : null;
@@ -466,7 +468,7 @@ function ki(r, t, s) {
466
468
  font_family: y
467
469
  };
468
470
  }
469
- const xi = new A([
471
+ const Ci = new A([
470
472
  "linear",
471
473
  "ease",
472
474
  "ease-in",
@@ -474,36 +476,36 @@ const xi = new A([
474
476
  "ease-in-out",
475
477
  "step-start",
476
478
  "step-end"
477
- ]), Ci = new A([
479
+ ]), zi = new A([
478
480
  "cubic-bezier",
479
481
  "steps"
480
482
  ]);
481
- function zi(r, t) {
483
+ function Si(r, t) {
482
484
  let s = !1;
483
485
  for (let e of r) {
484
486
  let n = e.type, a = e.name;
485
- n === W ? s = !1 : n === Ne && s === !1 ? (s = !0, t({
487
+ n === K ? s = !1 : n === Ne && s === !1 ? (s = !0, t({
486
488
  type: "duration",
487
489
  value: e
488
- })) : n === R ? xi.has(a) ? t({
490
+ })) : n === R ? Ci.has(a) ? t({
489
491
  type: "fn",
490
492
  value: e
491
493
  }) : ie.has(a) && t({
492
494
  type: "keyword",
493
495
  value: e
494
- }) : n === je && Ci.has(a) && t({
496
+ }) : n === je && zi.has(a) && t({
495
497
  type: "fn",
496
498
  value: e
497
499
  });
498
500
  }
499
501
  }
500
- function Jt(r) {
502
+ function Xt(r) {
501
503
  let t = r.children;
502
504
  if (!t)
503
505
  return !1;
504
506
  for (let s of t) {
505
507
  let { type: e, name: n } = s;
506
- if (e === R && F(n) || e === je && (F(n) || Jt(s)))
508
+ if (e === R && E(n) || e === je && (E(n) || Xt(s)))
507
509
  return !0;
508
510
  }
509
511
  return !1;
@@ -552,7 +554,7 @@ class o {
552
554
  */
553
555
  c() {
554
556
  let t = /* @__PURE__ */ new Map(), s = {}, e = this._useLocations, n = this._items, a = this._nodes, y = n.size;
555
- n.forEach((_, b) => {
557
+ n.forEach((_, k) => {
556
558
  if (e) {
557
559
  let P = _.map(function(D) {
558
560
  let T = D * 4;
@@ -563,15 +565,15 @@ class o {
563
565
  length: a[T + 3]
564
566
  };
565
567
  });
566
- t.set(b, P);
568
+ t.set(k, P);
567
569
  } else
568
- s[b] = _.length;
570
+ s[k] = _.length;
569
571
  });
570
- let k = this._total, w = {
571
- total: k,
572
+ let b = this._total, w = {
573
+ total: b,
572
574
  totalUnique: y,
573
575
  unique: s,
574
- uniquenessRatio: k === 0 ? 0 : y / k
576
+ uniquenessRatio: b === 0 ? 0 : y / b
575
577
  };
576
578
  return e && (w.uniqueWithLocations = Object.fromEntries(t)), w;
577
579
  }
@@ -599,11 +601,11 @@ class Ue {
599
601
  });
600
602
  }
601
603
  }
602
- function Si(r) {
604
+ function _i(r) {
603
605
  let t = /* @__PURE__ */ new Map(), s = -1, e = 0, n = 0, a = r.length;
604
606
  for (let y = 0; y < a; y++) {
605
- let k = r[y], w = (t.get(k) || 0) + 1;
606
- t.set(k, w), w > s && (s = w, e = 0, n = 0), w >= s && (e++, n += k);
607
+ let b = r[y], w = (t.get(b) || 0) + 1;
608
+ t.set(b, w), w > s && (s = w, e = 0, n = 0), w >= s && (e++, n += b);
607
609
  }
608
610
  return n / e;
609
611
  }
@@ -632,7 +634,7 @@ class C {
632
634
  range: 0,
633
635
  sum: 0
634
636
  };
635
- let s = this._items.slice().sort((k, w) => k - w), e = s[0], n = s[t - 1], a = Si(s), y = this._sum;
637
+ let s = this._items.slice().sort((b, w) => b - w), e = s[0], n = s[t - 1], a = _i(s), y = this._sum;
636
638
  return {
637
639
  min: e,
638
640
  max: n,
@@ -649,8 +651,8 @@ class C {
649
651
  return this._items;
650
652
  }
651
653
  }
652
- function _i(r) {
653
- if (Be(r) || F(r)) return !1;
654
+ function qi(r) {
655
+ if (Be(r) || E(r)) return !1;
654
656
  let t = r.charCodeAt(0);
655
657
  return t === 47 || t === 42 || t === 95 || t === 43 || t === 38 || t === 36 || t === 35;
656
658
  }
@@ -661,13 +663,13 @@ function m(r, t) {
661
663
  return Be(t) ? !1 : O(r, t);
662
664
  }
663
665
  function vi(r) {
664
- return F(r) ? r.slice(r.indexOf("-", 2) + 1) : r;
666
+ return E(r) ? r.slice(r.indexOf("-", 2) + 1) : r;
665
667
  }
666
- function qi(r) {
668
+ function Ai(r) {
667
669
  let t = 5, s = r.indexOf(";"), e = r.indexOf(",");
668
670
  return s === -1 || e !== -1 && e < s ? r.substring(t, e) : r.substring(t, s);
669
671
  }
670
- function Ai(r) {
672
+ function Pi(r) {
671
673
  let t = r.children;
672
674
  if (t) {
673
675
  let s = t.last;
@@ -675,7 +677,7 @@ function Ai(r) {
675
677
  }
676
678
  return !1;
677
679
  }
678
- let Pi = new A([
680
+ let Li = new A([
679
681
  "border-radius",
680
682
  "border-top-left-radius",
681
683
  "border-top-right-radius",
@@ -689,11 +691,11 @@ let Pi = new A([
689
691
  function z(r, t) {
690
692
  return t === 0 ? 0 : r / t;
691
693
  }
692
- let Li = {
694
+ let Oi = {
693
695
  useLocations: !1
694
696
  };
695
697
  function Ei(r, t = {}) {
696
- let e = Object.assign({}, Li, t).useLocations === !0, n = Date.now();
698
+ let e = Object.assign({}, Oi, t).useLocations === !0, n = Date.now();
697
699
  function a(i) {
698
700
  return y(i).trim();
699
701
  }
@@ -701,21 +703,21 @@ function Ei(r, t = {}) {
701
703
  let Y = i.loc;
702
704
  return r.substring(Y.start.offset, Y.end.offset);
703
705
  }
704
- let k = 0, w = 0, _ = 0, b = {
706
+ let b = 0, w = 0, _ = 0, k = {
705
707
  total: 0,
706
708
  /** @type {Map<string, { size: number, count: number } & ({ uniqueWithLocations?: undefined } | ({ uniqueWithLocations: { offset: number, line: number, column: number, length: number }[] })) }>} */
707
709
  unique: /* @__PURE__ */ new Map()
708
- }, P = Date.now(), D = $t(r, {
710
+ }, P = Date.now(), D = ei(r, {
709
711
  parseCustomProperty: !0,
710
712
  // To find font-families, colors, etc.
711
713
  positions: !0,
712
714
  // So we can use stringifyNode()
713
715
  /** @param {string} comment */
714
716
  onComment: function(i) {
715
- k++, w += i.length;
717
+ b++, w += i.length;
716
718
  }
717
- }), T = Date.now(), Xt = D.loc.end.line - D.loc.start.line + 1, Ye = new o(e), re = new C(), se = [], Ge = new o(e), le = new o(e), Qe = new o(e), Ze = new o(e), Je = new o(e), Xe = new o(e), $e = new o(e), ne = new o(e), et = new o(e), ae = new o(e), oe = new o(e), tt = new o(e), Q = new o(e), it = new o(e), ue = new C(), rt = new o(e), ce = 0, fe = 0, pe = new C(), he = new C(), me = new C(), st = new o(e), lt = new o(e), nt = new o(e), ge = new C(), at = new o(e), de = new o(e), ot = /* @__PURE__ */ new Set(), ye = new o(e), M, I, ut = new C(), ct = new C(), ft = new C(), pt = new o(e), Z = new C(), ht = new o(e), mt = [], we = new o(e), be = new o(e), gt = new o(e), dt = new o(e), ke = new C(), yt = new o(e), wt = /* @__PURE__ */ new Set(), K = 0, bt = new C(), J = 0, xe = 0, Ce = new o(e), ze = new C(), kt = new o(e), N = new o(e), Se = new o(e), _e = new o(e), X = new o(e), j = new C(), ve = new C(), xt = new o(e), qe = new o(e), Ct = new o(e), zt = new o(e), St = new o(e), Ae = new o(e), Pe = new o(e), Le = new o(e), $ = new o(e), ee = new o(e), U = new Ue(e), V = new o(e), Oe = new Ue(e), _t = new o(e), B = new o(e), vt = new Ue(e), qt = new o(e), L = 0;
718
- q(D, {
719
+ }), T = Date.now(), $t = D.loc.end.line - D.loc.start.line + 1, Ye = new o(e), re = new C(), se = [], Ge = new o(e), le = new o(e), Qe = new o(e), Ze = new o(e), Je = new o(e), Xe = new o(e), $e = new o(e), ne = new o(e), et = new o(e), ae = new o(e), oe = new o(e), tt = new o(e), Q = new o(e), it = new o(e), ue = new C(), rt = new o(e), ce = 0, fe = 0, pe = new C(), he = new C(), me = new C(), st = new o(e), lt = new o(e), nt = new o(e), ge = new C(), at = new o(e), de = new o(e), ot = /* @__PURE__ */ new Set(), ye = new o(e), M, I, ut = new C(), ct = new C(), ft = new C(), pt = new o(e), Z = new C(), ht = new o(e), mt = [], we = new o(e), ke = new o(e), gt = new o(e), dt = new o(e), be = new C(), yt = new o(e), wt = /* @__PURE__ */ new Set(), W = 0, kt = new C(), J = 0, xe = 0, Ce = new o(e), ze = new C(), bt = new o(e), N = new o(e), Se = new o(e), _e = new o(e), X = new o(e), j = new C(), qe = new C(), xt = new o(e), ve = new o(e), Ct = new o(e), zt = new o(e), St = new o(e), Ae = new o(e), Pe = new o(e), Le = new o(e), $ = new o(e), ee = new o(e), U = new Ue(e), V = new o(e), Oe = new Ue(e), _t = new o(e), B = new o(e), qt = new Ue(e), vt = new o(e), L = 0;
720
+ v(D, {
719
721
  enter(i) {
720
722
  var Y, Mt;
721
723
  switch (i.type) {
@@ -733,14 +735,14 @@ function Ei(r, t = {}) {
733
735
  if (i.prelude !== null) {
734
736
  let g = i.prelude, c = g && a(i.prelude), f = g.loc;
735
737
  if (p === "media")
736
- Ze.p(c, f), oi(g) && (Je.p(c, f), l++);
738
+ Ze.p(c, f), ui(g) && (Je.p(c, f), l++);
737
739
  else if (p === "supports")
738
- ne.p(c, f), ai(g) && (et.p(c, f), l++);
740
+ ne.p(c, f), oi(g) && (et.p(c, f), l++);
739
741
  else if (O("keyframes", p)) {
740
742
  let u = "@" + p + " " + c;
741
- F(p) && (oe.p(u, f), l++), ae.p(u, f);
743
+ E(p) && (oe.p(u, f), l++), ae.p(u, f);
742
744
  } else if (p === "import")
743
- q(i, function(u) {
745
+ v(i, function(u) {
744
746
  if (u.type === "Condition" && u.kind === "supports") {
745
747
  let h = a(u);
746
748
  return ne.p(h, u.loc), this.break;
@@ -772,20 +774,20 @@ function Ei(r, t = {}) {
772
774
  pe.push(f + u), st.p(f + u, i.loc), he.push(f), lt.p(f, p.loc), me.push(u), nt.p(u, l.loc), ge.push(L), at.p(L, i.loc), ce++, u === 0 && fe++;
773
775
  break;
774
776
  }
775
- case Ke: {
777
+ case We: {
776
778
  let p = a(i);
777
779
  if (this.atrule && O("keyframes", this.atrule.name))
778
780
  return de.p(p, i.loc), this.skip;
779
- Qt(i) && be.p(p, i.loc);
780
- let l = ci(i);
781
+ Zt(i) && ke.p(p, i.loc);
782
+ let l = fi(i);
781
783
  if (l !== !1)
782
784
  for (let x of l)
783
785
  gt.p(x, i.loc);
784
- let g = Zt(i);
785
- ui(i) && ye.p(p, i.loc), ot.add(p), Z.push(g), ht.p(g, i.loc), ke.push(L - 1), yt.p(L - 1, i.loc);
786
- let c = ei(i).toArray(), [f, u, h] = c;
787
- return pt.p(c.toString(), i.loc), ut.push(f), ct.push(u), ft.push(h), M === void 0 && (M = c), I === void 0 && (I = c), I !== void 0 && Wt(I, c) < 0 && (I = c), M !== void 0 && Wt(M, c) > 0 && (M = c), mt.push(c), f > 0 && we.p(p, i.loc), fi(i, function(v) {
788
- dt.p(v.name, v.loc);
786
+ let g = Jt(i);
787
+ ci(i) && ye.p(p, i.loc), ot.add(p), Z.push(g), ht.p(g, i.loc), be.push(L - 1), yt.p(L - 1, i.loc);
788
+ let c = ti(i).toArray(), [f, u, h] = c;
789
+ return pt.p(c.toString(), i.loc), ut.push(f), ct.push(u), ft.push(h), M === void 0 && (M = c), I === void 0 && (I = c), I !== void 0 && Wt(I, c) < 0 && (I = c), M !== void 0 && Wt(M, c) > 0 && (M = c), mt.push(c), f > 0 && we.p(p, i.loc), pi(i, function(q) {
790
+ dt.p(q.name, q.loc);
789
791
  }), this.skip;
790
792
  }
791
793
  case Ne: {
@@ -794,10 +796,10 @@ function Ei(r, t = {}) {
794
796
  let p = i.unit;
795
797
  return O("\\9", p) ? Oe.push(p.substring(0, p.length - 2), this.declaration.property, i.loc) : Oe.push(p, this.declaration.property, i.loc), this.skip;
796
798
  }
797
- case ni: {
798
- if (We("data:", i.value)) {
799
- let p = i.value, l = p.length, g = qi(p);
800
- b.total++, _ += l;
799
+ case ai: {
800
+ if (Ke("data:", i.value)) {
801
+ let p = i.value, l = p.length, g = Ai(p);
802
+ k.total++, _ += l;
801
803
  let c = {
802
804
  /** @type {number} */
803
805
  line: i.loc.start.line,
@@ -808,38 +810,41 @@ function Ei(r, t = {}) {
808
810
  /** @type {number} */
809
811
  length: i.loc.end.offset - i.loc.start.offset
810
812
  };
811
- if (b.unique.has(g)) {
812
- let f = b.unique.get(g);
813
- f.count++, f.size += l, b.unique.set(g, f), e && f.uniqueWithLocations.push(c);
813
+ if (k.unique.has(g)) {
814
+ let f = k.unique.get(g);
815
+ f.count++, f.size += l, k.unique.set(g, f), e && f.uniqueWithLocations.push(c);
814
816
  } else {
815
817
  let f = {
816
818
  count: 1,
817
819
  size: l
818
820
  };
819
- e && (f.uniqueWithLocations = [c]), b.unique.set(g, f);
821
+ e && (f.uniqueWithLocations = [c]), k.unique.set(g, f);
820
822
  }
821
823
  }
822
824
  break;
823
825
  }
824
- case ii: {
826
+ case ri: {
825
827
  if (te(i)) {
826
- ve.push(1), B.p(a(i), i.loc);
828
+ qe.push(1), B.p(a(i), i.loc);
827
829
  break;
828
830
  }
829
831
  let p = this.declaration, { property: l, important: g } = p, c = 1;
830
- Jt(i) && (xt.p(a(i), i.loc), c++), typeof g == "string" && (qe.p(y(i) + "!" + g, i.loc), c++), Ai(i) && (qe.p(a(i), i.loc), c++);
832
+ Xt(i) && (xt.p(a(i), i.loc), c++), typeof g == "string" && (ve.p(y(i) + "!" + g, i.loc), c++), Pi(i) && (ve.p(a(i), i.loc), c++);
831
833
  let f = i.children, u = i.loc;
832
- if (ve.push(c), m("margin", l) || m("margin-block", l) || m("margin-inline", l) || m("margin-top", l) || m("margin-right", l) || m("margin-bottom", l) || m("margin-left", l) || m("padding", l) || m("padding-block", l) || m("padding-inline", l) || m("padding-top", l) || m("padding-right", l) || m("padding-bottom", l) || m("padding-left", l))
833
- di(i) && qt.p(l, p.loc);
834
+ if (qe.push(c), m("margin", l) || m("margin-block", l) || m("margin-inline", l) || m("margin-top", l) || m("margin-right", l) || m("margin-bottom", l) || m("margin-left", l) || m("padding", l) || m("padding-block", l) || m("padding-inline", l) || m("padding-top", l) || m("padding-right", l) || m("padding-bottom", l) || m("padding-left", l))
835
+ yi(i) && vt.p(l, p.loc);
834
836
  else {
835
837
  if (m("z-index", l))
836
838
  return Ct.p(a(i), u), this.skip;
837
839
  if (m("font", l)) {
838
840
  if (Ie(i)) return;
839
- let { font_size: h, line_height: x, font_family: v } = ki(i, a, function(E) {
840
- E.type === "keyword" && B.p(E.value, u);
841
+ let h = xi(i, a, function(It) {
842
+ It.type === "keyword" && B.p(It.value, u);
841
843
  });
842
- v && Ae.p(v, u), h && Pe.p(h, u), x && Le.p(x, u);
844
+ if (!h)
845
+ return this.skip;
846
+ let { font_size: x, line_height: q, font_family: F } = h;
847
+ F && Ae.p(F, u), x && Pe.p(x, u), q && Le.p(q, u);
843
848
  break;
844
849
  } else if (m("font-size", l)) {
845
850
  Ie(i) || Pe.p(a(i), u);
@@ -850,54 +855,54 @@ function Ei(r, t = {}) {
850
855
  } else if (m("line-height", l))
851
856
  Le.p(a(i), u);
852
857
  else if (m("transition", l) || m("animation", l)) {
853
- zi(f, function(h) {
858
+ Si(f, function(h) {
854
859
  h.type === "fn" ? $.p(a(h.value), u) : h.type === "duration" ? ee.p(a(h.value), u) : h.type === "keyword" && B.p(a(h.value), u);
855
860
  });
856
861
  break;
857
862
  } else if (m("animation-duration", l) || m("transition-duration", l)) {
858
863
  f && f.size > 1 ? f.forEach((h) => {
859
- h.type !== W && ee.p(a(h), u);
864
+ h.type !== K && ee.p(a(h), u);
860
865
  }) : ee.p(a(i), u);
861
866
  break;
862
867
  } else if (m("transition-timing-function", l) || m("animation-timing-function", l)) {
863
868
  f && f.size > 1 ? f.forEach((h) => {
864
- h.type !== W && $.p(a(h), u);
869
+ h.type !== K && $.p(a(h), u);
865
870
  }) : $.p(a(i), u);
866
871
  break;
867
872
  } else if (m("container-name", l))
868
873
  Q.p(a(i), u);
869
874
  else if (m("container", l))
870
875
  ((Mt = f.first) == null ? void 0 : Mt.type) === "Identifier" && Q.p(f.first.name, u);
871
- else if (Pi.has(vi(l))) {
872
- te(i) || vt.push(a(i), l, u);
876
+ else if (Li.has(vi(l))) {
877
+ te(i) || qt.push(a(i), l, u);
873
878
  break;
874
879
  } else m("text-shadow", l) ? te(i) || zt.p(a(i), u) : m("box-shadow", l) && (te(i) || St.p(a(i), u));
875
880
  }
876
- q(i, function(h) {
881
+ v(i, function(h) {
877
882
  let x = h.name;
878
883
  switch (h.type) {
879
- case li: {
880
- let v = h.value.length;
881
- return O("\\9", h.value) && (v = v - 2), U.push("#" + h.value, l, u), V.p("hex" + v, u), this.skip;
884
+ case ni: {
885
+ let q = h.value.length;
886
+ return O("\\9", h.value) && (q = q - 2), U.push("#" + h.value, l, u), V.p("hex" + q, u), this.skip;
882
887
  }
883
888
  case R: {
884
889
  ie.has(x) && B.p(x, u);
885
- let v = x.length;
886
- if (v > 20 || v < 3)
890
+ let q = x.length;
891
+ if (q > 20 || q < 3)
887
892
  return this.skip;
888
- if (gi.has(x)) {
889
- let E = a(h);
890
- U.push(E, l, u), V.p(x.toLowerCase(), u);
893
+ if (di.has(x)) {
894
+ let F = a(h);
895
+ U.push(F, l, u), V.p(x.toLowerCase(), u);
891
896
  return;
892
897
  }
893
- if (pi.has(x)) {
894
- let E = a(h);
895
- U.push(E, l, u), V.p("named", u);
898
+ if (hi.has(x)) {
899
+ let F = a(h);
900
+ U.push(F, l, u), V.p("named", u);
896
901
  return;
897
902
  }
898
- if (hi.has(x)) {
899
- let E = a(h);
900
- U.push(E, l, u), V.p("system", u);
903
+ if (mi.has(x)) {
904
+ let F = a(h);
905
+ U.push(F, l, u), V.p("system", u);
901
906
  return;
902
907
  }
903
908
  return this.skip;
@@ -905,7 +910,7 @@ function Ei(r, t = {}) {
905
910
  case je: {
906
911
  if (S("var", x))
907
912
  return this.skip;
908
- if (mi.has(x)) {
913
+ if (gi.has(x)) {
909
914
  U.push(a(h), l, h.loc), V.p(x.toLowerCase(), h.loc);
910
915
  return;
911
916
  }
@@ -921,9 +926,9 @@ function Ei(r, t = {}) {
921
926
  case Ve: {
922
927
  if (this.atrulePrelude !== null)
923
928
  return this.skip;
924
- K++;
929
+ W++;
925
930
  let p = 1;
926
- wt.add(a(i)), ze.push(L - 1), kt.p(L - 1, i.loc), i.important === !0 && (J++, p++, this.atrule && O("keyframes", this.atrule.name) && (xe++, p++)), bt.push(p);
931
+ wt.add(a(i)), ze.push(L - 1), bt.p(L - 1, i.loc), i.important === !0 && (J++, p++, this.atrule && O("keyframes", this.atrule.name) && (xe++, p++)), kt.push(p);
927
932
  let { property: l, loc: { start: g } } = i, c = {
928
933
  start: {
929
934
  line: g.line,
@@ -934,7 +939,7 @@ function Ei(r, t = {}) {
934
939
  offset: g.offset + l.length
935
940
  }
936
941
  };
937
- N.p(l, c), F(l) ? (_e.p(l, c), j.push(2)) : _i(l) ? (Se.p(l, c), j.push(2)) : Be(l) ? (X.p(l, c), j.push(i.important ? 3 : 2), i.important === !0 && Ce.p(l, c)) : j.push(1);
942
+ N.p(l, c), E(l) ? (_e.p(l, c), j.push(2)) : qi(l) ? (Se.p(l, c), j.push(2)) : Be(l) ? (X.p(l, c), j.push(i.important ? 3 : 2), i.important === !0 && Ce.p(l, c)) : j.push(1);
938
943
  break;
939
944
  }
940
945
  }
@@ -944,15 +949,15 @@ function Ei(r, t = {}) {
944
949
  (i.type === Me || i.type === Te) && L--;
945
950
  }
946
951
  });
947
- let At = wt.size, H = Z.size(), Re = ut.aggregate(), De = ct.aggregate(), Ee = ft.aggregate(), Pt = ot.size, d = Object.assign, Lt = r.length, Fe = se.length, Ot = re.aggregate(), Rt = Z.aggregate(), Dt = bt.aggregate(), Et = j.aggregate(), Ft = ve.aggregate(), Tt = Ye.c();
952
+ let At = wt.size, H = Z.size(), Re = ut.aggregate(), De = ct.aggregate(), Fe = ft.aggregate(), Pt = ot.size, d = Object.assign, Lt = r.length, Ee = se.length, Ot = re.aggregate(), Rt = Z.aggregate(), Dt = kt.aggregate(), Ft = j.aggregate(), Et = qe.aggregate(), Tt = Ye.c();
948
953
  return {
949
954
  stylesheet: {
950
- sourceLinesOfCode: Tt.total + H + K + de.size(),
951
- linesOfCode: Xt,
955
+ sourceLinesOfCode: Tt.total + H + W + de.size(),
956
+ linesOfCode: $t,
952
957
  size: Lt,
953
- complexity: Ot.sum + Rt.sum + Dt.sum + Et.sum + Ft.sum,
958
+ complexity: Ot.sum + Rt.sum + Dt.sum + Ft.sum + Et.sum,
954
959
  comments: {
955
- total: k,
960
+ total: b,
956
961
  size: w
957
962
  },
958
963
  embeddedContent: {
@@ -961,10 +966,10 @@ function Ei(r, t = {}) {
961
966
  ratio: z(_, Lt)
962
967
  },
963
968
  types: {
964
- total: b.total,
965
- totalUnique: b.unique.size,
966
- uniquenessRatio: z(b.unique.size, b.total),
967
- unique: Object.fromEntries(b.unique)
969
+ total: k.total,
970
+ totalUnique: k.unique.size,
971
+ uniquenessRatio: z(k.unique.size, k.total),
972
+ unique: Object.fromEntries(k.unique)
968
973
  }
969
974
  }
970
975
  },
@@ -972,10 +977,10 @@ function Ei(r, t = {}) {
972
977
  Tt,
973
978
  {
974
979
  fontface: d({
975
- total: Fe,
976
- totalUnique: Fe,
980
+ total: Ee,
981
+ totalUnique: Ee,
977
982
  unique: se,
978
- uniquenessRatio: Fe === 0 ? 0 : 1
983
+ uniquenessRatio: Ee === 0 ? 0 : 1
979
984
  }, e ? {
980
985
  uniqueWithLocations: Ge.c().uniqueWithLocations
981
986
  } : {}),
@@ -1069,11 +1074,11 @@ function Ei(r, t = {}) {
1069
1074
  /** @type Specificity */
1070
1075
  max: M === void 0 ? [0, 0, 0] : M,
1071
1076
  /** @type Specificity */
1072
- sum: [Re.sum, De.sum, Ee.sum],
1077
+ sum: [Re.sum, De.sum, Fe.sum],
1073
1078
  /** @type Specificity */
1074
- mean: [Re.mean, De.mean, Ee.mean],
1079
+ mean: [Re.mean, De.mean, Fe.mean],
1075
1080
  /** @type Specificity */
1076
- mode: [Re.mode, De.mode, Ee.mode],
1081
+ mode: [Re.mode, De.mode, Fe.mode],
1077
1082
  /** @type Specificity */
1078
1083
  items: mt
1079
1084
  },
@@ -1087,9 +1092,9 @@ function Ei(r, t = {}) {
1087
1092
  }
1088
1093
  ),
1089
1094
  nesting: d(
1090
- ke.aggregate(),
1095
+ be.aggregate(),
1091
1096
  {
1092
- items: ke.toArray()
1097
+ items: be.toArray()
1093
1098
  },
1094
1099
  yt.c()
1095
1100
  ),
@@ -1101,9 +1106,9 @@ function Ei(r, t = {}) {
1101
1106
  ),
1102
1107
  pseudoClasses: gt.c(),
1103
1108
  accessibility: d(
1104
- be.c(),
1109
+ ke.c(),
1105
1110
  {
1106
- ratio: z(be.size(), H)
1111
+ ratio: z(ke.size(), H)
1107
1112
  }
1108
1113
  ),
1109
1114
  keyframes: de.c(),
@@ -1116,12 +1121,12 @@ function Ei(r, t = {}) {
1116
1121
  combinators: dt.c()
1117
1122
  },
1118
1123
  declarations: {
1119
- total: K,
1124
+ total: W,
1120
1125
  totalUnique: At,
1121
- uniquenessRatio: z(At, K),
1126
+ uniquenessRatio: z(At, W),
1122
1127
  importants: {
1123
1128
  total: J,
1124
- ratio: z(J, K),
1129
+ ratio: z(J, W),
1125
1130
  inKeyframes: {
1126
1131
  total: xe,
1127
1132
  ratio: z(xe, J)
@@ -1133,7 +1138,7 @@ function Ei(r, t = {}) {
1133
1138
  {
1134
1139
  items: ze.toArray()
1135
1140
  },
1136
- kt.c()
1141
+ bt.c()
1137
1142
  )
1138
1143
  },
1139
1144
  properties: d(
@@ -1163,7 +1168,7 @@ function Ei(r, t = {}) {
1163
1168
  ratio: z(Se.size(), N.size())
1164
1169
  }
1165
1170
  ),
1166
- complexity: Et
1171
+ complexity: Ft
1167
1172
  }
1168
1173
  ),
1169
1174
  values: {
@@ -1180,17 +1185,17 @@ function Ei(r, t = {}) {
1180
1185
  zindexes: Ct.c(),
1181
1186
  textShadows: zt.c(),
1182
1187
  boxShadows: St.c(),
1183
- borderRadiuses: vt.count(),
1188
+ borderRadiuses: qt.count(),
1184
1189
  animations: {
1185
1190
  durations: ee.c(),
1186
1191
  timingFunctions: $.c()
1187
1192
  },
1188
1193
  prefixes: xt.c(),
1189
- browserhacks: qe.c(),
1194
+ browserhacks: ve.c(),
1190
1195
  units: Oe.count(),
1191
- complexity: Ft,
1196
+ complexity: Et,
1192
1197
  keywords: B.c(),
1193
- resets: qt.c()
1198
+ resets: vt.c()
1194
1199
  },
1195
1200
  __meta__: {
1196
1201
  parseTime: T - P,
@@ -1203,14 +1208,20 @@ function Wt(r, t) {
1203
1208
  return r[0] === t[0] ? r[1] === t[1] ? t[2] - r[2] : t[1] - r[1] : t[0] - r[0];
1204
1209
  }
1205
1210
  export {
1211
+ A as KeywordSet,
1206
1212
  Ei as analyze,
1213
+ gi as colorFunctions,
1214
+ di as colorKeywords,
1207
1215
  Wt as compareSpecificity,
1208
- F as hasVendorPrefix,
1209
- Qt as isAccessibilitySelector,
1210
- oi as isMediaBrowserhack,
1211
- _i as isPropertyHack,
1212
- ui as isSelectorPrefixed,
1213
- ai as isSupportsBrowserhack,
1214
- Jt as isValuePrefixed,
1215
- Zt as selectorComplexity
1216
+ ie as cssKeywords,
1217
+ E as hasVendorPrefix,
1218
+ Zt as isAccessibilitySelector,
1219
+ ui as isMediaBrowserhack,
1220
+ qi as isPropertyHack,
1221
+ ci as isSelectorPrefixed,
1222
+ oi as isSupportsBrowserhack,
1223
+ Xt as isValuePrefixed,
1224
+ hi as namedColors,
1225
+ Jt as selectorComplexity,
1226
+ mi as systemColors
1216
1227
  };
package/dist/index.d.ts CHANGED
@@ -1035,7 +1035,9 @@ export function analyze(css: string, options?: Options): {
1035
1035
  export function compareSpecificity(a: Specificity, b: Specificity): number;
1036
1036
  export { isHack as isPropertyHack } from './properties/property-utils.js';
1037
1037
  export { isValuePrefixed } from './values/vendor-prefix.js';
1038
+ export { keywords as cssKeywords } from './values/values.js';
1038
1039
  export { hasVendorPrefix } from './vendor-prefix.js';
1040
+ export { KeywordSet } from './keyword-set.js';
1039
1041
  export type Options = {
1040
1042
  /**
1041
1043
  * Use Locations (`{ 'item': [{ line, column, offset, length }] }`) instead of a regular count per occurrence (`{ 'item': 3 }`)
@@ -1045,3 +1047,4 @@ export type Options = {
1045
1047
  export type Specificity = [number, number, number];
1046
1048
  export { getComplexity as selectorComplexity, isPrefixed as isSelectorPrefixed, isAccessibility as isAccessibilitySelector } from './selectors/utils.js';
1047
1049
  export { isSupportsBrowserhack, isMediaBrowserhack } from './atrules/atrules.js';
1050
+ export { colorFunctions, colorKeywords, namedColors, systemColors } from './values/colors.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@projectwallace/css-analyzer",
3
3
  "description": "The best CSS analyzer out there. Check design tokens, complexity, specificity, performance and more.",
4
- "version": "7.5.0",
4
+ "version": "7.6.0",
5
5
  "author": "Bart Veneman",
6
6
  "repository": {
7
7
  "type": "git",