@ngbracket/a11y-devtools 0.12.3 → 0.14.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/CHANGELOG.md CHANGED
@@ -3,6 +3,41 @@
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.0
7
+
8
+ ### Added
9
+
10
+ - **Evaluation worksheet for a VPAT/ACR.** `--format acr` writes
11
+ `<prefix>.acr.html` and `--format acr-md` writes `<prefix>.acr.md`: the scan
12
+ organised by WCAG 2.2 Level A and AA success criterion, one row per criterion.
13
+ Each row says what the scan found — "Automated failures found", "Possible
14
+ failures found — verify manually" (heuristic `ngbr/*` rules only), "No
15
+ automated failures detected — manual review required", or "No automated checks
16
+ — manual review required" — with the evidence (rule, impact, instances, pages,
17
+ components) or the rules that checked it. It never says "Supports": the
18
+ Conformance Level and Remarks columns, and the product, evaluator and date
19
+ fields, are left blank for a person. Findings from rules not mapped to an A/AA
20
+ criterion (best practices, AAA) are listed separately rather than dropped.
21
+ From code: `buildAcrWorksheet()`, `toAcrHtml()`, `toAcrMarkdown()`.
22
+ - **Reports record what was checked.** `scanPages()` results and JSON reports
23
+ now carry `checks`: the axe-core version, any `--tags`, and whether keyboard
24
+ checks and the keyboard-trap walk ran.
25
+
26
+ ## 0.13.0
27
+
28
+ ### Added
29
+
30
+ - **Report mode can start your dev server.** `--serve "<command>"` runs the
31
+ command (for example `--serve "npx ng serve"`), waits until `--base` answers,
32
+ scans, then stops the server and everything it started — even on Ctrl+C or a
33
+ cancelled CI job. `--base` defaults to `http://localhost:4200` with `--serve`.
34
+ If something already answers at `--base`, that server is scanned and nothing is
35
+ started, so the same command works locally with `ng serve` already running.
36
+ `--serve-timeout <seconds>` (default 180) sets how long to wait. If the command
37
+ exits early or never answers, the CLI exits with code `2` and prints the last
38
+ lines of its output. From code: `startDevServer()` and `isServing()` from
39
+ `@ngbracket/a11y-devtools/report`.
40
+
6
41
  ## 0.12.3
7
42
 
8
43
  ### Changed
