Skip to content

Commit 2d1c73e

Browse files
committed
Restore code formatting
Restore code formatting
1 parent b9ee6ef commit 2d1c73e

File tree

1 file changed

+64
-64
lines changed

1 file changed

+64
-64
lines changed

src/html5-qrcode.ts

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ export class Html5Qrcode {
281281
private borderShaders: Array<HTMLElement> | null = null;
282282
private qrMatch: boolean | null = null;
283283
private renderedCamera: RenderedCamera | null = null;
284-
284+
285285
private foreverScanTimeout: any;
286286
private qrRegion: QrcodeRegionBounds | null = null;
287287
private context: CanvasRenderingContext2D | null = null;
@@ -309,15 +309,15 @@ export class Html5Qrcode {
309309
*
310310
* TODO(mebjas): Deprecate the verbosity boolean flag completely.
311311
*/
312-
public constructor(elementId: string,
312+
public constructor(elementId: string,
313313
configOrVerbosityFlag?: boolean | Html5QrcodeFullConfig | undefined) {
314314
if (!document.getElementById(elementId)) {
315315
throw `HTML Element with id=${elementId} not found`;
316316
}
317317

318318
this.elementId = elementId;
319319
this.verbose = false;
320-
320+
321321
let experimentalFeatureConfig : ExperimentalFeaturesConfig | undefined;
322322
let configObject: Html5QrcodeFullConfig | undefined;
323323
if (typeof configOrVerbosityFlag == "boolean") {
@@ -392,7 +392,7 @@ export class Html5Qrcode {
392392
if (!internalConfig.isMediaStreamConstraintsValid()) {
393393
this.logger.logError(
394394
"'videoConstraints' is not valid 'MediaStreamConstraints, "
395-
+ "it will be ignored.'",
395+
+ "it will be ignored.'",
396396
/* experimental= */ true);
397397
} else {
398398
videoConstraintsAvailableAndValid = true;
@@ -415,8 +415,8 @@ export class Html5Qrcode {
415415
Html5QrcodeScannerState.SCANNING);
416416
return new Promise((resolve, reject) => {
417417
const videoConstraints = areVideoConstraintsEnabled
418-
? internalConfig.videoConstraints
419-
: $this.createVideoConstraints(cameraIdOrConfig);
418+
? internalConfig.videoConstraints
419+
: $this.createVideoConstraints(cameraIdOrConfig);
420420
if (!videoConstraints) {
421421
toScanningStateChangeTransaction.cancel();
422422
reject("videoConstraints should be defined");
@@ -568,7 +568,7 @@ export class Html5Qrcode {
568568
if (childElement) {
569569
this.element.removeChild(childElement);
570570
}
571-
};
571+
};
572572

573573
let $this = this;
574574
return this.renderedCamera!.close().then(() => {
@@ -639,7 +639,7 @@ export class Html5Qrcode {
639639
: Promise<Html5QrcodeResult> {
640640
if (!imageFile || !(imageFile instanceof File)) {
641641
throw "imageFile argument is mandatory and should be instance "
642-
+ "of File. Use 'event.target.files[0]'.";
642+
+ "of File. Use 'event.target.files[0]'.";
643643
}
644644

645645
if (isNullOrUndefined(showImage)) {
@@ -843,7 +843,7 @@ export class Html5Qrcode {
843843
private getRenderedCameraOrFail() {
844844
if (this.renderedCamera == null) {
845845
throw "Scanning is not in running state, call this API only when"
846-
+ " QR code scanning using camera is in running state.";
846+
+ " QR code scanning using camera is in running state.";
847847
}
848848
return this.renderedCamera!;
849849
}
@@ -884,7 +884,7 @@ export class Html5Qrcode {
884884
Html5QrcodeSupportedFormats.UPC_EAN_EXTENSION,
885885
];
886886

887-
if (!configOrVerbosityFlag
887+
if (!configOrVerbosityFlag
888888
|| typeof configOrVerbosityFlag == "boolean") {
889889
return allFormats;
890890
}
@@ -895,7 +895,7 @@ export class Html5Qrcode {
895895

896896
if (!Array.isArray(configOrVerbosityFlag.formatsToSupport)) {
897897
throw "configOrVerbosityFlag.formatsToSupport should be undefined "
898-
+ "or an array.";
898+
+ "or an array.";
899899
}
900900

901901
if (configOrVerbosityFlag.formatsToSupport.length === 0) {
@@ -964,7 +964,7 @@ export class Html5Qrcode {
964964
const validateMinSize = (size: number) => {
965965
if (size < Constants.MIN_QR_BOX_SIZE) {
966966
throw "minimum size of 'config.qrbox' dimension value is"
967-
+ ` ${Constants.MIN_QR_BOX_SIZE}px.`;
967+
+ ` ${Constants.MIN_QR_BOX_SIZE}px.`;
968968
}
969969
};
970970

@@ -1015,7 +1015,7 @@ export class Html5Qrcode {
10151015
// Alternatively, the config is expected to be of type QrDimensions.
10161016
if (qrboxSize.width === undefined || qrboxSize.height === undefined) {
10171017
throw "Invalid instance of QrDimensions passed for "
1018-
+ "'config.qrbox'. Both 'width' and 'height' should be set.";
1018+
+ "'config.qrbox'. Both 'width' and 'height' should be set.";
10191019
}
10201020
}
10211021

@@ -1060,7 +1060,7 @@ export class Html5Qrcode {
10601060

10611061
// If `qrbox` size is not set, it will default to the dimensions of the
10621062
// viewfinder.
1063-
const qrboxSize = isNullOrUndefined(internalConfig.qrbox) ?
1063+
const qrboxSize = isNullOrUndefined(internalConfig.qrbox) ?
10641064
{width: viewfinderWidth, height: viewfinderHeight}: internalConfig.qrbox!;
10651065

10661066
this.validateQrboxConfig(qrboxSize);
@@ -1070,10 +1070,10 @@ export class Html5Qrcode {
10701070
+ "greater than the height of the video stream. Shading will be"
10711071
+ " ignored");
10721072
}
1073-
1073+
10741074
const shouldShadingBeApplied
10751075
= internalConfig.isShadedBoxEnabled()
1076-
&& qrDimensions.height <= viewfinderHeight;
1076+
&& qrDimensions.height <= viewfinderHeight;
10771077
const defaultQrRegion: QrcodeRegionBounds = {
10781078
x: 0,
10791079
y: 0,
@@ -1084,7 +1084,7 @@ export class Html5Qrcode {
10841084
const qrRegion = shouldShadingBeApplied
10851085
? this.getShadedRegionBounds(viewfinderWidth, viewfinderHeight, qrDimensions)
10861086
: defaultQrRegion;
1087-
1087+
10881088
const canvasElement = this.createCanvasElement(
10891089
qrRegion.width, qrRegion.height);
10901090
// Tell user agent that this canvas will be read frequently.
@@ -1106,7 +1106,7 @@ export class Html5Qrcode {
11061106
}
11071107

11081108
this.createScannerPausedUiElement(this.element!);
1109-
1109+
11101110
// Update local states
11111111
this.qrRegion = qrRegion;
11121112
this.context = context;
@@ -1128,38 +1128,38 @@ export class Html5Qrcode {
11281128
rootElement.appendChild(scannerPausedUiElement);
11291129
this.scannerPausedUiElement = scannerPausedUiElement;
11301130
}
1131-
1132-
/**
1133-
* Scans current context using the qrcode library.
1134-
*
1135-
* <p>This method call would result in callback being triggered by the
1136-
* qrcode library. This method also handles the border coloring.
1137-
*
1138-
* @returns true if scan match is found, false otherwise.
1139-
*/
1131+
1132+
/**
1133+
* Scans current context using the qrcode library.
1134+
*
1135+
* <p>This method call would result in callback being triggered by the
1136+
* qrcode library. This method also handles the border coloring.
1137+
*
1138+
* @returns true if scan match is found, false otherwise.
1139+
*/
11401140
private scanContext(
1141-
qrCodeSuccessCallback: QrcodeSuccessCallback,
1142-
qrCodeErrorCallback: QrcodeErrorCallback
1143-
): Promise<boolean> {
1141+
qrCodeSuccessCallback: QrcodeSuccessCallback,
1142+
qrCodeErrorCallback: QrcodeErrorCallback
1143+
): Promise<boolean> {
11441144
if (this.stateManagerProxy.isPaused()) {
11451145
return Promise.resolve(false);
11461146
}
11471147

11481148
return this.qrcode.decodeAsync(this.canvasElement!)
1149-
.then((result) => {
1150-
qrCodeSuccessCallback(
1151-
result.text,
1152-
Html5QrcodeResultFactory.createFromQrcodeResult(
1153-
result));
1154-
this.possiblyUpdateShaders(/* qrMatch= */ true);
1155-
return true;
1156-
}).catch((error) => {
1157-
this.possiblyUpdateShaders(/* qrMatch= */ false);
1158-
let errorMessage = Html5QrcodeStrings.codeParseError(error);
1159-
qrCodeErrorCallback(
1160-
errorMessage, Html5QrcodeErrorFactory.createFrom(errorMessage));
1161-
return false;
1162-
});
1149+
.then((result) => {
1150+
qrCodeSuccessCallback(
1151+
result.text,
1152+
Html5QrcodeResultFactory.createFromQrcodeResult(
1153+
result));
1154+
this.possiblyUpdateShaders(/* qrMatch= */ true);
1155+
return true;
1156+
}).catch((error) => {
1157+
this.possiblyUpdateShaders(/* qrMatch= */ false);
1158+
let errorMessage = Html5QrcodeStrings.codeParseError(error);
1159+
qrCodeErrorCallback(
1160+
errorMessage, Html5QrcodeErrorFactory.createFrom(errorMessage));
1161+
return false;
1162+
});
11631163
}
11641164

11651165
/**
@@ -1256,7 +1256,7 @@ export class Html5Qrcode {
12561256

12571257
private createVideoConstraints(
12581258
cameraIdOrConfig: string | MediaTrackConstraints)
1259-
: MediaTrackConstraints | undefined {
1259+
: MediaTrackConstraints | undefined {
12601260
if (typeof cameraIdOrConfig == "string") {
12611261
// If it's a string it should be camera device Id.
12621262
return { deviceId: { exact: cameraIdOrConfig } };
@@ -1273,20 +1273,20 @@ export class Html5Qrcode {
12731273
} else {
12741274
// Invalid config
12751275
throw "config has invalid 'facingMode' value = "
1276-
+ `'${value}'`;
1276+
+ `'${value}'`;
12771277
}
12781278
};
12791279

12801280
const keys = Object.keys(cameraIdOrConfig);
12811281
if (keys.length !== 1) {
12821282
throw "'cameraIdOrConfig' object should have exactly 1 key,"
1283-
+ ` if passed as an object, found ${keys.length} keys`;
1283+
+ ` if passed as an object, found ${keys.length} keys`;
12841284
}
12851285

12861286
const key:string = Object.keys(cameraIdOrConfig)[0];
12871287
if (key !== facingModeKey && key !== deviceIdKey) {
12881288
throw `Only '${facingModeKey}' and '${deviceIdKey}' `
1289-
+ " are supported for 'cameraIdOrConfig'";
1289+
+ " are supported for 'cameraIdOrConfig'";
12901290
}
12911291

12921292
if (key === facingModeKey) {
@@ -1305,15 +1305,15 @@ export class Html5Qrcode {
13051305
} else if (typeof facingMode == "object") {
13061306
if (exactKey in facingMode) {
13071307
if (isValidFacingModeValue(facingMode[`${exactKey}`])) {
1308-
return {
1309-
facingMode: {
1310-
exact: facingMode[`${exactKey}`]
1311-
}
1312-
};
1308+
return {
1309+
facingMode: {
1310+
exact: facingMode[`${exactKey}`]
1311+
}
1312+
};
13131313
}
13141314
} else {
13151315
throw "'facingMode' should be string or object with"
1316-
+ ` ${exactKey} as key.`;
1316+
+ ` ${exactKey} as key.`;
13171317
}
13181318
} else {
13191319
const type = (typeof facingMode);
@@ -1335,7 +1335,7 @@ export class Html5Qrcode {
13351335
};
13361336
} else {
13371337
throw "'deviceId' should be string or object with"
1338-
+ ` ${exactKey} as key.`;
1338+
+ ` ${exactKey} as key.`;
13391339
}
13401340
} else {
13411341
const type = (typeof deviceId);
@@ -1462,7 +1462,7 @@ export class Html5Qrcode {
14621462
height: number,
14631463
qrboxSize: QrDimensions) {
14641464
if ((width - qrboxSize.width) < 1 || (height - qrboxSize.height) < 1) {
1465-
return;
1465+
return;
14661466
}
14671467
const shadingElement = document.createElement("div");
14681468
shadingElement.style.position = "absolute";
@@ -1484,18 +1484,18 @@ export class Html5Qrcode {
14841484
shadingElement.style.left = "0px";
14851485
shadingElement.style.right = "0px";
14861486
shadingElement.id = `${Constants.SHADED_REGION_ELEMENT_ID}`;
1487-
1487+
14881488
// Check if div is too small for shadows. As there are two 5px width
14891489
// borders the needs to have a size above 10px.
1490-
if ((width - qrboxSize.width) < 11
1490+
if ((width - qrboxSize.width) < 11
14911491
|| (height - qrboxSize.height) < 11) {
1492-
this.hasBorderShaders = false;
1492+
this.hasBorderShaders = false;
14931493
} else {
14941494
const smallSize = 5;
14951495
const largeSize = 40;
14961496
this.insertShaderBorders(
14971497
shadingElement,
1498-
/* width= */ largeSize,
1498+
/* width= */ largeSize,
14991499
/* height= */ smallSize,
15001500
/* top= */ -smallSize,
15011501
/* bottom= */ null,
@@ -1579,15 +1579,15 @@ export class Html5Qrcode {
15791579
elem.style.top = `${top}px`;
15801580
}
15811581
if (bottom !== null) {
1582-
elem.style.bottom = `${bottom}px`;
1582+
elem.style.bottom = `${bottom}px`;
15831583
}
15841584
if (isLeft) {
1585-
elem.style.left = `${side}px`;
1585+
elem.style.left = `${side}px`;
15861586
} else {
1587-
elem.style.right = `${side}px`;
1587+
elem.style.right = `${side}px`;
15881588
}
15891589
if (!this.borderShaders) {
1590-
this.borderShaders = [];
1590+
this.borderShaders = [];
15911591
}
15921592
this.borderShaders.push(elem);
15931593
shaderElem.appendChild(elem);

0 commit comments

Comments
 (0)