Polyfill BarcodeDetector API for improved performance of Html5QRcodeScanner

This commit is contained in:
Jan Böhmer 2025-01-04 16:49:17 +01:00
parent 9e85b70c17
commit 4b09a321ad
4 changed files with 54 additions and 1 deletions

View file

@ -44,4 +44,21 @@ import "./register_events";
import "./tristate_checkboxes";
//Define jquery globally
window.$ = window.jQuery = require("jquery")
window.$ = window.jQuery = require("jquery");
//Use the local WASM file for the ZXing library
import {
setZXingModuleOverrides,
} from "barcode-detector/pure";
import wasmFile from "../../node_modules/zxing-wasm/dist/reader/zxing_reader.wasm";
setZXingModuleOverrides({
locateFile: (path, prefix) => {
if (path.endsWith(".wasm")) {
return wasmFile;
}
return prefix + path;
},
});
//Enable polyfill for the barcode detector. The WASM triggering is done when the barcode detector is used
import "barcode-detector/side-effects";