@projectwallace/css-analyzer 7.0.0 → 7.0.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.
- package/dist/css-analyzer.js +185 -182
- package/package.json +2 -2
package/dist/css-analyzer.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import Dt from "css-tree/parser";
|
|
2
|
-
import
|
|
2
|
+
import P from "css-tree/walker";
|
|
3
3
|
import { calculateForAST as Ft } from "@bramus/specificity/core";
|
|
4
4
|
function Re(i, t) {
|
|
5
5
|
return t >= 65 && t <= 90 && (t = t | 32), i === t;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function _(i, t) {
|
|
8
8
|
if (i === t) return !0;
|
|
9
9
|
let r = i.length;
|
|
10
10
|
if (r !== t.length) return !1;
|
|
@@ -13,7 +13,7 @@ function z(i, t) {
|
|
|
13
13
|
return !1;
|
|
14
14
|
return !0;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function O(i, t) {
|
|
17
17
|
if (i === t) return !0;
|
|
18
18
|
let r = t.length, e = r - i.length;
|
|
19
19
|
if (e < 0)
|
|
@@ -32,40 +32,40 @@ function Ee(i, t) {
|
|
|
32
32
|
return !1;
|
|
33
33
|
return !0;
|
|
34
34
|
}
|
|
35
|
-
const Mt = "Atrule", Ut = "MediaQuery", Tt = "MediaFeature", It = "Rule", De = "Selector", zt = "TypeSelector", Y = "PseudoClassSelector", St = "AttributeSelector", vt = "PseudoElementSelector", Oe = "Declaration", Ht = "Value",
|
|
35
|
+
const Mt = "Atrule", Ut = "MediaQuery", Tt = "MediaFeature", It = "Rule", De = "Selector", zt = "TypeSelector", Y = "PseudoClassSelector", St = "AttributeSelector", vt = "PseudoElementSelector", Oe = "Declaration", Ht = "Value", L = "Identifier", Vt = "Nth", Wt = "Combinator", Kt = "Number", qt = "Dimension", V = "Operator", jt = "Hash", Bt = "Url", Fe = "Function";
|
|
36
36
|
function kt(i, t, r) {
|
|
37
37
|
let e = i.value.children.first;
|
|
38
|
-
return
|
|
38
|
+
return _(t, i.property) && e.type === L && _(r, e.name);
|
|
39
39
|
}
|
|
40
40
|
function Yt(i) {
|
|
41
41
|
let t = !1;
|
|
42
|
-
return
|
|
42
|
+
return P(i, function(r) {
|
|
43
43
|
if (r.type === Oe && (kt(r, "-webkit-appearance", "none") || kt(r, "-moz-appearance", "meterbar")))
|
|
44
44
|
return t = !0, this.break;
|
|
45
45
|
}), t;
|
|
46
46
|
}
|
|
47
47
|
function Gt(i) {
|
|
48
48
|
let t = !1;
|
|
49
|
-
return
|
|
49
|
+
return P(i, function(r) {
|
|
50
50
|
let e = r.children, n = r.name, l = r.value;
|
|
51
|
-
if (r.type === Ut && e.size === 1 && e.first.type ===
|
|
52
|
-
let
|
|
53
|
-
if (Ee("\\0",
|
|
51
|
+
if (r.type === Ut && e.size === 1 && e.first.type === L) {
|
|
52
|
+
let m = e.first.name;
|
|
53
|
+
if (Ee("\\0", m) || O("\\9 ", m))
|
|
54
54
|
return t = !0, this.break;
|
|
55
55
|
} else if (r.type === Tt) {
|
|
56
56
|
if (l && l.unit && l.unit === "\\0")
|
|
57
57
|
return t = !0, this.break;
|
|
58
|
-
if (
|
|
58
|
+
if (_("-moz-images-in-menus", n) || _("min--moz-device-pixel-ratio", n) || _("-ms-high-contrast", n))
|
|
59
59
|
return t = !0, this.break;
|
|
60
|
-
if (
|
|
60
|
+
if (_("min-resolution", n) && l && _(".001", l.value) && _("dpcm", l.unit))
|
|
61
61
|
return t = !0, this.break;
|
|
62
|
-
if (
|
|
62
|
+
if (_("-webkit-min-device-pixel-ratio", n) && l && l.value && (_("0", l.value) || _("10000", l.value)))
|
|
63
63
|
return t = !0, this.break;
|
|
64
64
|
}
|
|
65
65
|
}), t;
|
|
66
66
|
}
|
|
67
67
|
const xt = 45;
|
|
68
|
-
function
|
|
68
|
+
function D(i) {
|
|
69
69
|
return i.charCodeAt(0) === xt && i.charCodeAt(1) !== xt && i.indexOf("-", 2) !== -1;
|
|
70
70
|
}
|
|
71
71
|
class q {
|
|
@@ -80,7 +80,7 @@ class q {
|
|
|
80
80
|
}
|
|
81
81
|
function At(i, t) {
|
|
82
82
|
let r = [];
|
|
83
|
-
return
|
|
83
|
+
return P(i, {
|
|
84
84
|
visit: De,
|
|
85
85
|
enter: function(e) {
|
|
86
86
|
r.push(t(e));
|
|
@@ -100,10 +100,10 @@ const Pt = new q([
|
|
|
100
100
|
]);
|
|
101
101
|
function Lt(i) {
|
|
102
102
|
let t = !1;
|
|
103
|
-
return
|
|
103
|
+
return P(i, function(r) {
|
|
104
104
|
if (r.type === St) {
|
|
105
105
|
let e = r.name.name;
|
|
106
|
-
if (
|
|
106
|
+
if (_("role", e) || Ee("aria-", e))
|
|
107
107
|
return t = !0, this.break;
|
|
108
108
|
} else if (r.type === Y && Pt.has(r.name)) {
|
|
109
109
|
let e = At(r, Lt);
|
|
@@ -118,24 +118,24 @@ function Lt(i) {
|
|
|
118
118
|
}
|
|
119
119
|
function Qt(i) {
|
|
120
120
|
let t = !1;
|
|
121
|
-
return
|
|
121
|
+
return P(i, function(r) {
|
|
122
122
|
let e = r.type;
|
|
123
|
-
if ((e === vt || e === zt || e === Y) &&
|
|
123
|
+
if ((e === vt || e === zt || e === Y) && D(r.name))
|
|
124
124
|
return t = !0, this.break;
|
|
125
125
|
}), t;
|
|
126
126
|
}
|
|
127
127
|
function Zt(i) {
|
|
128
128
|
let t = [];
|
|
129
|
-
return
|
|
129
|
+
return P(i, function(r) {
|
|
130
130
|
r.type === Y && t.push(r.name);
|
|
131
131
|
}), t.length === 0 ? !1 : t;
|
|
132
132
|
}
|
|
133
133
|
function Ot(i) {
|
|
134
134
|
let t = 0;
|
|
135
|
-
return
|
|
135
|
+
return P(i, function(r) {
|
|
136
136
|
let e = r.type;
|
|
137
137
|
if (!(e === De || e === Vt)) {
|
|
138
|
-
if (t++, (e === vt || e === zt || e === Y) &&
|
|
138
|
+
if (t++, (e === vt || e === zt || e === Y) && D(r.name) && t++, e === St)
|
|
139
139
|
return r.value && t++, this.skip;
|
|
140
140
|
if (e === Y && Pt.has(r.name)) {
|
|
141
141
|
let n = At(r, Ot);
|
|
@@ -148,23 +148,23 @@ function Ot(i) {
|
|
|
148
148
|
}), t;
|
|
149
149
|
}
|
|
150
150
|
function Jt(i, t) {
|
|
151
|
-
|
|
151
|
+
P(i, function(r, e) {
|
|
152
152
|
if (r.type === Wt) {
|
|
153
153
|
let n = r.loc, l = r.name;
|
|
154
154
|
if (n === null) {
|
|
155
|
-
let
|
|
156
|
-
offset:
|
|
157
|
-
line:
|
|
158
|
-
column:
|
|
155
|
+
let m = e.prev.data.loc.end, w = {
|
|
156
|
+
offset: m.offset,
|
|
157
|
+
line: m.line,
|
|
158
|
+
column: m.column
|
|
159
159
|
};
|
|
160
160
|
t({
|
|
161
161
|
name: l,
|
|
162
162
|
loc: {
|
|
163
|
-
start:
|
|
163
|
+
start: w,
|
|
164
164
|
end: {
|
|
165
|
-
offset:
|
|
166
|
-
line:
|
|
167
|
-
column:
|
|
165
|
+
offset: w.offset + 1,
|
|
166
|
+
line: w.line,
|
|
167
|
+
column: w.column + 1
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
});
|
|
@@ -379,7 +379,7 @@ function $(i) {
|
|
|
379
379
|
let t = i.children, r = t.size;
|
|
380
380
|
if (!t || r > 1 || r === 0) return !1;
|
|
381
381
|
let e = t.first;
|
|
382
|
-
return e.type ===
|
|
382
|
+
return e.type === L && N.has(e.name);
|
|
383
383
|
}
|
|
384
384
|
const ti = new q([
|
|
385
385
|
"caption",
|
|
@@ -404,55 +404,58 @@ const ti = new q([
|
|
|
404
404
|
]), ri = 44, Ct = 47;
|
|
405
405
|
function Pe(i) {
|
|
406
406
|
let t = i.children.first;
|
|
407
|
-
return t === null ? !1 : t.type ===
|
|
407
|
+
return t === null ? !1 : t.type === L && ti.has(t.name);
|
|
408
408
|
}
|
|
409
409
|
function si(i, t, r) {
|
|
410
|
+
var w;
|
|
410
411
|
let e = Array.from({ length: 2 }), n, l;
|
|
411
|
-
i.children.forEach(function(
|
|
412
|
-
let
|
|
413
|
-
if (
|
|
412
|
+
i.children.forEach(function(g, z) {
|
|
413
|
+
let y = z.prev ? z.prev.data : void 0, A = z.next ? z.next.data : void 0;
|
|
414
|
+
if (g.type === L && N.has(g.name) && r({
|
|
414
415
|
type: "keyword",
|
|
415
|
-
value:
|
|
416
|
-
}),
|
|
417
|
-
n = t(
|
|
416
|
+
value: g.name
|
|
417
|
+
}), A && A.type === V && A.value.charCodeAt(0) === Ct) {
|
|
418
|
+
n = t(g);
|
|
418
419
|
return;
|
|
419
420
|
}
|
|
420
|
-
if (
|
|
421
|
-
l = t(
|
|
421
|
+
if (y && y.type === V && y.value.charCodeAt(0) === Ct) {
|
|
422
|
+
l = t(g);
|
|
422
423
|
return;
|
|
423
424
|
}
|
|
424
|
-
if (
|
|
425
|
-
e[0] =
|
|
425
|
+
if (A && A.type === V && A.value.charCodeAt(0) === ri && !e[0]) {
|
|
426
|
+
e[0] = g, !n && y && (n = t(y));
|
|
426
427
|
return;
|
|
427
428
|
}
|
|
428
|
-
if (
|
|
429
|
-
if (
|
|
430
|
-
e[1] =
|
|
429
|
+
if (g.type !== Kt) {
|
|
430
|
+
if (z.next === null) {
|
|
431
|
+
e[1] = g, !n && !e[0] && y && (n = t(y));
|
|
431
432
|
return;
|
|
432
433
|
}
|
|
433
|
-
if (
|
|
434
|
-
let
|
|
435
|
-
if (ii.has(
|
|
436
|
-
n =
|
|
434
|
+
if (g.type === L) {
|
|
435
|
+
let R = g.name;
|
|
436
|
+
if (ii.has(R)) {
|
|
437
|
+
n = R;
|
|
437
438
|
return;
|
|
438
439
|
}
|
|
439
440
|
}
|
|
440
441
|
}
|
|
441
442
|
});
|
|
442
|
-
let
|
|
443
|
+
let m = e[0] || e[1] ? t({
|
|
443
444
|
loc: {
|
|
444
445
|
start: {
|
|
445
446
|
offset: (e[0] || e[1]).loc.start.offset
|
|
446
447
|
},
|
|
447
448
|
end: {
|
|
448
|
-
|
|
449
|
+
// Either the node we detected as the last node, or the end of the whole value
|
|
450
|
+
// It's never 0 because the first node is always a font-size or font-style
|
|
451
|
+
offset: ((w = e[1]) == null ? void 0 : w.loc.end.offset) || i.loc.end.offset
|
|
449
452
|
}
|
|
450
453
|
}
|
|
451
454
|
}) : null;
|
|
452
455
|
return {
|
|
453
456
|
font_size: n,
|
|
454
457
|
line_height: l,
|
|
455
|
-
font_family:
|
|
458
|
+
font_family: m
|
|
456
459
|
};
|
|
457
460
|
}
|
|
458
461
|
const li = new q([
|
|
@@ -471,10 +474,10 @@ function ai(i, t) {
|
|
|
471
474
|
let r = !1;
|
|
472
475
|
for (let e of i) {
|
|
473
476
|
let n = e.type, l = e.name;
|
|
474
|
-
n ===
|
|
477
|
+
n === V ? r = !1 : n === qt && r === !1 ? (r = !0, t({
|
|
475
478
|
type: "duration",
|
|
476
479
|
value: e
|
|
477
|
-
})) : n ===
|
|
480
|
+
})) : n === L ? li.has(l) ? t({
|
|
478
481
|
type: "fn",
|
|
479
482
|
value: e
|
|
480
483
|
}) : N.has(l) && t({
|
|
@@ -492,7 +495,7 @@ function Rt(i) {
|
|
|
492
495
|
return !1;
|
|
493
496
|
for (let r of t) {
|
|
494
497
|
let { type: e, name: n } = r;
|
|
495
|
-
if (e ===
|
|
498
|
+
if (e === L && D(n) || e === Fe && (D(n) || Rt(r)))
|
|
496
499
|
return !0;
|
|
497
500
|
}
|
|
498
501
|
return !1;
|
|
@@ -509,8 +512,8 @@ class o {
|
|
|
509
512
|
p(t, r) {
|
|
510
513
|
let e = this._total;
|
|
511
514
|
if (this._useLocations) {
|
|
512
|
-
let n = r.start, l = n.offset,
|
|
513
|
-
this._nodes[
|
|
515
|
+
let n = r.start, l = n.offset, m = e * 4;
|
|
516
|
+
this._nodes[m] = n.line, this._nodes[m + 1] = n.column, this._nodes[m + 2] = l, this._nodes[m + 3] = r.end.offset - l;
|
|
514
517
|
}
|
|
515
518
|
if (this._items.has(t)) {
|
|
516
519
|
this._items.get(t).push(e), this._total++;
|
|
@@ -540,29 +543,29 @@ class o {
|
|
|
540
543
|
* })}
|
|
541
544
|
*/
|
|
542
545
|
c() {
|
|
543
|
-
let t = /* @__PURE__ */ new Map(), r = {}, e = this._useLocations, n = this._items, l = this._nodes,
|
|
544
|
-
n.forEach((
|
|
546
|
+
let t = /* @__PURE__ */ new Map(), r = {}, e = this._useLocations, n = this._items, l = this._nodes, m = n.size;
|
|
547
|
+
n.forEach((z, y) => {
|
|
545
548
|
if (e) {
|
|
546
|
-
let
|
|
547
|
-
let
|
|
549
|
+
let A = z.map(function(R) {
|
|
550
|
+
let F = R * 4;
|
|
548
551
|
return {
|
|
549
|
-
line: l[
|
|
550
|
-
column: l[
|
|
551
|
-
offset: l[
|
|
552
|
-
length: l[
|
|
552
|
+
line: l[F],
|
|
553
|
+
column: l[F + 1],
|
|
554
|
+
offset: l[F + 2],
|
|
555
|
+
length: l[F + 3]
|
|
553
556
|
};
|
|
554
557
|
});
|
|
555
|
-
t.set(y,
|
|
558
|
+
t.set(y, A);
|
|
556
559
|
} else
|
|
557
|
-
r[y] =
|
|
560
|
+
r[y] = z.length;
|
|
558
561
|
});
|
|
559
|
-
let
|
|
560
|
-
total:
|
|
561
|
-
totalUnique:
|
|
562
|
+
let w = this._total, g = {
|
|
563
|
+
total: w,
|
|
564
|
+
totalUnique: m,
|
|
562
565
|
unique: r,
|
|
563
|
-
uniquenessRatio:
|
|
566
|
+
uniquenessRatio: w === 0 ? 0 : m / w
|
|
564
567
|
};
|
|
565
|
-
return e && (
|
|
568
|
+
return e && (g.uniqueWithLocations = Object.fromEntries(t)), g;
|
|
566
569
|
}
|
|
567
570
|
}
|
|
568
571
|
class Le {
|
|
@@ -590,9 +593,9 @@ class Le {
|
|
|
590
593
|
}
|
|
591
594
|
function oi(i) {
|
|
592
595
|
let t = /* @__PURE__ */ new Map(), r = -1, e = 0, n = 0, l = i.length;
|
|
593
|
-
for (let
|
|
594
|
-
let
|
|
595
|
-
t.set(
|
|
596
|
+
for (let m = 0; m < l; m++) {
|
|
597
|
+
let w = i[m], g = (t.get(w) || 0) + 1;
|
|
598
|
+
t.set(w, g), g > r && (r = g, e = 0, n = 0), g >= r && (e++, n += w);
|
|
596
599
|
}
|
|
597
600
|
return n / e;
|
|
598
601
|
}
|
|
@@ -621,14 +624,14 @@ class v {
|
|
|
621
624
|
range: 0,
|
|
622
625
|
sum: 0
|
|
623
626
|
};
|
|
624
|
-
let r = this._items.slice().sort((
|
|
627
|
+
let r = this._items.slice().sort((w, g) => w - g), e = r[0], n = r[t - 1], l = oi(r), m = this._sum;
|
|
625
628
|
return {
|
|
626
629
|
min: e,
|
|
627
630
|
max: n,
|
|
628
|
-
mean:
|
|
631
|
+
mean: m / t,
|
|
629
632
|
mode: l,
|
|
630
633
|
range: n - e,
|
|
631
|
-
sum:
|
|
634
|
+
sum: m
|
|
632
635
|
};
|
|
633
636
|
}
|
|
634
637
|
/**
|
|
@@ -639,18 +642,18 @@ class v {
|
|
|
639
642
|
}
|
|
640
643
|
}
|
|
641
644
|
function ui(i) {
|
|
642
|
-
if (Me(i) ||
|
|
645
|
+
if (Me(i) || D(i)) return !1;
|
|
643
646
|
let t = i.charCodeAt(0);
|
|
644
647
|
return t === 47 || t === 42 || t === 95 || t === 43 || t === 38 || t === 36 || t === 35;
|
|
645
648
|
}
|
|
646
649
|
function Me(i) {
|
|
647
650
|
return i.length < 3 ? !1 : i.charCodeAt(0) === 45 && i.charCodeAt(1) === 45;
|
|
648
651
|
}
|
|
649
|
-
function
|
|
650
|
-
return Me(t) ? !1 :
|
|
652
|
+
function C(i, t) {
|
|
653
|
+
return Me(t) ? !1 : O(i, t);
|
|
651
654
|
}
|
|
652
655
|
function ci(i) {
|
|
653
|
-
return
|
|
656
|
+
return D(i) ? i.slice(i.indexOf("-", 2) + 1) : i;
|
|
654
657
|
}
|
|
655
658
|
function fi(i) {
|
|
656
659
|
let t = 5, r = i.indexOf(";"), e = i.indexOf(",");
|
|
@@ -660,7 +663,7 @@ function pi(i) {
|
|
|
660
663
|
let t = i.children;
|
|
661
664
|
if (t) {
|
|
662
665
|
let r = t.last;
|
|
663
|
-
return r && r.type ===
|
|
666
|
+
return r && r.type === L && O("\\9", r.name);
|
|
664
667
|
}
|
|
665
668
|
return !1;
|
|
666
669
|
}
|
|
@@ -684,48 +687,48 @@ let mi = {
|
|
|
684
687
|
function wi(i, t = {}) {
|
|
685
688
|
let e = Object.assign({}, mi, t).useLocations === !0, n = Date.now();
|
|
686
689
|
function l(s) {
|
|
687
|
-
return
|
|
690
|
+
return m(s).trim();
|
|
688
691
|
}
|
|
689
|
-
function
|
|
692
|
+
function m(s) {
|
|
690
693
|
let f = s.loc;
|
|
691
694
|
return i.substring(f.start.offset, f.end.offset);
|
|
692
695
|
}
|
|
693
|
-
let
|
|
696
|
+
let w = 0, g = 0, z = 0, y = {
|
|
694
697
|
total: 0,
|
|
695
698
|
/** @type {Map<string, { size: number, count: number } & ({ uniqueWithLocations?: undefined } | ({ uniqueWithLocations: { offset: number, line: number, column: number, length: number }[] })) }>} */
|
|
696
699
|
unique: /* @__PURE__ */ new Map()
|
|
697
|
-
},
|
|
700
|
+
}, A = Date.now(), R = Dt(i, {
|
|
698
701
|
parseCustomProperty: !0,
|
|
699
702
|
// To find font-families, colors, etc.
|
|
700
703
|
positions: !0,
|
|
701
704
|
// So we can use stringifyNode()
|
|
702
705
|
/** @param {string} comment */
|
|
703
706
|
onComment: function(s) {
|
|
704
|
-
|
|
707
|
+
w++, g += s.length;
|
|
705
708
|
}
|
|
706
|
-
}),
|
|
707
|
-
|
|
709
|
+
}), F = Date.now(), Et = R.loc.end.line - R.loc.start.line + 1, ee = 0, te = new v(), ie = [], Ue = new o(e), re = new o(e), Te = new o(e), Ie = new o(e), He = new o(e), Ve = new o(e), We = new o(e), Ke = new o(e), se = new o(e), le = new o(e), je = new o(e), Be = new o(e), ne = 0, ae = 0, oe = new v(), ue = new v(), ce = new v(), Ye = new o(e), Ge = new o(e), Qe = new o(e), fe = new o(e), Ze = /* @__PURE__ */ new Set(), pe = new o(e), M, U, Je = new v(), Xe = new v(), $e = new v(), Ne = new o(e), G = new v(), et = new o(e), tt = [], he = new o(e), me = new o(e), it = new o(e), rt = new o(e), st = /* @__PURE__ */ new Set(), W = 0, lt = new v(), Q = 0, de = 0, ge = new o(e), K = new o(e), ye = new o(e), we = new o(e), Z = new o(e), j = new v(), be = new v(), nt = new o(e), ke = new o(e), at = new o(e), ot = new o(e), ut = new o(e), xe = new o(e), Ce = new o(e), _e = new o(e), J = new o(e), X = new o(e), T = new Le(e), I = new o(e), ze = new Le(e), ct = new o(e), B = new o(e), ft = new Le(e);
|
|
710
|
+
P(R, function(s) {
|
|
708
711
|
switch (s.type) {
|
|
709
712
|
case Mt: {
|
|
710
713
|
ee++;
|
|
711
714
|
let f = s.name;
|
|
712
715
|
if (f === "font-face") {
|
|
713
|
-
let
|
|
716
|
+
let d = {};
|
|
714
717
|
e && Ue.p(s.loc.start.offset, s.loc), s.block.children.forEach((u) => {
|
|
715
|
-
u.type === Oe && (
|
|
716
|
-
}), ie.push(
|
|
718
|
+
u.type === Oe && (d[u.property] = l(u.value));
|
|
719
|
+
}), ie.push(d), te.push(1);
|
|
717
720
|
break;
|
|
718
721
|
}
|
|
719
722
|
let a = 1;
|
|
720
723
|
if (s.prelude !== null) {
|
|
721
|
-
let
|
|
724
|
+
let d = s.prelude, u = d && l(s.prelude), p = d.loc;
|
|
722
725
|
if (f === "media")
|
|
723
|
-
Ie.p(u, p), Gt(
|
|
726
|
+
Ie.p(u, p), Gt(d) && (He.p(u, p), a++);
|
|
724
727
|
else if (f === "supports")
|
|
725
|
-
We.p(u, p), Yt(
|
|
726
|
-
else if (
|
|
728
|
+
We.p(u, p), Yt(d) && (Ke.p(u, p), a++);
|
|
729
|
+
else if (O("keyframes", f)) {
|
|
727
730
|
let c = "@" + f + " " + u;
|
|
728
|
-
|
|
731
|
+
D(f) && (le.p(c, p), a++), se.p(c, p);
|
|
729
732
|
} else f === "import" ? Te.p(u, p) : f === "charset" ? Ve.p(u, p) : f === "container" ? je.p(u, p) : f === "layer" ? u.split(",").forEach((c) => re.p(c.trim(), p)) : f === "property" && Be.p(u, p);
|
|
730
733
|
} else
|
|
731
734
|
f === "layer" && (re.p("<anonymous>", s.loc), a++);
|
|
@@ -733,23 +736,23 @@ function wi(i, t = {}) {
|
|
|
733
736
|
break;
|
|
734
737
|
}
|
|
735
738
|
case It: {
|
|
736
|
-
let f = s.prelude, a = s.block,
|
|
739
|
+
let f = s.prelude, a = s.block, d = f.children, u = a.children, p = d ? d.size : 0, c = u ? u.size : 0;
|
|
737
740
|
oe.push(p + c), Ye.p(p + c, s.loc), ue.push(p), Ge.p(p, f.loc), ce.push(c), Qe.p(c, a.loc), ne++, c === 0 && ae++;
|
|
738
741
|
break;
|
|
739
742
|
}
|
|
740
743
|
case De: {
|
|
741
744
|
let f = l(s);
|
|
742
|
-
if (this.atrule &&
|
|
745
|
+
if (this.atrule && O("keyframes", this.atrule.name))
|
|
743
746
|
return fe.p(f, s.loc), this.skip;
|
|
744
747
|
Lt(s) && me.p(f, s.loc);
|
|
745
748
|
let a = Zt(s);
|
|
746
749
|
if (a !== !1)
|
|
747
750
|
for (let k of a)
|
|
748
751
|
it.p(k, s.loc);
|
|
749
|
-
let
|
|
750
|
-
Qt(s) && pe.p(f, s.loc), Ze.add(f), G.push(
|
|
752
|
+
let d = Ot(s);
|
|
753
|
+
Qt(s) && pe.p(f, s.loc), Ze.add(f), G.push(d), et.p(d, s.loc);
|
|
751
754
|
let u = Ft(s).toArray(), [p, c, h] = u;
|
|
752
|
-
return Ne.p(u.toString(), s.loc), Je.push(p), Xe.push(c), $e.push(h),
|
|
755
|
+
return Ne.p(u.toString(), s.loc), Je.push(p), Xe.push(c), $e.push(h), M === void 0 && (M = u), U === void 0 && (U = u), U !== void 0 && _t(U, u) < 0 && (U = u), M !== void 0 && _t(M, u) > 0 && (M = u), tt.push(u), p > 0 && he.p(f, s.loc), Jt(s, function(S) {
|
|
753
756
|
rt.p(S.name, S.loc);
|
|
754
757
|
}), this.skip;
|
|
755
758
|
}
|
|
@@ -757,12 +760,12 @@ function wi(i, t = {}) {
|
|
|
757
760
|
if (!this.declaration)
|
|
758
761
|
break;
|
|
759
762
|
let f = s.unit;
|
|
760
|
-
return
|
|
763
|
+
return O("\\9", f) ? ze.push(f.substring(0, f.length - 2), this.declaration.property, s.loc) : ze.push(f, this.declaration.property, s.loc), this.skip;
|
|
761
764
|
}
|
|
762
765
|
case Bt: {
|
|
763
766
|
if (Ee("data:", s.value)) {
|
|
764
|
-
let f = s.value, a = f.length,
|
|
765
|
-
y.total++,
|
|
767
|
+
let f = s.value, a = f.length, d = fi(f);
|
|
768
|
+
y.total++, z += a;
|
|
766
769
|
let u = {
|
|
767
770
|
/** @type {number} */
|
|
768
771
|
line: s.loc.start.line,
|
|
@@ -773,15 +776,15 @@ function wi(i, t = {}) {
|
|
|
773
776
|
/** @type {number} */
|
|
774
777
|
length: s.loc.end.offset - s.loc.start.offset
|
|
775
778
|
};
|
|
776
|
-
if (y.unique.has(
|
|
777
|
-
let p = y.unique.get(
|
|
778
|
-
p.count++, p.size += a, y.unique.set(
|
|
779
|
+
if (y.unique.has(d)) {
|
|
780
|
+
let p = y.unique.get(d);
|
|
781
|
+
p.count++, p.size += a, y.unique.set(d, p), e && p.uniqueWithLocations.push(u);
|
|
779
782
|
} else {
|
|
780
783
|
let p = {
|
|
781
784
|
count: 1,
|
|
782
785
|
size: a
|
|
783
786
|
};
|
|
784
|
-
e && (p.uniqueWithLocations = [u]), y.unique.set(
|
|
787
|
+
e && (p.uniqueWithLocations = [u]), y.unique.set(d, p);
|
|
785
788
|
}
|
|
786
789
|
}
|
|
787
790
|
break;
|
|
@@ -791,82 +794,82 @@ function wi(i, t = {}) {
|
|
|
791
794
|
be.push(1), B.p(l(s), s.loc);
|
|
792
795
|
break;
|
|
793
796
|
}
|
|
794
|
-
let f = this.declaration, { property: a, important:
|
|
795
|
-
Rt(s) && (nt.p(l(s), s.loc), u++), typeof
|
|
797
|
+
let f = this.declaration, { property: a, important: d } = f, u = 1;
|
|
798
|
+
Rt(s) && (nt.p(l(s), s.loc), u++), typeof d == "string" && (ke.p(m(s) + "!" + d, s.loc), u++), pi(s) && (ke.p(l(s), s.loc), u++);
|
|
796
799
|
let p = s.children, c = s.loc;
|
|
797
|
-
if (be.push(u),
|
|
800
|
+
if (be.push(u), C("z-index", a))
|
|
798
801
|
return at.p(l(s), c), this.skip;
|
|
799
|
-
if (
|
|
802
|
+
if (C("font", a)) {
|
|
800
803
|
if (Pe(s)) return;
|
|
801
|
-
let { font_size: h, line_height: k, font_family: S } = si(s, l, function(
|
|
802
|
-
|
|
804
|
+
let { font_size: h, line_height: k, font_family: S } = si(s, l, function(E) {
|
|
805
|
+
E.type === "keyword" && B.p(E.value, c);
|
|
803
806
|
});
|
|
804
807
|
S && xe.p(S, c), h && Ce.p(h, c), k && _e.p(k, c);
|
|
805
808
|
break;
|
|
806
|
-
} else if (
|
|
809
|
+
} else if (C("font-size", a)) {
|
|
807
810
|
Pe(s) || Ce.p(l(s), c);
|
|
808
811
|
break;
|
|
809
|
-
} else if (
|
|
812
|
+
} else if (C("font-family", a)) {
|
|
810
813
|
Pe(s) || xe.p(l(s), c);
|
|
811
814
|
break;
|
|
812
|
-
} else if (
|
|
815
|
+
} else if (C("line-height", a))
|
|
813
816
|
_e.p(l(s), c);
|
|
814
|
-
else if (
|
|
817
|
+
else if (C("transition", a) || C("animation", a)) {
|
|
815
818
|
ai(p, function(h) {
|
|
816
819
|
h.type === "fn" ? J.p(l(h.value), c) : h.type === "duration" ? X.p(l(h.value), c) : h.type === "keyword" && B.p(l(h.value), c);
|
|
817
820
|
});
|
|
818
821
|
break;
|
|
819
|
-
} else if (
|
|
822
|
+
} else if (C("animation-duration", a) || C("transition-duration", a)) {
|
|
820
823
|
p && p.size > 1 ? p.forEach((h) => {
|
|
821
|
-
h.type !==
|
|
824
|
+
h.type !== V && X.p(l(h), c);
|
|
822
825
|
}) : X.p(l(s), c);
|
|
823
826
|
break;
|
|
824
|
-
} else if (
|
|
827
|
+
} else if (C("transition-timing-function", a) || C("animation-timing-function", a)) {
|
|
825
828
|
p && p.size > 1 ? p.forEach((h) => {
|
|
826
|
-
h.type !==
|
|
829
|
+
h.type !== V && J.p(l(h), c);
|
|
827
830
|
}) : J.p(l(s), c);
|
|
828
831
|
break;
|
|
829
832
|
} else if (hi.has(ci(a))) {
|
|
830
833
|
$(s) || ft.push(l(s), a, c);
|
|
831
834
|
break;
|
|
832
|
-
} else
|
|
833
|
-
|
|
835
|
+
} else C("text-shadow", a) ? $(s) || ot.p(l(s), c) : C("box-shadow", a) && ($(s) || ut.p(l(s), c));
|
|
836
|
+
P(s, function(h) {
|
|
834
837
|
let k = h.name;
|
|
835
838
|
switch (h.type) {
|
|
836
839
|
case jt: {
|
|
837
840
|
let S = h.value.length;
|
|
838
|
-
return
|
|
841
|
+
return O("\\9", h.value) && (S = S - 2), T.push("#" + h.value, a, c), I.p("hex" + S, c), this.skip;
|
|
839
842
|
}
|
|
840
|
-
case
|
|
843
|
+
case L: {
|
|
841
844
|
N.has(k) && B.p(k, c);
|
|
842
845
|
let S = k.length;
|
|
843
846
|
if (S > 20 || S < 3)
|
|
844
847
|
return this.skip;
|
|
845
848
|
if (ei.has(k)) {
|
|
846
|
-
let
|
|
847
|
-
|
|
849
|
+
let E = l(h);
|
|
850
|
+
T.push(E, a, c), I.p(k.toLowerCase(), c);
|
|
848
851
|
return;
|
|
849
852
|
}
|
|
850
853
|
if (Xt.has(k)) {
|
|
851
|
-
let
|
|
852
|
-
|
|
854
|
+
let E = l(h);
|
|
855
|
+
T.push(E, a, c), I.p("named", c);
|
|
853
856
|
return;
|
|
854
857
|
}
|
|
855
858
|
if ($t.has(k)) {
|
|
856
|
-
let
|
|
857
|
-
|
|
859
|
+
let E = l(h);
|
|
860
|
+
T.push(E, a, c), I.p("system", c);
|
|
858
861
|
return;
|
|
859
862
|
}
|
|
860
863
|
return this.skip;
|
|
861
864
|
}
|
|
862
865
|
case Fe: {
|
|
863
|
-
if (
|
|
866
|
+
if (_("var", k))
|
|
864
867
|
return this.skip;
|
|
865
868
|
if (Nt.has(k)) {
|
|
866
|
-
|
|
869
|
+
T.push(l(h), a, h.loc), I.p(k.toLowerCase(), h.loc);
|
|
867
870
|
return;
|
|
868
871
|
}
|
|
869
|
-
if (
|
|
872
|
+
if (O("gradient", k)) {
|
|
870
873
|
ct.p(l(h), h.loc);
|
|
871
874
|
return;
|
|
872
875
|
}
|
|
@@ -880,37 +883,37 @@ function wi(i, t = {}) {
|
|
|
880
883
|
return this.skip;
|
|
881
884
|
W++;
|
|
882
885
|
let f = 1;
|
|
883
|
-
st.add(l(s)), s.important === !0 && (Q++, f++, this.atrule &&
|
|
884
|
-
let { property: a, loc: { start:
|
|
886
|
+
st.add(l(s)), s.important === !0 && (Q++, f++, this.atrule && O("keyframes", this.atrule.name) && (de++, f++)), lt.push(f);
|
|
887
|
+
let { property: a, loc: { start: d } } = s, u = {
|
|
885
888
|
start: {
|
|
886
|
-
line:
|
|
887
|
-
column:
|
|
888
|
-
offset:
|
|
889
|
+
line: d.line,
|
|
890
|
+
column: d.column,
|
|
891
|
+
offset: d.offset
|
|
889
892
|
},
|
|
890
893
|
end: {
|
|
891
|
-
offset:
|
|
894
|
+
offset: d.offset + a.length
|
|
892
895
|
}
|
|
893
896
|
};
|
|
894
|
-
K.p(a, u),
|
|
897
|
+
K.p(a, u), D(a) ? (we.p(a, u), j.push(2)) : ui(a) ? (ye.p(a, u), j.push(2)) : Me(a) ? (Z.p(a, u), j.push(s.important ? 3 : 2), s.important === !0 && ge.p(a, u)) : j.push(1);
|
|
895
898
|
break;
|
|
896
899
|
}
|
|
897
900
|
}
|
|
898
901
|
});
|
|
899
|
-
let pt = st.size,
|
|
902
|
+
let pt = st.size, H = G.size(), Se = Je.aggregate(), ve = Xe.aggregate(), qe = $e.aggregate(), ht = Ze.size, b = Object.assign, mt = i.length, Ae = ie.length, dt = te.aggregate(), gt = G.aggregate(), yt = lt.aggregate(), wt = j.aggregate(), bt = be.aggregate();
|
|
900
903
|
return {
|
|
901
904
|
stylesheet: {
|
|
902
|
-
sourceLinesOfCode: ee +
|
|
905
|
+
sourceLinesOfCode: ee + H + W + fe.size(),
|
|
903
906
|
linesOfCode: Et,
|
|
904
907
|
size: mt,
|
|
905
908
|
complexity: dt.sum + gt.sum + yt.sum + wt.sum + bt.sum,
|
|
906
909
|
comments: {
|
|
907
|
-
total:
|
|
908
|
-
size:
|
|
910
|
+
total: w,
|
|
911
|
+
size: g
|
|
909
912
|
},
|
|
910
913
|
embeddedContent: {
|
|
911
914
|
size: {
|
|
912
|
-
total:
|
|
913
|
-
ratio: x(
|
|
915
|
+
total: z,
|
|
916
|
+
ratio: x(z, mt)
|
|
914
917
|
},
|
|
915
918
|
types: {
|
|
916
919
|
total: y.total,
|
|
@@ -921,7 +924,7 @@ function wi(i, t = {}) {
|
|
|
921
924
|
}
|
|
922
925
|
},
|
|
923
926
|
atrules: {
|
|
924
|
-
fontface:
|
|
927
|
+
fontface: b({
|
|
925
928
|
total: Ae,
|
|
926
929
|
totalUnique: Ae,
|
|
927
930
|
unique: ie,
|
|
@@ -930,23 +933,23 @@ function wi(i, t = {}) {
|
|
|
930
933
|
uniqueWithLocations: Ue.c().uniqueWithLocations
|
|
931
934
|
} : {}),
|
|
932
935
|
import: Te.c(),
|
|
933
|
-
media:
|
|
936
|
+
media: b(
|
|
934
937
|
Ie.c(),
|
|
935
938
|
{
|
|
936
939
|
browserhacks: He.c()
|
|
937
940
|
}
|
|
938
941
|
),
|
|
939
942
|
charset: Ve.c(),
|
|
940
|
-
supports:
|
|
943
|
+
supports: b(
|
|
941
944
|
We.c(),
|
|
942
945
|
{
|
|
943
946
|
browserhacks: Ke.c()
|
|
944
947
|
}
|
|
945
948
|
),
|
|
946
|
-
keyframes:
|
|
949
|
+
keyframes: b(
|
|
947
950
|
se.c(),
|
|
948
951
|
{
|
|
949
|
-
prefixed:
|
|
952
|
+
prefixed: b(
|
|
950
953
|
le.c(),
|
|
951
954
|
{
|
|
952
955
|
ratio: x(le.size(), se.size())
|
|
@@ -966,21 +969,21 @@ function wi(i, t = {}) {
|
|
|
966
969
|
total: ae,
|
|
967
970
|
ratio: x(ae, ne)
|
|
968
971
|
},
|
|
969
|
-
sizes:
|
|
972
|
+
sizes: b(
|
|
970
973
|
oe.aggregate(),
|
|
971
974
|
{
|
|
972
975
|
items: oe.toArray()
|
|
973
976
|
},
|
|
974
977
|
Ye.c()
|
|
975
978
|
),
|
|
976
|
-
selectors:
|
|
979
|
+
selectors: b(
|
|
977
980
|
ue.aggregate(),
|
|
978
981
|
{
|
|
979
982
|
items: ue.toArray()
|
|
980
983
|
},
|
|
981
984
|
Ge.c()
|
|
982
985
|
),
|
|
983
|
-
declarations:
|
|
986
|
+
declarations: b(
|
|
984
987
|
ce.aggregate(),
|
|
985
988
|
{
|
|
986
989
|
items: ce.toArray()
|
|
@@ -989,15 +992,15 @@ function wi(i, t = {}) {
|
|
|
989
992
|
)
|
|
990
993
|
},
|
|
991
994
|
selectors: {
|
|
992
|
-
total:
|
|
995
|
+
total: H,
|
|
993
996
|
totalUnique: ht,
|
|
994
|
-
uniquenessRatio: x(ht,
|
|
995
|
-
specificity:
|
|
997
|
+
uniquenessRatio: x(ht, H),
|
|
998
|
+
specificity: b(
|
|
996
999
|
{
|
|
997
1000
|
/** @type Specificity */
|
|
998
|
-
min:
|
|
1001
|
+
min: U === void 0 ? [0, 0, 0] : U,
|
|
999
1002
|
/** @type Specificity */
|
|
1000
|
-
max:
|
|
1003
|
+
max: M === void 0 ? [0, 0, 0] : M,
|
|
1001
1004
|
/** @type Specificity */
|
|
1002
1005
|
sum: [Se.sum, ve.sum, qe.sum],
|
|
1003
1006
|
/** @type Specificity */
|
|
@@ -1009,31 +1012,31 @@ function wi(i, t = {}) {
|
|
|
1009
1012
|
},
|
|
1010
1013
|
Ne.c()
|
|
1011
1014
|
),
|
|
1012
|
-
complexity:
|
|
1015
|
+
complexity: b(
|
|
1013
1016
|
gt,
|
|
1014
1017
|
et.c(),
|
|
1015
1018
|
{
|
|
1016
1019
|
items: G.toArray()
|
|
1017
1020
|
}
|
|
1018
1021
|
),
|
|
1019
|
-
id:
|
|
1022
|
+
id: b(
|
|
1020
1023
|
he.c(),
|
|
1021
1024
|
{
|
|
1022
|
-
ratio: x(he.size(),
|
|
1025
|
+
ratio: x(he.size(), H)
|
|
1023
1026
|
}
|
|
1024
1027
|
),
|
|
1025
1028
|
pseudoClasses: it.c(),
|
|
1026
|
-
accessibility:
|
|
1029
|
+
accessibility: b(
|
|
1027
1030
|
me.c(),
|
|
1028
1031
|
{
|
|
1029
|
-
ratio: x(me.size(),
|
|
1032
|
+
ratio: x(me.size(), H)
|
|
1030
1033
|
}
|
|
1031
1034
|
),
|
|
1032
1035
|
keyframes: fe.c(),
|
|
1033
|
-
prefixed:
|
|
1036
|
+
prefixed: b(
|
|
1034
1037
|
pe.c(),
|
|
1035
1038
|
{
|
|
1036
|
-
ratio: x(pe.size(),
|
|
1039
|
+
ratio: x(pe.size(), H)
|
|
1037
1040
|
}
|
|
1038
1041
|
),
|
|
1039
1042
|
combinators: rt.c()
|
|
@@ -1052,20 +1055,20 @@ function wi(i, t = {}) {
|
|
|
1052
1055
|
},
|
|
1053
1056
|
complexity: yt
|
|
1054
1057
|
},
|
|
1055
|
-
properties:
|
|
1058
|
+
properties: b(
|
|
1056
1059
|
K.c(),
|
|
1057
1060
|
{
|
|
1058
|
-
prefixed:
|
|
1061
|
+
prefixed: b(
|
|
1059
1062
|
we.c(),
|
|
1060
1063
|
{
|
|
1061
1064
|
ratio: x(we.size(), K.size())
|
|
1062
1065
|
}
|
|
1063
1066
|
),
|
|
1064
|
-
custom:
|
|
1067
|
+
custom: b(
|
|
1065
1068
|
Z.c(),
|
|
1066
1069
|
{
|
|
1067
1070
|
ratio: x(Z.size(), K.size()),
|
|
1068
|
-
importants:
|
|
1071
|
+
importants: b(
|
|
1069
1072
|
ge.c(),
|
|
1070
1073
|
{
|
|
1071
1074
|
ratio: x(ge.size(), Z.size())
|
|
@@ -1073,7 +1076,7 @@ function wi(i, t = {}) {
|
|
|
1073
1076
|
)
|
|
1074
1077
|
}
|
|
1075
1078
|
),
|
|
1076
|
-
browserhacks:
|
|
1079
|
+
browserhacks: b(
|
|
1077
1080
|
ye.c(),
|
|
1078
1081
|
{
|
|
1079
1082
|
ratio: x(ye.size(), K.size())
|
|
@@ -1083,10 +1086,10 @@ function wi(i, t = {}) {
|
|
|
1083
1086
|
}
|
|
1084
1087
|
),
|
|
1085
1088
|
values: {
|
|
1086
|
-
colors:
|
|
1087
|
-
|
|
1089
|
+
colors: b(
|
|
1090
|
+
T.count(),
|
|
1088
1091
|
{
|
|
1089
|
-
formats:
|
|
1092
|
+
formats: I.c()
|
|
1090
1093
|
}
|
|
1091
1094
|
),
|
|
1092
1095
|
gradients: ct.c(),
|
|
@@ -1108,8 +1111,8 @@ function wi(i, t = {}) {
|
|
|
1108
1111
|
keywords: B.c()
|
|
1109
1112
|
},
|
|
1110
1113
|
__meta__: {
|
|
1111
|
-
parseTime:
|
|
1112
|
-
analyzeTime: Date.now() -
|
|
1114
|
+
parseTime: F - A,
|
|
1115
|
+
analyzeTime: Date.now() - F,
|
|
1113
1116
|
total: Date.now() - n
|
|
1114
1117
|
}
|
|
1115
1118
|
};
|
|
@@ -1120,7 +1123,7 @@ function _t(i, t) {
|
|
|
1120
1123
|
export {
|
|
1121
1124
|
wi as analyze,
|
|
1122
1125
|
_t as compareSpecificity,
|
|
1123
|
-
|
|
1126
|
+
D as hasVendorPrefix,
|
|
1124
1127
|
Lt as isAccessibilitySelector,
|
|
1125
1128
|
Gt as isMediaBrowserhack,
|
|
1126
1129
|
ui as isPropertyHack,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectwallace/css-analyzer",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"author": "Bart Veneman",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@codecov/vite-plugin": "^1.9.0",
|
|
52
52
|
"c8": "^10.1.3",
|
|
53
53
|
"uvu": "^0.5.6",
|
|
54
|
-
"vite": "^6.
|
|
54
|
+
"vite": "^6.3.4",
|
|
55
55
|
"vite-plugin-dts": "^4.5.0"
|
|
56
56
|
},
|
|
57
57
|
"mangle": {
|