qrbit 1.2.0 → 1.3.1
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 +165 -7
- package/dist/native.cjs +69 -56
- package/dist/native.d.cts +2 -6
- package/dist/native.d.ts +2 -6
- package/dist/native.js +70 -54
- package/dist/qrbit.cjs +54 -3
- package/dist/qrbit.cjs.map +1 -1
- package/dist/qrbit.d.cts +29 -0
- package/dist/qrbit.d.ts +29 -0
- package/dist/qrbit.darwin-arm64.node +0 -0
- package/dist/qrbit.darwin-x64.node +0 -0
- package/dist/qrbit.js +55 -6
- 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 +15 -14
package/dist/qrbit.js
CHANGED
|
@@ -6,10 +6,8 @@ import { Cacheable } from "cacheable";
|
|
|
6
6
|
import { Hookified } from "hookified";
|
|
7
7
|
import QRCode from "qrcode";
|
|
8
8
|
import {
|
|
9
|
+
convertSvgToJpeg as nativeConvertSvgToJpeg,
|
|
9
10
|
convertSvgToPng as nativeConvertSvgToPng,
|
|
10
|
-
generateQr as nativeGenerateQr,
|
|
11
|
-
generateQrPng as nativeGenerateQrPng,
|
|
12
|
-
generateQrPngWithBuffer as nativeGenerateQrPngWithBuffer,
|
|
13
11
|
generateQrSvg as nativeGenerateQrSvg,
|
|
14
12
|
generateQrSvgWithBuffer as nativeGenerateQrSvgWithBuffer
|
|
15
13
|
} from "./native.js";
|
|
@@ -28,10 +26,8 @@ var QrBit = class _QrBit extends Hookified {
|
|
|
28
26
|
constructor(options) {
|
|
29
27
|
super();
|
|
30
28
|
this._napi = {
|
|
29
|
+
convertSvgToJpeg: nativeConvertSvgToJpeg,
|
|
31
30
|
convertSvgToPng: nativeConvertSvgToPng,
|
|
32
|
-
generateQr: nativeGenerateQr,
|
|
33
|
-
generateQrPng: nativeGenerateQrPng,
|
|
34
|
-
generateQrPngWithBuffer: nativeGenerateQrPngWithBuffer,
|
|
35
31
|
generateQrSvg: nativeGenerateQrSvg,
|
|
36
32
|
generateQrSvgWithBuffer: nativeGenerateQrSvgWithBuffer
|
|
37
33
|
};
|
|
@@ -294,6 +290,48 @@ var QrBit = class _QrBit extends Hookified {
|
|
|
294
290
|
await fs.promises.mkdir(dir, { recursive: true });
|
|
295
291
|
await fs.promises.writeFile(filePath, pngBuffer);
|
|
296
292
|
}
|
|
293
|
+
/**
|
|
294
|
+
* Generate JPEG QR code with optional caching.
|
|
295
|
+
* Generates the QR as SVG either in rust if it has a logo or native. Then does a conversion on it.
|
|
296
|
+
* @param options - Generation options
|
|
297
|
+
* @param options.cache - Whether to use caching (default: true)
|
|
298
|
+
* @param options.quality - JPEG quality 1-100 (default: 90)
|
|
299
|
+
* @returns {Promise<Buffer>} The JPEG buffer
|
|
300
|
+
*/
|
|
301
|
+
async toJpg(options) {
|
|
302
|
+
let result;
|
|
303
|
+
const quality = options?.quality ?? 90;
|
|
304
|
+
const renderKey = `napi-jpeg-${quality}`;
|
|
305
|
+
if (this._cache && options?.cache !== false) {
|
|
306
|
+
const key = this.generateCacheKey(renderKey);
|
|
307
|
+
const cached = await this._cache.get(key);
|
|
308
|
+
if (cached) {
|
|
309
|
+
return Buffer.from(cached);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
const svg = await this.toSvg();
|
|
313
|
+
result = _QrBit.convertSvgToJpeg(svg, void 0, void 0, quality);
|
|
314
|
+
if (this._cache && options?.cache !== false) {
|
|
315
|
+
const key = this.generateCacheKey(renderKey);
|
|
316
|
+
await this._cache.set(key, result);
|
|
317
|
+
}
|
|
318
|
+
return result;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Generate JPEG QR code and save it to a file.
|
|
322
|
+
* Creates directories if they don't exist.
|
|
323
|
+
* @param filePath - The file path where to save the JPEG
|
|
324
|
+
* @param options - Generation options
|
|
325
|
+
* @param options.cache - Whether to use caching (default: true)
|
|
326
|
+
* @param options.quality - JPEG quality 1-100 (default: 90)
|
|
327
|
+
* @returns {Promise<void>} Resolves when file is written
|
|
328
|
+
*/
|
|
329
|
+
async toJpgFile(filePath, options) {
|
|
330
|
+
const jpegBuffer = await this.toJpg(options);
|
|
331
|
+
const dir = path.dirname(filePath);
|
|
332
|
+
await fs.promises.mkdir(dir, { recursive: true });
|
|
333
|
+
await fs.promises.writeFile(filePath, jpegBuffer);
|
|
334
|
+
}
|
|
297
335
|
/**
|
|
298
336
|
* Generate SVG QR code and save it to a file.
|
|
299
337
|
* Creates directories if they don't exist.
|
|
@@ -318,6 +356,17 @@ var QrBit = class _QrBit extends Hookified {
|
|
|
318
356
|
static convertSvgToPng(svgContent, width, height) {
|
|
319
357
|
return nativeConvertSvgToPng(svgContent, width, height);
|
|
320
358
|
}
|
|
359
|
+
/**
|
|
360
|
+
* Convert SVG content to JPEG buffer using the native Rust implementation.
|
|
361
|
+
* @param svgContent - The SVG content as a string
|
|
362
|
+
* @param width - Optional width for the JPEG output
|
|
363
|
+
* @param height - Optional height for the JPEG output
|
|
364
|
+
* @param quality - Optional JPEG quality 1-100 (default: 90)
|
|
365
|
+
* @returns {Buffer} The JPEG buffer
|
|
366
|
+
*/
|
|
367
|
+
static convertSvgToJpeg(svgContent, width, height, quality) {
|
|
368
|
+
return nativeConvertSvgToJpeg(svgContent, width, height, quality);
|
|
369
|
+
}
|
|
321
370
|
/**
|
|
322
371
|
* Generate a cache key based on the current QR code options.
|
|
323
372
|
* @param {string} renderKey the format that you are rendering in such as `napi-png`, `native-svg`, `napi-svg`
|
package/dist/qrbit.js.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\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\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A;AAAA,EAOA,MAAa,eAAe,UAAoC;AAC/D,QAAI;AACH,YAAM,GAAG,SAAS,OAAO,UAAU,GAAG,UAAU,IAAI;AACpD,aAAO;AAAA,IACR,SAAS,QAAQ;AAChB,aAAO;AAAA,IACR;AAAA,EACD;AACD;","names":["QrBitEvents"]}
|
|
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;\n\t\t}\n\t}\n}\n"],"mappings":";AAAA,SAAS,cAAc;AACvB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,iBAAiB;AAC1B,SAAS,iBAAwC;AACjD,OAAO,YAA4C;AACnD;AAAA,EACC,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,2BAA2B;AAAA,OACrB;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;AAmEtB,IAAM,QAAN,MAAM,eAAc,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBpC,YAAY,SAAoB;AAC/B,UAAM;AAZP,SAAQ,QAAQ;AAAA,MACf,kBAAkB;AAAA,MAClB,iBAAiB;AAAA,MACjB,eAAe;AAAA,MACf,yBAAyB;AAAA,IAC1B;AAQC,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A,MACtB,iBAAiB,KAAK;AAAA,MACtB;AAAA,IACD;AAEA,UAAM,QAAQ,KAAK,UAAU,IAAI,UAAU;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,GAAG,SAAS,OAAO,UAAU,GAAG,UAAU,IAAI;AACpD,aAAO;AAAA,IACR,SAAS,QAAQ;AAChB,aAAO;AAAA,IACR;AAAA,EACD;AACD;","names":["QrBitEvents"]}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qrbit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "A fast QR code generator with logo embedding support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/qrbit.cjs",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"benchmark:common": "tsx benchmark/qrcode-common-svg.ts && tsx benchmark/qrcode-common-png.ts",
|
|
34
34
|
"benchmark:svg": "tsx benchmark/qrcode-svg.ts",
|
|
35
35
|
"benchmark:png": "tsx benchmark/qrcode-png.ts",
|
|
36
|
+
"benchmark:jpg": "tsx benchmark/qrcode-jpg.ts",
|
|
36
37
|
"benchmark:logo": "tsx benchmark/qrcode-logo.ts",
|
|
37
38
|
"benchmark": "pnpm benchmark:svg && pnpm benchmark:png && pnpm benchmark:logo",
|
|
38
39
|
"generate-examples": "rimraf ./examples && pnpm tsx ./scripts/generate-examples.ts",
|
|
@@ -40,20 +41,20 @@
|
|
|
40
41
|
"version": "napi version"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@biomejs/biome": "^2.
|
|
44
|
-
"@faker-js/faker": "^10.
|
|
44
|
+
"@biomejs/biome": "^2.3.3",
|
|
45
|
+
"@faker-js/faker": "^10.1.0",
|
|
45
46
|
"@loskir/styled-qr-code-node": "^1.5.2",
|
|
46
47
|
"@monstermann/tinybench-pretty-printer": "^0.2.0",
|
|
47
|
-
"@napi-rs/cli": "^3.
|
|
48
|
-
"@types/node": "^24.
|
|
49
|
-
"@types/qrcode": "^1.5.
|
|
50
|
-
"@vitest/coverage-v8": "^
|
|
51
|
-
"rimraf": "^6.0
|
|
52
|
-
"tinybench": "^5.0
|
|
48
|
+
"@napi-rs/cli": "^3.4.1",
|
|
49
|
+
"@types/node": "^24.10.0",
|
|
50
|
+
"@types/qrcode": "^1.5.6",
|
|
51
|
+
"@vitest/coverage-v8": "^4.0.6",
|
|
52
|
+
"rimraf": "^6.1.0",
|
|
53
|
+
"tinybench": "^5.1.0",
|
|
53
54
|
"tsup": "^8.5.0",
|
|
54
|
-
"tsx": "^4.20.
|
|
55
|
-
"typescript": "^5.9.
|
|
56
|
-
"vitest": "^
|
|
55
|
+
"tsx": "^4.20.6",
|
|
56
|
+
"typescript": "^5.9.3",
|
|
57
|
+
"vitest": "^4.0.6"
|
|
57
58
|
},
|
|
58
59
|
"repository": {
|
|
59
60
|
"type": "git",
|
|
@@ -91,8 +92,8 @@
|
|
|
91
92
|
]
|
|
92
93
|
},
|
|
93
94
|
"dependencies": {
|
|
94
|
-
"cacheable": "^2.
|
|
95
|
-
"hookified": "^1.12.
|
|
95
|
+
"cacheable": "^2.1.1",
|
|
96
|
+
"hookified": "^1.12.2",
|
|
96
97
|
"qrcode": "^1.5.4"
|
|
97
98
|
}
|
|
98
99
|
}
|