@ngbracket/a11y-devtools 0.14.1 → 0.15.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 +36 -0
- package/README.md +3 -1
- package/bin/ngbr-a11y-report.mjs +74 -21
- package/dist/inpage.global.js +17 -6
- package/dist/keyboard/keyboard-scan.js +5 -1
- package/dist/keyboard/tab-sequence.d.ts +6 -0
- package/dist/keyboard/tab-sequence.js +21 -2
- package/dist/report/format.d.ts +7 -0
- package/dist/report/format.js +34 -0
- package/dist/report/headless.d.ts +2 -0
- package/dist/report/headless.js +2 -1
- package/dist/report/index.d.ts +2 -2
- package/dist/report/index.js +2 -2
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,42 @@
|
|
|
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.15.1
|
|
7
|
+
|
|
8
|
+
### Fixed
|
|
9
|
+
|
|
10
|
+
- **Collapsed sidebars no longer cause false tab-order findings.** A
|
|
11
|
+
`<details>` nested inside a closed `<details>` (a group inside a collapsed
|
|
12
|
+
sidebar section) had its summary counted as a tab stop, although it's hidden
|
|
13
|
+
and Tab can't reach it. The next section's summary then looked like a jump
|
|
14
|
+
back up the page, so `ngbr/tab-order-mismatch` fired once per section. Every
|
|
15
|
+
closed `<details>` up the tree now counts. This also fixes the tab-order
|
|
16
|
+
badges in the overlay. Found on our own docs site.
|
|
17
|
+
- **`ngbr/unreachable-control` skips hidden controls.** A custom control inside
|
|
18
|
+
a closed `<details>`, a `[hidden]` or `inert` subtree, or `display: none` was
|
|
19
|
+
reported as unreachable. Tab can't reach it because it isn't shown, which
|
|
20
|
+
isn't a problem; it's checked once it's shown.
|
|
21
|
+
|
|
22
|
+
## 0.15.0
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- **Re-render a saved report without scanning.** `--from <report.json>` reads
|
|
27
|
+
a previous run's JSON report (from `--out`) and writes it in whatever
|
|
28
|
+
`--format`s you ask for, so you can add an HTML report or an ACR worksheet
|
|
29
|
+
later without running the scan again. `--baseline` and `--fail-on` work as
|
|
30
|
+
usual; scan options such as `--route` or `--keyboard` are refused. The
|
|
31
|
+
output is byte-for-byte what the original scan would have written. For the
|
|
32
|
+
ACR worksheet, it notes when the report's axe-core version differs from the
|
|
33
|
+
installed one, or when the report predates `checks` (0.14.0).
|
|
34
|
+
From code: `parseReport()`, plus `axeVersion()` for the installed axe-core.
|
|
35
|
+
|
|
36
|
+
### Changed
|
|
37
|
+
|
|
38
|
+
- Type-checking: the specs are now type-checked in CI, and the browser source
|
|
39
|
+
compiles without Node types (report mode has its own tsconfig). No change to
|
|
40
|
+
the published output.
|
|
41
|
+
|
|
6
42
|
## 0.14.1
|
|
7
43
|
|
|
8
44
|
### Fixed
|
package/README.md
CHANGED
|
@@ -67,7 +67,8 @@ npx ngbr-a11y-report --serve "npx ng serve" --route / --route /settings \
|
|
|
67
67
|
```
|
|
68
68
|
|
|
69
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.
|
|
70
|
+
A/AA criterion, with the conformance columns left for a person to fill in. Already scanned?
|
|
71
|
+
`--from a11y.json --out a11y --format acr` writes it from the saved JSON report.
|
|
71
72
|
|
|
72
73
|
Next steps, in the docs:
|
|
73
74
|
[Your first scan](https://ngbracket.com/tools/a11y-devtools/docs/first-scan) ·
|
|
@@ -135,3 +136,4 @@ ever becomes reachable through a static import.
|
|
|
135
136
|
- Real-browser E2E tests, including component attribution in a real Angular app.
|
|
136
137
|
- Report mode can start the dev server (`--serve`).
|
|
137
138
|
- ACR evaluation worksheet by WCAG 2.2 A/AA criterion (`--format acr`).
|
|
139
|
+
- Re-render a saved JSON report in any format without scanning (`--from`).
|
package/bin/ngbr-a11y-report.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import {
|
|
4
|
+
axeVersion,
|
|
4
5
|
diffAgainstBaseline,
|
|
5
6
|
parseBaseline,
|
|
7
|
+
parseReport,
|
|
6
8
|
scanPages,
|
|
7
9
|
startDevServer,
|
|
8
10
|
toAcrHtml,
|
|
@@ -17,6 +19,7 @@ const USAGE = `ngbr-a11y-report — component-attributed a11y scan of a running
|
|
|
17
19
|
Usage:
|
|
18
20
|
ngbr-a11y-report --base <url> --route <path> [--route <path> ...] [options]
|
|
19
21
|
ngbr-a11y-report --serve "<command>" --route <path> [...] [options]
|
|
22
|
+
ngbr-a11y-report --from <report.json> [--out <prefix>] [--format <list>] [--baseline <file>] [--fail-on <impact>]
|
|
20
23
|
|
|
21
24
|
Options:
|
|
22
25
|
--base <url> Origin of the running dev server (e.g. http://localhost:4200).
|
|
@@ -27,6 +30,10 @@ Options:
|
|
|
27
30
|
--serve-timeout <s>
|
|
28
31
|
Seconds to wait for --serve to answer (default 180)
|
|
29
32
|
--route <path> Route to scan; repeat for multiple routes
|
|
33
|
+
--from <file> Don't scan: read a previous run's JSON report (from --out)
|
|
34
|
+
and write it in the --format(s) asked for — e.g. add an
|
|
35
|
+
HTML report or ACR worksheet later. --baseline and
|
|
36
|
+
--fail-on work as usual; the scan options don't apply
|
|
30
37
|
--tags <list> Comma-separated axe tags to scope the ruleset (e.g. wcag22aa,best-practice)
|
|
31
38
|
--out <prefix> Write <prefix>.md / .json / .html (default: print Markdown to stdout)
|
|
32
39
|
--format <list> Comma-separated: md, json, html — or both (= md,json) or all
|
|
@@ -79,6 +86,7 @@ function parseArgs(argv) {
|
|
|
79
86
|
case '--serve': opts.serve = next(); break;
|
|
80
87
|
case '--serve-timeout': opts.serveTimeout = Number(next()); break;
|
|
81
88
|
case '--route': opts.routes.push(next()); break;
|
|
89
|
+
case '--from': opts.from = next(); break;
|
|
82
90
|
case '--tags': opts.tags = next().split(',').map((s) => s.trim()).filter(Boolean); break;
|
|
83
91
|
case '--out': opts.out = next(); break;
|
|
84
92
|
case '--format': opts.format = next(); break;
|
|
@@ -105,7 +113,25 @@ function parseArgs(argv) {
|
|
|
105
113
|
const opts = parseArgs(process.argv.slice(2));
|
|
106
114
|
if (opts.serve && !opts.base) opts.base = 'http://localhost:4200';
|
|
107
115
|
|
|
108
|
-
|
|
116
|
+
// Options that only mean something when scanning — refused with --from, rather
|
|
117
|
+
// than silently ignored.
|
|
118
|
+
const SCAN_ONLY = {
|
|
119
|
+
base: '--base', serve: '--serve', serveTimeout: '--serve-timeout', routes: '--route', tags: '--tags',
|
|
120
|
+
wait: '--wait', frameworkPrefixes: '--framework-prefixes / --no-skip-primitives', keyboard: '--keyboard',
|
|
121
|
+
focusTraps: '--focus-traps', colorScheme: '--color-scheme', darkClass: '--dark-class',
|
|
122
|
+
darkAttribute: '--dark-attribute', headed: '--headed',
|
|
123
|
+
};
|
|
124
|
+
if (opts.from && !opts.help) {
|
|
125
|
+
const clash = Object.keys(SCAN_ONLY).filter((k) => (k === 'routes' ? opts.routes.length > 0 : opts[k] !== undefined));
|
|
126
|
+
if (clash.length > 0) {
|
|
127
|
+
process.stderr.write(
|
|
128
|
+
`--from re-renders a saved report without scanning, so ${clash.map((k) => SCAN_ONLY[k]).join(', ')} can't be used with it.\n`,
|
|
129
|
+
);
|
|
130
|
+
process.exit(2);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (opts.help || (!opts.from && (!opts.base || opts.routes.length === 0))) {
|
|
109
135
|
process.stderr.write(USAGE);
|
|
110
136
|
process.exit(opts.help ? 0 : 1);
|
|
111
137
|
}
|
|
@@ -146,6 +172,29 @@ if (opts.darkAttribute) {
|
|
|
146
172
|
darkAttribute = { name: opts.darkAttribute.slice(0, eq), value: opts.darkAttribute.slice(eq + 1) };
|
|
147
173
|
}
|
|
148
174
|
|
|
175
|
+
let saved;
|
|
176
|
+
if (opts.from) {
|
|
177
|
+
try {
|
|
178
|
+
saved = parseReport(readFileSync(opts.from, 'utf8'));
|
|
179
|
+
} catch (err) {
|
|
180
|
+
process.stderr.write(`Can't use --from ${opts.from}: ${err.message}\n`);
|
|
181
|
+
process.exit(2);
|
|
182
|
+
}
|
|
183
|
+
if (formats.has('acr') || formats.has('acr-md')) {
|
|
184
|
+
// The worksheet lists which rules checked each criterion from the installed
|
|
185
|
+
// axe-core, so say when that isn't the version the scan ran.
|
|
186
|
+
if (!saved.checks) {
|
|
187
|
+
process.stderr.write(
|
|
188
|
+
`Note: ${opts.from} doesn't record what was checked (reports from before 0.14.0 don't), so the worksheet counts a rule as run only where it found something.\n`,
|
|
189
|
+
);
|
|
190
|
+
} else if (saved.checks.axeVersion !== axeVersion()) {
|
|
191
|
+
process.stderr.write(
|
|
192
|
+
`Note: the scan ran axe-core ${saved.checks.axeVersion}; the worksheet's rule lists come from the installed axe-core ${axeVersion()}.\n`,
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
149
198
|
// Read the baseline before the (slow) scan, so a bad path fails fast.
|
|
150
199
|
let baseline;
|
|
151
200
|
if (opts.baseline) {
|
|
@@ -182,31 +231,35 @@ if (opts.serve) {
|
|
|
182
231
|
);
|
|
183
232
|
}
|
|
184
233
|
|
|
185
|
-
let report;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
234
|
+
let report = saved;
|
|
235
|
+
if (!report) {
|
|
236
|
+
try {
|
|
237
|
+
report = await scanPages({
|
|
238
|
+
baseUrl: opts.base,
|
|
239
|
+
routes: opts.routes,
|
|
240
|
+
tags: opts.tags,
|
|
241
|
+
waitMs: opts.wait,
|
|
242
|
+
headed: opts.headed,
|
|
243
|
+
frameworkPrefixes: opts.frameworkPrefixes,
|
|
244
|
+
keyboard: opts.keyboard,
|
|
245
|
+
focusTraps: opts.focusTraps,
|
|
246
|
+
colorScheme: opts.colorScheme,
|
|
247
|
+
darkClass: opts.darkClass,
|
|
248
|
+
darkAttribute,
|
|
249
|
+
});
|
|
250
|
+
} finally {
|
|
251
|
+
if (server && !server.reused) {
|
|
252
|
+
await server.stop();
|
|
253
|
+
process.stderr.write('Stopped the dev server.\n');
|
|
254
|
+
}
|
|
204
255
|
}
|
|
205
256
|
}
|
|
206
257
|
|
|
207
258
|
const allFindings = report.pages.flatMap((p) => p.findings);
|
|
208
259
|
process.stderr.write(
|
|
209
|
-
|
|
260
|
+
saved
|
|
261
|
+
? `Read ${report.pages.length} route(s) · ${allFindings.length} node-instance(s) from ${opts.from} (scanned ${report.generatedAt}).\n`
|
|
262
|
+
: `Scanned ${report.pages.length} route(s) · ${allFindings.length} node-instance(s).\n`,
|
|
210
263
|
);
|
|
211
264
|
const diff = baseline ? diffAgainstBaseline(report, baseline) : undefined;
|
|
212
265
|
if (diff) {
|
package/dist/inpage.global.js
CHANGED
|
@@ -7129,7 +7129,7 @@
|
|
|
7129
7129
|
isContextSpec: function isContextSpec() {
|
|
7130
7130
|
return _isContextSpec;
|
|
7131
7131
|
},
|
|
7132
|
-
isHidden: function
|
|
7132
|
+
isHidden: function isHidden3() {
|
|
7133
7133
|
return is_hidden_default;
|
|
7134
7134
|
},
|
|
7135
7135
|
isHtmlElement: function isHtmlElement() {
|
|
@@ -19809,7 +19809,7 @@
|
|
|
19809
19809
|
function _isLabelledShadowDomSelector(selector) {
|
|
19810
19810
|
return _objectHasOwn(selector, "fromShadowDom");
|
|
19811
19811
|
}
|
|
19812
|
-
function
|
|
19812
|
+
function isHidden2(el, recursed) {
|
|
19813
19813
|
var node = get_node_from_tree_default(el);
|
|
19814
19814
|
if (el.nodeType === 9) {
|
|
19815
19815
|
return false;
|
|
@@ -19825,13 +19825,13 @@
|
|
|
19825
19825
|
return true;
|
|
19826
19826
|
}
|
|
19827
19827
|
var parent = el.assignedSlot ? el.assignedSlot : el.parentNode;
|
|
19828
|
-
var hidden =
|
|
19828
|
+
var hidden = isHidden2(parent, true);
|
|
19829
19829
|
if (node) {
|
|
19830
19830
|
node._isHidden = hidden;
|
|
19831
19831
|
}
|
|
19832
19832
|
return hidden;
|
|
19833
19833
|
}
|
|
19834
|
-
var is_hidden_default =
|
|
19834
|
+
var is_hidden_default = isHidden2;
|
|
19835
19835
|
function _isHtmlElement(node) {
|
|
19836
19836
|
var _node$props$nodeName, _node$props;
|
|
19837
19837
|
var nodeName2 = (_node$props$nodeName = (_node$props = node.props) === null || _node$props === void 0 ? void 0 : _node$props.nodeName) !== null && _node$props$nodeName !== void 0 ? _node$props$nodeName : node.nodeName.toLowerCase();
|
|
@@ -34696,8 +34696,14 @@
|
|
|
34696
34696
|
function isStructurallyHidden(element) {
|
|
34697
34697
|
if (element.closest("[inert]") || element.closest("[hidden]"))
|
|
34698
34698
|
return true;
|
|
34699
|
-
|
|
34700
|
-
|
|
34699
|
+
for (let details = element.closest("details:not([open])"); details; details = details.parentElement?.closest("details:not([open])") ?? null) {
|
|
34700
|
+
if (details === element)
|
|
34701
|
+
continue;
|
|
34702
|
+
const summary = [...details.children].find((child) => child.tagName.toLowerCase() === "summary");
|
|
34703
|
+
if (!summary?.contains(element))
|
|
34704
|
+
return true;
|
|
34705
|
+
}
|
|
34706
|
+
return false;
|
|
34701
34707
|
}
|
|
34702
34708
|
function defaultIsVisible(element) {
|
|
34703
34709
|
const view = element.ownerDocument?.defaultView;
|
|
@@ -34712,6 +34718,9 @@
|
|
|
34712
34718
|
}
|
|
34713
34719
|
return true;
|
|
34714
34720
|
}
|
|
34721
|
+
function isHidden(element, isVisible = defaultIsVisible) {
|
|
34722
|
+
return isStructurallyHidden(element) || !isVisible(element);
|
|
34723
|
+
}
|
|
34715
34724
|
function isTabbable(element, isVisible = defaultIsVisible) {
|
|
34716
34725
|
if (resolvedTabIndex(element) < 0)
|
|
34717
34726
|
return false;
|
|
@@ -34867,6 +34876,8 @@
|
|
|
34867
34876
|
continue;
|
|
34868
34877
|
if (!interactiveByRole && hasFocusableDescendant(element))
|
|
34869
34878
|
continue;
|
|
34879
|
+
if (isHidden(element, isVisible))
|
|
34880
|
+
continue;
|
|
34870
34881
|
const focusable = isTabbable(element, isVisible);
|
|
34871
34882
|
if (!focusable) {
|
|
34872
34883
|
const reason = interactiveByRole ? `has role="${role}"` : "has a click handler";
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* confirmed failures.
|
|
13
13
|
*/
|
|
14
14
|
import { appComponentFromPath, DEFAULT_FRAMEWORK_PREFIXES, resolveComponentPath, resolveDirectiveNames, resolveListenerEvents, } from '../attribution.js';
|
|
15
|
-
import { hasFocusableDescendant, isNativelyFocusable, isTabbable, tabSequence, visualOrderJumps, } from './tab-sequence.js';
|
|
15
|
+
import { hasFocusableDescendant, isHidden, isNativelyFocusable, isTabbable, tabSequence, visualOrderJumps, } from './tab-sequence.js';
|
|
16
16
|
import { findUncontainedModals } from './focus-trap.js';
|
|
17
17
|
import { blockingModalDialog } from '../top-layer.js';
|
|
18
18
|
/** WAI-ARIA roles that make a non-native element behave as an interactive control. */
|
|
@@ -103,6 +103,10 @@ export function scanKeyboard(root = document, options = {}) {
|
|
|
103
103
|
// the keyboard reaches.
|
|
104
104
|
if (!interactiveByRole && hasFocusableDescendant(element))
|
|
105
105
|
continue;
|
|
106
|
+
// Hidden (a closed <details>, [hidden], display:none): not reachable because
|
|
107
|
+
// it isn't shown. Check it when it is.
|
|
108
|
+
if (isHidden(element, isVisible))
|
|
109
|
+
continue;
|
|
106
110
|
const focusable = isTabbable(element, isVisible);
|
|
107
111
|
if (!focusable) {
|
|
108
112
|
const reason = interactiveByRole ? `has role="${role}"` : 'has a click handler';
|
|
@@ -57,6 +57,12 @@ export declare function isNativelyFocusable(element: Element): boolean;
|
|
|
57
57
|
* `tabindex="foo"`) is ignored by browsers, so it falls back to the native value.
|
|
58
58
|
*/
|
|
59
59
|
export declare function resolvedTabIndex(element: Element): number;
|
|
60
|
+
/**
|
|
61
|
+
* True when `element` isn't shown at all: structurally hidden (see
|
|
62
|
+
* {@link isStructurallyHidden}) or hidden by layout. A hidden control is out of
|
|
63
|
+
* the tab order because nobody can see it, not because it's unreachable.
|
|
64
|
+
*/
|
|
65
|
+
export declare function isHidden(element: Element, isVisible?: (el: Element) => boolean): boolean;
|
|
60
66
|
/**
|
|
61
67
|
* True when `element` participates in sequential keyboard navigation: it's
|
|
62
68
|
* focusable, has a resolved `tabindex >= 0`, and is neither disabled nor hidden.
|
|
@@ -129,12 +129,23 @@ function isDisabled(element) {
|
|
|
129
129
|
* layout: inside an `[inert]` or `[hidden]` subtree, or non-summary content of a
|
|
130
130
|
* closed `<details>`. Kept separate from the layout check so the injectable
|
|
131
131
|
* visibility predicate only ever overrides computed-style visibility.
|
|
132
|
+
*
|
|
133
|
+
* Every closed `<details>` up the tree counts, not just the nearest: a nested
|
|
134
|
+
* `<details>` (a sidebar group inside a collapsed section) has its own summary,
|
|
135
|
+
* but that summary is hidden too while an outer one is closed.
|
|
132
136
|
*/
|
|
133
137
|
function isStructurallyHidden(element) {
|
|
134
138
|
if (element.closest('[inert]') || element.closest('[hidden]'))
|
|
135
139
|
return true;
|
|
136
|
-
|
|
137
|
-
|
|
140
|
+
for (let details = element.closest('details:not([open])'); details; details = details.parentElement?.closest('details:not([open])') ?? null) {
|
|
141
|
+
if (details === element)
|
|
142
|
+
continue;
|
|
143
|
+
// Only this <details>' own summary (its first <summary> child) stays shown.
|
|
144
|
+
const summary = [...details.children].find((child) => child.tagName.toLowerCase() === 'summary');
|
|
145
|
+
if (!summary?.contains(element))
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
return false;
|
|
138
149
|
}
|
|
139
150
|
/** Layout-aware default visibility: computed `display`/`visibility` up the tree. */
|
|
140
151
|
function defaultIsVisible(element) {
|
|
@@ -150,6 +161,14 @@ function defaultIsVisible(element) {
|
|
|
150
161
|
}
|
|
151
162
|
return true;
|
|
152
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* True when `element` isn't shown at all: structurally hidden (see
|
|
166
|
+
* {@link isStructurallyHidden}) or hidden by layout. A hidden control is out of
|
|
167
|
+
* the tab order because nobody can see it, not because it's unreachable.
|
|
168
|
+
*/
|
|
169
|
+
export function isHidden(element, isVisible = defaultIsVisible) {
|
|
170
|
+
return isStructurallyHidden(element) || !isVisible(element);
|
|
171
|
+
}
|
|
153
172
|
/**
|
|
154
173
|
* True when `element` participates in sequential keyboard navigation: it's
|
|
155
174
|
* focusable, has a resolved `tabindex >= 0`, and is neither disabled nor hidden.
|
package/dist/report/format.d.ts
CHANGED
|
@@ -76,6 +76,13 @@ export declare function impactRank(impact: Impact): number;
|
|
|
76
76
|
* output stays a valid baseline for the next run.
|
|
77
77
|
*/
|
|
78
78
|
export declare function toJson(report: ScanReport, diff?: BaselineDiff): string;
|
|
79
|
+
/**
|
|
80
|
+
* Read a report back from its JSON text (a `toJson` report), so it can be
|
|
81
|
+
* rendered in another format without scanning again. The derived fields
|
|
82
|
+
* (`summary`, per-page counts, `scope`, `baseline`) are dropped — every format
|
|
83
|
+
* recomputes them. Throws a readable error for anything that isn't a report.
|
|
84
|
+
*/
|
|
85
|
+
export declare function parseReport(json: string): ScanReport;
|
|
79
86
|
/** UI primitives and directives a finding came through, for a "via …" note. */
|
|
80
87
|
export declare function viaNames(finding: A11yFinding): string[];
|
|
81
88
|
/** Findings sorted most severe first (stable within an impact level). */
|
package/dist/report/format.js
CHANGED
|
@@ -86,6 +86,40 @@ export function toJson(report, diff) {
|
|
|
86
86
|
})),
|
|
87
87
|
}, null, 2);
|
|
88
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Read a report back from its JSON text (a `toJson` report), so it can be
|
|
91
|
+
* rendered in another format without scanning again. The derived fields
|
|
92
|
+
* (`summary`, per-page counts, `scope`, `baseline`) are dropped — every format
|
|
93
|
+
* recomputes them. Throws a readable error for anything that isn't a report.
|
|
94
|
+
*/
|
|
95
|
+
export function parseReport(json) {
|
|
96
|
+
let data;
|
|
97
|
+
try {
|
|
98
|
+
data = JSON.parse(json);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
throw new Error('not valid JSON — pass a report written by `--out` (the .json file).');
|
|
102
|
+
}
|
|
103
|
+
const { generatedAt, checks, pages } = (data ?? {});
|
|
104
|
+
const isPage = (p) => typeof p?.label === 'string' &&
|
|
105
|
+
typeof p.url === 'string' &&
|
|
106
|
+
Array.isArray(p.findings);
|
|
107
|
+
if (typeof generatedAt !== 'string' || !Array.isArray(pages) || !pages.every(isPage)) {
|
|
108
|
+
throw new Error('not a report-mode JSON report — pass a report written by `--out` (the .json file).');
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
generatedAt,
|
|
112
|
+
...(checks && { checks }),
|
|
113
|
+
pages: pages.map((p) => ({
|
|
114
|
+
label: p.label,
|
|
115
|
+
url: p.url,
|
|
116
|
+
findings: p.findings,
|
|
117
|
+
...(p.error !== undefined && { error: p.error }),
|
|
118
|
+
...(p.colorScheme && { colorScheme: p.colorScheme }),
|
|
119
|
+
...(p.darkOnly && { darkOnly: true }),
|
|
120
|
+
})),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
89
123
|
/** UI primitives and directives a finding came through, for a "via …" note. */
|
|
90
124
|
export function viaNames(finding) {
|
|
91
125
|
// e.g. an `<button nbButton>` shows as "via NbButtonComponent" under its app owner.
|
|
@@ -88,3 +88,5 @@ export interface ScanPagesOptions {
|
|
|
88
88
|
* to the component that rendered it — with no change to the target app.
|
|
89
89
|
*/
|
|
90
90
|
export declare function scanPages(options: ScanPagesOptions): Promise<ScanReport>;
|
|
91
|
+
/** Version of the installed axe-core — the one a scan run now would use. */
|
|
92
|
+
export declare function axeVersion(): string;
|
package/dist/report/headless.js
CHANGED
|
@@ -179,6 +179,7 @@ export async function scanPages(options) {
|
|
|
179
179
|
};
|
|
180
180
|
return { generatedAt: new Date().toISOString(), checks, pages };
|
|
181
181
|
}
|
|
182
|
-
|
|
182
|
+
/** Version of the installed axe-core — the one a scan run now would use. */
|
|
183
|
+
export function axeVersion() {
|
|
183
184
|
return createRequire(import.meta.url)('axe-core/package.json').version;
|
|
184
185
|
}
|
package/dist/report/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { scanPages, type ColorScheme, type ScanPagesOptions, type ThemeContext, } from './headless.js';
|
|
2
|
-
export { groupByComponent, distinctRuleCount, toJson, toMarkdown, DARK_ONLY_NOTE, type PageReport, type ScanChecks, type ScanReport, } from './format.js';
|
|
1
|
+
export { axeVersion, scanPages, type ColorScheme, type ScanPagesOptions, type ThemeContext, } from './headless.js';
|
|
2
|
+
export { groupByComponent, distinctRuleCount, parseReport, 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';
|
package/dist/report/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { scanPages, } from './headless.js';
|
|
2
|
-
export { groupByComponent, distinctRuleCount, toJson, toMarkdown, DARK_ONLY_NOTE, } from './format.js';
|
|
1
|
+
export { axeVersion, scanPages, } from './headless.js';
|
|
2
|
+
export { groupByComponent, distinctRuleCount, parseReport, 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
5
|
export { isServing, startDevServer } from './serve.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngbracket/a11y-devtools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.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",
|
|
@@ -48,8 +48,9 @@
|
|
|
48
48
|
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
|
-
"build": "tsc -p tsconfig.json && node scripts/build-inpage.mjs",
|
|
51
|
+
"build": "tsc -p tsconfig.json && tsc -p tsconfig.report.json && node scripts/build-inpage.mjs",
|
|
52
52
|
"test": "vitest run",
|
|
53
|
+
"typecheck": "tsc -p tsconfig.spec.json --noEmit",
|
|
53
54
|
"test:watch": "vitest",
|
|
54
55
|
"demo:console": "vitest run --config vitest.demo.config.ts --disableConsoleIntercept",
|
|
55
56
|
"prepublishOnly": "npm run build"
|