package/README.md CHANGED
@@ -59,17 +59,21 @@ finding highlights labelled with their owning component (including the ngbr/*
59
59
  keyboard findings), and the focus-follow accessibility-tree panel showing the
60
60
  focused button's computed role, name and states.](./demo/keyboard-layer-2026-09.png)
61
61
 
62
- In CI, against a running `ng serve`:
62
+ In CI (`--serve` starts `ng serve`, waits for it, and stops it after the scan):
63
63
 
64
64
  ```bash
65
- npx ngbr-a11y-report --base http://localhost:4200 --route / --route /settings \
65
+ 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
 
@@ -4,6 +4,9 @@ import {
4
4
  diffAgainstBaseline,
5
5
  parseBaseline,
6
6
  scanPages,
7
+ startDevServer,
8
+ toAcrHtml,
9
+ toAcrMarkdown,
7
10
  toHtml,
8
11
  toJson,
9
12
  toMarkdown,
@@ -13,14 +16,24 @@ const USAGE = `ngbr-a11y-report — component-attributed a11y scan of a running
13
16
 
14
17
  Usage:
15
18
  ngbr-a11y-report --base <url> --route <path> [--route <path> ...] [options]
19
+ ngbr-a11y-report --serve "<command>" --route <path> [...] [options]
16
20
 
17
21
  Options:
18
- --base <url> Origin of the running dev server (e.g. http://localhost:4200)
22
+ --base <url> Origin of the running dev server (e.g. http://localhost:4200).
23
+ With --serve, defaults to http://localhost:4200
24
+ --serve <command> Start the dev server with this command, wait until --base
25
+ answers, scan, then stop it — e.g. --serve "npx ng serve".
26
+ If --base already answers, that server is used as-is
27
+ --serve-timeout <s>
28
+ Seconds to wait for --serve to answer (default 180)
19
29
  --route <path> Route to scan; repeat for multiple routes
20
30
  --tags <list> Comma-separated axe tags to scope the ruleset (e.g. wcag22aa,best-practice)
21
31
  --out <prefix> Write <prefix>.md / .json / .html (default: print Markdown to stdout)
22
32
  --format <list> Comma-separated: md, json, html — or both (= md,json) or all
23
- (default: both when --out is set)
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
24
37
  --wait <ms> Settle time after load before scanning (default 1500)
25
38
  --fail-on <impact> Exit non-zero if any finding is at/above impact
26
39
  (minor | moderate | serious | critical) — for CI gating.
@@ -63,6 +76,8 @@ function parseArgs(argv) {
63
76
  const next = () => argv[++i];
64
77
  switch (arg) {
65
78
  case '--base': opts.base = next(); break;
79
+ case '--serve': opts.serve = next(); break;
80
+ case '--serve-timeout': opts.serveTimeout = Number(next()); break;
66
81
  case '--route': opts.routes.push(next()); break;
67
82
  case '--tags': opts.tags = next().split(',').map((s) => s.trim()).filter(Boolean); break;
68
83
  case '--out': opts.out = next(); break;
@@ -88,21 +103,34 @@ function parseArgs(argv) {
88
103
  }
89
104
 
90
105
  const opts = parseArgs(process.argv.slice(2));
106
+ if (opts.serve && !opts.base) opts.base = 'http://localhost:4200';
91
107
 
92
108
  if (opts.help || !opts.base || opts.routes.length === 0) {
93
109
  process.stderr.write(USAGE);
94
110
  process.exit(opts.help ? 0 : 1);
95
111
  }
96
112
 
97
- const FORMATS = { md: ['md'], json: ['json'], html: ['html'], both: ['md', 'json'], all: ['md', 'json', 'html'] };
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
+ };
98
122
  const formats = new Set();
99
123
  for (const name of String(opts.format).split(',').map((s) => s.trim()).filter(Boolean)) {
100
124
  if (!FORMATS[name]) {
101
- process.stderr.write(`Invalid --format "${name}" (use md, json, html, both or all)\n`);
125
+ process.stderr.write(`Invalid --format "${name}" (use md, json, html, both, all, acr or acr-md)\n`);
102
126
  process.exit(2);
103
127
  }
104
128
  FORMATS[name].forEach((f) => formats.add(f));
105
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
+ }
106
134
 
107
135
  if (opts.colorScheme && !['light', 'dark', 'both'].includes(opts.colorScheme)) {
108
136
  process.stderr.write(`Invalid --color-scheme "${opts.colorScheme}" (use light, dark or both)\n`);
@@ -129,19 +157,52 @@ if (opts.baseline) {
129
157
  }
130
158
  }
131
159
 
132
- const report = await scanPages({
133
- baseUrl: opts.base,
134
- routes: opts.routes,
135
- tags: opts.tags,
136
- waitMs: opts.wait,
137
- headed: opts.headed,
138
- frameworkPrefixes: opts.frameworkPrefixes,
139
- keyboard: opts.keyboard,
140
- focusTraps: opts.focusTraps,
141
- colorScheme: opts.colorScheme,
142
- darkClass: opts.darkClass,
143
- darkAttribute,
144
- });
160
+ if (opts.serveTimeout !== undefined && !(opts.serveTimeout > 0)) {
161
+ process.stderr.write('Invalid --serve-timeout (use a number of seconds, e.g. 300)\n');
162
+ process.exit(2);
163
+ }
164
+
165
+ let server;
166
+ if (opts.serve) {
167
+ process.stderr.write(`Starting dev server: ${opts.serve}\n`);
168
+ try {
169
+ server = await startDevServer({
170
+ command: opts.serve,
171
+ url: opts.base,
172
+ timeoutMs: opts.serveTimeout === undefined ? undefined : opts.serveTimeout * 1000,
173
+ });
174
+ } catch (err) {
175
+ process.stderr.write(`${err.message}\n`);
176
+ process.exit(2);
177
+ }
178
+ process.stderr.write(
179
+ server.reused
180
+ ? `${opts.base} is already serving; scanning that (nothing started).\n`
181
+ : `Dev server is up at ${opts.base}.\n`,
182
+ );
183
+ }
184
+
185
+ let report;
186
+ try {
187
+ report = await scanPages({
188
+ baseUrl: opts.base,
189
+ routes: opts.routes,
190
+ tags: opts.tags,
191
+ waitMs: opts.wait,
192
+ headed: opts.headed,
193
+ frameworkPrefixes: opts.frameworkPrefixes,
194
+ keyboard: opts.keyboard,
195
+ focusTraps: opts.focusTraps,
196
+ colorScheme: opts.colorScheme,
197
+ darkClass: opts.darkClass,
198
+ darkAttribute,
199
+ });
200
+ } finally {
201
+ if (server && !server.reused) {
202
+ await server.stop();
203
+ process.stderr.write('Stopped the dev server.\n');
204
+ }
205
+ }
145
206
 
146
207
  const allFindings = report.pages.flatMap((p) => p.findings);
147
208
  process.stderr.write(
@@ -162,10 +223,17 @@ if (allFindings.length > 0 && allFindings.every((f) => f.component === null)) {
162
223
  if (!opts.out) {
163
224
  process.stdout.write(toMarkdown(report, diff) + '\n');
164
225
  } else {
165
- const render = { md: toMarkdown, json: toJson, html: toHtml };
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
+ };
166
233
  for (const format of formats) {
167
- writeFileSync(`${opts.out}.${format}`, render[format](report, diff));
168
- process.stderr.write(`Wrote ${opts.out}.${format}\n`);
234
+ const [fn, ext] = render[format];
235
+ writeFileSync(`${opts.out}.${ext}`, fn(report, diff));
236
+ process.stderr.write(`Wrote ${opts.out}.${ext}\n`);
169
237
  }
170
238
  }
171
239
 
@@ -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
+ }
@@ -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
@@ -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),
@@ -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
- return { generatedAt: new Date().toISOString(), pages };
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
  }
@@ -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;
@@ -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, '&amp;')
19
19
  .replace(/</g, '&lt;')
@@ -22,10 +22,10 @@ function escapeHtml(text) {
22
22
  .replace(/'/g, '&#39;');
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;
@@ -1,4 +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
+ 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';
@@ -2,3 +2,6 @@ export { scanPages, } from './headless.js';
2
2
  export { groupByComponent, distinctRuleCount, toJson, toMarkdown, DARK_ONLY_NOTE, } from './format.js';
3
3
  export { toHtml } from './html.js';
4
4
  export { diffAgainstBaseline, findingKey, findingsNotIn, parseBaseline, } from './baseline.js';
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,33 @@
1
+ export interface DevServerOptions {
2
+ /** Shell command that starts the dev server, e.g. `npx ng serve admin --port 4300`. */
3
+ command: string;
4
+ /** URL to poll until the server answers, e.g. `http://localhost:4300`. */
5
+ url: string;
6
+ /** Give up if the server hasn't answered after this long (ms). Default 180000. */
7
+ timeoutMs?: number;
8
+ /**
9
+ * If something already answers at `url`, scan that and start nothing.
10
+ * Default true — handy locally when `ng serve` is already running.
11
+ */
12
+ reuseExisting?: boolean;
13
+ /** Working directory for the command. Default `process.cwd()`. */
14
+ cwd?: string;
15
+ /** Called with each line the command prints (stdout and stderr). */
16
+ onOutput?: (line: string) => void;
17
+ }
18
+ export interface DevServer {
19
+ /** True when an already-running server was reused and nothing was started. */
20
+ reused: boolean;
21
+ /** Stop the server (and everything it spawned). Safe to call more than once. */
22
+ stop(): Promise<void>;
23
+ }
24
+ /** True when something at `url` answers with a non-5xx response. */
25
+ export declare function isServing(url: string): Promise<boolean>;
26
+ /**
27
+ * Start a dev server and resolve once `url` answers — for report mode in CI,
28
+ * where nothing is running yet. Rejects (after stopping the process) if the
29
+ * command exits first or `timeoutMs` passes; the error includes the last lines
30
+ * of its output. Always `stop()` the result when the scan is done. Until then,
31
+ * SIGINT/SIGTERM stop the server before the process ends.
32
+ */
33
+ export declare function startDevServer(options: DevServerOptions): Promise<DevServer>;
@@ -0,0 +1,117 @@
1
+ import { spawn } from 'node:child_process';
2
+ /** Lines of dev-server output kept for the error message when it fails to start. */
3
+ const OUTPUT_TAIL = 30;
4
+ const POLL_MS = 500;
5
+ /** True when something at `url` answers with a non-5xx response. */
6
+ export async function isServing(url) {
7
+ try {
8
+ const res = await fetch(url, { signal: AbortSignal.timeout(2000), redirect: 'manual' });
9
+ await res.body?.cancel();
10
+ return res.status < 500;
11
+ }
12
+ catch {
13
+ return false;
14
+ }
15
+ }
16
+ /**
17
+ * Start a dev server and resolve once `url` answers — for report mode in CI,
18
+ * where nothing is running yet. Rejects (after stopping the process) if the
19
+ * command exits first or `timeoutMs` passes; the error includes the last lines
20
+ * of its output. Always `stop()` the result when the scan is done. Until then,
21
+ * SIGINT/SIGTERM stop the server before the process ends.
22
+ */
23
+ export async function startDevServer(options) {
24
+ const { command, url, timeoutMs = 180_000, reuseExisting = true } = options;
25
+ if (await isServing(url)) {
26
+ if (reuseExisting)
27
+ return { reused: true, stop: async () => { } };
28
+ throw new Error(`Something is already serving ${url}; stop it or use a different port.`);
29
+ }
30
+ // A process group of its own (POSIX), so stop() also ends what the shell spawned.
31
+ const child = spawn(command, {
32
+ cwd: options.cwd,
33
+ shell: true,
34
+ detached: process.platform !== 'win32',
35
+ stdio: ['ignore', 'pipe', 'pipe'],
36
+ });
37
+ const tail = [];
38
+ const collect = (chunk) => {
39
+ for (const line of chunk.toString().split(/\r?\n/)) {
40
+ if (!line.trim())
41
+ continue;
42
+ options.onOutput?.(line);
43
+ tail.push(line);
44
+ if (tail.length > OUTPUT_TAIL)
45
+ tail.shift();
46
+ }
47
+ };
48
+ child.stdout?.on('data', collect);
49
+ child.stderr?.on('data', collect);
50
+ let exitCode;
51
+ const exited = new Promise((done) => {
52
+ child.once('exit', (code, signal) => {
53
+ exitCode = code ?? (signal ? -1 : null);
54
+ done();
55
+ });
56
+ child.once('error', (err) => {
57
+ tail.push(err.message);
58
+ exitCode = -1;
59
+ done();
60
+ });
61
+ });
62
+ // The server is in its own process group, so Ctrl+C (or a cancelled CI job)
63
+ // doesn't reach it. Until stop(), pass those signals on, then re-raise them;
64
+ // if the process exits some other way, kill it synchronously.
65
+ const onSignal = (signal) => {
66
+ void stop().then(() => process.kill(process.pid, signal));
67
+ };
68
+ const onExit = () => killTree(child, 'SIGKILL');
69
+ process.once('SIGINT', onSignal);
70
+ process.once('SIGTERM', onSignal);
71
+ process.once('exit', onExit);
72
+ let stopped = false;
73
+ const stop = async () => {
74
+ if (stopped)
75
+ return;
76
+ stopped = true;
77
+ process.off('SIGINT', onSignal);
78
+ process.off('SIGTERM', onSignal);
79
+ process.off('exit', onExit);
80
+ if (exitCode === undefined) {
81
+ killTree(child, 'SIGTERM');
82
+ const forced = setTimeout(() => killTree(child, 'SIGKILL'), 5000);
83
+ await exited;
84
+ clearTimeout(forced);
85
+ }
86
+ };
87
+ const withOutput = (message) => new Error(tail.length ? `${message}\nLast output:\n ${tail.join('\n ')}` : message);
88
+ const deadline = Date.now() + timeoutMs;
89
+ while (true) {
90
+ if (exitCode !== undefined) {
91
+ await stop();
92
+ throw withOutput(`Dev server command exited (code ${exitCode}) before ${url} answered: ${command}`);
93
+ }
94
+ if (await isServing(url))
95
+ return { reused: false, stop };
96
+ if (Date.now() >= deadline) {
97
+ await stop();
98
+ throw withOutput(`Dev server didn't answer at ${url} within ${Math.round(timeoutMs / 1000)}s: ${command}`);
99
+ }
100
+ await Promise.race([exited, new Promise((r) => setTimeout(r, POLL_MS))]);
101
+ }
102
+ }
103
+ function killTree(child, signal) {
104
+ if (child.pid === undefined)
105
+ return;
106
+ try {
107
+ if (process.platform === 'win32') {
108
+ spawn('taskkill', ['/pid', String(child.pid), '/T', '/F'], { stdio: 'ignore' });
109
+ }
110
+ else {
111
+ process.kill(-child.pid, signal);
112
+ }
113
+ }
114
+ catch {
115
+ // Already gone.
116
+ }
117
+ }
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngbracket/a11y-devtools",
3
- "version": "0.12.3",
3
+ "version": "0.14.0",
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",