@qr-platform/qr-code.js 0.9.10 → 0.10.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.
Files changed (62) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -0
  3. package/docs/advanced-examples.md +177 -56
  4. package/docs/api-reference-guide.md +26 -6
  5. package/docs/border-methods-update-plan.md +28 -0
  6. package/docs/border-text-implementation-plan.md +155 -0
  7. package/docs/documentation.md +276 -11
  8. package/docs/examples.md +160 -37
  9. package/docs/license-management.md +4 -4
  10. package/docs/typescript-types-definitions.md +2 -2
  11. package/docs/usage-guide.md +71 -41
  12. package/lib/config/runtime-config.d.ts +3 -0
  13. package/lib/core/qr-code-js.d.ts +82 -7
  14. package/lib/core/qr-options-validation.d.ts +1 -1
  15. package/lib/core/qr-svg.d.ts +3 -1
  16. package/lib/core/templates/qr-styles-dark.d.ts +2 -0
  17. package/lib/core/templates/qr-styles.d.ts +9 -0
  18. package/lib/core/templates/qr-template-borders.d.ts +4 -0
  19. package/lib/core/templates/qr-template-text.d.ts +4 -0
  20. package/lib/core/templates/qr-templates.d.ts +12 -0
  21. package/lib/demo.d.ts +1 -0
  22. package/lib/index.d.ts +135 -21
  23. package/lib/index.js +1 -1
  24. package/lib/license/LicenseManager.d.ts +1 -1
  25. package/lib/node/config/runtime-config.d.ts +3 -0
  26. package/lib/node/core/qr-code-js.d.ts +82 -7
  27. package/lib/node/core/qr-options-validation.d.ts +1 -1
  28. package/lib/node/core/qr-svg.d.ts +3 -1
  29. package/lib/node/core/templates/qr-styles-dark.d.ts +2 -0
  30. package/lib/node/core/templates/qr-styles.d.ts +9 -0
  31. package/lib/node/core/templates/qr-template-borders.d.ts +4 -0
  32. package/lib/node/core/templates/qr-template-text.d.ts +4 -0
  33. package/lib/node/core/templates/qr-templates.d.ts +12 -0
  34. package/lib/node/demo.d.ts +1 -0
  35. package/lib/node/index.d.ts +135 -21
  36. package/lib/node/license/LicenseManager.d.ts +1 -1
  37. package/lib/node/node.d.ts +128 -17
  38. package/lib/node/options-demo.d.ts +2 -239
  39. package/lib/node/templates/scan-validators/tests/cases/colors.d.ts +0 -6
  40. package/lib/node/types/helper.d.ts +3 -0
  41. package/lib/node/types/style-options.d.ts +8 -2
  42. package/lib/node/types/text-options.d.ts +11 -0
  43. package/lib/node/utils/_network-helpers_multi_env.d.ts +16 -0
  44. package/lib/node/utils/gradient.d.ts +2 -1
  45. package/lib/node/utils/network-helpers.d.ts +17 -0
  46. package/lib/node/utils/options.d.ts +26 -21
  47. package/lib/node.d.ts +128 -17
  48. package/lib/node.js +1 -1
  49. package/lib/options-demo.d.ts +2 -239
  50. package/lib/templates/scan-validators/tests/cases/colors.d.ts +0 -6
  51. package/lib/types/helper.d.ts +3 -0
  52. package/lib/types/style-options.d.ts +8 -2
  53. package/lib/types/text-options.d.ts +11 -0
  54. package/lib/utils/_network-helpers_multi_env.d.ts +16 -0
  55. package/lib/utils/gradient.d.ts +2 -1
  56. package/lib/utils/network-helpers.d.ts +17 -0
  57. package/lib/utils/options.d.ts +26 -21
  58. package/package.json +1 -1
  59. package/lib/core/qr-styles.d.ts +0 -4
  60. package/lib/core/qr-templates.d.ts +0 -10
  61. package/lib/node/core/qr-styles.d.ts +0 -4
  62. package/lib/node/core/qr-templates.d.ts +0 -10
