@josueavalosjim/taste-check 0.5.0 → 0.5.2
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/README.md +9 -0
- package/package.json +1 -1
- package/src/cdp.mjs +25 -5
- package/src/runtime.mjs +17 -2
package/README.md
CHANGED
|
@@ -227,6 +227,15 @@ page's own scripts, which is where a theme belongs because the page reads it at
|
|
|
227
227
|
boot. `after` runs once there is a document, for opening a panel or focusing a
|
|
228
228
|
field. Each state's setup is removed before the next one, so they cannot leak.
|
|
229
229
|
|
|
230
|
+
**A foreground composites over its own background. An edge measures against
|
|
231
|
+
what is outside it.** Those are different questions. Text sits on the thing
|
|
232
|
+
behind it, so its own background belongs in the stack. A border is a boundary,
|
|
233
|
+
and 1.4.11 asks whether that boundary can be told apart from what is adjacent
|
|
234
|
+
to it, which is the page rather than the control's own fill. A solid button
|
|
235
|
+
that sets its border to its own background colour measures 1.00:1 the first
|
|
236
|
+
way and 14.68:1 the second, and only one of those is the edge anybody sees.
|
|
237
|
+
Border properties are handled this way for you.
|
|
238
|
+
|
|
230
239
|
Use `againstParent` when the thing being measured is a fill rather than a
|
|
231
240
|
foreground. A selected row with its own background measured against itself
|
|
232
241
|
scores 1.00, which is a pass that means nothing.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@josueavalosjim/taste-check",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Design review in CI with a line down the middle: measured checks that gate the build (WCAG contrast from your tokens or from a real rendered page, one-off values in your markup) and a fresh-eyes model judge whose verdicts stay advisory. Zero dependencies. Ships no design rules of its own.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
package/src/cdp.mjs
CHANGED
|
@@ -224,11 +224,18 @@ export async function connect({ endpoint, browserPath, timeout = 15000 }) {
|
|
|
224
224
|
return result.value;
|
|
225
225
|
},
|
|
226
226
|
/**
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
227
|
+
* Waits for the browser to actually exit before removing its profile.
|
|
228
|
+
*
|
|
229
|
+
* Killing and deleting in the same breath loses a race with Chrome, which
|
|
230
|
+
* is still flushing its profile when the signal arrives. Best effort was
|
|
231
|
+
* not good enough: it left a directory behind on nearly every run, and a
|
|
232
|
+
* tool that litters the temp directory every time CI runs is not one to
|
|
233
|
+
* inflict on anybody.
|
|
234
|
+
*
|
|
235
|
+
* Still incapable of throwing. Teardown must never take down a run whose
|
|
236
|
+
* measurements already succeeded.
|
|
230
237
|
*/
|
|
231
|
-
close() {
|
|
238
|
+
async close() {
|
|
232
239
|
try {
|
|
233
240
|
ws.close();
|
|
234
241
|
} catch {
|
|
@@ -236,7 +243,20 @@ export async function connect({ endpoint, browserPath, timeout = 15000 }) {
|
|
|
236
243
|
}
|
|
237
244
|
if (!child) return;
|
|
238
245
|
try {
|
|
239
|
-
child.
|
|
246
|
+
if (child.exitCode === null && child.signalCode === null) {
|
|
247
|
+
const exited = new Promise((resolve) => child.once('exit', resolve));
|
|
248
|
+
child.kill();
|
|
249
|
+
// SIGTERM is usually enough. If it is not, stop being polite.
|
|
250
|
+
const forced = new Promise((resolve) => setTimeout(resolve, 2000)).then(() => {
|
|
251
|
+
try {
|
|
252
|
+
child.kill('SIGKILL');
|
|
253
|
+
} catch {
|
|
254
|
+
/* already gone */
|
|
255
|
+
}
|
|
256
|
+
return new Promise((resolve) => setTimeout(resolve, 300));
|
|
257
|
+
});
|
|
258
|
+
await Promise.race([exited, forced]);
|
|
259
|
+
}
|
|
240
260
|
} catch {
|
|
241
261
|
/* already gone */
|
|
242
262
|
}
|
package/src/runtime.mjs
CHANGED
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
* 2. It can measure a state, because it can put the page into one first.
|
|
18
18
|
* A theme, an opened panel, a focused input.
|
|
19
19
|
*
|
|
20
|
+
* A foreground composites over its own background. An edge measures against
|
|
21
|
+
* what is outside it. Those are different questions and getting them the same
|
|
22
|
+
* way round produces confident nonsense in both directions.
|
|
23
|
+
*
|
|
20
24
|
* A selector that matches nothing is a failure, not a skipped target. So is a
|
|
21
25
|
* border with no width: you asked for the contrast of an edge that is not
|
|
22
26
|
* being drawn, and the honest answer is that the question is wrong.
|
|
@@ -42,7 +46,18 @@ const MEASURE = `(targets) => targets.map(({ selector, prop, againstParent }) =>
|
|
|
42
46
|
if (!width) return { error: 'has a ' + prop + ' but no width, so no edge is drawn' };
|
|
43
47
|
}
|
|
44
48
|
const layers = [];
|
|
45
|
-
|
|
49
|
+
// Two reasons to start one level up.
|
|
50
|
+
//
|
|
51
|
+
// A fill measured against itself scores 1.00, so againstParent hands us the
|
|
52
|
+
// parent instead.
|
|
53
|
+
//
|
|
54
|
+
// A border is the same, for a different reason. 1.4.11 asks whether the
|
|
55
|
+
// boundary of a control can be told apart from what is adjacent to it, and
|
|
56
|
+
// what is adjacent is the page, not the control's own fill. A solid button
|
|
57
|
+
// that sets its border to its own background colour measures 1.00:1 against
|
|
58
|
+
// that background: true, and an answer to a question nobody asked.
|
|
59
|
+
const outside = againstParent || prop.indexOf('border') === 0;
|
|
60
|
+
let node = outside ? el.parentElement : el;
|
|
46
61
|
if (!node) return { error: 'has no parent to measure against' };
|
|
47
62
|
while (node) {
|
|
48
63
|
const bg = getComputedStyle(node).backgroundColor;
|
|
@@ -147,7 +162,7 @@ export async function runRuntime(config, cwd, { connect: open = connect } = {})
|
|
|
147
162
|
} catch (error) {
|
|
148
163
|
problems.push(`the page could not be measured: ${error.message}`);
|
|
149
164
|
} finally {
|
|
150
|
-
page.close();
|
|
165
|
+
await page.close();
|
|
151
166
|
}
|
|
152
167
|
|
|
153
168
|
return {
|