qr-code-styling-node 1.10.0 → 1.11.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 +53 -0
- package/lib/core/QRCodeStyling.d.ts +23 -1
- package/lib/core/QRSVG.d.ts +3 -1
- package/lib/index.d.ts +3 -1
- package/lib/qr-code-styling.common.js +1 -1
- package/lib/qr-code-styling.common.js.map +1 -1
- package/lib/qr-code-styling.js +1 -1
- package/lib/qr-code-styling.js.map +1 -1
- package/lib/qr-code-styling.mjs +236 -38
- package/lib/qr-code-styling.mjs.map +4 -4
- package/lib/tools/circle.d.ts +16 -0
- package/lib/tools/payloads.d.ts +72 -0
- package/lib/tools/utf8.d.ts +4 -0
- package/lib/types/index.d.ts +11 -0
- package/package.json +3 -2
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RequiredOptions } from "../core/QROptions";
|
|
2
|
+
/**
|
|
3
|
+
* Round QR codes (shape: "circle"). The real code stays a square in the middle; the rest of the circle
|
|
4
|
+
* is filled with decorative modules. A one-module empty ring around the real code keeps it readable,
|
|
5
|
+
* as scanners ignore everything outside the finder patterns.
|
|
6
|
+
*/
|
|
7
|
+
export interface CircleLayout {
|
|
8
|
+
/** Modules across the whole circle. */
|
|
9
|
+
size: number;
|
|
10
|
+
/** Decorative modules on each side of the real code. */
|
|
11
|
+
pad: number;
|
|
12
|
+
/** True for a dark decorative module. Always false inside the real code and its quiet ring. */
|
|
13
|
+
isDecoration: (i: number, j: number) => boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare const isCircle: (options: RequiredOptions) => boolean;
|
|
16
|
+
export declare function getCircleLayout(count: number): CircleLayout;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builders for the data of common QR codes: Wi-Fi, contact card, calendar event, e-mail, phone, SMS and
|
|
3
|
+
* location. They only return a string, to pass as `data`.
|
|
4
|
+
*/
|
|
5
|
+
export interface WifiOptions {
|
|
6
|
+
ssid: string;
|
|
7
|
+
password?: string;
|
|
8
|
+
/** Default "WPA" when there is a password, otherwise "nopass". */
|
|
9
|
+
encryption?: "WPA" | "WEP" | "nopass";
|
|
10
|
+
hidden?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface VCardOptions {
|
|
13
|
+
firstName?: string;
|
|
14
|
+
lastName?: string;
|
|
15
|
+
/** Full name shown by phones. Default: first and last name. */
|
|
16
|
+
name?: string;
|
|
17
|
+
organization?: string;
|
|
18
|
+
title?: string;
|
|
19
|
+
phone?: string | string[];
|
|
20
|
+
email?: string | string[];
|
|
21
|
+
url?: string;
|
|
22
|
+
address?: {
|
|
23
|
+
street?: string;
|
|
24
|
+
city?: string;
|
|
25
|
+
region?: string;
|
|
26
|
+
postalCode?: string;
|
|
27
|
+
country?: string;
|
|
28
|
+
};
|
|
29
|
+
note?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface EventOptions {
|
|
32
|
+
title: string;
|
|
33
|
+
start: Date | string;
|
|
34
|
+
end?: Date | string;
|
|
35
|
+
/** Dates only, no time of day. */
|
|
36
|
+
allDay?: boolean;
|
|
37
|
+
location?: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
}
|
|
40
|
+
export declare function wifi({ ssid, password, encryption, hidden }: WifiOptions): string;
|
|
41
|
+
export declare function vCard(contact: VCardOptions): string;
|
|
42
|
+
export declare function event({ title, start, end, allDay, location, description }: EventOptions): string;
|
|
43
|
+
export declare function email({ to, subject, body }: {
|
|
44
|
+
to: string;
|
|
45
|
+
subject?: string;
|
|
46
|
+
body?: string;
|
|
47
|
+
}): string;
|
|
48
|
+
export declare const phone: (number: string) => string;
|
|
49
|
+
export declare const sms: ({ number, message }: {
|
|
50
|
+
number: string;
|
|
51
|
+
message?: string;
|
|
52
|
+
}) => string;
|
|
53
|
+
export declare const geo: ({ latitude, longitude }: {
|
|
54
|
+
latitude: number;
|
|
55
|
+
longitude: number;
|
|
56
|
+
}) => string;
|
|
57
|
+
declare const _default: {
|
|
58
|
+
wifi: typeof wifi;
|
|
59
|
+
vCard: typeof vCard;
|
|
60
|
+
event: typeof event;
|
|
61
|
+
email: typeof email;
|
|
62
|
+
phone: (number: string) => string;
|
|
63
|
+
sms: ({ number, message }: {
|
|
64
|
+
number: string;
|
|
65
|
+
message?: string;
|
|
66
|
+
}) => string;
|
|
67
|
+
geo: ({ latitude, longitude }: {
|
|
68
|
+
latitude: number;
|
|
69
|
+
longitude: number;
|
|
70
|
+
}) => string;
|
|
71
|
+
};
|
|
72
|
+
export default _default;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** UTF-8 bytes of a string (works without TextEncoder, for old browsers). */
|
|
2
|
+
export default function toUTF8Bytes(text: string): number[];
|
|
3
|
+
/** True when the text has characters outside Latin-1, which byte mode cannot hold as single bytes. */
|
|
4
|
+
export declare const needsUTF8: (text: string) => boolean;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type CornerSquareType = "dot" | "square" | "extra-rounded" | "rounded";
|
|
|
7
7
|
export type Extension = "svg" | "png" | "jpeg" | "webp";
|
|
8
8
|
export type GradientType = "radial" | "linear";
|
|
9
9
|
export type DrawType = "canvas" | "svg";
|
|
10
|
+
export type ShapeType = "square" | "circle";
|
|
10
11
|
export interface Canvas extends HTMLCanvasElement {
|
|
11
12
|
toBuffer?: (type: string) => Buffer;
|
|
12
13
|
createCanvas?: (width: number, height: number) => Canvas;
|
|
@@ -155,6 +156,11 @@ export interface LabelOptions {
|
|
|
155
156
|
}
|
|
156
157
|
export type Options = {
|
|
157
158
|
type?: DrawType;
|
|
159
|
+
/**
|
|
160
|
+
* "circle": a round QR code. The real code stays square in the middle and the rest of the circle is
|
|
161
|
+
* filled with decorative dots in the same style; the background becomes a circle. Default "square".
|
|
162
|
+
*/
|
|
163
|
+
shape?: ShapeType;
|
|
158
164
|
width?: number;
|
|
159
165
|
height?: number;
|
|
160
166
|
margin?: number;
|
|
@@ -214,6 +220,11 @@ export type DownloadOptions = {
|
|
|
214
220
|
name?: string;
|
|
215
221
|
extension?: Extension;
|
|
216
222
|
};
|
|
223
|
+
export type ShareOptions = DownloadOptions & {
|
|
224
|
+
/** Title and text passed to the share sheet. */
|
|
225
|
+
title?: string;
|
|
226
|
+
text?: string;
|
|
227
|
+
};
|
|
217
228
|
export type DrawArgs = {
|
|
218
229
|
x: number;
|
|
219
230
|
y: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qr-code-styling-node",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "Style your QR codes: dots, corners, gradients and a logo. Works in the browser and on Node.js.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"qr",
|
|
@@ -73,7 +73,8 @@
|
|
|
73
73
|
"bench": "npm run build && node scripts/bench.mjs",
|
|
74
74
|
"art-examples": "npm run build && node scripts/art-examples.mjs",
|
|
75
75
|
"style-examples": "npm run build && node scripts/style-examples.mjs",
|
|
76
|
-
"blend-examples": "npm run build && node scripts/blend-examples.mjs"
|
|
76
|
+
"blend-examples": "npm run build && node scripts/blend-examples.mjs",
|
|
77
|
+
"circle-examples": "npm run build && node scripts/circle-examples.mjs"
|
|
77
78
|
},
|
|
78
79
|
"dependencies": {
|
|
79
80
|
"qrcode-generator": "^1.4.3"
|