qr 0.5.4 โ†’ 0.6.0

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.
package/README.md CHANGED
@@ -3,11 +3,11 @@
3
3
  Minimal 0-dependency QR code generator & reader.
4
4
 
5
5
  - ๐Ÿ”’ Auditable, 0-dependency
6
+ - ๐ŸŽ [Fast](#speed): aims to be faster than all JS implementations
7
+ - ๐Ÿ” Reliable: 100MB+ of extensive test vectors ensure correctness
6
8
  - ๐Ÿž๏ธ Encoding (generating) supports ASCII, term, gif, svg and png codes
7
9
  - ๐Ÿ“ท Decoding (reading) supports camera feed input, files and non-browser environments
8
- - ๐ŸŽ Fast: faster than all JS implementations
9
- - ๐Ÿ” Extensive tests ensure correctness: 100MB+ of vectors
10
- - ๐Ÿชถ 16KB (gzipped) for encoding + decoding, 9KB for encoding
10
+ - ๐Ÿชถ 18KB (gzipped) for encoding + decoding, 9KB for encoding
11
11
 
12
12
  Check out:
13
13
 
@@ -76,25 +76,30 @@ const larger = encodeQR(txt, 'gif', { scale: 4 });
76
76
  // };
77
77
 
78
78
  console.log(ascii);
79
- > โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
80
- > โ–ˆโ–ˆ โ–„โ–„โ–„โ–„โ–„ โ–ˆ โ–€โ–„โ–„โ–ˆ โ–ˆโ–ˆโ–€โ–„โ–„โ–„โ–„โ–ˆ โ–€โ–ˆ โ–„โ–„โ–„โ–„โ–„ โ–ˆโ–ˆ
81
- > โ–ˆโ–ˆ โ–ˆ โ–ˆ โ–ˆโ–€โ–„โ–€โ–„ โ–„โ–„โ–ˆโ–„โ–ˆ โ–ˆโ–ˆโ–€โ–ˆโ–€โ–€โ–ˆ โ–ˆ โ–ˆ โ–ˆโ–ˆ
82
- > โ–ˆโ–ˆ โ–ˆโ–„โ–„โ–„โ–ˆ โ–ˆโ–ˆ โ–„โ–„โ–ˆโ–„โ–€โ–€ โ–€ โ–ˆโ–ˆ โ–„ โ–„โ–ˆ โ–ˆโ–„โ–„โ–„โ–ˆ โ–ˆโ–ˆ
83
- > โ–ˆโ–ˆโ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–ˆ โ–€ โ–€ โ–ˆโ–„โ–€ โ–€ โ–€โ–„โ–ˆ โ–ˆ โ–ˆโ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–ˆโ–ˆ
84
- > โ–ˆโ–ˆ โ–ˆ โ–€ โ–„โ–„โ–€โ–€โ–€ โ–ˆโ–€ โ–„ โ–€โ–€โ–„โ–€ โ–„โ–ˆ โ–€โ–ˆ โ–€โ–„โ–„โ–ˆโ–ˆ
85
- > โ–ˆโ–ˆโ–€โ–€โ–€ โ–€โ–„โ–„โ–ˆโ–ˆโ–„โ–€โ–€โ–„โ–ˆโ–€ โ–€โ–„โ–ˆ โ–€โ–€โ–€ โ–„ โ–ˆโ–„โ–„โ–ˆโ–ˆ
86
- > โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–„โ–€โ–€โ–„โ–„โ–ˆโ–ˆ โ–€ โ–€ โ–„โ–„โ–ˆโ–ˆโ–„ โ–„โ–„ โ–„ โ–ˆโ–€โ–ˆ โ–ˆ โ–ˆโ–ˆโ–ˆ
87
- > โ–ˆโ–ˆโ–ˆ โ–„โ–€โ–„โ–ˆโ–„โ–„โ–„โ–ˆ โ–€โ–ˆโ–ˆโ–„โ–„โ–„โ–€โ–€โ–ˆโ–„โ–€ โ–„โ–ˆโ–€ โ–ˆโ–ˆโ–ˆโ–ˆ
88
- > โ–ˆโ–ˆโ–€โ–€ โ–„ โ–€โ–„ โ–„โ–„โ–ˆโ–ˆโ–€โ–„โ–€โ–€โ–ˆโ–ˆโ–ˆโ–ˆโ–„โ–„โ–„ โ–ˆโ–„ โ–ˆ โ–ˆโ–€โ–€โ–ˆโ–ˆ
89
- > โ–ˆโ–ˆโ–€โ–€โ–„ โ–„โ–€โ–„ โ–€โ–€โ–ˆโ–„โ–€โ–€โ–„โ–„โ–€โ–€ โ–ˆโ–„โ–„โ–€โ–ˆโ–€ โ–€โ–„ โ–ˆโ–„ โ–€โ–ˆโ–ˆ
90
- > โ–ˆโ–ˆโ–€โ–„โ–€โ–ˆโ–ˆ โ–„โ–„ โ–€โ–ˆโ–„โ–ˆโ–€ โ–€ โ–€โ–ˆโ–„โ–€โ–€ โ–ˆโ–„โ–€โ–€ โ–ˆ โ–ˆ โ–ˆโ–ˆ
91
- > โ–ˆโ–ˆโ–ˆโ–€โ–ˆโ–„โ–€โ–„โ–„ โ–ˆ โ–ˆ โ–ˆโ–ˆ โ–ˆโ–ˆ โ–„ โ–ˆ โ–„โ–„โ–„ โ–„โ–€โ–€โ–„โ–„ โ–ˆโ–ˆ
92
- > โ–ˆโ–ˆโ–„โ–ˆโ–„โ–„โ–„โ–ˆโ–„โ–ˆ โ–„ โ–„โ–€โ–ˆโ–€โ–€ โ–„โ–€ โ–ˆโ–€ โ–„ โ–„โ–„โ–„ โ–€โ–„โ–€โ–„โ–ˆโ–ˆ
93
- > โ–ˆโ–ˆ โ–„โ–„โ–„โ–„โ–„ โ–ˆ โ–„โ–ˆโ–„โ–€โ–€ โ–€โ–ˆ โ–ˆโ–„โ–ˆ โ–ˆโ–„โ–ˆ โ–€โ–€โ–„โ–€โ–ˆโ–ˆ
94
- > โ–ˆโ–ˆ โ–ˆ โ–ˆ โ–ˆโ–€ โ–„โ–€โ–ˆ โ–ˆโ–ˆ โ–„โ–„โ–€โ–ˆโ–ˆ โ–„โ–„ โ–„โ–ˆ โ–ˆโ–ˆ
95
- > โ–ˆโ–ˆ โ–ˆโ–„โ–„โ–„โ–ˆ โ–ˆโ–„ โ–ˆโ–ˆโ–€ โ–„โ–„ โ–€โ–ˆ โ–„ โ–€โ–„โ–„โ–ˆโ–€โ–ˆโ–ˆ
96
- > โ–ˆโ–ˆโ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–ˆโ–„โ–ˆโ–ˆโ–ˆโ–„โ–ˆโ–„โ–ˆโ–„โ–„โ–„โ–„โ–ˆโ–„โ–ˆโ–„โ–ˆโ–ˆโ–ˆโ–ˆโ–„โ–„โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
97
- > โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€
79
+ ```
80
+
81
+ Example output:
82
+
83
+ ```text
84
+ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
85
+ โ–ˆโ–ˆ โ–„โ–„โ–„โ–„โ–„ โ–ˆ โ–€โ–„โ–„โ–ˆ โ–ˆโ–ˆโ–€โ–„โ–„โ–„โ–„โ–ˆ โ–€โ–ˆ โ–„โ–„โ–„โ–„โ–„ โ–ˆโ–ˆ
86
+ โ–ˆโ–ˆ โ–ˆ โ–ˆ โ–ˆโ–€โ–„โ–€โ–„ โ–„โ–„โ–ˆโ–„โ–ˆ โ–ˆโ–ˆโ–€โ–ˆโ–€โ–€โ–ˆ โ–ˆ โ–ˆ โ–ˆโ–ˆ
87
+ โ–ˆโ–ˆ โ–ˆโ–„โ–„โ–„โ–ˆ โ–ˆโ–ˆ โ–„โ–„โ–ˆโ–„โ–€โ–€ โ–€ โ–ˆโ–ˆ โ–„ โ–„โ–ˆ โ–ˆโ–„โ–„โ–„โ–ˆ โ–ˆโ–ˆ
88
+ โ–ˆโ–ˆโ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–ˆ โ–€ โ–€ โ–ˆโ–„โ–€ โ–€ โ–€โ–„โ–ˆ โ–ˆ โ–ˆโ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–ˆโ–ˆ
89
+ โ–ˆโ–ˆ โ–ˆ โ–€ โ–„โ–„โ–€โ–€โ–€ โ–ˆโ–€ โ–„ โ–€โ–€โ–„โ–€ โ–„โ–ˆ โ–€โ–ˆ โ–€โ–„โ–„โ–ˆโ–ˆ
90
+ โ–ˆโ–ˆโ–€โ–€โ–€ โ–€โ–„โ–„โ–ˆโ–ˆโ–„โ–€โ–€โ–„โ–ˆโ–€ โ–€โ–„โ–ˆ โ–€โ–€โ–€ โ–„ โ–ˆโ–„โ–„โ–ˆโ–ˆ
91
+ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–„โ–€โ–€โ–„โ–„โ–ˆโ–ˆ โ–€ โ–€ โ–„โ–„โ–ˆโ–ˆโ–„ โ–„โ–„ โ–„ โ–ˆโ–€โ–ˆ โ–ˆ โ–ˆโ–ˆโ–ˆ
92
+ โ–ˆโ–ˆโ–ˆ โ–„โ–€โ–„โ–ˆโ–„โ–„โ–„โ–ˆ โ–€โ–ˆโ–ˆโ–„โ–„โ–„โ–€โ–€โ–ˆโ–„โ–€ โ–„โ–ˆโ–€ โ–ˆโ–ˆโ–ˆโ–ˆ
93
+ โ–ˆโ–ˆโ–€โ–€ โ–„ โ–€โ–„ โ–„โ–„โ–ˆโ–ˆโ–€โ–„โ–€โ–€โ–ˆโ–ˆโ–ˆโ–ˆโ–„โ–„โ–„ โ–ˆโ–„ โ–ˆ โ–ˆโ–€โ–€โ–ˆโ–ˆ
94
+ โ–ˆโ–ˆโ–€โ–€โ–„ โ–„โ–€โ–„ โ–€โ–€โ–ˆโ–„โ–€โ–€โ–„โ–„โ–€โ–€ โ–ˆโ–„โ–„โ–€โ–ˆโ–€ โ–€โ–„ โ–ˆโ–„ โ–€โ–ˆโ–ˆ
95
+ โ–ˆโ–ˆโ–€โ–„โ–€โ–ˆโ–ˆ โ–„โ–„ โ–€โ–ˆโ–„โ–ˆโ–€ โ–€ โ–€โ–ˆโ–„โ–€โ–€ โ–ˆโ–„โ–€โ–€ โ–ˆ โ–ˆ โ–ˆโ–ˆ
96
+ โ–ˆโ–ˆโ–ˆโ–€โ–ˆโ–„โ–€โ–„โ–„ โ–ˆ โ–ˆ โ–ˆโ–ˆ โ–ˆโ–ˆ โ–„ โ–ˆ โ–„โ–„โ–„ โ–„โ–€โ–€โ–„โ–„ โ–ˆโ–ˆ
97
+ โ–ˆโ–ˆโ–„โ–ˆโ–„โ–„โ–„โ–ˆโ–„โ–ˆ โ–„ โ–„โ–€โ–ˆโ–€โ–€ โ–„โ–€ โ–ˆโ–€ โ–„ โ–„โ–„โ–„ โ–€โ–„โ–€โ–„โ–ˆโ–ˆ
98
+ โ–ˆโ–ˆ โ–„โ–„โ–„โ–„โ–„ โ–ˆ โ–„โ–ˆโ–„โ–€โ–€ โ–€โ–ˆ โ–ˆโ–„โ–ˆ โ–ˆโ–„โ–ˆ โ–€โ–€โ–„โ–€โ–ˆโ–ˆ
99
+ โ–ˆโ–ˆ โ–ˆ โ–ˆ โ–ˆโ–€ โ–„โ–€โ–ˆ โ–ˆโ–ˆ โ–„โ–„โ–€โ–ˆโ–ˆ โ–„โ–„ โ–„โ–ˆ โ–ˆโ–ˆ
100
+ โ–ˆโ–ˆ โ–ˆโ–„โ–„โ–„โ–ˆ โ–ˆโ–„ โ–ˆโ–ˆโ–€ โ–„โ–„ โ–€โ–ˆ โ–„ โ–€โ–„โ–„โ–ˆโ–€โ–ˆโ–ˆ
101
+ โ–ˆโ–ˆโ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–ˆโ–„โ–ˆโ–ˆโ–ˆโ–„โ–ˆโ–„โ–ˆโ–„โ–„โ–„โ–„โ–ˆโ–„โ–ˆโ–„โ–ˆโ–ˆโ–ˆโ–ˆโ–„โ–„โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
102
+ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€
98
103
  ```
99
104
 
100
105
  ## Decoding
@@ -143,21 +148,23 @@ function decodeWithExternal() {
143
148
  ### Decoding options
144
149
 
145
150
  ```ts
146
- export type Point4 = { x: number; y: number }[];
147
- export type Image = {
151
+ type Point = { x: number; y: number };
152
+ type Pattern = Point & { moduleSize: number; count: number };
153
+ type FinderPoints = [Pattern, Pattern, Point, Pattern];
154
+ type Image = {
148
155
  height: number;
149
156
  width: number;
150
157
  data: Uint8Array | Uint8ClampedArray | number[];
151
158
  };
152
- export type DecodeOpts = {
153
- // By default we assume that image has 4 channel per pixel (RGBA). isRGB: true will force to use only one
154
- isRGB?: boolean;
155
- // Returns 4 center (3 finder pattern + 1 alignment pattern) points if detected
156
- detectFn?: (points: Point4) => void;
157
- // Returns RGBA image of detected QR code
158
- qrFn?: (img: Image) => void;
159
+ type DecodeOpts = {
160
+ cropToSquare?: boolean;
161
+ textDecoder?: (bytes: Uint8Array) => string;
162
+ pointsOnDetect?: (points: FinderPoints) => void;
163
+ imageOnBitmap?: (img: Image) => void;
164
+ imageOnDetect?: (img: Image) => void;
165
+ imageOnResult?: (img: Image) => void;
159
166
  };
160
- export default function decodeQR(img: Image, opts: DecodeOpts = {});
167
+ declare function decodeQR(img: Image, opts?: DecodeOpts): string;
161
168
  ```
162
169
 
163
170
  ### Decoding algorithm
@@ -248,14 +255,14 @@ qrcode-generator x 2,909 ops/sec @ 343ฮผs/op
248
255
  nuintun x 3,470 ops/sec @ 288ฮผs/op
249
256
 
250
257
  # encode of large qr
251
- @paulmillr/qr x 318 ops/sec @ 3ms/op
258
+ @paulmillr/qr x 334 ops/sec @ 2ms/op
252
259
  qrcode-generator x 174 ops/sec @ 5ms/op
253
260
  nuintun x 221 ops/sec @ 4ms/op
254
261
 
255
262
  # decode
256
- @paulmillr/qr x 162 ops/sec @ 6ms/op ยฑ 3.78% (5ms..16ms)
257
- jsqr x 50 ops/sec @ 19ms/op ยฑ 5.44% (18ms..35ms)
258
- nuintun x 49 ops/sec @ 20ms/op ยฑ 5.08% (18ms..36ms)
263
+ @paulmillr/qr x 662 ops/sec @ 1ms/op
264
+ jsqr x 50 ops/sec @ 19ms/op
265
+ nuintun x 49 ops/sec @ 20ms/op
259
266
  instascan x 128 ops/sec @ 7ms/op ยฑ 31.44% (4ms..166ms)
260
267
  ```
261
268
 
package/decode.d.ts CHANGED
@@ -17,43 +17,130 @@ limitations under the License.
17
17
  /**
18
18
  * Methods for decoding (reading) QR code patterns.
19
19
  * @module
20
- * @example
21
- ```js
22
-
23
- ```
24
20
  */
25
- import type { Image, Point } from './index.ts';
21
+ import type { Image, Point, TArg, TRet } from './index.ts';
26
22
  import { Bitmap } from './index.ts';
23
+ type Point4 = [Point, Point, Point, Point];
24
+ /** Finder and alignment points returned by the detector. */
27
25
  export type FinderPoints = [Pattern, Pattern, Point, Pattern];
28
26
  /**
29
27
  * Convert to grayscale. The function is the most expensive part of decoding:
30
- * it takes up to 90% of time. TODO: check gamma correction / sqr.
28
+ * it takes up to 90% of time.
29
+ *
30
+ * Binarization pipeline:
31
+ * 1. Convert RGB/RGBA image to one luma byte per pixel.
32
+ * 2. Split the image into 8x8 blocks and collect per-block mean/min/max.
33
+ * 3. Build a 5x5 neighborhood mean over those block means.
34
+ * 4. Turn each 8x8 block into bitmap bits using a local cut derived from:
35
+ * - the neighborhood mean,
36
+ * - the current block statistics,
37
+ * - a cheap whole-image color-spread estimate,
38
+ * - and, on risky scenes, a local variance field over block means.
39
+ *
40
+ * Instead of producing "best looking" thresholding: we produce a
41
+ * bitmap where finder patterns survive perspective / blur / highlights while
42
+ * keeping false dark regions low enough for downstream finder selection.
31
43
  */
32
- declare function toBitmap(img: Image): Bitmap;
44
+ declare function toBitmap(img: TArg<Image>): TRet<Bitmap>;
33
45
  type Pattern = Point & {
34
46
  moduleSize: number;
35
47
  count: number;
36
48
  };
37
- declare function findFinder(b: Bitmap): {
49
+ declare function findFinder(b: TArg<Bitmap>): {
38
50
  bl: Pattern;
39
51
  tl: Pattern;
40
52
  tr: Pattern;
41
53
  };
42
- declare function detect(b: Bitmap): {
54
+ declare function findAlignment(b: TArg<Bitmap>, est: Pattern, allowanceFactor: number): Pattern;
55
+ declare function detect(b: TArg<Bitmap>): TRet<{
43
56
  bits: Bitmap;
44
57
  points: FinderPoints;
45
- };
46
- declare function decodeBitmap(b: Bitmap, decoder?: (bytes: Uint8Array, eci: number) => string): string;
58
+ }>;
59
+ declare function transform(b: TArg<Bitmap>, size: number, from: Point4, to: Point4): TRet<Bitmap>;
60
+ declare function decodeBitmap(b: TArg<Bitmap>, decoder?: TArg<(bytes: Uint8Array, eci: number) => string>): string;
61
+ /** QR decoding hooks and image preprocessing options. */
47
62
  export type DecodeOpts = {
63
+ /** Crop rectangular inputs to a centered square before decoding. */
48
64
  cropToSquare?: boolean;
49
- textDecoder?: (bytes: Uint8Array) => string;
65
+ /**
66
+ * Custom byte-to-text decoder used for byte segments.
67
+ *
68
+ * Receives the byte segment and, when needed, the active ECI designator.
69
+ * ISO/IEC 18004:2024 ยง7.4.3.4 keeps ECIs active "until the end of
70
+ * the encoded data or a change of ECI", so callers need the active
71
+ * designator to apply their own charset policy.
72
+ * @param bytes - Byte segment payload to decode.
73
+ * @param eci - Active ECI designator for the byte segment.
74
+ * @returns Decoded text for the byte segment.
75
+ */
76
+ textDecoder?: TArg<(bytes: Uint8Array, eci?: number) => string>;
77
+ /**
78
+ * Callback invoked with finder/alignment points after detection succeeds.
79
+ *
80
+ * Receives finder and alignment points returned by the detector.
81
+ * @param points - Finder and alignment points returned by the detector.
82
+ */
50
83
  pointsOnDetect?: (points: FinderPoints) => void;
84
+ /**
85
+ * Callback invoked with the grayscale bitmap that the detector sees.
86
+ *
87
+ * Receives the grayscale image generated during bitmap conversion.
88
+ * @param img - Grayscale image generated during bitmap conversion.
89
+ */
51
90
  imageOnBitmap?: (img: Image) => void;
91
+ /**
92
+ * Callback invoked with the perspective-corrected QR image.
93
+ *
94
+ * Receives the perspective-corrected QR image.
95
+ * @param img - Perspective-corrected QR image.
96
+ */
52
97
  imageOnDetect?: (img: Image) => void;
98
+ /**
99
+ * Callback invoked with the final decoded QR image.
100
+ *
101
+ * Receives the final QR image used to decode the payload.
102
+ * @param img - Final QR image used to decode the payload.
103
+ */
53
104
  imageOnResult?: (img: Image) => void;
54
105
  };
55
- export declare function decodeQR(img: Image, opts?: DecodeOpts): string;
106
+ /**
107
+ * Decode text from a QR image.
108
+ * @param img - RGB or RGBA image data that contains a QR code.
109
+ * @param opts - Decoder hooks and image preprocessing options. See {@link DecodeOpts}.
110
+ * @returns Decoded QR payload as a string.
111
+ * @throws If the image, decoder options, or QR contents are invalid. {@link Error}
112
+ * @example
113
+ * Decode text from a QR image.
114
+ * ```ts
115
+ * import encodeQR, { Bitmap } from 'qr';
116
+ * import decodeQR from 'qr/decode.js';
117
+ * const bits = encodeQR('Hello world', 'raw', { scale: 4 });
118
+ * const bm = new Bitmap({ width: bits[0].length, height: bits.length }, bits);
119
+ * const text = decodeQR(bm.toImage());
120
+ * ```
121
+ */
122
+ export declare function decodeQR(img: TArg<Image>, opts?: TArg<DecodeOpts>): string;
123
+ /**
124
+ * Default export alias for {@link decodeQR}.
125
+ * @param img - RGB or RGBA image data that contains a QR code.
126
+ * @param opts - Decoder hooks and image preprocessing options. See {@link DecodeOpts}.
127
+ * @returns Decoded QR payload as a string.
128
+ * @throws If the image, decoder options, or QR contents are invalid. {@link Error}
129
+ * @example
130
+ * Decode a rendered QR image via the default decoder export.
131
+ * ```ts
132
+ * import encodeQR, { Bitmap } from 'qr';
133
+ * import decodeQR from 'qr/decode.js';
134
+ * const bits = encodeQR('Hello world', 'raw', { scale: 4 });
135
+ * const bm = new Bitmap({ width: bits[0].length, height: bits.length }, bits);
136
+ * decodeQR(bm.toImage());
137
+ * ```
138
+ */
56
139
  export default decodeQR;
140
+ export declare const _TESTS: {
141
+ findAlignment: typeof findAlignment;
142
+ transform: typeof transform;
143
+ };
57
144
  export declare const _tests: {
58
145
  toBitmap: typeof toBitmap;
59
146
  decodeBitmap: typeof decodeBitmap;
package/decode.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["src/decode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;EAeE;AACF;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAiC,KAAK,EAAQ,KAAK,EAAE,MAAM,YAAY,CAAC;AACpF,OAAO,EAAE,MAAM,EAAS,MAAM,YAAY,CAAC;AAiB3C,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AA2B9D;;;GAGG;AACH,iBAAS,QAAQ,CAAC,GAAG,EAAE,KAAK,GAAG,MAAM,CAwEpC;AAGD,KAAK,OAAO,GAAG,KAAK,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AA6I7D,iBAAS,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG;IAC9B,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;CACb,CA8HA;AAoHD,iBAAS,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,CAAC;CACtB,CA6DA;AAqLD,iBAAS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