Socket
Socket
Sign inDemoInstall

@zxing/library

Package Overview
Dependencies
Maintainers
3
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zxing/library - npm Package Compare versions

Comparing version 0.5.1 to 0.6.0-beta.0

esm5/browser/BrowserDatamatrixCodeReader.d.ts

63

CONTRIBUTING.md

@@ -7,10 +7,19 @@ # Contributing

Local development using Node and npm, see package.json for dependencies.
Local development using Node.js and `npm` or `yarn`, see `package.json` for dependencies.
**Note:** Keep dependencies at minimum necessary.
**Note:** Keep dependencies at minimum necessary. 🖤
Unit tests: Mocha
### Run the docs
If using Visual Studio Code IDE hava a look at tsconfig.json and .vscode for default configurations
To run the docs, open the CLI in this project root folder (something like `<somepath>/zxing-js/library`):
```bash
user@computer BUILDV <somepath>/zxing-js/library (develop)
http-server ./docs -a localhost -p 4040 -o
```
**Note:** `http-server` is a package that runs a local server, install with `npm i -g http-server`.
## Porting

@@ -29,35 +38,30 @@

* Keep all types as close to the original as possible.
* Keep detailed type information in comments where applicable (example int will become `number /*int*/`) as the code is extensively using bitwise operations that can overflow.
* Use TypedArray whenever possible (example `int[]` will become `Int32Array`) - see below for more info.
* Use constructor property whenever possible.
* Take care of array initialisation with capacity, especially when using length and push later on. Basically only use when setting with index accesor only .
* Use utility classes to implement platform dependencies (like `System` or `Arrays`), avoid inline implementation for anything that is not trivial.
* Use single class|enum|interface per module, export with default. Move internal classes to separate modules if used from other modules.
* Package level visibility will transform to public to avoid module complexity.
* Keep enum as similar with the original interface as possible (transform to class and use static fields for enum values).
* Allways use `===` for `==` to avoid gliches from type transforms.
- Keep all types as close to the original as possible.
- Keep detailed type information in comments where applicable (example int will become `number /*int*/`) as the code is extensively using bitwise operations that can overflow.
- Use TypedArray whenever possible (example `int[]` will become `Int32Array`) - see below for more info.
- Use constructor property whenever possible.
- Take care of array initialisation with capacity, especially when using length and push later on. Basically only use when setting with index accesor only .
- Use utility classes to implement platform dependencies (like `System` or `Arrays`), avoid inline implementation for anything that is not trivial.
- Use single class|enum|interface per module, export with default. Move internal classes to separate modules if used from other modules.
- Package level visibility will transform to public to avoid module complexity.
- Keep enum as similar with the original interface as possible (transform to class and use static fields for enum values).
- Allways use `===` for `==` to avoid gliches from type transforms.
## Types
**Java types:**
### Java types
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
**JavasSript TypedArray:**
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
- `byte` has 8 bits, signed (eg -127 to 127), so `byte[]` would trasnforms to `Int8Array` however:
- `TextEncoder` will use `Uint8Array`.
- `canvas` image data will use `Uint8ClampedArray`.
- `int` has 32 bits, signed, so `int[]` transforms to `Int32Array`.
- `char` has 2 bytes, so `char[]` transfomrs to `Uint16Array`.
- `long` has 64 bit two's complement `integer`, can be signed or unsigned.
Java byte has 8 bits, signed (eg -127 to 127)
So `byte[]` would trasnforms to `Int8Array` however:
- because of using TextEncoder will use `Uint8Array`.
- because canvas image data will use `Uint8ClampedArray`.
### JavasSript TypedArray
Java int has 32 bits, signed
So `int[]` transforms to Int32Array
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
Java char has 2 bytes
So `char[]` transfomrs to Uint16Array
Java long has 64-bit two's complement integer, can be signed or unsigned
## Things to look for

@@ -83,3 +87,2 @@

- `Cp437` not supported by TextEncoding library see `DecodedBitStreamParserTestCase`.
- Need to completely redesign exception based "not found" pattern as exceptions do not work on node async environment.
- Replace `instanceof` with something more robust.

@@ -86,0 +89,0 @@ - Simplify double `null !== <something> && undefined !== <something>` checks.

@@ -15,3 +15,3 @@ import Reader from './../core/Reader';

private timeBetweenScansMillis;
private hints;
private hints?;
private videoElement;

@@ -62,4 +62,4 @@ private imageElement;

decodeFromVideoSource(videoUrl: string, videoElement?: string | HTMLVideoElement): Promise<Result>;
private prepareVideoElement(videoElement?);
private getMediaElement(mediaElementId, type);
private prepareVideoElement;
private getMediaElement;
/**

@@ -75,9 +75,13 @@ * Decodes the barcode from an image.

decodeFromImage(imageElement?: string | HTMLImageElement, imageUrl?: string): Promise<Result>;
private isImageLoaded(img);
private prepareImageElement(imageElement?);
private decodeOnceWithDelay(resolve, reject);
private decodeOnce(resolve, reject, retryIfNotFound?, retryIfChecksumOrFormatError?);
private isImageLoaded;
private prepareImageElement;
private decodeOnceWithDelay;
private decodeOnce;
/**
* This will remain protected, so who extends this class can customize this method.
*/
protected drawImageOnCanvas(canvasElementContext: CanvasRenderingContext2D, srcElement: HTMLVideoElement | HTMLImageElement): void;
protected readerDecode(binaryBitmap: BinaryBitmap): Result;
private prepareCaptureCanvas();
private stop();
private prepareCaptureCanvas;
private stop;
/**

@@ -84,0 +88,0 @@ * Resets the code reader to the initial state. Cancels any ongoing barcode scanning from video or camera.

@@ -5,5 +5,8 @@ "use strict";

var HybridBinarizer_1 = require("./../core/common/HybridBinarizer");
var Exception_1 = require("./../core/Exception");
var NotFoundException_1 = require("../core/NotFoundException");
var ArgumentException_1 = require("../core/ArgumentException");
var HTMLCanvasElementLuminanceSource_1 = require("./HTMLCanvasElementLuminanceSource");
var VideoInputDevice_1 = require("./VideoInputDevice");
var ChecksumException_1 = require("../core/ChecksumException");
var FormatException_1 = require("../core/FormatException");
/**

@@ -112,3 +115,3 @@ * Base class for browser code reader.

me.stop();
reject(new Exception_1.default(Exception_1.default.NotFoundException));
reject(new NotFoundException_1.default());
};

@@ -145,7 +148,7 @@ me.videoElement.addEventListener('ended', me.videoPlayEndedEventListener);

if (null === mediaElement) {
throw new Exception_1.default(Exception_1.default.ArgumentException, "element with id '" + mediaElementId + "' not found");
throw new ArgumentException_1.default("element with id '" + mediaElementId + "' not found");
}
if (mediaElement.nodeName.toLowerCase() !== type.toLowerCase()) {
console.log(mediaElement.nodeName);
throw new Exception_1.default(Exception_1.default.ArgumentException, "element with id '" + mediaElementId + "' must be an " + type + " element");
throw new ArgumentException_1.default("element with id '" + mediaElementId + "' must be an " + type + " element");
}

@@ -167,3 +170,3 @@ return mediaElement;

if (undefined === imageElement && undefined === imageUrl) {
throw new Exception_1.default(Exception_1.default.ArgumentException, 'either imageElement with a src set or an url must be provided');
throw new ArgumentException_1.default('either imageElement with a src set or an url must be provided');
}

@@ -184,3 +187,3 @@ this.prepareImageElement(imageElement);

else {
throw new Exception_1.default(Exception_1.default.ArgumentException, "either src or a loaded img should be provided");
throw new ArgumentException_1.default("either src or a loaded img should be provided");
}

@@ -227,3 +230,3 @@ });

}
this.canvasElementContext.drawImage(this.videoElement || this.imageElement, 0, 0);
this.drawImageOnCanvas(this.canvasElementContext, this.videoElement || this.imageElement);
var luminanceSource = new HTMLCanvasElementLuminanceSource_1.default(this.canvasElement);

@@ -237,7 +240,7 @@ var binaryBitmap = new BinaryBitmap_1.default(new HybridBinarizer_1.default(luminanceSource));

console.log(retryIfChecksumOrFormatError, re);
if (retryIfNotFound && Exception_1.default.isOfType(re, Exception_1.default.NotFoundException)) {
if (retryIfNotFound && re instanceof NotFoundException_1.default) {
console.log('not found, trying again...');
this.decodeOnceWithDelay(resolve, reject);
}
else if (retryIfChecksumOrFormatError && (Exception_1.default.isOfType(re, Exception_1.default.ChecksumException) || Exception_1.default.isOfType(re, Exception_1.default.FormatException))) {
else if (retryIfChecksumOrFormatError && (re instanceof ChecksumException_1.default || re instanceof FormatException_1.default)) {
console.log('checksum or format error, trying again...', re);

@@ -251,2 +254,8 @@ this.decodeOnceWithDelay(resolve, reject);

};
/**
* This will remain protected, so who extends this class can customize this method.
*/
BrowserCodeReader.prototype.drawImageOnCanvas = function (canvasElementContext, srcElement) {
canvasElementContext.drawImage(srcElement, 0, 0);
};
BrowserCodeReader.prototype.readerDecode = function (binaryBitmap) {

@@ -253,0 +262,0 @@ return this.reader.decode(binaryBitmap, this.hints);

@@ -21,6 +21,6 @@ import EncodeHintType from '../core/EncodeHintType';

*/
private renderResult(code, width, height, quietZone);
private createSVGElement(w, h);
private createSvgRectElement(x, y, w, h);
private renderResult;
private createSVGElement;
private createSvgRectElement;
}
export { BrowserQRCodeSvgWriter };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Exception_1 = require("../core/Exception");
var EncodeHintType_1 = require("../core/EncodeHintType");
var Encoder_1 = require("../core/qrcode/encoder/Encoder");
var ErrorCorrectionLevel_1 = require("../core/qrcode/decoder/ErrorCorrectionLevel");
var IllegalArgumentException_1 = require("../core/IllegalArgumentException");
var IllegalStateException_1 = require("../core/IllegalStateException");
var BrowserQRCodeSvgWriter = /** @class */ (function () {

@@ -22,9 +23,9 @@ /**

if (contents.length === 0) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Found empty contents');
throw new IllegalArgumentException_1.default('Found empty contents');
}
// if (format != BarcodeFormat.QR_CODE) {
// throw new Exception(Exception.IllegalArgumentException, "Can only encode QR_CODE, but got " + format)
// throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format)
// }
if (width < 0 || height < 0) {
throw new Exception_1.default('IllegalArgumentException', 'Requested dimensions are too small: ' + width + 'x' + height);
throw new IllegalArgumentException_1.default('Requested dimensions are too small: ' + width + 'x' + height);
}

@@ -51,3 +52,3 @@ var errorCorrectionLevel = ErrorCorrectionLevel_1.default.L;

if (input === null) {
throw new Exception_1.default(Exception_1.default.IllegalStateException);
throw new IllegalStateException_1.default();
}

@@ -54,0 +55,0 @@ var inputWidth = input.getWidth();

@@ -8,4 +8,4 @@ import LuminanceSource from './../core/LuminanceSource';

constructor(canvas: HTMLCanvasElement);
private static makeBufferFromCanvasImageData(canvas);
private static toGrayscaleBuffer(imageBuffer, width, height);
private static makeBufferFromCanvasImageData;
private static toGrayscaleBuffer;
getRow(y: number, row: Uint8ClampedArray): Uint8ClampedArray;

@@ -23,5 +23,5 @@ getMatrix(): Uint8ClampedArray;

rotateCounterClockwise45(): LuminanceSource;
private getTempCanvasElement();
private rotate(angle);
private getTempCanvasElement;
private rotate;
invert(): LuminanceSource;
}

@@ -15,3 +15,3 @@ "use strict";

var LuminanceSource_1 = require("./../core/LuminanceSource");
var Exception_1 = require("./../core/Exception");
var IllegalArgumentException_1 = require("../core/IllegalArgumentException");
var HTMLCanvasElementLuminanceSource = /** @class */ (function (_super) {

@@ -59,3 +59,3 @@ __extends(HTMLCanvasElementLuminanceSource, _super);

if (y < 0 || y >= this.getHeight()) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Requested row is outside the image: ' + y);
throw new IllegalArgumentException_1.default('Requested row is outside the image: ' + y);
}

@@ -62,0 +62,0 @@ var width = this.getWidth();

@@ -40,4 +40,4 @@ /**

/** UPC/EAN extension format. Not a stand-alone format. */
UPC_EAN_EXTENSION = 16,
UPC_EAN_EXTENSION = 16
}
export default BarcodeFormat;

@@ -0,1 +1,7 @@

/**
* This class is the core bitmap class used by ZXing to represent 1 bit data. Reader objects
* accept a BinaryBitmap and attempt to decode it.
*
* @author dswitkin@google.com (Daniel Switkin)
*/
import Binarizer from './Binarizer';

@@ -2,0 +8,0 @@ import BitArray from './common/BitArray';

@@ -18,10 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
/**
* This class is the core bitmap class used by ZXing to represent 1 bit data. Reader objects
* accept a BinaryBitmap and attempt to decode it.
*
* @author dswitkin@google.com (Daniel Switkin)
*/
/*namespace com.google.zxing {*/
var Exception_1 = require("./Exception");
var IllegalArgumentException_1 = require("./IllegalArgumentException");
var BinaryBitmap = /** @class */ (function () {

@@ -31,3 +24,3 @@ function BinaryBitmap(binarizer) {

if (binarizer === null) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Binarizer must be non-null.');
throw new IllegalArgumentException_1.default('Binarizer must be non-null.');
}

@@ -34,0 +27,0 @@ }

@@ -12,3 +12,3 @@ /**

getSizeInBytes(): number;
private ensureCapacity(size);
private ensureCapacity;
/**

@@ -103,3 +103,3 @@ * @param i bit to get

reverse(): void;
private static makeArray(size);
private static makeArray;
equals(o: any): boolean;

@@ -106,0 +106,0 @@ hashCode(): number;

@@ -23,3 +23,3 @@ "use strict";

var Arrays_1 = require("./../util/Arrays");
var Exception_1 = require("./../Exception");
var IllegalArgumentException_1 = require("../IllegalArgumentException");
/**

@@ -164,3 +164,3 @@ * <p>A simple, fast array of bits, represented compactly by an array of ints internally.</p>

if (end < start || start < 0 || end > this.size) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException);
throw new IllegalArgumentException_1.default();
}

@@ -203,3 +203,3 @@ if (end === start) {

if (end < start || start < 0 || end > this.size) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException);
throw new IllegalArgumentException_1.default();
}

@@ -244,3 +244,3 @@ if (end === start) {

if (numBits < 0 || numBits > 32) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Num bits must be between 0 and 32');
throw new IllegalArgumentException_1.default('Num bits must be between 0 and 32');
}

@@ -263,3 +263,3 @@ this.ensureCapacity(this.size + numBits);

if (this.size !== other.size) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Sizes don\'t match');
throw new IllegalArgumentException_1.default('Sizes don\'t match');
}

@@ -266,0 +266,0 @@ var bits = this.bits;

@@ -19,5 +19,5 @@ import BitArray from './BitArray';

private width;
private height;
private rowSize;
private bits;
private height?;
private rowSize?;
private bits?;
/**

@@ -147,4 +147,4 @@ * Creates an empty square {@link BitMatrix}.

toString(setString?: string, unsetString?: string, lineSeparator?: string): string;
private buildToString(setString, unsetString, lineSeparator);
private buildToString;
clone(): BitMatrix;
}

@@ -20,3 +20,2 @@ "use strict";

/*import java.util.Arrays;*/
var Exception_1 = require("./../Exception");
var BitArray_1 = require("./BitArray");

@@ -26,2 +25,3 @@ var System_1 = require("./../util/System");

var StringBuilder_1 = require("./../util/StringBuilder");
var IllegalArgumentException_1 = require("../IllegalArgumentException");
/**

@@ -59,3 +59,3 @@ * <p>Represents a 2D matrix of bits. In function arguments below, and throughout the common

// if (width < 1 || height < 1) {
// throw new Exception(Exception.IllegalArgumentException, "Both dimensions must be greater than 0")
// throw new IllegalArgumentException("Both dimensions must be greater than 0")
// }

@@ -68,5 +68,5 @@ // this.width = width

function BitMatrix(width /*int*/, height /*int*/, rowSize /*int*/, bits) {
this.width = width; /*int*/
this.height = height; /*int*/
this.rowSize = rowSize; /*int*/
this.width = width;
this.height = height;
this.rowSize = rowSize;
this.bits = bits;

@@ -78,3 +78,3 @@ if (undefined === height || null === height) {

if (width < 1 || height < 1) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Both dimensions must be greater than 0');
throw new IllegalArgumentException_1.default('Both dimensions must be greater than 0');
}

@@ -111,3 +111,3 @@ if (undefined === rowSize || null === rowSize) {

if (stringRepresentation === null) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'stringRepresentation cannot be null');
throw new IllegalArgumentException_1.default('stringRepresentation cannot be null');
}

@@ -128,3 +128,3 @@ var bits = new Array(stringRepresentation.length);

else if (bitsPos - rowStartPos !== rowLength) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'row lengths do not match');
throw new IllegalArgumentException_1.default('row lengths do not match');
}

@@ -147,3 +147,3 @@ rowStartPos = bitsPos;

else {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'illegal character encountered: ' + stringRepresentation.substring(pos));
throw new IllegalArgumentException_1.default('illegal character encountered: ' + stringRepresentation.substring(pos));
}

@@ -157,3 +157,3 @@ }

else if (bitsPos - rowStartPos !== rowLength) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'row lengths do not match');
throw new IllegalArgumentException_1.default('row lengths do not match');
}

@@ -214,3 +214,3 @@ nRows++;

|| this.rowSize !== mask.getRowSize()) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'input matrix dimensions do not match');
throw new IllegalArgumentException_1.default('input matrix dimensions do not match');
}

@@ -248,6 +248,6 @@ var rowArray = new BitArray_1.default(Math.floor(this.width / 32) + 1);

if (top < 0 || left < 0) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Left and top must be nonnegative');
throw new IllegalArgumentException_1.default('Left and top must be nonnegative');
}
if (height < 1 || width < 1) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Height and width must be at least 1');
throw new IllegalArgumentException_1.default('Height and width must be at least 1');
}

@@ -257,3 +257,3 @@ var right = left + width;

if (bottom > this.height || right > this.width) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'The region must fit inside the matrix');
throw new IllegalArgumentException_1.default('The region must fit inside the matrix');
}

@@ -260,0 +260,0 @@ var rowSize = this.rowSize;

@@ -19,3 +19,3 @@ "use strict";

/*namespace com.google.zxing.common {*/
var Exception_1 = require("./../Exception");
var IllegalArgumentException_1 = require("../IllegalArgumentException");
/**

@@ -60,3 +60,3 @@ * <p>This provides an easy abstraction to read bits at a time from a sequence of bytes, where the

if (numBits < 1 || numBits > 32 || numBits > this.available()) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, '' + numBits);
throw new IllegalArgumentException_1.default('' + numBits);
}

@@ -63,0 +63,0 @@ var result = 0;

@@ -28,3 +28,3 @@ export declare const enum CharacterSetValueIdentifiers {

GB18030 = 25,
EUC_KR = 26,
EUC_KR = 26
}

@@ -31,0 +31,0 @@ /**

@@ -19,3 +19,3 @@ "use strict";

/*namespace com.google.zxing.common {*/
var Exception_1 = require("./../Exception");
var FormatException_1 = require("../FormatException");
/**

@@ -82,7 +82,7 @@ * Encapsulates a Character Set ECI, according to "Extended Channel Interpretations" 5.3.1.1

if (value < 0 || value >= 900) {
throw new Exception_1.default(Exception_1.default.FormatException, 'incorect value');
throw new FormatException_1.default('incorect value');
}
var characterSet = CharacterSetECI.VALUES_TO_ECI.get(value);
if (undefined === characterSet) {
throw new Exception_1.default(Exception_1.default.FormatException, 'incorect value');
throw new FormatException_1.default('incorect value');
}

@@ -99,3 +99,3 @@ return characterSet;

if (undefined === characterSet) {
throw new Exception_1.default(Exception_1.default.FormatException, 'incorect value');
throw new FormatException_1.default('incorect value');
}

@@ -102,0 +102,0 @@ return characterSet;

@@ -32,3 +32,3 @@ "use strict";

var PerspectiveTransform_1 = require("./PerspectiveTransform");
var Exception_1 = require("./../Exception");
var NotFoundException_1 = require("../NotFoundException");
/**

@@ -50,3 +50,3 @@ * @author Sean Owen

if (dimensionX <= 0 || dimensionY <= 0) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -82,3 +82,3 @@ var bits = new BitMatrix_1.default(dimensionX, dimensionY);

// catching and wrapping ArrayIndexOutOfBoundsException.
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -85,0 +85,0 @@ }

@@ -5,3 +5,3 @@ /**

export default class MathUtils {
private MathUtils();
private MathUtils;
/**

@@ -8,0 +8,0 @@ * Ends up being a bit faster than {@link Math#round(float)}. This merely rounds its

@@ -46,3 +46,3 @@ import ResultPoint from './../../ResultPoint';

detect(): Array<ResultPoint>;
private getBlackPointOnSegment(aX, aY, bX, bY);
private getBlackPointOnSegment;
/**

@@ -61,3 +61,3 @@ * recenters the points of a constant distance towards the center

*/
private centerEdges(y, z, x, t);
private centerEdges;
/**

@@ -72,3 +72,3 @@ * Determines whether a segment contains a black point

*/
private containsBlackPoint(a, b, fixed, horizontal);
private containsBlackPoint;
}

