aria-ease 2.0.2 → 2.1.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.
Files changed (76) hide show
  1. package/README.md +2 -3
  2. package/bin/audit-cli.cjs +663 -0
  3. package/bin/audit-cli.cjs.map +1 -0
  4. package/bin/audit-cli.d.cts +1 -0
  5. package/bin/audit-cli.d.ts +1 -0
  6. package/bin/audit-cli.js +566 -0
  7. package/bin/audit-cli.js.map +1 -0
  8. package/bin/audit-cli.ts +80 -0
  9. package/dist/Types.d-p85gN5m_.d.cts +22 -0
  10. package/dist/Types.d-p85gN5m_.d.ts +22 -0
  11. package/dist/chunk-4366LRNM.js +38 -0
  12. package/dist/chunk-4366LRNM.js.map +1 -0
  13. package/dist/chunk-5HQ6LLC5.js +21 -0
  14. package/dist/chunk-5HQ6LLC5.js.map +1 -0
  15. package/dist/chunk-FBQ5LF2T.js +21 -0
  16. package/dist/chunk-FBQ5LF2T.js.map +1 -0
  17. package/dist/chunk-KVTLMA4J.js +58 -0
  18. package/dist/chunk-KVTLMA4J.js.map +1 -0
  19. package/dist/chunk-MEA5U2G4.js +24 -0
  20. package/dist/chunk-MEA5U2G4.js.map +1 -0
  21. package/dist/chunk-RK3JUAFZ.js +18 -0
  22. package/dist/chunk-RK3JUAFZ.js.map +1 -0
  23. package/dist/chunk-RT5IROW4.js +99 -0
  24. package/dist/chunk-RT5IROW4.js.map +1 -0
  25. package/dist/index.cjs +6 -55
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +7 -115
  28. package/dist/index.d.ts +7 -115
  29. package/dist/index.js +7 -313
  30. package/dist/index.js.map +1 -1
  31. package/dist/src/accordion/index.cjs +25 -0
  32. package/dist/src/accordion/index.cjs.map +1 -0
  33. package/dist/src/accordion/index.d.cts +13 -0
  34. package/dist/src/accordion/index.d.ts +13 -0
  35. package/dist/src/accordion/index.js +2 -0
  36. package/dist/src/accordion/index.js.map +1 -0
  37. package/dist/src/block/index.cjs +121 -0
  38. package/dist/src/block/index.cjs.map +1 -0
  39. package/dist/src/block/index.d.cts +8 -0
  40. package/dist/src/block/index.d.ts +8 -0
  41. package/dist/src/block/index.js +3 -0
  42. package/dist/src/block/index.js.map +1 -0
  43. package/dist/src/checkbox/index.cjs +19 -0
  44. package/dist/src/checkbox/index.cjs.map +1 -0
  45. package/dist/src/checkbox/index.d.cts +13 -0
  46. package/dist/src/checkbox/index.d.ts +13 -0
  47. package/dist/src/checkbox/index.js +2 -0
  48. package/dist/src/checkbox/index.js.map +1 -0
  49. package/dist/src/menu/index.cjs +155 -0
  50. package/dist/src/menu/index.cjs.map +1 -0
  51. package/dist/src/menu/index.d.cts +17 -0
  52. package/dist/src/menu/index.d.ts +17 -0
  53. package/dist/src/menu/index.js +3 -0
  54. package/dist/src/menu/index.js.map +1 -0
  55. package/dist/src/radio/index.cjs +22 -0
  56. package/dist/src/radio/index.cjs.map +1 -0
  57. package/dist/src/radio/index.d.cts +13 -0
  58. package/dist/src/radio/index.d.ts +13 -0
  59. package/dist/src/radio/index.js +2 -0
  60. package/dist/src/radio/index.js.map +1 -0
  61. package/dist/src/toggle/index.cjs +22 -0
  62. package/dist/src/toggle/index.cjs.map +1 -0
  63. package/dist/src/toggle/index.d.cts +13 -0
  64. package/dist/src/toggle/index.d.ts +13 -0
  65. package/dist/src/toggle/index.js +2 -0
  66. package/dist/src/toggle/index.js.map +1 -0
  67. package/dist/src/utils/audit/audit.cjs +208 -0
  68. package/dist/src/utils/audit/audit.cjs.map +1 -0
  69. package/dist/src/utils/audit/audit.d.cts +5 -0
  70. package/dist/src/utils/audit/audit.d.ts +5 -0
  71. package/dist/src/utils/audit/audit.js +201 -0
  72. package/dist/src/utils/audit/audit.js.map +1 -0
  73. package/package.json +46 -4
  74. package/dist/index.d.mts +0 -140
  75. package/dist/index.mjs +0 -110
  76. package/dist/index.mjs.map +0 -1
