html5-qrcode
Advanced tools
Comparing version 2.3.7 to 2.3.8
@@ -21,3 +21,3 @@ export interface CameraDevice { | ||
} | ||
export declare type OnRenderSurfaceReady = (viewfinderWidth: number, viewfinderHeight: number) => void; | ||
export type OnRenderSurfaceReady = (viewfinderWidth: number, viewfinderHeight: number) => void; | ||
export interface RenderingCallbacks { | ||
@@ -24,0 +24,0 @@ onRenderSurfaceReady: OnRenderSurfaceReady; |
@@ -32,3 +32,3 @@ "use strict"; | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -115,3 +115,3 @@ if (y = 0, t) op = [op[0] & 2, t.value]; | ||
if (!this.isSupported()) { | ||
throw new Error(this.name + " capability not supported"); | ||
throw new Error("".concat(this.name, " capability not supported")); | ||
} | ||
@@ -158,3 +158,3 @@ }; | ||
var videoElement = document.createElement("video"); | ||
videoElement.style.width = width + "px"; | ||
videoElement.style.width = "".concat(width, "px"); | ||
videoElement.style.display = "block"; | ||
@@ -161,0 +161,0 @@ videoElement.muted = true; |
@@ -21,3 +21,3 @@ export interface CameraDevice { | ||
} | ||
export declare type OnRenderSurfaceReady = (viewfinderWidth: number, viewfinderHeight: number) => void; | ||
export type OnRenderSurfaceReady = (viewfinderWidth: number, viewfinderHeight: number) => void; | ||
export interface RenderingCallbacks { | ||
@@ -24,0 +24,0 @@ onRenderSurfaceReady: OnRenderSurfaceReady; |
@@ -17,3 +17,3 @@ "use strict"; | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -20,0 +20,0 @@ if (y = 0, t) op = [op[0] & 2, t.value]; |
@@ -17,3 +17,3 @@ "use strict"; | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -20,0 +20,0 @@ if (y = 0, t) op = [op[0] & 2, t.value]; |
@@ -17,3 +17,3 @@ "use strict"; | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -20,0 +20,0 @@ if (y = 0, t) op = [op[0] & 2, t.value]; |
@@ -17,3 +17,3 @@ "use strict"; | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -135,3 +135,3 @@ if (y = 0, t) op = [op[0] & 2, t.value]; | ||
var mean = sum / this.executionResults.length; | ||
console.log(mean + " ms for " + this.executionResults.length + " last runs."); | ||
console.log("".concat(mean, " ms for ").concat(this.executionResults.length, " last runs.")); | ||
this.executions = 0; | ||
@@ -138,0 +138,0 @@ this.executionResults = []; |
@@ -40,3 +40,3 @@ export declare enum Html5QrcodeSupportedFormats { | ||
} | ||
export declare type QrDimensionFunction = (viewfinderWidth: number, viewfinderHeight: number) => QrDimensions; | ||
export type QrDimensionFunction = (viewfinderWidth: number, viewfinderHeight: number) => QrDimensions; | ||
export interface QrBounds extends QrDimensions { | ||
@@ -83,4 +83,4 @@ x: number; | ||
} | ||
export declare type QrcodeSuccessCallback = (decodedText: string, result: Html5QrcodeResult) => void; | ||
export declare type QrcodeErrorCallback = (errorMessage: string, error: Html5QrcodeError) => void; | ||
export type QrcodeSuccessCallback = (decodedText: string, result: Html5QrcodeResult) => void; | ||
export type QrcodeErrorCallback = (errorMessage: string, error: Html5QrcodeError) => void; | ||
export interface QrcodeDecoderAsync { | ||
@@ -87,0 +87,0 @@ decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; |
@@ -81,3 +81,3 @@ "use strict"; | ||
if (!html5QrcodeSupportedFormatsTextMap.has(format)) { | ||
throw format + " not in html5QrcodeSupportedFormatsTextMap"; | ||
throw "".concat(format, " not in html5QrcodeSupportedFormatsTextMap"); | ||
} | ||
@@ -84,0 +84,0 @@ return new QrcodeResultFormat(format, html5QrcodeSupportedFormatsTextMap.get(format)); |
import { Html5QrcodeScanType, QrcodeSuccessCallback, QrcodeErrorCallback } from "./core"; | ||
import { Html5QrcodeConfigs, Html5QrcodeCameraScanConfig } from "./html5-qrcode"; | ||
import { Html5QrcodeScannerState } from "./state-manager"; | ||
interface Html5QrcodeScannerConfig extends Html5QrcodeCameraScanConfig, Html5QrcodeConfigs { | ||
export interface Html5QrcodeScannerConfig extends Html5QrcodeCameraScanConfig, Html5QrcodeConfigs { | ||
rememberLastUsedCamera?: boolean | undefined; | ||
@@ -68,2 +68,1 @@ supportedScanTypes?: Array<Html5QrcodeScanType> | []; | ||
} | ||
export {}; |
@@ -51,3 +51,3 @@ "use strict"; | ||
if (!document.getElementById(elementId)) { | ||
throw "HTML Element with id=" + elementId + " not found"; | ||
throw "HTML Element with id=".concat(elementId, " not found"); | ||
} | ||
@@ -87,3 +87,3 @@ this.scanTypeSelector = new scan_type_selector_1.ScanTypeSelector(this.config.supportedScanTypes); | ||
if (!container) { | ||
throw "HTML Element with id=" + this.elementId + " not found"; | ||
throw "HTML Element with id=".concat(this.elementId, " not found"); | ||
} | ||
@@ -95,3 +95,3 @@ container.innerHTML = ""; | ||
Html5QrcodeScanner.prototype.pause = function (shouldPauseVideo) { | ||
if (core_1.isNullOrUndefined(shouldPauseVideo) || shouldPauseVideo !== true) { | ||
if ((0, core_1.isNullOrUndefined)(shouldPauseVideo) || shouldPauseVideo !== true) { | ||
shouldPauseVideo = false; | ||
@@ -212,3 +212,2 @@ } | ||
Html5QrcodeScanner.prototype.setupInitialDashboard = function (dashboard) { | ||
var $this = this; | ||
this.createSection(dashboard); | ||
@@ -311,3 +310,2 @@ this.createSectionControlPanel(); | ||
Html5QrcodeScanner.prototype.createSectionControlPanel = function () { | ||
var $this = this; | ||
var section = document.getElementById(this.getDashboardSectionId()); | ||
@@ -371,3 +369,3 @@ var sectionControlPanel = document.createElement("div"); | ||
} | ||
defaultZoom = core_1.clip(defaultZoom, zoomCapability.min(), zoomCapability.max()); | ||
defaultZoom = (0, core_1.clip)(defaultZoom, zoomCapability.min(), zoomCapability.max()); | ||
cameraZoomUi.setValues(zoomCapability.min(), zoomCapability.max(), defaultZoom, zoomCapability.step()); | ||
@@ -637,6 +635,6 @@ cameraZoomUi.show(); | ||
Html5QrcodeScanner.prototype.getDashboardSectionId = function () { | ||
return this.elementId + "__dashboard_section"; | ||
return "".concat(this.elementId, "__dashboard_section"); | ||
}; | ||
Html5QrcodeScanner.prototype.getDashboardSectionCameraScanRegionId = function () { | ||
return this.elementId + "__dashboard_section_csr"; | ||
return "".concat(this.elementId, "__dashboard_section_csr"); | ||
}; | ||
@@ -647,9 +645,9 @@ Html5QrcodeScanner.prototype.getDashboardSectionSwapLinkId = function () { | ||
Html5QrcodeScanner.prototype.getScanRegionId = function () { | ||
return this.elementId + "__scan_region"; | ||
return "".concat(this.elementId, "__scan_region"); | ||
}; | ||
Html5QrcodeScanner.prototype.getDashboardId = function () { | ||
return this.elementId + "__dashboard"; | ||
return "".concat(this.elementId, "__dashboard"); | ||
}; | ||
Html5QrcodeScanner.prototype.getHeaderMessageContainerId = function () { | ||
return this.elementId + "__header_message"; | ||
return "".concat(this.elementId, "__header_message"); | ||
}; | ||
@@ -656,0 +654,0 @@ Html5QrcodeScanner.prototype.getCameraPermissionButtonId = function () { |
import { QrcodeErrorCallback, QrcodeSuccessCallback, Html5QrcodeSupportedFormats, Html5QrcodeResult, QrDimensions, QrDimensionFunction } from "./core"; | ||
import { CameraDevice, CameraCapabilities } from "./camera/core"; | ||
import { ExperimentalFeaturesConfig } from "./experimental-features"; | ||
import { StateManagerProxy, Html5QrcodeScannerState } from "./state-manager"; | ||
declare type Html5QrcodeIdentifier = string | MediaTrackConstraints; | ||
import { Html5QrcodeScannerState } from "./state-manager"; | ||
export interface Html5QrcodeConfigs { | ||
@@ -38,6 +37,6 @@ formatsToSupport?: Array<Html5QrcodeSupportedFormats> | undefined; | ||
private lastScanImageFile; | ||
stateManagerProxy: StateManagerProxy; | ||
private stateManagerProxy; | ||
isScanning: boolean; | ||
constructor(elementId: string, configOrVerbosityFlag?: boolean | Html5QrcodeFullConfig | undefined); | ||
start(cameraIdOrConfig: Html5QrcodeIdentifier, configuration: Html5QrcodeCameraScanConfig | undefined, qrCodeSuccessCallback: QrcodeSuccessCallback | undefined, qrCodeErrorCallback: QrcodeErrorCallback | undefined): Promise<null>; | ||
start(cameraIdOrConfig: string | MediaTrackConstraints, configuration: Html5QrcodeCameraScanConfig | undefined, qrCodeSuccessCallback: QrcodeSuccessCallback | undefined, qrCodeErrorCallback: QrcodeErrorCallback | undefined): Promise<null>; | ||
pause(shouldPauseVideo?: boolean): void; | ||
@@ -78,2 +77,1 @@ resume(): void; | ||
} | ||
export {}; |
@@ -71,3 +71,3 @@ "use strict"; | ||
InternalHtml5QrcodeConfig.prototype.isShadedBoxEnabled = function () { | ||
return !core_1.isNullOrUndefined(this.qrbox); | ||
return !(0, core_1.isNullOrUndefined)(this.qrbox); | ||
}; | ||
@@ -93,3 +93,3 @@ InternalHtml5QrcodeConfig.create = function (config, logger) { | ||
if (!document.getElementById(elementId)) { | ||
throw "HTML Element with id=" + elementId + " not found"; | ||
throw "HTML Element with id=".concat(elementId, " not found"); | ||
} | ||
@@ -200,3 +200,3 @@ this.elementId = elementId; | ||
this.showPausedState(); | ||
if (core_1.isNullOrUndefined(shouldPauseVideo) || shouldPauseVideo !== true) { | ||
if ((0, core_1.isNullOrUndefined)(shouldPauseVideo) || shouldPauseVideo !== true) { | ||
shouldPauseVideo = false; | ||
@@ -280,3 +280,3 @@ } | ||
} | ||
if (core_1.isNullOrUndefined(showImage)) { | ||
if ((0, core_1.isNullOrUndefined)(showImage)) { | ||
showImage = true; | ||
@@ -334,3 +334,3 @@ } | ||
catch (exception) { | ||
reject("QR code parse error, error = " + exception); | ||
reject("QR code parse error, error = ".concat(exception)); | ||
} | ||
@@ -413,7 +413,7 @@ }; | ||
var format = _a[_i]; | ||
if (core_1.isValidHtml5QrcodeSupportedFormats(format)) { | ||
if ((0, core_1.isValidHtml5QrcodeSupportedFormats)(format)) { | ||
supportedFormats.push(format); | ||
} | ||
else { | ||
this.logger.warn("Invalid format: " + format + " passed in config, ignoring."); | ||
this.logger.warn("Invalid format: ".concat(format, " passed in config, ignoring.")); | ||
} | ||
@@ -427,13 +427,13 @@ } | ||
Html5Qrcode.prototype.getUseBarCodeDetectorIfSupported = function (config) { | ||
if (core_1.isNullOrUndefined(config)) { | ||
if ((0, core_1.isNullOrUndefined)(config)) { | ||
return true; | ||
} | ||
if (!core_1.isNullOrUndefined(config.useBarCodeDetectorIfSupported)) { | ||
if (!(0, core_1.isNullOrUndefined)(config.useBarCodeDetectorIfSupported)) { | ||
return config.useBarCodeDetectorIfSupported !== false; | ||
} | ||
if (core_1.isNullOrUndefined(config.experimentalFeatures)) { | ||
if ((0, core_1.isNullOrUndefined)(config.experimentalFeatures)) { | ||
return true; | ||
} | ||
var experimentalFeatures = config.experimentalFeatures; | ||
if (core_1.isNullOrUndefined(experimentalFeatures.useBarCodeDetectorIfSupported)) { | ||
if ((0, core_1.isNullOrUndefined)(experimentalFeatures.useBarCodeDetectorIfSupported)) { | ||
return true; | ||
@@ -451,3 +451,3 @@ } | ||
throw "minimum size of 'config.qrbox' dimension value is" | ||
+ (" " + Constants.MIN_QR_BOX_SIZE + "px."); | ||
+ " ".concat(Constants.MIN_QR_BOX_SIZE, "px."); | ||
} | ||
@@ -499,3 +499,3 @@ }; | ||
} | ||
var qrboxSize = core_1.isNullOrUndefined(internalConfig.qrbox) ? | ||
var qrboxSize = (0, core_1.isNullOrUndefined)(internalConfig.qrbox) ? | ||
{ width: viewfinderWidth, height: viewfinderHeight } : internalConfig.qrbox; | ||
@@ -536,3 +536,3 @@ this.validateQrboxConfig(qrboxSize); | ||
var scannerPausedUiElement = document.createElement("div"); | ||
scannerPausedUiElement.innerText = "Scanner paused"; | ||
scannerPausedUiElement.innerText = strings_1.Html5QrcodeStrings.scannerPaused(); | ||
scannerPausedUiElement.style.display = "none"; | ||
@@ -542,3 +542,4 @@ scannerPausedUiElement.style.position = "absolute"; | ||
scannerPausedUiElement.style.zIndex = "1"; | ||
scannerPausedUiElement.style.background = "yellow"; | ||
scannerPausedUiElement.style.background = "rgba(9, 9, 9, 0.46)"; | ||
scannerPausedUiElement.style.color = "#FFECEC"; | ||
scannerPausedUiElement.style.textAlign = "center"; | ||
@@ -623,3 +624,3 @@ scannerPausedUiElement.style.width = "100%"; | ||
throw "config has invalid 'facingMode' value = " | ||
+ ("'" + value + "'"); | ||
+ "'".concat(value, "'"); | ||
} | ||
@@ -630,7 +631,7 @@ }; | ||
throw "'cameraIdOrConfig' object should have exactly 1 key," | ||
+ (" if passed as an object, found " + keys.length + " keys"); | ||
+ " if passed as an object, found ".concat(keys.length, " keys"); | ||
} | ||
var key = Object.keys(cameraIdOrConfig)[0]; | ||
if (key !== facingModeKey && key !== deviceIdKey) { | ||
throw "Only '" + facingModeKey + "' and '" + deviceIdKey + "' " | ||
throw "Only '".concat(facingModeKey, "' and '").concat(deviceIdKey, "' ") | ||
+ " are supported for 'cameraIdOrConfig'"; | ||
@@ -647,6 +648,6 @@ } | ||
if (exactKey in facingMode) { | ||
if (isValidFacingModeValue(facingMode["" + exactKey])) { | ||
if (isValidFacingModeValue(facingMode["".concat(exactKey)])) { | ||
return { | ||
facingMode: { | ||
exact: facingMode["" + exactKey] | ||
exact: facingMode["".concat(exactKey)] | ||
} | ||
@@ -658,3 +659,3 @@ }; | ||
throw "'facingMode' should be string or object with" | ||
+ (" " + exactKey + " as key."); | ||
+ " ".concat(exactKey, " as key."); | ||
} | ||
@@ -664,3 +665,3 @@ } | ||
var type_1 = (typeof facingMode); | ||
throw "Invalid type of 'facingMode' = " + type_1; | ||
throw "Invalid type of 'facingMode' = ".concat(type_1); | ||
} | ||
@@ -676,3 +677,3 @@ } | ||
return { | ||
deviceId: { exact: deviceId["" + exactKey] } | ||
deviceId: { exact: deviceId["".concat(exactKey)] } | ||
}; | ||
@@ -682,3 +683,3 @@ } | ||
throw "'deviceId' should be string or object with" | ||
+ (" " + exactKey + " as key."); | ||
+ " ".concat(exactKey, " as key."); | ||
} | ||
@@ -688,3 +689,3 @@ } | ||
var type_2 = (typeof deviceId); | ||
throw "Invalid type of 'deviceId' = " + type_2; | ||
throw "Invalid type of 'deviceId' = ".concat(type_2); | ||
} | ||
@@ -694,3 +695,3 @@ } | ||
var type = (typeof cameraIdOrConfig); | ||
throw "Invalid type of 'cameraIdOrConfig' = " + type; | ||
throw "Invalid type of 'cameraIdOrConfig' = ".concat(type); | ||
}; | ||
@@ -721,4 +722,4 @@ Html5Qrcode.prototype.computeCanvasDrawConfig = function (imageWidth, imageHeight, containerWidth, containerHeight) { | ||
this.logger.log("Image downsampled from " | ||
+ (formerImageWidth + "X" + formerImageHeight) | ||
+ (" to " + imageWidth + "X" + imageHeight + ".")); | ||
+ "".concat(formerImageWidth, "X").concat(formerImageHeight) | ||
+ " to ".concat(imageWidth, "X").concat(imageHeight, ".")); | ||
return this.computeCanvasDrawConfig(imageWidth, imageHeight, containerWidth, containerHeight); | ||
@@ -761,6 +762,6 @@ } | ||
var canvasElement = document.createElement("canvas"); | ||
canvasElement.style.width = canvasWidth + "px"; | ||
canvasElement.style.height = canvasHeight + "px"; | ||
canvasElement.style.width = "".concat(canvasWidth, "px"); | ||
canvasElement.style.height = "".concat(canvasHeight, "px"); | ||
canvasElement.style.display = "none"; | ||
canvasElement.id = core_1.isNullOrUndefined(customId) | ||
canvasElement.id = (0, core_1.isNullOrUndefined)(customId) | ||
? "qr-canvas" : customId; | ||
@@ -790,9 +791,9 @@ return canvasElement; | ||
shadingElement.style.borderLeft | ||
= rightLeftBorderSize + "px solid rgba(0, 0, 0, 0.48)"; | ||
= "".concat(rightLeftBorderSize, "px solid rgba(0, 0, 0, 0.48)"); | ||
shadingElement.style.borderRight | ||
= rightLeftBorderSize + "px solid rgba(0, 0, 0, 0.48)"; | ||
= "".concat(rightLeftBorderSize, "px solid rgba(0, 0, 0, 0.48)"); | ||
shadingElement.style.borderTop | ||
= topBottomBorderSize + "px solid rgba(0, 0, 0, 0.48)"; | ||
= "".concat(topBottomBorderSize, "px solid rgba(0, 0, 0, 0.48)"); | ||
shadingElement.style.borderBottom | ||
= topBottomBorderSize + "px solid rgba(0, 0, 0, 0.48)"; | ||
= "".concat(topBottomBorderSize, "px solid rgba(0, 0, 0, 0.48)"); | ||
shadingElement.style.boxSizing = "border-box"; | ||
@@ -803,3 +804,3 @@ shadingElement.style.top = "0px"; | ||
shadingElement.style.right = "0px"; | ||
shadingElement.id = "" + Constants.SHADED_REGION_ELEMENT_ID; | ||
shadingElement.id = "".concat(Constants.SHADED_REGION_ELEMENT_ID); | ||
if ((width - qrboxSize.width) < 11 | ||
@@ -828,15 +829,15 @@ || (height - qrboxSize.height) < 11) { | ||
elem.style.backgroundColor = Constants.BORDER_SHADER_DEFAULT_COLOR; | ||
elem.style.width = width + "px"; | ||
elem.style.height = height + "px"; | ||
elem.style.width = "".concat(width, "px"); | ||
elem.style.height = "".concat(height, "px"); | ||
if (top !== null) { | ||
elem.style.top = top + "px"; | ||
elem.style.top = "".concat(top, "px"); | ||
} | ||
if (bottom !== null) { | ||
elem.style.bottom = bottom + "px"; | ||
elem.style.bottom = "".concat(bottom, "px"); | ||
} | ||
if (isLeft) { | ||
elem.style.left = side + "px"; | ||
elem.style.left = "".concat(side, "px"); | ||
} | ||
else { | ||
elem.style.right = side + "px"; | ||
elem.style.right = "".concat(side, "px"); | ||
} | ||
@@ -843,0 +844,0 @@ if (!this.borderShaders) { |
@@ -1,5 +0,6 @@ | ||
export { Html5Qrcode } from "./html5-qrcode"; | ||
export { Html5Qrcode, Html5QrcodeFullConfig, Html5QrcodeCameraScanConfig } from "./html5-qrcode"; | ||
export { Html5QrcodeScanner } from "./html5-qrcode-scanner"; | ||
export { Html5QrcodeSupportedFormats } from "./core"; | ||
export { Html5QrcodeSupportedFormats, Html5QrcodeResult, QrcodeSuccessCallback, QrcodeErrorCallback } from "./core"; | ||
export { Html5QrcodeScannerState } from "./state-manager"; | ||
export { Html5QrcodeScanType } from "./core"; | ||
export { CameraCapabilities, CameraDevice } from "./camera/core"; |
@@ -17,3 +17,3 @@ "use strict"; | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -124,3 +124,3 @@ if (y = 0, t) op = [op[0] & 2, t.value]; | ||
else { | ||
this.logger.warn(requestedFormat + " is not supported by" | ||
this.logger.warn("".concat(requestedFormat, " is not supported by") | ||
+ "BarcodeDetectorDelegate"); | ||
@@ -133,3 +133,3 @@ } | ||
if (!this.reverseFormatMap.has(barcodeDetectorFormat)) { | ||
throw "reverseFormatMap doesn't have " + barcodeDetectorFormat; | ||
throw "reverseFormatMap doesn't have ".concat(barcodeDetectorFormat); | ||
} | ||
@@ -136,0 +136,0 @@ return this.reverseFormatMap.get(barcodeDetectorFormat); |
@@ -69,3 +69,3 @@ "use strict"; | ||
if (newState === disallowedState) { | ||
throw "Cannot transition from " + this.state + " to " + newState; | ||
throw "Cannot transition from ".concat(this.state, " to ").concat(newState); | ||
} | ||
@@ -72,0 +72,0 @@ } |
@@ -8,2 +8,3 @@ export declare class Html5QrcodeStrings { | ||
static insecureContextCameraQueryError(): string; | ||
static scannerPaused(): string; | ||
} | ||
@@ -10,0 +11,0 @@ export declare class Html5QrcodeScannerStrings { |
@@ -8,6 +8,6 @@ "use strict"; | ||
Html5QrcodeStrings.codeParseError = function (exception) { | ||
return "QR code parse error, error = " + exception; | ||
return "QR code parse error, error = ".concat(exception); | ||
}; | ||
Html5QrcodeStrings.errorGettingUserMedia = function (error) { | ||
return "Error getting userMedia, error = " + error; | ||
return "Error getting userMedia, error = ".concat(error); | ||
}; | ||
@@ -29,2 +29,5 @@ Html5QrcodeStrings.onlyDeviceSupportedError = function () { | ||
}; | ||
Html5QrcodeStrings.scannerPaused = function () { | ||
return "Scanner paused"; | ||
}; | ||
return Html5QrcodeStrings; | ||
@@ -52,3 +55,3 @@ }()); | ||
Html5QrcodeScannerStrings.lastMatch = function (decodedText) { | ||
return "Last Match: " + decodedText; | ||
return "Last Match: ".concat(decodedText); | ||
}; | ||
@@ -55,0 +58,0 @@ Html5QrcodeScannerStrings.codeScannerTitle = function () { |
@@ -26,3 +26,3 @@ "use strict"; | ||
cameraSelectionContainer.innerText | ||
= selectCameraString + " (" + this.cameras.length + ") "; | ||
= "".concat(selectCameraString, " (").concat(this.cameras.length, ") "); | ||
} | ||
@@ -72,3 +72,3 @@ var anonymousCameraId = 1; | ||
if (!this.hasValue(value)) { | ||
throw new Error(value + " is not present in the camera list."); | ||
throw new Error("".concat(value, " is not present in the camera list.")); | ||
} | ||
@@ -75,0 +75,0 @@ this.selectElement.value = value; |
@@ -1,2 +0,2 @@ | ||
export declare type OnCameraZoomValueChangeCallback = (zoomValue: number) => void; | ||
export type OnCameraZoomValueChangeCallback = (zoomValue: number) => void; | ||
export declare class CameraZoomUi { | ||
@@ -3,0 +3,0 @@ private zoomElementContainer; |
@@ -31,3 +31,3 @@ "use strict"; | ||
var zoomString = strings_1.Html5QrcodeScannerStrings.zoom(); | ||
this.rangeText.innerText = this.rangeInput.value + "x " + zoomString; | ||
this.rangeText.innerText = "".concat(this.rangeInput.value, "x ").concat(zoomString); | ||
this.rangeText.style.marginRight = "10px"; | ||
@@ -42,3 +42,3 @@ var $this = this; | ||
var zoomString = strings_1.Html5QrcodeScannerStrings.zoom(); | ||
this.rangeText.innerText = this.rangeInput.value + "x " + zoomString; | ||
this.rangeText.innerText = "".concat(this.rangeInput.value, "x ").concat(zoomString); | ||
if (this.onChangeCallback) { | ||
@@ -45,0 +45,0 @@ this.onChangeCallback(parseFloat(this.rangeInput.value)); |
@@ -1,2 +0,2 @@ | ||
export declare type OnFileSelected = (file: File) => void; | ||
export type OnFileSelected = (file: File) => void; | ||
export declare class FileSelectionUi { | ||
@@ -3,0 +3,0 @@ private readonly fileBasedScanRegion; |
@@ -147,3 +147,3 @@ "use strict"; | ||
var last8Chars = imageFileName.substring(length_1 - 8, length_1); | ||
imageFileName = start8Chars + "...." + last8Chars; | ||
imageFileName = "".concat(start8Chars, "....").concat(last8Chars); | ||
} | ||
@@ -150,0 +150,0 @@ var newText = strings_1.Html5QrcodeScannerStrings.fileSelectionChooseAnother() |
@@ -36,3 +36,3 @@ "use strict"; | ||
if (supportedScanTypes.length > maxExpectedValues) { | ||
throw "Max " + maxExpectedValues + " values expected for " | ||
throw "Max ".concat(maxExpectedValues, " values expected for ") | ||
+ "supportedScanTypes"; | ||
@@ -44,3 +44,3 @@ } | ||
.includes(scanType)) { | ||
throw "Unsupported scan type " + scanType; | ||
throw "Unsupported scan type ".concat(scanType); | ||
} | ||
@@ -47,0 +47,0 @@ } |
import { BooleanCameraCapability } from "../../camera/core"; | ||
export declare type OnTorchActionFailureCallback = (failureMessage: string) => void; | ||
export type OnTorchActionFailureCallback = (failureMessage: string) => void; | ||
interface TorchButtonController { | ||
@@ -4,0 +4,0 @@ disable(): void; |
@@ -17,3 +17,3 @@ "use strict"; | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -20,0 +20,0 @@ if (y = 0, t) op = [op[0] & 2, t.value]; |
@@ -11,3 +11,3 @@ "use strict"; | ||
logger.logError("videoConstraints should be of type object, the " | ||
+ ("object passed is of type " + typeofVideoConstraints + "."), true); | ||
+ "object passed is of type ".concat(typeofVideoConstraints, "."), true); | ||
return false; | ||
@@ -30,3 +30,3 @@ } | ||
if (bannedkeysSet.has(key)) { | ||
logger.logError(key + " is not supported videoConstaints.", true); | ||
logger.logError("".concat(key, " is not supported videoConstaints."), true); | ||
return false; | ||
@@ -33,0 +33,0 @@ } |
@@ -85,3 +85,3 @@ "use strict"; | ||
if (!this.reverseFormatMap.has(zxingFormat)) { | ||
throw "reverseFormatMap doesn't have " + zxingFormat; | ||
throw "reverseFormatMap doesn't have ".concat(zxingFormat); | ||
} | ||
@@ -98,3 +98,3 @@ return this.reverseFormatMap.get(zxingFormat); | ||
else { | ||
this.logger.logError(requestedFormat + " is not supported by" | ||
this.logger.logError("".concat(requestedFormat, " is not supported by") | ||
+ "ZXingHtml5QrcodeShim"); | ||
@@ -101,0 +101,0 @@ } |
@@ -40,3 +40,3 @@ export declare enum Html5QrcodeSupportedFormats { | ||
} | ||
export declare type QrDimensionFunction = (viewfinderWidth: number, viewfinderHeight: number) => QrDimensions; | ||
export type QrDimensionFunction = (viewfinderWidth: number, viewfinderHeight: number) => QrDimensions; | ||
export interface QrBounds extends QrDimensions { | ||
@@ -83,4 +83,4 @@ x: number; | ||
} | ||
export declare type QrcodeSuccessCallback = (decodedText: string, result: Html5QrcodeResult) => void; | ||
export declare type QrcodeErrorCallback = (errorMessage: string, error: Html5QrcodeError) => void; | ||
export type QrcodeSuccessCallback = (decodedText: string, result: Html5QrcodeResult) => void; | ||
export type QrcodeErrorCallback = (errorMessage: string, error: Html5QrcodeError) => void; | ||
export interface QrcodeDecoderAsync { | ||
@@ -87,0 +87,0 @@ decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; |
@@ -21,3 +21,3 @@ export interface CameraDevice { | ||
} | ||
export declare type OnRenderSurfaceReady = (viewfinderWidth: number, viewfinderHeight: number) => void; | ||
export type OnRenderSurfaceReady = (viewfinderWidth: number, viewfinderHeight: number) => void; | ||
export interface RenderingCallbacks { | ||
@@ -24,0 +24,0 @@ onRenderSurfaceReady: OnRenderSurfaceReady; |
@@ -40,3 +40,3 @@ export declare enum Html5QrcodeSupportedFormats { | ||
} | ||
export declare type QrDimensionFunction = (viewfinderWidth: number, viewfinderHeight: number) => QrDimensions; | ||
export type QrDimensionFunction = (viewfinderWidth: number, viewfinderHeight: number) => QrDimensions; | ||
export interface QrBounds extends QrDimensions { | ||
@@ -83,4 +83,4 @@ x: number; | ||
} | ||
export declare type QrcodeSuccessCallback = (decodedText: string, result: Html5QrcodeResult) => void; | ||
export declare type QrcodeErrorCallback = (errorMessage: string, error: Html5QrcodeError) => void; | ||
export type QrcodeSuccessCallback = (decodedText: string, result: Html5QrcodeResult) => void; | ||
export type QrcodeErrorCallback = (errorMessage: string, error: Html5QrcodeError) => void; | ||
export interface QrcodeDecoderAsync { | ||
@@ -87,0 +87,0 @@ decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; |
import { Html5QrcodeScanType, QrcodeSuccessCallback, QrcodeErrorCallback } from "./core"; | ||
import { Html5QrcodeConfigs, Html5QrcodeCameraScanConfig } from "./html5-qrcode"; | ||
import { Html5QrcodeScannerState } from "./state-manager"; | ||
interface Html5QrcodeScannerConfig extends Html5QrcodeCameraScanConfig, Html5QrcodeConfigs { | ||
export interface Html5QrcodeScannerConfig extends Html5QrcodeCameraScanConfig, Html5QrcodeConfigs { | ||
rememberLastUsedCamera?: boolean | undefined; | ||
@@ -68,2 +68,1 @@ supportedScanTypes?: Array<Html5QrcodeScanType> | []; | ||
} | ||
export {}; |
@@ -204,3 +204,2 @@ import { Html5QrcodeConstants, Html5QrcodeScanType, Html5QrcodeErrorFactory, BaseLoggger, isNullOrUndefined, clip, } from "./core"; | ||
setupInitialDashboard(dashboard) { | ||
const $this = this; | ||
this.createSection(dashboard); | ||
@@ -303,3 +302,2 @@ this.createSectionControlPanel(); | ||
createSectionControlPanel() { | ||
const $this = this; | ||
const section = document.getElementById(this.getDashboardSectionId()); | ||
@@ -306,0 +304,0 @@ const sectionControlPanel = document.createElement("div"); |
import { QrcodeErrorCallback, QrcodeSuccessCallback, Html5QrcodeSupportedFormats, Html5QrcodeResult, QrDimensions, QrDimensionFunction } from "./core"; | ||
import { CameraDevice, CameraCapabilities } from "./camera/core"; | ||
import { ExperimentalFeaturesConfig } from "./experimental-features"; | ||
import { StateManagerProxy, Html5QrcodeScannerState } from "./state-manager"; | ||
declare type Html5QrcodeIdentifier = string | MediaTrackConstraints; | ||
import { Html5QrcodeScannerState } from "./state-manager"; | ||
export interface Html5QrcodeConfigs { | ||
@@ -38,6 +37,6 @@ formatsToSupport?: Array<Html5QrcodeSupportedFormats> | undefined; | ||
private lastScanImageFile; | ||
stateManagerProxy: StateManagerProxy; | ||
private stateManagerProxy; | ||
isScanning: boolean; | ||
constructor(elementId: string, configOrVerbosityFlag?: boolean | Html5QrcodeFullConfig | undefined); | ||
start(cameraIdOrConfig: Html5QrcodeIdentifier, configuration: Html5QrcodeCameraScanConfig | undefined, qrCodeSuccessCallback: QrcodeSuccessCallback | undefined, qrCodeErrorCallback: QrcodeErrorCallback | undefined): Promise<null>; | ||
start(cameraIdOrConfig: string | MediaTrackConstraints, configuration: Html5QrcodeCameraScanConfig | undefined, qrCodeSuccessCallback: QrcodeSuccessCallback | undefined, qrCodeErrorCallback: QrcodeErrorCallback | undefined): Promise<null>; | ||
pause(shouldPauseVideo?: boolean): void; | ||
@@ -78,2 +77,1 @@ resume(): void; | ||
} | ||
export {}; |
@@ -498,3 +498,3 @@ import { BaseLoggger, Html5QrcodeResultFactory, Html5QrcodeErrorFactory, Html5QrcodeSupportedFormats, isValidHtml5QrcodeSupportedFormats, Html5QrcodeConstants, isNullOrUndefined } from "./core"; | ||
const scannerPausedUiElement = document.createElement("div"); | ||
scannerPausedUiElement.innerText = "Scanner paused"; | ||
scannerPausedUiElement.innerText = Html5QrcodeStrings.scannerPaused(); | ||
scannerPausedUiElement.style.display = "none"; | ||
@@ -504,3 +504,4 @@ scannerPausedUiElement.style.position = "absolute"; | ||
scannerPausedUiElement.style.zIndex = "1"; | ||
scannerPausedUiElement.style.background = "yellow"; | ||
scannerPausedUiElement.style.background = "rgba(9, 9, 9, 0.46)"; | ||
scannerPausedUiElement.style.color = "#FFECEC"; | ||
scannerPausedUiElement.style.textAlign = "center"; | ||
@@ -507,0 +508,0 @@ scannerPausedUiElement.style.width = "100%"; |
@@ -1,5 +0,6 @@ | ||
export { Html5Qrcode } from "./html5-qrcode"; | ||
export { Html5Qrcode, Html5QrcodeFullConfig, Html5QrcodeCameraScanConfig } from "./html5-qrcode"; | ||
export { Html5QrcodeScanner } from "./html5-qrcode-scanner"; | ||
export { Html5QrcodeSupportedFormats } from "./core"; | ||
export { Html5QrcodeSupportedFormats, Html5QrcodeResult, QrcodeSuccessCallback, QrcodeErrorCallback } from "./core"; | ||
export { Html5QrcodeScannerState } from "./state-manager"; | ||
export { Html5QrcodeScanType } from "./core"; | ||
export { CameraCapabilities, CameraDevice } from "./camera/core"; |
@@ -12,2 +12,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
export class BarcodeDetectorDelegate { | ||
static isSupported() { | ||
if (!("BarcodeDetector" in window)) { | ||
return false; | ||
} | ||
const dummyDetector = new BarcodeDetector({ formats: ["qr_code"] }); | ||
return typeof dummyDetector !== "undefined"; | ||
} | ||
constructor(requestedFormats, verbose, logger) { | ||
@@ -42,9 +49,2 @@ this.formatMap = new Map([ | ||
} | ||
static isSupported() { | ||
if (!("BarcodeDetector" in window)) { | ||
return false; | ||
} | ||
const dummyDetector = new BarcodeDetector({ formats: ["qr_code"] }); | ||
return typeof dummyDetector !== "undefined"; | ||
} | ||
decodeAsync(canvas) { | ||
@@ -51,0 +51,0 @@ return __awaiter(this, void 0, void 0, function* () { |
@@ -8,2 +8,3 @@ export declare class Html5QrcodeStrings { | ||
static insecureContextCameraQueryError(): string; | ||
static scannerPaused(): string; | ||
} | ||
@@ -10,0 +11,0 @@ export declare class Html5QrcodeScannerStrings { |
@@ -23,2 +23,5 @@ export class Html5QrcodeStrings { | ||
} | ||
static scannerPaused() { | ||
return "Scanner paused"; | ||
} | ||
} | ||
@@ -25,0 +28,0 @@ export class Html5QrcodeScannerStrings { |
@@ -1,2 +0,2 @@ | ||
export declare type OnCameraZoomValueChangeCallback = (zoomValue: number) => void; | ||
export type OnCameraZoomValueChangeCallback = (zoomValue: number) => void; | ||
export declare class CameraZoomUi { | ||
@@ -3,0 +3,0 @@ private zoomElementContainer; |
@@ -1,2 +0,2 @@ | ||
export declare type OnFileSelected = (file: File) => void; | ||
export type OnFileSelected = (file: File) => void; | ||
export declare class FileSelectionUi { | ||
@@ -3,0 +3,0 @@ private readonly fileBasedScanRegion; |
import { BooleanCameraCapability } from "../../camera/core"; | ||
export declare type OnTorchActionFailureCallback = (failureMessage: string) => void; | ||
export type OnTorchActionFailureCallback = (failureMessage: string) => void; | ||
interface TorchButtonController { | ||
@@ -4,0 +4,0 @@ disable(): void; |
@@ -31,3 +31,3 @@ var __extends = (this && this.__extends) || (function () { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -112,3 +112,3 @@ if (y = 0, t) op = [op[0] & 2, t.value]; | ||
if (!this.isSupported()) { | ||
throw new Error(this.name + " capability not supported"); | ||
throw new Error("".concat(this.name, " capability not supported")); | ||
} | ||
@@ -155,3 +155,3 @@ }; | ||
var videoElement = document.createElement("video"); | ||
videoElement.style.width = width + "px"; | ||
videoElement.style.width = "".concat(width, "px"); | ||
videoElement.style.display = "block"; | ||
@@ -158,0 +158,0 @@ videoElement.muted = true; |
@@ -21,3 +21,3 @@ export interface CameraDevice { | ||
} | ||
export declare type OnRenderSurfaceReady = (viewfinderWidth: number, viewfinderHeight: number) => void; | ||
export type OnRenderSurfaceReady = (viewfinderWidth: number, viewfinderHeight: number) => void; | ||
export interface RenderingCallbacks { | ||
@@ -24,0 +24,0 @@ onRenderSurfaceReady: OnRenderSurfaceReady; |
@@ -16,3 +16,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -19,0 +19,0 @@ if (y = 0, t) op = [op[0] & 2, t.value]; |
@@ -16,3 +16,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -19,0 +19,0 @@ if (y = 0, t) op = [op[0] & 2, t.value]; |
@@ -16,3 +16,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -19,0 +19,0 @@ if (y = 0, t) op = [op[0] & 2, t.value]; |
@@ -16,3 +16,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -132,3 +132,3 @@ if (y = 0, t) op = [op[0] & 2, t.value]; | ||
var mean = sum / this.executionResults.length; | ||
console.log(mean + " ms for " + this.executionResults.length + " last runs."); | ||
console.log("".concat(mean, " ms for ").concat(this.executionResults.length, " last runs.")); | ||
this.executions = 0; | ||
@@ -135,0 +135,0 @@ this.executionResults = []; |
@@ -40,3 +40,3 @@ export declare enum Html5QrcodeSupportedFormats { | ||
} | ||
export declare type QrDimensionFunction = (viewfinderWidth: number, viewfinderHeight: number) => QrDimensions; | ||
export type QrDimensionFunction = (viewfinderWidth: number, viewfinderHeight: number) => QrDimensions; | ||
export interface QrBounds extends QrDimensions { | ||
@@ -83,4 +83,4 @@ x: number; | ||
} | ||
export declare type QrcodeSuccessCallback = (decodedText: string, result: Html5QrcodeResult) => void; | ||
export declare type QrcodeErrorCallback = (errorMessage: string, error: Html5QrcodeError) => void; | ||
export type QrcodeSuccessCallback = (decodedText: string, result: Html5QrcodeResult) => void; | ||
export type QrcodeErrorCallback = (errorMessage: string, error: Html5QrcodeError) => void; | ||
export interface QrcodeDecoderAsync { | ||
@@ -87,0 +87,0 @@ decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; |
@@ -77,3 +77,3 @@ export var Html5QrcodeSupportedFormats; | ||
if (!html5QrcodeSupportedFormatsTextMap.has(format)) { | ||
throw format + " not in html5QrcodeSupportedFormatsTextMap"; | ||
throw "".concat(format, " not in html5QrcodeSupportedFormatsTextMap"); | ||
} | ||
@@ -80,0 +80,0 @@ return new QrcodeResultFormat(format, html5QrcodeSupportedFormatsTextMap.get(format)); |
import { Html5QrcodeScanType, QrcodeSuccessCallback, QrcodeErrorCallback } from "./core"; | ||
import { Html5QrcodeConfigs, Html5QrcodeCameraScanConfig } from "./html5-qrcode"; | ||
import { Html5QrcodeScannerState } from "./state-manager"; | ||
interface Html5QrcodeScannerConfig extends Html5QrcodeCameraScanConfig, Html5QrcodeConfigs { | ||
export interface Html5QrcodeScannerConfig extends Html5QrcodeCameraScanConfig, Html5QrcodeConfigs { | ||
rememberLastUsedCamera?: boolean | undefined; | ||
@@ -68,2 +68,1 @@ supportedScanTypes?: Array<Html5QrcodeScanType> | []; | ||
} | ||
export {}; |
@@ -48,3 +48,3 @@ import { Html5QrcodeConstants, Html5QrcodeScanType, Html5QrcodeErrorFactory, BaseLoggger, isNullOrUndefined, clip, } from "./core"; | ||
if (!document.getElementById(elementId)) { | ||
throw "HTML Element with id=" + elementId + " not found"; | ||
throw "HTML Element with id=".concat(elementId, " not found"); | ||
} | ||
@@ -84,3 +84,3 @@ this.scanTypeSelector = new ScanTypeSelector(this.config.supportedScanTypes); | ||
if (!container) { | ||
throw "HTML Element with id=" + this.elementId + " not found"; | ||
throw "HTML Element with id=".concat(this.elementId, " not found"); | ||
} | ||
@@ -208,3 +208,2 @@ container.innerHTML = ""; | ||
Html5QrcodeScanner.prototype.setupInitialDashboard = function (dashboard) { | ||
var $this = this; | ||
this.createSection(dashboard); | ||
@@ -307,3 +306,2 @@ this.createSectionControlPanel(); | ||
Html5QrcodeScanner.prototype.createSectionControlPanel = function () { | ||
var $this = this; | ||
var section = document.getElementById(this.getDashboardSectionId()); | ||
@@ -632,6 +630,6 @@ var sectionControlPanel = document.createElement("div"); | ||
Html5QrcodeScanner.prototype.getDashboardSectionId = function () { | ||
return this.elementId + "__dashboard_section"; | ||
return "".concat(this.elementId, "__dashboard_section"); | ||
}; | ||
Html5QrcodeScanner.prototype.getDashboardSectionCameraScanRegionId = function () { | ||
return this.elementId + "__dashboard_section_csr"; | ||
return "".concat(this.elementId, "__dashboard_section_csr"); | ||
}; | ||
@@ -642,9 +640,9 @@ Html5QrcodeScanner.prototype.getDashboardSectionSwapLinkId = function () { | ||
Html5QrcodeScanner.prototype.getScanRegionId = function () { | ||
return this.elementId + "__scan_region"; | ||
return "".concat(this.elementId, "__scan_region"); | ||
}; | ||
Html5QrcodeScanner.prototype.getDashboardId = function () { | ||
return this.elementId + "__dashboard"; | ||
return "".concat(this.elementId, "__dashboard"); | ||
}; | ||
Html5QrcodeScanner.prototype.getHeaderMessageContainerId = function () { | ||
return this.elementId + "__header_message"; | ||
return "".concat(this.elementId, "__header_message"); | ||
}; | ||
@@ -651,0 +649,0 @@ Html5QrcodeScanner.prototype.getCameraPermissionButtonId = function () { |
import { QrcodeErrorCallback, QrcodeSuccessCallback, Html5QrcodeSupportedFormats, Html5QrcodeResult, QrDimensions, QrDimensionFunction } from "./core"; | ||
import { CameraDevice, CameraCapabilities } from "./camera/core"; | ||
import { ExperimentalFeaturesConfig } from "./experimental-features"; | ||
import { StateManagerProxy, Html5QrcodeScannerState } from "./state-manager"; | ||
declare type Html5QrcodeIdentifier = string | MediaTrackConstraints; | ||
import { Html5QrcodeScannerState } from "./state-manager"; | ||
export interface Html5QrcodeConfigs { | ||
@@ -38,6 +37,6 @@ formatsToSupport?: Array<Html5QrcodeSupportedFormats> | undefined; | ||
private lastScanImageFile; | ||
stateManagerProxy: StateManagerProxy; | ||
private stateManagerProxy; | ||
isScanning: boolean; | ||
constructor(elementId: string, configOrVerbosityFlag?: boolean | Html5QrcodeFullConfig | undefined); | ||
start(cameraIdOrConfig: Html5QrcodeIdentifier, configuration: Html5QrcodeCameraScanConfig | undefined, qrCodeSuccessCallback: QrcodeSuccessCallback | undefined, qrCodeErrorCallback: QrcodeErrorCallback | undefined): Promise<null>; | ||
start(cameraIdOrConfig: string | MediaTrackConstraints, configuration: Html5QrcodeCameraScanConfig | undefined, qrCodeSuccessCallback: QrcodeSuccessCallback | undefined, qrCodeErrorCallback: QrcodeErrorCallback | undefined): Promise<null>; | ||
pause(shouldPauseVideo?: boolean): void; | ||
@@ -78,2 +77,1 @@ resume(): void; | ||
} | ||
export {}; |
@@ -89,3 +89,3 @@ var __extends = (this && this.__extends) || (function () { | ||
if (!document.getElementById(elementId)) { | ||
throw "HTML Element with id=" + elementId + " not found"; | ||
throw "HTML Element with id=".concat(elementId, " not found"); | ||
} | ||
@@ -328,3 +328,3 @@ this.elementId = elementId; | ||
catch (exception) { | ||
reject("QR code parse error, error = " + exception); | ||
reject("QR code parse error, error = ".concat(exception)); | ||
} | ||
@@ -411,3 +411,3 @@ }; | ||
else { | ||
this.logger.warn("Invalid format: " + format + " passed in config, ignoring."); | ||
this.logger.warn("Invalid format: ".concat(format, " passed in config, ignoring.")); | ||
} | ||
@@ -444,3 +444,3 @@ } | ||
throw "minimum size of 'config.qrbox' dimension value is" | ||
+ (" " + Constants.MIN_QR_BOX_SIZE + "px."); | ||
+ " ".concat(Constants.MIN_QR_BOX_SIZE, "px."); | ||
} | ||
@@ -528,3 +528,3 @@ }; | ||
var scannerPausedUiElement = document.createElement("div"); | ||
scannerPausedUiElement.innerText = "Scanner paused"; | ||
scannerPausedUiElement.innerText = Html5QrcodeStrings.scannerPaused(); | ||
scannerPausedUiElement.style.display = "none"; | ||
@@ -534,3 +534,4 @@ scannerPausedUiElement.style.position = "absolute"; | ||
scannerPausedUiElement.style.zIndex = "1"; | ||
scannerPausedUiElement.style.background = "yellow"; | ||
scannerPausedUiElement.style.background = "rgba(9, 9, 9, 0.46)"; | ||
scannerPausedUiElement.style.color = "#FFECEC"; | ||
scannerPausedUiElement.style.textAlign = "center"; | ||
@@ -615,3 +616,3 @@ scannerPausedUiElement.style.width = "100%"; | ||
throw "config has invalid 'facingMode' value = " | ||
+ ("'" + value + "'"); | ||
+ "'".concat(value, "'"); | ||
} | ||
@@ -622,7 +623,7 @@ }; | ||
throw "'cameraIdOrConfig' object should have exactly 1 key," | ||
+ (" if passed as an object, found " + keys.length + " keys"); | ||
+ " if passed as an object, found ".concat(keys.length, " keys"); | ||
} | ||
var key = Object.keys(cameraIdOrConfig)[0]; | ||
if (key !== facingModeKey && key !== deviceIdKey) { | ||
throw "Only '" + facingModeKey + "' and '" + deviceIdKey + "' " | ||
throw "Only '".concat(facingModeKey, "' and '").concat(deviceIdKey, "' ") | ||
+ " are supported for 'cameraIdOrConfig'"; | ||
@@ -639,6 +640,6 @@ } | ||
if (exactKey in facingMode) { | ||
if (isValidFacingModeValue(facingMode["" + exactKey])) { | ||
if (isValidFacingModeValue(facingMode["".concat(exactKey)])) { | ||
return { | ||
facingMode: { | ||
exact: facingMode["" + exactKey] | ||
exact: facingMode["".concat(exactKey)] | ||
} | ||
@@ -650,3 +651,3 @@ }; | ||
throw "'facingMode' should be string or object with" | ||
+ (" " + exactKey + " as key."); | ||
+ " ".concat(exactKey, " as key."); | ||
} | ||
@@ -656,3 +657,3 @@ } | ||
var type_1 = (typeof facingMode); | ||
throw "Invalid type of 'facingMode' = " + type_1; | ||
throw "Invalid type of 'facingMode' = ".concat(type_1); | ||
} | ||
@@ -668,3 +669,3 @@ } | ||
return { | ||
deviceId: { exact: deviceId["" + exactKey] } | ||
deviceId: { exact: deviceId["".concat(exactKey)] } | ||
}; | ||
@@ -674,3 +675,3 @@ } | ||
throw "'deviceId' should be string or object with" | ||
+ (" " + exactKey + " as key."); | ||
+ " ".concat(exactKey, " as key."); | ||
} | ||
@@ -680,3 +681,3 @@ } | ||
var type_2 = (typeof deviceId); | ||
throw "Invalid type of 'deviceId' = " + type_2; | ||
throw "Invalid type of 'deviceId' = ".concat(type_2); | ||
} | ||
@@ -686,3 +687,3 @@ } | ||
var type = (typeof cameraIdOrConfig); | ||
throw "Invalid type of 'cameraIdOrConfig' = " + type; | ||
throw "Invalid type of 'cameraIdOrConfig' = ".concat(type); | ||
}; | ||
@@ -713,4 +714,4 @@ Html5Qrcode.prototype.computeCanvasDrawConfig = function (imageWidth, imageHeight, containerWidth, containerHeight) { | ||
this.logger.log("Image downsampled from " | ||
+ (formerImageWidth + "X" + formerImageHeight) | ||
+ (" to " + imageWidth + "X" + imageHeight + ".")); | ||
+ "".concat(formerImageWidth, "X").concat(formerImageHeight) | ||
+ " to ".concat(imageWidth, "X").concat(imageHeight, ".")); | ||
return this.computeCanvasDrawConfig(imageWidth, imageHeight, containerWidth, containerHeight); | ||
@@ -753,4 +754,4 @@ } | ||
var canvasElement = document.createElement("canvas"); | ||
canvasElement.style.width = canvasWidth + "px"; | ||
canvasElement.style.height = canvasHeight + "px"; | ||
canvasElement.style.width = "".concat(canvasWidth, "px"); | ||
canvasElement.style.height = "".concat(canvasHeight, "px"); | ||
canvasElement.style.display = "none"; | ||
@@ -782,9 +783,9 @@ canvasElement.id = isNullOrUndefined(customId) | ||
shadingElement.style.borderLeft | ||
= rightLeftBorderSize + "px solid rgba(0, 0, 0, 0.48)"; | ||
= "".concat(rightLeftBorderSize, "px solid rgba(0, 0, 0, 0.48)"); | ||
shadingElement.style.borderRight | ||
= rightLeftBorderSize + "px solid rgba(0, 0, 0, 0.48)"; | ||
= "".concat(rightLeftBorderSize, "px solid rgba(0, 0, 0, 0.48)"); | ||
shadingElement.style.borderTop | ||
= topBottomBorderSize + "px solid rgba(0, 0, 0, 0.48)"; | ||
= "".concat(topBottomBorderSize, "px solid rgba(0, 0, 0, 0.48)"); | ||
shadingElement.style.borderBottom | ||
= topBottomBorderSize + "px solid rgba(0, 0, 0, 0.48)"; | ||
= "".concat(topBottomBorderSize, "px solid rgba(0, 0, 0, 0.48)"); | ||
shadingElement.style.boxSizing = "border-box"; | ||
@@ -795,3 +796,3 @@ shadingElement.style.top = "0px"; | ||
shadingElement.style.right = "0px"; | ||
shadingElement.id = "" + Constants.SHADED_REGION_ELEMENT_ID; | ||
shadingElement.id = "".concat(Constants.SHADED_REGION_ELEMENT_ID); | ||
if ((width - qrboxSize.width) < 11 | ||
@@ -820,15 +821,15 @@ || (height - qrboxSize.height) < 11) { | ||
elem.style.backgroundColor = Constants.BORDER_SHADER_DEFAULT_COLOR; | ||
elem.style.width = width + "px"; | ||
elem.style.height = height + "px"; | ||
elem.style.width = "".concat(width, "px"); | ||
elem.style.height = "".concat(height, "px"); | ||
if (top !== null) { | ||
elem.style.top = top + "px"; | ||
elem.style.top = "".concat(top, "px"); | ||
} | ||
if (bottom !== null) { | ||
elem.style.bottom = bottom + "px"; | ||
elem.style.bottom = "".concat(bottom, "px"); | ||
} | ||
if (isLeft) { | ||
elem.style.left = side + "px"; | ||
elem.style.left = "".concat(side, "px"); | ||
} | ||
else { | ||
elem.style.right = side + "px"; | ||
elem.style.right = "".concat(side, "px"); | ||
} | ||
@@ -835,0 +836,0 @@ if (!this.borderShaders) { |
@@ -1,5 +0,6 @@ | ||
export { Html5Qrcode } from "./html5-qrcode"; | ||
export { Html5Qrcode, Html5QrcodeFullConfig, Html5QrcodeCameraScanConfig } from "./html5-qrcode"; | ||
export { Html5QrcodeScanner } from "./html5-qrcode-scanner"; | ||
export { Html5QrcodeSupportedFormats } from "./core"; | ||
export { Html5QrcodeSupportedFormats, Html5QrcodeResult, QrcodeSuccessCallback, QrcodeErrorCallback } from "./core"; | ||
export { Html5QrcodeScannerState } from "./state-manager"; | ||
export { Html5QrcodeScanType } from "./core"; | ||
export { CameraCapabilities, CameraDevice } from "./camera/core"; |
@@ -16,3 +16,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -121,3 +121,3 @@ if (y = 0, t) op = [op[0] & 2, t.value]; | ||
else { | ||
this.logger.warn(requestedFormat + " is not supported by" | ||
this.logger.warn("".concat(requestedFormat, " is not supported by") | ||
+ "BarcodeDetectorDelegate"); | ||
@@ -130,3 +130,3 @@ } | ||
if (!this.reverseFormatMap.has(barcodeDetectorFormat)) { | ||
throw "reverseFormatMap doesn't have " + barcodeDetectorFormat; | ||
throw "reverseFormatMap doesn't have ".concat(barcodeDetectorFormat); | ||
} | ||
@@ -133,0 +133,0 @@ return this.reverseFormatMap.get(barcodeDetectorFormat); |
@@ -66,3 +66,3 @@ export var Html5QrcodeScannerState; | ||
if (newState === disallowedState) { | ||
throw "Cannot transition from " + this.state + " to " + newState; | ||
throw "Cannot transition from ".concat(this.state, " to ").concat(newState); | ||
} | ||
@@ -69,0 +69,0 @@ } |
@@ -8,2 +8,3 @@ export declare class Html5QrcodeStrings { | ||
static insecureContextCameraQueryError(): string; | ||
static scannerPaused(): string; | ||
} | ||
@@ -10,0 +11,0 @@ export declare class Html5QrcodeScannerStrings { |
@@ -5,6 +5,6 @@ var Html5QrcodeStrings = (function () { | ||
Html5QrcodeStrings.codeParseError = function (exception) { | ||
return "QR code parse error, error = " + exception; | ||
return "QR code parse error, error = ".concat(exception); | ||
}; | ||
Html5QrcodeStrings.errorGettingUserMedia = function (error) { | ||
return "Error getting userMedia, error = " + error; | ||
return "Error getting userMedia, error = ".concat(error); | ||
}; | ||
@@ -26,2 +26,5 @@ Html5QrcodeStrings.onlyDeviceSupportedError = function () { | ||
}; | ||
Html5QrcodeStrings.scannerPaused = function () { | ||
return "Scanner paused"; | ||
}; | ||
return Html5QrcodeStrings; | ||
@@ -49,3 +52,3 @@ }()); | ||
Html5QrcodeScannerStrings.lastMatch = function (decodedText) { | ||
return "Last Match: " + decodedText; | ||
return "Last Match: ".concat(decodedText); | ||
}; | ||
@@ -52,0 +55,0 @@ Html5QrcodeScannerStrings.codeScannerTitle = function () { |
@@ -23,3 +23,3 @@ import { BaseUiElementFactory, PublicUiElementIdAndClasses } from "./base"; | ||
cameraSelectionContainer.innerText | ||
= selectCameraString + " (" + this.cameras.length + ") "; | ||
= "".concat(selectCameraString, " (").concat(this.cameras.length, ") "); | ||
} | ||
@@ -69,3 +69,3 @@ var anonymousCameraId = 1; | ||
if (!this.hasValue(value)) { | ||
throw new Error(value + " is not present in the camera list."); | ||
throw new Error("".concat(value, " is not present in the camera list.")); | ||
} | ||
@@ -72,0 +72,0 @@ this.selectElement.value = value; |
@@ -1,2 +0,2 @@ | ||
export declare type OnCameraZoomValueChangeCallback = (zoomValue: number) => void; | ||
export type OnCameraZoomValueChangeCallback = (zoomValue: number) => void; | ||
export declare class CameraZoomUi { | ||
@@ -3,0 +3,0 @@ private zoomElementContainer; |
@@ -28,3 +28,3 @@ import { BaseUiElementFactory, PublicUiElementIdAndClasses } from "./base"; | ||
var zoomString = Html5QrcodeScannerStrings.zoom(); | ||
this.rangeText.innerText = this.rangeInput.value + "x " + zoomString; | ||
this.rangeText.innerText = "".concat(this.rangeInput.value, "x ").concat(zoomString); | ||
this.rangeText.style.marginRight = "10px"; | ||
@@ -39,3 +39,3 @@ var $this = this; | ||
var zoomString = Html5QrcodeScannerStrings.zoom(); | ||
this.rangeText.innerText = this.rangeInput.value + "x " + zoomString; | ||
this.rangeText.innerText = "".concat(this.rangeInput.value, "x ").concat(zoomString); | ||
if (this.onChangeCallback) { | ||
@@ -42,0 +42,0 @@ this.onChangeCallback(parseFloat(this.rangeInput.value)); |
@@ -1,2 +0,2 @@ | ||
export declare type OnFileSelected = (file: File) => void; | ||
export type OnFileSelected = (file: File) => void; | ||
export declare class FileSelectionUi { | ||
@@ -3,0 +3,0 @@ private readonly fileBasedScanRegion; |
@@ -144,3 +144,3 @@ import { Html5QrcodeScannerStrings } from "../../strings"; | ||
var last8Chars = imageFileName.substring(length_1 - 8, length_1); | ||
imageFileName = start8Chars + "...." + last8Chars; | ||
imageFileName = "".concat(start8Chars, "....").concat(last8Chars); | ||
} | ||
@@ -147,0 +147,0 @@ var newText = Html5QrcodeScannerStrings.fileSelectionChooseAnother() |
@@ -33,3 +33,3 @@ import { Html5QrcodeScanType, Html5QrcodeConstants } from "../../core"; | ||
if (supportedScanTypes.length > maxExpectedValues) { | ||
throw "Max " + maxExpectedValues + " values expected for " | ||
throw "Max ".concat(maxExpectedValues, " values expected for ") | ||
+ "supportedScanTypes"; | ||
@@ -41,3 +41,3 @@ } | ||
.includes(scanType)) { | ||
throw "Unsupported scan type " + scanType; | ||
throw "Unsupported scan type ".concat(scanType); | ||
} | ||
@@ -44,0 +44,0 @@ } |
import { BooleanCameraCapability } from "../../camera/core"; | ||
export declare type OnTorchActionFailureCallback = (failureMessage: string) => void; | ||
export type OnTorchActionFailureCallback = (failureMessage: string) => void; | ||
interface TorchButtonController { | ||
@@ -4,0 +4,0 @@ disable(): void; |
@@ -16,3 +16,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -19,0 +19,0 @@ if (y = 0, t) op = [op[0] & 2, t.value]; |
@@ -8,3 +8,3 @@ var VideoConstraintsUtil = (function () { | ||
logger.logError("videoConstraints should be of type object, the " | ||
+ ("object passed is of type " + typeofVideoConstraints + "."), true); | ||
+ "object passed is of type ".concat(typeofVideoConstraints, "."), true); | ||
return false; | ||
@@ -27,3 +27,3 @@ } | ||
if (bannedkeysSet.has(key)) { | ||
logger.logError(key + " is not supported videoConstaints.", true); | ||
logger.logError("".concat(key, " is not supported videoConstaints."), true); | ||
return false; | ||
@@ -30,0 +30,0 @@ } |
@@ -82,3 +82,3 @@ import * as ZXing from "../third_party/zxing-js.umd"; | ||
if (!this.reverseFormatMap.has(zxingFormat)) { | ||
throw "reverseFormatMap doesn't have " + zxingFormat; | ||
throw "reverseFormatMap doesn't have ".concat(zxingFormat); | ||
} | ||
@@ -95,3 +95,3 @@ return this.reverseFormatMap.get(zxingFormat); | ||
else { | ||
this.logger.logError(requestedFormat + " is not supported by" | ||
this.logger.logError("".concat(requestedFormat, " is not supported by") | ||
+ "ZXingHtml5QrcodeShim"); | ||
@@ -98,0 +98,0 @@ } |
import { Html5QrcodeScanType, QrcodeSuccessCallback, QrcodeErrorCallback } from "./core"; | ||
import { Html5QrcodeConfigs, Html5QrcodeCameraScanConfig } from "./html5-qrcode"; | ||
import { Html5QrcodeScannerState } from "./state-manager"; | ||
interface Html5QrcodeScannerConfig extends Html5QrcodeCameraScanConfig, Html5QrcodeConfigs { | ||
export interface Html5QrcodeScannerConfig extends Html5QrcodeCameraScanConfig, Html5QrcodeConfigs { | ||
rememberLastUsedCamera?: boolean | undefined; | ||
@@ -68,2 +68,1 @@ supportedScanTypes?: Array<Html5QrcodeScanType> | []; | ||
} | ||
export {}; |
import { QrcodeErrorCallback, QrcodeSuccessCallback, Html5QrcodeSupportedFormats, Html5QrcodeResult, QrDimensions, QrDimensionFunction } from "./core"; | ||
import { CameraDevice, CameraCapabilities } from "./camera/core"; | ||
import { ExperimentalFeaturesConfig } from "./experimental-features"; | ||
import { StateManagerProxy, Html5QrcodeScannerState } from "./state-manager"; | ||
declare type Html5QrcodeIdentifier = string | MediaTrackConstraints; | ||
import { Html5QrcodeScannerState } from "./state-manager"; | ||
export interface Html5QrcodeConfigs { | ||
@@ -38,6 +37,6 @@ formatsToSupport?: Array<Html5QrcodeSupportedFormats> | undefined; | ||
private lastScanImageFile; | ||
stateManagerProxy: StateManagerProxy; | ||
private stateManagerProxy; | ||
isScanning: boolean; | ||
constructor(elementId: string, configOrVerbosityFlag?: boolean | Html5QrcodeFullConfig | undefined); | ||
start(cameraIdOrConfig: Html5QrcodeIdentifier, configuration: Html5QrcodeCameraScanConfig | undefined, qrCodeSuccessCallback: QrcodeSuccessCallback | undefined, qrCodeErrorCallback: QrcodeErrorCallback | undefined): Promise<null>; | ||
start(cameraIdOrConfig: string | MediaTrackConstraints, configuration: Html5QrcodeCameraScanConfig | undefined, qrCodeSuccessCallback: QrcodeSuccessCallback | undefined, qrCodeErrorCallback: QrcodeErrorCallback | undefined): Promise<null>; | ||
pause(shouldPauseVideo?: boolean): void; | ||
@@ -78,2 +77,1 @@ resume(): void; | ||
} | ||
export {}; |
@@ -1,5 +0,6 @@ | ||
export { Html5Qrcode } from "./html5-qrcode"; | ||
export { Html5Qrcode, Html5QrcodeFullConfig, Html5QrcodeCameraScanConfig } from "./html5-qrcode"; | ||
export { Html5QrcodeScanner } from "./html5-qrcode-scanner"; | ||
export { Html5QrcodeSupportedFormats } from "./core"; | ||
export { Html5QrcodeSupportedFormats, Html5QrcodeResult, QrcodeSuccessCallback, QrcodeErrorCallback } from "./core"; | ||
export { Html5QrcodeScannerState } from "./state-manager"; | ||
export { Html5QrcodeScanType } from "./core"; | ||
export { CameraCapabilities, CameraDevice } from "./camera/core"; |
{ | ||
"name": "html5-qrcode", | ||
"version": "2.3.7", | ||
"version": "2.3.8", | ||
"description": "A cross platform HTML5 QR Code & bar code scanner", | ||
@@ -29,5 +29,8 @@ "main": "./cjs/index.js", | ||
"build:umd_windows": ".\\scripts\\build-webpack.bat", | ||
"build:copy": "cp README.md dist && cp package.json dist && cp LICENSE dist", | ||
"build:copy": "cp README.md dist && cp package.json dist && cp LICENSE dist && cp -R src dist/src", | ||
"build:copy_windows": "copy README.md dist && copy package.json dist && copy LICENSE dist", | ||
"release": "npm run build && cd dist && npm publish" | ||
"internal_release": "npm run build && cp dist/html5-qrcode.min.js minified/html5-qrcode.min.js", | ||
"release": "npm run build && cp dist/html5-qrcode.min.js minified/html5-qrcode.min.js && cd dist && npm publish", | ||
"release_windows": "npm run build && cp dist\\html5-qrcode.min.js minified\\html5-qrcode.min.js && cd dist && npm publish", | ||
"doc_gen": "npx typedoc --excludePrivate src/index.ts" | ||
}, | ||
@@ -63,2 +66,3 @@ "repository": { | ||
"chai": "^4.3.4", | ||
"docusaurus-plugin-typedoc": "^0.18.0", | ||
"expose-loader": "^2.0.0", | ||
@@ -76,2 +80,4 @@ "jsdom": "20.0.2", | ||
"tsconfig-paths": "^3.12.0", | ||
"typedoc": "^0.23.28", | ||
"typedoc-plugin-markdown": "^3.14.0", | ||
"typescript": "^4.3.2", | ||
@@ -78,0 +84,0 @@ "typings": "^2.1.1", |
761
README.md
@@ -7,3 +7,3 @@ # Html5-QRCode | ||
### Key highlights | ||
## Key highlights | ||
- 🔲 Support scanning [different types of bar codes and QR codes](#supported-code-formats). | ||
@@ -34,10 +34,24 @@ | ||
| <img src="https://scanapp.org/assets/github_assets/pixel6pro-optimised.gif" width="180px"> | <img src="https://scanapp.org/assets/github_assets/pixel4_barcode_480.gif" width="180px">| | ||
| <img src="https://scanapp.org/assets/github_assets/pixel6pro-optimised.gif" width="180px" /> | <img src="https://scanapp.org/assets/github_assets/pixel4_barcode_480.gif" width="180px" />| | ||
| -- | -- | | ||
| _Demo at [scanapp.org](https://scanapp.org)_ | _Demo at [qrcode.minhazav.dev](https://qrcode.minhazav.dev) - **Scanning different types of codes**_ | | ||
## Notice | ||
**UX/UXD/UXR help wanted**: We are looking to improve user experience of this code scanning library — if you are interested in making this experience better for both developers and end users, please share your ideas, thoughts, inputs in [this discussion](https://github.com/mebjas/html5-qrcode/discussions/213) | ||
## We need your help! | ||
![image](https://user-images.githubusercontent.com/3007365/222830114-e5bcca15-bf8a-434e-9f48-339e82a0a4ef.png) | ||
Help incentivise feature development, bug fixing by supporting the sponsorhip goals of this project. See [list of sponsered feature requests here](https://github.com/mebjas/html5-qrcode/wiki/Feature-request-sponsorship-goals#feature-requests). | ||
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/L3L84G0C8) | ||
## Documentation | ||
The documentation for this project has been moved to [scanapp.org/html5-qrcode-docs](https://scanapp.org/html5-qrcode-docs/). | ||
- [Getting started](https://scanapp.org/html5-qrcode-docs/docs/intro) | ||
- [Supported frameworks](https://scanapp.org/html5-qrcode-docs/docs/supported_frameworks) | ||
- [Supported 1D and 2D Code formats](https://scanapp.org/html5-qrcode-docs/docs/supported_code_formats) | ||
- [Detailed API documentation](https://scanapp.org/html5-qrcode-docs/docs/apis) | ||
## Supported platforms | ||
We are working continuously on adding support for more and more platforms. If you find a platform or a browser where the library is not working, please feel free to file an issue. Check the [demo link](https://blog.minhazav.dev/research/html5-qrcode.html) to test it out. | ||
@@ -53,3 +67,3 @@ | ||
| --------- | --------- | --------- | --------- | ------- | | ||
|![](https://scanapp.org/assets/github_assets/done.png)| ![](https://scanapp.org/assets/github_assets/done.png)| ![](https://scanapp.org/assets/github_assets/done.png)| ![](assets/done.png) | ![](assets/done.png) | ||
|![](https://scanapp.org/assets/github_assets/done.png)| ![](https://scanapp.org/assets/github_assets/done.png)| ![](https://scanapp.org/assets/github_assets/done.png)| ![](https://scanapp.org/assets/github_assets/done.png) | ![](https://scanapp.org/assets/github_assets/done.png) | ||
@@ -76,5 +90,5 @@ ### Android | ||
|<img src="https://scanapp.org/assets/github_assets/html5.png" width="30px">| <img src="https://scanapp.org/assets/github_assets/vuejs.png" width="30px">|<img src="https://scanapp.org/assets/github_assets/electron.png" width="30px"> | <img src="https://scanapp.org/assets/github_assets/react.svg" width="30px"> | ||
| -------- | -------- | -------- | -------- | | ||
| [Html5](./examples/html5) | [VueJs](./examples/vuejs) | [ElectronJs](./examples/electron) | [React](https://github.com/scanapp-org/html5-qrcode-react) | ||
|<img src="https://scanapp.org/assets/github_assets/html5.png" width="30px" />| <img src="https://scanapp.org/assets/github_assets/vuejs.png" width="30px" />|<img src="https://scanapp.org/assets/github_assets/electron.png" width="30px" /> | <img src="https://scanapp.org/assets/github_assets/react.svg" width="30px" /> | <img src="https://seeklogo.com/images/L/lit-logo-6B43868CDC-seeklogo.com.png" width="30px" /> | ||
| -------- | -------- | -------- | -------- | -------- | | ||
| [Html5](./examples/html5) | [VueJs](./examples/vuejs) | [ElectronJs](./examples/electron) | [React](https://github.com/scanapp-org/html5-qrcode-react) | [Lit](./examples/lit) | ||
@@ -86,17 +100,17 @@ ### Supported Code formats | ||
| ---- | ----- | | ||
| QR Code | <img src="https://scanapp.org/assets/github_assets/qr-code.png" width="200px"> | | ||
| AZTEC | <img src="https://scanapp.org/assets/github_assets/aztec.png" > | | ||
| CODE_39| <img src="https://scanapp.org/assets/github_assets/code_39.gif" > | | ||
| CODE_93| <img src="https://scanapp.org/assets/github_assets/code_93.gif" >| | ||
| CODE_128| <img src="https://scanapp.org/assets/github_assets/code_128.gif" >| | ||
| ITF| <img src="https://scanapp.org/assets/github_assets/itf.png" >| | ||
| EAN_13|<img src="https://scanapp.org/assets/github_assets/ean13.jpeg" > | | ||
| EAN_8| <img src="https://scanapp.org/assets/github_assets/ean8.jpeg" >| | ||
| PDF_417| <img src="https://scanapp.org/assets/github_assets/pdf417.png" >| | ||
| UPC_A| <img src="https://scanapp.org/assets/github_assets/upca.jpeg" >| | ||
| UPC_E| <img src="https://scanapp.org/assets/github_assets/upce.jpeg" >| | ||
| DATA_MATRIX|<img src="https://scanapp.org/assets/github_assets/datamatrix.png" > | | ||
| MAXICODE*| <img src="https://scanapp.org/assets/github_assets/maxicode.gif" > | | ||
| RSS_14*| <img src="https://scanapp.org/assets/github_assets/rss14.gif" >| | ||
| RSS_EXPANDED*|<img src="https://scanapp.org/assets/github_assets/rssexpanded.gif" > | | ||
| QR Code | <img src="https://scanapp.org/assets/github_assets/qr-code.png" width="200px" /> | | ||
| AZTEC | <img src="https://scanapp.org/assets/github_assets/aztec.png" /> | | ||
| CODE_39| <img src="https://scanapp.org/assets/github_assets/code_39.gif" /> | | ||
| CODE_93| <img src="https://scanapp.org/assets/github_assets/code_93.gif" />| | ||
| CODE_128| <img src="https://scanapp.org/assets/github_assets/code_128.gif" />| | ||
| ITF| <img src="https://scanapp.org/assets/github_assets/itf.png" />| | ||
| EAN_13|<img src="https://scanapp.org/assets/github_assets/ean13.jpeg" /> | | ||
| EAN_8| <img src="https://scanapp.org/assets/github_assets/ean8.jpeg" />| | ||
| PDF_417| <img src="https://scanapp.org/assets/github_assets/pdf417.png" />| | ||
| UPC_A| <img src="https://scanapp.org/assets/github_assets/upca.jpeg" />| | ||
| UPC_E| <img src="https://scanapp.org/assets/github_assets/upce.jpeg" />| | ||
| DATA_MATRIX|<img src="https://scanapp.org/assets/github_assets/datamatrix.png" /> | | ||
| MAXICODE*| <img src="https://scanapp.org/assets/github_assets/maxicode.gif" /> | | ||
| RSS_14*| <img src="https://scanapp.org/assets/github_assets/rss14.gif" />| | ||
| RSS_EXPANDED*|<img src="https://scanapp.org/assets/github_assets/rssexpanded.gif" /> | | ||
@@ -120,218 +134,6 @@ > *Formats are not supported by our experimental integration with native | ||
### If you are on medium | ||
[![](https://img.shields.io/badge/Medium-12100E?style=for-the-badge&logo=medium&logoColor=white) - Thorough documentation on Html5-qrcode library on Medium](https://bit.ly/3CZiASv). | ||
Find detailed guidelines on how to use this library on [scanapp.org/html5-qrcode-docs](https://scanapp.org/html5-qrcode-docs/docs/intro). | ||
### Documentation | ||
Download the script from [release page](https://github.com/mebjas/html5-qrcode/releases) or install using `npm` with: | ||
```sh | ||
npm i html5-qrcode | ||
``` | ||
Add an element you want to use as a placeholder for QR Code scanner | ||
```html | ||
<div id="reader" width="600px"></div> | ||
``` | ||
> Ideally do not set the height of this container as the height should depend on the height of the video feed from the camera. The library would honor the existing width, otherwise apply the default width. The height is derived from the aspect ratio of the video feed. | ||
### Using directly in browser without any loader | ||
If you are not using any loader, you can get the latest UMD javascript code in production from [https://unpkg.com/html5-qrcode](https://unpkg.com/html5-qrcode). | ||
```html | ||
<script src="https://unpkg.com/html5-qrcode" type="text/javascript"> | ||
``` | ||
> In case you installed the plugin using `npm` but still use javascript without any module loader, you can get the minified script in `node_modules/html5-qrcode/html5-qrcode.min.js` | ||
### Using with module loaders | ||
Include the script with | ||
```js | ||
// To use Html5QrcodeScanner (more info below) | ||
import {Html5QrcodeScanner} from "html5-qrcode" | ||
// To use Html5Qrcode (more info below) | ||
import {Html5Qrcode} from "html5-qrcode" | ||
``` | ||
### Easy Mode - With end to end scanner user interface | ||
`Html5QrcodeScanner` lets you implement an end to end scanner with few lines of code with the default user interface which allows scanning using the camera or selecting an image from the file system. | ||
You can set up the scanner as follows: | ||
```js | ||
function onScanSuccess(decodedText, decodedResult) { | ||
// handle the scanned code as you like, for example: | ||
console.log(`Code matched = ${decodedText}`, decodedResult); | ||
} | ||
function onScanFailure(error) { | ||
// handle scan failure, usually better to ignore and keep scanning. | ||
// for example: | ||
console.warn(`Code scan error = ${error}`); | ||
} | ||
let html5QrcodeScanner = new Html5QrcodeScanner( | ||
"reader", | ||
{ fps: 10, qrbox: {width: 250, height: 250} }, | ||
/* verbose= */ false); | ||
html5QrcodeScanner.render(onScanSuccess, onScanFailure); | ||
``` | ||
### Pro Mode - if you want to implement your own user interface | ||
You can use `Html5Qrcode` class to set up your QR code scanner (with your own user interface) and allow users to scan QR codes using the camera or by choosing an image file in the file system or native cameras in smartphones. | ||
You can use the following APIs to `fetch camera`, `start` scanning and `stop` scanning. | ||
#### For using inline QR Code scanning with Webcam or Smartphone camera | ||
##### Start Scanning | ||
To get a list of supported cameras, query it using static method `Html5Qrcode.getCameras()`. This method returns a `Promise` with a list of devices supported in format `{ id: "id", label: "label" }`. | ||
```js | ||
// This method will trigger user permissions | ||
Html5Qrcode.getCameras().then(devices => { | ||
/** | ||
* devices would be an array of objects of type: | ||
* { id: "id", label: "label" } | ||
*/ | ||
if (devices && devices.length) { | ||
var cameraId = devices[0].id; | ||
// .. use this to start scanning. | ||
} | ||
}).catch(err => { | ||
// handle err | ||
}); | ||
``` | ||
**Important**: Note that this method will trigger user permission if the user has not granted it already. | ||
> Warning: Direct access to the camera is a powerful feature. It requires consent from the user, and your site MUST be on a secure origin (HTTPS). | ||
> | ||
> Warning: Asking for access to the camera on page load will result in most of your users rejecting access to it. [More info](https://developers.google.com/web/fundamentals/media/capturing-images) | ||
Once you have the camera ID from `device.id`, start camera using `Html5Qrcode#start(..)`. This method returns a `Promise` with Qr code scanning initiation. | ||
```js | ||
const html5QrCode = new Html5Qrcode(/* element id */ "reader"); | ||
html5QrCode.start( | ||
cameraId, | ||
{ | ||
fps: 10, // Optional, frame per seconds for qr code scanning | ||
qrbox: { width: 250, height: 250 } // Optional, if you want bounded box UI | ||
}, | ||
(decodedText, decodedResult) => { | ||
// do something when code is read | ||
}, | ||
(errorMessage) => { | ||
// parse error, ignore it. | ||
}) | ||
.catch((err) => { | ||
// Start failed, handle it. | ||
}); | ||
``` | ||
> You can optionally set another argument in constructor called `verbose` to print all logs to console | ||
```js | ||
const html5QrCode = new Html5Qrcode("reader", /* verbose= */ true); | ||
``` | ||
##### Scanning without cameraId | ||
In mobile devices you may want users to directly scan the QR code using the back camera or the front camera for some use cases. For such cases you can avoid using the exact camera device ID that you get from `Html5Qrcode.getCameras()`. The `start()` method allows passing constraints in place of camera device ID similar to [html5 web API syntax](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#Syntax). You can start scanning like mentioned in these examples: | ||
```js | ||
const html5QrCode = new Html5Qrcode("reader"); | ||
const qrCodeSuccessCallback = (decodedText, decodedResult) => { | ||
/* handle success */ | ||
}; | ||
const config = { fps: 10, qrbox: { width: 250, height: 250 } }; | ||
// If you want to prefer front camera | ||
html5QrCode.start({ facingMode: "user" }, config, qrCodeSuccessCallback); | ||
// If you want to prefer back camera | ||
html5QrCode.start({ facingMode: "environment" }, config, qrCodeSuccessCallback); | ||
// Select front camera or fail with `OverconstrainedError`. | ||
html5QrCode.start({ facingMode: { exact: "user"} }, config, qrCodeSuccessCallback); | ||
// Select back camera or fail with `OverconstrainedError`. | ||
html5QrCode.start({ facingMode: { exact: "environment"} }, config, qrCodeSuccessCallback); | ||
``` | ||
Passing the `cameraId` (recommended approach) is similar to | ||
```js | ||
html5QrCode.start({ deviceId: { exact: cameraId} }, config, qrCodeSuccessCallback); | ||
``` | ||
##### Stop Scanning | ||
To stop using camera and thus stop scanning, call `Html5Qrcode#stop()` which returns a `Promise` for stopping the video feed and scanning. | ||
```js | ||
html5QrCode.stop().then((ignore) => { | ||
// QR Code scanning is stopped. | ||
}).catch((err) => { | ||
// Stop failed, handle it. | ||
}); | ||
``` | ||
> Note that the class is stateful and `stop()` should be called to properly tear down the video and camera objects safely after calling `start()` when the scan is over or the user intend to move on. `stop()` will stop the video feed on the viewfinder. | ||
#### For QR Code scanning using local files or inbuilt camera on Smartphones | ||
| Selector in Android | Selector in IOS| | ||
|------|-------| | ||
| Taken on Pixel 3, Google Chrome<br><img src="https://scanapp.org/assets/github_assets/selector_android.png" width="300px"> | Taken on iPhone 7, Google Chrome<br><img src="https://scanapp.org/assets/github_assets/selector_iphone.jpg" width="300px"> | | ||
You can alternatively leverage QR Code scanning for local files on the device or default camera on the device. It works similar to inline QR Code scanning. | ||
Define the HTML container and import the JavaScript library as mentioned above | ||
```html | ||
<div id="reader" width="600px" height="600px"></div> | ||
<script src="./dist/html5-qrcode.js"></script> | ||
``` | ||
> It's not mandatory to set the height and width of the HTML element. If provided, the library would try to honor it. If it's not set, the library would set a default width and derive the height based on the input image's aspect ratio. | ||
Add an `Input` element for supporting file selection like this: | ||
```html | ||
<input type="file" id="qr-input-file" accept="image/*"> | ||
<!-- | ||
Or add captured if you only want to enable smartphone camera, PC browsers will ignore it. | ||
--> | ||
<input type="file" id="qr-input-file" accept="image/*" capture> | ||
``` | ||
Find more information about this at [developers.google.com](https://developers.google.com/web/fundamentals/media/capturing-images). | ||
And in JavaScript code initialize the object and attach listener like this: | ||
```js | ||
const html5QrCode = new Html5Qrcode(/* element id */ "reader"); | ||
// File based scanning | ||
const fileinput = document.getElementById('qr-input-file'); | ||
fileinput.addEventListener('change', e => { | ||
if (e.target.files.length == 0) { | ||
// No file selected, ignore | ||
return; | ||
} | ||
const imageFile = e.target.files[0]; | ||
// Scan QR Code | ||
html5QrCode.scanFile(imageFile, true) | ||
.then(decodedText => { | ||
// success, use decodedText | ||
console.log(decodedText); | ||
}) | ||
.catch(err => { | ||
// failure, handle it. | ||
console.log(`Error scanning file. Reason: ${err}`) | ||
}); | ||
}); | ||
// Note: Current public API `scanFile` only returns the decoded text. There is | ||
// another work in progress API (in beta) which returns a full decoded result of | ||
// type `QrcodeResult` (check interface in src/core.ts) which contains the | ||
// decoded text, code format, code bounds, etc. | ||
// Eventually, this beta API will be migrated to the public API. | ||
``` | ||
> Note that inline scanning and file-based scanning are mutually exclusive at the moment. This means you can only use one of them at a time. I'll soon be adding support for the option to have both if the requirement comes in. If you want to use both, use `html5QrCode#clear()` method to clear the canvas. | ||
## Demo | ||
<img src="https://scanapp.org/assets/github_assets/qr-code.png" width="200px"><br> | ||
<img src="https://scanapp.org/assets/github_assets/qr-code.png" width="200px"><br /> | ||
_Scan this image or visit [blog.minhazav.dev/research/html5-qrcode.html](https://blog.minhazav.dev/research/html5-qrcode.html)_ | ||
@@ -347,477 +149,8 @@ | ||
## Screenshots | ||
![screenshot](https://scanapp.org/assets/github_assets/screen.gif)<br> | ||
![screenshot](https://scanapp.org/assets/github_assets/screen.gif)<br /> | ||
_Figure: Screenshot from Google Chrome running on MacBook Pro_ | ||
## Documentation | ||
Following methods are available in this library (typescript definition) | ||
Find the full API documentation at [scanapp.org/html5-qrcode-docs/docs/apis](https://scanapp.org/html5-qrcode-docs/docs/apis). | ||
```ts | ||
/** Camera Device interface. */ | ||
interface CameraDevice { | ||
id: string; | ||
label: string; | ||
} | ||
/** Different states of scanner */ | ||
enum Html5QrcodeScannerState { | ||
// Indicates the sanning is not running or user is using file based | ||
// scanning. | ||
NOT_STARTED = 0, | ||
// Camera scan is running. | ||
SCANNING, | ||
// Camera scan is paused but camera is running. | ||
PAUSED, | ||
} | ||
/** | ||
* Code formats supported by this library. | ||
*/ | ||
enum Html5QrcodeSupportedFormats { | ||
QR_CODE = 0, | ||
AZTEC, | ||
CODABAR, | ||
CODE_39, | ||
CODE_93, | ||
CODE_128, | ||
DATA_MATRIX, | ||
MAXICODE, | ||
ITF, | ||
EAN_13, | ||
EAN_8, | ||
PDF_417, | ||
RSS_14, | ||
RSS_EXPANDED, | ||
UPC_A, | ||
UPC_E, | ||
UPC_EAN_EXTENSION, | ||
} | ||
/** Defines dimension for QR Code Scanner. */ | ||
interface QrDimensions { | ||
width: number; | ||
height: number; | ||
} | ||
/** | ||
* A function that takes in the width and height of the video stream | ||
* and returns QrDimensions. | ||
* | ||
* Viewfinder refers to the video showing camera stream. | ||
*/ | ||
type QrDimensionFunction = | ||
(viewfinderWidth: number, viewfinderHeight: number) => QrDimensions; | ||
/** Format of detected code. */ | ||
class QrcodeResultFormat { | ||
public readonly format: Html5QrcodeSupportedFormats; | ||
public readonly formatName: string; | ||
} | ||
/** Detailed scan result. */ | ||
interface QrcodeResult { | ||
/** Decoded text. */ | ||
text: string; | ||
/** Format that was successfully scanned. */ | ||
format?: QrcodeResultFormat, | ||
} | ||
/** QrCode result object. */ | ||
interface Html5QrcodeResult { | ||
decodedText: string; | ||
result: QrcodeResult; | ||
} | ||
/** Type for a callback for a successful code scan. */ | ||
type QrcodeSuccessCallback | ||
= (decodedText: string, result: Html5QrcodeResult) => void; | ||
/** Type for a callback for failure during code scan. */ | ||
type QrcodeErrorCallback | ||
= (errorMessage: string, error: Html5QrcodeError) => void; | ||
/** | ||
* Interface for configuring {@class Html5Qrcode} class instance. | ||
*/ | ||
interface Html5QrcodeConfigs { | ||
/** | ||
* Array of formats to support of type {@type Html5QrcodeSupportedFormats}. | ||
*/ | ||
formatsToSupport: Array<Html5QrcodeSupportedFormats> | undefined; | ||
/** | ||
* {@class BarcodeDetector} is being implemented by browsers at the moment. | ||
* It has very limited browser support but as it gets available it could | ||
* enable faster native code scanning experience. | ||
* | ||
* Set this flag to true, to enable using {@class BarcodeDetector} if | ||
* supported. This is true by default. | ||
* | ||
* Documentations: | ||
* - https://developer.mozilla.org/en-US/docs/Web/API/BarcodeDetector | ||
* - https://web.dev/shape-detection/#barcodedetector | ||
*/ | ||
useBarCodeDetectorIfSupported?: boolean | undefined; | ||
} | ||
/** Configuration for creating {@class Html5Qrcode}. */ | ||
interface Html5QrcodeFullConfig extends Html5QrcodeConfigs { | ||
/** | ||
* If true, all logs would be printed to console. False by default. | ||
*/ | ||
verbose: boolean | undefined; | ||
} | ||
interface Html5QrcodeCameraScanConfig { | ||
/** | ||
* Optional, Expected framerate of QR code scanning. example { fps: 2 } means the | ||
* scanning would be done every 500 ms. | ||
*/ | ||
fps: number | undefined; | ||
/** | ||
* Optional, edge size, dimension or calculator function for QR scanning | ||
* box, the value or computed value should be smaller than the width and | ||
* height of the full region. | ||
* | ||
* This would make the scanner look like this: | ||
* ---------------------- | ||
* |********************| | ||
* |******,,,,,,,,,*****| <--- shaded region | ||
* |******| |*****| <--- non shaded region would be | ||
* |******| |*****| used for QR code scanning. | ||
* |******|_______|*****| | ||
* |********************| | ||
* |********************| | ||
* ---------------------- | ||
* | ||
* Instance of {@interface QrDimensions} can be passed to construct a non | ||
* square rendering of scanner box. You can also pass in a function of type | ||
* {@type QrDimensionFunction} that takes in the width and height of the | ||
* video stream and return QR box size of type {@interface QrDimensions}. | ||
* | ||
* If this value is not set, no shaded QR box will be rendered and the scanner | ||
* will scan the entire area of video stream. | ||
*/ | ||
qrbox?: number | QrDimensions | QrDimensionFunction | undefined; | ||
/** | ||
* Optional, Desired aspect ratio for the video feed. Ideal aspect ratios | ||
* are 4:3 or 16:9. Passing very wrong aspect ratio could lead to video feed | ||
* not showing up. | ||
*/ | ||
aspectRatio?: number | undefined; | ||
/** | ||
* Optional, if {@code true} flipped QR Code won't be scanned. Only use this | ||
* if you are sure the camera cannot give mirrored feed if you are facing | ||
* performance constraints. | ||
*/ | ||
disableFlip?: boolean | undefined; | ||
/* | ||
* Optional, @beta(this config is not well supported yet). | ||
* | ||
* Important: When passed this will override other parameters like | ||
* 'cameraIdOrConfig' or configurations like 'aspectRatio'. | ||
* 'videoConstraints' should be of type {@code MediaTrackConstraints} as | ||
* defined in | ||
* https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints | ||
* and is used to specify a variety of video or camera controls like: | ||
* aspectRatio, facingMode, frameRate, etc. | ||
*/ | ||
videoConstraints?: MediaTrackConstraints | undefined; | ||
} | ||
/** | ||
* Interface for controlling different aspects of {@class Html5QrcodeScanner}. | ||
*/ | ||
interface Html5QrcodeScannerConfig | ||
extends Html5QrcodeCameraScanConfig, Html5QrcodeConfigs { | ||
/** | ||
* If {@code true} the library will remember if the camera permissions | ||
* were previously granted and what camera was last used. If the permissions | ||
* is already granted for "camera", QR code scanning will automatically | ||
* start for previously used camera. | ||
* | ||
* Note: default value is {@code true}. | ||
*/ | ||
rememberLastUsedCamera?: boolean | undefined; | ||
/** | ||
* Sets the desired scan types to be supported in the scanner. | ||
* | ||
* - Not setting a value will follow the default order supported by | ||
* library. | ||
* - First value would be used as the default value. Example: | ||
* - [SCAN_TYPE_CAMERA, SCAN_TYPE_FILE]: Camera will be default type, | ||
* user can switch to file based scan. | ||
* - [SCAN_TYPE_FILE, SCAN_TYPE_CAMERA]: File based scan will be default | ||
* type, user can switch to camera based scan. | ||
* - Setting only value will disable option to switch to other. Example: | ||
* - [SCAN_TYPE_CAMERA] - Only camera based scan supported. | ||
* - [SCAN_TYPE_FILE] - Only file based scan supported. | ||
* - Setting wrong values or multiple values will fail. | ||
*/ | ||
supportedScanTypes?: Array<Html5QrcodeScanType> | []; | ||
/** | ||
* If {@code true} the rendered UI will have button to turn flash on or off | ||
* based on device + browser support. | ||
* | ||
* Note: default value is {@code false}. | ||
*/ | ||
showTorchButtonIfSupported?: boolean | undefined; | ||
}; | ||
class Html5Qrcode { | ||
/** | ||
* Returns a Promise with a list of all cameras supported by the device. | ||
*/ | ||
static getCameras(): Promise<Array<CameraDevice>>; | ||
/** | ||
* Initialize QR Code scanner. | ||
* | ||
* @param elementId - Id of the HTML element. | ||
* @param verbose - optional configuration object | ||
*/ | ||
constructor(elementId: string, config: Html5QrcodeFullConfig | undefined); | ||
/** | ||
* Start scanning QR codes or barcodes for a given camera. | ||
* | ||
* @param cameraIdOrConfig Identifier of the camera, it can either be the | ||
* camera id retrieved from {@code Html5Qrcode#getCameras()} method or | ||
* object with facing mode constraint. | ||
* @param configuration Extra configurations to tune the code scanner. | ||
* @param qrCodeSuccessCallback Callback called when an instance of a QR | ||
* code or any other supported bar code is found. | ||
* @param qrCodeErrorCallback Callback called in cases where no instance of | ||
* QR code or any other supported bar code is found. | ||
*/ | ||
start( | ||
cameraIdOrConfig: Html5QrcodeIdentifier, | ||
configuration: Html5QrcodeCameraScanConfig | undefined, | ||
qrCodeSuccessCallback: QrcodeSuccessCallback | undefined, | ||
qrCodeErrorCallback: QrcodeErrorCallback | undefined, | ||
): Promise<null>; | ||
/** | ||
* Pauses the ongoing scan. | ||
* | ||
* @param shouldPauseVideo (Optional, default = false) If {@code true} the | ||
* video will be paused. | ||
* | ||
* @throws error if method is called when scanner is not in scanning state. | ||
*/ | ||
pause(shouldPauseVideo?: boolean); | ||
/** | ||
* Resumes the paused scan. | ||
* | ||
* If the video was previously paused by setting {@code shouldPauseVideo} | ||
* to {@code true} in {@link Html5Qrcode#pause(shouldPauseVideo)}, calling | ||
* this method will resume the video. | ||
* | ||
* Note: with this caller will start getting results in success and error | ||
* callbacks. | ||
* | ||
* @throws error if method is called when scanner is not in paused state. | ||
*/ | ||
resume(); | ||
/** | ||
* Stops streaming QR Code video and scanning. | ||
*/ | ||
stop(): Promise<void>; | ||
/** | ||
* Gets state of the camera scan. | ||
* | ||
* @returns state of type {@enum ScannerState}. | ||
*/ | ||
getState(): Html5QrcodeScannerState; | ||
/** | ||
* Scans an Image File for QR Code. | ||
* | ||
* This feature is mutually exclusive to camera-based scanning, you should | ||
* call stop() if the camera-based scanning was ongoing. | ||
* | ||
* @param imageFile a local file with Image content. | ||
* @param showImage if true, the Image will be rendered on given element. | ||
* | ||
* @returns Promise with decoded QR code string on success. | ||
*/ | ||
scanFile( | ||
imageFile: File, | ||
/* default=true */ showImage: boolean | undefined): Promise<string>; | ||
/** | ||
* Clears the existing canvas. | ||
* | ||
* Note: in case of ongoing web-cam based scan, it needs to be explicitly | ||
* closed before calling this method, else it will throw an exception. | ||
*/ | ||
clear(): void; | ||
/** | ||
* Returns the capabilities of the running video track. | ||
* | ||
* Read more: https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/getConstraints | ||
* | ||
* Important: | ||
* 1. Must be called only if the camera based scanning is in progress. | ||
* | ||
* @returns the capabilities of a running video track. | ||
* @throws error if the scanning is not in running state. | ||
*/ | ||
getRunningTrackCapabilities(): MediaTrackCapabilities; | ||
/** | ||
* Returns the object containing the current values of each constrainable | ||
* property of the running video track. | ||
* | ||
* Read more: https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/getSettings | ||
* | ||
* Important: | ||
* 1. Must be called only if the camera based scanning is in progress. | ||
* | ||
* @returns the supported settings of the running video track. | ||
* @throws error if the scanning is not in running state. | ||
*/ | ||
getRunningTrackSettings(): MediaTrackSettings; | ||
/** | ||
* Apply a video constraints on running video track from camera. | ||
* | ||
* Note: Should only be called if {@code Html5QrcodeScanner#getState()} | ||
* returns {@code Html5QrcodeScannerState#SCANNING} or | ||
* {@code Html5QrcodeScannerState#PAUSED}. | ||
* | ||
* @param {MediaTrackConstraints} specifies a variety of video or camera | ||
* controls as defined in | ||
* https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints | ||
* @returns a Promise which succeeds if the passed constraints are applied, | ||
* fails otherwise. | ||
* @throws error if the scanning is not in running state. | ||
*/ | ||
applyVideoConstraints(videoConstaints: MediaTrackConstraints): Promise<void>; | ||
} | ||
class Html5QrcodeScanner { | ||
/** | ||
* Creates an instance of this class. | ||
* | ||
* @param elementId Id of the HTML element. | ||
* @param config Extra configurations to tune the code scanner. | ||
* @param verbose - If true, all logs would be printed to console. | ||
*/ | ||
constructor( | ||
elementId: string, | ||
config: Html5QrcodeScannerConfig | undefined, | ||
verbose: boolean | undefined); | ||
/** | ||
* Renders the User Interface. | ||
* | ||
* @param qrCodeSuccessCallback Callback called when an instance of a QR | ||
* code or any other supported bar code is found. | ||
* @param qrCodeErrorCallback optional callback called in cases where no | ||
* instance of QR code or any other supported bar code is found. | ||
*/ | ||
render( | ||
qrCodeSuccessCallback: QrcodeSuccessCallback, | ||
qrCodeErrorCallback: QrcodeErrorCallback | undefined); | ||
/** | ||
* Pauses the ongoing scan. | ||
* | ||
* Notes: | ||
* - Should only be called if camera scan is ongoing. | ||
* | ||
* @param shouldPauseVideo (Optional, default = false) If {@code true} | ||
* the video will be paused. | ||
* | ||
* @throws error if method is called when scanner is not in scanning state. | ||
*/ | ||
pause(shouldPauseVideo?: boolean); | ||
/** | ||
* Resumes the paused scan. | ||
* | ||
* If the video was previously paused by setting {@code shouldPauseVideo} | ||
* to {@code true} in {@link Html5QrcodeScanner#pause(shouldPauseVideo)}, | ||
* calling this method will resume the video. | ||
* | ||
* Notes: | ||
* - Should only be called if camera scan is ongoing. | ||
* - With this caller will start getting results in success and error | ||
* callbacks. | ||
* | ||
* @throws error if method is called when scanner is not in paused state. | ||
*/ | ||
resume(); | ||
/** | ||
* Gets state of the camera scan. | ||
* | ||
* @returns state of type {@enum Html5QrcodeScannerState}. | ||
*/ | ||
getState(): Html5QrcodeScannerState; | ||
/** Removes the QR Code scanner UI. */ | ||
clear(): Promise<void>; | ||
/** | ||
* Returns the capabilities of the running video track. | ||
* | ||
* Read more: https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/getConstraints | ||
* | ||
* Note: Should only be called if {@code Html5QrcodeScanner#getState()} | ||
* returns {@code Html5QrcodeScannerState#SCANNING} or | ||
* {@code Html5QrcodeScannerState#PAUSED}. | ||
* | ||
* @returns the capabilities of a running video track. | ||
* @throws error if the scanning is not in running state. | ||
*/ | ||
getRunningTrackCapabilities(): MediaTrackCapabilities; | ||
/** | ||
* Returns the object containing the current values of each constrainable | ||
* property of the running video track. | ||
* | ||
* Read more: https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/getSettings | ||
* | ||
* Note: Should only be called if {@code Html5QrcodeScanner#getState()} | ||
* returns {@code Html5QrcodeScannerState#SCANNING} or | ||
* {@code Html5QrcodeScannerState#PAUSED}. | ||
* | ||
* @returns the supported settings of the running video track. | ||
* @throws error if the scanning is not in running state. | ||
*/ | ||
getRunningTrackSettings(): MediaTrackSettings; | ||
/** | ||
* Apply a video constraints on running video track from camera. | ||
* | ||
* Note: Should only be called if {@code Html5QrcodeScanner#getState()} | ||
* returns {@code Html5QrcodeScannerState#SCANNING} or | ||
* {@code Html5QrcodeScannerState#PAUSED}. | ||
* | ||
* @param {MediaTrackConstraints} specifies a variety of video or camera | ||
* controls as defined in | ||
* https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints | ||
* @returns a Promise which succeeds if the passed constraints are applied, | ||
* fails otherwise. | ||
* @throws error if the scanning is not in running state. | ||
*/ | ||
applyVideoConstraints(videoConstaints: MediaTrackConstraints) : Promise<void>; | ||
} | ||
``` | ||
### Extra optional `configuration` in `start()` method | ||
@@ -832,3 +165,3 @@ Configuration object that can be used to configure both the scanning behavior and the user interface (UI). Most of the fields have default properties that will be used unless a different value is provided. If you do not want to override anything, you can just pass in an empty object `{}`. | ||
<img src="https://scanapp.org/assets/github_assets/screen.gif"> | ||
<img src="https://scanapp.org/assets/github_assets/screen.gif" /> | ||
@@ -878,3 +211,3 @@ This can be used to set a rectangular scanning area with config like: | ||
| ----- | ---- | | ||
| <img src="https://scanapp.org/assets/github_assets/qr-code.png" width="200px"> | <img src="https://scanapp.org/assets/github_assets/qr-code-flipped.png" width="200px"><br> | | ||
| <img src="https://scanapp.org/assets/github_assets/qr-code.png" width="200px" /> | <img src="https://scanapp.org/assets/github_assets/qr-code-flipped.png" width="200px" /><br /> | | ||
@@ -1055,3 +388,3 @@ #### `rememberLastUsedCamera` — Boolean (Optional), default = true | ||
<!-- sponsors --> | ||
<a href="https://github.com/webauthor"><img src="https://github.com/webauthor.png" width="40px" alt="webauthor@"></a> | ||
<a href="https://github.com/webauthor"><img src="https://github.com/webauthor.png" width="40px" alt="webauthor@" /></a> | ||
<a href="https://github.com/ben-gy"><img src="https://github.com/ben-gy.png" width="40px" alt="ben-gy" /></a> | ||
@@ -1061,4 +394,6 @@ <a href="https://github.com/bujjivadu"><img src="https://github.com/bujjivadu.png" width="40px" alt="bujjivadu" /></a> | ||
And huge thanks to following organizations for non monitery sponsorships | ||
Help incentivise feature development, bug fixing by supporting the sponsorhip goals of this project. See [list of sponsered feature requests here](https://github.com/mebjas/html5-qrcode/wiki/Feature-request-sponsorship-goals#feature-requests). | ||
Also, huge thanks to following organizations for non monitery sponsorships | ||
<!-- sponsors --> | ||
@@ -1074,2 +409,2 @@ <div> | ||
## Credits | ||
The decoder used for the QR code reading is from `Zxing-js` https://github.com/zxing-js/library<br> | ||
The decoder used for the QR code reading is from `Zxing-js` https://github.com/zxing-js/library<br /> |
@@ -8,2 +8,3 @@ export declare class Html5QrcodeStrings { | ||
static insecureContextCameraQueryError(): string; | ||
static scannerPaused(): string; | ||
} | ||
@@ -10,0 +11,0 @@ export declare class Html5QrcodeScannerStrings { |
@@ -1,2 +0,2 @@ | ||
export declare type OnCameraZoomValueChangeCallback = (zoomValue: number) => void; | ||
export type OnCameraZoomValueChangeCallback = (zoomValue: number) => void; | ||
export declare class CameraZoomUi { | ||
@@ -3,0 +3,0 @@ private zoomElementContainer; |
@@ -1,2 +0,2 @@ | ||
export declare type OnFileSelected = (file: File) => void; | ||
export type OnFileSelected = (file: File) => void; | ||
export declare class FileSelectionUi { | ||
@@ -3,0 +3,0 @@ private readonly fileBasedScanRegion; |
import { BooleanCameraCapability } from "../../camera/core"; | ||
export declare type OnTorchActionFailureCallback = (failureMessage: string) => void; | ||
export type OnTorchActionFailureCallback = (failureMessage: string) => void; | ||
interface TorchButtonController { | ||
@@ -4,0 +4,0 @@ disable(): void; |
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
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
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
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
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
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 too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2627746
306
42391
27
399