@@ -20,4 +20,4 @@ "use strict";

var ResultPoint_1 = require("./../../ResultPoint");
var Exception_1 = require("./../../Exception");
var MathUtils_1 = require("./MathUtils");
var NotFoundException_1 = require("../../NotFoundException");
/**

@@ -52,8 +52,8 @@ * <p>

if (undefined === x || null === x) {
x = image.getWidth() / 2;
x = image.getWidth() / 2 | 0;
}
if (undefined === y || null === y) {
y = image.getHeight() / 2;
y = image.getHeight() / 2 | 0;
}
var halfsize = initSize / 2;
var halfsize = initSize / 2 | 0;
this.leftInit = x - halfsize;

@@ -64,3 +64,3 @@ this.rightInit = x + halfsize;

if (this.upInit < 0 || this.leftInit < 0 || this.downInit >= this.height || this.rightInit >= this.width) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -185,3 +185,3 @@ }

if (z == null) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -194,3 +194,3 @@ var t = null;

if (t == null) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -203,3 +203,3 @@ var x = null;

if (x == null) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -212,3 +212,3 @@ var y = null;

if (y == null) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -218,3 +218,3 @@ return this.centerEdges(y, z, x, t);

else {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -221,0 +221,0 @@ };

@@ -27,4 +27,4 @@ import Binarizer from './../Binarizer';

createBinarizer(source: LuminanceSource): Binarizer;
private initArrays(luminanceSize);
private static estimateBlackPoint(buckets);
private initArrays;
private static estimateBlackPoint;
}

@@ -32,3 +32,3 @@ "use strict";

var BitMatrix_1 = require("./BitMatrix");
var Exception_1 = require("./../Exception");
var NotFoundException_1 = require("../NotFoundException");
/**

@@ -179,3 +179,3 @@ * This Binarizer implementation uses the old ZXing global histogram approach. It is suitable

if (secondPeak - firstPeak <= numBuckets / 16) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -182,0 +182,0 @@ // Find a valley between them that is low and closer to the white peak.

@@ -18,3 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var Exception_1 = require("./../Exception");
var NotFoundException_1 = require("../NotFoundException");
/**

@@ -60,3 +60,3 @@ * Implementations of this class can, given locations of finder patterns for a QR code in an

if (x < -1 || x > width || y < -1 || y > height) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -87,3 +87,3 @@ nudged = false;

if (x < -1 || x > width || y < -1 || y > height) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -90,0 +90,0 @@ nudged = false;

@@ -42,8 +42,8 @@ import Binarizer from './../Binarizer';

*/
private static calculateThresholdForBlock(luminances, subWidth, subHeight, width, height, blackPoints, matrix);
private static cap(value, min, max);
private static calculateThresholdForBlock;
private static cap;
/**
* Applies a single threshold to a block of pixels.
*/
private static thresholdBlock(luminances, xoffset, yoffset, threshold, stride, matrix);
private static thresholdBlock;
/**

@@ -54,3 +54,3 @@ * Calculates a single black point for each block of pixels and saves it away.

*/
private static calculateBlackPoints(luminances, subWidth, subHeight, width, height);
private static calculateBlackPoints;
}

@@ -28,11 +28,11 @@ "use strict";

function PerspectiveTransform(a11 /*float*/, a21 /*float*/, a31 /*float*/, a12 /*float*/, a22 /*float*/, a32 /*float*/, a13 /*float*/, a23 /*float*/, a33 /*float*/) {
this.a11 = a11; /*float*/
this.a21 = a21; /*float*/
this.a31 = a31; /*float*/
this.a12 = a12; /*float*/
this.a22 = a22; /*float*/
this.a32 = a32; /*float*/
this.a13 = a13; /*float*/
this.a23 = a23; /*float*/
this.a33 = a33; /*float*/
this.a11 = a11;
this.a21 = a21;
this.a31 = a31;
this.a12 = a12;
this.a22 = a22;
this.a32 = a32;
this.a13 = a13;
this.a23 = a23;
this.a33 = a33;
}

@@ -39,0 +39,0 @@ PerspectiveTransform.quadrilateralToQuadrilateral = function (x0 /*float*/, y0 /*float*/, x1 /*float*/, y1 /*float*/, x2 /*float*/, y2 /*float*/, x3 /*float*/, y3 /*float*/, x0p /*float*/, y0p /*float*/, x1p /*float*/, y1p /*float*/, x2p /*float*/, y2p /*float*/, x3p /*float*/, y3p /*float*/) {

@@ -20,4 +20,5 @@ "use strict";

var GenericGFPoly_1 = require("./GenericGFPoly");
var Exception_1 = require("./../../Exception");
var Integer_1 = require("./../../util/Integer");
var IllegalArgumentException_1 = require("../../IllegalArgumentException");
var ArithmeticException_1 = require("../../ArithmeticException");
/**

@@ -47,5 +48,5 @@ * <p>This class contains utility methods for performing mathematical operations over

function GenericGF(primitive /*int*/, size /*int*/, generatorBase /*int*/) {
this.primitive = primitive; /*int*/
this.size = size; /*int*/
this.generatorBase = generatorBase; /*int*/
this.primitive = primitive;
this.size = size;
this.generatorBase = generatorBase;
var expTable = new Int32Array(size);

@@ -82,3 +83,3 @@ var x = 1;

if (degree < 0) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException);
throw new IllegalArgumentException_1.default();
}

@@ -111,3 +112,3 @@ if (coefficient === 0) {

if (a === 0) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException);
throw new IllegalArgumentException_1.default();
}

@@ -121,3 +122,3 @@ return this.logTable[a];

if (a === 0) {
throw new Exception_1.default(Exception_1.default.ArithmeticException);
throw new ArithmeticException_1.default();
}

@@ -124,0 +125,0 @@ return this.expTable[this.size - this.logTable[a] - 1];

@@ -20,4 +20,4 @@ "use strict";

var GenericGF_1 = require("./GenericGF");
var Exception_1 = require("./../../Exception");
var System_1 = require("./../../util/System");
var IllegalArgumentException_1 = require("../../IllegalArgumentException");
/**

@@ -44,3 +44,3 @@ * <p>Represents a polynomial whose coefficients are elements of a GF.

if (coefficients.length === 0) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException);
throw new IllegalArgumentException_1.default();
}

@@ -117,3 +117,3 @@ this.field = field;

if (!this.field.equals(other.field)) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'GenericGFPolys do not have same GenericGF field');
throw new IllegalArgumentException_1.default('GenericGFPolys do not have same GenericGF field');
}

@@ -144,3 +144,3 @@ if (this.isZero()) {

if (!this.field.equals(other.field)) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'GenericGFPolys do not have same GenericGF field');
throw new IllegalArgumentException_1.default('GenericGFPolys do not have same GenericGF field');
}

@@ -182,3 +182,3 @@ if (this.isZero() || other.isZero()) {

if (degree < 0) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException);
throw new IllegalArgumentException_1.default();
}

@@ -199,6 +199,6 @@ if (coefficient === 0) {

if (!this.field.equals(other.field)) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'GenericGFPolys do not have same GenericGF field');
throw new IllegalArgumentException_1.default('GenericGFPolys do not have same GenericGF field');
}
if (other.isZero()) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Divide by 0');
throw new IllegalArgumentException_1.default('Divide by 0');
}

@@ -205,0 +205,0 @@ var field = this.field;

@@ -37,5 +37,5 @@ import GenericGF from './GenericGF';

decode(received: Int32Array, twoS: number): void;
private runEuclideanAlgorithm(a, b, R);
private findErrorLocations(errorLocator);
private findErrorMagnitudes(errorEvaluator, errorLocations);
private runEuclideanAlgorithm;
private findErrorLocations;
private findErrorMagnitudes;
}

@@ -21,3 +21,4 @@ "use strict";

var GenericGFPoly_1 = require("./GenericGFPoly");
var Exception_1 = require("./../../Exception");
var ReedSolomonException_1 = require("../../ReedSolomonException");
var IllegalStateException_1 = require("../../IllegalStateException");
/**

@@ -82,3 +83,3 @@ * <p>Implements Reed-Solomon decoding, as the name implies.</p>

if (position < 0) {
throw new Exception_1.default(Exception_1.default.ReedSolomonException, 'Bad error location');
throw new ReedSolomonException_1.default('Bad error location');
}

@@ -101,3 +102,3 @@ received[position] = GenericGF_1.default.addOrSubtract(received[position], errorMagnitudes[i]);

// Run Euclidean algorithm until r's degree is less than R/2
while (r.getDegree() >= R / 2) {
while (r.getDegree() >= (R / 2 | 0)) {
var rLastLast = rLast;

@@ -110,3 +111,3 @@ var tLastLast = tLast;

// Oops, Euclidean algorithm already terminated?
throw new Exception_1.default(Exception_1.default.ReedSolomonException, 'r_{i-1} was zero');
throw new ReedSolomonException_1.default('r_{i-1} was zero');
}

@@ -125,3 +126,3 @@ r = rLastLast;

if (r.getDegree() >= rLast.getDegree()) {
throw new Exception_1.default(Exception_1.default.IllegalStateException, 'Division algorithm failed to reduce polynomial?');
throw new IllegalStateException_1.default('Division algorithm failed to reduce polynomial?');
}

@@ -131,3 +132,3 @@ }

if (sigmaTildeAtZero === 0) {
throw new Exception_1.default(Exception_1.default.ReedSolomonException, 'sigmaTilde(0) was zero');
throw new ReedSolomonException_1.default('sigmaTilde(0) was zero');
}

@@ -142,3 +143,3 @@ var inverse = field.inverse(sigmaTildeAtZero);

var numErrors = errorLocator.getDegree();
if (numErrors === 1) {
if (numErrors === 1) { // shortcut
return Int32Array.from([errorLocator.getCoefficient(1)]);

@@ -156,3 +157,3 @@ }

if (e !== numErrors) {
throw new Exception_1.default(Exception_1.default.ReedSolomonException, 'Error locator degree does not match number of roots');
throw new ReedSolomonException_1.default('Error locator degree does not match number of roots');
}

@@ -159,0 +160,0 @@ return result;

@@ -12,4 +12,4 @@ import GenericGF from './GenericGF';

constructor(field: GenericGF);
private buildGenerator(degree);
private buildGenerator;
encode(toEncode: Int32Array, ecBytes: number): void;
}

@@ -19,4 +19,4 @@ "use strict";

var GenericGFPoly_1 = require("./GenericGFPoly");
var Exception_1 = require("./../../Exception");
var System_1 = require("./../../util/System");
var IllegalArgumentException_1 = require("../../IllegalArgumentException");
/**

@@ -49,7 +49,7 @@ * <p>Implements Reed-Solomon encoding, as the name implies.</p>

if (ecBytes === 0) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'No error correction bytes');
throw new IllegalArgumentException_1.default('No error correction bytes');
}
var dataBytes = toEncode.length - ecBytes;
if (dataBytes <= 0) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'No data bytes provided');
throw new IllegalArgumentException_1.default('No data bytes provided');
}

@@ -56,0 +56,0 @@ var generator = this.buildGenerator(ecBytes);

@@ -11,8 +11,8 @@ import DecodeHintType from './../DecodeHintType';

static GB2312: string;
static ISO88591: string;
private static EUC_JP;
private static UTF8;
private static PLATFORM_DEFAULT_ENCODING;
private static ISO88591;
private static ASSUME_SHIFT_JIS;
private StringUtils();
private StringUtils;
/**

@@ -19,0 +19,0 @@ * @param bytes bytes encoding a string, whose encoding should be guessed

@@ -199,6 +199,6 @@ "use strict";

StringUtils.GB2312 = 'GB2312';
StringUtils.ISO88591 = CharacterSetECI_1.default.ISO8859_1.getName(); // "ISO8859_1"
StringUtils.EUC_JP = 'EUC_JP';
StringUtils.UTF8 = CharacterSetECI_1.default.UTF8.getName(); // "UTF8"
StringUtils.PLATFORM_DEFAULT_ENCODING = StringUtils.UTF8; // "UTF8"//Charset.defaultCharset().name()
StringUtils.ISO88591 = CharacterSetECI_1.default.ISO8859_1.getName(); // "ISO8859_1"
StringUtils.ASSUME_SHIFT_JIS = false;

@@ -205,0 +205,0 @@ return StringUtils;

@@ -67,4 +67,4 @@ /**

*/
ALLOWED_EAN_EXTENSIONS = 10,
ALLOWED_EAN_EXTENSIONS = 10
}
export default DecodeHintType;

@@ -18,3 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var Exception_1 = require("./Exception");
var IllegalArgumentException_1 = require("./IllegalArgumentException");
/*namespace com.google.zxing {*/

@@ -26,6 +26,6 @@ /**

function Dimension(width /*int*/, height /*int*/) {
this.width = width; /*int*/
this.height = height; /*int*/
this.width = width;
this.height = height;
if (width < 0 || height < 0) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException);
throw new IllegalArgumentException_1.default();
}

@@ -32,0 +32,0 @@ }

@@ -72,4 +72,4 @@ /**

*/
QR_VERSION = 10,
QR_VERSION = 10
}
export default EncodeHintType;

@@ -1,19 +0,12 @@

export default class Exception {
private type;
private message;
static IllegalArgumentException: string;
static NotFoundException: string;
static ArithmeticException: string;
static FormatException: string;
static ChecksumException: string;
static WriterException: string;
static IllegalStateException: string;
static UnsupportedOperationException: string;
static ReedSolomonException: string;
static ArgumentException: string;
static ReaderException: string;
constructor(type: string, message?: string);
getType(): string;
getMessage(): string | undefined;
static isOfType(ex: any, type: string): boolean;
import { CustomError } from 'ts-custom-error';
/**
* Custom Error class of type Exception.
*/
export default class Exception extends CustomError {
message: string;
/**
* Allows Exception to be constructed directly
* with some message and prototype definition.
*/
constructor(message?: string);
}
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var Exception = /** @class */ (function () {
function Exception(type, message) {
this.type = type;
this.message = message;
var ts_custom_error_1 = require("ts-custom-error");
/**
* Custom Error class of type Exception.
*/
var Exception = /** @class */ (function (_super) {
__extends(Exception, _super);
/**
* Allows Exception to be constructed directly
* with some message and prototype definition.
*/
function Exception(message) {
if (message === void 0) { message = undefined; }
var _this = _super.call(this, message) || this;
_this.message = message;
return _this;
}
Exception.prototype.getType = function () {
return this.type;
};
Exception.prototype.getMessage = function () {
return this.message;
};
Exception.isOfType = function (ex, type) {
return ex.type === type;
};
Exception.IllegalArgumentException = 'IllegalArgumentException';
Exception.NotFoundException = 'NotFoundException';
Exception.ArithmeticException = 'ArithmeticException';
Exception.FormatException = 'FormatException';
Exception.ChecksumException = 'ChecksumException';
Exception.WriterException = 'WriterException';
Exception.IllegalStateException = 'IllegalStateException';
Exception.UnsupportedOperationException = 'UnsupportedOperationException';
Exception.ReedSolomonException = 'ReedSolomonException';
Exception.ArgumentException = 'ArgumentException';
Exception.ReaderException = 'ReaderException';
return Exception;
}());
}(ts_custom_error_1.CustomError));
exports.default = Exception;
//# sourceMappingURL=Exception.js.map

@@ -18,4 +18,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var Exception_1 = require("./Exception");
var StringBuilder_1 = require("./util/StringBuilder");
var UnsupportedOperationException_1 = require("./UnsupportedOperationException");
/*namespace com.google.zxing {*/

@@ -33,4 +33,4 @@ /**

function LuminanceSource(width /*int*/, height /*int*/) {
this.width = width; /*int*/
this.height = height; /*int*/
this.width = width;
this.height = height;
}

@@ -66,3 +66,3 @@ /**

LuminanceSource.prototype.crop = function (left /*int*/, top /*int*/, width /*int*/, height /*int*/) {
throw new Exception_1.default(Exception_1.default.UnsupportedOperationException, 'This luminance source does not support cropping.');
throw new UnsupportedOperationException_1.default('This luminance source does not support cropping.');
};

@@ -82,3 +82,3 @@ /**

LuminanceSource.prototype.rotateCounterClockwise = function () {
throw new Exception_1.default(Exception_1.default.UnsupportedOperationException, 'This luminance source does not support rotation by 90 degrees.');
throw new UnsupportedOperationException_1.default('This luminance source does not support rotation by 90 degrees.');
};

@@ -92,3 +92,3 @@ /**

LuminanceSource.prototype.rotateCounterClockwise45 = function () {
throw new Exception_1.default(Exception_1.default.UnsupportedOperationException, 'This luminance source does not support rotation by 45 degrees.');
throw new UnsupportedOperationException_1.default('This luminance source does not support rotation by 45 degrees.');
};

@@ -95,0 +95,0 @@ /*@Override*/

@@ -23,2 +23,3 @@ import DecodeHintType from './DecodeHintType';

* @return The contents of the image
*
* @throws NotFoundException Any errors which occurred

@@ -32,2 +33,3 @@ */

* @return The contents of the image
*
* @throws NotFoundException Any errors which occurred

@@ -42,2 +44,3 @@ */

* @return The contents of the image
*
* @throws NotFoundException Any errors which occurred

@@ -55,3 +58,6 @@ */

reset(): void;
private decodeInternal(image);
/**
* @throws NotFoundException
*/
private decodeInternal;
}

@@ -19,4 +19,6 @@ "use strict";

var QRCodeReader_1 = require("./qrcode/QRCodeReader");
var Exception_1 = require("./Exception");
var MultiFormatOneDReader_1 = require("./oned/MultiFormatOneDReader");
var DataMatrixReader_1 = require("./datamatrix/DataMatrixReader");
var NotFoundException_1 = require("./NotFoundException");
var ReaderException_1 = require("./ReaderException");
/*namespace com.google.zxing {*/

@@ -41,6 +43,7 @@ /**

* @return The contents of the image
*
* @throws NotFoundException Any errors which occurred
*/
/*@Override*/
// public decode(image: BinaryBitmap): Result /*throws NotFoundException */ {
// public decode(image: BinaryBitmap): Result {
// setHints(null)

@@ -55,2 +58,3 @@ // return decodeInternal(image)

* @return The contents of the image
*
* @throws NotFoundException Any errors which occurred

@@ -69,2 +73,3 @@ */

* @return The contents of the image
*
* @throws NotFoundException Any errors which occurred

@@ -112,5 +117,5 @@ */

}
// if (formats.contains(BarcodeFormat.DATA_MATRIX)) {
// readers.push(new DataMatrixReader())
// }
if (formats.contains(5 /* DATA_MATRIX */)) {
readers.push(new DataMatrixReader_1.default());
}
// if (formats.contains(BarcodeFormat.AZTEC)) {

@@ -135,3 +140,3 @@ // readers.push(new AztecReader())

readers.push(new QRCodeReader_1.default());
// readers.push(new DataMatrixReader())
readers.push(new DataMatrixReader_1.default());
// readers.push(new AztecReader())

@@ -149,4 +154,4 @@ // readers.push(new PDF417Reader())

