@cappa/core 0.13.1 → 0.13.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/dist/index.d.cts CHANGED
@@ -16,8 +16,9 @@ interface CompareResult$1 {
16
16
  }
17
17
  /**
18
18
  * Compare two PNG images and return the difference
19
- * @param image1 - First image (file path or Buffer)
20
- * @param image2 - Second image (file path or Buffer)
19
+ * @param image1 - Baseline (expected) image (file path or Buffer)
20
+ * @param image2 - Current (actual) image (file path or Buffer). Order matters
21
+ * for `interpret`: content only in `image2` is reported as an addition.
21
22
  * @param withDiff - Whether to create a diff image
22
23
  * @param options - Comparison options
23
24
  * @returns Comparison result
@@ -25,8 +26,9 @@ interface CompareResult$1 {
25
26
  export declare function compareImages(image1: string | Buffer, image2: string | Buffer, withDiff?: boolean, options?: DiffConfig): Promise<CompareResult$1>;
26
27
  /**
27
28
  * Quick comparison function that returns only pass/fail
28
- * @param image1 - First image (file path or Buffer)
29
- * @param image2 - Second image (file path or Buffer)
29
+ * @param image1 - Baseline (expected) image (file path or Buffer)
30
+ * @param image2 - Current (actual) image (file path or Buffer). Order matters
31
+ * for `interpret`: content only in `image2` is reported as an addition.
30
32
  * @param options - Comparison options
31
33
  * @returns Whether the images match
32
34
  */
@@ -988,8 +990,8 @@ interface CompareResult {
988
990
  }
989
991
  /**
990
992
  * Compare two PNG images and return the difference
991
- * @param image1 - First image (file path or Buffer)
992
- * @param image2 - Second image (file path or Buffer)
993
+ * @param image1 - Baseline (expected) image (file path or Buffer)
994
+ * @param image2 - Current (actual) image (file path or Buffer)
993
995
  * @param withDiff - Whether to create a diff image
994
996
  * @param options - Comparison options
995
997
  * @returns Comparison result
@@ -997,8 +999,8 @@ interface CompareResult {
997
999
  export declare function compareImagesGMSD(image1: string | Buffer, image2: string | Buffer, withDiff?: boolean, options?: DiffConfigGMSD): Promise<CompareResult>;
998
1000
  /**
999
1001
  * Quick comparison function that returns only pass/fail
1000
- * @param image1 - First image (file path or Buffer)
1001
- * @param image2 - Second image (file path or Buffer)
1002
+ * @param image1 - Baseline (expected) image (file path or Buffer)
1003
+ * @param image2 - Current (actual) image (file path or Buffer)
1002
1004
  * @param options - Comparison options
1003
1005
  * @returns Whether the images match
1004
1006
  */
package/dist/index.d.mts CHANGED
@@ -16,8 +16,9 @@ interface CompareResult$1 {
16
16
  }
17
17
  /**
18
18
  * Compare two PNG images and return the difference
19
- * @param image1 - First image (file path or Buffer)
20
- * @param image2 - Second image (file path or Buffer)
19
+ * @param image1 - Baseline (expected) image (file path or Buffer)
20
+ * @param image2 - Current (actual) image (file path or Buffer). Order matters
21
+ * for `interpret`: content only in `image2` is reported as an addition.
21
22
  * @param withDiff - Whether to create a diff image
22
23
  * @param options - Comparison options
23
24
  * @returns Comparison result
@@ -25,8 +26,9 @@ interface CompareResult$1 {
25
26
  export declare function compareImages(image1: string | Buffer, image2: string | Buffer, withDiff?: boolean, options?: DiffConfig): Promise<CompareResult$1>;
26
27
  /**
27
28
  * Quick comparison function that returns only pass/fail
28
- * @param image1 - First image (file path or Buffer)
29
- * @param image2 - Second image (file path or Buffer)
29
+ * @param image1 - Baseline (expected) image (file path or Buffer)
30
+ * @param image2 - Current (actual) image (file path or Buffer). Order matters
31
+ * for `interpret`: content only in `image2` is reported as an addition.
30
32
  * @param options - Comparison options
31
33
  * @returns Whether the images match
32
34
  */
@@ -988,8 +990,8 @@ interface CompareResult {
988
990
  }
989
991
  /**
990
992
  * Compare two PNG images and return the difference
991
- * @param image1 - First image (file path or Buffer)
992
- * @param image2 - Second image (file path or Buffer)
993
+ * @param image1 - Baseline (expected) image (file path or Buffer)
994
+ * @param image2 - Current (actual) image (file path or Buffer)
993
995
  * @param withDiff - Whether to create a diff image
994
996
  * @param options - Comparison options
995
997
  * @returns Comparison result
@@ -997,8 +999,8 @@ interface CompareResult {
997
999
  export declare function compareImagesGMSD(image1: string | Buffer, image2: string | Buffer, withDiff?: boolean, options?: DiffConfigGMSD): Promise<CompareResult>;
998
1000
  /**
999
1001
  * Quick comparison function that returns only pass/fail
1000
- * @param image1 - First image (file path or Buffer)
1001
- * @param image2 - Second image (file path or Buffer)
1002
+ * @param image1 - Baseline (expected) image (file path or Buffer)
1003
+ * @param image2 - Current (actual) image (file path or Buffer)
1002
1004
  * @param options - Comparison options
1003
1005
  * @returns Whether the images match
1004
1006
  */
