@liquid-js/qr-code-styling 2.0.5 → 2.1.1
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 +57 -168
- package/lib/core/QRCodeStyling.d.ts +44 -3
- package/lib/core/QRSVG.d.ts +11 -0
- package/lib/qr-code-styling-node.js +42 -6
- package/lib/qr-code-styling-node.js.map +1 -1
- package/lib/qr-code-styling.js +1 -1
- package/lib/qr-code-styling.js.map +1 -1
- package/lib/tools/browserImageTools.d.ts +2 -2
- package/lib/types/index.d.ts +84 -6
- package/package.json +23 -12
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
2
|
+
import { Options } from "../types";
|
|
3
3
|
export declare const browserImageTools: {
|
|
4
4
|
toDataURL(url: string | Buffer | Blob): Promise<string>;
|
|
5
|
-
getSize(options:
|
|
5
|
+
getSize(options: Options): Promise<{
|
|
6
6
|
width: number;
|
|
7
7
|
height: number;
|
|
8
8
|
}>;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -29,10 +29,23 @@ export declare enum ShapeType {
|
|
|
29
29
|
circle = "circle"
|
|
30
30
|
}
|
|
31
31
|
export type Gradient = {
|
|
32
|
+
/**
|
|
33
|
+
* Type of gradient spread
|
|
34
|
+
*
|
|
35
|
+
* @default GradientType.linear
|
|
36
|
+
*/
|
|
32
37
|
type: GradientType;
|
|
38
|
+
/**
|
|
39
|
+
* Rotation of gradient (in radians, Math.PI === 180 degrees)
|
|
40
|
+
*
|
|
41
|
+
* @default 0
|
|
42
|
+
*/
|
|
33
43
|
rotation?: number;
|
|
44
|
+
/** Gradient colors. */
|
|
34
45
|
colorStops: {
|
|
46
|
+
/** Position of color in gradient range */
|
|
35
47
|
offset: number;
|
|
48
|
+
/** Color of stop in gradient range */
|
|
36
49
|
color: string;
|
|
37
50
|
}[];
|
|
38
51
|
};
|
|
@@ -100,43 +113,108 @@ export interface QRCode {
|
|
|
100
113
|
isDark(row: number, col: number): boolean;
|
|
101
114
|
}
|
|
102
115
|
export type Options = {
|
|
116
|
+
/** Use a custom DOM domplementation */
|
|
103
117
|
document?: Document;
|
|
104
|
-
|
|
118
|
+
/** Use a custom image fetching & serializaton implementation */
|
|
119
|
+
imageTools?: typeof browserImageTools;
|
|
120
|
+
/** @ignore */
|
|
105
121
|
width?: number;
|
|
122
|
+
/** @ignore */
|
|
106
123
|
height?: number;
|
|
124
|
+
/** The data will be encoded in the QR code */
|
|
107
125
|
data?: string;
|
|
126
|
+
/** The image will be copied to the center of the QR code */
|
|
108
127
|
image?: string | Buffer | Blob;
|
|
109
|
-
|
|
128
|
+
/**
|
|
129
|
+
* QR code shape
|
|
130
|
+
*
|
|
131
|
+
* @default ShapeType.square
|
|
132
|
+
*/
|
|
133
|
+
shape?: ShapeType;
|
|
134
|
+
/** Options will be passed to `qrcode-generator` lib */
|
|
110
135
|
qrOptions?: {
|
|
111
136
|
typeNumber?: TypeNumber;
|
|
112
137
|
mode?: Mode;
|
|
138
|
+
/** @default ErrorCorrectionLevel.Q */
|
|
113
139
|
errorCorrectionLevel?: ErrorCorrectionLevel;
|
|
114
140
|
};
|
|
115
141
|
imageOptions?: {
|
|
142
|
+
/**
|
|
143
|
+
* Hide all dots covered by the image
|
|
144
|
+
*
|
|
145
|
+
* @default true
|
|
146
|
+
*/
|
|
116
147
|
hideBackgroundDots?: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Coefficient of the image size
|
|
150
|
+
*
|
|
151
|
+
* @default 0.4
|
|
152
|
+
*/
|
|
117
153
|
imageSize?: number;
|
|
118
|
-
|
|
154
|
+
/**
|
|
155
|
+
* Margin of the image (in blocks)
|
|
156
|
+
*
|
|
157
|
+
* @default 0
|
|
158
|
+
*/
|
|
119
159
|
margin?: number;
|
|
160
|
+
/**
|
|
161
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLImageElement/crossOrigin)
|
|
162
|
+
*/
|
|
163
|
+
crossOrigin?: string;
|
|
120
164
|
};
|
|
121
165
|
dotsOptions?: {
|
|
122
|
-
|
|
166
|
+
/**
|
|
167
|
+
* QR dot size (in pixels)
|
|
168
|
+
*
|
|
169
|
+
* @default 10
|
|
170
|
+
*/
|
|
171
|
+
size?: number;
|
|
172
|
+
/**
|
|
173
|
+
* Color of QR dots
|
|
174
|
+
*
|
|
175
|
+
* @default "#000"
|
|
176
|
+
*/
|
|
123
177
|
color?: string;
|
|
178
|
+
/** Gradient of QR dots */
|
|
124
179
|
gradient?: Gradient;
|
|
180
|
+
/**
|
|
181
|
+
* Style of QR dots
|
|
182
|
+
*
|
|
183
|
+
* @default DotType.square
|
|
184
|
+
*/
|
|
185
|
+
type?: DotType;
|
|
125
186
|
};
|
|
187
|
+
/** Corners Square options, omitted values match dots */
|
|
126
188
|
cornersSquareOptions?: {
|
|
127
|
-
|
|
189
|
+
/** Color of Corners Square */
|
|
128
190
|
color?: string;
|
|
191
|
+
/** Gradient of Corners Square */
|
|
129
192
|
gradient?: Gradient;
|
|
193
|
+
/** Style of Corners Square */
|
|
194
|
+
type?: CornerSquareType;
|
|
130
195
|
};
|
|
196
|
+
/** Corners Dot options, omitted values match squares */
|
|
131
197
|
cornersDotOptions?: {
|
|
132
|
-
|
|
198
|
+
/** Color of Corners Dot */
|
|
133
199
|
color?: string;
|
|
200
|
+
/** Gradient of Corners Dot */
|
|
134
201
|
gradient?: Gradient;
|
|
202
|
+
/** Style of Corners Dot */
|
|
203
|
+
type?: CornerDotType;
|
|
135
204
|
};
|
|
205
|
+
/** QR background styling options, false to disable background */
|
|
136
206
|
backgroundOptions?: {
|
|
207
|
+
/** Background roundnes, from 0 (square) to 1 (circle) */
|
|
137
208
|
round?: number;
|
|
209
|
+
/** Background color */
|
|
138
210
|
color?: string;
|
|
211
|
+
/** Background Gradient */
|
|
139
212
|
gradient?: Gradient;
|
|
213
|
+
/**
|
|
214
|
+
* Margin (in blocks) between background and the QR code
|
|
215
|
+
*
|
|
216
|
+
* @default 0
|
|
217
|
+
*/
|
|
140
218
|
margin?: number;
|
|
141
219
|
} | false;
|
|
142
220
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liquid-js/qr-code-styling",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Add a style and an image to your QR code",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/qr-code-styling-node.js",
|
|
@@ -23,9 +23,13 @@
|
|
|
23
23
|
"@xmldom/xmldom": "^0.8.10",
|
|
24
24
|
"file-type": "^19.0.0",
|
|
25
25
|
"qrcode-generator": "^1.4.4",
|
|
26
|
-
"sharp": ">0.32.1 <1.0.0"
|
|
26
|
+
"sharp": ">0.32.1 <1.0.0",
|
|
27
|
+
"tslib": "^2.6.2",
|
|
28
|
+
"typedoc": "^0.25.13"
|
|
27
29
|
},
|
|
28
30
|
"devDependencies": {
|
|
31
|
+
"@commitlint/cli": "^19.3.0",
|
|
32
|
+
"@commitlint/config-conventional": "^19.2.2",
|
|
29
33
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
30
34
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
31
35
|
"@rollup/plugin-terser": "^0.4.4",
|
|
@@ -33,29 +37,35 @@
|
|
|
33
37
|
"@types/node": "<21.0.0",
|
|
34
38
|
"@types/node-fetch": "^2.6.11",
|
|
35
39
|
"@types/sharp": "^0.31.1",
|
|
36
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
37
|
-
"@typescript-eslint/parser": "^7.
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^7.7.1",
|
|
41
|
+
"@typescript-eslint/parser": "^7.7.1",
|
|
38
42
|
"canvas": "^2.11.2",
|
|
39
|
-
"eslint": "
|
|
43
|
+
"eslint": "<9.0.0",
|
|
40
44
|
"eslint-config-prettier": "^9.1.0",
|
|
41
|
-
"eslint-plugin-jest": "^
|
|
45
|
+
"eslint-plugin-jest": "^28.2.0",
|
|
42
46
|
"eslint-plugin-prettier": "^5.1.3",
|
|
47
|
+
"husky": "^9.0.11",
|
|
43
48
|
"jest": "^29.7.0",
|
|
44
49
|
"jest-environment-jsdom": "^29.7.0",
|
|
50
|
+
"npm-check-updates": "^16.14.18",
|
|
45
51
|
"prettier": "^3.2.5",
|
|
46
52
|
"rimraf": "^5.0.5",
|
|
47
|
-
"rollup": "^4.
|
|
53
|
+
"rollup": "^4.16.4",
|
|
48
54
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
55
|
+
"standard-version": "^9.5.0",
|
|
49
56
|
"ts-jest": "^29.1.2",
|
|
50
|
-
"typescript": "^5.4.
|
|
51
|
-
"vite": "^5.2.
|
|
57
|
+
"typescript": "^5.4.5",
|
|
58
|
+
"vite": "^5.2.10"
|
|
52
59
|
},
|
|
53
60
|
"scripts": {
|
|
54
61
|
"build": "rimraf lib && rollup -c rollup.config.ts --configPlugin rollup-plugin-typescript2",
|
|
55
62
|
"test": "jest",
|
|
56
63
|
"start": "vite src",
|
|
57
|
-
"lint": "eslint . --fix",
|
|
58
|
-
"prepublishOnly": "npm run build"
|
|
64
|
+
"lint": "prettier -w . && eslint . --fix",
|
|
65
|
+
"prepublishOnly": "npm run build",
|
|
66
|
+
"prepare": "husky",
|
|
67
|
+
"release": "git diff --exit-code && standard-version && git push --follow-tags origin",
|
|
68
|
+
"docs": "typedoc ./src/index.ts ./src/tools/browserUtils.ts ./src/tools/browserImageTools.ts"
|
|
59
69
|
},
|
|
60
70
|
"repository": {
|
|
61
71
|
"type": "git",
|
|
@@ -82,5 +92,6 @@
|
|
|
82
92
|
"bugs": {
|
|
83
93
|
"url": "https://github.com/Liquid-JS/qr-code-styling/issues"
|
|
84
94
|
},
|
|
85
|
-
"homepage": "https://qr-code-styling.com"
|
|
95
|
+
"homepage": "https://qr-code-styling.com",
|
|
96
|
+
"packageManager": "yarn@4.1.1"
|
|
86
97
|
}
|