@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,25 @@
1
+ import { ErrorCorrectLevel } from './ErrorCorrectLevel.js';
2
+ import { Mode } from './Mode.js';
3
+ import { Polynomial } from './Polynomial.js';
4
+ import { QRCodeMinimal } from './QRCodeMinimal.js';
5
+ /**
6
+ * QRUtil
7
+ *
8
+ * @author Kazuhiko Arase
9
+ */
10
+ export declare class QRUtil {
11
+ constructor();
12
+ static getPatternPosition(typeNumber: number): number[];
13
+ private static PATTERN_POSITION_TABLE;
14
+ private static MAX_LENGTH;
15
+ static getMaxLength(typeNumber: number, mode: Mode, errorCorrectLevel: ErrorCorrectLevel): number;
16
+ static getErrorCorrectPolynomial(errorCorrectLength: number): Polynomial;
17
+ static getMaskFunc(maskPattern: number): (i: number, j: number) => boolean;
18
+ static getLostPoint(qrCode: QRCodeMinimal): number;
19
+ static getBCHTypeInfo(data: number): number;
20
+ static getBCHTypeNumber(data: number): number;
21
+ private static G15;
22
+ private static G18;
23
+ private static G15_MASK;
24
+ private static getBCHDigit;
25
+ }
@@ -0,0 +1,16 @@
1
+ import { ErrorCorrectLevel } from './ErrorCorrectLevel.js';
2
+ /**
3
+ * RSBlock
4
+ *
5
+ * @author Kazuhiko Arase
6
+ */
7
+ export declare class RSBlock {
8
+ private totalCount;
9
+ private dataCount;
10
+ private static RS_BLOCK_TABLE;
11
+ constructor(totalCount: number, dataCount: number);
12
+ getDataCount(): number;
13
+ getTotalCount(): number;
14
+ static getRSBlocks(typeNumber: number, errorCorrectLevel: ErrorCorrectLevel): RSBlock[];
15
+ private static getRsBlockTable;
16
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * createStringToBytes
3
+ *
4
+ * @author Kazuhiko Arase
5
+ * @param unicodeData base64 string of byte array.
6
+ * [16bit Unicode],[16bit Bytes], ...
7
+ * @param numChars
8
+ */
9
+ export declare function createStringToBytes(unicodeData: string, numChars: number): (s: string) => number[];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * stringToBytes_SJIS
3
+ *
4
+ * @author Kazuhiko Arase
5
+ */
6
+ export declare const stringToBytes_SJIS: {
7
+ SJIS: (s: string) => number[];
8
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * stringToBytes_UTF8
3
+ * contributed by elhigu
4
+ */
5
+ export declare const stringToBytes_UTF8: {
6
+ UTF8: (s: string) => number[];
7
+ };
@@ -0,0 +1 @@
1
+ declare var zbarWasm: {};
@@ -0,0 +1,410 @@
1
+ import BinaryBitmap from '../core/BinaryBitmap';
2
+ import DecodeHintType from '../core/DecodeHintType';
3
+ import Reader from '../core/Reader';
4
+ import Result from '../core/Result';
5
+ import { DecodeContinuouslyCallback } from './DecodeContinuouslyCallback';
6
+ import { HTMLVisualMediaElement } from './HTMLVisualMediaElement';
7
+ import { VideoInputDevice } from './VideoInputDevice';
8
+ /**
9
+ *
10
+ * Base class for browser code reader.
11
+ */
12
+ export declare class BrowserCodeReader {
13
+ protected readonly reader: Reader;
14
+ protected timeBetweenScansMillis: number;
15
+ protected _hints?: Map<DecodeHintType, any> | undefined;
16
+ /**
17
+ * If navigator is present.
18
+ */
19
+ get hasNavigator(): boolean;
20
+ /**
21
+ * If mediaDevices under navigator is supported.
22
+ */
23
+ get isMediaDevicesSuported(): boolean;
24
+ /**
25
+ * If enumerateDevices under navigator is supported.
26
+ */
27
+ get canEnumerateDevices(): boolean;
28
+ /**
29
+ * This will break the loop.
30
+ */
31
+ private _stopContinuousDecode;
32
+ /**
33
+ * This will break the loop.
34
+ */
35
+ private _stopAsyncDecode;
36
+ /**
37
+ * Delay time between decode attempts made by the scanner.
38
+ */
39
+ protected _timeBetweenDecodingAttempts: number;
40
+ /** Time between two decoding tries in milli seconds. */
41
+ get timeBetweenDecodingAttempts(): number;
42
+ /**
43
+ * Change the time span the decoder waits between two decoding tries.
44
+ *
45
+ * @param {number} millis Time between two decoding tries in milli seconds.
46
+ */
47
+ set timeBetweenDecodingAttempts(millis: number);
48
+ /**
49
+ * The HTML canvas element, used to draw the video or image's frame for decoding.
50
+ */
51
+ protected captureCanvas: HTMLCanvasElement;
52
+ /**
53
+ * The HTML canvas element context.
54
+ */
55
+ protected captureCanvasContext: CanvasRenderingContext2D;
56
+ /**
57
+ * The HTML image element, used as a fallback for the video element when decoding.
58
+ */
59
+ protected imageElement: HTMLImageElement;
60
+ /**
61
+ * Should contain the current registered listener for image loading,
62
+ * used to unregister that listener when needed.
63
+ */
64
+ protected imageLoadedListener: EventListener;
65
+ /**
66
+ * The stream output from camera.
67
+ */
68
+ protected stream: MediaStream;
69
+ /**
70
+ * The HTML video element, used to display the camera stream.
71
+ */
72
+ protected videoElement: HTMLVideoElement;
73
+ /**
74
+ * Should contain the current registered listener for video loaded-metadata,
75
+ * used to unregister that listener when needed.
76
+ */
77
+ protected videoCanPlayListener: EventListener;
78
+ /**
79
+ * Should contain the current registered listener for video play-ended,
80
+ * used to unregister that listener when needed.
81
+ */
82
+ protected videoEndedListener: EventListener;
83
+ /**
84
+ * Should contain the current registered listener for video playing,
85
+ * used to unregister that listener when needed.
86
+ */
87
+ protected videoPlayingEventListener: EventListener;
88
+ /**
89
+ * Sets the hints.
90
+ */
91
+ set hints(hints: Map<DecodeHintType, any>);
92
+ /**
93
+ * Sets the hints.
94
+ */
95
+ get hints(): Map<DecodeHintType, any>;
96
+ /**
97
+ * Creates an instance of BrowserCodeReader.
98
+ * @param {Reader} reader The reader instance to decode the barcode
99
+ * @param {number} [timeBetweenScansMillis=500] the time delay between subsequent successful decode tries
100
+ *
101
+ * @memberOf BrowserCodeReader
102
+ */
103
+ constructor(reader: Reader, timeBetweenScansMillis?: number, _hints?: Map<DecodeHintType, any> | undefined);
104
+ /**
105
+ * Lists all the available video input devices.
106
+ */
107
+ listVideoInputDevices(): Promise<MediaDeviceInfo[]>;
108
+ /**
109
+ * Obtain the list of available devices with type 'videoinput'.
110
+ *
111
+ * @returns {Promise<VideoInputDevice[]>} an array of available video input devices
112
+ *
113
+ * @memberOf BrowserCodeReader
114
+ *
115
+ * @deprecated Use `listVideoInputDevices` instead.
116
+ */
117
+ getVideoInputDevices(): Promise<VideoInputDevice[]>;
118
+ /**
119
+ * Let's you find a device using it's Id.
120
+ */
121
+ findDeviceById(deviceId: string): Promise<MediaDeviceInfo>;
122
+ /**
123
+ * Decodes the barcode from the device specified by deviceId while showing the video in the specified video element.
124
+ *
125
+ * @param deviceId the id of one of the devices obtained after calling getVideoInputDevices. Can be undefined, in this case it will decode from one of the available devices, preffering the main camera (environment facing) if available.
126
+ * @param video the video element in page where to show the video while decoding. Can be either an element id or directly an HTMLVideoElement. Can be undefined, in which case no video will be shown.
127
+ * @returns The decoding result.
128
+ *
129
+ * @memberOf BrowserCodeReader
130
+ *
131
+ * @deprecated Use `decodeOnceFromVideoDevice` instead.
132
+ */
133
+ decodeFromInputVideoDevice(deviceId?: string, videoSource?: string | HTMLVideoElement): Promise<Result>;
134
+ /**
135
+ * In one attempt, tries to decode the barcode from the device specified by deviceId while showing the video in the specified video element.
136
+ *
137
+ * @param deviceId the id of one of the devices obtained after calling getVideoInputDevices. Can be undefined, in this case it will decode from one of the available devices, preffering the main camera (environment facing) if available.
138
+ * @param video the video element in page where to show the video while decoding. Can be either an element id or directly an HTMLVideoElement. Can be undefined, in which case no video will be shown.
139
+ * @returns The decoding result.
140
+ *
141
+ * @memberOf BrowserCodeReader
142
+ */
143
+ decodeOnceFromVideoDevice(deviceId?: string, videoSource?: string | HTMLVideoElement): Promise<Result>;
144
+ /**
145
+ * In one attempt, tries to decode the barcode from a stream obtained from the given constraints while showing the video in the specified video element.
146
+ *
147
+ * @param constraints the media stream constraints to get s valid media stream to decode from
148
+ * @param video the video element in page where to show the video while decoding. Can be either an element id or directly an HTMLVideoElement. Can be undefined, in which case no video will be shown.
149
+ * @returns The decoding result.
150
+ *
151
+ * @memberOf BrowserCodeReader
152
+ */
153
+ decodeOnceFromConstraints(constraints: MediaStreamConstraints, videoSource?: string | HTMLVideoElement): Promise<Result>;
154
+ /**
155
+ * In one attempt, tries to decode the barcode from a stream obtained from the given constraints while showing the video in the specified video element.
156
+ *
157
+ * @param {MediaStream} [constraints] the media stream constraints to get s valid media stream to decode from
158
+ * @param {string|HTMLVideoElement} [video] the video element in page where to show the video while decoding. Can be either an element id or directly an HTMLVideoElement. Can be undefined, in which case no video will be shown.
159
+ * @returns {Promise<Result>} The decoding result.
160
+ *
161
+ * @memberOf BrowserCodeReader
162
+ */
163
+ decodeOnceFromStream(stream: MediaStream, videoSource?: string | HTMLVideoElement): Promise<Result>;
164
+ /**
165
+ * Continuously decodes the barcode from the device specified by device while showing the video in the specified video element.
166
+ *
167
+ * @param {string|null} [deviceId] the id of one of the devices obtained after calling getVideoInputDevices. Can be undefined, in this case it will decode from one of the available devices, preffering the main camera (environment facing) if available.
168
+ * @param {string|HTMLVideoElement|null} [video] the video element in page where to show the video while decoding. Can be either an element id or directly an HTMLVideoElement. Can be undefined, in which case no video will be shown.
169
+ * @returns {Promise<void>}
170
+ *
171
+ * @memberOf BrowserCodeReader
172
+ *
173
+ * @deprecated Use `decodeFromVideoDevice` instead.
174
+ */
175
+ decodeFromInputVideoDeviceContinuously(deviceId: string | null, videoSource: string | HTMLVideoElement | null, callbackFn: DecodeContinuouslyCallback): Promise<void>;
176
+ /**
177
+ * Continuously tries to decode the barcode from the device specified by device while showing the video in the specified video element.
178
+ *
179
+ * @param {string|null} [deviceId] the id of one of the devices obtained after calling getVideoInputDevices. Can be undefined, in this case it will decode from one of the available devices, preffering the main camera (environment facing) if available.
180
+ * @param {string|HTMLVideoElement|null} [video] the video element in page where to show the video while decoding. Can be either an element id or directly an HTMLVideoElement. Can be undefined, in which case no video will be shown.
181
+ * @returns {Promise<void>}
182
+ *
183
+ * @memberOf BrowserCodeReader
184
+ */
185
+ decodeFromVideoDevice(deviceId: string | null, videoSource: string | HTMLVideoElement | null, callbackFn: DecodeContinuouslyCallback): Promise<void>;
186
+ /**
187
+ * Continuously tries to decode the barcode from a stream obtained from the given constraints while showing the video in the specified video element.
188
+ *
189
+ * @param {MediaStream} [constraints] the media stream constraints to get s valid media stream to decode from
190
+ * @param {string|HTMLVideoElement} [video] the video element in page where to show the video while decoding. Can be either an element id or directly an HTMLVideoElement. Can be undefined, in which case no video will be shown.
191
+ * @returns {Promise<Result>} The decoding result.
192
+ *
193
+ * @memberOf BrowserCodeReader
194
+ */
195
+ decodeFromConstraints(constraints: MediaStreamConstraints, videoSource: string | HTMLVideoElement, callbackFn: DecodeContinuouslyCallback): Promise<void>;
196
+ /**
197
+ * In one attempt, tries to decode the barcode from a stream obtained from the given constraints while showing the video in the specified video element.
198
+ *
199
+ * @param {MediaStream} [constraints] the media stream constraints to get s valid media stream to decode from
200
+ * @param {string|HTMLVideoElement} [video] the video element in page where to show the video while decoding. Can be either an element id or directly an HTMLVideoElement. Can be undefined, in which case no video will be shown.
201
+ * @returns {Promise<Result>} The decoding result.
202
+ *
203
+ * @memberOf BrowserCodeReader
204
+ */
205
+ decodeFromStream(stream: MediaStream, videoSource: string | HTMLVideoElement, callbackFn: DecodeContinuouslyCallback): Promise<void>;
206
+ /**
207
+ * Breaks the decoding loop.
208
+ */
209
+ stopAsyncDecode(): void;
210
+ /**
211
+ * Breaks the decoding loop.
212
+ */
213
+ stopContinuousDecode(): void;
214
+ /**
215
+ * Sets the new stream and request a new decoding-with-delay.
216
+ *
217
+ * @param stream The stream to be shown in the video element.
218
+ * @param decodeFn A callback for the decode method.
219
+ */
220
+ protected attachStreamToVideo(stream: MediaStream, videoSource: string | HTMLVideoElement): Promise<HTMLVideoElement>;
221
+ /**
222
+ *
223
+ * @param videoElement
224
+ */
225
+ protected playVideoOnLoadAsync(videoElement: HTMLVideoElement): Promise<void>;
226
+ /**
227
+ * Binds listeners and callbacks to the videoElement.
228
+ *
229
+ * @param element
230
+ * @param callbackFn
231
+ */
232
+ protected playVideoOnLoad(element: HTMLVideoElement, callbackFn: EventListener): void;
233
+ /**
234
+ * Checks if the given video element is currently playing.
235
+ */
236
+ isVideoPlaying(video: HTMLVideoElement): boolean;
237
+ /**
238
+ * Just tries to play the video and logs any errors.
239
+ * The play call is only made is the video is not already playing.
240
+ */
241
+ tryPlayVideo(videoElement: HTMLVideoElement): Promise<void>;
242
+ /**
243
+ * Searches and validates a media element.
244
+ */
245
+ getMediaElement(mediaElementId: string, type: string): HTMLVisualMediaElement;
246
+ /**
247
+ * Decodes the barcode from an image.
248
+ *
249
+ * @param {(string|HTMLImageElement)} [source] The image element that can be either an element id or the element itself. Can be undefined in which case the decoding will be done from the imageUrl parameter.
250
+ * @param {string} [url]
251
+ * @returns {Promise<Result>} The decoding result.
252
+ *
253
+ * @memberOf BrowserCodeReader
254
+ */
255
+ decodeFromImage(source?: string | HTMLImageElement, url?: string): Promise<Result>;
256
+ /**
257
+ * Decodes the barcode from a video.
258
+ *
259
+ * @param {(string|HTMLImageElement)} [source] The image element that can be either an element id or the element itself. Can be undefined in which case the decoding will be done from the imageUrl parameter.
260
+ * @param {string} [url]
261
+ * @returns {Promise<Result>} The decoding result.
262
+ *
263
+ * @memberOf BrowserCodeReader
264
+ */
265
+ decodeFromVideo(source?: string | HTMLVideoElement, url?: string): Promise<Result>;
266
+ /**
267
+ * Decodes continuously the barcode from a video.
268
+ *
269
+ * @param {(string|HTMLImageElement)} [source] The image element that can be either an element id or the element itself. Can be undefined in which case the decoding will be done from the imageUrl parameter.
270
+ * @param {string} [url]
271
+ * @returns {Promise<Result>} The decoding result.
272
+ *
273
+ * @memberOf BrowserCodeReader
274
+ *
275
+ * @experimental
276
+ */
277
+ decodeFromVideoContinuously(source: string | HTMLVideoElement | null, url: string | null, callbackFn: DecodeContinuouslyCallback): Promise<void>;
278
+ /**
279
+ * Decodes something from an image HTML element.
280
+ */
281
+ decodeFromImageElement(source: string | HTMLImageElement): Promise<Result>;
282
+ /**
283
+ * Decodes something from an image HTML element.
284
+ */
285
+ decodeFromVideoElement(source: string | HTMLVideoElement): Promise<Result>;
286
+ /**
287
+ * Decodes something from an image HTML element.
288
+ */
289
+ decodeFromVideoElementContinuously(source: string | HTMLVideoElement, callbackFn: DecodeContinuouslyCallback): Promise<void>;
290
+ /**
291
+ * Sets up the video source so it can be decoded when loaded.
292
+ *
293
+ * @param source The video source element.
294
+ */
295
+ private _decodeFromVideoElementSetup;
296
+ /**
297
+ * Decodes an image from a URL.
298
+ */
299
+ decodeFromImageUrl(url?: string): Promise<Result>;
300
+ /**
301
+ * Decodes an image from a URL.
302
+ */
303
+ decodeFromVideoUrl(url: string): Promise<Result>;
304
+ /**
305
+ * Decodes an image from a URL.
306
+ *
307
+ * @experimental
308
+ */
309
+ decodeFromVideoUrlContinuously(url: string, callbackFn: DecodeContinuouslyCallback): Promise<void>;
310
+ private _decodeOnLoadImage;
311
+ private _decodeOnLoadVideo;
312
+ private _decodeOnLoadVideoContinuously;
313
+ isImageLoaded(img: HTMLImageElement): boolean;
314
+ prepareImageElement(imageSource?: HTMLImageElement | string): HTMLImageElement;
315
+ /**
316
+ * Sets a HTMLVideoElement for scanning or creates a new one.
317
+ *
318
+ * @param videoSource The HTMLVideoElement to be set.
319
+ */
320
+ prepareVideoElement(videoSource?: HTMLVideoElement | string): HTMLVideoElement;
321
+ /**
322
+ * Tries to decode from the video input until it finds some value.
323
+ */
324
+ decodeOnce(element: HTMLVisualMediaElement, retryIfNotFound?: boolean, retryIfChecksumOrFormatError?: boolean): Promise<Result>;
325
+ /**
326
+ * Continuously decodes from video input.
327
+ */
328
+ decodeContinuously(element: HTMLVideoElement, callbackFn: DecodeContinuouslyCallback): void;
329
+ /**
330
+ * Gets the BinaryBitmap for ya! (and decodes it)
331
+ */
332
+ decode(element: HTMLVisualMediaElement): Result;
333
+ /**
334
+ * Creates a binaryBitmap based in some image source.
335
+ *
336
+ * @param mediaElement HTML element containing drawable image source.
337
+ */
338
+ createBinaryBitmap(mediaElement: HTMLVisualMediaElement): BinaryBitmap;
339
+ /**
340
+ *
341
+ */
342
+ protected getCaptureCanvasContext(mediaElement?: HTMLVisualMediaElement): CanvasRenderingContext2D;
343
+ /**
344
+ *
345
+ */
346
+ protected getCaptureCanvas(mediaElement?: HTMLVisualMediaElement): HTMLCanvasElement;
347
+ /**
348
+ * Overwriting this allows you to manipulate the next frame in anyway you want before decode.
349
+ */
350
+ drawFrameOnCanvas(srcElement: HTMLVideoElement, dimensions?: {
351
+ sx: number;
352
+ sy: number;
353
+ sWidth: number;
354
+ sHeight: number;
355
+ dx: number;
356
+ dy: number;
357
+ dWidth: number;
358
+ dHeight: number;
359
+ }, canvasElementContext?: CanvasRenderingContext2D): void;
360
+ /**
361
+ * Ovewriting this allows you to manipulate the snapshot image in anyway you want before decode.
362
+ */
363
+ drawImageOnCanvas(srcElement: HTMLImageElement, dimensions?: {
364
+ sx: number;
365
+ sy: number;
366
+ sWidth: number;
367
+ sHeight: number;
368
+ dx: number;
369
+ dy: number;
370
+ dWidth: number;
371
+ dHeight: number;
372
+ }, canvasElementContext?: CanvasRenderingContext2D): void;
373
+ /**
374
+ * Call the encapsulated readers decode
375
+ */
376
+ decodeBitmap(binaryBitmap: BinaryBitmap): Result;
377
+ /**
378
+ * 🖌 Prepares the canvas for capture and scan frames.
379
+ */
380
+ createCaptureCanvas(mediaElement?: HTMLVisualMediaElement): HTMLCanvasElement;
381
+ /**
382
+ * Stops the continuous scan and cleans the stream.
383
+ */
384
+ protected stopStreams(): void;
385
+ /**
386
+ * Resets the code reader to the initial state. Cancels any ongoing barcode scanning from video or camera.
387
+ *
388
+ * @memberOf BrowserCodeReader
389
+ */
390
+ reset(): void;
391
+ private _destroyVideoElement;
392
+ private _destroyImageElement;
393
+ /**
394
+ * Cleans canvas references 🖌
395
+ */
396
+ private _destroyCaptureCanvas;
397
+ /**
398
+ * Defines what the videoElement src will be.
399
+ *
400
+ * @param videoElement
401
+ * @param stream
402
+ */
403
+ addVideoSource(videoElement: HTMLVideoElement, stream: MediaStream): void;
404
+ /**
405
+ * Unbinds a HTML video src property.
406
+ *
407
+ * @param videoElement
408
+ */
409
+ private cleanVideoSource;
410
+ }
@@ -0,0 +1,29 @@
1
+ import BinaryBitmap from '../core/BinaryBitmap';
2
+ import Result from '../core/Result';
3
+ import { BrowserCodeReader } from './BrowserCodeReader';
4
+ /**
5
+ * QR Code reader to use from browser with improved error handling.
6
+ * This implementation properly handles promise rejections when QR codes can't be decoded.
7
+ */
8
+ export declare class BrowserQRCodeReader extends BrowserCodeReader {
9
+ private qrReader;
10
+ private inProgressDecodes;
11
+ constructor(timeBetweenScansMillis?: number);
12
+ /**
13
+ * Safely reset the reader without causing message channel issues
14
+ */
15
+ private safeReset;
16
+ /**
17
+ * Overrides the decodeBitmap method to ensure proper error handling and reader reset.
18
+ * This makes BrowserQRCodeReader behave consistently with BrowserMultiFormatReader.
19
+ */
20
+ decodeBitmap(binaryBitmap: BinaryBitmap): Result;
21
+ /**
22
+ * Overrides decodeFromImageUrl to ensure proper resource handling
23
+ */
24
+ decodeFromImageUrl(url: string): Promise<Result>;
25
+ /**
26
+ * Override the reset method to safely clean up resources
27
+ */
28
+ reset(): void;
29
+ }
@@ -0,0 +1,46 @@
1
+ import EncodeHintType from '../core/EncodeHintType';
2
+ /**
3
+ * @deprecated Moving to @zxing/browser
4
+ */
5
+ declare class BrowserQRCodeSvgWriter {
6
+ private static readonly QUIET_ZONE_SIZE;
7
+ /**
8
+ * SVG markup NameSpace
9
+ */
10
+ private static readonly SVG_NS;
11
+ /**
12
+ * Writes and renders a QRCode SVG element.
13
+ *
14
+ * @param contents
15
+ * @param width
16
+ * @param height
17
+ * @param hints
18
+ */
19
+ write(contents: string, width: number, height: number, hints?: Map<EncodeHintType, any>): SVGSVGElement;
20
+ /**
21
+ * Renders the result and then appends it to the DOM.
22
+ */
23
+ writeToDom(containerElement: string | HTMLElement, contents: string, width: number, height: number, hints?: Map<EncodeHintType, any>): void;
24
+ /**
25
+ * Note that the input matrix uses 0 == white, 1 == black.
26
+ * The output matrix uses 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap).
27
+ */
28
+ private renderResult;
29
+ /**
30
+ * Creates a SVG element.
31
+ *
32
+ * @param w SVG's width attribute
33
+ * @param h SVG's height attribute
34
+ */
35
+ private createSVGElement;
36
+ /**
37
+ * Creates a SVG rect element.
38
+ *
39
+ * @param x Element's x coordinate
40
+ * @param y Element's y coordinate
41
+ * @param w Element's width attribute
42
+ * @param h Element's height attribute
43
+ */
44
+ private createSvgRectElement;
45
+ }
46
+ export { BrowserQRCodeSvgWriter };
@@ -0,0 +1,49 @@
1
+ import EncodeHintType from '../core/EncodeHintType';
2
+ /**
3
+ * @deprecated Moving to @zxing/browser
4
+ */
5
+ declare abstract class BrowserSvgCodeWriter {
6
+ /**
7
+ * Default quiet zone in pixels.
8
+ */
9
+ private static readonly QUIET_ZONE_SIZE;
10
+ /**
11
+ * SVG markup NameSpace
12
+ */
13
+ private static readonly SVG_NS;
14
+ /**
15
+ * A HTML container element for the image.
16
+ */
17
+ private containerElement;
18
+ /**
19
+ * Constructs. 😉
20
+ */
21
+ constructor(containerElement: string | HTMLElement);
22
+ /**
23
+ * Writes the QR code to a SVG and renders it in the container.
24
+ */
25
+ write(contents: string, width: number, height: number, hints?: Map<EncodeHintType, any>): SVGSVGElement;
26
+ /**
27
+ * Encodes the content to a Barcode type.
28
+ */
29
+ private encode;
30
+ /**
31
+ * Renders the SVG in the container.
32
+ *
33
+ * @note the input matrix uses 0 == white, 1 == black. The output matrix uses 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap).
34
+ */
35
+ private renderResult;
36
+ /**
37
+ * Creates a SVG element.
38
+ */
39
+ protected createSVGElement(w: number, h: number): SVGSVGElement;
40
+ /**
41
+ * Creates a SVG rect.
42
+ */
43
+ protected createSvgPathPlaceholderElement(w: number, h: number): SVGPathElement;
44
+ /**
45
+ * Creates a SVG rect.
46
+ */
47
+ protected createSvgRectElement(x: number, y: number, w: number, h: number): SVGRectElement;
48
+ }
49
+ export { BrowserSvgCodeWriter };
@@ -0,0 +1,6 @@
1
+ import Exception from '../core/Exception';
2
+ import Result from '../core/Result';
3
+ /**
4
+ * Callback format for continuous decode scan.
5
+ */
6
+ export type DecodeContinuouslyCallback = (result: Result, error?: Exception) => any;
@@ -0,0 +1,27 @@
1
+ import LuminanceSource from '../core/LuminanceSource';
2
+ export declare class HTMLCanvasElementLuminanceSource extends LuminanceSource {
3
+ private canvas;
4
+ private buffer;
5
+ private static DEGREE_TO_RADIANS;
6
+ private static FRAME_INDEX;
7
+ private tempCanvasElement;
8
+ constructor(canvas: HTMLCanvasElement, doAutoInvert?: boolean);
9
+ private static makeBufferFromCanvasImageData;
10
+ private static toGrayscaleBuffer;
11
+ getRow(y: number, row: Uint8ClampedArray): Uint8ClampedArray;
12
+ getMatrix(): Uint8ClampedArray;
13
+ isCropSupported(): boolean;
14
+ crop(left: number, top: number, width: number, height: number): LuminanceSource;
15
+ /**
16
+ * This is always true, since the image is a gray-scale image.
17
+ *
18
+ * @return true
19
+ */
20
+ isRotateSupported(): boolean;
21
+ rotateCounterClockwise(): LuminanceSource;
22
+ rotateCounterClockwise45(): LuminanceSource;
23
+ private getTempCanvasElement;
24
+ private rotate;
25
+ invert(): LuminanceSource;
26
+ hightContrast(threshold?: number): LuminanceSource;
27
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * HTML elements that can be decoded.
3
+ */
4
+ export type HTMLVisualMediaElement = HTMLVideoElement | HTMLImageElement;
@@ -0,0 +1,22 @@
1
+ export declare class VideoInputDevice implements MediaDeviceInfo {
2
+ deviceId: string;
3
+ label: string;
4
+ /** @inheritdoc */
5
+ readonly kind = "videoinput";
6
+ /** @inheritdoc */
7
+ readonly groupId: string;
8
+ /**
9
+ * Creates an instance of VideoInputDevice.
10
+ *
11
+ * @param {string} deviceId the video input device id
12
+ * @param {string} label the label of the device if available
13
+ */
14
+ constructor(deviceId: string, label: string, groupId?: string);
15
+ /** @inheritdoc */
16
+ toJSON(): {
17
+ kind: string;
18
+ groupId: string;
19
+ deviceId: string;
20
+ label: string;
21
+ };
22
+ }
@@ -0,0 +1,3 @@
1
+ export * from './browser/BrowserQRCodeReader';
2
+ export * from './browser/HTMLCanvasElementLuminanceSource';
3
+ export * from './core/UniversalLuminanceSource';