Scan your whole stack
From OX Research Newsroom
Are you using @variance-authority/raster?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v0.37.0
@variance-authority/raster was last scanned on 29 Nov 2026 at version 0.37.0. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 0.37.0 LATEST | 29 Nov 2026 | No rules fired |
| 0.36.0 | 28 Nov 2026 | No rules fired |
| 0.35.0 | 22 Nov 2026 | No rules fired |
| 0.32.0 | 13 Nov 2026 | Not shown |
| 0.30.0 | 11 Nov 2026 | Not shown |
Findings for v0.37.0. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 0.37.0; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
Measure a difference that was never zero, watch it drift, and refuse to photograph a subject that will not hold still.
Part of Variance Authority.
Point your coding agent at llms.txt.
Three things, and the first two are not served by any snapshot tool you already run.
Measuring a difference that is allowed to be non-zero. Two renderers that
never agreed, a font stack that is always slightly off, a compression pass that
always softens an edge — none of those has to be eliminated before you can watch
it, because what gets measured is the disagreement rather than either side of
it. observeDifference records the difference as it stands today;
compareDifferenceObservations reports how it changed since you last recorded
it.
Keeping severity and amount apart. A pixel count collapses them into one
number, and the number is then dominated by area — which is how a one-pixel
spacing change reports thousands of differing pixels and means nothing by it.
The result here is a per-pixel field plus a curve C(t), the proportion of the
image differing at severity t or above, so a broad weak change and a small
severe one stop looking alike.
Deciding whether a subject is worth photographing, without photographing it.
A subject is one named UI state you asked for and can ask for again. The usual
instability check shoots, waits, shoots again, and repeats until two frames
agree: two captures minimum on every subject, on the most expensive step in the
pipeline, and when it finally succeeds nobody learns which component would not
sit still. gateStability compares two documents instead — markup plus the
CSS that applies, no image — and one disagreement is the answer.
The rest of the package is the contracts those steps and the wider pipeline are written against: what a render document assembles to, what a renderer promises, what a baseline store promises, and which comparison policy a number came from.
Use @variance-authority/raster when you already have decoded pixels, or when
you are wiring your own pipeline and need the contracts around rendering,
storage, plans and stability.
It does not decode PNGs, launch a browser, write a baseline, or choose a test
runner. If what you want is visual regression tests running end to end from a
project config, install
@variance-authority/cli
instead and never import this package directly.
Each capability this one leaves out is a separate package, named for the one thing it requires:
| package | requires | what it adds |
|---|---|---|
png |
a PNG codec | decodeImage(bytes) → a NormalizedImage, and @variance-authority/png/difference for the PNG-in, numbers-out form of everything below |
playwright |
a browser | a Renderer that paints an assembled document, one browser per run |
store |
a filesystem | a durable RasterStore over a directory or git-LFS |
remote |
a socket | a Renderer or RasterStore on the far side of an HTTP hop |
observe |
a PNG codec | compares two documents or rasters and returns one observation |
Nothing here imports any of them, so extending your own Playwright tests with this vocabulary costs you no second browser, and keeping baselines somewhere this project has never heard of costs you no disk.
Node 22 or newer. The package is ESM-only — import works, require does not.
Its one dependency is @variance-authority/core; there are no peers, and
installing it installs no browser, codec, filesystem client or HTTP client.
npm install --save-dev @variance-authority/raster @variance-authority/core
@variance-authority/raster/difference is a second entrypoint with its own
question. Run this file as-is:
// drift.mjs — node drift.mjs
import {
YIQ_DISTANCE,
observeDifference,
compareDifferenceObservations,
fieldStatistics,
} from '@variance-authority/raster/difference';
const WIDTH = 120;
const HEIGHT = 40;
// pixelmatch thresholds you already run, squared: 0.05, 0.1, 0.2, 0.4.
const LEVELS = [0.0025, 0.01, 0.04, 0.16];
// Stands in for two decoded screenshots: a white page with one dark band on it.
function panel({ left, ink }) {
const data = new Uint8Array(WIDTH * HEIGHT * 4).fill(255);
for (let y = 12; y < 28; y += 1) {
for (let x = left; x < left + 60; x += 1) {
const at = (y * WIDTH + x) * 4;
data[at] = ink;
data[at + 1] = ink;
data[at + 2] = ink;
}
}
return { width: WIDTH, height: HEIGHT, data, colorSpace: 'srgb', alphaMode: 'opaque' };
}
const chromium = panel({ left: 20, ink: 34 });
const webkit = panel({ left: 20, ink: 46 }); // never agreed: WebKit lays the ink down lighter
const webkitToday = panel({ left: 21, ink: 46 }); // and today the band sits one pixel right
const accepted = await observeDifference({
firstImage: chromium,
secondImage: webkit,
metric: YIQ_DISTANCE,
severityLevels: LEVELS,
});
const today = await observeDifference({
firstImage: chromium,
secondImage: webkitToday,
metric: YIQ_DISTANCE,
severityLevels: LEVELS,
});
const moved = compareDifferenceObservations(accepted, today);
console.log(
'changed pixels %d -> %d',
fieldStatistics(accepted.field).changedPixels,
fieldStatistics(today.field).changedPixels,
);
console.log(
'peak severity %s -> %s',
moved.summary.baselineMaximum.toFixed(4),
moved.summary.currentMaximum.toFixed(4),
);
for (const point of moved.curveDelta) {
console.log(
'severity >= %s %d -> %d pixels (%s%% of the image)',
point.severity.toFixed(4),
point.baselinePixelCount,
point.currentPixelCount,
(point.currentImageRatio * 100).toFixed(2),
);
}
console.log(
'field delta %d x %d signed values',
moved.fieldDelta.signed.width,
moved.fieldDelta.signed.height,
);
changed pixels 960 -> 976
peak severity 0.0021 -> 0.7008
severity >= 0.0025 0 -> 32 pixels (0.67% of the image)
severity >= 0.0100 0 -> 32 pixels (0.67% of the image)
severity >= 0.0400 0 -> 32 pixels (0.67% of the image)
severity >= 0.1600 0 -> 32 pixels (0.67% of the image)
field delta 120 x 40 signed values
A pixel count reports sixteen more changed pixels, which is indistinguishable
from noise. The curve reports that thirty-two pixels crossed every level you
declared when none had before, and the peak went from 0.0021 to 0.7008 —
the standing ink disagreement stayed exactly where it was, and something new
landed on top of it.
To get NormalizedImage values out of real screenshots, decode them:
decodeImage(bytes) from
@variance-authority/png/difference
is the supported route, and observePngDifference in the same module does the
decode and the observation in one call. This package never decodes anything; it
takes row-major RGBA, 8 bits per channel, with colorSpace and alphaMode
declared by whoever decoded it.
observeDifference returns a DifferenceObservation. Abridged, from the run
above:
{
formatVersion: 'variance-difference/1',
metric: {
name: 'yiq-distance',
version: '1',
parameters: { alphaBackground: 'white' },
unit: 'yiq-normalized',
range: { minimum: 0, maximum: 1 },
},
image: { width: 120, height: 40, colorSpace: 'srgb', alphaMode: 'opaque' },
normalization: { version: '1', parameters: { flattenOnto: 'none' } },
field: { width: 120, height: 40, values: Float32Array(4800) },
curve: [
{ severity: 0.0025, pixelCount: 0, imageRatio: 0 },
{ severity: 0.01, pixelCount: 0, imageRatio: 0 },
{ severity: 0.04, pixelCount: 0, imageRatio: 0 },
{ severity: 0.16, pixelCount: 0, imageRatio: 0 },
],
sourceHashes: {
firstImage: 'v1:e2d138c2c5d1c538520deb56b8b31f9d',
secondImage: 'v1:d28fb7c162c3712ab87bc2ec091cf739',
},
}
field.values is one non-negative number per pixel, row-major, where 0 means
measured and equal rather than unmeasured — a metric that cannot evaluate a
pixel throws instead of writing a zero. curve is that field counted at each
level you asked for. Everything else is what a later observation has to match
before the two can be compared at all; compareDifferenceObservations throws
IncomparableObservationsError when they do not, and comparabilityReasons
returns every mismatch at once if you would rather check first.
compareDifferenceObservations returns a DifferenceComparison whose three
interesting members are:
curveDelta — one entry per severity level, giving both observations'
pixel counts and ratios and the difference between them. Small enough to
store and graph. This is what the loop above printed.fieldDelta — { signed, increase, decrease }, each a full-resolution
width × height field. signed may go negative; increase and decrease
are its two halves as magnitudes. Use these when something downstream has to
cluster, attribute or draw the change.summary — baselineMean, currentMean, meanDelta, baselineMaximum,
currentMaximum, maximumDelta, totalIncrease, totalDecrease.There is no threshold, ranking, grouping, alignment, resizing or status field anywhere in the result, and no place to put one. That is what lets one stored observation outlive several generations of the policy reading it.
severityLevels is required and has no default, because a level is a policy and
the library cannot infer yours. Two ways to pick:
YIQ_DISTANCE performs the same
arithmetic as pixelmatch, divided by its own maximum, so
severity === threshold². yiqSeverityForThreshold(0.1) returns 0.01;
yiqThresholdForSeverity goes back. The four levels in the sample are
pixelmatch thresholds 0.05, 0.1, 0.2 and 0.4. Playwright's
toHaveScreenshot({ threshold }) and jest-image-snapshot both run
pixelmatch, so a curve can be quoted against a setting your team already
argued about.severityBetweenColors gives
the severity two opaque colours differ by without rendering anything — a
design token changing #2d6cdf → #b5179e is severity 0.153, so you can
put a level either side of it before the change lands.Levels are sorted and de-duplicated for you; a negative or non-finite level throws.
C(0) is 1.0 for every field, including one taken from two identical
images, because every pixel differs by at least nothing. If the question is
"did anything change at all", fieldStatistics(field).changedPixels is the
field that answers it — it counts D > 0 strictly. fieldStatistics also
returns mean, maximum and totalPixels.0.933,
so a greyscale subject cannot produce a severity above that however wrong it
is.observeDifference refuses rather than adapting. Differing width or height,
colorSpace or alphaMode all throw DifferenceFieldError naming both sides,
and so does a data array whose length is not width * height * 4. A subject
that grew by a row is a finding, and compositing it onto a union box would
decide on your behalf that it was not one — align or resize upstream, where
you can decide whether the change was intended.
The one transform available is opt-in. flattenOnto names an opaque colour —
observeDifference({ normalization: { flattenOnto: { red, green, blue } } })
composites straight alpha onto it before measuring, and records
which colour it used in normalization.parameters so two observations flattened
differently refuse to compare.
DiffPolicy — the threshold-and-antialiasing pair the rest of the pipeline
compares under. It has two knobs: threshold, the per-pixel colour distance
above which a pixel counts as changed, and includeAA, whether antialiased
pixels count at all. The curve reproduces the first and cannot reproduce the
second: pixelmatch decides antialiasing from a neighbourhood of both images,
so it can treat two pixels sharing an identical difference value oppositely,
and no threshold on any per-pixel field gets there because the decision is not a
property of the pixel. Keep both — the field for how big a change is, the
policy for whether a renderer's antialiasing counts as a change at all.
gateStability takes documents of one subject that ought to be identical and
returns whether to render. A documentDigest comes from
@variance-authority/core/format, over the same RenderDocument you would
render:
// gate.mjs — node gate.mjs
import { documentDigest } from '@variance-authority/core/format';
import { gateStability, summarizeGate } from '@variance-authority/raster';
const document = {
documentVersion: 1,
subject: { id: 'ds/Badge:default', kind: 'story' },
html: '<span class="badge">3 new</span>',
frame: { html: {}, body: {}, ancestors: [{ tag: 'div', attributes: { class: 'app' } }] },
css: ['.badge{padding:2px 6px;border-radius:9px}'],
viewport: { width: 320, height: 120, deviceScaleFactor: 1 },
inherited: { 'font-size': '14px' },
fonts: ['Inter'],
diagnostics: [],
};
// The second read of a subject that would not sit still.
const moved = { ...document, html: '<span class="badge">4 new</span>' };
console.log(documentDigest(document), documentDigest(moved));
const steady = gateStability([
{ documentDigest: documentDigest(document) },
{ documentDigest: documentDigest(document) },
]);
console.log(steady.state, steady.render, steady.because);
const restless = gateStability([
{ documentDigest: documentDigest(document) },
{ documentDigest: documentDigest(moved) },
]);
console.log(summarizeGate(restless));
v1:c1fa2a124e02572a12b3e0cc12451d30 v1:454a38fc5a9715598090cdb2bb6776d3
stable true 2 documents of this subject are identical
[unstable] this subject was still changing when it was observed, so no image was taken.
Re-photographing it until two frames agree would hide this and cost every run;
the fix is in the component named below.
two documents of this subject at one commit disagree, so it was moving when it was observed and no image was taken. Supply snapshots to learn where
state has three values, not two. With no sample, or only one, you get
unknown — a single sample proves nothing, and printing it as stable would be a
verdict resting on a comparison nobody made. Nothing here retries and nothing
here renders an image.
Pass a snapshot alongside each digest and an unstable verdict includes an
instability naming the component and the property that changed, rather than
only saying that something did:
gateStability([
{ documentDigest: firstDigest, snapshot: firstSnapshot },
{ documentDigest: secondDigest, snapshot: secondSnapshot },
]); Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.