@ngbracket/a11y-devtools 0.1.0 → 0.2.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/LICENSE +21 -0
- package/README.md +2 -3
- package/dist/attribution.d.ts +7 -0
- package/dist/attribution.js +34 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/overlay.d.ts +1 -1
- package/dist/provider.d.ts +1 -1
- package/dist/provider.js +2 -2
- package/dist/report.d.ts +1 -1
- package/dist/report.js +3 -1
- package/dist/runner.d.ts +2 -2
- package/dist/runner.js +2 -2
- package/dist/scan.d.ts +2 -0
- package/dist/scan.js +3 -2
- package/package.json +4 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Duncan Faulkner and Lara Sanz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -6,8 +6,7 @@ back to **the component that rendered it** — the attribution React overlay too
|
|
|
6
6
|
|
|
7
7
|
Report `♿ UserCardComponent — 2 issue(s)` instead of a wall of CSS selectors.
|
|
8
8
|
|
|
9
|
-
Part of the `@ngbracket` Angular tooling family.
|
|
10
|
-
[`docs/findings.md`](docs/findings.md) for the research and scope.
|
|
9
|
+
Part of the `@ngbracket` Angular tooling family.
|
|
11
10
|
|
|
12
11
|
## Status
|
|
13
12
|
|
|
@@ -89,7 +88,7 @@ npm run build # tsc -> dist/ (ESM + .d.ts)
|
|
|
89
88
|
## Roadmap
|
|
90
89
|
|
|
91
90
|
- **`host` / `hostDirectives` a11y** via `getDirectives(el)` — the runtime cases
|
|
92
|
-
|
|
91
|
+
a static ESLint pass can't see.
|
|
93
92
|
- Per-component filtering and a violation count badge.
|
|
94
93
|
|
|
95
94
|
Done: attribution · axe scan · grouped console reporter · dev-only provider ·
|
package/dist/attribution.d.ts
CHANGED
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
export interface NgDebugGlobal {
|
|
13
13
|
getComponent(element: Element): unknown;
|
|
14
14
|
getOwningComponent(element: Element | object): unknown;
|
|
15
|
+
getDirectives(element: Element | object): unknown[];
|
|
15
16
|
}
|
|
16
17
|
export declare function ngDebug(): NgDebugGlobal | undefined;
|
|
17
18
|
export declare function resolveOwningComponentName(node: Element): string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Names of the directives applied directly to `node`, including those attached
|
|
21
|
+
* via `hostDirectives` — the runtime-only a11y cases the static lint plugin
|
|
22
|
+
* can't see. Empty when the debug global is absent or the node has none.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveDirectiveNames(node: Element): string[];
|
package/dist/attribution.js
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
export function ngDebug() {
|
|
2
2
|
return globalThis.ng;
|
|
3
3
|
}
|
|
4
|
+
/**
|
|
5
|
+
* Angular's dev output can emit class names with a leading underscore
|
|
6
|
+
* (e.g. `_Login` for `Login`); strip it so attribution shows the authored name.
|
|
7
|
+
*/
|
|
8
|
+
function cleanName(name) {
|
|
9
|
+
if (!name)
|
|
10
|
+
return null;
|
|
11
|
+
return name.replace(/^_+/, '') || null;
|
|
12
|
+
}
|
|
4
13
|
function nameOf(instance) {
|
|
5
14
|
if (!instance || typeof instance !== 'object')
|
|
6
15
|
return null;
|
|
7
|
-
return instance.constructor.name ?? null;
|
|
16
|
+
return cleanName(instance.constructor.name ?? null);
|
|
8
17
|
}
|
|
9
18
|
export function resolveOwningComponentName(node) {
|
|
10
19
|
const ng = ngDebug();
|
|
@@ -13,3 +22,27 @@ export function resolveOwningComponentName(node) {
|
|
|
13
22
|
const component = ng.getComponent(node) ?? ng.getOwningComponent(node);
|
|
14
23
|
return nameOf(component);
|
|
15
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Names of the directives applied directly to `node`, including those attached
|
|
27
|
+
* via `hostDirectives` — the runtime-only a11y cases the static lint plugin
|
|
28
|
+
* can't see. Empty when the debug global is absent or the node has none.
|
|
29
|
+
*/
|
|
30
|
+
export function resolveDirectiveNames(node) {
|
|
31
|
+
const ng = ngDebug();
|
|
32
|
+
if (!ng?.getDirectives)
|
|
33
|
+
return [];
|
|
34
|
+
let directives;
|
|
35
|
+
try {
|
|
36
|
+
directives = ng.getDirectives(node) ?? [];
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return []; // node isn't part of a live view
|
|
40
|
+
}
|
|
41
|
+
const names = [];
|
|
42
|
+
for (const directive of directives) {
|
|
43
|
+
const name = nameOf(directive);
|
|
44
|
+
if (name)
|
|
45
|
+
names.push(name);
|
|
46
|
+
}
|
|
47
|
+
return names;
|
|
48
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { provideA11yDevtools, type A11yDevtoolsOptions } from './provider';
|
|
2
|
-
export { runA11yScan, type RunOptions } from './runner';
|
|
3
|
-
export { scan, type A11yFinding, type Impact } from './scan';
|
|
4
|
-
export { logFindings, type Logger } from './report';
|
|
5
|
-
export { resolveOwningComponentName, ngDebug, type NgDebugGlobal } from './attribution';
|
|
6
|
-
export { createOverlay, OVERLAY_ATTR, OVERLAY_EXCLUDE_SELECTOR, type A11yOverlay, type OverlayOptions, } from './overlay';
|
|
1
|
+
export { provideA11yDevtools, type A11yDevtoolsOptions } from './provider.js';
|
|
2
|
+
export { runA11yScan, type RunOptions } from './runner.js';
|
|
3
|
+
export { scan, type A11yFinding, type Impact } from './scan.js';
|
|
4
|
+
export { logFindings, type Logger } from './report.js';
|
|
5
|
+
export { resolveOwningComponentName, ngDebug, type NgDebugGlobal } from './attribution.js';
|
|
6
|
+
export { createOverlay, OVERLAY_ATTR, OVERLAY_EXCLUDE_SELECTOR, type A11yOverlay, type OverlayOptions, } from './overlay.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { provideA11yDevtools } from './provider';
|
|
2
|
-
export { runA11yScan } from './runner';
|
|
3
|
-
export { scan } from './scan';
|
|
4
|
-
export { logFindings } from './report';
|
|
5
|
-
export { resolveOwningComponentName, ngDebug } from './attribution';
|
|
6
|
-
export { createOverlay, OVERLAY_ATTR, OVERLAY_EXCLUDE_SELECTOR, } from './overlay';
|
|
1
|
+
export { provideA11yDevtools } from './provider.js';
|
|
2
|
+
export { runA11yScan } from './runner.js';
|
|
3
|
+
export { scan } from './scan.js';
|
|
4
|
+
export { logFindings } from './report.js';
|
|
5
|
+
export { resolveOwningComponentName, ngDebug } from './attribution.js';
|
|
6
|
+
export { createOverlay, OVERLAY_ATTR, OVERLAY_EXCLUDE_SELECTOR, } from './overlay.js';
|
package/dist/overlay.d.ts
CHANGED
package/dist/provider.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type EnvironmentProviders } from '@angular/core';
|
|
2
|
-
import type { Logger } from './report';
|
|
2
|
+
import type { Logger } from './report.js';
|
|
3
3
|
export interface A11yDevtoolsOptions {
|
|
4
4
|
/** Element/Document to scan. Defaults to `document`. */
|
|
5
5
|
root?: () => Element | Document;
|
package/dist/provider.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ApplicationRef, DestroyRef, inject, isDevMode, makeEnvironmentProviders, provideEnvironmentInitializer, } from '@angular/core';
|
|
2
2
|
import { debounceTime, filter } from 'rxjs';
|
|
3
|
-
import { runA11yScan } from './runner';
|
|
4
|
-
import { createOverlay } from './overlay';
|
|
3
|
+
import { runA11yScan } from './runner.js';
|
|
4
|
+
import { createOverlay } from './overlay.js';
|
|
5
5
|
/**
|
|
6
6
|
* Dev-only in-app accessibility auditing. Rescans whenever the application
|
|
7
7
|
* settles (zoneless-aware, via `ApplicationRef.isStable`) and reports each
|
package/dist/report.d.ts
CHANGED
package/dist/report.js
CHANGED
|
@@ -17,10 +17,12 @@ export function logFindings(findings, logger = console) {
|
|
|
17
17
|
else
|
|
18
18
|
byComponent.set(key, [finding]);
|
|
19
19
|
}
|
|
20
|
+
logger.info(`♿ a11y-devtools: ${findings.length} issue(s) across ${byComponent.size} component(s)`);
|
|
20
21
|
for (const [component, items] of byComponent) {
|
|
21
22
|
logger.groupCollapsed(`♿ ${component} — ${items.length} issue(s)`);
|
|
22
23
|
for (const finding of items) {
|
|
23
|
-
|
|
24
|
+
const via = finding.directives.length ? ` [via ${finding.directives.join(', ')}]` : '';
|
|
25
|
+
logger.warn(`${finding.impact ?? 'n/a'} · ${finding.id}: ${finding.help}${via}`, `\n ${finding.target}\n ${finding.helpUrl}`);
|
|
24
26
|
}
|
|
25
27
|
logger.groupEnd();
|
|
26
28
|
}
|
package/dist/runner.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type A11yFinding } from './scan';
|
|
2
|
-
import { type Logger } from './report';
|
|
1
|
+
import { type A11yFinding } from './scan.js';
|
|
2
|
+
import { type Logger } from './report.js';
|
|
3
3
|
export interface RunOptions {
|
|
4
4
|
/** Log grouped findings to the console. Default true. */
|
|
5
5
|
log?: boolean;
|
package/dist/runner.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { scan } from './scan';
|
|
2
|
-
import { logFindings } from './report';
|
|
1
|
+
import { scan } from './scan.js';
|
|
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
5
|
const findings = await scan(root ?? document);
|
package/dist/scan.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export interface A11yFinding {
|
|
|
9
9
|
helpUrl: string;
|
|
10
10
|
/** Owning component name, or null when attribution isn't available (prod). */
|
|
11
11
|
component: string | null;
|
|
12
|
+
/** Directives on the flagged node (incl. hostDirectives); [] when none/unavailable. */
|
|
13
|
+
directives: string[];
|
|
12
14
|
/** CSS selector axe reported for the node. */
|
|
13
15
|
target: string;
|
|
14
16
|
html: string;
|
package/dist/scan.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { resolveOwningComponentName } from './attribution';
|
|
2
|
-
import { OVERLAY_EXCLUDE_SELECTOR } from './overlay';
|
|
1
|
+
import { resolveDirectiveNames, resolveOwningComponentName } from './attribution.js';
|
|
2
|
+
import { OVERLAY_EXCLUDE_SELECTOR } from './overlay.js';
|
|
3
3
|
// axe-core is a singleton and throws if a run starts while another is in flight.
|
|
4
4
|
// Chain runs so overlapping callers (e.g. rapid rescans) serialize safely.
|
|
5
5
|
let runChain = Promise.resolve();
|
|
@@ -37,6 +37,7 @@ async function runAxeOnce(root, options) {
|
|
|
37
37
|
help: violation.help,
|
|
38
38
|
helpUrl: violation.helpUrl,
|
|
39
39
|
component: element ? resolveOwningComponentName(element) : null,
|
|
40
|
+
directives: element ? resolveDirectiveNames(element) : [],
|
|
40
41
|
target,
|
|
41
42
|
html: node.html,
|
|
42
43
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngbracket/a11y-devtools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.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",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"homepage": "https://ngbracket.com",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "https://github.com/ngbracket/a11y-devtools"
|
|
13
|
+
"url": "git+https://github.com/ngbracket/a11y-devtools.git"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
16
|
"angular",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
".": {
|
|
30
30
|
"types": "./dist/index.d.ts",
|
|
31
31
|
"import": "./dist/index.js"
|
|
32
|
-
}
|
|
32
|
+
},
|
|
33
|
+
"./package.json": "./package.json"
|
|
33
34
|
},
|
|
34
35
|
"files": [
|
|
35
36
|
"dist"
|