@qrcode-ai-com/qrcode-barcode-scanner-wasm
Version:
QR and barcode decoding + scannability scoring — one portable browser WASM with camera, tracking and overlay modules, plus optional URL destination checks
133 lines (129 loc) • 6.24 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'self'; worker-src 'self'; connect-src 'self'; img-src 'self' blob: data:; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="light dark">
<title>Scan an image: QR Code & Barcode Scanner example</title>
<link rel="icon" href="data:,">
<style>
:root {
color-scheme: light dark;
--bg: #ffffff; --fg: #1b1d21; --muted: #4f5662; --line: #848c98; --panel: #f3f5f8;
--accent: #0b57d0; --focus: #0b57d0; --error: #a8231c; --empty: #6b4e00; --ok: #146c2e;
}
@media (prefers-color-scheme: dark) {
:root {
--bg: #121417; --fg: #e8eaed; --muted: #b0b7c2; --line: #6b7380; --panel: #1d2026;
--accent: #8ab4f8; --focus: #8ab4f8; --error: #f2b8b5; --empty: #f0d48a; --ok: #9ad7a8;
}
}
* { box-sizing: border-box; }
[hidden] { display: none ; }
body {
margin: 0; background: var(--bg); color: var(--fg);
font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 52rem; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
h1 { font-size: 1.6rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 0.75rem; }
p { margin: 0.5rem 0; }
.muted { color: var(--muted); }
label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
input, select, button { font: inherit; color: inherit; }
input[type="file"] { max-width: 100%; }
select, button {
background: var(--panel); border: 1px solid var(--line); border-radius: 0.375rem;
padding: 0.4rem 0.6rem; min-height: 2.5rem;
}
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.drop-zone {
border: 2px dashed var(--line); border-radius: 0.5rem; padding: 1rem; background: var(--panel);
}
.drop-zone.dragging { border-color: var(--accent); border-style: solid; }
.field { margin-top: 1rem; }
#preview { margin: 1rem 0 0; }
#preview img {
display: block; max-width: 100%; max-height: 16rem; border: 1px solid var(--line);
background: #ffffff;
}
#preview figcaption { font-size: 0.9rem; }
#result { border-left: 4px solid var(--line); padding: 0.25rem 0 0.25rem 1rem; }
#result[data-state="result"] { border-left-color: var(--ok); }
#result[data-state="empty"],
#result[data-state="inconclusive"] { border-left-color: var(--empty); }
#result[data-state="error"] { border-left-color: var(--error); }
#summary { font-weight: 600; }
#detections { padding-left: 1.5rem; margin: 0.75rem 0 0; }
#detections > li { margin: 0 0 1.25rem; }
.facts { margin: 0; }
.facts > div { display: flex; flex-wrap: wrap; gap: 0 1rem; margin-bottom: 0.125rem; }
.facts dt { color: var(--muted); min-width: 9rem; }
.facts dd { margin: 0; min-width: 0; flex: 1 1 16rem; overflow-wrap: anywhere; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
pre.value {
margin: 0.5rem 0 0; padding: 0.5rem 0.75rem; background: var(--panel);
border: 1px solid var(--line); border-radius: 0.375rem;
white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
}
.note { font-size: 0.9rem; color: var(--muted); overflow-wrap: anywhere; }
</style>
<script type="module" src="./headless.js"></script>
</head>
<body>
<main>
<h1>Scan an image</h1>
<p>This page decodes an image you choose with the scanner package it is served from. The
image is decoded in a worker on this device: it is never uploaded, and the page requests
nothing outside the package folder. Decoded links are shown as text and never opened.</p>
<section aria-labelledby="input-title">
<h2 id="input-title">Image and profile</h2>
<div id="drop-zone" class="drop-zone">
<label for="file">Image file (PNG, JPEG, WebP or GIF)</label>
<input id="file" type="file" accept="image/*" aria-describedby="drop-hint">
<p id="drop-hint" class="muted">You can also drop an image file on this box.</p>
</div>
<div class="field">
<label for="profile">Profile</label>
<select id="profile" aria-describedby="profile-hint">
<option value="full" selected>full</option>
<option value="fast">fast</option>
<option value="frame">frame</option>
</select>
<p id="profile-hint" class="muted">full runs every stage and judges scannability; fast
skips the deep QR stages and scores less; frame only decodes, as for camera frames. Each
scan runs to its end, without a time budget. Changing the profile scans the chosen image
again.</p>
</div>
<figure id="preview" hidden>
<img id="preview-image" alt="">
<figcaption id="preview-caption" class="muted"></figcaption>
</figure>
</section>
<section aria-labelledby="result-title">
<h2 id="result-title">Result</h2>
<div id="result" data-state="starting" data-scan="0">
<p id="summary" role="status" aria-live="polite" tabindex="-1">Starting. If this message
stays, serve the package folder over http://localhost, with .js files sent as
text/javascript: module scripts and workers do not run from a file:// page.</p>
<ol id="detections"></ol>
</div>
<button id="retry" type="button" hidden>Load the scanner again</button>
</section>
<section aria-labelledby="build-title">
<h2 id="build-title">Package under test</h2>
<dl class="facts">
<div><dt>Package</dt><dd id="package-name" class="mono">not read yet</dd></div>
<div><dt>Version</dt><dd id="package-version" class="mono">not read yet</dd></div>
<div><dt>WASM SHA-256</dt><dd id="wasm-sha256" class="mono">not read yet</dd></div>
<div><dt>Engine version</dt><dd id="engine-version" class="mono">not loaded yet</dd></div>
</dl>
<p class="note">The package name and version come from package.json, the SHA-256 from
build-info.json (the digest of the one WASM module this package ships), and the engine
version from the loaded module itself.</p>
</section>
</main>
</body>
</html>