@ngbracket/a11y-devtools 0.4.0 → 0.5.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,22 @@
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.5.0
7
+
8
+ ### Added
9
+
10
+ - **Configurable framework prefixes.** The component-name prefixes attribution
11
+ walks past (third-party UI primitives) are now configurable instead of a
12
+ hardcoded `Nb`/`Mat`/`Cdk`/`Mdc` list:
13
+ - `provideA11yDevtools({ frameworkPrefixes })`, `runA11yScan(root, { frameworkPrefixes })`,
14
+ `scan(root, axe, { frameworkPrefixes })`, and `scanPages({ frameworkPrefixes })`.
15
+ - CLI: `--framework-prefixes Nb,Mat,Nz,Clr,Ion` and `--no-skip-primitives`.
16
+ - Pass `[]` (or `--no-skip-primitives`) to attribute to the **immediate** owner —
17
+ e.g. when scanning a component library's *own* code, so it blames the library
18
+ component rather than a demo wrapper.
19
+ - Exported `DEFAULT_FRAMEWORK_PREFIXES` (spread it to extend: `[...DEFAULT_FRAMEWORK_PREFIXES, 'Nz']`)
20
+ and the `ScanOptions` type.
21
+
6
22
  ## 0.4.0
7
23
 
8
24
  ### Added
package/README.md CHANGED
@@ -62,9 +62,18 @@ provideA11yDevtools({
62
62
  overlay: true, // in-app visual highlights over flagged nodes; default false
63
63
  debounceMs: 500, // quiet window after stabilization before scanning
64
64
  tags: ['wcag22aa'], // scope the ruleset; default = axe-core's full ruleset
65
+ frameworkPrefixes: ['Nb', 'Mat', 'Cdk', 'Mdc'], // UI primitives to attribute past (default)
65
66
  });
66
67
  ```
67
68
 
69
+ **Framework prefixes.** Attribution walks *past* third-party UI primitives to the app
70
+ component that placed them — a `<button nbButton>` with no name is blamed on your
71
+ `HeaderComponent`, not `NbButtonComponent`. The default list is `Nb`/`Mat`/`Cdk`/`Mdc`;
72
+ override `frameworkPrefixes` to add others (e.g. `['Nb','Mat','Nz','Clr','Ion']` — spread
73
+ `DEFAULT_FRAMEWORK_PREFIXES` to extend), or pass `[]` to attribute to the **immediate**
74
+ owner (useful when auditing a component library's *own* code). The same option is available
75
+ on `scan`, `runA11yScan`, `scanPages`, and the CLI (`--framework-prefixes` / `--no-skip-primitives`).
76
+
68
77
  Findings are grouped by owning component, led by a summary line, and each node's
69
78
  directives are shown inline:
70
79
 
@@ -16,6 +16,13 @@ Options:
16
16
  --wait <ms> Settle time after load before scanning (default 1500)
17
17
  --fail-on <impact> Exit non-zero if any finding is at/above impact
18
18
  (minor | moderate | serious | critical) — for CI gating
19
+ --framework-prefixes <list>
20
+ Comma-separated component-name prefixes to treat as
21
+ third-party UI primitives to walk past during attribution
22
+ (default: Nb,Mat,Cdk,Mdc). e.g. Nb,Mat,Nz,Clr,Ion
23
+ --no-skip-primitives
24
+ Attribute to the immediate owner (skip nothing) — use when
25
+ scanning a component library's own code
19
26
  --headed Launch a visible browser (debugging)
20
27
  -h, --help Show this help
21
28
  `;
