@vizzly-testing/honeydiff 0.10.2 → 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/CHANGELOG.md +29 -16
- package/README.md +181 -689
- package/assets/honeydiff-mascot-diff-drizzle.png +0 -0
- package/examples/color-blindness.js +18 -18
- package/examples/wcag.js +17 -17
- package/index.d.ts +59 -56
- package/index.js +1 -1
- package/package.json +2 -1
- package/platforms/index-aarch64-apple-darwin.node +0 -0
- package/platforms/index-aarch64-unknown-linux-gnu.node +0 -0
- package/platforms/index-x86_64-pc-windows-msvc.node +0 -0
- package/platforms/index-x86_64-unknown-linux-gnu.node +0 -0
|
Binary file
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Color Vision Deficiency (CVD) Simulation Example
|
|
3
3
|
*
|
|
4
|
-
* Demonstrates how to simulate color blindness for images and
|
|
5
|
-
*
|
|
4
|
+
* Demonstrates how to simulate color blindness for images and screen
|
|
5
|
+
* detected color boundaries with WCAG color-pair thresholds.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import fs from 'node:fs';
|
|
@@ -71,8 +71,8 @@ async function main() {
|
|
|
71
71
|
console.error(' Error:', error.message, '\n');
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
// Example 5: WCAG
|
|
75
|
-
console.log('5.
|
|
74
|
+
// Example 5: WCAG threshold screening for a specific CVD type
|
|
75
|
+
console.log('5. Screening WCAG contrast thresholds for deuteranopia users...');
|
|
76
76
|
try {
|
|
77
77
|
let analysis = await analyzeWcagForCvd(testImage, 'deuteranopia', {
|
|
78
78
|
checkAA: true,
|
|
@@ -82,10 +82,10 @@ async function main() {
|
|
|
82
82
|
|
|
83
83
|
console.log(` Total edges analyzed: ${analysis.totalEdges}`);
|
|
84
84
|
console.log(` AA normal text pass rate: ${analysis.aaNormalPassPercentage.toFixed(1)}%`);
|
|
85
|
-
console.log(`
|
|
85
|
+
console.log(` Warnings found: ${analysis.violations.length}`);
|
|
86
86
|
|
|
87
87
|
if (analysis.violations.length > 0) {
|
|
88
|
-
console.log('\n Top 3
|
|
88
|
+
console.log('\n Top 3 warnings:');
|
|
89
89
|
for (let i = 0; i < Math.min(3, analysis.violations.length); i++) {
|
|
90
90
|
let v = analysis.violations[i];
|
|
91
91
|
console.log(` ${i + 1}. Location: (${v.boundingBox.x}, ${v.boundingBox.y})`);
|
|
@@ -98,36 +98,36 @@ async function main() {
|
|
|
98
98
|
console.error(' Error:', error.message, '\n');
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
// Example 6: Comprehensive CVD
|
|
102
|
-
console.log('6. Running comprehensive CVD
|
|
101
|
+
// Example 6: Comprehensive CVD contrast report
|
|
102
|
+
console.log('6. Running comprehensive CVD contrast screening...');
|
|
103
103
|
try {
|
|
104
104
|
let report = await analyzeWcagAllCvd(testImage, {
|
|
105
105
|
checkAA: true,
|
|
106
106
|
checkAAA: true,
|
|
107
107
|
});
|
|
108
108
|
|
|
109
|
-
console.log('\n
|
|
109
|
+
console.log('\n Contrast Screening Report:');
|
|
110
110
|
console.log(' ─────────────────────────────────────────────');
|
|
111
111
|
console.log(
|
|
112
|
-
` Normal Vision: ${report.normalVision.violations.length}
|
|
112
|
+
` Normal Vision: ${report.normalVision.violations.length} warnings ` +
|
|
113
113
|
`(${report.normalVision.aaNormalPassPercentage.toFixed(1)}% pass)`
|
|
114
114
|
);
|
|
115
115
|
console.log(
|
|
116
|
-
` Protanopia: ${report.protanopia.violations.length}
|
|
116
|
+
` Protanopia: ${report.protanopia.violations.length} warnings ` +
|
|
117
117
|
`(${report.protanopia.aaNormalPassPercentage.toFixed(1)}% pass)`
|
|
118
118
|
);
|
|
119
119
|
console.log(
|
|
120
|
-
` Deuteranopia: ${report.deuteranopia.violations.length}
|
|
120
|
+
` Deuteranopia: ${report.deuteranopia.violations.length} warnings ` +
|
|
121
121
|
`(${report.deuteranopia.aaNormalPassPercentage.toFixed(1)}% pass)`
|
|
122
122
|
);
|
|
123
123
|
console.log(
|
|
124
|
-
` Tritanopia: ${report.tritanopia.violations.length}
|
|
124
|
+
` Tritanopia: ${report.tritanopia.violations.length} warnings ` +
|
|
125
125
|
`(${report.tritanopia.aaNormalPassPercentage.toFixed(1)}% pass)`
|
|
126
126
|
);
|
|
127
127
|
console.log(' ─────────────────────────────────────────────');
|
|
128
|
-
console.log(` Total
|
|
129
|
-
console.log(` CVD-only
|
|
130
|
-
console.log(` Has any
|
|
128
|
+
console.log(` Total warnings: ${report.totalViolations}`);
|
|
129
|
+
console.log(` CVD-only warnings: ~${report.cvdOnlyViolationCount}`);
|
|
130
|
+
console.log(` Has any warnings: ${report.hasAnyViolations}`);
|
|
131
131
|
console.log();
|
|
132
132
|
} catch (error) {
|
|
133
133
|
console.error(' Error:', error.message, '\n');
|
|
@@ -157,10 +157,10 @@ async function main() {
|
|
|
157
157
|
test('UI colors work for colorblind users', async () => {
|
|
158
158
|
let screenshot = await page.screenshot();
|
|
159
159
|
|
|
160
|
-
//
|
|
160
|
+
// Screen contrast for all CVD types
|
|
161
161
|
let report = await analyzeWcagAllCvd(screenshot, { checkAA: true });
|
|
162
162
|
|
|
163
|
-
// Assert no
|
|
163
|
+
// Assert no warnings
|
|
164
164
|
expect(report.hasAnyViolations).toBe(false);
|
|
165
165
|
|
|
166
166
|
// Or check specific CVD types
|
package/examples/wcag.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Screenshot Contrast Screening Example
|
|
3
3
|
*
|
|
4
|
-
* Demonstrates how to
|
|
5
|
-
* and generate visual overlays showing
|
|
4
|
+
* Demonstrates how to screen screenshots with WCAG color-pair thresholds
|
|
5
|
+
* and generate visual overlays showing regions worth reviewing.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import path from 'node:path';
|
|
@@ -12,10 +12,10 @@ import { analyzeWcagContrast, analyzeWcagContrastSync, saveWcagOverlay } from '.
|
|
|
12
12
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
13
13
|
|
|
14
14
|
async function main() {
|
|
15
|
-
console.log('===
|
|
15
|
+
console.log('=== Screenshot Contrast Screening Demo ===\n');
|
|
16
16
|
|
|
17
|
-
// Example 1: Basic
|
|
18
|
-
console.log('1. Running basic WCAG AA
|
|
17
|
+
// Example 1: Basic contrast screening
|
|
18
|
+
console.log('1. Running basic WCAG AA color-pair screening...');
|
|
19
19
|
try {
|
|
20
20
|
let analysis = await analyzeWcagContrast(
|
|
21
21
|
path.join(__dirname, '../../../tests/fixtures/screenshots/vizzly-baseline.png'),
|
|
@@ -30,10 +30,10 @@ async function main() {
|
|
|
30
30
|
console.log(` Total edges detected: ${analysis.totalEdges}`);
|
|
31
31
|
console.log(` AA normal text pass rate: ${analysis.aaNormalPassPercentage.toFixed(1)}%`);
|
|
32
32
|
console.log(` AA large text pass rate: ${analysis.aaLargePassPercentage.toFixed(1)}%`);
|
|
33
|
-
console.log(`
|
|
33
|
+
console.log(` Warnings found: ${analysis.violations.length}\n`);
|
|
34
34
|
|
|
35
35
|
if (analysis.violations.length > 0) {
|
|
36
|
-
console.log(' Top 5
|
|
36
|
+
console.log(' Top 5 warnings by size:');
|
|
37
37
|
for (let i = 0; i < Math.min(5, analysis.violations.length); i++) {
|
|
38
38
|
let violation = analysis.violations[i];
|
|
39
39
|
console.log(
|
|
@@ -51,8 +51,8 @@ async function main() {
|
|
|
51
51
|
console.error(' Error:', error.message);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
// Example 2: WCAG AAA
|
|
55
|
-
console.log('2. Running strict WCAG AAA
|
|
54
|
+
// Example 2: WCAG AAA threshold screening (stricter)
|
|
55
|
+
console.log('2. Running strict WCAG AAA color-pair screening...');
|
|
56
56
|
try {
|
|
57
57
|
let analysis = await analyzeWcagContrast(
|
|
58
58
|
path.join(__dirname, '../../../tests/fixtures/screenshots/vizzly-baseline.png'),
|
|
@@ -67,7 +67,7 @@ async function main() {
|
|
|
67
67
|
console.log(` Total edges detected: ${analysis.totalEdges}`);
|
|
68
68
|
console.log(` AAA normal text pass rate: ${analysis.aaaNormalPassPercentage.toFixed(1)}%`);
|
|
69
69
|
console.log(` AAA large text pass rate: ${analysis.aaaLargePassPercentage.toFixed(1)}%`);
|
|
70
|
-
console.log(` AAA
|
|
70
|
+
console.log(` AAA warnings found: ${analysis.violations.length}\n`);
|
|
71
71
|
} catch (error) {
|
|
72
72
|
console.error(' Error:', error.message);
|
|
73
73
|
}
|
|
@@ -83,7 +83,7 @@ async function main() {
|
|
|
83
83
|
}
|
|
84
84
|
);
|
|
85
85
|
|
|
86
|
-
let outputPath = path.join(__dirname, '../wcag-
|
|
86
|
+
let outputPath = path.join(__dirname, '../wcag-warnings.png');
|
|
87
87
|
|
|
88
88
|
await saveWcagOverlay(
|
|
89
89
|
path.join(__dirname, '../../../tests/fixtures/screenshots/vizzly-baseline.png'),
|
|
@@ -111,14 +111,14 @@ async function main() {
|
|
|
111
111
|
);
|
|
112
112
|
|
|
113
113
|
console.log(` Total edges: ${analysis.totalEdges}`);
|
|
114
|
-
console.log(`
|
|
114
|
+
console.log(` Warnings: ${analysis.violations.length}`);
|
|
115
115
|
console.log(` Pass rate: ${analysis.aaNormalPassPercentage.toFixed(1)}%\n`);
|
|
116
116
|
} catch (error) {
|
|
117
117
|
console.error(' Error:', error.message);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
// Example 5: Detailed
|
|
121
|
-
console.log('5. Analyzing
|
|
120
|
+
// Example 5: Detailed warning analysis
|
|
121
|
+
console.log('5. Analyzing warning details...');
|
|
122
122
|
try {
|
|
123
123
|
let analysis = await analyzeWcagContrast(
|
|
124
124
|
path.join(__dirname, '../../../tests/fixtures/screenshots/vizzly-baseline.png')
|
|
@@ -127,7 +127,7 @@ async function main() {
|
|
|
127
127
|
if (analysis.violations.length > 0) {
|
|
128
128
|
let violation = analysis.violations[0];
|
|
129
129
|
|
|
130
|
-
console.log(' First
|
|
130
|
+
console.log(' First warning details:');
|
|
131
131
|
console.log(` - Location: (${violation.boundingBox.x}, ${violation.boundingBox.y})`);
|
|
132
132
|
console.log(` - Size: ${violation.boundingBox.width}x${violation.boundingBox.height}`);
|
|
133
133
|
console.log(
|
|
@@ -141,7 +141,7 @@ async function main() {
|
|
|
141
141
|
` - Contrast ratio: ${violation.contrastRatio.toFixed(2)}:1 (${violation.minContrastRatio.toFixed(2)} - ${violation.maxContrastRatio.toFixed(2)})`
|
|
142
142
|
);
|
|
143
143
|
console.log(` - Pixel count: ${violation.pixelCount}`);
|
|
144
|
-
console.log(' -
|
|
144
|
+
console.log(' - Detected threshold status:');
|
|
145
145
|
console.log(` AA Normal (4.5:1): ${violation.failsAaNormal ? '❌ FAIL' : '✓ PASS'}`);
|
|
146
146
|
console.log(` AA Large (3.0:1): ${violation.failsAaLarge ? '❌ FAIL' : '✓ PASS'}`);
|
|
147
147
|
console.log(` AAA Normal (7.0:1): ${violation.failsAaaNormal ? '❌ FAIL' : '✓ PASS'}`);
|
package/index.d.ts
CHANGED
|
@@ -206,8 +206,8 @@ export interface CompareOptions {
|
|
|
206
206
|
* Useful for detecting border thickness changes, font weight shifts,
|
|
207
207
|
* and icon updates.
|
|
208
208
|
*
|
|
209
|
-
* **Note:**
|
|
210
|
-
*
|
|
209
|
+
* **Note:** For variable-height comparisons, GMSD is calculated on the
|
|
210
|
+
* overlapping region shared by both images.
|
|
211
211
|
*
|
|
212
212
|
* Reference: Xue et al. 2014 - "Gradient Magnitude Similarity Deviation:
|
|
213
213
|
* A Highly Efficient Perceptual Image Quality Index"
|
|
@@ -541,11 +541,11 @@ export function getImageMetadataFromFile(path: string): Promise<ImageMetadata>;
|
|
|
541
541
|
export function getImageMetadataFromFileSync(path: string): ImageMetadata;
|
|
542
542
|
|
|
543
543
|
// ============================================================================
|
|
544
|
-
//
|
|
544
|
+
// Screenshot Contrast Screening API
|
|
545
545
|
// ============================================================================
|
|
546
546
|
|
|
547
547
|
/**
|
|
548
|
-
* Options for WCAG color
|
|
548
|
+
* Options for screenshot contrast screening with WCAG color-pair math.
|
|
549
549
|
*/
|
|
550
550
|
export interface WcagOptions {
|
|
551
551
|
/**
|
|
@@ -564,38 +564,39 @@ export interface WcagOptions {
|
|
|
564
564
|
|
|
565
565
|
/**
|
|
566
566
|
* Maximum contrast threshold
|
|
567
|
-
*
|
|
568
|
-
*
|
|
567
|
+
* Set above 0 to exclude regions with contrast above this ratio. 0 reports
|
|
568
|
+
* all detected failures.
|
|
569
|
+
* @default 0
|
|
569
570
|
*/
|
|
570
571
|
maxContrastThreshold?: number;
|
|
571
572
|
|
|
572
573
|
/**
|
|
573
|
-
* Check WCAG AA
|
|
574
|
+
* Check WCAG AA color-pair thresholds (4.5:1 for normal text, 3.0:1 for large text)
|
|
574
575
|
* @default true
|
|
575
576
|
*/
|
|
576
577
|
checkAA?: boolean;
|
|
577
578
|
|
|
578
579
|
/**
|
|
579
|
-
* Check WCAG AAA
|
|
580
|
+
* Check WCAG AAA color-pair thresholds (7.0:1 for normal text, 4.5:1 for large text)
|
|
580
581
|
* @default false
|
|
581
582
|
*/
|
|
582
583
|
checkAAA?: boolean;
|
|
583
584
|
}
|
|
584
585
|
|
|
585
586
|
/**
|
|
586
|
-
* A single
|
|
587
|
+
* A single screenshot contrast warning region.
|
|
587
588
|
*/
|
|
588
589
|
export interface ContrastViolation {
|
|
589
|
-
/** Bounding box containing this
|
|
590
|
+
/** Bounding box containing this warning region */
|
|
590
591
|
boundingBox: BoundingBox;
|
|
591
592
|
|
|
592
|
-
/** List of pixel coordinates [x, y] in this
|
|
593
|
+
/** List of pixel coordinates [x, y] in this warning region */
|
|
593
594
|
pixels: [number, number][];
|
|
594
595
|
|
|
595
|
-
/** Center of mass [x, y] of the
|
|
596
|
+
/** Center of mass [x, y] of the warning region */
|
|
596
597
|
centerOfMass: [number, number];
|
|
597
598
|
|
|
598
|
-
/** Number of pixels in this
|
|
599
|
+
/** Number of pixels in this warning region */
|
|
599
600
|
pixelCount: number;
|
|
600
601
|
|
|
601
602
|
/** Foreground color [r, g, b, a] (0-255) */
|
|
@@ -633,7 +634,7 @@ export interface ContrastViolation {
|
|
|
633
634
|
}
|
|
634
635
|
|
|
635
636
|
/**
|
|
636
|
-
* Complete
|
|
637
|
+
* Complete screenshot contrast screening result.
|
|
637
638
|
*/
|
|
638
639
|
export interface WcagAnalysis {
|
|
639
640
|
/** Total number of edges analyzed */
|
|
@@ -651,7 +652,7 @@ export interface WcagAnalysis {
|
|
|
651
652
|
/** Number of edges passing WCAG AAA for large text */
|
|
652
653
|
aaaLargePass: number;
|
|
653
654
|
|
|
654
|
-
/** List of contrast
|
|
655
|
+
/** List of contrast warning regions found */
|
|
655
656
|
violations: ContrastViolation[];
|
|
656
657
|
|
|
657
658
|
/** Percentage of edges passing WCAG AA for normal text (0.0-100.0) */
|
|
@@ -668,14 +669,16 @@ export interface WcagAnalysis {
|
|
|
668
669
|
}
|
|
669
670
|
|
|
670
671
|
/**
|
|
671
|
-
*
|
|
672
|
+
* Screen screenshot contrast warnings asynchronously (recommended)
|
|
672
673
|
*
|
|
673
|
-
* Detects
|
|
674
|
-
*
|
|
674
|
+
* Detects color boundaries in an image and measures each color pair with the
|
|
675
|
+
* WCAG contrast formula. Treat results as screening warnings, not full WCAG
|
|
676
|
+
* conformance, because screenshots do not expose text size, boldness, DOM
|
|
677
|
+
* foreground/background, compositing, or semantic roles.
|
|
675
678
|
*
|
|
676
679
|
* @param img - Image to analyze (file path or Buffer)
|
|
677
|
-
* @param options -
|
|
678
|
-
* @returns Promise resolving to detailed
|
|
680
|
+
* @param options - Screenshot contrast screening options
|
|
681
|
+
* @returns Promise resolving to detailed screenshot contrast screening result
|
|
679
682
|
*
|
|
680
683
|
* @example
|
|
681
684
|
* ```typescript
|
|
@@ -699,14 +702,14 @@ export interface WcagAnalysis {
|
|
|
699
702
|
export function analyzeWcagContrast(img: ImageInput, options?: WcagOptions): Promise<WcagAnalysis>;
|
|
700
703
|
|
|
701
704
|
/**
|
|
702
|
-
*
|
|
705
|
+
* Screen screenshot contrast warnings synchronously (blocks event loop)
|
|
703
706
|
*
|
|
704
707
|
* Use this only when you need blocking behavior.
|
|
705
708
|
* For most cases, prefer the async analyzeWcagContrast() function.
|
|
706
709
|
*
|
|
707
710
|
* @param img - Image to analyze (file path or Buffer)
|
|
708
|
-
* @param options -
|
|
709
|
-
* @returns Detailed
|
|
711
|
+
* @param options - Screenshot contrast screening options
|
|
712
|
+
* @returns Detailed screenshot contrast screening result
|
|
710
713
|
*
|
|
711
714
|
* @example
|
|
712
715
|
* ```typescript
|
|
@@ -745,7 +748,7 @@ export interface WcagOutputOptions {
|
|
|
745
748
|
* Useful for visual debugging of accessibility issues.
|
|
746
749
|
*
|
|
747
750
|
* @param img - Original image (file path or Buffer)
|
|
748
|
-
* @param analysis -
|
|
751
|
+
* @param analysis - Screenshot contrast screening result from analyzeWcagContrast()
|
|
749
752
|
* @param outputPath - Path to save the overlay image
|
|
750
753
|
* @param options - Output options
|
|
751
754
|
* @returns Promise that resolves when the file is saved
|
|
@@ -778,7 +781,7 @@ export function saveWcagOverlay(
|
|
|
778
781
|
* For most cases, prefer the async saveWcagOverlay() function.
|
|
779
782
|
*
|
|
780
783
|
* @param img - Original image (file path or Buffer)
|
|
781
|
-
* @param analysis -
|
|
784
|
+
* @param analysis - Screenshot contrast screening result from analyzeWcagContrastSync()
|
|
782
785
|
* @param outputPath - Path to save the overlay image
|
|
783
786
|
* @param options - Output options
|
|
784
787
|
*
|
|
@@ -835,22 +838,22 @@ export interface ColorBlindnessTypeInfo {
|
|
|
835
838
|
}
|
|
836
839
|
|
|
837
840
|
/**
|
|
838
|
-
* Comprehensive
|
|
841
|
+
* Comprehensive screenshot contrast screening report for all color vision deficiency types.
|
|
839
842
|
*
|
|
840
|
-
* Contains
|
|
843
|
+
* Contains contrast screening for normal vision and all three main types
|
|
841
844
|
* of dichromatic color blindness (protanopia, deuteranopia, tritanopia).
|
|
842
845
|
*/
|
|
843
846
|
export interface CvdWcagReport {
|
|
844
|
-
/**
|
|
847
|
+
/** Contrast screening for normal (typical) color vision */
|
|
845
848
|
normalVision: WcagAnalysis;
|
|
846
849
|
|
|
847
|
-
/**
|
|
850
|
+
/** Contrast screening simulating protanopia (red-blind) */
|
|
848
851
|
protanopia: WcagAnalysis;
|
|
849
852
|
|
|
850
|
-
/**
|
|
853
|
+
/** Contrast screening simulating deuteranopia (green-blind) */
|
|
851
854
|
deuteranopia: WcagAnalysis;
|
|
852
855
|
|
|
853
|
-
/**
|
|
856
|
+
/** Contrast screening simulating tritanopia (blue-blind) */
|
|
854
857
|
tritanopia: WcagAnalysis;
|
|
855
858
|
|
|
856
859
|
/** Whether any CVD type has violations */
|
|
@@ -870,8 +873,8 @@ export interface CvdWcagReport {
|
|
|
870
873
|
* Simulate color blindness for an image asynchronously (recommended)
|
|
871
874
|
*
|
|
872
875
|
* Transforms the input image to show how it appears to someone with the
|
|
873
|
-
* specified type of color vision deficiency.
|
|
874
|
-
*
|
|
876
|
+
* specified type of color vision deficiency. Complete dichromacy uses the
|
|
877
|
+
* piecewise Brettel, Viénot & Mollon 1997 LMS projection model.
|
|
875
878
|
*
|
|
876
879
|
* @param img - Image to transform (file path or Buffer)
|
|
877
880
|
* @param cvdType - Type of color blindness to simulate
|
|
@@ -1010,16 +1013,17 @@ export function saveAllColorBlindnessSimulationsSync(
|
|
|
1010
1013
|
): void;
|
|
1011
1014
|
|
|
1012
1015
|
/**
|
|
1013
|
-
*
|
|
1016
|
+
* Screen contrast for a specific color blindness type asynchronously (recommended)
|
|
1014
1017
|
*
|
|
1015
1018
|
* Simulates the image as seen by someone with the specified color vision
|
|
1016
|
-
* deficiency, then runs
|
|
1017
|
-
*
|
|
1019
|
+
* deficiency, then runs screenshot contrast screening with WCAG color-pair
|
|
1020
|
+
* math. This finds detected color-pair warnings that only appear for
|
|
1021
|
+
* colorblind users.
|
|
1018
1022
|
*
|
|
1019
1023
|
* @param img - Image to analyze (file path or Buffer)
|
|
1020
1024
|
* @param cvdType - Type of color blindness to simulate
|
|
1021
|
-
* @param options -
|
|
1022
|
-
* @returns Promise resolving to
|
|
1025
|
+
* @param options - Screenshot contrast screening options
|
|
1026
|
+
* @returns Promise resolving to screening results for the simulated image
|
|
1023
1027
|
*
|
|
1024
1028
|
* @example
|
|
1025
1029
|
* ```typescript
|
|
@@ -1042,14 +1046,14 @@ export function analyzeWcagForCvd(
|
|
|
1042
1046
|
): Promise<WcagAnalysis>;
|
|
1043
1047
|
|
|
1044
1048
|
/**
|
|
1045
|
-
*
|
|
1049
|
+
* Screen contrast for a specific color blindness type synchronously (blocks event loop)
|
|
1046
1050
|
*
|
|
1047
1051
|
* Use this only when you need blocking behavior.
|
|
1048
1052
|
*
|
|
1049
1053
|
* @param img - Image to analyze (file path or Buffer)
|
|
1050
1054
|
* @param cvdType - Type of color blindness to simulate
|
|
1051
|
-
* @param options -
|
|
1052
|
-
* @returns
|
|
1055
|
+
* @param options - Screenshot contrast screening options
|
|
1056
|
+
* @returns Screening results for the simulated image
|
|
1053
1057
|
*
|
|
1054
1058
|
* @example
|
|
1055
1059
|
* ```typescript
|
|
@@ -1064,15 +1068,14 @@ export function analyzeWcagForCvdSync(
|
|
|
1064
1068
|
): WcagAnalysis;
|
|
1065
1069
|
|
|
1066
1070
|
/**
|
|
1067
|
-
*
|
|
1071
|
+
* Screen contrast for all CVD types asynchronously (recommended)
|
|
1068
1072
|
*
|
|
1069
|
-
* Runs
|
|
1070
|
-
* dichromatic color blindness.
|
|
1071
|
-
* report covering the majority of color vision deficiencies.
|
|
1073
|
+
* Runs screenshot contrast screening for normal vision and all three main
|
|
1074
|
+
* types of dichromatic color blindness.
|
|
1072
1075
|
*
|
|
1073
1076
|
* @param img - Image to analyze (file path or Buffer)
|
|
1074
|
-
* @param options -
|
|
1075
|
-
* @returns Promise resolving to a report containing
|
|
1077
|
+
* @param options - Screenshot contrast screening options (same options used for all analyses)
|
|
1078
|
+
* @returns Promise resolving to a report containing screening results for each vision type
|
|
1076
1079
|
*
|
|
1077
1080
|
* @example
|
|
1078
1081
|
* ```typescript
|
|
@@ -1081,11 +1084,11 @@ export function analyzeWcagForCvdSync(
|
|
|
1081
1084
|
* checkAAA: true
|
|
1082
1085
|
* });
|
|
1083
1086
|
*
|
|
1084
|
-
* console.log('
|
|
1085
|
-
* console.log(`Normal vision
|
|
1086
|
-
* console.log(`Protanopia
|
|
1087
|
-
* console.log(`Deuteranopia
|
|
1088
|
-
* console.log(`Tritanopia
|
|
1087
|
+
* console.log('Contrast Screening Report:');
|
|
1088
|
+
* console.log(`Normal vision warnings: ${report.normalVision.violations.length}`);
|
|
1089
|
+
* console.log(`Protanopia warnings: ${report.protanopia.violations.length}`);
|
|
1090
|
+
* console.log(`Deuteranopia warnings: ${report.deuteranopia.violations.length}`);
|
|
1091
|
+
* console.log(`Tritanopia warnings: ${report.tritanopia.violations.length}`);
|
|
1089
1092
|
*
|
|
1090
1093
|
* if (report.hasAnyViolations) {
|
|
1091
1094
|
* console.log(`\nTotal issues found: ${report.totalViolations}`);
|
|
@@ -1096,20 +1099,20 @@ export function analyzeWcagForCvdSync(
|
|
|
1096
1099
|
export function analyzeWcagAllCvd(img: ImageInput, options?: WcagOptions): Promise<CvdWcagReport>;
|
|
1097
1100
|
|
|
1098
1101
|
/**
|
|
1099
|
-
*
|
|
1102
|
+
* Screen contrast for all CVD types synchronously (blocks event loop)
|
|
1100
1103
|
*
|
|
1101
1104
|
* Use this only when you need blocking behavior.
|
|
1102
1105
|
*
|
|
1103
1106
|
* @param img - Image to analyze (file path or Buffer)
|
|
1104
|
-
* @param options -
|
|
1105
|
-
* @returns Report containing
|
|
1107
|
+
* @param options - Screenshot contrast screening options
|
|
1108
|
+
* @returns Report containing screening results for each vision type
|
|
1106
1109
|
*
|
|
1107
1110
|
* @example
|
|
1108
1111
|
* ```typescript
|
|
1109
1112
|
* const report = analyzeWcagAllCvdSync('ui.png');
|
|
1110
1113
|
*
|
|
1111
1114
|
* if (report.hasAnyViolations) {
|
|
1112
|
-
* console.log('
|
|
1115
|
+
* console.log('Contrast warnings detected!');
|
|
1113
1116
|
* }
|
|
1114
1117
|
* ```
|
|
1115
1118
|
*/
|
package/index.js
CHANGED
|
@@ -48,7 +48,7 @@ export const getImageMetadataSync = addon.getImageMetadataSync;
|
|
|
48
48
|
export const getImageMetadataFromFile = addon.getImageMetadataFromFile;
|
|
49
49
|
export const getImageMetadataFromFileSync = addon.getImageMetadataFromFileSync;
|
|
50
50
|
|
|
51
|
-
//
|
|
51
|
+
// Screenshot Contrast Screening API
|
|
52
52
|
export const analyzeWcagContrast = addon.analyzeWcagContrast;
|
|
53
53
|
export const analyzeWcagContrastSync = addon.analyzeWcagContrastSync;
|
|
54
54
|
export const saveWcagOverlay = addon.saveWcagOverlay;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizzly-testing/honeydiff",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "High-performance image diffing for Node.js - Native bindings to Honeydiff Rust library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"index.d.ts",
|
|
49
49
|
"load-platform.cjs",
|
|
50
50
|
"platforms/*.node",
|
|
51
|
+
"assets/",
|
|
51
52
|
"examples/",
|
|
52
53
|
"README.md",
|
|
53
54
|
"CHANGELOG.md"
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|