@ngbracket/a11y-devtools 0.13.0 → 0.14.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/CHANGELOG.md +31 -0
- package/README.md +17 -2
- package/bin/ngbr-a11y-report.mjs +30 -6
- package/dist/attribution.d.ts +2 -1
- package/dist/attribution.js +3 -2
- package/dist/inpage.global.js +1 -1
- package/dist/report/acr.d.ts +70 -0
- package/dist/report/acr.js +291 -0
- package/dist/report/format.d.ts +15 -1
- package/dist/report/format.js +2 -1
- package/dist/report/headless.js +11 -1
- package/dist/report/html.d.ts +18 -0
- package/dist/report/html.js +3 -3
- package/dist/report/index.d.ts +3 -1
- package/dist/report/index.js +2 -0
- package/dist/report/wcag.d.ts +24 -0
- package/dist/report/wcag.js +76 -0
- package/dist/scan.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,37 @@
|
|
|
3
3
|
All notable changes to `@ngbracket/a11y-devtools` are documented here.
|
|
4
4
|
This project adheres to [Semantic Versioning](https://semver.org/).
|
|
5
5
|
|
|
6
|
+
## 0.14.1
|
|
7
|
+
|
|
8
|
+
### Fixed
|
|
9
|
+
|
|
10
|
+
- **`componentPath` lists each component once.** With content projection, a
|
|
11
|
+
finding's path could repeat a component, e.g.
|
|
12
|
+
`HomePageComponent > PanelComponent > HomePageComponent > AppComponent` for an
|
|
13
|
+
image projected into a panel. It's now
|
|
14
|
+
`HomePageComponent > PanelComponent > AppComponent`. The attributed
|
|
15
|
+
`component`, "via" notes and baseline matching are unchanged.
|
|
16
|
+
|
|
17
|
+
## 0.14.0
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- **Evaluation worksheet for a VPAT/ACR.** `--format acr` writes
|
|
22
|
+
`<prefix>.acr.html` and `--format acr-md` writes `<prefix>.acr.md`: the scan
|
|
23
|
+
organised by WCAG 2.2 Level A and AA success criterion, one row per criterion.
|
|
24
|
+
Each row says what the scan found — "Automated failures found", "Possible
|
|
25
|
+
failures found — verify manually" (heuristic `ngbr/*` rules only), "No
|
|
26
|
+
automated failures detected — manual review required", or "No automated checks
|
|
27
|
+
— manual review required" — with the evidence (rule, impact, instances, pages,
|
|
28
|
+
components) or the rules that checked it. It never says "Supports": the
|
|
29
|
+
Conformance Level and Remarks columns, and the product, evaluator and date
|
|
30
|
+
fields, are left blank for a person. Findings from rules not mapped to an A/AA
|
|
31
|
+
criterion (best practices, AAA) are listed separately rather than dropped.
|
|
32
|
+
From code: `buildAcrWorksheet()`, `toAcrHtml()`, `toAcrMarkdown()`.
|
|
33
|
+
- **Reports record what was checked.** `scanPages()` results and JSON reports
|
|
34
|
+
now carry `checks`: the axe-core version, any `--tags`, and whether keyboard
|
|
35
|
+
checks and the keyboard-trap walk ran.
|
|
36
|
+
|
|
6
37
|
## 0.13.0
|
|
7
38
|
|
|
8
39
|
### Added
|
package/README.md
CHANGED
|
@@ -66,10 +66,14 @@ npx ngbr-a11y-report --serve "npx ng serve" --route / --route /settings \
|
|
|
66
66
|
--keyboard --baseline a11y-baseline.json --fail-on serious --out a11y --format all
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
+
Preparing a VPAT/ACR? `--format acr` adds an evaluation worksheet: the results by WCAG 2.2
|
|
70
|
+
A/AA criterion, with the conformance columns left for a person to fill in.
|
|
71
|
+
|
|
69
72
|
Next steps, in the docs:
|
|
70
73
|
[Your first scan](https://ngbracket.com/tools/a11y-devtools/docs/first-scan) ·
|
|
71
74
|
[Report mode](https://ngbracket.com/tools/a11y-devtools/docs/report-mode) ·
|
|
72
75
|
[CI gating with a baseline](https://ngbracket.com/tools/a11y-devtools/docs/ci-baseline) ·
|
|
76
|
+
[ACR worksheet](https://ngbracket.com/tools/a11y-devtools/docs/acr-worksheet) ·
|
|
73
77
|
[CLI reference](https://ngbracket.com/tools/a11y-devtools/docs/cli) ·
|
|
74
78
|
[Findings & rules](https://ngbracket.com/tools/a11y-devtools/docs/findings)
|
|
75
79
|
|
|
@@ -87,7 +91,16 @@ heuristics, labelled "verify manually". It helps you build toward supporting WCA
|
|
|
87
91
|
npm install --legacy-peer-deps
|
|
88
92
|
npm run build # tsc -> dist/ (ESM + .d.ts) + the in-page bundle
|
|
89
93
|
npm test # vitest + jsdom + Angular TestBed (real axe); the real-browser
|
|
90
|
-
# E2E
|
|
94
|
+
# E2E specs run after a build, once `npx playwright install chromium`
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The real-browser specs are `src/testing/e2e-report.spec.ts` (report mode against plain-HTML
|
|
98
|
+
pages) and `src/testing/e2e-angular.spec.ts` (component attribution against a real Angular
|
|
99
|
+
app). The second builds the fixture app in `e2e/angular-app` itself, with `@angular/build`
|
|
100
|
+
(no Angular CLI needed). To build it by hand, for example to open it in a browser:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
node scripts/build-angular-fixture.mjs # → e2e/angular-app/dist/{dev,prod}/browser
|
|
91
104
|
```
|
|
92
105
|
|
|
93
106
|
CI also runs a production-weight guard: a bundle-graph test that fails if axe-core
|
|
@@ -119,4 +132,6 @@ ever becomes reachable through a static import.
|
|
|
119
132
|
- **Keyboard & Focus Mode M3** — missing focus-trap detection (uncontained
|
|
120
133
|
`aria-modal`) and the keyboard-trap walk with real Tab presses.
|
|
121
134
|
- CI production-weight guard.
|
|
122
|
-
- Real-browser E2E
|
|
135
|
+
- Real-browser E2E tests, including component attribution in a real Angular app.
|
|
136
|
+
- Report mode can start the dev server (`--serve`).
|
|
137
|
+
- ACR evaluation worksheet by WCAG 2.2 A/AA criterion (`--format acr`).
|
package/bin/ngbr-a11y-report.mjs
CHANGED
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
parseBaseline,
|
|
6
6
|
scanPages,
|
|
7
7
|
startDevServer,
|
|
8
|
+
toAcrHtml,
|
|
9
|
+
toAcrMarkdown,
|
|
8
10
|
toHtml,
|
|
9
11
|
toJson,
|
|
10
12
|
toMarkdown,
|
|
@@ -28,7 +30,10 @@ Options:
|
|
|
28
30
|
--tags <list> Comma-separated axe tags to scope the ruleset (e.g. wcag22aa,best-practice)
|
|
29
31
|
--out <prefix> Write <prefix>.md / .json / .html (default: print Markdown to stdout)
|
|
30
32
|
--format <list> Comma-separated: md, json, html — or both (= md,json) or all
|
|
31
|
-
(
|
|
33
|
+
(= md,json,html). Default: both when --out is set.
|
|
34
|
+
Also: acr (<prefix>.acr.html) and acr-md (<prefix>.acr.md) —
|
|
35
|
+
an evaluation worksheet by WCAG 2.2 A/AA criterion, as input
|
|
36
|
+
to a VPAT/ACR. Not a conformance report
|
|
32
37
|
--wait <ms> Settle time after load before scanning (default 1500)
|
|
33
38
|
--fail-on <impact> Exit non-zero if any finding is at/above impact
|
|
34
39
|
(minor | moderate | serious | critical) — for CI gating.
|
|
@@ -105,15 +110,27 @@ if (opts.help || !opts.base || opts.routes.length === 0) {
|
|
|
105
110
|
process.exit(opts.help ? 0 : 1);
|
|
106
111
|
}
|
|
107
112
|
|
|
108
|
-
const FORMATS = {
|
|
113
|
+
const FORMATS = {
|
|
114
|
+
md: ['md'],
|
|
115
|
+
json: ['json'],
|
|
116
|
+
html: ['html'],
|
|
117
|
+
both: ['md', 'json'],
|
|
118
|
+
all: ['md', 'json', 'html'],
|
|
119
|
+
acr: ['acr'],
|
|
120
|
+
'acr-md': ['acr-md'],
|
|
121
|
+
};
|
|
109
122
|
const formats = new Set();
|
|
110
123
|
for (const name of String(opts.format).split(',').map((s) => s.trim()).filter(Boolean)) {
|
|
111
124
|
if (!FORMATS[name]) {
|
|
112
|
-
process.stderr.write(`Invalid --format "${name}" (use md, json, html, both or
|
|
125
|
+
process.stderr.write(`Invalid --format "${name}" (use md, json, html, both, all, acr or acr-md)\n`);
|
|
113
126
|
process.exit(2);
|
|
114
127
|
}
|
|
115
128
|
FORMATS[name].forEach((f) => formats.add(f));
|
|
116
129
|
}
|
|
130
|
+
if (!opts.out && (formats.has('acr') || formats.has('acr-md'))) {
|
|
131
|
+
process.stderr.write('--format acr / acr-md writes a file: add --out <prefix>\n');
|
|
132
|
+
process.exit(2);
|
|
133
|
+
}
|
|
117
134
|
|
|
118
135
|
if (opts.colorScheme && !['light', 'dark', 'both'].includes(opts.colorScheme)) {
|
|
119
136
|
process.stderr.write(`Invalid --color-scheme "${opts.colorScheme}" (use light, dark or both)\n`);
|
|
@@ -206,10 +223,17 @@ if (allFindings.length > 0 && allFindings.every((f) => f.component === null)) {
|
|
|
206
223
|
if (!opts.out) {
|
|
207
224
|
process.stdout.write(toMarkdown(report, diff) + '\n');
|
|
208
225
|
} else {
|
|
209
|
-
const render = {
|
|
226
|
+
const render = {
|
|
227
|
+
md: [toMarkdown, 'md'],
|
|
228
|
+
json: [toJson, 'json'],
|
|
229
|
+
html: [toHtml, 'html'],
|
|
230
|
+
acr: [(r) => toAcrHtml(r), 'acr.html'],
|
|
231
|
+
'acr-md': [(r) => toAcrMarkdown(r), 'acr.md'],
|
|
232
|
+
};
|
|
210
233
|
for (const format of formats) {
|
|
211
|
-
|
|
212
|
-
|
|
234
|
+
const [fn, ext] = render[format];
|
|
235
|
+
writeFileSync(`${opts.out}.${ext}`, fn(report, diff));
|
|
236
|
+
process.stderr.write(`Wrote ${opts.out}.${ext}\n`);
|
|
213
237
|
}
|
|
214
238
|
}
|
|
215
239
|
|
package/dist/attribution.d.ts
CHANGED
|
@@ -52,7 +52,8 @@ export declare function ngDebug(): NgDebugGlobal | undefined;
|
|
|
52
52
|
export declare const DEFAULT_FRAMEWORK_PREFIXES: readonly string[];
|
|
53
53
|
/**
|
|
54
54
|
* The chain of owning components from the flagged node up to the root, nearest
|
|
55
|
-
* first
|
|
55
|
+
* first, each listed once (content projection can bring a component back up the
|
|
56
|
+
* DOM path; only its nearest position is kept). Built by walking DOM ancestors and asking Angular's
|
|
56
57
|
* debug API who owns each, so a control that is itself a library primitive still
|
|
57
58
|
* reveals the app component that placed it. Empty when the global is absent (prod).
|
|
58
59
|
*/
|
package/dist/attribution.js
CHANGED
|
@@ -70,7 +70,8 @@ function isPrimitiveComponent(name, prefixes) {
|
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
72
|
* The chain of owning components from the flagged node up to the root, nearest
|
|
73
|
-
* first
|
|
73
|
+
* first, each listed once (content projection can bring a component back up the
|
|
74
|
+
* DOM path; only its nearest position is kept). Built by walking DOM ancestors and asking Angular's
|
|
74
75
|
* debug API who owns each, so a control that is itself a library primitive still
|
|
75
76
|
* reveals the app component that placed it. Empty when the global is absent (prod).
|
|
76
77
|
*/
|
|
@@ -93,7 +94,7 @@ export function resolveComponentPath(node) {
|
|
|
93
94
|
owner = null; // node isn't part of a live view
|
|
94
95
|
}
|
|
95
96
|
const name = nameOf(owner);
|
|
96
|
-
if (name &&
|
|
97
|
+
if (name && !path.includes(name))
|
|
97
98
|
path.push(name);
|
|
98
99
|
el = el.parentElement;
|
|
99
100
|
}
|
package/dist/inpage.global.js
CHANGED
|
@@ -34191,7 +34191,7 @@
|
|
|
34191
34191
|
owner = null;
|
|
34192
34192
|
}
|
|
34193
34193
|
const name = nameOf(owner);
|
|
34194
|
-
if (name &&
|
|
34194
|
+
if (name && !path.includes(name))
|
|
34195
34195
|
path.push(name);
|
|
34196
34196
|
el = el.parentElement;
|
|
34197
34197
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Impact } from '../scan.js';
|
|
2
|
+
import { type ScanChecks, type ScanReport } from './format.js';
|
|
3
|
+
import { type WcagCriterion } from './wcag.js';
|
|
4
|
+
/**
|
|
5
|
+
* ACR worksheet: an automated scan organised by WCAG 2.2 A/AA success
|
|
6
|
+
* criterion, as an *input* to a VPAT/ACR. It never decides conformance.
|
|
7
|
+
* Automated checks can show that something fails; they can't show that a
|
|
8
|
+
* criterion is supported, so no row ever says "Supports" and the Conformance
|
|
9
|
+
* Level and Remarks columns are left for a person to fill in.
|
|
10
|
+
*/
|
|
11
|
+
/** What the scan found for one criterion. */
|
|
12
|
+
export type AcrResult = 'failures' | 'possible-failures' | 'no-failures-detected' | 'not-checked';
|
|
13
|
+
export declare const ACR_RESULT_LABELS: Record<AcrResult, string>;
|
|
14
|
+
export declare const ACR_TITLE = "Evaluation worksheet \u2014 not a conformance report";
|
|
15
|
+
/** One rule's findings, summed across pages. */
|
|
16
|
+
export interface AcrRuleEvidence {
|
|
17
|
+
rule: string;
|
|
18
|
+
/** From a heuristic `ngbr/*` rule: a candidate to verify, not a confirmed failure. */
|
|
19
|
+
heuristic: boolean;
|
|
20
|
+
/** The worst impact among its findings. */
|
|
21
|
+
impact: Impact;
|
|
22
|
+
instances: number;
|
|
23
|
+
components: string[];
|
|
24
|
+
/** Page labels, e.g. `/settings` or `/settings (dark)`. */
|
|
25
|
+
pages: string[];
|
|
26
|
+
helpUrl: string;
|
|
27
|
+
}
|
|
28
|
+
export interface AcrRow {
|
|
29
|
+
criterion: WcagCriterion;
|
|
30
|
+
result: AcrResult;
|
|
31
|
+
/** Rules that checked this criterion in this run. */
|
|
32
|
+
checkedBy: string[];
|
|
33
|
+
evidence: AcrRuleEvidence[];
|
|
34
|
+
}
|
|
35
|
+
export interface AcrWorksheet {
|
|
36
|
+
generatedAt: string;
|
|
37
|
+
checks?: ScanChecks;
|
|
38
|
+
/** Labels of pages that scanned. */
|
|
39
|
+
pagesScanned: string[];
|
|
40
|
+
pagesFailed: {
|
|
41
|
+
label: string;
|
|
42
|
+
error: string;
|
|
43
|
+
}[];
|
|
44
|
+
rows: AcrRow[];
|
|
45
|
+
/** Findings from rules not mapped to any WCAG 2.2 A/AA criterion (best practice, AAA, 4.1.1). */
|
|
46
|
+
other: AcrRuleEvidence[];
|
|
47
|
+
}
|
|
48
|
+
/** The part of axe's rule metadata the worksheet needs (`axe.getRules()`). */
|
|
49
|
+
export interface AxeRuleMeta {
|
|
50
|
+
ruleId: string;
|
|
51
|
+
tags: string[];
|
|
52
|
+
enabled?: boolean;
|
|
53
|
+
}
|
|
54
|
+
export declare function loadAxeRules(): AxeRuleMeta[];
|
|
55
|
+
/**
|
|
56
|
+
* The axe rules a run used. Without tags: axe's default ruleset (enabled rules).
|
|
57
|
+
* With tags, axe runs every rule carrying one of them, even rules that are off
|
|
58
|
+
* by default (e.g. `target-size` under `wcag22aa`), but still skips
|
|
59
|
+
* experimental and deprecated rules unless those tags are asked for.
|
|
60
|
+
*/
|
|
61
|
+
export declare function axeRulesRun(rules: AxeRuleMeta[], checks?: ScanChecks): AxeRuleMeta[];
|
|
62
|
+
/**
|
|
63
|
+
* Organise a report by WCAG 2.2 A/AA criterion. `axeRules` defaults to the
|
|
64
|
+
* installed axe-core's metadata; pass your own to pin it (e.g. in tests).
|
|
65
|
+
*/
|
|
66
|
+
export declare function buildAcrWorksheet(report: ScanReport, axeRules?: AxeRuleMeta[]): AcrWorksheet;
|
|
67
|
+
/** Render the worksheet as Markdown. */
|
|
68
|
+
export declare function toAcrMarkdown(report: ScanReport, axeRules?: AxeRuleMeta[]): string;
|
|
69
|
+
/** Render the worksheet as one self-contained, accessible HTML document (tables paste into Word). */
|
|
70
|
+
export declare function toAcrHtml(report: ScanReport, axeRules?: AxeRuleMeta[]): string;
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { impactRank } from './format.js';
|
|
3
|
+
import { escapeHtml, safeHref, STYLES } from './html.js';
|
|
4
|
+
import { criterionForTag, understandingUrl, WCAG22_A_AA } from './wcag.js';
|
|
5
|
+
export const ACR_RESULT_LABELS = {
|
|
6
|
+
failures: 'Automated failures found',
|
|
7
|
+
'possible-failures': 'Possible failures found — verify manually',
|
|
8
|
+
'no-failures-detected': 'No automated failures detected — manual review required',
|
|
9
|
+
'not-checked': 'No automated checks — manual review required',
|
|
10
|
+
};
|
|
11
|
+
export const ACR_TITLE = 'Evaluation worksheet — not a conformance report';
|
|
12
|
+
/**
|
|
13
|
+
* Our keyboard rules and the criteria their docs cite. All are heuristic:
|
|
14
|
+
* their findings are candidates to verify (a trap can be intended, with a
|
|
15
|
+
* documented way out; an order mismatch can be deliberate).
|
|
16
|
+
*/
|
|
17
|
+
const NGBR_RULES = {
|
|
18
|
+
'ngbr/unreachable-control': { criteria: ['2.1.1'], ranWhen: 'keyboard' },
|
|
19
|
+
'ngbr/click-without-key': { criteria: ['2.1.1'], ranWhen: 'keyboard' },
|
|
20
|
+
'ngbr/tab-order-mismatch': { criteria: ['2.4.3'], ranWhen: 'keyboard' },
|
|
21
|
+
'ngbr/modal-focus-not-contained': { criteria: ['2.4.3'], ranWhen: 'keyboard' },
|
|
22
|
+
'ngbr/focus-trap': { criteria: ['2.1.2'], ranWhen: 'focusTraps' },
|
|
23
|
+
};
|
|
24
|
+
export function loadAxeRules() {
|
|
25
|
+
const axe = createRequire(import.meta.url)('axe-core');
|
|
26
|
+
return axe.getRules();
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The axe rules a run used. Without tags: axe's default ruleset (enabled rules).
|
|
30
|
+
* With tags, axe runs every rule carrying one of them, even rules that are off
|
|
31
|
+
* by default (e.g. `target-size` under `wcag22aa`), but still skips
|
|
32
|
+
* experimental and deprecated rules unless those tags are asked for.
|
|
33
|
+
*/
|
|
34
|
+
export function axeRulesRun(rules, checks) {
|
|
35
|
+
const tags = checks?.tags;
|
|
36
|
+
const skipped = (r, tag) => r.tags.includes(tag) && !tags?.includes(tag);
|
|
37
|
+
return rules.filter((r) => (tags ? r.tags.some((t) => tags.includes(t)) : r.enabled !== false) &&
|
|
38
|
+
!skipped(r, 'experimental') &&
|
|
39
|
+
!skipped(r, 'deprecated'));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Organise a report by WCAG 2.2 A/AA criterion. `axeRules` defaults to the
|
|
43
|
+
* installed axe-core's metadata; pass your own to pin it (e.g. in tests).
|
|
44
|
+
*/
|
|
45
|
+
export function buildAcrWorksheet(report, axeRules = loadAxeRules()) {
|
|
46
|
+
const scanned = report.pages.filter((p) => !p.error);
|
|
47
|
+
const allFindings = scanned.flatMap((p) => p.findings);
|
|
48
|
+
// Criterion id → rules that checked it this run. Nothing counts as checked if no page scanned.
|
|
49
|
+
const checkedBy = new Map();
|
|
50
|
+
const check = (criterionId, rule) => {
|
|
51
|
+
const set = checkedBy.get(criterionId) ?? new Set();
|
|
52
|
+
set.add(rule);
|
|
53
|
+
checkedBy.set(criterionId, set);
|
|
54
|
+
};
|
|
55
|
+
const tagsById = new Map(axeRules.map((r) => [r.ruleId, r.tags]));
|
|
56
|
+
if (scanned.length) {
|
|
57
|
+
for (const rule of axeRulesRun(axeRules, report.checks)) {
|
|
58
|
+
for (const tag of rule.tags) {
|
|
59
|
+
const criterion = criterionForTag(tag);
|
|
60
|
+
if (criterion)
|
|
61
|
+
check(criterion.id, rule.ruleId);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
for (const [rule, { criteria, ranWhen }] of Object.entries(NGBR_RULES)) {
|
|
65
|
+
// A hand-built report has no `checks`: count a rule as run if it produced findings.
|
|
66
|
+
const ran = report.checks ? report.checks[ranWhen] : allFindings.some((f) => f.id === rule);
|
|
67
|
+
if (ran)
|
|
68
|
+
criteria.forEach((id) => check(id, rule));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Criterion id (or '' for unmapped) → rule → evidence.
|
|
72
|
+
const evidence = new Map();
|
|
73
|
+
const add = (key, finding, page) => {
|
|
74
|
+
const byRule = evidence.get(key) ?? new Map();
|
|
75
|
+
evidence.set(key, byRule);
|
|
76
|
+
let item = byRule.get(finding.id);
|
|
77
|
+
if (!item) {
|
|
78
|
+
item = {
|
|
79
|
+
rule: finding.id,
|
|
80
|
+
heuristic: finding.id in NGBR_RULES,
|
|
81
|
+
impact: finding.impact,
|
|
82
|
+
instances: 0,
|
|
83
|
+
components: [],
|
|
84
|
+
pages: [],
|
|
85
|
+
helpUrl: finding.helpUrl,
|
|
86
|
+
};
|
|
87
|
+
byRule.set(finding.id, item);
|
|
88
|
+
}
|
|
89
|
+
item.instances++;
|
|
90
|
+
if (impactRank(finding.impact) < impactRank(item.impact))
|
|
91
|
+
item.impact = finding.impact;
|
|
92
|
+
const component = finding.component ?? '(unknown component)';
|
|
93
|
+
if (!item.components.includes(component))
|
|
94
|
+
item.components.push(component);
|
|
95
|
+
if (!item.pages.includes(page))
|
|
96
|
+
item.pages.push(page);
|
|
97
|
+
};
|
|
98
|
+
for (const page of scanned) {
|
|
99
|
+
for (const finding of page.findings) {
|
|
100
|
+
const criteria = criteriaFor(finding.id, tagsById);
|
|
101
|
+
if (criteria.length === 0)
|
|
102
|
+
add('', finding, page.label);
|
|
103
|
+
criteria.forEach((id) => add(id, finding, page.label));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const sorted = (key) => [...(evidence.get(key)?.values() ?? [])].sort((a, b) => impactRank(a.impact) - impactRank(b.impact) || b.instances - a.instances);
|
|
107
|
+
const rows = WCAG22_A_AA.map((criterion) => {
|
|
108
|
+
const items = sorted(criterion.id);
|
|
109
|
+
const rules = [...(checkedBy.get(criterion.id) ?? [])];
|
|
110
|
+
let result;
|
|
111
|
+
if (items.some((e) => !e.heuristic))
|
|
112
|
+
result = 'failures';
|
|
113
|
+
else if (items.length)
|
|
114
|
+
result = 'possible-failures';
|
|
115
|
+
else if (rules.length)
|
|
116
|
+
result = 'no-failures-detected';
|
|
117
|
+
else
|
|
118
|
+
result = 'not-checked';
|
|
119
|
+
return { criterion, result, checkedBy: rules, evidence: items };
|
|
120
|
+
});
|
|
121
|
+
return {
|
|
122
|
+
generatedAt: report.generatedAt,
|
|
123
|
+
...(report.checks && { checks: report.checks }),
|
|
124
|
+
pagesScanned: scanned.map((p) => p.label),
|
|
125
|
+
pagesFailed: report.pages.filter((p) => p.error).map((p) => ({ label: p.label, error: p.error })),
|
|
126
|
+
rows,
|
|
127
|
+
other: sorted(''),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function criteriaFor(rule, tagsById) {
|
|
131
|
+
if (rule in NGBR_RULES)
|
|
132
|
+
return NGBR_RULES[rule].criteria;
|
|
133
|
+
const ids = (tagsById.get(rule) ?? []).map((t) => criterionForTag(t)?.id).filter((id) => !!id);
|
|
134
|
+
return [...new Set(ids)];
|
|
135
|
+
}
|
|
136
|
+
function countByResult(rows) {
|
|
137
|
+
const counts = {
|
|
138
|
+
failures: 0,
|
|
139
|
+
'possible-failures': 0,
|
|
140
|
+
'no-failures-detected': 0,
|
|
141
|
+
'not-checked': 0,
|
|
142
|
+
};
|
|
143
|
+
rows.forEach((r) => counts[r.result]++);
|
|
144
|
+
return counts;
|
|
145
|
+
}
|
|
146
|
+
/** "a, b, c +2 more" */
|
|
147
|
+
function shortList(items, max = 3) {
|
|
148
|
+
return items.length <= max ? items.join(', ') : `${items.slice(0, max).join(', ')} +${items.length - max} more`;
|
|
149
|
+
}
|
|
150
|
+
function colorSchemes(report) {
|
|
151
|
+
return report.pages.some((p) => p.colorScheme === 'dark') ? 'light and dark' : 'light';
|
|
152
|
+
}
|
|
153
|
+
const INTRO = 'This worksheet organises an automated scan by WCAG 2.2 Level A and AA success criterion, as an ' +
|
|
154
|
+
'input to a VPAT or Accessibility Conformance Report (ACR). It does not decide conformance: automated ' +
|
|
155
|
+
'checks can show that something fails, but not that a criterion is supported. A person needs to ' +
|
|
156
|
+
'evaluate every row and fill in Conformance Level and Remarks.';
|
|
157
|
+
const HEURISTIC_NOTE = '“Possible failures” come from heuristic keyboard rules (ngbr/*): candidates to verify by hand, not confirmed failures.';
|
|
158
|
+
const EXCLUDED_NOTE = '4.1.1 Parsing is obsolete in WCAG 2.2 and is not listed. Level AAA is not covered.';
|
|
159
|
+
function scanDetails(report, sheet) {
|
|
160
|
+
const c = sheet.checks;
|
|
161
|
+
const details = [
|
|
162
|
+
['Scan generated', sheet.generatedAt],
|
|
163
|
+
['Tool', `@ngbracket/a11y-devtools report-mode${c ? `, axe-core ${c.axeVersion}` : ''}`],
|
|
164
|
+
['Ruleset', c?.tags ? `axe tags: ${c.tags.join(', ')}` : 'axe default ruleset'],
|
|
165
|
+
['Keyboard checks', c ? (c.keyboard ? 'on' : 'off') : 'unknown'],
|
|
166
|
+
['Keyboard-trap walk', c ? (c.focusTraps ? 'on' : 'off') : 'unknown'],
|
|
167
|
+
['Colour schemes', colorSchemes(report)],
|
|
168
|
+
['Pages scanned', sheet.pagesScanned.length ? sheet.pagesScanned.join(', ') : 'none'],
|
|
169
|
+
];
|
|
170
|
+
if (sheet.pagesFailed.length) {
|
|
171
|
+
details.push(['Pages that failed to scan', sheet.pagesFailed.map((p) => `${p.label} (${p.error})`).join('; ')]);
|
|
172
|
+
}
|
|
173
|
+
return details;
|
|
174
|
+
}
|
|
175
|
+
function evidenceText(e) {
|
|
176
|
+
const kind = e.heuristic ? 'possible' : (e.impact ?? 'n/a');
|
|
177
|
+
return (`${e.rule} (${kind}): ${e.instances} instance(s) on ${shortList(e.pages)}; ` +
|
|
178
|
+
`components: ${shortList(e.components)}`);
|
|
179
|
+
}
|
|
180
|
+
function checkedByText(rules) {
|
|
181
|
+
return rules.length ? `Checked by: ${shortList(rules)}` : '';
|
|
182
|
+
}
|
|
183
|
+
/** Escape a Markdown table cell. */
|
|
184
|
+
function cell(text) {
|
|
185
|
+
return text.replace(/\|/g, '\\|').replace(/\n/g, ' ');
|
|
186
|
+
}
|
|
187
|
+
/** Render the worksheet as Markdown. */
|
|
188
|
+
export function toAcrMarkdown(report, axeRules) {
|
|
189
|
+
const sheet = buildAcrWorksheet(report, axeRules);
|
|
190
|
+
const counts = countByResult(sheet.rows);
|
|
191
|
+
const out = [];
|
|
192
|
+
out.push(`# ${ACR_TITLE}`, '');
|
|
193
|
+
out.push(`> ${INTRO}`, '');
|
|
194
|
+
out.push('| | |', '|---|---|');
|
|
195
|
+
out.push('| Product and version | |', '| Evaluator | |', '| Evaluation date | |');
|
|
196
|
+
out.push('| Standard | WCAG 2.2 Level A and AA |');
|
|
197
|
+
for (const [k, v] of scanDetails(report, sheet))
|
|
198
|
+
out.push(`| ${cell(k)} | ${cell(v)} |`);
|
|
199
|
+
out.push('');
|
|
200
|
+
out.push('## Summary', '');
|
|
201
|
+
for (const result of Object.keys(ACR_RESULT_LABELS)) {
|
|
202
|
+
out.push(`- ${ACR_RESULT_LABELS[result]}: ${counts[result]}`);
|
|
203
|
+
}
|
|
204
|
+
out.push('', `${HEURISTIC_NOTE} ${EXCLUDED_NOTE}`, '');
|
|
205
|
+
out.push('## WCAG 2.2 Level A and AA', '');
|
|
206
|
+
out.push('| Criterion | Level | Automated result | Evidence | Conformance Level | Remarks and Explanations |');
|
|
207
|
+
out.push('|---|---|---|---|---|---|');
|
|
208
|
+
for (const row of sheet.rows) {
|
|
209
|
+
const { criterion } = row;
|
|
210
|
+
const evidence = row.evidence.length
|
|
211
|
+
? row.evidence.map(evidenceText).join('<br>')
|
|
212
|
+
: checkedByText(row.checkedBy);
|
|
213
|
+
out.push(`| [${criterion.id} ${cell(criterion.name)}](${understandingUrl(criterion)}) | ${criterion.level} | ${ACR_RESULT_LABELS[row.result]} | ${cell(evidence)} | | |`);
|
|
214
|
+
}
|
|
215
|
+
if (sheet.other.length) {
|
|
216
|
+
out.push('', '## Other findings', '');
|
|
217
|
+
out.push('Rules not mapped to a WCAG 2.2 A/AA criterion: best practices, Level AAA, or 4.1.1. Worth fixing; not rows in the table above.', '');
|
|
218
|
+
for (const e of sheet.other)
|
|
219
|
+
out.push(`- ${cell(evidenceText(e))}`);
|
|
220
|
+
}
|
|
221
|
+
return out.join('\n') + '\n';
|
|
222
|
+
}
|
|
223
|
+
const ACR_STYLES = `
|
|
224
|
+
table.acr th[scope], table.acr td:not(:first-child) { text-align: left; vertical-align: top; }
|
|
225
|
+
table.acr .level { white-space: nowrap; }
|
|
226
|
+
table.acr td.blank { min-width: 8rem; }
|
|
227
|
+
.result { font-weight: 600; }
|
|
228
|
+
.result-failures { color: var(--critical); }
|
|
229
|
+
.result-possible-failures { color: var(--serious); }
|
|
230
|
+
dl.fields { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 16px; }
|
|
231
|
+
dl.fields dt { font-weight: 600; }
|
|
232
|
+
dl.fields dd { margin: 0; overflow-wrap: anywhere; }
|
|
233
|
+
ul.evidence { margin: 0; padding-left: 1.1em; }
|
|
234
|
+
@media print { .table-wrap { overflow: visible; } }
|
|
235
|
+
`;
|
|
236
|
+
/** Render the worksheet as one self-contained, accessible HTML document (tables paste into Word). */
|
|
237
|
+
export function toAcrHtml(report, axeRules) {
|
|
238
|
+
const sheet = buildAcrWorksheet(report, axeRules);
|
|
239
|
+
const counts = countByResult(sheet.rows);
|
|
240
|
+
const out = [];
|
|
241
|
+
const link = (url, text) => {
|
|
242
|
+
const href = safeHref(url);
|
|
243
|
+
return href ? `<a href="${href}">${escapeHtml(text)}</a>` : escapeHtml(text);
|
|
244
|
+
};
|
|
245
|
+
out.push('<!doctype html>', '<html lang="en">', '<head>', '<meta charset="utf-8">');
|
|
246
|
+
out.push('<meta name="viewport" content="width=device-width, initial-scale=1">');
|
|
247
|
+
out.push(`<title>${escapeHtml(ACR_TITLE)}</title>`);
|
|
248
|
+
out.push(`<style>${STYLES}${ACR_STYLES}</style>`);
|
|
249
|
+
out.push('</head>', '<body>', '<main>');
|
|
250
|
+
out.push(`<h1>${escapeHtml(ACR_TITLE)}</h1>`);
|
|
251
|
+
out.push(`<p class="scope">${escapeHtml(INTRO)}</p>`);
|
|
252
|
+
out.push('<dl class="fields">');
|
|
253
|
+
out.push('<dt>Product and version</dt><dd></dd><dt>Evaluator</dt><dd></dd><dt>Evaluation date</dt><dd></dd>');
|
|
254
|
+
out.push('<dt>Standard</dt><dd>WCAG 2.2 Level A and AA</dd>');
|
|
255
|
+
for (const [k, v] of scanDetails(report, sheet))
|
|
256
|
+
out.push(`<dt>${escapeHtml(k)}</dt><dd>${escapeHtml(v)}</dd>`);
|
|
257
|
+
out.push('</dl>');
|
|
258
|
+
out.push('<section aria-labelledby="summary">', '<h2 id="summary">Summary</h2>', '<ul>');
|
|
259
|
+
for (const result of Object.keys(ACR_RESULT_LABELS)) {
|
|
260
|
+
out.push(`<li>${escapeHtml(ACR_RESULT_LABELS[result])}: ${counts[result]}</li>`);
|
|
261
|
+
}
|
|
262
|
+
out.push('</ul>', `<p class="meta">${escapeHtml(HEURISTIC_NOTE)} ${escapeHtml(EXCLUDED_NOTE)}</p>`, '</section>');
|
|
263
|
+
out.push('<section aria-labelledby="criteria">', '<h2 id="criteria">WCAG 2.2 Level A and AA</h2>');
|
|
264
|
+
out.push('<div class="table-wrap"><table class="acr">');
|
|
265
|
+
out.push('<thead><tr><th scope="col">Criterion</th><th scope="col">Level</th><th scope="col">Automated result</th><th scope="col">Evidence</th><th scope="col">Conformance Level</th><th scope="col">Remarks and Explanations</th></tr></thead>');
|
|
266
|
+
out.push('<tbody>');
|
|
267
|
+
for (const row of sheet.rows) {
|
|
268
|
+
const { criterion } = row;
|
|
269
|
+
const evidence = row.evidence.length
|
|
270
|
+
? `<ul class="evidence">${row.evidence
|
|
271
|
+
.map((e) => `<li>${link(e.helpUrl, e.rule)} ${escapeHtml(evidenceText(e).slice(e.rule.length + 1))}</li>`)
|
|
272
|
+
.join('')}</ul>`
|
|
273
|
+
: escapeHtml(checkedByText(row.checkedBy));
|
|
274
|
+
out.push(`<tr><th scope="row">${link(understandingUrl(criterion), `${criterion.id} ${criterion.name}`)}</th>` +
|
|
275
|
+
`<td class="level">${criterion.level}</td>` +
|
|
276
|
+
`<td><span class="result result-${row.result}">${escapeHtml(ACR_RESULT_LABELS[row.result])}</span></td>` +
|
|
277
|
+
`<td>${evidence}</td><td class="blank"></td><td class="blank"></td></tr>`);
|
|
278
|
+
}
|
|
279
|
+
out.push('</tbody>', '</table></div>', '</section>');
|
|
280
|
+
if (sheet.other.length) {
|
|
281
|
+
out.push('<section aria-labelledby="other">', '<h2 id="other">Other findings</h2>');
|
|
282
|
+
out.push('<p>Rules not mapped to a WCAG 2.2 A/AA criterion: best practices, Level AAA, or 4.1.1. Worth fixing; not rows in the table above.</p>');
|
|
283
|
+
out.push('<ul class="evidence">');
|
|
284
|
+
for (const e of sheet.other) {
|
|
285
|
+
out.push(`<li>${link(e.helpUrl, e.rule)} ${escapeHtml(evidenceText(e).slice(e.rule.length + 1))}</li>`);
|
|
286
|
+
}
|
|
287
|
+
out.push('</ul>', '</section>');
|
|
288
|
+
}
|
|
289
|
+
out.push('</main>', '</body>', '</html>');
|
|
290
|
+
return out.join('\n');
|
|
291
|
+
}
|
package/dist/report/format.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { A11yFinding } from '../scan.js';
|
|
1
|
+
import type { A11yFinding, Impact } from '../scan.js';
|
|
2
2
|
import type { BaselineDiff } from './baseline.js';
|
|
3
3
|
/**
|
|
4
4
|
* Pure formatting for report-mode: grouping + Markdown/JSON serialization. Kept
|
|
@@ -38,10 +38,23 @@ export declare const COVERAGE_URL = "https://ngbracket.com/tools/a11y-devtools/d
|
|
|
38
38
|
* conformance claim, and a VPAT/ACR needs a person to judge every criterion.
|
|
39
39
|
*/
|
|
40
40
|
export declare const REPORT_SCOPE_NOTE: string;
|
|
41
|
+
/** Which checks a run used — so a report can say what was and wasn't tested. */
|
|
42
|
+
export interface ScanChecks {
|
|
43
|
+
/** axe-core version the scan ran. */
|
|
44
|
+
axeVersion: string;
|
|
45
|
+
/** axe tags the ruleset was restricted to; absent means axe's default ruleset. */
|
|
46
|
+
tags?: string[];
|
|
47
|
+
/** The keyboard layer's `ngbr/*` rules ran. */
|
|
48
|
+
keyboard: boolean;
|
|
49
|
+
/** The real-Tab keyboard-trap walk (`ngbr/focus-trap`) ran. */
|
|
50
|
+
focusTraps: boolean;
|
|
51
|
+
}
|
|
41
52
|
/** A whole report-mode run across one or more pages. */
|
|
42
53
|
export interface ScanReport {
|
|
43
54
|
/** ISO timestamp of the run. */
|
|
44
55
|
generatedAt: string;
|
|
56
|
+
/** What the run checked. Set by `scanPages`; absent in hand-built reports. */
|
|
57
|
+
checks?: ScanChecks;
|
|
45
58
|
pages: PageReport[];
|
|
46
59
|
}
|
|
47
60
|
/**
|
|
@@ -56,6 +69,7 @@ export declare function groupByComponent(findings: A11yFinding[]): Map<string, A
|
|
|
56
69
|
* actually describes an app. Reports surface both so neither can mislead.
|
|
57
70
|
*/
|
|
58
71
|
export declare function distinctRuleCount(findings: A11yFinding[]): number;
|
|
72
|
+
export declare function impactRank(impact: Impact): number;
|
|
59
73
|
/**
|
|
60
74
|
* Serialize a report to JSON, with per-page and overall summary counts. With a
|
|
61
75
|
* baseline `diff`, adds a `baseline` block (counts + the new findings). The
|
package/dist/report/format.js
CHANGED
|
@@ -46,7 +46,7 @@ const IMPACT_RANK = {
|
|
|
46
46
|
moderate: 2,
|
|
47
47
|
minor: 3,
|
|
48
48
|
};
|
|
49
|
-
function impactRank(impact) {
|
|
49
|
+
export function impactRank(impact) {
|
|
50
50
|
return impact ? (IMPACT_RANK[impact] ?? 4) : 4;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
@@ -59,6 +59,7 @@ export function toJson(report, diff) {
|
|
|
59
59
|
return JSON.stringify({
|
|
60
60
|
generatedAt: report.generatedAt,
|
|
61
61
|
scope: `${REPORT_SCOPE_NOTE} ${COVERAGE_URL}`,
|
|
62
|
+
...(report.checks && { checks: report.checks }),
|
|
62
63
|
summary: {
|
|
63
64
|
pages: report.pages.length,
|
|
64
65
|
distinctRules: distinctRuleCount(all),
|
package/dist/report/headless.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
2
3
|
import { dirname, resolve } from 'node:path';
|
|
3
4
|
import { fileURLToPath } from 'node:url';
|
|
4
5
|
import { detectTabTrap } from '../keyboard/focus-walk.js';
|
|
@@ -170,5 +171,14 @@ export async function scanPages(options) {
|
|
|
170
171
|
finally {
|
|
171
172
|
await browser.close();
|
|
172
173
|
}
|
|
173
|
-
|
|
174
|
+
const checks = {
|
|
175
|
+
axeVersion: axeVersion(),
|
|
176
|
+
...(tags && { tags }),
|
|
177
|
+
keyboard: keyboard ?? false,
|
|
178
|
+
focusTraps,
|
|
179
|
+
};
|
|
180
|
+
return { generatedAt: new Date().toISOString(), checks, pages };
|
|
181
|
+
}
|
|
182
|
+
function axeVersion() {
|
|
183
|
+
return createRequire(import.meta.url)('axe-core/package.json').version;
|
|
174
184
|
}
|
package/dist/report/html.d.ts
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import type { BaselineDiff } from './baseline.js';
|
|
2
2
|
import { type ScanReport } from './format.js';
|
|
3
|
+
/**
|
|
4
|
+
* A single self-contained HTML report: inline CSS, no scripts, no external
|
|
5
|
+
* requests — so it can be attached to a CI run, emailed, or opened offline.
|
|
6
|
+
* Same content as the Markdown report (summary, optional baseline comparison,
|
|
7
|
+
* findings grouped by owning component, most severe first).
|
|
8
|
+
*
|
|
9
|
+
* An accessibility tool's own report has to be accessible: landmarks, a
|
|
10
|
+
* sequential heading outline, a real data table with header cells, severity
|
|
11
|
+
* given as text (never colour alone), and AA contrast in light and dark
|
|
12
|
+
* schemes. Component groups are plain `<h3>` sections rather than
|
|
13
|
+
* `<details>`: a heading inside `<summary>` loses its heading semantics in some
|
|
14
|
+
* browsers, and heading navigation is how screen-reader users move through a
|
|
15
|
+
* long report.
|
|
16
|
+
*/
|
|
17
|
+
export declare function escapeHtml(text: string): string;
|
|
18
|
+
/** Only http(s) links are rendered as links; anything else stays plain text. */
|
|
19
|
+
export declare function safeHref(url: string): string | null;
|
|
20
|
+
export declare const STYLES = "\n:root {\n color-scheme: light dark;\n --bg: #ffffff; --fg: #1a1a1a; --muted: #555555; --line: #d9d9d9; --panel: #f6f6f6;\n --critical: #a4001d; --serious: #9a4400; --moderate: #6b5300; --minor: #1f4e9c;\n --new: #0b6b3a; --link: #0b57d0;\n}\n@media (prefers-color-scheme: dark) {\n :root {\n --bg: #161616; --fg: #ececec; --muted: #b5b5b5; --line: #3a3a3a; --panel: #222222;\n --critical: #ff8a9a; --serious: #ffb77a; --moderate: #f0d060; --minor: #9cc3ff;\n --new: #7ee0a8; --link: #9cc3ff;\n }\n}\n* { box-sizing: border-box; }\nbody { margin: 0; background: var(--bg); color: var(--fg);\n font: 15px/1.55 system-ui, -apple-system, \"Segoe UI\", sans-serif; }\nmain { max-width: 960px; margin: 0 auto; padding: 32px 16px 64px; }\nh1 { font-size: 1.6rem; margin: 0 0 4px; }\nh2 { font-size: 1.25rem; margin: 40px 0 12px; padding-top: 16px; border-top: 1px solid var(--line); }\nh3 { font-size: 1.05rem; margin: 0 0 4px; }\n.meta { color: var(--muted); margin: 0 0 12px; }\n.scope { background: var(--panel); border: 1px solid var(--line); border-radius: 8px;\n margin: 0 0 24px; padding: 10px 14px; }\na { color: var(--link); }\ncode { font: 0.9em/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }\ntable { border-collapse: collapse; width: 100%; margin: 8px 0 16px; }\nth, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); }\nth[scope=\"col\"]:not(:first-child), td:not(:first-child) { text-align: right; }\ntfoot th, tfoot td { font-weight: 700; }\n.table-wrap { overflow-x: auto; }\n.component { background: var(--panel); border: 1px solid var(--line); border-radius: 8px;\n margin: 12px 0; padding: 12px 14px 0; }\n.count { color: var(--muted); font-weight: 400; }\na:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }\n.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;\n overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }\nul.findings { list-style: none; margin: 0 0 12px; padding: 0; }\nul.findings > li { padding: 10px 0; border-top: 1px solid var(--line); }\n.impact { font-weight: 700; text-transform: uppercase; font-size: 0.8em; letter-spacing: 0.04em; }\n.impact-critical { color: var(--critical); } .impact-serious { color: var(--serious); }\n.impact-moderate { color: var(--moderate); } .impact-minor { color: var(--minor); }\n.new { font-weight: 700; color: var(--new); }\n.rule { font-weight: 600; }\n.via, .detail { color: var(--muted); font-size: 0.92em; }\n.detail { margin: 4px 0 0; }\n.ok { color: var(--new); font-weight: 600; }\n.error { color: var(--critical); font-weight: 600; }\n.diff { background: var(--panel); border: 1px solid var(--line); border-radius: 8px;\n margin-top: 32px; padding: 4px 16px; }\n.diff h2 { border-top: 0; margin-top: 12px; padding-top: 0; }\n";
|
|
3
21
|
/** Render the report as one self-contained, accessible HTML document. */
|
|
4
22
|
export declare function toHtml(report: ScanReport, diff?: BaselineDiff): string;
|
package/dist/report/html.js
CHANGED
|
@@ -13,7 +13,7 @@ import { addedBySeverity, COVERAGE_URL, DARK_ONLY_NOTE, REPORT_SCOPE_NOTE, REPOR
|
|
|
13
13
|
* browsers, and heading navigation is how screen-reader users move through a
|
|
14
14
|
* long report.
|
|
15
15
|
*/
|
|
16
|
-
function escapeHtml(text) {
|
|
16
|
+
export function escapeHtml(text) {
|
|
17
17
|
return text
|
|
18
18
|
.replace(/&/g, '&')
|
|
19
19
|
.replace(/</g, '<')
|
|
@@ -22,10 +22,10 @@ function escapeHtml(text) {
|
|
|
22
22
|
.replace(/'/g, ''');
|
|
23
23
|
}
|
|
24
24
|
/** Only http(s) links are rendered as links; anything else stays plain text. */
|
|
25
|
-
function safeHref(url) {
|
|
25
|
+
export function safeHref(url) {
|
|
26
26
|
return /^https?:\/\//i.test(url) ? escapeHtml(url) : null;
|
|
27
27
|
}
|
|
28
|
-
const STYLES = `
|
|
28
|
+
export const STYLES = `
|
|
29
29
|
:root {
|
|
30
30
|
color-scheme: light dark;
|
|
31
31
|
--bg: #ffffff; --fg: #1a1a1a; --muted: #555555; --line: #d9d9d9; --panel: #f6f6f6;
|
package/dist/report/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { scanPages, type ColorScheme, type ScanPagesOptions, type ThemeContext, } from './headless.js';
|
|
2
|
-
export { groupByComponent, distinctRuleCount, toJson, toMarkdown, DARK_ONLY_NOTE, type PageReport, type ScanReport, } from './format.js';
|
|
2
|
+
export { groupByComponent, distinctRuleCount, toJson, toMarkdown, DARK_ONLY_NOTE, type PageReport, type ScanChecks, type ScanReport, } from './format.js';
|
|
3
3
|
export { toHtml } from './html.js';
|
|
4
4
|
export { diffAgainstBaseline, findingKey, findingsNotIn, parseBaseline, type BaselineDiff, type BaselineReport, type NewFinding, } from './baseline.js';
|
|
5
5
|
export { isServing, startDevServer, type DevServer, type DevServerOptions } from './serve.js';
|
|
6
|
+
export { ACR_RESULT_LABELS, ACR_TITLE, buildAcrWorksheet, toAcrHtml, toAcrMarkdown, type AcrResult, type AcrRow, type AcrRuleEvidence, type AcrWorksheet, type AxeRuleMeta, } from './acr.js';
|
|
7
|
+
export { WCAG22_A_AA, understandingUrl, type WcagCriterion } from './wcag.js';
|
package/dist/report/index.js
CHANGED
|
@@ -3,3 +3,5 @@ export { groupByComponent, distinctRuleCount, toJson, toMarkdown, DARK_ONLY_NOTE
|
|
|
3
3
|
export { toHtml } from './html.js';
|
|
4
4
|
export { diffAgainstBaseline, findingKey, findingsNotIn, parseBaseline, } from './baseline.js';
|
|
5
5
|
export { isServing, startDevServer } from './serve.js';
|
|
6
|
+
export { ACR_RESULT_LABELS, ACR_TITLE, buildAcrWorksheet, toAcrHtml, toAcrMarkdown, } from './acr.js';
|
|
7
|
+
export { WCAG22_A_AA, understandingUrl } from './wcag.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** A WCAG success criterion. */
|
|
2
|
+
export interface WcagCriterion {
|
|
3
|
+
/** e.g. `1.4.3`. */
|
|
4
|
+
id: string;
|
|
5
|
+
/** e.g. `Contrast (Minimum)`. */
|
|
6
|
+
name: string;
|
|
7
|
+
level: 'A' | 'AA';
|
|
8
|
+
/** Slug of its W3C "Understanding" page. */
|
|
9
|
+
slug: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* WCAG 2.2 Level A and AA success criteria, in document order — the set a
|
|
13
|
+
* VPAT/ACR "WCAG 2.2 Report" table covers. 4.1.1 Parsing is left out: WCAG 2.2
|
|
14
|
+
* marks it obsolete and removed.
|
|
15
|
+
*/
|
|
16
|
+
export declare const WCAG22_A_AA: readonly WcagCriterion[];
|
|
17
|
+
/** The W3C "Understanding" page for a criterion. */
|
|
18
|
+
export declare function understandingUrl(criterion: WcagCriterion): string;
|
|
19
|
+
/**
|
|
20
|
+
* The criterion an axe tag names, e.g. `wcag143` → `1.4.3`, `wcag1410` →
|
|
21
|
+
* `1.4.10`; undefined for level tags (`wcag2aa`) and criteria outside
|
|
22
|
+
* {@link WCAG22_A_AA}. Dropping the dots is unambiguous within the A/AA set.
|
|
23
|
+
*/
|
|
24
|
+
export declare function criterionForTag(tag: string): WcagCriterion | undefined;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WCAG 2.2 Level A and AA success criteria, in document order — the set a
|
|
3
|
+
* VPAT/ACR "WCAG 2.2 Report" table covers. 4.1.1 Parsing is left out: WCAG 2.2
|
|
4
|
+
* marks it obsolete and removed.
|
|
5
|
+
*/
|
|
6
|
+
export const WCAG22_A_AA = [
|
|
7
|
+
{ id: '1.1.1', name: 'Non-text Content', level: 'A', slug: 'non-text-content' },
|
|
8
|
+
{ id: '1.2.1', name: 'Audio-only and Video-only (Prerecorded)', level: 'A', slug: 'audio-only-and-video-only-prerecorded' },
|
|
9
|
+
{ id: '1.2.2', name: 'Captions (Prerecorded)', level: 'A', slug: 'captions-prerecorded' },
|
|
10
|
+
{ id: '1.2.3', name: 'Audio Description or Media Alternative (Prerecorded)', level: 'A', slug: 'audio-description-or-media-alternative-prerecorded' },
|
|
11
|
+
{ id: '1.2.4', name: 'Captions (Live)', level: 'AA', slug: 'captions-live' },
|
|
12
|
+
{ id: '1.2.5', name: 'Audio Description (Prerecorded)', level: 'AA', slug: 'audio-description-prerecorded' },
|
|
13
|
+
{ id: '1.3.1', name: 'Info and Relationships', level: 'A', slug: 'info-and-relationships' },
|
|
14
|
+
{ id: '1.3.2', name: 'Meaningful Sequence', level: 'A', slug: 'meaningful-sequence' },
|
|
15
|
+
{ id: '1.3.3', name: 'Sensory Characteristics', level: 'A', slug: 'sensory-characteristics' },
|
|
16
|
+
{ id: '1.3.4', name: 'Orientation', level: 'AA', slug: 'orientation' },
|
|
17
|
+
{ id: '1.3.5', name: 'Identify Input Purpose', level: 'AA', slug: 'identify-input-purpose' },
|
|
18
|
+
{ id: '1.4.1', name: 'Use of Color', level: 'A', slug: 'use-of-color' },
|
|
19
|
+
{ id: '1.4.2', name: 'Audio Control', level: 'A', slug: 'audio-control' },
|
|
20
|
+
{ id: '1.4.3', name: 'Contrast (Minimum)', level: 'AA', slug: 'contrast-minimum' },
|
|
21
|
+
{ id: '1.4.4', name: 'Resize Text', level: 'AA', slug: 'resize-text' },
|
|
22
|
+
{ id: '1.4.5', name: 'Images of Text', level: 'AA', slug: 'images-of-text' },
|
|
23
|
+
{ id: '1.4.10', name: 'Reflow', level: 'AA', slug: 'reflow' },
|
|
24
|
+
{ id: '1.4.11', name: 'Non-text Contrast', level: 'AA', slug: 'non-text-contrast' },
|
|
25
|
+
{ id: '1.4.12', name: 'Text Spacing', level: 'AA', slug: 'text-spacing' },
|
|
26
|
+
{ id: '1.4.13', name: 'Content on Hover or Focus', level: 'AA', slug: 'content-on-hover-or-focus' },
|
|
27
|
+
{ id: '2.1.1', name: 'Keyboard', level: 'A', slug: 'keyboard' },
|
|
28
|
+
{ id: '2.1.2', name: 'No Keyboard Trap', level: 'A', slug: 'no-keyboard-trap' },
|
|
29
|
+
{ id: '2.1.4', name: 'Character Key Shortcuts', level: 'A', slug: 'character-key-shortcuts' },
|
|
30
|
+
{ id: '2.2.1', name: 'Timing Adjustable', level: 'A', slug: 'timing-adjustable' },
|
|
31
|
+
{ id: '2.2.2', name: 'Pause, Stop, Hide', level: 'A', slug: 'pause-stop-hide' },
|
|
32
|
+
{ id: '2.3.1', name: 'Three Flashes or Below Threshold', level: 'A', slug: 'three-flashes-or-below-threshold' },
|
|
33
|
+
{ id: '2.4.1', name: 'Bypass Blocks', level: 'A', slug: 'bypass-blocks' },
|
|
34
|
+
{ id: '2.4.2', name: 'Page Titled', level: 'A', slug: 'page-titled' },
|
|
35
|
+
{ id: '2.4.3', name: 'Focus Order', level: 'A', slug: 'focus-order' },
|
|
36
|
+
{ id: '2.4.4', name: 'Link Purpose (In Context)', level: 'A', slug: 'link-purpose-in-context' },
|
|
37
|
+
{ id: '2.4.5', name: 'Multiple Ways', level: 'AA', slug: 'multiple-ways' },
|
|
38
|
+
{ id: '2.4.6', name: 'Headings and Labels', level: 'AA', slug: 'headings-and-labels' },
|
|
39
|
+
{ id: '2.4.7', name: 'Focus Visible', level: 'AA', slug: 'focus-visible' },
|
|
40
|
+
{ id: '2.4.11', name: 'Focus Not Obscured (Minimum)', level: 'AA', slug: 'focus-not-obscured-minimum' },
|
|
41
|
+
{ id: '2.5.1', name: 'Pointer Gestures', level: 'A', slug: 'pointer-gestures' },
|
|
42
|
+
{ id: '2.5.2', name: 'Pointer Cancellation', level: 'A', slug: 'pointer-cancellation' },
|
|
43
|
+
{ id: '2.5.3', name: 'Label in Name', level: 'A', slug: 'label-in-name' },
|
|
44
|
+
{ id: '2.5.4', name: 'Motion Actuation', level: 'A', slug: 'motion-actuation' },
|
|
45
|
+
{ id: '2.5.7', name: 'Dragging Movements', level: 'AA', slug: 'dragging-movements' },
|
|
46
|
+
{ id: '2.5.8', name: 'Target Size (Minimum)', level: 'AA', slug: 'target-size-minimum' },
|
|
47
|
+
{ id: '3.1.1', name: 'Language of Page', level: 'A', slug: 'language-of-page' },
|
|
48
|
+
{ id: '3.1.2', name: 'Language of Parts', level: 'AA', slug: 'language-of-parts' },
|
|
49
|
+
{ id: '3.2.1', name: 'On Focus', level: 'A', slug: 'on-focus' },
|
|
50
|
+
{ id: '3.2.2', name: 'On Input', level: 'A', slug: 'on-input' },
|
|
51
|
+
{ id: '3.2.3', name: 'Consistent Navigation', level: 'AA', slug: 'consistent-navigation' },
|
|
52
|
+
{ id: '3.2.4', name: 'Consistent Identification', level: 'AA', slug: 'consistent-identification' },
|
|
53
|
+
{ id: '3.2.6', name: 'Consistent Help', level: 'A', slug: 'consistent-help' },
|
|
54
|
+
{ id: '3.3.1', name: 'Error Identification', level: 'A', slug: 'error-identification' },
|
|
55
|
+
{ id: '3.3.2', name: 'Labels or Instructions', level: 'A', slug: 'labels-or-instructions' },
|
|
56
|
+
{ id: '3.3.3', name: 'Error Suggestion', level: 'AA', slug: 'error-suggestion' },
|
|
57
|
+
{ id: '3.3.4', name: 'Error Prevention (Legal, Financial, Data)', level: 'AA', slug: 'error-prevention-legal-financial-data' },
|
|
58
|
+
{ id: '3.3.7', name: 'Redundant Entry', level: 'A', slug: 'redundant-entry' },
|
|
59
|
+
{ id: '3.3.8', name: 'Accessible Authentication (Minimum)', level: 'AA', slug: 'accessible-authentication-minimum' },
|
|
60
|
+
{ id: '4.1.2', name: 'Name, Role, Value', level: 'A', slug: 'name-role-value' },
|
|
61
|
+
{ id: '4.1.3', name: 'Status Messages', level: 'AA', slug: 'status-messages' },
|
|
62
|
+
];
|
|
63
|
+
/** The W3C "Understanding" page for a criterion. */
|
|
64
|
+
export function understandingUrl(criterion) {
|
|
65
|
+
return `https://www.w3.org/WAI/WCAG22/Understanding/${criterion.slug}.html`;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The criterion an axe tag names, e.g. `wcag143` → `1.4.3`, `wcag1410` →
|
|
69
|
+
* `1.4.10`; undefined for level tags (`wcag2aa`) and criteria outside
|
|
70
|
+
* {@link WCAG22_A_AA}. Dropping the dots is unambiguous within the A/AA set.
|
|
71
|
+
*/
|
|
72
|
+
export function criterionForTag(tag) {
|
|
73
|
+
const digits = /^wcag(\d{3,4})$/.exec(tag)?.[1];
|
|
74
|
+
return digits ? BY_DIGITS.get(digits) : undefined;
|
|
75
|
+
}
|
|
76
|
+
const BY_DIGITS = new Map(WCAG22_A_AA.map((c) => [c.id.replace(/\./g, ''), c]));
|
package/dist/scan.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface A11yFinding {
|
|
|
26
26
|
helpUrl: string;
|
|
27
27
|
/** Owning component name, or null when attribution isn't available (prod). */
|
|
28
28
|
component: string | null;
|
|
29
|
-
/** Owning components from the flagged node up to the root, nearest first; [] in prod. */
|
|
29
|
+
/** Owning components from the flagged node up to the root, nearest first, each once; [] in prod. */
|
|
30
30
|
componentPath: string[];
|
|
31
31
|
/** Directives on the flagged node (incl. hostDirectives); [] when none/unavailable. */
|
|
32
32
|
directives: string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngbracket/a11y-devtools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "Dev-only in-app accessibility auditing for Angular that maps each axe violation back to the component that rendered it — the attribution React overlay tools can't do.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Duncan Faulkner",
|