visual-ai-assertions 0.10.0 → 0.12.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 +5 -3
- package/dist/index.cjs +22 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +22 -5
- package/dist/index.js.map +1 -1
- package/package.json +12 -36
package/dist/index.d.cts
CHANGED
|
@@ -33,6 +33,7 @@ declare const Model: {
|
|
|
33
33
|
readonly GPT_5_MINI: "gpt-5-mini";
|
|
34
34
|
};
|
|
35
35
|
readonly Google: {
|
|
36
|
+
readonly GEMINI_3_5_FLASH: "gemini-3.5-flash";
|
|
36
37
|
readonly GEMINI_3_1_PRO_PREVIEW: "gemini-3.1-pro-preview";
|
|
37
38
|
readonly GEMINI_3_1_FLASH_LITE_PREVIEW: "gemini-3.1-flash-lite-preview";
|
|
38
39
|
readonly GEMINI_3_FLASH_PREVIEW: "gemini-3-flash-preview";
|
|
@@ -74,6 +75,10 @@ declare const Accessibility: {
|
|
|
74
75
|
readonly READABILITY: "readability";
|
|
75
76
|
/** Detects interactive elements that are not visually distinct */
|
|
76
77
|
readonly INTERACTIVE_VISIBILITY: "interactive-visibility";
|
|
78
|
+
/** Detects color choices likely to be indistinguishable to viewers with common color vision deficiencies */
|
|
79
|
+
readonly COLOR_BLINDNESS: "color-blindness";
|
|
80
|
+
/** Detects information conveyed by color alone, without a non-color cue (icon, text, pattern, position) */
|
|
81
|
+
readonly COLOR_ALONE: "color-alone";
|
|
77
82
|
};
|
|
78
83
|
/** Union of all built-in content check names. */
|
|
79
84
|
type ContentCheckName = (typeof Content)[keyof typeof Content];
|
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ declare const Model: {
|
|
|
33
33
|
readonly GPT_5_MINI: "gpt-5-mini";
|
|
34
34
|
};
|
|
35
35
|
readonly Google: {
|
|
36
|
+
readonly GEMINI_3_5_FLASH: "gemini-3.5-flash";
|
|
36
37
|
readonly GEMINI_3_1_PRO_PREVIEW: "gemini-3.1-pro-preview";
|
|
37
38
|
readonly GEMINI_3_1_FLASH_LITE_PREVIEW: "gemini-3.1-flash-lite-preview";
|
|
38
39
|
readonly GEMINI_3_FLASH_PREVIEW: "gemini-3-flash-preview";
|
|
@@ -74,6 +75,10 @@ declare const Accessibility: {
|
|
|
74
75
|
readonly READABILITY: "readability";
|
|
75
76
|
/** Detects interactive elements that are not visually distinct */
|
|
76
77
|
readonly INTERACTIVE_VISIBILITY: "interactive-visibility";
|
|
78
|
+
/** Detects color choices likely to be indistinguishable to viewers with common color vision deficiencies */
|
|
79
|
+
readonly COLOR_BLINDNESS: "color-blindness";
|
|
80
|
+
/** Detects information conveyed by color alone, without a non-color cue (icon, text, pattern, position) */
|
|
81
|
+
readonly COLOR_ALONE: "color-alone";
|
|
77
82
|
};
|
|
78
83
|
/** Union of all built-in content check names. */
|
|
79
84
|
type ContentCheckName = (typeof Content)[keyof typeof Content];
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,7 @@ var Model = {
|
|
|
27
27
|
GPT_5_MINI: "gpt-5-mini"
|
|
28
28
|
},
|
|
29
29
|
Google: {
|
|
30
|
+
GEMINI_3_5_FLASH: "gemini-3.5-flash",
|
|
30
31
|
GEMINI_3_1_PRO_PREVIEW: "gemini-3.1-pro-preview",
|
|
31
32
|
GEMINI_3_1_FLASH_LITE_PREVIEW: "gemini-3.1-flash-lite-preview",
|
|
32
33
|
GEMINI_3_FLASH_PREVIEW: "gemini-3-flash-preview"
|
|
@@ -74,7 +75,11 @@ var Accessibility = {
|
|
|
74
75
|
/** Detects text that is cut off, overlapping, too small, or obscured */
|
|
75
76
|
READABILITY: "readability",
|
|
76
77
|
/** Detects interactive elements that are not visually distinct */
|
|
77
|
-
INTERACTIVE_VISIBILITY: "interactive-visibility"
|
|
78
|
+
INTERACTIVE_VISIBILITY: "interactive-visibility",
|
|
79
|
+
/** Detects color choices likely to be indistinguishable to viewers with common color vision deficiencies */
|
|
80
|
+
COLOR_BLINDNESS: "color-blindness",
|
|
81
|
+
/** Detects information conveyed by color alone, without a non-color cue (icon, text, pattern, position) */
|
|
82
|
+
COLOR_ALONE: "color-alone"
|
|
78
83
|
};
|
|
79
84
|
|
|
80
85
|
// src/errors.ts
|
|
@@ -399,12 +404,16 @@ var ALL_CHECKS = Object.values(Accessibility);
|
|
|
399
404
|
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.";
|
|
400
405
|
var ACCESSIBILITY_EDGE_RULES = [
|
|
401
406
|
"Do not state specific contrast ratios. Describe contrast as 'appears sufficient' or 'appears low'.",
|
|
402
|
-
"Dark mode and light mode themes are both valid. Do not flag a valid dark theme as a contrast issue."
|
|
407
|
+
"Dark mode and light mode themes are both valid. Do not flag a valid dark theme as a contrast issue.",
|
|
408
|
+
"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.",
|
|
409
|
+
"Only evaluate color cues that are visible in the screenshot. Do not assume hover/focus state colors exist if they are not shown."
|
|
403
410
|
];
|
|
404
411
|
var CHECK_STATEMENTS = {
|
|
405
412
|
[Accessibility.CONTRAST]: "All text and interactive elements appear to have sufficient color contrast \u2014 text is clearly readable against its background",
|
|
406
413
|
[Accessibility.READABILITY]: "All text is readable \u2014 no text is cut off, overlapping, too small to read, or obscured by background images",
|
|
407
|
-
[Accessibility.INTERACTIVE_VISIBILITY]: "All interactive elements (buttons, links, inputs) are clearly identifiable and visually distinct from non-interactive content"
|
|
414
|
+
[Accessibility.INTERACTIVE_VISIBILITY]: "All interactive elements (buttons, links, inputs) are clearly identifiable and visually distinct from non-interactive content",
|
|
415
|
+
[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)",
|
|
416
|
+
[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)"
|
|
408
417
|
};
|
|
409
418
|
function buildAccessibilityPrompt(options) {
|
|
410
419
|
const checks = options?.checks ?? [...ALL_CHECKS];
|
|
@@ -925,6 +934,10 @@ var PRICING_TABLE = {
|
|
|
925
934
|
inputPricePerToken: 0.25 / PER_MILLION,
|
|
926
935
|
outputPricePerToken: 2 / PER_MILLION
|
|
927
936
|
},
|
|
937
|
+
[`${Provider.GOOGLE}:${Model.Google.GEMINI_3_5_FLASH}`]: {
|
|
938
|
+
inputPricePerToken: 1.5 / PER_MILLION,
|
|
939
|
+
outputPricePerToken: 9 / PER_MILLION
|
|
940
|
+
},
|
|
928
941
|
[`${Provider.GOOGLE}:${Model.Google.GEMINI_3_1_PRO_PREVIEW}`]: {
|
|
929
942
|
inputPricePerToken: 2 / PER_MILLION,
|
|
930
943
|
outputPricePerToken: 12 / PER_MILLION
|
|
@@ -1011,15 +1024,19 @@ async function timedSendMessage(driver, images, prompt, options) {
|
|
|
1011
1024
|
|
|
1012
1025
|
// src/core/diff.ts
|
|
1013
1026
|
import sharp from "sharp";
|
|
1027
|
+
var DIFF_ALLOWED_MODELS = /* @__PURE__ */ new Set([
|
|
1028
|
+
Model.Google.GEMINI_3_FLASH_PREVIEW,
|
|
1029
|
+
Model.Google.GEMINI_3_5_FLASH
|
|
1030
|
+
]);
|
|
1014
1031
|
async function generateAiDiff(imgA, imgB, model, driver) {
|
|
1015
1032
|
if (!driver.generateImage) {
|
|
1016
1033
|
throw new VisualAIConfigError(
|
|
1017
1034
|
"AI-generated diff images require a provider that supports image generation. Currently only the Google (Gemini) provider supports this."
|
|
1018
1035
|
);
|
|
1019
1036
|
}
|
|
1020
|
-
if (model
|
|
1037
|
+
if (!DIFF_ALLOWED_MODELS.has(model)) {
|
|
1021
1038
|
throw new VisualAIConfigError(
|
|
1022
|
-
|
|
1039
|
+
`Annotated diff images are only supported with these Google models: ${[...DIFF_ALLOWED_MODELS].join(", ")}.`
|
|
1023
1040
|
);
|
|
1024
1041
|
}
|
|
1025
1042
|
const response = await driver.generateImage([imgA, imgB], buildAiDiffPrompt(), {
|