@diegovelasquezweb/a11y-engine 0.2.2 → 0.2.3

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.2",
3
+ "version": "0.2.3",
4
4
  "description": "WCAG 2.2 AA accessibility audit engine — scanner, analyzer, and report builders",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -16,7 +16,8 @@
16
16
  ".": {
17
17
  "types": "./scripts/index.d.mts",
18
18
  "default": "./scripts/index.mjs"
19
- }
19
+ },
20
+ "./package.json": "./package.json"
20
21
  },
21
22
  "main": "scripts/index.mjs",
22
23
  "types": "scripts/index.d.mts",
@@ -10,27 +10,37 @@ import { createRequire } from "node:module";
10
10
 
11
11
  /**
12
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.
13
+ * the original file location (CLI, direct node). Falls back to multiple
14
+ * strategies when running inside a bundler (e.g. Turbopack) where
15
+ * import.meta.url points to a generated chunk.
16
16
  */
17
17
  function resolveAssetRoot() {
18
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;
19
+ try {
20
+ const selfDir = path.dirname(fileURLToPath(import.meta.url));
21
+ const candidate = path.join(selfDir, "..", "..", "assets");
22
+ if (fs.existsSync(candidate)) return candidate;
23
+ } catch { /* import.meta.url might be a virtual URL in bundlers */ }
22
24
 
23
- // Fallback: resolve via require.resolve against node_modules
25
+ // Fallback 1: require.resolve with createRequire from process.cwd()
24
26
  try {
25
- const req = createRequire(import.meta.url);
27
+ const req = createRequire(path.join(process.cwd(), "package.json"));
26
28
  const pkgJson = req.resolve("@diegovelasquezweb/a11y-engine/package.json");
27
- const pkgRoot = path.dirname(pkgJson);
28
- const fallback = path.join(pkgRoot, "assets");
29
+ const fallback = path.join(path.dirname(pkgJson), "assets");
30
+ if (fs.existsSync(fallback)) return fallback;
31
+ } catch { /* package not installed or exports block it */ }
32
+
33
+ // Fallback 2: walk node_modules directly (handles pnpm symlinks)
34
+ try {
35
+ const nmBase = path.join(process.cwd(), "node_modules", "@diegovelasquezweb", "a11y-engine");
36
+ const realBase = fs.realpathSync(nmBase);
37
+ const fallback = path.join(realBase, "assets");
29
38
  if (fs.existsSync(fallback)) return fallback;
30
- } catch { /* not installed as dependency — skip */ }
39
+ } catch { /* not in node_modules */ }
31
40
 
32
- // Last resort: original candidate (will fail with a clear error at load time)
33
- return candidate;
41
+ // Last resort: relative to this file (will fail with a clear error at load time)
42
+ const selfDir = path.dirname(fileURLToPath(import.meta.url));
43
+ return path.join(selfDir, "..", "..", "assets");
34
44
  }
35
45
 
36
46
  const ASSET_ROOT = resolveAssetRoot();