@qr-platform/qr-code.js 0.8.17

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 (208) hide show
  1. package/.github/workflows/publish.yml +18 -0
  2. package/CHANGELOG.md +233 -0
  3. package/LICENSE.md +77 -0
  4. package/README.md +188 -0
  5. package/docs/advanced-examples.md +523 -0
  6. package/docs/api-reference-guide.md +254 -0
  7. package/docs/documentation.md +1592 -0
  8. package/docs/examples.md +322 -0
  9. package/docs/license-management.md +501 -0
  10. package/docs/typescript-types-definitions.md +372 -0
  11. package/docs/usage-guide.md +622 -0
  12. package/lib/core/qr-code-js.d.ts +48 -0
  13. package/lib/core/qr-constant.d.ts +9 -0
  14. package/lib/core/qr-options-validation.d.ts +13 -0
  15. package/lib/core/qr-svg.d.ts +76 -0
  16. package/lib/core/qr-templates.d.ts +6 -0
  17. package/lib/figures/corner-dot.d.ts +24 -0
  18. package/lib/figures/corner-square.d.ts +24 -0
  19. package/lib/figures/dot.d.ts +31 -0
  20. package/lib/index.d.ts +52 -0
  21. package/lib/lib/image/GIFImage.d.ts +19 -0
  22. package/lib/lib/io/Base64.d.ts +10 -0
  23. package/lib/lib/io/Base64DecodeInputStream.d.ts +15 -0
  24. package/lib/lib/io/Base64EncodeOutputStream.d.ts +17 -0
  25. package/lib/lib/io/ByteArrayInputStream.d.ts +12 -0
  26. package/lib/lib/io/ByteArrayOutputStream.d.ts +12 -0
  27. package/lib/lib/io/InputStream.d.ts +10 -0
  28. package/lib/lib/io/OutputStream.d.ts +12 -0
  29. package/lib/lib/qr-code.d.ts +5 -0
  30. package/lib/lib/qrcode/BitBuffer.d.ts +11 -0
  31. package/lib/lib/qrcode/ErrorCorrectLevel.d.ts +23 -0
  32. package/lib/lib/qrcode/MaskPattern.d.ts +39 -0
  33. package/lib/lib/qrcode/Mode.d.ts +23 -0
  34. package/lib/lib/qrcode/Polynomial.d.ts +15 -0
  35. package/lib/lib/qrcode/QR8BitByte.d.ts +13 -0
  36. package/lib/lib/qrcode/QRAlphaNum.d.ts +13 -0
  37. package/lib/lib/qrcode/QRCode.d.ts +22 -0
  38. package/lib/lib/qrcode/QRCodeMinimal.d.ts +58 -0
  39. package/lib/lib/qrcode/QRData.d.ts +17 -0
  40. package/lib/lib/qrcode/QRKanji.d.ts +13 -0
  41. package/lib/lib/qrcode/QRMath.d.ts +13 -0
  42. package/lib/lib/qrcode/QRNumber.d.ts +14 -0
  43. package/lib/lib/qrcode/QRUtil.d.ts +25 -0
  44. package/lib/lib/qrcode/RSBlock.d.ts +16 -0
  45. package/lib/lib/text/createStringToBytes.d.ts +9 -0
  46. package/lib/lib/text/stringToBytes_SJIS.d.ts +8 -0
  47. package/lib/lib/text/stringToBytes_UTF8.d.ts +7 -0
  48. package/lib/lib/zbar-wasm/index.d.ts +1 -0
  49. package/lib/lib/zxing-js/src/browser/BrowserCodeReader.d.ts +410 -0
  50. package/lib/lib/zxing-js/src/browser/BrowserQRCodeReader.d.ts +29 -0
  51. package/lib/lib/zxing-js/src/browser/BrowserQRCodeSvgWriter.d.ts +46 -0
  52. package/lib/lib/zxing-js/src/browser/BrowserSvgCodeWriter.d.ts +49 -0
  53. package/lib/lib/zxing-js/src/browser/DecodeContinuouslyCallback.d.ts +6 -0
  54. package/lib/lib/zxing-js/src/browser/HTMLCanvasElementLuminanceSource.d.ts +27 -0
  55. package/lib/lib/zxing-js/src/browser/HTMLVisualMediaElement.d.ts +4 -0
  56. package/lib/lib/zxing-js/src/browser/VideoInputDevice.d.ts +22 -0
  57. package/lib/lib/zxing-js/src/browser.d.ts +3 -0
  58. package/lib/lib/zxing-js/src/core/ArgumentException.d.ts +7 -0
  59. package/lib/lib/zxing-js/src/core/ArithmeticException.d.ts +7 -0
  60. package/lib/lib/zxing-js/src/core/ArrayIndexOutOfBoundsException.d.ts +10 -0
  61. package/lib/lib/zxing-js/src/core/BarcodeFormat.d.ts +42 -0
  62. package/lib/lib/zxing-js/src/core/Binarizer.d.ts +53 -0
  63. package/lib/lib/zxing-js/src/core/BinaryBitmap.d.ts +78 -0
  64. package/lib/lib/zxing-js/src/core/ChecksumException.d.ts +8 -0
  65. package/lib/lib/zxing-js/src/core/DecodeHintType.d.ts +91 -0
  66. package/lib/lib/zxing-js/src/core/Dimension.d.ts +13 -0
  67. package/lib/lib/zxing-js/src/core/EncodeHintType.d.ts +99 -0
  68. package/lib/lib/zxing-js/src/core/Exception.d.ts +17 -0
  69. package/lib/lib/zxing-js/src/core/FormatException.d.ts +8 -0
  70. package/lib/lib/zxing-js/src/core/HighContrastLuminanceSource.d.ts +27 -0
  71. package/lib/lib/zxing-js/src/core/IllegalArgumentException.d.ts +7 -0
  72. package/lib/lib/zxing-js/src/core/IllegalStateException.d.ts +7 -0
  73. package/lib/lib/zxing-js/src/core/IndexOutOfBoundsException.d.ts +7 -0
  74. package/lib/lib/zxing-js/src/core/InvertedLuminanceSource.d.ts +22 -0
  75. package/lib/lib/zxing-js/src/core/LuminanceSource.d.ts +84 -0
  76. package/lib/lib/zxing-js/src/core/NodeLuminanceSource.d.ts +36 -0
  77. package/lib/lib/zxing-js/src/core/NotFoundException.d.ts +8 -0
  78. package/lib/lib/zxing-js/src/core/NullPointerException.d.ts +7 -0
  79. package/lib/lib/zxing-js/src/core/OutOfMemoryError.d.ts +6 -0
  80. package/lib/lib/zxing-js/src/core/PlanarYUVLuminanceSource.d.ts +35 -0
  81. package/lib/lib/zxing-js/src/core/RGBLuminanceSource.d.ts +21 -0
  82. package/lib/lib/zxing-js/src/core/Reader.d.ts +49 -0
  83. package/lib/lib/zxing-js/src/core/ReaderException.d.ts +7 -0
  84. package/lib/lib/zxing-js/src/core/ReedSolomonException.d.ts +7 -0
  85. package/lib/lib/zxing-js/src/core/Result.d.ts +52 -0
  86. package/lib/lib/zxing-js/src/core/ResultMetadataType.d.ts +68 -0
  87. package/lib/lib/zxing-js/src/core/ResultPoint.d.ts +34 -0
  88. package/lib/lib/zxing-js/src/core/ResultPointCallback.d.ts +11 -0
  89. package/lib/lib/zxing-js/src/core/UniversalLuminanceSource.d.ts +46 -0
  90. package/lib/lib/zxing-js/src/core/UnsupportedOperationException.d.ts +7 -0
  91. package/lib/lib/zxing-js/src/core/Writer.d.ts +30 -0
  92. package/lib/lib/zxing-js/src/core/WriterException.d.ts +7 -0
  93. package/lib/lib/zxing-js/src/core/common/BitArray.d.ts +111 -0
  94. package/lib/lib/zxing-js/src/core/common/BitMatrix.d.ts +98 -0
  95. package/lib/lib/zxing-js/src/core/common/BitSource.d.ts +38 -0
  96. package/lib/lib/zxing-js/src/core/common/CharacterSetECI.d.ts +89 -0
  97. package/lib/lib/zxing-js/src/core/common/DecoderResult.d.ts +64 -0
  98. package/lib/lib/zxing-js/src/core/common/DefaultGridSampler.d.ts +10 -0
  99. package/lib/lib/zxing-js/src/core/common/DetectorResult.d.ts +16 -0
  100. package/lib/lib/zxing-js/src/core/common/ECIEncoderSet.d.ts +37 -0
  101. package/lib/lib/zxing-js/src/core/common/ECIInput.d.ts +79 -0
  102. package/lib/lib/zxing-js/src/core/common/GlobalHistogramBinarizer.d.ts +29 -0
  103. package/lib/lib/zxing-js/src/core/common/GridSampler.d.ts +36 -0
  104. package/lib/lib/zxing-js/src/core/common/GridSamplerInstance.d.ts +18 -0
  105. package/lib/lib/zxing-js/src/core/common/HybridBinarizer.d.ts +54 -0
  106. package/lib/lib/zxing-js/src/core/common/MinimalECIInput.d.ts +123 -0
  107. package/lib/lib/zxing-js/src/core/common/PerspectiveTransform.d.ts +26 -0
  108. package/lib/lib/zxing-js/src/core/common/StringUtils.d.ts +48 -0
  109. package/lib/lib/zxing-js/src/core/common/detector/CornerDetector.d.ts +35 -0
  110. package/lib/lib/zxing-js/src/core/common/detector/MathUtils.d.ts +36 -0
  111. package/lib/lib/zxing-js/src/core/common/detector/WhiteRectangleDetector.d.ts +71 -0
  112. package/lib/lib/zxing-js/src/core/common/reedsolomon/AbstractGenericGF.d.ts +34 -0
  113. package/lib/lib/zxing-js/src/core/common/reedsolomon/AbstractGenericGFPoly.d.ts +36 -0
  114. package/lib/lib/zxing-js/src/core/common/reedsolomon/GenericGF.d.ts +58 -0
  115. package/lib/lib/zxing-js/src/core/common/reedsolomon/GenericGFPoly.d.ts +47 -0
  116. package/lib/lib/zxing-js/src/core/common/reedsolomon/ReedSolomonDecoder.d.ts +40 -0
  117. package/lib/lib/zxing-js/src/core/common/reedsolomon/ReedSolomonEncoder.d.ts +41 -0
  118. package/lib/lib/zxing-js/src/core/qrcode/QRCodeReader.d.ts +35 -0
  119. package/lib/lib/zxing-js/src/core/qrcode/QRCodeWriter.d.ts +13 -0
  120. package/lib/lib/zxing-js/src/core/qrcode/decoder/BitMatrixParser.d.ts +58 -0
  121. package/lib/lib/zxing-js/src/core/qrcode/decoder/DataBlock.d.ts +28 -0
  122. package/lib/lib/zxing-js/src/core/qrcode/decoder/DataMask.d.ts +36 -0
  123. package/lib/lib/zxing-js/src/core/qrcode/decoder/DecodedBitStreamParser.d.ts +30 -0
  124. package/lib/lib/zxing-js/src/core/qrcode/decoder/Decoder.d.ts +44 -0
  125. package/lib/lib/zxing-js/src/core/qrcode/decoder/ECB.d.ts +12 -0
  126. package/lib/lib/zxing-js/src/core/qrcode/decoder/ECBlocks.d.ts +16 -0
  127. package/lib/lib/zxing-js/src/core/qrcode/decoder/ErrorCorrectionLevel.d.ts +38 -0
  128. package/lib/lib/zxing-js/src/core/qrcode/decoder/FormatInformation.d.ts +33 -0
  129. package/lib/lib/zxing-js/src/core/qrcode/decoder/Mode.d.ts +56 -0
  130. package/lib/lib/zxing-js/src/core/qrcode/decoder/QRCodeDecoderMetaData.d.ts +21 -0
  131. package/lib/lib/zxing-js/src/core/qrcode/decoder/Version.d.ts +44 -0
  132. package/lib/lib/zxing-js/src/core/qrcode/detector/AlignmentPattern.d.ts +21 -0
  133. package/lib/lib/zxing-js/src/core/qrcode/detector/AlignmentPatternFinder.d.ts +82 -0
  134. package/lib/lib/zxing-js/src/core/qrcode/detector/Detector.d.ts +87 -0
  135. package/lib/lib/zxing-js/src/core/qrcode/detector/FinderPattern.d.ts +26 -0
  136. package/lib/lib/zxing-js/src/core/qrcode/detector/FinderPatternFinder.d.ts +114 -0
  137. package/lib/lib/zxing-js/src/core/qrcode/detector/FinderPatternInfo.d.ts +16 -0
  138. package/lib/lib/zxing-js/src/core/qrcode/encoder/BlockPair.d.ts +7 -0
  139. package/lib/lib/zxing-js/src/core/qrcode/encoder/ByteMatrix.d.ts +24 -0
  140. package/lib/lib/zxing-js/src/core/qrcode/encoder/Encoder.d.ts +85 -0
  141. package/lib/lib/zxing-js/src/core/qrcode/encoder/MaskUtil.d.ts +47 -0
  142. package/lib/lib/zxing-js/src/core/qrcode/encoder/MatrixUtil.d.ts +37 -0
  143. package/lib/lib/zxing-js/src/core/qrcode/encoder/QRCode.d.ts +29 -0
  144. package/lib/lib/zxing-js/src/core/util/Arrays.d.ts +45 -0
  145. package/lib/lib/zxing-js/src/core/util/ByteArrayOutputStream.d.ts +174 -0
  146. package/lib/lib/zxing-js/src/core/util/Charset.d.ts +7 -0
  147. package/lib/lib/zxing-js/src/core/util/Collections.d.ts +11 -0
  148. package/lib/lib/zxing-js/src/core/util/Float.d.ts +14 -0
  149. package/lib/lib/zxing-js/src/core/util/Formatter.d.ts +28 -0
  150. package/lib/lib/zxing-js/src/core/util/Integer.d.ts +19 -0
  151. package/lib/lib/zxing-js/src/core/util/Long.d.ts +12 -0
  152. package/lib/lib/zxing-js/src/core/util/OutputStream.d.ts +106 -0
  153. package/lib/lib/zxing-js/src/core/util/StandardCharsets.d.ts +7 -0
  154. package/lib/lib/zxing-js/src/core/util/StringBuilder.d.ts +21 -0
  155. package/lib/lib/zxing-js/src/core/util/StringEncoding.d.ts +51 -0
  156. package/lib/lib/zxing-js/src/core/util/System.d.ts +10 -0
  157. package/lib/lib/zxing-js/src/customTypings.d.ts +16 -0
  158. package/lib/lib/zxing-js/src/index.d.ts +5 -0
  159. package/lib/lib/zxing-js/src/node.d.ts +1 -0
  160. package/lib/license/LicenseManager.d.ts +69 -0
  161. package/lib/license/LicenseManagerNode.d.ts +64 -0
  162. package/lib/node.d.ts +37 -0
  163. package/lib/options-demo.d.ts +239 -0
  164. package/lib/plugins/QRBorderHelpers.d.ts +32 -0
  165. package/lib/plugins/QRBorderPlugin.d.ts +35 -0
  166. package/lib/plugins/QRValidatorZbar.d.ts +38 -0
  167. package/lib/plugins/QRValidatorZbarNode.d.ts +60 -0
  168. package/lib/plugins/QRValidatorZbarNodeSharp.d.ts +83 -0
  169. package/lib/qr-code-js-node.js +1 -0
  170. package/lib/qr-code-js.js +1 -0
  171. package/lib/templates/borders-inner-outter.d.ts +129 -0
  172. package/lib/templates/borders-inner-scale-offset.d.ts +497 -0
  173. package/lib/templates/borders-inner.d.ts +129 -0
  174. package/lib/templates/borders-no-license.d.ts +129 -0
  175. package/lib/templates/borders-outter.d.ts +129 -0
  176. package/lib/templates/borders-text-auto-curved.d.ts +129 -0
  177. package/lib/templates/borders-text-full-curved.d.ts +133 -0
  178. package/lib/templates/borders.d.ts +129 -0
  179. package/lib/templates/scales.d.ts +130 -0
  180. package/lib/templates/scan-validators/index.d.ts +1 -0
  181. package/lib/templates/scan-validators/tests/cases/basic-inverted.d.ts +9 -0
  182. package/lib/templates/scan-validators/tests/cases/basic-no-license.d.ts +3 -0
  183. package/lib/templates/scan-validators/tests/cases/basic.d.ts +3 -0
  184. package/lib/templates/scan-validators/tests/cases/colors-inverted.d.ts +2 -0
  185. package/lib/templates/scan-validators/tests/cases/colors.d.ts +58 -0
  186. package/lib/templates/scan-validators/tests/cases/out-of-borders-inverted.d.ts +9 -0
  187. package/lib/templates/scan-validators/tests/cases/out-of-borders.d.ts +9 -0
  188. package/lib/templates/scan-validators/tests/cases/position-inverted.d.ts +9 -0
  189. package/lib/templates/scan-validators/tests/cases/position.d.ts +3 -0
  190. package/lib/templates/scan-validators/tests/index.d.ts +27 -0
  191. package/lib/tools/browser-image-tools.d.ts +7 -0
  192. package/lib/tools/browser-utils.d.ts +18 -0
  193. package/lib/types/helper.d.ts +23 -0
  194. package/lib/utils/canvas-options.d.ts +7 -0
  195. package/lib/utils/color.d.ts +4 -0
  196. package/lib/utils/gradient.d.ts +26 -0
  197. package/lib/utils/image.d.ts +16 -0
  198. package/lib/utils/merge.d.ts +5 -0
  199. package/lib/utils/options.d.ts +220 -0
  200. package/lib/utils/qrcode.d.ts +8 -0
  201. package/lib/utils/scan-validator-node.d.ts +15 -0
  202. package/lib/utils/scan-validators/abstract-scan-validator.d.ts +43 -0
  203. package/lib/utils/scan-validators/zbar-scan-validator.d.ts +8 -0
  204. package/lib/utils/scan-validators/zxing-canvas-scan-validator.d.ts +10 -0
  205. package/lib/utils/scan-validators/zxing-scan-validator.d.ts +8 -0
  206. package/lib/utils/svg.d.ts +2 -0
  207. package/lib/utils/token-validator.d.ts +19 -0
  208. package/package.json +80 -0
