@a11y-oracle/axe-bridge 1.0.0 → 1.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.
@@ -1 +1 @@
1
- {"version":3,"file":"axe-bridge.d.ts","sourceRoot":"","sources":["../../src/lib/axe-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,KAAK,EACV,UAAU,EAEV,yBAAyB,EAC1B,MAAM,YAAY,CAAC;AA2CpB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,yBAAyB,CAC7C,GAAG,EAAE,cAAc,EACnB,UAAU,EAAE,UAAU,EACtB,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,UAAU,CAAC,CA8DrB"}
1
+ {"version":3,"file":"axe-bridge.d.ts","sourceRoot":"","sources":["../../src/lib/axe-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG7D,OAAO,KAAK,EACV,UAAU,EAEV,yBAAyB,EAC1B,MAAM,YAAY,CAAC;AA2CpB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,yBAAyB,CAC7C,GAAG,EAAE,cAAc,EACnB,UAAU,EAAE,UAAU,EACtB,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,UAAU,CAAC,CAgErB"}
@@ -87,9 +87,11 @@ export async function resolveIncompleteContrast(cdp, axeResults, options) {
87
87
  const result = await analyzer.analyzeElement(selector, effectiveThreshold);
88
88
  switch (result.category) {
89
89
  case 'pass':
90
+ enrichNodeWithContrastData(node, result);
90
91
  passNodes.push(node);
91
92
  break;
92
93
  case 'violation':
94
+ enrichNodeWithContrastData(node, result);
93
95
  violationNodes.push(node);
94
96
  break;
95
97
  case 'incomplete':
@@ -104,3 +106,31 @@ export async function resolveIncompleteContrast(cdp, axeResults, options) {
104
106
  });
105
107
  return clone;
106
108
  }
109
+ /**
110
+ * Enrich an axe node's check data with measured contrast information
111
+ * from the visual analysis pipeline.
112
+ *
113
+ * Attaches the best-case measured contrast ratio, foreground color,
114
+ * and analysis reason to `node.any[0].data` and `node.any[0].message`.
115
+ * For violations, the best-case ratio is the highest contrast achieved
116
+ * (still below threshold). For passes, it's the worst-case ratio
117
+ * (still above threshold).
118
+ */
119
+ function enrichNodeWithContrastData(node, result) {
120
+ if (!node.any[0])
121
+ return;
122
+ const data = (node.any[0].data ?? {});
123
+ if (result.pixels) {
124
+ // For violations: best-case (max) is the highest contrast still failing.
125
+ // For passes: worst-case (min) is the lowest contrast still passing.
126
+ data.contrastRatio =
127
+ result.category === 'violation'
128
+ ? Math.max(result.pixels.crAgainstLightest, result.pixels.crAgainstDarkest)
129
+ : Math.min(result.pixels.crAgainstLightest, result.pixels.crAgainstDarkest);
130
+ }
131
+ if (result.textColor) {
132
+ data.fgColor = `rgb(${result.textColor.r}, ${result.textColor.g}, ${result.textColor.b})`;
133
+ }
134
+ node.any[0].data = data;
135
+ node.any[0].message = result.reason;
136
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a11y-oracle/axe-bridge",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Axe-core result post-processor that resolves 10 incomplete rules using visual analysis, keyboard interaction, and CDP inspection",
5
5
  "license": "MIT",
6
6
  "author": "a11y-oracle",
@@ -44,10 +44,10 @@
44
44
  "!**/*.tsbuildinfo"
45
45
  ],
46
46
  "dependencies": {
47
- "@a11y-oracle/cdp-types": "1.0.0",
48
- "@a11y-oracle/focus-analyzer": "1.0.0",
49
- "@a11y-oracle/keyboard-engine": "1.0.0",
50
- "@a11y-oracle/visual-engine": "1.0.0",
47
+ "@a11y-oracle/cdp-types": "1.1.0",
48
+ "@a11y-oracle/focus-analyzer": "1.1.0",
49
+ "@a11y-oracle/keyboard-engine": "1.1.0",
50
+ "@a11y-oracle/visual-engine": "1.1.0",
51
51
  "tslib": "^2.3.0"
52
52
  }
53
53
  }