@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,58 @@
|
|
1
|
+
import { ErrorCorrectLevel } from './ErrorCorrectLevel.js';
|
2
|
+
import { QRData } from './QRData.js';
|
3
|
+
type TypeNumber = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40;
|
4
|
+
declare const TypeNumber: { [P in TypeNumber]: P; };
|
5
|
+
export { TypeNumber };
|
6
|
+
export declare enum ErrorCorrectionLevel {
|
7
|
+
L = "L",
|
8
|
+
M = "M",
|
9
|
+
Q = "Q",
|
10
|
+
H = "H"
|
11
|
+
}
|
12
|
+
export declare enum Mode {
|
13
|
+
numeric = "numeric",
|
14
|
+
alphanumeric = "alphanumeric",
|
15
|
+
/**
|
16
|
+
* Default
|
17
|
+
*/
|
18
|
+
byte = "byte",
|
19
|
+
kanji = "kanji",
|
20
|
+
unicode = "unicode"
|
21
|
+
}
|
22
|
+
/**
|
23
|
+
* QRCode
|
24
|
+
*
|
25
|
+
* @author Kazuhiko Arase
|
26
|
+
*/
|
27
|
+
export declare class QRCodeMinimal {
|
28
|
+
static stringToBytesFuncs: {
|
29
|
+
[encoding: string]: (s: string) => number[];
|
30
|
+
};
|
31
|
+
private static PAD0;
|
32
|
+
private static PAD1;
|
33
|
+
private typeNumber;
|
34
|
+
private errorCorrectLevel;
|
35
|
+
private qrDataList;
|
36
|
+
private modules;
|
37
|
+
private moduleCount;
|
38
|
+
constructor(typeNumber?: TypeNumber, errorCorrectionLevel?: `${ErrorCorrectionLevel}`);
|
39
|
+
getTypeNumber(): number;
|
40
|
+
setTypeNumber(typeNumber: number): void;
|
41
|
+
getErrorCorrectLevel(): ErrorCorrectLevel;
|
42
|
+
setErrorCorrectLevel(errorCorrectLevel: ErrorCorrectLevel): void;
|
43
|
+
clearData(): void;
|
44
|
+
addData(qrData: QRData | string, mode?: `${Mode}`): void;
|
45
|
+
isDark(row: number, col: number): boolean;
|
46
|
+
getModuleCount(): number;
|
47
|
+
make(): void;
|
48
|
+
private getBestMaskPattern;
|
49
|
+
private makeImpl;
|
50
|
+
private mapData;
|
51
|
+
private setupPositionAdjustPattern;
|
52
|
+
private setupPositionProbePattern;
|
53
|
+
private setupTimingPattern;
|
54
|
+
private setupTypeNumber;
|
55
|
+
private setupTypeInfo;
|
56
|
+
static createData(typeNumber: number, errorCorrectLevel: ErrorCorrectLevel, dataArray: QRData[]): number[];
|
57
|
+
private static createBytes;
|
58
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { BitBuffer } from './BitBuffer.js';
|
2
|
+
import { Mode } from './Mode.js';
|
3
|
+
/**
|
4
|
+
* QRData
|
5
|
+
*
|
6
|
+
* @author Kazuhiko Arase
|
7
|
+
*/
|
8
|
+
export declare abstract class QRData {
|
9
|
+
private mode;
|
10
|
+
private data;
|
11
|
+
constructor(mode: Mode, data: string);
|
12
|
+
getMode(): Mode;
|
13
|
+
getData(): string;
|
14
|
+
abstract getLength(): number;
|
15
|
+
abstract write(buffer: BitBuffer): void;
|
16
|
+
getLengthInBits(typeNumber: number): number;
|
17
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { BitBuffer } from './BitBuffer.js';
|
2
|
+
import { QRData } from './QRData.js';
|
3
|
+
/**
|
4
|
+
* QRKanji(SJIS only)
|
5
|
+
*
|
6
|
+
* @author Kazuhiko Arase
|
7
|
+
*/
|
8
|
+
export declare class QRKanji extends QRData {
|
9
|
+
private stringToBytes;
|
10
|
+
constructor(data: string, stringToBytes: (s: string) => number[]);
|
11
|
+
write(buffer: BitBuffer): void;
|
12
|
+
getLength(): number;
|
13
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/**
|
2
|
+
* QRMath
|
3
|
+
*
|
4
|
+
* @author Kazuhiko Arase
|
5
|
+
*/
|
6
|
+
export declare class QRMath {
|
7
|
+
constructor();
|
8
|
+
static initialize: void;
|
9
|
+
private static EXP_TABLE;
|
10
|
+
private static LOG_TABLE;
|
11
|
+
static glog(n: number): number;
|
12
|
+
static gexp(n: number): number;
|
13
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { BitBuffer } from './BitBuffer.js';
|
2
|
+
import { QRData } from './QRData.js';
|
3
|
+
/**
|
4
|
+
* QRNumber
|
5
|
+
*
|
6
|
+
* @author Kazuhiko Arase
|
7
|
+
*/
|
8
|
+
export declare class QRNumber extends QRData {
|
9
|
+
constructor(data: string);
|
10
|
+
write(buffer: BitBuffer): void;
|
11
|
+
getLength(): number;
|
12
|
+
private static strToNum;
|
13
|
+
private static chatToNum;
|
14
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { ErrorCorrectLevel } from './ErrorCorrectLevel.js';
|
2
|
+
import { Mode } from './Mode.js';
|
3
|
+
import { Polynomial } from './Polynomial.js';
|
4
|
+
import { QRCodeMinimal } from './QRCodeMinimal.js';
|
5
|
+
/**
|
6
|
+
* QRUtil
|
7
|
+
*
|
8
|
+
* @author Kazuhiko Arase
|
9
|
+
*/
|
10
|
+
export declare class QRUtil {
|
11
|
+
constructor();
|
12
|
+
static getPatternPosition(typeNumber: number): number[];
|
13
|
+
private static PATTERN_POSITION_TABLE;
|
14
|
+
private static MAX_LENGTH;
|
15
|
+
static getMaxLength(typeNumber: number, mode: Mode, errorCorrectLevel: ErrorCorrectLevel): number;
|
16
|
+
static getErrorCorrectPolynomial(errorCorrectLength: number): Polynomial;
|
17
|
+
static getMaskFunc(maskPattern: number): (i: number, j: number) => boolean;
|
18
|
+
static getLostPoint(qrCode: QRCodeMinimal): number;
|
19
|
+
static getBCHTypeInfo(data: number): number;
|
20
|
+
static getBCHTypeNumber(data: number): number;
|
21
|
+
private static G15;
|
22
|
+
private static G18;
|
23
|
+
private static G15_MASK;
|
24
|
+
private static getBCHDigit;
|
25
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { ErrorCorrectLevel } from './ErrorCorrectLevel.js';
|
2
|
+
/**
|
3
|
+
* RSBlock
|
4
|
+
*
|
5
|
+
* @author Kazuhiko Arase
|
6
|
+
*/
|
7
|
+
export declare class RSBlock {
|
8
|
+
private totalCount;
|
9
|
+
private dataCount;
|
10
|
+
private static RS_BLOCK_TABLE;
|
11
|
+
constructor(totalCount: number, dataCount: number);
|
12
|
+
getDataCount(): number;
|
13
|
+
getTotalCount(): number;
|
14
|
+
static getRSBlocks(typeNumber: number, errorCorrectLevel: ErrorCorrectLevel): RSBlock[];
|
15
|
+
private static getRsBlockTable;
|
16
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* createStringToBytes
|
3
|
+
*
|
4
|
+
* @author Kazuhiko Arase
|
5
|
+
* @param unicodeData base64 string of byte array.
|
6
|
+
* [16bit Unicode],[16bit Bytes], ...
|
7
|
+
* @param numChars
|
8
|
+
*/
|
9
|
+
export declare function createStringToBytes(unicodeData: string, numChars: number): (s: string) => number[];
|
@@ -0,0 +1 @@
|
|
1
|
+
declare var zbarWasm: {};
|
@@ -0,0 +1,150 @@
|
|
1
|
+
import BinaryBitmap from '../core/BinaryBitmap';
|
2
|
+
import DecodeHintType from '../core/DecodeHintType';
|
3
|
+
import Reader from '../core/Reader';
|
4
|
+
import Result from '../core/Result';
|
5
|
+
import { HTMLVisualMediaElement } from './HTMLVisualMediaElement';
|
6
|
+
/**
|
7
|
+
*
|
8
|
+
* Base class for browser code reader.
|
9
|
+
*/
|
10
|
+
export declare class BrowserCodeReader {
|
11
|
+
protected readonly reader: Reader;
|
12
|
+
protected timeBetweenScansMillis: number;
|
13
|
+
protected _hints?: Map<DecodeHintType, any> | undefined;
|
14
|
+
/**
|
15
|
+
* If navigator is present.
|
16
|
+
*/
|
17
|
+
get hasNavigator(): boolean;
|
18
|
+
/**
|
19
|
+
* If mediaDevices under navigator is supported.
|
20
|
+
*/
|
21
|
+
get isMediaDevicesSuported(): boolean;
|
22
|
+
/**
|
23
|
+
* If enumerateDevices under navigator is supported.
|
24
|
+
*/
|
25
|
+
get canEnumerateDevices(): boolean;
|
26
|
+
/**
|
27
|
+
* Delay time between decode attempts made by the scanner.
|
28
|
+
*/
|
29
|
+
protected _timeBetweenDecodingAttempts: number;
|
30
|
+
/** Time between two decoding tries in milli seconds. */
|
31
|
+
get timeBetweenDecodingAttempts(): number;
|
32
|
+
/**
|
33
|
+
* Change the time span the decoder waits between two decoding tries.
|
34
|
+
*
|
35
|
+
* @param {number} millis Time between two decoding tries in milli seconds.
|
36
|
+
*/
|
37
|
+
set timeBetweenDecodingAttempts(millis: number);
|
38
|
+
/**
|
39
|
+
* The HTML canvas element, used to draw the video or image's frame for decoding.
|
40
|
+
*/
|
41
|
+
protected captureCanvas: HTMLCanvasElement;
|
42
|
+
/**
|
43
|
+
* The HTML canvas element context.
|
44
|
+
*/
|
45
|
+
protected captureCanvasContext: CanvasRenderingContext2D;
|
46
|
+
/**
|
47
|
+
* The HTML image element, used as a fallback for the video element when decoding.
|
48
|
+
*/
|
49
|
+
protected imageElement: HTMLImageElement;
|
50
|
+
/**
|
51
|
+
* Should contain the current registered listener for image loading,
|
52
|
+
* used to unregister that listener when needed.
|
53
|
+
*/
|
54
|
+
protected imageLoadedListener: EventListener;
|
55
|
+
/**
|
56
|
+
* Sets the hints.
|
57
|
+
*/
|
58
|
+
set hints(hints: Map<DecodeHintType, any>);
|
59
|
+
/**
|
60
|
+
* Sets the hints.
|
61
|
+
*/
|
62
|
+
get hints(): Map<DecodeHintType, any>;
|
63
|
+
/**
|
64
|
+
* Creates an instance of BrowserCodeReader.
|
65
|
+
* @param {Reader} reader The reader instance to decode the barcode
|
66
|
+
* @param {number} [timeBetweenScansMillis=500] the time delay between subsequent successful decode tries
|
67
|
+
*
|
68
|
+
* @memberOf BrowserCodeReader
|
69
|
+
*/
|
70
|
+
constructor(reader: Reader, timeBetweenScansMillis?: number, _hints?: Map<DecodeHintType, any> | undefined);
|
71
|
+
/**
|
72
|
+
* Searches and validates a media element.
|
73
|
+
*/
|
74
|
+
getMediaElement(mediaElementId: string, type: string): HTMLVisualMediaElement;
|
75
|
+
/**
|
76
|
+
* Decodes the barcode from an image.
|
77
|
+
*
|
78
|
+
* @param {(string|HTMLImageElement)} [source] The image element that can be either an element id or the element itself. Can be undefined in which case the decoding will be done from the imageUrl parameter.
|
79
|
+
* @param {string} [url]
|
80
|
+
* @returns {Promise<Result>} The decoding result.
|
81
|
+
*
|
82
|
+
* @memberOf BrowserCodeReader
|
83
|
+
*/
|
84
|
+
decodeFromImage(source?: string | HTMLImageElement, url?: string): Promise<Result>;
|
85
|
+
/**
|
86
|
+
* Decodes something from an image HTML element.
|
87
|
+
*/
|
88
|
+
decodeFromImageElement(source: string | HTMLImageElement): Promise<Result>;
|
89
|
+
/**
|
90
|
+
* Decodes an image from a URL.
|
91
|
+
*/
|
92
|
+
decodeFromImageUrl(url?: string): Promise<Result>;
|
93
|
+
private _decodeOnLoadImage;
|
94
|
+
isImageLoaded(img: HTMLImageElement): boolean;
|
95
|
+
prepareImageElement(imageSource?: HTMLImageElement | string): HTMLImageElement;
|
96
|
+
/**
|
97
|
+
* Tries to decode from the image input until it finds some value.
|
98
|
+
*/
|
99
|
+
decodeOnce(element: HTMLVisualMediaElement, retryIfNotFound?: boolean, retryIfChecksumOrFormatError?: boolean): Promise<Result>;
|
100
|
+
/**
|
101
|
+
* Gets the BinaryBitmap for ya! (and decodes it)
|
102
|
+
*/
|
103
|
+
decode(element: HTMLVisualMediaElement): Result;
|
104
|
+
/**
|
105
|
+
* Creates a binaryBitmap based in some image source.
|
106
|
+
*
|
107
|
+
* @param mediaElement HTML element containing drawable image source.
|
108
|
+
*/
|
109
|
+
createBinaryBitmap(mediaElement: HTMLVisualMediaElement): BinaryBitmap;
|
110
|
+
/**
|
111
|
+
*
|
112
|
+
*/
|
113
|
+
protected getCaptureCanvasContext(mediaElement?: HTMLVisualMediaElement): CanvasRenderingContext2D;
|
114
|
+
/**
|
115
|
+
*
|
116
|
+
*/
|
117
|
+
protected getCaptureCanvas(mediaElement?: HTMLVisualMediaElement): HTMLCanvasElement;
|
118
|
+
/**
|
119
|
+
* Ovewriting this allows you to manipulate the snapshot image in anyway you want before decode.
|
120
|
+
*/
|
121
|
+
drawImageOnCanvas(srcElement: HTMLImageElement, dimensions?: {
|
122
|
+
sx: number;
|
123
|
+
sy: number;
|
124
|
+
sWidth: number;
|
125
|
+
sHeight: number;
|
126
|
+
dx: number;
|
127
|
+
dy: number;
|
128
|
+
dWidth: number;
|
129
|
+
dHeight: number;
|
130
|
+
}, canvasElementContext?: CanvasRenderingContext2D): void;
|
131
|
+
/**
|
132
|
+
* Call the encapsulated readers decode
|
133
|
+
*/
|
134
|
+
decodeBitmap(binaryBitmap: BinaryBitmap): Result;
|
135
|
+
/**
|
136
|
+
* 🖌 Prepares the canvas for capture and scan frames.
|
137
|
+
*/
|
138
|
+
createCaptureCanvas(mediaElement?: HTMLVisualMediaElement): HTMLCanvasElement;
|
139
|
+
/**
|
140
|
+
* Resets the code reader to the initial state.
|
141
|
+
*
|
142
|
+
* @memberOf BrowserCodeReader
|
143
|
+
*/
|
144
|
+
reset(): void;
|
145
|
+
private _destroyImageElement;
|
146
|
+
/**
|
147
|
+
* Destroys the capture canvas and context.
|
148
|
+
*/
|
149
|
+
private _destroyCaptureCanvas;
|
150
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import BinaryBitmap from '../core/BinaryBitmap';
|
2
|
+
import Result from '../core/Result';
|
3
|
+
import { BrowserCodeReader } from './BrowserCodeReader';
|
4
|
+
/**
|
5
|
+
* QR Code reader to use from browser with improved error handling.
|
6
|
+
* This implementation properly handles promise rejections when QR codes can't be decoded.
|
7
|
+
*/
|
8
|
+
export declare class BrowserQRCodeReader extends BrowserCodeReader {
|
9
|
+
private qrReader;
|
10
|
+
private inProgressDecodes;
|
11
|
+
constructor(timeBetweenScansMillis?: number);
|
12
|
+
/**
|
13
|
+
* Safely reset the reader without causing message channel issues
|
14
|
+
*/
|
15
|
+
private safeReset;
|
16
|
+
/**
|
17
|
+
* Overrides the decodeBitmap method to ensure proper error handling and reader reset.
|
18
|
+
* This makes BrowserQRCodeReader behave consistently with BrowserMultiFormatReader.
|
19
|
+
*/
|
20
|
+
decodeBitmap(binaryBitmap: BinaryBitmap): Result;
|
21
|
+
/**
|
22
|
+
* Overrides decodeFromImageUrl to ensure proper resource handling
|
23
|
+
*/
|
24
|
+
decodeFromImageUrl(url: string): Promise<Result>;
|
25
|
+
/**
|
26
|
+
* Override the reset method to safely clean up resources
|
27
|
+
*/
|
28
|
+
reset(): void;
|
29
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import LuminanceSource from '../core/LuminanceSource';
|
2
|
+
export declare class HTMLCanvasElementLuminanceSource extends LuminanceSource {
|
3
|
+
private canvas;
|
4
|
+
private buffer;
|
5
|
+
private static DEGREE_TO_RADIANS;
|
6
|
+
private static FRAME_INDEX;
|
7
|
+
private tempCanvasElement;
|
8
|
+
constructor(canvas: HTMLCanvasElement, doAutoInvert?: boolean);
|
9
|
+
private static makeBufferFromCanvasImageData;
|
10
|
+
private static toGrayscaleBuffer;
|
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
|
+
/**
|
16
|
+
* This is always true, since the image is a gray-scale image.
|
17
|
+
*
|
18
|
+
* @return true
|
19
|
+
*/
|
20
|
+
isRotateSupported(): boolean;
|
21
|
+
rotateCounterClockwise(): LuminanceSource;
|
22
|
+
rotateCounterClockwise45(): LuminanceSource;
|
23
|
+
private getTempCanvasElement;
|
24
|
+
private rotate;
|
25
|
+
invert(): LuminanceSource;
|
26
|
+
hightContrast(threshold?: number): LuminanceSource;
|
27
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import IndexOutOfBoundsException from './IndexOutOfBoundsException';
|
2
|
+
/**
|
3
|
+
* Custom Error class of type Exception.
|
4
|
+
*/
|
5
|
+
export default class ArrayIndexOutOfBoundsException extends IndexOutOfBoundsException {
|
6
|
+
index: number;
|
7
|
+
message: string;
|
8
|
+
static readonly kind: string;
|
9
|
+
constructor(index: number, message: string);
|
10
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
/**
|
2
|
+
* Enumerates barcode formats known to this package. Please keep alphabetized.
|
3
|
+
*
|
4
|
+
* @author Sean Owen
|
5
|
+
*/
|
6
|
+
declare enum BarcodeFormat {
|
7
|
+
/** Aztec 2D barcode format. */
|
8
|
+
AZTEC = 0,
|
9
|
+
/** CODABAR 1D format. */
|
10
|
+
CODABAR = 1,
|
11
|
+
/** Code 39 1D format. */
|
12
|
+
CODE_39 = 2,
|
13
|
+
/** Code 93 1D format. */
|
14
|
+
CODE_93 = 3,
|
15
|
+
/** Code 128 1D format. */
|
16
|
+
CODE_128 = 4,
|
17
|
+
/** Data Matrix 2D barcode format. */
|
18
|
+
DATA_MATRIX = 5,
|
19
|
+
/** EAN-8 1D format. */
|
20
|
+
EAN_8 = 6,
|
21
|
+
/** EAN-13 1D format. */
|
22
|
+
EAN_13 = 7,
|
23
|
+
/** ITF (Interleaved Two of Five) 1D format. */
|
24
|
+
ITF = 8,
|
25
|
+
/** MaxiCode 2D barcode format. */
|
26
|
+
MAXICODE = 9,
|
27
|
+
/** PDF417 format. */
|
28
|
+
PDF_417 = 10,
|
29
|
+
/** QR Code 2D barcode format. */
|
30
|
+
QR_CODE = 11,
|
31
|
+
/** RSS 14 */
|
32
|
+
RSS_14 = 12,
|
33
|
+
/** RSS EXPANDED */
|
34
|
+
RSS_EXPANDED = 13,
|
35
|
+
/** UPC-A 1D format. */
|
36
|
+
UPC_A = 14,
|
37
|
+
/** UPC-E 1D format. */
|
38
|
+
UPC_E = 15,
|
39
|
+
/** UPC/EAN extension format. Not a stand-alone format. */
|
40
|
+
UPC_EAN_EXTENSION = 16
|
41
|
+
}
|
42
|
+
export default BarcodeFormat;
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import BitArray from './common/BitArray';
|
2
|
+
import BitMatrix from './common/BitMatrix';
|
3
|
+
import LuminanceSource from './LuminanceSource';
|
4
|
+
/**
|
5
|
+
* This class hierarchy provides a set of methods to convert luminance data to 1 bit data.
|
6
|
+
* It allows the algorithm to vary polymorphically, for example allowing a very expensive
|
7
|
+
* thresholding technique for servers and a fast one for mobile. It also permits the implementation
|
8
|
+
* to vary, e.g. a JNI version for Android and a Java fallback version for other platforms.
|
9
|
+
*
|
10
|
+
* @author dswitkin@google.com (Daniel Switkin)
|
11
|
+
*/
|
12
|
+
declare abstract class Binarizer {
|
13
|
+
private source;
|
14
|
+
protected constructor(source: LuminanceSource);
|
15
|
+
getLuminanceSource(): LuminanceSource;
|
16
|
+
/**
|
17
|
+
* Converts one row of luminance data to 1 bit data. May actually do the conversion, or return
|
18
|
+
* cached data. Callers should assume this method is expensive and call it as seldom as possible.
|
19
|
+
* This method is intended for decoding 1D barcodes and may choose to apply sharpening.
|
20
|
+
* For callers which only examine one row of pixels at a time, the same BitArray should be reused
|
21
|
+
* and passed in with each call for performance. However it is legal to keep more than one row
|
22
|
+
* at a time if needed.
|
23
|
+
*
|
24
|
+
* @param y The row to fetch, which must be in [0, bitmap height)
|
25
|
+
* @param row An optional preallocated array. If null or too small, it will be ignored.
|
26
|
+
* If used, the Binarizer will call BitArray.clear(). Always use the returned object.
|
27
|
+
* @return The array of bits for this row (true means black).
|
28
|
+
* @throws NotFoundException if row can't be binarized
|
29
|
+
*/
|
30
|
+
abstract getBlackRow(y: number, row: BitArray): BitArray;
|
31
|
+
/**
|
32
|
+
* Converts a 2D array of luminance data to 1 bit data. As above, assume this method is expensive
|
33
|
+
* and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or
|
34
|
+
* may not apply sharpening. Therefore, a row from this matrix may not be identical to one
|
35
|
+
* fetched using getBlackRow(), so don't mix and match between them.
|
36
|
+
*
|
37
|
+
* @return The 2D array of bits for the image (true means black).
|
38
|
+
* @throws NotFoundException if image can't be binarized to make a matrix
|
39
|
+
*/
|
40
|
+
abstract getBlackMatrix(): BitMatrix;
|
41
|
+
/**
|
42
|
+
* Creates a new object with the same type as this Binarizer implementation, but with pristine
|
43
|
+
* state. This is needed because Binarizer implementations may be stateful, e.g. keeping a cache
|
44
|
+
* of 1 bit data. See Effective Java for why we can't use Java's clone() method.
|
45
|
+
*
|
46
|
+
* @param source The LuminanceSource this Binarizer will operate on.
|
47
|
+
* @return A new concrete Binarizer implementation object.
|
48
|
+
*/
|
49
|
+
abstract createBinarizer(source: LuminanceSource): Binarizer;
|
50
|
+
getWidth(): number;
|
51
|
+
getHeight(): number;
|
52
|
+
}
|
53
|
+
export default Binarizer;
|
@@ -0,0 +1,78 @@
|
|
1
|
+
/**
|
2
|
+
* This class is the core bitmap class used by ZXing to represent 1 bit data. Reader objects
|
3
|
+
* accept a BinaryBitmap and attempt to decode it.
|
4
|
+
*
|
5
|
+
* @author dswitkin@google.com (Daniel Switkin)
|
6
|
+
*/
|
7
|
+
import Binarizer from './Binarizer';
|
8
|
+
import BitArray from './common/BitArray';
|
9
|
+
import BitMatrix from './common/BitMatrix';
|
10
|
+
export default class BinaryBitmap {
|
11
|
+
private binarizer;
|
12
|
+
private matrix;
|
13
|
+
constructor(binarizer: Binarizer);
|
14
|
+
/**
|
15
|
+
* @return The width of the bitmap.
|
16
|
+
*/
|
17
|
+
getWidth(): number;
|
18
|
+
/**
|
19
|
+
* @return The height of the bitmap.
|
20
|
+
*/
|
21
|
+
getHeight(): number;
|
22
|
+
/**
|
23
|
+
* Converts one row of luminance data to 1 bit data. May actually do the conversion, or return
|
24
|
+
* cached data. Callers should assume this method is expensive and call it as seldom as possible.
|
25
|
+
* This method is intended for decoding 1D barcodes and may choose to apply sharpening.
|
26
|
+
*
|
27
|
+
* @param y The row to fetch, which must be in [0, bitmap height)
|
28
|
+
* @param row An optional preallocated array. If null or too small, it will be ignored.
|
29
|
+
* If used, the Binarizer will call BitArray.clear(). Always use the returned object.
|
30
|
+
* @return The array of bits for this row (true means black).
|
31
|
+
* @throws NotFoundException if row can't be binarized
|
32
|
+
*/
|
33
|
+
getBlackRow(y: number, row: BitArray): BitArray;
|
34
|
+
/**
|
35
|
+
* Converts a 2D array of luminance data to 1 bit. As above, assume this method is expensive
|
36
|
+
* and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or
|
37
|
+
* may not apply sharpening. Therefore, a row from this matrix may not be identical to one
|
38
|
+
* fetched using getBlackRow(), so don't mix and match between them.
|
39
|
+
*
|
40
|
+
* @return The 2D array of bits for the image (true means black).
|
41
|
+
* @throws NotFoundException if image can't be binarized to make a matrix
|
42
|
+
*/
|
43
|
+
getBlackMatrix(): BitMatrix;
|
44
|
+
/**
|
45
|
+
* @return Whether this bitmap can be cropped.
|
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): BinaryBitmap;
|
59
|
+
/**
|
60
|
+
* @return Whether this bitmap supports counter-clockwise rotation.
|
61
|
+
*/
|
62
|
+
isRotateSupported(): boolean;
|
63
|
+
/**
|
64
|
+
* Returns a new object with rotated image data by 90 degrees counterclockwise.
|
65
|
+
* Only callable if {@link #isRotateSupported()} is true.
|
66
|
+
*
|
67
|
+
* @return A rotated version of this object.
|
68
|
+
*/
|
69
|
+
rotateCounterClockwise(): BinaryBitmap;
|
70
|
+
/**
|
71
|
+
* Returns a new object with rotated image data by 45 degrees counterclockwise.
|
72
|
+
* Only callable if {@link #isRotateSupported()} is true.
|
73
|
+
*
|
74
|
+
* @return A rotated version of this object.
|
75
|
+
*/
|
76
|
+
rotateCounterClockwise45(): BinaryBitmap;
|
77
|
+
toString(): string;
|
78
|
+
}
|