qr-code-styling-node 1.10.0 → 1.12.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.
@@ -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;
@@ -2,7 +2,6 @@ import { RequiredOptions } from "../core/QROptions";
2
2
  import { CornerDotType, CornerSquareType, DotType } from "../types";
3
3
  /** Dot types with a round look; blend art matches its corners and correction dots to them. */
4
4
  export declare const ROUND_DOT_TYPES: DotType[];
5
- /** True when alignment patterns must be drawn as plain squares for this dot type to scan. */
6
5
  export declare const needsSolidAlignment: (type: DotType) => boolean;
7
6
  export default function getCornerTypes(options: RequiredOptions): {
8
7
  square?: CornerSquareType;
@@ -0,0 +1,15 @@
1
+ export default class PathRecorder {
2
+ private _m;
3
+ private _parts;
4
+ private _open;
5
+ get d(): string;
6
+ beginPath(): void;
7
+ translate(x: number, y: number): void;
8
+ rotate(angle: number): void;
9
+ private _point;
10
+ moveTo(x: number, y: number): void;
11
+ lineTo(x: number, y: number): void;
12
+ closePath(): void;
13
+ rect(x: number, y: number, width: number, height: number): void;
14
+ arc(cx: number, cy: number, r: number, start: number, end: number, anticlockwise?: boolean): void;
15
+ }
@@ -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;
@@ -1,12 +1,13 @@
1
1
  export interface UnknownObject {
2
2
  [key: string]: any;
3
3
  }
4
- export type DotType = "dots" | "rounded" | "classy" | "classy-rounded" | "square" | "extra-rounded" | "diamond" | "small-square" | "vertical-lines" | "horizontal-lines" | "fluid";
4
+ export type DotType = "dots" | "rounded" | "classy" | "classy-rounded" | "square" | "extra-rounded" | "diamond" | "small-square" | "vertical-lines" | "horizontal-lines" | "fluid" | "wave" | "blob" | "circuit";
5
5
  export type CornerDotType = "dot" | "square" | "rounded";
6
6
  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,16 @@ 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;
164
+ /** SVG output only. */
165
+ svgOptions?: {
166
+ /** Draw all dots as one path instead of one element per module: smaller files, faster rendering. Default false. */
167
+ mergePaths?: boolean;
168
+ };
158
169
  width?: number;
159
170
  height?: number;
160
171
  margin?: number;
@@ -214,6 +225,11 @@ export type DownloadOptions = {
214
225
  name?: string;
215
226
  extension?: Extension;
216
227
  };
228
+ export type ShareOptions = DownloadOptions & {
229
+ /** Title and text passed to the share sheet. */
230
+ title?: string;
231
+ text?: string;
232
+ };
217
233
  export type DrawArgs = {
218
234
  x: number;
219
235
  y: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qr-code-styling-node",
3
- "version": "1.10.0",
3
+ "version": "1.12.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,9 @@
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",
78
+ "dot-examples": "npm run build && node scripts/dot-examples.mjs"
77
79
  },
78
80
  "dependencies": {
79
81
  "qrcode-generator": "^1.4.3"