<p align="center">
  <a href="https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust">
    <picture>
      <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/qrcode-ai-com/.github/main/profile/assets/banner-browser-dark.gif?v=74f967bc6d23">
      <img src="https://raw.githubusercontent.com/qrcode-ai-com/.github/main/profile/assets/banner-browser-light.gif?v=1ab06a2a50e5" alt="QR Code &amp; Barcode Scanner for the browser: the JavaScript and TypeScript logos, the quick start, and a QR code and a barcode read from a camera" width="100%">
    </picture>
  </a>
</p>

# @qrcode-ai-com/qrcode-barcode-scanner-wasm

<!-- qrcode-ai-readme-actions:v2 -->

### Ask AI

[![ChatGPT](https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/actions/chatgpt-v2.svg)](https://chatgpt.com/?q=Help%20me%20understand%20%40qrcode-ai-com%2Fqrcode-barcode-scanner-wasm%20%28crates%2Fqrcode-ai-scanner-wasm%2FREADME.md%29%20for%20QR%20Code%20%26%20Barcode%20Scanner%2C%20the%20open-source%20scanner.%20Source%20documentation%3B%20publication%20is%20not%20implied.%20Provided%20README%20context%20%28verify%20against%20the%20sources%29%3A%20Use%20the%20browser%20WebAssembly%20package%20to%20decode%20QR%20codes%20and%20barcodes%20from%20imported%20image%20bytes%20or%20application-supplied%20frames.%20Its%20JavaScript%20entry%20points%20also%20expose%20camera%2C%20tracking%20and%20overlay%20helpers%20documented%20below%3B%20your%20page%20remains%20responsible%20for%20permissions%20and%20user%20interaction.%20Start%20with%20a%20worker-based%20image%20scan%20before%20adding%20a%20live-camera%20interface%20or%20optional%20destination%20transport.%20Read%20the%20public%20documentation%20below.%20Explain%20what%20this%20destination%20does%2C%20its%20documented%20installation%20or%20access%20steps%2C%20a%20minimal%20example%20if%20supported%2C%20prerequisites%2C%20limitations%20and%20license.%20Distinguish%20published%20packages%20from%20working%20source%20and%20preparation.%20Cite%20your%20sources%3B%20if%20a%20page%20is%20unavailable%20or%20a%20fact%20cannot%20be%20checked%2C%20say%20so.%20Do%20not%20invent%20installation%20commands%2C%20benchmark%20results%20or%20comparisons.%20Answer%20in%20my%20language.%20Public%20sources%3A%20https%3A%2F%2Fgithub.com%2Fqrcode-ai-com%2Fqrcode-barcode-scanner-rust%2Fblob%2Fmain%2Fcrates%2Fqrcode-ai-scanner-wasm%2FREADME.md%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fqr-code-scanner%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fbarcode-scanner%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fqr-code-scanner%2Fsdk%2Fjavascript%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fbarcode-scanner%2Fsdk%2Fjavascript%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fqr-code-generator%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fbarcode-generator)
[![Claude](https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/actions/claude-v2.svg)](https://claude.ai/new?q=Help%20me%20understand%20%40qrcode-ai-com%2Fqrcode-barcode-scanner-wasm%20%28crates%2Fqrcode-ai-scanner-wasm%2FREADME.md%29%20for%20QR%20Code%20%26%20Barcode%20Scanner%2C%20the%20open-source%20scanner.%20Source%20documentation%3B%20publication%20is%20not%20implied.%20Provided%20README%20context%20%28verify%20against%20the%20sources%29%3A%20Use%20the%20browser%20WebAssembly%20package%20to%20decode%20QR%20codes%20and%20barcodes%20from%20imported%20image%20bytes%20or%20application-supplied%20frames.%20Its%20JavaScript%20entry%20points%20also%20expose%20camera%2C%20tracking%20and%20overlay%20helpers%20documented%20below%3B%20your%20page%20remains%20responsible%20for%20permissions%20and%20user%20interaction.%20Start%20with%20a%20worker-based%20image%20scan%20before%20adding%20a%20live-camera%20interface%20or%20optional%20destination%20transport.%20Read%20the%20public%20documentation%20below.%20Explain%20what%20this%20destination%20does%2C%20its%20documented%20installation%20or%20access%20steps%2C%20a%20minimal%20example%20if%20supported%2C%20prerequisites%2C%20limitations%20and%20license.%20Distinguish%20published%20packages%20from%20working%20source%20and%20preparation.%20Cite%20your%20sources%3B%20if%20a%20page%20is%20unavailable%20or%20a%20fact%20cannot%20be%20checked%2C%20say%20so.%20Do%20not%20invent%20installation%20commands%2C%20benchmark%20results%20or%20comparisons.%20Answer%20in%20my%20language.%20Public%20sources%3A%20https%3A%2F%2Fgithub.com%2Fqrcode-ai-com%2Fqrcode-barcode-scanner-rust%2Fblob%2Fmain%2Fcrates%2Fqrcode-ai-scanner-wasm%2FREADME.md%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fqr-code-scanner%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fbarcode-scanner%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fqr-code-scanner%2Fsdk%2Fjavascript%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fbarcode-scanner%2Fsdk%2Fjavascript%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fqr-code-generator%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fbarcode-generator)
[![Gemini](https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/actions/gemini-v2.svg)](https://gemini.google.com/)
[![Grok](https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/actions/grok-v2.svg)](https://grok.com/?q=Help%20me%20understand%20%40qrcode-ai-com%2Fqrcode-barcode-scanner-wasm%20%28crates%2Fqrcode-ai-scanner-wasm%2FREADME.md%29%20for%20QR%20Code%20%26%20Barcode%20Scanner%2C%20the%20open-source%20scanner.%20Source%20documentation%3B%20publication%20is%20not%20implied.%20Provided%20README%20context%20%28verify%20against%20the%20sources%29%3A%20Use%20the%20browser%20WebAssembly%20package%20to%20decode%20QR%20codes%20and%20barcodes%20from%20imported%20image%20bytes%20or%20application-supplied%20frames.%20Its%20JavaScript%20entry%20points%20also%20expose%20camera%2C%20tracking%20and%20overlay%20helpers%20documented%20below%3B%20your%20page%20remains%20responsible%20for%20permissions%20and%20user%20interaction.%20Start%20with%20a%20worker-based%20image%20scan%20before%20adding%20a%20live-camera%20interface%20or%20optional%20destination%20transport.%20Read%20the%20public%20documentation%20below.%20Explain%20what%20this%20destination%20does%2C%20its%20documented%20installation%20or%20access%20steps%2C%20a%20minimal%20example%20if%20supported%2C%20prerequisites%2C%20limitations%20and%20license.%20Distinguish%20published%20packages%20from%20working%20source%20and%20preparation.%20Cite%20your%20sources%3B%20if%20a%20page%20is%20unavailable%20or%20a%20fact%20cannot%20be%20checked%2C%20say%20so.%20Do%20not%20invent%20installation%20commands%2C%20benchmark%20results%20or%20comparisons.%20Answer%20in%20my%20language.%20Public%20sources%3A%20https%3A%2F%2Fgithub.com%2Fqrcode-ai-com%2Fqrcode-barcode-scanner-rust%2Fblob%2Fmain%2Fcrates%2Fqrcode-ai-scanner-wasm%2FREADME.md%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fqr-code-scanner%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fbarcode-scanner%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fqr-code-scanner%2Fsdk%2Fjavascript%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fbarcode-scanner%2Fsdk%2Fjavascript%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fqr-code-generator%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fbarcode-generator)
[![Perplexity](https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/actions/perplexity-v2.svg)](https://www.perplexity.ai/?q=Help%20me%20understand%20%40qrcode-ai-com%2Fqrcode-barcode-scanner-wasm%20%28crates%2Fqrcode-ai-scanner-wasm%2FREADME.md%29%20for%20QR%20Code%20%26%20Barcode%20Scanner%2C%20the%20open-source%20scanner.%20Source%20documentation%3B%20publication%20is%20not%20implied.%20Provided%20README%20context%20%28verify%20against%20the%20sources%29%3A%20Use%20the%20browser%20WebAssembly%20package%20to%20decode%20QR%20codes%20and%20barcodes%20from%20imported%20image%20bytes%20or%20application-supplied%20frames.%20Its%20JavaScript%20entry%20points%20also%20expose%20camera%2C%20tracking%20and%20overlay%20helpers%20documented%20below%3B%20your%20page%20remains%20responsible%20for%20permissions%20and%20user%20interaction.%20Start%20with%20a%20worker-based%20image%20scan%20before%20adding%20a%20live-camera%20interface%20or%20optional%20destination%20transport.%20Read%20the%20public%20documentation%20below.%20Explain%20what%20this%20destination%20does%2C%20its%20documented%20installation%20or%20access%20steps%2C%20a%20minimal%20example%20if%20supported%2C%20prerequisites%2C%20limitations%20and%20license.%20Distinguish%20published%20packages%20from%20working%20source%20and%20preparation.%20Cite%20your%20sources%3B%20if%20a%20page%20is%20unavailable%20or%20a%20fact%20cannot%20be%20checked%2C%20say%20so.%20Do%20not%20invent%20installation%20commands%2C%20benchmark%20results%20or%20comparisons.%20Answer%20in%20my%20language.%20Public%20sources%3A%20https%3A%2F%2Fgithub.com%2Fqrcode-ai-com%2Fqrcode-barcode-scanner-rust%2Fblob%2Fmain%2Fcrates%2Fqrcode-ai-scanner-wasm%2FREADME.md%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fqr-code-scanner%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fbarcode-scanner%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fqr-code-scanner%2Fsdk%2Fjavascript%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fbarcode-scanner%2Fsdk%2Fjavascript%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fqr-code-generator%20https%3A%2F%2Fqrcode-ai.com%2Fen-US%2Fbarcode-generator)
[![Copilot](https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/actions/copilot-v2.svg)](https://copilot.com/)
[![DeepSeek](https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/actions/deepseek-v2.svg)](https://chat.deepseek.com/)
[![Meta AI](https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/actions/meta-ai-v2.svg)](https://www.meta.ai/)
[![Qwen](https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/actions/qwen-v2.svg)](https://qwen.ai/)

Choose an AI assistant to explain this destination using its public sources. Gemini opens gemini.google.com. Gemini, Copilot, DeepSeek, Meta AI and Qwen require pasting the prompt below; the other links include it in their URL. Sign-in or a manual paste may still be required. Check the answer against the documentation.

<details>
<summary>Copy the plain-text prompt</summary>

Use the code block's copy control, or select its complete text, then paste it into your assistant.

```text
Help me understand @qrcode-ai-com/qrcode-barcode-scanner-wasm (crates/qrcode-ai-scanner-wasm/README.md) for QR Code & Barcode Scanner, the open-source scanner. Source documentation; publication is not implied. Provided README context (verify against the sources): Use the browser WebAssembly package to decode QR codes and barcodes from imported image bytes or application-supplied frames. Its JavaScript entry points also expose camera, tracking and overlay helpers documented below; your page remains responsible for permissions and user interaction. Start with a worker-based image scan before adding a live-camera interface or optional destination transport. Read the public documentation below. Explain what this destination does, its documented installation or access steps, a minimal example if supported, prerequisites, limitations and license. Distinguish published packages from working source and preparation. Cite your sources; if a page is unavailable or a fact cannot be checked, say so. Do not invent installation commands, benchmark results or comparisons. Answer in my language. Public sources: https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust/blob/main/crates/qrcode-ai-scanner-wasm/README.md https://qrcode-ai.com/en-US/qr-code-scanner https://qrcode-ai.com/en-US/barcode-scanner https://qrcode-ai.com/en-US/qr-code-scanner/sdk/javascript https://qrcode-ai.com/en-US/barcode-scanner/sdk/javascript https://qrcode-ai.com/en-US/qr-code-generator https://qrcode-ai.com/en-US/barcode-generator
```

</details>

<!-- /qrcode-ai-readme-actions:v2 -->

Use the browser WebAssembly package to decode QR codes and barcodes from imported image bytes or application-supplied frames. Its JavaScript entry points also expose camera, tracking and overlay helpers documented below; your page remains responsible for permissions and user interaction. Start with a worker-based image scan before adding a live-camera interface or optional destination transport.

The [QR code scanner](https://qrcode-ai.com/en-US/qr-code-scanner) and [barcode scanner](https://qrcode-ai.com/en-US/barcode-scanner) are QR Code AI’s browser scanning entry points. For the corresponding development route, the [QR code scanner JavaScript guide](https://qrcode-ai.com/en-US/qr-code-scanner/sdk/javascript) and [barcode scanner JavaScript guide](https://qrcode-ai.com/en-US/barcode-scanner/sdk/javascript) connect this documentation to the two product journeys. If a product page is unavailable, the instructions and references in this README remain the starting point for this source directory.

To prepare a saved image for a browser worker, use the [QR code generator](https://qrcode-ai.com/en-US/qr-code-generator) or the [barcode generator](https://qrcode-ai.com/en-US/barcode-generator). Keep the original payload with the exported image so that you can compare the scan result with the value you intended to encode.

One portable browser WASM build of the
[qrcode-barcode-scanner](https://crates.io/crates/qrcode-barcode-scanner) engine —
QR decoding + scannability scoring for artistic / AI-generated QR codes.
Decoding is fully client-side; optional destination checks use only the transport you supply.

[QR Code AI](https://qrcode-ai.com/en-US/qr-code-scanner/sdk/javascript) uses the engine family for QR verification. To decode a
saved QR image or a barcode label in the browser, run the [browser image example](https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust/blob/v0.12.3/crates/qrcode-ai-scanner-wasm/examples/README.md#scan-an-image-headlesshtml).

<p align="center">
  <a href="https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust#get-started">
    <picture>
      <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/qrcode-ai-com/.github/main/profile/assets/how-browser-dark.gif?v=32206e525b2c">
      <img src="https://raw.githubusercontent.com/qrcode-ai-com/.github/main/profile/assets/how-browser-light.gif?v=248e5382e6cc" alt="How the browser package works, in three steps: install and initialize, pass an image or a camera frame to the engine in the page, and read the report" width="100%">
    </picture>
  </a>
</p>

## Install and try the packaged example

Use npm in a project directory to install the exact browser package:

```sh
npm install --save-exact @qrcode-ai-com/qrcode-barcode-scanner-wasm@0.12.3
```

No Rust toolchain or native addon is required. For working source, check the
selected version on [npm](https://www.npmjs.com/package/@qrcode-ai-com/qrcode-barcode-scanner-wasm)
before installation. The release's bundled WebAssembly and JavaScript files
must stay together; a source README does not establish registry availability.

To try image scanning without a bundler, use Python 3 as a local static server
from that project directory:

```sh
python3 -m http.server 8000 --bind 127.0.0.1 --directory node_modules/@qrcode-ai-com/qrcode-barcode-scanner-wasm
```

Open [the local image example](http://127.0.0.1:8000/examples/headless.html)
and import an image. The decoder runs in the packaged module worker. The
[examples guide](https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust/blob/main/crates/qrcode-ai-scanner-wasm/examples/README.md)
explains camera access, HTTPS and CSP requirements. Opening the HTML as a
`file://` URL does not support the module-worker flow.

## Scan with named options (0.12.1)

```js
import { loadScanner, isFinal } from "@qrcode-ai-com/qrcode-barcode-scanner-wasm/auto";

const scanner = await loadScanner();

// encoded bytes (PNG, JPEG, WebP, GIF): a Uint8Array or an ArrayBuffer
const report = scanner.scan(await file.arrayBuffer(), {
  profile: "full",
  formats: ["qr_code", "ean13"], // read these symbologies only
  budgetMs: 1500,
});
const texts = report.detections.map((detection) => detection.content.text);
if (!isFinal(report)) {
  // the time budget cut the scan: codes can be missing, and a null score
  // beside a detection means "not judged"
}

// raw RGBA pixels: an ImageData, or any { data, width, height }
const pixels = context.getImageData(0, 0, canvas.width, canvas.height);
const live = scanner.scanFrame(pixels, { budgetMs: 80 });
```

The scanner that `loadScanner()` resolves to carries `scan(bytes, options)` and
`scanFrame(frame, options)`. They call `scan_image` and `scan_frame` with the
options given by name, in any order, and return the engine's report unchanged.
The positional functions stay on the same object and behave as before.

| Option | What it sets |
|---|---|
| `profile` | `"full"`, `"fast"` or `"frame"`. Left out, `scan` uses `full` and `scanFrame` uses `frame`. |
| `formats` | The symbologies to read, by the names a report uses, such as `"qr_code"`, `"ean13"`, `"code128"` or `"data_matrix"`; `capabilities().symbologies` lists them. Left out or empty, every symbology is read. |
| `budgetMs` | The time budget in milliseconds, in place of the profile's. `0` removes the limit. |
| `retryBudgetMs` | The budget of one second scan, which runs only when the first report is not final. `0` removes the limit for that scan. |
| `maxDimension`, `maxPixels` | The largest accepted width or height, and the largest pixel count: whole numbers from 1. |
| `scoreSkipAxes`, `scoreSkipChecks`, `scorePreset` | The score options of `scan_image`. |
| `alphaBackground`, `alphaPalette` | The transparency options of `scan_image`. |

An option left out keeps the engine's default. A key that is not in this table
throws a `TypeError` that names it and lists the accepted keys, so a misspelling
such as `budget_ms` is never ignored. The engine checks each value and throws
as it does for a positional call: `[QRS-006]` for a number outside its domain
or an unknown `formats` name, and an error without a code for an unknown
profile, axis or check name.

`scan` takes a `Uint8Array` (a Node `Buffer` is one) or an `ArrayBuffer`.
`scanFrame` takes an `ImageData`, or any `{ data, width, height }` whose `data`
is a `Uint8Array` or a `Uint8ClampedArray` of RGBA bytes. Anything else throws
a `TypeError` before the engine is called.

### Final reports and one retry

`isFinal(report)` is `true` unless the time budget cut the scan
(`report.trace.budget_exhausted === true`). A cut report is a valid account of
what was read in time: it can miss codes, and its `score` can be `null` beside
a detection, which then means "not judged", never "unscannable".
`retryBudgetMs` gives the usual answer in the same call:

```js
// a short first scan and, only if the budget cut it, one scan with no limit
const report = scanner.scan(bytes, { budgetMs: 200, retryBudgetMs: 0 });
```

The second report is returned as it is, final or not, and a third scan never
runs. A scan occupies its thread until it returns, so give a long or unlimited
budget to a worker, not to the page's main thread.

### The same scanner in Node

The `/node` entry loads the same module in Node 18 or later. It reads the
package's own `.wasm` file from disk where `/auto` fetches it:

```js
import { readFile } from "node:fs/promises";
import { loadScanner, isFinal } from "@qrcode-ai-com/qrcode-barcode-scanner-wasm/node";

const scanner = await loadScanner();
const report = scanner.scan(await readFile("label.png"), { profile: "fast" });
```

Its scanner has the shape `/auto` resolves to: the module's exports, `scan`,
`scanFrame` and `variant`. A failure is a `ScannerInitError` with the codes of
`/auto`, and a file that cannot be read rejects with `asset_read_failed`.
`createScannerLoader({ wasmPath })` reads the file from another path or
`file:` URL. The entry is exported for Node alone, so a browser build that
imports it fails when it resolves the name. `/node` runs the bytes the browser
runs; for the native Node addon, see
[The same engine in other runtimes](#the-same-engine-in-other-runtimes).

### Without a loader

`bindScanner` from `/scan` gives the same two functions to a module you
initialized yourself. `/scan` is plain JavaScript that imports nothing:

```js
import init, * as scanner from "@qrcode-ai-com/qrcode-barcode-scanner-wasm";
import { bindScanner, isFinal } from "@qrcode-ai-com/qrcode-barcode-scanner-wasm/scan";

await init();
const { scan, scanFrame } = bindScanner(scanner);
const report = scan(pngBytes, { profile: "fast", formats: ["qr_code"] });
```

## Automatic loading, including module workers

```js
import { loadScanner } from "@qrcode-ai-com/qrcode-barcode-scanner-wasm/auto";

const scanner = await loadScanner();
const report = scanner.scan_image(pngBytes, "full");
const loadedVariant = scanner.variant; // "portable"
const scannerVersion = scanner.version();
```

Run this same code inside a module Worker for UI responsiveness. Capability
detection runs in that worker's realm before the scanner is compiled. It uses
small real WASM validation probes, never user-agent, browser-version or CPU
guesses. The package holds one module and it uses no SIMD, so an engine without
SIMD loads the same bytes as every other supported engine.
`scannerCapabilities().simd` remains a diagnostic only.

Vite resolves the one literal asset URL at build time; nothing is fetched before
the loader is called. No remote service is involved. Importing `/auto` is safe
during SSR; calling it requires browser/worker WebAssembly and fetch support.
The root import below loads the same module through wasm-pack's default
initialization and `initSync`; `/auto` adds the feature checks and typed
errors. Use `/auto` in both the worker and any main-thread fallback.

Concurrent `loadScanner()` calls share one promise, and a loaded scanner is
kept: later calls return the same instance and request nothing. There are no
automatic retries, reloads, or blind fallbacks after a network/compiler error.
What a failed attempt leaves behind depends on its cause, which
`error.retryable` states:

- `loader_import_failed`, `asset_network_failed`, `asset_http_failed` and
  `asset_read_failed` have `retryable: true`. The loader does not keep them:
  every caller already waiting receives the one rejection, and the next call
  starts a fresh attempt.
- Every other code has `retryable: false` and stays cached. The options, the
  runtime or the bytes themselves are at fault, so another attempt would end
  the same way, and later calls return the same rejection.

Call the loader again from an explicit user action, such as a retry button:

```js
import { loadScanner } from "@qrcode-ai-com/qrcode-barcode-scanner-wasm/auto";

retryButton.addEventListener("click", async () => {
  try {
    start(await loadScanner()); // a new attempt after a retryable failure
  } catch (error) {
    retryButton.hidden = !error.retryable;
    show(`The scanner did not load (${error.code}).`);
  }
});
```

Before 0.12.1 every rejection stayed cached, and a retry needed a new loader
from `createScannerLoader()`. That form still works: each loader has its own
state. After a failed import of the package's module, a browser can keep that
failure for the life of the page and answer the next import with it, without a
new request; reloading the page is then the retry.

The factory also accepts an optional `wasmUrl` for an asset pipeline that
cannot process package URLs. Keep that override on the same exact package
version. Standard Vite/module-worker use needs no URL override. `variant`
accepts `"auto"`, `"portable"` and `"compatible"`, the 0.10 name of this same
no-SIMD feature set; any other value, `"simd"` included, rejects with
`invalid_options`. The 0.10 `compatible/` export paths were removed: import the
package root instead, and `variant: "compatible"` still selects this module.

`ScannerInitError` carries a stable `code`, selected `variant`, `retryable`,
optional HTTP `status`, and original `cause`. Codes distinguish `wasm_unavailable`,
`wasm_features_unsupported`, `loader_import_failed`, `asset_network_failed`,
`asset_http_failed`, `asset_read_failed`, `binary_invalid`,
`wasm_validation_failed`, `wasm_compile_failed`, `wasm_instantiate_failed` and
`invalid_options`. Preserve the native cause for diagnosis; do not label every
compile failure as a browser or CPU incompatibility. These are JS loading
diagnostics, separate from the unchanged Rust/report/QRS error contract.
Serialize stable fields explicitly when crossing a worker boundary.
`binary_invalid` means the bytes lack a valid WASM magic/version header.
`wasm_validation_failed` retains ambiguity between malformed code and unexpected
requirements in a wrong/stale asset. Inspect its native cause and the actual
failing bytes rather than guessing a feature or CPU incompatibility.

The portable build is **not an MVP-only WASM binary**. Automatic loading uses
a conservative supported baseline: mutable globals, bulk memory, sign extension,
nontrapping float-to-int, multivalue and reference types. The probe tests these
together; it is not a measurement of the optimized binary's minimum requirements:

```wat
(module
  (memory 1) (table 1 funcref)
  (global (export "g") (mut i32) (i32.const 0))
  (func (result i32 i32)
    i32.const 0 i32.extend8_s drop
    f64.const 0 i32.trunc_sat_f64_s drop
    i32.const 0 i32.const 0 i32.const 0 memory.copy
    ref.null func drop
    i32.const 0 i32.const 0))
```

The owning build script compiles this crate and every dependency with SIMD
disabled, restricts optimization to that feature profile, then validates the
optimized module with SIMD forbidden. The package's `build-info.json` records
the module's SHA-256, the features its code actually uses (read instruction by
instruction), a digest of the compiled sources and locks, the build recipe and
the tool versions; the release inspection refuses a package whose bytes, inputs
or features disagree with it. Inspect each actual artifact before attributing a
failure to a feature: the 0.11.0 module's code uses bulk memory, sign extension
and nontrapping float-to-int, and Binaryen validation fails without each of
them. Mutable globals, multivalue and reference types complete the declared
loader baseline, a support policy rather than evidence that an unknown failing
asset uses all six features. Compatibility claims require actual browser
evidence; this path alone does not qualify historical browser floors, real
Safari, mobile devices, arbitrary CSP rules, or a consumer's deployed binary.

## Direct entry

```js
import init, { capabilities, scan_image, scan_frame } from "@qrcode-ai-com/qrcode-barcode-scanner-wasm";

await init(); // loads the wasm module once

// canvas/upload verification (the generator quality-gate path)
const report = scan_image(pngBytes, "fast");
const ok = report.detections.length > 0;
// null = no judgment, never a zero: with trace.budget_exhausted the budget
// cut it (argument #5, budget_ms: 0 = unbounded, scans without a cut; the
// clock starts once the image is decoded). Out-of-domain numbers throw
// [QRS-006]: a cap that is not a whole number from 1, a budget above
// 4294967295 ms (spec/02-profiles.md § Option domains)
const score = report.score?.value ?? null;
const judged = report.score !== null || !report.trace.budget_exhausted;

// live camera (ImageData — no PNG roundtrip)
const frame = ctx.getImageData(0, 0, w, h);
const live = scan_frame(new Uint8Array(frame.data.buffer), w, h);
// after profile and budget_ms, scan_frame takes scan_image's other options:
// max_dimension, max_pixels, score_skip_axes, score_skip_checks,
// alpha_background, alpha_palette, score_preset (same domains and errors).
// From 0.12.1 both functions end with formats, the symbologies to read
// (absent or empty: all of them), and bindScanner takes every option by name

// the readers compiled into the module: versions, engines, symbologies
// (which readers are included, not that an image decodes)
const { engines, symbologies } = capabilities();
```

Same versioned `ScanReport` contract as the native package — detections,
0-100 score with per-axis survival, synthetic UEC margin, actionable hints.

## Camera and visual selection (0.11.0)

`/camera` captures camera frames and follows the codes found in them:
`createCameraScanner`, `createDetectionTracker`, `projectVideoGeometry`,
`projectVideoPoint`, `contentKey`, `sameContent`, `TRACKER_LIMITS` and
`CameraScannerError`. `/camera-overlay` draws the tracked codes over the video
and shows the selected one exactly: `createCameraOverlay`, its pure helpers,
`DEFAULT_LABELS`, `TRACK_COLORS` and `CAMERA_OVERLAY_CSS`. Neither needs a UI
framework. Importing either requests no camera, touches no DOM and starts no
timer, so both import safely during server rendering. Decoding stays in your
module worker: the controller hands it the RGBA pixels of each frame and never
creates a decoder of its own.

```ts
import { createCameraScanner, createDetectionTracker }
  from '@qrcode-ai-com/qrcode-barcode-scanner-wasm/camera';
import { createCameraOverlay }
  from '@qrcode-ai-com/qrcode-barcode-scanner-wasm/camera-overlay';

// The container holds the video and is positioned (position: relative, for example).
const overlay = createCameraOverlay({
  video,
  container,
  mount: { rail: railSlot, readout: readoutSlot }, // recommended: below the video
});
const tracker = createDetectionTracker({
  onChange: (snapshot) => overlay.update(snapshot), // every snapshot, in order
  onError: reportUiError,
});
let worker = await startWorker(); // loads /auto once; each request calls scan_frame
const camera = createCameraScanner({
  video,
  tracker, // updated before onResult, reset whenever a capture session ends
  scanFrame: (rgba, width, height, { signal, frame }) => {
    // Copy pixels only when a thumbnail is due, before the buffer is transferred.
    if (overlay.wantsFrameImage()) {
      overlay.setFrameImage(new ImageData(new Uint8ClampedArray(rgba), width, height), frame);
    }
    return worker.scan(rgba, width, height, { signal });
  },
  recover: async (_cause, { signal }) => {
    worker.terminate();
    worker = await startWorker({ signal });
  },
  onState: (change) => showCameraState(change),
  onError: (error) => showCameraError(error.code),
});

// From the camera button: the camera needs a secure context (HTTPS or localhost).
await camera.start();

// On unmount, in any order:
camera.stop();
tracker.destroy();
overlay.destroy();
```

`startWorker()` and `worker.scan()` are yours. The worker loads `/auto` once and
answers each request with `scan_frame(rgba, width, height)`, which uses the
`frame` profile; `worker.scan()` returns a promise of that `ScanReport`.
Transfer `rgba.buffer` to the worker rather than copying it. The package's
`examples/scanner.worker.js` is such a worker, and `examples/camera.js` wires
these parts in a page (see Examples below). That worker takes the named
options of the table above as fields of each scan request, beside the pixels,
so one worker can also read a single symbology or give a second scan its own
budget; `examples/README.md` lists its requests. Keep one loaded scanner for every
frame and every image you scan: image scanning and the camera then share one
WASM module and one initialization.

**Aztec codes.** The engine reads an Aztec code only when the code lies over
the center of the image it scans, in every profile, so an Aztec code off to
one side of a camera frame goes unread: ask users to center it.

**Capture.** `start()` opens the camera. `state` is `idle`, `starting`,
`running`, `recovering`, `stopped` or `failed`, and `onState` receives every
transition with its `reason` and every change of `muted` or `stalled`. Frames
follow `requestVideoFrameCallback` where the browser has it, otherwise a timer
that skips a capture whose sampled pixels have not changed. The scanned frame's
long edge is capped at `maxDimension` (1280 by default; a smaller cap is faster
but can lose narrow barcodes), the next frame is requested `intervalMs` (100)
after each result, and one decode is in flight at a time, across stops and
restarts. A decode slower than `decodeTimeoutMs` (5000) aborts
`context.signal`, the only abort the controller makes: your adapter must then
terminate its worker before it rejects, and never settle while the decoder
still works. With `recover`, the state becomes `recovering` until your
replacement decoder is ready, at most `maxRecoveries` (2) times per session,
each within `recoverTimeoutMs` (20000); without it, a timeout fails the
session. `stop()`, a hidden page, `pagehide` and an ended track release the
camera and discard late permission answers and results; call `start()` again
once the page is visible. `setConstraints()` switches cameras; the default
constraints are `{ facingMode: { ideal: 'environment' } }`.

A failed session sends one `CameraScannerError` to `onError`, and a `start()`
still pending rejects with that same error. Its `cause` keeps the native error,
and its `code` is `unsupported` (no `getUserMedia`, outside a secure context for
example), `permission_denied`, `device_not_found`, `device_busy`,
`constraints_unsatisfied`, `start_failed`, `play_failed`, `canvas_unavailable`,
`stream_ended`, `decode_failed`, `decode_timeout`, `recover_failed` or
`callback_failed` (a throw from `onResult` or `tracker.update` fails the
session; one from `onState` or the tracker's reset is only reported).

**Tracking.** `createDetectionTracker()` follows each measured copy of a code
from frame to frame: two printed copies of one content are two spatial tracks,
and a read without a measured position becomes a content track, which claims no
position. A track keeps its `id` and its display `slot` for life, and decoded
results (`snapshot.results`, one per content) are kept apart from the tracks. A
`ScanReport` proves a code gone only when its trace shows no budget cut and no
read or detection saturation, and one copy of a code still read gone only when
its occurrences are not saturated either; a bare array of detections proves
nothing unless you pass `{ complete: true }`. To filter a report, pass
`{ ...report, detections: kept }` and choose `kept` by content, never by
position. Outlines and identities expire by time, not by counting reports.
`update()`, `snapshot()`, `advance()`, `reset()` and `clear()` each return a new
`TrackerSnapshot` object, whose `detection` fields are the engine's objects, by
reference; a successful `forget(id)` returns `true` and sends its snapshot to
`onChange`.

| Option | Default | Meaning |
| --- | --- | --- |
| `smoothing` | `0.35` | weight of each new measurement; `{ kind: 'none' }` turns smoothing off |
| `staleMs` | `1200` | geometry older than this is withheld, and tracked or held tracks become lost |
| `reacquireMs` | `2000` | how long an identity survives without new evidence; at least `staleMs` |
| `maxMisses` | `1` | consecutive complete misses shown as held before a track is lost |
| `retainMs` | `Infinity` | how long a result without a live track is kept; at least `reacquireMs` |
| `maxResults` | `32` | results kept; at least 16 |

`holdMs`, which earlier 0.11 development builds accepted, now throws a TypeError
that names `staleMs` and `reacquireMs`.

**Slow devices.** A frame keeps its geometry only when its result arrives less
than `staleMs` after the frame's `observedAt`. A later result still updates the
decoded results, but it moves no outline: the spatial tracks of that code age,
turn lost and lose their outlines until faster frames return. If capture,
transfer and decoding can take that long where your page runs, raise `staleMs`,
and `reacquireMs` with it, since it must stay at least `staleMs`. The cost: when
the evidence stops (a stalled camera, a hung decoder, reports cut by their
budget), an outline stays at its last measured position for up to `staleMs`.

**Overlay.** `createCameraOverlay({ video, container })` draws from tracker
snapshots: one rounded four-corner outline for each valid measured quad, a line
for a scan line and dots for partial points. It never invents a rectangle, and
draws nothing for a content track, a lost track or geometry the tracker
withheld. Each track keeps a number (`slot + 1`) and a color
(`TRACK_COLORS[slot % 8]`) for life, and a code measured entirely outside the
visible area gets a numbered badge at the edge of the view. Deliver every
`onChange` snapshot, in order: an older snapshot is ignored, an array throws a
TypeError, and after `destroy()` an update does nothing. The scene, the rail
and the readout share one selected code, chosen automatically until the user
picks one or you call `select(id)`; `select(null)` returns to automatic choice,
and `select()` returns `false` for an unknown id. Dimming and blur, and a color
wash that is off by default (`effects`), leave sharp cutouts only around quads
that were precise in two consecutive frames, and never dim or blur a marked code
that the focus mode covers. They switch on after `dwellMs` of steady
eligibility, and `focus: 'off'` disables them. They never touch the video or the
capture canvas, so the decoder reads the same pixels. The readout shows the
exact symbology label, its family, the payload kind and the complete decoded
text, with invisible characters shown as named chips; the ECI, FNC1 and the
exact bytes in Details; GS1 fields and issues verbatim; and, for an `http:` or
`https:` URL, the encoded URL exactly as decoded with an Open link button.

**Layout.** The overlay covers the video's content box inside `container`,
which must contain the video and be positioned. It follows the video's computed
`object-fit` (`contain`, `cover`, `fill`, `none` or `scale-down`),
`object-position` and a horizontal mirror such as `transform: scaleX(-1)`; the
`fit`, `position` and `mirror` options override what it reads.
`overlay.alignment`, also `data-alignment` on the overlay root, is `aligned` or
the first problem found: `no-frame`, `no-size`, `unsupported-transform`,
`object-view-box`, `unsupported-fit`, `unsupported-position`, `no-media` or
`frame-mismatch`. Anything but `aligned` hides the markers and effects rather
than drawing them in the wrong place; the rail and the readout stay. The
container and its ancestors may carry a positive uniform scale and a
translation, and between the container and the video only a translation or a
horizontal mirror is allowed. Call `layout()` after a stylesheet-only change
elsewhere, and keep `opacity`, `filter`, `mask`, `clip-path` and
`mix-blend-mode` off the overlay root (`[data-qr-camera-overlay]`). The rail
and the readout render inside the video in a `regular`, `compact` or `minimal`
arrangement, or wherever you `mount` them; mounting both below the video keeps
every code visible and tappable. `rail` is `'auto'`, `'multiple'`, `'always'`
or `'never'`; with `rail: 'never'` and `readout: false`, provide your own
control that calls `select()`.

**Theming.** The overlay reads these custom properties and never declares them:
`--qr-scanner-color-0` to `--qr-scanner-color-7` (the track colors, by
`slot % 8`), `--qr-scanner-color-0-text` to `--qr-scanner-color-7-text` and
`--qr-scanner-action-text` (the numbers drawn on them; keep a contrast of at
least 4.5:1), `--qr-scanner-highlight` (every track with `colors: 'mono'`),
`--qr-scanner-casing`, `--qr-scanner-surface` and `--qr-scanner-text` (the rail
and the readout; override both together) and `--qr-scanner-focus`. `scheme`
(`'dark'` by default) sets the overlay's `color-scheme`. The overlay injects one
`<style>` element per document or shadow root; under a strict `style-src`, pass
the policy's nonce as `styleNonce`, or pass `styles: 'none'` and serve
`CAMERA_OVERLAY_CSS` in your own stylesheet. Per-element values go through the
CSSOM, never a `style` attribute.

**Accessibility.** The rail is a toolbar holding one radio group: Tab reaches it
once, the arrow keys, Home and End move the focus, Enter or Space selects, and a
digit selects codes 1 to 9 while the focus is in the rail or the readout. Escape
closes the full readout card. A visually hidden status region announces the
selection, the loss and return of the selected code and the outcome of each
action, never decoded content unless you set `announceContent: 'preview'`.
Reduced motion removes the animations, and forced colors remove the dimming,
wash, blur and glow. Buttons and rail entries measure at least 44 by 44 CSS
pixels, and the selected entry carries a check mark: color is never the only
cue.

**Labels.** `labels` overrides `DEFAULT_LABELS`, the frozen English defaults,
key by key at every depth; a key you leave out keeps its default. Set `lang` to
the language of your labels. The browser API guide gives a French set of every
label except the symbology names, which stay as they are.

**Destinations.** The readout shows a destination slot for the URL of a `url`,
`gs1_digital_link` or `me_card` payload. Without `destinations` it reads
"Destination not checked" and offers no check. To let users check one, pass a
verifier from `/destination` (next section) as `destinations`: a check starts
only when the user presses Check destination, and nothing is checked on scan or
opened. A result is an observation of one request chain, never a safety
verdict, and every URL in it renders as text. `destroy()` unsubscribes from the
verifier but cancels no attempt. To render your own destination row instead,
pass `destinationSlot: false` and, in `onSelect`, call
`selection.select(overlay.detection)` on a `createDestinationSelection(verifier)`
binder.

**Copy and Open.** Copy writes the exact decoded text with
`navigator.clipboard.writeText()`, and Details also offers Copy bytes, the exact
bytes as uppercase hexadecimal, for platforms that cut a text clipboard at
U+0000 or rewrite line endings. Open appears only for an `http:` or `https:`
URL, and a click calls `window.open(href, '_blank', 'noopener,noreferrer')`;
nothing opens by itself. `onAction(action)` runs before each open, copy, check
and cancel, and `action.preventDefault()` skips the overlay's own call.

**Thumbnails.** With `thumbnails: true`, rail entries show a crop of each code
from the frame the decoder read. The overlay never reads the video for them: in
`scanFrame`, ask `overlay.wantsFrameImage()`, and only when it returns `true`
pass a copy to `overlay.setFrameImage(image, frame)`, as the wiring above does.
Pass an `ImageData` or an `ImageBitmap`, never a canvas.

The [browser API guide](https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust/blob/v0.12.3/docs/api/wasm.mdx)
covers each part in full. Checks in automated browsers do not qualify a
physical camera or every mobile browser.

## URL destination checks (0.11.0, optional)

`/destination` reports where an encoded `http(s)` URL leads, only when your
application asks. It is plain JavaScript beside the WASM, with no imports, and
runs in browsers, module workers, Node and SSR. Importing it, scanning, and
creating a verifier or a transport send nothing: a request leaves only from
`verifier.resolve()`, `resolveDestination()` or a direct `transport.resolve()`
call, always through a transport your code passed in. `/camera-overlay`
imports `destinationCandidate` to read eligibility and checks a destination
only through a verifier you pass it, from a user action. A result describes
one check of a request chain; it is never a safety, reputation or phishing
verdict.

**Eligibility.** `destinationCandidate(input)` takes a `Detection`, a `Payload`
or a string. It reads the `url` field of a `url`, `gs1_digital_link` or
`me_card` payload. Other payload kinds, `text` included, give `no_url`; a
string is tested as it is, so plain text gives `not_http`. A detection whose
`content.charset` is `unknown` gives `lossy_text`. The value must start with
`http://` or `https://` at its first character (ASCII case ignored), parse as
a WHATWG URL without a user name or password, stay within 16384 UTF-16 code
units, and contain no control character, space or other separator, format
character, default-ignorable code point (a variation selector after an emoji
included) or lone surrogate. Nothing is trimmed, joined or
completed: the URL parser would delete tabs and line breaks, and IDNA would
delete invisible characters inside a host, so checking the parsed form would
request a URL the code does not contain. An ineligible candidate names its
`reason` (`no_url`, `lossy_text`, `not_http`, `control_or_space`,
`invalid_url`, `credentials` or `too_long`) and is never requested. An eligible
one keeps the exact `encodedUrl` apart from its `requestUrl`, the WHATWG
serialization without the fragment that a check requests; show both when they
differ.

**Explicit transports.** Each verifier uses the one transport you pass:

| Factory | Runs in | Behaviour |
| --- | --- | --- |
| `createFetchTransport({ scope: 'network' })` | browsers, module workers | One `GET` from the user's browser: no credentials, no referrer, no cache. |
| `createFetchTransport({ scope: 'fixture', fixtureOrigin })` | browsers, module workers | The same request for tests, refused outside one origin on `127.0.0.1` or `[::1]`. |
| `createEndpointTransport({ endpoint, label })` | browsers, module workers | One same-origin `POST` to your server's `createDestinationEndpoint()`. |
| `createPreparedTransport(entries)` | any runtime | Prepared results for demos and tests; nothing is requested. |
| `createNodeTransport()` from `/destination-node` | Node | A resolver that checks scheme, port and every resolved address on each hop. |

`scope` has no default: `createFetchTransport()` without `'network'` or
`'fixture'` throws a TypeError, so a forgotten option never sends a real
request. On a server runtime (Node, Bun, Deno, an Electron renderer with Node
integration) the fetch transport answers `unavailable` with
`transport_unsupported`, whatever `fetch` you inject; servers use
`createNodeTransport()`. A custom transport implements `DestinationTransport`,
and every observation it returns is validated before it is stored.

```js
import { createDestinationVerifier, createEndpointTransport, destinationCandidate }
  from '@qrcode-ai-com/qrcode-barcode-scanner-wasm/destination';

// In client code: a '/path' endpoint resolves against the page's location, so
// creating it on a server, during server rendering included, throws a TypeError.
const verifier = createDestinationVerifier({
  transport: createEndpointTransport({ endpoint: '/api/destination', label: 'App server' }),
});

// Only from an explicit user action, such as a "Check destination" button:
const candidate = destinationCandidate(detection);
if (candidate.eligible && verifier.canResolve) {
  const snapshot = await verifier.resolve(candidate);
  const observed = snapshot.state === 'resolved' && snapshot.provenance !== 'simulated';
  // Show snapshot.finalUrl as text beside snapshot.transport.label; never link it.
}
```

**Result model.** `verifier.get(target)`, the promise of `verifier.resolve()`
and each change sent to `verifier.subscribe()` listeners carry a frozen
snapshot with the same 18 keys in every state: `unverified`, `resolving`,
`resolved`, `failed`, `canceled` or `unavailable`, the last three with a
`reason` code. A resolved snapshot holds the observed `finalUrl` and `status`,
`redirected`, `changed` (whether `finalUrl` differs from `requestUrl`), and the
observed `redirects` steps with their `hopCount`, both `null` when the
transport cannot see the chain. An attempt made through a transport names it
(`transport.kind`, `transport.label`) and gives its `provenance` and
`requestSent` (`true`, `false`, or `null` when it cannot be known), with
`startedAt`, `settledAt` and `durationMs` from the verifier's own clocks.
`detail` is English text of at most 300 code points: fixed sentences from the
built-in transports, but a custom transport's or a prepared entry's own text,
with control and invisible formatting characters replaced. Only
`DESTINATION_POLICY.detailSentences` cross the endpoint wire. Translate the
`reason` codes for users. The store keeps one entry per exact `encodedUrl`,
joins a repeated `resolve()` to the attempt in flight, keeps a settled result
until the next `resolve()`, `forget()`, `clear()` or eviction, and bounds its
work (by default 2 attempts running, 16 queued, 64 entries).
`createDestinationSelection(verifier)` derives the view of the selected code
from the store, so a late result for one code never appears under another.

**Observed URLs are text.** `finalUrl`, each redirect step's `url` and
`location`, and `requestUrl` are observations. Render them as text, never as a
link, a navigation target or an open action. Each observed URL is a canonical
http(s) URL without credentials; a refused redirect reports only its
`refusedScheme`. The fetch, endpoint and Node transports put no socket address,
response body or header other than the redirect `Location` in a result; a
custom transport's or a prepared entry's `detail` is its own text.

**Simulated is not observed.** `createPreparedTransport()` results have
`provenance: 'simulated'` and `requestSent: false`; never present them as
observations. Before showing a destination as observed, test
`snapshot.state === 'resolved' && snapshot.provenance !== 'simulated'`, and
show `snapshot.transport.label` beside it. Each transport declares a provenance
ceiling (`network`, then `fixture`, then `simulated`): an observation that
claims more than its transport's ceiling is stored as `unavailable` with
`invalid_observation`, never upgraded.

**Limits.**

- A check is a real request. It can count a visit, use up a scan cap, consume
  a one-time link or trigger any other effect a server attaches to a `GET`.
  Nothing here checks on scan or navigates; start checks only from an explicit
  user action.
- Results depend on the observer: IP address, region, language, user agent and
  time can change a route. By default the Node resolver identifies itself as
  `qrcode-barcode-scanner-destination-bot/1` (its `userAgent` option), and some
  services answer bots differently from browsers.
- The fetch transport can read a response only when the destination allows
  CORS, which most sites do not. The result is then `unavailable` with
  `opaque_network_error` and `requestSent: null`, because the request may
  still have reached the server. After a redirect the browser hides the chain
  (`redirects` and `hopCount` are `null`), and it follows up to 20 redirects
  whatever `maxHops` says. Before sending, the transport checks only the first
  URL (bad ports, non-public address literals, special-use names, mixed
  content); name resolution and every redirect, including one into a private
  network, are left to the browser. Every request carries the user's IP
  address and the page's `Origin`.
- Response bodies are never read: meta refresh, JavaScript redirects and page
  content stay invisible.
- The address, name and port tables are a dated snapshot
  (`DESTINATION_POLICY.snapshot`).
- No Safari/WebKit or physical-device behaviour is claimed.

**Server use.** `/destination-node` is for Node only, tested on Node 22 and 24.
Its package export has a
`node` condition alone, so a browser build fails to resolve it, and its
transport answers `transport_unsupported` under Bun or Deno.
`createNodeTransport()` follows redirects itself and applies its policy on
every hop: http(s) only, ports 80 and 443 by default, special-use names
refused, every DNS answer vetted, public addresses only, proxy settings
ignored, certificate checks always on. `createDestinationEndpoint()` serves
`createEndpointTransport()` from your own origin:

```js
import { createDestinationEndpoint, createNodeTransport }
  from '@qrcode-ai-com/qrcode-barcode-scanner-wasm/destination-node';

const handler = createDestinationEndpoint({
  transport: createNodeTransport(), // one per process
  allowedHosts: ['app.example.com'],
});
// Before any body parser, on the page's own origin, behind your session check:
// app.post('/api/destination', requireSession, rateLimit, handler);
```

The endpoint lets callers make your server send requests, even with that
policy. Authenticate callers, limit their rate, keep URLs out of logs, and add
your network's NAT64 prefix and denied ranges; the
[security guide](https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust/blob/v0.12.3/docs/concepts/security.mdx)
lists the policy and the operator's duties. Project-authored source in this checkout is MIT;
the pinned published package retains its own license. The current [licensing guide](https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust/blob/main/LICENSING.md) explains
source, package and third-party terms.


## Examples

The package ships runnable examples in `examples/`. The pages load the
package's own files by relative path (`../auto.js`), with no bundler, framework
or download.

- `examples/headless.html`, with `headless.js`, scans an image you choose or
  drop. The image is decoded in a module worker on your device and never
  uploaded, and decoded links are shown as text, never opened. The page names
  the package version, the SHA-256 of its WASM module and the version the
  loaded module reports.
- `examples/camera.html`, with `camera.js`, wires `createCameraScanner`,
  `createDetectionTracker` and `createCameraOverlay` as an application would.
  The camera opens only when you press its button, every tracker snapshot
  reaches `overlay.update(snapshot)`, a frame is copied only when
  `overlay.wantsFrameImage()` asks, and a hung frame replaces the worker
  through `recover`. Open is turned off, and destination checks stay off until
  you turn them on.
- `examples/scanner.worker.js` is the module worker both pages use: it owns one
  scanner and answers `load`, `scan_image` and `scan_frame` requests by `id`.
  A scan request carries the named options (`profile`, `formats`, `budgetMs`,
  `retryBudgetMs` and the others) as fields beside its pixels; a field that is
  not an option is refused, never ignored.
- `examples/ssr.mjs` imports `/camera`, `/camera-overlay` and `/destination` in
  Node, with each DOM, camera and network global it lists replaced by a trap,
  and prints what a server can compute with them.

Module scripts and module workers do not run from a `file://` page. Serve the
package folder, the one that holds `package.json`, with a static server on
localhost that sends `.js` files with a JavaScript type, for example from a
project that installed the package:

```sh
python3 -m http.server 8000 --bind 127.0.0.1 --directory node_modules/@qrcode-ai-com/qrcode-barcode-scanner-wasm
```

Then open `http://127.0.0.1:8000/examples/headless.html` or
`http://127.0.0.1:8000/examples/camera.html`. The camera page needs a secure
context: `localhost` and `127.0.0.1` count as one on the machine that runs the
browser; from another device, such as a phone, serve the folder over `https`.
Run the server-rendering example with
`node node_modules/@qrcode-ai-com/qrcode-barcode-scanner-wasm/examples/ssr.mjs`.
[examples/README.md](https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust/blob/v0.12.3/crates/qrcode-ai-scanner-wasm/examples/README.md),
also in the installed package, describes each example and the worker's
messages.

### Content Security Policy

Both example pages scan with no violation reported when a server sends
`default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; img-src blob: data:`,
plus a `style-src` hash of the image page's one inline `<style>` element, as a
`Content-Security-Policy` header with every file of the package folder.
[examples/README.md](https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust/blob/v0.12.3/crates/qrcode-ai-scanner-wasm/examples/README.md#content-security-policy)
gives that exact policy, why each source is needed, and how the package's
browser job found it in Playwright's Chromium and Firefox. For a policy of your
own:

- Compiling the WebAssembly module needs `'wasm-unsafe-eval'` in `script-src`
  in the policy of the context that compiles it; otherwise the browser refuses
  to compile it. A module worker loaded from its own URL takes its policy from
  the headers of that script's response: a page's `meta` policy, such as the
  one each example page carries, does not reach it.
- `/auto` imports the package's own modules (`scan.js` with it, then the
  generated module when the loader is called) and fetches only its `.wasm`
  file, next to it unless you pass `wasmUrl`, so `connect-src`, or
  `default-src` when `connect-src` is absent, must allow that origin.
- The overlay injects one `<style>` element, which needs `styleNonce` or
  `styles: 'none'` with `CAMERA_OVERLAY_CSS` in your own stylesheet, and sets
  every other value through the CSSOM.
- A destination check requests only what its transport targets. Through
  `createFetchTransport()`, the page's `connect-src` must allow the link's
  origin, for example `connect-src 'self' https:`; otherwise the browser
  blocks the check before sending it, and the readout shows it as unavailable.

### SIMD, bundlers and server rendering

- **SIMD.** The package ships one module, which uses no SIMD, so a browser with
  WebAssembly SIMD disabled loads the same bytes; `scannerCapabilities().simd`
  is a diagnostic only. The package's browser job runs both example pages from
  the installed package in Playwright's Chromium and Firefox, and in CI also
  in a Chromium started with WebAssembly SIMD disabled. Those runs say nothing
  about Safari, iOS or Android.
- **Bundlers.** The examples need no bundler. In a bundled application, import
  the entries by name (`/auto`, `/scan`, `/camera`, `/camera-overlay`,
  `/destination`): the loader finds its `.wasm` through `import.meta.url`, and
  the package's CI builds a fresh Vite application with a module worker from
  the installed package. The browser API guide lists the bundler settings, and
  [Use a bundler](https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust/blob/v0.12.3/crates/qrcode-ai-scanner-wasm/examples/README.md#use-a-bundler)
  shows the example pages' imports by package name.
- **Server rendering.** Importing `/auto`, `/camera`, `/camera-overlay` and
  `/destination` during server rendering compiles no WebAssembly, fetches
  nothing and touches no DOM; the package's CI imports them in Node with
  `WebAssembly` undefined and checks that `fetch` is never called, and
  `examples/ssr.mjs` shows the camera, overlay and destination helpers a server
  can call. `/scan` imports nothing and is as safe to import. Load the scanner
  in the browser or a worker, and start the camera in the browser: where
  WebAssembly is missing, `loadScanner()` rejects with `wasm_unavailable`. On
  a server that should scan, `/node` loads the module from disk.

Releases up to 0.10.1 were published as `@supernovae-st/qrcode-ai-scanner-wasm`.



## What it returns

<p align="center">
  <a href="https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust#examples">
    <picture>
      <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/brand/examples-mixed-dark.png?v=385593c1c18d">
      <img src="https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/brand/examples-mixed-light.png?v=7f958679adcc" alt="A QR code and Code 128 decoded from the same image, each outlined where the engine measured it" width="100%">
    </picture>
  </a>
</p>

The picture is a recorded scan of one image that holds a QR code and a Code 128 barcode. Both come
back in the same report, each with its format and the place where the engine measured it.

## What it reads

The package holds the engine, so it reads what the engine reads.
Codes of different formats in the same image come back in one report.

<p align="center">
  <a href="https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust#supported-formats">
    <picture>
      <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/brand/formats-dark.gif?v=92fa0e8084df">
      <img src="https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/brand/formats-light.gif?v=bdfe5fc5f9b3" alt="The code families the engine reads: QR codes, matrix and stacked codes such as Data Matrix, retail barcodes such as EAN-13, and other linear barcodes such as Code 128" width="100%">
    </picture>
  </a>
</p>

| Family | Formats |
|---|---|
| QR | QR Code, Micro QR, rectangular Micro QR (rMQR) |
| Matrix and stacked | Data Matrix, Aztec, PDF417, MaxiCode |
| Retail | EAN-13, EAN-8, UPC-A, UPC-E |
| Other linear | Code 128, Code 39, Code 93, Codabar, ITF, GS1 DataBar, GS1 DataBar Expanded, Telepen |

The engine's [supported formats](https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust#supported-formats) section states the known limits.

## The same engine in other runtimes

<p align="center">
  <a href="https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust#get-started">
    <picture>
      <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/brand/runtimes-dark.png?v=57c63428574b">
      <img src="https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/brand/runtimes-light.png?v=6dbd5a8cf5ba" alt="One engine in the language you write: Rust on crates.io, Node.js and the browser on npm, Python on PyPI, Go, PHP, and the qrscan command line" width="100%">
    </picture>
  </a>
</p>

| Runtime | Package | How it scans |
|---|---|---|
| <picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/brand/mark-lang-rust-dark.png?v=31b5deebc32e"><img src="https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/brand/mark-lang-rust-light.png?v=c5207721973f" alt="" width="24" height="24" align="absmiddle"></picture> Rust | [`qrcode-barcode-scanner`](https://crates.io/crates/qrcode-barcode-scanner) on crates.io | In process |
| <picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/brand/mark-lang-nodejs-dark.png?v=cf2159524fc6"><img src="https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/brand/mark-lang-nodejs-light.png?v=6dd098480218" alt="" width="24" height="24" align="absmiddle"></picture> Node.js | [`@qrcode-ai-com/qrcode-barcode-scanner`](https://www.npmjs.com/package/@qrcode-ai-com/qrcode-barcode-scanner) on npm | In process, native |
| <picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/brand/mark-lang-browser-dark.png?v=bbe2f3560a6d"><img src="https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/brand/mark-lang-browser-light.png?v=591e304cf9e9" alt="" width="24" height="24" align="absmiddle"></picture> Browser | [`@qrcode-ai-com/qrcode-barcode-scanner-wasm`](https://www.npmjs.com/package/@qrcode-ai-com/qrcode-barcode-scanner-wasm) on npm | In the page, WebAssembly |
| <picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/brand/mark-lang-python-dark.png?v=7469c3e0b4fb"><img src="https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/brand/mark-lang-python-light.png?v=308121255ab7" alt="" width="24" height="24" align="absmiddle"></picture> Python | [`qrcode-barcode-scanner`](https://pypi.org/project/qrcode-barcode-scanner/) on PyPI | In process |
| <picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/brand/mark-lang-go-dark.png?v=b6dbac901176"><img src="https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/brand/mark-lang-go-light.png?v=1983a9eb7344" alt="" width="24" height="24" align="absmiddle"></picture> Go | [`qrcode-barcode-scanner-go`](https://github.com/qrcode-ai-com/qrcode-barcode-scanner-go) | Through the installed `qrscan` |
| <picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/brand/mark-lang-php-dark.png?v=3800932934c8"><img src="https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/brand/mark-lang-php-light.png?v=7bdd6884b3a4" alt="" width="24" height="24" align="absmiddle"></picture> PHP | [`qrcode-barcode-scanner-php`](https://github.com/qrcode-ai-com/qrcode-barcode-scanner-php) | Through the installed `qrscan` |
| <picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/brand/mark-terminal-dark.png?v=1e987f0ab278"><img src="https://raw.githubusercontent.com/qrcode-ai-com/qrcode-barcode-scanner-rust/main/docs/assets/brand/mark-terminal-light.png?v=2262d66bee6b" alt="" width="24" height="24" align="absmiddle"></picture> Command line | [`qrscan`](https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust#command-line) | One command, one JSON report |

The Rust, Node.js, browser and Python packages hold the engine. The Go and PHP packages hold no decoder:
each one starts `qrscan` and hands you its report.

<sub>Language and platform names and logos belong to their owners. They identify a runtime or a destination and imply no endorsement.</sub>

Source license: MIT · © SuperNovae Studio. Published archives retain their own license.

Maintained by **Thibaut Mélen & Nicolas Cella** for **QR Code AI**, a product of **SuperNovae Studio**. The license of each component is stated in its own license files.

<!-- qrscan-source-license:v1 -->

## Source license

Project-authored scanner code and documentation in this checkout are available under the [MIT License](https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust/blob/main/LICENSE). You may use, modify and redistribute this source in open-source or proprietary applications, including commercial products, while preserving the copyright and permission notice. Thibaut Mélen & Nicolas Cella develop QR Code AI at SuperNovae Studio.

Retained third-party code, dependencies, artwork and test data keep their own licenses and notices. The [licensing guide](https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust/blob/main/LICENSING.md) explains these component boundaries; the project license does not assign a license to an unrelated platform or service.

Published archives retain the license shipped with their version. A pinned engine, adapter or bundle may therefore have different terms from this working source. Read its packaged license and the [license history](https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust/blob/main/docs/guides/license-history.mdx) before reuse. The source change does not replace an archive or publish a new version.

<!-- /qrscan-source-license:v1 -->
