@projectwallace/css-analyzer 7.5.1 → 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.
@@ -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,7 +32,7 @@ function We(r, t) {
32
32
  return !1;
33
33
  return !0;
34
34
  }
35
- const Te = "Atrule", ii = "MediaQuery", Me = "Rule", Ke = "Selector", Nt = "TypeSelector", G = "PseudoClassSelector", jt = "AttributeSelector", Bt = "PseudoElementSelector", Ve = "Declaration", ri = "Value", R = "Identifier", si = "Nth", li = "Combinator", Yt = "Number", Ne = "Dimension", W = "Operator", ni = "Hash", ai = "Url", je = "Function";
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
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);
@@ -49,7 +49,7 @@ function ui(r) {
49
49
  return v(r, function(s) {
50
50
  let e = s.name, n = s.value;
51
51
  if (s.type === ii && s.mediaType !== null) {
52
- if (We("\\0", s.mediaType) || O("\\9 ", s.mediaType))
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")
@@ -68,7 +68,7 @@ function E(r) {
68
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
  }
@@ -80,7 +80,7 @@ class A {
80
80
  function Gt(r, t) {
81
81
  let s = [];
82
82
  return v(r, {
83
- visit: Ke,
83
+ visit: We,
84
84
  enter: function(e) {
85
85
  s.push(t(e));
86
86
  }
@@ -102,7 +102,7 @@ function Zt(r) {
102
102
  return v(r, function(s) {
103
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
107
  } else if (s.type === G && Qt.has(s.name)) {
108
108
  let e = Gt(s, Zt);
@@ -133,7 +133,7 @@ function Jt(r) {
133
133
  let t = 0;
134
134
  return v(r, function(s) {
135
135
  let e = s.type;
136
- if (!(e === Ke || e === si)) {
136
+ if (!(e === We || e === si)) {
137
137
  if (t++, (e === Bt || e === Nt || e === G) && E(s.name) && t++, e === jt)
138
138
  return s.value && t++, this.skip;
139
139
  if (e === G && Qt.has(s.name)) {
@@ -409,7 +409,7 @@ const wi = new A([
409
409
  /* <relative-size> values */
410
410
  "smaller",
411
411
  "larger"
412
- ]), bi = 44, Wt = 47;
412
+ ]), bi = 44, Kt = 47;
413
413
  function Ie(r) {
414
414
  let t = r.children.first;
415
415
  return t === null ? !1 : t.type === R && wi.has(t.name);
@@ -424,15 +424,15 @@ function xi(r, t, s) {
424
424
  if (w.type === R && ie.has(w.name) && s({
425
425
  type: "keyword",
426
426
  value: w.name
427
- }), P && P.type === W && P.value.charCodeAt(0) === Wt) {
427
+ }), P && P.type === K && P.value.charCodeAt(0) === Kt) {
428
428
  n = t(w);
429
429
  return;
430
430
  }
431
- if (k && k.type === W && k.value.charCodeAt(0) === Wt) {
431
+ if (k && k.type === K && k.value.charCodeAt(0) === Kt) {
432
432
  a = t(w);
433
433
  return;
434
434
  }
435
- if (P && P.type === W && P.value.charCodeAt(0) === bi && !e[0]) {
435
+ if (P && P.type === K && P.value.charCodeAt(0) === bi && !e[0]) {
436
436
  e[0] = w, !n && k && (n = t(k));
437
437
  return;
438
438
  }
@@ -484,7 +484,7 @@ function Si(r, t) {
484
484
  let s = !1;
485
485
  for (let e of r) {
486
486
  let n = e.type, a = e.name;
487
- n === W ? s = !1 : n === Ne && s === !1 ? (s = !0, t({
487
+ n === K ? s = !1 : n === Ne && s === !1 ? (s = !0, t({
488
488
  type: "duration",
489
489
  value: e
490
490
  })) : n === R ? Ci.has(a) ? t({
@@ -716,7 +716,7 @@ function Ei(r, t = {}) {
716
716
  onComment: function(i) {
717
717
  b++, w += i.length;
718
718
  }
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(), K = 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;
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
720
  v(D, {
721
721
  enter(i) {
722
722
  var Y, Mt;
@@ -774,7 +774,7 @@ function Ei(r, t = {}) {
774
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++;
775
775
  break;
776
776
  }
777
- case Ke: {
777
+ case We: {
778
778
  let p = a(i);
779
779
  if (this.atrule && O("keyframes", this.atrule.name))
780
780
  return de.p(p, i.loc), this.skip;
@@ -786,7 +786,7 @@ function Ei(r, t = {}) {
786
786
  let g = Jt(i);
787
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
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 && Kt(I, c) < 0 && (I = c), M !== void 0 && Kt(M, c) > 0 && (M = c), mt.push(c), f > 0 && we.p(p, i.loc), pi(i, function(q) {
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
790
  dt.p(q.name, q.loc);
791
791
  }), this.skip;
792
792
  }
@@ -797,7 +797,7 @@ function Ei(r, t = {}) {
797
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;
798
798
  }
799
799
  case ai: {
800
- if (We("data:", i.value)) {
800
+ if (Ke("data:", i.value)) {
801
801
  let p = i.value, l = p.length, g = Ai(p);
802
802
  k.total++, _ += l;
803
803
  let c = {
@@ -861,12 +861,12 @@ function Ei(r, t = {}) {
861
861
  break;
862
862
  } else if (m("animation-duration", l) || m("transition-duration", l)) {
863
863
  f && f.size > 1 ? f.forEach((h) => {
864
- h.type !== W && ee.p(a(h), u);
864
+ h.type !== K && ee.p(a(h), u);
865
865
  }) : ee.p(a(i), u);
866
866
  break;
867
867
  } else if (m("transition-timing-function", l) || m("animation-timing-function", l)) {
868
868
  f && f.size > 1 ? f.forEach((h) => {
869
- h.type !== W && $.p(a(h), u);
869
+ h.type !== K && $.p(a(h), u);
870
870
  }) : $.p(a(i), u);
871
871
  break;
872
872
  } else if (m("container-name", l))
@@ -926,7 +926,7 @@ function Ei(r, t = {}) {
926
926
  case Ve: {
927
927
  if (this.atrulePrelude !== null)
928
928
  return this.skip;
929
- K++;
929
+ W++;
930
930
  let p = 1;
931
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);
932
932
  let { property: l, loc: { start: g } } = i, c = {
@@ -952,7 +952,7 @@ function Ei(r, t = {}) {
952
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();
953
953
  return {
954
954
  stylesheet: {
955
- sourceLinesOfCode: Tt.total + H + K + de.size(),
955
+ sourceLinesOfCode: Tt.total + H + W + de.size(),
956
956
  linesOfCode: $t,
957
957
  size: Lt,
958
958
  complexity: Ot.sum + Rt.sum + Dt.sum + Ft.sum + Et.sum,
@@ -1121,12 +1121,12 @@ function Ei(r, t = {}) {
1121
1121
  combinators: dt.c()
1122
1122
  },
1123
1123
  declarations: {
1124
- total: K,
1124
+ total: W,
1125
1125
  totalUnique: At,
1126
- uniquenessRatio: z(At, K),
1126
+ uniquenessRatio: z(At, W),
1127
1127
  importants: {
1128
1128
  total: J,
1129
- ratio: z(J, K),
1129
+ ratio: z(J, W),
1130
1130
  inKeyframes: {
1131
1131
  total: xe,
1132
1132
  ratio: z(xe, J)
@@ -1204,12 +1204,16 @@ function Ei(r, t = {}) {
1204
1204
  }
1205
1205
  };
1206
1206
  }
1207
- function Kt(r, t) {
1207
+ function Wt(r, t) {
1208
1208
  return r[0] === t[0] ? r[1] === t[1] ? t[2] - r[2] : t[1] - r[1] : t[0] - r[0];
1209
1209
  }
1210
1210
  export {
1211
+ A as KeywordSet,
1211
1212
  Ei as analyze,
1212
- Kt as compareSpecificity,
1213
+ gi as colorFunctions,
1214
+ di as colorKeywords,
1215
+ Wt as compareSpecificity,
1216
+ ie as cssKeywords,
1213
1217
  E as hasVendorPrefix,
1214
1218
  Zt as isAccessibilitySelector,
1215
1219
  ui as isMediaBrowserhack,
@@ -1217,5 +1221,7 @@ export {
1217
1221
  ci as isSelectorPrefixed,
1218
1222
  oi as isSupportsBrowserhack,
1219
1223
  Xt as isValuePrefixed,
1220
- Jt as selectorComplexity
1224
+ hi as namedColors,
1225
+ Jt as selectorComplexity,
1226
+ mi as systemColors
1221
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.1",
4
+ "version": "7.6.0",
5
5
  "author": "Bart Veneman",
6
6
  "repository": {
7
7
  "type": "git",