From d5e55c9c577feb6f8000bad3c37045a2cd7c9b4c Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 23 Jun 2026 23:05:52 -0700 Subject: Add QR scanner to the send page (lazy-loaded decoder) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Scan a Bitcoin address, a BIP21 URI (fills address + amount), or a signed-transaction QR (opens a broadcast confirmation, then relays it) from a viewfinder button on the Send form. Decoder strategy keeps the main bundle small: - Prefer the native BarcodeDetector (Chrome desktop/Android) — no lib. - Otherwise lazy-load jsQR from a separate dist/jsqr.js, only when the scanner is opened. jsQR stays out of index.html (~424 KB vs ~551 KB) and off the initial load. - The service worker precaches jsqr.js so offline scanning works for installed PWAs on browsers without BarcodeDetector. The scanner needs a camera + secure context, so it never shows on a standalone file:// page; offline air-gapped signing is unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/jsqr-global.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/jsqr-global.js (limited to 'src/jsqr-global.js') diff --git a/src/jsqr-global.js b/src/jsqr-global.js new file mode 100644 index 0000000..5450160 --- /dev/null +++ b/src/jsqr-global.js @@ -0,0 +1,7 @@ +// Standalone bundle for the QR decoder, emitted as a separate dist/jsqr.js and +// loaded on demand by scan.js — only when a browser lacks the native +// BarcodeDetector API and the user actually opens the scanner. Keeps jsQR +// (~130 KB) out of the main single-file bundle and off the initial load. +import jsQR from 'jsqr'; + +window.jsQR = jsQR; -- cgit v1.2.3