@qr-platform/qr-code.js 0.9.4 → 0.9.6
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/lib/chunks/scan-validator-node-_qhS-Z_9.js +1 -0
- package/lib/chunks/scan-validator-worker-DfdvSWvZ.js +1 -0
- package/lib/chunks/{scan-validator-zxing-node-CWPfVTN8.js → scan-validator-zxing-node-Dc9Z0asL.js} +1 -1
- package/lib/chunks/{zbar-scan-validator-B3GQk_mt.js → zbar-scan-validator-CdUmQrkV.js} +1 -1
- package/lib/chunks/{zxing-scan-validator-CYcyNnMt.js → zxing-scan-validator-C8aRSTHv.js} +1 -1
- package/lib/index.js +1 -1
- package/lib/node/node.d.ts +4 -0
- package/lib/node/plugins/QRValidatorZbar.d.ts +6 -0
- package/lib/node/plugins/QRValidatorZbarNode.d.ts +13 -16
- package/lib/node/plugins/QRValidatorZbarNodeSharp.d.ts +2 -17
- package/lib/node/plugins/QRValidatorZbarWorker.d.ts +13 -16
- package/lib/node/utils/scan-validator-node.d.ts +14 -1
- package/lib/node/utils/scan-validator-worker.d.ts +13 -1
- package/lib/node/utils/scan-validator-zxing-node.d.ts +6 -0
- package/lib/node/utils/scan-validators/abstract-scan-validator.d.ts +5 -1
- package/lib/node/utils/scan-validators/zxing-canvas-scan-validator.d.ts +6 -0
- package/lib/node.d.ts +4 -0
- package/lib/node.js +1 -1
- package/lib/plugins/QRValidatorZbar.d.ts +6 -0
- package/lib/plugins/QRValidatorZbarNode.d.ts +13 -16
- package/lib/plugins/QRValidatorZbarNodeSharp.d.ts +2 -17
- package/lib/plugins/QRValidatorZbarWorker.d.ts +13 -16
- package/lib/utils/scan-validator-node.d.ts +14 -1
- package/lib/utils/scan-validator-worker.d.ts +13 -1
- package/lib/utils/scan-validator-zxing-node.d.ts +6 -0
- package/lib/utils/scan-validators/abstract-scan-validator.d.ts +5 -1
- package/lib/utils/scan-validators/zxing-canvas-scan-validator.d.ts +6 -0
- package/package.json +1 -1
- package/lib/chunks/scan-validator-node-BSN87ekg.js +0 -1
- package/lib/chunks/scan-validator-worker-CwjgE5by.js +0 -1
package/lib/node/node.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type * as _browserUtils from './tools/browser-utils';
|
|
|
4
4
|
import { RecursivePartial } from './types/helper';
|
|
5
5
|
import { StyleOptions } from './types/style-options';
|
|
6
6
|
import { Options } from './utils/options';
|
|
7
|
+
import { ImageDataLike } from './utils/scan-validator-worker';
|
|
7
8
|
import { ScanValidatorResponse } from './utils/scan-validators/abstract-scan-validator';
|
|
8
9
|
import { type DecodedLicenseToken } from './utils/token-validator';
|
|
9
10
|
export { ErrorCorrectionLevel, Mode, TypeNumber } from '~/lib/qrcode/QRCodeMinimal';
|
|
@@ -33,7 +34,9 @@ export declare class QRCodeJs extends _QRCodeJs {
|
|
|
33
34
|
static _initPromise: Promise<void> | null;
|
|
34
35
|
static initXmldom(): Promise<void>;
|
|
35
36
|
constructor(options: RecursivePartial<Options>, _?: boolean);
|
|
37
|
+
static validateImageData(imageData: ImageDataLike): Promise<ScanValidatorResponse>;
|
|
36
38
|
validateScanning(): Promise<ScanValidatorResponse>;
|
|
39
|
+
static validateSvg(svgSource: string): Promise<ScanValidatorResponse>;
|
|
37
40
|
/**
|
|
38
41
|
* Creates a QRCodeBuilder instance initialized with a specific template.
|
|
39
42
|
* Allows for fluent configuration chaining. We need it here to avoid circular dependency
|
|
@@ -84,5 +87,6 @@ declare class QRCodeBuilder {
|
|
|
84
87
|
}
|
|
85
88
|
export declare class _ extends QRCodeJs {
|
|
86
89
|
protected _hls(): boolean;
|
|
90
|
+
static get hls(): boolean;
|
|
87
91
|
constructor(options: RecursivePartial<Options>);
|
|
88
92
|
}
|
|
@@ -29,6 +29,12 @@ declare class QRValidatorZbar {
|
|
|
29
29
|
* @returns {Promise<Object>} - Validation result after retries
|
|
30
30
|
*/
|
|
31
31
|
decodeQRWithRetry(imageData: ImageData): Promise<Object>;
|
|
32
|
+
/**
|
|
33
|
+
* Validate and decode a QR code directly from ImageData
|
|
34
|
+
* @param {object} imageData - Object with { data: Uint8ClampedArray, width: number, height: number }
|
|
35
|
+
* @returns {Promise<Object>} - Validation results
|
|
36
|
+
*/
|
|
37
|
+
validateImageData(imageData: object): Promise<Object>;
|
|
32
38
|
/**
|
|
33
39
|
* Decode QR code from image data using zbar-wasm
|
|
34
40
|
* @param {ImageData} imageData - Raw image data
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This server-side class uses zbar-wasm to decode QR codes and other barcodes,
|
|
5
5
|
* with Jimp (and Resvg for SVG conversion) for image processing.
|
|
6
6
|
*/
|
|
7
|
+
import { ScanValidatorResponse } from '~/utils/scan-validators/abstract-scan-validator';
|
|
7
8
|
interface QRValidatorOptions {
|
|
8
9
|
/** Maximum number of retry attempts */
|
|
9
10
|
maxRetries?: number;
|
|
@@ -12,21 +13,13 @@ interface QRValidatorOptions {
|
|
|
12
13
|
/** Enable debug logging */
|
|
13
14
|
debug?: boolean;
|
|
14
15
|
}
|
|
15
|
-
interface
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
/** Number of retry attempts made */
|
|
23
|
-
attempts?: number;
|
|
24
|
-
/** Whether the successful decode came from an inverted image */
|
|
25
|
-
isInverted?: boolean;
|
|
26
|
-
/** Error message if validation failed */
|
|
27
|
-
error?: string;
|
|
28
|
-
/** Error code if validation failed */
|
|
29
|
-
errorCode?: string;
|
|
16
|
+
interface ImageDataLike {
|
|
17
|
+
/** Raw pixel data (RGBA) */
|
|
18
|
+
data: Uint8ClampedArray;
|
|
19
|
+
/** Image width */
|
|
20
|
+
width: number;
|
|
21
|
+
/** Image height */
|
|
22
|
+
height: number;
|
|
30
23
|
}
|
|
31
24
|
declare class QRValidatorZbarNode {
|
|
32
25
|
private maxRetries;
|
|
@@ -37,7 +30,7 @@ declare class QRValidatorZbarNode {
|
|
|
37
30
|
/**
|
|
38
31
|
* Validate and decode a QR code from an SVG string (or file path)
|
|
39
32
|
*/
|
|
40
|
-
validate(input: string, isInverted?: boolean): Promise<
|
|
33
|
+
validate(input: string, isInverted?: boolean): Promise<ScanValidatorResponse>;
|
|
41
34
|
private sleep;
|
|
42
35
|
/**
|
|
43
36
|
* Process image using Sharp and get raw pixel data
|
|
@@ -48,6 +41,10 @@ declare class QRValidatorZbarNode {
|
|
|
48
41
|
*/
|
|
49
42
|
private processImageResvg;
|
|
50
43
|
private validateWithRetry;
|
|
44
|
+
/**
|
|
45
|
+
* Validate and decode a QR code directly from ImageData
|
|
46
|
+
*/
|
|
47
|
+
validateImageData(imageData: ImageDataLike): Promise<ScanValidatorResponse>;
|
|
51
48
|
/**
|
|
52
49
|
* Save a debug image using Jimp. The raw image data is used to reconstruct an image.
|
|
53
50
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ScanValidatorResponse } from '~/utils/scan-validators/abstract-scan-validator';
|
|
1
2
|
interface QRValidatorOptions {
|
|
2
3
|
/** Maximum number of retry attempts */
|
|
3
4
|
maxRetries?: number;
|
|
@@ -6,22 +7,6 @@ interface QRValidatorOptions {
|
|
|
6
7
|
/** Enable debug logging */
|
|
7
8
|
debug?: boolean;
|
|
8
9
|
}
|
|
9
|
-
interface QRValidationResult {
|
|
10
|
-
/** Whether the validation was successful */
|
|
11
|
-
isValid: boolean;
|
|
12
|
-
/** Decoded data from the QR code (if successful) */
|
|
13
|
-
data?: string;
|
|
14
|
-
/** Format of the detected barcode */
|
|
15
|
-
format?: string;
|
|
16
|
-
/** Number of retry attempts made */
|
|
17
|
-
attempts?: number;
|
|
18
|
-
/** Whether the successful decode came from an inverted image */
|
|
19
|
-
isInverted?: boolean;
|
|
20
|
-
/** Error message if validation failed */
|
|
21
|
-
error?: string;
|
|
22
|
-
/** Error code if validation failed */
|
|
23
|
-
errorCode?: string;
|
|
24
|
-
}
|
|
25
10
|
declare class QRValidatorZbarNode {
|
|
26
11
|
private maxRetries;
|
|
27
12
|
private retryInterval;
|
|
@@ -43,7 +28,7 @@ declare class QRValidatorZbarNode {
|
|
|
43
28
|
* @param height Optional height for resizing
|
|
44
29
|
* @returns Validation results with decoded data if successful
|
|
45
30
|
*/
|
|
46
|
-
validate(input: string | Buffer, isInverted?: boolean, width?: number | null, height?: number | null): Promise<
|
|
31
|
+
validate(input: string | Buffer, isInverted?: boolean, width?: number | null, height?: number | null): Promise<ScanValidatorResponse>;
|
|
47
32
|
/**
|
|
48
33
|
* Sleep function to wait between retry attempts
|
|
49
34
|
* @param ms Milliseconds to wait
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This server-side class uses zbar-wasm to decode QR codes and other barcodes,
|
|
5
5
|
* with Jimp (and Resvg for SVG conversion) for image processing.
|
|
6
6
|
*/
|
|
7
|
+
import { ScanValidatorResponse } from '~/utils/scan-validators/abstract-scan-validator';
|
|
7
8
|
interface QRValidatorOptions {
|
|
8
9
|
/** Maximum number of retry attempts */
|
|
9
10
|
maxRetries?: number;
|
|
@@ -12,21 +13,13 @@ interface QRValidatorOptions {
|
|
|
12
13
|
/** Enable debug logging */
|
|
13
14
|
debug?: boolean;
|
|
14
15
|
}
|
|
15
|
-
interface
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
/** Number of retry attempts made */
|
|
23
|
-
attempts?: number;
|
|
24
|
-
/** Whether the successful decode came from an inverted image */
|
|
25
|
-
isInverted?: boolean;
|
|
26
|
-
/** Error message if validation failed */
|
|
27
|
-
error?: string;
|
|
28
|
-
/** Error code if validation failed */
|
|
29
|
-
errorCode?: string;
|
|
16
|
+
interface ImageDataLike {
|
|
17
|
+
/** Raw pixel data (RGBA) */
|
|
18
|
+
data: Uint8ClampedArray;
|
|
19
|
+
/** Image width */
|
|
20
|
+
width: number;
|
|
21
|
+
/** Image height */
|
|
22
|
+
height: number;
|
|
30
23
|
}
|
|
31
24
|
declare class QRValidatorZbarNode {
|
|
32
25
|
private maxRetries;
|
|
@@ -37,7 +30,7 @@ declare class QRValidatorZbarNode {
|
|
|
37
30
|
/**
|
|
38
31
|
* Validate and decode a QR code from an SVG string (or file path)
|
|
39
32
|
*/
|
|
40
|
-
validate(input: string, isInverted?: boolean): Promise<
|
|
33
|
+
validate(input: string, isInverted?: boolean): Promise<ScanValidatorResponse>;
|
|
41
34
|
private sleep;
|
|
42
35
|
/**
|
|
43
36
|
* Process image using Sharp and get raw pixel data
|
|
@@ -48,6 +41,10 @@ declare class QRValidatorZbarNode {
|
|
|
48
41
|
*/
|
|
49
42
|
private processImageResvg;
|
|
50
43
|
private validateWithRetry;
|
|
44
|
+
/**
|
|
45
|
+
* Validate and decode a QR code directly from ImageData
|
|
46
|
+
*/
|
|
47
|
+
validateImageData(imageData: ImageDataLike): Promise<ScanValidatorResponse>;
|
|
51
48
|
/**
|
|
52
49
|
* Save a debug image using Jimp. The raw image data is used to reconstruct an image.
|
|
53
50
|
*/
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { ScanValidatorResponse } from './scan-validators/abstract-scan-validator';
|
|
2
|
+
interface ImageDataLike {
|
|
3
|
+
data: Uint8ClampedArray;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
2
7
|
/**
|
|
3
8
|
* QR Code validator for Node.js environment
|
|
4
9
|
*/
|
|
5
|
-
export declare const
|
|
10
|
+
export declare const qrValidatorZbar: {
|
|
6
11
|
/**
|
|
7
12
|
* Validate QR code using zbar with SVG as input
|
|
8
13
|
* @param svgSource SVG string containing QR code
|
|
@@ -12,4 +17,12 @@ export declare const qrValidator: {
|
|
|
12
17
|
* @returns Validation result
|
|
13
18
|
*/
|
|
14
19
|
validateZbar: (svgSource: string | undefined, debug?: boolean) => Promise<ScanValidatorResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* Validate QR code using zbar with ImageData as input (Node.js)
|
|
22
|
+
* @param imageData Object with { data: Uint8ClampedArray, width: number, height: number }
|
|
23
|
+
* @param debug Enable detailed debugging (passed to underlying validator)
|
|
24
|
+
* @returns Validation result
|
|
25
|
+
*/
|
|
26
|
+
validateZbarImageData: (imageData: ImageDataLike, debug?: boolean) => Promise<ScanValidatorResponse>;
|
|
15
27
|
};
|
|
28
|
+
export {};
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { ScanValidatorResponse } from './scan-validators/abstract-scan-validator';
|
|
2
|
+
export interface ImageDataLike {
|
|
3
|
+
data: Uint8ClampedArray;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
2
7
|
/**
|
|
3
8
|
* QR Code validator for Node.js environment
|
|
4
9
|
*/
|
|
5
|
-
export declare const
|
|
10
|
+
export declare const qrValidatorZbar: {
|
|
6
11
|
/**
|
|
7
12
|
* Validate QR code using zbar with SVG as input
|
|
8
13
|
* @param svgSource SVG string containing QR code
|
|
@@ -12,4 +17,11 @@ export declare const qrValidator: {
|
|
|
12
17
|
* @returns Validation result
|
|
13
18
|
*/
|
|
14
19
|
validateZbar: (svgSource: string | undefined, debug?: boolean) => Promise<ScanValidatorResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* Validate QR code using zbar with ImageData as input
|
|
22
|
+
* @param imageData Object with { data: Uint8ClampedArray, width: number, height: number }
|
|
23
|
+
* @param debug Enable detailed debugging (passed to underlying validator)
|
|
24
|
+
* @returns Validation result
|
|
25
|
+
*/
|
|
26
|
+
validateZbarImageData: (imageData: ImageDataLike, debug?: boolean) => Promise<ScanValidatorResponse>;
|
|
15
27
|
};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { BinaryBitmap } from '~/lib/zxing-js/src';
|
|
2
2
|
import { NodeLuminanceSource } from '~/lib/zxing-js/src/node';
|
|
3
3
|
import { ScanValidatorResponse } from './scan-validators/abstract-scan-validator';
|
|
4
|
+
interface ImageDataLike {
|
|
5
|
+
data: Uint8ClampedArray;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}
|
|
4
9
|
export interface PreprocessingOptions {
|
|
5
10
|
lower?: number;
|
|
6
11
|
upper?: number;
|
|
@@ -14,5 +19,6 @@ export interface PreprocessingOptions {
|
|
|
14
19
|
*/
|
|
15
20
|
export declare const qrValidatorZxing: {
|
|
16
21
|
validateZxing: (svgString: string | undefined) => Promise<ScanValidatorResponse>;
|
|
22
|
+
validateImageData: (imageData: ImageDataLike) => Promise<ScanValidatorResponse>;
|
|
17
23
|
};
|
|
18
24
|
export type { NodeLuminanceSource, BinaryBitmap, ScanValidatorResponse };
|
|
@@ -9,7 +9,11 @@ export interface ScanValidatorResponse {
|
|
|
9
9
|
/**
|
|
10
10
|
* Decoded data from the QR code
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
data?: string | null;
|
|
13
|
+
/**
|
|
14
|
+
* Format of the detected barcode
|
|
15
|
+
*/
|
|
16
|
+
format?: string;
|
|
13
17
|
/**
|
|
14
18
|
* Whether the successful decode was from an inverted image
|
|
15
19
|
*/
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { LuminanceSource } from '~/lib/zxing-js/src';
|
|
2
2
|
import QRCodeReader from '~/lib/zxing-js/src/core/qrcode/QRCodeReader';
|
|
3
3
|
import AbstractScanValidator, { ScanValidator, ScanValidatorResponse } from './abstract-scan-validator';
|
|
4
|
+
interface ImageDataLike {
|
|
5
|
+
data: Uint8ClampedArray;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}
|
|
4
9
|
declare class ZXingCanvasScanValidator extends AbstractScanValidator implements ScanValidator {
|
|
5
10
|
validator: QRCodeReader;
|
|
6
11
|
constructor(debug?: boolean);
|
|
7
12
|
displayLuminanceSource(source: LuminanceSource, label: string): void;
|
|
8
13
|
validate(canvas: HTMLCanvasElement, debug?: boolean): Promise<ScanValidatorResponse>;
|
|
14
|
+
validateImageData(imageData: ImageDataLike, debug?: boolean): Promise<ScanValidatorResponse>;
|
|
9
15
|
}
|
|
10
16
|
export default ZXingCanvasScanValidator;
|
package/lib/node.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type * as _browserUtils from './tools/browser-utils';
|
|
|
4
4
|
import { RecursivePartial } from './types/helper';
|
|
5
5
|
import { StyleOptions } from './types/style-options';
|
|
6
6
|
import { Options } from './utils/options';
|
|
7
|
+
import { ImageDataLike } from './utils/scan-validator-worker';
|
|
7
8
|
import { ScanValidatorResponse } from './utils/scan-validators/abstract-scan-validator';
|
|
8
9
|
import { type DecodedLicenseToken } from './utils/token-validator';
|
|
9
10
|
export { ErrorCorrectionLevel, Mode, TypeNumber } from '~/lib/qrcode/QRCodeMinimal';
|
|
@@ -33,7 +34,9 @@ export declare class QRCodeJs extends _QRCodeJs {
|
|
|
33
34
|
static _initPromise: Promise<void> | null;
|
|
34
35
|
static initXmldom(): Promise<void>;
|
|
35
36
|
constructor(options: RecursivePartial<Options>, _?: boolean);
|
|
37
|
+
static validateImageData(imageData: ImageDataLike): Promise<ScanValidatorResponse>;
|
|
36
38
|
validateScanning(): Promise<ScanValidatorResponse>;
|
|
39
|
+
static validateSvg(svgSource: string): Promise<ScanValidatorResponse>;
|
|
37
40
|
/**
|
|
38
41
|
* Creates a QRCodeBuilder instance initialized with a specific template.
|
|
39
42
|
* Allows for fluent configuration chaining. We need it here to avoid circular dependency
|
|
@@ -84,5 +87,6 @@ declare class QRCodeBuilder {
|
|
|
84
87
|
}
|
|
85
88
|
export declare class _ extends QRCodeJs {
|
|
86
89
|
protected _hls(): boolean;
|
|
90
|
+
static get hls(): boolean;
|
|
87
91
|
constructor(options: RecursivePartial<Options>);
|
|
88
92
|
}
|