@teamflojo/floimg-qr 0.1.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/LICENSE +21 -0
- package/README.md +240 -0
- package/dist/index.d.ts +75 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +121 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Brett Cooke
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# imgflo-qr
|
|
2
|
+
|
|
3
|
+
QR code generator for imgflo using the qrcode library.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install imgflo imgflo-qr
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import createClient from 'imgflo';
|
|
15
|
+
import qr from 'imgflo-qr';
|
|
16
|
+
|
|
17
|
+
const imgflo = createClient();
|
|
18
|
+
imgflo.registerGenerator(qr());
|
|
19
|
+
|
|
20
|
+
// Generate a QR code
|
|
21
|
+
const qrCode = await imgflo.generate({
|
|
22
|
+
generator: 'qr',
|
|
23
|
+
params: {
|
|
24
|
+
text: 'https://github.com/bcooke/imgflo',
|
|
25
|
+
width: 300,
|
|
26
|
+
errorCorrectionLevel: 'H'
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Save to filesystem or S3
|
|
31
|
+
const result = await imgflo.save(qrCode, './output/qr-github.png');
|
|
32
|
+
// Or save to S3:
|
|
33
|
+
// const result = await imgflo.save(qrCode, 's3://my-bucket/qr/github.png');
|
|
34
|
+
console.log(result.location);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Examples
|
|
38
|
+
|
|
39
|
+
### Basic QR Code
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
const qr = await imgflo.generate({
|
|
43
|
+
generator: 'qr',
|
|
44
|
+
params: {
|
|
45
|
+
text: 'Hello World!',
|
|
46
|
+
width: 200
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### URL QR Code
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
const qr = await imgflo.generate({
|
|
55
|
+
generator: 'qr',
|
|
56
|
+
params: {
|
|
57
|
+
text: 'https://example.com',
|
|
58
|
+
width: 300,
|
|
59
|
+
errorCorrectionLevel: 'H' // High error correction
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Custom Colors
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
const qr = await imgflo.generate({
|
|
68
|
+
generator: 'qr',
|
|
69
|
+
params: {
|
|
70
|
+
text: 'Styled QR Code',
|
|
71
|
+
width: 400,
|
|
72
|
+
color: {
|
|
73
|
+
dark: '#667eea', // Purple
|
|
74
|
+
light: '#ffffff' // White background
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### SVG Output
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
const qr = await imgflo.generate({
|
|
84
|
+
generator: 'qr',
|
|
85
|
+
params: {
|
|
86
|
+
text: 'https://example.com',
|
|
87
|
+
format: 'svg',
|
|
88
|
+
width: 300
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### vCard Contact
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
const vcard = `BEGIN:VCARD
|
|
97
|
+
VERSION:3.0
|
|
98
|
+
FN:John Doe
|
|
99
|
+
TEL:+1-555-1234
|
|
100
|
+
EMAIL:john@example.com
|
|
101
|
+
END:VCARD`;
|
|
102
|
+
|
|
103
|
+
const qr = await imgflo.generate({
|
|
104
|
+
generator: 'qr',
|
|
105
|
+
params: {
|
|
106
|
+
text: vcard,
|
|
107
|
+
width: 350,
|
|
108
|
+
errorCorrectionLevel: 'H'
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### WiFi Network
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
const wifi = 'WIFI:T:WPA;S:MyNetwork;P:MyPassword;;';
|
|
117
|
+
|
|
118
|
+
const qr = await imgflo.generate({
|
|
119
|
+
generator: 'qr',
|
|
120
|
+
params: {
|
|
121
|
+
text: wifi,
|
|
122
|
+
width: 300
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Parameters
|
|
128
|
+
|
|
129
|
+
| Parameter | Type | Default | Description |
|
|
130
|
+
|-----------|------|---------|-------------|
|
|
131
|
+
| `text` | string | *required* | Text/URL to encode |
|
|
132
|
+
| `width` | number | 300 | Output width in pixels |
|
|
133
|
+
| `errorCorrectionLevel` | 'L'\|'M'\|'Q'\|'H' | 'M' | Error correction level |
|
|
134
|
+
| `margin` | number | 4 | Margin around QR code (in modules) |
|
|
135
|
+
| `color.dark` | string | '#000000' | Dark color |
|
|
136
|
+
| `color.light` | string | '#ffffff' | Light/background color |
|
|
137
|
+
| `format` | 'png'\|'svg' | 'png' | Output format |
|
|
138
|
+
| `version` | number | auto | QR code version (1-40) |
|
|
139
|
+
| `maskPattern` | number | auto | Mask pattern (0-7) |
|
|
140
|
+
|
|
141
|
+
## Error Correction Levels
|
|
142
|
+
|
|
143
|
+
- **L (Low)**: ~7% of codewords can be restored
|
|
144
|
+
- **M (Medium)**: ~15% of codewords can be restored (default)
|
|
145
|
+
- **Q (Quartile)**: ~25% of codewords can be restored
|
|
146
|
+
- **H (High)**: ~30% of codewords can be restored
|
|
147
|
+
|
|
148
|
+
Higher error correction allows QR codes to be read even if partially damaged, but requires more data.
|
|
149
|
+
|
|
150
|
+
## Configuration
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
imgflo.registerGenerator(qr({
|
|
154
|
+
errorCorrectionLevel: 'H', // Default to high error correction
|
|
155
|
+
width: 400, // Default width
|
|
156
|
+
margin: 5, // Default margin
|
|
157
|
+
color: {
|
|
158
|
+
dark: '#000000',
|
|
159
|
+
light: '#ffffff'
|
|
160
|
+
}
|
|
161
|
+
}));
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Use Cases
|
|
165
|
+
|
|
166
|
+
### Event Tickets
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
const ticketData = JSON.stringify({
|
|
170
|
+
event: 'Concert',
|
|
171
|
+
seat: 'A12',
|
|
172
|
+
code: 'ABC123'
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
const ticket = await imgflo.generate({
|
|
176
|
+
generator: 'qr',
|
|
177
|
+
params: {
|
|
178
|
+
text: ticketData,
|
|
179
|
+
width: 300,
|
|
180
|
+
errorCorrectionLevel: 'H'
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Payment QR Codes
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
const paymentUrl = 'bitcoin:1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa?amount=0.01';
|
|
189
|
+
|
|
190
|
+
const payment = await imgflo.generate({
|
|
191
|
+
generator: 'qr',
|
|
192
|
+
params: {
|
|
193
|
+
text: paymentUrl,
|
|
194
|
+
width: 350,
|
|
195
|
+
errorCorrectionLevel: 'H'
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### App Store Links
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
const appStore = 'https://apps.apple.com/app/id123456789';
|
|
204
|
+
|
|
205
|
+
const qr = await imgflo.generate({
|
|
206
|
+
generator: 'qr',
|
|
207
|
+
params: {
|
|
208
|
+
text: appStore,
|
|
209
|
+
width: 250,
|
|
210
|
+
margin: 6
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## QR Code Library Documentation
|
|
216
|
+
|
|
217
|
+
This generator uses the qrcode library directly. For advanced options:
|
|
218
|
+
- https://github.com/soldair/node-qrcode
|
|
219
|
+
- https://github.com/soldair/node-qrcode#qr-code-options
|
|
220
|
+
|
|
221
|
+
## Performance
|
|
222
|
+
|
|
223
|
+
- **Generation time**: ~5-50ms depending on data size
|
|
224
|
+
- **Memory**: Minimal (~1-5MB)
|
|
225
|
+
- **No external dependencies**: Pure Node.js
|
|
226
|
+
|
|
227
|
+
## Limitations
|
|
228
|
+
|
|
229
|
+
- Maximum data capacity depends on QR version and error correction level
|
|
230
|
+
- QR Version 40 with Low error correction can store ~2,953 bytes
|
|
231
|
+
- Higher error correction = less data capacity
|
|
232
|
+
|
|
233
|
+
## License
|
|
234
|
+
|
|
235
|
+
MIT
|
|
236
|
+
|
|
237
|
+
## See Also
|
|
238
|
+
|
|
239
|
+
- [imgflo](https://github.com/bcooke/imgflo) - Core library
|
|
240
|
+
- [qrcode](https://github.com/soldair/node-qrcode) - QR code library
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { ImageGenerator, GeneratorSchema } from "@teamflojo/floimg";
|
|
2
|
+
/**
|
|
3
|
+
* Schema for the QR code generator
|
|
4
|
+
*/
|
|
5
|
+
export declare const qrSchema: GeneratorSchema;
|
|
6
|
+
/**
|
|
7
|
+
* QR code generator using the qrcode library
|
|
8
|
+
*
|
|
9
|
+
* This generator accepts qrcode library options directly (pass-through pattern).
|
|
10
|
+
* No imgflo abstraction - you get full qrcode library capabilities.
|
|
11
|
+
*
|
|
12
|
+
* @see https://github.com/soldair/node-qrcode - qrcode library documentation
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import createClient from '@teamflojo/floimg';
|
|
17
|
+
* import qr from '@teamflojo/floimg-qr';
|
|
18
|
+
*
|
|
19
|
+
* const floimg = createClient();
|
|
20
|
+
* floimg.registerGenerator(qr());
|
|
21
|
+
*
|
|
22
|
+
* const qrCode = await floimg.generate({
|
|
23
|
+
* generator: 'qr',
|
|
24
|
+
* params: {
|
|
25
|
+
* text: 'https://github.com/TeamFlojo/floimg',
|
|
26
|
+
* errorCorrectionLevel: 'H',
|
|
27
|
+
* width: 300
|
|
28
|
+
* }
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export interface QRConfig {
|
|
33
|
+
/** Default error correction level */
|
|
34
|
+
errorCorrectionLevel?: 'L' | 'M' | 'Q' | 'H';
|
|
35
|
+
/** Default width */
|
|
36
|
+
width?: number;
|
|
37
|
+
/** Default margin */
|
|
38
|
+
margin?: number;
|
|
39
|
+
/** Default color (dark) */
|
|
40
|
+
color?: {
|
|
41
|
+
dark?: string;
|
|
42
|
+
light?: string;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export interface QRParams extends Record<string, unknown> {
|
|
46
|
+
/** Text/URL to encode (required) */
|
|
47
|
+
text?: string;
|
|
48
|
+
/** Error correction level: L (7%), M (15%), Q (25%), H (30%) */
|
|
49
|
+
errorCorrectionLevel?: 'L' | 'M' | 'Q' | 'H';
|
|
50
|
+
/** Output width in pixels */
|
|
51
|
+
width?: number;
|
|
52
|
+
/** Margin around QR code (in modules) */
|
|
53
|
+
margin?: number;
|
|
54
|
+
/** Colors */
|
|
55
|
+
color?: {
|
|
56
|
+
/** Dark color (default: #000000) */
|
|
57
|
+
dark?: string;
|
|
58
|
+
/** Light color (default: #ffffff) */
|
|
59
|
+
light?: string;
|
|
60
|
+
};
|
|
61
|
+
/** Output format: 'png' | 'svg' */
|
|
62
|
+
format?: 'png' | 'svg';
|
|
63
|
+
/** QR code version (1-40, auto if not specified) */
|
|
64
|
+
version?: number;
|
|
65
|
+
/** Mask pattern (0-7, auto if not specified) */
|
|
66
|
+
maskPattern?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
67
|
+
/** Output quality for JPEG (0-1) */
|
|
68
|
+
quality?: number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Create a QR code generator instance
|
|
72
|
+
*/
|
|
73
|
+
export default function qr(config?: QRConfig): ImageGenerator;
|
|
74
|
+
export { qr };
|
|
75
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAa,eAAe,EAAE,MAAM,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AM,CAAC,OAAO,UAAU,EAAE,CAAC,MAAM,GAAE,QAAa,GAAG,cAAc,CA0EhE;AAGD,OAAO,EAAE,EAAE,EAAE,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import QRCode from "qrcode";
|
|
2
|
+
/**
|
|
3
|
+
* Schema for the QR code generator
|
|
4
|
+
*/
|
|
5
|
+
export const qrSchema = {
|
|
6
|
+
name: "qr",
|
|
7
|
+
description: "Generate QR codes from text or URLs",
|
|
8
|
+
category: "Utility",
|
|
9
|
+
parameters: {
|
|
10
|
+
text: {
|
|
11
|
+
type: "string",
|
|
12
|
+
title: "Content",
|
|
13
|
+
description: "Text or URL to encode in the QR code",
|
|
14
|
+
},
|
|
15
|
+
errorCorrectionLevel: {
|
|
16
|
+
type: "string",
|
|
17
|
+
title: "Error Correction",
|
|
18
|
+
description: "Error correction level: L (7%), M (15%), Q (25%), H (30%)",
|
|
19
|
+
enum: ["L", "M", "Q", "H"],
|
|
20
|
+
default: "M",
|
|
21
|
+
},
|
|
22
|
+
width: {
|
|
23
|
+
type: "number",
|
|
24
|
+
title: "Width",
|
|
25
|
+
description: "Output width in pixels",
|
|
26
|
+
default: 300,
|
|
27
|
+
minimum: 50,
|
|
28
|
+
maximum: 1000,
|
|
29
|
+
},
|
|
30
|
+
margin: {
|
|
31
|
+
type: "number",
|
|
32
|
+
title: "Margin",
|
|
33
|
+
description: "Quiet zone margin (in modules)",
|
|
34
|
+
default: 4,
|
|
35
|
+
minimum: 0,
|
|
36
|
+
maximum: 20,
|
|
37
|
+
},
|
|
38
|
+
format: {
|
|
39
|
+
type: "string",
|
|
40
|
+
title: "Output Format",
|
|
41
|
+
description: "Output image format",
|
|
42
|
+
enum: ["png", "svg"],
|
|
43
|
+
default: "png",
|
|
44
|
+
},
|
|
45
|
+
version: {
|
|
46
|
+
type: "number",
|
|
47
|
+
title: "QR Version",
|
|
48
|
+
description: "QR code version (1-40, auto if not specified)",
|
|
49
|
+
minimum: 1,
|
|
50
|
+
maximum: 40,
|
|
51
|
+
},
|
|
52
|
+
maskPattern: {
|
|
53
|
+
type: "number",
|
|
54
|
+
title: "Mask Pattern",
|
|
55
|
+
description: "Mask pattern (0-7, auto if not specified)",
|
|
56
|
+
minimum: 0,
|
|
57
|
+
maximum: 7,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
requiredParameters: ["text"],
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Create a QR code generator instance
|
|
64
|
+
*/
|
|
65
|
+
export default function qr(config = {}) {
|
|
66
|
+
const { errorCorrectionLevel: defaultErrorLevel = 'M', width: defaultWidth = 300, margin: defaultMargin = 4, color: defaultColor = { dark: '#000000', light: '#ffffff' }, } = config;
|
|
67
|
+
return {
|
|
68
|
+
name: "qr",
|
|
69
|
+
schema: qrSchema,
|
|
70
|
+
async generate(params) {
|
|
71
|
+
const { text, errorCorrectionLevel = defaultErrorLevel, width = defaultWidth, margin = defaultMargin, color = defaultColor, format = 'png', version, maskPattern, quality, } = params;
|
|
72
|
+
if (!text) {
|
|
73
|
+
throw new Error("QR code 'text' parameter is required");
|
|
74
|
+
}
|
|
75
|
+
// Build qrcode library options (pass-through)
|
|
76
|
+
const baseOptions = {
|
|
77
|
+
errorCorrectionLevel,
|
|
78
|
+
width,
|
|
79
|
+
margin,
|
|
80
|
+
color,
|
|
81
|
+
...(version && { version }),
|
|
82
|
+
...(maskPattern !== undefined && { maskPattern }),
|
|
83
|
+
};
|
|
84
|
+
// Generate QR code
|
|
85
|
+
let bytes;
|
|
86
|
+
let mime;
|
|
87
|
+
if (format === 'svg') {
|
|
88
|
+
// Generate SVG
|
|
89
|
+
const svgString = await QRCode.toString(text, {
|
|
90
|
+
...baseOptions,
|
|
91
|
+
type: 'svg',
|
|
92
|
+
});
|
|
93
|
+
bytes = Buffer.from(svgString, 'utf-8');
|
|
94
|
+
mime = 'image/svg+xml';
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
// Generate PNG
|
|
98
|
+
bytes = await QRCode.toBuffer(text, {
|
|
99
|
+
...baseOptions,
|
|
100
|
+
type: 'png',
|
|
101
|
+
});
|
|
102
|
+
mime = 'image/png';
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
bytes,
|
|
106
|
+
mime,
|
|
107
|
+
width: width,
|
|
108
|
+
height: width, // QR codes are square
|
|
109
|
+
source: "qr",
|
|
110
|
+
metadata: {
|
|
111
|
+
text,
|
|
112
|
+
errorCorrectionLevel,
|
|
113
|
+
format,
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
// Also export as named export for convenience
|
|
120
|
+
export { qr };
|
|
121
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAoB;IACvC,IAAI,EAAE,IAAI;IACV,WAAW,EAAE,qCAAqC;IAClD,QAAQ,EAAE,SAAS;IACnB,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,SAAS;YAChB,WAAW,EAAE,sCAAsC;SACpD;QACD,oBAAoB,EAAE;YACpB,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,kBAAkB;YACzB,WAAW,EAAE,2DAA2D;YACxE,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;YAC1B,OAAO,EAAE,GAAG;SACb;QACD,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,OAAO;YACd,WAAW,EAAE,wBAAwB;YACrC,OAAO,EAAE,GAAG;YACZ,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,IAAI;SACd;QACD,MAAM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ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@teamflojo/floimg-qr",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "QR code generator for floimg using qrcode library",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"floimg",
|
|
21
|
+
"qr",
|
|
22
|
+
"qrcode",
|
|
23
|
+
"barcode",
|
|
24
|
+
"image-generation"
|
|
25
|
+
],
|
|
26
|
+
"author": "Brett Cooke",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/TeamFlojo/floimg.git",
|
|
31
|
+
"directory": "packages/floimg-qr"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@teamflojo/floimg": "^0.1.0"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"qrcode": "^1.5.4"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^22.10.2",
|
|
41
|
+
"@types/qrcode": "^1.5.5",
|
|
42
|
+
"typescript": "^5.7.2",
|
|
43
|
+
"vitest": "^2.1.8",
|
|
44
|
+
"@teamflojo/floimg": "0.1.0"
|
|
45
|
+
},
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=18.0.0"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsc",
|
|
51
|
+
"dev": "tsc --watch",
|
|
52
|
+
"test": "vitest",
|
|
53
|
+
"typecheck": "tsc --noEmit",
|
|
54
|
+
"clean": "rm -rf dist"
|
|
55
|
+
}
|
|
56
|
+
}
|