qr-generator-styled 1.0.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.
Files changed (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +438 -0
  3. package/dist/cli/index.d.ts +29 -0
  4. package/dist/cli/index.d.ts.map +1 -0
  5. package/dist/cli/index.js +126 -0
  6. package/dist/cli/index.js.map +1 -0
  7. package/dist/index.d.ts +13 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +12 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/lib/QRGenerator.d.ts +41 -0
  12. package/dist/lib/QRGenerator.d.ts.map +1 -0
  13. package/dist/lib/QRGenerator.js +107 -0
  14. package/dist/lib/QRGenerator.js.map +1 -0
  15. package/dist/lib/renderers/BackgroundRenderer.d.ts +23 -0
  16. package/dist/lib/renderers/BackgroundRenderer.d.ts.map +1 -0
  17. package/dist/lib/renderers/BackgroundRenderer.js +48 -0
  18. package/dist/lib/renderers/BackgroundRenderer.js.map +1 -0
  19. package/dist/lib/renderers/GradientRenderer.d.ts +19 -0
  20. package/dist/lib/renderers/GradientRenderer.d.ts.map +1 -0
  21. package/dist/lib/renderers/GradientRenderer.js +44 -0
  22. package/dist/lib/renderers/GradientRenderer.js.map +1 -0
  23. package/dist/lib/renderers/LogoRenderer.d.ts +23 -0
  24. package/dist/lib/renderers/LogoRenderer.d.ts.map +1 -0
  25. package/dist/lib/renderers/LogoRenderer.js +72 -0
  26. package/dist/lib/renderers/LogoRenderer.js.map +1 -0
  27. package/dist/lib/renderers/ModuleRenderer.d.ts +41 -0
  28. package/dist/lib/renderers/ModuleRenderer.d.ts.map +1 -0
  29. package/dist/lib/renderers/ModuleRenderer.js +133 -0
  30. package/dist/lib/renderers/ModuleRenderer.js.map +1 -0
  31. package/dist/lib/utils/types.d.ts +52 -0
  32. package/dist/lib/utils/types.d.ts.map +1 -0
  33. package/dist/lib/utils/types.js +29 -0
  34. package/dist/lib/utils/types.js.map +1 -0
  35. package/dist/lib/utils/validators.d.ts +11 -0
  36. package/dist/lib/utils/validators.d.ts.map +1 -0
  37. package/dist/lib/utils/validators.js +50 -0
  38. package/dist/lib/utils/validators.js.map +1 -0
  39. package/package.json +69 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Luis Yerena Sosa
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,438 @@
1
+ # 🎨 QR Generator Styled
2
+
3
+ A professional Node.js/TypeScript library for generating QR codes with advanced styling options including gradients, rounded modules, and logo support.
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![Node.js Version](https://img.shields.io/badge/node-%3E%3D14.0.0-brightgreen)](https://nodejs.org)
7
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0-blue)](https://www.typescriptlang.org/)
8
+
9
+ ## ✨ Features
10
+
11
+ - 🎨 **Customizable Styles**: Solid colors or multi-color gradients
12
+ - 🔷 **Rounded Modules**: Smooth, modern edges with radius control
13
+ - 🖼️ **Logo Support**: Add logos with circular or square backgrounds
14
+ - 📦 **Multiple Output Formats**: File, Buffer, Data URL, or Canvas
15
+ - 🛠️ **CLI & API**: Use from command line or programmatically
16
+ - ✅ **Built-in Validation**: Options validated automatically
17
+ - 🎯 **Full TypeScript Support**: Complete type definitions included
18
+ - 🔧 **Modular Architecture**: Clean, maintainable code
19
+
20
+ ## 📦 Installation
21
+
22
+ ```bash
23
+ npm install qr-generator-styled
24
+ ```
25
+
26
+ Or for global CLI usage:
27
+
28
+ ```bash
29
+ npm install -g qr-generator-styled
30
+ ```
31
+
32
+ ## 🚀 Quick Start
33
+
34
+ ### CLI Usage
35
+
36
+ ```bash
37
+ # Basic QR code
38
+ qr-styled --url "https://github.com"
39
+
40
+ # QR with gradient
41
+ qr-styled --url "https://github.com" --gradient
42
+
43
+ # QR with logo
44
+ qr-styled --url "https://github.com" --logo ./my-logo.png --out my-qr.png
45
+ ```
46
+
47
+ ### Library Usage
48
+
49
+ ```typescript
50
+ import { QRGenerator, generateQRToFile } from 'qr-generator-styled';
51
+
52
+ // Option 1: Using QRGenerator class
53
+ const generator = new QRGenerator({
54
+ url: 'https://github.com',
55
+ gradient: true,
56
+ gradientColors: '#667eea,#764ba2'
57
+ });
58
+
59
+ await generator.generateToFile('qr- output.png');
60
+
61
+ // Option 2: Using helper function
62
+ await generateQRToFile(
63
+ {
64
+ url: 'https://github.com',
65
+ color: '#2d3748'
66
+ },
67
+ 'qr-output.png'
68
+ );
69
+ ```
70
+
71
+ ## 📖 Documentation
72
+
73
+ ### Configuration Options
74
+
75
+ | Option | Type | Default | Description |
76
+ | ----------------- | --------- | ------------ | --------------------------- |
77
+ | `url` | `string` | **required** | URL or text for the QR code |
78
+ | `size` | `number` | `600` | Canvas size in pixels |
79
+ | `padding` | `number` | `40` | Padding around QR code |
80
+ | `color` | `string` | `'#000000'` | QR code color (hex format) |
81
+ | `rounded` | `boolean` | `true` | Use rounded module corners |
82
+ | `moduleRadius` | `number` | `0.35` | Corner radius (0.0 - 0.5) |
83
+ | `cornerRadius` | `number` | `60` | Background corner radius |
84
+ | `backgroundColor` | `string` | `'#ffffff'` | Background color |
85
+
86
+ #### Gradient Options
87
+
88
+ | Option | Type | Default | Description |
89
+ | ---------------- | --------- | ----------------------- | ------------------------ |
90
+ | `gradient` | `boolean` | `false` | Enable gradient |
91
+ | `gradientColors` | `string` | `'#FEDA75,#FA7E1E,...'` | Comma-separated colors |
92
+ | `gradientAngle` | `number` | `45` | Angle in degrees (0-360) |
93
+
94
+ #### Logo Options
95
+
96
+ | Option | Type | Default | Description |
97
+ | ------------- | -------------------- | ---------- | -------------------------- |
98
+ | `logo` | `string` | `''` | Logo image path or URL |
99
+ | `logoPadding` | `number` | `10` | Padding around logo |
100
+ | `logoShape` | `'circle'\|'square'` | `'circle'` | Logo background shape |
101
+ | `logoRadius` | `number` | `20` | Corner radius (for square) |
102
+
103
+ ### API Reference
104
+
105
+ #### `QRGenerator`
106
+
107
+ Main class for generating QR codes.
108
+
109
+ ```typescript
110
+ import { QRGenerator } from 'qr-generator-styled';
111
+
112
+ const generator = new QRGenerator(options);
113
+ ```
114
+
115
+ ##### Methods
116
+
117
+ ###### `generate()`
118
+
119
+ Generates QR code and returns the canvas.
120
+
121
+ ```typescript
122
+ const canvas = await generator.generate();
123
+ ```
124
+
125
+ ###### `generateToFile(outputPath)`
126
+
127
+ Generates and saves QR code to file.
128
+
129
+ ```typescript
130
+ await generator.generateToFile('output.png');
131
+ ```
132
+
133
+ ###### `generateToBuffer(format)`
134
+
135
+ Generates and returns a Buffer (useful for APIs/servers).
136
+
137
+ ```typescript
138
+ const buffer = await generator.generateToBuffer('png');
139
+ // In Express: res.type('png').send(buffer)
140
+ ```
141
+
142
+ ###### `generateToDataURL(format)`
143
+
144
+ Generates and returns a Data URL (useful for HTML).
145
+
146
+ ```typescript
147
+ const dataURL = await generator.generateToDataURL('png');
148
+ // In HTML: <img src="${dataURL}" />
149
+ ```
150
+
151
+ ###### `updateOptions(options)`
152
+
153
+ Updates generator options.
154
+
155
+ ```typescript
156
+ generator.updateOptions({ gradient: true });
157
+ await generator.generateToFile('updated.png');
158
+ ```
159
+
160
+ #### Helper Functions
161
+
162
+ ##### `generateQR(options)`
163
+
164
+ Quickly generate a QR code and return the canvas.
165
+
166
+ ```typescript
167
+ import { generateQR } from 'qr-generator-styled';
168
+
169
+ const canvas = await generateQR({ url: 'https://example.com' });
170
+ ```
171
+
172
+ ##### `generateQRToFile(options, outputPath)`
173
+
174
+ Generate and save a QR code to file.
175
+
176
+ ```typescript
177
+ import { generateQRToFile } from 'qr-generator-styled';
178
+
179
+ await generateQRToFile(
180
+ { url: 'https://example.com', gradient: true },
181
+ 'output.png'
182
+ );
183
+ ```
184
+
185
+ ## 💻 Usage Examples
186
+
187
+ ### Example 1: Instagram Gradient QR
188
+
189
+ ```typescript
190
+ const generator = new QRGenerator({
191
+ url: 'https://instagram.com/your-profile',
192
+ gradient: true,
193
+ gradientColors: '#FEDA75,#FA7E1E,#D62976,#962FBF,#4F5BD5',
194
+ gradientAngle: 45,
195
+ rounded: true
196
+ });
197
+
198
+ await generator.generateToFile('instagram-qr.png');
199
+ ```
200
+
201
+ ### Example 2: Corporate QR with Logo
202
+
203
+ ```typescript
204
+ const generator = new QRGenerator({
205
+ url: 'https://your-company.com',
206
+ color: '#1a365d',
207
+ logo: './company-logo.png',
208
+ logoShape: 'square',
209
+ logoRadius: 15,
210
+ backgroundColor: '#f7fafc'
211
+ });
212
+
213
+ await generator.generateToFile('company-qr.png');
214
+ ```
215
+
216
+ ### Example 3: QR for HTTP API
217
+
218
+ ```typescript
219
+ import express from 'express';
220
+ import { QRGenerator } from 'qr-generator-styled';
221
+
222
+ const app = express();
223
+
224
+ app.get('/qr', async (req, res) => {
225
+ const generator = new QRGenerator({
226
+ url: req.query.url,
227
+ gradient: true,
228
+ gradientColors: '#667eea,#764ba2'
229
+ });
230
+
231
+ const buffer = await generator.generateToBuffer('png');
232
+ res.type('png').send(buffer);
233
+ });
234
+
235
+ app.listen(3000);
236
+ ```
237
+
238
+ ### Example 4: Dynamic QR in Frontend
239
+
240
+ ```typescript
241
+ // In your Node.js server
242
+ app.get('/api/qr-data', async (req, res) => {
243
+ const generator = new QRGenerator({
244
+ url: 'https://example.com',
245
+ gradient: true
246
+ });
247
+
248
+ const dataURL = await generator.generateToDataURL('png');
249
+ res.json({ qrCode: dataURL });
250
+ });
251
+
252
+ // In your frontend (React, Vue, etc.)
253
+ fetch('/api/qr-data')
254
+ .then(res => res.json())
255
+ .then(data => {
256
+ document.getElementById('qr').src = data.qrCode;
257
+ });
258
+ ```
259
+
260
+ ## 🔧 CLI
261
+
262
+ ### Global Installation
263
+
264
+ ```bash
265
+ npm install -g qr-generator-styled
266
+ ```
267
+
268
+ ### Available Commands
269
+
270
+ ```bash
271
+ # Available commands
272
+ qr-styled [options]
273
+ qrgen [options] # Short alias
274
+ ```
275
+
276
+ ### CLI Examples
277
+
278
+ ```bash
279
+ # Basic QR
280
+ qr-styled --url "https://github.com"
281
+
282
+ # Custom filename
283
+ qr-styled --url "https://github.com" --out my-code.png
284
+
285
+ # QR with gradient
286
+ qr-styled --url "https://github.com" --gradient --gradientColors "#ff6b6b,#ee5a6f"
287
+
288
+ # QR with logo
289
+ qr-styled --url "https://github.com" --logo ./logo.png --logoShape square
290
+
291
+ # QR with all options
292
+ qr-styled \
293
+ --url "https://github.com" \
294
+ --size 800 \
295
+ --gradient \
296
+ --gradientColors "#667eea,#764ba2" \
297
+ --gradientAngle 90 \
298
+ --logo ./logo.png \
299
+ --logoShape circle \
300
+ --out custom-qr.png
301
+ ```
302
+
303
+ ### Help
304
+
305
+ ```bash
306
+ qr-styled --help
307
+ ```
308
+
309
+ ## 🏗️ Architecture
310
+
311
+ ```
312
+ src/
313
+ ├── index.ts # Main entry point
314
+ ├── lib/
315
+ │ ├── QRGenerator.ts # Main class
316
+ │ ├── renderers/ # Rendering modules
317
+ │ │ ├── BackgroundRenderer.ts
318
+ │ │ ├── GradientRenderer.ts
319
+ │ │ ├── ModuleRenderer.ts
320
+ │ │ └── LogoRenderer.ts
321
+ │ └── utils/ # Utilities
322
+ │ ├── types.ts
323
+ │ └── validators.ts
324
+ └── cli/
325
+ └── index.ts # Command line interface
326
+ ```
327
+
328
+ ### Design Principles
329
+
330
+ - **Separation of Concerns**: Each renderer handles a specific function
331
+ - **Composition over Inheritance**: Renderers are composed in QRGenerator
332
+ - **Input Validation**: All options validated before processing
333
+ - **Flexible API**: Supports multiple output formats
334
+ - **Clean Code**: Complete TypeScript types and documentation
335
+
336
+ ## 🧪 Included Examples
337
+
338
+ The project includes complete examples you can run:
339
+
340
+ ```bash
341
+ # Basic examples
342
+ npm run example:basic
343
+
344
+ # Programmatic usage examples
345
+ npm run example:programmatic
346
+ ```
347
+
348
+ Examples will generate files in `examples/output/` for you to review.
349
+
350
+ ## 🤝 Framework Integration
351
+
352
+ ### Express.js
353
+
354
+ ```typescript
355
+ app.get('/qr/:text', async (req, res) => {
356
+ const generator = new QRGenerator({ url: req.params.text });
357
+ const buffer = await generator.generateToBuffer();
358
+ res.type('png').send(buffer);
359
+ });
360
+ ```
361
+
362
+ ### Next.js (API Route)
363
+
364
+ ```typescript
365
+ // pages/api/qr.ts
366
+ import { QRGenerator } from 'qr-generator-styled';
367
+
368
+ export default async function handler(req, res) {
369
+ const { url } = req.query;
370
+ const generator = new QRGenerator({ url });
371
+ const buffer = await generator.generateToBuffer();
372
+
373
+ res.setHeader('Content-Type', 'image/png');
374
+ res.send(buffer);
375
+ }
376
+ ```
377
+
378
+ ### Fastify
379
+
380
+ ```typescript
381
+ fastify.get('/qr', async (request, reply) => {
382
+ const generator = new QRGenerator({ url: request.query.url });
383
+ const buffer = await generator.generateToBuffer();
384
+
385
+ reply.type('image/png').send(buffer);
386
+ });
387
+ ```
388
+
389
+ ## 🛠️ Development
390
+
391
+ ### Build
392
+
393
+ ```bash
394
+ npm run build
395
+ ```
396
+
397
+ ### Development Mode
398
+
399
+ ```bash
400
+ npm run dev -- --url "https://example.com"
401
+ ```
402
+
403
+ ### Run Examples
404
+
405
+ ```bash
406
+ npm run example:basic
407
+ npm run example:programmatic
408
+ ```
409
+
410
+ ## 📄 License
411
+
412
+ MIT © Luis Yerena Sosa
413
+
414
+ ## 🙏 Contributing
415
+
416
+ Contributions are welcome! Please:
417
+
418
+ 1. Fork the project
419
+ 2. Create a feature branch (`git checkout -b feature/AmazingFeature`)
420
+ 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
421
+ 4. Push to the branch (`git push origin feature/AmazingFeature`)
422
+ 5. Open a Pull Request
423
+
424
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for more details.
425
+
426
+ ## 🐛 Report Issues
427
+
428
+ If you find a bug or have a suggestion, please [open an issue](https://github.com/Luisma92/qr-generator-styled/issues).
429
+
430
+ ## 📚 Resources
431
+
432
+ - [QRCode Documentation](https://github.com/soldair/node-qrcode)
433
+ - [Canvas API](https://github.com/Automattic/node-canvas)
434
+ - [QR Code Specification](https://www.qrcode.com/en/about/)
435
+
436
+ ---
437
+
438
+ **⭐ If you find this project useful, consider giving it a star on GitHub!**
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ import yargs from 'yargs';
3
+ interface CLIArguments {
4
+ url: string;
5
+ out: string;
6
+ size: number;
7
+ color: string;
8
+ logo: string;
9
+ rounded: boolean;
10
+ moduleRadius: number;
11
+ logoPadding: number;
12
+ logoShape: 'circle' | 'square';
13
+ logoRadius: number;
14
+ gradient: boolean;
15
+ gradientColors: string;
16
+ gradientAngle: number;
17
+ padding: number;
18
+ cornerRadius: number;
19
+ }
20
+ /**
21
+ * CLI argument parser configuration
22
+ */
23
+ export declare function buildCLI(): yargs.Argv<CLIArguments>;
24
+ /**
25
+ * Executes the CLI command
26
+ */
27
+ export declare function runCLI(): Promise<void>;
28
+ export {};
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,UAAU,YAAY;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,QAAQ,IA2FP,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CACxC;AAED;;GAEG;AACH,wBAAsB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAkB5C"}
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env node
2
+ import yargs from 'yargs';
3
+ import { hideBin } from 'yargs/helpers';
4
+ import { QRGenerator } from '../lib/QRGenerator.js';
5
+ import chalk from 'chalk';
6
+ /**
7
+ * CLI argument parser configuration
8
+ */
9
+ export function buildCLI() {
10
+ return yargs(hideBin(process.argv))
11
+ .usage('Usage: $0 --url <text> [options]')
12
+ .option('url', {
13
+ type: 'string',
14
+ demandOption: true,
15
+ describe: 'URL or text for the QR code',
16
+ alias: 'u'
17
+ })
18
+ .option('out', {
19
+ type: 'string',
20
+ default: 'qr.png',
21
+ describe: 'Output file path',
22
+ alias: 'o'
23
+ })
24
+ .option('size', {
25
+ type: 'number',
26
+ default: 600,
27
+ describe: 'Canvas size in pixels'
28
+ })
29
+ .option('color', {
30
+ type: 'string',
31
+ default: '#000000',
32
+ describe: 'QR code color (hex format)',
33
+ alias: 'c'
34
+ })
35
+ .option('logo', {
36
+ type: 'string',
37
+ default: '',
38
+ describe: 'Logo image path or URL',
39
+ alias: 'l'
40
+ })
41
+ .option('rounded', {
42
+ type: 'boolean',
43
+ default: true,
44
+ describe: 'Use rounded module corners'
45
+ })
46
+ .option('moduleRadius', {
47
+ type: 'number',
48
+ default: 0.35,
49
+ describe: 'Module corner radius (0.0 - 0.5)'
50
+ })
51
+ .option('logoPadding', {
52
+ type: 'number',
53
+ default: 10,
54
+ describe: 'Padding around logo'
55
+ })
56
+ .option('logoShape', {
57
+ type: 'string',
58
+ default: 'circle',
59
+ choices: ['circle', 'square'],
60
+ describe: 'Logo background shape'
61
+ })
62
+ .option('logoRadius', {
63
+ type: 'number',
64
+ default: 20,
65
+ describe: 'Corner radius for square logo background'
66
+ })
67
+ .option('gradient', {
68
+ type: 'boolean',
69
+ default: false,
70
+ describe: 'Use gradient colors',
71
+ alias: 'g'
72
+ })
73
+ .option('gradientColors', {
74
+ type: 'string',
75
+ default: '#FEDA75,#FA7E1E,#D62976,#962FBF,#4F5BD5',
76
+ describe: 'Comma-separated gradient colors'
77
+ })
78
+ .option('gradientAngle', {
79
+ type: 'number',
80
+ default: 45,
81
+ describe: 'Gradient angle in degrees (0-360)'
82
+ })
83
+ .option('padding', {
84
+ type: 'number',
85
+ default: 40,
86
+ describe: 'Padding around QR code'
87
+ })
88
+ .option('cornerRadius', {
89
+ type: 'number',
90
+ default: 60,
91
+ describe: 'Background corner radius'
92
+ })
93
+ .example('$0 --url "https://example.com"', 'Generate basic QR code')
94
+ .example('$0 --url "https://example.com" --gradient', 'QR with gradient')
95
+ .example('$0 --url "https://example.com" --logo ./logo.png', 'QR with logo')
96
+ .help('h')
97
+ .alias('h', 'help')
98
+ .version()
99
+ .alias('v', 'version')
100
+ .strict();
101
+ }
102
+ /**
103
+ * Executes the CLI command
104
+ */
105
+ export async function runCLI() {
106
+ try {
107
+ const argv = await buildCLI().argv;
108
+ // Extract output path and create options object for generator
109
+ const { out, ...options } = argv;
110
+ console.log(chalk.blue('🔄 Generating QR code...'));
111
+ const generator = new QRGenerator(options);
112
+ await generator.generateToFile(out);
113
+ console.log(chalk.green(`✅ QR code generated successfully: ${out}`));
114
+ }
115
+ catch (error) {
116
+ const errorMessage = error instanceof Error ? error.message : String(error);
117
+ console.error(chalk.red('❌ Error generating QR code:'), errorMessage);
118
+ process.exit(1);
119
+ }
120
+ }
121
+ // Run CLI if this file is executed directly
122
+ const isMainModule = process.argv[1] === new URL(import.meta.url).pathname;
123
+ if (isMainModule) {
124
+ runCLI();
125
+ }
126
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,MAAM,OAAO,CAAC;AAoB1B;;GAEG;AACH,MAAM,UAAU,QAAQ;IACtB,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAChC,KAAK,CAAC,kCAAkC,CAAC;SACzC,MAAM,CAAC,KAAK,EAAE;QACb,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,6BAA6B;QACvC,KAAK,EAAE,GAAG;KACX,CAAC;SACD,MAAM,CAAC,KAAK,EAAE;QACb,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,QAAQ;QACjB,QAAQ,EAAE,kBAAkB;QAC5B,KAAK,EAAE,GAAG;KACX,CAAC;SACD,MAAM,CAAC,MAAM,EAAE;QACd,IAAI,E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AAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,6BAA6B,CAAC,EAAE,YAAY,CAAC,CAAC;QACtE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,4CAA4C;AAC5C,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;AAC3E,IAAI,YAAY,EAAE,CAAC;IACjB,MAAM,EAAE,CAAC;AACX,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @module qr-generator-styled
3
+ * @description A professional QR code generator library with advanced styling options
4
+ */
5
+ export { QRGenerator, generateQR, generateQRToFile } from './lib/QRGenerator.js';
6
+ export { DEFAULT_OPTIONS, VALID_LOGO_SHAPES, VALID_ERROR_CORRECTION_LEVELS } from './lib/utils/types.js';
7
+ export type { QROptions, LogoShape, ErrorCorrectionLevel } from './lib/utils/types.js';
8
+ export { validateOptions, normalizeOptions } from './lib/utils/validators.js';
9
+ export { BackgroundRenderer } from './lib/renderers/BackgroundRenderer.js';
10
+ export { GradientRenderer } from './lib/renderers/GradientRenderer.js';
11
+ export { ModuleRenderer } from './lib/renderers/ModuleRenderer.js';
12
+ export { LogoRenderer } from './lib/renderers/LogoRenderer.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,WAAW,EACX,UAAU,EACV,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,6BAA6B,EAC9B,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACV,SAAS,EACT,SAAS,EACT,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @module qr-generator-styled
3
+ * @description A professional QR code generator library with advanced styling options
4
+ */
5
+ export { QRGenerator, generateQR, generateQRToFile } from './lib/QRGenerator.js';
6
+ export { DEFAULT_OPTIONS, VALID_LOGO_SHAPES, VALID_ERROR_CORRECTION_LEVELS } from './lib/utils/types.js';
7
+ export { validateOptions, normalizeOptions } from './lib/utils/validators.js';
8
+ export { BackgroundRenderer } from './lib/renderers/BackgroundRenderer.js';
9
+ export { GradientRenderer } from './lib/renderers/GradientRenderer.js';
10
+ export { ModuleRenderer } from './lib/renderers/ModuleRenderer.js';
11
+ export { LogoRenderer } from './lib/renderers/LogoRenderer.js';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,WAAW,EACX,UAAU,EACV,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,6BAA6B,EAC9B,MAAM,sBAAsB,CAAC;AAQ9B,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC"}