@diegovelasquezweb/a11y-engine 0.2.1 → 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.1",
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: {