aria-ease 6.14.0 → 7.0.1

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.
Files changed (94) hide show
  1. package/README.md +1 -1
  2. package/dist/AccordionComponentStrategy-2SWMNUR6.js +1 -0
  3. package/dist/ComboboxComponentStrategy-YSYLR2U5.js +5 -0
  4. package/dist/MenuComponentStrategy-C22BZEBH.js +5 -0
  5. package/dist/RelativeTargetResolver-T4P25J2M.js +1 -0
  6. package/dist/TabsComponentStrategy-ADEEFJXM.js +1 -0
  7. package/dist/audit-WBKVW7H6.js +9 -0
  8. package/dist/badgeHelper-IB5RTMAG.js +11 -0
  9. package/dist/badgeHelper-JSROP5ML.js +1 -0
  10. package/dist/buildContracts-T4XQZBDU.js +13 -0
  11. package/dist/chunk-52I3INNG.js +11 -0
  12. package/dist/chunk-APUMBDOT.js +1 -0
  13. package/dist/chunk-BHNO4ZI3.js +1 -0
  14. package/dist/chunk-CNU4N4AY.js +1 -0
  15. package/dist/chunk-SM6ZKEDR.js +1 -0
  16. package/dist/chunk-ZNQ5BXVJ.js +1 -0
  17. package/dist/cli.cjs +132 -3560
  18. package/dist/cli.js +19 -161
  19. package/dist/configLoader-ZEJVXLX7.js +1 -0
  20. package/dist/configLoader-ZXTSCIP6.js +1 -0
  21. package/dist/contractTestRunnerPlaywright-FOCQTM4L.js +46 -0
  22. package/dist/contractTestRunnerPlaywright-QPU6HZXG.js +46 -0
  23. package/dist/formatters-H3CPDLG5.js +87 -0
  24. package/dist/index.cjs +64 -5103
  25. package/dist/index.d.cts +4 -6
  26. package/dist/index.d.ts +4 -6
  27. package/dist/index.js +17 -2703
  28. package/dist/src/accordion/index.cjs +1 -183
  29. package/dist/src/accordion/index.js +1 -181
  30. package/dist/src/block/index.cjs +1 -124
  31. package/dist/src/block/index.js +1 -122
  32. package/dist/src/checkbox/index.cjs +1 -109
  33. package/dist/src/checkbox/index.js +1 -107
  34. package/dist/src/combobox/index.cjs +1 -265
  35. package/dist/src/combobox/index.js +1 -263
  36. package/dist/src/menu/index.cjs +1 -339
  37. package/dist/src/menu/index.js +1 -337
  38. package/dist/src/radio/index.cjs +1 -117
  39. package/dist/src/radio/index.js +1 -115
  40. package/dist/src/tabs/index.cjs +1 -265
  41. package/dist/src/tabs/index.js +1 -263
  42. package/dist/src/toggle/index.cjs +1 -119
  43. package/dist/src/toggle/index.js +1 -117
  44. package/dist/src/utils/test/AccordionComponentStrategy-X2GSQ5KT.js +1 -0
  45. package/dist/src/utils/test/ComboboxComponentStrategy-SICWLI27.js +5 -0
  46. package/dist/src/utils/test/MenuComponentStrategy-R4VPAHDE.js +5 -0
  47. package/dist/src/utils/test/RelativeTargetResolver-UQQMZHI6.js +1 -0
  48. package/dist/src/utils/test/TabsComponentStrategy-L2PYNEW6.js +1 -0
  49. package/dist/src/utils/test/badgeHelper-ER5ZOHWF.js +11 -0
  50. package/dist/src/utils/test/chunk-APUMBDOT.js +1 -0
  51. package/dist/src/utils/test/chunk-BHNO4ZI3.js +1 -0
  52. package/dist/src/utils/test/configLoader-NCYRL2O6.js +1 -0
  53. package/dist/src/utils/test/contractTestRunnerPlaywright-YZCMF64Q.js +46 -0
  54. package/dist/src/utils/test/dsl/index.cjs +1 -838
  55. package/dist/src/utils/test/dsl/index.d.cts +2 -4
  56. package/dist/src/utils/test/dsl/index.d.ts +2 -4
  57. package/dist/src/utils/test/dsl/index.js +1 -836
  58. package/dist/src/utils/test/index.cjs +64 -2672
  59. package/dist/src/utils/test/index.d.cts +2 -2
  60. package/dist/src/utils/test/index.d.ts +2 -2
  61. package/dist/src/utils/test/index.js +16 -340
  62. package/dist/test-VXSCSKV5.js +19 -0
  63. package/package.json +8 -10
  64. package/dist/AccordionComponentStrategy-4ZEIQ2V6.js +0 -42
  65. package/dist/ComboboxComponentStrategy-DU342VMB.js +0 -64
  66. package/dist/MenuComponentStrategy-VYCC2XOM.js +0 -81
  67. package/dist/RelativeTargetResolver-DJAITO6D.js +0 -7
  68. package/dist/TabsComponentStrategy-3SQURPMX.js +0 -29
  69. package/dist/audit-JYEPKLHR.js +0 -63
  70. package/dist/badgeHelper-JOWO6RQG.js +0 -15
  71. package/dist/badgeHelper-RDOMCC6E.js +0 -108
  72. package/dist/buildContracts-VIV6GM56.js +0 -437
  73. package/dist/chunk-4DU5Z5BR.js +0 -340
  74. package/dist/chunk-GJGUY643.js +0 -182
  75. package/dist/chunk-GLT43UVH.js +0 -43
  76. package/dist/chunk-I2KLQ2HA.js +0 -22
  77. package/dist/chunk-JJEPLK7L.js +0 -107
  78. package/dist/chunk-PK5L2SAF.js +0 -17
  79. package/dist/configLoader-Q7N5XV4P.js +0 -183
  80. package/dist/configLoader-REHK3S3Q.js +0 -7
  81. package/dist/contractTestRunnerPlaywright-B2HLZKKK.js +0 -1394
  82. package/dist/contractTestRunnerPlaywright-RWK52C7S.js +0 -1394
  83. package/dist/formatters-32KQIIYS.js +0 -183
  84. package/dist/src/utils/test/AccordionComponentStrategy-WRHZOEN6.js +0 -38
  85. package/dist/src/utils/test/ComboboxComponentStrategy-XKQ72RFD.js +0 -60
  86. package/dist/src/utils/test/MenuComponentStrategy-6XWU5KLW.js +0 -77
  87. package/dist/src/utils/test/RelativeTargetResolver-G2XDN2VV.js +0 -1
  88. package/dist/src/utils/test/TabsComponentStrategy-BKG53SEV.js +0 -26
  89. package/dist/src/utils/test/badgeHelper-HZKGOPB4.js +0 -102
  90. package/dist/src/utils/test/chunk-4DU5Z5BR.js +0 -332
  91. package/dist/src/utils/test/chunk-GLT43UVH.js +0 -41
  92. package/dist/src/utils/test/configLoader-NA7IBCS3.js +0 -181
  93. package/dist/src/utils/test/contractTestRunnerPlaywright-5FIGA5G4.js +0 -1372
  94. package/dist/test-WDBS5JWO.js +0 -358
