@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,47 @@
1
+ import ByteMatrix from './ByteMatrix';
2
+ /**
3
+ * @author Satoru Takabayashi
4
+ * @author Daniel Switkin
5
+ * @author Sean Owen
6
+ */
7
+ export default class MaskUtil {
8
+ private static N1;
9
+ private static N2;
10
+ private static N3;
11
+ private static N4;
12
+ private constructor();
13
+ /**
14
+ * Apply mask penalty rule 1 and return the penalty. Find repetitive cells with the same color and
15
+ * give penalty to them. Example: 00000 or 11111.
16
+ */
17
+ static applyMaskPenaltyRule1(matrix: ByteMatrix): number;
18
+ /**
19
+ * Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give
20
+ * penalty to them. This is actually equivalent to the spec's rule, which is to find MxN blocks and give a
21
+ * penalty proportional to (M-1)x(N-1), because this is the number of 2x2 blocks inside such a block.
22
+ */
23
+ static applyMaskPenaltyRule2(matrix: ByteMatrix): number;
24
+ /**
25
+ * Apply mask penalty rule 3 and return the penalty. Find consecutive runs of 1:1:3:1:1:4
26
+ * starting with black, or 4:1:1:3:1:1 starting with white, and give penalty to them. If we
27
+ * find patterns like 000010111010000, we give penalty once.
28
+ */
29
+ static applyMaskPenaltyRule3(matrix: ByteMatrix): number;
30
+ private static isWhiteHorizontal;
31
+ private static isWhiteVertical;
32
+ /**
33
+ * Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give
34
+ * penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance.
35
+ */
36
+ static applyMaskPenaltyRule4(matrix: ByteMatrix): number;
37
+ /**
38
+ * Return the mask bit for "getMaskPattern" at "x" and "y". See 8.8 of JISX0510:2004 for mask
39
+ * pattern conditions.
40
+ */
41
+ static getDataMaskBit(maskPattern: number, x: number, y: number): boolean;
42
+ /**
43
+ * Helper function for applyMaskPenaltyRule1. We need this for doing this calculation in both
44
+ * vertical and horizontal orders respectively.
45
+ */
46
+ private static applyMaskPenaltyRule1Internal;
47
+ }
@@ -0,0 +1,37 @@
1
+ import BitArray from '../../common/BitArray';
2
+ import ErrorCorrectionLevel from '../decoder/ErrorCorrectionLevel';
3
+ import Version from '../decoder/Version';
4
+ import ByteMatrix from './ByteMatrix';
5
+ /**
6
+ * @author satorux@google.com (Satoru Takabayashi) - creator
7
+ * @author dswitkin@google.com (Daniel Switkin) - ported from C++
8
+ */
9
+ export default class MatrixUtil {
10
+ private constructor();
11
+ private static POSITION_DETECTION_PATTERN;
12
+ private static POSITION_ADJUSTMENT_PATTERN;
13
+ private static POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE;
14
+ private static TYPE_INFO_COORDINATES;
15
+ private static VERSION_INFO_POLY;
16
+ private static TYPE_INFO_POLY;
17
+ private static TYPE_INFO_MASK_PATTERN;
18
+ static clearMatrix(matrix: ByteMatrix): void;
19
+ static buildMatrix(dataBits: BitArray, ecLevel: ErrorCorrectionLevel, version: Version, maskPattern: number, matrix: ByteMatrix): void;
20
+ static embedBasicPatterns(version: Version, matrix: ByteMatrix): void;
21
+ static embedTypeInfo(ecLevel: ErrorCorrectionLevel, maskPattern: number, matrix: ByteMatrix): void;
22
+ static maybeEmbedVersionInfo(version: Version, matrix: ByteMatrix): void;
23
+ static embedDataBits(dataBits: BitArray, maskPattern: number, matrix: ByteMatrix): void;
24
+ static findMSBSet(value: number): number;
25
+ static calculateBCHCode(value: number, poly: number): number;
26
+ static makeTypeInfoBits(ecLevel: ErrorCorrectionLevel, maskPattern: number, bits: BitArray): void;
27
+ static makeVersionInfoBits(version: Version, bits: BitArray): void;
28
+ private static isEmpty;
29
+ private static embedTimingPatterns;
30
+ private static embedDarkDotAtLeftBottomCorner;
31
+ private static embedHorizontalSeparationPattern;
32
+ private static embedVerticalSeparationPattern;
33
+ private static embedPositionAdjustmentPattern;
34
+ private static embedPositionDetectionPattern;
35
+ private static embedPositionDetectionPatternsAndSeparators;
36
+ private static maybeEmbedPositionAdjustmentPatterns;
37
+ }
@@ -0,0 +1,29 @@
1
+ import ErrorCorrectionLevel from '../decoder/ErrorCorrectionLevel';
2
+ import Mode from '../decoder/Mode';
3
+ import Version from '../decoder/Version';
4
+ import ByteMatrix from './ByteMatrix';
5
+ /**
6
+ * @author satorux@google.com (Satoru Takabayashi) - creator
7
+ * @author dswitkin@google.com (Daniel Switkin) - ported from C++
8
+ */
9
+ export default class QRCode {
10
+ static NUM_MASK_PATTERNS: number;
11
+ private mode;
12
+ private ecLevel;
13
+ private version;
14
+ private maskPattern;
15
+ private matrix;
16
+ constructor();
17
+ getMode(): Mode;
18
+ getECLevel(): ErrorCorrectionLevel;
19
+ getVersion(): Version;
20
+ getMaskPattern(): number;
21
+ getMatrix(): ByteMatrix;
22
+ toString(): string;
23
+ setMode(value: Mode): void;
24
+ setECLevel(value: ErrorCorrectionLevel): void;
25
+ setVersion(version: Version): void;
26
+ setMaskPattern(value: number): void;
27
+ setMatrix(value: ByteMatrix): void;
28
+ static isValidMaskPattern(maskPattern: number): boolean;
29
+ }
@@ -0,0 +1,45 @@
1
+ import { int } from '../../customTypings';
2
+ export default class Arrays {
3
+ /**
4
+ * Assigns the specified int value to each element of the specified array
5
+ * of ints.
6
+ *
7
+ * @param a the array to be filled
8
+ * @param val the value to be stored in all elements of the array
9
+ */
10
+ static fill(a: Int32Array | Uint8Array | any[], val: int): void;
11
+ /**
12
+ * Assigns the specified int value to each element of the specified
13
+ * range of the specified array of ints. The range to be filled
14
+ * extends from index {@code fromIndex}, inclusive, to index
15
+ * {@code toIndex}, exclusive. (If {@code fromIndex==toIndex}, the
16
+ * range to be filled is empty.)
17
+ *
18
+ * @param a the array to be filled
19
+ * @param fromIndex the index of the first element (inclusive) to be
20
+ * filled with the specified value
21
+ * @param toIndex the index of the last element (exclusive) to be
22
+ * filled with the specified value
23
+ * @param val the value to be stored in all elements of the array
24
+ * @throws IllegalArgumentException if {@code fromIndex > toIndex}
25
+ * @throws ArrayIndexOutOfBoundsException if {@code fromIndex < 0} or
26
+ * {@code toIndex > a.length}
27
+ */
28
+ static fillWithin(a: Int32Array, fromIndex: int, toIndex: int, val: int): void;
29
+ /**
30
+ * Checks that {@code fromIndex} and {@code toIndex} are in
31
+ * the range and throws an exception if they aren't.
32
+ */
33
+ static rangeCheck(arrayLength: int, fromIndex: int, toIndex: int): void;
34
+ static asList<T = any>(...args: T[]): T[];
35
+ static create<T = any>(rows: int, cols: int, value?: T): T[][];
36
+ static createInt32Array(rows: int, cols: int, value?: int): Int32Array[];
37
+ static equals(first: any, second: any): boolean;
38
+ static hashCode(a: any): number;
39
+ static fillUint8Array(a: Uint8Array, value: number): void;
40
+ static copyOf(original: Int32Array, newLength: number): Int32Array;
41
+ static copyOfUint8Array(original: Uint8Array, newLength: number): Uint8Array;
42
+ static copyOfRange(original: Int32Array, from: number, to: number): Int32Array;
43
+ static binarySearch(ar: Int32Array, el: number, comparator?: (a: number, b: number) => number): number;
44
+ static numberComparator(a: number, b: number): number;
45
+ }
@@ -0,0 +1,174 @@
1
+ import { int } from '../../customTypings';
2
+ import OutputStream from './OutputStream';
3
+ /**
4
+ * This class implements an output stream in which the data is
5
+ * written into a byte array. The buffer automatically grows as data
6
+ * is written to it.
7
+ * The data can be retrieved using <code>toByteArray()</code> and
8
+ * <code>toString()</code>.
9
+ * <p>
10
+ * Closing a <tt>ByteArrayOutputStream</tt> has no effect. The methods in
11
+ * this class can be called after the stream has been closed without
12
+ * generating an <tt>IOException</tt>.
13
+ *
14
+ * @author Arthur van Hoff
15
+ * @since JDK1.0
16
+ */
17
+ export default class ByteArrayOutputStream extends OutputStream {
18
+ /**
19
+ * The buffer where data is stored.
20
+ */
21
+ protected buf: Uint8Array;
22
+ /**
23
+ * The number of valid bytes in the buffer.
24
+ */
25
+ protected count: int;
26
+ /**
27
+ * Creates a new byte array output stream. The buffer capacity is
28
+ * initially 32 bytes, though its size increases if necessary.
29
+ */
30
+ /**
31
+ * Creates a new byte array output stream, with a buffer capacity of
32
+ * the specified size, in bytes.
33
+ *
34
+ * @param size the initial size.
35
+ * @exception IllegalArgumentException if size is negative.
36
+ */
37
+ constructor(size?: int);
38
+ /**
39
+ * Increases the capacity if necessary to ensure that it can hold
40
+ * at least the number of elements specified by the minimum
41
+ * capacity argument.
42
+ *
43
+ * @param minCapacity the desired minimum capacity
44
+ * @throws OutOfMemoryError if {@code minCapacity < 0}. This is
45
+ * interpreted as a request for the unsatisfiably large capacity
46
+ * {@code (long) Integer.MAX_VALUE + (minCapacity - Integer.MAX_VALUE)}.
47
+ */
48
+ private ensureCapacity;
49
+ /**
50
+ * Increases the capacity to ensure that it can hold at least the
51
+ * number of elements specified by the minimum capacity argument.
52
+ *
53
+ * @param minCapacity the desired minimum capacity
54
+ */
55
+ private grow;
56
+ /**
57
+ * Writes the specified byte to this byte array output stream.
58
+ *
59
+ * @param b the byte to be written.
60
+ */
61
+ write(b: int): void;
62
+ /**
63
+ * Writes <code>len</code> bytes from the specified byte array
64
+ * starting at offset <code>off</code> to this byte array output stream.
65
+ *
66
+ * @param b the data.
67
+ * @param off the start offset in the data.
68
+ * @param len the number of bytes to write.
69
+ */
70
+ writeBytesOffset(b: Uint8Array, off: int, len: int): void;
71
+ /**
72
+ * Writes the complete contents of this byte array output stream to
73
+ * the specified output stream argument, as if by calling the output
74
+ * stream's write method using <code>out.write(buf, 0, count)</code>.
75
+ *
76
+ * @param out the output stream to which to write the data.
77
+ * @exception IOException if an I/O error occurs.
78
+ */
79
+ writeTo(out: OutputStream): void;
80
+ /**
81
+ * Resets the <code>count</code> field of this byte array output
82
+ * stream to zero, so that all currently accumulated output in the
83
+ * output stream is discarded. The output stream can be used again,
84
+ * reusing the already allocated buffer space.
85
+ *
86
+ * @see java.io.ByteArrayInputStream#count
87
+ */
88
+ reset(): void;
89
+ /**
90
+ * Creates a newly allocated byte array. Its size is the current
91
+ * size of this output stream and the valid contents of the buffer
92
+ * have been copied into it.
93
+ *
94
+ * @return the current contents of this output stream, as a byte array.
95
+ * @see java.io.ByteArrayOutputStream#size()
96
+ */
97
+ toByteArray(): Uint8Array;
98
+ /**
99
+ * Returns the current size of the buffer.
100
+ *
101
+ * @return the value of the <code>count</code> field, which is the number
102
+ * of valid bytes in this output stream.
103
+ * @see java.io.ByteArrayOutputStream#count
104
+ */
105
+ size(): int;
106
+ toString(param?: number | string): string;
107
+ /**
108
+ * Converts the buffer's contents into a string decoding bytes using the
109
+ * platform's default character set. The length of the new <tt>String</tt>
110
+ * is a function of the character set, and hence may not be equal to the
111
+ * size of the buffer.
112
+ *
113
+ * <p> This method always replaces malformed-input and unmappable-character
114
+ * sequences with the default replacement string for the platform's
115
+ * default character set. The {@linkplain java.nio.charset.CharsetDecoder}
116
+ * class should be used when more control over the decoding process is
117
+ * required.
118
+ *
119
+ * @return String decoded from the buffer's contents.
120
+ * @since JDK1.1
121
+ */
122
+ toString_void(): string;
123
+ /**
124
+ * Converts the buffer's contents into a string by decoding the bytes using
125
+ * the specified {@link java.nio.charset.Charset charsetName}. The length of
126
+ * the new <tt>String</tt> is a function of the charset, and hence may not be
127
+ * equal to the length of the byte array.
128
+ *
129
+ * <p> This method always replaces malformed-input and unmappable-character
130
+ * sequences with this charset's default replacement string. The {@link
131
+ * java.nio.charset.CharsetDecoder} class should be used when more control
132
+ * over the decoding process is required.
133
+ *
134
+ * @param charsetName the name of a supported
135
+ * {@linkplain java.nio.charset.Charset </code>charset<code>}
136
+ * @return String decoded from the buffer's contents.
137
+ * @exception UnsupportedEncodingException
138
+ * If the named charset is not supported
139
+ * @since JDK1.1
140
+ */
141
+ toString_string(charsetName: string): string;
142
+ /**
143
+ * Creates a newly allocated string. Its size is the current size of
144
+ * the output stream and the valid contents of the buffer have been
145
+ * copied into it. Each character <i>c</i> in the resulting string is
146
+ * constructed from the corresponding element <i>b</i> in the byte
147
+ * array such that:
148
+ * <blockquote><pre>
149
+ * c == (char)(((hibyte &amp; 0xff) &lt;&lt; 8) | (b &amp; 0xff))
150
+ * </pre></blockquote>
151
+ *
152
+ * @deprecated This method does not properly convert bytes into characters.
153
+ * As of JDK&nbsp;1.1, the preferred way to do this is via the
154
+ * <code>toString(String enc)</code> method, which takes an encoding-name
155
+ * argument, or the <code>toString()</code> method, which uses the
156
+ * platform's default character encoding.
157
+ *
158
+ * @param hibyte the high byte of each resulting Unicode character.
159
+ * @return the current contents of the output stream, as a string.
160
+ * @see java.io.ByteArrayOutputStream#size()
161
+ * @see java.io.ByteArrayOutputStream#toString(String)
162
+ * @see java.io.ByteArrayOutputStream#toString()
163
+ */
164
+ toString_number(hibyte: int): string;
165
+ /**
166
+ * Closing a <tt>ByteArrayOutputStream</tt> has no effect. The methods in
167
+ * this class can be called after the stream has been closed without
168
+ * generating an <tt>IOException</tt>.
169
+ * <p>
170
+ *
171
+ * @throws IOException
172
+ */
173
+ close(): void;
174
+ }
@@ -0,0 +1,7 @@
1
+ import CharacterSetECI from '../common/CharacterSetECI';
2
+ /**
3
+ * Just to make a shortcut between Java code and TS code.
4
+ */
5
+ export default class Charset extends CharacterSetECI {
6
+ static forName(name: string): Charset;
7
+ }
@@ -0,0 +1,11 @@
1
+ import { Collection, int } from '../../customTypings';
2
+ export default class Collections {
3
+ /**
4
+ * The singletonList(T) method is used to return an immutable list containing only the specified object.
5
+ */
6
+ static singletonList<T = any>(item: T): Collection<T>;
7
+ /**
8
+ * The min(Collection<? extends T>, Comparator<? super T>) method is used to return the minimum element of the given collection, according to the order induced by the specified comparator.
9
+ */
10
+ static min<T = any>(collection: Collection<T>, comparator: (a: T, b: T) => int): T;
11
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Ponyfill for Java's Float class.
3
+ */
4
+ export default class Float {
5
+ /**
6
+ * The float max value in JS is the number max value.
7
+ */
8
+ static MAX_VALUE: number;
9
+ /**
10
+ * SincTS has no difference between int and float, there's all numbers,
11
+ * this is used only to polyfill Java code.
12
+ */
13
+ static floatToIntBits(f: number): number;
14
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Java Formatter class polyfill that works in the JS way.
3
+ */
4
+ export default class Formatter {
5
+ /**
6
+ * The internal formatted value.
7
+ */
8
+ buffer: string;
9
+ constructor();
10
+ /**
11
+ *
12
+ * @see https://stackoverflow.com/a/13439711/4367683
13
+ *
14
+ * @param str
15
+ * @param arr
16
+ */
17
+ private static form;
18
+ /**
19
+ *
20
+ * @param append The new string to append.
21
+ * @param args Argumets values to be formated.
22
+ */
23
+ format(append: string, ...args: any): void;
24
+ /**
25
+ * Returns the Formatter string value.
26
+ */
27
+ toString(): string;
28
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Ponyfill for Java's Integer class.
3
+ */
4
+ export default class Integer {
5
+ static MIN_VALUE_32_BITS: number;
6
+ static MAX_VALUE: number;
7
+ static numberOfTrailingZeros(i: number): number;
8
+ static numberOfLeadingZeros(i: number): number;
9
+ static toHexString(i: number): string;
10
+ static toBinaryString(intNumber: number): string;
11
+ static bitCount(i: number): number;
12
+ static truncDivision(dividend: number, divisor: number): number;
13
+ /**
14
+ * Converts A string to an integer.
15
+ * @param s A string to convert into a number.
16
+ * @param radix A value between 2 and 36 that specifies the base of the number in numString. If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. All other strings are considered decimal.
17
+ */
18
+ static parseInt(num: string, radix?: number): number;
19
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Ponyfill for Java's Long class.
3
+ */
4
+ export default class Long {
5
+ /**
6
+ * Parses a string to a number, since JS has no really Int64.
7
+ *
8
+ * @param num Numeric string.
9
+ * @param radix Destination radix.
10
+ */
11
+ static parseLong(num: string, radix?: number | undefined): number;
12
+ }
@@ -0,0 +1,106 @@
1
+ /**
2
+ * This abstract class is the superclass of all classes representing
3
+ * an output stream of bytes. An output stream accepts output bytes
4
+ * and sends them to some sink.
5
+ * <p>
6
+ * Applications that need to define a subclass of
7
+ * <code>OutputStream</code> must always provide at least a method
8
+ * that writes one byte of output.
9
+ *
10
+ * @author Arthur van Hoff
11
+ * @see java.io.BufferedOutputStream
12
+ * @see java.io.ByteArrayOutputStream
13
+ * @see java.io.DataOutputStream
14
+ * @see java.io.FilterOutputStream
15
+ * @see java.io.InputStream
16
+ * @see java.io.OutputStream#write(int)
17
+ * @since JDK1.0
18
+ */
19
+ export default abstract class OutputStream {
20
+ /**
21
+ * Writes the specified byte to this output stream. The general
22
+ * contract for <code>write</code> is that one byte is written
23
+ * to the output stream. The byte to be written is the eight
24
+ * low-order bits of the argument <code>b</code>. The 24
25
+ * high-order bits of <code>b</code> are ignored.
26
+ * <p>
27
+ * Subclasses of <code>OutputStream</code> must provide an
28
+ * implementation for this method.
29
+ *
30
+ * @param b the <code>byte</code>.
31
+ * @exception IOException if an I/O error occurs. In particular,
32
+ * an <code>IOException</code> may be thrown if the
33
+ * output stream has been closed.
34
+ */
35
+ abstract write(b: number): void;
36
+ /**
37
+ * Writes <code>b.length</code> bytes from the specified byte array
38
+ * to this output stream. The general contract for <code>write(b)</code>
39
+ * is that it should have exactly the same effect as the call
40
+ * <code>write(b, 0, b.length)</code>.
41
+ *
42
+ * @param b the data.
43
+ * @exception IOException if an I/O error occurs.
44
+ * @see java.io.OutputStream#write(byte[], int, int)
45
+ */
46
+ writeBytes(b: Uint8Array): void;
47
+ /**
48
+ * Writes <code>len</code> bytes from the specified byte array
49
+ * starting at offset <code>off</code> to this output stream.
50
+ * The general contract for <code>write(b, off, len)</code> is that
51
+ * some of the bytes in the array <code>b</code> are written to the
52
+ * output stream in order; element <code>b[off]</code> is the first
53
+ * byte written and <code>b[off+len-1]</code> is the last byte written
54
+ * by this operation.
55
+ * <p>
56
+ * The <code>write</code> method of <code>OutputStream</code> calls
57
+ * the write method of one argument on each of the bytes to be
58
+ * written out. Subclasses are encouraged to override this method and
59
+ * provide a more efficient implementation.
60
+ * <p>
61
+ * If <code>b</code> is <code>null</code>, a
62
+ * <code>NullPointerException</code> is thrown.
63
+ * <p>
64
+ * If <code>off</code> is negative, or <code>len</code> is negative, or
65
+ * <code>off+len</code> is greater than the length of the array
66
+ * <code>b</code>, then an <tt>IndexOutOfBoundsException</tt> is thrown.
67
+ *
68
+ * @param b the data.
69
+ * @param off the start offset in the data.
70
+ * @param len the number of bytes to write.
71
+ * @exception IOException if an I/O error occurs. In particular,
72
+ * an <code>IOException</code> is thrown if the output
73
+ * stream is closed.
74
+ */
75
+ writeBytesOffset(b: Uint8Array, off: number, len: number): void;
76
+ /**
77
+ * Flushes this output stream and forces any buffered output bytes
78
+ * to be written out. The general contract of <code>flush</code> is
79
+ * that calling it is an indication that, if any bytes previously
80
+ * written have been buffered by the implementation of the output
81
+ * stream, such bytes should immediately be written to their
82
+ * intended destination.
83
+ * <p>
84
+ * If the intended destination of this stream is an abstraction provided by
85
+ * the underlying operating system, for example a file, then flushing the
86
+ * stream guarantees only that bytes previously written to the stream are
87
+ * passed to the operating system for writing; it does not guarantee that
88
+ * they are actually written to a physical device such as a disk drive.
89
+ * <p>
90
+ * The <code>flush</code> method of <code>OutputStream</code> does nothing.
91
+ *
92
+ * @exception IOException if an I/O error occurs.
93
+ */
94
+ flush(): void;
95
+ /**
96
+ * Closes this output stream and releases any system resources
97
+ * associated with this stream. The general contract of <code>close</code>
98
+ * is that it closes the output stream. A closed stream cannot perform
99
+ * output operations and cannot be reopened.
100
+ * <p>
101
+ * The <code>close</code> method of <code>OutputStream</code> does nothing.
102
+ *
103
+ * @exception IOException if an I/O error occurs.
104
+ */
105
+ close(): void;
106
+ }
@@ -0,0 +1,7 @@
1
+ import CharacterSetECI from '../common/CharacterSetECI';
2
+ /**
3
+ * Just to make a shortcut between Java code and TS code.
4
+ */
5
+ export default class StandardCharsets {
6
+ static ISO_8859_1: CharacterSetECI;
7
+ }
@@ -0,0 +1,21 @@
1
+ import { char, int } from '../../customTypings';
2
+ import CharacterSetECI from '../common/CharacterSetECI';
3
+ export default class StringBuilder {
4
+ private value;
5
+ private encoding?;
6
+ constructor(value?: string);
7
+ enableDecoding(encoding: CharacterSetECI): StringBuilder;
8
+ append(s: string | number): StringBuilder;
9
+ appendChars(str: char[] | string[], offset: int, len: int): StringBuilder;
10
+ length(): number;
11
+ charAt(n: number): string;
12
+ deleteCharAt(n: number): void;
13
+ setCharAt(n: number, c: string): void;
14
+ substring(start: int, end: int): string;
15
+ /**
16
+ * @note helper method for RSS Expanded
17
+ */
18
+ setLengthToZero(): void;
19
+ toString(): string;
20
+ insert(n: number, c: string): void;
21
+ }
@@ -0,0 +1,51 @@
1
+ import CharacterSetECI from '../common/CharacterSetECI';
2
+ /**
3
+ * Responsible for en/decoding strings.
4
+ */
5
+ export default class StringEncoding {
6
+ /**
7
+ * Allows the user to set a custom decoding function
8
+ * so more encoding formats the native ones can be supported.
9
+ */
10
+ static customDecoder: (bytes: Uint8Array, encodingName: string) => string;
11
+ /**
12
+ * Allows the user to set a custom encoding function
13
+ * so more encoding formats the native ones can be supported.
14
+ */
15
+ static customEncoder: (s: string, encodingName: string) => Uint8Array;
16
+ /**
17
+ * Decodes some Uint8Array to a string format.
18
+ */
19
+ static decode(bytes: Uint8Array, encoding: string | CharacterSetECI): string;
20
+ /**
21
+ * Checks if the decoding method should use the fallback for decoding
22
+ * once Node TextDecoder doesn't support all encoding formats.
23
+ *
24
+ * @param encodingName
25
+ */
26
+ private static shouldDecodeOnFallback;
27
+ /**
28
+ * Encodes some string into a Uint8Array.
29
+ */
30
+ static encode(s: string, encoding: string | CharacterSetECI): Uint8Array;
31
+ private static isBrowser;
32
+ /**
33
+ * Returns the string value from some encoding character set.
34
+ */
35
+ static encodingName(encoding: string | CharacterSetECI): string;
36
+ /**
37
+ * Returns character set from some encoding character set.
38
+ */
39
+ static encodingCharacterSet(encoding: string | CharacterSetECI): CharacterSetECI;
40
+ /**
41
+ * Runs a fallback for the native decoding funcion.
42
+ */
43
+ private static decodeFallback;
44
+ private static isDecodeFallbackSupported;
45
+ /**
46
+ * Runs a fallback for the native encoding funcion.
47
+ *
48
+ * @see https://stackoverflow.com/a/17192845/4367683
49
+ */
50
+ private static encodeFallback;
51
+ }
@@ -0,0 +1,10 @@
1
+ export default class System {
2
+ /**
3
+ * Makes a copy of a array.
4
+ */
5
+ static arraycopy(src: any, srcPos: number, dest: any, destPos: number, length: number): void;
6
+ /**
7
+ * Returns the current time in milliseconds.
8
+ */
9
+ static currentTimeMillis(): number;
10
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * This file contains some types to make our
3
+ * lifes easier when copy and pasting Java code.
4
+ * With it we can keep int, float, etc., references
5
+ * in code to keep as close as possible as the Java version
6
+ * but without the need to sacrifice ourselves with boring
7
+ * and annoying things.
8
+ */
9
+ export declare type byte = number;
10
+ export declare type short = number;
11
+ export declare type int = number;
12
+ export declare type float = number;
13
+ export type char = number;
14
+ export type List<T> = T[];
15
+ export type Collection<T> = T[];
16
+ export type Deque<T> = T[];
@@ -0,0 +1,5 @@
1
+ export * from './browser';
2
+ export { default as BinaryBitmap } from './core/BinaryBitmap';
3
+ export { default as InvertedLuminanceSource } from './core/InvertedLuminanceSource';
4
+ export { default as LuminanceSource } from './core/LuminanceSource';
5
+ export { default as HybridBinarizer } from './core/common/HybridBinarizer';
@@ -0,0 +1 @@
1
+ export { NodeLuminanceSource } from './core/NodeLuminanceSource';