if (this.readers !== null) {
for (var i = 0, length_1 = this.readers.length; i !== length_1; i++) {
var reader = this.readers[i];
for (var _i = 0, _a = this.readers; _i < _a.length; _i++) {
var reader = _a[_i];
reader.reset();

@@ -156,18 +161,25 @@ }

};
/**
* @throws NotFoundException
*/
MultiFormatReader.prototype.decodeInternal = function (image) {
if (this.readers !== null) {
for (var i = 0, length_2 = this.readers.length; i !== length_2; i++) {
var reader = this.readers[i];
try {
return reader.decode(image, this.hints);
if (this.readers === null) {
throw new ReaderException_1.default('No readers where selected, nothing can be read.');
}
for (var _i = 0, _a = this.readers; _i < _a.length; _i++) {
var reader = _a[_i];
// console.log(`Trying to decode with ${reader.constructor.name} reader.`);
try {
return reader.decode(image, this.hints);
}
catch (ex) {
if (ex instanceof ReaderException_1.default) {
continue;
}
catch (re /*ReaderException*/) {
// console.log(`Exception ${re.type} ${re.message}`)
if (re.type === 'ReaderException') {
continue;
}
}
// Uncomment for test outputting.
// const extra = !ex.message ? '.' : ` with the message: \n\n\t${ex.message}\n\n`;
// console.error('[decodeInternal]', `Exception of type \`${ex.constructor.name}\` was thrown${extra}`);
}
}
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default('No MultiFormat Readers were able to detect the code.');
};

@@ -174,0 +186,0 @@ return MultiFormatReader;

@@ -30,3 +30,3 @@ "use strict";

var QRCodeWriter_1 = require("./qrcode/QRCodeWriter");
var Exception_1 = require("./Exception");
var IllegalArgumentException_1 = require("./IllegalArgumentException");
/*import java.util.Map;*/

@@ -93,3 +93,3 @@ /**

default:
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'No encoder available for format ' + format);
throw new IllegalArgumentException_1.default('No encoder available for format ' + format);
}

@@ -96,0 +96,0 @@ return writer.encode(contents, format, width, height, hints);

@@ -27,5 +27,5 @@ import BitArray from '../common/BitArray';

private static CODE_STOP;
private static findStartPattern(row);
private static decodeCode(row, counters, rowOffset);
private static findStartPattern;
private static decodeCode;
decodeRow(rowNumber: number, row: BitArray, hints?: Map<DecodeHintType, any>): Result;
}

@@ -28,6 +28,8 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var Exception_1 = require("../Exception");
var Result_1 = require("../Result");
var ResultPoint_1 = require("../ResultPoint");
var OneDReader_1 = require("./OneDReader");
var NotFoundException_1 = require("../NotFoundException");
var FormatException_1 = require("../FormatException");
var ChecksumException_1 = require("../ChecksumException");
/**

@@ -84,3 +86,3 @@ * <p>Decodes Code 128 barcodes.</p>

}
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
};

@@ -104,3 +106,3 @@ Code128Reader.decodeCode = function (row, counters, rowOffset) {

else {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -127,3 +129,3 @@ };

default:
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}

@@ -168,3 +170,3 @@ var done = false;

case Code128Reader.CODE_START_C:
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}

@@ -354,3 +356,3 @@ switch (codeSet) {

if (!row.isRange(nextStart, Math.min(row.getSize(), nextStart + (nextStart - lastStart) / 2), false)) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -361,3 +363,3 @@ // Pull out from sum the value of the penultimate check code

if (checksumTotal % 103 !== lastCode) {
throw new Exception_1.default(Exception_1.default.ChecksumException);
throw new ChecksumException_1.default();
}

@@ -368,3 +370,3 @@ // Need to pull out the check digits from string

// false positive
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -371,0 +373,0 @@ // Only bother if the result had at least one character, and if the checksum digit happened to

@@ -22,9 +22,9 @@ import BitArray from '../common/BitArray';

decodeRow(rowNumber: number, row: BitArray, hints?: Map<DecodeHintType, any>): Result;
private static decodeMiddle(row, payloadStart, payloadEnd, resultString);
private decodeStart(row);
private validateQuietZone(row, startPattern);
private static skipWhiteSpace(row);
private decodeEnd(row);
private static findGuardPattern(row, rowOffset, pattern);
private static decodeDigit(counters);
private static decodeMiddle;
private decodeStart;
private validateQuietZone;
private static skipWhiteSpace;
private decodeEnd;
private static findGuardPattern;
private static decodeDigit;
}

@@ -28,3 +28,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var Exception_1 = require("../Exception");
var Result_1 = require("../Result");

@@ -35,2 +34,4 @@ var ResultPoint_1 = require("../ResultPoint");

var System_1 = require("../util/System");
var FormatException_1 = require("../FormatException");
var NotFoundException_1 = require("../NotFoundException");
/**

@@ -89,3 +90,3 @@ * <p>Decodes ITF barcodes.</p>

if (!lengthOK) {
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}

@@ -178,3 +179,3 @@ var points = [new ResultPoint_1.default(startRange[1], rowNumber), new ResultPoint_1.default(endRange[0], rowNumber)];

// Unable to find the necessary number of quiet zone pixels.
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -194,3 +195,3 @@ };

if (endStart === width) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -276,3 +277,3 @@ return endStart;

}
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
};

@@ -307,3 +308,3 @@ /*/!**

else {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -310,0 +311,0 @@ };

@@ -30,4 +30,5 @@ "use strict";

var Code128Reader_1 = require("./Code128Reader");
var Exception_1 = require("../Exception");
var ITFReader_1 = require("./ITFReader");
var MultiFormatUPCEANReader_1 = require("./MultiFormatUPCEANReader");
var NotFoundException_1 = require("../NotFoundException");
/**

@@ -45,2 +46,5 @@ * @author Daniel Switkin <dswitkin@google.com>

if (possibleFormats) {
if (possibleFormats.get(7 /* EAN_13 */)) {
_this.readers.push(new MultiFormatUPCEANReader_1.default(hints));
}
// if (possibleFormats.get(BarcodeFormat.EAN_13) ||

@@ -79,2 +83,3 @@ // possibleFormats.get(BarcodeFormat.UPC_A) ||

// this.readers.push(new Code93Reader());
_this.readers.push(new MultiFormatUPCEANReader_1.default(hints));
_this.readers.push(new Code128Reader_1.default());

@@ -97,3 +102,3 @@ _this.readers.push(new ITFReader_1.default());

}
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
};

@@ -100,0 +105,0 @@ // @Override

@@ -30,3 +30,3 @@ import BinaryBitmap from '../BinaryBitmap';

*/
private doDecode(image, hints?);
private doDecode;
/**

@@ -33,0 +33,0 @@ * Records the size of successive runs of white and black pixels in a row, starting at a given point.

@@ -19,5 +19,5 @@ "use strict";

var BitArray_1 = require("../common/BitArray");
var Exception_1 = require("../Exception");
var ResultMetadataType_1 = require("../ResultMetadataType");
var ResultPoint_1 = require("../ResultPoint");
var NotFoundException_1 = require("../NotFoundException");
/**

@@ -69,3 +69,3 @@ * Encapsulates functionality and implementation that is common to all families

else {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -123,3 +123,3 @@ }

var _loop_1 = function (attempt) {
if (attempt === 1) {
if (attempt === 1) { // trying again?
row.reverse(); // reverse the row and continue

@@ -166,3 +166,3 @@ // This means we will only ever draw result points *once* in the life of this method

}
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
};

@@ -188,3 +188,3 @@ /**

if (start >= end) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -212,3 +212,3 @@ var isWhite = !row.get(start);

if (!(counterPosition === numCounters || (counterPosition === numCounters - 1 && i === end))) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -227,3 +227,3 @@ };

if (numTransitionsLeft >= 0) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -230,0 +230,0 @@ OneDReader.recordPattern(row, start + 1, counters);

@@ -33,4 +33,4 @@ import LuminanceSource from './LuminanceSource';

getThumbnailHeight(): number;
private reverseHorizontal(width, height);
private reverseHorizontal;
invert(): LuminanceSource;
}

@@ -30,5 +30,5 @@ "use strict";

var System_1 = require("./util/System");
var Exception_1 = require("./Exception");
var LuminanceSource_1 = require("./LuminanceSource");
var InvertedLuminanceSource_1 = require("./InvertedLuminanceSource");
var IllegalArgumentException_1 = require("./IllegalArgumentException");
/**

@@ -49,8 +49,8 @@ * This object extends LuminanceSource around an array of YUV data returned from the camera driver,

_this.yuvData = yuvData;
_this.dataWidth = dataWidth; /*int*/
_this.dataHeight = dataHeight; /*int*/
_this.left = left; /*int*/
_this.top = top; /*int*/
_this.dataWidth = dataWidth;
_this.dataHeight = dataHeight;
_this.left = left;
_this.top = top;
if (left + width > dataWidth || top + height > dataHeight) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Crop rectangle does not fit within image data.');
throw new IllegalArgumentException_1.default('Crop rectangle does not fit within image data.');
}

@@ -65,3 +65,3 @@ if (reverseHorizontal) {

if (y < 0 || y >= this.getHeight()) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Requested row is outside the image: ' + y);
throw new IllegalArgumentException_1.default('Requested row is outside the image: ' + y);
}

@@ -68,0 +68,0 @@ var width = this.getWidth();

@@ -33,3 +33,3 @@ import BitMatrix from './../../common/BitMatrix';

readVersion(): Version;
private copyBit(i, j, versionBits);
private copyBit;
/**

@@ -36,0 +36,0 @@ * <p>Reads the bits in the {@link BitMatrix} representing the finder pattern in the

@@ -20,4 +20,4 @@ "use strict";

var FormatInformation_1 = require("./FormatInformation");
var Exception_1 = require("./../../Exception");
var DataMask_1 = require("./DataMask");
var FormatException_1 = require("../../FormatException");
/**

@@ -34,3 +34,3 @@ * @author Sean Owen

if (dimension < 21 || (dimension & 0x03) !== 1) {
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}

@@ -77,3 +77,3 @@ this.bitMatrix = bitMatrix;

}
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
};

@@ -121,3 +121,3 @@ /**

}
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
};

@@ -181,3 +181,3 @@ BitMatrixParser.prototype.copyBit = function (i /*int*/, j /*int*/, versionBits /*int*/) {

if (resultOffset !== version.getTotalCodewords()) {
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}

@@ -184,0 +184,0 @@ return result;

@@ -18,3 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var Exception_1 = require("./../../Exception");
var IllegalArgumentException_1 = require("../../IllegalArgumentException");
/**

@@ -29,3 +29,3 @@ * <p>Encapsulates a block of data within a QR Code. QR Codes may split their data into

function DataBlock(numDataCodewords /*int*/, codewords) {
this.numDataCodewords = numDataCodewords; /*int*/
this.numDataCodewords = numDataCodewords;
this.codewords = codewords;

@@ -46,3 +46,3 @@ }

if (rawCodewords.length !== version.getTotalCodewords()) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException);
throw new IllegalArgumentException_1.default();
}

@@ -49,0 +49,0 @@ // Figure out the number and size of data blocks used by this version and

@@ -10,3 +10,3 @@ import BitMatrix from './../../common/BitMatrix';

DATA_MASK_110 = 6,
DATA_MASK_111 = 7,
DATA_MASK_111 = 7
}

@@ -13,0 +13,0 @@ /**

@@ -23,9 +23,9 @@ import DecodeHintType from './../../DecodeHintType';

*/
private static decodeHanziSegment(bits, result, count);
private static decodeKanjiSegment(bits, result, count);
private static decodeByteSegment(bits, result, count, currentCharacterSetECI, byteSegments, hints);
private static toAlphaNumericChar(value);
private static decodeAlphanumericSegment(bits, result, count, fc1InEffect);
private static decodeNumericSegment(bits, result, count);
private static parseECIValue(bits);
private static decodeHanziSegment;
private static decodeKanjiSegment;
private static decodeByteSegment;
private static toAlphaNumericChar;
private static decodeAlphanumericSegment;
private static decodeNumericSegment;
private static parseECIValue;
}

@@ -23,5 +23,5 @@ "use strict";

var Mode_1 = require("./Mode");
var Exception_1 = require("./../../Exception");
var StringBuilder_1 = require("./../../util/StringBuilder");
var StringEncoding_1 = require("./../../util/StringEncoding");
var FormatException_1 = require("../../FormatException");
/*import java.io.UnsupportedEncodingException;*/

@@ -74,3 +74,3 @@ /*import java.util.ArrayList;*/

if (bits.available() < 16) {
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}

@@ -87,3 +87,3 @@ // sequence number and parity is added later to the result metadata

if (currentCharacterSetECI === null) {
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}

@@ -118,3 +118,3 @@ break;

default:
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}

@@ -127,3 +127,3 @@ break;

// from readBits() calls
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}

@@ -138,3 +138,3 @@ return new DecoderResult_1.default(bytes, result.toString(), byteSegments.length === 0 ? null : byteSegments, ecLevel === null ? null : ecLevel.toString(), symbolSequence, parityData);

if (count * 13 > bits.available()) {
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}

@@ -167,3 +167,3 @@ // Each character will require 2 bytes. Read the characters as 2-byte pairs

catch (ignored /*: UnsupportedEncodingException*/) {
throw new Exception_1.default(Exception_1.default.FormatException, ignored);
throw new FormatException_1.default(ignored);
}

@@ -174,3 +174,3 @@ };

if (count * 13 > bits.available()) {
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}

@@ -204,3 +204,3 @@ // Each character will require 2 bytes. Read the characters as 2-byte pairs

catch (ignored /*: UnsupportedEncodingException*/) {
throw new Exception_1.default(Exception_1.default.FormatException, ignored);
throw new FormatException_1.default(ignored);
}

@@ -211,3 +211,3 @@ };

if (8 * count > bits.available()) {
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}

@@ -234,3 +234,3 @@ var readBytes = new Uint8Array(count);

catch (ignored /*: UnsupportedEncodingException*/) {
throw new Exception_1.default(Exception_1.default.FormatException, ignored);
throw new FormatException_1.default(ignored);
}

@@ -241,3 +241,3 @@ byteSegments.push(readBytes);

if (value >= DecodedBitStreamParser.ALPHANUMERIC_CHARS.length) {
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}

@@ -251,3 +251,3 @@ return DecodedBitStreamParser.ALPHANUMERIC_CHARS[value];

if (bits.available() < 11) {
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}

@@ -262,3 +262,3 @@ var nextTwoCharsBits = bits.readBits(11);

if (bits.available() < 6) {
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}

@@ -289,7 +289,7 @@ result.append(DecodedBitStreamParser.toAlphaNumericChar(bits.readBits(6)));

if (bits.available() < 10) {
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}
var threeDigitsBits = bits.readBits(10);
if (threeDigitsBits >= 1000) {
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}

@@ -304,7 +304,7 @@ result.append(DecodedBitStreamParser.toAlphaNumericChar(Math.floor(threeDigitsBits / 100)));

if (bits.available() < 7) {
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}
var twoDigitsBits = bits.readBits(7);
if (twoDigitsBits >= 100) {
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}

@@ -317,7 +317,7 @@ result.append(DecodedBitStreamParser.toAlphaNumericChar(Math.floor(twoDigitsBits / 10)));

if (bits.available() < 4) {
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}
var digitBits = bits.readBits(4);
if (digitBits >= 10) {
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}

@@ -343,3 +343,3 @@ result.append(DecodedBitStreamParser.toAlphaNumericChar(digitBits));

}
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
};

@@ -346,0 +346,0 @@ /**

@@ -34,3 +34,3 @@ import DecodeHintType from './../../DecodeHintType';

decodeBitMatrix(bits: BitMatrix, hints?: Map<DecodeHintType, any>): DecoderResult;
private decodeBitMatrixParser(parser, hints);
private decodeBitMatrixParser;
/**

@@ -44,3 +44,3 @@ * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to

*/
private correctErrors(codewordBytes, numDataCodewords);
private correctErrors;
}

@@ -25,3 +25,3 @@ "use strict";

var DecodedBitStreamParser_1 = require("./DecodedBitStreamParser");
var Exception_1 = require("./../../Exception");
var ChecksumException_1 = require("../../ChecksumException");
/*import java.util.Map;*/

@@ -155,3 +155,3 @@ /**

catch (ignored /*: ReedSolomonException*/) {
throw new Exception_1.default(Exception_1.default.ChecksumException);
throw new ChecksumException_1.default();
}

@@ -158,0 +158,0 @@ // Copy back into array of bytes -- only need to worry about the bytes that were data

@@ -15,3 +15,3 @@ "use strict";

}
this.ecCodewordsPerBlock = ecCodewordsPerBlock; /*int*/
this.ecCodewordsPerBlock = ecCodewordsPerBlock;
this.ecBlocks = ecBlocks;

@@ -18,0 +18,0 @@ }

@@ -5,3 +5,3 @@ export declare const enum ErrorCorrectionLevelValues {

Q = 2,
H = 3,
H = 3
}

@@ -8,0 +8,0 @@ /**

@@ -19,3 +19,4 @@ "use strict";

/*namespace com.google.zxing.qrcode.decoder {*/
var Exception_1 = require("./../../Exception");
var ArgumentException_1 = require("../../ArgumentException");
var IllegalArgumentException_1 = require("../../IllegalArgumentException");
/**

@@ -31,3 +32,3 @@ * <p>See ISO 18004:2006, 6.5.1. This enum encapsulates the four error correction levels

this.stringValue = stringValue;
this.bits = bits; /*int*/
this.bits = bits;
ErrorCorrectionLevel.FOR_BITS.set(bits, this);

@@ -48,3 +49,3 @@ ErrorCorrectionLevel.FOR_VALUE.set(value, this);

case 'H': return ErrorCorrectionLevel.H;
default: throw new Exception_1.default(Exception_1.default.ArgumentException, s + 'not available');
default: throw new ArgumentException_1.default(s + 'not available');
}

@@ -68,3 +69,3 @@ };

if (bits < 0 || bits >= ErrorCorrectionLevel.FOR_BITS.size) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException);
throw new IllegalArgumentException_1.default();
}

@@ -71,0 +72,0 @@ return ErrorCorrectionLevel.FOR_BITS.get(bits);

@@ -28,3 +28,3 @@ import ErrorCorrectionLevel from './ErrorCorrectionLevel';

static decodeFormatInformation(maskedFormatInfo1: number, maskedFormatInfo2: number): FormatInformation;
private static doDecodeFormatInformation(maskedFormatInfo1, maskedFormatInfo2);
private static doDecodeFormatInformation;
getErrorCorrectionLevel(): ErrorCorrectionLevel;

@@ -31,0 +31,0 @@ getDataMask(): number;

@@ -13,3 +13,3 @@ import Version from './Version';

/** See GBT 18284-2000; "Hanzi" is a transliteration of this mode name. */
HANZI = 9,
HANZI = 9
}

@@ -16,0 +16,0 @@ /**

@@ -18,4 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
/*namespace com.google.zxing.qrcode.decoder {*/
var Exception_1 = require("./../../Exception");
var IllegalArgumentException_1 = require("../../IllegalArgumentException");
/**

@@ -32,3 +31,3 @@ * <p>See ISO 18004:2006, 6.4.1, Tables 2 and 3. This enum encapsulates the various modes in which

this.characterCountBitsForVersions = characterCountBitsForVersions;
this.bits = bits; /*int*/
this.bits = bits;
Mode.FOR_BITS.set(bits, this);

@@ -45,3 +44,3 @@ Mode.FOR_VALUE.set(value, this);

if (undefined === mode) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException);
throw new IllegalArgumentException_1.default();
}

@@ -48,0 +47,0 @@ return mode;

@@ -20,6 +20,7 @@ "use strict";

var BitMatrix_1 = require("./../../common/BitMatrix");
var Exception_1 = require("./../../Exception");
var FormatInformation_1 = require("./FormatInformation");
var ECBlocks_1 = require("./ECBlocks");
var ECB_1 = require("./ECB");
var FormatException_1 = require("../../FormatException");
var IllegalArgumentException_1 = require("../../IllegalArgumentException");
/**

@@ -36,3 +37,3 @@ * See ISO 18004:2006 Annex D

}
this.versionNumber = versionNumber; /*int*/
this.versionNumber = versionNumber;
this.alignmentPatternCenters = alignmentPatternCenters;

@@ -75,3 +76,3 @@ this.ecBlocks = ecBlocks;

if (dimension % 4 !== 1) {
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}

@@ -82,3 +83,3 @@ try {

catch (ignored /*: IllegalArgumentException*/) {
throw new Exception_1.default(Exception_1.default.FormatException);
throw new FormatException_1.default();
}

@@ -88,3 +89,3 @@ };

if (versionNumber < 1 || versionNumber > 40) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException);
throw new IllegalArgumentException_1.default();
}

@@ -91,0 +92,0 @@ return Version.VERSIONS[versionNumber - 1];

@@ -40,3 +40,3 @@ "use strict";

var _this = _super.call(this, posX, posY) || this;
_this.estimatedModuleSize = estimatedModuleSize; /*float*/
_this.estimatedModuleSize = estimatedModuleSize;
return _this;

@@ -43,0 +43,0 @@ }

@@ -51,3 +51,3 @@ import ResultPointCallback from './../../ResultPointCallback';

*/
private static centerFromEnd(stateCount, end);
private static centerFromEnd;
/**

@@ -58,3 +58,3 @@ * @param stateCount count of black/white/black pixels just read

*/
private foundPatternCross(stateCount);
private foundPatternCross;
/**

@@ -71,3 +71,3 @@ * <p>After a horizontal scan finds a potential alignment pattern, this method

*/
private crossCheckVertical(startI, centerJ, maxCount, originalStateCountTotal);
private crossCheckVertical;
/**

@@ -84,3 +84,3 @@ * <p>This is called when a horizontal scan finds a possible alignment pattern. It will

*/
private handlePossibleCenter(stateCount, i, j);
private handlePossibleCenter;
}

@@ -19,3 +19,3 @@ "use strict";

var AlignmentPattern_1 = require("./AlignmentPattern");
var Exception_1 = require("./../../Exception");
var NotFoundException_1 = require("../../NotFoundException");
/*import java.util.ArrayList;*/

