@ngbracket/a11y-devtools 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -7
- package/dist/attribution.d.ts +2 -1
- package/dist/provider.d.ts +8 -0
- package/dist/provider.js +5 -2
- package/dist/runner.d.ts +9 -0
- package/dist/runner.js +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -4,13 +4,13 @@ Dev-only, in-app accessibility auditing for Angular that maps each axe violation
|
|
|
4
4
|
back to **the component that rendered it** — so you get
|
|
5
5
|
`♿ UserCardComponent — 2 issue(s)`, not a wall of CSS selectors.
|
|
6
6
|
|
|
7
|
-
The
|
|
8
|
-
[`axe-mode`](https://github.com/raunofreiberg/axe-mode),
|
|
9
|
-
[TanStack
|
|
10
|
-
— report the DOM node (selector,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
internals.
|
|
7
|
+
The axe-based devtools in this space — [`@axe-core/react`](https://www.npmjs.com/package/@axe-core/react),
|
|
8
|
+
[`axe-mode`](https://github.com/raunofreiberg/axe-mode), and
|
|
9
|
+
[TanStack's a11y plugin](https://tanstack.com/devtools/latest/docs/plugins/a11y)
|
|
10
|
+
(now cross-framework, with an Angular adapter too) — report the DOM node (selector,
|
|
11
|
+
HTML, rule id) and highlight it, but we haven't seen one tie a violation back to the
|
|
12
|
+
component that rendered it, by name. This does, through Angular's **documented** dev
|
|
13
|
+
debug API (`window.ng`) rather than private framework internals.
|
|
14
14
|
|
|
15
15
|
Part of the `@ngbracket` Angular tooling family.
|
|
16
16
|
|
|
@@ -61,6 +61,7 @@ provideA11yDevtools({
|
|
|
61
61
|
log: true, // grouped console output; default true
|
|
62
62
|
overlay: true, // in-app visual highlights over flagged nodes; default false
|
|
63
63
|
debounceMs: 500, // quiet window after stabilization before scanning
|
|
64
|
+
tags: ['wcag22aa'], // scope the ruleset; default = axe-core's full ruleset
|
|
64
65
|
});
|
|
65
66
|
```
|
|
66
67
|
|
|
@@ -87,6 +88,26 @@ const findings = await runA11yScan(); // scan + grouped log
|
|
|
87
88
|
const raw = await scan(document.body); // findings only
|
|
88
89
|
```
|
|
89
90
|
|
|
91
|
+
`scan()` and `runA11yScan()` also take full axe-core run options as a second
|
|
92
|
+
argument (`scan(root, { runOnly: … })`) for finer control than the provider's
|
|
93
|
+
`tags`.
|
|
94
|
+
|
|
95
|
+
## What it checks (and what it can't)
|
|
96
|
+
|
|
97
|
+
Under the hood this is [axe-core](https://github.com/dequelabs/axe-core) — the
|
|
98
|
+
scan runs axe's rules and enriches each violation with the owning component. By
|
|
99
|
+
default it runs axe-core's full ruleset: the **machine-testable** rules across
|
|
100
|
+
**WCAG 2.0, 2.1 and 2.2, Levels A & AA**, plus axe's *best-practice* rules. Scope
|
|
101
|
+
it to a single conformance target with `tags` (e.g. `['wcag22aa']`) or
|
|
102
|
+
`['wcag21aa', 'best-practice']`.
|
|
103
|
+
|
|
104
|
+
Automated checks only cover the part of WCAG a machine can test — on the order of
|
|
105
|
+
a third of the success criteria. Many WCAG 2.2 additions have **no automated rule
|
|
106
|
+
at all** (target size 2.5.8, dragging 2.5.7, consistent help, redundant entry,
|
|
107
|
+
accessible authentication), so a clean run is necessary, not sufficient — the rest
|
|
108
|
+
needs keyboard, screen-reader and human testing. (WCAG 3.0 is still an early W3C
|
|
109
|
+
draft with a different, non-final model; there's nothing to test against yet.)
|
|
110
|
+
|
|
90
111
|
## Production weight
|
|
91
112
|
|
|
92
113
|
In production `provideA11yDevtools()` is a **no-op** and axe-core is never loaded.
|
package/dist/attribution.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Attribution core: given a DOM node that axe flagged, return the name of the
|
|
3
|
-
* component responsible for it — the differentiator
|
|
3
|
+
* component responsible for it — the differentiator we haven't seen other axe
|
|
4
|
+
* overlay devtools do (they report the DOM node, not the owning component by name).
|
|
4
5
|
*
|
|
5
6
|
* Angular's debug helpers are NOT public named exports of `@angular/core`; they
|
|
6
7
|
* are methods on the `window.ng` global published in dev mode
|
package/dist/provider.d.ts
CHANGED
|
@@ -11,6 +11,14 @@ export interface A11yDevtoolsOptions {
|
|
|
11
11
|
overlay?: boolean;
|
|
12
12
|
/** Quiet window after stabilization before scanning. Default 500ms. */
|
|
13
13
|
debounceMs?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Restrict the scan to specific axe tags, e.g. `['wcag22aa']` or
|
|
16
|
+
* `['wcag21aa', 'best-practice']`. Omit to run axe-core's default ruleset —
|
|
17
|
+
* the machine-testable rules across WCAG 2.0/2.1/2.2 (Levels A & AA) plus axe's
|
|
18
|
+
* best-practice rules. (For finer control, call `runA11yScan`/`scan` with full
|
|
19
|
+
* axe run options.)
|
|
20
|
+
*/
|
|
21
|
+
tags?: string[];
|
|
14
22
|
}
|
|
15
23
|
/**
|
|
16
24
|
* Dev-only in-app accessibility auditing. Rescans whenever the application
|
package/dist/provider.js
CHANGED
|
@@ -15,7 +15,10 @@ export function provideA11yDevtools(options = {}) {
|
|
|
15
15
|
if (!isDevMode()) {
|
|
16
16
|
return makeEnvironmentProviders([]);
|
|
17
17
|
}
|
|
18
|
-
const { root, log = true, logger, overlay = false, debounceMs = 500 } = options;
|
|
18
|
+
const { root, log = true, logger, overlay = false, debounceMs = 500, tags } = options;
|
|
19
|
+
const axe = tags
|
|
20
|
+
? { runOnly: { type: 'tag', values: tags } }
|
|
21
|
+
: undefined;
|
|
19
22
|
return makeEnvironmentProviders([
|
|
20
23
|
provideEnvironmentInitializer(() => {
|
|
21
24
|
const appRef = inject(ApplicationRef);
|
|
@@ -28,7 +31,7 @@ export function provideA11yDevtools(options = {}) {
|
|
|
28
31
|
if (scanning)
|
|
29
32
|
return; // don't stack rescans while one is in flight
|
|
30
33
|
scanning = true;
|
|
31
|
-
runA11yScan(root?.(), { log, logger })
|
|
34
|
+
runA11yScan(root?.(), { log, logger, axe })
|
|
32
35
|
.then((findings) => overlayView?.render(findings))
|
|
33
36
|
.catch(() => undefined)
|
|
34
37
|
.finally(() => {
|
package/dist/runner.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RunOptions as AxeRunOptions } from 'axe-core';
|
|
1
2
|
import { type A11yFinding } from './scan.js';
|
|
2
3
|
import { type Logger } from './report.js';
|
|
3
4
|
export interface RunOptions {
|
|
@@ -5,6 +6,14 @@ export interface RunOptions {
|
|
|
5
6
|
log?: boolean;
|
|
6
7
|
/** Sink for reporting; defaults to `console`. */
|
|
7
8
|
logger?: Logger;
|
|
9
|
+
/**
|
|
10
|
+
* axe-core run options — use this to scope the ruleset, e.g.
|
|
11
|
+
* `{ runOnly: { type: 'tag', values: ['wcag22aa'] } }`. Omit to run axe-core's
|
|
12
|
+
* default ruleset: the machine-testable rules across WCAG 2.0/2.1/2.2 (Levels
|
|
13
|
+
* A & AA) plus axe's best-practice rules. (The provider exposes the common case
|
|
14
|
+
* as a friendlier `tags: string[]`.)
|
|
15
|
+
*/
|
|
16
|
+
axe?: AxeRunOptions;
|
|
8
17
|
}
|
|
9
18
|
/** Scan `root`, optionally report, and return the findings. */
|
|
10
19
|
export declare function runA11yScan(root?: Element | Document, options?: RunOptions): Promise<A11yFinding[]>;
|
package/dist/runner.js
CHANGED
|
@@ -2,7 +2,7 @@ import { scan } from './scan.js';
|
|
|
2
2
|
import { logFindings } from './report.js';
|
|
3
3
|
/** Scan `root`, optionally report, and return the findings. */
|
|
4
4
|
export async function runA11yScan(root, options = {}) {
|
|
5
|
-
const findings = await scan(root ?? document);
|
|
5
|
+
const findings = await scan(root ?? document, options.axe);
|
|
6
6
|
if (options.log !== false) {
|
|
7
7
|
logFindings(findings, options.logger);
|
|
8
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngbracket/a11y-devtools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"build": "tsc -p tsconfig.json",
|
|
43
43
|
"test": "vitest run",
|
|
44
44
|
"test:watch": "vitest",
|
|
45
|
+
"demo:console": "vitest run --config vitest.demo.config.ts --disableConsoleIntercept",
|
|
45
46
|
"prepublishOnly": "npm run build"
|
|
46
47
|
},
|
|
47
48
|
"dependencies": {
|