@d-zero/a11y-check-axe-scenario 0.2.0 → 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/dist/convert-results-from-node.d.ts +7 -0
- package/dist/convert-results-from-node.js +7 -0
- package/dist/convert-results-from-violations.d.ts +8 -0
- package/dist/convert-results-from-violations.js +8 -0
- package/dist/detect-level.d.ts +4 -0
- package/dist/detect-level.js +4 -0
- package/dist/detect-version.d.ts +4 -0
- package/dist/detect-version.js +4 -0
- package/dist/infer-explanation.d.ts +6 -0
- package/dist/infer-explanation.js +6 -0
- package/dist/pargraph.d.ts +8 -0
- package/dist/pargraph.js +8 -0
- package/dist/tags-to-scs.d.ts +8 -0
- package/dist/tags-to-scs.js +8 -0
- package/package.json +5 -5
- package/dist/axe-puppeteer.d.ts +0 -3
- package/dist/axe-puppeteer.js +0 -17
- package/dist/sc.d.ts +0 -1
- package/dist/sc.js +0 -23
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { Style } from '@d-zero/a11y-check-core';
|
|
2
2
|
import type { Page } from '@d-zero/puppeteer-page';
|
|
3
3
|
import type { NodeResult } from 'axe-core';
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param page
|
|
7
|
+
* @param node
|
|
8
|
+
* @param screenshot
|
|
9
|
+
* @param log
|
|
10
|
+
*/
|
|
4
11
|
export declare function convertResultsFromNode(page: Page, node: NodeResult, screenshot: boolean, log: (log: string) => void): Promise<{
|
|
5
12
|
screenshot: string | null;
|
|
6
13
|
style: Style | null;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { hash } from '@d-zero/shared/hash';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param page
|
|
6
|
+
* @param node
|
|
7
|
+
* @param screenshot
|
|
8
|
+
* @param log
|
|
9
|
+
*/
|
|
3
10
|
export async function convertResultsFromNode(page, node, screenshot, log) {
|
|
4
11
|
const target = node.target[0] && typeof node.target[0] === 'string' ? node.target[0] : null;
|
|
5
12
|
if (!target) {
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { Violation } from '@d-zero/a11y-check-core';
|
|
2
2
|
import type { Page } from '@d-zero/puppeteer-page';
|
|
3
3
|
import type { AxeResults } from 'axe-core';
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param page
|
|
7
|
+
* @param axeResults
|
|
8
|
+
* @param sizeName
|
|
9
|
+
* @param screenshot
|
|
10
|
+
* @param log
|
|
11
|
+
*/
|
|
4
12
|
export declare function convertResultsFromViolations(page: Page, axeResults: AxeResults, sizeName: string, screenshot: boolean, log: (log: string) => void): Promise<Violation[]>;
|
|
@@ -3,6 +3,14 @@ import { detectLevel } from './detect-level.js';
|
|
|
3
3
|
import { inferExplanation } from './infer-explanation.js';
|
|
4
4
|
import { p } from './pargraph.js';
|
|
5
5
|
import { tagsToSCs } from './tags-to-scs.js';
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param page
|
|
9
|
+
* @param axeResults
|
|
10
|
+
* @param sizeName
|
|
11
|
+
* @param screenshot
|
|
12
|
+
* @param log
|
|
13
|
+
*/
|
|
6
14
|
export async function convertResultsFromViolations(page, axeResults, sizeName, screenshot, log) {
|
|
7
15
|
const results = [];
|
|
8
16
|
const violations = [...axeResults.incomplete, ...axeResults.violations];
|
package/dist/detect-level.d.ts
CHANGED
package/dist/detect-level.js
CHANGED
package/dist/detect-version.d.ts
CHANGED
package/dist/detect-version.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { AxeRuleId, Explanation } from './types.js';
|
|
2
2
|
import type { Style } from '@d-zero/a11y-check-core';
|
|
3
3
|
import type { NodeResult } from 'axe-core';
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param id
|
|
7
|
+
* @param node
|
|
8
|
+
* @param style
|
|
9
|
+
*/
|
|
4
10
|
export declare function inferExplanation(id: AxeRuleId, node: NodeResult, style: Style | null): Explanation | null;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { colorContrastCheck, ColorContrastError } from '@d-zero/a11y-check-core';
|
|
2
2
|
import { br, p } from './pargraph.js';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param id
|
|
6
|
+
* @param node
|
|
7
|
+
* @param style
|
|
8
|
+
*/
|
|
3
9
|
export function inferExplanation(id, node, style) {
|
|
4
10
|
switch (id) {
|
|
5
11
|
case 'accesskeys': {
|
package/dist/pargraph.d.ts
CHANGED
package/dist/pargraph.js
CHANGED
package/dist/tags-to-scs.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param tags
|
|
4
|
+
*/
|
|
1
5
|
export declare function tagsToSCs(tags: string[]): string;
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param tag
|
|
9
|
+
*/
|
|
2
10
|
export declare function tagToSC(tag: string): "1.1.1" | "1.2.1" | "1.2.2" | "1.2.3" | "1.2.4" | "1.2.5" | "1.2.6" | "1.2.7" | "1.2.8" | "1.2.9" | "1.3.1" | "1.3.2" | "1.3.3" | "1.3.4" | "1.3.5" | "1.3.6" | "1.4.1" | "1.4.2" | "1.4.3" | "1.4.4" | "1.4.5" | "1.4.6" | "1.4.7" | "1.4.8" | "1.4.9" | "1.4.10" | "1.4.11" | "1.4.12" | "1.4.13" | "2.1.1" | "2.1.2" | "2.1.3" | "2.1.4" | "2.2.1" | "2.2.2" | "2.2.3" | "2.2.4" | "2.2.5" | "2.2.6" | "2.3.1" | "2.3.2" | "2.3.3" | "2.4.1" | "2.4.2" | "2.4.3" | "2.4.4" | "2.4.5" | "2.4.6" | "2.4.7" | "2.4.8" | "2.4.9" | "2.4.10" | "2.4.11" | "2.4.12" | "2.4.13" | "2.5.1" | "2.5.2" | "2.5.3" | "2.5.4" | "2.5.5" | "2.5.6" | "2.5.7" | "2.5.8" | "3.1.1" | "3.1.2" | "3.1.3" | "3.1.4" | "3.1.5" | "3.1.6" | "3.2.1" | "3.2.2" | "3.2.3" | "3.2.4" | "3.2.5" | "3.2.6" | "3.3.1" | "3.3.2" | "3.3.3" | "3.3.4" | "3.3.5" | "3.3.6" | "3.3.7" | "3.3.8" | "3.3.9" | "4.1.2" | "4.1.3" | null;
|
package/dist/tags-to-scs.js
CHANGED
|
@@ -2,9 +2,17 @@ import { wcag } from '@d-zero/db-wcag';
|
|
|
2
2
|
const scVersions = new Set(
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
Object.keys(wcag.successCriterions['wcag_2.2'].en));
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param tags
|
|
8
|
+
*/
|
|
5
9
|
export function tagsToSCs(tags) {
|
|
6
10
|
return tags.map(tagToSC).filter(Boolean).join('\n');
|
|
7
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param tag
|
|
15
|
+
*/
|
|
8
16
|
export function tagToSC(tag) {
|
|
9
17
|
if (!tag.startsWith('wcag') || tag.endsWith('a')) {
|
|
10
18
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d-zero/a11y-check-axe-scenario",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Accessibility Checker Axe Scenario",
|
|
5
5
|
"author": "D-ZERO",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"clean": "tsc --build --clean"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@d-zero/a11y-check-core": "0.
|
|
27
|
+
"@d-zero/a11y-check-core": "0.3.0",
|
|
28
28
|
"@d-zero/db-wcag": "1.0.0-alpha.1",
|
|
29
|
-
"@d-zero/shared": "0.
|
|
29
|
+
"@d-zero/shared": "0.7.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@d-zero/puppeteer-page": "0.
|
|
32
|
+
"@d-zero/puppeteer-page": "0.3.0",
|
|
33
33
|
"axe-core": "4.10.2"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "e4fd17857e31022d121527b00fd7f009dbdb2142"
|
|
36
36
|
}
|
package/dist/axe-puppeteer.d.ts
DELETED
package/dist/axe-puppeteer.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { AxePuppeteer } from '@axe-core/puppeteer';
|
|
2
|
-
import { delay } from '@d-zero/shared/delay';
|
|
3
|
-
export async function runAxePuppeteer(page, lang, log) {
|
|
4
|
-
const mod = await import(`axe-core/locales/${lang}.json`, {
|
|
5
|
-
with: { type: 'json' },
|
|
6
|
-
});
|
|
7
|
-
const locale = mod.default;
|
|
8
|
-
log(`Analyze%dots%`);
|
|
9
|
-
const axeResults = await new AxePuppeteer(page)
|
|
10
|
-
.configure({
|
|
11
|
-
locale,
|
|
12
|
-
})
|
|
13
|
-
.analyze();
|
|
14
|
-
log(`Found ${axeResults.violations.length} violations, ${axeResults.incomplete.length} incomplete issues`);
|
|
15
|
-
await delay(600);
|
|
16
|
-
return axeResults;
|
|
17
|
-
}
|
package/dist/sc.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function sc(tags: string[]): string;
|
package/dist/sc.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { wcag } from '@d-zero/db-wcag';
|
|
2
|
-
const scVersions = new Set(
|
|
3
|
-
// @ts-ignore
|
|
4
|
-
Object.keys(wcag.successCriterions['wcag_2.2'].en));
|
|
5
|
-
export function sc(tags) {
|
|
6
|
-
return tags.map(_sc).filter(Boolean).join('\n');
|
|
7
|
-
}
|
|
8
|
-
function _sc(tag) {
|
|
9
|
-
if (!tag.startsWith('wcag') || tag.endsWith('a')) {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
const num = /\d+/.exec(tag)?.[0];
|
|
13
|
-
if (!num) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
for (const version of scVersions) {
|
|
17
|
-
const crushedNum = version.replaceAll('.', '');
|
|
18
|
-
if (tag === crushedNum) {
|
|
19
|
-
return version;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
}
|