package/README.md CHANGED
@@ -19,7 +19,7 @@ Add accessibility to menu: menu can be a dropdown, combo box, slide navigation m
19
19
  #### Usage
20
20
 
21
21
  ```javascript
22
- import { Menu } from "aria-ease";
22
+ import * as Menu from "aria-ease/menu";
23
23
 
24
24
  useEffect(() => {
25
25
  menuRef.current = Menu.makeMenuAccessible({
@@ -29,8 +29,7 @@ useEffect(() => {
29
29
  });
30
30
  }, []);
31
31
 
32
- const toggleMenuDisplay = (event) => {
33
- event.preventDefault();
32
+ const toggleMenuDisplay = () => {
34
33
  const menuDiv = document.querySelector("#menu-div");
35
34
  if (getComputedStyle(menuDiv).display === "none") {
36
35
  menuRef.current.openMenu();
@@ -0,0 +1,663 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ function _array_like_to_array(arr, len) {
4
+ if (len == null || len > arr.length) len = arr.length;
5
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
6
+ return arr2;
7
+ }
8
+ function _array_without_holes(arr) {
9
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
10
+ }
11
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
12
+ try {
13
+ var info = gen[key](arg);
14
+ var value = info.value;
15
+ } catch (error) {
16
+ reject(error);
17
+ return;
18
+ }
19
+ if (info.done) {
20
+ resolve(value);
21
+ } else {
22
+ Promise.resolve(value).then(_next, _throw);
23
+ }
24
+ }
25
+ function _async_to_generator(fn) {
26
+ return function() {
27
+ var self = this, args = arguments;
28
+ return new Promise(function(resolve, reject) {
29
+ var gen = fn.apply(self, args);
30
+ function _next(value) {
31
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
32
+ }
33
+ function _throw(err) {
34
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
35
+ }
36
+ _next(undefined);
37
+ });
38
+ };
39
+ }
40
+ function _getRequireWildcardCache(nodeInterop) {
41
+ if (typeof WeakMap !== "function") return null;
42
+ var cacheBabelInterop = new WeakMap();
43
+ var cacheNodeInterop = new WeakMap();
44
+ return (_getRequireWildcardCache = function(nodeInterop) {
45
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
46
+ })(nodeInterop);
47
+ }
48
+ function _interop_require_wildcard(obj, nodeInterop) {
49
+ if (!nodeInterop && obj && obj.__esModule) {
50
+ return obj;
51
+ }
52
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
53
+ return {
54
+ default: obj
55
+ };
56
+ }
57
+ var cache = _getRequireWildcardCache(nodeInterop);
58
+ if (cache && cache.has(obj)) {
59
+ return cache.get(obj);
60
+ }
61
+ var newObj = {
62
+ __proto__: null
63
+ };
64
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
65
+ for(var key in obj){
66
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
67
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
68
+ if (desc && (desc.get || desc.set)) {
69
+ Object.defineProperty(newObj, key, desc);
70
+ } else {
71
+ newObj[key] = obj[key];
72
+ }
73
+ }
74
+ }
75
+ newObj.default = obj;
76
+ if (cache) {
77
+ cache.set(obj, newObj);
78
+ }
79
+ return newObj;
80
+ }
81
+ function _iterable_to_array(iter) {
82
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
83
+ }
84
+ function _non_iterable_spread() {
85
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
86
+ }
87
+ function _to_consumable_array(arr) {
88
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
89
+ }
90
+ function _type_of(obj) {
91
+ "@swc/helpers - typeof";
92
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
93
+ }
94
+ function _unsupported_iterable_to_array(o, minLen) {
95
+ if (!o) return;
96
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
97
+ var n = Object.prototype.toString.call(o).slice(8, -1);
98
+ if (n === "Object" && o.constructor) n = o.constructor.name;
99
+ if (n === "Map" || n === "Set") return Array.from(n);
100
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
101
+ }
102
+ function _ts_generator(thisArg, body) {
103
+ var f, y, t, _ = {
104
+ label: 0,
105
+ sent: function() {
106
+ if (t[0] & 1) throw t[1];
107
+ return t[1];
108
+ },
109
+ trys: [],
110
+ ops: []
111
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
112
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
113
+ return this;
114
+ }), g;
115
+ function verb(n) {
116
+ return function(v) {
117
+ return step([
118
+ n,
119
+ v
120
+ ]);
121
+ };
122
+ }
123
+ function step(op) {
124
+ if (f) throw new TypeError("Generator is already executing.");
125
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
126
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
127
+ if (y = 0, t) op = [
128
+ op[0] & 2,
129
+ t.value
130
+ ];
131
+ switch(op[0]){
132
+ case 0:
133
+ case 1:
134
+ t = op;
135
+ break;
136
+ case 4:
137
+ _.label++;
138
+ return {
139
+ value: op[1],
140
+ done: false
141
+ };
142
+ case 5:
143
+ _.label++;
144
+ y = op[1];
145
+ op = [
146
+ 0
147
+ ];
148
+ continue;
149
+ case 7:
150
+ op = _.ops.pop();
151
+ _.trys.pop();
152
+ continue;
153
+ default:
154
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
155
+ _ = 0;
156
+ continue;
157
+ }
158
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
159
+ _.label = op[1];
160
+ break;
161
+ }
162
+ if (op[0] === 6 && _.label < t[1]) {
163
+ _.label = t[1];
164
+ t = op;
165
+ break;
166
+ }
167
+ if (t && _.label < t[2]) {
168
+ _.label = t[2];
169
+ _.ops.push(op);
170
+ break;
171
+ }
172
+ if (t[2]) _.ops.pop();
173
+ _.trys.pop();
174
+ continue;
175
+ }
176
+ op = body.call(thisArg, _);
177
+ } catch (e) {
178
+ op = [
179
+ 6,
180
+ e
181
+ ];
182
+ y = 0;
183
+ } finally{
184
+ f = t = 0;
185
+ }
186
+ if (op[0] & 5) throw op[1];
187
+ return {
188
+ value: op[0] ? op[1] : void 0,
189
+ done: true
190
+ };
191
+ }
192
+ }
193
+ var __create = Object.create;
194
+ var __defProp = Object.defineProperty;
195
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
196
+ var __getOwnPropNames = Object.getOwnPropertyNames;
197
+ var __getProtoOf = Object.getPrototypeOf;
198
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
199
+ var __copyProps = function(to, from, except, desc) {
200
+ if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
201
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
202
+ try {
203
+ var _loop = function() {
204
+ var key = _step.value;
205
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
206
+ get: function() {
207
+ return from[key];
208
+ },
209
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
210
+ });
211
+ };
212
+ for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
213
+ } catch (err) {
214
+ _didIteratorError = true;
215
+ _iteratorError = err;
216
+ } finally{
217
+ try {
218
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
219
+ _iterator.return();
220
+ }
221
+ } finally{
222
+ if (_didIteratorError) {
223
+ throw _iteratorError;
224
+ }
225
+ }
226
+ }
227
+ }
228
+ return to;
229
+ };
230
+ var __toESM = function(mod, isNodeMode, target) {
231
+ return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
232
+ // file that has been converted to a CommonJS file using a Babel-
233
+ // compatible transform (i.e. "__esModule" has not been set), then set
234
+ // "default" to the CommonJS "module.exports" for node compatibility.
235
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
236
+ value: mod,
237
+ enumerable: true
238
+ }) : target, mod);
239
+ };
240
+ // bin/audit-cli.ts
241
+ var import_commander = require("commander");
242
+ var import_chalk = __toESM(require("chalk"), 1);
243
+ var import_path = __toESM(require("path"), 1);
244
+ var import_fs_extra = __toESM(require("fs-extra"), 1);
245
+ // dist/src/utils/audit/audit.js
246
+ var import_playwright = __toESM(require("@axe-core/playwright"), 1);
247
+ var import_playwright2 = require("playwright");
248
+ function asyncGeneratorStep1(gen, resolve, reject, _next, _throw, key, arg) {
249
+ try {
250
+ var info = gen[key](arg);
251
+ var value = info.value;
252
+ } catch (error) {
253
+ reject(error);
254
+ return;
255
+ }
256
+ if (info.done) {
257
+ resolve(value);
258
+ } else {
259
+ Promise.resolve(value).then(_next, _throw);
260
+ }
261
+ }
262
+ function _async_to_generator1(fn) {
263
+ return function() {
264
+ var self = this, args = arguments;
265
+ return new Promise(function(resolve, reject) {
266
+ var gen = fn.apply(self, args);
267
+ function _next(value) {
268
+ asyncGeneratorStep1(gen, resolve, reject, _next, _throw, "next", value);
269
+ }
270
+ function _throw(err) {
271
+ asyncGeneratorStep1(gen, resolve, reject, _next, _throw, "throw", err);
272
+ }
273
+ _next(void 0);
274
+ });
275
+ };
276
+ }
277
+ function _ts_generator1(thisArg, body) {
278
+ var f, y, t, _ = {
279
+ label: 0,
280
+ sent: function sent() {
281
+ if (t[0] & 1) throw t[1];
282
+ return t[1];
283
+ },
284
+ trys: [],
285
+ ops: []
286
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
287
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
288
+ return this;
289
+ }), g;
290
+ function verb(n) {
291
+ return function(v) {
292
+ return step([
293
+ n,
294
+ v
295
+ ]);
296
+ };
297
+ }
298
+ function step(op) {
299
+ if (f) throw new TypeError("Generator is already executing.");
300
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
301
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
302
+ if (y = 0, t) op = [
303
+ op[0] & 2,
304
+ t.value
305
+ ];
306
+ switch(op[0]){
307
+ case 0:
308
+ case 1:
309
+ t = op;
310
+ break;
311
+ case 4:
312
+ _.label++;
313
+ return {
314
+ value: op[1],
315
+ done: false
316
+ };
317
+ case 5:
318
+ _.label++;
319
+ y = op[1];
320
+ op = [
321
+ 0
322
+ ];
323
+ continue;
324
+ case 7:
325
+ op = _.ops.pop();
326
+ _.trys.pop();
327
+ continue;
328
+ default:
329
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
330
+ _ = 0;
331
+ continue;
332
+ }
333
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
334
+ _.label = op[1];
335
+ break;
336
+ }
337
+ if (op[0] === 6 && _.label < t[1]) {
338
+ _.label = t[1];
339
+ t = op;
340
+ break;
341
+ }
342
+ if (t && _.label < t[2]) {
343
+ _.label = t[2];
344
+ _.ops.push(op);
345
+ break;
346
+ }
347
+ if (t[2]) _.ops.pop();
348
+ _.trys.pop();
349
+ continue;
350
+ }
351
+ op = body.call(thisArg, _);
352
+ } catch (e) {
353
+ op = [
354
+ 6,
355
+ e
356
+ ];
357
+ y = 0;
358
+ } finally{
359
+ f = t = 0;
360
+ }
361
+ if (op[0] & 5) throw op[1];
362
+ return {
363
+ value: op[0] ? op[1] : void 0,
364
+ done: true
365
+ };
366
+ }
367
+ }
368
+ function runAudit(url) {
369
+ return _async_to_generator1(function() {
370
+ var browser, context, page, axe, axeResults, error;
371
+ return _ts_generator1(this, function(_state) {
372
+ switch(_state.label){
373
+ case 0:
374
+ return [
375
+ 4,
376
+ import_playwright2.chromium.launch({
377
+ headless: true
378
+ })
379
+ ];
380
+ case 1:
381
+ browser = _state.sent();
382
+ return [
383
+ 4,
384
+ browser.newContext()
385
+ ];
386
+ case 2:
387
+ context = _state.sent();
388
+ return [
389
+ 4,
390
+ context.newPage()
391
+ ];
392
+ case 3:
393
+ page = _state.sent();
394
+ return [
395
+ 4,
396
+ page.goto(url, {
397
+ waitUntil: "networkidle"
398
+ })
399
+ ];
400
+ case 4:
401
+ _state.sent();
402
+ _state.label = 5;
403
+ case 5:
404
+ _state.trys.push([
405
+ 5,
406
+ 7,
407
+ ,
408
+ 8
409
+ ]);
410
+ axe = new import_playwright.default({
411
+ page: page
412
+ });
413
+ return [
414
+ 4,
415
+ axe.analyze()
416
+ ];
417
+ case 6:
418
+ axeResults = _state.sent();
419
+ return [
420
+ 2,
421
+ axeResults
422
+ ];
423
+ case 7:
424
+ error = _state.sent();
425
+ console.log(error);
426
+ return [
427
+ 3,
428
+ 8
429
+ ];
430
+ case 8:
431
+ return [
432
+ 4,
433
+ browser.close()
434
+ ];
435
+ case 9:
436
+ _state.sent();
437
+ return [
438
+ 2
439
+ ];
440
+ }
441
+ });
442
+ })();
443
+ }
444
+ // src/utils/audit/formatters.ts
445
+ function formatResults(allResults, format) {
446
+ switch(format){
447
+ case "json":
448
+ return JSON.stringify(allResults.flatMap(function(param) {
449
+ var url = param.url, result = param.result;
450
+ return result ? result.violations.flatMap(function(v) {
451
+ return v.nodes.map(function(n) {
452
+ return {
453
+ URL: url,
454
+ Rule: v.id,
455
+ Impact: v.impact,
456
+ Description: v.description,
457
+ Target: n.target,
458
+ FailureSummary: n.failureSummary
459
+ };
460
+ });
461
+ }) : [];
462
+ }), null, 2);
463
+ case "csv":
464
+ return toCSV(allResults);
465
+ default:
466
+ return "";
467
+ }
468
+ }
469
+ function toCSV(allResults) {
470
+ var rows = [
471
+ "URL,Rule,Impact,Description,Target,FailureSummary"
472
+ ];
473
+ allResults.forEach(function(param) {
474
+ var url = param.url, result = param.result;
475
+ if (result) {
476
+ result.violations.forEach(function(v) {
477
+ v.nodes.forEach(function(n) {
478
+ rows.push('"'.concat(url, '","').concat(v.id, '","').concat(v.impact, '","').concat(v.description, '","').concat(n.target, '","').concat(n.failureSummary, '"'));
479
+ });
480
+ });
481
+ }
482
+ });
483
+ return rows.join("\n");
484
+ }
485
+ // bin/audit-cli.ts
486
+ var program = new import_commander.Command();
487
+ program.name("aria-ease").description("Run accessibility audits").version("2.0.4");
488
+ program.command("audit").description("Run accessibility audit").option("-u, --url <url>", "Single URL to audit").option("-f, --format <format>", "Output format for the audit report: json | csv", "csv").option("-o, --out <path>", "Directory to save the audit report", "./accessibility-reports").action(function(opts) {
489
+ return _async_to_generator(function() {
490
+ var _urls, configPath, config, _tmp, urls, allResults, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, url, result, err1, err, hasResults, formatted, timestamp, fileName, filePath;
491
+ return _ts_generator(this, function(_state) {
492
+ switch(_state.label){
493
+ case 0:
494
+ console.log(import_chalk.default.cyanBright("\uD83D\uDE80 Starting accessibility audit...\n"));
495
+ configPath = import_path.default.resolve(process.cwd(), "ariaease.config.js");
496
+ config = {};
497
+ return [
498
+ 4,
499
+ import_fs_extra.default.pathExists(configPath)
500
+ ];
501
+ case 1:
502
+ if (!_state.sent()) return [
503
+ 3,
504
+ 5
505
+ ];
506
+ return [
507
+ 4,
508
+ Promise.resolve(configPath).then(function(p) {
509
+ return /*#__PURE__*/ _interop_require_wildcard(require(p));
510
+ })
511
+ ];
512
+ case 2:
513
+ _tmp = _state.sent().default;
514
+ if (_tmp) return [
515
+ 3,
516
+ 4
517
+ ];
518
+ return [
519
+ 4,
520
+ Promise.resolve(configPath).then(function(p) {
521
+ return /*#__PURE__*/ _interop_require_wildcard(require(p));
522
+ })
523
+ ];
524
+ case 3:
525
+ _tmp = _state.sent();
526
+ _state.label = 4;
527
+ case 4:
528
+ config = _tmp;
529
+ console.log(import_chalk.default.green("\u2705 Loaded config from ariaease.config.js\n"));
530
+ return [
531
+ 3,
532
+ 6
533
+ ];
534
+ case 5:
535
+ console.log(import_chalk.default.yellow("\u2139\uFE0F No ariaease.config.js found at project root, using default configurations."));
536
+ _state.label = 6;
537
+ case 6:
538
+ urls = [];
539
+ if (opts.url) urls.push(opts.url);
540
+ if (config.urls && Array.isArray(config.urls)) (_urls = urls).push.apply(_urls, _to_consumable_array(config.urls));
541
+ if (urls.length === 0) {
542
+ console.log(import_chalk.default.red('\u274C No URLs provided. Use --url option or add "urls" in ariaease.config.js'));
543
+ process.exit(1);
544
+ }
545
+ allResults = [];
546
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
547
+ _state.label = 7;
548
+ case 7:
549
+ _state.trys.push([
550
+ 7,
551
+ 14,
552
+ 15,
553
+ 16
554
+ ]);
555
+ _iterator = urls[Symbol.iterator]();
556
+ _state.label = 8;
557
+ case 8:
558
+ if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
559
+ 3,
560
+ 13
561
+ ];
562
+ url = _step.value;
563
+ console.log(import_chalk.default.yellow("\uD83D\uDD0E Auditing: ".concat(url)));
564
+ _state.label = 9;
565
+ case 9:
566
+ _state.trys.push([
567
+ 9,
568
+ 11,
569
+ ,
570
+ 12
571
+ ]);
572
+ return [
573
+ 4,
574
+ runAudit(url)
575
+ ];
576
+ case 10:
577
+ result = _state.sent();
578
+ allResults.push({
579
+ url: url,
580
+ result: result
581
+ });
582
+ console.log(import_chalk.default.green("✅ Completed audit for ".concat(url, "\n")));
583
+ return [
584
+ 3,
585
+ 12
586
+ ];
587
+ case 11:
588
+ err1 = _state.sent();
589
+ console.log(import_chalk.default.red("❌ Failed auditing ".concat(url, ": ").concat(err1.message)));
590
+ return [
591
+ 3,
592
+ 12
593
+ ];
594
+ case 12:
595
+ _iteratorNormalCompletion = true;
596
+ return [
597
+ 3,
598
+ 8
599
+ ];
600
+ case 13:
601
+ return [
602
+ 3,
603
+ 16
604
+ ];
605
+ case 14:
606
+ err = _state.sent();
607
+ _didIteratorError = true;
608
+ _iteratorError = err;
609
+ return [
610
+ 3,
611
+ 16
612
+ ];
613
+ case 15:
614
+ try {
615
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
616
+ _iterator.return();
617
+ }
618
+ } finally{
619
+ if (_didIteratorError) {
620
+ throw _iteratorError;
621
+ }
622
+ }
623
+ return [
624
+ 7
625
+ ];
626
+ case 16:
627
+ hasResults = allResults.some(function(r) {
628
+ return r.result && r.result.violations && r.result.violations.length > 0;
629
+ });
630
+ if (!hasResults) {
631
+ console.log(import_chalk.default.red("\u274C No audit report generated"));
632
+ process.exit(1);
633
+ }
634
+ formatted = formatResults(allResults, opts.format);
635
+ return [
636
+ 4,
637
+ import_fs_extra.default.ensureDir(opts.out)
638
+ ];
639
+ case 17:
640
+ _state.sent();
641
+ timestamp = /* @__PURE__ */ new Date().toISOString().replace(/[:.]/g, "-");
642
+ fileName = "ariaease-report-".concat(timestamp, ".").concat(opts.format);
643
+ filePath = import_path.default.join(opts.out, fileName);
644
+ return [
645
+ 4,
646
+ import_fs_extra.default.writeFile(filePath, formatted, "utf-8")
647
+ ];
648
+ case 18:
649
+ _state.sent();
650
+ console.log(import_chalk.default.magentaBright("\uD83D\uDCC1 Report saved to ".concat(filePath)));
651
+ console.log(import_chalk.default.green("\n\uD83C\uDF89 All audits completed."));
652
+ return [
653
+ 2
654
+ ];
655
+ }
656
+ });
657
+ })();
658
+ });
659
+ program.command("help").description("Display help information").action(function() {
660
+ program.outputHelp();
661
+ });
662
+ program.parse(process.argv);
663
+ //# sourceMappingURL=audit-cli.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/macx/aria-ease/package/bin/audit-cli.cjs"],"names":[],"mappings":";AACA","sourcesContent":["#!/usr/bin/env node\n\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\n\n// dist/src/utils/audit/audit.js\nvar import_playwright = __toESM(require(\"@axe-core/playwright\"), 1);\nvar import_playwright2 = require(\"playwright\");\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {\n try {\n var info = gen[key](arg);\n var value = info.value;\n } catch (error) {\n reject(error);\n return;\n }\n if (info.done) {\n resolve(value);\n } else {\n Promise.resolve(value).then(_next, _throw);\n }\n}\nfunction _async_to_generator(fn) {\n return function() {\n var self = this, args2 = arguments;\n return new Promise(function(resolve, reject) {\n var gen = fn.apply(self, args2);\n function _next(value) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value);\n }\n function _throw(err) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err);\n }\n _next(void 0);\n });\n };\n}\nfunction _ts_generator(thisArg, body) {\n var f, y, t, _ = {\n label: 0,\n sent: function() {\n if (t[0] & 1) throw t[1];\n return t[1];\n },\n trys: [],\n ops: []\n }, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() {\n return this;\n }), g;\n function verb(n) {\n return function(v) {\n return step([\n n,\n v\n ]);\n };\n }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [\n op[0] & 2,\n t.value\n ];\n switch (op[0]) {\n case 0:\n case 1:\n t = op;\n break;\n case 4:\n _.label++;\n return {\n value: op[1],\n done: false\n };\n case 5:\n _.label++;\n y = op[1];\n op = [\n 0\n ];\n continue;\n case 7:\n op = _.ops.pop();\n _.trys.pop();\n continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {\n _ = 0;\n continue;\n }\n if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {\n _.label = op[1];\n break;\n }\n if (op[0] === 6 && _.label < t[1]) {\n _.label = t[1];\n t = op;\n break;\n }\n if (t && _.label < t[2]) {\n _.label = t[2];\n _.ops.push(op);\n break;\n }\n if (t[2]) _.ops.pop();\n _.trys.pop();\n continue;\n }\n op = body.call(thisArg, _);\n } catch (e) {\n op = [\n 6,\n e\n ];\n y = 0;\n } finally {\n f = t = 0;\n }\n if (op[0] & 5) throw op[1];\n return {\n value: op[0] ? op[1] : void 0,\n done: true\n };\n }\n}\nfunction runAudit() {\n return _async_to_generator(function() {\n var browser, context, page, axe, axeResults, snapshot, error;\n return _ts_generator(this, function(_state) {\n switch (_state.label) {\n case 0:\n return [\n 4,\n import_playwright2.chromium.launch({\n headless: true\n })\n ];\n case 1:\n browser = _state.sent();\n return [\n 4,\n browser.newContext()\n ];\n case 2:\n context = _state.sent();\n return [\n 4,\n context.newPage()\n ];\n case 3:\n page = _state.sent();\n return [\n 4,\n page.goto(\"http://localhost:5173/\")\n ];\n case 4:\n _state.sent();\n _state.label = 5;\n case 5:\n _state.trys.push([\n 5,\n 8,\n ,\n 9\n ]);\n axe = new import_playwright.default({\n page\n });\n return [\n 4,\n axe.analyze()\n ];\n case 6:\n axeResults = _state.sent();\n console.log(\"--- AXE-CORE RESULTS ---\");\n console.log(axeResults);\n return [\n 4,\n page.accessibility.snapshot()\n ];\n case 7:\n snapshot = _state.sent();\n console.log(\"\\n--- PLAYWRIGHT SNAPSHOT ---\");\n console.log(snapshot);\n return [\n 3,\n 9\n ];\n case 8:\n error = _state.sent();\n console.log(error);\n return [\n 3,\n 9\n ];\n case 9:\n return [\n 4,\n browser.close()\n ];\n case 10:\n _state.sent();\n return [\n 2\n ];\n }\n });\n })();\n}\n\n// bin/audit-cli.ts\nvar args = process.argv.slice(2);\nif (args[0] === \"audit\") {\n (async () => {\n await runAudit();\n })();\n} else {\n console.log(\"Usage: npx aria-ease audit\");\n}\n"]}