@@ -50,7 +50,7 @@ /*import java.util.List;*/

this.image = image;
this.startX = startX; /*int*/
this.startY = startY; /*int*/
this.width = width; /*int*/
this.height = height; /*int*/
this.moduleSize = moduleSize; /*float*/
this.startX = startX;
this.startY = startY;
this.width = width;
this.height = height;
this.moduleSize = moduleSize;
this.resultPointCallback = resultPointCallback;

@@ -95,8 +95,8 @@ this.possibleCenters = []; // new Array<any>(5))

// Black pixel
if (currentState === 1) {
if (currentState === 1) { // Counting black pixels
stateCount[1]++;
}
else {
if (currentState === 2) {
if (this.foundPatternCross(stateCount)) {
else { // Counting white pixels
if (currentState === 2) { // A winner?
if (this.foundPatternCross(stateCount)) { // Yes
var confirmed = this.handlePossibleCenter(stateCount, i, j);

@@ -117,4 +117,4 @@ if (confirmed !== null) {

}
else {
if (currentState === 1) {
else { // White pixel
if (currentState === 1) { // Counting black pixels
currentState++;

@@ -138,3 +138,3 @@ }

}
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
};

@@ -141,0 +141,0 @@ /**

@@ -37,4 +37,4 @@ import DecodeHintType from './../../DecodeHintType';

protected processFinderPatternInfo(info: FinderPatternInfo): DetectorResult;
private static createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);
private static sampleGrid(image, transform, dimension);
private static createTransform;
private static sampleGrid;
/**

@@ -44,3 +44,3 @@ * <p>Computes the dimension (number of modules on a size) of the QR Code based on the position

*/
private static computeDimension(topLeft, topRight, bottomLeft, moduleSize);
private static computeDimension;
/**

@@ -61,3 +61,3 @@ * <p>Computes an average estimated module size based on estimated derived from the positions

*/
private calculateModuleSizeOneWay(pattern, otherPattern);
private calculateModuleSizeOneWay;
/**

@@ -68,3 +68,3 @@ * See {@link #sizeOfBlackWhiteBlackRun(int, int, int, int)}; computes the total width of

*/
private sizeOfBlackWhiteBlackRunBothWays(fromX, fromY, toX, toY);
private sizeOfBlackWhiteBlackRunBothWays;
/**

@@ -78,3 +78,3 @@ * <p>This method traces a line from a point in the image, in the direction towards another point.

*/
private sizeOfBlackWhiteBlackRun(fromX, fromY, toX, toY);
private sizeOfBlackWhiteBlackRun;
/**

@@ -81,0 +81,0 @@ * <p>Attempts to locate an alignment pattern in a limited region of the image, which is

@@ -25,4 +25,4 @@ "use strict";

var FinderPatternFinder_1 = require("./FinderPatternFinder");
var Exception_1 = require("./../../Exception");
var AlignmentPatternFinder_1 = require("./AlignmentPatternFinder");
var NotFoundException_1 = require("../../NotFoundException");
/*import java.util.Map;*/

@@ -76,3 +76,3 @@ /**

if (moduleSize < 1.0) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default('No pattern found in proccess finder.');
}

@@ -91,4 +91,4 @@ var dimension = Detector.computeDimension(topLeft, topRight, bottomLeft, moduleSize);

var correctionToTopLeft = 1.0 - 3.0 / modulesBetweenFPCenters;
var estAlignmentX = Math.floor(topLeft.getX() + correctionToTopLeft * (bottomRightX - topLeft.getX()));
var estAlignmentY = Math.floor(topLeft.getY() + correctionToTopLeft * (bottomRightY - topLeft.getY()));
var estAlignmentX = /*(int) */ Math.floor(topLeft.getX() + correctionToTopLeft * (bottomRightX - topLeft.getX()));
var estAlignmentY = /*(int) */ Math.floor(topLeft.getY() + correctionToTopLeft * (bottomRightY - topLeft.getY()));
// Kind of arbitrary -- expand search radius before giving up

@@ -101,3 +101,3 @@ for (var i = 4; i <= 16; i <<= 1) {

catch (re /*NotFoundException*/) {
if (!Exception_1.default.isOfType(re, Exception_1.default.NotFoundException)) {
if (!(re instanceof NotFoundException_1.default)) {
throw re;

@@ -154,3 +154,3 @@ }

var dimension = Math.floor((tltrCentersDimension + tlblCentersDimension) / 2) + 7;
switch (dimension & 0x03) {
switch (dimension & 0x03) { // mod 4
case 0:

@@ -164,3 +164,3 @@ dimension++;

case 3:
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default('Dimensions could be not found.');
}

@@ -225,3 +225,3 @@ return dimension;

}
var otherToY = Math.floor(fromY - (toY - fromY) * scale);
var otherToY = /*(int) */ Math.floor(fromY - (toY - fromY) * scale);
scale = 1.0;

@@ -314,7 +314,7 @@ if (otherToY < 0) {

// should be
var allowance = Math.floor(allowanceFactor * overallEstModuleSize);
var allowance = /*(int) */ Math.floor(allowanceFactor * overallEstModuleSize);
var alignmentAreaLeftX = Math.max(0, estAlignmentX - allowance);
var alignmentAreaRightX = Math.min(this.image.getWidth() - 1, estAlignmentX + allowance);
if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default('Alignment top exceeds estimated module size.');
}

@@ -324,3 +324,3 @@ var alignmentAreaTopY = Math.max(0, estAlignmentY - allowance);

if (alignmentAreaBottomY - alignmentAreaTopY < overallEstModuleSize * 3) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default('Alignment bottom exceeds estimated module size.');
}

@@ -327,0 +327,0 @@ var alignmentFinder = new AlignmentPatternFinder_1.default(this.image, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, this.resultPointCallback);

@@ -11,3 +11,3 @@ import ResultPoint from './../../ResultPoint';

private estimatedModuleSize;
private count;
private count?;
constructor(posX: number, posY: number, estimatedModuleSize: number, count?: number);

@@ -14,0 +14,0 @@ getEstimatedModuleSize(): number;

@@ -44,4 +44,4 @@ "use strict";

var _this = _super.call(this, posX, posY) || this;
_this.estimatedModuleSize = estimatedModuleSize; /*float*/
_this.count = count; /*int*/
_this.estimatedModuleSize = estimatedModuleSize;
_this.count = count;
if (undefined === count) {

@@ -48,0 +48,0 @@ _this.count = 1;

@@ -36,3 +36,3 @@ import DecodeHintType from './../../DecodeHintType';

*/
private static centerFromEnd(stateCount, end);
private static centerFromEnd;
/**

@@ -44,3 +44,3 @@ * @param stateCount count of black/white/black/white/black pixels just read

protected static foundPatternCross(stateCount: Int32Array): boolean;
private getCrossCheckStateCount();
private getCrossCheckStateCount;
/**

@@ -58,3 +58,3 @@ * After a vertical and horizontal scan finds a potential finder pattern, this method

*/
private crossCheckDiagonal(startI, centerJ, maxCount, originalStateCountTotal);
private crossCheckDiagonal;
/**

@@ -71,3 +71,3 @@ * <p>After a horizontal scan finds a potential finder pattern, this method

*/
private crossCheckVertical(startI, centerJ, maxCount, originalStateCountTotal);
private crossCheckVertical;
/**

@@ -78,3 +78,3 @@ * <p>Like {@link #crossCheckVertical(int, int, int, int)}, and in fact is basically identical,

*/
private crossCheckHorizontal(startJ, centerI, maxCount, originalStateCountTotal);
private crossCheckHorizontal;
/**

@@ -105,3 +105,3 @@ * <p>This is called when a horizontal scan finds a possible alignment pattern. It will

*/
private findRowSkip();
private findRowSkip;
/**

@@ -112,3 +112,3 @@ * @return true iff we have found at least 3 finder patterns that have been detected

*/
private haveMultiplyConfirmedCenters();
private haveMultiplyConfirmedCenters;
/**

@@ -120,3 +120,3 @@ * @return the 3 best {@link FinderPattern}s from our list of candidates. The "best" are

*/
private selectBestPatterns();
private selectBestPatterns;
}

@@ -21,3 +21,3 @@ "use strict";

var FinderPatternInfo_1 = require("./FinderPatternInfo");
var Exception_1 = require("./../../Exception");
var NotFoundException_1 = require("../../NotFoundException");
/*import java.io.Serializable;*/

@@ -88,3 +88,3 @@ /*import java.util.ArrayList;*/

// Black pixel
if ((currentState & 1) === 1) {
if ((currentState & 1) === 1) { // Counting white pixels
currentState++;

@@ -94,6 +94,6 @@ }

}
else {
if ((currentState & 1) === 0) {
if (currentState === 4) {
if (FinderPatternFinder.foundPatternCross(stateCount)) {
else { // White pixel
if ((currentState & 1) === 0) { // Counting black pixels
if (currentState === 4) { // A winner?
if (FinderPatternFinder.foundPatternCross(stateCount)) { // Yes
var confirmed = this.handlePossibleCenter(stateCount, i, j, pureBarcode);

@@ -139,3 +139,3 @@ if (confirmed === true) {

}
else {
else { // No, shift counts back by two
stateCount[0] = stateCount[2];

@@ -153,3 +153,3 @@ stateCount[1] = stateCount[3];

}
else {
else { // Counting white pixels
stateCount[currentState]++;

@@ -551,3 +551,3 @@ }

// Couldn't find enough finder patterns
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -554,0 +554,0 @@ var possibleCenters = this.possibleCenters;

@@ -30,4 +30,4 @@ "use strict";

function ByteMatrix(width /*int*/, height /*int*/) {
this.width = width; /*int*/
this.height = height; /*int*/
this.width = width;
this.height = height;
var bytes = new Array(height); // [height][width]

@@ -34,0 +34,0 @@ for (var i = 0; i !== height; i++) {

@@ -15,3 +15,3 @@ import EncodeHintType from './../../EncodeHintType';

private constructor();
private static calculateMaskPenalty(matrix);
private static calculateMaskPenalty;
/**

@@ -30,4 +30,4 @@ * @param content text to encode

*/
private static recommendVersion(ecLevel, mode, headerBits, dataBits);
private static calculateBitsNeeded(mode, headerBits, dataBits, version);
private static recommendVersion;
private static calculateBitsNeeded;
/**

@@ -43,5 +43,5 @@ * @return the code point of the table used in alphanumeric mode or

static chooseMode(content: string, encoding?: string): Mode;
private static isOnlyDoubleByteKanji(content);
private static chooseMaskPattern(bits, ecLevel, version, matrix);
private static chooseVersion(numInputBits, ecLevel);
private static isOnlyDoubleByteKanji;
private static chooseMaskPattern;
private static chooseVersion;
/**

@@ -51,3 +51,3 @@ * @return true if the number of input bits will fit in a code with the specified version and

*/
private static willFit(numInputBits, version, ecLevel);
private static willFit;
/**

@@ -81,9 +81,12 @@ * Terminate bits as described in 8.4.8 and 8.4.9 of JISX0510:2004 (p.24).

static appendBytes(content: string, mode: Mode, bits: BitArray, encoding: string): void;
private static getDigit(singleCharacter);
private static isDigit(singleCharacter);
private static getDigit;
private static isDigit;
static appendNumericBytes(content: string, bits: BitArray): void;
static appendAlphanumericBytes(content: string, bits: BitArray): void;
static append8BitBytes(content: string, bits: BitArray, encoding: string): void;
/**
* @throws WriterException
*/
static appendKanjiBytes(content: string, bits: BitArray): void;
private static appendECI(eci, bits);
private static appendECI;
}

@@ -29,6 +29,6 @@ "use strict";

var QRCode_1 = require("./QRCode");
var Exception_1 = require("./../../Exception");
var MatrixUtil_1 = require("./MatrixUtil");
var StringEncoding_1 = require("./../../util/StringEncoding");
var BlockPair_1 = require("./BlockPair");
var WriterException_1 = require("../../WriterException");
/*import java.io.UnsupportedEncodingException;*/

@@ -97,3 +97,3 @@ /*import java.util.ArrayList;*/

if (!this.willFit(bitsNeeded, version, ecLevel)) {
throw new Exception_1.default(Exception_1.default.WriterException, 'Data too big for requested version');
throw new WriterException_1.default('Data too big for requested version');
}

@@ -235,3 +235,3 @@ }

}
throw new Exception_1.default(Exception_1.default.WriterException, 'Data too big');
throw new WriterException_1.default('Data too big');
};

@@ -260,3 +260,3 @@ /**

if (bits.getSize() > capacity) {
throw new Exception_1.default(Exception_1.default.WriterException, 'data bits cannot fit in the QR Code' + bits.getSize() + ' > ' +
throw new WriterException_1.default('data bits cannot fit in the QR Code' + bits.getSize() + ' > ' +
capacity);

@@ -281,3 +281,3 @@ }

if (bits.getSize() !== capacity) {
throw new Exception_1.default(Exception_1.default.WriterException, 'Bits size does not equal capacity');
throw new WriterException_1.default('Bits size does not equal capacity');
}

@@ -292,3 +292,3 @@ };

if (blockID >= numRSBlocks) {
throw new Exception_1.default(Exception_1.default.WriterException, 'Block ID too large');
throw new WriterException_1.default('Block ID too large');
}

@@ -314,7 +314,7 @@ // numRsBlocksInGroup2 = 196 % 5 = 1

if (numEcBytesInGroup1 !== numEcBytesInGroup2) {
throw new Exception_1.default(Exception_1.default.WriterException, 'EC bytes mismatch');
throw new WriterException_1.default('EC bytes mismatch');
}
// 5 = 4 + 1.
if (numRSBlocks !== numRsBlocksInGroup1 + numRsBlocksInGroup2) {
throw new Exception_1.default(Exception_1.default.WriterException, 'RS blocks mismatch');
throw new WriterException_1.default('RS blocks mismatch');
}

@@ -327,3 +327,3 @@ // 196 = (13 + 26) * 4 + (14 + 26) * 1

numRsBlocksInGroup2)) {
throw new Exception_1.default(Exception_1.default.WriterException, 'Total bytes mismatch');
throw new WriterException_1.default('Total bytes mismatch');
}

@@ -346,3 +346,3 @@ if (blockID < numRsBlocksInGroup1) {

if (bits.getSizeInBytes() !== numDataBytes) {
throw new Exception_1.default(Exception_1.default.WriterException, 'Number of bits and data bytes does not match');
throw new WriterException_1.default('Number of bits and data bytes does not match');
}

@@ -370,3 +370,3 @@ // Step 1. Divide data bytes into blocks and generate error correction bytes for them. We'll

if (numDataBytes !== dataBytesOffset) {
throw new Exception_1.default(Exception_1.default.WriterException, 'Data bytes does not match offset');
throw new WriterException_1.default('Data bytes does not match offset');
}

@@ -394,4 +394,4 @@ var result = new BitArray_1.default();

}
if (numTotalBytes !== result.getSizeInBytes()) {
throw new Exception_1.default('WriterException', 'Interleaving error: ' + numTotalBytes + ' and ' +
if (numTotalBytes !== result.getSizeInBytes()) { // Should be same.
throw new WriterException_1.default('Interleaving error: ' + numTotalBytes + ' and ' +
result.getSizeInBytes() + ' differ.');

@@ -426,3 +426,3 @@ }

if (numLetters >= (1 << numBits)) {
throw new Exception_1.default(Exception_1.default.WriterException, numLetters + ' is bigger than ' + ((1 << numBits) - 1));
throw new WriterException_1.default(numLetters + ' is bigger than ' + ((1 << numBits) - 1));
}

@@ -449,3 +449,3 @@ bits.appendBits(numLetters, numBits);

default:
throw new Exception_1.default(Exception_1.default.WriterException, 'Invalid mode: ' + mode);
throw new WriterException_1.default('Invalid mode: ' + mode);
}

@@ -491,3 +491,3 @@ };

if (code1 === -1) {
throw new Exception_1.default(Exception_1.default.WriterException);
throw new WriterException_1.default();
}

@@ -497,3 +497,3 @@ if (i + 1 < length) {

if (code2 === -1) {
throw new Exception_1.default(Exception_1.default.WriterException);
throw new WriterException_1.default();
}

@@ -517,3 +517,3 @@ // Encode two alphanumeric letters in 11 bits.

catch (uee /*: UnsupportedEncodingException*/) {
throw new Exception_1.default(Exception_1.default.WriterException, uee);
throw new WriterException_1.default(uee);
}

@@ -525,2 +525,5 @@ for (var i = 0, length_2 = bytes.length; i !== length_2; i++) {

};
/**
* @throws WriterException
*/
Encoder.appendKanjiBytes = function (content, bits) {

@@ -532,3 +535,3 @@ var bytes;

catch (uee /*: UnsupportedEncodingException*/) {
throw new Exception_1.default(Exception_1.default.WriterException, uee);
throw new WriterException_1.default(uee);
}

@@ -548,3 +551,3 @@ var length = bytes.length;

if (subtracted === -1) {
throw new Exception_1.default(Exception_1.default.WriterException, 'Invalid byte sequence');
throw new WriterException_1.default('Invalid byte sequence');
}

@@ -551,0 +554,0 @@ var encoded = ((subtracted >> 8) * 0xc0) + (subtracted & 0xff);

@@ -30,4 +30,4 @@ import ByteMatrix from './ByteMatrix';

static applyMaskPenaltyRule3(matrix: ByteMatrix): number;
private static isWhiteHorizontal(rowArray, from, to);
private static isWhiteVertical(array, col, from, to);
private static isWhiteHorizontal;
private static isWhiteVertical;
/**

@@ -47,3 +47,3 @@ * Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give

*/
private static applyMaskPenaltyRule1Internal(matrix, isHorizontal);
private static applyMaskPenaltyRule1Internal;
}

@@ -18,3 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var Exception_1 = require("./../../Exception");
var IllegalArgumentException_1 = require("../../IllegalArgumentException");
/**

@@ -173,3 +173,3 @@ * @author Satoru Takabayashi

default:
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Invalid mask pattern: ' + maskPattern);
throw new IllegalArgumentException_1.default('Invalid mask pattern: ' + maskPattern);
}

@@ -176,0 +176,0 @@ return intermediate === 0;

@@ -28,11 +28,11 @@ import BitArray from './../../common/BitArray';

static makeVersionInfoBits(version: Version, bits: BitArray): void;
private static isEmpty(value);
private static embedTimingPatterns(matrix);
private static embedDarkDotAtLeftBottomCorner(matrix);
private static embedHorizontalSeparationPattern(xStart, yStart, matrix);
private static embedVerticalSeparationPattern(xStart, yStart, matrix);
private static embedPositionAdjustmentPattern(xStart, yStart, matrix);
private static embedPositionDetectionPattern(xStart, yStart, matrix);
private static embedPositionDetectionPatternsAndSeparators(matrix);
private static maybeEmbedPositionAdjustmentPatterns(version, matrix);
private static isEmpty;
private static embedTimingPatterns;
private static embedDarkDotAtLeftBottomCorner;
private static embedHorizontalSeparationPattern;
private static embedVerticalSeparationPattern;
private static embedPositionAdjustmentPattern;
private static embedPositionDetectionPattern;
private static embedPositionDetectionPatternsAndSeparators;
private static maybeEmbedPositionAdjustmentPatterns;
}

@@ -20,6 +20,7 @@ "use strict";

var BitArray_1 = require("./../../common/BitArray");
var Exception_1 = require("./../../Exception");
var Integer_1 = require("./../../util/Integer");
var QRCode_1 = require("./QRCode");
var MaskUtil_1 = require("./MaskUtil");
var WriterException_1 = require("../../WriterException");
var IllegalArgumentException_1 = require("../../IllegalArgumentException");
/**

@@ -99,3 +100,3 @@ * @author satorux@google.com (Satoru Takabayashi) - creator

MatrixUtil.maybeEmbedVersionInfo = function (version, matrix) {
if (version.getVersionNumber() < 7) {
if (version.getVersionNumber() < 7) { // Version info is necessary if version >= 7.
return; // Don't need version info.

@@ -163,3 +164,3 @@ }

if (bitIndex !== dataBits.getSize()) {
throw new Exception_1.default(Exception_1.default.WriterException, 'Not all bits consumed: ' + bitIndex + '/' + dataBits.getSize());
throw new WriterException_1.default('Not all bits consumed: ' + bitIndex + '/' + dataBits.getSize());
}

@@ -202,3 +203,3 @@ };

if (poly === 0) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, '0 polynomial');
throw new IllegalArgumentException_1.default('0 polynomial');
}

@@ -221,3 +222,3 @@ // If poly is "1 1111 0010 0101" (version info poly), msbSetInPoly is 13. We'll subtract 1

if (!QRCode_1.default.isValidMaskPattern(maskPattern)) {
throw new Exception_1.default(Exception_1.default.WriterException, 'Invalid mask pattern');
throw new WriterException_1.default('Invalid mask pattern');
}

@@ -231,4 +232,4 @@ var typeInfo = (ecLevel.getBits() << 3) | maskPattern;

bits.xor(maskBits);
if (bits.getSize() !== 15) {
throw new Exception_1.default(Exception_1.default.WriterException, 'should not happen but we got: ' + bits.getSize());
if (bits.getSize() !== 15) { // Just in case.
throw new WriterException_1.default('should not happen but we got: ' + bits.getSize());
}

@@ -242,4 +243,4 @@ };

bits.appendBits(bchCode, 12);
if (bits.getSize() !== 18) {
throw new Exception_1.default(Exception_1.default.WriterException, 'should not happen but we got: ' + bits.getSize());
if (bits.getSize() !== 18) { // Just in case.
throw new WriterException_1.default('should not happen but we got: ' + bits.getSize());
}

@@ -269,3 +270,3 @@ };

if (matrix.get(8, matrix.getHeight() - 8) === 0) {
throw new Exception_1.default(Exception_1.default.WriterException);
throw new WriterException_1.default();
}

@@ -277,3 +278,3 @@ matrix.setNumber(8, matrix.getHeight() - 8, 1);

if (!MatrixUtil.isEmpty(matrix.get(xStart + x, yStart))) {
throw new Exception_1.default(Exception_1.default.WriterException);
throw new WriterException_1.default();
}

@@ -286,3 +287,3 @@ matrix.setNumber(xStart + x, yStart, 0);

if (!MatrixUtil.isEmpty(matrix.get(xStart, yStart + y))) {
throw new Exception_1.default(Exception_1.default.WriterException);
throw new WriterException_1.default();
}

@@ -337,3 +338,3 @@ matrix.setNumber(xStart, yStart + y, 0);

MatrixUtil.maybeEmbedPositionAdjustmentPatterns = function (version, matrix) {
if (version.getVersionNumber() < 2) {
if (version.getVersionNumber() < 2) { // The patterns appear if version >= 2
return;

@@ -340,0 +341,0 @@ }

@@ -33,4 +33,4 @@ import BinaryBitmap from './../BinaryBitmap';

*/
private static extractPureBits(image);
private static moduleSize(leftTopBlack, image);
private static extractPureBits;
private static moduleSize;
}

@@ -24,3 +24,3 @@ "use strict";

var Detector_1 = require("./detector/Detector");
var Exception_1 = require("./../Exception");
var NotFoundException_1 = require("../NotFoundException");
/*import java.util.List;*/

@@ -101,3 +101,3 @@ /*import java.util.Map;*/

if (leftTopBlack === null || rightBottomBlack === null) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -111,3 +111,3 @@ var moduleSize = this.moduleSize(leftTopBlack, image);

if (left >= right || top >= bottom) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -120,3 +120,3 @@ if (bottom - top !== right - left) {

// Abort if that would not make sense -- off image
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -127,7 +127,7 @@ }

if (matrixWidth <= 0 || matrixHeight <= 0) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}
if (matrixHeight !== matrixWidth) {
// Only possibly decode square regions
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -137,3 +137,3 @@ // Push in the "border" by half the module width so that we start

// little off, this will help recover.
var nudge = Math.floor(moduleSize / 2.0);
var nudge = /*(int) */ Math.floor(moduleSize / 2.0);
top += nudge;

@@ -148,3 +148,3 @@ left += nudge;

// Neither way fits; abort
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -158,3 +158,3 @@ left -= nudgedTooFarRight;

// Neither way fits; abort
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -193,3 +193,3 @@ top -= nudgedTooFarDown;

if (x === width || y === height) {
throw new Exception_1.default(Exception_1.default.NotFoundException);
throw new NotFoundException_1.default();
}

@@ -196,0 +196,0 @@ return (x - leftTopBlack[0]) / 7.0;

@@ -13,3 +13,3 @@ import BarcodeFormat from './../BarcodeFormat';

encode(contents: string, format: BarcodeFormat, width: number, height: number, hints: Map<EncodeHintType, any>): BitMatrix;
private static renderResult(code, width, height, quietZone);
private static renderResult;
}

@@ -22,3 +22,4 @@ "use strict";

var Encoder_1 = require("./encoder/Encoder");
var Exception_1 = require("./../Exception");
var IllegalArgumentException_1 = require("../IllegalArgumentException");
var IllegalStateException_1 = require("../IllegalStateException");
/*import java.util.Map;*/

@@ -41,10 +42,9 @@ /**

if (contents.length === 0) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Found empty contents');
throw new IllegalArgumentException_1.default('Found empty contents');
}
if (format !== 11 /* QR_CODE */) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Can only encode QR_CODE, but got ' + format);
throw new IllegalArgumentException_1.default('Can only encode QR_CODE, but got ' + format);
}
if (width < 0 || height < 0) {
throw new Exception_1.default('IllegalArgumentException', 'Requested dimensions are too small: ' + width + 'x' +
height);
throw new IllegalArgumentException_1.default("Requested dimensions are too small: " + width + "x" + height);
}

@@ -69,3 +69,3 @@ var errorCorrectionLevel = ErrorCorrectionLevel_1.default.L;

if (input === null) {
throw new Exception_1.default(Exception_1.default.IllegalStateException);
throw new IllegalStateException_1.default();
}

@@ -72,0 +72,0 @@ var inputWidth = input.getWidth();

@@ -46,6 +46,6 @@ "use strict";

this.rawBytes = rawBytes;
this.numBits = numBits; /*int*/
this.numBits = numBits;
this.resultPoints = resultPoints;
this.format = format;
this.timestamp = timestamp; /*long*/
this.timestamp = timestamp;
this.text = text;

@@ -52,0 +52,0 @@ this.rawBytes = rawBytes;

@@ -66,4 +66,4 @@ /**

*/
STRUCTURED_APPEND_PARITY = 10,
STRUCTURED_APPEND_PARITY = 10
}
export default ResultMetadataType;

@@ -32,3 +32,3 @@ /**

*/
private static crossProductZ(pointA, pointB, pointC);
private static crossProductZ;
}

@@ -29,4 +29,4 @@ "use strict";

function ResultPoint(x /*float*/, y /*float*/) {
this.x = x; /*float*/
this.y = y; /*float*/
this.x = x;
this.y = y;
}

@@ -33,0 +33,0 @@ ResultPoint.prototype.getX = function () {

@@ -11,6 +11,6 @@ import './InvertedLuminanceSource';

export default class RGBLuminanceSource extends LuminanceSource {
private dataWidth;
private dataHeight;
private left;
private top;
private dataWidth?;
private dataHeight?;
private left?;
private top?;
private luminances;

@@ -17,0 +17,0 @@ constructor(luminances: Uint8ClampedArray | Int32Array, width: number, height: number, dataWidth?: number, dataHeight?: number, left?: number, top?: number);

@@ -32,4 +32,4 @@ "use strict";

var LuminanceSource_1 = require("./LuminanceSource");
var Exception_1 = require("./Exception");
var System_1 = require("./util/System");
var IllegalArgumentException_1 = require("./IllegalArgumentException");
/**

@@ -46,7 +46,7 @@ * This class is used to help decode images from files which arrive as RGB data from

var _this = _super.call(this, width, height) || this;
_this.dataWidth = dataWidth; /*int*/
_this.dataHeight = dataHeight; /*int*/
_this.left = left; /*int*/
_this.top = top; /*int*/
if (luminances.BYTES_PER_ELEMENT === 4) {
_this.dataWidth = dataWidth;
_this.dataHeight = dataHeight;
_this.left = left;
_this.top = top;
if (luminances.BYTES_PER_ELEMENT === 4) { // Int32Array
var size = width * height;

@@ -80,3 +80,3 @@ var luminancesUint8Array = new Uint8ClampedArray(size);

if (_this.left + width > _this.dataWidth || _this.top + height > _this.dataHeight) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Crop rectangle does not fit within image data.');
throw new IllegalArgumentException_1.default('Crop rectangle does not fit within image data.');
}

@@ -88,3 +88,3 @@ return _this;

if (y < 0 || y >= this.getHeight()) {
throw new Exception_1.default(Exception_1.default.IllegalArgumentException, 'Requested row is outside the image: ' + y);
throw new IllegalArgumentException_1.default('Requested row is outside the image: ' + y);
}

@@ -91,0 +91,0 @@ var width = this.getWidth();

@@ -10,2 +10,3 @@ export default class StringBuilder {

toString(): string;
insert(n: number, c: string): void;
}

@@ -32,2 +32,5 @@ "use strict";

};
StringBuilder.prototype.insert = function (n, c) {
this.value = this.value.substr(0, n) + c + this.value.substr(n + c.length);
};
return StringBuilder;

@@ -34,0 +37,0 @@ }());

import CharacterSetECI from './../common/CharacterSetECI';
/**
* Responsible for en/decoding strings.
*/
export default class StringEncoding {
/**
* Decodes some Uint8Array to a string format.
*/
static decode(bytes: Uint8Array, encoding: string | CharacterSetECI): string;
/**
* Encodes some string into a Uint8Array.
*
* @todo natively support other string formats than UTF-8.
*/
static encode(s: string, encoding: string | CharacterSetECI): Uint8Array;
private static isBrowser();
private static decodeFallBack(bytes, encoding);
private static encodeFallBack(s, encoding);
private static isBrowser;
/**
* Returns the string value from some encoding character set.
*/
static encodingName(encoding: string | CharacterSetECI): string;
/**
* Returns character set from some encoding character set.
*/
static encodingCharacterSet(encoding: string | CharacterSetECI): CharacterSetECI;
/**
* Runs a fallback for the native decoding funcion.
*/
private static decodeFallback;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var text_encoding_1 = require("text-encoding");
var CharacterSetECI_1 = require("./../common/CharacterSetECI");
var Exception_1 = require("./../Exception");
var UnsupportedOperationException_1 = require("../UnsupportedOperationException");
/**
* Responsible for en/decoding strings.
*/
var StringEncoding = /** @class */ (function () {
function StringEncoding() {
}
/**
* Decodes some Uint8Array to a string format.
*/
StringEncoding.decode = function (bytes, encoding) {
var encodingString;
if (typeof encoding === 'string') {
encodingString = encoding;
var encodingName = this.encodingName(encoding);
// Node.js environment fallback.
if (!StringEncoding.isBrowser()) {
return new text_encoding_1.TextDecoder(encodingName).decode(bytes);
}
else {
encodingString = encoding.getName();
// TextDecoder not available
if (typeof TextDecoder === 'undefined') {
return this.decodeFallback(bytes, encodingName);
}
if (StringEncoding.isBrowser()) {
// tslint:disable-next-line:no-string-literal
var TextDecoderBrowser = window['TextDecoder'];
// use TextEncoder if is available (should be in newer browsers)
if (undefined !== TextDecoderBrowser) {
// console.log(TextDecoderBrowser)
return new TextDecoderBrowser(encoding).decode(bytes);
}
else {
// fall back to minimal decoding
return StringEncoding.decodeFallBack(bytes, encodingString);
}
}
else {
var TextDecoderFromTEClass = require('text-encoding').TextDecoder;
return new TextDecoderFromTEClass(encodingString).decode(bytes);
}
return new TextDecoder(encodingName).decode(bytes);
};
/**
* Encodes some string into a Uint8Array.
*
* @todo natively support other string formats than UTF-8.
*/
StringEncoding.encode = function (s, encoding) {
var encodingString;
if (typeof encoding === 'string') {
encodingString = encoding;
// Uses `text-encoding` package.
if (!StringEncoding.isBrowser()) {
return new text_encoding_1.TextEncoder(this.encodingName(encoding), { NONSTANDARD_allowLegacyEncoding: true }).encode(s);
}
else {
encodingString = encoding.getName();
}
if (StringEncoding.isBrowser()) {
// tslint:disable-next-line:no-string-literal
var TextEncoderBrowser = window['TextEncoder'];
// use TextEncoder if is available (should be in newer browsers)
var ec = CharacterSetECI_1.default.getCharacterSetECIByName(encodingString);
if (undefined !== TextEncoderBrowser) {
// TODO: TextEncoder only supports utf-8 encoding as per specs
return new TextEncoderBrowser(encoding).encode(s);
}
else {
// fall back to minimal decoding
return StringEncoding.encodeFallBack(s, encodingString);
}
}
else {
// Note: NONSTANDARD_allowLegacyEncoding is required for other encodings than UTF8
// TextEncoder only encodes to UTF8 by default as specified by encoding.spec.whatwg.org
var TextEncoderFromTEClass = require('text-encoding').TextEncoder;
return new TextEncoderFromTEClass(encodingString, { NONSTANDARD_allowLegacyEncoding: true }).encode(s);
}
// TextEncoder only encodes to UTF8 by default as specified by encoding.spec.whatwg.org
return new TextEncoder().encode(s);
};

@@ -66,7 +43,24 @@ StringEncoding.isBrowser = function () {

};
StringEncoding.decodeFallBack = function (bytes, encoding) {
var ec = CharacterSetECI_1.default.getCharacterSetECIByName(encoding);
if (ec.equals(CharacterSetECI_1.default.UTF8) ||
ec.equals(CharacterSetECI_1.default.ISO8859_1) ||
ec.equals(CharacterSetECI_1.default.ASCII)) {
/**
* Returns the string value from some encoding character set.
*/
StringEncoding.encodingName = function (encoding) {
return typeof encoding === 'string'
? encoding
: encoding.getName();
};
/**
* Returns character set from some encoding character set.
*/
StringEncoding.encodingCharacterSet = function (encoding) {
return CharacterSetECI_1.default.getCharacterSetECIByName(this.encodingName(encoding));
};
/**
* Runs a fallback for the native decoding funcion.
*/
StringEncoding.decodeFallback = function (bytes, encoding) {
var characterSet = this.encodingCharacterSet(encoding);
if (characterSet.equals(CharacterSetECI_1.default.UTF8) ||
characterSet.equals(CharacterSetECI_1.default.ISO8859_1) ||
characterSet.equals(CharacterSetECI_1.default.ASCII)) {
var s = '';

@@ -82,13 +76,7 @@ for (var i = 0, length_1 = bytes.length; i < length_1; i++) {

}
else if (ec.equals(CharacterSetECI_1.default.UnicodeBigUnmarked)) {
if (characterSet.equals(CharacterSetECI_1.default.UnicodeBigUnmarked)) {
return String.fromCharCode.apply(null, new Uint16Array(bytes.buffer));
}
else {
throw new Exception_1.default(Exception_1.default.UnsupportedOperationException, "encoding " + encoding + " not supported");
}
throw new UnsupportedOperationException_1.default("Encoding " + this.encodingName(encoding) + " not supported by fallback.");
};
StringEncoding.encodeFallBack = function (s, encoding) {
// TODO: encode
return null;
};
return StringEncoding;

@@ -95,0 +83,0 @@ }());

export default class System {
/**
* Makes a copy of a array.
*/
static arraycopy(src: any, srcPos: number, dest: any, destPos: number, length: number): void;
/**
* Returns the current time in milliseconds.
*/
static currentTimeMillis(): number;
}

@@ -7,11 +7,14 @@ "use strict";

// public static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
/**
* Makes a copy of a array.
*/
System.arraycopy = function (src, srcPos, dest, destPos, length) {
// TODO: better use split or set?
var i = srcPos;
var j = destPos;
var c = length;
while (c--) {
dest[j++] = src[i++];
while (length--) {
dest[destPos++] = src[srcPos++];
}
};
/**
* Returns the current time in milliseconds.
*/
System.currentTimeMillis = function () {

@@ -18,0 +21,0 @@ return Date.now();

@@ -1,6 +0,7 @@

export { default as BrowserCodeReader } from './browser/BrowserCodeReader';
export * from './browser/BrowserCodeReader';
export * from './browser/BrowserQRCodeReader';
export * from './browser/BrowserDatamatrixCodeReader';
export * from './browser/BrowserQRCodeSvgWriter';
export { default as HTMLCanvasElementLuminanceSource } from './browser/HTMLCanvasElementLuminanceSource';
export { default as VideoInputDevice } from './browser/VideoInputDevice';
export * from './browser/HTMLCanvasElementLuminanceSource';
export * from './browser/VideoInputDevice';
export * from './browser/BrowserBarcodeReader';

@@ -45,3 +46,4 @@ export { default as BarcodeFormat } from './core/BarcodeFormat';

export { default as OneDReader } from './core/oned/OneDReader';
export { default as EAN13Reader } from './core/oned/EAN13Reader';
export { default as Code128Reader } from './core/oned/Code128Reader';
export { default as ITFReader } from './core/oned/ITFReader';

@@ -7,10 +7,8 @@ "use strict";

// browser
var BrowserCodeReader_1 = require("./browser/BrowserCodeReader");
exports.BrowserCodeReader = BrowserCodeReader_1.default;
__export(require("./browser/BrowserCodeReader"));
__export(require("./browser/BrowserQRCodeReader"));
__export(require("./browser/BrowserDatamatrixCodeReader"));
__export(require("./browser/BrowserQRCodeSvgWriter"));
var HTMLCanvasElementLuminanceSource_1 = require("./browser/HTMLCanvasElementLuminanceSource");
exports.HTMLCanvasElementLuminanceSource = HTMLCanvasElementLuminanceSource_1.default;
var VideoInputDevice_1 = require("./browser/VideoInputDevice");
exports.VideoInputDevice = VideoInputDevice_1.default;
__export(require("./browser/HTMLCanvasElementLuminanceSource"));
__export(require("./browser/VideoInputDevice"));
__export(require("./browser/BrowserBarcodeReader"));

@@ -81,3 +79,3 @@ var Binarizer_1 = require("./core/Binarizer");

exports.ReedSolomonEncoder = ReedSolomonEncoder_1.default;
// core/qrcode
// core/twod/qrcode
var QRCodeReader_1 = require("./core/qrcode/QRCodeReader");

@@ -90,2 +88,4 @@ exports.QRCodeReader = QRCodeReader_1.default;

exports.OneDReader = OneDReader_1.default;
var EAN13Reader_1 = require("./core/oned/EAN13Reader");
exports.EAN13Reader = EAN13Reader_1.default;
var Code128Reader_1 = require("./core/oned/Code128Reader");

@@ -92,0 +92,0 @@ exports.Code128Reader = Code128Reader_1.default;

{
"name": "@zxing/library",
"version": "0.5.1",
"version": "0.6.0-beta.0",
"description": "TypeScript port of ZXing multi-format 1D/2D barcode image processing library, with Code128 and ITF support.",

@@ -46,18 +46,32 @@ "keywords": [

"private": false,
"main": "./bundles/library.js",
"es2015": "./bundles/library.min.js",
"main": "./umd/index.js",
"module": "./esm5/index.js",
"typings": "./esm5/index.d.ts",
"nyc": {
"include": [
"src/**/*.ts"
],
"sourceMap": false,
"instrument": false
},
"scripts": {
"clean": "shx rm -rf bundles esm5",
"build": "yarn clean && tsc && tsc --target es5 --outDir esm5 && webpack && webpack --env.prod",
"test": "mocha-webpack --webpack-config webpack.config.test.js src/test.js --timeout 20000",
"lint": "tslint src/**/*.ts"
"lint": "yarn tslint src/**/*.ts",
"clean": "yarn shx rm -rf umd esm5",
"test": "yarn mocha-webpack \"./src/**/*.spec.ts\" --timeout 200000 --webpack-config webpack.config.test.js",
"cover": "yarn nyc --reporter=lcov --reporter=text yarn test",
"build": "yarn clean && yarn tsc && yarn webpack --mode production",
"shx": "./node_modules/.bin/shx",
"tsc": "./node_modules/.bin/tsc",
"tslint": "./node_modules/.bin/tslint",
"mocha-webpack": "./node_modules/.bin/mocha-webpack",
"nyc": "./node_modules/.bin/nyc",
"webpack": "./node_modules/.bin/webpack-cli"
},
"dependencies": {
"sharp": "^0.20.0",
"ts-custom-error": "^2.2.1"
},
"optionalDependencies": {
"text-encoding": "^0.6.4"
},
"devDependencies": {
"@types/async": "^2.0.47",
"@types/chai": "^4.1.2",

@@ -67,9 +81,9 @@ "@types/mocha": "^2.2.48",

"@types/seedrandom": "^2.4.27",
"@types/sharp": "^0.17.7",
"@types/text-encoding": "^0.0.32",
"async": "^2.6.0",
"@types/sharp": "^0.17.8",
"@types/text-encoding": "0.0.33",
"awesome-typescript-loader": "^3.1.3",
"chai": "^4.1.2",
"codacy-coverage": "^3.0.0",
"eslint": "^4.19.1",
"jasmine": "^3.0.0",
"istanbul-instrumenter-loader": "^3.0.1",
"karma": "^2.0.0",

@@ -79,6 +93,3 @@ "karma-chai": "^0.1.0",

"karma-coverage": "^1.1.2",
"karma-jasmine": "^1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "^1.0.4",
"karma-remap-coverage": "^0.1.5",

@@ -89,16 +100,18 @@ "karma-sinon": "^1.0.5",

"karma-typescript-preprocessor": "^0.3.1",
"karma-typescript-preprocessor2": "^1.2.1",
"karma-webpack": "^2.0.9",
"mocha": "4.1.0",
"mocha-webpack": "^0.7.0",
"phantomjs-prebuilt": "^2.1.16",
"mocha": "^5.2.0",
"mocha-lcov-reporter": "^1.3.0",
"mocha-webpack": "^2.0.0-beta.0",
"nyc": "^12.0.2",
"seedrandom": "^2.4.3",
"sharp": "^0.20.3",
"shx": "0.2.2",
"sinon": "^4.2.2",
"ts-loader": "^3.5.0",
"ts-loader": "^4.3.1",
"tslint": "^5.10.0",
"typescript": "~2.7.1",
"typescript": "^2.8",
"uglify-js": "^3.3.25",
"uglifyjs-webpack-plugin": "^1.1.8",
"webpack": "^3.12.0",
"webpack": "^4.11.1",
"webpack-cli": "^3.0.3",
"webpack-config-utils": "2.3.0",

@@ -105,0 +118,0 @@ "webpack-node-externals": "^1.6.0"

@@ -17,11 +17,11 @@ [<img align="right" src="https://raw.github.com/wiki/zxing/zxing/zxing-logo.png"/>][1]

| 1D product | 1D industrial | 2D
| ---------------------- | -------------------- | --------------
| ~UPC-A~ | ~Code 39~ | QR Code
| ~UPC-E~ | ~Code 93~ | Data Matrix (_in-progress_)
| ~EAN-8~ | Code 128 (_no docs_) | ~Aztec (beta)~
| EAN-13 (_in-progress_) | ~Codabar~ | PDF 417 (_in-progress_)
| | ITF (_no docs_) | ~MaxiCode~
| | ~RSS-14~ |
| | ~RSS-Expanded~ |
| 1D product | 1D industrial | 2D
| ------------------ | -------------------- | --------------
| ~UPC-A~ | ~Code 39~ | QR Code
| ~UPC-E~ | ~Code 93~ | Data Matrix (_no docs_)
| ~EAN-8~ | Code 128 (_no docs_) | ~Aztec (beta)~
| EAN-13 (_no docs_) | ~Codabar~ | PDF 417 (_in-progress_)
| | ITF (_no docs_) | ~MaxiCode~
| | ~RSS-14~ |
| | ~RSS-Expanded~ |

@@ -216,10 +216,2 @@ ## Status

### Text Encoding and Decoding
To decode a barcode, the library needs at some point to decode from bits to text. Also, to generate a barcode it needs to encode text to bits. Unfortunately, the state of encoding and decoding text in ECMAScript/browser is somehow messy at the moment.
To have full support for all encodings in [CharacterSetECI](https://github.com/zxing-js/library/blob/master/src/core/common/CharacterSetECI.ts) *except Cp437* use [text-encoding](https://github.com/inexorabletash/text-encoding) library. The library is used implicitly for node (and tests), but is an optional dependency for browser because is rather large (> 600k). You will need to include it yourself if you want/need to use it. The `text-encoding` library will be removed as soon as this library starts to run on TypeScript 2.8.
By default, in browser, [TextDecoder](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder)/[TextEncoder](https://developer.mozilla.org/ro/docs/Web/API/TextEncoder) web API are used if available (take care as these are labeled as experimental as of this writing). Also, be aware that TextEncoder encodes only to UTF-8 as per spec. If these are not available the library falls back to a minimal implementation that only encodes and decodes to/from UTF-8 (see [`StringEncoding`](https://github.com/zxing-js/library/blob/master/src/core/util/StringEncoding.ts)).
### Porting Information

@@ -226,0 +218,0 @@

@@ -5,6 +5,9 @@ import Reader from './../core/Reader';

import Result from './../core/Result';
import Exception from './../core/Exception';
import NotFoundException from '../core/NotFoundException';
import ArgumentException from '../core/ArgumentException';
import HTMLCanvasElementLuminanceSource from './HTMLCanvasElementLuminanceSource';
import VideoInputDevice from './VideoInputDevice';
import DecodeHintType from '../core/DecodeHintType';
import ChecksumException from '../core/ChecksumException';
import FormatException from '../core/FormatException';

@@ -128,3 +131,3 @@ /**

me.stop();
reject(new Exception(Exception.NotFoundException));
reject(new NotFoundException());
};

@@ -163,7 +166,7 @@ me.videoElement.addEventListener('ended', me.videoPlayEndedEventListener);

if (null === mediaElement) {
throw new Exception(Exception.ArgumentException, `element with id '${mediaElementId}' not found`);
throw new ArgumentException(`element with id '${mediaElementId}' not found`);
}
if (mediaElement.nodeName.toLowerCase() !== type.toLowerCase()) {
console.log(mediaElement.nodeName);
throw new Exception(Exception.ArgumentException, `element with id '${mediaElementId}' must be an ${type} element`);
throw new ArgumentException(`element with id '${mediaElementId}' must be an ${type} element`);
}

@@ -186,3 +189,3 @@ return mediaElement;

if (undefined === imageElement && undefined === imageUrl) {
throw new Exception(Exception.ArgumentException, 'either imageElement with a src set or an url must be provided');
throw new ArgumentException('either imageElement with a src set or an url must be provided');
}

@@ -204,3 +207,3 @@

} else {
throw new Exception(Exception.ArgumentException, `either src or a loaded img should be provided`);
throw new ArgumentException(`either src or a loaded img should be provided`);
}

@@ -251,3 +254,3 @@ });

this.canvasElementContext.drawImage(this.videoElement || this.imageElement, 0, 0);
this.drawImageOnCanvas(this.canvasElementContext, this.videoElement || this.imageElement);

@@ -261,6 +264,6 @@ const luminanceSource = new HTMLCanvasElementLuminanceSource(this.canvasElement);

console.log(retryIfChecksumOrFormatError, re);
if (retryIfNotFound && Exception.isOfType(re, Exception.NotFoundException)) {
if (retryIfNotFound && re instanceof NotFoundException) {
console.log('not found, trying again...');
this.decodeOnceWithDelay(resolve, reject);
} else if (retryIfChecksumOrFormatError && (Exception.isOfType(re, Exception.ChecksumException) || Exception.isOfType(re, Exception.FormatException))) {
} else if (retryIfChecksumOrFormatError && (re instanceof ChecksumException || re instanceof FormatException)) {
console.log('checksum or format error, trying again...', re);

@@ -274,2 +277,9 @@ this.decodeOnceWithDelay(resolve, reject);

/**
* This will remain protected, so who extends this class can customize this method.
*/
protected drawImageOnCanvas(canvasElementContext: CanvasRenderingContext2D, srcElement: HTMLVideoElement | HTMLImageElement) {
canvasElementContext.drawImage(srcElement, 0, 0);
}
protected readerDecode(binaryBitmap: BinaryBitmap): Result {

@@ -276,0 +286,0 @@ return this.reader.decode(binaryBitmap, this.hints);

@@ -1,2 +0,1 @@

import Exception from '../core/Exception';
import EncodeHintType from '../core/EncodeHintType';

@@ -6,2 +5,4 @@ import Encoder from '../core/qrcode/encoder/Encoder';

import ErrorCorrectionLevel from '../core/qrcode/decoder/ErrorCorrectionLevel';
import IllegalArgumentException from '../core/IllegalArgumentException';
import IllegalStateException from '../core/IllegalStateException';

@@ -40,14 +41,11 @@ class BrowserQRCodeSvgWriter {

if (contents.length === 0) {
throw new Exception(Exception.IllegalArgumentException, 'Found empty contents');
throw new IllegalArgumentException('Found empty contents');
}
// if (format != BarcodeFormat.QR_CODE) {
// throw new Exception(Exception.IllegalArgumentException, "Can only encode QR_CODE, but got " + format)
// throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format)
// }
if (width < 0 || height < 0) {
throw new Exception(
'IllegalArgumentException',
'Requested dimensions are too small: ' + width + 'x' + height
);
throw new IllegalArgumentException('Requested dimensions are too small: ' + width + 'x' + height);
}

@@ -83,3 +81,3 @@

if (input === null) {
throw new Exception(Exception.IllegalStateException);
throw new IllegalStateException();
}

@@ -86,0 +84,0 @@

import InvertedLuminanceSource from './../core/InvertedLuminanceSource';
import LuminanceSource from './../core/LuminanceSource';
import Exception from './../core/Exception';
import IllegalArgumentException from '../core/IllegalArgumentException';

@@ -52,3 +52,3 @@ export default class HTMLCanvasElementLuminanceSource extends LuminanceSource {

if (y < 0 || y >= this.getHeight()) {
throw new Exception(Exception.IllegalArgumentException, 'Requested row is outside the image: ' + y);
throw new IllegalArgumentException('Requested row is outside the image: ' + y);
}

@@ -55,0 +55,0 @@ const width: number /*int*/ = this.getWidth();

@@ -26,3 +26,2 @@ /*

import Exception from './Exception';
import Binarizer from './Binarizer';

@@ -32,2 +31,3 @@ import BitArray from './common/BitArray';

import LuminanceSource from './LuminanceSource';
import IllegalArgumentException from './IllegalArgumentException';

@@ -39,3 +39,3 @@ export default class BinaryBitmap {

if (binarizer === null) {
throw new Exception(Exception.IllegalArgumentException, 'Binarizer must be non-null.');
throw new IllegalArgumentException('Binarizer must be non-null.');
}

@@ -42,0 +42,0 @@ }

@@ -24,4 +24,5 @@ /*

import Arrays from './../util/Arrays';
import Exception from './../Exception';
import IllegalArgumentException from '../IllegalArgumentException';
/**

@@ -180,3 +181,3 @@ * <p>A simple, fast array of bits, represented compactly by an array of ints internally.</p>

if (end < start || start < 0 || end > this.size) {
throw new Exception(Exception.IllegalArgumentException);
throw new IllegalArgumentException();
}

@@ -221,3 +222,3 @@ if (end === start) {

if (end < start || start < 0 || end > this.size) {
throw new Exception(Exception.IllegalArgumentException);
throw new IllegalArgumentException();
}

@@ -264,3 +265,3 @@ if (end === start) {

if (numBits < 0 || numBits > 32) {
throw new Exception(Exception.IllegalArgumentException, 'Num bits must be between 0 and 32');
throw new IllegalArgumentException('Num bits must be between 0 and 32');
}

@@ -285,3 +286,3 @@ this.ensureCapacity(this.size + numBits);

if (this.size !== other.size) {
throw new Exception(Exception.IllegalArgumentException, 'Sizes don\'t match');
throw new IllegalArgumentException('Sizes don\'t match');
}

@@ -288,0 +289,0 @@ const bits = this.bits;

@@ -20,3 +20,3 @@ /*

/*import java.util.Arrays;*/
import Exception from './../Exception';
import BitArray from './BitArray';

@@ -26,2 +26,3 @@ import System from './../util/System';

import StringBuilder from './../util/StringBuilder';
import IllegalArgumentException from '../IllegalArgumentException';

@@ -62,3 +63,3 @@ /**

// if (width < 1 || height < 1) {
// throw new Exception(Exception.IllegalArgumentException, "Both dimensions must be greater than 0")
// throw new IllegalArgumentException("Both dimensions must be greater than 0")
// }

@@ -78,3 +79,3 @@ // this.width = width

if (width < 1 || height < 1) {
throw new Exception(Exception.IllegalArgumentException, 'Both dimensions must be greater than 0');
throw new IllegalArgumentException('Both dimensions must be greater than 0');
}

@@ -113,3 +114,3 @@ if (undefined === rowSize || null === rowSize) {

if (stringRepresentation === null) {
throw new Exception(Exception.IllegalArgumentException, 'stringRepresentation cannot be null');
throw new IllegalArgumentException('stringRepresentation cannot be null');
}

@@ -130,3 +131,3 @@

} else if (bitsPos - rowStartPos !== rowLength) {
throw new Exception(Exception.IllegalArgumentException, 'row lengths do not match');
throw new IllegalArgumentException('row lengths do not match');
}

@@ -146,3 +147,3 @@ rowStartPos = bitsPos;

} else {
throw new Exception(Exception.IllegalArgumentException,
throw new IllegalArgumentException(
'illegal character encountered: ' + stringRepresentation.substring(pos));

@@ -157,3 +158,3 @@ }

} else if (bitsPos - rowStartPos !== rowLength) {
throw new Exception(Exception.IllegalArgumentException, 'row lengths do not match');
throw new IllegalArgumentException('row lengths do not match');
}

@@ -220,3 +221,3 @@ nRows++;

|| this.rowSize !== mask.getRowSize()) {
throw new Exception(Exception.IllegalArgumentException, 'input matrix dimensions do not match');
throw new IllegalArgumentException('input matrix dimensions do not match');
}

@@ -256,6 +257,6 @@ const rowArray = new BitArray(Math.floor(this.width / 32) + 1);

if (top < 0 || left < 0) {
throw new Exception(Exception.IllegalArgumentException, 'Left and top must be nonnegative');
throw new IllegalArgumentException('Left and top must be nonnegative');
}
if (height < 1 || width < 1) {
throw new Exception(Exception.IllegalArgumentException, 'Height and width must be at least 1');
throw new IllegalArgumentException('Height and width must be at least 1');
}

@@ -265,3 +266,3 @@ const right = left + width;

if (bottom > this.height || right > this.width) {
throw new Exception(Exception.IllegalArgumentException, 'The region must fit inside the matrix');
throw new IllegalArgumentException('The region must fit inside the matrix');
}

@@ -268,0 +269,0 @@ const rowSize = this.rowSize;

@@ -19,4 +19,5 @@ /*

import Exception from './../Exception';
import IllegalArgumentException from '../IllegalArgumentException';
/**

@@ -67,3 +68,3 @@ * <p>This provides an easy abstraction to read bits at a time from a sequence of bytes, where the

if (numBits < 1 || numBits > 32 || numBits > this.available()) {
throw new Exception(Exception.IllegalArgumentException, '' + numBits);
throw new IllegalArgumentException('' + numBits);
}

@@ -70,0 +71,0 @@

@@ -19,4 +19,5 @@ /*

import Exception from './../Exception';
import FormatException from '../FormatException';
/*import java.util.HashMap;*/

@@ -219,3 +220,3 @@ /*import java.util.Map;*/

if (value < 0 || value >= 900) {
throw new Exception(Exception.FormatException, 'incorect value');
throw new FormatException('incorect value');
}

@@ -226,3 +227,3 @@

if (undefined === characterSet) {
throw new Exception(Exception.FormatException, 'incorect value');
throw new FormatException('incorect value');
}

@@ -243,3 +244,3 @@

if (undefined === characterSet) {
throw new Exception(Exception.FormatException, 'incorect value');
throw new FormatException('incorect value');
}

@@ -246,0 +247,0 @@

@@ -22,4 +22,5 @@ /*

import PerspectiveTransform from './PerspectiveTransform';
import Exception from './../Exception';
import NotFoundException from '../NotFoundException';
/**

@@ -56,3 +57,3 @@ * @author Sean Owen

if (dimensionX <= 0 || dimensionY <= 0) {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -87,3 +88,3 @@ const bits = new BitMatrix(dimensionX, dimensionY);

// catching and wrapping ArrayIndexOutOfBoundsException.
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -90,0 +91,0 @@ }

@@ -21,4 +21,5 @@ /*

import BitMatrix from './../BitMatrix';
import Exception from './../../Exception';
import MathUtils from './MathUtils';
import NotFoundException from '../../NotFoundException';

@@ -65,8 +66,8 @@ /**

if (undefined === x || null === x) {
x = image.getWidth() / 2;
x = image.getWidth() / 2 | 0;
}
if (undefined === y || null === y) {
y = image.getHeight() / 2;
y = image.getHeight() / 2 | 0;
}
const halfsize = initSize / 2;
const halfsize = initSize / 2 | 0;
this.leftInit = x - halfsize;

@@ -77,3 +78,3 @@ this.rightInit = x + halfsize;

if (this.upInit < 0 || this.leftInit < 0 || this.downInit >= this.height || this.rightInit >= this.width) {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -97,3 +98,2 @@ }

public detect(): Array<ResultPoint> /*throws NotFoundException*/ {
let left = this.leftInit;

@@ -215,3 +215,3 @@ let right = this.rightInit;

if (z == null) {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -226,3 +226,3 @@

if (t == null) {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -237,3 +237,3 @@

if (x == null) {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -248,3 +248,3 @@

if (y == null) {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -255,3 +255,3 @@

} else {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -258,0 +258,0 @@ }

@@ -23,4 +23,5 @@ /*

import BitMatrix from './BitMatrix';
import Exception from './../Exception';
import NotFoundException from '../NotFoundException';
/**

@@ -190,3 +191,3 @@ * This Binarizer implementation uses the old ZXing global histogram approach. It is suitable

if (secondPeak - firstPeak <= numBuckets / 16) {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -193,0 +194,0 @@

@@ -21,4 +21,5 @@ /*

import PerspectiveTransform from './PerspectiveTransform';
import Exception from './../Exception';
import NotFoundException from '../NotFoundException';
/**

@@ -123,3 +124,3 @@ * Implementations of this class can, given locations of finder patterns for a QR code in an

if (x < -1 || x > width || y < -1 || y > height) {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -155,3 +156,3 @@

if (x < -1 || x > width || y < -1 || y > height) {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -158,0 +159,0 @@

@@ -20,4 +20,6 @@ /*

import GenericGFPoly from './GenericGFPoly';
import Exception from './../../Exception';
import Integer from './../../util/Integer';
import IllegalArgumentException from '../../IllegalArgumentException';
import ArithmeticException from '../../ArithmeticException';

@@ -100,3 +102,3 @@ /**

if (degree < 0) {
throw new Exception(Exception.IllegalArgumentException);
throw new IllegalArgumentException();
}

@@ -132,3 +134,3 @@ if (coefficient === 0) {

if (a === 0) {
throw new Exception(Exception.IllegalArgumentException);
throw new IllegalArgumentException();
}

@@ -143,3 +145,3 @@ return this.logTable[a];

if (a === 0) {
throw new Exception(Exception.ArithmeticException);
throw new ArithmeticException();
}

@@ -146,0 +148,0 @@ return this.expTable[this.size - this.logTable[a] - 1];

@@ -20,4 +20,5 @@ /*

import GenericGF from './GenericGF';
import Exception from './../../Exception';
import System from './../../util/System';
import IllegalArgumentException from '../../IllegalArgumentException';

@@ -49,3 +50,3 @@ /**

if (coefficients.length === 0) {
throw new Exception(Exception.IllegalArgumentException);
throw new IllegalArgumentException();
}

@@ -109,3 +110,3 @@ this.field = field;

const coefficients = this.coefficients;
let result;
let result: number;
if (a === 1) {

@@ -131,3 +132,3 @@ // Just the sum of the coefficients

if (!this.field.equals(other.field)) {
throw new Exception(Exception.IllegalArgumentException, 'GenericGFPolys do not have same GenericGF field');
throw new IllegalArgumentException('GenericGFPolys do not have same GenericGF field');
}

@@ -162,3 +163,3 @@ if (this.isZero()) {

if (!this.field.equals(other.field)) {
throw new Exception(Exception.IllegalArgumentException, 'GenericGFPolys do not have same GenericGF field');
throw new IllegalArgumentException('GenericGFPolys do not have same GenericGF field');
}

@@ -203,3 +204,3 @@ if (this.isZero() || other.isZero()) {

if (degree < 0) {
throw new Exception(Exception.IllegalArgumentException);
throw new IllegalArgumentException();
}

@@ -221,6 +222,6 @@ if (coefficient === 0) {

if (!this.field.equals(other.field)) {
throw new Exception(Exception.IllegalArgumentException, 'GenericGFPolys do not have same GenericGF field');
throw new IllegalArgumentException('GenericGFPolys do not have same GenericGF field');
}
if (other.isZero()) {
throw new Exception(Exception.IllegalArgumentException, 'Divide by 0');
throw new IllegalArgumentException('Divide by 0');
}

@@ -227,0 +228,0 @@

@@ -21,4 +21,6 @@ /*

import GenericGFPoly from './GenericGFPoly';
import Exception from './../../Exception';
import ReedSolomonException from '../../ReedSolomonException';
import IllegalStateException from '../../IllegalStateException';
/**

@@ -83,3 +85,3 @@ * <p>Implements Reed-Solomon decoding, as the name implies.</p>

if (position < 0) {
throw new Exception(Exception.ReedSolomonException, 'Bad error location');
throw new ReedSolomonException('Bad error location');
}

@@ -106,3 +108,3 @@ received[position] = GenericGF.addOrSubtract(received[position], errorMagnitudes[i]);

// Run Euclidean algorithm until r's degree is less than R/2
while (r.getDegree() >= R / 2) {
while (r.getDegree() >= (R / 2 | 0)) {
let rLastLast = rLast;

@@ -116,3 +118,3 @@ let tLastLast = tLast;

// Oops, Euclidean algorithm already terminated?
throw new Exception(Exception.ReedSolomonException, 'r_{i-1} was zero');
throw new ReedSolomonException('r_{i-1} was zero');
}

@@ -133,3 +135,3 @@ r = rLastLast;

if (r.getDegree() >= rLast.getDegree()) {
throw new Exception(Exception.IllegalStateException, 'Division algorithm failed to reduce polynomial?');
throw new IllegalStateException('Division algorithm failed to reduce polynomial?');
}

@@ -140,3 +142,3 @@ }

if (sigmaTildeAtZero === 0) {
throw new Exception(Exception.ReedSolomonException, 'sigmaTilde(0) was zero');
throw new ReedSolomonException('sigmaTilde(0) was zero');
}

@@ -166,3 +168,3 @@

if (e !== numErrors) {
throw new Exception(Exception.ReedSolomonException, 'Error locator degree does not match number of roots');
throw new ReedSolomonException('Error locator degree does not match number of roots');
}

@@ -169,0 +171,0 @@ return result;

@@ -24,4 +24,5 @@ /*

import GenericGFPoly from './GenericGFPoly';
import Exception from './../../Exception';
import System from './../../util/System';
import IllegalArgumentException from '../../IllegalArgumentException';

@@ -62,7 +63,7 @@ /**

if (ecBytes === 0) {
throw new Exception(Exception.IllegalArgumentException, 'No error correction bytes');
throw new IllegalArgumentException('No error correction bytes');
}
const dataBytes = toEncode.length - ecBytes;
if (dataBytes <= 0) {
throw new Exception(Exception.IllegalArgumentException, 'No data bytes provided');
throw new IllegalArgumentException('No data bytes provided');
}

@@ -69,0 +70,0 @@ const generator = this.buildGenerator(ecBytes);

@@ -35,6 +35,6 @@ /*

public static GB2312 = 'GB2312';
public static ISO88591 = CharacterSetECI.ISO8859_1.getName(); // "ISO8859_1"
private static EUC_JP = 'EUC_JP';
private static UTF8 = CharacterSetECI.UTF8.getName(); // "UTF8"
private static PLATFORM_DEFAULT_ENCODING = StringUtils.UTF8; // "UTF8"//Charset.defaultCharset().name()
private static ISO88591 = CharacterSetECI.ISO8859_1.getName(); // "ISO8859_1"
private static ASSUME_SHIFT_JIS = false;

@@ -41,0 +41,0 @@ // SHIFT_JIS.equalsIgnoreCase(PLATFORM_DEFAULT_ENCODING) ||

@@ -17,3 +17,3 @@ /*

import Exception from './Exception';
import IllegalArgumentException from './IllegalArgumentException';

@@ -28,3 +28,3 @@ /*namespace com.google.zxing {*/

if (width < 0 || height < 0) {
throw new Exception(Exception.IllegalArgumentException);
throw new IllegalArgumentException();
}

@@ -31,0 +31,0 @@ }

@@ -1,28 +0,17 @@

export default class Exception {
import { CustomError } from 'ts-custom-error';
public static IllegalArgumentException = 'IllegalArgumentException';
public static NotFoundException = 'NotFoundException';
public static ArithmeticException = 'ArithmeticException';
public static FormatException = 'FormatException';
public static ChecksumException = 'ChecksumException';
public static WriterException = 'WriterException';
public static IllegalStateException = 'IllegalStateException';
public static UnsupportedOperationException = 'UnsupportedOperationException';
public static ReedSolomonException = 'ReedSolomonException';
public static ArgumentException = 'ArgumentException';
public static ReaderException = 'ReaderException';
/**
* Custom Error class of type Exception.
*/
export default class Exception extends CustomError {
public constructor(private type: string, private message?: string) { }
public getType(): string {
return this.type;
}
public getMessage(): string | undefined {
return this.message;
}
public static isOfType(ex: any, type: string): boolean {
return ex.type === type;
}
/**
* Allows Exception to be constructed directly
* with some message and prototype definition.
*/
constructor(
public message: string = undefined
) {
super(message);
}
}

@@ -17,5 +17,6 @@ /*

import Exception from './Exception';
import InvertedLuminanceSource from './InvertedLuminanceSource';
import StringBuilder from './util/StringBuilder';
import UnsupportedOperationException from './UnsupportedOperationException';

@@ -93,3 +94,3 @@ /*namespace com.google.zxing {*/

public crop(left: number /*int*/, top: number /*int*/, width: number /*int*/, height: number /*int*/): LuminanceSource {
throw new Exception(Exception.UnsupportedOperationException, 'This luminance source does not support cropping.');
throw new UnsupportedOperationException('This luminance source does not support cropping.');
}

@@ -117,3 +118,3 @@

public rotateCounterClockwise(): LuminanceSource {
throw new Exception(Exception.UnsupportedOperationException, 'This luminance source does not support rotation by 90 degrees.');
throw new UnsupportedOperationException('This luminance source does not support rotation by 90 degrees.');
}

@@ -128,3 +129,3 @@

public rotateCounterClockwise45(): LuminanceSource {
throw new Exception(Exception.UnsupportedOperationException, 'This luminance source does not support rotation by 45 degrees.');
throw new UnsupportedOperationException('This luminance source does not support rotation by 45 degrees.');
}

@@ -131,0 +132,0 @@

@@ -23,4 +23,7 @@ /*

import QRCodeReader from './qrcode/QRCodeReader';
import Exception from './Exception';
import MultiFormatOneDReader from './oned/MultiFormatOneDReader';
import DataMatrixReader from './datamatrix/DataMatrixReader';
import NotFoundException from './NotFoundException';
import ReaderException from './ReaderException';

@@ -49,6 +52,7 @@ /*namespace com.google.zxing {*/

* @return The contents of the image
*
* @throws NotFoundException Any errors which occurred
*/
/*@Override*/
// public decode(image: BinaryBitmap): Result /*throws NotFoundException */ {
// public decode(image: BinaryBitmap): Result {
// setHints(null)

@@ -64,6 +68,7 @@ // return decodeInternal(image)

* @return The contents of the image
*
* @throws NotFoundException Any errors which occurred
*/
/*@Override*/
public decode(image: BinaryBitmap, hints?: Map<DecodeHintType, any>): Result /*throws NotFoundException */ {
public decode(image: BinaryBitmap, hints?: Map<DecodeHintType, any>): Result {
this.setHints(hints);

@@ -79,5 +84,6 @@ return this.decodeInternal(image);

* @return The contents of the image
*
* @throws NotFoundException Any errors which occurred
*/
public decodeWithState(image: BinaryBitmap): Result /*throws NotFoundException */ {
public decodeWithState(image: BinaryBitmap): Result {
// Make sure to set up the default state so we don't crash

@@ -127,5 +133,5 @@ if (this.readers === null || this.readers === undefined) {

}
// if (formats.contains(BarcodeFormat.DATA_MATRIX)) {
// readers.push(new DataMatrixReader())
// }
if (formats.contains(BarcodeFormat.DATA_MATRIX)) {
readers.push(new DataMatrixReader());
}
// if (formats.contains(BarcodeFormat.AZTEC)) {

@@ -151,3 +157,3 @@ // readers.push(new AztecReader())

readers.push(new QRCodeReader());
// readers.push(new DataMatrixReader())
readers.push(new DataMatrixReader());
// readers.push(new AztecReader())

@@ -167,4 +173,3 @@ // readers.push(new PDF417Reader())

if (this.readers !== null) {
for (let i = 0, length = this.readers.length; i !== length; i++) {
const reader = this.readers[i];
for (const reader of this.readers) {
reader.reset();

@@ -175,19 +180,31 @@ }

private decodeInternal(image: BinaryBitmap): Result /*throws NotFoundException */ {
if (this.readers !== null) {
for (let i = 0, length = this.readers.length; i !== length; i++) {
const reader = this.readers[i];
try {
return reader.decode(image, this.hints);
} catch (re/*ReaderException*/) {
// console.log(`Exception ${re.type} ${re.message}`)
if (re.type === 'ReaderException') {
continue;
}
/**
* @throws NotFoundException
*/
private decodeInternal(image: BinaryBitmap): Result {
if (this.readers === null) {
throw new ReaderException('No readers where selected, nothing can be read.');
}
for (const reader of this.readers) {
// console.log(`Trying to decode with ${reader.constructor.name} reader.`);
try {
return reader.decode(image, this.hints);
} catch (ex) {
if (ex instanceof ReaderException) {
continue;
}
// Uncomment for test outputting.
// const extra = !ex.message ? '.' : ` with the message: \n\n\t${ex.message}\n\n`;
// console.error('[decodeInternal]', `Exception of type \`${ex.constructor.name}\` was thrown${extra}`);
}
}
throw new Exception(Exception.NotFoundException);
throw new NotFoundException('No MultiFormat Readers were able to detect the code.');
}
}

@@ -35,4 +35,5 @@ /*

import EncodeHintType from './EncodeHintType';
import Exception from './Exception';
import IllegalArgumentException from './IllegalArgumentException';
/*import java.util.Map;*/

@@ -104,3 +105,3 @@

default:
throw new Exception(Exception.IllegalArgumentException, 'No encoder available for format ' + format);
throw new IllegalArgumentException('No encoder available for format ' + format);
}

@@ -107,0 +108,0 @@ return writer.encode(contents, format, width, height, hints);

@@ -23,3 +23,3 @@ /*

import DecodeHintType from '../DecodeHintType';
import Exception from '../Exception';
import Reader from '../Reader';

@@ -30,2 +30,5 @@ import Result from '../Result';

import OneDReader from './OneDReader';
import NotFoundException from '../NotFoundException';
import FormatException from '../FormatException';
import ChecksumException from '../ChecksumException';

@@ -211,3 +214,3 @@ /**

}
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -231,3 +234,3 @@

} else {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -258,3 +261,3 @@ }

default:
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -312,3 +315,3 @@

case Code128Reader.CODE_START_C:
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -492,3 +495,3 @@

false)) {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -500,3 +503,3 @@

if (checksumTotal % 103 !== lastCode) {
throw new Exception(Exception.ChecksumException);
throw new ChecksumException();
}

@@ -508,3 +511,3 @@

// false positive
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -511,0 +514,0 @@

@@ -22,3 +22,3 @@ /*

import DecodeHintType from '../DecodeHintType';
import Exception from '../Exception';
import Result from '../Result';

@@ -29,2 +29,4 @@ import ResultPoint from '../ResultPoint';

import System from '../util/System';
import FormatException from '../FormatException';
import NotFoundException from '../NotFoundException';

@@ -136,3 +138,3 @@ /**

if (!lengthOK) {
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -255,3 +257,3 @@

// Unable to find the necessary number of quiet zone pixels.
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -273,3 +275,3 @@ }

if (endStart === width) {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -369,3 +371,3 @@

}
throw new Exception (Exception.NotFoundException);
throw new NotFoundException();
}

@@ -404,3 +406,3 @@

} else {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -407,0 +409,0 @@ }

@@ -25,4 +25,6 @@ /*

import BitArray from './../common/BitArray';
import Exception from '../Exception';
import ITFReader from './ITFReader';
import MultiFormatUPCEANReader from './MultiFormatUPCEANReader';
import NotFoundException from '../NotFoundException';

@@ -43,2 +45,5 @@ /**

if (possibleFormats) {
if (possibleFormats.get(BarcodeFormat.EAN_13)) {
this.readers.push(new MultiFormatUPCEANReader(hints));
}
// if (possibleFormats.get(BarcodeFormat.EAN_13) ||

@@ -77,2 +82,3 @@ // possibleFormats.get(BarcodeFormat.UPC_A) ||

// this.readers.push(new Code93Reader());
this.readers.push(new MultiFormatUPCEANReader(hints));
this.readers.push(new Code128Reader());

@@ -100,3 +106,3 @@ this.readers.push(new ITFReader());

throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -103,0 +109,0 @@

@@ -22,3 +22,3 @@ /*

import DecodeHintType from '../DecodeHintType';
import Exception from '../Exception';
import Reader from '../Reader';

@@ -28,2 +28,3 @@ import Result from '../Result';

import ResultPoint from '../ResultPoint';
import NotFoundException from '../NotFoundException';

@@ -75,3 +76,3 @@ /**

} else {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -169,3 +170,3 @@ }

throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -193,3 +194,3 @@

if (start >= end) {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -217,3 +218,3 @@

if (!(counterPosition === numCounters || (counterPosition === numCounters - 1 && i === end))) {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -233,3 +234,3 @@ }

if (numTransitionsLeft >= 0) {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -236,0 +237,0 @@

@@ -20,5 +20,6 @@ /*

import System from './util/System';
import Exception from './Exception';
import LuminanceSource from './LuminanceSource';
import InvertedLuminanceSource from './InvertedLuminanceSource';
import IllegalArgumentException from './IllegalArgumentException';

@@ -50,3 +51,3 @@ /**

if (left + width > dataWidth || top + height > dataHeight) {
throw new Exception(Exception.IllegalArgumentException, 'Crop rectangle does not fit within image data.');
throw new IllegalArgumentException('Crop rectangle does not fit within image data.');
}

@@ -62,3 +63,3 @@

if (y < 0 || y >= this.getHeight()) {
throw new Exception(Exception.IllegalArgumentException, 'Requested row is outside the image: ' + y);
throw new IllegalArgumentException('Requested row is outside the image: ' + y);
}

@@ -65,0 +66,0 @@ const width: number /*int*/ = this.getWidth();

@@ -22,4 +22,5 @@ /*

import FormatInformation from './FormatInformation';
import Exception from './../../Exception';
import DataMask from './DataMask';
import FormatException from '../../FormatException';
/**

@@ -42,3 +43,3 @@ * @author Sean Owen

if (dimension < 21 || (dimension & 0x03) !== 1) {
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -90,3 +91,3 @@ this.bitMatrix = bitMatrix;

}
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -142,3 +143,3 @@

}
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -208,3 +209,3 @@

if (resultOffset !== version.getTotalCodewords()) {
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -211,0 +212,0 @@ return result;

@@ -23,4 +23,5 @@ /*

import ErrorCorrectionLevel from './ErrorCorrectionLevel';
import Exception from './../../Exception';
import IllegalArgumentException from '../../IllegalArgumentException';
/**

@@ -53,3 +54,3 @@ * <p>Encapsulates a block of data within a QR Code. QR Codes may split their data into

if (rawCodewords.length !== version.getTotalCodewords()) {
throw new Exception(Exception.IllegalArgumentException);
throw new IllegalArgumentException();
}

@@ -56,0 +57,0 @@

@@ -27,5 +27,6 @@ /*

import Mode from './Mode';
import Exception from './../../Exception';
import StringBuilder from './../../util/StringBuilder';
import StringEncoding from './../../util/StringEncoding';
import FormatException from '../../FormatException';

@@ -89,3 +90,3 @@ /*import java.io.UnsupportedEncodingException;*/

if (bits.available() < 16) {
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -102,3 +103,3 @@ // sequence number and parity is added later to the result metadata

if (currentCharacterSetECI === null) {
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -133,3 +134,3 @@ break;

default:
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -141,3 +142,3 @@ break;

// from readBits() calls
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -161,3 +162,3 @@

if (count * 13 > bits.available()) {
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -190,3 +191,3 @@

} catch (ignored/*: UnsupportedEncodingException*/) {
throw new Exception(Exception.FormatException, ignored);
throw new FormatException(ignored);
}

@@ -200,3 +201,3 @@ }

if (count * 13 > bits.available()) {
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -229,3 +230,3 @@

} catch (ignored/*: UnsupportedEncodingException*/) {
throw new Exception(Exception.FormatException, ignored);
throw new FormatException(ignored);
}

@@ -242,3 +243,3 @@ }

if (8 * count > bits.available()) {
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -264,3 +265,3 @@

} catch (ignored/*: UnsupportedEncodingException*/) {
throw new Exception(Exception.FormatException, ignored);
throw new FormatException(ignored);
}

@@ -272,3 +273,3 @@ byteSegments.push(readBytes);

if (value >= DecodedBitStreamParser.ALPHANUMERIC_CHARS.length) {
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -286,3 +287,3 @@ return DecodedBitStreamParser.ALPHANUMERIC_CHARS[value];

if (bits.available() < 11) {
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -297,3 +298,3 @@ const nextTwoCharsBits = bits.readBits(11);

if (bits.available() < 6) {
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -326,7 +327,7 @@ result.append(DecodedBitStreamParser.toAlphaNumericChar(bits.readBits(6)));

if (bits.available() < 10) {
throw new Exception(Exception.FormatException);
throw new FormatException();
}
const threeDigitsBits = bits.readBits(10);
if (threeDigitsBits >= 1000) {
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -341,7 +342,7 @@ result.append(DecodedBitStreamParser.toAlphaNumericChar(Math.floor(threeDigitsBits / 100)));

if (bits.available() < 7) {
throw new Exception(Exception.FormatException);
throw new FormatException();
}
const twoDigitsBits = bits.readBits(7);
if (twoDigitsBits >= 100) {
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -353,7 +354,7 @@ result.append(DecodedBitStreamParser.toAlphaNumericChar(Math.floor(twoDigitsBits / 10)));

if (bits.available() < 4) {
throw new Exception(Exception.FormatException);
throw new FormatException();
}
const digitBits = bits.readBits(4);
if (digitBits >= 10) {
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -380,3 +381,3 @@ result.append(DecodedBitStreamParser.toAlphaNumericChar(digitBits));

}
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -383,0 +384,0 @@

@@ -28,4 +28,5 @@ /*

import DecodedBitStreamParser from './DecodedBitStreamParser';
import Exception from './../../Exception';
import ChecksumException from '../../ChecksumException';
/*import java.util.Map;*/

@@ -180,3 +181,3 @@

} catch (ignored/*: ReedSolomonException*/) {
throw new Exception(Exception.ChecksumException);
throw new ChecksumException();
}

@@ -183,0 +184,0 @@ // Copy back into array of bytes -- only need to worry about the bytes that were data

@@ -19,4 +19,6 @@ /*

import Exception from './../../Exception';
import ArgumentException from '../../ArgumentException';
import IllegalArgumentException from '../../IllegalArgumentException';
export const enum ErrorCorrectionLevelValues {

@@ -68,3 +70,3 @@ L,

case 'H': return ErrorCorrectionLevel.H;
default: throw new Exception(Exception.ArgumentException, s + 'not available');
default: throw new ArgumentException(s + 'not available');
}

@@ -90,3 +92,3 @@ }

if (bits < 0 || bits >= ErrorCorrectionLevel.FOR_BITS.size) {
throw new Exception(Exception.IllegalArgumentException);
throw new IllegalArgumentException();
}

@@ -93,0 +95,0 @@ return ErrorCorrectionLevel.FOR_BITS.get(bits);

@@ -19,4 +19,5 @@ /*

import Exception from './../../Exception';
import Version from './Version';
import IllegalArgumentException from '../../IllegalArgumentException';

@@ -73,3 +74,3 @@ export const enum ModeValues {

if (undefined === mode) {
throw new Exception(Exception.IllegalArgumentException);
throw new IllegalArgumentException();
}

@@ -76,0 +77,0 @@ return mode;

@@ -20,3 +20,3 @@ /*

import BitMatrix from './../../common/BitMatrix';
import Exception from './../../Exception';
import ErrorCorrectionLevel from './ErrorCorrectionLevel';

@@ -26,2 +26,4 @@ import FormatInformation from './FormatInformation';

import ECB from './ECB';
import FormatException from '../../FormatException';
import IllegalArgumentException from '../../IllegalArgumentException';

@@ -429,3 +431,3 @@ /**

if (dimension % 4 !== 1) {
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -435,3 +437,3 @@ try {

} catch (ignored/*: IllegalArgumentException*/) {
throw new Exception(Exception.FormatException);
throw new FormatException();
}

@@ -442,3 +444,3 @@ }

if (versionNumber < 1 || versionNumber > 40) {
throw new Exception(Exception.IllegalArgumentException);
throw new IllegalArgumentException();
}

@@ -445,0 +447,0 @@ return Version.VERSIONS[versionNumber - 1];

@@ -22,4 +22,5 @@ /*

import AlignmentPattern from './AlignmentPattern';
import Exception from './../../Exception';
import NotFoundException from '../../NotFoundException';
/*import java.util.ArrayList;*/

@@ -146,3 +147,3 @@ /*import java.util.List;*/

throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -149,0 +150,0 @@

@@ -32,5 +32,6 @@ /*

import FinderPattern from './FinderPattern';
import Exception from './../../Exception';
import AlignmentPattern from './AlignmentPattern';
import AlignmentPatternFinder from './AlignmentPatternFinder';
import NotFoundException from '../../NotFoundException';

@@ -97,3 +98,3 @@ /*import java.util.Map;*/

if (moduleSize < 1.0) {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException('No pattern found in proccess finder.');
}

@@ -127,3 +128,3 @@ const dimension = Detector.computeDimension(topLeft, topRight, bottomLeft, moduleSize);

} catch (re/*NotFoundException*/) {
if (!Exception.isOfType(re, Exception.NotFoundException)) {
if (!(re instanceof NotFoundException)) {
throw re;

@@ -221,3 +222,3 @@ }

case 3:
throw new Exception(Exception.NotFoundException);
throw new NotFoundException('Dimensions could be not found.');
}

@@ -391,3 +392,3 @@ return dimension;

if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3) {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException('Alignment top exceeds estimated module size.');
}

@@ -398,14 +399,15 @@

if (alignmentAreaBottomY - alignmentAreaTopY < overallEstModuleSize * 3) {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException('Alignment bottom exceeds estimated module size.');
}
const alignmentFinder =
new AlignmentPatternFinder(
this.image,
alignmentAreaLeftX,
alignmentAreaTopY,
alignmentAreaRightX - alignmentAreaLeftX,
alignmentAreaBottomY - alignmentAreaTopY,
overallEstModuleSize,
this.resultPointCallback);
const alignmentFinder = new AlignmentPatternFinder(
this.image,
alignmentAreaLeftX,
alignmentAreaTopY,
alignmentAreaRightX - alignmentAreaLeftX,
alignmentAreaBottomY - alignmentAreaTopY,
overallEstModuleSize,
this.resultPointCallback
);
return alignmentFinder.find();

@@ -412,0 +414,0 @@ }

@@ -25,4 +25,5 @@ /*

import FinderPatternInfo from './FinderPatternInfo';
import Exception from './../../Exception';
import NotFoundException from '../../NotFoundException';
/*import java.io.Serializable;*/

@@ -595,3 +596,3 @@ /*import java.util.ArrayList;*/

// Couldn't find enough finder patterns
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -598,0 +599,0 @@

@@ -30,3 +30,3 @@ /*

import QRCode from './QRCode';
import Exception from './../../Exception';
import ECBlocks from './../decoder/ECBlocks';

@@ -36,2 +36,3 @@ import MatrixUtil from './MatrixUtil';

import BlockPair from './BlockPair';
import WriterException from '../../WriterException';

@@ -125,3 +126,3 @@ /*import java.io.UnsupportedEncodingException;*/

if (!this.willFit(bitsNeeded, version, ecLevel)) {
throw new Exception(Exception.WriterException, 'Data too big for requested version');
throw new WriterException('Data too big for requested version');
}

@@ -289,3 +290,3 @@ } else {

}
throw new Exception(Exception.WriterException, 'Data too big');
throw new WriterException('Data too big');
}

@@ -316,3 +317,3 @@

if (bits.getSize() > capacity) {
throw new Exception(Exception.WriterException, 'data bits cannot fit in the QR Code' + bits.getSize() + ' > ' +
throw new WriterException('data bits cannot fit in the QR Code' + bits.getSize() + ' > ' +
capacity);

@@ -337,3 +338,3 @@ }

if (bits.getSize() !== capacity) {
throw new Exception(Exception.WriterException, 'Bits size does not equal capacity');
throw new WriterException('Bits size does not equal capacity');
}

@@ -354,3 +355,3 @@ }

if (blockID >= numRSBlocks) {
throw new Exception(Exception.WriterException, 'Block ID too large');
throw new WriterException('Block ID too large');
}

@@ -376,7 +377,7 @@ // numRsBlocksInGroup2 = 196 % 5 = 1

if (numEcBytesInGroup1 !== numEcBytesInGroup2) {
throw new Exception(Exception.WriterException, 'EC bytes mismatch');
throw new WriterException('EC bytes mismatch');
}
// 5 = 4 + 1.
if (numRSBlocks !== numRsBlocksInGroup1 + numRsBlocksInGroup2) {
throw new Exception(Exception.WriterException, 'RS blocks mismatch');
throw new WriterException('RS blocks mismatch');
}

@@ -389,3 +390,3 @@ // 196 = (13 + 26) * 4 + (14 + 26) * 1

numRsBlocksInGroup2)) {
throw new Exception(Exception.WriterException, 'Total bytes mismatch');
throw new WriterException('Total bytes mismatch');
}

@@ -413,3 +414,3 @@

if (bits.getSizeInBytes() !== numDataBytes) {
throw new Exception(Exception.WriterException, 'Number of bits and data bytes does not match');
throw new WriterException('Number of bits and data bytes does not match');
}

@@ -444,3 +445,3 @@

if (numDataBytes !== dataBytesOffset) {
throw new Exception(Exception.WriterException, 'Data bytes does not match offset');
throw new WriterException('Data bytes does not match offset');
}

@@ -469,3 +470,3 @@

if (numTotalBytes !== result.getSizeInBytes()) { // Should be same.
throw new Exception('WriterException', 'Interleaving error: ' + numTotalBytes + ' and ' +
throw new WriterException('Interleaving error: ' + numTotalBytes + ' and ' +
result.getSizeInBytes() + ' differ.');

@@ -506,3 +507,3 @@ }

if (numLetters >= (1 << numBits)) {
throw new Exception(Exception.WriterException, numLetters + ' is bigger than ' + ((1 << numBits) - 1));
throw new WriterException(numLetters + ' is bigger than ' + ((1 << numBits) - 1));
}

@@ -533,3 +534,3 @@ bits.appendBits(numLetters, numBits);

default:
throw new Exception(Exception.WriterException, 'Invalid mode: ' + mode);
throw new WriterException('Invalid mode: ' + mode);
}

@@ -577,3 +578,3 @@ }

if (code1 === -1) {
throw new Exception(Exception.WriterException);
throw new WriterException();
}

@@ -583,3 +584,3 @@ if (i + 1 < length) {

if (code2 === -1) {
throw new Exception(Exception.WriterException);
throw new WriterException();
}

@@ -602,3 +603,3 @@ // Encode two alphanumeric letters in 11 bits.

} catch (uee/*: UnsupportedEncodingException*/) {
throw new Exception(Exception.WriterException, uee);
throw new WriterException(uee);
}

@@ -611,11 +612,19 @@ for (let i = 0, length = bytes.length; i !== length; i++) {

public static appendKanjiBytes(content: string, bits: BitArray): void /*throws WriterException*/ {
/**
* @throws WriterException
*/
public static appendKanjiBytes(content: string, bits: BitArray): void /*throws */ {
let bytes: Uint8Array;
try {
bytes = StringEncoding.encode(content, CharacterSetECI.SJIS.getName());
} catch (uee/*: UnsupportedEncodingException*/) {
throw new Exception(Exception.WriterException, uee);
throw new WriterException(uee);
}
const length = bytes.length;
for (let i = 0; i < length; i += 2) {
const byte1 = bytes[i] & 0xFF;

@@ -625,2 +634,3 @@ const byte2 = bytes[i + 1] & 0xFF;

let subtracted = -1;
if (code >= 0x8140 && code <= 0x9ffc) {

@@ -631,6 +641,9 @@ subtracted = code - 0x8140;

}
if (subtracted === -1) {
throw new Exception(Exception.WriterException, 'Invalid byte sequence');
throw new WriterException('Invalid byte sequence');
}
const encoded = ((subtracted >> 8) * 0xc0) + (subtracted & 0xff);
bits.appendBits(encoded, 13);

@@ -637,0 +650,0 @@ }

@@ -20,4 +20,5 @@ /*

import ByteMatrix from './ByteMatrix';
import Exception from './../../Exception';
import IllegalArgumentException from '../../IllegalArgumentException';
/**

@@ -190,3 +191,3 @@ * @author Satoru Takabayashi

default:
throw new Exception(Exception.IllegalArgumentException, 'Invalid mask pattern: ' + maskPattern);
throw new IllegalArgumentException('Invalid mask pattern: ' + maskPattern);
}

@@ -193,0 +194,0 @@ return intermediate === 0;

@@ -23,6 +23,8 @@ /*

import ByteMatrix from './ByteMatrix';
import Exception from './../../Exception';
import Integer from './../../util/Integer';
import QRCode from './QRCode';
import MaskUtil from './MaskUtil';
import WriterException from '../../WriterException';
import IllegalArgumentException from '../../IllegalArgumentException';

@@ -269,3 +271,3 @@ /**

if (bitIndex !== dataBits.getSize()) {
throw new Exception(Exception.WriterException, 'Not all bits consumed: ' + bitIndex + '/' + dataBits.getSize());
throw new WriterException('Not all bits consumed: ' + bitIndex + '/' + dataBits.getSize());
}

@@ -310,3 +312,3 @@ }

if (poly === 0) {
throw new Exception(Exception.IllegalArgumentException, '0 polynomial');
throw new IllegalArgumentException('0 polynomial');
}

@@ -330,3 +332,3 @@ // If poly is "1 1111 0010 0101" (version info poly), msbSetInPoly is 13. We'll subtract 1

if (!QRCode.isValidMaskPattern(maskPattern)) {
throw new Exception(Exception.WriterException, 'Invalid mask pattern');
throw new WriterException('Invalid mask pattern');
}

@@ -344,3 +346,3 @@ const typeInfo = (ecLevel.getBits() << 3) | maskPattern;

if (bits.getSize() !== 15) { // Just in case.
throw new Exception(Exception.WriterException, 'should not happen but we got: ' + bits.getSize());
throw new WriterException('should not happen but we got: ' + bits.getSize());
}

@@ -357,3 +359,3 @@ }

if (bits.getSize() !== 18) { // Just in case.
throw new Exception(Exception.WriterException, 'should not happen but we got: ' + bits.getSize());
throw new WriterException('should not happen but we got: ' + bits.getSize());
}

@@ -386,3 +388,3 @@ }

if (matrix.get(8, matrix.getHeight() - 8) === 0) {
throw new Exception(Exception.WriterException);
throw new WriterException();
}

@@ -397,3 +399,3 @@ matrix.setNumber(8, matrix.getHeight() - 8, 1);

if (!MatrixUtil.isEmpty(matrix.get(xStart + x, yStart))) {
throw new Exception(Exception.WriterException);
throw new WriterException();
}

@@ -409,3 +411,3 @@ matrix.setNumber(xStart + x, yStart, 0);

if (!MatrixUtil.isEmpty(matrix.get(xStart, yStart + y))) {
throw new Exception(Exception.WriterException);
throw new WriterException();
}

@@ -412,0 +414,0 @@ matrix.setNumber(xStart, yStart + y, 0);

@@ -32,4 +32,5 @@ /*

import Detector from './detector/Detector';
import Exception from './../Exception';
import NotFoundException from '../NotFoundException';
/*import java.util.List;*/

@@ -121,3 +122,3 @@ /*import java.util.Map;*/

if (leftTopBlack === null || rightBottomBlack === null) {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -134,3 +135,3 @@

if (left >= right || top >= bottom) {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -144,3 +145,3 @@

// Abort if that would not make sense -- off image
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -152,7 +153,7 @@ }

if (matrixWidth <= 0 || matrixHeight <= 0) {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}
if (matrixHeight !== matrixWidth) {
// Only possibly decode square regions
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -174,3 +175,3 @@

// Neither way fits; abort
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -184,3 +185,3 @@ left -= nudgedTooFarRight;

// Neither way fits; abort
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -221,3 +222,3 @@ top -= nudgedTooFarDown;

if (x === width || y === height) {
throw new Exception(Exception.NotFoundException);
throw new NotFoundException();
}

@@ -224,0 +225,0 @@ return (x - leftTopBlack[0]) / 7.0;

@@ -23,8 +23,9 @@ /*

import BitMatrix from './../common/BitMatrix';
import ByteMatrix from './encoder/ByteMatrix';
import ErrorCorrectionLevel from './decoder/ErrorCorrectionLevel';
import Encoder from './encoder/Encoder';
import QRCode from './encoder/QRCode';
import Exception from './../Exception';
import IllegalArgumentException from '../IllegalArgumentException';
import IllegalStateException from '../IllegalStateException';
/*import java.util.Map;*/

@@ -56,12 +57,11 @@

if (contents.length === 0) {
throw new Exception(Exception.IllegalArgumentException, 'Found empty contents');
throw new IllegalArgumentException('Found empty contents');
}
if (format !== BarcodeFormat.QR_CODE) {
throw new Exception(Exception.IllegalArgumentException, 'Can only encode QR_CODE, but got ' + format);
throw new IllegalArgumentException('Can only encode QR_CODE, but got ' + format);
}
if (width < 0 || height < 0) {
throw new Exception('IllegalArgumentException', 'Requested dimensions are too small: ' + width + 'x' +
height);
throw new IllegalArgumentException(`Requested dimensions are too small: ${width}x${height}`);
}

@@ -89,3 +89,3 @@

if (input === null) {
throw new Exception(Exception.IllegalStateException);
throw new IllegalStateException();
}

@@ -92,0 +92,0 @@ const inputWidth = input.getWidth();

@@ -56,3 +56,3 @@ /*

private format: BarcodeFormat,
private timestamp: number/*long*/) {
private timestamp: number /*long*/) {
this.text = text;

@@ -59,0 +59,0 @@ this.rawBytes = rawBytes;

@@ -22,4 +22,5 @@ /*

import LuminanceSource from './LuminanceSource';
import Exception from './Exception';
import System from './util/System';
import IllegalArgumentException from './IllegalArgumentException';

@@ -99,3 +100,3 @@ /**

if (this.left + width > this.dataWidth || this.top + height > this.dataHeight) {
throw new Exception(Exception.IllegalArgumentException, 'Crop rectangle does not fit within image data.');
throw new IllegalArgumentException('Crop rectangle does not fit within image data.');
}

@@ -107,3 +108,3 @@ }

if (y < 0 || y >= this.getHeight()) {
throw new Exception(Exception.IllegalArgumentException, 'Requested row is outside the image: ' + y);
throw new IllegalArgumentException('Requested row is outside the image: ' + y);
}

@@ -110,0 +111,0 @@ const width = this.getWidth();

@@ -33,2 +33,6 @@ export default class StringBuilder {

}
public insert(n: number, c: string) {
this.value = this.value.substr(0, n) + c + this.value.substr(n + c.length);
}
}

@@ -1,61 +0,45 @@

// declare require to support dynamic text-encoding module loading in node
declare function require(moduleName: string): any;
// declare window to use in browser
declare var window: any;
import { TextDecoder as TextDecoderFromTE, TextEncoder as TextEncoderFromTE } from 'text-encoding';
import { TextEncoder as TextEncoderLegacy, TextDecoder as TextDecoderLegacy } from 'text-encoding';
import CharacterSetECI from './../common/CharacterSetECI';
import Exception from './../Exception';
import UnsupportedOperationException from '../UnsupportedOperationException';
/**
* Responsible for en/decoding strings.
*/
export default class StringEncoding {
/**
* Decodes some Uint8Array to a string format.
*/
public static decode(bytes: Uint8Array, encoding: string | CharacterSetECI): string {
let encodingString: string;
if (typeof encoding === 'string') {
encodingString = encoding;
} else {
encodingString = encoding.getName();
const encodingName = this.encodingName(encoding);
// Node.js environment fallback.
if (!StringEncoding.isBrowser()) {
return new TextDecoderLegacy(encodingName).decode(bytes);
}
if (StringEncoding.isBrowser()) {
// tslint:disable-next-line:no-string-literal
const TextDecoderBrowser = window['TextDecoder'];
// use TextEncoder if is available (should be in newer browsers)
if (undefined !== TextDecoderBrowser) {
// console.log(TextDecoderBrowser)
return new TextDecoderBrowser(encoding).decode(bytes);
} else {
// fall back to minimal decoding
return StringEncoding.decodeFallBack(bytes, encodingString);
}
} else {
const TextDecoderFromTEClass: typeof TextDecoderFromTE = require('text-encoding').TextDecoder;
return new TextDecoderFromTEClass(encodingString).decode(bytes);
// TextDecoder not available
if (typeof TextDecoder === 'undefined') {
return this.decodeFallback(bytes, encodingName);
}
return new TextDecoder(encodingName).decode(bytes);
}
/**
* Encodes some string into a Uint8Array.
*
* @todo natively support other string formats than UTF-8.
*/
public static encode(s: string, encoding: string | CharacterSetECI): Uint8Array {
let encodingString: string;
if (typeof encoding === 'string') {
encodingString = encoding;
} else {
encodingString = encoding.getName();
// Uses `text-encoding` package.
if (!StringEncoding.isBrowser()) {
return new TextEncoderLegacy(this.encodingName(encoding), { NONSTANDARD_allowLegacyEncoding: true }).encode(s);
}
if (StringEncoding.isBrowser()) {
// tslint:disable-next-line:no-string-literal
const TextEncoderBrowser = window['TextEncoder'];
// use TextEncoder if is available (should be in newer browsers)
const ec = CharacterSetECI.getCharacterSetECIByName(encodingString);
if (undefined !== TextEncoderBrowser) {
// TODO: TextEncoder only supports utf-8 encoding as per specs
return new TextEncoderBrowser(encoding).encode(s);
} else {
// fall back to minimal decoding
return StringEncoding.encodeFallBack(s, encodingString);
}
} else {
// Note: NONSTANDARD_allowLegacyEncoding is required for other encodings than UTF8
// TextEncoder only encodes to UTF8 by default as specified by encoding.spec.whatwg.org
const TextEncoderFromTEClass: typeof TextEncoderFromTE = require('text-encoding').TextEncoder;
return new TextEncoderFromTEClass(encodingString, { NONSTANDARD_allowLegacyEncoding: true }).encode(s);
}
// TextEncoder only encodes to UTF8 by default as specified by encoding.spec.whatwg.org
return new TextEncoder().encode(s);
}

@@ -67,27 +51,51 @@

private static decodeFallBack(bytes: Uint8Array, encoding: string): string {
const ec = CharacterSetECI.getCharacterSetECIByName(encoding);
if (ec.equals(CharacterSetECI.UTF8) ||
ec.equals(CharacterSetECI.ISO8859_1) ||
ec.equals(CharacterSetECI.ASCII)) {
/**
* Returns the string value from some encoding character set.
*/
public static encodingName(encoding: string | CharacterSetECI): string {
return typeof encoding === 'string'
? encoding
: encoding.getName();
}
/**
* Returns character set from some encoding character set.
*/
public static encodingCharacterSet(encoding: string | CharacterSetECI): CharacterSetECI {
return CharacterSetECI.getCharacterSetECIByName(this.encodingName(encoding));
}
/**
* Runs a fallback for the native decoding funcion.
*/
private static decodeFallback(bytes: Uint8Array, encoding: string | CharacterSetECI): string {
const characterSet = this.encodingCharacterSet(encoding);
if (characterSet.equals(CharacterSetECI.UTF8) ||
characterSet.equals(CharacterSetECI.ISO8859_1) ||
characterSet.equals(CharacterSetECI.ASCII)) {
let s = '';
for (let i = 0, length = bytes.length; i < length; i++) {
let h = bytes[i].toString(16);
if (h.length < 2) {
h = '0' + h;
}
s += '%' + h;
}
return decodeURIComponent(s);
} else if (ec.equals(CharacterSetECI.UnicodeBigUnmarked)) {
}
if (characterSet.equals(CharacterSetECI.UnicodeBigUnmarked)) {
return String.fromCharCode.apply(null, new Uint16Array(bytes.buffer));
} else {
throw new Exception(Exception.UnsupportedOperationException, `encoding ${encoding} not supported`);
}
}
private static encodeFallBack(s: string, encoding: string): Uint8Array {
// TODO: encode
return null;
throw new UnsupportedOperationException(`Encoding ${this.encodingName(encoding)} not supported by fallback.`);
}
}
export default class System {
// public static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
public static arraycopy(src: any, srcPos: number, dest: any, destPos: number, length: number) {
/**
* Makes a copy of a array.
*/
public static arraycopy(src: any, srcPos: number, dest: any, destPos: number, length: number): void {
// TODO: better use split or set?
let i = srcPos;
let j = destPos;
let c = length;
while (c--) {
dest[j++] = src[i++];
while (length--) {
dest[destPos++] = src[srcPos++];
}
}
public static currentTimeMillis() {
/**
* Returns the current time in milliseconds.
*/
public static currentTimeMillis(): number {
return Date.now();
}
}
// browser
export { default as BrowserCodeReader } from './browser/BrowserCodeReader';
export * from './browser/BrowserCodeReader';
export * from './browser/BrowserQRCodeReader';
export * from './browser/BrowserDatamatrixCodeReader';
export * from './browser/BrowserQRCodeSvgWriter';
export { default as HTMLCanvasElementLuminanceSource } from './browser/HTMLCanvasElementLuminanceSource';
export { default as VideoInputDevice } from './browser/VideoInputDevice';
export * from './browser/HTMLCanvasElementLuminanceSource';
export * from './browser/VideoInputDevice';
export * from './browser/BrowserBarcodeReader';

@@ -53,3 +54,3 @@

// core/qrcode
// core/twod/qrcode
export { default as QRCodeReader } from './core/qrcode/QRCodeReader';

@@ -60,3 +61,4 @@ export { default as QRCodeWriter } from './core/qrcode/QRCodeWriter';

export { default as OneDReader } from './core/oned/OneDReader';
export { default as EAN13Reader } from './core/oned/EAN13Reader';
export { default as Code128Reader } from './core/oned/Code128Reader';
export { default as ITFReader } from './core/oned/ITFReader';

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 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 not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc