@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,6 @@
1
+ import Exception from './Exception';
2
+ /**
3
+ * Custom Error class of type Exception.
4
+ */
5
+ export default class OutOfMemoryError extends Exception {
6
+ }
@@ -0,0 +1,35 @@
1
+ import LuminanceSource from './LuminanceSource';
2
+ /**
3
+ * This object extends LuminanceSource around an array of YUV data returned from the camera driver,
4
+ * with the option to crop to a rectangle within the full data. This can be used to exclude
5
+ * superfluous pixels around the perimeter and speed up decoding.
6
+ *
7
+ * It works for any pixel format where the Y channel is planar and appears first, including
8
+ * YCbCr_420_SP and YCbCr_422_SP.
9
+ *
10
+ * @author dswitkin@google.com (Daniel Switkin)
11
+ */
12
+ export default class PlanarYUVLuminanceSource extends LuminanceSource {
13
+ private yuvData;
14
+ private dataWidth;
15
+ private dataHeight;
16
+ private left;
17
+ private top;
18
+ private static THUMBNAIL_SCALE_FACTOR;
19
+ constructor(yuvData: Uint8ClampedArray, dataWidth: number, dataHeight: number, left: number, top: number, width: number, height: number, reverseHorizontal: boolean);
20
+ getRow(y: number, row?: Uint8ClampedArray): Uint8ClampedArray;
21
+ getMatrix(): Uint8ClampedArray;
22
+ isCropSupported(): boolean;
23
+ crop(left: number, top: number, width: number, height: number): LuminanceSource;
24
+ renderThumbnail(): Int32Array;
25
+ /**
26
+ * @return width of image from {@link #renderThumbnail()}
27
+ */
28
+ getThumbnailWidth(): number;
29
+ /**
30
+ * @return height of image from {@link #renderThumbnail()}
31
+ */
32
+ getThumbnailHeight(): number;
33
+ private reverseHorizontal;
34
+ invert(): LuminanceSource;
35
+ }
@@ -0,0 +1,21 @@
1
+ import LuminanceSource from './LuminanceSource';
2
+ /**
3
+ * This class is used to help decode images from files which arrive as RGB data from
4
+ * an ARGB pixel array. It does not support rotation.
5
+ *
6
+ * @author dswitkin@google.com (Daniel Switkin)
7
+ * @author Betaminos
8
+ */
9
+ export default class RGBLuminanceSource extends LuminanceSource {
10
+ private dataWidth?;
11
+ private dataHeight?;
12
+ private left?;
13
+ private top?;
14
+ private luminances;
15
+ constructor(luminances: Uint8ClampedArray | Int32Array, width: number, height: number, dataWidth?: number | undefined, dataHeight?: number | undefined, left?: number | undefined, top?: number | undefined);
16
+ getRow(y: number, row?: Uint8ClampedArray): Uint8ClampedArray;
17
+ getMatrix(): Uint8ClampedArray;
18
+ isCropSupported(): boolean;
19
+ crop(left: number, top: number, width: number, height: number): LuminanceSource;
20
+ invert(): LuminanceSource;
21
+ }
@@ -0,0 +1,49 @@
1
+ import BinaryBitmap from './BinaryBitmap';
2
+ import DecodeHintType from './DecodeHintType';
3
+ import Result from './Result';
4
+ export default Reader;
5
+ /**
6
+ * Implementations of this interface can decode an image of a barcode in some format into
7
+ * the it: string encodes. For example, {@link com.google.zxing.qrcode.QRCodeReader} can
8
+ * decode a QR code. The decoder may optionally receive hints from the caller which may help
9
+ * it decode more quickly or accurately.
10
+ *
11
+ * See {@link MultiFormatReader}, which attempts to determine what barcode
12
+ * format is present within the image as well, and then decodes it accordingly.
13
+ *
14
+ * @author Sean Owen
15
+ * @author dswitkin@google.com (Daniel Switkin)
16
+ */
17
+ interface Reader {
18
+ /**
19
+ * Locates and decodes a barcode in some format within an image.
20
+ *
21
+ * @param image image of barcode to decode
22
+ * @return which: string the barcode encodes
23
+ * @throws NotFoundException if no potential barcode is found
24
+ * @throws ChecksumException if a potential barcode is found but does not pass its checksum
25
+ * @throws FormatException if a potential barcode is found but format is invalid
26
+ */
27
+ /**
28
+ * Locates and decodes a barcode in some format within an image. This method also accepts
29
+ * hints, each possibly associated to some data, which may help the implementation decode.
30
+ *
31
+ * @param image image of barcode to decode
32
+ * @param hints passed as a {@link Map} from {@link DecodeHintType}
33
+ * to arbitrary data. The
34
+ * meaning of the data depends upon the hint type. The implementation may or may not do
35
+ * anything with these hints.
36
+ *
37
+ * @return which: string the barcode encodes
38
+ *
39
+ * @throws NotFoundException if no potential barcode is found
40
+ * @throws ChecksumException if a potential barcode is found but does not pass its checksum
41
+ * @throws FormatException if a potential barcode is found but format is invalid
42
+ */
43
+ decode(image: BinaryBitmap, hints?: Map<DecodeHintType, any> | null): Result;
44
+ /**
45
+ * Resets any internal state the implementation has after a decode, to prepare it
46
+ * for reuse.
47
+ */
48
+ reset(): void;
49
+ }
@@ -0,0 +1,7 @@
1
+ import Exception from './Exception';
2
+ /**
3
+ * Custom Error class of type Exception.
4
+ */
5
+ export default class ReaderException extends Exception {
6
+ static readonly kind: string;
7
+ }
@@ -0,0 +1,7 @@
1
+ import Exception from './Exception';
2
+ /**
3
+ * Custom Error class of type Exception.
4
+ */
5
+ export default class ReedSolomonException extends Exception {
6
+ static readonly kind: string;
7
+ }
@@ -0,0 +1,52 @@
1
+ import BarcodeFormat from './BarcodeFormat';
2
+ import ResultMetadataType from './ResultMetadataType';
3
+ import ResultPoint from './ResultPoint';
4
+ /**
5
+ * <p>Encapsulates the result of decoding a barcode within an image.</p>
6
+ *
7
+ * @author Sean Owen
8
+ */
9
+ export default class Result {
10
+ text: string | null;
11
+ rawBytes: Uint8Array;
12
+ private numBits;
13
+ private resultPoints;
14
+ format: BarcodeFormat;
15
+ private timestamp;
16
+ private resultMetadata;
17
+ constructor(text: string | null | undefined, rawBytes: Uint8Array, numBits: number | undefined, resultPoints: ResultPoint[], format: BarcodeFormat, timestamp?: number);
18
+ /**
19
+ * @return raw text encoded by the barcode
20
+ */
21
+ getText(): string | null;
22
+ /**
23
+ * @return raw bytes encoded by the barcode, if applicable, otherwise {@code null}
24
+ */
25
+ getRawBytes(): Uint8Array;
26
+ /**
27
+ * @return how many bits of {@link #getRawBytes()} are valid; typically 8 times its length
28
+ * @since 3.3.0
29
+ */
30
+ getNumBits(): number;
31
+ /**
32
+ * @return points related to the barcode in the image. These are typically points
33
+ * identifying finder patterns or the corners of the barcode. The exact meaning is
34
+ * specific to the type of barcode that was decoded.
35
+ */
36
+ getResultPoints(): ResultPoint[];
37
+ /**
38
+ * @return The format of the barcode that was decoded
39
+ */
40
+ getBarcodeFormat(): BarcodeFormat;
41
+ /**
42
+ * @return Mapping keys to values. May be
43
+ * This contains optional metadata about what was detected about the barcode,
44
+ * like orientation.
45
+ */
46
+ getResultMetadata(): Map<ResultMetadataType, object>;
47
+ putMetadata(type: ResultMetadataType, value: object): void;
48
+ putAllMetadata(metadata: Map<ResultMetadataType, object>): void;
49
+ addResultPoints(newPoints: ResultPoint[]): void;
50
+ getTimestamp(): number;
51
+ toString(): string | null;
52
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Represents some type of metadata about the result of the decoding that the decoder
3
+ * wishes to communicate back to the caller.
4
+ *
5
+ * @author Sean Owen
6
+ */
7
+ declare enum ResultMetadataType {
8
+ /**
9
+ * Unspecified, application-specific metadata. Maps to an unspecified {@link Object}.
10
+ */
11
+ OTHER = 0,
12
+ /**
13
+ * Denotes the likely approximate orientation of the barcode in the image. This value
14
+ * is given as degrees rotated clockwise from the normal, upright orientation.
15
+ * For example a 1D barcode which was found by reading top-to-bottom would be
16
+ * said to have orientation "90". This key maps to an {@link Integer} whose
17
+ * value is in the range [0,360).
18
+ */
19
+ ORIENTATION = 1,
20
+ /**
21
+ * <p>2D barcode formats typically encode text, but allow for a sort of 'byte mode'
22
+ * which is sometimes used to encode binary data. While {@link Result} makes available
23
+ * the complete raw bytes in the barcode for these formats, it does not offer the bytes
24
+ * from the byte segments alone.</p>
25
+ *
26
+ * <p>This maps to a {@link java.util.List} of byte arrays corresponding to the
27
+ * raw bytes in the byte segments in the barcode, in order.</p>
28
+ */
29
+ BYTE_SEGMENTS = 2,
30
+ /**
31
+ * Error correction level used, if applicable. The value type depends on the
32
+ * format, but is typically a String.
33
+ */
34
+ ERROR_CORRECTION_LEVEL = 3,
35
+ /**
36
+ * For some periodicals, indicates the issue number as an {@link Integer}.
37
+ */
38
+ ISSUE_NUMBER = 4,
39
+ /**
40
+ * For some products, indicates the suggested retail price in the barcode as a
41
+ * formatted {@link String}.
42
+ */
43
+ SUGGESTED_PRICE = 5,
44
+ /**
45
+ * For some products, the possible country of manufacture as a {@link String} denoting the
46
+ * ISO country code. Some map to multiple possible countries, like "US/CA".
47
+ */
48
+ POSSIBLE_COUNTRY = 6,
49
+ /**
50
+ * For some products, the extension text
51
+ */
52
+ UPC_EAN_EXTENSION = 7,
53
+ /**
54
+ * PDF417-specific metadata
55
+ */
56
+ PDF417_EXTRA_METADATA = 8,
57
+ /**
58
+ * If the code format supports structured append and the current scanned code is part of one then the
59
+ * sequence number is given with it.
60
+ */
61
+ STRUCTURED_APPEND_SEQUENCE = 9,
62
+ /**
63
+ * If the code format supports structured append and the current scanned code is part of one then the
64
+ * parity is given with it.
65
+ */
66
+ STRUCTURED_APPEND_PARITY = 10
67
+ }
68
+ export default ResultMetadataType;
@@ -0,0 +1,34 @@
1
+ import { float, int } from '../customTypings';
2
+ /**
3
+ * <p>Encapsulates a point of interest in an image containing a barcode. Typically, this
4
+ * would be the location of a finder pattern or the corner of the barcode, for example.</p>
5
+ *
6
+ * @author Sean Owen
7
+ */
8
+ export default class ResultPoint {
9
+ private x;
10
+ private y;
11
+ constructor(x: float, y: float);
12
+ getX(): float;
13
+ getY(): float;
14
+ equals(other: object): boolean;
15
+ hashCode(): int;
16
+ toString(): string;
17
+ /**
18
+ * Orders an array of three ResultPoints in an order [A,B,C] such that AB is less than AC
19
+ * and BC is less than AC, and the angle between BC and BA is less than 180 degrees.
20
+ *
21
+ * @param patterns array of three {@code ResultPoint} to order
22
+ */
23
+ static orderBestPatterns(patterns: ResultPoint[]): void;
24
+ /**
25
+ * @param pattern1 first pattern
26
+ * @param pattern2 second pattern
27
+ * @return distance between two points
28
+ */
29
+ static distance(pattern1: ResultPoint, pattern2: ResultPoint): float;
30
+ /**
31
+ * Returns the z component of the cross product between vectors BC and BA.
32
+ */
33
+ private static crossProductZ;
34
+ }
@@ -0,0 +1,11 @@
1
+ import ResultPoint from './ResultPoint';
2
+ export default ResultPointCallback;
3
+ /**
4
+ * Callback which is invoked when a possible result point (significant
5
+ * point in the barcode image such as a corner) is found.
6
+ *
7
+ * @see DecodeHintType#NEED_RESULT_POINT_CALLBACK
8
+ */
9
+ interface ResultPointCallback {
10
+ foundPossibleResultPoint(point: ResultPoint): void;
11
+ }
@@ -0,0 +1,46 @@
1
+ import LuminanceSource from './LuminanceSource';
2
+ /**
3
+ * NodeLuminanceSource replicates the behavior of a LuminanceSource
4
+ * but does NOT use sharp. Instead, you provide raw RGBA data and
5
+ * we convert it to grayscale internally.
6
+ */
7
+ export declare class UniversalLuminanceSource extends LuminanceSource {
8
+ private buffer;
9
+ private _width;
10
+ private _height;
11
+ /**
12
+ * Private constructor; use the static createFromRawRGBA() method below.
13
+ */
14
+ constructor(width: number, height: number, buffer: Uint8ClampedArray);
15
+ /**
16
+ * Create a NodeLuminanceSource from raw RGBA data.
17
+ * @param rgbaData - A Uint8ClampedArray of RGBA bytes (length = width * height * 4).
18
+ * @param width - Image width in pixels.
19
+ * @param height - Image height in pixels.
20
+ * @param doAutoInvert - If true, invert each computed luminance.
21
+ */
22
+ static createFromRawRGBA(rgbaData: Uint8ClampedArray, width: number, height: number, doAutoInvert?: boolean): UniversalLuminanceSource;
23
+ /**
24
+ * Converts raw RGBA data to a grayscale buffer (single channel).
25
+ * If doAutoInvert is true, each computed luminance is inverted.
26
+ */
27
+ private static toGrayscaleBuffer;
28
+ getWidth(): number;
29
+ getHeight(): number;
30
+ getRow(y: number, row?: Uint8ClampedArray): Uint8ClampedArray;
31
+ getMatrix(): Uint8ClampedArray;
32
+ isCropSupported(): boolean;
33
+ /**
34
+ * Crops a region from the grayscale buffer.
35
+ */
36
+ crop(left: number, top: number, width: number, height: number): LuminanceSource;
37
+ isRotateSupported(): boolean;
38
+ rotateCounterClockwise(): LuminanceSource;
39
+ rotateCounterClockwise45(): LuminanceSource;
40
+ invert(): LuminanceSource;
41
+ /**
42
+ * Rotates the grayscale buffer by the specified angle in degrees.
43
+ * Supports multiples of 90 only. Throws otherwise.
44
+ */
45
+ private rotate;
46
+ }
@@ -0,0 +1,7 @@
1
+ import Exception from './Exception';
2
+ /**
3
+ * Custom Error class of type Exception.
4
+ */
5
+ export default class UnsupportedOperationException extends Exception {
6
+ static readonly kind: string;
7
+ }
@@ -0,0 +1,30 @@
1
+ import BarcodeFormat from './BarcodeFormat';
2
+ import BitMatrix from './common/BitMatrix';
3
+ import EncodeHintType from './EncodeHintType';
4
+ /**
5
+ * The base class for all objects which encode/generate a barcode image.
6
+ *
7
+ * @author dswitkin@google.com (Daniel Switkin)
8
+ */
9
+ export interface Writer {
10
+ /**
11
+ * Encode a barcode using the default settings.
12
+ *
13
+ * @param contents The contents to encode in the barcode
14
+ * @param format The barcode format to generate
15
+ * @param width The preferred width in pixels
16
+ * @param height The preferred height in pixels
17
+ * @return {@link BitMatrix} representing encoded barcode image
18
+ * @throws WriterException if contents cannot be encoded legally in a format
19
+ */
20
+ /**
21
+ * @param contents The contents to encode in the barcode
22
+ * @param format The barcode format to generate
23
+ * @param width The preferred width in pixels
24
+ * @param height The preferred height in pixels
25
+ * @param hints Additional parameters to supply to the encoder
26
+ * @returns BitMatrix representing encoded barcode image
27
+ * @throws WriterException if contents cannot be encoded legally in a format
28
+ */
29
+ encode(contents: string, format: BarcodeFormat, width: number, height: number, hints: Map<EncodeHintType, any>): BitMatrix;
30
+ }
@@ -0,0 +1,7 @@
1
+ import Exception from './Exception';
2
+ /**
3
+ * Custom Error class of type Exception.
4
+ */
5
+ export default class WriterException extends Exception {
6
+ static readonly kind: string;
7
+ }
@@ -0,0 +1,111 @@
1
+ /**
2
+ * <p>A simple, fast array of bits, represented compactly by an array of ints internally.</p>
3
+ *
4
+ * @author Sean Owen
5
+ */
6
+ export default class BitArray {
7
+ private size;
8
+ private bits;
9
+ constructor(size?: number, bits?: Int32Array);
10
+ getSize(): number;
11
+ getSizeInBytes(): number;
12
+ private ensureCapacity;
13
+ /**
14
+ * @param i bit to get
15
+ * @return true iff bit i is set
16
+ */
17
+ get(i: number): boolean;
18
+ /**
19
+ * Sets bit i.
20
+ *
21
+ * @param i bit to set
22
+ */
23
+ set(i: number): void;
24
+ /**
25
+ * Flips bit i.
26
+ *
27
+ * @param i bit to set
28
+ */
29
+ flip(i: number): void;
30
+ /**
31
+ * @param from first bit to check
32
+ * @return index of first bit that is set, starting from the given index, or size if none are set
33
+ * at or beyond this given index
34
+ * @see #getNextUnset(int)
35
+ */
36
+ getNextSet(from: number): number;
37
+ /**
38
+ * @param from index to start looking for unset bit
39
+ * @return index of next unset bit, or {@code size} if none are unset until the end
40
+ * @see #getNextSet(int)
41
+ */
42
+ getNextUnset(from: number): number;
43
+ /**
44
+ * Sets a block of 32 bits, starting at bit i.
45
+ *
46
+ * @param i first bit to set
47
+ * @param newBits the new value of the next 32 bits. Note again that the least-significant bit
48
+ * corresponds to bit i, the next-least-significant to i+1, and so on.
49
+ */
50
+ setBulk(i: number, newBits: number): void;
51
+ /**
52
+ * Sets a range of bits.
53
+ *
54
+ * @param start start of range, inclusive.
55
+ * @param end end of range, exclusive
56
+ */
57
+ setRange(start: number, end: number): void;
58
+ /**
59
+ * Clears all bits (sets to false).
60
+ */
61
+ clear(): void;
62
+ /**
63
+ * Efficient method to check if a range of bits is set, or not set.
64
+ *
65
+ * @param start start of range, inclusive.
66
+ * @param end end of range, exclusive
67
+ * @param value if true, checks that bits in range are set, otherwise checks that they are not set
68
+ * @return true iff all bits are set or not set in range, according to value argument
69
+ * @throws IllegalArgumentException if end is less than start or the range is not contained in the array
70
+ */
71
+ isRange(start: number, end: number, value: boolean): boolean;
72
+ appendBit(bit: boolean): void;
73
+ /**
74
+ * Appends the least-significant bits, from value, in order from most-significant to
75
+ * least-significant. For example, appending 6 bits from 0x000001E will append the bits
76
+ * 0, 1, 1, 1, 1, 0 in that order.
77
+ *
78
+ * @param value {@code int} containing bits to append
79
+ * @param numBits bits from value to append
80
+ */
81
+ appendBits(value: number, numBits: number): void;
82
+ appendBitArray(other: BitArray): void;
83
+ xor(other: BitArray): void;
84
+ /**
85
+ *
86
+ * @param bitOffset first bit to start writing
87
+ * @param array array to write into. Bytes are written most-significant byte first. This is the opposite
88
+ * of the internal representation, which is exposed by {@link #getBitArray()}
89
+ * @param offset position in array to start writing
90
+ * @param numBytes how many bytes to write
91
+ */
92
+ toBytes(bitOffset: number, array: Uint8Array, offset: number, numBytes: number): void;
93
+ /**
94
+ * @return underlying array of ints. The first element holds the first 32 bits, and the least
95
+ * significant bit is bit 0.
96
+ */
97
+ getBitArray(): Int32Array;
98
+ /**
99
+ * Reverses all bits in the array.
100
+ */
101
+ reverse(): void;
102
+ private static makeArray;
103
+ equals(o: any): boolean;
104
+ hashCode(): number;
105
+ toString(): string;
106
+ clone(): BitArray;
107
+ /**
108
+ * converts to boolean array.
109
+ */
110
+ toArray(): Array<boolean>;
111
+ }
@@ -0,0 +1,98 @@
1
+ import { int } from '../../customTypings';
2
+ import BitArray from './BitArray';
3
+ export default class BitMatrix {
4
+ private width;
5
+ private height?;
6
+ private rowSize?;
7
+ private bits?;
8
+ constructor(width: number, height?: number | undefined, rowSize?: number | undefined, bits?: Int32Array | undefined);
9
+ /**
10
+ * Interprets a 2D array of booleans as a BitMatrix, where "true" means an "on" bit.
11
+ */
12
+ static parseFromBooleanArray(image: boolean[][]): BitMatrix;
13
+ /**
14
+ * Parses a string representation of the bit matrix.
15
+ */
16
+ static parseFromString(stringRepresentation: string, setString: string, unsetString: string): BitMatrix;
17
+ /**
18
+ * Gets the bit at position (x, y).
19
+ */
20
+ get(x: number, y: number): boolean;
21
+ /**
22
+ * Sets the bit at position (x, y) to true.
23
+ */
24
+ set(x: number, y: number): void;
25
+ /**
26
+ * Unsets the bit at position (x, y) (sets it to false).
27
+ */
28
+ unset(x: number, y: number): void;
29
+ /**
30
+ * Flips the bit at position (x, y).
31
+ */
32
+ flip(x: number, y: number): void;
33
+ /**
34
+ * XORs this matrix with another matrix.
35
+ */
36
+ xor(mask: BitMatrix): void;
37
+ /**
38
+ * Clears all bits (sets to false).
39
+ */
40
+ clear(): void;
41
+ /**
42
+ * Sets a square region of the matrix to true.
43
+ */
44
+ setRegion(left: number, top: number, width: number, height: number): void;
45
+ /**
46
+ * Retrieves a row as a BitArray.
47
+ */
48
+ getRow(y: number, row?: BitArray): BitArray;
49
+ /**
50
+ * Sets a row from a BitArray.
51
+ */
52
+ setRow(y: number, row: BitArray): void;
53
+ /**
54
+ * Rotates the matrix 180 degrees.
55
+ */
56
+ rotate180(): void;
57
+ /**
58
+ * Returns the smallest rectangle that encloses all set bits.
59
+ */
60
+ getEnclosingRectangle(): Int32Array;
61
+ /**
62
+ * Returns the coordinate of the top-left set bit.
63
+ */
64
+ getTopLeftOnBit(): Int32Array;
65
+ /**
66
+ * Returns the coordinate of the bottom-right set bit.
67
+ */
68
+ getBottomRightOnBit(): Int32Array;
69
+ /**
70
+ * Returns the width of the matrix.
71
+ */
72
+ getWidth(): number;
73
+ /**
74
+ * Returns the height of the matrix.
75
+ */
76
+ getHeight(): number;
77
+ /**
78
+ * Returns the row size of the matrix.
79
+ */
80
+ getRowSize(): number;
81
+ /**
82
+ * Checks equality with another BitMatrix.
83
+ */
84
+ equals(o: Object): boolean;
85
+ /**
86
+ * Computes the hash code.
87
+ */
88
+ hashCode(): int;
89
+ /**
90
+ * Returns a string representation of the matrix.
91
+ */
92
+ toString(setString?: string, unsetString?: string, lineSeparator?: string): string;
93
+ private buildToString;
94
+ /**
95
+ * Returns a clone of this BitMatrix.
96
+ */
97
+ clone(): BitMatrix;
98
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * <p>This provides an easy abstraction to read bits at a time from a sequence of bytes, where the
3
+ * number of bits read is not often a multiple of 8.</p>
4
+ *
5
+ * <p>This class is thread-safe but not reentrant -- unless the caller modifies the bytes array
6
+ * it passed in, in which case all bets are off.</p>
7
+ *
8
+ * @author Sean Owen
9
+ */
10
+ export default class BitSource {
11
+ private bytes;
12
+ private byteOffset;
13
+ private bitOffset;
14
+ /**
15
+ * @param bytes bytes from which this will read bits. Bits will be read from the first byte first.
16
+ * Bits are read within a byte from most-significant to least-significant bit.
17
+ */
18
+ constructor(bytes: Uint8Array);
19
+ /**
20
+ * @return index of next bit in current byte which would be read by the next call to {@link #readBits(int)}.
21
+ */
22
+ getBitOffset(): number;
23
+ /**
24
+ * @return index of next byte in input byte array which would be read by the next call to {@link #readBits(int)}.
25
+ */
26
+ getByteOffset(): number;
27
+ /**
28
+ * @param numBits number of bits to read
29
+ * @return int representing the bits read. The bits will appear as the least-significant
30
+ * bits of the int
31
+ * @throws IllegalArgumentException if numBits isn't in [1,32] or more than is available
32
+ */
33
+ readBits(numBits: number): number;
34
+ /**
35
+ * @return number of bits that can be read successfully
36
+ */
37
+ available(): number;
38
+ }