@part-db/html5-qrcode
Advanced tools
Comparing version 3.1.0 to 3.1.1
@@ -48,6 +48,11 @@ "use strict"; | ||
this.verbose = verbose; | ||
if (!native_bar_code_detector_1.BarcodeDetectorDelegate.isSupported()) { | ||
throw new Error("BarcodeDetector is not supported by this browser. Use Polyfill if required!"); | ||
if (native_bar_code_detector_1.BarcodeDetectorDelegate.isNativeSupported()) { | ||
logger.log("Native BarcodeDetector is supported, using it as primary decoder."); | ||
this.primaryDecoder = new native_bar_code_detector_1.BarcodeDetectorDelegate(requestedFormats, verbose, logger); | ||
this.secondaryDecoder = new native_bar_code_detector_1.BarcodeDetectorDelegate(requestedFormats, verbose, logger, true); | ||
} | ||
this.primaryDecoder = new native_bar_code_detector_1.BarcodeDetectorDelegate(requestedFormats, verbose, logger); | ||
else { | ||
logger.log("Native BarcodeDetector is not supported, using polyfill as primary decoder."); | ||
this.primaryDecoder = new native_bar_code_detector_1.BarcodeDetectorDelegate(requestedFormats, verbose, logger, true); | ||
} | ||
} | ||
@@ -54,0 +59,0 @@ Html5QrcodeShim.prototype.decodeAsync = function (canvas) { |
@@ -8,3 +8,3 @@ import { QrcodeResult, Html5QrcodeSupportedFormats, QrcodeDecoderAsync, Logger } from "./core"; | ||
private detector; | ||
static isSupported(): boolean; | ||
static isNativeSupported(): boolean; | ||
constructor(requestedFormats: Array<Html5QrcodeSupportedFormats>, verbose: boolean, logger: Logger, usePolyfill?: boolean); | ||
@@ -11,0 +11,0 @@ decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; |
@@ -61,5 +61,4 @@ "use strict"; | ||
this.reverseFormatMap = this.createReverseFormatMap(); | ||
if (!BarcodeDetectorDelegate.isSupported()) { | ||
throw "Use html5qrcode.min.js without edit, Use " | ||
+ "BarcodeDetectorDelegate only if it isSupported();"; | ||
if (!usePolyfill && !BarcodeDetectorDelegate.isNativeSupported()) { | ||
throw "BarcodeDetector is not supported natively by this browser. Use Polyfill by setting usePolyfill to true!"; | ||
} | ||
@@ -79,3 +78,3 @@ this.verbose = verbose; | ||
} | ||
BarcodeDetectorDelegate.isSupported = function () { | ||
BarcodeDetectorDelegate.isNativeSupported = function () { | ||
if (!("BarcodeDetector" in window)) { | ||
@@ -82,0 +81,0 @@ return false; |
@@ -18,6 +18,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
this.verbose = verbose; | ||
if (!BarcodeDetectorDelegate.isSupported()) { | ||
throw new Error("BarcodeDetector is not supported by this browser. Use Polyfill if required!"); | ||
if (BarcodeDetectorDelegate.isNativeSupported()) { | ||
logger.log("Native BarcodeDetector is supported, using it as primary decoder."); | ||
this.primaryDecoder = new BarcodeDetectorDelegate(requestedFormats, verbose, logger); | ||
this.secondaryDecoder = new BarcodeDetectorDelegate(requestedFormats, verbose, logger, true); | ||
} | ||
this.primaryDecoder = new BarcodeDetectorDelegate(requestedFormats, verbose, logger); | ||
else { | ||
logger.log("Native BarcodeDetector is not supported, using polyfill as primary decoder."); | ||
this.primaryDecoder = new BarcodeDetectorDelegate(requestedFormats, verbose, logger, true); | ||
} | ||
} | ||
@@ -24,0 +29,0 @@ decodeAsync(canvas) { |
@@ -8,3 +8,3 @@ import { QrcodeResult, Html5QrcodeSupportedFormats, QrcodeDecoderAsync, Logger } from "./core"; | ||
private detector; | ||
static isSupported(): boolean; | ||
static isNativeSupported(): boolean; | ||
constructor(requestedFormats: Array<Html5QrcodeSupportedFormats>, verbose: boolean, logger: Logger, usePolyfill?: boolean); | ||
@@ -11,0 +11,0 @@ decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; |
@@ -13,3 +13,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
export class BarcodeDetectorDelegate { | ||
static isSupported() { | ||
static isNativeSupported() { | ||
if (!("BarcodeDetector" in window)) { | ||
@@ -38,5 +38,4 @@ return false; | ||
this.reverseFormatMap = this.createReverseFormatMap(); | ||
if (!BarcodeDetectorDelegate.isSupported()) { | ||
throw "Use html5qrcode.min.js without edit, Use " | ||
+ "BarcodeDetectorDelegate only if it isSupported();"; | ||
if (!usePolyfill && !BarcodeDetectorDelegate.isNativeSupported()) { | ||
throw "BarcodeDetector is not supported natively by this browser. Use Polyfill by setting usePolyfill to true!"; | ||
} | ||
@@ -43,0 +42,0 @@ this.verbose = verbose; |
@@ -45,6 +45,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
this.verbose = verbose; | ||
if (!BarcodeDetectorDelegate.isSupported()) { | ||
throw new Error("BarcodeDetector is not supported by this browser. Use Polyfill if required!"); | ||
if (BarcodeDetectorDelegate.isNativeSupported()) { | ||
logger.log("Native BarcodeDetector is supported, using it as primary decoder."); | ||
this.primaryDecoder = new BarcodeDetectorDelegate(requestedFormats, verbose, logger); | ||
this.secondaryDecoder = new BarcodeDetectorDelegate(requestedFormats, verbose, logger, true); | ||
} | ||
this.primaryDecoder = new BarcodeDetectorDelegate(requestedFormats, verbose, logger); | ||
else { | ||
logger.log("Native BarcodeDetector is not supported, using polyfill as primary decoder."); | ||
this.primaryDecoder = new BarcodeDetectorDelegate(requestedFormats, verbose, logger, true); | ||
} | ||
} | ||
@@ -51,0 +56,0 @@ Html5QrcodeShim.prototype.decodeAsync = function (canvas) { |
@@ -8,3 +8,3 @@ import { QrcodeResult, Html5QrcodeSupportedFormats, QrcodeDecoderAsync, Logger } from "./core"; | ||
private detector; | ||
static isSupported(): boolean; | ||
static isNativeSupported(): boolean; | ||
constructor(requestedFormats: Array<Html5QrcodeSupportedFormats>, verbose: boolean, logger: Logger, usePolyfill?: boolean); | ||
@@ -11,0 +11,0 @@ decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; |
@@ -58,5 +58,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
this.reverseFormatMap = this.createReverseFormatMap(); | ||
if (!BarcodeDetectorDelegate.isSupported()) { | ||
throw "Use html5qrcode.min.js without edit, Use " | ||
+ "BarcodeDetectorDelegate only if it isSupported();"; | ||
if (!usePolyfill && !BarcodeDetectorDelegate.isNativeSupported()) { | ||
throw "BarcodeDetector is not supported natively by this browser. Use Polyfill by setting usePolyfill to true!"; | ||
} | ||
@@ -76,3 +75,3 @@ this.verbose = verbose; | ||
} | ||
BarcodeDetectorDelegate.isSupported = function () { | ||
BarcodeDetectorDelegate.isNativeSupported = function () { | ||
if (!("BarcodeDetector" in window)) { | ||
@@ -79,0 +78,0 @@ return false; |
{ | ||
"name": "@part-db/html5-qrcode", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "A cross platform HTML5 QR Code & bar code scanner (forked for Part-DB)", | ||
@@ -5,0 +5,0 @@ "main": "./cjs/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1010336
12518