@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,91 @@
|
|
1
|
+
/**
|
2
|
+
* Encapsulates a type of hint that a caller may pass to a barcode reader to help it
|
3
|
+
* more quickly or accurately decode it. It is up to implementations to decide what,
|
4
|
+
* if anything, to do with the information that is supplied.
|
5
|
+
*
|
6
|
+
* @author Sean Owen
|
7
|
+
* @author dswitkin@google.com (Daniel Switkin)
|
8
|
+
* @see Reader#decode(BinaryBitmap,java.util.Map)
|
9
|
+
*/
|
10
|
+
declare enum DecodeHintType {
|
11
|
+
/**
|
12
|
+
* Unspecified, application-specific hint. Maps to an unspecified {@link Object}.
|
13
|
+
*/
|
14
|
+
OTHER = 0,
|
15
|
+
/**
|
16
|
+
* Image is a pure monochrome image of a barcode. Doesn't matter what it maps to;
|
17
|
+
* use {@link Boolean#TRUE}.
|
18
|
+
*/
|
19
|
+
PURE_BARCODE = 1,
|
20
|
+
/**
|
21
|
+
* Image is known to be of one of a few possible formats.
|
22
|
+
* Maps to a {@link List} of {@link BarcodeFormat}s.
|
23
|
+
*/
|
24
|
+
POSSIBLE_FORMATS = 2,
|
25
|
+
/**
|
26
|
+
* Spend more time to try to find a barcode; optimize for accuracy, not speed.
|
27
|
+
* Doesn't matter what it maps to; use {@link Boolean#TRUE}.
|
28
|
+
*/
|
29
|
+
TRY_HARDER = 3,
|
30
|
+
/**
|
31
|
+
* Specifies what character encoding to use when decoding, where applicable (type String)
|
32
|
+
*/
|
33
|
+
CHARACTER_SET = 4,
|
34
|
+
/**
|
35
|
+
* Allowed lengths of encoded data -- reject anything else. Maps to an {@code Int32Array}.
|
36
|
+
*/
|
37
|
+
ALLOWED_LENGTHS = 5,
|
38
|
+
/**
|
39
|
+
* Assume Code 39 codes employ a check digit. Doesn't matter what it maps to;
|
40
|
+
* use {@link Boolean#TRUE}.
|
41
|
+
*/
|
42
|
+
ASSUME_CODE_39_CHECK_DIGIT = 6,
|
43
|
+
/**
|
44
|
+
* Enable extended mode for Code 39 codes. Doesn't matter what it maps to;
|
45
|
+
* use {@link Boolean#TRUE}.
|
46
|
+
*/
|
47
|
+
ENABLE_CODE_39_EXTENDED_MODE = 7,
|
48
|
+
/**
|
49
|
+
* Assume the barcode is being processed as a GS1 barcode, and modify behavior as needed.
|
50
|
+
* For example this affects FNC1 handling for Code 128 (aka GS1-128). Doesn't matter what it maps to;
|
51
|
+
* use {@link Boolean#TRUE}.
|
52
|
+
*/
|
53
|
+
ASSUME_GS1 = 8,
|
54
|
+
/**
|
55
|
+
* If true, return the start and end digits in a Codabar barcode instead of stripping them. They
|
56
|
+
* are alpha, whereas the rest are numeric. By default, they are stripped, but this causes them
|
57
|
+
* to not be. Doesn't matter what it maps to; use {@link Boolean#TRUE}.
|
58
|
+
*/
|
59
|
+
RETURN_CODABAR_START_END = 9,
|
60
|
+
/**
|
61
|
+
* The caller needs to be notified via callback when a possible {@link ResultPoint}
|
62
|
+
* is found. Maps to a {@link ResultPointCallback}.
|
63
|
+
*/
|
64
|
+
NEED_RESULT_POINT_CALLBACK = 10,
|
65
|
+
/**
|
66
|
+
* Allowed extension lengths for EAN or UPC barcodes. Other formats will ignore this.
|
67
|
+
* Maps to an {@code Int32Array} of the allowed extension lengths, for example [2], [5], or [2, 5].
|
68
|
+
* If it is optional to have an extension, do not set this hint. If this is set,
|
69
|
+
* and a UPC or EAN barcode is found but an extension is not, then no result will be returned
|
70
|
+
* at all.
|
71
|
+
*/
|
72
|
+
ALLOWED_EAN_EXTENSIONS
|
73
|
+
/**
|
74
|
+
* Data type the hint is expecting.
|
75
|
+
* Among the possible values the {@link Void} stands out as being used for
|
76
|
+
* hints that do not expect a value to be supplied (flag hints). Such hints
|
77
|
+
* will possibly have their value ignored, or replaced by a
|
78
|
+
* {@link Boolean#TRUE}. Hint suppliers should probably use
|
79
|
+
* {@link Boolean#TRUE} as directed by the actual hint documentation.
|
80
|
+
*/
|
81
|
+
= 11
|
82
|
+
/**
|
83
|
+
* Data type the hint is expecting.
|
84
|
+
* Among the possible values the {@link Void} stands out as being used for
|
85
|
+
* hints that do not expect a value to be supplied (flag hints). Such hints
|
86
|
+
* will possibly have their value ignored, or replaced by a
|
87
|
+
* {@link Boolean#TRUE}. Hint suppliers should probably use
|
88
|
+
* {@link Boolean#TRUE} as directed by the actual hint documentation.
|
89
|
+
*/
|
90
|
+
}
|
91
|
+
export default DecodeHintType;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { CustomError } from 'ts-custom-error';
|
2
|
+
/**
|
3
|
+
* Custom Error class of type Exception.
|
4
|
+
*/
|
5
|
+
export default class Exception extends CustomError {
|
6
|
+
message: string | undefined;
|
7
|
+
/**
|
8
|
+
* It's typed as string so it can be extended and overriden.
|
9
|
+
*/
|
10
|
+
static readonly kind: string;
|
11
|
+
/**
|
12
|
+
* Allows Exception to be constructed directly
|
13
|
+
* with some message and prototype definition.
|
14
|
+
*/
|
15
|
+
constructor(message?: string | undefined);
|
16
|
+
getKind(): string;
|
17
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import LuminanceSource from './LuminanceSource';
|
2
|
+
/**
|
3
|
+
* A wrapper implementation of LuminanceSource which converts the source image
|
4
|
+
* into a high contrast (binary) image using a fixed threshold. Pixels with a value
|
5
|
+
* below the threshold become black (0) and those equal to or above become white (255).
|
6
|
+
*/
|
7
|
+
export default class HighContrastLuminanceSource extends LuminanceSource {
|
8
|
+
private delegate;
|
9
|
+
private threshold;
|
10
|
+
constructor(delegate: LuminanceSource, threshold?: number);
|
11
|
+
getRow(y: number, row?: Uint8ClampedArray): Uint8ClampedArray;
|
12
|
+
getMatrix(): Uint8ClampedArray;
|
13
|
+
isCropSupported(): boolean;
|
14
|
+
crop(left: number, top: number, width: number, height: number): LuminanceSource;
|
15
|
+
isRotateSupported(): boolean;
|
16
|
+
rotateCounterClockwise(): LuminanceSource;
|
17
|
+
rotateCounterClockwise45(): LuminanceSource;
|
18
|
+
/**
|
19
|
+
* Inverts the high contrast image. This wraps the current instance with InvertedLuminanceSource,
|
20
|
+
* which effectively swaps black and white.
|
21
|
+
*/
|
22
|
+
invert(): LuminanceSource;
|
23
|
+
/**
|
24
|
+
* Since this source is already high contrast, calling highContrast() returns itself.
|
25
|
+
*/
|
26
|
+
highContrast(): LuminanceSource;
|
27
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import LuminanceSource from './LuminanceSource';
|
2
|
+
/**
|
3
|
+
* A wrapper implementation of {@link LuminanceSource} which inverts the luminances it returns -- black becomes
|
4
|
+
* white and vice versa, and each value becomes (255-value).
|
5
|
+
*
|
6
|
+
* @author Sean Owen
|
7
|
+
*/
|
8
|
+
export default class InvertedLuminanceSource extends LuminanceSource {
|
9
|
+
private delegate;
|
10
|
+
constructor(delegate: LuminanceSource);
|
11
|
+
getRow(y: number, row?: Uint8ClampedArray): Uint8ClampedArray;
|
12
|
+
getMatrix(): Uint8ClampedArray;
|
13
|
+
isCropSupported(): boolean;
|
14
|
+
crop(left: number, top: number, width: number, height: number): LuminanceSource;
|
15
|
+
isRotateSupported(): boolean;
|
16
|
+
/**
|
17
|
+
* @return original delegate {@link LuminanceSource} since invert undoes itself
|
18
|
+
*/
|
19
|
+
invert(): LuminanceSource;
|
20
|
+
rotateCounterClockwise(): LuminanceSource;
|
21
|
+
rotateCounterClockwise45(): LuminanceSource;
|
22
|
+
}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
/**
|
2
|
+
* The purpose of this class hierarchy is to abstract different bitmap implementations across
|
3
|
+
* platforms into a standard interface for requesting greyscale luminance values. The interface
|
4
|
+
* only provides immutable methods; therefore crop and rotation create copies. This is to ensure
|
5
|
+
* that one Reader does not modify the original luminance source and leave it in an unknown state
|
6
|
+
* for other Readers in the chain.
|
7
|
+
*
|
8
|
+
* @author dswitkin@google.com (Daniel Switkin)
|
9
|
+
*/
|
10
|
+
declare abstract class LuminanceSource {
|
11
|
+
private width;
|
12
|
+
private height;
|
13
|
+
protected constructor(width: number, height: number);
|
14
|
+
/**
|
15
|
+
* Fetches one row of luminance data from the underlying platform's bitmap. Values range from
|
16
|
+
* 0 (black) to 255 (white). Because Java does not have an unsigned byte type, callers will have
|
17
|
+
* to bitwise and with 0xff for each value. It is preferable for implementations of this method
|
18
|
+
* to only fetch this row rather than the whole image, since no 2D Readers may be installed and
|
19
|
+
* getMatrix() may never be called.
|
20
|
+
*
|
21
|
+
* @param y The row to fetch, which must be in [0,getHeight())
|
22
|
+
* @param row An optional preallocated array. If null or too small, it will be ignored.
|
23
|
+
* Always use the returned object, and ignore the .length of the array.
|
24
|
+
* @return An array containing the luminance data.
|
25
|
+
*/
|
26
|
+
abstract getRow(y: number, row?: Uint8ClampedArray): Uint8ClampedArray;
|
27
|
+
/**
|
28
|
+
* Fetches luminance data for the underlying bitmap. Values should be fetched using:
|
29
|
+
* {@code int luminance = array[y * width + x] & 0xff}
|
30
|
+
*
|
31
|
+
* @return A row-major 2D array of luminance values. Do not use result.length as it may be
|
32
|
+
* larger than width * height bytes on some platforms. Do not modify the contents
|
33
|
+
* of the result.
|
34
|
+
*/
|
35
|
+
abstract getMatrix(): Uint8ClampedArray;
|
36
|
+
/**
|
37
|
+
* @return The width of the bitmap.
|
38
|
+
*/
|
39
|
+
getWidth(): number;
|
40
|
+
/**
|
41
|
+
* @return The height of the bitmap.
|
42
|
+
*/
|
43
|
+
getHeight(): number;
|
44
|
+
/**
|
45
|
+
* @return Whether this subclass supports cropping.
|
46
|
+
*/
|
47
|
+
isCropSupported(): boolean;
|
48
|
+
/**
|
49
|
+
* Returns a new object with cropped image data. Implementations may keep a reference to the
|
50
|
+
* original data rather than a copy. Only callable if isCropSupported() is true.
|
51
|
+
*
|
52
|
+
* @param left The left coordinate, which must be in [0,getWidth())
|
53
|
+
* @param top The top coordinate, which must be in [0,getHeight())
|
54
|
+
* @param width The width of the rectangle to crop.
|
55
|
+
* @param height The height of the rectangle to crop.
|
56
|
+
* @return A cropped version of this object.
|
57
|
+
*/
|
58
|
+
crop(left: number, top: number, width: number, height: number): LuminanceSource;
|
59
|
+
/**
|
60
|
+
* @return Whether this subclass supports counter-clockwise rotation.
|
61
|
+
*/
|
62
|
+
isRotateSupported(): boolean;
|
63
|
+
/**
|
64
|
+
* @return a wrapper of this {@code LuminanceSource} which inverts the luminances it returns -- black becomes
|
65
|
+
* white and vice versa, and each value becomes (255-value).
|
66
|
+
*/
|
67
|
+
abstract invert(): LuminanceSource;
|
68
|
+
/**
|
69
|
+
* Returns a new object with rotated image data by 90 degrees counterclockwise.
|
70
|
+
* Only callable if {@link #isRotateSupported()} is true.
|
71
|
+
*
|
72
|
+
* @return A rotated version of this object.
|
73
|
+
*/
|
74
|
+
rotateCounterClockwise(): LuminanceSource;
|
75
|
+
/**
|
76
|
+
* Returns a new object with rotated image data by 45 degrees counterclockwise.
|
77
|
+
* Only callable if {@link #isRotateSupported()} is true.
|
78
|
+
*
|
79
|
+
* @return A rotated version of this object.
|
80
|
+
*/
|
81
|
+
rotateCounterClockwise45(): LuminanceSource;
|
82
|
+
toString(): string;
|
83
|
+
}
|
84
|
+
export default LuminanceSource;
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import LuminanceSource from './LuminanceSource';
|
2
|
+
/**
|
3
|
+
* NodeLuminanceSource replicates the behavior of HTMLCanvasElementLuminanceSource
|
4
|
+
* but uses Sharp to obtain image data from a Buffer.
|
5
|
+
*/
|
6
|
+
export declare class NodeLuminanceSource extends LuminanceSource {
|
7
|
+
private buffer;
|
8
|
+
private constructor();
|
9
|
+
/**
|
10
|
+
* Asynchronously creates a NodeLuminanceSource from an image buffer.
|
11
|
+
* Can handle standard image formats (PNG/JPEG via Jimp) or raw RGBA buffers.
|
12
|
+
* @param bufferInput - The image data as a Buffer (PNG, JPEG, or raw RGBA).
|
13
|
+
* @param isPngOrJpeg - Flag indicating if the buffer is a standard format (true) or raw RGBA (false).
|
14
|
+
* @param width - Required width if bufferInput is raw RGBA.
|
15
|
+
* @param height - Required height if bufferInput is raw RGBA.
|
16
|
+
* @param doAutoInvert - If true, computes an inverted grayscale buffer (only relevant for grayscale conversion).
|
17
|
+
*/
|
18
|
+
static create(bufferInput: Buffer, isPngOrJpeg: boolean, // Renamed from isPng for clarity
|
19
|
+
width?: number, // Optional width
|
20
|
+
height?: number, // Optional height
|
21
|
+
doAutoInvert?: boolean): Promise<NodeLuminanceSource>;
|
22
|
+
/**
|
23
|
+
* Converts raw RGBA data to a grayscale buffer.
|
24
|
+
* If doAutoInvert is true, each computed luminance is inverted.
|
25
|
+
*/
|
26
|
+
private static toGrayscaleBuffer;
|
27
|
+
getRow(y: number, row?: Uint8ClampedArray): Uint8ClampedArray;
|
28
|
+
getMatrix(): Uint8ClampedArray;
|
29
|
+
isCropSupported(): boolean;
|
30
|
+
crop(left: number, top: number, width: number, height: number): LuminanceSource;
|
31
|
+
isRotateSupported(): boolean;
|
32
|
+
invert(): LuminanceSource;
|
33
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import BinaryBitmap from './BinaryBitmap';
|
2
|
+
import DecodeHintType from './DecodeHintType';
|
3
|
+
import Result from './Result';
|
4
|
+
export default Reader;
|
5
|
+
/**
|
6
|
+
* Implementations of this interface can decode an image of a barcode in some format into
|
7
|
+
* the it: string encodes. For example, {@link com.google.zxing.qrcode.QRCodeReader} can
|
8
|
+
* decode a QR code. The decoder may optionally receive hints from the caller which may help
|
9
|
+
* it decode more quickly or accurately.
|
10
|
+
*
|
11
|
+
* See {@link MultiFormatReader}, which attempts to determine what barcode
|
12
|
+
* format is present within the image as well, and then decodes it accordingly.
|
13
|
+
*
|
14
|
+
* @author Sean Owen
|
15
|
+
* @author dswitkin@google.com (Daniel Switkin)
|
16
|
+
*/
|
17
|
+
interface Reader {
|
18
|
+
/**
|
19
|
+
* Locates and decodes a barcode in some format within an image.
|
20
|
+
*
|
21
|
+
* @param image image of barcode to decode
|
22
|
+
* @return which: string the barcode encodes
|
23
|
+
* @throws NotFoundException if no potential barcode is found
|
24
|
+
* @throws ChecksumException if a potential barcode is found but does not pass its checksum
|
25
|
+
* @throws FormatException if a potential barcode is found but format is invalid
|
26
|
+
*/
|
27
|
+
/**
|
28
|
+
* Locates and decodes a barcode in some format within an image. This method also accepts
|
29
|
+
* hints, each possibly associated to some data, which may help the implementation decode.
|
30
|
+
*
|
31
|
+
* @param image image of barcode to decode
|
32
|
+
* @param hints passed as a {@link Map} from {@link DecodeHintType}
|
33
|
+
* to arbitrary data. The
|
34
|
+
* meaning of the data depends upon the hint type. The implementation may or may not do
|
35
|
+
* anything with these hints.
|
36
|
+
*
|
37
|
+
* @return which: string the barcode encodes
|
38
|
+
*
|
39
|
+
* @throws NotFoundException if no potential barcode is found
|
40
|
+
* @throws ChecksumException if a potential barcode is found but does not pass its checksum
|
41
|
+
* @throws FormatException if a potential barcode is found but format is invalid
|
42
|
+
*/
|
43
|
+
decode(image: BinaryBitmap, hints?: Map<DecodeHintType, any> | null): Result;
|
44
|
+
/**
|
45
|
+
* Resets any internal state the implementation has after a decode, to prepare it
|
46
|
+
* for reuse.
|
47
|
+
*/
|
48
|
+
reset(): void;
|
49
|
+
}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import BarcodeFormat from './BarcodeFormat';
|
2
|
+
import ResultMetadataType from './ResultMetadataType';
|
3
|
+
import ResultPoint from './ResultPoint';
|
4
|
+
/**
|
5
|
+
* <p>Encapsulates the result of decoding a barcode within an image.</p>
|
6
|
+
*
|
7
|
+
* @author Sean Owen
|
8
|
+
*/
|
9
|
+
export default class Result {
|
10
|
+
text: string | null;
|
11
|
+
rawBytes: Uint8Array;
|
12
|
+
private numBits;
|
13
|
+
private resultPoints;
|
14
|
+
format: BarcodeFormat;
|
15
|
+
private timestamp;
|
16
|
+
private resultMetadata;
|
17
|
+
constructor(text: string | null | undefined, rawBytes: Uint8Array, numBits: number | undefined, resultPoints: ResultPoint[], format: BarcodeFormat, timestamp?: number);
|
18
|
+
/**
|
19
|
+
* @return raw text encoded by the barcode
|
20
|
+
*/
|
21
|
+
getText(): string | null;
|
22
|
+
/**
|
23
|
+
* @return raw bytes encoded by the barcode, if applicable, otherwise {@code null}
|
24
|
+
*/
|
25
|
+
getRawBytes(): Uint8Array;
|
26
|
+
/**
|
27
|
+
* @return how many bits of {@link #getRawBytes()} are valid; typically 8 times its length
|
28
|
+
* @since 3.3.0
|
29
|
+
*/
|
30
|
+
getNumBits(): number;
|
31
|
+
/**
|
32
|
+
* @return points related to the barcode in the image. These are typically points
|
33
|
+
* identifying finder patterns or the corners of the barcode. The exact meaning is
|
34
|
+
* specific to the type of barcode that was decoded.
|
35
|
+
*/
|
36
|
+
getResultPoints(): ResultPoint[];
|
37
|
+
/**
|
38
|
+
* @return The format of the barcode that was decoded
|
39
|
+
*/
|
40
|
+
getBarcodeFormat(): BarcodeFormat;
|
41
|
+
/**
|
42
|
+
* @return Mapping keys to values. May be
|
43
|
+
* This contains optional metadata about what was detected about the barcode,
|
44
|
+
* like orientation.
|
45
|
+
*/
|
46
|
+
getResultMetadata(): Map<ResultMetadataType, object>;
|
47
|
+
putMetadata(type: ResultMetadataType, value: object): void;
|
48
|
+
putAllMetadata(metadata: Map<ResultMetadataType, object>): void;
|
49
|
+
addResultPoints(newPoints: ResultPoint[]): void;
|
50
|
+
getTimestamp(): number;
|
51
|
+
toString(): string | null;
|
52
|
+
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
/**
|
2
|
+
* Represents some type of metadata about the result of the decoding that the decoder
|
3
|
+
* wishes to communicate back to the caller.
|
4
|
+
*
|
5
|
+
* @author Sean Owen
|
6
|
+
*/
|
7
|
+
declare enum ResultMetadataType {
|
8
|
+
/**
|
9
|
+
* Unspecified, application-specific metadata. Maps to an unspecified {@link Object}.
|
10
|
+
*/
|
11
|
+
OTHER = 0,
|
12
|
+
/**
|
13
|
+
* Denotes the likely approximate orientation of the barcode in the image. This value
|
14
|
+
* is given as degrees rotated clockwise from the normal, upright orientation.
|
15
|
+
* For example a 1D barcode which was found by reading top-to-bottom would be
|
16
|
+
* said to have orientation "90". This key maps to an {@link Integer} whose
|
17
|
+
* value is in the range [0,360).
|
18
|
+
*/
|
19
|
+
ORIENTATION = 1,
|
20
|
+
/**
|
21
|
+
* <p>2D barcode formats typically encode text, but allow for a sort of 'byte mode'
|
22
|
+
* which is sometimes used to encode binary data. While {@link Result} makes available
|
23
|
+
* the complete raw bytes in the barcode for these formats, it does not offer the bytes
|
24
|
+
* from the byte segments alone.</p>
|
25
|
+
*
|
26
|
+
* <p>This maps to a {@link java.util.List} of byte arrays corresponding to the
|
27
|
+
* raw bytes in the byte segments in the barcode, in order.</p>
|
28
|
+
*/
|
29
|
+
BYTE_SEGMENTS = 2,
|
30
|
+
/**
|
31
|
+
* Error correction level used, if applicable. The value type depends on the
|
32
|
+
* format, but is typically a String.
|
33
|
+
*/
|
34
|
+
ERROR_CORRECTION_LEVEL = 3,
|
35
|
+
/**
|
36
|
+
* For some periodicals, indicates the issue number as an {@link Integer}.
|
37
|
+
*/
|
38
|
+
ISSUE_NUMBER = 4,
|
39
|
+
/**
|
40
|
+
* For some products, indicates the suggested retail price in the barcode as a
|
41
|
+
* formatted {@link String}.
|
42
|
+
*/
|
43
|
+
SUGGESTED_PRICE = 5,
|
44
|
+
/**
|
45
|
+
* For some products, the possible country of manufacture as a {@link String} denoting the
|
46
|
+
* ISO country code. Some map to multiple possible countries, like "US/CA".
|
47
|
+
*/
|
48
|
+
POSSIBLE_COUNTRY = 6,
|
49
|
+
/**
|
50
|
+
* For some products, the extension text
|
51
|
+
*/
|
52
|
+
UPC_EAN_EXTENSION = 7,
|
53
|
+
/**
|
54
|
+
* PDF417-specific metadata
|
55
|
+
*/
|
56
|
+
PDF417_EXTRA_METADATA = 8,
|
57
|
+
/**
|
58
|
+
* If the code format supports structured append and the current scanned code is part of one then the
|
59
|
+
* sequence number is given with it.
|
60
|
+
*/
|
61
|
+
STRUCTURED_APPEND_SEQUENCE = 9,
|
62
|
+
/**
|
63
|
+
* If the code format supports structured append and the current scanned code is part of one then the
|
64
|
+
* parity is given with it.
|
65
|
+
*/
|
66
|
+
STRUCTURED_APPEND_PARITY = 10
|
67
|
+
}
|
68
|
+
export default ResultMetadataType;
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { float, int } from '../customTypings';
|
2
|
+
/**
|
3
|
+
* <p>Encapsulates a point of interest in an image containing a barcode. Typically, this
|
4
|
+
* would be the location of a finder pattern or the corner of the barcode, for example.</p>
|
5
|
+
*
|
6
|
+
* @author Sean Owen
|
7
|
+
*/
|
8
|
+
export default class ResultPoint {
|
9
|
+
private x;
|
10
|
+
private y;
|
11
|
+
constructor(x: float, y: float);
|
12
|
+
getX(): float;
|
13
|
+
getY(): float;
|
14
|
+
equals(other: object): boolean;
|
15
|
+
hashCode(): int;
|
16
|
+
toString(): string;
|
17
|
+
/**
|
18
|
+
* Orders an array of three ResultPoints in an order [A,B,C] such that AB is less than AC
|
19
|
+
* and BC is less than AC, and the angle between BC and BA is less than 180 degrees.
|
20
|
+
*
|
21
|
+
* @param patterns array of three {@code ResultPoint} to order
|
22
|
+
*/
|
23
|
+
static orderBestPatterns(patterns: ResultPoint[]): void;
|
24
|
+
/**
|
25
|
+
* @param pattern1 first pattern
|
26
|
+
* @param pattern2 second pattern
|
27
|
+
* @return distance between two points
|
28
|
+
*/
|
29
|
+
static distance(pattern1: ResultPoint, pattern2: ResultPoint): float;
|
30
|
+
/**
|
31
|
+
* Returns the z component of the cross product between vectors BC and BA.
|
32
|
+
*/
|
33
|
+
private static crossProductZ;
|
34
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import ResultPoint from './ResultPoint';
|
2
|
+
export default ResultPointCallback;
|
3
|
+
/**
|
4
|
+
* Callback which is invoked when a possible result point (significant
|
5
|
+
* point in the barcode image such as a corner) is found.
|
6
|
+
*
|
7
|
+
* @see DecodeHintType#NEED_RESULT_POINT_CALLBACK
|
8
|
+
*/
|
9
|
+
interface ResultPointCallback {
|
10
|
+
foundPossibleResultPoint(point: ResultPoint): void;
|
11
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import LuminanceSource from './LuminanceSource';
|
2
|
+
/**
|
3
|
+
* NodeLuminanceSource replicates the behavior of a LuminanceSource
|
4
|
+
* but does NOT use sharp. Instead, you provide raw RGBA data and
|
5
|
+
* we convert it to grayscale internally.
|
6
|
+
*/
|
7
|
+
export declare class UniversalLuminanceSource extends LuminanceSource {
|
8
|
+
private buffer;
|
9
|
+
private _width;
|
10
|
+
private _height;
|
11
|
+
/**
|
12
|
+
* Private constructor; use the static createFromRawRGBA() method below.
|
13
|
+
*/
|
14
|
+
constructor(width: number, height: number, buffer: Uint8ClampedArray);
|
15
|
+
/**
|
16
|
+
* Create a NodeLuminanceSource from raw RGBA data.
|
17
|
+
* @param rgbaData - A Uint8ClampedArray of RGBA bytes (length = width * height * 4).
|
18
|
+
* @param width - Image width in pixels.
|
19
|
+
* @param height - Image height in pixels.
|
20
|
+
* @param doAutoInvert - If true, invert each computed luminance.
|
21
|
+
*/
|
22
|
+
static createFromRawRGBA(rgbaData: Uint8ClampedArray, width: number, height: number, doAutoInvert?: boolean): UniversalLuminanceSource;
|
23
|
+
/**
|
24
|
+
* Converts raw RGBA data to a grayscale buffer (single channel).
|
25
|
+
* If doAutoInvert is true, each computed luminance is inverted.
|
26
|
+
*/
|
27
|
+
private static toGrayscaleBuffer;
|
28
|
+
getWidth(): number;
|
29
|
+
getHeight(): number;
|
30
|
+
getRow(y: number, row?: Uint8ClampedArray): Uint8ClampedArray;
|
31
|
+
getMatrix(): Uint8ClampedArray;
|
32
|
+
isCropSupported(): boolean;
|
33
|
+
/**
|
34
|
+
* Crops a region from the grayscale buffer.
|
35
|
+
*/
|
36
|
+
crop(left: number, top: number, width: number, height: number): LuminanceSource;
|
37
|
+
isRotateSupported(): boolean;
|
38
|
+
rotateCounterClockwise(): LuminanceSource;
|
39
|
+
rotateCounterClockwise45(): LuminanceSource;
|
40
|
+
invert(): LuminanceSource;
|
41
|
+
/**
|
42
|
+
* Rotates the grayscale buffer by the specified angle in degrees.
|
43
|
+
* Supports multiples of 90 only. Throws otherwise.
|
44
|
+
*/
|
45
|
+
private rotate;
|
46
|
+
}
|