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.
Files changed (80) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +92 -0
  3. package/lib/browser/encode.d.ts +2 -0
  4. package/lib/browser/errorcode.d.ts +1 -0
  5. package/lib/browser/matrix.d.ts +9 -0
  6. package/lib/browser/pdf.d.ts +2 -0
  7. package/lib/browser/pdf.umd.js +26816 -0
  8. package/lib/browser/pdf.umd.js.map +1 -0
  9. package/lib/browser/png.d.ts +6 -0
  10. package/lib/browser/png.umd.js +1540 -0
  11. package/lib/browser/png.umd.js.map +1 -0
  12. package/lib/browser/png_browser.d.ts +5 -0
  13. package/lib/browser/qr-base.d.ts +4 -0
  14. package/lib/browser/qr.d.ts +2 -0
  15. package/lib/browser/svg.d.ts +7 -0
  16. package/lib/browser/svg.umd.js +1536 -0
  17. package/lib/browser/svg.umd.js.map +1 -0
  18. package/lib/browser/tests/_common.d.ts +4 -0
  19. package/lib/browser/tests/browser.test.d.ts +1 -0
  20. package/lib/browser/tests/test.d.ts +1 -0
  21. package/lib/browser/typing/types.d.ts +28 -0
  22. package/lib/browser/utils.d.ts +17 -0
  23. package/lib/encode.d.ts +2 -0
  24. package/lib/encode.js +137 -0
  25. package/lib/encode.js.map +1 -0
  26. package/lib/errorcode.d.ts +1 -0
  27. package/lib/errorcode.js +62 -0
  28. package/lib/errorcode.js.map +1 -0
  29. package/lib/matrix.d.ts +9 -0
  30. package/lib/matrix.js +347 -0
  31. package/lib/matrix.js.map +1 -0
  32. package/lib/pdf.d.ts +2 -0
  33. package/lib/pdf.js +64 -0
  34. package/lib/pdf.js.map +1 -0
  35. package/lib/png.d.ts +6 -0
  36. package/lib/png.js +30 -0
  37. package/lib/png.js.map +1 -0
  38. package/lib/png_browser.d.ts +5 -0
  39. package/lib/png_browser.js +53 -0
  40. package/lib/png_browser.js.map +1 -0
  41. package/lib/qr-base.d.ts +4 -0
  42. package/lib/qr-base.js +151 -0
  43. package/lib/qr-base.js.map +1 -0
  44. package/lib/qr.d.ts +2 -0
  45. package/lib/qr.js +2 -0
  46. package/lib/qr.js.map +1 -0
  47. package/lib/svg.d.ts +7 -0
  48. package/lib/svg.js +49 -0
  49. package/lib/svg.js.map +1 -0
  50. package/lib/tests/_common.d.ts +4 -0
  51. package/lib/tests/_common.js +36 -0
  52. package/lib/tests/_common.js.map +1 -0
  53. package/lib/tests/browser.test.d.ts +1 -0
  54. package/lib/tests/browser.test.js +193 -0
  55. package/lib/tests/browser.test.js.map +1 -0
  56. package/lib/tests/test.d.ts +1 -0
  57. package/lib/tests/test.js +238 -0
  58. package/lib/tests/test.js.map +1 -0
  59. package/lib/typing/types.d.ts +28 -0
  60. package/lib/typing/types.js +2 -0
  61. package/lib/typing/types.js.map +1 -0
  62. package/lib/utils.d.ts +17 -0
  63. package/lib/utils.js +68 -0
  64. package/lib/utils.js.map +1 -0
  65. package/package.json +105 -0
  66. package/src/encode.ts +176 -0
  67. package/src/errorcode.ts +75 -0
  68. package/src/matrix.ts +393 -0
  69. package/src/pdf.ts +80 -0
  70. package/src/png.ts +42 -0
  71. package/src/png_browser.ts +73 -0
  72. package/src/qr-base.ts +180 -0
  73. package/src/qr.ts +2 -0
  74. package/src/svg.ts +89 -0
  75. package/src/tests/_common.ts +40 -0
  76. package/src/tests/browser.test.ts +209 -0
  77. package/src/tests/test.ts +250 -0
  78. package/src/typing/index.d.ts +5 -0
  79. package/src/typing/types.ts +99 -0
  80. 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
+ [![npm version](https://badge.fury.io/js/qreator.svg)](https://badge.fury.io/js/qreator)
4
+
5
+ QR Code generator for browser and node.js with tree shaking and logo support
6
+
7
+ ![image](https://github.com/Short-io/qreator/assets/75169/02b84738-56f2-44d8-8d11-f40e263302ed)
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,2 @@
1
+ import { NumberData } from "./typing/types";
2
+ export declare function encode(inData: string | number | ArrayBuffer, parse_url: boolean): NumberData;
@@ -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[][];
@@ -0,0 +1,2 @@
1
+ import { ImageOptions } from "./typing/types";
2
+ export declare function getPDF(text: string, inOptions: ImageOptions): Promise<Uint8Array>;