ultra11y 5.57.3 → 5.57.5
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.opencode/plugins/ultra11y.js +1 -1
- package/dist/cypress-plugin.d.ts +1 -1
- package/dist/cypress.d.ts +2 -2
- package/dist/cypress.mjs +33 -2
- package/dist/{payload-BMFQTm5s.d.ts → payload-BrdH5eEV.d.ts} +11 -1
- package/dist/playwright.d.ts +7 -1
- package/dist/playwright.mjs +69 -3
- package/docker/runner.mjs +16 -1
- package/package.json +1 -1
- package/scripts/ultra11y.mjs +257 -30
- package/skills/review-a11y/SKILL.md +1 -1
- package/skills/review-a11y/scripts/ultra11y.mjs +257 -30
- package/skills/ultra11y/SKILL.md +1 -1
- package/skills/ultra11y/references/e2e.md +20 -1
- package/skills/ultra11y/references/pages.md +3 -2
- package/skills/ultra11y/scripts/ultra11y.mjs +257 -30
- package/skills/ultra11y/templates/gitlab-ci.yml +1 -1
- package/src/adjudicate-subjects.ts +4 -1
- package/src/adjudicate.ts +13 -1
- package/src/audit.ts +17 -7
- package/src/cli.ts +6 -1
- package/src/collector.ts +79 -0
- package/src/dev.ts +11 -1
- package/src/e2e.ts +2 -0
- package/src/graph/imports.ts +82 -1
- package/src/html-report.ts +1 -1
- package/src/integrations/payload.ts +27 -2
- package/src/integrations/playwright.ts +32 -4
- package/src/pages-report.ts +4 -2
- package/src/pages.ts +13 -4
- package/src/report.ts +4 -2
- package/src/rules/cross-registry.ts +9 -2
- package/src/rules/headings.ts +12 -0
- package/src/rules/rule.ts +38 -1
- package/src/scan-local.ts +27 -2
- package/src/scan.ts +24 -1
- package/src/snapshot.ts +55 -3
- package/src/types.ts +9 -2
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"name": "ultra11y",
|
|
11
11
|
"source": "./",
|
|
12
12
|
"description": "RGAA 4.1.2 accessibility audits on a WCAG 2.2 AA core: automatic review before commit, push and pull request, plus dated, evidenced Markdown, HTML and per-page conformance reports in Claude Code.",
|
|
13
|
-
"version": "5.57.
|
|
13
|
+
"version": "5.57.5",
|
|
14
14
|
"author": { "name": "maxgfr" },
|
|
15
15
|
"homepage": "https://github.com/SocialGouv/ultra11y",
|
|
16
16
|
"repository": "https://github.com/SocialGouv/ultra11y",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ultra11y",
|
|
3
3
|
"description": "RGAA 4.1.2 accessibility audits, the French State's standard, on a WCAG 2.2 AA core: automatic review before commit, push and pull request, plus dated, evidenced Markdown, HTML and per-page conformance reports. Never declares conforming what it has not verified.",
|
|
4
|
-
"version": "5.57.
|
|
4
|
+
"version": "5.57.5",
|
|
5
5
|
"author": { "name": "maxgfr" },
|
|
6
6
|
"homepage": "https://github.com/SocialGouv/ultra11y",
|
|
7
7
|
"repository": "https://github.com/SocialGouv/ultra11y",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ultra11y",
|
|
3
3
|
"description": "RGAA 4.1.2 accessibility audits, the French State's standard, on a WCAG 2.2 AA core: automatic review before commit, push and pull request, plus dated, evidenced Markdown, HTML and per-page conformance reports. Never declares conforming what it has not verified.",
|
|
4
|
-
"version": "5.57.
|
|
4
|
+
"version": "5.57.5",
|
|
5
5
|
"author": { "name": "maxgfr", "url": "https://github.com/maxgfr" },
|
|
6
6
|
"homepage": "https://github.com/SocialGouv/ultra11y",
|
|
7
7
|
"repository": "https://github.com/SocialGouv/ultra11y",
|
|
@@ -44,7 +44,7 @@ import { fileURLToPath } from "node:url";
|
|
|
44
44
|
// does not carry it, so a user's own ultra11y.js is never clobbered. Kept as text, not as
|
|
45
45
|
// an export (see above).
|
|
46
46
|
const ULTRA11Y_OPENCODE_PLUGIN = "ULTRA11Y_OPENCODE_PLUGIN";
|
|
47
|
-
const ULTRA11Y_PLUGIN_VERSION = "5.57.
|
|
47
|
+
const ULTRA11Y_PLUGIN_VERSION = "5.57.5";
|
|
48
48
|
const PLUGIN_ID = "ultra11y";
|
|
49
49
|
const SKILL_NAMES = ["ultra11y", "review-a11y"];
|
|
50
50
|
|
package/dist/cypress-plugin.d.ts
CHANGED
package/dist/cypress.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CheckOptions } from './payload-
|
|
2
|
-
export { s as slugify } from './payload-
|
|
1
|
+
import { C as CheckOptions } from './payload-BrdH5eEV.js';
|
|
2
|
+
export { s as slugify } from './payload-BrdH5eEV.js';
|
|
3
3
|
|
|
4
4
|
interface CypressCheckOptions extends CheckOptions {
|
|
5
5
|
/** Capture a viewport screenshot so the pixel tier can run. On by default — the plugin
|
package/dist/cypress.mjs
CHANGED
|
@@ -40,6 +40,27 @@ var COLLECTED_CSS = [
|
|
|
40
40
|
"cursor"
|
|
41
41
|
];
|
|
42
42
|
var COLLECT_MAX_ELEMENTS = 5e3;
|
|
43
|
+
var LOADING_STATE = `(() => {
|
|
44
|
+
const out = [];
|
|
45
|
+
const shown = (e) => {
|
|
46
|
+
const r = e.getBoundingClientRect();
|
|
47
|
+
if (r.width <= 0 && r.height <= 0) return false;
|
|
48
|
+
const s = getComputedStyle(e);
|
|
49
|
+
return s.display !== 'none' && s.visibility !== 'hidden';
|
|
50
|
+
};
|
|
51
|
+
const name = (e) => e.localName + (e.id ? '#' + e.id : '');
|
|
52
|
+
for (const e of Array.from(document.querySelectorAll('[aria-busy="true"]'))) if (shown(e)) out.push('aria-busy="true" ' + name(e));
|
|
53
|
+
for (const e of Array.from(document.querySelectorAll('[role="progressbar"]:not([aria-valuenow]), progress:not([value])'))) if (shown(e)) out.push('indeterminate progress ' + name(e));
|
|
54
|
+
const PHRASE = /^(chargement( en cours)?|veuillez patienter|loading|please wait)\\s*(\\.{1,3}|\u2026)?$/i;
|
|
55
|
+
const text = (e) => (e.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
56
|
+
if (document.body) for (const e of Array.from(document.body.querySelectorAll('p,span,div,li,h1,h2,h3,h4,h5,h6,strong,em,output,[role="status"]'))) {
|
|
57
|
+
const t = text(e);
|
|
58
|
+
if (t.length > 40 || !PHRASE.test(t)) continue;
|
|
59
|
+
if (Array.from(e.children).some((c) => PHRASE.test(text(c)))) continue;
|
|
60
|
+
if (shown(e)) out.push('text "' + t + '" ' + name(e));
|
|
61
|
+
}
|
|
62
|
+
return out.slice(0, 10);
|
|
63
|
+
})()`;
|
|
43
64
|
var COLLECT_SNAPSHOT = `(() => {
|
|
44
65
|
const PROPS = ${JSON.stringify(COLLECTED_CSS)};
|
|
45
66
|
const MAX = ${COLLECT_MAX_ELEMENTS};
|
|
@@ -151,6 +172,12 @@ var COLLECT_SNAPSHOT = `(() => {
|
|
|
151
172
|
lang: document.documentElement.getAttribute('lang') || '',
|
|
152
173
|
url: location.href,
|
|
153
174
|
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
175
|
+
// The document's full height, so the producer knows whether a full-page screenshot adds
|
|
176
|
+
// anything to the viewport one.
|
|
177
|
+
docHeight: Math.max(document.documentElement.scrollHeight, document.body ? document.body.scrollHeight : 0),
|
|
178
|
+
// Still loading at the instant of collection: the markers, or none. Every producer runs
|
|
179
|
+
// this same collector, so every producer can say so \u2014 see LOADING_STATE.
|
|
180
|
+
loading: ${LOADING_STATE},
|
|
154
181
|
styles: { v: 1, entries: styles, truncated: truncated },
|
|
155
182
|
boxes: { v: 1, entries: boxes, truncated: truncated }
|
|
156
183
|
};
|
|
@@ -184,7 +211,7 @@ function stayedOnPage(expected, actual) {
|
|
|
184
211
|
if (a === void 0 || b === void 0) return true;
|
|
185
212
|
return a === b;
|
|
186
213
|
}
|
|
187
|
-
function buildPayload(collected, url, runner, opts, screenshot, probes, axe) {
|
|
214
|
+
function buildPayload(collected, url, runner, opts, screenshot, probes, axe, screenshotFull) {
|
|
188
215
|
const id = opts.as || slugify(url);
|
|
189
216
|
return {
|
|
190
217
|
meta: {
|
|
@@ -207,13 +234,17 @@ function buildPayload(collected, url, runner, opts, screenshot, probes, axe) {
|
|
|
207
234
|
...collected.doctype !== void 0 ? { doctype: collected.doctype } : {},
|
|
208
235
|
...opts.auth !== void 0 ? { auth: opts.auth } : {},
|
|
209
236
|
...opts.sources ? { sources: opts.sources } : {},
|
|
210
|
-
...opts.notes ? { notes: opts.notes } : {}
|
|
237
|
+
...opts.notes ? { notes: opts.notes } : {},
|
|
238
|
+
// Still loading when collected: named, so the report can say so and the audit concludes
|
|
239
|
+
// nothing from this page's silence.
|
|
240
|
+
...collected.loading?.length ? { loading: collected.loading } : {}
|
|
211
241
|
},
|
|
212
242
|
dom: collected.dom,
|
|
213
243
|
styles: collected.styles,
|
|
214
244
|
boxes: collected.boxes,
|
|
215
245
|
css: collected.css,
|
|
216
246
|
...screenshot ? { screenshot } : {},
|
|
247
|
+
...screenshotFull ? { screenshotFull } : {},
|
|
217
248
|
// What the live probes measured, when the caller asked for them. It rides in the payload
|
|
218
249
|
// because `snapshot write` persists it beside the DOM — the audit that folds it runs later
|
|
219
250
|
// and in another process, so a measurement kept in memory decides nothing.
|
|
@@ -21,6 +21,8 @@ interface SnapshotPayload {
|
|
|
21
21
|
boxes?: unknown;
|
|
22
22
|
css?: unknown;
|
|
23
23
|
screenshot?: string;
|
|
24
|
+
/** The whole page, height-bounded (FULL_SCREENSHOT_MAX_HEIGHT) — for the report's reader. */
|
|
25
|
+
screenshotFull?: string;
|
|
24
26
|
/** What the live probes measured, when the caller ran them. */
|
|
25
27
|
probes?: unknown;
|
|
26
28
|
/** What axe-core found on this page, when the caller ran it. */
|
|
@@ -41,8 +43,16 @@ interface CheckOptions {
|
|
|
41
43
|
sources?: string[];
|
|
42
44
|
/** Reproduction notes carried into the auditor ticket. */
|
|
43
45
|
notes?: string;
|
|
44
|
-
/** Capture a viewport screenshot for the pixel tier (Playwright: on by default)
|
|
46
|
+
/** Capture a viewport screenshot for the pixel tier (Playwright: on by default), and — when
|
|
47
|
+
* the page is taller than the viewport — a full-page one beside it for the report. */
|
|
45
48
|
screenshot?: boolean;
|
|
49
|
+
/** How long to wait, before collecting, for the page to stop declaring itself loading —
|
|
50
|
+
* `aria-busy="true"`, an indeterminate progress bar, a « Chargement… » standing in for the
|
|
51
|
+
* content (default 10 000 ms; `0` checks without waiting). A page still loading when it
|
|
52
|
+
* runs out is recorded anyway, MARKED (`meta.loading`) and reported « capture en état de
|
|
53
|
+
* chargement »: its findings count, its silence does not. Playwright only — Cypress records
|
|
54
|
+
* the markers it sees but leaves the waiting to the test's own `should`. */
|
|
55
|
+
loadingTimeoutMs?: number;
|
|
46
56
|
/** The path you NAVIGATED to. Given it, the fixture refuses to record a page the browser
|
|
47
57
|
* did not stay on — a guarded route that redirected, a session that expired — instead of
|
|
48
58
|
* filing that other screen under this page's `as`/`name`. Nothing about such a snapshot
|
package/dist/playwright.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import { C as CheckOptions, A as AuditLike } from './payload-
|
|
1
|
+
import { C as CheckOptions, A as AuditLike } from './payload-BrdH5eEV.js';
|
|
2
2
|
|
|
3
3
|
interface PlaywrightPage {
|
|
4
4
|
evaluate(script: string): Promise<unknown>;
|
|
5
5
|
screenshot(opts: {
|
|
6
6
|
fullPage: boolean;
|
|
7
|
+
clip?: {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
};
|
|
7
13
|
}): Promise<Buffer>;
|
|
8
14
|
url(): string;
|
|
9
15
|
viewportSize?(): {
|
package/dist/playwright.mjs
CHANGED
|
@@ -45,6 +45,44 @@ var COLLECTED_CSS = [
|
|
|
45
45
|
"cursor"
|
|
46
46
|
];
|
|
47
47
|
var COLLECT_MAX_ELEMENTS = 5e3;
|
|
48
|
+
var LOADING_STATE = `(() => {
|
|
49
|
+
const out = [];
|
|
50
|
+
const shown = (e) => {
|
|
51
|
+
const r = e.getBoundingClientRect();
|
|
52
|
+
if (r.width <= 0 && r.height <= 0) return false;
|
|
53
|
+
const s = getComputedStyle(e);
|
|
54
|
+
return s.display !== 'none' && s.visibility !== 'hidden';
|
|
55
|
+
};
|
|
56
|
+
const name = (e) => e.localName + (e.id ? '#' + e.id : '');
|
|
57
|
+
for (const e of Array.from(document.querySelectorAll('[aria-busy="true"]'))) if (shown(e)) out.push('aria-busy="true" ' + name(e));
|
|
58
|
+
for (const e of Array.from(document.querySelectorAll('[role="progressbar"]:not([aria-valuenow]), progress:not([value])'))) if (shown(e)) out.push('indeterminate progress ' + name(e));
|
|
59
|
+
const PHRASE = /^(chargement( en cours)?|veuillez patienter|loading|please wait)\\s*(\\.{1,3}|\u2026)?$/i;
|
|
60
|
+
const text = (e) => (e.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
61
|
+
if (document.body) for (const e of Array.from(document.body.querySelectorAll('p,span,div,li,h1,h2,h3,h4,h5,h6,strong,em,output,[role="status"]'))) {
|
|
62
|
+
const t = text(e);
|
|
63
|
+
if (t.length > 40 || !PHRASE.test(t)) continue;
|
|
64
|
+
if (Array.from(e.children).some((c) => PHRASE.test(text(c)))) continue;
|
|
65
|
+
if (shown(e)) out.push('text "' + t + '" ' + name(e));
|
|
66
|
+
}
|
|
67
|
+
return out.slice(0, 10);
|
|
68
|
+
})()`;
|
|
69
|
+
async function waitForLoaded(page, timeoutMs, intervalMs = 150) {
|
|
70
|
+
const started = Date.now();
|
|
71
|
+
for (; ; ) {
|
|
72
|
+
let markers = [];
|
|
73
|
+
try {
|
|
74
|
+
const r = await page.evaluate(LOADING_STATE);
|
|
75
|
+
markers = Array.isArray(r) ? r.filter((m) => typeof m === "string") : [];
|
|
76
|
+
} catch {
|
|
77
|
+
return { markers: [], waitedMs: Date.now() - started };
|
|
78
|
+
}
|
|
79
|
+
const waitedMs = Date.now() - started;
|
|
80
|
+
if (!markers.length || waitedMs >= timeoutMs) return { markers, waitedMs };
|
|
81
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(intervalMs, Math.max(1, timeoutMs - waitedMs))));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
var LOADING_TIMEOUT_MS = 1e4;
|
|
85
|
+
var FULL_SCREENSHOT_MAX_HEIGHT = 8e3;
|
|
48
86
|
var COLLECT_SNAPSHOT = `(() => {
|
|
49
87
|
const PROPS = ${JSON.stringify(COLLECTED_CSS)};
|
|
50
88
|
const MAX = ${COLLECT_MAX_ELEMENTS};
|
|
@@ -156,6 +194,12 @@ var COLLECT_SNAPSHOT = `(() => {
|
|
|
156
194
|
lang: document.documentElement.getAttribute('lang') || '',
|
|
157
195
|
url: location.href,
|
|
158
196
|
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
197
|
+
// The document's full height, so the producer knows whether a full-page screenshot adds
|
|
198
|
+
// anything to the viewport one.
|
|
199
|
+
docHeight: Math.max(document.documentElement.scrollHeight, document.body ? document.body.scrollHeight : 0),
|
|
200
|
+
// Still loading at the instant of collection: the markers, or none. Every producer runs
|
|
201
|
+
// this same collector, so every producer can say so \u2014 see LOADING_STATE.
|
|
202
|
+
loading: ${LOADING_STATE},
|
|
159
203
|
styles: { v: 1, entries: styles, truncated: truncated },
|
|
160
204
|
boxes: { v: 1, entries: boxes, truncated: truncated }
|
|
161
205
|
};
|
|
@@ -1317,7 +1361,7 @@ function stayedOnPage(expected, actual) {
|
|
|
1317
1361
|
if (a === void 0 || b === void 0) return true;
|
|
1318
1362
|
return a === b;
|
|
1319
1363
|
}
|
|
1320
|
-
function buildPayload(collected, url, runner, opts, screenshot, probes, axe) {
|
|
1364
|
+
function buildPayload(collected, url, runner, opts, screenshot, probes, axe, screenshotFull) {
|
|
1321
1365
|
const id = opts.as || slugify(url);
|
|
1322
1366
|
return {
|
|
1323
1367
|
meta: {
|
|
@@ -1340,13 +1384,17 @@ function buildPayload(collected, url, runner, opts, screenshot, probes, axe) {
|
|
|
1340
1384
|
...collected.doctype !== void 0 ? { doctype: collected.doctype } : {},
|
|
1341
1385
|
...opts.auth !== void 0 ? { auth: opts.auth } : {},
|
|
1342
1386
|
...opts.sources ? { sources: opts.sources } : {},
|
|
1343
|
-
...opts.notes ? { notes: opts.notes } : {}
|
|
1387
|
+
...opts.notes ? { notes: opts.notes } : {},
|
|
1388
|
+
// Still loading when collected: named, so the report can say so and the audit concludes
|
|
1389
|
+
// nothing from this page's silence.
|
|
1390
|
+
...collected.loading?.length ? { loading: collected.loading } : {}
|
|
1344
1391
|
},
|
|
1345
1392
|
dom: collected.dom,
|
|
1346
1393
|
styles: collected.styles,
|
|
1347
1394
|
boxes: collected.boxes,
|
|
1348
1395
|
css: collected.css,
|
|
1349
1396
|
...screenshot ? { screenshot } : {},
|
|
1397
|
+
...screenshotFull ? { screenshotFull } : {},
|
|
1350
1398
|
// What the live probes measured, when the caller asked for them. It rides in the payload
|
|
1351
1399
|
// because `snapshot write` persists it beside the DOM — the audit that folds it runs later
|
|
1352
1400
|
// and in another process, so a measurement kept in memory decides nothing.
|
|
@@ -1527,14 +1575,32 @@ async function runAxe(page, mode) {
|
|
|
1527
1575
|
return void 0;
|
|
1528
1576
|
}
|
|
1529
1577
|
}
|
|
1578
|
+
async function fullPageShot(page, collected) {
|
|
1579
|
+
const vp = collected.viewport;
|
|
1580
|
+
const height = Math.min(collected.docHeight ?? 0, FULL_SCREENSHOT_MAX_HEIGHT);
|
|
1581
|
+
if (!vp?.width || !vp.height || height <= vp.height) return void 0;
|
|
1582
|
+
try {
|
|
1583
|
+
return (await page.screenshot({ fullPage: true, clip: { x: 0, y: 0, width: vp.width, height } })).toString("base64");
|
|
1584
|
+
} catch {
|
|
1585
|
+
return void 0;
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1530
1588
|
async function checkA11y(page, opts = {}) {
|
|
1589
|
+
const settled = await waitForLoaded(page, opts.loadingTimeoutMs ?? LOADING_TIMEOUT_MS);
|
|
1531
1590
|
const collected = await page.evaluate(COLLECT_SNAPSHOT);
|
|
1591
|
+
if (collected.loading?.length) {
|
|
1592
|
+
console.warn(
|
|
1593
|
+
`ultra11y: capture en \xE9tat de chargement \u2014 "${opts.as ?? opts.name ?? collected.url ?? page.url()}" still showed ${collected.loading.join(", ")} after ${settled.waitedMs} ms. Recorded and marked: its findings count, its silence does not. Wait for the content in the test, or raise \`loadingTimeoutMs\`.`
|
|
1594
|
+
);
|
|
1595
|
+
}
|
|
1532
1596
|
let shot;
|
|
1597
|
+
let fullShot;
|
|
1533
1598
|
if (opts.screenshot !== false) {
|
|
1534
1599
|
try {
|
|
1535
1600
|
shot = (await page.screenshot({ fullPage: false })).toString("base64");
|
|
1536
1601
|
} catch {
|
|
1537
1602
|
}
|
|
1603
|
+
fullShot = await fullPageShot(page, collected);
|
|
1538
1604
|
}
|
|
1539
1605
|
const url = collected.url || page.url();
|
|
1540
1606
|
if (opts.expectPath && !stayedOnPage(opts.expectPath, url)) {
|
|
@@ -1557,7 +1623,7 @@ async function checkA11y(page, opts = {}) {
|
|
|
1557
1623
|
}
|
|
1558
1624
|
}
|
|
1559
1625
|
const axe = await runAxe(page, opts.axe ?? "auto");
|
|
1560
|
-
const payload = buildPayload(collected, url, "playwright", opts, shot, probes, axe);
|
|
1626
|
+
const payload = buildPayload(collected, url, "playwright", opts, shot, probes, axe, fullShot);
|
|
1561
1627
|
const result = auditSnapshot(payload);
|
|
1562
1628
|
if (opts.pdf !== false) {
|
|
1563
1629
|
try {
|
package/docker/runner.mjs
CHANGED
|
@@ -3,12 +3,21 @@ import axe from "axe-core";
|
|
|
3
3
|
const target = process.argv[2];
|
|
4
4
|
const isFile = target.startsWith("/work/");
|
|
5
5
|
const SNAPSHOT = process.env.ULTRA11Y_SNAPSHOT !== "0";
|
|
6
|
-
const COLLECT = "(() => {\n const PROPS = [\"color\",\"backgroundColor\",\"backgroundImage\",\"fontSize\",\"fontWeight\",\"fontStyle\",\"textDecorationLine\",\"textTransform\",\"lineHeight\",\"letterSpacing\",\"wordSpacing\",\"whiteSpace\",\"display\",\"visibility\",\"opacity\",\"position\",\"overflowX\",\"overflowY\",\"outlineStyle\",\"outlineWidth\",\"outlineColor\",\"borderTopStyle\",\"borderRightStyle\",\"borderBottomStyle\",\"borderLeftStyle\",\"borderTopWidth\",\"borderRightWidth\",\"borderBottomWidth\",\"borderLeftWidth\",\"borderTopColor\",\"borderRightColor\",\"borderBottomColor\",\"borderLeftColor\",\"boxShadow\",\"cursor\"];\n const MAX = 5000;\n // The ordinal is a JOIN KEY against parseHtml(dom), so the walk must enumerate elements\n // exactly as a reparse of the serialisation below will (#101). querySelectorAll('*') did not:\n // - an element appended INSIDE a raw-text element (Next's dev overlay puts <nextjs-portal>\n // in a <script>) is serialised as that element's raw text, and a reparse reads text —\n // one ordinal too many, and every digest refused from there on;\n // - <template> contents are serialised and reparsed as elements, but live in\n // template.content, which querySelectorAll never traverses — one ordinal too few.\n // Pre-order, children of the raw-text elements HTML parsers (htmlparser2 included) treat as\n // text skipped, template.content descended.\n const RAW_TEXT = new Set(['script', 'style', 'title', 'textarea', 'xmp', 'iframe', 'noembed', 'noframes']);\n const els = [];\n const walkElements = (parent) => {\n for (const child of parent.children) {\n els.push(child);\n const name = child.localName;\n if (RAW_TEXT.has(name)) continue;\n // With scripting on, a <noscript>'s content is raw TEXT to the browser, while the reparse\n // reads it as elements (#112). Parse that text with the page's own parser and count what\n // it yields, in place, so every later ordinal still lines up. The inert parsed nodes have\n // no computed style and an empty box, which the rules read as « nothing measured ».\n if (name === 'noscript' && child.children.length === 0 && (child.textContent || '').includes('<')) {\n const parsed = document.createElement('template');\n parsed.innerHTML = child.textContent || '';\n walkElements(parsed.content);\n continue;\n }\n walkElements(name === 'template' && child.content ? child.content : child);\n }\n };\n walkElements(document);\n const styles = [];\n const boxes = [];\n const n = Math.min(els.length, MAX);\n for (let i = 0; i < n; i++) {\n const el = els[i];\n const tag = el.tagName.toLowerCase();\n const cs = getComputedStyle(el);\n const css = {};\n for (const p of PROPS) {\n const v = cs[p];\n if (v !== undefined && v !== null && v !== '') css[p] = String(v);\n }\n styles.push({ i: i, tag: tag, css: css });\n const r = el.getBoundingClientRect();\n boxes.push({ i: i, tag: tag, x: Math.round(r.left), y: Math.round(r.top), w: Math.round(r.width), h: Math.round(r.height) });\n }\n // The page's own stylesheets. Some criteria are properties of the STYLESHEET rather than of\n // any element's computed style — focus styling removed with no replacement (2.4.7), a media\n // query that locks the orientation (1.3.4) — and this is the only place they exist.\n // A cross-origin sheet throws on .cssRules: COUNT those instead of ignoring them, so a rule\n // reading this digest can tell \"nothing there\" apart from \"I could not look\".\n // The cap is on the ORDINARY pool only, and the traversal never stops early.\n //\n // It used to return the moment the pool filled, which abandoned every remaining sheet —\n // and on a design-system app the pool fills long before the end. Measured on a real capture\n // of 38 pages: all 38 came back truncated, so rendered-focus-not-visible declined on every\n // one of them and 2.4.7 could never be decided by any number of scans. The rule was right to\n // decline (a :focus rule might have been among the dropped ones); the collector was wrong to\n // make that unavoidable.\n //\n // So the rules a rendered criterion actually READS — :focus styling, orientation locks,\n // pinned positioning, animation — are kept whatever the pool is doing, and truncated now\n // means \"some ordinary rule was dropped\", which is a much weaker statement. A rule can then\n // ask for what it needs instead of refusing on a cap that never concerned it.\n const cssRules = [];\n let unreadable = 0;\n let dropped = 0;\n const MAXR = 4000;\n const camel = (p) => p.replace(/-([a-z])/g, (_, c) => c.toUpperCase());\n const KEEP_SELECTOR = /:focus|:target|:active/i;\n const KEEP_PROP = /^(?:outline|position|animation|transition|transform)/;\n const walk = (list, media) => {\n for (const r of list) {\n if (typeof r.selectorText === 'string' && r.style) {\n const decls = {};\n for (let i = 0; i < r.style.length; i++) {\n const prop = r.style[i];\n decls[camel(prop)] = r.style.getPropertyValue(prop);\n }\n const keep = KEEP_SELECTOR.test(r.selectorText) || Object.keys(decls).some((k) => KEEP_PROP.test(k));\n if (cssRules.length >= MAXR && !keep) { dropped++; continue; }\n cssRules.push(media ? { selector: r.selectorText, media: media, decls: decls } : { selector: r.selectorText, decls: decls });\n } else if (r.cssRules) {\n const cond = r.conditionText || (r.media && r.media.mediaText) || media;\n walk(r.cssRules, cond);\n }\n }\n };\n for (const sheet of document.styleSheets) {\n try {\n walk(sheet.cssRules, undefined);\n } catch (e) {\n unreadable++;\n }\n }\n\n const truncated = els.length > MAX;\n return {\n dom: document.documentElement.outerHTML,\n css: { v: 1, rules: cssRules, unreadable: unreadable, truncated: dropped > 0, dropped: dropped },\n title: document.title,\n // The doctype is NOT part of documentElement.outerHTML, so a capture that records only\n // the DOM drops it — and RGAA 8.1 (is a doctype present, valid, and before <html>?) then\n // has nothing to look at. Recorded as its own field for that reason.\n doctype: document.doctype ? '<!DOCTYPE ' + document.doctype.name + (document.doctype.publicId ? ' PUBLIC \"' + document.doctype.publicId + '\"' : '') + (document.doctype.systemId ? ' \"' + document.doctype.systemId + '\"' : '') + '>' : '',\n lang: document.documentElement.getAttribute('lang') || '',\n url: location.href,\n viewport: { width: window.innerWidth, height: window.innerHeight },\n styles: { v: 1, entries: styles, truncated: truncated },\n boxes: { v: 1, entries: boxes, truncated: truncated }\n };\n})()";
|
|
6
|
+
const COLLECT = "(() => {\n const PROPS = [\"color\",\"backgroundColor\",\"backgroundImage\",\"fontSize\",\"fontWeight\",\"fontStyle\",\"textDecorationLine\",\"textTransform\",\"lineHeight\",\"letterSpacing\",\"wordSpacing\",\"whiteSpace\",\"display\",\"visibility\",\"opacity\",\"position\",\"overflowX\",\"overflowY\",\"outlineStyle\",\"outlineWidth\",\"outlineColor\",\"borderTopStyle\",\"borderRightStyle\",\"borderBottomStyle\",\"borderLeftStyle\",\"borderTopWidth\",\"borderRightWidth\",\"borderBottomWidth\",\"borderLeftWidth\",\"borderTopColor\",\"borderRightColor\",\"borderBottomColor\",\"borderLeftColor\",\"boxShadow\",\"cursor\"];\n const MAX = 5000;\n // The ordinal is a JOIN KEY against parseHtml(dom), so the walk must enumerate elements\n // exactly as a reparse of the serialisation below will (#101). querySelectorAll('*') did not:\n // - an element appended INSIDE a raw-text element (Next's dev overlay puts <nextjs-portal>\n // in a <script>) is serialised as that element's raw text, and a reparse reads text —\n // one ordinal too many, and every digest refused from there on;\n // - <template> contents are serialised and reparsed as elements, but live in\n // template.content, which querySelectorAll never traverses — one ordinal too few.\n // Pre-order, children of the raw-text elements HTML parsers (htmlparser2 included) treat as\n // text skipped, template.content descended.\n const RAW_TEXT = new Set(['script', 'style', 'title', 'textarea', 'xmp', 'iframe', 'noembed', 'noframes']);\n const els = [];\n const walkElements = (parent) => {\n for (const child of parent.children) {\n els.push(child);\n const name = child.localName;\n if (RAW_TEXT.has(name)) continue;\n // With scripting on, a <noscript>'s content is raw TEXT to the browser, while the reparse\n // reads it as elements (#112). Parse that text with the page's own parser and count what\n // it yields, in place, so every later ordinal still lines up. The inert parsed nodes have\n // no computed style and an empty box, which the rules read as « nothing measured ».\n if (name === 'noscript' && child.children.length === 0 && (child.textContent || '').includes('<')) {\n const parsed = document.createElement('template');\n parsed.innerHTML = child.textContent || '';\n walkElements(parsed.content);\n continue;\n }\n walkElements(name === 'template' && child.content ? child.content : child);\n }\n };\n walkElements(document);\n const styles = [];\n const boxes = [];\n const n = Math.min(els.length, MAX);\n for (let i = 0; i < n; i++) {\n const el = els[i];\n const tag = el.tagName.toLowerCase();\n const cs = getComputedStyle(el);\n const css = {};\n for (const p of PROPS) {\n const v = cs[p];\n if (v !== undefined && v !== null && v !== '') css[p] = String(v);\n }\n styles.push({ i: i, tag: tag, css: css });\n const r = el.getBoundingClientRect();\n boxes.push({ i: i, tag: tag, x: Math.round(r.left), y: Math.round(r.top), w: Math.round(r.width), h: Math.round(r.height) });\n }\n // The page's own stylesheets. Some criteria are properties of the STYLESHEET rather than of\n // any element's computed style — focus styling removed with no replacement (2.4.7), a media\n // query that locks the orientation (1.3.4) — and this is the only place they exist.\n // A cross-origin sheet throws on .cssRules: COUNT those instead of ignoring them, so a rule\n // reading this digest can tell \"nothing there\" apart from \"I could not look\".\n // The cap is on the ORDINARY pool only, and the traversal never stops early.\n //\n // It used to return the moment the pool filled, which abandoned every remaining sheet —\n // and on a design-system app the pool fills long before the end. Measured on a real capture\n // of 38 pages: all 38 came back truncated, so rendered-focus-not-visible declined on every\n // one of them and 2.4.7 could never be decided by any number of scans. The rule was right to\n // decline (a :focus rule might have been among the dropped ones); the collector was wrong to\n // make that unavoidable.\n //\n // So the rules a rendered criterion actually READS — :focus styling, orientation locks,\n // pinned positioning, animation — are kept whatever the pool is doing, and truncated now\n // means \"some ordinary rule was dropped\", which is a much weaker statement. A rule can then\n // ask for what it needs instead of refusing on a cap that never concerned it.\n const cssRules = [];\n let unreadable = 0;\n let dropped = 0;\n const MAXR = 4000;\n const camel = (p) => p.replace(/-([a-z])/g, (_, c) => c.toUpperCase());\n const KEEP_SELECTOR = /:focus|:target|:active/i;\n const KEEP_PROP = /^(?:outline|position|animation|transition|transform)/;\n const walk = (list, media) => {\n for (const r of list) {\n if (typeof r.selectorText === 'string' && r.style) {\n const decls = {};\n for (let i = 0; i < r.style.length; i++) {\n const prop = r.style[i];\n decls[camel(prop)] = r.style.getPropertyValue(prop);\n }\n const keep = KEEP_SELECTOR.test(r.selectorText) || Object.keys(decls).some((k) => KEEP_PROP.test(k));\n if (cssRules.length >= MAXR && !keep) { dropped++; continue; }\n cssRules.push(media ? { selector: r.selectorText, media: media, decls: decls } : { selector: r.selectorText, decls: decls });\n } else if (r.cssRules) {\n const cond = r.conditionText || (r.media && r.media.mediaText) || media;\n walk(r.cssRules, cond);\n }\n }\n };\n for (const sheet of document.styleSheets) {\n try {\n walk(sheet.cssRules, undefined);\n } catch (e) {\n unreadable++;\n }\n }\n\n const truncated = els.length > MAX;\n return {\n dom: document.documentElement.outerHTML,\n css: { v: 1, rules: cssRules, unreadable: unreadable, truncated: dropped > 0, dropped: dropped },\n title: document.title,\n // The doctype is NOT part of documentElement.outerHTML, so a capture that records only\n // the DOM drops it — and RGAA 8.1 (is a doctype present, valid, and before <html>?) then\n // has nothing to look at. Recorded as its own field for that reason.\n doctype: document.doctype ? '<!DOCTYPE ' + document.doctype.name + (document.doctype.publicId ? ' PUBLIC \"' + document.doctype.publicId + '\"' : '') + (document.doctype.systemId ? ' \"' + document.doctype.systemId + '\"' : '') + '>' : '',\n lang: document.documentElement.getAttribute('lang') || '',\n url: location.href,\n viewport: { width: window.innerWidth, height: window.innerHeight },\n // The document's full height, so the producer knows whether a full-page screenshot adds\n // anything to the viewport one.\n docHeight: Math.max(document.documentElement.scrollHeight, document.body ? document.body.scrollHeight : 0),\n // Still loading at the instant of collection: the markers, or none. Every producer runs\n // this same collector, so every producer can say so — see LOADING_STATE.\n loading: (() => {\n const out = [];\n const shown = (e) => {\n const r = e.getBoundingClientRect();\n if (r.width <= 0 && r.height <= 0) return false;\n const s = getComputedStyle(e);\n return s.display !== 'none' && s.visibility !== 'hidden';\n };\n const name = (e) => e.localName + (e.id ? '#' + e.id : '');\n for (const e of Array.from(document.querySelectorAll('[aria-busy=\"true\"]'))) if (shown(e)) out.push('aria-busy=\"true\" ' + name(e));\n for (const e of Array.from(document.querySelectorAll('[role=\"progressbar\"]:not([aria-valuenow]), progress:not([value])'))) if (shown(e)) out.push('indeterminate progress ' + name(e));\n const PHRASE = /^(chargement( en cours)?|veuillez patienter|loading|please wait)\\s*(\\.{1,3}|…)?$/i;\n const text = (e) => (e.textContent || '').replace(/\\s+/g, ' ').trim();\n if (document.body) for (const e of Array.from(document.body.querySelectorAll('p,span,div,li,h1,h2,h3,h4,h5,h6,strong,em,output,[role=\"status\"]'))) {\n const t = text(e);\n if (t.length > 40 || !PHRASE.test(t)) continue;\n if (Array.from(e.children).some((c) => PHRASE.test(text(c)))) continue;\n if (shown(e)) out.push('text \"' + t + '\" ' + name(e));\n }\n return out.slice(0, 10);\n})(),\n styles: { v: 1, entries: styles, truncated: truncated },\n boxes: { v: 1, entries: boxes, truncated: truncated }\n };\n})()";
|
|
7
7
|
const REFLOW = "(async () => { \nconst __sel = (e) => {\n if (!e || !e.tagName) return '—';\n const esc = (v) => (typeof CSS !== 'undefined' && CSS.escape) ? CSS.escape(v) : String(v).replace(/[^a-zA-Z0-9_-]/g, '\\\\$&');\n const unique = (s) => { try { return document.querySelectorAll(s).length === 1; } catch { return false; } };\n const short = (n) => {\n const t = n.tagName.toLowerCase();\n if (n.id) return t + '#' + esc(n.id);\n const c = typeof n.className === 'string' ? n.className.trim().split(/\\s+/)[0] : '';\n return c ? t + '.' + esc(c) : t;\n };\n const first = short(e);\n if (unique(first)) return first;\n const parts = [];\n for (let n = e; n && n.tagName; n = n.parentElement) {\n let part = short(n);\n if (n.id && unique(part)) { parts.unshift(part); return parts.join(' > '); }\n const parent = n.parentElement;\n if (parent) {\n const same = Array.from(parent.children).filter((x) => x.tagName === n.tagName);\n if (same.length > 1) part += ':nth-of-type(' + (same.indexOf(n) + 1) + ')';\n }\n parts.unshift(part);\n const path = parts.join(' > ');\n if (unique(path)) return path;\n }\n return parts.join(' > ') || first;\n};\nconst __vis = (e) => {\n const r = e.getBoundingClientRect();\n if (r.width <= 4 || r.height <= 4) return false; // tiny / 1px sr-only boxes\n const s = getComputedStyle(e);\n if (s.display === 'none' || s.visibility === 'hidden' || parseFloat(s.opacity) === 0) return false;\n // visually-hidden \"screen-reader-only\" pattern (clip rect / clip-path inset) — present in\n // the a11y tree but not painted; must not be measured for clipping/target-size.\n if (s.clip && s.clip !== 'auto' && s.clip !== 'rect(auto, auto, auto, auto)') return false;\n if (s.clipPath && (s.clipPath.indexOf('inset(100%') >= 0 || s.clipPath.indexOf('inset(50%') >= 0)) return false;\n return true;\n};\nconst __html = (e) => (e.outerHTML || '').slice(0, 160);\n \nconst __frames = () => new Promise((res) => {\n let done = false;\n const end = () => { if (!done) { done = true; res(true); } };\n setTimeout(end, 200);\n try { requestAnimationFrame(() => requestAnimationFrame(end)); } catch { end(); }\n});\n\n await __frames();\n const el = document.scrollingElement || document.documentElement;\n const vw = el.clientWidth;\n const horizontalScroll = el.scrollWidth > vw + 2;\n if (!horizontalScroll) return { horizontalScroll };\n const sx = window.scrollX || 0;\n const contained = (e) => {\n for (let n = e.parentElement; n && n !== document.body && n !== document.documentElement; n = n.parentElement) {\n if (getComputedStyle(n).overflowX !== 'visible') return true;\n }\n return false;\n };\n const boxes = new Set();\n const outer = [];\n const content = [];\n for (const e of Array.from(document.querySelectorAll('body, body *'))) {\n const r = e.getBoundingClientRect();\n if (r.width <= 0 || r.height <= 0) continue;\n const s = getComputedStyle(e);\n if (s.position === 'fixed' || s.display === 'none' || s.visibility === 'hidden') continue;\n const boxOver = r.right + sx - vw;\n const contentOver = s.overflowX === 'visible' ? r.left + sx + e.scrollWidth - vw : 0;\n if (boxOver <= 2 && contentOver <= 2) continue;\n if (contained(e)) continue;\n if (boxOver > 2) {\n boxes.add(e);\n let top = true;\n for (let n = e.parentElement; n; n = n.parentElement) if (boxes.has(n)) { top = false; break; }\n if (top) outer.push([e, 'déborde de ' + Math.round(boxOver) + 'px à droite (largeur ' + Math.round(r.width) + 'px)']);\n } else {\n content.push([e, 'son contenu (texte ou pseudo-élément) déborde de ' + Math.round(contentOver) + 'px à droite de la boîte']);\n }\n }\n // A box wider than the viewport is the cause; failing one, the DEEPEST element whose own\n // content (a long word, a ::before/::after) spills out — its ancestors only carry the spill.\n const deepest = content.filter(([e]) => !content.some(([o]) => o !== e && e.contains(o)) && !Array.from(boxes).some((b) => e.contains(b)));\n const widening = outer.concat(deepest).slice(0, 5).map(([e, d]) => ({ selector: __sel(e), html: __html(e), detail: d }));\n return { horizontalScroll, widening };\n})()";
|
|
8
|
+
const LOADING = "(() => {\n const out = [];\n const shown = (e) => {\n const r = e.getBoundingClientRect();\n if (r.width <= 0 && r.height <= 0) return false;\n const s = getComputedStyle(e);\n return s.display !== 'none' && s.visibility !== 'hidden';\n };\n const name = (e) => e.localName + (e.id ? '#' + e.id : '');\n for (const e of Array.from(document.querySelectorAll('[aria-busy=\"true\"]'))) if (shown(e)) out.push('aria-busy=\"true\" ' + name(e));\n for (const e of Array.from(document.querySelectorAll('[role=\"progressbar\"]:not([aria-valuenow]), progress:not([value])'))) if (shown(e)) out.push('indeterminate progress ' + name(e));\n const PHRASE = /^(chargement( en cours)?|veuillez patienter|loading|please wait)\\s*(\\.{1,3}|…)?$/i;\n const text = (e) => (e.textContent || '').replace(/\\s+/g, ' ').trim();\n if (document.body) for (const e of Array.from(document.body.querySelectorAll('p,span,div,li,h1,h2,h3,h4,h5,h6,strong,em,output,[role=\"status\"]'))) {\n const t = text(e);\n if (t.length > 40 || !PHRASE.test(t)) continue;\n if (Array.from(e.children).some((c) => PHRASE.test(text(c)))) continue;\n if (shown(e)) out.push('text \"' + t + '\" ' + name(e));\n }\n return out.slice(0, 10);\n})()";
|
|
8
9
|
const browser = await chromium.launch({ args: ["--no-sandbox", "--disable-dev-shm-usage"] });
|
|
9
10
|
try {
|
|
10
11
|
const page = await browser.newPage();
|
|
11
12
|
await page.goto(isFile ? "file://" + target : target, { waitUntil: "load", timeout: 45000 });
|
|
13
|
+
// Not while the page still declares itself loading (aria-busy, a spinner, « Chargement… »).
|
|
14
|
+
// Bounded: a page that never settles is collected anyway, and the collector marks it.
|
|
15
|
+
for (const end = Date.now() + 10000; Date.now() < end; ) {
|
|
16
|
+
let markers = [];
|
|
17
|
+
try { markers = await page.evaluate(LOADING); } catch {}
|
|
18
|
+
if (!markers.length) break;
|
|
19
|
+
await page.waitForTimeout(150);
|
|
20
|
+
}
|
|
12
21
|
// Collected FIRST, on the pristine page: axe's injected source and the 320px reflow
|
|
13
22
|
// resize both come after, and a snapshot must be the page as the browser built it.
|
|
14
23
|
let snapshot;
|
|
@@ -16,6 +25,12 @@ try {
|
|
|
16
25
|
try {
|
|
17
26
|
snapshot = await page.evaluate(COLLECT);
|
|
18
27
|
try { snapshot.screenshot = (await page.screenshot({ fullPage: false })).toString("base64"); } catch {}
|
|
28
|
+
// The whole page beside it, height-bounded, for the report's reader.
|
|
29
|
+
try {
|
|
30
|
+
const vp = snapshot.viewport;
|
|
31
|
+
const height = Math.min(snapshot.docHeight || 0, 8000);
|
|
32
|
+
if (vp && height > vp.height) snapshot.screenshotFull = (await page.screenshot({ fullPage: true, clip: { x: 0, y: 0, width: vp.width, height } })).toString("base64");
|
|
33
|
+
} catch {}
|
|
19
34
|
} catch {}
|
|
20
35
|
}
|
|
21
36
|
await page.addScriptTag({ content: axe.source });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ultra11y",
|
|
3
|
-
"version": "5.57.
|
|
3
|
+
"version": "5.57.5",
|
|
4
4
|
"description": "Audit d'accessibilité RGAA 4.1.2, le référentiel de l'État : rapport daté, grille des 106 critères, backlog et tickets. Moteur statique, navigateur et jugement IA contre-vérifié. Il ne déclare jamais conforme ce qu'il n'a pas vérifié. Socle WCAG 2.2 AA.",
|
|
5
5
|
"homepage": "https://socialgouv.github.io/ultra11y/",
|
|
6
6
|
"type": "module",
|