@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.
Files changed (186) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/docs/advanced-examples.md +84 -0
  3. package/docs/api-reference-guide.md +38 -0
  4. package/docs/documentation.md +182 -0
  5. package/docs/examples.md +145 -27
  6. package/docs/template-update-plan.md +53 -0
  7. package/docs/usage-guide.md +47 -0
  8. package/lib/chunks/scan-validator-node-BGUxkBJt.js +1 -0
  9. package/lib/chunks/scan-validator-zxing-node-CV9K2v4n.js +1 -0
  10. package/lib/core/qr-code-js.d.ts +10 -1
  11. package/lib/core/qr-styles.d.ts +4 -0
  12. package/lib/index.d.ts +34 -7
  13. package/lib/index.js +1 -1
  14. package/lib/node/core/qr-code-js.d.ts +61 -0
  15. package/lib/node/core/qr-constant.d.ts +9 -0
  16. package/lib/node/core/qr-options-validation.d.ts +13 -0
  17. package/lib/node/core/qr-styles.d.ts +4 -0
  18. package/lib/node/core/qr-svg.d.ts +76 -0
  19. package/lib/node/core/qr-templates.d.ts +10 -0
  20. package/lib/node/figures/corner-dot.d.ts +24 -0
  21. package/lib/node/figures/corner-square.d.ts +24 -0
  22. package/lib/node/figures/dot.d.ts +31 -0
  23. package/lib/node/index.d.ts +101 -0
  24. package/lib/node/lib/image/GIFImage.d.ts +19 -0
  25. package/lib/node/lib/io/Base64.d.ts +10 -0
  26. package/lib/node/lib/io/Base64DecodeInputStream.d.ts +15 -0
  27. package/lib/node/lib/io/Base64EncodeOutputStream.d.ts +17 -0
  28. package/lib/node/lib/io/ByteArrayInputStream.d.ts +12 -0
  29. package/lib/node/lib/io/ByteArrayOutputStream.d.ts +12 -0
  30. package/lib/node/lib/io/InputStream.d.ts +10 -0
  31. package/lib/node/lib/io/OutputStream.d.ts +12 -0
  32. package/lib/node/lib/qr-code.d.ts +5 -0
  33. package/lib/node/lib/qrcode/BitBuffer.d.ts +11 -0
  34. package/lib/node/lib/qrcode/ErrorCorrectLevel.d.ts +23 -0
  35. package/lib/node/lib/qrcode/MaskPattern.d.ts +39 -0
  36. package/lib/node/lib/qrcode/Mode.d.ts +23 -0
  37. package/lib/node/lib/qrcode/Polynomial.d.ts +15 -0
  38. package/lib/node/lib/qrcode/QR8BitByte.d.ts +13 -0
  39. package/lib/node/lib/qrcode/QRAlphaNum.d.ts +13 -0
  40. package/lib/node/lib/qrcode/QRCode.d.ts +22 -0
  41. package/lib/node/lib/qrcode/QRCodeMinimal.d.ts +58 -0
  42. package/lib/node/lib/qrcode/QRData.d.ts +17 -0
  43. package/lib/node/lib/qrcode/QRKanji.d.ts +13 -0
  44. package/lib/node/lib/qrcode/QRMath.d.ts +13 -0
  45. package/lib/node/lib/qrcode/QRNumber.d.ts +14 -0
  46. package/lib/node/lib/qrcode/QRUtil.d.ts +25 -0
  47. package/lib/node/lib/qrcode/RSBlock.d.ts +16 -0
  48. package/lib/node/lib/text/createStringToBytes.d.ts +9 -0
  49. package/lib/node/lib/text/stringToBytes_SJIS.d.ts +8 -0
  50. package/lib/node/lib/text/stringToBytes_UTF8.d.ts +7 -0
  51. package/lib/node/lib/zbar-wasm/index.d.ts +1 -0
  52. package/lib/node/lib/zxing-js/src/browser/BrowserCodeReader.d.ts +150 -0
  53. package/lib/node/lib/zxing-js/src/browser/BrowserQRCodeReader.d.ts +29 -0
  54. package/lib/node/lib/zxing-js/src/browser/HTMLCanvasElementLuminanceSource.d.ts +27 -0
  55. package/lib/node/lib/zxing-js/src/browser/HTMLVisualMediaElement.d.ts +4 -0
  56. package/lib/node/lib/zxing-js/src/browser.d.ts +3 -0
  57. package/lib/node/lib/zxing-js/src/core/ArgumentException.d.ts +7 -0
  58. package/lib/node/lib/zxing-js/src/core/ArithmeticException.d.ts +7 -0
  59. package/lib/node/lib/zxing-js/src/core/ArrayIndexOutOfBoundsException.d.ts +10 -0
  60. package/lib/node/lib/zxing-js/src/core/BarcodeFormat.d.ts +42 -0
  61. package/lib/node/lib/zxing-js/src/core/Binarizer.d.ts +53 -0
  62. package/lib/node/lib/zxing-js/src/core/BinaryBitmap.d.ts +78 -0
  63. package/lib/node/lib/zxing-js/src/core/ChecksumException.d.ts +8 -0
  64. package/lib/node/lib/zxing-js/src/core/DecodeHintType.d.ts +91 -0
  65. package/lib/node/lib/zxing-js/src/core/Exception.d.ts +17 -0
  66. package/lib/node/lib/zxing-js/src/core/FormatException.d.ts +8 -0
  67. package/lib/node/lib/zxing-js/src/core/HighContrastLuminanceSource.d.ts +27 -0
  68. package/lib/node/lib/zxing-js/src/core/IllegalArgumentException.d.ts +7 -0
  69. package/lib/node/lib/zxing-js/src/core/IllegalStateException.d.ts +7 -0
  70. package/lib/node/lib/zxing-js/src/core/IndexOutOfBoundsException.d.ts +7 -0
  71. package/lib/node/lib/zxing-js/src/core/InvertedLuminanceSource.d.ts +22 -0
  72. package/lib/node/lib/zxing-js/src/core/LuminanceSource.d.ts +84 -0
  73. package/lib/node/lib/zxing-js/src/core/NodeLuminanceSource.d.ts +33 -0
  74. package/lib/node/lib/zxing-js/src/core/NotFoundException.d.ts +8 -0
  75. package/lib/node/lib/zxing-js/src/core/NullPointerException.d.ts +7 -0
  76. package/lib/node/lib/zxing-js/src/core/OutOfMemoryError.d.ts +6 -0
  77. package/lib/node/lib/zxing-js/src/core/Reader.d.ts +49 -0
  78. package/lib/node/lib/zxing-js/src/core/ReaderException.d.ts +7 -0
  79. package/lib/node/lib/zxing-js/src/core/ReedSolomonException.d.ts +7 -0
  80. package/lib/node/lib/zxing-js/src/core/Result.d.ts +52 -0
  81. package/lib/node/lib/zxing-js/src/core/ResultMetadataType.d.ts +68 -0
  82. package/lib/node/lib/zxing-js/src/core/ResultPoint.d.ts +34 -0
  83. package/lib/node/lib/zxing-js/src/core/ResultPointCallback.d.ts +11 -0
  84. package/lib/node/lib/zxing-js/src/core/UniversalLuminanceSource.d.ts +46 -0
  85. package/lib/node/lib/zxing-js/src/core/UnsupportedOperationException.d.ts +7 -0
  86. package/lib/node/lib/zxing-js/src/core/common/BitArray.d.ts +111 -0
  87. package/lib/node/lib/zxing-js/src/core/common/BitMatrix.d.ts +98 -0
  88. package/lib/node/lib/zxing-js/src/core/common/BitSource.d.ts +38 -0
  89. package/lib/node/lib/zxing-js/src/core/common/CharacterSetECI.d.ts +89 -0
  90. package/lib/node/lib/zxing-js/src/core/common/DecoderResult.d.ts +64 -0
  91. package/lib/node/lib/zxing-js/src/core/common/DefaultGridSampler.d.ts +10 -0
  92. package/lib/node/lib/zxing-js/src/core/common/DetectorResult.d.ts +16 -0
  93. package/lib/node/lib/zxing-js/src/core/common/GlobalHistogramBinarizer.d.ts +29 -0
  94. package/lib/node/lib/zxing-js/src/core/common/GridSampler.d.ts +36 -0
  95. package/lib/node/lib/zxing-js/src/core/common/GridSamplerInstance.d.ts +18 -0
  96. package/lib/node/lib/zxing-js/src/core/common/HybridBinarizer.d.ts +54 -0
  97. package/lib/node/lib/zxing-js/src/core/common/PerspectiveTransform.d.ts +26 -0
  98. package/lib/node/lib/zxing-js/src/core/common/StringUtils.d.ts +48 -0
  99. package/lib/node/lib/zxing-js/src/core/common/detector/MathUtils.d.ts +36 -0
  100. package/lib/node/lib/zxing-js/src/core/common/reedsolomon/AbstractGenericGF.d.ts +34 -0
  101. package/lib/node/lib/zxing-js/src/core/common/reedsolomon/GenericGF.d.ts +58 -0
  102. package/lib/node/lib/zxing-js/src/core/common/reedsolomon/GenericGFPoly.d.ts +47 -0
  103. package/lib/node/lib/zxing-js/src/core/common/reedsolomon/ReedSolomonDecoder.d.ts +40 -0
  104. package/lib/node/lib/zxing-js/src/core/qrcode/QRCodeReader.d.ts +35 -0
  105. package/lib/node/lib/zxing-js/src/core/qrcode/decoder/BitMatrixParser.d.ts +58 -0
  106. package/lib/node/lib/zxing-js/src/core/qrcode/decoder/DataBlock.d.ts +28 -0
  107. package/lib/node/lib/zxing-js/src/core/qrcode/decoder/DataMask.d.ts +36 -0
  108. package/lib/node/lib/zxing-js/src/core/qrcode/decoder/DecodedBitStreamParser.d.ts +30 -0
  109. package/lib/node/lib/zxing-js/src/core/qrcode/decoder/Decoder.d.ts +44 -0
  110. package/lib/node/lib/zxing-js/src/core/qrcode/decoder/ECB.d.ts +12 -0
  111. package/lib/node/lib/zxing-js/src/core/qrcode/decoder/ECBlocks.d.ts +16 -0
  112. package/lib/node/lib/zxing-js/src/core/qrcode/decoder/ErrorCorrectionLevel.d.ts +38 -0
  113. package/lib/node/lib/zxing-js/src/core/qrcode/decoder/FormatInformation.d.ts +33 -0
  114. package/lib/node/lib/zxing-js/src/core/qrcode/decoder/Mode.d.ts +56 -0
  115. package/lib/node/lib/zxing-js/src/core/qrcode/decoder/QRCodeDecoderMetaData.d.ts +21 -0
  116. package/lib/node/lib/zxing-js/src/core/qrcode/decoder/Version.d.ts +44 -0
  117. package/lib/node/lib/zxing-js/src/core/qrcode/detector/AlignmentPattern.d.ts +21 -0
  118. package/lib/node/lib/zxing-js/src/core/qrcode/detector/AlignmentPatternFinder.d.ts +82 -0
  119. package/lib/node/lib/zxing-js/src/core/qrcode/detector/Detector.d.ts +87 -0
  120. package/lib/node/lib/zxing-js/src/core/qrcode/detector/FinderPattern.d.ts +26 -0
  121. package/lib/node/lib/zxing-js/src/core/qrcode/detector/FinderPatternFinder.d.ts +114 -0
  122. package/lib/node/lib/zxing-js/src/core/qrcode/detector/FinderPatternInfo.d.ts +16 -0
  123. package/lib/node/lib/zxing-js/src/core/util/Arrays.d.ts +45 -0
  124. package/lib/node/lib/zxing-js/src/core/util/Charset.d.ts +7 -0
  125. package/lib/node/lib/zxing-js/src/core/util/Float.d.ts +14 -0
  126. package/lib/node/lib/zxing-js/src/core/util/Integer.d.ts +19 -0
  127. package/lib/node/lib/zxing-js/src/core/util/StringBuilder.d.ts +21 -0
  128. package/lib/node/lib/zxing-js/src/core/util/StringEncoding.d.ts +51 -0
  129. package/lib/node/lib/zxing-js/src/core/util/System.d.ts +10 -0
  130. package/lib/node/lib/zxing-js/src/customTypings.d.ts +16 -0
  131. package/lib/node/lib/zxing-js/src/index.d.ts +5 -0
  132. package/lib/node/lib/zxing-js/src/node.d.ts +1 -0
  133. package/lib/node/license/LicenseManager.d.ts +69 -0
  134. package/lib/node/license/LicenseManagerNode.d.ts +64 -0
  135. package/lib/node/node.d.ts +88 -0
  136. package/lib/node/options-demo.d.ts +239 -0
  137. package/lib/node/plugins/QRBorderHelpers.d.ts +32 -0
  138. package/lib/node/plugins/QRBorderPlugin.d.ts +35 -0
  139. package/lib/node/plugins/QRValidatorZbar.d.ts +38 -0
  140. package/lib/node/plugins/QRValidatorZbarNode.d.ts +60 -0
  141. package/lib/node/plugins/QRValidatorZbarNodeSharp.d.ts +83 -0
  142. package/lib/node/templates/borders-inner-outter.d.ts +129 -0
  143. package/lib/node/templates/borders-inner-scale-offset.d.ts +497 -0
  144. package/lib/node/templates/borders-inner.d.ts +129 -0
  145. package/lib/node/templates/borders-no-license.d.ts +129 -0
  146. package/lib/node/templates/borders-outter.d.ts +129 -0
  147. package/lib/node/templates/borders-text-auto-curved.d.ts +129 -0
  148. package/lib/node/templates/borders-text-full-curved.d.ts +133 -0
  149. package/lib/node/templates/borders.d.ts +129 -0
  150. package/lib/node/templates/scales.d.ts +130 -0
  151. package/lib/node/templates/scan-validators/index.d.ts +1 -0
  152. package/lib/node/templates/scan-validators/tests/cases/basic-inverted.d.ts +9 -0
  153. package/lib/node/templates/scan-validators/tests/cases/basic-no-license.d.ts +3 -0
  154. package/lib/node/templates/scan-validators/tests/cases/basic.d.ts +3 -0
  155. package/lib/node/templates/scan-validators/tests/cases/colors-inverted.d.ts +2 -0
  156. package/lib/node/templates/scan-validators/tests/cases/colors.d.ts +58 -0
  157. package/lib/node/templates/scan-validators/tests/cases/out-of-borders-inverted.d.ts +9 -0
  158. package/lib/node/templates/scan-validators/tests/cases/out-of-borders.d.ts +9 -0
  159. package/lib/node/templates/scan-validators/tests/cases/position-inverted.d.ts +9 -0
  160. package/lib/node/templates/scan-validators/tests/cases/position.d.ts +3 -0
  161. package/lib/node/templates/scan-validators/tests/index.d.ts +27 -0
  162. package/lib/node/tools/browser-image-tools.d.ts +7 -0
  163. package/lib/node/tools/browser-utils.d.ts +18 -0
  164. package/lib/node/types/helper.d.ts +23 -0
  165. package/lib/node/types/style-options.d.ts +37 -0
  166. package/lib/node/utils/canvas-options.d.ts +7 -0
  167. package/lib/node/utils/color.d.ts +4 -0
  168. package/lib/node/utils/gradient.d.ts +26 -0
  169. package/lib/node/utils/image.d.ts +16 -0
  170. package/lib/node/utils/merge.d.ts +5 -0
  171. package/lib/node/utils/options.d.ts +220 -0
  172. package/lib/node/utils/qrcode.d.ts +8 -0
  173. package/lib/node/utils/scan-validator-node.d.ts +15 -0
  174. package/lib/node/utils/scan-validator-zxing-node.d.ts +18 -0
  175. package/lib/node/utils/scan-validators/abstract-scan-validator.d.ts +43 -0
  176. package/lib/node/utils/scan-validators/zbar-scan-validator.d.ts +8 -0
  177. package/lib/node/utils/scan-validators/zxing-canvas-scan-validator.d.ts +10 -0
  178. package/lib/node/utils/scan-validators/zxing-scan-validator.d.ts +8 -0
  179. package/lib/node/utils/style-mapper.d.ts +13 -0
  180. package/lib/node/utils/svg.d.ts +2 -0
  181. package/lib/node/utils/token-validator.d.ts +19 -0
  182. package/lib/node.d.ts +38 -10
  183. package/lib/node.js +1 -1
  184. package/lib/types/style-options.d.ts +37 -0
  185. package/lib/utils/style-mapper.d.ts +13 -0
  186. package/package.json +1 -1
