@a.incantalupo/web-tools 0.3.1 → 0.5.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.
- package/README.md +1 -0
- package/dist/audit/lighthouse-cli.js +4 -1
- package/dist/audit/lighthouse.js +8 -5
- package/package.json +16 -5
package/README.md
CHANGED
|
@@ -47,6 +47,7 @@ FAIL /contact reading ease 61 · 1 fail · 2 warn (small-text, target-44)
|
|
|
47
47
|
| Largest contentful paint | 2.5 s |
|
|
48
48
|
| Layout shift (CLS) | 0.1 |
|
|
49
49
|
| The server's first byte | 800 ms |
|
|
50
|
+
| Total blocking time (main-thread work while loading; the lab's stand-in for INP) | 200 ms |
|
|
50
51
|
| Scripts, as sent | 100 kB |
|
|
51
52
|
|
|
52
53
|
- A `FAIL` line names the number and its limit; for the largest paint, also the element that was timed.
|
|
@@ -47,7 +47,8 @@ await mkdir(outDir, { recursive: true });
|
|
|
47
47
|
const runs = await runLighthouse(positionals, outDir, times);
|
|
48
48
|
// The limits of a public page. Lab numbers on a simulated mid-range phone and on a
|
|
49
49
|
// desktop: limits, not goals.
|
|
50
|
-
|
|
50
|
+
// TBT: the lab's stand-in for INP (main-thread work while the page loads); INP itself is field-only.
|
|
51
|
+
const LIMITS = { lcpMs: 2500, cls: 0.1, ttfbMs: 800, tbtMs: 200, scriptBytes: 100 * 1024 };
|
|
51
52
|
const judging = values.budget || minPerf != null;
|
|
52
53
|
const over = [];
|
|
53
54
|
for (const r of runs) {
|
|
@@ -66,6 +67,8 @@ for (const r of runs) {
|
|
|
66
67
|
add("cls", `CLS ${m.cls.toFixed(3)} over ${LIMITS.cls}`);
|
|
67
68
|
if (m.ttfbMs != null && m.ttfbMs > LIMITS.ttfbMs)
|
|
68
69
|
add("ttfb", `first byte ${Math.round(m.ttfbMs)} ms over ${LIMITS.ttfbMs} ms`);
|
|
70
|
+
if (m.tbtMs != null && m.tbtMs > LIMITS.tbtMs)
|
|
71
|
+
add("tbt", `blocking time ${Math.round(m.tbtMs)} ms over ${LIMITS.tbtMs} ms`);
|
|
69
72
|
if (r.scriptBytes != null && r.scriptBytes > LIMITS.scriptBytes)
|
|
70
73
|
add("js", `scripts ${Math.round(r.scriptBytes / 1024)} kB over ${LIMITS.scriptBytes / 1024} kB`);
|
|
71
74
|
}
|
package/dist/audit/lighthouse.js
CHANGED
|
@@ -16,11 +16,14 @@ const METRICS = {
|
|
|
16
16
|
speedIndexMs: "speed-index",
|
|
17
17
|
ttfbMs: "server-response-time",
|
|
18
18
|
};
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* The LCP element, from Lighthouse 13's "LCP breakdown" insight: a list whose items are
|
|
21
|
+
* the subparts table and the element's node (`type: "node"`).
|
|
22
|
+
*/
|
|
20
23
|
function lcpElementOf(details) {
|
|
21
|
-
const
|
|
22
|
-
[];
|
|
23
|
-
const node =
|
|
24
|
+
const items = details
|
|
25
|
+
?.items ?? [];
|
|
26
|
+
const node = items.find((i) => i?.type === "node");
|
|
24
27
|
if (!node?.selector && !node?.snippet)
|
|
25
28
|
return null;
|
|
26
29
|
const snippet = (node.snippet ?? "").replace(/\s+/g, " ");
|
|
@@ -148,7 +151,7 @@ export async function runLighthouse(urls, outDir, times = 1) {
|
|
|
148
151
|
error: lhr.runtimeError?.message ?? metricError ?? null,
|
|
149
152
|
reportFile,
|
|
150
153
|
screenshot,
|
|
151
|
-
lcpElement: lcpElementOf(lhr.audits["
|
|
154
|
+
lcpElement: lcpElementOf(lhr.audits["lcp-breakdown-insight"]?.details),
|
|
152
155
|
},
|
|
153
156
|
});
|
|
154
157
|
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a.incantalupo/web-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Checks and captures for any website: readability and contrast, screenshots, style snapshots and diffs, glyph and image checks, a site audit with niche profiles, your own signed-in browser.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"stack-tools": "dist/cli.js"
|
|
8
8
|
},
|
|
9
9
|
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./audit": {
|
|
15
|
+
"types": "./dist/audit/index.d.ts",
|
|
16
|
+
"default": "./dist/audit/index.js"
|
|
17
|
+
}
|
|
12
18
|
},
|
|
13
|
-
"files": [
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
14
23
|
"license": "MIT",
|
|
24
|
+
"engines": { "node": ">=22.19" },
|
|
15
25
|
"repository": {
|
|
16
26
|
"type": "git",
|
|
17
27
|
"url": "git+https://github.com/Alessandro-Incantalupo/web-stack-kb.git",
|
|
@@ -20,12 +30,13 @@
|
|
|
20
30
|
"scripts": {
|
|
21
31
|
"build": "rm -rf dist && tsc -p tsconfig.json && chmod +x dist/cli.js",
|
|
22
32
|
"check": "tsc -p tsconfig.json --noEmit",
|
|
33
|
+
"test": "node --test 'test/*.test.ts'",
|
|
23
34
|
"prepublishOnly": "pnpm build"
|
|
24
35
|
},
|
|
25
36
|
"dependencies": {
|
|
26
37
|
"cheerio": "^1.1.0",
|
|
27
38
|
"chrome-launcher": "^1.2.0",
|
|
28
|
-
"lighthouse": "^
|
|
39
|
+
"lighthouse": "^13.6.0",
|
|
29
40
|
"playwright-core": "1.56.1"
|
|
30
41
|
},
|
|
31
42
|
"devDependencies": {
|