visual-wasm
The visual audit suite as WebAssembly: backdrop sampling, layout and pixel audits, baseline diffs and overlays on raw canvas RGBA.
Layer L3. visual-audit, pixel-diff and visual-evidence behind a WASM boundary for the
browser, extensions and Workers. The package translates, it does not judge: flat columns and RGBA
bytes go in, reports in the shared model (a11y-report) come out.
Status
New, not yet released. Crate visual-wasm and npm package @casoon/visual-wasm (built by
packages/visual-wasm/build.mjs). The consumer is liveaudit, which loads the package only when
the user turns the visual check on.
Structure
The logic sits in plain functions (Capture, build_boxes, run_audit_geometry); the
wasm_bindgen wrappers only translate errors and results. Native tests cover that core.
Public surface
new VisualScan(width, height, dpr, rgba), then sampleBackdrops, runAudit, diffAgainst,
renderOverlay, renderOverlayLayer; and the free function runAuditGeometry for a run without
screenshot. Method names are camelCase, as in @casoon/a11y-wasm. Signatures, the flags bit
layout and the coordinate systems are in the
crate README;
the TypeScript types of the report are hand-written to mirror a11y-report and a test compares
the fields.
runAudittakes the columnsnodeIds,parentIdx(-1for none),rectsXywh,flags(bits: text, interactive, image, fixed/sticky, overflow clips, two-dimensional), the optionaltextColorsand the paint-order pairtopNodeCounts/topNodeIdx(per box a count,-1for “no hit test”, and the concatenated box indices of the topmost nodes at the sample points). The fieldsin_running_text,inline_level,native_control,essentialanddestinationofVisualBoxhave no bit or column: no rule reads them. The host computes the pair withelementsFromPointat the centre and four inset corners of each box, ascollect.mjsofvisual-auditdoes.sampleBackdropsreturns luminance arrays in the shape ofa11y_dom::Backdrop, ornullper rect that cannot be sampled.@casoon/a11y-wasmdoes not take them yet; the shape is the contract for when it does.diffAgainstreturns{ outcome, report }; an empty baseline ismissing_baseline.
No PNG, no hash
The browser supplies RGBA8, so the bundle has no PNG codec and no SHA-256 (visual-evidence
without hash and png, pixel-diff without png). Hosts that have PNG bytes (auditmysite)
use the native crates instead.
Not run is visible
- Without a screenshot (
runAuditGeometry, for example a tainted canvas), the pixel rules appear inrule_runswithnot_run: "capability_missing"and a reason. - Without paint-order data (
topNodeCountsempty)visual/fixed-obscures-contentiscapability_missing. - Without boxes the geometry rules are not run either, and an empty baseline gives
capability_missingforvisual/regression. - Contradicting columns, unknown flag bits, a parent index out of range and non-finite numbers
throw an
Error; they never produce a report that looks clean.
Size
Measured on 2026-12-03 (wasm-opt after the build, gzip -9):
| Value | |
|---|---|
| WASM, raw | 221.5 KiB (226,851 bytes) |
| WASM, gzip -9 | 98.5 KiB (100,848 bytes) |
Budget (build.mjs) | 103 KiB gzip |
Dependencies
Downward: visual-audit (without de unless the crate feature de is on, which is the
default), visual-evidence (without hash/png), pixel-diff (without png), a11y-report
and a11y-dom. Upward: nobody inside this repository.
Limits
Only the colour threshold of the baseline comparison is a parameter; the remaining tolerances are
the defaults of BaselinePolicy. Overlays draw frames, fills and numeric badges only. The module
is single-threaded: run a large screenshot in a worker.