qreator 9.0.6
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/LICENSE +20 -0
- package/README.md +92 -0
- package/lib/browser/encode.d.ts +2 -0
- package/lib/browser/errorcode.d.ts +1 -0
- package/lib/browser/matrix.d.ts +9 -0
- package/lib/browser/pdf.d.ts +2 -0
- package/lib/browser/pdf.umd.js +26816 -0
- package/lib/browser/pdf.umd.js.map +1 -0
- package/lib/browser/png.d.ts +6 -0
- package/lib/browser/png.umd.js +1540 -0
- package/lib/browser/png.umd.js.map +1 -0
- package/lib/browser/png_browser.d.ts +5 -0
- package/lib/browser/qr-base.d.ts +4 -0
- package/lib/browser/qr.d.ts +2 -0
- package/lib/browser/svg.d.ts +7 -0
- package/lib/browser/svg.umd.js +1536 -0
- package/lib/browser/svg.umd.js.map +1 -0
- package/lib/browser/tests/_common.d.ts +4 -0
- package/lib/browser/tests/browser.test.d.ts +1 -0
- package/lib/browser/tests/test.d.ts +1 -0
- package/lib/browser/typing/types.d.ts +28 -0
- package/lib/browser/utils.d.ts +17 -0
- package/lib/encode.d.ts +2 -0
- package/lib/encode.js +137 -0
- package/lib/encode.js.map +1 -0
- package/lib/errorcode.d.ts +1 -0
- package/lib/errorcode.js +62 -0
- package/lib/errorcode.js.map +1 -0
- package/lib/matrix.d.ts +9 -0
- package/lib/matrix.js +347 -0
- package/lib/matrix.js.map +1 -0
- package/lib/pdf.d.ts +2 -0
- package/lib/pdf.js +64 -0
- package/lib/pdf.js.map +1 -0
- package/lib/png.d.ts +6 -0
- package/lib/png.js +30 -0
- package/lib/png.js.map +1 -0
- package/lib/png_browser.d.ts +5 -0
- package/lib/png_browser.js +53 -0
- package/lib/png_browser.js.map +1 -0
- package/lib/qr-base.d.ts +4 -0
- package/lib/qr-base.js +151 -0
- package/lib/qr-base.js.map +1 -0
- package/lib/qr.d.ts +2 -0
- package/lib/qr.js +2 -0
- package/lib/qr.js.map +1 -0
- package/lib/svg.d.ts +7 -0
- package/lib/svg.js +49 -0
- package/lib/svg.js.map +1 -0
- package/lib/tests/_common.d.ts +4 -0
- package/lib/tests/_common.js +36 -0
- package/lib/tests/_common.js.map +1 -0
- package/lib/tests/browser.test.d.ts +1 -0
- package/lib/tests/browser.test.js +193 -0
- package/lib/tests/browser.test.js.map +1 -0
- package/lib/tests/test.d.ts +1 -0
- package/lib/tests/test.js +238 -0
- package/lib/tests/test.js.map +1 -0
- package/lib/typing/types.d.ts +28 -0
- package/lib/typing/types.js +2 -0
- package/lib/typing/types.js.map +1 -0
- package/lib/utils.d.ts +17 -0
- package/lib/utils.js +68 -0
- package/lib/utils.js.map +1 -0
- package/package.json +105 -0
- package/src/encode.ts +176 -0
- package/src/errorcode.ts +75 -0
- package/src/matrix.ts +393 -0
- package/src/pdf.ts +80 -0
- package/src/png.ts +42 -0
- package/src/png_browser.ts +73 -0
- package/src/qr-base.ts +180 -0
- package/src/qr.ts +2 -0
- package/src/svg.ts +89 -0
- package/src/tests/_common.ts +40 -0
- package/src/tests/browser.test.ts +209 -0
- package/src/tests/test.ts +250 -0
- package/src/typing/index.d.ts +5 -0
- package/src/typing/types.ts +99 -0
- package/src/utils.ts +86 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2023 Short.cm inc
|
|
2
|
+
Copyright (c) 2013 Yandex LLC
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
|
12
|
+
all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# qreator
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/qreator)
|
|
4
|
+
|
|
5
|
+
QR Code generator for browser and node.js with tree shaking and logo support
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
- generate image in `png`, `svg` and `pdf` formats
|
|
12
|
+
- numeric and alphanumeric modes
|
|
13
|
+
- support UTF-8
|
|
14
|
+
- supports color customization
|
|
15
|
+
- supports logos
|
|
16
|
+
- tree shaking support
|
|
17
|
+
- browser / node.js
|
|
18
|
+
|
|
19
|
+
[Releases](https://github.com/Short-io/qreator/releases)
|
|
20
|
+
|
|
21
|
+
## Installing
|
|
22
|
+
|
|
23
|
+
```shell
|
|
24
|
+
npm install qreator
|
|
25
|
+
# or
|
|
26
|
+
yarn add qreator
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
Example:
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
import { getSVG } from "qreator/lib/svg";
|
|
35
|
+
import { getPNG } from "qreator/lib/png"; // imports canvas implementation in browser and sharp module in node.js
|
|
36
|
+
import { getPDF } from "qreator/lib/pdf"; // this import is large, consider async import
|
|
37
|
+
const svgString = await getSVG("I love QR", {
|
|
38
|
+
logo: fs.openFileSync("my-logo.svg"),
|
|
39
|
+
color: "#000000",
|
|
40
|
+
bgColor: "#FFFFFF",
|
|
41
|
+
});
|
|
42
|
+
const pngBuffer = await getPNG("I love QR", {
|
|
43
|
+
logo: fs.openFileSync("my-logo.svg"),
|
|
44
|
+
color: "rgb(0, 0, 0)",
|
|
45
|
+
bgColor: "rgb(255, 255, 255)",
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
[More examples](./examples)
|
|
50
|
+
|
|
51
|
+
### Syntax
|
|
52
|
+
|
|
53
|
+
- `getPNG(text, [options])`: Readable stream with image data.
|
|
54
|
+
- `getSVG(text, [options])`: Readable stream with image data.
|
|
55
|
+
- `getPDF(text, [options])`: Readable stream with image data.
|
|
56
|
+
|
|
57
|
+
### Options
|
|
58
|
+
|
|
59
|
+
- `text`: text to encode
|
|
60
|
+
- `options`: additional image options object
|
|
61
|
+
|
|
62
|
+
#### Additional Options
|
|
63
|
+
|
|
64
|
+
| Name | Description | Type | Possible Values | Default |
|
|
65
|
+
| :------------: | :------------------------------------------------: | :---------: | :-------------------: | :--------------------------------------: |
|
|
66
|
+
| `ec_level` | error correction level | string | `L`, `M`, `Q`, `H` | `M` |
|
|
67
|
+
| `type` | image type | string | `png`, `svg`, `pdf` | `png` |
|
|
68
|
+
| `size` | png and svg only<br />size of one module in pixels | number | `0` - n | `5` (png)<br />`0` (others) |
|
|
69
|
+
| `margin` | white space around QR image in modules | number | `0` - n | `4` (png)<br />`1` (others) |
|
|
70
|
+
| `parse_url` | EXPERIMENTAL<br />try to optimize QR-code for URLs | boolean | `true`, `false` | `false` |
|
|
71
|
+
| `logo` | buffer with png/jpeg image | ArrayBuffer | - | `undefined` |
|
|
72
|
+
| `logoWidth` | height of logo in percent | number | `0` - `100` | `20` |
|
|
73
|
+
| `logoHeight` | width of logo in percent | number | `0` - `100` | `20` |
|
|
74
|
+
| `color` | module color in rgba or hex format | number | `#000000` - `#000000` | `#000000`<br />(black with 100% opacity) |
|
|
75
|
+
| `bgColor` | background color in rgba or hex format | number | `#000000` - `#FFFFFF` | `#FFFFFF`<br />(white with 100% opacity) |
|
|
76
|
+
| `borderRadius` | border-radius (in pixels) | number | 0 - `size / 2` | `0` |
|
|
77
|
+
|
|
78
|
+
## Benchmarks
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
getPNG x 229 ops/sec ±0.45% (84 runs sampled)
|
|
82
|
+
getPDF x 186 ops/sec ±24.91% (86 runs sampled)
|
|
83
|
+
getSVG x 2,482 ops/sec ±0.18% (90 runs sampled)
|
|
84
|
+
getPNG with logo x 69.96 ops/sec ±0.72% (68 runs sampled)
|
|
85
|
+
getPDF with logo x 44.83 ops/sec ±9.52% (77 runs sampled)
|
|
86
|
+
getSVG with logo x 2,494 ops/sec ±0.19% (88 runs sampled)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## TODO
|
|
90
|
+
|
|
91
|
+
- Use lighter versions of PDF library
|
|
92
|
+
- Background
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function calculateEC(msg: number[], ec_len: number): Uint8Array;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Data, EcLevel, Matrix } from "./typing/types";
|
|
2
|
+
export declare function init(version: number): Matrix;
|
|
3
|
+
export declare function fillFinders(matrix: Matrix): void;
|
|
4
|
+
export declare function fillAlignAndTiming(matrix: Matrix): void;
|
|
5
|
+
export declare function fillStub(matrix: Matrix): void;
|
|
6
|
+
export declare const fillReserved: (matrix: Matrix, ec_level: EcLevel, mask: number) => void;
|
|
7
|
+
export declare const fillData: (matrix: Matrix, data: Data, mask: number) => void;
|
|
8
|
+
export declare function calculatePenalty(matrix: Matrix): number;
|
|
9
|
+
export declare function getMatrix(data: Data): number[][];
|