qrbit 1.3.4 → 1.4.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/README.md CHANGED
@@ -17,7 +17,7 @@ A fast QR code generator with logo embedding support, built with Rust and native
17
17
  - **Cross-platform**: Works on iOS, Windows, Linux, and macOS
18
18
  - **Logo embedding**: Add custom logos to your QR codes with no need for node canvas!
19
19
  - **Customizable**: Custom colors, sizes, and margins
20
- - **Multiple formats**: Generate SVG, PNG, and JPEG outputs
20
+ - **Multiple formats**: Generate SVG, PNG, JPEG, and WebP outputs
21
21
  - **Scalable**: With caching you can also use a secondary store for persistence
22
22
  - **Well-tested**: Comprehensive test coverage with Vitest
23
23
  - **Maintained**: Actively maintained with regular updates
@@ -95,7 +95,7 @@ interface QrOptions {
95
95
 
96
96
  interface toOptions {
97
97
  cache?: boolean; // Enable/disable caching (default: true)
98
- quality?: number; // JPEG quality 1-100 (default: 90) - only for toJpg methods
98
+ quality?: number; // Quality 1-100 (default: 90) - for toJpg; reserved for toWebp
99
99
  }
100
100
  ```
101
101
 
@@ -313,6 +313,46 @@ await qr.toJpgFile("./output/qr-code.jpg", { quality: 95 });
313
313
  await qr.toJpgFile("./output/qr-code.jpg", { quality: 70, cache: false });
314
314
  ```
315
315
 
316
+ ### .toWebp(options?: toOptions)
317
+
318
+ Generate WebP QR code with optional caching. Uses high-performance SVG to WebP conversion with lossless encoding.
319
+
320
+ **Parameters:**
321
+ - `options.cache?: boolean` - Whether to use caching (default: true)
322
+ - `options.quality?: number` - Reserved for future lossy WebP support
323
+
324
+ **Returns:** Promise<Buffer> - The WebP buffer
325
+
326
+ ```javascript
327
+ const qr = new QrBit({ text: "Hello World" });
328
+ const webpBuffer = await qr.toWebp();
329
+
330
+ // Save to file
331
+ fs.writeFileSync("qr-code.webp", webpBuffer);
332
+
333
+ // Without caching
334
+ const webpNoCache = await qr.toWebp({ cache: false });
335
+ ```
336
+
337
+ ### .toWebpFile(filePath: string, options?: toOptions)
338
+
339
+ Generate WebP QR code and save it to a file. Creates directories if they don't exist.
340
+
341
+ **Parameters:**
342
+ - `filePath: string` - The file path where to save the WebP
343
+ - `options.cache?: boolean` - Whether to use caching (default: true)
344
+ - `options.quality?: number` - Reserved for future lossy WebP support
345
+
346
+ **Returns:** Promise<void>
347
+
348
+ ```javascript
349
+ const qr = new QrBit({ text: "Hello World" });
350
+ await qr.toWebpFile("./output/qr-code.webp");
351
+
352
+ // With options
353
+ await qr.toWebpFile("./output/qr-code.webp", { cache: false });
354
+ ```
355
+
316
356
  ### Static Methods
317
357
 
318
358
  #### QrBit.convertSvgToPng(svgContent: string, width?: number, height?: number)
@@ -348,6 +388,23 @@ const svg = '<svg>...</svg>';
348
388
  const jpegBuffer = QrBit.convertSvgToJpeg(svg, 400, 400, 85);
349
389
  ```
350
390
 
391
+ #### QrBit.convertSvgToWebp(svgContent: string, width?: number, height?: number, quality?: number)
392
+
393
+ Convert SVG content to WebP buffer using the native Rust implementation with lossless encoding.
394
+
395
+ **Parameters:**
396
+ - `svgContent: string` - The SVG content as a string
397
+ - `width?: number` - Optional width for the WebP output
398
+ - `height?: number` - Optional height for the WebP output
399
+ - `quality?: number` - Reserved for future lossy WebP support
400
+
401
+ **Returns:** Buffer - The WebP buffer
402
+
403
+ ```javascript
404
+ const svg = '<svg>...</svg>';
405
+ const webpBuffer = QrBit.convertSvgToWebp(svg, 400, 400);
406
+ ```
407
+
351
408
  # Benchmarks
352
409
 
353
410
  ## QR Codes SVG (No Logo)
@@ -361,19 +418,27 @@ const jpegBuffer = QrBit.convertSvgToJpeg(svg, 400, 400, 85);
361
418
  `Rust` is there for performance and when doing heavy image processing without needing node `canvas` installed. If you do not add a logo then the `Native` version is what you will get for SVG.
362
419
 
363
420
  ## QR Codes PNG (No Logo)
364
- | name | summary | ops/sec | time/op | margin | samples |
365
- |-----------------------------------------|:---------:|----------:|----------:|:--------:|----------:|
366
- | QrBit toPng (v1.0.0) | 🥇 | 2K | 647µs | ±0.68% | 2K |
367
- | QRCode toBuffer (v1.5.4) | -49% | 804 | 1ms | ±0.77% | 794 |
368
- | styled-qr-code-node toBuffer (v1.5.2) | -85% | 238 | 4ms | ±0.74% | 238 |
421
+ | name | summary | ops/sec | time/op | margin | samples |
422
+ |-----------------------------------------|:---------:|----------:|----------:|:---------:|----------:|
423
+ | QrBit toPng (v1.4.0) Cached | 🥇 | 6K | 1ms | ±12.19% | 992 |
424
+ | QrBit toPng (v1.4.0) | -52% | 3K | 1ms | ±16.23% | 899 |
425
+ | QRCode toBuffer (v1.5.4) | -92% | 437 | 2ms | ±1.23% | 428 |
426
+ | styled-qr-code-node toBuffer (v1.5.2) | -98% | 141 | 7ms | ±0.82% | 141 |
369
427
 
370
428
  ## QR Codes JPG (No Logo)
371
- | name | summary | ops/sec | time/op | margin | samples |
372
- |-----------------------------------------|:---------:|----------:|----------:|:--------:|----------:|
373
- | QrBit toJpg (v1.2.0) | 🥇 | 663 | 2ms | ±0.37% | 662 |
374
- | styled-qr-code-node toBuffer (v1.5.2) | -36% | 424 | 2ms | ±2.13% | 418 |
429
+ | name | summary | ops/sec | time/op | margin | samples |
430
+ |-----------------------------------------|:---------:|----------:|----------:|:---------:|----------:|
431
+ | QrBit toJpg (v1.4.0) | 🥇 | 1K | 3ms | ±32.99% | 372 |
432
+ | QrBit toJpg (v1.4.0) Cached | -19% | 1,000 | 3ms | ±36.82% | 367 |
433
+ | styled-qr-code-node toBuffer (v1.5.2) | -78% | 269 | 4ms | ±1.13% | 266 |
375
434
 
376
- `Rust` is used for `toPng()` and `toJpg` to optimize performance for image generation and heavy image processing without needing node `canvas` installed.
435
+ ## QR Codes WebP (No Logo)
436
+ | name | summary | ops/sec | time/op | margin | samples |
437
+ |--------------------------------|:---------:|----------:|----------:|:---------:|----------:|
438
+ | QrBit toWebp Cached (v1.4.0) | 🥇 | 7K | 911µs | ±11.27% | 1K |
439
+ | QrBit toWebp (v1.4.0) | -44% | 4K | 998µs | ±14.47% | 1K |
440
+
441
+ `Rust` is used for `toPng()`, `toJpg()`, and `toWebp()` to optimize performance for image generation and heavy image processing without needing node `canvas` installed.
377
442
 
378
443
  ## QR Codes with Embedded Logos
379
444
  | name | summary | ops/sec | time/op | margin | samples |
@@ -387,22 +452,6 @@ const jpegBuffer = QrBit.convertSvgToJpeg(svg, 400, 400, 85);
387
452
 
388
453
  `Buffer` is much slower as we have to push the stream across to the rust module. For fastest performance provide the path of the image.
389
454
 
390
- ## QR Codes SVG with Caching
391
- | name | summary | ops/sec | time/op | margin | samples |
392
- |-----------------------------------------|:---------:|----------:|----------:|:--------:|----------:|
393
- | QrBit toSvg (Native) (v1.0.0) | 🥇 | 95K | 94µs | ±2.08% | 11K |
394
- | QRCode toString (v1.5.4) | -93% | 6K | 161µs | ±0.37% | 6K |
395
- | QrBit toSvg (Rust) (v1.0.0) | -99% | 938 | 1ms | ±1.12% | 907 |
396
- | styled-qr-code-node toBuffer (v1.5.2) | -99% | 710 | 1ms | ±1.10% | 700 |
397
-
398
-
399
- ## QR Codes PNG with Caching
400
- | name | summary | ops/sec | time/op | margin | samples |
401
- |-----------------------------------------|:---------:|----------:|----------:|:--------:|----------:|
402
- | QrBit toPng (v1.0.0) | 🥇 | 13K | 584µs | ±1.84% | 2K |
403
- | QRCode toBuffer (v1.5.4) | -94% | 760 | 1ms | ±1.54% | 741 |
404
- | styled-qr-code-node toBuffer (v1.5.2) | -98% | 233 | 4ms | ±2.10% | 231 |
405
-
406
455
  # Examples
407
456
 
408
457
  The `examples/` directory contains various QR code examples showcasing different features and use cases. You can generate these examples by running:
@@ -580,7 +629,62 @@ await qr.toJpgFile("14_jpg_buffer_logo_orange.jpg", { quality: 85 });
580
629
  ```
581
630
  ![JPEG Buffer Logo Orange QR Code](examples/14_jpg_buffer_logo_orange.jpg)
582
631
 
583
- These examples demonstrate the versatility and capabilities of QrBit for generating QR codes with various customizations, from simple text encoding to complex styled codes with embedded logos, supporting SVG, PNG, and JPEG formats with quality control.
632
+ ## 15. Basic WebP
633
+ WebP format with lossless encoding.
634
+ ```javascript
635
+ const qr = new QrBit({
636
+ text: "Basic WebP QR Code",
637
+ size: 300
638
+ });
639
+ await qr.toWebpFile("15_webp_basic.webp");
640
+ ```
641
+ ![Basic WebP QR Code](examples/15_webp_basic.webp)
642
+
643
+ ## 16. WebP with Logo and Blue Theme
644
+ WebP with embedded logo and custom blue background.
645
+ ```javascript
646
+ const qr = new QrBit({
647
+ text: "WebP with Logo",
648
+ logo: "./logo.png",
649
+ size: 400,
650
+ logoSizeRatio: 0.25,
651
+ backgroundColor: "#1e3a5f",
652
+ foregroundColor: "#FFFFFF"
653
+ });
654
+ await qr.toWebpFile("16_webp_logo_blue.webp");
655
+ ```
656
+ ![WebP with Logo Blue QR Code](examples/16_webp_logo_blue.webp)
657
+
658
+ ## 17. Large WebP with Green Theme
659
+ Large WebP QR code with green color scheme.
660
+ ```javascript
661
+ const qr = new QrBit({
662
+ text: "https://github.com/jaredwray/qrbit",
663
+ size: 500,
664
+ backgroundColor: "#4CAF50",
665
+ foregroundColor: "#FFFFFF"
666
+ });
667
+ await qr.toWebpFile("17_webp_large_green.webp");
668
+ ```
669
+ ![Large WebP Green QR Code](examples/17_webp_large_green.webp)
670
+
671
+ ## 18. WebP with Buffer Logo and Purple Theme
672
+ WebP using buffer-based logo with purple background.
673
+ ```javascript
674
+ const logoBuffer = fs.readFileSync("./logo.png");
675
+ const qr = new QrBit({
676
+ text: "WebP Buffer Logo",
677
+ logo: logoBuffer,
678
+ size: 350,
679
+ logoSizeRatio: 0.2,
680
+ backgroundColor: "#9C27B0",
681
+ foregroundColor: "#FFFFFF"
682
+ });
683
+ await qr.toWebpFile("18_webp_buffer_logo_purple.webp");
684
+ ```
685
+ ![WebP Buffer Logo Purple QR Code](examples/18_webp_buffer_logo_purple.webp)
686
+
687
+ These examples demonstrate the versatility and capabilities of QrBit for generating QR codes with various customizations, from simple text encoding to complex styled codes with embedded logos, supporting SVG, PNG, JPEG, and WebP formats.
584
688
 
585
689
  ## Contributing
586
690
 
package/dist/native.cjs CHANGED
@@ -77,8 +77,8 @@ function requireNative() {
77
77
  try {
78
78
  const binding = require('qrbit-android-arm64')
79
79
  const bindingPackageVersion = require('qrbit-android-arm64/package.json').version
80
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
82
82
  }
83
83
  return binding
84
84
  } catch (e) {
@@ -93,8 +93,8 @@ function requireNative() {
93
93
  try {
94
94
  const binding = require('qrbit-android-arm-eabi')
95
95
  const bindingPackageVersion = require('qrbit-android-arm-eabi/package.json').version
96
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
98
98
  }
99
99
  return binding
100
100
  } catch (e) {
@@ -114,8 +114,8 @@ function requireNative() {
114
114
  try {
115
115
  const binding = require('qrbit-win32-x64-gnu')
116
116
  const bindingPackageVersion = require('qrbit-win32-x64-gnu/package.json').version
117
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
117
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
119
119
  }
120
120
  return binding
121
121
  } catch (e) {
@@ -130,8 +130,8 @@ function requireNative() {
130
130
  try {
131
131
  const binding = require('qrbit-win32-x64-msvc')
132
132
  const bindingPackageVersion = require('qrbit-win32-x64-msvc/package.json').version
133
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
135
135
  }
136
136
  return binding
137
137
  } catch (e) {
@@ -147,8 +147,8 @@ function requireNative() {
147
147
  try {
148
148
  const binding = require('qrbit-win32-ia32-msvc')
149
149
  const bindingPackageVersion = require('qrbit-win32-ia32-msvc/package.json').version
150
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
152
  }
153
153
  return binding
154
154
  } catch (e) {
@@ -163,8 +163,8 @@ function requireNative() {
163
163
  try {
164
164
  const binding = require('qrbit-win32-arm64-msvc')
165
165
  const bindingPackageVersion = require('qrbit-win32-arm64-msvc/package.json').version
166
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
168
168
  }
169
169
  return binding
170
170
  } catch (e) {
@@ -182,8 +182,8 @@ function requireNative() {
182
182
  try {
183
183
  const binding = require('qrbit-darwin-universal')
184
184
  const bindingPackageVersion = require('qrbit-darwin-universal/package.json').version
185
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
187
  }
188
188
  return binding
189
189
  } catch (e) {
@@ -198,8 +198,8 @@ function requireNative() {
198
198
  try {
199
199
  const binding = require('qrbit-darwin-x64')
200
200
  const bindingPackageVersion = require('qrbit-darwin-x64/package.json').version
201
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
203
  }
204
204
  return binding
205
205
  } catch (e) {
@@ -214,8 +214,8 @@ function requireNative() {
214
214
  try {
215
215
  const binding = require('qrbit-darwin-arm64')
216
216
  const bindingPackageVersion = require('qrbit-darwin-arm64/package.json').version
217
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
219
219
  }
220
220
  return binding
221
221
  } catch (e) {
@@ -234,8 +234,8 @@ function requireNative() {
234
234
  try {
235
235
  const binding = require('qrbit-freebsd-x64')
236
236
  const bindingPackageVersion = require('qrbit-freebsd-x64/package.json').version
237
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
239
  }
240
240
  return binding
241
241
  } catch (e) {
@@ -250,8 +250,8 @@ function requireNative() {
250
250
  try {
251
251
  const binding = require('qrbit-freebsd-arm64')
252
252
  const bindingPackageVersion = require('qrbit-freebsd-arm64/package.json').version
253
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
255
255
  }
256
256
  return binding
257
257
  } catch (e) {
@@ -271,8 +271,8 @@ function requireNative() {
271
271
  try {
272
272
  const binding = require('qrbit-linux-x64-musl')
273
273
  const bindingPackageVersion = require('qrbit-linux-x64-musl/package.json').version
274
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
276
  }
277
277
  return binding
278
278
  } catch (e) {
@@ -287,8 +287,8 @@ function requireNative() {
287
287
  try {
288
288
  const binding = require('qrbit-linux-x64-gnu')
289
289
  const bindingPackageVersion = require('qrbit-linux-x64-gnu/package.json').version
290
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
292
292
  }
293
293
  return binding
294
294
  } catch (e) {
@@ -305,8 +305,8 @@ function requireNative() {
305
305
  try {
306
306
  const binding = require('qrbit-linux-arm64-musl')
307
307
  const bindingPackageVersion = require('qrbit-linux-arm64-musl/package.json').version
308
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
310
  }
311
311
  return binding
312
312
  } catch (e) {
@@ -321,8 +321,8 @@ function requireNative() {
321
321
  try {
322
322
  const binding = require('qrbit-linux-arm64-gnu')
323
323
  const bindingPackageVersion = require('qrbit-linux-arm64-gnu/package.json').version
324
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
326
  }
327
327
  return binding
328
328
  } catch (e) {
@@ -339,8 +339,8 @@ function requireNative() {
339
339
  try {
340
340
  const binding = require('qrbit-linux-arm-musleabihf')
341
341
  const bindingPackageVersion = require('qrbit-linux-arm-musleabihf/package.json').version
342
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
344
  }
345
345
  return binding
346
346
  } catch (e) {
@@ -355,8 +355,8 @@ function requireNative() {
355
355
  try {
356
356
  const binding = require('qrbit-linux-arm-gnueabihf')
357
357
  const bindingPackageVersion = require('qrbit-linux-arm-gnueabihf/package.json').version
358
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
360
  }
361
361
  return binding
362
362
  } catch (e) {
@@ -373,8 +373,8 @@ function requireNative() {
373
373
  try {
374
374
  const binding = require('qrbit-linux-loong64-musl')
375
375
  const bindingPackageVersion = require('qrbit-linux-loong64-musl/package.json').version
376
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
378
  }
379
379
  return binding
380
380
  } catch (e) {
@@ -389,8 +389,8 @@ function requireNative() {
389
389
  try {
390
390
  const binding = require('qrbit-linux-loong64-gnu')
391
391
  const bindingPackageVersion = require('qrbit-linux-loong64-gnu/package.json').version
392
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
394
  }
395
395
  return binding
396
396
  } catch (e) {
@@ -407,8 +407,8 @@ function requireNative() {
407
407
  try {
408
408
  const binding = require('qrbit-linux-riscv64-musl')
409
409
  const bindingPackageVersion = require('qrbit-linux-riscv64-musl/package.json').version
410
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
412
  }
413
413
  return binding
414
414
  } catch (e) {
@@ -423,8 +423,8 @@ function requireNative() {
423
423
  try {
424
424
  const binding = require('qrbit-linux-riscv64-gnu')
425
425
  const bindingPackageVersion = require('qrbit-linux-riscv64-gnu/package.json').version
426
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
428
  }
429
429
  return binding
430
430
  } catch (e) {
@@ -440,8 +440,8 @@ function requireNative() {
440
440
  try {
441
441
  const binding = require('qrbit-linux-ppc64-gnu')
442
442
  const bindingPackageVersion = require('qrbit-linux-ppc64-gnu/package.json').version
443
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
445
  }
446
446
  return binding
447
447
  } catch (e) {
@@ -456,8 +456,8 @@ function requireNative() {
456
456
  try {
457
457
  const binding = require('qrbit-linux-s390x-gnu')
458
458
  const bindingPackageVersion = require('qrbit-linux-s390x-gnu/package.json').version
459
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
461
461
  }
462
462
  return binding
463
463
  } catch (e) {
@@ -476,8 +476,8 @@ function requireNative() {
476
476
  try {
477
477
  const binding = require('qrbit-openharmony-arm64')
478
478
  const bindingPackageVersion = require('qrbit-openharmony-arm64/package.json').version
479
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
481
  }
482
482
  return binding
483
483
  } catch (e) {
@@ -492,8 +492,8 @@ function requireNative() {
492
492
  try {
493
493
  const binding = require('qrbit-openharmony-x64')
494
494
  const bindingPackageVersion = require('qrbit-openharmony-x64/package.json').version
495
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
497
  }
498
498
  return binding
499
499
  } catch (e) {
@@ -508,8 +508,8 @@ function requireNative() {
508
508
  try {
509
509
  const binding = require('qrbit-openharmony-arm')
510
510
  const bindingPackageVersion = require('qrbit-openharmony-arm/package.json').version
511
- if (bindingPackageVersion !== '1.3.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
- throw new Error(`Native binding package version mismatch, expected 1.3.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
513
  }
514
514
  return binding
515
515
  } catch (e) {
@@ -578,5 +578,6 @@ if (!nativeBinding) {
578
578
  module.exports = nativeBinding
579
579
  module.exports.convertSvgToJpeg = nativeBinding.convertSvgToJpeg
580
580
  module.exports.convertSvgToPng = nativeBinding.convertSvgToPng
581
+ module.exports.convertSvgToWebp = nativeBinding.convertSvgToWebp
581
582
  module.exports.generateQrSvg = nativeBinding.generateQrSvg
582
583
  module.exports.generateQrSvgWithBuffer = nativeBinding.generateQrSvgWithBuffer
package/dist/native.d.cts CHANGED
@@ -4,6 +4,8 @@ export declare function convertSvgToJpeg(svgContent: string, width?: number | un
4
4
 
5
5
  export declare function convertSvgToPng(svgContent: string, width?: number | undefined | null, height?: number | undefined | null): Buffer
6
6
 
7
+ export declare function convertSvgToWebp(svgContent: string, width?: number | undefined | null, height?: number | undefined | null, quality?: number | undefined | null): Buffer
8
+
7
9
  export declare function generateQrSvg(options: QrOptions): string
8
10
 
9
11
  export declare function generateQrSvgWithBuffer(options: QrOptionsWithBuffer): string
package/dist/native.d.ts CHANGED
@@ -4,6 +4,8 @@ export declare function convertSvgToJpeg(svgContent: string, width?: number | un
4
4
 
5
5
  export declare function convertSvgToPng(svgContent: string, width?: number | undefined | null, height?: number | undefined | null): Buffer
6
6
 
7
+ export declare function convertSvgToWebp(svgContent: string, width?: number | undefined | null, height?: number | undefined | null, quality?: number | undefined | null): Buffer
8
+
7
9
  export declare function generateQrSvg(options: QrOptions): string
8
10
 
9
11
  export declare function generateQrSvgWithBuffer(options: QrOptionsWithBuffer): string