@@ -0,0 +1,36 @@
1
+ /**
2
+ * General math-related and numeric utility functions.
3
+ */
4
+ export default class MathUtils {
5
+ private constructor();
6
+ /**
7
+ * Ends up being a bit faster than {@link Math#round(float)}. This merely rounds its
8
+ * argument to the nearest int, where x.5 rounds up to x+1. Semantics of this shortcut
9
+ * differ slightly from {@link Math#round(float)} in that half rounds down for negative
10
+ * values. -2.5 rounds to -3, not -2. For purposes here it makes no difference.
11
+ *
12
+ * @param d real value to round
13
+ * @return nearest {@code int}
14
+ */
15
+ static round(d: number): number;
16
+ /**
17
+ * @param aX point A x coordinate
18
+ * @param aY point A y coordinate
19
+ * @param bX point B x coordinate
20
+ * @param bY point B y coordinate
21
+ * @return Euclidean distance between points A and B
22
+ */
23
+ static distance(aX: number, aY: number, bX: number, bY: number): number;
24
+ /**
25
+ * @param aX point A x coordinate
26
+ * @param aY point A y coordinate
27
+ * @param bX point B x coordinate
28
+ * @param bY point B y coordinate
29
+ * @return Euclidean distance between points A and B
30
+ */
31
+ /**
32
+ * @param array values to sum
33
+ * @return sum of values in array
34
+ */
35
+ static sum(array: Int32Array): number;
36
+ }
@@ -0,0 +1,71 @@
1
+ import ResultPoint from '../../ResultPoint';
2
+ import BitMatrix from '../BitMatrix';
3
+ /**
4
+ * <p>
5
+ * Detects a candidate barcode-like rectangular region within an image. It
6
+ * starts around the center of the image, increases the size of the candidate
7
+ * region until it finds a white rectangular region. By keeping track of the
8
+ * last black points it encountered, it determines the corners of the barcode.
9
+ * </p>
10
+ *
11
+ * @author David Olivier
12
+ */
13
+ export default class WhiteRectangleDetector {
14
+ private image;
15
+ private static INIT_SIZE;
16
+ private static CORR;
17
+ private height;
18
+ private width;
19
+ private leftInit;
20
+ private rightInit;
21
+ private downInit;
22
+ private upInit;
23
+ /**
24
+ * @param image barcode image to find a rectangle in
25
+ * @param initSize initial size of search area around center
26
+ * @param x x position of search center
27
+ * @param y y position of search center
28
+ * @throws NotFoundException if image is too small to accommodate {@code initSize}
29
+ */
30
+ constructor(image: BitMatrix, initSize?: number, x?: number, y?: number);
31
+ /**
32
+ * <p>
33
+ * Detects a candidate barcode-like rectangular region within an image. It
34
+ * starts around the center of the image, increases the size of the candidate
35
+ * region until it finds a white rectangular region.
36
+ * </p>
37
+ *
38
+ * @return {@link ResultPoint}[] describing the corners of the rectangular
39
+ * region. The first and last points are opposed on the diagonal, as
40
+ * are the second and third. The first point will be the topmost
41
+ * point and the last, the bottommost. The second point will be
42
+ * leftmost and the third, the rightmost
43
+ * @throws NotFoundException if no Data Matrix Code can be found
44
+ */
45
+ detect(): Array<ResultPoint>;
46
+ private getBlackPointOnSegment;
47
+ /**
48
+ * recenters the points of a constant distance towards the center
49
+ *
50
+ * @param y bottom most point
51
+ * @param z left most point
52
+ * @param x right most point
53
+ * @param t top most point
54
+ * @return {@link ResultPoint}[] describing the corners of the rectangular
55
+ * region. The first and last points are opposed on the diagonal, as
56
+ * are the second and third. The first point will be the topmost
57
+ * point and the last, the bottommost. The second point will be
58
+ * leftmost and the third, the rightmost
59
+ */
60
+ private centerEdges;
61
+ /**
62
+ * Determines whether a segment contains a black point
63
+ *
64
+ * @param a min value of the scanned coordinate
65
+ * @param b max value of the scanned coordinate
66
+ * @param fixed value of fixed coordinate
67
+ * @param horizontal set to true if scan must be horizontal, false if vertical
68
+ * @return true if a black point has been found, else false.
69
+ */
70
+ private containsBlackPoint;
71
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * <p>This class contains utility methods for performing mathematical operations over
3
+ * the Galois Fields. Operations use a given primitive polynomial in calculations.</p>
4
+ *
5
+ * <p>Throughout this package, elements of the GF are represented as an {@code int}
6
+ * for convenience and speed (but at the cost of memory).
7
+ * </p>
8
+ *
9
+ * @author Sean Owen
10
+ * @author David Olivier
11
+ */
12
+ export default abstract class AbstractGenericGF {
13
+ protected expTable: any;
14
+ protected logTable: any;
15
+ abstract getZero(): any;
16
+ abstract buildMonomial(degree: number, coefficient: number): any;
17
+ abstract equals(o: Object): boolean;
18
+ abstract multiply(a: number, b: number): number;
19
+ abstract inverse(a: number): number;
20
+ /**
21
+ * @return 2 to the power of a in GF(size)
22
+ */
23
+ exp(a: number): number;
24
+ /**
25
+ * @return base 2 log of a in GF(size)
26
+ */
27
+ log(a: number): number;
28
+ /**
29
+ * Implements both addition and subtraction -- they are the same in GF(size).
30
+ *
31
+ * @return sum/difference of a and b
32
+ */
33
+ static addOrSubtract(a: number, b: number): number;
34
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * <p>Represents a polynomial whose coefficients are elements of a GF.
3
+ * Instances of this class are immutable.</p>
4
+ *
5
+ * <p>Much credit is due to William Rucklidge since portions of this code are an indirect
6
+ * port of his C++ Reed-Solomon implementation.</p>
7
+ *
8
+ * @author Sean Owen
9
+ */
10
+ export default abstract class AbstractGenericGFPoly {
11
+ protected field: any;
12
+ protected coefficients: any;
13
+ getCoefficients(): Int32Array;
14
+ /**
15
+ * @return degree of this polynomial
16
+ */
17
+ getDegree(): number;
18
+ /**
19
+ * @return true iff this polynomial is the monomial "0"
20
+ */
21
+ isZero(): boolean;
22
+ /**
23
+ * @return coefficient of x^degree term in this polynomial
24
+ */
25
+ getCoefficient(degree: number): number;
26
+ /**
27
+ * @return evaluation of this polynomial at a given point
28
+ */
29
+ evaluateAt(a: number): number;
30
+ abstract addOrSubtract(other: AbstractGenericGFPoly): AbstractGenericGFPoly;
31
+ abstract multiply(other: AbstractGenericGFPoly): AbstractGenericGFPoly;
32
+ abstract multiplyScalar(scalar: number): AbstractGenericGFPoly;
33
+ abstract multiplyByMonomial(degree: number, coefficient: number): AbstractGenericGFPoly;
34
+ abstract divide(other: AbstractGenericGFPoly): AbstractGenericGFPoly[];
35
+ toString(): string;
36
+ }
@@ -0,0 +1,58 @@
1
+ import AbstractGenericGF from './AbstractGenericGF';
2
+ import GenericGFPoly from './GenericGFPoly';
3
+ /**
4
+ * <p>This class contains utility methods for performing mathematical operations over
5
+ * the Galois Fields. Operations use a given primitive polynomial in calculations.</p>
6
+ *
7
+ * <p>Throughout this package, elements of the GF are represented as an {@code int}
8
+ * for convenience and speed (but at the cost of memory).
9
+ * </p>
10
+ *
11
+ * @author Sean Owen
12
+ * @author David Olivier
13
+ */
14
+ export default class GenericGF extends AbstractGenericGF {
15
+ private primitive;
16
+ private size;
17
+ private generatorBase;
18
+ static AZTEC_DATA_12: GenericGF;
19
+ static AZTEC_DATA_10: GenericGF;
20
+ static AZTEC_DATA_6: GenericGF;
21
+ static AZTEC_PARAM: GenericGF;
22
+ static QR_CODE_FIELD_256: GenericGF;
23
+ static DATA_MATRIX_FIELD_256: GenericGF;
24
+ static AZTEC_DATA_8: GenericGF;
25
+ static MAXICODE_FIELD_64: GenericGF;
26
+ private zero;
27
+ private one;
28
+ /**
29
+ * Create a representation of GF(size) using the given primitive polynomial.
30
+ *
31
+ * @param primitive irreducible polynomial whose coefficients are represented by
32
+ * the bits of an int, where the least-significant bit represents the constant
33
+ * coefficient
34
+ * @param size the size of the field
35
+ * @param b the factor b in the generator polynomial can be 0- or 1-based
36
+ * (g(x) = (x+a^b)(x+a^(b+1))...(x+a^(b+2t-1))).
37
+ * In most cases it should be 1, but for QR code it is 0.
38
+ */
39
+ constructor(primitive: number, size: number, generatorBase: number);
40
+ getZero(): GenericGFPoly;
41
+ getOne(): GenericGFPoly;
42
+ /**
43
+ * @return the monomial representing coefficient * x^degree
44
+ */
45
+ buildMonomial(degree: number, coefficient: number): GenericGFPoly;
46
+ /**
47
+ * @return multiplicative inverse of a
48
+ */
49
+ inverse(a: number): number;
50
+ /**
51
+ * @return product of a and b in GF(size)
52
+ */
53
+ multiply(a: number, b: number): number;
54
+ getSize(): number;
55
+ getGeneratorBase(): number;
56
+ toString(): string;
57
+ equals(o: Object): boolean;
58
+ }
@@ -0,0 +1,47 @@
1
+ import AbstractGenericGF from './AbstractGenericGF';
2
+ /**
3
+ * <p>Represents a polynomial whose coefficients are elements of a GF.
4
+ * Instances of this class are immutable.</p>
5
+ *
6
+ * <p>Much credit is due to William Rucklidge since portions of this code are an indirect
7
+ * port of his C++ Reed-Solomon implementation.</p>
8
+ *
9
+ * @author Sean Owen
10
+ */
11
+ export default class GenericGFPoly {
12
+ private field;
13
+ private coefficients;
14
+ /**
15
+ * @param field the {@link GenericGF} instance representing the field to use
16
+ * to perform computations
17
+ * @param coefficients coefficients as ints representing elements of GF(size), arranged
18
+ * from most significant (highest-power term) coefficient to least significant
19
+ * @throws IllegalArgumentException if argument is null or empty,
20
+ * or if leading coefficient is 0 and this is not a
21
+ * constant polynomial (that is, it is not the monomial "0")
22
+ */
23
+ constructor(field: AbstractGenericGF, coefficients: Int32Array);
24
+ getCoefficients(): Int32Array;
25
+ /**
26
+ * @return degree of this polynomial
27
+ */
28
+ getDegree(): number;
29
+ /**
30
+ * @return true iff this polynomial is the monomial "0"
31
+ */
32
+ isZero(): boolean;
33
+ /**
34
+ * @return coefficient of x^degree term in this polynomial
35
+ */
36
+ getCoefficient(degree: number): number;
37
+ /**
38
+ * @return evaluation of this polynomial at a given point
39
+ */
40
+ evaluateAt(a: number): number;
41
+ addOrSubtract(other: GenericGFPoly): GenericGFPoly;
42
+ multiply(other: GenericGFPoly): GenericGFPoly;
43
+ multiplyScalar(scalar: number): GenericGFPoly;
44
+ multiplyByMonomial(degree: number, coefficient: number): GenericGFPoly;
45
+ divide(other: GenericGFPoly): GenericGFPoly[];
46
+ toString(): string;
47
+ }
@@ -0,0 +1,40 @@
1
+ import GenericGF from './GenericGF';
2
+ /**
3
+ * <p>Implements Reed-Solomon decoding, as the name implies.</p>
4
+ *
5
+ * <p>The algorithm will not be explained here, but the following references were helpful
6
+ * in creating this implementation:</p>
7
+ *
8
+ * <ul>
9
+ * <li>Bruce Maggs.
10
+ * <a href="http://www.cs.cmu.edu/afs/cs.cmu.edu/project/pscico-guyb/realworld/www/rs_decode.ps">
11
+ * "Decoding Reed-Solomon Codes"</a> (see discussion of Forney's Formula)</li>
12
+ * <li>J.I. Hall. <a href="www.mth.msu.edu/~jhall/classes/codenotes/GRS.pdf">
13
+ * "Chapter 5. Generalized Reed-Solomon Codes"</a>
14
+ * (see discussion of Euclidean algorithm)</li>
15
+ * </ul>
16
+ *
17
+ * <p>Much credit is due to William Rucklidge since portions of this code are an indirect
18
+ * port of his C++ Reed-Solomon implementation.</p>
19
+ *
20
+ * @author Sean Owen
21
+ * @author William Rucklidge
22
+ * @author sanfordsquires
23
+ */
24
+ export default class ReedSolomonDecoder {
25
+ private field;
26
+ constructor(field: GenericGF);
27
+ /**
28
+ * <p>Decodes given set of received codewords, which include both data and error-correction
29
+ * codewords. Really, this means it uses Reed-Solomon to detect and correct errors, in-place,
30
+ * in the input.</p>
31
+ *
32
+ * @param received data and error-correction codewords
33
+ * @param twoS number of error-correction codewords available
34
+ * @throws ReedSolomonException if decoding fails for any reason
35
+ */
36
+ decode(received: Int32Array, twoS: number): void;
37
+ private runEuclideanAlgorithm;
38
+ private findErrorLocations;
39
+ private findErrorMagnitudes;
40
+ }
@@ -0,0 +1,41 @@
1
+ import GenericGF from './GenericGF';
2
+ /**
3
+ * <p>Implements Reed-Solomon encoding, as the name implies.</p>
4
+ *
5
+ * @author Sean Owen
6
+ * @author William Rucklidge
7
+ */
8
+ export default class ReedSolomonEncoder {
9
+ private field;
10
+ private cachedGenerators;
11
+ /**
12
+ * A reed solomon error-correcting encoding constructor is created by
13
+ * passing as Galois Field with of size equal to the number of code
14
+ * words (symbols) in the alphabet (the number of values in each
15
+ * element of arrays that are encoded/decoded).
16
+ * @param field A galois field with a number of elements equal to the size
17
+ * of the alphabet of symbols to encode.
18
+ */
19
+ constructor(field: GenericGF);
20
+ private buildGenerator;
21
+ /**
22
+ * <p>Encode a sequence of code words (symbols) using Reed-Solomon to allow decoders
23
+ * to detect and correct errors that may have been introduced when the resulting
24
+ * data is stored or transmitted.</p>
25
+ *
26
+ * @param toEncode array used for both and output. Caller initializes the array with
27
+ * the code words (symbols) to be encoded followed by empty elements allocated to make
28
+ * space for error-correction code words in the encoded output. The array contains
29
+ * the encdoded output when encode returns. Code words are encoded as numbers from
30
+ * 0 to n-1, where n is the number of possible code words (symbols), as determined
31
+ * by the size of the Galois Field passed in the constructor of this object.
32
+ * @param ecBytes the number of elements reserved in the array (first parameter)
33
+ * to store error-correction code words. Thus, the number of code words (symbols)
34
+ * to encode in the first parameter is thus toEncode.length - ecBytes.
35
+ * Note, the use of "bytes" in the name of this parameter is misleading, as there may
36
+ * be more or fewer than 256 symbols being encoded, as determined by the number of
37
+ * elements in the Galois Field passed as a constructor to this object.
38
+ * @throws IllegalArgumentException thrown in response to validation errros.
39
+ */
40
+ encode(toEncode: Int32Array, ecBytes: number): void;
41
+ }
@@ -0,0 +1,35 @@
1
+ import BinaryBitmap from '../BinaryBitmap';
2
+ import DecodeHintType from '../DecodeHintType';
3
+ import Result from '../Result';
4
+ import Decoder from './decoder/Decoder';
5
+ /**
6
+ * This implementation can detect and decode QR Codes in an image.
7
+ *
8
+ * @author Sean Owen
9
+ */
10
+ export default class QRCodeReader {
11
+ private static NO_POINTS;
12
+ private decoder;
13
+ protected getDecoder(): Decoder;
14
+ /**
15
+ * Locates and decodes a QR code in an image.
16
+ *
17
+ * @return a representing: string the content encoded by the QR code
18
+ * @throws NotFoundException if a QR code cannot be found
19
+ * @throws FormatException if a QR code cannot be decoded
20
+ * @throws ChecksumException if error correction fails
21
+ */
22
+ decode(image: BinaryBitmap, hints?: Map<DecodeHintType, any>): Result;
23
+ decode2(image: BinaryBitmap, hints?: Map<DecodeHintType, any>): Result;
24
+ reset(): void;
25
+ /**
26
+ * This method detects a code in a "pure" image -- that is, pure monochrome image
27
+ * which contains only an unrotated, unskewed, image of a code, with some white border
28
+ * around it. This is a specialized method that works exceptionally fast in this special
29
+ * case.
30
+ *
31
+ * @see com.google.zxing.datamatrix.DataMatrixReader#extractPureBits(BitMatrix)
32
+ */
33
+ private static extractPureBits;
34
+ private static moduleSize;
35
+ }
@@ -0,0 +1,13 @@
1
+ import BarcodeFormat from '../BarcodeFormat';
2
+ import BitMatrix from '../common/BitMatrix';
3
+ import EncodeHintType from '../EncodeHintType';
4
+ /**
5
+ * This object renders a QR Code as a BitMatrix 2D array of greyscale values.
6
+ *
7
+ * @author dswitkin@google.com (Daniel Switkin)
8
+ */
9
+ export default class QRCodeWriter {
10
+ private static QUIET_ZONE_SIZE;
11
+ encode(contents: string, format: BarcodeFormat, width: number, height: number, hints: Map<EncodeHintType, any>): BitMatrix;
12
+ private static renderResult;
13
+ }
@@ -0,0 +1,58 @@
1
+ import BitMatrix from '../../common/BitMatrix';
2
+ import FormatInformation from './FormatInformation';
3
+ import Version from './Version';
4
+ /**
5
+ * @author Sean Owen
6
+ */
7
+ export default class BitMatrixParser {
8
+ private bitMatrix;
9
+ private parsedVersion?;
10
+ private parsedFormatInfo?;
11
+ private isMirror?;
12
+ /**
13
+ * @param bitMatrix {@link BitMatrix} to parse
14
+ * @throws FormatException if dimension is not >= 21 and 1 mod 4
15
+ */
16
+ constructor(bitMatrix: BitMatrix);
17
+ /**
18
+ * <p>Reads format information from one of its two locations within the QR Code.</p>
19
+ *
20
+ * @return {@link FormatInformation} encapsulating the QR Code's format info
21
+ * @throws FormatException if both format information locations cannot be parsed as
22
+ * the valid encoding of format information
23
+ */
24
+ readFormatInformation(): FormatInformation;
25
+ /**
26
+ * <p>Reads version information from one of its two locations within the QR Code.</p>
27
+ *
28
+ * @return {@link Version} encapsulating the QR Code's version
29
+ * @throws FormatException if both version information locations cannot be parsed as
30
+ * the valid encoding of version information
31
+ */
32
+ readVersion(): Version;
33
+ private copyBit;
34
+ /**
35
+ * <p>Reads the bits in the {@link BitMatrix} representing the finder pattern in the
36
+ * correct order in order to reconstruct the codewords bytes contained within the
37
+ * QR Code.</p>
38
+ *
39
+ * @return bytes encoded within the QR Code
40
+ * @throws FormatException if the exact number of bytes expected is not read
41
+ */
42
+ readCodewords(): Uint8Array;
43
+ /**
44
+ * Revert the mask removal done while reading the code words. The bit matrix should revert to its original state.
45
+ */
46
+ remask(): void;
47
+ /**
48
+ * Prepare the parser for a mirrored operation.
49
+ * This flag has effect only on the {@link #readFormatInformation()} and the
50
+ * {@link #readVersion()}. Before proceeding with {@link #readCodewords()} the
51
+ * {@link #mirror()} method should be called.
52
+ *
53
+ * @param mirror Whether to read version and format information mirrored.
54
+ */
55
+ setMirror(isMirror: boolean): void;
56
+ /** Mirror the bit matrix in order to attempt a second reading. */
57
+ mirror(): void;
58
+ }
@@ -0,0 +1,28 @@
1
+ import ErrorCorrectionLevel from './ErrorCorrectionLevel';
2
+ import Version from './Version';
3
+ /**
4
+ * <p>Encapsulates a block of data within a QR Code. QR Codes may split their data into
5
+ * multiple blocks, each of which is a unit of data and error-correction codewords. Each
6
+ * is represented by an instance of this class.</p>
7
+ *
8
+ * @author Sean Owen
9
+ */
10
+ export default class DataBlock {
11
+ private numDataCodewords;
12
+ private codewords;
13
+ private constructor();
14
+ /**
15
+ * <p>When QR Codes use multiple data blocks, they are actually interleaved.
16
+ * That is, the first byte of data block 1 to n is written, then the second bytes, and so on. This
17
+ * method will separate the data into original blocks.</p>
18
+ *
19
+ * @param rawCodewords bytes as read directly from the QR Code
20
+ * @param version version of the QR Code
21
+ * @param ecLevel error-correction level of the QR Code
22
+ * @return DataBlocks containing original bytes, "de-interleaved" from representation in the
23
+ * QR Code
24
+ */
25
+ static getDataBlocks(rawCodewords: Uint8Array, version: Version, ecLevel: ErrorCorrectionLevel): DataBlock[];
26
+ getNumDataCodewords(): number;
27
+ getCodewords(): Uint8Array;
28
+ }
@@ -0,0 +1,36 @@
1
+ import BitMatrix from '../../common/BitMatrix';
2
+ export declare enum DataMaskValues {
3
+ DATA_MASK_000 = 0,
4
+ DATA_MASK_001 = 1,
5
+ DATA_MASK_010 = 2,
6
+ DATA_MASK_011 = 3,
7
+ DATA_MASK_100 = 4,
8
+ DATA_MASK_101 = 5,
9
+ DATA_MASK_110 = 6,
10
+ DATA_MASK_111 = 7
11
+ }
12
+ /**
13
+ * <p>Encapsulates data masks for the data bits in a QR code, per ISO 18004:2006 6.8. Implementations
14
+ * of this class can un-mask a raw BitMatrix. For simplicity, they will unmask the entire BitMatrix,
15
+ * including areas used for finder patterns, timing patterns, etc. These areas should be unused
16
+ * after the point they are unmasked anyway.</p>
17
+ *
18
+ * <p>Note that the diagram in section 6.8.1 is misleading since it indicates that i is column position
19
+ * and j is row position. In fact, as the text says, i is row position and j is column position.</p>
20
+ *
21
+ * @author Sean Owen
22
+ */
23
+ export default class DataMask {
24
+ private value;
25
+ private isMasked;
26
+ constructor(value: DataMaskValues, isMasked: (i: number, j: number) => boolean);
27
+ static values: Map<DataMaskValues, DataMask>;
28
+ /**
29
+ * <p>Implementations of this method reverse the data masking process applied to a QR Code and
30
+ * make its bits ready to read.</p>
31
+ *
32
+ * @param bits representation of QR Code bits
33
+ * @param dimension dimension of QR Code, represented by bits, being unmasked
34
+ */
35
+ unmaskBitMatrix(bits: BitMatrix, dimension: number): void;
36
+ }
@@ -0,0 +1,30 @@
1
+ import DecoderResult from '../../common/DecoderResult';
2
+ import DecodeHintType from '../../DecodeHintType';
3
+ import ErrorCorrectionLevel from './ErrorCorrectionLevel';
4
+ import Version from './Version';
5
+ /**
6
+ * <p>QR Codes can encode text as bits in one of several modes, and can use multiple modes
7
+ * in one QR Code. This class decodes the bits back into text.</p>
8
+ *
9
+ * <p>See ISO 18004:2006, 6.4.3 - 6.4.7</p>
10
+ *
11
+ * @author Sean Owen
12
+ */
13
+ export default class DecodedBitStreamParser {
14
+ /**
15
+ * See ISO 18004:2006, 6.4.4 Table 5
16
+ */
17
+ private static ALPHANUMERIC_CHARS;
18
+ private static GB2312_SUBSET;
19
+ static decode(bytes: Uint8Array, version: Version, ecLevel: ErrorCorrectionLevel, hints: Map<DecodeHintType, any>): DecoderResult;
20
+ /**
21
+ * See specification GBT 18284-2000
22
+ */
23
+ private static decodeHanziSegment;
24
+ private static decodeKanjiSegment;
25
+ private static decodeByteSegment;
26
+ private static toAlphaNumericChar;
27
+ private static decodeAlphanumericSegment;
28
+ private static decodeNumericSegment;
29
+ private static parseECIValue;
30
+ }
@@ -0,0 +1,44 @@
1
+ import BitMatrix from '../../common/BitMatrix';
2
+ import DecoderResult from '../../common/DecoderResult';
3
+ import DecodeHintType from '../../DecodeHintType';
4
+ /**
5
+ * <p>The main class which implements QR Code decoding -- as opposed to locating and extracting
6
+ * the QR Code from an image.</p>
7
+ *
8
+ * @author Sean Owen
9
+ */
10
+ export default class Decoder {
11
+ private rsDecoder;
12
+ constructor();
13
+ /**
14
+ * <p>Convenience method that can decode a QR Code represented as a 2D array of booleans.
15
+ * "true" is taken to mean a black module.</p>
16
+ *
17
+ * @param image booleans representing white/black QR Code modules
18
+ * @param hints decoding hints that should be used to influence decoding
19
+ * @return text and bytes encoded within the QR Code
20
+ * @throws FormatException if the QR Code cannot be decoded
21
+ * @throws ChecksumException if error correction fails
22
+ */
23
+ decodeBooleanArray(image: boolean[][], hints?: Map<DecodeHintType, any>): DecoderResult;
24
+ /**
25
+ * <p>Decodes a QR Code represented as a {@link BitMatrix}. A 1 or "true" is taken to mean a black module.</p>
26
+ *
27
+ * @param bits booleans representing white/black QR Code modules
28
+ * @param hints decoding hints that should be used to influence decoding
29
+ * @return text and bytes encoded within the QR Code
30
+ * @throws FormatException if the QR Code cannot be decoded
31
+ * @throws ChecksumException if error correction fails
32
+ */
33
+ decodeBitMatrix(bits: BitMatrix, hints?: Map<DecodeHintType, any>): DecoderResult;
34
+ private decodeBitMatrixParser;
35
+ /**
36
+ * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
37
+ * correct the errors in-place using Reed-Solomon error correction.</p>
38
+ *
39
+ * @param codewordBytes data and error correction codewords
40
+ * @param numDataCodewords number of codewords that are data bytes
41
+ * @throws ChecksumException if error correction fails
42
+ */
43
+ private correctErrors;
44
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * <p>Encapsulates the parameters for one error-correction block in one symbol version.
3
+ * This includes the number of data codewords, and the number of times a block with these
4
+ * parameters is used consecutively in the QR code version's format.</p>
5
+ */
6
+ export default class ECB {
7
+ private count;
8
+ private dataCodewords;
9
+ constructor(count: number, dataCodewords: number);
10
+ getCount(): number;
11
+ getDataCodewords(): number;
12
+ }
@@ -0,0 +1,16 @@
1
+ import ECB from './ECB';
2
+ /**
3
+ * <p>Encapsulates a set of error-correction blocks in one symbol version. Most versions will
4
+ * use blocks of differing sizes within one version, so, this encapsulates the parameters for
5
+ * each set of blocks. It also holds the number of error-correction codewords per block since it
6
+ * will be the same across all blocks within one version.</p>
7
+ */
8
+ export default class ECBlocks {
9
+ private ecCodewordsPerBlock;
10
+ private ecBlocks;
11
+ constructor(ecCodewordsPerBlock: number, ...ecBlocks: ECB[]);
12
+ getECCodewordsPerBlock(): number;
13
+ getNumBlocks(): number;
14
+ getTotalECCodewords(): number;
15
+ getECBlocks(): ECB[];
16
+ }