@liquid-js/qr-code-styling 2.1.0 → 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.
@@ -1,8 +1,8 @@
1
1
  /// <reference types="node" />
2
- import { RequiredOptions } from "../core/QROptions";
2
+ import { Options } from "../types";
3
3
  export declare const browserImageTools: {
4
4
  toDataURL(url: string | Buffer | Blob): Promise<string>;
5
- getSize(options: RequiredOptions): Promise<{
5
+ getSize(options: Options): Promise<{
6
6
  width: number;
7
7
  height: number;
8
8
  }>;
@@ -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
- shape?: ShapeType;
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
- imageTools?: typeof browserImageTools;
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
- crossOrigin?: string;
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
- type?: DotType;
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
- type?: CornerSquareType;
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
- type?: CornerDotType;
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.1.0",
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",
@@ -24,7 +24,8 @@
24
24
  "file-type": "^19.0.0",
25
25
  "qrcode-generator": "^1.4.4",
26
26
  "sharp": ">0.32.1 <1.0.0",
27
- "tslib": "^2.6.2"
27
+ "tslib": "^2.6.2",
28
+ "typedoc": "^0.25.13"
28
29
  },
29
30
  "devDependencies": {
30
31
  "@commitlint/cli": "^19.3.0",
@@ -63,7 +64,8 @@
63
64
  "lint": "prettier -w . && eslint . --fix",
64
65
  "prepublishOnly": "npm run build",
65
66
  "prepare": "husky",
66
- "release": "git diff --exit-code && standard-version && git push --follow-tags origin"
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"
67
69
  },
68
70
  "repository": {
69
71
  "type": "git",