qrbit 1.3.3 → 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 +133 -29
- package/dist/native.cjs +59 -54
- package/dist/native.d.cts +2 -0
- package/dist/native.d.ts +2 -0
- package/dist/native.js +60 -55
- package/dist/qrbit.cjs +58 -2
- package/dist/qrbit.cjs.map +1 -1
- package/dist/qrbit.d.cts +30 -0
- package/dist/qrbit.d.ts +30 -0
- package/dist/qrbit.darwin-arm64.node +0 -0
- package/dist/qrbit.darwin-x64.node +0 -0
- package/dist/qrbit.js +59 -2
- package/dist/qrbit.js.map +1 -1
- package/dist/qrbit.linux-x64-gnu.node +0 -0
- package/dist/qrbit.linux-x64-musl.node +0 -0
- package/dist/qrbit.win32-x64-msvc.node +0 -0
- package/package.json +10 -9
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.
|
|
85
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
84
|
+
if (bindingPackageVersion !== '1.4.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.4.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.
|
|
101
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
100
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
102
102
|
}
|
|
103
103
|
return binding
|
|
104
104
|
} catch (e) {
|
|
@@ -118,8 +118,8 @@ function requireNative() {
|
|
|
118
118
|
try {
|
|
119
119
|
const binding = require('qrbit-win32-x64-gnu')
|
|
120
120
|
const bindingPackageVersion = require('qrbit-win32-x64-gnu/package.json').version
|
|
121
|
-
if (bindingPackageVersion !== '1.
|
|
122
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
121
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
123
123
|
}
|
|
124
124
|
return binding
|
|
125
125
|
} catch (e) {
|
|
@@ -134,8 +134,8 @@ function requireNative() {
|
|
|
134
134
|
try {
|
|
135
135
|
const binding = require('qrbit-win32-x64-msvc')
|
|
136
136
|
const bindingPackageVersion = require('qrbit-win32-x64-msvc/package.json').version
|
|
137
|
-
if (bindingPackageVersion !== '1.
|
|
138
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
137
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
139
139
|
}
|
|
140
140
|
return binding
|
|
141
141
|
} catch (e) {
|
|
@@ -151,8 +151,8 @@ function requireNative() {
|
|
|
151
151
|
try {
|
|
152
152
|
const binding = require('qrbit-win32-ia32-msvc')
|
|
153
153
|
const bindingPackageVersion = require('qrbit-win32-ia32-msvc/package.json').version
|
|
154
|
-
if (bindingPackageVersion !== '1.
|
|
155
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
154
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
156
156
|
}
|
|
157
157
|
return binding
|
|
158
158
|
} catch (e) {
|
|
@@ -167,8 +167,8 @@ function requireNative() {
|
|
|
167
167
|
try {
|
|
168
168
|
const binding = require('qrbit-win32-arm64-msvc')
|
|
169
169
|
const bindingPackageVersion = require('qrbit-win32-arm64-msvc/package.json').version
|
|
170
|
-
if (bindingPackageVersion !== '1.
|
|
171
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
170
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
172
172
|
}
|
|
173
173
|
return binding
|
|
174
174
|
} catch (e) {
|
|
@@ -186,8 +186,8 @@ function requireNative() {
|
|
|
186
186
|
try {
|
|
187
187
|
const binding = require('qrbit-darwin-universal')
|
|
188
188
|
const bindingPackageVersion = require('qrbit-darwin-universal/package.json').version
|
|
189
|
-
if (bindingPackageVersion !== '1.
|
|
190
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
189
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
191
191
|
}
|
|
192
192
|
return binding
|
|
193
193
|
} catch (e) {
|
|
@@ -202,8 +202,8 @@ function requireNative() {
|
|
|
202
202
|
try {
|
|
203
203
|
const binding = require('qrbit-darwin-x64')
|
|
204
204
|
const bindingPackageVersion = require('qrbit-darwin-x64/package.json').version
|
|
205
|
-
if (bindingPackageVersion !== '1.
|
|
206
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
205
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
207
207
|
}
|
|
208
208
|
return binding
|
|
209
209
|
} catch (e) {
|
|
@@ -218,8 +218,8 @@ function requireNative() {
|
|
|
218
218
|
try {
|
|
219
219
|
const binding = require('qrbit-darwin-arm64')
|
|
220
220
|
const bindingPackageVersion = require('qrbit-darwin-arm64/package.json').version
|
|
221
|
-
if (bindingPackageVersion !== '1.
|
|
222
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
221
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
223
223
|
}
|
|
224
224
|
return binding
|
|
225
225
|
} catch (e) {
|
|
@@ -238,8 +238,8 @@ function requireNative() {
|
|
|
238
238
|
try {
|
|
239
239
|
const binding = require('qrbit-freebsd-x64')
|
|
240
240
|
const bindingPackageVersion = require('qrbit-freebsd-x64/package.json').version
|
|
241
|
-
if (bindingPackageVersion !== '1.
|
|
242
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
241
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
243
243
|
}
|
|
244
244
|
return binding
|
|
245
245
|
} catch (e) {
|
|
@@ -254,8 +254,8 @@ function requireNative() {
|
|
|
254
254
|
try {
|
|
255
255
|
const binding = require('qrbit-freebsd-arm64')
|
|
256
256
|
const bindingPackageVersion = require('qrbit-freebsd-arm64/package.json').version
|
|
257
|
-
if (bindingPackageVersion !== '1.
|
|
258
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
257
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
259
259
|
}
|
|
260
260
|
return binding
|
|
261
261
|
} catch (e) {
|
|
@@ -275,8 +275,8 @@ function requireNative() {
|
|
|
275
275
|
try {
|
|
276
276
|
const binding = require('qrbit-linux-x64-musl')
|
|
277
277
|
const bindingPackageVersion = require('qrbit-linux-x64-musl/package.json').version
|
|
278
|
-
if (bindingPackageVersion !== '1.
|
|
279
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
278
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
280
280
|
}
|
|
281
281
|
return binding
|
|
282
282
|
} catch (e) {
|
|
@@ -291,8 +291,8 @@ function requireNative() {
|
|
|
291
291
|
try {
|
|
292
292
|
const binding = require('qrbit-linux-x64-gnu')
|
|
293
293
|
const bindingPackageVersion = require('qrbit-linux-x64-gnu/package.json').version
|
|
294
|
-
if (bindingPackageVersion !== '1.
|
|
295
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
294
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
296
296
|
}
|
|
297
297
|
return binding
|
|
298
298
|
} catch (e) {
|
|
@@ -309,8 +309,8 @@ function requireNative() {
|
|
|
309
309
|
try {
|
|
310
310
|
const binding = require('qrbit-linux-arm64-musl')
|
|
311
311
|
const bindingPackageVersion = require('qrbit-linux-arm64-musl/package.json').version
|
|
312
|
-
if (bindingPackageVersion !== '1.
|
|
313
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
312
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
314
314
|
}
|
|
315
315
|
return binding
|
|
316
316
|
} catch (e) {
|
|
@@ -325,8 +325,8 @@ function requireNative() {
|
|
|
325
325
|
try {
|
|
326
326
|
const binding = require('qrbit-linux-arm64-gnu')
|
|
327
327
|
const bindingPackageVersion = require('qrbit-linux-arm64-gnu/package.json').version
|
|
328
|
-
if (bindingPackageVersion !== '1.
|
|
329
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
328
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
330
330
|
}
|
|
331
331
|
return binding
|
|
332
332
|
} catch (e) {
|
|
@@ -343,8 +343,8 @@ function requireNative() {
|
|
|
343
343
|
try {
|
|
344
344
|
const binding = require('qrbit-linux-arm-musleabihf')
|
|
345
345
|
const bindingPackageVersion = require('qrbit-linux-arm-musleabihf/package.json').version
|
|
346
|
-
if (bindingPackageVersion !== '1.
|
|
347
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
346
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
348
348
|
}
|
|
349
349
|
return binding
|
|
350
350
|
} catch (e) {
|
|
@@ -359,8 +359,8 @@ function requireNative() {
|
|
|
359
359
|
try {
|
|
360
360
|
const binding = require('qrbit-linux-arm-gnueabihf')
|
|
361
361
|
const bindingPackageVersion = require('qrbit-linux-arm-gnueabihf/package.json').version
|
|
362
|
-
if (bindingPackageVersion !== '1.
|
|
363
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
362
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
364
364
|
}
|
|
365
365
|
return binding
|
|
366
366
|
} catch (e) {
|
|
@@ -377,8 +377,8 @@ function requireNative() {
|
|
|
377
377
|
try {
|
|
378
378
|
const binding = require('qrbit-linux-loong64-musl')
|
|
379
379
|
const bindingPackageVersion = require('qrbit-linux-loong64-musl/package.json').version
|
|
380
|
-
if (bindingPackageVersion !== '1.
|
|
381
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
380
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
382
382
|
}
|
|
383
383
|
return binding
|
|
384
384
|
} catch (e) {
|
|
@@ -393,8 +393,8 @@ function requireNative() {
|
|
|
393
393
|
try {
|
|
394
394
|
const binding = require('qrbit-linux-loong64-gnu')
|
|
395
395
|
const bindingPackageVersion = require('qrbit-linux-loong64-gnu/package.json').version
|
|
396
|
-
if (bindingPackageVersion !== '1.
|
|
397
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
396
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
398
398
|
}
|
|
399
399
|
return binding
|
|
400
400
|
} catch (e) {
|
|
@@ -411,8 +411,8 @@ function requireNative() {
|
|
|
411
411
|
try {
|
|
412
412
|
const binding = require('qrbit-linux-riscv64-musl')
|
|
413
413
|
const bindingPackageVersion = require('qrbit-linux-riscv64-musl/package.json').version
|
|
414
|
-
if (bindingPackageVersion !== '1.
|
|
415
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
414
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
416
416
|
}
|
|
417
417
|
return binding
|
|
418
418
|
} catch (e) {
|
|
@@ -427,8 +427,8 @@ function requireNative() {
|
|
|
427
427
|
try {
|
|
428
428
|
const binding = require('qrbit-linux-riscv64-gnu')
|
|
429
429
|
const bindingPackageVersion = require('qrbit-linux-riscv64-gnu/package.json').version
|
|
430
|
-
if (bindingPackageVersion !== '1.
|
|
431
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
430
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
432
432
|
}
|
|
433
433
|
return binding
|
|
434
434
|
} catch (e) {
|
|
@@ -444,8 +444,8 @@ function requireNative() {
|
|
|
444
444
|
try {
|
|
445
445
|
const binding = require('qrbit-linux-ppc64-gnu')
|
|
446
446
|
const bindingPackageVersion = require('qrbit-linux-ppc64-gnu/package.json').version
|
|
447
|
-
if (bindingPackageVersion !== '1.
|
|
448
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
447
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
449
449
|
}
|
|
450
450
|
return binding
|
|
451
451
|
} catch (e) {
|
|
@@ -460,8 +460,8 @@ function requireNative() {
|
|
|
460
460
|
try {
|
|
461
461
|
const binding = require('qrbit-linux-s390x-gnu')
|
|
462
462
|
const bindingPackageVersion = require('qrbit-linux-s390x-gnu/package.json').version
|
|
463
|
-
if (bindingPackageVersion !== '1.
|
|
464
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
463
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
465
465
|
}
|
|
466
466
|
return binding
|
|
467
467
|
} catch (e) {
|
|
@@ -480,8 +480,8 @@ function requireNative() {
|
|
|
480
480
|
try {
|
|
481
481
|
const binding = require('qrbit-openharmony-arm64')
|
|
482
482
|
const bindingPackageVersion = require('qrbit-openharmony-arm64/package.json').version
|
|
483
|
-
if (bindingPackageVersion !== '1.
|
|
484
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
483
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
485
485
|
}
|
|
486
486
|
return binding
|
|
487
487
|
} catch (e) {
|
|
@@ -496,8 +496,8 @@ function requireNative() {
|
|
|
496
496
|
try {
|
|
497
497
|
const binding = require('qrbit-openharmony-x64')
|
|
498
498
|
const bindingPackageVersion = require('qrbit-openharmony-x64/package.json').version
|
|
499
|
-
if (bindingPackageVersion !== '1.
|
|
500
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
499
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
501
501
|
}
|
|
502
502
|
return binding
|
|
503
503
|
} catch (e) {
|
|
@@ -512,8 +512,8 @@ function requireNative() {
|
|
|
512
512
|
try {
|
|
513
513
|
const binding = require('qrbit-openharmony-arm')
|
|
514
514
|
const bindingPackageVersion = require('qrbit-openharmony-arm/package.json').version
|
|
515
|
-
if (bindingPackageVersion !== '1.
|
|
516
|
-
throw new Error(`Native binding package version mismatch, expected 1.
|
|
515
|
+
if (bindingPackageVersion !== '1.4.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.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
517
517
|
}
|
|
518
518
|
return binding
|
|
519
519
|
} catch (e) {
|
|
@@ -540,13 +540,17 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
|
540
540
|
wasiBindingError = err
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
|
-
if (!nativeBinding) {
|
|
543
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
544
544
|
try {
|
|
545
545
|
wasiBinding = require('qrbit-wasm32-wasi')
|
|
546
546
|
nativeBinding = wasiBinding
|
|
547
547
|
} catch (err) {
|
|
548
548
|
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
549
|
-
wasiBindingError
|
|
549
|
+
if (!wasiBindingError) {
|
|
550
|
+
wasiBindingError = err
|
|
551
|
+
} else {
|
|
552
|
+
wasiBindingError.cause = err
|
|
553
|
+
}
|
|
550
554
|
loadErrors.push(err)
|
|
551
555
|
}
|
|
552
556
|
}
|
|
@@ -575,8 +579,9 @@ if (!nativeBinding) {
|
|
|
575
579
|
throw new Error(`Failed to load native binding`)
|
|
576
580
|
}
|
|
577
581
|
|
|
578
|
-
const { convertSvgToJpeg, convertSvgToPng, generateQrSvg, generateQrSvgWithBuffer } = nativeBinding
|
|
582
|
+
const { convertSvgToJpeg, convertSvgToPng, convertSvgToWebp, generateQrSvg, generateQrSvgWithBuffer } = nativeBinding
|
|
579
583
|
export { convertSvgToJpeg }
|
|
580
584
|
export { convertSvgToPng }
|
|
585
|
+
export { convertSvgToWebp }
|
|
581
586
|
export { generateQrSvg }
|
|
582
587
|
export { generateQrSvgWithBuffer }
|
package/dist/qrbit.cjs
CHANGED
|
@@ -58,6 +58,7 @@ var QrBit = class _QrBit extends import_hookified.Hookified {
|
|
|
58
58
|
this._napi = {
|
|
59
59
|
convertSvgToJpeg: import_native.convertSvgToJpeg,
|
|
60
60
|
convertSvgToPng: import_native.convertSvgToPng,
|
|
61
|
+
convertSvgToWebp: import_native.convertSvgToWebp,
|
|
61
62
|
generateQrSvg: import_native.generateQrSvg,
|
|
62
63
|
generateQrSvgWithBuffer: import_native.generateQrSvgWithBuffer
|
|
63
64
|
};
|
|
@@ -298,7 +299,7 @@ var QrBit = class _QrBit extends import_hookified.Hookified {
|
|
|
298
299
|
return import_node_buffer.Buffer.from(cached);
|
|
299
300
|
}
|
|
300
301
|
}
|
|
301
|
-
const svg = await this.toSvg();
|
|
302
|
+
const svg = await this.toSvg(options);
|
|
302
303
|
result = _QrBit.convertSvgToPng(svg);
|
|
303
304
|
if (this._cache && options?.cache !== false) {
|
|
304
305
|
const key = await this.generateCacheKey(renderKey);
|
|
@@ -339,7 +340,7 @@ var QrBit = class _QrBit extends import_hookified.Hookified {
|
|
|
339
340
|
return import_node_buffer.Buffer.from(cached);
|
|
340
341
|
}
|
|
341
342
|
}
|
|
342
|
-
const svg = await this.toSvg();
|
|
343
|
+
const svg = await this.toSvg(options);
|
|
343
344
|
result = _QrBit.convertSvgToJpeg(svg, void 0, void 0, quality);
|
|
344
345
|
if (this._cache && options?.cache !== false) {
|
|
345
346
|
const key = await this.generateCacheKey(renderKey);
|
|
@@ -362,6 +363,49 @@ var QrBit = class _QrBit extends import_hookified.Hookified {
|
|
|
362
363
|
await import_node_fs.default.promises.mkdir(dir, { recursive: true });
|
|
363
364
|
await import_node_fs.default.promises.writeFile(filePath, jpegBuffer);
|
|
364
365
|
}
|
|
366
|
+
/**
|
|
367
|
+
* Generate WebP QR code with optional caching.
|
|
368
|
+
* Generates the QR as SVG either in rust if it has a logo or native. Then does a conversion on it.
|
|
369
|
+
* Note: WebP encoding uses lossless compression - quality parameter is reserved for future lossy support.
|
|
370
|
+
* @param options - Generation options
|
|
371
|
+
* @param options.cache - Whether to use caching (default: true)
|
|
372
|
+
* @param options.quality - Reserved for future lossy WebP support (currently ignored)
|
|
373
|
+
* @returns {Promise<Buffer>} The WebP buffer
|
|
374
|
+
*/
|
|
375
|
+
async toWebp(options) {
|
|
376
|
+
let result;
|
|
377
|
+
const quality = options?.quality ?? 90;
|
|
378
|
+
const renderKey = `napi-webp-${quality}`;
|
|
379
|
+
if (this._cache && options?.cache !== false) {
|
|
380
|
+
const key = await this.generateCacheKey(renderKey);
|
|
381
|
+
const cached = await this._cache.get(key);
|
|
382
|
+
if (cached) {
|
|
383
|
+
return import_node_buffer.Buffer.from(cached);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
const svg = await this.toSvg(options);
|
|
387
|
+
result = _QrBit.convertSvgToWebp(svg);
|
|
388
|
+
if (this._cache && options?.cache !== false) {
|
|
389
|
+
const key = await this.generateCacheKey(renderKey);
|
|
390
|
+
await this._cache.set(key, result);
|
|
391
|
+
}
|
|
392
|
+
return result;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Generate WebP QR code and save it to a file.
|
|
396
|
+
* Creates directories if they don't exist.
|
|
397
|
+
* @param filePath - The file path where to save the WebP
|
|
398
|
+
* @param options - Generation options
|
|
399
|
+
* @param options.cache - Whether to use caching (default: true)
|
|
400
|
+
* @param options.quality - Reserved for future lossy WebP support (currently ignored)
|
|
401
|
+
* @returns {Promise<void>} Resolves when file is written
|
|
402
|
+
*/
|
|
403
|
+
async toWebpFile(filePath, options) {
|
|
404
|
+
const webpBuffer = await this.toWebp(options);
|
|
405
|
+
const dir = import_node_path.default.dirname(filePath);
|
|
406
|
+
await import_node_fs.default.promises.mkdir(dir, { recursive: true });
|
|
407
|
+
await import_node_fs.default.promises.writeFile(filePath, webpBuffer);
|
|
408
|
+
}
|
|
365
409
|
/**
|
|
366
410
|
* Generate SVG QR code and save it to a file.
|
|
367
411
|
* Creates directories if they don't exist.
|
|
@@ -397,6 +441,18 @@ var QrBit = class _QrBit extends import_hookified.Hookified {
|
|
|
397
441
|
static convertSvgToJpeg(svgContent, width, height, quality) {
|
|
398
442
|
return (0, import_native.convertSvgToJpeg)(svgContent, width, height, quality);
|
|
399
443
|
}
|
|
444
|
+
/**
|
|
445
|
+
* Convert SVG content to WebP buffer using the native Rust implementation.
|
|
446
|
+
* Note: WebP encoding uses lossless compression - quality parameter is reserved for future lossy support.
|
|
447
|
+
* @param svgContent - The SVG content as a string
|
|
448
|
+
* @param width - Optional width for the WebP output
|
|
449
|
+
* @param height - Optional height for the WebP output
|
|
450
|
+
* @param quality - Reserved for future lossy WebP support (currently ignored)
|
|
451
|
+
* @returns {Buffer} The WebP buffer
|
|
452
|
+
*/
|
|
453
|
+
static convertSvgToWebp(svgContent, width, height, quality) {
|
|
454
|
+
return (0, import_native.convertSvgToWebp)(svgContent, width, height, quality);
|
|
455
|
+
}
|
|
400
456
|
/**
|
|
401
457
|
* Generate a cache key based on the current QR code options.
|
|
402
458
|
* @param {string} renderKey the format that you are rendering in such as `napi-png`, `native-svg`, `napi-svg`
|
package/dist/qrbit.cjs.map
CHANGED
|
@@ -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\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 = await 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 = await 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 = await 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 = await 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 = await 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 = await 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 {Promise<string>} The cache key\n\t */\n\tpublic async generateCacheKey(renderKey: string): Promise<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\taw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,QAAQ;AAChB,aAAO;AAAA,IACR;AAAA,EACD;AACD;","names":["QrBitEvents","nativeConvertSvgToJpeg","nativeConvertSvgToPng","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\tconvertSvgToWebp as nativeConvertSvgToWebp,\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\tconvertSvgToWebp: nativeConvertSvgToWebp,\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 = await 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 = await 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 = await 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(options);\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 = await 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 = await 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(options);\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 = await 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 WebP 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 * Note: WebP encoding uses lossless compression - quality parameter is reserved for future lossy support.\n\t * @param options - Generation options\n\t * @param options.cache - Whether to use caching (default: true)\n\t * @param options.quality - Reserved for future lossy WebP support (currently ignored)\n\t * @returns {Promise<Buffer>} The WebP buffer\n\t */\n\tpublic async toWebp(options?: toOptions): Promise<Buffer> {\n\t\tlet result: Buffer;\n\t\tconst quality = options?.quality ?? 90;\n\t\tconst renderKey = `napi-webp-${quality}`;\n\n\t\t// check the cache\n\t\tif (this._cache && options?.cache !== false) {\n\t\t\tconst key = await 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(options);\n\t\tresult = QrBit.convertSvgToWebp(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 = await 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 WebP 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 WebP\n\t * @param options - Generation options\n\t * @param options.cache - Whether to use caching (default: true)\n\t * @param options.quality - Reserved for future lossy WebP support (currently ignored)\n\t * @returns {Promise<void>} Resolves when file is written\n\t */\n\tpublic async toWebpFile(\n\t\tfilePath: string,\n\t\toptions?: toOptions,\n\t): Promise<void> {\n\t\tconst webpBuffer = await this.toWebp(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, webpBuffer);\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 * Convert SVG content to WebP buffer using the native Rust implementation.\n\t * Note: WebP encoding uses lossless compression - quality parameter is reserved for future lossy support.\n\t * @param svgContent - The SVG content as a string\n\t * @param width - Optional width for the WebP output\n\t * @param height - Optional height for the WebP output\n\t * @param quality - Reserved for future lossy WebP support (currently ignored)\n\t * @returns {Buffer} The WebP buffer\n\t */\n\tpublic static convertSvgToWebp(\n\t\tsvgContent: string,\n\t\twidth?: number,\n\t\theight?: number,\n\t\tquality?: number,\n\t): Buffer {\n\t\treturn nativeConvertSvgToWebp(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 {Promise<string>} The cache key\n\t */\n\tpublic async generateCacheKey(renderKey: string): Promise<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,oBAMO;AAEA,IAAK,cAAL,kBAAKA,iBAAL;AACN,EAAA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AAAA,EACjE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,OAAc,iBACb,YACA,OACA,QACA,SACS;AACT,eAAO,cAAAE,kBAAuB,YAAY,OAAO,QAAQ,OAAO;AAAA,EACjE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAa,iBAAiB,WAAoC;AACjE,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,eAAAK,QAAG,SAAS,OAAO,UAAU,eAAAA,QAAG,UAAU,IAAI;AACpD,aAAO;AAAA,IACR,SAAS,QAAQ;AAChB,aAAO;AAAA,IACR;AAAA,EACD;AACD;","names":["QrBitEvents","nativeConvertSvgToJpeg","nativeConvertSvgToPng","nativeConvertSvgToWebp","nativeGenerateQrSvg","nativeGenerateQrSvgWithBuffer","QRCode","path","fs"]}
|
package/dist/qrbit.d.cts
CHANGED
|
@@ -218,6 +218,26 @@ declare class QrBit extends Hookified {
|
|
|
218
218
|
* @returns {Promise<void>} Resolves when file is written
|
|
219
219
|
*/
|
|
220
220
|
toJpgFile(filePath: string, options?: toOptions): Promise<void>;
|
|
221
|
+
/**
|
|
222
|
+
* Generate WebP QR code with optional caching.
|
|
223
|
+
* Generates the QR as SVG either in rust if it has a logo or native. Then does a conversion on it.
|
|
224
|
+
* Note: WebP encoding uses lossless compression - quality parameter is reserved for future lossy support.
|
|
225
|
+
* @param options - Generation options
|
|
226
|
+
* @param options.cache - Whether to use caching (default: true)
|
|
227
|
+
* @param options.quality - Reserved for future lossy WebP support (currently ignored)
|
|
228
|
+
* @returns {Promise<Buffer>} The WebP buffer
|
|
229
|
+
*/
|
|
230
|
+
toWebp(options?: toOptions): Promise<Buffer>;
|
|
231
|
+
/**
|
|
232
|
+
* Generate WebP QR code and save it to a file.
|
|
233
|
+
* Creates directories if they don't exist.
|
|
234
|
+
* @param filePath - The file path where to save the WebP
|
|
235
|
+
* @param options - Generation options
|
|
236
|
+
* @param options.cache - Whether to use caching (default: true)
|
|
237
|
+
* @param options.quality - Reserved for future lossy WebP support (currently ignored)
|
|
238
|
+
* @returns {Promise<void>} Resolves when file is written
|
|
239
|
+
*/
|
|
240
|
+
toWebpFile(filePath: string, options?: toOptions): Promise<void>;
|
|
221
241
|
/**
|
|
222
242
|
* Generate SVG QR code and save it to a file.
|
|
223
243
|
* Creates directories if they don't exist.
|
|
@@ -244,6 +264,16 @@ declare class QrBit extends Hookified {
|
|
|
244
264
|
* @returns {Buffer} The JPEG buffer
|
|
245
265
|
*/
|
|
246
266
|
static convertSvgToJpeg(svgContent: string, width?: number, height?: number, quality?: number): Buffer;
|
|
267
|
+
/**
|
|
268
|
+
* Convert SVG content to WebP buffer using the native Rust implementation.
|
|
269
|
+
* Note: WebP encoding uses lossless compression - quality parameter is reserved for future lossy support.
|
|
270
|
+
* @param svgContent - The SVG content as a string
|
|
271
|
+
* @param width - Optional width for the WebP output
|
|
272
|
+
* @param height - Optional height for the WebP output
|
|
273
|
+
* @param quality - Reserved for future lossy WebP support (currently ignored)
|
|
274
|
+
* @returns {Buffer} The WebP buffer
|
|
275
|
+
*/
|
|
276
|
+
static convertSvgToWebp(svgContent: string, width?: number, height?: number, quality?: number): Buffer;
|
|
247
277
|
/**
|
|
248
278
|
* Generate a cache key based on the current QR code options.
|
|
249
279
|
* @param {string} renderKey the format that you are rendering in such as `napi-png`, `native-svg`, `napi-svg`
|
package/dist/qrbit.d.ts
CHANGED
|
@@ -218,6 +218,26 @@ declare class QrBit extends Hookified {
|
|
|
218
218
|
* @returns {Promise<void>} Resolves when file is written
|
|
219
219
|
*/
|
|
220
220
|
toJpgFile(filePath: string, options?: toOptions): Promise<void>;
|
|
221
|
+
/**
|
|
222
|
+
* Generate WebP QR code with optional caching.
|
|
223
|
+
* Generates the QR as SVG either in rust if it has a logo or native. Then does a conversion on it.
|
|
224
|
+
* Note: WebP encoding uses lossless compression - quality parameter is reserved for future lossy support.
|
|
225
|
+
* @param options - Generation options
|
|
226
|
+
* @param options.cache - Whether to use caching (default: true)
|
|
227
|
+
* @param options.quality - Reserved for future lossy WebP support (currently ignored)
|
|
228
|
+
* @returns {Promise<Buffer>} The WebP buffer
|
|
229
|
+
*/
|
|
230
|
+
toWebp(options?: toOptions): Promise<Buffer>;
|
|
231
|
+
/**
|
|
232
|
+
* Generate WebP QR code and save it to a file.
|
|
233
|
+
* Creates directories if they don't exist.
|
|
234
|
+
* @param filePath - The file path where to save the WebP
|
|
235
|
+
* @param options - Generation options
|
|
236
|
+
* @param options.cache - Whether to use caching (default: true)
|
|
237
|
+
* @param options.quality - Reserved for future lossy WebP support (currently ignored)
|
|
238
|
+
* @returns {Promise<void>} Resolves when file is written
|
|
239
|
+
*/
|
|
240
|
+
toWebpFile(filePath: string, options?: toOptions): Promise<void>;
|
|
221
241
|
/**
|
|
222
242
|
* Generate SVG QR code and save it to a file.
|
|
223
243
|
* Creates directories if they don't exist.
|
|
@@ -244,6 +264,16 @@ declare class QrBit extends Hookified {
|
|
|
244
264
|
* @returns {Buffer} The JPEG buffer
|
|
245
265
|
*/
|
|
246
266
|
static convertSvgToJpeg(svgContent: string, width?: number, height?: number, quality?: number): Buffer;
|
|
267
|
+
/**
|
|
268
|
+
* Convert SVG content to WebP buffer using the native Rust implementation.
|
|
269
|
+
* Note: WebP encoding uses lossless compression - quality parameter is reserved for future lossy support.
|
|
270
|
+
* @param svgContent - The SVG content as a string
|
|
271
|
+
* @param width - Optional width for the WebP output
|
|
272
|
+
* @param height - Optional height for the WebP output
|
|
273
|
+
* @param quality - Reserved for future lossy WebP support (currently ignored)
|
|
274
|
+
* @returns {Buffer} The WebP buffer
|
|
275
|
+
*/
|
|
276
|
+
static convertSvgToWebp(svgContent: string, width?: number, height?: number, quality?: number): Buffer;
|
|
247
277
|
/**
|
|
248
278
|
* Generate a cache key based on the current QR code options.
|
|
249
279
|
* @param {string} renderKey the format that you are rendering in such as `napi-png`, `native-svg`, `napi-svg`
|
|
Binary file
|