Skip to content

Commit

Permalink
fix(ui): scanning of small QR codes (#3946)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Lando <daniel.sorridi@gmail.com>
  • Loading branch information
AlCalzone and robertsLando authored Oct 15, 2024
1 parent b4baf4a commit 6420ee4
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 3 deletions.
42 changes: 41 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"ansi_up": "^6.0.2",
"archiver": "^7.0.1",
"axios": "^1.7.2",
"barcode-detector": "^2.2.11",
"connect-history-api-fallback": "2.0.0",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
Expand Down Expand Up @@ -111,7 +112,8 @@
"vuetify": "^2.7.2",
"winston": "^3.13.0",
"winston-daily-rotate-file": "^5.0.0",
"zwave-js": "^13.9.0"
"zwave-js": "^13.9.0",
"zxing-wasm": "^1.2.15"
},
"devDependencies": {
"@actions/github": "^6.0.0",
Expand Down
Binary file added public/zxing_reader.wasm
Binary file not shown.
19 changes: 18 additions & 1 deletion src/components/custom/QrReader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,29 @@
</div>
</template>
<script>
import QrScanner from 'qr-scanner'
// The BarcodeDetector Web API is not yet supported in all browsers,
// and "qr-scanner" defaults to a suboptimal implementation if it is not available.
// The following import makes a better implementation available that is based on a
// WebAssembly port of ZXing:
import { setZXingModuleOverrides } from 'barcode-detector'
import { wait } from '../../lib/utils.js'
import logger from '../../lib/logger'
const log = logger.get('QrReader')
import QrScanner from 'qr-scanner'
setZXingModuleOverrides({
locateFile: (path, prefix) => {
if (path.endsWith('.wasm')) {
// This file has been copied from node_modules/zxing-wasm/dist/reader/ to public/
// Don't forget to update the file when updating the node_module
return 'zxing_reader.wasm'
}
return prefix + path
},
})
export default {
props: {
qrbox: {
Expand Down

0 comments on commit 6420ee4

Please sign in to comment.