@qr-platform/qr-code.js 0.9.0 → 0.9.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/lib/chunks/scan-validator-node-BGUxkBJt.js +1 -0
- package/lib/chunks/scan-validator-zxing-node-CV9K2v4n.js +1 -0
- package/lib/core/qr-code-js.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/node/core/qr-code-js.d.ts +61 -0
- package/lib/node/core/qr-constant.d.ts +9 -0
- package/lib/node/core/qr-options-validation.d.ts +13 -0
- package/lib/node/core/qr-styles.d.ts +4 -0
- package/lib/node/core/qr-svg.d.ts +76 -0
- package/lib/node/core/qr-templates.d.ts +10 -0
- package/lib/node/figures/corner-dot.d.ts +24 -0
- package/lib/node/figures/corner-square.d.ts +24 -0
- package/lib/node/figures/dot.d.ts +31 -0
- package/lib/node/index.d.ts +101 -0
- package/lib/node/lib/image/GIFImage.d.ts +19 -0
- package/lib/node/lib/io/Base64.d.ts +10 -0
- package/lib/node/lib/io/Base64DecodeInputStream.d.ts +15 -0
- package/lib/node/lib/io/Base64EncodeOutputStream.d.ts +17 -0
- package/lib/node/lib/io/ByteArrayInputStream.d.ts +12 -0
- package/lib/node/lib/io/ByteArrayOutputStream.d.ts +12 -0
- package/lib/node/lib/io/InputStream.d.ts +10 -0
- package/lib/node/lib/io/OutputStream.d.ts +12 -0
- package/lib/node/lib/qr-code.d.ts +5 -0
- package/lib/node/lib/qrcode/BitBuffer.d.ts +11 -0
- package/lib/node/lib/qrcode/ErrorCorrectLevel.d.ts +23 -0
- package/lib/node/lib/qrcode/MaskPattern.d.ts +39 -0
- package/lib/node/lib/qrcode/Mode.d.ts +23 -0
- package/lib/node/lib/qrcode/Polynomial.d.ts +15 -0
- package/lib/node/lib/qrcode/QR8BitByte.d.ts +13 -0
- package/lib/node/lib/qrcode/QRAlphaNum.d.ts +13 -0
- package/lib/node/lib/qrcode/QRCode.d.ts +22 -0
- package/lib/node/lib/qrcode/QRCodeMinimal.d.ts +58 -0
- package/lib/node/lib/qrcode/QRData.d.ts +17 -0
- package/lib/node/lib/qrcode/QRKanji.d.ts +13 -0
- package/lib/node/lib/qrcode/QRMath.d.ts +13 -0
- package/lib/node/lib/qrcode/QRNumber.d.ts +14 -0
- package/lib/node/lib/qrcode/QRUtil.d.ts +25 -0
- package/lib/node/lib/qrcode/RSBlock.d.ts +16 -0
- package/lib/node/lib/text/createStringToBytes.d.ts +9 -0
- package/lib/node/lib/text/stringToBytes_SJIS.d.ts +8 -0
- package/lib/node/lib/text/stringToBytes_UTF8.d.ts +7 -0
- package/lib/node/lib/zbar-wasm/index.d.ts +1 -0
- package/lib/node/lib/zxing-js/src/browser/BrowserCodeReader.d.ts +150 -0
- package/lib/node/lib/zxing-js/src/browser/BrowserQRCodeReader.d.ts +29 -0
- package/lib/node/lib/zxing-js/src/browser/HTMLCanvasElementLuminanceSource.d.ts +27 -0
- package/lib/node/lib/zxing-js/src/browser/HTMLVisualMediaElement.d.ts +4 -0
- package/lib/node/lib/zxing-js/src/browser.d.ts +3 -0
- package/lib/node/lib/zxing-js/src/core/ArgumentException.d.ts +7 -0
- package/lib/node/lib/zxing-js/src/core/ArithmeticException.d.ts +7 -0
- package/lib/node/lib/zxing-js/src/core/ArrayIndexOutOfBoundsException.d.ts +10 -0
- package/lib/node/lib/zxing-js/src/core/BarcodeFormat.d.ts +42 -0
- package/lib/node/lib/zxing-js/src/core/Binarizer.d.ts +53 -0
- package/lib/node/lib/zxing-js/src/core/BinaryBitmap.d.ts +78 -0
- package/lib/node/lib/zxing-js/src/core/ChecksumException.d.ts +8 -0
- package/lib/node/lib/zxing-js/src/core/DecodeHintType.d.ts +91 -0
- package/lib/node/lib/zxing-js/src/core/Exception.d.ts +17 -0
- package/lib/node/lib/zxing-js/src/core/FormatException.d.ts +8 -0
- package/lib/node/lib/zxing-js/src/core/HighContrastLuminanceSource.d.ts +27 -0
- package/lib/node/lib/zxing-js/src/core/IllegalArgumentException.d.ts +7 -0
- package/lib/node/lib/zxing-js/src/core/IllegalStateException.d.ts +7 -0
- package/lib/node/lib/zxing-js/src/core/IndexOutOfBoundsException.d.ts +7 -0
- package/lib/node/lib/zxing-js/src/core/InvertedLuminanceSource.d.ts +22 -0
- package/lib/node/lib/zxing-js/src/core/LuminanceSource.d.ts +84 -0
- package/lib/node/lib/zxing-js/src/core/NodeLuminanceSource.d.ts +33 -0
- package/lib/node/lib/zxing-js/src/core/NotFoundException.d.ts +8 -0
- package/lib/node/lib/zxing-js/src/core/NullPointerException.d.ts +7 -0
- package/lib/node/lib/zxing-js/src/core/OutOfMemoryError.d.ts +6 -0
- package/lib/node/lib/zxing-js/src/core/Reader.d.ts +49 -0
- package/lib/node/lib/zxing-js/src/core/ReaderException.d.ts +7 -0
- package/lib/node/lib/zxing-js/src/core/ReedSolomonException.d.ts +7 -0
- package/lib/node/lib/zxing-js/src/core/Result.d.ts +52 -0
- package/lib/node/lib/zxing-js/src/core/ResultMetadataType.d.ts +68 -0
- package/lib/node/lib/zxing-js/src/core/ResultPoint.d.ts +34 -0
- package/lib/node/lib/zxing-js/src/core/ResultPointCallback.d.ts +11 -0
- package/lib/node/lib/zxing-js/src/core/UniversalLuminanceSource.d.ts +46 -0
- package/lib/node/lib/zxing-js/src/core/UnsupportedOperationException.d.ts +7 -0
- package/lib/node/lib/zxing-js/src/core/common/BitArray.d.ts +111 -0
- package/lib/node/lib/zxing-js/src/core/common/BitMatrix.d.ts +98 -0
- package/lib/node/lib/zxing-js/src/core/common/BitSource.d.ts +38 -0
- package/lib/node/lib/zxing-js/src/core/common/CharacterSetECI.d.ts +89 -0
- package/lib/node/lib/zxing-js/src/core/common/DecoderResult.d.ts +64 -0
- package/lib/node/lib/zxing-js/src/core/common/DefaultGridSampler.d.ts +10 -0
- package/lib/node/lib/zxing-js/src/core/common/DetectorResult.d.ts +16 -0
- package/lib/node/lib/zxing-js/src/core/common/GlobalHistogramBinarizer.d.ts +29 -0
- package/lib/node/lib/zxing-js/src/core/common/GridSampler.d.ts +36 -0
- package/lib/node/lib/zxing-js/src/core/common/GridSamplerInstance.d.ts +18 -0
- package/lib/node/lib/zxing-js/src/core/common/HybridBinarizer.d.ts +54 -0
- package/lib/node/lib/zxing-js/src/core/common/PerspectiveTransform.d.ts +26 -0
- package/lib/node/lib/zxing-js/src/core/common/StringUtils.d.ts +48 -0
- package/lib/node/lib/zxing-js/src/core/common/detector/MathUtils.d.ts +36 -0
- package/lib/node/lib/zxing-js/src/core/common/reedsolomon/AbstractGenericGF.d.ts +34 -0
- package/lib/node/lib/zxing-js/src/core/common/reedsolomon/GenericGF.d.ts +58 -0
- package/lib/node/lib/zxing-js/src/core/common/reedsolomon/GenericGFPoly.d.ts +47 -0
- package/lib/node/lib/zxing-js/src/core/common/reedsolomon/ReedSolomonDecoder.d.ts +40 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/QRCodeReader.d.ts +35 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/BitMatrixParser.d.ts +58 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/DataBlock.d.ts +28 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/DataMask.d.ts +36 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/DecodedBitStreamParser.d.ts +30 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/Decoder.d.ts +44 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/ECB.d.ts +12 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/ECBlocks.d.ts +16 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/ErrorCorrectionLevel.d.ts +38 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/FormatInformation.d.ts +33 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/Mode.d.ts +56 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/QRCodeDecoderMetaData.d.ts +21 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/decoder/Version.d.ts +44 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/detector/AlignmentPattern.d.ts +21 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/detector/AlignmentPatternFinder.d.ts +82 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/detector/Detector.d.ts +87 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/detector/FinderPattern.d.ts +26 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/detector/FinderPatternFinder.d.ts +114 -0
- package/lib/node/lib/zxing-js/src/core/qrcode/detector/FinderPatternInfo.d.ts +16 -0
- package/lib/node/lib/zxing-js/src/core/util/Arrays.d.ts +45 -0
- package/lib/node/lib/zxing-js/src/core/util/Charset.d.ts +7 -0
- package/lib/node/lib/zxing-js/src/core/util/Float.d.ts +14 -0
- package/lib/node/lib/zxing-js/src/core/util/Integer.d.ts +19 -0
- package/lib/node/lib/zxing-js/src/core/util/StringBuilder.d.ts +21 -0
- package/lib/node/lib/zxing-js/src/core/util/StringEncoding.d.ts +51 -0
- package/lib/node/lib/zxing-js/src/core/util/System.d.ts +10 -0
- package/lib/node/lib/zxing-js/src/customTypings.d.ts +16 -0
- package/lib/node/lib/zxing-js/src/index.d.ts +5 -0
- package/lib/node/lib/zxing-js/src/node.d.ts +1 -0
- package/lib/node/license/LicenseManager.d.ts +69 -0
- package/lib/node/license/LicenseManagerNode.d.ts +64 -0
- package/lib/node/node.d.ts +88 -0
- package/lib/node/options-demo.d.ts +239 -0
- package/lib/node/plugins/QRBorderHelpers.d.ts +32 -0
- package/lib/node/plugins/QRBorderPlugin.d.ts +35 -0
- package/lib/node/plugins/QRValidatorZbar.d.ts +38 -0
- package/lib/node/plugins/QRValidatorZbarNode.d.ts +60 -0
- package/lib/node/plugins/QRValidatorZbarNodeSharp.d.ts +83 -0
- package/lib/node/templates/borders-inner-outter.d.ts +129 -0
- package/lib/node/templates/borders-inner-scale-offset.d.ts +497 -0
- package/lib/node/templates/borders-inner.d.ts +129 -0
- package/lib/node/templates/borders-no-license.d.ts +129 -0
- package/lib/node/templates/borders-outter.d.ts +129 -0
- package/lib/node/templates/borders-text-auto-curved.d.ts +129 -0
- package/lib/node/templates/borders-text-full-curved.d.ts +133 -0
- package/lib/node/templates/borders.d.ts +129 -0
- package/lib/node/templates/scales.d.ts +130 -0
- package/lib/node/templates/scan-validators/index.d.ts +1 -0
- package/lib/node/templates/scan-validators/tests/cases/basic-inverted.d.ts +9 -0
- package/lib/node/templates/scan-validators/tests/cases/basic-no-license.d.ts +3 -0
- package/lib/node/templates/scan-validators/tests/cases/basic.d.ts +3 -0
- package/lib/node/templates/scan-validators/tests/cases/colors-inverted.d.ts +2 -0
- package/lib/node/templates/scan-validators/tests/cases/colors.d.ts +58 -0
- package/lib/node/templates/scan-validators/tests/cases/out-of-borders-inverted.d.ts +9 -0
- package/lib/node/templates/scan-validators/tests/cases/out-of-borders.d.ts +9 -0
- package/lib/node/templates/scan-validators/tests/cases/position-inverted.d.ts +9 -0
- package/lib/node/templates/scan-validators/tests/cases/position.d.ts +3 -0
- package/lib/node/templates/scan-validators/tests/index.d.ts +27 -0
- package/lib/node/tools/browser-image-tools.d.ts +7 -0
- package/lib/node/tools/browser-utils.d.ts +18 -0
- package/lib/node/types/helper.d.ts +23 -0
- package/lib/node/types/style-options.d.ts +37 -0
- package/lib/node/utils/canvas-options.d.ts +7 -0
- package/lib/node/utils/color.d.ts +4 -0
- package/lib/node/utils/gradient.d.ts +26 -0
- package/lib/node/utils/image.d.ts +16 -0
- package/lib/node/utils/merge.d.ts +5 -0
- package/lib/node/utils/options.d.ts +220 -0
- package/lib/node/utils/qrcode.d.ts +8 -0
- package/lib/node/utils/scan-validator-node.d.ts +15 -0
- package/lib/node/utils/scan-validator-zxing-node.d.ts +18 -0
- package/lib/node/utils/scan-validators/abstract-scan-validator.d.ts +43 -0
- package/lib/node/utils/scan-validators/zbar-scan-validator.d.ts +8 -0
- package/lib/node/utils/scan-validators/zxing-canvas-scan-validator.d.ts +10 -0
- package/lib/node/utils/scan-validators/zxing-scan-validator.d.ts +8 -0
- package/lib/node/utils/style-mapper.d.ts +13 -0
- package/lib/node/utils/svg.d.ts +2 -0
- package/lib/node/utils/token-validator.d.ts +19 -0
- package/lib/node.d.ts +4 -1
- package/lib/node.js +1 -1
- package/package.json +1 -1
@@ -0,0 +1,69 @@
|
|
1
|
+
import { type DecodedLicenseToken } from '../utils/token-validator';
|
2
|
+
export declare const STORAGE_KEY = "QRCodeJsLicense";
|
3
|
+
export type LicenseReasonCode = // Export the type
|
4
|
+
'DOMAIN_MISMATCH' | 'TOKEN_EXPIRED' | 'TOKEN_INVALID' | 'FETCH_FAILED' | 'KEY_INVALID';
|
5
|
+
export interface ValidationResult {
|
6
|
+
isValid: boolean;
|
7
|
+
token: string | null;
|
8
|
+
license: DecodedLicenseToken | null;
|
9
|
+
reason?: LicenseReasonCode;
|
10
|
+
}
|
11
|
+
export declare class LicenseManager {
|
12
|
+
private static _instance;
|
13
|
+
private static _defaultLicenseApiUrl;
|
14
|
+
private static _currentHostname;
|
15
|
+
private _hls;
|
16
|
+
private _decodedToken;
|
17
|
+
private _licenseKey;
|
18
|
+
private _isInitialized;
|
19
|
+
private _initPromise;
|
20
|
+
private _licenseFetcher;
|
21
|
+
private constructor();
|
22
|
+
/**
|
23
|
+
* Gets the singleton instance of LicenseManager.
|
24
|
+
*/
|
25
|
+
static get instance(): LicenseManager;
|
26
|
+
/**
|
27
|
+
* Sets the default URL used by the built-in license fetcher.
|
28
|
+
* Call this *before* activating with a key if you are not providing a custom fetcher.
|
29
|
+
* @param url The new default URL for fetching license tokens.
|
30
|
+
*/
|
31
|
+
static setDefaultLicenseApiUrl(url: string): void;
|
32
|
+
get hls(): boolean;
|
33
|
+
get isInitialized(): boolean;
|
34
|
+
getLicenseDetails(): DecodedLicenseToken | null;
|
35
|
+
get licenseKey(): string | null;
|
36
|
+
/**
|
37
|
+
* Configures the function used to fetch a license token from a key.
|
38
|
+
* @param fetcher A function that accepts a license key string and returns a Promise<string> (the token).
|
39
|
+
*/
|
40
|
+
configureLicenseFetcher(fetcher: (licenseKey: string) => Promise<string>): void;
|
41
|
+
initialize(): Promise<boolean>;
|
42
|
+
private _performInitialization;
|
43
|
+
/**
|
44
|
+
* Resets the initialization state, forcing re-initialization on the next call to initialize().
|
45
|
+
*/
|
46
|
+
resetInitialization(): void;
|
47
|
+
/**
|
48
|
+
* Resets the current license state (hls, decodedToken, licenseKey).
|
49
|
+
*/
|
50
|
+
resetLicenseState(): void;
|
51
|
+
/**
|
52
|
+
* Activates the license using a pre-fetched JWT token.
|
53
|
+
* Pass `null` to explicitly clear the current license state.
|
54
|
+
* @param token The JWT token string, or null to clear the license.
|
55
|
+
* @returns {Promise<ValidationResult>} The result of the validation.
|
56
|
+
*/
|
57
|
+
activateWithToken(token: string | null): Promise<ValidationResult>;
|
58
|
+
/**
|
59
|
+
* Activates the license using a license key, fetching a token if necessary.
|
60
|
+
* @param licenseKey The license key string.
|
61
|
+
* @returns {Promise<ValidationResult>} The result of the validation.
|
62
|
+
*/
|
63
|
+
activateWithKey(licenseKey: string): Promise<ValidationResult>;
|
64
|
+
private _checkDomain;
|
65
|
+
private _logValidationWarning;
|
66
|
+
private _getStoredLicenseData;
|
67
|
+
private _setStoredLicenseData;
|
68
|
+
private _validateAndStoreToken;
|
69
|
+
}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
import { type DecodedLicenseToken } from '../utils/token-validator';
|
2
|
+
export interface ValidationResult {
|
3
|
+
isValid: boolean;
|
4
|
+
token: string | null;
|
5
|
+
license: DecodedLicenseToken | null;
|
6
|
+
}
|
7
|
+
export declare class LicenseManagerNode {
|
8
|
+
private static _instance;
|
9
|
+
private static _defaultLicenseApiUrl;
|
10
|
+
private _hls;
|
11
|
+
private _decodedToken;
|
12
|
+
private _licenseKey;
|
13
|
+
private _storedToken;
|
14
|
+
private _storedKey;
|
15
|
+
private _isInitialized;
|
16
|
+
private _initPromise;
|
17
|
+
private _licenseFetcher;
|
18
|
+
private constructor();
|
19
|
+
/**
|
20
|
+
* Gets the singleton instance of LicenseManagerNode.
|
21
|
+
*/
|
22
|
+
static get instance(): LicenseManagerNode;
|
23
|
+
/**
|
24
|
+
* Sets the default absolute URL used by the built-in license fetcher.
|
25
|
+
* MUST be called before activating with a key if not providing a custom fetcher.
|
26
|
+
* @param url The new default absolute URL for fetching license tokens.
|
27
|
+
*/
|
28
|
+
static setDefaultLicenseApiUrl(url: string): void;
|
29
|
+
get hls(): boolean;
|
30
|
+
get isInitialized(): boolean;
|
31
|
+
getLicenseDetails(): DecodedLicenseToken | null;
|
32
|
+
get licenseKey(): string | null;
|
33
|
+
/**
|
34
|
+
* Configures the function used to fetch a license token from a key.
|
35
|
+
* @param fetcher A function that accepts a license key string and returns a Promise<string> (the token).
|
36
|
+
*/
|
37
|
+
configureLicenseFetcher(fetcher: (licenseKey: string) => Promise<string>): void;
|
38
|
+
initialize(): Promise<boolean>;
|
39
|
+
private _performInitialization;
|
40
|
+
/**
|
41
|
+
* Resets the initialization state, forcing re-initialization on the next call to initialize().
|
42
|
+
*/
|
43
|
+
resetInitialization(): void;
|
44
|
+
/**
|
45
|
+
* Resets the current license state (hls, decodedToken, licenseKey).
|
46
|
+
*/
|
47
|
+
resetLicenseState(): void;
|
48
|
+
/**
|
49
|
+
* Activates the license using a pre-fetched JWT token.
|
50
|
+
* Pass `null` to explicitly clear the current license state.
|
51
|
+
* @param token The JWT token string, or null to clear the license.
|
52
|
+
* @returns {Promise<ValidationResult>} The result of the validation.
|
53
|
+
*/
|
54
|
+
activateWithToken(token: string | null): Promise<ValidationResult>;
|
55
|
+
/**
|
56
|
+
* Activates the license using a license key, fetching a token if necessary.
|
57
|
+
* @param licenseKey The license key string.
|
58
|
+
* @returns {Promise<ValidationResult>} The result of the validation.
|
59
|
+
*/
|
60
|
+
activateWithKey(licenseKey: string): Promise<ValidationResult>;
|
61
|
+
private _getStoredLicenseData;
|
62
|
+
private _setStoredLicenseData;
|
63
|
+
private _validateAndStoreToken;
|
64
|
+
}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
import { QRCodeJs as _QRCodeJs } from './core/qr-code-js';
|
2
|
+
import { type ValidationResult } from './license/LicenseManagerNode';
|
3
|
+
import type * as _browserUtils from './tools/browser-utils';
|
4
|
+
import { RecursivePartial } from './types/helper';
|
5
|
+
import { StyleOptions } from './types/style-options';
|
6
|
+
import { Options } from './utils/options';
|
7
|
+
import { ScanValidatorResponse } from './utils/scan-validators/abstract-scan-validator';
|
8
|
+
import { type DecodedLicenseToken } from './utils/token-validator';
|
9
|
+
export { ErrorCorrectionLevel, Mode, TypeNumber } from '~/lib/qrcode/QRCodeMinimal';
|
10
|
+
export { type ExtensionFunction } from './core/qr-code-js';
|
11
|
+
export { FileExtension } from './tools/browser-utils';
|
12
|
+
export { type RecursivePartial } from './types/helper';
|
13
|
+
export { type CanvasOptions } from './utils/canvas-options';
|
14
|
+
export { GradientType, type Gradient } from './utils/gradient';
|
15
|
+
export { CornerDotType, CornerSquareType, DotType, ImageMode, ShapeType, type Options } from './utils/options';
|
16
|
+
export { ErrorCorrectionPercents } from './utils/qrcode';
|
17
|
+
export declare const browserUtils: typeof _browserUtils | undefined;
|
18
|
+
export declare class QRCodeJs extends _QRCodeJs {
|
19
|
+
static initializeIfNeeded(): Promise<boolean>;
|
20
|
+
static get hls(): boolean;
|
21
|
+
protected _hls(): boolean;
|
22
|
+
static getLicenseDetails(): DecodedLicenseToken | null;
|
23
|
+
static configureLicenseFetcher(fetcher: (licenseKey: string) => Promise<string>): void;
|
24
|
+
static token(token: string | null): Promise<ValidationResult>;
|
25
|
+
static license(licenseKey: string): Promise<ValidationResult>;
|
26
|
+
/**
|
27
|
+
* Sets the absolute URL used by the built-in license fetcher.
|
28
|
+
* MUST be called before using .license('key') if not providing a custom fetcher.
|
29
|
+
* @param url The absolute URL for fetching license tokens (e.g., https://api.example.com/get-token).
|
30
|
+
*/
|
31
|
+
static setLicenseUrl(url: string): typeof QRCodeJs;
|
32
|
+
static _xmldomSync: any;
|
33
|
+
static _initPromise: Promise<void> | null;
|
34
|
+
static initXmldom(): Promise<void>;
|
35
|
+
constructor(options: RecursivePartial<Options>, _?: boolean);
|
36
|
+
validateScanning(): Promise<ScanValidatorResponse>;
|
37
|
+
/**
|
38
|
+
* Creates a QRCodeBuilder instance initialized with a specific template.
|
39
|
+
* Allows for fluent configuration chaining. We need it here to avoid circular dependency
|
40
|
+
* @param templateName - The name of the template to start with.
|
41
|
+
* @param templateNameOrOptions - The name of the template or a partial options object to start with.
|
42
|
+
* @returns A new QRCodeBuilder instance.
|
43
|
+
*/
|
44
|
+
static useTemplate(templateNameOrOptions: string | RecursivePartial<Options>): QRCodeBuilder;
|
45
|
+
/**
|
46
|
+
* Creates a QRCodeBuilder instance initialized with a specific style.
|
47
|
+
* Allows for fluent configuration chaining.
|
48
|
+
* @param styleNameOrOptions - The name of the predefined style or a StyleOptions object.
|
49
|
+
* @returns A new QRCodeBuilder instance.
|
50
|
+
*/
|
51
|
+
static useStyle(styleNameOrOptions: string | StyleOptions): QRCodeBuilder;
|
52
|
+
}
|
53
|
+
declare class QRCodeBuilder {
|
54
|
+
protected config: RecursivePartial<Options>;
|
55
|
+
/**
|
56
|
+
* Creates a new QRCodeBuilder instance.
|
57
|
+
* @param templateNameOrOptions - Optional name of a predefined template or a partial options object to start with.
|
58
|
+
*/
|
59
|
+
constructor(templateNameOrOptions?: string | RecursivePartial<Options>);
|
60
|
+
/**
|
61
|
+
* Applies a template to the builder's configuration. Template options
|
62
|
+
* will be overridden by subsequently chained .style() or .options() calls.
|
63
|
+
* @param templateNameOrOptions - The name of the template or a partial options object to apply.
|
64
|
+
* @returns The builder instance for chaining.
|
65
|
+
*/
|
66
|
+
useTemplate(templateNameOrOptions: string | RecursivePartial<Options>): this;
|
67
|
+
/**
|
68
|
+
* Applies style options to the builder's configuration.
|
69
|
+
* @param styleNameOrOptions - Name of a predefined style or Style options object to apply.
|
70
|
+
* @returns The builder instance for chaining.
|
71
|
+
*/
|
72
|
+
useStyle(styleNameOrOptions: string | StyleOptions): this;
|
73
|
+
/**
|
74
|
+
* Merges the provided options into the builder's configuration.
|
75
|
+
* @param options - A partial options object to merge.
|
76
|
+
* @returns The builder instance for chaining.
|
77
|
+
*/
|
78
|
+
options(options: RecursivePartial<Options>): QRCodeJs;
|
79
|
+
/**
|
80
|
+
* Builds the QRCodeJs instance with the accumulated configuration.
|
81
|
+
* @returns The created QRCodeJs instance.
|
82
|
+
*/
|
83
|
+
build(): QRCodeJs;
|
84
|
+
}
|
85
|
+
export declare class _ extends QRCodeJs {
|
86
|
+
protected _hls(): boolean;
|
87
|
+
constructor(options: RecursivePartial<Options>);
|
88
|
+
}
|
@@ -0,0 +1,239 @@
|
|
1
|
+
import { ShapeType } from './utils/options';
|
2
|
+
export declare const options2: {
|
3
|
+
shape: ShapeType;
|
4
|
+
verticalOffset: number;
|
5
|
+
isResponive: string;
|
6
|
+
margin: number;
|
7
|
+
scale: number;
|
8
|
+
data: string;
|
9
|
+
image: string;
|
10
|
+
dotsOptions: {
|
11
|
+
type: string;
|
12
|
+
color: string;
|
13
|
+
size: number;
|
14
|
+
};
|
15
|
+
backgroundOptions: {
|
16
|
+
color: string;
|
17
|
+
};
|
18
|
+
cornersDotOptions: {
|
19
|
+
type: string;
|
20
|
+
color: string;
|
21
|
+
};
|
22
|
+
cornersSquareOptions: {
|
23
|
+
type: string;
|
24
|
+
color: string;
|
25
|
+
};
|
26
|
+
imageOptions: {
|
27
|
+
crossOrigin: string;
|
28
|
+
imageSize: number;
|
29
|
+
margin: number;
|
30
|
+
};
|
31
|
+
borderOptions: {
|
32
|
+
hasBorder: boolean;
|
33
|
+
radius: string;
|
34
|
+
thickness: number;
|
35
|
+
inner: {
|
36
|
+
radius: string;
|
37
|
+
scale: number;
|
38
|
+
horizontalOffset: number;
|
39
|
+
verticalOffset: number;
|
40
|
+
};
|
41
|
+
color: string;
|
42
|
+
decorations: {
|
43
|
+
top: {
|
44
|
+
disabled: boolean;
|
45
|
+
enableText: boolean;
|
46
|
+
offset: number;
|
47
|
+
curveAdjustment: number;
|
48
|
+
curveDisabled: boolean;
|
49
|
+
curveRadius: string;
|
50
|
+
type: string;
|
51
|
+
value: string;
|
52
|
+
style: {
|
53
|
+
fontFace: string;
|
54
|
+
fontSize: number;
|
55
|
+
fontColor: string;
|
56
|
+
letterSpacing: number;
|
57
|
+
fontWeight: string;
|
58
|
+
};
|
59
|
+
};
|
60
|
+
bottom: {
|
61
|
+
disabled: boolean;
|
62
|
+
enableText: boolean;
|
63
|
+
offset: number;
|
64
|
+
curveAdjustment: number;
|
65
|
+
curveRadius: string;
|
66
|
+
curveDisabled: boolean;
|
67
|
+
type: string;
|
68
|
+
value: string;
|
69
|
+
style: {
|
70
|
+
fontFace: string;
|
71
|
+
fontSize: number;
|
72
|
+
fontColor: string;
|
73
|
+
letterSpacing: number;
|
74
|
+
fontWeight: string;
|
75
|
+
};
|
76
|
+
};
|
77
|
+
left: {
|
78
|
+
disabled: boolean;
|
79
|
+
enableText: boolean;
|
80
|
+
offset: number;
|
81
|
+
curveAdjustment: number;
|
82
|
+
curveRadius: string;
|
83
|
+
curveDisabled: boolean;
|
84
|
+
type: string;
|
85
|
+
value: string;
|
86
|
+
style: {
|
87
|
+
fontFace: string;
|
88
|
+
fontSize: number;
|
89
|
+
fontColor: string;
|
90
|
+
letterSpacing: number;
|
91
|
+
fontWeight: string;
|
92
|
+
};
|
93
|
+
};
|
94
|
+
right: {
|
95
|
+
disabled: boolean;
|
96
|
+
enableText: boolean;
|
97
|
+
offset: number;
|
98
|
+
curveAdjustment: number;
|
99
|
+
curveDisabled: boolean;
|
100
|
+
curveRadius: string;
|
101
|
+
type: string;
|
102
|
+
value: string;
|
103
|
+
style: {
|
104
|
+
fontFace: string;
|
105
|
+
fontSize: number;
|
106
|
+
fontColor: string;
|
107
|
+
letterSpacing: number;
|
108
|
+
fontWeight: string;
|
109
|
+
};
|
110
|
+
};
|
111
|
+
};
|
112
|
+
borderOuter: {
|
113
|
+
color: string;
|
114
|
+
thickness: number;
|
115
|
+
};
|
116
|
+
borderInner: {
|
117
|
+
color: string;
|
118
|
+
thickness: number;
|
119
|
+
};
|
120
|
+
};
|
121
|
+
};
|
122
|
+
export declare const options: {
|
123
|
+
name: string;
|
124
|
+
description: string;
|
125
|
+
data: string;
|
126
|
+
image: string;
|
127
|
+
margin: number;
|
128
|
+
verticalOffset: number;
|
129
|
+
scale: number;
|
130
|
+
shape: string;
|
131
|
+
qrOptions: {};
|
132
|
+
imageOptions: {
|
133
|
+
imageSize: number;
|
134
|
+
margin: number;
|
135
|
+
roundedValue: number;
|
136
|
+
};
|
137
|
+
dotsOptions: {
|
138
|
+
type: string;
|
139
|
+
color: string;
|
140
|
+
};
|
141
|
+
cornersSquareOptions: {
|
142
|
+
type: string;
|
143
|
+
color: string;
|
144
|
+
};
|
145
|
+
cornersDotOptions: {
|
146
|
+
type: string;
|
147
|
+
color: string;
|
148
|
+
};
|
149
|
+
backgroundOptions: {
|
150
|
+
color: string;
|
151
|
+
gradient: {
|
152
|
+
type: string;
|
153
|
+
colorStops: {
|
154
|
+
offset: number;
|
155
|
+
color: string;
|
156
|
+
}[];
|
157
|
+
};
|
158
|
+
};
|
159
|
+
borderOptions: {
|
160
|
+
hasBorder: boolean;
|
161
|
+
radius: string;
|
162
|
+
innerRadius: string;
|
163
|
+
thickness: number;
|
164
|
+
color: string;
|
165
|
+
isTopBorderOnly: boolean;
|
166
|
+
isBottomBorderOnly: boolean;
|
167
|
+
isTopBottomBorderOnly: boolean;
|
168
|
+
decorations: {
|
169
|
+
top: {
|
170
|
+
enableText: boolean;
|
171
|
+
verticalOffset: number;
|
172
|
+
curveAdjustment: number;
|
173
|
+
disableCurve: boolean;
|
174
|
+
type: string;
|
175
|
+
value: string;
|
176
|
+
style: {
|
177
|
+
fontFace: string;
|
178
|
+
fontSize: number;
|
179
|
+
fontColor: string;
|
180
|
+
letterSpacing: number;
|
181
|
+
fontWeight: string;
|
182
|
+
};
|
183
|
+
};
|
184
|
+
bottom: {
|
185
|
+
enableText: boolean;
|
186
|
+
verticalOffset: number;
|
187
|
+
curveAdjustment: number;
|
188
|
+
disableCurve: boolean;
|
189
|
+
type: string;
|
190
|
+
value: string;
|
191
|
+
style: {
|
192
|
+
fontFace: string;
|
193
|
+
fontSize: number;
|
194
|
+
fontColor: string;
|
195
|
+
letterSpacing: number;
|
196
|
+
fontWeight: string;
|
197
|
+
};
|
198
|
+
};
|
199
|
+
left: {
|
200
|
+
enableText: boolean;
|
201
|
+
verticalOffset: number;
|
202
|
+
curveAdjustment: number;
|
203
|
+
disableCurve: boolean;
|
204
|
+
type: string;
|
205
|
+
value: string;
|
206
|
+
style: {
|
207
|
+
fontFace: string;
|
208
|
+
fontSize: number;
|
209
|
+
fontColor: string;
|
210
|
+
letterSpacing: number;
|
211
|
+
fontWeight: string;
|
212
|
+
};
|
213
|
+
};
|
214
|
+
right: {
|
215
|
+
enableText: boolean;
|
216
|
+
verticalOffset: number;
|
217
|
+
curveAdjustment: number;
|
218
|
+
disableCurve: boolean;
|
219
|
+
type: string;
|
220
|
+
value: string;
|
221
|
+
style: {
|
222
|
+
fontFace: string;
|
223
|
+
fontSize: number;
|
224
|
+
fontColor: string;
|
225
|
+
letterSpacing: number;
|
226
|
+
fontWeight: string;
|
227
|
+
};
|
228
|
+
};
|
229
|
+
};
|
230
|
+
borderOuter: {
|
231
|
+
color: string;
|
232
|
+
thickness: number;
|
233
|
+
};
|
234
|
+
borderInner: {
|
235
|
+
color: string;
|
236
|
+
thickness: number;
|
237
|
+
};
|
238
|
+
};
|
239
|
+
};
|
@@ -0,0 +1,32 @@
|
|
1
|
+
export type Position = 'top' | 'bottom' | 'left' | 'right';
|
2
|
+
export type DecorationType = 'text' | 'image';
|
3
|
+
export declare const Positions: Record<Position, Position>;
|
4
|
+
export interface BorderOffsets {
|
5
|
+
left?: number;
|
6
|
+
right?: number;
|
7
|
+
top?: number;
|
8
|
+
bottom?: number;
|
9
|
+
}
|
10
|
+
export declare function computeBorderOffsets(thickness: number, noBorderThickness: number, enabledBorders: {
|
11
|
+
top: boolean;
|
12
|
+
right: boolean;
|
13
|
+
bottom: boolean;
|
14
|
+
left: boolean;
|
15
|
+
}): BorderOffsets;
|
16
|
+
export declare const buildTransform: (rotate: number, flip: boolean, width: number, height: number) => string;
|
17
|
+
export declare function computeTextPathOffset(position: Position, // 'top' | 'bottom' | 'left' | 'right'
|
18
|
+
thickness: number, // main border thickness
|
19
|
+
noBorderThickness: number, // fallback thickness if side is disabled
|
20
|
+
enabledBorders: {
|
21
|
+
[key in Position]: boolean;
|
22
|
+
}): {
|
23
|
+
x: number;
|
24
|
+
y: number;
|
25
|
+
};
|
26
|
+
export declare const calculatePathDimensions: (size: number, thickness: number, outerBorderPadding: number, offset: number, borderOffsets?: BorderOffsets) => {
|
27
|
+
startX: number;
|
28
|
+
startY: number;
|
29
|
+
pathWidth: number;
|
30
|
+
};
|
31
|
+
export declare const getRoundValue: (round: string | number) => number;
|
32
|
+
export declare const addProcentageToRadius: (radius: string | undefined, defaultRadius?: string | number) => string | number;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { Gradient } from '../utils/gradient';
|
2
|
+
import { BorderOptions } from '../utils/options.js';
|
3
|
+
import { Position } from './QRBorderHelpers.js';
|
4
|
+
export interface QRBorderPluginStyleOptions {
|
5
|
+
fontFace?: string;
|
6
|
+
fontSize?: number;
|
7
|
+
fontColor?: string;
|
8
|
+
letterSpacing?: number;
|
9
|
+
fontWeight?: string;
|
10
|
+
}
|
11
|
+
interface QRPluginSettings {
|
12
|
+
width?: number;
|
13
|
+
height?: number;
|
14
|
+
document: Document;
|
15
|
+
instanceId: number;
|
16
|
+
backgroundOptions?: {
|
17
|
+
/** Background roundnes, from 0 (square) to 1 (circle) */
|
18
|
+
round?: number;
|
19
|
+
/** Background color */
|
20
|
+
color?: string;
|
21
|
+
/** Background Gradient */
|
22
|
+
gradient?: Gradient;
|
23
|
+
} | false;
|
24
|
+
}
|
25
|
+
type QRBorderPluginFn = (options: BorderOptions) => (svgElement: SVGElement, settings: QRPluginSettings, svgSize: number, drawBackgroundForBorder: (padding: number, baseRadius: number) => SVGElement | undefined, bordersMain: {
|
26
|
+
[key in Position]: number;
|
27
|
+
}, bordersOuter: {
|
28
|
+
[key in Position]: number;
|
29
|
+
}, bordersInner: {
|
30
|
+
[key in Position]: number;
|
31
|
+
}, noBorderThickness: number, hs: () => boolean) => void;
|
32
|
+
export declare const isBorderSideEnabled: (options: BorderOptions, position: Position) => boolean;
|
33
|
+
export declare const isBorderSideEnabledBottom: (options: BorderOptions, position: Position, _hls: boolean) => boolean;
|
34
|
+
declare const QRBorderPlugin: QRBorderPluginFn;
|
35
|
+
export { QRBorderPlugin };
|
@@ -0,0 +1,38 @@
|
|
1
|
+
export default QRValidatorZbar;
|
2
|
+
declare class QRValidatorZbar {
|
3
|
+
constructor(options?: {});
|
4
|
+
canvas: HTMLCanvasElement;
|
5
|
+
context: CanvasRenderingContext2D | null;
|
6
|
+
maxRetries: any;
|
7
|
+
retryInterval: any;
|
8
|
+
/**
|
9
|
+
* Validate and decode a QR code from an image
|
10
|
+
* @param {HTMLImageElement|File|Blob|String} input - Input image (can be an image element, file, blob or data URL)
|
11
|
+
* @returns {Promise<Object>} - Validation results with decoded data if successful
|
12
|
+
*/
|
13
|
+
validate(input: HTMLImageElement | File | Blob | string, width: any, height: any): Promise<Object>;
|
14
|
+
/**
|
15
|
+
* Load image from various sources
|
16
|
+
* @param {HTMLImageElement|File|Blob|String} input - Input image
|
17
|
+
* @returns {Promise<HTMLImageElement>} - Loaded image
|
18
|
+
*/
|
19
|
+
loadImage(input: HTMLImageElement | File | Blob | string): Promise<HTMLImageElement>;
|
20
|
+
/**
|
21
|
+
* Sleep function to wait between retry attempts
|
22
|
+
* @param {number} ms - Milliseconds to wait
|
23
|
+
* @returns {Promise<void>}
|
24
|
+
*/
|
25
|
+
sleep(ms: number): Promise<void>;
|
26
|
+
/**
|
27
|
+
* Decode QR code with automatic retry
|
28
|
+
* @param {ImageData} imageData - Raw image data
|
29
|
+
* @returns {Promise<Object>} - Validation result after retries
|
30
|
+
*/
|
31
|
+
decodeQRWithRetry(imageData: ImageData): Promise<Object>;
|
32
|
+
/**
|
33
|
+
* Decode QR code from image data using zbar-wasm
|
34
|
+
* @param {ImageData} imageData - Raw image data
|
35
|
+
* @returns {Promise<Object>} - Validation result
|
36
|
+
*/
|
37
|
+
decodeQR(imageData: ImageData): Promise<Object>;
|
38
|
+
}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
/**
|
2
|
+
* QRValidatorZbar Validation Library for Node.js
|
3
|
+
*
|
4
|
+
* This server-side class uses zbar-wasm to decode QR codes and other barcodes,
|
5
|
+
* with Jimp (and Resvg for SVG conversion) for image processing.
|
6
|
+
*/
|
7
|
+
interface QRValidatorOptions {
|
8
|
+
/** Maximum number of retry attempts */
|
9
|
+
maxRetries?: number;
|
10
|
+
/** Time to wait between retries in milliseconds */
|
11
|
+
retryInterval?: number;
|
12
|
+
/** Enable debug logging */
|
13
|
+
debug?: boolean;
|
14
|
+
}
|
15
|
+
interface QRValidationResult {
|
16
|
+
/** Whether the validation was successful */
|
17
|
+
isValid: boolean;
|
18
|
+
/** Decoded data from the QR code (if successful) */
|
19
|
+
data?: string;
|
20
|
+
/** Format of the detected barcode */
|
21
|
+
format?: string;
|
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;
|
30
|
+
}
|
31
|
+
declare class QRValidatorZbarNode {
|
32
|
+
private maxRetries;
|
33
|
+
private retryInterval;
|
34
|
+
private debug;
|
35
|
+
constructor(options?: QRValidatorOptions);
|
36
|
+
private log;
|
37
|
+
/**
|
38
|
+
* Validate and decode a QR code from an SVG string (or file path)
|
39
|
+
*/
|
40
|
+
validate(input: string, isInverted?: boolean): Promise<QRValidationResult>;
|
41
|
+
private sleep;
|
42
|
+
/**
|
43
|
+
* Process image using Sharp and get raw pixel data
|
44
|
+
* @param input Input image
|
45
|
+
* @param width Optional width for resizing
|
46
|
+
* @param height Optional height for resizing
|
47
|
+
* @returns Processed image data compatible with zbar-wasm
|
48
|
+
*/
|
49
|
+
private processImageResvg;
|
50
|
+
private validateWithRetry;
|
51
|
+
/**
|
52
|
+
* Save a debug image using Jimp. The raw image data is used to reconstruct an image.
|
53
|
+
*/
|
54
|
+
private saveDebugImage;
|
55
|
+
/**
|
56
|
+
* Decode the QR code from image data using zbar-wasm.
|
57
|
+
*/
|
58
|
+
private decodeQR;
|
59
|
+
}
|
60
|
+
export default QRValidatorZbarNode;
|