@vizzly-testing/honeydiff 0.4.1 → 0.4.2

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 CHANGED
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.4.2] - 2025-12-01
9
+
10
+ ## What's Changed
11
+
12
+ ### Fixed
13
+ - **ESM exports now work correctly in published package** - Fixed critical bug where ESM imports were broken in consuming projects (e.g., `import { compare } from '@vizzly-testing/honeydiff'` threw `SyntaxError: The requested module does not provide an export named 'compare'`). The package loader now auto-detects whether to use platform-specific binaries (published package) or the local development build. (#14)
14
+
15
+ **Full Changelog**: https://github.com/vizzly-testing/honeydiff/compare/v0.4.1...v0.4.2
16
+
8
17
  ## [0.4.1] - 2025-11-30
9
18
 
10
19
  ## What's Changed
package/index.js CHANGED
@@ -2,31 +2,61 @@
2
2
  * @vizzly-testing/honeydiff - Native Node.js bindings for Honeydiff
3
3
  */
4
4
 
5
+ import { existsSync } from 'node:fs';
6
+ import { createRequire } from 'node:module';
7
+ import { dirname, join } from 'node:path';
8
+ import { fileURLToPath } from 'node:url';
9
+
10
+ const require = createRequire(import.meta.url);
11
+ const __dirname = dirname(fileURLToPath(import.meta.url));
12
+
5
13
  let addon;
6
14
 
7
- try {
8
- // Load the platform-specific native addon
9
- addon = require('./load-platform.js');
10
- } catch (e) {
11
- throw new Error(
12
- '@vizzly-testing/honeydiff failed to load native binary.\n' +
13
- 'Platform: ' + process.platform + ' ' + process.arch + '\n' +
14
- 'Original error: ' + e.message
15
- );
15
+ // Try to load the native addon:
16
+ // 1. First try load-platform.js (exists in published npm package with multi-platform binaries)
17
+ // 2. Fall back to index.node (exists in local development builds)
18
+ const platformLoaderPath = join(__dirname, 'load-platform.js');
19
+
20
+ if (existsSync(platformLoaderPath)) {
21
+ // Published package: use platform-specific loader
22
+ addon = require(platformLoaderPath);
23
+ } else {
24
+ // Local development: use directly built index.node
25
+ try {
26
+ addon = require('./index.node');
27
+ } catch (e) {
28
+ throw new Error(
29
+ '@vizzly-testing/honeydiff: Failed to load native binary.\n' +
30
+ 'If developing locally, run "cargo build --release" first.\n' +
31
+ 'Original error: ' +
32
+ e.message
33
+ );
34
+ }
16
35
  }
17
36
 
18
- // Export all functions from the native addon
19
- module.exports = {
20
- compare: addon.compare,
21
- quickCompare: addon.quickCompare,
22
- compareSync: addon.compareSync,
23
- quickCompareSync: addon.quickCompareSync,
24
- getDimensions: addon.getDimensions,
25
- getDimensionsSync: addon.getDimensionsSync,
26
-
27
- // WCAG Accessibility API
28
- analyzeWcagContrast: addon.analyzeWcagContrast,
29
- analyzeWcagContrastSync: addon.analyzeWcagContrastSync,
30
- saveWcagOverlay: addon.saveWcagOverlay,
31
- saveWcagOverlaySync: addon.saveWcagOverlaySync,
32
- };
37
+ // Core comparison API
38
+ export const compare = addon.compare;
39
+ export const quickCompare = addon.quickCompare;
40
+ export const compareSync = addon.compareSync;
41
+ export const quickCompareSync = addon.quickCompareSync;
42
+ export const getDimensions = addon.getDimensions;
43
+ export const getDimensionsSync = addon.getDimensionsSync;
44
+
45
+ // WCAG Accessibility API
46
+ export const analyzeWcagContrast = addon.analyzeWcagContrast;
47
+ export const analyzeWcagContrastSync = addon.analyzeWcagContrastSync;
48
+ export const saveWcagOverlay = addon.saveWcagOverlay;
49
+ export const saveWcagOverlaySync = addon.saveWcagOverlaySync;
50
+
51
+ // Color Vision Deficiency (CVD) Simulation API
52
+ export const simulateColorBlindness = addon.simulateColorBlindness;
53
+ export const simulateColorBlindnessSync = addon.simulateColorBlindnessSync;
54
+ export const saveColorBlindnessSimulation = addon.saveColorBlindnessSimulation;
55
+ export const saveColorBlindnessSimulationSync = addon.saveColorBlindnessSimulationSync;
56
+ export const saveAllColorBlindnessSimulations = addon.saveAllColorBlindnessSimulations;
57
+ export const saveAllColorBlindnessSimulationsSync = addon.saveAllColorBlindnessSimulationsSync;
58
+ export const analyzeWcagForCvd = addon.analyzeWcagForCvd;
59
+ export const analyzeWcagForCvdSync = addon.analyzeWcagForCvdSync;
60
+ export const analyzeWcagAllCvd = addon.analyzeWcagAllCvd;
61
+ export const analyzeWcagAllCvdSync = addon.analyzeWcagAllCvdSync;
62
+ export const getColorBlindnessTypes = addon.getColorBlindnessTypes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizzly-testing/honeydiff",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
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",