qrbit 1.1.1 → 1.3.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/dist/native.js CHANGED
@@ -81,8 +81,8 @@ function requireNative() {
81
81
  try {
82
82
  const binding = require('qrbit-android-arm64')
83
83
  const bindingPackageVersion = require('qrbit-android-arm64/package.json').version
84
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
85
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
84
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
85
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
86
86
  }
87
87
  return binding
88
88
  } catch (e) {
@@ -97,8 +97,8 @@ function requireNative() {
97
97
  try {
98
98
  const binding = require('qrbit-android-arm-eabi')
99
99
  const bindingPackageVersion = require('qrbit-android-arm-eabi/package.json').version
100
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
101
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
100
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
101
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
102
102
  }
103
103
  return binding
104
104
  } catch (e) {
@@ -109,7 +109,24 @@ function requireNative() {
109
109
  }
110
110
  } else if (process.platform === 'win32') {
111
111
  if (process.arch === 'x64') {
112
+ if (process.report?.getReport?.()?.header?.osName?.startsWith?.('MINGW')) {
113
+ try {
114
+ return require('./qrbit.win32-x64-gnu.node')
115
+ } catch (e) {
116
+ loadErrors.push(e)
117
+ }
112
118
  try {
119
+ const binding = require('qrbit-win32-x64-gnu')
120
+ const bindingPackageVersion = require('qrbit-win32-x64-gnu/package.json').version
121
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
122
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
123
+ }
124
+ return binding
125
+ } catch (e) {
126
+ loadErrors.push(e)
127
+ }
128
+ } else {
129
+ try {
113
130
  return require('./qrbit.win32-x64-msvc.node')
114
131
  } catch (e) {
115
132
  loadErrors.push(e)
@@ -117,13 +134,14 @@ function requireNative() {
117
134
  try {
118
135
  const binding = require('qrbit-win32-x64-msvc')
119
136
  const bindingPackageVersion = require('qrbit-win32-x64-msvc/package.json').version
120
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
121
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
137
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
138
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
122
139
  }
123
140
  return binding
124
141
  } catch (e) {
125
142
  loadErrors.push(e)
126
143
  }
144
+ }
127
145
  } else if (process.arch === 'ia32') {
128
146
  try {
129
147
  return require('./qrbit.win32-ia32-msvc.node')
@@ -133,8 +151,8 @@ function requireNative() {
133
151
  try {
134
152
  const binding = require('qrbit-win32-ia32-msvc')
135
153
  const bindingPackageVersion = require('qrbit-win32-ia32-msvc/package.json').version
136
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
137
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
154
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
155
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
138
156
  }
139
157
  return binding
140
158
  } catch (e) {
@@ -149,8 +167,8 @@ function requireNative() {
149
167
  try {
150
168
  const binding = require('qrbit-win32-arm64-msvc')
151
169
  const bindingPackageVersion = require('qrbit-win32-arm64-msvc/package.json').version
152
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
153
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
170
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
171
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
154
172
  }
155
173
  return binding
156
174
  } catch (e) {
@@ -168,8 +186,8 @@ function requireNative() {
168
186
  try {
169
187
  const binding = require('qrbit-darwin-universal')
170
188
  const bindingPackageVersion = require('qrbit-darwin-universal/package.json').version
171
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
172
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
189
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
190
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
173
191
  }
174
192
  return binding
175
193
  } catch (e) {
@@ -184,8 +202,8 @@ function requireNative() {
184
202
  try {
185
203
  const binding = require('qrbit-darwin-x64')
186
204
  const bindingPackageVersion = require('qrbit-darwin-x64/package.json').version
187
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
188
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
205
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
206
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
189
207
  }
190
208
  return binding
191
209
  } catch (e) {
@@ -200,8 +218,8 @@ function requireNative() {
200
218
  try {
201
219
  const binding = require('qrbit-darwin-arm64')
202
220
  const bindingPackageVersion = require('qrbit-darwin-arm64/package.json').version
203
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
204
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
221
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
222
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
205
223
  }
206
224
  return binding
207
225
  } catch (e) {
@@ -220,8 +238,8 @@ function requireNative() {
220
238
  try {
221
239
  const binding = require('qrbit-freebsd-x64')
222
240
  const bindingPackageVersion = require('qrbit-freebsd-x64/package.json').version
223
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
224
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
241
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
242
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
225
243
  }
226
244
  return binding
227
245
  } catch (e) {
@@ -236,8 +254,8 @@ function requireNative() {
236
254
  try {
237
255
  const binding = require('qrbit-freebsd-arm64')
238
256
  const bindingPackageVersion = require('qrbit-freebsd-arm64/package.json').version
239
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
240
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
257
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
258
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
241
259
  }
242
260
  return binding
243
261
  } catch (e) {
@@ -257,8 +275,8 @@ function requireNative() {
257
275
  try {
258
276
  const binding = require('qrbit-linux-x64-musl')
259
277
  const bindingPackageVersion = require('qrbit-linux-x64-musl/package.json').version
260
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
261
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
278
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
279
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
262
280
  }
263
281
  return binding
264
282
  } catch (e) {
@@ -273,8 +291,8 @@ function requireNative() {
273
291
  try {
274
292
  const binding = require('qrbit-linux-x64-gnu')
275
293
  const bindingPackageVersion = require('qrbit-linux-x64-gnu/package.json').version
276
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
277
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
294
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
295
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
278
296
  }
279
297
  return binding
280
298
  } catch (e) {
@@ -291,8 +309,8 @@ function requireNative() {
291
309
  try {
292
310
  const binding = require('qrbit-linux-arm64-musl')
293
311
  const bindingPackageVersion = require('qrbit-linux-arm64-musl/package.json').version
294
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
295
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
312
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
313
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
296
314
  }
297
315
  return binding
298
316
  } catch (e) {
@@ -307,8 +325,8 @@ function requireNative() {
307
325
  try {
308
326
  const binding = require('qrbit-linux-arm64-gnu')
309
327
  const bindingPackageVersion = require('qrbit-linux-arm64-gnu/package.json').version
310
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
311
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
328
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
329
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
312
330
  }
313
331
  return binding
314
332
  } catch (e) {
@@ -325,8 +343,8 @@ function requireNative() {
325
343
  try {
326
344
  const binding = require('qrbit-linux-arm-musleabihf')
327
345
  const bindingPackageVersion = require('qrbit-linux-arm-musleabihf/package.json').version
328
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
329
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
346
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
347
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
330
348
  }
331
349
  return binding
332
350
  } catch (e) {
@@ -341,8 +359,8 @@ function requireNative() {
341
359
  try {
342
360
  const binding = require('qrbit-linux-arm-gnueabihf')
343
361
  const bindingPackageVersion = require('qrbit-linux-arm-gnueabihf/package.json').version
344
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
345
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
362
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
363
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
346
364
  }
347
365
  return binding
348
366
  } catch (e) {
@@ -359,8 +377,8 @@ function requireNative() {
359
377
  try {
360
378
  const binding = require('qrbit-linux-loong64-musl')
361
379
  const bindingPackageVersion = require('qrbit-linux-loong64-musl/package.json').version
362
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
363
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
380
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
381
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
364
382
  }
365
383
  return binding
366
384
  } catch (e) {
@@ -375,8 +393,8 @@ function requireNative() {
375
393
  try {
376
394
  const binding = require('qrbit-linux-loong64-gnu')
377
395
  const bindingPackageVersion = require('qrbit-linux-loong64-gnu/package.json').version
378
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
379
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
396
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
397
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
380
398
  }
381
399
  return binding
382
400
  } catch (e) {
@@ -393,8 +411,8 @@ function requireNative() {
393
411
  try {
394
412
  const binding = require('qrbit-linux-riscv64-musl')
395
413
  const bindingPackageVersion = require('qrbit-linux-riscv64-musl/package.json').version
396
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
397
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
414
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
415
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
398
416
  }
399
417
  return binding
400
418
  } catch (e) {
@@ -409,8 +427,8 @@ function requireNative() {
409
427
  try {
410
428
  const binding = require('qrbit-linux-riscv64-gnu')
411
429
  const bindingPackageVersion = require('qrbit-linux-riscv64-gnu/package.json').version
412
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
413
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
430
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
431
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
414
432
  }
415
433
  return binding
416
434
  } catch (e) {
@@ -426,8 +444,8 @@ function requireNative() {
426
444
  try {
427
445
  const binding = require('qrbit-linux-ppc64-gnu')
428
446
  const bindingPackageVersion = require('qrbit-linux-ppc64-gnu/package.json').version
429
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
430
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
447
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
448
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
431
449
  }
432
450
  return binding
433
451
  } catch (e) {
@@ -442,8 +460,8 @@ function requireNative() {
442
460
  try {
443
461
  const binding = require('qrbit-linux-s390x-gnu')
444
462
  const bindingPackageVersion = require('qrbit-linux-s390x-gnu/package.json').version
445
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
446
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
463
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
464
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
447
465
  }
448
466
  return binding
449
467
  } catch (e) {
@@ -462,8 +480,8 @@ function requireNative() {
462
480
  try {
463
481
  const binding = require('qrbit-openharmony-arm64')
464
482
  const bindingPackageVersion = require('qrbit-openharmony-arm64/package.json').version
465
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
466
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
483
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
484
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
467
485
  }
468
486
  return binding
469
487
  } catch (e) {
@@ -478,8 +496,8 @@ function requireNative() {
478
496
  try {
479
497
  const binding = require('qrbit-openharmony-x64')
480
498
  const bindingPackageVersion = require('qrbit-openharmony-x64/package.json').version
481
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
482
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
499
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
500
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
483
501
  }
484
502
  return binding
485
503
  } catch (e) {
@@ -494,8 +512,8 @@ function requireNative() {
494
512
  try {
495
513
  const binding = require('qrbit-openharmony-arm')
496
514
  const bindingPackageVersion = require('qrbit-openharmony-arm/package.json').version
497
- if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
498
- throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
515
+ if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
516
+ throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
499
517
  }
500
518
  return binding
501
519
  } catch (e) {
@@ -557,10 +575,8 @@ if (!nativeBinding) {
557
575
  throw new Error(`Failed to load native binding`)
558
576
  }
559
577
 
560
- const { convertSvgToPng, generateQr, generateQrPng, generateQrPngWithBuffer, generateQrSvg, generateQrSvgWithBuffer } = nativeBinding
578
+ const { convertSvgToJpeg, convertSvgToPng, generateQrSvg, generateQrSvgWithBuffer } = nativeBinding
579
+ export { convertSvgToJpeg }
561
580
  export { convertSvgToPng }
562
- export { generateQr }
563
- export { generateQrPng }
564
- export { generateQrPngWithBuffer }
565
581
  export { generateQrSvg }
566
582
  export { generateQrSvgWithBuffer }
package/dist/qrbit.cjs CHANGED
@@ -56,10 +56,8 @@ var QrBit = class _QrBit extends import_hookified.Hookified {
56
56
  constructor(options) {
57
57
  super();
58
58
  this._napi = {
59
+ convertSvgToJpeg: import_native.convertSvgToJpeg,
59
60
  convertSvgToPng: import_native.convertSvgToPng,
60
- generateQr: import_native.generateQr,
61
- generateQrPng: import_native.generateQrPng,
62
- generateQrPngWithBuffer: import_native.generateQrPngWithBuffer,
63
61
  generateQrSvg: import_native.generateQrSvg,
64
62
  generateQrSvgWithBuffer: import_native.generateQrSvgWithBuffer
65
63
  };
@@ -322,6 +320,48 @@ var QrBit = class _QrBit extends import_hookified.Hookified {
322
320
  await import_node_fs.default.promises.mkdir(dir, { recursive: true });
323
321
  await import_node_fs.default.promises.writeFile(filePath, pngBuffer);
324
322
  }
323
+ /**
324
+ * Generate JPEG QR code with optional caching.
325
+ * Generates the QR as SVG either in rust if it has a logo or native. Then does a conversion on it.
326
+ * @param options - Generation options
327
+ * @param options.cache - Whether to use caching (default: true)
328
+ * @param options.quality - JPEG quality 1-100 (default: 90)
329
+ * @returns {Promise<Buffer>} The JPEG buffer
330
+ */
331
+ async toJpg(options) {
332
+ let result;
333
+ const quality = options?.quality ?? 90;
334
+ const renderKey = `napi-jpeg-${quality}`;
335
+ if (this._cache && options?.cache !== false) {
336
+ const key = this.generateCacheKey(renderKey);
337
+ const cached = await this._cache.get(key);
338
+ if (cached) {
339
+ return import_node_buffer.Buffer.from(cached);
340
+ }
341
+ }
342
+ const svg = await this.toSvg();
343
+ result = _QrBit.convertSvgToJpeg(svg, void 0, void 0, quality);
344
+ if (this._cache && options?.cache !== false) {
345
+ const key = this.generateCacheKey(renderKey);
346
+ await this._cache.set(key, result);
347
+ }
348
+ return result;
349
+ }
350
+ /**
351
+ * Generate JPEG QR code and save it to a file.
352
+ * Creates directories if they don't exist.
353
+ * @param filePath - The file path where to save the JPEG
354
+ * @param options - Generation options
355
+ * @param options.cache - Whether to use caching (default: true)
356
+ * @param options.quality - JPEG quality 1-100 (default: 90)
357
+ * @returns {Promise<void>} Resolves when file is written
358
+ */
359
+ async toJpgFile(filePath, options) {
360
+ const jpegBuffer = await this.toJpg(options);
361
+ const dir = import_node_path.default.dirname(filePath);
362
+ await import_node_fs.default.promises.mkdir(dir, { recursive: true });
363
+ await import_node_fs.default.promises.writeFile(filePath, jpegBuffer);
364
+ }
325
365
  /**
326
366
  * Generate SVG QR code and save it to a file.
327
367
  * Creates directories if they don't exist.
@@ -346,6 +386,17 @@ var QrBit = class _QrBit extends import_hookified.Hookified {
346
386
  static convertSvgToPng(svgContent, width, height) {
347
387
  return (0, import_native.convertSvgToPng)(svgContent, width, height);
348
388
  }
389
+ /**
390
+ * Convert SVG content to JPEG buffer using the native Rust implementation.
391
+ * @param svgContent - The SVG content as a string
392
+ * @param width - Optional width for the JPEG output
393
+ * @param height - Optional height for the JPEG output
394
+ * @param quality - Optional JPEG quality 1-100 (default: 90)
395
+ * @returns {Buffer} The JPEG buffer
396
+ */
397
+ static convertSvgToJpeg(svgContent, width, height, quality) {
398
+ return (0, import_native.convertSvgToJpeg)(svgContent, width, height, quality);
399
+ }
349
400
  /**
350
401
  * Generate a cache key based on the current QR code options.
351
402
  * @param {string} renderKey the format that you are rendering in such as `napi-png`, `native-svg`, `napi-svg`
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/qrbit.ts"],"sourcesContent":["import { Buffer } from \"node:buffer\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { Cacheable } from \"cacheable\";\nimport { Hookified, type HookifiedOptions } from \"hookified\";\nimport QRCode, { type QRCodeToStringOptions } from \"qrcode\";\nimport {\n\tconvertSvgToPng as nativeConvertSvgToPng,\n\tgenerateQr as nativeGenerateQr,\n\tgenerateQrPng as nativeGenerateQrPng,\n\tgenerateQrPngWithBuffer as nativeGenerateQrPngWithBuffer,\n\tgenerateQrSvg as nativeGenerateQrSvg,\n\tgenerateQrSvgWithBuffer as nativeGenerateQrSvgWithBuffer,\n} from \"./native.js\";\n\nexport enum QrBitEvents {\n\twarn = \"warn\",\n\tinfo = \"info\",\n\terror = \"error\",\n}\n\nconst logoFileDoesNotExistMessage = (logo: string) =>\n\t`Logo file not found: ${logo}. Proceeding without logo.`;\n\nexport type QrOptions = {\n\t/**\n\t * The text content to encode in the QR code. It can be text or a url.\n\t * @type {string}\n\t */\n\ttext: string;\n\t/**\n\t * The size of the QR code in pixels.\n\t * @type {number}\n\t * @default 200\n\t */\n\tsize?: number;\n\t/**\n\t * The margin around the QR code in pixels.\n\t * @type {number}\n\t */\n\tmargin?: number;\n\t/**\n\t * The logo to embed in the QR code.\n\t * @type {string | Buffer}\n\t */\n\tlogo?: string | Buffer;\n\t/**\n\t * The logo size ratio relative to QR code size.\n\t * @type {number}\n\t * @default 0.2\n\t */\n\tlogoSizeRatio?: number;\n\t/**\n\t * The background color of the QR code.\n\t * @type {string}\n\t * @default \"#FFFFFF\"\n\t */\n\tbackgroundColor?: string;\n\t/**\n\t * The foreground color of the QR code.\n\t * @type {string}\n\t * @default \"#000000\"\n\t */\n\tforegroundColor?: string;\n\t/**\n\t * Caching is enabled by default. You can disable it by setting this option to false. You can also pass\n\t * a custom Cacheable instance.\n\t * @type {Cacheable | boolean}\n\t * @default true\n\t */\n\tcache?: Cacheable | boolean;\n} & HookifiedOptions;\n\nexport interface QrResult {\n\tsvg?: string;\n\tpng?: Buffer;\n\twidth: number;\n\theight: number;\n}\n\nexport type toOptions = {\n\tcache?: boolean;\n};\n\n/**\n * QR code generator with logo support and caching capabilities.\n * Supports both file path and buffer-based logos with automatic optimization.\n */\nexport class QrBit extends Hookified {\n\tprivate _text: string;\n\tprivate _size: number;\n\tprivate _margin: number | undefined;\n\tprivate _logo: string | Buffer | undefined;\n\tprivate _logoSizeRatio: number;\n\tprivate _backgroundColor: string;\n\tprivate _foregroundColor: string;\n\tprivate _cache: Cacheable | undefined;\n\tprivate _napi = {\n\t\tconvertSvgToPng: nativeConvertSvgToPng,\n\t\tgenerateQr: nativeGenerateQr,\n\t\tgenerateQrPng: nativeGenerateQrPng,\n\t\tgenerateQrPngWithBuffer: nativeGenerateQrPngWithBuffer,\n\t\tgenerateQrSvg: nativeGenerateQrSvg,\n\t\tgenerateQrSvgWithBuffer: nativeGenerateQrSvgWithBuffer,\n\t};\n\n\t/**\n\t * Create a new QrBit instance.\n\t * @param options - Configuration options for the QR code\n\t */\n\tconstructor(options: QrOptions) {\n\t\tsuper();\n\t\tthis._text = options.text;\n\t\tthis._size = options.size ?? 200;\n\t\tthis._margin = options.margin ?? undefined;\n\t\tthis._logo = options.logo;\n\t\tthis._logoSizeRatio = options.logoSizeRatio ?? 0.2;\n\t\tthis._backgroundColor = options.backgroundColor ?? \"#FFFFFF\";\n\t\tthis._foregroundColor = options.foregroundColor ?? \"#000000\";\n\t\tif (options.cache !== undefined) {\n\t\t\t// if it is boolean and true then create a new cacheable instance\n\t\t\tif (options.cache === true) {\n\t\t\t\tthis._cache = new Cacheable();\n\t\t\t} else if (options.cache !== false) {\n\t\t\t\t// it is a cacheable instance\n\t\t\t\tthis._cache = options.cache as Cacheable;\n\t\t\t}\n\t\t} else {\n\t\t\tthis._cache = new Cacheable();\n\t\t}\n\n\t\t// set throwOnEmitError to true if there are no listeners\n\t\tthis.throwOnEmitError = true;\n\t}\n\n\t/**\n\t * Get the text content for the QR code.\n\t * @returns {string} The text content\n\t */\n\tpublic get text(): string {\n\t\treturn this._text;\n\t}\n\n\t/**\n\t * Set the text content for the QR code.\n\t * @param value - The text content to encode\n\t */\n\tpublic set text(value: string) {\n\t\tthis._text = value;\n\t}\n\n\t/**\n\t * Get the size of the QR code in pixels.\n\t * @returns {number} The size in pixels\n\t * @default 200\n\t */\n\tpublic get size(): number {\n\t\treturn this._size;\n\t}\n\n\t/**\n\t * Set the size of the QR code in pixels.\n\t * @param value - The size in pixels\n\t */\n\tpublic set size(value: number) {\n\t\tthis._size = value;\n\t}\n\n\t/**\n\t * Get the margin around the QR code in pixels.\n\t * @returns {number | undefined} The margin in pixels\n\t */\n\tpublic get margin(): number | undefined {\n\t\treturn this._margin;\n\t}\n\n\t/**\n\t * Set the margin around the QR code in pixels.\n\t * @param value - The margin in pixels\n\t */\n\tpublic set margin(value: number | undefined) {\n\t\tthis._margin = value;\n\t}\n\n\t/**\n\t * Get the logo path or buffer.\n\t * @returns {string | Buffer | undefined} The logo path, buffer, or undefined if no logo\n\t * @default undefined\n\t */\n\tpublic get logo(): string | Buffer | undefined {\n\t\treturn this._logo;\n\t}\n\n\t/**\n\t * Set the logo as a file path or buffer.\n\t * @param value - The logo file path, buffer, or undefined to remove logo\n\t */\n\tpublic set logo(value: string | Buffer | undefined) {\n\t\tthis._logo = value;\n\t}\n\n\t/**\n\t * Get the logo size ratio relative to QR code size.\n\t * @returns {number} The logo size ratio\n\t * @default 0.2\n\t */\n\tpublic get logoSizeRatio(): number {\n\t\treturn this._logoSizeRatio;\n\t}\n\n\t/**\n\t * Set the logo size ratio relative to QR code size.\n\t * @param value - The logo size ratio (0.0 to 1.0)\n\t */\n\tpublic set logoSizeRatio(value: number) {\n\t\tthis._logoSizeRatio = value;\n\t}\n\n\t/**\n\t * Get the background color of the QR code.\n\t * @returns {string} The background color in hex format\n\t * @default \"#FFFFFF\"\n\t */\n\tpublic get backgroundColor(): string {\n\t\treturn this._backgroundColor;\n\t}\n\n\t/**\n\t * Set the background color of the QR code.\n\t * @param value - The background color in hex format (e.g., \"#FFFFFF\")\n\t */\n\tpublic set backgroundColor(value: string) {\n\t\tthis._backgroundColor = value;\n\t}\n\n\t/**\n\t * Get the foreground color of the QR code.\n\t * @returns {string} The foreground color in hex format\n\t * @default \"#000000\"\n\t */\n\tpublic get foregroundColor(): string {\n\t\treturn this._foregroundColor;\n\t}\n\n\t/**\n\t * Set the foreground color of the QR code.\n\t * @param value - The foreground color in hex format (e.g., \"#000000\")\n\t */\n\tpublic set foregroundColor(value: string) {\n\t\tthis._foregroundColor = value;\n\t}\n\n\t/**\n\t * Get the cache instance.\n\t * @returns {Cacheable | undefined} The cache instance or undefined if caching is disabled\n\t */\n\tpublic get cache(): Cacheable | undefined {\n\t\treturn this._cache;\n\t}\n\n\t/**\n\t * Set the cache instance.\n\t * @param value - The cache instance or undefined to disable caching\n\t */\n\tpublic set cache(value: Cacheable | undefined) {\n\t\tthis._cache = value;\n\t}\n\n\t/**\n\t * Generate SVG QR code with optional caching.\n\t * Uses QRCode library for simple cases, Rust implementation for logos.\n\t * @param {toOptions} options - Generation options whether to use caching (default: true)\n\t * @returns {Promise<string>} The SVG string\n\t */\n\tpublic async toSvg(options?: toOptions): Promise<string> {\n\t\tlet result = \"\";\n\t\tlet renderKey = `native-svg`;\n\n\t\tif (this._logo) {\n\t\t\trenderKey = `napi-svg`;\n\t\t}\n\n\t\t// set all the options\n\t\tconst qrOptions = {\n\t\t\ttext: this._text,\n\t\t\tsize: this._size,\n\t\t\tmargin: this._margin,\n\t\t\tlogo: this._logo,\n\t\t\tlogoSizeRatio: this._logoSizeRatio,\n\t\t\tbackgroundColor: this._backgroundColor,\n\t\t\tforegroundColor: this._foregroundColor,\n\t\t};\n\n\t\t// check the cache\n\t\tif (this._cache && options?.cache !== false) {\n\t\t\tconst key = this.generateCacheKey(renderKey);\n\t\t\tconst cached = await this._cache.get<string>(key);\n\t\t\tif (cached) {\n\t\t\t\treturn cached;\n\t\t\t}\n\t\t}\n\n\t\tif (!this._logo) {\n\t\t\tconst qrCodeOptions: QRCodeToStringOptions = {\n\t\t\t\ttype: \"svg\",\n\t\t\t\twidth: qrOptions.size,\n\t\t\t\tcolor: {\n\t\t\t\t\tdark: qrOptions.foregroundColor,\n\t\t\t\t\tlight: qrOptions.backgroundColor,\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tresult = await QRCode.toString(this._text, qrCodeOptions);\n\t\t} else {\n\t\t\t// If logoPath is set, use the Rust implementation\n\t\t\tresult = await this.toSvgNapi();\n\t\t}\n\n\t\tif (this._cache && options?.cache !== false) {\n\t\t\t// set the cache, generate the key from hash\n\t\t\tconst key = this.generateCacheKey(renderKey);\n\t\t\t// cache the value\n\t\t\tawait this._cache.set(key, result);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Generate SVG QR code using the native Rust implementation.\n\t * Automatically chooses between file path and buffer functions.\n\t * @returns {Promise<string>} The SVG string\n\t */\n\tpublic async toSvgNapi(): Promise<string> {\n\t\t// Choose optimal path based on logo type\n\t\tif (this._logo && Buffer.isBuffer(this._logo)) {\n\t\t\t// Logo is already a buffer - use buffer function\n\t\t\tconst nativeOptionsBuffer = {\n\t\t\t\ttext: this._text,\n\t\t\t\tsize: this._size,\n\t\t\t\tmargin: this._margin,\n\t\t\t\tlogoBuffer: this._logo,\n\t\t\t\tlogoSizeRatio: this._logoSizeRatio,\n\t\t\t\tbackgroundColor: this._backgroundColor,\n\t\t\t\tforegroundColor: this._foregroundColor,\n\t\t\t};\n\t\t\treturn this._napi.generateQrSvgWithBuffer(nativeOptionsBuffer);\n\t\t} else {\n\t\t\t// Logo is a string path or undefined - use original function\n\t\t\tconst nativeOptions = {\n\t\t\t\ttext: this._text,\n\t\t\t\tsize: this._size,\n\t\t\t\tmargin: this._margin,\n\t\t\t\tlogoPath: this._logo as string,\n\t\t\t\tlogoSizeRatio: this._logoSizeRatio,\n\t\t\t\tbackgroundColor: this._backgroundColor,\n\t\t\t\tforegroundColor: this._foregroundColor,\n\t\t\t};\n\n\t\t\tif (this._logo && this.isLogoString()) {\n\t\t\t\tif (!(await this.logoFileExists(this._logo as string))) {\n\t\t\t\t\tthis.emit(\n\t\t\t\t\t\tQrBitEvents.error,\n\t\t\t\t\t\tlogoFileDoesNotExistMessage(this._logo as string),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn this._napi.generateQrSvg(nativeOptions);\n\t\t}\n\t}\n\n\t/**\n\t * Generate PNG QR code with optional caching.\n\t * Generates the QR as Svg either in rust if it has a logo or native. Then does a conversion on it.\n\t * @param options - Generation options\n\t * @param options.cache - Whether to use caching (default: true)\n\t * @returns {Promise<Buffer>} The PNG buffer\n\t */\n\tpublic async toPng(options?: toOptions): Promise<Buffer> {\n\t\tlet result: Buffer;\n\t\tconst renderKey = `napi-png`;\n\n\t\t// check the cache\n\t\tif (this._cache && options?.cache !== false) {\n\t\t\tconst key = this.generateCacheKey(renderKey);\n\t\t\tconst cached = await this._cache.get<Buffer>(key);\n\t\t\tif (cached) {\n\t\t\t\t// Ensure we return a Buffer, not Uint8Array\n\t\t\t\treturn Buffer.from(cached);\n\t\t\t}\n\t\t}\n\n\t\tconst svg = await this.toSvg();\n\t\tresult = QrBit.convertSvgToPng(svg);\n\n\t\tif (this._cache && options?.cache !== false) {\n\t\t\t// set the cache, generate the key from hash\n\t\t\tconst key = this.generateCacheKey(renderKey);\n\t\t\t// cache the value\n\t\t\tawait this._cache.set(key, result);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Generate PNG QR code and save it to a file.\n\t * Creates directories if they don't exist.\n\t * @param filePath - The file path where to save the PNG\n\t * @param options - Generation options\n\t * @param options.cache - Whether to use caching (default: true)\n\t * @returns {Promise<void>} Resolves when file is written\n\t */\n\tpublic async toPngFile(filePath: string, options?: toOptions): Promise<void> {\n\t\tconst pngBuffer = await this.toPng(options);\n\n\t\t// Create directory if it doesn't exist\n\t\tconst dir = path.dirname(filePath);\n\t\tawait fs.promises.mkdir(dir, { recursive: true });\n\n\t\tawait fs.promises.writeFile(filePath, pngBuffer);\n\t}\n\n\t/**\n\t * Generate SVG QR code and save it to a file.\n\t * Creates directories if they don't exist.\n\t * @param filePath - The file path where to save the SVG\n\t * @param options - Generation options\n\t * @param options.cache - Whether to use caching (default: true)\n\t * @returns {Promise<void>} Resolves when file is written\n\t */\n\tpublic async toSvgFile(filePath: string, options?: toOptions): Promise<void> {\n\t\tconst svgString = await this.toSvg(options);\n\n\t\t// Create directory if it doesn't exist\n\t\tconst dir = path.dirname(filePath);\n\t\tawait fs.promises.mkdir(dir, { recursive: true });\n\n\t\tawait fs.promises.writeFile(filePath, svgString, \"utf8\");\n\t}\n\n\t/**\n\t * Convert SVG content to PNG buffer using the native Rust implementation.\n\t * @param svgContent - The SVG content as a string\n\t * @param width - Optional width for the PNG output\n\t * @param height - Optional height for the PNG output\n\t * @returns {Buffer} The PNG buffer\n\t */\n\tpublic static convertSvgToPng(\n\t\tsvgContent: string,\n\t\twidth?: number,\n\t\theight?: number,\n\t): Buffer {\n\t\treturn nativeConvertSvgToPng(svgContent, width, height);\n\t}\n\n\t/**\n\t * Generate a cache key based on the current QR code options.\n\t * @param {string} renderKey the format that you are rendering in such as `napi-png`, `native-svg`, `napi-svg`\n\t * @returns {string} The cache key\n\t */\n\tpublic generateCacheKey(renderKey: string): string {\n\t\tconst qrOptions = {\n\t\t\ttext: this._text,\n\t\t\tsize: this._size,\n\t\t\tmargin: this._margin,\n\t\t\tlogo: this._logo || undefined,\n\t\t\tlogoSizeRatio: this._logoSizeRatio,\n\t\t\tbackgroundColor: this._backgroundColor,\n\t\t\tforegroundColor: this._foregroundColor,\n\t\t\trenderKey,\n\t\t};\n\n\t\tconst cache = this._cache || new Cacheable();\n\n\t\treturn cache.hash(qrOptions);\n\t}\n\n\t/**\n\t * Check if the logo is a string (file path).\n\t * @returns {boolean} True if logo is a string, false otherwise\n\t */\n\tpublic isLogoString(): boolean {\n\t\treturn typeof this._logo === \"string\";\n\t}\n\n\t/**\n\t * Check if a logo file exists at the specified path.\n\t * @param filePath - The file path to check\n\t * @returns {Promise<boolean>} True if file exists, false otherwise\n\t */\n\tpublic async logoFileExists(filePath: string): Promise<boolean> {\n\t\ttry {\n\t\t\tawait fs.promises.access(filePath, fs.constants.F_OK);\n\t\t\treturn true;\n\t\t} catch (_error) {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAuB;AACvB,qBAAe;AACf,uBAAiB;AACjB,uBAA0B;AAC1B,uBAAiD;AACjD,oBAAmD;AACnD,oBAOO;AAEA,IAAK,cAAL,kBAAKA,iBAAL;AACN,EAAAA,aAAA,UAAO;AACP,EAAAA,aAAA,UAAO;AACP,EAAAA,aAAA,WAAQ;AAHG,SAAAA;AAAA,GAAA;AAMZ,IAAM,8BAA8B,CAAC,SACpC,wBAAwB,IAAI;AAkEtB,IAAM,QAAN,MAAM,eAAc,2BAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBpC,YAAY,SAAoB;AAC/B,UAAM;AAdP,SAAQ,QAAQ;AAAA,MACf,iBAAiB,cAAAC;AAAA,MACjB,YAAY,cAAAC;AAAA,MACZ,eAAe,cAAAC;AAAA,MACf,yBAAyB,cAAAC;AAAA,MACzB,eAAe,cAAAC;AAAA,MACf,yBAAyB,cAAAC;A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R,iBAAsB,YAAY,OAAO,MAAM;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,iBAAiB,WAA2B;AAClD,UAAM,YAAY;AAAA,MACjB,MAAM,KAAK;AAAA,MACX,MAAM,KAAK;AAAA,MACX,QAAQ,KAAK;AAAA,MACb,MAAM,KAAK,SAAS;AAAA,MACpB,eAAe,KAAK;AAAA,MACpB,iBAAiB,KAAK;AAAA,MACtB,iBAAiB,KAAK;AAAA,MACtB;AAAA,IACD;AAEA,UAAM,QAAQ,KAAK,UAAU,IAAI,2BAAU;AAE3C,WAAO,MAAM,KAAK,SAAS;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,eAAwB;AAC9B,WAAO,OAAO,KAAK,UAAU;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAa,eAAe,UAAoC;AAC/D,QAAI;AACH,YAAM,eAAAQ,QAAG,SAAS,OAAO,UAAU,eAAAA,QAAG,UAAU,IAAI;AACpD,aAAO;AAAA,IACR,SAAS,QAAQ;AAChB,aAAO;AAAA,IACR;AAAA,EACD;AACD;","names":["QrBitEvents","nativeConvertSvgToPng","nativeGenerateQr","nativeGenerateQrPng","nativeGenerateQrPngWithBuffer","nativeGenerateQrSvg","nativeGenerateQrSvgWithBuffer","QRCode","path","fs"]}
1
+ {"version":3,"sources":["../src/qrbit.ts"],"sourcesContent":["import { Buffer } from \"node:buffer\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { Cacheable } from \"cacheable\";\nimport { Hookified, type HookifiedOptions } from \"hookified\";\nimport QRCode, { type QRCodeToStringOptions } from \"qrcode\";\nimport {\n\tconvertSvgToJpeg as nativeConvertSvgToJpeg,\n\tconvertSvgToPng as nativeConvertSvgToPng,\n\tgenerateQrSvg as nativeGenerateQrSvg,\n\tgenerateQrSvgWithBuffer as nativeGenerateQrSvgWithBuffer,\n} from \"./native.js\";\n\nexport enum QrBitEvents {\n\twarn = \"warn\",\n\tinfo = \"info\",\n\terror = \"error\",\n}\n\nconst logoFileDoesNotExistMessage = (logo: string) =>\n\t`Logo file not found: ${logo}. Proceeding without logo.`;\n\nexport type QrOptions = {\n\t/**\n\t * The text content to encode in the QR code. It can be text or a url.\n\t * @type {string}\n\t */\n\ttext: string;\n\t/**\n\t * The size of the QR code in pixels.\n\t * @type {number}\n\t * @default 200\n\t */\n\tsize?: number;\n\t/**\n\t * The margin around the QR code in pixels.\n\t * @type {number}\n\t */\n\tmargin?: number;\n\t/**\n\t * The logo to embed in the QR code.\n\t * @type {string | Buffer}\n\t */\n\tlogo?: string | Buffer;\n\t/**\n\t * The logo size ratio relative to QR code size.\n\t * @type {number}\n\t * @default 0.2\n\t */\n\tlogoSizeRatio?: number;\n\t/**\n\t * The background color of the QR code.\n\t * @type {string}\n\t * @default \"#FFFFFF\"\n\t */\n\tbackgroundColor?: string;\n\t/**\n\t * The foreground color of the QR code.\n\t * @type {string}\n\t * @default \"#000000\"\n\t */\n\tforegroundColor?: string;\n\t/**\n\t * Caching is enabled by default. You can disable it by setting this option to false. You can also pass\n\t * a custom Cacheable instance.\n\t * @type {Cacheable | boolean}\n\t * @default true\n\t */\n\tcache?: Cacheable | boolean;\n} & HookifiedOptions;\n\nexport interface QrResult {\n\tsvg?: string;\n\tpng?: Buffer;\n\twidth: number;\n\theight: number;\n}\n\nexport type toOptions = {\n\tcache?: boolean;\n\tquality?: number;\n};\n\n/**\n * QR code generator with logo support and caching capabilities.\n * Supports both file path and buffer-based logos with automatic optimization.\n */\nexport class QrBit extends Hookified {\n\tprivate _text: string;\n\tprivate _size: number;\n\tprivate _margin: number | undefined;\n\tprivate _logo: string | Buffer | undefined;\n\tprivate _logoSizeRatio: number;\n\tprivate _backgroundColor: string;\n\tprivate _foregroundColor: string;\n\tprivate _cache: Cacheable | undefined;\n\tprivate _napi = {\n\t\tconvertSvgToJpeg: nativeConvertSvgToJpeg,\n\t\tconvertSvgToPng: nativeConvertSvgToPng,\n\t\tgenerateQrSvg: nativeGenerateQrSvg,\n\t\tgenerateQrSvgWithBuffer: nativeGenerateQrSvgWithBuffer,\n\t};\n\n\t/**\n\t * Create a new QrBit instance.\n\t * @param options - Configuration options for the QR code\n\t */\n\tconstructor(options: QrOptions) {\n\t\tsuper();\n\t\tthis._text = options.text;\n\t\tthis._size = options.size ?? 200;\n\t\tthis._margin = options.margin ?? undefined;\n\t\tthis._logo = options.logo;\n\t\tthis._logoSizeRatio = options.logoSizeRatio ?? 0.2;\n\t\tthis._backgroundColor = options.backgroundColor ?? \"#FFFFFF\";\n\t\tthis._foregroundColor = options.foregroundColor ?? \"#000000\";\n\t\tif (options.cache !== undefined) {\n\t\t\t// if it is boolean and true then create a new cacheable instance\n\t\t\tif (options.cache === true) {\n\t\t\t\tthis._cache = new Cacheable();\n\t\t\t} else if (options.cache !== false) {\n\t\t\t\t// it is a cacheable instance\n\t\t\t\tthis._cache = options.cache as Cacheable;\n\t\t\t}\n\t\t} else {\n\t\t\tthis._cache = new Cacheable();\n\t\t}\n\n\t\t// set throwOnEmitError to true if there are no listeners\n\t\tthis.throwOnEmitError = true;\n\t}\n\n\t/**\n\t * Get the text content for the QR code.\n\t * @returns {string} The text content\n\t */\n\tpublic get text(): string {\n\t\treturn this._text;\n\t}\n\n\t/**\n\t * Set the text content for the QR code.\n\t * @param value - The text content to encode\n\t */\n\tpublic set text(value: string) {\n\t\tthis._text = value;\n\t}\n\n\t/**\n\t * Get the size of the QR code in pixels.\n\t * @returns {number} The size in pixels\n\t * @default 200\n\t */\n\tpublic get size(): number {\n\t\treturn this._size;\n\t}\n\n\t/**\n\t * Set the size of the QR code in pixels.\n\t * @param value - The size in pixels\n\t */\n\tpublic set size(value: number) {\n\t\tthis._size = value;\n\t}\n\n\t/**\n\t * Get the margin around the QR code in pixels.\n\t * @returns {number | undefined} The margin in pixels\n\t */\n\tpublic get margin(): number | undefined {\n\t\treturn this._margin;\n\t}\n\n\t/**\n\t * Set the margin around the QR code in pixels.\n\t * @param value - The margin in pixels\n\t */\n\tpublic set margin(value: number | undefined) {\n\t\tthis._margin = value;\n\t}\n\n\t/**\n\t * Get the logo path or buffer.\n\t * @returns {string | Buffer | undefined} The logo path, buffer, or undefined if no logo\n\t * @default undefined\n\t */\n\tpublic get logo(): string | Buffer | undefined {\n\t\treturn this._logo;\n\t}\n\n\t/**\n\t * Set the logo as a file path or buffer.\n\t * @param value - The logo file path, buffer, or undefined to remove logo\n\t */\n\tpublic set logo(value: string | Buffer | undefined) {\n\t\tthis._logo = value;\n\t}\n\n\t/**\n\t * Get the logo size ratio relative to QR code size.\n\t * @returns {number} The logo size ratio\n\t * @default 0.2\n\t */\n\tpublic get logoSizeRatio(): number {\n\t\treturn this._logoSizeRatio;\n\t}\n\n\t/**\n\t * Set the logo size ratio relative to QR code size.\n\t * @param value - The logo size ratio (0.0 to 1.0)\n\t */\n\tpublic set logoSizeRatio(value: number) {\n\t\tthis._logoSizeRatio = value;\n\t}\n\n\t/**\n\t * Get the background color of the QR code.\n\t * @returns {string} The background color in hex format\n\t * @default \"#FFFFFF\"\n\t */\n\tpublic get backgroundColor(): string {\n\t\treturn this._backgroundColor;\n\t}\n\n\t/**\n\t * Set the background color of the QR code.\n\t * @param value - The background color in hex format (e.g., \"#FFFFFF\")\n\t */\n\tpublic set backgroundColor(value: string) {\n\t\tthis._backgroundColor = value;\n\t}\n\n\t/**\n\t * Get the foreground color of the QR code.\n\t * @returns {string} The foreground color in hex format\n\t * @default \"#000000\"\n\t */\n\tpublic get foregroundColor(): string {\n\t\treturn this._foregroundColor;\n\t}\n\n\t/**\n\t * Set the foreground color of the QR code.\n\t * @param value - The foreground color in hex format (e.g., \"#000000\")\n\t */\n\tpublic set foregroundColor(value: string) {\n\t\tthis._foregroundColor = value;\n\t}\n\n\t/**\n\t * Get the cache instance.\n\t * @returns {Cacheable | undefined} The cache instance or undefined if caching is disabled\n\t */\n\tpublic get cache(): Cacheable | undefined {\n\t\treturn this._cache;\n\t}\n\n\t/**\n\t * Set the cache instance.\n\t * @param value - The cache instance or undefined to disable caching\n\t */\n\tpublic set cache(value: Cacheable | undefined) {\n\t\tthis._cache = value;\n\t}\n\n\t/**\n\t * Generate SVG QR code with optional caching.\n\t * Uses QRCode library for simple cases, Rust implementation for logos.\n\t * @param {toOptions} options - Generation options whether to use caching (default: true)\n\t * @returns {Promise<string>} The SVG string\n\t */\n\tpublic async toSvg(options?: toOptions): Promise<string> {\n\t\tlet result = \"\";\n\t\tlet renderKey = `native-svg`;\n\n\t\tif (this._logo) {\n\t\t\trenderKey = `napi-svg`;\n\t\t}\n\n\t\t// set all the options\n\t\tconst qrOptions = {\n\t\t\ttext: this._text,\n\t\t\tsize: this._size,\n\t\t\tmargin: this._margin,\n\t\t\tlogo: this._logo,\n\t\t\tlogoSizeRatio: this._logoSizeRatio,\n\t\t\tbackgroundColor: this._backgroundColor,\n\t\t\tforegroundColor: this._foregroundColor,\n\t\t};\n\n\t\t// check the cache\n\t\tif (this._cache && options?.cache !== false) {\n\t\t\tconst key = this.generateCacheKey(renderKey);\n\t\t\tconst cached = await this._cache.get<string>(key);\n\t\t\tif (cached) {\n\t\t\t\treturn cached;\n\t\t\t}\n\t\t}\n\n\t\tif (!this._logo) {\n\t\t\tconst qrCodeOptions: QRCodeToStringOptions = {\n\t\t\t\ttype: \"svg\",\n\t\t\t\twidth: qrOptions.size,\n\t\t\t\tcolor: {\n\t\t\t\t\tdark: qrOptions.foregroundColor,\n\t\t\t\t\tlight: qrOptions.backgroundColor,\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tresult = await QRCode.toString(this._text, qrCodeOptions);\n\t\t} else {\n\t\t\t// If logoPath is set, use the Rust implementation\n\t\t\tresult = await this.toSvgNapi();\n\t\t}\n\n\t\tif (this._cache && options?.cache !== false) {\n\t\t\t// set the cache, generate the key from hash\n\t\t\tconst key = this.generateCacheKey(renderKey);\n\t\t\t// cache the value\n\t\t\tawait this._cache.set(key, result);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Generate SVG QR code using the native Rust implementation.\n\t * Automatically chooses between file path and buffer functions.\n\t * @returns {Promise<string>} The SVG string\n\t */\n\tpublic async toSvgNapi(): Promise<string> {\n\t\t// Choose optimal path based on logo type\n\t\tif (this._logo && Buffer.isBuffer(this._logo)) {\n\t\t\t// Logo is already a buffer - use buffer function\n\t\t\tconst nativeOptionsBuffer = {\n\t\t\t\ttext: this._text,\n\t\t\t\tsize: this._size,\n\t\t\t\tmargin: this._margin,\n\t\t\t\tlogoBuffer: this._logo,\n\t\t\t\tlogoSizeRatio: this._logoSizeRatio,\n\t\t\t\tbackgroundColor: this._backgroundColor,\n\t\t\t\tforegroundColor: this._foregroundColor,\n\t\t\t};\n\t\t\treturn this._napi.generateQrSvgWithBuffer(nativeOptionsBuffer);\n\t\t} else {\n\t\t\t// Logo is a string path or undefined - use original function\n\t\t\tconst nativeOptions = {\n\t\t\t\ttext: this._text,\n\t\t\t\tsize: this._size,\n\t\t\t\tmargin: this._margin,\n\t\t\t\tlogoPath: this._logo as string,\n\t\t\t\tlogoSizeRatio: this._logoSizeRatio,\n\t\t\t\tbackgroundColor: this._backgroundColor,\n\t\t\t\tforegroundColor: this._foregroundColor,\n\t\t\t};\n\n\t\t\tif (this._logo && this.isLogoString()) {\n\t\t\t\tif (!(await this.logoFileExists(this._logo as string))) {\n\t\t\t\t\tthis.emit(\n\t\t\t\t\t\tQrBitEvents.error,\n\t\t\t\t\t\tlogoFileDoesNotExistMessage(this._logo as string),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn this._napi.generateQrSvg(nativeOptions);\n\t\t}\n\t}\n\n\t/**\n\t * Generate PNG QR code with optional caching.\n\t * Generates the QR as Svg either in rust if it has a logo or native. Then does a conversion on it.\n\t * @param options - Generation options\n\t * @param options.cache - Whether to use caching (default: true)\n\t * @returns {Promise<Buffer>} The PNG buffer\n\t */\n\tpublic async toPng(options?: toOptions): Promise<Buffer> {\n\t\tlet result: Buffer;\n\t\tconst renderKey = `napi-png`;\n\n\t\t// check the cache\n\t\tif (this._cache && options?.cache !== false) {\n\t\t\tconst key = this.generateCacheKey(renderKey);\n\t\t\tconst cached = await this._cache.get<Buffer>(key);\n\t\t\tif (cached) {\n\t\t\t\t// Ensure we return a Buffer, not Uint8Array\n\t\t\t\treturn Buffer.from(cached);\n\t\t\t}\n\t\t}\n\n\t\tconst svg = await this.toSvg();\n\t\tresult = QrBit.convertSvgToPng(svg);\n\n\t\tif (this._cache && options?.cache !== false) {\n\t\t\t// set the cache, generate the key from hash\n\t\t\tconst key = this.generateCacheKey(renderKey);\n\t\t\t// cache the value\n\t\t\tawait this._cache.set(key, result);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Generate PNG QR code and save it to a file.\n\t * Creates directories if they don't exist.\n\t * @param filePath - The file path where to save the PNG\n\t * @param options - Generation options\n\t * @param options.cache - Whether to use caching (default: true)\n\t * @returns {Promise<void>} Resolves when file is written\n\t */\n\tpublic async toPngFile(filePath: string, options?: toOptions): Promise<void> {\n\t\tconst pngBuffer = await this.toPng(options);\n\n\t\t// Create directory if it doesn't exist\n\t\tconst dir = path.dirname(filePath);\n\t\tawait fs.promises.mkdir(dir, { recursive: true });\n\n\t\tawait fs.promises.writeFile(filePath, pngBuffer);\n\t}\n\n\t/**\n\t * Generate JPEG QR code with optional caching.\n\t * Generates the QR as SVG either in rust if it has a logo or native. Then does a conversion on it.\n\t * @param options - Generation options\n\t * @param options.cache - Whether to use caching (default: true)\n\t * @param options.quality - JPEG quality 1-100 (default: 90)\n\t * @returns {Promise<Buffer>} The JPEG buffer\n\t */\n\tpublic async toJpg(options?: toOptions): Promise<Buffer> {\n\t\tlet result: Buffer;\n\t\tconst quality = options?.quality ?? 90;\n\t\tconst renderKey = `napi-jpeg-${quality}`;\n\n\t\t// check the cache\n\t\tif (this._cache && options?.cache !== false) {\n\t\t\tconst key = this.generateCacheKey(renderKey);\n\t\t\tconst cached = await this._cache.get<Buffer>(key);\n\t\t\tif (cached) {\n\t\t\t\t// Ensure we return a Buffer, not Uint8Array\n\t\t\t\treturn Buffer.from(cached);\n\t\t\t}\n\t\t}\n\n\t\tconst svg = await this.toSvg();\n\t\tresult = QrBit.convertSvgToJpeg(svg, undefined, undefined, quality);\n\n\t\tif (this._cache && options?.cache !== false) {\n\t\t\t// set the cache, generate the key from hash\n\t\t\tconst key = this.generateCacheKey(renderKey);\n\t\t\t// cache the value\n\t\t\tawait this._cache.set(key, result);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Generate JPEG QR code and save it to a file.\n\t * Creates directories if they don't exist.\n\t * @param filePath - The file path where to save the JPEG\n\t * @param options - Generation options\n\t * @param options.cache - Whether to use caching (default: true)\n\t * @param options.quality - JPEG quality 1-100 (default: 90)\n\t * @returns {Promise<void>} Resolves when file is written\n\t */\n\tpublic async toJpgFile(filePath: string, options?: toOptions): Promise<void> {\n\t\tconst jpegBuffer = await this.toJpg(options);\n\n\t\t// Create directory if it doesn't exist\n\t\tconst dir = path.dirname(filePath);\n\t\tawait fs.promises.mkdir(dir, { recursive: true });\n\n\t\tawait fs.promises.writeFile(filePath, jpegBuffer);\n\t}\n\n\t/**\n\t * Generate SVG QR code and save it to a file.\n\t * Creates directories if they don't exist.\n\t * @param filePath - The file path where to save the SVG\n\t * @param options - Generation options\n\t * @param options.cache - Whether to use caching (default: true)\n\t * @returns {Promise<void>} Resolves when file is written\n\t */\n\tpublic async toSvgFile(filePath: string, options?: toOptions): Promise<void> {\n\t\tconst svgString = await this.toSvg(options);\n\n\t\t// Create directory if it doesn't exist\n\t\tconst dir = path.dirname(filePath);\n\t\tawait fs.promises.mkdir(dir, { recursive: true });\n\n\t\tawait fs.promises.writeFile(filePath, svgString, \"utf8\");\n\t}\n\n\t/**\n\t * Convert SVG content to PNG buffer using the native Rust implementation.\n\t * @param svgContent - The SVG content as a string\n\t * @param width - Optional width for the PNG output\n\t * @param height - Optional height for the PNG output\n\t * @returns {Buffer} The PNG buffer\n\t */\n\tpublic static convertSvgToPng(\n\t\tsvgContent: string,\n\t\twidth?: number,\n\t\theight?: number,\n\t): Buffer {\n\t\treturn nativeConvertSvgToPng(svgContent, width, height);\n\t}\n\n\t/**\n\t * Convert SVG content to JPEG buffer using the native Rust implementation.\n\t * @param svgContent - The SVG content as a string\n\t * @param width - Optional width for the JPEG output\n\t * @param height - Optional height for the JPEG output\n\t * @param quality - Optional JPEG quality 1-100 (default: 90)\n\t * @returns {Buffer} The JPEG buffer\n\t */\n\tpublic static convertSvgToJpeg(\n\t\tsvgContent: string,\n\t\twidth?: number,\n\t\theight?: number,\n\t\tquality?: number,\n\t): Buffer {\n\t\treturn nativeConvertSvgToJpeg(svgContent, width, height, quality);\n\t}\n\n\t/**\n\t * Generate a cache key based on the current QR code options.\n\t * @param {string} renderKey the format that you are rendering in such as `napi-png`, `native-svg`, `napi-svg`\n\t * @returns {string} The cache key\n\t */\n\tpublic generateCacheKey(renderKey: string): string {\n\t\tconst qrOptions = {\n\t\t\ttext: this._text,\n\t\t\tsize: this._size,\n\t\t\tmargin: this._margin,\n\t\t\tlogo: this._logo || undefined,\n\t\t\tlogoSizeRatio: this._logoSizeRatio,\n\t\t\tbackgroundColor: this._backgroundColor,\n\t\t\tforegroundColor: this._foregroundColor,\n\t\t\trenderKey,\n\t\t};\n\n\t\tconst cache = this._cache || new Cacheable();\n\n\t\treturn cache.hash(qrOptions);\n\t}\n\n\t/**\n\t * Check if the logo is a string (file path).\n\t * @returns {boolean} True if logo is a string, false otherwise\n\t */\n\tpublic isLogoString(): boolean {\n\t\treturn typeof this._logo === \"string\";\n\t}\n\n\t/**\n\t * Check if a logo file exists at the specified path.\n\t * @param filePath - The file path to check\n\t * @returns {Promise<boolean>} True if file exists, false otherwise\n\t */\n\tpublic async logoFileExists(filePath: string): Promise<boolean> {\n\t\ttry {\n\t\t\tawait fs.promises.access(filePath, fs.constants.F_OK);\n\t\t\treturn true;\n\t\t} catch (_error) {\n\t\t\treturn false;\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GenerateQrSvgWithBuffer","QRCode","path","fs"]}
package/dist/qrbit.d.cts CHANGED
@@ -63,6 +63,7 @@ interface QrResult {
63
63
  }
64
64
  type toOptions = {
65
65
  cache?: boolean;
66
+ quality?: number;
66
67
  };
67
68
  /**
68
69
  * QR code generator with logo support and caching capabilities.
@@ -198,6 +199,25 @@ declare class QrBit extends Hookified {
198
199
  * @returns {Promise<void>} Resolves when file is written
199
200
  */
200
201
  toPngFile(filePath: string, options?: toOptions): Promise<void>;
202
+ /**
203
+ * Generate JPEG QR code with optional caching.
204
+ * Generates the QR as SVG either in rust if it has a logo or native. Then does a conversion on it.
205
+ * @param options - Generation options
206
+ * @param options.cache - Whether to use caching (default: true)
207
+ * @param options.quality - JPEG quality 1-100 (default: 90)
208
+ * @returns {Promise<Buffer>} The JPEG buffer
209
+ */
210
+ toJpg(options?: toOptions): Promise<Buffer>;
211
+ /**
212
+ * Generate JPEG QR code and save it to a file.
213
+ * Creates directories if they don't exist.
214
+ * @param filePath - The file path where to save the JPEG
215
+ * @param options - Generation options
216
+ * @param options.cache - Whether to use caching (default: true)
217
+ * @param options.quality - JPEG quality 1-100 (default: 90)
218
+ * @returns {Promise<void>} Resolves when file is written
219
+ */
220
+ toJpgFile(filePath: string, options?: toOptions): Promise<void>;
201
221
  /**
202
222
  * Generate SVG QR code and save it to a file.
203
223
  * Creates directories if they don't exist.
@@ -215,6 +235,15 @@ declare class QrBit extends Hookified {
215
235
  * @returns {Buffer} The PNG buffer
216
236
  */
217
237
  static convertSvgToPng(svgContent: string, width?: number, height?: number): Buffer;
238
+ /**
239
+ * Convert SVG content to JPEG buffer using the native Rust implementation.
240
+ * @param svgContent - The SVG content as a string
241
+ * @param width - Optional width for the JPEG output
242
+ * @param height - Optional height for the JPEG output
243
+ * @param quality - Optional JPEG quality 1-100 (default: 90)
244
+ * @returns {Buffer} The JPEG buffer
245
+ */
246
+ static convertSvgToJpeg(svgContent: string, width?: number, height?: number, quality?: number): Buffer;
218
247
  /**
219
248
  * Generate a cache key based on the current QR code options.
220
249
  * @param {string} renderKey the format that you are rendering in such as `napi-png`, `native-svg`, `napi-svg`
package/dist/qrbit.d.ts CHANGED
@@ -63,6 +63,7 @@ interface QrResult {
63
63
  }
64
64
  type toOptions = {
65
65
  cache?: boolean;
66
+ quality?: number;
66
67
  };
67
68
  /**
68
69
  * QR code generator with logo support and caching capabilities.
@@ -198,6 +199,25 @@ declare class QrBit extends Hookified {
198
199
  * @returns {Promise<void>} Resolves when file is written
199
200
  */
200
201
  toPngFile(filePath: string, options?: toOptions): Promise<void>;
202
+ /**
203
+ * Generate JPEG QR code with optional caching.
204
+ * Generates the QR as SVG either in rust if it has a logo or native. Then does a conversion on it.
205
+ * @param options - Generation options
206
+ * @param options.cache - Whether to use caching (default: true)
207
+ * @param options.quality - JPEG quality 1-100 (default: 90)
208
+ * @returns {Promise<Buffer>} The JPEG buffer
209
+ */
210
+ toJpg(options?: toOptions): Promise<Buffer>;
211
+ /**
212
+ * Generate JPEG QR code and save it to a file.
213
+ * Creates directories if they don't exist.
214
+ * @param filePath - The file path where to save the JPEG
215
+ * @param options - Generation options
216
+ * @param options.cache - Whether to use caching (default: true)
217
+ * @param options.quality - JPEG quality 1-100 (default: 90)
218
+ * @returns {Promise<void>} Resolves when file is written
219
+ */
220
+ toJpgFile(filePath: string, options?: toOptions): Promise<void>;
201
221
  /**
202
222
  * Generate SVG QR code and save it to a file.
203
223
  * Creates directories if they don't exist.
@@ -215,6 +235,15 @@ declare class QrBit extends Hookified {
215
235
  * @returns {Buffer} The PNG buffer
216
236
  */
217
237
  static convertSvgToPng(svgContent: string, width?: number, height?: number): Buffer;
238
+ /**
239
+ * Convert SVG content to JPEG buffer using the native Rust implementation.
240
+ * @param svgContent - The SVG content as a string
241
+ * @param width - Optional width for the JPEG output
242
+ * @param height - Optional height for the JPEG output
243
+ * @param quality - Optional JPEG quality 1-100 (default: 90)
244
+ * @returns {Buffer} The JPEG buffer
245
+ */
246
+ static convertSvgToJpeg(svgContent: string, width?: number, height?: number, quality?: number): Buffer;
218
247
  /**
219
248
  * Generate a cache key based on the current QR code options.
220
249
  * @param {string} renderKey the format that you are rendering in such as `napi-png`, `native-svg`, `napi-svg`
Binary file
Binary file