@qr-platform/qr-code.js 0.8.24 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/docs/advanced-examples.md +84 -0
- package/docs/api-reference-guide.md +38 -0
- package/docs/documentation.md +182 -0
- package/docs/examples.md +145 -27
- package/docs/template-update-plan.md +53 -0
- package/docs/usage-guide.md +47 -0
- package/lib/chunks/scan-validator-node-BGUxkBJt.js +1 -0
- package/lib/chunks/scan-validator-zxing-node-CV9K2v4n.js +1 -0
- package/lib/core/qr-code-js.d.ts +10 -1
- package/lib/core/qr-styles.d.ts +4 -0
- package/lib/index.d.ts +34 -7
- package/lib/index.js +1 -1
- package/lib/node/core/qr-code-js.d.ts +61 -0
- package/lib/node/core/qr-constant.d.ts +9 -0
- package/lib/node/core/qr-options-validation.d.ts +13 -0
- package/lib/node/core/qr-styles.d.ts +4 -0
- package/lib/node/core/qr-svg.d.ts +76 -0
- package/lib/node/core/qr-templates.d.ts +10 -0
- package/lib/node/figures/corner-dot.d.ts +24 -0
- package/lib/node/figures/corner-square.d.ts +24 -0
- package/lib/node/figures/dot.d.ts +31 -0
- package/lib/node/index.d.ts +101 -0
- package/lib/node/lib/image/GIFImage.d.ts +19 -0
- package/lib/node/lib/io/Base64.d.ts +10 -0
- package/lib/node/lib/io/Base64DecodeInputStream.d.ts +15 -0
- package/lib/node/lib/io/Base64EncodeOutputStream.d.ts +17 -0
- package/lib/node/lib/io/ByteArrayInputStream.d.ts +12 -0
- package/lib/node/lib/io/ByteArrayOutputStream.d.ts +12 -0
- package/lib/node/lib/io/InputStream.d.ts +10 -0
- package/lib/node/lib/io/OutputStream.d.ts +12 -0
- package/lib/node/lib/qr-code.d.ts +5 -0
- package/lib/node/lib/qrcode/BitBuffer.d.ts +11 -0
- package/lib/node/lib/qrcode/ErrorCorrectLevel.d.ts +23 -0
- package/lib/node/lib/qrcode/MaskPattern.d.ts +39 -0
- package/lib/node/lib/qrcode/Mode.d.ts +23 -0
- package/lib/node/lib/qrcode/Polynomial.d.ts +15 -0
- package/lib/node/lib/qrcode/QR8BitByte.d.ts +13 -0
- package/lib/node/lib/qrcode/QRAlphaNum.d.ts +13 -0
- package/lib/node/lib/qrcode/QRCode.d.ts +22 -0
- package/lib/node/lib/qrcode/QRCodeMinimal.d.ts +58 -0
- package/lib/node/lib/qrcode/QRData.d.ts +17 -0
- package/lib/node/lib/qrcode/QRKanji.d.ts +13 -0
- package/lib/node/lib/qrcode/QRMath.d.ts +13 -0
- package/lib/node/lib/qrcode/QRNumber.d.ts +14 -0
- package/lib/node/lib/qrcode/QRUtil.d.ts +25 -0
- package/lib/node/lib/qrcode/RSBlock.d.ts +16 -0
- package/lib/node/lib/text/createStringToBytes.d.ts +9 -0
- package/lib/node/lib/text/stringToBytes_SJIS.d.ts +8 -0
- package/lib/node/lib/text/stringToBytes_UTF8.d.ts +7 -0
- package/lib/node/lib/zbar-wasm/index.d.ts +1 -0
- package/lib/node/lib/zxing-js/src/browser/BrowserCodeReader.d.ts +150 -0
- package/lib/node/lib/zxing-js/src/browser/BrowserQRCodeReader.d.ts +29 -0
- package/lib/node/lib/zxing-js/src/browser/HTMLCanvasElementLuminanceSource.d.ts +27 -0
- package/lib/node/lib/zxing-js/src/browser/HTMLVisualMediaElement.d.ts +4 -0
- package/lib/node/lib/zxing-js/src/browser.d.ts +3 -0
- package/lib/node/lib/zxing-js/src/core/ArgumentException.d.ts +7 -0
- package/lib/node/lib/zxing-js/src/core/ArithmeticException.d.ts +7 -0
- package/lib/node/lib/zxing-js/src/core/ArrayIndexOutOfBoundsException.d.ts +10 -0
- package/lib/node/lib/zxing-js/src/core/BarcodeFormat.d.ts +42 -0
- package/lib/node/lib/zxing-js/src/core/Binarizer.d.ts +53 -0
- package/lib/node/lib/zxing-js/src/core/BinaryBitmap.d.ts +78 -0
- package/lib/node/lib/zxing-js/src/core/ChecksumException.d.ts +8 -0
- package/lib/node/lib/zxing-js/src/core/DecodeHintType.d.ts +91 -0
- package/lib/node/lib/zxing-js/src/core/Exception.d.ts +17 -0
- package/lib/node/lib/zxing-js/src/core/FormatException.d.ts +8 -0
- package/lib/node/lib/zxing-js/src/core/HighContrastLuminanceSource.d.ts +27 -0
- package/lib/node/lib/zxing-js/src/core/IllegalArgumentException.d.ts +7 -0
- package/lib/node/lib/zxing-js/src/core/IllegalStateException.d.ts +7 -0
- package/lib/node/lib/zxing-js/src/core/IndexOutOfBoundsException.d.ts +7 -0
- package/lib/node/lib/zxing-js/src/core/InvertedLuminanceSource.d.ts +22 -0
- package/lib/node/lib/zxing-js/src/core/LuminanceSource.d.ts +84 -0
- package/lib/node/lib/zxing-js/src/core/NodeLuminanceSource.d.ts +33 -0
- package/lib/node/lib/zxing-js/src/core/NotFoundException.d.ts +8 -0
- package/lib/node/lib/zxing-js/src/core/NullPointerException.d.ts +7 -0
- package/lib/node/lib/zxing-js/src/core/OutOfMemoryError.d.ts +6 -0
- package/lib/node/lib/zxing-js/src/core/Reader.d.ts +49 -0
- package/lib/node/lib/zxing-js/src/core/ReaderException.d.ts +7 -0
- package/lib/node/lib/zxing-js/src/core/ReedSolomonException.d.ts +7 -0
- package/lib/node/lib/zxing-js/src/core/Result.d.ts +52 -0
- package/lib/node/lib/zxing-js/src/core/ResultMetadataType.d.ts +68 -0
- package/lib/node/lib/zxing-js/src/core/ResultPoint.d.ts +34 -0
- package/lib/node/lib/zxing-js/src/core/ResultPointCallback.d.ts +11 -0
- package/lib/node/lib/zxing-js/src/core/UniversalLuminanceSource.d.ts +46 -0
- package/lib/node/lib/zxing-js/src/core/UnsupportedOperationException.d.ts +7 -0
- package/lib/node/lib/zxing-js/src/core/common/BitArray.d.ts +111 -0
- package/lib/node/lib/zxing-js/src/core/common/BitMatrix.d.ts +98 -0
- package/lib/node/lib/zxing-js/src/core/common/BitSource.d.ts +38 -0
- package/lib/node/lib/zxing-js/src/core/common/CharacterSetECI.d.ts +89 -0
- package/lib/node/lib/zxing-js/src/core/common/DecoderResult.d.ts +64 -0
- package/lib/node/lib/zxing-js/src/core/common/DefaultGridSampler.d.ts +10 -0
- package/lib/node/lib/zxing-js/src/core/common/DetectorResult.d.ts +16 -0
- package/lib/node/lib/zxing-js/src/core/common/GlobalHistogramBinarizer.d.ts +29 -0
- package/lib/node/lib/zxing-js/src/core/common/GridSampler.d.ts +36 -0
- package/lib/node/lib/zxing-js/src/core/common/GridSamplerInstance.d.ts +18 -0
- package/lib/node/lib/zxing-js/src/core/common/HybridBinarizer.d.ts +54 -0
- package/lib/node/lib/zxing-js/src/core/common/PerspectiveTransform.d.ts +26 -0
- package/lib/node/lib/zxing-js/src/core/common/StringUtils.d.ts +48 -0
- package/lib/node/lib/zxing-js/src/core/common/detector/MathUtils.d.ts +36 -0
- package/lib/node/lib/zxing-js/src/core/common/reedsolomon/AbstractGenericGF.d.ts +34 -0
- package/lib/node/lib/zxing-js/src/core/common/reedsolomon/GenericGF.d.ts +58 -0
- package/lib/node/lib/zxing-js/src/core/common/reedsolomon/GenericGFPoly.d.ts +47 -0
- package/lib/node/lib/zxing-js/src/core/common/reedsolomon/ReedSolomonDecoder.d.ts +40 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/QRCodeReader.d.ts +35 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/BitMatrixParser.d.ts +58 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/DataBlock.d.ts +28 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/DataMask.d.ts +36 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/DecodedBitStreamParser.d.ts +30 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/Decoder.d.ts +44 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/ECB.d.ts +12 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/ECBlocks.d.ts +16 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/ErrorCorrectionLevel.d.ts +38 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/FormatInformation.d.ts +33 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/Mode.d.ts +56 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/QRCodeDecoderMetaData.d.ts +21 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/Version.d.ts +44 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/detector/AlignmentPattern.d.ts +21 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/detector/AlignmentPatternFinder.d.ts +82 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/detector/Detector.d.ts +87 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/detector/FinderPattern.d.ts +26 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/detector/FinderPatternFinder.d.ts +114 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/detector/FinderPatternInfo.d.ts +16 -0
- package/lib/node/lib/zxing-js/src/core/util/Arrays.d.ts +45 -0
- package/lib/node/lib/zxing-js/src/core/util/Charset.d.ts +7 -0
- package/lib/node/lib/zxing-js/src/core/util/Float.d.ts +14 -0
- package/lib/node/lib/zxing-js/src/core/util/Integer.d.ts +19 -0
- package/lib/node/lib/zxing-js/src/core/util/StringBuilder.d.ts +21 -0
- package/lib/node/lib/zxing-js/src/core/util/StringEncoding.d.ts +51 -0
- package/lib/node/lib/zxing-js/src/core/util/System.d.ts +10 -0
- package/lib/node/lib/zxing-js/src/customTypings.d.ts +16 -0
- package/lib/node/lib/zxing-js/src/index.d.ts +5 -0
- package/lib/node/lib/zxing-js/src/node.d.ts +1 -0
- package/lib/node/license/LicenseManager.d.ts +69 -0
- package/lib/node/license/LicenseManagerNode.d.ts +64 -0
- package/lib/node/node.d.ts +88 -0
- package/lib/node/options-demo.d.ts +239 -0
- package/lib/node/plugins/QRBorderHelpers.d.ts +32 -0
- package/lib/node/plugins/QRBorderPlugin.d.ts +35 -0
- package/lib/node/plugins/QRValidatorZbar.d.ts +38 -0
- package/lib/node/plugins/QRValidatorZbarNode.d.ts +60 -0
- package/lib/node/plugins/QRValidatorZbarNodeSharp.d.ts +83 -0
- package/lib/node/templates/borders-inner-outter.d.ts +129 -0
- package/lib/node/templates/borders-inner-scale-offset.d.ts +497 -0
- package/lib/node/templates/borders-inner.d.ts +129 -0
- package/lib/node/templates/borders-no-license.d.ts +129 -0
- package/lib/node/templates/borders-outter.d.ts +129 -0
- package/lib/node/templates/borders-text-auto-curved.d.ts +129 -0
- package/lib/node/templates/borders-text-full-curved.d.ts +133 -0
- package/lib/node/templates/borders.d.ts +129 -0
- package/lib/node/templates/scales.d.ts +130 -0
- package/lib/node/templates/scan-validators/index.d.ts +1 -0
- package/lib/node/templates/scan-validators/tests/cases/basic-inverted.d.ts +9 -0
- package/lib/node/templates/scan-validators/tests/cases/basic-no-license.d.ts +3 -0
- package/lib/node/templates/scan-validators/tests/cases/basic.d.ts +3 -0
- package/lib/node/templates/scan-validators/tests/cases/colors-inverted.d.ts +2 -0
- package/lib/node/templates/scan-validators/tests/cases/colors.d.ts +58 -0
- package/lib/node/templates/scan-validators/tests/cases/out-of-borders-inverted.d.ts +9 -0
- package/lib/node/templates/scan-validators/tests/cases/out-of-borders.d.ts +9 -0
- package/lib/node/templates/scan-validators/tests/cases/position-inverted.d.ts +9 -0
- package/lib/node/templates/scan-validators/tests/cases/position.d.ts +3 -0
- package/lib/node/templates/scan-validators/tests/index.d.ts +27 -0
- package/lib/node/tools/browser-image-tools.d.ts +7 -0
- package/lib/node/tools/browser-utils.d.ts +18 -0
- package/lib/node/types/helper.d.ts +23 -0
- package/lib/node/types/style-options.d.ts +37 -0
- package/lib/node/utils/canvas-options.d.ts +7 -0
- package/lib/node/utils/color.d.ts +4 -0
- package/lib/node/utils/gradient.d.ts +26 -0
- package/lib/node/utils/image.d.ts +16 -0
- package/lib/node/utils/merge.d.ts +5 -0
- package/lib/node/utils/options.d.ts +220 -0
- package/lib/node/utils/qrcode.d.ts +8 -0
- package/lib/node/utils/scan-validator-node.d.ts +15 -0
- package/lib/node/utils/scan-validator-zxing-node.d.ts +18 -0
- package/lib/node/utils/scan-validators/abstract-scan-validator.d.ts +43 -0
- package/lib/node/utils/scan-validators/zbar-scan-validator.d.ts +8 -0
- package/lib/node/utils/scan-validators/zxing-canvas-scan-validator.d.ts +10 -0
- package/lib/node/utils/scan-validators/zxing-scan-validator.d.ts +8 -0
- package/lib/node/utils/style-mapper.d.ts +13 -0
- package/lib/node/utils/svg.d.ts +2 -0
- package/lib/node/utils/token-validator.d.ts +19 -0
- package/lib/node.d.ts +38 -10
- package/lib/node.js +1 -1
- package/lib/types/style-options.d.ts +37 -0
- package/lib/utils/style-mapper.d.ts +13 -0
- package/package.json +1 -1
@@ -0,0 +1,36 @@
|
|
1
|
+
/**
|
2
|
+
* General math-related and numeric utility functions.
|
3
|
+
*/
|
4
|
+
export default class MathUtils {
|
5
|
+
private constructor();
|
6
|
+
/**
|
7
|
+
* Ends up being a bit faster than {@link Math#round(float)}. This merely rounds its
|
8
|
+
* argument to the nearest int, where x.5 rounds up to x+1. Semantics of this shortcut
|
9
|
+
* differ slightly from {@link Math#round(float)} in that half rounds down for negative
|
10
|
+
* values. -2.5 rounds to -3, not -2. For purposes here it makes no difference.
|
11
|
+
*
|
12
|
+
* @param d real value to round
|
13
|
+
* @return nearest {@code int}
|
14
|
+
*/
|
15
|
+
static round(d: number): number;
|
16
|
+
/**
|
17
|
+
* @param aX point A x coordinate
|
18
|
+
* @param aY point A y coordinate
|
19
|
+
* @param bX point B x coordinate
|
20
|
+
* @param bY point B y coordinate
|
21
|
+
* @return Euclidean distance between points A and B
|
22
|
+
*/
|
23
|
+
static distance(aX: number, aY: number, bX: number, bY: number): number;
|
24
|
+
/**
|
25
|
+
* @param aX point A x coordinate
|
26
|
+
* @param aY point A y coordinate
|
27
|
+
* @param bX point B x coordinate
|
28
|
+
* @param bY point B y coordinate
|
29
|
+
* @return Euclidean distance between points A and B
|
30
|
+
*/
|
31
|
+
/**
|
32
|
+
* @param array values to sum
|
33
|
+
* @return sum of values in array
|
34
|
+
*/
|
35
|
+
static sum(array: Int32Array): number;
|
36
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/**
|
2
|
+
* <p>This class contains utility methods for performing mathematical operations over
|
3
|
+
* the Galois Fields. Operations use a given primitive polynomial in calculations.</p>
|
4
|
+
*
|
5
|
+
* <p>Throughout this package, elements of the GF are represented as an {@code int}
|
6
|
+
* for convenience and speed (but at the cost of memory).
|
7
|
+
* </p>
|
8
|
+
*
|
9
|
+
* @author Sean Owen
|
10
|
+
* @author David Olivier
|
11
|
+
*/
|
12
|
+
export default abstract class AbstractGenericGF {
|
13
|
+
protected expTable: any;
|
14
|
+
protected logTable: any;
|
15
|
+
abstract getZero(): any;
|
16
|
+
abstract buildMonomial(degree: number, coefficient: number): any;
|
17
|
+
abstract equals(o: Object): boolean;
|
18
|
+
abstract multiply(a: number, b: number): number;
|
19
|
+
abstract inverse(a: number): number;
|
20
|
+
/**
|
21
|
+
* @return 2 to the power of a in GF(size)
|
22
|
+
*/
|
23
|
+
exp(a: number): number;
|
24
|
+
/**
|
25
|
+
* @return base 2 log of a in GF(size)
|
26
|
+
*/
|
27
|
+
log(a: number): number;
|
28
|
+
/**
|
29
|
+
* Implements both addition and subtraction -- they are the same in GF(size).
|
30
|
+
*
|
31
|
+
* @return sum/difference of a and b
|
32
|
+
*/
|
33
|
+
static addOrSubtract(a: number, b: number): number;
|
34
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import AbstractGenericGF from './AbstractGenericGF';
|
2
|
+
import GenericGFPoly from './GenericGFPoly';
|
3
|
+
/**
|
4
|
+
* <p>This class contains utility methods for performing mathematical operations over
|
5
|
+
* the Galois Fields. Operations use a given primitive polynomial in calculations.</p>
|
6
|
+
*
|
7
|
+
* <p>Throughout this package, elements of the GF are represented as an {@code int}
|
8
|
+
* for convenience and speed (but at the cost of memory).
|
9
|
+
* </p>
|
10
|
+
*
|
11
|
+
* @author Sean Owen
|
12
|
+
* @author David Olivier
|
13
|
+
*/
|
14
|
+
export default class GenericGF extends AbstractGenericGF {
|
15
|
+
private primitive;
|
16
|
+
private size;
|
17
|
+
private generatorBase;
|
18
|
+
static AZTEC_DATA_12: GenericGF;
|
19
|
+
static AZTEC_DATA_10: GenericGF;
|
20
|
+
static AZTEC_DATA_6: GenericGF;
|
21
|
+
static AZTEC_PARAM: GenericGF;
|
22
|
+
static QR_CODE_FIELD_256: GenericGF;
|
23
|
+
static DATA_MATRIX_FIELD_256: GenericGF;
|
24
|
+
static AZTEC_DATA_8: GenericGF;
|
25
|
+
static MAXICODE_FIELD_64: GenericGF;
|
26
|
+
private zero;
|
27
|
+
private one;
|
28
|
+
/**
|
29
|
+
* Create a representation of GF(size) using the given primitive polynomial.
|
30
|
+
*
|
31
|
+
* @param primitive irreducible polynomial whose coefficients are represented by
|
32
|
+
* the bits of an int, where the least-significant bit represents the constant
|
33
|
+
* coefficient
|
34
|
+
* @param size the size of the field
|
35
|
+
* @param b the factor b in the generator polynomial can be 0- or 1-based
|
36
|
+
* (g(x) = (x+a^b)(x+a^(b+1))...(x+a^(b+2t-1))).
|
37
|
+
* In most cases it should be 1, but for QR code it is 0.
|
38
|
+
*/
|
39
|
+
constructor(primitive: number, size: number, generatorBase: number);
|
40
|
+
getZero(): GenericGFPoly;
|
41
|
+
getOne(): GenericGFPoly;
|
42
|
+
/**
|
43
|
+
* @return the monomial representing coefficient * x^degree
|
44
|
+
*/
|
45
|
+
buildMonomial(degree: number, coefficient: number): GenericGFPoly;
|
46
|
+
/**
|
47
|
+
* @return multiplicative inverse of a
|
48
|
+
*/
|
49
|
+
inverse(a: number): number;
|
50
|
+
/**
|
51
|
+
* @return product of a and b in GF(size)
|
52
|
+
*/
|
53
|
+
multiply(a: number, b: number): number;
|
54
|
+
getSize(): number;
|
55
|
+
getGeneratorBase(): number;
|
56
|
+
toString(): string;
|
57
|
+
equals(o: Object): boolean;
|
58
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import AbstractGenericGF from './AbstractGenericGF';
|
2
|
+
/**
|
3
|
+
* <p>Represents a polynomial whose coefficients are elements of a GF.
|
4
|
+
* Instances of this class are immutable.</p>
|
5
|
+
*
|
6
|
+
* <p>Much credit is due to William Rucklidge since portions of this code are an indirect
|
7
|
+
* port of his C++ Reed-Solomon implementation.</p>
|
8
|
+
*
|
9
|
+
* @author Sean Owen
|
10
|
+
*/
|
11
|
+
export default class GenericGFPoly {
|
12
|
+
private field;
|
13
|
+
private coefficients;
|
14
|
+
/**
|
15
|
+
* @param field the {@link GenericGF} instance representing the field to use
|
16
|
+
* to perform computations
|
17
|
+
* @param coefficients coefficients as ints representing elements of GF(size), arranged
|
18
|
+
* from most significant (highest-power term) coefficient to least significant
|
19
|
+
* @throws IllegalArgumentException if argument is null or empty,
|
20
|
+
* or if leading coefficient is 0 and this is not a
|
21
|
+
* constant polynomial (that is, it is not the monomial "0")
|
22
|
+
*/
|
23
|
+
constructor(field: AbstractGenericGF, coefficients: Int32Array);
|
24
|
+
getCoefficients(): Int32Array;
|
25
|
+
/**
|
26
|
+
* @return degree of this polynomial
|
27
|
+
*/
|
28
|
+
getDegree(): number;
|
29
|
+
/**
|
30
|
+
* @return true iff this polynomial is the monomial "0"
|
31
|
+
*/
|
32
|
+
isZero(): boolean;
|
33
|
+
/**
|
34
|
+
* @return coefficient of x^degree term in this polynomial
|
35
|
+
*/
|
36
|
+
getCoefficient(degree: number): number;
|
37
|
+
/**
|
38
|
+
* @return evaluation of this polynomial at a given point
|
39
|
+
*/
|
40
|
+
evaluateAt(a: number): number;
|
41
|
+
addOrSubtract(other: GenericGFPoly): GenericGFPoly;
|
42
|
+
multiply(other: GenericGFPoly): GenericGFPoly;
|
43
|
+
multiplyScalar(scalar: number): GenericGFPoly;
|
44
|
+
multiplyByMonomial(degree: number, coefficient: number): GenericGFPoly;
|
45
|
+
divide(other: GenericGFPoly): GenericGFPoly[];
|
46
|
+
toString(): string;
|
47
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import GenericGF from './GenericGF';
|
2
|
+
/**
|
3
|
+
* <p>Implements Reed-Solomon decoding, as the name implies.</p>
|
4
|
+
*
|
5
|
+
* <p>The algorithm will not be explained here, but the following references were helpful
|
6
|
+
* in creating this implementation:</p>
|
7
|
+
*
|
8
|
+
* <ul>
|
9
|
+
* <li>Bruce Maggs.
|
10
|
+
* <a href="http://www.cs.cmu.edu/afs/cs.cmu.edu/project/pscico-guyb/realworld/www/rs_decode.ps">
|
11
|
+
* "Decoding Reed-Solomon Codes"</a> (see discussion of Forney's Formula)</li>
|
12
|
+
* <li>J.I. Hall. <a href="www.mth.msu.edu/~jhall/classes/codenotes/GRS.pdf">
|
13
|
+
* "Chapter 5. Generalized Reed-Solomon Codes"</a>
|
14
|
+
* (see discussion of Euclidean algorithm)</li>
|
15
|
+
* </ul>
|
16
|
+
*
|
17
|
+
* <p>Much credit is due to William Rucklidge since portions of this code are an indirect
|
18
|
+
* port of his C++ Reed-Solomon implementation.</p>
|
19
|
+
*
|
20
|
+
* @author Sean Owen
|
21
|
+
* @author William Rucklidge
|
22
|
+
* @author sanfordsquires
|
23
|
+
*/
|
24
|
+
export default class ReedSolomonDecoder {
|
25
|
+
private field;
|
26
|
+
constructor(field: GenericGF);
|
27
|
+
/**
|
28
|
+
* <p>Decodes given set of received codewords, which include both data and error-correction
|
29
|
+
* codewords. Really, this means it uses Reed-Solomon to detect and correct errors, in-place,
|
30
|
+
* in the input.</p>
|
31
|
+
*
|
32
|
+
* @param received data and error-correction codewords
|
33
|
+
* @param twoS number of error-correction codewords available
|
34
|
+
* @throws ReedSolomonException if decoding fails for any reason
|
35
|
+
*/
|
36
|
+
decode(received: Int32Array, twoS: number): void;
|
37
|
+
private runEuclideanAlgorithm;
|
38
|
+
private findErrorLocations;
|
39
|
+
private findErrorMagnitudes;
|
40
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import BinaryBitmap from '../BinaryBitmap';
|
2
|
+
import DecodeHintType from '../DecodeHintType';
|
3
|
+
import Result from '../Result';
|
4
|
+
import Decoder from './decoder/Decoder';
|
5
|
+
/**
|
6
|
+
* This implementation can detect and decode QR Codes in an image.
|
7
|
+
*
|
8
|
+
* @author Sean Owen
|
9
|
+
*/
|
10
|
+
export default class QRCodeReader {
|
11
|
+
private static NO_POINTS;
|
12
|
+
private decoder;
|
13
|
+
protected getDecoder(): Decoder;
|
14
|
+
/**
|
15
|
+
* Locates and decodes a QR code in an image.
|
16
|
+
*
|
17
|
+
* @return a representing: string the content encoded by the QR code
|
18
|
+
* @throws NotFoundException if a QR code cannot be found
|
19
|
+
* @throws FormatException if a QR code cannot be decoded
|
20
|
+
* @throws ChecksumException if error correction fails
|
21
|
+
*/
|
22
|
+
decode(image: BinaryBitmap, hints?: Map<DecodeHintType, any>): Result;
|
23
|
+
decode2(image: BinaryBitmap, hints?: Map<DecodeHintType, any>): Result;
|
24
|
+
reset(): void;
|
25
|
+
/**
|
26
|
+
* This method detects a code in a "pure" image -- that is, pure monochrome image
|
27
|
+
* which contains only an unrotated, unskewed, image of a code, with some white border
|
28
|
+
* around it. This is a specialized method that works exceptionally fast in this special
|
29
|
+
* case.
|
30
|
+
*
|
31
|
+
* @see com.google.zxing.datamatrix.DataMatrixReader#extractPureBits(BitMatrix)
|
32
|
+
*/
|
33
|
+
private static extractPureBits;
|
34
|
+
private static moduleSize;
|
35
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import BitMatrix from '../../common/BitMatrix';
|
2
|
+
import FormatInformation from './FormatInformation';
|
3
|
+
import Version from './Version';
|
4
|
+
/**
|
5
|
+
* @author Sean Owen
|
6
|
+
*/
|
7
|
+
export default class BitMatrixParser {
|
8
|
+
private bitMatrix;
|
9
|
+
private parsedVersion?;
|
10
|
+
private parsedFormatInfo?;
|
11
|
+
private isMirror?;
|
12
|
+
/**
|
13
|
+
* @param bitMatrix {@link BitMatrix} to parse
|
14
|
+
* @throws FormatException if dimension is not >= 21 and 1 mod 4
|
15
|
+
*/
|
16
|
+
constructor(bitMatrix: BitMatrix);
|
17
|
+
/**
|
18
|
+
* <p>Reads format information from one of its two locations within the QR Code.</p>
|
19
|
+
*
|
20
|
+
* @return {@link FormatInformation} encapsulating the QR Code's format info
|
21
|
+
* @throws FormatException if both format information locations cannot be parsed as
|
22
|
+
* the valid encoding of format information
|
23
|
+
*/
|
24
|
+
readFormatInformation(): FormatInformation;
|
25
|
+
/**
|
26
|
+
* <p>Reads version information from one of its two locations within the QR Code.</p>
|
27
|
+
*
|
28
|
+
* @return {@link Version} encapsulating the QR Code's version
|
29
|
+
* @throws FormatException if both version information locations cannot be parsed as
|
30
|
+
* the valid encoding of version information
|
31
|
+
*/
|
32
|
+
readVersion(): Version;
|
33
|
+
private copyBit;
|
34
|
+
/**
|
35
|
+
* <p>Reads the bits in the {@link BitMatrix} representing the finder pattern in the
|
36
|
+
* correct order in order to reconstruct the codewords bytes contained within the
|
37
|
+
* QR Code.</p>
|
38
|
+
*
|
39
|
+
* @return bytes encoded within the QR Code
|
40
|
+
* @throws FormatException if the exact number of bytes expected is not read
|
41
|
+
*/
|
42
|
+
readCodewords(): Uint8Array;
|
43
|
+
/**
|
44
|
+
* Revert the mask removal done while reading the code words. The bit matrix should revert to its original state.
|
45
|
+
*/
|
46
|
+
remask(): void;
|
47
|
+
/**
|
48
|
+
* Prepare the parser for a mirrored operation.
|
49
|
+
* This flag has effect only on the {@link #readFormatInformation()} and the
|
50
|
+
* {@link #readVersion()}. Before proceeding with {@link #readCodewords()} the
|
51
|
+
* {@link #mirror()} method should be called.
|
52
|
+
*
|
53
|
+
* @param mirror Whether to read version and format information mirrored.
|
54
|
+
*/
|
55
|
+
setMirror(isMirror: boolean): void;
|
56
|
+
/** Mirror the bit matrix in order to attempt a second reading. */
|
57
|
+
mirror(): void;
|
58
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import ErrorCorrectionLevel from './ErrorCorrectionLevel';
|
2
|
+
import Version from './Version';
|
3
|
+
/**
|
4
|
+
* <p>Encapsulates a block of data within a QR Code. QR Codes may split their data into
|
5
|
+
* multiple blocks, each of which is a unit of data and error-correction codewords. Each
|
6
|
+
* is represented by an instance of this class.</p>
|
7
|
+
*
|
8
|
+
* @author Sean Owen
|
9
|
+
*/
|
10
|
+
export default class DataBlock {
|
11
|
+
private numDataCodewords;
|
12
|
+
private codewords;
|
13
|
+
private constructor();
|
14
|
+
/**
|
15
|
+
* <p>When QR Codes use multiple data blocks, they are actually interleaved.
|
16
|
+
* That is, the first byte of data block 1 to n is written, then the second bytes, and so on. This
|
17
|
+
* method will separate the data into original blocks.</p>
|
18
|
+
*
|
19
|
+
* @param rawCodewords bytes as read directly from the QR Code
|
20
|
+
* @param version version of the QR Code
|
21
|
+
* @param ecLevel error-correction level of the QR Code
|
22
|
+
* @return DataBlocks containing original bytes, "de-interleaved" from representation in the
|
23
|
+
* QR Code
|
24
|
+
*/
|
25
|
+
static getDataBlocks(rawCodewords: Uint8Array, version: Version, ecLevel: ErrorCorrectionLevel): DataBlock[];
|
26
|
+
getNumDataCodewords(): number;
|
27
|
+
getCodewords(): Uint8Array;
|
28
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import BitMatrix from '../../common/BitMatrix';
|
2
|
+
export declare enum DataMaskValues {
|
3
|
+
DATA_MASK_000 = 0,
|
4
|
+
DATA_MASK_001 = 1,
|
5
|
+
DATA_MASK_010 = 2,
|
6
|
+
DATA_MASK_011 = 3,
|
7
|
+
DATA_MASK_100 = 4,
|
8
|
+
DATA_MASK_101 = 5,
|
9
|
+
DATA_MASK_110 = 6,
|
10
|
+
DATA_MASK_111 = 7
|
11
|
+
}
|
12
|
+
/**
|
13
|
+
* <p>Encapsulates data masks for the data bits in a QR code, per ISO 18004:2006 6.8. Implementations
|
14
|
+
* of this class can un-mask a raw BitMatrix. For simplicity, they will unmask the entire BitMatrix,
|
15
|
+
* including areas used for finder patterns, timing patterns, etc. These areas should be unused
|
16
|
+
* after the point they are unmasked anyway.</p>
|
17
|
+
*
|
18
|
+
* <p>Note that the diagram in section 6.8.1 is misleading since it indicates that i is column position
|
19
|
+
* and j is row position. In fact, as the text says, i is row position and j is column position.</p>
|
20
|
+
*
|
21
|
+
* @author Sean Owen
|
22
|
+
*/
|
23
|
+
export default class DataMask {
|
24
|
+
private value;
|
25
|
+
private isMasked;
|
26
|
+
constructor(value: DataMaskValues, isMasked: (i: number, j: number) => boolean);
|
27
|
+
static values: Map<DataMaskValues, DataMask>;
|
28
|
+
/**
|
29
|
+
* <p>Implementations of this method reverse the data masking process applied to a QR Code and
|
30
|
+
* make its bits ready to read.</p>
|
31
|
+
*
|
32
|
+
* @param bits representation of QR Code bits
|
33
|
+
* @param dimension dimension of QR Code, represented by bits, being unmasked
|
34
|
+
*/
|
35
|
+
unmaskBitMatrix(bits: BitMatrix, dimension: number): void;
|
36
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import DecoderResult from '../../common/DecoderResult';
|
2
|
+
import DecodeHintType from '../../DecodeHintType';
|
3
|
+
import ErrorCorrectionLevel from './ErrorCorrectionLevel';
|
4
|
+
import Version from './Version';
|
5
|
+
/**
|
6
|
+
* <p>QR Codes can encode text as bits in one of several modes, and can use multiple modes
|
7
|
+
* in one QR Code. This class decodes the bits back into text.</p>
|
8
|
+
*
|
9
|
+
* <p>See ISO 18004:2006, 6.4.3 - 6.4.7</p>
|
10
|
+
*
|
11
|
+
* @author Sean Owen
|
12
|
+
*/
|
13
|
+
export default class DecodedBitStreamParser {
|
14
|
+
/**
|
15
|
+
* See ISO 18004:2006, 6.4.4 Table 5
|
16
|
+
*/
|
17
|
+
private static ALPHANUMERIC_CHARS;
|
18
|
+
private static GB2312_SUBSET;
|
19
|
+
static decode(bytes: Uint8Array, version: Version, ecLevel: ErrorCorrectionLevel, hints: Map<DecodeHintType, any>): DecoderResult;
|
20
|
+
/**
|
21
|
+
* See specification GBT 18284-2000
|
22
|
+
*/
|
23
|
+
private static decodeHanziSegment;
|
24
|
+
private static decodeKanjiSegment;
|
25
|
+
private static decodeByteSegment;
|
26
|
+
private static toAlphaNumericChar;
|
27
|
+
private static decodeAlphanumericSegment;
|
28
|
+
private static decodeNumericSegment;
|
29
|
+
private static parseECIValue;
|
30
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import BitMatrix from '../../common/BitMatrix';
|
2
|
+
import DecoderResult from '../../common/DecoderResult';
|
3
|
+
import DecodeHintType from '../../DecodeHintType';
|
4
|
+
/**
|
5
|
+
* <p>The main class which implements QR Code decoding -- as opposed to locating and extracting
|
6
|
+
* the QR Code from an image.</p>
|
7
|
+
*
|
8
|
+
* @author Sean Owen
|
9
|
+
*/
|
10
|
+
export default class Decoder {
|
11
|
+
private rsDecoder;
|
12
|
+
constructor();
|
13
|
+
/**
|
14
|
+
* <p>Convenience method that can decode a QR Code represented as a 2D array of booleans.
|
15
|
+
* "true" is taken to mean a black module.</p>
|
16
|
+
*
|
17
|
+
* @param image booleans representing white/black QR Code modules
|
18
|
+
* @param hints decoding hints that should be used to influence decoding
|
19
|
+
* @return text and bytes encoded within the QR Code
|
20
|
+
* @throws FormatException if the QR Code cannot be decoded
|
21
|
+
* @throws ChecksumException if error correction fails
|
22
|
+
*/
|
23
|
+
decodeBooleanArray(image: boolean[][], hints?: Map<DecodeHintType, any>): DecoderResult;
|
24
|
+
/**
|
25
|
+
* <p>Decodes a QR Code represented as a {@link BitMatrix}. A 1 or "true" is taken to mean a black module.</p>
|
26
|
+
*
|
27
|
+
* @param bits booleans representing white/black QR Code modules
|
28
|
+
* @param hints decoding hints that should be used to influence decoding
|
29
|
+
* @return text and bytes encoded within the QR Code
|
30
|
+
* @throws FormatException if the QR Code cannot be decoded
|
31
|
+
* @throws ChecksumException if error correction fails
|
32
|
+
*/
|
33
|
+
decodeBitMatrix(bits: BitMatrix, hints?: Map<DecodeHintType, any>): DecoderResult;
|
34
|
+
private decodeBitMatrixParser;
|
35
|
+
/**
|
36
|
+
* <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
|
37
|
+
* correct the errors in-place using Reed-Solomon error correction.</p>
|
38
|
+
*
|
39
|
+
* @param codewordBytes data and error correction codewords
|
40
|
+
* @param numDataCodewords number of codewords that are data bytes
|
41
|
+
* @throws ChecksumException if error correction fails
|
42
|
+
*/
|
43
|
+
private correctErrors;
|
44
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/**
|
2
|
+
* <p>Encapsulates the parameters for one error-correction block in one symbol version.
|
3
|
+
* This includes the number of data codewords, and the number of times a block with these
|
4
|
+
* parameters is used consecutively in the QR code version's format.</p>
|
5
|
+
*/
|
6
|
+
export default class ECB {
|
7
|
+
private count;
|
8
|
+
private dataCodewords;
|
9
|
+
constructor(count: number, dataCodewords: number);
|
10
|
+
getCount(): number;
|
11
|
+
getDataCodewords(): number;
|
12
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import ECB from './ECB';
|
2
|
+
/**
|
3
|
+
* <p>Encapsulates a set of error-correction blocks in one symbol version. Most versions will
|
4
|
+
* use blocks of differing sizes within one version, so, this encapsulates the parameters for
|
5
|
+
* each set of blocks. It also holds the number of error-correction codewords per block since it
|
6
|
+
* will be the same across all blocks within one version.</p>
|
7
|
+
*/
|
8
|
+
export default class ECBlocks {
|
9
|
+
private ecCodewordsPerBlock;
|
10
|
+
private ecBlocks;
|
11
|
+
constructor(ecCodewordsPerBlock: number, ...ecBlocks: ECB[]);
|
12
|
+
getECCodewordsPerBlock(): number;
|
13
|
+
getNumBlocks(): number;
|
14
|
+
getTotalECCodewords(): number;
|
15
|
+
getECBlocks(): ECB[];
|
16
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
export declare enum ErrorCorrectionLevelValues {
|
2
|
+
L = 0,
|
3
|
+
M = 1,
|
4
|
+
Q = 2,
|
5
|
+
H = 3
|
6
|
+
}
|
7
|
+
/**
|
8
|
+
* <p>See ISO 18004:2006, 6.5.1. This enum encapsulates the four error correction levels
|
9
|
+
* defined by the QR code standard.</p>
|
10
|
+
*
|
11
|
+
* @author Sean Owen
|
12
|
+
*/
|
13
|
+
export default class ErrorCorrectionLevel {
|
14
|
+
private value;
|
15
|
+
private stringValue;
|
16
|
+
private bits;
|
17
|
+
private static FOR_BITS;
|
18
|
+
private static FOR_VALUE;
|
19
|
+
/** L = ~7% correction */
|
20
|
+
static L: ErrorCorrectionLevel;
|
21
|
+
/** M = ~15% correction */
|
22
|
+
static M: ErrorCorrectionLevel;
|
23
|
+
/** Q = ~25% correction */
|
24
|
+
static Q: ErrorCorrectionLevel;
|
25
|
+
/** H = ~30% correction */
|
26
|
+
static H: ErrorCorrectionLevel;
|
27
|
+
private constructor();
|
28
|
+
getValue(): ErrorCorrectionLevelValues;
|
29
|
+
getBits(): number;
|
30
|
+
static fromString(s: string): ErrorCorrectionLevel;
|
31
|
+
toString(): string;
|
32
|
+
equals(o: any): boolean;
|
33
|
+
/**
|
34
|
+
* @param bits int containing the two bits encoding a QR Code's error correction level
|
35
|
+
* @return ErrorCorrectionLevel representing the encoded error correction level
|
36
|
+
*/
|
37
|
+
static forBits(bits: number): ErrorCorrectionLevel;
|
38
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import ErrorCorrectionLevel from './ErrorCorrectionLevel';
|
2
|
+
/**
|
3
|
+
* <p>Encapsulates a QR Code's format information, including the data mask used and
|
4
|
+
* error correction level.</p>
|
5
|
+
*
|
6
|
+
* @author Sean Owen
|
7
|
+
* @see DataMask
|
8
|
+
* @see ErrorCorrectionLevel
|
9
|
+
*/
|
10
|
+
export default class FormatInformation {
|
11
|
+
private static FORMAT_INFO_MASK_QR;
|
12
|
+
/**
|
13
|
+
* See ISO 18004:2006, Annex C, Table C.1
|
14
|
+
*/
|
15
|
+
private static FORMAT_INFO_DECODE_LOOKUP;
|
16
|
+
private errorCorrectionLevel;
|
17
|
+
private dataMask;
|
18
|
+
private constructor();
|
19
|
+
static numBitsDiffering(a: number, b: number): number;
|
20
|
+
/**
|
21
|
+
* @param maskedFormatInfo1 format info indicator, with mask still applied
|
22
|
+
* @param maskedFormatInfo2 second copy of same info; both are checked at the same time
|
23
|
+
* to establish best match
|
24
|
+
* @return information about the format it specifies, or {@code null}
|
25
|
+
* if doesn't seem to match any known pattern
|
26
|
+
*/
|
27
|
+
static decodeFormatInformation(maskedFormatInfo1: number, maskedFormatInfo2: number): FormatInformation | null;
|
28
|
+
private static doDecodeFormatInformation;
|
29
|
+
getErrorCorrectionLevel(): ErrorCorrectionLevel;
|
30
|
+
getDataMask(): number;
|
31
|
+
hashCode(): number;
|
32
|
+
equals(o: Object): boolean;
|
33
|
+
}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import Version from './Version';
|
2
|
+
export declare enum ModeValues {
|
3
|
+
TERMINATOR = 0,// Not really a mode...
|
4
|
+
NUMERIC = 1,
|
5
|
+
ALPHANUMERIC = 2,
|
6
|
+
STRUCTURED_APPEND = 3,// Not supported
|
7
|
+
BYTE = 4,
|
8
|
+
ECI = 5,// character counts don't apply
|
9
|
+
KANJI = 6,
|
10
|
+
FNC1_FIRST_POSITION = 7,
|
11
|
+
FNC1_SECOND_POSITION = 8,
|
12
|
+
/** See GBT 18284-2000; "Hanzi" is a transliteration of this mode name. */
|
13
|
+
HANZI = 9
|
14
|
+
}
|
15
|
+
/**
|
16
|
+
* <p>See ISO 18004:2006, 6.4.1, Tables 2 and 3. This enum encapsulates the various modes in which
|
17
|
+
* data can be encoded to bits in the QR code standard.</p>
|
18
|
+
*
|
19
|
+
* @author Sean Owen
|
20
|
+
*/
|
21
|
+
export default class Mode {
|
22
|
+
private value;
|
23
|
+
private stringValue;
|
24
|
+
private characterCountBitsForVersions;
|
25
|
+
private bits;
|
26
|
+
private static FOR_BITS;
|
27
|
+
private static FOR_VALUE;
|
28
|
+
static TERMINATOR: Mode;
|
29
|
+
static NUMERIC: Mode;
|
30
|
+
static ALPHANUMERIC: Mode;
|
31
|
+
static STRUCTURED_APPEND: Mode;
|
32
|
+
static BYTE: Mode;
|
33
|
+
static ECI: Mode;
|
34
|
+
static KANJI: Mode;
|
35
|
+
static FNC1_FIRST_POSITION: Mode;
|
36
|
+
static FNC1_SECOND_POSITION: Mode;
|
37
|
+
/** See GBT 18284-2000; "Hanzi" is a transliteration of this mode name. */
|
38
|
+
static HANZI: Mode;
|
39
|
+
private constructor();
|
40
|
+
/**
|
41
|
+
* @param bits four bits encoding a QR Code data mode
|
42
|
+
* @return Mode encoded by these bits
|
43
|
+
* @throws IllegalArgumentException if bits do not correspond to a known mode
|
44
|
+
*/
|
45
|
+
static forBits(bits: number): Mode;
|
46
|
+
/**
|
47
|
+
* @param version version in question
|
48
|
+
* @return number of bits used, in this QR Code symbol {@link Version}, to encode the
|
49
|
+
* count of characters that will follow encoded in this Mode
|
50
|
+
*/
|
51
|
+
getCharacterCountBits(version: Version): number;
|
52
|
+
getValue(): ModeValues;
|
53
|
+
getBits(): number;
|
54
|
+
equals(o: any): boolean;
|
55
|
+
toString(): string;
|
56
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import ResultPoint from '../../ResultPoint';
|
2
|
+
/**
|
3
|
+
* Meta-data container for QR Code decoding. Instances of this class may be used to convey information back to the
|
4
|
+
* decoding caller. Callers are expected to process this.
|
5
|
+
*
|
6
|
+
* @see com.google.zxing.common.DecoderResult#getOther()
|
7
|
+
*/
|
8
|
+
export default class QRCodeDecoderMetaData {
|
9
|
+
private mirrored;
|
10
|
+
constructor(mirrored: boolean);
|
11
|
+
/**
|
12
|
+
* @return true if the QR Code was mirrored.
|
13
|
+
*/
|
14
|
+
isMirrored(): boolean;
|
15
|
+
/**
|
16
|
+
* Apply the result points' order correction due to mirroring.
|
17
|
+
*
|
18
|
+
* @param points Array of points to apply mirror correction to.
|
19
|
+
*/
|
20
|
+
applyMirroredCorrection(points: Array<ResultPoint>): void;
|
21
|
+
}
|