visual-regression-compare 1.0.0-beta.0 → 1.0.0-beta.1

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/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Manifest, ManifestColorMetric, ManifestEntry, ManifestEntryPlatform, ManifestExtra, ManifestStatus, ManifestViewport } from 'visual-regression-manifest';
1
+ import type { Manifest, ManifestColorMetric, ManifestEntry, ManifestEntryInput, ManifestEntryPlatform, ManifestExtra, ManifestStatus, ManifestViewport } from 'visual-regression-manifest';
2
2
  /** Decoded image: 8-bit RGBA, row by row. */
3
3
  export type RgbaImage = {
4
4
  width: number;
@@ -77,6 +77,39 @@ export type Matcher = {
77
77
  /** Where the baseline of an incoming image is (or should be); `null` skips the image. */
78
78
  baselineFor(incoming: ImageRef): ImageRef | null;
79
79
  };
80
+ /**
81
+ * What a single call may change about the comparer's own settings, for this
82
+ * screenshot only. `limits`, `update`, `onMissingBaseline` and
83
+ * `onSizeMismatch` replace the comparer's value; `engineOptions` are merged
84
+ * over it.
85
+ */
86
+ export type CompareOptions = {
87
+ limits?: Limits;
88
+ engineOptions?: EngineOptions;
89
+ update?: UpdatePolicy;
90
+ onMissingBaseline?: OnMissingBaseline;
91
+ onSizeMismatch?: SizeMismatch;
92
+ };
93
+ /**
94
+ * Files of one screenshot, as absolute paths, for a runner that already knows
95
+ * where everything lives. They replace the store, the layout and the matcher
96
+ * for this call. `actual` and `diff` default to the `.actual.png` and
97
+ * `.diff.png` files beside the baseline.
98
+ */
99
+ export type CompareFiles = {
100
+ baseline: string;
101
+ actual?: string;
102
+ diff?: string;
103
+ };
104
+ /** Entry fields a runner states itself; they are recorded as given. */
105
+ export type CompareEntryFields = Pick<ManifestEntryInput, 'options' | 'renderer' | 'attachments' | 'baselineExtra' | 'target' | 'subject'>;
106
+ /** The images `compare` can hand back next to the entry. `baseline` and `actual` are the sizes that were compared (padded or cropped, when sizes differed). */
107
+ export type ImagePart = 'baseline' | 'actual' | 'diff';
108
+ export type CompareResult = {
109
+ entry: ManifestEntry;
110
+ /** PNG bytes of the requested parts that exist: there is no `diff` without a baseline, and none from an engine that makes none. */
111
+ images: Partial<Record<ImagePart, Uint8Array>>;
112
+ };
80
113
  /** Identity of one compared screenshot, as an adapter or the CLI states it. */
81
114
  export type CompareInput = {
82
115
  /** Screenshot name; becomes the file name through the layout (unsafe characters are replaced). */
@@ -93,6 +126,12 @@ export type CompareInput = {
93
126
  extra?: ManifestExtra;
94
127
  /** Capture plus preceding time in milliseconds, recorded as the entry's `duration`. */
95
128
  duration?: number;
129
+ /** Settings for this screenshot only. */
130
+ options?: CompareOptions;
131
+ /** Where the files are, instead of the store and layout. */
132
+ files?: CompareFiles;
133
+ /** Entry fields recorded as given (the comparer's own `options` block is replaced by `entry.options`). */
134
+ entry?: CompareEntryFields;
96
135
  };
97
136
  /**
98
137
  * What hooks see of one comparison. `attachments` is reserved for extra inputs
package/dist/worker.js CHANGED
@@ -137,13 +137,18 @@ var runCompare = async (job, engine) => {
137
137
  );
138
138
  }
139
139
  const { diff, ...result } = await engine.compare(baseline, actual);
140
+ const compared = (part, image) => job.include?.includes(part) ? {
141
+ [`${part}Png`]: resized ? encodePng(image) : job[part]
142
+ } : {};
140
143
  return {
141
144
  kind: "compared",
142
145
  baselineSize,
143
146
  actualSize,
144
147
  ...resized && { resized },
145
148
  ...result,
146
- ...diff && { diffPng: encodePng(diff) }
149
+ ...diff && { diffPng: encodePng(diff) },
150
+ ...compared("baseline", baseline),
151
+ ...compared("actual", actual)
147
152
  };
148
153
  };
149
154
  var runJob = async (job) => runCompare(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "visual-regression-compare",
3
3
  "description": "Tool-agnostic image comparison for visual regression testing: pairs baseline and actual screenshots, runs a pluggable diff engine, applies limits, writes .actual and .diff files and a visual-regression-manifest run manifest. A CLI for folders of images and a library for test-runner adapters.",
4
- "version": "1.0.0-beta.0",
4
+ "version": "1.0.0-beta.1",
5
5
  "author": "Jakub Freisler <jakub.freisler@frsource.org>",
6
6
  "homepage": "https://visual-regression.dev/compare-cli",
7
7
  "repository": {