@projectwallace/css-code-coverage 0.2.1 → 0.2.3
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-code-coverage.js +48 -48
- package/package.json +1 -1
|
@@ -25,9 +25,9 @@ function X(t) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
function P(t) {
|
|
28
|
-
return t.map(({ url: e, text: s, ranges:
|
|
28
|
+
return t.map(({ url: e, text: s, ranges: n }) => {
|
|
29
29
|
if (!s)
|
|
30
|
-
return { url: e, text: s, ranges:
|
|
30
|
+
return { url: e, text: s, ranges: n };
|
|
31
31
|
let c = F(s), f = /* @__PURE__ */ new Set([
|
|
32
32
|
x.EOF,
|
|
33
33
|
x.BadString,
|
|
@@ -36,34 +36,34 @@ function P(t) {
|
|
|
36
36
|
x.Semicolon,
|
|
37
37
|
x.Comment,
|
|
38
38
|
x.Colon
|
|
39
|
-
]), o =
|
|
39
|
+
]), o = n.map(({ start: a, end: i }) => ({ start: a, end: i, tokens: [] }));
|
|
40
40
|
function v(a, i) {
|
|
41
|
-
let
|
|
41
|
+
let r = 0;
|
|
42
42
|
for (let u of o) {
|
|
43
43
|
if (u.start > i) return -1;
|
|
44
44
|
if (u.start <= a && u.end >= i)
|
|
45
|
-
return
|
|
46
|
-
|
|
45
|
+
return r;
|
|
46
|
+
r++;
|
|
47
47
|
}
|
|
48
48
|
return -1;
|
|
49
49
|
}
|
|
50
50
|
let _ = 0;
|
|
51
|
-
$(s, (a, i,
|
|
51
|
+
$(s, (a, i, r) => {
|
|
52
52
|
if (f.has(a)) return;
|
|
53
53
|
_++, a === x.Url && (_ += 2);
|
|
54
|
-
let u = v(i,
|
|
54
|
+
let u = v(i, r);
|
|
55
55
|
u !== -1 && o[u].tokens.push(_);
|
|
56
56
|
});
|
|
57
57
|
let g = /* @__PURE__ */ new Map();
|
|
58
|
-
_ = 0, $(c, (a, i,
|
|
59
|
-
f.has(a) || (_++, a === x.Url && (_ += 2), g.set(_, { start: i, end:
|
|
58
|
+
_ = 0, $(c, (a, i, r) => {
|
|
59
|
+
f.has(a) || (_++, a === x.Url && (_ += 2), g.set(_, { start: i, end: r }));
|
|
60
60
|
});
|
|
61
61
|
let y = [];
|
|
62
62
|
for (let a of o) {
|
|
63
|
-
let i = g.get(a.tokens.at(0)),
|
|
64
|
-
i !== void 0 &&
|
|
63
|
+
let i = g.get(a.tokens.at(0)), r = g.get(a.tokens.at(-1));
|
|
64
|
+
i !== void 0 && r !== void 0 && y.push({
|
|
65
65
|
start: i.start,
|
|
66
|
-
end:
|
|
66
|
+
end: r.end
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
return { url: e, text: c, ranges: y };
|
|
@@ -72,9 +72,9 @@ function P(t) {
|
|
|
72
72
|
function R(t) {
|
|
73
73
|
let e = /* @__PURE__ */ new Map();
|
|
74
74
|
for (let s of t) {
|
|
75
|
-
let
|
|
76
|
-
if (e.has(
|
|
77
|
-
let f = e.get(
|
|
75
|
+
let n = s.text || "";
|
|
76
|
+
if (e.has(n)) {
|
|
77
|
+
let f = e.get(n).ranges;
|
|
78
78
|
for (let o of s.ranges) {
|
|
79
79
|
let v = !1;
|
|
80
80
|
for (let _ of f)
|
|
@@ -85,7 +85,7 @@ function R(t) {
|
|
|
85
85
|
v || f.push(o);
|
|
86
86
|
}
|
|
87
87
|
} else
|
|
88
|
-
e.set(
|
|
88
|
+
e.set(n, {
|
|
89
89
|
url: s.url,
|
|
90
90
|
ranges: s.ranges
|
|
91
91
|
});
|
|
@@ -102,7 +102,7 @@ function D(t) {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
function G(t, e, s) {
|
|
105
|
-
let
|
|
105
|
+
let n = t(e), c = "", f = [], o = 0, v = n.querySelectorAll("style");
|
|
106
106
|
for (let _ of Array.from(v)) {
|
|
107
107
|
let g = _.textContent;
|
|
108
108
|
if (!g.trim()) continue;
|
|
@@ -125,29 +125,29 @@ function H(t) {
|
|
|
125
125
|
}
|
|
126
126
|
function K(t, e) {
|
|
127
127
|
let s = [];
|
|
128
|
-
for (let
|
|
129
|
-
if (!
|
|
130
|
-
let c = D(
|
|
128
|
+
for (let n of t) {
|
|
129
|
+
if (!n.text) continue;
|
|
130
|
+
let c = D(n.url).toLowerCase();
|
|
131
131
|
if (c !== "js") {
|
|
132
132
|
if (c === "css") {
|
|
133
|
-
s.push(
|
|
133
|
+
s.push(n);
|
|
134
134
|
continue;
|
|
135
135
|
}
|
|
136
|
-
if (H(
|
|
136
|
+
if (H(n.text)) {
|
|
137
137
|
if (!e)
|
|
138
138
|
continue;
|
|
139
|
-
let { css: f, ranges: o } = G(e,
|
|
139
|
+
let { css: f, ranges: o } = G(e, n.text, n.ranges);
|
|
140
140
|
s.push({
|
|
141
|
-
url:
|
|
141
|
+
url: n.url,
|
|
142
142
|
text: f,
|
|
143
143
|
ranges: o
|
|
144
144
|
});
|
|
145
145
|
continue;
|
|
146
146
|
}
|
|
147
147
|
s.push({
|
|
148
|
-
url:
|
|
149
|
-
text:
|
|
150
|
-
ranges:
|
|
148
|
+
url: n.url,
|
|
149
|
+
text: n.text,
|
|
150
|
+
ranges: n.ranges
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
153
|
}
|
|
@@ -160,50 +160,50 @@ function Y(t, e) {
|
|
|
160
160
|
let s = t.length;
|
|
161
161
|
if (!q(t))
|
|
162
162
|
throw new TypeError("No valid coverage data found");
|
|
163
|
-
let
|
|
164
|
-
function M(
|
|
165
|
-
let b = d +
|
|
163
|
+
let n = K(t, e), c = P(n), f = R(c), o = Array.from(f).map(([r, { url: u, ranges: L }]) => {
|
|
164
|
+
function M(l, d) {
|
|
165
|
+
let b = d + l.length, N = b + 1, W = /^\s*$/.test(l), k = l.endsWith("}");
|
|
166
166
|
if (!W && !k) {
|
|
167
167
|
for (let m of L)
|
|
168
168
|
if (!(m.start > b || m.end < d)) {
|
|
169
169
|
if (m.start <= d && m.end >= b)
|
|
170
170
|
return !0;
|
|
171
|
-
if (
|
|
171
|
+
if (l.startsWith("@") && m.start > d && m.start < N)
|
|
172
172
|
return !0;
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
return !1;
|
|
176
176
|
}
|
|
177
|
-
let S =
|
|
178
|
-
`), O = S.length, p = new Uint8Array(O), C = 0, B =
|
|
179
|
-
for (let
|
|
180
|
-
let d = S[
|
|
181
|
-
(z && !m && !k || (k || m) && T || k && !T && M(S[
|
|
177
|
+
let S = r.split(`
|
|
178
|
+
`), O = S.length, p = new Uint8Array(O), C = 0, B = r.length, U = 0, E = 0;
|
|
179
|
+
for (let l = 0; l < S.length; l++) {
|
|
180
|
+
let d = S[l], b = E, W = E + d.length + 1, k = /^\s*$/.test(d), m = d.endsWith("}"), z = M(d, b), w = !1, T = l > 0 && p[l - 1] === 1;
|
|
181
|
+
(z && !m && !k || (k || m) && T || k && !T && M(S[l + 1], W)) && (w = !0), p[l] = w ? 1 : 0, w && (C++, U += d.length + 1), E = W;
|
|
182
182
|
}
|
|
183
183
|
let A = [
|
|
184
184
|
{
|
|
185
185
|
start_line: 1,
|
|
186
186
|
is_covered: p[0] === 1,
|
|
187
|
-
end_line:
|
|
188
|
-
total_lines:
|
|
187
|
+
end_line: 1,
|
|
188
|
+
total_lines: 1
|
|
189
189
|
}
|
|
190
190
|
];
|
|
191
|
-
for (let
|
|
192
|
-
let d = p[
|
|
193
|
-
if (
|
|
191
|
+
for (let l = 1; l < p.length; l++) {
|
|
192
|
+
let d = p[l];
|
|
193
|
+
if (d !== p[l - 1]) {
|
|
194
194
|
let b = A.at(-1);
|
|
195
|
-
b.end_line =
|
|
196
|
-
start_line:
|
|
195
|
+
b.end_line = l, b.total_lines = l - b.start_line + 1, A.push({
|
|
196
|
+
start_line: l + 1,
|
|
197
197
|
is_covered: d === 1,
|
|
198
|
-
end_line:
|
|
198
|
+
end_line: l,
|
|
199
199
|
total_lines: 0
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
let I = A.at(-1);
|
|
204
|
-
return I.total_lines = p.length - I.start_line
|
|
204
|
+
return I.total_lines = p.length + 1 - I.start_line, I.end_line = p.length, {
|
|
205
205
|
url: u,
|
|
206
|
-
text:
|
|
206
|
+
text: r,
|
|
207
207
|
ranges: L,
|
|
208
208
|
unused_bytes: B - U,
|
|
209
209
|
used_bytes: U,
|
|
@@ -217,7 +217,7 @@ function Y(t, e) {
|
|
|
217
217
|
chunks: A
|
|
218
218
|
};
|
|
219
219
|
}), { total_lines: v, total_covered_lines: _, total_uncovered_lines: g, total_bytes: y, total_used_bytes: a, total_unused_bytes: i } = o.reduce(
|
|
220
|
-
(
|
|
220
|
+
(r, u) => (r.total_lines += u.total_lines, r.total_covered_lines += u.covered_lines, r.total_uncovered_lines += u.uncovered_lines, r.total_bytes += u.total_bytes, r.total_used_bytes += u.used_bytes, r.total_unused_bytes += u.unused_bytes, r),
|
|
221
221
|
{
|
|
222
222
|
total_lines: 0,
|
|
223
223
|
total_covered_lines: 0,
|