@@ -35,6 +42,10 @@ function parseArgs(argv) {
35
42
  case '--format': opts.format = next(); break;
36
43
  case '--wait': opts.wait = Number(next()); break;
37
44
  case '--fail-on': opts.failOn = next(); break;
45
+ case '--framework-prefixes':
46
+ opts.frameworkPrefixes = next().split(',').map((s) => s.trim()).filter(Boolean);
47
+ break;
48
+ case '--no-skip-primitives': opts.frameworkPrefixes = []; break;
38
49
  case '--headed': opts.headed = true; break;
39
50
  case '-h': case '--help': opts.help = true; break;
40
51
  default: console.error(`Unknown argument: ${arg}\n`); opts.help = true;
@@ -56,6 +67,7 @@ const report = await scanPages({
56
67
  tags: opts.tags,
57
68
  waitMs: opts.wait,
58
69
  headed: opts.headed,
70
+ frameworkPrefixes: opts.frameworkPrefixes,
59
71
  });
60
72
 
61
73
  const allFindings = report.pages.flatMap((p) => p.findings);
@@ -16,6 +16,18 @@ export interface NgDebugGlobal {
16
16
  getDirectives(element: Element | object): unknown[];
17
17
  }
18
18
  export declare function ngDebug(): NgDebugGlobal | undefined;
19
+ /**
20
+ * Default component-name prefixes treated as third-party UI primitives (Nebular
21
+ * `Nb*`, Angular Material `Mat*`, CDK `Cdk*`/`Mdc*`) whose violations are fixed
22
+ * where the primitive is *used*, not inside the library — e.g. `<button nbButton>`
23
+ * with no name is fixed in the component that placed it, not in Nebular.
24
+ * Attribution walks past these to the app component. A component library you
25
+ * author (e.g. `Ngbr*`) is deliberately absent: a bug in a component you ship is
26
+ * fixed in that component. Override with the `frameworkPrefixes` option — add
27
+ * `Nz`/`Clr`/`Ion`/`Tui` for other libraries, or pass `[]` to disable walking
28
+ * (attribute to the immediate owner) when scanning a library's own code.
29
+ */
30
+ export declare const DEFAULT_FRAMEWORK_PREFIXES: readonly string[];
19
31
  /**
20
32
  * The chain of owning components from the flagged node up to the root, nearest
21
33
  * first and de-duplicated. Built by walking DOM ancestors and asking Angular's
@@ -23,14 +35,18 @@ export declare function ngDebug(): NgDebugGlobal | undefined;
23
35
  * reveals the app component that placed it. Empty when the global is absent (prod).
24
36
  */
25
37
  export declare function resolveComponentPath(node: Element): string[];
26
- /** The component to blame from an ownership path: the nearest one the app owns. */
27
- export declare function appComponentFromPath(path: string[]): string | null;
38
+ /**
39
+ * The component to blame from an ownership path: the nearest one the app owns,
40
+ * walking past third-party UI primitives. Pass `frameworkPrefixes: []` to skip
41
+ * nothing and return the immediate owner.
42
+ */
43
+ export declare function appComponentFromPath(path: string[], frameworkPrefixes?: readonly string[]): string | null;
28
44
  /**
29
45
  * The owning component name for a flagged node — the nearest component the app
30
46
  * author actually owns (walking past third-party UI primitives to where the fix
31
47
  * lives). Null when the debug global is absent (prod).
32
48
  */
33
- export declare function resolveOwningComponentName(node: Element): string | null;
49
+ export declare function resolveOwningComponentName(node: Element, frameworkPrefixes?: readonly string[]): string | null;
34
50
  /**
35
51
  * Names of the directives applied directly to `node`, including those attached
36
52
  * via `hostDirectives` — the runtime-only a11y cases the static lint plugin
@@ -16,17 +16,31 @@ function nameOf(instance) {
16
16
  return cleanName(instance.constructor.name ?? null);
17
17
  }
18
18
  /**
19
- * Third-party UI-primitive components (Nebular `Nb*`, Angular Material `Mat*`,
20
- * CDK `Cdk*`/`Mdc*`) whose violations are fixed where the primitive is *used*,
21
- * not inside the library — e.g. `<button nbButton>` with no name is fixed in the
22
- * component that placed it, not in Nebular. Attribution walks past these to the
23
- * app component. Matched with a CamelCase boundary so `MatchListComponent` isn't
24
- * mistaken for Material. A component library you author (e.g. `Ngbr*`) is
25
- * deliberately absent: a bug in a component you ship is fixed in that component.
19
+ * Default component-name prefixes treated as third-party UI primitives (Nebular
20
+ * `Nb*`, Angular Material `Mat*`, CDK `Cdk*`/`Mdc*`) whose violations are fixed
21
+ * where the primitive is *used*, not inside the library — e.g. `<button nbButton>`
22
+ * with no name is fixed in the component that placed it, not in Nebular.
23
+ * Attribution walks past these to the app component. A component library you
24
+ * author (e.g. `Ngbr*`) is deliberately absent: a bug in a component you ship is
25
+ * fixed in that component. Override with the `frameworkPrefixes` option — add
26
+ * `Nz`/`Clr`/`Ion`/`Tui` for other libraries, or pass `[]` to disable walking
27
+ * (attribute to the immediate owner) when scanning a library's own code.
26
28
  */
27
- const PRIMITIVE_COMPONENT = /^(Nb|Mat|Cdk|Mdc)[A-Z]/;
28
- function isPrimitiveComponent(name) {
29
- return PRIMITIVE_COMPONENT.test(name);
29
+ export const DEFAULT_FRAMEWORK_PREFIXES = ['Nb', 'Mat', 'Cdk', 'Mdc'];
30
+ /**
31
+ * True when `name` starts with one of `prefixes` at a CamelCase boundary, so
32
+ * `MatCard` matches Material but `MatchList` does not. An empty prefix list
33
+ * matches nothing — nothing is treated as a primitive.
34
+ */
35
+ function isPrimitiveComponent(name, prefixes) {
36
+ for (const prefix of prefixes) {
37
+ if (!prefix || name.length <= prefix.length || !name.startsWith(prefix))
38
+ continue;
39
+ const next = name.charCodeAt(prefix.length);
40
+ if (next >= 65 && next <= 90)
41
+ return true; // next char is A–Z
42
+ }
43
+ return false;
30
44
  }
31
45
  /**
32
46
  * The chain of owning components from the flagged node up to the root, nearest
@@ -59,17 +73,21 @@ export function resolveComponentPath(node) {
59
73
  }
60
74
  return path;
61
75
  }
62
- /** The component to blame from an ownership path: the nearest one the app owns. */
63
- export function appComponentFromPath(path) {
64
- return path.find((name) => !isPrimitiveComponent(name)) ?? path[0] ?? null;
76
+ /**
77
+ * The component to blame from an ownership path: the nearest one the app owns,
78
+ * walking past third-party UI primitives. Pass `frameworkPrefixes: []` to skip
79
+ * nothing and return the immediate owner.
80
+ */
81
+ export function appComponentFromPath(path, frameworkPrefixes = DEFAULT_FRAMEWORK_PREFIXES) {
82
+ return path.find((name) => !isPrimitiveComponent(name, frameworkPrefixes)) ?? path[0] ?? null;
65
83
  }
66
84
  /**
67
85
  * The owning component name for a flagged node — the nearest component the app
68
86
  * author actually owns (walking past third-party UI primitives to where the fix
69
87
  * lives). Null when the debug global is absent (prod).
70
88
  */
71
- export function resolveOwningComponentName(node) {
72
- return appComponentFromPath(resolveComponentPath(node));
89
+ export function resolveOwningComponentName(node, frameworkPrefixes = DEFAULT_FRAMEWORK_PREFIXES) {
90
+ return appComponentFromPath(resolveComponentPath(node), frameworkPrefixes);
73
91
  }
74
92
  /**
75
93
  * Names of the directives applied directly to `node`, including those attached
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { provideA11yDevtools, type A11yDevtoolsOptions } from './provider.js';
2
2
  export { runA11yScan, type RunOptions } from './runner.js';
3
- export { scan, type A11yFinding, type Impact } from './scan.js';
3
+ export { scan, type A11yFinding, type Impact, type ScanOptions } from './scan.js';
4
4
  export { logFindings, type Logger } from './report.js';
5
- export { resolveOwningComponentName, resolveComponentPath, appComponentFromPath, ngDebug, type NgDebugGlobal, } from './attribution.js';
5
+ export { resolveOwningComponentName, resolveComponentPath, appComponentFromPath, DEFAULT_FRAMEWORK_PREFIXES, ngDebug, type NgDebugGlobal, } from './attribution.js';
6
6
  export { createOverlay, OVERLAY_ATTR, OVERLAY_EXCLUDE_SELECTOR, type A11yOverlay, type OverlayOptions, } from './overlay.js';
package/dist/index.js CHANGED
@@ -2,5 +2,5 @@ export { provideA11yDevtools } from './provider.js';
2
2
  export { runA11yScan } from './runner.js';
3
3
  export { scan } from './scan.js';
4
4
  export { logFindings } from './report.js';
5
- export { resolveOwningComponentName, resolveComponentPath, appComponentFromPath, ngDebug, } from './attribution.js';
5
+ export { resolveOwningComponentName, resolveComponentPath, appComponentFromPath, DEFAULT_FRAMEWORK_PREFIXES, ngDebug, } from './attribution.js';
6
6
  export { createOverlay, OVERLAY_ATTR, OVERLAY_EXCLUDE_SELECTOR, } from './overlay.js';
package/dist/inpage.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { RunOptions as AxeRunOptions } from 'axe-core';
2
- import { type A11yFinding } from './scan.js';
2
+ import { type A11yFinding, type ScanOptions } from './scan.js';
3
3
  /**
4
4
  * The browser-injected half of report-mode. A headless driver injects the built
5
5
  * IIFE (`dist/inpage.global.js`) into a running **dev** page and calls this
@@ -9,4 +9,4 @@ import { type A11yFinding } from './scan.js';
9
9
  * This entry is deliberately NOT re-exported from `index.ts`: it bundles axe-core
10
10
  * and must never reach a consumer's application bundle.
11
11
  */
12
- export type InPageScan = (options?: AxeRunOptions) => Promise<A11yFinding[]>;
12
+ export type InPageScan = (options?: AxeRunOptions, scanOptions?: ScanOptions) => Promise<A11yFinding[]>;
@@ -34146,9 +34146,16 @@
34146
34146
  return null;
34147
34147
  return cleanName(instance.constructor.name ?? null);
34148
34148
  }
34149
- var PRIMITIVE_COMPONENT = /^(Nb|Mat|Cdk|Mdc)[A-Z]/;
34150
- function isPrimitiveComponent(name) {
34151
- return PRIMITIVE_COMPONENT.test(name);
34149
+ var DEFAULT_FRAMEWORK_PREFIXES = ["Nb", "Mat", "Cdk", "Mdc"];
34150
+ function isPrimitiveComponent(name, prefixes) {
34151
+ for (const prefix of prefixes) {
34152
+ if (!prefix || name.length <= prefix.length || !name.startsWith(prefix))
34153
+ continue;
34154
+ const next = name.charCodeAt(prefix.length);
34155
+ if (next >= 65 && next <= 90)
34156
+ return true;
34157
+ }
34158
+ return false;
34152
34159
  }
34153
34160
  function resolveComponentPath(node) {
34154
34161
  const ng = ngDebug();
@@ -34171,11 +34178,11 @@
34171
34178
  }
34172
34179
  return path;
34173
34180
  }
34174
- function appComponentFromPath(path) {
34175
- return path.find((name) => !isPrimitiveComponent(name)) ?? path[0] ?? null;
34181
+ function appComponentFromPath(path, frameworkPrefixes = DEFAULT_FRAMEWORK_PREFIXES) {
34182
+ return path.find((name) => !isPrimitiveComponent(name, frameworkPrefixes)) ?? path[0] ?? null;
34176
34183
  }
34177
- function resolveOwningComponentName(node) {
34178
- return appComponentFromPath(resolveComponentPath(node));
34184
+ function resolveOwningComponentName(node, frameworkPrefixes = DEFAULT_FRAMEWORK_PREFIXES) {
34185
+ return appComponentFromPath(resolveComponentPath(node), frameworkPrefixes);
34179
34186
  }
34180
34187
  function resolveDirectiveNames(node) {
34181
34188
  const ng = ngDebug();
@@ -34329,13 +34336,14 @@
34329
34336
 
34330
34337
  // dist/scan.js
34331
34338
  var runChain = Promise.resolve();
34332
- function scan(root = document, options) {
34333
- const result = runChain.then(() => runAxeOnce(root, options));
34339
+ function scan(root = document, options, scanOptions) {
34340
+ const result = runChain.then(() => runAxeOnce(root, options, scanOptions));
34334
34341
  runChain = result.catch(() => void 0);
34335
34342
  return result;
34336
34343
  }
34337
- async function runAxeOnce(root, options) {
34344
+ async function runAxeOnce(root, options, scanOptions) {
34338
34345
  const axe = (await Promise.resolve().then(() => __toESM(require_axe(), 1))).default;
34346
+ const frameworkPrefixes = scanOptions?.frameworkPrefixes ?? DEFAULT_FRAMEWORK_PREFIXES;
34339
34347
  const context = { include: root, exclude: [OVERLAY_EXCLUDE_SELECTOR] };
34340
34348
  const results = await axe.run(context, options ?? {});
34341
34349
  const doc = root instanceof Document ? root : root.ownerDocument ?? document;
@@ -34355,7 +34363,7 @@
34355
34363
  impact: violation.impact ?? null,
34356
34364
  help: violation.help,
34357
34365
  helpUrl: violation.helpUrl,
34358
- component: appComponentFromPath(componentPath),
34366
+ component: appComponentFromPath(componentPath, frameworkPrefixes),
34359
34367
  componentPath,
34360
34368
  directives: element ? resolveDirectiveNames(element) : [],
34361
34369
  target,
@@ -34367,7 +34375,7 @@
34367
34375
  }
34368
34376
 
34369
34377
  // dist/inpage.js
34370
- var run = (options) => scan(document, options);
34378
+ var run = (options, scanOptions) => scan(document, options, scanOptions);
34371
34379
  globalThis.__ngbA11yScan = run;
34372
34380
  })();
34373
34381
  /*! Bundled license information:
package/dist/inpage.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import { scan } from './scan.js';
2
- const run = (options) => scan(document, options);
2
+ const run = (options, scanOptions) => scan(document, options, scanOptions);
3
3
  globalThis.__ngbA11yScan = run;
@@ -19,6 +19,13 @@ export interface A11yDevtoolsOptions {
19
19
  * axe run options.)
20
20
  */
21
21
  tags?: string[];
22
+ /**
23
+ * Component-name prefixes treated as third-party UI primitives to walk past
24
+ * during attribution. Defaults to `Nb`/`Mat`/`Cdk`/`Mdc`. Add others (e.g.
25
+ * `Nz`/`Clr`/`Ion`) or pass `[]` to attribute to the immediate owner — useful
26
+ * when auditing a component library's own code.
27
+ */
28
+ frameworkPrefixes?: readonly string[];
22
29
  }
23
30
  /**
24
31
  * Dev-only in-app accessibility auditing. Rescans whenever the application
package/dist/provider.js CHANGED
@@ -15,7 +15,7 @@ export function provideA11yDevtools(options = {}) {
15
15
  if (!isDevMode()) {
16
16
  return makeEnvironmentProviders([]);
17
17
  }
18
- const { root, log = true, logger, overlay = false, debounceMs = 500, tags } = options;
18
+ const { root, log = true, logger, overlay = false, debounceMs = 500, tags, frameworkPrefixes } = options;
19
19
  const axe = tags
20
20
  ? { runOnly: { type: 'tag', values: tags } }
21
21
  : undefined;
@@ -31,7 +31,7 @@ export function provideA11yDevtools(options = {}) {
31
31
  if (scanning)
32
32
  return; // don't stack rescans while one is in flight
33
33
  scanning = true;
34
- runA11yScan(root?.(), { log, logger, axe })
34
+ runA11yScan(root?.(), { log, logger, axe, frameworkPrefixes })
35
35
  .then((findings) => overlayView?.render(findings))
36
36
  .catch(() => undefined)
37
37
  .finally(() => {
@@ -19,6 +19,13 @@ export interface ScanPagesOptions {
19
19
  setup?: (page: Page) => Promise<void>;
20
20
  /** Launch a headed browser (for debugging). Default false (headless). */
21
21
  headed?: boolean;
22
+ /**
23
+ * Component-name prefixes treated as third-party UI primitives to walk past
24
+ * during attribution. Defaults to `Nb`/`Mat`/`Cdk`/`Mdc`; pass `[]` to
25
+ * attribute to the immediate owner — useful when scanning a component
26
+ * library's own code (so it blames the library component, not a demo wrapper).
27
+ */
28
+ frameworkPrefixes?: readonly string[];
22
29
  }
23
30
  /**
24
31
  * Drive a real headless browser over a running Angular **dev** build and return
@@ -21,7 +21,7 @@ function inPageScriptPath() {
21
21
  * to the component that rendered it — with no change to the target app.
22
22
  */
23
23
  export async function scanPages(options) {
24
- const { baseUrl, routes, tags, waitMs = 1500, labels = {}, setup, headed = false } = options;
24
+ const { baseUrl, routes, tags, waitMs = 1500, labels = {}, setup, headed = false, frameworkPrefixes } = options;
25
25
  const axeOptions = tags
26
26
  ? { runOnly: { type: 'tag', values: tags } }
27
27
  : undefined;
@@ -45,10 +45,10 @@ export async function scanPages(options) {
45
45
  await page.goto(url, { waitUntil: 'networkidle' }).catch(() => page.goto(url));
46
46
  await page.waitForTimeout(waitMs);
47
47
  await page.addScriptTag({ content: inPageScript });
48
- const findings = (await page.evaluate((opts) => {
48
+ const findings = (await page.evaluate((args) => {
49
49
  const w = window;
50
- return w.__ngbA11yScan(opts);
51
- }, axeOptions));
50
+ return w.__ngbA11yScan(args.axe, args.scan);
51
+ }, { axe: axeOptions, scan: { frameworkPrefixes } }));
52
52
  pages.push({ label, url: page.url(), findings });
53
53
  }
54
54
  catch (err) {
package/dist/runner.d.ts CHANGED
@@ -14,6 +14,12 @@ export interface RunOptions {
14
14
  * as a friendlier `tags: string[]`.)
15
15
  */
16
16
  axe?: AxeRunOptions;
17
+ /**
18
+ * Component-name prefixes treated as third-party UI primitives to walk past
19
+ * during attribution. Defaults to `Nb`/`Mat`/`Cdk`/`Mdc`; pass `[]` to
20
+ * attribute to the immediate owner (e.g. when scanning a library's own code).
21
+ */
22
+ frameworkPrefixes?: readonly string[];
17
23
  }
18
24
  /** Scan `root`, optionally report, and return the findings. */
19
25
  export declare function runA11yScan(root?: Element | Document, options?: RunOptions): Promise<A11yFinding[]>;
package/dist/runner.js CHANGED
@@ -2,7 +2,9 @@ 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, options.axe);
5
+ const findings = await scan(root ?? document, options.axe, {
6
+ frameworkPrefixes: options.frameworkPrefixes,
7
+ });
6
8
  if (options.log !== false) {
7
9
  logFindings(findings, options.logger);
8
10
  }
package/dist/scan.d.ts CHANGED
@@ -1,5 +1,15 @@
1
1
  import type { RunOptions } from 'axe-core';
2
2
  export type Impact = 'minor' | 'moderate' | 'serious' | 'critical' | null;
3
+ /** Attribution options for a scan (separate from axe's own run options). */
4
+ export interface ScanOptions {
5
+ /**
6
+ * Component-name prefixes treated as third-party UI primitives to walk past
7
+ * during attribution. Defaults to {@link DEFAULT_FRAMEWORK_PREFIXES}
8
+ * (`Nb`/`Mat`/`Cdk`/`Mdc`). Pass `[]` to disable walking and attribute to the
9
+ * immediate owner — useful when scanning a component library's own code.
10
+ */
11
+ frameworkPrefixes?: readonly string[];
12
+ }
3
13
  /** One axe violation node, enriched with the component that rendered it. */
4
14
  export interface A11yFinding {
5
15
  /** axe rule id, e.g. `image-alt`. */
@@ -23,4 +33,4 @@ export interface A11yFinding {
23
33
  * main bundle (the provider also no-ops outside dev mode). Concurrent calls are
24
34
  * serialized because axe cannot run more than once at a time.
25
35
  */
26
- export declare function scan(root?: Element | Document, options?: RunOptions): Promise<A11yFinding[]>;
36
+ export declare function scan(root?: Element | Document, options?: RunOptions, scanOptions?: ScanOptions): Promise<A11yFinding[]>;
package/dist/scan.js CHANGED
@@ -1,4 +1,4 @@
1
- import { appComponentFromPath, resolveComponentPath, resolveDirectiveNames } from './attribution.js';
1
+ import { appComponentFromPath, DEFAULT_FRAMEWORK_PREFIXES, resolveComponentPath, resolveDirectiveNames, } from './attribution.js';
2
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.
@@ -9,13 +9,14 @@ let runChain = Promise.resolve();
9
9
  * main bundle (the provider also no-ops outside dev mode). Concurrent calls are
10
10
  * serialized because axe cannot run more than once at a time.
11
11
  */
12
- export function scan(root = document, options) {
13
- const result = runChain.then(() => runAxeOnce(root, options));
12
+ export function scan(root = document, options, scanOptions) {
13
+ const result = runChain.then(() => runAxeOnce(root, options, scanOptions));
14
14
  runChain = result.catch(() => undefined);
15
15
  return result;
16
16
  }
17
- async function runAxeOnce(root, options) {
17
+ async function runAxeOnce(root, options, scanOptions) {
18
18
  const axe = (await import('axe-core')).default;
19
+ const frameworkPrefixes = scanOptions?.frameworkPrefixes ?? DEFAULT_FRAMEWORK_PREFIXES;
19
20
  // Scan within `root` but never flag the overlay's own highlights.
20
21
  const context = { include: root, exclude: [OVERLAY_EXCLUDE_SELECTOR] };
21
22
  const results = await axe.run(context, options ?? {});
@@ -37,7 +38,7 @@ async function runAxeOnce(root, options) {
37
38
  impact: (violation.impact ?? null),
38
39
  help: violation.help,
39
40
  helpUrl: violation.helpUrl,
40
- component: appComponentFromPath(componentPath),
41
+ component: appComponentFromPath(componentPath, frameworkPrefixes),
41
42
  componentPath,
42
43
  directives: element ? resolveDirectiveNames(element) : [],
43
44
  target,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngbracket/a11y-devtools",
3
- "version": "0.4.0",
3
+ "version": "0.5.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",