@@ -1,340 +0,0 @@
1
- // src/utils/test/src/ContractReporter.ts
2
- var ContractReporter = class {
3
- startTime = 0;
4
- componentName = "";
5
- staticPasses = 0;
6
- staticFailures = 0;
7
- staticWarnings = 0;
8
- dynamicResults = [];
9
- totalTests = 0;
10
- skipped = 0;
11
- warnings = 0;
12
- isPlaywright = false;
13
- isCustomContract = false;
14
- apgUrl = "https://www.w3.org/WAI/ARIA/apg/";
15
- hasPrintedStaticSection = false;
16
- hasPrintedDynamicSection = false;
17
- constructor(isPlaywright = false, isCustomContract = false) {
18
- this.isPlaywright = isPlaywright;
19
- this.isCustomContract = isCustomContract;
20
- }
21
- log(message) {
22
- process.stderr.write(message + "\n");
23
- }
24
- start(componentName, totalTests, apgUrl) {
25
- this.startTime = Date.now();
26
- this.componentName = componentName;
27
- this.totalTests = totalTests;
28
- this.hasPrintedStaticSection = false;
29
- this.hasPrintedDynamicSection = false;
30
- if (apgUrl) {
31
- this.apgUrl = apgUrl;
32
- }
33
- const mode = this.isPlaywright ? "Playwright (Real Browser)" : "jsdom (Fast)";
34
- this.log(`
35
- ${"\u2550".repeat(60)}`);
36
- this.log(`\u{1F50D} Testing ${componentName.charAt(0).toUpperCase() + componentName.slice(1)} Component - ${mode}`);
37
- this.log(`${"\u2550".repeat(60)}
38
- `);
39
- }
40
- reportStatic(passes, failures, warnings = 0) {
41
- this.staticPasses = passes;
42
- this.staticFailures = failures;
43
- this.staticWarnings = warnings;
44
- }
45
- /**
46
- * Report individual static test pass
47
- */
48
- reportStaticTest(description, status, failureMessage, level) {
49
- if (!this.hasPrintedStaticSection) {
50
- this.log(`${"\u2500".repeat(60)}`);
51
- this.log(`\u{1F9EA} Static Assertions`);
52
- this.log(`${"\u2500".repeat(60)}`);
53
- this.hasPrintedStaticSection = true;
54
- }
55
- const icon = status === "pass" ? "\u2713" : status === "warn" ? "\u26A0" : status === "skip" ? "\u25CB" : "\u2717";
56
- this.log(` ${icon} ${description}`);
57
- if (level) {
58
- this.log(` \u21B3 level=${level}`);
59
- }
60
- if ((status === "fail" || status === "warn" || status === "skip") && failureMessage) {
61
- this.log(` \u21B3 ${failureMessage}`);
62
- }
63
- }
64
- /**
65
- * Report individual dynamic test result
66
- */
67
- reportTest(test, status, failureMessage) {
68
- if (!this.hasPrintedDynamicSection) {
69
- this.log("");
70
- this.log(`${"\u2500".repeat(60)}`);
71
- this.log(`\u2328\uFE0F Dynamic Interaction Tests`);
72
- this.log(`${"\u2500".repeat(60)}`);
73
- this.hasPrintedDynamicSection = true;
74
- }
75
- const result = {
76
- description: test.description,
77
- status,
78
- failureMessage,
79
- level: test.level
80
- };
81
- if (status === "skip") {
82
- result.skipReason = "Requires real browser (addEventListener events)";
83
- }
84
- this.dynamicResults.push(result);
85
- const icons = { pass: "\u2713", fail: "\u2717", warn: "\u26A0", skip: "\u25CB" };
86
- const levelPrefix = test.level ? `[${test.level.toUpperCase()}] ` : "";
87
- this.log(` ${icons[status]} ${levelPrefix}${test.description}`);
88
- if (status === "skip" && !this.isPlaywright) {
89
- this.log(` \u21B3 Skipped in jsdom (runs in Playwright)`);
90
- }
91
- if (status === "fail" && failureMessage) {
92
- this.log(` \u21B3 ${failureMessage}`);
93
- }
94
- if (status === "warn" && failureMessage) {
95
- this.log(` \u21B3 ${failureMessage}`);
96
- }
97
- if (status === "skip" && failureMessage) {
98
- this.log(` \u21B3 ${failureMessage}`);
99
- }
100
- }
101
- /**
102
- * Report all failures with actionable context
103
- */
104
- reportFailures(failures) {
105
- if (failures.length === 0) return;
106
- this.log(`
107
- ${"\u2500".repeat(60)}`);
108
- this.log(`\u274C Failures (${failures.length}):
109
- `);
110
- failures.forEach((failure, index) => {
111
- this.log(`${index + 1}. ${failure}`);
112
- if (failure.includes("aria-")) {
113
- this.log(` \u{1F4A1} Add the missing ARIA attribute to improve screen reader support`);
114
- } else if (failure.includes("focus")) {
115
- this.log(` \u{1F4A1} Check keyboard event handlers and focus management`);
116
- } else if (failure.includes("visible")) {
117
- this.log(` \u{1F4A1} Verify display/visibility styles and state management`);
118
- }
119
- this.log("");
120
- });
121
- }
122
- reportWarnings() {
123
- const warnings = this.dynamicResults.filter((r) => r.status === "warn");
124
- if (warnings.length === 0 && this.staticWarnings === 0) return;
125
- this.log(`
126
- ${"\u2500".repeat(60)}`);
127
- this.log(`\u26A0\uFE0F Warnings (${this.staticWarnings + warnings.length}):
128
- `);
129
- this.log(`These checks are failing but treated as warnings under the active strictness mode.
130
- `);
131
- warnings.forEach((test, index) => {
132
- this.log(`${index + 1}. ${test.description}`);
133
- if (test.failureMessage) {
134
- this.log(` \u21B3 ${test.failureMessage}`);
135
- }
136
- if (test.level) {
137
- this.log(` \u21B3 level=${test.level}`);
138
- }
139
- });
140
- if (this.apgUrl) {
141
- this.log(`
142
- Reference: ${this.apgUrl}
143
- `);
144
- }
145
- }
146
- /**
147
- * Report skipped tests with helpful context
148
- */
149
- reportSkipped() {
150
- if (this.skipped === 0 || this.isPlaywright) return;
151
- const skippedTests = this.dynamicResults.filter((r) => r.status === "skip");
152
- this.log(`
153
- ${"\u2500".repeat(60)}`);
154
- this.log(`\u2139\uFE0F Skipped Tests (${this.skipped}):
155
- `);
156
- this.log(`These tests use native keyboard events via addEventListener,`);
157
- this.log(`which jsdom cannot simulate. They run successfully in Playwright.
158
- `);
159
- skippedTests.forEach((test, index) => {
160
- this.log(`${index + 1}. ${test.description}`);
161
- });
162
- this.log(`
163
- \u{1F4A1} Run with Playwright for full validation:`);
164
- this.log(` testUiComponent('${this.componentName}', null, 'http://localhost:5173/test-harness?component=component_name')
165
- `);
166
- }
167
- /**
168
- * Generate final summary with statistics
169
- */
170
- summary(failures) {
171
- const duration = Date.now() - this.startTime;
172
- const dynamicPasses = this.dynamicResults.filter((r) => r.status === "pass").length;
173
- const dynamicFailures = this.dynamicResults.filter((r) => r.status === "fail").length;
174
- const dynamicWarnings = this.dynamicResults.filter((r) => r.status === "warn").length;
175
- this.skipped = this.dynamicResults.filter((r) => r.status === "skip").length;
176
- this.warnings = this.staticWarnings + dynamicWarnings;
177
- const totalPasses = this.staticPasses + dynamicPasses;
178
- const totalFailures = this.staticFailures + dynamicFailures;
179
- const totalRun = totalPasses + totalFailures + this.warnings;
180
- const getComponentMessage = () => {
181
- const componentDisplayName = `${this.componentName.charAt(0).toUpperCase()}${this.componentName.slice(1)}`;
182
- if (this.isCustomContract) {
183
- return `${componentDisplayName} component validates against your custom accessibility policy \u2713`;
184
- }
185
- return `${componentDisplayName} component meets Aria-Ease baseline WAI-ARIA expectations \u2713`;
186
- };
187
- if (failures.length > 0) {
188
- this.reportFailures(failures);
189
- }
190
- this.reportWarnings();
191
- this.reportSkipped();
192
- this.log(`
193
- ${"\u2550".repeat(60)}`);
194
- this.log(`\u{1F4CA} Summary
195
- `);
196
- if (totalFailures === 0 && this.skipped === 0 && this.warnings === 0) {
197
- this.log(`\u2705 All ${totalRun} tests passed!`);
198
- this.log(` ${getComponentMessage()}`);
199
- } else if (totalFailures === 0) {
200
- this.log(`\u2705 ${totalPasses}/${totalRun} tests passed`);
201
- if (this.skipped > 0) {
202
- this.log(`\u25CB ${this.skipped} tests skipped`);
203
- }
204
- if (this.warnings > 0) {
205
- this.log(`\u26A0\uFE0F ${this.warnings} warning${this.warnings > 1 ? "s" : ""}`);
206
- }
207
- this.log(` ${getComponentMessage()}`);
208
- } else {
209
- this.log(`\u274C ${totalFailures} test${totalFailures > 1 ? "s" : ""} failed`);
210
- this.log(`\u2705 ${totalPasses} test${totalPasses > 1 ? "s" : ""} passed`);
211
- if (this.warnings > 0) {
212
- this.log(`\u26A0\uFE0F ${this.warnings} warning${this.warnings > 1 ? "s" : ""}`);
213
- }
214
- if (this.skipped > 0) {
215
- this.log(`\u25CB ${this.skipped} test${this.skipped > 1 ? "s" : ""} skipped`);
216
- }
217
- }
218
- this.log(`\u23F1\uFE0F Duration: ${duration}ms`);
219
- this.log(`${"\u2550".repeat(60)}
220
- `);
221
- if (totalFailures > 0) {
222
- this.log(`\u{1F527} Next Steps:`);
223
- this.log(` 1. Review the failures above`);
224
- this.log(` 2. Fix ARIA attributes and keyboard handlers`);
225
- this.log(` 3. Re-run tests to verify fixes
226
- `);
227
- } else if (!this.isPlaywright && this.skipped > 0) {
228
- this.log(`\u2728 Optional: Run Playwright tests for complete validation
229
- `);
230
- }
231
- return {
232
- passes: totalPasses,
233
- failures: totalFailures,
234
- skipped: this.skipped,
235
- duration
236
- };
237
- }
238
- /**
239
- * Report an error during test execution
240
- */
241
- error(message, context) {
242
- this.log(`
243
- \u274C Error: ${message}`);
244
- if (context) {
245
- this.log(` Context: ${context}`);
246
- }
247
- this.log("");
248
- }
249
- };
250
-
251
- // src/utils/test/src/strictness.ts
252
- var FALLBACK_LEVEL = "required";
253
- function normalizeLevel(level) {
254
- if (level === "required" || level === "recommended" || level === "optional") {
255
- return level;
256
- }
257
- return FALLBACK_LEVEL;
258
- }
259
- function normalizeStrictness(strictness) {
260
- if (strictness === "minimal" || strictness === "balanced" || strictness === "strict" || strictness === "paranoid") {
261
- return strictness;
262
- }
263
- return "balanced";
264
- }
265
- function resolveEnforcement(level, strictness) {
266
- const matrix = {
267
- minimal: {
268
- required: "error",
269
- recommended: "ignore",
270
- optional: "ignore"
271
- },
272
- balanced: {
273
- required: "error",
274
- recommended: "warning",
275
- optional: "ignore"
276
- },
277
- strict: {
278
- required: "error",
279
- recommended: "error",
280
- optional: "warning"
281
- },
282
- paranoid: {
283
- required: "error",
284
- recommended: "error",
285
- optional: "error"
286
- }
287
- };
288
- return matrix[strictness][level];
289
- }
290
-
291
- // src/utils/test/src/playwrightTestHarness.ts
292
- import { chromium } from "playwright";
293
- var sharedBrowser = null;
294
- var sharedContext = null;
295
- async function getOrCreateBrowser() {
296
- if (!sharedBrowser) {
297
- sharedBrowser = await chromium.launch({
298
- headless: true,
299
- // Launch with clean browser profile - no extensions, no user data
300
- args: [
301
- "--disable-extensions",
302
- "--disable-blink-features=AutomationControlled"
303
- ]
304
- });
305
- }
306
- return sharedBrowser;
307
- }
308
- async function getOrCreateContext() {
309
- if (!sharedContext) {
310
- const browser = await getOrCreateBrowser();
311
- sharedContext = await browser.newContext({
312
- permissions: [],
313
- ignoreHTTPSErrors: true
314
- });
315
- }
316
- return sharedContext;
317
- }
318
- async function createTestPage() {
319
- const context = await getOrCreateContext();
320
- return await context.newPage();
321
- }
322
- async function closeSharedBrowser() {
323
- if (sharedContext) {
324
- await sharedContext.close();
325
- sharedContext = null;
326
- }
327
- if (sharedBrowser) {
328
- await sharedBrowser.close();
329
- sharedBrowser = null;
330
- }
331
- }
332
-
333
- export {
334
- ContractReporter,
335
- normalizeLevel,
336
- normalizeStrictness,
337
- resolveEnforcement,
338
- createTestPage,
339
- closeSharedBrowser
340
- };
@@ -1,182 +0,0 @@
1
- // src/utils/cli/configLoader.ts
2
- import path from "path";
3
- import fs from "fs-extra";
4
- function validateConfig(config) {
5
- const errors = [];
6
- if (!config || typeof config !== "object") {
7
- errors.push("Config must be an object");
8
- return { valid: false, errors };
9
- }
10
- const cfg = config;
11
- if (cfg.audit !== void 0) {
12
- if (typeof cfg.audit !== "object" || cfg.audit === null) {
13
- errors.push("audit must be an object");
14
- } else {
15
- if (cfg.audit.urls !== void 0) {
16
- if (!Array.isArray(cfg.audit.urls)) {
17
- errors.push("audit.urls must be an array");
18
- } else if (cfg.audit.urls.some((url) => typeof url !== "string")) {
19
- errors.push("audit.urls must contain only strings");
20
- }
21
- }
22
- if (cfg.audit.output !== void 0) {
23
- if (typeof cfg.audit.output !== "object") {
24
- errors.push("audit.output must be an object");
25
- } else {
26
- const output = cfg.audit.output;
27
- if (output.format !== void 0) {
28
- if (!["json", "csv", "html", "all"].includes(output.format)) {
29
- errors.push("audit.output.format must be one of: json, csv, html, all");
30
- }
31
- }
32
- if (output.out !== void 0 && typeof output.out !== "string") {
33
- errors.push("audit.output.out must be a string");
34
- }
35
- }
36
- }
37
- }
38
- }
39
- if (cfg.test !== void 0) {
40
- if (typeof cfg.test !== "object" || cfg.test === null) {
41
- errors.push("test must be an object");
42
- } else {
43
- if (cfg.test.disableTimeouts !== void 0 && typeof cfg.test.disableTimeouts !== "boolean") {
44
- errors.push("test.disableTimeouts must be a boolean when provided");
45
- }
46
- const testTimeoutFields = [
47
- "actionTimeoutMs",
48
- "assertionTimeoutMs",
49
- "navigationTimeoutMs",
50
- "componentReadyTimeoutMs"
51
- ];
52
- for (const field of testTimeoutFields) {
53
- const value = cfg.test[field];
54
- if (value !== void 0) {
55
- if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
56
- errors.push(`test.${field} must be a non-negative number when provided`);
57
- }
58
- }
59
- }
60
- if (cfg.test.components !== void 0) {
61
- if (!Array.isArray(cfg.test.components)) {
62
- errors.push("test.components must be an array");
63
- } else {
64
- cfg.test.components.forEach((comp, idx) => {
65
- if (typeof comp !== "object" || comp === null) {
66
- errors.push(`test.components[${idx}] must be an object`);
67
- } else {
68
- if (typeof comp.name !== "string") {
69
- errors.push(`test.components[${idx}].name must be a string`);
70
- }
71
- if (comp.contractPath !== void 0 && typeof comp.contractPath !== "string") {
72
- errors.push(`test.components[${idx}].contractPath must be a string when provided`);
73
- }
74
- if (comp.strategyPath !== void 0 && typeof comp.strategyPath !== "string") {
75
- errors.push(`test.components[${idx}].strategyPath must be a string when provided`);
76
- }
77
- if (comp.strictness !== void 0 && !["minimal", "balanced", "strict", "paranoid"].includes(comp.strictness)) {
78
- errors.push(`test.components[${idx}].strictness must be one of: minimal, balanced, strict, paranoid`);
79
- }
80
- if (comp.disableTimeouts !== void 0 && typeof comp.disableTimeouts !== "boolean") {
81
- errors.push(`test.components[${idx}].disableTimeouts must be a boolean when provided`);
82
- }
83
- const componentTimeoutFields = [
84
- "actionTimeoutMs",
85
- "assertionTimeoutMs",
86
- "navigationTimeoutMs",
87
- "componentReadyTimeoutMs"
88
- ];
89
- for (const field of componentTimeoutFields) {
90
- const value = comp[field];
91
- if (value !== void 0) {
92
- if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
93
- errors.push(`test.components[${idx}].${field} must be a non-negative number when provided`);
94
- }
95
- }
96
- }
97
- }
98
- });
99
- }
100
- }
101
- if (cfg.test.strictness !== void 0) {
102
- if (!["minimal", "balanced", "strict", "paranoid"].includes(cfg.test.strictness)) {
103
- errors.push("test.strictness must be one of: minimal, balanced, strict, paranoid");
104
- }
105
- }
106
- }
107
- }
108
- if (cfg.contracts !== void 0) {
109
- if (!Array.isArray(cfg.contracts)) {
110
- errors.push("contracts must be an array");
111
- } else {
112
- cfg.contracts.forEach((contract, idx) => {
113
- if (typeof contract !== "object" || contract === null) {
114
- errors.push(`contracts[${idx}] must be an object`);
115
- } else {
116
- if (typeof contract.src !== "string") {
117
- errors.push(`contracts[${idx}].src is required and must be a string`);
118
- }
119
- if (contract.out !== void 0 && typeof contract.out !== "string") {
120
- errors.push(`contracts[${idx}].out must be a string`);
121
- }
122
- }
123
- });
124
- }
125
- }
126
- return { valid: errors.length === 0, errors };
127
- }
128
- async function loadConfigFile(filePath) {
129
- try {
130
- const ext = path.extname(filePath);
131
- if (ext === ".json") {
132
- const content = await fs.readFile(filePath, "utf-8");
133
- return JSON.parse(content);
134
- } else if ([".js", ".mjs", ".cjs", ".ts"].includes(ext)) {
135
- const imported = await import(filePath);
136
- return imported.default || imported;
137
- }
138
- return null;
139
- } catch {
140
- return null;
141
- }
142
- }
143
- async function loadConfig(cwd = process.cwd()) {
144
- const configNames = [
145
- "ariaease.config.js",
146
- "ariaease.config.mjs",
147
- "ariaease.config.cjs",
148
- "ariaease.config.json",
149
- "ariaease.config.ts"
150
- ];
151
- let loadedConfig = null;
152
- let foundPath = null;
153
- const errors = [];
154
- for (const name of configNames) {
155
- const configPath = path.resolve(cwd, name);
156
- if (await fs.pathExists(configPath)) {
157
- foundPath = configPath;
158
- loadedConfig = await loadConfigFile(configPath);
159
- if (loadedConfig === null) {
160
- errors.push(`Found config at ${name} but failed to load it. Check for syntax errors.`);
161
- continue;
162
- }
163
- const validation = validateConfig(loadedConfig);
164
- if (!validation.valid) {
165
- errors.push(`Config validation failed in ${name}:`);
166
- errors.push(...validation.errors.map((err) => ` - ${err}`));
167
- loadedConfig = null;
168
- continue;
169
- }
170
- break;
171
- }
172
- }
173
- return {
174
- config: loadedConfig || {},
175
- configPath: loadedConfig ? foundPath : null,
176
- errors
177
- };
178
- }
179
-
180
- export {
181
- loadConfig
182
- };
@@ -1,43 +0,0 @@
1
- // src/utils/test/src/RelativeTargetResolver.ts
2
- var RelativeTargetResolver = class {
3
- /**
4
- * Resolve a relative target like "first", "second", "last", "next", "previous"
5
- * @param page Playwright page instance
6
- * @param selector Base selector to find elements
7
- * @param relative Relative position (first, second, last, next, previous)
8
- * @returns The resolved Locator or null if not found
9
- */
10
- static async resolve(page, selector, relative) {
11
- const items = await page.locator(selector).all();
12
- switch (relative) {
13
- case "first":
14
- return items[0];
15
- case "second":
16
- return items[1];
17
- case "last":
18
- return items[items.length - 1];
19
- case "next": {
20
- const currentIndex = await page.evaluate(([sel]) => {
21
- const items2 = Array.from(document.querySelectorAll(sel));
22
- return items2.indexOf(document.activeElement);
23
- }, [selector]);
24
- const nextIndex = (currentIndex + 1) % items.length;
25
- return items[nextIndex];
26
- }
27
- case "previous": {
28
- const currentIndex = await page.evaluate(([sel]) => {
29
- const items2 = Array.from(document.querySelectorAll(sel));
30
- return items2.indexOf(document.activeElement);
31
- }, [selector]);
32
- const prevIndex = (currentIndex - 1 + items.length) % items.length;
33
- return items[prevIndex];
34
- }
35
- default:
36
- return null;
37
- }
38
- }
39
- };
40
-
41
- export {
42
- RelativeTargetResolver
43
- };
@@ -1,22 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
-
19
- export {
20
- __export,
21
- __reExport
22
- };
@@ -1,107 +0,0 @@
1
- // src/utils/cli/badgeHelper.ts
2
- import fs from "fs-extra";
3
- import path from "path";
4
- import chalk from "chalk";
5
- import readline from "readline";
6
- var BADGE_CONFIGS = {
7
- audit: {
8
- type: "audit",
9
- fileName: "audited-by-aria-ease.svg",
10
- label: "Audited by aria-ease",
11
- markdownUrl: "https://cdn.jsdelivr.net/gh/aria-ease/aria-ease@main/badges/audited-by-aria-ease.svg"
12
- },
13
- component: {
14
- type: "component",
15
- fileName: "components-tested-aria-ease.svg",
16
- label: "Components tested: aria-ease",
17
- markdownUrl: "https://cdn.jsdelivr.net/gh/aria-ease/aria-ease@main/badges/components-tested-aria-ease.svg"
18
- },
19
- verified: {
20
- type: "verified",
21
- fileName: "verified-by-aria-ease.svg",
22
- label: "Verified by aria-ease",
23
- markdownUrl: "https://cdn.jsdelivr.net/gh/aria-ease/aria-ease@main/badges/verified-by-aria-ease.svg"
24
- }
25
- };
26
- function getBadgeMarkdown(badgeType) {
27
- const config = BADGE_CONFIGS[badgeType];
28
- return `[![${config.label}](${config.markdownUrl})](https://github.com/aria-ease/aria-ease)`;
29
- }
30
- function displayBadgeInfo(badgeType) {
31
- const markdown = getBadgeMarkdown(badgeType);
32
- console.log(chalk.cyan("\n\u{1F3C5} Show your accessibility commitment!"));
33
- console.log(chalk.white(" Add this badge to your README.md:\n"));
34
- console.log(chalk.green(" " + markdown));
35
- console.log(chalk.dim("\n This helps others discover accessibility tools and shows you care!\n"));
36
- }
37
- async function promptAddBadge(badgeType, cwd = process.cwd()) {
38
- const readmePath = path.join(cwd, "README.md");
39
- const readmeExists = await fs.pathExists(readmePath);
40
- if (!readmeExists) {
41
- console.log(chalk.yellow(" \u2139\uFE0F No README.md found in current directory"));
42
- return;
43
- }
44
- const readmeContent = await fs.readFile(readmePath, "utf-8");
45
- const markdown = getBadgeMarkdown(badgeType);
46
- if (readmeContent.includes(markdown) || readmeContent.includes(BADGE_CONFIGS[badgeType].fileName)) {
47
- console.log(chalk.gray(" \u2713 Badge already in README.md"));
48
- return;
49
- }
50
- const rl = readline.createInterface({
51
- input: process.stdin,
52
- output: process.stdout
53
- });
54
- const answer = await new Promise((resolve) => {
55
- rl.question(chalk.cyan(" Add badge to README.md now? (y/n): "), (ans) => {
56
- rl.close();
57
- resolve(ans.toLowerCase().trim());
58
- });
59
- });
60
- if (answer === "y" || answer === "yes") {
61
- await addBadgeToReadme(readmePath, readmeContent, markdown);
62
- console.log(chalk.green(" \u2713 Badge added to README.md!"));
63
- } else {
64
- console.log(chalk.gray(" Skipped. You can add it manually anytime."));
65
- }
66
- }
67
- async function addBadgeToReadme(readmePath, content, badge) {
68
- const lines = content.split("\n");
69
- let insertIndex = 0;
70
- for (let i = 0; i < lines.length; i++) {
71
- const line = lines[i].trim();
72
- if (line.startsWith("[![") || line.startsWith("[!")) {
73
- insertIndex = i + 1;
74
- continue;
75
- }
76
- if (insertIndex > 0 && !line.startsWith("[![") && !line.startsWith("[!") && line.length > 0) {
77
- break;
78
- }
79
- if (insertIndex === 0 && line.startsWith("#")) {
80
- insertIndex = i + 2;
81
- break;
82
- }
83
- }
84
- if (insertIndex === 0) {
85
- insertIndex = 1;
86
- }
87
- lines.splice(insertIndex, 0, badge);
88
- await fs.writeFile(readmePath, lines.join("\n"), "utf-8");
89
- }
90
- function displayAllBadges() {
91
- console.log(chalk.cyan("\n\u{1F4CD} Available badges:"));
92
- console.log(chalk.white("\n For audits:"));
93
- console.log(chalk.green(" " + getBadgeMarkdown("audit")));
94
- console.log(chalk.white("\n For component testing:"));
95
- console.log(chalk.green(" " + getBadgeMarkdown("component")));
96
- console.log(chalk.white("\n For both (verified):"));
97
- console.log(chalk.green(" " + getBadgeMarkdown("verified")));
98
- console.log("");
99
- }
100
-
101
- export {
102
- BADGE_CONFIGS,
103
- getBadgeMarkdown,
104
- displayBadgeInfo,
105
- promptAddBadge,
106
- displayAllBadges
107
- };