@diegovelasquezweb/a11y-engine 0.2.0 → 0.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diegovelasquezweb/a11y-engine",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "WCAG 2.2 AA accessibility audit engine — scanner, analyzer, and report builders",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -6,9 +6,34 @@
6
6
  import fs from "node:fs";
7
7
  import path from "node:path";
8
8
  import { fileURLToPath } from "node:url";
9
+ import { createRequire } from "node:module";
9
10
 
10
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
11
- const ASSET_ROOT = path.join(__dirname, "..", "..", "assets");
11
+ /**
12
+ * Resolves the assets root directory. Uses import.meta.url when running from
13
+ * the original file location (CLI, direct node). Falls back to require.resolve
14
+ * when running inside a bundler (e.g. Turbopack) where import.meta.url points
15
+ * to a generated chunk instead of the original file.
16
+ */
17
+ function resolveAssetRoot() {
18
+ // Primary: resolve relative to this file's location
19
+ const selfDir = path.dirname(fileURLToPath(import.meta.url));
20
+ const candidate = path.join(selfDir, "..", "..", "assets");
21
+ if (fs.existsSync(candidate)) return candidate;
22
+
23
+ // Fallback: resolve via require.resolve against node_modules
24
+ try {
25
+ const req = createRequire(import.meta.url);
26
+ const pkgJson = req.resolve("@diegovelasquezweb/a11y-engine/package.json");
27
+ const pkgRoot = path.dirname(pkgJson);
28
+ const fallback = path.join(pkgRoot, "assets");
29
+ if (fs.existsSync(fallback)) return fallback;
30
+ } catch { /* not installed as dependency — skip */ }
31
+
32
+ // Last resort: original candidate (will fail with a clear error at load time)
33
+ return candidate;
34
+ }
35
+
36
+ const ASSET_ROOT = resolveAssetRoot();
12
37
 
13
38
  export const ASSET_PATHS = {
14
39
  discovery: {
@@ -214,6 +214,7 @@ export interface RunAuditOptions {
214
214
  framework?: string;
215
215
  projectDir?: string;
216
216
  skipPatterns?: boolean;
217
+ screenshotsDir?: string;
217
218
  onProgress?: (step: string, status: string, extra?: Record<string, unknown>) => void;
218
219
  }
219
220
 
package/scripts/index.mjs CHANGED
@@ -480,6 +480,7 @@ export async function runAudit(options) {
480
480
  axeTags: options.axeTags,
481
481
  onlyRule: options.onlyRule,
482
482
  excludeSelectors: options.excludeSelectors,
483
+ screenshotsDir: options.screenshotsDir,
483
484
  },
484
485
  { onProgress },
485
486
  );