diff --git a/bundled-addons/aegis/addon.json b/bundled-addons/aegis/addon.json index 9298ab4d..f87b5b92 100644 --- a/bundled-addons/aegis/addon.json +++ b/bundled-addons/aegis/addon.json @@ -1,7 +1,7 @@ { "id": "aegis", "name": "Aegis Wallet", - "version": "0.28.0", + "version": "0.28.1", "category": "plugin", "description": "Multi-chain wallet (BCH, BTC, TRX, ETH, SOL, SC, DGB) derived from your Theseus vault. Dapps get window.bitcoincash and window.wizardconnect on any site; window.tronWeb / window.tronLink / window.ethereum / window.solana too. Every call needs your approval.", "author": "Silent Mode", diff --git a/bundled-addons/aegis/panel.html b/bundled-addons/aegis/panel.html index 594e5478..117fb6bf 100644 --- a/bundled-addons/aegis/panel.html +++ b/bundled-addons/aegis/panel.html @@ -1387,8 +1387,14 @@ - - - + + + diff --git a/bundled-addons/aegis/panel.js b/bundled-addons/aegis/panel.js index d5817974..dc501fa4 100644 --- a/bundled-addons/aegis/panel.js +++ b/bundled-addons/aegis/panel.js @@ -1619,8 +1619,26 @@ function classifyScannedSecret(text) { return { kind: "unknown", value: s }; } +// jsQR is 257 KB of vendored decoder and it is only needed when someone +// actually imports a QR image. Loading it from panel.html meant every panel +// open — every hide/show — parsed all of it before panel.js even started. +// Fetch it the first time it is wanted instead. +let jsqrLoad = null; +function loadJsQr() { + if (typeof jsQR === "function") return Promise.resolve(); + if (jsqrLoad) return jsqrLoad; + jsqrLoad = new Promise((resolve, reject) => { + const el = document.createElement("script"); + el.src = "lib/jsqr.js"; + el.onload = () => (typeof jsQR === "function" ? resolve() : reject(new Error("the QR decoder loaded but exposed nothing"))); + el.onerror = () => { jsqrLoad = null; reject(new Error("the QR decoder failed to load")); }; + document.head.appendChild(el); + }); + return jsqrLoad; +} + async function decodeQrFile(file) { - if (typeof jsQR !== "function") throw new Error("the QR decoder failed to load"); + await loadJsQr(); const bitmap = await createImageBitmap(file); try { // Very large photos cost time and memory for no accuracy gain; jsQR wants