@@ -0,0 +1,44 @@
1
+ import BitMatrix from '../../common/BitMatrix';
2
+ import ECBlocks from './ECBlocks';
3
+ import ErrorCorrectionLevel from './ErrorCorrectionLevel';
4
+ /**
5
+ * See ISO 18004:2006 Annex D
6
+ *
7
+ * @author Sean Owen
8
+ */
9
+ export default class Version {
10
+ private versionNumber;
11
+ private alignmentPatternCenters;
12
+ /**
13
+ * See ISO 18004:2006 Annex D.
14
+ * Element i represents the raw version bits that specify version i + 7
15
+ */
16
+ private static VERSION_DECODE_INFO;
17
+ /**
18
+ * See ISO 18004:2006 6.5.1 Table 9
19
+ */
20
+ private static VERSIONS;
21
+ private ecBlocks;
22
+ private totalCodewords;
23
+ private constructor();
24
+ getVersionNumber(): number;
25
+ getAlignmentPatternCenters(): Int32Array;
26
+ getTotalCodewords(): number;
27
+ getDimensionForVersion(): number;
28
+ getECBlocksForLevel(ecLevel: ErrorCorrectionLevel): ECBlocks;
29
+ /**
30
+ * <p>Deduces version information purely from QR Code dimensions.</p>
31
+ *
32
+ * @param dimension dimension in modules
33
+ * @return Version for a QR Code of that dimension
34
+ * @throws FormatException if dimension is not 1 mod 4
35
+ */
36
+ static getProvisionalVersionForDimension(dimension: number): Version;
37
+ static getVersionForNumber(versionNumber: number): Version;
38
+ static decodeVersionInformation(versionBits: number): Version | null;
39
+ /**
40
+ * See ISO 18004:2006 Annex E
41
+ */
42
+ buildFunctionPattern(): BitMatrix;
43
+ toString(): string;
44
+ }
@@ -0,0 +1,21 @@
1
+ import ResultPoint from '../../ResultPoint';
2
+ /**
3
+ * <p>Encapsulates an alignment pattern, which are the smaller square patterns found in
4
+ * all but the simplest QR Codes.</p>
5
+ *
6
+ * @author Sean Owen
7
+ */
8
+ export default class AlignmentPattern extends ResultPoint {
9
+ private estimatedModuleSize;
10
+ constructor(posX: number, posY: number, estimatedModuleSize: number);
11
+ /**
12
+ * <p>Determines if this alignment pattern "about equals" an alignment pattern at the stated
13
+ * position and size -- meaning, it is at nearly the same center with nearly the same size.</p>
14
+ */
15
+ aboutEquals(moduleSize: number, i: number, j: number): boolean;
16
+ /**
17
+ * Combines this object's current estimate of a finder pattern position and module size
18
+ * with a new estimate. It returns a new {@code FinderPattern} containing an average of the two.
19
+ */
20
+ combineEstimate(i: number, j: number, newModuleSize: number): AlignmentPattern;
21
+ }
@@ -0,0 +1,82 @@
1
+ import BitMatrix from '../../common/BitMatrix';
2
+ import ResultPointCallback from '../../ResultPointCallback';
3
+ import AlignmentPattern from './AlignmentPattern';
4
+ /**
5
+ * <p>This class attempts to find alignment patterns in a QR Code. Alignment patterns look like finder
6
+ * patterns but are smaller and appear at regular intervals throughout the image.</p>
7
+ *
8
+ * <p>At the moment this only looks for the bottom-right alignment pattern.</p>
9
+ *
10
+ * <p>This is mostly a simplified copy of {@link FinderPatternFinder}. It is copied,
11
+ * pasted and stripped down here for maximum performance but does unfortunately duplicate
12
+ * some code.</p>
13
+ *
14
+ * <p>This class is thread-safe but not reentrant. Each thread must allocate its own object.</p>
15
+ *
16
+ * @author Sean Owen
17
+ */
18
+ export default class AlignmentPatternFinder {
19
+ private image;
20
+ private startX;
21
+ private startY;
22
+ private width;
23
+ private height;
24
+ private moduleSize;
25
+ private resultPointCallback;
26
+ private possibleCenters;
27
+ private crossCheckStateCount;
28
+ /**
29
+ * <p>Creates a finder that will look in a portion of the whole image.</p>
30
+ *
31
+ * @param image image to search
32
+ * @param startX left column from which to start searching
33
+ * @param startY top row from which to start searching
34
+ * @param width width of region to search
35
+ * @param height height of region to search
36
+ * @param moduleSize estimated module size so far
37
+ */
38
+ constructor(image: BitMatrix, startX: number, startY: number, width: number, height: number, moduleSize: number, resultPointCallback: ResultPointCallback);
39
+ /**
40
+ * <p>This method attempts to find the bottom-right alignment pattern in the image. It is a bit messy since
41
+ * it's pretty performance-critical and so is written to be fast foremost.</p>
42
+ *
43
+ * @return {@link AlignmentPattern} if found
44
+ * @throws NotFoundException if not found
45
+ */
46
+ find(): AlignmentPattern;
47
+ /**
48
+ * Given a count of black/white/black pixels just seen and an end position,
49
+ * figures the location of the center of this black/white/black run.
50
+ */
51
+ private static centerFromEnd;
52
+ /**
53
+ * @param stateCount count of black/white/black pixels just read
54
+ * @return true iff the proportions of the counts is close enough to the 1/1/1 ratios
55
+ * used by alignment patterns to be considered a match
56
+ */
57
+ private foundPatternCross;
58
+ /**
59
+ * <p>After a horizontal scan finds a potential alignment pattern, this method
60
+ * "cross-checks" by scanning down vertically through the center of the possible
61
+ * alignment pattern to see if the same proportion is detected.</p>
62
+ *
63
+ * @param startI row where an alignment pattern was detected
64
+ * @param centerJ center of the section that appears to cross an alignment pattern
65
+ * @param maxCount maximum reasonable number of modules that should be
66
+ * observed in any reading state, based on the results of the horizontal scan
67
+ * @return vertical center of alignment pattern, or {@link Float#NaN} if not found
68
+ */
69
+ private crossCheckVertical;
70
+ /**
71
+ * <p>This is called when a horizontal scan finds a possible alignment pattern. It will
72
+ * cross check with a vertical scan, and if successful, will see if this pattern had been
73
+ * found on a previous horizontal scan. If so, we consider it confirmed and conclude we have
74
+ * found the alignment pattern.</p>
75
+ *
76
+ * @param stateCount reading state module counts from horizontal scan
77
+ * @param i row where alignment pattern may be found
78
+ * @param j end of possible alignment pattern in row
79
+ * @return {@link AlignmentPattern} if we have found the same pattern twice, or null if not
80
+ */
81
+ private handlePossibleCenter;
82
+ }
@@ -0,0 +1,87 @@
1
+ import BitMatrix from '../../common/BitMatrix';
2
+ import DetectorResult from '../../common/DetectorResult';
3
+ import DecodeHintType from '../../DecodeHintType';
4
+ import ResultPoint from '../../ResultPoint';
5
+ import ResultPointCallback from '../../ResultPointCallback';
6
+ import AlignmentPattern from './AlignmentPattern';
7
+ import FinderPatternInfo from './FinderPatternInfo';
8
+ /**
9
+ * <p>Encapsulates logic that can detect a QR Code in an image, even if the QR Code
10
+ * is rotated or skewed, or partially obscured.</p>
11
+ *
12
+ * @author Sean Owen
13
+ */
14
+ export default class Detector {
15
+ private image;
16
+ private resultPointCallback?;
17
+ constructor(image: BitMatrix);
18
+ protected getImage(): BitMatrix;
19
+ protected getResultPointCallback(): ResultPointCallback | undefined;
20
+ /**
21
+ * <p>Detects a QR Code in an image.</p>
22
+ *
23
+ * @return {@link DetectorResult} encapsulating results of detecting a QR Code
24
+ * @throws NotFoundException if QR Code cannot be found
25
+ * @throws FormatException if a QR Code cannot be decoded
26
+ */
27
+ /**
28
+ * <p>Detects a QR Code in an image.</p>
29
+ *
30
+ * @param hints optional hints to detector
31
+ * @return {@link DetectorResult} encapsulating results of detecting a QR Code
32
+ * @throws NotFoundException if QR Code cannot be found
33
+ * @throws FormatException if a QR Code cannot be decoded
34
+ */
35
+ detect(hints: Map<DecodeHintType, any>): DetectorResult;
36
+ protected processFinderPatternInfo(info: FinderPatternInfo): DetectorResult;
37
+ private static createTransform;
38
+ private static sampleGrid;
39
+ /**
40
+ * <p>Computes the dimension (number of modules on a size) of the QR Code based on the position
41
+ * of the finder patterns and estimated module size.</p>
42
+ */
43
+ private static computeDimension;
44
+ /**
45
+ * <p>Computes an average estimated module size based on estimated derived from the positions
46
+ * of the three finder patterns.</p>
47
+ *
48
+ * @param topLeft detected top-left finder pattern center
49
+ * @param topRight detected top-right finder pattern center
50
+ * @param bottomLeft detected bottom-left finder pattern center
51
+ * @return estimated module size
52
+ */
53
+ protected calculateModuleSize(topLeft: ResultPoint, topRight: ResultPoint, bottomLeft: ResultPoint): number;
54
+ /**
55
+ * <p>Estimates module size based on two finder patterns -- it uses
56
+ * {@link #sizeOfBlackWhiteBlackRunBothWays(int, int, int, int)} to figure the
57
+ * width of each, measuring along the axis between their centers.</p>
58
+ */
59
+ private calculateModuleSizeOneWay;
60
+ /**
61
+ * See {@link #sizeOfBlackWhiteBlackRun(int, int, int, int)}; computes the total width of
62
+ * a finder pattern by looking for a black-white-black run from the center in the direction
63
+ * of another point (another finder pattern center), and in the opposite direction too.
64
+ */
65
+ private sizeOfBlackWhiteBlackRunBothWays;
66
+ /**
67
+ * <p>This method traces a line from a point in the image, in the direction towards another point.
68
+ * It begins in a black region, and keeps going until it finds white, then black, then white again.
69
+ * It reports the distance from the start to this point.</p>
70
+ *
71
+ * <p>This is used when figuring out how wide a finder pattern is, when the finder pattern
72
+ * may be skewed or rotated.</p>
73
+ */
74
+ private sizeOfBlackWhiteBlackRun;
75
+ /**
76
+ * <p>Attempts to locate an alignment pattern in a limited region of the image, which is
77
+ * guessed to contain it. This method uses {@link AlignmentPattern}.</p>
78
+ *
79
+ * @param overallEstModuleSize estimated module size so far
80
+ * @param estAlignmentX x coordinate of center of area probably containing alignment pattern
81
+ * @param estAlignmentY y coordinate of above
82
+ * @param allowanceFactor number of pixels in all directions to search from the center
83
+ * @return {@link AlignmentPattern} if found, or null otherwise
84
+ * @throws NotFoundException if an unexpected error occurs during detection
85
+ */
86
+ protected findAlignmentInRegion(overallEstModuleSize: number, estAlignmentX: number, estAlignmentY: number, allowanceFactor: number): AlignmentPattern;
87
+ }
@@ -0,0 +1,26 @@
1
+ import ResultPoint from '../../ResultPoint';
2
+ /**
3
+ * <p>Encapsulates a finder pattern, which are the three square patterns found in
4
+ * the corners of QR Codes. It also encapsulates a count of similar finder patterns,
5
+ * as a convenience to the finder's bookkeeping.</p>
6
+ *
7
+ * @author Sean Owen
8
+ */
9
+ export default class FinderPattern extends ResultPoint {
10
+ private estimatedModuleSize;
11
+ private count?;
12
+ constructor(posX: number, posY: number, estimatedModuleSize: number, count?: number | undefined);
13
+ getEstimatedModuleSize(): number;
14
+ getCount(): number | undefined;
15
+ /**
16
+ * <p>Determines if this finder pattern "about equals" a finder pattern at the stated
17
+ * position and size -- meaning, it is at nearly the same center with nearly the same size.</p>
18
+ */
19
+ aboutEquals(moduleSize: number, i: number, j: number): boolean;
20
+ /**
21
+ * Combines this object's current estimate of a finder pattern position and module size
22
+ * with a new estimate. It returns a new {@code FinderPattern} containing a weighted average
23
+ * based on count.
24
+ */
25
+ combineEstimate(i: number, j: number, newModuleSize: number): FinderPattern;
26
+ }
@@ -0,0 +1,114 @@
1
+ import BitMatrix from '../../common/BitMatrix';
2
+ import DecodeHintType from '../../DecodeHintType';
3
+ import ResultPointCallback from '../../ResultPointCallback';
4
+ import FinderPattern from './FinderPattern';
5
+ import FinderPatternInfo from './FinderPatternInfo';
6
+ /**
7
+ * <p>This class attempts to find finder patterns in a QR Code. Finder patterns are the square
8
+ * markers at three corners of a QR Code.</p>
9
+ *
10
+ * <p>This class is thread-safe but not reentrant. Each thread must allocate its own object.
11
+ *
12
+ * @author Sean Owen
13
+ */
14
+ export default class FinderPatternFinder {
15
+ private image;
16
+ private resultPointCallback;
17
+ private static CENTER_QUORUM;
18
+ protected static MIN_SKIP: number;
19
+ protected static MAX_MODULES: number;
20
+ private possibleCenters;
21
+ private hasSkipped?;
22
+ private crossCheckStateCount;
23
+ /**
24
+ * <p>Creates a finder that will search the image for three finder patterns.</p>
25
+ *
26
+ * @param image image to search
27
+ */
28
+ constructor(image: BitMatrix, resultPointCallback: ResultPointCallback);
29
+ protected getImage(): BitMatrix;
30
+ protected getPossibleCenters(): FinderPattern[];
31
+ find(hints: Map<DecodeHintType, any>): FinderPatternInfo;
32
+ /**
33
+ * Given a count of black/white/black/white/black pixels just seen and an end position,
34
+ * figures the location of the center of this run.
35
+ */
36
+ private static centerFromEnd;
37
+ /**
38
+ * @param stateCount count of black/white/black/white/black pixels just read
39
+ * @return true iff the proportions of the counts is close enough to the 1/1/3/1/1 ratios
40
+ * used by finder patterns to be considered a match
41
+ */
42
+ protected static foundPatternCross(stateCount: Int32Array): boolean;
43
+ private getCrossCheckStateCount;
44
+ /**
45
+ * After a vertical and horizontal scan finds a potential finder pattern, this method
46
+ * "cross-cross-cross-checks" by scanning down diagonally through the center of the possible
47
+ * finder pattern to see if the same proportion is detected.
48
+ *
49
+ * @param startI row where a finder pattern was detected
50
+ * @param centerJ center of the section that appears to cross a finder pattern
51
+ * @param maxCount maximum reasonable number of modules that should be
52
+ * observed in any reading state, based on the results of the horizontal scan
53
+ * @param originalStateCountTotal The original state count total.
54
+ * @return true if proportions are withing expected limits
55
+ */
56
+ private crossCheckDiagonal;
57
+ /**
58
+ * <p>After a horizontal scan finds a potential finder pattern, this method
59
+ * "cross-checks" by scanning down vertically through the center of the possible
60
+ * finder pattern to see if the same proportion is detected.</p>
61
+ *
62
+ * @param startI row where a finder pattern was detected
63
+ * @param centerJ center of the section that appears to cross a finder pattern
64
+ * @param maxCount maximum reasonable number of modules that should be
65
+ * observed in any reading state, based on the results of the horizontal scan
66
+ * @return vertical center of finder pattern, or {@link Float#NaN} if not found
67
+ */
68
+ private crossCheckVertical;
69
+ /**
70
+ * <p>Like {@link #crossCheckVertical(int, int, int, int)}, and in fact is basically identical,
71
+ * except it reads horizontally instead of vertically. This is used to cross-cross
72
+ * check a vertical cross check and locate the real center of the alignment pattern.</p>
73
+ */
74
+ private crossCheckHorizontal;
75
+ /**
76
+ * <p>This is called when a horizontal scan finds a possible alignment pattern. It will
77
+ * cross check with a vertical scan, and if successful, will, ah, cross-cross-check
78
+ * with another horizontal scan. This is needed primarily to locate the real horizontal
79
+ * center of the pattern in cases of extreme skew.
80
+ * And then we cross-cross-cross check with another diagonal scan.</p>
81
+ *
82
+ * <p>If that succeeds the finder pattern location is added to a list that tracks
83
+ * the number of times each location has been nearly-matched as a finder pattern.
84
+ * Each additional find is more evidence that the location is in fact a finder
85
+ * pattern center
86
+ *
87
+ * @param stateCount reading state module counts from horizontal scan
88
+ * @param i row where finder pattern may be found
89
+ * @param j end of possible finder pattern in row
90
+ * @param pureBarcode true if in "pure barcode" mode
91
+ * @return true if a finder pattern candidate was found this time
92
+ */
93
+ protected handlePossibleCenter(stateCount: Int32Array, i: number, j: number, pureBarcode: boolean): boolean;
94
+ /**
95
+ * @return number of rows we could safely skip during scanning, based on the first
96
+ * two finder patterns that have been located. In some cases their position will
97
+ * allow us to infer that the third pattern must lie below a certain point farther
98
+ * down in the image.
99
+ */
100
+ private findRowSkip;
101
+ /**
102
+ * @return true iff we have found at least 3 finder patterns that have been detected
103
+ * at least {@link #CENTER_QUORUM} times each, and, the estimated module size of the
104
+ * candidates is "pretty similar"
105
+ */
106
+ private haveMultiplyConfirmedCenters;
107
+ /**
108
+ * @return the 3 best {@link FinderPattern}s from our list of candidates. The "best" are
109
+ * those that have been detected at least {@link #CENTER_QUORUM} times, and whose module
110
+ * size differs from the average among those patterns the least
111
+ * @throws NotFoundException if 3 such finder patterns do not exist
112
+ */
113
+ private selectBestPatterns;
114
+ }
@@ -0,0 +1,16 @@
1
+ import FinderPattern from './FinderPattern';
2
+ /**
3
+ * <p>Encapsulates information about finder patterns in an image, including the location of
4
+ * the three finder patterns, and their estimated module size.</p>
5
+ *
6
+ * @author Sean Owen
7
+ */
8
+ export default class FinderPatternInfo {
9
+ private bottomLeft;
10
+ private topLeft;
11
+ private topRight;
12
+ constructor(patternCenters: FinderPattern[]);
13
+ getBottomLeft(): FinderPattern;
14
+ getTopLeft(): FinderPattern;
15
+ getTopRight(): FinderPattern;
16
+ }
@@ -0,0 +1,45 @@
1
+ import { int } from '../../customTypings';
2
+ export default class Arrays {
3
+ /**
4
+ * Assigns the specified int value to each element of the specified array
5
+ * of ints.
6
+ *
7
+ * @param a the array to be filled
8
+ * @param val the value to be stored in all elements of the array
9
+ */
10
+ static fill(a: Int32Array | Uint8Array | any[], val: int): void;
11
+ /**
12
+ * Assigns the specified int value to each element of the specified
13
+ * range of the specified array of ints. The range to be filled
14
+ * extends from index {@code fromIndex}, inclusive, to index
15
+ * {@code toIndex}, exclusive. (If {@code fromIndex==toIndex}, the
16
+ * range to be filled is empty.)
17
+ *
18
+ * @param a the array to be filled
19
+ * @param fromIndex the index of the first element (inclusive) to be
20
+ * filled with the specified value
21
+ * @param toIndex the index of the last element (exclusive) to be
22
+ * filled with the specified value
23
+ * @param val the value to be stored in all elements of the array
24
+ * @throws IllegalArgumentException if {@code fromIndex > toIndex}
25
+ * @throws ArrayIndexOutOfBoundsException if {@code fromIndex < 0} or
26
+ * {@code toIndex > a.length}
27
+ */
28
+ static fillWithin(a: Int32Array, fromIndex: int, toIndex: int, val: int): void;
29
+ /**
30
+ * Checks that {@code fromIndex} and {@code toIndex} are in
31
+ * the range and throws an exception if they aren't.
32
+ */
33
+ static rangeCheck(arrayLength: int, fromIndex: int, toIndex: int): void;
34
+ static asList<T = any>(...args: T[]): T[];
35
+ static create<T = any>(rows: int, cols: int, value?: T): T[][];
36
+ static createInt32Array(rows: int, cols: int, value?: int): Int32Array[];
37
+ static equals(first: any, second: any): boolean;
38
+ static hashCode(a: any): number;
39
+ static fillUint8Array(a: Uint8Array, value: number): void;
40
+ static copyOf(original: Int32Array, newLength: number): Int32Array;
41
+ static copyOfUint8Array(original: Uint8Array, newLength: number): Uint8Array;
42
+ static copyOfRange(original: Int32Array, from: number, to: number): Int32Array;
43
+ static binarySearch(ar: Int32Array, el: number, comparator?: (a: number, b: number) => number): number;
44
+ static numberComparator(a: number, b: number): number;
45
+ }
@@ -0,0 +1,7 @@
1
+ import CharacterSetECI from '../common/CharacterSetECI';
2
+ /**
3
+ * Just to make a shortcut between Java code and TS code.
4
+ */
5
+ export default class Charset extends CharacterSetECI {
6
+ static forName(name: string): Charset;
7
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Ponyfill for Java's Float class.
3
+ */
4
+ export default class Float {
5
+ /**
6
+ * The float max value in JS is the number max value.
7
+ */
8
+ static MAX_VALUE: number;
9
+ /**
10
+ * SincTS has no difference between int and float, there's all numbers,
11
+ * this is used only to polyfill Java code.
12
+ */
13
+ static floatToIntBits(f: number): number;
14
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Ponyfill for Java's Integer class.
3
+ */
4
+ export default class Integer {
5
+ static MIN_VALUE_32_BITS: number;
6
+ static MAX_VALUE: number;
7
+ static numberOfTrailingZeros(i: number): number;
8
+ static numberOfLeadingZeros(i: number): number;
9
+ static toHexString(i: number): string;
10
+ static toBinaryString(intNumber: number): string;
11
+ static bitCount(i: number): number;
12
+ static truncDivision(dividend: number, divisor: number): number;
13
+ /**
14
+ * Converts A string to an integer.
15
+ * @param s A string to convert into a number.
16
+ * @param radix A value between 2 and 36 that specifies the base of the number in numString. If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. All other strings are considered decimal.
17
+ */
18
+ static parseInt(num: string, radix?: number): number;
19
+ }
@@ -0,0 +1,21 @@
1
+ import { char, int } from '../../customTypings';
2
+ import CharacterSetECI from '../common/CharacterSetECI';
3
+ export default class StringBuilder {
4
+ private value;
5
+ private encoding?;
6
+ constructor(value?: string);
7
+ enableDecoding(encoding: CharacterSetECI): StringBuilder;
8
+ append(s: string | number): StringBuilder;
9
+ appendChars(str: char[] | string[], offset: int, len: int): StringBuilder;
10
+ length(): number;
11
+ charAt(n: number): string;
12
+ deleteCharAt(n: number): void;
13
+ setCharAt(n: number, c: string): void;
14
+ substring(start: int, end: int): string;
15
+ /**
16
+ * @note helper method for RSS Expanded
17
+ */
18
+ setLengthToZero(): void;
19
+ toString(): string;
20
+ insert(n: number, c: string): void;
21
+ }
@@ -0,0 +1,51 @@
1
+ import CharacterSetECI from '../common/CharacterSetECI';
2
+ /**
3
+ * Responsible for en/decoding strings.
4
+ */
5
+ export default class StringEncoding {
6
+ /**
7
+ * Allows the user to set a custom decoding function
8
+ * so more encoding formats the native ones can be supported.
9
+ */
10
+ static customDecoder: (bytes: Uint8Array, encodingName: string) => string;
11
+ /**
12
+ * Allows the user to set a custom encoding function
13
+ * so more encoding formats the native ones can be supported.
14
+ */
15
+ static customEncoder: (s: string, encodingName: string) => Uint8Array;
16
+ /**
17
+ * Decodes some Uint8Array to a string format.
18
+ */
19
+ static decode(bytes: Uint8Array, encoding: string | CharacterSetECI): string;
20
+ /**
21
+ * Checks if the decoding method should use the fallback for decoding
22
+ * once Node TextDecoder doesn't support all encoding formats.
23
+ *
24
+ * @param encodingName
25
+ */
26
+ private static shouldDecodeOnFallback;
27
+ /**
28
+ * Encodes some string into a Uint8Array.
29
+ */
30
+ static encode(s: string, encoding: string | CharacterSetECI): Uint8Array;
31
+ private static isBrowser;
32
+ /**
33
+ * Returns the string value from some encoding character set.
34
+ */
35
+ static encodingName(encoding: string | CharacterSetECI): string;
36
+ /**
37
+ * Returns character set from some encoding character set.
38
+ */
39
+ static encodingCharacterSet(encoding: string | CharacterSetECI): CharacterSetECI;
40
+ /**
41
+ * Runs a fallback for the native decoding funcion.
42
+ */
43
+ private static decodeFallback;
44
+ private static isDecodeFallbackSupported;
45
+ /**
46
+ * Runs a fallback for the native encoding funcion.
47
+ *
48
+ * @see https://stackoverflow.com/a/17192845/4367683
49
+ */
50
+ private static encodeFallback;
51
+ }
@@ -0,0 +1,10 @@
1
+ export default class System {
2
+ /**
3
+ * Makes a copy of a array.
4
+ */
5
+ static arraycopy(src: any, srcPos: number, dest: any, destPos: number, length: number): void;
6
+ /**
7
+ * Returns the current time in milliseconds.
8
+ */
9
+ static currentTimeMillis(): number;
10
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * This file contains some types to make our
3
+ * lifes easier when copy and pasting Java code.
4
+ * With it we can keep int, float, etc., references
5
+ * in code to keep as close as possible as the Java version
6
+ * but without the need to sacrifice ourselves with boring
7
+ * and annoying things.
8
+ */
9
+ export declare type byte = number;
10
+ export declare type short = number;
11
+ export declare type int = number;
12
+ export declare type float = number;
13
+ export type char = number;
14
+ export type List<T> = T[];
15
+ export type Collection<T> = T[];
16
+ export type Deque<T> = T[];
@@ -0,0 +1,5 @@
1
+ export * from './browser';
2
+ export { default as BinaryBitmap } from './core/BinaryBitmap';
3
+ export { default as InvertedLuminanceSource } from './core/InvertedLuminanceSource';
4
+ export { default as LuminanceSource } from './core/LuminanceSource';
5
+ export { default as HybridBinarizer } from './core/common/HybridBinarizer';
@@ -0,0 +1 @@
1
+ export { NodeLuminanceSource } from './core/NodeLuminanceSource';