package/dist/index.mjs CHANGED
@@ -236,8 +236,8 @@ const compare$1 = (image1, image2, diff, width, height, options) => {
236
236
  };
237
237
  /**
238
238
  * Compare two PNG images and return the difference
239
- * @param image1 - First image (file path or Buffer)
240
- * @param image2 - Second image (file path or Buffer)
239
+ * @param image1 - Baseline (expected) image (file path or Buffer)
240
+ * @param image2 - Current (actual) image (file path or Buffer)
241
241
  * @param withDiff - Whether to create a diff image
242
242
  * @param options - Comparison options
243
243
  * @returns Comparison result
@@ -285,8 +285,8 @@ function annotateDiffImage(image, options) {
285
285
  }
286
286
  /**
287
287
  * Quick comparison function that returns only pass/fail
288
- * @param image1 - First image (file path or Buffer)
289
- * @param image2 - Second image (file path or Buffer)
288
+ * @param image1 - Baseline (expected) image (file path or Buffer)
289
+ * @param image2 - Current (actual) image (file path or Buffer)
290
290
  * @param options - Comparison options
291
291
  * @returns Whether the images match
292
292
  */
@@ -323,8 +323,9 @@ function toNativeOptions(config) {
323
323
  }
324
324
  /**
325
325
  * Compare two PNG images and return the difference
326
- * @param image1 - First image (file path or Buffer)
327
- * @param image2 - Second image (file path or Buffer)
326
+ * @param image1 - Baseline (expected) image (file path or Buffer)
327
+ * @param image2 - Current (actual) image (file path or Buffer). Order matters
328
+ * for `interpret`: content only in `image2` is reported as an addition.
328
329
  * @param withDiff - Whether to create a diff image
329
330
  * @param options - Comparison options
330
331
  * @returns Comparison result
@@ -409,8 +410,9 @@ async function compareImages(image1, image2, withDiff = false, options = {}) {
409
410
  }
410
411
  /**
411
412
  * Quick comparison function that returns only pass/fail
412
- * @param image1 - First image (file path or Buffer)
413
- * @param image2 - Second image (file path or Buffer)
413
+ * @param image1 - Baseline (expected) image (file path or Buffer)
414
+ * @param image2 - Current (actual) image (file path or Buffer). Order matters
415
+ * for `interpret`: content only in `image2` is reported as an addition.
414
416
  * @param options - Comparison options
415
417
  * @returns Whether the images match
416
418
  */
@@ -629,7 +631,7 @@ var ScreenshotFileSystem = class {
629
631
  }
630
632
  if (screenshot.category === "passed") {
631
633
  if (!screenshot.expectedPath) throw new Error("Expected path is required for passed screenshots");
632
- if (!await imagesMatch(path.resolve(outputDir, screenshot.actualPath), path.resolve(outputDir, screenshot.expectedPath), diff.type === "gmsd" ? { threshold: diff.threshold } : diff)) await this.approveFromActualPath(path.resolve(outputDir, screenshot.actualPath));
634
+ if (!await imagesMatch(path.resolve(outputDir, screenshot.expectedPath), path.resolve(outputDir, screenshot.actualPath), diff.type === "gmsd" ? { threshold: diff.threshold } : diff)) await this.approveFromActualPath(path.resolve(outputDir, screenshot.actualPath));
633
635
  }
634
636
  }
635
637
  /**
@@ -1726,7 +1728,7 @@ var ScreenshotTool = class {
1726
1728
  delay: this.getIncBackoffDelay(i, options.delay || 0)
1727
1729
  });
1728
1730
  if (!screenshotBuffer) throw new Error("Screenshot buffer is undefined");
1729
- const comparisonResult = diffConfig.type === "gmsd" ? await compareImagesGMSD(screenshotBuffer, referenceImage, true, diffConfig) : await compareImages(screenshotBuffer, referenceImage, true, diffConfig);
1731
+ const comparisonResult = diffConfig.type === "gmsd" ? await compareImagesGMSD(referenceImage, screenshotBuffer, true, diffConfig) : await compareImages(referenceImage, screenshotBuffer, true, diffConfig);
1730
1732
  if (i === this.retries - 1 && !comparisonResult.passed) {
1731
1733
  this.logger.error(`Failed to match screenshot after ${this.retries} retries`);
1732
1734
  return {