visual-ai-assertions 0.10.0 → 0.11.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.
- package/README.md +2 -2
- package/dist/index.cjs +11 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/package.json +12 -36
package/README.md
CHANGED
|
@@ -253,10 +253,10 @@ await ai.elementsVisible(screenshot, ["Submit button", "Nav bar", "Footer"]);
|
|
|
253
253
|
// Check that UI elements are hidden
|
|
254
254
|
await ai.elementsHidden(screenshot, ["Loading spinner", "Error modal"]);
|
|
255
255
|
|
|
256
|
-
// Accessibility checks (contrast, readability, interactive visibility)
|
|
256
|
+
// Accessibility checks (contrast, readability, interactive visibility, color blindness, color-alone meaning)
|
|
257
257
|
await ai.accessibility(screenshot);
|
|
258
258
|
await ai.accessibility(screenshot, {
|
|
259
|
-
checks: [Accessibility.CONTRAST, Accessibility.
|
|
259
|
+
checks: [Accessibility.CONTRAST, Accessibility.COLOR_BLINDNESS, Accessibility.COLOR_ALONE],
|
|
260
260
|
});
|
|
261
261
|
|
|
262
262
|
// Layout checks (overlap, overflow, alignment)
|
package/dist/index.cjs
CHANGED
|
@@ -142,7 +142,11 @@ var Accessibility = {
|
|
|
142
142
|
/** Detects text that is cut off, overlapping, too small, or obscured */
|
|
143
143
|
READABILITY: "readability",
|
|
144
144
|
/** Detects interactive elements that are not visually distinct */
|
|
145
|
-
INTERACTIVE_VISIBILITY: "interactive-visibility"
|
|
145
|
+
INTERACTIVE_VISIBILITY: "interactive-visibility",
|
|
146
|
+
/** Detects color choices likely to be indistinguishable to viewers with common color vision deficiencies */
|
|
147
|
+
COLOR_BLINDNESS: "color-blindness",
|
|
148
|
+
/** Detects information conveyed by color alone, without a non-color cue (icon, text, pattern, position) */
|
|
149
|
+
COLOR_ALONE: "color-alone"
|
|
146
150
|
};
|
|
147
151
|
|
|
148
152
|
// src/errors.ts
|
|
@@ -467,12 +471,16 @@ var ALL_CHECKS = Object.values(Accessibility);
|
|
|
467
471
|
var ACCESSIBILITY_ROLE = "Evaluate this screenshot for visual accessibility. Focus on what you can actually perceive \u2014 apparent contrast levels, text legibility, and visual distinctiveness of interactive elements.";
|
|
468
472
|
var ACCESSIBILITY_EDGE_RULES = [
|
|
469
473
|
"Do not state specific contrast ratios. Describe contrast as 'appears sufficient' or 'appears low'.",
|
|
470
|
-
"Dark mode and light mode themes are both valid. Do not flag a valid dark theme as a contrast issue."
|
|
474
|
+
"Dark mode and light mode themes are both valid. Do not flag a valid dark theme as a contrast issue.",
|
|
475
|
+
"Purely decorative color (branding, backgrounds, gradients) is not a color-blindness or color-alone issue \u2014 only flag color usage that carries meaning a user must perceive to use the interface.",
|
|
476
|
+
"Only evaluate color cues that are visible in the screenshot. Do not assume hover/focus state colors exist if they are not shown."
|
|
471
477
|
];
|
|
472
478
|
var CHECK_STATEMENTS = {
|
|
473
479
|
[Accessibility.CONTRAST]: "All text and interactive elements appear to have sufficient color contrast \u2014 text is clearly readable against its background",
|
|
474
480
|
[Accessibility.READABILITY]: "All text is readable \u2014 no text is cut off, overlapping, too small to read, or obscured by background images",
|
|
475
|
-
[Accessibility.INTERACTIVE_VISIBILITY]: "All interactive elements (buttons, links, inputs) are clearly identifiable and visually distinct from non-interactive content"
|
|
481
|
+
[Accessibility.INTERACTIVE_VISIBILITY]: "All interactive elements (buttons, links, inputs) are clearly identifiable and visually distinct from non-interactive content",
|
|
482
|
+
[Accessibility.COLOR_BLINDNESS]: "Information conveyed by color remains distinguishable to viewers with common color vision deficiencies \u2014 status indicators, chart series, and other meaningful color pairings do not rely on hue combinations that are commonly confused (e.g., red/green, blue/purple)",
|
|
483
|
+
[Accessibility.COLOR_ALONE]: "Information conveyed by color is also conveyed through at least one non-color cue \u2014 text labels, icons, shapes, patterns, underlines, or position accompany any color-based meaning (e.g., required fields, error states, chart legends, link styling)"
|
|
476
484
|
};
|
|
477
485
|
function buildAccessibilityPrompt(options) {
|
|
478
486
|
const checks = options?.checks ?? [...ALL_CHECKS];
|