@@ -1,239 +1,2 @@
1
- import { ShapeType } from './utils/options';
2
- export declare const options2: {
3
- shape: ShapeType;
4
- verticalOffset: number;
5
- isResponive: string;
6
- margin: number;
7
- scale: number;
8
- data: string;
9
- image: string;
10
- dotsOptions: {
11
- type: string;
12
- color: string;
13
- size: number;
14
- };
15
- backgroundOptions: {
16
- color: string;
17
- };
18
- cornersDotOptions: {
19
- type: string;
20
- color: string;
21
- };
22
- cornersSquareOptions: {
23
- type: string;
24
- color: string;
25
- };
26
- imageOptions: {
27
- crossOrigin: string;
28
- imageSize: number;
29
- margin: number;
30
- };
31
- borderOptions: {
32
- hasBorder: boolean;
33
- radius: string;
34
- thickness: number;
35
- inner: {
36
- radius: string;
37
- scale: number;
38
- horizontalOffset: number;
39
- verticalOffset: number;
40
- };
41
- color: string;
42
- decorations: {
43
- top: {
44
- disabled: boolean;
45
- enableText: boolean;
46
- offset: number;
47
- curveAdjustment: number;
48
- curveDisabled: boolean;
49
- curveRadius: string;
50
- type: string;
51
- value: string;
52
- style: {
53
- fontFace: string;
54
- fontSize: number;
55
- fontColor: string;
56
- letterSpacing: number;
57
- fontWeight: string;
58
- };
59
- };
60
- bottom: {
61
- disabled: boolean;
62
- enableText: boolean;
63
- offset: number;
64
- curveAdjustment: number;
65
- curveRadius: string;
66
- curveDisabled: boolean;
67
- type: string;
68
- value: string;
69
- style: {
70
- fontFace: string;
71
- fontSize: number;
72
- fontColor: string;
73
- letterSpacing: number;
74
- fontWeight: string;
75
- };
76
- };
77
- left: {
78
- disabled: boolean;
79
- enableText: boolean;
80
- offset: number;
81
- curveAdjustment: number;
82
- curveRadius: string;
83
- curveDisabled: boolean;
84
- type: string;
85
- value: string;
86
- style: {
87
- fontFace: string;
88
- fontSize: number;
89
- fontColor: string;
90
- letterSpacing: number;
91
- fontWeight: string;
92
- };
93
- };
94
- right: {
95
- disabled: boolean;
96
- enableText: boolean;
97
- offset: number;
98
- curveAdjustment: number;
99
- curveDisabled: boolean;
100
- curveRadius: string;
101
- type: string;
102
- value: string;
103
- style: {
104
- fontFace: string;
105
- fontSize: number;
106
- fontColor: string;
107
- letterSpacing: number;
108
- fontWeight: string;
109
- };
110
- };
111
- };
112
- borderOuter: {
113
- color: string;
114
- thickness: number;
115
- };
116
- borderInner: {
117
- color: string;
118
- thickness: number;
119
- };
120
- };
121
- };
122
- export declare const options: {
123
- name: string;
124
- description: string;
125
- data: string;
126
- image: string;
127
- margin: number;
128
- verticalOffset: number;
129
- scale: number;
130
- shape: string;
131
- qrOptions: {};
132
- imageOptions: {
133
- imageSize: number;
134
- margin: number;
135
- roundedValue: number;
136
- };
137
- dotsOptions: {
138
- type: string;
139
- color: string;
140
- };
141
- cornersSquareOptions: {
142
- type: string;
143
- color: string;
144
- };
145
- cornersDotOptions: {
146
- type: string;
147
- color: string;
148
- };
149
- backgroundOptions: {
150
- color: string;
151
- gradient: {
152
- type: string;
153
- colorStops: {
154
- offset: number;
155
- color: string;
156
- }[];
157
- };
158
- };
159
- borderOptions: {
160
- hasBorder: boolean;
161
- radius: string;
162
- innerRadius: string;
163
- thickness: number;
164
- color: string;
165
- isTopBorderOnly: boolean;
166
- isBottomBorderOnly: boolean;
167
- isTopBottomBorderOnly: boolean;
168
- decorations: {
169
- top: {
170
- enableText: boolean;
171
- verticalOffset: number;
172
- curveAdjustment: number;
173
- disableCurve: boolean;
174
- type: string;
175
- value: string;
176
- style: {
177
- fontFace: string;
178
- fontSize: number;
179
- fontColor: string;
180
- letterSpacing: number;
181
- fontWeight: string;
182
- };
183
- };
184
- bottom: {
185
- enableText: boolean;
186
- verticalOffset: number;
187
- curveAdjustment: number;
188
- disableCurve: boolean;
189
- type: string;
190
- value: string;
191
- style: {
192
- fontFace: string;
193
- fontSize: number;
194
- fontColor: string;
195
- letterSpacing: number;
196
- fontWeight: string;
197
- };
198
- };
199
- left: {
200
- enableText: boolean;
201
- verticalOffset: number;
202
- curveAdjustment: number;
203
- disableCurve: boolean;
204
- type: string;
205
- value: string;
206
- style: {
207
- fontFace: string;
208
- fontSize: number;
209
- fontColor: string;
210
- letterSpacing: number;
211
- fontWeight: string;
212
- };
213
- };
214
- right: {
215
- enableText: boolean;
216
- verticalOffset: number;
217
- curveAdjustment: number;
218
- disableCurve: boolean;
219
- type: string;
220
- value: string;
221
- style: {
222
- fontFace: string;
223
- fontSize: number;
224
- fontColor: string;
225
- letterSpacing: number;
226
- fontWeight: string;
227
- };
228
- };
229
- };
230
- borderOuter: {
231
- color: string;
232
- thickness: number;
233
- };
234
- borderInner: {
235
- color: string;
236
- thickness: number;
237
- };
238
- };
239
- };
1
+ import { Options } from '.';
2
+ export declare const options: Options;
@@ -6,9 +6,6 @@ export declare const baseOptions: {
6
6
  scale: number;
7
7
  margin: number;
8
8
  shape: string;
9
- qrOptions: {
10
- errorCorrectionLevel: string;
11
- };
12
9
  dotsOptions: {
13
10
  type: string;
14
11
  color: string;
@@ -49,9 +46,6 @@ export declare const buildOptions: (elementColor: string, backgroundColor: strin
49
46
  scale: number;
50
47
  margin: number;
51
48
  shape: string;
52
- qrOptions: {
53
- errorCorrectionLevel: string;
54
- };
55
49
  };
56
50
  export declare const alphas: number[];
57
51
  declare const cases: TestCase[];
@@ -21,3 +21,6 @@ export interface RotateFigureArgs {
21
21
  rotation?: number;
22
22
  draw: () => void;
23
23
  }
24
+ export interface MethodOverrideOptions {
25
+ override?: boolean;
26
+ }
@@ -20,11 +20,17 @@ export interface StyleOptions {
20
20
  logoSize?: number;
21
21
  logoMode?: ImageMode;
22
22
  logoMargin?: number;
23
- logoFillColor?: string;
24
- logoFillGradient?: Gradient;
23
+ logoBackgroundColor?: string;
24
+ logoPadding?: number;
25
+ logoRadius?: string | number;
25
26
  borderColor?: string;
26
27
  borderThickness?: number;
27
28
  borderRadius?: string | number;
29
+ borderInnerColor?: string;
30
+ borderInnerThickness?: number;
31
+ borderInnerRadius?: string | number;
32
+ borderOuterColor?: string;
33
+ borderOuterThickness?: number;
28
34
  borderTextTop?: string;
29
35
  borderTextRight?: string;
30
36
  borderTextBottom?: string;
@@ -0,0 +1,11 @@
1
+ export interface TextOptions {
2
+ topValue?: string | null;
3
+ leftValue?: string | null;
4
+ rightValue?: string | null;
5
+ bottomValue?: string | null;
6
+ }
7
+ export interface QRTextTemplateDefinition {
8
+ id: string;
9
+ name: string;
10
+ options: TextOptions;
11
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Fetches an image directly from its URL and converts it to a Data URL.
3
+ * Handles potential CORS issues and other fetch errors.
4
+ *
5
+ * @param imageUrl The URL of the image to fetch.
6
+ * @param crossOrigin The crossOrigin attribute value ('anonymous', 'use-credentials').
7
+ * @returns A Promise resolving to the Data URL string, or null if fetching fails.
8
+ */
9
+ export declare function fetchImageDataUrlDirectly(imageUrl: string, crossOrigin?: string): Promise<string | null>;
10
+ /**
11
+ * Fetches an image via a proxy service, which returns the image as a Data URL.
12
+ *
13
+ * @param imageUrl The original URL of the image to fetch via proxy.
14
+ * @returns A Promise resolving to the Data URL string from the proxy, or null if fetching fails.
15
+ */
16
+ export declare function fetchImageDataUrlViaProxy(imageUrl: string): Promise<string | null>;
@@ -2,13 +2,14 @@ export declare enum GradientType {
2
2
  radial = "radial",
3
3
  linear = "linear"
4
4
  }
5
+ export type GradientTypeStrings = `${GradientType}`;
5
6
  export interface Gradient {
6
7
  /**
7
8
  * Type of gradient spread
8
9
  *
9
10
  * @default GradientType.linear
10
11
  */
11
- type: GradientType;
12
+ type: GradientType | GradientTypeStrings;
12
13
  /**
13
14
  * Rotation of gradient (in radians, Math.PI === 180 degrees)
14
15
  *
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Fetches an image directly from its URL and converts it to a Data URL.
3
+ * Handles potential CORS issues and other fetch errors.
4
+ * Works in Browser, Node.js, and Worker environments.
5
+ *
6
+ * @param imageUrl The URL of the image to fetch.
7
+ * @param crossOrigin The crossOrigin attribute value ('anonymous', 'use-credentials').
8
+ * @returns A Promise resolving to the Data URL string, or null if fetching fails.
9
+ */
10
+ export declare function fetchImageDataUrlDirectly(imageUrl: string, crossOrigin?: string): Promise<string | null>;
11
+ /**
12
+ * Fetches an image via a proxy service, which returns the image as a Data URL.
13
+ *
14
+ * @param imageUrl The original URL of the image to fetch via proxy.
15
+ * @returns A Promise resolving to the Data URL string from the proxy, or null if fetching fails.
16
+ */
17
+ export declare function fetchImageDataUrlViaProxy(imageUrl: string): Promise<string | null>;
@@ -10,8 +10,8 @@ export interface DecorationOption {
10
10
  curveDisabled?: boolean;
11
11
  curveRadius?: string;
12
12
  enableText?: boolean;
13
- type: 'text' | 'image';
14
- value: string;
13
+ type?: 'text' | 'image';
14
+ value?: string;
15
15
  style?: QRBorderPluginStyleOptions;
16
16
  }
17
17
  export interface BorderOptions {
@@ -28,17 +28,17 @@ export interface BorderOptions {
28
28
  innerVerticalOffset?: number;
29
29
  thickness: number;
30
30
  noBorderThickness?: number;
31
- color: string;
31
+ color?: string;
32
32
  background?: string;
33
33
  decorations?: {
34
34
  [key in Position]?: DecorationOption;
35
35
  };
36
36
  borderOuter?: {
37
- color: string;
37
+ color?: string;
38
38
  thickness: number;
39
39
  };
40
40
  borderInner?: {
41
- color: string;
41
+ color?: string;
42
42
  thickness: number;
43
43
  };
44
44
  }
@@ -93,6 +93,11 @@ export declare enum ImageMode {
93
93
  */
94
94
  background = "background"
95
95
  }
96
+ type ShapeTypeStrings = `${ShapeType}`;
97
+ type DotTypeStrings = `${DotType}`;
98
+ type CornerSquareTypeStrings = `${CornerSquareType}`;
99
+ type CornerDotTypeStrings = `${CornerDotType}`;
100
+ type ImageModeStrings = `${ImageMode}`;
96
101
  export interface Options {
97
102
  /** Use a custom DOM domplementation */
98
103
  document: Document;
@@ -116,7 +121,7 @@ export interface Options {
116
121
  *
117
122
  * @default ShapeType.square
118
123
  */
119
- shape: ShapeType;
124
+ shape: ShapeType | ShapeTypeStrings;
120
125
  /** Options will be passed to `~` lib */
121
126
  scale?: number;
122
127
  offset?: number;
@@ -132,20 +137,17 @@ export interface Options {
132
137
  *
133
138
  * @default ImageMode.center
134
139
  */
135
- mode?: ImageMode;
140
+ mode?: ImageMode | ImageModeStrings;
136
141
  /**
137
- * Fill blank areas of the code with selected color
142
+ * Background color of QR code image (logo, image, etc.)
143
+ */
144
+ backgroundColor?: string;
145
+ /**
146
+ * Padding around the image (in blocks)
147
+ *
148
+ * @default 0
138
149
  */
139
- fill?: {
140
- /**
141
- * Color of QR dots
142
- *
143
- * @default "rgba(255,255,255,0.75)"
144
- */
145
- color: string;
146
- /** Gradient of Corners Dot */
147
- gradient?: Gradient;
148
- };
150
+ padding?: number;
149
151
  /**
150
152
  * Coefficient of the image size
151
153
  *
@@ -158,6 +160,8 @@ export interface Options {
158
160
  * @default 0
159
161
  */
160
162
  margin: number;
163
+ /** Radius of the image */
164
+ radius?: string | number;
161
165
  /**
162
166
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLImageElement/crossOrigin)
163
167
  */
@@ -183,7 +187,7 @@ export interface Options {
183
187
  *
184
188
  * @default DotType.square
185
189
  */
186
- type: DotType;
190
+ type: DotType | DotTypeStrings;
187
191
  };
188
192
  /** Corners Square options, omitted values match dots */
189
193
  cornersSquareOptions?: {
@@ -192,7 +196,7 @@ export interface Options {
192
196
  /** Gradient of Corners Square */
193
197
  gradient?: Gradient;
194
198
  /** Style of Corners Square */
195
- type?: CornerSquareType;
199
+ type?: CornerSquareType | CornerSquareTypeStrings;
196
200
  };
197
201
  /** Corners Dot options, omitted values match squares */
198
202
  cornersDotOptions?: {
@@ -201,7 +205,7 @@ export interface Options {
201
205
  /** Gradient of Corners Dot */
202
206
  gradient?: Gradient;
203
207
  /** Style of Corners Dot */
204
- type?: CornerDotType;
208
+ type?: CornerDotType | CornerDotTypeStrings;
205
209
  };
206
210
  /** QR background styling options, false to disable background */
207
211
  backgroundOptions?: {
@@ -218,3 +222,4 @@ export interface Options {
218
222
  borderOptions?: BorderOptions;
219
223
  }
220
224
  export declare function sanitizeOptions(options: Options): Options;
225
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qr-platform/qr-code.js",
3
- "version": "0.9.10",
3
+ "version": "0.10.1",
4
4
  "description": "QRCode.js is a professional JavaScript/TypeScript library for creating customized QR codes, offering a blend of simplicity and sophistication. With versatile styling options—dot shapes, colors, gradients, embedded images, borders, and text—it enables you to design unique, visually appealing QR codes that work flawlessly with standard scanners. QRCode.js is part of QR-Platform: All-in-One QR Codes Management Solution.",
5
5
  "type": "module",
6
6
  "main": "./lib/node.js",
@@ -1,4 +0,0 @@
1
- import { StyleOptions } from '../types/style-options';
2
- export declare const qrStyles: {
3
- [key: string]: StyleOptions;
4
- };
@@ -1,10 +0,0 @@
1
- import { type Options } from '~/utils/options';
2
- import { RecursivePartial } from '~/types/helper';
3
- export declare const plainQRTemplate: RecursivePartial<Options>;
4
- export declare const basicQRTemplate: RecursivePartial<Options>;
5
- export declare const roundedQRTemplate: RecursivePartial<Options>;
6
- export declare const dotsQRTemplate: RecursivePartial<Options>;
7
- export declare const classyQRTemplate: RecursivePartial<Options>;
8
- export declare const qrTemplates: {
9
- [key: string]: RecursivePartial<Options>;
10
- };
@@ -1,4 +0,0 @@
1
- import { StyleOptions } from '../types/style-options';
2
- export declare const qrStyles: {
3
- [key: string]: StyleOptions;
4
- };
@@ -1,10 +0,0 @@
1
- import { type Options } from '~/utils/options';
2
- import { RecursivePartial } from '~/types/helper';
3
- export declare const plainQRTemplate: RecursivePartial<Options>;
4
- export declare const basicQRTemplate: RecursivePartial<Options>;
5
- export declare const roundedQRTemplate: RecursivePartial<Options>;
6
- export declare const dotsQRTemplate: RecursivePartial<Options>;
7
- export declare const classyQRTemplate: RecursivePartial<Options>;
8
- export declare const qrTemplates: {
9
- [key: string]: RecursivePartial<Options>;
10
- };