aria-ease 2.8.2 → 2.8.4
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/bin/audit-XABLAI36.js +47 -0
- package/{dist/chunk-PCORWVIQ.js → bin/chunk-JGKPHTSR.js} +0 -35
- package/bin/chunk-JSBRDJBE.js +30 -0
- package/bin/cli.cjs +13820 -0
- package/bin/cli.d.cts +1 -0
- package/bin/cli.d.ts +1 -0
- package/bin/cli.js +5 -243
- package/{dist/contractTestRunnerPlaywright-SE6TPWZZ.js → bin/contractTestRunnerPlaywright-EHQAMXQA.js} +7 -3
- package/bin/contractTestRunnerPlaywright-VDTXMVK5.js +263 -0
- package/bin/formatters-2RPHPXW2.js +176 -0
- package/bin/test-N6M7MDBZ.js +12804 -0
- package/bin/test-S2U633GD.js +12804 -0
- package/dist/{contractTestRunnerPlaywright-YNHMLHQ2.js → contractTestRunnerPlaywright-7O2T4JES.js} +5 -2
- package/dist/{contractTestRunnerPlaywright-ZY2T4UTV.js → contractTestRunnerPlaywright-AJ2DOOJT.js} +10 -2
- package/dist/index.cjs +10 -2
- package/dist/index.js +1 -1
- package/dist/src/utils/test/{contractTestRunnerPlaywright-I36Y2NHA.js → contractTestRunnerPlaywright-7O2T4JES.js} +5 -2
- package/dist/src/utils/test/{contractTestRunnerPlaywright-YNHMLHQ2.js → contractTestRunnerPlaywright-AJ2DOOJT.js} +10 -2
- package/dist/src/utils/test/index.cjs +10 -2
- package/dist/src/utils/test/index.js +1 -1
- package/package.json +2 -1
- package/dist/src/utils/test/contractTestRunnerPlaywright-ZY2T4UTV.js +0 -249
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import "./chunk-JSBRDJBE.js";
|
|
2
|
+
|
|
3
|
+
// src/utils/audit/src/formatters/formatters.js
|
|
4
|
+
function formatResults(allResults, format) {
|
|
5
|
+
switch (format) {
|
|
6
|
+
case "json":
|
|
7
|
+
return JSON.stringify(allResults.flatMap(({ url, result }) => result ? result.violations.flatMap((v) => v.nodes.map((n) => ({
|
|
8
|
+
URL: url,
|
|
9
|
+
Rule: v.id,
|
|
10
|
+
Impact: v.impact,
|
|
11
|
+
Description: v.description,
|
|
12
|
+
Target: n.target,
|
|
13
|
+
FailureSummary: n.failureSummary
|
|
14
|
+
}))) : []), null, 2);
|
|
15
|
+
case "csv":
|
|
16
|
+
return toCSV(allResults);
|
|
17
|
+
case "html":
|
|
18
|
+
return toHTML(allResults);
|
|
19
|
+
default:
|
|
20
|
+
return "";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function toCSV(allResults) {
|
|
24
|
+
const rows = ["URL,Rule,Impact,Description,Target,FailureSummary"];
|
|
25
|
+
allResults.forEach(({ url, result }) => {
|
|
26
|
+
if (result) {
|
|
27
|
+
result.violations.forEach((v) => {
|
|
28
|
+
v.nodes.forEach((n) => {
|
|
29
|
+
rows.push(escapeCSV(url) + "," + escapeCSV(v.id) + "," + escapeCSV(v.impact) + "," + escapeCSV(v.description) + "," + escapeCSV(Array.isArray(n.target) ? n.target.join("; ") : String(n.target)) + "," + escapeCSV(n.failureSummary ?? ""));
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return rows.join("\n");
|
|
35
|
+
}
|
|
36
|
+
function escapeCSV(value) {
|
|
37
|
+
const s = String(value ?? "");
|
|
38
|
+
return `"${s.replace(/"/g, '""')}"`;
|
|
39
|
+
}
|
|
40
|
+
function toHTML(allResults) {
|
|
41
|
+
const summary = {
|
|
42
|
+
pagesAudited: 0,
|
|
43
|
+
pagesWithViolations: 0,
|
|
44
|
+
totalViolations: 0,
|
|
45
|
+
distinctRules: /* @__PURE__ */ new Set(),
|
|
46
|
+
impactCounts: /* @__PURE__ */ new Map()
|
|
47
|
+
};
|
|
48
|
+
allResults.forEach(({ result }) => {
|
|
49
|
+
if (!result)
|
|
50
|
+
return;
|
|
51
|
+
summary.pagesAudited++;
|
|
52
|
+
const pageViolations = result.violations.reduce((acc, v) => {
|
|
53
|
+
const nodesCount = (v.nodes || []).length;
|
|
54
|
+
if (nodesCount > 0) {
|
|
55
|
+
summary.distinctRules.add(v.id);
|
|
56
|
+
summary.totalViolations += nodesCount;
|
|
57
|
+
acc += nodesCount;
|
|
58
|
+
const impact = String(v.impact ?? "unknown");
|
|
59
|
+
summary.impactCounts.set(impact, (summary.impactCounts.get(impact) || 0) + nodesCount);
|
|
60
|
+
}
|
|
61
|
+
return acc;
|
|
62
|
+
}, 0);
|
|
63
|
+
if (pageViolations > 0)
|
|
64
|
+
summary.pagesWithViolations++;
|
|
65
|
+
});
|
|
66
|
+
const rows = [];
|
|
67
|
+
allResults.forEach(({ url, result }) => {
|
|
68
|
+
if (!result)
|
|
69
|
+
return;
|
|
70
|
+
result.violations.forEach((v) => {
|
|
71
|
+
v.nodes.forEach((n) => {
|
|
72
|
+
const target = Array.isArray(n.target) ? n.target.join("; ") : String(n.target);
|
|
73
|
+
rows.push(`
|
|
74
|
+
<tr>
|
|
75
|
+
<td class="nowrap">${escapeHTML(url)}</td>
|
|
76
|
+
<td class="nowrap">${escapeHTML(v.id)}</td>
|
|
77
|
+
<td class="impact ${escapeClass(String(v.impact ?? "unknown"))}">${escapeHTML(String(v.impact ?? ""))}</td>
|
|
78
|
+
<td class="desc">${escapeHTML(v.description ?? "")}</td>
|
|
79
|
+
<td class="target"><code>${escapeHTML(target)}</code></td>
|
|
80
|
+
<td class="fail">${escapeHTML(n.failureSummary ?? "").split(/\r?\n/).join("<br/>")}</td>
|
|
81
|
+
</tr>
|
|
82
|
+
`);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
const impactSummary = Array.from(summary.impactCounts.entries()).map(([impact, count]) => `<li><strong class="impact ${escapeClass(impact)}">${escapeHTML(impact)}</strong>: ${count}</li>`).join("\n");
|
|
87
|
+
const d = /* @__PURE__ */ new Date();
|
|
88
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
89
|
+
const reportDateTime = `${pad(d.getDate())}-${pad(d.getMonth() + 1)}-${d.getFullYear()} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
|
|
90
|
+
const headerSummary = `
|
|
91
|
+
<section class="summary">
|
|
92
|
+
<h2>Report summary</h2>
|
|
93
|
+
<ul>
|
|
94
|
+
<li><strong>Date:</strong> ${reportDateTime}</li>
|
|
95
|
+
<li><strong>Pages audited:</strong> ${summary.pagesAudited}</li>
|
|
96
|
+
<li><strong>Pages with violations:</strong> ${summary.pagesWithViolations}</li>
|
|
97
|
+
<li><strong>Total violations:</strong> ${summary.totalViolations}</li>
|
|
98
|
+
<li><strong>Distinct rules:</strong> ${summary.distinctRules.size}</li>
|
|
99
|
+
</ul>
|
|
100
|
+
<div class="impact-summary">
|
|
101
|
+
<h3>By impact</h3>
|
|
102
|
+
<ul class="summary-list">
|
|
103
|
+
${impactSummary || "<li>None</li>"}
|
|
104
|
+
</ul>
|
|
105
|
+
</div>
|
|
106
|
+
</section>
|
|
107
|
+
`.trim();
|
|
108
|
+
const html = `
|
|
109
|
+
<!DOCTYPE html>
|
|
110
|
+
<html lang="en">
|
|
111
|
+
<head>
|
|
112
|
+
<meta charset="utf-8"/>
|
|
113
|
+
<title>Aria-Ease Accessibility Audit Report</title>
|
|
114
|
+
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
115
|
+
<style>
|
|
116
|
+
:root{
|
|
117
|
+
--bg:#ffffff; --muted:#6b7280; --border:#e6e9ee;
|
|
118
|
+
--impact-critical: red; --impact-moderate:#fff4dd; --impact-serious:rgb(255, 123, 0);
|
|
119
|
+
}
|
|
120
|
+
body{font-family:Inter,ui-sans-serif,system-ui,Segoe UI,Roboto,Helvetica,Arial; background:var(--bg); color:#111827; padding:24px; line-height:1.4}
|
|
121
|
+
h1{margin:0 0 8px}
|
|
122
|
+
.summary{background:#f8fafc;border:1px solid var(--border);padding:12px 16px;border-radius:8px;margin-bottom:18px}
|
|
123
|
+
.summary ul{margin:6px 0 0 0;padding:0 18px}
|
|
124
|
+
.impact-summary h3{margin:12px 0 6px}
|
|
125
|
+
table{width:100%; border-collapse:collapse; margin-top:12px}
|
|
126
|
+
th,td{border:1px solid var(--border); padding:10px; text-align:left; vertical-align:top}
|
|
127
|
+
th{background:#f3f4f6; font-weight:600; position:sticky; top:0; z-index:1}
|
|
128
|
+
.nowrap{white-space:nowrap}
|
|
129
|
+
.target code{font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", "Courier New", monospace; white-space:pre-wrap}
|
|
130
|
+
.desc{max-width:380px}
|
|
131
|
+
tr:nth-child(even){background:#fbfbfb}
|
|
132
|
+
td.fail{color:#7b1e1e}
|
|
133
|
+
.impact.critical{background:var(--impact-critical); font-weight:600}
|
|
134
|
+
.impact.moderate{background:var(--impact-moderate); font-weight:600}
|
|
135
|
+
.impact.serious{background:var(--impact-serious); font-weight:600}
|
|
136
|
+
@media (max-width:900px){
|
|
137
|
+
.desc{max-width:200px}
|
|
138
|
+
table, thead, tbody, th, td, tr{display:block}
|
|
139
|
+
thead{display:none}
|
|
140
|
+
tr{margin-bottom:10px; border: 1px solid var(--border);}
|
|
141
|
+
td{border:1px solid var(--border); padding:6px}
|
|
142
|
+
td::before{font-weight:600; display:inline-block; width:120px}
|
|
143
|
+
}
|
|
144
|
+
.summary-list strong,
|
|
145
|
+
.summary-list li {
|
|
146
|
+
padding: 2px 4px;
|
|
147
|
+
}
|
|
148
|
+
</style>
|
|
149
|
+
</head>
|
|
150
|
+
<body>
|
|
151
|
+
<h1>Aria-Ease Accessibility Audit Report</h1>
|
|
152
|
+
${headerSummary}
|
|
153
|
+
<table>
|
|
154
|
+
<thead>
|
|
155
|
+
<tr>
|
|
156
|
+
<th>URL</th><th>Rule</th><th>Impact</th><th>Description</th><th>Target</th><th>FailureSummary</th>
|
|
157
|
+
</tr>
|
|
158
|
+
</thead>
|
|
159
|
+
<tbody>
|
|
160
|
+
${rows.join("\n") || '<tr><td colspan="6"><em>No violations found.</em></td></tr>'}
|
|
161
|
+
</tbody>
|
|
162
|
+
</table>
|
|
163
|
+
</body>
|
|
164
|
+
</html>
|
|
165
|
+
`.trim();
|
|
166
|
+
return html;
|
|
167
|
+
}
|
|
168
|
+
function escapeHTML(str) {
|
|
169
|
+
return String(str ?? "").replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
170
|
+
}
|
|
171
|
+
function escapeClass(s) {
|
|
172
|
+
return String(s ?? "").toLowerCase().replace(/[^a-z0-9]+/g, "-");
|
|
173
|
+
}
|
|
174
|
+
export {
|
|
175
|
+
formatResults
|
|
176
|
+
};
|